| 1 |
# ========================================================= |
| 2 |
# Author: Tom Payerle <[email protected]> |
| 3 |
|
| 4 |
#-------------------------------------------------------------------- |
| 5 |
# GetPackageFamilyVersion |
| 6 |
# |
| 7 |
# Given the fully qualified spec for a modulefile, returns a list |
| 8 |
# with the package family name and version. |
| 9 |
# |
| 10 |
# E.g., for foo/1.1/gcc/8.2.0/openmpi/3.1 would return {foo 1.1} |
| 11 |
# But also handles stuff like foo/gcc/8.2.0/openmpi/3.1/1.1 (returning |
| 12 |
# again {foo 1.1}) |
| 13 |
proc GetPackageFamilyVersion { tag } { |
| 14 |
# Return empty list if given empty tag |
| 15 |
if { $tag eq {} } { return {} } |
| 16 |
|
| 17 |
# Split tag into components |
| 18 |
set components [ split $tag / ] |
| 19 |
set compLen [ llength $components ] |
| 20 |
if { $compLen < 1 } { return {} } |
| 21 |
|
| 22 |
# Family should always be first |
| 23 |
set family [ lindex $components 0 ] |
| 24 |
if { $compLen < 2 } { return $family } |
| 25 |
|
| 26 |
# First guess, version immediately follows family |
| 27 |
set version [ lindex $components 1 ] |
| 28 |
# Check if it matches known non-version stuff following family |
| 29 |
# Compilers, MPIs, other things branch on |
| 30 |
set nonVers { gnu gcc pgi intel openmpi ompi intelmpi impi mvapich |
| 31 |
mvapich2 avx avx2 sse4.1 sse3 python perl hdf hdf4 hdf5 } |
| 32 |
set tmp [ lsearch $nonVers $version ] |
| 33 |
if { $tmp > -1 } { |
| 34 |
# The component immediately following family was NOT a version |
| 35 |
# Use last component as version |
| 36 |
set version [ lindex $components end ] |
| 37 |
} |
| 38 |
return "$family $version" |
| 39 |
} |