You are here:

Modules at CHPC

There is a short training video that covers the basics of modules. Modules is an environment management tool which makes modifying the user's shell environment simple and dynamic. The advantage of modules primarily comes from the capability to load and unload the environment needed for a given software package, allowing users to quickly and easily start using programs or switch development environments. CHPC has implemented modules on all of its clusters to improve the user experience and to align with other national computing centers which are now using modules. 

For the foreseeable future, CHPC users will have the choice to adopt the module environment or to remain with the script sourcing method that has been used in the past.  All new users accounts will be started with the module option. In order to implement the modules existing CHPC users will have to replace their current script sourcing based .bashrc and .tcshrc files as outlined below. 

CHPC uses the Lmod version of modules produced by TACC. For more information, please visit the Lmod Homepage.


 

Setting up Modules

To enable modules, the user will need to copy the CHPC bashrc and tcshrc to their home directory:

cp /uufs/chpc.utah.edu/sys/modulefiles/templates/bashrc ~/.bashrc
cp /uufs/chpc.utah.edu/sys/modulefiles/templates/tcshrc ~/.tcshrc

To set up the default CHPC environment, users will also need to copy the custom.sh and custom.csh scripts

cp /uufs/chpc.utah.edu/sys/modulefiles/templates/custom.sh ~/.custom.sh
cp /uufs/chpc.utah.edu/sys/modulefiles/templates/custom.csh ~/.custom.csh

Existing CHPC users may want to make backup copies of their existing .tcshrc or .bashrc if they have particular modifications which they would like to preserve. After copying the .bashrc/.tcshrc, the user will need to log out and log in. After this, the user should be able to use modules. Users should not modify the .bashrc/.tcshrc; please read the section about customization to see how to set up a custom shell environment using custom.sh/csh. Users may create a ".aliases" file if they desire, which will be automatically sourced by the .bashrc/.tcshrc. CHPC strongly discourages users from setting environment variables in ".aliases"; the file should only contain alias commands.

Note: Bash users should ensure that the .bash_profile file is present in $HOME.

How to Use Modules

The most basic command is simply typing module into the command line, which will print a list of available commands for modules

> module
module [options] sub-command [args ...]
Help sub-commands:
------------------
  help                              prints this message
  help                module [...]  print help message from module(s)
(continues)

A useful command is module avail which shows the list of modules which can currently be loaded.

> module avail
---------------------------------- /uufs/chpc.utah.edu/sys/modulefiles/Core ----------------------------------
   R/3.1.0.omp           (D)    gcc/4.7.2                matlab/R2014b         (D)
   R/3.1.0                     idl/8.4                  maven/3.2.1           (D)
   csd/2015                    intel/2015.1.133         maven/3.2.5
   fastx/1.0-32.x86_64         itac/9.0.1.033           pgi/12.8
   fastx/1.0-39.x86_64   (D)    jdk/1.7.0_67             pgi/13.4
   findbugs/1.3.9               jdk/1.8.0_25      (D)    pgi/14.7
   gaussian09/EM64T.D01  (D)    mathematica/9.0.1       pgi/14.10             (D)
   gaussian09/EM64TL.D01        mathematica/10.0  (D)   totalview/8.14.0-21
   gcc/4.4.7             (D)    matlab/R2014a            vtune/2015.1.0.367959

An important note about module avail is that the command does not show all packages that exist on the system. The reader may notice there are no MPI modules listed above; this is because the use of an MPI library depends on having a compiler loaded. To see a list of allavailable modules, the user should use the command module spider:

> module spider
----------------------------------------------------------------------------------------------------------
The following is a list of the modules currently available:
----------------------------------------------------------------------------------------------------------
  R: R/3.1.0.omp, R/3.1.0
    statistics package
  cmake: cmake/3.1.0.g
  csd: csd/2015
    Crystallographic database and tools
  fastx: fastx/1.0-32.x86_64, fastx/1.0-39.x86_64
    X11 Client

Users can search for a specific module by specifying a name:

> module spider mvapich2
----------------------------------------------------------------------------------------------------------
  mvapich2:
