(j3.2006) ELEMENTAL finalizers vs. finalizing elementally
Mon Apr 14 12:14:28 EDT 2008
Here's a confusing case.
I remember discussions impinging on this but not the details.
REAL :: X, Y
FINAL :: S
END TYPE POINT
SUBROUTINE S(P) ! not ELEMENTAL
PRINT *, 'Finalizer was called'
END SUBROUTINE S
END MODULE FOO
TYPE(POINT), ALLOCATABLE :: A(:)
DEALLOCATE(A) ! Finalization would occur here
A is of a finalizable type and ought to be finalized when deallocated
A is an array.
You can't finalize all of A at once by calling a finalizer, because there
aren't any rank-1 finalizers in sight nor any elemental finalizers in
Conceivably you could finalize each element of array A separately by
calling S once per element of A.
That is, it is a logical thing that would be possible to do manually.
But I argue that you shouldn't, that the standard doesn't say to do that.
FInalizing each element of an array separately is reserved for
finaliable components (that happen to be arrays) (rule (2) [59:9-11] ).
And A here isn't a component.
So no finalizers should get called.
On this reading, you do rather different things when you
finalize an array "at the top of the finalization tree" -- an entity
finalized because of one of the rules in 126.96.36.199 directly applies -- vs.
finalizing an array "lower down on the finalization tree" -- an entity
finalized as part of the recursion in rule (2) of 188.8.131.52.
For the former you call ELEMENTAL finalizers if you have them handy,
for the latter you don't call ELEMENTAL finalizers but you finalize
each element of the array separately using any scalar finalizers you
More information about the J3