[MPI3 Fortran] Start discussing new Fortran binding

Lionel, Steve steve.lionel at intel.com
Tue Feb 19 09:38:19 CST 2008


Hi, folks.  This is Steve Lionel from the Intel Fortran development
team.  I've asked to join this list to help with the Fortran bindings to
MPI-3.  Here's my comments on the current discussion.

> Not being a fortran guy, here's a few options that jump to mind (some/
> all of these make be senseless in Fortran):
> 
> 1. Can there be a fortran integer equivalent than can map to either of
> those, given an appropriate KIND?

Yes, this would be INTEGER(C_INTPTR_T) which is an integer kind that is
the size of a pointer for the companion processor.  This is equivalent
to C's intptr_t type. Note that it isn't guaranteed that there is such
an integer kind, though I'd expect that there would be.

C_PTR is a type on its own and not a KIND value.  It is an "opaque" type
that can be manipulated by functions such as C_F_POINTER which
"converts" a value of type C_PTR to a Fortran pointer.

For MPI arguments that are "handles" - that is, values that are simply
fetched, stored and passed and not used arithmetically, then type(C_PTR)
would be appropriate. But there's a better option - see below.

> 
> 2. Is there a way to use a preprocessor to replace something like this
> 
>        integer(MPI_HANDLE_TYPE), value, intent(in) :: datatype
> 
> with either C_INT or C_PTR, depending on what the implementation
> requires?

The proper (IMO) way to do this in Fortran is as follows:

type, BIND(C) :: MPI_HANDLE_TYPE
  private
  type(C_PTR) :: handle
  end type MPI_HANDLE_TYPE

This allows the user to declare things of type(MPI_HANDLE_TYPE) but
makes the contents inaccessible other than passing, storing or fetching.
The BIND(C) tells the Fortran compiler that this is an interoperable
type and it is not allowed to pad it or rearrange the contents.

> 3. Does F03 have the equivalent to C's "typedef" such that we could
> create handle types that map to integer(C_INT) or type(C_PTR) (and the
> user doesn't need to know)? 

See above.


Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH 






More information about the mpiwg-fortran mailing list