From 6331505140fa3af1e9744f253a4a9272060a908e Mon Sep 17 00:00:00 2001
From: Guillaume S <gsamson@mercator-ocean.fr>
Date: Tue, 20 Dec 2022 23:34:22 +0100
Subject: [PATCH] fix symbolic link issue with OVERFLOW & LOCK_EXCHANGE
 namelist_cfg

---
 mk/Fmake_config.sh        |  2 +-
 sette/all_functions.sh    | 11 ++++++++---
 sette/sette_test-cases.sh |  4 ++--
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/mk/Fmake_config.sh b/mk/Fmake_config.sh
index 6a3e942b..04df7d09 100755
--- a/mk/Fmake_config.sh
+++ b/mk/Fmake_config.sh
@@ -61,7 +61,7 @@ set -o posix
 \mkdir -p ${1}/MY_SRC
 [ "${2}/cpp_${2##*/}.fcm" != "${1}/cpp_${1##*/}.fcm" ] && \cp -R -n ${2}/cpp_${2##*/}.fcm ${1}/cpp_${1##*/}.fcm
 for f in ${2}/EXPREF/*.xml ${2}/EXPREF/*namelist*; do
-  if [ -L ${f} ]; then ln -sf $(readlink -f ${f}) ${1}/EXP00/$(basename ${f}); else cp -R -n ${f} ${1}/EXP00/.; fi
+  if [[ -L ${f} && $(readlink -f ${f}) =~ "SHARED" ]]; then ln -sf $(readlink -f ${f}) ${1}/EXP00/$(basename ${f}); else cp -R -n ${f} ${1}/EXP00/.; fi
 done
 [ -f ${2}/EXPREF/AGRIF_FixedGrids.in ] && \cp -a -n ${2}/EXPREF/AGRIF_FixedGrids.in ${1}/EXP00/.
 [ -d    ${2}/MY_SRC ] && \cp -an ${2}/MY_SRC/* ${1}/MY_SRC/. 2> /dev/null
diff --git a/sette/all_functions.sh b/sette/all_functions.sh
index f5f92259..167263ef 100755
--- a/sette/all_functions.sh
+++ b/sette/all_functions.sh
@@ -153,9 +153,14 @@ clean_config() {
       echo ''
       echo "./makenemo -n $(basename $lCFG) ${CUSTOM_DIR:+-t ${CMP_DIR}} clean"
       echo ''
-      ./makenemo -n $(basename $lCFG) ${CUSTOM_DIR:+-t ${CMP_DIR}} clean
-      echo ''
-      echo "$(basename $lCFG) configuration has been cleaned"
+      if [ -d $lCFG ]; then
+        ./makenemo -n $(basename $lCFG) ${CUSTOM_DIR:+-t ${CMP_DIR}} clean
+        echo ''
+        echo "$(basename $lCFG) configuration has been cleaned"
+      else
+        echo ''
+        echo "$(basename $lCFG) configuration does not exist; we skip cleaning"
+      fi
       echo ''
       echo '-------------------------------------------------------------------------------'
    fi
diff --git a/sette/sette_test-cases.sh b/sette/sette_test-cases.sh
index 67a31a9a..e1649645 100755
--- a/sette/sette_test-cases.sh
+++ b/sette/sette_test-cases.sh
@@ -238,7 +238,7 @@ if [ ${config} == "OVERFLOW" ] && [ ${DO_PHYOPTS} == "1" ] ;  then
         NPROC=1
         if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
         cd ${EXE_DIR}
-        rm namelist_*_*_*_*
+        rm namelist_*_*_*_* namelist_cfg
         cp -pL ${CMP_DIR:-${CONFIG_DIR0}}/${SETTE_CONFIG}/EXP00/$file namelist_cfg
 	set_namelist namelist_cfg nn_it000 1
 	set_namelist namelist_cfg nn_itend ${ITEND}
@@ -355,7 +355,7 @@ if [ ${config} == "LOCK_EXCHANGE" ] && [ ${DO_PHYOPTS} == "1" ] ;  then
         NPROC=1
         if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
         cd ${EXE_DIR}
-        rm namelist_*_*_*_*
+        rm namelist_*_*_*_* namelist_cfg
         cp -pL ${CMP_DIR:-${CONFIG_DIR0}}/${SETTE_CONFIG}/EXP00/$file namelist_cfg
 	set_namelist namelist_cfg nn_it000 1
         set_namelist namelist_cfg nn_itend ${ITEND}
-- 
GitLab