XL Fortran for AIX 8.1

Language Reference

CYCLE

Purpose

The CYCLE statement terminates the current execution cycle of a DO or DO WHILE construct.

Format



>>-CYCLE--+-------------------+--------------------------------><
          '-DO_construct_name-'
 
 

DO_construct_name
is the name of a DO or DO WHILE construct

Rules

The CYCLE statement is placed within a DO or DO WHILE construct and belongs to the particular DO or DO WHILE construct specified by DO_construct_name or, if not specified, to the DO or DO WHILE construct that immediately surrounds it. The statement terminates only the current cycle of the construct that it belongs to.

When the CYCLE statement is executed, the current execution cycle of the DO or DO WHILE construct is terminated. 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.

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

Related Information


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]