Using Environment Modules

Environment Modules gives the user the ability to easily modify their Unix environment, making it easier to use software packages. No more setting shell environment variables, all the variables can by dynamically loaded to use a particular software package, including finding all the software's dependencies. You can use Environment Modules by running the module command.

To see all available modules, run module avail. The following examples shows the first few lines of the output from running module avail.

$ module avail

-------------- /usr/local/share/Modules/modulefiles -----------------

-------------- /opt/share/Modules/modulefiles --------------

To use a particular module, run module load modulename. You don't need to list the full name of the module, as listed above, if you only use the first component, it will choose the latest version for you. (It actually chooses the last item alphabetically.) For example:

$ module load openmpi intel

Or equivalently

$ module load openmpi
$ module load intel

To see which modules are loaded, run module list. For example:

$ module list
Currently Loaded Modulefiles:
1) openmpi/intel-17.0/3.1.3/64
2) intel-mkl/2019.3/3/64
3) intel/19.0/64/

You can see from the above that the openmpi module automatically loaded OpenMPI built with the Intel compilers, because the letter 'i' comes after 'g' in the alphabet. Also, the Intel OpenMPI requires the Intel compilers, which are loaded by including "intel" after "openmpi". If you had wanted to load the OpenMPI built with GCC, you would simply run module load openmpi/gcc. If you want to load a specific version of the OpenMPI built with the Intel compiler, run module load openmpi/intel-19.0/3.1.3/64.

Now that the openmpi module is loaded, you can run OpenMPI commands. For example:

$ which mpicc

And the code may be built with

$ mpicc -o program program.c


To unload a module, run module unload modulename. For example:

$ module unload openmpi intel
$ module list
No Module files Currently Loaded.

As you can see, the openmpi module has been unloaded, as well as the intel compilers.

Do not put the module load modulename command in your shell's startup script (e.g., .bashrc) as it can lead to difficult to diagnose problems. Instead, use the module command in your Slurm submission scripts and the module will be loaded when the job is run.

To see exactly which environment variables the module modifies, run module show modulename.