From 7f3d7e343eedd5b89811019d08c546b68a440436 Mon Sep 17 00:00:00 2001
From: Guillaume Samson <guillaume.samson@mercator-ocean.fr>
Date: Fri, 23 Sep 2022 12:39:25 +0000
Subject: [PATCH] Resolve "add a new "debug" (-d) option to `makenemo` and a
 specific FCM flag to switch more easily in debug mode"

---
 arch/CNRS/arch-X64_IRENE.fcm                  |  6 +-
 arch/CNRS/arch-X64_IRENE_DEBUG.fcm            | 58 -------------
 arch/CNRS/arch-X64_IRENE_GCC.fcm              |  3 +-
 arch/CNRS/arch-X64_IRENE_GCC_DEBUG.fcm        | 44 ----------
 arch/CNRS/arch-X64_JEANZAY.fcm                |  3 +-
 arch/CNRS/arch-X64_JEANZAY_DEBUG.fcm          | 63 --------------
 arch/MERCATOR/arch-X64_AA_INTEL_IMPI.fcm      |  5 +-
 arch/MERCATOR/arch-X64_AA_INTEL_OMPI.fcm      |  3 +-
 .../MERCATOR/arch-X64_AA_INTEL_OMPI_DEBUG.fcm | 62 -------------
 arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI.fcm |  3 +-
 .../arch-X64_BELENOS_INTEL_IMPI_DEBUG.fcm     | 70 ---------------
 arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP.fcm | 11 +--
 .../arch-X64_BELENOS_INTEL_MVAP_DEBUG.fcm     | 70 ---------------
 .../arch-X64_BELENOS_INTEL_OMPI_DEBUG.fcm     |  1 -
 arch/MERCATOR/arch-X64_KARA_GCC_OMPI.fcm      |  5 +-
 .../MERCATOR/arch-X64_KARA_GCC_OMPI_DEBUG.fcm | 64 --------------
 arch/arch-osx_gfortran.fcm                    |  3 +-
 arch/arch-osx_gfortran_debug.fcm              | 51 -----------
 makenemo                                      | 21 ++---
 mk/Fcheck_archfile.sh                         | 18 +++-
 .../batch-X64_AA_INTEL_OMPI_DEBUG             |  1 -
 .../batch-X64_BELENOS_INTEL_IMPI_DEBUG        |  1 -
 sette/BATCH_TEMPLATE/batch-X64_IRENE_DEBUG    | 76 ----------------
 .../BATCH_TEMPLATE/batch-X64_IRENE_GCC_DEBUG  | 87 -------------------
 sette/BATCH_TEMPLATE/batch-X64_JEANZAY_DEBUG  | 79 -----------------
 .../batch-X64_KARA_GCC_OMPI_DEBUG             |  1 -
 .../batch-mpmd-X64_AA_INTEL_OMPI              |  1 -
 .../batch-mpmd-X64_AA_INTEL_OMPI_DEBUG        |  1 -
 .../batch-mpmd-X64_BELENOS_INTEL_IMPI         |  1 -
 .../batch-mpmd-X64_BELENOS_INTEL_IMPI_DEBUG   |  1 -
 .../batch-mpmd-X64_KARA_GCC_OMPI              |  1 -
 .../batch-mpmd-X64_KARA_GCC_OMPI_DEBUG        |  1 -
 sette/all_functions.sh                        |  6 +-
 sette/prepare_exe_dir.sh                      |  6 +-
 sette/sette.sh                                | 13 ++-
 sette/sette_reference-configurations.sh       | 44 +++++-----
 sette/sette_rpt.sh                            | 10 ++-
 sette/sette_test-cases.sh                     | 36 ++++----
 38 files changed, 123 insertions(+), 807 deletions(-)
 delete mode 100644 arch/CNRS/arch-X64_IRENE_DEBUG.fcm
 delete mode 100644 arch/CNRS/arch-X64_IRENE_GCC_DEBUG.fcm
 delete mode 100644 arch/CNRS/arch-X64_JEANZAY_DEBUG.fcm
 delete mode 100644 arch/MERCATOR/arch-X64_AA_INTEL_OMPI_DEBUG.fcm
 delete mode 100644 arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI_DEBUG.fcm
 delete mode 100644 arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP_DEBUG.fcm
 delete mode 120000 arch/MERCATOR/arch-X64_BELENOS_INTEL_OMPI_DEBUG.fcm
 delete mode 100644 arch/MERCATOR/arch-X64_KARA_GCC_OMPI_DEBUG.fcm
 delete mode 100644 arch/arch-osx_gfortran_debug.fcm
 delete mode 120000 sette/BATCH_TEMPLATE/batch-X64_AA_INTEL_OMPI_DEBUG
 delete mode 120000 sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI_DEBUG
 delete mode 100644 sette/BATCH_TEMPLATE/batch-X64_IRENE_DEBUG
 delete mode 100644 sette/BATCH_TEMPLATE/batch-X64_IRENE_GCC_DEBUG
 delete mode 100644 sette/BATCH_TEMPLATE/batch-X64_JEANZAY_DEBUG
 delete mode 120000 sette/BATCH_TEMPLATE/batch-X64_KARA_GCC_OMPI_DEBUG
 delete mode 120000 sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI
 delete mode 120000 sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI_DEBUG
 delete mode 120000 sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI
 delete mode 120000 sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI_DEBUG
 delete mode 120000 sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI
 delete mode 120000 sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI_DEBUG

diff --git a/arch/CNRS/arch-X64_IRENE.fcm b/arch/CNRS/arch-X64_IRENE.fcm
index b96db19b0..63431b643 100644
--- a/arch/CNRS/arch-X64_IRENE.fcm
+++ b/arch/CNRS/arch-X64_IRENE.fcm
@@ -30,7 +30,8 @@
 #  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
 #  - fcm variables are starting with a % (and not a $)
 #
-%XIOS_HOME           $CCCWORKDIR/xios-trunk
+%PROD_XIOS_HOME      $CCCWORKDIR/xios-trunk
+%DEBUG_XIOS_HOME     %{PROD_XIOS_HOME}_debug
 %OASIS_HOME          $CCCWORKDIR/now/models/oa3mct
 
 %NCDF_INC            -I$NETCDFFORTRAN_INCDIR -I$NETCDF_INCDIR
@@ -43,7 +44,8 @@
 
 %CPP	             cpp
 %FC                  mpif90 -c -cpp
-%FCFLAGS             -i4 -r8 -O3 -fp-model strict -xCORE-AVX512 -fno-alias
+%PROD_FCFLAGS        -i4 -r8 -O3 -fp-model strict -xCORE-AVX512 -fno-alias
+%DEBUG_FCFLAGS       -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
 %FFLAGS              %FCFLAGS
 %LD                  mpif90
 %LDFLAGS             
diff --git a/arch/CNRS/arch-X64_IRENE_DEBUG.fcm b/arch/CNRS/arch-X64_IRENE_DEBUG.fcm
deleted file mode 100644
index 0db4df2dd..000000000
--- a/arch/CNRS/arch-X64_IRENE_DEBUG.fcm
+++ /dev/null
@@ -1,58 +0,0 @@
-# Irene BULL at TGCC, http://www-hpc.cea.fr/en/complexe/tgcc-Irene.htm
-#
-# NCDF_HOME   root directory containing lib and include subdirectories for netcdf4
-# HDF5_HOME   root directory containing lib and include subdirectories for HDF5
-# XIOS_HOME   root directory containing lib for XIOS
-# OASIS_HOME  root directory containing lib for OASIS
-#
-# NCDF_INC    netcdf4 include file
-# NCDF_LIB    netcdf4 library
-# XIOS_INC    xios include file    (taken into accound only if key_xios is activated)
-# XIOS_LIB    xios library         (taken into accound only if key_xios is activated)
-# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
-# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
-#
-# FC          Fortran compiler command
-# FCFLAGS     Fortran compiler flags
-# FFLAGS      Fortran 77 compiler flags
-# LD          linker
-# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make
-# USER_INC    complete list of include files
-# USER_LIB    complete list of libraries to pass to the linker
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-%XIOS_HOME           $CCCWORKDIR/xios-trunk
-%OASIS_HOME          $CCCWORKDIR/now/models/oa3mct
-
-%NCDF_INC            -I$NETCDFFORTRAN_INCDIR -I$NETCDF_INCDIR
-%NCDF_LIB            -L$NETCDFFORTRAN_LIBDIR -lnetcdff -L$NETCDF_LIBDIR -lnetcdf -L$HDF5_LIBDIR -lhdf5_hl -lhdf5 -lz -lcurl
-
-%XIOS_INC            -I%XIOS_HOME/inc 
-%XIOS_LIB            -L%XIOS_HOME/lib -lxios -lstdc++
-%OASIS_INC           -I%OASIS_HOME/build/lib/mct -I%OASIS_HOME/build/lib/psmile.MPI1
-%OASIS_LIB           -L%OASIS_HOME/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP	             cpp
-%FC                  mpif90 -c -cpp
-%FCFLAGS             -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
-%FFLAGS              %FCFLAGS
-%LD                  mpif90
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  cc
-%CFLAGS              -O0
diff --git a/arch/CNRS/arch-X64_IRENE_GCC.fcm b/arch/CNRS/arch-X64_IRENE_GCC.fcm
index 6d27c5fa3..99dffdfbe 100644
--- a/arch/CNRS/arch-X64_IRENE_GCC.fcm
+++ b/arch/CNRS/arch-X64_IRENE_GCC.fcm
@@ -29,7 +29,8 @@
 
 %CPP	             cpp -Dkey_nosignedzero 
 %FC                  mpif90
