next up previous contents
Next: Indexed DO Loop Up: Control Flow Previous: Named and Nested Loops

 

DO ... WHILE Loops

If a condition is to be tested at the top of a loop a DO ... WHILE loop could be used,

    DO WHILE (a .EQ. b)
     ...
    END DO

The loop only executes if the logical expression evaluates to .TRUE.. Clearly, here, the values of a or b must be modified within the loop otherwise it will never terminate.

The above loop is functionally equivalent to,

    DO; IF (a .NE. b) EXIT
     ...
    END DO

EXIT and CYCLE can still be used in a DO WHILE loop, just as there could be multiple EXIT and CYCLE statements in a regular loop.

Return to corresponding overview page gif


next up previous contents
Next: Indexed DO Loop Up: Control Flow Previous: Named and Nested Loops

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.