From 0f6769e615e253e8c247cb9d08f40dcbe618eb0b Mon Sep 17 00:00:00 2001
From: Karl-Hermann Wieners <karl-hermann.wieners@mpimet.mpg.de>
Date: Tue, 14 Nov 2023 10:34:30 +0100
Subject: [PATCH] Import: adapt model start detection for inserts

---
 importexp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/importexp b/importexp
index b191b3c..7635582 100755
--- a/importexp
+++ b/importexp
@@ -94,14 +94,15 @@ do
     # 4. to handle external scripts, replace working dir with tmp dir
     # 5. to handle external scripts, replace ./ calls appropriately
     # 6. to handle external scripts, replace build and model dirs appropriately
-    # 7. use original model base for executable
+    # 7. ignore function make_and_change_to_experiment_dir
+    # 8. use original model base for executable
 
     if $IGNORE_ERRORS
     then
         REMOVE_ERROR_FLAG_SH='
 s:^(\s*)(set\s+-e\s*$|(set\s+-\w+)e):\1\3:
 s@^(\s*)check_error@\1: check_error@
-s:^(\s*)\$\{START\}:\1exit # ${START}:
+s:^(\s*)(\$\{START\}|srun):\1exit # \2:
 '
         REMOVE_ERROR_FLAG_PL='\s+-e\s*$|(\s+-\w+)e|'
     fi
@@ -127,7 +128,7 @@ done\
         s@^(\s*)(cat\s+\$thisscript)@\1: \2@
         2 i\
 cd '$WORK_DIR'
-        /^\s*(\$\{START\}|srun)/ i'"$SHOW_HERE_DOCS"'
+        /^\s*#.*start\s+experiment/i i'"$SHOW_HERE_DOCS"'
         s:^(\s*)(set\s+\+x\s*$|(set\s+\+\w+)x):\1\3:
         '"${REMOVE_ERROR_FLAG_SH-}"'
         s:^(\s*)SCRIPT_DIR=.*$:\1SCRIPT_DIR='$WORK_DIR':
@@ -139,6 +140,7 @@ cd '$WORK_DIR'
         '${SUBST_BUILD_DIR-}'
         '${SUBST_MODEL_DIR-}'
         '${SUBST_basedir-}'
+        s/^\s*make_and_change_to_experiment_dir/: &/
     ' "$RUN_SCRIPT" > $RUN_FILE
 
     # Get script shell without possible +x/-e settings
-- 
GitLab