-%FCFLAGS             -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer -ffree-line-length-none -Wno-missing-include-dirs 
+%PROD_FCFLAGS        -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer -ffree-line-length-none -Wno-missing-include-dirs 
+%DEBUG_FCFLAGS       -fdefault-real-8 -O0 -g -fbacktrace -funroll-all-loops -fcray-pointer -ffree-line-length-none -fcheck=all -finit-real=nan
 %FFLAGS              %FCFLAGS
 %LD                  mpif90
 %LDFLAGS             
diff --git a/arch/CNRS/arch-X64_IRENE_GCC_DEBUG.fcm b/arch/CNRS/arch-X64_IRENE_GCC_DEBUG.fcm
deleted file mode 100644
index f83799fcc..000000000
--- a/arch/CNRS/arch-X64_IRENE_GCC_DEBUG.fcm
+++ /dev/null
@@ -1,44 +0,0 @@
-# Irene BULL at TGCC, http://www-hpc.cea.fr/en/complexe/tgcc-Irene.htm
-#
-# list of modules used
-#
-#   module purge
-#   module load gnu/8.3.0
-#   module load flavor/buildcompiler/gcc/8
-#   module load flavor/buildmpi/openmpi/2.0
-#   module load flavor/hdf5/parallel
-#   module load mpi/openmpi/2.0.4
-#   module load hdf5/1.8.20
-#   module load netcdf-c/4.6.0
-#   module load netcdf-fortran/4.4.4
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-%XIOS_HOME           $CCCWORKDIR/xios-trunk_gcc
-%OASIS_HOME          $CCCWORKDIR/now/models/oa3mct
-
-%NCDF_INC            -I$NETCDFFORTRAN_INCDIR -I$NETCDF_INCDIR
-%NCDF_LIB            -L$NETCDFFORTRAN_LIBDIR -lnetcdff -L$NETCDF_LIBDIR -lnetcdf -L$HDF5_LIBDIR -lhdf5_hl -lhdf5 -lz -lcurl
-
-%XIOS_INC            -I%XIOS_HOME/inc 
-%XIOS_LIB            -L%XIOS_HOME/lib -lxios -lstdc++
-%OASIS_INC           -I%OASIS_HOME/build/lib/mct -I%OASIS_HOME/build/lib/psmile.MPI1
-%OASIS_LIB           -L%OASIS_HOME/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP	             cpp -Dkey_nosignedzero 
-%FC                  mpif90
-%FCFLAGS             -fdefault-real-8 -O0 -g -fbacktrace -funroll-all-loops -fcray-pointer -ffree-line-length-none -fcheck=all -finit-real=nan
-%FFLAGS              %FCFLAGS
-%LD                  mpif90
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  make
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  cc
-%CFLAGS              -O0
diff --git a/arch/CNRS/arch-X64_JEANZAY.fcm b/arch/CNRS/arch-X64_JEANZAY.fcm
index e6e7ee1d0..069b4fbce 100644
--- a/arch/CNRS/arch-X64_JEANZAY.fcm
+++ b/arch/CNRS/arch-X64_JEANZAY.fcm
@@ -48,7 +48,8 @@
 
 %CPP	             cpp
 %FC                  mpiifort -c -cpp
-%FCFLAGS             -i4 -r8 -O3 -fp-model strict -xCORE-AVX512 -fno-alias
+%PROD_FCFLAGS        -i4 -r8 -O3 -fp-model strict -xCORE-AVX512 -fno-alias
+%DEBUG_FCFLAGS       -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
 %FFLAGS              %FCFLAGS
 %LD                  mpiifort
 %LDFLAGS             
diff --git a/arch/CNRS/arch-X64_JEANZAY_DEBUG.fcm b/arch/CNRS/arch-X64_JEANZAY_DEBUG.fcm
deleted file mode 100644
index 727cabff5..000000000
--- a/arch/CNRS/arch-X64_JEANZAY_DEBUG.fcm
+++ /dev/null
@@ -1,63 +0,0 @@
-# Jean-Zay HPE at IDRIS, http://www.idris.fr/jean-zay
-#
-# XIOS_HOME   root directory containing lib for XIOS
-# OASIS_HOME  root directory containing lib for OASIS
-#
-# NCDF_INC    netcdf4 include file
-# NCDF_LIB    netcdf4 library
-# XIOS_INC    xios include file    (taken into accound only if key_xios is activated)
-# XIOS_LIB    xios library         (taken into accound only if key_xios is activated)
-# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
-# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
-#
-# FC          Fortran compiler command
-# FCFLAGS     Fortran compiler flags
-# FFLAGS      Fortran 77 compiler flags
-# LD          linker
-# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make
-# USER_INC    complete list of include files
-# USER_LIB    complete list of libraries to pass to the linker
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-# All NETCDF and HDF paths are empty as they are automatically defined through environment
-# variables by the load of modules
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-#
-#
-%XIOS_HOME           $WORK/xios-trunk
-%OASIS_HOME          
-
-%NCDF_INC            
-%NCDF_LIB            -lnetcdff -lnetcdf
-%XIOS_INC            -I%XIOS_HOME/inc 
-%XIOS_LIB            -L%XIOS_HOME/lib -lxios -lstdc++
-%OASIS_INC           -I%OASIS_HOME/build/lib/mct -I%OASIS_HOME/build/lib/psmile.MPI1
-%OASIS_LIB           -L%OASIS_HOME/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP	             cpp
-%FC                  mpiifort -c -cpp
-%FCFLAGS             -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
-%FFLAGS              %FCFLAGS
-%LD                  mpiifort
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  cc
-%CFLAGS              -O0
diff --git a/arch/MERCATOR/arch-X64_AA_INTEL_IMPI.fcm b/arch/MERCATOR/arch-X64_AA_INTEL_IMPI.fcm
index 40a7450e4..fbe1226d3 100644
--- a/arch/MERCATOR/arch-X64_AA_INTEL_IMPI.fcm
+++ b/arch/MERCATOR/arch-X64_AA_INTEL_IMPI.fcm
@@ -41,12 +41,13 @@
 %NCDF_LIB            ${NETCDF4_LIB} ${HDF5_LIB}
 %XIOS_INC            -I${XIOS_INC}
 %XIOS_LIB            -L${XIOS_LIB} -lxios -lstdc++
-%OASIS_INC           -I${OASIS_DIR}/build/lib/mct -I${OASIS_DIR}/build/lib/psmile.MPI1
+%OASIS_INC           -I${OASIS_DIR}/include
 %OASIS_LIB           -L${OASIS_DIR}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
 
 %CPP                 cpp
 %FC                  mpiifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%PROD_FCFLAGS        -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%DEBUG_FCFLAGS       -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
 %FFLAGS              %FCFLAGS
 %LD                  mpiifort
 %LDFLAGS             
diff --git a/arch/MERCATOR/arch-X64_AA_INTEL_OMPI.fcm b/arch/MERCATOR/arch-X64_AA_INTEL_OMPI.fcm
index 2e8a31399..b30d157c4 100644
--- a/arch/MERCATOR/arch-X64_AA_INTEL_OMPI.fcm
+++ b/arch/MERCATOR/arch-X64_AA_INTEL_OMPI.fcm
@@ -47,7 +47,8 @@
 
 %CPP                 cpp
 %FC                  mpifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%PROD_FCFLAGS        -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%DEBUG_FCFLAGS       -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
 %FFLAGS              %FCFLAGS
 %LD                  mpifort
 %LDFLAGS             
