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