From 9c547df25ad0536dde235fbdfcbb2570d52379b2 Mon Sep 17 00:00:00 2001
From: schroeder5 <s.schroeder@fz-juelich.de>
Date: Tue, 18 Mar 2025 15:11:57 +0000
Subject: [PATCH] latest version of scripts for starting EURAD-IM runs

---
 utils/start_destine_demonstrator.sh | 34 +++++---------------
 utils/start_one_run.sh              | 48 +++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 27 deletions(-)
 create mode 100644 utils/start_one_run.sh

diff --git a/utils/start_destine_demonstrator.sh b/utils/start_destine_demonstrator.sh
index 597c1b4..705f18c 100644
--- a/utils/start_destine_demonstrator.sh
+++ b/utils/start_destine_demonstrator.sh
@@ -1,35 +1,15 @@
 #!/bin/bash
 
-## TODO: "configuration.general" should be an argument to suite_config.py
-## (if two persons are setting up an experiment at the same time, using a constant file may cause an hazzard)
-
 #get setup from script arguments
 MODE=$1
 ENSEMBLE=$2
+STARTDATE=$3
+FC_HOURS=$4
 
-# set environment
-source /p/project/cjicg21/schroeder5/Destine_AQ/setenv.sh
-
-# adapt configuration to actual setup
-EXP_NAME=${MODE^^}
-cd /p/project/cjicg21/schroeder5/Destine_AQ/SCRIPTS/ECFLOW
-sed -i -e 's/MODE = "test3" #"destineaq"/MODE = \"'"${MODE}"'\"/' configuration.general
-sed -i -e 's/EXP_NAME = "TEST3" #"DestineAQ"/EXP_NAME = \"'"${EXP_NAME}"'\"/' configuration.general
+/p/project/cjicg21/destine-aq-service/Destine_AQ/start_one_run.sh ${MODE} ${ENSEMBLE} ${STARTDATE} ${FC_HOURS}
+# start base run, if an emission scenario run is chosen
 if [ "$ENSEMBLE" -ne "0" ]; then
-  sed -i -e 's/ensemble = false/ensemble = true/' configuration.general
-  sed -i -e 's/ensemble_size = 15/ensemble_size = 1/' configuration.general
-  sed -i -e 's/ensemble_member = \[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19\]/ensemble_member = \['"$ENSEMBLE"'\]/' configuration.general
+  # make sure not to overwrite files that are still in use from the previous command
+  /usr/bin/sleep 1
+  /p/project/cjicg21/destine-aq-service/Destine_AQ/start_one_run.sh B${MODE} 0 ${STARTDATE} ${FC_HOURS}
 fi
-sed -i -e 's/JWTEST/'"${EXP_NAME}"'/' start_ecflow.sh
-sed -i -e 's/destineaq/'"${MODE}"'/g' start_ecflow.sh
-python Airshed4.py
-
-# run the script
-./start_ecflow.sh
-
-# reset settings
-rm configuration.general
-ln -s configurations/configuration.JURECA-DC.destine.toml configuration.general
-sed -i -e 's/'"${EXP_NAME}"'/JWTEST/g' start_ecflow.sh
-sed -i -e 's/'"${MODE}"'/destineaq/g' start_ecflow.sh
-
diff --git a/utils/start_one_run.sh b/utils/start_one_run.sh
new file mode 100644
index 0000000..5ef0a5a
--- /dev/null
+++ b/utils/start_one_run.sh
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+## TODO: "configuration.general" should be an argument to suite_config.py
+## (if two persons are setting up an experiment at the same time, using a constant file may cause an hazzard)
+
+#get setup from script arguments
+MODE=$1
+ENSEMBLE=$2
+STARTDATE=$3
+FC_HOURS=$4
+
+cd /p/project/cjicg21/destine-aq-service/Destine_AQ
+# set environment
+source /p/project/cjicg21/destine-aq-service/Destine_AQ/setenv.sh
+
+# overwrite ECF_HOST and ECF_PORT for this special application!
+export ECF_HOST='jrlogin05.jureca'
+export ECF_PORT=4960
+
+# adapt configuration to actual setup
+EXP_NAME=${MODE^^}
+cd /p/project/cjicg21/destine-aq-service/Destine_AQ/SCRIPTS/ECFLOW
+mv configuration.general configuration.general_saved
+cp configuration.general_saved configuration.general
+sed -i -e 's/MODE = "destineaq"/MODE = \"'"${MODE}"'\"/' configuration.general
+sed -i -e 's/EXP_NAME = "DTdriven" #"DestineAQ"/EXP_NAME = \"'"${EXP_NAME}"'\"/' configuration.general
+if [ "$ENSEMBLE" -ne "0" ]; then
+  sed -i -e 's/ensemble = false/ensemble = true/' configuration.general
+  sed -i -e 's/ensemble_size = 15/ensemble_size = 1/' configuration.general
+  sed -i -e 's/ensemble_member = \[5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19\]/ensemble_member = \['"$ENSEMBLE"'\]/' configuration.general
+fi
+sed -i -e 's/startdate=2018-07-24/startdate = '"$STARTDATE"'/' configuration.general
+mv configuration.forecast configuration.forecast_saved
+cp configuration.forecast_saved configuration.forecast
+sed -i -e 's/fc_hours = 24/fc_hours = '"$FC_HOURS"'/' configuration.forecast
+python Airshed4.py
+
+# run the script
+# for some unknown reason the def filename needs to be in capital letters from now on (2024-03-01)
+ln -s ${MODE}.def ${EXP_NAME}.def
+./start_ecflow.sh
+
+# reset settings
+rm configuration.general*
+ln -s configurations/configuration.JURECA-DC.destine_de3.toml configuration.general
+rm configuration.forecast*
+ln -s configurations/configuration.forecast_de3.toml configuration.forecast
+
-- 
GitLab