(j3.2006) FINAL subroutines with explicit/assumed-size arrays

Tobias Burnus burnus
Mon May 7 17:51:18 EDT 2012


Bill Long wrote:
> On 5/7/12 3:32 PM, Tobias Burnus wrote:
>> when looking at the FINAL, I got the impression that not only
>> assumed-shape arrays are allowed but also explicit-size and assumed-size
>> arrays.
>>
>
> Allocatable and pointer arrays are also allowed.

Sorry for not being clear enough. I was talking about the dummy argument 
of the finalization subroutine - not about the variables which get 
finalized. (The dummy argument of the finalization subroutine has to be 
nonallocatable and a nonpointer.)


> Elemental FINAL subroutines are allowed (and handy).  They are useful 
> in accommodating multiple ranks and sizes of actual arguments.

I completely agree that those are the most useful ones - but also 
finalization subroutines with assumed-shape dummy arguments should be 
fine - and be useful in some special cases.

Nevertheless, I do have problems with an assumed-size or explicit-size 
dummy argument of a finalization subroutine.


>> Hence, is the following program valid? If not, why? If yes, was it
>> intended to valid - and, if not, does it make sense to fill an IR?
>>
>
> Seems OK.

OK. Though, I expect that the variant of passing a size-3 array to a 
size-4 finalization dummy should be invalid.

Tobias

>>
>> module test
>> type t
>> contains
>> final :: fin
>> end type t
>> contains
>> subroutine fin(x)
>> type(t), intent(inout) :: x(3)
>> ! or alternatively: "(2)" or "(*)" or "(4)"
>> end subroutine fin
>> end module test
>>
>> subroutine useIt()
>> use test
>> type(t) :: y(3)
>> end subroutine useIt
>>
>> call useIt()
>> end
>>
>>
>> Tobias
>>
>> PS: The main FINAL constraint is the following:
>>
>> C480 (R452) A final-subroutine-name shall be the name of a module
>> procedure with exactly one dummy argument. That argument shall be
>> nonoptional and shall be a nonpointer, nonallocatable, nonpolymorphic
>> variable of the derived type being defined. All length type parameters
>> of the dummy argument shall be assumed. The dummy argument shall not
>> have the INTENT (OUT) or VALUE attribute.



More information about the J3 mailing list