Debian Codegraph @

doc/example/compiler-etc-dependencies/modulerc3/foo/gcc/9.1.0/.modulerc

raw
1 #%Module
2 # Choose MPI family
3 #
4 # This check if any MPI lib was previously "module loaded"
5 #
6 # If no MPI library was previously module loaded (and intel compiler suite
7 # was not loaded, see below) and nompiFlag is set (default is set), then
8 # if a "nompi" subdirectory exists, we will default to that.
9 # If nompiFlag is not set, then we just return w/out setting any default
10 # (allowing modulecmd to default on its own. It is the responsibility
11 # and the resulting modulefile to lado/require the MPI lib it needs or err
12 # as appropriate).
13 #
14 # If an MPI library was loaded, then we check for a subdirectory named after
15 # the family of the loaded MPI library, and if such exists, default to that.
16 # If it does not exist, we return w/out defaulting, allowing modulecmd to
17 # default according to its own rules. The resulting modulefile is responsible
18 # for aborting/complaining about the MPI library mismatch.
19 #
20 # Special handling is needed for intel MPI, as it does not get explicitly
21 # loaded if the Intel compiler suite is being used. So if no MPI library
22 # is loaded, we check to see if an Intel compiler was loaded. If so, we
23 # check for an "intelmpi" or similar subdirectory, and if found default to
24 # that. If not found, we proceed as above for the no MPI library case
25 # (defaulting to "nompi" if found and nompiFlag set, or just returning w/out
26 # defaulting otherwise).
27 #
28 # Usage:
29 # In most cases, can simply symlink .modulerc to this file
30 #
31 # In more complicated cases, .modulerc can source this file, and can
32 # then test the variable _did_default, which will be true if we set
33 # a default for modules for the next level, or false otherwise (in which
34 # case your .modulerc can set one)
35
36 # Source some required Tcl procedures here. Hack for cookbook
37 # making use of environment variable for location.
38 # In production, this should ideally be in a site config file.
39 # At minimum, hardcode the path
40 set rootdir $::env(MOD_GIT_ROOTDIR)
41 set tcllibdir $rootdir/doc/example/compiler-etc-dependencies/tcllib
42 source $tcllibdir/common_utilities.tcl
43
44 #Default nompiFlag to set
45 if ![info exists nompiFlag] { set nompiFlag true }
46
47 # _did_default will be true if we actually default something
48 # Useful in case a .modulerc sources us, and wants to set a default if we
49 # did not
50 set _did_default false
51
52 set moduledir [file dirname $ModulesCurrentModulefile]
53 set baseComponent [ file tail $moduledir ]
54
55 # Get the currently loaded MPI library
56 set fullMpiTag [ GetLoadedMPI 0 ]
57 set tmpMpiTag [ GetPackageFamilyVersion $fullMpiTag ]
58 set mpiFamily [ lindex $tmpMpiTag 0 ]
59
60 if { $mpiFamily eq {} } {
61 # No MPI module loaded
62 # What compiler is loaded (default from path if needed, but not GetDefaultCompiler)
63 set fullComp [ GetLoadedCompiler 1 0 ]
64 set tmpComp [ GetPackageFamilyVersion $fullComp ]
65 set compFam [ lindex $tmpComp 0 ]
66 if { $compFam eq {intel} } {
67 # OK, no MPI explicitly loaded, but using Intel compiler
68 # So set mpiFamily to first found in list below
69 set mpiList {intelmpi impi intel intelmpi-mt impi-mt intel-mp}
70 set mpiFamily [ FirstChildModuleInList $mpiList ]
71 }
72 }
73
74 if { $mpiFamily eq {} } {
75 # No MPI lib was explicitly loaded, and if intel compiler was loaded,
76 # did not find a subdir matching intelmpi or one of its variants
77 # Looks for a "nompi" dir if $nompiFlag is set
78 if { $nompiFlag } {
79 if [ ChildModuleExists nompi ] {
80 # nompi subdir exists, default to it
81 module-version $baseComponent/nompi default
82 set _did_default true
83 }
84 }
85 } else {
86 # Either MPI lib was explicitly loaded, or implied intelmpi
87 # Default to the subdir named after MPI family, if it exists
88 if [ ChildModuleExists $mpiFamily ] {
89 module-version $baseComponent/$mpiFamily default
90 set _did_default true
91 }
92 }