Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


O2 uses the Lmod system of environment modules; this system allows you to manage your environment to access separate applications that are installed on O2. Lmod also automatically tracks dependencies, so you do not need to worry about accidentally running a program in the wrong environment or against the wrong libraries. This is also how Lmod organizes the applications.

...

In order to see a list of all modules that are available to the user on O2, type into the terminal:

Code Block
module spider

This command generates a verbose list of modules and their brief descriptions, which you can page through with <spacebar>, j or k, arrow keys, etc.

To view a list of modules that are available to load immediately, type into the terminal:

Code Block
module avail

This command generates a concise list of modules that you can load given the current state of your environment.

To search all modules for specific keywords use the command: 

Code Block
module keyword string

which will display information about all modules containing the keyword "string". This command can be useful when module spider does not return any result.

...

To load a module, simply take one of the module strings from the output of the module viewing commands, and load it like so (in the example of GCC 6.2.0):

Code Block
module load gcc/6.2.0

This will add GCC version 6.2.0 to your environment. You can confirm that it is there by typing:

Code Block
module list

to see a list of modules currently loaded in your environment. Sometimes you will see that there are more modules loaded than you have explicitly loaded yourself; this is because RC has tried to handle any codependencies that a program might have by having the main module load those extra modules in order to provide a more painless user experience (i.e. less need to troubleshoot a faulty module).

To unload a module, simply type:

Code Block
module unload gcc/6.2.0

(to unload gcc/6.2.0.) Any extra modules that were loaded with the module when you first loaded it also get unloaded when you unload that module. For instance, if you load module A, which automatically loads B and C, if you unload A, B and C also get unloaded. However, if you unload B or C, A will remain. We trust you will be careful with your dependencies, as Lmod can only mitigate so much user error.

To remove all modules from your environment, type:

Code Block
module purge

and your environment will no longer have any modules loaded.

...

If you have a set of modules you load and use often, you can take a snapshot of your environment and set it up to be reloaded whenever you like. Once you have your list of modules loaded, type:

Code Block
module save <collection_name>

and it will record the list of modules, saved to the name you specified. You can have as many of these as you'd like.

To load a collection, use the following command:

Code Block
module restore <collection_name>

To view the contents of a collection, use:

Code Block
module describe <collection_name>

To view all of your collections, use:

Code Block
module savelist

Creating Your Own Modules

...

Once you have your program installed/the information on how it was installed, you need to create a modulefile for this program. A typical modulefile for a program on the O2 application stack will look something like this (using GCC 6.2.0 as an example), written in Lua:

Code Block
linenumberstrue
help([[
For detailed instructions, go to:

    https://gcc.gnu.org/
]])

whatis("Version: 6.2.0")
whatis("Keywords: compiler, gcc")
whatis("URL: https://gcc.gnu.org/")
whatis("Description: GCC stands for \"GNU Compiler Collection\". GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Java, Fortran, Ada, and Go.")

prepend_path( "PATH",            "/n/app/gcc/6.2.0/bin")
prepend_path( "LD_LIBRARY_PATH", "/n/app/gcc/6.2.0/lib")
prepend_path( "LD_LIBRARY_PATH", "/n/app/gcc/6.2.0/lib64")
prepend_path( "MANPATH",         "/n/app/gcc/6.2.0/share/man")

add_property("state", "experimental")

family("gcc")

-- set up MODULEPATH for packages built by this compiler
local mroot = os.getenv("MODULEPATH_ROOT")
local mdir = pathJoin(mroot, "Compiler/gcc", "6.2.0")
prepend_path("MODULEPATH", mdir)

...

On O2, modulefiles are structured such that within the modulefile directory, the hierarchy is

Code Block
<program_name>/<version>.lua

So if you have version 5 of program A, the hierarchy would be something like

Code Block
modulefiles/A/5.lua

where 5.lua contains the contents of the modulefile you have written (in lua). You can have multiple subdirectories, and all of them will be mapped.

Once you have set up your modulefile directory tree, add that directory to your Lmod cache with the following command:

Code Block
module use path/to/modulefiles

To remove a directory (e.g. if you move the directory to somewhere else), simply type

Code Block
module unuse path/to/modulefiles

These commands will modify your MODULEPATH environment variable. DO NOT MODIFY THIS VARIABLE MANUALLY; only use module use and module unuse to interact with this environment variable.