ChasteGuides/HostconfigSystem

The hostconfig system

The source release of Chaste relies on many libraries for core functionality. These can be found in different locations on different systems, and several different versions are supported. The hostconfig system, consisting of the files in python/hostconfig, is used to specify the settings for the current system.

The file used by the build system is hostconfig.py. This is not intended for user editing however, but loads a settings file. For core developers, it will try loading stored settings from the machines folder (see below). For other users, it will first try to find settings for your Linux distribution (currently only Ubuntu is supported, for the benefit of users installing the Ubuntu package), and if that fails, will use the file default.py. These choices may be overridden by supplying a file python/hostconfig/local.py with your settings.

NB: If you're not seeing expected behaviour from your hostconfig, it's worth running scons with hostconfig debugging turned on to see what settings Chaste is actually picking up. Use (e.g.) "scons debug=1" to do this. This will output which hostconfig file is being used, and the settings it contains.

Configuring the hostconfig system

The configuration file is actually a small Python program providing certain variables specifying where to find libraries and tools, along with some additional settings.

Several variables are used to specify which PETSc installation to use. Four variables give paths to different versions of PETSc:

OR both of these:

At least one of these must be defined. If you specify more than one, Chaste will by default attempt to use the newest version of PETSc it can find. If none of these variables specifies a usable PETSc installation, an error message will be given.

A particular PETSc installation may support multiple architectures/settings, by setting the PETSC_ARCH environment variable when compiling PETSc. You must tell Chaste which architecture to use by setting the petsc_build_name variables. There are 4 of these variables, allowing the use of different PETSc compilation options for different Chaste build types:

The following variables are flags which indicate whether to use certain optional external libraries. If the variable is not present, it will default to False. If the variable is set to True, then the appropriate include and library paths (see below) should be specified, too.

For all libraries used except for PETSc and MPI, the paths to the folders containing the compiled libraries, and their header files, must be set, and the names of the libraries. The default.py file included with Chaste should give an indication of which libraries to use, but some systems will require additional libraries; consult your system administrator. These should be given in the following variables:

The blas and lapack library names are set separately, in the blas_lapack variable. Lapack must appear before blas in this list.

Other variables that may be set include:

Particularly important tools that may need to be given here are mpicxx, mpirun and xsd.

Chaste can make use of the Intel compilers if they are available. There are a few variables that affect this.

Any non-absolute paths will be considered relative to the root of the Chaste install.

Advanced usage

Since the settings file is a Python program, it may define functions. Three functions in particular have special meaning to the build system, and will allow advanced functionality if they are defined.

The first is ModifyBuild, which if defined will be called at the end of the configuration step. It is passed a single argument: the BuildType instance (see source:trunk/python/BuildTypes.py) for this build. This allows arbitrary modification of that object.

The other two functions allow easy switching between different versions of the libraries Chaste uses. As described briefly here, a hostconfig option may be appended to the build type, something like build=default_hostconfig,boost=1-37,petsc=3-0,hdf5=1-8,xsd=3-2,use-cvode=1,use-vtk=0.

For this build type option to work, one of the functions Configure or SetPreferedVersions must be defined in the hostconfig settings file. They differ in their signature and when they are called, but have a very similar purpose, and typically at most one will be defined. Both, if defined, will be called before attempting to read any of the variables described above, and thus can set those variables to appropriate values.

The prefs dictionary contains the settings specified in the hostconfig build option. The option must follow the form hostconfig,name1=value1,name2=value2, and the name/value pairs are stored in the prefs dictionary. Due to restrictions on the allowed characters in build type names, the option string cannot include the '.' character, and so '-' is used instead; any dashes in the values will be converted to dots before being passed to the functions above.

Several functions are also pre-defined (in hostconfig.py) and made available to the settings program for use by the above functions if desired:

There is a public example of using these functions at InstallGuides/TestingMultipleVersions.

The machines folder

The file source:trunk/python/hostconfig/machines/__init__.py determines which configuration file to use based on the hostname of the machine running Chaste, and so must be edited if adding a new settings file.

If you want to maintain local settings not committed to the repository, place them in a file python/hostconfig/local.py. (The older location of python/hostconfig/machines/local.py is also supported.)