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. For example:
% module avail
------------------------ /usr/share/Modules/modulefiles ------------------------
dot module-cvs module-info modules null use.own
--------------------- /usr/local/share/Modules/modulefiles ---------------------
mpich/gcc/1.2.7p1/32 openmpi/gcc/1.2.3/32 openmpi/intel/1.2.3/32
mpich/intel/1.2.7p1/32 openmpi/gcc-ib/1.2.3/32 openmpi/intel-ib/1.2.3/32
openmpi/gcc/1.1.2/32 openmpi/intel/1.1.2/32
openmpi/gcc/1.1.4/32 openmpi/intel/1.1.4/32
------------------------ /opt/share/Modules/modulefiles ------------------------
intel/9.1/32/C/9.1.045 intel/9.1/32/Iidb/9.1.045
intel/9.1/32/Fortran/9.1.040 intel/9.1/32/default
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
To see what modules are loaded, run module list. For example:
% module list
Currently Loaded Modulefiles:
1) intel/9.1/32/C/9.1.045 4) intel/9.1/32/default
2) intel/9.1/32/Fortran/9.1.040 5) openmpi/intel-ib/1.2.3/32
3) intel/9.1/32/Iidb/9.1.045
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, so they were automatically loaded. If you had wanted to load the OpenMPI built with GCC, you 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/1.1.2.
Now that the openmpi module is loaded, you can run OpenMPI commands. For example:
% which mpicc
/usr/local/openmpi/1.2.3/intel-ib/i386/bin/mpicc
% mpicc -o program program.c
To unload a module, run module unload modulename. For example:
% module unload openmpi
% module list
No Modulefiles Currently Loaded.
As you can see, the openmpi module has been unloaded, as well as all its dependencies.
To automatically load modules when you log in to a system, put the module load modulename command in your shell's startup script. For example, if your shell is bash, put the command in your ~/.bashrc, and if your shell is csh, put it in your ~/.cshrc. You can also use the module command in your PBS submission job, and it will automatically load the module when the job is run.
