Importance of Natural Resources

Environment Modules

Today we’re going to learn about the
environment model system before I explain how to use our model system you need to know
a couple of things first. The PATH is an environment variable that tells your
shell the directories where executable programs are located in other words the
PATH environment variable is how the shell knows what to do when you type
the `ls` command for example. However what happens if you want to use a
program that is not on our default path? We must first add that directory containing the executable programs to our PATH. We can do so like this. This will add all
the executables from the bin directory in my home directory to my path so I can use
them. Note that you separate the directories you wish to add with a colon. Also note
that we are *prepending* to our current path instead of overwriting it because we
reference the PATH variable at the end of this command. This process can get
tedious however, especially when you have to manage multiple versions of the same
software. This is where the environment model system comes in. It works by
modifying the PATH environment variable to tell your shell where to find new
programs that it doesn’t know about by default. This allows us to easily run
software that does not come preinstalled as part of the system. The other thing we need to know is when a program runs it usually requires some external libraries. One of the ways the
system knows where to find that libraries to load for the program is to
another environment variable called the LD_LIBRARY_PATH. Our model system updates this variable automatically so that a program always has access to the libraries it needs to run. I will explain some of the more helpful module commands
to use. You can display a list of all the available modules we have installed
simply by typing `module available`. Here we can see that it printed out all the
different versions of the software or modules That we have available. You can also
simply type `avail` as a shortcut. You can also see different versions of a
specific software by using the same command. For example, if I wanted to see
the different versions of the GNU Compiler Collection that we have
available I can simply type `module available compiler_gnu`. We can use any of the available modules that we have installed simply by typing `module load` For example, if I wanted to use the Julia
language, right now if I type Julia it says the command is not found this is
because the system cannot find Julia on my PATH. However if I type `module load julia` and then the version I want to use… We can see that it has been loaded by typing `module list` this will
list all of the models that we have currently loaded and available for use.
Now when I type in Julia, it does what we expected to do. This is because the
module command automatically updates the PATH environment variable for us.
Also note that if you don’t explicitly load a module there are some default
models that are automatically loaded for you when you login. We change these
default modules from time to time. Now, let’s say wanted to use a newer version of Julia I can do so by typing `module load julia/0.3.10_gnu-5.1.0` But as we can see, it tells us that it cannot load the new version of Julia
because it conflicts with the version of Julia we already have loaded. So, we must first unload Julia by typing ‘module unload julia` and then loaded again, or we can
do module swap and type the newer version to swap out the older version that we
already have loaded like this… Now as you can see have the new version of Julia loaded. and available to use. You can also unload all of the modules that you have currently loaded by typing `module purge` instead of typing `module unload` and then specifying all the modules we currently have loaded. As with most other programs you can type `man module` for more help. You can also use `module help` and then name of the module that you want help for. Or `module whatis` and the name of the module please be aware some models do not have a `help` or `whatis` command Thank you for watching and happy researching!

Leave a Reply

Your email address will not be published. Required fields are marked *