diff --git a/arch/MERCATOR/arch-X64_AA_INTEL_OMPI_DEBUG.fcm b/arch/MERCATOR/arch-X64_AA_INTEL_OMPI_DEBUG.fcm
deleted file mode 100644
index dd0994798..000000000
--- a/arch/MERCATOR/arch-X64_AA_INTEL_OMPI_DEBUG.fcm
+++ /dev/null
@@ -1,62 +0,0 @@
-# compiler options for AA (using INTEL compiler & OpenMPI)
-#
-# module purge
-# module use /home/ar0s/modules
-# module load prgenv/intel intel/2021.4.0 openmpi/4.1.1.1 hdf5-parallel/1.10.6 netcdf4-parallel/4.7.4 xios/trunk/rev2320-nmpi
-#
-#
-# NCDF_INC    netcdf4 include file
-# NCDF_LIB    netcdf4 library
-# XIOS_INC    xios include file    (taken into accound only if key_xios is activated)
-# XIOS_LIB    xios library         (taken into accound only if key_xios is activated)
-# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
-# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
-#
-# FC          Fortran compiler command
-# FCFLAGS     Fortran compiler flags
-# FFLAGS      Fortran 77 compiler flags
-# LD          linker
-# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make
-# USER_INC    complete list of include files
-# USER_LIB    complete list of libraries to pass to the linker
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-# All NETCDF and HDF paths are empty as they are automatically defined through environment
-# variables by the load of modules
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-#
-#
-%NCDF_INC            ${NETCDF4_INCLUDE}
-%NCDF_LIB            ${NETCDF4_LIB} -L${HDF5_DIR}/lib -Wl,-rpath,${HDF5_DIR}/lib -lhdf5_hl -lhdf5 -lz
-%XIOS_INC            -I${XIOS_INC}
-%XIOS_LIB            -L${XIOS_LIB} -lxios -lstdc++
-%OASIS_INC           -I${OASIS_DIR}/build/lib/mct -I${OASIS_DIR}/build/lib/psmile.MPI1
-%OASIS_LIB           -L${OASIS_DIR}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP                 cpp
-%FC                  mpifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
-%FFLAGS              %FCFLAGS
-%LD                  mpifort
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  mpicc
-%CFLAGS              -O0
diff --git a/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI.fcm b/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI.fcm
index 83772b33d..f41974d3d 100644
--- a/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI.fcm
+++ b/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI.fcm
@@ -55,7 +55,8 @@
 
 %CPP                 cpp
 %FC                  mpiifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%PROD_FCFLAGS        -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%DEBUG_FCFLAGS       -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
 %FFLAGS              %FCFLAGS
 %LD                  mpiifort
 %LDFLAGS             
diff --git a/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI_DEBUG.fcm b/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI_DEBUG.fcm
deleted file mode 100644
index 9ca5dcc09..000000000
--- a/arch/MERCATOR/arch-X64_BELENOS_INTEL_IMPI_DEBUG.fcm
+++ /dev/null
@@ -1,70 +0,0 @@
-# compiler options for BELENOS/TARANIS (using INTEL compiler)
-#
-# --------------------------------
-# INTEL_IMPI (NEMO 4.0 + XIOS-2.5)
-# --------------------------------
-# module use /home/ext/mr/smer/samsong/modules
-# module load intel/2018.5.274 intelmpi/2018.5.274 phdf5/1.8.18 netcdf_par/4.7.1_V2 xios/2.5/rev1903
-#
-# ----------------------------------
-# INTEL_IMPI (NEMO 4.2 + XIOS-TRUNK)
-# ----------------------------------
-# module use /home/ext/mr/smer/samsong/modules
-# module load gcc/9.2.0 intel/2018.5.274 intelmpi/2018.5.274 phdf5/1.8.18 netcdf_par/4.7.1_V2 xios/trunk/rev2134
-#
-#
-# NCDF_INC    netcdf4 include file
-# NCDF_LIB    netcdf4 library
-# XIOS_INC    xios include file    (taken into accound only if key_xios is activated)
-# XIOS_LIB    xios library         (taken into accound only if key_xios is activated)
-# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
-# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
-#
-# FC          Fortran compiler command
-# FCFLAGS     Fortran compiler flags
-# FFLAGS      Fortran 77 compiler flags
-# LD          linker
-# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make
-# USER_INC    complete list of include files
-# USER_LIB    complete list of libraries to pass to the linker
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-# All NETCDF and HDF paths are empty as they are automatically defined through environment
-# variables by the load of modules
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-#
-#
-%NCDF_INC            -I${NETCDF_INC}
-%NCDF_LIB            -L${NETCDF_LIB} -lnetcdff -lnetcdf -L${PHDF5_LIB_DIR} -lhdf5_hl -lhdf5
-%XIOS_INC            -I${XIOS_INC}
-%XIOS_LIB            -L${XIOS_LIB} -lxios -lstdc++
-%OASIS_INC           -I${OASIS_DIR}/include
-%OASIS_LIB           -L${OASIS_DIR}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP                 cpp
-%FC                  mpiifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
-%FFLAGS              %FCFLAGS
-%LD                  mpiifort
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  mpiicc
-%CFLAGS              -O0
diff --git a/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP.fcm b/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP.fcm
index 0e28d12b9..5c2b92541 100644
--- a/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP.fcm
+++ b/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP.fcm
@@ -50,14 +50,15 @@
 %NCDF_LIB            -L${NETCDF_LIB} -lnetcdff -lnetcdf -L${PHDF5_LIB_DIR} -lhdf5_hl -lhdf5
 %XIOS_INC            -I${XIOS_INC}
 %XIOS_LIB            -L${XIOS_LIB} -lxios -lstdc++
-%OASIS_INC           -I${OASIS_DIR}/build/lib/mct -I${OASIS_DIR}/build/lib/psmile.MPI1
+%OASIS_INC           -I${OASIS_DIR}/include
 %OASIS_LIB           -L${OASIS_DIR}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
 
 %CPP                 cpp
-%FC                  mpifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%FC                  mpiifort -c -cpp
+%PROD_FCFLAGS        -march=core-avx2 -i4 -r8 -O3 -fp-model strict -fno-alias -align array64byte
+%DEBUG_FCFLAGS       -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
 %FFLAGS              %FCFLAGS
-%LD                  mpifort
+%LD                  mpiifort
 %LDFLAGS             
 %FPPFLAGS            -P -traditional
 %AR                  ar
@@ -66,5 +67,5 @@
 %USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
 %USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
 
-%CC                  mpicc
+%CC                  mpiicc
 %CFLAGS              -O0
diff --git a/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP_DEBUG.fcm b/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP_DEBUG.fcm
deleted file mode 100644
index 4ec5587d3..000000000
--- a/arch/MERCATOR/arch-X64_BELENOS_INTEL_MVAP_DEBUG.fcm
+++ /dev/null
@@ -1,70 +0,0 @@
-# compiler options for BELENOS/TARANIS (using INTEL compiler + Intel MPI)
-#
-# --------------------------------
-# INTEL_IMPI (NEMO 4.0 + XIOS-2.5)
-# --------------------------------
-# module use /home/ext/mr/smer/samsong/modules
-# module load intel/2018.5.274 intelmpi/2018.5.274 phdf5/1.8.18 netcdf_par/4.7.1_V2 xios/2.5/rev1903
-#
-# ----------------------------------
-# INTEL_IMPI (NEMO 4.2 + XIOS-TRUNK)
-# ----------------------------------
-# module use /home/ext/mr/smer/samsong/modules
-# module load gcc/9.2.0 intel/2018.5.274 intelmpi/2018.5.274 phdf5/1.8.18 netcdf_par/4.7.1_V2 xios/trunk/rev2134
-#
-#
-# NCDF_INC    netcdf4 include file
-# NCDF_LIB    netcdf4 library
-# XIOS_INC    xios include file    (taken into accound only if key_xios is activated)
-# XIOS_LIB    xios library         (taken into accound only if key_xios is activated)
-# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
-# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
-#
-# FC          Fortran compiler command
-# FCFLAGS     Fortran compiler flags
-# FFLAGS      Fortran 77 compiler flags
-# LD          linker
-# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make
-# USER_INC    complete list of include files
-# USER_LIB    complete list of libraries to pass to the linker
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-# All NETCDF and HDF paths are empty as they are automatically defined through environment
-# variables by the load of modules
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-#
-#
-%NCDF_INC            -I${NETCDF_INC}
-%NCDF_LIB            -L${NETCDF_LIB} -lnetcdff -lnetcdf -L${PHDF5_LIB_DIR} -lhdf5_hl -lhdf5
-%XIOS_INC            -I${XIOS_INC}
-%XIOS_LIB            -L${XIOS_LIB} -lxios -lstdc++
-%OASIS_INC           -I${OASIS_DIR}/include
-%OASIS_LIB           -L${OASIS_DIR}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP                 cpp
-%FC                  mpiifort -c -cpp
-%FCFLAGS             -march=core-avx2 -i4 -r8 -g -O0 -debug all -traceback -fp-model strict -ftrapuv -check all,noarg_temp_created -fpe-all0 -ftz -init=arrays,snan,huge
-%FFLAGS              %FCFLAGS
-%LD                  mpiifort
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  mpiicc
-%CFLAGS              -O0
diff --git a/arch/MERCATOR/arch-X64_BELENOS_INTEL_OMPI_DEBUG.fcm b/arch/MERCATOR/arch-X64_BELENOS_INTEL_OMPI_DEBUG.fcm
deleted file mode 120000
index 43aab1143..000000000
--- a/arch/MERCATOR/arch-X64_BELENOS_INTEL_OMPI_DEBUG.fcm
+++ /dev/null
@@ -1 +0,0 @@
-arch-X64_BELENOS_INTEL_IMPI_DEBUG.fcm
\ No newline at end of file
diff --git a/arch/MERCATOR/arch-X64_KARA_GCC_OMPI.fcm b/arch/MERCATOR/arch-X64_KARA_GCC_OMPI.fcm
index 8ba606ef0..5e886a887 100644
--- a/arch/MERCATOR/arch-X64_KARA_GCC_OMPI.fcm
+++ b/arch/MERCATOR/arch-X64_KARA_GCC_OMPI.fcm
@@ -49,8 +49,9 @@
 
 %CPP                 cpp -Dkey_nosignedzero
 %FC                  mpif90 -c -cpp
