diff --git a/Pmodules/modulecmd.bash.in b/Pmodules/modulecmd.bash.in index e448d9e..67429ec 100755 --- a/Pmodules/modulecmd.bash.in +++ b/Pmodules/modulecmd.bash.in @@ -15,10 +15,8 @@ declare -r libdir="${prefix}/lib" declare -r libexecdir="${prefix}/libexec" declare -r base64="${sbindir}/base64" -#declare -r getopt="${sbindir}/getopt" declare -r mktemp="${sbindir}/mktemp" declare -r sort="${sbindir}/sort" -#declare -r tail="${sbindir}/tail" source "${libdir}/libstd.bash" source "${libdir}/libpmodules.bash" @@ -79,7 +77,7 @@ pbuild::save_env() { pbuild::export_env ${shell} PMODULES_ENV } -trap 'pbuild::save_env ${g_shell} Groups GroupDepths UsedReleases PMODULES_DEFAULT_GROUPS PMODULES_DEFINED_RELEASES PMODULES_DEFAULT_RELEASES' EXIT +trap 'pbuild::save_env ${g_shell} Groups GroupDepths UsedReleases UsedArchs PMODULES_DEFAULT_GROUPS PMODULES_DEFINED_RELEASES PMODULES_DEFAULT_RELEASES' EXIT print_version() { echo " @@ -651,7 +649,6 @@ subcommand_load() { # # Notes: # The variable 'release' in function 'subcommand_load()' will be set. - # The variable 'm' in function 'subcommand_load()' may be set. # is_available() { local m=$1 @@ -800,11 +797,20 @@ subcommand_load() { std::die 3 "${CMD} load: illegal release name." std::append_path UsedReleases "${release}" fi - fi - if ! is_available "${m}"; then - std::info "${CMD} load: module unavailable -- ${m}" - [[ ${verbosity_lvl} == 'verbose' ]] && output_load_hints - std::die 3 "" + fi + local use_arch='no' + for arch in "${UsedArchs[@]}"; do + if is_available "${m}_${arch}"; then + m="${m}_${arch}" + use_arch='yes' + fi + done + if [[ "${use_arch}" = 'no' ]]; then + if ! is_available "${m}"; then + std::info "${CMD} load: module unavailable -- ${m}" + [[ ${verbosity_lvl} == 'verbose' ]] && output_load_hints + std::die 3 "" + fi fi if [[ ":${LOADEDMODULES}:" =~ ":${m}:" ]]; then std::die 3 "${CMD} load: module conflicts with already loaded module -- ${m}" @@ -1172,6 +1178,11 @@ subcommand_use() { fi done + std::info "\nUsed architecures:" + for arch in "${UsedArchs//:/ }"; do + std::info "\t${arch}" + done + std::info "\nAdditonal directories in MODULEPATH:" let n=0 for (( i=0; i<${#modulepath[@]}; i++)); do @@ -1208,6 +1219,8 @@ subcommand_use() { if is_release "${arg}"; then # releases are always *appended* std::append_path UsedReleases "${arg}" + elif [[ "${arg}" =~ "arch=" ]]; then + std::append_path UsedArchs "${arg/arch=}" elif [[ ! ${arg} =~ */* ]] && [[ -d ${modulefiles_dir} ]]; then if [[ -z "${GroupDepths[$arg]}" ]]; then # not yet cached group @@ -1295,6 +1308,8 @@ subcommand_unuse() { local modulefiles_dir="${PMODULES_ROOT}/${arg}/${PMODULES_MODULEFILES_DIR}" if is_release "${arg}"; then std::remove_path UsedReleases "${arg}" + elif [[ "${arg}" =~ "arch=" ]]; then + std::remove_path UsedArchs "${arg/arch=}" elif [[ ! ${arg} =~ */* ]] && [[ -d ${modulefiles_dir} ]]; then if (( ${GroupDepths[$arg]} != 0 )); then std::die 3 "${CMD} ${FUNCNAME[0]##*_}: cannot remove group ${arg} from module path" @@ -1399,6 +1414,7 @@ pmodules_init() { declare -ag Groups='()' declare -Ag GroupDepths='()' declare -g UsedReleases='' + declare -g UsedArchs=() for r in ${PMODULES_DEFAULT_RELEASES//:/ }; do std::append_path UsedReleases "${r}" done