Environment Modules


The Environment Modules package provides for the dynamic modification of a user's environment via modulefiles. Modules can be loaded and unloaded dynamically and atomically, in an clean fashion. All popular shells are supported, including bash, ksh, zsh, sh, csh, tcsh, as well as some scripting languages such as perl

Since we support more shells now, the execution order of the environment files is important. Inside IMP/IMBA most users will use bash/sh or tcsh/csh (Debian 5 lenny) or dash/sh (Ubuntu, Linux Mint, Debian 6+) as main shell. The Grid Engine and a few other software packages work with csh

Shell configuration files calling order (from left to right):

  • sh:  ~/.profile
  • dash: ~/.profile
  • bash: ~/.bash_profile (~/.bash_login or  ~/.profile)  ~/.bashrc
  • zsh: ~/.zshenv  ~/.zprofile ~/.zshrc  ~/.zlogin
  • ksh: ~/.profile
  • csh: ~/.cshrc ~/.login
  • tcsh: (~/.tcshrc or ~/.cshrc)  ~/.login

Basic Setup

IMP/IMBA users should add support for sh and csh based shells to their environment to make it fully functionally.

Many groups want to have a single script to add their most used programs to their environment. For example (change groupname with your groupname e.g. stark) in the examples below.

All users who use bash, dash as main shell should add to their ~/.profile

if [ -f /biosw/modules/init/modules-env.sh ]; then
 module load groupname.grp

All users who use csh, tcsh as main shell should add to their ~/.cshrc file: 

if ( -f /biosw/modules/init/modules-env.csh ) then 
 module load groupname.grp 

If you want individual settings, you do not need the groupfiles above. You can add your most favorite programs/versions directly instead e.g.:

if [ -f /biosw/modules/init/modules-env.sh ]; then
 module load ncbi-blast+
 module load meme/4.8.1

For other shells, please look for a proper configuration file in the Shell configuration files calling order above.

Own and/or local modulefiles can be put into the directory ~/privatemodules and activated by the following command:

 module load use.own 

Usage examples

  • module list
  • module avail
  • module load python
  • module unload python/2.7.3
  • module load python/3.2.3
  • module help ncbi-blast+
  • module whatis ncbi-blast+
  • module show aliases
  • man module
  • man modulefile
  • module purge
  • module load minimal
  • module avail -t 2>&1 | grep emboss

Environment Migration

With the old BASH based environment all settings were located in /sw/lenny/etc/.

For most groups we made a single script to add their most used programs to their environment. For example (change bioinfo with your groupname e.g. stark):

 source /sw/lenny/etc/bioinfo.grp

With the new environment you can do the same like:

 module load bioinfo.grp

Then you should have the most common settings and programs in your environment. With the new environment modules you don't have to care about the current operating system version. It will be automatically detected and you get the right settings and proper programs.

You can always override these settings in your profile. For example you want to use Python 3 instead of Python 2.7 like the rest of your group. So your sample profile setting would look like:

if [ -f /biosw/modules/init/modules-env.sh ]; then
 module load bioinfo.grp
 module unload python/2.7.3
 module load python/3.2.3

Notes for using module aliases in shell scripts

Some module definitions contain program aliases for easier usage. They work well in the commandline, but they are not recognized when loaded dynamically in scripts. 

To use command aliases in scripts do as in the following example:

 shopt -s expand_aliases
 module load picard-tools

Notes for Linux Desktop Systems

Newer Linux desktop systems (e.g. Ubuntu 12, Linux Mint, ...) use Python to generate e.g. system menu entries. So if you load the python module in your profile, it can happen that you do not have any menu entries after a GUI login, because our server python module installation has different Python packages than the GUI system.

A workaround for users using bash as login shell is as follows:

if [ `type -t module`"" == 'function' ]; then
 if [ -f /biosw/modules/init/modules-env.sh ]; then
  module load python