From d6d58a52dfb833c1216ea3e108eb248c0b7f219a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de>
Date: Thu, 25 May 2023 10:44:03 +0200
Subject: [PATCH] Further simplification of the test cases.

---
 examples/01_real-from-ideal+psp.sh | 10 ++--------
 examples/01_real-from-ideal.sh     |  8 ++------
 examples/02_real-from-dwd-ana.sh   | 10 ++--------
 examples/example_utils.sh          | 30 +++++++++++++++++++++++-------
 4 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/examples/01_real-from-ideal+psp.sh b/examples/01_real-from-ideal+psp.sh
index 49e0d58..259a988 100755
--- a/examples/01_real-from-ideal+psp.sh
+++ b/examples/01_real-from-ideal+psp.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 #######################################################################################################################
 # Three variables are required to define the test case
+EXPID="rfipsp"
 ICON_CASE="real-from-ideal"
 ICON_VERSION="psp"
 EXTRA_NAMELIST=$(
@@ -30,11 +31,4 @@ source ${SCRIPT_DIR}/example_utils.sh
 # case: right now it can be real-from-ideal or real-from-dwd-ana
 # ICON_VERSION: it can be master, psp, plexrt or a specific version like 2.6.5-nwp0 (the latest at that moment)
 # EXTRA_NAMELIST: In case we want to provide extra parameters we can use it
-setup_autoicon_example "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}"
-
-# Create and run experiment
-autosubmit create ${EXPID} -np
-autosubmit run ${EXPID}
-
-# Check that all jobs finished correctly
-[ ! -s autosubmit/${EXPID}/tmp/ASLOGS/jobs_failed_status.log ] || exit 1
+run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}"
diff --git a/examples/01_real-from-ideal.sh b/examples/01_real-from-ideal.sh
index 4839ba7..85d0cc6 100755
--- a/examples/01_real-from-ideal.sh
+++ b/examples/01_real-from-ideal.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 #######################################################################################################################
 # Three variables are required to define the test case
+EXPID="rfi"
 ICON_CASE="real-from-ideal"
 ICON_VERSION="2.6.5-nwp0"
 EXTRA_NAMELIST=""
@@ -19,11 +20,6 @@ source ${SCRIPT_DIR}/example_utils.sh
 # case: right now it can be real-from-ideal or real-from-dwd-ana
 # ICON_VERSION: it can be master, psp, plexrt or a specific version like 2.6.5-nwp0 (the latest at that moment)
 # EXTRA_NAMELIST: In case we want to provide extra parameters we can use it
-setup_autoicon_example "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}"
+run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}"
 
-# Create and run experiment
-autosubmit create ${EXPID} -np
-autosubmit run ${EXPID}
 
-# Check that all jobs finished correctly
-[ ! -s autosubmit/${EXPID}/tmp/ASLOGS/jobs_failed_status.log ] || exit 1
diff --git a/examples/02_real-from-dwd-ana.sh b/examples/02_real-from-dwd-ana.sh
index fd5fbaf..7e3796a 100755
--- a/examples/02_real-from-dwd-ana.sh
+++ b/examples/02_real-from-dwd-ana.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 #######################################################################################################################
 # Three variables are required to define the test case
+EXPID="rfda"
 ICON_CASE="real-from-dwd-ana"
 ICON_VERSION="2.6.5-nwp0"
 EXTRA_NAMELIST=""
@@ -19,11 +20,4 @@ source ${SCRIPT_DIR}/example_utils.sh
 # case: right now it can be real-from-ideal or real-from-dwd-ana
 # ICON_VERSION: it can be master, psp, plexrt or a specific version like 2.6.5-nwp0 (the latest at that moment)
 # EXTRA_NAMELIST: In case we want to provide extra parameters we can use it
-setup_autoicon_example "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}"
-
-# Create and run experiment
-autosubmit create ${EXPID} -np
-autosubmit run ${EXPID}
-
-# Check that all jobs finished correctly
-[ ! -s autosubmit/${EXPID}/tmp/ASLOGS/jobs_failed_status.log ] || exit 1
+run_autoicon_example "$EXPID" "$ICON_CASE" "$ICON_VERSION" "${EXTRA_NAMELIST}"
diff --git a/examples/example_utils.sh b/examples/example_utils.sh
index 411c607..1bb48de 100644
--- a/examples/example_utils.sh
+++ b/examples/example_utils.sh
@@ -1,9 +1,11 @@
 # setup_autoicon_example function that sets up an AutoSub environment for the ICON model
-function setup_autoicon_example() {
+function run_autoicon_example() {
   # Read the input parameters
-  local ICON_CASE=$1
-  local ICON_VERSION=$2
-  local EXTRA_NAMELIST=$3
+  local EXPID=$1
+  local ICON_CASE=$2
+  local ICON_VERSION=$3
+  local EXTRA_NAMELIST=$4
+
 
   # Setup environment
   setup_environment
@@ -12,7 +14,9 @@ function setup_autoicon_example() {
   configure_and_install_autosubmit
 
   # Set up project
-  setup_project
+  setup_project "$EXPID"
+
+  create_and_run_experiment "$EXPID"
 
 }
 
@@ -57,9 +61,9 @@ function configure_and_install_autosubmit() {
 }
 
 function setup_project() {
+  local EXPID=$1
   PROJECT_ORIGIN="https://gitlab.physik.uni-muenchen.de/w2w/autoicon.git"
   PROJECT_BRANCH="master"
-  EXPID=rfi001
 
   # If experiment directory doesn't exist, create it and set up the experiment
   if [ ! -e autosubmit/$EXPID/ ]; then
@@ -113,7 +117,6 @@ spack:
   upstreams: "/software/opt/focal/x86_64/spack/2023.02/spack/opt/spack"
 
 icon:
-  #build_cmd: "icon-nwp@%ICON.VERSION%% %SPACK.COMPILER%+debug+petsc target=x86_64_v2 ^openmpi+pmi+legacylaunchers schedulers=slurm fabrics=ucx ucx+dc+dm+ib_hw_tm+mlx5_dv+rc+rdmacm+thread_multiple+ud+verbs"
   build_cmd: "icon-nwp@%ICON.VERSION%% %SPACK.COMPILER%+debug~mpichecks target=x86_64_v2 source=dkrz_https"
   version: ${ICON_VERSION}
 
@@ -134,3 +137,16 @@ EOF
   fi
 
 }
+
+function create_and_run_experiment() {
+  local EXPID=$1
+  # Create and run experiment
+  autosubmit create ${EXPID} -np
+  autosubmit run ${EXPID}
+
+  # Check that all jobs finished correctly
+  [ ! -s autosubmit/${EXPID}/tmp/ASLOGS/jobs_failed_status.log ] || (
+    cat autosubmit/${EXPID}/tmp/ASLOGS/jobs_failed_status.log
+    exit 1
+  )
+}
-- 
GitLab