From e27edd0ee7ed6834078037eb44360af4a9e6bc39 Mon Sep 17 00:00:00 2001
From: "Takumi.Matsunobu" <Takumi.Matsunobu@physik.uni-muenchen.de>
Date: Mon, 25 Sep 2023 16:34:52 +0200
Subject: [PATCH] bier

---
 spack_repo/packages/icon-nwp/package.py           |  4 ++--
 templates/real-from-d2-ana/build_env.sh           | 10 ++++++++++
 templates/real-from-d2-ana/prepare_date_remote.sh |  4 ++--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/spack_repo/packages/icon-nwp/package.py b/spack_repo/packages/icon-nwp/package.py
index 95de07b..4df813b 100644
--- a/spack_repo/packages/icon-nwp/package.py
+++ b/spack_repo/packages/icon-nwp/package.py
@@ -92,9 +92,9 @@ class IconNwp(Package):
                 url = "{}://{}:{}@{}/{}".format(parsed.scheme, user, password, parsed.netloc, parsed.path)
 
         if "+lmu" in self.spec:
-            self.fetcher[0].url = self.git = "https://gitlab.physik.uni-muenchen.de/LDAP_w2w-b3/icon.git"
+            self.fetcher.url = self.git = "https://gitlab.physik.uni-muenchen.de/LDAP_w2w-b3/icon.git"
         else:
-            self.fetcher[0].url = self.git = url
+            self.fetcher.url = self.git = url
 
         super(IconNwp, self).do_fetch(mirror_only)
 
diff --git a/templates/real-from-d2-ana/build_env.sh b/templates/real-from-d2-ana/build_env.sh
index cffbf36..9d7f3f4 100644
--- a/templates/real-from-d2-ana/build_env.sh
+++ b/templates/real-from-d2-ana/build_env.sh
@@ -55,3 +55,13 @@ if [ ! -f "${definitions_tar_file}" ]; then
   # Create a file containing the environment variable that needs to be set in order to use DWD's definitions:
   echo "export ECCODES_DEFINITION_PATH=${WORKDIR}/definitions.edzw-${eccodes_version}-1" >eccodes_defs.env
 fi
+
+
+# Build dwd-icon-tools
+SPACK_BUILD_ECCODES="%ECCODES.BUILD_CMD%" #"eccodes %%SPACK.COMPILER%target=x86_64_v2"
+
+#if [ "${SPACK_LOAD_ECCODES}" == "build_cmd" ]; then SPACK_LOAD_DWDICONTOOLS=${SPACK_BUILD_DWDICONTOOLS}; fi
+if [ ! -z "$SPACK_BUILD_ECCODES" ]; then
+  spack install --reuse $SPACK_BUILD_ECCODES
+  spack load --first ${SPACK_BUILD_ECCODES}
+fi
diff --git a/templates/real-from-d2-ana/prepare_date_remote.sh b/templates/real-from-d2-ana/prepare_date_remote.sh
index a8faf1a..9514c4b 100644
--- a/templates/real-from-d2-ana/prepare_date_remote.sh
+++ b/templates/real-from-d2-ana/prepare_date_remote.sh
@@ -16,8 +16,8 @@ if [ "${IC_DATA_IS_LOCAL}" != "True" ]; then
   load_spack "%spack.init%" "%spack.root%" "%spack.url%" "%spack.branch%" "%spack.externals%" "%spack.compiler%" "%spack.disable_local_config%" "%spack.user_cache_path%" "%spack.user_config_path%" "%spack.upstreams%"
 
   # Load icon module
-  spack load --first eccodes
-  spack load --first dwd-icon-tools
+  spack load --first %ECCODES.BUILD_CMD%
+  spack load --first  %ECCODES.LOAD_CMD%
 
   # Set environment variable for eccodes-dwd definitions:
   source ${WORKDIR}/eccodes_defs.env
-- 
GitLab