Debian Codegraph @

doc/example/compiler-etc-dependencies/tcllib/LoadedMpiMatches.tcl

raw
1 # =========================================================
2 # Author: Tom Payerle <[email protected]>
3
4 #--------------------------------------------------------------------
5 # LoadedMpiMatches:
6 #
7 # Takes the tag of the desired MPI library $wanted (in form of FAMILY/VERSION)
8 # Checks if any MPI is loaded, and will throw error if one is
9 # loaded and it does not match $wanted.
10 # If MPIs match, it will prereq the MPI lib if $requireIt set
11 # If no MPI is loaded, will load if optional boolean parameter
12 # $loadIt is set (default unset), and prereq if $requireIt is set, and
13 # then return.
14 # Option parameters:
15 # requireIt: boolean, default false. If set, will prereq $wanted
16 # loadIt: boolean, default false. If set, load $wanted
17 # if no MPI is already loaded
18 # noLoadIntel: boolean, passed to RequireMPI. If set,
19 # will not attempt to load intelmpi variants if compiler is intel
20 # forceNoMpi: boolean, default false. If set and $wanted is 'nompi',
21 # insist that no MPI module is loaded
22 # modTag: string, defaults go [module-info specified]. Used in error messages
23 proc LoadedMpiMatches { wanted {requireIt 0} { loadIt 0 } { noLoadIntel 0 }
24 { forceNoMpi 0 } {modTag {} } } {
25 # Default modTag
26 if { $modTag eq {} } { set modTag [ module-info specified ] }
27 # If no MPI given in $wanted, just return
28 if { $wanted eq {} } { return }
29
30 # Get loaded MPI, no defaulting to intelmpi
31 set loaded [ GetLoadedMPI 0 ]
32
33 # If wanted is nompi, no need to do anything unless forceNoMpi set
34 if { $wanted eq {nompi} } {
35 if { $forceNoMpi } {
36 # Complain if any MPI loaded
37 if { $loaded ne {} } {
38 PrintLoadError "MPI Mismatch
39 You have an MPI library loaded ($loaded), but package $modTag
40 really insists that no MPI library be loaded.
41
42 Please unload the MPI library and try again."
43 }
44 }
45 return
46 }
47
48 # If no MPI is loaded, then load it if $loadIt (this is valid even
49 # in edge cases of nompi or intelmpi), prereq it if $requireIt,
50 # and return
51 if { $loaded eq {} } {
52 if { $loadIt } {
53 RequireMPI $wanted $noLoadIntel
54 if { $requireIt } { prereq $wanted }
55 }
56 return
57 }
58
59 # Have a loaded MPI, split into family and version
60 set tmpLoaded [ GetPackageFamilyVersion $loaded ]
61 set loadedFam [ lindex $tmpLoaded 0 ]
62 set loadedVer [ lindex $tmpLoaded 1 ]
63
64 # Split wanted into family and version
65 set tmpWanted [ split $wanted / ]
66 set wantedLen [ llength $tmpWanted ]
67 #Nothing to do if no components to wanted
68 if { $wantedLen < 1 } { return }
69 set wantedFam [ lindex $tmpWanted 0 ]
70
71 # Ensure families match
72 if { $loadedFam ne $wantedFam } {
73 PrintLoadError "MPI Mismatch
74
75 Package $modTag does not appear to be built for currently
76 loaded MPI library $loaded."
77 }
78
79 # OK, families match
80 # If no version specified in $wanted, we are basically done
81 if { $wantedLen < 2 } {
82 if { $requireIt } { prereq $wanted }
83 return
84 }
85
86 # Ensure versions match
87 set wantedVer [ lindex $tmpWanted 1 ]
88 if { $loadedVer eq $wantedVer } {
89 if { $requireIt } { prereq $wanted }
90 return
91 }
92 # Versions don't match
93 PrintLoadError "MPI Mismatch
94
95 Package $modTag does not appear to be built for currently
96 loaded MPI library $loaded."
97 }