Customizing Your Computing Environment with Modules

7. Switching Application Environments

When switching among applications, you may need to remove the changes made by a previously loaded modulefile(s) before loading another one. There are two ways you can do this. 

First, you can use the module unload and module load commands that you learned about previously. Recall that the module unload command removes the environment changes made by a modulefile. Therefore, when switching applications, you can use the module unload command to remove the changes made by your previously loaded modulefile(s) and then load your new modulefile using the module load command. 

The second way is to use a single Modules command that lets you switch between applications by unloading one modulefile and loading another. This command is appropriately called module switch. Note that the module swap command and the module switch commands are equivalent, and only the name differs. If you try one of them on your system and you get an error message, use the other one. On some systems, you can use either one.

The syntax for the module switch command is:

module switch modulefile1 modulefile2

where modulefile1 is the currently loaded modulefile, and modulefile2 is the modulefile you want to load.

For example, to switch to another version of Matlab, say version 9.4, you would enter:

$ module switch matlab/9.7 matlab/9.4

Entering the module list command, we see that the switch was made.

$ module list
Currently Loaded Modulefiles:
  1) torque/6.1.2   2) moab/9.1.2     3) env/ncsa       4) env/taub       5) matlab/9.4     6) java/1.8


Icon indicating an exerciseExercises

Complete the following exercises by entering the appropriate module command on your system's command line:

Exercise 1: In the last section's exercises, you used the module load command to load a modulefile of your choice. Now, remove it and show that it is no longer in your shell environment.



Exercise 2:  You have java/1.8 loaded into your software environment. What single module command would you enter to switch it to another version?