Lmod on Linux Hosts

If you can't find an application on a Purdue IT-supported Linux host, try using the Lmod environment module system. This command will show you the software available for loading using Lmod:

module avail

You will see something like this:

------------------------------- /etc/modulefiles -------------------------------
   mpi/mpich-x86_64        mpi/mpich-3.2-x86_64        pkg/python3/3.7.4
   mpi/mpich-3.0-x86_64    mpi/openmpi3-x86_64  (D)

----------------------------- /etc/modulefiles/pkg -----------------------------
   python3/3.7.4

----------------------- /package/modulefiles/ecn/common ------------------------
   comsol/4.3b        gurobi/8.0.1            matlab/R2019a
   comsol/5.2a        intel/16.0.3            matlab/R2019b        (D)
   comsol/5.3a        intel/18.0.1     (D)    pointwise/18.3R1
   comsol/5.3         maple/2019              tecplot-360/2018R1.1
   comsol/5.4         mathematica/12.0        tecplot-rs/2017R1
   comsol/5.5  (D)    matlab/R2015a           thermocalc/2018b
   cplex/12.9         matlab/R2017a
   gams/27.2.0        matlab/R2018b

----------------------- /package/modulefiles/ecn/centos ------------------------
   abaqus/2019         ansys/2020R1           gcc/5.3.0
   ansys/15.0.7        ansysedt/19.0          gcc/6.3.0
   ansys/19.0          ansysedt/2019R2 (D)    gcc/7.1.0
   ansys/2019R2 (D)    ansysedt/2019R3        gcc/8.3.0    (D)
   ansys/2019R3        ansysedt/2020R1        texlive/2019

By default, no modules are loaded at login or when a terminal/console/shell is opened. To use a specific application:

module load matlab

This will load the default version of Matlab. Those are noted by the (D) next to them in the module avail command.

You can also load a specific version of an application, too:

module load matlab/R2015a

This will unload the version of Matlab currently loaded if it is not R2015a.

NOTE: loading a module does not start the associated software. It only modifies your environment so you can then run the associated command(s) for that software.

Also, lmod modifies your shell environment. Previously, you might have used an explicit path to run Matlab, like:

/usr/opt/bin/matlab -nodisplay < my_run.m

This is a perfectly reasonable and excellent way to do things. However, there is no /usr/opt/bin on systems that use lmod. Instead, you can just do:

matlab -nodisplay < my_run.m

You could use an explicit path for a program by doing something like:

which matlab

However, that path might change over time, so we would recommend against it when using lmod.

More information about Lmod can be found in the project documentation.

If you have problems with lmod commands not being found:

You can determine which shell you're using by running:

echo "$SHELL"

If you are using bash, it is recommended you add the lines below to the top of ~/.bashrc :

if [ -f /etc/bashrc ]; then
   . /etc/bashrc
elif [ -f /etc/bash.bashrc ]; then
   . /etc/bash.bashrc
fi

You might need to make sure the terminal/shell is a 'login' shell. First, look at the top of the terminal/shell window. If the title of the window is 'Terminal', see the Terminal instructions. If the title includes 'Konsole', see the Konsole instructions.

Terminal

Under Edit-->Preferences there should be a choice to open the terminal/shell as a 'login' shell. Select "Run command as login shell", then close that terminal and open a new one. The lmod commands should now be properly sourced and available.

Terminal Preferences window with the "Run command as login shell" option checked

Konsole

Click on the Settings menu item and select Manage Profiles...

Konsole Settings menu with Manage Profiles highlighted

If there is only one profile listed and it is marked as read-only, a new profile must be created. Click on the New button on the left side.

Konsole configuration Profiles tab with the New button highlighted

If the existing default profile is not read-only, click on the Edit button on the left side instead. Under the profile name check the box labeled Default profile. Add the "-l" flag /bin/bash (or another shell like tcsh or zsh). Next, click the Apply button.

Konsole new profile settings window. The default profile checkbox is checked. The command is "/bin/bash -l". The Apply button is highlighted

Click on the OK button, then close that terminal and open a new one. The lmod commands should now be properly sourced and available.