Skip to content

Environment Modules

Under Construction

This page still needs serious work, but it's here as a placeholder. I replaced the output of the TCL Modules module help command with the Lmod version, but I still need to adjust the rest of the content.

  • Remove initadd/del/prepend/rm/switch/list/clear/etc commands
    • they aren't in Lmod
  • Add spider command
  • Add save/restore
  • Add others as needed

NERSC has a page on Lmod that I may "adapt".

Kennesaw State's VHPC uses a piece of software known as Environment Modules to manage nearly all our installed software. There are two huge advantages of the module approach:

  1. We can provide many different versions and installations of a single package on a given machine, including a default version as well as several older and newer versions; and

  2. Users can easily switch to different versions or installations without specifying additional paths. The Environment Modules software manages environment variables and configuration settings for each package without the user needing any details about how we installed the software.

The Environment Modules software consists of two parts: the module command and the modulefiles on which it operates.

Module Command Syntax

module help

To get a usage list of module commands, type the following:

[barney@vhpc ~]$ module help
Usage: module [options] sub-command [args ...]

Options:
  -h -? -H --help                   This help message
  -s availStyle --style=availStyle  Site controlled avail style: system (default: system)
  --regression_testing              Lmod regression testing
  -D                                Program tracing written to stderr
  --debug=dbglvl                    Program tracing written to stderr (where dbglvl is a
                                    number 1,2,3)
  --pin_versions=pinVersions        When doing a restore use specified version, do not
                                    follow defaults
  -d --default                      List default modules only when used with avail
  -q --quiet                        Do not print out warnings
  --expert                          Expert mode
  -t --terse                        Write out in machine readable format for commands: list,
                                    avail, spider, savelist
  --initial_load                    loading Lmod for first time in a user shell
  --latest                          Load latest (ignore default)
  --ignore_cache                    Treat the cache file(s) as out-of-date
  --novice                          Turn off expert and quiet flag
  --raw                             Print modulefile in raw output when used with show
  -w twidth --width=twidth          Use this as max term width
  -v --version                      Print version info and quit
  -r --regexp                       use regular expression match
  --gitversion                      Dump git version in a machine readable way and quit
  --dumpversion                     Dump version in a machine readable way and quit
  --check_syntax --checkSyntax      Checking module command syntax: do not load
  --config                          Report Lmod Configuration
  --config_json                     Report Lmod Configuration in json format
  --mt                              Report Module Table State
  --timer                           report run times
  --force                           force removal of a sticky module or save an empty
                                    collection
  --redirect                        Send the output of list, avail, spider to stdout (not
                                    stderr)
  --no_redirect                     Force output of list, avail and spider to stderr
  --show_hidden                     Avail and spider will report hidden modules
  --spider_timeout=timeout          a timeout for spider
  -T --trace
  --nx --no_extensions
  --loc --location                  Just print the file location when using show


module [options] sub-command [args ...]

Help sub-commands:
------------------
  help                              prints this message
  help                module [...]  print help message from module(s)

Loading/Unloading sub-commands:
-------------------------------
  load | add          module [...]  load module(s)
  try-load | try-add  module [...]  Add module(s), do not complain if not found
  del | unload        module [...]  Remove module(s), do not complain if not found
  swap | sw | switch  m1 m2         unload m1 and load m2
  purge                             unload all modules
  refresh                           reload aliases from current list of modules.
  update                            reload all currently loaded modules.

Listing / Searching sub-commands:
---------------------------------
  list                              List loaded modules
  list                s1 s2 ...     List loaded modules that match the pattern
  avail | av                        List available modules
  avail | av          string        List available modules that contain "string".
  spider                            List all possible modules
  spider              module        List all possible version of that module file
  spider              string        List all module that contain the "string".
  spider              name/version  Detailed information about that version of the module.
  whatis              module        Print whatis information about module
  keyword | key       string        Search all name and whatis that contain "string".

Searching with Lmod:
--------------------
  All searching (spider, list, avail, keyword) support regular expressions:


  -r spider           '^p'          Finds all the modules that start with `p' or `P'
  -r spider           mpi           Finds all modules that have "mpi" in their name.
  -r spider           'mpi$         Finds all modules that end with "mpi" in their name.

Handling a collection of modules:
--------------------------------
  save | s                          Save the current list of modules to a user defined
                                    "default" collection.
  save | s            name          Save the current list of modules to "name" collection.
  reset                             The same as "restore system"
  restore | r                       Restore modules from the user's "default" or system
                                    default.
  restore | r         name          Restore modules from "name" collection.
  restore             system        Restore module state to system defaults.
  savelist                          List of saved collections.
  describe | mcc      name          Describe the contents of a module collection.
  disable             name          Disable (i.e. remove) a collection.

Deprecated commands:
--------------------
  getdefault          [name]        load name collection of modules or user's "default" if
                                    no name given.
                                    ===> Use "restore" instead <====
  setdefault          [name]        Save current list of modules to name if given, otherwise
                                    save as the default list for you the user.
                                    ===> Use "save" instead. <====

