| ad49c6e3 | 19-Jul-2025 |
Martin Diehl <mail@martin-diehl.net> |
ensure that Fortran Bool is interoperable
The kind C_BOOL for logical from ISO_C_binding only defines the size of the logical as 1 Byte. It does not define which values (bit patterns) are used to en
ensure that Fortran Bool is interoperable
The kind C_BOOL for logical from ISO_C_binding only defines the size of the logical as 1 Byte. It does not define which values (bit patterns) are used to encode true and false. In stdbool.h from C, true is defined as 1 and false as 0, but these values are not guaranteed by the Fortran standard.
There are (at least) two contemporary Fortran compilers that use a difference convention: Intel Fortran (ifort and ifx) and NVIDIA Fortran (nvfortran, former PGI). Both represent true as all bits set, i.e. -1 for a signed integer or 255 for an unsigned integer.
Intel Fortran can be made interoperable with the "-standard-semantics" or "-fpscomp logicals". The latter is now set by default to ensure interoperability while avoiding effects such as modified name mangling rules and performance degradations due to the former.
NVIDIA Fortran can be made interoperable with the "-Munixlogical" flag. This is set manually in the "linux-cuda-single-cxx" pipeline. This is now set by default.
show more ...
|