This is an old revision of the document!
Modules Environment
Introduction
Environment modules provide a great way to easily customize your linux shell environment (PATH, MANPATH, INCLUDE, LD_LIBRARY_PATH), especially with loading or unloading a module file.
This is a system that allows you to easily change between different versions of compilers and other software, no matter what shell you use, without having to set a lot of environment variables by hand each time, making it easier to use software packages.
Usage
The workstations have a variety of compilers, libraries, and other bits of software installed. Some of it exists in multiple versions, and, for example, you may wish to switch between compilers for testing or you may wish to select a specific revision of Matlab.
The purpose of the module package is to simplify this for you.
On all workstations the modules package is available as standard; it provides for the dynamic modification of the user's environment via modulefiles.
Each modulefile contains the information needed to configure the shell for an application; 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, etc.
The modulefiles are added to and removed from the current environment by the user. The environment changes contained in a modulefile can be summarized through the module
command as well. If no arguments are given, a summary of the module usage and sub-commands are shown:
[user@workstation ~]# module Modules Release Tcl x.x.x ($RCSfile: modulecmd.tcl,v $ $Revision: x.xxx $) Copyright GNU GPL v2 1991 Usage: module [ switches ] [ command ] Switches: -t terse format avail and list -l long format avail and list Commands: list | add|load modulefile [modulefile ...] purge | rm|unload modulefile [modulefile ...] reload | switch|swap [oldmodulefile] newmodulefile | display|show modulefile [modulefile ...] | avail [modulefile [modulefile ...]] | whatis [modulefile [modulefile ...]] | help [modulefile [modulefile ...]] | path modulefile | paths modulefile | use dir [dir ...] | unuse dir [dir ...] | source scriptfile | apropos|keyword string | initlist | initadd modulefile initclear | initprepend modulefile | initrm modulefile
Sub-Commands
avail
With the subcommand avail
you get available list of module files (versions or names may change):
[user@workstation ~]# module avail ------------ /u/shared/programs/noarch/common/modulefiles ------------ mathematica/6.0.2(default) mkl/10.0.2.018(default) mathematica/6.0.1 mkl/9.0.1 ------------ /u/shared/programs/x86_64/common/modulefiles ------------ cce/10.1.013(default) intel/10.1.013(default) pgi/7.1-6(default) cce/9.0.1 intel/9.1 pgi/6.1 fce/10.1.013(default) maple/11(default) sm/2.4.34(default) fce/9.1 maple/10 sm/2.2.3 idbe/10.1.013(default) matlab/2007b(default) idbe/9.1 matlab/2007a
The notation for the modulefilename is “name of the application/version and description”
.
load
To use a particular module, run module load modulename
. You don't need to list the full name of the module, as listed in module avail
output, if you only use the first component, it will choose the latest version for you. (It actually chooses the last item alphabetically.)
[user@workstation ~]# module load cce
list
This lists all modules which are currently loaded into the users' environment (versions or names may change).
[user@workstation ~]# module list Currently Loaded Modulefiles: 1) cce/10.1.013
unload
Use this command to unload one or more of the loaded module files (seen in list
before).
[user@workstation ~]# module unload cce
whatis
If a module looks interesting, use this command to display the information contained within the given module file (versions or names may change).
[user@workstation ~]# module whatis cce ----------- /u/shared/programs/noarch/common/modulefiles ------------- ----------- /u/shared/programs/x86_64/common/modulefiles ------------- cce/10.1.013: loads the Intel(R) C++ Compiler 10.1.013
display
Use this command to see exactly what a given modulefile will do to your environment, such as what will be added to the PATH, MANPATH, etc. environment variables.
[user@workstation ~]# module display cce ------------------------------------------------------------------- /u/shared/programs/x86_64/common/modulefiles/cce/10.1.013: module-whatis loads the Intel(R) C++ Compiler 10.1.013 prepend-path PATH /u/shared/programs/x86_64/common/intel/cce/10.1.013/bin prepend-path LD_LIBRARY_PATH /u/shared/programs/x86_64/common/intel/cce/10.1.013/lib prepend-path MANPATH /u/shared/programs/x86_64/common/intel/cce/10.1.013/man prepend-path INTEL_LICENSE_FILE /u/shared/licenses/intel -------------------------------------------------------------------
Using modules in batch
To automatically load modules when you log in to a system, put the module load modulename
command in your shell's startup script.
For example:
- if your shell is
bash
, put the command in your~/.bashrc
- if your shell is
csh
, put it in your~/.cshrc
.
If you change shells in your batch script you may need to explicitly load the modules environment (if your script does not use modules commands, there is, of course, no need to do this) by adding as the first line of your bash
script:
. /etc/profile.d/modules.sh
or in case your script is csh
derived:
source /etc/profile.d/modules.csh