Print

Print


Neil Carlson wrote:
>
> Thanks, Richard; I expected you'd be likely to reply first!
>
> >  > INTENT(OUT) asserts that the pointer association
> >  > will be set by the procedure,
> >
> > Not quite.  The procedure does not necessarily need to set it.
> > It is undefined until the procedure does set it, but as long as
> > it doesn't end up getting referenced, it may be fine for it
> > to be undefined.
>
> Do you really mean "undefined" as in can't use ASSOCIATED on it?
> If in the derived type definition the pointer component had been
> initialized with "=> NULL()" would the dummy argument pointer
> component start with the "dissassociated" status, or does the standard
> leave these specifics up to the individual implementation?
>

The standard really does say that an INTENT(OUT) dummy "becomes
undefined" on entry to a procedure.  But, it also says that default
initialization will take place for any components of an INTENT(OUT)
argument.  So, an INTENT(OUT) pointer component would be initialized
to NULL() as part of the entry sequence if the type definition
specified initialization.

As a useless aside, it even works with OPTIONAL.  Given something like
 >   type :: my_type
 >     real, pointer :: x(:) => NULL()
 >   end type my_type
 >     ...
 >   subroutine my_sub (a)
 >   type(my_type), intent(OUT), OPTIONAL :: a
     END
Then
     type (my_type) xxx
     call my_sub (xxx)
is the same as
     xxx%x => NULL()
which surprised me the first time I saw it,
and
     call my_sub()
is a do nothing statement.

Dick Hendrickson


> Neil
> --
> Neil N. Carlson                    Motorola, Los Alamos Research Park
> Motorola Labs / PSRL               4200 W. Jemez Road, Suite 300
> Computational Nanoscience Group    Los Alamos, New Mexico 87544
>
> [log in to unmask]           Fax: (505) 663-5150
> Voice: (505) 663-5106              Pager: [log in to unmask] or
> 888-946-2817