-#%FCFLAGS             -fdefault-real-8 -O2 -ftree-vectorize -funroll-all-loops -march=skylake-avx512 -ffree-line-length-none -Wno-missing-include-dirs
-%FCFLAGS             -fdefault-real-8 -O1 -march=skylake-avx512 -ffree-line-length-none -Wno-missing-include-dirs
+#%PROD_FCFLAGS       -fdefault-real-8 -O2 -ftree-vectorize -funroll-all-loops -march=skylake-avx512 -ffree-line-length-none -Wno-missing-include-dirs
+%PROD_FCFLAGS        -fdefault-real-8 -O1 -march=skylake-avx512 -ffree-line-length-none -Wno-missing-include-dirs
+%DEBUG_FCFLAGS       -fdefault-real-8 -O0 -g -fbacktrace -ftree-vectorize -funroll-all-loops -march=skylake-avx512 -ffree-line-length-none -fcheck=all -finit-real=snan -Wno-missing-include-dirs -ffpe-trap=invalid,zero,overflow
 %FFLAGS              %FCFLAGS
 %LD                  mpif90
 %LDFLAGS             -lstdc++
diff --git a/arch/MERCATOR/arch-X64_KARA_GCC_OMPI_DEBUG.fcm b/arch/MERCATOR/arch-X64_KARA_GCC_OMPI_DEBUG.fcm
deleted file mode 100644
index dad25a47a..000000000
--- a/arch/MERCATOR/arch-X64_KARA_GCC_OMPI_DEBUG.fcm
+++ /dev/null
@@ -1,64 +0,0 @@
-# compiler options for KARA (using GNU compiler)
-#
-# GNU_OMPI (NEMO-4.0 + XIOS-2.5)
-# gcc/9.3.0 openmpi/4.0.5_gcc9.3.0 hdf5/1.8.18_gcc9.3.0 netcdf/4.7.1_gcc9.3.0 xios/2.5_rev1903_gcc9.3.0
-#
-# GNU_OMPI (NEMO-4.2 + XIOS-TRUNK)
-# gcc/9.3.0 openmpi/4.0.5_gcc9.3.0 hdf5/1.8.18_gcc9.3.0 netcdf/4.7.1_gcc9.3.0 xios/trunk_rev2136_gcc9.3.0
-#
-#
-# NCDF_INC    netcdf4 include file
-# NCDF_LIB    netcdf4 library
-# XIOS_INC    xios include file    (taken into accound only if key_xios is activated)
-# XIOS_LIB    xios library         (taken into accound only if key_xios is activated)
-# OASIS_INC   oasis include file   (taken into accound only if key_oasis3 is activated)
-# OASIS_LIB   oasis library        (taken into accound only if key_oasis3 is activated)
-#
-# FC          Fortran compiler command
-# FCFLAGS     Fortran compiler flags
-# FFLAGS      Fortran 77 compiler flags
-# LD          linker
-# LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries
-# FPPFLAGS    pre-processing flags
-# AR          assembler
-# ARFLAGS     assembler flags
-# MK          make
-# USER_INC    complete list of include files
-# USER_LIB    complete list of libraries to pass to the linker
-# CC          C compiler used to compile conv for AGRIF
-# CFLAGS      compiler flags used with CC
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-# All NETCDF and HDF paths are empty as they are automatically defined through environment
-# variables by the load of modules
-#---------------------------------------------------------------------------------------------
-#---------------------------------------------------------------------------------------------
-#
-#
-%NCDF_INC            -I${NETCDF_INC}
-%NCDF_LIB            -L${NETCDF_LIB} -lnetcdff -lnetcdf -L${HDF5_LIB} -lhdf5_hl -lhdf5
-%XIOS_INC            -I${XIOS_INC}
-%XIOS_LIB            -L${XIOS_LIB} -lxios
-%OASIS_INC           -I${OASIS_DIR}/build/lib/mct -I${OASIS_DIR}/build/lib/psmile.MPI1
-%OASIS_LIB           -L${OASIS_DIR}/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP                 cpp -Dkey_nosignedzero
-%FC                  mpif90 -c -cpp
-%FCFLAGS             -fdefault-real-8 -O0 -g -fbacktrace -ftree-vectorize -funroll-all-loops -march=skylake-avx512 -ffree-line-length-none -fcheck=all -finit-real=snan -Wno-missing-include-dirs -ffpe-trap=invalid,zero,overflow
-%FFLAGS              %FCFLAGS
-%LD                  mpif90
-%LDFLAGS             -lstdc++
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  gmake
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  gcc
-%CFLAGS              -O0
diff --git a/arch/arch-osx_gfortran.fcm b/arch/arch-osx_gfortran.fcm
index 5fb2f2826..3ce12293a 100644
--- a/arch/arch-osx_gfortran.fcm
+++ b/arch/arch-osx_gfortran.fcm
@@ -35,7 +35,8 @@
 
 %CPP	             cpp -Dkey_nosignedzero 
 %FC	             mpif90 
-%FCFLAGS             -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer -ffree-line-length-none  -fallow-argument-mismatch 
+%PROD_FCFLAGS        -fdefault-real-8 -O3 -funroll-all-loops -fcray-pointer -ffree-line-length-none  -fallow-argument-mismatch 
+%DEBUG_FCFLAGS       -fdefault-real-8 -O0 -g -fbacktrace -funroll-all-loops -fcray-pointer -ffree-line-length-none -fcheck=all -finit-real=nan
 %FFLAGS              %FCFLAGS
 %LD                  %FC
 %LDFLAGS             
diff --git a/arch/arch-osx_gfortran_debug.fcm b/arch/arch-osx_gfortran_debug.fcm
deleted file mode 100644
index 0d0773060..000000000
--- a/arch/arch-osx_gfortran_debug.fcm
+++ /dev/null
@@ -1,51 +0,0 @@
-# generic gfortran compiler options for OSX installed with macport, http://www.macports.org/
-#
-#   Prerequisite softwares installed with MacPorts :
-#   Prerequisite softwares installed with MacPorts :
-#     sudo port install gcc9
-#     sudo port install gcc_select
-#     sudo port select --set gcc mp-gcc9
-#     sudo port install mpich-gcc9
-#     sudo port install mpi_select
-#     sudo port select --set mpi mpich-gcc9-fortran
-#     sudo port install hdf5 +gcc9 +mpich +szip
-#     sudo port install netcdf +gcc9 +mpich
-#     sudo port install netcdf-fortran +gcc9 +mpich
-#     sudo port install p5.30-uri
-#
-#     $ port select --show mpi
-#     The currently selected version for 'mpi' is 'mpich-gcc9-fortran'.
-#     $ port select --show gcc
-#     The currently selected version for 'gcc' is 'mp-gcc9'.
-#
-# Note that:
-#  - unix variables "$..." are accpeted and will be evaluated before calling fcm.
-#  - fcm variables are starting with a % (and not a $)
-#
-%NCDF_HOME           /opt/local
-%HDF5_HOME           /opt/local
-%XIOS_HOME           /Users/$( whoami )/xios-trunk
-%OASIS_HOME          /not/defined
-
-%NCDF_INC            -I%NCDF_HOME/include -I%HDF5_HOME/include
-%NCDF_LIB            -L%NCDF_HOME/lib -lnetcdff -lnetcdf
-%XIOS_INC            -I%XIOS_HOME/inc 
-%XIOS_LIB            -L%XIOS_HOME/lib -lxios -lstdc++
-%OASIS_INC           -I%OASIS_HOME/build/lib/mct -I%OASIS_HOME/build/lib/psmile.MPI1
-%OASIS_LIB           -L%OASIS_HOME/lib -lpsmile.MPI1 -lmct -lmpeu -lscrip
-
-%CPP	             cpp -Dkey_nosignedzero 
-%FC	             mpif90 
-%FCFLAGS             -fdefault-real-8 -O0 -g -fbacktrace -funroll-all-loops -fcray-pointer -ffree-line-length-none -fcheck=all -finit-real=nan
-%FFLAGS              %FCFLAGS
-%LD                  %FC
-%LDFLAGS             
-%FPPFLAGS            -P -traditional
-%AR                  ar
-%ARFLAGS             rs
-%MK                  make
-%USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
-%USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
-
-%CC                  cc
-%CFLAGS              -O0
diff --git a/makenemo b/makenemo
index 14caf82a4..68a08ab1a 100755
--- a/makenemo
+++ b/makenemo
@@ -84,9 +84,8 @@ set -o posix
 
 #-
 ##- Initialization of the options ---
