I need some clarification on the use of INTENT with derived type dummy
arguments that contain pointer components. Intent is supposed to refer
to the pointer association status and *not* the target. With that in
mind, have I got the following right?
type :: my_type
real, pointer :: x(:)
end type my_type
...
subroutine my_sub (a, ...)
type(my_type), intent(in) :: a
a % x = 1
This is legal; I'm not altering the pointer association status.
Is INTENT(IN) also an assertion that the pointer is associated?
subroutine my_sub (a, ...)
type(my_type), intent(out) :: a
a % x = 1
This is illegal; INTENT(OUT) asserts that the pointer association
will be set by the procedure, and that on entry the pointer could
in fact be nullified. The one compiler that I use mostly, and trust
the most, gives a warning message that suggests this is the case.
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
|