comp.lang.ada
 help / color / mirror / Atom feed
From: Paul van Delst <pvandelst@ncep.noaa.gov>
Subject: Re: F9X twister & ADA (was: n-dim'l vectors)
Date: 2000/04/07
Date: 2000-04-07T00:00:00+00:00	[thread overview]
Message-ID: <38EE44A3.AC8244AC@ncep.noaa.gov> (raw)
In-Reply-To: 38ED4ECA.ADB698C9@sdynamix.com

bv wrote:
> 
> Paul van Delst wrote:
> >
> > nsavvinv2@my-deja.com wrote:
> > > Can a function return an n-dimensional vector?
> >
> > Sure - in f90 at least....dunno about f77. I got it to work for vectors
> > by using INTERFACE blocks in the code that calls the function, e.g.
> >
> > FUNCTION my_func ( x, y ) RESULT ( z )
> >
> >   IMPLICIT NONE
> >   INTEGER, INTENT( IN ), DIMENSION( : )         :: x, y
> >   INTEGER,               DIMENSION( SIZE( x ) ) :: z
> >
> >   z(:) = x(:) + y(:)   ! Assumes x and y are the same size
> >
> >   RETURN
> >
> > END FUNCTION my_func
> >
> > and then in the calling program:
> >
> > PROGRAM blah
> >
> >   IMPLICIT NONE
> >
> >   INTERFACE
> > !   Interface body for my_func
> >     FUNCTION my_func ( x, y ) RESULT ( z )
> >       IMPLICIT NONE
> >       INTEGER, INTENT( IN ), DIMENSION( : )         :: x, y
> >       INTEGER,               DIMENSION( SIZE( x ) ) :: z
> >     END FUNCTION my_func
> >   END INTERFACE
> >
> >   INTEGER, DIMENSION( 5 ) :: x = (/ -1,  1, -1,  1, -1 /), &
> >                              y = (/  1, -1,  1, -1,  1 /)
> >
> >   WRITE( *, '( 5i5 )' ) my_func( x, y )
> >
> > END PROGRAM blah
> 
> What a slaughter of Fortran,

If you're basing this opinion on the code snippet I wrote above - I
defer to your expertise. I don't claim to be a Fortran 'spert or even a
programmer for that matter. (But everyone must aspire to something,
right?) As Dr. Maine pointed out in his reply, this is not the only way
to write the code (I wish you hadn't been as vitriolic as you were in
your response coz I would have liked to have seen his example - I get my
tips where I can, ya know.)

> showing every symptom of design by ignorant
> and incompetent committee. What happened, where they too busy with
> themselves to bother and learn from ADA?? If they did, they'd see
> something along these lines:
> 
>         function normalize(v: in vector) return vector is
>         vni: float;
>         begin
>           vni := 1./norm(v)
>           return (v(x)*vni, v(y)*vni, v(z)*vni);
>         end normalize;
> 
> --      somewhere in your code
>         u,v: vector;
>                 .
>                 .
>                 .
>         u := normalize(v);
> 
> The difference speaks for itself!!

Wow. You're right. I can understand my code. :o)

Sorry for sucking up the bandwidth with this reply, but, jeez, it's
fridy! Strawberry margeritas all round....my shout. 

cheers and avagoodweegend,

paulv
-- 
Paul van Delst           Ph:  (301) 763-8000 x7274 
CIMSS @ NOAA/NCEP        Fax: (301) 763-8545
Rm.202, 5200 Auth Rd.    Email: pvandelst@ncep.noaa.gov
Camp Springs MD 20746




  parent reply	other threads:[~2000-04-07  0:00 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8cctts$ujr$1@nnrp1.deja.com>
     [not found] ` <38EA0440.1ECBC158@ncep.noaa.gov>
2000-04-06  0:00   ` F9X twister & ADA (was: n-dim'l vectors) bv
2000-04-06  0:00     ` Richard Maine
2000-04-07  0:00       ` Brian Rogoff
2000-04-08  0:00         ` Dick Hendrickson
2000-04-08  0:00           ` Richard Maine
2000-04-09  0:00             ` Gary Scott
2000-04-09  0:00               ` Richard Maine
2000-04-09  0:00           ` Geoff Bull
2000-04-09  0:00             ` Dick Hendrickson
2000-04-09  0:00               ` Robert Dewar
2000-04-09  0:00                 ` Gordon Sande
2000-04-09  0:00                   ` James Giles
2000-04-10  0:00                 ` tmoran
2000-04-15  0:00                 ` Aidan Skinner
2000-04-17  0:00                   ` Robert I. Eachus
2000-04-16  0:00                 ` Ken Garlington
2000-04-12  0:00               ` Robert I. Eachus
2000-04-10  0:00       ` bv
2000-04-10  0:00         ` James Van Buskirk
2000-04-11  0:00         ` James Giles
2000-04-11  0:00           ` Dale Stanbrough
2000-04-11  0:00             ` James Giles
2000-04-12  0:00               ` Robert A Duff
2000-04-11  0:00           ` Geoff Bull
2000-04-11  0:00             ` James Giles
2000-04-11  0:00               ` Larry Kilgallen
2000-04-11  0:00                 ` James Giles
2000-04-11  0:00                   ` Larry Kilgallen
2000-04-12  0:00                   ` Robert A Duff
2000-04-12  0:00               ` Geoff Bull
2000-04-12  0:00                 ` James Giles
2000-04-12  0:00                   ` Geoff Bull
2000-04-12  0:00                     ` James Giles
2000-04-12  0:00                       ` Geoff Bull
2000-04-12  0:00                         ` Marin D. Condic
2000-04-12  0:00                           ` James Giles
2000-04-12  0:00                           ` James Giles
2000-04-12  0:00                         ` James Giles
2000-04-13  0:00                           ` Geoff Bull
2000-04-13  0:00                             ` Debugging (was: F9X twister & ADA) James Giles
2000-04-13  0:00                             ` F9X twister & ADA (was: n-dim'l vectors) James Giles
2000-04-14  0:00                               ` Geoff Bull
2000-04-14  0:00           ` bv
2000-04-07  0:00     ` Paul van Delst [this message]
2000-04-10  0:00       ` bv
2000-04-07  0:00     ` Erik Edelmann
2000-04-07  0:00       ` Robert Dewar
2000-04-07  0:00         ` Erik Edelmann
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox