(j3.2006) Finalization ordering question
Fri Oct 12 15:42:10 EDT 2007
Michael Ingrassia wrote:
>> This "arrays are just a collection of scalars" idea does not apply
>> here. The user can specify different final routines for scalar and each
>> rank of array objects.
> Arrays as collection of scalars seems to apply even here.
> Or how do you escape [04-007:59:9-11]
> "If the entity being finalized is an array,
> each finalizable component of each element of that entity is
> finalized separately.".
This is Step 2 which only applies if there is something left after Step
1. In general, arrays and scalars are treated differently in the
finalization game. Although in this particular case, it might not be a
> I can't visualize this stuff without examples.
> In the case (apologies for syntax errors)
> MODULE FOO
> TYPE C ! This is a finalizable derived type.
> INTEGER c
> FINAL :: FANCY1, FANCY2
> END TYPE C
> SUBROUTINE FANCY1(FINALIZEE) ! We can finalize scalars of TYPE(C)
> TYPE(C) :: FINALIZEE
> END SUBROUTINE FANCY1
> SUBROUTINE FANCY2(FINALIZEE) ! We can differently finalize arrays
> TYPE(C) :: FINALIZEE(*)
> END SUBROUTINE FANCY2
> END MODULE FOO
> TYPE T ! This is a finalizable basetype.
> TYPE(C) :: ft
> END TYPE T
> TYPE, EXTENDS T :: E ! This is a finalizable extended type.
> TYPE(C) :: fe
> END TYPE E
> TYPE(E) :: X(3) ! X(3) is a finalizable data entity.
> To finalize X(3) following steps (1)-(3) on page 59:
> (1) Nothing to call at this point as E has no final subroutines.
> (2) Finalize the fe component in X(1), X(2), X(3)
> This would be the same as
> CALL FANCY1(X(1)%fe)
> CALL FANCY1(X(2)%fe)
> CALL FANCY1(X(3)%fe)
> I don't see any opportunity at all to be calling FANCY2,
> even if
> CALL FANCY2(X(1:3)%fe)
> would be potentially useful.
> (3) Finalize "the parent component" of entity X(3).
I read this as a mandate to finalize x(1:3)%t. Type T does not have a
final routine, so Step 1 does not apply, and we go to Step 2 and
finalize each element of the array x(1:3)%t%ft. I don't see this as
ambiguous. However, my original question is unchanged - why do we force
the implementation to finalize all the fe's before starting on the ft's?
> The entity X(3) is an array. Therefore it doesn't have a parent
> component, although its type does. Right?
> Structures (which are scalars) have components, and
> derived types have components, but arrays only have elements.
> I don't see that the standard language is correct here, although
> finalizing X(1)%T%ft, X(2)%T%ft, X(3)%T%ft
> seems like a good guess at what is intended.
> What am I misreading?
> In sum: I don't think the standard even spells out what to do
> for Bill's case, so we need an interp.
> --Michael I.
> J3 mailing list
> J3 at j3-fortran.org
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