[MPI3 Fortran] Fwd: [Mpi-comments] MPI 3.0: Fortran 2008 interface - issue with the LOGICAL kind

Tobias Burnus burnus at net-b.de
Sat Mar 2 03:22:59 CST 2013


Am 02.03.2013 10:10, schrieb N.M. Maclaren:
> On Mar 1 2013, Bill Long wrote:
>>> I don't see how that will work, anyway, as BIND(C) passes all non-VALUE
>>> arguments as addresses, and the C interfaces define a lot of them as
>>> values.  Communicators are one example, but they are used in almost all
>>> of the calls.
>>
>> For the cases where C expects a value, you need the VALUE attribute 
>> in the Fortran interface for that C function.   This works.
>
> They don't have it at present.  The simplest example is MPI_Barrier.
>    int MPI_Barrier(MPI_Comm comm)
>
>    [SUBROUTINE] MPI_Barrier(comm, ierror) BIND(C)
>    TYPE(MPI_Comm), INTENT(IN) :: comm
>
> No VALUE there.  Thanks for the correction on the opacity - I had
> forgotten that gotcha.  That's not nice at all.

But that shouldn't be a problem as both have different binding names: 
"MPI_Barrier" in C and "mpi_barrier" in Fortran. If they had the same 
binding name also the optional "ierr" wouldn't work.

>> The even worse problem with default INTEGER is that some users will 
>> compile their Fortran codes with options like -r8 -i8, leading to the 
>> near certainty that in at least one case, KIND(0) will not be the 
>> same as C_INT.   You need two copies of the .mod file for the module 
>> - one for 32-bit default integers, and the other for 64-bit default 
>> integers. The source for the module can be the same, you just have to 
>> compile the module twice, once each with and without the -r8 -i8 
>> options. And make sure the compiler points to the right module file 
>> depending on the -r8 -i8 settings in later compilations. Wrappers and 
>> "path magic" solve this problem.  But it is an artificial problem 
>> introduced by the use of default INTEGER.
>
> Bill, we have been here several times before.  That particular problem
> may be the one that affects you, but it affects very few users of MPI,
> and it is the least of small issues as far as the option compatibility
> goes.  Other than the half-dozen USA mountain-top sites, most MPI users
> do not run with more than 2-4 GB per process, because cores and memory
> are increasing pro-rata.

I also have the impression that "-i8" seems to get only rarely used, 
contrary to "-r8". In addition, even for arrays it is often not needed. 
The whole array size might be larger than huge(0_int32) but usually 
every dimension is smaller than huge(0_int32). On the other hand, other 
things (like I/O) might break with -i8 (as with -r8, but code compiled 
with -r8 is often written such that it will work with -r8 and breaks 
without).

Tobias



More information about the mpiwg-fortran mailing list