next up previous contents
Next: Named and Nested Loops Up: Control Constructs Previous: Conditional Exit Loops

 

Conditional Cycle Loops

Can set up a DO loop which, on some iterations, only executes a subset of its statements. Consider,

    i = 0
    DO
      i = i + 1
      IF (i >= 50 .AND. i <= 59) CYCLE
      IF (i > 100) EXIT
      PRINT*, "I is", i
    END DO
    PRINT*, "Loop finished. I now equals", i

this will generate

  I is   1
  I is   2
    ....
  I is   49
  I is   60
    ....
  I is   100
  Loop finished. I now equals   101

CYCLE forces control to the innermost active DO statement and the loop begins a new iteration.

For more information, click here gif


next up previous contents
Next: Named and Nested Loops Up: Control Constructs Previous: Conditional Exit Loops

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