Hi, Toon,
I'm not an expert on exactly what's in F2002, so hopefully someone
else will confirm or refute on the fine points, but here goes on
the basic issues you raise.
On Wed, 10 May 2000, Toon Moene wrote:
> Clive Page wrote:
>
> > I quite agree. I apologise if I haven't been keeping up at the back, but
> > I'm still slightly confused about what F2002 is going to bring us. At
> > present (in F95) there are three main circumstances in which you need to
> > use pointers:
>
> > 1. When you _really_ want a pointer, e.g. for a linked-list.
>
> > 2. When you want an allocatable component of a derived type.
>
> > 3. When you want to hand an array over as an actual arg to return filled
> > but don't know how many values will be returned so you can't allocate
> > it in advance.
>
> > F2002 solves (2), does it also solve (3)?
AFAIK, yes. I think under F2002, a procedure parameter can have
the ALLOCATABLE attribute.
> I'm coming a bit late in this conversation (been attending a workshop at
> the UK Met. Office the last few days) - but isn't (1) just a specific
> example of (2) ?
No. Recall that in C, a pointer is commonly used either to point to
something else or as an array. This is also true in F9x. F2k attempts
to remove the need for using pointers as arrays. Thus, a component
of a derived type (as in (2)) and a procedure parameter (as in (3))
can have the ALLOCATABLE attribute. Therefore one need not use
Fortran POINTERs to emulate allocatable arrays in these situations.
One can just use ALLOCATABLEs.
Item 1 refers to using a pointer simply to point to some object,
which might or might not have been freshly allocated. The
linked-list example is pertinent; the pointer component would
point to the next link, which would most likely be a scalar, not an
array. When updating the list, or perhaps even just changing the
order of the links, the value of the pointer components would
change to point to different links, without altering the underlying
storage. This couldn't be done with ALLOCATABLEs.
-P.
--
** Whether the playing field is level depends on the coordinate system. ***
********* Peter S. Shenkin; Schrodinger, Inc.; (201)433-2014 x111 *********
*********** [log in to unmask]; http://www.schrodinger.com ***********
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|