(j3.2006) TS 29113: INTENT(out) and TYPE(*)
Wed Mar 7 04:18:55 EST 2012
after re-thinking the issue, I think using TYPE(*) with INTENT(OUT) is
possible. However, one needs to pass to Fortran procedures [those without
BIND(C)] not only the address of the data but the same meta information
as with CLASS(*). That information is needed to do deallocation and default
That's possible, but then NOTE 5.1 is highly misleading as it states:
"An assumed-type object that is not assumed-shape and not assumed-rank is
intended to be passed as the C address of the object."
I think that should state that this only applies to BIND(C) procedures.
(Or INTENT(OUT) should be disallowed for TYPE(*).)
As the full type information has to be available, the restriction in
6.3 does not seem to be required:
"An assumed-type dummy argument shall not correspond to an actual argument
that is of a derived type that has type parameters, type-bound procedures,
or final procedures."
(I wonder whether it would apply to allocatable components; I think even
with that restriction, one needs to finalize them.)
* * *
For BIND(C) with TYPE(*) the situation for INTENT(OUT) is simpler as many
types are not interoperable. (I think in particular allocatable components
are still not allowed, unless I missed some fine print.)
However, I think the following part should not only apply to allocatable
dummies but also to nonallocatable dummies with default initialization.
(That default initialization is allowed, is implied by C516.)
"When a C function is invoked from a Fortran procedure via an interface "
with an INTENT(OUT) allocatable dummy argument, and the actual argument
in the reference to the C function is an allocated allocatable variable,
the variable is deallocated on invocation (before execution of the C
Namely, I expect some wording that the default initialization of the
intent(out) dummy is also done in the involking Fortran procedure.
On Mon, Mar 05, 2012 at 10:28:25AM +0100, Tobias Burnus wrote:
> type t
> integer :: a = 5
> end type t
> type(t) :: var
> var%a = 8
> call one(x)
> print *, var%a
> subroutine one(x)
> type(*) :: x
> call two(x)
> end subroutine two
> subroutine two(y) ! optionally with Bind(C).
> type(*), intent(out) :: y
> end subroutine
More information about the J3