Help with interpreting TYPE(*) with INTENT(OUT)
Tobias Burnus
tobias.burnus@physik.fu-berlin.de
Wed Mar 7 09:02:00 GMT 2012
Hello,
I try to understand how TYPE(*) is supposed to act for non-BIND(C) procedures
according to TS 29113.
So far, I thought that a scalar TYPE(*) or a non-assumed-shape TYPE(*) passes
the pointer to the data of the scalar or of the address of the first element of
the array. That's also what is implied by NOTE 5.1.
However, even though allocatables and pointers are not allowed with TYPE(*),
INTENT(OUT) seems to be allowed. And as INTENT(OUT) causes deallocation of
allocatable components and default initialization, there is a problem if one
has only passed the pointer.
(There is no problem with finalization as the derived type passed to TYPE(*)
may not have "type parameters, type-bound procedures, or final procedures"
per 6.3p2.) However, I wonder whether they are allowed to appear in components
of that type. But even with out, default initialization alone causes the problem.
Thus, if INTENT(OUT) is indeed allowed, one needs to pass everything wrapped into
a class container ("CLASS(*)") - at least for the Fortran case. But then the
restriction regarding the finalization and type-bound procedure does not make
any sense as the full type information is available.
For TYPE(*) with BIND(C): Some problems do not occur since not all data types
are valid. In particular, allocatable components don't seem to be allowed.
As for allocatable dummies, the INTENT(OUT) is handled on the Fortran side,
I assume that the same applies to default initialization of nonallocatable
dummies - though the standard does not talk about this.
If my current reading of the standard is correct, TYPE(*) without BIND(C) is
currently mishandled [no class container] and I think there is also an issue
with INTENT(OUT).
The TS29113 draft is available at
http://j3-fortran.org/doc/meeting/197/12-119r1.pdf
I would be happy for comment about my understanding of the spec. (I also
asked at J3, but so far without success.)
Tobias
More information about the Fortran
mailing list