manual   quickstart   instguide   update   basis

Next: 19.7 Tables and Plotting Up: 19 Advanced features of Previous: 19.5 Convergence thresholds   Contents   PDF

19.6 Program control using do loops, if blocks and goto commands

MOLPRO also allows the writing of simple input programs, which check for conditions or perform loops over certain parts of the input. IF blocks and DO loops have a similar form as in Fortran.

One line IF:

IF (condition) command

If more than one command depends on the condition, IF blocks can be used:

IF (condition) THEN
   commands
END IF

or

IF (condition) THEN
   commands
ELSE
   commands
END IF

Also the structure of DO loops is as in Fortran:

DO ivar=istart,iend,[increment]
 commands
ENDDO

ivar is the loop index variable, istart, iend, increment are either numbers or variables. The default for increment is 1.

Examples:

Loop over several geometries (potential curve for HCl):

***,HCl
geometry={        !Z-matrix geometry input
h
cl,h,r
}

r=1.5             !start value for bond distance
hf                !Hartree-Fock for start geometry

do i=1,10         !loop over bond distances

casscf;           !perform casscf
ecas(i)=energy    !save casscf energy in array ecas
mrci              !perform mrci
rhcl(i)=r         !save distances in array rhcl
emrci(i)=energy   !save mrci energies in array emrci
emrda(i)=energd   !save Davidson corrected energies in array emrda

r=r+0.2           !increment r
end do

Alternatively, one could predefine a number of distances:

***,HCl

rhcl=[1.6,1.8,2.0,2.2,2.3,2.4,2.5,2.7,3.0,3.5,4.0,5.0,6.0,7.0]

geometry={        !Z-matrix geometry input
h
cl,h,r
}

do i=1,#rhcl      !loop over all distances
r=rhcl(i)         !set r to current bond distance

if(i.eq.1) then   !in first calculation, do Hartree-Fock
  hf              !Hartree-Fock for start geometry
end if

casscf;           !perform casscf
ecas(i)=energy    !save casscf energy in array ecas
mrci              !perform mrci
rhcl(i)=r         !save distances in array rhcl
emrci(i)=energy   !save mrci energies in array emrci
emrda(i)=energd   !save Davidson corrected energies in array emrda
end do

One can skip to some command later in the input using GOTO. For instance

if(orbital.ne.0) goto casscf   !skip to casscf if an orbital record exists
hf                             !Hartree-Fock
casscf;                        !casscf



Next: 19.7 Tables and Plotting Up: 19 Advanced features of Previous: 19.5 Convergence thresholds   Contents   PDF

manual   quickstart   instguide   update   basis

molpro@molpro.net 2017-12-10