(j3.2006) Should Fortran processor handle the contiguity of an assumed-length assumed-size/explicit-shape dummy argument of a bind(c) procedure?
Malcolm Cohen
malcolm
Wed Oct 8 21:41:10 EDT 2014
Hi Daniel,
This does seem to be unspecified, probably because we just expected it to work that way, the same as it does without BIND(C) since that?s a Fortran 77 style dummy (the number of F77 compilers prepared to accept discontiguous array slice actual arguments for an assumed-size dummy can be numbered on the fingers of one foot).
I think this is a defect. In the paragraph you quote, after ?with the CONTIGUOUS attribute?, it should probably say something not entirely unlike ?, an explicit-shape or assumed-size array with assumed character length, or an assumed-size array with assumed type?. Probably more words need to go in here. However, the quoted paragraph needs a complete rewrite as it is nonsense anyway (see UTI005) so we don?t need to wordsmith this fix now.
i.e. IMO yes the Fortran processor should handle this ?properly?, the same as we require for CONTIGUOUS assumed-shape, and we need to state this.
Cheers,
From: Daniel C Chen
Date: ?? 26?10?9? 0:30
To: j3 at mailman.j3-fortran.org
Subject: (j3.2006) Should Fortran processor handle the contiguity of an assumed-length assumed-size/explicit-shape dummy argument of a bind(c) procedure?
Hello,
Please consider the following Fortran procedure,
subroutine sub(arg1, arg2) bind(c)
character(*) :: arg1(*)
character(*) :: arg2(2,3)
.....
.....
end subroutine
TS29113 specifies that both arg1 and arg2 correspond to a CFI descriptor as they are assumed-length. However, I couldn't find words in the standard or TS that explicitly specifies if Fortran processor is supposed to handle the contiguity inside "sub" for arg1 and arg2 in the case that the caller is a C function that passes non-contiguous CFI descriptor actual arguments.
The closest I found is:
"In an invocation of an interoperable procedure whose Fortran interface has an assumed-shape or assumed-rank
dummy argument with the CONTIGUOUS attribute, the associated effective argument may be an array that is
not contiguous or the address of a C descriptor for such an array. If the procedure is invoked from Fortran or the
procedure is a Fortran procedure, the Fortran processor will handle the difference in contiguity. If the procedure
is invoked from C and the procedure is a C procedure, the C code within the procedure shall be prepared to
handle the situation of receiving a discontiguous argument."
TIA,
Daniel
XL Fortran Development - IBM Toronto Software Lab
Phone: 905-413-3056
Tie: 969-3056
Email: cdchen at ca.ibm.com
http://www.ibm.com/software/awdtools/fortran/xlfortran
________________________________________________________________________
This e-mail has been scanned for all viruses by Star.
________________________________________________________________________
--------------------------------------------------------------------------------
_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
--
................................Malcolm Cohen, Nihon NAG, Tokyo.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.j3-fortran.org/pipermail/j3/attachments/20141009/36e3e3c1/attachment.html
More information about the J3
mailing list