The National Institute for Computational Sciences

Modules

Description

The modules software package allows you to dynamically modify your user environment by using “modulefiles.”

Each modulefile contains the information needed to configure the shell for an application. After the modules software package is initialized, the environment can be modified on a per-module basis using the module command, which interprets modulefiles. Typically, modulefiles instruct the module command to alter or set shell environment variables such as PATH, MANPATH, and others. The modulefiles can be shared by many users on a system, and users can have their own collection to supplement or replace the shared modulefiles.

As a user, you can add and remove modulefiles from the current environment. The environment changes contained in a modulefile can also be summarized through the module show command. You are welcome to change modules in your .bashrc or .cshrc, but be aware that some modules print information (to standard error) when loaded, this should be directed to a file or /dev/null when loaded in an initialization script.

More information on modules can be found by typing module help on the NICS systems. Ignore the module init* commands – these modify a .modulerc file which is incompatible with the way NICS modules are set up. If you run into any issues, remove any .modulerc and log in again.

Use

The following table lists the most common module command options

Command Description
module list Lists modules currently loaded in a user's environment. A module is considered loaded when its associated modulefile has been executed and the user's environment contains the changes from the modulefile.
module avail Lists all available modules on a system.
module show Shows environment changes that will be made by loading a given module.
module load Loads a module.
module unload Unloads a module.
module help Shows help for a module.
module swap Swaps a currently loaded module for an unloaded module.

Note: The module command outputs to stderr. To grep this in bash, use

module avail 2>&1 | grep 'acml'

In tcsh, simply use

module avail |& grep 'acml'

Examples

  1. Find the name of the HDF5 module.
    % module avail
      CC                  X11                 libsci
      CC.5.1.0.4          X11.6.6.0.1         libsci.5.1.0.1
      CC.5.1.0.5          X11.6.6.0.2         libsci.5.4.0.1
      hdf5-par            ncarg-1             netcdf-3
      hdf5-ser            globus              netcdf-5
    
  2. Verify that the HDF5 module or another version of the module is not currently loaded. Loading multiple versions of the same module can have unpredictable results.
    % module list
       Currently Loaded Modulefiles:
      1) CC        4) hdf5-ser
      2) X11
      3) libsci
    
  3. Help on a particular modulefile including usage can be obtained.
    % module help netcdf/3.6.2
    --- Module Specific Help for 'netcdf/3.6.2' ----
    Sets up environment to use netcdf 3.6.2.
    Usage:   ftn test.f90 ${NETCDF_FLIB}
        or   cc test.c ${NETCDF_CLIB}
    
  4. If another version of the HDF5 module is loaded (as in the above example) it must first be unloaded, or it can simply be swapped for the needed module.
    % module swap hdf5-ser hdf5-par
    
  5. If there is not a version of the needed module (hdf5-par) currently loaded, the module can simply be loaded.
    % module load hdf5-par
    
  6. Verify the change.
    % module list
       Currently Loaded Modulefiles:
      1) CC        4) hdf5-par
      2) X11
      3) libsci
    
  7. Show environment changes that will be made by loading a HDF5 module:
    %  module show hdf5/1.8.6
    ---------------------------
    /opt/cray/modulefiles/hdf5/1.8.6:
    
    conflict         hdf5-parallel
    conflict         PrgEnv-pathscale
    setenv           CRAY_HDF5_DIR /opt/cray/hdf5/1.8.6
    setenv           CRAY_HDF5_VERSION 1.8.6
    prepend-path     PE_PRODUCT_LIST CRAY_HDF5
    prepend-path     PATH /opt/cray/hdf5/1.8.6/pgi/109/bin
    setenv           HDF5_DIR /opt/cray/hdf5/1.8.6/pgi/109
    setenv           HDF5_INCLUDE_OPTS /opt/cray/hdf5/1.8.6/pgi/109/include
    prepend-path     CRAY_LD_LIBRARY_PATH /opt/cray/hdf5/1.8.6/pgi/109/lib
    ---------------------------