From b304e74887ac66b7cb53b695bc4f6b928ffae15a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Oriol=20Tint=C3=B3?= <oriol.tinto@lmu.de>
Date: Tue, 18 Jul 2023 11:58:00 +0200
Subject: [PATCH] Avoid renaming expid. Use autosubmit expid -repo instead of
 rewriting the minimal.yml file.

---
 examples/example_utils.sh | 45 ++++++---------------------------------
 1 file changed, 7 insertions(+), 38 deletions(-)

diff --git a/examples/example_utils.sh b/examples/example_utils.sh
index f208dfb..7aed35c 100644
--- a/examples/example_utils.sh
+++ b/examples/example_utils.sh
@@ -18,7 +18,9 @@ function run_autoicon_example() {
   configure_and_install_autosubmit
 
   # Set up project
-  setup_project "$EXPID"
+  EXPID=$( setup_project )
+
+  echo "NewEXPID=${EXPID}"
 
   # Create and run the experiment
   create_and_run_experiment "$EXPID"
@@ -66,49 +68,15 @@ 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"}
 
   # If experiment directory doesn't exist, create it and set up the experiment
-  if [ ! -e autosubmit/$EXPID/ ]; then
-    mkdir -p autosubmit/$EXPID/
-    autosubmit expid -min -H lmu -d myiconsim -repo $PROJECT_ORIGIN -b $PROJECT_BRANCH -conf "conf/${ICON_CASE}.yml"&> >(tee autosubmit/$EXPID/log.autosubmit.expid)
-    AUTOID=$(grep Experiment autosubmit/$EXPID/log.autosubmit.expid | awk '{print $2}')
-    mv -v autosubmit/$AUTOID/* autosubmit/$EXPID
-    rmdir -v autosubmit/$AUTOID
-  fi
-
-#  # Create and write the minimal config file
-#  cat >autosubmit/$EXPID/conf/minimal.yml <<EOF
-#ICON_CASE: "${ICON_CASE}"
-#
-#CONFIG:
-#  AUTOSUBMIT_VERSION: "$AUTOSUBMIT_VERSION"
-#  TOTALJOBS: 20
-#  MAXWAITINGJOBS: 20
-#  RETRIALS: 0
-#DEFAULT:
-#  EXPID: "$EXPID"
-#  HPCARCH: "${PLATFORM}" # use LMU to run on cluster
-#  CUSTOM_CONFIG:
-#    PRE:
-#      - "%PROJDIR%/conf/common"
-#      - "%PROJDIR%/conf/%ICON_CASE%"
-#
-#PROJECT:
-#  PROJECT_TYPE: "git"
-#  PROJECT_DESTINATION: "autoicon"
-#GIT:
-#  PROJECT_ORIGIN: "$PROJECT_ORIGIN"
-#  PROJECT_BRANCH: "$PROJECT_BRANCH"
-#  PROJECT_COMMIT: ""
-#  PROJECT_SUBMODULES: ""
-#  FETCH_SINGLE_BRANCH: True
-#EOF
+  autosubmit expid -min -H LOCAL -d myiconsim -repo $PROJECT_ORIGIN -b $PROJECT_BRANCH -conf "conf/${ICON_CASE}.yml" &> autosubmit/log.autosubmit.expid
+  EXPID=$(grep "Experiment.*created" autosubmit/log.autosubmit.expid | awk '{print $2}')
 
   # Create and write the additional config file
-  cat >autosubmit/${EXPID}/conf/01_myconf.yml <<EOF
+  cat > autosubmit/${EXPID}/conf/01_myconf.yml <<EOF
 spack:
   init: "" # command to load spack environment, e.g. module load spack, use spack/setup-env.sh if empty
   url: https://github.com/spack/spack.git # url to download spack if necessary
@@ -152,6 +120,7 @@ $EXTRA_NAMELIST
 EOF
   fi
 
+echo "${EXPID}"
 }
 
 function create_and_run_experiment() {
-- 
GitLab