FORTRAN 77 Language Reference

IF Block

An IF block consists of all the executable statements following the block IF statement, up to, but not including, the next ELSE, ELSE IF, or END IF statement that has the same if level as the block IF statement. An IF block can be empty. In the following example, the two assignment statements form an IF block:


       IF ( X .LT. Y ) THEN 
              M = 0 
              N = N+1 
       END IF

Execution proceeds as follows:

  1. The logical expression e is evaluated first. If e is true, execution continues with the first statement of the IF block.

  2. If e is true and the IF block is empty, control is transferred to the next END IF statement with the same IF level as the block IF statement.

  3. If e is false, control is transferred to the next ELSE IF, ELSE, or END IF statement with the same IF level as the block IF statement.

  4. If the last statement of the IF block does not result in a branch to a label, control is transferred to the next END IF statement that has the same IF level as the block IF statement preceding the IF block.