next up previous contents
Next: DO ... WHILE Loops Up: Control Constructs Previous: Conditional Cycle Loops

 

Named and Nested Loops

Loops can be given names and an EXIT or CYCLE statement can be made to refer to a particular loop.

0|      outa: DO
1|       inna: DO
2|        ...
3|        IF (a.GT.b) EXIT outa  ! jump to line 9
4|        IF (a.EQ.b) CYCLE outa ! jump to line 0
5|        IF (c.GT.d) EXIT inna  ! jump to line 8
6|        IF (c.EQ.a) CYCLE      ! jump to line 1
7|       END DO inna
8|      END DO outa
9|      ...

The (optional) name following the EXIT or CYCLE highlights which loop the statement refers to.

Loop names can only be used once per program unit.

For more information, click here gif

Now try this question gif


next up previous contents
Next: DO ... WHILE Loops Up: Control Constructs Previous: Conditional Cycle Loops

©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997
Not for commercial use.