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

N.M. Maclaren nmm1 at cam.ac.uk
Tue Feb 26 11:32:43 CST 2013


On Feb 26 2013, Jeff Squyres (jsquyres) wrote:
>> From: Tobias Burnus <burnus at net-b.de>
>>
>> Digest version: The Fortran 2008 interface should use 
>> "LOGICAL(kind=C_BOOL)" instead of "LOGICAL".
>> 
>> Hence, I strongly suggest to change in all BIND(C) procedures LOGICAL 
>> to LOGICAL(C_Bool). ...

This is a catastrophic idea.  Let's ignore the minor detail that _Bool
was attempt to mimic C++'s bool, but is not necessarily compatible with
it.  Yes, really.  Many people on WG14 opposed it (including the UK,
formally, if I recall) and a lot of people still disrecommend it on
those grounds.

This would force ALL users who need those calls to start using C types,
and the need for that may well be removed in the next standard.  Far
worse, a Fortran compiler need not support C_BOOL in any case, so MPI
would cease being fully portable in Fortran.

But the REALLY bad problem is that this is a code-breaking change,
unless the authors of the modules, include file and header make heroic
efforts to avoid it.  From page 598 (17.1 Fortran Support): "In a single
application, it must be possible to link together routines which USE
mpi_f08, USE mpi, and INCLUDE 'mpif.h'."

To actually get it right would mean that the MPI_F08 module invokes a
different copy of all of the test functions to the ones invoked by the
MPI one and the included file 'mpif.h'.  So why put the ability to use
the same function for the MPI_F08 module and the header 'mpi.h' above
that of doing so for the MPI_F08 module and the MPI module and the
included file 'mpif.h'?  That's unnatural.

I don't understand the objections to (theoretical) interface functions;
a particular MPI implementation can always optimise them out.  While I
can understand the desire of people to put those BIND(C) specifiers on,
I think that it was a mistake.  It should be dropped for these
functions.


On Feb 26 2013, Bill Long wrote:
>
>In particular, the C function is not using _Bool.  It would seem to be 
>more consistent for the Fortran interface to specify the argument as
>
>INTEGER :: FLAG
>
>or, better
>
>INTEGER(c_int) :: FLAG.

Yes, but my points apply as much to C_INT as they do for C_BOOL,
except for the specific reason to avoid C_BOOL.


Regards,
Nick Maclaren.




More information about the mpiwg-fortran mailing list