diff --git a/conf/common/build.yml b/conf/common/build.yml
index 4b95d6a09172555831a48e6f3c7c48f2abe6d2fb..d320758724e23eaa81706d080dbf6a1799b043a1 100644
--- a/conf/common/build.yml
+++ b/conf/common/build.yml
@@ -18,6 +18,7 @@ icon:
 python_environment:
   # Name of the virtual environment in the remote platform experiment folder
   folder_name: python_environment
+  python_version: "3.8:"   # In spack notation use x: to indicate at least x
   requirements:
     # Because there's an issue with numba, for now we need to keep a specific version of numpy
     - numpy==1.23
@@ -25,3 +26,5 @@ python_environment:
     # Just to try a library from a git repository.
     - git+https://gitlab.physik.uni-muenchen.de/Oriol.Tinto/otils.git
     - f90nml
+
+LOGIN: "LOGIN"
\ No newline at end of file
diff --git a/conf/real-from-ideal/jobs.yml b/conf/real-from-ideal/jobs.yml
index 9b2fc8944fdf013166ea17d2b8458706a510aebd..40deb2fd11ea6ffcbf3023540abc2593f299757a 100644
--- a/conf/real-from-ideal/jobs.yml
+++ b/conf/real-from-ideal/jobs.yml
@@ -79,14 +79,12 @@ JOBS:
     DEPENDENCIES: BUILD_ICON
     RUNNING: once
     WALLCLOCK: 00:10
-    PLATFORM: LOGIN
 
   PREPARE_IDEAL_DIRECTORY:
     FILE: templates/real-from-ideal/prepare_ideal_directory.sh
     DEPENDENCIES: PREPARE_EXPERIMENT
     RUNNING: date
     WALLCLOCK: 00:10
-    PLATFORM: LOGIN
 
   PREPARE_IDEAL_NAMELIST:
     FILE: templates/real-from-ideal/prepare_ideal_namelist.py
@@ -95,7 +93,6 @@ JOBS:
     WALLCLOCK: 00:10
     TYPE: python
     EXECUTABLE: "%HPCROOTDIR%/%python_environment.folder_name%/bin/python3"
-    PLATFORM: LOGIN
 
   RUN_IDEAL:
     FILE: templates/real-from-ideal/run_ideal.sh
@@ -125,7 +122,6 @@ JOBS:
     DEPENDENCIES: FG_ANA_FROM_IDEALIZED EXTPAR_FROM_IDEALIZED
     RUNNING: member
     WALLCLOCK: 01:00
-    PLATFORM: LOGIN
 
   PREPARE_CHUNK:
     FILE: templates/real-from-ideal/prepare_chunk.py
@@ -134,7 +130,6 @@ JOBS:
     RUNNING: chunk
     TYPE: python
     EXECUTABLE: "%HPCROOTDIR%/%python_environment.folder_name%/bin/python3"
-    PLATFORM: LOGIN
 
   RUN_ICON:
     FILE: templates/common/run_icon.sh
@@ -162,4 +157,3 @@ JOBS:
     DEPENDENCIES: TRANSFER
     WALLCLOCK: 00:10
     RUNNING: member
-    PLATFORM: LOGIN
diff --git a/templates/common/build_python_environment.sh b/templates/common/build_python_environment.sh
index 043dc546da789157b28573eae2d7f7939d9d1e4b..3220707802ca2229a9901cc2c8d302c2287a7e0f 100644
--- a/templates/common/build_python_environment.sh
+++ b/templates/common/build_python_environment.sh
@@ -2,41 +2,29 @@
 # 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%
-
-# If the workdir directory does not exist create it
-if [ ! -d ${WORKDIR} ]; then
-  mkdir -p ${WORKDIR}
-fi
+SPACK_URL=%SPACK.URL%
+SPACK_BRANCH=%SPACK.BRANCH%
+SPACK_COMPILER=%SPACK.COMPILER%
 
+PYTHON_VERSION=%PYTHON_ENVIRONMENT.PYTHON_VERSION%
 # Go to the working directory
 cd ${WORKDIR}
 
-# Check if experiment's spack installation already exists, if it doesn't, clone it.
-SPACK_ENV=spack/share/spack/setup-env.sh
-if [ ! -f ${SPACK_ENV} ]; then
-  echo "Spack folder not found!"
-  exit 1
-fi
+. ${WORKDIR}/proj/platforms/common/spack_utils.sh
+load_spack "%spack.init%" "%spack.root%" "%spack.url%" "%spack.branch%" "%spack.compiler%" "%spack.disable_local_config%" "%spack.user_cache_path%" "%spack.user_config_path%"
 
-# Setup the spack environment
-source ${SPACK_ENV}
 
 # Use spack to get a recent enough version of python3
