FORTRAN 77 Language Reference

Description

Execution proceeds as follows:

  1. The specified expression is evaluated.

  2. If the value of the expression is true, the statements in the range of the DO WHILE loop are executed.

  3. If the value of the expression is false, control is transferred to the statement following the DO WHILE loop.

Terminal Statement

If s is specified, the statement identified by it is called the terminal statement, and it must follow the DO WHILE statement. The terminal statement must not be one of the following statements:

If the terminal statement is a logical IF statement, it can contain any executable statement, except:

If s is not specified, the DO WHILE loop must end with an END DO statement.

DO WHILE Loop Range

The range of a DO WHILE loop consists of all the executable statements that appear following the DO WHILE statement, up to and including the terminal statement.

If a DO WHILE statement appears within the range of another DO WHILE loop, its range must be entirely contained within the range of the outer DO WHILE loop. More than one DO WHILE loop can have the same terminal statement.

If a DO WHILE statement appears within an IF, ELSE IF, or ELSE block, the range of the associated DO WHILE loop must be entirely within that block.

If a block IF statement appears within the range of a DO WHILE loop, the corresponding END IF statement must also appear within the range of that DO WHILE loop.

Terminal Statement Processing

After the terminal statement of a DO WHILE loop is executed, control is transferred back to the corresponding DO WHILE statement.