// Using Modules
The Linux modules package is used to manage users' environment variables to allow users to easily access different versions of commonly used software.
Multiple versions of compilers from different vendors and other support applications are available for users on the Discover cluster. These applications are loaded into your environment through the use of modules.
When you log into the Discover system, no modules are loaded by default.
The following table consists of helpful module commands.
Module command | Description |
---|---|
module avail | displays all available modules |
module avail comp | displays all available compiler modules |
module load <module_name> | load a module |
module unload <module_name> | unload a module |
module swap <loaded_old_module> <new_module_name> | switch between two different versions of the same application or compiler, or switch between compilers from different vendors. |
module list | see which modules you currently have loaded |
module show |
display a list of environment variables and other information about an individual module |
module purge | remove all modules from the environment |
Note: Users are strongly encouraged to use "man module" to better understand how to use the modules command.
For a new Discover user, here is an example module command to prepare the environment for running and developing MPI applications with Intel compiler and Intel MPI:
$ module load comp/intel/19.1.3.304 mpi/impi/19.1.3.304
This command loads the Intel version 19.0, then the Intel MPI 19.0 libraries.
Resolving Software Dependencies using Modules
Sometimes modules depend on other modules or compiler modules to load. If you have not loaded the proper module or compiler, Lmod will remind you. For example:
$ module load netcdf4/4.7.4
Lmod has detected the following error: These module(s) exist but cannot be loaded as requested: "netcdf4/4.7.4"
Try: "module spider netcdf4/4.7.4" to see how to load the module(s).
To fix this, just load the recommended module(s) under "module spider module/name" and try again. Some modules will also automatically load other modules they depend on:
$ module load netcdf4/4.7.4
$ module list
Currently Loaded Modules:
1) comp/intel/19.1.3.304 2) hdf5/1.13.0 3) netcdf4/4.7.4
Loading the netcdf4/4.7.4 module caused the hdf5/1.13.0 module to load
due to the line in the module:
depends_on("comp/intel/19.1.3.304","hdf5/1.13.0")
The compiler module "comp/intel/19.1.3.304" was loaded manually after Lmod gave the error shown two steps above.
What happens when you load multiple versions of the same software/compiler?
There is no harm in loading the same module twice. However, you will be told if you load two modules associated with two different versions of the same tool. For example, the current operating system on Discover supports gcc versions 6.5.0, 8.3.0, 10.1.0, and others out of the box. If you load the module for version 10.1.0 and then load 9.3.0 without unloading or purging your modules, Lmod will reload the module with the newest change:
$ module load comp/gcc/9.3.0
$ module load comp/gcc/10.1.0
The following have been reloaded with a version change:
1) comp/gcc/9.3.0 => comp/gcc/10.1.0
You could also either unload the old version first, or use "module swap old/module new/module"