3. Modulefile Contents

Typically, a modulefile contains commands for extending the PATH, MANPATH, INCLUDE, and LD_LIBRARY_PATH variables for local applications and tools. It may also include commands to create variables, aliases, and functions that facilitate using specialized hardware.

Modulefiles are written in the Tool Command Language, Tcl(3). A sample modulefile used to configure an environment using MPI is shown below.

#########################################
##
## mpi4py
##

set _module_name  [module-info name]

proc ModulesHelp { } {
global _module_name
puts stderr "The $_module_name modulefile defines the environment for the numpy
}

set _module_name  [module-info name]
set is_module_rm  [module-info mode remove]
set sys           [uname sysname]
set os            [uname release]
set mach          [uname machine]

set mpi4py_1_2_2 /usr/local/packages/mpi4py-1.2.2
set mpi4py_1_2_2_BIN $mpi4py_1_2_2/build/exe.linux-x86_64-2.7
set mpi4py_1_2_2_LIB $mpi4py_1_2_2/lib
#################################################

setenv          MPI4PY_VERSION 1.2.2
setenv          MPI4PY_DIR $mpi4py_1_2_2
module load python/2.7.1
prepend-path    PATH $mpi4py_1_2_2_BIN
prepend-path    LD_LIBRARY_PATH $mpi4py_1_2_2_LIB
append-path    PYTHONPATH       $mpi4py_1_2_2/lib/python2.7/site-packages/

Don't worry if this looks a bit complicated. HPC clusters typically provide pre-written modulefiles you can use to easily set up your environment without becoming an expert in writing modulefiles. However, if you want to learn how to code your modulefiles, see the Modulefile manpage.