A relational expression compares the values of two arithmetic expressions or two character expressions: the result is a logical value, either true or false. Relational expressions are commonly used in IF statements, as in this example:
IF(SENSOR .GT. UPPER) THEN CALL COOL ELSE IF(SENSOR .LT. LOWER) THEN CALL HEAT END IF
The relational operators have forms such as .GT. and .LT. because the Fortran character set does not include the usual characters . and <. Relational expressions are most commonly used in IF statements, but any logical variable or array element may be used to store a logical value for use later on.
CHARACTER*10 OPTION LOGICAL EXIT EXIT = OPTION .EQ. 'FINISH' *... IF(EXIT) STOP 'Finish requested'
Logical expressions are covered in more detail in the next section.