@@ -73,12 +73,54 @@ to a hierarchy with 3 levels:
73733 . The `` MPI `` level, containing libraries and applications that depend on the compiler used and the MPI
7474 implementation.
7575
76+ ??? Example "A simple Lmod hierarchy with a single compiler"
77+
78+ Here is a simple example of such a 3-level module hierarchy
79+ (that almost could have been generated by EasyBuild):
80+
81+ <div align="center"><img src="../../img/hmns.png" width="60%"/></div>
82+
83+ In this example the ``Core`` level only includes a single module `GCC/9.3.0`,
84+ while the ``Compiler`` level includes two modules: `OpenMPI/4.0.3` and `MPICH/3.3.2`.
85+ In the ``MPI `` level, three modules are available: one for `FFTW`, one for `ScaLAPACK`,
86+ and one for `HDF5`.
87+
88+ Initially only the modules on the top level of a module hierarchy are available for loading.
89+ If you run "`module avail`", the command that is used to view all modules that are available
90+ for loading, with this example module hierarchy, you will only see the `GCC/9.3.0` module.
91+
92+ Some modules in the top level of the hierarchy act as a "gateway" to modules in the
93+ next level below.
94+ To make additional modules available for loading one of these gateway modules has to be loaded.
95+ In our example, loading the `GCC/9.3.0` module results in two additional modules coming into
96+ view from the ``Compiler`` level, as indicated by the arrows: the modules for `OpenMPI` and `MPICH`.
97+ These correspond to installations of `OpenMPI`
98+ and `MPICH` that were built using `GCC/9.3.0`.
99+
100+ Similarly, the `OpenMPI/4.0.3` module serves as a gateway to the three modules in the ``MPI`` level.
101+ Only by loading the `OpenMPI` module will these additional three modules become
102+ available for loading. They correspond to software installations built using the ``GCC/9.3.0``
103+ compiler with ``OpenMPI/4.0.3``.
104+
76105Now assume that we have two compilers in the hierarchy, Compiler_A and Compiler_B. Their modules would reside
77- at the `` Core `` level. Both copilers provide the same MPI implementation, MPI_C. So there would be two modules
106+ at the `` Core `` level. Both compilers provide the same MPI implementation, MPI_C. So there would be two modules
78107for `` MPI_C `` in two different subdirectories at the `` Compiler `` level. And further assume that we have an
79108application, Appl_E, compiled with both Compiler_A and Compiler_B and using MPI_C. For that application there would
80109also be two module files at the `` MPI `` level, one in a subdirectory corresponding ao Compiler_A and MPI_C and one
81- in a subdirectory corresponding to Compiler_B and MPI_C. To be able to load the module for Appl_E, a user should
110+ in a subdirectory corresponding to Compiler_B and MPI_C.
111+
112+ ``` mermaid
113+ graph TD;
114+ A[Compiler_A] --> AC[MPI_C];
115+ A --> AD[MPI_D]
116+ B[Compiler_B] --> BC[MPI_C];
117+ AC --> ACE[Appl_E];
118+ AD --> ADE[Appl_E]
119+ BC --> BCE[Appl_E];
120+ ```
121+
122+
123+ To be able to load the module for Appl_E, a user should
82124first load Compiler_A, then load MPI_C and only then is it possible to load the module for Appl_E:
83125
84126``` bash
@@ -102,6 +144,23 @@ and depending on those adapt the path to the binaries, several very simple modul
102144logic, and one could add an Appl_E module for a different compiler or MPI implementation without touching any of the already
103145existing module files for that application.
104146
147+ Similarly, if after
148+
149+ ``` bash
150+ module load Compiler_A MPI_C Appl_E
151+ ```
152+
153+ one does
154+
155+ ``` bash
156+ module load MPI_D
157+ ```
158+
159+ thent MPI_C gets unloaded, Lmod notices that it also has to unload/deactivate Appl_E, then will load MPI_D for Compiler_A and
160+ finally will notice that there is an equivalent Appl_E module available again, and Lmod will load that one also. However,
161+ now loading Compiler_B will cause a warning that MPI_D and Appl_E have been deactivated as there is no module name MPI_D in
162+ any version for Compiler_B.
163+
105164
106165### Building blocks
107166
@@ -126,8 +185,9 @@ Some mechanisms in Lmod make implementing a hierarchy fairly easy (though there
126185
127186### Implementation details
128187
129- The above example could be implemented using 6 module files: One for each compiler, two for the MPI module and
130- two for the application module.
188+ The above example could be implemented using 8 module files: One for each compiler, three for the MPI modules
189+ (two for MPI_C and one for MPI_D) and
190+ three for the application modules.
131191
132192```
133193moduleroot
@@ -139,17 +199,23 @@ moduleroot
139199├── Compiler
140200│ ├── Compiler_A
141201│ │ └── version_A
142- │ │ └── MPI_C
143- │ │ └── version_C.lua
202+ │ │ ├── MPI_C
203+ │ │ │ └── version_C.lua
204+ │ │ └── MPI_D
205+ │ │ └── version_D.lua
144206│ └── Compiler_B
145207│ └── version_B
146208│ └── MPI_C
147209│ └── version_C.lua
148210└── MPI
149211 ├── Compiler_A
150212 │ └── version_A
151- │ └── MPI_C
152- │ └── version_C
213+ │ ├── MPI_C
214+ │ │ └── version_C
215+ │ │ └── Appl_E
216+ │ │ └── version_E.lua
217+ │ └── MPI_D
218+ │ └── version_D
153219 │ └── Appl_E
154220 │ └── version_E.lua
155221 └── Compiler_B
0 commit comments