(j3.2006) question about deallocation

Bill Long longb at cray.com
Sat Mar 28 09:06:24 EDT 2009



Robert Corbett wrote:
> Consider the code fragment
>
>        MODULE M
>          . . .
>          TYPE BASE
>            INTEGER I
>          CONTAINS
>            FINAL SUBR1
>          END TYPE
>          TYPE, EXTENDS(BASE) :: EXTENDED
>          CONTAINS
>            FINAL SUBR2
>          END TYPE
>          . . .
>        END MODULE
>
>        PROGRAM MAIN
>          USE M
>          TYPE(EXTENDED), POINTER :: P
>          TYPE(BASE), POINTER :: Q
>          . . .
>          ALLOCATE(P)
>          Q => P%BASE
>          . . .
>          DEALLOCATE(Q)
>          . . .
>        END
>
> Is the DEALLOCATE statement standard conforming?  

The extended type does not add any components, so it looks OK to me.

> If so,
> are both final subroutines invoked, or is only SUBR1
> invoked? 

The type of the object being deallocated is BASE, and a final routine is 
bound to the type, so I would say SUBR1 (only) is executed.

Cheers,
Bill


>  The implementation of deallocation in Sun
> Fortran can easily be extended to support either
> semantics.
>
> Bob Corbett
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://j3-fortran.org/mailman/listinfo/j3
>   

-- 
Bill Long                                   longb at cray.com
Fortran Technical Support    &              voice: 651-605-9024
Bioinformatics Software Development         fax:   651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120

            



More information about the J3 mailing list