Next: Hollerith constants support, Previous: Unary operators, Up: Extensions implemented in GNU Fortran
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.