XL Fortran for AIX 8.1

Language Reference

DO WHILE

Purpose

The DO WHILE statement is the first statement in the DO WHILE construct, which indicates that you want the following statement block, up to and including a specified terminal statement, to be repeatedly executed for as long as the logical expression specified in the statement continues to be true.

Format



>>-+----------------------+--DO--+------------+--+---+---------->
   '-DO_construct_name--:-'      '-stmt_label-'  '-,-'
 
>--WHILE--(--logical_expr--)-----------------------------------><
 
 

DO_construct_name
is a name that identifies the DO WHILE construct

stmt_label
is the statement label of an executable statement appearing after the DO WHILE statement in the same scoping unit. It denotes the end of the DO WHILE construct.

logical_expr
is a scalar logical expression

Rules

If you specify a DO_construct_name on the DO WHILE statement, you must terminate the construct with an END DO and the same DO_construct_name. Conversely, if you do not specify a DO_construct_name on the DO WHILE statement, and you terminate the DO WHILE construct with an END DO statement, you must not have a DO_construct_name on the END DO statement.

If you specify a statement label in the DO WHILE statement, you must terminate the DO WHILE construct with a statement that is labeled with that statement label. You can terminate a labeled DO WHILE statement with an END DO statement that is labeled with that statement label, but you cannot terminate it with an unlabeled END DO statement. If you do not specify a label in the DO WHILE statement, you must terminate the DO WHILE construct with an END DO statement.

Examples

      MYDO: DO 10 WHILE (I .LE. 5)  ! MYDO is the construct name
         SUM = SUM + INC
         I = I + 1
10    END DO MYDO
      END
 
      SUBROUTINE EXAMPLE2
        REAL X(10)
        LOGICAL FLAG1
        DATA    FLAG1 /.TRUE./
        DO 20 WHILE (I .LE. 10)
           X(I) = A
           I = I + 1
20      IF (.NOT. FLAG1) STOP
      END SUBROUTINE EXAMPLE2

Related Information


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