-x_d=''; x_h=''; x_n=''; x_r='';
-x_u=''; x_a=''; x_m=''; x_t='';
-x_c='';
+x_d=''; x_h=''; x_n=''; x_r=''; x_c='';
+x_u=''; x_a=''; x_m=''; x_t=''; x_b='';
 x_j='1'; x_e='none'; x_s='src'; x_v='1'
 
 ##- Local variables ---
@@ -112,7 +111,7 @@ export PATH=${MAIN_DIR}/ext/FCM/bin:$PATH
 
 #-
 #- Choice of the options ---
-while getopts :hd:n:r:u:a:m:j:e:s:v:t:k: option; do
+while getopts :hd:n:r:u:a:m:j:e:s:v:t:k:b option; do
 
 	case $option in
 		('h') cat <<EOF
@@ -132,6 +131,7 @@ Mandatory
 
 Optional
    -d    New set of sub-components (subfolders from ./src directory)
+   -b    Compile Nemo in debug mode (if %DEBUG_FCFLAGS is defined in arch file)
    -e    Path for alter patch  location (default: 'MY_SRC' in configuration folder)
    -h    Print this help
    -j    Number of processes to compile (0: dry run with no build)
@@ -151,12 +151,12 @@ Examples
         Removal        : ./makenemo -n ... clean_config
 EOF
 				exit 0       ;;
-	  	('d') x_d=${OPTARG};; ('n') x_n=${OPTARG};; ('r') x_r=${OPTARG};; ('u') x_u=${OPTARG};;
-		('a') x_a=${OPTARG};; ('m') x_m=${OPTARG};; ('j') x_j=${OPTARG};; ('t') x_t=${OPTARG};;
-		('e') x_e=(${OPTARG});; ('s') x_s=${OPTARG};; ('v') x_v=${OPTARG}                      ;;
-		('k') chk_key=${OPTARG}                                                              ;;
-		(':') echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;	exit 2             ;;
-		('?') echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;	exit 2             ;;
+		('b') x_b="True"   ;;   ('n') x_n=${OPTARG};; ('r') x_r=${OPTARG};; ('u') x_u=${OPTARG};;
+		('a') x_a=${OPTARG};;   ('m') x_m=${OPTARG};; ('j') x_j=${OPTARG};; ('t') x_t=${OPTARG};;
+		('e') x_e=(${OPTARG});; ('s') x_s=${OPTARG};; ('v') x_v=${OPTARG};; ('d') x_d=${OPTARG};;
+		('k') chk_key=${OPTARG}                                                                ;;
+		(':') echo ${b_n}" : -"${OPTARG}" option : missing value" 1>&2;	exit 2                 ;;
+		('?') echo ${b_n}" : -"${OPTARG}" option : not supported" 1>&2;	exit 2                 ;;
 	esac
 
 done
@@ -189,6 +189,7 @@ DEMO_CONF=${x_a}
 RMT_CONF=${x_u}
 TML_CONF=${REF_CONF}
 export NEMO_DIR=${MAIN_DIR}/${x_s}
+NEMO_DBG=${x_b}
 
 [ "${CMP_NAM}" == 'all' ] && . ${COMPIL_DIR}/Flist_archfile.sh all && exit
 
diff --git a/mk/Fcheck_archfile.sh b/mk/Fcheck_archfile.sh
index 0fa3c884d..92ee4b63d 100755
--- a/mk/Fcheck_archfile.sh
+++ b/mk/Fcheck_archfile.sh
@@ -74,7 +74,8 @@ EOF
     done < $1
 }
 # cleaning related to the old version
