[MPI3 Fortran] [Mpi-comments] MPI 3.0: Fortran 2008 interface - issue with the LOGICAL kind
burnus at net-b.de
Mon Mar 4 13:26:14 CST 2013
Bill Long wrote:
>> There isn't any difficulty about a Fortran wrapper using integers (as
>> C does), and converting them to LOGICAL, but it can't be BIND(C).
> There is also no difficulty in having the wrapper arguments being
> subroutine sub (x) bind(c, name="MPI_xxx_f")
> logical :: x
> integer(int) :: cx
> cx = merge(1, 0, x)
Well, except that compilers might simply reject a default-kind LOGICAL
with BIND(C), in line with the Fortran standard.
Your code above assumes that a Fortran compiler allows passing a
default-kind LOGICAL to a Bind(C) procedure and that it then can handle
that LOGICAL. I think no one really doubts the second part. But the
first part is not really covered by the Fortran standard and
standard-conforming compilers do exist, which reject default-kind LOGICALs.
J3/WG5 could change the standard such that it supports other LOGICAL
kinds besides C_Bool, including kind(.true.). However, if
LOGICAL(kind=kind(.true.) / C_INT) exists, users will assume that it
acts like C's "int", which will lead to problems. So far, I haven't seen
a convincing proposal how to solve this.
More information about the mpiwg-fortran