From 929090d8b131504d5f3177772ca0cea49bd11faa Mon Sep 17 00:00:00 2001
From: Daley Calvert <daley.calvert@metoffice.gov.uk>
Date: Fri, 9 Dec 2022 15:56:01 +0000
Subject: [PATCH] Resolve "SETTE issues after 7f3d7e34"

---
 sette/all_functions.sh                  |  3 ++-
 sette/prepare_exe_dir.sh                |  3 ++-
 sette/sette.sh                          |  2 +-
 sette/sette_reference-configurations.sh | 24 +++++++++++++-----------
 sette/sette_test-cases.sh               | 22 ++++++++++++----------
 5 files changed, 30 insertions(+), 24 deletions(-)

diff --git a/sette/all_functions.sh b/sette/all_functions.sh
index 9c95cafd..f75cfe3d 100755
--- a/sette/all_functions.sh
+++ b/sette/all_functions.sh
@@ -195,7 +195,8 @@ set_valid_dir () {
     fi
     # remove last _ST followed by zero or more alphanumeric characters
     NEW_CONF1=$( echo $NEW_CONF | sed -e 's/_ST\([0-9a-zA-Z]*\)$//' )
-    if [[ -n "${NEMO_DEBUG}" && ! ${CMP_NAM,,} =~ ("debug"|"dbg") ]]; then
+    CMP_NAM_L=$(echo ${CMP_NAM} | tr '[:upper:]' '[:lower:]')
+    if [[ -n "${NEMO_DEBUG}" && ! ${CMP_NAM_L} =~ ("debug"|"dbg") ]]; then
       export NEMO_VALID=${NEMO_VALIDATION_DIR}/${CMP_NAM}_DEBUG/${REVISION_NB}/${NEW_CONF1}/${TEST_NAME}
     else
       export NEMO_VALID=${NEMO_VALIDATION_DIR}/${CMP_NAM}/${REVISION_NB}/${NEW_CONF1}/${TEST_NAME}
diff --git a/sette/prepare_exe_dir.sh b/sette/prepare_exe_dir.sh
index 47d5207f..b446a7e3 100755
--- a/sette/prepare_exe_dir.sh
+++ b/sette/prepare_exe_dir.sh
@@ -69,7 +69,8 @@ set -o posix
 if [ -z "${CUSTOM_DIR}" ]; then
   export EXE_DIR=${CONFIG_DIR}/${NEW_CONF}/${TEST_NAME}
 else
-  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]; then
+  CMP_NAM_L=$(echo ${CMP_NAM} | tr '[:upper:]' '[:lower:]')
+  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]; then
     export EXE_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}_DEBUG/${NEW_CONF}/${TEST_NAME}
   else
     export EXE_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}/${NEW_CONF}/${TEST_NAME}
diff --git a/sette/sette.sh b/sette/sette.sh
index b161c7a6..9de659ab 100755
--- a/sette/sette.sh
+++ b/sette/sette.sh
@@ -335,7 +335,7 @@ while [[ $NRUN -ne 0 && $nit -le 1080 ]]; do
       printf "%-3d %s\r" $NRUN 'nemo_sette runs still in queue or running ...';
    else
       printf "%-50s\n" " "
-      ./sette_rpt.sh ${NEMO_DEBUG}
+      . ./sette_rpt.sh ${NEMO_DEBUG}
       exit
    fi
    sleep 10
diff --git a/sette/sette_reference-configurations.sh b/sette/sette_reference-configurations.sh
index 4d22ddff..379ee02a 100755
--- a/sette/sette_reference-configurations.sh
+++ b/sette/sette_reference-configurations.sh
@@ -112,13 +112,15 @@ CONFIG_DIR0=${MAIN_DIR}/cfgs
 TOOLS_DIR=${MAIN_DIR}/tools
 if [ -n "${CUSTOM_DIR}" ]; then
   NEMO_REV=$( git rev-parse --short HEAD 2> /dev/null )
-  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]; then
+  CMP_NAM_L=$(echo ${CMP_NAM} | tr '[:upper:]' '[:lower:]')
+  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]; then
     export CMP_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}_DEBUG
   else
     export CMP_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}
   fi
 fi
 CMP_NAM=${1:-$COMPILER}
+CMP_NAM_L=$(echo ${CMP_NAM} | tr '[:upper:]' '[:lower:]')
 
 # Copy job_batch_COMPILER file for specific compiler into job_batch_template
 cd ${SETTE_DIR}
@@ -143,7 +145,7 @@ do
 # -----------
 if [ ${config} == "GYRE_PISCES" ] ;  then
     SETTE_CONFIG="GYRE_PISCES"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12    # 1 day
     else
@@ -290,7 +292,7 @@ fi
 # -----------------
 if [ ${config} == "ORCA2_ICE_PISCES" ] ;  then
     SETTE_CONFIG="ORCA2_ICE_PISCES"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 1 day
     else
