Ada, Adapp: User instructions for the module command

Introduction

The module command is a means of responding most effectively to your specific needs. That is, to set the environment variables such as compilers, mathematical libraries and tools without you having to look for them. It enhances the environment according to what you want to use.

Syntax

module (avail [product] | load product[/version] | list | switch product/version1 product/version2 | display product[/version] …)

  • ''avail'': lists the different products available and their versions
  • ''load'': loads the product in its default version (noted: default), if a version is not specified
  • ''list'': lists the different products loaded and their versions
  • ''switch'': changes the version of a product already loaded

product represents the choice of:

  • a work mode
  • a compilor
  • a library
  • an application or a tool

version represents the different versions of the same product, and can include:

  • default: version by default. This is taken if you do not specify a version; the default version is generally the best adapted.
  • a number: complete number of the version. 

Initialisation of the module command

The initialisation of module is done implicitly in the general environment files. Nothing needs to be positioned to obtain access to the module command.         

List of available products

Are you looking for a specific product such as a particular version of a library? Do we have it for your use? To find the response to this question, use the command module avail:

  $ module avail

  --------------------------- /smplocal/pub/Modules/IDRIS/modulefiles/environnement ---------------------------
  compilerwrappers/no           modules/1.147
  compilerwrappers/yes(default) modules/3.2.10(default)
  
  --------------------------- /smplocal/pub/Modules/IDRIS/modulefiles/bibliotheques ---------------------------
  arpack/96(default)               lapack/10.3.6(default)           petsc/real-hypre/3.3-p5
  blas/10.3.6(default)             lapack95/10.3.6(default)         petsc/real-mumps/3.1-p8(default)
  blas95/10.3.6(default)           mumps/4.10.0(default)            petsc/real-mumps/3.3-p5
  cmor/2.8.1(default)              nag/23(default)                  phdf5/1.8.9(default)
  fftw/2.1.5                       ncar/6.1(default)                pnetcdf/1.1.1
  fftw/3.2.2                       netcdf/4.1.3                     pnetcdf/1.3.1(default)
  fftw/3.3.2(default)              netcdf/mpi/4.1.3                 scalapack/10.3.6(default)
  fftw/3.3.3                       netcdf/seq/4.1.3(default)        scotch/6.0.0(default)
  hdf5/1.8.9(default)              p3dfft/2.5.1(default)            udunits/2.1.24(default)
  hdf5/mpi/1.8.9                   parmetis/3.2.0(default)          uuid/1.6.2(default)
  hdf5/seq/1.8.9                   parpack/96(default)              vtk/5.10.1(default)
  hypre/2.9.0b(default)            petsc/3.1-p8
  
  --------------------------- /smplocal/pub/Modules/IDRIS/modulefiles/applications ----------------------------
  abinit/7.0.5(default)        espresso/4.3.2               namd/2.8
  adf/2012.01c(default)        espresso/5.0.1(default)      namd/2.9(default)
  adf/2013.01.r36703           espresso/5.0.2               nwchem/6.1.1(default)
  avbp/avbp(default)           gaussian/g03_D02             siesta/2.0.2
  cdo/1.5.9(default)           gaussian/g09_A02(default)    siesta/3.1(default)
  cp2k/2.3_12343(default)      gromacs/4.5.5(default)       siesta/3.1-pl20
  cp2k/2.4_12578               gromacsplumed/4.5.5(default) vasp/4.6.35
  cpmd/3.13.2                  lammps/2012.10.10(default)   vasp/5.2.12(default)
  cpmd/3.15.3(default)         molcas/7.8(default)          vasp/5.2.2
  espresso/4.2.1               molpro/2010.1(default)
  
  ------------------------------ /smplocal/pub/Modules/IDRIS/modulefiles/outils -------------------------------
  cmake/2.8.10.2(default)   idl/8.2(default)          papi/5.1.0.2(default)     python/3.3.0
  ferret/6.84(default)      nco/4.2.3(default)        paraview/3.98(default)    totalview/8.11.0(default)
  fpmpi2/2.2(default)       ncview/2.1.2(default)     python/2.7.3(default)     xmgrace/5.1.23(default)

This list is permanently evolving. (The above list is dated April 2013.)

Loading an application

To launch an application, it is necessary to explicitly load the product before the execution by using the command module load: 

$ module load namd

The module command completes the environment variable PATH in such a way as to be able to execute the product without needing to position the absolute or relative path to define its localisation.  You can see all the positioned environment variables of a module by using the command module display :

$ module display namd
-------------------------------------------------------------------
/smplocal/pub/Modules/IDRIS/modulefiles/applications/namd/2.9:

conflict         namd
prepend-path     PATH /smplocal/prod/NAMD/2.9/bin 
module-whatis    namd version 2.9
-------------------------------------------------------------------

Implicit linking with a library

Your code calls the NetCDF library : Before launching the compilation, it is necessary to load the module corresponding to the library by using the command module load :

$ module load netcdf

The compiling and linking with NetCDF are done implicitly:

$ mpiifort -c call_netcdf.f90
$ mpiifort call_netcdf.o -o call_netcdf.exe

Linking with library

The NetCDF references will be found automatically at the time of linking because one uses “module compilerwrappers/yes” by default, which adds some hidden options to the native compilers (wrappers). To see the options actually passed to the compiler, you can use the following compilation flags -display, -show, -#, -echo, -v :

