Module Environment

From IBERS Bioinformatics and HPC Wiki
Jump to: navigation, search

When you log into bert.ibers you see a message like this;

   
Use the following commands to adjust your environment:

'module avail'            - show available modules
'module add <module>'     - adds a module to your environment for this session
'module initadd <module>' - configure module to be loaded at every login

-------------------------------------------------------------------------------
    

This is the first indication of the module environment. So what is a module?

A module is an environment that can be loaded by the user. A common usage for this is if there are several versions of a piece of software available on the machine. By default when you log into bert.ibers and type in the command for the piece of software, it will run the latest version. This might be fine for everyday use, but there could be a time when you need an older version (maybe to make it compatible with another piece of software). You wouldn't wish to replace a new version with an old one. This is where modules become useful. By making software available in modules, it allows the user to specify the environment they wish to work, thus choosing which version of a given program you wish to use.

Loading and unloading modules

If you type;

   
[username@bert ~]$ module list
Currently Loaded Modulefiles:
  1) gcc/4.4.6     2) sge/6.2u5p2
    

you will see which modules are currently loaded.

To see which modules are available, type;


   
[username@bert ~]$ module avail

---------------------------- /cm/local/modulefiles ----------------------------
cluster-tools/5.2 freeipmi/1.0.2    null              version
cmd               ipmitool/1.8.11   shared
dot               module-info       use.own

--------------------------- /cm/shared/modulefiles ----------------------------
R/R-2.14.2                           fftw2/open64/64/float/2.1.5
acml/gcc/64/4.4.0                    fftw3/gcc/64/3.2.2
acml/gcc/64/5.1.0                    fftw3/open64/64/3.2.2
    

you will get a long list of programs and environments available to you.

You can see what a module is by typing;

   
[username@bert ~]$ module whatis R
R                    : adds the R statistical package R-2.14.2
    

You can load modules by typing;

   
[username@bert ~]$ module load R
[username@bert ~]$ R

R version 2.14.2 (2012-02-29)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 
    

Notice that no output was given when you load the R module. By typing R into the command line you run the R statistical package.

To unload a module, type;

   
[username@bert ~]$ module unload R
[username@bert ~]$ R
-bash: R: command not found
    

Notice now that the module is no longer loaded R is not available.

For more information about the module environment, type;

   
[username@bert ~]$ module --H
    

and you will get a list of commands.

Automatically loading a module when logging in

So loading modules are great to avoid confusion between versions of software, which on a shared system like this it can become a problem. However it is easy to forget to load a module that you use so often. You can automatically load a module every time you log into Bert by editing the .bashrc file.

In your home directory there is a file called .bashrc

Edit this with your favourite editor (e.g. vi or nano etc) and add the line;

  module load MODNAME

where MODNAME is the name of a module from the module list. Once you've saved it, whenever you log into Bert, the module will be loaded.