diff --git a/conf/real-from-ideal/proj.yaml b/conf/real-from-ideal/proj.yaml index 01eec3507c0340fa9ed6afb3ea76e81123a84986..360611ebfa66c22215155bd4f63d12ba84a5271f 100644 --- a/conf/real-from-ideal/proj.yaml +++ b/conf/real-from-ideal/proj.yaml @@ -1,10 +1,17 @@ spack: - url: git@gitlab.physik.uni-muenchen.de:LDAP_rbg/spack.git - branch: lmu/ubuntu20.04-icon - compiler: gcc@11.3.0 + #url: git@gitlab.physik.uni-muenchen.de:LDAP_rbg/spack.git + #branch: lmu/ubuntu20.04-icon + #compiler: gcc@11.3.0 + url: https://github.com/spack/spack.git + branch: develop + compiler: gcc@12.2.0 + root: %HPCROOTDIR%/spack # path to a spack install, will be cloned with git if not present + user_cache_path: %HPCROOTDIR%/spack_user_cache_path # spack puts data here when bootstrapping, leave empty to use home folder + disable_local_config: true # if false, spack install into home folder icon: - version: 2.6.5-nwp0 + spack_cmd: openmpi%${SPACK_COMPILER}+pmi+legacylaunchers schedulers=slurm fabrics=ucx ucx%${SPACK_COMPILER}+dc+dm+ib_hw_tm+mlx5_dv+rc+rdmacm+thread_multiple+ud+verbs ^gettext@0.20.2%${SPACK_COMPILER} + version: master python_environment: # Name of the virtual environment in the remote platform experiment folder diff --git a/platforms/common/spack_utils.sh b/platforms/common/spack_utils.sh index 0650e618d850d432bd6f49962c5880d9807fb741..4c4b25167cffb5216fd838061c7fc68e872e540a 100644 --- a/platforms/common/spack_utils.sh +++ b/platforms/common/spack_utils.sh @@ -1,27 +1,39 @@ function spack_env() { -export SPACK_SETUP_ENV=spack/share/spack/setup-env.sh -export SPACK_VENV=spack_icon_env -export SPACK_USER_CACHE_PATH=${WORKDIR}/SPACK_USER_CACHE_PATH -export SPACK_DISABLE_LOCAL_CONFIG=true +export SPACK_URL=%spack.url% +export SPACK_BRANCH=%spack.branch% +export SPACK_ROOT=%spack.root% +export SPACK_COMPILER=%spack.compiler% +export SPACK_DISABLE_LOCAL_CONFIG=%spack.disable_local_config% + +if [ ! -z "%spack.user_cache_path%" ]; then + echo "setting SPACK_USER_CACHE_PATH=%spack.user_cache_path%" + export SPACK_USER_CACHE_PATH=%spack.user_cache_path% +fi + +export SPACK_SETUP_ENV=$SPACK_ROOT/share/spack/setup-env.sh } function install_spack() { spack_env -#TODO: Would be good to enable the re-utilization of existing spack packages (via packages.yaml or upstreams.yaml) -if [ ! -f ${SPACK_SETUP_ENV} ]; then - git clone ${SPACK_URL} -b ${SPACK_BRANCH} +if [ ! -f ${SPACK_ROOT} ]; then + git clone ${SPACK_URL} -b ${SPACK_BRANCH} ${SPACK_ROOT} fi . ${SPACK_SETUP_ENV} -spack env create $SPACK_VENV -spack env activate -p $SPACK_VENV -spack compiler find + +if [[ $(spack compiler info ${SPACK_COMPILER}) ]]; then + echo "Found Compiler $(spack compiler info ${SPACK_COMPILER})" +else + echo "could not find compiler, will now try to install it... this may take a while" + spack install ${SPACK_COMPILER} + spack compiler add $(spack location --install-dir $SPACK_COMPILER) +fi } function load_spack() { spack_env -if [ ! -f ${SPACK_SETUP_ENV} ]; then install_spack; fi +if [ ! -f ${SPACK_ROOT} ]; then install_spack; fi . ${SPACK_SETUP_ENV} -spack env activate -p $SPACK_VENV } + diff --git a/templates/common/build_icon.sh b/templates/common/build_icon.sh index 29442e138ca163b608b9fd294d2c414a036ada42..113848083516c892eb94f7b95f4bb342b50fcf28 100644 --- a/templates/common/build_icon.sh +++ b/templates/common/build_icon.sh @@ -1,10 +1,7 @@ # Get some variables provided by autosubmit. # TODO: What do we do to ensure that these variables are defined in the proj file? WORKDIR=%HPCROOTDIR% -ICON_VERSION=%ICON_VERSION% -SPACK_URL=%spack.url% -SPACK_BRANCH=%spack.branch% -SPACK_COMPILER=%spack.compiler% +ICON_VERSION=%icon.version% # If the workdir directory does not exist create it if [ ! -d ${WORKDIR} ]; then @@ -17,27 +14,12 @@ cd ${WORKDIR} . ${WORKDIR}/proj/platforms/common/spack_utils.sh load_spack -if [ $( - spack find icon-nwp@${ICON_VERSION} &>/dev/null - echo $? -) -ne 0 ]; then - echo "Installing icon-nwp@${ICON_VERSION}." - - if [[ $(spack compiler info ${SPACK_COMPILER}) ]]; then - echo "Found Compiler" - else - echo "could not find compiler, try to install it... this may take a while" - spack add ${SPACK_COMPILER} - spack install - spack compiler add $(spack location --install-dir $SPACK_COMPILER) - fi - - spack add ucx%${SPACK_COMPILER}+dc+dm+ib_hw_tm+mlx5_dv+rc+rdmacm+thread_multiple+ud+verbs~cuda - spack add openmpi%${SPACK_COMPILER}+pmi+legacylaunchers~cuda schedulers=slurm fabrics=ucx - spack add icon-nwp@${ICON_VERSION}%${SPACK_COMPILER} ^openmpi%${SPACK_COMPILER} - spack install -else - echo "icon-nwp@${ICON_VERSION} already installed!" +SPACK_BUILD_ICON=%icon.spack_cmd% +if [ ! -z $SPACK_BUILD_ICON ]; then + echo "Installing ICON with spack!" + echo "cmd=$SPACK_BUILD_ICON" + spack install $SPACK_BUILD_ICON + spack load $SPACK_BUILD_ICON fi # Need to get ECCODES DWD definitions: