>
> > Is the allocatable component XX%A in MYSUB automatically deallocated
> > upon return from this subroutine?
> >
> The intended answer is yes, it should be automatically deallocated.
> That said, I cannot find direct confirmation of this in Section
> 6.3.3.1 of the F2003 standard.
I find it easier to quote MR&C, Section 12.4:
"When a variable of derived type is deallocated, any ultimate
allocatable component
that is currently allocated is also deallocated, as if by a deallocate
statement. The variable may be a pointer or an allocatable array, and
the rule applies recursively, so that all allocated allocatable
components at all levels (apart from any lying beyond pointer
components)
are deallocated. Such deallocations of components also
occur when a variable is associated with an {intent(out)} dummy
argument.
Note the convenience to the
programmer of this feature; to avoid memory leakage with pointer
components, the programmer would need to deallocate each one explicitly
and be careful to order the deallocations correctly."
Regards,
Mike Metcalf
|