5.4 Setup Variables and Preprocessing Config Files

setup allows you to assign values to “Setup Variables”. These variables can be string-valued, integer-valued, or boolean. A setup call like

 

./setup -a Sod Foo=Bar Baz=True

sets the variable “Foo" to string “Bar" and “Baz" to boolean True5.3. setup can conditionally include and exclude parts of the Config file it reads based on the values of these variables. For example, the IO/IOMain/hdf5/Config file contains

 
DEFAULT serial


USESETUPVARS parallelIO


IF parallelIO
    DEFAULT parallel
 ENDIF

The code sets IO to its default value of “serial” and then resets it to “parallel" if the setup variable “parallelIO" is True. The USESETUPVARS keyword in the Config file instructs setup that the specified variables must be defined; undefined variables will be set to the empty string.

Through judicious use of setup variables, the user can ensure that specific implementations are included or the simulation is properly configured. For example, the setup line ./setup -a Sod +ug expands to ./setup -a Sod -unit=Grid/GridMain/ Grid=UG. The relevant part of the Grid/GridMain/Config file is given below:

 
# Requires use of the Grid SetupVariable
USESETUPVARS Grid


DEFAULT paramesh


IF Grid=='UG'
   DEFAULT UG
ENDIF
IF Grid=='PM2'
   DEFAULT paramesh/Paramesh2
ENDIF
The Grid/GridMain/Config file defaults to choosing PARAMESH. But when the setup variable Grid is set to “UG" through the shortcut +ug, the default implementation is set to “UG". The same technique is used to ensure that the right IO unit is automatically included.

See bin/Readme.SetupVars for an exhaustive list of Setup Variables which are used in the various Config files. For example the setup variable nDim can be test to ensure that a simulation is configured with the appropriate dimensionality (see for example Simulation/SimulationMain/unitTest/Eos/Config).