Module is a convinient way to manage shell environment variables and aliases. And it is simple enough for linux novice users to use the right software/compiler that they want. As far as I know, there are two module software, lmod and environmental module using tcl language.
Our cluster OS came with Environmental Module 3.2.10.
1. Customize module path (only needed for adding a new parent folder for modulefiles)
the Module software searches in a environment variable, MODULEPATH, for available modulefiles. The first step is to add a new folder to this environment variable MODULEPATH and thus we can put all the customized-modulefile in this new folder. I don't want to revise the system default module folder, like /usr/share/Modules/modulefiles and /etc/modulefiles, so that we can also distinguish our adaption to the system default modules.
mkdir -p /share/apps/Modules/modulefiles echo "
export MODULEPATH=\$MODULEPATH:/share/apps/Modules/modulefiles" >>/etc/profile.d/modules.sh
Since the files in /etc/profile.d are not automatically sync to compute nodes. We can push this change manually. The for loop will loop over all nodes and copy the .sh file from the master node to the compute node.
rocks run host compute command="echo "export MODULEPATH=\$MODULEPATH:/share/apps/Modules/modulefiles" >>/etc/profile.d/modules.sh"
However, this is not enough. This manual push will be purged if the compute node is reinstalled. (for example, rocks will reinstall the compute node after an power outage, not reboot though.)
We also need to add this change into the distro. See offical manual here.
vi /export/rocks/install/site-profiles/6.1/nodes #edit the file and add a line in the post installation section. <post> ... echo "export MODULEPATH=\$MODULEPATH:/share/apps/Modules/modulefiles" >>/etc/profile.d/modules.sh </post>
Rebuild the distribution
cd /export/rocks/install rocks create distro
We don't need to do anything for the /share/apps/Modules folder, since /share/apps are automatically updated to all compute nodes.
2. Add in module files
The module file has to be written in TCL and put in the folder /share/apps/Modules
At the moment, I only add several files for vasp and mpi. I learn the format by official manual of module, modulefile and
module show null module show modules
and the example on XSEDE machines.
Here's a list of the new module added.
mpich: 3.0.3 openmpi: 1.6.4 vasp: 5.4.1-mpich 5.4.1-openmpi-1.6.4
3. set up the default version
add a ".version" file at the module folder you want like below
cd /share/apps/Modules/mpich-3.0.3/qe cat > .version <<EOF #%Module1.0 set ModulesVersion "6.0" EOF