-rm -f $( find ${COMPIL_DIR} -type l -name $1 -print )
+rm -f $( find ${COMPIL_DIR} -type f -name $1 -print )
+
 #
 if [ ${#3} -eq 0 ]; then # arch not specified
     if [ ! -f ${COMPIL_DIR}/arch.history ]; then
@@ -213,3 +214,18 @@ do
     fi
 done
 
+# Nemo debug ?
+if [ -n "${NEMO_DBG}" ]; then
+    if [ $( grep -c "^%DEBUG_FCFLAGS" ${COMPIL_DIR}/$1 ) -eq 0 ]; then
+       echo "ERROR: You must defined '%DEBUG_FCFLAGS' in your arch file if you want to compile Nemo in debug mode using '-d' option"
+       exit 1
+    fi
+    # duplicate the lines starting with %DEBUG_XXX and replace, in the duplicated line, %DEBUG_XXX by %XXX
+    sed -i "/^%DEBUG_/{p;s/^%DEBUG_\([^ ]*\)/%\1/;}" ${COMPIL_DIR}/$1
+else
+    if [ $( grep -q "^%PROD_FCFLAGS" ${COMPIL_DIR}/$1 ) -eq 0 ]; then
+        echo "WARNING: '%PROD_FCFLAGS' not defined in your arch file, makenemo will use '%FCFLAGS' instead"
+    fi
+    # duplicate the lines starting with %PROD_XXX and replace, in the duplicated line, %PROD_XXX by %XXX
+    sed -i "/^%PROD_/{p;s/^%PROD_\([^ ]*\)/%\1/;}" ${COMPIL_DIR}/$1
+fi
diff --git a/sette/BATCH_TEMPLATE/batch-X64_AA_INTEL_OMPI_DEBUG b/sette/BATCH_TEMPLATE/batch-X64_AA_INTEL_OMPI_DEBUG
deleted file mode 120000
index 11d73e632..000000000
--- a/sette/BATCH_TEMPLATE/batch-X64_AA_INTEL_OMPI_DEBUG
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_AA_INTEL_OMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI_DEBUG b/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI_DEBUG
deleted file mode 120000
index b77eb07f1..000000000
--- a/sette/BATCH_TEMPLATE/batch-X64_BELENOS_INTEL_IMPI_DEBUG
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_BELENOS_INTEL_IMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-X64_IRENE_DEBUG b/sette/BATCH_TEMPLATE/batch-X64_IRENE_DEBUG
deleted file mode 100644
index c9535d290..000000000
--- a/sette/BATCH_TEMPLATE/batch-X64_IRENE_DEBUG
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/bash
-#MSUB -T 1790                # elapsed time limit in seconds   (60 minutes)
-#MSUB -r SETTE_JOB           # Job name
-#MSUB -o sette.jobid_%I.txt  # standard output
-#MSUB -e sette.jobid_%I.txt  # standard error
-#MSUB -n NPROCS              # Total number of mpi task to use
-#MSUB -A   gen7451          # project name
-#MSUB -q   skylake          # (queue name) only for thin nodes
-#MSUB -m store,work,scratch
-##########################################################################
-#
-# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
-# (via sed operating on this template job file). 
-#
-  OCEANCORES=NPROCS
-  export SETTE_DIR=DEF_SETTE_DIR
-#
-# set up mpp computing environment
-#
-# Local settings for machine BULL (TITANE at CCRT France)
-#
-export MPIRUN="ccc_mprun -n $OCEANCORES"
-
-#
-# load sette functions (only post_test_tidyup needed)
-#
-  . ${SETTE_DIR}/all_functions.sh
-#
-
-# modules to load
-
-# Don't remove neither change the following line
-# BODY
-
-#
-# These variables are needed by post_test_tidyup function in all_functions.sh
-#
-  export EXE_DIR=DEF_EXE_DIR
-  export INPUT_DIR=DEF_INPUT_DIR
-  export CONFIG_DIR=DEF_CONFIG_DIR
-  export TOOLS_DIR=DEF_TOOLS_DIR
-  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
-  export NEW_CONF=DEF_NEW_CONF
-  export CMP_NAM=DEF_CMP_NAM
-  export TEST_NAME=DEF_TEST_NAME
-#
-# end of set up
-###############################################################
-#
-# change to the working directory 
-#
-cd ${EXE_DIR}
-
-  echo Running on host `hostname`
-  echo Time is `date`
-  echo Directory is `pwd`
-# 
-#  Run the parallel MPI executable 
-#
-  echo "Running time ${MPIRUN} ./nemo"
-#
-  if [ MPI_FLAG == "yes" ]; then
-     time ${MPIRUN} ./nemo
-  else
-     time ./nemo
-  fi
-
-#
-  post_test_tidyup
-
-# END_BODY
-# Don't remove neither change the previous line
-
-
-  exit
-
diff --git a/sette/BATCH_TEMPLATE/batch-X64_IRENE_GCC_DEBUG b/sette/BATCH_TEMPLATE/batch-X64_IRENE_GCC_DEBUG
deleted file mode 100644
index 9dd3bcc6a..000000000
--- a/sette/BATCH_TEMPLATE/batch-X64_IRENE_GCC_DEBUG
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/bash
-#MSUB -T 1790                # elapsed time limit in seconds   (60 minutes)
-#MSUB -r SETTE_JOB           # Job name
-#MSUB -o sette.jobid_%I.txt  # standard output
-#MSUB -e sette.jobid_%I.txt  # standard error
-#MSUB -n NPROCS              # Total number of mpi task to use
-#MSUB -A   gen7451          # project name
-#MSUB -q   skylake          # (queue name) only for thin nodes
-#MSUB -m store,work,scratch
-##########################################################################
-#
-# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
-# (via sed operating on this template job file). 
-#
-  OCEANCORES=NPROCS
-  export SETTE_DIR=DEF_SETTE_DIR
-#
-# set up mpp computing environment
-#
-  set +vx
-  module purge
-  module load gnu/8.3.0
-  module load flavor/buildcompiler/gcc/8
-  module load flavor/buildmpi/openmpi/2.0
-  module load flavor/hdf5/parallel
-  module load mpi/openmpi/2.0.4
-  module load hdf5/1.8.20
-  module load netcdf-c/4.6.0
-  module load netcdf-fortran/4.4.4
-#
-# Local settings for machine BULL (TITANE at CCRT France)
-#
-  export MPIRUN="ccc_mprun -n $OCEANCORES"
-
-#
-# load sette functions (only post_test_tidyup needed)
-#
-  . ${SETTE_DIR}/all_functions.sh
-#
-
-# modules to load
-
-# Don't remove neither change the following line
-# BODY
-
-#
-# These variables are needed by post_test_tidyup function in all_functions.sh
-#
-  export EXE_DIR=DEF_EXE_DIR
-  export INPUT_DIR=DEF_INPUT_DIR
-  export CONFIG_DIR=DEF_CONFIG_DIR
-  export TOOLS_DIR=DEF_TOOLS_DIR
-  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
-  export NEW_CONF=DEF_NEW_CONF
-  export CMP_NAM=DEF_CMP_NAM
-  export TEST_NAME=DEF_TEST_NAME
-#
-# end of set up
-###############################################################
-#
-# change to the working directory 
-#
-cd ${EXE_DIR}
-
-  echo Running on host `hostname`
-  echo Time is `date`
-  echo Directory is `pwd`
-# 
-#  Run the parallel MPI executable 
-#
-  echo "Running time ${MPIRUN} ./nemo"
-#
-  if [ MPI_FLAG == "yes" ]; then
-     time ${MPIRUN} ./nemo
-  else
-     time ./nemo
-  fi
-
-#
-  post_test_tidyup
-
-# END_BODY
-# Don't remove neither change the previous line
-
-
-  exit
-
diff --git a/sette/BATCH_TEMPLATE/batch-X64_JEANZAY_DEBUG b/sette/BATCH_TEMPLATE/batch-X64_JEANZAY_DEBUG
deleted file mode 100644
index a26c4b222..000000000
--- a/sette/BATCH_TEMPLATE/batch-X64_JEANZAY_DEBUG
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-#SBATCH -A GROUP_IDRIS@cpu
-#SBATCH --job-name=SETTE_JOB      # nom du job
-#SBATCH --partition=cpu_p1        # Nom de la partition d'exécution
-#SBATCH --ntasks=NPROCS                # Nombre total de processus MPI
-#SBATCH --ntasks-per-node=40       # Nombre de processus MPI par noeud
-# /!\ Attention, la ligne suivante est trompeuse mais dans le vocabulaire
-# de Slurm "multithread" fait bien référence à l'hyperthreading.
-#SBATCH --hint=nomultithread       # 1 processus MPI par coeur physique (pas d'hyperthreading)
-#SBATCH --time=00:29:00            # Temps d’exécution maximum demande (HH:MM:SS)
-#SBATCH --output=sette.jobid_%j.out  # Nom du fichier de sortie
-#SBATCH --error=sette.jobid_%j.out   # Nom du fichier d'erreur (ici commun avec la sortie)
-##########################################################################
-#
-# Test specific settings. Do not hand edit these lines; the fcm_job.sh script will set these
-# (via sed operating on this template job file). 
-#
-  OCEANCORES=NPROCS
-  export SETTE_DIR=DEF_SETTE_DIR
-#
-# set up mpp computing environment
-#
-# Local settings for machine BULL (TITANE at CCRT France)
-#
-export MPIRUN="srun --mpi=pmi2 --cpu-bind=cores -K1"
-
-#
-# load sette functions (only post_test_tidyup needed)
-#
-  . ${SETTE_DIR}/all_functions.sh
-#
-
-# modules to load
-
-# Don't remove neither change the following line
-# BODY
-
-#
-# These variables are needed by post_test_tidyup function in all_functions.sh
-#
-  export EXE_DIR=DEF_EXE_DIR
-  export INPUT_DIR=DEF_INPUT_DIR
-  export CONFIG_DIR=DEF_CONFIG_DIR
-  export TOOLS_DIR=DEF_TOOLS_DIR
-  export NEMO_VALIDATION_DIR=DEF_NEMO_VALIDATION
-  export NEW_CONF=DEF_NEW_CONF
-  export CMP_NAM=DEF_CMP_NAM
-  export TEST_NAME=DEF_TEST_NAME
-#
-# end of set up
-###############################################################
-#
-# change to the working directory 
-#
-cd ${EXE_DIR}
-
-  echo Running on host `hostname`
-  echo Time is `date`
-  echo Directory is `pwd`
-# 
-#  Run the parallel MPI executable 
-#
-  echo "Running time ${MPIRUN} ./nemo"
-#
-  if [ MPI_FLAG == "yes" ]; then
-     time ${MPIRUN} ./nemo
-  else
-     time ./nemo
-  fi
-
-#
-  post_test_tidyup
-
-# END_BODY
-# Don't remove neither change the previous line
-
-
-  exit
-
diff --git a/sette/BATCH_TEMPLATE/batch-X64_KARA_GCC_OMPI_DEBUG b/sette/BATCH_TEMPLATE/batch-X64_KARA_GCC_OMPI_DEBUG
deleted file mode 120000
index a2ec08987..000000000
--- a/sette/BATCH_TEMPLATE/batch-X64_KARA_GCC_OMPI_DEBUG
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_KARA_GCC_OMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI b/sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI
deleted file mode 120000
index 11d73e632..000000000
--- a/sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_AA_INTEL_OMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI_DEBUG b/sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI_DEBUG
deleted file mode 120000
index 178a7f6ea..000000000
--- a/sette/BATCH_TEMPLATE/batch-mpmd-X64_AA_INTEL_OMPI_DEBUG
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_AA_INTEL_OMPI_DEBUG
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI b/sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI
deleted file mode 120000
index b77eb07f1..000000000
--- a/sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_BELENOS_INTEL_IMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI_DEBUG b/sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI_DEBUG
deleted file mode 120000
index b77eb07f1..000000000
--- a/sette/BATCH_TEMPLATE/batch-mpmd-X64_BELENOS_INTEL_IMPI_DEBUG
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_BELENOS_INTEL_IMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI b/sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI
deleted file mode 120000
index a2ec08987..000000000
--- a/sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_KARA_GCC_OMPI
\ No newline at end of file
diff --git a/sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI_DEBUG b/sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI_DEBUG
deleted file mode 120000
index a2ec08987..000000000
--- a/sette/BATCH_TEMPLATE/batch-mpmd-X64_KARA_GCC_OMPI_DEBUG
+++ /dev/null
@@ -1 +0,0 @@
-batch-X64_KARA_GCC_OMPI
\ No newline at end of file
diff --git a/sette/all_functions.sh b/sette/all_functions.sh
index 1a459a171..4be4be5a6 100755
--- a/sette/all_functions.sh
+++ b/sette/all_functions.sh
@@ -195,7 +195,11 @@ 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]*\)$//' )
-    export NEMO_VALID=${NEMO_VALIDATION_DIR}/${CMP_NAM}/${REVISION_NB}/${NEW_CONF1}/${TEST_NAME}
+    if [[ -n "${NEMO_DEBUG}" && ! ${CMP_NAM,,} =~ ("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}
+    fi
 }
 
 # clean valid dir (move old ocean_output/run.stat and tracer to avoid checking them in case something wrong happen.
diff --git a/sette/prepare_exe_dir.sh b/sette/prepare_exe_dir.sh
index 5e6b1a011..47d5207fd 100755
--- a/sette/prepare_exe_dir.sh
+++ b/sette/prepare_exe_dir.sh
@@ -69,7 +69,11 @@ set -o posix
 if [ -z "${CUSTOM_DIR}" ]; then
   export EXE_DIR=${CONFIG_DIR}/${NEW_CONF}/${TEST_NAME}
 else
-  export EXE_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}/${NEW_CONF}/${TEST_NAME}
+  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("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}
+  fi
 fi
 mkdir -p ${EXE_DIR}
 
diff --git a/sette/sette.sh b/sette/sette.sh
index da7e29145..9c3e0a3a2 100755
--- a/sette/sette.sh
+++ b/sette/sette.sh
@@ -1,10 +1,12 @@
 #!/bin/sh
+#set -x
 # initialise user dependent variable
 export cmd=$0 ; export cmdargs=$@
 SETTE_DIR=$(cd $(dirname "$0"); pwd)
 MAIN_DIR=$(dirname $SETTE_DIR)
 export CMPL_CORES=8            # Number of threads to use for compiling
 export SETTE_STG="_ST"         # Base suffix to append to configuration name
+NEMO_DEBUG=""
 dry_run=0
 NO_REPORT=0
 #
@@ -65,13 +67,15 @@ fi
 
 # Parse command-line arguments
 if [ $# -gt 0 ]; then
-  while getopts n:x:v:g:cdrshTqQteiACFNXua option; do 
+  while getopts n:x:v:g:cybrshTqQteiACFNXua option; do
      case $option in
         c) export SETTE_CLEAN_CONFIGS='yes'
            export SETTE_SYNC_CONFIGS='yes'
            echo "-c: Configuration ${SETTE_TEST_CONFIGS[@]} will be cleaned; this option enforces also synchronisation"
            echo "";;
-        d) dry_run=1
+        y) dry_run=1
+           echo "";;
+        b) NEMO_DEBUG="-b"
            echo "";;
         r) NO_REPORT=1
            echo "";;
