LOGICAL Type and Variables

LOGICAL values are either true or false. In Fortran, they must be written as .TRUE. and .FALSE. Note that the two periods surrounding TRUE and FALSE must be there; otherwise, they become identifiers.

A variable that can hold one of the logical values is a logical variable and it is of type LOGICAL. To declare a LOGICAL variable, do it as what you did for INTEGER and REAL variables. But, use the type name LOGICAL instead.

LOGICAL constants can have aliases declared with the PARAMETER attribute.

LOGICAL variables can be initialized when they are declared and can be assigned a logical value.

However, a LOGICAL variable can only hold a logical value. Putting a value of any other type (e.g., INTEGER or REAL) into a LOGICAL variable will cause an error. The following are examples: