[MPI3 Fortran] Start discussing new Fortran binding
Jeff Squyres
jsquyres at cisco.com
Thu Feb 14 20:22:33 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)
--
Jeff Squyres
Cisco Systems
More information about the mpiwg-fortran
mailing list