$  mpiifort -c -display call_netcdf.f90
# Modules - Fortran compiler wrapper
# mpiifort is /opt/intel/impi/4.0.3.008/intel64/bin/mpiifort
# mpiifort -c call_netcdf.f90 -I/smplocal/pub/NetCDF/4.1.3/seq/include
$  mpiifort -display call_netcdf.o
# Modules - Fortran compiler wrapper
# mpiifort is /opt/intel/impi/4.0.3.008/intel64/bin/mpiifort
# mpiifort  call_netcdf.o -I/smplocal/pub/NetCDF/4.1.3/seq/include -L/smplocal/pub/NetCDF/4.1.3/seq/lib -Bstatic -lnetcdff -lnetcdf -lnetcdf_c++ -Bdynamic -L/smplocal/pub/HDF5/1.8.9/seq/lib -Bstatic -lhdf5hl_fortran -lhdf5_hl_cpp -lhdf5_hl -lhdf5_fortran  -lhdf5_cpp -lhdf5  -Bdynamic -lz

Execution

The executable built with the module command calls the libraries which are linked in static mode, unless stated otherwise in the specific documentation of the library. It is not necessary, therefore, to launch module another time before the execution.

Explicit linking with a library

If you wish to find the native compilers and thereby disactivate the wrappers, you must proceed as follows:

$ module purge
$ module load compilerwrappers/no      (Must be the first load.)
$ module load netcdf

Following this, you must not forget to explicitly use the environment variables generated by module during the compilation and linking:

$ mpiifort -c $NETCDF_FFLAGS call_netcdf.f90
$ mpiifort $NETCDF_LDFLAGS call_netcdf.o -o call_netcdf.exe

You can visualise the environment variables defined at load time by using the command module display :

$ module display netcdf
-------------------------------------------------------------------
/smplocal/pub/Modules/IDRIS/modulefiles/bibliotheques/netcdf/seq/4.1.3:

conflict         netcdf
prepend-path     PATH /smplocal/pub/NetCDF/4.1.3/seq/bin
prepend-path     MANPATH /smplocal/pub/NetCDF/4.1.3/seq/share/man
prepend-path     WRAPPER_FFLAGS -I/smplocal/pub/NetCDF/4.1.3/seq/include
prepend-path     WRAPPER_CXXFLAGS -I/smplocal/pub/NetCDF/4.1.3/seq/include
prepend-path     WRAPPER_LDFLAGS -L/smplocal/pub/NetCDF/4.1.3/seq/lib -Bstatic -lnetcdff -lnetcdf -lnetcdf_c++ -Bdynamic -L/smplocal/pub/HDF5/1.8.9/seq/lib -Bstatic -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -Bdynamic -lz
setenv           WRAPPER_PATH /smplocal/pub/Modules/IDRIS/wrappers
prepend-path     PATH /smplocal/pub/Modules/IDRIS/wrappers
module-whatis    netcdf seq 4.1.3
-------------------------------------------------------------------

Loading a product containing different versions

A product (application, library, tool, …) can offer several versions, or a hierarchy of versions, but has only one version by default (label default).  Here are two examples indicating the different possible syntaxes for loading a product:

  • The Quantum ESPRESSO application contains several versions :
  $ module avail espresso
  ------------------------------- /smplocal/pub/Modules/IDRIS/modulefiles/applications --------------------------------
  espresso/4.2.1          espresso/4.3.2          espresso/5.0.1(default) espresso/5.0.2

To load the version by default espresso/5.0.1, you can use the following:

  $ module load espresso
  $ module load espresso/5.0.1

However, to load espresso/5.0.2, you must specify the version number :

  $ module load espresso/5.0.2
  • Another example:  The HDF5 library contains 2 sub-versions (parallel mpi and sequential seq) :
  $ module avail hdf5
  ------------------------------- /smplocal/pub/Modules/IDRIS/modulefiles/bibliotheques -------------------------------
  hdf5/mpi/1.8.9          hdf5/seq/1.8.9(default)

The following syntaxes are authorised for loading the version by default hdf5/seq/1.8.9 :

    $ module load hdf5
    $ module load hdf5/seq
    $ module load hdf5/seq/1.8.9

To load hdf5/mpi/1.8.9, you can do the following:

$ module load hdf5/mpi
$ module load hdf5/mpi/1.8.9

List of products loaded

$ module list
Currently Loaded Modulefiles:
  1) espresso/5.0.1            2) hdf5/seq/1.8.9(default)

Changing the version of a product already loaded

This is not possible, of course, unless an alternative version appears in the list given by module avail. For example, the Quantum ESPRESSO version by default is not suitable for you? You can replace it vithankther available version by using the argument switch of the module command.

$ module switch espresso/5.0.1 espresso/5.0.2

With this command, you will use Quantum ESPRESSO version 5.0.2 instead of version 5.0.1.

Secondary effects to be avoided

The use of the module command can generate messages on the standard output stdout. This is a behaviour which must be avoided if the command is placed in a file ~/.bashrc or ~/.tcshrc  because this is detrimental to behaviours of commands such as rsh or ssh. In a non-interactive shell, these messages can be disactivated by using the option -s :

$ module -s load netcdf