[MPI3 Fortran] Fortran extra_state argument to MPIattributefunctions

Aleksandar Donev donev1 at llnl.gov
Thu May 28 11:11:12 CDT 2009

Ian asked:

>  > Is there a standard-conformant way to indicate that extra may be accessed
>  > or modified during the calls to mpi_comm_dup and mpi_comm_free?

And Jim responded:
> Not now.
This is incorrect. There are ways to do what Ian asks for above, in 
fact, two attributes cover it, notably, TARGET and VOLATILE or a 
combination of both. The right one in this context is the TARGET 
attribute. Your array extra *must* have the TARGET attribute. In fact, 
using C interop as I suggested and thus using C_LOC, requires the 
attribute (I am sure the vendor exentsion LOC doesn't because extensions 
don't worry about fine details like this---this is why we usually turn 
them down in the committee!).

It is perfectly legal in Fortran 95, and all subsequent versions, for a 
routine to save a pointer to a TARGET, and then later use it during a 
call to a procedure. Unless the compiler can prove otherwise, it is not 
allowed to move code past calls to unknown routines, since it does not 
know whether targets are affected.

What is not allowed or supported, and is needed for non-blocking 
communication, is to modify the array extra while the Fortran code is 
executing (asynchronously), not necessarily during a procedure call. If 
you put a VOLATILE argument that will be handled too. But it will also 
make any use of the said array inefficient.

To repeat: Jim, this is a separate issue from ASYNCHRONOUS data 
transfers and should not be mixed under that banner.


More information about the mpiwg-fortran mailing list