From 533167016171b6981d76447c1f721566dfeec4ff Mon Sep 17 00:00:00 2001
From: Karl-Hermann Wieners <karl-hermann.wieners@mpimet.mpg.de>
Date: Tue, 9 Apr 2024 08:38:15 +0200
Subject: [PATCH] Tools: add importexp option to supply path to routine helper

---
 importexp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/importexp b/importexp
index a9f8ff4..46639d1 100755
--- a/importexp
+++ b/importexp
@@ -12,10 +12,11 @@ DEBUG=false
 RESTART=
 #% endhelp
 
-while getopts b:B:d:D:e:Ehis:t:c:r:x OPTOPT
+while getopts a:b:B:d:D:e:Ehis:t:c:r:x OPTOPT
 do
     case $OPTOPT in
         #% help
+        a) ADD_RUN_ROUTINES=$OPTARG ;;
         b) BUILD_SUBDIR=$OPTARG ;;
         B) BUILD_DIR=$OPTARG ;;
         d) DATA_BASE_DIR=$OPTARG ;;
@@ -110,6 +111,7 @@ s:^(\s*)(\$\{START\}|srun):\1exit # \2:
     [ "$OLD_BUILD_DIR" ] && SUBST_BUILD_DIR="s:$OLD_BUILD_DIR:$BUILD_DIR:"
     [ "$OLD_MODEL_DIR" ] && SUBST_MODEL_DIR="s:$OLD_MODEL_DIR:$MODEL_BASE_DIR:"
     [ "$OLD_basedir" ] && SUBST_basedir="s:$OLD_basedir:$MODEL_BASE_DIR:"
+    [ "${ADD_RUN_ROUTINES-}" ] && SUBST_add_run_routines="s:^.*add_run_routines:. ${ADD_RUN_ROUTINES}:"
 
     EXEC_SHELL=$(perl -ne '/^\#!\s*(\/\S+)/x and print($1); exit' $RUN_SCRIPT)
     case $EXEC_SHELL in
@@ -140,6 +142,7 @@ cd '$WORK_DIR'
         '${SUBST_BUILD_DIR-}'
         '${SUBST_MODEL_DIR-}'
         '${SUBST_basedir-}'
+        '"${SUBST_add_run_routines-}"'
         s/^\s*make_and_change_to_experiment_dir/: &/
     ' "$RUN_SCRIPT" > $RUN_FILE
 
-- 
GitLab