(j3.2006) FINAL subroutines with explicit/assumed-size arrays
Mon May 7 18:34:28 EDT 2012
On 5/7/12 4:51 PM, Tobias Burnus wrote:
> 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
>> 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.)
You're right, I was thinking about the actual argument, not the dummy.
>> 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.
There is actually an interp out (F08/0070 = paper 12-118r1) for vote
somewhat related to this issue. If you have an explicit-shape dummy
argument that is smaller than the associated actual argument, only the
part of the actual that properly corresponds to the dummy gets finalized.
The case of an assumed-size dummy is problematic since you, in general,
don't know the size of the actual so would be severely restricted in
what you could do with the argument. I suppose you could increment
some separate variable to indicate that the final subroutine was called,
without doing anything with the argument itself.
>>> 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.
>>> module test
>>> type t
>>> final :: fin
>>> end type t
>>> 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()
>>> 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.
> 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./Cray Plaza, Suite 210/380 Jackson St./St. Paul, MN 55101
More information about the J3