@@ -161,7 +165,8 @@ if [ $# -gt 0 ]; then
                echo '-g "group_suffix" single character suffix to be appended to the standard _ST suffix used'
                echo '                  for SETTE-built configurations (needed if sette.sh invocations may overlap)'
                echo '-r to execute without waiting to run sette_rpt.sh at the end (useful for chaining sette.sh invocations)'
-               echo '-d to perform a dryrun to simply report what settings will be used'
+               echo '-y to perform a dryrun to simply report what settings will be used'
+               echo '-d to compile Nemo with debug options (only if %DEBUG_FCFLAGS if defined in your arch file)'
                echo '-c to clean each configuration'
                echo '-s to synchronise the sette MY_SRC and EXP00 with the reference MY_SRC and EXPREF'
                echo '-u to run sette.sh without any user interaction. This means no checks on creating'
@@ -328,7 +333,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
+      ./sette_rpt.sh ${NEMO_DEBUG}
       exit
    fi
    sleep 10
diff --git a/sette/sette_reference-configurations.sh b/sette/sette_reference-configurations.sh
index b79c4d79f..4d22ddff5 100755
--- a/sette/sette_reference-configurations.sh
+++ b/sette/sette_reference-configurations.sh
@@ -112,7 +112,11 @@ 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 )
-  CMP_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}
+  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("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}
 
@@ -139,7 +143,7 @@ do
 # -----------
 if [ ${config} == "GYRE_PISCES" ] ;  then
     SETTE_CONFIG="GYRE_PISCES"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12    # 1 day
     else
@@ -153,7 +157,7 @@ if [ ${config} == "GYRE_PISCES" ] ;  then
     clean_config GYRE_PISCES ${SETTE_CONFIG} 'cfgs'
     #
     # GYRE uses linssh so remove key_qco if added by default
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r GYRE_PISCES -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r GYRE_PISCES -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "GYRE_PISCES" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests for GYRE_PISCES
@@ -286,7 +290,7 @@ fi
 # -----------------
 if [ ${config} == "ORCA2_ICE_PISCES" ] ;  then
     SETTE_CONFIG="ORCA2_ICE_PISCES"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 1 day
     else
@@ -299,7 +303,7 @@ if [ ${config} == "ORCA2_ICE_PISCES" ] ;  then
     sync_config  ORCA2_ICE_PISCES ${SETTE_CONFIG} 'cfgs'
     clean_config ORCA2_ICE_PISCES ${SETTE_CONFIG} 'cfgs'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_ICE_PISCES -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_ICE_PISCES -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "ORCA2_ICE_PISCES" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests for ORCA2_ICE_PISCES
@@ -573,7 +577,7 @@ fi
 # ----------------
 if [ ${config} == "ORCA2_OFF_PISCES" ] ;  then
     SETTE_CONFIG="ORCA2_OFF_PISCES"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 4 days
     else
@@ -587,7 +591,7 @@ if [ ${config} == "ORCA2_OFF_PISCES" ] ;  then
     clean_config ${SETTE_CONFIG} ORCA2_OFF_PISCES_ST 'cfgs'
     #
     # ORCA2_OFF_PISCES uses linssh so remove key_qco if added by default
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_OFF_PISCES -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_OFF_PISCES -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "ORCA2_OFF_PISCES" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests for ORCA2_OFF_PISCES
@@ -750,7 +754,7 @@ fi
 # -----
 if [ ${config} == "AMM12" ] ;  then
     SETTE_CONFIG="AMM12"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12   # 3 h
     else
@@ -763,7 +767,7 @@ if [ ${config} == "AMM12" ] ;  then
     sync_config  AMM12 ${SETTE_CONFIG} 'cfgs'
     clean_config AMM12 ${SETTE_CONFIG} 'cfgs'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AMM12 -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AMM12 -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "AMM12" ] && [ ${DO_RESTART} == "1" ] ;  then
     ## Restartability tests for AMM12
@@ -884,7 +888,7 @@ fi
 # ---------
 if [ ${config} == "SAS" ] ;  then
     SETTE_CONFIG="ORCA2_SAS_ICE"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 1 day
     else
@@ -898,7 +902,7 @@ if [ ${config} == "SAS" ] ;  then
     clean_config ORCA2_SAS_ICE ${SETTE_CONFIG} 'cfgs'
     #
     # ORCA2_SAS_ICE uses linssh so remove key_qco if added by default
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_SAS_ICE -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_SAS_ICE -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "SAS" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests
@@ -965,7 +969,7 @@ fi
 
 if [ ${config} == "SAS" ] && [ ${DO_REPRO} == "1" ] ;  then
 ## Reproducibility tests
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16  # 1 day
     else
@@ -1033,7 +1037,7 @@ fi
 if [ ${config} == "ORCA2_ICE_OBS" ] ;  then
     SETTE_CONFIG="ORCA2_ICE_OBS"${SETTE_STG}
 ## Reproducibility tests
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16  # 1 day
     else
