Why we use environment modules

All software requires that you modify your environment in some way. Your environment consists of the running shell, typically bash on Flux, and the set of environment variables that are set. The most familiar environment variable is the PATH variable, which lists all the directories for the shell to search for a command, but there may be many others, depending on the particular software package. We use environment modules (just modules, hereafter) to resolve the changes needed to accommodate having many versions of the same software installed and usable. We use modules to help manage conflicts among the environment variables across the spectrum of software packages. Modules can be used to modify your own default environment settings, and they are also useful if you install software for your own use.

Basic usage

The modules software provides the module command, an easy mechanism for changing the environment as you need to add or remove software packages from your environment. A module is a collection of environment variable settings that can be loaded or unloaded. When you first log into Flux, a set of modules is loaded by default. To see which modules are currently loaded, you can use the command

$ module list

To see what modules are available, or to see which versions of a particular package (Matlab in the example) are available, you can use (respectively) the commands

$ module available
[ . . . deleted . . . ]
$ module av matlab
----------------- /usr/flux/software/rhel6/Modules/modulefiles -----------------
matlab/2010b          matlab/2012b          matlab/2014a
matlab/2012a(default) matlab/2013a

where available can be abbreviated to as little as av for brevity. As you can see, there are several version of Matlab available. If you use the command

$ module load matlab

the version labeled (default) will be loaded. If there is no default version set, then the one with the highest version number will be loaded. To load a version other than the default, you specify the version as it is displayed by the module av command; for example,

$ module load matlab/2014a

To unload a module, you would use

$ module unload matlab

where you do not need to specify the version of the package’s module that you are unloading (rm is a synonym for unload).

To see what a module will set in your environment, say for the software package R, you would use

$ module show R
-------------------------------------------------------------------
/home/software/rhel6/Modules/modulefiles/R/2.15.1:

conflict	 R 
prepend-path	 PATH /home/software/rhel6/R/2.15.1-gcc/bin 
prepend-path	 LD_LIBRARY_PATH /home/software/rhel6/R/2.15.1-gcc/lib64/R/lib 
module-whatis	 R is a software environment for statistical computing. 
module-whatis	 Flux Documentation: https://arc.umich.edu/software/R/
module-whatis	 Vendor Website: http://www.r-project.org/ 
module-whatis	 Manual: http://cran.r-project.org/manuals.html 
-------------------------------------------------------------------

The output shows you the location of the R module file, any conflicts (in this case, only other versions of R) and what will be added to the beginning of your PATH and LD_LIBRARY_PATH (loader library path) environment variables. It will also show references to online documentation for the package, if they are available.

Module groups

Currently, modules are provided by the administrative unit that installs and maintains the software, and each unit has a module repository. The default repository is that provided by the CAEN HPC unit. Other units are LSA, the Medical School, the School of Public Health, and the Institute for Social Research. To see or use the software provided by those units, you must first load the unit module, which adds the unit’s collection of modules to the list.

For example, the following transcript shows loading the lsa module, querying available versions of the package fsl, where you will note there are two locations

$ module load lsa
$ module av fsl

------------------- /home/software/rhel6/Modules/modulefiles -------------------
fsl/5.0.2.2 fsl/5.0.6

----------------- /home/software/rhel6/lsa/Modules/modulefiles -----------------
fsl/4.1.9

$ module load fsl
$ module list
Currently Loaded Modulefiles:
  1) moab        3) modules     5) git/1.8.1   7) fsl/5.0.6
  2) torque      4) use.own     6) lsa

The most recent version was loaded from the first listed module repository.