comp.lang.ada
 help / color / mirror / Atom feed
From: ncohen@watson.ibm.com (Norman H. Cohen)
Subject: Fortran 90 arrays (was: Re: Ada9X Features)
Date: 14 Sep 1994 13:06:05 GMT
Date: 1994-09-14T13:06:05+00:00	[thread overview]
Message-ID: <356sft$oen@watnews1.watson.ibm.com> (raw)
In-Reply-To: 3550l2$8o7@schonberg.cs.nyu.edu

In article <3550l2$8o7@schonberg.cs.nyu.edu>, dewar@cs.nyu.edu (Robert Dewar)
writes: 

|>         Arrays in Fortran are passed by address only, and bounds information
|> is not passed (note I am talking up through 77 here, who knows what they
|> have wrought in 90 -- well probbaly some reader of this group does :-)
|>

Fortran 90 has "assumed shape arrays".  If a dummy argument (that's
Fortranese for formal parameter) named A is declared

       dimension(:,:)::A

for example, it's a two dimensional assumed-shape array that gets its
bounds from the actual argument.  A subroutine with such an argument must
be declared in an interface block--roughly analogous to an Ada subprogram
or package declaration.  That alerts the compiler to pass a descriptor
for the array, containing bounds information, rather than just the
address of the array.  This preserves upward compatibility, because
arrays can be passed to old-style subroutines by address, allowing the
conventional Fortran overlay tricks to be used within those subroutines.
There are intrinsic functions analogous to the Ada 'First(n) and 'Last(n)
attributes.

Fortran 90 also has "deferred shape arrays," analogous to values in
access types designating unconstrained array subtypes.  Such arrays are
allocated dynamically by specifying their bounds in an Allocate
statement.  A conspicuous difference is that Fortran 90 pointers are
dereferenced implicitly, like C++ references.

Ada programmers will find a number of familiar terms and programming
mechanisms in Fortran 90.  Unfortunately, the correspondence between the
terms and the mechanisms is not the same as in Ada.  For example,
Fortran 90 has record types, but they're called derived types!  Fortran
90 has overloaded declarations, but they're called generic interfaces!

--
Norman H. Cohen    ncohen@watson.ibm.com



  reply	other threads:[~1994-09-14 13:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-12 15:12 Ada9X Features Michael Hagerty
1994-09-13 16:08 ` Michael Feldman
1994-09-13 20:04   ` Robert Dewar
1994-09-14 13:06     ` Norman H. Cohen [this message]
1994-09-16  1:39     ` Michael Feldman
1994-09-14  9:15   ` Richard A. O'Keefe
1994-09-14 14:26     ` Michael Feldman
1994-09-21  6:03       ` ISO Pascal Extended Richard A. O'Keefe
replies disabled

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