[MPI3 Fortran] Fortran extra_state argument to MPIattributefunctions
donev1 at llnl.gov
Wed May 27 20:02:10 CDT 2009
Jeff Squyres wrote:
> I guess I should clarify here -- the intent for this parameter is not to
> be interoperable with C.
I understand, but you were asking about a "neutral" type that can be
"cast" into the "right type". The C void* can be used for such things,
but Fortran does not have an equivalent, at least not unless you count
Fortran 2003 object oriented features (where there are "unlimited
polymorphic pointers" which provide a type-safe "castable" generic
pointer). This is why using C interoperability is good here---it is
legal and does what you want.
> The intent is that a Fortran application can
> pass some meaningful value through this parameter in the call to
> MPI_COMM_CREATE_KEYVAL, and then later that same Fortran application can
> get the extra_value back and do something meaningful with it.
> The fact that the MPI implementation is written in C should not really
> have any impact on the discussion.
> On May 27, 2009, at 4:32 PM, Aleksandar Donev wrote:
>> 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
>> Web: http:// cims.nyu.edu/~donev/
>> mpi3-fortran mailing list
>> mpi3-fortran at lists.mpi-forum.org
>> http:// lists.mpi-forum.org/mailman/listinfo.cgi/mpi3-fortran
Aleksandar Donev, Ph.D.
Lawrence Postdoctoral Fellow @ LLNL
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