manual   quickstart   instguide   update   basis

Next: 6.6.1 Examples for do Up: 6 PROGRAM CONTROL Previous: 6.5 Allocating dynamic memory   Contents   Index   PDF


6.6 DO loops (DO/ENDDO)

DO loops can be constructed using the DO and ENDDO commands. The general format of the DO command is similar to Fortran:

DO variable=start, end [[,]increment] [[,]unit]

where start, end, increment may be expressions or variables. The default for increment is 1. In contrast to Fortran, these variables can be modified within the loop (to be used with care!). For instance:

DR=0.2
DO R=1.0,6.0,DR,ANG
IF (R.EQ.2) DR=0.5
IF (R.EQ.3) DR=1.0
....
ENDDO

performs the loop for the following values of R: 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0 Ångstrøm. The same could be achieved as follows:

RVEC=[1.0,1.2,1.4,1.6,1.8,2.0,2.5,3.0,4.0,5.0,6.0] ANG
DO I=1,#RVEC
R=RVEC(I)
....
ENDDO

Up to 20 DO loops may be nested. Each DO must end with its own ENDDO.

Jumps into DO loops are possible if the DO variables are known. This can be useful in restarts, since it allows to continue an interrupted calculation without changing the input (all variables are recovered in a restart).



Subsections

Next: 6.6.1 Examples for do Up: 6 PROGRAM CONTROL Previous: 6.5 Allocating dynamic memory   Contents   Index   PDF

manual   quickstart   instguide   update   basis

molpro@molpro.net 2017-12-17