Module written in C
This is a verbatim redistribution (fair use under GPL v2.0) of cmod written by the following people:
- Per Cederqvist
- Kent Engström
- Henrik Rindlöw
- David Kågedal
The source file can be found at http://www.lysator.liu.se/cmod/
git clone https://github.com/yuhangwang/CMod.git
cd CMod/src/source
tar xvf cmod-1.1.tar.gz
cd cmod-1.1
mkdir -p ~/install/cmod/1.1
./configure --prefix=$HOME/install/cmod/1.1
make
make check
make install
- If you are using
bash
shell, add the following line to your.bashrc
file (or.bash_profile
if you are using Mac OS)source $HOME/install/cmod/1.1/etc/cmod/bash.init
- If you are using
tcsh
shell, add the following line to your.cshrc
filesource $HOME/install/cmod/1.1/etc/cmod/tcsh.init
- To dynamically load/unload some software into your shell environment,
you need to write some module specification scripts and use
module use [path to your module specification folder]
command to makemodule
aware of these scripts. Take a look at the use case below.
- Suppose we have installed a new version of python and we want to
use
module
to dynamically loaded it into the our shell environment when we need it and unload it when we are done. - First, you need to make a folder containing the CMod scripts.
mkdir -p ~/modules/python
- Then create a new file
~/modules/python/default
with the following content.prepend-path PATH /Users/steven/install/miniconda/3/bin prepend-path DYLD_LIBRARY_PATH /Users/steven/install/miniconda/3/lib
- You can also use other file names
such as
~/modules/python/3.7
. Then you have to usemodule add python/3.7
instead of justmodule add python
. - Add the following lines in your
~/.bashrc
filesource $HOME/install/cmod/1.1/etc/cmod/bash.init module use $HOME/modules
- Refresh your BASH shell using
source ~/.bashrc
- Now you can see the available modules with
module avail
- To load a module into your current bash shell, use
module add python
- To remove the module, use
module rm python
- To see the currently loaded modules, use
module list
- You can add more module files to
~/modules
similar to the python example.
append-path
: appending a directory to a path.prepend-path
: prepending a directory to a path.remove-path
: removing a directory from a path.setenv
: setting a variable to a fixed value.unsetenv
: unsetting a variable.
module add
: add module(s), e.g.,module add python/3.7
module try-add
: same asmodule add
except without error messages if the module is not found.module rm
: remove a loaded module, e.g.,module rm python/3.7
module use
: add a new path that contains module scripts, e.g.,module use /home/steven/modules/apps
. In theapps
folder, you can put subfolders which contain module specification scripts, e.g.,apps/python/default
.module unuse
: remove a path searchable bymodule
module list
: list currently loaded modulesmodule avail
: list all available modules, a very useful feature to see all the software you have installed.
A complete documentation can be found in the info
folder of your cmod installation path.
You can also browse the documentation contained in the usage/cmod.md
file of this Github repository.
For some example module specification scripts, take a look at the examples folder.