HPC2N - Support - Environment: Using the 'module' command

Using the module command

 

The module command is the preferred method for a user to manage the environment. It is used both to load libraries and paths for  specific applications or compilers. The modules are organized into packages which may be added and removed as needed. Please use the module command instead of configuring the environment manually. HPC2N will from time to time make changes to the various packages - these will be transparent to you if you use module to manage your environment.

Below follows a short introduction to the module command. To learn more, read the man page for module.

Typing module or module help at the command line will give you a brief usage report. 

$ module
$ module help

Important module commands

These are some of the more commonly used module commands. To see more commands, run module or module help. All commands should be entered as module <command> OR <command> <module name>. Note that adding modules etc. is only done for that one shell you are working in.

Command What it does
add <module name> OR
load <module name>
Loads the path and other environment variables for the program/library <module name>
rm <module name> OR
unload <module name>
Attempts to undo the changes to the shell environment done by the addition of a module (removes the module)
module display <module name> OR
module show <module name>
Shows what it will do to your environment to add this module
module avail OR
module avail <module name>
Lists the available modules - if a module name is given (like psc for PathScale compilers) it will list the available versions of that module
module purge Removes (or attempts to remove) all modules you had added. Warning: sometimes does not do so correctly!
module list Lists all the modules you currently have loaded

Available modules

In order to learn which modules are available, type

module avail

Available versions of a module

In order to see which versions are available for a certain module (for instance, which PathScale compiler versions are available), you must use the command:

module avail <module name>

Example for PathScale

p-bc9901 [~]$ module avail psc  
-------------------- /usr/local/modulefiles ---------------- 
psc/3.1-261.14750       psc/3.2-459.15310      psc/3.3-beta 
psc/3.1.99(3.1)         psc/3.2-560.15310(default:3.2) 
p-bc9901 [~]$

This will often tell you which version is the default version (e.g. which version that will be loaded if you only give the program (like psc) and not the version number too (like psc/3.1).

Note: module avail does prefix match to whatever string you give it. If you are unsure of the name of a module (say, looking for blas and not knowing it is called xblas), and you do not get any matches from module avail, you might try using module apropos -i instead. It does not always work correctly, but might give matches when the above does not (such as for blas).

module apropos

Used to find matches for programs, where you do not know the name of the module. You must use the -i flag (case insensitive module parameter evaluation) to get the expected output.

Example, blas:

p-bc9901 [~]$ module avail blas
p-bc9901 [~]$ 
p-bc9901 [~]$ module apropos -i blas
espressomd/2.2.0b(3):ERROR:102: Tcl command execution failed: source /lap/hdf5/1.8.5/modulefiles/.global

gotoblas2/1.13/gcc   : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/1.13/intel : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/1.13/pgi   : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/1.13/psc   : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/gcc        : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/intel      : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/pgi        : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
gotoblas2/psc        : GotoBLAS2 - High-Performance BLAS by Kazushige Goto
libgoto/gcc          : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/intel        : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/pgi          : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/psc          : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/r1.26/gcc    : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/r1.26/intel  : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/r1.26/pgi    : GOTOBLAS - High-Performance BLAS by Kazushige Goto
libgoto/r1.26/psc    : GOTOBLAS - High-Performance BLAS by Kazushige Goto
xblas/1.0.248/gcc    : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/1.0.248/intel  : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/1.0.248/pgi    : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/1.0.248/psc    : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/gcc            : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/intel          : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/pgi            : xblas - Extra Precise Basic Linear Algebra Subroutines
xblas/psc            : xblas - Extra Precise Basic Linear Algebra Subroutines
p-bc9901 [~]$ 

Loading/adding a module

To add or load a module, use

module add <module name>

or

module load <module name>

Note that modules can consist of both a name and a version number. When loading a module, you can  use only the name to load the default version, or specify which version you wish to load. 

Examples

(Loading the module openmpi/gcc - the GCC compilers with OpenMPI libraries - default version)

p-bc9901 [~]$ module load openmpi/gcc
p-bc9901 [~]$ 

 

(loading the module openmpi/1.3.3/gcc - the GCC compilers with OpenMPI libraries - version 1.3.3)

p-bc9901 [~]$ module load openmpi/1.3.3/gcc
p-bc9901 [~]$

Note that you will need to load any relevant modules within job submission scripts that use those applications. Loading the module before submitting your job is not sufficient.

Unloading/removing a module

To unload a module use

module unload <module name>

or

module rm <module name>

List currently loaded modules

You list the currently loaded modules with the command module list:

p-bc9901 [~]$ module list
Currently Loaded Modulefiles:
  1) systemdefault
p-bc9901 [~]$ 

If you load a module this list will change:

p-bc9901 [~]$ module list
Currently Loaded Modulefiles:
  1) systemdefault  2) openmpi/gcc
p-bc9901 [~]$ 

Then when you unload the module again:

p-bc9901 [~]$ module unload openmpi/gcc
p-bc9901 [~]$ module list
Currently Loaded Modulefiles:
  1) systemdefault
p-bc9901 [~]$ 

Show module details

To see what loading a module will do to your path and environment, you can use the command

module show <module name>

Examples

(the effect of loading the PathScale Compiler suite)

p-bc9901 [~]$ module show psc
--------------------------------------------------------------
/usr/local/modulefiles/psc/3.2-560.15310:


	Pathscale compiler 3.2-560.15310

setenv	      PSC_VERSION 3.2 
setenv	      PSC /lap/psc/3.2-560.15310 
setenv	      PSC_COMPILER_DEFAULTS_PATH 
              /lap/psc/3.2-560.15310/configs/gcc4.1 
prepend-path  PATH /lap/psc/3.2-560.15310/bin 
prepend-path  LD_LIBRARY_PATH /lap/psc/3.2-560.15310/lib/3.2/32 
prepend-path  LD_LIBRARY_PATH /lap/psc/3.2-560.15310/lib/3.2 
prepend-path  MANPATH /lap/psc/3.2-560.15310/man 
setenv	      __PSC_LOADED_GCC no 
--------------------------------------------------------------

p-bc9901 [~]$ 

(the effect of loading the PathScale Compiler suite, version 3.1.99)

p-bc9901 [~]$ module show psc/3.1.99
--------------------------------------------------------------
/usr/local/modulefiles/psc/3.1.99:


	Pathscale compiler 3.1.99

setenv	       PSC_VERSION 3.1.99 
setenv	       PSC /lap/psc/3.1.99 
setenv	       PSC_COMPILER_DEFAULTS_PATH 
               /lap/psc/3.1.99/configs/gcc4.1 
prepend-path   PATH /lap/psc/3.1.99/bin 
prepend-path   LD_LIBRARY_PATH /lap/psc/3.1.99/lib/3.1.99/32 
prepend-path   LD_LIBRARY_PATH /lap/psc/3.1.99/lib/3.1.99 
prepend-path   MANPATH /lap/psc/3.1.99/man 
setenv	       __PSC_LOADED_GCC no 
--------------------------------------------------------------

p-bc9901 [~]$