-if [ $( spack find python@3.8: &>/dev/null
-  echo $?
-) -ne 0 ]; then
+if [ $(spack find python@${PYTHON_VERSION}: &>/dev/null ) ]; then
+  echo "python@${PYTHON_VERSION} already installed!"
+else
   echo "Installing a version of python3"
   # Compile openmpi with schedulers=slurm
-  spack install python@3.8:
-else
-  echo "python@3.8: already installed!"
+  spack install python@${PYTHON_VERSION}
 fi
 
 # Load the python module
-spack load python@3.8:
+spack load --first python@${PYTHON_VERSION}
 
 PYTHON_ENVIRONMENT_FOLDER=%python_environment.folder_name%
 
@@ -56,7 +44,7 @@ ln -sf $(which python3) ${WORKDIR}/python3
 requirements="%python_environment.requirements%"
 
 # Convert list with python format to a bash array
-requirements=($( echo ${requirements} | sed "s/'//g" | tr -d '[],'))
+requirements=($(echo ${requirements} | sed "s/'//g" | tr -d '[],'))
 
 #TODO: Shouldn't be necessary but it is for now to overcome an issue with a repetition of the requirements.
 # Use sort and uniq to get the unique elements
@@ -66,6 +54,6 @@ unique_requirements=($(printf "%s\n" "${requirements[@]}" | sort -u))
 echo "${unique_requirements[@]}"
 
 # Install requirements.
-for requirement in ${unique_requirements[@]} ; do
+for requirement in "${unique_requirements[@]}"; do
   python -m pip install ${requirement}
 done
diff --git a/templates/common/run_icon.sh b/templates/common/run_icon.sh
index 1a5fec30d901590072f9aa3135292dba299a6bfd..a1ceaf1b74c4279d8a5b87d8662ac0b82643b315 100644
--- a/templates/common/run_icon.sh
+++ b/templates/common/run_icon.sh
@@ -12,8 +12,9 @@ RUNDIR=${WORKDIR}/${STARTDATE}/${MEMBER}
 cd ${RUNDIR}
 
 # Activate spack
-SPACK_ENV=${WORKDIR}/spack/share/spack/setup-env.sh
-source ${SPACK_ENV}
+. ${WORKDIR}/proj/platforms/common/spack_utils.sh
+load_spack "%spack.init%" "%spack.root%" "%spack.url%" "%spack.branch%" "%spack.compiler%" "%spack.disable_local_config%" "%spack.user_cache_path%" "%spack.user_config_path%"
+
 # Load icon module
 spack load icon-nwp@%ICON_VERSION%
 
diff --git a/templates/real-from-dwd-ana/prepare_experiment.sh b/templates/real-from-dwd-ana/prepare_experiment.sh
index 5d9b03dcf54d7cb2c3e32780033d78d6ca64d265..677cc057226382c8bf54c896be1ad0803906882f 100644
--- a/templates/real-from-dwd-ana/prepare_experiment.sh
+++ b/templates/real-from-dwd-ana/prepare_experiment.sh
@@ -8,8 +8,8 @@ EXTERNAL_PARAMETERS_FILE=%simulation.external_parameters_filename%
 
 
 # Activate spack
-SPACK_ENV=${WORKDIR}/spack/share/spack/setup-env.sh
-source ${SPACK_ENV}
+. ${WORKDIR}/proj/platforms/common/spack_utils.sh
+load_spack "%spack.init%" "%spack.root%" "%spack.url%" "%spack.branch%" "%spack.compiler%" "%spack.disable_local_config%" "%spack.user_cache_path%" "%spack.user_config_path%"
 
 # Load icon module needed to retrieve some data
 spack load icon-nwp@%ICON_VERSION%
diff --git a/templates/real-from-ideal/prepare_experiment.sh b/templates/real-from-ideal/prepare_experiment.sh
index b25b40a9fa6eeca08222eb7fb8e40f15c7bf2901..d7f3791f9b976ae250fce203c14f7986e9ea923a 100644
--- a/templates/real-from-ideal/prepare_experiment.sh
+++ b/templates/real-from-ideal/prepare_experiment.sh
@@ -6,8 +6,8 @@ DYNAMICS_GRID_FILENAME=%simulation.dynamics_grid_filename%
 RADIATION_GRID_FILE=%simulation.radiation_grid_filename%
 
 # Activate spack
-SPACK_ENV=${WORKDIR}/spack/share/spack/setup-env.sh
-source ${SPACK_ENV}
+. ${WORKDIR}/proj/platforms/common/spack_utils.sh
+load_spack "%spack.init%" "%spack.root%" "%spack.url%" "%spack.branch%" "%spack.compiler%" "%spack.disable_local_config%" "%spack.user_cache_path%" "%spack.user_config_path%"
 
 # Load icon module needed to retrieve some data
 spack load icon-nwp@%ICON_VERSION%