@@ -1045,7 +1049,7 @@ if [ ${config} == "ORCA2_ICE_OBS" ] ;  then
     sync_config  ORCA2_ICE_PISCES ${SETTE_CONFIG} 'cfgs'
     clean_config ORCA2_ICE_PISCES ${SETTE_CONFIG} 'cfgs'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_ICE_PISCES -d "OCE ICE" -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "key_asminc ${ADD_KEYS}" del_key "key_top ${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r ORCA2_ICE_PISCES -d "OCE ICE" -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "key_asminc ${ADD_KEYS}" del_key "key_top ${DEL_KEYS}"
 fi
 if [ ${config} == "ORCA2_ICE_OBS" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Reproducibility tests
@@ -1153,7 +1157,7 @@ fi
 # -----------
 if [ ${config} == "AGRIF" ] ;  then
     SETTE_CONFIG="AGRIF_DEMO"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=4   # 6h
     else
@@ -1171,7 +1175,7 @@ if [ ${config} == "AGRIF" ] ;  then
     #
     # AGRIF_DEMO does not yet support nn_hls=2 => key_loop_fusion can not be used
 #    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AGRIF_DEMO -j ${CMPL_CORES} add_key "${ADD_KEYS/key_loop_fusion}" del_key "${DEL_KEYS}"
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AGRIF_DEMO -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AGRIF_DEMO -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "AGRIF" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests
@@ -1436,7 +1440,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 [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=16   # 1d
     else
@@ -1487,7 +1491,7 @@ if [ ${config} == "AGRIF" ] && [ ${DO_CORRUPT} == "1" ] ;  then
     clean_config AGRIF_DEMO ${SETTE_CONFIG} 'cfgs'
     #
     # AGRIF_DEMO does not yet support nn_hls=2 => key_loop_fusion can not be used
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AGRIF_DEMO -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS/key_loop_fusion}" del_key "key_agrif ${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r AGRIF_DEMO -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS/key_loop_fusion}" del_key "key_agrif ${DEL_KEYS}"
     cd ${SETTE_DIR}
     . ./prepare_exe_dir.sh
     set_valid_dir
@@ -1521,7 +1525,7 @@ fi
 # -------
 if [ ${config} == "WED025" ] ;  then
     SETTE_CONFIG="WED025"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12   # 4h
     else
@@ -1535,7 +1539,7 @@ if [ ${config} == "WED025" ] ;  then
     clean_config WED025 ${SETTE_CONFIG} 'cfgs'
     #
     # WED025 uses ln_hpg_isf so remove key_qco if added by default
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r WED025 -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -r WED025 -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "WED025" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests
diff --git a/sette/sette_rpt.sh b/sette/sette_rpt.sh
index dfc9db7a3..89d3d4498 100755
--- a/sette/sette_rpt.sh
+++ b/sette/sette_rpt.sh
@@ -1,5 +1,4 @@
 #!/bin/bash -f
-# set -vx
 # simple SETTE report generator.
 #
 # This version should be run in the SETTE directory. 
@@ -477,7 +476,7 @@ function identictest(){
   mach=${COMPILER}
 # overwrite revision (later) or compiler
   if [ $# -gt 0 ]; then
-    while getopts r:R:c:v:V:uh option; do 
+    while getopts r:R:c:v:V:ubh option; do
        case $option in
           c) mach=$OPTARG;;
           r) rev=$OPTARG;;
@@ -491,6 +490,8 @@ function identictest(){
              fi
              ;;
           u) USER_INPUT='no';;
+          b) mach=${mach//_DEBUG}_DEBUG
+             DEBUG="with DEBUG (-b) option";;
           h | *) echo ''
                  echo 'sette_rpt.sh : ' 
                  echo '     display result for the latest change'
@@ -506,6 +507,7 @@ function identictest(){
                  echo '     2nd validation sub-directory below NEMO_VALIDATION_DIR'
                  echo '     if set the comparison is between two subdirectory trees beneath NEMO_VALIDATION_DIR'
                  echo ' -u to run sette_rpt.sh without any user interaction'
+                 echo ' -b to check DEBUG directory of COMPILER_name'
                  echo ''
                  exit 42;;
        esac
@@ -584,7 +586,7 @@ if [[ $? == 0 ]] ; then
      branchname="Unknown"
    fi
   else
-   revision=`git rev-list --abbrev-commit origin | head -1l`
+   revision=`git rev-list --abbrev-commit HEAD | head -1l`
   fi
 else
   branchname="Unknown"
@@ -612,7 +614,7 @@ else
  echo "       $branchname @ $revision"
 fi
 echo ""
-echo "       on $COMPILER arch file"
+echo "       on $COMPILER arch file $DEBUG"
 echo ""
 
 #
diff --git a/sette/sette_test-cases.sh b/sette/sette_test-cases.sh
index 629fa0def..db9c81dcf 100755
--- a/sette/sette_test-cases.sh
+++ b/sette/sette_test-cases.sh
@@ -113,7 +113,11 @@ TOOLS_DIR=${MAIN_DIR}/tools
 
 if [ -n "${CUSTOM_DIR}" ]; then
   NEMO_REV=$( git rev-parse --short HEAD 2> /dev/null )
-  CMP_DIR=${CUSTOM_DIR}/${SETTE_SUB_VAL}_${NEMO_REV}
+  if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("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}
 # Copy job_batch_COMPILER file for specific compiler into job_batch_template
@@ -139,7 +143,7 @@ do
 # ---------
 if [ ${config} == "OVERFLOW" ] ;  then
     SETTE_CONFIG="OVERFLOW"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -153,7 +157,7 @@ if [ ${config} == "OVERFLOW" ] ;  then
     #
     sync_config  OVERFLOW ${SETTE_CONFIG} 'tests'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a OVERFLOW -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a OVERFLOW -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "OVERFLOW" ] && [ ${DO_RESTART} == "1" ] ;  then
     ## Restartability tests for OVERFLOW
@@ -211,7 +215,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 [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -255,7 +259,7 @@ fi
 # --------------
 if [ ${config} == "LOCK_EXCHANGE" ] ;  then
     SETTE_CONFIG="LOCK_EXCHANGE"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -270,7 +274,7 @@ if [ ${config} == "LOCK_EXCHANGE" ] ;  then
     #
     sync_config  LOCK_EXCHANGE ${SETTE_CONFIG} 'tests'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a LOCK_EXCHANGE -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a LOCK_EXCHANGE -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "LOCK_EXCHANGE" ] && [ ${DO_RESTART} == "1" ] ;  then
     ## Restartability tests for LOCK_EXCHANGE
@@ -327,7 +331,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 [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -373,7 +377,7 @@ fi
 # ---------
 if [ ${config} == "VORTEX" ] ;  then
     SETTE_CONFIG="VORTEX"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -389,7 +393,7 @@ if [ ${config} == "VORTEX" ] ;  then
     #
     sync_config  VORTEX ${SETTE_CONFIG} 'tests'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a VORTEX -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES}  add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a VORTEX -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES}  add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "VORTEX" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests for VORTEX
@@ -567,7 +571,7 @@ fi
 # ---------
 if [ ${config} == "ICE_AGRIF" ] ;  then
     SETTE_CONFIG="ICE_AGRIF"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=10
     else
@@ -584,7 +588,7 @@ if [ ${config} == "ICE_AGRIF" ] ;  then
     sync_config  ICE_AGRIF ${SETTE_CONFIG} 'tests'
     #
     # ICE_AGRIF uses linssh so remove key_qco if added by default
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a ICE_AGRIF -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES}  add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a ICE_AGRIF -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES}  add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "ICE_AGRIF" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests for ICE_AGRIF
@@ -766,7 +770,7 @@ fi
 # ------
 if [ ${config} == "ISOMIP+" ] ;  then
     SETTE_CONFIG="ISOMIP+"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -782,7 +786,7 @@ if [ ${config} == "ISOMIP+" ] ;  then
     sync_config  ISOMIP+ ${SETTE_CONFIG} 'tests'
     #
     # ISOMIP+ uses ln_hpg_isf so remove key_qco if added by default
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a ISOMIP+ -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a ISOMIP+ -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES} add_key "${ADD_KEYS/key_qco/}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "ISOMIP+" ] && [ ${DO_RESTART} == "1" ] ;  then
 ## Restartability tests
@@ -846,7 +850,7 @@ fi
 
 if [ ${config} == "ISOMIP+" ] && [ ${DO_REPRO} == "1" ] ;  then
 ## Reproducibility tests
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -911,7 +915,7 @@ fi
 # ---------
 if [ ${config} == "SWG" ] && [ ${USING_QCO} == "yes" ] ;  then
     SETTE_CONFIG="SWG"${SETTE_STG}
-    if [ $( echo ${CMP_NAM} | grep -ic debug ) -eq 1 ]
+    if [[ -n "${NEMO_DEBUG}" || ${CMP_NAM,,} =~ ("debug"|"dbg") ]]
     then
 	ITEND=12
     else
@@ -926,7 +930,7 @@ if [ ${config} == "SWG" ] && [ ${USING_QCO} == "yes" ] ;  then
     #
     sync_config  SWG ${SETTE_CONFIG} 'tests'
     #
-    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a SWG -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 -j ${CMPL_CORES}  add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
+    . ./makenemo -m ${CMP_NAM} -n ${SETTE_CONFIG} -a SWG -t ${CMP_DIR:-${CONFIG_DIR0}} -k 0 ${NEMO_DEBUG} -j ${CMPL_CORES}  add_key "${ADD_KEYS}" del_key "${DEL_KEYS}"
 fi
 if [ ${config} == "SWG" ] && [ ${DO_RESTART} == "1" ] && [ ${USING_QCO} == "yes" ] ;  then
 ## Restartability tests for SWG
-- 
GitLab