Using Modules to Manage Software

The Discovery cluster uses modules to manage the user environment for different third-party software versions. The advantage of the modules approach is that the user is no longer required to explicitly specify paths for different executable versions, and to try to keep the PATH, MANPATH and related environment variables coordinated. With the modules approach, users simply “load” and “unload” modules to control their environment.


Modules provides an easy mechanism for updating a user’s environment especially the PATH, MANPATH, and LD_LIBRARY_PATH environment variables to name a few. When you get a Discovery cluster account, your dot-files should be set up correctly to use modules. If you delete or modify these files in such a way to make modules fail, contact the Discovery consultants for help.

You can modify your environment so that certain modules are loaded whenever you log in.

Use this command to have a module automatically loaded each time you log into the system:

  • module initadd modulename
  • where modulename is the name of the module you want loaded.
Module commands

module help – Get a usage list of module options

The listing has been abbreviated to only show those commands discussed in this page.

$ module help

Available Commands and Usage:

+  add|load     modulefile [modulefile ...]
+  rm|unload    modulefile [modulefile ...]
+  switch       modulefile1 modulefile2
+  display      modulefile [modulefile ...]
+  avail        path [path]
+  list
+  initadd	modulefile [modulefile ...]
+  help         modulefile [modulefile ...]
+  initrm       modulefile [modulefile ...]
+  initswitch   modulefile1 modulefile2

module list – This lists all the modules which are currently loaded into the users environment.

$ module list

Currently Loaded Modulefiles:
1) modules/3.2.9(default)                7) totalview/8.4(default)
2) matlab/r2013a(default)                8) maple/11.0(default)
3) intel-compilers/13.0(default)          9) mathematica/6.0(default)
4) pgi-compilers/7.1-3(default)         10) idl/7.0(default)
5) mpich/1.2.7p1-intel9.1(default)      11) opendx/4.4.0(default)
6) mpiexec/0.83(default)                12) paraview/3.2.1(default)

module avail – This option lists all the modules which are available to be loaded.

Notice that many of them have version numbers associated with them. Modules makes it easy to switch compiler application versions. The default version is identified in the listing.

$module avail

------------------------ /opt/Modules/3.2.9/modulefiles ------------------------
acml/4.1.0-intel(default)                      mpich/1.2.7p1-pgi7.1.3
dot                                            mpich2/1.0.7rc2-intel9.1(default)
idl/7.0(default)                               mpiexec/0.83(default)
intel-compilers/9.1(default)                   mumps/4.7.3-intel(default)
maple/11.0(default)                            mvapich/0.99-gcc4.1.2
mathematica/6.0(default)                       mvapich/0.99-intel9.1(default)
matlab/r2007b                                  mvapich/0.99-pgi7.1.3
matlab/r2009a(default)                         mvapich2/0.98-intel9.1(default)
mkl/9.0(default)                               netcdf/3.6.2(default)
moduleinfo                                     opendx/4.4.0(default)
modules/3.2.6(default)                         paraview/3.2.1(default)
mpich/1.2.7p1-gcc4.1.2                         pgi-compilers/7.1-3(default)
mpich/1.2.7p1-intel9.1(default)                scalapack/1.7.3-intel(default)
mpich/1.2.7p1-intel9.1-gcc                     totalview/8.4(default)

module help modulefile* – To retrieve more information about a module, use this command to display the help information contained within the given module file.

$ module help netcdf

----------- Module Specific Help for 'netcdf/3.6.2' ---------------

Sets up the environment to use the netCDf libraries
Sets up the netCDF libraries, include files, binaries and man pages.
Add $NETCDF_LIB to include the netcdf library when linking your program.
Example: ifort -o myprog myproc.f $NETCDF_LIB
Add $NETCDF_INCLUDE to include the netcdf include files when compiling.
Example: ifort $NETCDF_INCLUDE -c myproc.f

module display modulefile – Use this command to see exactly what a given modulefile will do to your environment, such as what will be added to the PATH, MANPATH, and other environment variables.

$ module display matlab


module-whatis    loads Matlab version R2009a
prepend-path     PATH /opt/matlab/Matlab_R2009a/bin

module load modulefile – This adds one or more modulefiles to the user’s current environment. It does so silently, unless there is a problem with a modulefile.

If you load the generic name of a module, you will get the default version.

To load a specific version, load the module using its full specification.

module load matlab/r2007b

module unload modulefile – This removes any listed modules from the user’s current environment.

The modules can be removed in any order.

module unload matlab/r2007b

module switch  old_modulefile  new_modulefile – This command demonstrates the true advantages of modules. Different versions of entire software packages can be replaced with a single module command.

module initadd modulefile – This command modifies your environment so the module is loaded automatically whenever you log in.

module initrm modulefile – This command modifies your environment so the module will not be loaded automatically when you log into the system.

module initswitch modulefile1 modulefile2 – This command modifies your environment so the modulefile2  will be loaded automatically instead of modulefile1.