The IF construct selects no more than one of its statement blocks for execution.
>>-Block_IF_statement------------------------------------------><
>>-statement_block---------------------------------------------><
>>-+-------------------+--------------------------------------->< | .---------------. | | V | | '---ELSE_IF_block-+-'
>>-+------------+---------------------------------------------->< '-ELSE_block-'
>>-END_IF_statement--------------------------------------------><
ELSE_IF_block
>>-ELSE_IF_statement-------------------------------------------><
>>-statement_block---------------------------------------------><
ELSE_block
>>-ELSE_statement----------------------------------------------><
>>-statement_block---------------------------------------------><
The scalar logical expressions in an IF construct (that is, the block IF and ELSE IF statements) are evaluated in the order of their appearance until a true value, an ELSE statement, or an END IF statement is found:
If the IF construct name is specified, it must appear on the IF statement and END IF statement, and optionally on any ELSE IF or ELSE statements.
! Get a record (containing a command) from the terminal DO WHICHC: IF (CMD .EQ. 'RETRY') THEN ! named IF construct IF (LIMIT .GT. FIVE) THEN ! nested IF construct ! Print retry limit exceeded CALL STOP ELSE CALL RETRY END IF ELSE IF (CMD .EQ. 'STOP') THEN WHICHC ! ELSE IF blocks CALL STOP ELSE IF (CMD .EQ. 'ABORT') THEN CALL ABORT ELSE WHICHC ! ELSE block ! Print unrecognized command END IF WHICHC END DO END