Help:HPCC Env Modules: Difference between revisions

From CSDMS
m (Add table of user RC files and shells)
m (Add examples, trim table, get shell)
Line 37: Line 37:
== Set Up Environment Modules ==
== Set Up Environment Modules ==


To use Environment Modules you will have to add a couple of things to your startup RC file.  The name of your RC file depends on the shell that you are using.
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,
<syntaxhighlight lang=bash>
source /usr/local/modules/init/<shell>
</syntaxhighlight>
Where <code><shell></code> 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.


The following table lists user RC files for some popular shells.
== Use beach-Specific Modules ==
 
For module to recognize the modules install on the cluster, you must tell module to use the local modulefiles,
<syntaxhighlight lang=bash>
module use /data/progs/localmodules
</syntaxhighlight>
You can also add this to your RC file after the previous initialization 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,
<syntaxhighlight lang=bash>
> module avail
---------------------------------------------------------- /data/progs/localmodules -----------------------------------------------------------
cca/eric                glib2                  mpich2/1.1              petsc                  sedflux/mars
cca/stable(default)    gnu                    mvapich2/1.2            python/2.4              sedflux/nightly
cca/yanb                hdf5                    netcdf                  python/2.5              sedflux/stable(default)
cmake                  intel/11.0              null                    python/2.6(default)    subversion
gcc/4.1                libxml2                openmi/1.4              scons                  torque
gcc/4.3(default)        matlab/2008b            openmpi/1.3            sedflux/intel          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
</syntaxhighlight>
 
Load python 2.6,
<syntaxhighlight lang=bash>
> which python
/usr/bin/python
> module load python/2.6
> which python
/usr/local/bin/python/bin/python
</syntaxhighlight>
 
== Get the name of your shell ==
 
If you're not sure what shell you are running, try running the following command,
<syntaxhighlight lang=bash>
> grep <username> /etc/passwd | cut -d: -f7
</syntaxhighlight>
Substitute your username for <code><username></code>.
 
== Get the name of your startup RC file ==
 
The following table lists user RC files for shells available on the cluster.


{| class="wikitable sortable"
{| class="wikitable sortable"
Line 48: Line 101:
! tcsh
! tcsh
! bash
! bash
! zsh
|-
|-
|<code>~/.tcshrc</code> || || || || yes || ||
|-
| <code>~/.cshrc</code>|| || || yes || yes || ||
|-
|<code>~/.login</code> || || || login || login || ||
|-
| <code>~/.logout</code> || || || login || login || ||
|-
|<code>~/.profile</code> || login || login || || || login ||
|-
|-
|<code>~/.bash_profile</code> || || || || || login ||
|<code>~/.tcshrc</code> || || || || always ||
|-
|-
|<code>~/.bash_login</code> || || || || || login ||
| <code>~/.cshrc</code>|| || || always || always ||
|-
|-
|<code>~/.bash_logout</code> || || || || || login ||
|<code>~/.login</code> || || || login || login ||
|-
|-
|<code>~/.bashrc</code> || || || || || ! login ||
| <code>~/.logout</code> || || || login || login ||  
|-
|-
|<code>~/.zshenv</code> || || || || || || yes
|<code>~/.profile</code> || login || login || || || login
|-
|-
|<code>~/.zprofile</code> || || || || || || login
|<code>~/.bash_profile</code> || || || || || login
|-
|-
|<code>~/.zshrc</code> || || || || || || int
|<code>~/.bash_login</code> || || || || || login
|-
|-
|<code>~/.zlogin</code> || || || || || || login
|<code>~/.bash_logout</code> || || || || || login
|-
|-
|<code>~/.zlogout</code> || || || || || || login
|<code>~/.bashrc</code> || || || || || ! login
|}
|}


Explanation:
Explanation:
* Blank means the file is not read by the shell at all.
* Blank means the file is not read by the shell at all.
* '''yes''' means the file is always read by the shell upon startup.
* '''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 a login shell.
* '''! login''' means the file is read if the shell is not a login shell.
* '''! login''' means the file is read if the shell is ''not'' a login shell.
* '''int''' means the file is read if the shell is interactive.

Revision as of 16:10, 11 August 2009

Environment Modules

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>

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.

Use beach-Specific Modules

For module to recognize the modules install on the cluster, you must tell module to use the local modulefiles,

module use /data/progs/localmodules

You can also add this to your RC file after the previous initialization 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                glib2                   mpich2/1.1              petsc                   sedflux/mars
cca/stable(default)     gnu                     mvapich2/1.2            python/2.4              sedflux/nightly
cca/yanb                hdf5                    netcdf                  python/2.5              sedflux/stable(default)
cmake                   intel/11.0              null                    python/2.6(default)     subversion
gcc/4.1                 libxml2                 openmi/1.4              scons                   torque
gcc/4.3(default)        matlab/2008b            openmpi/1.3             sedflux/intel           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.