next up previous contents
Next: Indexed DO Loops Up: Control Flow 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.

    outa: DO
     inna: DO
      ...
      IF (a.GT.b) EXIT outa
      ...
      IF (a.EQ.b) CYCLE outa
      ...
      IF (c.GT.d) EXIT inna
      ...
     END DO inna
     ...
    END DO outa

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: Indexed DO Loops Up: Control Flow Previous: Conditional Cycle Loops

Adam Marshall ©University of Liverpool, 1996
Fri Dec 6 18:56:08 GMT 1996
Not for commercial use.