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

N.M. Maclaren nmm1 at cam.ac.uk
Wed Feb 27 04:02:11 CST 2013


On Feb 27 2013, Malcolm Cohen wrote:
>
>>It would also allow (for example) the C library function
>>isalnum() to be called from Fortran.
>
>Already allowed, not a problem.  You just declare it with type 
>INTEGER(C_int) and use isalnum(...)/=0.
>
> The problem, such as it exists, arises if you allow LOGICAL instead of 
> INTEGER on the Fortran side.

Thanks for saying what I meant to say, but didn't :-(  I should have
appended "as a LOGICAL function", but it was late at night.  I fully
agree with your other points, of course.

> Fortran LOGICAL only has two values, .TRUE. 
> and .FALSE., whereas C's "boolean" use of integers has many values but 
> only 2 equivalence classes (true and false).

Which are defined to be all non-zeroes and zero, with a canonical value
for true of 1.  C++'s bool is, of course, somewhere in between ....


Regards,
Nick Maclaren.






More information about the mpiwg-fortran mailing list