Help:HPCC Env Modules

From CSDMS

Environment Modules

Photo by Flickr user wallyg used under a Creative Commons license
Photo by Flickr user wallyg used under a Creative Commons license

Several software packages on the cluster require correct definition of certain environment variables. These variables establish the package's configuration and influence its behavior. For example, PATH and LD_LIBRARY_PATH specify the location of package binary files.

Environment Modules is a tool to manage package environment variables.

With simple command line options, you can prepare the environment for any package available on the cluster. In the case of packages with multiple versions, there are options to switch between one version and another - defining and undefining variables as needed. If there is a conflict between two packages, module will alert you.

Cheat Sheet

Command Description
module avail List available modules
module load <module-name> Load module named <module-name>
module unload <module-name> Unload module named <module-name>
module whatis <module-name> Give description of module <module-name>
module list List modules that are loaded in your environment
module purge Unload all currently loaded modules from your environment
module display <module-name> Give the rules for module <module-name>

For a more complete description, see the module man page or type

> man module

Set Up Environment Modules

To use Environment Modules you will have to add a couple of things to your startup RC file. The module command is initialized by sourcing a shell-specific initialization file. You will find the initialization files /usr/local/modules/init. To initialize modules,

source /usr/local/modules/init/<shell>

Where <shell> is the name of your shell. To have this done automatically when you login, add this command to the end of your startup RC file. You should now be able to use the module command.

Examples

The following examples assume that you have executed (either interactively or in a login RC file) the previous two commands.

List all available modules,

> module avail
--------------------------- /data/progs/localmodules ---------------------------
cca/eric                libxml2                 python/2.5
cca/stable(default)     matlab/2008b            python/2.6(default)
cca/yanb                mpich2/1.1              scons
cmake                   mvapich2/1.2            sedflux/intel
gcc/4.1                 netcdf                  sedflux/mars
gcc/4.3(default)        null                    sedflux/nightly
glib2                   openmi/1.4              sedflux/stable(default)
gnu                     openmpi/1.3             subversion
hdf5                    petsc                   torque
intel/11.0              python/2.4              udunits

------------------ /usr/local/modules-3.2.6/Modules/versions -------------------
3.2.6

-------------- /usr/local/modules-3.2.6/Modules/3.2.6/modulefiles --------------
dot         module-cvs  module-info modules     null        use.own

Load python 2.6,

> which python
/usr/bin/python
> module load python/2.6
> which python
/usr/local/bin/python/bin/python

Get the name of your shell

If you're not sure what shell you are running, try running the following command,

> grep <username> /etc/passwd | cut -d: -f7

Substitute your username for <username>.

Get the name of your startup RC file

The following table lists user RC files for shells available on the cluster.

sh ksh csh tcsh bash
~/.tcshrc always
~/.cshrc always always
~/.login login login
~/.logout login login
~/.profile login login login
~/.bash_profile login
~/.bash_login login
~/.bash_logout login
~/.bashrc ! login

Explanation:

  • Blank means the file is not read by the shell at all.
  • always means the file is always read by the shell upon startup.
  • login means the file is read if the shell is a login shell.
  • ! login means the file is read if the shell is not a login shell.