The LOGICAL statement is used to declare variables and functions of type logical for use in the program.
The logical type declaration statement is used in a similar manner to other type declaration statements. For instance, this type statement will support all of the attributes that the INTEGER and REAL statements support. Also, variables can be initialized inside of the type statement just like other type declaration statements. The only major difference between the logical type and other types is the fact that logical variables can only be assigned one of two values, .true. and .false. With this in mind, a logical type declaration statement will take on a form similar to the following when used.
Logical, parameter :: lvar = .true.
Logical, target,dimension(:,:) :: larray
The major use of these variables is to make logical comparisons within a program. The results of these comparisons could then be used as a condition for branching within a program. For instance, the next little block of code shows how a logical variable might be used with an if statement to cause branching within a program.
if (lvar) then X = 5.6 go to 1200 else x = 76.8 go to 1201 end if
examples: iftests.f and inter1.f
Written by Jason Wehr: firstname.lastname@example.org and Maintained by John Mahaffy : email@example.com