Creating a module

De Wiki de Calcul Québec
Aller à : Navigation, rechercher
Cette page est une traduction de la page Créer un module et la traduction est complétée à 100 % et à jour.

Autres langues :anglais 100% • ‎français 100%

General description

A module file describes the environment that is associated to an application. Using this file you can for example add, using just one command, new access paths to the $PATH environment variable or add library paths to $LD_LIBRARY_PATH.

Module files are written in the Tool Command Language (TCL). However, you do not need to know this language to write one, because only a small subset of commands suffices.

Warning! When you create your own modules, you must specify the complete path to those modules when you load them. For example, if you have a module named ~/modulefiles/apps/myapp/1.0.0, you can load it as follows:

[name@server $] module load /home/user/modulefiles/apps/myapp/1.0.0

. You can omit this complexity if you add the directory /home/user/modulefiles to the environment variable $MODULEPATH. To do this, use the module sub-command 'use:

[name@server $] module use /home/user/modulefiles/


If you use modules automatically, you can put this command at the start of your ~/.modules file. Do not put it in your .bashrc file because when you start a session the .modules file is read before the .bashrc file is ran.

Example

A module file's contents are simple enough, a good starting point is to take an existing file as an example and to modify the variables it contains to adapt it to the module that you would wish to install:

File : modulefiles/mpi/openmpi/1.6.3_intel
#%Module1.0
#####################################################################
##
## OPENMPI MPI lib
##
##
proc ModulesHelp { } {
        puts stderr "\tAdds the OpenMPI library to your environment. "
}
 
module-whatis "(Category_______) mpi"
module-whatis "(Name___________) OpenMPI"
module-whatis "(Version________) 1.6.3"
module-whatis "(Website________) http://www.open-mpi.org/"
module-whatis "(Authorship_____) The Open MPI Team"
module-whatis "(Compiler_______) Intel 2013"
module-whatis "(Flags__________) CFLAGS='-O3 -xHOST -Wall' ../openmpi-1.6.3/configure --prefix=prefix --with-threads "
module-whatis "                  --enable-mpi-thread-multiple --with-openib --enable-shared --enable-static --with-ft=cr --enable-ft-thread "
module-whatis "                  --with-blcr=/software/apps/blcr/0.8.4 --with-blcr-libdir=/software/apps/blcr/0.8.4/lib --with-tm=/opt/torque "
module-whatis "                  CFLAGS='CFLAGS' --with-io-romio-flags='--with-file-system=testfs+ufs+nfs+lustre'"
module-whatis "(Dependencies___) Intel 2013"
 
conflict                               mpi
prereq                             compilers/intel/2013
set                synopsys            /software/MPI/openmpi/1.6.3_intel
set                blcr_synopsys       /software/apps/blcr/0.8.4
prepend-path       PATH                $synopsys/bin:$blcr_synopsys/bin
prepend-path       LD_LIBRARY_PATH     $synopsys/lib:$blcr_synopsys/lib
prepend-path       LIBRARY_PATH     $synopsys/lib:$blcr_synopsys/lib
prepend-path       CPATH      $synopsys/include
prepend-path       MANPATH             $synopsys/share/man:$blcr_synopsys/man
setenv             OMPI_MCA_plm_rsh_num_concurrent 960


Let us consider this example in detail. This file start with a comment (lines starting with the number sign #), which specifies that it is a module using format 1.0. Other comments show that this is a module for the MPI library OpenMPI. The actual module then starts by defining a function, ModulesHelp. This function is then called when a user runs the following command:

[name@server $] module help mpi/openmpi/1.6.3_intel


This command outputs the message "Adds the OpenMPI library to your environment." to standard error.

Note : All messages that are displayed by the module command use standard error (stderr) instead of standard output (stdout).

The module then continues with a list of commands including the following:

Command Meaning
module-whatis Allows for a more elaborate description of the module, which is shown using module whatis module_name.
conflict Specifies that this module cannot be loaded if the given module was already loaded.
prereq Specifies a pre-required module.
set Defines a variable that is internal to the module.
prepend-path Prefix an environment variable of the type PATH using the specified path.
setenv Defines an environment variable.

The above module defines a detailed description using the module-whatis command. Following that, it specifies that the module cannot be loaded together with another mpi module, that means that only one mpi module can be loaded at the same time. After that, it specifies that the Intel compiler, version 2013, is required.

After that, the module adds some directories to various environment variables, and finally defines a new environment variable (an OpenMPI control parameter in this case).

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Ressources de Calcul Québec
Outils
Partager