| 1 |
#%Module |
| 2 |
# Choose MPI version |
| 3 |
# |
| 4 |
# This check if any MPI lib was previously "module loaded" |
| 5 |
# |
| 6 |
# If an MPI library was loaded, and the family of loaded MPI lib matches |
| 7 |
# the name of the parent dir for this .modulerc, and there is a subdir |
| 8 |
# of that directory matching the MPI version, then we default to that |
| 9 |
# subdir. |
| 10 |
# |
| 11 |
# If no MPI library was previously module loaded, or the loaded MPI family |
| 12 |
# does not match the name of the parent directory, or no subdir matching |
| 13 |
# the MPI version is found, then we just return w/out defaulting. |
| 14 |
# The modulecmd will then default according to its own rules, and it is |
| 15 |
# up to the resulting modulefile to either load the appropriate MPI library |
| 16 |
# or abort/complain about an MPI mismatch as appropriate. |
| 17 |
# |
| 18 |
# NOTE: no special handling is needed for intelmpi, as we assume that if |
| 19 |
# intelmpi is selected because the intel compiler was loaded, then we |
| 20 |
# are to use the intelmpi that shipped with the compiler suite, and so |
| 21 |
# there is no needed for additional versioning of the intelmpi beneath |
| 22 |
# the intelmpi subdir. If intelmpi is being used with a non-intel compiler, |
| 23 |
# then it is assumed intelmpi was explicitly loaded. |
| 24 |
# |
| 25 |
# Usage: |
| 26 |
# In most cases, can simply symlink .modulerc to this file |
| 27 |
# |
| 28 |
# In more complicated cases, .modulerc can source this file, and can |
| 29 |
# then test the variable _did_default, which will be true if we set |
| 30 |
# a default for modules for the next level, or false otherwise (in which |
| 31 |
# case your .modulerc can set one) |
| 32 |
|
| 33 |
# Source some required Tcl procedures here. Hack for cookbook |
| 34 |
# making use of environment variable for location. |
| 35 |
# In production, this should ideally be in a site config file. |
| 36 |
# At minimum, hardcode the path |
| 37 |
set rootdir $::env(MOD_GIT_ROOTDIR) |
| 38 |
set tcllibdir $rootdir/doc/example/compiler-etc-dependencies/tcllib |
| 39 |
source $tcllibdir/common_utilities.tcl |
| 40 |
|
| 41 |
# _did_default will be true if we actually default something |
| 42 |
set _did_default false |
| 43 |
|
| 44 |
set moduledir [file dirname $ModulesCurrentModulefile] |
| 45 |
set parentDir [ file tail $moduledir ] |
| 46 |
|
| 47 |
# Get the currently loaded compiler, w/out defaulting |
| 48 |
set fullMpiTag [ GetLoadedMPI 0 ] |
| 49 |
|
| 50 |
if { $fullMpiTag ne {} } { |
| 51 |
# We have an MPI module loaded |
| 52 |
set tmpMpiTag [ GetPackageFamilyVersion $fullMpiTag ] |
| 53 |
set mpiFamily [ lindex $tmpMpiTag 0 ] |
| 54 |
set mpiVersion [ lindex $tmpMpiTag 1 ] |
| 55 |
|
| 56 |
# Canonicalize intelmpi variants in parentDir and mpiFamily for comparison |
| 57 |
set intelList "intelmpi impi intel intelmpi-mt impi-mt intel-mt" |
| 58 |
set tmpMpiFamily $mpiFamily |
| 59 |
if { [lsearch $intelList $tmpMpiFamily] > -1 } { |
| 60 |
set tmpMpiFamily intelmpi |
| 61 |
} |
| 62 |
set tmpParentDir $parentDir |
| 63 |
if { [lsearch $intelList $tmpParentDir] > -1 } { |
| 64 |
set tmpParentDir intelmpi |
| 65 |
} |
| 66 |
|
| 67 |
if { $tmpParentDir eq $tmpMpiFamily } { |
| 68 |
# The loaded MPI lib family name matches parentDir |
| 69 |
# So see if have subdir matching version, and if so, default it |
| 70 |
if { $mpiVersion ne {} } { |
| 71 |
if [ ChildModuleExists $mpiVersion ] { |
| 72 |
module-version $mpiFamily/$mpiVersion default |
| 73 |
set _did_default true |
| 74 |
} |
| 75 |
} |
| 76 |
} |
| 77 |
} |