What are modules?

It is often desirable to have multiple versions of the same software installed and usable at the same time. The lmod modules system makes it very easy to specify which version you want to use and keeps everything consistent. There are also circumstances, where one software program will have some environment setting or file that conflicts with a different program, and also has modules that help solve this problem.

Which modules are available?

Most software packages available on ABACUS2.0 can be found as a module. To see a list of available software run the command module spider.

Note that the list below is not updated automatically. To get an updated list, rerun the command on the frontend node. You can also look at our software page.

testuser@fe1:~$ module spider

----------------------------------------------------------------------------
The following is a list of the modules currently available:
----------------------------------------------------------------------------
  amber: amber/14-2015.04

  cmake: cmake/3.2.2
    CMake is a cross-platform, open-source build system

  gcc: gcc/4.8-c7
    GCC 4.8 as provided by Centos7

  gromacs: gromacs/4.6.7, gromacs/5.0.4-openmpi, gromacs/5.0.4

  intel: intel/2015.02
    Intel Compiler Collection

  intelmpi: intelmpi/2015.02
    Intel MPI

  lmod: lmod/5.7.5
    Lmod: An Environment Module System

  namd: namd/2.10

  openmpi: openmpi/1.8.4
    OpenMPI

  settarg: settarg/5.7.5

----------------------------------------------------------------------------
To learn more about a package enter:

   $ module spider Foo

where "Foo" is the name of a module

To find detailed information about a particular package you
must enter the version if there is more than one version:

   $ module spider Foo/11.1
----------------------------------------------------------------------------

You can optionally specify a package name, and it will show you all available versions of that package. For example, here is what it could look like for GROMACS (GROningen MAchine for Chemical Simulations (GROMACSis a molecular dynamics package mainly designed for simulations of proteins, lipids, and nucleic acids).

testuser@fe1:~$ module spider gromacs

----------------------------------------------------------------------------
  gromacs:
----------------------------------------------------------------------------
     Versions:
        gromacs/4.6.7
        gromacs/5.0.4-openmpi
        gromacs/5.0.4

----------------------------------------------------------------------------
  To find detailed information about gromacs please enter the full name.
  For example:

     $ module spider gromacs/5.0.4
----------------------------------------------------------------------------

testuser@fe1:~$ module spider gromacs/5.0.4

----------------------------------------------------------------------------
  gromacs: gromacs/5.0.4
----------------------------------------------------------------------------

    This module can be loaded directly: module load gromacs/5.0.4

    Help:
            GROMACS is a collection of molecular dynamics simulation programs.
            http://www.gromacs.org/

The default version is shown last. In general, the default version is always the newest installed version. If you want a specific version, you should always specify it as shown in the later examples.

Load a module

To load a module, use the command module load modulename. The default version will get loaded. If you want a particular version, use module load modulename/version, e.g.:

testuser@fe1:~$ module list
No modules loaded

testuser@fe1:~$ module load gromacs
testuser@fe1:~$ module list
Currently Loaded Modules:
  1) intel/2015.02   2) intelmpi/2015.02   3) gromacs/5.0.4

Note that module load automatically loads dependencies. In this case GROMACS (GROningen MAchine for Chemical Simulations (GROMACSis a molecular dynamics package mainly designed for simulations of proteins, lipids, and nucleic acids) on a specific version of the Intel compiler and Intel MPI (Message Passing Interface – definition: is a standardized means of exchanging messages between multiple computers running a parallel program across distributed memory).

Multiple modules can be loaded in a single command e.g.

testuser@fe1:~$ module load cmake gromacs
testuser@fe1:~$ module list

Currently Loaded Modules:
  1) cmake/3.2.2   2) intel/2015.02   3) intelmpi/2015.02   4) gromacs/5.0.4

Unload a module

To unload a module, use the command module unload modulename. To unload everything, use module purge

testuser@fe1:~$ module list

Currently Loaded Modules:
  1) cmake/3.2.2   2) intel/2015.02   3) intelmpi/2015.02   4) gromacs/5.0.4

testuser@fe1:~$ module unload gromacs
testuser@fe1:~$ module list

