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

 

Conditional Exit Loops

Can set up a DO loop which is terminated by simply jumping out of it. Consider,

    i = 0
    DO
      i = i + 1
      IF (i .GT. 100) EXIT
      PRINT*, "I is", i
    END DO
    ! if i>100 control jumps here
    PRINT*, "Loop finished. I now equals", i

this will generate

  I is   1
  I is   2
  I is   3
    ....
  I is   100
  Loop finished. I now equals   101

The EXIT statement tells control to jump out of the current DO loop.

For more information, click here gif


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

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