A newer version of this document is available. Customers should click here to go to the newest version.
Logical Data Types
Logical data types can be specified as follows:
LOGICAL
LOGICAL([KIND=]n)
LOGICAL*n
n |
Is a constant expression that evaluates to kind 1, 2, 4, or 8. The named constants for LOGICAL kind values are defined in the intrinsic module ISO_FORTRAN_ENV: LOGICAL8=1, LOGICAL16=2,LOGICAL32=4, and LOGICAL64=8. |
If a kind parameter is specified, the logical constant has the kind specified. If no kind parameter is specified, the kind of the constant is default logical. The intrinsic inquiry function KIND returns the kind type parameter of its argument if you do not know it. You can use the SELECTED_LOGICAL_KIND intrinsic to find the kind type parameter of a logical type whose storage size is at least as many bits as the argument.
Examples
The following examples show how logical variables can be declared.
An entity-oriented example is:
LOGICAL, ALLOCATABLE :: flag1, flag2
LOGICAL (KIND = byte), SAVE :: doit, dont
An attribute-oriented example is:
LOGICAL flag1, flag2
LOGICAL (KIND = byte) doit, dont
ALLOCATABLE flag1, flag2
SAVE doit, dont