Currently Loaded Modules:
  1) cmake/3.2.2

testuser@fe1:~$ module purge
testuser@fe1:~$ module list
No modules loaded

Note that module unload automatically unloads dependencies.

See what modules have been loaded

The command module list shows which modules have been loaded.

testuser@fe1:~$ module list

Currently Loaded Modules:
  1) cmake/3.2.2   2) intel/2015.02   3) intelmpi/2015.02   4) gromacs/5.0.4

Switch to a different version of a module

The command module switch modulename modulename/version switches from one version of a module to another.

testuser@fe1:~$ module list

Currently Loaded Modules:
  1) intel/2015.02   2) intelmpi/2015.02   3) gromacs/5.0.4

testuser@fe1:~$ module switch gromacs gromacs/4.6.7
testuser@fe1:~$ module list

Currently Loaded Modules:
  1) intel/2015.02   2) intelmpi/2015.02   3) gromacs/4.6.7

Examine a module file

If you want to see what the module command is doing to your environment, you can run:

testuser@fe1:~$ module show amber/14-2015.04
------------------------------------------------------------------------------
   /opt/sys/modulefiles/Apps/amber/14-2015.04.lua:
------------------------------------------------------------------------------
help([[       AMBER is a collection of molecular dynamics simulation programs.
        Amber is ONLY available for SDU users.
        http://ambermd.org/
]])
whatis("AMBER is a collection of molecular dynamics simulation programs")
conflict("amber")
load("intel","openmpi")
setenv("AMBERHOME","/opt/sys/apps/amber/14-2015.04")
setenv("AMBER_DAT","/opt/sys/apps/amber/14-2015.04/dat")
prepend_path("PATH","/opt/sys/apps/amber/14-2015.04/bin")
prepend_path("LD_LIBRARY_PATH","/opt/sys/apps/amber/14-2015.04/lib")
prepend_path("LD_RUN_PATH","/opt/sys/apps/amber/14-2015.04/lib")
prepend_path("MANPATH","/opt/sys/apps/amber/14-2015.04/share/man")
prepend_path("PKG_CONFIG_PATH","/opt/sys/apps/amber/14-2015.04/lib/pkgconfig")

Module dependencies

Some modules depend on other modules to work e.g. Gromacs requires the intel and intelmpi packages. In general dependencies are auto-loaded but in some cases this is not possible e.g. if you want to use two packages that depend on two different MPI implementations:

testuser@fe1:~$ module purge
testuser@fe1:~$ module load amber
testuser@fe1:~$ module load gromacs

Lmod has detected the following error: You can only have one mpi module loaded at a time.
You already have openmpi loaded.
To correct the situation, please enter the following command:

  module swap openmpi intelmpi/2015.02

Please submit a consulting ticket if you require additional assistance.
...

In general, the safest option is to module purge all modules before loading new modules:

testuser@fe1:~$ module purge
testuser@fe1:~$ module load amber
testuser@fe1:~$ # ... use amber ...
testuser@fe1:~$ module purge
testuser@fe1:~$ module load gromacs

A similar problem occurs for the different available MPI implementations which have been compiled/optimized for each by the compilers in our system. You should first select the compiler you want to use and then select the MPI implementation:

testuser@fe1:~$ module load openmpi/1.8.4

Lmod has detected the following error:
These module(s) exist but cannot be loaded as requested: "openmpi/1.8.4"

   Try: "module spider openmpi/1.8.4" to see how to load the module(s).

testuser@fe1:~$ module spider openmpi/1.8.4

------------------------------------------------------------------------------
  openmpi: openmpi/1.8.4
------------------------------------------------------------------------------
    Description:
      OpenMPI

    This module can only be loaded through the following modules:

      gcc/4.8-c7
      intel/2015.02

    Help:
        This module loads the OpenMPI compiler path and environment variables
        http://www.open-mpi.org/

testuser@fe1:~$ module load gcc/4.8-c7 openmpi/1.8.4

Using modules in scripts

The module command can be used in scripts e.g. slurm batch scripts:

#! /bin/bash
#SBATCH options
#...

module purge
module load somemodule
...
some-command-depending-on-some-module

Further reading