@@ -577,7 +579,7 @@ fi
 # ----------------
 if [ ${config} == "ORCA2_OFF_PISCES" ] ;  then
     SETTE_CONFIG="ORCA2_OFF_PISCES"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 4 days
     else
@@ -754,7 +756,7 @@ fi
 # -----
 if [ ${config} == "AMM12" ] ;  then
     SETTE_CONFIG="AMM12"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12   # 3 h
     else
@@ -888,7 +890,7 @@ fi
 # ---------
 if [ ${config} == "SAS" ] ;  then
     SETTE_CONFIG="ORCA2_SAS_ICE"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 1 day
     else
@@ -969,7 +971,7 @@ fi
 
 if [ ${config} == "SAS" ] && [ ${DO_REPRO} == "1" ] ;  then
 ## Reproducibility tests
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16  # 1 day
     else
@@ -1037,7 +1039,7 @@ fi
 if [ ${config} == "ORCA2_ICE_OBS" ] ;  then
     SETTE_CONFIG="ORCA2_ICE_OBS"${SETTE_STG}
 ## Reproducibility tests
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16  # 1 day
     else
@@ -1157,7 +1159,7 @@ fi
 # -----------
 if [ ${config} == "AGRIF" ] ;  then
     SETTE_CONFIG="AGRIF_DEMO"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=4   # 6h
     else
@@ -1440,7 +1442,7 @@ fi
 
 if [ ${config} == "AGRIF" ] && [ ${DO_CORRUPT} == "1" ] ;  then
 ## test code corruption with AGRIF (phase 1) ==> Compile with key_agrif but run with no zoom
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 1d
     else
@@ -1525,7 +1527,7 @@ fi
 # -------
 if [ ${config} == "WED025" ] ;  then
     SETTE_CONFIG="WED025"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12   # 4h
     else
diff --git a/sette/sette_test-cases.sh b/sette/sette_test-cases.sh
index db9c81dc..1d879f30 100755
--- a/sette/sette_test-cases.sh
+++ b/sette/sette_test-cases.sh
@@ -113,13 +113,15 @@ TOOLS_DIR=${MAIN_DIR}/tools
 
 if [ -n "${CUSTOM_DIR}" ]; then
   NEMO_REV=$( git rev-parse --short HEAD 2> /dev/null )
-  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]; then
+  CMP_NAM_L=$(echo ${CMP_NAM} | tr '[:upper:]' '[:lower:]')
+  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]; then
     export CMP_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}_DEBUG
   else
     export CMP_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}
   fi
 fi
 CMP_NAM=${1:-$COMPILER}
+CMP_NAM_L=$(echo ${CMP_NAM} | tr '[:upper:]' '[:lower:]')
 # Copy job_batch_COMPILER file for specific compiler into job_batch_template
 cd ${SETTE_DIR}
 cp BATCH_TEMPLATE/${JOB_PREFIX}-${COMPILER} job_batch_template || exit
@@ -143,7 +145,7 @@ do
 # ---------
 if [ ${config} == "OVERFLOW" ] ;  then
     SETTE_CONFIG="OVERFLOW"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -215,7 +217,7 @@ fi
 if [ ${config} == "OVERFLOW" ] && [ ${DO_PHYOPTS} == "1" ] ;  then
     ## Test for all advection, vert. coordinates, vector form, flux form: test runability and complete all time steps
     ## Needed namelist-xxxx for every type of run tested
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -259,7 +261,7 @@ fi
 # --------------
 if [ ${config} == "LOCK_EXCHANGE" ] ;  then
     SETTE_CONFIG="LOCK_EXCHANGE"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -331,7 +333,7 @@ fi
 if [ ${config} == "LOCK_EXCHANGE" ] && [ ${DO_PHYOPTS} == "1" ] ;  then
     ## Test for all advection, vector form, flux form: test runability and complete all time steps
     ## Needed namelist-xxxx for every type of run tested
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -377,7 +379,7 @@ fi
 # ---------
 if [ ${config} == "VORTEX" ] ;  then
     SETTE_CONFIG="VORTEX"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -571,7 +573,7 @@ fi
 # ---------
 if [ ${config} == "ICE_AGRIF" ] ;  then
     SETTE_CONFIG="ICE_AGRIF"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=10
     else
@@ -770,7 +772,7 @@ fi
 # ------
 if [ ${config} == "ISOMIP+" ] ;  then
     SETTE_CONFIG="ISOMIP+"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -850,7 +852,7 @@ fi
 
 if [ ${config} == "ISOMIP+" ] && [ ${DO_REPRO} == "1" ] ;  then
 ## Reproducibility tests
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -915,7 +917,7 @@ fi
 # ---------
 if [ ${config} == "SWG" ] && [ ${USING_QCO} == "yes" ] ;  then
     SETTE_CONFIG="SWG"${SETTE_STG}
-    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM_L} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
-- 
GitLab