Visible to Intel only — GUID: GUID-56D29765-57FD-40DC-9273-B1C43411B70E
Visible to Intel only — GUID: GUID-56D29765-57FD-40DC-9273-B1C43411B70E
CYCLE
Statement: Interrupts the current execution cycle of the innermost (or named) DO construct.
CYCLE [name]
name |
(Optional) Is the name of the DO construct. |
Description
When a CYCLE statement is executed, the following occurs:
The current execution cycle of the named (or innermost) DO construct is terminated.
If a DO construct name is specified, the CYCLE statement must be within the range of that construct.
The iteration count (if any) is decremented by 1.
The DO variable (if any) is incremented by the value of the increment parameter (if any).
A new iteration cycle of the DO construct begins.
Any executable statements following the CYCLE statement (including a labeled terminal statement) are not executed.
A CYCLE statement can be labeled, but it cannot be used to terminate a DO construct.
Execution of a CYCLE statement that belongs to a DO CONCURRENT construct completes execution of that iteration of the construct.
A CYCLE statement cannot appear in a CHANGE TEAM, DO CONCURRENT, or CRITICAL construct if it belongs to an outer construct.
Example
The following example shows a CYCLE statement:
DO I =1, 10
A(I) = C + D(I)
IF (D(I) < 0) CYCLE ! If true, the next statement is omitted
A(I) = 0 ! from the loop and the loop is tested again.
END DO
The following shows another example:
sample_loop: do i = 1, 5
print *,i
if( i .gt. 3 ) cycle sample_loop
print *,i
end do sample_loop
print *,'done!'
!output:
! 1
! 1
! 2
! 2
! 3
! 3
! 4
! 5
! done!