Environment Modules (software)
{{Short description|Software to modify a shell environment during a session}}
{{how-to|date=February 2015}}
{{Infobox software
| name = Environment Modules
| logo = Environment_Modules_logo.svg
| latest_release_version = 5.5.0
| latest_release_date = {{Start date and age|2024|11|11}}
| operating_system = Unix-like
| programming_language = Tcl
| license = GNU General Public License#Version 2
| website = {{URL|https://modules.sourceforge.net/}}
}}
The Environment Modules system is a software tool to help users manage their Unix or Linux shell environment, by allowing groups of related environment-variable settings to be made or removed dynamically.
Development
Modules has been around since the early 1990s{{cite journal |last=Furlani |first=John L. |date=September 30 – October 3, 1991 |title=Modules: Providing a Flexible User Environment |url=http://modules.sourceforge.net/docs/Modules-Paper.pdf |journal=Proceedings of the Fifth Large Installation Systems Administration Conference (LISA V) |location=San Diego, CA |pages=141–152 |access-date=9 February 2014}} and is used at some of the largest computer centers{{cite web|url=http://www.nics.tennessee.edu/computing-resources/kraken/modules |title=NICS User Support Kraken Modules Description |date=22 May 2011 |website=The National Institute for Computational Sciences (NICS) |publisher=Oak Ridge National Laboratory - Department of Energy |access-date=9 February 2014 |url-status=dead |archive-url=https://web.archive.org/web/20140222062335/http://www.nics.tennessee.edu/computing-resources/kraken/modules |archive-date=22 February 2014 }} to deploy multiple versions of different software tools to users. The National Energy Research Scientific Computing Center (NERSC) reports that they use Environment Modules to manage nearly all software.{{cite web |url=https://www.nersc.gov/users/software/nersc-user-environment/modules/ |title=NERSC Modules Software Environment |author= |date=2014-02-07 |website=The National Energy Research Scientific Computing Center (NERSC) |publisher=Office of Science - Department of Energy |access-date=19 February 2014}} Environment Modules is specified as a Baseline Configuration requirement of the DoD High Performance Computing Modernization Program (HPCMP){{cite web|url=http://centers.hpc.mil/consolidated/bc/policies.php?choice=modules |title=Use of Modules for Accessing Multiple Versions of Software |date=20 Mar 2008 |website=Baseline Configuration |publisher=DoD High Performance Computing Modernization Program (HPCMP) |access-date=9 February 2014 |url-status=dead |archive-url=https://web.archive.org/web/20140222063501/http://centers.hpc.mil/consolidated/bc/policies.php?choice=modules |archive-date=22 February 2014 }} Project Baseline Configuration{{cite web|url=http://centers.hpc.mil/consolidated/bc/index.php |title=DoD High Performance Computing Modernization Program Baseline Configuration |website=Baseline Configuration |publisher=DoD High Performance Computing Modernization Program (HPCMP) |access-date=9 February 2014 |url-status=dead |archive-url=https://web.archive.org/web/20140222063504/http://centers.hpc.mil/consolidated/bc/index.php |archive-date=22 February 2014 }} team for participating DoD Supercomputing Resource Centers (DSRCs).
Modulefiles
The modules system is based on modulefiles,{{cite web |url=http://modules.sourceforge.net/man/modulefile.html |title=modulefile - files containing Tcl code for the Modules package |author=John L. Furlani & Peter W. Osel |date=July 2009 |website=SourceForge |publisher=man page |access-date=9 February 2014}} which specify groups of environment settings that need to be made together. Modulefiles can be installed in a central location for general use, or in a user directory for personal use. Environment Modules modulefiles are written in the Tcl (Tool Command Language) and are interpreted by the modulecmd program via the module{{cite web |url=http://modules.sourceforge.net/man/module.html |title=module - command interface to the Modules package |author=John L. Furlani & Peter W. Osel |date=July 2009 |website=SourceForge |publisher=man page |access-date=9 February 2014}} user interface.
The key advantage of Environment Modules is that it is shell independent and supports all major shells such as Bash (bash), KornShell (ksh), Z shell (zsh), Bourne shell (sh), tcsh, and C shell (csh). The second key advantage is that it allows to use multiple versions of the program or package from the same account by just loading proper module. Those two advantages were instrumental in making Environment Modules a part of most HPC cluster setups. It also inspired several alternative implementation such as lmod from University of Texas, which is written in Lua instead of Tcl.
Modulefiles are created on per application per version basis. They can be dynamically loaded, unloaded, or switched. Along with the capability of using multiple versions of the same software it also can be used to implement site policies regarding the access and use of applications.
= Default modulefiles directory =
The default modules search path is in a hidden configuration file you can display with:
{{sxhl|2=console|
$ cat ${MODULESHOME}/init/.modulespath
/etc/modulefiles # CentOS, Scientific Linux, RHEL
/usr/local/Modules/modulefiles # Build from source default
}}
The {{mono|/etc/modulefiles}} directory used by some distributions (or any other directory) can be used after a build from source by modifying the {{mono|${MODULESHOME}/init/.modulespath}} file.
= Add your own modules to the path =
The {{mono|${MODULESHOME}/modulefiles/use.own}} module essentially performs these steps:
{{sxhl|2=bash|
mkdir $HOME/privatemodules
cp ${MODULESHOME}/modulefiles/null $HOME/privatemodules
module use --append $HOME/privatemodules
}}
= Use a version file within a hierarchical organization =
The commands in this section require read/write/execute access to the {{Mono|/etc/modulefiles}} directory. The {{Mono|$HOME/privatemodules}} or another directory can be used instead along with "{{Mono|module use --append}}" or modification of the configuration file specifying the default modules search path.
The default {{Mono|modulefiles}} directory is empty initially. Copy the null module to the default modulefiles directory to have it shown by "module avail". The following uses the null and module-info modules to show use of a version file within a hierarchical organization and their effect on module avail and module show:
mkdir /etc/modulefiles/test
cp ${MODULESHOME}/modulefiles/null /etc/modulefiles/test/2.0
cp ${MODULESHOME}/modulefiles/module-info /etc/modulefiles/test/1.0
module avail
module show test
Set the first version as the default:
echo '#%Module' > /etc/modulefiles/test/.version
echo 'set ModulesVersion "1.0"' >> /etc/modulefiles/test/.version
module avail
module show test
module show test/2.0
Switch to the newer version as the default with:
rm /etc/modulefiles/test/.version
echo '#%Module' > /etc/modulefiles/test/.version
echo 'set ModulesVersion "2.0"' >> /etc/modulefiles/test/.version
module avail
module show test
After the above following a fresh install from source you would see:
$ module avail
-------------------- /usr/local/Modules/3.2.10/modulefiles ---------------------
dot module-git module-info modules null use.own
------------------------------- /etc/modulefiles -------------------------------
null test/1.0 test/2.0(default)
--------------------------- /home/user/privatemodules --------------------------
null
$ module show test
-------------------------------------------------------------------
/etc/modulefiles/test/2.0:
module-whatis does absolutely nothing
-------------------------------------------------------------------
$ module show test/1.0
-------------------------------------------------------------------
/etc/modulefiles/test/1.0:
module-whatis returns all various module-info values
+++ module-info +++++++++++++++++++++++++++++++
flags = 2
mode = display
name = test/1.0
specified = test/1.0
shell = bash
shelltype = sh
version = test/1.0
user = advanced
trace = 0
tracepat = -.*
symbols = *undef*
+++ info ++++++++++++++++++++++++++++++++++++++
hostname = localhost
level = 1
loaded null = 0
library = /usr/local/lib/tcl8.6
nameofexecutable =
sharedlibextension = .so
tclversion = 8.6
patchlevel = 8.6.1
+++++++++++++++++++++++++++++++++++++++++++++++
-------------------------------------------------------------------
Automatic modules initialization
Environment Modules on Scientific Linux, CentOS, and Red Hat Enterprise Linux distributions in the environment-modules package include {{mono|modules.csh}} and {{mono|modules.sh}} scripts for the {{mono|/etc/profile.d}} directory that make modules initialization part of the default shell initialization. One of the advantages of Environment Modules is a single modulefile that supports bash, ksh, zsh, sh as well as tcsh and csh shell users for environment setup and initialization. This makes managing complex environments a bit less complicated.
For a source build the automation for all users can be manually configured.
= bash, ksh, zsh, sh automatic modules initialization =
{{mono|/etc/profile.d/modules.sh}} from the {{mono|etc/global/profile.modules}} file in the 3.2.10 modules build directory.
trap "" 1 2 3
case "$0" in
-bash|bash|*/bash) . /usr/local/Modules/default/init/bash ;;
-ksh|ksh|*/ksh) . /usr/local/Modules/default/init/ksh ;;
-zsh|zsh|*/zsh) . /usr/local/Modules/default/init/zsh ;;
*) . /usr/local/Modules/default/init/sh ;; # default
esac
trap 1 2 3
Copy the {{mono|etc/global/profile.modules}} file from the 3.2.10 modules build directory to the system initialization directory:
$ sudo cp etc/global/profile.modules /etc/profile.d/modules.sh
Add a version 3.2.10 symbolic link for the above generic addresses:
$ cd /usr/local/Modules
$ sudo ln -sT 3.2.10 default
= tcsh, csh automatic modules initialization =
A {{mono|/etc/profile.d/modules.csh}} symbolic link to the {{mono|etc/global/profile.modules}} file in the 3.2.10 modules build directory can enable automatic modules initialization for these users.
Installing on Linux
= yum and rpm =
On Scientific Linux, CentOS, and RHEL distributions Environment Modules is in the environment-modules package which can be installed with:
sudo yum install environment-modules
Once installed the package information can be viewed with:
rpm -qi environment-modules
rpm -ql environment-modules
= apt and dpkg =
= Linux from source =
Although installing from a Linux distributions repository using that distributions update manager is the easiest the software can be installed from source. Resolve dependencies is the most difficult task for an installation from source. The typical configure, make, install cycle can become painfully slow as each configure improvement reveals another dependency not available in your default environment. This section includes the steps to install the Environment Modules package on source including compiling the Tcl from source as a dependency.http://nickgeoghegan.net/linux/installing-environment-modules
== 8.6.1 version of Tcl built from /usr/local/src ==
Although the PCLinuxOS 64-bit repositories include Tcl they do not include a development package with the configuration files required to build Environment Modules on Linux from source. Building Tcl from source will make the required files available.{{cite web | url=http://sourceforge.net/projects/tcl/files/Tcl/ | title=TCL - Browse /TCL at SourceForge.net }}
Extract source after downloading
{{sxhl|2=bash|
cd /usr/local/src
tar -xvzf ~/Downloads/tcl8.6.1-src.tar.gz
}}
Configure, make, install
{{sxhl|2=bash|
cd /usr/local/src/tcl8.6.1
unix/configure
make
sudo make install
}}
== 3.2.10 version of modules built from /usr/local/src ==
Extract source after downloading
{{sxhl|2=bash|
cd /usr/local/src
tar -xvzf ~/Downloads/modules-3.2.10.tar.gz
}}
Configure, make, install
{{sxhl|2=bash|1=
cd /usr/local/src/modules-3.2.10
CPPFLAGS="-DUSE_INTERP_ERRORLINE" ./configure
make
sudo make install
}}
References
{{Reflist}}
External links
{{Portal|Free and open-source software}}
- {{Official website|https://modules.sourceforge.net/}}
- {{GitHub|envmodules/modules}}
- John L. Furlani, [http://modules.sourceforge.net/docs/Modules-Paper.pdf Modules: Providing a Flexible User Environment] Proceedings of the Fifth Large Installation Systems Administration Conference (LISA V), pp. 141–152, San Diego, CA, September 30 - October 3, 1991.
- http://lmod.sourceforge.net - alternative implementation using Lua instead of Tcl
- http://www.lysator.liu.se/cmod/ - alternative implementation using C only
- [https://web.archive.org/web/20140203041538/http://rcc.its.psu.edu/user_guides/system_utilities/modules/ PennState Environment Modules User Guide]
- [http://modules.sourceforge.net/docs/MC2_whitney_paper.pdf Drag your design environment kicking and screaming into the '90s with Modules!] - SNUB Boston 2001 - Erich Whitney, Axiowave Networks, Mark Sprague, ATI Research
- [https://web.archive.org/web/20150217180220/https://www.xsede.org/software-environments Xsede Software Environments]. The Extreme Science and Engineering Discovery Environment ― National Science Foundation
- [http://www.nics.tennessee.edu/computing-resources/modules NICS Modules Description] ― The National Institute for Computational Sciences at Oak Ridge National Laboratory ― Department of Energy
- [https://www.tacc.utexas.edu/research-development/tacc-projects/lmod Lmod] ― Lua-based module system
- [https://spack.io/ Spack] ― Package Manager for HPC Software developed at Lawrence Livermore National Laboratory