Next: 12.6 Indexed Variables (Vectors) Up: 12 VARIABLES Previous: 12.4 System variables


12.5 Macro definitions using string variables

String variables for which the stored string has the form of an algebraic expression are evaluated to a number if they are preceded by two dollars ($$). Example:

string='a+b'
a=3
b=4
text,This is string $string which evaluates to $$string
prints

** This is string a+b which evaluates to 7

This can be used to define simple macros, which can be used at various places in the subsequent input. For instance,

ECORR='ENERGY-ESCF' !define a macro
HF                  !do SCF calculation
ESCF=ENERGY         !store SCF energy in variable ESCF
MULTI               !do CASSCF
DEMC=$$ECORR        !store CASSCF correlation energy in variable DEMC
MRCI                !do MRCI
DECI=$$ECORR        !store MRCI correlation energy in variable DECI

Here is an example of advanced use of macros and string variables:

Input: oh_macros.com

Output: oh_macros.out



molpro@molpro.net
Oct 10, 2007