Packaging Draft / Use of environment modules
Introduction
When one has multiple programs serving the same purpose (for instance SMTP servers such as sendmail, exim and postfix; or print servers such as lprng and cups), it is usual to wrap these using alternatives. Alternatives provides a clean way to have many types of software serving the same purpose installed at the same time and have the commands such as mail
and lpr
point to the wanted versions.
However, when there are multiple variants that each serve the needs of some user and thus must be available simultaneously by users, the alternatives system simply isn't enough since it is system-wide. This has been reality on supercomputers and clusters for eons, and a solution has been developed: environment modules.
Using environment modules
To create an environment module, place a module file into /etc/modulefiles/
. To see what modules are available, run $ module avail
The module files are plain text with a tcl syntax, for instance the openmpi module openmpi-i386
is at the moment:
# OpenMPI module for use with 'environment-modules' package: # prepend-path PATH /usr/lib/openmpi/1.3.3-gcc/bin prepend-path LD_LIBRARY_PATH /usr/lib/openmpi/1.3.3-gcc/lib setenv CFLAGS "-I/usr/lib/openmpi/1.3.3-gcc/include -m32" setenv LDFLAGS "-L/usr/lib/openmpi/1.3.3-gcc/lib -lmpi" setenv MPI_BIN /usr/lib/openmpi/1.3.3-gcc/bin setenv MPI_LIB /usr/lib/openmpi/1.3.3-gcc/lib setenv MPI_HOME /usr/lib/openmpi/1.3.3-gcc
The above prepends the path with the bindir of the 32-bit OpenMPI 1.3.3 compiled with GCC and adds the relevant library path. Then it sets five environment variables.
In the case of MPI compilers, no CFLAGS or LDFLAGS should however be set, since the compilers should be invoked with the mpicc
, mpicxx
, mpif77
and mpif90
wrappers that already contain the necessary include and library paths.