[MPI3 Fortran] Fortran proposal w.r.t. BIND(C)/logical/linker symbols/etc. (take 2)

Bill Long longb at cray.com
Mon Jun 3 13:30:22 CDT 2013


Hi Rolf,

Embedded comments. questions:

On 6/3/13 12:25 PM, Rolf Rabenseifner wrote:
>>> 3) The C implementation allows for certain routines to be
>>> implemented
>>> as macros (2.6.4, pages 19-20). In particular, the type conversion
>>> routines. In that case, there is no external PMPI version. It would
>>> be
>>> reasonable to allow the same exemption in the case that these
>>> routines
>>> are implemented by Fortran module procedures (which, from the end
>>> result of compilation, would have an effect much like a C macro). I
>>> assume
>>> that the tools people would not be harmed if these could not be
>>> intercepted, as that is already the case for C anyway.
>>
>> The functions in 17.2.4 do not have Fortran interfaces.
>> They exist only in C.

There are only C interfaces. They could very well be implemented in 
Fortran - actually that makes more sense since they depend on knowing 
the size of INTEGER which is known to the Fortran compiler, but not to 
the C compiler.  As I see it, the only requirement is that the interface 
has to be such that it looks like they are C functions to a caller. 
(See examples in Fortran below.)

>>
>> The macro-allowance for MPI_Wtime and Wtick is only for C.
>>
>> For MPI_Wtime and MPI_Wtick in Fortran, the usual rules apply.
>> No macro exception.

OK, so actual functions are required for Fortran. Easy to supply those, 
as long as there are corresponding C versions to call from the (trivial) 
wrapper.

>
> My answer was 50% a mistake.
> For the fortran written wrappers, we need these functions also in
> Fortran and especially the constants MPI_C_COMM_KIND, etc. for
> the size of the C handles to be able to store them
> in Fortran integers.


Here is an example of the 17.2.4 functions with C interfaces implemented 
in Fortran:

!  MPI_Fint MPI_Comm_c2f(MPI_Comm comm) 


   function mpi_comm_c2f (comm) bind(c,name="MPI_Comm_c2f") result (res)
     use mpi_C_types, only: C_comm
     integer(C_comm),value :: comm
     INTEGER :: res

     res = comm
   end function mpi_comm_c2f

   function pmpi_comm_c2f (comm) bind(c,name="PMPI_Comm_c2f") result (res)
     use mpi_C_types, only: C_comm
     integer(C_comm),value :: comm
     INTEGER :: res

     res = comm
   end function pmpi_comm_c2f


Separately,  a constant with a standardized name, MPI_C_COMM_KIND, could 
be defined as equal to the value of the internal constant C_comm (that 
name style is copied from the iso_c_binding naming conventions).

Is there any need to make duplicates of these with names like 
mpi_comm_c2f_ for the benefit of tools people who do not expect to 
intercept these anyway?  In practice, these would "clearly" be inlined 
in Fortran anyway - give that the executable part of the function is 
only one trivial line of code.  So there would no actual external 
linkage symbol visible in the executable.

[So far, I've not found any actual use for these routines, but that does 
not mean there isn't one. ]

Cheers,
Bill

>
> I expect that we add this later - it is a minor part.
>
> Best regards
> Rolf
>
>
>

-- 
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 mpiwg-fortran mailing list