From ec13b89c5023c40c200db1e5a7c999d66e8cf6b6 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Fri, 17 May 2019 17:45:42 +0100
Subject: [PATCH 01/18] Add gitignore

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..19665ba
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# log file for main1.sh script
+SCRIPTS/main_output.txt
-- 
GitLab


From af25b9fed9a5f8fd7429bc28abf17646e9c03c18 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Fri, 17 May 2019 17:48:25 +0100
Subject: [PATCH 02/18] Updates for restructed dir

---
 ARCH/arch-XC_ARCHER_INTEL.fcm                 |   61 +
 MY_SRC/bdyini.F90                             | 1743 +++++++++++++++++
 MY_SRC/diaharm.F90                            |  848 ++++++++
 MY_SRC/diaharm_fast.F90                       |  857 ++++++++
 MY_SRC/dommsk.F90                             |  303 +++
 MY_SRC/dtatsd.F90                             |  298 +++
 MY_SRC/dynnxt.F90                             |  428 ++++
 MY_SRC/dynspg.F90                             |  242 +++
 MY_SRC/par_oce.F90                            |   90 +
 MY_SRC/sbctide.F90                            |  137 ++
 MY_SRC/step.F90                               |  364 ++++
 MY_SRC/step_oce.F90                           |  127 ++
 MY_SRC/tide_FES14.h90                         |  114 ++
 MY_SRC/tide_mod.F90                           |  430 ++++
 MY_SRC/tideini.F90                            |  125 ++
 MY_SRC/usrdef_istate.F90                      |   73 +
 MY_SRC/usrdef_sbc.F90                         |   86 +
 .../INITIAL_CONDITION/sosie_initcd_T          |   26 +
 .../f_files/dynnxt.F90                        |  428 ++++
 .../f_files/dynspg.F90                        |  242 +++
 SCRIPTS/make_nemo.sh                          |   12 +-
 SCRIPTS/make_paths.sh                         |    2 +-
 cpp_file.fcm                                  |    6 +
 23 files changed, 7035 insertions(+), 7 deletions(-)
 create mode 100755 ARCH/arch-XC_ARCHER_INTEL.fcm
 create mode 100755 MY_SRC/bdyini.F90
 create mode 100755 MY_SRC/diaharm.F90
 create mode 100755 MY_SRC/diaharm_fast.F90
 create mode 100755 MY_SRC/dommsk.F90
 create mode 100755 MY_SRC/dtatsd.F90
 create mode 100644 MY_SRC/dynnxt.F90
 create mode 100644 MY_SRC/dynspg.F90
 create mode 100755 MY_SRC/par_oce.F90
 create mode 100755 MY_SRC/sbctide.F90
 create mode 100755 MY_SRC/step.F90
 create mode 100755 MY_SRC/step_oce.F90
 create mode 100755 MY_SRC/tide_FES14.h90
 create mode 100755 MY_SRC/tide_mod.F90
 create mode 100755 MY_SRC/tideini.F90
 create mode 100755 MY_SRC/usrdef_istate.F90
 create mode 100755 MY_SRC/usrdef_sbc.F90
 create mode 100644 NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/sosie_initcd_T
 create mode 100644 NAMELISTS_AND_FORTRAN_FILES/f_files/dynnxt.F90
 create mode 100644 NAMELISTS_AND_FORTRAN_FILES/f_files/dynspg.F90
 create mode 100755 cpp_file.fcm

diff --git a/ARCH/arch-XC_ARCHER_INTEL.fcm b/ARCH/arch-XC_ARCHER_INTEL.fcm
new file mode 100755
index 0000000..c268c05
--- /dev/null
+++ b/ARCH/arch-XC_ARCHER_INTEL.fcm
@@ -0,0 +1,61 @@
+# compiler options for Archer CRAY XC-30 (using intel compiler)
+#
+# 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_iomput is activated)
+# XIOS_LIB    xios library         (taken into accound only if key_iomput 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 $)
+#
+%NCDF_HOME           $NETCDF_DIR
+%HDF5_HOME           $HDF5_DIR
+%XIOS_HOME           /work/n01/n01/$USER/XIOS
+#OASIS_HOME          
+
+%NCDF_INC            -I%NCDF_HOME/include -I%HDF5_HOME/include
+%NCDF_LIB            -L%HDF5_HOME/lib -L%NCDF_HOME/lib -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz
+%XIOS_INC            -I%XIOS_HOME/inc 
+%XIOS_LIB            -L%XIOS_HOME/lib -lxios
+#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                  ftn
+%FCFLAGS             -integer-size 32 -real-size 64 -g -O3 -fp-model source -zero -fpp -warn all
+%FFLAGS              -integer-size 32 -real-size 64 -g -O3 -fp-model source -zero -fpp -warn all
+%LD                  CC -Wl,"--allow-multiple-definition"
+%FPPFLAGS            -P -C -traditional
+%LDFLAGS
+%AR                  ar 
+%ARFLAGS             -r
+%MK                  gmake
+%USER_INC            %XIOS_INC %NCDF_INC
+%USER_LIB            %XIOS_LIB %NCDF_LIB
+#USER_INC            %XIOS_INC %OASIS_INC %NCDF_INC
+#USER_LIB            %XIOS_LIB %OASIS_LIB %NCDF_LIB
+
+%CC                  cc
+%CFLAGS              -O0
diff --git a/MY_SRC/bdyini.F90 b/MY_SRC/bdyini.F90
new file mode 100755
index 0000000..ef881b0
--- /dev/null
+++ b/MY_SRC/bdyini.F90
@@ -0,0 +1,1743 @@
+MODULE bdyini
+   !!======================================================================
+   !!                       ***  MODULE  bdyini  ***
+   !! Unstructured open boundaries : initialisation
+   !!======================================================================
+   !! History :  1.0  !  2005-01  (J. Chanut, A. Sellar)  Original code
+   !!             -   !  2007-01  (D. Storkey) Update to use IOM module
+   !!             -   !  2007-01  (D. Storkey) Tidal forcing
+   !!            3.0  !  2008-04  (NEMO team)  add in the reference version
+   !!            3.3  !  2010-09  (E.O'Dea) updates for Shelf configurations
+   !!            3.3  !  2010-09  (D.Storkey) add ice boundary conditions
+   !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
+   !!            3.4  !  2012     (J. Chanut) straight open boundary case update
+   !!            3.5  !  2012     (S. Mocavero, I. Epicoco) optimization of BDY communications
+   !!            3.7  !  2016     (T. Lovato) Remove bdy macro, call here init for dta and tides
+   !!----------------------------------------------------------------------
+   !!   bdy_init      : Initialization of unstructured open boundaries
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain
+   USE bdy_oce        ! unstructured open boundary conditions
+   USE bdydta         ! open boundary cond. setting   (bdy_dta_init routine)
+   USE bdytides       ! open boundary cond. setting   (bdytide_init routine)
+   USE sbctide        ! Tidal forcing or not
+   USE phycst   , ONLY: rday
+   !
+   USE in_out_manager ! I/O units
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! for mpp_sum  
+   USE iom            ! I/O
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   bdy_init   ! routine called in nemo_init
+
+   INTEGER, PARAMETER ::   jp_nseg = 100   ! 
+   INTEGER, PARAMETER ::   nrimmax =  20   ! maximum rimwidth in structured
+                                               ! open boundary data files
+   ! Straight open boundary segment parameters:
+   INTEGER  ::   nbdysege, nbdysegw, nbdysegn, nbdysegs 
+   INTEGER, DIMENSION(jp_nseg) ::   jpieob, jpjedt, jpjeft, npckge   !
+   INTEGER, DIMENSION(jp_nseg) ::   jpiwob, jpjwdt, jpjwft, npckgw   !
+   INTEGER, DIMENSION(jp_nseg) ::   jpjnob, jpindt, jpinft, npckgn   !
+   INTEGER, DIMENSION(jp_nseg) ::   jpjsob, jpisdt, jpisft, npckgs   !
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: bdyini.F90 7646 2017-02-06 09:25:03Z timgraham $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE bdy_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_init  ***
+      !!
+      !! ** Purpose :   Initialization of the dynamics and tracer fields with
+      !!              unstructured open boundaries.
+      !!
+      !! ** Method  :   Read initialization arrays (mask, indices) to identify
+      !!              an unstructured open boundary
+      !!
+      !! ** Input   :  bdy_init.nc, input file for unstructured open boundaries
+      !!----------------------------------------------------------------------
+      NAMELIST/nambdy/ ln_bdy, nb_bdy, ln_coords_file, cn_coords_file,         &
+         &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
+         &             cn_dyn3d, nn_dyn3d_dta, cn_tra, nn_tra_dta,             &
+         &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
+         &             cn_ice_lim, nn_ice_lim_dta,                             &
+         &             rn_ice_tem, rn_ice_sal, rn_ice_age,                     &
+         &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
+         !
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('bdy_init')
+
+      ! ------------------------
+      ! Read namelist parameters
+      ! ------------------------
+      REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries
+      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries
+      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nambdy in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, nambdy )
+
+      ! -----------------------------------------
+      ! unstructured open boundaries use control
+      ! -----------------------------------------
+      IF ( ln_bdy ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'bdy_init : initialization of open boundaries'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~'
+         !
+         ! Open boundaries definition (arrays and masks)
+         CALL bdy_segs
+         !
+         ! Open boundaries initialisation of external data arrays
+         CALL bdy_dta_init
+         !
+         ! Open boundaries initialisation of tidal harmonic forcing
+         IF( ln_tide ) CALL bdytide_init
+         !
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'bdy_init : open boundaries not used (ln_bdy = F)'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~'
+         !
+      ENDIF
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('bdy_init')
+      !
+   END SUBROUTINE bdy_init
+   
+   SUBROUTINE bdy_segs
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_init  ***
+      !!         
+      !! ** Purpose :   Definition of unstructured open boundaries.
+      !!
+      !! ** Method  :   Read initialization arrays (mask, indices) to identify 
+      !!              an unstructured open boundary
+      !!
+      !! ** Input   :  bdy_init.nc, input file for unstructured open boundaries
+      !!----------------------------------------------------------------------      
+
+      ! local variables
+      !-------------------
+      INTEGER  ::   ib_bdy, ii, ij, ik, igrd, ib, ir, iseg ! dummy loop indices
+      INTEGER  ::   icount, icountr, ibr_max, ilen1, ibm1  ! local integers
+      INTEGER  ::   iwe, ies, iso, ino, inum, id_dummy     !   -       -
+      INTEGER  ::   igrd_start, igrd_end, jpbdta           !   -       -
+      INTEGER  ::   jpbdtau, jpbdtas                       !   -       -
+      INTEGER  ::   ib_bdy1, ib_bdy2, ib1, ib2             !   -       -
+      INTEGER  ::   i_offset, j_offset                     !   -       -
+      INTEGER , POINTER  ::  nbi, nbj, nbr                 ! short cuts
+      REAL(wp), POINTER  ::  flagu, flagv                  !    -   -
+      REAL(wp), POINTER, DIMENSION(:,:)       ::   pmask    ! pointer to 2D mask fields
+      REAL(wp) ::   zefl, zwfl, znfl, zsfl                 ! local scalars
+      INTEGER, DIMENSION (2)                  ::   kdimsz
+      INTEGER, DIMENSION(jpbgrd,jp_bdy)       ::   nblendta         ! Length of index arrays 
+      INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbidta, nbjdta   ! Index arrays: i and j indices of bdy dta
+      INTEGER, ALLOCATABLE, DIMENSION(:,:,:)  ::   nbrdta           ! Discrete distance from rim points
+      CHARACTER(LEN=1),DIMENSION(jpbgrd)      ::   cgrid
+      INTEGER :: com_east, com_west, com_south, com_north          ! Flags for boundaries sending
+      INTEGER :: com_east_b, com_west_b, com_south_b, com_north_b  ! Flags for boundaries receiving
+      INTEGER :: iw_b(4), ie_b(4), is_b(4), in_b(4)                ! Arrays for neighbours coordinates
+      REAL(wp), POINTER, DIMENSION(:,:)       ::   zfmask  ! temporary fmask array excluding coastal boundary condition (shlat)
+      !!
+      CHARACTER(LEN=1)                     ::   ctypebdy   !     -        - 
+      INTEGER                              ::   nbdyind, nbdybeg, nbdyend
+      !!
+      NAMELIST/nambdy_index/ ctypebdy, nbdyind, nbdybeg, nbdyend
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('bdy_segs')
+      !
+      cgrid = (/'t','u','v'/)
+
+      ! -----------------------------------------
+      ! Check and write out namelist parameters
+      ! -----------------------------------------
+!     IF( jperio /= 0 )   CALL ctl_stop( 'bdy_segs: Cyclic or symmetric,',   &
+!        &                               ' and general open boundary condition are not compatible' )
+
+      IF( nb_bdy == 0 ) THEN 
+        IF(lwp) WRITE(numout,*) 'nb_bdy = 0, NO OPEN BOUNDARIES APPLIED.'
+      ELSE
+        IF(lwp) WRITE(numout,*) 'Number of open boundary sets : ', nb_bdy
+      ENDIF
+
+      DO ib_bdy = 1,nb_bdy
+        IF(lwp) WRITE(numout,*) ' ' 
+        IF(lwp) WRITE(numout,*) '------ Open boundary data set ',ib_bdy,'------' 
+
+        IF( ln_coords_file(ib_bdy) ) THEN
+           IF(lwp) WRITE(numout,*) 'Boundary definition read from file '//TRIM(cn_coords_file(ib_bdy))
+        ELSE
+           IF(lwp) WRITE(numout,*) 'Boundary defined in namelist.'
+        ENDIF
+        IF(lwp) WRITE(numout,*)
+
+        IF(lwp) WRITE(numout,*) 'Boundary conditions for barotropic solution:  '
+        SELECT CASE( cn_dyn2d(ib_bdy) )                  
+          CASE( 'none' )         
+             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
+             dta_bdy(ib_bdy)%ll_ssh = .false.
+             dta_bdy(ib_bdy)%ll_u2d = .false.
+             dta_bdy(ib_bdy)%ll_v2d = .false.
+          CASE( 'frs' )          
+             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
+             dta_bdy(ib_bdy)%ll_ssh = .false.
+             dta_bdy(ib_bdy)%ll_u2d = .true.
+             dta_bdy(ib_bdy)%ll_v2d = .true.
+          CASE( 'flather' )      
+             IF(lwp) WRITE(numout,*) '      Flather radiation condition'
+             dta_bdy(ib_bdy)%ll_ssh = .true.
+             dta_bdy(ib_bdy)%ll_u2d = .true.
+             dta_bdy(ib_bdy)%ll_v2d = .true.
+          CASE( 'orlanski' )     
+             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
+             dta_bdy(ib_bdy)%ll_ssh = .false.
+             dta_bdy(ib_bdy)%ll_u2d = .true.
+             dta_bdy(ib_bdy)%ll_v2d = .true.
+          CASE( 'orlanski_npo' ) 
+             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
+             dta_bdy(ib_bdy)%ll_ssh = .false.
+             dta_bdy(ib_bdy)%ll_u2d = .true.
+             dta_bdy(ib_bdy)%ll_v2d = .true.
+          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn2d' )
+        END SELECT
+        IF( cn_dyn2d(ib_bdy) /= 'none' ) THEN
+           SELECT CASE( nn_dyn2d_dta(ib_bdy) )                   ! 
+              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
+              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
+              CASE( 2 )      ;   IF(lwp) WRITE(numout,*) '      tidal harmonic forcing taken from file'
+              CASE( 3 )      ;   IF(lwp) WRITE(numout,*) '      boundary data AND tidal harmonic forcing taken from files'
+              CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn2d_dta must be between 0 and 3' )
+           END SELECT
+           IF (( nn_dyn2d_dta(ib_bdy) .ge. 2 ).AND.(.NOT.ln_tide)) THEN
+             CALL ctl_stop( 'You must activate with ln_tide to add tidal forcing at open boundaries' )
+           ENDIF
+        ENDIF
+        IF(lwp) WRITE(numout,*)
+
+        IF(lwp) WRITE(numout,*) 'Boundary conditions for baroclinic velocities:  '
+        SELECT CASE( cn_dyn3d(ib_bdy) )                  
+          CASE('none')
+             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
+             dta_bdy(ib_bdy)%ll_u3d = .false.
+             dta_bdy(ib_bdy)%ll_v3d = .false.
+          CASE('frs')       
+             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
+             dta_bdy(ib_bdy)%ll_u3d = .true.
+             dta_bdy(ib_bdy)%ll_v3d = .true.
+          CASE('specified')
+             IF(lwp) WRITE(numout,*) '      Specified value'
+             dta_bdy(ib_bdy)%ll_u3d = .true.
+             dta_bdy(ib_bdy)%ll_v3d = .true.
+          CASE('neumann')
+             IF(lwp) WRITE(numout,*) '      Neumann conditions'
+             dta_bdy(ib_bdy)%ll_u3d = .false.
+             dta_bdy(ib_bdy)%ll_v3d = .false.
+          CASE('zerograd')
+             IF(lwp) WRITE(numout,*) '      Zero gradient for baroclinic velocities'
+             dta_bdy(ib_bdy)%ll_u3d = .false.
+             dta_bdy(ib_bdy)%ll_v3d = .false.
+          CASE('zero')
+             IF(lwp) WRITE(numout,*) '      Zero baroclinic velocities (runoff case)'
+             dta_bdy(ib_bdy)%ll_u3d = .false.
+             dta_bdy(ib_bdy)%ll_v3d = .false.
+          CASE('orlanski')
+             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
+             dta_bdy(ib_bdy)%ll_u3d = .true.
+             dta_bdy(ib_bdy)%ll_v3d = .true.
+          CASE('orlanski_npo')
+             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
+             dta_bdy(ib_bdy)%ll_u3d = .true.
+             dta_bdy(ib_bdy)%ll_v3d = .true.
+          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_dyn3d' )
+        END SELECT
+        IF( cn_dyn3d(ib_bdy) /= 'none' ) THEN
+           SELECT CASE( nn_dyn3d_dta(ib_bdy) )                   ! 
+              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
+              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
+              CASE DEFAULT   ;   CALL ctl_stop( 'nn_dyn3d_dta must be 0 or 1' )
+           END SELECT
+        ENDIF
+
+        IF ( ln_dyn3d_dmp(ib_bdy) ) THEN
+           IF ( cn_dyn3d(ib_bdy) == 'none' ) THEN
+              IF(lwp) WRITE(numout,*) 'No open boundary condition for baroclinic velocities: ln_dyn3d_dmp is set to .false.'
+              ln_dyn3d_dmp(ib_bdy)=.false.
+           ELSEIF ( cn_dyn3d(ib_bdy) == 'frs' ) THEN
+              CALL ctl_stop( 'Use FRS OR relaxation' )
+           ELSE
+              IF(lwp) WRITE(numout,*) '      + baroclinic velocities relaxation zone'
+              IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
+              IF((lwp).AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
+              dta_bdy(ib_bdy)%ll_u3d = .true.
+              dta_bdy(ib_bdy)%ll_v3d = .true.
+           ENDIF
+        ELSE
+           IF(lwp) WRITE(numout,*) '      NO relaxation on baroclinic velocities'
+        ENDIF
+        IF(lwp) WRITE(numout,*)
+
+        IF(lwp) WRITE(numout,*) 'Boundary conditions for temperature and salinity:  '
+        SELECT CASE( cn_tra(ib_bdy) )                  
+          CASE('none')
+             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
+             dta_bdy(ib_bdy)%ll_tem = .false.
+             dta_bdy(ib_bdy)%ll_sal = .false.
+          CASE('frs')
+             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
+             dta_bdy(ib_bdy)%ll_tem = .true.
+             dta_bdy(ib_bdy)%ll_sal = .true.
+          CASE('specified')
+             IF(lwp) WRITE(numout,*) '      Specified value'
+             dta_bdy(ib_bdy)%ll_tem = .true.
+             dta_bdy(ib_bdy)%ll_sal = .true.
+          CASE('neumann')
+             IF(lwp) WRITE(numout,*) '      Neumann conditions'
+             dta_bdy(ib_bdy)%ll_tem = .false.
+             dta_bdy(ib_bdy)%ll_sal = .false.
+          CASE('runoff')
+             IF(lwp) WRITE(numout,*) '      Runoff conditions : Neumann for T and specified to 0.1 for salinity'
+             dta_bdy(ib_bdy)%ll_tem = .false.
+             dta_bdy(ib_bdy)%ll_sal = .false.
+          CASE('orlanski')
+             IF(lwp) WRITE(numout,*) '      Orlanski (fully oblique) radiation condition with adaptive nudging'
+             dta_bdy(ib_bdy)%ll_tem = .true.
+             dta_bdy(ib_bdy)%ll_sal = .true.
+          CASE('orlanski_npo')
+             IF(lwp) WRITE(numout,*) '      Orlanski (NPO) radiation condition with adaptive nudging'
+             dta_bdy(ib_bdy)%ll_tem = .true.
+             dta_bdy(ib_bdy)%ll_sal = .true.
+          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_tra' )
+        END SELECT
+        IF( cn_tra(ib_bdy) /= 'none' ) THEN
+           SELECT CASE( nn_tra_dta(ib_bdy) )                   ! 
+              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
+              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
+              CASE DEFAULT   ;   CALL ctl_stop( 'nn_tra_dta must be 0 or 1' )
+           END SELECT
+        ENDIF
+
+        IF ( ln_tra_dmp(ib_bdy) ) THEN
+           IF ( cn_tra(ib_bdy) == 'none' ) THEN
+              IF(lwp) WRITE(numout,*) 'No open boundary condition for tracers: ln_tra_dmp is set to .false.'
+              ln_tra_dmp(ib_bdy)=.false.
+           ELSEIF ( cn_tra(ib_bdy) == 'frs' ) THEN
+              CALL ctl_stop( 'Use FRS OR relaxation' )
+           ELSE
+              IF(lwp) WRITE(numout,*) '      + T/S relaxation zone'
+              IF(lwp) WRITE(numout,*) '      Damping time scale: ',rn_time_dmp(ib_bdy),' days'
+              IF(lwp) WRITE(numout,*) '      Outflow damping time scale: ',rn_time_dmp_out(ib_bdy),' days'
+              IF((lwp).AND.rn_time_dmp(ib_bdy)<0) CALL ctl_stop( 'Time scale must be positive' )
+              dta_bdy(ib_bdy)%ll_tem = .true.
+              dta_bdy(ib_bdy)%ll_sal = .true.
+           ENDIF
+        ELSE
+           IF(lwp) WRITE(numout,*) '      NO T/S relaxation'
+        ENDIF
+        IF(lwp) WRITE(numout,*)
+
+#if defined key_lim2
+        IF(lwp) WRITE(numout,*) 'Boundary conditions for sea ice:  '
+        SELECT CASE( cn_ice_lim(ib_bdy) )                  
+          CASE('none')
+             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
+             dta_bdy(ib_bdy)%ll_frld  = .false.
+             dta_bdy(ib_bdy)%ll_hicif = .false.
+             dta_bdy(ib_bdy)%ll_hsnif = .false.
+          CASE('frs')
+             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
+             dta_bdy(ib_bdy)%ll_frld  = .true.
+             dta_bdy(ib_bdy)%ll_hicif = .true.
+             dta_bdy(ib_bdy)%ll_hsnif = .true.
+          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_ice_lim' )
+        END SELECT
+        IF( cn_ice_lim(ib_bdy) /= 'none' ) THEN 
+           SELECT CASE( nn_ice_lim_dta(ib_bdy) )                   ! 
+              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
+              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
+              CASE DEFAULT   ;   CALL ctl_stop( 'nn_ice_lim_dta must be 0 or 1' )
+           END SELECT
+        ENDIF
+        IF(lwp) WRITE(numout,*)
+#elif defined key_lim3
+        IF(lwp) WRITE(numout,*) 'Boundary conditions for sea ice:  '
+        SELECT CASE( cn_ice_lim(ib_bdy) )                  
+          CASE('none')
+             IF(lwp) WRITE(numout,*) '      no open boundary condition'        
+             dta_bdy(ib_bdy)%ll_a_i  = .false.
+             dta_bdy(ib_bdy)%ll_ht_i = .false.
+             dta_bdy(ib_bdy)%ll_ht_s = .false.
+          CASE('frs')
+             IF(lwp) WRITE(numout,*) '      Flow Relaxation Scheme'
+             dta_bdy(ib_bdy)%ll_a_i  = .true.
+             dta_bdy(ib_bdy)%ll_ht_i = .true.
+             dta_bdy(ib_bdy)%ll_ht_s = .true.
+          CASE DEFAULT   ;   CALL ctl_stop( 'unrecognised value for cn_ice_lim' )
+        END SELECT
+        IF( cn_ice_lim(ib_bdy) /= 'none' ) THEN 
+           SELECT CASE( nn_ice_lim_dta(ib_bdy) )                   ! 
+              CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      initial state used for bdy data'        
+              CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      boundary data taken from file'
+              CASE DEFAULT   ;   CALL ctl_stop( 'nn_ice_lim_dta must be 0 or 1' )
+           END SELECT
+        ENDIF
+        IF(lwp) WRITE(numout,*)
+        IF(lwp) WRITE(numout,*) '      tem of bdy sea-ice = ', rn_ice_tem(ib_bdy)         
+        IF(lwp) WRITE(numout,*) '      sal of bdy sea-ice = ', rn_ice_sal(ib_bdy)         
+        IF(lwp) WRITE(numout,*) '      age of bdy sea-ice = ', rn_ice_age(ib_bdy)         
+#endif
+
+        IF(lwp) WRITE(numout,*) '      Width of relaxation zone = ', nn_rimwidth(ib_bdy)
+        IF(lwp) WRITE(numout,*)
+
+      ENDDO
+
+     IF (nb_bdy .gt. 0) THEN
+        IF( ln_vol ) THEN                     ! check volume conservation (nn_volctl value)
+          IF(lwp) WRITE(numout,*) 'Volume correction applied at open boundaries'
+          IF(lwp) WRITE(numout,*)
+          SELECT CASE ( nn_volctl )
+            CASE( 1 )      ;   IF(lwp) WRITE(numout,*) '      The total volume will be constant'
+            CASE( 0 )      ;   IF(lwp) WRITE(numout,*) '      The total volume will vary according to the surface E-P flux'
+            CASE DEFAULT   ;   CALL ctl_stop( 'nn_volctl must be 0 or 1' )
+          END SELECT
+          IF(lwp) WRITE(numout,*)
+        ELSE
+          IF(lwp) WRITE(numout,*) 'No volume correction applied at open boundaries'
+          IF(lwp) WRITE(numout,*)
+        ENDIF
+        IF( nb_jpk_bdy > 0 ) THEN
+           IF(lwp) WRITE(numout,*) '*** open boundary will be interpolate in the vertical onto the native grid ***'
+        ELSE
+           IF(lwp) WRITE(numout,*) '*** open boundary will be read straight onto the native grid without vertical interpolation ***'
+        ENDIF
+     ENDIF
+
+      ! -------------------------------------------------
+      ! Initialise indices arrays for open boundaries
+      ! -------------------------------------------------
+
+      ! Work out global dimensions of boundary data
+      ! ---------------------------------------------
+      REWIND( numnam_cfg )     
+
+      nblendta(:,:) = 0
+      nbdysege = 0
+      nbdysegw = 0
+      nbdysegn = 0
+      nbdysegs = 0
+      icount   = 0 ! count user defined segments
+      ! Dimensions below are used to allocate arrays to read external data
+      jpbdtas = 1 ! Maximum size of boundary data (structured case)
+      jpbdtau = 1 ! Maximum size of boundary data (unstructured case)
+
+      DO ib_bdy = 1, nb_bdy
+
+         IF( .NOT. ln_coords_file(ib_bdy) ) THEN ! Work out size of global arrays from namelist parameters
+ 
+            icount = icount + 1
+            ! No REWIND here because may need to read more than one nambdy_index namelist.
+            ! Read only namelist_cfg to avoid unseccessfull overwrite
+!!          REWIND( numnam_ref )              ! Namelist nambdy_index in reference namelist : Open boundaries indexes
+!!          READ  ( numnam_ref, namrun, IOSTAT = ios, ERR = 903)
+!!903       IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambdy_index in reference namelist', lwp )
+
+!!          REWIND( numnam_cfg )              ! Namelist nambdy_index in configuration namelist : Open boundaries indexes
+            READ  ( numnam_cfg, nambdy_index, IOSTAT = ios, ERR = 904 )
+904         IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambdy_index in configuration namelist', lwp )
+            IF(lwm) WRITE ( numond, nambdy_index )
+
+            SELECT CASE ( TRIM(ctypebdy) )
+              CASE( 'N' )
+                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+                    nbdyind  = jpjglo - 2  ! set boundary to whole side of model domain.
+                    nbdybeg  = 2
+                    nbdyend  = jpiglo - 1
+                 ENDIF
+                 nbdysegn = nbdysegn + 1
+                 npckgn(nbdysegn) = ib_bdy ! Save bdy package number
+                 jpjnob(nbdysegn) = nbdyind
+                 jpindt(nbdysegn) = nbdybeg
+                 jpinft(nbdysegn) = nbdyend
+                 !
+              CASE( 'S' )
+                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+                    nbdyind  = 2           ! set boundary to whole side of model domain.
+                    nbdybeg  = 2
+                    nbdyend  = jpiglo - 1
+                 ENDIF
+                 nbdysegs = nbdysegs + 1
+                 npckgs(nbdysegs) = ib_bdy ! Save bdy package number
+                 jpjsob(nbdysegs) = nbdyind
+                 jpisdt(nbdysegs) = nbdybeg
+                 jpisft(nbdysegs) = nbdyend
+                 !
+              CASE( 'E' )
+                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+                    nbdyind  = jpiglo - 2  ! set boundary to whole side of model domain.
+                    nbdybeg  = 2
+                    nbdyend  = jpjglo - 1
+                 ENDIF
+                 nbdysege = nbdysege + 1 
+                 npckge(nbdysege) = ib_bdy ! Save bdy package number
+                 jpieob(nbdysege) = nbdyind
+                 jpjedt(nbdysege) = nbdybeg
+                 jpjeft(nbdysege) = nbdyend
+                 !
+              CASE( 'W' )
+                 IF( nbdyind == -1 ) THEN  ! Automatic boundary definition: if nbdysegX = -1
+                    nbdyind  = 2           ! set boundary to whole side of model domain.
+                    nbdybeg  = 2
+                    nbdyend  = jpjglo - 1
+                 ENDIF
+                 nbdysegw = nbdysegw + 1
+                 npckgw(nbdysegw) = ib_bdy ! Save bdy package number
+                 jpiwob(nbdysegw) = nbdyind
+                 jpjwdt(nbdysegw) = nbdybeg
+                 jpjwft(nbdysegw) = nbdyend
+                 !
+              CASE DEFAULT   ;   CALL ctl_stop( 'ctypebdy must be N, S, E or W' )
+            END SELECT
+
+            ! For simplicity we assume that in case of straight bdy, arrays have the same length
+            ! (even if it is true that last tangential velocity points
+            ! are useless). This simplifies a little bit boundary data format (and agrees with format
+            ! used so far in obc package)
+
+            nblendta(1:jpbgrd,ib_bdy) =  (nbdyend - nbdybeg + 1) * nn_rimwidth(ib_bdy)
+            jpbdtas = MAX(jpbdtas, (nbdyend - nbdybeg + 1))
+            IF (lwp.and.(nn_rimwidth(ib_bdy)>nrimmax)) &
+            & CALL ctl_stop( 'rimwidth must be lower than nrimmax' )
+
+         ELSE            ! Read size of arrays in boundary coordinates file.
+            CALL iom_open( cn_coords_file(ib_bdy), inum )
+            DO igrd = 1, jpbgrd
+               id_dummy = iom_varid( inum, 'nbi'//cgrid(igrd), kdimsz=kdimsz )  
+               !clem nblendta(igrd,ib_bdy) = kdimsz(1)
+               !clem jpbdtau = MAX(jpbdtau, kdimsz(1))
+               nblendta(igrd,ib_bdy) = MAXVAL(kdimsz)
+               jpbdtau = MAX(jpbdtau, MAXVAL(kdimsz))
+            END DO
+            CALL iom_close( inum )
+            !
+         ENDIF 
+         !
+      END DO ! ib_bdy
+
+      IF (nb_bdy>0) THEN
+         jpbdta = MAXVAL(nblendta(1:jpbgrd,1:nb_bdy))
+
+         ! Allocate arrays
+         !---------------
+         ALLOCATE( nbidta(jpbdta, jpbgrd, nb_bdy), nbjdta(jpbdta, jpbgrd, nb_bdy),    &
+            &      nbrdta(jpbdta, jpbgrd, nb_bdy) )
+
+         IF( nb_jpk_bdy>0 ) THEN
+            ALLOCATE( dta_global(jpbdtau, 1, nb_jpk_bdy) )
+            ALLOCATE( dta_global_z(jpbdtau, 1, nb_jpk_bdy) )
+            ALLOCATE( dta_global_dz(jpbdtau, 1, nb_jpk_bdy) )
+         ELSE
+            ALLOCATE( dta_global(jpbdtau, 1, jpk) )
+            ALLOCATE( dta_global_z(jpbdtau, 1, jpk) ) ! needed ?? TODO
+            ALLOCATE( dta_global_dz(jpbdtau, 1, jpk) )! needed ?? TODO
+         ENDIF
+
+         IF ( icount>0 ) THEN
+            IF( nb_jpk_bdy>0 ) THEN
+               ALLOCATE( dta_global2(jpbdtas, nrimmax, nb_jpk_bdy) )
+               ALLOCATE( dta_global2_z(jpbdtas, nrimmax, nb_jpk_bdy) )
+               ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, nb_jpk_bdy) )
+            ELSE
+               ALLOCATE( dta_global2(jpbdtas, nrimmax, jpk) )
+               ALLOCATE( dta_global2_z(jpbdtas, nrimmax, jpk) ) ! needed ?? TODO
+               ALLOCATE( dta_global2_dz(jpbdtas, nrimmax, jpk) )! needed ?? TODO  
+            ENDIF
+         ENDIF
+         ! 
+      ENDIF
+
+      ! Now look for crossings in user (namelist) defined open boundary segments:
+      !--------------------------------------------------------------------------
+      IF( icount>0 )   CALL bdy_ctl_seg
+
+      ! Calculate global boundary index arrays or read in from file
+      !------------------------------------------------------------               
+      ! 1. Read global index arrays from boundary coordinates file.
+      DO ib_bdy = 1, nb_bdy
+         !
+         IF( ln_coords_file(ib_bdy) ) THEN
+            !
+            CALL iom_open( cn_coords_file(ib_bdy), inum )
+            DO igrd = 1, jpbgrd
+               CALL iom_get( inum, jpdom_unknown, 'nbi'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
+               DO ii = 1,nblendta(igrd,ib_bdy)
+                  nbidta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
+               END DO
+               CALL iom_get( inum, jpdom_unknown, 'nbj'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
+               DO ii = 1,nblendta(igrd,ib_bdy)
+                  nbjdta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
+               END DO
+               CALL iom_get( inum, jpdom_unknown, 'nbr'//cgrid(igrd), dta_global(1:nblendta(igrd,ib_bdy),:,1) )
+               DO ii = 1,nblendta(igrd,ib_bdy)
+                  nbrdta(ii,igrd,ib_bdy) = INT( dta_global(ii,1,1) )
+               END DO
+               !
+               ibr_max = MAXVAL( nbrdta(:,igrd,ib_bdy) )
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' Maximum rimwidth in file is ', ibr_max
+               IF(lwp) WRITE(numout,*) ' nn_rimwidth from namelist is ', nn_rimwidth(ib_bdy)
+               IF (ibr_max < nn_rimwidth(ib_bdy))   &
+                     CALL ctl_stop( 'nn_rimwidth is larger than maximum rimwidth in file',cn_coords_file(ib_bdy) )
+            END DO
+            CALL iom_close( inum )
+            !
+         ENDIF 
+         !
+      END DO      
+    
+      ! 2. Now fill indices corresponding to straight open boundary arrays:
+      ! East
+      !-----
+      DO iseg = 1, nbdysege
+         ib_bdy = npckge(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjedt(iseg), jpjeft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjedt(iseg), jpjeft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 1 - ir
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+!            DO ij = jpjedt(iseg), jpjeft(iseg) - 1
+            DO ij = jpjedt(iseg), jpjeft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpieob(iseg) + 2 - ir
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+      ENDDO
+      !
+      ! West
+      !-----
+      DO iseg = 1, nbdysegw
+         ib_bdy = npckgw(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjwdt(iseg), jpjwft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ij = jpjwdt(iseg), jpjwft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+!            DO ij = jpjwdt(iseg), jpjwft(iseg) - 1
+            DO ij = jpjwdt(iseg), jpjwft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = jpiwob(iseg) + ir - 1
+               nbjdta(icount, igrd, ib_bdy) = ij
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+      ENDDO
+      !
+      ! North
+      !-----
+      DO iseg = 1, nbdysegn
+         ib_bdy = npckgn(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpindt(iseg), jpinft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir 
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+!            DO ii = jpindt(iseg), jpinft(iseg) - 1
+            DO ii = jpindt(iseg), jpinft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 2 - ir
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpindt(iseg), jpinft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjnob(iseg) + 1 - ir
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+      ENDDO
+      !
+      ! South
+      !-----
+      DO iseg = 1, nbdysegs
+         ib_bdy = npckgs(iseg)
+         !
+         ! ------------ T points -------------
+         igrd=1
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpisdt(iseg), jpisft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+         !
+         ! ------------ U points -------------
+         igrd=2
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+!            DO ii = jpisdt(iseg), jpisft(iseg) - 1
+            DO ii = jpisdt(iseg), jpisft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+            nbidta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+            nbjdta(icount, igrd, ib_bdy) = -ib_bdy ! Discount this point
+         ENDDO
+         !
+         ! ------------ V points -------------
+         igrd=3
+         icount=0
+         DO ir = 1, nn_rimwidth(ib_bdy)
+            DO ii = jpisdt(iseg), jpisft(iseg)
+               icount = icount + 1
+               nbidta(icount, igrd, ib_bdy) = ii
+               nbjdta(icount, igrd, ib_bdy) = jpjsob(iseg) + ir - 1
+               nbrdta(icount, igrd, ib_bdy) = ir
+            ENDDO
+         ENDDO
+      ENDDO
+
+      !  Deal with duplicated points
+      !-----------------------------
+      ! We assign negative indices to duplicated points (to remove them from bdy points to be updated)
+      ! if their distance to the bdy is greater than the other
+      ! If their distance are the same, just keep only one to avoid updating a point twice
+      DO igrd = 1, jpbgrd
+         DO ib_bdy1 = 1, nb_bdy
+            DO ib_bdy2 = 1, nb_bdy
+               IF (ib_bdy1/=ib_bdy2) THEN
+                  DO ib1 = 1, nblendta(igrd,ib_bdy1)
+                     DO ib2 = 1, nblendta(igrd,ib_bdy2)
+                        IF ((nbidta(ib1, igrd, ib_bdy1)==nbidta(ib2, igrd, ib_bdy2)).AND. &
+                        &   (nbjdta(ib1, igrd, ib_bdy1)==nbjdta(ib2, igrd, ib_bdy2))) THEN
+!                           IF ((lwp).AND.(igrd==1)) WRITE(numout,*) ' found coincident point ji, jj:', & 
+!                                                       &              nbidta(ib1, igrd, ib_bdy1),      & 
+!                                                       &              nbjdta(ib2, igrd, ib_bdy2)
+                           ! keep only points with the lowest distance to boundary:
+                           IF (nbrdta(ib1, igrd, ib_bdy1)<nbrdta(ib2, igrd, ib_bdy2)) THEN
+                             nbidta(ib2, igrd, ib_bdy2) =-ib_bdy2
+                             nbjdta(ib2, igrd, ib_bdy2) =-ib_bdy2
+                           ELSEIF (nbrdta(ib1, igrd, ib_bdy1)>nbrdta(ib2, igrd, ib_bdy2)) THEN
+                             nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                             nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                           ! Arbitrary choice if distances are the same:
+                           ELSE
+                             nbidta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                             nbjdta(ib1, igrd, ib_bdy1) =-ib_bdy1
+                           ENDIF
+                        END IF
+                     END DO
+                  END DO
+               ENDIF
+            END DO
+         END DO
+      END DO
+
+      ! Work out dimensions of boundary data on each processor
+      ! ------------------------------------------------------
+
+      ! Rather assume that boundary data indices are given on global domain
+      ! TO BE DISCUSSED ?
+!      iw = mig(1) + 1            ! if monotasking and no zoom, iw=2
+!      ie = mig(1) + nlci-1 - 1   ! if monotasking and no zoom, ie=jpim1
+!      is = mjg(1) + 1            ! if monotasking and no zoom, is=2
+!      in = mjg(1) + nlcj-1 - 1   ! if monotasking and no zoom, in=jpjm1      
+      iwe = mig(1) - 1 + 2         ! if monotasking and no zoom, iw=2
+      ies = mig(1) + nlci-1 - 1  ! if monotasking and no zoom, ie=jpim1
+      iso = mjg(1) - 1 + 2         ! if monotasking and no zoom, is=2
+      ino = mjg(1) + nlcj-1 - 1  ! if monotasking and no zoom, in=jpjm1
+
+      ALLOCATE( nbondi_bdy(nb_bdy))
+      ALLOCATE( nbondj_bdy(nb_bdy))
+      nbondi_bdy(:)=2
+      nbondj_bdy(:)=2
+      ALLOCATE( nbondi_bdy_b(nb_bdy))
+      ALLOCATE( nbondj_bdy_b(nb_bdy))
+      nbondi_bdy_b(:)=2
+      nbondj_bdy_b(:)=2
+
+      ! Work out dimensions of boundary data on each neighbour process
+      IF(nbondi == 0) THEN
+         iw_b(1) = 1 + nimppt(nowe+1)
+         ie_b(1) = 1 + nimppt(nowe+1)+nlcit(nowe+1)-3
+         is_b(1) = 1 + njmppt(nowe+1)
+         in_b(1) = 1 + njmppt(nowe+1)+nlcjt(nowe+1)-3
+
+         iw_b(2) = 1 + nimppt(noea+1)
+         ie_b(2) = 1 + nimppt(noea+1)+nlcit(noea+1)-3
+         is_b(2) = 1 + njmppt(noea+1)
+         in_b(2) = 1 + njmppt(noea+1)+nlcjt(noea+1)-3
+      ELSEIF(nbondi == 1) THEN
+         iw_b(1) = 1 + nimppt(nowe+1)
+         ie_b(1) = 1 + nimppt(nowe+1)+nlcit(nowe+1)-3
+         is_b(1) = 1 + njmppt(nowe+1)
+         in_b(1) = 1 + njmppt(nowe+1)+nlcjt(nowe+1)-3
+      ELSEIF(nbondi == -1) THEN
+         iw_b(2) = 1 + nimppt(noea+1)
+         ie_b(2) = 1 + nimppt(noea+1)+nlcit(noea+1)-3
+         is_b(2) = 1 + njmppt(noea+1)
+         in_b(2) = 1 + njmppt(noea+1)+nlcjt(noea+1)-3
+      ENDIF
+
+      IF(nbondj == 0) THEN
+         iw_b(3) = 1 + nimppt(noso+1)
+         ie_b(3) = 1 + nimppt(noso+1)+nlcit(noso+1)-3
+         is_b(3) = 1 + njmppt(noso+1)
+         in_b(3) = 1 + njmppt(noso+1)+nlcjt(noso+1)-3
+
+         iw_b(4) = 1 + nimppt(nono+1)
+         ie_b(4) = 1 + nimppt(nono+1)+nlcit(nono+1)-3
+         is_b(4) = 1 + njmppt(nono+1)
+         in_b(4) = 1 + njmppt(nono+1)+nlcjt(nono+1)-3
+      ELSEIF(nbondj == 1) THEN
+         iw_b(3) = 1 + nimppt(noso+1)
+         ie_b(3) = 1 + nimppt(noso+1)+nlcit(noso+1)-3
+         is_b(3) = 1 + njmppt(noso+1)
+         in_b(3) = 1 + njmppt(noso+1)+nlcjt(noso+1)-3
+      ELSEIF(nbondj == -1) THEN
+         iw_b(4) = 1 + nimppt(nono+1)
+         ie_b(4) = 1 + nimppt(nono+1)+nlcit(nono+1)-3
+         is_b(4) = 1 + njmppt(nono+1)
+         in_b(4) = 1 + njmppt(nono+1)+nlcjt(nono+1)-3
+      ENDIF
+
+      DO ib_bdy = 1, nb_bdy
+         DO igrd = 1, jpbgrd
+            icount  = 0
+            icountr = 0
+            idx_bdy(ib_bdy)%nblen(igrd)    = 0
+            idx_bdy(ib_bdy)%nblenrim(igrd) = 0
+            DO ib = 1, nblendta(igrd,ib_bdy)
+               ! check that data is in correct order in file
+               ibm1 = MAX(1,ib-1)
+               IF(lwp) THEN         ! Since all procs read global data only need to do this check on one proc...
+                  IF( nbrdta(ib,igrd,ib_bdy) < nbrdta(ibm1,igrd,ib_bdy) ) THEN
+                     CALL ctl_stop('bdy_segs : ERROR : boundary data in file must be defined ', &
+                          &        ' in order of distance from edge nbr A utility for re-ordering ', &
+                          &        ' boundary coordinates and data files exists in the TOOLS/OBC directory')
+                  ENDIF    
+               ENDIF
+               ! check if point is in local domain
+               IF(  nbidta(ib,igrd,ib_bdy) >= iwe .AND. nbidta(ib,igrd,ib_bdy) <= ies .AND.   &
+                  & nbjdta(ib,igrd,ib_bdy) >= iso .AND. nbjdta(ib,igrd,ib_bdy) <= ino      ) THEN
+                  !
+                  icount = icount  + 1
+                  !
+                  IF( nbrdta(ib,igrd,ib_bdy) == 1 )   icountr = icountr+1
+               ENDIF
+            ENDDO
+            idx_bdy(ib_bdy)%nblenrim(igrd) = icountr !: length of rim boundary data on each proc
+            idx_bdy(ib_bdy)%nblen   (igrd) = icount  !: length of boundary data on each proc        
+         ENDDO  ! igrd
+
+         ! Allocate index arrays for this boundary set
+         !--------------------------------------------
+         ilen1 = MAXVAL( idx_bdy(ib_bdy)%nblen(:) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbi   (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbj   (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbr   (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbd   (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbdout(ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbmap (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%nbw   (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%flagu (ilen1,jpbgrd) )
+         ALLOCATE( idx_bdy(ib_bdy)%flagv (ilen1,jpbgrd) )
+
+         ! Dispatch mapping indices and discrete distances on each processor
+         ! -----------------------------------------------------------------
+
+         com_east  = 0
+         com_west  = 0
+         com_south = 0
+         com_north = 0
+
+         com_east_b  = 0
+         com_west_b  = 0
+         com_south_b = 0
+         com_north_b = 0
+
+         DO igrd = 1, jpbgrd
+            icount  = 0
+            ! Loop on rimwidth to ensure outermost points come first in the local arrays.
+            DO ir=1, nn_rimwidth(ib_bdy)
+               DO ib = 1, nblendta(igrd,ib_bdy)
+                  ! check if point is in local domain and equals ir
+                  IF(  nbidta(ib,igrd,ib_bdy) >= iwe .AND. nbidta(ib,igrd,ib_bdy) <= ies .AND.   &
+                     & nbjdta(ib,igrd,ib_bdy) >= iso .AND. nbjdta(ib,igrd,ib_bdy) <= ino .AND.   &
+                     & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                     !
+                     icount = icount  + 1
+
+                     ! Rather assume that boundary data indices are given on global domain
+                     ! TO BE DISCUSSED ?
+!                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1
+!                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1
+                     idx_bdy(ib_bdy)%nbi(icount,igrd)   = nbidta(ib,igrd,ib_bdy)- mig(1)+1
+                     idx_bdy(ib_bdy)%nbj(icount,igrd)   = nbjdta(ib,igrd,ib_bdy)- mjg(1)+1
+                     ! check if point has to be sent
+                     ii = idx_bdy(ib_bdy)%nbi(icount,igrd)
+                     ij = idx_bdy(ib_bdy)%nbj(icount,igrd)
+                     if((com_east .ne. 1) .and. (ii == (nlci-1)) .and. (nbondi .le. 0)) then
+                        com_east = 1
+                     elseif((com_west .ne. 1) .and. (ii == 2) .and. (nbondi .ge. 0) .and. (nbondi .ne. 2)) then
+                        com_west = 1
+                     endif 
+                     if((com_south .ne. 1) .and. (ij == 2) .and. (nbondj .ge. 0) .and. (nbondj .ne. 2)) then
+                        com_south = 1
+                     elseif((com_north .ne. 1) .and. (ij == (nlcj-1)) .and. (nbondj .le. 0)) then
+                        com_north = 1
+                     endif 
+                     idx_bdy(ib_bdy)%nbr(icount,igrd)   = nbrdta(ib,igrd,ib_bdy)
+                     idx_bdy(ib_bdy)%nbmap(icount,igrd) = ib
+                  ENDIF
+                  ! check if point has to be received from a neighbour
+                  IF(nbondi == 0) THEN
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(1) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(1) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(1) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(1) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
+                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
+                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
+                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
+                            com_south = 1
+                          elseif((ij == nlcjt(nowe+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
+                            com_north = 1
+                          endif
+                          com_west_b = 1
+                       endif 
+                     ENDIF
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(2) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(2) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(2) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(2) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
+                       if((com_east_b .ne. 1) .and. (ii == 2)) then
+                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
+                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
+                            com_south = 1
+                          elseif((ij == nlcjt(noea+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
+                            com_north = 1
+                          endif
+                          com_east_b = 1
+                       endif 
+                     ENDIF
+                  ELSEIF(nbondi == 1) THEN
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(1) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(1) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(1) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(1) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(1)+2
+                       if((com_west_b .ne. 1) .and. (ii == (nlcit(nowe+1)-1))) then
+                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(1)+2
+                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
+                            com_south = 1
+                          elseif((ij == nlcjt(nowe+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
+                            com_north = 1
+                          endif
+                          com_west_b = 1
+                       endif 
+                     ENDIF
+                  ELSEIF(nbondi == -1) THEN
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(2) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(2) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(2) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(2) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ii = nbidta(ib,igrd,ib_bdy)- iw_b(2)+2
+                       if((com_east_b .ne. 1) .and. (ii == 2)) then
+                          ij = nbjdta(ib,igrd,ib_bdy) - is_b(2)+2
+                          if((ij == 2) .and. (nbondj == 0 .or. nbondj == 1)) then
+                            com_south = 1
+                          elseif((ij == nlcjt(noea+1)-1) .and. (nbondj == 0 .or. nbondj == -1)) then
+                            com_north = 1
+                          endif
+                          com_east_b = 1
+                       endif 
+                     ENDIF
+                  ENDIF
+                  IF(nbondj == 0) THEN
+                     IF(com_north_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(4)-1  &
+                       & .OR. nbidta(ib,igrd,ib_bdy) == ie_b(4)+1) .AND. &
+                       & nbjdta(ib,igrd,ib_bdy) == is_b(4) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
+                       com_north_b = 1 
+                     ENDIF
+                     IF(com_south_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(3)-1  &
+                       &.OR. nbidta(ib,igrd,ib_bdy) == ie_b(3)+1) .AND. &
+                       & nbjdta(ib,igrd,ib_bdy) == in_b(3) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
+                       com_south_b = 1 
+                     ENDIF
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(3) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(3) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(3) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(3) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
+                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
+                          com_south_b = 1
+                       endif 
+                     ENDIF
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(4) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(4) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(4) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(4) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(4)+2
+                       if((com_north_b .ne. 1) .and. (ij == 2)) then
+                          com_north_b = 1
+                       endif 
+                     ENDIF
+                  ELSEIF(nbondj == 1) THEN
+                     IF( com_south_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(3)-1 .OR. &
+                       & nbidta(ib,igrd,ib_bdy) == ie_b(3)+1) .AND. &
+                       & nbjdta(ib,igrd,ib_bdy) == in_b(3) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
+                       com_south_b = 1 
+                     ENDIF
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(3) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(3) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(3) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(3) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(3)+2
+                       if((com_south_b .ne. 1) .and. (ij == (nlcjt(noso+1)-1))) then
+                          com_south_b = 1
+                       endif 
+                     ENDIF
+                  ELSEIF(nbondj == -1) THEN
+                     IF(com_north_b .ne. 1 .AND. (nbidta(ib,igrd,ib_bdy) == iw_b(4)-1  &
+                       & .OR. nbidta(ib,igrd,ib_bdy) == ie_b(4)+1) .AND. &
+                       & nbjdta(ib,igrd,ib_bdy) == is_b(4) .AND. nbrdta(ib,igrd,ib_bdy) == ir) THEN
+                       com_north_b = 1 
+                     ENDIF
+                     IF( nbidta(ib,igrd,ib_bdy) >= iw_b(4) .AND. nbidta(ib,igrd,ib_bdy) <= ie_b(4) .AND.   &
+                       & nbjdta(ib,igrd,ib_bdy) >= is_b(4) .AND. nbjdta(ib,igrd,ib_bdy) <= in_b(4) .AND.   &
+                       & nbrdta(ib,igrd,ib_bdy) == ir  ) THEN
+                       ij = nbjdta(ib,igrd,ib_bdy)- is_b(4)+2
+                       if((com_north_b .ne. 1) .and. (ij == 2)) then
+                          com_north_b = 1
+                       endif 
+                     ENDIF
+                  ENDIF
+               ENDDO
+            ENDDO
+         ENDDO 
+
+         ! definition of the i- and j- direction local boundaries arrays used for sending the boundaries
+         IF(     (com_east  == 1) .and. (com_west  == 1) ) THEN   ;   nbondi_bdy(ib_bdy) =  0
+         ELSEIF( (com_east  == 1) .and. (com_west  == 0) ) THEN   ;   nbondi_bdy(ib_bdy) = -1
+         ELSEIF( (com_east  == 0) .and. (com_west  == 1) ) THEN   ;   nbondi_bdy(ib_bdy) =  1
+         ENDIF
+         IF(     (com_north == 1) .and. (com_south == 1) ) THEN   ;   nbondj_bdy(ib_bdy) =  0
+         ELSEIF( (com_north == 1) .and. (com_south == 0) ) THEN   ;   nbondj_bdy(ib_bdy) = -1
+         ELSEIF( (com_north == 0) .and. (com_south == 1) ) THEN   ;   nbondj_bdy(ib_bdy) =  1
+         ENDIF
+
+         ! definition of the i- and j- direction local boundaries arrays used for receiving the boundaries
+         IF(     (com_east_b  == 1) .and. (com_west_b  == 1) ) THEN   ;   nbondi_bdy_b(ib_bdy) =  0
+         ELSEIF( (com_east_b  == 1) .and. (com_west_b  == 0) ) THEN   ;   nbondi_bdy_b(ib_bdy) = -1
+         ELSEIF( (com_east_b  == 0) .and. (com_west_b  == 1) ) THEN   ;   nbondi_bdy_b(ib_bdy) =  1
+         ENDIF
+         IF(     (com_north_b == 1) .and. (com_south_b == 1) ) THEN   ;   nbondj_bdy_b(ib_bdy) =  0
+         ELSEIF( (com_north_b == 1) .and. (com_south_b == 0) ) THEN   ;   nbondj_bdy_b(ib_bdy) = -1
+         ELSEIF( (com_north_b == 0) .and. (com_south_b == 1) ) THEN   ;   nbondj_bdy_b(ib_bdy) =  1
+         ENDIF
+
+         ! Compute rim weights for FRS scheme
+         ! ----------------------------------
+         DO igrd = 1, jpbgrd
+            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
+               nbr => idx_bdy(ib_bdy)%nbr(ib,igrd)
+               idx_bdy(ib_bdy)%nbw(ib,igrd) = 1.- TANH( REAL( nbr - 1 ) *0.5 )      ! tanh formulation
+!               idx_bdy(ib_bdy)%nbw(ib,igrd) = (REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.  ! quadratic
+!               idx_bdy(ib_bdy)%nbw(ib,igrd) =  REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy))       ! linear
+            END DO
+         END DO 
+
+         ! Compute damping coefficients
+         ! ----------------------------
+         DO igrd = 1, jpbgrd
+            DO ib = 1, idx_bdy(ib_bdy)%nblen(igrd)
+               nbr => idx_bdy(ib_bdy)%nbr(ib,igrd)
+               idx_bdy(ib_bdy)%nbd(ib,igrd) = 1. / ( rn_time_dmp(ib_bdy) * rday ) & 
+               & *(REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
+               idx_bdy(ib_bdy)%nbdout(ib,igrd) = 1. / ( rn_time_dmp_out(ib_bdy) * rday ) & 
+               & *(REAL(nn_rimwidth(ib_bdy)+1-nbr)/REAL(nn_rimwidth(ib_bdy)))**2.   ! quadratic
+            END DO
+         END DO 
+
+      ENDDO
+
+      ! ------------------------------------------------------
+      ! Initialise masks and find normal/tangential directions
+      ! ------------------------------------------------------
+
+      ! Read global 2D mask at T-points: bdytmask
+      ! -----------------------------------------
+      ! bdytmask = 1  on the computational domain AND on open boundaries
+      !          = 0  elsewhere   
+ 
+      bdytmask(:,:) = ssmask(:,:)
+
+      ! we need to derive mask on U and V grid from mask on T grid here.
+      bdyumask(:,:) = 0._wp
+      bdyvmask(:,:) = 0._wp
+      DO ij = 1, jpjm1
+         DO ii = 1, jpim1
+            bdyumask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii+1, ij )
+            bdyvmask(ii,ij) = bdytmask(ii,ij) * bdytmask(ii  ,ij+1)  
+         END DO
+      END DO
+      CALL lbc_lnk( bdyumask(:,:), 'U', 1. )   ;   CALL lbc_lnk( bdyvmask(:,:), 'V', 1. )      ! Lateral boundary cond.
+     
+      ! bdy masks are now set to zero on boundary points:
+      !
+      igrd = 1
+      DO ib_bdy = 1, nb_bdy
+        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)      
+          bdytmask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
+        END DO
+      END DO
+      !
+      igrd = 2
+      DO ib_bdy = 1, nb_bdy
+        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
+          bdyumask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
+        END DO
+      END DO
+      !
+      igrd = 3
+      DO ib_bdy = 1, nb_bdy
+        DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
+          bdyvmask(idx_bdy(ib_bdy)%nbi(ib,igrd), idx_bdy(ib_bdy)%nbj(ib,igrd)) = 0._wp
+        ENDDO
+      ENDDO
+
+      ! For the flagu/flagv calculation below we require a version of fmask without
+      ! the land boundary condition (shlat) included:
+      CALL wrk_alloc(jpi,jpj,  zfmask ) 
+      DO ij = 2, jpjm1
+         DO ii = 2, jpim1
+            zfmask(ii,ij) = tmask(ii,ij  ,1) * tmask(ii+1,ij  ,1)   &
+           &              * tmask(ii,ij+1,1) * tmask(ii+1,ij+1,1)
+         END DO      
+      END DO
+
+      ! Lateral boundary conditions
+      CALL lbc_lnk( zfmask       , 'F', 1. )
+      CALL lbc_lnk( fmask        , 'F', 1. )   ;   CALL lbc_lnk( bdytmask(:,:), 'T', 1. )
+      CALL lbc_lnk( bdyumask(:,:), 'U', 1. )   ;   CALL lbc_lnk( bdyvmask(:,:), 'V', 1. )
+
+      DO ib_bdy = 1, nb_bdy       ! Indices and directions of rim velocity components
+
+         idx_bdy(ib_bdy)%flagu(:,:) = 0._wp
+         idx_bdy(ib_bdy)%flagv(:,:) = 0._wp
+         icount = 0 
+
+         ! Calculate relationship of U direction to the local orientation of the boundary
+         ! flagu = -1 : u component is normal to the dynamical boundary and its direction is outward
+         ! flagu =  0 : u is tangential
+         ! flagu =  1 : u is normal to the boundary and is direction is inward
+  
+         DO igrd = 1,jpbgrd 
+            SELECT CASE( igrd )
+               CASE( 1 )   ;   pmask => umask   (:,:,1)   ;   i_offset = 0
+               CASE( 2 )   ;   pmask => bdytmask(:,:)     ;   i_offset = 1
+               CASE( 3 )   ;   pmask => zfmask  (:,:)     ;   i_offset = 0
+            END SELECT 
+            icount = 0
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)  
+               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
+               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
+               zefl = pmask(nbi+i_offset-1,nbj)
+               zwfl = pmask(nbi+i_offset,nbj)
+               ! This error check only works if you are using the bdyXmask arrays
+               IF( i_offset == 1 .and. zefl + zwfl == 2 ) THEN
+                  icount = icount + 1
+                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(nbi),mjg(nbj)
+               ELSE
+                  idx_bdy(ib_bdy)%flagu(ib,igrd) = -zefl + zwfl
+               ENDIF
+            END DO
+            IF( icount /= 0 ) THEN
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+                  ' are not boundary points (flagu calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
+               IF(lwp) WRITE(numout,*) ' ========== '
+               IF(lwp) WRITE(numout,*)
+               nstop = nstop + 1
+            ENDIF 
+         END DO
+
+         ! Calculate relationship of V direction to the local orientation of the boundary
+         ! flagv = -1 : v component is normal to the dynamical boundary but its direction is outward
+         ! flagv =  0 : v is tangential
+         ! flagv =  1 : v is normal to the boundary and is direction is inward
+
+         DO igrd = 1, jpbgrd 
+            SELECT CASE( igrd )
+               CASE( 1 )   ;   pmask => vmask (:,:,1)   ;   j_offset = 0
+               CASE( 2 )   ;   pmask => zfmask(:,:)     ;   j_offset = 0
+               CASE( 3 )   ;   pmask => bdytmask        ;   j_offset = 1
+            END SELECT 
+            icount = 0
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)  
+               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
+               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
+               znfl = pmask(nbi,nbj+j_offset-1)
+               zsfl = pmask(nbi,nbj+j_offset  )
+               ! This error check only works if you are using the bdyXmask arrays
+               IF( j_offset == 1 .and. znfl + zsfl == 2 ) THEN
+                  IF(lwp) WRITE(numout,*) 'Problem with igrd = ',igrd,' at (global) nbi, nbj : ',mig(nbi),mjg(nbj)
+                  icount = icount + 1
+               ELSE
+                  idx_bdy(ib_bdy)%flagv(ib,igrd) = -znfl + zsfl
+               END IF
+            END DO
+            IF( icount /= 0 ) THEN
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' E R R O R : Some ',cgrid(igrd),' grid points,',   &
+                  ' are not boundary points (flagv calculation). Check nbi, nbj, indices for boundary set ',ib_bdy
+               IF(lwp) WRITE(numout,*) ' ========== '
+               IF(lwp) WRITE(numout,*)
+               nstop = nstop + 1
+            ENDIF 
+         END DO
+         !
+      END DO
+
+      ! Compute total lateral surface for volume correction:
+      ! ----------------------------------------------------
+      ! JC: this must be done at each time step with non-linear free surface
+      bdysurftot = 0._wp 
+      IF( ln_vol ) THEN  
+         igrd = 2      ! Lateral surface at U-points
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
+               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
+               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
+               flagu => idx_bdy(ib_bdy)%flagu(ib,igrd)
+               bdysurftot = bdysurftot + hu_n   (nbi  , nbj)                           &
+                  &                    * e2u    (nbi  , nbj) * ABS( flagu ) &
+                  &                    * tmask_i(nbi  , nbj)                           &
+                  &                    * tmask_i(nbi+1, nbj)                   
+            END DO
+         END DO
+
+         igrd=3 ! Add lateral surface at V-points
+         DO ib_bdy = 1, nb_bdy
+            DO ib = 1, idx_bdy(ib_bdy)%nblenrim(igrd)
+               nbi => idx_bdy(ib_bdy)%nbi(ib,igrd)
+               nbj => idx_bdy(ib_bdy)%nbj(ib,igrd)
+               flagv => idx_bdy(ib_bdy)%flagv(ib,igrd)
+               bdysurftot = bdysurftot + hv_n   (nbi, nbj  )                           &
+                  &                    * e1v    (nbi, nbj  ) * ABS( flagv ) &
+                  &                    * tmask_i(nbi, nbj  )                           &
+                  &                    * tmask_i(nbi, nbj+1)
+            END DO
+         END DO
+         !
+         IF( lk_mpp )   CALL mpp_sum( bdysurftot )      ! sum over the global domain
+      END IF   
+      !
+      ! Tidy up
+      !--------
+      IF( nb_bdy>0 )   DEALLOCATE( nbidta, nbjdta, nbrdta )
+      !
+      CALL wrk_dealloc(jpi,jpj,   zfmask ) 
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('bdy_segs')
+      !
+   END SUBROUTINE bdy_segs
+
+   SUBROUTINE bdy_ctl_seg
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_ctl_seg  ***
+      !!
+      !! ** Purpose :   Check straight open boundary segments location
+      !!
+      !! ** Method  :   - Look for open boundary corners
+      !!                - Check that segments start or end on land 
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ib, ib1, ib2, ji ,jj, itest  
+      INTEGER, DIMENSION(jp_nseg,2) :: icorne, icornw, icornn, icorns  
+      REAL(wp), DIMENSION(2) ::   ztestmask
+      !!----------------------------------------------------------------------
+      !
+      IF (lwp) WRITE(numout,*) ' '
+      IF (lwp) WRITE(numout,*) 'bdy_ctl_seg: Check analytical segments'
+      IF (lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+      !
+      IF(lwp) WRITE(numout,*) 'Number of east  segments     : ', nbdysege
+      IF(lwp) WRITE(numout,*) 'Number of west  segments     : ', nbdysegw
+      IF(lwp) WRITE(numout,*) 'Number of north segments     : ', nbdysegn
+      IF(lwp) WRITE(numout,*) 'Number of south segments     : ', nbdysegs
+      ! 1. Check bounds
+      !----------------
+      DO ib = 1, nbdysegn
+         IF (lwp) WRITE(numout,*) '**check north seg bounds pckg: ', npckgn(ib)
+         IF ((jpjnob(ib).ge.jpjglo-1).or.& 
+            &(jpjnob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
+         IF (jpindt(ib).ge.jpinft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
+         IF (jpindt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpinft(ib).ge.jpiglo)     CALL ctl_stop( 'End index out of domain' )
+      END DO
+      !
+      DO ib = 1, nbdysegs
+         IF (lwp) WRITE(numout,*) '**check south seg bounds pckg: ', npckgs(ib)
+         IF ((jpjsob(ib).ge.jpjglo-1).or.& 
+            &(jpjsob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
+         IF (jpisdt(ib).ge.jpisft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
+         IF (jpisdt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpisft(ib).ge.jpiglo)     CALL ctl_stop( 'End index out of domain' )
+      END DO
+      !
+      DO ib = 1, nbdysege
+         IF (lwp) WRITE(numout,*) '**check east  seg bounds pckg: ', npckge(ib)
+         IF ((jpieob(ib).ge.jpiglo-1).or.& 
+            &(jpieob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
+         IF (jpjedt(ib).ge.jpjeft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
+         IF (jpjedt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpjeft(ib).ge.jpjglo)     CALL ctl_stop( 'End index out of domain' )
+      END DO
+      !
+      DO ib = 1, nbdysegw
+         IF (lwp) WRITE(numout,*) '**check west  seg bounds pckg: ', npckgw(ib)
+         IF ((jpiwob(ib).ge.jpiglo-1).or.& 
+            &(jpiwob(ib).le.1))        CALL ctl_stop( 'nbdyind out of domain' )
+         IF (jpjwdt(ib).ge.jpjwft(ib)) CALL ctl_stop( 'Bdy start index is greater than end index' )
+         IF (jpjwdt(ib).le.1     )     CALL ctl_stop( 'Start index out of domain' )
+         IF (jpjwft(ib).ge.jpjglo)     CALL ctl_stop( 'End index out of domain' )
+      ENDDO
+      !
+      !      
+      ! 2. Look for segment crossings
+      !------------------------------ 
+      IF (lwp) WRITE(numout,*) '**Look for segments corners  :'
+      !
+      itest = 0 ! corner number
+      !
+      ! flag to detect if start or end of open boundary belongs to a corner
+      ! if not (=0), it must be on land.
+      ! if a corner is detected, save bdy package number for further tests
+      icorne(:,:)=0. ; icornw(:,:)=0. ; icornn(:,:)=0. ; icorns(:,:)=0.
+      ! South/West crossings
+      IF ((nbdysegw > 0).AND.(nbdysegs > 0)) THEN
+         DO ib1 = 1, nbdysegw        
+            DO ib2 = 1, nbdysegs
+               IF (( jpisdt(ib2)<=jpiwob(ib1)).AND. &
+                &  ( jpisft(ib2)>=jpiwob(ib1)).AND. &
+                &  ( jpjwdt(ib1)<=jpjsob(ib2)).AND. &
+                &  ( jpjwft(ib1)>=jpjsob(ib2))) THEN
+                  IF ((jpjwdt(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpiwob(ib1))) THEN 
+                     ! We have a possible South-West corner                      
+!                     WRITE(numout,*) ' Found a South-West corner at (i,j): ', jpisdt(ib2), jpjwdt(ib1) 
+!                     WRITE(numout,*) ' between segments: ', npckgw(ib1), npckgs(ib2)
+                     icornw(ib1,1) = npckgs(ib2)
+                     icorns(ib2,1) = npckgw(ib1)
+                  ELSEIF ((jpisft(ib2)==jpiwob(ib1)).AND.(jpjwft(ib1)==jpjsob(ib2))) THEN
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     &                                     jpisft(ib2), jpjwft(ib1)
+                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
+                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), & 
+                     &                                                    ' and South segment: ',npckgs(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  ELSE
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and West Open boundary indices'
+                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1) , &
+                     &                                                    ' and South segment: ',npckgs(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop+1
+                  END IF
+               END IF
+            END DO
+         END DO
+      END IF
+      !
+      ! South/East crossings
+      IF ((nbdysege > 0).AND.(nbdysegs > 0)) THEN
+         DO ib1 = 1, nbdysege
+            DO ib2 = 1, nbdysegs
+               IF (( jpisdt(ib2)<=jpieob(ib1)+1).AND. &
+                &  ( jpisft(ib2)>=jpieob(ib1)+1).AND. &
+                &  ( jpjedt(ib1)<=jpjsob(ib2)  ).AND. &
+                &  ( jpjeft(ib1)>=jpjsob(ib2)  )) THEN
+                  IF ((jpjedt(ib1)==jpjsob(ib2)).AND.(jpisft(ib2)==jpieob(ib1)+1)) THEN
+                     ! We have a possible South-East corner 
+!                     WRITE(numout,*) ' Found a South-East corner at (i,j): ', jpisft(ib2), jpjedt(ib1) 
+!                     WRITE(numout,*) ' between segments: ', npckge(ib1), npckgs(ib2)
+                     icorne(ib1,1) = npckgs(ib2)
+                     icorns(ib2,2) = npckge(ib1)
+                  ELSEIF ((jpjeft(ib1)==jpjsob(ib2)).AND.(jpisdt(ib2)==jpieob(ib1)+1)) THEN
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     &                                     jpisdt(ib2), jpjeft(ib1)
+                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
+                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
+                     &                                                    ' and South segment: ',npckgs(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  ELSE
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Check South and East Open boundary indices'
+                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
+                     &                                                    ' and South segment: ',npckgs(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  END IF
+               END IF
+            END DO
+         END DO
+      END IF
+      !
+      ! North/West crossings
+      IF ((nbdysegn > 0).AND.(nbdysegw > 0)) THEN
+         DO ib1 = 1, nbdysegw        
+            DO ib2 = 1, nbdysegn
+               IF (( jpindt(ib2)<=jpiwob(ib1)  ).AND. &
+                &  ( jpinft(ib2)>=jpiwob(ib1)  ).AND. &
+                &  ( jpjwdt(ib1)<=jpjnob(ib2)+1).AND. &
+                &  ( jpjwft(ib1)>=jpjnob(ib2)+1)) THEN
+                  IF ((jpjwft(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpiwob(ib1))) THEN
+                     ! We have a possible North-West corner 
+!                     WRITE(numout,*) ' Found a North-West corner at (i,j): ', jpindt(ib2), jpjwft(ib1) 
+!                     WRITE(numout,*) ' between segments: ', npckgw(ib1), npckgn(ib2)
+                     icornw(ib1,2) = npckgn(ib2)
+                     icornn(ib2,1) = npckgw(ib1)
+                  ELSEIF ((jpjwdt(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpiwob(ib1))) THEN
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     &                                     jpinft(ib2), jpjwdt(ib1)
+                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
+                     IF(lwp) WRITE(numout,*) '             Crossing problem with West segment: ',npckgw(ib1), &
+                     &                                                    ' and North segment: ',npckgn(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  ELSE
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and West Open boundary indices'
+                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with West segment: ',npckgw(ib1), &
+                     &                                                    ' and North segment: ',npckgn(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  END IF
+               END IF
+            END DO
+         END DO
+      END IF
+      !
+      ! North/East crossings
+      IF ((nbdysegn > 0).AND.(nbdysege > 0)) THEN
+         DO ib1 = 1, nbdysege        
+            DO ib2 = 1, nbdysegn
+               IF (( jpindt(ib2)<=jpieob(ib1)+1).AND. &
+                &  ( jpinft(ib2)>=jpieob(ib1)+1).AND. &
+                &  ( jpjedt(ib1)<=jpjnob(ib2)+1).AND. &
+                &  ( jpjeft(ib1)>=jpjnob(ib2)+1)) THEN
+                  IF ((jpjeft(ib1)==jpjnob(ib2)+1).AND.(jpinft(ib2)==jpieob(ib1)+1)) THEN
+                     ! We have a possible North-East corner 
+!                     WRITE(numout,*) ' Found a North-East corner at (i,j): ', jpinft(ib2), jpjeft(ib1)
+!                     WRITE(numout,*) ' between segments: ', npckge(ib1), npckgn(ib2)
+                     icorne(ib1,2) = npckgn(ib2)
+                     icornn(ib2,2) = npckge(ib1)
+                  ELSEIF ((jpjedt(ib1)==jpjnob(ib2)+1).AND.(jpindt(ib2)==jpieob(ib1)+1)) THEN
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Found an acute open boundary corner at point (i,j)= ', &
+                     &                                     jpindt(ib2), jpjedt(ib1)
+                     IF(lwp) WRITE(numout,*) ' ==========  Not allowed yet'
+                     IF(lwp) WRITE(numout,*) '             Crossing problem with East segment: ',npckge(ib1), &
+                     &                                                    ' and North segment: ',npckgn(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  ELSE
+                     IF(lwp) WRITE(numout,*)
+                     IF(lwp) WRITE(numout,*) ' E R R O R : Check North and East Open boundary indices'
+                     IF(lwp) WRITE(numout,*) ' ==========  Crossing problem with East segment: ',npckge(ib1), &
+                     &                                                    ' and North segment: ',npckgn(ib2)
+                     IF(lwp) WRITE(numout,*)
+                     nstop = nstop + 1
+                  END IF
+               END IF
+            END DO
+         END DO
+      END IF
+      !
+      ! 3. Check if segment extremities are on land
+      !-------------------------------------------- 
+      !
+      ! West segments
+      DO ib = 1, nbdysegw
+         ! get mask at boundary extremities:
+         ztestmask(1:2)=0.
+         DO ji = 1, jpi
+            DO jj = 1, jpj             
+              IF (((ji + nimpp - 1) == jpiwob(ib)).AND. & 
+               &  ((jj + njmpp - 1) == jpjwdt(ib))) ztestmask(1)=tmask(ji,jj,1)
+              IF (((ji + nimpp - 1) == jpiwob(ib)).AND. & 
+               &  ((jj + njmpp - 1) == jpjwft(ib))) ztestmask(2)=tmask(ji,jj,1)  
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF (ztestmask(1)==1) THEN 
+            IF (icornw(ib,1)==0) THEN
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
+               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
+               IF(lwp) WRITE(numout,*)
+               nstop = nstop + 1
+            ELSE
+               ! This is a corner
+               IF(lwp) WRITE(numout,*) 'Found a South-West corner at (i,j): ', jpiwob(ib), jpjwdt(ib)
+               CALL bdy_ctl_corn(npckgw(ib), icornw(ib,1))
+               itest=itest+1
+            ENDIF
+         ENDIF
+         IF (ztestmask(2)==1) THEN
+            IF (icornw(ib,2)==0) THEN
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgw(ib)
+               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
+               IF(lwp) WRITE(numout,*)
+               nstop = nstop + 1
+            ELSE
+               ! This is a corner
+               IF(lwp) WRITE(numout,*) 'Found a North-West corner at (i,j): ', jpiwob(ib), jpjwft(ib)
+               CALL bdy_ctl_corn(npckgw(ib), icornw(ib,2))
+               itest=itest+1
+            ENDIF
+         ENDIF
+      END DO
+      !
+      ! East segments
+      DO ib = 1, nbdysege
+         ! get mask at boundary extremities:
+         ztestmask(1:2)=0.
+         DO ji = 1, jpi
+            DO jj = 1, jpj             
+              IF (((ji + nimpp - 1) == jpieob(ib)+1).AND. & 
+               &  ((jj + njmpp - 1) == jpjedt(ib))) ztestmask(1)=tmask(ji,jj,1)
+              IF (((ji + nimpp - 1) == jpieob(ib)+1).AND. & 
+               &  ((jj + njmpp - 1) == jpjeft(ib))) ztestmask(2)=tmask(ji,jj,1)  
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF (ztestmask(1)==1) THEN
+            IF (icorne(ib,1)==0) THEN
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
+               IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
+               IF(lwp) WRITE(numout,*)
+               nstop = nstop + 1 
+            ELSE
+               ! This is a corner
+               IF(lwp) WRITE(numout,*) 'Found a South-East corner at (i,j): ', jpieob(ib)+1, jpjedt(ib)
+               CALL bdy_ctl_corn(npckge(ib), icorne(ib,1))
+               itest=itest+1
+            ENDIF
+         ENDIF
+         IF (ztestmask(2)==1) THEN
+            IF (icorne(ib,2)==0) THEN
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckge(ib)
+               IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
+               IF(lwp) WRITE(numout,*)
+               nstop = nstop + 1
+            ELSE
+               ! This is a corner
+               IF(lwp) WRITE(numout,*) 'Found a North-East corner at (i,j): ', jpieob(ib)+1, jpjeft(ib)
+               CALL bdy_ctl_corn(npckge(ib), icorne(ib,2))
+               itest=itest+1
+            ENDIF
+         ENDIF
+      END DO
+      !
+      ! South segments
+      DO ib = 1, nbdysegs
+         ! get mask at boundary extremities:
+         ztestmask(1:2)=0.
+         DO ji = 1, jpi
+            DO jj = 1, jpj             
+              IF (((jj + njmpp - 1) == jpjsob(ib)).AND. & 
+               &  ((ji + nimpp - 1) == jpisdt(ib))) ztestmask(1)=tmask(ji,jj,1)
+              IF (((jj + njmpp - 1) == jpjsob(ib)).AND. & 
+               &  ((ji + nimpp - 1) == jpisft(ib))) ztestmask(2)=tmask(ji,jj,1)  
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF ((ztestmask(1)==1).AND.(icorns(ib,1)==0)) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
+            IF(lwp) WRITE(numout,*) ' ==========  does not start on land or on a corner'                                                  
+            IF(lwp) WRITE(numout,*)
+            nstop = nstop + 1
+         ENDIF
+         IF ((ztestmask(2)==1).AND.(icorns(ib,2)==0)) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgs(ib)
+            IF(lwp) WRITE(numout,*) ' ==========  does not end on land or on a corner'                                                  
+            IF(lwp) WRITE(numout,*)
+            nstop = nstop + 1
+         ENDIF
+      END DO
+      !
+      ! North segments
+      DO ib = 1, nbdysegn
+         ! get mask at boundary extremities:
+         ztestmask(1:2)=0.
+         DO ji = 1, jpi
+            DO jj = 1, jpj             
+              IF (((jj + njmpp - 1) == jpjnob(ib)+1).AND. & 
+               &  ((ji + nimpp - 1) == jpindt(ib))) ztestmask(1)=tmask(ji,jj,1)
+              IF (((jj + njmpp - 1) == jpjnob(ib)+1).AND. & 
+               &  ((ji + nimpp - 1) == jpinft(ib))) ztestmask(2)=tmask(ji,jj,1)  
+            END DO
+         END DO
+         IF( lk_mpp )   CALL mpp_sum( ztestmask, 2 )   ! sum over the global domain
+
+         IF ((ztestmask(1)==1).AND.(icornn(ib,1)==0)) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
+            IF(lwp) WRITE(numout,*) ' ==========  does not start on land'                                                  
+            IF(lwp) WRITE(numout,*)
+            nstop = nstop + 1
+         ENDIF
+         IF ((ztestmask(2)==1).AND.(icornn(ib,2)==0)) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) ' E R R O R : Open boundary segment ', npckgn(ib)
+            IF(lwp) WRITE(numout,*) ' ==========  does not end on land'                                                  
+            IF(lwp) WRITE(numout,*)
+            nstop = nstop + 1
+         ENDIF
+      END DO
+      !
+      IF ((itest==0).AND.(lwp)) WRITE(numout,*) 'NO open boundary corner found'
+      !
+      ! Other tests TBD: 
+      ! segments completly on land
+      ! optimized open boundary array length according to landmask
+      ! Nudging layers that overlap with interior domain
+      !
+   END SUBROUTINE bdy_ctl_seg
+
+   SUBROUTINE bdy_ctl_corn( ib1, ib2 )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE bdy_ctl_corn  ***
+      !!
+      !! ** Purpose :   Check numerical schemes consistency between
+      !!                segments having a common corner
+      !!
+      !! ** Method  :   
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in)  ::   ib1, ib2
+      INTEGER :: itest
+      !!----------------------------------------------------------------------
+      itest = 0
+
+      IF( cn_dyn2d(ib1) /= cn_dyn2d(ib2) )   itest = itest + 1
+      IF( cn_dyn3d(ib1) /= cn_dyn3d(ib2) )   itest = itest + 1
+      IF( cn_tra  (ib1) /= cn_tra  (ib2) )   itest = itest + 1
+      !
+      IF( nn_dyn2d_dta(ib1) /= nn_dyn2d_dta(ib2) )   itest = itest + 1
+      IF( nn_dyn3d_dta(ib1) /= nn_dyn3d_dta(ib2) )   itest = itest + 1
+      IF( nn_tra_dta  (ib1) /= nn_tra_dta  (ib2) )   itest = itest + 1
+      !
+      IF( nn_rimwidth(ib1) /= nn_rimwidth(ib2) )   itest = itest + 1   
+      !
+      IF( itest>0 ) THEN
+         IF(lwp) WRITE(numout,*) ' E R R O R : Segments ', ib1, 'and ', ib2
+         IF(lwp) WRITE(numout,*) ' ==========  have different open bdy schemes'                                                  
+         IF(lwp) WRITE(numout,*)
+         nstop = nstop + 1
+      ENDIF
+      !
+   END SUBROUTINE bdy_ctl_corn
+
+   !!=================================================================================
+END MODULE bdyini
diff --git a/MY_SRC/diaharm.F90 b/MY_SRC/diaharm.F90
new file mode 100755
index 0000000..3bb42dc
--- /dev/null
+++ b/MY_SRC/diaharm.F90
@@ -0,0 +1,848 @@
+MODULE diaharm 
+   !!======================================================================
+   !!                       ***  MODULE  diaharm  ***
+   !! Harmonic analysis of tidal constituents 
+   !!======================================================================
+   !! History :  3.1  !  2007  (O. Le Galloudec, J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+#if defined key_diaharm 
+   !!----------------------------------------------------------------------
+   !!   'key_diaharm'
+   !!
+   !!   NB: 2017-12 : add 3D harmonic analysis of velocities
+   !!                 integration of Maria Luneva's development
+   !!   'key_3Ddiaharm'
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain
+   USE phycst
+   USE daymod
+   USE tide_mod
+   USE sbctide         ! Tidal forcing or not
+   !
+# if defined key_3Ddiaharm
+   USE zdf_oce
+#endif
+   !
+   USE in_out_manager  ! I/O units
+   USE iom             ! I/0 library
+   USE ioipsl          ! NetCDF IPSL library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE timing          ! preformance summary
+   USE wrk_nemo        ! working arrays
+
+   IMPLICIT NONE
+   PRIVATE
+
+   LOGICAL, PUBLIC, PARAMETER :: lk_diaharm  = .TRUE.
+   
+   INTEGER, PARAMETER :: jpincomax    = 2.*jpmax_harmo
+   INTEGER, PARAMETER :: jpdimsparse  = jpincomax*300*24
+
+   !                         !!** namelist variables **
+   INTEGER ::   nit000_han    ! First time step used for harmonic analysis
+   INTEGER ::   nitend_han    ! Last time step used for harmonic analysis
+   INTEGER ::   nstep_han     ! Time step frequency for harmonic analysis
+   INTEGER ::   nb_ana        ! Number of harmonics to analyse
+
+
+   INTEGER , ALLOCATABLE, DIMENSION(:)           ::   name
+   REAL(wp), ALLOCATABLE, DIMENSION(:)           ::   ana_freq, ut   , vt   , ft
+# if defined key_3Ddiaharm
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:,:)   ::   ana_temp
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)     ::   out_eta , out_u, out_v , out_w , out_dzi
+# else
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)     ::   ana_temp
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)       ::   out_eta , out_u, out_v
+# endif
+
+   INTEGER ::   ninco, nsparse
+   INTEGER ,       DIMENSION(jpdimsparse)         ::   njsparse, nisparse
+   INTEGER , SAVE, DIMENSION(jpincomax)           ::   ipos1
+   REAL(wp),       DIMENSION(jpdimsparse)         ::   valuesparse
+   REAL(wp),       DIMENSION(jpincomax)           ::   ztmp4 , ztmp7
+   REAL(wp), SAVE, DIMENSION(jpincomax,jpincomax) ::   ztmp3 , zpilier
+   REAL(wp), SAVE, DIMENSION(jpincomax)           ::   zpivot
+
+   CHARACTER (LEN=4), DIMENSION(jpmax_harmo) ::   tname   ! Names of tidal constituents ('M2', 'K1',...)
+
+   PUBLIC   dia_harm   ! routine called by step.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.5 , NEMO Consortium (2013)
+   !! $Id: diaharm.F90 5585 2015-07-10 14:19:11Z jchanut $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dia_harm_init 
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_harm_init  ***
+      !!         
+      !! ** Purpose :   Initialization of tidal harmonic analysis
+      !!
+      !! ** Method  :   Initialize frequency array and  nodal factor for nit000_han
+      !!
+      !!--------------------------------------------------------------------
+      INTEGER :: jh, nhan, jl
+      INTEGER ::   ios                 ! Local integer output status for namelist read
+
+      NAMELIST/nam_diaharm/ nit000_han, nitend_han, nstep_han, tname
+      !!----------------------------------------------------------------------
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dia_harm_init: Tidal harmonic analysis initialization'
+# if defined key_3Ddiaharm
+         WRITE(numout,*) '  - 3D harmonic analysis of currents actovated (key_3Ddiaharm)'
+#endif
+         WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+      !
+      IF( .NOT. ln_tide )   CALL ctl_stop( 'dia_harm_init : ln_tide must be true for harmonic analysis')
+      !
+      CALL tide_init_Wave
+      !
+      REWIND( numnam_ref )              ! Namelist nam_diaharm in reference namelist : Tidal harmonic analysis
+      READ  ( numnam_ref, nam_diaharm, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diaharm in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist nam_diaharm in configuration namelist : Tidal harmonic analysis
+      READ  ( numnam_cfg, nam_diaharm, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diaharm in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, nam_diaharm )
+      !
+      IF(lwp) THEN
+         WRITE(numout,*) 'First time step used for analysis:  nit000_han= ', nit000_han
+         WRITE(numout,*) 'Last  time step used for analysis:  nitend_han= ', nitend_han
+         WRITE(numout,*) 'Time step frequency for harmonic analysis:  nstep_han= ', nstep_han
+      ENDIF
+
+      ! Basic checks on harmonic analysis time window:
+      ! ----------------------------------------------
+      IF( nit000 > nit000_han )   CALL ctl_stop( 'dia_harm_init : nit000_han must be greater than nit000',   &
+         &                                       ' restart capability not implemented' )
+      IF( nitend < nitend_han )   CALL ctl_stop( 'dia_harm_init : nitend_han must be lower than nitend',   &
+         &                                       'restart capability not implemented' )
+
+      IF( MOD( nitend_han-nit000_han+1 , nstep_han ) /= 0 )   &
+         &                        CALL ctl_stop( 'dia_harm_init : analysis time span must be a multiple of nstep_han' )
+
+      nb_ana = 0
+      DO jh=1,jpmax_harmo
+         DO jl=1,jpmax_harmo
+            IF(TRIM(tname(jh)) == Wave(jl)%cname_tide) THEN
+               nb_ana=nb_ana+1
+            ENDIF
+         END DO
+      END DO
+      !
+      IF(lwp) THEN
+         WRITE(numout,*) '        Namelist nam_diaharm'
+         WRITE(numout,*) '        nb_ana    = ', nb_ana
+         CALL flush(numout)
+      ENDIF
+      !
+      IF (nb_ana > jpmax_harmo) THEN
+        IF(lwp) WRITE(numout,*) ' E R R O R dia_harm_init : nb_ana must be lower than jpmax_harmo, stop'
+        IF(lwp) WRITE(numout,*) ' jpmax_harmo= ', jpmax_harmo
+        nstop = nstop + 1
+      ENDIF
+
+      ALLOCATE(name    (nb_ana))
+      DO jh=1,nb_ana
+       DO jl=1,jpmax_harmo
+          IF (TRIM(tname(jh)) .eq. Wave(jl)%cname_tide) THEN
+             name(jh) = jl
+             EXIT
+          END IF
+       END DO
+      END DO
+
+      ! Initialize frequency array:
+      ! ---------------------------
+      ALLOCATE( ana_freq(nb_ana), ut(nb_ana), vt(nb_ana), ft(nb_ana) )
+
+      CALL tide_harmo( ana_freq, vt, ut, ft, name, nb_ana )
+
+      IF(lwp) WRITE(numout,*) 'Analysed frequency  : ',nb_ana ,'Frequency '
+
+      DO jh = 1, nb_ana
+        IF(lwp) WRITE(numout,*) '                    : ',tname(jh),' ',ana_freq(jh)
+      END DO
+
+      ! Initialize temporary arrays:
+      ! ----------------------------
+# if defined key_3Ddiaharm
+      ALLOCATE( ana_temp( jpi, jpj, 2*nb_ana, 5, jpk ) )
+      ana_temp(:,:,:,:,:) = 0._wp
+# else
+      ALLOCATE( ana_temp( jpi, jpj, 2*nb_ana, 3      ) )
+      ana_temp(:,:,:,:  ) = 0._wp
+#endif
+
+   END SUBROUTINE dia_harm_init
+
+
+   SUBROUTINE dia_harm ( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_harm  ***
+      !!         
+      !! ** Purpose :   Tidal harmonic analysis main routine
+      !!
+      !! ** Action  :   Sums ssh/u/v over time analysis [nit000_han,nitend_han]
+      !!
+      !!--------------------------------------------------------------------
+      INTEGER, INTENT( IN ) :: kt
+      !
+      INTEGER  :: ji, jj, jh, jc, nhc
+# if defined key_3Ddiaharm
+      INTEGER  :: jk
+# endif
+      REAL(wp) :: ztime, ztemp
+      !!--------------------------------------------------------------------
+      IF( nn_timing == 1 )   CALL timing_start('dia_harm')
+
+      IF( kt == nit000 ) CALL dia_harm_init
+
+      IF( kt >= nit000_han .AND. kt <= nitend_han .AND. MOD(kt,nstep_han) == 0 ) THEN
+
+         ztime = (kt-nit000+1) * rdt 
+
+         !IF(lwp) WRITE(numout,*) "ztime OLD", kt, ztime, sshn(25,25)
+ 
+         nhc = 0
+         DO jh = 1, nb_ana
+            DO jc = 1, 2
+               nhc = nhc+1
+               ztemp =(     MOD(jc,2) * ft(jh) *COS(ana_freq(jh)*ztime + vt(jh) + ut(jh))  &
+                  &    +(1.-MOD(jc,2))* ft(jh) *SIN(ana_freq(jh)*ztime + vt(jh) + ut(jh)))
+
+! ssh, ub, vb are stored at the last level of 5d array
+               DO jj = 1,jpj
+                  DO ji = 1,jpi
+                     ! Elevation and currents
+# if defined key_3Ddiaharm
+                     ana_temp(ji,jj,nhc,1,jpk) = ana_temp(ji,jj,nhc,1,jpk) + ztemp*sshn(ji,jj)*ssmask (ji,jj)        
+                     ana_temp(ji,jj,nhc,2,jpk) = ana_temp(ji,jj,nhc,2,jpk) + ztemp*un_b(ji,jj)*ssumask(ji,jj)
+                     ana_temp(ji,jj,nhc,3,jpk) = ana_temp(ji,jj,nhc,3,jpk) + ztemp*vn_b(ji,jj)*ssvmask(ji,jj)
+
+                     ana_temp(ji,jj,nhc,5,jpk) = ana_temp(ji,jj,nhc,5,jpk)                               &
+                   &                              + ztemp*bfrva(ji,jj)*vn(ji,jj,mbkv(ji,jj))*ssvmask(ji,jj)
+                     ana_temp(ji,jj,nhc,4,jpk) = ana_temp(ji,jj,nhc,4,jpk)                               & 
+                   &                              + ztemp*bfrua(ji,jj)*un(ji,jj,mbku(ji,jj))*ssumask(ji,jj)
+# else
+                      ana_temp(ji,jj,nhc,1) = ana_temp(ji,jj,nhc,1) + ztemp*sshn(ji,jj)*ssmask (ji,jj)        
+                      ana_temp(ji,jj,nhc,2) = ana_temp(ji,jj,nhc,2) + ztemp*un_b(ji,jj)*ssumask(ji,jj)
+                      ana_temp(ji,jj,nhc,3) = ana_temp(ji,jj,nhc,3) + ztemp*vn_b(ji,jj)*ssvmask(ji,jj)
+# endif
+                  END DO
+               END DO
+               !
+# if defined key_3Ddiaharm
+! 3d velocity and density:
+             DO jk=1,jpk-1
+               DO jj = 1,jpj
+                  DO ji = 1,jpi
+                     ! density and velocity
+                     ana_temp(ji,jj,nhc,1,jk) = ana_temp(ji,jj,nhc,1,jk) + ztemp*rhd(ji,jj,jk)
+                     ana_temp(ji,jj,nhc,2,jk) = ana_temp(ji,jj,nhc,2,jk) + ztemp*(un(ji,jj,jk)-un_b(ji,jj)) &
+                &                                          *umask(ji,jj,jk)
+                     ana_temp(ji,jj,nhc,3,jk) = ana_temp(ji,jj,nhc,3,jk) + ztemp*(vn(ji,jj,jk)-vn_b(ji,jj)) &
+                &                                          *vmask(ji,jj,jk) 
+                     ana_temp(ji,jj,nhc,4,jk) = ana_temp(ji,jj,nhc,4,jk) + ztemp*wn(ji,jj,jk)
+ 
+                     ana_temp(ji,jj,nhc,5,jk) = ana_temp(ji,jj,nhc,5,jk) - 0.5*grav*ztemp*(rhd(ji,jj,jk)+rhd(ji,jj,jk+1) )/max(rn2(ji,jj,jk),1.e-8_wp)
+!                     IF(jk<=mbathy(ji,jj) )      ana_temp(ji,jj,nhc,5,jk) = ana_temp(ji,jj,nhc,5,jk) -      &
+!                &          0.5*grav*ztemp*(rhd(ji,jj,jk)+rhd(ji,jj,jk+1) )/max(rn2(ji,jj,jk),1.e-8_wp)
+                  END DO
+               END DO
+             ENDDO
+# endif
+
+            END DO
+         END DO
+         !       
+      END IF
+
+      IF ( kt == nitend_han )   CALL dia_harm_end
+
+      IF( nn_timing == 1 )   CALL timing_stop('dia_harm')
+ 
+   END SUBROUTINE dia_harm
+
+
+   SUBROUTINE dia_harm_end
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE diaharm_end  ***
+      !!         
+      !! ** Purpose :  Compute the Real and Imaginary part of tidal constituents
+      !!
+      !! ** Action  :  Decompose the signal on the harmonic constituents 
+      !!
+      !!--------------------------------------------------------------------
+      INTEGER :: ji, jj, jh, jc, jn, nhan, jl 
+# if defined key_3Ddiaharm
+      INTEGER  :: jk
+# endif
+      INTEGER :: ksp, kun, keq
+      REAL(wp) :: ztime, ztime_ini, ztime_end
+      REAL(wp) :: X1,X2
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) :: ana_amp
+      !!--------------------------------------------------------------------
+      CALL wrk_alloc( jpi , jpj , jpmax_harmo , 2 , ana_amp )
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'anharmo_end: kt=nitend_han: Perform harmonic analysis'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+
+      ztime_ini = nit000_han*rdt                 ! Initial time in seconds at the beginning of analysis
+      ztime_end = nitend_han*rdt                 ! Final time in seconds at the end of analysis
+      nhan = (nitend_han-nit000_han+1)/nstep_han ! Number of dumps used for analysis
+
+# if defined key_3Ddiaharm
+      ALLOCATE( out_eta(jpi,jpj,jpk,2*nb_ana),   &
+         &      out_u  (jpi,jpj,jpk,2*nb_ana),   &
+         &      out_v  (jpi,jpj,jpk,2*nb_ana),   &
+         &      out_w  (jpi,jpj,jpk,2*nb_ana),   &
+         &      out_dzi(jpi,jpj,jpk,2*nb_ana) )
+# else
+      ALLOCATE( out_eta(jpi,jpj,2*nb_ana),   &
+         &      out_u  (jpi,jpj,2*nb_ana),   &
+         &      out_v  (jpi,jpj,2*nb_ana)  )
+# endif
+
+      IF(lwp) WRITE(numout,*) 'ANA F OLD', ft 
+      IF(lwp) WRITE(numout,*) 'ANA U OLD', ut
+      IF(lwp) WRITE(numout,*) 'ANA V OLD', vt
+
+
+      ninco = 2*nb_ana
+      ksp = 0
+      keq = 0        
+      DO jn = 1, nhan
+         ztime=( (nhan-jn)*ztime_ini + (jn-1)*ztime_end )/FLOAT(nhan-1)
+         keq = keq + 1
+         kun = 0
+         DO jh = 1, nb_ana
+            DO jc = 1, 2
+               kun = kun + 1
+               ksp = ksp + 1
+               nisparse(ksp) = keq
+               njsparse(ksp) = kun
+               valuesparse(ksp) = (   MOD(jc,2) * ft(jh) * COS(ana_freq(jh)*ztime + vt(jh) + ut(jh))   &
+                  &             + (1.-MOD(jc,2))* ft(jh) * SIN(ana_freq(jh)*ztime + vt(jh) + ut(jh)) )
+            END DO
+         END DO
+      END DO
+
+      nsparse = ksp
+
+      ! Density and Elevation:
+# if defined key_3Ddiaharm
+    DO jk=1,jpk
+# endif
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! Fill input array
+            kun = 0
+            DO jh = 1, nb_ana
+               DO jc = 1, 2
+                  kun = kun + 1
+# if defined key_3Ddiaharm
+                  ztmp4(kun)=ana_temp(ji,jj,kun,1,jk)
+# else
+                  ztmp4(kun)=ana_temp(ji,jj,kun,1)
+# endif
+               END DO
+            END DO
+
+            CALL SUR_DETERMINE(jj)
+
+            ! Fill output array
+            DO jh = 1, nb_ana
+               ana_amp(ji,jj,jh,1)=ztmp7((jh-1)*2+1)
+               ana_amp(ji,jj,jh,2)=ztmp7((jh-1)*2+2)
+            END DO
+         END DO
+      END DO
+
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jh = 1, nb_ana 
+               X1 = ana_amp(ji,jj,jh,1)
+               X2 =-ana_amp(ji,jj,jh,2)
+# if defined key_3Ddiaharm
+               out_eta(ji,jj,jk,jh       ) = X1 * tmask_i(ji,jj)
+               out_eta(ji,jj,jk,jh+nb_ana) = X2 * tmask_i(ji,jj)
+# else
+               out_eta(ji,jj   ,jh       ) = X1 * tmask_i(ji,jj)
+               out_eta(ji,jj   ,jh+nb_ana) = X2 * tmask_i(ji,jj)
+# endif
+            END DO
+         END DO
+      END DO
+
+      ! u-component of velocity
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! Fill input array
+            kun=0
+            DO jh = 1,nb_ana
+               DO jc = 1,2
+                  kun = kun + 1
+# if defined key_3Ddiaharm
+                  ztmp4(kun)=ana_temp(ji,jj,kun,2,jk)
+# else
+                  ztmp4(kun)=ana_temp(ji,jj,kun,2)
+# endif
+               END DO
+            END DO
+
+            CALL SUR_DETERMINE(jj+1)
+
+            ! Fill output array
+            DO jh = 1, nb_ana
+               ana_amp(ji,jj,jh,1) = ztmp7((jh-1)*2+1)
+               ana_amp(ji,jj,jh,2) = ztmp7((jh-1)*2+2)
+            END DO
+
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jh = 1, nb_ana 
+               X1= ana_amp(ji,jj,jh,1)
+               X2=-ana_amp(ji,jj,jh,2)
+# if defined key_3Ddiaharm
+               out_u(ji,jj,jk,       jh) = X1 * ssumask(ji,jj)
+               out_u(ji,jj,jk,nb_ana+jh) = X2 * ssumask(ji,jj)
+# else
+               out_u(ji,jj,          jh) = X1 * ssumask(ji,jj)
+               out_u(ji,jj,   nb_ana+jh) = X2 * ssumask(ji,jj)
+# endif
+            ENDDO
+         ENDDO
+      ENDDO
+
+      ! v- velocity
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! Fill input array
+            kun=0
+            DO jh = 1,nb_ana
+               DO jc = 1,2
+                  kun = kun + 1
+# if defined key_3Ddiaharm
+                  ztmp4(kun)=ana_temp(ji,jj,kun,3,jk)
+# else
+                  ztmp4(kun)=ana_temp(ji,jj,kun,3)
+# endif
+               END DO
+            END DO
+
+            CALL SUR_DETERMINE(jj+1)
+
+            ! Fill output array
+            DO jh = 1, nb_ana
+               ana_amp(ji,jj,jh,1)=ztmp7((jh-1)*2+1)
+               ana_amp(ji,jj,jh,2)=ztmp7((jh-1)*2+2)
+            END DO
+
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jh = 1, nb_ana 
+               X1=ana_amp(ji,jj,jh,1)
+               X2=-ana_amp(ji,jj,jh,2)
+# if defined key_3Ddiaharm
+               out_v(ji,jj,jk,       jh)=X1 * ssvmask(ji,jj)
+               out_v(ji,jj,jk,nb_ana+jh)=X2 * ssvmask(ji,jj)
+# else
+               out_v(ji,jj,          jh)=X1 * ssvmask(ji,jj)
+               out_v(ji,jj,   nb_ana+jh)=X2 * ssvmask(ji,jj)
+# endif
+            END DO
+         END DO
+      END DO
+
+# if defined key_3Ddiaharm
+      ! w- velocity
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! Fill input array
+            kun=0
+            DO jh = 1,nb_ana
+               DO jc = 1,2
+                  kun = kun + 1
+                  ztmp4(kun)=ana_temp(ji,jj,kun,4,jk)
+               END DO
+            END DO
+
+            CALL SUR_DETERMINE(jj+1)
+
+            ! Fill output array
+            DO jh = 1, nb_ana
+               ana_amp(ji,jj,jh,1)=ztmp7((jh-1)*2+1)
+               ana_amp(ji,jj,jh,2)=ztmp7((jh-1)*2+2)
+            END DO
+
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jh = 1, nb_ana
+               X1=ana_amp(ji,jj,jh,1)
+               X2=-ana_amp(ji,jj,jh,2)
+               out_w(ji,jj,jk,       jh)=X1 * tmask_i(ji,jj)
+               out_w(ji,jj,jk,nb_ana+jh)=X2 * tmask_i(ji,jj)
+            END DO
+         END DO
+      END DO
+
+       ! dzi- isopycnal displacements
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            ! Fill input array
+            kun=0
+            DO jh = 1,nb_ana
+               DO jc = 1,2
+                  kun = kun + 1
+                  ztmp4(kun)=ana_temp(ji,jj,kun,5,jk)
+               END DO
+            END DO
+
+            CALL SUR_DETERMINE(jj+1)
+
+            ! Fill output array
+            DO jh = 1, nb_ana
+               ana_amp(ji,jj,jh,1)=ztmp7((jh-1)*2+1)
+               ana_amp(ji,jj,jh,2)=ztmp7((jh-1)*2+2)
+            END DO
+
+         END DO
+      END DO
+
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            DO jh = 1, nb_ana
+               X1=ana_amp(ji,jj,jh,1)
+               X2=-ana_amp(ji,jj,jh,2)
+               out_dzi(ji,jj,jk,       jh)=X1 * tmask_i(ji,jj)
+               out_dzi(ji,jj,jk,nb_ana+jh)=X2 * tmask_i(ji,jj)
+            END DO
+         END DO
+      END DO
+
+   ENDDO ! jk
+# endif
+
+      CALL dia_wri_harm ! Write results in files
+      CALL wrk_dealloc( jpi , jpj , jpmax_harmo , 2 , ana_amp )
+      !
+   END SUBROUTINE dia_harm_end
+
+
+   SUBROUTINE dia_wri_harm
+      !!--------------------------------------------------------------------
+      !!                 ***  ROUTINE dia_wri_harm  ***
+      !!         
+      !! ** Purpose : Write tidal harmonic analysis results in a netcdf file
+      !!--------------------------------------------------------------------
+      CHARACTER(LEN=lc) :: cltext
+      CHARACTER(LEN=lc) ::   &
+         cdfile_name_T   ,   & ! name of the file created (T-points)
+         cdfile_name_U   ,   & ! name of the file created (U-points)
+         cdfile_name_V         ! name of the file created (V-points)
+      INTEGER  ::   jh
+
+# if defined key_3Ddiaharm
+      CHARACTER(LEN=lc) :: cdfile_name_W         ! name of the file created (W-points)
+      INTEGER  :: jk
+      REAL(WP), ALLOCATABLE, DIMENSION (:,:,:) :: z3real, z3im 
+      REAL(WP), ALLOCATABLE, DIMENSION (:,:)   :: z2real, z2im      
+# endif
+!!----------------------------------------------------------------------
+
+#if defined key_dimgout
+      cdfile_name_T = TRIM(cexper)//'_Tidal_harmonics_gridT.dimgproc'
+      cdfile_name_U = TRIM(cexper)//'_Tidal_harmonics_gridU.dimgproc'
+      cdfile_name_V = TRIM(cexper)//'_Tidal_harmonics_gridV.dimgproc'
+#   if defined key_3Ddiaharm
+      cdfile_name_W = TRIM(cexper)//'_Tidal_harmonics_gridW.dimgproc'
+#   endif
+#endif
+
+      IF(lwp) WRITE(numout,*) '  '
+      IF(lwp) WRITE(numout,*) 'dia_wri_harm : Write harmonic analysis results'
+#if defined key_dimgout
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~  Output files: ', TRIM(cdfile_name_T)
+      IF(lwp) WRITE(numout,*) '                             ', TRIM(cdfile_name_U)
+      IF(lwp) WRITE(numout,*) '                             ', TRIM(cdfile_name_V)
+#   if defined key_3Ddiaharm
+      IF(lwp) WRITE(numout,*) '                             ', TRIM(cdfile_name_W)
+#   endif
+#endif
+      IF(lwp) WRITE(numout,*) '  '
+
+# if defined key_3Ddiaharm
+      ALLOCATE( z3real(jpi,jpj,jpk),z3im(jpi,jpj,jpk),z2real(jpi,jpj),z2im(jpi,jpj))
+# endif
+
+      ! A) density and elevation
+      !/////////////
+      !
+#if defined key_dimgout
+      cltext='density amplitude and phase; elevation is level=jpk '
+      CALL dia_wri_dimg(TRIM(cdfile_name_T), TRIM(cltext), out_eta, 2*nb_ana, '2')
+#else
+#   if defined key_3Ddiaharm
+      z3real(:,:,:) = 0._wp; z3im(:,:,:) = 0._wp
+#   endif
+      DO jh = 1, nb_ana
+#   if defined key_3Ddiaharm
+        DO jk=1,jpkm1
+          z3real(:,:,jk)=out_eta(:,:,jk,jh)
+          z3im  (:,:,jk)=out_eta(:,:,jk,jh+nb_ana)
+        ENDDO
+      z2real(:,:)=out_eta(:,:,jpk,jh); z2im(:,:)=out_eta(:,:,jpk,jh+nb_ana)
+      CALL iom_put( TRIM(tname(jh))//'x_ro', z3real(:,:,:) )
+      CALL iom_put( TRIM(tname(jh))//'y_ro', z3im  (:,:,:) )
+      CALL iom_put( TRIM(tname(jh))//'x'   , z2real(:,:  ) )
+      CALL iom_put( TRIM(tname(jh))//'y'   , z2im  (:,:  ) )
+#   else 
+      WRITE(numout,*) "OUTPUT ORI: ", TRIM(tname(jh))//'x', ' & ', TRIM(tname(jh))//'y', MAXVAL(out_eta(:,:,jh))
+      CALL iom_put( TRIM(tname(jh))//'x', out_eta(:,:,jh) )
+      CALL iom_put( TRIM(tname(jh))//'y', out_eta(:,:,nb_ana+jh) )
+#   endif
+      END DO
+#endif
+
+      ! B) u
+      !/////////
+      !
+#if defined key_dimgout
+      cltext='3d u amplitude and phase; ubar is the last level'
+      CALL dia_wri_dimg(TRIM(cdfile_name_U), TRIM(cltext), out_u, 2*nb_ana, '2')
+#else
+#   if defined key_3Ddiaharm
+      z3real(:,:,:) = 0._wp; z3im(:,:,:) = 0._wp
+#   endif
+      DO jh = 1, nb_ana
+#   if defined key_3Ddiaharm
+        DO jk=1,jpkm1
+          z3real(:,:,jk)=out_u(:,:,jk,jh)
+          z3im  (:,:,jk)=out_u(:,:,jk,jh+nb_ana)
+        ENDDO
+        z2real(:,:)=out_u(:,:,jpk,jh); z2im(:,:)=out_u(:,:,jpk,jh+nb_ana)
+        CALL iom_put( TRIM(tname(jh))//'x_u3d', z3real(:,:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_u3d', z3im (:,:,:)  )
+        CALL iom_put( TRIM(tname(jh))//'x_u2d', z2real(:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_u2d', z2im (:,:)  )
+        z2real(:,:)=out_w(:,:,jpk,jh); z2im(:,:)=out_w(:,:,jpk,jh+nb_ana)
+        CALL iom_put( TRIM(tname(jh))//'x_tabx', z2real(:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_tabx', z2im (:,:)  )
+#   else
+        CALL iom_put( TRIM(tname(jh))//'x_u2d', out_u(:,:,jh) )
+        CALL iom_put( TRIM(tname(jh))//'y_u2d', out_u(:,:,nb_ana+jh) )
+#   endif
+      END DO
+#endif
+
+      ! C) v
+      !/////////
+      !
+#if defined key_dimgout
+      cltext='3d v amplitude and phase; vbar is the last level'
+      CALL dia_wri_dimg(TRIM(cdfile_name_V), TRIM(cltext), out_v, 2*nb_ana, '2')
+#else
+#   if defined key_3Ddiaharm
+      z3real(:,:,:) = 0._wp; z3im(:,:,:) = 0._wp
+#   endif
+      DO jh = 1, nb_ana
+#   if defined key_3Ddiaharm
+        DO jk=1,jpkm1
+          z3real(:,:,jk)=out_v(:,:,jk,jh)
+          z3im  (:,:,jk)=out_v(:,:,jk,jh+nb_ana)
+        ENDDO
+        z2real(:,:)=out_v(:,:,jpk,jh); z2im(:,:)=out_v(:,:,jpk,jh+nb_ana)
+        CALL iom_put( TRIM(tname(jh))//'x_v3d', z3real(:,:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_v3d', z3im (:,:,:)  )
+        CALL iom_put( TRIM(tname(jh))//'x_v2d'  , z2real(:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_v2d'  , z2im (:,:)  )
+        z2real(:,:)=out_dzi(:,:,jpk,jh); z2im(:,:)=out_dzi(:,:,jpk,jh+nb_ana)
+        CALL iom_put( TRIM(tname(jh))//'x_taby', z2real(:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_taby', z2im (:,:)  )
+#   else
+         CALL iom_put( TRIM(tname(jh))//'x_v2d', out_v(:,:,jh       ) )
+         CALL iom_put( TRIM(tname(jh))//'y_v2d', out_v(:,:,jh+nb_ana) )
+#   endif
+       END DO
+
+#endif
+      ! D) w
+# if defined key_3Ddiaharm
+#   if defined key_dimgout
+      cltext='3d w amplitude and phase; vort_baro is the last level'
+      CALL dia_wri_dimg(TRIM(cdfile_name_W), TRIM(cltext), out_w, 2*nb_ana, '2')
+#   else
+      DO jh = 1, nb_ana
+        DO jk=1,jpkm1
+         z3real(:,:,jk)=out_w(:,:,jk,jh)
+         z3im(:,:,jk)=out_w(:,:,jk,jh+nb_ana)
+        ENDDO
+        CALL iom_put( TRIM(tname(jh))//'x_w3d', z3real(:,:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_w3d', z3im(:,:,:) )
+      END DO
+#   endif
+
+!       E) dzi + tau_bot
+#   if defined key_dimgout
+      cltext='dzi=g*ro/N2 amplitude and phase'
+      CALL dia_wri_dimg(TRIM(cdfile_name_W), TRIM(cltext), out_w, 2*nb_ana, '2')
+#   else
+      DO jh = 1, nb_ana
+        DO jk=1,jpkm1
+         z3real(:,:,jk)=out_dzi(:,:,jk,jh)
+         z3im(:,:,jk)=out_dzi(:,:,jk,jh+nb_ana)
+        ENDDO
+        CALL iom_put( TRIM(tname(jh))//'x_dzi', z3real(:,:,:) )
+        CALL iom_put( TRIM(tname(jh))//'y_dzi', z3im(:,:,:) )
+      END DO
+#   endif
+# endif 
+
+      !
+# if defined key_3Ddiaharm
+   DEALLOCATE(z3real, z3im, z2real,z2im)
+# endif
+
+   END SUBROUTINE dia_wri_harm
+
+
+   SUBROUTINE SUR_DETERMINE(init)
+      !!---------------------------------------------------------------------------------
+      !!                      *** ROUTINE SUR_DETERMINE ***
+      !!    
+      !!    
+      !!       
+      !!---------------------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   init 
+      !
+      INTEGER                         :: ji_sd, jj_sd, ji1_sd, ji2_sd, jk1_sd, jk2_sd
+      REAL(wp)                        :: zval1, zval2, zx1
+      REAL(wp), POINTER, DIMENSION(:) :: ztmpx, zcol1, zcol2
+      INTEGER , POINTER, DIMENSION(:) :: ipos2, ipivot
+      !---------------------------------------------------------------------------------
+      CALL wrk_alloc( jpincomax , ztmpx , zcol1 , zcol2 )
+      CALL wrk_alloc( jpincomax , ipos2 , ipivot        )
+            
+      IF( init == 1 ) THEN
+         IF( nsparse > jpdimsparse )   CALL ctl_stop( 'STOP', 'SUR_DETERMINE : nsparse .GT. jpdimsparse')
+         IF( ninco   > jpincomax   )   CALL ctl_stop( 'STOP', 'SUR_DETERMINE : ninco .GT. jpincomax')
+         !
+         ztmp3(:,:) = 0._wp
+         !
+         DO jk1_sd = 1, nsparse
+            DO jk2_sd = 1, nsparse
+               nisparse(jk2_sd) = nisparse(jk2_sd)
+               njsparse(jk2_sd) = njsparse(jk2_sd)
+               IF( nisparse(jk2_sd) == nisparse(jk1_sd) ) THEN
+                  ztmp3(njsparse(jk1_sd),njsparse(jk2_sd)) = ztmp3(njsparse(jk1_sd),njsparse(jk2_sd))  &
+                     &                                     + valuesparse(jk1_sd)*valuesparse(jk2_sd)
+               ENDIF
+            END DO
+         END DO
+         !
+         DO jj_sd = 1 ,ninco
+            ipos1(jj_sd) = jj_sd
+            ipos2(jj_sd) = jj_sd
+         END DO
+         !
+         DO ji_sd = 1 , ninco
+            !
+            !find greatest non-zero pivot:
+            zval1 = ABS(ztmp3(ji_sd,ji_sd))
+            !
+            ipivot(ji_sd) = ji_sd
+            DO jj_sd = ji_sd, ninco
+               zval2 = ABS(ztmp3(ji_sd,jj_sd))
+               IF( zval2.GE.zval1 )THEN
+                  ipivot(ji_sd) = jj_sd
+                  zval1         = zval2
+               ENDIF
+            END DO
+            !
+            DO ji1_sd = 1, ninco
+               zcol1(ji1_sd)               = ztmp3(ji1_sd,ji_sd)
+               zcol2(ji1_sd)               = ztmp3(ji1_sd,ipivot(ji_sd))
+               ztmp3(ji1_sd,ji_sd)         = zcol2(ji1_sd)
+               ztmp3(ji1_sd,ipivot(ji_sd)) = zcol1(ji1_sd)
+            END DO
+            !
+            ipos2(ji_sd)         = ipos1(ipivot(ji_sd))
+            ipos2(ipivot(ji_sd)) = ipos1(ji_sd)
+            ipos1(ji_sd)         = ipos2(ji_sd)
+            ipos1(ipivot(ji_sd)) = ipos2(ipivot(ji_sd))
+            zpivot(ji_sd)        = ztmp3(ji_sd,ji_sd)
+            DO jj_sd = 1, ninco
+               ztmp3(ji_sd,jj_sd) = ztmp3(ji_sd,jj_sd) / zpivot(ji_sd)
+            END DO
+            !
+            DO ji2_sd = ji_sd+1, ninco
+               zpilier(ji2_sd,ji_sd)=ztmp3(ji2_sd,ji_sd)
+               DO jj_sd=1,ninco
+                  ztmp3(ji2_sd,jj_sd)=  ztmp3(ji2_sd,jj_sd) - ztmp3(ji_sd,jj_sd) * zpilier(ji2_sd,ji_sd)
+               END DO
+            END DO
+            !
+         END DO
+         !
+      ENDIF ! End init==1
+
+      DO ji_sd = 1, ninco
+         ztmp4(ji_sd) = ztmp4(ji_sd) / zpivot(ji_sd)
+         DO ji2_sd = ji_sd+1, ninco
+            ztmp4(ji2_sd) = ztmp4(ji2_sd) - ztmp4(ji_sd) * zpilier(ji2_sd,ji_sd)
+         END DO
+      END DO
+
+      !system solving: 
+      ztmpx(ninco) = ztmp4(ninco) / ztmp3(ninco,ninco)
+      ji_sd = ninco
+      DO ji_sd = ninco-1, 1, -1
+         zx1 = 0._wp
+         DO jj_sd = ji_sd+1, ninco
+            zx1 = zx1 + ztmpx(jj_sd) * ztmp3(ji_sd,jj_sd)
+         END DO
+         ztmpx(ji_sd) = ztmp4(ji_sd)-zx1
+      END DO
+
+      DO jj_sd =1, ninco
+         ztmp7(ipos1(jj_sd))=ztmpx(jj_sd)
+      END DO
+
+      CALL wrk_dealloc( jpincomax , ztmpx , zcol1 , zcol2 )
+      CALL wrk_dealloc( jpincomax , ipos2 , ipivot        )
+      !
+   END SUBROUTINE SUR_DETERMINE
+
+#else
+   !!----------------------------------------------------------------------
+   !!   Default case :   Empty module
+   !!----------------------------------------------------------------------
+   LOGICAL, PUBLIC, PARAMETER ::   lk_diaharm = .FALSE.
+CONTAINS
+   SUBROUTINE dia_harm ( kt )     ! Empty routine
+      INTEGER, INTENT( IN ) :: kt  
+      WRITE(*,*) 'dia_harm: you should not have seen this print'
+   END SUBROUTINE dia_harm
+#endif
+
+   !!======================================================================
+END MODULE diaharm
diff --git a/MY_SRC/diaharm_fast.F90 b/MY_SRC/diaharm_fast.F90
new file mode 100755
index 0000000..66ba75e
--- /dev/null
+++ b/MY_SRC/diaharm_fast.F90
@@ -0,0 +1,857 @@
+MODULE diaharm_fast 
+   !!======================================================================
+   !!                       ***  MODULE  example  ***
+   !! Ocean physics:  On line harmonic analyser
+   !!                 
+   !!=====================================================================
+
+#if defined key_diaharm_fast 
+
+   !!----------------------------------------------------------------------
+   !!   'key_harm_ana'  :                Calculate harmonic analysis
+   !!----------------------------------------------------------------------
+   !!   harm_ana        :
+   !!   harm_ana_init   :
+   !!   NB: 2017-12 : add 3D harmonic analysis of velocities
+   !!                 integration of Maria Luneva's development
+   !!   'key_3Ddiaharm'
+   !!----------------------------------------------------------------------
+
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE iom
+   USE in_out_manager  ! I/O units
+   USE phycst          ! physical constants
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE bdy_oce         ! ocean open boundary conditions
+   USE bdytides        ! tidal bdy forcing
+   USE daymod          ! calendar
+   USE tideini
+   USE restart
+   USE ioipsl, ONLY : ju2ymds    ! for calendar
+   !
+   !
+   USE timing          ! preformance summary
+   USE zdf_oce
+
+   IMPLICIT NONE
+   PRIVATE
+
+   !! *  Routine accessibility
+   PUBLIC dia_harm_fast                                      ! routine called in step.F90 module
+   LOGICAL, PUBLIC, PARAMETER :: lk_diaharm_fast  = .TRUE.   ! to be run or not
+   LOGICAL, PUBLIC :: lk_diaharm_2D   ! = .TRUE.   ! to run 2d
+   LOGICAL, PUBLIC :: lk_diaharm_3D   ! = .TRUE.   ! to run 3d
+
+   !! * Module variables
+   INTEGER, PARAMETER ::  nharm_max  = jpmax_harmo  ! max number of harmonics to be analysed 
+   INTEGER, PARAMETER ::  nhm_max    = 2*nharm_max+1 
+   INTEGER, PARAMETER ::  nvab       = 2 ! number of 3D variables
+   INTEGER            ::  nharm
+   INTEGER            ::  nhm 
+   INTEGER ::                 & !!! ** toto namelist (namtoto) **
+      nflag  =  1                ! default value of nflag 
+   REAL(wp), DIMENSION(nharm_max) ::                & 
+      om_tide                     ! tidal frequencies ( rads/sec)
+   REAL(wp), ALLOCATABLE,SAVE,DIMENSION(:)   ::                & 
+      bzz,c,x    ! work arrays
+   REAL(wp) :: cca,ssa,zm,bt,dd_cumul
+!
+   REAL(wp), PUBLIC ::   fjulday_startharm       !: Julian Day since start of harmonic analysis
+   REAL(wp), PUBLIC, ALLOCATABLE,DIMENSION(:) :: anau, anav, anaf   ! nodel/phase corrections used by diaharmana
+   REAL(WP), ALLOCATABLE,SAVE,DIMENSION(:,:)   :: cc,a
+!
+   INTEGER ::  nvar_2d, nvar_3d    !: number of 2d and 3d variables to analyse
+   INTEGER, ALLOCATABLE,DIMENSION(:) :: m_posi_2d, m_posi_3d
+
+!  Name of variables used in the restart
+   CHARACTER( LEN = 10 ), DIMENSION(5), PARAMETER :: m_varName2d = (/'ssh','u2d','v2d','ubfr','vbfr'/)
+   CHARACTER( LEN = 10 ), DIMENSION(4), PARAMETER :: m_varName3d = (/'rho','u3d','v3d','w3d'/)
+!
+   REAL(wp), ALLOCATABLE,SAVE,DIMENSION(:,:,:,:  ) :: g_cosamp2D, g_sinamp2D, g_cumul_var2D
+   REAL(wp), ALLOCATABLE,SAVE,DIMENSION(:,:,:,:,:) :: g_cosamp3D, g_sinamp3D, g_cumul_var3D  
+!
+   REAL(wp), ALLOCATABLE,SAVE,DIMENSION(:,:)       :: g_out2D,h_out2D  ! arrays for output
+   REAL(wp), ALLOCATABLE,SAVE,DIMENSION(:,:,:)     :: g_out3D,h_out3D  ! arrays for 3D output
+!
+!  NAMELIST
+   LOGICAL, PUBLIC :: ln_diaharm_store           !: =T  Stores data for harmonic Analysis
+   LOGICAL, PUBLIC :: ln_diaharm_compute         !: =T  Compute harmonic Analysis
+   LOGICAL, PUBLIC :: ln_diaharm_read_restart   !: =T  Read restart from a previous run 
+   LOGICAL, PUBLIC :: ln_ana_ssh, ln_ana_uvbar, ln_ana_bfric, ln_ana_rho, ln_ana_uv3d, ln_ana_w3d
+   INTEGER ::   nb_ana        ! Number of harmonics to analyse
+   CHARACTER (LEN=4), DIMENSION(jpmax_harmo) ::   tname   ! Names of tidal constituents ('M2', 'K1',...)
+   INTEGER , ALLOCATABLE, DIMENSION(:)       ::   ntide_all ! INDEX within the full set of constituents (tide.h90)
+   INTEGER , ALLOCATABLE, DIMENSION(:)       ::   ntide_sub ! INDEX within the subset of constituents pass in input
+
+   !! * Substitutions
+
+   !!----------------------------------------------------------------------
+   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
+   !! or LIM 2.0 , UCL-LOCEAN-IPSL (2005)
+   !! or  TOP 1.0 , LOCEAN-IPSL (2005)
+   !! $Header: /home/opalod/NEMOCVSROOT/NEMO/OPA_SRC/module_example,v 1.3 2005/03/27 18:34:47 opalod Exp $ 
+   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt
+   !!----------------------------------------------------------------------
+
+CONTAINS
+
+   SUBROUTINE dia_harm_fast( kt )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE harm_ana  ***
+      !!
+      !! ** Purpose :   Harmonic analyser
+      !!
+      !! ** Method  :   
+      !!
+      !! ** Action  : - first action (share memory array/varible modified
+      !!                in this routine
+      !!              - second action .....
+      !!              - .....
+      !!
+      !! References :
+      !!   Give references if exist otherwise suppress these lines
+      !!
+      !! History :
+      !!   9.0  !  03-08  (Autor Names)  Original code
+      !!        !  02-08  (Author names)  brief description of modifications
+      !!----------------------------------------------------------------------
+      !! * Modules used
+      
+      !! * arguments
+      INTEGER, INTENT( in  ) ::   &  
+         kt                          ! describe it!!!
+
+      !! * local declarations
+      INTEGER  :: ji, jk, jj          ! dummy loop arguments
+      INTEGER  :: jh, i1, i2, jgrid
+      INTEGER  :: j2d, j3d
+      REAL(WP) :: sec2start
+      !!--------------------------------------------------------------------
+
+      IF( nn_timing == 1 )   CALL timing_start( 'dia_harm_fast' )
+      IF( kt == nit000   )   CALL harm_ana_init    ! Initialization (first time-step only)
+
+     IF ( ln_diaharm_store .and. ( lk_diaharm_2D .or. lk_diaharm_3D) ) THEN
+
+      ! this bit done every time step
+      nhm=2*nb_ana+1
+      c(1) = 1.0
+
+      sec2start = nint( (fjulday-fjulday_startharm)*86400._wp ) 
+      !IF(lwp) WRITE(numout,*) "ztime NEW", kt, sec2start, fjulday_startharm
+
+      DO jh=1,nb_ana
+         c(2*jh  ) = anaf(jh)*cos( sec2start*om_tide(jh) + anau(jh) + anav(jh) )
+         c(2*jh+1) = anaf(jh)*sin( sec2start*om_tide(jh) + anau(jh) + anav(jh) )
+      ENDDO 
+
+      !IF(lwp) WRITE(numout,*) "c init", c, "c end", sec2start, om_tide(1), anau(1), anav(1),"end nodal"
+
+
+      ! CUMULATE
+      DO ji=1,jpi         ! loop lon
+         DO jj=1,jpj      ! loop lat
+            DO jh=1,nhm   ! loop harmonic
+
+               DO j2d=1,nvar_2d
+                  IF ( m_posi_2d(j2d) .eq. 1 ) dd_cumul = c(jh) * sshn(ji,jj) * ssmask (ji,jj)             ! analysis elevation
+                  IF ( m_posi_2d(j2d) .eq. 2 ) dd_cumul = c(jh) * un_b(ji,jj) * ssumask(ji,jj)             ! analysis depth average velocities 
+                  IF ( m_posi_2d(j2d) .eq. 3 ) dd_cumul = c(jh) * vn_b(ji,jj) * ssvmask(ji,jj)
+                  IF ( m_posi_2d(j2d) .eq. 4 ) dd_cumul = c(jh) * bfrua(ji,jj) * un(ji,jj,mbku(ji,jj)) * ssumask(ji,jj) ! analysis bottom friction
+                  IF ( m_posi_2d(j2d) .eq. 5 ) dd_cumul = c(jh) * bfrva(ji,jj) * vn(ji,jj,mbkv(ji,jj)) * ssvmask(ji,jj)
+                  g_cumul_var2D(jh,ji,jj,j2d) = g_cumul_var2D(jh,ji,jj,j2d) + dd_cumul
+               ENDDO
+
+               DO j3d=1,nvar_3d
+                  DO jk=1,jpkm1
+                     IF ( m_posi_3d(j3d) .eq. 1 ) dd_cumul = c(jh) *  rhd(ji,jj,jk)               * tmask(ji,jj,jk)   
+                     IF ( m_posi_3d(j3d) .eq. 2 ) dd_cumul = c(jh) * ( un(ji,jj,jk)-un_b(ji,jj) ) * umask(ji,jj,jk) 
+                     IF ( m_posi_3d(j3d) .eq. 3 ) dd_cumul = c(jh) * ( vn(ji,jj,jk)-vn_b(ji,jj) ) * vmask(ji,jj,jk)
+                     IF ( m_posi_3d(j3d) .eq. 4 ) dd_cumul = c(jh) *   wn(ji,jj,jk)               * wmask(ji,jj,jk)
+                     g_cumul_var3D(jh,ji,jj,jk,j3d) = g_cumul_var3D(jh,ji,jj,jk,j3d) + dd_cumul
+                  ENDDO
+               ENDDO
+
+            ENDDO     ! end loop harmonic
+         ENDDO        ! end loop lat
+      ENDDO           ! end loop lon
+
+      ! Compute nodal factor cumulative cross-product
+      DO i1=1,nhm
+         DO i2=1,nhm
+            cc(i1,i2)=cc(i1,i2)+c(i1)*c(i2)
+         ENDDO
+      ENDDO
+
+      ! Output RESTART
+      IF( kt == nitrst ) THEN
+         CALL harm_rst_write(kt) ! Dump out data for a restarted run 
+      ENDIF
+
+      ! At End of run
+      IF ( kt ==  nitend ) THEN
+
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'harm_ana : harmonic analysis of tides at end of run'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~'
+
+         IF( ln_diaharm_compute ) THEN
+
+             ! INITIALISE TABLE TO 0
+             IF ( nvar_2d .gt. 0 ) THEN
+                g_cosamp2D = 0.0_wp
+                g_sinamp2D = 0.0_wp
+             ENDIF
+             IF ( nvar_3d .gt. 0 ) THEN
+                g_cosamp3D = 0.0_wp
+                g_sinamp3D = 0.0_wp
+             ENDIF
+
+             ! FIRST OUTPUT 2D VARIABLES
+             DO jgrid=1,nvar_2d    ! loop number of 2d variables (ssh, U2d, V2d, UVfric) to analyse harmonically
+                DO ji=1,jpi        ! loop lon
+                   DO jj=1,jpj     ! loop lat
+                      bt = 1.0_wp; bzz(:) = 0.0_wp
+                      DO jh=1,nhm  ! loop harmonic
+                         bzz(jh) = g_cumul_var2D(jh,ji,jj,jgrid)
+                         bt = bt*bzz(jh)
+                      ENDDO
+                      ! Copy back original cumulated nodal factor
+                      a(:,:) = cc(:,:)
+!                     now do gaussian elimination of the system
+!                     a * x = b
+!                     the matrix x is (a0,a1,b1,a2,b2 ...)
+!                     the matrix a and rhs b solved here for x
+                      x=0.0_wp
+                      IF(bt.ne.0.) THEN
+                        CALL gelim( a, bzz, x, nhm )
+!                       Backup output in variables
+                        DO jh=1,nb_ana
+                           g_cosamp2D(jh,ji,jj,jgrid) = x(jh*2  )
+                           g_sinamp2D(jh,ji,jj,jgrid) = x(jh*2+1)
+                        ENDDO
+                        g_cosamp2D( 0,ji,jj,jgrid) = x(1)
+                        g_sinamp2D( 0,ji,jj,jgrid) = 0.0_wp
+                      ENDIF     ! bt.ne.0.
+                   ENDDO        ! jj
+                ENDDO           ! ji
+             ENDDO              ! jgrid
+
+             ! SECOND OUTPUT 3D VARIABLES
+             DO jgrid=1,nvar_3d     ! loop number of 3d variables rho, U, V, W
+                DO jk=1,jpkm1       ! loop over vertical level
+                   DO ji=1,jpi      ! loop over lon
+                      DO jj=1,jpj   ! loop over lat
+                         bt = 1.0_wp; bzz(:) = 0.0_wp
+                         DO jh=1,nhm
+                            bzz(jh) = g_cumul_var3D(jh,ji,jj,jk,jgrid)
+                            bt = bt*bzz(jh)
+                         ENDDO
+                         ! Copy back original cumulated nodal factor
+                         a(:,:) = cc(:,:)                      
+!                        now do gaussian elimination of the system
+!                        a * x = b
+!                        the matrix x is (a0,a1,b1,a2,b2 ...)
+!                        the matrix a and rhs b solved here for x
+                         x=0.0_wp
+                         IF(bt.ne.0.) THEN
+                           CALL gelim( a, bzz, x, nhm )
+!                          Backup output in variables
+                           DO jh=1,nb_ana
+                              g_cosamp3D(jh,ji,jj,jk,jgrid) = x(jh*2  )
+                              g_sinamp3D(jh,ji,jj,jk,jgrid) = x(jh*2+1)
+                           ENDDO
+                           g_cosamp3D   ( 0,ji,jj,jk,jgrid) = x(1)
+                           g_sinamp3D   ( 0,ji,jj,jk,jgrid) = 0.0_wp
+                        ENDIF     ! bt.ne.0.
+                      ENDDO       ! jj
+                   ENDDO          ! ji
+                ENDDO             ! jk
+             ENDDO                ! jgrid
+
+             CALL harm_ana_out     ! output analysis (last time step)
+
+         ELSE    ! ln_harmana_compute = False 
+             IF(lwp) WRITE(numout,*) " Skipping Computing harmonics at last step"
+
+         ENDIF   ! ln_harmana_compute 
+      ENDIF      ! kt ==  nitend
+
+     ENDIF
+
+      IF( nn_timing == 1 )   CALL timing_stop( 'dia_harm_fast' )
+
+   END SUBROUTINE dia_harm_fast 
+
+   SUBROUTINE harm_ana_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE harm_ana_init  ***
+      !!                   
+      !! ** Purpose :   initialization of ....
+      !!
+      !! ** Method  :   blah blah blah ...
+      !!
+      !! ** input   :   Namlist namexa
+      !!
+      !! ** Action  :   ...  
+      !!
+      !! history :
+      !!   9.0  !  03-08  (Autor Names)  Original code
+      !!----------------------------------------------------------------------
+      !! * local declarations
+      INTEGER ::   ji, jk, jh  ! dummy loop indices
+      INTEGER ::   ios                  ! Local integer output status for namelist read
+      INTEGER ::   k2d, k3d             ! dummy number of analysis
+      NAMELIST/nam_diaharm_fast/ ln_diaharm_store, ln_diaharm_compute, ln_diaharm_read_restart, ln_ana_ssh, ln_ana_uvbar, ln_ana_bfric, ln_ana_rho, ln_ana_uv3d, ln_ana_w3d, tname
+      !!----------------------------------------------------------------------
+
+      lk_diaharm_2D    = .TRUE.   ! to run 2d
+      lk_diaharm_3D    = .TRUE.   ! to run 3d
+
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'harm_init : initialization of harmonic analysis of tides'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~'
+
+      ! GET NAMELIST DETAILS
+      REWIND( numnam_ref )              ! Namelist nam_diaharm_fast in reference namelist : Tidal harmonic analysis
+      READ  ( numnam_ref, nam_diaharm_fast, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diaharm_fast in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist nam_diaharm_fast in configuration namelist : Tidal harmonic analysis
+      READ  ( numnam_cfg, nam_diaharm_fast, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diaharm_fast in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, nam_diaharm_fast )
+
+      ! GET NUMBER OF HARMONIC TO ANALYSE - from diaharm.F90
+      nb_ana = 0
+      DO jk=1,jpmax_harmo
+         DO ji=1,nb_harmo
+            IF(TRIM(tname(jk)) == Wave( ntide(ji) )%cname_tide ) THEN
+               nb_ana=nb_ana+1
+            ENDIF
+         END DO
+      END DO
+      !
+      IF(lwp) THEN
+         WRITE(numout,*) '        Namelist nam_diaharm_fast'
+         WRITE(numout,*) '        nb_ana    = ', nb_ana
+         CALL flush(numout)
+      ENDIF
+      !
+      IF (nb_ana > nharm_max) THEN
+        IF(lwp) WRITE(numout,*) ' E R R O R harm_ana : nb_ana must be lower than nharm_max, stop'
+        IF(lwp) WRITE(numout,*) ' nharm_max = ', nharm_max
+        nstop = nstop + 1
+      ENDIF
+
+      ALLOCATE(ntide_all(nb_ana))
+      ALLOCATE(ntide_sub(nb_ana))
+
+      DO jk=1,nb_ana
+       DO ji=1,nb_harmo
+          IF (TRIM(tname(jk)) .eq. Wave( ntide(ji) )%cname_tide ) THEN
+             ntide_sub(jk) = ji
+             ntide_all(jk) = ntide(ji)
+             EXIT
+          END IF
+       END DO
+      END DO
+
+      ! SEARCH HOW MANY VARIABLES 2D AND 3D TO PROCESS
+      nvar_2d = 0; nvar_3d = 0
+      IF ( ln_ana_ssh   ) nvar_2d = nvar_2d + 1       ! analysis elevation
+      IF ( ln_ana_uvbar ) nvar_2d = nvar_2d + 2       ! analysis depth-averaged velocity
+      IF ( ln_ana_bfric ) nvar_2d = nvar_2d + 2       ! analysis bottom friction 
+            
+      IF ( ln_ana_rho   ) nvar_3d = nvar_3d + 1       ! analysis density
+      IF ( ln_ana_uv3d  ) nvar_3d = nvar_3d + 2       ! analysis 3D horizontal velocities
+      IF ( ln_ana_w3d   ) nvar_3d = nvar_3d + 1       ! analysis 3D vertical velocity
+
+      ! CHECK IF SOMETHING TO RUN
+      IF ( nvar_2d .eq. 0 ) lk_diaharm_2D = .FALSE.   ! no 2d to run
+      IF ( nvar_3d .eq. 0 ) lk_diaharm_3D = .FALSE.   ! no 3d to run
+!      IF ( nvar_2d .gt. 0 .and. nvar_3d .gt. 0 ) lk_diaharm_fast = .FALSE.
+!      IF ( .NOT. ln_diaharm_store ) lk_diaharm_fast = .FALSE.
+
+      IF ( ln_diaharm_store .and. ( lk_diaharm_2D .or. lk_diaharm_3D) ) THEN
+
+         ! DO ALLOCATIONS
+         IF ( lk_diaharm_2D ) THEN
+            ALLOCATE( g_cumul_var2D(nb_ana*2+1,jpi,jpj,    nvar_2d) )
+            ALLOCATE( g_cosamp2D( 0:nb_ana*2+1,jpi,jpj,    nvar_2d) )
+            ALLOCATE( g_sinamp2D( 0:nb_ana*2+1,jpi,jpj,    nvar_2d) )
+            ALLOCATE( g_out2D (jpi,jpj) )
+            ALLOCATE( h_out2D (jpi,jpj) )
+            ALLOCATE( m_posi_2d( nvar_2d ) ); m_posi_2d(:)=0
+         ENDIF
+ 
+         IF ( lk_diaharm_3D ) THEN
+            ALLOCATE( g_cumul_var3D(nb_ana*2+1,jpi,jpj,jpk,nvar_3d) )
+            ALLOCATE( g_cosamp3D( 0:nb_ana*2+1,jpi,jpj,jpk,nvar_3d) )
+            ALLOCATE( g_sinamp3D( 0:nb_ana*2+1,jpi,jpj,jpk,nvar_3d) )
+            ALLOCATE( g_out3D (jpi,jpj,jpk) )
+            ALLOCATE( h_out3D (jpi,jpj,jpk) )
+            ALLOCATE( m_posi_3d( nvar_3d ) ); m_posi_3d(:)=0
+         ENDIF
+
+         ALLOCATE( cc(nb_ana*2+1,nb_ana*2+1) )
+         ALLOCATE( a (nb_ana*2+1,nb_ana*2+1) )
+         ALLOCATE( bzz(nb_ana*2+1) )
+         ALLOCATE( x  (nb_ana*2+1) )
+         ALLOCATE( c  (nb_ana*2+1) )
+         ALLOCATE( anau(nb_ana) )
+         ALLOCATE( anav(nb_ana) )
+         ALLOCATE( anaf(nb_ana) )
+         ! END ALLOCATE 
+
+         ! STORE INDEX OF WHAT TO PRODUCE DEPENDING ON ACTIVATED LOGICAL
+         ! MAKES THINGS EASIER AND FASTER LATER
+         ! !!! UGLY !!!
+         jh = 1; k2d = 0; 
+         IF ( ln_ana_ssh   ) THEN
+            k2d = k2d + 1; m_posi_2d(k2d) = jh
+            IF(lwp) WRITE(numout,*) "   - ssh harmonic analysis activated (ln_ana_ssh)"
+         ENDIF
+         jh = jh + 1
+         IF ( ln_ana_uvbar ) THEN
+            k2d = k2d + 1; m_posi_2d(k2d) = jh
+            jh  = jh  + 1 
+            k2d = k2d + 1; m_posi_2d(k2d) = jh
+            IF(lwp) WRITE(numout,*) "   - barotropic currents harmonic analysis activated (ln_ana_uvbar)"
+         ELSE
+            jh  = jh  + 1
+         ENDIF
+         jh = jh + 1
+         IF ( ln_ana_bfric ) THEN
+            k2d = k2d + 1; m_posi_2d(k2d) = jh
+            jh  = jh  + 1; 
+            k2d = k2d + 1; m_posi_2d(k2d) = jh
+            IF(lwp) WRITE(numout,*) "   - bottom friction harmonic analysis activated (ln_ana_vbfr)"
+         ELSE
+            jh  = jh  + 1
+         ENDIF
+
+         ! and for 3D
+         jh = 1; k3d = 0; 
+         IF ( ln_ana_rho  ) THEN
+            k3d = k3d + 1; m_posi_3d(k3d) = jh
+            IF(lwp) WRITE(numout,*) "   - 3D density harmonic analysis activated (ln_ana_rho)"
+         ENDIF
+         jh = jh + 1
+         IF ( ln_ana_uv3d )  THEN
+            k3d = k3d + 1; m_posi_3d(k3d) = jh
+            jh  = jh  + 1 
+            k3d = k3d + 1; m_posi_3d(k3d) = jh
+            IF(lwp) WRITE(numout,*) "   - 3D horizontal currents harmonic analysis activated (ln_ana_uv3d)"
+         ELSE
+            jh  = jh  + 1
+         ENDIF
+         jh = jh + 1
+         IF ( ln_ana_w3d ) THEN
+            k3d = k3d + 1; m_posi_3d(k3d) = jh
+            IF(lwp) WRITE(numout,*) "   - 3D vertical currents harmonic analysis activated (ln_ana_w3d)"
+         ENDIF
+
+         ! SELECT AND STORE FREQUENCIES
+         IF(lwp)    WRITE(numout,*) 'Analysed frequency  : ',nb_ana ,'Frequency '
+         DO jh=1,nb_ana
+            om_tide(jh) = omega_tide( ntide_sub(jh) ) 
+            IF(lwp) WRITE(numout,*) '        - ',tname(jh),' ',om_tide(jh)
+         ENDDO
+
+         ! READ RESTART IF 
+         IF ( ln_diaharm_read_restart ) THEN
+            IF (lwp) WRITE(numout,*) "Reading previous harmonic data from previous run"
+            ! Need to read in  bssh bz, cc anau anav and anaf 
+            call harm_rst_read  ! This reads in from the previous day
+                                ! Currrently the data in in assci format
+         ELSE 
+
+            IF (lwp) WRITE(numout,*) "Starting harmonic analysis from Fresh "
+ 
+            IF ( lk_diaharm_2D ) g_cumul_var2D(:,:,:,:  ) = 0.0_wp
+            IF ( lk_diaharm_3D ) g_cumul_var3D(:,:,:,:,:) = 0.0_wp
+            cc           = 0.0_wp
+            a    (:,:)   = 0.0_wp ! NB
+            bzz  (:)     = 0.0_wp
+            x    (:)     = 0.0_wp
+            c    (:)     = 0.0_wp
+            anau (:)     = 0.0_wp
+            anav (:)     = 0.0_wp
+            anaf (:)     = 0.0_wp
+
+            DO jh = 1, nb_ana
+               anau(jh) = utide ( ntide_sub(jh) )
+               anav(jh) = v0tide( ntide_sub(jh) )
+               anaf(jh) = ftide ( ntide_sub(jh) )
+            END DO
+
+            fjulday_startharm=fjulday !Set this at very start and store
+
+            IF (lwp) THEN
+               WRITE(numout,*) '--------------------------'
+               WRITE(numout,*) '   - Output anaf for check'
+               WRITE(numout,*) 'ANA F', anaf
+               WRITE(numout,*) 'ANA U', anau
+               WRITE(numout,*) 'ANA V', anav
+               WRITE(numout,*) fjulday_startharm
+               WRITE(numout,*) '--------------------------'
+            ENDIF
+
+         ENDIF
+
+      ELSE
+
+         IF (lwp) WRITE(numout,*) "No variable setup for harmonic analysis"
+
+      ENDIF
+
+   END SUBROUTINE harm_ana_init
+!
+   SUBROUTINE gelim (a,b,x,n)
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE harm_ana  ***
+      !!
+      !! ** Purpose :   Guassian elimination
+      !!
+      !!
+      !! ** Action  : - first action (share memory array/varible modified
+      !!                in this routine
+      !!              - second action .....
+      !!              - .....
+      !!
+      !! References :
+      !!   Give references if exist otherwise suppress these lines
+      !!
+      !! History :
+        implicit none
+!
+        integer  :: n
+        REAL(WP) :: b(nb_ana*2+1), a(nb_ana*2+1,nb_ana*2+1)
+        REAL(WP) :: x(nb_ana*2+1)
+        INTEGER  :: row,col,prow,pivrow,rrow
+        REAL(WP) :: atemp
+        REAL(WP) :: pivot
+        REAL(WP) :: m
+
+        do row=1,n-1
+           pivrow=row
+           pivot=a(row,n-row+1)
+           do prow=row+1,n
+              if (abs(a(prow,n-row+1)).gt.abs(pivot)  ) then
+                 pivot=a(prow,n-row+1)
+                 pivrow=prow
+              endif
+           enddo
+!	swap row and prow
+           if ( pivrow .ne. row ) then
+              atemp=b(pivrow)
+              b(pivrow)=b(row)
+              b(row)=atemp
+              do col=1,n
+                 atemp=a(pivrow,col)
+                 a(pivrow,col)=a(row,col)
+                 a(row,col)=atemp
+              enddo
+           endif
+
+           do rrow=row+1,n
+              if (a(row,row).ne.0) then
+   
+                 m=-a(rrow,n-row+1)/a(row,n-row+1)
+                 do col=1,n
+                    a(rrow,col)=m*a(row,col)+a(rrow,col)
+                 enddo
+                 b(rrow)=m*b(row)+b(rrow)
+              endif
+           enddo
+        enddo
+!	back substitution now
+
+        x(1)=b(n)/a(n,1)
+        do row=n-1,1,-1
+           x(n-row+1)=b(row)
+           do col=1,(n-row)
+              x(n-row+1)=(x(n-row+1)-a(row,col)*x(col)) 
+           enddo
+
+           x(n-row+1)=(x(n-row+1)/a(row,(n-row)+1))
+        enddo
+
+        return
+   END SUBROUTINE gelim
+
+   SUBROUTINE harm_ana_out
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE harm_ana_init  ***
+      !!                   
+      !! ** Purpose :   initialization of ....
+      !!
+      !! ** Method  :   blah blah blah ...
+      !!
+      !! ** input   :   Namlist namexa
+      !!
+      !! ** Action  :   ...  
+      !!
+      !! history :
+      !!   9.0  !  03-08  (Autor Names)  Original code
+      !!----------------------------------------------------------------------
+        USE dianam          ! build name of file (routine)
+ 
+      !! * local declarations
+      INTEGER :: ji, jj, jk, jgrid, jh    ! dummy loop indices
+!      INTEGER :: nh_T
+!      INTEGER :: nid_harm
+!      CHARACTER (len=40) :: clhstnamt, clop1, clop2 ! temporary names 
+!      CHARACTER (len=40) :: clhstnamu, clhstnamv    ! temporary names 
+      CHARACTER (len=40) :: suffix
+!      REAL(wp) :: zsto1, zsto2, zout, zmax, zjulian, zdt, zmdi  ! temporary scalars
+
+      do jgrid=1,nvar_2d
+          do jh=1,nb_ana
+             h_out2D = 0.0
+             g_out2D = 0.0
+             do jj=1,nlcj
+                do ji=1,nlci
+                   cca=g_cosamp2D(jh,ji,jj,jgrid)
+                   ssa=g_sinamp2D(jh,ji,jj,jgrid)
+                   h_out2D(ji,jj)=sqrt(cca**2+ssa**2)
+                   IF (cca.eq.0.0 .and. ssa.eq.0.0) THEN 
+                      g_out2D(ji,jj)= 0.0_wp
+                   ELSE
+                      g_out2D(ji,jj)=(180.0/rpi)*atan2(ssa,cca)       
+                   ENDIF 
+                   IF (h_out2D(ji,jj).ne.0) THEN
+                       h_out2D(ji,jj)=h_out2D(ji,jj)/anaf(jh)
+                   ENDIF
+                   IF (g_out2D(ji,jj).ne.0) THEN  !Correct and take modulus
+                       g_out2D(ji,jj) = g_out2D(ji,jj) + MOD( (anau(jh)+anav(jh))/rad , 360.0)
+                       if (g_out2D(ji,jj).gt.360.0) then
+                           g_out2D(ji,jj)=g_out2D(ji,jj)-360.0
+                       else if (g_out2D(ji,jj).lt.0.0) then
+                           g_out2D(ji,jj)=g_out2D(ji,jj)+360.0
+                       endif
+                   ENDIF
+                enddo
+             enddo
+             !
+             ! NETCDF OUTPUT
+             suffix = TRIM( m_varName2d( m_posi_2d(jgrid) ) )
+             CALL iom_put( TRIM(Wave(ntide_all(jh))%cname_tide)//'amp_'//TRIM(suffix), h_out2D(:,:) )
+             CALL iom_put( TRIM(Wave(ntide_all(jh))%cname_tide)//'pha_'//TRIM(suffix), g_out2D(:,:) )
+
+          enddo
+      enddo
+!
+! DO THE SAME FOR 3D VARIABLES
+!
+      do jgrid=1,nvar_3d
+          do jh=1,nb_ana
+             h_out3D = 0.0
+             g_out3D = 0.0
+             DO jk=1,jpkm1
+                do jj=1,nlcj
+                   do ji=1,nlci
+                      cca=g_cosamp3D(jh,ji,jj,jk,jgrid)
+                      ssa=g_sinamp3D(jh,ji,jj,jk,jgrid)
+                      h_out3D(ji,jj,jk)=sqrt(cca**2+ssa**2)
+                      IF (cca.eq.0.0 .and. ssa.eq.0.0) THEN
+                         g_out3D(ji,jj,jk) = 0.0_wp
+                      ELSE
+                         g_out3D(ji,jj,jk) = (180.0/rpi)*atan2(ssa,cca)
+                      ENDIF
+                      IF (h_out3D(ji,jj,jk).ne.0) THEN
+                          h_out3D(ji,jj,jk) = h_out3D(ji,jj,jk)/anaf(jh)
+                      ENDIF
+                      IF (g_out3D(ji,jj,jk).ne.0) THEN  !Correct and take modulus
+                          g_out3D(ji,jj,jk) = g_out3D(ji,jj,jk) + MOD( (anau(jh)+anav(jh))/rad , 360.0)
+                          if      (g_out3D(ji,jj,jk).gt.360.0) then
+                                   g_out3D(ji,jj,jk) = g_out3D(ji,jj,jk)-360.0
+                          else if (g_out3D(ji,jj,jk).lt.0.0) then
+                                   g_out3D(ji,jj,jk) = g_out3D(ji,jj,jk)+360.0
+                          endif
+                      ENDIF
+                   enddo    ! ji
+                enddo       ! jj
+             ENDDO          ! jk
+             !
+             ! NETCDF OUTPUT
+             suffix = TRIM( m_varName3d( m_posi_3d(jgrid) ) )
+             IF(lwp) WRITE(numout,*) "harm_ana_out", suffix
+             CALL iom_put( TRIM(Wave(ntide_all(jh))%cname_tide)//'amp_'//TRIM(suffix), h_out3D(:,:,:) )
+             CALL iom_put( TRIM(Wave(ntide_all(jh))%cname_tide)//'pha_'//TRIM(suffix), g_out3D(:,:,:) )
+          enddo             ! jh 
+      enddo                 ! jgrid
+!
+   END SUBROUTINE harm_ana_out
+!
+   SUBROUTINE harm_rst_write(kt)
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE harm_ana_init  ***
+      !!                   
+      !! ** Purpose :  To write out cummulated Tidal Harmomnic data to file for
+      !!               restarting
+      !!
+      !! ** Method  :   restart files will be dated by default
+      !!
+      !! ** input   :   
+      !!
+      !! ** Action  :   ...  
+      !!
+      !! history :
+      !!   0.0  !  01-16  (Enda O'Dea)  Original code
+      !! ASSUMES  dated file for rose  , can change later to be more generic
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt     ! ocean time-step
+      !!
+      INTEGER             ::   jh, j2d, j3d
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step define as a character
+      CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
+      CHARACTER(LEN=150)  ::   clpath   ! full path to ocean output restart file
+      CHARACTER(LEN=250)  ::   clfinal   ! full name
+
+      !restart file
+      DO j2d=1,nvar_2d
+         CALL iom_rstput( kt, nitrst, numrow, 'Mean_'//TRIM(m_varName2d( m_posi_2d(j2d) )), g_cumul_var2D( 1, :, :, j2d ) )
+         DO jh=1,nb_ana
+            CALL iom_rstput( kt, nitrst, numrow, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName2d( m_posi_2d(j2d) ))//'_cos', g_cumul_var2D( jh*2  , :, :, j2d ) )
+            CALL iom_rstput( kt, nitrst, numrow, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName2d( m_posi_2d(j2d) ))//'_sin', g_cumul_var2D( jh*2+1, :, :, j2d ) )
+         ENDDO
+      ENDDO
+
+      DO j3d=1,nvar_3d
+         CALL iom_rstput( kt, nitrst, numrow, 'Mean_'//TRIM(m_varName2d( m_posi_3d(j3d) )), g_cumul_var3D( 1, :, :, :, j3d ) )
+         DO jh=1,nb_ana
+            CALL iom_rstput( kt, nitrst, numrow, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName3d( m_posi_3d(j3d) ))//'_cos', g_cumul_var3D( jh*2  , :, :, :, j3d ) )
+            CALL iom_rstput( kt, nitrst, numrow, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName3d( m_posi_3d(j3d) ))//'_sin', g_cumul_var3D( jh*2+1, :, :, :, j3d ) )
+         ENDDO
+      ENDDO
+
+      IF(lwp) THEN
+        IF( kt > 999999999 ) THEN ; WRITE(clkt, *       ) kt
+        ELSE                      ; WRITE(clkt, '(i8.8)') kt
+        ENDIF
+        clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_restart_harm_ana.bin"
+        clpath = TRIM(cn_ocerst_outdir)
+        IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+        IF (lwp) WRITE(numout,*) 'Open tidal harmonics restart file for writing: ',TRIM(clpath)//clname
+
+        WRITE(clfinal,'(a)') trim(clpath)//trim(clname)
+        OPEN( 66, file=TRIM(clfinal), form='unformatted', access="stream" )
+        WRITE(66) cc
+        WRITE(66) anau
+        WRITE(66) anav
+        WRITE(66) anaf
+        WRITE(66) fjulday_startharm
+        CLOSE(66)
+        WRITE(numout,*) '----------------------------'
+        WRITE(numout,*) '   harm_rst_write: DONE '
+        WRITE(numout,*) cc
+        WRITE(numout,*) anaf
+        WRITE(numout,*) fjulday_startharm
+        WRITE(numout,*) '----------------------------'
+      ENDIF
+ 
+   END SUBROUTINE harm_rst_write
+
+   SUBROUTINE harm_rst_read
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE harm_ana_init  ***
+      !!                   
+      !! ** Purpose :  To read in  cummulated Tidal Harmomnic data to file for
+      !!               restarting
+      !!
+      !! ** Method  :   
+      !!
+      !! ** input   :   
+      !!
+      !! ** Action  :   ...  
+      !!
+      !! history :
+      !!   0.0  !  01-16  (Enda O'Dea)  Original code
+      !! ASSUMES  dated file for rose  , can change later to be more generic
+      !!----------------------------------------------------------------------
+      CHARACTER(LEN=20)   ::   clkt     ! ocean time-step define as a character
+      CHARACTER(LEN=50)   ::   clname   ! ocean output restart file name
+      CHARACTER(LEN=150)  ::   clpath   ! full path to ocean output restart file
+      CHARACTER(LEN=250)  ::   clfinal   ! full name
+      INTEGER             ::   jh, j2d, j3d
+
+      IF( nit000 > 999999999 ) THEN ; WRITE(clkt, *       ) nit000-1
+      ELSE                      ; WRITE(clkt, '(i8.8)') nit000-1
+      ENDIF
+      clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_restart_harm_ana.bin"
+      clpath = TRIM(cn_ocerst_outdir)
+      IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
+
+      IF (lwp) WRITE(numout,*) 'Open tidal harmonics restart file for reading: ',TRIM(clpath)//clname
+
+      DO j2d=1,nvar_2d
+         CALL iom_get( numror,jpdom_autoglo, 'Mean_'//TRIM(m_varName2d( m_posi_2d(j2d) )), g_cumul_var2D( 1, :, :, j2d ) )
+         IF(lwp) WRITE(numout,*) "2D", j2d, m_posi_2d(j2d), m_varName2d( m_posi_2d(j2d) )
+         DO jh=1,nb_ana
+            CALL iom_get( numror,jpdom_autoglo, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName2d( m_posi_2d(j2d) ))//'_cos', g_cumul_var2D( jh*2  , :, :, j2d ) )
+            CALL iom_get( numror,jpdom_autoglo, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName2d( m_posi_2d(j2d) ))//'_sin', g_cumul_var2D( jh*2+1, :, :, j2d ) )
+         ENDDO
+      ENDDO
+
+      DO j3d=1,nvar_3d
+         CALL iom_get( numror,jpdom_autoglo, 'Mean_'//TRIM(m_varName2d( m_posi_3d(j3d) )), g_cumul_var3D( 1, :, :, :, j3d ) )
+         IF(lwp) WRITE(numout,*) "3D", j3d,  m_posi_3d(j3d), m_varName3d( m_posi_3d(j3d) )
+
+         DO jh=1,nb_ana
+            CALL iom_get( numror,jpdom_autoglo, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName3d( m_posi_3d(j3d) ))//'_cos', g_cumul_var3D( jh*2  , :, :, :, j3d ) )
+            CALL iom_get( numror,jpdom_autoglo, TRIM(Wave(ntide_all(jh))%cname_tide)//"_"//TRIM(m_varName3d( m_posi_3d(j3d) ))//'_sin', g_cumul_var3D( jh*2+1, :, :, :, j3d ) )
+         ENDDO
+      ENDDO
+
+      WRITE(clfinal,'(a)') trim(clpath)//trim(clname)
+      OPEN( 66, file=TRIM(clfinal), form='unformatted', access="stream" )
+      READ(66) cc
+      READ(66) anau
+      READ(66) anav
+      READ(66) anaf
+      READ(66) fjulday_startharm
+      CLOSE(66)
+
+      IF(lwp) THEN
+        WRITE(numout,*) '----------------------------'
+        WRITE(numout,*) '   Checking anaf is correct'
+        WRITE(numout,*) cc
+        WRITE(numout,*) anaf
+        WRITE(numout,*) fjulday_startharm
+        WRITE(numout,*) '----------------------------'
+      ENDIF
+ 
+   END SUBROUTINE harm_rst_read
+
+   !!======================================================================
+#else
+!!---------------------------------------------------------------------------------
+!!   Dummy module                                   NO harmonic Analysis
+!!---------------------------------------------------------------------------------
+        LOGICAL, PUBLIC, PARAMETER :: lk_diaharm_fast  = .FALSE.   ! to be run or not
+
+        CONTAINS
+           SUBROUTINE harm_rst_write(kt)     ! Dummy routine
+           END SUBROUTINE harm_rst_write
+           SUBROUTINE harm_rst_read    ! Dummy routine
+           END SUBROUTINE harm_rst_read
+           SUBROUTINE harm_ana_out      ! Dummy routine
+           END SUBROUTINE harm_ana_out
+           SUBROUTINE harm_ana_init
+           END SUBROUTINE harm_ana_init
+           SUBROUTINE harm_ana( kt )
+!--- NB : end call not properly written
+           END SUBROUTINE harm_ana
+!           END SUBROUTINE harm_ana_init
+!--- END NB
+           SUBROUTINE gelim (a,b,x,n)
+!--- NB : end call not properly written
+           END SUBROUTINE gelim
+!           END SUBROUTINE gelim (a,b,x,n)
+!--- END NB           
+#endif
+
+END MODULE diaharm_fast 
diff --git a/MY_SRC/dommsk.F90 b/MY_SRC/dommsk.F90
new file mode 100755
index 0000000..29d4b88
--- /dev/null
+++ b/MY_SRC/dommsk.F90
@@ -0,0 +1,303 @@
+MODULE dommsk
+   !!======================================================================
+   !!                       ***  MODULE dommsk   ***
+   !! Ocean initialization : domain land/sea mask 
+   !!======================================================================
+   !! History :  OPA  ! 1987-07  (G. Madec)  Original code
+   !!            6.0  ! 1993-03  (M. Guyon)  symetrical conditions (M. Guyon)
+   !!            7.0  ! 1996-01  (G. Madec)  suppression of common work arrays
+   !!             -   ! 1996-05  (G. Madec)  mask computed from tmask
+   !!            8.0  ! 1997-02  (G. Madec)  mesh information put in domhgr.F
+   !!            8.1  ! 1997-07  (G. Madec)  modification of kbat and fmask
+   !!             -   ! 1998-05  (G. Roullet)  free surface
+   !!            8.2  ! 2000-03  (G. Madec)  no slip accurate
+   !!             -   ! 2001-09  (J.-M. Molines)  Open boundaries
+   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and module
+   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!            3.6  ! 2015-05  (P. Mathiot) ISF: add wmask,wumask and wvmask
+   !!            4.0  ! 2016-06  (G. Madec, S. Flavoni)  domain configuration / user defined interface
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dom_msk       : compute land/ocean mask
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE usrdef_fmask   ! user defined fmask
+   USE bdy_oce      
+   USE in_out_manager ! I/O manager
+   USE iom
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! Massively Parallel Processing library
+   USE wrk_nemo       ! Memory allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dom_msk    ! routine called by inidom.F90
+
+   !                            !!* Namelist namlbc : lateral boundary condition *
+   REAL(wp)        :: rn_shlat   ! type of lateral boundary condition on velocity
+   LOGICAL, PUBLIC :: ln_vorlat  !  consistency of vorticity boundary condition 
+   !                                            with analytical eqs.
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id: dommsk.F90 7753 2017-03-03 11:46:59Z mocavero $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dom_msk( k_top, k_bot )
+      !!---------------------------------------------------------------------
+      !!                 ***  ROUTINE dom_msk  ***
+      !!
+      !! ** Purpose :   Compute land/ocean mask arrays at tracer points, hori-
+      !!      zontal velocity points (u & v), vorticity points (f) points.
+      !!
+      !! ** Method  :   The ocean/land mask  at t-point is deduced from ko_top 
+      !!      and ko_bot, the indices of the fist and last ocean t-levels which 
+      !!      are either defined in usrdef_zgr or read in zgr_read.
+      !!                The velocity masks (umask, vmask, wmask, wumask, wvmask) 
+      !!      are deduced from a product of the two neighboring tmask.
+      !!                The vorticity mask (fmask) is deduced from tmask taking
+      !!      into account the choice of lateral boundary condition (rn_shlat) :
+      !!         rn_shlat = 0, free slip  (no shear along the coast)
+      !!         rn_shlat = 2, no slip  (specified zero velocity at the coast)
+      !!         0 < rn_shlat < 2, partial slip   | non-linear velocity profile
+      !!         2 < rn_shlat, strong slip        | in the lateral boundary layer
+      !!
+      !!      tmask_i : interior ocean mask at t-point, i.e. excluding duplicated
+      !!                rows/lines due to cyclic or North Fold boundaries as well
+      !!                as MPP halos.
+      !!      tmask_h : halo mask at t-point, i.e. excluding duplicated rows/lines
+      !!                due to cyclic or North Fold boundaries as well as MPP halos.
+      !!
+      !! ** Action :   tmask, umask, vmask, wmask, wumask, wvmask : land/ocean mask 
+      !!                         at t-, u-, v- w, wu-, and wv-points (=0. or 1.)
+      !!               fmask   : land/ocean mask at f-point (=0., or =1., or 
+      !!                         =rn_shlat along lateral boundaries)
+      !!               tmask_i : interior ocean mask 
+      !!               tmask_h : halo mask
+      !!               ssmask , ssumask, ssvmask, ssfmask : 2D ocean mask
+      !!----------------------------------------------------------------------
+      INTEGER, DIMENSION(:,:), INTENT(in) ::   k_top, k_bot   ! first and last ocean level
+      !
+      INTEGER  ::   ji, jj, jk     ! dummy loop indices
+      INTEGER  ::   iif, iil       ! local integers
+      INTEGER  ::   ijf, ijl       !   -       -
+      INTEGER  ::   iktop, ikbot   !   -       -
+      INTEGER  ::   ios, inum
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zwf   ! 2D workspace
+      !!
+      NAMELIST/namlbc/ rn_shlat, ln_vorlat
+      NAMELIST/nambdy/ ln_bdy ,nb_bdy, ln_coords_file, cn_coords_file,         &
+         &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
+         &             cn_dyn3d, nn_dyn3d_dta, cn_tra, nn_tra_dta,             &
+         &             ln_tra_dmp, ln_dyn3d_dmp, rn_time_dmp, rn_time_dmp_out, &
+         &             cn_ice_lim, nn_ice_lim_dta,                           &
+         &             rn_ice_tem, rn_ice_sal, rn_ice_age,                 &
+         &             ln_vol, nn_volctl, nn_rimwidth, nb_jpk_bdy
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dom_msk')
+      !
+      REWIND( numnam_ref )              ! Namelist namlbc in reference namelist : Lateral momentum boundary condition
+      READ  ( numnam_ref, namlbc, IOSTAT = ios, ERR = 901 )
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlbc in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist namlbc in configuration namelist : Lateral momentum boundary condition
+      READ  ( numnam_cfg, namlbc, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namlbc in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namlbc )
+      
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dommsk : ocean mask '
+         WRITE(numout,*) '~~~~~~'
+         WRITE(numout,*) '   Namelist namlbc'
+         WRITE(numout,*) '      lateral momentum boundary cond.    rn_shlat  = ',rn_shlat
+         WRITE(numout,*) '      consistency with analytical form   ln_vorlat = ',ln_vorlat 
+      ENDIF
+
+      IF     (      rn_shlat == 0.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  free-slip '
+      ELSEIF (      rn_shlat == 2.               ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  no-slip '
+      ELSEIF ( 0. < rn_shlat .AND. rn_shlat < 2. ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  partial-slip '
+      ELSEIF ( 2. < rn_shlat                     ) THEN   ;   IF(lwp) WRITE(numout,*) '   ocean lateral  strong-slip '
+      ELSE
+         WRITE(ctmp1,*) ' rn_shlat is negative = ', rn_shlat
+         CALL ctl_stop( ctmp1 )
+      ENDIF
+
+
+      !  Ocean/land mask at t-point  (computed from ko_top and ko_bot)
+      ! ----------------------------
+      !
+      tmask(:,:,:) = 0._wp
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            iktop = k_top(ji,jj)
+            ikbot = k_bot(ji,jj)
+            IF( iktop /= 0 ) THEN       ! water in the column
+               tmask(ji,jj,iktop:ikbot  ) = 1._wp
+            ENDIF
+         END DO  
+      END DO  
+!SF  add here lbc_lnk: bug not still understood : cause now domain configuration is read !
+!!gm I don't understand why...  
+      CALL lbc_lnk( tmask  , 'T', 1._wp )      ! Lateral boundary conditions
+
+     ! Mask corrections for bdy (read in mppini2)
+      REWIND( numnam_ref )              ! Namelist nambdy in reference namelist :Unstructured open boundaries
+      READ  ( numnam_ref, nambdy, IOSTAT = ios, ERR = 903)
+903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambdy in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist nambdy in configuration namelist :Unstructured open boundaries
+      READ  ( numnam_cfg, nambdy, IOSTAT = ios, ERR = 904 )
+904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nambdy in configuration namelist', lwp )
+      ! ------------------------
+      IF ( ln_bdy .AND. ln_mask_file ) THEN
+         CALL iom_open( cn_mask_file, inum )
+         CALL iom_get ( inum, jpdom_data, 'bdy_msk', bdytmask(:,:) )
+         CALL iom_close( inum )
+         DO jk = 1, jpkm1
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  tmask(ji,jj,jk) = tmask(ji,jj,jk) * bdytmask(ji,jj)
+               END DO
+            END DO
+         END DO
+      ENDIF
+         
+      !  Ocean/land mask at u-, v-, and f-points   (computed from tmask)
+      ! ----------------------------------------
+      ! NB: at this point, fmask is designed for free slip lateral boundary condition
+      DO jk = 1, jpk
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector loop
+               umask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)
+               vmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji  ,jj+1,jk)
+            END DO
+            DO ji = 1, jpim1      ! NO vector opt.
+               fmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)   &
+                  &            * tmask(ji,jj+1,jk) * tmask(ji+1,jj+1,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( umask  , 'U', 1._wp )      ! Lateral boundary conditions
+      CALL lbc_lnk( vmask  , 'V', 1._wp )
+      CALL lbc_lnk( fmask  , 'F', 1._wp )
+
+ 
+      ! Ocean/land mask at wu-, wv- and w points    (computed from tmask)
+      !-----------------------------------------
+      wmask (:,:,1) = tmask(:,:,1)     ! surface
+      wumask(:,:,1) = umask(:,:,1)
+      wvmask(:,:,1) = vmask(:,:,1)
+      DO jk = 2, jpk                   ! interior values
+         wmask (:,:,jk) = tmask(:,:,jk) * tmask(:,:,jk-1)
+         wumask(:,:,jk) = umask(:,:,jk) * umask(:,:,jk-1)   
+         wvmask(:,:,jk) = vmask(:,:,jk) * vmask(:,:,jk-1)
+      END DO
+
+
+      ! Ocean/land column mask at t-, u-, and v-points   (i.e. at least 1 wet cell in the vertical)
+      ! ----------------------------------------------
+      ssmask (:,:) = MAXVAL( tmask(:,:,:), DIM=3 )
+      ssumask(:,:) = MAXVAL( umask(:,:,:), DIM=3 )
+      ssvmask(:,:) = MAXVAL( vmask(:,:,:), DIM=3 )
+
+
+      ! Interior domain mask  (used for global sum)
+      ! --------------------
+      !
+      iif = jpreci   ;   iil = nlci - jpreci + 1
+      ijf = jprecj   ;   ijl = nlcj - jprecj + 1
+      !
+      !                          ! halo mask : 0 on the halo and 1 elsewhere
+      tmask_h(:,:) = 1._wp                  
+      tmask_h( 1 :iif,   :   ) = 0._wp      ! first columns
+      tmask_h(iil:jpi,   :   ) = 0._wp      ! last  columns (including mpp extra columns)
+      tmask_h(   :   , 1 :ijf) = 0._wp      ! first rows
+      tmask_h(   :   ,ijl:jpj) = 0._wp      ! last  rows (including mpp extra rows)
+      !
+      !                          ! north fold mask
+      tpol(1:jpiglo) = 1._wp 
+      fpol(1:jpiglo) = 1._wp
+      IF( jperio == 3 .OR. jperio == 4 ) THEN      ! T-point pivot
+         tpol(jpiglo/2+1:jpiglo) = 0._wp
+         fpol(     1    :jpiglo) = 0._wp
+         IF( mjg(nlej) == jpjglo ) THEN                  ! only half of the nlcj-1 row for tmask_h
+            DO ji = iif+1, iil-1
+               tmask_h(ji,nlej-1) = tmask_h(ji,nlej-1) * tpol(mig(ji))
+            END DO
+         ENDIF
+      ENDIF
+      !
+      IF( jperio == 5 .OR. jperio == 6 ) THEN      ! F-point pivot
+         tpol(     1    :jpiglo) = 0._wp
+         fpol(jpiglo/2+1:jpiglo) = 0._wp
+      ENDIF
+      !
+      !                          ! interior mask : 2D ocean mask x halo mask 
+      tmask_i(:,:) = ssmask(:,:) * tmask_h(:,:)
+
+
+      ! Lateral boundary conditions on velocity (modify fmask)
+      ! ---------------------------------------  
+      IF( rn_shlat /= 0 ) THEN      ! Not free-slip lateral boundary condition
+         !
+         CALL wrk_alloc( jpi,jpj,   zwf )
+         !
+         DO jk = 1, jpk
+            zwf(:,:) = fmask(:,:,jk)         
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  IF( fmask(ji,jj,jk) == 0._wp ) THEN
+                     fmask(ji,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jj), zwf(ji,jj+1),   &
+                        &                                           zwf(ji-1,jj), zwf(ji,jj-1)  )  )
+                  ENDIF
+               END DO
+            END DO
+            DO jj = 2, jpjm1
+               IF( fmask(1,jj,jk) == 0._wp ) THEN
+                  fmask(1  ,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(2,jj), zwf(1,jj+1), zwf(1,jj-1) ) )
+               ENDIF
+               IF( fmask(jpi,jj,jk) == 0._wp ) THEN
+                  fmask(jpi,jj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(jpi,jj+1), zwf(jpim1,jj), zwf(jpi,jj-1) ) )
+               ENDIF
+            END DO         
+            DO ji = 2, jpim1
+               IF( fmask(ji,1,jk) == 0._wp ) THEN
+                  fmask(ji, 1 ,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,1), zwf(ji,2), zwf(ji-1,1) ) )
+               ENDIF
+               IF( fmask(ji,jpj,jk) == 0._wp ) THEN
+                  fmask(ji,jpj,jk) = rn_shlat * MIN( 1._wp , MAX( zwf(ji+1,jpj), zwf(ji-1,jpj), zwf(ji,jpjm1) ) )
+               ENDIF
+            END DO
+         END DO
+         !
+         CALL wrk_dealloc( jpi,jpj,   zwf )
+         !
+         CALL lbc_lnk( fmask, 'F', 1._wp )      ! Lateral boundary conditions on fmask
+         !
+         ! CAUTION : The fmask may be further modified in dyn_vor_init ( dynvor.F90 ) depending on ln_vorlat
+         !
+      ENDIF
+      
+      ! User defined alteration of fmask (use to reduce ocean transport in specified straits)
+      ! -------------------------------- 
+      !
+      CALL usr_def_fmask( cn_cfg, nn_cfg, fmask )
+      !
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dom_msk')
+      !
+   END SUBROUTINE dom_msk
+   
+   !!======================================================================
+END MODULE dommsk
diff --git a/MY_SRC/dtatsd.F90 b/MY_SRC/dtatsd.F90
new file mode 100755
index 0000000..78a2f4d
--- /dev/null
+++ b/MY_SRC/dtatsd.F90
@@ -0,0 +1,298 @@
+MODULE dtatsd
+   !!======================================================================
+   !!                     ***  MODULE  dtatsd  ***
+   !! Ocean data  :  read ocean Temperature & Salinity Data from gridded data
+   !!======================================================================
+   !! History :  OPA  ! 1991-03  ()  Original code
+   !!             -   ! 1992-07  (M. Imbard)
+   !!            8.0  ! 1999-10  (M.A. Foujols, M. Imbard)  NetCDF FORMAT 
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module 
+   !!            3.3  ! 2010-10  (C. Bricaud, S. Masson)  use of fldread
+   !!            3.4  ! 2010-11  (G. Madec, C. Ethe) Merge of dtatem and dtasal + suppression of CPP keys
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dta_tsd      : read and time interpolated ocean Temperature & Salinity Data
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE fldread         ! read input fields
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+   USE lib_mpp         ! MPP library
+   USE wrk_nemo        ! Memory allocation
+   USE timing          ! Timing
+   USE iom
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dta_tsd_init   ! called by opa.F90
+   PUBLIC   dta_tsd        ! called by istate.F90 and tradmp.90
+
+   LOGICAL , PUBLIC ::   ln_tsd_init      !: T & S data flag
+   LOGICAL , PUBLIC ::   ln_tsd_interp    !: vertical interpolation flag
+   LOGICAL , PUBLIC ::   ln_tsd_tradmp    !: internal damping toward input data flag
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_tsd   ! structure of input SST (file informations, fields read)
+   INTEGER                                 ::   jpk_init , inum_dta
+   INTEGER                                 ::   id ,linum   ! local integers
+   INTEGER                                 ::   zdim(4)
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: dtatsd.F90 7753 2017-03-03 11:46:59Z mocavero $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dta_tsd_init( ld_tradmp )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dta_tsd_init  ***
+      !!                    
+      !! ** Purpose :   initialisation of T & S input data 
+      !! 
+      !! ** Method  : - Read namtsd namelist
+      !!              - allocates T & S data structure 
+      !!----------------------------------------------------------------------
+      LOGICAL, INTENT(in), OPTIONAL ::   ld_tradmp   ! force the initialization when tradp is used
+      !
+      INTEGER ::   ios, ierr0, ierr1, ierr2, ierr3, ierr4, ierr5   ! local integers
+      !!
+      CHARACTER(len=100)            ::   cn_dir          ! Root directory for location of ssr files
+      TYPE(FLD_N), DIMENSION(jpts+2)::   slf_i           ! array of namelist informations on the fields to read
+      TYPE(FLD_N)                   ::   sn_tem, sn_sal, sn_dep, sn_msk
+      
+      !!
+      NAMELIST/namtsd/   ln_tsd_init, ln_tsd_interp, ln_tsd_tradmp, cn_dir, sn_tem, sn_sal, sn_dep, sn_msk
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dta_tsd_init')
+      !
+      !  Initialisation
+      ierr0 = 0  ;  ierr1 = 0  ;  ierr2 = 0  ;  ierr3 = 0  ; ierr4 = 0  ;  ierr5 = 0 
+      !
+      REWIND( numnam_ref )              ! Namelist namtsd in reference namelist : 
+      READ  ( numnam_ref, namtsd, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtsd in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist namtsd in configuration namelist : Parameters of the run
+      READ  ( numnam_cfg, namtsd, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtsd in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namtsd )
+
+      IF( PRESENT( ld_tradmp ) )   ln_tsd_tradmp = .TRUE.     ! forces the initialization when tradmp is used
+      
+      IF(lwp) THEN                  ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dta_tsd_init : Temperature & Salinity data '
+         WRITE(numout,*) '~~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namtsd'
+         WRITE(numout,*) '      Initialisation of ocean T & S with T &S input data   ln_tsd_init   = ', ln_tsd_init
+         WRITE(numout,*) '      iInterpolation of initial conditions in the vertical ln_tsd_interp = ', ln_tsd_interp
+         WRITE(numout,*) '      damping of ocean T & S toward T &S input data        ln_tsd_tradmp = ', ln_tsd_tradmp
+         WRITE(numout,*)
+         IF( .NOT.ln_tsd_init .AND. .NOT.ln_tsd_tradmp ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) '   T & S data not used'
+         ENDIF
+      ENDIF
+      !
+      IF( ln_rstart .AND. ln_tsd_init ) THEN
+         CALL ctl_warn( 'dta_tsd_init: ocean restart and T & S data intialisation, ',   &
+            &           'we keep the restart T & S values and set ln_tsd_init to FALSE' )
+         ln_tsd_init = .FALSE.
+      ENDIF
+      IF( ln_tsd_interp .AND. ln_tsd_tradmp ) THEN
+            CALL ctl_stop( 'dta_tsd_init: Tracer damping and vertical interpolation not yet configured' )   ;   RETURN
+      ENDIF
+      IF( ln_tsd_interp .AND. LEN(TRIM(sn_msk%wname)) > 0 ) THEN
+            CALL ctl_stop( 'dta_tsd_init: Using vertical interpolation and weights files not recommended' )   ;   RETURN
+      ENDIF
+      !
+      !                             ! allocate the arrays (if necessary)
+      IF(  ln_tsd_init .OR. ln_tsd_tradmp  ) THEN
+         !
+         IF( ln_tsd_interp ) THEN
+           ALLOCATE( sf_tsd(jpts+2), STAT=ierr0 ) ! to carry the addtional depth information
+         ELSE
+           ALLOCATE( sf_tsd(jpts  ), STAT=ierr0 ) 
+         ENDIF 
+         IF( ierr0 > 0 ) THEN
+            CALL ctl_stop( 'dta_tsd_init: unable to allocate sf_tsd structure' )   ;   RETURN
+         ENDIF
+         !
+         IF( ln_tsd_interp ) THEN
+            CALL iom_open ( trim(cn_dir) // trim(sn_dep%clname), inum_dta ) 
+            id = iom_varid( inum_dta, sn_dep%clvar, zdim )
+            jpk_init = zdim(3)
+            IF(lwp) WRITE(numout,*) 'Dimension of veritcal coordinate in ICs: ', jpk_init
+            CALL iom_close( inum_dta )   ! Close the input file
+            !
+                                 ALLOCATE( sf_tsd(jp_tem)%fnow(jpi,jpj,jpk_init  ) , STAT=ierr0 )
+            IF( sn_tem%ln_tint ) ALLOCATE( sf_tsd(jp_tem)%fdta(jpi,jpj,jpk_init,2) , STAT=ierr1 )
+                                 ALLOCATE( sf_tsd(jp_sal)%fnow(jpi,jpj,jpk_init  ) , STAT=ierr2 )
+            IF( sn_sal%ln_tint ) ALLOCATE( sf_tsd(jp_sal)%fdta(jpi,jpj,jpk_init,2) , STAT=ierr3 )  
+                                 ALLOCATE( sf_tsd(jp_dep)%fnow(jpi,jpj,jpk_init  ) , STAT=ierr4 )
+                                 ALLOCATE( sf_tsd(jp_msk)%fnow(jpi,jpj,jpk_init  ) , STAT=ierr5 )
+         ELSE
+                                 ALLOCATE( sf_tsd(jp_tem)%fnow(jpi,jpj,jpk)   , STAT=ierr0 )
+            IF( sn_tem%ln_tint ) ALLOCATE( sf_tsd(jp_tem)%fdta(jpi,jpj,jpk,2) , STAT=ierr1 )
+                                 ALLOCATE( sf_tsd(jp_sal)%fnow(jpi,jpj,jpk)   , STAT=ierr2 )
+            IF( sn_sal%ln_tint ) ALLOCATE( sf_tsd(jp_sal)%fdta(jpi,jpj,jpk,2) , STAT=ierr3 )  
+         ENDIF ! ln_tsd_interp
+
+         !
+         IF( ierr0 + ierr1 + ierr2 + ierr3 + ierr4 + ierr5 > 0 ) THEN
+            CALL ctl_stop( 'dta_tsd : unable to allocate T & S data arrays' )   ;   RETURN
+         ENDIF
+         !                         ! fill sf_tsd with sn_tem & sn_sal and control print
+         slf_i(jp_tem) = sn_tem   ;   slf_i(jp_sal) = sn_sal
+         IF( ln_tsd_interp ) slf_i(jp_dep) = sn_dep   ;   slf_i(jp_msk) = sn_msk
+         CALL fld_fill( sf_tsd, slf_i, cn_dir, 'dta_tsd', 'Temperature & Salinity data', 'namtsd', no_print )
+         !
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dta_tsd_init')
+      !
+   END SUBROUTINE dta_tsd_init
+
+
+   SUBROUTINE dta_tsd( kt, ptsd )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE dta_tsd  ***
+      !!                    
+      !! ** Purpose :   provides T and S data at kt
+      !! 
+      !! ** Method  : - call fldread routine
+      !!              - ORCA_R2: add some hand made alteration to read data  
+      !!              - 'key_orca_lev10' interpolates on 10 times more levels
+      !!              - s- or mixed z-s coordinate: vertical interpolation on model mesh
+      !!              - ln_tsd_tradmp=F: deallocates the T-S data structure
+      !!                as T-S data are no are used
+      !!
+      !! ** Action  :   ptsd   T-S data on medl mesh and interpolated at time-step kt
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt     ! ocean time-step
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   ptsd   ! T & S data
+      !
+      INTEGER ::   ji, jj, jk, jl, jk_init   ! dummy loop indicies
+      INTEGER ::   ik, il0, il1, ii0, ii1, ij0, ij1        ! local integers
+      REAL(wp)::   zl, zi
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dta_tsd')
+      !
+      CALL fld_read( kt, 1, sf_tsd )      !==   read T & S data at kt time step   ==!
+      !
+      !
+!!gm  This should be removed from the code   ===>>>>  T & S files has to be changed
+      !
+      !                                   !==   ORCA_R2 configuration and T & S damping   ==! 
+      IF( cn_cfg == "orca" .AND. nn_cfg == 2 .AND. ln_tsd_tradmp ) THEN    ! some hand made alterations
+         !
+         ij0 = 101   ;   ij1 = 109                       ! Reduced T & S in the Alboran Sea
+         ii0 = 141   ;   ii1 = 155
+         DO jj = mj0(ij0), mj1(ij1)
+            DO ji = mi0(ii0), mi1(ii1)
+               sf_tsd(jp_tem)%fnow(ji,jj,13:13) = sf_tsd(jp_tem)%fnow(ji,jj,13:13) - 0.20_wp
+               sf_tsd(jp_tem)%fnow(ji,jj,14:15) = sf_tsd(jp_tem)%fnow(ji,jj,14:15) - 0.35_wp
+               sf_tsd(jp_tem)%fnow(ji,jj,16:25) = sf_tsd(jp_tem)%fnow(ji,jj,16:25) - 0.40_wp
+               !
+               sf_tsd(jp_sal)%fnow(ji,jj,13:13) = sf_tsd(jp_sal)%fnow(ji,jj,13:13) - 0.15_wp
+               sf_tsd(jp_sal)%fnow(ji,jj,14:15) = sf_tsd(jp_sal)%fnow(ji,jj,14:15) - 0.25_wp
+               sf_tsd(jp_sal)%fnow(ji,jj,16:17) = sf_tsd(jp_sal)%fnow(ji,jj,16:17) - 0.30_wp
+               sf_tsd(jp_sal)%fnow(ji,jj,18:25) = sf_tsd(jp_sal)%fnow(ji,jj,18:25) - 0.35_wp
+            END DO
+         END DO
+         ij0 =  87   ;   ij1 =  96                          ! Reduced temperature in Red Sea
+         ii0 = 148   ;   ii1 = 160
+         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 ) = 7.0_wp
+         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 ) = 6.5_wp
+         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp
+      ENDIF
+!!gm end
+      !
+      IF( kt == nit000 .AND. lwp )THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dta_tsd: interpolates T & S data onto current mesh'
+      ENDIF
+      !
+      IF( ln_tsd_interp ) THEN                 ! probably should use pointers in the following to make more readable
+      !
+         DO jk = 1, jpk                        ! determines the intepolated T-S profiles at each (i,j) points
+            DO jj= 1, jpj
+               DO ji= 1, jpi
+                  zl = gdept_0(ji,jj,jk)
+                  IF( zl < sf_tsd(jp_dep)%fnow(ji,jj,1) ) THEN                     ! above the first level of data
+                     ptsd(ji,jj,jk,jp_tem) = sf_tsd(jp_tem)%fnow(ji,jj,1) 
+                     ptsd(ji,jj,jk,jp_sal) = sf_tsd(jp_sal)%fnow(ji,jj,1)
+                  ELSEIF( zl > sf_tsd(jp_dep)%fnow(ji,jj,jpk_init) ) THEN          ! below the last level of data
+                     ptsd(ji,jj,jk,jp_tem) = sf_tsd(jp_tem)%fnow(ji,jj,jpk_init)
+                     ptsd(ji,jj,jk,jp_sal) = sf_tsd(jp_sal)%fnow(ji,jj,jpk_init)
+                  ELSE                                                             ! inbetween : vertical interpolation between jk_init & jk_init+1
+                     DO jk_init = 1, jpk_init-1                                    ! when  gdept(jk_init) < zl < gdept(jk_init+1)
+                        IF( sf_tsd(jp_msk)%fnow(ji,jj,jk_init+1) == 0 ) THEN       ! if there is no data fill down
+                           sf_tsd(jp_tem)%fnow(ji,jj,jk_init+1) = sf_tsd(jp_tem)%fnow(ji,jj,jk_init)
+                           sf_tsd(jp_sal)%fnow(ji,jj,jk_init+1) = sf_tsd(jp_sal)%fnow(ji,jj,jk_init)
+                        ENDIF
+                        IF( (zl-sf_tsd(jp_dep)%fnow(ji,jj,jk_init)) * (zl-sf_tsd(jp_dep)%fnow(ji,jj,jk_init+1)) <= 0._wp ) THEN
+                           zi = ( zl - sf_tsd(jp_dep)%fnow(ji,jj,jk_init) ) / &
+                        &       (sf_tsd(jp_dep)%fnow(ji,jj,jk_init+1)-sf_tsd(jp_dep)%fnow(ji,jj,jk_init))
+                           ptsd(ji,jj,jk,jp_tem) = sf_tsd(jp_tem)%fnow(ji,jj,jk_init) + &
+                        &                          (sf_tsd(jp_tem)%fnow(ji,jj,jk_init+1)-sf_tsd(jp_tem)%fnow(ji,jj,jk_init)) * zi
+                           ptsd(ji,jj,jk,jp_sal) = sf_tsd(jp_sal)%fnow(ji,jj,jk_init) + &
+                        &                          (sf_tsd(jp_sal)%fnow(ji,jj,jk_init+1)-sf_tsd(jp_sal)%fnow(ji,jj,jk_init)) * zi
+                        ENDIF
+                     END DO
+                  ENDIF
+               ENDDO
+            ENDDO
+         END DO
+         !
+         ptsd(:,:,:,jp_tem) = ptsd(:,:,:,jp_tem) *tmask(:,:,:)
+         ptsd(:,:,:,jp_sal) = ptsd(:,:,:,jp_sal) *tmask(:,:,:)
+      ELSE                                !==   z- or zps- coordinate   ==!
+         !                             
+         ptsd(:,:,:,jp_tem) = sf_tsd(jp_tem)%fnow(:,:,:)  * tmask(:,:,:)  ! Mask
+         ptsd(:,:,:,jp_sal) = sf_tsd(jp_sal)%fnow(:,:,:)  * tmask(:,:,:)
+         !
+         IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  ik = mbkt(ji,jj) 
+                  IF( ik > 1 ) THEN
+                     zl = ( gdept_1d(ik) - gdept_0(ji,jj,ik) ) / ( gdept_1d(ik) - gdept_1d(ik-1) )
+                     ptsd(ji,jj,ik,jp_tem) = (1.-zl) * ptsd(ji,jj,ik,jp_tem) + zl * ptsd(ji,jj,ik-1,jp_tem)
+                     ptsd(ji,jj,ik,jp_sal) = (1.-zl) * ptsd(ji,jj,ik,jp_sal) + zl * ptsd(ji,jj,ik-1,jp_sal)
+                  ENDIF
+                  ik = mikt(ji,jj)
+                  IF( ik > 1 ) THEN
+                     zl = ( gdept_0(ji,jj,ik) - gdept_1d(ik) ) / ( gdept_1d(ik+1) - gdept_1d(ik) ) 
+                     ptsd(ji,jj,ik,jp_tem) = (1.-zl) * ptsd(ji,jj,ik,jp_tem) + zl * ptsd(ji,jj,ik+1,jp_tem)
+                     ptsd(ji,jj,ik,jp_sal) = (1.-zl) * ptsd(ji,jj,ik,jp_sal) + zl * ptsd(ji,jj,ik+1,jp_sal)
+                  END IF
+               END DO
+            END DO
+         ENDIF
+         !
+      ENDIF
+      !
+      IF( .NOT.ln_tsd_tradmp ) THEN                   !==   deallocate T & S structure   ==! 
+         !                                              (data used only for initialisation)
+         IF(lwp) WRITE(numout,*) 'dta_tsd: deallocte T & S arrays as they are only use to initialize the run'
+                                        DEALLOCATE( sf_tsd(jp_tem)%fnow )     ! T arrays in the structure
+         IF( sf_tsd(jp_tem)%ln_tint )   DEALLOCATE( sf_tsd(jp_tem)%fdta )
+                                        DEALLOCATE( sf_tsd(jp_sal)%fnow )     ! S arrays in the structure
+         IF( sf_tsd(jp_sal)%ln_tint )   DEALLOCATE( sf_tsd(jp_sal)%fdta )
+         IF( ln_tsd_interp )            DEALLOCATE( sf_tsd(jp_dep)%fnow )     ! T arrays in the structure
+         IF( ln_tsd_interp )            DEALLOCATE( sf_tsd(jp_msk)%fnow )     ! T arrays in the structure
+                                        DEALLOCATE( sf_tsd              )     ! the structure itself
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dta_tsd')
+      !
+   END SUBROUTINE dta_tsd
+
+   !!======================================================================
+END MODULE dtatsd
diff --git a/MY_SRC/dynnxt.F90 b/MY_SRC/dynnxt.F90
new file mode 100644
index 0000000..756dfb5
--- /dev/null
+++ b/MY_SRC/dynnxt.F90
@@ -0,0 +1,428 @@
+MODULE dynnxt
+   !!=========================================================================
+   !!                       ***  MODULE  dynnxt  ***
+   !! Ocean dynamics: time stepping
+   !!=========================================================================
+   !! History :  OPA  !  1987-02  (P. Andrich, D. L Hostis)  Original code
+   !!                 !  1990-10  (C. Levy, G. Madec)
+   !!            7.0  !  1993-03  (M. Guyon)  symetrical conditions
+   !!            8.0  !  1997-02  (G. Madec & M. Imbard)  opa, release 8.0
+   !!            8.2  !  1997-04  (A. Weaver)  Euler forward step
+   !!             -   !  1997-06  (G. Madec)  lateral boudary cond., lbc routine
+   !!    NEMO    1.0  !  2002-08  (G. Madec)  F90: Free form and module
+   !!             -   !  2002-10  (C. Talandier, A-M. Treguier) Open boundary cond.
+   !!            2.0  !  2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            2.3  !  2007-07  (D. Storkey) Calls to BDY routines. 
+   !!            3.2  !  2009-06  (G. Madec, R.Benshila)  re-introduce the vvl option
+   !!            3.3  !  2010-09  (D. Storkey, E.O'Dea) Bug fix for BDY module
+   !!            3.3  !  2011-03  (P. Oddo) Bug fix for time-splitting+(BDY-OBC) and not VVL
+   !!            3.5  !  2013-07  (J. Chanut) Compliant with time splitting changes
+   !!            3.6  !  2014-04  (G. Madec) add the diagnostic of the time filter trends
+   !!            3.7  !  2015-11  (J. Chanut) Free surface simplification
+   !!-------------------------------------------------------------------------
+  
+   !!-------------------------------------------------------------------------
+   !!   dyn_nxt       : obtain the next (after) horizontal velocity
+   !!-------------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE sbc_oce        ! Surface boundary condition: ocean fields
+   USE phycst         ! physical constants
+   USE dynadv         ! dynamics: vector invariant versus flux form
+   USE dynspg_ts      ! surface pressure gradient: split-explicit scheme
+   USE dynspg
+   USE domvvl         ! variable volume
+   USE bdy_oce   , ONLY: ln_bdy
+   USE bdydta         ! ocean open boundary conditions
+   USE bdydyn         ! ocean open boundary conditions
+   USE bdyvol         ! ocean open boundary condition (bdy_vol routines)
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   USE trdken         ! trend manager: kinetic energy
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O manager library
+   USE lbclnk         ! lateral boundary condition (or mpp link)
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE prtctl         ! Print control
+   USE timing         ! Timing
+#if defined key_agrif
+   USE agrif_opa_interp
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC    dyn_nxt   ! routine called by step.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: dynnxt.F90 7753 2017-03-03 11:46:59Z mocavero $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_nxt ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_nxt  ***
+      !!                   
+      !! ** Purpose :   Finalize after horizontal velocity. Apply the boundary 
+      !!             condition on the after velocity, achieve the time stepping 
+      !!             by applying the Asselin filter on now fields and swapping 
+      !!             the fields.
+      !!
+      !! ** Method  : * Ensure after velocities transport matches time splitting
+      !!             estimate (ln_dynspg_ts=T)
+      !!
+      !!              * Apply lateral boundary conditions on after velocity 
+      !!             at the local domain boundaries through lbc_lnk call,
+      !!             at the one-way open boundaries (ln_bdy=T),
+      !!             at the AGRIF zoom   boundaries (lk_agrif=T)
+      !!
+      !!              * Apply the time filter applied and swap of the dynamics
+      !!             arrays to start the next time step:
+      !!                (ub,vb) = (un,vn) + atfp [ (ub,vb) + (ua,va) - 2 (un,vn) ]
+      !!                (un,vn) = (ua,va).
+      !!             Note that with flux form advection and non linear free surface,
+      !!             the time filter is applied on thickness weighted velocity.
+      !!             As a result, dyn_nxt MUST be called after tra_nxt.
+      !!
+      !! ** Action :   ub,vb   filtered before horizontal velocity of next time-step
+      !!               un,vn   now horizontal velocity of next time-step
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ikt          ! local integers
+      REAL(wp) ::   zue3a, zue3n, zue3b, zuf, zcoef    ! local scalars
+      REAL(wp) ::   zve3a, zve3n, zve3b, zvf, z1_2dt   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:)   ::  zue, zve
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ze3u_f, ze3v_f, zua, zva 
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('dyn_nxt')
+      !
+      IF( ln_dynspg_ts       )   CALL wrk_alloc( jpi,jpj,       zue, zve)
+      IF( l_trddyn           )   CALL wrk_alloc( jpi,jpj,jpk,   zua, zva)
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_nxt : time stepping'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      IF ( ln_dynspg_ts ) THEN
+         ! Ensure below that barotropic velocities match time splitting estimate
+         ! Compute actual transport and replace it with ts estimate at "after" time step
+         zue(:,:) = e3u_a(:,:,1) * ua(:,:,1) * umask(:,:,1)
+         zve(:,:) = e3v_a(:,:,1) * va(:,:,1) * vmask(:,:,1)
+         DO jk = 2, jpkm1
+            zue(:,:) = zue(:,:) + e3u_a(:,:,jk) * ua(:,:,jk) * umask(:,:,jk)
+            zve(:,:) = zve(:,:) + e3v_a(:,:,jk) * va(:,:,jk) * vmask(:,:,jk)
+         END DO
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = ( ua(:,:,jk) - zue(:,:) * r1_hu_a(:,:) + ua_b(:,:) ) * umask(:,:,jk)
+            va(:,:,jk) = ( va(:,:,jk) - zve(:,:) * r1_hv_a(:,:) + va_b(:,:) ) * vmask(:,:,jk)
+         END DO
+         !
+         IF( .NOT.ln_bt_fw ) THEN
+            ! Remove advective velocity from "now velocities" 
+            ! prior to asselin filtering     
+            ! In the forward case, this is done below after asselin filtering   
+            ! so that asselin contribution is removed at the same time 
+            DO jk = 1, jpkm1
+               un(:,:,jk) = ( un(:,:,jk) - un_adv(:,:) + un_b(:,:) )*umask(:,:,jk)
+               vn(:,:,jk) = ( vn(:,:,jk) - vn_adv(:,:) + vn_b(:,:) )*vmask(:,:,jk)
+            END DO  
+         ENDIF
+      ENDIF
+
+      ! Update after velocity on domain lateral boundaries
+      ! --------------------------------------------------      
+# if defined key_agrif
+      CALL Agrif_dyn( kt )             !* AGRIF zoom boundaries
+# endif
+      !
+      CALL lbc_lnk( ua, 'U', -1. )     !* local domain boundaries
+      CALL lbc_lnk( va, 'V', -1. ) 
+      !
+      !                                !* BDY open boundaries
+      IF( ln_bdy .AND. ln_dynspg_exp )   CALL bdy_dyn( kt )
+      IF( ln_bdy .AND. ln_dynspg_ts  )   CALL bdy_dyn( kt, dyn3d_only=.true. )
+
+!!$   Do we need a call to bdy_vol here??
+      !
+      IF( l_trddyn ) THEN             ! prepare the atf trend computation + some diagnostics
+         z1_2dt = 1._wp / (2. * rdt)        ! Euler or leap-frog time step 
+         IF( neuler == 0 .AND. kt == nit000 )   z1_2dt = 1._wp / rdt
+         !
+         !                                  ! Kinetic energy and Conversion
+         IF( ln_KE_trd  )   CALL trd_dyn( ua, va, jpdyn_ken, kt )
+         !
+         IF( ln_dyn_trd ) THEN              ! 3D output: total momentum trends
+            zua(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) * z1_2dt
+            zva(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) * z1_2dt
+            CALL iom_put( "utrd_tot", zua )        ! total momentum trends, except the asselin time filter
+            CALL iom_put( "vtrd_tot", zva )
+         ENDIF
+         !
+         zua(:,:,:) = un(:,:,:)             ! save the now velocity before the asselin filter
+         zva(:,:,:) = vn(:,:,:)             ! (caution: there will be a shift by 1 timestep in the
+         !                                  !  computation of the asselin filter trends)
+      ENDIF
+
+      ! Time filter and swap of dynamics arrays
+      ! ------------------------------------------
+      IF( neuler == 0 .AND. kt == nit000 ) THEN        !* Euler at first time-step: only swap
+         DO jk = 1, jpkm1
+            un(:,:,jk) = ua(:,:,jk)                          ! un <-- ua
+            vn(:,:,jk) = va(:,:,jk)
+         END DO
+!jth limit velocities
+       IF (ln_ulimit) THEN
+         call dyn_limit_velocity (kt)
+       ENDIF
+         IF(.NOT.ln_linssh ) THEN
+            DO jk = 1, jpkm1
+               e3t_b(:,:,jk) = e3t_n(:,:,jk)
+               e3u_b(:,:,jk) = e3u_n(:,:,jk)
+               e3v_b(:,:,jk) = e3v_n(:,:,jk)
+            END DO
+         ENDIF
+      ELSE                                             !* Leap-Frog : Asselin filter and swap
+         !                                ! =============!
+         IF( ln_linssh ) THEN             ! Fixed volume !
+            !                             ! =============!
+            DO jk = 1, jpkm1                              
+               DO jj = 1, jpj
+                  DO ji = 1, jpi    
+                     zuf = un(ji,jj,jk) + atfp * ( ub(ji,jj,jk) - 2._wp * un(ji,jj,jk) + ua(ji,jj,jk) )
+                     zvf = vn(ji,jj,jk) + atfp * ( vb(ji,jj,jk) - 2._wp * vn(ji,jj,jk) + va(ji,jj,jk) )
+                     !
+                     ub(ji,jj,jk) = zuf                      ! ub <-- filtered velocity
+                     vb(ji,jj,jk) = zvf
+                     un(ji,jj,jk) = ua(ji,jj,jk)             ! un <-- ua
+                     vn(ji,jj,jk) = va(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+!jth 
+       IF (ln_ulimit) THEN
+           call dyn_limit_velocity (kt)
+       ENDIF
+            !                             ! ================!
+         ELSE                             ! Variable volume !
+            !                             ! ================!
+            ! Before scale factor at t-points
+            ! (used as a now filtered scale factor until the swap)
+            ! ----------------------------------------------------
+            IF( ln_dynspg_ts .AND. ln_bt_fw ) THEN    ! No asselin filtering on thicknesses if forward time splitting
+               e3t_b(:,:,1:jpkm1) = e3t_n(:,:,1:jpkm1)
+            ELSE
+               DO jk = 1, jpkm1
+                  e3t_b(:,:,jk) = e3t_n(:,:,jk) + atfp * ( e3t_b(:,:,jk) - 2._wp * e3t_n(:,:,jk) + e3t_a(:,:,jk) )
+               END DO
+               ! Add volume filter correction: compatibility with tracer advection scheme
+               ! => time filter + conservation correction (only at the first level)
+               zcoef = atfp * rdt * r1_rau0
+               IF ( .NOT. ln_isf ) THEN   ! if no ice shelf melting
+                  e3t_b(:,:,1) = e3t_b(:,:,1) - zcoef * ( emp_b(:,:) - emp(:,:) &
+                                 &                      - rnf_b(:,:) + rnf(:,:) ) * tmask(:,:,1)
+               ELSE                     ! if ice shelf melting
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        ikt = mikt(ji,jj)
+                        e3t_b(ji,jj,ikt) = e3t_b(ji,jj,ikt) - zcoef * (  emp_b   (ji,jj) - emp   (ji,jj)  &
+                           &                                           - rnf_b   (ji,jj) + rnf   (ji,jj)  &
+                           &                                           + fwfisf_b(ji,jj) - fwfisf(ji,jj)  ) * tmask(ji,jj,ikt)
+                     END DO
+                  END DO
+               END IF
+            ENDIF
+            !
+            IF( ln_dynadv_vec ) THEN      ! Asselin filter applied on velocity
+               ! Before filtered scale factor at (u/v)-points
+               CALL dom_vvl_interpol( e3t_b(:,:,:), e3u_b(:,:,:), 'U' )
+               CALL dom_vvl_interpol( e3t_b(:,:,:), e3v_b(:,:,:), 'V' )
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        zuf = un(ji,jj,jk) + atfp * ( ub(ji,jj,jk) - 2._wp * un(ji,jj,jk) + ua(ji,jj,jk) )
+                        zvf = vn(ji,jj,jk) + atfp * ( vb(ji,jj,jk) - 2._wp * vn(ji,jj,jk) + va(ji,jj,jk) )
+                        !
+                        ub(ji,jj,jk) = zuf                      ! ub <-- filtered velocity
+                        vb(ji,jj,jk) = zvf
+                        un(ji,jj,jk) = ua(ji,jj,jk)             ! un <-- ua
+                        vn(ji,jj,jk) = va(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO
+!jth limit velocities
+       IF (ln_ulimit) THEN
+         call dyn_limit_velocity (kt)
+       ENDIF
+               !
+            ELSE                          ! Asselin filter applied on thickness weighted velocity
+               !
+               CALL wrk_alloc( jpi,jpj,jpk,   ze3u_f, ze3v_f )
+               ! Before filtered scale factor at (u/v)-points stored in ze3u_f, ze3v_f
+               CALL dom_vvl_interpol( e3t_b(:,:,:), ze3u_f, 'U' )
+               CALL dom_vvl_interpol( e3t_b(:,:,:), ze3v_f, 'V' )
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi                  
+                        zue3a = e3u_a(ji,jj,jk) * ua(ji,jj,jk)
+                        zve3a = e3v_a(ji,jj,jk) * va(ji,jj,jk)
+                        zue3n = e3u_n(ji,jj,jk) * un(ji,jj,jk)
+                        zve3n = e3v_n(ji,jj,jk) * vn(ji,jj,jk)
+                        zue3b = e3u_b(ji,jj,jk) * ub(ji,jj,jk)
+                        zve3b = e3v_b(ji,jj,jk) * vb(ji,jj,jk)
+                        !
+                        zuf = ( zue3n + atfp * ( zue3b - 2._wp * zue3n  + zue3a ) ) / ze3u_f(ji,jj,jk)
+                        zvf = ( zve3n + atfp * ( zve3b - 2._wp * zve3n  + zve3a ) ) / ze3v_f(ji,jj,jk)
+                        !
+                        ub(ji,jj,jk) = zuf                     ! ub <-- filtered velocity
+                        vb(ji,jj,jk) = zvf
+                        un(ji,jj,jk) = ua(ji,jj,jk)            ! un <-- ua
+                        vn(ji,jj,jk) = va(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO
+!jth limit velocities
+       IF (ln_ulimit) THEN
+         call dyn_limit_velocity (kt)
+       ENDIF
+               e3u_b(:,:,1:jpkm1) = ze3u_f(:,:,1:jpkm1)        ! e3u_b <-- filtered scale factor
+               e3v_b(:,:,1:jpkm1) = ze3v_f(:,:,1:jpkm1)
+               !
+               CALL wrk_dealloc( jpi,jpj,jpk,   ze3u_f, ze3v_f )
+            ENDIF
+            !
+         ENDIF
+         !
+         IF( ln_dynspg_ts .AND. ln_bt_fw ) THEN
+            ! Revert "before" velocities to time split estimate
+            ! Doing it here also means that asselin filter contribution is removed  
+            zue(:,:) = e3u_b(:,:,1) * ub(:,:,1) * umask(:,:,1)
+            zve(:,:) = e3v_b(:,:,1) * vb(:,:,1) * vmask(:,:,1)    
+            DO jk = 2, jpkm1
+               zue(:,:) = zue(:,:) + e3u_b(:,:,jk) * ub(:,:,jk) * umask(:,:,jk)
+               zve(:,:) = zve(:,:) + e3v_b(:,:,jk) * vb(:,:,jk) * vmask(:,:,jk)    
+            END DO
+            DO jk = 1, jpkm1
+               ub(:,:,jk) = ub(:,:,jk) - (zue(:,:) * r1_hu_n(:,:) - un_b(:,:)) * umask(:,:,jk)
+               vb(:,:,jk) = vb(:,:,jk) - (zve(:,:) * r1_hv_n(:,:) - vn_b(:,:)) * vmask(:,:,jk)
+            END DO
+         ENDIF
+         !
+      ENDIF ! neuler =/0
+      !
+      ! Set "now" and "before" barotropic velocities for next time step:
+      ! JC: Would be more clever to swap variables than to make a full vertical
+      ! integration
+      !
+      !
+      IF(.NOT.ln_linssh ) THEN
+         hu_b(:,:) = e3u_b(:,:,1) * umask(:,:,1)
+         hv_b(:,:) = e3v_b(:,:,1) * vmask(:,:,1)
+         DO jk = 2, jpkm1
+            hu_b(:,:) = hu_b(:,:) + e3u_b(:,:,jk) * umask(:,:,jk)
+            hv_b(:,:) = hv_b(:,:) + e3v_b(:,:,jk) * vmask(:,:,jk)
+         END DO
+         r1_hu_b(:,:) = ssumask(:,:) / ( hu_b(:,:) + 1._wp - ssumask(:,:) )
+         r1_hv_b(:,:) = ssvmask(:,:) / ( hv_b(:,:) + 1._wp - ssvmask(:,:) )
+      ENDIF
+      !
+      un_b(:,:) = e3u_a(:,:,1) * un(:,:,1) * umask(:,:,1)
+      ub_b(:,:) = e3u_b(:,:,1) * ub(:,:,1) * umask(:,:,1)
+      vn_b(:,:) = e3v_a(:,:,1) * vn(:,:,1) * vmask(:,:,1)
+      vb_b(:,:) = e3v_b(:,:,1) * vb(:,:,1) * vmask(:,:,1)
+      DO jk = 2, jpkm1
+         un_b(:,:) = un_b(:,:) + e3u_a(:,:,jk) * un(:,:,jk) * umask(:,:,jk)
+         ub_b(:,:) = ub_b(:,:) + e3u_b(:,:,jk) * ub(:,:,jk) * umask(:,:,jk)
+         vn_b(:,:) = vn_b(:,:) + e3v_a(:,:,jk) * vn(:,:,jk) * vmask(:,:,jk)
+         vb_b(:,:) = vb_b(:,:) + e3v_b(:,:,jk) * vb(:,:,jk) * vmask(:,:,jk)
+      END DO
+      un_b(:,:) = un_b(:,:) * r1_hu_a(:,:)
+      vn_b(:,:) = vn_b(:,:) * r1_hv_a(:,:)
+      ub_b(:,:) = ub_b(:,:) * r1_hu_b(:,:)
+      vb_b(:,:) = vb_b(:,:) * r1_hv_b(:,:)
+      !
+      IF( .NOT.ln_dynspg_ts ) THEN        ! output the barotropic currents
+         CALL iom_put(  "ubar", un_b(:,:) )
+         CALL iom_put(  "vbar", vn_b(:,:) )
+      ENDIF
+      IF( l_trddyn ) THEN                ! 3D output: asselin filter trends on momentum
+         zua(:,:,:) = ( ub(:,:,:) - zua(:,:,:) ) * z1_2dt
+         zva(:,:,:) = ( vb(:,:,:) - zva(:,:,:) ) * z1_2dt
+         CALL trd_dyn( zua, zva, jpdyn_atf, kt )
+      ENDIF
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=un, clinfo1=' nxt  - Un: ', mask1=umask,   &
+         &                       tab3d_2=vn, clinfo2=' Vn: '       , mask2=vmask )
+      ! 
+      IF( ln_dynspg_ts )   CALL wrk_dealloc( jpi,jpj,       zue, zve )
+      IF( l_trddyn     )   CALL wrk_dealloc( jpi,jpj,jpk,   zua, zva )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_nxt')
+      !
+   END SUBROUTINE dyn_nxt
+
+   SUBROUTINE dyn_limit_velocity (kt)
+   ! limits maxming vlaues of un and vn by volume courant number
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) :: zzu,zplim,zmlim,isp,ism,zcn,ze3e1,zzcn,zcnn,idivp,idivm
+
+   !!=========================================================================
+!jth limit fluxes
+      zcn =cn_ulimit !0.9 ! maximum velocity inverse courant number
+      zcnn = cnn_ulimit !0.54 ! how much to reduce cn by in divergen flow
+
+      DO jk = 1, jpkm1
+       DO jj = 1, jpjm1
+        DO ji = 1, jpim1
+! U direction
+         zzu = un(ji,jj,jk)
+         ze3e1 = e3u_n(ji  ,jj,jk) * e2u(ji  ,jj) 
+! ips is 1 if flow is positive othersize zero
+         isp =  0.5 * (sign(1.0_wp,zzu) + 1.0_wp )
+         ism = -0.5 * (sign(1.0_wp,zzu) - 1.0_wp )
+!idev is 1 if divergent flow otherwise zero
+         idivp = isp *  -0.5 * (sign(1.0_wp, un(ji-1,jj,jk)) - 1.0_wp )
+         idivm = ism *   0.5 * (sign(1.0_wp, un(ji+1,jj,jk)) + 1.0_wp )
+         zzcn = (idivp+idivm)*(zcnn-1.0_wp)+1.0_wp
+         zzcn = zzcn * zcn
+         zplim =  zzcn * (e3t_n(ji  ,jj,jk) * e1t(ji  ,jj) * e2t(ji  ,jj)) / (2.0*rdt * ze3e1)*umask(ji,jj,jk)
+         zmlim = -zzcn * (e3t_n(ji+1,jj,jk) * e1t(ji+1,jj) * e2t(ji+1,jj)) / (2.0*rdt * ze3e1)*umask(ji,jj,jk)
+!limit currents
+         un(ji,jj,jk) = min ( zzu,zplim) * isp + max (zzu,zmlim) *ism
+!         if (abs(un(ji,jj,jk)) .ge. 20.) write(666,*)  un(ji,jj,jk),ze3e1, isp,ism, zzu,e3t_n(ji+1,jj,jk)
+!         call flush(666)
+! if (ji+nimpp-1==122 .and. jj+njmpp-1==149 .and. jk == 1 ) write (6,*) 'uu',un(ji,jj,jk), ze3e1, isp,ism, zzu,e3t_n(ji+1,jj,jk),e1t(ji+1,jj), e2t(ji+1,jj),zmlim
+!         call flush(6)
+! V  direction
+         zzu = vn(ji,jj,jk)
+         ze3e1 = e3v_n(ji  ,jj,jk) * e1v(ji  ,jj)
+         isp =  0.5 * (sign(1.0_wp,zzu) + 1.0_wp )
+         ism = -0.5 * (sign(1.0_wp,zzu) - 1.0_wp )
+!idev is 1 if divergent flow otherwise zero
+         idivp = isp *  -0.5 * (sign(1.0_wp, vn(ji,jj-1,jk)) - 1.0_wp )
+         idivm = ism *   0.5 * (sign(1.0_wp, vn(ji,jj+1,jk)) + 1.0_wp )
+         zzcn = (idivp+idivm)*(zcnn-1.0_wp)+1.0_wp
+         zzcn = zzcn * zcn
+         zplim =  zzcn * (e3t_n(ji,jj  ,jk) * e1t(ji,jj  ) * e2t(ji,jj  )) / (2.0*rdt * ze3e1)*vmask(ji,jj,jk)
+         zmlim = -zzcn * (e3t_n(ji,jj+1,jk) * e1t(ji,jj+1) * e2t(ji,jj+1)) / (2.0*rdt * ze3e1)*vmask(ji,jj,jk)
+         vn(ji,jj,jk) = min ( zzu,zplim) * isp + max (zzu,zmlim) *ism
+!	   if (abs(vn(ji,jj,jk)) .ge. 20.) write(666,*) vn(ji,jj,jk), ze3e1, isp,ism, zzu,e3t_n(ji,jj+1,jk)
+!         call flush(666)
+! if (ji+nimpp-1==122 .and. jj+njmpp-1==149 .and. jk == 1 ) write (6,*) 'vv',vn(ji,jj,jk), ze3e1, isp,ism, zzu,e3t_n(ji,jj+1,jk)
+
+       ENDDO
+      ENDDO
+     ENDDO
+
+    END SUBROUTINE dyn_limit_velocity 
+END MODULE dynnxt
diff --git a/MY_SRC/dynspg.F90 b/MY_SRC/dynspg.F90
new file mode 100644
index 0000000..3fa4160
--- /dev/null
+++ b/MY_SRC/dynspg.F90
@@ -0,0 +1,242 @@
+MODULE dynspg
+   !!======================================================================
+   !!                       ***  MODULE  dynspg  ***
+   !! Ocean dynamics:  surface pressure gradient control
+   !!======================================================================
+   !! History :  1.0  ! 2005-12  (C. Talandier, G. Madec, V. Garnier)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_spg     : update the dynamics trend with surface pressure gradient 
+   !!   dyn_spg_init: initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE c1d            ! 1D vertical configuration
+   USE phycst         ! physical constants
+   USE sbc_oce        ! surface boundary condition: ocean
+   USE sbcapr         ! surface boundary condition: atmospheric pressure
+   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
+   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
+   USE sbctide        ! 
+   USE updtide        ! 
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   !
+   USE prtctl         ! Print control                     (prt_ctl routine)
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_spg        ! routine called by step module
+   PUBLIC   dyn_spg_init   ! routine called by opa module
+
+   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_... 
+!jth
+   LOGICAL, PUBLIC ::  ln_ulimit
+   REAL(wp), PUBLIC :: cn_ulimit,cnn_ulimit
+!
+   !                       ! Parameter to control the surface pressure gradient scheme
+   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
+   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
+   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id: dynspg.F90 7753 2017-03-03 11:46:59Z mocavero $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_spg( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_spg  ***
+      !!
+      !! ** Purpose :   compute surface pressure gradient including the 
+      !!              atmospheric pressure forcing (ln_apr_dyn=T).
+      !!
+      !! ** Method  :   Two schemes:
+      !!              - explicit       : the spg is evaluated at now
+      !!              - split-explicit : a time splitting technique is used
+      !!
+      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied 
+      !!             as the gradient of the inverse barometer ssh:
+      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
+      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
+      !!             Note that as all external forcing a time averaging over a two rdt
+      !!             period is used to prevent the divergence of odd and even time step.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
+      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
+      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpice
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
+      !
+      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
+         CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
+         ztrdu(:,:,:) = ua(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
+      !
+      IF(      ln_apr_dyn                                                &   ! atmos. pressure
+         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
+         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
+         !
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               spgu(ji,jj) = 0._wp
+               spgv(ji,jj) = 0._wp
+            END DO
+         END DO         
+         !
+         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
+            zg_2 = grav * 0.5
+            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
+                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
+                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
+               END DO
+            END DO
+         ENDIF
+         !
+         !                                    !==  tide potential forcing term  ==!
+         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. ln_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
+            !
+            CALL upd_tide( kt )                      ! update tide potential
+            !
+            DO jj = 2, jpjm1                         ! add tide potential forcing
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
+               END DO 
+            END DO
+         ENDIF
+         !
+         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
+            CALL wrk_alloc( jpi,jpj,   zpice )
+            !                                            
+            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
+            zgrau0r     = - grav * r1_rau0
+            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
+               END DO
+            END DO
+            !
+            CALL wrk_dealloc( jpi,jpj,   zpice )         
+         ENDIF
+         !
+         DO jk = 1, jpkm1                    !== Add all terms to the general trend
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
+                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
+               END DO
+            END DO
+         END DO    
+         !
+!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
+         !    
+      ENDIF
+      !
+      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
+      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
+      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
+      END SELECT
+      !                    
+      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
+         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
+      ENDIF
+      !                                      ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
+      !
+   END SUBROUTINE dyn_spg
+
+
+   SUBROUTINE dyn_spg_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_spg_init  ***
+      !!                
+      !! ** Purpose :   Control the consistency between namelist options for 
+      !!              surface pressure gradient schemes
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio, ios   ! local integers
+      !
+      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
+      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
+      &                    nn_baro , rn_bt_cmax, nn_bt_flt,ln_ulimit,cn_ulimit,cnn_ulimit
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
+      !
+      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
+      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
+      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namdyn_spg )
+      !
+      IF(lwp) THEN             ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
+         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
+
+         write(numout,*) '     Limit velocities                       ln_ulimit     = ',ln_ulimit
+         write(numout,*) '     Limit velocities      max inverse Courant number     = ',cn_ulimit
+         write(numout,*) '     Limit velocities   multiplier for divergant flow     = ',cnn_ulimit
+
+      ENDIF
+      !                          ! Control of surface pressure gradient scheme options
+                                     nspg =  np_NO    ;   ioptio = 0
+      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
+      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
+      !
+      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
+      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
+      IF( ln_dynspg_exp .AND. ln_isfcav )   &
+           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( nspg == np_EXP )   WRITE(numout,*) '      ===>>   explicit free surface'
+         IF( nspg == np_TS  )   WRITE(numout,*) '      ===>>   free surface with time splitting scheme'
+         IF( nspg == np_NO  )   WRITE(numout,*) '      ===>>   No surface surface pressure gradient trend in momentum Eqs.'
+      ENDIF
+      !
+      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
+         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
+         IF( dyn_spg_ts_alloc() /= 0  )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays' )
+         IF( neuler/=0 .AND. ln_bt_fw )   CALL ts_rst( nit000, 'READ' )
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
+      !
+   END SUBROUTINE dyn_spg_init
+
+  !!======================================================================
+END MODULE dynspg
diff --git a/MY_SRC/par_oce.F90 b/MY_SRC/par_oce.F90
new file mode 100755
index 0000000..faf0b9c
--- /dev/null
+++ b/MY_SRC/par_oce.F90
@@ -0,0 +1,90 @@
+MODULE par_oce
+   !!======================================================================
+   !!                        ***  par_oce  ***
+   !! Ocean :   set the ocean parameters
+   !!======================================================================
+   !! History :  OPA  !  1991     (Imbard, Levy, Madec)  Original code
+   !!   NEMO     1.0  !  2004-01  (G. Madec, J.-M. Molines)  Free form and module
+   !!            3.3  !  2010-09  (C. Ethe) TRA-TRC merge: add jpts, jp_tem & jp_sal
+   !!----------------------------------------------------------------------
+   USE par_kind          ! kind parameters
+
+   IMPLICIT NONE
+   PUBLIC
+
+   !!----------------------------------------------------------------------
+   !!                   namcfg namelist parameters
+   !!----------------------------------------------------------------------
+   LOGICAL       ::   ln_read_cfg      !: (=T) read the domain configuration file or (=F) not
+   CHARACTER(lc) ::      cn_domcfg        !: filename the configuration file to be read
+   LOGICAL       ::   ln_write_cfg     !: (=T) create the domain configuration file
+   CHARACTER(lc) ::      cn_domcfg_out    !: filename the configuration file to be read
+   !
+   LOGICAL       ::   ln_use_jattr     !: input file read offset
+   !                                   !  Use file global attribute: open_ocean_jstart to determine start j-row 
+   !                                   !  when reading input from those netcdf files that have the 
+   !                                   !  attribute defined. This is designed to enable input files associated 
+   !                                   !  with the extended grids used in the under ice shelf configurations to 
+   !                                   !  be used without redundant rows when the ice shelves are not in use.
+   ! 
+
+   !!---------------------------------------------------------------------
+   !! Domain Matrix size 
+   !!---------------------------------------------------------------------
+   ! configuration name & resolution   (required only in ORCA family case)
+   CHARACTER(lc) ::   cn_cfg           !: name of the configuration
+   INTEGER       ::   nn_cfg           !: resolution of the configuration 
+
+   ! global domain size               !!! * total computational domain *
+   INTEGER       ::   jpiglo           !: 1st dimension of global domain --> i-direction
+   INTEGER       ::   jpjglo           !: 2nd    -                  -    --> j-direction
+   INTEGER       ::   jpkglo           !: 3nd    -                  -    --> k levels
+
+#if defined key_agrif
+
+!!gm  BUG ?   I'm surprised by the calculation below of nbcellsx and nbcellsy before jpiglo,jpjglo 
+!!gm                           has been assigned to a value....
+!!gm
+
+   ! global domain size for AGRIF     !!! * total AGRIF computational domain *
+   INTEGER, PUBLIC, PARAMETER ::   nbghostcells = 1                             !: number of ghost cells
+   INTEGER, PUBLIC            ::   nbcellsx     = jpiglo - 2 - 2*nbghostcells   !: number of cells in i-direction
+   INTEGER, PUBLIC            ::   nbcellsy     = jpjglo - 2 - 2*nbghostcells   !: number of cells in j-direction
+#endif
+
+   ! local domain size                !!! * local computational domain *
+   INTEGER, PUBLIC ::   jpi   ! = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci   !: first  dimension
+   INTEGER, PUBLIC ::   jpj   ! = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj   !: second dimension
+   INTEGER, PUBLIC ::   jpk   ! = jpkglo
+   INTEGER, PUBLIC ::   jpim1 ! = jpi-1                                            !: inner domain indices
+   INTEGER, PUBLIC ::   jpjm1 ! = jpj-1                                            !:   -     -      -
+   INTEGER, PUBLIC ::   jpkm1 ! = jpk-1                                            !:   -     -      -
+   INTEGER, PUBLIC ::   jpij  ! = jpi*jpj                                          !:  jpi x jpj
+
+   !!---------------------------------------------------------------------
+   !! Active tracer parameters
+   !!---------------------------------------------------------------------
+   INTEGER, PUBLIC, PARAMETER ::   jpts   = 2    !: Number of active tracers (=2, i.e. T & S )
+   INTEGER, PUBLIC, PARAMETER ::   jp_tem = 1    !: indice for temperature
+   INTEGER, PUBLIC, PARAMETER ::   jp_sal = 2    !: indice for salinity
+   INTEGER, PUBLIC, PARAMETER ::   jp_dep = 3    !: indice for depth
+   INTEGER, PUBLIC, PARAMETER ::   jp_msk = 4    !: indice for depth
+
+   !!----------------------------------------------------------------------
+   !!   Domain decomposition
+   !!----------------------------------------------------------------------
+   !! if we dont use massively parallel computer (parameters jpni=jpnj=1) so jpiglo=jpi and jpjglo=jpj
+   INTEGER, PUBLIC            ::   jpni         !: number of processors following i 
+   INTEGER, PUBLIC            ::   jpnj         !: number of processors following j
+   INTEGER, PUBLIC            ::   jpnij        !: nb of local domain = nb of processors ( <= jpni x jpnj )
+   INTEGER, PUBLIC, PARAMETER ::   jpr2di = 0   !: number of columns for extra outer halo 
+   INTEGER, PUBLIC, PARAMETER ::   jpr2dj = 0   !: number of rows    for extra outer halo 
+   INTEGER, PUBLIC, PARAMETER ::   jpreci = 1   !: number of columns for overlap 
+   INTEGER, PUBLIC, PARAMETER ::   jprecj = 1   !: number of rows    for overlap 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id: par_oce.F90 7646 2017-02-06 09:25:03Z timgraham $ 
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE par_oce
diff --git a/MY_SRC/sbctide.F90 b/MY_SRC/sbctide.F90
new file mode 100755
index 0000000..ea6d4fe
--- /dev/null
+++ b/MY_SRC/sbctide.F90
@@ -0,0 +1,137 @@
+MODULE sbctide
+   !!======================================================================
+   !!                       ***  MODULE  sbctide  ***
+   !! Initialization of tidal forcing
+   !!======================================================================
+   !! History :  9.0  !  2007  (O. Le Galloudec)  Original code
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constant
+   USE daymod         ! calandar
+   USE tideini        ! 
+   !
+   USE in_out_manager ! I/O units
+   USE iom            ! xIOs server
+   USE ioipsl         ! NetCDF IPSL library
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   ! NB - to access love number 
+   USE bdytides
+   ! END NB
+
+   IMPLICIT NONE
+   PUBLIC
+
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) ::   pot_astro   !
+
+   !!----------------------------------------------------------------------
+   !!   tidal potential
+   !!----------------------------------------------------------------------
+   !!   sbc_tide            : 
+   !!   tide_init_potential :
+   !!----------------------------------------------------------------------
+
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   amp_pot, phi_pot
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.5 , NEMO Consortium (2013)
+   !! $Id: sbctide.F90 7646 2017-02-06 09:25:03Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE sbc_tide( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE sbc_tide  ***
+      !!----------------------------------------------------------------------      
+      INTEGER, INTENT( in ) ::   kt     ! ocean time-step
+      INTEGER               ::   jk     ! dummy loop index
+      INTEGER               ::   nsec_day_orig     ! Temporary variable
+      !!----------------------------------------------------------------------
+      
+      IF( nsec_day == NINT(0.5_wp * rdt) .OR. kt == nit000 ) THEN      ! start a new day
+         !
+         IF( kt == nit000 ) THEN
+            ALLOCATE( amp_pot(jpi,jpj,nb_harmo),                      &
+               &      phi_pot(jpi,jpj,nb_harmo), pot_astro(jpi,jpj)   )
+         ENDIF
+         !
+         amp_pot(:,:,:) = 0._wp
+         phi_pot(:,:,:) = 0._wp
+         pot_astro(:,:) = 0._wp
+         !
+         ! If the run does not start from midnight then need to initialise tides
+         ! at the start of the current day (only occurs when kt==nit000)
+         ! Temporarily set nsec_day to beginning of day.
+         nsec_day_orig = nsec_day
+         IF ( nsec_day /= NINT(0.5_wp * rdt) ) THEN 
+            kt_tide = kt - (nsec_day - 0.5_wp * rdt)/rdt
+            nsec_day = NINT(0.5_wp * rdt)
+         ELSE
+            kt_tide = kt 
+         ENDIF
+         CALL tide_harmo( omega_tide, v0tide, utide, ftide, ntide, nb_harmo )
+         !
+         !
+         IF(lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'sbc_tide : Update of the components and (re)Init. the potential at kt=', kt
+            WRITE(numout,*) '~~~~~~~~ '
+            DO jk = 1, nb_harmo
+               WRITE(numout,*) Wave(ntide(jk))%cname_tide, utide(jk), ftide(jk), v0tide(jk), omega_tide(jk)
+            END DO
+         ENDIF
+         !
+         IF( ln_tide_pot )   CALL tide_init_potential
+         !
+         ! Reset nsec_day
+         nsec_day = nsec_day_orig 
+      ENDIF
+      !
+   END SUBROUTINE sbc_tide
+
+
+   SUBROUTINE tide_init_potential
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init_potential  ***
+      !!----------------------------------------------------------------------
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zcons, ztmp1, ztmp2, zlat, zlon, ztmp, zamp, zcs   ! local scalar
+      !!----------------------------------------------------------------------
+
+      DO jk = 1, nb_harmo
+!--- NB 11/2017
+! love number now provides in tide namelist
+         zcons = dn_love_number * Wave(ntide(jk))%equitide * ftide(jk)
+! ORIGINAL zcons = 0.7_wp * Wave(ntide(jk))%equitide * ftide(jk)
+!--- END NB
+         DO ji = 1, jpi
+            DO jj = 1, jpj
+               ztmp1 =  amp_pot(ji,jj,jk) * COS( phi_pot(ji,jj,jk) )
+               ztmp2 = -amp_pot(ji,jj,jk) * SIN( phi_pot(ji,jj,jk) )
+               zlat = gphit(ji,jj)*rad !! latitude en radian
+               zlon = glamt(ji,jj)*rad !! longitude en radian
+               ztmp = v0tide(jk) + utide(jk) + Wave(ntide(jk))%nutide * zlon
+               ! le potentiel est composé des effets des astres:
+               IF    ( Wave(ntide(jk))%nutide == 1 )  THEN  ;  zcs = zcons * SIN( 2._wp*zlat )
+               ELSEIF( Wave(ntide(jk))%nutide == 2 )  THEN  ;  zcs = zcons * COS( zlat )**2
+!--- NB 11/2017
+! Add tide potential for long period tides
+               ELSEIF( Wave(ntide(jk))%nutide == 0 )  THEN  ;  zcs = zcons * (0.5_wp-1.5_wp*SIN(zlat)**2._wp)
+!--- END NB
+               ELSE                                         ;  zcs = 0._wp
+               ENDIF
+               ztmp1 = ztmp1 + zcs * COS( ztmp )
+               ztmp2 = ztmp2 - zcs * SIN( ztmp )
+               zamp = SQRT( ztmp1*ztmp1 + ztmp2*ztmp2 )
+               amp_pot(ji,jj,jk) = zamp
+               phi_pot(ji,jj,jk) = ATAN2( -ztmp2 / MAX( 1.e-10_wp , zamp ) ,   &
+                  &                        ztmp1 / MAX( 1.e-10_wp,  zamp )   )
+            END DO
+         END DO
+      END DO
+      !
+   END SUBROUTINE tide_init_potential
+
+  !!======================================================================
+END MODULE sbctide
diff --git a/MY_SRC/step.F90 b/MY_SRC/step.F90
new file mode 100755
index 0000000..fe08ea3
--- /dev/null
+++ b/MY_SRC/step.F90
@@ -0,0 +1,364 @@
+MODULE step
+   !!======================================================================
+   !!                       ***  MODULE step  ***
+   !! Time-stepping   : manager of the ocean, tracer and ice time stepping
+   !!======================================================================
+   !! History :  OPA  !  1991-03  (G. Madec)  Original code
+   !!             -   !  1991-11  (G. Madec)
+   !!             -   !  1992-06  (M. Imbard)  add a first output record
+   !!             -   !  1996-04  (G. Madec)  introduction of dynspg
+   !!             -   !  1996-04  (M.A. Foujols)  introduction of passive tracer
+   !!            8.0  !  1997-06  (G. Madec)  new architecture of call
+   !!            8.2  !  1997-06  (G. Madec, M. Imbard, G. Roullet)  free surface
+   !!             -   !  1999-02  (G. Madec, N. Grima)  hpg implicit
+   !!             -   !  2000-07  (J-M Molines, M. Imbard)  Open Bondary Conditions
+   !!   NEMO     1.0  !  2002-06  (G. Madec)  free form, suppress macro-tasking
+   !!             -   !  2004-08  (C. Talandier) New trends organization
+   !!             -   !  2005-01  (C. Ethe) Add the KPP closure scheme
+   !!             -   !  2005-11  (G. Madec)  Reorganisation of tra and dyn calls
+   !!             -   !  2006-01  (L. Debreu, C. Mazauric)  Agrif implementation
+   !!             -   !  2006-07  (S. Masson)  restart using iom
+   !!            3.2  !  2009-02  (G. Madec, R. Benshila)  reintroduicing z*-coordinate
+   !!             -   !  2009-06  (S. Masson, G. Madec)  TKE restart compatible with key_cpl
+   !!            3.3  !  2010-05  (K. Mogensen, A. Weaver, M. Martin, D. Lea) Assimilation interface
+   !!             -   !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA
+   !!            3.4  !  2011-04  (G. Madec, C. Ethe) Merge of dtatem and dtasal
+   !!            3.6  !  2012-07  (J. Simeon, G. Madec. C. Ethe)  Online coarsening of outputs
+   !!            3.6  !  2014-04  (F. Roquet, G. Madec) New equations of state
+   !!            3.6  !  2014-10  (E. Clementi, P. Oddo) Add Qiao vertical mixing in case of waves
+   !!            3.7  !  2014-10  (G. Madec)  LDF simplication 
+   !!             -   !  2014-12  (G. Madec) remove KPP scheme
+   !!             -   !  2015-11  (J. Chanut) free surface simplification
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   stp             : OPA system time-stepping
+   !!----------------------------------------------------------------------
+   USE step_oce         ! time stepping definition modules
+   !
+   USE iom              ! xIOs server
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   stp   ! called by nemogcm.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: step.F90 7753 2017-03-03 11:46:59Z mocavero $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+#if defined key_agrif
+   RECURSIVE SUBROUTINE stp( )
+      INTEGER             ::   kstp   ! ocean time-step index
+#else
+   SUBROUTINE stp( kstp )
+      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
+#endif
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE stp  ***
+      !!
+      !! ** Purpose : - Time stepping of OPA (momentum and active tracer eqs.)
+      !!              - Time stepping of LIM (dynamic and thermodynamic eqs.)
+      !!              - Tme stepping  of TRC (passive tracer eqs.)
+      !!
+      !! ** Method  : -1- Update forcings and data
+      !!              -2- Update ocean physics
+      !!              -3- Compute the t and s trends
+      !!              -4- Update t and s
+      !!              -5- Compute the momentum trends
+      !!              -6- Update the horizontal velocity
+      !!              -7- Compute the diagnostics variables (rd,N2, hdiv,w)
+      !!              -8- Outputs and diagnostics
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji,jj,jk ! dummy loop indice
+      INTEGER ::   indic    ! error indicator if < 0
+      INTEGER ::   kcall    ! optional integer argument (dom_vvl_sf_nxt)
+      !! ---------------------------------------------------------------------
+#if defined key_agrif
+      kstp = nit000 + Agrif_Nb_Step()
+      IF( lk_agrif_debug ) THEN
+         IF( Agrif_Root() .and. lwp)   WRITE(*,*) '---'
+         IF(lwp)   WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint()
+      ENDIF
+      IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
+# if defined key_iomput
+      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
+# endif
+#endif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! update I/O and calendar 
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                             indic = 0                ! reset to no error condition
+                             
+      IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS)
+                             CALL iom_init(      cxios_context          )  ! for model grid (including passible AGRIF zoom)
+         IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid
+      ENDIF
+      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
+                             CALL iom_setkt( kstp - nit000 + 1,      cxios_context          )   ! tell IOM we are at time step kstp
+      IF( ln_crs         )   CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" )   ! tell IOM we are at time step kstp
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Update external forcing (tides, open boundaries, and surface boundary condition (including sea-ice)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( ln_tide    )   CALL sbc_tide( kstp )                   ! update tide potential
+      IF( ln_apr_dyn )   CALL sbc_apr ( kstp )                   ! atmospheric pressure (NB: call before bdy_dta which needs ssh_ib) 
+      IF( ln_bdy     )   CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries
+                         CALL sbc     ( kstp )                   ! Sea Boundary Condition (including sea-ice)
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Update stochastic parameters and random T/S fluctuations
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      IF( ln_sto_eos ) CALL sto_par( kstp )          ! Stochastic parameters
+      IF( ln_sto_eos ) CALL sto_pts( tsn  )          ! Random T/S fluctuations
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Ocean physics update                (ua, va, tsa used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !  THERMODYNAMICS
+                         CALL eos_rab( tsb, rab_b )       ! before local thermal/haline expension ratio at T-points
+                         CALL eos_rab( tsn, rab_n )       ! now    local thermal/haline expension ratio at T-points
+                         CALL bn2    ( tsb, rab_b, rn2b ) ! before Brunt-Vaisala frequency
+                         CALL bn2    ( tsn, rab_n, rn2  ) ! now    Brunt-Vaisala frequency
+
+      !
+      !  VERTICAL PHYSICS
+                         CALL zdf_bfr( kstp )         ! bottom friction (if quadratic)
+      !                                               ! Vertical eddy viscosity and diffusivity coefficients
+      IF( lk_zdfric  )   CALL zdf_ric ( kstp )             ! Richardson number dependent Kz
+      IF( lk_zdftke  )   CALL zdf_tke ( kstp )             ! TKE closure scheme for Kz
+      IF( lk_zdfgls  )   CALL zdf_gls ( kstp )             ! GLS closure scheme for Kz
+      IF( ln_zdfqiao )   CALL zdf_qiao( kstp )             ! Qiao vertical mixing 
+      !
+      IF( lk_zdfcst  ) THEN                                ! Constant Kz (reset avt, avm[uv] to the background value)
+         avt (:,:,:) = rn_avt0 * wmask (:,:,:)
+         avmu(:,:,:) = rn_avm0 * wumask(:,:,:)
+         avmv(:,:,:) = rn_avm0 * wvmask(:,:,:)
+      ENDIF
+
+      IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths
+         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2._wp * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO
+      ENDIF
+      IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
+
+      IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
+
+      IF( lk_zdfddm  )   CALL zdf_ddm( kstp )         ! double diffusive mixing
+
+                         CALL zdf_mxl( kstp )         ! mixed layer depth
+
+                                                      ! write TKE or GLS information in the restart file
+      IF( lrst_oce .AND. lk_zdftke )   CALL tke_rst( kstp, 'WRITE' )
+      IF( lrst_oce .AND. lk_zdfgls )   CALL gls_rst( kstp, 'WRITE' )
+      !
+      !  LATERAL  PHYSICS
+      !
+      IF( l_ldfslp ) THEN                             ! slope of lateral mixing
+                         CALL eos( tsb, rhd, gdept_0(:,:,:) )               ! before in situ density
+
+         IF( ln_zps .AND. .NOT. ln_isfcav)                               &
+            &            CALL zps_hde    ( kstp, jpts, tsb, gtsu, gtsv,  &  ! Partial steps: before horizontal gradient
+            &                                          rhd, gru , grv    )  ! of t, s, rd at the last ocean level
+
+         IF( ln_zps .AND.       ln_isfcav)                               &
+            &            CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv, gtui, gtvi,  &  ! Partial steps for top cell (ISF)
+            &                                          rhd, gru , grv , grui, grvi   )  ! of t, s, rd at the first ocean level
+         IF( ln_traldf_triad ) THEN 
+                         CALL ldf_slp_triad( kstp )                       ! before slope for triad operator
+         ELSE     
+                         CALL ldf_slp     ( kstp, rhd, rn2b )             ! before slope for standard operator
+         ENDIF
+      ENDIF
+      !                                                                   ! eddy diffusivity coeff.
+      IF( l_ldftra_time .OR. l_ldfeiv_time )   CALL ldf_tra( kstp )       !       and/or eiv coeff.
+      IF( l_ldfdyn_time                    )   CALL ldf_dyn( kstp )       ! eddy viscosity coeff. 
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      !  Ocean dynamics : hdiv, ssh, e3, u, v, w
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+                            CALL ssh_nxt       ( kstp )  ! after ssh (includes call to div_hor)
+      IF(.NOT.ln_linssh )   CALL dom_vvl_sf_nxt( kstp )  ! after vertical scale factors 
+                            CALL wzv           ( kstp )  ! now cross-level velocity 
+                            CALL eos    ( tsn, rhd, rhop, gdept_n(:,:,:) )  ! now in situ density for hpg computation
+                            
+!!jc: fs simplification
+!!jc: lines below are useless if ln_linssh=F. Keep them here (which maintains a bug if ln_linssh=T and ln_zps=T, cf ticket #1636) 
+!!                                         but ensures reproductible results
+!!                                         with previous versions using split-explicit free surface          
+            IF( ln_zps .AND. .NOT. ln_isfcav )                               &
+               &            CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,   &  ! Partial steps: before horizontal gradient
+               &                                          rhd, gru , grv     )  ! of t, s, rd at the last ocean level
+            IF( ln_zps .AND.       ln_isfcav )                                          &
+               &            CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, gtui, gtvi,  &  ! Partial steps for top cell (ISF)
+               &                                          rhd, gru , grv , grui, grvi   )  ! of t, s, rd at the first ocean level
+!!jc: fs simplification
+                            
+                         ua(:,:,:) = 0._wp            ! set dynamics trends to zero
+                         va(:,:,:) = 0._wp
+
+      IF(  lk_asminc .AND. ln_asmiau .AND. ln_dyninc )   &
+               &         CALL dyn_asm_inc   ( kstp )  ! apply dynamics assimilation increment
+      IF( ln_bdy     )   CALL bdy_dyn3d_dmp ( kstp )  ! bdy damping trends
+#if defined key_agrif
+      IF(.NOT. Agrif_Root())  & 
+               &         CALL Agrif_Sponge_dyn        ! momentum sponge
+#endif
+                         CALL dyn_adv       ( kstp )  ! advection (vector or flux form)
+                         CALL dyn_vor       ( kstp )  ! vorticity term including Coriolis
+                         CALL dyn_ldf       ( kstp )  ! lateral mixing
+                         CALL dyn_hpg       ( kstp )  ! horizontal gradient of Hydrostatic pressure
+                         CALL dyn_spg       ( kstp )  ! surface pressure gradient
+
+                                                      ! With split-explicit free surface, since now transports have been updated and ssha as well
+      IF( ln_dynspg_ts ) THEN                         ! vertical scale factors and vertical velocity need to be updated
+                            CALL div_hor    ( kstp )              ! Horizontal divergence  (2nd call in time-split case)
+         IF(.NOT.ln_linssh) CALL dom_vvl_sf_nxt( kstp, kcall=2 )  ! after vertical scale factors (update depth average component)
+                            CALL wzv        ( kstp )              ! now cross-level velocity 
+      ENDIF
+
+                         CALL dyn_bfr       ( kstp )  ! bottom friction
+                         CALL dyn_zdf       ( kstp )  ! vertical diffusion
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! cool skin
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<      
+      IF ( ln_diurnal )  CALL stp_diurnal( kstp )
+      
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! diagnostics and outputs             (ua, va, tsa used as workspace)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_floats  )   CALL flo_stp( kstp )         ! drifting Floats
+      IF( nn_diacfl == 1 )   CALL dia_cfl( kstp )         ! Courant number diagnostics
+      IF( lk_diahth  )   CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth)
+      IF( lk_diadct  )   CALL dia_dct( kstp )         ! Transports
+                         CALL dia_ar5( kstp )         ! ar5 diag
+      IF( lk_diaharm )   CALL dia_harm( kstp )        ! Tidal harmonic analysis
+      ! NB - new harmonic analysis 
+      IF( lk_diaharm_fast )                           &
+            &            CALL dia_harm_fast( kstp )   ! Tidal harmonic analysis - restart and faster version
+      ! END NB
+                         CALL dia_wri( kstp )         ! ocean model: outputs
+      !
+      IF( ln_crs     )   CALL crs_fld       ( kstp )  ! ocean model: online field coarsening & output
+      
+#if defined key_top
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Passive Tracer Model
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL trc_stp       ( kstp )  ! time-stepping
+#endif
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Active tracers                              
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         tsa(:,:,:,:) = 0._wp         ! set tracer trends to zero
+
+      IF(  lk_asminc .AND. ln_asmiau .AND. &
+         & ln_trainc )   CALL tra_asm_inc   ( kstp )  ! apply tracer assimilation increment
+                         CALL tra_sbc       ( kstp )  ! surface boundary condition
+      IF( ln_traqsr  )   CALL tra_qsr       ( kstp )  ! penetrative solar radiation qsr
+      IF( ln_trabbc  )   CALL tra_bbc       ( kstp )  ! bottom heat flux
+      IF( lk_trabbl  )   CALL tra_bbl       ( kstp )  ! advective (and/or diffusive) bottom boundary layer scheme
+      IF( ln_tradmp  )   CALL tra_dmp       ( kstp )  ! internal damping trends
+      IF( ln_bdy     )   CALL bdy_tra_dmp   ( kstp )  ! bdy damping trends
+#if defined key_agrif
+      IF(.NOT. Agrif_Root())  & 
+               &         CALL Agrif_Sponge_tra        ! tracers sponge
+#endif
+                         CALL tra_adv       ( kstp )  ! horizontal & vertical advection
+                         CALL tra_ldf       ( kstp )  ! lateral mixing
+
+!!gm : why CALL to dia_ptr has been moved here??? (use trends info?)
+      IF( ln_diaptr  )   CALL dia_ptr                 ! Poleward adv/ldf TRansports diagnostics
+!!gm
+                         CALL tra_zdf       ( kstp )  ! vertical mixing and after tracer fields
+      IF( ln_zdfnpc  )   CALL tra_npc       ( kstp )  ! update after fields by non-penetrative convection
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Set boundary conditions and Swap
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+!!jc1: For agrif, it would be much better to finalize tracers/momentum here (e.g. bdy conditions) and move the swap 
+!!    (and time filtering) after Agrif update. Then restart would be done after and would contain updated fields. 
+!!    If so: 
+!!    (i) no need to call agrif update at initialization time
+!!    (ii) no need to update "before" fields 
+!!
+!!    Apart from creating new tra_swp/dyn_swp routines, this however: 
+!!    (i) makes boundary conditions at initialization time computed from updated fields which is not the case between 
+!!    two restarts => restartability issue. One can circumvent this, maybe, by assuming "interface separation", 
+!!    e.g. a shift of the feedback interface inside child domain. 
+!!    (ii) requires that all restart outputs of updated variables by agrif (e.g. passive tracers/tke/barotropic arrays) are done at the same
+!!    place.
+!! 
+!!jc2: dynnxt must be the latest call. e3t_b are indeed updated in that routine
+                         CALL tra_nxt       ( kstp )  ! finalize (bcs) tracer fields at next time step and swap
+                         CALL dyn_nxt       ( kstp )  ! finalize (bcs) velocities at next time step and swap
+                         CALL ssh_swp       ( kstp )  ! swap of sea surface height
+      IF(.NOT.ln_linssh) CALL dom_vvl_sf_swp( kstp )  ! swap of vertical scale factors
+      !
+      IF( ln_diahsb        )   CALL dia_hsb( kstp )         ! - ML - global conservation diagnostics
+
+!!gm : This does not only concern the dynamics ==>>> add a new title
+!!gm2: why ouput restart before AGRIF update?
+!!
+!!jc: That would be better, but see comment above
+!!
+      IF( lrst_oce         )   CALL rst_write    ( kstp )   ! write output ocean restart file
+      IF( ln_sto_eos       )   CALL sto_rst_write( kstp )   ! write restart file for stochastic parameters
+
+#if defined key_agrif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! AGRIF
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<      
+                         CALL Agrif_Integrate_ChildGrids( stp )  
+
+      IF( Agrif_NbStepint() == 0 ) THEN               ! AGRIF Update 
+!!jc in fact update is useless at last time step, but do it for global diagnostics
+                         CALL Agrif_Update_Tra()      ! Update active tracers
+                         CALL Agrif_Update_Dyn()      ! Update momentum
+      ENDIF
+#endif
+      IF( ln_diaobs  )   CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Control
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL stp_ctl       ( kstp, indic )
+      IF( indic < 0  ) THEN
+                         CALL ctl_stop( 'step: indic < 0' )
+                         CALL dia_wri_state( 'output.abort', kstp )
+      ENDIF
+!#if defined key_harm_ana
+!--- NB Restart for the tidal harmonic analysis
+!      IF( ln_harm_ana_store   )   CALL harm_ana( kstp )        ! Harmonic analysis of tides 
+!--- END NB -----------------------------------
+!# endif
+      IF( kstp == nit000 ) THEN
+                 CALL iom_close( numror )     ! close input  ocean restart file
+         IF(lwm) CALL FLUSH    ( numond )     ! flush output namelist oce
+         IF(lwm.AND.numoni /= -1 )   &
+            &    CALL FLUSH    ( numoni )     ! flush output namelist ice (if exist)
+      ENDIF
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Coupled mode
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+!!gm why lk_oasis and not lk_cpl ????
+      IF( lk_oasis   )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
+      !
+#if defined key_iomput
+      IF( kstp == nitend .OR. indic < 0 ) THEN 
+                      CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
+         IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) ! 
+      ENDIF
+#endif
+      !
+      IF( nn_timing == 1 .AND.  kstp == nit000  )   CALL timing_reset
+      !
+   END SUBROUTINE stp
+   
+END MODULE step
diff --git a/MY_SRC/step_oce.F90 b/MY_SRC/step_oce.F90
new file mode 100755
index 0000000..d4e0cbc
--- /dev/null
+++ b/MY_SRC/step_oce.F90
@@ -0,0 +1,127 @@
+MODULE step_oce
+   !!======================================================================
+   !!                       ***  MODULE step_oce  ***
+   !! Ocean time-stepping : module used in both initialisation phase and time stepping
+   !!======================================================================
+   !! History :   3.3  !  2010-08  (C. Ethe)  Original code - reorganisation of the initial phase
+   !!             3.7  !  2014-01  (G. Madec) LDF simplication 
+   !!----------------------------------------------------------------------
+   USE oce              ! ocean dynamics and tracers variables
+   USE dom_oce          ! ocean space and time domain variables
+   USE zdf_oce          ! ocean vertical physics variables
+
+   USE daymod           ! calendar                         (day     routine)
+
+   USE sbc_oce          ! surface boundary condition: ocean
+   USE sbcmod           ! surface boundary condition       (sbc     routine)
+   USE sbcrnf           ! surface boundary condition: runoff variables
+   USE sbccpl           ! surface boundary condition: coupled formulation (call send at end of step)
+   USE sbcapr           ! surface boundary condition: atmospheric pressure
+   USE sbctide          ! Tide initialisation
+   USE sbcwave          ! Wave intialisation
+
+   USE traqsr           ! solar radiation penetration      (tra_qsr routine)
+   USE trasbc           ! surface boundary condition       (tra_sbc routine)
+   USE trabbc           ! bottom boundary condition        (tra_bbc routine)
+   USE trabbl           ! bottom boundary layer            (tra_bbl routine)
+   USE tradmp           ! internal damping                 (tra_dmp routine)
+   USE traadv           ! advection scheme control     (tra_adv_ctl routine)
+   USE traldf           ! lateral mixing                   (tra_ldf routine)
+   USE trazdf           ! vertical mixing                  (tra_zdf routine)
+   USE tranxt           ! time-stepping                    (tra_nxt routine)
+   USE tranpc           ! non-penetrative convection       (tra_npc routine)
+
+   USE eosbn2           ! equation of state                (eos_bn2 routine)
+
+   USE divhor           ! horizontal divergence            (div_hor routine)
+   USE dynadv           ! advection                        (dyn_adv routine)
+   USE dynbfr           ! Bottom friction terms            (dyn_bfr routine)
+   USE dynvor           ! vorticity term                   (dyn_vor routine)
+   USE dynhpg           ! hydrostatic pressure grad.       (dyn_hpg routine)
+   USE dynldf           ! lateral momentum diffusion       (dyn_ldf routine)
+   USE dynzdf           ! vertical diffusion               (dyn_zdf routine)
+   USE dynspg           ! surface pressure gradient        (dyn_spg routine)
+
+   USE dynnxt           ! time-stepping                    (dyn_nxt routine)
+
+   USE stopar           ! Stochastic parametrization       (sto_par routine)
+   USE stopts 
+
+   USE bdy_oce    , ONLY: ln_bdy
+   USE bdydta           ! open boundary condition data     (bdy_dta routine)
+   USE bdytra           ! bdy cond. for tracers            (bdy_tra routine)
+   USE bdydyn3d         ! bdy cond. for baroclinic vel.  (bdy_dyn3d routine)
+
+   USE sshwzv           ! vertical velocity and ssh        (ssh_nxt routine)
+   !                                                       (ssh_swp routine)
+   !                                                       (wzv     routine)
+   USE domvvl           ! variable vertical scale factors  (dom_vvl_sf_nxt routine)
+   !                                                       (dom_vvl_sf_swp routine)
+
+   USE ldfslp           ! iso-neutral slopes               (ldf_slp routine)
+   USE ldfdyn           ! lateral eddy viscosity coef.     (ldf_dyn routine)
+   USE ldftra           ! lateral eddy diffusive coef.     (ldf_tra routine)
+
+   USE zdftmx           ! tide-induced vertical mixing     (zdf_tmx routine)
+   USE zdfbfr           ! bottom friction                  (zdf_bfr routine)
+   USE zdftke           ! TKE vertical mixing              (zdf_tke routine)
+   USE zdfgls           ! GLS vertical mixing              (zdf_gls routine)
+   USE zdfddm           ! double diffusion mixing          (zdf_ddm routine)
+   USE zdfevd           ! enhanced vertical diffusion      (zdf_evd routine)
+   USE zdfric           ! Richardson vertical mixing       (zdf_ric routine)
+   USE zdfmxl           ! Mixed-layer depth                (zdf_mxl routine)
+   USE zdfqiao          !Qiao module wave induced mixing   (zdf_qiao routine)
+
+   USE step_diu        ! Time stepping for diurnal sst
+   USE diurnal_bulk    ! diurnal SST bulk routines  (diurnal_sst_takaya routine) 
+   USE cool_skin       ! diurnal cool skin correction (diurnal_sst_coolskin routine)   
+   USE sbc_oce         ! surface fluxes  
+   
+   USE zpshde           ! partial step: hor. derivative     (zps_hde routine)
+
+   USE diawri           ! Standard run outputs             (dia_wri routine)
+   USE diaptr           ! poleward transports              (dia_ptr routine)
+   USE diadct           ! sections transports              (dia_dct routine)
+   USE diaar5           ! AR5 diagnosics                   (dia_ar5 routine)
+   USE diahth           ! thermocline depth                (dia_hth routine)
+   USE diahsb           ! heat, salt and volume budgets    (dia_hsb routine)
+   USE diaharm
+!--- NB for restart hamonic analysis
+   USE diaharm_fast     ! harmonic analysis of tides (harm_ana routine) 
+!--- END NB -----------------------------------
+   USE diacfl
+   USE flo_oce          ! floats variables
+   USE floats           ! floats computation               (flo_stp routine)
+
+   USE crsfld           ! Standard output on coarse grid   (crs_fld routine)
+
+   USE asminc           ! assimilation increments      (tra_asm_inc routine)
+   !                                                   (dyn_asm_inc routine)
+   USE asmbkg
+   USE stpctl           ! time stepping control            (stp_ctl routine)
+   USE restart          ! ocean restart                    (rst_wri routine)
+   USE prtctl           ! Print control                    (prt_ctl routine)
+
+   USE diaobs           ! Observation operator
+
+   USE in_out_manager   ! I/O manager
+   USE iom              !
+   USE lbclnk
+   USE timing           ! Timing
+
+#if defined key_iomput
+   USE xios
+#endif
+#if defined key_agrif
+   USE agrif_opa_sponge ! Momemtum and tracers sponges
+   USE agrif_opa_update ! Update (2-way nesting)
+#endif
+#if defined key_top
+   USE trcstp           ! passive tracer time-stepping      (trc_stp routine)
+#endif
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! $Id: step_oce.F90 7646 2017-02-06 09:25:03Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!======================================================================
+END MODULE step_oce
diff --git a/MY_SRC/tide_FES14.h90 b/MY_SRC/tide_FES14.h90
new file mode 100755
index 0000000..3998e80
--- /dev/null
+++ b/MY_SRC/tide_FES14.h90
@@ -0,0 +1,114 @@
+   !!----------------------------------------------------------------------
+   !! History :  3.2  !  2007  (O. Le Galloudec)  Original code
+   !!----------------------------------------------------------------------
+   !! TIDES ADDED  ! 2017 (Nico Bruneau) 
+   !! Following this document that seems to match implemented code 
+   !!    https://docs.lib.noaa.gov/rescue/cgs_specpubs/QB275U35no981924.pdf
+   !! see page 189 for some proposed values
+   !!
+   !! The convention which seems to have been chosen is the Shureman one and 
+   !! not the Cartwright and Tayer (1971)
+   !! This is probably due to the fact the Schureman has a solar calendar 
+   !! while Cartwright and Tayer is based on a lunar calendar
+   !!
+   !! Therefore the coefficient are not the Doodson number but the one 
+   !! defined by Schureman. For example :
+   !! M2 : Doodson   : 2  0 0 0 0 0
+   !!      Schureman : 2 -2 2 0 0 0
+   !!
+   !! Components 1-34 are for FES 2014
+   !! Components >= 35 are the one that were initially present in NEMO and not in FES14
+   !!                  keep in mind than equitide coefficient have been ajusted for the
+   !!                  34 FES 2014 constituents
+   !! 
+   !! The different coefficient are as follows
+   !!   - nt   = T  = Number of Julian centuries (36625 days) from Greenwich mean noon on December 31, 1899.
+   !!               = Hour angle of mean sun
+   !!   - ns   = s  = mean longitude of the moon
+   !!   - nh   = h  = mean longitude of the sun
+   !!   - np   = p  = mean longitude of the lunar perigee
+   !!   - np1  = p1 = mean longitude of the solar perigee
+   !!   - shift appears in table as a bias in degree
+   !!   - nksi Coefficient for the longitude in moon's orbit of lunar intersection
+   !!   - nu0 Coefficient for the right ascension of lunar intersection
+   !!   - nu1 Coefficient for the term in argument of lunisolar constituent K1
+   !!   - nu2 Coefficient for the term in argument of lunisolar constituent K2
+   !!   - R = ??? 
+   !!   - Formula = Nodal factor function; see the table of Schureman. Implemented in tide_mod.F90 
+   !! 
+   !! The equitide parameter seems to be the equilibrium tide amplitude corrected
+   !! with the C_n^m coefficient: see Cartwright and Tayer (1971) equation 12 
+   !! and Table 2
+   !! As an example in their Table 4c (p66), M2 (200000) has an amplitude of 
+   !! around 0.63186 m
+   !! Table 2, give us a correction of m = 2, n = 2 (semi-diurnal)
+   !! 0.63186*3*sqrt( 5 / 96 / pi ) = 0.24407 
+   !! very close to the one define originally here : 0.242297
+   !! Third order terms are neglected
+   !!
+   !! So to correct (to match what is implemented in sbctide.F90 - take care CT71 uses co-latitude):
+   !!    - long wave : Amplitude from CT71 * [ -1   * sqrt( 5 /  4 / pi ) ]
+   !!    - diurnal   : Amplitude from CT71 * [ -3/2 * sqrt( 5 / 24 / pi ) ]
+   !!    - semi-diur : Amplitude from CT71 * [  3   * sqrt( 5 / 96 / pi ) ]
+   !!
+   !! ATTENTION: convention seems to be to have a positive coefficient and a 180 shift to 
+   !!            represent negative value. to be confirmed though.
+   !!
+   !! All equtide were computed using the last epocs from Cartwright and Tayer (1971) multiply by
+   !! the corresponding coefficient of their table 2
+   !! 
+   !! nutide is used to compute tide potential - it uses a different formulation depending of nutide
+   !! see sbctide.F90 in function tide_init_potential
+   !!
+   !! Some random note
+   !! in cnes fes tool:
+   !!        Msf has nksi = 2 and nnu0 = -2 which is reverse from Schureman (I kept the Schureman one)
+   !!
+   !!----------------------------------------------------------------------
+   !
+   !             !! name_tide , equitide , nutide , nt , ns , nh , np , np1 , shift , nksi , nnu0 , nnu1 , nnu2 , R , formula !!
+   !             !!           !          !        !    !    !    !    !     !       !      !      !      !      !   !         !!
+   !
+   ! Long Period Tides
+   Wave( 1) = tide(  'SA'     , 0.003103 ,    0   ,  0 ,  0 ,  1 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )
+   Wave( 2) = tide(  'SSA'    , 0.019523 ,    0   ,  0 ,  0 ,  2 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,    0    )
+   Wave( 3) = tide(  'MM'     , 0.022191 ,    0   ,  0 ,  1 ,  0 , -1 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,   73    )
+   Wave( 4) = tide(  'MF'     , 0.042023 ,    0   ,  0 ,  2 ,  0 ,  0 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
+   Wave( 5) = tide(  'MTM'    , 0.008042 ,    0   ,  0 ,  3 ,  0 , -1 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
+   Wave( 6) = tide(  'MSF'    , 0.003671 ,    0   ,  0 ,  2 , -2 ,  0 ,  0  ,    0  , -2   ,  2   ,  0   ,  0   , 0 ,   78    )
+   Wave( 7) = tide(  'MSQM'   , 0.001293 ,    0   ,  0 ,  4 , -2 ,  0 ,  0  ,    0  , -2   ,  0   ,  0   ,  0   , 0 ,   74    )
+   !
+   ! Diurnal Tides
+   Wave( 8) = tide(  'K1'     ,-0.142442 ,    1   ,  1 ,  0 ,  1 ,  0 ,  0  ,  -90  ,  0   ,  0   , -1   ,  0   , 0 ,   227   )
+   Wave( 9) = tide(  'O1'     , 0.101277 ,    1   ,  1 , -2 ,  1 ,  0 ,  0  ,  +90  ,  2   , -1   ,  0   ,  0   , 0 ,    75   )
+   Wave(10) = tide(  'Q1'     , 0.019383 ,    1   ,  1 , -3 ,  1 ,  1 ,  0  ,  +90  ,  2   , -1   ,  0   ,  0   , 0 ,    75   )
+   Wave(11) = tide(  'P1'     , 0.047145 ,    1   ,  1 ,  0 , -1 ,  0 ,  0  ,  +90  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
+   Wave(12) = tide(  'S1'     ,-0.001116 ,    1   ,  1 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
+   Wave(13) = tide(  'J1'     ,-0.007961 ,    1   ,  1 ,  1 ,  1 , -1 ,  0  ,  -90  ,  0   , -1   ,  0   ,  0   , 0 ,    76   )
+   !
+   ! Semi-Diurnal Tides
+   Wave(14) = tide(  'M2'     , 0.244083 ,    2   ,  2 , -2 ,  2 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   Wave(15) = tide(  'N2'     , 0.046720 ,    2   ,  2 , -3 ,  2 ,  1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   Wave(16) = tide(  'S2'     , 0.113565 ,    2   ,  2 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
+   Wave(17) = tide(  'K2'     , 0.030875 ,    2   ,  2 ,  0 ,  2 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   , -2   , 0 ,   235   )
+   Wave(18) = tide(  'L2'     , 0.006903 ,    2   ,  2 , -1 ,  2 , -1 ,  0  , +180  ,  2   , -2   ,  0   ,  0   , 0 ,   215   )
+   Wave(19) = tide(  'T2'     , 0.006644 ,    2   ,  2 ,  0 , -1 ,  0 ,  1  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
+   Wave(20) = tide(  'R2'     , 0.000950 ,    2   ,  2 ,  0 ,  1 ,  0 , -1  , +180  ,  2   ,  0   ,  0   ,  0   , 0 ,     0   )
+   !
+   Wave(21) = tide(  'MU2'    , 0.007451 ,    2   ,  2 , -4 ,  4 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   Wave(22) = tide(  'NU2'    , 0.008873 ,    2   ,  2 , -3 ,  4 , -1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   Wave(23) = tide( '2N2'     , 0.006176 ,    2   ,  2 , -4 ,  2 ,  2 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   Wave(24) = tide(  'MKS2'   , 0.000000 ,    2   ,  2 , -2 ,  4 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   , -2   , 0 ,     4   )
+   Wave(25) = tide(  'LA2'    , 0.001800 ,    2   ,  2 , -1 ,  0 ,  1 ,  0  , +180  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   Wave(26) = tide(  'EPS2'   , 0.001796 ,    2   ,  2 , -5 ,  4 ,  1 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   !
+   ! Harmonic and others
+   Wave(27) = tide(  'M3'     , 0.000000 ,    3   ,  3 , -3 ,  3 ,  0 ,  0  ,    0  ,  3   , -3   ,  0   ,  0   , 0 ,   149   )
+   Wave(28) = tide(  'M4'     , 0.000000 ,    4   ,  4 , -4 ,  4 ,  0 ,  0  ,    0  ,  4   , -4   ,  0   ,  0   , 0 ,     1   )
+   Wave(29) = tide(  'M6'     , 0.000000 ,    6   ,  6 , -6 ,  6 ,  0 ,  0  ,    0  ,  6   , -6   ,  0   ,  0   , 0 ,    18   )
+   Wave(30) = tide(  'M8'     , 0.000000 ,    8   ,  8 , -8 ,  8 ,  0 ,  0  ,    0  ,  8   , -8   ,  0   ,  0   , 0 ,    20   )
+   Wave(31) = tide(  'N4'     , 0.000000 ,    4   ,  4 , -6 ,  4 ,  2 ,  0  ,    0  ,  4   , -4   ,  0   ,  0   , 0 ,     1   )
+   Wave(32) = tide(  'S4'     , 0.000000 ,    4   ,  4 ,  0 ,  0 ,  0 ,  0  ,    0  ,  0   ,  0   ,  0   ,  0   , 0 ,     0   )
+   Wave(33) = tide(  'MN4'    , 0.000000 ,    4   ,  4 , -5 ,  4 ,  1 ,  0  ,    0  ,  4   , -4   ,  0   ,  0   , 0 ,     1   )
+   Wave(34) = tide(  'MS4'    , 0.000000 ,    4   ,  4 , -2 ,  2 ,  0 ,  0  ,    0  ,  2   , -2   ,  0   ,  0   , 0 ,    78   )
+   ! 
diff --git a/MY_SRC/tide_mod.F90 b/MY_SRC/tide_mod.F90
new file mode 100755
index 0000000..d14af9b
--- /dev/null
+++ b/MY_SRC/tide_mod.F90
@@ -0,0 +1,430 @@
+MODULE tide_mod
+   !!======================================================================
+   !!                       ***  MODULE  tide_mod  ***
+   !! Compute nodal modulations corrections and pulsations
+   !!======================================================================
+   !! History :  1.0  !  2007  (O. Le Galloudec)  Original code
+   !!----------------------------------------------------------------------
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constant
+   USE daymod         ! calendar
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tide_harmo       ! called by tideini and diaharm modules
+   PUBLIC   tide_init_Wave   ! called by tideini and diaharm modules
+
+!--- NB - extend number of constituents for tide
+# if defined key_FES14_tides
+   INTEGER, PUBLIC, PARAMETER ::   jpmax_harmo = 34   !: maximum number of harmonic
+# else
+   INTEGER, PUBLIC, PARAMETER ::   jpmax_harmo = 19   !: maximum number of harmonic
+# endif
+!--- END NB
+
+
+   TYPE, PUBLIC ::    tide
+      CHARACTER(LEN=4) ::   cname_tide
+      REAL(wp)         ::   equitide
+      INTEGER          ::   nutide
+      INTEGER          ::   nt, ns, nh, np, np1, shift
+      INTEGER          ::   nksi, nnu0, nnu1, nnu2, R
+      INTEGER          ::   nformula
+   END TYPE tide
+
+   TYPE(tide), PUBLIC, DIMENSION(jpmax_harmo) ::   Wave   !:
+
+   REAL(wp) ::   sh_T, sh_s, sh_h, sh_p, sh_p1             ! astronomic angles
+   REAL(wp) ::   sh_xi, sh_nu, sh_nuprim, sh_nusec, sh_R   !
+   REAL(wp) ::   sh_I, sh_x1ra, sh_N                       !
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , LOCEAN-IPSL (2010) 
+   !! $Id: tide_mod.F90 5215 2015-04-15 16:11:56Z nicolasmartin $ 
+   !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tide_init_Wave
+!! NB
+# if defined key_FES14_tides
+#     include "tide_FES14.h90"
+# else
+!! END NB
+#     include "tide.h90"
+# endif
+   END SUBROUTINE tide_init_Wave
+
+
+   SUBROUTINE tide_harmo( pomega, pvt, put , pcor, ktide ,kc)
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide            ! Indice of tidal constituents
+      INTEGER                , INTENT(in ) ::   kc               ! Total number of tidal constituents
+      REAL(wp), DIMENSION(kc), INTENT(out) ::   pomega           ! pulsation in radians/s
+      REAL(wp), DIMENSION(kc), INTENT(out) ::   pvt, put, pcor   !
+      !!----------------------------------------------------------------------
+      !
+      CALL astronomic_angle
+      CALL tide_pulse( pomega, ktide ,kc )
+      CALL tide_vuf  ( pvt, put, pcor, ktide ,kc )
+      !
+   END SUBROUTINE tide_harmo
+
+
+   SUBROUTINE astronomic_angle
+      !!----------------------------------------------------------------------
+      !!  tj is time elapsed since 1st January 1900, 0 hour, counted in julian
+      !!  century (e.g. time in days divide by 36525)
+      !!----------------------------------------------------------------------
+      REAL(wp) ::   cosI, p, q, t2, t4, sin2I, s2, tgI2, P1, sh_tgn2, at1, at2
+      REAL(wp) ::   zqy , zsy, zday, zdj, zhfrac
+      !!----------------------------------------------------------------------
+      !
+      zqy = AINT( (nyear-1901.)/4. )
+      zsy = nyear - 1900.
+      !
+      zdj  = dayjul( nyear, nmonth, nday )
+      zday = zdj + zqy - 1.
+      !
+      zhfrac = nsec_day / 3600.
+      !
+      !----------------------------------------------------------------------
+      !  Sh_n Longitude of ascending lunar node
+      !----------------------------------------------------------------------
+      sh_N=(259.1560564-19.328185764*zsy-.0529539336*zday-.0022064139*zhfrac)*rad
+      !----------------------------------------------------------------------
+      ! T mean solar angle (Greenwhich time)
+      !----------------------------------------------------------------------
+      sh_T=(180.+zhfrac*(360./24.))*rad
+      !----------------------------------------------------------------------
+      ! h mean solar Longitude
+      !----------------------------------------------------------------------
+      sh_h=(280.1895014-.238724988*zsy+.9856473288*zday+.0410686387*zhfrac)*rad
+      !----------------------------------------------------------------------
+      ! s mean lunar Longitude
+      !----------------------------------------------------------------------
+      sh_s=(277.0256206+129.38482032*zsy+13.176396768*zday+.549016532*zhfrac)*rad
+      !----------------------------------------------------------------------
+      ! p1 Longitude of solar perigee
+      !----------------------------------------------------------------------
+      sh_p1=(281.2208569+.01717836*zsy+.000047064*zday+.000001961*zhfrac)*rad
+      !----------------------------------------------------------------------
+      ! p Longitude of lunar perigee
+      !----------------------------------------------------------------------
+      sh_p=(334.3837214+40.66246584*zsy+.111404016*zday+.004641834*zhfrac)*rad
+
+      sh_N = MOD( sh_N ,2*rpi )
+      sh_s = MOD( sh_s ,2*rpi )
+      sh_h = MOD( sh_h, 2*rpi )
+      sh_p = MOD( sh_p, 2*rpi )
+      sh_p1= MOD( sh_p1,2*rpi )
+
+      cosI = 0.913694997 -0.035692561 *cos(sh_N)
+
+      sh_I = ACOS( cosI )
+
+      sin2I   = sin(sh_I)
+      sh_tgn2 = tan(sh_N/2.0)
+
+      at1=atan(1.01883*sh_tgn2)
+      at2=atan(0.64412*sh_tgn2)
+
+      sh_xi=-at1-at2+sh_N
+
+      IF( sh_N > rpi )   sh_xi=sh_xi-2.0*rpi
+
+      sh_nu = at1 - at2
+
+      !----------------------------------------------------------------------
+      ! For constituents l2 k1 k2
+      !----------------------------------------------------------------------
+
+      tgI2 = tan(sh_I/2.0)
+      P1   = sh_p-sh_xi
+
+      t2 = tgI2*tgI2
+      t4 = t2*t2
+      sh_x1ra = sqrt( 1.0-12.0*t2*cos(2.0*P1)+36.0*t4 )
+
+      p = sin(2.0*P1)
+      q = 1.0/(6.0*t2)-cos(2.0*P1)
+      sh_R = atan(p/q)
+
+      p = sin(2.0*sh_I)*sin(sh_nu)
+      q = sin(2.0*sh_I)*cos(sh_nu)+0.3347
+      sh_nuprim = atan(p/q)
+
+      s2 = sin(sh_I)*sin(sh_I)
+      p  = s2*sin(2.0*sh_nu)
+      q  = s2*cos(2.0*sh_nu)+0.0727
+      sh_nusec = 0.5*atan(p/q)
+      !
+   END SUBROUTINE astronomic_angle
+
+
+   SUBROUTINE tide_pulse( pomega, ktide ,kc )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE tide_pulse  ***
+      !!                      
+      !! ** Purpose : Compute tidal frequencies
+      !!----------------------------------------------------------------------
+      INTEGER                , INTENT(in ) ::   kc       ! Total number of tidal constituents
+      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide    ! Indice of tidal constituents
+      REAL(wp), DIMENSION(kc), INTENT(out) ::   pomega   ! pulsation in radians/s
+      !
+      INTEGER  ::   jh
+      REAL(wp) ::   zscale
+      REAL(wp) ::   zomega_T =  13149000.0_wp
+      REAL(wp) ::   zomega_s =    481267.892_wp
+      REAL(wp) ::   zomega_h =     36000.76892_wp
+      REAL(wp) ::   zomega_p =      4069.0322056_wp
+      REAL(wp) ::   zomega_n =      1934.1423972_wp
+      REAL(wp) ::   zomega_p1=         1.719175_wp
+      !!----------------------------------------------------------------------
+      !
+      zscale =  rad / ( 36525._wp * 86400._wp ) 
+      !
+      DO jh = 1, kc
+         pomega(jh) = (  zomega_T * Wave( ktide(jh) )%nT   &
+            &          + zomega_s * Wave( ktide(jh) )%ns   &
+            &          + zomega_h * Wave( ktide(jh) )%nh   &
+            &          + zomega_p * Wave( ktide(jh) )%np   &
+            &          + zomega_p1* Wave( ktide(jh) )%np1  ) * zscale
+      END DO
+      !
+   END SUBROUTINE tide_pulse
+
+
+   SUBROUTINE tide_vuf( pvt, put, pcor, ktide ,kc )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE tide_vuf  ***
+      !!                      
+      !! ** Purpose : Compute nodal modulation corrections
+      !!
+      !! ** Outputs : vt: Phase of tidal potential relative to Greenwich (radians)
+      !!              ut: Phase correction u due to nodal motion (radians)
+      !!              ft: Nodal correction factor
+      !!----------------------------------------------------------------------
+      INTEGER                , INTENT(in ) ::   kc               ! Total number of tidal constituents
+      INTEGER , DIMENSION(kc), INTENT(in ) ::   ktide            ! Indice of tidal constituents
+      REAL(wp), DIMENSION(kc), INTENT(out) ::   pvt, put, pcor   !
+      !
+      INTEGER ::   jh   ! dummy loop index
+      !!----------------------------------------------------------------------
+      !
+      DO jh = 1, kc
+         !  Phase of the tidal potential relative to the Greenwhich 
+         !  meridian (e.g. the position of the fictuous celestial body). Units are radian:
+         pvt(jh) = sh_T * Wave( ktide(jh) )%nT    &
+            &    + sh_s * Wave( ktide(jh) )%ns    &
+            &    + sh_h * Wave( ktide(jh) )%nh    &
+            &    + sh_p * Wave( ktide(jh) )%np    &
+            &    + sh_p1* Wave( ktide(jh) )%np1   &
+            &    +        Wave( ktide(jh) )%shift * rad
+         !
+         !  Phase correction u due to nodal motion. Units are radian:
+         put(jh) = sh_xi     * Wave( ktide(jh) )%nksi   &
+            &    + sh_nu     * Wave( ktide(jh) )%nnu0   &
+            &    + sh_nuprim * Wave( ktide(jh) )%nnu1   &
+            &    + sh_nusec  * Wave( ktide(jh) )%nnu2   &
+            &    + sh_R      * Wave( ktide(jh) )%R
+
+         !  Nodal correction factor:
+         pcor(jh) = nodal_factort( Wave( ktide(jh) )%nformula )
+      END DO
+      !
+   END SUBROUTINE tide_vuf
+
+
+   RECURSIVE FUNCTION nodal_factort( kformula ) RESULT( zf )
+      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kformula
+      !
+      REAL(wp) :: zf
+      REAL(wp) :: zs, zf1, zf2
+      !!----------------------------------------------------------------------
+      !
+      SELECT CASE( kformula )
+      !
+      CASE( 0 )                  !==  formule 0, solar waves
+         zf = 1.0
+         !
+      CASE( 1 )                  !==  formule 1, compound waves (78 x 78)
+         zf=nodal_factort(78)
+         zf = zf * zf
+         !
+      CASE ( 2 )                 !==  formule 2, compound waves (78 x 0)  ===  (78) 
+       zf1= nodal_factort(78)
+       zf = nodal_factort( 0)
+       zf = zf1 * zf
+       !
+      CASE ( 4 )                 !==  formule 4,  compound waves (78 x 235) 
+         zf1 = nodal_factort( 78)
+         zf  = nodal_factort(235)
+         zf  = zf1 * zf
+         !
+      CASE ( 5 )                 !==  formule 5,  compound waves (78 *78 x 235)
+         zf1 = nodal_factort( 78)
+         zf  = nodal_factort(235)
+         zf  = zf * zf1 * zf1
+         !
+      CASE ( 6 )                 !==  formule 6,  compound waves (78 *78 x 0)
+         zf1 = nodal_factort(78)
+         zf  = nodal_factort( 0)
+         zf  = zf * zf1 * zf1 
+         !
+      CASE( 7 )                  !==  formule 7, compound waves (75 x 75)
+         zf = nodal_factort(75)
+         zf = zf * zf
+         !
+      CASE( 8 )                  !==  formule 8,  compound waves (78 x 0 x 235)
+         zf  = nodal_factort( 78)
+         zf1 = nodal_factort(  0)
+         zf2 = nodal_factort(235)
+         zf  = zf * zf1 * zf2
+         !
+      CASE( 9 )                  !==  formule 9,  compound waves (78 x 0 x 227)
+         zf  = nodal_factort( 78)
+         zf1 = nodal_factort(  0)
+         zf2 = nodal_factort(227)
+         zf  = zf * zf1 * zf2
+         !
+      CASE( 10 )                 !==  formule 10,  compound waves (78 x 227)
+         zf  = nodal_factort( 78)
+         zf1 = nodal_factort(227)
+         zf  = zf * zf1
+         !
+      CASE( 11 )                 !==  formule 11,  compound waves (75 x 0)
+!!gm bug???? zf 2 fois !
+         zf = nodal_factort(75)
+         zf = nodal_factort( 0)
+         zf = zf * zf1
+         !
+      CASE( 12 )                 !==  formule 12,  compound waves (78 x 78 x 78 x 0) 
+         zf1 = nodal_factort(78)
+         zf  = nodal_factort( 0)
+         zf  = zf * zf1 * zf1 * zf1
+         !
+      CASE( 13 )                 !==  formule 13, compound waves (78 x 75)
+         zf1 = nodal_factort(78)
+         zf  = nodal_factort(75)
+         zf  = zf * zf1
+         !
+      CASE( 14 )                 !==  formule 14, compound waves (235 x 0)  ===  (235)
+         zf  = nodal_factort(235)
+         zf1 = nodal_factort(  0)
+         zf  = zf * zf1
+         !
+      CASE( 15 )                 !==  formule 15, compound waves (235 x 75) 
+         zf  = nodal_factort(235)
+         zf1 = nodal_factort( 75)
+         zf  = zf * zf1
+         !
+      CASE( 16 )                 !==  formule 16, compound waves (78 x 0 x 0)  ===  (78)
+         zf  = nodal_factort(78)
+         zf1 = nodal_factort( 0)
+         zf  = zf * zf1 * zf1
+         !
+      CASE( 17 )                 !==  formule 17,  compound waves (227 x 0) 
+         zf1 = nodal_factort(227)
+         zf  = nodal_factort(  0)
+         zf  = zf * zf1
+         !
+      CASE( 18 )                 !==  formule 18,  compound waves (78 x 78 x 78 )
+         zf1 = nodal_factort(78)
+         zf  = zf1 * zf1 * zf1
+         !
+      CASE( 19 )                 !==  formule 19, compound waves (78 x 0 x 0 x 0)  ===  (78)
+!!gm bug2 ==>>>   here identical to formule 16,  a third multiplication by zf1 is missing
+         zf  = nodal_factort(78)
+         zf1 = nodal_factort( 0)
+         zf = zf * zf1 * zf1
+         !
+!--- NB 11/2017
+      CASE( 20 )                 !==  formule 20,  compound waves ( 78 x 78 x 78 x 78 )
+         zf1 = nodal_factort(78)
+         zf  = zf1 * zf1 * zf1 * zf1
+!--- END NB
+!
+      CASE( 73 )                 !==  formule 73
+         zs = sin(sh_I)
+         zf = (2./3.-zs*zs)/0.5021
+         !
+      CASE( 74 )                 !==  formule 74
+         zs = sin(sh_I)
+         zf = zs * zs / 0.1578
+         !
+      CASE( 75 )                 !==  formule 75
+         zs = cos(sh_I/2)
+         zf = sin(sh_I) * zs * zs / 0.3800
+         !
+      CASE( 76 )                 !==  formule 76
+         zf = sin(2*sh_I) / 0.7214
+         !
+      CASE( 77 )                 !==  formule 77
+         zs = sin(sh_I/2)
+         zf = sin(sh_I) * zs * zs / 0.0164
+         !
+      CASE( 78 )                 !==  formule 78
+         zs = cos(sh_I/2)
+         zf = zs * zs * zs * zs / 0.9154
+         !
+      CASE( 79 )                 !==  formule 79
+         zs = sin(sh_I)
+         zf = zs * zs / 0.1565
+         !
+      CASE( 144 )                !==  formule 144
+         zs = sin(sh_I/2)
+         zf = ( 1-10*zs*zs+15*zs*zs*zs*zs ) * cos(sh_I/2) / 0.5873
+         !
+      CASE( 149 )                !==  formule 149
+         zs = cos(sh_I/2)
+         zf = zs*zs*zs*zs*zs*zs / 0.8758
+         !
+      CASE( 215 )                !==  formule 215
+         zs = cos(sh_I/2)
+         zf = zs*zs*zs*zs / 0.9154 * sh_x1ra
+         !
+      CASE( 227 )                !==  formule 227 
+         zs = sin(2*sh_I)
+         zf = sqrt( 0.8965*zs*zs+0.6001*zs*cos (sh_nu)+0.1006 )
+         !
+      CASE ( 235 )               !==  formule 235 
+         zs = sin(sh_I)
+         zf = sqrt( 19.0444*zs*zs*zs*zs + 2.7702*zs*zs*cos(2*sh_nu) + .0981 )
+         !
+      END SELECT
+      !
+   END FUNCTION nodal_factort
+
+
+   FUNCTION dayjul( kyr, kmonth, kday )
+      !!----------------------------------------------------------------------
+      !!  *** THIS ROUTINE COMPUTES THE JULIAN DAY (AS A REAL VARIABLE)
+      !!----------------------------------------------------------------------
+      INTEGER,INTENT(in) ::   kyr, kmonth, kday
+      !
+      INTEGER,DIMENSION(12) ::  idayt, idays
+      INTEGER  ::   inc, ji
+      REAL(wp) ::   dayjul, zyq
+      !
+      DATA idayt/0.,31.,59.,90.,120.,151.,181.,212.,243.,273.,304.,334./
+      !!----------------------------------------------------------------------
+      !
+      idays(1) = 0.
+      idays(2) = 31.
+      inc = 0.
+      zyq = MOD( kyr-1900. , 4. )
+      IF( zyq == 0.)   inc = 1.
+      DO ji = 3, 12
+         idays(ji)=idayt(ji)+inc
+      END DO
+      dayjul = idays(kmonth) + kday
+      !
+   END FUNCTION dayjul
+
+   !!======================================================================
+END MODULE tide_mod
diff --git a/MY_SRC/tideini.F90 b/MY_SRC/tideini.F90
new file mode 100755
index 0000000..7094de8
--- /dev/null
+++ b/MY_SRC/tideini.F90
@@ -0,0 +1,125 @@
+MODULE tideini
+   !!======================================================================
+   !!                       ***  MODULE  tideini  ***
+   !! Initialization of tidal forcing
+   !!======================================================================
+   !! History :  1.0  !  2007  (O. Le Galloudec)  Original code
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constant
+   USE daymod         ! calandar
+   USE tide_mod       ! 
+   !
+   USE in_out_manager ! I/O units
+   USE iom            ! xIOs server
+   USE ioipsl         ! NetCDF IPSL library
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PUBLIC
+
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   omega_tide   !:
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   v0tide       !:
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   utide        !:
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   ftide        !:
+
+   LOGICAL , PUBLIC ::   ln_tide         !:
+   LOGICAL , PUBLIC ::   ln_tide_pot     !:
+   LOGICAL , PUBLIC ::   ln_tide_ramp    !:
+   INTEGER , PUBLIC ::   nb_harmo        !:
+   INTEGER , PUBLIC ::   kt_tide         !:
+   REAL(wp), PUBLIC ::   rdttideramp     !:
+   ! NB - read love number from namelist
+   REAL(wp), PUBLIC ::   dn_love_number  !:
+   ! END NB
+   INTEGER , PUBLIC, ALLOCATABLE, DIMENSION(:) ::   ntide   !:
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.5 , NEMO Consortium (2013)
+   !! $Id: tideini.F90 7646 2017-02-06 09:25:03Z timgraham $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+   
+   SUBROUTINE tide_init
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tide_init  ***
+      !!----------------------------------------------------------------------      
+      INTEGER  :: ji, jk
+      CHARACTER(LEN=4), DIMENSION(jpmax_harmo) :: clname
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      !
+      ! NB - read love number from namelist
+      !NAMELIST/nam_tide/ln_tide, ln_tide_pot, ln_tide_ramp, rdttideramp, clname
+      NAMELIST/nam_tide/ln_tide, ln_tide_pot, ln_tide_ramp, rdttideramp, dn_love_number, clname
+      ! END NB
+      !!----------------------------------------------------------------------
+      !
+      ! Read Namelist nam_tide
+      REWIND( numnam_ref )              ! Namelist nam_tide in reference namelist : Tides
+      READ  ( numnam_ref, nam_tide, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist nam_tide in configuration namelist : Tides
+      READ  ( numnam_cfg, nam_tide, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'nam_tide in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, nam_tide )
+      !
+      IF (ln_tide) THEN
+         IF (lwp) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'tide_init : Initialization of the tidal components'
+            WRITE(numout,*) '~~~~~~~~~ '
+            WRITE(numout,*) '   Namelist nam_tide'
+            WRITE(numout,*) '              Use tidal components : ln_tide      = ', ln_tide
+            WRITE(numout,*) '      Apply astronomical potential : ln_tide_pot  = ', ln_tide_pot
+!            WRITE(numout,*) '                                     nb_harmo     = ', nb_harmo
+            WRITE(numout,*) '                                     ln_tide_ramp = ', ln_tide_ramp
+! NB - Love number
+            WRITE(numout,*) '                                     dn_love_number = ', dn_love_number
+! End NB
+         ENDIF
+      ELSE
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tide_init : tidal components not used (ln_tide = F)'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~ '
+         RETURN
+      ENDIF
+      !
+      CALL tide_init_Wave
+      !
+      nb_harmo=0
+      DO jk = 1, jpmax_harmo
+         DO ji = 1,jpmax_harmo
+            IF( TRIM(clname(jk)) == Wave(ji)%cname_tide )   nb_harmo = nb_harmo + 1
+         END DO
+      END DO
+      IF (ln_tide .and.lwp) WRITE(numout,*) '                                     nb_harmo     = ', nb_harmo
+
+      ! Ensure that tidal components have been set in namelist_cfg
+      IF( nb_harmo == 0 )   CALL ctl_stop( 'tide_init : No tidal components set in nam_tide' )
+      !
+      IF( ln_tide_ramp.AND.((nitend-nit000+1)*rdt/rday < rdttideramp) )   &
+         &   CALL ctl_stop('rdttideramp must be lower than run duration')
+      IF( ln_tide_ramp.AND.(rdttideramp<0.) ) &
+         &   CALL ctl_stop('rdttideramp must be positive')
+      !
+      ALLOCATE( ntide(nb_harmo) )
+      DO jk = 1, nb_harmo
+         DO ji = 1, jpmax_harmo
+            IF( TRIM(clname(jk)) == Wave(ji)%cname_tide ) THEN
+               ntide(jk) = ji
+               EXIT
+            ENDIF
+         END DO
+      END DO
+      !
+      ALLOCATE( omega_tide(nb_harmo), v0tide    (nb_harmo),   &
+         &      utide     (nb_harmo), ftide     (nb_harmo)  )
+      kt_tide = nit000
+      !
+   END SUBROUTINE tide_init
+     
+   !!======================================================================
+END MODULE tideini
diff --git a/MY_SRC/usrdef_istate.F90 b/MY_SRC/usrdef_istate.F90
new file mode 100755
index 0000000..e7f1502
--- /dev/null
+++ b/MY_SRC/usrdef_istate.F90
@@ -0,0 +1,73 @@
+MODULE usrdef_istate
+   !!======================================================================
+   !!                   ***  MODULE  usrdef_istate   ***
+   !!
+   !!                     ===  GYRE configuration  ===
+   !!
+   !! User defined : set the initial state of a user configuration
+   !!======================================================================
+   !! History :  NEMO ! 2016-03  (S. Flavoni) Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  usr_def_istate : initial state in Temperature and salinity
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_istate   ! called in istate.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+  
+   SUBROUTINE usr_def_istate( pdept, ptmask, pts, pu, pv, pssh )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers
+      !!                Here GYRE configuration example : (double gyre with rotated domain)
+      !!
+      !! ** Method  : - set temprature field
+      !!              - set salinity   field
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pdept   ! depth of t-point               [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   ptmask  ! t-point ocean mask             [m]
+      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts), INTENT(  out) ::   pts     ! T & S fields      [Celsius ; g/kg]
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pu      ! i-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pv      ! j-component of the velocity  [m/s] 
+      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height
+      !
+      INTEGER :: ji, jj, jk  ! dummy loop indices
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate : analytical definition of initial state '
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   Ocean at rest, with an horizontally uniform T and S profiles'
+      !
+      pu  (:,:,:) = 0._wp        ! ocean at rest
+      pv  (:,:,:) = 0._wp
+      pssh(:,:)   = 0._wp
+      !
+      DO jk = 1, jpk             ! horizontally uniform T & S profiles
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               pts(ji,jj,jk,jp_tem) = 20._wp * ptmask(ji,jj,jk)
+               pts(ji,jj,jk,jp_sal) = 36.25_wp * ptmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !   
+   END SUBROUTINE usr_def_istate
+
+   !!======================================================================
+END MODULE usrdef_istate
diff --git a/MY_SRC/usrdef_sbc.F90 b/MY_SRC/usrdef_sbc.F90
new file mode 100755
index 0000000..9f0ef2f
--- /dev/null
+++ b/MY_SRC/usrdef_sbc.F90
@@ -0,0 +1,86 @@
+MODULE usrdef_sbc
+   !!======================================================================
+   !!                       ***  MODULE usrdef_sbc  ***
+   !! 
+   !!                  ===  WAD_TEST_CASES configuration  ===
+   !!
+   !! User defined :   surface forcing of a user configuration
+   !!======================================================================
+   !! History :  4.0   ! 2016-03  (S. Flavoni, G. Madec)  user defined interface
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usrdef_sbc     : user defined surface bounday conditions in WAD_TEST_CASES case
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE phycst          ! physical constants
+   !
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distribued memory computing library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usrdef_sbc_oce    ! routine called in sbcmod module
+   PUBLIC   usrdef_sbc_ice_tau  ! routine called by sbcice_lim.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by sbcice_lim.F90 for ice thermo
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 4.0 , NEMO Consortium (2016)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usrdef_sbc_oce( kt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE usr_def_sbc  ***
+      !!              
+      !! ** Purpose :   provide at each time-step the surface boundary
+      !!              condition, i.e. the momentum, heat and freshwater fluxes.
+      !!
+      !! ** Method  :   all 0 fields, for WAD_TEST_CASES case
+      !!                CAUTION : never mask the surface stress field !
+      !!
+      !! ** Action  : - set to ZERO all the ocean surface boundary condition, i.e.   
+      !!                   utau, vtau, taum, wndm, qns, qsr, emp, sfx
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp) WRITE(numout,*)' usr_sbc : WAD_TEST_CASES case: NO surface forcing'
+         IF(lwp) WRITE(numout,*)' ~~~~~~~~~~~   utau = vtau = taum = wndm = qns = qsr = emp = sfx = 0'
+         !
+         utau(:,:) = 0._wp
+         vtau(:,:) = 0._wp
+         taum(:,:) = 0._wp
+         wndm(:,:) = 0._wp
+         !
+         emp (:,:) = 0._wp
+         sfx (:,:) = 0._wp
+         qns (:,:) = 0._wp
+         qsr (:,:) = 0._wp
+         !         
+      ENDIF
+      !
+   END SUBROUTINE usrdef_sbc_oce
+
+   SUBROUTINE usrdef_sbc_ice_tau( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_tau
+
+   SUBROUTINE usrdef_sbc_ice_flx( kt )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+   !!======================================================================
+END MODULE usrdef_sbc
diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/sosie_initcd_T b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/sosie_initcd_T
new file mode 100644
index 0000000..8da08a5
--- /dev/null
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/sosie_initcd_T
@@ -0,0 +1,26 @@
+#!/bin/bash
+#PBS -N init_T
+#PBS -l select=serial=true:ncpus=1
+#PBS -l walltime=06:00:00
+#PBS -o init_T.log
+#PBS -e init_T.err
+#PBS -A n01-ACCORD
+###################################################
+
+module swap PrgEnv-cray PrgEnv-intel
+module load cray-hdf5-parallel
+module load cray-netcdf-hdf5parallel
+
+
+cd /home/n01/n01/jelt/sosie
+make clean
+make
+make install
+
+#set up paths
+cd /work/n01/n01/jelt/BoBEAS/INPUTS
+
+/home/n01/n01/jelt/local/bin/sosie.x -f initcd_votemper.namelist
+
+# qsub -q serial <filename>
+###################################################
diff --git a/NAMELISTS_AND_FORTRAN_FILES/f_files/dynnxt.F90 b/NAMELISTS_AND_FORTRAN_FILES/f_files/dynnxt.F90
new file mode 100644
index 0000000..756dfb5
--- /dev/null
+++ b/NAMELISTS_AND_FORTRAN_FILES/f_files/dynnxt.F90
@@ -0,0 +1,428 @@
+MODULE dynnxt
+   !!=========================================================================
+   !!                       ***  MODULE  dynnxt  ***
+   !! Ocean dynamics: time stepping
+   !!=========================================================================
+   !! History :  OPA  !  1987-02  (P. Andrich, D. L Hostis)  Original code
+   !!                 !  1990-10  (C. Levy, G. Madec)
+   !!            7.0  !  1993-03  (M. Guyon)  symetrical conditions
+   !!            8.0  !  1997-02  (G. Madec & M. Imbard)  opa, release 8.0
+   !!            8.2  !  1997-04  (A. Weaver)  Euler forward step
+   !!             -   !  1997-06  (G. Madec)  lateral boudary cond., lbc routine
+   !!    NEMO    1.0  !  2002-08  (G. Madec)  F90: Free form and module
+   !!             -   !  2002-10  (C. Talandier, A-M. Treguier) Open boundary cond.
+   !!            2.0  !  2005-11  (V. Garnier) Surface pressure gradient organization
+   !!            2.3  !  2007-07  (D. Storkey) Calls to BDY routines. 
+   !!            3.2  !  2009-06  (G. Madec, R.Benshila)  re-introduce the vvl option
+   !!            3.3  !  2010-09  (D. Storkey, E.O'Dea) Bug fix for BDY module
+   !!            3.3  !  2011-03  (P. Oddo) Bug fix for time-splitting+(BDY-OBC) and not VVL
+   !!            3.5  !  2013-07  (J. Chanut) Compliant with time splitting changes
+   !!            3.6  !  2014-04  (G. Madec) add the diagnostic of the time filter trends
+   !!            3.7  !  2015-11  (J. Chanut) Free surface simplification
+   !!-------------------------------------------------------------------------
+  
+   !!-------------------------------------------------------------------------
+   !!   dyn_nxt       : obtain the next (after) horizontal velocity
+   !!-------------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE sbc_oce        ! Surface boundary condition: ocean fields
+   USE phycst         ! physical constants
+   USE dynadv         ! dynamics: vector invariant versus flux form
+   USE dynspg_ts      ! surface pressure gradient: split-explicit scheme
+   USE dynspg
+   USE domvvl         ! variable volume
+   USE bdy_oce   , ONLY: ln_bdy
+   USE bdydta         ! ocean open boundary conditions
+   USE bdydyn         ! ocean open boundary conditions
+   USE bdyvol         ! ocean open boundary condition (bdy_vol routines)
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   USE trdken         ! trend manager: kinetic energy
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O manager library
+   USE lbclnk         ! lateral boundary condition (or mpp link)
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE prtctl         ! Print control
+   USE timing         ! Timing
+#if defined key_agrif
+   USE agrif_opa_interp
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC    dyn_nxt   ! routine called by step.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: dynnxt.F90 7753 2017-03-03 11:46:59Z mocavero $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_nxt ( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_nxt  ***
+      !!                   
+      !! ** Purpose :   Finalize after horizontal velocity. Apply the boundary 
+      !!             condition on the after velocity, achieve the time stepping 
+      !!             by applying the Asselin filter on now fields and swapping 
+      !!             the fields.
+      !!
+      !! ** Method  : * Ensure after velocities transport matches time splitting
+      !!             estimate (ln_dynspg_ts=T)
+      !!
+      !!              * Apply lateral boundary conditions on after velocity 
+      !!             at the local domain boundaries through lbc_lnk call,
+      !!             at the one-way open boundaries (ln_bdy=T),
+      !!             at the AGRIF zoom   boundaries (lk_agrif=T)
+      !!
+      !!              * Apply the time filter applied and swap of the dynamics
+      !!             arrays to start the next time step:
+      !!                (ub,vb) = (un,vn) + atfp [ (ub,vb) + (ua,va) - 2 (un,vn) ]
+      !!                (un,vn) = (ua,va).
+      !!             Note that with flux form advection and non linear free surface,
+      !!             the time filter is applied on thickness weighted velocity.
+      !!             As a result, dyn_nxt MUST be called after tra_nxt.
+      !!
+      !! ** Action :   ub,vb   filtered before horizontal velocity of next time-step
+      !!               un,vn   now horizontal velocity of next time-step
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ikt          ! local integers
+      REAL(wp) ::   zue3a, zue3n, zue3b, zuf, zcoef    ! local scalars
+      REAL(wp) ::   zve3a, zve3n, zve3b, zvf, z1_2dt   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:)   ::  zue, zve
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ze3u_f, ze3v_f, zua, zva 
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('dyn_nxt')
+      !
+      IF( ln_dynspg_ts       )   CALL wrk_alloc( jpi,jpj,       zue, zve)
+      IF( l_trddyn           )   CALL wrk_alloc( jpi,jpj,jpk,   zua, zva)
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_nxt : time stepping'
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+      ENDIF
+
+      IF ( ln_dynspg_ts ) THEN
+         ! Ensure below that barotropic velocities match time splitting estimate
+         ! Compute actual transport and replace it with ts estimate at "after" time step
+         zue(:,:) = e3u_a(:,:,1) * ua(:,:,1) * umask(:,:,1)
+         zve(:,:) = e3v_a(:,:,1) * va(:,:,1) * vmask(:,:,1)
+         DO jk = 2, jpkm1
+            zue(:,:) = zue(:,:) + e3u_a(:,:,jk) * ua(:,:,jk) * umask(:,:,jk)
+            zve(:,:) = zve(:,:) + e3v_a(:,:,jk) * va(:,:,jk) * vmask(:,:,jk)
+         END DO
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = ( ua(:,:,jk) - zue(:,:) * r1_hu_a(:,:) + ua_b(:,:) ) * umask(:,:,jk)
+            va(:,:,jk) = ( va(:,:,jk) - zve(:,:) * r1_hv_a(:,:) + va_b(:,:) ) * vmask(:,:,jk)
+         END DO
+         !
+         IF( .NOT.ln_bt_fw ) THEN
+            ! Remove advective velocity from "now velocities" 
+            ! prior to asselin filtering     
+            ! In the forward case, this is done below after asselin filtering   
+            ! so that asselin contribution is removed at the same time 
+            DO jk = 1, jpkm1
+               un(:,:,jk) = ( un(:,:,jk) - un_adv(:,:) + un_b(:,:) )*umask(:,:,jk)
+               vn(:,:,jk) = ( vn(:,:,jk) - vn_adv(:,:) + vn_b(:,:) )*vmask(:,:,jk)
+            END DO  
+         ENDIF
+      ENDIF
+
+      ! Update after velocity on domain lateral boundaries
+      ! --------------------------------------------------      
+# if defined key_agrif
+      CALL Agrif_dyn( kt )             !* AGRIF zoom boundaries
+# endif
+      !
+      CALL lbc_lnk( ua, 'U', -1. )     !* local domain boundaries
+      CALL lbc_lnk( va, 'V', -1. ) 
+      !
+      !                                !* BDY open boundaries
+      IF( ln_bdy .AND. ln_dynspg_exp )   CALL bdy_dyn( kt )
+      IF( ln_bdy .AND. ln_dynspg_ts  )   CALL bdy_dyn( kt, dyn3d_only=.true. )
+
+!!$   Do we need a call to bdy_vol here??
+      !
+      IF( l_trddyn ) THEN             ! prepare the atf trend computation + some diagnostics
+         z1_2dt = 1._wp / (2. * rdt)        ! Euler or leap-frog time step 
+         IF( neuler == 0 .AND. kt == nit000 )   z1_2dt = 1._wp / rdt
+         !
+         !                                  ! Kinetic energy and Conversion
+         IF( ln_KE_trd  )   CALL trd_dyn( ua, va, jpdyn_ken, kt )
+         !
+         IF( ln_dyn_trd ) THEN              ! 3D output: total momentum trends
+            zua(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) * z1_2dt
+            zva(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) * z1_2dt
+            CALL iom_put( "utrd_tot", zua )        ! total momentum trends, except the asselin time filter
+            CALL iom_put( "vtrd_tot", zva )
+         ENDIF
+         !
+         zua(:,:,:) = un(:,:,:)             ! save the now velocity before the asselin filter
+         zva(:,:,:) = vn(:,:,:)             ! (caution: there will be a shift by 1 timestep in the
+         !                                  !  computation of the asselin filter trends)
+      ENDIF
+
+      ! Time filter and swap of dynamics arrays
+      ! ------------------------------------------
+      IF( neuler == 0 .AND. kt == nit000 ) THEN        !* Euler at first time-step: only swap
+         DO jk = 1, jpkm1
+            un(:,:,jk) = ua(:,:,jk)                          ! un <-- ua
+            vn(:,:,jk) = va(:,:,jk)
+         END DO
+!jth limit velocities
+       IF (ln_ulimit) THEN
+         call dyn_limit_velocity (kt)
+       ENDIF
+         IF(.NOT.ln_linssh ) THEN
+            DO jk = 1, jpkm1
+               e3t_b(:,:,jk) = e3t_n(:,:,jk)
+               e3u_b(:,:,jk) = e3u_n(:,:,jk)
+               e3v_b(:,:,jk) = e3v_n(:,:,jk)
+            END DO
+         ENDIF
+      ELSE                                             !* Leap-Frog : Asselin filter and swap
+         !                                ! =============!
+         IF( ln_linssh ) THEN             ! Fixed volume !
+            !                             ! =============!
+            DO jk = 1, jpkm1                              
+               DO jj = 1, jpj
+                  DO ji = 1, jpi    
+                     zuf = un(ji,jj,jk) + atfp * ( ub(ji,jj,jk) - 2._wp * un(ji,jj,jk) + ua(ji,jj,jk) )
+                     zvf = vn(ji,jj,jk) + atfp * ( vb(ji,jj,jk) - 2._wp * vn(ji,jj,jk) + va(ji,jj,jk) )
+                     !
+                     ub(ji,jj,jk) = zuf                      ! ub <-- filtered velocity
+                     vb(ji,jj,jk) = zvf
+                     un(ji,jj,jk) = ua(ji,jj,jk)             ! un <-- ua
+                     vn(ji,jj,jk) = va(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+!jth 
+       IF (ln_ulimit) THEN
+           call dyn_limit_velocity (kt)
+       ENDIF
+            !                             ! ================!
+         ELSE                             ! Variable volume !
+            !                             ! ================!
+            ! Before scale factor at t-points
+            ! (used as a now filtered scale factor until the swap)
+            ! ----------------------------------------------------
+            IF( ln_dynspg_ts .AND. ln_bt_fw ) THEN    ! No asselin filtering on thicknesses if forward time splitting
+               e3t_b(:,:,1:jpkm1) = e3t_n(:,:,1:jpkm1)
+            ELSE
+               DO jk = 1, jpkm1
+                  e3t_b(:,:,jk) = e3t_n(:,:,jk) + atfp * ( e3t_b(:,:,jk) - 2._wp * e3t_n(:,:,jk) + e3t_a(:,:,jk) )
+               END DO
+               ! Add volume filter correction: compatibility with tracer advection scheme
+               ! => time filter + conservation correction (only at the first level)
+               zcoef = atfp * rdt * r1_rau0
+               IF ( .NOT. ln_isf ) THEN   ! if no ice shelf melting
+                  e3t_b(:,:,1) = e3t_b(:,:,1) - zcoef * ( emp_b(:,:) - emp(:,:) &
+                                 &                      - rnf_b(:,:) + rnf(:,:) ) * tmask(:,:,1)
+               ELSE                     ! if ice shelf melting
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        ikt = mikt(ji,jj)
+                        e3t_b(ji,jj,ikt) = e3t_b(ji,jj,ikt) - zcoef * (  emp_b   (ji,jj) - emp   (ji,jj)  &
+                           &                                           - rnf_b   (ji,jj) + rnf   (ji,jj)  &
+                           &                                           + fwfisf_b(ji,jj) - fwfisf(ji,jj)  ) * tmask(ji,jj,ikt)
+                     END DO
+                  END DO
+               END IF
+            ENDIF
+            !
+            IF( ln_dynadv_vec ) THEN      ! Asselin filter applied on velocity
+               ! Before filtered scale factor at (u/v)-points
+               CALL dom_vvl_interpol( e3t_b(:,:,:), e3u_b(:,:,:), 'U' )
+               CALL dom_vvl_interpol( e3t_b(:,:,:), e3v_b(:,:,:), 'V' )
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        zuf = un(ji,jj,jk) + atfp * ( ub(ji,jj,jk) - 2._wp * un(ji,jj,jk) + ua(ji,jj,jk) )
+                        zvf = vn(ji,jj,jk) + atfp * ( vb(ji,jj,jk) - 2._wp * vn(ji,jj,jk) + va(ji,jj,jk) )
+                        !
+                        ub(ji,jj,jk) = zuf                      ! ub <-- filtered velocity
+                        vb(ji,jj,jk) = zvf
+                        un(ji,jj,jk) = ua(ji,jj,jk)             ! un <-- ua
+                        vn(ji,jj,jk) = va(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO
+!jth limit velocities
+       IF (ln_ulimit) THEN
+         call dyn_limit_velocity (kt)
+       ENDIF
+               !
+            ELSE                          ! Asselin filter applied on thickness weighted velocity
+               !
+               CALL wrk_alloc( jpi,jpj,jpk,   ze3u_f, ze3v_f )
+               ! Before filtered scale factor at (u/v)-points stored in ze3u_f, ze3v_f
+               CALL dom_vvl_interpol( e3t_b(:,:,:), ze3u_f, 'U' )
+               CALL dom_vvl_interpol( e3t_b(:,:,:), ze3v_f, 'V' )
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi                  
+                        zue3a = e3u_a(ji,jj,jk) * ua(ji,jj,jk)
+                        zve3a = e3v_a(ji,jj,jk) * va(ji,jj,jk)
+                        zue3n = e3u_n(ji,jj,jk) * un(ji,jj,jk)
+                        zve3n = e3v_n(ji,jj,jk) * vn(ji,jj,jk)
+                        zue3b = e3u_b(ji,jj,jk) * ub(ji,jj,jk)
+                        zve3b = e3v_b(ji,jj,jk) * vb(ji,jj,jk)
+                        !
+                        zuf = ( zue3n + atfp * ( zue3b - 2._wp * zue3n  + zue3a ) ) / ze3u_f(ji,jj,jk)
+                        zvf = ( zve3n + atfp * ( zve3b - 2._wp * zve3n  + zve3a ) ) / ze3v_f(ji,jj,jk)
+                        !
+                        ub(ji,jj,jk) = zuf                     ! ub <-- filtered velocity
+                        vb(ji,jj,jk) = zvf
+                        un(ji,jj,jk) = ua(ji,jj,jk)            ! un <-- ua
+                        vn(ji,jj,jk) = va(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO
+!jth limit velocities
+       IF (ln_ulimit) THEN
+         call dyn_limit_velocity (kt)
+       ENDIF
+               e3u_b(:,:,1:jpkm1) = ze3u_f(:,:,1:jpkm1)        ! e3u_b <-- filtered scale factor
+               e3v_b(:,:,1:jpkm1) = ze3v_f(:,:,1:jpkm1)
+               !
+               CALL wrk_dealloc( jpi,jpj,jpk,   ze3u_f, ze3v_f )
+            ENDIF
+            !
+         ENDIF
+         !
+         IF( ln_dynspg_ts .AND. ln_bt_fw ) THEN
+            ! Revert "before" velocities to time split estimate
+            ! Doing it here also means that asselin filter contribution is removed  
+            zue(:,:) = e3u_b(:,:,1) * ub(:,:,1) * umask(:,:,1)
+            zve(:,:) = e3v_b(:,:,1) * vb(:,:,1) * vmask(:,:,1)    
+            DO jk = 2, jpkm1
+               zue(:,:) = zue(:,:) + e3u_b(:,:,jk) * ub(:,:,jk) * umask(:,:,jk)
+               zve(:,:) = zve(:,:) + e3v_b(:,:,jk) * vb(:,:,jk) * vmask(:,:,jk)    
+            END DO
+            DO jk = 1, jpkm1
+               ub(:,:,jk) = ub(:,:,jk) - (zue(:,:) * r1_hu_n(:,:) - un_b(:,:)) * umask(:,:,jk)
+               vb(:,:,jk) = vb(:,:,jk) - (zve(:,:) * r1_hv_n(:,:) - vn_b(:,:)) * vmask(:,:,jk)
+            END DO
+         ENDIF
+         !
+      ENDIF ! neuler =/0
+      !
+      ! Set "now" and "before" barotropic velocities for next time step:
+      ! JC: Would be more clever to swap variables than to make a full vertical
+      ! integration
+      !
+      !
+      IF(.NOT.ln_linssh ) THEN
+         hu_b(:,:) = e3u_b(:,:,1) * umask(:,:,1)
+         hv_b(:,:) = e3v_b(:,:,1) * vmask(:,:,1)
+         DO jk = 2, jpkm1
+            hu_b(:,:) = hu_b(:,:) + e3u_b(:,:,jk) * umask(:,:,jk)
+            hv_b(:,:) = hv_b(:,:) + e3v_b(:,:,jk) * vmask(:,:,jk)
+         END DO
+         r1_hu_b(:,:) = ssumask(:,:) / ( hu_b(:,:) + 1._wp - ssumask(:,:) )
+         r1_hv_b(:,:) = ssvmask(:,:) / ( hv_b(:,:) + 1._wp - ssvmask(:,:) )
+      ENDIF
+      !
+      un_b(:,:) = e3u_a(:,:,1) * un(:,:,1) * umask(:,:,1)
+      ub_b(:,:) = e3u_b(:,:,1) * ub(:,:,1) * umask(:,:,1)
+      vn_b(:,:) = e3v_a(:,:,1) * vn(:,:,1) * vmask(:,:,1)
+      vb_b(:,:) = e3v_b(:,:,1) * vb(:,:,1) * vmask(:,:,1)
+      DO jk = 2, jpkm1
+         un_b(:,:) = un_b(:,:) + e3u_a(:,:,jk) * un(:,:,jk) * umask(:,:,jk)
+         ub_b(:,:) = ub_b(:,:) + e3u_b(:,:,jk) * ub(:,:,jk) * umask(:,:,jk)
+         vn_b(:,:) = vn_b(:,:) + e3v_a(:,:,jk) * vn(:,:,jk) * vmask(:,:,jk)
+         vb_b(:,:) = vb_b(:,:) + e3v_b(:,:,jk) * vb(:,:,jk) * vmask(:,:,jk)
+      END DO
+      un_b(:,:) = un_b(:,:) * r1_hu_a(:,:)
+      vn_b(:,:) = vn_b(:,:) * r1_hv_a(:,:)
+      ub_b(:,:) = ub_b(:,:) * r1_hu_b(:,:)
+      vb_b(:,:) = vb_b(:,:) * r1_hv_b(:,:)
+      !
+      IF( .NOT.ln_dynspg_ts ) THEN        ! output the barotropic currents
+         CALL iom_put(  "ubar", un_b(:,:) )
+         CALL iom_put(  "vbar", vn_b(:,:) )
+      ENDIF
+      IF( l_trddyn ) THEN                ! 3D output: asselin filter trends on momentum
+         zua(:,:,:) = ( ub(:,:,:) - zua(:,:,:) ) * z1_2dt
+         zva(:,:,:) = ( vb(:,:,:) - zva(:,:,:) ) * z1_2dt
+         CALL trd_dyn( zua, zva, jpdyn_atf, kt )
+      ENDIF
+      !
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=un, clinfo1=' nxt  - Un: ', mask1=umask,   &
+         &                       tab3d_2=vn, clinfo2=' Vn: '       , mask2=vmask )
+      ! 
+      IF( ln_dynspg_ts )   CALL wrk_dealloc( jpi,jpj,       zue, zve )
+      IF( l_trddyn     )   CALL wrk_dealloc( jpi,jpj,jpk,   zua, zva )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_nxt')
+      !
+   END SUBROUTINE dyn_nxt
+
+   SUBROUTINE dyn_limit_velocity (kt)
+   ! limits maxming vlaues of un and vn by volume courant number
+      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) :: zzu,zplim,zmlim,isp,ism,zcn,ze3e1,zzcn,zcnn,idivp,idivm
+
+   !!=========================================================================
+!jth limit fluxes
+      zcn =cn_ulimit !0.9 ! maximum velocity inverse courant number
+      zcnn = cnn_ulimit !0.54 ! how much to reduce cn by in divergen flow
+
+      DO jk = 1, jpkm1
+       DO jj = 1, jpjm1
+        DO ji = 1, jpim1
+! U direction
+         zzu = un(ji,jj,jk)
+         ze3e1 = e3u_n(ji  ,jj,jk) * e2u(ji  ,jj) 
+! ips is 1 if flow is positive othersize zero
+         isp =  0.5 * (sign(1.0_wp,zzu) + 1.0_wp )
+         ism = -0.5 * (sign(1.0_wp,zzu) - 1.0_wp )
+!idev is 1 if divergent flow otherwise zero
+         idivp = isp *  -0.5 * (sign(1.0_wp, un(ji-1,jj,jk)) - 1.0_wp )
+         idivm = ism *   0.5 * (sign(1.0_wp, un(ji+1,jj,jk)) + 1.0_wp )
+         zzcn = (idivp+idivm)*(zcnn-1.0_wp)+1.0_wp
+         zzcn = zzcn * zcn
+         zplim =  zzcn * (e3t_n(ji  ,jj,jk) * e1t(ji  ,jj) * e2t(ji  ,jj)) / (2.0*rdt * ze3e1)*umask(ji,jj,jk)
+         zmlim = -zzcn * (e3t_n(ji+1,jj,jk) * e1t(ji+1,jj) * e2t(ji+1,jj)) / (2.0*rdt * ze3e1)*umask(ji,jj,jk)
+!limit currents
+         un(ji,jj,jk) = min ( zzu,zplim) * isp + max (zzu,zmlim) *ism
+!         if (abs(un(ji,jj,jk)) .ge. 20.) write(666,*)  un(ji,jj,jk),ze3e1, isp,ism, zzu,e3t_n(ji+1,jj,jk)
+!         call flush(666)
+! if (ji+nimpp-1==122 .and. jj+njmpp-1==149 .and. jk == 1 ) write (6,*) 'uu',un(ji,jj,jk), ze3e1, isp,ism, zzu,e3t_n(ji+1,jj,jk),e1t(ji+1,jj), e2t(ji+1,jj),zmlim
+!         call flush(6)
+! V  direction
+         zzu = vn(ji,jj,jk)
+         ze3e1 = e3v_n(ji  ,jj,jk) * e1v(ji  ,jj)
+         isp =  0.5 * (sign(1.0_wp,zzu) + 1.0_wp )
+         ism = -0.5 * (sign(1.0_wp,zzu) - 1.0_wp )
+!idev is 1 if divergent flow otherwise zero
+         idivp = isp *  -0.5 * (sign(1.0_wp, vn(ji,jj-1,jk)) - 1.0_wp )
+         idivm = ism *   0.5 * (sign(1.0_wp, vn(ji,jj+1,jk)) + 1.0_wp )
+         zzcn = (idivp+idivm)*(zcnn-1.0_wp)+1.0_wp
+         zzcn = zzcn * zcn
+         zplim =  zzcn * (e3t_n(ji,jj  ,jk) * e1t(ji,jj  ) * e2t(ji,jj  )) / (2.0*rdt * ze3e1)*vmask(ji,jj,jk)
+         zmlim = -zzcn * (e3t_n(ji,jj+1,jk) * e1t(ji,jj+1) * e2t(ji,jj+1)) / (2.0*rdt * ze3e1)*vmask(ji,jj,jk)
+         vn(ji,jj,jk) = min ( zzu,zplim) * isp + max (zzu,zmlim) *ism
+!	   if (abs(vn(ji,jj,jk)) .ge. 20.) write(666,*) vn(ji,jj,jk), ze3e1, isp,ism, zzu,e3t_n(ji,jj+1,jk)
+!         call flush(666)
+! if (ji+nimpp-1==122 .and. jj+njmpp-1==149 .and. jk == 1 ) write (6,*) 'vv',vn(ji,jj,jk), ze3e1, isp,ism, zzu,e3t_n(ji,jj+1,jk)
+
+       ENDDO
+      ENDDO
+     ENDDO
+
+    END SUBROUTINE dyn_limit_velocity 
+END MODULE dynnxt
diff --git a/NAMELISTS_AND_FORTRAN_FILES/f_files/dynspg.F90 b/NAMELISTS_AND_FORTRAN_FILES/f_files/dynspg.F90
new file mode 100644
index 0000000..3fa4160
--- /dev/null
+++ b/NAMELISTS_AND_FORTRAN_FILES/f_files/dynspg.F90
@@ -0,0 +1,242 @@
+MODULE dynspg
+   !!======================================================================
+   !!                       ***  MODULE  dynspg  ***
+   !! Ocean dynamics:  surface pressure gradient control
+   !!======================================================================
+   !! History :  1.0  ! 2005-12  (C. Talandier, G. Madec, V. Garnier)  Original code
+   !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_spg     : update the dynamics trend with surface pressure gradient 
+   !!   dyn_spg_init: initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables
+   USE c1d            ! 1D vertical configuration
+   USE phycst         ! physical constants
+   USE sbc_oce        ! surface boundary condition: ocean
+   USE sbcapr         ! surface boundary condition: atmospheric pressure
+   USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
+   USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
+   USE sbctide        ! 
+   USE updtide        ! 
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   !
+   USE prtctl         ! Print control                     (prt_ctl routine)
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   dyn_spg        ! routine called by step module
+   PUBLIC   dyn_spg_init   ! routine called by opa module
+
+   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_... 
+!jth
+   LOGICAL, PUBLIC ::  ln_ulimit
+   REAL(wp), PUBLIC :: cn_ulimit,cnn_ulimit
+!
+   !                       ! Parameter to control the surface pressure gradient scheme
+   INTEGER, PARAMETER ::   np_TS  = 1   ! split-explicit time stepping (Time-Splitting)
+   INTEGER, PARAMETER ::   np_EXP = 0   !       explicit time stepping
+   INTEGER, PARAMETER ::   np_NO  =-1   ! no surface pressure gradient, no scheme
+
+   !! * Substitutions
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
+   !! $Id: dynspg.F90 7753 2017-03-03 11:46:59Z mocavero $ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_spg( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_spg  ***
+      !!
+      !! ** Purpose :   compute surface pressure gradient including the 
+      !!              atmospheric pressure forcing (ln_apr_dyn=T).
+      !!
+      !! ** Method  :   Two schemes:
+      !!              - explicit       : the spg is evaluated at now
+      !!              - split-explicit : a time splitting technique is used
+      !!
+      !!              ln_apr_dyn=T : the atmospheric pressure forcing is applied 
+      !!             as the gradient of the inverse barometer ssh:
+      !!                apgu = - 1/rau0 di[apr] = 0.5*grav di[ssh_ib+ssh_ibb]
+      !!                apgv = - 1/rau0 dj[apr] = 0.5*grav dj[ssh_ib+ssh_ibb]
+      !!             Note that as all external forcing a time averaging over a two rdt
+      !!             period is used to prevent the divergence of odd and even time step.
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk                             ! dummy loop indices
+      REAL(wp) ::   z2dt, zg_2, zintp, zgrau0r             ! temporary scalar
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
+      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpice
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_spg')
+      !
+      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
+         CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
+         ztrdu(:,:,:) = ua(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:)
+      ENDIF
+      !
+      IF(      ln_apr_dyn                                                &   ! atmos. pressure
+         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
+         .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
+         !
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               spgu(ji,jj) = 0._wp
+               spgv(ji,jj) = 0._wp
+            END DO
+         END DO         
+         !
+         IF( ln_apr_dyn .AND. .NOT.ln_dynspg_ts ) THEN   !==  Atmospheric pressure gradient (added later in time-split case) ==!
+            zg_2 = grav * 0.5
+            DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
+                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
+                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
+               END DO
+            END DO
+         ENDIF
+         !
+         !                                    !==  tide potential forcing term  ==!
+         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. ln_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
+            !
+            CALL upd_tide( kt )                      ! update tide potential
+            !
+            DO jj = 2, jpjm1                         ! add tide potential forcing
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
+               END DO 
+            END DO
+         ENDIF
+         !
+         IF( nn_ice_embd == 2 ) THEN          !== embedded sea ice: Pressure gradient due to snow-ice mass ==!
+            CALL wrk_alloc( jpi,jpj,   zpice )
+            !                                            
+            zintp = REAL( MOD( kt-1, nn_fsbc ) ) / REAL( nn_fsbc )
+            zgrau0r     = - grav * r1_rau0
+            zpice(:,:) = (  zintp * snwice_mass(:,:) + ( 1.- zintp ) * snwice_mass_b(:,:)  ) * zgrau0r
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
+               END DO
+            END DO
+            !
+            CALL wrk_dealloc( jpi,jpj,   zpice )         
+         ENDIF
+         !
+         DO jk = 1, jpkm1                    !== Add all terms to the general trend
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ua(ji,jj,jk) = ua(ji,jj,jk) + spgu(ji,jj)
+                  va(ji,jj,jk) = va(ji,jj,jk) + spgv(ji,jj)
+               END DO
+            END DO
+         END DO    
+         !
+!!gm add here a call to dyn_trd for ice pressure gradient, the surf pressure trends ????
+         !    
+      ENDIF
+      !
+      SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
+      CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt )              ! explicit
+      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
+      END SELECT
+      !                    
+      IF( l_trddyn )   THEN                  ! save the surface pressure gradient trends for further diagnostics
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
+         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
+         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv ) 
+      ENDIF
+      !                                      ! print mean trends (used for debugging)
+      IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' spg  - Ua: ', mask1=umask, &
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg')
+      !
+   END SUBROUTINE dyn_spg
+
+
+   SUBROUTINE dyn_spg_init
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE dyn_spg_init  ***
+      !!                
+      !! ** Purpose :   Control the consistency between namelist options for 
+      !!              surface pressure gradient schemes
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio, ios   ! local integers
+      !
+      NAMELIST/namdyn_spg/ ln_dynspg_exp       , ln_dynspg_ts,   &
+      &                    ln_bt_fw, ln_bt_av  , ln_bt_auto  ,   &
+      &                    nn_baro , rn_bt_cmax, nn_bt_flt,ln_ulimit,cn_ulimit,cnn_ulimit
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
+      !
+      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
+      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
+      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namdyn_spg )
+      !
+      IF(lwp) THEN             ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
+         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
+
+         write(numout,*) '     Limit velocities                       ln_ulimit     = ',ln_ulimit
+         write(numout,*) '     Limit velocities      max inverse Courant number     = ',cn_ulimit
+         write(numout,*) '     Limit velocities   multiplier for divergant flow     = ',cnn_ulimit
+
+      ENDIF
+      !                          ! Control of surface pressure gradient scheme options
+                                     nspg =  np_NO    ;   ioptio = 0
+      IF( ln_dynspg_exp ) THEN   ;   nspg =  np_EXP   ;   ioptio = ioptio + 1   ;   ENDIF
+      IF( ln_dynspg_ts  ) THEN   ;   nspg =  np_TS    ;   ioptio = ioptio + 1   ;   ENDIF
+      !
+      IF( ioptio  > 1 )   CALL ctl_stop( 'Choose only one surface pressure gradient scheme' )
+      IF( ioptio == 0 )   CALL ctl_warn( 'NO surface pressure gradient trend in momentum Eqs.' )
+      IF( ln_dynspg_exp .AND. ln_isfcav )   &
+           &   CALL ctl_stop( ' dynspg_exp not tested with ice shelf cavity ' )
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         IF( nspg == np_EXP )   WRITE(numout,*) '      ===>>   explicit free surface'
+         IF( nspg == np_TS  )   WRITE(numout,*) '      ===>>   free surface with time splitting scheme'
+         IF( nspg == np_NO  )   WRITE(numout,*) '      ===>>   No surface surface pressure gradient trend in momentum Eqs.'
+      ENDIF
+      !
+      IF( nspg == np_TS ) THEN   ! split-explicit scheme initialisation
+         CALL dyn_spg_ts_init          ! do it first: set nn_baro used to allocate some arrays later on
+         IF( dyn_spg_ts_alloc() /= 0  )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays' )
+         IF( neuler/=0 .AND. ln_bt_fw )   CALL ts_rst( nit000, 'READ' )
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_spg_init')
+      !
+   END SUBROUTINE dyn_spg_init
+
+  !!======================================================================
+END MODULE dynspg
diff --git a/SCRIPTS/make_nemo.sh b/SCRIPTS/make_nemo.sh
index ca98593..95cb5a3 100755
--- a/SCRIPTS/make_nemo.sh
+++ b/SCRIPTS/make_nemo.sh
@@ -1,7 +1,7 @@
 svn co http://forge.ipsl.jussieu.fr/nemo/svn/trunk/NEMOGCM@8395 $NEMO/trunk_NEMOGCM_r8395
 
-#cp $GITCLONE/ARCH/arch-XC_ARCHER_INTEL.fcm $CDIR/../ARCH/
-cp $ARCH/arch-XC_ARCHER_INTEL.fcm $CDIR/../ARCH/
+cp $GITCLONE/ARCH/arch-XC_ARCHER_INTEL.fcm $CDIR/../ARCH/
+#cp $ARCH/arch-XC_ARCHER_INTEL.fcm $CDIR/../ARCH/
 
 cd $CDIR
 
@@ -10,10 +10,10 @@ printf 'y\nn\nn\nn\nn\nn\nn\nn\n' | ./makenemo -n $CONFIG -m XC_ARCHER_INTEL -j
 ./makenemo -n $CONFIG -m XC_ARCHER_INTEL -j 10 clean
 
 
-#cp $GITCLONE/MY_SRC/* $CDIR/$CONFIG/MY_SRC/.
-cp $GFILE/f_files/* $CDIR/$CONFIG/MY_SRC/.
-#cp $GITCLONE/cpp_file.fcm $CONFIG/cpp_$CONFIG.fcm
-cp $GFILE/cpp_file.fcm $CONFIG/cpp_$CONFIG.fcm
+cp $GITCLONE/MY_SRC/* $CDIR/$CONFIG/MY_SRC/.
+#cp $GFILE/f_files/* $CDIR/$CONFIG/MY_SRC/.
+cp $GITCLONE/cpp_file.fcm $CONFIG/cpp_$CONFIG.fcm
+#cp $GFILE/cpp_file.fcm $CONFIG/cpp_$CONFIG.fcm
 
 ./makenemo -n $CONFIG -m XC_ARCHER_INTEL -j 10
 
diff --git a/SCRIPTS/make_paths.sh b/SCRIPTS/make_paths.sh
index a8fee99..08de871 100755
--- a/SCRIPTS/make_paths.sh
+++ b/SCRIPTS/make_paths.sh
@@ -1,4 +1,4 @@
-export CONFIG=INDIAN_OCEAN_AUTO
+export CONFIG=BoBEAS
 export WORK=/work/n01/n01/$USER
 export AWORK=/work/n01/n01/ashbre
 export WDIR=$WORK/$CONFIG
diff --git a/cpp_file.fcm b/cpp_file.fcm
new file mode 100755
index 0000000..e2cd675
--- /dev/null
+++ b/cpp_file.fcm
@@ -0,0 +1,6 @@
+bld::tool::fppkeys key_zdfgls \
+key_FES14_tides \
+key_diaharm_fast \
+key_mpp_mpi \
+key_iomput \
+key_nosignedzero
-- 
GitLab


From cd2d1aae96eef1590189a81ec0f8d3c47b3b98a0 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Fri, 17 May 2019 22:11:04 +0100
Subject: [PATCH 03/18] ensure target grid has same number of levels as child

---
 .../INITIAL_CONDITION/initcd_vosaline.namelist                | 4 ++--
 .../INITIAL_CONDITION/initcd_votemper.namelist                | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist
index 23f7f21..67f32f8 100755
--- a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist
@@ -156,8 +156,8 @@ ismooth   = 0
 &n3d
 cf_z_in  = 'initcd_vosaline.nc'
 cv_z_in  = 'gdept'
-cf_z_out = 'initcd_vosaline.nc'
-cv_z_out = 'gdept'
+cf_z_out = 'domain_cfg.nc'
+cv_z_out = 'nav_lev'
 cv_z_out_name = 'gdept'
 ctype_z_in = 'z'
 ctype_z_out = 'z'
diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist
index 5026472..215dd75 100755
--- a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist
@@ -156,8 +156,8 @@ ismooth   = 0
 &n3d
 cf_z_in  = 'initcd_votemper.nc'
 cv_z_in  = 'gdept'
-cf_z_out = 'initcd_votemper.nc'
-cv_z_out = 'gdept'
+cf_z_out = 'domain_cfg.nc'
+cv_z_out = 'nav_lev'
 cv_z_out_name = 'gdept'
 ctype_z_in = 'z'
 ctype_z_out = 'z'
-- 
GitLab


From 265258b0b751facd6d5ca6c144d210ddf6e2645d Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Fri, 17 May 2019 22:26:41 +0100
Subject: [PATCH 04/18] first attempt at Apr19 cold start

---
 EXP_Apr19/context_nemo.xml          |  120 +++
 EXP_Apr19/domain_def_nemo.xml       |  258 ++++++
 EXP_Apr19/field_def_nemo-lim.xml    |  182 ++++
 EXP_Apr19/field_def_nemo-opa.xml    | 1107 ++++++++++++++++++++++++
 EXP_Apr19/field_def_nemo-pisces.xml |  298 +++++++
 EXP_Apr19/file_def_nemo-opa.xml     |   55 ++
 EXP_Apr19/file_def_nemo.xml         |  151 ++++
 EXP_Apr19/iodef.xml                 |   27 +
 EXP_Apr19/namelist_cfg              |  407 +++++++++
 EXP_Apr19/namelist_ref              | 1200 +++++++++++++++++++++++++++
 EXP_Apr19/run_script.pbs            |   41 +
 11 files changed, 3846 insertions(+)
 create mode 100755 EXP_Apr19/context_nemo.xml
 create mode 100755 EXP_Apr19/domain_def_nemo.xml
 create mode 100755 EXP_Apr19/field_def_nemo-lim.xml
 create mode 100755 EXP_Apr19/field_def_nemo-opa.xml
 create mode 100755 EXP_Apr19/field_def_nemo-pisces.xml
 create mode 100755 EXP_Apr19/file_def_nemo-opa.xml
 create mode 100755 EXP_Apr19/file_def_nemo.xml
 create mode 100755 EXP_Apr19/iodef.xml
 create mode 100755 EXP_Apr19/namelist_cfg
 create mode 100755 EXP_Apr19/namelist_ref
 create mode 100755 EXP_Apr19/run_script.pbs

diff --git a/EXP_Apr19/context_nemo.xml b/EXP_Apr19/context_nemo.xml
new file mode 100755
index 0000000..4ab125f
--- /dev/null
+++ b/EXP_Apr19/context_nemo.xml
@@ -0,0 +1,120 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+<!-- $id$ -->
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-opa.xml"/>   <!--  NEMO ocean dynamics                     -->
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo.xml"/>     <!--  NEMO ocean dynamics                     -->
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+    <axis_definition>
+      <axis id="deptht" long_name="Vertical T levels" unit="m" positive="down" />
+      <axis id="depthu" long_name="Vertical U levels" unit="m" positive="down" />
+      <axis id="depthv" long_name="Vertical V levels" unit="m" positive="down" />
+      <axis id="depthw" long_name="Vertical W levels" unit="m" positive="down" />
+      <axis id="nfloat" long_name="Float number"      unit="-"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"               />
+      <axis id="ncatice" long_name="Ice category"       unit="1"               />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"            />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"            />
+    </axis_definition>
+ 
+    <domain_definition src="./domain_def_nemo.xml"/>
+  
+    <grid_definition>    
+
+        <!--  -->
+       <grid id="grid_T_2D" >
+         <domain id="grid_T" />
+       </grid>
+        <!--  -->
+       <grid id="grid_T_3D_ncatice" >
+         <domain id="grid_T" />
+         <axis id="ncatice" />
+       </grid>
+        <!--  -->
+       <grid id="grid_T_3D" >
+         <domain id="grid_T" />
+         <axis id="deptht" />
+       </grid>
+        <!--  -->
+       <grid id="grid_U_2D" >
+         <domain id="grid_U" />
+       </grid>
+        <!--  -->
+       <grid id="grid_U_3D" >
+         <domain id="grid_U" />
+         <axis id="depthu" />
+       </grid>
+        <!--  -->
+       <grid id="grid_V_2D" >
+         <domain id="grid_V" />
+       </grid>
+        <!--  -->
+       <grid id="grid_V_3D" >
+         <domain id="grid_V" />
+         <axis id="depthv" />
+       </grid>
+        <!--  -->
+       <grid id="grid_W_2D" >
+         <domain id="grid_W" />
+       </grid>
+        <!--  -->
+       <grid id="grid_W_3D" >
+         <domain id="grid_W" />
+         <axis id="depthw" />
+       </grid>
+        <!--  -->
+       <grid id="grid_1point" >
+         <domain domain_ref="1point"/>
+       </grid>
+        <!--  -->
+       <grid id="grid_T_nfloat" >
+         <domain id="grid_T" />
+         <axis id="nfloat" />
+       </grid>
+        <!--  -->
+       <grid id="grid_EqT" >
+         <domain domain_ref="EqT" />
+       </grid>
+        <!--  -->
+       <grid id="grid_znl_T_2D">
+         <domain id="gznl" />
+       </grid>
+        <!--  -->
+       <grid id="grid_znl_T_3D">
+         <domain id="gznl" />
+         <axis id="deptht" />
+       </grid>
+        <!--  -->
+       <grid id="grid_znl_W_3D">
+         <domain id="gznl" />
+         <axis id="depthw" />
+       </grid>
+
+      <grid id="grid_ptr_T_2D">
+       <domain id="ptr" />
+      </grid>
+
+      <grid id="grid_ptr_T_3D">
+       <domain id="ptr" />
+         <axis id="deptht" />
+       </grid>
+
+      <grid id="grid_ptr_W_3D">
+       <domain id="ptr" />
+         <axis id="depthw" />
+      </grid>
+
+    </grid_definition>   
+
+</context>
diff --git a/EXP_Apr19/domain_def_nemo.xml b/EXP_Apr19/domain_def_nemo.xml
new file mode 100755
index 0000000..a8f71f8
--- /dev/null
+++ b/EXP_Apr19/domain_def_nemo.xml
@@ -0,0 +1,258 @@
+
+   <domain_definition>
+      <domain_group id="grid_T">
+         <domain id="grid_T" long_name="grid T"/>
+	 <!--   My zoom: example of hand defined zoom   -->
+
+         <domain id="moorT"   ibegin="39" jbegin="82" ni="1"  nj="1" />
+
+         <domain id="sec01T"  ibegin="33"  jbegin="62" ni="28" nj="1" />
+         <domain id="sec02T"  ibegin="34" jbegin="68" ni="27" nj="1" />
+         <domain id="sec03T"  ibegin="29"  jbegin="75" ni="18" nj="1" />
+         <domain id="sec04T"  ibegin="29"  jbegin="80" ni="16" nj="1" />
+         <domain id="sec05T"  ibegin="25"  jbegin="88" ni="12" nj="1" />
+         <domain id="sec06T"  ibegin="25"  jbegin="91" ni="7" nj="1" />
+         <domain id="sec07T"  ibegin="25"  jbegin="92" ni="3" nj="1" />
+         <domain id="sec08T"  ibegin="57" jbegin="77" ni="4" nj="1" />
+         <domain id="sec09T"  ibegin="61" jbegin="62" ni="1"  nj="15" />
+
+         <domain id="sec00ST" ibegin="2"   jbegin="2"   ni="115" nj="1"   />
+         <domain id="sec00NT" ibegin="2"   jbegin="104" ni="115" nj="1"   />
+         <domain id="sec00WT" ibegin="2"   jbegin="2"   ni="1"   nj="103" />
+         <domain id="sec00ET" ibegin="116" jbegin="2"   ni="1"   nj="103" />
+
+	 <domain id="1point" domain_ref="grid_T" >
+           <zoom_domain id="1point" ibegin="139" jbegin="119" ni="1" nj="1" />
+	 </domain>
+         <!--   Eq section -->
+	 <domain id="EqT" domain_ref="grid_T" >
+           <zoom_domain id="EqT" ibegin="0" jbegin="0000" ni="0000" nj="1" />
+         </domain>
+         <!--   TAO : see example above   -->
+         <!--   137e   -->
+         <!-- <domain id="2n137eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n137eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n137eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   147e   -\-> -->
+         <!-- <domain id="0n147eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n147eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n147eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   156e   -\-> -->
+         <!-- <domain id="5s156eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s156eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n156eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n156eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n156eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n156eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   165e   -\-> -->
+         <!-- <domain id="8s165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n165eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   180w   -\-> -->
+         <!-- <domain id="8s180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n180wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   170w   -\-> -->
+         <!-- <domain id="8s170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n170wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   155w   -\-> -->
+         <!-- <domain id="8s155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n155wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   140w   -\-> -->
+         <!-- <domain id="8s140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n140wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   125w   -\-> -->
+         <!-- <domain id="8s125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n125wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   110w   -\-> -->
+         <!-- <domain id="8s110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n110wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   95w   -\-> -->
+         <!-- <domain id="8s95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2s95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="2n95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5n95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n95wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   RAMA   -\-> -->
+         <!-- <\!--   55e   -\-> -->
+         <!-- <domain id="16s55eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12s55eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8s55eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4s55eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5s55eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n55eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5n55eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4n55eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!--    <\!--   65e   -\-> -->
+         <!-- <domain id="15n65eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!--    <\!--   67e   -\-> -->
+         <!-- <domain id="16s67eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12s67eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8s67eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4s67eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5s67eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n67eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5n67eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4n67eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n67eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   80.5e   -\-> -->
+         <!-- <domain id="16s80.5eT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12s80.5eT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8s80.5eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4s80.5eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5s80.5eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n80.5eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5n80.5eT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4n80.5eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   90e   -\-> -->
+         <!-- <domain id="1.5s90eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n90eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="1.5n90eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4n90eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n90eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12n90eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="15n90eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   95e   -\-> -->
+         <!-- <domain id="16s95eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12s95eT"    domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8s95eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="5s95eT"     domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   PIRATA   -\-> -->
+         <!-- <\!--   38w-30w   -\-> -->
+         <!-- <domain id="19s34wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="14s32wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8s30wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n35wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4n38wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="8n38wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12n38wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="15n38wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="20n38wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   23w   -\-> -->
+         <!-- <domain id="0n23wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="4n23wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="12n23wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="21n23wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   10w   -\-> -->
+         <!-- <domain id="10s10wT" domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="6s10wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <domain id="0n10wT"  domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+         <!-- <\!--   0e   -\-> -->
+         <!-- <domain id="0n0eT"   domain_ref="grid_T" ibegin="0000" jbegin="0000" ni="1" nj="1" /> -->
+	 
+      </domain_group>
+
+      <domain_group id="grid_U">
+         <domain id="grid_U" long_name="grid U"/>
+	 <!--   My zoom: example of hand defined zoom   -->
+         <domain id="moorU"   ibegin="39" jbegin="82" ni="1"  nj="1" />
+         <domain id="sec01U"  ibegin="33"  jbegin="62" ni="28" nj="1" />
+         <domain id="sec02U"  ibegin="34" jbegin="68" ni="27" nj="1" />
+         <domain id="sec03U"  ibegin="29"  jbegin="75" ni="18" nj="1" />
+         <domain id="sec04U"  ibegin="29"  jbegin="80" ni="16" nj="1" />
+         <domain id="sec05U"  ibegin="25"  jbegin="88" ni="12" nj="1" />
+         <domain id="sec06U"  ibegin="25"  jbegin="91" ni="7" nj="1" />
+         <domain id="sec07U"  ibegin="25"  jbegin="92" ni="3" nj="1" />
+         <domain id="sec08U"  ibegin="57" jbegin="77" ni="4" nj="1" />
+         <domain id="sec09U"  ibegin="61" jbegin="62" ni="1"  nj="15" />
+
+         <domain id="sec00SU" ibegin="2"   jbegin="2"   ni="115" nj="1"   />
+         <domain id="sec00NU" ibegin="2"   jbegin="104" ni="115" nj="1"   />
+         <domain id="sec00WU" ibegin="2"   jbegin="2"   ni="1"   nj="103" />
+         <domain id="sec00EU" ibegin="116" jbegin="2"   ni="1"   nj="103" />
+         <!--   Eq section   -->
+         <domain id="EqU" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+
+      </domain_group>
+      
+      <domain_group id="grid_V">
+  	 <domain id="grid_V" long_name="grid V"/>
+ 	 <!--   My zoom: example of hand defined zoom   -->
+         <domain id="moorV"   ibegin="39" jbegin="82" ni="1"  nj="1" />
+         <domain id="sec01V"  ibegin="33"  jbegin="62" ni="28" nj="1" />
+         <domain id="sec02V"  ibegin="34" jbegin="68" ni="27" nj="1" />
+         <domain id="sec03V"  ibegin="29"  jbegin="75" ni="18" nj="1" />
+         <domain id="sec04V"  ibegin="29"  jbegin="80" ni="16" nj="1" />
+         <domain id="sec05V"  ibegin="25"  jbegin="88" ni="12" nj="1" />
+         <domain id="sec06V"  ibegin="25"  jbegin="91" ni="7" nj="1" />
+         <domain id="sec07V"  ibegin="25"  jbegin="92" ni="3" nj="1" />
+         <domain id="sec08V"  ibegin="57" jbegin="77" ni="4" nj="1" />
+         <domain id="sec09V"  ibegin="61" jbegin="62" ni="1"  nj="15" />
+
+         <domain id="sec00SV" ibegin="2"   jbegin="2"   ni="115" nj="1"   />
+         <domain id="sec00NV" ibegin="2"   jbegin="104" ni="115" nj="1"   />
+         <domain id="sec00WV" ibegin="2"   jbegin="2"   ni="1"   nj="103" />
+         <domain id="sec00EV" ibegin="116" jbegin="2"   ni="1"   nj="103" />
+      </domain_group>
+
+      <domain_group id="grid_W">
+         <domain id="grid_W" long_name="grid W"/>
+	 <!--   My zoom: example of hand defined zoom   -->
+         <domain id="moorW"   ibegin="39" jbegin="82" ni="1"  nj="1" />
+         <domain id="sec01W"  ibegin="33"  jbegin="62" ni="28" nj="1" />
+         <domain id="sec02W"  ibegin="34" jbegin="68" ni="27" nj="1" />
+         <domain id="sec03W"  ibegin="29"  jbegin="75" ni="18" nj="1" />
+         <domain id="sec04W"  ibegin="29"  jbegin="80" ni="16" nj="1" />
+         <domain id="sec05W"  ibegin="25"  jbegin="88" ni="12" nj="1" />
+         <domain id="sec06W"  ibegin="25"  jbegin="91" ni="7" nj="1" />
+         <domain id="sec07W"  ibegin="25"  jbegin="92" ni="3" nj="1" />
+         <domain id="sec08W"  ibegin="57" jbegin="77" ni="4" nj="1" />
+         <domain id="sec09W"  ibegin="61" jbegin="62" ni="1"  nj="15" />
+
+         <domain id="sec00SW" ibegin="2"   jbegin="2"   ni="115" nj="1"   />
+         <domain id="sec00NW" ibegin="2"   jbegin="104" ni="115" nj="1"   />
+         <domain id="sec00WW" ibegin="2"   jbegin="2"   ni="1"   nj="103" />
+         <domain id="sec00EW" ibegin="116" jbegin="2"   ni="1"   nj="103" />
+         <!--   Eq section   -->
+         <domain id="EqW" ibegin="1" jbegin="0000" ni="0000" nj="1" />
+      </domain_group>
+
+      <domain_group id="scalarpoint">
+         <domain id="scalarpoint" long_name="scalar"/>
+      </domain_group>
+
+      <domain_group id="gznl">
+        <domain id="gznl" long_name="gznl"/>
+        <domain id="ptr" domain_ref="gznl" >
+          <zoom_domain id="ptr" ibegin="0000" jbegin="0" ni="1" nj="0000" />
+        </domain>
+      </domain_group>
+      
+
+   </domain_definition>    
+ 
diff --git a/EXP_Apr19/field_def_nemo-lim.xml b/EXP_Apr19/field_def_nemo-lim.xml
new file mode 100755
index 0000000..556fe89
--- /dev/null
+++ b/EXP_Apr19/field_def_nemo-lim.xml
@@ -0,0 +1,182 @@
+<?xml version="1.0"?> 
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+   <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
+
+      <field_group id="SBC" grid_ref="grid_T_2D" > <!-- time step automaticaly defined based on nn_fsbc -->
+
+         <!-- LIM2(only) fields -->
+         <field id="qsr_ai_cea"   long_name="Air-Ice downward solar heat flux (cell average)"              standard_name="surface_downwelling_shortwave_flux_in_air"          unit="W/m2"         />
+         <field id="qns_ai_cea"   long_name="Air-Ice downward non-solar heat flux (cell average)"                                                                             unit="W/m2"         />
+         <field id="qla_ai_cea"   long_name="Air-Ice downward Latent heat flux (cell average)"             standard_name="surface_downward_latent_heat_flux"                  unit="W/m2"         />         
+         <field id="qsr_io_cea"   long_name="Ice-Oce downward solar heat flux (cell average)"              standard_name="net_downward_shortwave_flux_at_sea_water_surface"   unit="W/m2"         />
+         <field id="qns_io_cea"   long_name="Ice-Oce downward non-solar heat flux (cell average)"                                                                             unit="W/m2"         />
+         <field id="iceprod_cea"  long_name="Ice production (cell average)"                                                                                                   unit="m/s"          />
+         <field id="iiceconc"     long_name="Ice concentration"                                            standard_name="sea_ice_area_fraction"                              unit="1"            />
+         <field id="ice_pres"     long_name="Ice presence"                                                                                                                    unit=""             />
+         <field id="ist_cea"      long_name="Ice surface temperature (cell average)"                       standard_name="surface_temperature"                                unit="degC"         />
+         <field id="ist_ipa"      long_name="Ice surface temperature (ice presence average)"               standard_name="surface_temperature"                                unit="degC"         />
+         <field id="u_imasstr"    long_name="Sea-ice mass transport along i-axis"                          standard_name="sea_ice_x_transport"                                unit="kg/s"         />
+         <field id="v_imasstr"    long_name="Sea-ice mass transport along j-axis"                          standard_name="sea_ice_y_transport"                                unit="kg/s"         />
+
+         <!-- LIM3 fields -->  
+         <field id="ice_cover"    long_name="Ice fraction"                                                 standard_name="sea_ice_area_fraction"                              unit="1"            />
+ 
+         <field id="snowthic_cea" long_name="Snow thickness (cell average)"                                standard_name="surface_snow_thickness"                             unit="m"            />
+         <field id="icethic_cea"  long_name="Ice thickness (cell average)"                                 standard_name="sea_ice_thickness"                                  unit="m"            />
+
+         <field id="uice_ipa"     long_name="Ice velocity along i-axis at I-point (ice presence average)"  standard_name="sea_ice_x_velocity"                                 unit="m/s"          />      
+         <field id="vice_ipa"     long_name="Ice velocity along j-axis at I-point (ice presence average)"  standard_name="sea_ice_y_velocity"                                 unit="m/s"          />               
+         <field id="utau_ice"     long_name="Wind stress along i-axis over the ice at i-point"             standard_name="surface_downward_x_stress"                          unit="N/m2"         />
+         <field id="vtau_ice"     long_name="Wind stress along j-axis over the ice at i-point"             standard_name="surface_downward_y_stress"                          unit="N/m2"         />
+         
+         <field id="iceconc"      long_name="ice concentration"                                            standard_name="sea_ice_area_fraction"                              unit="%"            />
+       	 <field id="isst"         long_name="sea surface temperature"                                      standard_name="sea_surface_temperature"                            unit="degC"         />
+         <field id="isss"         long_name="sea surface salinity"                                         standard_name="sea_surface_salinity"                               unit="1e-3"         /> 
+         <field id="qt_oce"       long_name="total flux at ocean surface"                                  standard_name="surface_downward_heat_flux_in_sea_water"            unit="W/m2"         />
+         <field id="qsr_oce"      long_name="solar heat flux at ocean surface"                             standard_name="net_downward_shortwave_flux_at_sea_water_surface"   unit="W/m2"         />
+         <field id="qt_ice"       long_name="total heat flux at ice surface: sum over categories"          standard_name="surface_downward_heat_flux_in_air"                  unit="W/m2"         />
+         <field id="qsr_ice"      long_name="solar heat flux at ice surface: sum over categories"          standard_name="surface_downwelling_shortwave_flux_in_air"          unit="W/m2"         />
+         <field id="qns_ice"      long_name="non-solar heat flux at ice surface: sum over categories"                                                                         unit="W/m2"         />
+         <field id="qtr_ice"      long_name="solar heat flux transmitted through ice: sum over categories"                                                                    unit="W/m2"         />
+         <field id="qemp_ice"     long_name="Downward Heat Flux from E-P over ice"                                                                                            unit="W/m2"         />
+         <field id="micesalt"     long_name="Mean ice salinity"                                                                                                               unit="1e-3"         />
+         <field id="miceage"      long_name="Mean ice age"                                                                                                                    unit="years"        />
+         <field id="alb_ice"      long_name="Mean albedo over sea ice"                                                                                                        unit=""             />
+         <field id="albedo"       long_name="Mean albedo over sea ice and ocean"                                                                                              unit=""             />
+
+         <field id="iceage_cat"   long_name="Ice age for categories"                                       unit="days"   grid_ref="grid_T_3D_ncatice" />
+         <field id="iceconc_cat"  long_name="Ice concentration for categories"                             unit="%"      grid_ref="grid_T_3D_ncatice" />
+         <field id="icethic_cat"  long_name="Ice thickness for categories"                                 unit="m"      grid_ref="grid_T_3D_ncatice" />
+         <field id="snowthic_cat" long_name="Snow thicknessi for categories"                               unit="m"      grid_ref="grid_T_3D_ncatice" />
+         <field id="salinity_cat" long_name="Sea-Ice Bulk salinity for categories"                         unit="g/kg"   grid_ref="grid_T_3D_ncatice" />
+         <field id="brinevol_cat" long_name="Brine volume for categories"                                  unit="%"      grid_ref="grid_T_3D_ncatice" />
+         <field id="icetemp_cat"  long_name="Ice temperature for categories"                               unit="degC"   grid_ref="grid_T_3D_ncatice" />
+         <field id="snwtemp_cat"  long_name="Snow temperature for categories"                              unit="degC"   grid_ref="grid_T_3D_ncatice" />
+
+         <field id="micet"        long_name="Mean ice temperature"                                         unit="degC"     />
+         <field id="icehc"        long_name="ice total heat content"                                       unit="10^9J"    /> 
+         <field id="isnowhc"      long_name="snow total heat content"                                      unit="10^9J"    />
+         <field id="icest"        long_name="ice surface temperature"                                      unit="degC"     />
+         <field id="ibrinv"       long_name="brine volume"                                                 unit="%"        />
+         <field id="icecolf"      long_name="frazil ice collection thickness"                              unit="m"        />
+         <field id="icestr"       long_name="ice strength"                                                 unit="N/m"      />
+         <field id="icevel"       long_name="ice velocity"                                                 unit="m/s"      />
+         <field id="idive"        long_name="divergence"                                                   unit="1e-8s-1"  />
+         <field id="ishear"       long_name="shear"                                                        unit="1e-8s-1"  />
+         <field id="icevolu"      long_name="ice volume"                                                   unit="m"        />
+         <field id="snowvol"      long_name="snow volume"                                                  unit="m"        />
+         <field id="tau_icebfr"   long_name="ice friction on ocean bottom for landfast ice"                unit="N/2"      />
+
+         <field id="icetrp"       long_name="ice volume transport"                                         unit="m/day"          />
+         <field id="snwtrp"       long_name="snw volume transport"                                         unit="m/day"          />
+         <field id="saltrp"       long_name="salt content transport"                                       unit="1e-3*kg/m2/day" />
+         <field id="deitrp"       long_name="advected ice enthalpy"                                        unit="W/m2"           />
+         <field id="destrp"       long_name="advected snw enthalpy"                                        unit="W/m2"           />
+
+         <field id="sfxbri"       long_name="brine salt flux"                                              unit="1e-3*kg/m2/day" />
+         <field id="sfxdyn"       long_name="salt flux from ridging rafting"                               unit="1e-3*kg/m2/day" />
+         <field id="sfxres"       long_name="salt flux from lipupdate (resultant)"                         unit="1e-3*kg/m2/day" />
+         <field id="sfxbog"       long_name="salt flux from bot growth"                                    unit="1e-3*kg/m2/day" />
+         <field id="sfxbom"       long_name="salt flux from bot melt"                                      unit="1e-3*kg/m2/day" />
+         <field id="sfxsum"       long_name="salt flux from surf melt"                                     unit="1e-3*kg/m2/day" />
+         <field id="sfxlam"       long_name="salt flux from lateral melt"                                  unit="1e-3*kg/m2/day" />
+         <field id="sfxsni"       long_name="salt flux from snow-ice formation"                            unit="1e-3*kg/m2/day" />
+         <field id="sfxopw"       long_name="salt flux from open water ice formation"                      unit="1e-3*kg/m2/day" />
+         <field id="sfxsub"       long_name="salt flux from sublimation"                                   unit="1e-3*kg/m2/day" />
+         <field id="sfx"          long_name="salt flux total"                                              unit="1e-3*kg/m2/day" />
+
+         <field id="vfxbog"       long_name="daily bottom thermo ice prod."                                unit="m/day"   />
+         <field id="vfxdyn"       long_name="daily  dynamic ice prod."                                     unit="m/day"   />
+         <field id="vfxopw"       long_name="daily lateral thermo ice prod."                               unit="m/day"   />
+         <field id="vfxsni"       long_name="daily snowice ice prod."                                      unit="m/day"   />
+         <field id="vfxsum"       long_name="surface melt"                                                 unit="m/day"   />
+         <field id="vfxlam"       long_name="lateral melt"                                                 unit="m/day"   />
+         <field id="vfxbom"       long_name="bottom melt"                                                  unit="m/day"   />
+         <field id="vfxres"       long_name="daily resultant ice prod./melting from limupdate"             unit="m/day"   />
+         <field id="vfxice"       long_name="ice melt/growth"                                              unit="m/day"   />
+         <field id="vfxsnw"       long_name="snw melt/growth"                                              unit="m/day"   />
+         <field id="vfxsub"       long_name="snw sublimation"                                              unit="m/day"   />
+         <field id="vfxsub_err"   long_name="excess of snw sublimation sent to ocean"                      unit="m/day"   />
+         <field id="vfxspr"       long_name="snw precipitation on ice"                                     unit="m/day"   />
+         <field id="vfxthin"      long_name="daily thermo ice prod. for thin ice(20cm) + open water"      unit="m/day"   />
+
+         <field id="afxtot"       long_name="area tendency (total)"                                        unit="day-1"   />
+         <field id="afxdyn"       long_name="area tendency (dynamics)"                                     unit="day-1"   />
+         <field id="afxthd"       long_name="area tendency (thermo)"                                       unit="day-1"   />
+
+         <field id="hfxsum"       long_name="heat fluxes causing surface ice melt"                         unit="W/m2"  />
+         <field id="hfxbom"       long_name="heat fluxes causing bottom ice melt"                          unit="W/m2"  />
+         <field id="hfxbog"       long_name="heat fluxes causing bottom ice growth"                        unit="W/m2"  />
+         <field id="hfxdif"       long_name="heat fluxes causing ice temperature change"                   unit="W/m2"  />
+         <field id="hfxopw"       long_name="heat fluxes causing open water ice formation"                 unit="W/m2"  />
+         <field id="hfxsnw"       long_name="heat fluxes causing snow melt"                                unit="W/m2"  />
+         <field id="hfxerr"       long_name="heat fluxes error after heat diffusion"                       unit="W/m2"  />
+         <field id="hfxerr_rem"   long_name="heat fluxes error after remapping"                            unit="W/m2"  />
+         <field id="hfxout"       long_name="total heat fluxes received by the ocean"                      unit="W/m2"  />
+         <field id="hfxin"        long_name="total heat fluxes at the ice/ocean surface"                   unit="W/m2"  />
+
+         <!-- heat flux associated with mass exchange -->
+         <field id="hfxthd"       long_name="heat fluxes from ice-ocean mass exchange during thermo"       unit="W/m2"  />
+         <field id="hfxdyn"       long_name="heat fluxes from ice-ocean mass exchange during dynamic"      unit="W/m2"  />
+         <field id="hfxres"       long_name="heat fluxes from ice-ocean mass exchange during resultant"    unit="W/m2"  />
+         <field id="hfxsub"       long_name="heat fluxes from ice-atm. mass exchange during sublimation"   unit="W/m2"  />
+         <field id="hfxspr"       long_name="heat fluxes from ice-atm. mass exchange during snow precip"   unit="W/m2"  />
+
+         <!-- diags -->
+         <field id="hfxdhc"       long_name="Heat content variation in snow and ice"                       unit="W/m2" />
+         <field id="hfxtur"       long_name="turbulent heat flux at the ice base"                          unit="W/m2" />
+
+	 <!-- sbcssm variables -->
+         <field id="sst_m"    unit="degC" />
+         <field id="sss_m"    unit="psu"  />
+         <field id="ssu_m"    unit="m/s"  />
+         <field id="ssv_m"    unit="m/s"  />
+         <field id="ssh_m"    unit="m"    />
+         <field id="e3t_m"    unit="m"    />
+         <field id="frq_m"    unit="-"    />
+
+      </field_group>
+
+      <!-- LIM3 scalar variables -->
+      <field_group id="SBC_scalar"  grid_ref="grid_T_2D" >
+         <!-- available with ln_limdiaout -->
+         <field id="ibgfrcvoltop"    long_name="global mean ice/snow forcing at interface ice/snow-atm (volume equivalent ocean volume)"   unit="km3"       />
+         <field id="ibgfrcvolbot"    long_name="global mean ice/snow forcing at interface ice/snow-ocean (volume equivalent ocean volume)" unit="km3"       />
+         <field id="ibgfrctemtop"    long_name="global mean heat on top of ice/snw/ocean-atm "                                             unit="1e20J"     />
+         <field id="ibgfrctembot"    long_name="global mean heat below ice (on top of ocean) "                                             unit="1e20J"     />
+         <field id="ibgfrcsal"       long_name="global mean ice/snow forcing (salt equivalent ocean volume)"                               unit="pss*km3"   />
+         <field id="ibgfrchfxtop"    long_name="global mean heat flux on top of ice/snw/ocean-atm "                                        unit="W/m2"      />
+         <field id="ibgfrchfxbot"    long_name="global mean heat flux below ice (on top of ocean) "                                        unit="W/m2"      />
+ 
+         <field id="ibgvolume"       long_name="drift in ice/snow volume (equivalent ocean volume)"            unit="km3"        />
+         <field id="ibgsaltco"       long_name="drift in ice salt content (equivalent ocean volume)"           unit="pss*km3"    />
+         <field id="ibgheatco"       long_name="drift in ice/snow heat content"                                unit="1e20J"      />
+         <field id="ibgheatfx"       long_name="drift in ice/snow heat flux"                                   unit="W/m2"       />
+
+         <field id="ibgvol_tot"      long_name="global mean ice volume"                                        unit="km3"        />
+         <field id="sbgvol_tot"      long_name="global mean snow volume"                                       unit="km3"        />
+         <field id="ibgarea_tot"     long_name="global mean ice area"                                          unit="km2"        />
+         <field id="ibgsalt_tot"     long_name="global mean ice salt content"                                  unit="1e-3*km3"   />
+         <field id="ibgheat_tot"     long_name="global mean ice heat content"                                  unit="1e20J"      />
+         <field id="sbgheat_tot"     long_name="global mean snow heat content"                                 unit="1e20J"      />
+      </field_group>
+  
+      <!-- 
+============================================================================================================
+	-->
+      <!-- output variables for my configuration (example) --> 
+      
+      <field_group id="myvarICE" >
+         <field field_ref="icethic_cea"      name="sithic"     long_name="sea_ice_thickness"        />
+         <field field_ref="icevolu"          name="sivolu"  />
+         <field field_ref="iceconc"          name="siconc"  />
+      </field_group>    
+      
+   </field_definition>
diff --git a/EXP_Apr19/field_def_nemo-opa.xml b/EXP_Apr19/field_def_nemo-opa.xml
new file mode 100755
index 0000000..65a6e78
--- /dev/null
+++ b/EXP_Apr19/field_def_nemo-opa.xml
@@ -0,0 +1,1107 @@
+<?xml version="1.0"?> 
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+   <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
+
+    <!-- 
+============================================================================================================
+                                  Physical ocean model variables
+============================================================================================================
+    -->
+
+      <!-- T grid -->
+      
+      <field_group id="grid_T" grid_ref="grid_T_2D" >
+         <field id="e3t"          long_name="T-cell thickness"   standard_name="cell_thickness"   unit="m"   grid_ref="grid_T_3D"/>
+         <field id="e3t_surf"     long_name="T-cell thickness"   field_ref="e3t"  standard_name="cell_thickness"   unit="m"   grid_ref="grid_T_SFC"/>
+         <field id="e3t_0"        long_name="Initial T-cell thickness"   standard_name="ref_cell_thickness"   unit="m"   grid_ref="grid_T_3D"/>
+
+         <field id="toce"         long_name="temperature"         standard_name="sea_water_potential_temperature"   unit="degC"     grid_ref="grid_T_3D"/>
+         <field id="toce_e3t"     long_name="temperature (thickness weighted)"                                      unit="degC"     grid_ref="grid_T_3D" > toce * e3t </field >
+         <field id="soce"         long_name="salinity"            standard_name="sea_water_practical_salinity"      unit="1e-3"     grid_ref="grid_T_3D"/>
+         <field id="soce_e3t"     long_name="salinity    (thickness weighted)"                                      unit="1e-3"     grid_ref="grid_T_3D" > soce * e3t </field >
+
+         <!-- t-eddy viscosity coefficients (ldfdyn) -->
+	 <field id="ahmt_2d"      long_name=" surface t-eddy viscosity coefficient"   unit="m2/s or m4/s" />
+	 <field id="ahmt_3d"      long_name=" 3D      t-eddy viscosity coefficient"   unit="m2/s or m4/s"                           grid_ref="grid_T_3D"/>
+
+         <field id="sst"          long_name="sea surface temperature"             standard_name="sea_surface_temperature"             unit="degC"     />
+         <field id="sst2"         long_name="square of sea surface temperature"   standard_name="square_of_sea_surface_temperature"   unit="degC2"     > sst * sst </field >
+         <field id="sstmax"       long_name="max of sea surface temperature"   field_ref="sst"   operation="maximum"                                  />
+         <field id="sstmin"       long_name="min of sea surface temperature"   field_ref="sst"   operation="minimum"                                  />
+         <field id="sstgrad"      long_name="module of sst gradient"                                                                  unit="degC/m"   />
+         <field id="sstgrad2"     long_name="square of module of sst gradient"                                                        unit="degC2/m2" />
+         <field id="sbt"          long_name="sea bottom temperature"                                                                  unit="degC"     />
+         <field id="tosmint"      long_name="vertical integral of temperature times density"   standard_name="integral_wrt_depth_of_product_of_density_and_potential_temperature"  unit="(kg m2) degree_C" />
+         <field id="sst_wl"       long_name="Delta SST of warm layer"                                                                 unit="degC"     />
+         <field id="sst_cs"       long_name="Delta SST of cool skin"                                                                  unit="degC"     />
+	 <field id="temp_3m"      long_name="temperature at 3m"                                                                       unit="degC"     />
+         
+         <field id="sss"          long_name="sea surface salinity"             standard_name="sea_surface_salinity"   unit="1e-3" />
+         <field id="sss2"         long_name="square of sea surface salinity"                                          unit="1e-6"  > sss * sss </field >
+         <field id="sssmax"       long_name="max of sea surface salinity"   field_ref="sss"   operation="maximum"                 />
+         <field id="sssmin"       long_name="min of sea surface salinity"   field_ref="sss"   operation="minimum"                 />
+         <field id="sbs"          long_name="sea bottom salinity"                                                     unit="0.001" />
+         <field id="somint"       long_name="vertical integral of salinity times density"   standard_name="integral_wrt_depth_of_product_of_density_and_salinity"  unit="(kg m2) x (1e-3)" /> 
+
+         <field id="taubot"       long_name="bottom stress module"                                                    unit="N/m2" /> 
+
+         <field id="ssh"          long_name="sea surface height"             standard_name="sea_surface_height_above_geoid"             unit="m" />
+         <field id="ssh2"         long_name="square of sea surface height"   standard_name="square_of_sea_surface_height_above_geoid"   unit="m2" > ssh * ssh </field >
+         <field id="wetdep"       long_name="wet depth"                      standard_name="wet_depth"                unit="m" />
+         <field id="sshmax"       long_name="max of sea surface height"   field_ref="ssh"   operation="maximum"                                  />
+
+         <field id="mldkz5"       long_name="Turbocline depth (Kz = 5e-4)"                       standard_name="ocean_mixed_layer_thickness_defined_by_vertical_tracer_diffusivity"                unit="m"          />
+         <field id="mldr10_1"     long_name="Mixed Layer Depth (dsigma = 0.01 wrt 10m)"          standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"          />
+         <field id="mldr10_1max"  long_name="Max of Mixed Layer Depth (dsigma = 0.01 wrt 10m)"   field_ref="mldr10_1"   operation="maximum"                                                                          />
+         <field id="mldr10_1min"  long_name="Min of Mixed Layer Depth (dsigma = 0.01 wrt 10m)"   field_ref="mldr10_1"   operation="minimum"                                                                          />
+         <field id="heatc"        long_name="Heat content vertically integrated"                 standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"       />
+         <field id="saltc"        long_name="Salt content vertically integrated"                                                                                                                   unit="1e-3*kg/m2" />
+
+         <!-- EOS -->
+         <field id="alpha"        long_name="thermal expansion"                                                         unit="degC-1" grid_ref="grid_T_3D" />
+         <field id="beta"         long_name="haline contraction"                                                        unit="1e3"    grid_ref="grid_T_3D" />
+         <field id="bn2"          long_name="squared Brunt-Vaisala frequency"                                           unit="s-1"    grid_ref="grid_T_3D" />
+         <field id="rhop"         long_name="potential density (sigma0)"        standard_name="sea_water_sigma_theta"   unit="kg/m3"  grid_ref="grid_T_3D" />
+
+         <!-- Energy - horizontal divergence -->
+         <field id="eken"         long_name="kinetic energy"          standard_name="specific_kinetic_energy_of_sea_water"   unit="m2/s2"  grid_ref="grid_T_3D" />
+         <field id="hdiv"         long_name="horizontal divergence"                                                          unit="s-1"    grid_ref="grid_T_3D" />
+
+         <!-- variables available with MLE -->
+         <field id="Lf_NHpf"      long_name="MLE: Lf = N H / f"   unit="m" />
+
+         <!-- next variables available with key_diahth -->
+         <field id="mlddzt"       long_name="Thermocline Depth (depth of max dT/dz)"         standard_name="depth_at_maximum_upward_derivative_of_sea_water_potential_temperature"             unit="m"                         />
+         <field id="mldr10_3"     long_name="Mixed Layer Depth (dsigma = 0.03 wrt 10m)"      standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="mldr0_1"      long_name="Mixed Layer Depth (dsigma = 0.01 wrt sfc)"      standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="mldr0_3"      long_name="Mixed Layer Depth (dsigma = 0.03 wrt sfc)"      standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="mld_dt02"     long_name="Mixed Layer Depth (|dT| = 0.2 wrt 10m)"         standard_name="ocean_mixed_layer_thickness_defined_by_temperature"                                unit="m"                         />
+         <field id="topthdep"     long_name="Top of Thermocline Depth (dT = -0.2 wrt 10m)"   standard_name="ocean_mixed_layer_thickness_defined_by_temperature"                                unit="m"                         />
+         <field id="pycndep"      long_name="Pycnocline Depth (dsigma[dT=-0.2] wrt 10m)"     standard_name="ocean_mixed_layer_thickness_defined_by_sigma_theta"                                unit="m"                         />
+         <field id="BLT"          long_name="Barrier Layer Thickness"                                                                                                                          unit="m"                          > topthdep - pycndep </field>
+         <field id="tinv"         long_name="Max of vertical invertion of temperature"                                                                                                         unit="degC"                      />
+         <field id="depti"        long_name="Depth of max. vert. inv. of temperature"                                                                                                          unit="m"                         />
+         <field id="20d"          long_name="Depth of 20C isotherm"                          standard_name="depth_of_isosurface_of_sea_water_potential_temperature"                            unit="m"      axis_ref="iax_20C" />
+         <field id="28d"          long_name="Depth of 28C isotherm"                          standard_name="depth_of_isosurface_of_sea_water_potential_temperature"                            unit="m"      axis_ref="iax_28C" />
+         <field id="hc300"        long_name="Heat content 0-300m"                            standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"                      />
+
+         <!-- variables available with diaar5 -->
+         <field id="botpres"      long_name="Sea Water Pressure at Sea Floor"   standard_name="sea_water_pressure_at_sea_floor"   unit="dbar" />
+         <field id="sshdyn"       long_name="dynamic sea surface height"     standard_name="dynamic_sea_surface_height_above_geoid"     unit="m" />
+         <field id="sshdyn2"      long_name="square of dynamic sea surface height"     standard_name="dynamic_sea_surface_height_above_geoid_squared"     unit="m2" > sshdyn * sshdyn </field>
+         <field id="tnpeo"      long_name="Tendency of ocean potential energy content"          unit="W/m2"                           />
+
+         <!-- variables available ln_linssh=.FALSE. -->
+         <field id="tpt_dep"      long_name="T-point depth"                  standard_name="depth_below_geoid"   unit="m"   grid_ref="grid_T_3D" />
+         <field id="e3tdef"       long_name="T-cell thickness deformation"                                       unit="%"   grid_ref="grid_T_3D" />
+      </field_group>
+
+      <!-- Tides -->
+
+      <field_group id="Tides_T" grid_ref="grid_T_2D" operation="once" >
+         <!-- tidal composante -->
+         <field id="M2x"          long_name="M2 Elevation harmonic real part "                             unit="m"        />
+         <field id="M2y"          long_name="M2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="S2x"          long_name="S2 Elevation harmonic real part "                             unit="m"        />
+         <field id="S2y"          long_name="S2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="N2x"          long_name="N2 Elevation harmonic real part "                             unit="m"        />
+         <field id="N2y"          long_name="N2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="K1x"          long_name="K1 Elevation harmonic real part "                             unit="m"        />
+         <field id="K1y"          long_name="K1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="O1x"          long_name="O1 Elevation harmonic real part "                             unit="m"        />
+         <field id="O1y"          long_name="O1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="Q1x"          long_name="Q1 Elevation harmonic real part "                             unit="m"        />
+         <field id="Q1y"          long_name="Q1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="M4x"          long_name="M4 Elevation harmonic real part "                             unit="m"        />
+         <field id="M4y"          long_name="M4 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="K2x"          long_name="K2 Elevation harmonic real part "                             unit="m"        />
+         <field id="K2y"          long_name="K2 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="P1x"          long_name="P1 Elevation harmonic real part "                             unit="m"        />
+         <field id="P1y"          long_name="P1 Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="Mfx"          long_name="Mf Elevation harmonic real part "                             unit="m"        />
+         <field id="Mfy"          long_name="Mf Elevation harmonic imaginary part"                         unit="m"        />
+         <field id="Mmx"          long_name="Mm Elevation harmonic real part "                             unit="m"        />
+         <field id="Mmy"          long_name="Mm Elevation harmonic imaginary part"                         unit="m"        />
+        
+	 <field id="M2amp"        long_name="M2 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="M2phase"      long_name="M2 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="S2amp"        long_name="S2 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="S2phase"      long_name="S2 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="N2amp"        long_name="N2 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="N2phase"      long_name="N2 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="K1amp"        long_name="K1 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="K1phase"      long_name="K1 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="O1amp"        long_name="O1 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="O1phase"      long_name="O1 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="Q1amp"        long_name="Q1 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="Q1phase"      long_name="Q1 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="M4amp"        long_name="M4 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="M4phase"      long_name="M4 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="MS4amp"        long_name="MS4 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="MS4phase"      long_name="MS4 Elevation harmonic Phase"                                  unit="degree"   />
+                                                                           
+         <field id="MN4amp"        long_name="MN4 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="MN4phase"      long_name="MN4 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="K2amp"        long_name="K2 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="K2phase"      long_name="K2 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="P1amp"        long_name="P1 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="P1phase"      long_name="P1 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="Mfamp"        long_name="Mf Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="Mfphase"      long_name="Mf Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="Mmamp"        long_name="Mm Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="Mmphase"      long_name="Mm Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="T2amp"        long_name="T2 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="T2phase"      long_name="T2 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="L2amp"        long_name="L2 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="L2phase"      long_name="L2 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="S1amp"        long_name="S1 Elevation harmonic Amplitude"                              unit="m"        />
+         <field id="S1phase"      long_name="S1 Elevation harmonic Phase"                                  unit="degree"   />
+
+         <field id="2N2amp"       long_name="2N2 Elevation harmonic Amplitude"                             unit="m"        />
+         <field id="2N2phase"     long_name="2N2 Elevation harmonic Phase"                                 unit="degree"   />
+
+         <field id="MU2amp"       long_name="MU2 Elevation harmonic Amplitude"                             unit="m"        />
+         <field id="MU2phase"     long_name="MU2 Elevation harmonic Phase"                                 unit="degree"   />
+
+         <field id="NU2amp"       long_name="NU2 Elevation harmonic Amplitude"                             unit="m"        />
+         <field id="NU2phase"     long_name="NU2 Elevation harmonic Phase"                                 unit="degree"   />
+                                                                                                   
+      </field_group>
+	 
+      <field_group id="Tides_U" grid_ref="grid_U_2D" operation="once" >
+         <field id="M2x_u"        long_name="M2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="M2y_u"        long_name="M2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="S2x_u"        long_name="S2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="S2y_u"        long_name="S2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="N2x_u"        long_name="N2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="N2y_u"        long_name="N2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K1x_u"        long_name="K1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="K1y_u"        long_name="K1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="O1x_u"        long_name="O1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="O1y_u"        long_name="O1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Q1x_u"        long_name="Q1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="Q1y_u"        long_name="Q1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="M4x_u"        long_name="M4 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="M4y_u"        long_name="M4 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K2x_u"        long_name="K2 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="K2y_u"        long_name="K2 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="P1x_u"        long_name="P1 current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="P1y_u"        long_name="P1 current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mfx_u"        long_name="Mf current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="Mfy_u"        long_name="Mf current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mmx_u"        long_name="Mm current barotrope along i-axis harmonic real part "        unit="m/s"      />
+         <field id="Mmy_u"        long_name="Mm current barotrope along i-axis harmonic imaginary part "   unit="m/s"      />
+      
+         <field id="M2amp_u2D"      long_name="M2 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="M2phase_u2D"    long_name="M2 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="S2amp_u2D"      long_name="S2 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="S2phase_u2D"    long_name="S2 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="N2amp_u2D"      long_name="N2 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="N2phase_u2D"    long_name="N2 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="K1amp_u2D"      long_name="K1 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="K1phase_u2D"    long_name="K1 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="O1amp_u2D"      long_name="O1 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="O1phase_u2D"    long_name="O1 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="Q1amp_u2D"      long_name="Q1 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="Q1phase_u2D"    long_name="Q1 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="M4amp_u2D"      long_name="M4 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="M4phase_u2D"    long_name="M4 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="MS4amp_u2D"      long_name="MS4 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="MS4phase_u2D"    long_name="MS4 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="MN4amp_u2D"      long_name="MN4 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="MN4phase_u2D"    long_name="MN4 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="K2amp_u2D"      long_name="K2 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="K2phase_u2D"    long_name="K2 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="P1amp_u2D"      long_name="P1 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="P1phase_u2D"    long_name="P1 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="Mfamp_u2D"      long_name="Mf U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="Mfphase_u2D"    long_name="Mf U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="Mmamp_u2D"      long_name="Mm U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="Mmphase_u2D"    long_name="Mm U barotropic harmonic Phase"                               unit="degree"   />
+         <field id="T2amp_u2D"      long_name="T2 U barotropic harmonic Amplitude"                           unit="m/s"      />
+
+         <field id="T2phase_u2D"    long_name="T2 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="L2amp_u2D"      long_name="L2 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="L2phase_u2D"    long_name="L2 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="S1amp_u2D"      long_name="S1 U barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="S1phase_u2D"    long_name="S1 U barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="2N2amp_u2D"     long_name="2N2 U barotropic harmonic Amplitude"                          unit="m/s"      />
+         <field id="2N2phase_u2D"   long_name="2N2 U barotropic harmonic Phase"                              unit="degree"   />
+
+         <field id="MU2amp_u2D"     long_name="MU2 U barotropic harmonic Amplitude"                          unit="m/s"      />
+         <field id="MU2phase_u2D"   long_name="MU2 U barotropic harmonic Phase"                              unit="degree"   />
+
+         <field id="NU2amp_u2D"     long_name="NU2 U barotropic harmonic Amplitude"                          unit="m/s"      />
+         <field id="NU2phase_u2D"   long_name="NU2 U barotropic harmonic Phase"                              unit="degree"   />
+
+      </field_group>
+	 
+      <field_group id="Tides_V" grid_ref="grid_V_2D" operation="once" >
+         <field id="M2x_v"        long_name="M2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="M2y_v"        long_name="M2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="S2x_v"        long_name="S2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="S2y_v"        long_name="S2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="N2x_v"        long_name="N2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="N2y_v"        long_name="N2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K1x_v"        long_name="K1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="K1y_v"        long_name="K1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="O1x_v"        long_name="O1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="O1y_v"        long_name="O1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Q1x_v"        long_name="Q1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="Q1y_v"        long_name="Q1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="M4x_v"        long_name="M4 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="M4y_v"        long_name="M4 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="K2x_v"        long_name="K2 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="K2y_v"        long_name="K2 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="P1x_v"        long_name="P1 current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="P1y_v"        long_name="P1 current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mfx_v"        long_name="Mf current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="Mfy_v"        long_name="Mf current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />
+         <field id="Mmx_v"        long_name="Mm current barotrope along j-axis harmonic real part "        unit="m/s"      />
+         <field id="Mmy_v"        long_name="Mm current barotrope along j-axis harmonic imaginary part "   unit="m/s"      />	 
+
+         <field id="M2amp_v2D"      long_name="M2 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="M2phase_v2D"    long_name="M2 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="S2amp_v2D"      long_name="S2 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="S2phase_v2D"    long_name="S2 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="N2amp_v2D"      long_name="N2 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="N2phase_v2D"    long_name="N2 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="K1amp_v2D"      long_name="K1 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="K1phase_v2D"    long_name="K1 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="O1amp_v2D"      long_name="O1 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="O1phase_v2D"    long_name="O1 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="Q1amp_v2D"      long_name="Q1 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="Q1phase_v2D"    long_name="Q1 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="M4amp_v2D"      long_name="M4 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="M4phase_v2D"    long_name="M4 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="MS4amp_v2D"      long_name="MS4 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="MS4phase_v2D"    long_name="MS4 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="MN4amp_v2D"      long_name="MN4 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="MN4phase_v2D"    long_name="MN4 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="K2amp_v2D"      long_name="K2 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="K2phase_v2D"    long_name="K2 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="P1amp_v2D"      long_name="P1 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="P1phase_v2D"    long_name="P1 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="Mfamp_v2D"      long_name="Mf V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="Mfphase_v2D"    long_name="Mf V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="Mmamp_v2D"      long_name="Mm V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="Mmphase_v2D"    long_name="Mm V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="T2amp_v2D"      long_name="T2 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="T2phase_v2D"    long_name="T2 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="L2amp_v2D"      long_name="L2 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="L2phase_v2D"    long_name="L2 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="S1amp_v2D"      long_name="S1 V barotropic harmonic Amplitude"                           unit="m/s"      />
+         <field id="S1phase_v2D"    long_name="S1 V barotropic harmonic Phase"                               unit="degree"   />
+
+         <field id="2N2amp_v2D"     long_name="2N2 V barotropic harmonic Amplitude"                          unit="m/s"      />
+         <field id="2N2phase_v2D"   long_name="2N2 V barotropic harmonic Phase"                              unit="degree"   />
+
+         <field id="MU2amp_v2D"     long_name="MU2 V barotropic harmonic Amplitude"                          unit="m/s"      />
+         <field id="MU2phase_v2D"   long_name="MU2 V barotropic harmonic Phase"                              unit="degree"   />
+
+         <field id="NU2amp_v2D"     long_name="NU2 V barotropic harmonic Amplitude"                          unit="m/s"      />
+         <field id="NU2phase_v2D"   long_name="NU2 V barotropic harmonic Phase"                              unit="degree"   />
+
+      </field_group>
+
+      <!-- SBC -->
+      
+      <field_group id="SBC" grid_ref="grid_T_2D" > <!-- time step automaticaly defined based on nn_fsbc -->
+         <field id="empmr"        long_name="Net Upward Water Flux"                standard_name="water_flux_out_of_sea_ice_and_sea_water"                              unit="kg/m2/s"   />
+         <field id="empbmr"       long_name="Net Upward Water Flux at pre. tstep"  standard_name="water_flux_out_of_sea_ice_and_sea_water"                              unit="kg/m2/s"   />
+         <field id="emp_oce"      long_name="Evap minus Precip over ocean"         standard_name="evap_minus_precip_over_sea_water"                                     unit="kg/m2/s"   />
+         <field id="emp_ice"      long_name="Evap minus Precip over ice"           standard_name="evap_minus_precip_over_sea_ice"                                       unit="kg/m2/s"   />
+         <field id="saltflx"      long_name="Downward salt flux"                                                                                                        unit="1e-3/m2/s" />
+         <field id="fmmflx"       long_name="Water flux due to freezing/melting"                                                                                        unit="kg/m2/s"   />
+         <field id="snowpre"      long_name="Snow precipitation"                   standard_name="snowfall_flux"                                                        unit="kg/m2/s"   />
+         <field id="runoffs"      long_name="River Runoffs"                        standard_name="water_flux_into_sea_water_from_rivers"                                unit="kg/m2/s"   />
+         <field id="precip"       long_name="Total precipitation"                  standard_name="precipitation_flux"                                                   unit="kg/m2/s"   />
+ 
+         <field id="qt"           long_name="Net Downward Heat Flux"                standard_name="surface_downward_heat_flux_in_sea_water"                              unit="W/m2"                           />
+         <field id="qns"          long_name="non solar Downward Heat Flux"                                                                                               unit="W/m2"                           />
+         <field id="qsr"          long_name="Shortwave Radiation"                   standard_name="net_downward_shortwave_flux_at_sea_water_surface"                     unit="W/m2"                           />
+         <field id="qsr3d"        long_name="Shortwave Radiation 3D distribution"   standard_name="downwelling_shortwave_flux_in_sea_water"                              unit="W/m2"      grid_ref="grid_T_3D" />
+         <field id="qrp"          long_name="Surface Heat Flux: Damping"            standard_name="heat_flux_into_sea_water_due_to_newtonian_relaxation"                 unit="W/m2"                           />
+         <field id="erp"          long_name="Surface Water Flux: Damping"           standard_name="water_flux_out_of_sea_water_due_to_newtonian_relaxation"              unit="kg/m2/s"                        />
+         <field id="taum"         long_name="wind stress module"                    standard_name="magnitude_of_surface_downward_stress"                                 unit="N/m2"                           />
+         <field id="wspd"         long_name="wind speed module"                     standard_name="wind_speed"                                                           unit="m/s"                            />
+         <field id="uwnd"         long_name="u component of wind"       unit="m/s"          grid_ref="grid_U_2D"     />
+         <field id="vwnd"         long_name="v component of wind"       unit="m/s"          grid_ref="grid_V_2D"    />
+         
+         <!-- * variable relative to atmospheric pressure forcing : available with ln_apr_dyn -->
+         <field id="ssh_ib"       long_name="Inverse barometer sea surface height"  standard_name="sea_surface_height_correction_due_to_air_pressure_at_low_frequency"   unit="m"        />
+
+         <!-- * variable related to ice shelf forcing * -->
+         <field id="fwfisf"       long_name="Ice shelf melting"                             unit="kg/m2/s"  />
+         <field id="fwfisf3d"     long_name="Ice shelf melting"                             unit="kg/m2/s"  grid_ref="grid_T_3D" />
+         <field id="qlatisf"      long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
+         <field id="qlatisf3d"    long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+         <field id="qhcisf"       long_name="Ice shelf heat content flux"                   unit="W/m2"     />
+         <field id="qhcisf3d"     long_name="Ice shelf heat content flux"                   unit="W/m2"     grid_ref="grid_T_3D" />
+         <field id="isfgammat"    long_name="transfert coefficient for isf (temperature) "  unit="m/s"      />
+         <field id="isfgammas"    long_name="transfert coefficient for isf (salinity)    "  unit="m/s"      />
+         <field id="stbl"         long_name="salinity in the Losh tbl                    "  unit="PSU"      />
+         <field id="ttbl"         long_name="temperature in the Losh tbl                 "  unit="C"        />
+         <field id="utbl"         long_name="zonal current in the Losh tbl at T point    "  unit="m/s"      />
+         <field id="vtbl"         long_name="merid current in the Losh tbl at T point    "  unit="m/s"      />
+         <field id="thermald"     long_name="thermal driving of ice shelf melting        "  unit="C"        />
+         <field id="tfrz"         long_name="top freezing point (used to compute melt)   "  unit="C"        />
+         <field id="tinsitu"      long_name="top insitu temperature (used to cmpt melt)  "  unit="C"        />
+         <field id="ustar"        long_name="ustar at T point used in ice shelf melting  "  unit="m/s"      />
+
+         <!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
+         <field id="qlw_oce"      long_name="Longwave Downward Heat Flux over open ocean"  standard_name="surface_net_downward_longwave_flux"   unit="W/m2"  />
+         <field id="qsb_oce"      long_name="Sensible Downward Heat Flux over open ocean"  standard_name="surface_downward_sensible_heat_flux"  unit="W/m2"  />
+         <field id="qla_oce"      long_name="Latent Downward Heat Flux over open ocean"    standard_name="surface_downward_latent_heat_flux"    unit="W/m2"  />
+         <field id="qemp_oce"     long_name="Downward Heat Flux from E-P over open ocean"                                                       unit="W/m2"  />
+         <field id="taum_oce"     long_name="wind stress module over open ocean"           standard_name="magnitude_of_surface_downward_stress" unit="N/m2"  />
+         <field id="qns_oce"      long_name="Downward non-solar heat flux"                                                                      unit="W/m2"  />
+         <field id="qsr_oce"      long_name="Downward solar heat flux"                                                                          unit="W/m2"  />
+         <field id="qt_oce"       long_name="total flux at ocean surface"    standard_name="surface_downward_heat_flux_in_sea_water"            unit="W/m2"  />  
+       <!-- available key_oasis3 -->
+         <field id="snow_ao_cea"  long_name="Snow over ice-free ocean (cell average)"   standard_name="snowfall_flux"                             unit="kg/m2/s"  />
+         <field id="snow_ai_cea"  long_name="Snow over sea-ice (cell average)"          standard_name="snowfall_flux"                             unit="kg/m2/s"  />
+         <field id="subl_ai_cea"  long_name="Sublimation over sea-ice (cell average)"   standard_name="surface_snow_and_ice_sublimation_flux"     unit="kg/m2/s"  />
+         <field id="icealb_cea"   long_name="Ice albedo (cell average)"                 standard_name="sea_ice_albedo"                            unit="1"        />
+         <field id="calving_cea"  long_name="Calving"                                   standard_name="water_flux_into_sea_water_from_icebergs"   unit="kg/m2/s"  />
+         <field id="iceberg_cea"  long_name="Iceberg"                                   standard_name="water_flux_into_sea_water_from_icebergs"   unit="kg/m2/s"  />
+         <field id="iceshelf_cea" long_name="Iceshelf"                                  standard_name="water_flux_into_sea_water_from_iceshelf"   unit="kg/m2/s"  />
+
+
+         <!-- available if key_oasis3 + conservative method -->
+         <field id="rain"          long_name="Liquid precipitation"                                     standard_name="rainfall_flux"                                                                 unit="kg/m2/s"  />
+         <field id="evap_ao_cea"   long_name="Evaporation over ice-free ocean (cell average)"           standard_name="water_evaporation_flux"                                                        unit="kg/m2/s"  />
+         <field id="isnwmlt_cea"   long_name="Snow over Ice melting (cell average)"                     standard_name="surface_snow_melt_flux"                                                        unit="kg/m2/s"  />
+         <field id="fsal_virt_cea" long_name="Virtual salt flux due to ice formation (cell average)"    standard_name="virtual_salt_flux_into_sea_water_due_to_sea_ice_thermodynamics"                unit="kg/m2/s"  />
+         <field id="fsal_real_cea" long_name="Real salt flux due to ice formation (cell average)"       standard_name="downward_sea_ice_basal_salt_flux"                                              unit="kg/m2/s"  />
+         <field id="hflx_rain_cea" long_name="heat flux due to rainfall"                                standard_name="temperature_flux_due_to_rainfall_expressed_as_heat_flux_into_sea_water"        unit="W/m2"     />
+         <field id="hflx_evap_cea" long_name="heat flux due to evaporation"                             standard_name="temperature_flux_due_to_evaporation_expressed_as_heat_flux_out_of_sea_water"   unit="W/m2"     />
+         <field id="hflx_snow_cea" long_name="heat flux due to snow falling"                            standard_name="heat_flux_onto_ocean_and_ice_due_to_snow_thermodynamics"                       unit="W/m2"     />
+         <field id="hflx_snow_ai_cea" long_name="heat flux due to snow falling over ice"                standard_name="heat_flux_onto_ice_due_to_snow_thermodynamics"                                 unit="W/m2"     />
+         <field id="hflx_snow_ao_cea" long_name="heat flux due to snow falling over ice-free ocean"     standard_name="heat_flux_onto_sea_water_due_to_snow_thermodynamics"                           unit="W/m2"     />
+         <field id="hflx_ice_cea"  long_name="heat flux due to ice thermodynamics"                      standard_name="heat_flux_into_sea_water_due_to_sea_ice_thermodynamics"                        unit="W/m2"     />
+         <field id="hflx_rnf_cea"  long_name="heat flux due to runoffs"                                 standard_name="temperature_flux_due_to_runoff_expressed_as_heat_flux_into_sea_water"          unit="W/m2"     />
+         <field id="hflx_cal_cea"  long_name="heat flux due to calving"                                 standard_name="heat_flux_into_sea_water_due_to_calving"                                       unit="W/m2"     />
+         <field id="hflx_icb_cea"  long_name="heat flux due to iceberg"                                 standard_name="heat_flux_into_sea_water_due_to_icebergs"                                      unit="W/m2"     />
+         <field id="hflx_isf_cea"  long_name="heat flux due to iceshelf"                                standard_name="heat_flux_into_sea_water_due_to_iceshelf"                                      unit="W/m2"     />
+         <field id="bicemel_cea"   long_name="Rate of Melt at Sea Ice Base (cell average)"              standard_name="tendency_of_sea_ice_amount_due_to_basal_melting"                               unit="kg/m2/s"  />
+         <field id="licepro_cea"   long_name="Lateral Sea Ice Growth Rate (cell average)"               standard_name="tendency_of_sea_ice_amount_due_to_lateral_growth_of_ice_floes"                 unit="kg/m2/s"  />
+         <field id="snowmel_cea"   long_name="Snow Melt Rate (cell average)"                            standard_name="surface_snow_melt_flux"                                                        unit="kg/m2/s"  />
+         <field id="sntoice_cea"   long_name="Snow-Ice Formation Rate (cell average)"                   standard_name="tendency_of_sea_ice_amount_due_to_snow_conversion"                             unit="kg/m2/s"  />
+         <field id="ticemel_cea"   long_name="Rate of Melt at Upper Surface of Sea Ice (cell average)"  standard_name="tendency_of_sea_ice_amount_due_to_surface_melting"                             unit="kg/m2/s"  />
+
+         <!-- ice field (nn_ice=1)  -->
+         <field id="ice_cover"    long_name="Ice fraction"                                                 standard_name="sea_ice_area_fraction"                              unit="1"            />
+         
+         <!-- dilution -->
+         <field id="emp_x_sst"    long_name="Concentration/Dilution term on SST"                                                                                              unit="kg*degC/m2/s" />
+         <field id="emp_x_sss"    long_name="Concentration/Dilution term on SSS"                                                                                              unit="kg*1e-3/m2/s" />        
+         <field id="rnf_x_sst"    long_name="Runoff term on SST"                                                                                                              unit="kg*degC/m2/s" />
+         <field id="rnf_x_sss"    long_name="Runoff term on SSS"                                                                                                              unit="kg*1e-3/m2/s" />
+       
+	 <!-- sbcssm variables -->
+         <field id="sst_m"    unit="degC" />
+         <field id="sss_m"    unit="psu"  />
+         <field id="ssu_m"    unit="m/s"  />
+         <field id="ssv_m"    unit="m/s"  />
+         <field id="ssh_m"    unit="m"    />
+         <field id="e3t_m"    unit="m"    />
+         <field id="frq_m"    unit="-"    />
+
+      </field_group>
+
+      <!-- U grid -->
+      
+      <field_group id="grid_U"   grid_ref="grid_U_2D">
+         <field id="e3u"          long_name="U-cell thickness"                                       standard_name="cell_thickness"              unit="m"          grid_ref="grid_U_3D" />
+         <field id="e3u_0"        long_name="Initial U-cell thickness"                               standard_name="ref_cell_thickness"          unit="m"          grid_ref="grid_U_3D"/>
+         <field id="utau"         long_name="Wind Stress along i-axis"                               standard_name="surface_downward_x_stress"   unit="N/m2"                            />
+         <field id="uoce"         long_name="ocean current along i-axis"                             standard_name="sea_water_x_velocity"        unit="m/s"        grid_ref="grid_U_3D" />
+         <field id="uoce_e3u"     long_name="ocean current along i-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_U_3D"  > uoce * e3u </field>
+         <field id="ssu"          long_name="ocean surface current along i-axis"                                                                 unit="m/s"                             />
+         <field id="sbu"          long_name="ocean bottom current along i-axis"                                                                  unit="m/s"                             />
+         <field id="ubar"         long_name="ocean barotropic current along i-axis"                                                              unit="m/s"                             />
+         <field id="uocetr_eff"   long_name="Effective ocean transport along i-axis"                 standard_name="ocean_volume_x_transport"    unit="m3/s"       grid_ref="grid_U_3D" />
+         <field id="uocet"        long_name="ocean transport along i-axis times temperature (CRS)"                                               unit="degC*m/s"   grid_ref="grid_U_3D" />
+         <field id="uoces"        long_name="ocean transport along i-axis times salinity (CRS)"                                                  unit="1e-3*m/s"   grid_ref="grid_U_3D" />
+
+         <!-- u-eddy coefficients (ldftra) -->
+         <field id="ahtu_2d"      long_name=" surface u-eddy diffusivity coefficient"   unit="m2/s or m4/s" />
+         <field id="ahtu_3d"      long_name=" 3D u-EIV coefficient"                     unit="m2/s or m4/s"      grid_ref="grid_U_3D"/>
+         <field id="aeiu_2d"      long_name=" surface u-EIV coefficient"                unit="m2/s" />
+         <field id="aeiu_3d"      long_name=" 3D u-EIV coefficient"                     unit="m2/s"              grid_ref="grid_U_3D"/>
+
+         <!-- variables available with MLE -->
+         <field id="psiu_mle"     long_name="MLE streamfunction along i-axis"   unit="m3/s"   grid_ref="grid_U_3D" />
+
+         <!-- uoce_eiv: available EIV -->
+         <field id="uoce_eiv"     long_name="EIV ocean current along i-axis"   standard_name="bolus_sea_water_x_velocity"   unit="m/s"   grid_ref="grid_U_3D" />
+
+         <!-- uoce_eiv: available with key_trabbl -->
+         <field id="uoce_bbl"     long_name="BBL ocean current along i-axis"    unit="m/s"  />
+         <field id="ahu_bbl"      long_name="BBL diffusive flux along i-axis"   unit="m3/s" />
+
+         <!-- variable for ice shelves -->
+         <field id="utbl"         long_name="zonal current in the Losh tbl"     unit="m/s" />
+
+         <field id="u_masstr"     long_name="Ocean Mass X Transport"    standard_name="ocean_mass_x_transport"                          unit="kg/s"        grid_ref="grid_U_3D" />
+         <field id="u_masstr_vint" long_name="vertical integral of ocean eulerian mass transport along i-axis"    standard_name="vertical_integral_of_ocean_mass_x_transport"  unit="kg/s" />
+         <field id="u_heattr"     long_name="ocean eulerian heat transport along i-axis"    standard_name="ocean_heat_x_transport"                          unit="W"                                />
+         <field id="u_salttr"     long_name="ocean eulerian salt transport along i-axis"    standard_name="ocean_salt_x_transport"                          unit="1e-3*kg/s"                        />
+         <field id="uadv_heattr"  long_name="ocean advective heat transport along i-axis"    standard_name="advectice_ocean_heat_x_transport"               unit="W"                                />
+         <field id="uadv_salttr"  long_name="ocean advective salt transport along i-axis"    standard_name="advectice_ocean_salt_x_transport"               unit="1e-3*kg/s"                      />
+         <field id="ueiv_heattr"  long_name="ocean bolus heat transport along i-axis"       standard_name="ocean_heat_x_transport_due_to_bolus_advection"   unit="W"                                />
+         <field id="ueiv_salttr"  long_name="ocean bolus salt transport along i-axis"       standard_name="ocean_salt_x_transport_due_to_bolus_advection"   unit="Kg"                                />
+         <field id="ueiv_heattr3d" long_name="ocean bolus heat transport along i-axis"    standard_name="ocean_heat_x_transport_due_to_bolus_advection"   unit="W"    grid_ref="grid_U_3D" />
+         <field id="ueiv_salttr3d" long_name="ocean bolus salt transport along i-axis"    standard_name="ocean_salt_x_transport_due_to_bolus_advection"   unit="kg"   grid_ref="grid_U_3D" />
+         <field id="udiff_heattr" long_name="ocean diffusion heat transport along i-axis"   standard_name="ocean_heat_x_transport_due_to_diffusion"         unit="W"                                />
+         <field id="udiff_salttr" long_name="ocean diffusion salt transport along i-axis"   standard_name="ocean_salt_x_transport_due_to_diffusion"         unit="1e-3*kg/s"                                />
+      </field_group>
+      
+      <!-- V grid -->
+      
+      <field_group id="grid_V"   grid_ref="grid_V_2D">
+         <field id="e3v"          long_name="V-cell thickness"                                       standard_name="cell_thickness"              unit="m"          grid_ref="grid_V_3D" />
+         <field id="e3v_0"        long_name="Initial V-cell thickness"                               standard_name="ref_cell_thickness"          unit="m"          grid_ref="grid_V_3D"/>
+         <field id="vtau"         long_name="Wind Stress along j-axis"                               standard_name="surface_downward_y_stress"   unit="N/m2"                            />
+         <field id="voce"         long_name="ocean current along j-axis"                             standard_name="sea_water_y_velocity"        unit="m/s"        grid_ref="grid_V_3D" />
+         <field id="voce_e3v"     long_name="ocean current along j-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_V_3D"  > voce * e3v </field>
+         <field id="ssv"          long_name="ocean surface current along j-axis"                                                                 unit="m/s"                             />
+         <field id="sbv"          long_name="ocean bottom current along j-axis"                                                                  unit="m/s"                             />
+         <field id="vbar"         long_name="ocean barotropic current along j-axis"                                                              unit="m/s"                             />
+         <field id="vocetr_eff"   long_name="Effective ocean transport along j-axis"                 standard_name="ocean_volume_y_transport"    unit="m3/s"       grid_ref="grid_V_3D" />
+         <field id="vocet"        long_name="ocean transport along j-axis times temperature (CRS)"                                               unit="degC*m/s"   grid_ref="grid_V_3D" />
+         <field id="voces"        long_name="ocean transport along j-axis times salinity (CRS)"                                                  unit="1e-3*m/s"   grid_ref="grid_V_3D" />
+
+         <!-- v-eddy coefficients (ldftra, ldfdyn) -->
+         <field id="ahtv_2d"      long_name=" surface v-eddy diffusivity coefficient"     unit="m2/s or (m4/s)^1/2" />
+         <field id="ahtv_3d"      long_name=" 3D v-eddy diffusivity coefficient"          unit="m2/s or (m4/s)^1/2"           grid_ref="grid_V_3D"/>
+         <field id="aeiv_2d"      long_name=" surface v-EIV coefficient"                  unit="m2/s" />
+         <field id="aeiv_3d"      long_name=" 3D v-EIV coefficient"                       unit="m2/s"                         grid_ref="grid_V_3D" />
+
+         <!-- variables available with MLE -->
+         <field id="psiv_mle"     long_name="MLE streamfunction along j-axis"   unit="m3/s"   grid_ref="grid_V_3D" />
+
+         <!-- voce_eiv: available with EIV -->
+         <field id="voce_eiv"     long_name="EIV ocean current along j-axis"   standard_name="bolus_sea_water_y_velocity"   unit="m/s"   grid_ref="grid_V_3D" />
+
+         <!-- voce_eiv: available with key_trabbl -->
+         <field id="voce_bbl"     long_name="BBL ocean current along j-axis"    unit="m/s"  />
+         <field id="ahv_bbl"      long_name="BBL diffusive flux along j-axis"   unit="m3/s" />
+
+         <!-- variable for ice shelves -->
+         <field id="vtbl"         long_name="meridional current in the Losh tbl"   unit="m/s" />
+
+         <!-- variables available with diaar5 -->
+         <field id="v_masstr"     long_name="ocean eulerian mass transport along j-axis"    standard_name="ocean_mass_y_transport"                          unit="kg/s"        grid_ref="grid_V_3D" />
+         <field id="v_heattr"     long_name="ocean eulerian heat transport along j-axis"    standard_name="ocean_heat_y_transport"                          unit="W"                                />
+         <field id="v_salttr"     long_name="ocean eulerian salt transport along i-axis"    standard_name="ocean_salt_y_transport"                          unit="1e-3*kg/s"                        />
+         <field id="vadv_heattr"  long_name="ocean advective heat transport along j-axis"   standard_name="advectice_ocean_heat_y_transport"                unit="W"                      />
+         <field id="vadv_salttr"  long_name="ocean advective salt transport along j-axis"   standard_name="advectice_ocean_salt_y_transport"                unit="1e-3*kg/s"              />
+         <field id="veiv_heattr"  long_name="ocean bolus heat transport along j-axis"       standard_name="ocean_heat_y_transport_due_to_bolus_advection"   unit="W"                                />
+         <field id="veiv_salttr"  long_name="ocean bolus salt transport along j-axis"       standard_name="ocean_salt_x_transport_due_to_bolus_advection"   unit="Kg"                                />
+         <field id="veiv_heattr3d" long_name="ocean bolus heat transport along j-axis"    standard_name="ocean_heat_y_transport_due_to_bolus_advection"   unit="W"    grid_ref="grid_V_3D" />
+         <field id="veiv_salttr3d" long_name="ocean bolus salt transport along j-axis"    standard_name="ocean_salt_y_transport_due_to_bolus_advection"   unit="kg"   grid_ref="grid_V_3D" />
+         <field id="vdiff_heattr" long_name="ocean diffusion heat transport along j-axis"   standard_name="ocean_heat_y_transport_due_to_diffusion"         unit="W"                                />
+         <field id="vdiff_salttr" long_name="ocean diffusion salt transport along j-axis"   standard_name="ocean_salt_y_transport_due_to_diffusion"         unit="1e-3*kg/s"                        />
+      </field_group>
+      
+      <!-- W grid -->
+      
+      <field_group id="grid_W" grid_ref="grid_W_3D">
+         <field id="e3w"          long_name="W-cell thickness"                     standard_name="cell_thickness"              unit="m"    />
+         <field id="woce"         long_name="ocean vertical velocity"              standard_name="upward_sea_water_velocity"   unit="m/s"  />
+         <field id="wocetr_eff"   long_name="effective ocean vertical transport"                                               unit="m3/s" />
+
+         <!-- woce_eiv: available with EIV -->
+         <field id="woce_eiv"     long_name="EIV ocean vertical velocity"   standard_name="bolus_upward_sea_water_velocity"   unit="m/s" />
+
+         <field id="avt"          long_name="vertical eddy diffusivity"   standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
+         <field id="logavt"       long_name="logarithm of vertical eddy diffusivity"   standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
+         <field id="avm"          long_name="vertical eddy viscosity"     standard_name="ocean_vertical_momentum_diffusivity"   unit="m2/s" />
+
+         <!-- avs: available with key_zdfddm -->
+         <field id="avs"          long_name="salt vertical eddy diffusivity"   standard_name="ocean_vertical_salt_diffusivity"   unit="m2/s" />
+         <field id="logavs"       long_name="logarithm of salt vertical eddy diffusivity"   standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
+
+         <!-- avt_evd and avm_evd: available with ln_zdfevd -->
+         <field id="avt_evd"      long_name="convective enhancement of vertical diffusivity"   standard_name="ocean_vertical_tracer_diffusivity_due_to_convection"     unit="m2/s" />
+         <field id="avm_evd"      long_name="convective enhancement of vertical viscosity"     standard_name="ocean_vertical_momentum_diffusivity_due_to_convection"   unit="m2/s" />
+
+         <!-- avt_tide: available with key_zdftmx -->
+         <field id="av_tide"      long_name="tidal vertical diffusivity"   standard_name="ocean_vertical_tracer_diffusivity_due_to_tides"   unit="m2/s" />
+
+         <!-- variables available with key_zdftmx_new -->
+         <field id="av_ratio"     long_name="S over T diffusivity ratio"            standard_name="salinity_over_temperature_diffusivity_ratio"                     unit="1"    />
+         <field id="av_wave"      long_name="wave-induced vertical diffusivity"     standard_name="ocean_vertical_tracer_diffusivity_due_to_internal_waves"         unit="m2/s" />
+         <field id="bflx_tmx"     long_name="wave-induced buoyancy flux"            standard_name="buoyancy_flux_due_to_internal_waves"                             unit="W/kg" />
+         <field id="pcmap_tmx"    long_name="power consumed by wave-driven mixing"  standard_name="vertically_integrated_power_consumption_by_wave_driven_mixing"   unit="W/m2"      grid_ref="grid_W_2D" />
+         <field id="emix_tmx"     long_name="power density available for mixing"    standard_name="power_available_for_mixing_from_breaking_internal_waves"         unit="W/kg" />
+
+         <!-- variables available with diaar5 -->   
+         <field id="w_masstr"     long_name="vertical mass transport"             standard_name="upward_ocean_mass_transport"             unit="kg/s"   />
+         <field id="w_masstr2"    long_name="square of vertical mass transport"   standard_name="square_of_upward_ocean_mass_transport"   unit="kg2/s2" />
+
+         <!-- aht2d and  aht2d_eiv -->
+         <field id="aht2d"        long_name="lateral eddy diffusivity"       standard_name="ocean_tracer_xy_laplacian_diffusivity"      unit="m2/s"   grid_ref="grid_W_2D" />
+         <field id="aht2d_eiv"    long_name="EIV lateral eddy diffusivity"   standard_name="ocean_tracer_bolus_laplacian_diffusivity"   unit="m2/s"   grid_ref="grid_W_2D" />
+
+      </field_group>
+        
+      <!-- F grid -->
+      <!-- f-eddy viscosity coefficients (ldfdyn) -->
+      <field id="ahmf_2d"      long_name=" surface f-eddy viscosity coefficient"   unit="m2/s or m4/s" />
+      <field id="ahmf_3d"      long_name=" 3D      f-eddy viscosity coefficient"   unit="m2/s or m4/s"                           grid_ref="grid_T_3D"/>
+
+      <field_group id="scalar"  grid_ref="grid_T_2D"  >
+         <field id="voltot"     long_name="global total volume"                          standard_name="sea_water_volume"                               unit="m3"   />
+         <field id="sshtot"     long_name="global mean ssh"                              standard_name="global_average_sea_level_change"                unit="m"    />
+         <field id="sshsteric"  long_name="global mean ssh steric"                       standard_name="global_average_steric_sea_level_change"         unit="m"    />
+         <field id="sshthster"  long_name="global mean ssh thermosteric"                 standard_name="global_average_thermosteric_sea_level_change"   unit="m"    />
+         <field id="masstot"    long_name="global total mass"                            standard_name="sea_water_mass"                                 unit="kg"   />
+         <field id="temptot"    long_name="global mean temperature"                      standard_name="sea_water_potential_temperature"                unit="degC" />
+         <field id="saltot"     long_name="global mean salinity"                         standard_name="sea_water_salinity"                             unit="1e-3" />
+         <field id="fram_trans" long_name="Sea Ice Mass Transport Through Fram Strait"   standard_name="sea_ice_transport_across_line"                  unit="kg/s" />
+
+      	 <!-- available with ln_diahsb -->
+         <field id="bgtemper"     long_name="drift in global mean temperature wrt timestep 1"                 standard_name="change_over_time_in_sea_water_potential_temperature"   unit="degC"     />
+         <field id="bgsaline"     long_name="drift in global mean salinity wrt timestep 1"                    standard_name="change_over_time_in_sea_water_practical_salinity"      unit="1e-3"     />
+         <field id="bgheatco"     long_name="drift in global mean heat content wrt timestep 1"                                                                                      unit="1.e20J"   />
+         <field id="bgheatfx"     long_name="drift in global mean heat flux    wrt timestep 1"                                                                                      unit="W/m2"     />
+         <field id="bgsaltco"     long_name="drift in global mean salt content wrt timestep 1"                                                                                      unit="1e-3*km3" />
+         <field id="bgvolssh"     long_name="drift in global mean ssh volume wrt timestep 1"                                                                                        unit="km3"      />
+         <field id="bgvole3t"     long_name="drift in global mean volume variation (e3t) wrt timestep 1"                                                                            unit="km3"      />
+         <field id="bgfrcvol"     long_name="global mean volume from forcing"                                                                                                       unit="km3"      />
+         <field id="bgfrctem"     long_name="global mean heat content from forcing"                                                                                                 unit="1.e20J"   />
+         <field id="bgfrchfx"     long_name="global mean heat flux from forcing"                                                                                                    unit="W/m2"     />
+         <field id="bgfrcsal"     long_name="global mean salt content from forcing"                                                                                                 unit="1e-3*km3" />
+         <field id="bgmistem"     long_name="global mean temperature error due to free surface (linssh true)"                                                                            unit="degC"     />
+         <field id="bgmissal"     long_name="global mean salinity error due to free surface (linssh true)"                                                                               unit="1e-3"     />
+      </field_group>
+  
+      <!-- variables available with key_float -->
+
+      <field_group id="floatvar" grid_ref="grid_T_nfloat"  operation="instant" >
+         <field id="traj_lon"      long_name="floats longitude"                                                           unit="degrees_east"  />
+         <field id="traj_lat"      long_name="floats latitude"                                                            unit="degrees_north" />
+         <field id="traj_dep"      long_name="floats depth"                                                               unit="m"             />
+         <field id="traj_temp"     long_name="floats temperature"       standard_name="sea_water_potential_temperature"   unit="degC"          />
+         <field id="traj_salt"     long_name="floats salinity"          standard_name="sea_water_practical_salinity"      unit="1e-3"          />
+         <field id="traj_dens"     long_name="floats in-situ density"   standard_name="sea_water_density"                 unit="kg/m3"         />
+         <field id="traj_group"    long_name="floats group"                                                               unit="1"             />
+      </field_group>
+
+      <!-- variables available with iceberg trajectories -->
+
+      <field_group id="icbvar" domain_ref="grid_T"  > 
+         <field id="berg_melt"          long_name="icb melt rate of icebergs"                       unit="kg/m2/s"                    />
+         <field id="berg_buoy_melt"     long_name="icb buoyancy component of iceberg melt rate"     unit="kg/m2/s"                    />
+         <field id="berg_eros_melt"     long_name="icb erosion component of iceberg melt rate"      unit="kg/m2/s"                    />
+         <field id="berg_conv_melt"     long_name="icb convective component of iceberg melt rate"   unit="kg/m2/s"                    />
+         <field id="berg_virtual_area"  long_name="icb virtual coverage by icebergs"                unit="m2"                         />
+         <field id="bits_src"           long_name="icb mass source of bergy bits"                   unit="kg/m2/s"                    />
+         <field id="bits_melt"          long_name="icb melt rate of bergy bits"                     unit="kg/m2/s"                    />
+         <field id="bits_mass"          long_name="icb bergy bit density field"                     unit="kg/m2"                      />
+         <field id="berg_mass"          long_name="icb iceberg density field"                       unit="kg/m2"                      />
+         <field id="calving"            long_name="icb calving mass input"                          unit="kg/s"                       />
+         <field id="berg_floating_melt" long_name="icb melt rate of icebergs + bits"                unit="kg/m2/s"                    />
+         <field id="berg_real_calving"  long_name="icb calving into iceberg class"                  unit="kg/s"     axis_ref="icbcla" />
+         <field id="berg_stored_ice"    long_name="icb accumulated ice mass by class"               unit="kg"       axis_ref="icbcla" />
+      </field_group>
+
+      <!-- Poleward transport : ptr -->     
+      <field_group id="diaptr" >  
+         <field id="zomsfglo"          long_name="Meridional Stream-Function: Global"           unit="Sv"       grid_ref="gznl_W_3D" />
+         <field id="zomsfatl"          long_name="Meridional Stream-Function: Atlantic"         unit="Sv"       grid_ref="gznl_W_3D" />
+         <field id="zomsfpac"          long_name="Meridional Stream-Function: Pacific"          unit="Sv"       grid_ref="gznl_W_3D" />
+         <field id="zomsfind"          long_name="Meridional Stream-Function: Indian"           unit="Sv"       grid_ref="gznl_W_3D" />
+         <field id="zomsfipc"          long_name="Meridional Stream-Function: Pacific+Indian"   unit="Sv"       grid_ref="gznl_W_3D" />
+         <field id="zotemglo"          long_name="Zonal Mean Temperature : Global"              unit="degree_C"     grid_ref="gznl_T_3D" />
+         <field id="zotematl"          long_name="Zonal Mean Temperature : Atlantic"            unit="degree_C"     grid_ref="gznl_T_3D" />
+         <field id="zotempac"          long_name="Zonal Mean Temperature : Pacific"             unit="degree_C"     grid_ref="gznl_T_3D" />
+         <field id="zotemind"          long_name="Zonal Mean Temperature : Indian"              unit="degree_C"     grid_ref="gznl_T_3D" />
+         <field id="zotemipc"          long_name="Zonal Mean Temperature : Pacific+Indian"      unit="degree_C"     grid_ref="gznl_T_3D" />
+         <field id="zosalglo"          long_name="Zonal Mean Salinity : Global"                 unit="0.001"     grid_ref="gznl_T_3D" />
+         <field id="zosalatl"          long_name="Zonal Mean Salinity : Atlantic"               unit="0.001"     grid_ref="gznl_T_3D" />
+         <field id="zosalpac"          long_name="Zonal Mean Salinity : Pacific"                unit="0.001"     grid_ref="gznl_T_3D" />
+         <field id="zosalind"          long_name="Zonal Mean Salinity : Indian"                 unit="0.001"     grid_ref="gznl_T_3D" />
+         <field id="zosalipc"          long_name="Zonal Mean Salinity : Pacific+Indian"         unit="0.001"     grid_ref="gznl_T_3D" />
+         <field id="zosrfglo"          long_name="Zonal Mean Surface"                           unit="m2"       grid_ref="gznl_T_3D" />
+         <field id="zosrfatl"          long_name="Zonal Mean Surface : Atlantic"                unit="m2"       grid_ref="gznl_T_3D" />
+         <field id="zosrfpac"          long_name="Zonal Mean Surface : Pacific"                 unit="m2"       grid_ref="gznl_T_3D" />
+         <field id="zosrfind"          long_name="Zonal Mean Surface : Indian"                  unit="m2"       grid_ref="gznl_T_3D" />
+         <field id="zosrfipc"          long_name="Zonal Mean Surface : Pacific+Indian"          unit="m2"       grid_ref="gznl_T_3D" />
+         <field id="sophtadv"          long_name="Advective Heat Transport"                     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtadv_atl"      long_name="Advective Heat Transport: Atlantic"           unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtadv_pac"      long_name="Advective Heat Transport: Pacific"            unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtadv_ind"      long_name="Advective Heat Transport: Indian"             unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtadv_ipc"      long_name="Advective Heat Transport: Pacific+Indian"     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtldf"          long_name="Diffusive Heat Transport"                     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtldf_atl"      long_name="Diffusive Heat Transport: Atlantic"           unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtldf_pac"      long_name="Diffusive Heat Transport: Pacific"            unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtldf_ind"      long_name="Diffusive Heat Transport: Indian"             unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtldf_ipc"      long_name="Diffusive Heat Transport: Pacific+Indian"     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtove"          long_name="Overturning Heat Transport"                     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtove_atl"      long_name="Overturning Heat Transport: Atlantic"           unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtove_pac"      long_name="Overturning Heat Transport: Pacific"            unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtove_ind"      long_name="Overturning Heat Transport: Indian"             unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtove_ipc"      long_name="Overturning Heat Transport: Pacific+Indian"     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtbtr"          long_name="Barotropic Heat Transport"                     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtbtr_atl"      long_name="Barotropic Heat Transport: Atlantic"           unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtbtr_pac"      long_name="Barotropic Heat Transport: Pacific"            unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtbtr_ind"      long_name="Barotropic Heat Transport: Indian"             unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophtbtr_ipc"      long_name="Barotropic Heat Transport: Pacific+Indian"     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophteiv"          long_name="Heat Transport from mesoscale eddy advection"                     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophteiv_atl"      long_name="Heat Transport from mesoscale eddy advection: Atlantic"           unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophteiv_pac"      long_name="Heat Transport from mesoscale eddy advection: Pacific"            unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophteiv_ind"      long_name="Heat Transport from mesoscale eddy advection: Indian"             unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sophteiv_ipc"      long_name="Heat Transport from mesoscale eddy advection: Pacific+Indian"     unit="PW"       grid_ref="gznl_T_2D" />
+         <field id="sopstadv"          long_name="Advective Salt Transport"                     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstadv_atl"      long_name="Advective Salt Transport: Atlantic"           unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstadv_pac"      long_name="Advective Salt Transport: Pacific"            unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstadv_ind"      long_name="Advective Salt Transport: Indian"             unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstadv_ipc"      long_name="Advective Salt Transport: Pacific+Indian"     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstove"          long_name="Overturning Salt Transport"                     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstove_atl"      long_name="Overturning Salt Transport: Atlantic"           unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstove_pac"      long_name="Overturning Salt Transport: Pacific"            unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstove_ind"      long_name="Overturning Salt Transport: Indian"             unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstove_ipc"      long_name="Overturning Salt Transport: Pacific+Indian"     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstbtr"          long_name="Barotropic Salt Transport"                     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstbtr_atl"      long_name="Barotropic Salt Transport: Atlantic"           unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstbtr_pac"      long_name="Barotropic Salt Transport: Pacific"            unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstbtr_ind"      long_name="Barotropic Salt Transport: Indian"             unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstbtr_ipc"      long_name="Barotropic Salt Transport: Pacific+Indian"     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstldf"          long_name="Diffusive Salt Transport"                     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstldf_atl"      long_name="Diffusive Salt Transport: Atlantic"           unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstldf_pac"      long_name="Diffusive Salt Transport: Pacific"            unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstldf_ind"      long_name="Diffusive Salt Transport: Indian"             unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopstldf_ipc"      long_name="Diffusive Salt Transport: Pacific+Indian"     unit="Giga g/s" grid_ref="gznl_T_2D" />
+         <field id="sopsteiv"          long_name="Salt Transport from mesoscale eddy advection"                     unit="Giga g/s"       grid_ref="gznl_T_2D" />
+          <field id="sopsteiv_atl"      long_name="Salt Transport from mesoscale eddy advection: Atlantic"           unit="Giga g/s"       grid_ref="gznl_T_2D" />
+         <field id="sopsteiv_pac"      long_name="Salt Transport from mesoscale eddy advection: Pacific"            unit="Giga g/s"       grid_ref="gznl_T_2D" />
+         <field id="sopsteiv_ind"      long_name="Salt Transport from mesoscale eddy advection: Indian"             unit="Giga g/s"       grid_ref="gznl_T_2D" />
+         <field id="sopsteiv_ipc"      long_name="Salt Transport from mesoscale eddy advection: Pacific+Indian"     unit="Giga g/s"       grid_ref="gznl_T_2D" />       
+      </field_group>
+
+    <!-- 
+============================================================================================================
+                  Physical ocean model trend diagnostics : temperature, KE, PE, momentum
+============================================================================================================
+    -->
+
+   <!-- variables available with ln_tra_trd -->
+   <!-- Asselin trends  calculated on odd time steps-->
+   <field_group id="trendT_odd"  grid_ref="grid_T_3D">
+      <field id="ttrd_atf"      long_name="temperature-trend: asselin time filter"       unit="degree_C/s" />
+      <field id="strd_atf"      long_name="salinity   -trend: asselin time filter"       unit="0.001/s" />
+      <!-- Thickness weighted versions: -->
+      <field id="ttrd_atf_e3t"      unit="degC/s * m"  >  ttrd_atf * e3t </field>
+      <field id="strd_atf_e3t"      unit="1e-3/s * m"  >  strd_atf * e3t </field>
+      <!-- OMIP  layer-integrated trends -->
+      <field id="ttrd_atf_li"      long_name="layer integrated heat-trend: asselin time filter "       unit="W/m^2" > ttrd_atf_e3t * 1026.0 * 3991.86795711963  </field>
+      <field id="strd_atf_li"      long_name="layer integrated salt   -trend: asselin time filter "       unit="kg/(m^2 s)" > strd_atf_e3t * 1026.0 * 0.001 </field>
+    </field_group>
+
+    <!-- Other trends  calculated on even time steps-->
+    <field_group id="trendT_even" grid_ref="grid_T_3D">
+       <field id="ttrd_xad"      long_name="temperature-trend: i-advection"                                                                                          unit="degC/s"                        />
+       <field id="strd_xad"      long_name="salinity   -trend: i-advection"                                                                                          unit="1e-3/s"                        />
+       <field id="ttrd_yad"      long_name="temperature-trend: j-advection"                                                                                          unit="degC/s"                        />
+       <field id="strd_yad"      long_name="salinity   -trend: j-advection"                                                                                          unit="1e-3/s"                        />
+       <field id="ttrd_zad"      long_name="temperature-trend: k-advection"                                                                                          unit="degC/s"                        />
+       <field id="strd_zad"      long_name="salinity   -trend: k-advection"                                                                                          unit="1e-3/s"                        />
+       <field id="ttrd_ad"       long_name="temperature-trend: advection"               standard_name="tendency_of_sea_water_temperature_due_to_advection"           unit="degC/s"                         > sqrt( ttrd_xad^2 + ttrd_yad^2 + ttrd_zad^2 ) </field>
+       <field id="strd_ad"       long_name="salinity   -trend: advection"               standard_name="tendency_of_sea_water_salinity_due_to_advection"              unit="1e-3/s"                         > sqrt( strd_xad^2 + strd_yad^2 + strd_zad^2 ) </field>
+       <field id="ttrd_totad"    long_name="temperature-trend: total advection"         standard_name="tendency_of_sea_water_salinity_due_to_advection"              unit="degC/s"                        />
+       <field id="strd_totad"    long_name="salinity   -trend: total advection"         standard_name="tendency_of_sea_water_salinity_due_to_advection"              unit="1e-3/s"                        />
+       <field id="ttrd_sad"      long_name="temperature-trend: surface adv. (linssh true)"                                                                                unit="degC/s"   grid_ref="grid_T_2D" />
+       <field id="strd_sad"      long_name="salinity   -trend: surface adv. (linssh true)"                                                                                unit="1e-3/s"   grid_ref="grid_T_2D" />
+       <field id="ttrd_ldf"      long_name="temperature-trend: lateral  diffusion"      standard_name="tendency_of_sea_water_temperature_due_to_horizontal_mixing"   unit="degC/s"                        />
+       <field id="strd_ldf"      long_name="salinity   -trend: lateral  diffusion"      standard_name="tendency_of_sea_water_salinity_due_to_horizontal_mixing"      unit="1e-3/s"                        />
+       <field id="ttrd_zdf"      long_name="temperature-trend: vertical diffusion"      standard_name="tendency_of_sea_water_temperature_due_to_vertical_mixing"     unit="degC/s"                        />
+       <field id="strd_zdf"      long_name="salinity   -trend: vertical diffusion"      standard_name="tendency_of_sea_water_salinity_due_to_vertical_mixing"        unit="1e-3/s"                        />
+       <field id="ttrd_evd"      long_name="temperature-trend: EVD convection"                                                                                       unit="degC/s"                        />
+       <field id="strd_evd"      long_name="salinity   -trend: EVD convection"                                                                                       unit="1e-3/s"                        />
+
+       <!-- ln_traldf_iso=T only (iso-neutral diffusion) -->
+       <field id="ttrd_iso"      long_name="temperature-trend: isopycnal diffusion"                             unit="degC/s" > ttrd_ldf + ttrd_zdf - ttrd_zdfp </field>
+       <field id="strd_iso"      long_name="salinity   -trend: isopycnal diffusion"                             unit="1e-3/s" > strd_ldf + strd_zdf - strd_zdfp </field>
+       <field id="ttrd_zdfp"     long_name="temperature-trend: pure vert. diffusion"   unit="degC/s" />
+       <field id="strd_zdfp"     long_name="salinity   -trend: pure vert. diffusion"   unit="1e-3/s" />
+
+       <!-- -->
+       <field id="ttrd_dmp"      long_name="temperature-trend: interior restoring"        unit="degC/s" />
+       <field id="strd_dmp"      long_name="salinity   -trend: interior restoring"        unit="1e-3/s" />
+       <field id="ttrd_bbl"      long_name="temperature-trend: bottom boundary layer"     unit="degC/s" />
+       <field id="strd_bbl"      long_name="salinity   -trend: bottom boundary layer"     unit="1e-3/s" />
+       <field id="ttrd_npc"      long_name="temperature-trend: non-penetrative conv."     unit="degC/s" />
+       <field id="strd_npc"      long_name="salinity   -trend: non-penetrative conv."     unit="1e-3/s" />
+       <field id="ttrd_qns"      long_name="temperature-trend: non-solar flux + runoff"   unit="degC/s" grid_ref="grid_T_2D" />
+       <field id="strd_cdt"      long_name="salinity   -trend: C/D term       + runoff"   unit="degC/s" grid_ref="grid_T_2D" />
+       <field id="ttrd_qsr"      long_name="temperature-trend: solar penetr. heating"     unit="degC/s" />
+       <field id="ttrd_bbc"      long_name="temperature-trend: geothermal heating"        unit="degC/s" />
+
+       <!-- Thickness weighted versions: -->
+       <field id="ttrd_xad_e3t"      unit="degC/s * m" >  ttrd_xad * e3t </field>
+       <field id="strd_xad_e3t"      unit="1e-3/s * m" >  strd_xad * e3t </field>
+       <field id="ttrd_yad_e3t"      unit="degC/s * m" >  ttrd_yad * e3t </field>
+       <field id="strd_yad_e3t"      unit="1e-3/s * m" >  strd_yad * e3t </field>
+       <field id="ttrd_zad_e3t"      unit="degC/s * m" >  ttrd_zad * e3t </field>
+       <field id="strd_zad_e3t"      unit="1e-3/s * m" >  strd_zad * e3t </field>
+       <field id="ttrd_ad_e3t"       unit="degC/s * m" >  ttrd_ad  * e3t </field>
+       <field id="strd_ad_e3t"       unit="1e-3/s * m" >  strd_ad  * e3t </field>
+       <field id="ttrd_totad_e3t"    unit="degC/s * m" >  ttrd_totad  * e3t </field>
+       <field id="strd_totad_e3t"    unit="1e-3/s * m" >  strd_totad  * e3t </field>
+       <field id="ttrd_ldf_e3t"      unit="degC/s * m" >  ttrd_ldf * e3t </field>
+       <field id="strd_ldf_e3t"      unit="1e-3/s * m" >  strd_ldf * e3t </field>
+       <field id="ttrd_zdf_e3t"      unit="degC/s * m" >  ttrd_zdf * e3t </field>
+       <field id="strd_zdf_e3t"      unit="1e-3/s * m" >  strd_zdf * e3t </field>
+       <field id="ttrd_evd_e3t"      unit="degC/s * m" >  ttrd_evd * e3t </field>
+       <field id="strd_evd_e3t"      unit="1e-3/s * m" >  strd_evd * e3t </field>
+
+       <!-- ln_traldf_iso=T only (iso-neutral diffusion) -->
+       <field id="ttrd_iso_e3t"      unit="degC/s * m"  >  ttrd_iso * e3t </field>
+       <field id="strd_iso_e3t"      unit="1e-3/s * m"  >  strd_iso * e3t </field>
+       <field id="ttrd_zdfp_e3t"     unit="degC/s * m"  >  ttrd_zdfp * e3t </field>
+       <field id="strd_zdfp_e3t"     unit="1e-3/s * m"  >  strd_zdfp * e3t </field>
+
+       <!-- -->
+       <field id="ttrd_dmp_e3t"      unit="degC/s * m"  >  ttrd_dmp * e3t </field>
+       <field id="strd_dmp_e3t"      unit="1e-3/s * m"  >  strd_dmp * e3t </field>
+       <field id="ttrd_bbl_e3t"      unit="degC/s * m"  >  ttrd_bbl * e3t </field>
+       <field id="strd_bbl_e3t"      unit="1e-3/s * m"  >  strd_bbl * e3t </field>
+       <field id="ttrd_npc_e3t"      unit="degC/s * m"  >  ttrd_npc * e3t </field>
+       <field id="strd_npc_e3t"      unit="1e-3/s * m"  >  strd_npc * e3t </field>
+       <field id="ttrd_qns_e3t"      unit="degC/s * m"  >  ttrd_qns * e3t_surf </field>
+       <field id="strd_cdt_e3t"      unit="degC/s * m"  >  strd_cdt * e3t_surf </field>
+       <field id="ttrd_qsr_e3t"      unit="degC/s * m"  >  ttrd_qsr * e3t </field>
+       <field id="ttrd_bbc_e3t"      unit="degC/s * m"  >  ttrd_bbc * e3t </field>
+
+       <!-- OMIP  layer-integrated trends -->
+       <field id="ttrd_totad_li"    long_name="layer integrated heat-trend : total advection"       unit="W/m^2"     > ttrd_totad_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="strd_totad_li"    long_name="layer integrated salt   -trend : total advection"      unit="kg/(m^2 s)"    > strd_totad_e3t * 1026.0 * 0.001  </field>
+       <field id="ttrd_evd_li"      long_name="layer integrated heat-trend : EVD convection"         unit="W/m^2"    > ttrd_evd_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="strd_evd_li"      long_name="layer integrated salt   -trend : EVD convection"      unit="kg/(m^2 s)"  > strd_evd_e3t * 1026.0 * 0.001  </field>
+       <field id="ttrd_iso_li"      long_name="layer integrated heat-trend : isopycnal diffusion"    unit="W/m^2" > ttrd_iso_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="strd_iso_li"      long_name="layer integrated salt   -trend : isopycnal diffusion"   unit="kg/(m^2 s)" > strd_iso_e3t * 1026.0 * 0.001  </field>
+       <field id="ttrd_zdfp_li"     long_name="layer integrated heat-trend : pure vert. diffusion"   unit="W/m^2" > ttrd_zdfp_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="strd_zdfp_li"     long_name="layer integrated salt   -trend : pure vert. diffusion"   unit="kg/(m^2 s)" > strd_zdfp_e3t * 1026.0 * 0.001  </field>
+       <field id="ttrd_qns_li"      long_name="layer integrated heat-trend : non-solar flux + runoff"   unit="W/m^2" grid_ref="grid_T_2D"> ttrd_qns_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="ttrd_qsr_li"      long_name="layer integrated heat-trend : solar flux"   unit="W/m^2"  grid_ref="grid_T_3D"> ttrd_qsr_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="ttrd_bbl_li"      long_name="layer integrated heat-trend: bottom boundary layer "     unit="W/m^2" > ttrd_bbl_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="strd_bbl_li"      long_name="layer integrated salt   -trend: bottom boundary layer "     unit="kg/(m^2 s)" > strd_bbl_e3t * 1026.0 * 0.001  </field>
+       <field id="ttrd_evd_li"      long_name="layer integrated heat -trend: evd convection "       unit="W/m^2" >ttrd_evd_e3t * 1026.0 * 3991.86795711963  </field>
+       <field id="strd_evd_li"      long_name="layer integrated salt -trend: evd convection "       unit="kg/(m^2 s)" > strd_evd_e3t * 1026.0 * 0.001  </field>
+
+    </field_group>
+
+    <!--  Total trends calculated every time step-->
+    <field_group id="trendT" grid_ref="grid_T_3D">
+       <field id="ttrd_tot"      long_name="temperature-trend: total model trend"         unit="degC/s" />
+       <field id="strd_tot"      long_name="salinity   -trend: total model trend"         unit="1e-3/s" />
+       <!-- Thickness weighted versions: -->
+       <field id="ttrd_tot_e3t"      unit="degC/s * m"  >  ttrd_tot * e3t </field>
+       <field id="strd_tot_e3t"      unit="1e-3/s * m"  >  strd_tot * e3t </field>
+       <!-- OMIP  layer-integrated total trends -->
+       <field id="ttrd_tot_li"      long_name="layer integrated heat-trend: total model trend :"         unit="W/m^2" > ttrd_tot_e3t * 1026.0 * 3991.86795711963 </field>
+       <field id="strd_tot_li"      long_name="layer integrated salt   -trend: total model trend :"         unit="kg/(m^2 s)" > strd_tot_e3t * 1026.0 * 0.001  </field>
+
+       <!-- **** these trends have not been apportioned to all/even/odd ts yet **** -->
+       <!-- variables available with ln_KE_trd -->
+       <field id="ketrd_hpg"     long_name="ke-trend: hydrostatic pressure gradient"          unit="W/s^3"                        />
+       <field id="ketrd_spg"     long_name="ke-trend: surface     pressure gradient"          unit="W/s^3"                        />
+       <field id="ketrd_spgexp"  long_name="ke-trend: surface pressure gradient (explicit)"   unit="W/s^3"                        />
+       <field id="ketrd_spgflt"  long_name="ke-trend: surface pressure gradient (filter)"     unit="W/s^3"                        />
+       <field id="ssh_flt"       long_name="filtered contribution to ssh (dynspg_flt)"        unit="m"       grid_ref="grid_T_2D" />
+       <field id="w0"            long_name="surface vertical velocity"                        unit="m/s"     grid_ref="grid_T_2D" />
+       <field id="pw0_exp"       long_name="surface pressure flux due to ssh"                 unit="W/s^2"   grid_ref="grid_T_2D" />
+       <field id="pw0_flt"       long_name="surface pressure flux due to filtered ssh"        unit="W/s^2"   grid_ref="grid_T_2D" />
+       <field id="ketrd_keg"     long_name="ke-trend: KE gradient         or hor. adv."       unit="W/s^3"                        />
+       <field id="ketrd_rvo"     long_name="ke-trend: relative  vorticity or metric term"     unit="W/s^3"                        />
+       <field id="ketrd_pvo"     long_name="ke-trend: planetary vorticity"                    unit="W/s^3"                        />
+       <field id="ketrd_zad"     long_name="ke-trend: vertical  advection"                    unit="W/s^3"                        />
+       <field id="ketrd_udx"     long_name="ke-trend: U.dx[U]"                                unit="W/s^3"                        />
+       <field id="ketrd_ldf"     long_name="ke-trend: lateral   diffusion"                    unit="W/s^3"                        />
+       <field id="ketrd_zdf"     long_name="ke-trend: vertical  diffusion"                    unit="W/s^3"                        />
+       <field id="ketrd_tau"     long_name="ke-trend: wind stress "                           unit="W/s^3"   grid_ref="grid_T_2D" />
+       <field id="ketrd_bfr"     long_name="ke-trend: bottom friction (explicit)"             unit="W/s^3"                        />   
+       <field id="ketrd_bfri"    long_name="ke-trend: bottom friction (implicit)"             unit="W/s^3"                        />   
+       <field id="ketrd_atf"     long_name="ke-trend: asselin time filter trend"              unit="W/s^3"                        />  
+       <field id="ketrd_convP2K" long_name="ke-trend: conversion (potential to kinetic)"      unit="W/s^3"                        />
+       <field id="KE"            long_name="kinetic energy: u(n)*u(n+1)/2"                    unit="W/s^2"                        />   
+
+       <!-- variables available with ln_PE_trd -->
+       <field id="petrd_xad"     long_name="pe-trend: i-advection"                unit="W/m^3"                        />
+       <field id="petrd_yad"     long_name="pe-trend: j-advection"                unit="W/m^3"                        />
+       <field id="petrd_zad"     long_name="pe-trend: k-advection"                unit="W/m^3"                        />
+       <field id="petrd_sad"     long_name="pe-trend: surface adv. (linssh true)"      unit="W/m^3"   grid_ref="grid_T_2D" />
+       <field id="petrd_ldf"     long_name="pe-trend: lateral  diffusion"         unit="W/m^3"                        />
+       <field id="petrd_zdf"     long_name="pe-trend: vertical diffusion"         unit="W/m^3"                        />
+       <field id="petrd_zdfp"    long_name="pe-trend: pure vert. diffusion"       unit="W/m^3"                        />
+       <field id="petrd_dmp"     long_name="pe-trend: interior restoring"         unit="W/m^3"                        />
+       <field id="petrd_bbl"     long_name="pe-trend: bottom boundary layer"      unit="W/m^3"                        />
+       <field id="petrd_npc"     long_name="pe-trend: non-penetrative conv."      unit="W/m^3"                        />
+       <field id="petrd_nsr"     long_name="pe-trend: surface forcing + runoff"   unit="W/m^3"                        />
+       <field id="petrd_qsr"     long_name="pe-trend: solar penetr. heating"      unit="W/m^3"                        />
+       <field id="petrd_bbc"     long_name="pe-trend: geothermal heating"         unit="W/m^3"                        />
+       <field id="petrd_atf"     long_name="pe-trend: asselin time filter"        unit="W/m^3"                        />
+       <field id="PEanom"        long_name="potential energy anomaly"             unit="1"                            />   
+       <field id="alphaPE"       long_name="partial deriv. of PEanom wrt T"       unit="degC-1"                       />   
+       <field id="betaPE"        long_name="partial deriv. of PEanom wrt S"       unit="1e3"                          />   
+    </field_group>
+
+    <field_group id="trendU" grid_ref="grid_U_3D">
+       <!-- variables available with ln_dyn_trd -->
+       <field id="utrd_hpg"       long_name="i-trend: hydrostatic pressure gradient"          unit="m/s^2"                        />
+       <field id="utrd_spg"       long_name="i-trend: surface     pressure gradient"          unit="m/s^2"                        />
+       <field id="utrd_spgexp"    long_name="i-trend: surface pressure gradient (explicit)"   unit="m/s^2"                        />
+       <field id="utrd_spgflt"    long_name="i-trend: surface pressure gradient (filtered)"   unit="m/s^2"                        />
+       <field id="utrd_keg"       long_name="i-trend: KE gradient         or hor. adv."       unit="m/s^2"                        />
+       <field id="utrd_rvo"       long_name="i-trend: relative  vorticity or metric term"     unit="m/s^2"                        />
+       <field id="utrd_pvo"       long_name="i-trend: planetary vorticity"                    unit="m/s^2"                        />
+       <field id="utrd_zad"       long_name="i-trend: vertical  advection"                    unit="m/s^2"                        />
+       <field id="utrd_udx"       long_name="i-trend: U.dx[U]"                                unit="m/s^2"                        />
+       <field id="utrd_ldf"       long_name="i-trend: lateral   diffusion"                    unit="m/s^2"                        />
+       <field id="utrd_zdf"       long_name="i-trend: vertical  diffusion"                    unit="m/s^2"                        />
+       <field id="utrd_tau"       long_name="i-trend: wind stress "                           unit="m/s^2"   grid_ref="grid_U_2D" />
+       <field id="utrd_bfr"       long_name="i-trend: bottom friction (explicit)"             unit="m/s^2"                        />   
+       <field id="utrd_bfri"      long_name="i-trend: bottom friction (implicit)"             unit="m/s^2"                        />   
+       <field id="utrd_tot"       long_name="i-trend: total momentum trend before atf"        unit="m/s^2"                        />   
+       <field id="utrd_atf"       long_name="i-trend: asselin time filter trend"              unit="m/s^2"                        />   
+    </field_group>
+
+    <field_group id="trendV" grid_ref="grid_V_3D">
+       <!-- variables available with ln_dyn_trd -->
+       <field id="vtrd_hpg"       long_name="j-trend: hydrostatic pressure gradient"          unit="m/s^2"                        />
+       <field id="vtrd_spg"       long_name="j-trend: surface     pressure gradient"          unit="m/s^2"                        />
+       <field id="vtrd_spgexp"    long_name="j-trend: surface pressure gradient (explicit)"   unit="m/s^2"                        />
+       <field id="vtrd_spgflt"    long_name="j-trend: surface pressure gradient (filtered)"   unit="m/s^2"                        />
+       <field id="vtrd_keg"       long_name="j-trend: KE gradient         or hor. adv."       unit="m/s^2"                        />
+       <field id="vtrd_rvo"       long_name="j-trend: relative  vorticity or metric term"     unit="m/s^2"                        />
+       <field id="vtrd_pvo"       long_name="j-trend: planetary vorticity"                    unit="m/s^2"                        />
+       <field id="vtrd_zad"       long_name="j-trend: vertical  advection"                    unit="m/s^2"                        />
+       <field id="vtrd_vdy"       long_name="i-trend: V.dx[V]"                                unit="m/s^2"                        />
+       <field id="vtrd_ldf"       long_name="j-trend: lateral   diffusion"                    unit="m/s^2"                        />
+       <field id="vtrd_zdf"       long_name="j-trend: vertical  diffusion"                    unit="m/s^2"                        />
+       <field id="vtrd_tau"       long_name="j-trend: wind stress "                           unit="m/s^2"   grid_ref="grid_V_2D" />
+       <field id="vtrd_bfr"       long_name="j-trend: bottom friction (explicit)"             unit="m/s^2"                        />   
+       <field id="vtrd_bfri"      long_name="j-trend: bottom friction (implicit)"             unit="m/s^2"                        />   
+       <field id="vtrd_tot"       long_name="j-trend: total momentum trend before atf"        unit="m/s^2"                        />   
+       <field id="vtrd_atf"       long_name="j-trend: asselin time filter trend"              unit="m/s^2"                        />   
+    </field_group>
+
+
+    <!-- 
+============================================================================================================
+                                        Definitions for iodef_demo.xml
+============================================================================================================
+    -->
+
+     <field_group id="TRD" >
+          <field field_ref="ttrd_totad_li"   name="opottempadvect"  />
+          <field field_ref="ttrd_iso_li"     name="opottemppmdiff"  />
+          <field field_ref="ttrd_zdfp_li"    name="opottempdiff"  />
+          <field field_ref="ttrd_evd_li"     name="opottempevd" />
+          <field field_ref="strd_evd_li"     name="osaltevd" />
+          <field field_ref="ttrd_qns_li"     name="opottempqns"  />
+          <field field_ref="ttrd_qsr_li"     name="rsdoabsorb" operation="accumulate" />
+          <field field_ref="strd_totad_li"   name="osaltadvect" />
+          <field field_ref="strd_iso_li"     name="osaltpmdiff"  />
+          <field field_ref="strd_zdfp_li"    name="osaltdiff" />
+    </field_group>
+    
+    <field_group id="mooring" >
+       <field field_ref="toce"         name="thetao"   long_name="sea_water_potential_temperature"      />
+       <field field_ref="soce"         name="so"       long_name="sea_water_salinity"                   />
+       <field field_ref="uoce"         name="uo"       long_name="sea_water_x_velocity"                 />
+       <field field_ref="voce"         name="vo"       long_name="sea_water_y_velocity"                 />
+       <field field_ref="woce"         name="wo"       long_name="sea_water_z_velocity"                 />
+       <field field_ref="avt"          name="difvho"   long_name="ocean_vertical_heat_diffusivity"      />
+       <field field_ref="avm"          name="difvmo"   long_name="ocean_vertical_momentum_diffusivity"  />
+   
+       <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"                       />
+       <field field_ref="sst2"         name="tossq"    long_name="square_of_sea_surface_temperature"             />
+       <field field_ref="sstgrad"      name="tosgrad"  long_name="module_of_sea_surface_temperature_gradient"    />
+       <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"                          />
+       <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"                />
+       <field field_ref="empmr"        name="wfo"      long_name="water_flux_into_sea_water"                     />
+       <field field_ref="qsr"          name="rsntds"   long_name="surface_net_downward_shortwave_flux"           />
+       <field field_ref="qt"           name="tohfls"   long_name="surface_net_downward_total_heat_flux"          />
+       <field field_ref="taum"                                                                                   />
+       <field field_ref="20d"                                                                                    />
+       <field field_ref="mldkz5"                                                                                 />
+       <field field_ref="mldr10_1"                                                                               />
+       <field field_ref="mldr10_3"                                                                               />
+       <field field_ref="mldr0_1"                                                                                />
+       <field field_ref="mldr0_3"                                                                                />
+       <field field_ref="mld_dt02"                                                                               />
+       <field field_ref="topthdep"                                                                               />
+       <field field_ref="pycndep"                                                                                />
+       <field field_ref="tinv"                                                                                   />
+       <field field_ref="depti"                                                                                  />
+       <field field_ref="BLT"          name="blt"      long_name="barrier_layer_thickness"                       />
+       <field field_ref="utau"         name="tauuo"    long_name="surface_downward_x_stress"                     />
+       <field field_ref="vtau"         name="tauvo"    long_name="surface_downward_y_stress"                     />
+    </field_group>
+
+    <field_group id="groupT" >
+       <field field_ref="toce"         name="thetao"   long_name="sea_water_potential_temperature"               />
+       <field field_ref="soce"         name="so"       long_name="sea_water_salinity"                            />
+       <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"                       />
+       <field field_ref="sst2"         name="tossq"    long_name="square_of_sea_surface_temperature"             />
+       <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"                          />
+       <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"                />
+       <field field_ref="empmr"        name="wfo"      long_name="water_flux_into_sea_water"                     />
+       <field field_ref="qsr"          name="rsntds"   long_name="surface_net_downward_shortwave_flux"           />
+       <field field_ref="qt"           name="tohfls"   long_name="surface_net_downward_total_heat_flux"          />
+       <field field_ref="taum"                                                                                   />
+       <field field_ref="20d"                                                                                    />
+       <field field_ref="mldkz5"                                                                                 />
+       <field field_ref="mldr10_1"                                                                               />
+       <field field_ref="mldr10_3"                                                                               />
+       <field field_ref="mld_dt02"                                                                               />
+       <field field_ref="topthdep"                                                                               />
+       <field field_ref="pycndep"                                                                                />
+       <field field_ref="tinv"                                                                                   />
+       <field field_ref="depti"                                                                                  />
+       <field field_ref="BLT"          name="blt"      long_name="Barrier Layer Thickness"                       />
+    </field_group>
+    
+    <field_group id="groupU" >
+       <field field_ref="uoce"         name="uo"      long_name="sea_water_x_velocity"      />
+       <field field_ref="ssu"          name="uos"     long_name="sea_surface_x_velocity"    />
+       <field field_ref="utau"         name="tauuo"   long_name="surface_downward_x_stress" />
+    </field_group>
+    
+    <field_group id="groupV" >
+       <field field_ref="voce"         name="vo"      long_name="sea_water_y_velocity"      />
+       <field field_ref="ssv"          name="vos"     long_name="sea_surface_y_velocity"    />
+       <field field_ref="vtau"         name="tauvo"   long_name="surface_downward_y_stress" />
+    </field_group>
+    
+    <field_group id="groupW" >
+       <field field_ref="woce"         name="wo"       long_name="ocean vertical velocity"  />
+    </field_group>
+
+    <!-- TMB diagnostic output -->
+    <field_group  id="1h_grid_T_tmb" grid_ref="grid_T_2D" operation="instant">
+       <field id="top_temp"           name="votemper_top"  unit="degC"  />
+       <field id="mid_temp"           name="votemper_mid"  unit="degC"  />
+       <field id="bot_temp"           name="votemper_bot"  unit="degC"  />
+       <field id="top_sal"            name="vosaline_top"  unit="psu"   />
+       <field id="mid_sal"            name="vosaline_mid"  unit="psu"   />
+       <field id="bot_sal"            name="vosaline_bot"  unit="psu"   />
+       <field id="sshnmasked"         name="sossheig"      unit="m"     /> 
+    </field_group>
+
+    <field_group  id="1h_grid_U_tmb" grid_ref="grid_U_2D" operation="instant">
+       <field id="top_u"           name="vozocrtx_top"  unit="m/s"  />
+       <field id="mid_u"           name="vozocrtx_mid"  unit="m/s"  />
+       <field id="bot_u"           name="vozocrtx_bot"  unit="m/s"  />
+       <field id="baro_u"          name="vobtcrtx"      unit="m/s"  />
+    </field_group>
+
+    <field_group  id="1h_grid_V_tmb" grid_ref="grid_V_2D" operation="instant">
+       <field id="top_v"           name="vomecrty_top"  unit="m/s"  />
+       <field id="mid_v"           name="vomecrty_mid"  unit="m/s"  />
+       <field id="bot_v"           name="vomecrty_bot"  unit="m/s"  />
+       <field id="baro_v"          name="vobtcrty"      unit="m/s"  />
+    </field_group>
+
+    <!-- 25h diagnostic output -->
+    <field_group id="25h_grid_T" grid_ref="grid_T_3D" operation="instant">
+       <field id="temper25h"         name="potential temperature 25h mean"    unit="degC" />
+       <field id="tempis25h"         name="insitu temperature 25h mean"    unit="degC" />
+       <field id="salin25h"          name="salinity 25h mean"                 unit="psu"  />
+       <field id="ssh25h"            name="sea surface height 25h mean"  grid_ref="grid_T_2D"      unit="m"    />
+    </field_group>
+
+    <field_group id="25h_grid_U" grid_ref="grid_U_3D" operation="instant" >
+       <field id="vozocrtx25h"         name="i current 25h mean"    unit="m/s"   />
+    </field_group>
+
+    <field_group id="25h_grid_V" grid_ref="grid_V_3D" operation="instant">
+       <field id="vomecrty25h"         name="j current 25h mean"    unit="m/s"    />
+    </field_group>
+
+    <field_group id="25h_grid_W" grid_ref="grid_W_3D" operation="instant">
+       <field id="vomecrtz25h"         name="k current 25h mean"                 unit="m/s"      />
+       <field id="avt25h"             name="vertical diffusivity25h mean"       unit="m2/s" />
+       <field id="avm25h"              name="vertical viscosity 25h mean"        unit="m2/s" />
+       <field id="tke25h"              name="turbulent kinetic energy 25h mean" />
+       <field id="mxln25h"             name="mixing length 25h mean"             unit="m" />
+    </field_group>
+
+     <!-- 
+============================================================================================================
+       -->
+     <!-- output variables for my configuration (example) --> 
+ 
+    <field_group id="myvarOCE" >
+       <!-- grid T --> 
+       <field field_ref="e3t"          name="e3t"      long_name="vertical scale factor"           />
+       <field field_ref="sst"          name="tos"      long_name="sea_surface_temperature"         />
+       <field field_ref="sss"          name="sos"      long_name="sea_surface_salinity"            />
+       <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"  />
+      
+       <!-- grid U --> 
+       <field field_ref="e3u"          name="e3u"     long_name="vertical scale factor"            />
+       <field field_ref="ssu"          name="uos"     long_name="sea_surface_x_velocity"           />
+      
+       <!-- grid V --> 
+       <field field_ref="e3v"          name="e3v"     long_name="vertical scale factor"            />
+       <field field_ref="ssv"          name="vos"     long_name="sea_surface_y_velocity"           />     
+    </field_group>    
+
+   </field_definition>
diff --git a/EXP_Apr19/field_def_nemo-pisces.xml b/EXP_Apr19/field_def_nemo-pisces.xml
new file mode 100755
index 0000000..3642fec
--- /dev/null
+++ b/EXP_Apr19/field_def_nemo-pisces.xml
@@ -0,0 +1,298 @@
+<?xml version="1.0"?> 
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+   <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
+
+    <!-- 
+============================================================================================================
+                                     Biogeochemistry model variables
+============================================================================================================
+    -->
+
+      <!-- ptrc on T grid -->
+
+     <field_group id="ptrc_T" grid_ref="grid_T_3D">
+       <!-- PISCES standard : variables available with ln_p4z  -->
+       <field id="DIC"          long_name="Dissolved inorganic Concentration"        unit="mmol/m3" />
+       <field id="DIC_e3t"      long_name="DIC * e3t"                                unit="mmol/m2" > DIC * e3t </field >
+       <field id="Alkalini"     long_name="Total Alkalinity Concentration"           unit="mmol/m3" />
+       <field id="Alkalini_e3t" long_name="Alkalini * e3t"                           unit="mmol/m2"  > Alkalini * e3t </field >
+       <field id="O2"           long_name="Oxygen Concentration"                     unit="mmol/m3" />
+       <field id="O2_e3t"       long_name="O2 * e3t"                                 unit="mmol/m2"  > O2 * e3t </field >
+       <field id="CaCO3"        long_name="Calcite Concentration"                    unit="mmol/m3" />
+       <field id="CaCO3_e3t"    long_name="CaCO3 * e3t"                              unit="mmol/m2"  > CaCO3 * e3t </field >
+       <field id="PO4"          long_name="Phosphate Concentration"                  unit="mmol/m3" />
+       <field id="PO4_e3t"      long_name="PO4 * e3t"                                unit="mmol/m2"  > PO4 * e3t </field >
+       <field id="POC"          long_name="Small organic carbon Concentration"       unit="mmol/m3" />
+       <field id="POC_e3t"      long_name="POC * e3t"                                unit="mmol/m2"  > POC * e3t </field >
+       <field id="Si"           long_name="Silicate Concentration"                   unit="mmol/m3" />
+       <field id="Si_e3t"       long_name="Si * e3t"                                 unit="mmol/m2"  > Si * e3t </field >
+       <field id="PHY"          long_name="(Nano)Phytoplankton Concentration"        unit="mmol/m3" />
+       <field id="PHY_e3t"      long_name="PHY * e3t"                                unit="mmol/m2"  > PHY * e3t </field >
+       <field id="ZOO"          long_name="(Micro)Zooplankton Concentration"         unit="mmol/m3" />
+       <field id="ZOO_e3t"      long_name="ZOO2 * e3t"                               unit="mmol/m2"  > ZOO * e3t </field >
+       <field id="DOC"          long_name="Dissolved organic Concentration"          unit="mmol/m3" />
+       <field id="DOC_e3t"      long_name="DOC * e3t"                                unit="mmol/m2"  > DOC * e3t </field >
+       <field id="PHY2"         long_name="Diatoms Concentration"                    unit="mmol/m3" />
+       <field id="PHY2_e3t"     long_name="PHY2 * e3t"                               unit="mmol/m2"  > PHY2 * e3t </field >
+       <field id="ZOO2"         long_name="Mesozooplankton Concentration"            unit="mmol/m3" />
+       <field id="ZOO2_e3t"     long_name="ZOO2 * e3t"                               unit="mmol/m2"  > ZOO2 * e3t </field >
+       <field id="DSi"          long_name="Diatoms Silicate Concentration"           unit="mmol/m3" />
+       <field id="DSi_e3t"      long_name="Dsi * e3t"                                unit="mmol/m2"  > DSi * e3t </field >
+       <field id="Fer"          long_name="Dissolved Iron Concentration"             unit="mmol/m3" />
+       <field id="Fer_e3t"      long_name="Fer * e3t"                                unit="mmol/m2"  > Fer * e3t </field >
+       <field id="BFe"          long_name="Big iron particles Concentration"         unit="mmol/m3" />
+       <field id="BFe_e3t"      long_name="BFe * e3t"                                unit="mmol/m2"  > BFe * e3t </field >
+       <field id="GOC"          long_name="Big organic carbon Concentration"         unit="mmol/m3" />
+       <field id="GOC_e3t"      long_name="GOC * e3t"                                unit="mmol/m2"  > GOC * e3t </field >
+       <field id="SFe"          long_name="Small iron particles Concentration"       unit="mmol/m3" />
+       <field id="SFe_e3t"      long_name="SFe * e3t"                                unit="mmol/m2"  > SFe * e3t </field >
+       <field id="DFe"          long_name="Diatoms iron  Concentration"              unit="mmol/m3" />
+       <field id="DFe_e3t"      long_name="DFe * e3t"                                unit="mmol/m2"  > DFe * e3t </field >
+       <field id="GSi"          long_name="Sinking biogenic Silicate Concentration"  unit="mmol/m3" />
+       <field id="GSi_e3t"      long_name="GSi * e3t"                                unit="mmol/m2"  > GSi * e3t </field >
+       <field id="NFe"          long_name="Nano iron Concentration"                  unit="mmol/m3" />
+       <field id="NFe_e3t"      long_name="NFe * e3t"                                unit="mmol/m2"  > NFe * e3t </field >
+       <field id="NCHL"         long_name="Nano chlorophyl Concentration"            unit="mg/m3"   />
+       <field id="NCHL_e3t"     long_name="NCHL * e3t"                               unit="mmol/m2"  > NCHL * e3t </field >
+       <field id="DCHL"         long_name="Diatoms chlorophyl Concentration"         unit="mg/m3"   />
+       <field id="DCHL_e3t"     long_name="DCHL * e3t"                               unit="mmol/m2"  > DCHL * e3t </field >
+       <field id="NO3"          long_name="Nitrate Concentration"                    unit="mmol/m3" />
+       <field id="NO3_e3t"      long_name="NO3 * e3t"                                unit="mmol/m2"  > NO3 * e3t </field >
+       <field id="NH4"          long_name="Ammonium Concentration"                   unit="mmol/m3" />
+       <field id="NH4_e3t"      long_name="NH4 * e3t"                                unit="mmol/m2"  > NH4 * e3t </field >
+
+       <!-- PISCES quota : variables available with ln_p5z  -->
+
+       <field id="DON"          long_name="Dissolved organic N Concentration"        unit="mmol/m3" />
+       <field id="DON_e3t"      long_name="DON * e3t"                                unit="mmol/m2"  > DON * e3t </field >
+       <field id="DOP"          long_name="Dissolved organic P Concentration"        unit="mmol/m3" />
+       <field id="DOP_e3t"      long_name="DOP * e3t"                                unit="mmol/m2"  > DOP * e3t </field >
+       <field id="PON"          long_name="Small PON Concentration"                  unit="mmol/m3" />
+       <field id="PON_e3t"      long_name="PON * e3t"                                unit="mmol/m2"  > PON * e3t </field >
+       <field id="POP"          long_name="Small POP Concentration"                  unit="mmol/m3" />
+       <field id="POP_e3t"      long_name="POP * e3t"                                unit="mmol/m2"  > POP * e3t </field >
+       <field id="GON"          long_name="Big PON Concentration"                    unit="mmol/m3" />
+       <field id="GON_e3t"      long_name="GON * e3t"                                unit="mmol/m2"  > GON * e3t </field >
+       <field id="GOP"          long_name="Big POP Concentration"                    unit="mmol/m3" />
+       <field id="GOP_e3t"      long_name="GOP * e3t"                                unit="mmol/m2"  > GOP * e3t </field >
+       <field id="PHYN"         long_name="Nanophytoplankton N biomass"              unit="mmol/m3" />
+       <field id="PHYN_e3t"     long_name="PHYN * e3t"                               unit="mmol/m2"  > PHYN * e3t </field >
+       <field id="PHYP"         long_name="Nanophytoplankton P biomass"              unit="mmol/m3" />
+       <field id="PHYP_e3t"     long_name="PHYP * e3t"                               unit="mmol/m2"  > PHYP * e3t </field >
+       <field id="DIAN"         long_name="Diatoms N biomass"                        unit="mmol/m3" />
+       <field id="DIAN_e3t"     long_name="DIAN * e3t"                               unit="mmol/m2"  > DIAN * e3t </field >
+       <field id="DIAP"         long_name="Diatoms P biomass"                        unit="mmol/m3" />
+       <field id="DIAP_e3t"     long_name="DIAP * e3t"                               unit="mmol/m2"  > DIAP * e3t </field >
+       <field id="PIC"          long_name="Picophytoplankton C biomass"              unit="mmol/m3" />
+       <field id="PIC_e3t"      long_name="PIC * e3t"                                unit="mmol/m2"  > PIC * e3t </field >
+       <field id="PICN"         long_name="Picophytoplankton N biomass"              unit="mmol/m3" />
+       <field id="PICN_e3t"     long_name="PICN * e3t"                               unit="mmol/m2"  > PICN * e3t </field >
+       <field id="PICP"         long_name="Picophytoplankton P biomass"              unit="mmol/m3" />
+       <field id="PICP_e3t"     long_name="PICP * e3t"                               unit="mmol/m2"  > PICP * e3t </field >
+       <field id="PFe"          long_name="Picophytoplankton Fe biomass"             unit="mmol/m3" />
+       <field id="PFe_e3t"      long_name="PFe * e3t"                                unit="mmol/m2"  > PFe * e3t </field >
+       <field id="PCHL"         long_name="Picophytoplankton Chl biomass"            unit="mg/m3" />
+       <field id="PCHL_e3t"     long_name="PCHL * e3t"                               unit="mmol/m2"  > PCHL * e3t </field >
+
+      <!-- PISCES with ligand parametisation : variables available namelist paramter ln_ligand -->
+       <field id="LGW"         long_name="Weak ligands concentration"                unit="mmol/m3" />
+       <field id="LGW_e3t"     long_name="LGW * e3t"                                 unit="mmol/m2"  > LGW * e3t </field >
+       <field id="LFe"         long_name="Lithogenic iron concentration"             unit="mmol/m3" />
+       <field id="LFe_e3t"     long_name="LFe * e3t"                                 unit="mmol/m2"  > LFe * e3t </field >
+
+       <!-- PISCES light : variables available with ln_p2z  -->
+       <field id="DET"         long_name="Detritus"                                 unit="mmol-N/m3" />
+       <field id="DET_e3t"     long_name="DET * e3t"                                unit="mmol-N/m2"  > DET * e3t </field >
+       <field id="DOM"         long_name="Dissolved Organic Matter"                 unit="mmol-N/m3" />
+       <field id="DOM_e3t"     long_name="DOM * e3t"                                unit="mmol-N/m2"  > DOM * e3t </field >
+
+       <!-- CFC11 : variables available with ln_cfc11 -->
+       <field id="CFC11"       long_name="Chlorofluoro carbon11 Concentration"      unit="umol/m3" />
+       <field id="CFC11_e3t"   long_name="CFC11 * e3t"                              unit="umol/m2"  > CFC11 * e3t </field >
+
+       <!-- CFC12 : variables available with ln_cfc12 -->
+       <field id="CFC12"       long_name="Chlorofluoro carbon12 Concentration"      unit="umol/m3" />
+       <field id="CFC12_e3t"   long_name="CFC12 * e3t"                              unit="umol/m2"  > CFC12 * e3t </field >
+
+       <!-- SF6 : variables available with ln_sf6 -->
+       <field id="SF6"       long_name="Sulfur hexafluoride Concentration"      unit="umol/m3" />
+       <field id="SF6_e3t"   long_name="SF6 * e3t"                              unit="umol/m2"  > SF6 * e3t </field >
+
+       <!-- C14 : variables available with ln_c14 -->
+       <field id="RC14"        long_name="Radiocarbon ratio"                        unit="-"         />
+       <field id="RC14_e3t"    long_name="RC14 * e3t"                               unit="m"  > RC14 * e3t </field >
+
+       <!-- AGE : variables available with ln_age -->
+       <field id="Age"        long_name="Sea water age since surface contact"       unit="yr"         />
+       <field id="Age_e3t"    long_name="Age * e3t"                                 unit="yr * m"  > Age * e3t </field >
+
+     </field_group>
+
+     <!-- PISCES additional diagnostics on T grid  -->
+
+     <field_group id="diad_T" grid_ref="grid_T_2D">
+       <field id="PH"          long_name="PH"                                      unit="1"          grid_ref="grid_T_3D" />
+       <field id="CO3"         long_name="Bicarbonates"                            unit="mol/m3"     grid_ref="grid_T_3D" />
+       <field id="CO3sat"      long_name="CO3 saturation"                          unit="mol/m3"     grid_ref="grid_T_3D" />
+       <field id="PAR"         long_name="Photosynthetically Available Radiation"  unit="W/m2"       grid_ref="grid_T_3D" />
+       <field id="PARDM"       long_name="Daily mean PAR"                          unit="W/m2"       grid_ref="grid_T_3D" />
+       <field id="PPPHYN"      long_name="Primary production of nanophyto"         unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PPPHYP"      long_name="Primary production of picophyto"         unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PPPHYD"      long_name="Primary production of diatoms"           unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PPNEWN"      long_name="New Primary production of nanophyto"     unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PPNEWP"      long_name="New Primary production of picophyto"     unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PPNEWD"      long_name="New Primary production of diatoms"       unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PBSi"        long_name="Primary production of Si diatoms"        unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PFeN"        long_name="Primary production of nano iron"         unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PFeP"        long_name="Primary production of pico iron"         unit="molC/m3/s"  grid_ref="grid_T_3D" />
+       <field id="PFeD"        long_name="Primary production of diatoms iron"      unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="xfracal"     long_name="Calcifying fraction"                     unit="1"          grid_ref="grid_T_3D" />
+       <field id="PCAL"        long_name="Calcite production"                      unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="DCAL"        long_name="Calcite dissolution"                     unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="GRAZ1"       long_name="Grazing by microzooplankton"             unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="GRAZ2"       long_name="Grazing by mesozooplankton"              unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="REMIN"       long_name="Oxic remineralization of OM"             unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="DENIT"       long_name="Anoxic remineralization of OM"           unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="REMINP"       long_name="Oxic remineralization rate of POC"      unit="d-1"        grid_ref="grid_T_3D" />
+       <field id="REMING"       long_name="Oxic remineralization rate of GOC"      unit="d-1"        grid_ref="grid_T_3D" />
+       <field id="Nfix"        long_name="Nitrogen fixation"                       unit="mol/m3/s"   grid_ref="grid_T_3D" />
+       <field id="Mumax"       long_name="Maximum growth rate"                     unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MuN"         long_name="Realized growth rate for nanophyto"      unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MuP"         long_name="Realized growth rate for picophyto"      unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MuD"         long_name="Realized growth rate for diatomes"       unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MunetN"      long_name="Net growth rate for nanophyto"           unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MunetP"      long_name="Net growth rate for picophyto"           unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="MunetD"      long_name="Net growth rate for diatomes"            unit="s-1"        grid_ref="grid_T_3D" />
+       <field id="LNnut"       long_name="Nutrient limitation term in Nanophyto"   unit=""           grid_ref="grid_T_3D" />
+       <field id="LPnut"       long_name="Nutrient limitation term in Picophyto"   unit="-"          grid_ref="grid_T_3D" />
+       <field id="LDnut"       long_name="Nutrient limitation term in Diatoms"     unit=""           grid_ref="grid_T_3D" />
+       <field id="LNFe"        long_name="Iron limitation term in Nanophyto"       unit=""           grid_ref="grid_T_3D" />
+       <field id="LPFe"        long_name="Iron limitation term in Picophyto"       unit="-"          grid_ref="grid_T_3D" />
+       <field id="LDFe"        long_name="Iron limitation term in Diatoms"         unit=""           grid_ref="grid_T_3D" />
+       <field id="LNlight"     long_name="Light limitation term in Nanophyto"      unit=""           grid_ref="grid_T_3D" />
+       <field id="LPlight"     long_name="Light limitation term in Picophyto"      unit="-"          grid_ref="grid_T_3D" />
+       <field id="LDlight"     long_name="Light limitation term in Diatoms"        unit=""           grid_ref="grid_T_3D" />
+       <field id="SIZEN"       long_name="Mean relative size of nanophyto."        unit="-"          grid_ref="grid_T_3D" />
+       <field id="SIZEP"       long_name="Mean relative size of picophyto."        unit="-"          grid_ref="grid_T_3D" />
+       <field id="SIZED"       long_name="Mean relative size of diatoms"           unit="-"          grid_ref="grid_T_3D" />
+       <field id="Fe2"         long_name="Iron II concentration"                   unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="Fe3"         long_name="Iron III concentration"                  unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="FeL1"        long_name="Complexed Iron concentration with L1"    unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="FeL2"        long_name="Complexed Iron concentration with L2"    unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="FeP"         long_name="Precipitated Iron III"                   unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="TL1"         long_name="Total L1 concentration"                  unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="TL2"         long_name="Total L2 concentration"                  unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="pdust"       long_name="dust concentration"                      unit="g/m3"                            />
+       <field id="Totlig"      long_name="Total ligand concentation"               unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="Biron"       long_name="Bioavailable iron"                       unit="nmol/m3"    grid_ref="grid_T_3D" />
+       <field id="Sdenit"      long_name="Nitrate reduction in the sediments"      unit="mol/m2/s"                        />
+       <field id="Ironice"     long_name="Iron input/uptake due to sea ice"        unit="mol/m2/s"                        />
+       <field id="SedCal"      long_name="Calcite burial in the sediments"         unit="molC/m2/s"                       />
+       <field id="SedSi"       long_name="Silicon burial in the sediments"         unit="molSi/m2/s"                      />
+       <field id="SedC"        long_name="Organic C burial in the sediments"       unit="molC/m2/s"                       />
+       <field id="HYDR"        long_name="Iron input from hydrothemal vents"       unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EPC100"      long_name="Export of carbon particles at 100 m"     unit="mol/m2/s"                        />
+       <field id="EPFE100"     long_name="Export of biogenic iron at 100 m"        unit="mol/m2/s"                        />
+       <field id="EPSI100"     long_name="Export of Silicate at 100 m"             unit="mol/m2/s"                        />
+       <field id="EPCAL100"    long_name="Export of Calcite at 100 m"              unit="mol/m2/s"                        />
+       <field id="EXPC"        long_name="Export of carbon"                        unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EXPFE"       long_name="Export of biogenic iron"                 unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EXPSI"       long_name="Export of Silicate"                      unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="EXPCAL"      long_name="Export of Calcite"                       unit="mol/m2/s"   grid_ref="grid_T_3D" />
+       <field id="Cflx"        long_name="DIC flux"                                unit="mol/m2/s"                        />
+       <field id="Oflx"        long_name="Oxygen flux"                             unit="mol/m2/s"                        />
+       <field id="Kg"          long_name="Gas transfer"                            unit="mol/m2/s/uatm"                   />
+       <field id="Dpco2"       long_name="Delta CO2"                               unit="uatm"                            />
+       <field id="Dpo2"        long_name="Delta O2"                                unit="uatm"                            />
+       <field id="Heup"        long_name="Euphotic layer depth"                    unit="m"                               />
+       <field id="Irondep"     long_name="Iron deposition from dust"               unit="mol/m2/s"                        />
+       <field id="Ironsed"     long_name="Iron deposition from sediment"           unit="mol/m2/s"   grid_ref="grid_T_3D" />
+
+       <!-- dbio_T on T grid : variables available with diaar5 -->
+       <field id="TPP"         long_name="Total Primary production of phyto"                   unit="mol/m3/s"  grid_ref="grid_T_3D" />
+       <field id="TPNEW"       long_name="New Primary production of phyto"                     unit="mol/m3/s"  grid_ref="grid_T_3D" />
+       <field id="TPBFE"       long_name="Total biogenic iron production"                      unit="mol/m3/s"  grid_ref="grid_T_3D" />
+       <field id="INTDIC"      long_name="DIC content"                                         unit="kg/m2"                          />
+       <field id="O2MIN"       long_name="Oxygen minimum concentration"                        unit="mol/m3"                          />
+       <field id="ZO2MIN"      long_name="Depth of oxygen minimum concentration"               unit="m"                              />
+       <field id="INTNFIX"     long_name="Nitrogen fixation rate : vert. integrated"           unit="mol/m2/s"                       />
+       <field id="INTPPPHYN"   long_name="Vertically integrated primary production by nanophy" unit="mol/m2/s"                       />
+       <field id="INTPPPHYD"   long_name="Vertically integrated primary production by diatom"  unit="mol/m2/s"                       />
+       <field id="INTPP"       long_name="Vertically integrated primary production by phyto"   unit="mol/m2/s"                       />
+       <field id="INTPNEW"     long_name="Vertically integrated new primary production"        unit="mol/m2/s"                       />
+       <field id="INTPBFE"     long_name="Vertically integrated of biogenic iron production"   unit="mol/m2/s"                       />
+       <field id="INTPBSI"     long_name="Vertically integrated of biogenic Si production"     unit="mol/m2/s"                       />
+       <field id="INTPCAL"     long_name="Vertically integrated of calcite production"         unit="mol/m2/s"                       />
+
+       <!-- PISCES light : variables available with key_pisces_reduced -->
+       <field id="FNO3PHY"     long_name="FNO3PHY"                                 unit=""          grid_ref="grid_T_3D" /> 
+       <field id="FNH4PHY"     long_name="FNH4PHY"                                 unit=""          grid_ref="grid_T_3D" /> 
+       <field id="FNH4NO3"     long_name="FNH4NO3"                                 unit=""          grid_ref="grid_T_3D" /> 
+       <field id="TNO3PHY"     long_name="TNO3PHY"                                 unit=""  /> 
+       <field id="TNH4PHY"     long_name="TNH4PHY"                                 unit=""  /> 
+       <field id="TPHYDOM"     long_name="TPHYDOM"                                 unit=""  /> 
+       <field id="TPHYNH4"     long_name="TPHYNH4"                                 unit=""  /> 
+       <field id="TPHYZOO"     long_name="TPHYZOO"                                 unit=""  /> 
+       <field id="TPHYDET"     long_name="TPHYDET"                                 unit=""  /> 
+       <field id="TDETZOO"     long_name="TDETZOO"                                 unit=""  /> 
+       <field id="TZOODET"     long_name="TZOODET"                                 unit=""  /> 
+       <field id="TZOOBOD"     long_name="TZOOBOD"                                 unit=""  /> 
+       <field id="TZOONH4"     long_name="TZOONH4"                                 unit=""  /> 
+       <field id="TZOODOM"     long_name="TZOODOM"                                 unit=""  /> 
+       <field id="TNH4NO3"     long_name="TNH4NO3"                                 unit=""  /> 
+       <field id="TDOMNH4"     long_name="TDOMNH4"                                 unit=""  /> 
+       <field id="TDETNH4"     long_name="TDETNH4"                                 unit=""  /> 
+       <field id="TPHYTOT"     long_name="TPHYTOT"                                 unit=""  /> 
+       <field id="TZOOTOT"     long_name="TZOOTOT"                                 unit=""  /> 
+       <field id="SEDPOC"      long_name="SEDPOC"                                  unit=""  /> 
+       <field id="TDETSED"     long_name="TDETSED"                                 unit=""  /> 
+
+       <!-- CFC11 : variables available with ln_cfc11 -->
+       <field id="qtr_CFC11"    long_name="Air-sea flux of CFC-11"                  unit="mol/m2/s"   />
+       <field id="qint_CFC11"   long_name="Cumulative air-sea flux of CFC-11"       unit="mol/m2"     />
+
+       <!-- CFC12 : variables available with ln_cfc12 -->
+       <field id="qtr_CFC12"    long_name="Air-sea flux of CFC12"                  unit="mol/m2/s"   />
+       <field id="qint_CFC12"   long_name="Cumulative air-sea flux of CFC12"       unit="mol/m2"     />
+
+       <!-- SF6 : variables available with ln_sf6 -->
+       <field id="qtr_SF6"      long_name="Air-sea flux of SF6"                    unit="mol/m2/s"   />
+       <field id="qint_SF6"     long_name="Cumulative air-sea flux of SF6"         unit="mol/m2"     />
+
+       <!--  C14 : variables available with ln_c14 -->
+       <field id="DeltaC14"     long_name="Delta C14"                              unit="permil" grid_ref="grid_T_3D"   />
+       <field id="C14Age"       long_name="Radiocarbon age"                        unit="yr"     grid_ref="grid_T_3D"   />
+       <field id="RAge"         long_name="Reservoir Age"                          unit="yr"     />
+       <field id="qtr_C14"      long_name="Air-sea flux of C14"                    unit="1/m2/s"   />
+       <field id="qint_C14"     long_name="Cumulative air-sea flux of C14"         unit="1/m2"     />
+     </field_group>
+
+     <field_group id="tracer_scalar"  grid_ref="grid_T_2D"  >
+     <!-- PISCES scalar  -->
+       <field id="pno3tot"         long_name="Global mean nitrate concentration"                  unit="mol/m3"   />
+       <field id="ppo4tot"         long_name="global mean phosphorus concentration"               unit="mol/m3"   />
+       <field id="psiltot"         long_name="Global mean silicate concentration"                 unit="mol/m3"   />
+       <field id="palktot"         long_name="Global mean alkalinity concentration"               unit="mol/m3"   />
+       <field id="pfertot"         long_name="Global mean iron concentration"                     unit="mol/m3"   />
+       <field id="tcflx"           long_name="Total Flux of Carbon out of the ocean"              unit="mol/s"   />
+       <field id="tcflxcum"        long_name="Cumulative total Flux of Carbon out of the ocean"   unit="mol/s"   />
+       <field id="tcexp"           long_name="Total Carbon export at 100m"                        unit="mol/s"   />
+       <field id="tintpp"          long_name="Global total integrated primary production"         unit="mol/s"   />
+       <field id="tnfix"           long_name="Global total nitrogen fixation"                     unit="mol/s"   />
+       <field id="tdenit"          long_name="Total denitrification"                              unit="mol/s"   />
+     <!-- C14 scalar  -->
+       <field id="AtmCO2"          long_name="Global atmospheric CO2"                             unit="ppm"   />
+       <field id="AtmC14"          long_name="Global atmospheric DeltaC14"                        unit="permil"   />
+       <field id="K_C14"           long_name="Global 14C/C exchange velocity"                     unit="m/yr"   />
+       <field id="K_CO2"           long_name="Global CO2 piston velocity"                         unit="cm/h"   />
+       <field id="C14Inv"          long_name="global Radiocarbon ocean inventory"                 unit="10^26 atoms"   />
+     </field_group>
+
+   </field_definition>
diff --git a/EXP_Apr19/file_def_nemo-opa.xml b/EXP_Apr19/file_def_nemo-opa.xml
new file mode 100755
index 0000000..0c76435
--- /dev/null
+++ b/EXP_Apr19/file_def_nemo-opa.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition type="multiple_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="10d" min_digits="4">
+    
+      <file_group id="15mi" output_freq="15mi"  output_level="10" enabled=".TRUE." > <!-- 1 time step files -->
+         <file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="ssh"          name="zos"      long_name="sea_surface_height_above_geoid"            operation="instant"      />
+        </file>
+       
+        <file id="file2" name_suffix="_grid_U" description="ocean U grid variables" >
+          <field field_ref="ssu"          name="uos"     long_name="sea_water_surface_x_velocity"  operation="instant" />
+          <field field_ref="uwnd"         name="uwnd"    long_name="u_component_of_wind"           operation="instant" />
+        </file>
+
+        <file id="file3" name_suffix="_grid_V" description="ocean V grid variables" >
+          <field field_ref="ssv"          name="vos"     long_name="sea_water_surface_y_velocity"  operation="instant" />
+          <field field_ref="vwnd"         name="vwnd"    long_name="v_component_of_wind"           operation="instant" />
+        </file>
+
+      </file_group>
+
+
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE." />                      
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->
+      <file_group id="25h_mean" output_freq="1d" output_level="10" enabled=".TRUE."/>
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."/> <!-- 1d files -->
+      <file_group id="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d files -->    
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE."/>  <!-- 5d files -->   
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+
+   </file_definition>
+    
+
diff --git a/EXP_Apr19/file_def_nemo.xml b/EXP_Apr19/file_def_nemo.xml
new file mode 100755
index 0000000..cf06a03
--- /dev/null
+++ b/EXP_Apr19/file_def_nemo.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0"?>
+
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="10d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."> <!-- 1h files -->
+  	<file id="file19" name_suffix="_SSH" description="ocean T grid variables" >
+    	 <field field_ref="ssh"          name="zos"   />
+         <field field_ref="sst"          name="tos"   />
+  	</file>
+      </file_group>
+
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."/> <!-- 1d files -->
+      <file_group id="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d files -->
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   
+
+	<file id="file20" name_suffix="_Tides" description="tidal harmonics" >
+	  <field field_ref="M2x"          name="M2x"      long_name="M2 Elevation harmonic real part"                       />
+	  <field field_ref="M2y"          name="M2y"      long_name="M2 Elevation harmonic imaginary part"                  />
+	  <field field_ref="M2x_u"        name="M2x_u"    long_name="M2 current barotrope along i-axis harmonic real part "       />
+	  <field field_ref="M2y_u"        name="M2y_u"    long_name="M2 current barotrope along i-axis harmonic imaginary part "  />
+	  <field field_ref="M2x_v"        name="M2x_v"    long_name="M2 current barotrope along j-axis harmonic real part "       />
+	  <field field_ref="M2y_v"        name="M2y_v"    long_name="M2 current barotrope along j-axis harmonic imaginary part "  />
+	</file>
+<!--
+        <file id="file11" name_suffix="_Tides_T" >
+          <field field_ref="M2x"     name="M2_x_elev"  />
+          <field field_ref="M2y"     name="M2_y_elev"  />
+          <field field_ref="S2x"     name="S2_x_elev"  />
+          <field field_ref="S2y"     name="S2_y_elev"  />
+          <field field_ref="N2x"     name="N2_x_elev"  />
+          <field field_ref="N2y"     name="N2_y_elev"  />
+          <field field_ref="K2x"     name="K2_x_elev"  />
+          <field field_ref="K2y"     name="K2_y_elev"  />
+          <field field_ref="K1x"     name="K1_x_elev"  />
+          <field field_ref="K1y"     name="K1_y_elev"  />
+          <field field_ref="M4x"     name="M4_x_elev"  />
+          <field field_ref="M4y"     name="M4_y_elev"  />
+          <field field_ref="Q1x"     name="Q1_x_elev"  />
+          <field field_ref="Q1y"     name="Q1_y_elev"  />
+          <field field_ref="O1x"     name="O1_x_elev"  />
+          <field field_ref="O1y"     name="O1_y_elev"  />
+          <field field_ref="P1x"     name="P1_x_elev"  />
+          <field field_ref="P1y"     name="P1_y_elev"  />
+          <field field_ref="S1x"     name="S1_x_elev"  />
+          <field field_ref="S1y"     name="S1_y_elev"  />
+          <field field_ref="2N2x"    name="a2N2_x_elev"  />
+          <field field_ref="2N2y"    name="a2N2_y_elev"  />
+          <field field_ref="MU2x"    name="MU2_x_elev"  />
+          <field field_ref="MU2y"    name="MU2_y_elev"  />
+          <field field_ref="NU2x"    name="NU2_x_elev"  />
+          <field field_ref="NU2y"    name="NU2_y_elev"  />
+          <field field_ref="L2x"     name="L2_x_elev"  />
+          <field field_ref="L2y"     name="L2_y_elev"  />
+          <field field_ref="T2x"     name="T2_x_elev"  />
+          <field field_ref="T2y"     name="T2_y_elev"  />
+        </file>
+
+        <file id="file12" name_suffix="_Tides_U" >
+          <field field_ref="M2x_u"     name="M2_x_u"  />
+          <field field_ref="M2y_u"     name="M2_y_u"  />
+          <field field_ref="S2x_u"     name="S2_x_u"  />
+          <field field_ref="S2y_u"     name="S2_y_u"  />
+          <field field_ref="N2x_u"     name="N2_x_u"  />
+          <field field_ref="N2y_u"     name="N2_y_u"  />
+          <field field_ref="K2x_u"     name="K2_x_u"  />
+          <field field_ref="K2y_u"     name="K2_y_u"  />
+          <field field_ref="K1x_u"     name="K1_x_u"  />
+          <field field_ref="K1y_u"     name="K1_y_u"  />
+          <field field_ref="M4x_u"     name="M4_x_u"  />
+          <field field_ref="M4y_u"     name="M4_y_u"  />
+          <field field_ref="Q1x_u"     name="Q1_x_u"  />
+          <field field_ref="Q1y_u"     name="Q1_y_u"  />
+          <field field_ref="O1x_u"     name="O1_x_u"  />
+          <field field_ref="O1y_u"     name="O1_y_u"  />
+          <field field_ref="P1x_u"     name="P1_x_u"  />
+          <field field_ref="P1y_u"     name="P1_y_u"  />
+          <field field_ref="S1x_u"     name="S1_x_u" />
+          <field field_ref="S1y_u"     name="S1_y_u" />
+          <field field_ref="2N2x_u"    name="a2N2_x_u" />
+          <field field_ref="2N2y_u"    name="a2N2_y_u" />
+          <field field_ref="MU2x_u"    name="MU2_x_u" />
+          <field field_ref="MU2y_u"    name="MU2_y_u" />
+          <field field_ref="NU2x_u"    name="NU2_x_u" />
+          <field field_ref="NU2y_u"    name="NU2_y_u" />
+          <field field_ref="L2x_u"     name="L2_x_u" />
+          <field field_ref="L2y_u"     name="L2_y_u" />
+          <field field_ref="T2x_u"     name="T2_x_u" />
+          <field field_ref="T2y_u"     name="T2_y_u" />
+        </file>
+
+        <file id="file13" name_suffix="_Tides_V" >
+          <field field_ref="M2x_v"     name="M2_x_v"  />
+          <field field_ref="M2y_v"     name="M2_y_v"  />
+          <field field_ref="S2x_v"     name="S2_x_v"  />
+          <field field_ref="S2y_v"     name="S2_y_v"  />
+          <field field_ref="N2x_v"     name="N2_x_v"  />
+          <field field_ref="N2y_v"     name="N2_y_v"  />
+          <field field_ref="K2x_v"     name="K2_x_v"  />
+          <field field_ref="K2y_v"     name="K2_y_v"  />
+          <field field_ref="K1x_v"     name="K1_x_v"  />
+          <field field_ref="K1y_v"     name="K1_y_v"  />
+          <field field_ref="M4x_v"     name="M4_x_v"  />
+          <field field_ref="M4y_v"     name="M4_y_v"  />
+          <field field_ref="Q1x_v"     name="Q1_x_v"  />
+          <field field_ref="Q1y_v"     name="Q1_y_v"  />
+          <field field_ref="O1x_v"     name="O1_x_v"  />
+          <field field_ref="O1y_v"     name="O1_y_v"  />
+          <field field_ref="P1x_v"     name="P1_x_v"  />
+          <field field_ref="P1y_v"     name="P1_y_v"  />
+          <field field_ref="S1x_v"     name="S1_x_v" />
+          <field field_ref="S1y_v"     name="S1_y_v" />
+          <field field_ref="2N2x_v"    name="a2N2_x_v" />
+          <field field_ref="2N2y_v"    name="a2N2_y_v" />
+          <field field_ref="MU2x_v"    name="MU2_x_v" />
+          <field field_ref="MU2y_v"    name="MU2_y_v" />
+          <field field_ref="NU2x_v"    name="NU2_x_v" />
+          <field field_ref="NU2y_v"    name="NU2_y_v" />
+          <field field_ref="L2x_v"     name="L2_x_v" />
+          <field field_ref="L2y_v"     name="L2_y_v" />
+          <field field_ref="T2x_v"     name="T2_x_v" />
+          <field field_ref="T2y_v"     name="T2_y_v" />
+        </file>
+-->
+      </file_group>
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
diff --git a/EXP_Apr19/iodef.xml b/EXP_Apr19/iodef.xml
new file mode 100755
index 0000000..9a1f846
--- /dev/null
+++ b/EXP_Apr19/iodef.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<simulation> 
+
+<!-- ============================================================================================ -->
+<!-- XIOS context                                                                                 -->
+<!-- ============================================================================================ -->
+
+  <context id="xios">
+
+      <variable_definition>
+	
+	  <variable id="info_level"                type="int">0</variable>
+	  <variable id="using_server"              type="bool">true</variable>
+	  <variable id="using_oasis"               type="bool">false</variable>
+	  <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+	
+      </variable_definition>
+               
+  </context>
+
+<!-- ============================================================================================ -->
+<!-- NEMO  CONTEXT add and suppress the components you need                                       -->
+<!-- ============================================================================================ -->
+
+  <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+  
+</simulation>
diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
new file mode 100755
index 0000000..8ba50b2
--- /dev/null
+++ b/EXP_Apr19/namelist_cfg
@@ -0,0 +1,407 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  : AMM12 configuration namelist used to overwrite defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  "BoBEAS"  !  experience name
+   nn_it000    = 1 ! 57601  !  first time step ! CHNAGE THIS TO END OF LAST RUN + 1
+   nn_itend    = 100 ! 218880 crashed in Apr16 ! 138240 !  last  time step (std 1 day = 144) (for dt = 6 min, so 240*dt = 1 day) ! CHANGE THIS TO THIS + 56 DAYS
+   nn_date0    =  20190401  !20110717 !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
+   nn_time0    =       0   !  initial time of day in hhmm
+   nn_leapy    =       1   !  Leap year calendar (1) or not (0)
+   ln_rstart   =  .false.  !  start from rest (F) or from a restart file (T)
+      nn_euler    =    1            !  = 0 : start with forward time step if ln_rstart=T
+      nn_rstctl   =    2            !  restart control ==> activated only if ln_rstart=T
+      !                             !    = 0 nn_date0 read in namelist ; nn_it000 : read in namelist
+      !                             !    = 1 nn_date0 read in namelist ; nn_it000 : check consistancy between namelist and restart
+      !                             !    = 2 nn_date0 read in restart  ; nn_it000 : check consistancy between namelist and restart
+      cn_ocerst_in    = "INDIAN_00138240_restart"   !  suffix of ocean restart name (input) ! CHANGE THIS TO LAST RESTART FILE NUMBER
+      cn_ocerst_indir = "./restarts"         !  directory from which to read input ocean restarts
+      cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
+      cn_ocerst_outdir= "./restarts"         !  directory in which to write output ocean restarts
+!   nn_euler    =       1   !  = 0 : start with forward time step if ln_rstart=.true.
+!   cn_ocerst_in   = "ammsurge_restart_oce"   !  suffix of ocean restart name (input)
+!   cn_ocerst_out  = "restart_oce_out"   !  suffix of ocean restart name (input)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_stock    =  100 ! 40320 =28days ! frequency of creation of a restart file (modulo referenced to 1) ! 28 DAYS
+   nn_write    =  10 ! 86400    !  frequency of write in the output file   (modulo referenced to nit000) 
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   ln_read_cfg = .true.   !  (=T) read the domain configuration file
+                          !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+   cn_domcfg = "domain_cfg.nc"         ! domain configuration filename
+/
+!-----------------------------------------------------------------------
+!&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+!   ln_zps      = .false.   !  z-coordinate - partial steps   (T/F)
+!   ln_sco      = .true.    !  s- or hybrid z-s-coordinate    (T/F)
+!/
+!-----------------------------------------------------------------------
+!&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+!   rn_sbot_min =    6.0    !  minimum depth of s-bottom surface (>0) (m)
+!   rn_hc       =    0.0    !  critical depth for transition to stretched coordinates
+!   rn_rmax     =    1.0    !  maximum cut-off r-value allowed (0<r_max<1)
+!   rn_theta    =    0.0    !  surface control parameter (0<=theta<=20)
+!/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+!   ln_2d        = .false.  !  (=T) run in 2D barotropic mode (no tracer processes or vertical diffusion)
+   rn_rdt      =   60.    !  time step for the dynamics (and tracer if nn_acc=0)
+/
+
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+!              !  file name                 ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                            !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_tem = 'initcd_votemper.nc',      -1      ,'votemper',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'initcd_vosaline.nc',      -1      ,'vosaline',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_dep = 'initcd_depth.nc'   ,      -12        ,'gdept_4D',   .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
+   sn_msk = 'sosie_initcd_mask.nc',    -12        ,'mask',       .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
+
+   !
+   cn_dir      = './ICS/'      !  root directory for the location of the runoff files
+   ln_tsd_init = .true.    !  Initialisation of ocean T & S with T & S input data (T) or not (F)
+   ln_tsd_interp = .true.    !  Interpolation of T & S in the verticalinput data (T) or not (F)
+   ln_tsd_tradmp = .false.  !  damping of ocean T & S toward T & S input data (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation
+                           !     (also = the frequency of sea-ice model call)
+   ln_usr =  .false.
+   ln_blk =  .true.
+   ln_apr_dyn  = .false.    !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+   ln_rnf      = .true.   !  Runoffs                                   (T => fill namsbc_rnf) 
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   ln_traqsr   = .false.   !  Light penetration in the ocean            (T => fill namtra_qsr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+/
+
+
+!-----------------------------------------------------------------------
+&namsbc_usr  !   namsbc_surge   surge model fluxes
+!-----------------------------------------------------------------------
+   ln_use_sbc  = .false.    ! (T) to turn on surge fluxes (wind and pressure only)
+                            ! (F) for no fluxes (ie tide only case)
+
+!
+!              !  file name                    ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation !
+!              !                               !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  !
+!   sn_wndi     = 'CARIB_u10_weights_bicubic_atmos.nc'              ,       1           ,'x_wind',   .true.     , .false. , 'daily'  ,'weights_era5_INDIAN_bicubic.nc' , ''
+!   sn_wndj     = 'CARIB_v10_weights_bicubic_atmos.nc'              ,       1           ,'y_wind',   .true.     , .false. , 'daily'  ,'weights_era5_INDIAN_bicubic.nc' , ''
+   cn_dir      = './FORCING/'          !  root directory for the location of the bulk files
+   rn_vfac     = 1.                   !  multiplicative factor for ocean/ice velocity
+                                      !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
+   rn_charn_const = 0.0275
+/
+
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+/
+
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_apr= 'ERA5_MSL',        1         ,   'air_pressure_at_sea_level' ,    .true.    , .false., 'daily'   ,  'weights_era5_INDIAN_bicubic.nc'      ,   ''     ,  'ERA5_LSM'
+   cn_dir      = './FORCING/'!  root directory for the location of the bulk files
+   rn_pref     = 101200.    !  reference atmospheric pressure   [N/m2]/
+   ln_ref_apr  = .false.    !  ref. pressure: global mean Patm (T) or a constant (F)
+   ln_apr_obc  = .true.     !  inverse barometer added to OBC ssh data
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters                                   (default: No iceberg)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =     0     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+
+!-----------------------------------------------------------------------
+&nam_tide      !   tide parameters
+!-----------------------------------------------------------------------
+   ln_tide     = .true.
+   rdttideramp =    0
+   clname(1)     =   'M2'   !  name of constituent
+   clname(2)     =   'K2'
+   clname(3)     =   'S2'
+   clname(4)     =   'N2'
+   clname(5)     =   'Q1'   !  name of constituent
+   clname(6)     =   'O1'
+   clname(7)     =   'P1'
+   clname(8)     =   'K1'
+!   clname(5)     =   '2N2'
+!   clname(6)     =   'MU2'
+!   clname(7)     =   'N2'
+!   clname(8)     =   'NU2'
+!   clname(9)     =   'M2'
+!   clname(10)    =   'L2'
+!   clname(11)    =   'T2'
+!   clname(12)    =   'S2'
+!   clname(13)    =   'K2'
+!   clname(14)    =   'M4'
+!   clname(15)    =   '2MK6'
+!   clname(16)    =   '2MS6'
+!   clname(17)    =   '2SM2'
+!   clname(18)    =   '3M2S2'
+!   clname(19)    =   'Lam2'
+!   clname(20)    =   'M6'
+!   clname(21)    =   'MK3'
+!   clname(22)    =   'MN4'
+!   clname(23)    =   'MNS2'
+!   clname(24)    =   'MO3'
+!   clname(25)    =   'MS4'
+!   clname(26)    =   'MSN2'
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries
+!-----------------------------------------------------------------------
+   ln_bdy     = .true.
+   nb_bdy         = 1                    !  number of open boundary sets
+   cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
+   cn_dyn2d       = 'flather'            ! was flather
+   nn_dyn2d_dta   =  0                   !  = 0, bdy data are equal to the initial state
+                                         !  = 1, bdy data are read in 'bdydata   .nc' files
+                                         !  = 2, use tidal harmonic forcing data from files
+                                         !  = 3, use external data AND tidal harmonic forcing
+
+    cn_dyn3d      =  'frs'               !
+    nn_dyn3d_dta  =  0                   !  = 0, bdy data are equal to the initial state
+                                         !  = 1, bdy data are read in 'bdydata   .nc' files
+
+
+   cn_tra        =  'frs'                ! 'frs'
+   nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
+                                         !  = 1, bdy data are read in 'bdydata   .nc' files
+   nn_rimwidth   = 1                     !  width of the relaxation zone
+   ln_tra_dmp    = .false.
+/
+!-----------------------------------------------------------------------
+&nambdy_dta      !  open boundaries - external data
+!-----------------------------------------------------------------------
+!              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   bn_ssh      = 'INDIAN_bdy_SSH' ,    24        , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u2d      = 'INDIAN_bdy_U'    ,    24        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v2d      = 'INDIAN_bdy_V'    ,    24        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u3d      = 'INDIAN_bdy_U'    ,    24        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v3d      = 'INDIAN_bdy_V'    ,    24        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_tem      = 'INDIAN_bdy_TEMP',    24        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_sal      = 'INDIAN_bdy_SAL' ,    24        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at open boundaries
+!-----------------------------------------------------------------------
+   filtide      = 'TIDES/INDIAN_bdytide_rotT_'         !  file name root of tidal forcing files
+   ln_bdytide_2ddta = .false. 
+   ln_bdytide_conj  = .false.                   !
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri2    =    2.4e-3 !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    0.0e0  !  bottom turbulent kinetic energy background  (m2/s2)
+   ln_loglayer =   .false. !  loglayer bottom friction (only effect when nn_bfr = 2)
+   rn_bfrz0    =    0.003  !  bottom roughness (only effect when ln_loglayer = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+   nn_bbl_ldf  =  0      !  diffusive bbl (=1)   or not (=0)
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   ln_teos10   = .true.         !  = Use TEOS-10 equation of state
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.                         (default: NO)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .true.    !  s-coordinate (Standard Jacobian scheme)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+   ln_dynspg_ts = .true.    ! split-explicit free surface
+   ln_bt_auto =    .true.           !  Set nn_baro automatically to be just below
+                                       !  a user defined maximum courant number (rn_bt_cmax)
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   ln_dynldf_blp  =  .true.   !  bilaplacian operator
+   ln_dynldf_lap    =  .false.  !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev  =  .true.   !  iso-level
+                           !  Coefficient
+   rn_ahm_0     = 60.0      !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_bhm_0     = -1.0e+9   !  horizontal bilaplacian eddy viscosity [m4/s]
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   0.1e-6  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   0.1e-6  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   ln_zdfevd   = .false.   !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+/
+!-----------------------------------------------------------------------
+&namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namnc4        !   netcdf4 chunking and compression settings            ("key_netcdf4")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ("key_trdmld" or     "key_trdvor")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdiu        !   Cool skin and warm layer models                       (default F)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents ('key_diaharm')
+!-----------------------------------------------------------------------
+    nit000_han = 1 !43201     ! First time step used for harmonic analysis
+    nitend_han = 43680 !86400      ! Last time step used for harmonic analysis
+    nstep_han  = 5         ! Time step frequency for harmonic analysis
+    tname(1)   = 'M2'      ! Name of tidal constituents
+    tname(2)   = 'K2'
+    tname(3)   = 'S2'
+/
+!-----------------------------------------------------------------------
+&namdct        ! transports through sections
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diatmb    !  Top Middle Bottom Output                               (default F)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_dia25h    !  25h Mean Output                                        (default F)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage switch                               ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namwad       !   Wetting and Drying namelist
+!-----------------------------------------------------------------------
+   ln_wd = .false.   !: key to turn on/off wetting/drying (T: on, F: off) 
+   rn_wdmin1=0.1     !: minimum water depth on dried cells 
+   rn_wdmin2 = 0.01  !: tolerrance of minimum water depth on dried cells
+   rn_wdld   = 20.0  !: land elevation below which wetting/drying will be considered
+   nn_wdit   =   10  !: maximum number of iteration for W/D limiter
+/
diff --git a/EXP_Apr19/namelist_ref b/EXP_Apr19/namelist_ref
new file mode 100755
index 0000000..d301714
--- /dev/null
+++ b/EXP_Apr19/namelist_ref
@@ -0,0 +1,1200 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!!                            namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namcfg, namzgr, namdom, namtsd, namcrs, namc1d, namc1d_uvd)
+!!              3 - Surface boundary (namsbc, namsbc_flx, namsbc_blk, namsbc_sas)
+!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf,
+!!                                    namsbc_apr, namsbc_ssr, namsbc_alb, namsbc_wave)
+!!              4 - lateral boundary (namlbc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_ldfeiv, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_ddm, namzdf_tmx, namzdf_tmx_new)
+!!              9 - diagnostics      (namnc4, namtrd, namspr, namflo, namhsb, namsto)
+!!             10 - miscellaneous    (nammpp, namctl)
+!!             11 - Obs & Assim      (namobs, nam_asminc)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun       parameters of the run
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number (no more used...)
+   cn_exp      =  "ORCA2"  !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =    5475   !  last  time step (std 5475)
+   nn_date0    =  010101   !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
+   nn_time0    =       0   !  initial time of day in hhmm
+   nn_leapy    =       0   !  Leap year calendar (1) or not (0)
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+      nn_euler    =    1            !  = 0 : start with forward time step if ln_rstart=T
+      nn_rstctl   =    0            !  restart control ==> activated only if ln_rstart=T
+      !                             !    = 0 nn_date0 read in namelist ; nn_it000 : read in namelist
+      !                             !    = 1 nn_date0 read in namelist ; nn_it000 : check consistancy between namelist and restart
+      !                             !    = 2 nn_date0 read in restart  ; nn_it000 : check consistancy between namelist and restart
+      cn_ocerst_in    = "restart"   !  suffix of ocean restart name (input)
+      cn_ocerst_indir = "."         !  directory from which to read input ocean restarts
+      cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
+      cn_ocerst_outdir= "."         !  directory in which to write output ocean restarts
+   ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
+   nn_stock    =    5475   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
+   nn_write    =    5475   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_cfmeta   = .false.   !  output additional data to netCDF files required for compliance with the CF metadata standard
+   ln_clobber  = .true.    !  clobber (overwrite) an existing file
+   nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (works only with iom_nf90 routines)
+/
+!
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namcfg       parameters of the configuration
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!   namwad       Wetting and drying                                    (default F)
+!!   namtsd       data: temperature & salinity
+!!   namcrs       coarsened grid (for outputs and/or TOP)               ("key_crs")
+!!   namc1d       1D configuration options                              ("key_c1d")
+!!   namc1d_dyndmp 1D newtonian damping applied on currents             ("key_c1d")
+!!   namc1d_uvd   1D data (currents)                                    ("key_c1d")
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   ln_read_cfg = .false.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "domain_cfg"         ! domain configuration filename
+      !
+   ln_write_cfg= .false.   !  (=T) create the domain configuration file
+      cn_domcfg_out = "domain_cfg_out" ! newly created domain configuration filename
+      !
+   ln_use_jattr = .false.  !  use (T) the file attribute: open_ocean_jstart, if present
+   !                       !  in netcdf input files, as the start j-row for reading
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   ln_linssh   = .false.   !  =T  linear free surface  ==>>  model level are fixed in time
+   nn_closea   =    0      !  remove (=0) or keep (=1) closed seas and lakes (ORCA)
+   !
+   nn_msh      =    0      !  create (>0) a mesh file or not (=0)
+   rn_isfhmin  =    1.00   !  treshold (m) to discriminate grounding ice to floating ice
+   !
+   rn_rdt      = 5760.     !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   !
+   ln_crs      = .false.   !  Logical switch for coarsening module
+/
+!-----------------------------------------------------------------------
+&namtsd        !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+!              !  file name                 ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                            !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_tem = './ICS/initcd_votemper.nc',      -1      ,'votemper',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = './ICS/initcd_vosaline.nc',      -1      ,'vosaline',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+
+
+   !
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_tsd_init = .true.    !  Initialisation of ocean T & S with T & S input data (T) or not (F)
+   ln_tsd_tradmp = .true.  !  damping of ocean T & S toward T & S input data (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namwad        !   Wetting and drying                                   (default F)
+!-----------------------------------------------------------------------
+   ln_wd       = .false.   !  T/F activation of wetting and drying
+   rn_wdmin1   =  0.1      !  Minimum wet depth on dried cells
+   rn_wdmin2   =  0.01     !  Tolerance of min wet depth on dried cells
+   rn_wdld     =  20.0     !  Land elevation below which wetting/drying is allowed
+   nn_wdit     =  10       !  Max iterations for W/D limiter
+/
+!-----------------------------------------------------------------------
+&namcrs        !   coarsened grid (for outputs and/or TOP)              ("key_crs")
+!-----------------------------------------------------------------------
+   nn_factx    = 3         !  Reduction factor of x-direction
+   nn_facty    = 3         !  Reduction factor of y-direction
+   nn_binref   = 0         !  Bin centering preference: NORTH or EQUAT
+                           !  0, coarse grid is binned with preferential treatment of the north fold
+                           !  1, coarse grid is binned with centering at the equator
+                           !    Symmetry with nn_facty being odd-numbered. Asymmetry with even-numbered nn_facty.
+   nn_msh_crs  = 1         !  create (=1) a mesh file or not (=0)
+   nn_crs_kz   = 0         ! 0, MEAN of volume boxes
+                           ! 1, MAX of boxes
+                           ! 2, MIN of boxes
+   ln_crs_wn   = .true.    ! wn coarsened (T) or computed using horizontal divergence ( F )
+/
+!-----------------------------------------------------------------------
+&namc1d        !   1D configuration options                             ("key_c1d")
+!-----------------------------------------------------------------------
+   rn_lat1d    =      50   !  Column latitude (default at PAPA station)
+   rn_lon1d    =    -145   !  Column longitude (default at PAPA station)
+   ln_c1d_locpt=  .true.   ! Localization of 1D config in a grid (T) or independant point (F)
+/
+!-----------------------------------------------------------------------
+&namc1d_dyndmp !   U & V newtonian damping                              ("key_c1d")
+!-----------------------------------------------------------------------
+   ln_dyndmp   =  .false.  !  add a damping term (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namc1d_uvd    !   data: U & V currents                                 ("key_c1d")
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_ucur     = 'ucurrent'  ,         -1        ,'u_current',   .false.    , .true. , 'monthly' ,  ''      ,  'Ume'   , ''
+   sn_vcur     = 'vcurrent'  ,         -1        ,'v_current',   .false.    , .true. , 'monthly' ,  ''      ,  'Vme'   , ''
+!
+   cn_dir        = './'    !  root directory for the location of the files
+   ln_uvd_init   = .false. !  Initialisation of ocean U & V with U & V input data (T) or not (F)
+   ln_uvd_dyndmp = .false. !  damping of ocean U & V toward U & V input data (T) or not (F)
+/
+
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc          surface boundary condition
+!!   namsbc_flx      flux               formulation                     (ln_flx     =T)
+!!   namsbc_blk      Bulk formulae formulation                          (ln_blk     =T)
+!!   namsbc_cpl      CouPLed            formulation                     ("key_oasis3" )
+!!   namsbc_sas      Stand-Alone Surface module
+!!   namtra_qsr      penetrative solar radiation                        (ln_traqsr  =T)
+!!   namsbc_rnf      river runoffs                                      (ln_rnf     =T)
+!!   namsbc_isf      ice shelf melting/freezing                         (nn_isf     >0)
+!!   namsbc_iscpl    coupling option between land ice model and ocean
+!!   namsbc_apr      Atmospheric Pressure                               (ln_apr_dyn =T)
+!!   namsbc_ssr      sea surface restoring term (for T and/or S)        (ln_ssr     =T)
+!!   namsbc_alb      albedo parameters
+!!   namsbc_wave     external fields from wave model                    (ln_wave    =T)
+!!   namberg         iceberg floats                                     (ln_icebergs=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 5         !  frequency of surface boundary condition computation
+                           !     (also = the frequency of sea-ice & iceberg model call)
+                     ! Type of air-sea fluxes 
+   ln_usr      = .false.   !  user defined formulation                  (T => check usrdef_sbc)
+   ln_flx      = .false.   !  flux formulation                          (T => fill namsbc_flx )
+   ln_blk      = .true.    !  Bulk formulation                          (T => fill namsbc_blk )
+                     ! Type of coupling (Ocean/Ice/Atmosphere) :
+   ln_cpl      = .false.   !  atmosphere coupled   formulation          ( requires key_oasis3 )
+   ln_mixcpl   = .false.   !  forced-coupled mixed formulation          ( requires key_oasis3 )
+   nn_components = 0       !  configuration of the opa-sas OASIS coupling
+                           !  =0 no opa-sas OASIS coupling: default single executable configuration
+                           !  =1 opa-sas OASIS coupling: multi executable configuration, OPA component
+                           !  =2 opa-sas OASIS coupling: multi executable configuration, SAS component 
+   nn_limflx = -1          !  LIM3 Multi-category heat flux formulation (use -1 if LIM3 is not used)
+                           !  =-1  Use per-category fluxes, bypass redistributor, forced mode only, not yet implemented coupled
+                           !  = 0  Average per-category fluxes (forced and coupled mode)
+                           !  = 1  Average and redistribute per-category fluxes, forced mode only, not yet implemented coupled
+                           !  = 2  Redistribute a single flux over categories (coupled mode only)
+                     ! Sea-ice :
+   nn_ice      = 3         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 to 4 :  ice-model used (LIM2, LIM3 or CICE)                         ("key_lim3", "key_lim2", or "key_cice")
+   nn_ice_embd = 1         !  =0 levitating ice (no mass exchange, concentration/dilution effect)
+                           !  =1 levitating ice with mass and salt exchange but no presure effect
+                           !  =2 embedded sea-ice (full salt and mass exchanges and pressure)
+                     ! Misc. options of sbc : 
+   ln_traqsr   = .false.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle on short wave
+   ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
+   ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   nn_fwb      = 2         !  FreshWater Budget: =0 unchecked
+                           !     =1 global mean of e-p-r set to zero at each time step
+                           !     =2 annual global mean of e-p-r set to zero
+   ln_apr_dyn  = .false.   !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
+   ln_isf      = .false.   !  ice shelf                                 (T   => fill namsbc_isf)
+   ln_wave     = .false.   !  Activate coupling with wave  (T => fill namsbc_wave)
+   ln_cdgw     = .false.   !  Neutral drag coefficient read from wave model (T => ln_wave=.true. & fill namsbc_wave)
+   ln_sdw      = .false.   !  Read 2D Surf Stokes Drift & Computation of 3D stokes drift (T => ln_wave=.true. & fill namsbc_wave) 
+   ln_tauoc    = .false.   !  Activate ocean stress modified by external wave induced stress (T => ln_wave=.true. & fill namsbc_wave)
+   ln_stcor    = .false.   !  Activate Stokes Coriolis term (T => ln_wave=.true. & ln_sdw=.true. & fill namsbc_wave)
+   nn_lsm      = 1         !  =0 land/sea mask for input fields is not applied (keep empty land/sea mask filename field) ,
+                           !  =1:n number of iterations of land/sea mask application for input fields (fill land/sea mask filename field)
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_utau     = 'utau'      ,        24         , 'utau'    , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_vtau     = 'vtau'      ,        24         , 'vtau'    , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_qtot     = 'qtot'      ,        24         , 'qtot'    , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_qsr      = 'qsr'       ,        24         , 'qsr'     , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_emp      = 'emp'       ,        24         , 'emp'     , .false.      , .false., 'yearly'  , ''       , ''       , ''
+
+   cn_dir      = './fluxes/'      !  root directory for the location of the flux files
+/
+!-----------------------------------------------------------------------
+&namsbc_blk   !   namsbc_blk  generic Bulk formula                      (ln_blk = T)
+!-----------------------------------------------------------------------
+!              !  file name                   ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights                              ! rotation ! land/sea mask !
+!              !                              !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename                             ! pairing  ! filename      !
+   sn_humi=          'ERA5_SPH',                        1,            'SPH',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM' 
+   sn_prec=          'ERA5_TP',                         1,            'TP',        .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   sn_qlw =          'ERA5_STRD',                       1,            'STRD',      .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   sn_qsr=           'ERA5_SSRD',                       1,            'SSRD',      .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   sn_snow=          'ERA5_SF',                          1,            'SF',        .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   sn_tair=          'ERA5_T2M',                         1,            'T2M',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   sn_wndi=          'ERA5_U10',                        1,            'U10',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    'Uwnd',       'ERA5_LSM'
+   sn_wndj=          'ERA5_V10',                        1,            'V10',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    'Vwnd',       'ERA5_LSM'
+   sn_slp=           'SPH_ERA5_SP',                     1,            'SP',        .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+!   sn_tdif=          'SPH_ERA5_D2M',                    1,            'D2M',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   !                    !  bulk algorithm :
+   ln_NCAR     = .true.   ! "NCAR"      algorithm   (Large and Yeager 2008)
+   ln_COARE_3p0= .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
+   ln_COARE_3p5= .false.   ! "COARE 3.5" algorithm   (Edson et al. 2013)
+   ln_ECMWF    = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
+   !
+   cn_dir      = './fluxes/'      !  root directory for the location of the bulk files
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data
+   rn_zqt      = 2.       !  Air temperature and humidity reference height (m)
+   rn_zu       = 10.       !  Wind vector reference height (m)
+   rn_pfac     = 1.     !  multiplicative factor for precipitation (total & snow)
+   rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
+   rn_vfac     = 1.        !  multiplicative factor for ocean/ice velocity
+                           !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
+   ln_Cd_L12   = .false.   !  Modify the drag ice-atm and oce-atm depending on ice concentration
+                           !  This parameterization is from Lupkes et al. (JGR 2012)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
+!-----------------------------------------------------------------------
+!                    !     description      !  multiple  !    vector   !      vector          ! vector !
+!                    !                      ! categories !  reference  !    orientation       ! grids  !
+! send
+   sn_snd_temp   =   'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_alb    =   'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_thick  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_crt    =   'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+   sn_snd_co2    =   'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_crtw   =       'none'                 ,    'no'    ,     ''      ,         ''           , 'U,V'
+   sn_snd_ifrac  =       'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_wlev   =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
+! receive
+   sn_rcv_w10m   =   'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_taumod =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_tau    =   'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
+   sn_rcv_dqnsdt =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_qsr    =   'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_qns    =   'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_emp    =   'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_rnf    =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_cal    =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_co2    =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_hsig   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_iceflx =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_mslp   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_phioc  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_sdrfx  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_sdrfy  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wper   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wnum   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wstrf  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wdrag  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+!
+   nn_cplmodel   =     1   !  Maximum number of models to/from which NEMO is potentialy sending/receiving data
+   ln_usecplmask = .false. !  use a coupling mask file to merge data received from several models
+   !                       !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
+/
+!-----------------------------------------------------------------------
+&namsbc_sas    !   Stand Alone Surface boundary condition
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   l_sasread   = .TRUE.   ! Read fields in a file if .TRUE. , or initialize to 0. in sbcssm.F90 if .FALSE.
+   sn_usp      = 'sas_grid_U',     120           , 'vozocrtx',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_vsp      = 'sas_grid_V',     120           , 'vomecrty',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem      = 'sas_grid_T',     120           , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal      = 'sas_grid_T',     120           , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_ssh      = 'sas_grid_T',     120           , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_e3t      = 'sas_grid_T',     120           , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_frq      = 'sas_grid_T',     120           , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+
+   ln_3d_uve   = .true.    !  specify whether we are supplying a 3D u,v and e3 field
+   ln_read_frq = .false.   !  specify whether we must read frq or not
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr=T)
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_chl      ='chlorophyll',        -1         , 'CHLA'    ,   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      1    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   ln_qsr_ice  = .false.    !  light penetration for ice-model LIM3
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition          (ln_rnf=T)
+!-----------------------------------------------------------------------
+!              !  file name           ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                      !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_rnf      = 'river_test'         ,        -1         , 'rorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'river_test'         ,         0         , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,        24         , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,        24         , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,         0         , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_rnf_mouth= .false.    !  specific treatment at rivers mouths
+      rn_hrnf     =  15.e0    !  depth over which enhanced vertical mixing is used    (ln_rnf_mouth=T)
+      rn_avt_rnf  =   1.e-3   !  value of the additional vertical mixing coef. [m2/s] (ln_rnf_mouth=T)
+   rn_rfact    =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth= .false.   !  read in depth information for runoff
+   ln_rnf_tem  = .false.   !  read in temperature information for runoff
+   ln_rnf_sal  = .false.   !  read in salinity information for runoff
+   ln_rnf_depth_ini = .false. ! compute depth at initialisation from runoff file
+      rn_rnf_max  = 5.735e-4  !  max value of the runoff climatologie over global domain ( ln_rnf_depth_ini = .true )
+      rn_dep_max  = 150.      !  depth over which runoffs is spread ( ln_rnf_depth_ini = .true )
+      nn_rnf_depth_file = 0   !  create (=1) a runoff depth file or not (=0)
+/
+!-----------------------------------------------------------------------
+&namsbc_isf    !  Top boundary layer (ISF)                              (nn_isf >0)
+!-----------------------------------------------------------------------
+!              ! file name ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+! nn_isf == 4
+   sn_fwfisf   = 'rnfisf'  ,         -12       ,'sowflisf',   .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+! nn_isf == 3
+   sn_rnfisf   = 'rnfisf'  ,         -12       ,'sofwfisf',   .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+! nn_isf == 2 and 3
+   sn_depmax_isf='rnfisf'  ,         -12       ,'sozisfmax',  .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_depmin_isf='rnfisf'  ,         -12       ,'sozisfmin',  .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+! nn_isf == 2
+   sn_Leff_isf = 'rnfisf'  ,         -12       ,'Leff'    ,   .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+!
+! for all case
+   nn_isf      = 1         !  ice shelf melting/freezing
+                           !  1 = presence of ISF    2 = bg03 parametrisation 
+                           !  3 = rnf file for isf   4 = ISF fwf specified
+                           !  option 1 and 4 need ln_isfcav = .true. (domzgr)
+! only for nn_isf = 1 or 2
+   rn_gammat0  = 1.e-4     ! gammat coefficient used in blk formula
+   rn_gammas0  = 1.e-4     ! gammas coefficient used in blk formula
+! only for nn_isf = 1 or 4
+   rn_hisf_tbl =  30.      ! thickness of the top boundary layer    (Losh et al. 2008)
+   !                       ! 0 => thickness of the tbl = thickness of the first wet cell
+! only for nn_isf = 1
+   nn_isfblk   = 1         ! 1 ISOMIP  like: 2 equations formulation (Hunter et al., 2006)
+   !                       ! 2 ISOMIP+ like: 3 equations formulation (Asay-Davis et al., 2015)
+   nn_gammablk = 1         ! 0 = cst Gammat (= gammat/s)
+   !                       ! 1 = velocity dependend Gamma (u* * gammat/s)  (Jenkins et al. 2010)
+   !                       ! 2 = velocity and stability dependent Gamma    (Holland et al. 1999)
+/
+!-----------------------------------------------------------------------
+&namsbc_iscpl  !   land ice / ocean coupling option                     
+!-----------------------------------------------------------------------
+   nn_drown    = 10        ! number of iteration of the extrapolation loop (fill the new wet cells)
+   ln_hsb      = .false.   ! activate conservation module (conservation exact after a time of rn_fiscpl)
+   nn_fiscpl   = 43800     ! (number of time step) conservation period (maybe should be fix to the coupling frequencey of restart frequency)
+/
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing           (ln_apr_dyn =T)
+!-----------------------------------------------------------------------
+!              ! file name ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_apr      = 'patm'    ,         -1        ,'somslpre',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,      ''
+
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   rn_pref     = 101000.   !  reference atmospheric pressure   [N/m2]/
+   ln_ref_apr  = .false.   !  ref. pressure: global mean Patm (T) or a constant (F)
+   ln_apr_obc  = .false.   !  inverse barometer added to OBC ssh data
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring   (ln_ssr=T)
+!-----------------------------------------------------------------------
+!              ! file name ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !   name   !   (logical) !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_sst      = 'sst_data',        24         ,  'sst'   ,    .false.  , .false., 'yearly'  ,    ''    ,    ''    ,     ''
+   sn_sss      = 'sss_data',        -1         ,  'sss'   ,    .true.   , .true. , 'yearly'  ,    ''    ,    ''    ,     ''
+
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     2     !  add a damping     term in the surface freshwater flux (=2)
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =  -166.67  !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =  .true.   !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+   nn_ice_alb   =    1   !  parameterization of ice/snow albedo
+                         !     0: Shine & Henderson-Sellers (JGR 1985), giving clear-sky albedo
+                         !     1: "home made" based on Brandt et al. (JClim 2005) and Grenfell & Perovich (JGR 2004),
+                         !        giving cloud-sky albedo
+   rn_alb_sdry  =  0.85  !  dry snow albedo         : 0.80 (nn_ice_alb = 0); 0.85 (nn_ice_alb = 1); obs 0.85-0.87 (cloud-sky)
+   rn_alb_smlt  =  0.75  !  melting snow albedo     : 0.65 ( '' )          ; 0.75 ( '' )          ; obs 0.72-0.82 ( '' )
+   rn_alb_idry  =  0.60  !  dry ice albedo          : 0.72 ( '' )          ; 0.60 ( '' )          ; obs 0.54-0.65 ( '' )
+   rn_alb_imlt  =  0.50  !  bare puddled ice albedo : 0.53 ( '' )          ; 0.50 ( '' )          ; obs 0.49-0.58 ( '' )
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model                        (ln_wave=T)
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable     ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name       !   (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_cdg      =  'sdw_wave' ,        1          , 'drag_coeff' ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_usd      =  'sdw_wave' ,        1          , 'u_sd2d'     ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_vsd      =  'sdw_wave' ,        1          , 'v_sd2d'     ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_hsw      =  'sdw_wave' ,        1          , 'hs'         ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_wmp      =  'sdw_wave' ,        1          , 'wmp'        ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_wnum     =  'sdw_wave' ,        1          , 'wave_num'   ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_tauoc    =  'sdw_wave' ,        1          , 'wave_stress',     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+!
+   cn_dir  = './'  !  root directory for the location of drag coefficient files
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters                                   (default: No iceberg)
+!-----------------------------------------------------------------------
+   ln_icebergs              = .false.              ! iceberg floats or not
+   ln_bergdia               = .true.               ! Calculate budgets
+   nn_verbose_level         = 1                    ! Turn on more verbose output if level > 0
+   nn_verbose_write         = 15                   ! Timesteps between verbose messages
+   nn_sample_rate           = 1                    ! Timesteps between sampling for trajectory storage
+                                                   ! Initial mass required for an iceberg of each class
+   rn_initial_mass          = 8.8e7, 4.1e8, 3.3e9, 1.8e10, 3.8e10, 7.5e10, 1.2e11, 2.2e11, 3.9e11, 7.4e11
+                                                   ! Proportion of calving mass to apportion to each class
+   rn_distribution          = 0.24, 0.12, 0.15, 0.18, 0.12, 0.07, 0.03, 0.03, 0.03, 0.02
+                                                   ! Ratio between effective and real iceberg mass (non-dim)
+                                                   ! i.e. number of icebergs represented at a point
+   rn_mass_scaling          = 2000, 200, 50, 20, 10, 5, 2, 1, 1, 1
+                                                   ! thickness of newly calved bergs (m)
+   rn_initial_thickness     = 40., 67., 133., 175., 250., 250., 250., 250., 250., 250.
+   rn_rho_bergs             = 850.                 ! Density of icebergs
+   rn_LoW_ratio             = 1.5                  ! Initial ratio L/W for newly calved icebergs
+   ln_operator_splitting    = .true.               ! Use first order operator splitting for thermodynamics
+   rn_bits_erosion_fraction = 0.                   ! Fraction of erosion melt flux to divert to bergy bits
+   rn_sicn_shift            = 0.                   ! Shift of sea-ice concn in erosion flux (0<sicn_shift<1)
+   ln_passive_mode          = .false.              ! iceberg - ocean decoupling
+   nn_test_icebergs         =  10                  ! Create test icebergs of this class (-1 = no)
+                                                   ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
+   rn_test_box              = 108.0,  116.0, -66.0, -58.0
+   rn_speed_limit           = 0.                   ! CFL speed limit for a berg
+
+!         ! file name ! frequency (hours) !   variable   ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!         !           !  (if <0  months)  !     name     !   (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_icb =  'calving',       -1          , 'calvingmask',  .true.      , .true.  , 'yearly'  , ''       , ''       , ''
+
+   cn_dir = './'
+/
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
+!!   nam_tide      Tidal forcing 
+!!   nambdy        Unstructured open boundaries                         
+!!   nambdy_dta    Unstructured open boundaries - external data         
+!!   nambdy_tide   tidal forcing at open boundaries                     
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   !                       !  free slip  !   partial slip  !   no slip   ! strong slip
+   rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+   ln_vorlat   = .false.   !  consistency of vorticity boundary condition with analytical Eqs.
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+   nn_cln_update =    3    !  baroclinic update frequency
+   ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
+   rn_sponge_tra = 2880.   !  coefficient for tracer   sponge layer [m2/s]
+   rn_sponge_dyn = 2880.   !  coefficient for dynamics sponge layer [m2/s]
+   ln_chk_bathy  = .FALSE. !
+/
+!-----------------------------------------------------------------------
+&nam_tide      !   tide parameters
+!-----------------------------------------------------------------------
+   ln_tide     = .false.
+   ln_tide_pot = .true.    !  use tidal potential forcing
+   ln_tide_ramp= .false.   !
+   rdttideramp =    0.     !
+   clname(1)   = 'DUMMY'   !  name of constituent - all tidal components must be set in namelist_cfg
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          
+!-----------------------------------------------------------------------
+    ln_bdy         = .false.              !  Use unstructured open boundaries
+    nb_bdy         = 0                    !  number of open boundary sets
+    ln_coords_file = .true.               !  =T : read bdy coordinates from file
+    cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
+    ln_mask_file   = .false.              !  =T : read mask from file
+    cn_mask_file   = ''                   !  name of mask file (if ln_mask_file=.TRUE.)
+    cn_dyn2d       = 'none'               !
+    nn_dyn2d_dta   =  0                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+                                          !  = 2, use tidal harmonic forcing data from files
+                                          !  = 3, use external data AND tidal harmonic forcing
+    cn_dyn3d      =  'none'               !
+    nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_tra        =  'none'               !
+    nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_ice_lim      =  'none'             !
+    nn_ice_lim_dta  =  0                  !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    rn_ice_tem      = 270.                !  lim3 only: arbitrary temperature of incoming sea ice
+    rn_ice_sal      = 10.                 !  lim3 only:      --   salinity           --
+    rn_ice_age      = 30.                 !  lim3 only:      --   age                --
+
+    ln_tra_dmp    =.false.                !  open boudaries conditions for tracers
+    ln_dyn3d_dmp  =.false.                !  open boundary condition for baroclinic velocities
+    rn_time_dmp   =  1.                   ! Damping time scale in days
+    rn_time_dmp_out =  1.                 ! Outflow damping time scale
+    nn_rimwidth   = 10                    !  width of the relaxation zone
+    ln_vol        = .false.               !  total volume correction (see nn_volctl parameter)
+    nn_volctl     = 1                     !  = 0, the total water flux across open boundaries is zero
+    nb_jpk_bdy    = -1                    ! number of levels in the bdy data (set < 0 if consistent with planned run)
+/
+!-----------------------------------------------------------------------
+&nambdy_dta    !  open boundaries - external data                       
+!-----------------------------------------------------------------------
+!              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   bn_ssh      = 'INDIAN_bdyT_u2d',         1        , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u2d      = 'INDIAN_bdyU_u2d',         1        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v2d      = 'INDIAN_bdyV_u2d',         1        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u3d      = 'INDIAN_bdyU_u3d',         1        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v3d      = 'INDIAN_bdyV_u3d',         1        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_tem      = 'INDIAN_bdyT_tra',         1        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_sal      = 'INDIAN_bdyT_tra',         1        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+! for lim2
+!   bn_frld    = 'amm12_bdyT_ice',         24        , 'ileadfra',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_hicif   = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_hsnif   = 'amm12_bdyT_ice',         24        , 'isnowthi',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+! for lim3
+!   bn_a_i     = 'amm12_bdyT_ice',         24        , 'ileadfra',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_ht_i    = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_ht_s    = 'amm12_bdyT_ice',         24        , 'isnowthi',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+
+   cn_dir      = 'OBC/' !  root directory for the location of the bulk files
+   ln_full_vel = .false.   !  
+/
+!-----------------------------------------------------------------------
+&nambdy_tide   !  tidal forcing at open boundaries
+!-----------------------------------------------------------------------
+   filtide          = 'bdydta/amm12_bdytide_'   !  file name root of tidal forcing files
+   ln_bdytide_2ddta = .false.                   !
+   ln_bdytide_conj  = .false.                   ! 
+/
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl")
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction                                      (default: linear)
+!-----------------------------------------------------------------------
+   nn_bfr      =    1      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri1    =    4.e-4  !  bottom drag coefficient (linear case)
+   rn_bfri2    =    1.e-3  !  bottom drag coefficient (non linear case). Minimum coeft if ln_loglayer=T
+   rn_bfri2_max=    1.e-1  !  max. bottom drag coefficient (non linear case and ln_loglayer=T)
+   rn_bfeb2    =    2.5e-3 !  bottom turbulent kinetic energy background  (m2/s2)
+   rn_bfrz0    =    3.e-3  !  bottom roughness [m] if ln_loglayer=T
+   ln_bfr2d    = .false.   !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d=T)
+   rn_tfri1    =    4.e-4  !  top drag coefficient (linear case)
+   rn_tfri2    =    2.5e-3 !  top drag coefficient (non linear case). Minimum coeft if ln_loglayer=T
+   rn_tfri2_max=    1.e-1  !  max. top drag coefficient (non linear case and ln_loglayer=T)
+   rn_tfeb2    =    0.0    !  top turbulent kinetic energy background  (m2/s2)
+   rn_tfrz0    =    3.e-3  !  top roughness [m] if ln_loglayer=T
+   ln_tfr2d    = .false.   !  horizontal variation of the top friction coef (read a 2D mask file )
+   rn_tfrien   =   50.     !  local multiplying factor of tfr (ln_tfr2d=T)
+
+   ln_bfrimp   = .true.    !  implicit bottom friction (requires ln_zdfexp = .false. if true)
+   ln_loglayer = .false.   !  logarithmic formulation (non linear case)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition                (default: NO)
+!-----------------------------------------------------------------------
+!              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_qgh      ='geothermal_heating.nc',  -12.       , 'heatflow',   .false.   , .true.  , 'yearly'  ,   ''     ,   ''     ,   ''
+   !
+   ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+   cn_dir      = './'      !  root directory for the location of the runoff files 
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme                         ("key_trabbl")
+!-----------------------------------------------------------------------
+   nn_bbl_ldf  =  1        !  diffusive bbl (=1)   or not (=0)
+   nn_bbl_adv  =  0        !  advective bbl (=1/2) or not (=0)
+   rn_ahtbbl   =  1000.    !  lateral mixing coefficient in the bbl  [m2/s]
+   rn_gambbl   =  10.      !  advective bbl coefficient                 [s]
+/
+
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos           equation of state
+!!   namtra_adv       advection scheme
+!!   namtra_adv_mle   mixed layer eddy param. (Fox-Kemper param.)
+!!   namtra_ldf       lateral diffusion scheme
+!!   namtra_ldfeiv    eddy induced velocity param.
+!!   namtra_dmp       T & S newtonian damping
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   ln_teos10   = .false.         !  = Use TEOS-10 equation of state
+   ln_eos80    = .false.         !  = Use EOS80 equation of state
+   ln_seos     = .false.         !  = Use simplified equation of state (S-EOS)
+                                 !
+   !                     ! S-EOS coefficients (ln_seos=T):
+   !                             !  rd(T,S,Z)*rau0 = -a0*(1+.5*lambda*dT+mu*Z+nu*dS)*dT+b0*dS
+   rn_a0       =  1.6550e-1      !  thermal expension coefficient
+   rn_b0       =  7.6554e-1      !  saline  expension coefficient
+   rn_lambda1  =  5.9520e-2      !  cabbeling coeff in T^2  (=0 for linear eos)
+   rn_lambda2  =  7.4914e-4      !  cabbeling coeff in S^2  (=0 for linear eos)
+   rn_mu1      =  1.4970e-4      !  thermobaric coeff. in T (=0 for linear eos)
+   rn_mu2      =  1.1090e-5      !  thermobaric coeff. in S (=0 for linear eos)
+   rn_nu       =  2.4341e-3      !  cabbeling coeff in T*S  (=0 for linear eos)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO advection)
+!-----------------------------------------------------------------------
+   ln_traadv_cen = .false. !  2nd order centered scheme
+      nn_cen_h   =  4            !  =2/4, horizontal 2nd order CEN / 4th order CEN
+      nn_cen_v   =  4            !  =2/4, vertical   2nd order CEN / 4th order COMPACT
+   ln_traadv_fct = .false. !  FCT scheme
+      nn_fct_h   =  2            !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2            !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0            !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                          !        (number of sub-timestep = nn_fct_zts)
+   ln_traadv_mus = .false. !  MUSCL scheme
+      ln_mus_ups = .false.       !  use upstream scheme near river mouths
+   ln_traadv_ubs = .false. !  UBS scheme
+      nn_ubs_v   =  2            !  =2  , vertical 2nd order FCT / COMPACT 4th order
+   ln_traadv_qck = .true. !  QUICKEST scheme
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param) (default: NO)
+!-----------------------------------------------------------------------
+   ln_mle      = .false.   ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce       = 0.06      ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle      = 1         ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf       = 5.e+3     ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time     = 172800.   ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat      = 20.       ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv   = 0         ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv     = 0         ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle= 0.01      ! delta rho criterion used to calculate MLD for FK
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO diffusion)
+!-----------------------------------------------------------------------
+   !                       !  Operator type:
+   !                           !  no diffusion: set ln_traldf_lap=..._blp=F 
+   ln_traldf_lap   =  .false.  !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .false.  !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .false.  !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity and grid-spacing)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!-----------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.                         (default: NO)
+!-----------------------------------------------------------------------
+   ln_ldfeiv     =.false.  ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.false.  ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.   ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21      ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      (default: NO)
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .false.   !  add a damping termn (T) or not (F)
+   nn_zdmp     =    0      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   cn_resto    ='resto.nc' !  Name of file containing restoration coeff. field (use dmp_tools to create this)
+/
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: vector form)
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
+   nn_dynkeg     = 0       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+   ln_dynzad_zts = .false. !  Use (T) sub timestepping for vertical momentum advection
+/
+!-----------------------------------------------------------------------
+&nam_vvl    !   vertical coordinate options                             (default: zstar)
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  zstar vertical coordinate
+   ln_vvl_ztilde = .false.          !  ztilde vertical coordinate: only high frequency variations
+   ln_vvl_layer  = .false.          !  full layer vertical coordinate
+   ln_vvl_ztilde_as_zstar = .false. !  ztilde vertical coordinate emulating zstar
+   ln_vvl_zstar_at_eqtor  = .false. !  ztilde near the equator
+   rn_ahe3       = 0.0e0            !  thickness diffusion coefficient
+   rn_rst_e3t    = 30.e0            !  ztilde to zstar restoration timescale [days]
+   rn_lf_cutoff  = 5.0e0            !  cutoff frequency for low-pass filter  [days]
+   rn_zdef_max   = 0.9e0            !  maximum fractional e3t deformation
+   ln_vvl_dbg    = .true.           !  debug prints    (T/F)
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .false. !  energy & enstrophy scheme
+      nn_een_e3f = 1          ! e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   ln_dynvor_msk = .false. !  vorticity multiplied by fmask (=T) or not (=F) (all vorticity schemes)  ! PLEASE DO NOT ACTIVATE
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: zps)
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_isf  = .false.   !  s-coordinate (sco ) adapted to isf
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_prj  = .false.   !  s-coordinate (Pressure Jacobian scheme)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO)
+!-----------------------------------------------------------------------
+   ln_dynspg_exp  = .false.   ! explicit free surface
+   ln_dynspg_ts   = .false.   ! split-explicit free surface
+      ln_bt_fw      = .true.     ! Forward integration of barotropic Eqs.
+      ln_bt_av      = .true.     ! Time filtering of barotropic variables
+         nn_bt_flt     = 1          ! Time filter choice  = 0 None
+         !                          !                     = 1 Boxcar over   nn_baro sub-steps
+         !                          !                     = 2 Boxcar over 2*nn_baro  "    "
+      ln_bt_auto    = .true.     ! Number of sub-step defined from:
+         rn_bt_cmax   =  0.8        ! =T : the Maximum Courant Number allowed
+         nn_baro      = 30          ! =F : the number of sub-step in rn_rdt seconds
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO)
+!-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .false.    !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   !                                !  = 32  F(i,j,k)=F(local gridscale and deformation rate)
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
+   !                       !  Smagorinsky settings (nn_ahm_ijk_t  = 32) :
+   rn_csmc       = 3.5         !  Smagorinsky constant of proportionality
+   rn_minfac     = 1.0         !  multiplier of theorectical lower limit
+   rn_maxfac     = 1.0         !  multiplier of theorectical upper limit
+/
+
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!    namzdf        vertical physics
+!!    namzdf_ric    richardson number dependent vertical mixing         ("key_zdfric")
+!!    namzdf_tke    TKE dependent vertical mixing                       ("key_zdftke")
+!!    namzdf_gls    GLS vertical mixing                                 ("key_zdfgls")
+!!    namzdf_ddm    double diffusive mixing parameterization            ("key_zdfddm")
+!!    namzdf_tmx    tidal mixing parameterization                       ("key_zdftmx")
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+      nn_evdm     =    0        ! evd apply on tracer (=0) or on tracer and momentum (=1)
+      rn_avevd    =  100.       !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative Convective algorithm (T) or not (F)
+      nn_npc      =    1        ! frequency of application of npc
+      nn_npcp     =  365        ! npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+      nn_zdfexp   =    3        ! number of sub-timestep for ln_zdfexp=T
+   ln_zdfqiao  = .false.   !  Enhanced wave vertical mixing Qiao (2010) (T => ln_wave=.true. & ln_sdw=.true. & fill namsbc_wave)
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+   rn_avmri    =  100.e-4  !  maximum value of the vertical viscosity
+   rn_alp      =    5.     !  coefficient of the parameterization
+   nn_ric      =    2      !  coefficient of the parameterization
+   rn_ekmfc    =    0.7    !  Factor in the Ekman depth Equation
+   rn_mldmin   =    1.0    !  minimum allowable mixed-layer depth estimate (m)
+   rn_mldmax   = 1000.0    !  maximum allowable mixed-layer depth estimate (m)
+   rn_wtmix    =   10.0    !  vertical eddy viscosity coeff [m2/s] in the mixed-layer
+   rn_wvmix    =   10.0    !  vertical eddy diffusion coeff [m2/s] in the mixed-layer
+   ln_mldw     =  .true.   !  Flag to use or not the mixed layer depth param.
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =  67.83    !  coef. of the surface input of tke (=67.83 suggested when ln_mxl0=T)
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  ! background shear (>0) currently a numerical threshold (do not change it)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 as =2 with distinct disspipative an mixing length scale
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .true.    !  surface mixing length scale = F(wind stress) (T) or not (F)
+   rn_mxl0     =   0.04    !  surface  buoyancy lenght scale minimum value
+   ln_lc       = .true.    !  Langmuir cell parameterisation (Axell 2002)
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+   nn_etau     =   1       !  penetration of tke below the mixed layer (ML) due to near intertial waves
+                           !        = 0 no penetration
+                           !        = 1 add a tke source below the ML
+                           !        = 2 add a tke source just at the base of the ML
+                           !        = 3 as = 1 applied on HF part of the stress           (ln_cpl=T)
+   rn_efr      =   0.05    !  fraction of surface tke value which penetrates below the ML (nn_etau=1 or 2)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration below the ML
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m poleward of 40 degrees
+/
+!-----------------------------------------------------------------------
+&namzdf_gls    !   GLS vertical diffusion                               ("key_zdfgls")
+!-----------------------------------------------------------------------
+   rn_emin       = 1.e-7   !  minimum value of e   [m2/s2]
+   rn_epsmin     = 1.e-12  !  minimum value of eps [m2/s3]
+   ln_length_lim = .true.  !  limit on the dissipation rate under stable stratification (Galperin et al., 1988)
+   rn_clim_galp  = 0.267   !  galperin limit
+   ln_sigpsi     = .true.  !  Activate or not Burchard 2001 mods on psi schmidt number in the wb case
+   rn_crban      = 100.    !  Craig and Banner 1994 constant for wb tke flux
+   rn_charn      = 70000.  !  Charnock constant for wb induced roughness length
+   rn_hsro       =  0.02   !  Minimum surface roughness
+   rn_frac_hs    =   1.3   !  Fraction of wave height as roughness (if nn_z0_met=2)
+   nn_z0_met     =     2   !  Method for surface roughness computation (0/1/2/3)
+   !                             ! =3 requires ln_wave=T
+   nn_bc_surf    =     1   !  surface condition (0/1=Dir/Neum)
+   nn_bc_bot     =     1   !  bottom condition (0/1=Dir/Neum)
+   nn_stab_func  =     2   !  stability function (0=Galp, 1= KC94, 2=CanutoA, 3=CanutoB)
+   nn_clos       =     1   !  predefined closure type (0=MY82, 1=k-eps, 2=k-w, 3=Gen)
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency
+   ln_tmx_itf  = .true.    !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx_new !   internal wave-driven mixing parameterization        ("key_zdftmx_new" & "key_zdfddm")
+!-----------------------------------------------------------------------
+   nn_zpyc     = 1         !  pycnocline-intensified dissipation scales as N (=1) or N^2 (=2)
+   ln_mevar    = .true.    !  variable (T) or constant (F) mixing efficiency
+   ln_tsdiff   = .true.    !  account for differential T/S mixing (T) or not (F)
+/
+!!======================================================================
+!!                  ***  Miscellaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   namctl            Control prints 
+!!   namsto            Stochastic parametrization of EOS
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+   cn_mpi_send =  'I'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+   ln_nnogather=  .false.  !  activate code to avoid mpi_allgather use at the northfold
+   jpni        =   0       !  jpni   number of processors following i (set automatically if < 1)
+   jpnj        =   0       !  jpnj   number of processors following j (set automatically if < 1)
+   jpnij       =   0       !  jpnij  number of local domains (set automatically if < 1)
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints 
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_timing   =    0      !  timing by routine activated (=1) creates timing.output file, or not (=0)
+   nn_diacfl   =    0      !  Write out CFL diagnostics (=1) in cfl_diagnostics.ascii, or not (=0)
+/
+!-----------------------------------------------------------------------
+&namsto        ! Stochastic parametrization of EOS                      (default: NO)
+!-----------------------------------------------------------------------
+   ln_sto_eos  = .false.   ! stochastic equation of state
+   nn_sto_eos  = 1         ! number of independent random walks
+   rn_eos_stdxy= 1.4       ! random walk horz. standard deviation (in grid points)
+   rn_eos_stdz = 0.7       ! random walk vert. standard deviation (in grid points)
+   rn_eos_tcor = 1440.     ! random walk time correlation (in timesteps)
+   nn_eos_ord  = 1         ! order of autoregressive processes
+   nn_eos_flt  = 0         ! passes of Laplacian filter
+   rn_eos_lim  = 2.0       ! limitation factor (default = 3.0)
+   ln_rststo   = .false.   ! start from mean parameter (F) or from restart file (T)
+   ln_rstseed  = .true.    ! read seed of RNG from restart file
+   cn_storst_in  = "restart_sto" !  suffix of stochastic parameter restart file (input)
+   cn_storst_out = "restart_sto" !  suffix of stochastic parameter restart file (output)
+/
+
+!!======================================================================
+!!                  ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         (default F)
+!!   namptr       Poleward Transport Diagnostics                        (default F)
+!!   namhsb       Heat and salt budgets                                 (default F)
+!!   namdiu       Cool skin and warm layer models                       (default F)
+!!   namdiu       Cool skin and warm layer models                       (default F)
+!!   namflo       float parameters                                      ("key_float")
+!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
+!!   namdct       transports through some sections                      ("key_diadct")
+!!   nam_diatmb   Top Middle Bottom Output                              (default F)
+!!   nam_dia25h   25h Mean Output                                       (default F)
+!!   namnc4       netcdf4 chunking and compression settings             ("key_netcdf4")
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namtrd        !   trend diagnostics                                    (default F)
+!-----------------------------------------------------------------------
+   ln_glo_trd  = .false.   ! (T) global domain averaged diag for T, T^2, KE, and PE
+   ln_dyn_trd  = .false.   ! (T) 3D momentum trend output
+   ln_dyn_mxl  = .false.   ! (T) 2D momentum trends averaged over the mixed layer (not coded yet)
+   ln_vor_trd  = .false.   ! (T) 2D barotropic vorticity trends (not coded yet)
+   ln_KE_trd   = .false.   ! (T) 3D Kinetic   Energy     trends
+   ln_PE_trd   = .false.   ! (T) 3D Potential Energy     trends
+   ln_tra_trd  = .false.   ! (T) 3D tracer trend output
+   ln_tra_mxl  = .false.   ! (T) 2D tracer trends averaged over the mixed layer (not coded yet)
+   nn_trd      = 365       !  print frequency (ln_glo_trd=T) (unit=time step)
+/
+!!gm   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+!!gm   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+!!gm   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+!!gm   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+!!gm   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+!!gm   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+!!gm
+!-----------------------------------------------------------------------
+&namptr        !   Poleward Transport Diagnostic                         (default F)
+!-----------------------------------------------------------------------
+   ln_diaptr   = .false.   !  Poleward heat and salt transport (T) or not (F)
+   ln_subbas   = .false.   !  Atlantic/Pacific/Indian basins computation (T) or not
+/
+!-----------------------------------------------------------------------
+&namhsb        !  Heat and salt budgets                                  (default F)
+!-----------------------------------------------------------------------
+   ln_diahsb   = .false.   !  check the heat and salt budgets (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namdiu        !   Cool skin and warm layer models                       (default F)
+!-----------------------------------------------------------------------
+   ln_diurnal      = .false.   !
+   ln_diurnal_only = .false.   !
+/
+!-----------------------------------------------------------------------
+&namflo        !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+   jpnfl       = 1         !  total number of floats during the run
+   jpnnewflo   = 0         !  number of floats for the restart
+   ln_rstflo   = .false.   !  float restart (T) or not (F)
+   nn_writefl  =      75   !  frequency of writing in float output file
+   nn_stockfl  =    5475   !  frequency of creation of the float restart file
+   ln_argo     = .false.   !  Argo type floats (stay at the surface each 10 days)
+   ln_flork4   = .false.   !  trajectories computed with a 4th order Runge-Kutta (T)
+   !                       !  or computed with Blanke' scheme (F)
+   ln_ariane   = .true.    !  Input with Ariane tool convention(T)
+   ln_flo_ascii= .true.    !  Output with Ariane tool netcdf convention(F) or ascii file (T)
+/
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents               ("key_diaharm")
+!-----------------------------------------------------------------------
+    nit000_han = 1         ! First time step used for harmonic analysis
+    nitend_han = 75        ! Last time step used for harmonic analysis
+    nstep_han  = 15        ! Time step frequency for harmonic analysis
+    tname(1)   = 'M2'      ! Name of tidal constituents
+    tname(2)   = 'K1'
+/
+!-----------------------------------------------------------------------
+&namdct        ! transports through some sections                        ("key_diadct")
+!-----------------------------------------------------------------------
+    nn_dct     = 15        !  time step frequency for transports computing
+    nn_dctwri  = 15        !  time step frequency for transports writing
+    nn_secdebug= 112       !      0 : no section to debug
+    !                      !     -1 : debug all section
+    !                      !  0 < n : debug section number n
+/
+!-----------------------------------------------------------------------
+&nam_diatmb    !  Top Middle Bottom Output                               (default F)
+!-----------------------------------------------------------------------
+   ln_diatmb   = .false.   !  Choose Top Middle and Bottom output or not
+/
+!-----------------------------------------------------------------------
+&nam_dia25h    !  25h Mean Output                                        (default F)
+!-----------------------------------------------------------------------
+   ln_dia25h   = .false.   ! Choose 25h mean output or not
+/
+!-----------------------------------------------------------------------
+&namnc4        !   netcdf4 chunking and compression settings             ("key_netcdf4")
+!-----------------------------------------------------------------------
+   nn_nchunks_i=   4       !  number of chunks in i-dimension
+   nn_nchunks_j=   4       !  number of chunks in j-dimension
+   nn_nchunks_k=   31      !  number of chunks in k-dimension
+   !                       !  setting nn_nchunks_k = jpk will give a chunk size of 1 in the vertical which
+   !                       !  is optimal for postprocessing which works exclusively with horizontal slabs
+   ln_nc4zip   = .true.    !  (T) use netcdf4 chunking and compression
+   !                       !  (F) ignore chunking information and produce netcdf3-compatible files
+/
+
+!!======================================================================
+!!               ***  Observation & Assimilation  ***
+!!======================================================================
+!!   namobs       observation and model comparison
+!!   nam_asminc   assimilation increments                               ('key_asminc')
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namobs        !  observation usage switch
+!-----------------------------------------------------------------------
+   ln_diaobs   = .false.             ! Logical switch for the observation operator
+   ln_t3d      = .false.             ! Logical switch for T profile observations
+   ln_s3d      = .false.             ! Logical switch for S profile observations
+   ln_sla      = .false.             ! Logical switch for SLA observations
+   ln_sst      = .false.             ! Logical switch for SST observations
+   ln_sic      = .false.             ! Logical switch for Sea Ice observations
+   ln_vel3d    = .false.             ! Logical switch for velocity observations
+   ln_altbias  = .false.             ! Logical switch for altimeter bias correction
+   ln_nea      = .false.             ! Logical switch for rejection of observations near land
+   ln_grid_global = .true.           ! Logical switch for global distribution of observations
+   ln_grid_search_lookup = .false.   ! Logical switch for obs grid search w/lookup table
+   ln_ignmis   = .true.              ! Logical switch for ignoring missing files
+   ln_s_at_t   = .false.             ! Logical switch for computing model S at T obs if not there
+   ln_sstnight = .false.             ! Logical switch for calculating night-time average for SST obs
+! All of the *files* variables below are arrays. Use namelist_cfg to add more files
+   cn_profbfiles = 'profiles_01.nc'  ! Profile feedback input observation file names
+   cn_slafbfiles = 'sla_01.nc'       ! SLA feedback input observation file names
+   cn_sstfbfiles = 'sst_01.nc'       ! SST feedback input observation file names
+   cn_sicfbfiles = 'sic_01.nc'       ! SIC feedback input observation file names
+   cn_velfbfiles = 'vel_01.nc'       ! Velocity feedback input observation file names
+   cn_altbiasfile = 'altbias.nc'     ! Altimeter bias input file name
+   cn_gridsearchfile='gridsearch.nc' ! Grid search file name
+   rn_gridsearchres = 0.5            ! Grid search resolution
+   rn_dobsini  = 00010101.000000     ! Initial date in window YYYYMMDD.HHMMSS
+   rn_dobsend  = 00010102.000000     ! Final date in window YYYYMMDD.HHMMSS
+   nn_1dint    = 0                   ! Type of vertical interpolation method
+   nn_2dint    = 0                   ! Type of horizontal interpolation method
+   nn_msshc    = 0                   ! MSSH correction scheme
+   rn_mdtcorr  = 1.61                ! MDT  correction
+   rn_mdtcutoff = 65.0               ! MDT cutoff for computed correction
+   nn_profdavtypes = -1              ! Profile daily average types - array
+   ln_sstbias  = .false.             !
+   cn_sstbias_files = 'sstbias.nc'   !
+/
+!-----------------------------------------------------------------------
+&nam_asminc    !   assimilation increments                              ('key_asminc')
+!-----------------------------------------------------------------------
+    ln_bkgwri  = .false.   !  Logical switch for writing out background state
+    ln_trainc  = .false.   !  Logical switch for applying tracer increments
+    ln_dyninc  = .false.   !  Logical switch for applying velocity increments
+    ln_sshinc  = .false.   !  Logical switch for applying SSH increments
+    ln_asmdin  = .false.   !  Logical switch for Direct Initialization (DI)
+    ln_asmiau  = .false.   !  Logical switch for Incremental Analysis Updating (IAU)
+    nitbkg     = 0         !  Timestep of background in [0,nitend-nit000-1]
+    nitdin     = 0         !  Timestep of background for DI in [0,nitend-nit000-1]
+    nitiaustr  = 1         !  Timestep of start of IAU interval in [0,nitend-nit000-1]
+    nitiaufin  = 15        !  Timestep of end of IAU interval in [0,nitend-nit000-1]
+    niaufn     = 0         !  Type of IAU weighting function
+    ln_salfix  = .false.   !  Logical switch for ensuring that the sa > salfixmin
+    salfixmin  = -9999     !  Minimum salinity after applying the increments
+    nn_divdmp  = 0         !  Number of iterations of divergence damping operator
+/
diff --git a/EXP_Apr19/run_script.pbs b/EXP_Apr19/run_script.pbs
new file mode 100755
index 0000000..8d6cc0c
--- /dev/null
+++ b/EXP_Apr19/run_script.pbs
@@ -0,0 +1,41 @@
+#!/bin/bash
+# ---------------------------
+#===============================================================
+# CLUSTER BITS
+#===============================================================
+#PBS -N BoBEAS
+#PBS -l select=21
+#PBS -l walltime=00:20:00
+#PBS -A n01-ACCORD
+#PBS -j oe
+#PBS -r n
+# mail alert at (b)eginning, (e)nd and (a)bortion of execution
+#PBS -m bea
+#PBS -M jelt@noc.ac.uk
+
+module swap PrgEnv-cray PrgEnv-intel
+module load cray-netcdf-hdf5parallel
+module load cray-hdf5-parallel
+
+export PBS_O_WORKDIR=$(readlink -f $PBS_O_WORKDIR)
+# Change to the direcotry that the job was submitted from
+cd $PBS_O_WORKDIR
+
+
+# Set the number of threads to 1
+#   This prevents any system libraries from automatically
+#   using threading.
+export OMP_NUM_THREADS=1
+# Change to the directory that the job was submitted from
+ulimit -s unlimited
+ulimit -c unlimited
+
+export NEMOproc=480 #550
+export XIOSproc=1
+
+#===============================================================
+# LAUNCH JOB
+#===============================================================
+echo `date` : Launch Job
+aprun -b -n 5 -N 5 ./xios_server.exe : -n $NEMOproc -N 24 ./opa
+exit
-- 
GitLab


From 7c7f5891903425699163539ef049b0cd36608b2f Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Sat, 18 May 2019 12:47:04 +0100
Subject: [PATCH 05/18] fixed an issue with parent and child having different
 numbers of levels

---
 .../INITIAL_CONDITION/initcd_vosaline.namelist         | 10 +++++-----
 .../INITIAL_CONDITION/initcd_votemper.namelist         | 10 +++++-----
 .../namelist_reshape_bilin_initcd_vosaline             |  2 +-
 .../namelist_reshape_bilin_initcd_votemper             |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist
index 67f32f8..153dbd1 100755
--- a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_vosaline.namelist
@@ -99,16 +99,16 @@
 &ninput
 ivect     = 0
 lregin    = T
-cf_in     = './initcd_vosaline.nc'
+cf_in     = './initcd_origz_vosaline.nc'
 cv_in     = 'vosaline'
 cv_t_in   = 'time_counter'
 jt1       = 0
 jt2       = 0
 jplev     = 0
-cf_x_in   = './initcd_vosaline.nc'
+cf_x_in   = './initcd_origz_vosaline.nc'
 cv_lon_in = 'x'
 cv_lat_in = 'y'
-cf_lsm_in = 'sosie_initcd_mask.nc'
+cf_lsm_in = 'initcd_origz_mask.nc'
 cv_lsm_in = 'mask'
 ldrown    = T
 ewper     = -1
@@ -154,7 +154,7 @@ ismooth   = 0
 !! ssig_out     : structure with ROMS s-coordinates parameters on output grid (see above)
 !!
 &n3d
-cf_z_in  = 'initcd_vosaline.nc'
+cf_z_in  = 'initcd_origz_vosaline.nc'
 cv_z_in  = 'gdept'
 cf_z_out = 'domain_cfg.nc'
 cv_z_out = 'nav_lev'
@@ -216,7 +216,7 @@ ctype_z_out = 'z'
 !!
 &nhtarget
 lregout    = F
-cf_x_out   = 'initcd_vosaline.nc'
+cf_x_out   = 'initcd_origz_vosaline.nc'
 cv_lon_out = 'x'
 cv_lat_out = 'y'
 cf_lsm_out = ''
diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist
index 215dd75..e37fb61 100755
--- a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/initcd_votemper.namelist
@@ -99,16 +99,16 @@
 &ninput
 ivect     = 0
 lregin    = T
-cf_in     = './initcd_votemper.nc'
+cf_in     = './initcd_origz_votemper.nc'
 cv_in     = 'votemper'
 cv_t_in   = 'time_counter'
 jt1       = 0
 jt2       = 0
 jplev     = 0
-cf_x_in   = './initcd_votemper.nc'
+cf_x_in   = './initcd_origz_votemper.nc'
 cv_lon_in = 'x'
 cv_lat_in = 'y'
-cf_lsm_in = 'sosie_initcd_mask.nc'
+cf_lsm_in = 'initcd_origz_mask.nc'
 cv_lsm_in = 'mask'
 ldrown    = T
 ewper     = -1
@@ -154,7 +154,7 @@ ismooth   = 0
 !! ssig_out     : structure with ROMS s-coordinates parameters on output grid (see above)
 !!
 &n3d
-cf_z_in  = 'initcd_votemper.nc'
+cf_z_in  = 'initcd_origz_votemper.nc'
 cv_z_in  = 'gdept'
 cf_z_out = 'domain_cfg.nc'
 cv_z_out = 'nav_lev'
@@ -216,7 +216,7 @@ ctype_z_out = 'z'
 !!
 &nhtarget
 lregout    = F
-cf_x_out   = 'initcd_votemper.nc'
+cf_x_out   = 'initcd_origz_votemper.nc'
 cv_lon_out = 'x'
 cv_lat_out = 'y'
 cf_lsm_out = ''
diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_vosaline b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_vosaline
index 0e467f8..b1202fc 100755
--- a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_vosaline
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_vosaline
@@ -72,7 +72,7 @@
 /
 
 &interp_outputs
-    output_file = "initcd_vosaline.nc"
+    output_file = "initcd_origz_vosaline.nc"
     output_mode = "create"
     output_dims = 'x', 'y', 'z', 'time_counter'
     output_scaling = "vosaline|1.0"
diff --git a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_votemper b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_votemper
index 73f4dc0..15589e9 100755
--- a/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_votemper
+++ b/NAMELISTS_AND_FORTRAN_FILES/INITIAL_CONDITION/namelist_reshape_bilin_initcd_votemper
@@ -72,7 +72,7 @@
 /
 
 &interp_outputs
-    output_file = "initcd_votemper.nc"
+    output_file = "initcd_origz_votemper.nc"
     output_mode = "create"
     output_dims = 'x', 'y', 'z', 'time_counter'
     output_scaling = "votemper|1.0"
-- 
GitLab


From a9d205255d5b711ccd3838440ecdf0103ff9736c Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Sat, 18 May 2019 21:31:35 +0100
Subject: [PATCH 06/18] working initial condition test (no bcs)

---
 EXP_Apr19/namelist_cfg | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index 8ba50b2..48a70c2 100755
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -6,7 +6,7 @@
 !-----------------------------------------------------------------------
    cn_exp      =  "BoBEAS"  !  experience name
    nn_it000    = 1 ! 57601  !  first time step ! CHNAGE THIS TO END OF LAST RUN + 1
-   nn_itend    = 100 ! 218880 crashed in Apr16 ! 138240 !  last  time step (std 1 day = 144) (for dt = 6 min, so 240*dt = 1 day) ! CHANGE THIS TO THIS + 56 DAYS
+   nn_itend    = 14400 ! 218880 crashed in Apr16 ! 138240 !  last  time step (std 1 day = 144) (for dt = 6 min, so 240*dt = 1 day) ! CHANGE THIS TO THIS + 56 DAYS
    nn_date0    =  20190401  !20110717 !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
    nn_time0    =       0   !  initial time of day in hhmm
    nn_leapy    =       1   !  Leap year calendar (1) or not (0)
@@ -24,7 +24,7 @@
 !   cn_ocerst_in   = "ammsurge_restart_oce"   !  suffix of ocean restart name (input)
 !   cn_ocerst_out  = "restart_oce_out"   !  suffix of ocean restart name (input)
    nn_istate   =       0   !  output the initial state (1) or not (0)
-   nn_stock    =  100 ! 40320 =28days ! frequency of creation of a restart file (modulo referenced to 1) ! 28 DAYS
+   nn_stock    =  14400 ! 40320 =28days ! frequency of creation of a restart file (modulo referenced to 1) ! 28 DAYS
    nn_write    =  10 ! 86400    !  frequency of write in the output file   (modulo referenced to nit000) 
 /
 !-----------------------------------------------------------------------
@@ -60,15 +60,15 @@
 !-----------------------------------------------------------------------
 !              !  file name                 ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                            !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_tem = 'initcd_votemper.nc',      -1      ,'votemper',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'initcd_vosaline.nc',      -1      ,'vosaline',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem = 'initcd_votemper.nc',      -12     ,'votemper',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'initcd_vosaline.nc',      -12     ,'vosaline',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
    sn_dep = 'initcd_depth.nc'   ,      -12        ,'gdept_4D',   .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
-   sn_msk = 'sosie_initcd_mask.nc',    -12        ,'mask',       .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
+   sn_msk = 'initcd_mask.nc',    -12        ,'mask',       .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
 
    !
    cn_dir      = './ICS/'      !  root directory for the location of the runoff files
    ln_tsd_init = .true.    !  Initialisation of ocean T & S with T & S input data (T) or not (F)
-   ln_tsd_interp = .true.    !  Interpolation of T & S in the verticalinput data (T) or not (F)
+   ln_tsd_interp = .false.    !  Interpolation of T & S in the verticalinput data (T) or not (F)
    ln_tsd_tradmp = .false.  !  damping of ocean T & S toward T & S input data (T) or not (F)
 /
 !-----------------------------------------------------------------------
-- 
GitLab


From 3c4c051f43cdc7a70857a3f776ded116b854ee8c Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Mon, 20 May 2019 09:00:48 +0100
Subject: [PATCH 07/18] attempt to diagnose early blow up with Ash namelist

---
 EXP_Apr19/file_def_nemo.xml |  4 +++-
 EXP_Apr19/namelist_cfg      | 41 ++++++++++++++++++++++++++-----------
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/EXP_Apr19/file_def_nemo.xml b/EXP_Apr19/file_def_nemo.xml
index cf06a03..a7e5ba2 100755
--- a/EXP_Apr19/file_def_nemo.xml
+++ b/EXP_Apr19/file_def_nemo.xml
@@ -12,10 +12,12 @@
     
       <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
 
-      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."> <!-- 1h files -->
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."> <!-- 1h files -->
   	<file id="file19" name_suffix="_SSH" description="ocean T grid variables" >
     	 <field field_ref="ssh"          name="zos"   />
          <field field_ref="sst"          name="tos"   />
+         <field field_ref="ssu"          name="uos"  grid_ref="grid_U_2D" />
+         <field field_ref="ssv"          name="vos"  grid_ref="grid_V_2D" />
   	</file>
       </file_group>
 
diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index 48a70c2..2bf2fb2 100755
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -6,7 +6,7 @@
 !-----------------------------------------------------------------------
    cn_exp      =  "BoBEAS"  !  experience name
    nn_it000    = 1 ! 57601  !  first time step ! CHNAGE THIS TO END OF LAST RUN + 1
-   nn_itend    = 14400 ! 218880 crashed in Apr16 ! 138240 !  last  time step (std 1 day = 144) (for dt = 6 min, so 240*dt = 1 day) ! CHANGE THIS TO THIS + 56 DAYS
+   nn_itend    = 100! 218880 crashed in Apr16 ! 138240 !  last  time step (std 1 day = 144) (for dt = 6 min, so 240*dt = 1 day) ! CHANGE THIS TO THIS + 56 DAYS
    nn_date0    =  20190401  !20110717 !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
    nn_time0    =       0   !  initial time of day in hhmm
    nn_leapy    =       1   !  Leap year calendar (1) or not (0)
@@ -23,8 +23,8 @@
 !   nn_euler    =       1   !  = 0 : start with forward time step if ln_rstart=.true.
 !   cn_ocerst_in   = "ammsurge_restart_oce"   !  suffix of ocean restart name (input)
 !   cn_ocerst_out  = "restart_oce_out"   !  suffix of ocean restart name (input)
-   nn_istate   =       0   !  output the initial state (1) or not (0)
-   nn_stock    =  14400 ! 40320 =28days ! frequency of creation of a restart file (modulo referenced to 1) ! 28 DAYS
+   nn_istate   =       1   !  output the initial state (1) or not (0)
+   nn_stock    =  10 ! 40320 =28days ! frequency of creation of a restart file (modulo referenced to 1) ! 28 DAYS
    nn_write    =  10 ! 86400    !  frequency of write in the output file   (modulo referenced to nit000) 
 /
 !-----------------------------------------------------------------------
@@ -52,7 +52,7 @@
 &namdom        !   space and time domain (bathymetry, mesh, timestep)
 !-----------------------------------------------------------------------
 !   ln_2d        = .false.  !  (=T) run in 2D barotropic mode (no tracer processes or vertical diffusion)
-   rn_rdt      =   60.    !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_rdt      =   30.    !  time step for the dynamics (and tracer if nn_acc=0)
 /
 
 !-----------------------------------------------------------------------
@@ -68,7 +68,7 @@
    !
    cn_dir      = './ICS/'      !  root directory for the location of the runoff files
    ln_tsd_init = .true.    !  Initialisation of ocean T & S with T & S input data (T) or not (F)
-   ln_tsd_interp = .false.    !  Interpolation of T & S in the verticalinput data (T) or not (F)
+   ln_tsd_interp = .true.    !  Interpolation of T & S in the verticalinput data (T) or not (F)
    ln_tsd_tradmp = .false.  !  damping of ocean T & S toward T & S input data (T) or not (F)
 /
 !-----------------------------------------------------------------------
@@ -76,8 +76,8 @@
 !-----------------------------------------------------------------------
    nn_fsbc     = 1         !  frequency of surface boundary condition computation
                            !     (also = the frequency of sea-ice model call)
-   ln_usr =  .false.
-   ln_blk =  .true.
+   ln_usr =  .true.
+   ln_blk =  .false.
    ln_apr_dyn  = .false.    !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
    nn_ice      = 0         !  =0 no ice boundary condition   ,
    ln_rnf      = .true.   !  Runoffs                                   (T => fill namsbc_rnf) 
@@ -174,7 +174,7 @@
    nb_bdy         = 1                    !  number of open boundary sets
    cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
    cn_dyn2d       = 'flather'            ! was flather
-   nn_dyn2d_dta   =  0                   !  = 0, bdy data are equal to the initial state
+   nn_dyn2d_dta   =  2                   !  = 0, bdy data are equal to the initial state
                                          !  = 1, bdy data are read in 'bdydata   .nc' files
                                          !  = 2, use tidal harmonic forcing data from files
                                          !  = 3, use external data AND tidal harmonic forcing
@@ -271,13 +271,30 @@
    ln_hpg_sco  = .true.    !  s-coordinate (Standard Jacobian scheme)
 /
 !-----------------------------------------------------------------------
-&namdyn_spg    !   surface pressure gradient   (CPP key only)
+&namdyn_spg    !   surface pressure gradient                            (default: NO)
 !-----------------------------------------------------------------------
-   ln_dynspg_ts = .true.    ! split-explicit free surface
-   ln_bt_auto =    .true.           !  Set nn_baro automatically to be just below
-                                       !  a user defined maximum courant number (rn_bt_cmax)
+  ln_dynspg_exp  = .false.   ! explicit free surface
+  ln_dynspg_ts   = .true.   ! split-explicit free surface
+      ln_bt_fw      = .true.     ! Forward integration of barotropic Eqs.
+      ln_bt_av      = .true.     ! Time filtering of barotropic variables
+        nn_bt_flt     = 1          ! Time filter choice  = 0 None
+         !                          !                     = 1 Boxcar over   nn_baro sub-steps
+        !                          !                     = 2 Boxcar over 2*nn_baro  "    "
+      ln_bt_auto    = .true.     ! Number of sub-step defined from:
+       rn_bt_cmax   =  0.5        ! =T : the Maximum Courant Number allowed
+        nn_baro      = 30          ! =F : the number of sub-step in rn_rdt seconds
+      ln_ulimit     =.true.
+       cn_ulimit     = 0.9
+       cnn_ulimit    = 0.54
 /
 !-----------------------------------------------------------------------
+!&namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!   ln_dynspg_ts = .true.    ! split-explicit free surface
+!   ln_bt_auto =    .true.           !  Set nn_baro automatically to be just below
+!                                       !  a user defined maximum courant number (rn_bt_cmax)
+!/
+!-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
    !                       !  Type of the operator :
-- 
GitLab


From fa71f137c1677eba994754e686576ca7c7790e4d Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Mon, 20 May 2019 09:30:36 +0100
Subject: [PATCH 08/18] copied namelists from Jason GCOMS BLZ run

---
 EXP_Apr19/namelist_cfg | 1267 +++++++++++++++++++++++++++++++++-------
 EXP_Apr19/namelist_ref |   70 ++-
 2 files changed, 1081 insertions(+), 256 deletions(-)
 mode change 100755 => 100644 EXP_Apr19/namelist_cfg

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
old mode 100755
new mode 100644
index 2bf2fb2..c4dd9da
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -1,424 +1,1251 @@
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-!! NEMO/OPA  : AMM12 configuration namelist used to overwrite defaults values defined in SHARED/namelist_ref
+!!                            namelist_ref
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  1 - run manager      (namrun)
+!! namelists    2 - Domain           (namcfg, namzgr, namdom, namtsd, namcrs, namc1d, namc1d_uvd)
+!!              3 - Surface boundary (namsbc, namsbc_flx, namsbc_blk, namsbc_sas)
+!!                                    namsbc_cpl, namtra_qsr, namsbc_rnf,
+!!                                    namsbc_apr, namsbc_ssr, namsbc_alb, namsbc_wave)
+!!              4 - lateral boundary (namlbc, namagrif, nambdy, nambdy_tide)
+!!              5 - bottom  boundary (nambfr, nambbc, nambbl)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_ldfeiv, namtra_dmp)
+!!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_ddm, namzdf_tmx, namzdf_tmx_new)
+!!              9 - diagnostics      (namnc4, namtrd, namspr, namflo, namhsb, namsto)
+!!             10 - miscellaneous    (nammpp, namctl)
+!!             11 - Obs & Assim      (namobs, nam_asminc)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!!======================================================================
+!!                   ***  Run management namelists  ***
+!!======================================================================
+!!   namrun       parameters of the run
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &namrun        !   parameters of the run
 !-----------------------------------------------------------------------
-   cn_exp      =  "BoBEAS"  !  experience name
-   nn_it000    = 1 ! 57601  !  first time step ! CHNAGE THIS TO END OF LAST RUN + 1
-   nn_itend    = 100! 218880 crashed in Apr16 ! 138240 !  last  time step (std 1 day = 144) (for dt = 6 min, so 240*dt = 1 day) ! CHANGE THIS TO THIS + 56 DAYS
-   nn_date0    =  20190401  !20110717 !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
+   cn_exp      =    "BoBEAS"  !  experience name
+   nn_it000    =  1 !  first time step
+   nn_itend    =  100 ! 10800! 259200!133920! 10800!43200 ! 10day=14400   !  last  time step (std 5475)
+   nn_date0    =  20190401   !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
    nn_time0    =       0   !  initial time of day in hhmm
    nn_leapy    =       1   !  Leap year calendar (1) or not (0)
-   ln_rstart   =  .false.  !  start from rest (F) or from a restart file (T)
-      nn_euler    =    1            !  = 0 : start with forward time step if ln_rstart=T
-      nn_rstctl   =    2            !  restart control ==> activated only if ln_rstart=T
+   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+       nn_euler    =  1            !  = 0 : start with forward time step if ln_rstart=T
+       nn_rstctl   =  2             !  restart control ==> activated only if ln_rstart=T
       !                             !    = 0 nn_date0 read in namelist ; nn_it000 : read in namelist
       !                             !    = 1 nn_date0 read in namelist ; nn_it000 : check consistancy between namelist and restart
       !                             !    = 2 nn_date0 read in restart  ; nn_it000 : check consistancy between namelist and restart
-      cn_ocerst_in    = "INDIAN_00138240_restart"   !  suffix of ocean restart name (input) ! CHANGE THIS TO LAST RESTART FILE NUMBER
+      cn_ocerst_in    = "__RESFILE__"   !  suffix of ocean restart name (input)
       cn_ocerst_indir = "./restarts"         !  directory from which to read input ocean restarts
       cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
       cn_ocerst_outdir= "./restarts"         !  directory in which to write output ocean restarts
-!   nn_euler    =       1   !  = 0 : start with forward time step if ln_rstart=.true.
-!   cn_ocerst_in   = "ammsurge_restart_oce"   !  suffix of ocean restart name (input)
-!   cn_ocerst_out  = "restart_oce_out"   !  suffix of ocean restart name (input)
-   nn_istate   =       1   !  output the initial state (1) or not (0)
-   nn_stock    =  10 ! 40320 =28days ! frequency of creation of a restart file (modulo referenced to 1) ! 28 DAYS
-   nn_write    =  10 ! 86400    !  frequency of write in the output file   (modulo referenced to nit000) 
+   ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+   ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
+   nn_stock    =   10 !43200 ! 14400   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
+   nn_write    =   10 ! 14400   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
+   ln_cfmeta   = .false.   !  output additional data to netCDF files required for compliance with the CF metadata standard
+   ln_clobber  = .true.    !  clobber (overwrite) an existing file
+   nn_chunksz  =       0   !  chunksize (bytes) for NetCDF file (works only with iom_nf90 routines)
 /
+!
+!!======================================================================
+!!                      ***  Domain namelists  ***
+!!======================================================================
+!!   namcfg       parameters of the configuration
+!!   namzgr       vertical coordinate                                   (default: NO selection)
+!!   namdom       space and time domain (bathymetry, mesh, timestep)
+!!   namwad       Wetting and drying                                    (default F)
+!!   namtsd       data: temperature & salinity
+!!   namcrs       coarsened grid (for outputs and/or TOP)               ("key_crs")
+!!   namc1d       1D configuration options                              ("key_c1d")
+!!   namc1d_dyndmp 1D newtonian damping applied on currents             ("key_c1d")
+!!   namc1d_uvd   1D data (currents)                                    ("key_c1d")
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &namcfg        !   parameters of the configuration
 !-----------------------------------------------------------------------
    ln_read_cfg = .true.   !  (=T) read the domain configuration file
-                          !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
-   cn_domcfg = "domain_cfg.nc"         ! domain configuration filename
+      !                   !  (=F) user defined configuration  ==>>>  see usrdef(_...) modules
+      cn_domcfg = "domain_cfg.nc"         ! domain configuration filename
+      !
+   ln_write_cfg= .false.   !  (=T) create the domain configuration file
+      cn_domcfg_out = "domain_cfg_out" ! newly created domain configuration filename
+      !
+   ln_use_jattr = .false.  !  use (T) the file attribute: open_ocean_jstart, if present
+   !                       !  in netcdf input files, as the start j-row for reading
 /
 !-----------------------------------------------------------------------
-!&namzgr        !   vertical coordinate
-!-----------------------------------------------------------------------
-!   ln_zps      = .false.   !  z-coordinate - partial steps   (T/F)
-!   ln_sco      = .true.    !  s- or hybrid z-s-coordinate    (T/F)
-!/
+&namzgr        !   vertical coordinate                                  (default: NO selection)
 !-----------------------------------------------------------------------
-!&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+   ln_zco      = .false.   !  z-coordinate - full    steps
+   ln_zps      = .false.   !  z-coordinate - partial steps
+   ln_sco      = .true.   !  s- or hybrid z-s-coordinate
+   ln_isfcav   = .false.   !  ice shelf cavity
+!   ln_linssh   = .false.   !  linear free surface
+/
 !-----------------------------------------------------------------------
-!   rn_sbot_min =    6.0    !  minimum depth of s-bottom surface (>0) (m)
-!   rn_hc       =    0.0    !  critical depth for transition to stretched coordinates
-!   rn_rmax     =    1.0    !  maximum cut-off r-value allowed (0<r_max<1)
-!   rn_theta    =    0.0    !  surface control parameter (0<=theta<=20)
-!/
+&namzgr_sco
+!-----------------------------------------------------------------------
+   ln_s_sf12=.true.,
+   ln_s_sh94=.false.,
+   ln_sigcrit=.true.,
+   rn_alpha=4.4,
+   rn_bb=0.8,
+   rn_efold=0.0,
+   rn_hc=10000.0,
+   rn_rmax=1.0,
+   rn_sbot_max=10000.0,
+   rn_sbot_min=1.0e-5,
+   rn_theta=6.0,
+   rn_thetb=1.0,
+   rn_zb_a=0.024,
+   rn_zb_b=-0.2,
+   rn_zs=1.0,
+/
 !-----------------------------------------------------------------------
 &namdom        !   space and time domain (bathymetry, mesh, timestep)
 !-----------------------------------------------------------------------
-!   ln_2d        = .false.  !  (=T) run in 2D barotropic mode (no tracer processes or vertical diffusion)
-   rn_rdt      =   30.    !  time step for the dynamics (and tracer if nn_acc=0)
-/
 
+   ln_linssh   = .false.   !  =T  linear free surface  ==>>  model level are fixed in time
+   nn_closea   =    0      !  remove (=0) or keep (=1) closed seas and lakes (ORCA)
+   !
+   nn_msh      =    0      !  create (>0) a mesh file or not (=0)
+   rn_isfhmin  =    1.00   !  treshold (m) to discriminate grounding ice to floating ice
+   !
+   rn_rdt      =  60.!60.!120.!60.     !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =    0.1    !  asselin time filter parameter
+   !
+   ln_crs      = .false.   !  Logical switch for coarsening module
+!   ldbletanh   =    .false.             !  Use/do not use double tanf function for vertical coordinates
+/
 !-----------------------------------------------------------------------
-&namtsd    !   data : Temperature  & Salinity
+&namtsd        !   data : Temperature  & Salinity
 !-----------------------------------------------------------------------
 !              !  file name                 ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                            !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_tem = 'initcd_votemper.nc',      -12     ,'votemper',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = 'initcd_vosaline.nc',      -12     ,'vosaline',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_dep = 'initcd_depth.nc'   ,      -12        ,'gdept_4D',   .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
-   sn_msk = 'initcd_mask.nc',    -12        ,'mask',       .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
-
+   sn_tem  = 'initcd_votemper',         -1        ,'votemper' ,    .false.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
+   sn_sal  = 'initcd_vosaline',         -1        ,'vosaline' ,    .false.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
+   !sn_dep = 'initcd_depth.nc'   ,      -12        ,'gdept_4D',   .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
+   !sn_msk = 'initcd_mask.nc',    -12        ,'mask',       .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
    !
-   cn_dir      = './ICS/'      !  root directory for the location of the runoff files
-   ln_tsd_init = .true.    !  Initialisation of ocean T & S with T & S input data (T) or not (F)
+   cn_dir        = './ICS/'     !  root directory for the location of the runoff files
+   ln_tsd_init   = .true.   !  Initialisation of ocean T & S with T &S input data (T) or not (F)
    ln_tsd_interp = .true.    !  Interpolation of T & S in the verticalinput data (T) or not (F)
-   ln_tsd_tradmp = .false.  !  damping of ocean T & S toward T & S input data (T) or not (F)
+   ln_tsd_tradmp = .false.   !  damping of ocean T & S toward T &S input data (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namwad        !   Wetting and drying                                   (default F)
+!-----------------------------------------------------------------------
+   ln_wd       = .false.   !  T/F activation of wetting and drying
+   rn_wdmin1   =  0.1      !  Minimum wet depth on dried cells
+   rn_wdmin2   =  0.01     !  Tolerance of min wet depth on dried cells
+   rn_wdld     =  20.0     !  Land elevation below which wetting/drying is allowed
+   nn_wdit     =  10       !  Max iterations for W/D limiter
+/
+!-----------------------------------------------------------------------
+&namcrs        !   coarsened grid (for outputs and/or TOP)              ("key_crs")
+!-----------------------------------------------------------------------
+   nn_factx    = 3         !  Reduction factor of x-direction
+   nn_facty    = 3         !  Reduction factor of y-direction
+   nn_binref   = 0         !  Bin centering preference: NORTH or EQUAT
+                           !  0, coarse grid is binned with preferential treatment of the north fold
+                           !  1, coarse grid is binned with centering at the equator
+                           !    Symmetry with nn_facty being odd-numbered. Asymmetry with even-numbered nn_facty.
+   nn_msh_crs  = 1         !  create (=1) a mesh file or not (=0)
+   nn_crs_kz   = 0         ! 0, MEAN of volume boxes
+                           ! 1, MAX of boxes
+                           ! 2, MIN of boxes
+   ln_crs_wn   = .true.    ! wn coarsened (T) or computed using horizontal divergence ( F )
 /
 !-----------------------------------------------------------------------
+&namc1d        !   1D configuration options                             ("key_c1d")
+!-----------------------------------------------------------------------
+   rn_lat1d    =      50   !  Column latitude (default at PAPA station)
+   rn_lon1d    =    -145   !  Column longitude (default at PAPA station)
+   ln_c1d_locpt=  .true.   ! Localization of 1D config in a grid (T) or independant point (F)
+/
+!-----------------------------------------------------------------------
+&namc1d_dyndmp !   U & V newtonian damping                              ("key_c1d")
+!-----------------------------------------------------------------------
+   ln_dyndmp   =  .false.  !  add a damping term (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namc1d_uvd    !   data: U & V currents                                 ("key_c1d")
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_ucur     = 'ucurrent'  ,         -1        ,'u_current',   .false.    , .true. , 'monthly' ,  ''      ,  'Ume'   , ''
+   sn_vcur     = 'vcurrent'  ,         -1        ,'v_current',   .false.    , .true. , 'monthly' ,  ''      ,  'Vme'   , ''
+!
+   cn_dir        = './'    !  root directory for the location of the files
+   ln_uvd_init   = .false. !  Initialisation of ocean U & V with U & V input data (T) or not (F)
+   ln_uvd_dyndmp = .false. !  damping of ocean U & V toward U & V input data (T) or not (F)
+/
+
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***
+!!======================================================================
+!!   namsbc          surface boundary condition
+!!   namsbc_flx      flux               formulation                     (ln_flx     =T)
+!!   namsbc_blk      Bulk formulae formulation                          (ln_blk     =T)
+!!   namsbc_cpl      CouPLed            formulation                     ("key_oasis3" )
+!!   namsbc_sas      Stand-Alone Surface module
+!!   namtra_qsr      penetrative solar radiation                        (ln_traqsr  =T)
+!!   namsbc_rnf      river runoffs                                      (ln_rnf     =T)
+!!   namsbc_isf      ice shelf melting/freezing                         (nn_isf     >0)
+!!   namsbc_iscpl    coupling option between land ice model and ocean
+!!   namsbc_apr      Atmospheric Pressure                               (ln_apr_dyn =T)
+!!   namsbc_ssr      sea surface restoring term (for T and/or S)        (ln_ssr     =T)
+!!   namsbc_alb      albedo parameters
+!!   namsbc_wave     external fields from wave model                    (ln_wave    =T)
+!!   namberg         iceberg floats                                     (ln_icebergs=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
 &namsbc        !   Surface Boundary Condition (surface module)
 !-----------------------------------------------------------------------
    nn_fsbc     = 1         !  frequency of surface boundary condition computation
-                           !     (also = the frequency of sea-ice model call)
-   ln_usr =  .true.
-   ln_blk =  .false.
-   ln_apr_dyn  = .false.    !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
+                           !     (also = the frequency of sea-ice & iceberg model call)
+                     ! Type of air-sea fluxes
+   ln_usr      = .true.    !  user defined formulation                  (T => check usrdef_sbc)
+   ln_flx      = .false.   !  flux formulation                          (T => fill namsbc_flx )
+   ln_blk      = .false.    !  Bulk formulation                          (T => fill namsbc_blk )
+                     ! Type of coupling (Ocean/Ice/Atmosphere) :
+   ln_cpl      = .false.   !  atmosphere coupled   formulation          ( requires key_oasis3 )
+   ln_mixcpl   = .false.   !  forced-coupled mixed formulation          ( requires key_oasis3 )
+   nn_components = 0       !  configuration of the opa-sas OASIS coupling
+                           !  =0 no opa-sas OASIS coupling: default single executable configuration
+                           !  =1 opa-sas OASIS coupling: multi executable configuration, OPA component
+                           !  =2 opa-sas OASIS coupling: multi executable configuration, SAS component
+   nn_limflx = -1          !  LIM3 Multi-category heat flux formulation (use -1 if LIM3 is not used)
+                           !  =-1  Use per-category fluxes, bypass redistributor, forced mode only, not yet implemented coupled
+                           !  = 0  Average per-category fluxes (forced and coupled mode)
+                           !  = 1  Average and redistribute per-category fluxes, forced mode only, not yet implemented coupled
+                           !  = 2  Redistribute a single flux over categories (coupled mode only)
+                     ! Sea-ice :
    nn_ice      = 0         !  =0 no ice boundary condition   ,
-   ln_rnf      = .true.   !  Runoffs                                   (T => fill namsbc_rnf) 
-   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
-   ln_traqsr   = .false.   !  Light penetration in the ocean            (T => fill namtra_qsr)
+                           !  =1 use observed ice-cover      ,
+                           !  =2 to 4 :  ice-model used (LIM2, LIM3 or CICE)                         ("key_lim3", "key_lim2", or "key_cice")
+   nn_ice_embd = 1         !  =0 levitating ice (no mass exchange, concentration/dilution effect)
+                           !  =1 levitating ice with mass and salt exchange but no presure effect
+                           !  =2 embedded sea-ice (full salt and mass exchanges and pressure)
+                     ! Misc. options of sbc :
+   ln_traqsr   = .false.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+   ln_dm2dc    = .false.   !  daily mean to diurnal cycle on short wave
+   ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
+   ln_ssr      = .false.    !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
    nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+                           !     =1 global mean of e-p-r set to zero at each time step
+                           !     =2 annual global mean of e-p-r set to zero
+   ln_apr_dyn  = .false.   !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
+   ln_isf      = .false.   !  ice shelf                                 (T   => fill namsbc_isf)
+   ln_wave     = .false.   !  Activate coupling with wave  (T => fill namsbc_wave)
+   ln_cdgw     = .false.   !  Neutral drag coefficient read from wave model (T => ln_wave=.true. & fill namsbc_wave)
+   ln_sdw      = .false.   !  Read 2D Surf Stokes Drift & Computation of 3D stokes drift (T => ln_wave=.true. & fill namsbc_wave)
+   ln_tauoc    = .false.   !  Activate ocean stress modified by external wave induced stress (T => ln_wave=.true. & fill namsbc_wave)
+   ln_stcor    = .false.   !  Activate Stokes Coriolis term (T => ln_wave=.true. & ln_sdw=.true. & fill namsbc_wave)
+   nn_lsm      = 0         !  =0 land/sea mask for input fields is not applied (keep empty land/sea mask filename field) ,
+                           !  =1:n number of iterations of land/sea mask application for input fields (fill land/sea mask filename field)
 /
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_utau     = 'utau'      ,        24         , 'utau'    , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_vtau     = 'vtau'      ,        24         , 'vtau'    , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_qtot     = 'qtot'      ,        24         , 'qtot'    , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_qsr      = 'qsr'       ,        24         , 'qsr'     , .false.      , .false., 'yearly'  , ''       , ''       , ''
+   sn_emp      = 'emp'       ,        24         , 'emp'     , .false.      , .false., 'yearly'  , ''       , ''       , ''
 
+   cn_dir      = './'      !  root directory for the location of the flux files
+/
+!-----------------------------------------------------------------------
+&namsbc_blk   !   namsbc_blk  generic Bulk formula                      (ln_blk = T)
+!-----------------------------------------------------------------------
+!-----------------------------------------------------------------------
+!              !  file name                   ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights                              ! rotation ! land/sea mask !
+!              !                              !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename                             ! pairing  ! filename      !
+   sn_wndi     = 'ERA5_U10'        ,         1         , 'U10',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'   , 'Uwnd'   , ''
+   sn_wndj     = 'ERA5_V10'        ,         1        , 'V10',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'   , 'Vwnd'   , ''
+   sn_qsr      = 'ERA5_MSDWSWRF'    ,        1         , 'MSDWSWRF',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   sn_qlw      = 'ERA5_MSDWLWRF'    ,        1         , 'MSDWLWRF',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   sn_tair     = 'ERA5_T2M'        ,         1         , 'T2M',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   sn_humi     = 'ERA5_SPH'        ,         1         , 'SPH',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   sn_prec     = 'ERA5_MTPR' ,       1         , 'MTPR',   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   sn_snow     = 'ERA5_MSR' ,        1         , 'MSR'    ,   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   sn_slp      = 'ERA5_MSL'        ,         1         , 'MSL'     ,   .false.    , .false. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+!   sn_tdif     = 'taudif_core'                 ,        24         , 'taudif'  ,   .false.    , .true. , 'yearly'  , 'weights_bilinear_atmos.nc'  , ''       , ''
+   !                    !  bulk algorithm :
+   ln_NCAR     = .false.   ! "NCAR"      algorithm   (Large and Yeager 2008)
+   ln_COARE_3p0= .true.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
+   ln_COARE_3p5= .false.   ! "COARE 3.5" algorithm   (Edson et al. 2013)
+   ln_ECMWF    = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
+   !
+   cn_dir      = 'metdta/'      !  root directory for the location of the bulk files
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data
+   rn_zqt      = 2.  !10.  !  Air temperature and humidity reference height (m) ***val : I changed from 10 to 2 ***
+   rn_zu       = 10.       !  Wind vector reference height (m)
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+   rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
+   rn_vfac     = 0.        !  multiplicative factor for ocean/ice velocity
+                           !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
+   ln_Cd_L12   = .false.   !  Modify the drag ice-atm and oce-atm depending on ice concentration
+                           !  This parameterization is from Lupkes et al. (JGR 2012)
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
+!-----------------------------------------------------------------------
+!                    !     description      !  multiple  !    vector   !      vector          ! vector !
+!                    !                      ! categories !  reference  !    orientation       ! grids  !
+! send
+   sn_snd_temp   =   'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_alb    =   'weighted ice'         ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_thick  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_crt    =   'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+   sn_snd_co2    =   'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_crtw   =       'none'                 ,    'no'    ,     ''      ,         ''           , 'U,V'
+   sn_snd_ifrac  =       'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_wlev   =       'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
+! receive
+   sn_rcv_w10m   =   'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_taumod =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_tau    =   'oce only'             ,    'no'    , 'cartesian' , 'eastward-northward',  'U,V'
+   sn_rcv_dqnsdt =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_qsr    =   'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_qns    =   'oce and ice'          ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_emp    =   'conservative'         ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_rnf    =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_cal    =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_co2    =   'coupled'              ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_hsig   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_iceflx =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_mslp   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_phioc  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_sdrfx  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_sdrfy  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wper   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wnum   =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wstrf  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wdrag  =       'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+!
+   nn_cplmodel   =     1   !  Maximum number of models to/from which NEMO is potentialy sending/receiving data
+   ln_usecplmask = .false. !  use a coupling mask file to merge data received from several models
+   !                       !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
+/
+!-----------------------------------------------------------------------
+&namsbc_sas    !   Stand Alone Surface boundary condition
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   l_sasread   = .TRUE.   ! Read fields in a file if .TRUE. , or initialize to 0. in sbcssm.F90 if .FALSE.
+   sn_usp      = 'sas_grid_U',     120           , 'vozocrtx',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_vsp      = 'sas_grid_V',     120           , 'vomecrty',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_tem      = 'sas_grid_T',     120           , 'sosstsst',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal      = 'sas_grid_T',     120           , 'sosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_ssh      = 'sas_grid_T',     120           , 'sossheig',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_e3t      = 'sas_grid_T',     120           , 'e3t_m'   ,   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_frq      = 'sas_grid_T',     120           , 'frq_m'   ,   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
 
+   ln_3d_uve   = .true.    !  specify whether we are supplying a 3D u,v and e3 field
+   ln_read_frq = .false.   !  specify whether we must read frq or not
+   cn_dir      = './'      !  root directory for the location of the bulk files are
+/
 !-----------------------------------------------------------------------
-&namsbc_usr  !   namsbc_surge   surge model fluxes
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr=T)
 !-----------------------------------------------------------------------
-   ln_use_sbc  = .false.    ! (T) to turn on surge fluxes (wind and pressure only)
-                            ! (F) for no fluxes (ie tide only case)
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_chl      ='chlorophyll',        -1         , 'CHLA'    ,   .true.     , .true. , 'yearly'  , ''       , ''       , ''
 
-!
-!              !  file name                    ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation !
-!              !                               !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  !
-!   sn_wndi     = 'CARIB_u10_weights_bicubic_atmos.nc'              ,       1           ,'x_wind',   .true.     , .false. , 'daily'  ,'weights_era5_INDIAN_bicubic.nc' , ''
-!   sn_wndj     = 'CARIB_v10_weights_bicubic_atmos.nc'              ,       1           ,'y_wind',   .true.     , .false. , 'daily'  ,'weights_era5_INDIAN_bicubic.nc' , ''
-   cn_dir      = './FORCING/'          !  root directory for the location of the bulk files
-   rn_vfac     = 1.                   !  multiplicative factor for ocean/ice velocity
-                                      !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
-   rn_charn_const = 0.0275
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_qsr_rgb  = .true.    !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .false.   !  2 bands              light penetration
+   ln_qsr_bio  = .false.   !  bio-model light penetration
+   nn_chldta   =      1    !  RGB : Chl data (=1) or cst value (=0)
+   rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
+   rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
+   rn_si1      =   23.0    !  2 bands: longest depth of extinction
+   ln_qsr_ice  = .true.    !  light penetration for ice-model LIM3
 /
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition          (ln_rnf=T)
+!-----------------------------------------------------------------------
+!              !  file name           ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                      !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_rnf      = 'river_test'         ,        -1         , 'rorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'river_test'         ,         0         , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,        24         , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,        24         , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,         0         , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
 
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   ln_rnf_mouth= .false.    !  specific treatment at rivers mouths
+      rn_hrnf     =  15.e0    !  depth over which enhanced vertical mixing is used    (ln_rnf_mouth=T)
+      rn_avt_rnf  =   1.e-3   !  value of the additional vertical mixing coef. [m2/s] (ln_rnf_mouth=T)
+   rn_rfact    =   1.e0    !  multiplicative factor for runoff
+   ln_rnf_depth= .false.   !  read in depth information for runoff
+   ln_rnf_tem  = .false.   !  read in temperature information for runoff
+   ln_rnf_sal  = .false.   !  read in salinity information for runoff
+ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file ***val : I need to activate that so that the rivers are not boiling anymore***
+   rn_rnf_max  = 1.6224      !  5.735e-4    !  max value of the runoff climatologie over global domain ( ln_rnf_depth_ini = .true )
+   rn_dep_max  = 50.         !  150.        !  depth over which runoffs is spread ( ln_rnf_depth_ini = .true )
+   nn_rnf_depth_file = 0     !  create (=1) a runoff depth file or not (=0)
+
+
+
+!   ln_rnf_depth_ini = .false. ! compute depth at initialisation from runoff file
+!      rn_rnf_max  = 5.735e-4  !  max value of the runoff climatologie over global domain ( ln_rnf_depth_ini = .true )
+!      rn_dep_max  = 150.      !  depth over which runoffs is spread ( ln_rnf_depth_ini = .true )
+!      nn_rnf_depth_file = 0   !  create (=1) a runoff depth file or not (=0)
+/
 !-----------------------------------------------------------------------
-&namtra_qsr    !   penetrative solar radiation
+&namsbc_isf    !  Top boundary layer (ISF)                              (nn_isf >0)
+!-----------------------------------------------------------------------
+!              ! file name ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+! nn_isf == 4
+   sn_fwfisf   = 'rnfisf'  ,         -12       ,'sowflisf',   .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+! nn_isf == 3
+   sn_rnfisf   = 'rnfisf'  ,         -12       ,'sofwfisf',   .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+! nn_isf == 2 and 3
+   sn_depmax_isf='rnfisf'  ,         -12       ,'sozisfmax',  .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+   sn_depmin_isf='rnfisf'  ,         -12       ,'sozisfmin',  .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+! nn_isf == 2
+   sn_Leff_isf = 'rnfisf'  ,         -12       ,'Leff'    ,   .false.   , .true. , 'yearly'  ,    ''    ,   ''     ,    ''
+!
+! for all case
+   nn_isf      = 0         !  ice shelf melting/freezing
+                           !  1 = presence of ISF    2 = bg03 parametrisation
+                           !  3 = rnf file for isf   4 = ISF fwf specified
+                           !  option 1 and 4 need ln_isfcav = .true. (domzgr)
+! only for nn_isf = 1 or 2
+   rn_gammat0  = 1.e-4     ! gammat coefficient used in blk formula
+   rn_gammas0  = 1.e-4     ! gammas coefficient used in blk formula
+! only for nn_isf = 1 or 4
+   rn_hisf_tbl =  30.      ! thickness of the top boundary layer    (Losh et al. 2008)
+   !                       ! 0 => thickness of the tbl = thickness of the first wet cell
+! only for nn_isf = 1
+   nn_isfblk   = 1         ! 1 ISOMIP  like: 2 equations formulation (Hunter et al., 2006)
+   !                       ! 2 ISOMIP+ like: 3 equations formulation (Asay-Davis et al., 2015)
+   nn_gammablk = 1         ! 0 = cst Gammat (= gammat/s)
+   !                       ! 1 = velocity dependend Gamma (u* * gammat/s)  (Jenkins et al. 2010)
+   !                       ! 2 = velocity and stability dependent Gamma    (Holland et al. 1999)
+/
 !-----------------------------------------------------------------------
+&namsbc_iscpl  !   land ice / ocean coupling option
+!-----------------------------------------------------------------------
+   nn_drown    = 10        ! number of iteration of the extrapolation loop (fill the new wet cells)
+   ln_hsb      = .false.   ! activate conservation module (conservation exact after a time of rn_fiscpl)
+   nn_fiscpl   = 43800     ! (number of time step) conservation period (maybe should be fix to the coupling frequencey of restart frequency)
 /
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing           (ln_apr_dyn =T)
+!-----------------------------------------------------------------------
+!              ! file name ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_apr      = 'patm'    ,         -1        ,'somslpre',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,      ''
 
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   rn_pref     = 101000.   !  reference atmospheric pressure   [N/m2]/
+   ln_ref_apr  = .false.   !  ref. pressure: global mean Patm (T) or a constant (F)
+   ln_apr_obc  = .false.   !  inverse barometer added to OBC ssh data
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring   (ln_ssr=T)
+!-----------------------------------------------------------------------
+!              ! file name ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !   name   !   (logical) !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_sst      = 'sst_data',        24         ,  'sst'   ,    .false.  , .false., 'yearly'  ,    ''    ,    ''    ,     ''
+   sn_sss      = 'sss_data',        -1         ,  'sss'   ,    .true.   , .true. , 'yearly'  ,    ''    ,    ''    ,     ''
+
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_sstr     =     0     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=2)
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_dqdt     =   -40.    !  magnitude of the retroaction on temperature   [W/m2/K]
+   rn_deds     =  -166.67  !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =  .true.   !  flag to bound erp term (associated with nn_sssr=2)
+   rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
 !-----------------------------------------------------------------------
-&namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
+   nn_ice_alb  =    0      !  parameterization of ice/snow albedo
+                           !     0: Shine & Henderson-Sellers (JGR 1985)
+                           !     1: "home made" based on Brandt et al. (J. Climate 2005)
+                           !                         and Grenfell & Perovich (JGR 2004)
+   rn_albice   =  0.53     !  albedo of bare puddled ice (values from 0.49 to 0.58)
+                           !     0.53 (default) => if nn_ice_alb=0
+                           !     0.50 (default) => if nn_ice_alb=1
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model
 !-----------------------------------------------------------------------
-!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_apr= 'ERA5_MSL',        1         ,   'air_pressure_at_sea_level' ,    .true.    , .false., 'daily'   ,  'weights_era5_INDIAN_bicubic.nc'      ,   ''     ,  'ERA5_LSM'
-   cn_dir      = './FORCING/'!  root directory for the location of the bulk files
-   rn_pref     = 101200.    !  reference atmospheric pressure   [N/m2]/
-   ln_ref_apr  = .false.    !  ref. pressure: global mean Patm (T) or a constant (F)
-   ln_apr_obc  = .true.     !  inverse barometer added to OBC ssh data
+!              !  file name  ! frequency (hours) ! variable     ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name       !   (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_cdg      =  'sdw_wave' ,        1          , 'drag_coeff' ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_usd      =  'sdw_wave' ,        1          , 'u_sd2d'     ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_vsd      =  'sdw_wave' ,        1          , 'v_sd2d'     ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_swh      =  'sdw_wave' ,        1          , 'hs'         ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_wmp      =  'sdw_wave' ,        1          , 'wmp'        ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_wnum     =  'sdw_wave' ,        1          , 'wave_num'   ,     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+   sn_tauoc    =  'sdw_wave' ,        1          , 'wave_stress',     .true.   , .false. , 'daily'   ,  ''      , ''       , ''
+!
+   cn_dir  = './'  !  root directory for the location of drag coefficient files
 /
 !-----------------------------------------------------------------------
 &namberg       !   iceberg parameters                                   (default: No iceberg)
 !-----------------------------------------------------------------------
+   ln_icebergs              = .false.              ! iceberg floats or not
+   ln_bergdia               = .true.               ! Calculate budgets
+   nn_verbose_level         = 1                    ! Turn on more verbose output if level > 0
+   nn_verbose_write         = 15                   ! Timesteps between verbose messages
+   nn_sample_rate           = 1                    ! Timesteps between sampling for trajectory storage
+                                                   ! Initial mass required for an iceberg of each class
+   rn_initial_mass          = 8.8e7, 4.1e8, 3.3e9, 1.8e10, 3.8e10, 7.5e10, 1.2e11, 2.2e11, 3.9e11, 7.4e11
+                                                   ! Proportion of calving mass to apportion to each class
+   rn_distribution          = 0.24, 0.12, 0.15, 0.18, 0.12, 0.07, 0.03, 0.03, 0.03, 0.02
+                                                   ! Ratio between effective and real iceberg mass (non-dim)
+                                                   ! i.e. number of icebergs represented at a point
+   rn_mass_scaling          = 2000, 200, 50, 20, 10, 5, 2, 1, 1, 1
+                                                   ! thickness of newly calved bergs (m)
+   rn_initial_thickness     = 40., 67., 133., 175., 250., 250., 250., 250., 250., 250.
+   rn_rho_bergs             = 850.                 ! Density of icebergs
+   rn_LoW_ratio             = 1.5                  ! Initial ratio L/W for newly calved icebergs
+   ln_operator_splitting    = .true.               ! Use first order operator splitting for thermodynamics
+   rn_bits_erosion_fraction = 0.                   ! Fraction of erosion melt flux to divert to bergy bits
+   rn_sicn_shift            = 0.                   ! Shift of sea-ice concn in erosion flux (0<sicn_shift<1)
+   ln_passive_mode          = .false.              ! iceberg - ocean decoupling
+   nn_test_icebergs         =  10                  ! Create test icebergs of this class (-1 = no)
+                                                   ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
+   rn_test_box              = 108.0,  116.0, -66.0, -58.0
+   rn_speed_limit           = 0.                   ! CFL speed limit for a berg
+
+!         ! file name ! frequency (hours) !   variable   ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!         !           !  (if <0  months)  !     name     !   (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_icb =  'calving',       -1          , 'calvingmask',  .true.      , .true.  , 'yearly'  , ''       , ''       , ''
+
+   cn_dir = './'
 /
+
+!!======================================================================
+!!               ***  Lateral boundary condition  ***
+!!======================================================================
+!!   namlbc        lateral momentum boundary condition
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
+!!   nam_tide      Tidal forcing
+!!   nambdy        Unstructured open boundaries
+!!   nambdy_dta    Unstructured open boundaries - external data
+!!   nambdy_tide   tidal forcing at open boundaries
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &namlbc        !   lateral momentum boundary condition
 !-----------------------------------------------------------------------
-   rn_shlat    =     0     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
-                           !  free slip  !   partial slip  !   no slip   ! strong slip
+   !                       !  free slip  !   partial slip  !   no slip   ! strong slip
+   rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+   ln_vorlat   = .false.   !  consistency of vorticity boundary condition with analytical Eqs.
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+   nn_cln_update =    3    !  baroclinic update frequency
+   ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
+   rn_sponge_tra = 2880.   !  coefficient for tracer   sponge layer [m2/s]
+   rn_sponge_dyn = 2880.   !  coefficient for dynamics sponge layer [m2/s]
+   ln_chk_bathy  = .FALSE. !
 /
-
 !-----------------------------------------------------------------------
 &nam_tide      !   tide parameters
 !-----------------------------------------------------------------------
    ln_tide     = .true.
-   rdttideramp =    0
-   clname(1)     =   'M2'   !  name of constituent
-   clname(2)     =   'K2'
-   clname(3)     =   'S2'
-   clname(4)     =   'N2'
-   clname(5)     =   'Q1'   !  name of constituent
-   clname(6)     =   'O1'
-   clname(7)     =   'P1'
-   clname(8)     =   'K1'
-!   clname(5)     =   '2N2'
-!   clname(6)     =   'MU2'
-!   clname(7)     =   'N2'
-!   clname(8)     =   'NU2'
-!   clname(9)     =   'M2'
-!   clname(10)    =   'L2'
-!   clname(11)    =   'T2'
-!   clname(12)    =   'S2'
-!   clname(13)    =   'K2'
-!   clname(14)    =   'M4'
-!   clname(15)    =   '2MK6'
-!   clname(16)    =   '2MS6'
-!   clname(17)    =   '2SM2'
-!   clname(18)    =   '3M2S2'
-!   clname(19)    =   'Lam2'
-!   clname(20)    =   'M6'
-!   clname(21)    =   'MK3'
-!   clname(22)    =   'MN4'
-!   clname(23)    =   'MNS2'
-!   clname(24)    =   'MO3'
-!   clname(25)    =   'MS4'
-!   clname(26)    =   'MSN2'
+   ln_tide_pot = .true.    !  use tidal potential forcing
+   ln_tide_ramp= .false.   !
+   rdttideramp =    1.     !
+   clname(1)   =  'M2'   !  name of constituent - all tidal components must be set in namelist_cfg
+   clname(2)   = 'S2'   !  name of constituent - all tidal components must be set in namelist_cfg
+   clname(3)   = 'K2'   !  name of constituent - all tidal components must be set in namelist_cfg
+   clname(4)   = 'O1'
+   clname(5)   = 'K1'
 /
 !-----------------------------------------------------------------------
 &nambdy        !  unstructured open boundaries
 !-----------------------------------------------------------------------
-   ln_bdy     = .true.
-   nb_bdy         = 1                    !  number of open boundary sets
-   cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
-   cn_dyn2d       = 'flather'            ! was flather
-   nn_dyn2d_dta   =  2                   !  = 0, bdy data are equal to the initial state
-                                         !  = 1, bdy data are read in 'bdydata   .nc' files
-                                         !  = 2, use tidal harmonic forcing data from files
-                                         !  = 3, use external data AND tidal harmonic forcing
+    ln_bdy         = .true.              !  Use unstructured open boundaries
+    nb_bdy         = 1                    !  number of open boundary sets
+    ln_coords_file = .true.               !  =T : read bdy coordinates from file
+    cn_coords_file = 'coordinates.bdy.nc' !  bdy coordinates files
+    ln_mask_file   = .false.              !  =T : read mask from file
+    cn_mask_file   = 'bdy_mask.nc'                   !  name of mask file (if ln_mask_file=.TRUE.)
+    cn_dyn2d       = 'flather'               !
+    nn_dyn2d_dta   =  2                   !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+                                          !  = 2, use tidal harmonic forcing data from files
+                                          !  = 3, use external data AND tidal harmonic forcing
+    cn_dyn3d      =  'specified'               !
+    nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_tra        =  'frs'               !
+    nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    cn_ice_lim      =  'none'             !
+    nn_ice_lim_dta  =  0                  !  = 0, bdy data are equal to the initial state
+                                          !  = 1, bdy data are read in 'bdydata   .nc' files
+    rn_ice_tem      = 270.                !  lim3 only: arbitrary temperature of incoming sea ice
+    rn_ice_sal      = 10.                 !  lim3 only:      --   salinity           --
+    rn_ice_age      = 30.                 !  lim3 only:      --   age                --
 
-    cn_dyn3d      =  'frs'               !
-    nn_dyn3d_dta  =  0                   !  = 0, bdy data are equal to the initial state
-                                         !  = 1, bdy data are read in 'bdydata   .nc' files
-
-
-   cn_tra        =  'frs'                ! 'frs'
-   nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
-                                         !  = 1, bdy data are read in 'bdydata   .nc' files
-   nn_rimwidth   = 1                     !  width of the relaxation zone
-   ln_tra_dmp    = .false.
+    ln_tra_dmp    =.false.                !  open boudaries conditions for tracers
+    ln_dyn3d_dmp  =.false.                !  open boundary condition for baroclinic velocities
+    rn_time_dmp   =  1.                   ! Damping time scale in days
+    rn_time_dmp_out =  1.                 ! Outflow damping time scale
+    nn_rimwidth   = 9                    !  width of the relaxation zone
+    ln_vol        = .false.               !  total volume correction (see nn_volctl parameter)
+    nn_volctl     = 1                     !  = 0, the total water flux across open boundaries is zero
+    nb_jpk_bdy    = 75                    ! number of levels in the bdy data (set < 0 if consistent with planned run)
 /
 !-----------------------------------------------------------------------
-&nambdy_dta      !  open boundaries - external data
+&nambdy_dta    !  open boundaries - external data
 !-----------------------------------------------------------------------
 !              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_ssh      = 'INDIAN_bdy_SSH' ,    24        , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_u2d      = 'INDIAN_bdy_U'    ,    24        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_v2d      = 'INDIAN_bdy_V'    ,    24        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_u3d      = 'INDIAN_bdy_U'    ,    24        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_v3d      = 'INDIAN_bdy_V'    ,    24        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_tem      = 'INDIAN_bdy_TEMP',    24        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_sal      = 'INDIAN_bdy_SAL' ,    24        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_ssh      = 'GCOMS1k_LME_12_BLZE_bt_bdyT',24       , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u2d      = 'GCOMS1k_LME_12_BLZE_bdyU',   24        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v2d      = 'GCOMS1k_LME_12_BLZE_bdyV',   24        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u3d      = 'GCOMS1k_LME_12_BLZE_bdyU'    24        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v3d      = 'GCOMS1k_LME_12_BLZE_bdyV'    24        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_tem      = 'GCOMS1k_LME_12_BLZE_bdyT'    24        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_sal      = 'GCOMS1k_LME_12_BLZE_bdyT'    24        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+! for lim2
+!   bn_frld    = 'amm12_bdyT_ice',         24        , 'ileadfra',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_hicif   = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_hsnif   = 'amm12_bdyT_ice',         24        , 'isnowthi',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+! for lim3
+!   bn_a_i     = 'amm12_bdyT_ice',         24        , 'ileadfra',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_ht_i    = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+!   bn_ht_s    = 'amm12_bdyT_ice',         24        , 'isnowthi',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+
+   cn_dir      = 'bdydta/' !  root directory for the location of the bulk files
+   ln_full_vel = .true.   !
 /
 !-----------------------------------------------------------------------
-&nambdy_tide     ! tidal forcing at open boundaries
+&nambdy_tide   !  tidal forcing at open boundaries
 !-----------------------------------------------------------------------
-   filtide      = 'TIDES/INDIAN_bdytide_rotT_'         !  file name root of tidal forcing files
-   ln_bdytide_2ddta = .false. 
+   filtide      = 'TIDES/INDIAN_bdytide_rotT_'  !  file name root of tidal forcing files
+   ln_bdytide_2ddta = .false.                   !
    ln_bdytide_conj  = .false.                   !
 /
+
+!!======================================================================
+!!                 ***  Bottom boundary condition  ***
+!!======================================================================
+!!   nambfr        bottom friction
+!!   nambbc        bottom temperature boundary condition
+!!   nambbl        bottom boundary layer scheme                         ("key_trabbl")
+!!======================================================================
+!
 !-----------------------------------------------------------------------
-&nambfr        !   bottom friction
+&nambfr        !   bottom friction                                      (default: linear)
 !-----------------------------------------------------------------------
    nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
                            !                              = 2 : nonlinear friction
-   rn_bfri2    =    2.4e-3 !  bottom drag coefficient (non linear case)
-   rn_bfeb2    =    0.0e0  !  bottom turbulent kinetic energy background  (m2/s2)
-   ln_loglayer =   .false. !  loglayer bottom friction (only effect when nn_bfr = 2)
-   rn_bfrz0    =    0.003  !  bottom roughness (only effect when ln_loglayer = .true.)
+   rn_bfri2    =    2.5e-3  !  bottom drag coefficient (non linear case). Minimum coeft if ln_loglayer=T
+   rn_bfri2_max=    1.e-1  !  max. bottom drag coefficient (non linear case and ln_loglayer=T)
+   rn_bfeb2    =    0.0e-3 !  bottom turbulent kinetic energy background  (m2/s2)
+   rn_bfrz0    =    3.e-3  !  bottom roughness [m] if ln_loglayer=T
+   ln_bfr2d    = .false.   !  horizontal variation of the bottom friction coef (read a 2D mask file )
+   rn_bfrien   =    50.    !  local multiplying factor of bfr (ln_bfr2d=T)
+   rn_tfri1    =    4.e-4  !  top drag coefficient (linear case)
+   rn_tfri2    =    2.5e-3 !  top drag coefficient (non linear case). Minimum coeft if ln_loglayer=T
+   rn_tfri2_max=    1.e-1  !  max. top drag coefficient (non linear case and ln_loglayer=T)
+   rn_tfeb2    =    0.0    !  top turbulent kinetic energy background  (m2/s2)
+   rn_tfrz0    =    3.e-3  !  top roughness [m] if ln_loglayer=T
+   ln_tfr2d    = .false.   !  horizontal variation of the top friction coef (read a 2D mask file )
+   rn_tfrien   =   50.     !  local multiplying factor of tfr (ln_tfr2d=T)
+
+   ln_bfrimp   = .true.    !  implicit bottom friction (requires ln_zdfexp = .false. if true)
+   ln_loglayer = .true.   !  logarithmic formulation (non linear case)
 /
 !-----------------------------------------------------------------------
-&nambbc        !   bottom temperature boundary condition
+&nambbc        !   bottom temperature boundary condition                (default: NO)
 !-----------------------------------------------------------------------
+!              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_qgh      ='geothermal_heating.nc',  -12.       , 'heatflow',   .false.   , .true.  , 'yearly'  ,   ''     ,   ''     ,   ''
+   !
    ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
+                           !     = 1 constant flux
+                           !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
+   rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
+   cn_dir      = './'      !  root directory for the location of the runoff files
 /
 !-----------------------------------------------------------------------
-&nambbl        !   bottom boundary layer scheme
+&nambbl        !   bottom boundary layer scheme                         ("key_trabbl")
 !-----------------------------------------------------------------------
-   nn_bbl_ldf  =  0      !  diffusive bbl (=1)   or not (=0)
+   nn_bbl_ldf  =  1        !  diffusive bbl (=1)   or not (=0)
+   nn_bbl_adv  =  0        !  advective bbl (=1/2) or not (=0)
+   rn_ahtbbl   =  1000.    !  lateral mixing coefficient in the bbl  [m2/s]
+   rn_gambbl   =  10.      !  advective bbl coefficient                 [s]
 /
+
+!!======================================================================
+!!                        Tracer (T & S ) namelists
+!!======================================================================
+!!   nameos           equation of state
+!!   namtra_adv       advection scheme
+!!   namtra_adv_mle   mixed layer eddy param. (Fox-Kemper param.)
+!!   namtra_ldf       lateral diffusion scheme
+!!   namtra_ldfeiv    eddy induced velocity param.
+!!   namtra_dmp       T & S newtonian damping
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &nameos        !   ocean physical parameters
 !-----------------------------------------------------------------------
-   ln_teos10   = .true.         !  = Use TEOS-10 equation of state
+   ln_teos10   = .false.         !  = Use TEOS-10 equation of state
+   ln_eos80    = .true.         !  = Use EOS80 equation of state
+   ln_seos     = .false.         !  = Use simplified equation of state (S-EOS)
+                                 !
+   !                     ! S-EOS coefficients (ln_seos=T):
+   !                             !  rd(T,S,Z)*rau0 = -a0*(1+.5*lambda*dT+mu*Z+nu*dS)*dT+b0*dS
+   rn_a0       =  1.6550e-1      !  thermal expension coefficient
+   rn_b0       =  7.6554e-1      !  saline  expension coefficient
+   rn_lambda1  =  5.9520e-2      !  cabbeling coeff in T^2  (=0 for linear eos)
+   rn_lambda2  =  7.4914e-4      !  cabbeling coeff in S^2  (=0 for linear eos)
+   rn_mu1      =  1.4970e-4      !  thermobaric coeff. in T (=0 for linear eos)
+   rn_mu2      =  1.1090e-5      !  thermobaric coeff. in S (=0 for linear eos)
+   rn_nu       =  2.4341e-3      !  cabbeling coeff in T*S  (=0 for linear eos)
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer
+&namtra_adv    !   advection scheme for tracer                          (default: NO advection)
+!-----------------------------------------------------------------------
+   ln_traadv_cen = .false. !  2nd order centered scheme
+      nn_cen_h   =  4            !  =2/4, horizontal 2nd order CEN / 4th order CEN
+      nn_cen_v   =  4            !  =2/4, vertical   2nd order CEN / 4th order COMPACT
+   ln_traadv_fct = .true. !  FCT scheme
+      nn_fct_h   =  2            !  =2/4, horizontal 2nd / 4th order
+      nn_fct_v   =  2            !  =2/4, vertical   2nd / COMPACT 4th order
+      nn_fct_zts =  0            !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                          !        (number of sub-timestep = nn_fct_zts)
+   ln_traadv_mus = .false. !  MUSCL scheme
+      ln_mus_ups = .false.       !  use upstream scheme near river mouths
+   ln_traadv_ubs = .false. !  UBS scheme
+      nn_ubs_v   =  2            !  =2  , vertical 2nd order FCT / COMPACT 4th order
+   ln_traadv_qck = .false. !  QUICKEST scheme
+/
 !-----------------------------------------------------------------------
+&namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param) (default: NO)
+!-----------------------------------------------------------------------
+   ln_mle      = .false.   ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   rn_ce       = 0.06      ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_mle      = 1         ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_lf       = 5.e+3     ! typical scale of mixed layer front (meters)                      (case rn_mle=0)
+   rn_time     = 172800.   ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_mle=0)
+   rn_lat      = 20.       ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   nn_mld_uv   = 0         ! space interpolation of MLD at u- & v-pts (0=min,1=averaged,2=max)
+   nn_conv     = 0         ! =1 no MLE in case of convection ; =0 always MLE
+   rn_rho_c_mle= 0.01      ! delta rho criterion used to calculate MLD for FK
 /
 !-----------------------------------------------------------------------
-&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO diffusion)
 !-----------------------------------------------------------------------
-/
-!----------------------------------------------------------------------------------
-&namtra_ldf    !   lateral diffusion scheme for tracers
-!----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   !                           !  no diffusion: set ln_traldf_lap=..._blp=F
+   ln_traldf_lap   =  .true.  !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.  !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:
+   ln_traldf_msc   =  .false.  !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity and grid-spacing)
+   rn_aht_0        = 25. !125.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
 /
 !-----------------------------------------------------------------------
 &namtra_ldfeiv !   eddy induced velocity param.                         (default: NO)
 !-----------------------------------------------------------------------
+   ln_ldfeiv     =.false.  ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.false.  ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.   ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21      ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
-&namtra_dmp    !   tracer: T & S newtonian damping
+&namtra_dmp    !   tracer: T & S newtonian damping                      (default: NO)
 !-----------------------------------------------------------------------
+   ln_tradmp   =  .false.   !  add a damping termn (T) or not (F)
+   nn_zdmp     =    0      !  vertical   shape =0    damping throughout the water column
+                           !                   =1 no damping in the mixing layer (kz  criteria)
+                           !                   =2 no damping in the mixed  layer (rho crieria)
+   cn_resto    ='resto.nc' !  Name of file containing restoration coeff. field (use dmp_tools to create this)
 /
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***
+!!======================================================================
+!!   namdyn_adv    formulation of the momentum advection
+!!   namdyn_vor    advection scheme
+!!   namdyn_hpg    hydrostatic pressure gradient
+!!   namdyn_spg    surface pressure gradient
+!!   namdyn_ldf    lateral diffusion scheme
+!!======================================================================
+!
 !-----------------------------------------------------------------------
-&namdyn_adv    !   formulation of the momentum advection
+&namdyn_adv    !   formulation of the momentum advection                (default: vector form)
 !-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
+   nn_dynkeg     = 0       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+   ln_dynzad_zts = .false. !  Use (T) sub timestepping for vertical momentum advection
 /
 !-----------------------------------------------------------------------
-&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+&nam_vvl    !   vertical coordinate options                             (default: zstar)
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  zstar vertical coordinate
+   ln_vvl_ztilde = .false.          !  ztilde vertical coordinate: only high frequency variations
+   ln_vvl_layer  = .false.          !  full layer vertical coordinate
+   ln_vvl_ztilde_as_zstar = .false. !  ztilde vertical coordinate emulating zstar
+   ln_vvl_zstar_at_eqtor  = .false. !  ztilde near the equator
+   rn_ahe3       = 0.0e0            !  thickness diffusion coefficient
+   rn_rst_e3t    = 30.e0            !  ztilde to zstar restoration timescale [days]
+   rn_lf_cutoff  = 5.0e0            !  cutoff frequency for low-pass filter  [days]
+   rn_zdef_max   = 0.9e0            !  maximum fractional e3t deformation
+   ln_vvl_dbg    = .true.           !  debug prints    (T/F)
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO)
 !-----------------------------------------------------------------------
-   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true. !  energy & enstrophy scheme
+      nn_een_e3f = 1          ! e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   ln_dynvor_msk = .false. !  vorticity multiplied by fmask (=T) or not (=F) (all vorticity schemes)  ! PLEASE DO NOT ACTIVATE
 /
 !-----------------------------------------------------------------------
-&namdyn_hpg    !   Hydrostatic pressure gradient option
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: zps)
 !-----------------------------------------------------------------------
+   ln_hpg_zco  = .false.   !  z-coordinate - full steps
    ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
-   ln_hpg_sco  = .true.    !  s-coordinate (Standard Jacobian scheme)
+   ln_hpg_sco  = .false.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_isf  = .false.   !  s-coordinate (sco ) adapted to isf
+   ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
+   ln_hpg_prj  = .true.   !  s-coordinate (Pressure Jacobian scheme)
 /
 !-----------------------------------------------------------------------
 &namdyn_spg    !   surface pressure gradient                            (default: NO)
 !-----------------------------------------------------------------------
-  ln_dynspg_exp  = .false.   ! explicit free surface
-  ln_dynspg_ts   = .true.   ! split-explicit free surface
+   ln_dynspg_exp  = .false.   ! explicit free surface
+   ln_dynspg_ts   = .true.   ! split-explicit free surface
       ln_bt_fw      = .true.     ! Forward integration of barotropic Eqs.
       ln_bt_av      = .true.     ! Time filtering of barotropic variables
-        nn_bt_flt     = 1          ! Time filter choice  = 0 None
+         nn_bt_flt     = 1          ! Time filter choice  = 0 None
          !                          !                     = 1 Boxcar over   nn_baro sub-steps
-        !                          !                     = 2 Boxcar over 2*nn_baro  "    "
+         !                          !                     = 2 Boxcar over 2*nn_baro  "    "
       ln_bt_auto    = .true.     ! Number of sub-step defined from:
-       rn_bt_cmax   =  0.5        ! =T : the Maximum Courant Number allowed
-        nn_baro      = 30          ! =F : the number of sub-step in rn_rdt seconds
-      ln_ulimit     =.true.
+         rn_bt_cmax   =  0.5        ! =T : the Maximum Courant Number allowed
+         nn_baro      = 30          ! =F : the number of sub-step in rn_rdt seconds
+       ln_ulimit     =.true.
        cn_ulimit     = 0.9
        cnn_ulimit    = 0.54
 /
 !-----------------------------------------------------------------------
-!&namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
-!   ln_dynspg_ts = .true.    ! split-explicit free surface
-!   ln_bt_auto =    .true.           !  Set nn_baro automatically to be just below
-!                                       !  a user defined maximum courant number (rn_bt_cmax)
-!/
-!-----------------------------------------------------------------------
-&namdyn_ldf    !   lateral diffusion on momentum
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO)
 !-----------------------------------------------------------------------
    !                       !  Type of the operator :
-   ln_dynldf_blp  =  .true.   !  bilaplacian operator
-   ln_dynldf_lap    =  .false.  !  bilaplacian operator
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .true.    !  bilaplacian operator
    !                       !  Direction of action  :
-   ln_dynldf_lev  =  .true.   !  iso-level
-                           !  Coefficient
-   rn_ahm_0     = 60.0      !  horizontal laplacian eddy viscosity   [m2/s]
-   rn_bhm_0     = -1.0e+9   !  horizontal bilaplacian eddy viscosity [m4/s]
+   ln_dynldf_lev =  .true.    !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   !                                !  = 32  F(i,j,k)=F(local gridscale and deformation rate)
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
+   rn_ahm_0      =  50.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =   0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = -1.e+7      !  horizontal bilaplacian eddy viscosity [m4/s]
+   !                       !  Smagorinsky settings (nn_ahm_ijk_t  = 32) :
+   rn_csmc       = 3.5         !  Smagorinsky constant of proportionality
+   rn_minfac     = 1.0         !  multiplier of theorectical lower limit
+   rn_maxfac     = 1.0         !  multiplier of theorectical upper limit
 /
+
+!!======================================================================
+!!             Tracers & Dynamics vertical physics namelists
+!!======================================================================
+!!    namzdf        vertical physics
+!!    namzdf_ric    richardson number dependent vertical mixing         ("key_zdfric")
+!!    namzdf_tke    TKE dependent vertical mixing                       ("key_zdftke")
+!!    namzdf_gls    GLS vertical mixing                                 ("key_zdfgls")
+!!    namzdf_ddm    double diffusive mixing parameterization            ("key_zdfddm")
+!!    namzdf_tmx    tidal mixing parameterization                       ("key_zdftmx")
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &namzdf        !   vertical physics
 !-----------------------------------------------------------------------
-   rn_avm0     =   0.1e-6  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
-   rn_avt0     =   0.1e-6  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
-   ln_zdfevd   = .false.   !  enhanced vertical diffusion (evd) (T) or not (F)
-   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+   rn_avm0     =   1.2e-4  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+      nn_evdm     =    0        ! evd apply on tracer (=0) or on tracer and momentum (=1)
+      rn_avevd    =  100.       !  evd mixing coefficient [m2/s]
+   ln_zdfnpc   = .false.   !  Non-Penetrative Convective algorithm (T) or not (F)
+      nn_npc      =    1        ! frequency of application of npc
+      nn_npcp     =  365        ! npc control print frequency
+   ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
+      nn_zdfexp   =    3        ! number of sub-timestep for ln_zdfexp=T
+   ln_zdfqiao  = .false.   !  Enhanced wave vertical mixing Qiao (2010) (T => ln_wave=.true. & ln_sdw=.true. & fill namsbc_wave)
 /
 !-----------------------------------------------------------------------
 &namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
 !-----------------------------------------------------------------------
+   rn_avmri    =  100.e-4  !  maximum value of the vertical viscosity
+   rn_alp      =    5.     !  coefficient of the parameterization
+   nn_ric      =    2      !  coefficient of the parameterization
+   rn_ekmfc    =    0.7    !  Factor in the Ekman depth Equation
+   rn_mldmin   =    1.0    !  minimum allowable mixed-layer depth estimate (m)
+   rn_mldmax   = 1000.0    !  maximum allowable mixed-layer depth estimate (m)
+   rn_wtmix    =   10.0    !  vertical eddy viscosity coeff [m2/s] in the mixed-layer
+   rn_wvmix    =   10.0    !  vertical eddy diffusion coeff [m2/s] in the mixed-layer
+   ln_mldw     =  .true.   !  Flag to use or not the mixed layer depth param.
 /
 !-----------------------------------------------------------------------
 &namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
 !-----------------------------------------------------------------------
+   rn_ediff    =   0.1     !  coef. for vertical eddy coef. (avt=rn_ediff*mxl*sqrt(e) )
+   rn_ediss    =   0.7     !  coef. of the Kolmogoroff dissipation
+   rn_ebb      =  67.83    !  coef. of the surface input of tke (=67.83 suggested when ln_mxl0=T)
+   rn_emin     =   1.e-6   !  minimum value of tke [m2/s2]
+   rn_emin0    =   1.e-4   !  surface minimum value of tke [m2/s2]
+   rn_bshear   =   1.e-20  ! background shear (>0) currently a numerical threshold (do not change it)
+   nn_mxl      =   2       !  mixing length: = 0 bounded by the distance to surface and bottom
+                           !                 = 1 bounded by the local vertical scale factor
+                           !                 = 2 first vertical derivative of mixing length bounded by 1
+                           !                 = 3 as =2 with distinct disspipative an mixing length scale
+   nn_pdl      =   1       !  Prandtl number function of richarson number (=1, avt=pdl(Ri)*avm) or not (=0, avt=avm)
+   ln_mxl0     = .true.    !  surface mixing length scale = F(wind stress) (T) or not (F)
+   rn_mxl0     =   0.04    !  surface  buoyancy lenght scale minimum value
+   ln_lc       = .true.    !  Langmuir cell parameterisation (Axell 2002)
+   rn_lc       =   0.15    !  coef. associated to Langmuir cells
+   nn_etau     =   1       !  penetration of tke below the mixed layer (ML) due to near intertial waves
+                           !        = 0 no penetration
+                           !        = 1 add a tke source below the ML
+                           !        = 2 add a tke source just at the base of the ML
+                           !        = 3 as = 1 applied on HF part of the stress           (ln_cpl=T)
+   rn_efr      =   0.05    !  fraction of surface tke value which penetrates below the ML (nn_etau=1 or 2)
+   nn_htau     =   1       !  type of exponential decrease of tke penetration below the ML
+                           !        = 0  constant 10 m length scale
+                           !        = 1  0.5m at the equator to 30m poleward of 40 degrees
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-/
-!-----------------------------------------------------------------------
-&namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
 !-----------------------------------------------------------------------
+&namzdf_gls    !   GLS vertical diffusion                               ("key_zdfgls")
+!-----------------------------------------------------------------------
+   rn_emin       = 1.e-7   !  minimum value of e   [m2/s2]
+   rn_epsmin     = 1.e-12  !  minimum value of eps [m2/s3]
+   ln_length_lim = .true.  !  limit on the dissipation rate under stable stratification (Galperin et al., 1988)
+   rn_clim_galp  = 0.267   !  galperin limit
+   ln_sigpsi     = .true.  !  Activate or not Burchard 2001 mods on psi schmidt number in the wb case
+   rn_crban      = 100.    !  Craig and Banner 1994 constant for wb tke flux
+   rn_charn      = 70000.  !  Charnock constant for wb induced roughness length
+   rn_hsro       =  0.02   !  Minimum surface roughness
+   rn_frac_hs    =   1.3   !  Fraction of wave height as roughness (if nn_z0_met=2)
+   nn_z0_met     =     2   !  Method for surface roughness computation (0/1/2)
+   nn_bc_surf    =     1   !  surface condition (0/1=Dir/Neum)
+   nn_bc_bot     =     1   !  bottom condition (0/1=Dir/Neum)
+   nn_stab_func  =     2   !  stability function (0=Galp, 1= KC94, 2=CanutoA, 3=CanutoB)
+   nn_clos       =     1   !  predefined closure type (0=MY82, 1=k-eps, 2=k-w, 3=Gen)
 /
 !-----------------------------------------------------------------------
 &namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
 !-----------------------------------------------------------------------
+   rn_avts     = 1.e-4     !  maximum avs (vertical mixing on salinity)
+   rn_hsbfr    = 1.6       !  heat/salt buoyancy flux ratio
 /
 !-----------------------------------------------------------------------
 &namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
 !-----------------------------------------------------------------------
+   rn_htmx     = 500.      !  vertical decay scale for turbulence (meters)
+   rn_n2min    = 1.e-8     !  threshold of the Brunt-Vaisala frequency (s-1)
+   rn_tfe      = 0.333     !  tidal dissipation efficiency
+   rn_me       = 0.2       !  mixing efficiency
+   ln_tmx_itf  = .true.    !  ITF specific parameterisation
+   rn_tfe_itf  = 1.        !  ITF tidal dissipation efficiency
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
+&namzdf_tmx_new !   internal wave-driven mixing parameterization        ("key_zdftmx_new" & "key_zdfddm")
 !-----------------------------------------------------------------------
+   nn_zpyc     = 1         !  pycnocline-intensified dissipation scales as N (=1) or N^2 (=2)
+   ln_mevar    = .true.    !  variable (T) or constant (F) mixing efficiency
+   ln_tsdiff   = .true.    !  account for differential T/S mixing (T) or not (F)
 /
+!!======================================================================
+!!                  ***  Miscellaneous namelists  ***
+!!======================================================================
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
+!!   namctl            Control prints
+!!   namsto            Stochastic parametrization of EOS
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
+   cn_mpi_send =  'I'      !  mpi send/recieve type   ='S', 'B', or 'I' for standard send,
+                           !  buffer blocking send or immediate non-blocking sends, resp.
+   nn_buffer   =   0       !  size in bytes of exported buffer ('B' case), 0 no exportation
+   ln_nnogather=  .false.  !  activate code to avoid mpi_allgather use at the northfold
+   jpni        =  -20       !  jpni   number of processors following i (set automatically if < 1)
+   jpnj        =  -40    !  jpnj   number of processors following j (set automatically if < 1)
+   jpnij       =  -550    !  jpnij  number of local domains (set automatically if < 1)
 /
 !-----------------------------------------------------------------------
-&namctl        !   Control prints & Benchmark
-!-----------------------------------------------------------------------
+&namctl        !   Control prints
+!-----------------------------------------------------------------------
+   ln_ctl      = .false.   !  trends control print (expensive!)
+   nn_print    =    0      !  level of print (0 no extra print)
+   nn_ictls    =    0      !  start i indice of control sum (use to compare mono versus
+   nn_ictle    =    0      !  end   i indice of control sum        multi processor runs
+   nn_jctls    =    0      !  start j indice of control               over a subdomain)
+   nn_jctle    =    0      !  end   j indice of control
+   nn_isplt    =    1      !  number of processors in i-direction
+   nn_jsplt    =    1      !  number of processors in j-direction
+   nn_timing   =   1      !  timing by routine activated (=1) creates timing.output file, or not (=0)
+   nn_diacfl   =    0      !  Write out CFL diagnostics (=1) in cfl_diagnostics.ascii, or not (=0)
 /
 !-----------------------------------------------------------------------
-&namnc4        !   netcdf4 chunking and compression settings            ("key_netcdf4")
-!-----------------------------------------------------------------------
+&namsto        ! Stochastic parametrization of EOS                      (default: NO)
+!-----------------------------------------------------------------------
+   ln_sto_eos  = .false.   ! stochastic equation of state
+   nn_sto_eos  = 1         ! number of independent random walks
+   rn_eos_stdxy= 1.4       ! random walk horz. standard deviation (in grid points)
+   rn_eos_stdz = 0.7       ! random walk vert. standard deviation (in grid points)
+   rn_eos_tcor = 1440.     ! random walk time correlation (in timesteps)
+   nn_eos_ord  = 1         ! order of autoregressive processes
+   nn_eos_flt  = 0         ! passes of Laplacian filter
+   rn_eos_lim  = 2.0       ! limitation factor (default = 3.0)
+   ln_rststo   = .false.   ! start from mean parameter (F) or from restart file (T)
+   ln_rstseed  = .true.    ! read seed of RNG from restart file
+   cn_storst_in  = "restart_sto" !  suffix of stochastic parameter restart file (input)
+   cn_storst_out = "restart_sto" !  suffix of stochastic parameter restart file (output)
 /
+
+!!======================================================================
+!!                  ***  Diagnostics namelists  ***
+!!======================================================================
+!!   namtrd       dynamics and/or tracer trends                         (default F)
+!!   namptr       Poleward Transport Diagnostics                        (default F)
+!!   namhsb       Heat and salt budgets                                 (default F)
+!!   namdiu       Cool skin and warm layer models                       (default F)
+!!   namdiu       Cool skin and warm layer models                       (default F)
+!!   namflo       float parameters                                      ("key_float")
+!!   nam_diaharm  Harmonic analysis of tidal constituents               ("key_diaharm")
+!!   namdct       transports through some sections                      ("key_diadct")
+!!   nam_diatmb   Top Middle Bottom Output                              (default F)
+!!   nam_dia25h   25h Mean Output                                       (default F)
+!!   namnc4       netcdf4 chunking and compression settings             ("key_netcdf4")
+!!======================================================================
+!
 !-----------------------------------------------------------------------
-&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
-!              !       or mixed-layer trends or barotropic vorticity    ("key_trdmld" or     "key_trdvor")
-!-----------------------------------------------------------------------
+&namtrd        !   trend diagnostics                                    (default F)
+!-----------------------------------------------------------------------
+   ln_glo_trd  = .false.   ! (T) global domain averaged diag for T, T^2, KE, and PE
+   ln_dyn_trd  = .false.   ! (T) 3D momentum trend output
+   ln_dyn_mxl  = .false.   ! (T) 2D momentum trends averaged over the mixed layer (not coded yet)
+   ln_vor_trd  = .false.   ! (T) 2D barotropic vorticity trends (not coded yet)
+   ln_KE_trd   = .false.   ! (T) 3D Kinetic   Energy     trends
+   ln_PE_trd   = .false.   ! (T) 3D Potential Energy     trends
+   ln_tra_trd  = .false.   ! (T) 3D tracer trend output
+   ln_tra_mxl  = .false.   ! (T) 2D tracer trends averaged over the mixed layer (not coded yet)
+   nn_trd      = 365       !  print frequency (ln_glo_trd=T) (unit=time step)
 /
-!-----------------------------------------------------------------------
-&namflo       !   float parameters                                      ("key_float")
-!-----------------------------------------------------------------------
+!!gm   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+!!gm   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+!!gm   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+!!gm   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+!!gm   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+!!gm   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+!!gm
+!-----------------------------------------------------------------------
+&namptr        !   Poleward Transport Diagnostic                         (default F)
+!-----------------------------------------------------------------------
+   ln_diaptr   = .false.   !  Poleward heat and salt transport (T) or not (F)
+   ln_subbas   = .false.   !  Atlantic/Pacific/Indian basins computation (T) or not
 /
 !-----------------------------------------------------------------------
-&namptr       !   Poleward Transport Diagnostic
+&namhsb        !  Heat and salt budgets                                  (default F)
 !-----------------------------------------------------------------------
+   ln_diahsb   = .false.   !  check the heat and salt budgets (T) or not (F)
 /
 !-----------------------------------------------------------------------
-&namhsb       !  Heat and salt budgets
+&namdiu        !   Cool skin and warm layer models                       (default F)
 !-----------------------------------------------------------------------
+   ln_diurnal      = .false.   !
+   ln_diurnal_only = .false.   !
 /
 !-----------------------------------------------------------------------
-&namdiu        !   Cool skin and warm layer models                       (default F)
-!-----------------------------------------------------------------------
+&namflo        !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+   jpnfl       = 1         !  total number of floats during the run
+   jpnnewflo   = 0         !  number of floats for the restart
+   ln_rstflo   = .false.   !  float restart (T) or not (F)
+   nn_writefl  =      75   !  frequency of writing in float output file
+   nn_stockfl  =    5475   !  frequency of creation of the float restart file
+   ln_argo     = .false.   !  Argo type floats (stay at the surface each 10 days)
+   ln_flork4   = .false.   !  trajectories computed with a 4th order Runge-Kutta (T)
+   !                       !  or computed with Blanke' scheme (F)
+   ln_ariane   = .true.    !  Input with Ariane tool convention(T)
+   ln_flo_ascii= .true.    !  Output with Ariane tool netcdf convention(F) or ascii file (T)
 /
 !-----------------------------------------------------------------------
-&nam_diaharm   !   Harmonic analysis of tidal constituents ('key_diaharm')
+&nam_diaharm   !   Harmonic analysis of tidal constituents               ("key_diaharm")
 !-----------------------------------------------------------------------
-    nit000_han = 1 !43201     ! First time step used for harmonic analysis
-    nitend_han = 43680 !86400      ! Last time step used for harmonic analysis
-    nstep_han  = 5         ! Time step frequency for harmonic analysis
+    nit000_han = 14401         ! First time step used for harmonic analysis
+    nitend_han = 10800! 7200      ! Last time step used for harmonic analysis
+    nstep_han  = 5        ! Time step frequency for harmonic analysis
     tname(1)   = 'M2'      ! Name of tidal constituents
-    tname(2)   = 'K2'
-    tname(3)   = 'S2'
+    tname(2)   = 'S2'      ! Name of tidal constituents
+    tname(3)   = 'K1'      ! Name of tidal constituents
+    tname(4)   = 'O1'      ! Name of tidal constituents
 /
 !-----------------------------------------------------------------------
-&namdct        ! transports through sections
+&namdct        ! transports through some sections                        ("key_diadct")
 !-----------------------------------------------------------------------
+    nn_dct     = 15        !  time step frequency for transports computing
+    nn_dctwri  = 15        !  time step frequency for transports writing
+    nn_secdebug= 112       !      0 : no section to debug
+    !                      !     -1 : debug all section
+    !                      !  0 < n : debug section number n
 /
 !-----------------------------------------------------------------------
 &nam_diatmb    !  Top Middle Bottom Output                               (default F)
 !-----------------------------------------------------------------------
+   ln_diatmb   = .false.   !  Choose Top Middle and Bottom output or not
 /
 !-----------------------------------------------------------------------
-&nam_dia25h    !  25h Mean Output                                        (default F)
-!-----------------------------------------------------------------------
-/
 !-----------------------------------------------------------------------
-&namobs       !  observation usage switch                               ('key_diaobs')
+&namnc4        !   netcdf4 chunking and compression settings            ("key_netcdf4")
 !-----------------------------------------------------------------------
+   ln_diatmb   = .false.   !  Choose Top Middle and Bottom output or not
 /
 !-----------------------------------------------------------------------
-&nam_asminc   !   assimilation increments                               ('key_asminc')
+&nam_dia25h    !  25h Mean Output                                        (default F)
 !-----------------------------------------------------------------------
+   ln_dia25h   = .true.   ! Choose 25h mean output or not
 /
 !-----------------------------------------------------------------------
-&namsbc_wave   ! External fields from wave model
+&namnc4        !   netcdf4 chunking and compression settings             ("key_netcdf4")
 !-----------------------------------------------------------------------
+   nn_nchunks_i=   4       !  number of chunks in i-dimension
+   nn_nchunks_j=   4       !  number of chunks in j-dimension
+   nn_nchunks_k=   31      !  number of chunks in k-dimension
+   !                       !  setting nn_nchunks_k = jpk will give a chunk size of 1 in the vertical which
+   !                       !  is optimal for postprocessing which works exclusively with horizontal slabs
+   ln_nc4zip   = .true.    !  (T) use netcdf4 chunking and compression
+   !                       !  (F) ignore chunking information and produce netcdf3-compatible files
 /
+
+!!======================================================================
+!!               ***  Observation & Assimilation  ***
+!!======================================================================
+!!   namobs       observation and model comparison
+!!   nam_asminc   assimilation increments                               ('key_asminc')
+!!======================================================================
+!
 !-----------------------------------------------------------------------
-&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
-!-----------------------------------------------------------------------
+&namobs        !  observation usage switch
+!-----------------------------------------------------------------------
+   ln_diaobs   = .false.             ! Logical switch for the observation operator
+   ln_t3d      = .false.             ! Logical switch for T profile observations
+   ln_s3d      = .false.             ! Logical switch for S profile observations
+   ln_sla      = .false.             ! Logical switch for SLA observations
+   ln_sst      = .false.             ! Logical switch for SST observations
+   ln_sic      = .false.             ! Logical switch for Sea Ice observations
+   ln_vel3d    = .false.             ! Logical switch for velocity observations
+   ln_altbias  = .false.             ! Logical switch for altimeter bias correction
+   ln_nea      = .false.             ! Logical switch for rejection of observations near land
+   ln_grid_global = .true.           ! Logical switch for global distribution of observations
+   ln_grid_search_lookup = .false.   ! Logical switch for obs grid search w/lookup table
+   ln_ignmis   = .true.              ! Logical switch for ignoring missing files
+   ln_s_at_t   = .false.             ! Logical switch for computing model S at T obs if not there
+   ln_sstnight = .false.             ! Logical switch for calculating night-time average for SST obs
+! All of the *files* variables below are arrays. Use namelist_cfg to add more files
+   cn_profbfiles = 'profiles_01.nc'  ! Profile feedback input observation file names
+   cn_slafbfiles = 'sla_01.nc'       ! SLA feedback input observation file names
+   cn_sstfbfiles = 'sst_01.nc'       ! SST feedback input observation file names
+   cn_sicfbfiles = 'sic_01.nc'       ! SIC feedback input observation file names
+   cn_velfbfiles = 'vel_01.nc'       ! Velocity feedback input observation file names
+   cn_altbiasfile = 'altbias.nc'     ! Altimeter bias input file name
+   cn_gridsearchfile='gridsearch.nc' ! Grid search file name
+   rn_gridsearchres = 0.5            ! Grid search resolution
+   rn_dobsini  = 00010101.000000     ! Initial date in window YYYYMMDD.HHMMSS
+   rn_dobsend  = 00010102.000000     ! Final date in window YYYYMMDD.HHMMSS
+   nn_1dint    = 0                   ! Type of vertical interpolation method
+   nn_2dint    = 0                   ! Type of horizontal interpolation method
+   nn_msshc    = 0                   ! MSSH correction scheme
+   rn_mdtcorr  = 1.61                ! MDT  correction
+   rn_mdtcutoff = 65.0               ! MDT cutoff for computed correction
+   nn_profdavtypes = -1              ! Profile daily average types - array
+   ln_sstbias  = .false.             !
+   cn_sstbias_files = 'sstbias.nc'   !
 /
 !-----------------------------------------------------------------------
-&namwad       !   Wetting and Drying namelist
-!-----------------------------------------------------------------------
-   ln_wd = .false.   !: key to turn on/off wetting/drying (T: on, F: off) 
-   rn_wdmin1=0.1     !: minimum water depth on dried cells 
-   rn_wdmin2 = 0.01  !: tolerrance of minimum water depth on dried cells
-   rn_wdld   = 20.0  !: land elevation below which wetting/drying will be considered
-   nn_wdit   =   10  !: maximum number of iteration for W/D limiter
+&nam_asminc    !   assimilation increments                              ('key_asminc')
+!-----------------------------------------------------------------------
+    ln_bkgwri  = .false.   !  Logical switch for writing out background state
+    ln_trainc  = .false.   !  Logical switch for applying tracer increments
+    ln_dyninc  = .false.   !  Logical switch for applying velocity increments
+    ln_sshinc  = .false.   !  Logical switch for applying SSH increments
+    ln_asmdin  = .false.   !  Logical switch for Direct Initialization (DI)
+    ln_asmiau  = .false.   !  Logical switch for Incremental Analysis Updating (IAU)
+    nitbkg     = 0         !  Timestep of background in [0,nitend-nit000-1]
+    nitdin     = 0         !  Timestep of background for DI in [0,nitend-nit000-1]
+    nitiaustr  = 1         !  Timestep of start of IAU interval in [0,nitend-nit000-1]
+    nitiaufin  = 15        !  Timestep of end of IAU interval in [0,nitend-nit000-1]
+    niaufn     = 0         !  Type of IAU weighting function
+    ln_salfix  = .false.   !  Logical switch for ensuring that the sa > salfixmin
+    salfixmin  = -9999     !  Minimum salinity after applying the increments
+    nn_divdmp  = 0         !  Number of iterations of divergence damping operator
 /
diff --git a/EXP_Apr19/namelist_ref b/EXP_Apr19/namelist_ref
index d301714..377fecd 100755
--- a/EXP_Apr19/namelist_ref
+++ b/EXP_Apr19/namelist_ref
@@ -99,10 +99,8 @@
 !-----------------------------------------------------------------------
 !              !  file name                 ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                            !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_tem = './ICS/initcd_votemper.nc',      -1      ,'votemper',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-   sn_sal = './ICS/initcd_vosaline.nc',      -1      ,'vosaline',   .false.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
-
-
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1      ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1      ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
    !
    cn_dir      = './'      !  root directory for the location of the runoff files
    ln_tsd_init = .true.    !  Initialisation of ocean T & S with T & S input data (T) or not (F)
@@ -205,7 +203,7 @@
                            !  =1 levitating ice with mass and salt exchange but no presure effect
                            !  =2 embedded sea-ice (full salt and mass exchanges and pressure)
                      ! Misc. options of sbc : 
-   ln_traqsr   = .false.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+   ln_traqsr   = .true.    !  Light penetration in the ocean            (T => fill namtra_qsr)
    ln_dm2dc    = .false.   !  daily mean to diurnal cycle on short wave
    ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
    ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
@@ -219,7 +217,7 @@
    ln_sdw      = .false.   !  Read 2D Surf Stokes Drift & Computation of 3D stokes drift (T => ln_wave=.true. & fill namsbc_wave) 
    ln_tauoc    = .false.   !  Activate ocean stress modified by external wave induced stress (T => ln_wave=.true. & fill namsbc_wave)
    ln_stcor    = .false.   !  Activate Stokes Coriolis term (T => ln_wave=.true. & ln_sdw=.true. & fill namsbc_wave)
-   nn_lsm      = 1         !  =0 land/sea mask for input fields is not applied (keep empty land/sea mask filename field) ,
+   nn_lsm      = 0         !  =0 land/sea mask for input fields is not applied (keep empty land/sea mask filename field) ,
                            !  =1:n number of iterations of land/sea mask application for input fields (fill land/sea mask filename field)
 /
 !-----------------------------------------------------------------------
@@ -233,36 +231,36 @@
    sn_qsr      = 'qsr'       ,        24         , 'qsr'     , .false.      , .false., 'yearly'  , ''       , ''       , ''
    sn_emp      = 'emp'       ,        24         , 'emp'     , .false.      , .false., 'yearly'  , ''       , ''       , ''
 
-   cn_dir      = './fluxes/'      !  root directory for the location of the flux files
+   cn_dir      = './'      !  root directory for the location of the flux files
 /
 !-----------------------------------------------------------------------
 &namsbc_blk   !   namsbc_blk  generic Bulk formula                      (ln_blk = T)
 !-----------------------------------------------------------------------
 !              !  file name                   ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights                              ! rotation ! land/sea mask !
 !              !                              !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename                             ! pairing  ! filename      !
-   sn_humi=          'ERA5_SPH',                        1,            'SPH',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM' 
-   sn_prec=          'ERA5_TP',                         1,            'TP',        .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
-   sn_qlw =          'ERA5_STRD',                       1,            'STRD',      .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
-   sn_qsr=           'ERA5_SSRD',                       1,            'SSRD',      .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
-   sn_snow=          'ERA5_SF',                          1,            'SF',        .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
-   sn_tair=          'ERA5_T2M',                         1,            'T2M',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
-   sn_wndi=          'ERA5_U10',                        1,            'U10',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    'Uwnd',       'ERA5_LSM'
-   sn_wndj=          'ERA5_V10',                        1,            'V10',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    'Vwnd',       'ERA5_LSM'
-   sn_slp=           'SPH_ERA5_SP',                     1,            'SP',        .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
-!   sn_tdif=          'SPH_ERA5_D2M',                    1,            'D2M',       .true.,    .false.,   'yearly',    'weights_era5_INDIAN_bicubic.nc',    '',       'ERA5_LSM'
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,         6         , 'U_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'   , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,         6         , 'V_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'   , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,        24         , 'SWDN_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,        24         , 'LWDN_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,         6         , 'T_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,         6         , 'Q_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',        -1         , 'PRC_MOD1',   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',        -1         , 'SNOW'    ,   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,         6         , 'SLP'     ,   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
+   sn_tdif     = 'taudif_core'                ,        24         , 'taudif'  ,   .false.    , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc'  , ''       , ''
    !                    !  bulk algorithm :
-   ln_NCAR     = .true.   ! "NCAR"      algorithm   (Large and Yeager 2008)
+   ln_NCAR     = .false.   ! "NCAR"      algorithm   (Large and Yeager 2008)
    ln_COARE_3p0= .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
    ln_COARE_3p5= .false.   ! "COARE 3.5" algorithm   (Edson et al. 2013)
    ln_ECMWF    = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
    !
-   cn_dir      = './fluxes/'      !  root directory for the location of the bulk files
+   cn_dir      = './'      !  root directory for the location of the bulk files
    ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data
-   rn_zqt      = 2.       !  Air temperature and humidity reference height (m)
+   rn_zqt      = 10.       !  Air temperature and humidity reference height (m)
    rn_zu       = 10.       !  Wind vector reference height (m)
-   rn_pfac     = 1.     !  multiplicative factor for precipitation (total & snow)
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
    rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
-   rn_vfac     = 1.        !  multiplicative factor for ocean/ice velocity
+   rn_vfac     = 0.        !  multiplicative factor for ocean/ice velocity
                            !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
    ln_Cd_L12   = .false.   !  Modify the drag ice-atm and oce-atm depending on ice concentration
                            !  This parameterization is from Lupkes et al. (JGR 2012)
@@ -340,21 +338,21 @@
    rn_abs      =   0.58    !  RGB & 2 bands: fraction of light (rn_si1)
    rn_si0      =   0.35    !  RGB & 2 bands: shortess depth of extinction
    rn_si1      =   23.0    !  2 bands: longest depth of extinction
-   ln_qsr_ice  = .false.    !  light penetration for ice-model LIM3
+   ln_qsr_ice  = .true.    !  light penetration for ice-model LIM3
 /
 !-----------------------------------------------------------------------
 &namsbc_rnf    !   runoffs namelist surface boundary condition          (ln_rnf=T)
 !-----------------------------------------------------------------------
 !              !  file name           ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                      !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_rnf      = 'river_test'         ,        -1         , 'rorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
-   sn_cnf      = 'river_test'         ,         0         , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_rnf      = 'runoff_core_monthly',        -1         , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'runoff_core_monthly',         0         , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
    sn_s_rnf    = 'runoffs'            ,        24         , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
    sn_t_rnf    = 'runoffs'            ,        24         , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
    sn_dep_rnf  = 'runoffs'            ,         0         , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
 
    cn_dir      = './'      !  root directory for the location of the runoff files
-   ln_rnf_mouth= .false.    !  specific treatment at rivers mouths
+   ln_rnf_mouth= .true.    !  specific treatment at rivers mouths
       rn_hrnf     =  15.e0    !  depth over which enhanced vertical mixing is used    (ln_rnf_mouth=T)
       rn_avt_rnf  =   1.e-3   !  value of the additional vertical mixing coef. [m2/s] (ln_rnf_mouth=T)
    rn_rfact    =   1.e0    !  multiplicative factor for runoff
@@ -574,13 +572,13 @@
 !-----------------------------------------------------------------------
 !              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_ssh      = 'INDIAN_bdyT_u2d',         1        , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_u2d      = 'INDIAN_bdyU_u2d',         1        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_v2d      = 'INDIAN_bdyV_u2d',         1        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_u3d      = 'INDIAN_bdyU_u3d',         1        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_v3d      = 'INDIAN_bdyV_u3d',         1        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_tem      = 'INDIAN_bdyT_tra',         1        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_sal      = 'INDIAN_bdyT_tra',         1        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_ssh      = 'amm12_bdyT_u2d',         24        , 'sossheig',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+   bn_u2d      = 'amm12_bdyU_u2d',         24        , 'vobtcrtx',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+   bn_v2d      = 'amm12_bdyV_u2d',         24        , 'vobtcrty',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+   bn_u3d      = 'amm12_bdyU_u3d',         24        , 'vozocrtx',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+   bn_v3d      = 'amm12_bdyV_u3d',         24        , 'vomecrty',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+   bn_tem      = 'amm12_bdyT_tra',         24        , 'votemper',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
+   bn_sal      = 'amm12_bdyT_tra',         24        , 'vosaline',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 ! for lim2
 !   bn_frld    = 'amm12_bdyT_ice',         24        , 'ileadfra',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 !   bn_hicif   = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
@@ -590,7 +588,7 @@
 !   bn_ht_i    = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 !   bn_ht_s    = 'amm12_bdyT_ice',         24        , 'isnowthi',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 
-   cn_dir      = 'OBC/' !  root directory for the location of the bulk files
+   cn_dir      = 'bdydta/' !  root directory for the location of the bulk files
    ln_full_vel = .false.   !  
 /
 !-----------------------------------------------------------------------
@@ -698,7 +696,7 @@
       ln_mus_ups = .false.       !  use upstream scheme near river mouths
    ln_traadv_ubs = .false. !  UBS scheme
       nn_ubs_v   =  2            !  =2  , vertical 2nd order FCT / COMPACT 4th order
-   ln_traadv_qck = .true. !  QUICKEST scheme
+   ln_traadv_qck = .false. !  QUICKEST scheme
 /
 !-----------------------------------------------------------------------
 &namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param) (default: NO)
@@ -763,7 +761,7 @@
 !-----------------------------------------------------------------------
 &namtra_dmp    !   tracer: T & S newtonian damping                      (default: NO)
 !-----------------------------------------------------------------------
-   ln_tradmp   =  .false.   !  add a damping termn (T) or not (F)
+   ln_tradmp   =  .true.   !  add a damping termn (T) or not (F)
    nn_zdmp     =    0      !  vertical   shape =0    damping throughout the water column
                            !                   =1 no damping in the mixing layer (kz  criteria)
                            !                   =2 no damping in the mixed  layer (rho crieria)
-- 
GitLab


From 08427789568cbfb244aaf81d463b498dabbb3c61 Mon Sep 17 00:00:00 2001
From: jpolton <jpolton@gmail.com>
Date: Mon, 20 May 2019 09:39:11 +0100
Subject: [PATCH 09/18] Update README.md

---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index c38be18..9c0b13e 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 # NEMO_cfgs
 NEMO BoBEAS configuration
 
+** IN ORDER TO FINISH THE DELIVERABLES I AM RESTRUCTING THIS REPO. SO THIS IS W.I.P**
+
 Each configuration directory should be laid out in the following manner, to
 facilitate configuration archival and sharing:
 
-- 
GitLab


From a2ababff7e92b0ea051be3a0454937d1f4681f25 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Tue, 21 May 2019 15:21:49 +0100
Subject: [PATCH 10/18] try non penetrative convection for IC stability

---
 EXP_Apr19/namelist_cfg | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index c4dd9da..3f2a604 100644
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -42,7 +42,7 @@
       cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
       cn_ocerst_outdir= "./restarts"         !  directory in which to write output ocean restarts
    ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
-   nn_istate   =       0   !  output the initial state (1) or not (0)
+   nn_istate   =       1   !  output the initial state (1) or not (0)
    ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
    nn_stock    =   10 !43200 ! 14400   !  frequency of creation of a restart file (modulo referenced to 1)
    nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
@@ -129,10 +129,10 @@
 !-----------------------------------------------------------------------
 !              !  file name                 ! frequency (hours) ! variable ! time interp.!  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                            !  (if <0  months)  !   name   !  (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
-   sn_tem  = 'initcd_votemper',         -1        ,'votemper' ,    .false.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
-   sn_sal  = 'initcd_vosaline',         -1        ,'vosaline' ,    .false.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
-   !sn_dep = 'initcd_depth.nc'   ,      -12        ,'gdept_4D',   .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
-   !sn_msk = 'initcd_mask.nc',    -12        ,'mask',       .false.   , .true. , 'yearly'   , ''  ,    ''    ,      ''
+   sn_tem  = 'initcd_votemper',         -12       ,'votemper' ,    .false.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
+   sn_sal  = 'initcd_vosaline',         -12       ,'vosaline' ,    .false.    , .true. , 'yearly'   , ''       ,   ''    ,    ''
+   sn_dep = 'initcd_depth.nc'   ,      -12       ,'gdept_4D',     .false.    , .true. , 'yearly'   , ''  ,    ''    ,      ''
+   sn_msk = 'initcd_mask.nc',          -12       ,'mask',         .false.    , .true. , 'yearly'   , ''  ,    ''    ,      ''
    !
    cn_dir        = './ICS/'     !  root directory for the location of the runoff files
    ln_tsd_init   = .true.   !  Initialisation of ocean T & S with T &S input data (T) or not (F)
@@ -606,7 +606,7 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
     ln_dyn3d_dmp  =.false.                !  open boundary condition for baroclinic velocities
     rn_time_dmp   =  1.                   ! Damping time scale in days
     rn_time_dmp_out =  1.                 ! Outflow damping time scale
-    nn_rimwidth   = 9                    !  width of the relaxation zone
+    nn_rimwidth   = 1                    !  width of the relaxation zone
     ln_vol        = .false.               !  total volume correction (see nn_volctl parameter)
     nn_volctl     = 1                     !  = 0, the total water flux across open boundaries is zero
     nb_jpk_bdy    = 75                    ! number of levels in the bdy data (set < 0 if consistent with planned run)
@@ -710,8 +710,8 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
 !-----------------------------------------------------------------------
 &nameos        !   ocean physical parameters
 !-----------------------------------------------------------------------
-   ln_teos10   = .false.         !  = Use TEOS-10 equation of state
-   ln_eos80    = .true.         !  = Use EOS80 equation of state
+   ln_teos10   = .true.         !  = Use TEOS-10 equation of state
+   ln_eos80    = .false.         !  = Use EOS80 equation of state
    ln_seos     = .false.         !  = Use simplified equation of state (S-EOS)
                                  !
    !                     ! S-EOS coefficients (ln_seos=T):
@@ -933,7 +933,7 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
    ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
       nn_evdm     =    0        ! evd apply on tracer (=0) or on tracer and momentum (=1)
       rn_avevd    =  100.       !  evd mixing coefficient [m2/s]
-   ln_zdfnpc   = .false.   !  Non-Penetrative Convective algorithm (T) or not (F)
+   ln_zdfnpc   = .true.   !  Non-Penetrative Convective algorithm (T) or not (F)
       nn_npc      =    1        ! frequency of application of npc
       nn_npcp     =  365        ! npc control print frequency
    ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
-- 
GitLab


From 7c824b4165f409d1e3ae23f8535e9f959bd90548 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Tue, 21 May 2019 18:54:59 +0100
Subject: [PATCH 11/18] switch off conflicting zdf enhanced mixing

---
 EXP_Apr19/namelist_cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index 3f2a604..2f7fb25 100644
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -930,7 +930,7 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
    rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
    nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
-   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   ln_zdfevd   = .false.    !  enhanced vertical diffusion (evd) (T) or not (F)
       nn_evdm     =    0        ! evd apply on tracer (=0) or on tracer and momentum (=1)
       rn_avevd    =  100.       !  evd mixing coefficient [m2/s]
    ln_zdfnpc   = .true.   !  Non-Penetrative Convective algorithm (T) or not (F)
-- 
GitLab


From bac128c52e2306ac6d45f7dfe8546fb3254ddbbd Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Tue, 21 May 2019 18:58:14 +0100
Subject: [PATCH 12/18] Add better (slower) error reporting

---
 MY_SRC/stpctl.F90                             | 189 ++++++++++++++++++
 .../f_files/stpctl.F90                        | 189 ++++++++++++++++++
 2 files changed, 378 insertions(+)
 create mode 100644 MY_SRC/stpctl.F90
 create mode 100644 NAMELISTS_AND_FORTRAN_FILES/f_files/stpctl.F90

diff --git a/MY_SRC/stpctl.F90 b/MY_SRC/stpctl.F90
new file mode 100644
index 0000000..ededc36
--- /dev/null
+++ b/MY_SRC/stpctl.F90
@@ -0,0 +1,189 @@
+MODULE stpctl
+   !!======================================================================
+   !!                       ***  MODULE  stpctl  ***
+   !! Ocean run control :  gross check of the ocean time stepping
+   !!======================================================================
+   !! History :  OPA  ! 1991-03  (G. Madec) Original code
+   !!            6.0  ! 1992-06  (M. Imbard)
+   !!            8.0  ! 1997-06  (A.M. Treguier)
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            2.0  ! 2009-07  (G. Madec)  Add statistic for time-spliting
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   stp_ctl      : Control the run
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE c1d             ! 1D vertical configuration
+   !
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+   USE lib_fortran     ! Fortran routines library 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC stp_ctl           ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: stpctl.F90 7852 2017-03-30 14:04:54Z cetlod $
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE stp_ctl( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE stp_ctl  ***
+      !!                     
+      !! ** Purpose :   Control the run
+      !!
+      !! ** Method  : - Save the time step in numstp
+      !!              - Print it each 50 time steps
+      !!              - Stop the run IF problem ( indic < 0 )
+      !!
+      !! ** Actions :   'time.step' file containing the last ocean time-step
+      !!                
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      INTEGER, INTENT(inout) ::   kindic   ! error indicator
+      !!
+      INTEGER  ::   ji, jj, jk             ! dummy loop indices
+      INTEGER  ::   ii, ij, ik             ! local integers
+      REAL(wp) ::   velmax2, zsmin, zssh2, zsshmax    ! local scalars
+      INTEGER, DIMENSION(3) ::   ilocu     ! 
+      INTEGER, DIMENSION(2) ::   ilocs     ! 
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'stp_ctl : time-stepping control'
+         WRITE(numout,*) '~~~~~~~'
+         ! open time.step file
+         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+      ENDIF
+      !
+      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
+      IF(lwp) REWIND( numstp )                       !  --------------------------
+      !
+      !                                              !* Test maximum of velocity 
+      !                                              !  ------------------------
+      !! velmax2 = MAXVAL( ABS( un(:,:,:) ) )                ! slower than the following loop on NEC SX5
+      velmax2 = 0.e0
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               velmax2 = MAX( velmax2,un(ji,jj,jk)**2 + vn(ji,jj,jk)**2 )
+          END DO 
+        END DO 
+      END DO        
+      IF( lk_mpp )   CALL mpp_max( velmax2 )                 ! max over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' 3d speed2 max: ', velmax2
+      !
+      IF( velmax2 > 20.e0**2 ) THEN
+         IF( lk_mpp ) THEN
+            CALL mpp_maxloc( un(:,:,:)**2+vn(:,:,:)**2,umask,velmax2,ii,ij,ik)
+         ELSE
+            ilocu = MAXLOC( un(:,:,:)**2 + vn(:,:,:)**2 )
+            ii = ilocu(1) + nimpp - 1
+            ij = ilocu(2) + njmpp - 1
+            ik = ilocu(3)
+         ENDIF
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) ' stpctl: the speed is larger than 20 m/s'
+            WRITE(numout,*) ' ====== '
+            WRITE(numout,9400) kt, velmax2, ii, ij, ik
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9400  FORMAT (' kt=',i6,' max abs(vel)**2: ',1pg11.4,', i j k: ',3i5)
+      !
+      !                                              !* Test minimum of salinity
+      !                                              !  ------------------------
+      !! zsmin = MINVAL( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )  slower than the following loop on NEC SX5
+      zsmin = 100._wp
+      DO jj = 2, jpjm1
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,tsn(ji,jj,1,jp_sal))
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_min( zsmin )                ! min over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin
+      !
+      IF( zsmin < 0.) THEN 
+         IF (lk_mpp) THEN
+            CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij )
+         ELSE
+            ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )
+            ii = ilocs(1) + nimpp - 1
+            ij = ilocs(2) + njmpp - 1
+         ENDIF
+         !
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
+            WRITE(numout,*) '======= '
+            WRITE(numout,9500) kt, zsmin, ii, ij
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5)
+      !
+      !
+      IF( lk_c1d )  RETURN          ! No log file in case of 1D vertical configuration
+
+      ! log file (ssh statistics)
+      ! --------                                   !* ssh statistics (and others...)
+      IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file)
+         CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+      ENDIF
+      !
+      zsshmax = 0.e0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 1) zsshmax = MAX( zsshmax, ABS(sshn(ji,jj)) )
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_max( zsshmax )                ! min over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' ssh max:', zsshmax
+      !
+      IF( zsshmax > 10.e0 ) THEN 
+         IF (lk_mpp) THEN
+            CALL mpp_maxloc( ABS(sshn(:,:)),tmask(:,:,1),zsshmax,ii,ij)
+         ELSE
+            ilocs = MAXLOC( ABS(sshn(:,:)) )
+            ii = ilocs(1) + nimpp - 1
+            ij = ilocs(2) + njmpp - 1
+         ENDIF
+         !
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) 'stp_ctl : the ssh is larger than 10m'
+            WRITE(numout,*) '======= '
+            WRITE(numout,9600) kt, zsshmax, ii, ij
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9600  FORMAT (' kt=',i6,' max ssh: ',1pg11.4,', i j: ',2i5)
+      !
+      zssh2 = glob_sum( sshn(:,:) * sshn(:,:) )
+      !
+      IF(lwp) WRITE(numsol,9700) kt, zssh2, velmax2, zsmin      ! ssh statistics
+      !
+9700  FORMAT(' it :', i8, ' ssh2: ', d23.16, ' vel2max: ',d23.16,' SSSmin: ',d23.16)
+      !
+   END SUBROUTINE stp_ctl
+
+   !!======================================================================
+END MODULE stpctl
diff --git a/NAMELISTS_AND_FORTRAN_FILES/f_files/stpctl.F90 b/NAMELISTS_AND_FORTRAN_FILES/f_files/stpctl.F90
new file mode 100644
index 0000000..ededc36
--- /dev/null
+++ b/NAMELISTS_AND_FORTRAN_FILES/f_files/stpctl.F90
@@ -0,0 +1,189 @@
+MODULE stpctl
+   !!======================================================================
+   !!                       ***  MODULE  stpctl  ***
+   !! Ocean run control :  gross check of the ocean time stepping
+   !!======================================================================
+   !! History :  OPA  ! 1991-03  (G. Madec) Original code
+   !!            6.0  ! 1992-06  (M. Imbard)
+   !!            8.0  ! 1997-06  (A.M. Treguier)
+   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            2.0  ! 2009-07  (G. Madec)  Add statistic for time-spliting
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   stp_ctl      : Control the run
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   USE c1d             ! 1D vertical configuration
+   !
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+   USE lib_fortran     ! Fortran routines library 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC stp_ctl           ! routine called by step.F90
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id: stpctl.F90 7852 2017-03-30 14:04:54Z cetlod $
+   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE stp_ctl( kt, kindic )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE stp_ctl  ***
+      !!                     
+      !! ** Purpose :   Control the run
+      !!
+      !! ** Method  : - Save the time step in numstp
+      !!              - Print it each 50 time steps
+      !!              - Stop the run IF problem ( indic < 0 )
+      !!
+      !! ** Actions :   'time.step' file containing the last ocean time-step
+      !!                
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      INTEGER, INTENT(inout) ::   kindic   ! error indicator
+      !!
+      INTEGER  ::   ji, jj, jk             ! dummy loop indices
+      INTEGER  ::   ii, ij, ik             ! local integers
+      REAL(wp) ::   velmax2, zsmin, zssh2, zsshmax    ! local scalars
+      INTEGER, DIMENSION(3) ::   ilocu     ! 
+      INTEGER, DIMENSION(2) ::   ilocs     ! 
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'stp_ctl : time-stepping control'
+         WRITE(numout,*) '~~~~~~~'
+         ! open time.step file
+         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+      ENDIF
+      !
+      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp
+      IF(lwp) REWIND( numstp )                       !  --------------------------
+      !
+      !                                              !* Test maximum of velocity 
+      !                                              !  ------------------------
+      !! velmax2 = MAXVAL( ABS( un(:,:,:) ) )                ! slower than the following loop on NEC SX5
+      velmax2 = 0.e0
+      DO jk = 1, jpk
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               velmax2 = MAX( velmax2,un(ji,jj,jk)**2 + vn(ji,jj,jk)**2 )
+          END DO 
+        END DO 
+      END DO        
+      IF( lk_mpp )   CALL mpp_max( velmax2 )                 ! max over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' 3d speed2 max: ', velmax2
+      !
+      IF( velmax2 > 20.e0**2 ) THEN
+         IF( lk_mpp ) THEN
+            CALL mpp_maxloc( un(:,:,:)**2+vn(:,:,:)**2,umask,velmax2,ii,ij,ik)
+         ELSE
+            ilocu = MAXLOC( un(:,:,:)**2 + vn(:,:,:)**2 )
+            ii = ilocu(1) + nimpp - 1
+            ij = ilocu(2) + njmpp - 1
+            ik = ilocu(3)
+         ENDIF
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) ' stpctl: the speed is larger than 20 m/s'
+            WRITE(numout,*) ' ====== '
+            WRITE(numout,9400) kt, velmax2, ii, ij, ik
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9400  FORMAT (' kt=',i6,' max abs(vel)**2: ',1pg11.4,', i j k: ',3i5)
+      !
+      !                                              !* Test minimum of salinity
+      !                                              !  ------------------------
+      !! zsmin = MINVAL( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )  slower than the following loop on NEC SX5
+      zsmin = 100._wp
+      DO jj = 2, jpjm1
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,tsn(ji,jj,1,jp_sal))
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_min( zsmin )                ! min over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin
+      !
+      IF( zsmin < 0.) THEN 
+         IF (lk_mpp) THEN
+            CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij )
+         ELSE
+            ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )
+            ii = ilocs(1) + nimpp - 1
+            ij = ilocs(2) + njmpp - 1
+         ENDIF
+         !
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
+            WRITE(numout,*) '======= '
+            WRITE(numout,9500) kt, zsmin, ii, ij
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5)
+      !
+      !
+      IF( lk_c1d )  RETURN          ! No log file in case of 1D vertical configuration
+
+      ! log file (ssh statistics)
+      ! --------                                   !* ssh statistics (and others...)
+      IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file)
+         CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+      ENDIF
+      !
+      zsshmax = 0.e0
+      DO jj = 1, jpj
+         DO ji = 1, jpi
+            IF( tmask(ji,jj,1) == 1) zsshmax = MAX( zsshmax, ABS(sshn(ji,jj)) )
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_max( zsshmax )                ! min over the global domain
+      !
+      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' ssh max:', zsshmax
+      !
+      IF( zsshmax > 10.e0 ) THEN 
+         IF (lk_mpp) THEN
+            CALL mpp_maxloc( ABS(sshn(:,:)),tmask(:,:,1),zsshmax,ii,ij)
+         ELSE
+            ilocs = MAXLOC( ABS(sshn(:,:)) )
+            ii = ilocs(1) + nimpp - 1
+            ij = ilocs(2) + njmpp - 1
+         ENDIF
+         !
+         IF(lwp) THEN
+            WRITE(numout,cform_err)
+            WRITE(numout,*) 'stp_ctl : the ssh is larger than 10m'
+            WRITE(numout,*) '======= '
+            WRITE(numout,9600) kt, zsshmax, ii, ij
+            WRITE(numout,*)
+            WRITE(numout,*) '          output of last fields in numwso'
+         ENDIF
+         kindic = -3
+      ENDIF
+9600  FORMAT (' kt=',i6,' max ssh: ',1pg11.4,', i j: ',2i5)
+      !
+      zssh2 = glob_sum( sshn(:,:) * sshn(:,:) )
+      !
+      IF(lwp) WRITE(numsol,9700) kt, zssh2, velmax2, zsmin      ! ssh statistics
+      !
+9700  FORMAT(' it :', i8, ' ssh2: ', d23.16, ' vel2max: ',d23.16,' SSSmin: ',d23.16)
+      !
+   END SUBROUTINE stp_ctl
+
+   !!======================================================================
+END MODULE stpctl
-- 
GitLab


From cf25d2c0f9c3daf7c71b3ece1996792b05050f1e Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Tue, 21 May 2019 20:17:32 +0100
Subject: [PATCH 13/18] attempt restart from hydrostatic ocean

---
 EXP_Apr19/namelist_cfg | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index 2f7fb25..67b108a 100644
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -26,27 +26,27 @@
 &namrun        !   parameters of the run
 !-----------------------------------------------------------------------
    cn_exp      =    "BoBEAS"  !  experience name
-   nn_it000    =  1 !  first time step
-   nn_itend    =  100 ! 10800! 259200!133920! 10800!43200 ! 10day=14400   !  last  time step (std 5475)
+   nn_it000    =  101 !  first time step
+   nn_itend    =  1440 ! 10800! 259200!133920! 10800!43200 ! 10day=14400   !  last  time step (std 5475)
    nn_date0    =  20190401   !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
    nn_time0    =       0   !  initial time of day in hhmm
    nn_leapy    =       1   !  Leap year calendar (1) or not (0)
-   ln_rstart   = .false.   !  start from rest (F) or from a restart file (T)
+   ln_rstart   = .true.   !  start from rest (F) or from a restart file (T)
        nn_euler    =  1            !  = 0 : start with forward time step if ln_rstart=T
        nn_rstctl   =  2             !  restart control ==> activated only if ln_rstart=T
       !                             !    = 0 nn_date0 read in namelist ; nn_it000 : read in namelist
       !                             !    = 1 nn_date0 read in namelist ; nn_it000 : check consistancy between namelist and restart
       !                             !    = 2 nn_date0 read in restart  ; nn_it000 : check consistancy between namelist and restart
-      cn_ocerst_in    = "__RESFILE__"   !  suffix of ocean restart name (input)
+      cn_ocerst_in    = "BoBEAS_00000100_restart"   !  suffix of ocean restart name (input)
       cn_ocerst_indir = "./restarts"         !  directory from which to read input ocean restarts
       cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
       cn_ocerst_outdir= "./restarts"         !  directory in which to write output ocean restarts
    ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
    nn_istate   =       1   !  output the initial state (1) or not (0)
    ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
-   nn_stock    =   10 !43200 ! 14400   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stock    =   144 !43200 ! 14400   !  frequency of creation of a restart file (modulo referenced to 1)
    nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
-   nn_write    =   10 ! 14400   !  frequency of write in the output file   (modulo referenced to nn_it000)
+   nn_write    =   144 ! 14400   !  frequency of write in the output file   (modulo referenced to nn_it000)
    ln_mskland  = .false.   !  mask land points in NetCDF outputs (costly: + ~15%)
    ln_cfmeta   = .false.   !  output additional data to netCDF files required for compliance with the CF metadata standard
    ln_clobber  = .true.    !  clobber (overwrite) an existing file
@@ -930,10 +930,10 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
    rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
    nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
-   ln_zdfevd   = .false.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
       nn_evdm     =    0        ! evd apply on tracer (=0) or on tracer and momentum (=1)
       rn_avevd    =  100.       !  evd mixing coefficient [m2/s]
-   ln_zdfnpc   = .true.   !  Non-Penetrative Convective algorithm (T) or not (F)
+   ln_zdfnpc   = .false.   !  Non-Penetrative Convective algorithm (T) or not (F)
       nn_npc      =    1        ! frequency of application of npc
       nn_npcp     =  365        ! npc control print frequency
    ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
-- 
GitLab


From 0cb2bd5711286a8815613616c63f052e95edfba0 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Tue, 21 May 2019 20:47:01 +0100
Subject: [PATCH 14/18] istate=0

---
 EXP_Apr19/namelist_cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index 67b108a..2763c04 100644
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -42,7 +42,7 @@
       cn_ocerst_out   = "restart"   !  suffix of ocean restart name (output)
       cn_ocerst_outdir= "./restarts"         !  directory in which to write output ocean restarts
    ln_iscpl    = .false.   !  cavity evolution forcing or coupling to ice sheet model
-   nn_istate   =       1   !  output the initial state (1) or not (0)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
    ln_rst_list = .false.   !  output restarts at list of times using nn_stocklist (T) or at set frequency with nn_stock (F)
    nn_stock    =   144 !43200 ! 14400   !  frequency of creation of a restart file (modulo referenced to 1)
    nn_stocklist = 0,0,0,0,0,0,0,0,0,0 ! List of timesteps when a restart file is to be written
-- 
GitLab


From a78669271eb730eb651b64c84c845cb3388ea872 Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Wed, 22 May 2019 11:52:43 +0100
Subject: [PATCH 15/18] switch to non-penetrative convection: zdfnpc=T

---
 EXP_Apr19/namelist_cfg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index 2763c04..efb0336 100644
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -930,10 +930,10 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
    rn_avt0     =   1.2e-5  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
    nn_avb      =    0      !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0      !  horizontal shape for avtb (=1) or not (=0)
-   ln_zdfevd   = .true.    !  enhanced vertical diffusion (evd) (T) or not (F)
+   ln_zdfevd   = .false.    !  enhanced vertical diffusion (evd) (T) or not (F)
       nn_evdm     =    0        ! evd apply on tracer (=0) or on tracer and momentum (=1)
       rn_avevd    =  100.       !  evd mixing coefficient [m2/s]
-   ln_zdfnpc   = .false.   !  Non-Penetrative Convective algorithm (T) or not (F)
+   ln_zdfnpc   = .true.   !  Non-Penetrative Convective algorithm (T) or not (F)
       nn_npc      =    1        ! frequency of application of npc
       nn_npcp     =  365        ! npc control print frequency
    ln_zdfexp   = .false.   !  time-stepping: split-explicit (T) or implicit (F) time stepping
-- 
GitLab


From cea77c6767e0078927236985861b9615df689f9f Mon Sep 17 00:00:00 2001
From: Dr Jeff Polton <jpolton@gmail.com>
Date: Wed, 22 May 2019 12:19:44 +0100
Subject: [PATCH 16/18] try openbcs

---
 EXP_Apr19/namelist_cfg | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/EXP_Apr19/namelist_cfg b/EXP_Apr19/namelist_cfg
index efb0336..2e19b48 100644
--- a/EXP_Apr19/namelist_cfg
+++ b/EXP_Apr19/namelist_cfg
@@ -585,15 +585,15 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
     ln_mask_file   = .false.              !  =T : read mask from file
     cn_mask_file   = 'bdy_mask.nc'                   !  name of mask file (if ln_mask_file=.TRUE.)
     cn_dyn2d       = 'flather'               !
-    nn_dyn2d_dta   =  2                   !  = 0, bdy data are equal to the initial state
+    nn_dyn2d_dta   =  3                   !  = 0, bdy data are equal to the initial state
                                           !  = 1, bdy data are read in 'bdydata   .nc' files
                                           !  = 2, use tidal harmonic forcing data from files
                                           !  = 3, use external data AND tidal harmonic forcing
     cn_dyn3d      =  'specified'               !
-    nn_dyn3d_dta  =  0                    !  = 0, bdy data are equal to the initial state
+    nn_dyn3d_dta  =  1                    !  = 0, bdy data are equal to the initial state
                                           !  = 1, bdy data are read in 'bdydata   .nc' files
     cn_tra        =  'frs'               !
-    nn_tra_dta    =  0                    !  = 0, bdy data are equal to the initial state
+    nn_tra_dta    =  1                    !  = 0, bdy data are equal to the initial state
                                           !  = 1, bdy data are read in 'bdydata   .nc' files
     cn_ice_lim      =  'none'             !
     nn_ice_lim_dta  =  0                  !  = 0, bdy data are equal to the initial state
@@ -606,7 +606,7 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
     ln_dyn3d_dmp  =.false.                !  open boundary condition for baroclinic velocities
     rn_time_dmp   =  1.                   ! Damping time scale in days
     rn_time_dmp_out =  1.                 ! Outflow damping time scale
-    nn_rimwidth   = 1                    !  width of the relaxation zone
+    nn_rimwidth   = 9                    !  width of the relaxation zone
     ln_vol        = .false.               !  total volume correction (see nn_volctl parameter)
     nn_volctl     = 1                     !  = 0, the total water flux across open boundaries is zero
     nb_jpk_bdy    = 75                    ! number of levels in the bdy data (set < 0 if consistent with planned run)
@@ -616,13 +616,13 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
 !-----------------------------------------------------------------------
 !              !  file name      ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
 !              !                 !  (if <0  months)  !   name    !  (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
-   bn_ssh      = 'GCOMS1k_LME_12_BLZE_bt_bdyT',24       , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_u2d      = 'GCOMS1k_LME_12_BLZE_bdyU',   24        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_v2d      = 'GCOMS1k_LME_12_BLZE_bdyV',   24        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_u3d      = 'GCOMS1k_LME_12_BLZE_bdyU'    24        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_v3d      = 'GCOMS1k_LME_12_BLZE_bdyV'    24        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_tem      = 'GCOMS1k_LME_12_BLZE_bdyT'    24        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
-   bn_sal      = 'GCOMS1k_LME_12_BLZE_bdyT'    24        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_ssh      = 'BoBEAS_bt_bdyT',24       , 'sossheig',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u2d      = 'BoBEAS_bdyU',   24        , 'vobtcrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v2d      = 'BoBEAS_bdyV',   24        , 'vobtcrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_u3d      = 'BoBEAS_bdyU'    24        , 'vozocrtx',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_v3d      = 'BoBEAS_bdyV'    24        , 'vomecrty',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_tem      = 'BoBEAS_bdyT'    24        , 'votemper',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
+   bn_sal      = 'BoBEAS_bdyT'    24        , 'vosaline',    .true.   , .false. ,  'monthly'  ,    ''    ,   ''     ,     ''
 ! for lim2
 !   bn_frld    = 'amm12_bdyT_ice',         24        , 'ileadfra',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 !   bn_hicif   = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
@@ -632,7 +632,7 @@ ln_rnf_depth_ini = .true.    !  compute depth at initialisation from runoff file
 !   bn_ht_i    = 'amm12_bdyT_ice',         24        , 'iicethic',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 !   bn_ht_s    = 'amm12_bdyT_ice',         24        , 'isnowthi',    .true.   , .false. ,  'daily'  ,    ''    ,   ''     ,     ''
 
-   cn_dir      = 'bdydta/' !  root directory for the location of the bulk files
+   cn_dir      = 'OBC/' !  root directory for the location of the bulk files
    ln_full_vel = .true.   !
 /
 !-----------------------------------------------------------------------
-- 
GitLab


From b62cfbc4e5c1c7a5901e2e80a57826d8977d6a60 Mon Sep 17 00:00:00 2001
From: jpolton <jpolton@gmail.com>
Date: Wed, 22 May 2019 13:02:26 +0100
Subject: [PATCH 17/18] Update README.md

---
 README.md | 75 +------------------------------------------------------
 1 file changed, 1 insertion(+), 74 deletions(-)

diff --git a/README.md b/README.md
index 9c0b13e..fc6fefa 100644
--- a/README.md
+++ b/README.md
@@ -8,80 +8,7 @@ facilitate configuration archival and sharing:
 
 <pre>
 BoBEAS
-|____NAMELISTS_AND_FORTRAN_FILES
-| |___INITIAL_CONDITION
-| | |____initcd_vosaline.namelist
-| | |____initcd_votemper.namelist
-| | |____namelist_reshape_bilin_initcd_vosaline
-| | |____namelist_reshape_bilin_initcd_votemper
-| | |____sosie.x
-| |
-| |___RUN_DIRECTORY
-| | |____namelist_cfg
-| | |____namelist_ref
-| |
-| |___TIDES
-| | |____inputs_dst.ncml
-| | |____inputs_src.ncml
-| | |____namelist.bdy
-| | |____run_script.pbs
-| |
-| |___f_files
-| | |____bdyini.F90
-| | |____diaharm.F90
-| | |____diaharm_fast.F90
-| | |____dommsk.F90
-| | |____dtatsd.F90
-| | |____par_oce.F90
-| | |____sbctide.F90
-| | |____step.F90
-| | |____step_oce.F90
-| | |____tide_FES14.h90
-| | |____tide_mod.F90
-| | |____tideini.F90
-| |
-| |___p_files
-| | |____scrip.patch
-| | |____scripgrid.patch
-| | |____scripinterp.patch
-| | |____scripinterp_mod.patch
-| | |____scripshape.patch
-|
-|____SCRIPTS
-| |____load_modules_1.sh
-| |____make_tools.sh
-| |____create_coordinates.sh
-| |____load_modules_2.sh
-| |____main1.sh
-| |____fix_elevation.sh
-| |____make_directories.sh
-| |____python_script.sh
-| |____python_tide.sh
-| |____scri.sh
-| |____setup_python_obc.sh
-| |____setup_python_tide.sh
-| |____interpolate_gebco.sh
-| |____make_domain_cfg.sh
-| |____make_nemo.sh
-| |____make_paths.sh
-| |____make_tides.sh
-| |____make_xios.sh
-| |____bdy_obc.m
-| |____COPERNICUS_INTERP_SSH.m
-| |____nemo_IC_temperature.m
-| |____nemo_IC_salinity.m
-| |____COPERNICUS_INTERP.m
-| |____obc_Sal.m
-| |____obc_U.m
-| |____obc_V.m
-| |____obc_Temp.m
-| |____obc_SSH.m
-| |____river_maker.m
-| |____Coast_finder.m
-| |____smooth2.m
-| |____bathymetry_fill.m
-| |____Generate_NEMO_Forcing.py
-| |____python_mask.py
 |
+|____stuff
 |____README.md
 </pre>
-- 
GitLab


From 61486f7469de2c0eda3d369467991090cc5195ff Mon Sep 17 00:00:00 2001
From: jpolton <jpolton@gmail.com>
Date: Wed, 22 May 2019 13:03:39 +0100
Subject: [PATCH 18/18] Update README.md

---
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index fc6fefa..185373a 100644
--- a/README.md
+++ b/README.md
@@ -2,6 +2,7 @@
 NEMO BoBEAS configuration
 
 ** IN ORDER TO FINISH THE DELIVERABLES I AM RESTRUCTING THIS REPO. SO THIS IS W.I.P**
+** BRANCH:ashbre contains the original structure **
 
 Each configuration directory should be laid out in the following manner, to
 facilitate configuration archival and sharing:
@@ -9,6 +10,7 @@ facilitate configuration archival and sharing:
 <pre>
 BoBEAS
 |
-|____stuff
 |____README.md
+|
+|____stuff
 </pre>
-- 
GitLab