6.1.13 Implicitly convert LOGICAL and INTEGER values
As an extension for backwards compatibility with other compilers, GNU Fortran allows the implicit conversion of LOGICAL
values to INTEGER
values and vice versa. When converting from a LOGICAL
to an INTEGER
, .FALSE.
is interpreted as zero, and .TRUE.
is interpreted as one. When converting from INTEGER
to LOGICAL
, the value zero is interpreted as .FALSE.
and any nonzero value is interpreted as .TRUE.
.
LOGICAL :: l l = 1
INTEGER :: i i = .TRUE.
However, there is no implicit conversion of INTEGER
values in if
-statements, nor of LOGICAL
or INTEGER
values in I/O operations.
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gfortran/Implicitly-convert-LOGICAL-and-INTEGER-values.html