. /usr/share/Modules/init/bash
That will source the environment script and you will have the appropriate MODULEPATH and MODULESHOME values.
[root@master iozone]# set | grep MODULE LOADEDMODULES= MODULEPATH=/usr/share/Modules/modulefiles:/etc/modulefiles: MODULESHOME=/usr/share/Modules
After that, you will be able to add the module command in your scripts. Consider the following:
#!/bin/bash . /usr/share/Modules/init/bash module list module purge module list module avail module load mpi/openmpi-mellanox-interconnects-gcc module list
If you add the above commands to a file ''~/sandbox/modu.sh'' you will get the following:
sh ~/sandbox/modu.sh
No Modulefiles Currently Loaded.
No Modulefiles Currently Loaded.
----------------------------------------------- /usr/share/Modules/modulefiles -----------------------------------------------
PMPI/modulefile mpi/mvapich1-platform-interconnects-gnu
dot mpi/mvapich2-platform-interconnects-gnu
module-cvs mpi/openmpi-mellanox-interconnects-gcc
module-info mpi/openmpi-mellanox-interconnects-intel
modules mpi/openmpi-mellanox-interconnects-pgi
mpi/mvapich1-mellanox-interconnects-gcc mpi/openmpi-platform-interconnects-gnu
mpi/mvapich1-mellanox-interconnects-intel null
mpi/mvapich1-mellanox-interconnects-pgi use.own
This module will prepend the openmpi-mellanox-gnu bin, man and lib directories
to the PATH, MANPATH and LD_LIBRARY_PATH environment variables,
respectively.
Currently Loaded Modulefiles:
1) mpi/openmpi-mellanox-interconnects-gcc
[root@master iozone]#
anxious
calm

