DO construct

Standard: F77 F90 F95 F2003 F2008 Example program



The syntax of the DO statement is as follows.

[ construct-name : ] DO [ label ] [ [ , ] control ]

control ::= name = expr1 , expr2 [ , expr3 ]
| CONCURRENT concurrent-header
| WHILE ( expr )

end-do ::= continue-stmt
| end-do-stmt

The syntax of the END DO statement is as follows.
      END DO [ construct-name ]
If the DO statement has a construct name, the construct shall end with an END DO statement with the same construct name.

If the loop ends with a continue-stmt, the do-stmt must have a label and this must be the label of the CONTINUE statement.

If control is WHILE (expr), the expr shall be a scalar logical expression. If control is CONCURRENT concurrent-header, the construct is a concurrent DO construct. Otherwise, the name shall be a variable, and it and the expressions shall all be scalar integers.


A (non-concurrent) DO construct executes the statements in its block repeatedly as follows.

The concurrent DO construct executes the iterations in any order, and may execute more than one iteration at the same time. The syntax and semantics of the concurrent DO construct are described here.


Any DO loop can be advanced to the next iteration using a CYCLE statement, or terminated by an EXIT statement. Also, transferring control out of the loop (e.g. by GOTO) terminates the loop.

Nested DO loops can share the same ending statement, provided it is not an END DO statement. This is error-prone and considered obsolescent.

A DO loop can end on an executable statement that is not an END DO or CONTINUE statement. For the purposes of looping, this is treated as if the loop ended with CONTINUE and the executable statement was immediately before it, except that transfers (e.g. GOTO) go to the executable statement not to the implied CONTINUE. This is very error-prone and considered obsolescent.


CONTINUE statement, CYCLE statement, DO CONCURRENT construct, DO WHILE statement, END DO statement, EXIT statement, GO TO statement