[MPI3 Fortran] Fortran extra_state argument to MPI attributefunctions
donev1 at llnl.gov
Wed May 27 15:32:48 CDT 2009
On Wednesday 27 May 2009 12:54, Jeff Squyres wrote:
> > USE ISO_C_BINDING ! F03 intrinsic module
> > TYPE(C_PTR), VALUE :: extra_state
> Is this effectively a neutral type
I am not sure exactly what you mean: It is meant to be "interoperable"
with void*, that is, have the same physical representation and follow
the passing conventions.
> -- such that a Fortran app can
> pass a reference/pointer/whatever to some larger structure through
> this type in the call to MPI_COMM_CREATE_KEYVAL and then "cast" it
> back to the right type in the callback function?
Yes, this can be done inside Fortran, so long as that "datastructure"
has the TARGET attribute (which it ought to anyway if you want to be
able to save and restore pointers to it).
In fact, it is part of the design of TYPE(C_PTR) to be usable
as "handles" for interoperable callbacks (you cannot get this by
reading the standard but since I proposed it I know ;-)
The only downside, as I mentioned, that it uses Fortran 2003 features.
But they are widely implemented, so I would encourage you to use them.
Aleksandar Donev, Ph.D.
Lawrence Postdoctoral Fellow @ Lawrence Livermore National Laboratory
High Performance Computational Materials Science and Chemistry
E-mail: donev1 at llnl.gov
Phone: (925) 424-6816 Fax: (925) 423-0785
Address: P.O.Box 808, L-367, Livermore, CA 94551-9900
More information about the mpiwg-fortran