----------------------------------------------------------------------------------------------------------
     Versions:
        mvapich2/2.0.kp.g
        mvapich2/2.0.kp.i
        mvapich2/2.0.kp.p
----------------------------------------------------------------------------------------------------------
  To find detailed information about mvapich2 please enter the full name.
  For example:
     $ module spider mvapich2/2.0.kp.p
----------------------------------------------------------------------------------------------------------

The user can execute spider with a version as well and receive instructions on how to load the module:

> module spider mvapich2/2.0.kp.i
----------------------------------------------------------------------------------------------------------
  mvapich2: mvapich2/2.0.kp.i
----------------------------------------------------------------------------------------------------------
    This module can only be loaded through the following modules:
      intel/2015.1.133

Notes about CHPC Modules and versions

Since CHPC has several clusters which partially or completely share a computing environment., the user may assume that if a module is available, or can be made available through loading another module, the programs in that module can be executed without problems.

Some modules have additional version information as part of the module name. For example, mvapich2 modules will follow the form 2.0.kp.i, which indicates cluster and compiler mode. This information is given to assist the user in knowing exactly what computing environment they are using. The reasoning for this goes beyond the scope of this tutorial, but understand that CHPC allows users to load multiple compilers at the same time, and that because of this the user will have the option to load an MPI distribution of the same version for different compilers. Users should be especially aware of what MPI distribution they are loading, and should load MPI distributions using a specific version where possible. 

While CHPC staff members are working on creating modules for all existing applications, users may find that the package they need does not yet have a module available. In this case, please contact CHPC via issues@chpc.utah.edu with a request that to create the necessary module files.

Loading, Swapping, and Unloading Modules

Let's say a user wants to load the matlab module. The user enters the command module load matlab. If the user types the command module list, they will see that the module is loaded.

> module load matlab
> module list

Currently Loaded Modules:
  1) matlab/R2014b

Suppose now that the user didn't want version R2014b, but version R2014a. The user can accomplish this by using the module swap command. After the command, a module list should show that R2014a is loaded.

> module swap matlab/R2014b matlab/R2014a

One way to unload a module is to use the module unload command:

> module unload matlab/R2014a
> module list
No modules loaded

If a user wants to unload all modules, the easiest way is to use module purge. A purge leaves the user with an empty modules environment, which is usually most suitable when starting a development environment.

For more information on modules, see the Advanced Modules Guide.

Customizing CHPC modules

Users can customize the way how the modules are named and shown using the ~/.modulerc file.  The ~/.modulerc file syntax is as follows:

if { [info exists ::env(LMOD_VERSION_MAJOR)] } {
#Lmod stuff
hide-version idl/8.0
module-version python/2.7.11 2.7
module-alias python2 python/2.7.11
}

As can be seen in the example above, one can hide the display of the module in module avail command (which CHPC prefers to do ourselves in the system default), and, more usefully for an user, create a custom version or alias to the module, which is especially useful to shorten long version names or create a custom name for a given version.

We have a global custom file in /uufs/chpc.utah.edu/sys/modulefiles/etc/rc , which we mostly use to hide deprecated modules, shorten versions and set aliases to commonly used modules.

Customizing the default user environment via .bashrc/.tcshrc

CHPC has streamlined its approach to customizing user environments. As mentioned before, CHPC strongly discourages the modification of .bashrc/.tcshrc files. This is because any time CHPC releases new versions of these files, often users will have their shell environment broken by the changes. CHPC has provided the custom.sh and custom.csh files for users to customize their environment. The user should have copied these files already (or started with them in a new user account).  After copying, these files should work seamlessly with the .bashrc/.tcshrc. The user is free to make any modifications they want in the custom scripts. As a convenience, a means for modifying environments on a cluster specific basis is also given in the custom script.

Setting up command aliases

Users can create a .aliases file in their home directory to set up any command aliases that they want to have defined in their working environment. If this file exists, it will automatically be sourced upon login by the .tcshrc/.bashrc file.

Last Updated: 9/15/17