VMS Help  —  FORTRAN  Statements  DO
  Executes a block of statements repeatedly until the value of a
  control variable equals, exceeds, or is less than the terminal
  value, according to the control variable specified in the DO loop
  (indexed DO).  The block of statements starts immediately following
  the DO statement.

  You can transfer control out of a DO loop, but not out of a
  parallel DO loop.

  Statement format:

      [name:] DO [s][,] v = e1,e2[,e3]
         block
      [s] term-stmt

      name Is the name of the DO construct.

      s    Is an optional label of an executable statement
           which follows the DO statement in the same program unit.
           The label designates the last statement of the DO
           loop. If omitted, an END DO statement is required.

      v    Is the control variable; an integer or real variable
           (it cannot be a record field).  You cannot modify
           the control variable inside the DO loop.

      e1   Is the initial value of the control variable; an
           integer or real value.

      e2   Is the terminal value of the control variable; an
           integer or real value.

      e3   Is the value by which to increment the control
           variable after each execution of the DO loop;
           integer or real value.  It cannot be 0.
           The default of e3 is 1.

      block Is a sequence of zero or more statements or
            constructs.

      term-stmt Is the terminal statement for the construct.

  If the iteration count (the number of executions of the DO range)
  is zero or negative, the body of the loop is not executed.  If the
  /NOF77 compiler option is specified and the iteration count is zero
  or negative, the body of the loop is executed once.

  If a DO statement does not contain a terminal statement label, the
  construct must be terminated by an END DO statement.  If it does
  contain a terminal statement label, the END DO is optional.

  If a construct name is specified in a block DO statement, the same
  name must appear in the terminal END DO statement.  If no construct
  name is specified in the block DO statement, no name can appear in
  the terminal END DO statement.  The construct name must be a unique
  identifier in the program unit.

  The following cannot be terminal statements for DO constructs:
  CYCLE, DO, END (for a program unit), EXIT, GO TO, IF, RETURN, or
  STOP.
Close Help