Logical

IBM extension begins The following table shows the values that XL Fortran can represent using the logical data type:

Kind parameter Values Internal (hex) Representation
1

.TRUE.
.FALSE.

01
00

2

.TRUE.
.FALSE.

0001
0000

4

.TRUE.
.FALSE.

00000001
00000000

8

.TRUE.
.FALSE.

0000000000000001
0000000000000000

Note: Any internal representation other than 1 for .TRUE. and 0 for .FALSE. is undefined.

XL Fortran sets the default kind type parameter to 4. The kind type parameter is equivalent to the byte size for logical values. Use the -qintsize compiler option to change the default logical size to 2, 4, or 8 bytes. Note that the -qintsize option similarly affects the default integer size. Use –qintlog to mix integer and logical data entities in expressions and statements.

The -qport=clogicals option allows you to instruct the compiler to treat all nonzero integers used in logical expressions as TRUE. In order to use the -qport=clogicals option, you must also specify the -qintlog option. IBM extension ends

The logical type specifier must include the LOGICAL keyword. See LOGICAL for details on declaring entities of type logical.

The form of a logical literal constant is:
Read syntax diagramSkip visual syntax diagram
>>-+-.TRUE.--+--+---------------+------------------------------><
   '-.FALSE.-'  '-_--kind_param-'   

kind_param
is either a digit-string or a scalar-int-constant-name

A logical constant can have a logical value of either true or false.

You can also use the abbreviations T and F (without the periods) for .TRUE. and .FALSE., respectively, but only in formatted input, or as initial values in DATA statements, STATIC statements, or type declaration statements. A kind type parameter cannot be specified for the abbreviated form. If T or F has been defined as a named constant, it is treated as that named constant rather than the logical literal constant.

Example of a logical constant
.FALSE._4
 .TRUE.


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us