Skip to content

Set $SYSTEMNAME in machine-specific environment file #73

Description

@kvrigor

Address this TODO item in default.2025.env:

# TODO: Deducing which environment file maps to a machine relies on
# partial string match, which makes surgically-precise SYSTEMNAME
# introspection unnecessary. A substring match allows for simple
# and robust solution, e.g. `MACHINE=$(hostname)` already works 99%
# of the time (other 1% comes from intentionally obfuscated hostnames)
#
# HPC admins know best so perhaps it's better to let them handle
# SYSTEMNAME setting on their respective environment file. Saving the
# machine name to a dummy variable is sufficient.
#
# Set SYSTEMNAME if not yet set
if [ -z "${SYSTEMNAME}" ]; then
if [ $(command -v sinfo) ]; then
export SYSTEMNAME=$(scontrol show config | grep ClusterName | awk -F= '{ print $2 }' | xargs)
else
export SYSTEMNAME=$(hostname | awk -F. '{ for(i=1;i<=NF;i++) if(!match($i, /[0-9]$/)) { print $i; break }; if(i==NF+1) { print $1 } }')
fi
fi

# Map machine to environment file by detecting a
# unique signature from the machine name.
known_machine="true"
env_dir=$(dirname $(realpath ${BASH_SOURCE:-$0}))
if [[ $SYSTEMNAME == *"jedi"* || $SYSTEMNAME == *"jupiter"* ]]; then
export TSMP2_ENV_FILE=${env_dir}/jsc.2025.gnu.openmpi
elif [[ $SYSTEMNAME == *"jureca"* || $SYSTEMNAME == *"juwels"* || $SYSTEMNAME == *"jusuf"* ]]; then
export TSMP2_ENV_FILE=${env_dir}/jsc.2025.intel.psmpi
elif [[ $SYSTEMNAME == *"marvin"* ]]; then
export TSMP2_ENV_FILE=${env_dir}/uni-bonn.gnu.openmpi
elif [[ $SYSTEMNAME == *"UBUNTU"* ]]; then
export TSMP2_ENV_FILE=${env_dir}/ubuntu.gnu.openmpi
else
echo "WARNING: Unknown default environment for machine '$(hostname)'"
known_machine="false"
fi

Activity

  1. mvhulten commented on Nov 26, 2025

    @mvhulten
    Contributor

    I think this is long addressed as best as possible in env/default.2025.env (22) (and below that line overwritten—above code—for certainty) and this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions