[MPI3 Fortran] Start discussing new Fortran binding

Craig E. Rasmussen rasmussn at lanl.gov
Fri Feb 15 14:56:26 CST 2008

> On Feb 14, 2008, at 9:03 PM, Craig E. Rasmussen wrote:
>>>> ! We need to figure out the type of MPI handles.
>>>> ! Currently I'm leaning toward TYPE(C_PTR) rather than
>>>> ! the INTEGER(MPI_HANDLE_KIND) Jeff and I used in our paper.
>>> Will this be able to handle MPI implementations that use integers as
>>> MPI handles in C?
>> So are we talking about global constants like MPI_COMM_WORLD?  If so
>> it
>> looks like we can use the same global integers that are used in C.
> That's the point, though -- some MPI implementations (e.g., Open MPI)
> use pointers for MPI handles in C, while others (e.g., MPICH) use C
> int's.  The standard doesn't specify what the type has to be, so
> implementations do what they please.
>> We
>> would just initialize MPI_COMM_WORLD in Fortran MPI_Init to the
>> address of
>> the global C integer.  If you can grok the Fortran, I've included
>> the code
>> snippets:
>> ! the global integer in OMPI
>>  integer, bind(C) :: ompi_mpi_comm_world
>> ! the declaration of the handle in Fortran
>>  type(C_PTR) :: MPI_COMM_WORLD
>> ! the initialization in MPI_Init()
>> MPI_COMM_WORLD = C_LOC(ompi_mpi_comm_world)
> If I grok this, it looks like the Fortran binding for MPI_COMM_WORLD
> will always be a C pointer.  How would that translate automatically
> back to the C bindings if the back-end C type is an integer?  I
> thought the goal was to make the C and Fortran types be the same (or
> automatically translatable by the compiler).
> (note that OMPI uses pointers in C, so ompi_mpi_comm_world is a
> pointer, not an integer.  But you could s/ompi_mpi_comm_world/
> mpich_mpi_comm_world/ and have a valid-ish example)

It would be easier to use ints (as we did in the paper).  I just wasn't
sure how to implement everything as ints using OpenMPI.  Perhaps you could
remind me how to do it.  Ints would be preferable as I've already run into
trouble with the current implementation attempt (see attached files) as
the pointers are not compile time constants (and it seems that MPI_Recv is
messing around with my datatype pointer).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: mpi.f90
Type: /
Size: 3540 bytes
Desc: not available
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-fortran/attachments/20080215/f9d83849/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ring.f90
Type: /
Size: 3040 bytes
Desc: not available
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-fortran/attachments/20080215/f9d83849/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: print_ptr.c
Type: /
Size: 102 bytes
Desc: not available
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-fortran/attachments/20080215/f9d83849/attachment-0005.bin>

More information about the mpiwg-fortran mailing list