Environment Modules User Guide

Environment Modules is a utility for the dynamic modification of a user’s environment via modulefiles. There is a modulefile for each of available software packages installed on the system. Therefore, users may use the module command to check available software on the system. Users can issue a module command to dynamically set or remove shell environment variables such as PATH, INCLUDE, LD_LIBRARY_PATH, MANPATH, etc. for the corresponding software package/version. Users may put a module command in the job script file as needed, and can also add a module command into their ~/.bashrc.

Check available modules/packages

The command to check the module files for installed software packages is

$ module avail

More module files will become available when software packages are added.

Example:

$ module avail

--------------------------------------------------- /opt/modulefiles/Core ---------------------------------------------------------------------------
crystal/09.1.0.1        intel/2019.1.144          mkl/2019.1.144          mpich                     plask/openblas        qchem/mpich
crystal/09.2.0.1        intel/2021.1.1   (L,D)    mkl/2020.0.166          openmpi/2.1.0             python/default        qchem/openmp
crystal/17.1.0.2 (D)    meep             (L)      mkl/2021.1.1   (L,D)    openmpi/4.0.3rc4 (D)      python/2.7            qchem/serial (D)
intel/2013.2.146        mkl/default               mpb            (L)      plask/mkl        (L,D)    python/3.8     (D)    turbomole

------------------------------------------- /usr/share/lmod/lmod/modulefiles/Core -------------------------------------------------------------------
lmod/6.6    settarg/6.6

  Where:
    L:  Module is loaded
    D:  Default Module

List loaded modules/packages

The command to list loaded modules/packages is module list

$ module list

  Currently Loaded Modules:
    1) intel/2021.1.1   2) meep   3) mpb   4) mkl/2021.1.1   5) plask/mkl

Load/add a module to set the environmental variables

The command to set the environmental variables for a software package is module load [modulefile]. You may check the loaded modules using module list after you load a module/package.

$ module load crystal
$ module list

  Currently Loaded Modules:
    1) intel/2021.1.1   2) meep   3) mpb   4) mkl/2021.1.1   5) plask/mkl   6) crystal/17.1.0.2

To display what environmental variables have been set in a module use command module display [modulename]:

$ module display crystal

-----------------------------------------------------------------------------------------------------------------------------------------------
    /opt/modulefiles/Core/crystal/17.1.0.2.lua:
-----------------------------------------------------------------------------------------------------------------------------------------------
help([[
  This module loads CRYSTAL.
]])
whatis("Name: crystal ")
whatis("Description: This module loads CRYSTAL. ")
whatis("Version: 17.1.0.2 ")
setenv("CRY_EXEDIR","/opt/crystal/Linux-ifort17_XE_emt64/v1.0.2")
setenv("CRY_SCRDIR","/tmp")
setenv("CRY_MPIBIN","/opt/openmpi-2.1.0/bin/mpirun")
prepend_path("PATH","/opt/crystal/bin")
family("crystal")

To display basic help information for a module use help subcommand:

$ module help [modulefile]

Unload/remove a module from the shell environment

The command to unset the environmental variables for a software package is module unload [modulefile]. You may check the loaded modules using module list after you unload the module/package.

$ module unload crystal
$ module list

Currently Loaded Modules:
  1) intel/2021.1.1   2) meep   3) mpb   4) mkl/2021.1.1   5) plask/mkl

Unload all loaded modules

The command to unload all the loaded modules is module purge.

$ module purge

Save and restore loaded modules

The command to save the loaded modules/packages is module save [filename]. This command will save the loaded modules/packages in a file filename in ~/.lmod.d. You can load the saved modules/packages using module restore [filename]. If the filename is omitted, then the default file ~/.lmod.d/default is used.

$ module save
$ module list

Currently Loaded Modules:
  1) intel/2021.1.1   2) meep   3) mpb   4) mkl/2021.1.1   5) plask/mkl

$ module purge
$ module list

Currently Loaded Modules:

$ module restore
$ module list

Currently Loaded Modules:
  1) intel/2021.1.1   2) meep   3) mpb   4) mkl/2021.1.1   5) plask/mkl

Search for a module

The module spider command searches for modules that match the regular expression. If the regular expression is omitted, then all modules are listed. The output of module spider is a table with the following columns:

  • Module: The name of the module.

  • Version: The version of the module.

  • Description: A brief description of the module.

  • Keywords: A list of keywords that are used to search for the module.

  • URL: A URL that can be used to get more information about the module.

The module spider command is a powerful tool that can be used to search for modules. It is important to note that the module spider command is not the same as the module avail command. The module avail command lists the modules that are available to the user. The module spider command searches for modules that match the regular expression. If the regular expression is omitted, then all modules are listed.

The module spider command is useful when you are trying to find a module for a particular software package. For example, if you are looking for a module for the FFTW package, you can use the following command

$ module spider fftw

This will list all the modules that are available for FFTW. The module spider command is case insensitive, so you can also use the following command

$ module spider FFTW

If you know the name of the module, but you are not sure what version is available, you can use the following command

$ module spider fftw/3.3

This will list all the modules that are available for FFTW 3.3.

ml: a convenient tool

For those of you who can’t type the mdoule, moduel, err module command correctly, Lmod has a tool for you. With ml you won’t have to type the module command again. The two most common commands are module list*and *module load <something> and ml does both

$ ml

means module list. And

$ ml foo

means module load foo while

$ ml -bar

means module unload bar. It won’t come as a surprise that you can combine them

$ ml foo -bar

means module unload bar; module load foo. You can do all the module commands

$ ml save
$ ml avail
$ ml spider
$ ml show foo

If you ever have to load a module name spider you can do

$ ml load spider

If you are ever force to type the module command instead of ml then that is a bug and should be reported.