CYCLE
Purpose
The CYCLE statement terminates the current execution cycle of a DO or DO WHILE construct that it belongs to.
The
CYCLE statement completes the execution of the current iteration of the
DO CONCURRENT construct that it belongs to.
Syntax
- DO_construct_name
- is the name of a DO,
DO
CONCURRENT
, or DO WHILE construct.
Rules
The CYCLE statement is placed within a
DO,
DO CONCURRENT
, or
DO WHILE construct and belongs to the particular
DO,
DO CONCURRENT
, or
DO WHILE construct that is specified by
DO_construct_name. If DO_construct_name is
not specified, the CYCLE statement belongs to the
DO,
DO CONCURRENT
, or DO WHILE construct that
immediately surrounds it.
A
CYCLE statement must not be placed within a DO
CONCURRENT construct if it belongs to an outer construct.
Execution of a CYCLE statement that belongs to a DO or DO WHILE construct only terminates the current execution cycle of the DO or DO WHILE construct. Any executable statements after the CYCLE statement, including any terminating labeled action statement, will not be executed. For DO constructs, program execution continues with incrementation processing, if any. For DO WHILE constructs, program execution continues with loop control processing.
Execution of a CYCLE statement that belongs to a DO
CONCURRENT construct completes the execution of the current iteration of the
construct.
A CYCLE statement can have a statement label. However, it cannot be used as a labeled action statement that terminates a DO construct.
Examples
LOOP1: DO I = 1, 20
N = N + 1
IF (N > NMAX) CYCLE LOOP1 ! cycle to LOOP1
LOOP2: DO WHILE (K==1)
IF (K > KMAX) CYCLE ! cycle to LOOP2
K = K + 1
END DO LOOP2
LOOP3: DO J = 1, 10
N = N + 1
IF (N > NMAX) CYCLE LOOP1 ! cycle to LOOP1
CYCLE LOOP3 ! cycle to LOOP3
END DO LOOP3
END DO LOOP1
END
