What is User Environment Modules?
Taken from Environment Modules Project
The Environment Modules package provides for the dynamic modification of a user’s environment via modulefiles.
Each modulefile contains the information needed to configure the shell for an application. Once the Modules package is initialized, the environment can be modified on a per-module basis using the module command which interprets modulefiles. Typically modulefiles instruct the module command to alter or set shell environment variables such as PATH, MANPATH, etc. modulefiles may be shared by many users on a system and users may have their own collection to supplement or replace the shared modulefiles.
Step 1: Download the modules packages
Download the latest modules packages from Modules Sourceforge Project Site.
Step 2: Download the dependencies tcl and tcl-devel
# yum install tcl tcl-devel
Step 3: Unpacked, Configure and Install
# tar -zxvf modules-3.2.9c.tar.gz
Go to the Modules folder ($ModuleHome)
# cd modules-3.2.9
I wanted to keep all my individual modules files at /usr/local/Modules/contents. You can keep module files anywhere you wish to keep.
# ./configure --with-module-path=/usr/local/Modules/contents
Make and install the configuration
# make && make install
Step 4: Amend .modulefiles
Edit . modules to let Modules know where all the customized module files will be kept
# vim /usr/local/Modules/3.2.9/init/.modulespath
Comment out all the lines except the directory where all the customised modules files will be kept.
..... ..... /usr/local/Modules/contents # General module files ..... .....
Step 5: Update /etc/profile.d of the Servers
Copy the profile.modules from the $ModuleHome Directory
# cp /$ModuleHome/modules-3.2.9/etc/global/profile.modules /etc/profile.d/modules.sh
The content of modules.sh are as followed
#----------------------------------------------------------------------# # system-wide profile.modules # # Initialize modules for all sh-derivative shells # #----------------------------------------------------------------------# 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 ;; # sh and default for scripts esac trap 1 2 3
Sample Installation of an application using Modules (Intel Compilers)
Step 1: Create a Module File.
Place the Module File for Intel in /usr/local/Modules/contents
a. Create an Intel Folder inside /usr/local/Modules/contents
# mkdir /usr/local/Modules/intel
b. Create a module file for the version of Intel (In my case, “12.0.2”). To save some time, you can copy a “sample” file and you can edit
# cp $ModuleHome/modules-3.2.9/modulefiles/modulefile /usr/local/Modules/contents/intel/12.0.2
# vim /usr/local/Modules/contents/intel/12.0.2
#%Module1.0 proc ModulesHelp { } { global version prefix puts stderr "\tIntel XE 12.0.2 (icc, icpc, ifort)" } module-whatis "Intel XE 12.0.2 (icc, icpc, ifort)" prepend-path PATH /opt/intel/composerxe/bin prepend-path LIBRARY_PATH /opt/intel/composerxe/lib/intel64 prepend-path LD_LIBRARY_PATH /opt/intel/composerxe/lib/intel64:/opt/intel/mkl/10.2.6.038/lib/em64t prepend-path MANPATH /opt/intel/composerxe/man prepend-path MKL_HOME /opt/intel/mkl/10.2.6.038 setenv CC icc setenv CXX icpc setenv FC ifort setenv F77 ifort setenv F90 ifort
Step 2: Setting the Default versions of Intel.
If you have different version of software you wish to present to the users, do the following
# vim /usr/local/Modules/contents/intel/.version
#%Module1.0 set ModuleVersion "12.0.2"
More Information
Rather than build from sources, you could install the binary package from EPEL. It’s called “environment-modules” there. (I notice the name of the project on Sourceforge has changed to match this, too.) Hope that helps! (I’ll cross post this to the related CentOS6 posting!)
LikeLike
Hey Rich,
Is it possible for you to give me some help on creating modulefiles? I would really appreciate! Thanks!
LikeLike
Pingback: Installing and Configuring Environment Modules on CentOS 6 | Linux Cluster