Logical Data Representations

Logical data lengths can be 1, 2, 4, or 8 bytes in length.

The default data size used for a LOGICAL data declaration is LOGICAL(4) (same as LOGICAL(KIND=4)), unless -integer-size 16 or -integer-size 64 (Linux OS and Mac OS X) or /integer-size:16 or /integer-size:64 (Windows OS) was specified.

To improve performance on systems using Intel® 64 architecture and IA-64 architecture, use LOGICAL(4) (or LOGICAL(8)) rather than LOGICAL(2) or LOGICAL(1). On systems using IA-32 architecture, use LOGICAL(4) rather than LOGICAL(8), LOGICAL(2), or LOGICAL(1).

LOGICAL(KIND=1) values are stored in 1 byte. In addition to having logical values .TRUE. and .FALSE., LOGICAL(1) data can also have values in the range -128 to 127. Logical variables can also be interpreted as integer data.

In addition to LOGICAL(1), logical values can also be stored in 2 (LOGICAL(2)), 4 (LOGICAL(4)), or 8 (LOGICAL(8)) contiguous bytes, starting on an arbitrary byte boundary.

If the -fpscomp nological (Linux OS and Mac OS X) or /fpscomp:nological (Windows OS) compiler option is set (the default), the low-order bit determines whether the logical value is true or false. Specify logical instead of nological for Microsoft* Fortran PowerStation logical values, where 0 (zero) is false and non-zero values are true.

LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) data representation (when nological is specified) appears below.

LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) Data Representations
LOGICAL(1), LOGICAL(2), LOGICAL(4), and LOGICAL(8) Data Representations