Statement: Terminates execution of a DO construct.
Syntax
EXIT [name]
name
(Optional) Is the name of the DO construct.
Description
The EXIT statement causes execution of the named (or innermost) DO construct to be terminated.
If a DO construct name is specified, the EXIT statement must be within the range of that construct.
Any DO variable present retains its last defined value.
An EXIT statement can be labeled, but it cannot be used to terminate a DO construct.
See Also
Examples
The following example shows an EXIT statement:
LOOP_A : DO I = 1, 15
N = N + 1
IF (N > I) EXIT LOOP_A
END DO LOOP_A
The following shows another example:
CC See CYCLE.F90 in the TBD for an example of EXIT in nested
CC DO loops
CC Loop terminates early if one of the data points is zero:
CC
INTEGER numpoints, point
REAL datarray(1000), sum
sum = 0.0
DO point = 1, 1000
sum = sum + datarray(point)
IF (datarray(point+1) .EQ. 0.0) EXIT
END DO