Next: 8.9 Text cards (TEXT) Up: 8 PROGRAM CONTROL Previous: 8.7.3 Labels (LABEL)


8.8 Procedures (PROC/ENDPROC)

Procedures can be defined at the top of the input, in the default file molproi.rc, or in INCLUDE files as follows:

PROC name
statements
ENDPROC

Alternatively, one can use the form

PROC name[=]{statements}

In the latter case, it is required that the left curly bracket ($\{$) appears on the same line as PROC, but statements can consist of several lines. If in the subsequent input name is found as a command in the first field of a line, it is substituted by the statements. Example:

PROC SCF
IF (#SPIN.EQ.0.OR.MOD(SPIN,2).NE.MOD(NELEC,2)) SPIN=MOD(NELEC,2)
IF (SPIN.EQ.0) THEN
  HF
ELSE
  RHF
ENDIF
ENDPROC

Alternatively, this could be written as

PROC SCF={
IF (#SPIN.EQ.0.OR.MOD(SPIN,2).NE.MOD(NELEC,2)) SPIN=MOD(NELEC,2)
IF (SPIN.EQ.0) THEN; HF; ELSE; RHF; ENDIF}
Procedures may be nested up to a depth of 10. In the following example SCF is a procedure:

PROC CC
SCF
IF (SPIN.EQ.0) THEN
  CCSD
ELSE
  RCCSD
ENDPROC

Note: Procedure names are substituted only if found in the first field of an input line. Therefore, they must not be used on one-line IF statements; please use IF / ENDIF structures instead.

If as first statement of a procedure ECHO is specified, the substituted commands of the present and lower level procedures will be printed. If ECHO is specified in the main input file, all subsequent procedures are printed.

Certain important input data can be passed to the program using variables. For instance, occupancy patterns, symmetries, number of electrons, and multiplicity can be defined in this way (see section 6.6 for more details). This allows the quite general use of procedures. For example, assume the following procedure has been defined in molproi.rc:

PROC MRCI
IF (INTDONE.EQ.0) INT
IF (SCFDONE.EQ.0) THEN   
SCF
ENDIF
MULTI
CI
ENDPROC

This procedure can be used for a calculation of a vertical ionization potential of H$_2$O as follows:

 
R=1 ANG           !Set bond distance 
THETA=104 DEGREE  !Set bond angle

BASIS=VTZ         !Define basis set

GEOMETRY          !Geometry input block
O                 !Z-matrix
H1,O,R
H2,O,R,H1,THETA
ENDG              !End of geometry input

MRCI              !Compute mrci energy of water using defaults 
EH2O=ENERGY       !save mrci energy in variable EH2O 

NELEC=9           !Set number of electrons to 9 
SYMMETRY=2        !Set wavefunction symmetry to 2
MRCI              !Compute mrci energy of H2O+ (2B2 state)

IPCI=(ENERGY-EH2O)*TOEV   compute MRCI ionization potential in eV

Note: At present, all variables are global, i.e., variables are commonly known to all procedures and all variables defined in procedures will be subsequently known outside the procedures as well. The reason is that procedures are included into the internal input deck at the beginning of the job and not at execution time; for the same reason, variable substitution of procedure names is not possible, e.g. one cannot use constructs like

method=scf
$method       !this does not work!



Next: 8.9 Text cards (TEXT) Up: 8 PROGRAM CONTROL Previous: 8.7.3 Labels (LABEL)

P.J. Knowles and H.-J. Werner
molpro@tc.bham.ac.uk
Jan 15, 2002