Miscellaneous sub-commands:
---------------------------
  is-loaded           modulefile    return a true status if module is loaded
  is-avail            modulefile    return a true status if module can be loaded
  show                modulefile    show the commands in the module file.
  use [-a]            path          Prepend or Append path to MODULEPATH.
  unuse               path          remove path from MODULEPATH.
  tablelist                         output list of active modules as a lua table.

Important Environment Variables:
--------------------------------
  LMOD_COLORIZE                     If defined to be "YES" then Lmod prints properties and
                                    warning in color.

    ------------------------------------------------------------------------------------------

Lmod Web Sites

  Documentation:    http://lmod.readthedocs.org
  Github:           https://github.com/TACC/Lmod
  Sourceforge:      https://lmod.sf.net
  TACC Homepage:    https://www.tacc.utexas.edu/research-development/tacc-projects/lmod

  To report a bug please read http://lmod.readthedocs.io/en/latest/075_bug_reporting.html
    ------------------------------------------------------------------------------------------



Modules based on Lua: Version 8.5  2021-05-10 13:40 -05:00
    by Robert McLay mclay@tacc.utexas.edu

module list

[barney@vhpc ~]$ module list

This command lists all the modulefiles that are currently loaded into your environment.

module avail

[barney@vhpc ~]$ module avail

This command lists all the modulefiles that are available to be loaded. Notice that many have version numbers associated with them and that one is labeled as the default where there is more than one version. You can also restrict this command to a single package; for example,

[barney@vhpc ~]$ module avail visit

module display

[barney@vhpc ~]$ module display [modulefile]

Use this command to see all of the changes a given modulefile will make in your environment, such as changes to the PATH environment variable. This command is synonymous with

[barney@vhpc ~]$ module show [modulefile]

module load

[barney@vhpc ~]$ module load [modulefile1] [modulefile2] ...

This command adds one or more modulefiles to your 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 modulefile using its full specification. For example,

[barney@vhpc ~]$ module load visit

will do the same thing as

[barney@vhpc ~]$ module load visit/2.1.2

module unload

[barney@vhpc ~]$ module unload [modulefile]

This command removes the listed module from the user's current environment. Modulefiles can be removed in any order. Note that this command will fail silently if the modulefile you specify is not already loaded.

module switch

[barney@vhpc ~]$ module switch [modulefile_old] [modulefile_new]

This command demonstrates the true advantage of using modules. You can use this command to switch between versions of software packages (or even switch between different packages) with a single module command.

This command is synonymous with

[barney@vhpc ~]$ module swap [modulefile_old] [modulefile_new]

Note that the following command would be completely correct and appropriate if, before issuing it, you had issued a module load command for a non-default version of the VisIt software and you wish to switch to the default version:

[barney@vhpc ~]$ module swap visit visit

Please refer to module man page for more details.

Loading Modules into Your Default Environment

Use the .modules file to maintain the modules you wish to load whenever you log in. However, you can use any of the following files, depending on your shell:

Shell Shell Startup Files
csh .modules, .cshrc(.ext), .csh_variables, and .login(.ext)
tcsh .modules, .tcshrc, .cshrc(.ext), .csh_variables, and .login(.ext)
sh .modules and .profile(.ext)
ksh .modules, .profile(.ext), and kshenv(.ext)
bash .modules, .bash_profile, .bash_login, .profile(.ext), and .bashrc(.ext)
zsh .modules, .zshenv(.ext), .zlogin(.ext), and .zshrc(.ext)

The system checks for the startup files in the order they are listed.

The module command comes with a series of sub-commands to help maintain your startup files:

module initadd

[barney@vhpc ~]$ module initadd modulefile

This command adds modulefile to the shell's initialization file in your home directory. For any of the init sub-commands to work correctly, you must add a module load line to one of the startup files listed above. If the module load line is found in multiple shell initialization files, all instances of the module load lines are changed.

module initprepend

[barney@vhpc ~]$ module initprepend modulefile

This command does the same thing as module initadd but prepends the given modules to the beginning of the list.

module initrm

[barney@vhpc ~]$ module initrm modulefile

This command removes modulefile from the shell's initialization files.

module initswitch

[barney@vhpc ~]$ module initswitch modulefile_old modulefile_new

This command switches modulefile_old with modulefile_new in the shell's initialization files.

module initlist

[barney@vhpc ~]$ module initlist

This command lists all of the modulefiles loaded from the shell's initialization file.

module initclear

[barney@vhpc ~]$ module initclear

This command clears all of the modulefiles from the shell's initializtion files.

Install your own customized modules

You can create and install modules for your convenience or share software among collaborators. The module definition files can be in a project directory, your home directory, or any available file system. Ensure the UNIX file permissions grant access to all users who want to use the software. (Note: do not give write permissions in your home directory to anyone else!)

You can look at the existing modules and the modulefile man page for information regarding writing module files. Take a look at the use.own module. It automatically creates and enables a private module directory in your home directory.

Please contact hpc@kennesaw.edu if you need help with creating modules.

References

Information taken from NERSC Web Site: http://www.nersc.gov/users/software/nersc-user-environment/modules/