(j3.2006) (SC22WG5.3591) Assumed-type and Assumed-rank extensions for C Interop TR.

Jim Xia jimxia
Fri Jul 25 11:52:22 EDT 2008

j3-bounces at j3-fortran.org wrote on 07/24/2008 07:13:22 PM:

> At the last J3 meeting there was discussion about how to better 
> interoperate with C functions that have void * arguments. This was 
> mainly in the context of cooperation with the MPI committee that is 
> trying to design a better Fortran interface module for the MPI library. 
> However, the basic issue is wider than just MPI.
> Debate in May narrowed down the list of options to 3 (see paper 
> 08-185r1).  Attached is a draft of a proposal for one of these options, 
> somewhat expanded. This was the option that, at least to me, seemed to 
> have the fewest vocal opponents.
> The original mandate for the TR did not include a feature like this, so 
> the first question is whether WG5 supports this addition. 
> Comments on the proposal itself are also welcome.  The MPI folks prefer 
> adding this feature to the TR rather than making this part of the Base 
> f08, on the grounds that a vendor could implement the TR as an addition 
> to f03, as it does not depend on any of the new f08 features. This would 

> enable earlier access. 
> As before, fell free to solicit input from others not on the WG5 list.

Just some comments

1.) why not expand assumed-rank to include rank 0, which means a scalar.
2.) If the goal of this is to deal with MPI community in "void *" type 
dummy (not even a function return result), then I don't see a reason to 
expand to include descriptors (assumed-shape, pointer and allocatable). 
That part does not fit well in Fortran.
3.) I agree with Alex that generic resolution is not an area you want to 
have this included.
4.) I don't understand the examples, so I have to ask for clarifications

In the paper, it says

In C:  void MPI_xxx ( void * buffer, int n);

In the Fortran MPI module:

interface MPI_xxx
   subroutine MPI_xxx (buffer, n) bind(c,name="MPI_xxx")
      type(*),dimension(*) :: buffer
      integer(c_int),value :: n
   end subroutine MPI_xxx
   module procedure MPI_xxx_i8
end interface MPI_xxx

If TYPE(*) already means void *, then why buffer is declared as an 
assumed-size array?  The Fortran side declaration look like a declaration 
of void ** to me.  Can you please clarify that?

And more, I don't understand this fragment

type(*),target     :: block(*)
integer(8)         :: nbytes
Integer(8),pointer :: usable(:)

call c_f_pointer (c_loc(block), usable, [nbytes*bit_size(usable)/8] )

In particular, I don't understand what c_loc is used for since block is 
already an address.  Also I don't see any type "casting" happens here as 
the example to demonstrate that.


Jim Xia

RL Fortran Compiler Test
IBM Toronto Lab at 8200 Warden Ave, Markham, On, L6G 1C7
Phone (905) 413-3444  Tie-line 313-3444
email: jimxia at ca.ibm.com
D2/YF7/8200 /MKM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://j3-fortran.org/pipermail/j3/attachments/20080725/c6156a98/attachment.html 

More information about the J3 mailing list