Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/INSTALL.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/INSTALL.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/INSTALL.rst	(revision 14644)
@@ -5,5 +5,5 @@
 .. todo::
 
-
+   TBD
 
 .. contents::
@@ -122,5 +122,5 @@
 .. code:: console
 
-   $ svn co https://forge.ipsl.jussieu.fr/nemo/svn/NEMO/releases/r4.0/r4.0.4
+   $ svn co https://forge.ipsl.jussieu.fr/nemo/svn/NEMO/trunk
 
 Description of 1\ :sup:`st` level tree structure
@@ -268,3 +268,3 @@
 Once changed, one needs to recompile ``nemo`` in order for this change to be taken in account.
 Note that most NEMO configurations will need to specify the following CPP keys:
-``key_iomput`` for IOs and ``key_mpp_mpi`` for parallelism.
+``key_xios`` for IOs. MPI parallelism is activated by default. Use ``key_mpi_off`` to compile without MPI.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/README.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/README.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/README.rst	(revision 14644)
@@ -62,5 +62,5 @@
  |NEMO-OCE|   |DOI man OCE|_     |DOI qsg|
  |NEMO-ICE|   |DOI man ICE|
- |NEMO-TOP|   |DOI man TOP|
+ |NEMO-MBG|   |DOI man MBG|
 ============ ================== ===================
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 14644)
@@ -376,5 +376,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -383,5 +383,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 14644)
@@ -326,5 +326,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -332,5 +332,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 14644)
@@ -326,5 +326,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -332,5 +332,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 14644)
@@ -377,5 +377,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -383,5 +383,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_agrif key_qco
+bld::tool::fppkeys   key_si3 key_top key_xios key_agrif key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/EXPREF/namelist_cfg	(revision 14644)
@@ -369,5 +369,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -375,5 +375,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/cpp_AMM12.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/cpp_AMM12.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/cpp_AMM12.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_diainstant key_mpp_mpi key_iomput key_qco
+ bld::tool::fppkeys   key_diainstant key_xios key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/EXPREF/namelist_cfg	(revision 14644)
@@ -471,5 +471,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -477,5 +477,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,8 +51,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -74,5 +76,6 @@
       kpk = 75 
       !                             ! Set the lateral boundary condition of the global domain
-      kperio =  7                   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
+      ldIperio =  .TRUE.   ;   ldJperio = .TRUE.   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -90,6 +93,5 @@
          WRITE(numout,*) '                                               jpjglo = ', kpj
          WRITE(numout,*) '                                               jpkglo = ', kpk
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      C1D : closed basin                       jperio = ', kperio
+         WRITE(numout,*) '   '
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/cpp_C1D_PAPA.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/cpp_C1D_PAPA.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/cpp_C1D_PAPA.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_c1d key_mpp_mpi key_iomput key_linssh
+ bld::tool::fppkeys   key_c1d key_xios key_linssh
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/EXPREF/namelist_cfg	(revision 14644)
@@ -240,5 +240,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/cpp_GYRE_BFM.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/cpp_GYRE_BFM.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/cpp_GYRE_BFM.fcm	(revision 14644)
@@ -1,2 +1,2 @@
-bld::tool::fppkeys   key_top key_my_trc key_mpp_mpi key_iomput key_linssh
+bld::tool::fppkeys   key_top key_my_trc key_xios key_linssh
 inc $BFMDIR/src/nemo/bfm.fcm
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/EXPREF/namelist_cfg	(revision 14644)
@@ -229,5 +229,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -236,5 +236,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/cpp_GYRE_PISCES.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/cpp_GYRE_PISCES.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/cpp_GYRE_PISCES.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_top key_linssh key_mpp_mpi key_iomput
+bld::tool::fppkeys   key_top key_linssh key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg	(revision 14644)
@@ -422,5 +422,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -428,5 +428,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/cpp_ORCA2_ICE_ABL.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/cpp_ORCA2_ICE_ABL.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/cpp_ORCA2_ICE_ABL.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_mpp_mpi key_si3 key_iomput key_qco
+bld::tool::fppkeys key_si3 key_xios key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-pisces.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-pisces.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/file_def_nemo-pisces.xml	(revision 14644)
@@ -33,13 +33,13 @@
 
         <file id="file32" name_suffix="_ptrc_T" description="pisces sms variables" >
-          <field field_ref="DIC"      />
-          <field field_ref="Alkalini" />
-          <field field_ref="O2"       />
-          <field field_ref="PO4"      />
-          <field field_ref="Si"       />
-          <field field_ref="Fer"      />
-          <field field_ref="NCHL"     />
-          <field field_ref="DCHL"     />
-          <field field_ref="NO3"      />
+          <field field_ref="DIC"       name="DIC"      operation="average" freq_op="1mo" > @DIC_e3t / @e3t </field>
+          <field field_ref="Alkalini"  name="Alkalini" operation="average" freq_op="1mo" > @Alkalini_e3t / @e3t </field>
+          <field field_ref="O2"        name="O2"       operation="average" freq_op="1mo" > @O2_e3t / @e3t </field>
+          <field field_ref="PO4"       name="PO4"      operation="average" freq_op="1mo" > @PO4_e3t / @e3t </field>
+          <field field_ref="Si"        name="Si"       operation="average" freq_op="1mo" > @Si_e3t / @e3t </field>
+          <field field_ref="Fer"       name="Fer"      operation="average" freq_op="1mo" > @Fer_e3t / @e3t </field>
+          <field field_ref="NCHL"      name="NCHL"     operation="average" freq_op="1mo" > @NCHL_e3t / @e3t </field>
+          <field field_ref="DCHL"      name="DCHL"     operation="average" freq_op="1mo" > @DCHL_e3t / @e3t </field>
+          <field field_ref="NO3"       name="NO3"      operation="average" freq_op="1mo" > @NO3_e3t / @e3t </field>
         </file>
 
@@ -53,29 +53,29 @@
       <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."> <!-- real yearly files -->
 
-        <file id="file34" name_suffix="_ptrc_T" description="pisces sms variables" >
-          <field field_ref="DIC"      />
-          <field field_ref="Alkalini" />
-          <field field_ref="O2"       />
-          <field field_ref="CaCO3"    />
-          <field field_ref="PO4"      />
-          <field field_ref="POC"      />
-          <field field_ref="Si"       />
-          <field field_ref="PHY"      />
-          <field field_ref="ZOO"      />
-          <field field_ref="DOC"      />
-          <field field_ref="PHY2"     />
-          <field field_ref="ZOO2"     />
-          <field field_ref="DSi"      />
-          <field field_ref="Fer"      />
-          <field field_ref="BFe"      />
-          <field field_ref="GOC"      />
-          <field field_ref="SFe"      />
-          <field field_ref="DFe"      />
-          <field field_ref="GSi"      />
-          <field field_ref="NFe"      />
-          <field field_ref="NCHL"     />
-          <field field_ref="DCHL"     />
-          <field field_ref="NO3"      />
-          <field field_ref="NH4"      />
+	<file id="file34" name_suffix="_ptrc_T" description="pisces sms variables" >
+          <field field_ref="DIC"       name="DIC"      operation="average" freq_op="1y" > @DIC_e3t / @e3t </field>
+          <field field_ref="Alkalini"  name="Alkalini" operation="average" freq_op="1y" > @Alkalini_e3t / @e3t </field>
+          <field field_ref="O2"        name="O2"       operation="average" freq_op="1y" > @O2_e3t / @e3t </field>
+          <field field_ref="CaCO3"     name="CaCO3"    operation="average" freq_op="1y" > @CaCO3_e3t / @e3t </field>
+          <field field_ref="PO4"       name="PO4"      operation="average" freq_op="1y" > @PO4_e3t / @e3t </field>
+          <field field_ref="POC"       name="POC"      operation="average" freq_op="1y" > @POC_e3t / @e3t </field>
+          <field field_ref="Si"        name="Si"       operation="average" freq_op="1y" > @Si_e3t / @e3t </field>
+          <field field_ref="PHY"       name="PHY"      operation="average" freq_op="1y" > @PHY_e3t / @e3t </field>
+          <field field_ref="ZOO"       name="ZOO"      operation="average" freq_op="1y" > @ZOO_e3t / @e3t </field>
+          <field field_ref="DOC"       name="DOC"      operation="average" freq_op="1y" > @DOC_e3t / @e3t </field>
+          <field field_ref="PHY2"      name="PHY2"     operation="average" freq_op="1y" > @PHY2_e3t / @e3t </field>
+          <field field_ref="ZOO2"      name="ZOO2"     operation="average" freq_op="1y" > @ZOO2_e3t / @e3t </field>
+          <field field_ref="DSi"       name="DSi"      operation="average" freq_op="1y" > @DSi_e3t / @e3t </field>
+          <field field_ref="Fer"       name="Fer"      operation="average" freq_op="1y" > @Fer_e3t / @e3t </field>
+          <field field_ref="BFe"       name="BFe"      operation="average" freq_op="1y" > @BFe_e3t / @e3t </field>
+          <field field_ref="GOC"       name="GOC"      operation="average" freq_op="1y" > @GOC_e3t / @e3t </field>
+          <field field_ref="SFe"       name="SFe"      operation="average" freq_op="1y" > @SFe_e3t / @e3t </field>
+          <field field_ref="DFe"       name="DFe"      operation="average" freq_op="1y" > @DFe_e3t / @e3t </field>
+          <field field_ref="GSi"       name="GSi"      operation="average" freq_op="1y" > @GSi_e3t / @e3t </field>
+          <field field_ref="NFe"       name="NFe"      operation="average" freq_op="1y" > @NFe_e3t / @e3t </field>
+          <field field_ref="NCHL"      name="NCHL"     operation="average" freq_op="1y" > @NCHL_e3t / @e3t </field>
+          <field field_ref="DCHL"      name="DCHL"     operation="average" freq_op="1y" > @DCHL_e3t / @e3t </field>
+          <field field_ref="NO3"       name="NO3"      operation="average" freq_op="1y" > @NO3_e3t / @e3t </field>
+          <field field_ref="NH4"       name="NH4"      operation="average" freq_op="1y" > @NH4_e3t / @e3t </field>
         </file>
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 14644)
@@ -433,5 +433,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -439,5 +439,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_top_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_top_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_top_cfg	(revision 14644)
@@ -110,8 +110,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_trcsbc(5)  = 'dust.orca.new'   ,       -1          , 'dustpo4'     ,  .true.      , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
-   sn_trcsbc(7)  = 'dust.orca.new'   ,       -1          , 'dustsi'      ,  .true.      , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
-   sn_trcsbc(14) = 'dust.orca.new'   ,       -1          , 'dustfer'     ,  .true.      , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
-   sn_trcsbc(23) = 'ndeposition.orca',      -12          , 'ndep2'       ,  .false.     , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
+   sn_trcsbc(5)  = 'dust.orca.new'   ,       -1          , 'dustpo4'     ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(7)  = 'dust.orca.new'   ,       -1          , 'dustsi'      ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(14) = 'dust.orca.new'   ,       -1          , 'dustfer'     ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(23) = 'ndeposition.orca',      -12          , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
    rn_trsfac(5)  = 8.264e-02   !  (  0.021 / 31. * 122 )
    rn_trsfac(7)  = 3.313e-01     !  ( 8.8   / 28.1 )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_qco 
+bld::tool::fppkeys   key_si3 key_top key_xios key_qco 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_cfg	(revision 14644)
@@ -313,6 +313,5 @@
    ln_dynrnf       =  .false.    !  runoffs option enabled (T) or not (F)
    ln_dynrnf_depth =  .false.    !  runoffs is spread in vertical (T) or not (F)
-!   fwbcorr        = 3.786e-06   !  annual global mean of empmr for ssh correction
-
+   !
    cn_dir      = './'      !  root directory for the ocean data location
    !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
@@ -429,5 +428,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -435,5 +434,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_top_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_top_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/EXPREF/namelist_top_cfg	(revision 14644)
@@ -110,8 +110,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_trcsbc(5)  = 'dust.orca.new'   ,       -1          , 'dustpo4'     ,  .true.      , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
-   sn_trcsbc(7)  = 'dust.orca.new'   ,       -1          , 'dustsi'      ,  .true.      , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
-   sn_trcsbc(14) = 'dust.orca.new'   ,       -1          , 'dustfer'     ,  .true.      , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
-   sn_trcsbc(23) = 'ndeposition.orca',      -12          , 'ndep2'       ,  .false.     , .true. , 'yearly'  , 'weights_2D_r360x180_bilin.nc'       , ''    , ''
+   sn_trcsbc(5)  = 'dust.orca.new'   ,       -1          , 'dustpo4'     ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(7)  = 'dust.orca.new'   ,       -1          , 'dustsi'      ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(14) = 'dust.orca.new'   ,       -1          , 'dustfer'     ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(23) = 'ndeposition.orca',      -12          , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
    rn_trsfac(5)  = 8.264e-02   !  (  0.021 / 31. * 122 )
    rn_trsfac(7)  = 3.313e-01     !  ( 8.8   / 28.1 )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/cpp_ORCA2_OFF_PISCES.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/cpp_ORCA2_OFF_PISCES.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_PISCES/cpp_ORCA2_OFF_PISCES.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_top key_iomput key_mpp_mpi
+bld::tool::fppkeys   key_top key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/context_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/context_nemo.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/context_nemo.xml	(revision 14644)
@@ -20,9 +20,10 @@
 
 <!-- Fields definition -->
-    <field_definition src="./field_def_nemo-oce.xml"/>    <!--  NEMO ocean dynamics     -->
-    <field_definition src="./field_def_nemo-innerttrc.xml"/> <!--  NEMO ocean biology      -->
+    <field_definition src="./field_def_nemo-oce.xml"/>      <!--  NEMO ocean dynamics     -->
+    <field_definition src="./field_def_nemo-pisces.xml"/>    <!--  NEMO ocean biogeochemistry     -->
+    <field_definition src="./field_def_nemo-innerttrc.xml"/> <!--  NEMO ocean passive tracers      -->
 
 <!-- Files definition -->
-    <file_definition src="./file_def_nemo-innerttrc.xml"/>  <!--  NEMO ocean biology       -->
+    <file_definition src="./file_def_nemo-innerttrc.xml"/>  <!--  NEMO ocean passive tracers       -->
 
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/field_def_nemo-pisces.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/field_def_nemo-pisces.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/field_def_nemo-pisces.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../SHARED/field_def_nemo-pisces.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/file_def_nemo-innerttrc.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/file_def_nemo-innerttrc.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/file_def_nemo-innerttrc.xml	(revision 14644)
@@ -31,11 +31,16 @@
 
       <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."> <!-- real yearly files -->
+	      
+	<file id="file1" name_suffix="grid_T" description="passive tracers variables" >
+           <field field_ref="e3t"     />
+           <field field_ref="ssh"    name="zos"  />
+         </file>
 
-        <file id="file1" name_suffix="_ptrc_T" description="passive tracers variables" >
-           <field field_ref="Age"    />
-           <field field_ref="CFC11"  />
-           <field field_ref="CFC12"  />
-           <field field_ref="SF6"    />
-           <field field_ref="RC14"   />
+	 <file id="file1" name_suffix="_trc" description="passive tracers variables" >
+           <field field_ref="Age"     name="Age"     operation="average" freq_op="1y"  > @Age_e3t / @e3t   </field>		      
+           <field field_ref="CFC11"   name="CFC11"   operation="average" freq_op="1y"  > @CFC11_e3t / @e3t </field>
+           <field field_ref="CFC12"   name="CFC12"   operation="average" freq_op="1y"  > @CFC12_e3t / @e3t </field>
+           <field field_ref="SF6"     name="SF6"     operation="average" freq_op="1y"  > @SF6_e3t / @e3t   </field>
+           <field field_ref="RC14"    name="RC14"    operation="average" freq_op="1y"  > @RC14_e3t / @e3t  </field>
          </file>
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/EXPREF/namelist_cfg	(revision 14644)
@@ -22,7 +22,7 @@
    cn_exp      =  "TRACERS"  !  experience name
    nn_it000    =       1     !  first time step
-   nn_itend    =    14600    !  last  time step (std 5475)
+   nn_itend    =    1460    !  last  time step (std 5475)
    nn_date0    =  19600101   !  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
-   nn_stock    =    14600    !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_stock    =    1460    !  frequency of creation of a restart file (modulo referenced to 1)
    ln_mskland  = .true.      !  mask land points in NetCDF outputs (costly: + ~15%)
    ln_cfmeta   = .true.      !  output additional data to netCDF files required for compliance with the CF metadata standard
@@ -32,5 +32,4 @@
 &namdom        !   time and space domain
 !-----------------------------------------------------------------------
-   ln_linssh   = .true.   !  =T  linear free surface  ==>>  model level are fixed in time
    !
    rn_Dt      = 21600.     !  time step for the dynamics and tracer
@@ -197,4 +196,5 @@
 &namdrg        !   top/bottom drag coefficient                          (default: NO selection)
 !-----------------------------------------------------------------------
+   ln_drg_OFF  = .true.   !  free-slip  
 /
 !-----------------------------------------------------------------------
@@ -308,26 +308,28 @@
 &namdta_dyn    !   offline ocean input files                            (OFF_SRC only)
 !-----------------------------------------------------------------------
-   ln_dynrnf       =  .false.    !  runoffs option enabled (T) or not (F)
+   ln_dynrnf       =  .true.    !  runoffs option enabled (T) or not (F)
    ln_dynrnf_depth =  .false.    !  runoffs is spread in vertical (T) or not (F)
-!   fwbcorr        = 3.786e-06   !  annual global mean of empmr for ssh correction
-
+   !
    cn_dir      = './'      !  root directory for the ocean data location
-   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
-   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
-   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
-   sn_tem      = 'dyna_grid_T'           ,       120.        , 'votemper'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_sal      = 'dyna_grid_T'           ,       120.        , 'vosaline'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_mld      = 'dyna_grid_T'           ,       120.        , 'somixhgt'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_emp      = 'dyna_grid_T'           ,       120.        , 'sowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_fmf      = 'dyna_grid_T'           ,       120.        , 'iowaflup'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ice      = 'dyna_grid_T'           ,       120.        , 'soicecov'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_qsr      = 'dyna_grid_T'           ,       120.        , 'soshfldo'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wnd      = 'dyna_grid_T'           ,       120.        , 'sowindsp'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_uwd      = 'dyna_grid_U'           ,       120.        , 'uocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vwd      = 'dyna_grid_V'           ,       120.        , 'vocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_wwd      = 'dyna_grid_W'           ,       120.        , 'wocetr_eff',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_avt      = 'dyna_grid_W'           ,       120.        , 'voddmavs'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_ubl      = 'dyna_grid_U'           ,       120.        , 'sobblcox'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
-   sn_vbl      = 'dyna_grid_V'           ,       120.        , 'sobblcoy'  ,  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   !___________!_________________________!___________________!_____________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name              ! frequency (hours) !   variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !     name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   sn_tem      = 'dyna_grid_T'           ,       120.        , 'thetao'    ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_sal      = 'dyna_grid_T'           ,       120.        , 'so'        ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_div      = 'dyna_grid_T'           ,       120.        , 'hdivtr'    ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_mld      = 'dyna_grid_T'           ,       120.        , 'mldr10_1'  ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_emp      = 'dyna_grid_T'           ,       120.        , 'wfo'       ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_empb     = 'dyna_grid_T'           ,       120.        , 'wfob'      ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_fmf      = 'dyna_grid_T'           ,       120.        , 'fmmflx'    ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_rnf      = 'dyna_grid_T'           ,       120.        , 'runoffs'   ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ice      = 'dyna_grid_T'           ,       120.        , 'siconc'    ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_qsr      = 'dyna_grid_T'           ,       120.        , 'rsntds'    ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wnd      = 'dyna_grid_T'           ,       120.        , 'windsp'    ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_uwd      = 'dyna_grid_U'           ,       120.        , 'uocetr_eff',    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vwd      = 'dyna_grid_V'           ,       120.        , 'vocetr_eff',    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_wwd      = 'dyna_grid_W'           ,       120.        , 'wocetr_eff',    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_avt      = 'dyna_grid_W'           ,       120.        , 'difvsolog' ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_ubl      = 'dyna_grid_U'           ,       120.        , 'ahu_bbl'   ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
+   sn_vbl      = 'dyna_grid_V'           ,       120.        , 'ahv_bbl'   ,    .true.   , .true. , 'yearly'  , ''               , ''       , ''
 /
 !!======================================================================
@@ -345,4 +347,5 @@
 &namzdf        !   vertical physics manager                             (default: NO selection)
 !-----------------------------------------------------------------------
+   ln_zdfcst   = .true.      !  constant mixing
 /
 !-----------------------------------------------------------------------
@@ -425,5 +428,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -431,5 +434,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/cpp_ORCA2_OFF_TRC.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/cpp_ORCA2_OFF_TRC.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_OFF_TRC/cpp_ORCA2_OFF_TRC.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_top key_iomput key_mpp_mpi
+bld::tool::fppkeys   key_top key_xios key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 14644)
@@ -190,5 +190,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -196,5 +196,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/cpp_ORCA2_SAS_ICE.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/cpp_ORCA2_SAS_ICE.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/cpp_ORCA2_SAS_ICE.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_si3 key_linssh key_iomput key_mpp_mpi
+ bld::tool::fppkeys   key_si3 key_linssh key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/README.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/README.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/README.rst	(revision 14644)
@@ -240,5 +240,5 @@
    The vertical eddy viscosity and diffusivity coefficients are increased to 1 m\ :sup:`2`/s in
    case of static instability.
-:time step: is 5760sec (1h36') so that there is 15 time steps in one day.
+:time step: is 5400sec (1h30') so that there is 16 time steps in one day.
 
 ORCA2_OFF_PISCES
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/README.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/README.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/README.rst	(revision 14644)
@@ -17,5 +17,5 @@
 Much more information is available from the :xios:`XIOS homepage<>` above and from the NEMO manual.
 
-Use of XIOS for diagnostics is activated using the pre-compiler key ``key_iomput``.
+Use of XIOS for diagnostics is activated using the pre-compiler key ``key_xios``.
 
 Extracting and installing XIOS
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-ice.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-ice.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-ice.xml	(revision 14644)
@@ -178,4 +178,10 @@
       <field id="hfxcndtop"    long_name="Net conductive heat flux at the ice surface (neg = ice cooling)"  standard_name="conductive_heat_flux_at_sea_ice_surface"    unit="W/m2" />
       <field id="hfxcndbot"    long_name="Net conductive heat flux at the ice bottom (neg = ice cooling)"   standard_name="conductive_heat_flux_at_sea_ice_bottom"     unit="W/m2" />
+      <!-- clem: uncomment when uncommented in iceupdate.F90 -->
+      <!--
+      <field id="hfxmelt"      long_name="Melt heat flux at the ice surface"       unit="W/m2" />
+      <field id="hfxldmelt"    long_name="Heat flux in the lead for ice melting"   unit="W/m2" />
+      <field id="hfxldgrow"    long_name="Heat flux in the lead for ice growth"    unit="W/m2" />
+      -->
 
       <!-- diags -->
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-innerttrc.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-innerttrc.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-innerttrc.xml	(revision 14644)
@@ -43,6 +43,6 @@
     <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 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 id="AtmCO2"       long_name="Global atmospheric CO2"                   unit="ppm"      />
     <field id="AtmC14"       long_name="Global atmospheric DeltaC14"              unit="permil"   />
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-oce.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-oce.xml	(revision 14644)
@@ -183,4 +183,5 @@
     <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" />
+    <field id="saltc2"       long_name="Salt content vertically integrated"                                                                                                                   unit="1e-3*kg/m2" > saltc * saltc </field >
 
     <!-- EOS -->
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-pisces.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-pisces.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-pisces.xml	(revision 14644)
@@ -166,5 +166,4 @@
     <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" />
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ice_ref
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ice_ref	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ice_ref	(revision 14644)
@@ -210,5 +210,5 @@
          rn_apnd_min =   0.15         !     minimum meltwater fraction contributing to pond growth (TOPO and LEV)
          rn_apnd_max =   0.85         !     maximum meltwater fraction contributing to pond growth (TOPO and LEV)
-         rn_pnd_flush=   0.01         !     pond flushing efficiency (tuning parameter) (LEV)
+         rn_pnd_flush=   0.1          !     pond flushing efficiency (tuning parameter) (LEV)
       ln_pnd_CST     = .false.        !  constant  melt ponds
          rn_apnd     =   0.2          !     prescribed pond fraction, at Tsu=0 degC
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ref
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ref	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ref	(revision 14644)
@@ -57,5 +57,5 @@
       !                          !    = -1 do not do any restart
    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    =       0   !  used only if key_iomput is not defined: output frequency (modulo referenced to nn_it000)
+   nn_write    =       0   !  used only if key_xios is not defined: output frequency (modulo referenced to nn_it000)
       !                          !    =  0 force to write output files only at the end of the run
       !                          !    = -1 do not do any output file
@@ -220,5 +220,5 @@
    nn_components = 0       !  configuration of the opa-sas OASIS coupling
       !                    !  =0 no opa-sas OASIS coupling: default single executable config.
-      !                    !  =1 opa-sas OASIS coupling: multi executable config., OPA component
+      !                    !  =1 opa-sas OASIS coupling: multi executable config., OCE component
       !                    !  =2 opa-sas OASIS coupling: multi executable config., SAS component
                      ! Sea-ice :
@@ -644,5 +644,5 @@
    rn_test_box             = 108.0,  116.0, -66.0, -58.0
    ln_use_calving          = .false. ! Use calving data even when nn_test_icebergs > 0
-   rn_speed_limit          = 0.      ! CFL speed limit for a berg
+   rn_speed_limit          = 0.      ! CFL speed limit for a berg (safe value is 0.4, see #2581)
    !
    ln_M2016                = .false. ! use Merino et al. (2016) modification (use of 3d ocean data instead of only sea surface data)
@@ -1092,6 +1092,5 @@
    ln_dynrnf       =  .false.    !  runoffs option enabled (T) or not (F)
    ln_dynrnf_depth =  .false.    !  runoffs is spread in vertical (T) or not (F)
-   fwbcorr         =    0.0      !  annual global mean of empmr for ssh correction
-
+   !
    cn_dir      = './'      !  root directory for the ocean data location
    !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
@@ -1485,5 +1484,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -1491,5 +1490,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    ln_listonly =  .false.  !  do nothing else than listing the best domain decompositions (with land domains suppression)
@@ -1499,4 +1498,5 @@
    jpnj        =   0       !  number of processors following j (set automatically if < 1), see also ln_listonly = T
    nn_hls      =   1       !  halo width (applies to both rows and columns)
+   nn_comm     =   1       !  comm choice
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/EXPREF/namelist_cfg	(revision 14644)
@@ -390,5 +390,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -396,5 +396,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/cpp_SPITZ12.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/cpp_SPITZ12.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/cpp_SPITZ12.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_mpp_mpi key_iomput key_si3 key_qco
+ bld::tool::fppkeys key_xios key_si3 key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/WED025/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/WED025/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/WED025/EXPREF/namelist_cfg	(revision 14644)
@@ -641,5 +641,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -647,5 +647,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/WED025/cpp_WED025.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/WED025/cpp_WED025.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/WED025/cpp_WED025.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_mpp_mpi key_iomput key_si3 key_nosignedzero
+ bld::tool::fppkeys key_xios key_si3
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/NEMO_manual_state.txt
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/NEMO_manual_state.txt	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/NEMO_manual_state.txt	(revision 14644)
@@ -15,6 +15,6 @@
 chap_misc.tex: key{mpp\_mpi} key{nosignedzero} key{vectopt\_loop} np{iom\_get} np{jpjdta} np{jpjglo} np{nn\_bench} np{nn\_bit\_cmp} np{open\_ocean\_jstart} 
 chap_LDF.tex: hf{dynldf\_cNd} hf{ldfdyn\_substitute} hf{ldftra\_substitute} hf{traldf\_c1d} hf{traldf\_cNd} key{dynldf\_c1d} key{dynldf\_c2d} key{dynldf\_c3d} key{traldf\_c1d} key{traldf\_c2d} key{traldf\_c3d} key{traldf\_cNd} key{traldf\_eiv} mdl{ldfdyn\_c2d} mdl{ldfeiv} mdl{traadv\_eiv} np{ln\_dynldf\_bilap} np{ln\_sco} np{nn\_eos} np{rn\_aeih\_0} np{rn\_aeiv} np{rn\_aeiv\_0} np{rn\_ahm0} np{rn\_ahmb0} np{rn\_aht0} np{rn\_ahtb0} np{traldf\_grif} np{traldf\_grif\_iso} rou{ldf\_dyn\_c2d\_orca} rou{ldfslp\_init} 
-chap_LBC.tex: jp{jpreci} key{mpp\_mpi} np{jperio} np{jpiglo} np{jpindt} np{jpinft} np{jpjglo} np{jpjnob} np{nbdysegn} np{nn\_bdy\_jpk} np{nn\_msh} np{nn\_tra} rou{inimpp2} 
-chap_DOM.tex: key{mpp\_mpi} ngn{namzgr} ngn{namzgr\_sco} nlst{namzgr} nlst{namzgr_sco} np{jperio} np{jpiglo} np{jpjglo} np{jpkglo} np{ln\_sco} np{ln\_sigcrit} np{ln\_s\_SF12} np{ln\_s\_SH94} np{ln\_tsd\_ini} np{ln\_zco} np{ln\_zps} np{nn\_bathy} np{nn\_msh} np{ppa0} np{ppa1} np{ppacr} np{ppdzmin} np{pphmax} np{ppkth} np{ppsur} np{rn\_alpha} np{rn\_bb} np{rn\_e3zps\_min} np{rn\_e3zps\_rat} np{rn\_hc} np{rn\_rmax} np{rn\_sbot\_max} np{rn\_sbot\_min} np{rn\_theta} np{rn\_zb\_a} np{rn\_zb\_b} np{rn\_zs} rou{istate\_t\_s} 
+chap_LBC.tex: jp{jpreci} key{mpp\_mpi} np{jpiglo} np{jpindt} np{jpinft} np{jpjglo} np{jpjnob} np{nbdysegn} np{nn\_bdy\_jpk} np{nn\_msh} np{nn\_tra} rou{inimpp2} 
+chap_DOM.tex: key{mpp\_mpi} ngn{namzgr} ngn{namzgr\_sco} nlst{namzgr} nlst{namzgr_sco} np{jpiglo} np{jpjglo} np{jpkglo} np{ln\_sco} np{ln\_sigcrit} np{ln\_s\_SF12} np{ln\_s\_SH94} np{ln\_tsd\_ini} np{ln\_zco} np{ln\_zps} np{nn\_bathy} np{nn\_msh} np{ppa0} np{ppa1} np{ppacr} np{ppdzmin} np{pphmax} np{ppkth} np{ppsur} np{rn\_alpha} np{rn\_bb} np{rn\_e3zps\_min} np{rn\_e3zps\_rat} np{rn\_hc} np{rn\_rmax} np{rn\_sbot\_max} np{rn\_sbot\_min} np{rn\_theta} np{rn\_zb\_a} np{rn\_zb\_b} np{rn\_zs} rou{istate\_t\_s} 
 chap_conservation.tex: key{\_} 
 annex_iso.tex: key{trabbl} key{traldf\_eiv} np{ln\_traldf\_eiv} np{ln\_traldf\_gdia} 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/.svnignore
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/.svnignore	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/.svnignore	(revision 14644)
@@ -9,5 +9,8 @@
 *.lo*
 *.out
+*.pdf
+*.pyg
+*.tdo
 *.toc
 *.xdv
-_minted-*
+cache*
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/NEMO_manual.ist
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/NEMO_manual.ist	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/NEMO_manual.ist	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../global/index.ist
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/abstract.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/abstract.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/abstract.tex	(revision 14644)
@@ -1,17 +1,8 @@
-%% ================================================================
-%% Abstract
-%% ================================================================
+%% =================================================================================================
+%% Specific abstract
+%% =================================================================================================
 
-%% Common part between NEMO-SI3-TOP
-\NEMO\ (``Nucleus for European Modelling of the Ocean'') is a framework of ocean-related engines.
-It is intended to be a flexible tool for studying the ocean dynamics and thermodynamics (``blue ocean''),
-as well as its interactions with the components of the Earth climate system over
-a wide range of space and time scales.
-Within \NEMO, the ocean engine is interfaced with a sea-ice model (\SIcube\ or
-\href{http://github.com/CICE-Consortium/CICE}{CICE}),
-passive tracers and biogeochemical models (\TOP) and,
-via the \href{http://portal.enes.org/oasis}{OASIS} coupler,
-with several atmospheric general circulation models.
-It also supports two-way grid embedding by means of the \href{http://agrif.imag.fr}{AGRIF} software.
+%% Common part
+\input{../../global/nemo}
 
 %% Specific part
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/appendices.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/appendices.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/appendices.tex	(revision 14644)
@@ -1,2 +1,5 @@
+%% =================================================================================================
+%% Appendices
+%% =================================================================================================
 
 \subfile{../subfiles/apdx_s_coord}      %% A. Generalised vertical coordinate
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/authors.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/authors.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/authors.tex	(revision 14644)
@@ -1,34 +1,9 @@
-%Romain Bourdall\'{e}-Badie
-%\orcid{0000-0002-8742-3289} \\
-%Mike Bell                   \\
-%J\'{e}r\^{o}me Chanut       \\
-%Emanuela Clementi
-%\orcid{0000-0002-5752-1849} \\
-%Andrew Coward
-%\orcid{0000-0002-0456-129X} \\
-%Massimiliano Drudi
-%\orcid{0000-0002-9951-740X} \\
-%Christian \'{E}th\'{e}      \\
-%Doroteaciro Iovino
-%\orcid{0000-0001-5132-7255} \\
-%Dan Lea                     \\
-%Claire L\'{e}vy
-%\orcid{0000-0003-2518-6692} \\
-%Gurvan Madec
-%\orcid{0000-0002-6447-4198} \\
-%Nicolas Martin              \\
-%S\'{e}bastien Masson
-%\orcid{0000-0002-1694-8117} \\
-%Pierre Mathiot              \\
-%Silvia Mocavero
-%\orcid{0000-0002-6309-8282} \\
-%Simon M\"{u}ller            \\
-%George Nurser               \\
-%Guillaume Samson
-%\orcid{0000-0001-7481-6369} \\
-%Dave Storkey
+%% =================================================================================================
+%% Authors
+%% =================================================================================================
 
+\orcid{0000-0002-6447-4198} Gurvan Madec                \\
+                            Mike Bell                   \\
 \orcid{0000-0002-8742-3289} Romain Bourdall\'{e}-Badie  \\
-                            Mike Bell                   \\
                             J\'{e}r\^{o}me Chanut       \\
 \orcid{0000-0002-5752-1849} Emanuela Clementi           \\
@@ -39,5 +14,4 @@
                             Dan Lea                     \\
 \orcid{0000-0003-2518-6692} Claire L\'{e}vy             \\
-\orcid{0000-0002-6447-4198} Gurvan Madec                \\
                             Nicolas Martin              \\
 \orcid{0000-0002-1694-8117} S\'{e}bastien Masson        \\
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/bibliography.bib
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/bibliography.bib	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/bibliography.bib	(revision 14644)
@@ -119,4 +119,16 @@
   issn          = "0148-0227",
   doi           = "10.1029/2001jc000922"
+}
+
+@Article{         Asaydavis2016,
+  author        = {Asay-Davis, X. S. and Cornford, S. L. and Durand, G. and Galton-Fenzi, B. K. and Gladstone, R. M. and Gudmundsson, G. H. and Hattermann, T. and Holland, D. M. and Holland, D. and Holland, P. R. and Martin, D. F. and Mathiot, P. and Pattyn, F. and Seroussi, H.},
+  title         = {Experimental design for three interrelated marine ice sheet and ocean model intercomparison projects: MISMIP v. 3 (MISMIP$+$), ISOMIP v. 2 (ISOMIP$+$) and MISOMIP v. 1 (MISOMIP1)},
+  journal       = {Geoscientific Model Development},
+  volume        = {9},
+  year          = {2016},
+  number        = {7},
+  pages         = {2471--2497},
+  url           = {https://www.geosci-model-dev.net/9/2471/2016/},
+  doi           = {10.5194/gmd-9-2471-2016}
 }
 
@@ -878,4 +890,16 @@
 }
 
+@Article{         favier2019,
+  author        = {Favier, L. and Jourdain, N. C. and Jenkins, A. and Merino, N. and Durand, G. and Gagliardini, O. and Gillet-Chaulet, F. and Mathiot, P.},
+  title         = {Assessment of sub-shelf melting parameterisations using the ocean--ice-sheet coupled model NEMO(v3.6)--Elmer/Ice(v8.3)},
+  journal       = {Geoscientific Model Development},
+  volume        = {12},
+  year          = {2019},
+  number        = {6},
+  pages         = {2255--2283},
+  url           = {https://www.geosci-model-dev.net/12/2255/2019/},
+  doi           = {10.5194/gmd-12-2255-2019}
+}
+
 @article{         flather_JPO94,
   title         = "A storm surge prediction model for the northern Bay of
@@ -1186,4 +1210,17 @@
 }
 
+@article{         grosfeld1997,
+author          = {Grosfeld, K. and Gerdes, R. and Determann, J.},
+title           = {Thermohaline circulation and interaction between ice shelf cavities and the adjacent open ocean},
+journal         = {Journal of Geophysical Research: Oceans},
+
+volume          = {102},
+number          = {C7},
+pages           = {15595-15610},
+doi             = {10.1029/97JC00891},
+url             = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/97JC00891},
+year            = {1997}
+}
+
 @article{         guilyardi.madec.ea_CD01,
   title         = "The role of lateral ocean physics in the upper ocean
@@ -1414,4 +1451,29 @@
   issn          = "0148-0227",
   doi           = "10.1029/91jc01842"
+}
+
+@article{         jenkins2001,
+  author        = {Jenkins, Adrian and Hellmer, Hartmut H. and Holland, David M.},
+  title         = {The Role of Meltwater Advection in the Formulation of Conservative Boundary Conditions at an Ice–Ocean Interface},
+  journal       = {Journal of Physical Oceanography},
+  volume        = {31},
+  number        = {1},
+  pages         = {285-296},
+  year          = {2001},
+  doi           = {10.1175/1520-0485(2001)031<0285:TROMAI>2.0.CO;2},
+  url           = {https://doi.org/10.1175/1520-0485(2001)031<0285:TROMAI>2.0.CO;2}
+}
+
+@article{         jourdain2017,
+  author        = {Jourdain, Nicolas C. and Mathiot, Pierre and Merino, Nacho and Durand, Gaël and Le Sommer, Julien and Spence, Paul and Dutrieux, Pierre and Madec, Gurvan},
+  title         = {Ocean circulation and sea-ice thinning induced by melting ice shelves in the Amundsen Sea},
+  journal       = {Journal of Geophysical Research: Oceans},
+  volume        = {122},
+  number        = {3},
+  pages         = {2550-2573},
+  keywords      = {Amundsen Sea, ice shelf, efficiency, circumpolar deep water, ocean circulation, sea ice},
+  doi           = {10.1002/2016JC012509},
+  url           = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1002/2016JC012509},
+  year          = {2017}
 }
 
@@ -2226,4 +2288,18 @@
 }
 
+@article{Merino_OM2016,
+title = "Antarctic icebergs melt over the Southern Ocean: Climatology and impact on sea ice",
+journal = "Ocean Modelling",
+volume = "104",
+pages = "99 - 110",
+year = "2016",
+issn = "1463-5003",
+doi = "https://doi.org/10.1016/j.ocemod.2016.05.001",
+url = "http://www.sciencedirect.com/science/article/pii/S1463500316300300",
+author = "Nacho Merino and Julien {Le Sommer} and Gael Durand and Nicolas C. Jourdain and Gurvan Madec and Pierre Mathiot and Jean Tournadre",
+keywords = "Icebergs, Southern Ocean, Sea ice, Freshwater fluxes",
+abstract = "Recent increase in Antarctic freshwater release to the Southern Ocean is suggested to contribute to change in water masses and sea ice. However, climate models differ in their representation of the freshwater sources. Recent improvements in altimetry-based detection of small icebergs and in estimates of the mass loss of Antarctica may help better constrain the values of Antarctic freshwater releases. We propose a model-based seasonal climatology of iceberg melt over the Southern Ocean using state-of-the-art observed glaciological estimates of the Antarctic mass loss. An improved version of a Lagrangian iceberg model is coupled with a global, eddy-permitting ocean/sea ice model and compared to small icebergs observations. Iceberg melt increases sea ice cover, about 10% in annual mean sea ice volume, and decreases sea surface temperature over most of the Southern Ocean, but with distinctive regional patterns. Our results underline the importance of improving the representation of Antarctic freshwater sources. This can be achieved by forcing ocean/sea ice models with a climatological iceberg fresh-water flux."
+}
+
 @article{         merryfield.holloway.ea_JPO99,
   title         = "A Global Ocean Model with Double-Diffusive Mixing",
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/chapters.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/chapters.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/chapters.tex	(revision 14644)
@@ -1,17 +1,21 @@
-\subfile{../subfiles/chap_model_basics}   %% 1.
-\subfile{../subfiles/chap_time_domain}    %% 2.  Time discretisation (time stepping strategy)
-\subfile{../subfiles/chap_DOM}            %% 3.  Space discretisation
-\subfile{../subfiles/chap_TRA}            %% 4.  Tracer advection/diffusion equation
-\subfile{../subfiles/chap_DYN}            %% 5.  Dynamics : momentum equation
-\subfile{../subfiles/chap_SBC}            %% 6.  Surface Boundary Conditions
-\subfile{../subfiles/chap_LBC}            %% 7.  Lateral Boundary Conditions
-\subfile{../subfiles/chap_LDF}            %% 8.  Lateral diffusion
-\subfile{../subfiles/chap_ZDF}            %% 9.  Vertical diffusion
-\subfile{../subfiles/chap_DIA}            %% 10. Outputs and Diagnostics
-\subfile{../subfiles/chap_OBS}            %% 11. Observation operator
-\subfile{../subfiles/chap_ASM}            %% 12. Assimilation increments
-\subfile{../subfiles/chap_STO}            %% 13. Stochastic param.
-\subfile{../subfiles/chap_misc}           %% 14. Miscellaneous topics
-\subfile{../subfiles/chap_cfgs}           %% 15. Predefined configurations
+%% =================================================================================================
+%% Chapters
+%% =================================================================================================
+
+\subfile{../subfiles/chap_model_basics} %% Continuous equations and assumptions
+\subfile{../subfiles/chap_time_domain}  %% Time discretisation (time stepping strategy)
+\subfile{../subfiles/chap_DOM}          %% Space discretisation
+\subfile{../subfiles/chap_TRA}          %% Tracer advection/diffusion equation
+\subfile{../subfiles/chap_DYN}          %% Dynamics : momentum equation
+\subfile{../subfiles/chap_SBC}          %% Surface Boundary Conditions
+\subfile{../subfiles/chap_LBC}          %% Lateral Boundary Conditions
+\subfile{../subfiles/chap_LDF}          %% Lateral diffusion
+\subfile{../subfiles/chap_ZDF}          %% Vertical diffusion
+\subfile{../subfiles/chap_DIA}          %% Outputs and Diagnostics
+\subfile{../subfiles/chap_OBS}          %% Observation operator
+\subfile{../subfiles/chap_ASM}          %% Assimilation increments
+\subfile{../subfiles/chap_STO}          %% Stochastic param.
+\subfile{../subfiles/chap_misc}         %% Miscellaneous topics
+\subfile{../subfiles/chap_cfgs}         %% Predefined configurations
 
 %% Not included
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/introduction.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/introduction.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/introduction.tex	(revision 14644)
@@ -1,21 +1,3 @@
-
 \chapter*{Introduction}
-
-%\chaptertoc
-
-%\paragraph{Changes record} ~\\
-
-%\thispagestyle{plain}
-
-%{\footnotesize
-%  \begin{tabularx}{\textwidth}{l||X|X}
-%    Release & Author(s) & Modifications \\
-%    \hline
-%    {\em x.x} & {\em ...} & {\em ...}   \\
-%    {\em ...} & {\em ...} & {\em ...}   \\
-%  \end{tabularx}
-%}
-
-%\clearpage
 
 The \textbf{N}ucleus for \textbf{E}uropean \textbf{M}odelling of the \textbf{O}cean (\NEMO) is
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/settings.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/settings.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/main/settings.tex	(revision 14644)
@@ -1,20 +1,18 @@
-%% Engine (subfolder name)
-\def \engine{NEMO}
+%% Engine
+\def\eng{NEMO}
 
-%% Cover page settings
-\def \spacetop{  \vspace*{1.85cm} }
-\def \heading{NEMO ocean engine}
-%\def \subheading{}
-\def \spacedown{ \vspace*{0.75cm } }
-\def \authorswidth{ 0.3\linewidth}
-\def \rulelenght{270pt}
-\def \abstractwidth{0.6\linewidth}
+%% Cover page
+\def\spcup{\vspace*{2.15cm}}
+\def\hdg{NEMO ocean engine}
+%\def\shdg{} %% No subheading
+\def\spcdn{\vspace*{1.00cm}}
+\def\autwd{0.25\linewidth}\def\lnlg{270pt}\def\abswd{0.65\linewidth}
 
-%% Manual color (frontpage banner, links  and chapter boxes)
-\def \setmanualcolor{ \definecolor{manualcolor}{cmyk}{1, .60, 0, .4} }
+%% Color in cmyk model for manual theme (frontpage banner, links and chapter boxes)
+\def\clr{1.0,0.6,0.0,0.4}
 
 %% IPSL publication number
-\def \ipslnum{27}
+\def\ipsl{27}
 
-%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
-\def \zid{1464816}
+%% Zenodo ID, i.e. doi:10.5281/zenodo.\zid
+\def\zid{1464816}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex	(revision 14644)
@@ -6,8 +6,4 @@
 \label{apdx:DOMCFG}
 
-%    {\em 4.0} & {\em Andrew Coward} & {\em Created at v4.0 from materials removed from chap\_DOM that are still relevant to the \forcode{DOMAINcfg} tool and which illustrate and explain the choices to be made by the user when setting up new domains }  \\
-
-\thispagestyle{plain}
-
 \chaptertoc
 
@@ -16,10 +12,10 @@
 {\footnotesize
   \begin{tabularx}{\textwidth}{l||X|X}
-    Release & Author(s) & Modifications \\
-    \hline
-    {\em   4.0} & {\em ...} & {\em ...} \\
-    {\em   3.6} & {\em ...} & {\em ...} \\
-    {\em   3.4} & {\em ...} & {\em ...} \\
-    {\em <=3.4} & {\em ...} & {\em ...}
+    Release     & Author(s)            & Modifications                                                 \\
+    \hline
+    {\em  next} & {\em Pierre Mathiot} & {\em Add ice shelf and closed sea option description        } \\
+    {\em   4.0} & {\em  Andrew Coward} & {\em Creation from materials removed from \autoref{chap:DOM}
+                                              that are still relevant to the DOMAINcfg tool
+                                              when setting up new domains                            }
   \end{tabularx}
 }
@@ -46,5 +42,4 @@
 
 \begin{listing}
-%  \nlst{namdom_domcfg}
   \begin{forlines}
 !-----------------------------------------------------------------------
@@ -91,5 +86,5 @@
  \item [{\np{jphgr_mesh}{jphgr\_mesh}=0}]  The most general curvilinear orthogonal grids.
   The coordinates and their first derivatives with respect to $i$ and $j$ are provided
-  in a input file (\ifile{coordinates}), read in \rou{hgr\_read} subroutine of the domhgr module.
+  in a input file (\textit{coordinates.nc}), read in \rou{hgr\_read} subroutine of the domhgr module.
   This is now the only option available within \NEMO\ itself from v4.0 onwards.
 \item [{\np{jphgr_mesh}{jphgr\_mesh}=1 to 5}] A few simple analytical grids are provided (see below).
@@ -156,6 +151,6 @@
 The reference coordinate transformation $z_0(k)$ defines the arrays $gdept_0$ and
 $gdepw_0$ for $t$- and $w$-points, respectively. See \autoref{sec:DOMCFG_sco} for the
-S-coordinate options.  As indicated on \autoref{fig:DOM_index_vert} \jp{jpk} is the number of
-$w$-levels.  $gdepw_0(1)$ is the ocean surface.  There are at most \jp{jpk}-1 $t$-points
+S-coordinate options.  As indicated on \autoref{fig:DOM_index_vert} \texttt{jpk} is the number of
+$w$-levels.  $gdepw_0(1)$ is the ocean surface.  There are at most \texttt{jpk}-1 $t$-points
 inside the ocean, the additional $t$-point at $jk = jpk$ is below the sea floor and is not
 used.  The vertical location of $w$- and $t$-levels is defined from the analytic
@@ -167,5 +162,5 @@
 
 It is possible to define a simple regular vertical grid by giving zero stretching
-(\np[=0]{ppacr}{ppacr}).  In that case, the parameters \jp{jpk} (number of $w$-levels)
+(\np[=0]{ppacr}{ppacr}).  In that case, the parameters \texttt{jpk} (number of $w$-levels)
 and \np{pphmax}{pphmax} (total ocean depth in meters) fully define the grid.
 
@@ -179,5 +174,5 @@
 \end{gather}
 
-where $k = 1$ to \jp{jpk} for $w$-levels and $k = 1$ to $k = 1$ for $t-$levels.  Such an
+where $k = 1$ to \texttt{jpk} for $w$-levels and $k = 1$ to $k = 1$ for $t-$levels.  Such an
 expression allows us to define a nearly uniform vertical location of levels at the ocean
 top and bottom with a smooth hyperbolic tangent transition in between (\autoref{fig:DOMCFG_zgr}).
@@ -227,5 +222,5 @@
 \end{equation}
 
-With the choice of the stretching $h_{cr} = 3$ and the number of levels \jp{jpk}~$= 31$,
+With the choice of the stretching $h_{cr} = 3$ and the number of levels \texttt{jpk}~$= 31$,
 the four coefficients $h_{sur}$, $h_0$, $h_1$, and $h_{th}$ in
 \autoref{eq:DOMCFG_zgr_ana_2} have been determined such that \autoref{eq:DOMCFG_zgr_coef}
@@ -245,5 +240,5 @@
   Values from $3$ to $10$ are usual.
 \item \np{ppkth}{ppkth}~$= h_{th}$: is approximately the model level at which maximum stretching occurs
-  (nondimensional, usually of order 1/2 or 2/3 of \jp{jpk})
+  (nondimensional, usually of order 1/2 or 2/3 of \texttt{jpk})
 \item \np{ppdzmin}{ppdzmin}: minimum thickness for the top layer (in meters).
 \item \np{pphmax}{pphmax}: total depth of the ocean (meters).
@@ -251,5 +246,5 @@
 
 As an example, for the $45$ layers used in the DRAKKAR configuration those parameters are:
-\jp{jpk}~$= 46$, \np{ppacr}{ppacr}~$= 9$, \np{ppkth}{ppkth}~$= 23.563$, \np{ppdzmin}{ppdzmin}~$= 6~m$,
+\texttt{jpk}~$= 46$, \np{ppacr}{ppacr}~$= 9$, \np{ppkth}{ppkth}~$= 23.563$, \np{ppdzmin}{ppdzmin}~$= 6~m$,
 \np{pphmax}{pphmax}~$= 5750~m$.
 
@@ -346,5 +341,5 @@
   This is meant for the "EEL-R5" configuration, a periodic or open boundary channel with a seamount.
 \item [{\np[=1]{nn_bathy}{nn\_bathy}}]: read a bathymetry and ice shelf draft (if needed).
-  The \ifile{bathy\_meter} file (Netcdf format) provides the ocean depth (positive, in meters) at
+  The \textit{bathy\_meter.nc} file (Netcdf format) provides the ocean depth (positive, in meters) at
   each grid point of the model grid.
   The bathymetry is usually built by interpolating a standard bathymetry product (\eg\ ETOPO2) onto
@@ -352,9 +347,4 @@
   Defining the bathymetry also defines the coastline: where the bathymetry is zero,
   no wet levels are defined (all levels are masked).
-
-  The \ifile{isfdraft\_meter} file (Netcdf format) provides the ice shelf draft (positive, in meters) at
-  each grid point of the model grid.
-  This file is only needed if \np[=.true.]{ln_isfcav}{ln\_isfcav}.
-  Defining the ice shelf draft will also define the ice shelf edge and the grounding line position.
 \end{description}
 
@@ -396,8 +386,8 @@
 bathymetry varies by less than one level thickness from one grid point to the next).  The
 reference layer thicknesses $e_{3t}^0$ have been defined in the absence of bathymetry.
-With partial steps, layers from 1 to \jp{jpk}-2 can have a thickness smaller than
+With partial steps, layers from 1 to \texttt{jpk-2} can have a thickness smaller than
 $e_{3t}(jk)$.
 
-The model deepest layer (\jp{jpk}-1) is allowed to have either a smaller or larger
+The model deepest layer (\texttt{jpk-1}) is allowed to have either a smaller or larger
 thickness than $e_{3t}(jpk)$: the maximum thickness allowed is $2*e_{3t}(jpk - 1)$.
 
@@ -418,5 +408,4 @@
 
 \begin{listing}
-%  \nlst{namzgr_sco_domcfg}
   \caption{\forcode{&namzgr_sco_domcfg}}
   \label{lst:namzgr_sco_domcfg}
@@ -592,4 +581,145 @@
 This option is described in the Report by Levier \textit{et al.} (2007), available on the \NEMO\ web site.
 
+\section{Ice shelf cavity definition}
+\label{subsec:zgrisf}
+
+  If the under ice shelf seas are opened (\np{ln_isfcav}{ln\_isfcav}), the depth of the ice shelf/ocean interface has to be include in 
+  the \textit{isfdraft\_meter} file (Netcdf format). This file need to include the \textit{isf\_draft} variable. 
+  A positive value will mean ice shelf/ocean or ice shelf bedrock interface below the reference 0m ssh. 
+  The exact shape of the ice shelf cavity (grounding line position and minimum thickness of the water column under an ice shelf, ...) can be specify in \nam{zgr_isf}{zgr\_isf}.
+
+\begin{listing}
+  \caption{\forcode{&namzgr_isf}}
+  \label{lst:namzgr_isf}
+  \begin{forlines}
+!-----------------------------------------------------------------------
+&namzgr_isf    !   isf cavity geometry definition                       (default: OFF)
+!-----------------------------------------------------------------------
+   rn_isfdep_min    = 10.         ! minimum isf draft tickness (if lower, isf draft set to this value)
+   rn_glhw_min      = 1.e-3       ! minimum water column thickness to define the grounding line
+   rn_isfhw_min     = 10          ! minimum water column thickness in the cavity once the grounding line defined.
+   ln_isfchannel    = .false.     ! remove channel (based on 2d mask build from isfdraft-bathy)
+   ln_isfconnect    = .false.     ! force connection under the ice shelf (based on 2d mask build from isfdraft-bathy)
+      nn_kisfmax       = 999         ! limiter in level on the previous condition. (if change larger than this number, get back to value before we enforce the connection)
+      rn_zisfmax       = 7000.       ! limiter in m     on the previous condition. (if change larger than this number, get back to value before we enforce the connection)
+   ln_isfcheminey   = .false.     ! close cheminey
+   ln_isfsubgl      = .false.     ! remove subglacial lake created by the remapping process
+      rn_isfsubgllon   =    0.0      !  longitude of the seed to determine the open ocean
+      rn_isfsubgllat   =    0.0      !  latitude  of the seed to determine the open ocean
+/
+  \end{forlines}
+\end{listing}
+
+   The options available to define the shape of the under ice shelf cavities are listed in \nam{zgr_isf}{zgr\_isf} (\texttt{DOMAINcfg} only, \autoref{lst:namzgr_isf}).
+
+\subsection{Model ice shelf draft definition}
+\label{subsec:zgrisf_isfd}
+
+First of all, the tool make sure, the ice shelf draft ($h_{isf}$) is sensible and compatible with the bathymetry.
+There are 3 compulsory steps to achieve this:
+
+\begin{description}
+\item{\np{rn_isfdep_min}{rn\_isfdep\_min}:} this is the minimum ice shelf draft. This is to make sure there is no ridiculous thin ice shelf. If \np{rn_isfdep_min}{rn\_isfdep\_min} is smaller than the surface level, \np{rn_isfdep_min}{rn\_isfdep\_min} is set to $e3t\_1d(1)$. 
+  Where $h_{isf} < MAX(e3t\_1d(1),rn\_isfdep\_min)$, $h_{isf}$ is set to \np{rn_isfdep_min}{rn\_isfdep\_min}.
+
+\item{\np{rn_glhw_min}{rn\_glhw\_min}:} This parameter is used to define the grounding line position.
+  Where the difference between the bathymetry and the ice shelf draft is smaller than \np{rn_glhw_min}{rn\_glhw\_min}, the cell are grounded (ie masked). 
+  This step is needed to take into account possible small mismatch between ice shelf draft value and bathymetry value (sources are coming from different grid, different data processes, rounding error, ...).
+
+\item{\np{rn_isfhw_min}{rn\_isfhw\_min}:} This parameter is the minimum water column thickness in the cavity. 
+  Where the water column thickness is lower than \np{rn_isfhw_min}{rn\_isfhw\_min}, the ice shelf draft is adjusted to match this criterion. 
+  If for any reason, this adjustement break the minimum ice shelf draft allowed (\np{rn_isfdep_min}{rn\_isfdep\_min}), the cell is masked.
+\end{description}
+
+Once all these adjustements are made, if the water column thickness contains one cell wide channels, these channels can be closed using \np{ln_isfchannel}{ln\_isfchannel}.  
+ 
+\subsection{Model top level definition}
+After the definition of the ice shelf draft, the tool defines the top level. 
+The compulsory criterion is that the water column needs at least 2 wet cells in the water column at U- and V-points.
+To do so, if there one cell wide water column, the tools adjust the ice shelf draft to fillful the requierement.\\
+
+The process is the following:
+\begin{description}
+\item{step 1:} The top level is defined in the same way as the bottom level is defined.
+\item{step 2:} The isolated grid point in the bathymetry are filled (as it is done in a domain without ice shelf)
+\item{step 3:} The tools make sure, the top level is above or equal to the bottom level
+\item{step 4:} If the water column at a U- or V- point is one wet cell wide, the ice shelf draft is adjusted. So the actual top cell become fully open and the new
+  top cell thickness is set to the minimum cell thickness allowed (following the same logic as for the bottom partial cell). This step is iterated 4 times to ensure the condition is fullfill along the 4 sides of the cell.
+\end{description}
+
+In case of steep slope and shallow water column, it likely that 2 cells are disconnected (bathymetry above its neigbourging ice shelf draft). 
+The option \np{ln_isfconnect}{ln\_isfconnect} allow the tool to force the connection between these 2 cells.
+Some limiters in meter or levels on the digging allowed by the tool are available (respectively, \np{rn_zisfmax}{rn\_zisfmax} or \np{rn_kisfmax}{rn\_kisfmax}).
+This will prevent the formation of subglacial lakes at the expense of long vertical pipe to connect cells at very different levels.
+
+\subsection{Subglacial lakes}
+Despite careful setting of your ice shelf draft and bathymetry input file as well as setting described in \autoref{subsec:zgrisf_isfd}, some situation are unavoidable.
+For exemple if you setup your ice shelf draft and bathymetry to do ocean/ice sheet coupling, 
+you may decide to fill the whole antarctic with a bathymetry and an ice shelf draft value (ice/bedrock interface depth when grounded). 
+If you do so, the subglacial lakes will show up (Vostock for example). An other possibility is with coarse vertical resolution, some ice shelves could be cut in 2 parts: 
+one connected to the main ocean and an other one closed which can be considered as a subglacial sea be the model.\\
+
+The namelist option \np{ln_isfsubgl}{ln\_isfsubgl} allow you to remove theses subglacial lakes.
+This may be useful for esthetical reason or for stability reasons:
+
+\begin{description}
+\item $\bullet$ In a subglacial lakes, in case of very weak circulation (often the case), the only heat flux is the conductive heat flux through the ice sheet. 
+  This will lead to constant freezing until water reaches -20C. 
+  This is one of the defitiency of the 3 equation melt formulation (for details on this formulation, see: \autoref{sec:isf}).
+\item $\bullet$ In case of coupling with an ice sheet model, 
+  the ssh in the subglacial lakes and the main ocean could be very different (ssh initial adjustement for example), 
+  and so if for any reason both a connected at some point, the model is likely to fall over.\\
+\end{description}
+
+\section{Closed sea definition}
+\label{sec:clocfg}
+
+\begin{listing}
+  \caption{\forcode{&namclo}}
+  \label{lst:namdom_clo}
+  \begin{forlines}
+!-----------------------------------------------------------------------
+&namclo ! (closed sea : need ln_domclo = .true. in namcfg)
+!-----------------------------------------------------------------------
+   rn_lon_opnsea = -2.0     ! longitude seed of open ocean
+   rn_lat_opnsea = -2.0     ! latitude  seed of open ocean
+   nn_closea = 8           ! number of closed seas ( = 0; only the open_sea mask will be computed)
+   !                name   ! lon_src ! lat_src ! lon_trg ! lat_trg ! river mouth area   ! net evap/precip correction scheme ! radius tgt   ! id trg
+   !                       ! (degree)! (degree)! (degree)! (degree)! local/coast/global ! (glo/rnf/emp)                     !     (m)      !
+   ! North American lakes
+   sn_lake(1) = 'superior' ,  -86.57 ,  47.30  , -66.49  , 50.45   , 'local'            , 'rnf'                             ,   550000.0 , 2    
+   sn_lake(2) = 'michigan' ,  -87.06 ,  42.74  , -66.49  , 50.45   , 'local'            , 'rnf'                             ,   550000.0 , 2    
+   sn_lake(3) = 'huron'    ,  -82.51 ,  44.74  , -66.49  , 50.45   , 'local'            , 'rnf'                             ,   550000.0 , 2    
+   sn_lake(4) = 'erie'     ,  -81.13 ,  42.25  , -66.49  , 50.45   , 'local'            , 'rnf'                             ,   550000.0 , 2    
+   sn_lake(5) = 'ontario'  ,  -77.72 ,  43.62  , -66.49  , 50.45   , 'local'            , 'rnf'                             ,   550000.0 , 2    
+   ! African Lake
+   sn_lake(6) = 'victoria' ,   32.93 ,  -1.08  ,  30.44  , 31.37   , 'coast'            , 'emp'                             ,   100000.0 , 3    
+   ! Asian Lakes
+   sn_lake(7) = 'caspian'  ,   50.0  ,  44.0   ,   0.0   ,  0.0    , 'global'           , 'glo'                             ,        0.0 , 1     
+   sn_lake(8) = 'aral'     ,   60.0  ,  45.0   ,   0.0   ,  0.0    , 'global'           , 'glo'                             ,        0.0 , 1    
+/
+   \end{forlines}
+\end{listing}
+
+The options available to define the closed seas and how closed sea net fresh water input will be redistributed by NEMO are listed in \nam{dom_clo}{dom\_clo} (\texttt{DOMAINcfg} only).
+The individual definition of each closed sea is managed by \np{sn_lake}{sn\_lake}. In this fields the user needs to define:\\
+   \begin{description}
+   \item $\bullet$    the name of the closed sea (print output purposes).
+   \item $\bullet$    the seed location to define the area of the closed sea (if seed on land because not present in this configuration, this closed sea will be ignored).\\
+   \item $\bullet$    the seed location for the target area.
+   \item $\bullet$    the type of target area ('local','coast' or 'global'). See point 6 for definition of these cases.
+   \item $\bullet$    the type of redistribution scheme for the net fresh water flux over the closed sea (as a runoff in a target area, as emp in a target area, as emp globally). For the runoff case, if the net fwf is negative, it will be redistribut globally.
+   \item $\bullet$    the radius of the target area (not used for the 'global' case). So the target defined by a 'local' target area of a radius of 100km, for example, correspond to all the wet points within this radius. The coastal case will return only the coastal point within the specifid radius.
+   \item $\bullet$    the target id. This target id is used to group multiple lakes into the same river ouflow (Great Lakes for example).
+   \end{description}
+
+The closed sea module defines a number of masks in the \textit{domain\_cfg} output:
+   \begin{description}
+   \item[\textit{mask\_opensea}:] a mask of the main ocean without all the closed seas closed. This mask is defined by a flood filling algorithm with an initial seed (localisation defined by \np{rn_lon_opnsea}{rn\_lon\_opnsea} and \np{rn_lat_opnsea}{rn\_lat\_opnsea}).
+   \item[\textit{mask\_csglo}, \textit{mask\_csrnf}, \textit{mask\_csemp}:] a mask of all the closed seas defined in the namelist by \np{sn_lake}{sn\_lake} for each redistribution scheme. The total number of defined closed seas has to be defined in \np{nn_closea}{nn\_closea}.
+   \item[\textit{mask\_csgrpglo}, \textit{mask\_csgrprnf}, \textit{mask\_csgrpemp}:] a mask of all the closed seas and targets grouped by target id for each type of redistribution scheme.
+   \item[\textit{mask\_csundef}:] a mask of all the closed sea not defined in \np{sn_lake}{sn\_lake}. This will allows NEMO to mask them if needed or to inform the user of potential minor issues in its bathymetry.
+   \end{description}
+   
 \subinc{\input{../../global/epilogue}}
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_algos.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_algos.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_algos.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Note on some algorithms}
 \label{apdx:ALGOS}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_diff_opers.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_diff_opers.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_diff_opers.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Diffusive Operators}
 \label{apdx:DIFFOPERS}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_invariants.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_invariants.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_invariants.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Discrete Invariants of the Equations}
 \label{apdx:INVARIANTS}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_s_coord.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_s_coord.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_s_coord.tex	(revision 14644)
@@ -8,6 +8,4 @@
 %    {\em 4.0} & {\em Mike Bell} & {\em review}  \\
 %    {\em 3.x} & {\em Gurvan Madec} & {\em original}  \\
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_triads.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_triads.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_triads.tex	(revision 14644)
@@ -2,19 +2,7 @@
 
 \begin{document}
-
-%% Local cmds
-\newcommand{\rML}[1][i]{\ensuremath{_{\mathrm{ML}\,#1}}}
-\newcommand{\rMLt}[1][i]{\tilde{r}_{\mathrm{ML}\,#1}}
-%% Move to ../../global/new_cmds.tex to avoid error with \listoffigures
-%\newcommand{\triad}[6][]{\ensuremath{{}_{#2}^{#3}{\mathbb{#4}_{#1}}_{#5}^{\,#6}}
-\newcommand{\triadd}[5]{\ensuremath{{}_{#1}^{#2}{\mathbb{#3}}_{#4}^{\,#5}}}
-\newcommand{\triadt}[5]{\ensuremath{{}_{#1}^{#2}{\tilde{\mathbb{#3}}}_{#4}^{\,#5}}}
-\newcommand{\rtriad}[2][]{\ensuremath{\triad[#1]{i}{k}{#2}{i_p}{k_p}}}
-\newcommand{\rtriadt}[1]{\ensuremath{\triadt{i}{k}{#1}{i_p}{k_p}}}
 
 \chapter{Iso-Neutral Diffusion and Eddy Advection using Triads}
 \label{apdx:TRIADS}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -36,5 +24,5 @@
 
 %% =================================================================================================
-\section[Choice of \forcode{namtra\_ldf} namelist parameters]{Choice of \protect\nam{tra_ldf}{tra\_ldf} namelist parameters}
+\section[Choice of \forcode{namtra_ldf} namelist parameters]{Choice of \protect\nam{tra_ldf}{tra\_ldf} namelist parameters}
 
 Two scheme are available to perform the iso-neutral diffusion.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ASM.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ASM.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ASM.tex	(revision 14644)
@@ -8,6 +8,4 @@
 %    {\em 4.0} & {\em D. J. Lea} & {\em \NEMO\ 4.0 updates}  \\
 %    {\em 3.4} & {\em D. J. Lea, M. Martin, K. Mogensen, A. Weaver} & {\em Initial version}  \\
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DIA.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DIA.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DIA.tex	(revision 14644)
@@ -11,6 +11,4 @@
 %    {\em 3.4} & {\em Gurvan Madec, Rachid Benshila, Andrew Coward } & {\em }  \\
 %    {\em }      & {\em Christian Ethe, Sebastien Masson } & {\em }  \\
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -666,5 +664,5 @@
 \end{forlines}
 
-\noindent will give the following file name radical: \ifile{myfile\_ORCA2\_19891231\_freq1d}
+\noindent will give the following file name radical: \textit{myfile\_ORCA2\_19891231\_freq1d}
 
 %% =================================================================================================
@@ -1942,9 +1940,9 @@
 When \np[=.true.]{ln_subbas}{ln\_subbas}, transports and stream function are computed for the Atlantic, Indian,
 Pacific and Indo-Pacific Oceans (defined north of 30\deg{S}) as well as for the World Ocean.
-The sub-basin decomposition requires an input file (\ifile{subbasins}) which contains three 2D mask arrays,
+The sub-basin decomposition requires an input file (\textit{subbasins}) which contains three 2D mask arrays,
 the Indo-Pacific mask been deduced from the sum of the Indian and Pacific mask (\autoref{fig:DIA_mask_subasins}).
 
 \begin{listing}
-  \nlst{namptr}
+%  \nlst{namptr}
   \caption{\forcode{&namptr}}
   \label{lst:namptr}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DIU.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DIU.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DIU.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Diurnal SST Models (DIU)}
 \label{chap:DIU}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -52,4 +50,5 @@
 
 This namelist contains only two variables:
+
 \begin{description}
 \item [{\np{ln_diurnal}{ln\_diurnal}}] A logical switch for turning on/off both the cool skin and warm layer.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DOM.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DOM.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DOM.tex	(revision 14644)
@@ -14,6 +14,4 @@
 % -    domclo: closed sea and lakes....
 %              management of closea sea area: specific to global cfg, both forced and coupled
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -368,6 +366,6 @@
 \label{subsec:DOM_size}
 
-The total size of the computational domain is set by the parameters \jp{jpiglo}, \jp{jpjglo} and
-\jp{jpkglo} for the $i$, $j$ and $k$ directions, respectively.
+The total size of the computational domain is set by the parameters \texttt{jpiglo}, \texttt{jpjglo} and
+\texttt{jpkglo} for the $i$, $j$ and $k$ directions, respectively.
 Note, that the variables \texttt{jpi} and \texttt{jpj} refer to
 the size of each processor subdomain when the code is run in parallel using domain decomposition
@@ -379,7 +377,7 @@
 in which case \np{cn_cfg}{cn\_cfg} and \np{nn_cfg}{nn\_cfg} are set from these values accordingly).
 
-The global lateral boundary condition type is selected from 8 options using parameter \jp{jperio}.
+The global lateral boundary condition type is selected from 8 options using parameters \texttt{l\_Iperio}, \texttt{l\_Jperio}, \texttt{l\_NFold} and \texttt{c\_NFtype}.
 See \autoref{sec:LBC_jperio} for details on the available options and
-the corresponding values for \jp{jperio}.
+the corresponding values for \texttt{l\_Iperio}, \texttt{l\_Jperio}, \texttt{l\_NFold} and \texttt{c\_NFtype}.
 
 %% =================================================================================================
@@ -396,10 +394,12 @@
 
 \begin{clines}
-int    jpiglo, jpjglo, jpkglo     /* global domain sizes                                    */
-int    jperio                     /* lateral global domain b.c.                             */
-double glamt, glamu, glamv, glamf /* geographic longitude (t,u,v and f points respectively) */
-double gphit, gphiu, gphiv, gphif /* geographic latitude                                    */
-double e1t, e1u, e1v, e1f         /* horizontal scale factors                               */
-double e2t, e2u, e2v, e2f         /* horizontal scale factors                               */
+integer   Ni0glo, NjOglo, jpkglo       /* global domain sizes (without MPI halos)                */
+logical   l\_Iperio, l\_Jperio         /* lateral global domain b.c.: i- j-periodicity           */
+logical   l\_NFold                     /* lateral global domain b.c.: North Pole folding         */
+char(1)   c\_NFtype                    /*    type of North pole Folding: T or F point            */
+real      glamt, glamu, glamv, glamf   /* geographic longitude (t,u,v and f points respectively) */
+real      gphit, gphiu, gphiv, gphif   /* geographic latitude                                    */
+real      e1t, e1u, e1v, e1f           /* horizontal scale factors                               */
+real      e2t, e2u, e2v, e2f           /* horizontal scale factors                               */
 \end{clines}
 
@@ -465,5 +465,5 @@
 \begin{enumerate}
 \item the bathymetry given in meters;
-\item the number of levels of the model (\jp{jpk});
+\item the number of levels of the model (\texttt{jpk});
 \item the analytical transformation $z(i,j,k)$ and the vertical scale factors
   (derivatives of the transformation); and
@@ -575,6 +575,6 @@
 every gridcell in the model regardless of the choice of vertical coordinate.
 With constant z-levels, e3 metrics will be uniform across each horizontal level.
-In the partial step case each e3 at the \jp{bottom\_level}
-(and, possibly, \jp{top\_level} if ice cavities are present)
+In the partial step case each e3 at the \texttt{bottom\_level}
+(and, possibly, \texttt{top\_level} if ice cavities are present)
 may vary from its horizontal neighbours.
 And, in s-coordinates, variations can occur throughout the water column.
@@ -585,8 +585,8 @@
 those arising from a flat sea surface with zero elevation.
 
-The \jp{bottom\_level} and \jp{top\_level} 2D arrays define
-the \jp{bottom\_level} and top wet levels in each grid column.
-Without ice cavities, \jp{top\_level} is essentially a land mask (0 on land; 1 everywhere else).
-With ice cavities, \jp{top\_level} determines the first wet point below the overlying ice shelf.
+The \texttt{bottom\_level} and \texttt{top\_level} 2D arrays define
+the \texttt{bottom\_level} and top wet levels in each grid column.
+Without ice cavities, \texttt{top\_level} is essentially a land mask (0 on land; 1 everywhere else).
+With ice cavities, \texttt{top\_level} determines the first wet point below the overlying ice shelf.
 
 %% =================================================================================================
@@ -594,5 +594,5 @@
 \label{subsec:DOM_msk}
 
-From \jp{top\_level} and \jp{bottom\_level} fields, the mask fields are defined as follows:
+From \texttt{top\_level} and \texttt{bottom\_level} fields, the mask fields are defined as follows:
 \begin{align*}
   tmask(i,j,k) &=
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DYN.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DYN.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DYN.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Ocean Dynamics (DYN)}
 \label{chap:DYN}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LBC.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LBC.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LBC.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Lateral Boundary Condition (LBC)}
 \label{chap:LBC}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -161,5 +159,5 @@
 
 %% =================================================================================================
-\section[Model domain boundary condition (\forcode{jperio})]{Model domain boundary condition (\protect\jp{jperio})}
+\section{Model domain boundary condition}
 \label{sec:LBC_jperio}
 
@@ -170,9 +168,9 @@
 
 %% =================================================================================================
-\subsection[Closed, cyclic (\forcode{=0,1,2,7})]{Closed, cyclic (\protect\jp{jperio}\forcode{=0,1,2,7})}
+\subsection{Closed, cyclic (\forcode{l_Iperio,l_jperio})}
 \label{subsec:LBC_jperio012}
 
 The choice of closed or cyclic model domain boundary condition is made by
-setting \jp{jperio} to 0, 1, 2 or 7 in namelist \nam{cfg}{cfg}.
+setting \forcode{l_Iperio,l_jperio} to true or false in namelist \nam{cfg}{cfg}.
 Each time such a boundary condition is needed, it is set by a call to routine \mdl{lbclnk}.
 The computation of momentum and tracer trends proceeds from $i=2$ to $i=jpi-1$ and from $j=2$ to $j=jpj-1$,
@@ -183,18 +181,18 @@
 \begin{description}
 
-\item [For closed boundary (\jp{jperio}\forcode{=0})], solid walls are imposed at all model boundaries:
+\item [For closed boundary (\forcode{l_Iperio = .false.,l_jperio = .false.})], solid walls are imposed at all model boundaries:
   first and last rows and columns are set to zero.
 
-\item [For cyclic east-west boundary (\jp{jperio}\forcode{=1})], first and last rows are set to zero (closed) whilst the first column is set to
+\item [For cyclic east-west boundary (\forcode{l_Iperio = .true.,l_jperio = .false.})], first and last rows are set to zero (closed) whilst the first column is set to
   the value of the last-but-one column and the last column to the value of the second one
   (\autoref{fig:LBC_jperio}-a).
   Whatever flows out of the eastern (western) end of the basin enters the western (eastern) end.
 
-\item [For cyclic north-south boundary (\jp{jperio}\forcode{=2})], first and last columns are set to zero (closed) whilst the first row is set to
+\item [For cyclic north-south boundary (\forcode{l_Iperio = .false.,l_jperio = .true.})], first and last columns are set to zero (closed) whilst the first row is set to
   the value of the last-but-one row and the last row to the value of the second one
   (\autoref{fig:LBC_jperio}-a).
   Whatever flows out of the northern (southern) end of the basin enters the southern (northern) end.
 
-\item [Bi-cyclic east-west and north-south boundary (\jp{jperio}\forcode{=7})] combines cases 1 and 2.
+\item [Bi-cyclic east-west and north-south boundary (\forcode{l_Iperio = .true.,l_jperio = .true.})] combines cases 1 and 2.
 
 \end{description}
@@ -209,5 +207,5 @@
 
 %% =================================================================================================
-\subsection[North-fold (\forcode{=3,6})]{North-fold (\protect\jp{jperio}\forcode{=3,6})}
+\subsection{North-fold (\forcode{l_NFold = .true.})}
 \label{subsec:LBC_north_fold}
 
@@ -222,5 +220,5 @@
   \includegraphics[width=0.66\textwidth]{LBC_North_Fold_T}
   \caption[North fold boundary in ORCA 2\deg, 1/4\deg and 1/12\deg]{
-    North fold boundary with a $T$-point pivot and cyclic east-west boundary condition ($jperio=4$),
+    North fold boundary with a $T$-point pivot and cyclic east-west boundary condition ($c\_NFtype='T'$),
     as used in ORCA 2\deg, 1/4\deg and 1/12\deg.
     Pink shaded area corresponds to the inner domain mask (see text).}
@@ -288,9 +286,9 @@
 Each processor is independent and without message passing or synchronous process, programs run alone and access just its own local memory.
 For this reason,
-the main model dimensions are now the local dimensions of the subdomain (pencil) that are named \jp{jpi}, \jp{jpj}, \jp{jpk}.
+the main model dimensions are now the local dimensions of the subdomain (pencil) that are named \texttt{jpi}, \texttt{jpj}, \texttt{jpk}.
 These dimensions include the internal domain and the overlapping rows.
-The number of rows to exchange (known as the halo) is usually set to one (nn\_hls=1, in \mdl{par\_oce},
+The number of rows to exchange (known as the halo) is usually set to one (\forcode{nn_hls=1}, in \mdl{par\_oce},
 and must be kept to one until further notice).
-The whole domain dimensions are named \jp{jpiglo}, \jp{jpjglo} and \jp{jpk}.
+The whole domain dimensions are named \texttt{jpiglo}, \texttt{jpjglo} and \texttt{jpk}.
 The relationship between the whole domain and a sub-domain is:
 \begin{gather*}
@@ -299,5 +297,5 @@
 \end{gather*}
 
-One also defines variables nldi and nlei which correspond to the internal domain bounds, and the variables nimpp and njmpp which are the position of the (1,1) grid-point in the global domain (\autoref{fig:LBC_mpp}). Note that since the version 4, there is no more extra-halo area as defined in \autoref{fig:LBC_mpp} so \jp{jpi} is now always equal to nlci and \jp{jpj} equal to nlcj.
+One also defines variables nldi and nlei which correspond to the internal domain bounds, and the variables nimpp and njmpp which are the position of the (1,1) grid-point in the global domain (\autoref{fig:LBC_mpp}). Note that since the version 4, there is no more extra-halo area as defined in \autoref{fig:LBC_mpp} so \texttt{jpi} is now always equal to nlci and \texttt{jpj} equal to nlcj.
 
 An element of $T_{l}$, a local array (subdomain) corresponds to an element of $T_{g}$,
@@ -309,5 +307,5 @@
 with $1 \leq i \leq jpi$, $1  \leq j \leq jpj $ , and  $1  \leq k \leq jpk$.
 
-The 1-d arrays $mig(1:\jp{jpi})$ and $mjg(1:\jp{jpj})$, defined in \rou{dom\_glo} routine (\mdl{domain} module), should be used to get global domain indices from local domain indices. The 1-d arrays, $mi0(1:\jp{jpiglo})$, $mi1(1:\jp{jpiglo})$ and $mj0(1:\jp{jpjglo})$, $mj1(1:\jp{jpjglo})$ have the reverse purpose and should be used to define loop indices expressed in global domain indices (see examples in \mdl{dtastd} module).\\
+The 1-d arrays $mig(1:\texttt{jpi})$ and $mjg(1:\texttt{jpj})$, defined in \rou{dom\_glo} routine (\mdl{domain} module), should be used to get global domain indices from local domain indices. The 1-d arrays, $mi0(1:\texttt{jpiglo})$, $mi1(1:\texttt{jpiglo})$ and $mj0(1:\texttt{jpjglo})$, $mj1(1:\texttt{jpjglo})$ have the reverse purpose and should be used to define loop indices expressed in global domain indices (see examples in \mdl{dtastd} module).\\
 
 The \NEMO\ model computes equation terms with the help of mask arrays (0 on land points and 1 on sea points). It is therefore possible that an MPI subdomain contains only land points. To save ressources, we try to supress from the computational domain as much land subdomains as possible. For example if $N_{mpi}$ processes are allocated to NEMO, the domain decomposition will be given by the following equation:
@@ -372,6 +370,6 @@
 The number of boundary sets is defined by \np{nb_bdy}{nb\_bdy}.
 Each boundary set can be either defined as a series of straight line segments directly in the namelist
-(\np[=.false.]{ln_coords_file}{ln\_coords\_file}, and a namelist block \forcode{&nambdy_index} must be included for each set) or read in from a file (\np[=.true.]{ln_coords_file}{ln\_coords\_file}, and a ``\ifile{coordinates.bdy}'' file must be provided).
-The coordinates.bdy file is analagous to the usual \NEMO\ ``\ifile{coordinates}'' file.
+(\np[=.false.]{ln_coords_file}{ln\_coords\_file}, and a namelist block \forcode{&nambdy_index} must be included for each set) or read in from a file (\np[=.true.]{ln_coords_file}{ln\_coords\_file}, and a ``\textit{coordinates.bdy.nc}'' file must be provided).
+The coordinates.bdy file is analagous to the usual \NEMO\ ``\textit{coordinates.nc}'' file.
 In the example above, there are two boundary sets, the first of which is defined via a file and
 the second is defined in the namelist.
@@ -570,14 +568,14 @@
 
 The boundary geometry for each set may be defined in a namelist \forcode{&nambdy_index} or
-by reading in a ``\ifile{coordinates.bdy}'' file.
-The \texttt{nambdy\_index} namelist defines a series of straight-line segments for north, east, south and west boundaries.
-One \texttt{nambdy\_index} namelist block is needed for each boundary condition defined by indexes.
+by reading in a ``\textit{coordinates.bdy.nc}'' file.
+The \forcode{&nambdy_index} namelist defines a series of straight-line segments for north, east, south and west boundaries.
+One \forcode{&nambdy_index} namelist block is needed for each boundary condition defined by indexes.
 For the northern boundary, \texttt{nbdysegn} gives the number of segments,
-\jp{jpjnob} gives the $j$ index for each segment and \jp{jpindt} and
-\jp{jpinft} give the start and end $i$ indices for each segment with similar for the other boundaries.
+\texttt{jpjnob} gives the $j$ index for each segment and \texttt{jpindt} and
+\texttt{jpinft} give the start and end $i$ indices for each segment with similar for the other boundaries.
 These segments define a list of $T$ grid points along the outermost row of the boundary ($nbr\,=\, 1$).
 The code deduces the $U$ and $V$ points and also the points for $nbr\,>\, 1$ if \np[>1]{nn_rimwidth}{nn\_rimwidth}.
 
-The boundary geometry may also be defined from a ``\ifile{coordinates.bdy}'' file.
+The boundary geometry may also be defined from a ``\textit{coordinates.bdy.nc}'' file.
 \autoref{fig:LBC_nc_header} gives an example of the header information from such a file, based on the description of geometrical setup given above.
 The file should contain the index arrays for each of the $T$, $U$ and $V$ grids.
@@ -633,6 +631,6 @@
   \centering
   \includegraphics[width=0.66\textwidth]{LBC_nc_header}
-  \caption[Header for a \protect\ifile{coordinates.bdy} file]{
-    Example of the header for a \protect\ifile{coordinates.bdy} file}
+  \caption[Header for a \textit{coordinates.bdy.nc} file]{
+    Example of the header for a \textit{coordinates.bdy.nc} file}
   \label{fig:LBC_nc_header}
 \end{figure}
@@ -684,15 +682,15 @@
 \texttt{<constituent>\_z1} and \texttt{<constituent>\_z2} for the real and imaginary parts of
 SSH, respectively, are expected to be available in file
-\ifile{<input>\_grid\_T}, variables \texttt{<constituent>\_u1} and
+\textit{<input>\_grid\_T.nc}, variables \texttt{<constituent>\_u1} and
 \texttt{<constituent>\_u2} for the real and imaginary parts of u, respectively, in file
-\ifile{<input>\_grid\_U}, and \texttt{<constituent>\_v1} and
+\textit{<input>\_grid\_U.nc}, and \texttt{<constituent>\_v1} and
 \texttt{<constituent>\_v2} for the real and imaginary parts of v, respectively, in file
-\ifile{<input>\_grid\_V}; when data along open boundary segments is used,
+\textit{<input>\_grid\_V.nc}; when data along open boundary segments is used,
 variables \texttt{z1} and \texttt{z2} (real and imaginary part of SSH) are
-expected to be available in file \ifile{<input><constituent>\_grid\_T},
+expected to be available in file \textit{<input><constituent>\_grid\_T.nc},
 variables \texttt{u1} and \texttt{u2} (real and imaginary part of u) in file
-\ifile{<input><constituent>\_grid\_U}, and variables \texttt{v1} and \texttt{v2}
+\textit{<input><constituent>\_grid\_U.nc}, and variables \texttt{v1} and \texttt{v2}
 (real and imaginary part of v) in file
-\ifile{<input><constituent>\_grid\_V}.\par
+\textit{<input><constituent>\_grid\_V.nc}.\par
 
 Note that the barotropic velocity components are assumed to be defined
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LDF.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LDF.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LDF.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Lateral Ocean Physics (LDF)}
 \label{chap:LDF}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_OBS.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_OBS.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_OBS.tex	(revision 14644)
@@ -14,6 +14,4 @@
 %    {\em --\texttt{"}--} & {\em ... K. Mogensen, A. Vidard, A. Weaver} & {\em ---\texttt{"}---}  \\
 %\end{tabular}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -420,5 +418,5 @@
 
 To use Sea Level Anomaly (SLA) data the mean dynamic topography (MDT) must be provided in a separate file defined on
-the model grid called \ifile{slaReferenceLevel}.
+the model grid called \textit{slaReferenceLevel.nc}.
 The MDT is required in order to produce the model equivalent sea level anomaly from the model sea surface height.
 Below is an example header for this file (on the ORCA025 grid).
@@ -915,5 +913,4 @@
 
 \begin{listing}
-%  \nlst{namsao}
   \begin{forlines}
 !----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_SBC.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Surface Boundary Condition (SBC, SAS, ISF, ICB, TDE)}
 \label{chap:SBC}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -17,4 +15,5 @@
     \hline
     {\em  next} & {\em Simon M{\" u}ller} & {\em Update of \autoref{sec:SBC_TDE}; revision of \autoref{subsec:SBC_fwb}}\\[2mm]
+    {\em  next} & {\em Pierre Mathiot} & {\em update of the ice shelf section (2019 developments)}\\[2mm]  
     {\em   4.0} & {\em ...} & {\em ...} \\
     {\em   3.6} & {\em ...} & {\em ...} \\
@@ -74,6 +73,4 @@
   (\np[=0..3]{nn_ice}{nn\_ice}),
 \item the addition of river runoffs as surface freshwater fluxes or lateral inflow (\np[=.true.]{ln_rnf}{ln\_rnf}),
-\item the addition of ice-shelf melting as lateral inflow (parameterisation) or
-  as fluxes applied at the land-ice ocean interface (\np[=.true.]{ln_isf}{ln\_isf}),
 \item the addition of a freshwater flux adjustment in order to avoid a mean sea-level drift
   (\np[=0..2]{nn_fwb}{nn\_fwb}),
@@ -99,6 +96,4 @@
 One of these is modification by icebergs (see \autoref{sec:SBC_ICB_icebergs}),
 which act as drifting sources of fresh water.
-Another example of modification is that due to the ice shelf melting/freezing (see \autoref{sec:SBC_isf}),
-which provides additional sources of fresh water.
 
 %% =================================================================================================
@@ -646,6 +641,6 @@
 parameters. It is therefore recommended to chose version 3.6 over 3.
 
-\subsection{Cool-skin and warm-layer parametrizations}
-%\subsection[Cool-skin and warm-layer parameterizations (\forcode{ln_skin_cs} \& \forcode{ln_skin_wl})]{Cool-skin and warm-layer parameterizations (\protect\np{ln_skin_cs}{ln\_skin\_cs} \& \np{ln_skin_wl}{ln\_skin\_wl})}
+\subsection[Cool-skin and warm-layer parameterizations (   \forcode{ln_skin_cs}               \& \forcode{ln_skin_wl}              )]
+           {Cool-skin and warm-layer parameterizations (\protect\np{ln_skin_cs}{ln\_skin\_cs} \&      \np{ln_skin_wl}{ln\_skin\_wl})}
 \label{subsec:SBC_skin}
 
@@ -979,9 +974,9 @@
   ocean tide model}: Mf, Mm, Ssa, Mtm, Msf, Msqm, Sa, K1, O1, P1, Q1, J1, S1,
 M2, S2, N2, K2, nu2, mu2, 2N2, L2, T2, eps2, lam2, R2, M3, MKS2, MN4, MS4, M4,
-N4, S4, M6, and M8; see file \hf{tide} and \mdl{tide\_mod} for further
-information and references\footnote{As a legacy option \np{ln_tide_var} can be
+N4, S4, M6, and M8; see file \textit{tide.h90} and \mdl{tide\_mod} for further
+information and references\footnote{As a legacy option \np{ln_tide_var}{ln\_tide\_var} can be
   set to \forcode{0}, in which case the 19 tidal constituents (M2, N2, 2N2, S2,
   K2, K1, O1, Q1, P1, M4, Mf, Mm, Msqm, Mtm, S1, MU2, NU2, L2, and T2; see file
-  \hf{tide}) and associated parameters that have been available in NEMO version
+  \textit{tide.h90}) and associated parameters that have been available in NEMO version
   4.0 and earlier are available}. Constituents to be included in the tidal forcing
 (surface and lateral boundaries) are selected by enumerating their respective
@@ -1013,5 +1008,5 @@
 potential). The tidal tilt factor $\gamma = 1 + k - h$ includes the
 Love numbers $k$ and $h$ \citep{love_PRSL09}; this factor is
-configurable using \np{rn_tide_gamma} (default value 0.7). Optionally,
+configurable using \np{rn_tide_gamma}{rn\_tide\_gamma} (default value 0.7). Optionally,
 when \np[=.true.]{ln_tide_ramp}{ln\_tide\_ramp}, the equilibrium tidal
 forcing can be ramped up linearly from zero during the initial
@@ -1183,146 +1178,295 @@
 
 %% =================================================================================================
-\section[Ice shelf melting (\textit{sbcisf.F90})]{Ice shelf melting (\protect\mdl{sbcisf})}
+\section[Ice Shelf (ISF)]{Interaction with ice shelves (ISF)}
 \label{sec:SBC_isf}
 
 \begin{listing}
-  \nlst{namsbc_isf}
-  \caption{\forcode{&namsbc_isf}}
-  \label{lst:namsbc_isf}
+  \nlst{namisf}
+  \caption{\forcode{&namisf}}
+  \label{lst:namisf}
 \end{listing}
 
-The namelist variable in \nam{sbc}{sbc}, \np{nn_isf}{nn\_isf}, controls the ice shelf representation.
-Description and result of sensitivity test to \np{nn_isf}{nn\_isf} are presented in \citet{mathiot.jenkins.ea_GMD17}.
-The different options are illustrated in \autoref{fig:SBC_isf}.
-
+The namelist variable in \nam{isf}{isf}, \np{ln_isf}{ln\_isf}, controls the ice shelf interactions:
 \begin{description}
-  \item [{\np[=1]{nn_isf}{nn\_isf}}]: The ice shelf cavity is represented (\np[=.true.]{ln_isfcav}{ln\_isfcav} needed).
-  The fwf and heat flux are depending of the local water properties.
-
-  Two different bulk formulae are available:
+   \item $\bullet$ representation of the ice shelf/ocean melting/freezing for opened cavity (cav, \np{ln_isfcav_mlt}{ln\_isfcav\_mlt}).
+   \item $\bullet$ parametrisation of the ice shelf/ocean melting/freezing for closed cavities (par, \np{ln_isfpar_mlt}{ln\_isfpar\_mlt}).
+   \item $\bullet$ coupling with an ice sheet model (\np{ln_isfcpl}{ln\_isfcpl}).
+\end{description}
+
+  \subsection{Ocean/Ice shelf fluxes in opened cavities}
+
+     \np{ln_isfcav_mlt}{ln\_isfcav\_mlt}\forcode{ = .true.} activates the ocean/ice shelf thermodynamics interactions at the ice shelf/ocean interface. 
+     If \np{ln_isfcav_mlt}{ln\_isfcav\_mlt}\forcode{ = .false.}, thermodynamics interactions are desctivated but the ocean dynamics inside the cavity is still active.
+     The logical flag \np{ln_isfcav}{ln\_isfcav} control whether or not the ice shelf cavities are closed. \np{ln_isfcav}{ln\_isfcav} is not defined in the namelist but in the domcfg.nc input file.\\
+
+     3 options are available to represent to ice-shelf/ocean fluxes at the interface:
+     \begin{description}
+        \item[\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = 'spe'}]:
+        The fresh water flux is specified by a forcing fields \np{sn_isfcav_fwf}{sn\_isfcav\_fwf}. Convention of the input file is: positive toward the ocean (i.e. positive for melting and negative for freezing).
+        The latent heat fluxes is derived from the fresh water flux. 
+        The heat content flux is derived from the fwf flux assuming a temperature set to the freezing point in the top boundary layer (\np{rn_htbl}{rn\_htbl})
+
+        \item[\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = 'oasis'}]:
+        The \forcode{'oasis'} is a prototype of what could be a method to spread precipitation on Antarctic ice sheet as ice shelf melt inside the cavity when a coupled model Atmosphere/Ocean is used. 
+        It has not been tested and therefore the model will stop if you try to use it. 
+        Actions will be undertake in 2020 to build a comprehensive interface to do so for Greenland, Antarctic and ice shelf (cav), ice shelf (par), icebergs, subglacial runoff and runoff.
+
+        \item[\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = '2eq'}]:
+        The heat flux and the fresh water flux (negative for melting) resulting from ice shelf melting/freezing are parameterized following \citet{Grosfeld1997}. 
+        This formulation is based on a balance between the vertical diffusive heat flux across the ocean top boundary layer (\autoref{eq:ISOMIP1}) 
+        and the latent heat due to melting/freezing (\autoref{eq:ISOMIP2}):
+
+        \begin{equation}
+        \label{eq:ISOMIP1}
+        \mathcal{Q}_h = \rho c_p \gamma (T_w - T_f)
+        \end{equation}
+        \begin{equation}
+        \label{eq:ISOMIP2}
+        q = \frac{-\mathcal{Q}_h}{L_f}
+        \end{equation}
+        
+        where $\mathcal{Q}_h$($W.m^{-2}$) is the heat flux,q($kg.s^{-1}m^{-2}$) the fresh-water flux, 
+        $L_f$ the specific latent heat, $T_w$ the temperature averaged over a boundary layer below the ice shelf (explained below), 
+        $T_f$ the freezing point using  the  pressure  at  the  ice  shelf  base  and  the  salinity  of the water in the boundary layer, 
+        and $\gamma$ the thermal exchange coefficient.
+
+        \item[\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = '3eq'}]:
+        For realistic studies, the heat and freshwater fluxes are parameterized following \citep{Jenkins2001}. This formulation is based on three equations: 
+        a balance between the vertical diffusive heat flux across the boundary layer 
+        , the latent heat due to melting/freezing of ice and the vertical diffusive heat flux into the ice shelf (\autoref{eq:3eq1}); 
+        a balance between the vertical diffusive salt flux across the boundary layer and the salt source or sink represented by the melting/freezing (\autoref{eq:3eq2}); 
+        and a linear equation for the freezing temperature of sea water (\autoref{eq:3eq3}, detailed of the linearisation coefficient in \citet{AsayDavis2016}):
+
+        \begin{equation}
+        \label{eq:3eq1}
+        c_p \rho \gamma_T (T_w-T_b) = -L_f q - \rho_i c_{p,i} \kappa \frac{T_s - T_b}{h_{isf}}
+        \end{equation}
+        \begin{equation}
+        \label{eq:3eq2}
+        \rho \gamma_S (S_w - S_b) = (S_i - S_b)q
+        \end{equation}
+        \begin{equation}
+        \label{eq:3eq3}
+        T_b = \lambda_1 S_b + \lambda_2 +\lambda_3 z_{isf}
+        \end{equation}
+
+        where $T_b$ is the temperature at the interface, $S_b$ the salinity at the interface, $\gamma_T$ and $\gamma_S$ the exchange coefficients for temperature and salt, respectively, 
+        $S_i$ the salinity of the ice (assumed to be 0), $h_{isf}$ the ice shelf thickness, $z_{isf}$ the ice shelf draft, $\rho_i$ the density of the iceshelf, 
+        $c_{p,i}$ the specific heat capacity of the ice, $\kappa$ the thermal diffusivity of the ice 
+        and $T_s$ the atmospheric surface temperature (at the ice/air interface, assumed to be -20C). 
+        The Liquidus slope ($\lambda_1$), the liquidus intercept ($\lambda_2$) and the Liquidus pressure coefficient ($\lambda_3$) 
+        for TEOS80 and TEOS10 are described in \citep{AsayDavis2016} and in \citep{Jourdain2017}.
+        The linear system formed by \autoref{eq:3eq1}, \autoref{eq:3eq2} and the linearised equation for the freezing temperature of sea water (\autoref{eq:3eq3}) can be solved for $S_b$ or $T_b$. 
+        Afterward, the freshwater flux ($q$) and the heat flux ($\mathcal{Q}_h$) can be computed.
+
+     \end{description}
+
+     \begin{table}[h]
+        \centering
+        \caption{Description of the parameters hard coded into the ISF module}
+        \label{tab:isf}
+        \begin{tabular}{|l|l|l|l|}
+        \hline
+        Symbol    & Description               & Value              & Unit               \\
+        \hline
+        $C_p$     & Ocean specific heat       & 3992               & $J.kg^{-1}.K^{-1}$ \\
+        $L_f$     & Ice latent heat of fusion & $3.34 \times 10^5$ & $J.kg^{-1}$        \\
+        $C_{p,i}$ & Ice specific heat         & 2000               & $J.kg^{-1}.K^{-1}$ \\
+        $\kappa$  & Heat diffusivity          & $1.54 \times 10^{-6}$& $m^2.s^{-1}$     \\
+        $\rho_i$  & Ice density               & 920                & $kg.m^3$           \\
+        \hline
+        \end{tabular}
+     \end{table}
+
+     Temperature and salinity used to compute the fluxes in \autoref{eq:ISOMIP1}, \autoref{eq:3eq1} and \autoref{eq:3eq2} are the average temperature in the top boundary layer \citep{losch_JGR08}. 
+     Its thickness is defined by \np{rn_htbl}{rn\_htbl}.
+     The fluxes and friction velocity are computed using the mean temperature, salinity and velocity in the first \np{rn_htbl}{rn\_htbl} m.
+     Then, the fluxes are spread over the same thickness (ie over one or several cells).
+     If \np{rn_htbl}{rn\_htbl} is larger than top $e_{3}t$, there is no more direct feedback between the freezing point at the interface and the top cell temperature.
+     This can lead to super-cool temperature in the top cell under melting condition.
+     If \np{rn_htbl}{rn\_htbl} smaller than top $e_{3}t$, the top boundary layer thickness is set to the top cell thickness.\\
+
+     Each melt formula (\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = '3eq'} or \np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = '2eq'}) depends on an exchange coeficient ($\Gamma^{T,S}$) between the ocean and the ice.
+     Below, the exchange coeficient $\Gamma^{T}$ and $\Gamma^{S}$ are respectively defined by \np{rn_gammat0}{rn\_gammat0} and \np{rn_gammas0}{rn\_gammas0}. 
+     There are 3 different ways to compute the exchange velocity:
+
+     \begin{description}
+        \item[\np{cn_gammablk}{cn\_gammablk}\forcode{='spe'}]:
+        The salt and heat exchange coefficients are constant and defined by:
+\[
+\gamma^{T} = \Gamma^{T}
+\]
+\[
+\gamma^{S} = \Gamma^{S}
+\] 
+        This is the recommended formulation for ISOMIP.
+
+	\item[\np{cn_gammablk}{cn\_gammablk}\forcode{='vel'}]:
+        The salt and heat exchange coefficients are velocity dependent and defined as
+\[
+\gamma^{T} = \Gamma^{T} \times u_{*} 
+\]
+\[
+\gamma^{S} = \Gamma^{S} \times u_{*}
+\]
+        where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn_htbl}{rn\_htbl} meters).
+        See \citet{jenkins.nicholls.ea_JPO10} for all the details on this formulation. It is the recommended formulation for realistic application and ISOMIP+/MISOMIP configuration.
+
+	\item[\np{cn_gammablk}{cn\_gammablk}\forcode{'vel\_stab'}]:
+        The salt and heat exchange coefficients are velocity and stability dependent and defined as:
+\[
+\gamma^{T,S} = \frac{u_{*}}{\Gamma_{Turb} + \Gamma^{T,S}_{Mole}} 
+\]
+        where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn_tbl}{rn\_htbl} meters),
+        $\Gamma_{Turb}$ the contribution of the ocean stability and
+        $\Gamma^{T,S}_{Mole}$ the contribution of the molecular diffusion.
+        See \citet{holland.jenkins_JPO99} for all the details on this formulation. 
+        This formulation has not been extensively tested in NEMO (not recommended).
+     \end{description}
+
+\subsection{Ocean/Ice shelf fluxes in parametrised cavities}
 
   \begin{description}
-  \item [{\np[=1]{nn_isfblk}{nn\_isfblk}}]: The melt rate is based on a balance between the upward ocean heat flux and
-    the latent heat flux at the ice shelf base. A complete description is available in \citet{hunter_trpt06}.
-  \item [{\np[=2]{nn_isfblk}{nn\_isfblk}}]: The melt rate and the heat flux are based on a 3 equations formulation
-    (a heat flux budget at the ice base, a salt flux budget at the ice base and a linearised freezing point temperature equation).
-    A complete description is available in \citet{jenkins_JGR91}.
+
+     \item[\np{cn_isfpar_mlt}{cn\_isfpar\_mlt}\forcode{ = 'bg03'}]:
+     The ice shelf cavities are not represented.
+     The fwf and heat flux are computed using the \citet{beckmann.goosse_OM03} parameterisation of isf melting.
+     The fluxes are distributed along the ice shelf edge between the depth of the average grounding line (GL)
+     (\np{sn_isfpar_zmax}{sn\_isfpar\_zmax}) and the base of the ice shelf along the calving front
+     (\np{sn_isfpar_zmin}{sn\_isfpar\_zmin}) as in (\np{cn_isfpar_mlt}{cn\_isfpar\_mlt}\forcode{ = 'spe'}).
+     The effective melting length (\np{sn_isfpar_Leff}{sn\_isfpar\_Leff}) is read from a file.
+     This parametrisation has not been tested since a while and based on \citet{Favier2019}, 
+     this parametrisation should probably not be used.
+
+     \item[\np{cn_isfpar_mlt}{cn\_isfpar\_mlt}\forcode{ = 'spe'}]:
+     The ice shelf cavity is not represented.
+     The fwf (\np{sn_isfpar_fwf}{sn\_isfpar\_fwf}) is prescribed and distributed along the ice shelf edge between
+     the depth of the average grounding line (GL) (\np{sn_isfpar_zmax}{sn\_isfpar\_zmax}) and
+     the base of the ice shelf along the calving front (\np{sn_isfpar_zmin}{sn\_isfpar\_min}). Convention of the input file is positive toward the ocean (i.e. positive for melting and negative for freezing).
+     The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
+
+     \item[\np{cn_isfpar_mlt}{cn\_isfpar\_mlt}\forcode{ = 'oasis'}]:
+     The \forcode{'oasis'} is a prototype of what could be a method to spread precipitation on Antarctic ice sheet as ice shelf melt inside the cavity when a coupled model Atmosphere/Ocean is used. 
+     It has not been tested and therefore the model will stop if you try to use it. 
+     Action will be undertake in 2020 to build a comprehensive interface to do so for Greenland, Antarctic and ice shelf (cav), ice shelf (par), icebergs, subglacial runoff and runoff.
+
   \end{description}
 
-  Temperature and salinity used to compute the melt are the average temperature in the top boundary layer \citet{losch_JGR08}.
-  Its thickness is defined by \np{rn_hisf_tbl}{rn\_hisf\_tbl}.
-  The fluxes and friction velocity are computed using the mean temperature, salinity and velocity in the the first \np{rn_hisf_tbl}{rn\_hisf\_tbl} m.
-  Then, the fluxes are spread over the same thickness (ie over one or several cells).
-  If \np{rn_hisf_tbl}{rn\_hisf\_tbl} larger than top $e_{3}t$, there is no more feedback between the freezing point at the interface and the the top cell temperature.
-  This can lead to super-cool temperature in the top cell under melting condition.
-  If \np{rn_hisf_tbl}{rn\_hisf\_tbl} smaller than top $e_{3}t$, the top boundary layer thickness is set to the top cell thickness.\\
-
-  Each melt bulk formula depends on a exchange coeficient ($\Gamma^{T,S}$) between the ocean and the ice.
-  There are 3 different ways to compute the exchange coeficient:
-  \begin{description}
-  \item [{\np[=0]{nn_gammablk}{nn\_gammablk}}]: The salt and heat exchange coefficients are constant and defined by \np{rn_gammas0}{rn\_gammas0} and \np{rn_gammat0}{rn\_gammat0}.
-    \begin{gather*}
-       % \label{eq:SBC_isf_gamma_iso}
-      \gamma^{T} = rn\_gammat0 \\
-      \gamma^{S} = rn\_gammas0
-    \end{gather*}
-    This is the recommended formulation for ISOMIP.
-  \item [{\np[=1]{nn_gammablk}{nn\_gammablk}}]: The salt and heat exchange coefficients are velocity dependent and defined as
-    \begin{gather*}
-      \gamma^{T} = rn\_gammat0 \times u_{*} \\
-      \gamma^{S} = rn\_gammas0 \times u_{*}
-    \end{gather*}
-    where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn_hisf_tbl}{rn\_hisf\_tbl} meters).
-    See \citet{jenkins.nicholls.ea_JPO10} for all the details on this formulation. It is the recommended formulation for realistic application.
-  \item [{\np[=2]{nn_gammablk}{nn\_gammablk}}]: The salt and heat exchange coefficients are velocity and stability dependent and defined as:
-    \[
-      \gamma^{T,S} = \frac{u_{*}}{\Gamma_{Turb} + \Gamma^{T,S}_{Mole}}
-    \]
-    where $u_{*}$ is the friction velocity in the top boundary layer (ie first \np{rn_hisf_tbl}{rn\_hisf\_tbl} meters),
-    $\Gamma_{Turb}$ the contribution of the ocean stability and
-    $\Gamma^{T,S}_{Mole}$ the contribution of the molecular diffusion.
-    See \citet{holland.jenkins_JPO99} for all the details on this formulation.
-    This formulation has not been extensively tested in \NEMO\ (not recommended).
-  \end{description}
-\item [{\np[=2]{nn_isf}{nn\_isf}}]: The ice shelf cavity is not represented.
-  The fwf and heat flux are computed using the \citet{beckmann.goosse_OM03} parameterisation of isf melting.
-  The fluxes are distributed along the ice shelf edge between the depth of the average grounding line (GL)
-  (\np{sn_depmax_isf}{sn\_depmax\_isf}) and the base of the ice shelf along the calving front
-  (\np{sn_depmin_isf}{sn\_depmin\_isf}) as in (\np[=3]{nn_isf}{nn\_isf}).
-  The effective melting length (\np{sn_Leff_isf}{sn\_Leff\_isf}) is read from a file.
-\item [{\np[=3]{nn_isf}{nn\_isf}}]: The ice shelf cavity is not represented.
-  The fwf (\np{sn_rnfisf}{sn\_rnfisf}) is prescribed and distributed along the ice shelf edge between
-  the depth of the average grounding line (GL) (\np{sn_depmax_isf}{sn\_depmax\_isf}) and
-  the base of the ice shelf along the calving front (\np{sn_depmin_isf}{sn\_depmin\_isf}).
-  The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
-\item [{\np[=4]{nn_isf}{nn\_isf}}]: The ice shelf cavity is opened (\np[=.true.]{ln_isfcav}{ln\_isfcav} needed).
-  However, the fwf is not computed but specified from file \np{sn_fwfisf}{sn\_fwfisf}).
-  The heat flux ($Q_h$) is computed as $Q_h = fwf \times L_f$.
-  As in \np[=1]{nn_isf}{nn\_isf}, the fluxes are spread over the top boundary layer thickness (\np{rn_hisf_tbl}{rn\_hisf\_tbl})
-\end{description}
-
-$\bullet$ \np[=1]{nn_isf}{nn\_isf} and \np[=2]{nn_isf}{nn\_isf} compute a melt rate based on
+\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = '2eq'}, \np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = '3eq'} and \np{cn_isfpar_mlt}{cn\_isfpar\_mlt}\forcode{ = 'bg03'} compute a melt rate based on
 the water mass properties, ocean velocities and depth.
-This flux is thus highly dependent of the model resolution (horizontal and vertical),
-realism of the water masses onto the shelf ...\\
-
-$\bullet$ \np[=3]{nn_isf}{nn\_isf} and \np[=4]{nn_isf}{nn\_isf} read the melt rate from a file.
+The resulting fluxes are thus highly dependent of the model resolution (horizontal and vertical) and 
+realism of the water masses onto the shelf.\\
+
+\np{cn_isfcav_mlt}{cn\_isfcav\_mlt}\forcode{ = 'spe'} and \np{cn_isfpar_mlt}{cn\_isfpar\_mlt}\forcode{ = 'spe'} read the melt rate from a file.
 You have total control of the fwf forcing.
 This can be useful if the water masses on the shelf are not realistic or
 the resolution (horizontal/vertical) are too coarse to have realistic melting or
-for studies where you need to control your heat and fw input.\\
-
-The ice shelf melt is implemented as a volume flux as for the runoff.
-The fw addition due to the ice shelf melting is, at each relevant depth level, added to
-the horizontal divergence (\textit{hdivn}) in the subroutine \rou{sbc\_isf\_div}, called from \mdl{divhor}.
-See \autoref{sec:SBC_rnf} for all the details about the divergence correction.
+for studies where you need to control your heat and fw input. 
+However, if your forcing is not consistent with the dynamics below you can reach unrealistic low water temperature.\\
+
+The ice shelf fwf is implemented as a volume flux as for the runoff.
+The fwf addition due to the ice shelf melting is, at each relevant depth level, added to
+the horizontal divergence (\textit{hdivn}) in the subroutine \rou{isf\_hdiv}, called from \mdl{divhor}.
+See the runoff section \autoref{sec:SBC_rnf} for all the details about the divergence correction.\\
+
+Description and result of sensitivity tests to \np{ln_isfcav_mlt}{ln\_isfcav\_mlt} and \np{ln_isfpar_mlt}{ln\_isfpar\_mlt} are presented in \citet{mathiot.jenkins.ea_GMD17}. 
+The different options are illustrated in \autoref{fig:ISF}.
 
 \begin{figure}[!t]
   \centering
-  \includegraphics[width=0.66\textwidth]{SBC_isf}
+  \includegraphics[width=0.66\textwidth]{SBC_isf_v4.2}
   \caption[Ice shelf location and fresh water flux definition]{
     Illustration of the location where the fwf is injected and
-    whether or not the fwf is interactif or not depending of \protect\np{nn_isf}{nn\_isf}.}
-  \label{fig:SBC_isf}
+    whether or not the fwf is interactive or not.}
+  \label{fig:ISF}
 \end{figure}
 
-%% =================================================================================================
-\section{Ice sheet coupling}
-\label{sec:SBC_iscpl}
-
-\begin{listing}
-  \nlst{namsbc_iscpl}
-  \caption{\forcode{&namsbc_iscpl}}
-  \label{lst:namsbc_iscpl}
-\end{listing}
+\subsection{Available outputs}
+The following outputs are availables via XIOS:
+\begin{description}
+   \item[for parametrised cavities]:
+      \begin{xmllines}
+ <field id="isftfrz_par"     long_name="freezing point temperature in the parametrization boundary layer" unit="degC"     />
+ <field id="fwfisf_par"      long_name="Ice shelf melt rate"                           unit="kg/m2/s"  />
+ <field id="qoceisf_par"     long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     />
+ <field id="qlatisf_par"     long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
+ <field id="qhcisf_par"      long_name="Ice shelf heat content flux of injected water" unit="W/m2"     />
+ <field id="fwfisf3d_par"    long_name="Ice shelf melt rate"                           unit="kg/m2/s"  grid_ref="grid_T_3D" />
+ <field id="qoceisf3d_par"   long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+ <field id="qlatisf3d_par"   long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+ <field id="qhcisf3d_par"    long_name="Ice shelf heat content flux of injected water" unit="W/m2"     grid_ref="grid_T_3D" />
+ <field id="ttbl_par"        long_name="temperature in the parametrisation boundary layer" unit="degC" />
+ <field id="isfthermald_par" long_name="thermal driving of ice shelf melting"          unit="degC"     />
+      \end{xmllines}
+   \item[for open cavities]:
+      \begin{xmllines}
+ <field id="isftfrz_cav"     long_name="freezing point temperature at ocean/isf interface"                unit="degC"     />
+ <field id="fwfisf_cav"      long_name="Ice shelf melt rate"                           unit="kg/m2/s"  />
+ <field id="qoceisf_cav"     long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     />
+ <field id="qlatisf_cav"     long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
+ <field id="qhcisf_cav"      long_name="Ice shelf heat content flux of injected water" unit="W/m2"     />
+ <field id="fwfisf3d_cav"    long_name="Ice shelf melt rate"                           unit="kg/m2/s"  grid_ref="grid_T_3D" />
+ <field id="qoceisf3d_cav"   long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+ <field id="qlatisf3d_cav"   long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
+ <field id="qhcisf3d_cav"    long_name="Ice shelf heat content flux of injected water" unit="W/m2"     grid_ref="grid_T_3D" />
+ <field id="ttbl_cav"        long_name="temperature in Losch tbl"                      unit="degC"     />
+ <field id="isfthermald_cav" long_name="thermal driving of ice shelf melting"          unit="degC"     />
+ <field id="isfgammat"       long_name="Ice shelf heat-transfert velocity"             unit="m/s"      />
+ <field id="isfgammas"       long_name="Ice shelf salt-transfert velocity"             unit="m/s"      />
+ <field id="stbl"            long_name="salinity in the Losh tbl"                      unit="1e-3"     />
+ <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="isfustar"        long_name="ustar at T point used in ice shelf melting"    unit="m/s"      />
+ <field id="qconisf"         long_name="Conductive heat flux through the ice shelf"    unit="W/m2"     />
+      \end{xmllines}
+\end{description}
+
+%% =================================================================================================
+\subsection{Ice sheet coupling}
+\label{subsec:ISF_iscpl}
 
 Ice sheet/ocean coupling is done through file exchange at the restart step.
-At each restart step:
-
-\begin{enumerate}
-\item the ice sheet model send a new bathymetry and ice shelf draft netcdf file.
-\item a new domcfg.nc file is built using the DOMAINcfg tools.
-\item \NEMO\ run for a specific period and output the average melt rate over the period.
-\item the ice sheet model run using the melt rate outputed in step 4.
-\item go back to 1.
-\end{enumerate}
-
-If \np[=.true.]{ln_iscpl}{ln\_iscpl}, the isf draft is assume to be different at each restart step with
+At each restart step, the procedure is this one:
+
+\begin{description}
+\item[Step 1]: the ice sheet model send a new bathymetry and ice shelf draft netcdf file.
+\item[Step 2]: a new domcfg.nc file is built using the DOMAINcfg tools.
+\item[Step 3]: NEMO run for a specific period and output the average melt rate over the period.
+\item[Step 4]: the ice sheet model run using the melt rate outputed in step 3.
+\item[Step 5]: go back to 1.
+\end{description}
+
+If \np{ln_iscpl}{ln\_iscpl}\forcode{ = .true.}, the isf draft is assume to be different at each restart step with
 potentially some new wet/dry cells due to the ice sheet dynamics/thermodynamics.
-The wetting and drying scheme applied on the restart is very simple and described below for the 6 different possible cases:
+The wetting and drying scheme, applied on the restart, is very simple. The 6 different possible cases for the tracer and ssh are:
 
 \begin{description}
-\item [Thin a cell down]: T/S/ssh are unchanged and U/V in the top cell are corrected to keep the barotropic transport (bt) constant
-  ($bt_b=bt_n$).
-\item [Enlarge  a cell]: See case "Thin a cell down"
-\item [Dry a cell]: mask, T/S, U/V and ssh are set to 0.
-  Furthermore, U/V into the water column are modified to satisfy ($bt_b=bt_n$).
-\item [Wet a cell]: mask is set to 1, T/S is extrapolated from neighbours, $ssh_n = ssh_b$ and U/V set to 0.
-  If no neighbours, T/S is extrapolated from old top cell value.
-  If no neighbours along i,j and k (both previous test failed), T/S/U/V/ssh and mask are set to 0.
-\item [Dry a column]: mask, T/S, U/V are set to 0 everywhere in the column and ssh set to 0.
-\item [Wet a column]: set mask to 1, T/S is extrapolated from neighbours, ssh is extrapolated from neighbours and U/V set to 0.
-  If no neighbour, T/S/U/V and mask set to 0.
+   \item[Thin a cell]:
+   T/S/ssh are unchanged.
+
+   \item[Enlarge  a cell]:
+   See case "Thin a cell down"
+
+   \item[Dry a cell]:
+   Mask, T/S, U/V and ssh are set to 0.
+
+   \item[Wet a cell]: 
+   Mask is set to 1, T/S is extrapolated from neighbours, $ssh_n = ssh_b$.
+   If no neighbours, T/S is extrapolated from old top cell value. 
+   If no neighbours along i,j and k (both previous tests failed), T/S/ssh and mask are set to 0.
+
+   \item[Dry a column]:
+   mask, T/S and ssh are set to 0.
+
+   \item[Wet a column]:
+   set mask to 1, T/S/ssh are extrapolated from neighbours.
+   If no neighbour, T/S/ssh and mask set to 0.
 \end{description}
+
+The method described above will strongly affect the barotropic transport under an ice shelf when the geometry change.
+In order to keep the model stable, an adjustment of the dynamics at the initialisation after the coupling step is needed. 
+The idea behind this is to keep $\pd[\eta]{t}$ as it should be without change in geometry at the initialisation. 
+This will prevent any strong velocity due to large pressure gradient. 
+To do so, we correct the horizontal divergence before $\pd[\eta]{t}$ is computed in the first time step.\\
 
 Furthermore, as the before and now fields are not compatible (modification of the geometry),
@@ -1331,16 +1475,15 @@
 The horizontal extrapolation to fill new cell with realistic value is called \np{nn_drown}{nn\_drown} times.
 It means that if the grounding line retreat by more than \np{nn_drown}{nn\_drown} cells between 2 coupling steps,
-the code will be unable to fill all the new wet cells properly.
+the code will be unable to fill all the new wet cells properly and the model is likely to blow up at the initialisation.
 The default number is set up for the MISOMIP idealised experiments.
 This coupling procedure is able to take into account grounding line and calving front migration.
-However, it is a non-conservative processe.
+However, it is a non-conservative proccess. 
 This could lead to a trend in heat/salt content and volume.\\
 
 In order to remove the trend and keep the conservation level as close to 0 as possible,
-a simple conservation scheme is available with \np[=.true.]{ln_hsb}{ln\_hsb}.
-The heat/salt/vol. gain/loss is diagnosed, as well as the location.
-A correction increment is computed and apply each time step during the next \np{rn_fiscpl}{rn\_fiscpl} time steps.
-For safety, it is advised to set \np{rn_fiscpl}{rn\_fiscpl} equal to the coupling period (smallest increment possible).
-The corrective increment is apply into the cell itself (if it is a wet cell), the neigbouring cells or the closest wet cell (if the cell is now dry).
+a simple conservation scheme is available with \np{ln_isfcpl_cons}{ln\_isfcpl\_cons}\forcode{ = .true.}.
+The heat/salt/vol. gain/loss are diagnosed, as well as the location.
+A correction increment is computed and applied each time step during the model run.
+The corrective increment are applied into the cells itself (if it is a wet cell), the neigbouring cells or the closest wet cell (if the cell is now dry).
 
 %% =================================================================================================
@@ -1390,4 +1533,11 @@
 which are assumed to propagate with their larger parent and thus delay fluxing into the ocean.
 Melt water (and other variables on the configuration grid) are written into the main \NEMO\ model output files.
+
+By default, iceberg thermodynamic and dynamic are computed using ocean surface variable (sst, ssu, ssv) and the icebergs are not sensible to the bathymetry (only to land) whatever the iceberg draft. 
+\citet{Merino_OM2016} developed an option to use vertical profiles of ocean currents and temperature instead (\np{ln_M2016}{ln\_M2016}).
+Full details on the sensitivity to this parameter in done in \citet{Merino_OM2016}. 
+If \np{ln_M2016}{ln\_M2016} activated, \np{ln_icb_grd}{ln\_icb\_grd} activate (or not) an option to prevent thick icebergs to move across shallow bank (ie shallower than the iceberg draft).
+This option need to be used with care as it could required to either change the distribution to prevent generation of icebergs with draft larger than the bathymetry 
+or to build a variable \forcode{maxclass} to prevent NEMO filling the icebergs classes too thick for the local bathymetry.
 
 Extensive diagnostics can be produced.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_STO.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_STO.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_STO.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Stochastic Parametrization of EOS (STO)}
 \label{chap:STO}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_TRA.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_TRA.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_TRA.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Ocean Tracers (TRA)}
 \label{chap:TRA}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -930,5 +928,5 @@
 When \np{nn_geoflx}{nn\_geoflx} is set to 2,
 a spatially varying geothermal heat flux is introduced which is provided in
-the \ifile{geothermal\_heating} NetCDF file
+the \textit{geothermal\_heating.nc} NetCDF file
 (\autoref{fig:TRA_geothermal}) \citep{emile-geay.madec_OS09}.
 
@@ -1151,5 +1149,5 @@
 \citep{madec.delecluse.ea_JPO96}.
 
-For generating \ifile{resto},
+For generating \textit{resto.nc},
 see the documentation for the DMP tools provided with the source code under \path{./tools/DMP_TOOLS}.
 
@@ -1175,5 +1173,5 @@
 $\gamma$ is initialized as \np{rn_atfp}{rn\_atfp}, its default value is \forcode{10.e-3}.
 Note that the forcing correction term in the filter is not applied in linear free surface
-(\jp{ln\_linssh}\forcode{=.true.}) (see \autoref{subsec:TRA_sbc}).
+(\np[=.true.]{ln_linssh}{ln\_linssh}) (see \autoref{subsec:TRA_sbc}).
 Not also that in constant volume case, the time stepping is performed on $T$,
 not on its content, $e_{3t}T$.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ZDF.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ZDF.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ZDF.tex	(revision 14644)
@@ -2,12 +2,7 @@
 
 \begin{document}
-
-%% Custom aliases
-\newcommand{\cf}{\ensuremath{C\kern-0.14em f}}
 
 \chapter{Vertical Ocean Physics (ZDF)}
 \label{chap:ZDF}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -1085,4 +1080,5 @@
   \label{lst:namdrg}
 \end{listing}
+
 \begin{listing}
   \nlst{namdrg_top}
@@ -1090,4 +1086,5 @@
   \label{lst:namdrg_top}
 \end{listing}
+
 \begin{listing}
   \nlst{namdrg_bot}
@@ -1181,5 +1178,5 @@
 These values are assigned in \mdl{zdfdrg}.
 Note that there is support for local enhancement of these values via an externally defined 2D mask array
-(\np[=.true.]{ln_boost}{ln\_boost}) given in the \ifile{bfr\_coef} input NetCDF file.
+(\np[=.true.]{ln_boost}{ln\_boost}) given in the \textit{bfr\_coef.nc} input NetCDF file.
 The mask values should vary from 0 to 1.
 Locations with a non-zero mask value will have the friction coefficient increased by
@@ -1564,5 +1561,5 @@
 by only a few extra physics choices namely:
 
-\begin{verbatim}
+\begin{forlines}
      ln_dynldf_OFF = .false.
      ln_dynldf_lap = .true.
@@ -1572,5 +1569,5 @@
         nn_fct_h   =  2
         nn_fct_v   =  2
-\end{verbatim}
+\end{forlines}
 
 \noindent which were chosen to provide a slightly more stable and less noisy solution. The
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_cfgs.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_cfgs.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_cfgs.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Configurations}
 \label{chap:CFGS}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -85,5 +83,5 @@
 the SI3 model (ORCA-ICE) and possibly with PISCES biogeochemical model (ORCA-ICE-PISCES).
 An appropriate namelist is available in \path{./cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg} for ORCA2.
-The domain of ORCA2 configuration is defined in \ifile{ORCA\_R2\_zps\_domcfg} file,
+The domain of ORCA2 configuration is defined in \textit{ORCA\_R2\_zps\_domcfg.nc} file,
 this file is available in tar file on the \NEMO\ community zenodo platform: \\
 https://doi.org/10.5281/zenodo.2640723
@@ -152,5 +150,5 @@
 Each of configuration is set through the \textit{domain\_cfg} domain configuration file,
 which sets the grid size and configuration name parameters.
-The \NEMO\ System Team provides only ORCA2 domain input file "\ifile{ORCA\_R2\_zps\_domcfg}" file
+The \NEMO\ System Team provides only ORCA2 domain input file "\textit{ORCA\_R2\_zps\_domcfg.nc}" file
 (\autoref{tab:CFGS_ORCA}).
 
@@ -158,5 +156,5 @@
   \centering
   \begin{tabular}{p{4cm} c c c c}
-    Horizontal Grid & \jp{ORCA\_index} & \jp{jpiglo} & \jp{jpjglo} \\
+    Horizontal Grid & \texttt{ORCA\_index} & \texttt{jpiglo} & \texttt{jpjglo} \\
     \hline \hline
     % 4   \deg\ &              4   &          92 &          76 \\
@@ -246,12 +244,13 @@
 Its horizontal resolution (and thus the size of the domain) is determined by
 setting \np{nn_GYRE}{nn\_GYRE} in \nam{usr_def}{usr\_def}:
+
 \begin{align*}
-  \jp{jpiglo} = 30 \times \text{\np{nn_GYRE}{nn\_GYRE}} + 2 + 2 \times \text{\np{nn_hls}{nn\_hls}} \\
-  \jp{jpjglo} = 20 \times \text{\np{nn_GYRE}{nn\_GYRE}} + 2 + 2 \times \text{\np{nn_hls}{nn\_hls}}
+   jpiglo = 30 \times \text{\np{nn_GYRE}{nn\_GYRE}} + 2 + 2 \times \text{\np{nn_hls}{nn\_hls}} \\
+   jpjglo = 20 \times \text{\np{nn_GYRE}{nn\_GYRE}} + 2 + 2 \times \text{\np{nn_hls}{nn\_hls}}
 \end{align*}
 
 Obviously, the namelist parameters have to be adjusted to the chosen resolution,
 see the Configurations pages on the \NEMO\ web site (\NEMO\ Configurations).
-In the vertical, GYRE uses the default 30 ocean levels (\jp{jpk}\forcode{ = 31}) (\autoref{fig:DOM_zgr_e3}).
+In the vertical, GYRE uses the default 30 ocean levels (\forcode{jpk = 31}, \autoref{fig:DOM_zgr_e3}).
 
 \begin{listing}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_conservation.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_conservation.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_conservation.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Invariants of the Primitive Equations}
 \label{chap:CONS}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_misc.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_misc.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_misc.tex	(revision 14644)
@@ -6,6 +6,4 @@
 \label{chap:MISC}
 
-\thispagestyle{plain}
-
 \chaptertoc
 
@@ -14,10 +12,11 @@
 {\footnotesize
   \begin{tabularx}{\textwidth}{l||X|X}
-    Release & Author(s) & Modifications \\
+    Release     & Author(s)            & Modifications                      \\
     \hline
-    {\em   4.0} & {\em ...} & {\em ...} \\
-    {\em   3.6} & {\em ...} & {\em ...} \\
-    {\em   3.4} & {\em ...} & {\em ...} \\
-    {\em <=3.4} & {\em ...} & {\em ...}
+    {\em   X.X} & {\em Pierre Mathiot} & {Update of the closed sea section} \\
+    {\em   4.0} & {\em ...           } & {\em ...                         } \\
+    {\em   3.6} & {\em ...           } & {\em ...                         } \\
+    {\em   3.4} & {\em ...           } & {\em ...                         } \\
+    {\em <=3.4} & {\em ...           } & {\em ...                         }
   \end{tabularx}
 }
@@ -109,21 +108,13 @@
 \end{figure}
 
-\begin{figure}[!tbp]
-  \centering
-  \includegraphics[width=0.66\textwidth]{MISC_closea_mask_example}
-  \caption[Mask fields for the \protect\mdl{closea} module]{
-    Example of mask fields for the \protect\mdl{closea} module.
-    \textit{Left}: a closea\_mask field;
-    \textit{Right}: a closea\_mask\_rnf field.
-    In this example, if \protect\np{ln_closea}{ln\_closea} is set to \forcode{.true.},
-    the mean freshwater flux over each of the American Great Lakes will be set to zero,
-    and the total residual for all the lakes, if negative, will be put into
-    the St Laurence Seaway in the area shown.}
-  \label{fig:MISC_closea_mask_example}
-\end{figure}
-
 %% =================================================================================================
 \section[Closed seas (\textit{closea.F90})]{Closed seas (\protect\mdl{closea})}
 \label{sec:MISC_closea}
+
+\begin{listing}
+  \nlst{namclo}
+  \caption{\forcode{&namclo}}
+  \label{lst:namclo}
+\end{listing}
 
 Some configurations include inland seas and lakes as ocean
@@ -138,53 +129,50 @@
 to zero and put the residual flux into the ocean.
 
-Prior to \NEMO\ 4 the locations of inland seas and lakes was set via
-hardcoded indices for various ORCA configurations. From \NEMO\ 4 onwards
-the inland seas and lakes are defined using mask fields in the
-domain configuration file. The options are as follows.
-
-\begin{enumerate}
-\item {{\bfseries No ``closea\_mask'' field is included in domain configuration
-  file.} In this case the closea module does nothing.}
-
-\item {{\bfseries A field called closea\_mask is included in the domain
-configuration file and ln\_closea=.false. in namelist namcfg.} In this
-case the inland seas defined by the closea\_mask field are filled in
-(turned to land points) at run time. That is every point in
-closea\_mask that is nonzero is set to be a land point.}
-
-\item {{\bfseries A field called closea\_mask is included in the domain
-configuration file and ln\_closea=.true. in namelist namcfg.} Each
-inland sea or group of inland seas is set to a positive integer value
-in the closea\_mask field (see \autoref{fig:MISC_closea_mask_example}
-for an example). The net surface flux over each inland sea or group of
+The inland seas and lakes are defined using mask fields in the
+domain configuration file. Special treatment of the closed sea (redistribution of net freshwater or mask those), are defined in \autoref{lst:namclo} and
+can be trigger by \np{ln_closea}{ln\_closea}\forcode{=.true.} in namelist namcfg.
+
+The options available are the following:
+\begin{description}
+\item[\np{ln_maskcs}{ln\_maskcs}\forcode{ = .true.}] All the closed seas are masked using \textit{mask\_opensea} variable.
+\item[\np{ln_maskcs}{ln\_maskcs}\forcode{ = .false.}] The net surface flux over each inland sea or group of
 inland seas is set to zero each timestep and the residual flux is
-distributed over the global ocean (ie. all ocean points where
-closea\_mask is zero).}
-
-\item {{\bfseries Fields called closea\_mask and closea\_mask\_rnf are
-included in the domain configuration file and ln\_closea=.true. in
-namelist namcfg.} This option works as for option 3, except that if
-the net surface flux over an inland sea is negative (net
-precipitation) it is put into the ocean at specified runoff points. A
-net positive surface flux (net evaporation) is still spread over the
-global ocean. The mapping from inland seas to runoff points is defined
-by the closea\_mask\_rnf field. Each mapping is defined by a positive
-integer value for the inland sea(s) and the corresponding runoff
-points. An example is given in
-\autoref{fig:MISC_closea_mask_example}. If no mapping is provided for a
-particular inland sea then the residual is spread over the global
-ocean.}
-
-\item {{\bfseries Fields called closea\_mask and closea\_mask\_emp are
-included in the domain configuration file and ln\_closea=.true. in
-namelist namcfg.} This option works the same as option 4 except that
-the nonzero net surface flux is sent to the ocean at the specified
-runoff points regardless of whether it is positive or negative. The
-mapping from inland seas to runoff points in this case is defined by
-the closea\_mask\_emp field.}
-\end{enumerate}
-
-There is a python routine to create the closea\_mask fields and append
-them to the domain configuration file in the utils/tools/DOMAINcfg directory.
+distributed over a target area.
+\end{description}
+
+When \np{ln_maskcs}{ln\_maskcs}\forcode{ = .false.}, 
+3 options are available for the redistribution (set up of these options is done in the tool DOMAINcfg):
+\begin{description}[font=$\bullet$ ]
+\item[ glo]: The residual flux is redistributed globally.
+\item[ emp]: The residual flux is redistributed as emp in a river outflow.
+\item[ rnf]: The residual flux is redistributed as rnf in a river outflow if negative. If there is a net evaporation, the residual flux is redistributed globally.
+\end{description}
+
+For each case, 2 masks are needed (\autoref{fig:MISC_closea_mask_example}): 
+\begin{description}
+\item $\bullet$ one describing the 'sources' (ie the closed seas concerned by each options) called \textit{mask\_csglo}, \textit{mask\_csrnf}, \textit{mask\_csemp}. 
+\item $\bullet$ one describing each group of inland seas (the Great Lakes for example) and the target area (river outflow or world ocean) for each group of inland seas (St Laurence for the Great Lakes for example) called
+\textit{mask\_csgrpglo}, \textit{mask\_csgrprnf}, \textit{mask\_csgrpemp}.
+\end{description}
+
+\begin{figure}[!tbp]
+  \centering
+  \includegraphics[width=0.66\textwidth]{MISC_closea_mask_example}
+  \caption[Mask fields for the \protect\mdl{closea} module]{
+    Example of mask fields for the \protect\mdl{closea} module.
+    \textit{Left}: a \textit{mask\_csrnf} field;
+    \textit{Right}: a \textit{mask\_csgrprnf} field.
+    In this example, if \protect\np{ln_closea}{ln\_closea} is set to \forcode{.true.},
+    the mean freshwater flux over each of the American Great Lakes will be set to zero,
+    and the total residual for all the lakes, if negative, will be put into
+    the St Laurence Seaway in the area shown.}
+  \label{fig:MISC_closea_mask_example}
+\end{figure}
+
+Closed sea not defined (because too small, issue in the bathymetry definition ...) are defined in \textit{mask\_csundef}.
+These points can be masked using the namelist option \np{ln_mask_csundef}{ln\_mask\_csundef}\forcode{= .true.} or used to correct the bathymetry input file.\\
+
+The masks needed for the closed sea can be created using the DOMAINcfg tool in the utils/tools/DOMAINcfg directory.
+See \autoref{sec:clocfg} for details on the usage of definition of the closed sea masks.
 
 %% =================================================================================================
@@ -205,5 +193,5 @@
 
 \noindent Consider an ORCA1
-configuration using the extended grid domain configuration file: \ifile{eORCA1\_domcfg.nc}
+configuration using the extended grid domain configuration file: \textit{eORCA1\_domcfg.nc}
 This file define a horizontal domain of 362x332.  The first row with
 open ocean wet points in the non-isf bathymetry for this set is row 42 (\fortran\ indexing)
@@ -226,5 +214,5 @@
 \noindent Note that with this option, the j-size of the global domain is (extended
 j-size minus \np{open_ocean_jstart}{open\_ocean\_jstart} + 1 ) and this must match the \texttt{jpjglo} value
-for the configuration. This means an alternative version of \ifile{eORCA1\_domcfg.nc} must
+for the configuration. This means an alternative version of \textit{eORCA1\_domcfg.nc} must
 be created for when \np{ln_use_jattr}{ln\_use\_jattr} is active. The \texttt{ncap2} tool provides a
 convenient way of achieving this:
@@ -234,5 +222,5 @@
 \end{cmds}
 
-The domain configuration file is unique in this respect since it also contains the value of \jp{jpjglo}
+The domain configuration file is unique in this respect since it also contains the value of \texttt{jpjglo}
 that is read and used by the model.
 Any other global, 2D and 3D, netcdf, input field can be prepared for use in a reduced domain by adding the
@@ -374,5 +362,5 @@
 
 When more information is required for monitoring or debugging purposes, the various
-forms of output can be selected via the \np{sn\_cfctl} structure. As well as simple
+forms of output can be selected via the \np{sn_cfctl}{sn\_cfctl} structure. As well as simple
 on-off switches this structure also allows selection of a range of processors for
 individual reporting (where appropriate) and a time-increment option to restrict
@@ -449,7 +437,5 @@
 systems so bug-hunting efforts using this facility should also utilise the \fortran:
 
-\begin{forlines} 
-   CALL FLUSH(numout)
-\end{forlines}
+\forline|CALL FLUSH(numout)|
 
 statement after any additional write statements to ensure that file contents reflect
@@ -482,18 +468,18 @@
 
 \begin{forlines}
-   sn_cfctl%l_glochk = .FALSE.    ! Range sanity checks are local (F) or global (T). Set T for debugging only
-   sn_cfctl%l_allon  = .FALSE.    ! IF T activate all options. If F deactivate all unless l_config is T
-     sn_cfctl%l_config = .TRUE.     ! IF .true. then control which reports are written with the following
-       sn_cfctl%l_runstat = .FALSE. ! switches and which areas produce reports with the proc integer settings.
-       sn_cfctl%l_trcstat = .FALSE. ! The default settings for the proc integers should ensure
-       sn_cfctl%l_oceout  = .FALSE. ! that  all areas report.
-       sn_cfctl%l_layout  = .FALSE. !
-       sn_cfctl%l_prtctl  = .FALSE. !
-       sn_cfctl%l_prttrc  = .FALSE. !
-       sn_cfctl%l_oasout  = .FALSE. !
-       sn_cfctl%procmin   = 0       ! Minimum area number for reporting [default:0]
-       sn_cfctl%procmax   = 1000000 ! Maximum area number for reporting [default:1000000]
-       sn_cfctl%procincr  = 1       ! Increment for optional subsetting of areas [default:1]
-       sn_cfctl%ptimincr  = 1       ! Timestep increment for writing time step progress info
+   sn_cfctl%l_glochk  = .false. ! Range sanity checks are local (F) or global (T). Set T for debugging only
+   sn_cfctl%l_allon   = .false. ! IF T activate all options. If F deactivate all unless l_config is T
+   sn_cfctl%l_config  = .true.  ! IF .true. then control which reports are written with the following
+   sn_cfctl%l_runstat = .false. ! switches and which areas produce reports with the proc integer settings.
+   sn_cfctl%l_trcstat = .false. ! The default settings for the proc integers should ensure
+   sn_cfctl%l_oceout  = .false. ! that  all areas report.
+   sn_cfctl%l_layout  = .false. !
+   sn_cfctl%l_prtctl  = .false. !
+   sn_cfctl%l_prttrc  = .false. !
+   sn_cfctl%l_oasout  = .false. !
+   sn_cfctl%procmin   = 0       ! Minimum area number for reporting [default:0]
+   sn_cfctl%procmax   = 1000000 ! Maximum area number for reporting [default:1000000]
+   sn_cfctl%procincr  = 1       ! Increment for optional subsetting of areas [default:1]
+   sn_cfctl%ptimincr  = 1       ! Timestep increment for writing time step progress info
 \end{forlines}
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics.tex	(revision 14644)
@@ -5,6 +5,4 @@
 \chapter{Model Basics}
 \label{chap:MB}
-
-\thispagestyle{plain}
 
 \chaptertoc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex	(revision 14644)
@@ -4,6 +4,4 @@
 
 \chapter{ essai \zstar \sstar}
-
-\thispagestyle{plain}
 
 \chaptertoc
@@ -85,4 +83,5 @@
 
 %\nlst{nam_dynspg}
+
 Options are defined through the \nam{_dynspg}{\_dynspg} namelist variables.
 The surface pressure gradient term is related to the representation of the free surface (\autoref{sec:MB_hor_pg}).
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_time_domain.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_time_domain.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_time_domain.tex	(revision 14644)
@@ -6,6 +6,4 @@
 \label{chap:TD}
 
-\thispagestyle{plain}
-
 \chaptertoc
 
@@ -14,12 +12,12 @@
 {\footnotesize
   \begin{tabularx}{0.5\textwidth}{l||X|X}
-    Release          & Author(s)                                       &
+    Release          & Author(s)                                       & 
     Modifications                                                      \\
     \hline
-    {\em        4.0} & {\em J\'{e}r\^{o}me Chanut \newline Tim Graham} &
+    {\em        4.0} & {\em J\'{e}r\^{o}me Chanut \newline Tim Graham} & 
     {\em Review \newline Update                                      } \\
-    {\em        3.6} & {\em Christian \'{E}th\'{e}                   } &
+    {\em        3.6} & {\em Christian \'{E}th\'{e}                   } & 
     {\em Update                                                      } \\
-    {\em $\leq$ 3.4} & {\em Gurvan Madec                             } &
+    {\em $\leq$ 3.4} & {\em Gurvan Madec                             } & 
     {\em First version                                               } \\
   \end{tabularx}
@@ -46,8 +44,10 @@
 
 The time stepping used in \NEMO\ is a three level scheme that can be represented as follows:
+
 \begin{equation}
   \label{eq:TD}
   x^{t + \rdt} = x^{t - \rdt} + 2 \, \rdt \ \text{RHS}_x^{t - \rdt, \, t, \, t + \rdt}
 \end{equation}
+
 where $x$ stands for $u$, $v$, $T$ or $S$;
 RHS is the \textbf{R}ight-\textbf{H}and-\textbf{S}ide of the corresponding time evolution equation;
@@ -99,8 +99,10 @@
 first designed by \citet{robert_JMSJ66} and more comprehensively studied by \citet{asselin_MWR72},
 is a kind of laplacian diffusion in time that mixes odd and even time steps:
+
 \begin{equation}
   \label{eq:TD_asselin}
   x_F^t = x^t + \gamma \, \lt[ x_F^{t - \rdt} - 2 x^t + x^{t + \rdt} \rt]
 \end{equation}
+
 where the subscript $F$ denotes filtered values and $\gamma$ is the Asselin coefficient.
 $\gamma$ is initialized as \np{rn_atfp}{rn\_atfp} (namelist parameter).
@@ -134,4 +136,5 @@
 The conditions for stability of second and fourth order horizontal diffusion schemes are
 \citep{griffies_bk04}:
+
 \begin{equation}
   \label{eq:TD_euler_stability}
@@ -142,4 +145,5 @@
   \end{cases}
 \end{equation}
+
 where $e$ is the smallest grid size in the two horizontal directions and
 $A^h$ is the mixing coefficient.
@@ -153,4 +157,5 @@
 To overcome the stability constraint, a backward (or implicit) time differencing scheme is used.
 This scheme is unconditionally stable but diffusive and can be written as follows:
+
 \begin{equation}
   \label{eq:TD_imp}
@@ -170,9 +175,12 @@
 where RHS is the right hand side of the equation except for the vertical diffusion term.
 We rewrite \autoref{eq:TD_imp} as:
+
 \begin{equation}
   \label{eq:TD_imp_mat}
   -c(k + 1) \; T^{t + 1}(k + 1) + d(k) \; T^{t + 1}(k) - \; c(k) \; T^{t + 1}(k - 1) \equiv b(k)
 \end{equation}
+
 where
+
 \[
   c(k) = A_w^{vT} (k) \, / \, e_{3w} (k) \text{,} \quad
@@ -241,4 +249,5 @@
 $Q$ is redistributed over several time step.
 In the modified LF-RA environment, these two formulations have been replaced by:
+
 \begin{gather}
   \label{eq:TD_forcing}
@@ -248,4 +257,5 @@
                     - \gamma \, \rdt \, \lt( Q^{t + \rdt / 2} - Q^{t - \rdt / 2} \rt)
 \end{gather}
+
 The change in the forcing formulation given by \autoref{eq:TD_forcing}
 (see \autoref{fig:TD_MLF_forcing}) has a significant effect:
@@ -377,4 +387,5 @@
   %
 \end{flalign*}
+
 \begin{flalign*}
   \allowdisplaybreaks
@@ -389,4 +400,5 @@
   %
 \end{flalign*}
+
 \begin{flalign*}
   \allowdisplaybreaks
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/main/SI3_manual.ist
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/main/SI3_manual.ist	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/main/SI3_manual.ist	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../global/index.ist
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/main/settings.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/main/settings.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/main/settings.tex	(revision 14644)
@@ -1,20 +1,18 @@
-%% Engine (folder name)
-\def \engine{SI3}
+%% Engine
+\def\eng{SI3}
 
-%% Title and cover page settings
-\def \spacetop{  \vspace*{1.2cm} }
-\def \heading{Sea Ice modelling Integrated Initiative (SI$^3$)}
-\def \subheading{The NEMO sea ice engine}
-\def \spacedown{ \vspace*{  1cm} }
-\def \authorswidth{0.2\linewidth}
-\def \rulelenght{230pt}
-\def \abstractwidth{0.65\linewidth}
+%% Cover page
+\def\spcup{\vspace*{1.20cm}}
+\def \hdg{Sea Ice modelling Integrated Initiative (SI$^3$)}
+\def\shdg{The NEMO sea ice engine                         }
+\def\spcdn{\vspace*{1.00cm}}
+\def\autwd{0.20\linewidth}\def\lnlg{230pt}\def\abswd{0.65\linewidth}
 
-%% Color for document (frontpage banner, links and chapter boxes)
-\def \setmanualcolor{ \definecolor{manualcolor}{cmyk}{0, 0, 0, 0.4} }
+%% Color in cmyk model for manual theme (frontpage banner, links and chapter boxes)
+\def\clr{0.0,0.0,0.0,0.4}
 
 %% IPSL publication number
-\def \ipslnum{31}
+\def\ipsl{31}
 
-%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
-\def \zid{1471689}
+%% Zenodo ID, i.e. doi:10.5281/zenodo.\zid
+\def\zid{1471689}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/TOP_manual.ist
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/TOP_manual.ist	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/TOP_manual.ist	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../global/index.ist
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/bibliography.bib
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/bibliography.bib	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/bibliography.bib	(revision 14644)
@@ -185,4 +185,16 @@
   journal	= {Global Biogeochemical Cycles},
   publisher	= {American Geophysical Union (AGU)}
+}
+
+@techreport{      gibson_trpt86,
+  title         = "Standards for software development and maintenance",
+  pages         = "21",
+  series        = "ECMWF Technical Memoranda",
+  number        = "120",
+  author        = "J. K. Gibson",
+  institution   = "ECMWF Operations Department; Reading, United Kingdom",
+  year          = "1986",
+  month         = "aug",
+  doi           = "10.21957/gi113q4gn"
 }
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/settings.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/settings.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/main/settings.tex	(revision 14644)
@@ -1,20 +1,18 @@
-%% Engine (folder name)
-\def \engine{TOP}
+%% Engine
+\def\eng{TOP}
 
-%% Title and cover page settings
-\def \spacetop{  \vspace*{1.3cm} }
-\def \heading{Tracers in Ocean Paradigm (TOP)}
-\def \subheading{The NEMO passive tracers engine}
-\def \spacedown{ \vspace*{  1cm} }
-\def \authorswidth{0.15\linewidth}
-\def \rulelenght{110pt}
-\def \abstractwidth{0.7\linewidth}
+%% Cover page
+\def\spcup{\vspace*{1.30cm}}
+\def \hdg{Tracers in Ocean Paradigm (TOP)}
+\def\shdg{The NEMO passive tracers engine}
+\def\spcdn{\vspace*{1.00cm}}
+\def\autwd{0.15\linewidth}\def\lnlg{110pt}\def\abswd{0.70\linewidth}
 
-%% Color for document (frontpage banner, links and chapter boxes)
-\def \setmanualcolor{ \definecolor{manualcolor}{cmyk}{1, 0, 1, .4} }
+%% Color in cmyk model for manual theme (frontpage banner, links and chapter boxes)
+\def\clr{1.0,0.0,1.0,0.4}
 
 %% IPSL publication number
-\def \ipslnum{28}
+\def\ipsl{28}
 
-%% Zenodo ID, i.e. doi:10.5281/zenodo.\([0-9]*\)
-\def \zid{1471700}
+%% Zenodo ID, i.e. doi:10.5281/zenodo.\zid
+\def\zid{1471700}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/subfiles/miscellaneous.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/subfiles/miscellaneous.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/subfiles/miscellaneous.tex	(revision 14644)
@@ -24,5 +24,5 @@
 %
 \begin{minted}{bash}
-    bld::tool::fppkeys   key_iomput key_mpp_mpi key_top
+    bld::tool::fppkeys   key_xios key_top
 \end{minted}
 
@@ -42,5 +42,5 @@
 %
 \begin{minted}{bash}
-   bld::tool::fppkeys   key_iomput key_mpp_mpi key_top
+   bld::tool::fppkeys   key_xios key_top
 
    src::MYBGC::initialization         <MYBGCPATH>/initialization
@@ -60,5 +60,5 @@
 %Note that, the additional lines specific for the BGC model source and build paths, can be written into a separate file, e.g. named MYBGC.fcm, and then simply included in the cpp_NEMO_MYBGC.fcm as follow
 %
-%bld::tool::fppkeys  key_zdftke key_dynspg_ts key_iomput key_mpp_mpi key_top
+%bld::tool::fppkeys  key_zdftke key_dynspg_ts key_xios key_top
 %inc <MYBGCPATH>/MYBGC.fcm
 %This will enable a more portable compilation structure for all MYBGC related configurations.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/subfiles/model_description.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/subfiles/model_description.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/TOP/subfiles/model_description.tex	(revision 14644)
@@ -9,6 +9,4 @@
 \newcommand{\Dcq}{\Delta ^{14}\mathrm{C}}
 \newcommand{\Rq}{\mathrm{^{14}{R}}}
-\newcommand{\CODE}[1]{\textsc{#1}}
-%\newcommand{\CODE}[1]{\textcolor{black}{\textsc{#1}}\xspace}
 
 \chapter{Model Description}
@@ -28,7 +26,11 @@
 where expressions of $D^{lC}$ and $D^{vC}$ depend on the choice for the lateral and vertical subgrid scale parameterizations, see equations 5.10 and 5.11 in \citep{nemo_manual}
 
-{S(C)} , the first term on the right hand side of \ref{Eq_tracer}; is the SMS - Source Minus Sink - inherent to the tracer.  In the case of biological tracer such as phytoplankton, {S(C)} is the balance between phytoplankton growth and its decay through mortality and grazing. In the case of a tracer comprising carbon,  {S(C)} accounts for gas exchange, river discharge, flux to the sediments, gravitational sinking and other biological processes. In the case of a radioactive tracer, {S(C)} is simply loss due to radioactive decay.
-
-The second term (within brackets) represents the advection of the tracer in the three directions. It can be interpreted as the budget between the incoming and outgoing tracer fluxes in a volume $T$-cells $b_t= e_{1t}\,e_{2t}\,e_{3t}$
+{S(C)} , the first term on the right hand side of \autoref{Eq_tracer}; is the SMS - Source Minus Sink - inherent to the tracer.
+In the case of biological tracer such as phytoplankton, {S(C)} is the balance between phytoplankton growth and its decay through mortality and grazing.
+In the case of a tracer comprising carbon,  {S(C)} accounts for gas exchange, river discharge, flux to the sediments, gravitational sinking and other biological processes.
+In the case of a radioactive tracer, {S(C)} is simply loss due to radioactive decay.
+
+The second term (within brackets) represents the advection of the tracer in the three directions.
+It can be interpreted as the budget between the incoming and outgoing tracer fluxes in a volume $T$-cells $b_t= e_{1t}\,e_{2t}\,e_{3t}$
 
 The third term  represents the change due to lateral diffusion.
@@ -46,5 +48,6 @@
 \label{sec:TopInt}
 
-TOP is the NEMO hardwired interface toward biogeochemical models and provide the physical constraints/boundaries for oceanic tracers. It consists of a modular framework to handle multiple ocean tracers, including also a variety of built-in modules.
+TOP is the NEMO hardwired interface toward biogeochemical models and provide the physical constraints/boundaries for oceanic tracers.
+It consists of a modular framework to handle multiple ocean tracers, including also a variety of built-in modules.
 
 This component of the NEMO framework allows one to exploit available modules  and further develop a range of applications, spanning from the implementation of a dye passive tracer to evaluate dispersion processes (by means of MY\_TRC), track water masses age (AGE module), assess the ocean interior penetration of persistent chemical compounds (e.g., gases like CFC or even PCBs), up to the full set of equations involving marine biogeochemical cycles.
@@ -61,5 +64,6 @@
         \item \textbf{AGE}	    :    Water age tracking
         \item \textbf{MY\_TRC}  :	Template for creation of new modules and external BGC models coupling
-        \item \textbf{PISCES}    :	 Built in BGC model. See \citep{aumont_2015} for a throughout description.
+        \item \textbf{PISCES}    :	 Built in BGC model.
+See \citep{aumont_2015} for a throughout description.
 \end{itemize}
 %  ----------------------------------------------------------
@@ -69,17 +73,21 @@
 The passive tracer transport component  shares the same advection/diffusion routines with the dynamics, with specific treatment of some features like the surface boundary conditions, or the positivity of passive tracers concentrations.
 
- \subsection{ Advection}
+\subsection{Advection}
 %------------------------------------------namtrc_adv----------------------------------------------------
 \nlst{namtrc_adv}
 %-------------------------------------------------------------------------------------------------------------
-The advection schemes used for the passive tracers are the same than the ones for $T$ and $S$ and described in section 5.1 of \citep{nemo_manual}. The choice of an advection scheme  can be selected independently and  can differ from the ones used for active tracers. This choice is made in the \textit{namtrc\_adv} namelist, by  setting to \textit{true} one and only one of the logicals \textit{ln\_trcadv\_xxx}, the same way of what is done for dynamics.
-cen2, MUSCL2, and UBS are not \textit{positive} schemes meaning that negative values can appear in an initially strictly positive tracer field which is advected, implying that false extrema are permitted. Their use is not recommended on passive tracers
-
- \subsection{ Lateral diffusion}
+The advection schemes used for the passive tracers are the same than the ones for $T$ and $S$ and described in section 5.1 of \citep{nemo_manual}.
+The choice of an advection scheme  can be selected independently and  can differ from the ones used for active tracers.
+This choice is made in the \textit{namtrc\_adv} namelist, by  setting to \textit{true} one and only one of the logicals \textit{ln\_trcadv\_xxx}, the same way of what is done for dynamics.
+cen2, MUSCL2, and UBS are not \textit{positive} schemes meaning that negative values can appear in an initially strictly positive tracer field which is advected, implying that false extrema are permitted.
+Their use is not recommended on passive tracers
+
+\subsection{Lateral diffusion}
 %------------------------------------------namtrc_ldf----------------------------------------------------
 \nlst{namtrc_ldf}
 %-------------------------------------------------------------------------------------------------------------
-In NEMO v4.0, the passive tracer diffusion has necessarily the same form as the active tracer diffusion, meaning that the numerical scheme must be the same. However the passive tracer mixing coefficient can be chosen as a multiple of the active ones by changing the value of \textit{rn\_ldf\_multi} in namelist \textit{namtrc\_ldf}. The choice of numerical scheme is then set  in the \nam{namtra_ldf}{namtra\_ldf} namelist for the dynamic described in section 5.2 of \citep{nemo_manual}.
-
+In NEMO v4.0, the passive tracer diffusion has necessarily the same form as the active tracer diffusion, meaning that the numerical scheme must be the same.
+However the passive tracer mixing coefficient can be chosen as a multiple of the active ones by changing the value of \textit{rn\_ldf\_multi} in namelist \textit{namtrc\_ldf}.
+The choice of numerical scheme is then set in the \forcode{&namtra_ldf} namelist for the dynamic described in section 5.2 of \citep{nemo_manual}.
 
 %-----------------We also offers the possibility to increase zonal equatorial diffusion for passive tracers by introducing an enhanced zonal diffusivity coefficent in the equatorial domain which can be defined by the equation below :
@@ -88,5 +96,5 @@
 %-----------------\end{equation}
 
- \subsection{ Tracer damping}
+\subsection{Tracer damping}
 
 %------------------------------------------namtrc_dmp----------------------------------------------------
@@ -94,8 +102,12 @@
 %-------------------------------------------------------------------------------------------------------------
 
-The use of newtonian damping  to climatological fields or observations is also coded, sharing the same routine dans active tracers. Boolean variables are defined in the namelist\_top\_ref to select the tracers on which restoring is applied
-Options are defined through the \nam{namtrc_dmp}{namtrc\_dmp} namelist variables. The restoring term is added when the namelist parameter \np{ln\_trcdmp} is set to true. The restoring coefficient is a three-dimensional array read in a file, which name is specified by the namelist variable \np{cn\_resto\_tr}. This netcdf file can be generated using the DMP\_TOOLS tool.
-
- \subsection{ Tracer positivity}
+The use of newtonian damping  to climatological fields or observations is also coded, sharing the same routine dans active tracers.
+Boolean variables are defined in the namelist\_top\_ref to select the tracers on which restoring is applied
+Options are defined through the \nam{trc_dmp}{trc\_dmp} namelist variables.
+The restoring term is added when the namelist parameter \np{ln\_trcdmp} is set to true.
+The restoring coefficient is a three-dimensional array read in a file, which name is specified by the namelist variable \np{cn\_resto\_tr}.
+This netcdf file can be generated using the DMP\_TOOLS tool.
+
+\subsection{Tracer positivity}
 
 %------------------------------------------namtrc_rad----------------------------------------------------
@@ -103,6 +115,8 @@
 %-------------------------------------------------------------------------------------------------------------
 
-Sometimes, numerical scheme can generates negative values of passive tracers concentration that must be positive. For exemple,  isopycnal diffusion can created extrema. The trcrad routine artificially corrects negative concentrations with a very crude solution that either sets negative concentration to zero without adjusting the tracer budget, or by removing negative concentration and keeping mass conservation.
-The treatment of negative concentrations is an option and can be selected in the namelist \nam{namtrc_rad}{namtrc\_rad} by setting the parameter \np{ln\_trcrad}  to true.
+Sometimes, numerical scheme can generates negative values of passive tracers concentration that must be positive.
+For exemple,  isopycnal diffusion can created extrema.
+The trcrad routine artificially corrects negative concentrations with a very crude solution that either sets negative concentration to zero without adjusting the tracer budget, or by removing negative concentration and keeping mass conservation.
+The treatment of negative concentrations is an option and can be selected in the namelist \nam{trc_rad}{trc\_rad} by setting the parameter \np{ln\_trcrad}  to true.
 
 \section{The SMS modules}
@@ -119,31 +133,42 @@
 %----------------------------------------------------------------------------------------------------------
 
-
- An `ideal age' tracer is integrated online in TOP when \textit{ln\_age} = \texttt{.true.} in namelist \textit{namtrc}. This tracer marks the length of time in units of years that fluid has spent in the interior of the ocean, insulated from exposure to the atmosphere. Thus, away from the surface for $z<-H_{\mathrm{Age}}$ where $H_{\mathrm{Age}}$ is specified by the \textit{namage} namelist variable \textit{rn\_age\_depth}, whose default value is 10~m, there is a source $\mathrm{SMS_{\mathrm{Age}}}$ of the age tracer $A$:
+An `ideal age' tracer is integrated online in TOP when \textit{ln\_age} = \texttt{.true.} in namelist \textit{namtrc}.
+This tracer marks the length of time in units of years that fluid has spent in the interior of the ocean, insulated from exposure to the atmosphere.
+Thus, away from the surface for $z<-H_{\mathrm{Age}}$ where $H_{\mathrm{Age}}$ is specified by the \textit{namage} namelist variable \textit{rn\_age\_depth}, whose default value is 10~m, there is a source $\mathrm{SMS_{\mathrm{Age}}}$ of the age tracer $A$:
+
 \begin{equation}
   \label{eq:TOP-age-interior}
   \mathrm{SMS_{\mathrm{Age}}} = 1 \mathrm{yr}\;^{-1} = 1/T_{\mathrm{year}},
- \end{equation}
- where the length of the current year $T_{\mathrm{year}} = 86400*N_{\mathrm{days\;in\;current\; year}}\;\mathrm{s}$, where $N_{\mathrm{days\;in\;current\; year}}$ may be 366 or 365 depending on whether the current year is a leap year or not.
- Near the surface, for $z>-H_{\mathrm{Age}}$, ideal age is relaxed back to zero:
+\end{equation}
+
+where the length of the current year $T_{\mathrm{year}} = 86400*N_{\mathrm{days\;in\;current\; year}}\;\mathrm{s}$, where $N_{\mathrm{days\;in\;current\; year}}$ may be 366 or 365 depending on whether the current year is a leap year or not.
+Near the surface, for $z>-H_{\mathrm{Age}}$, ideal age is relaxed back to zero:
+
 \begin{equation}
   \label{eq:TOP-age-surface}
    \mathrm{SMS_{\mathrm{Age}}} = -\lambda_{\mathrm{Age}}A,
- \end{equation}
- where the relaxation rate $\lambda_{\mathrm{Age}}$  (units $\mathrm{s}\;^{-1}$) is specified by the \textit{namage} namelist variable \textit{rn\_age\_kill\_rate} and has a default value of 1/7200~s. Since this relaxation is applied explicitly, this relaxation rate in principle should not exceed $1/\Delta t$, where $\Delta t$ is the time step used to step forward passive tracers (2 * \textit{nn\_dttrc * rn\_rdt} when the default  leapfrog time-stepping scheme is employed).
-
- Currently the 1-dimensional reference depth of the grid boxes is used rather than the dynamically evolving depth to determine whether the age tracer is incremented or relaxed to zero. This means that the tracer only works correctly in z-coordinates. To ensure that the forcing is independent of the level thicknesses, where the tracer cell at level $k$ has its upper face $z=-depw(k)$ above the depth $-H_{\mathrm{Age}}$, but its lower face $z=-depw(k+1)$ below that depth, then the age source
- \begin{equation}
+\end{equation}
+
+where the relaxation rate $\lambda_{\mathrm{Age}}$  (units $\mathrm{s}\;^{-1}$) is specified by the \textit{namage} namelist variable \textit{rn\_age\_kill\_rate} and has a default value of 1/7200~s.
+Since this relaxation is applied explicitly, this relaxation rate in principle should not exceed $1/\Delta t$, where $\Delta t$ is the time step used to step forward passive tracers (2 * \textit{nn\_dttrc * rn\_rdt} when the default  leapfrog time-stepping scheme is employed).
+
+Currently the 1-dimensional reference depth of the grid boxes is used rather than the dynamically evolving depth to determine whether the age tracer is incremented or relaxed to zero.
+This means that the tracer only works correctly in z-coordinates.
+To ensure that the forcing is independent of the level thicknesses, where the tracer cell at level $k$ has its upper face $z=-depw(k)$ above the depth $-H_{\mathrm{Age}}$, but its lower face $z=-depw(k+1)$ below that depth, then the age source
+
+\begin{equation}
   \label{eq:TOP-age-mixed}
    \mathrm{SMS_{\mathrm{Age}}} = -f_{\mathrm{kill}}\lambda_{\mathrm{Age}}A +f_{\mathrm{add}}/T_{\mathrm{year}} ,
- \end{equation}
- where
- \begin{align}
+\end{equation}
+
+where
+
+\begin{align}
     f_{\mathrm{kill}} &= e3t_k^{-1}(H_{\mathrm{Age}} - depw(k)) , \\
     f_{\mathrm{add}} &= 1 - f_{\mathrm{kill}}.
- \end{align}
-
-
- This implementation was first used in the CORE-II intercomparison runs described e.g.\ in \citet{danabasoglu_2014}.
+\end{align}
+
+
+This implementation was first used in the CORE-II intercomparison runs described e.g.\ in \citet{danabasoglu_2014}.
 
 \subsection{Inert carbons tracer}
@@ -155,10 +180,14 @@
 
 Chlorofluorocarbons 11 and 12 (CFC-11 and CFC-12), and sulfur hexafluoride (SF6), are synthetic chemicals manufactured for industrial and domestic applications from the early 20th century onwards.
-CFC-11 (CCl$_{3}$F) is a volatile liquid at room temperature, and was widely used in refrigeration. CFC-12 (CCl$_{2}$F$_{2}$) is a gas at room temperature, and, like CFC-11, was widely used as a refrigerant,
-and additionally as an aerosol propellant. SF6 (SF$_{6}$) is also a gas at room temperature, with a range of applications based around its property as an excellent electrical insulator (often replacing more toxic alternatives).
-All three are relatively inert chemicals that are both non-toxic and non-flammable, and their wide use has led to their accumulation within the Earth's atmosphere. Large-scale production of CFC-11 and CFC-12 began in the 1930s, while production of SF6 began in the 1950s, and their atmospheric concentration time-histories are shown in Figure \ref{img_cfcatm}.
+CFC-11 (CCl$_{3}$F) is a volatile liquid at room temperature, and was widely used in refrigeration.
+CFC-12 (CCl$_{2}$F$_{2}$) is a gas at room temperature, and, like CFC-11, was widely used as a refrigerant,
+and additionally as an aerosol propellant.
+SF6 (SF$_{6}$) is also a gas at room temperature, with a range of applications based around its property as an excellent electrical insulator (often replacing more toxic alternatives).
+All three are relatively inert chemicals that are both non-toxic and non-flammable, and their wide use has led to their accumulation within the Earth's atmosphere.
+Large-scale production of CFC-11 and CFC-12 began in the 1930s, while production of SF6 began in the 1950s, and their atmospheric concentration time-histories are shown in Figure \autoref{img_cfcatm}.
 As can be seen in the figure, while the concentration of SF6 continues to rise to the present  day, the concentrations of both CFC-11 and CFC-12 have levelled off and declined since around the 1990s.
 These declines have been driven by the Montreal Protocol (effective since August 1989), which has banned the production of CFC-11 and CFC-12 (as well as other CFCs) because of their role in the depletion of
-stratospheric ozone (O$_{3}$), critical in decreasing the flux of ultraviolet radiation to the Earth's surface. Separate to this role in ozone-depletion, all three chemicals are significantly more potent greenhouse gases
+stratospheric ozone (O$_{3}$), critical in decreasing the flux of ultraviolet radiation to the Earth's surface.
+Separate to this role in ozone-depletion, all three chemicals are significantly more potent greenhouse gases
 than CO$_{2}$ (especially SF6), although their relatively low atmospheric concentrations limit their role in climate change. \\
 
@@ -171,5 +200,5 @@
 % This release began in the 1930s for CFC-11 and CFC-12, and the 1950s for SF6, and
 % regularly increasing their atmospheric concentration until the 1090s, 2000s for respectively CFC11, CFC12,
-% and is still increasing, and SF6 (see Figure \ref{img_cfcatm}).  \\
+% and is still increasing, and SF6 (see Figure \autoref{img_cfcatm}).  \\
 
 The ocean is a notable sink for all three gases, and their relatively recent occurrence in the atmosphere, coupled to the ease of making high precision measurements of their dissolved concentrations, has made them
@@ -177,8 +206,10 @@
 Because they only enter the ocean via surface air-sea exchange, and are almost completely chemically and biologically inert, their distribution within the ocean interior reveals its ventilation via transport and mixing.
 Measuring the dissolved concentrations of the gases -- as well as the mixing ratios between them -- shows circulation pathways within the ocean as well as water mass ages (i.e. the time since last contact with the
-atmosphere). This feature of the gases has made them valuable across a wide range of oceanographic problems. One use lies in ocean modelling, where they can be used to evaluate the realism of the circulation and
+atmosphere).
+This feature of the gases has made them valuable across a wide range of oceanographic problems.
+One use lies in ocean modelling, where they can be used to evaluate the realism of the circulation and
 ventilation of models, key for understanding the behaviour of wider modelled marine biogeochemistry (e.g. \citep{dutay_2002,palmieri_2015}). \\
 
-Modelling these gases (henceforth CFCs) in NEMO is done within the passive tracer transport module, TOP, using the conservation state equation \ref{Eq_tracer}
+Modelling these gases (henceforth CFCs) in NEMO is done within the passive tracer transport module, TOP, using the conservation state equation \autoref{Eq_tracer}
 
 Advection and diffusion of the CFCs in NEMO are calculated by the physical module, OPA,
@@ -198,6 +229,6 @@
 \end{eqnarray}
 
-Where $K_{w}$ is the piston velocity (in m~s$^{-1}$), as defined in Equation \ref{equ_Kw};
-$C_{sat}$ is the saturation concentration of the CFC tracer, as defined in Equation \ref{equ_C_sat};
+Where $K_{w}$ is the piston velocity (in m~s$^{-1}$), as defined in Equation \autoref{equ_Kw};
+$C_{sat}$ is the saturation concentration of the CFC tracer, as defined in Equation \autoref{equ_C_sat};
 $C_{surf}$ is the local surface concentration of the CFC tracer within the model (in mol~m$^{-3}$);
 and $f_{i}$ is the fractional sea-ice cover of the local ocean (ranging between 0.0 for ice-free ocean,
@@ -211,5 +242,5 @@
 \end{eqnarray}
 
-Where $Sol$ is the gas solubility in mol~m$^{-3}$~pptv$^{-1}$, as defined in Equation \ref{equ_Sol_CFC};
+Where $Sol$ is the gas solubility in mol~m$^{-3}$~pptv$^{-1}$, as defined in Equation \autoref{equ_Sol_CFC};
 and $P_{cfc}$ is the atmosphere concentration of the CFC (in parts per trillion by volume, pptv).
 This latter concentration is provided to the model by the historical time-series of \citet{bullister_2017}.
@@ -231,5 +262,5 @@
 $a$ is a constant re-estimated by \citet{wanninkhof_2014} to 0.251 (in $\frac{cm~h^{-1}}{(m~s^{-1})^{2}}$);
 and $u$ is the 10~m wind speed in m~s$^{-1}$ from either an atmosphere model or reanalysis atmospheric forcing.
-$Sc$ is the Schmidt number, and is calculated as follow, using coefficients from \citet{wanninkhof_2014} (see Table \ref{tab_Sc}).
+$Sc$ is the Schmidt number, and is calculated as follow, using coefficients from \citet{wanninkhof_2014} (see Table \autoref{tab_Sc}).
 
 \begin{eqnarray}
@@ -238,5 +269,5 @@
 \end{eqnarray}
 
-The solubility, $Sol$, used in Equation \ref{equ_C_sat} is calculated in mol~l$^{-1}$~atm$^{-1}$,
+The solubility, $Sol$, used in Equation \autoref{equ_C_sat} is calculated in mol~l$^{-1}$~atm$^{-1}$,
 and is specific for each gas.
 It has been experimentally estimated by \citet{warner_1985} as a function of temperature
@@ -260,13 +291,13 @@
 
 Where $T_{X}$ is $\frac{T + 273.16}{100}$, a function of temperature;
-and the $a_{x}$ and $b_{x}$ coefficients are specific for each gas (see Table \ref{tab_ref_CFC}).
+and the $a_{x}$ and $b_{x}$ coefficients are specific for each gas (see Table \autoref{tab_ref_CFC}).
 This is then converted to mol~m$^{-3}$~pptv$^{-1}$ assuming a constant atmospheric surface pressure of 1~atm.
 The solubility of CFCs thus decreases with rising $T$ while being relatively insensitive to salinity changes.
-Consequently, this translates to a pattern of solubility where it is greatest in cold, polar regions (see Figure \ref{img_cfcsol}).
+Consequently, this translates to a pattern of solubility where it is greatest in cold, polar regions (see Figure \autoref{img_cfcsol}).
 
 % AXY: not 100% sure about the units below; they might be in nanomol, or in seconds or years
 
 The standard outputs of the CFC module are seawater CFC concentrations (in mol~m$^{-3}$), the net air-sea flux (in mol~m$^{-2}$~d$^{-1}$) and the cumulative net air-sea flux (in mol~m$^{-2}$).
-Using XIOS, it is possible to obtain outputs such as the vertical integral of CFC concentrations (in mol~m$^{-2}$; see Figure \ref{img_cfcinv}).
+Using XIOS, it is possible to obtain outputs such as the vertical integral of CFC concentrations (in mol~m$^{-2}$; see Figure \autoref{img_cfcinv}).
 This property, when divided by the surface CFC concentration, estimates the local penetration depth (in m) of the CFC.
 
@@ -285,5 +316,5 @@
 
 \begin{table}[!t]
-\caption{Coefficients for fit of the CFCs solubility (Eq. \ref{equ_Sol_CFC}).}
+\caption{Coefficients for fit of the CFCs solubility (Eq. \autoref{equ_Sol_CFC}).}
 \vskip4mm
 \centering
@@ -302,5 +333,5 @@
 
 \begin{table}[!t]
-\caption{Coefficients for fit of the CFCs Schmidt number (Eq. \ref{equ_Sc}). }
+\caption{Coefficients for fit of the CFCs Schmidt number (Eq. \autoref{equ_Sc}). }
 \vskip4mm
 \centering
@@ -353,19 +384,28 @@
 %----------------------------------------------------------------------------------------------------------
 
-The C14 package implemented in NEMO by Anne Mouchet models ocean $\Dcq$. It offers several possibilities: $\Dcq$ as a physical tracer of the ocean ventilation (natural $\cq$), assessment of bomb radiocarbon uptake, as well as transient studies of paleo-historical ocean radiocarbon distributions.
+The C14 package implemented in NEMO by Anne Mouchet models ocean $\Dcq$.
+It offers several possibilities: $\Dcq$ as a physical tracer of the ocean ventilation (natural $\cq$), assessment of bomb radiocarbon uptake, as well as transient studies of paleo-historical ocean radiocarbon distributions.
 
 \subsubsection{Method}
 
- Let  $\Rq$ represent the ratio of $\cq$ atoms to the total number of carbon atoms in the sample, i.e. $\cq/\mathrm{C}$. Then, radiocarbon anomalies are reported as
+Let  $\Rq$ represent the ratio of $\cq$ atoms to the total number of carbon atoms in the sample, i.e. $\cq/\mathrm{C}$.
+Then, radiocarbon anomalies are reported as
+
 \begin{equation}
 \Dcq = \left( \frac{\Rq}{\Rq_\mathrm{ref}} - 1 \right) 10^3, \label{eq:c14dcq}
 \end{equation}
-where $\Rq_{\textrm{ref}}$ is a reference ratio. For the purpose of ocean ventilation studies $\Rq_{\textrm{ref}}$ is set to one.
+
+where $\Rq_{\textrm{ref}}$ is a reference ratio.
+For the purpose of ocean ventilation studies $\Rq_{\textrm{ref}}$ is set to one.
 
 Here we adopt the approach of \cite{fiadeiro_1982} and \cite{toggweiler_1989a,toggweiler_1989b} in which  the ratio $\Rq$ is transported rather than the individual concentrations C and $\cq$.
-This approach calls for a strong assumption, i.e., that of a homogeneous and constant dissolved inorganic carbon (DIC) field \citep{toggweiler_1989a,mouchet_2013}. While in terms of
-oceanic $\Dcq$, it yields similar results to approaches involving carbonate chemistry, it underestimates the bomb radiocarbon inventory because it assumes a constant air-sea $\cd$ disequilibrium (Mouchet, 2013). Yet, field reconstructions of the ocean bomb $\cq$ inventory are also biased low \citep{naegler_2009} since they assume that the anthropogenic perturbation did not affect ocean DIC since the pre-bomb epoch. For these reasons, bomb $\cq$ inventories obtained with the present method are directly comparable to reconstructions based on field measurements.
-
-This simplified approach also neglects the effects of fractionation (e.g.,  air-sea exchange) and of biological processes. Previous studies by \cite{bacastow_1990} and \cite{joos_1997} resulted in nearly identical $\Dcq$ distributions among experiments considering biology or not.
+This approach calls for a strong assumption, i.e., that of a homogeneous and constant dissolved inorganic carbon (DIC) field \citep{toggweiler_1989a,mouchet_2013}.
+While in terms of
+oceanic $\Dcq$, it yields similar results to approaches involving carbonate chemistry, it underestimates the bomb radiocarbon inventory because it assumes a constant air-sea $\cd$ disequilibrium (Mouchet, 2013).
+Yet, field reconstructions of the ocean bomb $\cq$ inventory are also biased low \citep{naegler_2009} since they assume that the anthropogenic perturbation did not affect ocean DIC since the pre-bomb epoch.
+For these reasons, bomb $\cq$ inventories obtained with the present method are directly comparable to reconstructions based on field measurements.
+
+This simplified approach also neglects the effects of fractionation (e.g.,  air-sea exchange) and of biological processes.
+Previous studies by \cite{bacastow_1990} and \cite{joos_1997} resulted in nearly identical $\Dcq$ distributions among experiments considering biology or not.
 Since observed $\Rq$ ratios are corrected for the isotopic fractionation when converted to the standard $\Dcq$ notation \citep{stuiver_1977} the model results are directly comparable to observations.
 
@@ -373,28 +413,37 @@
 
 The equation governing the transport of $\Rq$  in the ocean is
+
 \begin{equation}
 \frac{\partial}{\partial t} {\Rq} =  - \bigtriangledown \cdot ( \mathbf{u} \Rq - \mathbf{K} \cdot \bigtriangledown \Rq )  - \lambda \Rq, \label{eq:quick}
 \end{equation}
+
 where $\lambda$ is the radiocarbon decay rate, ${\mathbf{u}}$ the 3-D velocity field, and $\mathbf{K}$ the diffusivity tensor.
 
-At the air-sea interface a Robin boundary condition \citep{haine_2006} is applied to \eqref{eq:quick}, i.e., the flux
+At the air-sea interface a Robin boundary condition \citep{haine_2006} is applied to \autoref{eq:quick}, i.e., the flux
 through the interface is proportional to the difference in the ratios between
 the ocean and the atmosphere
+
 \begin{equation}
 \mathcal{\!F} =  \kappa_{R}  (\Rq  - \Rq_{a} ), \label{eq:BCR}
 \end{equation}
-where $\mathcal{\!F}$ is the flux out of the ocean, and $\Rq_{a}$ is the atmospheric $\cq/\mathrm{C}$ ratio. The transfer velocity $ \kappa_{R} $ for the radiocarbon ratio in \eqref{eq:BCR} is computed as
+
+where $\mathcal{\!F}$ is the flux out of the ocean, and $\Rq_{a}$ is the atmospheric $\cq/\mathrm{C}$ ratio.
+The transfer velocity $ \kappa_{R} $ for the radiocarbon ratio in \autoref{eq:BCR} is computed as
+
 \begin{equation}
  \kappa_{R} =  \frac{\kappa_{\cd} K_0}{\overline{\Ct}} \, \pacd   \label{eq:Rspeed}
 \end{equation}
+
 with $\kappa_{\cd}$ the carbon dioxide transfer or piston velocity, $K_0$ the $\cd$ solubility in seawater, $\pacd$ the atmospheric $\cd$ pressure at sea level, and $\overline{\Ct}$ the average sea-surface dissolved inorganic carbon concentration.
 
-
-The $\cd$ transfer velocity is based on the empirical formulation of \cite{wanninkhof_1992} with chemical enhancement \citep{wanninkhof_1996,wanninkhof_2014}. The original formulation is modified to account for the reduction of the  air-sea exchange rate in the presence of sea ice. Hence
+The $\cd$ transfer velocity is based on the empirical formulation of \cite{wanninkhof_1992} with chemical enhancement \citep{wanninkhof_1996,wanninkhof_2014}.
+The original formulation is modified to account for the reduction of the  air-sea exchange rate in the presence of sea ice.
+Hence
+
 \begin{equation}
 \kappa_\cd=\left( K_W\,\mathrm{w}^2 + b  \right)\, (1-f_\mathrm{ice})\,\sqrt{660/Sc}, \label{eq:wanc14}
 \end{equation}
 with $\mathrm{w}$ the wind magnitude, $f_\mathrm{ice}$ the fractional ice cover, and $Sc$ the Schmidt number.
-$K_W$ in \eqref{eq:wanc14} is an empirical coefficient with dimension of an inverse velocity.
+$K_W$ in \autoref{eq:wanc14} is an empirical coefficient with dimension of an inverse velocity.
 The chemical enhancement term $b$ is represented as a function of temperature $T$ \citep{wanninkhof_1992}
 \begin{equation}
@@ -402,5 +451,5 @@
 \end{equation}
 
-%We compare the results of equilibrium and transient experiments obtained with both methods in section \ref{sec:UNDEU}.
+%We compare the results of equilibrium and transient experiments obtained with both methods in section \autoref{sec:UNDEU}.
 
 %
@@ -413,35 +462,41 @@
 \label{sec:param}
  %
-The radiocarbon decay rate (\CODE{rlam14}; in \texttt{trcnam\_c14} module) is set to $\lambda=(1/8267)$ yr$^{-1}$ \citep{stuiver_1977}, which corresponds to a half-life of 5730 yr.\\[1pt]
-%
-The Schmidt number $Sc$, Eq. \eqref{eq:wanc14}, is calculated with the help of the formulation of \cite{wanninkhof_2014}. The $\cd$ solubility $K_0$ in \eqref{eq:Rspeed} is taken from \cite{weiss_1974}. $K_0$ and $Sc$ are computed with the OGCM temperature and salinity fields (\texttt{trcsms\_c14} module).\\[1pt]
+The radiocarbon decay rate (\forcode{rlam14}; in \texttt{trcnam\_c14} module) is set to $\lambda=(1/8267)$ yr$^{-1}$ \citep{stuiver_1977}, which corresponds to a half-life of 5730 yr.\\[1pt]
+%
+The Schmidt number $Sc$, Eq. \autoref{eq:wanc14}, is calculated with the help of the formulation of \cite{wanninkhof_2014}.
+The $\cd$ solubility $K_0$ in \autoref{eq:Rspeed} is taken from \cite{weiss_1974}. $K_0$ and $Sc$ are computed with the OGCM temperature and salinity fields (\texttt{trcsms\_c14} module).\\[1pt]
 %
 The following parameters intervening in the air-sea exchange rate are set in \texttt{namelist\_c14}:
+
 \begin{itemize}
-\item The reference DIC concentration $\overline{\Ct}$ (\CODE{xdicsur}) intervening in \eqref{eq:Rspeed} is classically set to 2 mol m$^{-3}$ \citep{toggweiler_1989a,orr_2001,butzin_2005}.
-%
-\item The value of the empirical coefficient $K_W$ (\CODE{xkwind}) in \eqref{eq:wanc14} depends on the wind field and on the model upper ocean mixing rate \citep{toggweiler_1989a,wanninkhof_1992,naegler_2009,wanninkhof_2014}.
+\item The reference DIC concentration $\overline{\Ct}$ (\forcode{xdicsur}) intervening in \autoref{eq:Rspeed} is classically set to 2 mol m$^{-3}$ \citep{toggweiler_1989a,orr_2001,butzin_2005}.
+%
+\item The value of the empirical coefficient $K_W$ (\forcode{xkwind}) in \autoref{eq:wanc14} depends on the wind field and on the model upper ocean mixing rate \citep{toggweiler_1989a,wanninkhof_1992,naegler_2009,wanninkhof_2014}.
 It should be adjusted so that the globally averaged $\cd$ piston velocity is $\kappa_\cd = 16.5\pm 3.2$ cm/h \citep{naegler_2009}.
-%The sensitivity to this parametrization is discussed in section \ref{sec:result}.
-%
-\item Chemical enhancement (term $b$  in Eq. \ref{eq:wanchem}) may be set on/off by means of the logical variable \CODE{ln\_chemh}.
+%The sensitivity to this parametrization is discussed in section \autoref{sec:result}.
+%
+\item Chemical enhancement (term $b$  in Eq. \autoref{eq:wanchem}) may be set on/off by means of the logical variable \forcode{ln\_chemh}.
 \end{itemize}
 
 %
 \paragraph{Experiment type}
-The type of experiment is determined by the value given to \CODE{kc14typ} in \texttt{namelist\_c14}. There are three possibilities:
+The type of experiment is determined by the value given to \forcode{kc14typ} in \texttt{namelist\_c14}.
+There are three possibilities:
+
 \begin{enumerate}
-\item natural $\Dcq$: \CODE{kc14typ}=0
-\item bomb $\Dcq$: \CODE{kc14typ}=1
-\item transient paleo-historical $\Dcq$: \CODE{kc14typ}=2
+\item natural                    $\Dcq$: \forcode{kc14typ}=0
+\item bomb                       $\Dcq$: \forcode{kc14typ}=1
+\item transient paleo-historical $\Dcq$: \forcode{kc14typ}=2
 \end{enumerate}
-%
+
+% 
 \textbf{Natural or Equilibrium radiocarbon}
-\CODE{kc14typ}=0
-
-Unless otherwise specified in \texttt{namelist\_c14}, the atmospheric $\Rq_a$ (\CODE{rc14at}) is set to one, the atmospheric $\cd$ (\CODE{pco2at}) to 280 ppm, and the ocean $\Rq$ is initialized with \CODE{rc14init=0.85}, i.e., $\Dcq=$-150\textperthousand  \cite[typical for deep-ocean, Fig 6 in][]{key_2004}.
-
-Equilibrium experiment should last until 98\% of the ocean volume exhibit a drift of less than 0.001\textperthousand/year \citep{orr_2000}; this is usually achieved after few kyr (Fig. \ref{fig:drift}).
-%
+\forcode{kc14typ}=0
+
+Unless otherwise specified in \texttt{namelist\_c14}, the atmospheric $\Rq_a$ (\forcode{rc14at}) is set to one, the atmospheric $\cd$ (\forcode{pco2at}) to 280 ppm, and the ocean $\Rq$ is initialized with \forcode{rc14init=0.85}, i.e., $\Dcq=$-150\textperthousand \cite[typical for deep-ocean, Fig 6 in][]{key_2004}.
+
+Equilibrium experiment should last until 98\% of the ocean volume exhibit a drift of less than 0.001\textperthousand/year \citep{orr_2000}; this is usually achieved after few kyr (Fig. \autoref{fig:drift}).
+%
+
 \begin{figure}[!h]
 \begin{center}
@@ -449,10 +504,12 @@
 \end{center}
 \vspace{-4ex}
-\caption{ Time evolution of $\Rq$ inventory anomaly for equilibrium run with homogeneous ocean initial state. The anomaly (or drift) is given in \%  change in total ocean inventory per 50 years. Time on x-axis is in simulation year.\label{fig:drift} }
+\caption{ Time evolution of $\Rq$ inventory anomaly for equilibrium run with homogeneous ocean initial state.
+The anomaly (or drift) is given in \%  change in total ocean inventory per 50 years.
+Time on x-axis is in simulation year.\label{fig:drift} }
 \end{figure}
 
 \textbf{Transient: Bomb}
 \label{sec:bomb}
-\CODE{kc14typ}=1
+\forcode{kc14typ}=1
 
 \begin{figure}[!h]
@@ -461,27 +518,35 @@
 \end{center}
 \vspace{-4ex}
-\caption{Atmospheric $\Dcq$ (solid; left axis) and $\cd$ (dashed; right axis)  forcing for the $\cq$-bomb experiments. The $\Dcq$ is illustrated for the three zonal bands (upper, middle, and lower curves correspond to latitudes $> 20$N, $\in [20\mathrm{S},20\mathrm{N}]$, and $< 20$S, respectively.} \label{fig:bomb}
+\caption{Atmospheric $\Dcq$ (solid; left axis) and $\cd$ (dashed; right axis)  forcing for the $\cq$-bomb experiments.
+The $\Dcq$ is illustrated for the three zonal bands (upper, middle, and lower curves correspond to latitudes $> 20$N, $\in [20\mathrm{S},20\mathrm{N}]$, and $< 20$S, respectively.} \label{fig:bomb}
 \end{figure}
 
-Performing this type of experiment requires that a pre-industrial equilibrium run be performed beforehand (\CODE{ln\_rsttr} should be set to \texttt{.TRUE.}).
-
-An exception to this rule is when wishing to perform a perturbation bomb experiment as was possible with the package \texttt{C14b}. It is still possible to easily set-up that type of transient experiment for which no previous run is needed.  In addition to the instructions as given in this section it is however necessary to adapt the \texttt{atmc14.dat} file so that it does no longer contain any negative $\Dcq$ values (Suess effect in the pre-bomb period).
-
-The model  is integrated from a given initial date following the observed records provided from 1765 AD on ( Fig. \ref{fig:bomb}).
-The file \texttt{atmc14.dat}  \cite[][\& I. Levin, personal comm.]{enting_1994} provides atmospheric $\Dcq$ for three latitudinal bands: 90S-20S,    20S-20N \&    20N-90N.
-Atmospheric $\cd$ in the file \texttt{splco2.dat} is obtained from a spline fit through ice core data and direct atmospheric measurements \cite[][\& J. Orr, personal comm.]{orr_2000}.
+Performing this type of experiment requires that a pre-industrial equilibrium run be performed beforehand (\forcode{ln\_rsttr} should be set to \texttt{.TRUE.}).
+
+An exception to this rule is when wishing to perform a perturbation bomb experiment as was possible with the package \texttt{C14b}.
+It is still possible to easily set-up that type of transient experiment for which no previous run is needed.
+In addition to the instructions as given in this section it is however necessary to adapt the \texttt{atmc14.dat} file so that it does no longer contain any negative $\Dcq$ values (Suess effect in the pre-bomb period).
+
+The model  is integrated from a given initial date following the observed records provided from 1765 AD on ( Fig. \autoref{fig:bomb}).
+The file \texttt{atmc14.dat}  \cite[][\& I.
+Levin, personal comm.]{enting_1994} provides atmospheric $\Dcq$ for three latitudinal bands: 90S-20S,    20S-20N \&    20N-90N.
+Atmospheric $\cd$ in the file \texttt{splco2.dat} is obtained from a spline fit through ice core data and direct atmospheric measurements \cite[][\& J.
+Orr, personal comm.]{orr_2000}.
 Dates in these forcing files are expressed as yr AD.
 
 To ensure that the atmospheric forcing is applied properly as well as that output files contain consistent dates and inventories the experiment should be set up carefully:
+
 \begin{itemize}
-\item Specify the starting date of the experiment: \CODE{nn\_date0} in \texttt{namelist}.  \CODE{nn\_date0} is written as Year0101 where Year may take any positive value (AD).
-\item Then the parameters \CODE{nn\_rstctl} in  \texttt{namelist} (on-line) and \CODE{nn\_rsttr} in \texttt{namelist\_top} (off-line)  must be \textbf{set to 0} at the start of the experiment (force the date to \CODE{nn\_date0} for the \textbf{first} experiment year).
-\item These two parameters (\CODE{nn\_rstctl} and \CODE{nn\_rsttr}) have then to be \textbf{set to 2} for the following years (the date must be read in the restart file).
+\item Specify the starting date of the experiment: \forcode{nn\_date0} in \texttt{namelist}.  \forcode{nn\_date0} is written as Year0101 where Year may take any positive value (AD).
+\item Then the parameters \forcode{nn\_rstctl} in  \texttt{namelist} (on-line) and \forcode{nn\_rsttr} in \texttt{namelist\_top} (off-line)  must be \textbf{set to 0} at the start of the experiment (force the date to \forcode{nn\_date0} for the \textbf{first} experiment year).
+\item These two parameters (\forcode{nn\_rstctl} and \forcode{nn\_rsttr}) have then to be \textbf{set to 2} for the following years (the date must be read in the restart file).
 \end{itemize}
- If the experiment date is outside the data time span then the first or last atmospheric concentrations are prescribed depending on whether the date is earlier or later. Note that \CODE{tyrc14\_beg} (\texttt{namelist\_c14}) is not used in this context.
+
+If the experiment date is outside the data time span then the first or last atmospheric concentrations are prescribed depending on whether the date is earlier or later.
+Note that \forcode{tyrc14\_beg} (\texttt{namelist\_c14}) is not used in this context.
 
 %
 \textbf{Transient: Past}
-\CODE{kc14typ}=2
+\forcode{kc14typ}=2
 %
 \begin{figure}[!h]
@@ -490,43 +555,52 @@
 \end{center}
 \vspace{-4ex}
-\caption{Atmospheric $\Dcq$ (solid) and $\cd$ (dashed)  forcing for the Paleo experiments. The $\cd$ scale is given on the right axis.} \label{fig:paleo}
+\caption{Atmospheric $\Dcq$ (solid) and $\cd$ (dashed)  forcing for the Paleo experiments.
+The $\cd$ scale is given on the right axis.} \label{fig:paleo}
 \end{figure}
 
-This experiment type does not need a previous equilibrium run. It should start 5--6 kyr earlier than the period to be analyzed.
-Atmospheric $\Rq_a$ and $\cd$ are prescribed from forcing files. The ocean $\Rq$ is initialized with the value attributed to \CODE{rc14init} in \texttt{namelist\_c14}.
+This experiment type does not need a previous equilibrium run.
+It should start 5--6 kyr earlier than the period to be analyzed.
+Atmospheric $\Rq_a$ and $\cd$ are prescribed from forcing files.
+The ocean $\Rq$ is initialized with the value attributed to \forcode{rc14init} in \texttt{namelist\_c14}.
 
 The file \texttt{intcal13.14c} \citep{reimer_2013} contains atmospheric $\Dcq$ from 0 to 50 kyr cal BP\footnote{cal BP: number of years before 1950 AD}.
-The $\cd$ forcing is provided in file \texttt{ByrdEdcCO2.txt}. The content of this file is based on  the high resolution record from EPICA Dome C \citep{monnin_2004} for the Holocene and the Transition, and on Byrd Ice Core CO2 Data for 20--90 kyr BP  \citep{ahn_2008}. These atmospheric values are reproduced in Fig. \ref{fig:paleo}. Dates in these files are expressed as yr BP.
+The $\cd$ forcing is provided in file \texttt{ByrdEdcCO2.txt}.
+The content of this file is based on  the high resolution record from EPICA Dome C \citep{monnin_2004} for the Holocene and the Transition, and on Byrd Ice Core CO2 Data for 20--90 kyr BP  \citep{ahn_2008}.
+These atmospheric values are reproduced in Fig. \autoref{fig:paleo}.
+Dates in these files are expressed as yr BP.
 
 To ensure that the atmospheric forcing is applied properly as well as that output files contain consistent dates and inventories the experiment should be set up carefully.
-The true experiment starting date is given by \CODE{tyrc14\_beg} (in yr BP) in \texttt{namelist\_c14}. In consequence, \CODE{nn\_date0} in \texttt{namelist} MUST be set to 00010101.\\
-Then the parameters \CODE{nn\_rstctl} in  \texttt{namelist} (on-line) and \CODE{nn\_rsttr} in \texttt{namelist\_top} (off-line)  must be set to 0 at the start of the experiment (force the date to \CODE{nn\_date0} for the first experiment year). These two parameters have then to be set to 2 for the following years (read the date in the restart file). \\
- If the experiment date is outside the data time span then the first or last atmospheric concentrations are prescribed depending on whether the date is earlier or later.
+The true experiment starting date is given by \forcode{tyrc14\_beg} (in yr BP) in \texttt{namelist\_c14}.
+In consequence, \forcode{nn\_date0} in \texttt{namelist} MUST be set to 00010101.\\
+Then the parameters \forcode{nn\_rstctl} in  \texttt{namelist} (on-line) and \forcode{nn\_rsttr} in \texttt{namelist\_top} (off-line)  must be set to 0 at the start of the experiment (force the date to \forcode{nn\_date0} for the first experiment year).
+These two parameters have then to be set to 2 for the following years (read the date in the restart file). \\
+If the experiment date is outside the data time span then the first or last atmospheric concentrations are prescribed depending on whether the date is earlier or later.
 
 %
 \paragraph{Model output}
 \label{sec:output}
-All output fields in Table \ref{tab:out} are routinely computed. It depends on the actual settings in \texttt{iodef.xml} whether they are stored or not.
+
+All output fields in Table \autoref{tab:out} are routinely computed.
+It depends on the actual settings in \texttt{iodef.xml} whether they are stored or not.
 %
 \begin{table}[!h]
 \begin{center}
-\caption{Standard output fields for the C14 package \label{tab:out}.
-}
+\caption{Standard output fields for the C14 package \label{tab:out}.}
 %\begin{small}
 \renewcommand{\arraystretch}{1.3}%
 \begin{tabular}[h]{|l*{3}{|c}|l|}
 \hline
-Field & Type & Dim & Units & Description \\ \hline
-RC14 & ptrc & 3-D & -        & Radiocarbon ratio \\
-DeltaC14 & diad & 3-D & \textperthousand & $\Dcq$\\
-C14Age & diad & 3-D & yr &   Radiocarbon age \\
-RAge & diad & 2-D & yr & Reservoir age\\
-qtr\_c14 &  diad & 2-D & m$^{-2}$ yr$^{-1}$ & Air-to-sea net $\Rq$ flux\\
-qint\_c14 & diad & 2-D &   m$^{-2}$ &  Cumulative air-to-sea $\Rq$ flux \\
-AtmCO2 & scalar & 0-D & ppm & Global atmospheric $\cd$ \\
-AtmC14 & scalar & 0-D & \textperthousand  & Global atmospheric $\Dcq$\\
-K\_CO2 & scalar & 0-D & cm h$^{-1}$  & Global $\cd$ piston velocity ($ \overline{\kappa_{\cd}}$) \\
-K\_C14 & scalar & 0-D &m yr$^{-1}$ & Global $\Rq$ transfer velocity  ($ \overline{\kappa_R}$)\\
-C14Inv & scalar & 0-D & $10^{26}$ atoms & Ocean radiocarbon inventory \\ \hline
+Field     & Type   & Dim & Units              & Description                                               \\ \hline
+RC14      & ptrc   & 3-D & -                  & Radiocarbon ratio                                         \\
+DeltaC14  & diad   & 3-D & \textperthousand   & $\Dcq$                                                    \\
+C14Age    & diad   & 3-D & yr                 & Radiocarbon age                                           \\
+RAge      & diad   & 2-D & yr                 & Reservoir age                                             \\
+qtr\_c14  & diad   & 2-D & m$^{-2}$ yr$^{-1}$ & Air-to-sea net $\Rq$ flux                                 \\
+qint\_c14 & diad   & 2-D & m$^{-2}$           & Cumulative air-to-sea $\Rq$ flux                          \\
+AtmCO2    & scalar & 0-D & ppm                & Global atmospheric $\cd$                                  \\
+AtmC14    & scalar & 0-D & \textperthousand   & Global atmospheric $\Dcq$                                 \\
+K\_CO2    & scalar & 0-D & cm h$^{-1}$        & Global $\cd$ piston velocity ($ \overline{\kappa_{\cd}}$) \\
+K\_C14    & scalar & 0-D & m yr$^{-1}$        & Global $\Rq$ transfer velocity  ($ \overline{\kappa_R}$)  \\
+C14Inv    & scalar & 0-D & $10^{26}$ atoms    & Ocean radiocarbon inventory                               \\ \hline
 \end{tabular}
 %\end{small}
@@ -539,20 +613,30 @@
 The radiocarbon age is computed as  $(-1/\lambda) \ln{ \left( \Rq \right)}$, with zero age corresponding to $\Rq=1$.
 
-The reservoir age is the age difference between the ocean uppermost layer and the atmosphere. It is usually reported as conventional radiocarbon age; i.e., computed by means of the Libby radiocarbon mean life \cite[8033 yr;][]{stuiver_1977}
+The reservoir age is the age difference between the ocean uppermost layer and the atmosphere.
+It is usually reported as conventional radiocarbon age; i.e., computed by means of the Libby radiocarbon mean life \cite[8033 yr;][]{stuiver_1977}
+
 \begin{align}
 {^{14}\tau_\mathrm{c}}= -8033 \; \ln \left(1 + \frac{\Dcq}{10^3}\right), \label{eq:convage}
 \end{align}
-where ${^{14}\tau_\mathrm{c}}$ is expressed in years B.P. Here we do not use that convention and compute reservoir ages with the mean lifetime $1/\lambda$. Conversion from one scale to the other is readily performed. The conventional radiocarbon age is lower than the radiocarbon age by $\simeq3\%$.
+
+where ${^{14}\tau_\mathrm{c}}$ is expressed in years B.P.
+Here we do not use that convention and compute reservoir ages with the mean lifetime $1/\lambda$.
+Conversion from one scale to the other is readily performed.
+The conventional radiocarbon age is lower than the radiocarbon age by $\simeq3\%$.
 
 The ocean radiocarbon  inventory is computed as
+
 \begin{equation}
 N_A \Rq_\mathrm{oxa} \overline{\Ct} \left( \int_\Omega \Rq d\Omega \right) /10^{26}, \label{eq:inv}
 \end{equation}
-where $N_A$ is the Avogadro's number ($N_A=6.022\times10^{23}$ at/mol), $\Rq_\mathrm{oxa}$ is the oxalic acid radiocarbon standard \cite[$\Rq_\mathrm{oxa}=1.176\times10^{-12}$;][]{stuiver_1977}, and $\Omega$ is the ocean volume.  Bomb $\cq$ inventories are traditionally reported in units of $10^{26}$ atoms, hence the denominator in \eqref{eq:inv}.
-
-All transformations from second to year, and inversely, are performed with the help of the physical constant \CODE{rsiyea} the sideral year length expressed in seconds\footnote{The variable (\CODE{nyear\_len}) which reports the length in days of the previous/current/future year (see \textrm{oce\_trc.F90}) is not a constant. }.
+
+where $N_A$ is the Avogadro's number ($N_A=6.022\times10^{23}$ at/mol), $\Rq_\mathrm{oxa}$ is the oxalic acid radiocarbon standard \cite[$\Rq_\mathrm{oxa}=1.176\times10^{-12}$;][]{stuiver_1977}, and $\Omega$ is the ocean volume.
+Bomb $\cq$ inventories are traditionally reported in units of $10^{26}$ atoms, hence the denominator in \autoref{eq:inv}.
+
+All transformations from second to year, and inversely, are performed with the help of the physical constant \forcode{rsiyea} the sideral year length expressed in seconds\footnote{The variable (\forcode{nyear\_len}) which reports the length in days of the previous/current/future year (see \textrm{oce\_trc.F90}) is not a constant. }.
 
 The global transfer velocities represent time-averaged\footnote{the actual duration is set in \texttt{iodef.xml}} global integrals of the transfer rates:
- \begin{equation}
+
+\begin{equation}
  \overline{\kappa_{\cd}}= \int_\mathcal{S} \kappa_{\cd} d\mathcal{S}  \text{ and } \overline{\kappa_R}= \int_\mathcal{S} \kappa_R d\mathcal{S}
 \end{equation}
@@ -561,19 +645,41 @@
 \subsection{PISCES biogeochemical model}
 
-PISCES is a biogeochemical model which simulates the lower trophic levels of marine ecosystem (phytoplankton, microzooplankton and mesozooplankton) and the biogeochemical cycles of carbonand of the main nutrients (P, N, Fe, and Si). The  model is intended to be used for both regional and global configurations at high or low spatial resolutions as well as for  short-term (seasonal, interannual) and long-term (climate change, paleoceanography) analyses.
+PISCES is a biogeochemical model which simulates the lower trophic levels of marine ecosystem (phytoplankton, microzooplankton and mesozooplankton) and the biogeochemical cycles of carbonand of the main nutrients (P, N, Fe, and Si).
+The  model is intended to be used for both regional and global configurations at high or low spatial resolutions as well as for  short-term (seasonal, interannual) and long-term (climate change, paleoceanography) analyses.
 Two versions of PISCES are available in NEMO v4.0 :
 
-PISCES-v2, by setting in namelist\_pisces\_ref  \np{ln\_p4z} to true,  can be seen as one of the many Monod models \citep{monod_1958}. It assumes a constant Redfield ratio and phytoplankton growth depends on the external concentration in nutrients. There are twenty-four prognostic variables (tracers) including two phytoplankton compartments  (diatoms and nanophytoplankton), two zooplankton size-classes (microzooplankton and  mesozooplankton) and a description of the carbonate chemistry. Formulations in PISCES-v2 are based on a mixed Monod/Quota formalism: On one hand, stoichiometry of C/N/P is fixed and growth rate of phytoplankton is limited by the external availability in N, P and Si. On the other hand, the iron and silicium quotas are variable and growth rate of phytoplankton is limited by the internal availability in Fe. Various parameterizations can be activated in PISCES-v2, setting for instance the complexity of iron chemistry or the description of particulate organic materials.
-
-PISCES-QUOTA has been built on the PISCES-v2 model described in \citet{aumont_2015}. PISCES-QUOTA has thirty-nine prognostic compartments. Phytoplankton growth can be controlled by five modeled limiting nutrients: Nitrate and Ammonium, Phosphate, Silicate and Iron. Five living compartments are represented: Three phytoplankton size classes/groups corresponding to picophytoplankton, nanophytoplankton and diatoms, and two zooplankton size classes which are microzooplankton and mesozooplankton. For phytoplankton, the prognostic variables are the carbon, nitrogen, phosphorus,  iron, chlorophyll and silicon biomasses (the latter only for diatoms). This means that the N/C, P/C, Fe/C and Chl/C ratios of both phytoplankton groups as well as the Si/C ratio of diatoms are prognostically predicted  by the model. Zooplankton are assumed to be strictly homeostatic \citep[e.g.,][]{sterner_2003,woods_2013,meunier_2014}. As a consequence, the C/N/P/Fe ratios of these groups are maintained constant and are not allowed to vary. In PISCES, the Redfield ratios C/N/P are set to 122/16/1 \citep{takahashi_1985} and the -O/C ratio is set to 1.34 \citep{kortzinger_2001}. No silicified zooplankton is assumed. The bacterial pool is not yet explicitly modeled.
-
-There are three non-living compartments: Semi-labile dissolved organic matter, small sinking particles, and large sinking particles. As a consequence of the variable stoichiometric ratios of phytoplankton and of the stoichiometric regulation of zooplankton, elemental ratios in organic matter cannot be supposed constant anymore as that was the case in PISCES-v2. Indeed, the nitrogen, phosphorus, iron, silicon and calcite pools of the particles are now all explicitly modeled. The sinking speed of the particles is not altered by their content in calcite and biogenic silicate (''The ballast effect'', \citep{honjo_1996,armstrong_2001}). The latter particles are assumed to sink at the same speed as the large organic matter particles. All the non-living compartments experience aggregation due to turbulence and differential settling as well as Brownian coagulation for DOM.
-
+PISCES-v2, by setting in namelist\_pisces\_ref  \np{ln\_p4z} to true,  can be seen as one of the many Monod models \citep{monod_1958}.
+It assumes a constant Redfield ratio and phytoplankton growth depends on the external concentration in nutrients.
+There are twenty-four prognostic variables (tracers) including two phytoplankton compartments  (diatoms and nanophytoplankton), two zooplankton size-classes (microzooplankton and  mesozooplankton) and a description of the carbonate chemistry.
+Formulations in PISCES-v2 are based on a mixed Monod/Quota formalism: On one hand, stoichiometry of C/N/P is fixed and growth rate of phytoplankton is limited by the external availability in N, P and Si.
+On the other hand, the iron and silicium quotas are variable and growth rate of phytoplankton is limited by the internal availability in Fe.
+Various parameterizations can be activated in PISCES-v2, setting for instance the complexity of iron chemistry or the description of particulate organic materials.
+
+PISCES-QUOTA has been built on the PISCES-v2 model described in \citet{aumont_2015}.
+PISCES-QUOTA has thirty-nine prognostic compartments.
+Phytoplankton growth can be controlled by five modeled limiting nutrients: Nitrate and Ammonium, Phosphate, Silicate and Iron.
+Five living compartments are represented: Three phytoplankton size classes/groups corresponding to picophytoplankton, nanophytoplankton and diatoms, and two zooplankton size classes which are microzooplankton and mesozooplankton.
+For phytoplankton, the prognostic variables are the carbon, nitrogen, phosphorus,  iron, chlorophyll and silicon biomasses (the latter only for diatoms).
+This means that the N/C, P/C, Fe/C and Chl/C ratios of both phytoplankton groups as well as the Si/C ratio of diatoms are prognostically predicted  by the model.
+Zooplankton are assumed to be strictly homeostatic \citep[e.g.,][]{sterner_2003,woods_2013,meunier_2014}.
+As a consequence, the C/N/P/Fe ratios of these groups are maintained constant and are not allowed to vary.
+In PISCES, the Redfield ratios C/N/P are set to 122/16/1 \citep{takahashi_1985} and the -O/C ratio is set to 1.34 \citep{kortzinger_2001}.
+No silicified zooplankton is assumed.
+The bacterial pool is not yet explicitly modeled.
+
+There are three non-living compartments: Semi-labile dissolved organic matter, small sinking particles, and large sinking particles.
+As a consequence of the variable stoichiometric ratios of phytoplankton and of the stoichiometric regulation of zooplankton, elemental ratios in organic matter cannot be supposed constant anymore as that was the case in PISCES-v2.
+Indeed, the nitrogen, phosphorus, iron, silicon and calcite pools of the particles are now all explicitly modeled.
+The sinking speed of the particles is not altered by their content in calcite and biogenic silicate (''The ballast effect'', \citep{honjo_1996,armstrong_2001}).
+The latter particles are assumed to sink at the same speed as the large organic matter particles.
+All the non-living compartments experience aggregation due to turbulence and differential settling as well as Brownian coagulation for DOM.
 
 \subsection{MY\_TRC interface for coupling external BGC models}
 \label{Mytrc}
 
-The NEMO-TOP has only one built-in biogeochemical model - PISCES - but there are several BGC models - MEDUSA, ERSEM, BFM or ECO3M - which are meant to be coupled with the NEMO dynamics. Therefore it was necessary to provide to the users a framework for easily add their own BGCM model, that can be a single passive tracer.
-The generalized interface is pivoted on MY\_TRC module that contains template files to build the coupling between NEMO and any external BGC model. The call to MY\_TRC is activated by setting  \textit{ln\_my\_trc} = \texttt{.true.} in namelist \textit{namtrc}
+The NEMO-TOP has only one built-in biogeochemical model - PISCES - but there are several BGC models - MEDUSA, ERSEM, BFM or ECO3M - which are meant to be coupled with the NEMO dynamics.
+Therefore it was necessary to provide to the users a framework for easily add their own BGCM model, that can be a single passive tracer.
+The generalized interface is pivoted on MY\_TRC module that contains template files to build the coupling between NEMO and any external BGC model.
+The call to MY\_TRC is activated by setting  \textit{ln\_my\_trc} = \texttt{.true.} in namelist \textit{namtrc}
 
 The following 6 fortran files are available in MY\_TRC with the specific purposes here described.
@@ -581,11 +687,15 @@
 \begin{itemize}
    \item \textit{par\_my\_trc.F90} :  This module allows to define additional arrays and public variables to be used within the MY\_TRC interface
-   \item \textit{trcini\_my\_trc.F90} :  Here are initialized user defined namelists and the call to the external BGC model initialization procedures to populate general tracer array (trn and trb). Here are also likely to be defined suport arrays related to system metrics that could be needed by the BGC model.
+   \item \textit{trcini\_my\_trc.F90} :  Here are initialized user defined namelists and the call to the external BGC model initialization procedures to populate general tracer array (trn and trb).
+Here are also likely to be defined suport arrays related to system metrics that could be needed by the BGC model.
   \item \textit{trcnam\_my\_trc.F90} :  This routine is called at the beginning of trcini\_my\_trc and should contain the initialization of additional namelists for the BGC model or user-defined code.
-  \item \textit{trcsms\_my\_trc.F90} :  The routine performs the call to Boundary Conditions and its main purpose is to contain the Source-Minus-Sinks terms due to the biogeochemical processes of the external model. Be aware that lateral boundary conditions are applied in trcnxt routine. IMPORTANT: the routines to compute the light penetration along the water column and the tracer vertical sinking should be defined/called in here, as generalized modules are still missing in the code.
- \item \textit{trcice\_my\_trc.F90} : Here it is possible to prescribe the tracers concentrations in the seaice that will be used as boundary conditions when ice melting occurs (nn\_ice\_tr =1 in namtrc\_ice). See e.g. the correspondent PISCES subroutine.
- \item \textit{trcwri\_my\_trc.F90} : This routine performs the output of the model tracers using IOM module (see Manual Chapter Output and Diagnostics). It is possible to place here the output of additional variables produced by the model, if not done elsewhere in the code, using the call to \textit{iom\_put}.
+  \item \textit{trcsms\_my\_trc.F90} :  The routine performs the call to Boundary Conditions and its main purpose is to contain the Source-Minus-Sinks terms due to the biogeochemical processes of the external model.
+Be aware that lateral boundary conditions are applied in trcnxt routine.
+IMPORTANT: the routines to compute the light penetration along the water column and the tracer vertical sinking should be defined/called in here, as generalized modules are still missing in the code.
+ \item \textit{trcice\_my\_trc.F90} : Here it is possible to prescribe the tracers concentrations in the seaice that will be used as boundary conditions when ice melting occurs (nn\_ice\_tr =1 in namtrc\_ice).
+See e.g. the correspondent PISCES subroutine.
+ \item \textit{trcwri\_my\_trc.F90} : This routine performs the output of the model tracers using IOM module (see Manual Chapter Output and Diagnostics).
+It is possible to place here the output of additional variables produced by the model, if not done elsewhere in the code, using the call to \textit{iom\_put}.
 \end{itemize}
-
 
 \section{The Offline Option}
@@ -596,9 +706,12 @@
 %-------------------------------------------------------------------------------------------------------------
 
-Coupling passive tracers offline with NEMO requires precomputed  physical fields from OGCM. Those fields are read from files and interpolated on-the-fly at each model time step
+Coupling passive tracers offline with NEMO requires precomputed  physical fields from OGCM.
+Those fields are read from files and interpolated on-the-fly at each model time step
 At least the following dynamical parameters should be absolutely passed to the transport : ocean velocities, temperature, salinity, mixed layer depth and for ecosystem models like PISCES, sea ice concentration, short wave radiation at the ocean surface, wind speed (or at least, wind stress).
 The so-called offline mode is useful since it has lower computational costs for example to perform very longer simulations - about 3000 years - to reach equilibrium of CO2 sinks for climate-carbon studies.
 
-The offline interface is located in the code repository : \path{<repository>/src/OFF/}. It is activated by adding the CPP key  \textit{key\_offline} to the CPP keys list. There are two specifics routines for the Offline code :
+The offline interface is located in the code repository : \path{<repository>/src/OFF/}.
+It is activated by adding the CPP key  \textit{key\_offline} to the CPP keys list.
+There are two specifics routines for the Offline code :
 
 \begin{itemize}
@@ -606,5 +719,4 @@
    \item \textit{nemogcm.F90} :  a degraded version of the main nemogcm.F90 code of NEMO to manage the time-stepping
 \end{itemize}
-
 
 %-
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/document.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/document.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/document.tex	(revision 14644)
@@ -1,88 +1,90 @@
-
 %% =================================================================================================
-%% Template structure for reference manuals
+%% Manual structure
 %% =================================================================================================
 
-%% NEMO release version
-\def \version{trunk}
-
-%% Preamble
+%% Preamble: global configuration
 %% =================================================================================================
 
-%% Document layout
-\documentclass[fontsize = 10pt, twoside, abstract]{scrreprt}
+%% Layout
+\documentclass[fontsize=10pt,twoside,abstract,draft]{scrreprt}
+%\documentclass[fontsize=10pt,twoside,abstract      ]{scrreprt}
 
-%% Load manual configuration
-\input{../../global/prologue}
+%% Overall configuration 
+\input{../../global/preamble}
 
-%% End of common preamble between main and sub-files
-%% Override custom cmds for full manual compilation
-\newcommand{\subinc}[1]{#1}
-\newcommand{\subexc}[1]{}
+%% Special cmds around to {in,ex}clude content only in subfile
+  \newcommand{\subinc}[1]{#1}
+  \newcommand{\subexc}[1]{  }
 
 \begin{document}
 
-\renewcommand{\subinc}[1]{}
+\renewcommand{\subinc}[1]{  }
 \renewcommand{\subexc}[1]{#1}
 
-
-%% Frontmatter
+%% Frontmatter: covers
+%% ({sub}title, DOI, authors, abstract and color theme are specific to each manual)
 %% =================================================================================================
 
+%\frontmatter %% Not recognized in 'scrreprt' document class
 \pagenumbering{gobble}   %% Disable page numbering temporarily
+\pagestyle{empty}
 
-%% Title page
 \input{../../global/frontpage}
-
-%% Footer for introductory parts (no header by cleaning default)
-\ofoot[]{\engine\ Reference Manual} \ifoot[]{\pagemark}
-
-%% Information page (2nd page)
 \input{../../global/info_page}
 
+\cleardoublepage
+
+\pagenumbering{Roman} %% Reactivate page numbering (uppercase roman numbers)
+\pagestyle{plain}
+%\lastpageref{pagesLTS.0}
+
+\tableofcontents
 \listoffigures
 \listoflistings
 \listoftables
+%\listoftodos
+%\lastpageref{pagesLTS.Roman}
 
-\clearpage
+\cleardoublepage
 
-\pagenumbering{roman}
-\ofoot[]{\engine\ Reference Manual} \ifoot[]{\pagemark}
+%% Mainmatter: toc, lists, introduction and primary chapters
+%% =================================================================================================
+
+%\mainmatter %% Not recognized in 'scrreprt' document class
+\pagenumbering{arabic} %% Standard page numbering
+\pagestyle{plain}
 
 \input{introduction}
 
-%% Table of Contents
-\tableofcontents
+\cleardoublepage
 
-\clearpage
+\pagestyle{scrheadings}
+\renewcommand{\chapterpagestyle}{empty}
 
+\input{chapters}
 
-%% Mainmatter
+%% Appendix: subordinate chapters
 %% =================================================================================================
 
-%% Headings for document body
-\pagenumbering{arabic}
-\lohead{Chap.\ \thechapter\ \leftmark} \rehead{Sect.\ \thesection\ \rightmark}
-\ifoot[]{Page\ \pagemark\ of \pageref*{LastPage}}
+\appendix %% Chapter numbering with letters by now
+\lohead{Apdx \thechapter\ \leftmark}
 
-\include{chapters}
+\input{appendices}
 
+\input{../../global/coding_rules} %% Add coding rules on every manual
 
-%% Appendix
+%\lastpageref{pagesLTS.arabic}
+\cleardoublepage
+
+%% Backmatter: bibliography, glossaries and indices
 %% =================================================================================================
 
-\appendix   %% Chapter numbering with letters by now
-\lohead{Apdx\ \thechapter\ \leftmark}
-\include{appendices}
+%\backmatter %% Not recognized in 'scrreprt' document class
+\pagenumbering{roman} %% Lowercase roman numbers
+\pagestyle{plain}
 
-%% Append coding rules for every manual
-\input{../../global/coding_rules}
-
-
-%% Backmatter
-%% =================================================================================================
-
-%% Bibliography and indexes
 \input{../../global/epilogue}
 
+%\lastpageref{pagesLTS.roman}
+
 \end{document}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/epilogue.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/epilogue.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/epilogue.tex	(revision 14644)
@@ -1,17 +1,24 @@
-
-\clearpage
+%% =================================================================================================
+%% Backmatter
+%% =================================================================================================
 
 %% Bibliography
+%% =================================================================================================
+
 \phantomsection
 \addcontentsline{toc}{chapter}{Bibliography}
-\lohead{Bibliography} \rehead{Bibliography}
+\lohead{Bibliography}
+\rehead{Bibliography}
 \bibliography{../main/bibliography}
 
 \clearpage
 
-%% Indexes
+%% Indices
+%% =================================================================================================
+
 \phantomsection
-\addcontentsline{toc}{chapter}{Indexes}
-\lohead{Indexes} \rehead{Indexes}
+\addcontentsline{toc}{chapter}{Indices}
+\lohead{Indices}
+\rehead{Indices}
 \printindex[blocks]
 \printindex[keys]
@@ -19,2 +26,12 @@
 \printindex[parameters]
 \printindex[subroutines]
+
+\clearpage
+
+%% Glossary
+%% =================================================================================================
+
+%\phantomsection
+%\addcontentsline{toc}{chapter}{Glossary}
+%\lohead{Glossary}\rehead{Glossary}
+%\printglossaries
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/frontpage.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/frontpage.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/frontpage.tex	(revision 14644)
@@ -1,67 +1,71 @@
+%% =================================================================================================
+%% Front cover
+%% =================================================================================================
 
 \begin{titlepage}
-%  \newgeometry{hmargin = 1.5cm, vmargin = 3cm}
-  \setlength{\parindent}{0pt}
+%   \newgeometry{hmargin=1.5cm,vmargin=3cm}
+   \setlength{\parindent}{0pt}
 
-  \begin{center}
-    \begin{minipage}{0.3\textwidth}
-      \includegraphics[height=1.5cm]{logos/NEMO_grey}
-    \end{minipage}\begin{minipage}{0.6\textwidth}
-      \begin{center}
-      \Large\slshape
-      \textbf{N}ucleus for \textbf{E}uropean \textbf{M}odelling of the \textbf{O}cean \\
+   \begin{center}
+
+      \begin{minipage}{0.3\textwidth}
+         \includegraphics[height=1.5cm]{NEMO_grey}
+      \end{minipage} %% Don't insert void line between `minipage` envs
+      \begin{minipage}{0.6\textwidth}
+         \begin{center}
+            \Large\slshape
+            \textbf{N}ucleus for \textbf{E}uropean \textbf{M}odelling of the \textbf{O}cean \\
+            \medskip
+            \hyperref[resources]{
+               \faWordpress \hspace{1cm} \faCodeFork      \hspace{1cm}
+               \faGithub    \hspace{1cm} \faCloudDownload \hspace{1cm} \faEnvelope
+            }
+         \end{center}
+      \end{minipage}
+
+   \end{center}
+
+   \spcup
+   \textcolor{white}{\fontsize{0.8cm}{0.8cm}\selectfont\textbf{\hdg}}
+   \ifdef{\shdg}{\medskip\par\textcolor{white}{\Huge\shdg}}{}
+   \spcdn
+
+   \begin{center}
+      \LARGE Version {\ver} - {\today} \\
       \medskip
-      \hyperref[resources]{\textcolor{black}{
-          \faWordpress \hspace{0.75cm} \faCodeFork      \hspace{0.75cm}
-          \faGithub    \hspace{0.75cm} \faCloudDownload \hspace{0.75cm} \faEnvelope
-        }
-      }
-      \end{center}
-    \end{minipage}
-  \end{center}
+      \href{http://doi.org/10.5281/zenodo.\zid}{\includegraphics{zenodo.\zid}}
+   \end{center}
 
-  \spacetop
-  \textcolor{white}{\fontsize{0.8cm}{0.8cm}\selectfont\textbf{\heading}}
-  \ifdef{\subheading}{
-    \medskip
-    \par
-    \textcolor{white}{\Huge \subheading}
-  }{}
-  \spacedown
+   \vfill
 
-  \begin{center}
-    \LARGE Version \version\ -\ \today \\
-    \medskip
-    \href{http://doi.org/10.5281/zenodo.\zid}{ \includegraphics{badges/zenodo.\zid} }
-  \end{center}
+   \begin{minipage}{\autwd}
+      \raggedleft\input{authors}
+   \end{minipage}
+   \hspace{15pt} %% Don't insert void line between `minipage` envs
+   \begin{minipage}{0.02\linewidth}
+      \rule{1pt}{\lnlg}
+   \end{minipage}
+   \hspace{ 5pt} %%   "     ""    ""   ""     "        ""      ""
+   \begin{minipage}{\abswd}
+      \begin{abstract}
+         \input{abstract}
+      \end{abstract}
+   \end{minipage}
 
-  \vfill
+   \vfill
 
-  \begin{minipage}{\authorswidth}
-    \raggedleft
-    \input{authors}
-  \end{minipage}\hspace{15pt}\begin{minipage}{0.02\linewidth}
-    \rule{1pt}{\rulelenght}
-  \end{minipage}\hspace{ 5pt}\begin{minipage}{\abstractwidth}
-    \begin{abstract}
-      \input{abstract}
-    \end{abstract}
-  \end{minipage}
-
-  \vfill
-
-  \begin{center}
-    \Large
-    \href{http://www.cmcc.it          }{ \includegraphics[height=1cm]{logos/CMCC} } \hspace{0.25cm}
-    \href{http://www.cnrs.fr          }{ \includegraphics[height=1cm]{logos/CNRS} } \hspace{0.25cm}
-    \href{http://www.mercator-ocean.fr}{ \includegraphics[height=1cm]{logos/MOI}  } \hspace{0.25cm}
-    \href{http://www.metoffice.gov.uk }{ \includegraphics[height=1cm]{logos/UKMO} } \hspace{0.25cm}
-    \href{http://nerc.ukri.org        }{ \includegraphics[height=1cm]{logos/NERC} } \\
-    \medskip
-    \slshape
-    {C}ommunity \hspace{1.5em} {O}cean \hspace{1.5em} {M}odel \\
-  \end{center}
+   \begin{center}
+      \Large
+      \CMCC{\includegraphics[height=1cm]{CMCC}} \hspace{0.25cm}
+      \CNRS{\includegraphics[height=1cm]{CNRS}} \hspace{0.25cm}
+       \MOI{\includegraphics[height=1cm]{MOI} } \hspace{0.25cm}
+      \UKMO{\includegraphics[height=1cm]{UKMO}} \hspace{0.25cm}
+      \NERC{\includegraphics[height=1cm]{NERC}}                 \\
+      \medskip
+      \slshape
+         {C}ommunity \hspace{1.5em} {O}cean \hspace{1.5em} {M}odel
+   \end{center}
 
 \end{titlepage}
 
-\restoregeometry
+%\restoregeometry
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/glossaries.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/glossaries.tex	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/glossaries.tex	(revision 14644)
@@ -0,0 +1,11 @@
+%% =================================================================================================
+%% Glossaries
+%% =================================================================================================
+
+\usepackage[toc]{glossaries}
+
+%% \newglossaryentry{<label>}{<settings>}
+
+%% \newacronym{<label>}{<abbrv>}{<full>}
+
+\makeglossaries
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/highlighting.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/highlighting.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/highlighting.tex	(revision 14644)
@@ -1,32 +1,32 @@
+%% =================================================================================================
 %% Syntax highlighting configuration
-%% ==============================================================================
-
-\usepackage[outputdir=../build, chapter, newfloat]{minted}
+%% =================================================================================================
 
 %% Global highlighting style
-\definecolor{bg}{HTML}{f8f8f8}
+\definecolor{bg}{HTML}{f8f8f8} %% ?
 \usemintedstyle{emacs}
-\setminted{bgcolor=bg, fontsize=\scriptsize, breaklines}
-\setminted[xml]{style=borland} %% Specific per language
+\setminted{bgcolor=bg,fontsize=\scriptsize,breaklines}
+\setminted[xml]{style=borland} %% Specific style for XML
+
+%% Inline
+\newmintinline[forcode]{fortran}{bgcolor=,fontsize=auto} %% \forcode{...}
+\newmintinline[xmlcode]{xml}{    bgcolor=,fontsize=auto} %% \xmlcode{...}
+\newmintinline[snippet]{console}{bgcolor=,fontsize=auto} %% \snippet{...}
 
 %% Oneliner
-\newmint[forline]{fortran}{}   % \forline|...|
-\newmint[xmlline]{xml}{}       % \xmlline|...|
-\newmint[cmd]{console}{}       % \cmd|...|
+\newmint[forline]{fortran}{} %% \forline|...|
+\newmint[xmlline]{xml    }{} %% \xmlline|...|
+\newmint[cmd]{    console}{} %% \cmd|...|
 
 %% Multi-lines
-\newminted[forlines]{fortran}{}   % \begin{forlines}
-\newminted[xmllines]{xml}{}       % \begin{xmllines}
-\newminted[cmds]{console}{}       % \begin{cmds}
-\newminted[clines]{c}{}           % \begin{clines}
+\newminted[forlines]{fortran}{} %% \begin{forlines}
+\newminted[xmllines]{xml    }{} %% \begin{xmllines}
+\newminted[cmds]{    console}{} %% \begin{cmds}
+\newminted[clines]{  c      }{} %% \begin{clines}
 
-%% File
+%% File (namelist or module)
 \newmintedfile[forfile]{fortran}{}
-
-%% Inline
-\newmintinline[forcode]{fortran}{bgcolor=, fontsize=auto}   % \forcode{...}
-\newmintinline[xmlcode]{xml}{    bgcolor=, fontsize=auto}   % \xmlcode{...}
-\newmintinline[snippet]{console}{bgcolor=, fontsize=auto}   % \snippet{...}
 
 %% Namelists inclusion
 \newcommand{\nlst}[1]{\forfile{../../../namelists/#1}}
+
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/index.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/index.tex	(revision 14643)
+++ 	(revision )
@@ -1,25 +1,0 @@
-
-\usepackage{imakeidx}
-
-%% Naming customization
-\renewcommand{\listingname}{namelist}
-\renewcommand{\listlistingname}{List of Namelists}
-
-%% Index entries (italic font for files, preformat for code)
-\newcommand{\hf}[1]{   \index{h90 files!#1}             \textit{#1.h90}          }
-\newcommand{\ifile}[1]{\index{Input NetCDF files!#1.nc} \textit{#1.nc}           }
-\newcommand{\jp}[1]{   \index{Model parameters!#1}      \texttt{#1}              }
-\newcommand{\key}[1]{  \index[keys]{#1@\texttt{\textbf{key\_#1}}} \texttt{\textbf{key\_#1}}}
-\newcommand{\mdl}[1]{  \index[modules]{#1@\textit{#1.F90}}        \textit{#1.F90}          }
-\newcommand{\nam}[2]{  \index[blocks]{#1@\texttt{\&nam#2}}        \forcode{&nam#1} (\autoref{lst:nam#1})}
-\newcommand{\np}[3][]{ \index[parameters]{#3@\texttt{#3}}         \forcode{#2#1}           }
-\newcommand{\rou}[1]{  \index[subroutines]{#1@\texttt{#1}}        \texttt{#1}              }
-
-
-\indexsetup{toclevel=section, othercode=\small}
-
-\makeindex[intoc=true, name=blocks     , title=Namelist blocks      , columns=3]
-\makeindex[intoc=true, name=keys       , title=CPP keys                        ]
-\makeindex[intoc=true, name=modules    , title=\fortran\ modules    , columns=3]
-\makeindex[intoc=true, name=parameters , title=Namelist parameters  , columns=3]
-\makeindex[intoc=true, name=subroutines, title=\fortran\ subroutines           ]
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/indices.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/indices.tex	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/indices.tex	(revision 14644)
@@ -0,0 +1,28 @@
+%% =================================================================================================
+%% Indices
+%% =================================================================================================
+
+%% Index entries (italic font for files, preformat for code)
+\newcommand{\key}[1]{
+   \index[keys]{       #1@\texttt{\textbf{key\_#1}}} \texttt{\textbf{key\_#1}}
+}             
+\newcommand{\mdl}[1]{
+   \index[modules]{    #1@\textit{#1.F90}          } \textit{#1.F90}
+}
+\newcommand{\nam}[2]{
+   \index[blocks]{     #1@\texttt{\&nam#2}         } \forcode{&nam#1} (\autoref{lst:nam#1})
+}
+\newcommand{\np}[3][]{
+   \index[parameters]{ #3@\texttt{#3}              } \forcode{#2#1}
+}
+\newcommand{\rou}[1]{
+   \index[subroutines]{#1@\texttt{#1}              } \texttt{#1}
+}
+
+\indexsetup{toclevel=section,othercode=\small}
+
+\makeindex[intoc=true,name=blocks     ,title=Namelist blocks      ,columns=3]
+\makeindex[intoc=true,name=keys       ,title=CPP keys                       ]
+\makeindex[intoc=true,name=modules    ,title=\fortran\ modules    ,columns=3]
+\makeindex[intoc=true,name=parameters ,title=Namelist parameters  ,columns=3]
+\makeindex[intoc=true,name=subroutines,title=\fortran\ subroutines          ]
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/info_page.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/info_page.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/info_page.tex	(revision 14644)
@@ -1,12 +1,13 @@
+%% =================================================================================================
+%% Back cover
+%% =================================================================================================
 
-\thispagestyle{plain}
+%% Disclaimer
+%% =================================================================================================
 
-%% ================================================================
-%% Disclaimer
-%% ================================================================
 \subsubsection*{Disclaimer}
 
 Like all components of the modelling framework,
-the \engine\ core engine is developed under the \href{http://www.cecill.info}{CECILL license},
+the \eng\ core engine is developed under the \href{http://www.cecill.info}{CECILL license},
 which is a French adaptation of the GNU GPL (\textbf{G}eneral \textbf{P}ublic \textbf{L}icense).
 Anyone may use it freely for research purposes, and is encouraged to
@@ -20,32 +21,32 @@
 The authors assume no responsibility for problems, errors, or incorrect usage of \NEMO.
 
-%% ================================================================
 %% External resources
-%% ================================================================
+%% =================================================================================================
+
 \subsubsection*{Other resources}
 \label{resources}
 
 Additional information can be found on:
+
 \begin{itemize}
-\item \faWordpress\ the \href{http://www.nemo-ocean.eu}{website} of the project detailing several
-  associated applications and an exhaustive users bibliography
-\item \faCodeFork\ the \href{http://forge.ipsl.jussieu.fr/nemo}{development platform} of
-  the model with the code repository for the shared reference and some main resources
-  (wiki, ticket system, forums, \ldots) \\
-  \faGithub\ the \href{http://github.com/NEMO-ocean/NEMO-examples}
-  {repository of the demonstration cases} for research or training
-\item \faCloudDownload\ the \href{http://zenodo.org/communities/nemo-ocean}{online archive}
-  delivering the publications issued by the consortium (manuals, reports, datasets, \ldots)
-\item \faEnvelope\ two mailing lists:
-  the \href{http://listes.ipsl.fr/sympa/info/nemo-newsletter}{newsletter} for
-  top-down communications from the project
-  (announcements, calls, job opportunities, \ldots)
-  and the \href{http://listes.ipsl.fr/sympa/info/nemo-forge}{forge updates}
-  (commits, tickets and forums)
+   \item \faWordpress\ the \href{http://www.nemo-ocean.eu}{website} of the project detailing
+      several associated applications and an exhaustive users bibliography
+   \item \faCodeFork\ the \href{http://forge.ipsl.jussieu.fr/nemo}{development platform} of
+      the model with the code repository for the shared reference and some main resources
+      (wiki, ticket system, forums, \ldots) \\
+      \faGithub\ the \href{http://github.com/NEMO-ocean/NEMO-examples}
+      {repository of the demonstration cases} for research or training
+   \item \faCloudDownload\ the \href{http://zenodo.org/communities/nemo-ocean}{online archive}
+      delivering the publications issued by the consortium (manuals, reports, datasets, \ldots)
+   \item \faEnvelope\ two mailing lists:
+      the \href{http://listes.ipsl.fr/sympa/info/nemo-newsletter}{newsletter} for
+      top-down communications from the project (announcements, calls, job opportunities, \ldots)
+      and the \href{http://listes.ipsl.fr/sympa/info/nemo-forge}{forge updates}
+      (commits, tickets and forums)
 \end{itemize}
 
-%% ================================================================
 %% Citation
-%% ================================================================
+%% =================================================================================================
+
 \subsubsection*{Citation}
 
@@ -55,22 +56,24 @@
 
 \begin{sloppypar}
-  ``{\bfseries \heading}\ifdef{\subheading}{ -- \subheading}{}'',
-  {\em Scientific Notes of Climate Modelling Center}, \textbf{\ipslnum} --- ISSN 1288-1619,
-  Institut Pierre-Simon Laplace (IPSL),
-  \href{https://doi.org/10.5281/zenodo.\zid}{doi:10.5281/zenodo.\zid}
+   ``{\bfseries \hdg}\ifdef{\shdg}{ -- \shdg}{}'',
+   {\em Scientific Notes of Climate Modelling Center}, \textbf{\ipsl} --- ISSN 1288-1619,
+   Institut Pierre-Simon Laplace (IPSL),
+   \href{https://doi.org/10.5281/zenodo.\zid}{doi:10.5281/zenodo.\zid}
 \end{sloppypar}
 
 \begin{figure}[b]
-  \begin{minipage}[c]{0.7\textwidth}
-    \small
-    \ttfamily{
-      Scientific Notes of Climate Modelling Center \\
-      ISSN 1288-1619                               \\
-      Institut Pierre-Simon Laplace (IPSL)
-    }
-  \end{minipage}
-  \hfill
-  \begin{minipage}[c]{0.25\textwidth}
-    \href{http://www.cmc.ipsl.fr}{\includegraphics[width=\textwidth]{logos/IPSL_master}}
-  \end{minipage}
+
+   \begin{minipage}[c]{0.7\textwidth}
+      \small
+      \ttfamily{
+         Scientific Notes of Climate Modelling Center \\
+         ISSN 1288-1619                               \\
+         Institut Pierre-Simon Laplace (IPSL)
+      }
+   \end{minipage}
+   \hfill %% Don't insert void line between `minipage` envs
+   \begin{minipage}[c]{0.25\textwidth}
+      \href{http://www.cmc.ipsl.fr}{\includegraphics[width=\textwidth]{IPSL_master}}
+   \end{minipage}
+
 \end{figure}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/latexmk.pl
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/latexmk.pl	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/latexmk.pl	(revision 14644)
@@ -1,13 +1,17 @@
+## Defaults
+#$silent   = 1;
+$pdf_mode = 5;
 
-## Defaults
-$do_cd    = 1;   ## Change to the directory of the main source file
-$silent   = 1;   ## Less verbosity
+## Using relative paths
+$ENV{'openout_any'} = 'a'       ;
+$do_cd              = 1         ;
+$out_dir            = '../build';
 
-## Use of 'build' relative directory
-$ENV{'openout_any'}='a';
-$out_dir = '../build';
-
-## Global option
-set_tex_cmds( '-shell-escape' );
-
-$makeindex = "makeindex %O -s ../../global/index -o $out_dir/%D $out_dir/%S";
+## Custom cmds
+set_tex_cmds('-shell-escape -file-line-error -interaction=nonstopmode');
+#set_tex_cmds('-shell-escape -file-line-error');
+$makeindex = 'makeindex %O -s %R.ist -o %D %S';
+## %D: Destination file (.ind for index)
+## %O: Options
+## %R: Root filename (${model}_manual)
+## %S: Source file      (.idx for index)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/nemo.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/nemo.tex	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/nemo.tex	(revision 14644)
@@ -0,0 +1,23 @@
+%% =================================================================================================
+%% Common abstract
+%% =================================================================================================
+
+``Nucleus for European Modelling of the Ocean'' as \NEMO\ is a state-of-the-art modelling framework of
+ocean-related engines for research activities and forecasting services in oceanography and climatology,
+developed in a sustainable way since 2008 by a European consortium of 5 institutes
+(\CMCC{CMCC} | \CNRS{CNRS} | \MOI{Mercator Océan} | \UKMO{Met Office} | \NERC{NERC}).
+It is intended to be a flexible tool for studying the physical and biogeochemical phenomena in
+the ocean circulation, as well as its interactions with the components of the Earth climate system,
+over a wide range of space and time scales.
+
+Concerning the physics, the fundamental engine for the \textcolor{blue}{``blue ocean''} solves
+the primitive equations of the ocean \{thermo\}dynamics.
+It can be supplemented by the \textcolor{gray}{``white ocean''} for sea-ice \{thermo\}dynamics,
+brine inclusions and subgrid-scale thickness variations (\SIcube), and also by
+the \textcolor{green}{``green ocean''} for \{on,off\}line oceanic tracers transport and
+biogeochemical processes (\TOP-\PISCES).
+External alternative models can be used instead of the core engines (\eg\ \CICE\ and \BFM).
+Regarding the numerics, main features include versatile data assimilation interface,
+agile diagnostics generation thanks to \XIOS\ software,
+ocean-atmosphere coupling via the \OASIS\ library, and
+seamless embedded zooms with the \AGRIF\ 2-way nesting package.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/new_cmds.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/new_cmds.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/new_cmds.tex	(revision 14644)
@@ -1,18 +1,27 @@
-%% Global custom commands: \newcommand{<name>}[<args>][<first argument value>]{<code>}
-%% ==============================================================================
+%% =================================================================================================
+%% Global custom commands
+%% =================================================================================================
 
-%% Same slanted font for NEMO and its core engines
-\newcommand{\NEMO  }{\textsl{NEMO}}
-\newcommand{\OPA   }{\textsl{OPA}}
-\newcommand{\SIcube}{\textsl{SI$^3$}}
-\newcommand{\TOP   }{\textsl{TOP}}
-\newcommand{\PISCES}{\textsl{PISCES}}
+%% \newcommand{<name>}[<args>][<first argument value>]{<code>}
+
+%% Same font for NEMO and its core engines
+\newcommand{\NEMO   }{\textsl{NEMO}}
+\newcommand{\OPA    }{\textsl{OPA}}
+\newcommand{\SIcube }{\textsl{SI$^3$}}
+\newcommand{\TOP    }{\textsl{TOP}}
+\newcommand{\PISCES }{\textsl{PISCES}}
 \newcommand{\NEMOVAR}{\textsl{NEMOVAR}}
 
-%% Links for external components
-\newcommand{\AGRIF}{\href{http://agrif.imag.fr}{AGRIF}}
+%% URL links for consortium institutes and external components
+\newcommand{\CMCC }{\href{http://www.cmcc.it}          }
+\newcommand{\CNRS }{\href{http://www.cnrs.fr}          }
+\newcommand{\MOI  }{\href{http://www.mercator-ocean.fr}}
+\newcommand{\UKMO }{\href{http://www.metoffice.gov.uk} }
+\newcommand{\NERC }{\href{http://nerc.ukri.org}        }
+\newcommand{\AGRIF}{\href{http://agrif.imag.fr                  }{AGRIF}}
+\newcommand{\BFM  }{\href{http://bfm-community.eu               }{BFM}}
 \newcommand{\CICE }{\href{http://github.com/CICE-Consortium/CICE}{CICE}}
-\newcommand{\OASIS}{\href{http://portal.enes.org/oasis}{OASIS}}
-\newcommand{\XIOS }{\href{http://forge.ipsl.jussieu.fr/ioserver}{XIOS}}
+\newcommand{\OASIS}{\href{http://portal.enes.org/oasis          }{OASIS}}
+\newcommand{\XIOS }{\href{http://forge.ipsl.jussieu.fr/ioserver }{XIOS}}
 
 %% Fortran in small capitals
@@ -22,48 +31,47 @@
 %% Common aliases
 \renewcommand{\deg}[1][]{\ensuremath{^{\circ}#1}}
+\newcommand{\eg    }{\ensuremath{e.g.}}
+\newcommand{\ie    }{\ensuremath{i.e.}}
 \newcommand{\zstar }{\ensuremath{z^\star}}
 \newcommand{\sstar }{\ensuremath{s^\star}}
 \newcommand{\ztilde}{\ensuremath{\tilde z}}
 \newcommand{\stilde}{\ensuremath{\tilde s}}
-\newcommand{\ie}{\ensuremath{i.e.}}
-\newcommand{\eg}{\ensuremath{e.g.}}
-
-%% Inline maths
-\newcommand{\fractext}[2]{\textstyle \frac{#1}{#2}}
-\newcommand{\rdt}{\Delta t}
 
 %% Gurvan's comments
 \newcommand{\cmtgm}[1]{}
 
-%% Maths
+%% Maths: reduce equation
+\newcommand{\fractext}[2]{\textstyle\frac{#1}{#2}}
 \newcommand{\lt}{\left}
+\newcommand{\pd}[2][]{\ensuremath{\frac{\partial #1}{\partial #2}}}
+\newcommand{\rdt}{\Delta t}
 \newcommand{\rt}{\right}
-\newcommand{\vect}[1]{\ensuremath{ \mathbf{#1} }}
-\newcommand{\pd}[2][]{\ensuremath{\frac{\partial #1}{\partial #2}}}
-
-%% Convert chapter/section headings to lowercase
-\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
-\renewcommand{\sectionmark}[1]{\markright{#1}{}}
+\newcommand{\vect}[1][]{\ensuremath{\mathbf{#1}}}
 
 %% Retrieve month name
 \renewcommand{\today}{
-  \ifcase \month\or January\or February\or March\or
-                    April\or   May\or      June\or
-                    July\or    August\or   September\or
-                    October\or November\or December
+  \ifcase \month\or   January\or February\or    March\or    April\or
+                          May\or     June\or     July\or   August\or
+                    September\or  October\or November\or December
   \fi, \number \year
 }
 
-%% Link to orcid profile
-\newcommand{\orcid}[1]{\href{http://orcid.org/#1}{\textcolor{orcidcolor}\aiOrcidSquare}}
+%% Custom aliases
+\newcommand{\cf}{\ensuremath{C\kern-0.14em f}}
+\newcommand{\rML}[1][i]{\ensuremath{_{\mathrm{ML}\,#1}}}
+\newcommand{\rMLt}[1][i]{\tilde{r}_{\mathrm{ML}\,#1}}
+\newcommand{\triad}[6][]{\ensuremath{{}_{#2}^{#3}{\mathbb{#4}_{#1}}_{#5}^{\,#6}}}
+\newcommand{\triadd}[5]{\ensuremath{{}_{#1}^{#2}{\mathbb{#3}}_{#4}^{\,#5}}}
+\newcommand{\triadt}[5]{\ensuremath{{}_{#1}^{#2}{\tilde{\mathbb{#3}}}_{#4}^{\,#5}}}
+\newcommand{\rtriad}[2][]{\ensuremath{\triad[#1]{i}{k}{#2}{i_p}{k_p}}}
+\newcommand{\rtriadt}[1]{\ensuremath{\triadt{i}{k}{#1}{i_p}{k_p}}}
 
-%% Workaround for \listoffigures
-\DeclareRobustCommand{\triad}[6][]{\ensuremath{ {}_{#2}^{#3} { \mathbb{#4}_{#1} }_{#5}^{\,#6} }}
-
-%% New command for ToC
-\newcommand{\chaptertoc}[1][Table of contents]{%
-  \thispagestyle{empty}
-  \etocsettocstyle{\addsec*{#1}}{}%
-  \localtableofcontents%
+%% New command for ToC (?)
+\newcommand{\chaptertoc}[1][Table of contents]{
+  \etocsettocstyle{\addsec*{#1}}{}
+  \localtableofcontents
   \vfill
 }
+
+%% ORCID links
+\newcommand{\orcid}[1]{\href{http://orcid.org/#1}{\textcolor{orcidclr}\aiOrcidSquare}}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/packages.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/packages.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/packages.tex	(revision 14644)
@@ -1,46 +1,46 @@
+%% =================================================================================================
+%% Packages
+%% =================================================================================================
 
-%% LaTeX packages in use
-%% ==============================================================================
+%% Document class
+\usepackage[footsepline=0.25pt,headsepline=0.25pt]{scrlayer-scrpage} %% KOMA-script
 
-%% 'hyperref' pkg is loaded at the end of the preamble for higher compatibility
-
-%% KOMA-script
-\usepackage[footsepline=0.25pt, headsepline=0.25pt]{scrlayer-scrpage}
-
-%% customization (layout, header/footer styles & contents, background)
-\usepackage{draftwatermark}
-\usepackage[margin = 2cm]{geometry}
-\usepackage[pages = some]{background}   %% 'some' for title page
-\usepackage[Bjornstrup]{fncychap}
+%% Customisation (cover page, chapter headings and mark of draft copy)
+\usepackage[margin=2cm]{geometry} %% Why 2cm margin? Load geometry before background!
+\usepackage[pages=some]{background} %% 'some' for title page
+\usepackage[scale=15,color=pink]{draftwatermark}
+\usepackage[Bjornstrup]{fncychap} %% Chapter style
 
 %% Fonts
 \usepackage{fontspec}
-%% Issue with fontawesome pkg: path to FontAwesome.otf has to be hard-coded
-\defaultfontfeatures{
-    Path = /home/nicolas/.local/texlive/2020/texmf-dist/fonts/opentype/public/fontawesome/
-}
-\usepackage{academicons, fontawesome, newtxtext}
+%% Issue with path to 'FontAwesome.otf'
+\defaultfontfeatures{Path=/usr/local/texlive/2020/texmf-dist/fonts/opentype/public/fontawesome/}
+\usepackage{academicons,fontawesome}
 
 %% Formatting
 \usepackage[inline]{enumitem}
-\usepackage{etoc, tabularx, xcolor}
+\usepackage{etoc,tabularx,xcolor}
 
 %% Graphics
-\usepackage{caption, graphicx, grffile}
+\usepackage{caption}
+\graphicspath{{../../../badges/}{../figures/}{../../../logos/}}
 
 %% Labels
-\usepackage{lastpage, natbib}
+\usepackage{lastpage,natbib}
+%\usepackage{natbib,pageslts}
 
-%% Mathematics
-\usepackage{amsmath, amssymb, mathtools}
+%% Mathematics: 'amsmath' is loaded by 'mathtools'
+\usepackage{mathtools,amssymb}
 
 %% Versatility
 \usepackage{subfiles}
 
-%% Configuration
-\graphicspath{ {../../../} {../figures/} }
+%% Source code listings
+\usepackage[cachedir=cache,outputdir=../build,chapter,newfloat]{minted}
+%% chapter? newfloat?
+
+%% Indexing and cross-referencing, loaded at the end for higher compatibility
+\usepackage{hyperref,imakeidx}
 
 %% Missing utmr8a font
 \usepackage{times}
-
-\usepackage{hyperref}   %% links
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/preamble.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/preamble.tex	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/preamble.tex	(revision 14644)
@@ -0,0 +1,17 @@
+%% =================================================================================================
+%% Preamble
+%% =================================================================================================
+
+\def\ver{trunk}
+
+%% Specific configuration
+\input{../main/settings}
+
+%% Global configuration
+\input{../../global/packages} % First obviously
+\input{../../global/styles} % Color definitions
+\input{../../global/highlighting}
+\input{../../global/indices}
+\input{../../global/new_cmds}
+%\input{../../global/todonotes}
+%\input{../../global/glossaries}
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/prologue.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/prologue.tex	(revision 14643)
+++ 	(revision )
@@ -1,25 +1,0 @@
-
-%% Specific configuration
-\input{../main/settings}
-
-%% Global configuration
-\input{../../global/packages}
-\input{../../global/highlighting}
-\input{../../global/index}
-\input{../../global/styles}
-\input{../../global/new_cmds}
-%\input{../../global/todonotes}
-
-%% Load hyperref at the end of the preamble to make it work with other pkgs
-\usepackage{hyperref}   %% links
-\hypersetup{
-  colorlinks,
-  citecolor = manualcolor, linkcolor = manualcolor, urlcolor = manualcolor,
-  final   %% Links even in draft mode
-}
-
-%% `\autoref` uncapitalization
-\renewcommand{\appendixautorefname}{appendix}
-\renewcommand{\equationautorefname}{equation}
-\renewcommand{\figureautorefname}{figure}
-\renewcommand{\tableautorefname}{table}
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/styles.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/styles.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/styles.tex	(revision 14644)
@@ -1,23 +1,52 @@
-
+%% =================================================================================================
 %% Styles
-%% ==============================================================================
+%% =================================================================================================
 
 %% Colors
-\setmanualcolor
-\colorlet{manualcolorshaded}{manualcolor!60}
-\definecolor{orcidcolor}{HTML}{A6CE39}
+\definecolor{orcidclr}{HTML}{A6CE39}
+\definecolor{manclr}{cmyk}{\clr} %% \clr defined for each manual from local settings.tex
+\colorlet{manclrshd}{manclr!60} %% Derived color for chapter heading, see below
+
+%% Cover page
+\backgroundsetup{
+   firstpage=true,scale=1,angle=0,opacity=1,
+   contents ={
+      \begin{tikzpicture}[remember picture,overlay]
+         \path[fill=manclr] (-0.5\paperwidth,7) rectangle (0.5\paperwidth,10);
+      \end{tikzpicture}
+    }
+}
 
 %% Page layout
-\pagestyle{scrheadings}
+%\pagestyle{scrheadings}
+%\renewcommand{\chapterpagestyle}{empty}
+\renewcommand{\chaptermark}[1]{\markboth{ #1}{}} %% Convert mark to lowercase
+\renewcommand{\sectionmark}[1]{\markright{#1}{}} %%    "     ""  ""     "  
+\ohead{} %% Clear default headings
+\lohead{Chap. \thechapter\  \leftmark}
+\rehead{Sect. \thesection\ \rightmark}
+\ifoot{Page \thepage\ of \pageref*{LastPage}}
+%\ifoot[\pagemark]{Page \thepage\ of \lastpageref*{pagesLTS.arabic}}
+\ofoot{\eng\ Reference Manual}
 \addtokomafont{pagehead}{  \sffamily              }
 \addtokomafont{pagefoot}{  \sffamily \footnotesize}
 \addtokomafont{pagenumber}{\sffamily \slshape     }
-\addtokomafont{chapter}{\color{white}}
-\ohead{} \ofoot{}   %% Clear defaults
+%\addtokomafont{chapter}{\color{white}}
 
-%% Caption
-\captionsetup{font = footnotesize, justification = justified}
+%% Cross-referencing
+\hypersetup{
+   pdftitle=\hdg,pdfauthor=Gurvan Madec and NEMO System Team,
+   pdfsubject=Reference manual of NEMO modelling framework,pdfkeywords=ocean circulation modelling,
+   colorlinks,allcolors=manclr
+}
+\renewcommand{\appendixautorefname}{appendix}          %% `\autoref` uncapitalization
+\renewcommand{\equationautorefname}{equation}          %%     ""            ""
+\renewcommand{\figureautorefname  }{figure}            %%     ""            ""
+\renewcommand{\listingname        }{namelist}          %%     ""            ""
+\renewcommand{\listlistingname    }{List of Namelists} %%     ""            ""
+\renewcommand{\tableautorefname   }{table}             %%     ""            ""
 
-%% Footnote
+%% Misc. (caption and footnote)
+\captionsetup{font=footnotesize,justification=justified}
 \renewcommand{\thefootnote}{\fnsymbol{footnote}}
 
@@ -28,58 +57,33 @@
 \renewcommand{\bibpostamble}{  \end{multicols}   }
 
-%% Catcodes
+%% Catcodes (between `\makeatletter` and `\makeatother`)
 \makeatletter
 
-%% Prevent error with tikz and namelist inclusion
-\global\let\tikz@ensure@dollar@catcode=\relax
-
-%% First page
-\backgroundsetup{
-  firstpage = true,
-  scale = 1, angle = 0, opacity = 1,
-  contents = {
-    \begin{tikzpicture}[remember picture, overlay]
-      \path [fill = manualcolor] (-0.5\paperwidth, 7) rectangle (0.5\paperwidth, 10);
-    \end{tikzpicture}
-  }
+%% Apply manual color for chap. headings (original snippets from fncychap.sty)
+%% !!! Let trailing percent sign to avoid space insertion
+\renewcommand{\DOCH}{% %% Upper box with chapter number
+   \settowidth{\py}{\CNoV\thechapter}%
+   \addtolength{\py}{-10pt}% %% Amount of space by which the number is shifted right
+   \fboxsep=0pt%
+   \colorbox{manclr}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
+   \kern-\py\raise20pt%
+   \hbox{\color{manclrshd}\CNoV\thechapter}\\
+}
+\renewcommand{\DOTI}[1]{% %% Lower box with chapter title
+   \nointerlineskip\raggedright%
+   \fboxsep=\myhi%
+   \vskip-1ex%
+   \colorbox{manclr}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
+   \vskip 40\p@%
+}
+\renewcommand{\DOTIS}[1]{% %% Box for unumbered chapter
+   \fboxsep=0pt%
+   \colorbox{manclr}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\
+   \nointerlineskip\raggedright%
+   \fboxsep=\myhi%
+   \vskip-1ex% %% Remove white 1pt line
+   \colorbox{manclr}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
+   \vskip 40\p@%
 }
 
-%% Apply engine color for chapter headings: tweaking snippets from fncychap.sty
-\renewcommand{\DOCH}{%
-  \settowidth{\py}{\CNoV\thechapter}
-  \addtolength{\py}{-10pt}      % Amount of space by which the
-%                                  % number is shifted right
-  \fboxsep=0pt%
-  \colorbox{manualcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
-  \kern-\py\raise20pt%
-  \hbox{\color{manualcolorshaded}\CNoV\thechapter}\\%
-}
-\renewcommand{\DOTI}[1]{%
-  \nointerlineskip\raggedright%
-  \fboxsep=\myhi%
-  \vskip-1ex%
-  \colorbox{manualcolor}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
-  \vskip 40\p@%
-}
-\renewcommand{\DOTIS}[1]{%
-  \fboxsep=0pt
-  \colorbox{manualcolor}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\%
-  \nointerlineskip\raggedright%
-  \fboxsep=\myhi%
-  \vskip-1ex% Remove white 1pt line
-  \colorbox{manualcolor}{\parbox[t]{\mylen}{\color{white}\CTV\FmTi{#1}}}\par\nobreak%
-  \vskip 40\p@%
-}
-
-%% Temporary fix
-\def\set@curr@file#1{%
-  \begingroup
-    \escapechar\m@ne
-    \xdef\@curr@file{\expandafter\string\csname #1\endcsname}%
-  \endgroup
-}
-\def\quote@name#1{"\quote@@name#1\@gobble""}
-\def\quote@@name#1"{#1\quote@@name}
-\def\unquote@name#1{\quote@@name#1\@gobble"}
-
 \makeatother
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/todonotes.tex
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/todonotes.tex	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/global/todonotes.tex	(revision 14644)
@@ -1,24 +1,30 @@
-\usepackage[]{todonotes}
+%% =================================================================================================
+%% Notes
+%% =================================================================================================
+
+\usepackage{todonotes}
 
 \newcounter{ubcomment}
-\newcommand{\ubcomment}[2][]{%
-\refstepcounter{ubcomment}%
-{%
-\todo[linecolor=black,backgroundcolor={green!40!},size=\footnotesize]{%
-\textbf{Fixme: UB [\uppercase{#1}\theubcomment]:}~#2}%
-}}
-\newcommand{\ubcommentinline}[2][]{%
-\refstepcounter{ubcomment}%
-{%
-\todo[linecolor=black,inline,backgroundcolor={green!40!},size=\footnotesize]{%
-\textbf{Fixme: UB [\uppercase{#1}\theubcomment]:}~#2}%
+
+\newcommand{\ubcomment         }[2][]{
+\refstepcounter{ubcomment}
+{
+\todo[linecolor=black,       backgroundcolor={green!40!},size=\footnotesize ]{
+\textbf{Fixme: UB [\uppercase{#1}\theubcomment]:}~#2}
 }}
 
-\newcommand{\ubcommentmultiline}[2]{%
-\refstepcounter{ubcomment}%
-{%
-\todo[linecolor=black,inline,caption={\textbf{{Fixme: UB}
-    [\theubcomment] #1}} ,backgroundcolor={green!40!},size=\footnotesize]{%
-\textbf{Fixme: UB [\theubcomment]:}~#2}%
+\newcommand{\ubcommentinline   }[2][]{
+\refstepcounter{ubcomment}
+{
+\todo[linecolor=black,inline,backgroundcolor={green!40!},size=\footnotesize ]{
+\textbf{Fixme: UB [\uppercase{#1}\theubcomment]:}~#2}
+}}
+
+\newcommand{\ubcommentmultiline}[2]{
+\refstepcounter{ubcomment}
+{
+\todo[linecolor=black,inline,backgroundcolor={green!40!},size=\footnotesize,
+      caption={\textbf{{Fixme: UB} [\theubcomment] #1}}                     ]{
+\textbf{Fixme: UB [              \theubcomment]:}~#2}
 }}
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/manual_build.sh
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/manual_build.sh	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/manual_build.sh	(revision 14644)
@@ -21,15 +21,8 @@
 
 ## LaTeX installation, find latexmk should be enough
-[ -z $( which latexmk ) ] && { echo 'latexmk not installed => QUIT'; exit 2; }
+[ -z "$( which latexmk )" ] && { echo 'latexmk not installed => QUIT'; exit 2; }
 
 ## Pygments package for syntax highlighting of source code (namelists & snippets)
 [ -n "$( ./tools/check_pkg.py pygments )" ] && { echo 'Python pygments is missing => QUIT'; exit 2; }
-
-## Retrieve figures if not already there
-#if [ ! -d latex/figures ]; then
-#    printf "Downloading of shared figures and logos\n\n"
-#    svn co http://forge.ipsl.jussieu.fr/nemo/svn/utils/figures latex/figures > /dev/null
-#fi
-
 
 ## Loop on the models
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namberg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namberg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namberg	(revision 14644)
@@ -33,4 +33,7 @@
    rn_speed_limit          = 0.      ! CFL speed limit for a berg
 
+   ln_M2016                = .false. ! use Merino et al. (2016) modification (use of 3d ocean data instead of only sea surface data)
+      ln_icb_grd           = .false. ! ground icb when icb bottom level hit oce bottom level (need ln_M2016 to be activated)
+
    cn_dir      = './'      !  root directory for the calving data location
    !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nammpp
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nammpp	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nammpp	(revision 14644)
@@ -1,4 +1,4 @@
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    ln_listonly =  .false.  !  do nothing else than listing the best domain decompositions (with land domains suppression)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namrun
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namrun	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namrun	(revision 14644)
@@ -26,5 +26,5 @@
       !                          !    = -1 do not do any restart
    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    =       0   !  used only if key_iomput is not defined: output frequency (modulo referenced to nn_it000)
+   nn_write    =       0   !  used only if key_xios is not defined: output frequency (modulo referenced to nn_it000)
       !                          !    =  0 force to write output files only at the end of the run
       !                          !    = -1 do not do any output file
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/rst/source/conf.py
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/rst/source/conf.py	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/rst/source/conf.py	(revision 14644)
@@ -43,5 +43,5 @@
 # General information about the project.
 project = u'NEMO'
-copyright = u'2019, NEMO Consortium'
+copyright = u'2020, NEMO Consortium'
 
 # The version info for the project you're documenting, acts as replacement for
@@ -50,5 +50,5 @@
 #
 # The short X.Y version.
-version = 'trk'
+version = 'trunk'
 # The full version, including alpha/beta/rc tags.
 release = 'trunk'
@@ -279,2 +279,5 @@
 # Default language to highlight set to fortran
 highlight_language = 'fortran'
+
+# Extra setting for sphinxcontrib.bibtex upgrade to 2.X.X branche
+bibtex_bibfiles = ['cfgs.bib', 'ref.bib', 'tests.bib', 'zooms.bib']
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/rst/source/guide.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/rst/source/guide.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/rst/source/guide.rst	(revision 14644)
@@ -16,5 +16,6 @@
 .. toctree::
    :hidden:
-.. todos::
+
+   todos
 
 .. Only displayed with 'make drafthtml'
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/tools/check_pkg.py
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/tools/check_pkg.py	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/tools/check_pkg.py	(revision 14644)
@@ -1,3 +1,3 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import sys, importlib
@@ -7,4 +7,4 @@
 		importlib.import_module(argv)
 	except ImportError:
-		print("Package %s is missing in Python" % argv)
+		print("Package %s is missing in Python 3" % argv)
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/tools/shr_func.sh
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/tools/shr_func.sh	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/tools/shr_func.sh	(revision 14644)
@@ -8,7 +8,7 @@
 
 build() {
-    printf "\t¤ Generation of the PDF format\n"
-    latexmk -r ./latex/global/latexmk.pl -pdfxe ./latex/$1/main/$1_manual \
-#	1> /dev/null
+    printf "\t¤ Generation of the PDF export of the manual\n"
+    latexmk -r ./latex/global/latexmk.pl ./latex/$1/main/$1_manual \
+	1> /dev/null
     [ -f ./latex/$1/build/$1_manual.pdf ] && mv ./latex/$1/build/$1_manual.pdf .
     echo
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/ablmod.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/ablmod.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/ablmod.F90	(revision 14644)
@@ -41,5 +41,5 @@
               &            pu_dta, pv_dta, pt_dta, pq_dta,    &
               &            pslp_dta, pgu_dta, pgv_dta,        &
-              &            pcd_du, psen, pevp,                &     ! in/out
+              &            pcd_du, psen, pevp, plat,          &     ! in/out
               &            pwndm, ptaui, ptauj, ptaum         &
 #if defined key_si3
@@ -84,4 +84,5 @@
       REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   pevp       ! Ce x Du
       REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   pwndm      ! ||uwnd||
+      REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   plat       ! latent heat flux
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptaui      ! taux
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptauj      ! tauy
@@ -530,11 +531,11 @@
       !-------------
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      !                            !  6 *** MPI exchanges
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      !
-      CALL lbc_lnk_multi( 'ablmod',  u_abl(:,:,:,nt_a      ), 'T', -1._wp,  v_abl(:,:,:,nt_a)      , 'T', -1._wp                            )
-      CALL lbc_lnk_multi( 'ablmod', tq_abl(:,:,:,nt_a,jp_ta), 'T', 1._wp , tq_abl(:,:,:,nt_a,jp_qa), 'T',  1._wp , kfillmode = jpfillnothing )   ! ++++ this should not be needed...
-      !
-#if defined key_iomput
+      !                            !  6 *** MPI exchanges & IOM outputs
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      CALL lbc_lnk( 'ablmod',  u_abl(:,:,:,nt_a      ), 'T', -1._wp,  v_abl(:,:,:,nt_a)      , 'T', -1._wp                            )
+      CALL lbc_lnk( 'ablmod', tq_abl(:,:,:,nt_a,jp_ta), 'T', 1._wp , tq_abl(:,:,:,nt_a,jp_qa), 'T',  1._wp , kfillmode = jpfillnothing )   ! ++++ this should not be needed...
+      !
+#if defined key_xios
       ! 2D & first ABL level
       IF ( iom_use("pblh"   ) ) CALL iom_put (    "pblh",    pblh(:,:             ) )
@@ -590,4 +591,5 @@
          psen( ji, jj ) =    - cp_air(zhumi) * zcff * psen(ji,jj) * ( psst(ji,jj) + rt0 - ztemp )   !GS: negative sign to respect aerobulk convention
          pevp( ji, jj ) = rn_efac*MAX( 0._wp,  zcff * pevp(ji,jj) * ( pssq(ji,jj)       - zhumi ) )
+         plat( ji, jj ) = - L_vap( psst(ji,jj) ) * pevp( ji, jj )
          rhoa( ji, jj ) = zcff
       END_2D
@@ -598,5 +600,5 @@
       END_2D
       !
-      CALL lbc_lnk_multi( 'ablmod', zwnd_i(:,:) , 'T', -1.0_wp, zwnd_j(:,:) , 'T', -1.0_wp )
+      CALL lbc_lnk( 'ablmod', zwnd_i(:,:) , 'T', -1.0_wp, zwnd_j(:,:) , 'T', -1.0_wp )
       !
       ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
@@ -623,5 +625,5 @@
       END_2D
       !
-      CALL lbc_lnk_multi( 'ablmod', ptaui(:,:), 'U', -1.0_wp, ptauj(:,:), 'V', -1.0_wp )
+      CALL lbc_lnk( 'ablmod', ptaui(:,:), 'U', -1.0_wp, ptauj(:,:), 'V', -1.0_wp )
 
       CALL iom_put( "taum_oce", ptaum )
@@ -643,5 +645,5 @@
             &                      * ( 0.5_wp * ( v_abl(ji,jj+1,2,nt_a) + v_abl(ji,jj,2,nt_a) ) - pssv_ice(ji,jj) )
       END_2D
-      CALL lbc_lnk_multi( 'ablmod', ptaui_ice, 'U', -1.0_wp, ptauj_ice, 'V', -1.0_wp )
+      CALL lbc_lnk( 'ablmod', ptaui_ice, 'U', -1.0_wp, ptauj_ice, 'V', -1.0_wp )
       !
       IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab2d_1=ptaui_ice  , clinfo1=' abl_stp: putaui : '   &
@@ -662,5 +664,5 @@
             &         * ( zztmp2 - pssv_ice(ji,jj) )
       END_2D
-      CALL lbc_lnk_multi( 'ablmod', ptaui_ice, 'U', -1.0_wp, ptauj_ice,'V', -1.0_wp )
+      CALL lbc_lnk( 'ablmod', ptaui_ice, 'U', -1.0_wp, ptauj_ice,'V', -1.0_wp )
       !
       IF(sn_cfctl%l_prtctl) THEN
@@ -1263,15 +1265,15 @@
       smth_b = 1._wp / 4._wp
       !
-      DO_2D( 1, 1, 1, 0 )
+      DO_2D( 1, 0, 1, 1 )
          zumsk = msk(ji,jj) * msk(ji+1,jj)
          zdX ( ji, jj ) = ( pvar2d( ji+1,jj ) - pvar2d( ji  ,jj ) ) * zumsk
       END_2D
 
-      DO_2D( 1, 0, 1, 1 )
+      DO_2D( 1, 1, 1, 0 )
          zvmsk = msk(ji,jj) * msk(ji,jj+1)
          zdY ( ji, jj ) = ( pvar2d( ji, jj+1 ) - pvar2d( ji  ,jj ) ) * zvmsk
       END_2D
 
-      DO_2D( 1, 0, 0, 0 )
+      DO_2D( 0, 0, 1, 0 )
          zFY ( ji, jj  ) =   zdY ( ji, jj   )                        &
             & +  smth_a*  ( (zdX ( ji, jj+1 ) - zdX( ji-1, jj+1 ))   &
@@ -1279,5 +1281,5 @@
       END_2D
 
-      DO_2D( 0, 0, 1, 0 )
+      DO_2D( 1, 0, 0, 0 )
          zFX( ji, jj  ) =    zdX( ji, jj   )                         &
            &    + smth_a*(  (zdY( ji+1, jj ) - zdY( ji+1, jj-1))     &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/ablrst.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/ablrst.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/ablrst.F90	(revision 14644)
@@ -45,4 +45,5 @@
       CHARACTER(len=50)   ::   clname   ! abl output restart file name
       CHARACTER(len=256)  ::   clpath   ! full path to abl output restart file 
+      CHARACTER(LEN=52)   ::   clpname  ! abl output restart file name including prefix for AGRIF
       !!----------------------------------------------------------------------
       !
@@ -74,5 +75,21 @@
             ENDIF
             !
-            CALL iom_open( TRIM(clpath)//TRIM(clname), numraw, ldwrt = .TRUE., kdlev = jpka, cdcomp = 'ABL' )
+            IF(.NOT.lwxios) THEN
+               CALL iom_open( TRIM(clpath)//TRIM(clname), numraw, ldwrt = .TRUE., kdlev = jpka, cdcomp = 'ABL' )
+            ELSE
+#if defined key_xios
+               cw_ablrst_cxt = "rstwa_"//TRIM(ADJUSTL(clkt))
+               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+                  clpname = clname
+               ELSE
+                  clpname = TRIM(Agrif_CFixed())//"_"//clname
+               ENDIF
+               numraw = iom_xios_setid(TRIM(clpath)//TRIM(clpname))
+               CALL iom_init( cw_ablrst_cxt, kdid = numraw, ld_closedef = .FALSE. )
+               CALL iom_swap( cxios_context )
+#else
+               CALL ctl_stop( 'Can not use XIOS in rst_opn' )
+#endif
+            ENDIF
             lrst_abl = .TRUE.
          ENDIF
@@ -103,9 +120,10 @@
 
       ! Write in numraw (if iter == nitrst)
-      ! ------------------ 
+      ! ------------------
       !                                                                        ! calendar control
       CALL iom_rstput( iter, nitrst, numraw, 'nn_fsbc', REAL( nn_fsbc, dp ) )      ! time-step 
       CALL iom_rstput( iter, nitrst, numraw, 'kt_abl' , REAL( iter   , dp ) )      ! date
-      CALL iom_delay_rst( 'WRITE', 'ABL', numraw )   ! save only abl delayed global communication variables
+
+      IF(.NOT.lwxios) CALL iom_delay_rst( 'WRITE', 'ABL', numraw )   ! save only abl delayed global communication variables
 
       ! Prognostic (after timestep + swap time indices = now timestep) variables
@@ -124,5 +142,11 @@
       ! ------------------
       IF( iter == nitrst ) THEN
-         CALL iom_close( numraw )
+         IF(.NOT.lwxios) THEN
+            CALL iom_close( numraw )
+         ELSE
+            CALL iom_context_finalize(      cw_ablrst_cxt          )
+            iom_file(numraw)%nfid       = 0
+            numraw = 0
+         ENDIF
          lrst_abl = .FALSE.
       ENDIF
@@ -146,5 +170,17 @@
       ENDIF
 
+      lxios_sini = .FALSE.
       CALL iom_open ( TRIM(cn_ablrst_indir)//'/'//cn_ablrst_in, numrar )
+
+      IF( lrxios) THEN
+          cr_ablrst_cxt = 'abl_rst'
+          IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for ABL'
+!         IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+!            clpname = cn_ablrst_in
+!         ELSE
+!            clpname = TRIM(Agrif_CFixed())//"_"//cn_ablrst_in
+!         ENDIF
+          CALL iom_init( cr_ablrst_cxt, kdid = numrar, ld_closedef = .TRUE. )
+      ENDIF
 
       ! Time info
@@ -174,5 +210,6 @@
       CALL iom_get( numrar, jpdom_auto,'mxld_abl',mxld_abl(:,:,:           ) )
       CALL iom_get( numrar, jpdom_auto,    'pblh',    pblh(:,:             ) )
-      CALL iom_delay_rst( 'READ', 'ABL', numrar )   ! read only abl delayed global communication variables
+
+      IF(.NOT.lrxios) CALL iom_delay_rst( 'READ', 'ABL', numrar )   ! read only abl delayed global communication variables
 
    END SUBROUTINE abl_rst_read
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/sbcabl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/sbcabl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ABL/sbcabl.F90	(revision 14644)
@@ -36,5 +36,5 @@
    USE sbc_ice, ONLY : wndm_ice, utau_ice, vtau_ice
 #endif
-#if ! defined key_iomput
+#if ! defined key_xios
    USE diawri    , ONLY : dia_wri_alloc_abl
 #endif
@@ -149,5 +149,5 @@
       CALL iom_close( inum )
 
-#if ! defined key_iomput
+#if ! defined key_xios
       IF( dia_wri_alloc_abl()  /= 0 ) CALL ctl_stop( 'STOP', 'abl_init : unable to allocate arrays' )
 #endif
@@ -363,5 +363,5 @@
             &              sf(jp_hpgi)%fnow(:,:,:), sf(jp_hpgj)%fnow(:,:,:),   &   !   <<= in
             &              zcd_du, zsen, zevp,                                 &   !   <=> in/out
-            &              wndm, utau, vtau, taum                              &   !   =>> out
+            &              zlat, wndm, utau, vtau, taum                        &   !   =>> out
 #if defined key_si3
             &            , tm_su, u_ice, v_ice, zssqi, zcd_dui                 &   !   <<= in
@@ -377,5 +377,5 @@
          CALL blk_oce_2( tq_abl(:,:,2,nt_n,jp_ta), sf(jp_qlw )%fnow(:,:,1),   &
             &            sf(jp_prec)%fnow(:,:,1) , sf(jp_snow)%fnow(:,:,1),   &
-            &            tsk_m, zsen, zlat, zevp                                )
+            &            tsk_m, zsen, zlat, zevp                              )
 
          CALL abl_rst_opn( kt )                       ! Open abl restart file (if necessary)
@@ -384,5 +384,5 @@
 #if defined key_si3
          ! Avoid a USE abl in icesbc module
-         sf(jp_tair)%fnow(:,:,1) = tq_abl(:,:,2,nt_n,jp_ta);  sf(jp_humi)%fnow(:,:,1) = tq_abl(:,:,2,nt_n,jp_qa)
+         theta_air_zt = tq_abl(:,:,2,nt_n,jp_ta) ;   q_air_zt = tq_abl(:,:,2,nt_n,jp_qa)
 #endif
       END IF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icecor.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icecor.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icecor.F90	(revision 14644)
@@ -116,5 +116,5 @@
             ENDIF
          END_2D
-         CALL lbc_lnk_multi( 'icecor', u_ice, 'U', -1.0_wp, v_ice, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icecor', u_ice, 'U', -1.0_wp, v_ice, 'V', -1.0_wp )
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icectl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icectl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icectl.F90	(revision 14644)
@@ -777,6 +777,6 @@
       IF( iom_use('icedrift_mass') .OR. iom_use('icedrift_salt') .OR. iom_use('icedrift_heat') ) THEN
          DO_2D( 1, 1, 1, 1 )
-            zdiag_mass2D(ji,jj) =   wfx_ice(ji,jj)   + wfx_snw(ji,jj)   + wfx_spr(ji,jj) + wfx_sub(ji,jj) &
-               &                  + diag_vice(ji,jj) + diag_vsnw(ji,jj) - diag_adv_mass(ji,jj)
+            zdiag_mass2D(ji,jj) = wfx_ice(ji,jj)   + wfx_snw(ji,jj)   + wfx_spr(ji,jj)   + wfx_sub(ji,jj) + wfx_pnd(ji,jj) &
+               &                + diag_vice(ji,jj) + diag_vsnw(ji,jj) + diag_vpnd(ji,jj) - diag_adv_mass(ji,jj)
             zdiag_salt2D(ji,jj) = sfx(ji,jj) + diag_sice(ji,jj) - diag_adv_salt(ji,jj)
             zdiag_heat2D(ji,jj) = qt_oce_ai(ji,jj) - qt_atm_oi(ji,jj) + diag_heat(ji,jj) - diag_adv_heat(ji,jj)
@@ -790,6 +790,6 @@
 
       ! -- mass diag -- !
-      zdiag_mass     = glob_sum( 'icectl', (  wfx_ice   + wfx_snw   + wfx_spr + wfx_sub &
-         &                                  + diag_vice + diag_vsnw - diag_adv_mass ) * e1e2t ) * rDt_ice
+      zdiag_mass     = glob_sum( 'icectl', (  wfx_ice   + wfx_snw   + wfx_spr   + wfx_sub + wfx_pnd &
+         &                                  + diag_vice + diag_vsnw + diag_vpnd - diag_adv_mass ) * e1e2t ) * rDt_ice
       zdiag_adv_mass = glob_sum( 'icectl', diag_adv_mass * e1e2t ) * rDt_ice
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_adv_pra.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_adv_pra.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_adv_pra.F90	(revision 14644)
@@ -115,5 +115,5 @@
       CALL icemax3D( ph_ip, zhip_max)
       CALL icemax3D( zs_i , zsi_max )
-      CALL lbc_lnk_multi( 'icedyn_adv_pra', zhi_max, 'T', 1._wp, zhs_max, 'T', 1._wp, zhip_max, 'T', 1._wp, zsi_max, 'T', 1._wp )
+      CALL lbc_lnk( 'icedyn_adv_pra', zhi_max, 'T', 1._wp, zhs_max, 'T', 1._wp, zhip_max, 'T', 1._wp, zsi_max, 'T', 1._wp )
       !
       ! enthalpies
@@ -265,26 +265,26 @@
          ! --- Lateral boundary conditions --- !
          !     caution: for gradients (sx and sy) the sign changes
-         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ice , 'T', 1._wp, sxice , 'T', -1._wp, syice , 'T', -1._wp  & ! ice volume
-            &                                , sxxice, 'T', 1._wp, syyice, 'T',  1._wp, sxyice, 'T',  1._wp  &
-            &                                , z0snw , 'T', 1._wp, sxsn  , 'T', -1._wp, sysn  , 'T', -1._wp  & ! snw volume
-            &                                , sxxsn , 'T', 1._wp, syysn , 'T',  1._wp, sxysn , 'T',  1._wp  )
-         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0smi , 'T', 1._wp, sxsal , 'T', -1._wp, sysal , 'T', -1._wp  & ! ice salinity
-            &                                , sxxsal, 'T', 1._wp, syysal, 'T',  1._wp, sxysal, 'T',  1._wp  &
-            &                                , z0ai  , 'T', 1._wp, sxa   , 'T', -1._wp, sya   , 'T', -1._wp  & ! ice concentration
-            &                                , sxxa  , 'T', 1._wp, syya  , 'T',  1._wp, sxya  , 'T',  1._wp  )
-         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0oi  , 'T', 1._wp, sxage , 'T', -1._wp, syage , 'T', -1._wp  & ! ice age
-            &                                , sxxage, 'T', 1._wp, syyage, 'T',  1._wp, sxyage, 'T',  1._wp  )
-         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0es  , 'T', 1._wp, sxc0  , 'T', -1._wp, syc0  , 'T', -1._wp  & ! snw enthalpy
-            &                                , sxxc0 , 'T', 1._wp, syyc0 , 'T',  1._wp, sxyc0 , 'T',  1._wp  )
-         CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ei  , 'T', 1._wp, sxe   , 'T', -1._wp, sye   , 'T', -1._wp  & ! ice enthalpy
-            &                                , sxxe  , 'T', 1._wp, syye  , 'T',  1._wp, sxye  , 'T',  1._wp  )
+         CALL lbc_lnk( 'icedyn_adv_pra', z0ice , 'T', 1._wp, sxice , 'T', -1._wp, syice , 'T', -1._wp  & ! ice volume
+            &                          , sxxice, 'T', 1._wp, syyice, 'T',  1._wp, sxyice, 'T',  1._wp  &
+            &                          , z0snw , 'T', 1._wp, sxsn  , 'T', -1._wp, sysn  , 'T', -1._wp  & ! snw volume
+            &                          , sxxsn , 'T', 1._wp, syysn , 'T',  1._wp, sxysn , 'T',  1._wp  )
+         CALL lbc_lnk( 'icedyn_adv_pra', z0smi , 'T', 1._wp, sxsal , 'T', -1._wp, sysal , 'T', -1._wp  & ! ice salinity
+            &                          , sxxsal, 'T', 1._wp, syysal, 'T',  1._wp, sxysal, 'T',  1._wp  &
+            &                          , z0ai  , 'T', 1._wp, sxa   , 'T', -1._wp, sya   , 'T', -1._wp  & ! ice concentration
+            &                          , sxxa  , 'T', 1._wp, syya  , 'T',  1._wp, sxya  , 'T',  1._wp  )
+         CALL lbc_lnk( 'icedyn_adv_pra', z0oi  , 'T', 1._wp, sxage , 'T', -1._wp, syage , 'T', -1._wp  & ! ice age
+            &                          , sxxage, 'T', 1._wp, syyage, 'T',  1._wp, sxyage, 'T',  1._wp  )
+         CALL lbc_lnk( 'icedyn_adv_pra', z0es  , 'T', 1._wp, sxc0  , 'T', -1._wp, syc0  , 'T', -1._wp  & ! snw enthalpy
+            &                          , sxxc0 , 'T', 1._wp, syyc0 , 'T',  1._wp, sxyc0 , 'T',  1._wp  )
+         CALL lbc_lnk( 'icedyn_adv_pra', z0ei  , 'T', 1._wp, sxe   , 'T', -1._wp, sye   , 'T', -1._wp  & ! ice enthalpy
+            &                          , sxxe  , 'T', 1._wp, syye  , 'T',  1._wp, sxye  , 'T',  1._wp  )
          IF ( ln_pnd_LEV .OR. ln_pnd_TOPO ) THEN
-            CALL lbc_lnk_multi( 'icedyn_adv_pra', z0ap , 'T', 1._wp, sxap , 'T', -1._wp, syap , 'T', -1._wp  & ! melt pond fraction
-               &                                , sxxap, 'T', 1._wp, syyap, 'T',  1._wp, sxyap, 'T',  1._wp  &
-               &                                , z0vp , 'T', 1._wp, sxvp , 'T', -1._wp, syvp , 'T', -1._wp  & ! melt pond volume
-               &                                , sxxvp, 'T', 1._wp, syyvp, 'T',  1._wp, sxyvp, 'T',  1._wp  )
+            CALL lbc_lnk( 'icedyn_adv_pra', z0ap , 'T', 1._wp, sxap , 'T', -1._wp, syap , 'T', -1._wp  & ! melt pond fraction
+               &                          , sxxap, 'T', 1._wp, syyap, 'T',  1._wp, sxyap, 'T',  1._wp  &
+               &                          , z0vp , 'T', 1._wp, sxvp , 'T', -1._wp, syvp , 'T', -1._wp  & ! melt pond volume
+               &                          , sxxvp, 'T', 1._wp, syyvp, 'T',  1._wp, sxyvp, 'T',  1._wp  )
             IF ( ln_pnd_lids ) THEN
-               CALL lbc_lnk_multi( 'icedyn_adv_pra', z0vl ,'T', 1._wp, sxvl ,'T', -1._wp, syvl ,'T', -1._wp  & ! melt pond lid volume
-                  &                                , sxxvl,'T', 1._wp, syyvl,'T',  1._wp, sxyvl,'T',  1._wp  )
+               CALL lbc_lnk( 'icedyn_adv_pra', z0vl ,'T', 1._wp, sxvl ,'T', -1._wp, syvl ,'T', -1._wp  & ! melt pond lid volume
+                  &                          , sxxvl,'T', 1._wp, syyvl,'T',  1._wp, sxyvl,'T',  1._wp  )
             ENDIF
          ENDIF
@@ -582,5 +582,5 @@
          !
          ! Limitation of moments.
-         DO_2D( 1, 1, ji0, ji0 )
+         DO_2D( ji0, ji0, 1, 1 )
             !
             zpsm  = psm (ji,jj,jl) ! optimization
@@ -642,5 +642,5 @@
          END_2D
          !
-         DO_2D( 1, 0, ji0, ji0 )
+         DO_2D( ji0, ji0, 1, 0 )
             !                                !  Flux from j+1 to j when v LT 0.
             zalf          = MAX( 0._wp, -pvt(ji,jj) ) * pdt / psm(ji,jj+1,jl)
@@ -662,5 +662,5 @@
          END_2D
 
-         DO_2D( 0, 0, ji0, ji0 )
+         DO_2D( ji0, ji0, 0, 0 )
             !                                !  Readjust moments remaining in the box.
             zbt  =         zbet(ji,jj-1)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_adv_umx.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_adv_umx.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_adv_umx.F90	(revision 14644)
@@ -119,5 +119,5 @@
       CALL icemax3D( ph_ip, zhip_max)
       CALL icemax3D( zs_i , zsi_max )
-      CALL lbc_lnk_multi( 'icedyn_adv_umx', zhi_max, 'T', 1._wp, zhs_max, 'T', 1._wp, zhip_max, 'T', 1._wp, zsi_max, 'T', 1._wp )
+      CALL lbc_lnk( 'icedyn_adv_umx', zhi_max, 'T', 1._wp, zhs_max, 'T', 1._wp, zhip_max, 'T', 1._wp, zsi_max, 'T', 1._wp )
       !
       ! enthalpies
@@ -360,11 +360,11 @@
          ! --- Lateral boundary conditions --- !
          IF    ( ( ln_pnd_LEV .OR. ln_pnd_TOPO ) .AND. ln_pnd_lids ) THEN
-            CALL lbc_lnk_multi( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp &
-               &                                , pa_ip,'T',1._wp, pv_ip,'T',1._wp, pv_il,'T',1._wp )
+            CALL lbc_lnk( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp &
+               &                          , pa_ip,'T',1._wp, pv_ip,'T',1._wp, pv_il,'T',1._wp )
          ELSEIF( ( ln_pnd_LEV .OR. ln_pnd_TOPO ) .AND. .NOT.ln_pnd_lids ) THEN
-            CALL lbc_lnk_multi( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp &
-               &                                , pa_ip,'T',1._wp, pv_ip,'T',1._wp )
+            CALL lbc_lnk( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp &
+               &                          , pa_ip,'T',1._wp, pv_ip,'T',1._wp )
          ELSE
-            CALL lbc_lnk_multi( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp )
+            CALL lbc_lnk( 'icedyn_adv_umx', pa_i,'T',1._wp, pv_i,'T',1._wp, pv_s,'T',1._wp, psv_i,'T',1._wp, poa_i,'T',1._wp )
          ENDIF
          CALL lbc_lnk( 'icedyn_adv_umx', pe_i, 'T', 1._wp )
@@ -491,5 +491,5 @@
       IF( pamsk == 0._wp ) THEN
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                IF( ABS( pu(ji,jj) ) > epsi10 ) THEN
                   zfu_ho (ji,jj,jl) = zfu_ho (ji,jj,jl) * puc    (ji,jj,jl) / pu(ji,jj)
@@ -501,5 +501,5 @@
                !
             END_2D
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                IF( ABS( pv(ji,jj) ) > epsi10 ) THEN
                   zfv_ho (ji,jj,jl) = zfv_ho (ji,jj,jl) * pvc    (ji,jj,jl) / pv(ji,jj)
@@ -536,9 +536,9 @@
       IF( PRESENT( pua_ho ) ) THEN
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                pua_ho (ji,jj,jl) = zfu_ho (ji,jj,jl)
                pua_ups(ji,jj,jl) = zfu_ups(ji,jj,jl)
             END_2D
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                pva_ho (ji,jj,jl) = zfv_ho (ji,jj,jl)
                pva_ups(ji,jj,jl) = zfv_ups(ji,jj,jl)
@@ -594,5 +594,5 @@
             !
             DO jl = 1, jpl              !-- flux in x-direction
-               DO_2D( 1, 1, 1, 0 )
+               DO_2D( 1, 0, 1, 1 )
                   pfu_ups(ji,jj,jl) = MAX( pu(ji,jj), 0._wp ) * pt(ji,jj,jl) + MIN( pu(ji,jj), 0._wp ) * pt(ji+1,jj,jl)
                END_2D
@@ -600,5 +600,5 @@
             !
             DO jl = 1, jpl              !-- first guess of tracer from u-flux
-               DO_2D( 1, 1, 0, 0 )
+               DO_2D( 0, 0, 1, 1 )
                   ztra = - ( pfu_ups(ji,jj,jl) - pfu_ups(ji-1,jj,jl) )              &
                      &   + ( pu     (ji,jj   ) - pu     (ji-1,jj   ) ) * pt(ji,jj,jl) * (1.-pamsk)
@@ -609,5 +609,5 @@
             !
             DO jl = 1, jpl              !-- flux in y-direction
-               DO_2D( 1, 0, 0, 0 )
+               DO_2D( 0, 0, 1, 0 )
                   pfv_ups(ji,jj,jl) = MAX( pv(ji,jj), 0._wp ) * zpt(ji,jj,jl) + MIN( pv(ji,jj), 0._wp ) * zpt(ji,jj+1,jl)
                END_2D
@@ -617,5 +617,5 @@
             !
             DO jl = 1, jpl              !-- flux in y-direction
-               DO_2D( 1, 0, 1, 1 )
+               DO_2D( 1, 1, 1, 0 )
                   pfv_ups(ji,jj,jl) = MAX( pv(ji,jj), 0._wp ) * pt(ji,jj,jl) + MIN( pv(ji,jj), 0._wp ) * pt(ji,jj+1,jl)
                END_2D
@@ -623,5 +623,5 @@
             !
             DO jl = 1, jpl              !-- first guess of tracer from v-flux
-               DO_2D( 0, 0, 1, 1 )
+               DO_2D( 1, 1, 0, 0 )
                   ztra = - ( pfv_ups(ji,jj,jl) - pfv_ups(ji,jj-1,jl) )  &
                      &   + ( pv     (ji,jj   ) - pv     (ji,jj-1   ) ) * pt(ji,jj,jl) * (1.-pamsk)
@@ -632,5 +632,5 @@
             !
             DO jl = 1, jpl              !-- flux in x-direction
-               DO_2D( 0, 0, 1, 0 )
+               DO_2D( 1, 0, 0, 0 )
                   pfu_ups(ji,jj,jl) = MAX( pu(ji,jj), 0._wp ) * zpt(ji,jj,jl) + MIN( pu(ji,jj), 0._wp ) * zpt(ji+1,jj,jl)
                END_2D
@@ -681,8 +681,8 @@
          !
          DO jl = 1, jpl
+            DO_2D( 1, 0, 1, 1 )
+               pfu_ho(ji,jj,jl) = 0.5_wp * pu(ji,jj) * ( pt(ji,jj,jl) + pt(ji+1,jj  ,jl) )
+            END_2D
             DO_2D( 1, 1, 1, 0 )
-               pfu_ho(ji,jj,jl) = 0.5_wp * pu(ji,jj) * ( pt(ji,jj,jl) + pt(ji+1,jj  ,jl) )
-            END_2D
-            DO_2D( 1, 0, 1, 1 )
                pfv_ho(ji,jj,jl) = 0.5_wp * pv(ji,jj) * ( pt(ji,jj,jl) + pt(ji  ,jj+1,jl) )
             END_2D
@@ -701,5 +701,5 @@
             !
             DO jl = 1, jpl              !-- flux in x-direction
-               DO_2D( 1, 1, 1, 0 )
+               DO_2D( 1, 0, 1, 1 )
                   pfu_ho(ji,jj,jl) = 0.5_wp * pu(ji,jj) * ( pt(ji,jj,jl) + pt(ji+1,jj,jl) )
                END_2D
@@ -708,5 +708,5 @@
 
             DO jl = 1, jpl              !-- first guess of tracer from u-flux
-               DO_2D( 1, 1, 0, 0 )
+               DO_2D( 0, 0, 1, 1 )
                   ztra = - ( pfu_ho(ji,jj,jl) - pfu_ho(ji-1,jj,jl) )              &
                      &   + ( pu    (ji,jj   ) - pu    (ji-1,jj   ) ) * pt(ji,jj,jl) * (1.-pamsk)
@@ -717,5 +717,5 @@
 
             DO jl = 1, jpl              !-- flux in y-direction
-               DO_2D( 1, 0, 0, 0 )
+               DO_2D( 0, 0, 1, 0 )
                   pfv_ho(ji,jj,jl) = 0.5_wp * pv(ji,jj) * ( zpt(ji,jj,jl) + zpt(ji,jj+1,jl) )
                END_2D
@@ -726,5 +726,5 @@
             !
             DO jl = 1, jpl              !-- flux in y-direction
-               DO_2D( 1, 0, 1, 1 )
+               DO_2D( 1, 1, 1, 0 )
                   pfv_ho(ji,jj,jl) = 0.5_wp * pv(ji,jj) * ( pt(ji,jj,jl) + pt(ji,jj+1,jl) )
                END_2D
@@ -733,5 +733,5 @@
             !
             DO jl = 1, jpl              !-- first guess of tracer from v-flux
-               DO_2D( 0, 0, 1, 1 )
+               DO_2D( 1, 1, 0, 0 )
                   ztra = - ( pfv_ho(ji,jj,jl) - pfv_ho(ji,jj-1,jl) )  &
                      &   + ( pv    (ji,jj   ) - pv    (ji,jj-1   ) ) * pt(ji,jj,jl) * (1.-pamsk)
@@ -742,5 +742,5 @@
             !
             DO jl = 1, jpl              !-- flux in x-direction
-               DO_2D( 0, 0, 1, 0 )
+               DO_2D( 1, 0, 0, 0 )
                   pfu_ho(ji,jj,jl) = 0.5_wp * pu(ji,jj) * ( zpt(ji,jj,jl) + zpt(ji+1,jj,jl) )
                END_2D
@@ -899,5 +899,5 @@
          !
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (                                pt(ji+1,jj,jl) + pt(ji,jj,jl)   &
                   &                                         - SIGN( 1._wp, pu(ji,jj) ) * ( pt(ji+1,jj,jl) - pt(ji,jj,jl) ) )
@@ -908,5 +908,5 @@
          !
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
                pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (                                pt(ji+1,jj,jl) + pt(ji,jj,jl)   &
@@ -918,5 +918,5 @@
          !
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
                zdx2 = e1u(ji,jj) * e1u(ji,jj)
@@ -932,5 +932,5 @@
          !
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
                zdx2 = e1u(ji,jj) * e1u(ji,jj)
@@ -946,5 +946,5 @@
          !
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                zcu  = pu(ji,jj) * r1_e2u(ji,jj) * pdt * r1_e1u(ji,jj)
                zdx2 = e1u(ji,jj) * e1u(ji,jj)
@@ -967,5 +967,5 @@
       IF( ll_neg ) THEN
          DO jl = 1, jpl
-            DO_2D( 0, 0, 1, 0 )
+            DO_2D( 1, 0, 0, 0 )
                IF( pt_u(ji,jj,jl) < 0._wp .OR. ( imsk_small(ji,jj,jl) == 0 .AND. pamsk == 0. ) ) THEN
                   pt_u(ji,jj,jl) = 0.5_wp * umask(ji,jj,1) * (                                pt(ji+1,jj,jl) + pt(ji,jj,jl)   &
@@ -977,5 +977,5 @@
       !                                                     !-- High order flux in i-direction  --!
       DO jl = 1, jpl
-         DO_2D( 0, 0, 1, 0 )
+         DO_2D( 1, 0, 0, 0 )
             pfu_ho(ji,jj,jl) = pu(ji,jj) * pt_u(ji,jj,jl)
          END_2D
@@ -1010,5 +1010,5 @@
       !                                                     !--  Laplacian in j-direction  --!
       DO jl = 1, jpl
-         DO_2D( 1, 0, 0, 0 )         ! First derivative (gradient)
+         DO_2D( 0, 0, 1, 0 )         ! First derivative (gradient)
             ztv1(ji,jj,jl) = ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) * r1_e2v(ji,jj) * vmask(ji,jj,1)
          END_2D
@@ -1021,5 +1021,5 @@
       !                                                     !--  BiLaplacian in j-direction  --!
       DO jl = 1, jpl
-         DO_2D( 1, 0, 0, 0 )         ! First derivative
+         DO_2D( 0, 0, 1, 0 )         ! First derivative
             ztv3(ji,jj,jl) = ( ztv2(ji,jj+1,jl) - ztv2(ji,jj,jl) ) * r1_e2v(ji,jj) * vmask(ji,jj,1)
          END_2D
@@ -1035,5 +1035,5 @@
       CASE( 1 )                                                !==  1st order central TIM  ==! (Eq. 21)
          DO jl = 1, jpl
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                                pt(ji,jj+1,jl) + pt(ji,jj,jl)   &
                   &                                         - SIGN( 1._wp, pv(ji,jj) ) * ( pt(ji,jj+1,jl) - pt(ji,jj,jl) ) )
@@ -1043,5 +1043,5 @@
       CASE( 2 )                                                !==  2nd order central TIM  ==! (Eq. 23)
          DO jl = 1, jpl
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
                pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                                pt(ji,jj+1,jl) + pt(ji,jj,jl)   &
@@ -1052,5 +1052,5 @@
       CASE( 3 )                                                !==  3rd order central TIM  ==! (Eq. 24)
          DO jl = 1, jpl
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
                zdy2 = e2v(ji,jj) * e2v(ji,jj)
@@ -1065,5 +1065,5 @@
       CASE( 4 )                                                !==  4th order central TIM  ==! (Eq. 27)
          DO jl = 1, jpl
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
                zdy2 = e2v(ji,jj) * e2v(ji,jj)
@@ -1078,5 +1078,5 @@
       CASE( 5 )                                                !==  5th order central TIM  ==! (Eq. 29)
          DO jl = 1, jpl
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                zcv  = pv(ji,jj) * r1_e1v(ji,jj) * pdt * r1_e2v(ji,jj)
                zdy2 = e2v(ji,jj) * e2v(ji,jj)
@@ -1099,5 +1099,5 @@
       IF( ll_neg ) THEN
          DO jl = 1, jpl
-            DO_2D( 1, 0, 0, 0 )
+            DO_2D( 0, 0, 1, 0 )
                IF( pt_v(ji,jj,jl) < 0._wp .OR. ( jmsk_small(ji,jj,jl) == 0 .AND. pamsk == 0. ) ) THEN
                   pt_v(ji,jj,jl) = 0.5_wp * vmask(ji,jj,1) * (                              ( pt(ji,jj+1,jl) + pt(ji,jj,jl) )  &
@@ -1109,5 +1109,5 @@
       !                                                     !-- High order flux in j-direction  --!
       DO jl = 1, jpl
-         DO_2D( 1, 0, 0, 0 )
+         DO_2D( 0, 0, 1, 0 )
             pfv_ho(ji,jj,jl) = pv(ji,jj) * pt_v(ji,jj,jl)
          END_2D
@@ -1145,8 +1145,8 @@
       ! --------------------------------------------------
       DO jl = 1, jpl
+         DO_2D( 1, 0, 0, 0 )
+            pfu_ho(ji,jj,jl) = pfu_ho(ji,jj,jl) - pfu_ups(ji,jj,jl)
+         END_2D
          DO_2D( 0, 0, 1, 0 )
-            pfu_ho(ji,jj,jl) = pfu_ho(ji,jj,jl) - pfu_ups(ji,jj,jl)
-         END_2D
-         DO_2D( 1, 0, 0, 0 )
             pfv_ho(ji,jj,jl) = pfv_ho(ji,jj,jl) - pfv_ups(ji,jj,jl)
          END_2D
@@ -1169,5 +1169,5 @@
             END_2D
          END DO
-         CALL lbc_lnk_multi( 'icedyn_adv_umx', zti_ups, 'T', 1.0_wp, ztj_ups, 'T', 1.0_wp )
+         CALL lbc_lnk( 'icedyn_adv_umx', zti_ups, 'T', 1.0_wp, ztj_ups, 'T', 1.0_wp )
 
          DO jl = 1, jpl
@@ -1191,5 +1191,5 @@
             END_2D
          END DO
-         CALL lbc_lnk_multi( 'icedyn_adv_umx', pfu_ho, 'U', -1.0_wp, pfv_ho, 'V', -1.0_wp )   ! lateral boundary cond.
+         CALL lbc_lnk( 'icedyn_adv_umx', pfu_ho, 'U', -1.0_wp, pfv_ho, 'V', -1.0_wp )   ! lateral boundary cond.
 
       ENDIF
@@ -1248,5 +1248,5 @@
          END_2D
       END DO
-      CALL lbc_lnk_multi( 'icedyn_adv_umx', zbetup, 'T', 1.0_wp, zbetdo, 'T', 1.0_wp )   ! lateral boundary cond. (unchanged sign)
+      CALL lbc_lnk( 'icedyn_adv_umx', zbetup, 'T', 1.0_wp, zbetdo, 'T', 1.0_wp )   ! lateral boundary cond. (unchanged sign)
 
 
@@ -1254,5 +1254,5 @@
       ! ---------------------------------
       DO jl = 1, jpl
-         DO_2D( 0, 0, 1, 0 )
+         DO_2D( 1, 0, 0, 0 )
             zau = MIN( 1._wp , zbetdo(ji,jj,jl) , zbetup(ji+1,jj,jl) )
             zbu = MIN( 1._wp , zbetup(ji,jj,jl) , zbetdo(ji+1,jj,jl) )
@@ -1265,5 +1265,5 @@
          END_2D
 
-         DO_2D( 1, 0, 0, 0 )
+         DO_2D( 0, 0, 1, 0 )
             zav = MIN( 1._wp , zbetdo(ji,jj,jl) , zbetup(ji,jj+1,jl) )
             zbv = MIN( 1._wp , zbetup(ji,jj,jl) , zbetdo(ji,jj+1,jl) )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_eap.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_eap.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_eap.F90	(revision 14644)
@@ -350,5 +350,5 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_eap', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
+      CALL lbc_lnk( 'icedyn_rhg_eap', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
       !
       !                                  !== Landfast ice parameterization ==!
@@ -488,5 +488,5 @@
             zs2(ji,jj) = ( zs2(ji,jj) * zalph1 + zstressmtmp ) * z1_alph1
          END_2D
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zstress12tmp, 'T', 1.0_wp , paniso_11, 'T', 1.0_wp , paniso_12, 'T', 1.0_wp)
+         CALL lbc_lnk( 'icedyn_rhg_eap', zstress12tmp, 'T', 1.0_wp , paniso_11, 'T', 1.0_wp , paniso_12, 'T', 1.0_wp)
 
         ! Save beta at T-points for further computations
@@ -516,5 +516,5 @@
 
          END_2D
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zs1, 'T', 1.0_wp, zs2, 'T', 1.0_wp, zs12, 'F', 1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zs1, 'T', 1.0_wp, zs2, 'T', 1.0_wp, zs12, 'F', 1.0_wp )
 
          ! --- Ice internal stresses (Appendix C of Hunke and Dukowicz, 2002) --- !
@@ -810,7 +810,7 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_eap', pshear_i, 'T', 1.0_wp, pdivu_i, 'T', 1.0_wp, pdelta_i, 'T', 1.0_wp, &
-         &                                    zten_i, 'T', 1.0_wp, zs1    , 'T', 1.0_wp, zs2     , 'T', 1.0_wp, &
-         &                                      zs12, 'F', 1.0_wp )
+      CALL lbc_lnk( 'icedyn_rhg_eap', pshear_i, 'T', 1.0_wp, pdivu_i, 'T', 1.0_wp, pdelta_i, 'T', 1.0_wp, &
+         &                              zten_i, 'T', 1.0_wp, zs1    , 'T', 1.0_wp, zs2     , 'T', 1.0_wp, &
+         &                                zs12, 'F', 1.0_wp )
 
       ! --- Store the stress tensor for the next time step --- !
@@ -827,6 +827,6 @@
          & iom_use('utau_bi') .OR. iom_use('vtau_bi') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, ztaux_ai, 'U', -1.0_wp, &
-            &                                  ztauy_ai, 'V', -1.0_wp, ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, ztaux_ai, 'U', -1.0_wp, &
+            &                            ztauy_ai, 'V', -1.0_wp, ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
          !
          CALL iom_put( 'utau_oi' , ztaux_oi * aimsk00 )
@@ -912,5 +912,5 @@
       IF( iom_use('yield11') .OR. iom_use('yield12') .OR. iom_use('yield22')) THEN
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zyield11, 'T', 1.0_wp, zyield22, 'T', 1.0_wp, zyield12, 'T', 1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zyield11, 'T', 1.0_wp, zyield22, 'T', 1.0_wp, zyield12, 'T', 1.0_wp )
 
          CALL iom_put( 'yield11', zyield11 * aimsk00 )
@@ -929,7 +929,7 @@
          & iom_use('corstrx') .OR. iom_use('corstry') .OR. iom_use('intstrx') .OR. iom_use('intstry') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
-            &                                  zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, &
-            &                                    zfU, 'U', -1.0_wp,   zfV, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
+            &                            zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, &
+            &                              zfU, 'U', -1.0_wp,   zfV, 'V', -1.0_wp )
 
          CALL iom_put( 'dssh_dx' , zspgU * aimsk00 )   ! Sea-surface tilt term in force balance (x)
@@ -963,7 +963,7 @@
          END_2D
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
-            &                                  zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
-            &                                  zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
+            &                            zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
+            &                            zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
 
          CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_evp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_evp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_evp.F90	(revision 14644)
@@ -316,5 +316,5 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_evp', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
+      CALL lbc_lnk( 'icedyn_rhg_evp', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
       !
       !                                  !== Landfast ice parameterization ==!
@@ -750,6 +750,6 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_evp', pshear_i, 'T', 1._wp, pdivu_i, 'T', 1._wp, pdelta_i, 'T', 1._wp, zten_i, 'T', 1._wp, &
-         &                                  zs1     , 'T', 1._wp, zs2    , 'T', 1._wp, zs12    , 'F', 1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_evp', pshear_i, 'T', 1._wp, pdivu_i, 'T', 1._wp, pdelta_i, 'T', 1._wp, zten_i, 'T', 1._wp, &
+         &                            zs1     , 'T', 1._wp, zs2    , 'T', 1._wp, zs12    , 'F', 1._wp )
 
       ! --- Store the stress tensor for the next time step --- !
@@ -766,6 +766,7 @@
          & iom_use('utau_bi') .OR. iom_use('vtau_bi') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, ztaux_ai, 'U', -1.0_wp, ztauy_ai, 'V', -1.0_wp, &
-            &                                  ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_evp', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, &
+            &                            ztaux_ai, 'U', -1.0_wp, ztauy_ai, 'V', -1.0_wp, &
+            &                            ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
          !
          CALL iom_put( 'utau_oi' , ztaux_oi * zmsk00 )
@@ -851,6 +852,6 @@
          & iom_use('corstrx') .OR. iom_use('corstry') .OR. iom_use('intstrx') .OR. iom_use('intstry') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
-            &                                  zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, zfU, 'U', -1.0_wp, zfV, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_evp', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
+            &                            zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, zfU, 'U', -1.0_wp, zfV, 'V', -1.0_wp )
 
          CALL iom_put( 'dssh_dx' , zspgU * zmsk00 )   ! Sea-surface tilt term in force balance (x)
@@ -884,7 +885,7 @@
          END_2D
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
-            &                                  zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
-            &                                  zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_evp', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
+            &                            zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
+            &                            zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
 
          CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_vp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_vp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_vp.F90	(revision 14644)
@@ -461,5 +461,5 @@
 
          CALL lbc_lnk( 'icedyn_rhg_vp', zds, 'F', 1._wp ) ! MV TEST could be un-necessary according to Gurvan
-         CALL iom_put( 'zds'        , zds      )   ! MV DEBUG
+         CALL iom_put( 'zds'          , zds      )   ! MV DEBUG
 
          IF( lwp )   WRITE(numout,*) ' outer loop  1a i_out : ', i_out
@@ -506,5 +506,5 @@
          END DO
          
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zp_deltastar_t , 'T', 1._wp , zzt , 'T', 1._wp, zet, 'T', 1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zp_deltastar_t , 'T', 1._wp , zzt , 'T', 1._wp, zet, 'T', 1._wp )
 
          CALL iom_put( 'zzt'        , zzt      )   ! MV DEBUG
@@ -527,5 +527,5 @@
          
          CALL lbc_lnk( 'icedyn_rhg_vp', zef, 'F', 1._wp )
-         CALL iom_put( 'zef'           , zef            ) ! MV DEBUG
+         CALL iom_put( 'zef'          , zef            ) ! MV DEBUG
          IF( lwp )   WRITE(numout,*) ' outer loop  1c i_out : ', i_out
 
@@ -567,6 +567,6 @@
          IF( lwp )   WRITE(numout,*) ' outer loop  1d i_out : ', i_out
          
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zCwU ,  'U', -1._wp, zCwV, 'V', -1._wp )
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zCorU,  'U', -1._wp, zCorV, 'V', -1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zCwU ,  'U', -1._wp, zCwV, 'V', -1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zCorU,  'U', -1._wp, zCorV, 'V', -1._wp )
 
          CALL iom_put( 'zCwU'          , zCwU           ) ! MV DEBUG
@@ -674,7 +674,7 @@
          END DO
          
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zrhsu, 'U', -1._wp, zrhsv, 'V',  -1._wp)
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zmU_t, 'U', -1._wp, zmV_t, 'V',  -1._wp)
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', ztaux_oi_rhsu, 'U', -1._wp, ztauy_oi_rhsv, 'V',  -1._wp)
+         CALL lbc_lnk( 'icedyn_rhg_vp', zrhsu, 'U', -1._wp, zrhsv, 'V',  -1._wp)
+         CALL lbc_lnk( 'icedyn_rhg_vp', zmU_t, 'U', -1._wp, zmV_t, 'V',  -1._wp)
+         CALL lbc_lnk( 'icedyn_rhg_vp', ztaux_oi_rhsu, 'U', -1., ztauy_oi_rhsv, 'V',  -1.)
 
          CALL iom_put( 'zmU_t'         , zmU_t          ) ! MV DEBUG
@@ -779,9 +779,9 @@
          END DO
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zAU  , 'U', 1._wp, zAV  , 'V',  1._wp )
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zBU  , 'U', 1._wp, zBV  , 'V',  1._wp )
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zCU  , 'U', 1._wp, zCV  , 'V',  1._wp )
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zDU  , 'U', 1._wp, zDV  , 'V',  1._wp )
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zEU  , 'U', 1._wp, zEV  , 'V',  1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zAU  , 'U', 1._wp, zAV  , 'V',  1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zBU  , 'U', 1._wp, zBV  , 'V',  1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zCU  , 'U', 1._wp, zCV  , 'V',  1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zDU  , 'U', 1._wp, zDV  , 'V',  1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zEU  , 'U', 1._wp, zEV  , 'V',  1._wp )
                
          CALL iom_put( 'zAU'           , zAU            ) ! MV DEBUG
@@ -885,5 +885,5 @@
                      END DO
 
-                     CALL lbc_lnk_multi( 'icedyn_rhg_vp', zFU_prime, 'U',  1._wp, zBU_prime, 'U', 1._wp )
+                     CALL lbc_lnk( 'icedyn_rhg_vp', zFU_prime, 'U',  1._wp, zBU_prime, 'U', 1._wp )
  
                      !-----------------------------
@@ -983,5 +983,5 @@
                      END DO
 
-                     CALL lbc_lnk_multi( 'icedyn_rhg_vp', zFV_prime, 'V',  1._wp, zBV_prime, 'V', 1._wp )
+                     CALL lbc_lnk( 'icedyn_rhg_vp', zFV_prime, 'V',  1._wp, zBV_prime, 'V', 1._wp )
                      
                      !-----------------------------
@@ -1020,5 +1020,5 @@
                ENDIF !   ll_v_iterate
 
-               CALL lbc_lnk_multi( 'icedyn_rhg_vp', u_ice, 'U', -1._wp, v_ice, 'V', -1._wp )
+               CALL lbc_lnk( 'icedyn_rhg_vp', u_ice, 'U', -1._wp, v_ice, 'V', -1._wp )
                               
                !--------------------------------------------------------------------------------------
@@ -1110,8 +1110,8 @@
       IF ( lwp ) WRITE(numout,*) ' We are out of outer loop '
 
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', zFU  , 'U',  1._wp, zFV  , 'V',  1._wp )
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', zBU_prime  , 'U',  1._wp, zBV_prime  , 'V',  1._wp )
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', zFU_prime  , 'U',  1._wp, zFV_prime  , 'V',  1._wp )
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', zCU_prime  , 'U',  1._wp, zCV_prime  , 'V',  1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_vp', zFU  , 'U',  1., zFV  , 'V',  1. )
+      CALL lbc_lnk( 'icedyn_rhg_vp', zBU_prime  , 'U',  1._wp, zBV_prime  , 'V',  1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_vp', zFU_prime  , 'U',  1._wp, zFV_prime  , 'V',  1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_vp', zCU_prime  , 'U',  1._wp, zCV_prime  , 'V',  1._wp )
 
       CALL iom_put( 'zFU'           , zFU            ) ! MV DEBUG
@@ -1125,5 +1125,5 @@
       CALL iom_put( 'zFV_prime'     , zFV_prime      ) ! MV DEBUG
 
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', u_ice, 'U', -1._wp, v_ice, 'V', -1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_vp', u_ice, 'U', -1._wp, v_ice, 'V', -1._wp )
 
       IF ( lwp ) WRITE(numout,*) ' We are about to output uice_dbg '
@@ -1161,5 +1161,5 @@
       END DO
 
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', u_ice, 'U', -1._wp, v_ice, 'V', -1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_vp', u_ice, 'U', -1._wp, v_ice, 'V', -1._wp )
 
       IF ( lwp ) WRITE(numout,*) ' Velocity replaced '
@@ -1222,5 +1222,5 @@
       IF ( lwp ) WRITE(numout,*) ' Deformation recalculated '
       
-      CALL lbc_lnk_multi( 'icedyn_rhg_vp', pshear_i, 'T', 1._wp, pdivu_i, 'T', 1._wp, pdelta_i, 'T', 1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_vp', pshear_i, 'T', 1._wp, pdivu_i, 'T', 1._wp, pdelta_i, 'T', 1._wp )
       
       !------------------------------------------------------------------------------!
@@ -1249,5 +1249,5 @@
          END DO
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zs1, 'T', 1._wp, zs2, 'T', 1._wp, zs12, 'T', 1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zs1, 'T', 1._wp, zs2, 'T', 1._wp, zs12, 'T', 1._wp )
       
       ENDIF
@@ -1307,6 +1307,6 @@
          
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', ztaux_oi, 'U', -1._wp, ztauy_oi, 'V', -1._wp, ztaux_ai, 'U', -1._wp, ztauy_ai, 'V', -1._wp ) !, &
-!            &                                 ztaux_bi, 'U', -1., ztauy_bi, 'V', -1. )
+         CALL lbc_lnk( 'icedyn_rhg_vp', ztaux_oi, 'U', -1._wp, ztauy_oi, 'V', -1._wp, ztaux_ai, 'U', -1._wp, ztauy_ai, 'V', -1. ) !, &
+!            &                           ztaux_bi, 'U', -1.)_wp, ztauy_bi, 'V', -1._wp )
          !
          CALL iom_put( 'utau_oi' , ztaux_oi * zmsk00 )
@@ -1348,5 +1348,5 @@
          END DO
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zsig_I, 'T', 1._wp, zsig_II, 'T', 1._wp)
+         CALL lbc_lnk( 'icedyn_rhg_vp', zsig_I, 'T', 1._wp, zsig_II, 'T', 1._wp)
          
          IF( iom_use('normstr') )   CALL iom_put( 'normstr' ,   zsig_I(:,:)  * zmsk00(:,:) ) ! Normal stress
@@ -1393,5 +1393,5 @@
          IF ( lwp ) WRITE(numout,*) 'Some shitty stress work done'
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zsig1_p, 'T', 1._wp, zsig2_p, 'T', 1._wp)
+         CALL lbc_lnk( 'icedyn_rhg_vp', zsig1_p, 'T', 1._wp, zsig2_p, 'T', 1._wp)
          !      
          IF ( lwp ) WRITE(numout,*) ' Beauaaaarflblbllll '
@@ -1423,6 +1423,6 @@
          END DO
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zspgU, 'U', -1._wp, zspgV, 'V', -1._wp, &
-            &                                 zCorU, 'U', -1._wp, zCorV, 'V', -1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zspgU, 'U', -1._wp, zspgV, 'V', -1._wp, &
+            &                           zCorU, 'U', -1._wp, zCorV, 'V', -1._wp )
          !
          CALL iom_put( 'dssh_dx' , zspgU * zmsk00 )   ! Sea-surface tilt term in force balance (x)
@@ -1453,5 +1453,5 @@
          END DO
             
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zfU, 'U', -1._wp, zfV, 'V', -1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zfU, 'U', -1._wp, zfV, 'V', -1._wp )
          
          CALL iom_put( 'intstrx' , zfU   * zmsk00 )   ! Internal force term in force balance (x)
@@ -1485,7 +1485,7 @@
          END DO
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_vp', zdiag_xmtrp_ice, 'U', -1._wp, zdiag_ymtrp_ice, 'V', -1._wp, &
-            &                                 zdiag_xmtrp_snw, 'U', -1._wp, zdiag_ymtrp_snw, 'V', -1._wp, &
-            &                                 zdiag_xatrp    , 'U', -1._wp, zdiag_yatrp    , 'V', -1._wp )
+         CALL lbc_lnk( 'icedyn_rhg_vp', zdiag_xmtrp_ice, 'U', -1._wp, zdiag_ymtrp_ice, 'V', -1._wp, &
+            &                           zdiag_xmtrp_snw, 'U', -1._wp, zdiag_ymtrp_snw, 'V', -1._wp, &
+            &                           zdiag_xatrp    , 'U', -1._wp, zdiag_yatrp    , 'V', -1._wp )
 
          CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icerst.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icerst.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icerst.F90	(revision 14644)
@@ -89,5 +89,5 @@
                CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
             ELSE
-#if defined key_iomput
+#if defined key_xios
                cw_icerst_cxt = "rstwi_"//TRIM(ADJUSTL(clkt))
                IF( TRIM(Agrif_CFixed()) == '0' ) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icesbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icesbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icesbc.F90	(revision 14644)
@@ -87,5 +87,5 @@
             vtau_ice(ji,jj) = vtau_ice(ji,jj) * xcplmask(ji,jj,0) + zvtau_ice(ji,jj) * ( 1. - xcplmask(ji,jj,0) )
          END_2D
-         CALL lbc_lnk_multi( 'icesbc', utau_ice, 'U', -1.0_wp, vtau_ice, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icesbc', utau_ice, 'U', -1.0_wp, vtau_ice, 'V', -1.0_wp )
       ENDIF
       !
@@ -147,5 +147,5 @@
             &                                         sf(jp_slp)%fnow(:,:,1), sf(jp_qlw)%fnow(:,:,1), &
             &                                         sf(jp_prec)%fnow(:,:,1), sf(jp_snow)%fnow(:,:,1) )
-         IF( ln_mixcpl        )   CALL sbc_cpl_ice_flx( picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su, phs=h_s, phi=h_i )
+         IF( ln_mixcpl        )   CALL sbc_cpl_ice_flx( kt, picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su, phs=h_s, phi=h_i )
          IF( nn_flxdist /= -1 )   CALL ice_flx_dist   ( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_flxdist )
          !                        !    compute conduction flux and surface temperature (as in Jules surface module)
@@ -153,5 +153,5 @@
             &                     CALL blk_ice_qcn    ( ln_virtual_itd, t_su, t_bo, h_s, h_i )
       CASE ( jp_purecpl )         !--- coupled formulation
-                                  CALL sbc_cpl_ice_flx( picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su, phs=h_s, phi=h_i )
+                                  CALL sbc_cpl_ice_flx( kt, picefr=at_i_b, palbi=alb_ice, psst=sst_m, pist=t_su, phs=h_s, phi=h_i )
          IF( nn_flxdist /= -1 )   CALL ice_flx_dist   ( t_su, alb_ice, qns_ice, qsr_ice, dqns_ice, evap_ice, devap_ice, nn_flxdist )
       END SELECT
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd.F90	(revision 14644)
@@ -136,5 +136,5 @@
          END_2D
       ENDIF
-      CALL lbc_lnk_multi( 'icethd', zfric, 'T',  1.0_wp, zvel, 'T', 1.0_wp )
+      CALL lbc_lnk( 'icethd', zfric, 'T',  1.0_wp, zvel, 'T', 1.0_wp )
       !
       !--------------------------------------------------------------------!
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd_do.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd_do.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd_do.F90	(revision 14644)
@@ -193,5 +193,5 @@
          END_2D
          ! 
-         CALL lbc_lnk_multi( 'icethd_do', zvrel, 'T', 1.0_wp, ht_i_new, 'T', 1.0_wp  )
+         CALL lbc_lnk( 'icethd_do', zvrel, 'T', 1.0_wp, ht_i_new, 'T', 1.0_wp  )
 
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd_pnd.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd_pnd.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icethd_pnd.F90	(revision 14644)
@@ -511,5 +511,5 @@
       !!-------------------------------------------------------------------
       REAL(wp), PARAMETER :: &   ! shared parameters for topographic melt ponds
-         zTd     = 0.15_wp       , & ! temperature difference for freeze-up (C)
+         zTd     = 273._wp       , & ! temperature difference for freeze-up (K)
          zvp_min = 1.e-4_wp          ! minimum pond volume (m)
 
@@ -530,6 +530,7 @@
          zv_mlt          ! total amount of meltwater produced
 
-      REAL(wp), DIMENSION(jpi,jpj) ::   zvolp, &     !! total melt pond water available before redistribution and drainage
-                                        zvolp_res    !! remaining melt pond water available after drainage
+      REAL(wp), DIMENSION(jpi,jpj) ::   zvolp_ini , &   !! total melt pond water available before redistribution and drainage
+                                        zvolp     , &   !! total melt pond water volume
+                                        zvolp_res       !! remaining melt pond water available after drainage
 
       REAL(wp), DIMENSION(jpi,jpj,jpl) ::   z1_a_i
@@ -624,4 +625,6 @@
       END DO ! ji
 
+      zvolp_ini(:,:) = zvolp(:,:)
+
       !--------------------------------------------------------------
       ! Redistribute and drain water from ponds
@@ -637,5 +640,5 @@
          DO_2D( 1, 1, 1, 1 )
 
-            IF ( at_i(ji,jj) > 0.01 .AND. hm_i(ji,jj) > rn_himin .AND. vt_ip(ji,jj) > zvp_min * at_i(ji,jj) ) THEN
+            IF ( at_i(ji,jj) > 0.01 .AND. hm_i(ji,jj) > rn_himin .AND. zvolp_ini(ji,jj) > zvp_min * at_i(ji,jj) ) THEN
 
                !--------------------------
@@ -688,5 +691,5 @@
 
                         ! differential growth of base of surface floating ice layer
-                        zdTice = MAX( - t_su(ji,jj,jl) - zTd , 0._wp ) ! > 0
+                        zdTice = MAX( - ( t_su(ji,jj,jl) - zTd ) , 0._wp ) ! > 0
                         zomega = rcnd_i * zdTice / zrhoi_L
                         zdHui  = SQRT( 2._wp * zomega * rDt_ice + ( v_il(ji,jj,jl) / a_i(ji,jj,jl) )**2 ) &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/iceupdate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/iceupdate.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/iceupdate.F90	(revision 14644)
@@ -104,5 +104,10 @@
       ! Net heat flux on top of the ice-ocean (W.m-2)
       !----------------------------------------------
-      qt_atm_oi(:,:) = qns_tot(:,:) + qsr_tot(:,:)
+      IF( ln_cndflx ) THEN   ! ice-atm interface = conduction (and melting) fluxes
+         qt_atm_oi(:,:) = ( 1._wp - at_i_b(:,:) ) * ( qns_oce(:,:) + qsr_oce(:,:) ) + qemp_oce(:,:) + &
+            &             SUM( a_i_b * ( qcn_ice + qml_ice + qtr_ice_top ), dim=3 ) + qemp_ice(:,:)
+      ELSE                   ! ice-atm interface = solar and non-solar fluxes
+         qt_atm_oi(:,:) = qns_tot(:,:) + qsr_tot(:,:) 
+      ENDIF
 
       ! --- case we bypass ice thermodynamics --- !
@@ -119,13 +124,19 @@
          ! Solar heat flux reaching the ocean (max) = zqsr (W.m-2)
          !---------------------------------------------------
-         zqsr = qsr_tot(ji,jj) - SUM( a_i_b(ji,jj,:) * ( qsr_ice(ji,jj,:) - qtr_ice_bot(ji,jj,:) ) )
+         IF( ln_cndflx ) THEN   ! ice-atm interface = conduction (and melting) fluxes
+            zqsr = ( 1._wp - at_i_b(ji,jj) ) * qsr_oce(ji,jj) + SUM( a_i_b (ji,jj,:) * qtr_ice_bot(ji,jj,:) )
+         ELSE                   ! ice-atm interface = solar and non-solar fluxes
+            zqsr = qsr_tot(ji,jj) - SUM( a_i_b(ji,jj,:) * ( qsr_ice(ji,jj,:) - qtr_ice_bot(ji,jj,:) ) )
+         ENDIF
 
          ! Total heat flux reaching the ocean = qt_oce_ai (W.m-2)
          !---------------------------------------------------
-         qt_oce_ai(ji,jj) = qt_atm_oi(ji,jj) - hfx_sum(ji,jj) - hfx_bom(ji,jj) - hfx_bog(ji,jj) &
-            &                                - hfx_dif(ji,jj) - hfx_opw(ji,jj) - hfx_snw(ji,jj) &
-            &                                + hfx_thd(ji,jj) + hfx_dyn(ji,jj) + hfx_res(ji,jj) &
-            &                                + hfx_sub(ji,jj) - SUM( qevap_ice(ji,jj,:) * a_i_b(ji,jj,:) ) + hfx_spr(ji,jj)
-
+         IF( ln_icethd ) THEN
+            qt_oce_ai(ji,jj) = qt_atm_oi(ji,jj) - hfx_sum(ji,jj) - hfx_bom(ji,jj) - hfx_bog(ji,jj) &
+               &                                - hfx_dif(ji,jj) - hfx_opw(ji,jj) - hfx_snw(ji,jj) &
+               &                                + hfx_thd(ji,jj) + hfx_dyn(ji,jj) + hfx_res(ji,jj) &
+               &                                + hfx_sub(ji,jj) - SUM( qevap_ice(ji,jj,:) * a_i_b(ji,jj,:) ) + hfx_spr(ji,jj)
+         ENDIF
+         
          ! New qsr and qns used to compute the oceanic heat flux at the next time step
          !----------------------------------------------------------------------------
@@ -144,5 +155,5 @@
          !
          ! the non-solar is simply derived from the solar flux
-         qns(ji,jj) = qt_oce_ai(ji,jj) - zqsr
+         qns(ji,jj) = qt_oce_ai(ji,jj) - qsr(ji,jj)
 
          ! Mass flux at the atm. surface
@@ -275,7 +286,10 @@
 
       ! other heat fluxes
-      IF( iom_use('hfxsensib'  ) )   CALL iom_put( 'hfxsensib'  ,     -qsb_ice_bot * at_i_b         )   ! Sensible oceanic heat flux
+      IF( iom_use('hfxsensib'  ) )   CALL iom_put( 'hfxsensib'  ,      qsb_ice_bot * at_i_b         )   ! Sensible oceanic heat flux
       IF( iom_use('hfxcndbot'  ) )   CALL iom_put( 'hfxcndbot'  , SUM( qcn_ice_bot * a_i_b, dim=3 ) )   ! Bottom conduction flux
       IF( iom_use('hfxcndtop'  ) )   CALL iom_put( 'hfxcndtop'  , SUM( qcn_ice_top * a_i_b, dim=3 ) )   ! Surface conduction flux
+!!    IF( iom_use('hfxmelt'    ) )   CALL iom_put( 'hfxmelt'    , SUM( qml_ice     * a_i_b, dim=3 ) )   ! Surface melt flux
+!!    IF( iom_use('hfxldmelt'  ) )   CALL iom_put( 'hfxldmelt'  ,      fhld        * at_i_b         )   ! Heat in lead for ice melting 
+!!    IF( iom_use('hfxldgrow'  ) )   CALL iom_put( 'hfxldgrow'  ,      qlead       * r1_Dt_ice      )   ! Heat in lead for ice growth
 
       ! controls
@@ -345,5 +359,5 @@
             tmod_io(ji,jj) = zrhoco * SQRT( zmodt )          ! rhoco * |U_ice-U_oce| at T-point
          END_2D
-         CALL lbc_lnk_multi( 'iceupdate', taum, 'T', 1.0_wp, tmod_io, 'T', 1.0_wp )
+         CALL lbc_lnk( 'iceupdate', taum, 'T', 1.0_wp, tmod_io, 'T', 1.0_wp )
          !
          utau_oce(:,:) = utau(:,:)                    !* save the air-ocean stresses at ice time-step
@@ -374,5 +388,5 @@
          vtau(ji,jj) = ( 1._wp - zat_v ) * vtau_oce(ji,jj) + zat_v * zvtau_ice
       END_2D
-      CALL lbc_lnk_multi( 'iceupdate', utau, 'U', -1.0_wp, vtau, 'V', -1.0_wp )   ! lateral boundary condition
+      CALL lbc_lnk( 'iceupdate', utau, 'U', -1.0_wp, vtau, 'V', -1.0_wp )   ! lateral boundary condition
       !
       IF( ln_timing )   CALL timing_stop('ice_update')
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_interp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_interp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_interp.F90	(revision 14644)
@@ -2,5 +2,5 @@
    !!======================================================================
    !!                   ***  MODULE  agrif_oce_interp  ***
-   !! AGRIF: interpolation package for the ocean dynamics (OPA)
+   !! AGRIF: interpolation package for the ocean dynamics (OCE)
    !!======================================================================
    !! History :  2.0  !  2002-06  (L. Debreu)  Original cade
@@ -109,5 +109,5 @@
       vv(:,:,:,Kbb) = vv(:,:,:,Kbb) * vmask(:,:,:) 
 
-      CALL lbc_lnk_multi( 'agrif_istate_oce', uu(:,:,:  ,Kbb), 'U', -1.0_wp , vv(:,:,:,Kbb), 'V', -1.0_wp )
+      CALL lbc_lnk( 'agrif_istate_oce', uu(:,:,:  ,Kbb), 'U', -1.0_wp , vv(:,:,:,Kbb), 'V', -1.0_wp )
       CALL lbc_lnk( 'agrif_istate_oce', ts(:,:,:,:,Kbb), 'T',  1.0_wp )
 
@@ -863,35 +863,35 @@
                   ! Build vertical grids:
                   N_in = mbkt_parent(ji,jj)
-                  ! Input grid (account for partial cells if any):
-                  DO jk=1,N_in
-                     z_in(jk) = ptab(ji,jj,jk,n2) - ptab(ji,jj,k2,n2)
-                     tabin(jk,1:jpts) = ptab(ji,jj,jk,1:jpts)
-                  END DO
+                  N_out = mbkt(ji,jj)
+                  IF (N_in*N_out > 0) THEN
+                     ! Input grid (account for partial cells if any):
+                     DO jk=1,N_in
+                        z_in(jk) = ptab(ji,jj,jk,n2) - ptab(ji,jj,k2,n2)
+                        tabin(jk,1:jpts) = ptab(ji,jj,jk,1:jpts)
+                     END DO
                   
-                  ! Intermediate grid:
-                  IF ( l_vremap ) THEN
-                     DO jk = 1, N_in
-                        h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
-                          &       (1._wp + ptab(ji,jj,k2,n2)/(ht0_parent(ji,jj)*ssmask(ji,jj) + 1._wp - ssmask(ji,jj)))
+                     ! Intermediate grid:
+                     IF ( l_vremap ) THEN
+                        DO jk = 1, N_in
+                           h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
+                             &       (1._wp + ptab(ji,jj,k2,n2)/(ht0_parent(ji,jj)*ssmask(ji,jj) + 1._wp - ssmask(ji,jj)))
+                        END DO
+                        z_in_i(1) = 0.5_wp * h_in_i(1)
+                        DO jk=2,N_in
+                           z_in_i(jk) = z_in_i(jk-1) + 0.5_wp * ( h_in_i(jk) + h_in_i(jk-1) )
+                        END DO
+                        z_in_i(1:N_in) = z_in_i(1:N_in)  - ptab(ji,jj,k2,n2)
+                     ENDIF                              
+
+                     ! Output (Child) grid:
+                     DO jk=1,N_out
+                        h_out(jk) = e3t(ji,jj,jk,Krhs_a)
                      END DO
-                     z_in_i(1) = 0.5_wp * h_in_i(1)
-                     DO jk=2,N_in
-                        z_in_i(jk) = z_in_i(jk-1) + 0.5_wp * ( h_in_i(jk) + h_in_i(jk-1) )
+                     z_out(1) = 0.5_wp * h_out(1)
+                     DO jk=2,N_out
+                        z_out(jk) = z_out(jk-1) + 0.5_wp * ( h_out(jk)+h_out(jk-1) )
                      END DO
-                     z_in_i(1:N_in) = z_in_i(1:N_in)  - ptab(ji,jj,k2,n2)
-                  ENDIF                              
-
-                  ! Output (Child) grid:
-                  N_out = mbkt(ji,jj)
-                  DO jk=1,N_out
-                     h_out(jk) = e3t(ji,jj,jk,Krhs_a)
-                  END DO
-                  z_out(1) = 0.5_wp * h_out(1)
-                  DO jk=2,N_out
-                     z_out(jk) = z_out(jk-1) + 0.5_wp * ( h_out(jk)+h_out(jk-1) )
-                  END DO
-                  IF (.NOT.ln_linssh) z_out(1:N_out) = z_out(1:N_out)  - ssh(ji,jj,Krhs_a)
-
-                  IF (N_in*N_out > 0) THEN
+                     IF (.NOT.ln_linssh) z_out(1:N_out) = z_out(1:N_out)  - ssh(ji,jj,Krhs_a)
+
                      IF( l_ini_child ) THEN
                         CALL remap_linear(tabin(1:N_in,1:jpts),z_in(1:N_in),ts(ji,jj,1:N_out,1:jpts,Krhs_a),              &
@@ -1040,50 +1040,48 @@
                   uu(ji,jj,:,Krhs_a) = 0._wp
                   N_in = mbku_parent(ji,jj)
-                  zhtot = 0._wp
-                  DO jk=1,N_in
-                     !IF (jk==N_in) THEN
-                     !   h_in(jk) = hu0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
-                     !ELSE
-                     !   h_in(jk) = ptab(ji,jj,jk,2)/(e2u(ji,jj)*zrhoy) 
-                     !ENDIF
-                     IF ( l_vremap ) THEN
-                        h_in(jk) = e3u0_parent(ji,jj,jk) 
-                     ELSE
-                        IF (jk==N_in) THEN
-                           h_in(jk) = hu0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
+                  N_out = mbku(ji,jj)
+                  IF (N_in*N_out > 0) THEN
+                     zhtot = 0._wp
+                     DO jk=1,N_in
+                        !IF (jk==N_in) THEN
+                        !   h_in(jk) = hu0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
+                        !ELSE
+                        !   h_in(jk) = ptab(ji,jj,jk,2)/(e2u(ji,jj)*zrhoy) 
+                        !ENDIF
+                        IF ( l_vremap ) THEN
+                           h_in(jk) = e3u0_parent(ji,jj,jk) 
                         ELSE
-                           h_in(jk) = ptab(ji,jj,jk,2)/(e2u(ji,jj)*zrhoy) 
+                           IF (jk==N_in) THEN
+                              h_in(jk) = hu0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
+                           ELSE
+                              h_in(jk) = ptab(ji,jj,jk,2)/(e2u(ji,jj)*zrhoy) 
+                           ENDIF
                         ENDIF
-                     ENDIF
-                     zhtot = zhtot + h_in(jk)
-                     IF( h_in(jk) .GT. 0. ) THEN
-                     tabin(jk) = ptab(ji,jj,jk,1)/(e2u(ji,jj)*zrhoy*h_in(jk))
-                     ELSE
-                     tabin(jk) = 0.
-                     ENDIF
-                 END DO
-                 z_in(1) = 0.5_wp * h_in(1) - zhtot + hu0_parent(ji,jj) 
-                 DO jk=2,N_in
-                    z_in(jk) = z_in(jk-1) + 0.5_wp * (h_in(jk)+h_in(jk-1))
-                 END DO
+                        zhtot = zhtot + h_in(jk)
+                        IF( h_in(jk) .GT. 0. ) THEN
+                           tabin(jk) = ptab(ji,jj,jk,1)/(e2u(ji,jj)*zrhoy*h_in(jk))
+                        ELSE
+                           tabin(jk) = 0.
+                        ENDIF
+                    END DO
+                    z_in(1) = 0.5_wp * h_in(1) - zhtot + hu0_parent(ji,jj) 
+                    DO jk=2,N_in
+                       z_in(jk) = z_in(jk-1) + 0.5_wp * (h_in(jk)+h_in(jk-1))
+                    END DO
                      
-                 N_out = 0
-                 DO jk=1,jpk
-                    IF (umask(ji,jj,jk) == 0) EXIT
-                    N_out = N_out + 1
-                    h_out(N_out) = e3u(ji,jj,jk,Krhs_a)
-                 END DO
-
-                 z_out(1) = 0.5_wp * h_out(1) - SUM(h_out(1:N_out)) + hu_0(ji,jj)
-                 DO jk=2,N_out
-                    z_out(jk) = z_out(jk-1) + 0.5_wp * (h_out(jk-1) + h_out(jk)) 
-                 END DO  
-
-                 IF (N_in*N_out > 0) THEN
-                     IF( l_ini_child ) THEN
-                        CALL remap_linear       (tabin(1:N_in),z_in(1:N_in),uu(ji,jj,1:N_out,Krhs_a),z_out(1:N_out),N_in,N_out,1)
-                     ELSE
-                        CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),uu(ji,jj,1:N_out,Krhs_a),h_out(1:N_out),N_in,N_out,1)
-                     ENDIF   
+                    DO jk=1, N_out
+                       h_out(jk) = e3u(ji,jj,jk,Krhs_a)
+                    END DO
+
+                    z_out(1) = 0.5_wp * h_out(1) - SUM(h_out(1:N_out)) + hu_0(ji,jj)
+                    DO jk=2,N_out
+                       z_out(jk) = z_out(jk-1) + 0.5_wp * (h_out(jk-1) + h_out(jk)) 
+                    END DO  
+
+                    IF( l_ini_child ) THEN
+                       CALL remap_linear       (tabin(1:N_in),z_in(1:N_in),uu(ji,jj,1:N_out,Krhs_a),z_out(1:N_out),N_in,N_out,1)
+                    ELSE
+                       CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),uu(ji,jj,1:N_out,Krhs_a),h_out(1:N_out),N_in,N_out,1)
+                    ENDIF   
                  ENDIF
                END DO
@@ -1171,46 +1169,45 @@
                   vv(ji,jj,:,Krhs_a) = 0._wp
                   N_in = mbkv_parent(ji,jj)
-                  zhtot = 0._wp
-                  DO jk=1,N_in
-                     !IF (jk==N_in) THEN
-                     !   h_in(jk) = hv0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
-                     !ELSE
-                     !   h_in(jk) = ptab(ji,jj,jk,2)/(e1v(ji,jj)*zrhox) 
-                     !ENDIF
-                     IF (l_vremap) THEN
-                        h_in(jk) = e3v0_parent(ji,jj,jk)
-                     ELSE
-                        IF (jk==N_in) THEN
-                           h_in(jk) = hv0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
+                  N_out = mbkv(ji,jj)
+
+                  IF (N_in*N_out > 0) THEN
+                     zhtot = 0._wp
+                     DO jk=1,N_in
+                        !IF (jk==N_in) THEN
+                        !   h_in(jk) = hv0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
+                        !ELSE
+                        !   h_in(jk) = ptab(ji,jj,jk,2)/(e1v(ji,jj)*zrhox) 
+                        !ENDIF
+                        IF (l_vremap) THEN
+                           h_in(jk) = e3v0_parent(ji,jj,jk)
                         ELSE
-                           h_in(jk) = ptab(ji,jj,jk,2)/(e1v(ji,jj)*zrhox) 
+                           IF (jk==N_in) THEN
+                              h_in(jk) = hv0_parent(ji,jj) + ptab(ji,jj,k2,2) - zhtot
+                           ELSE
+                              h_in(jk) = ptab(ji,jj,jk,2)/(e1v(ji,jj)*zrhox) 
+                           ENDIF
                         ENDIF
-                     ENDIF
-                     zhtot = zhtot + h_in(jk)
-                     IF( h_in(jk) .GT. 0. ) THEN
-                       tabin(jk) = ptab(ji,jj,jk,1)/(e1v(ji,jj)*zrhox*h_in(jk))
-                     ELSE
-                       tabin(jk)  = 0.
-                     ENDIF 
-                  END DO
-
-                  z_in(1) = 0.5_wp * h_in(1) - zhtot + hv0_parent(ji,jj)
-                  DO jk=2,N_in
-                     z_in(jk) = z_in(jk-1) + 0.5_wp * (h_in(jk-1)+h_in(jk))
-                  END DO
-
-                  N_out = 0
-                  DO jk=1,jpk
-                     IF (vmask(ji,jj,jk) == 0) EXIT
-                     N_out = N_out + 1
-                     h_out(N_out) = e3v(ji,jj,jk,Krhs_a)
-                  END DO
-
-                  z_out(1) = 0.5_wp * h_out(1) - SUM(h_out(1:N_out)) + hv_0(ji,jj)
-                  DO jk=2,N_out
-                     z_out(jk) = z_out(jk-1) + 0.5_wp * (h_out(jk-1)+h_out(jk))
-                  END DO
+                        zhtot = zhtot + h_in(jk)
+                        IF( h_in(jk) .GT. 0. ) THEN
+                          tabin(jk) = ptab(ji,jj,jk,1)/(e1v(ji,jj)*zrhox*h_in(jk))
+                        ELSE
+                          tabin(jk)  = 0.
+                        ENDIF 
+                     END DO
+
+                     z_in(1) = 0.5_wp * h_in(1) - zhtot + hv0_parent(ji,jj)
+                     DO jk=2,N_in
+                        z_in(jk) = z_in(jk-1) + 0.5_wp * (h_in(jk-1)+h_in(jk))
+                     END DO
+
+                     DO jk=1,N_out
+                        h_out(jk) = e3v(ji,jj,jk,Krhs_a)
+                     END DO
+
+                     z_out(1) = 0.5_wp * h_out(1) - SUM(h_out(1:N_out)) + hv_0(ji,jj)
+                     DO jk=2,N_out
+                        z_out(jk) = z_out(jk-1) + 0.5_wp * (h_out(jk-1)+h_out(jk))
+                     END DO
  
-                  IF (N_in*N_out > 0) THEN
                      IF( l_ini_child ) THEN
                         CALL remap_linear       (tabin(1:N_in),z_in(1:N_in),vv(ji,jj,1:N_out,Krhs_a),z_out(1:N_out),N_in,N_out,1)
@@ -1560,5 +1557,5 @@
                      &                 ptab(ji,jj,jk), tmask(ji,jj,jk) * e3t_0(ji,jj,jk), &
                      &                 mig0(ji), mjg0(jj), jk
-                !     kindic_agr = kindic_agr + 1
+                     kindic_agr = kindic_agr + 1
                   ENDIF
                END DO
@@ -1703,24 +1700,13 @@
 
          IF( l_vremap ) THEN
-            ! Interpolate thicknesses
+            ! Interpolate interfaces 
             ! Warning: these are masked, hence extrapolated prior interpolation.
             DO jk=k1,k2
                DO jj=j1,j2
                   DO ji=i1,i2
-                      ptab(ji,jj,jk,2) = tmask(ji,jj,jk) * e3t(ji,jj,jk,Kmm_a)
+                      ptab(ji,jj,jk,2) = tmask(ji,jj,jk) * gdepw(ji,jj,jk,Kmm_a)
                   END DO
                END DO
             END DO
-
-            ! Extrapolate thicknesses in partial bottom cells:
-            ! Set them to Agrif_SpecialValue (0.). Correct bottom thicknesses are retrieved later on
-            IF (ln_zps) THEN
-               DO jj=j1,j2
-                  DO ji=i1,i2
-                      jk = mbkt(ji,jj)
-                      ptab(ji,jj,jk,2) = 0._wp
-                  END DO
-               END DO           
-            END IF
         
            ! Save ssh at last level:
@@ -1736,20 +1722,20 @@
          IF( l_vremap ) THEN
             IF (ln_linssh) ptab(i1:i2,j1:j2,k2,2) = 0._wp 
-            avm_k(i1:i2,j1:j2,k1:k2) = 0._wp
+            avm_k(i1:i2,j1:j2,1:jpkm1) = 0._wp
                
             DO jj = j1, j2
                DO ji =i1, i2
                   N_in = mbkt_parent(ji,jj)
-                  IF ( tmask(ji,jj,1) == 0._wp) N_in = 0
-                  z_in(N_in+1) = ht0_parent(ji,jj) + ptab(ji,jj,k2,2)
-                  DO jk = N_in, 1, -1  ! Parent vertical grid               
-                        z_in(jk) = z_in(jk+1) - ptab(ji,jj,jk,2)
-                       tabin(jk) = ptab(ji,jj,jk,1)
-                  END DO
-                  N_out = mbkt(ji,jj) 
-                  DO jk = 1, N_out        ! Child vertical grid
-                     z_out(jk) = gdepw(ji,jj,jk,Kmm_a)
-                  END DO
+                  N_out = mbkt(ji,jj)
                   IF (N_in*N_out > 0) THEN
+                     DO jk = 1, N_in  ! Parent vertical grid               
+                        z_in(jk)  = ptab(ji,jj,jk,2) - ptab(ji,jj,k2,2)
+                        tabin(jk) = ptab(ji,jj,jk,1)
+                     END DO
+                     DO jk = 1, N_out        ! Child vertical grid
+                        z_out(jk) = gdepw(ji,jj,jk,Kmm_a) - ssh(ji,jj,Kmm_a)
+                     END DO
+                     IF (.NOT.ln_linssh) z_out(1:N_out) = z_out(1:N_out)  - ssh(ji,jj,Kmm_a)
+
                      CALL remap_linear(tabin(1:N_in),z_in(1:N_in),avm_k(ji,jj,1:N_out),z_out(1:N_out),N_in,N_out,1)
                   ENDIF
@@ -1757,5 +1743,5 @@
             END DO
          ELSE
-            avm_k(i1:i2,j1:j2,k1:k2) = ptab (i1:i2,j1:j2,k1:k2,1)
+            avm_k(i1:i2,j1:j2,1:jpkm1) = ptab (i1:i2,j1:j2,1:jpkm1,1)
          ENDIF
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_sponge.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_sponge.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_sponge.F90	(revision 14644)
@@ -4,5 +4,5 @@
    !!======================================================================
    !!                   ***  MODULE  agrif_oce_interp  ***
-   !! AGRIF: sponge package for the ocean dynamics (OPA)
+   !! AGRIF: sponge package for the ocean dynamics (OCE)
    !!======================================================================
    !! History :  2.0  !  2002-06  (XXX)  Original cade
@@ -236,5 +236,5 @@
       END_2D
       
-      CALL lbc_lnk_multi( 'agrif_Sponge', fspu, 'U', 1._wp, fspv, 'V', 1._wp, fspt, 'T', 1._wp, fspf, 'F', 1._wp )
+      CALL lbc_lnk( 'agrif_Sponge', fspu, 'U', 1._wp, fspv, 'V', 1._wp, fspt, 'T', 1._wp, fspf, 'F', 1._wp )
       !
       ! Remove vertical interpolation where not needed:
@@ -368,5 +368,5 @@
          fspf_2d(ji,jj) = ztabramp(ji,jj) * ssvmask(ji,jj) * ssvmask(ji,jj+1)
          END_2D
-      CALL lbc_lnk_multi( 'agrif_Sponge_2d', fspu_2d, 'U', 1._wp, fspv_2d, 'V', 1._wp, fspt_2d, 'T', 1._wp, fspf_2d, 'F', 1._wp )
+      CALL lbc_lnk( 'agrif_Sponge_2d', fspu_2d, 'U', 1._wp, fspv_2d, 'V', 1._wp, fspt_2d, 'T', 1._wp, fspf_2d, 'F', 1._wp )
       !
 #endif
@@ -658,31 +658,29 @@
                   tabres_child(ji,jj,:) = 0._wp
                   N_in = mbku_parent(ji,jj)
-                  zhtot = 0._wp
-                  DO jk=1,N_in
-                     !IF (jk==N_in) THEN
-                     !   h_in(jk) = hu0_parent(ji,jj) + tabres(ji,jj,k2,m2) - zhtot
-                     !ELSE
-                     !   h_in(jk) = tabres(ji,jj,jk,m2)
-                     !ENDIF
-                     h_in(jk) = e3u0_parent(ji,jj,jk)
-                     zhtot = zhtot + h_in(jk)
-                     tabin(jk) = tabres(ji,jj,jk,m1)
-                  END DO
-                  !         
-                  N_out = 0
-                  DO jk=1,jpk
-                     IF (umask(ji,jj,jk) == 0) EXIT
-                     N_out = N_out + 1
-                     h_out(N_out) = e3u(ji,jj,jk,Kbb_a)
-                  END DO
-
-                  ! Account for small differences in free-surface
-                  IF ( sum(h_out(1:N_out)) > sum(h_in(1:N_in) )) THEN
-                     h_out(1) = h_out(1) - ( sum(h_out(1:N_out))-sum(h_in(1:N_in)) )
-                  ELSE
-                     h_in(1)   = h_in(1)   - (sum(h_in(1:N_in))-sum(h_out(1:N_out)) )
-                  ENDIF
+                  N_out = mbku(ji,jj)
+                  IF (N_in * N_out > 0) THEN
+                     zhtot = 0._wp
+                     DO jk=1,N_in
+                        !IF (jk==N_in) THEN
+                        !   h_in(jk) = hu0_parent(ji,jj) + tabres(ji,jj,k2,m2) - zhtot
+                        !ELSE
+                        !   h_in(jk) = tabres(ji,jj,jk,m2)
+                        !ENDIF
+                        h_in(jk) = e3u0_parent(ji,jj,jk)
+                        zhtot = zhtot + h_in(jk)
+                        tabin(jk) = tabres(ji,jj,jk,m1)
+                     END DO
+                     !         
+                     DO jk=1,N_out
+                        h_out(jk) = e3u(ji,jj,jk,Kbb_a)
+                     END DO
+
+                     ! Account for small differences in free-surface
+                     IF ( sum(h_out(1:N_out)) > sum(h_in(1:N_in) )) THEN
+                        h_out(1) = h_out(1) - ( sum(h_out(1:N_out))-sum(h_in(1:N_in)) )
+                     ELSE
+                        h_in(1)   = h_in(1)   - (sum(h_in(1:N_in))-sum(h_out(1:N_out)) )
+                     ENDIF
                   
-                  IF (N_in * N_out > 0) THEN
                      CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out,1)
                   ENDIF 
@@ -843,32 +841,31 @@
                   tabres_child(ji,jj,:) = 0._wp
                   N_in = mbkv_parent(ji,jj)
-                  zhtot = 0._wp
-                  DO jk=1,N_in
-                     !IF (jk==N_in) THEN
-                     !   h_in(jk) = hv0_parent(ji,jj) + tabres(ji,jj,k2,m2) - zhtot
-                     !ELSE
-                     !   h_in(jk) = tabres(ji,jj,jk,m2)
-                     !ENDIF
-                     h_in(jk) = e3v0_parent(ji,jj,jk)
-                     zhtot = zhtot + h_in(jk)
-                     tabin(jk) = tabres(ji,jj,jk,m1)
-                  END DO
-                  !          
-                  N_out = 0
-                  DO jk=1,jpk
-                     IF (vmask(ji,jj,jk) == 0) EXIT
-                     N_out = N_out + 1
-                     h_out(N_out) = e3v(ji,jj,jk,Kbb_a)
-                  END DO
-
-                  ! Account for small differences in free-surface
-                  IF ( sum(h_out(1:N_out)) > sum(h_in(1:N_in) )) THEN
-                     h_out(1) = h_out(1) - ( sum(h_out(1:N_out))-sum(h_in(1:N_in)) )
-                  ELSE
-                     h_in(1)   = h_in(1) - (  sum(h_in(1:N_in))-sum(h_out(1:N_out)) )
-                  ENDIF
+                  N_out = mbkv(ji,jj)
+                  IF (N_in * N_out > 0) THEN
+                     zhtot = 0._wp
+                     DO jk=1,N_in
+                        !IF (jk==N_in) THEN
+                        !   h_in(jk) = hv0_parent(ji,jj) + tabres(ji,jj,k2,m2) - zhtot
+                        !ELSE
+                        !   h_in(jk) = tabres(ji,jj,jk,m2)
+                        !ENDIF
+                        h_in(jk) = e3v0_parent(ji,jj,jk)
+                        zhtot = zhtot + h_in(jk)
+                        tabin(jk) = tabres(ji,jj,jk,m1)
+                     END DO
+                     !          
+                     DO jk=1,N_out
+                        h_out(jk) = e3v(ji,jj,jk,Kbb_a)
+                     END DO
+
+                     ! Account for small differences in free-surface
+                     IF ( sum(h_out(1:N_out)) > sum(h_in(1:N_in) )) THEN
+                        h_out(1) = h_out(1) - ( sum(h_out(1:N_out))-sum(h_in(1:N_in)) )
+                     ELSE
+                        h_in(1)   = h_in(1) - (  sum(h_in(1:N_in))-sum(h_out(1:N_out)) )
+                     ENDIF
          
-                  IF (N_in * N_out > 0) THEN
                      CALL reconstructandremap(tabin(1:N_in),h_in(1:N_in),tabres_child(ji,jj,1:N_out),h_out(1:N_out),N_in,N_out,1)
+
                   ENDIF
                END DO
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_update.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_update.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_update.F90	(revision 14644)
@@ -6,5 +6,5 @@
    !!======================================================================
    !!                   ***  MODULE  agrif_oce_interp  ***
-   !! AGRIF: update package for the ocean dynamics (OPA)
+   !! AGRIF: update package for the ocean dynamics (OCE)
    !!======================================================================
    !! History :  2.0  !  2002-06  (L. Debreu)  Original code
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_interp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_interp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_interp.F90	(revision 14644)
@@ -120,35 +120,35 @@
                   ! Build vertical grids:
                   N_in = mbkt_parent(ji,jj)
-                  ! Input grid (account for partial cells if any):
-                  DO jk=1,N_in
-                     z_in(jk) = ptab(ji,jj,jk,n2) - ptab(ji,jj,k2,n2)
-                     tabin(jk,1:jptra) = ptab(ji,jj,jk,1:jptra)
-                  END DO
+                  N_out = mbkt(ji,jj)
+                  IF (N_in*N_out > 0) THEN
+                     ! Input grid (account for partial cells if any):
+                     DO jk=1,N_in
+                        z_in(jk) = ptab(ji,jj,jk,n2) - ptab(ji,jj,k2,n2)
+                        tabin(jk,1:jptra) = ptab(ji,jj,jk,1:jptra)
+                     END DO
                   
-                  ! Intermediate grid:
-                  IF ( l_vremap ) THEN
-                     DO jk = 1, N_in
-                        h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
-                          &       (1._wp + ptab(ji,jj,k2,n2)/(ht0_parent(ji,jj)*ssmask(ji,jj) + 1._wp - ssmask(ji,jj)))
-                     END DO
-                     z_in_i(1) = 0.5_wp * h_in_i(1)
-                     DO jk=2,N_in
-                        z_in_i(jk) = z_in_i(jk-1) + 0.5_wp * ( h_in_i(jk) + h_in_i(jk-1) )
-                     END DO
-                     z_in_i(1:N_in) = z_in_i(1:N_in)  - ptab(ji,jj,k2,n2)
-                  ENDIF
-
-                  ! Output (Child) grid:
-                  N_out = mbkt(ji,jj)
-                  DO jk=1,N_out
-                     h_out(jk) = e3t(ji,jj,jk,Krhs_a)
-                  END DO
-                  z_out(1) = 0.5_wp * h_out(1)
-                  DO jk=2,N_out
-                     z_out(jk) = z_out(jk-1) + 0.5_wp * ( h_out(jk)+h_out(jk-1) )
-                  END DO
-                  IF (.NOT.ln_linssh) z_out(1:N_out) = z_out(1:N_out)  - ssh(ji,jj,Krhs_a)               
-
-                  IF (N_in*N_out > 0) THEN
+                     ! Intermediate grid:
+                     IF ( l_vremap ) THEN
+                        DO jk = 1, N_in
+                           h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
+                             &       (1._wp + ptab(ji,jj,k2,n2)/(ht0_parent(ji,jj)*ssmask(ji,jj) + 1._wp - ssmask(ji,jj)))
+                        END DO
+                        z_in_i(1) = 0.5_wp * h_in_i(1)
+                        DO jk=2,N_in
+                           z_in_i(jk) = z_in_i(jk-1) + 0.5_wp * ( h_in_i(jk) + h_in_i(jk-1) )
+                        END DO
+                        z_in_i(1:N_in) = z_in_i(1:N_in)  - ptab(ji,jj,k2,n2)
+                     ENDIF
+
+                     ! Output (Child) grid:
+                     DO jk=1,N_out
+                        h_out(jk) = e3t(ji,jj,jk,Krhs_a)
+                     END DO
+                     z_out(1) = 0.5_wp * h_out(1)
+                     DO jk=2,N_out
+                        z_out(jk) = z_out(jk-1) + 0.5_wp * ( h_out(jk)+h_out(jk-1) )
+                     END DO
+                     IF (.NOT.ln_linssh) z_out(1:N_out) = z_out(1:N_out)  - ssh(ji,jj,Krhs_a)               
+
                      IF( l_ini_child ) THEN
                         CALL remap_linear(tabin(1:N_in,1:jptra),z_in(1:N_in),tr(ji,jj,1:N_out,1:jptra,Krhs_a),          &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_user.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_user.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_user.F90	(revision 14644)
@@ -63,5 +63,5 @@
 ! In case of East-West periodicity, prevent AGRIF interpolation at east and west boundaries
 ! The procnames will not be called at these boundaries
-      IF (jperio == 1) THEN
+      IF (l_Iperio) THEN
          CALL Agrif_Set_NearCommonBorderX(.TRUE.)
          CALL Agrif_Set_DistantCommonBorderX(.TRUE.)
@@ -209,5 +209,5 @@
       ENDIF
       !
-      CALL lbc_lnk_multi( 'Agrif_Init_Domain', hu0_parent, 'U', 1.0_wp, hv0_parent, 'V', 1.0_wp )
+      CALL lbc_lnk( 'Agrif_Init_Domain', hu0_parent, 'U', 1.0_wp, hv0_parent, 'V', 1.0_wp )
       DO_2D( 0, 0, 0, 0 )
          zk(ji,jj) = REAL( mbku_parent(ji,jj), wp )
@@ -251,5 +251,5 @@
          ENDIF
 
-         CALL lbc_lnk_multi( 'Agrif_Init_Domain', e3u0_parent, 'U', 1.0_wp, e3v0_parent, 'V', 1.0_wp )
+         CALL lbc_lnk( 'Agrif_Init_Domain', e3u0_parent, 'U', 1.0_wp, e3v0_parent, 'V', 1.0_wp )
       ENDIF
 
@@ -272,13 +272,13 @@
                   
             CALL Agrif_check_bat( kindic_agr )           
-
-            CALL mpp_sum( 'agrif_InitValues_Domain', kindic_agr )
-            IF( kindic_agr /= 0 ) THEN
-               CALL ctl_stop('==> Child Bathymetry is NOT correct near boundaries.')
-            ELSE
-               IF(lwp) WRITE(numout,*) '==> Child Bathymetry is ok near boundaries.'
-               IF(lwp) WRITE(numout,*) ' '
-            ENDIF  
          ENDIF
+         !
+         CALL mpp_sum( 'agrif_InitValues_Domain', kindic_agr )
+         IF( kindic_agr /= 0 ) THEN
+            CALL ctl_stop('==> Child Bathymetry is NOT correct near boundaries.')
+         ELSE
+            IF(lwp) WRITE(numout,*) '==> Child Bathymetry is ok near boundaries.'
+            IF(lwp) WRITE(numout,*) ' '
+         ENDIF  
       ENDIF
       !
@@ -532,5 +532,5 @@
       CALL Agrif_Set_bc(   ub2b_cor_id, (/-imaxrho*nn_shift_bar,ind1/) )
       CALL Agrif_Set_bc(   vb2b_cor_id, (/-imaxrho*nn_shift_bar,ind1/) )
-      IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bc( avm_id, (/0,ind1/) )
+      IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bc( avm_id, (/0,ind1-1/) )
 !!$      CALL Agrif_Set_bc(glamt_id, (/0,ind1-1/) )  
 !!$      CALL Agrif_Set_bc(gphit_id, (/0,ind1-1/) )  
@@ -872,5 +872,5 @@
       nbghostcells_y_n = nbghostcells
       !
-      IF(   jperio == 1  )   nbghostcells_x   = 0
+      IF(    l_Iperio    )   nbghostcells_x   = 0
       IF( .NOT. lk_south )   nbghostcells_y_s = 0
       IF( .NOT. lk_north )   nbghostcells_y_n = 0
@@ -889,5 +889,5 @@
 
    
-# if defined key_mpp_mpi
+# if ! defined key_mpi_off
    SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
       !!----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/vremap.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/vremap.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/vremap.F90	(revision 14644)
@@ -1,3 +1,3 @@
-#undef PPR_LIB      /* USE PPR library */
+#define PPR_LIB      /* USE PPR library */
 MODULE vremap
 !$AGRIF_DO_NOT_TREAT
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdydyn2d.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdydyn2d.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdydyn2d.F90	(revision 14644)
@@ -18,4 +18,5 @@
    USE bdylib          ! BDY library routines
    USE phycst          ! physical constants
+   USE lib_mpp, ONLY: jpfillnothing
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE wet_dry         ! Use wet dry to get reference ssh level
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdydyn3d.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdydyn3d.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdydyn3d.F90	(revision 14644)
@@ -15,4 +15,5 @@
    USE bdy_oce         ! ocean open boundary conditions
    USE bdylib          ! for orlanski library routines
+   USE lib_mpp, ONLY: jpfillnothing
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE in_out_manager  !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdyice.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdyice.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdyice.F90	(revision 14644)
@@ -92,11 +92,11 @@
          IF( ANY(llsend1) .OR. ANY(llrecv1) ) THEN   ! if need to send/recv in at least one direction
             ! exchange 3d arrays
-            CALL lbc_lnk_multi('bdyice', a_i , 'T', 1._wp, h_i , 'T', 1._wp, h_s , 'T', 1._wp, oa_i, 'T', 1._wp                   &
-               &                       , s_i , 'T', 1._wp, t_su, 'T', 1._wp, v_i , 'T', 1._wp, v_s , 'T', 1._wp, sv_i, 'T', 1._wp &
-               &                       , a_ip, 'T', 1._wp, v_ip, 'T', 1._wp, v_il, 'T', 1._wp                                     &
-               &                       , kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+            CALL lbc_lnk('bdyice', a_i , 'T', 1._wp, h_i , 'T', 1._wp, h_s , 'T', 1._wp, oa_i, 'T', 1._wp                   &
+               &                 , s_i , 'T', 1._wp, t_su, 'T', 1._wp, v_i , 'T', 1._wp, v_s , 'T', 1._wp, sv_i, 'T', 1._wp &
+               &                 , a_ip, 'T', 1._wp, v_ip, 'T', 1._wp, v_il, 'T', 1._wp                                     &
+               &                 , kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
             ! exchange 4d arrays :   third dimension = 1   and then   third dimension = jpk
-            CALL lbc_lnk_multi('bdyice', t_s , 'T', 1._wp, e_s , 'T', 1._wp, kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
-            CALL lbc_lnk_multi('bdyice', t_i , 'T', 1._wp, e_i , 'T', 1._wp, kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+            CALL lbc_lnk('bdyice', t_s , 'T', 1._wp, e_s , 'T', 1._wp, kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
+            CALL lbc_lnk('bdyice', t_i , 'T', 1._wp, e_i , 'T', 1._wp, kfillmode=jpfillnothing ,lsend=llsend1, lrecv=llrecv1 )
          END IF
       END DO   ! ir
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdyini.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdyini.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdyini.F90	(revision 14644)
@@ -166,7 +166,5 @@
       ! 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(lwp) WRITE(numout,*) 'Number of open boundary sets : ', nb_bdy
 
@@ -575,21 +573,21 @@
                ! check if point has to be sent     to   a neighbour
                ! W neighbour and on the inner left  side
-               IF( ii == 2     .and. (nbondi == 0 .or. nbondi ==  1) )   lsend_bdy(ib_bdy,igrd,1,ir) = .true.
+               IF( ii == 2     .AND. mpiSnei(nn_hls,jpwe) > -1 )   lsend_bdy(ib_bdy,igrd,jpwe,ir) = .TRUE.
                ! E neighbour and on the inner right side
-               IF( ii == jpi-1 .and. (nbondi == 0 .or. nbondi == -1) )   lsend_bdy(ib_bdy,igrd,2,ir) = .true.
+               IF( ii == jpi-1 .AND. mpiSnei(nn_hls,jpea) > -1 )   lsend_bdy(ib_bdy,igrd,jpea,ir) = .TRUE.
                ! S neighbour and on the inner down side
-               IF( ij == 2     .and. (nbondj == 0 .or. nbondj ==  1) )   lsend_bdy(ib_bdy,igrd,3,ir) = .true.
+               IF( ij == 2     .AND. mpiSnei(nn_hls,jpso) > -1 )   lsend_bdy(ib_bdy,igrd,jpso,ir) = .TRUE.
                ! N neighbour and on the inner up   side
-               IF( ij == jpj-1 .and. (nbondj == 0 .or. nbondj == -1) )   lsend_bdy(ib_bdy,igrd,4,ir) = .true.
+               IF( ij == jpj-1 .AND. mpiSnei(nn_hls,jpno) > -1 )   lsend_bdy(ib_bdy,igrd,jpno,ir) = .TRUE.
                !
                ! check if point has to be received from a neighbour
                ! W neighbour and on the outter left  side
-               IF( ii == 1     .and. (nbondi == 0 .or. nbondi ==  1) )   lrecv_bdy(ib_bdy,igrd,1,ir) = .true.
+               IF( ii == 1     .AND. mpiRnei(nn_hls,jpwe) > -1 )   lrecv_bdy(ib_bdy,igrd,jpwe,ir) = .TRUE.
                ! E neighbour and on the outter right side
-               IF( ii == jpi   .and. (nbondi == 0 .or. nbondi == -1) )   lrecv_bdy(ib_bdy,igrd,2,ir) = .true.
+               IF( ii == jpi   .AND. mpiRnei(nn_hls,jpea) > -1 )   lrecv_bdy(ib_bdy,igrd,jpea,ir) = .TRUE.
                ! S neighbour and on the outter down side
-               IF( ij == 1     .and. (nbondj == 0 .or. nbondj ==  1) )   lrecv_bdy(ib_bdy,igrd,3,ir) = .true.
+               IF( ij == 1     .AND. mpiRnei(nn_hls,jpso) > -1 )   lrecv_bdy(ib_bdy,igrd,jpso,ir) = .TRUE.
                ! N neighbour and on the outter up   side
-               IF( ij == jpj   .and. (nbondj == 0 .or. nbondj == -1) )   lrecv_bdy(ib_bdy,igrd,4,ir) = .true.
+               IF( ij == jpj   .AND. mpiRnei(nn_hls,jpno) > -1 )   lrecv_bdy(ib_bdy,igrd,jpno,ir) = .TRUE.
                !
             END DO
@@ -654,5 +652,5 @@
          END DO
       END DO
-      CALL lbc_lnk_multi( 'bdyini', bdyumask, 'U', 1.0_wp , bdyvmask, 'V', 1.0_wp )   ! Lateral boundary cond. 
+      CALL lbc_lnk( 'bdyini', bdyumask, 'U', 1.0_wp , bdyvmask, 'V', 1.0_wp )   ! Lateral boundary cond. 
 
       ! bdy masks are now set to zero on rim 0 points:
@@ -739,19 +737,19 @@
                !      <--    (o exterior)     -->  
                ! (1)  o|x         OR    (2)   x|o
-               !       |___                 ___| 
-               IF( iibi == 0     .OR. ii1 == 0     .OR. ii2 == 0     .OR. ii3 == 0     )   lrecv_bdyint(ib_bdy,igrd,1,ir) = .true.
-               IF( iibi == jpi+1 .OR. ii1 == jpi+1 .OR. ii2 == jpi+1 .OR. ii3 == jpi+1 )   lrecv_bdyint(ib_bdy,igrd,2,ir) = .true.  
-               IF( iibe == 0                                                           )   lrecv_bdyext(ib_bdy,igrd,1,ir) = .true.
-               IF( iibe == jpi+1                                                       )   lrecv_bdyext(ib_bdy,igrd,2,ir) = .true.  
+               !       |___                 ___|
+               IF( iibi==0     .OR. ii1==0     .OR. ii2==0     .OR. ii3==0     )   lrecv_bdyint(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( iibi==jpi+1 .OR. ii1==jpi+1 .OR. ii2==jpi+1 .OR. ii3==jpi+1 )   lrecv_bdyint(ib_bdy,igrd,jpea,ir) = .TRUE.  
+               IF( iibe==0                                                     )   lrecv_bdyext(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( iibe==jpi+1                                                 )   lrecv_bdyext(ib_bdy,igrd,jpea,ir) = .TRUE.  
                ! Check if neighbour has its rim parallel to its mpi subdomain border and located next to its halo
                ! :¨¨¨¨¨|¨¨-->    |                                             |    <--¨¨|¨¨¨¨¨: 
                ! :     |  x:o    |    neighbour limited by ... would need o    |    o:x  |     :
                ! :.....|_._:_____|   (1) W neighbour         E neighbour (2)   |_____:_._|.....:
-               IF( ii == 2     .AND. ( nbondi ==  1 .OR. nbondi == 0 ) .AND. &
-                  & ( iibi == 3     .OR. ii1 == 3     .OR. ii2 == 3     .OR. ii3 == 3    ) )   lsend_bdyint(ib_bdy,igrd,1,ir)=.true.
-               IF( ii == jpi-1 .AND. ( nbondi == -1 .OR. nbondi == 0 ) .AND. &
-                  & ( iibi == jpi-2 .OR. ii1 == jpi-2 .OR. ii2 == jpi-2 .OR. ii3 == jpi-2) )   lsend_bdyint(ib_bdy,igrd,2,ir)=.true.
-               IF( ii == 2     .AND. ( nbondi ==  1 .OR. nbondi == 0 ) .AND. iibe == 3     )   lsend_bdyext(ib_bdy,igrd,1,ir)=.true.
-               IF( ii == jpi-1 .AND. ( nbondi == -1 .OR. nbondi == 0 ) .AND. iibe == jpi-2 )   lsend_bdyext(ib_bdy,igrd,2,ir)=.true.
+               IF( ii==2     .AND. mpiSnei(nn_hls,jpwe) > -1 .AND. &
+                  & ( iibi==3     .OR. ii1==3     .OR. ii2==3     .OR. ii3==3    ) )   lsend_bdyint(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( ii==jpi-1 .AND. mpiSnei(nn_hls,jpea) > -1 .AND. &
+                  & ( iibi==jpi-2 .OR. ii1==jpi-2 .OR. ii2==jpi-2 .OR. ii3==jpi-2) )   lsend_bdyint(ib_bdy,igrd,jpea,ir) = .TRUE.
+               IF( ii==2     .AND. mpiSnei(nn_hls,jpwe) > -1 .AND. iibe==3     )   lsend_bdyext(ib_bdy,igrd,jpwe,ir) = .TRUE.
+               IF( ii==jpi-1 .AND. mpiSnei(nn_hls,jpea) > -1 .AND. iibe==jpi-2 )   lsend_bdyext(ib_bdy,igrd,jpea,ir) = .TRUE.
                !
                ! search neighbour in the north/south direction   
@@ -760,18 +758,18 @@
                !  |   |___x___|   OR    |  |   x   |
                !  v       o           (4)  |       |
-               IF( ijbi == 0     .OR. ij1 == 0     .OR. ij2 == 0     .OR. ij3 == 0     )   lrecv_bdyint(ib_bdy,igrd,3,ir) = .true.
-               IF( ijbi == jpj+1 .OR. ij1 == jpj+1 .OR. ij2 == jpj+1 .OR. ij3 == jpj+1 )   lrecv_bdyint(ib_bdy,igrd,4,ir) = .true.
-               IF( ijbe == 0                                                           )   lrecv_bdyext(ib_bdy,igrd,3,ir) = .true.
-               IF( ijbe == jpj+1                                                       )   lrecv_bdyext(ib_bdy,igrd,4,ir) = .true.
+               IF( ijbi==0     .OR. ij1==0     .OR. ij2==0     .OR. ij3==0     )   lrecv_bdyint(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ijbi==jpj+1 .OR. ij1==jpj+1 .OR. ij2==jpj+1 .OR. ij3==jpj+1 )   lrecv_bdyint(ib_bdy,igrd,jpno,ir) = .TRUE.
+               IF( ijbe==0                                                     )   lrecv_bdyext(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ijbe==jpj+1                                                 )   lrecv_bdyext(ib_bdy,igrd,jpno,ir) = .TRUE.
                ! Check if neighbour has its rim parallel to its mpi subdomain     _________  border and next to its halo
                !   ^  |    o    |                                                :         : 
                !   |  |¨¨¨¨x¨¨¨¨|   neighbour limited by ... would need o     |  |....x....|
                !      :_________:  (3) S neighbour          N neighbour (4)   v  |    o    |   
-               IF( ij == 2     .AND. ( nbondj ==  1 .OR. nbondj == 0 ) .AND. &
-                  & ( ijbi == 3     .OR. ij1 == 3     .OR. ij2 == 3     .OR. ij3 == 3    ) )   lsend_bdyint(ib_bdy,igrd,3,ir)=.true.
-               IF( ij == jpj-1 .AND. ( nbondj == -1 .OR. nbondj == 0 ) .AND. &
-                  & ( ijbi == jpj-2 .OR. ij1 == jpj-2 .OR. ij2 == jpj-2 .OR. ij3 == jpj-2) )   lsend_bdyint(ib_bdy,igrd,4,ir)=.true.
-               IF( ij == 2     .AND. ( nbondj ==  1 .OR. nbondj == 0 ) .AND. ijbe == 3     )   lsend_bdyext(ib_bdy,igrd,3,ir)=.true.
-               IF( ij == jpj-1 .AND. ( nbondj == -1 .OR. nbondj == 0 ) .AND. ijbe == jpj-2 )   lsend_bdyext(ib_bdy,igrd,4,ir)=.true.
+               IF( ij==2     .AND. mpiSnei(nn_hls,jpso) > -1 .AND. &
+                  & ( ijbi==3     .OR. ij1==3     .OR. ij2==3     .OR. ij3==3    ) )   lsend_bdyint(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ij==jpj-1 .AND. mpiSnei(nn_hls,jpno) > -1 .AND. &
+                  & ( ijbi==jpj-2 .OR. ij1==jpj-2 .OR. ij2==jpj-2 .OR. ij3==jpj-2) )   lsend_bdyint(ib_bdy,igrd,jpno,ir) = .TRUE.
+               IF( ij==2     .AND. mpiSnei(nn_hls,jpso) > -1 .AND. ijbe==3     )   lsend_bdyext(ib_bdy,igrd,jpso,ir) = .TRUE.
+               IF( ij==jpj-1 .AND. mpiSnei(nn_hls,jpno) > -1 .AND. ijbe==jpj-2 )   lsend_bdyext(ib_bdy,igrd,jpno,ir) = .TRUE.
             END DO
          END DO
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdytra.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdytra.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdytra.F90	(revision 14644)
@@ -18,4 +18,5 @@
    !
    USE in_out_manager ! I/O manager
+   USE lib_mpp, ONLY: jpfillnothing
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp, ONLY: ctl_stop
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/C1D/step_c1d.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/C1D/step_c1d.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/C1D/step_c1d.F90	(revision 14644)
@@ -42,5 +42,5 @@
       !!
       !! ** Purpose :  - Time stepping of SBC including sea ice (dynamic and thermodynamic eqs.)
-      !!               - Time stepping of OPA (momentum and active tracer eqs.)
+      !!               - Time stepping of OCE (momentum and active tracer eqs.)
       !!               - Time stepping of TOP (passive tracer eqs.)
       !!
@@ -143,5 +143,5 @@
       IF( lrst_oce       )   CALL rst_write( kstp, Nbb, Nnn )  ! write output ocean restart file
       !
-#if defined key_iomput
+#if defined key_xios
       IF( kstp == nitend .OR. nstop > 0 )   CALL xios_context_finalize()   ! needed for XIOS
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crs.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crs.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crs.F90	(revision 14644)
@@ -32,6 +32,6 @@
       INTEGER  ::  jpi_crsm1, jpj_crsm1         !: loop indices      
       INTEGER  ::  jpiglo_crsm1, jpjglo_crsm1   !: loop indices      
-      INTEGER  ::  nperio_full, nperio_crs      !: jperio of parent and coarse grids
-      INTEGER  ::  npolj_full, npolj_crs        !: north fold mark
+!!$      INTEGER  ::  nperio_full, nperio_crs      !: jperio of parent and coarse grids
+!!$      INTEGER  ::  npolj_full, npolj_crs        !: north fold mark
       INTEGER  ::  jpiglo_full, jpjglo_full     !: jpiglo / jpjglo
       INTEGER  ::  npiglo, npjglo               !: jpjglo
@@ -46,25 +46,5 @@
       INTEGER  ::  nimpp_full, njmpp_full       !: global position of point (1,1) of subdomain on parent grid
       INTEGER  ::  nimpp_crs, njmpp_crs         !: set to 1,1 for now .  Valid only for monoproc
-      !cc
-      INTEGER ::   noea_full, nowe_full        !: index of the local neighboring processors in
-      INTEGER ::   noso_full, nono_full        !: east, west, south and north directions
-      INTEGER ::   npne_full, npnw_full        !: index of north east and north west processor
-      INTEGER ::   npse_full, npsw_full        !: index of south east and south west processor
-      INTEGER ::   nbne_full, nbnw_full        !: logical of north east & north west processor
-      INTEGER ::   nbse_full, nbsw_full        !: logical of south east & south west processor
-      INTEGER ::   nidom_full                  !: ???
-      INTEGER ::   nproc_full                  !:number for local processor
-      INTEGER ::   nbondi_full, nbondj_full    !: mark of i- and j-direction local boundaries
-      INTEGER ::   noea_crs, nowe_crs          !: index of the local neighboring processors in
-      INTEGER ::   noso_crs, nono_crs          !: east, west, south and north directions
-      INTEGER ::   npne_crs, npnw_crs          !: index of north east and north west processor
-      INTEGER ::   npse_crs, npsw_crs          !: index of south east and south west processor
-      INTEGER ::   nbne_crs, nbnw_crs          !: logical of north east & north west processor
-      INTEGER ::   nbse_crs, nbsw_crs          !: logical of south east & south west processor
-      INTEGER ::   nidom_crs                   !: ???
-      INTEGER ::   nproc_crs                   !:number for local processor
-      INTEGER ::   nbondi_crs, nbondj_crs      !: mark of i- and j-direction local boundaries
-      
-
+     
       INTEGER, DIMENSION(:), ALLOCATABLE :: mis_crs, mie_crs, mis2_crs, mie2_crs  ! starting and ending i-indices of parent subset
       INTEGER, DIMENSION(:), ALLOCATABLE :: mjs_crs, mje_crs, mjs2_crs, mje2_crs ! starting and ending  j-indices of parent subset
@@ -72,12 +52,12 @@
       INTEGER, DIMENSION(:), ALLOCATABLE :: mi0_crs, mi1_crs, mj0_crs, mj1_crs
       INTEGER  :: mxbinctr, mybinctr            ! central point in grid box
-      INTEGER, DIMENSION(:), ALLOCATABLE ::    jpiall_crs,  jpiall_full   !: dimensions of every subdomain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::   nis0all_crs, nis0all_full   !: first, last indoor index for each i-domain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::   nie0all_crs, nie0all_full   !: first, last indoor index for each j-domain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::    nimppt_crs,  nimppt_full   !: first, last indoor index for each j-domain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::    jpjall_crs,  jpjall_full   !: dimensions of every subdomain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::   njs0all_crs, njs0all_full   !: first, last indoor index for each i-domain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::   nje0all_crs, nje0all_full   !: first, last indoor index for each j-domain
-      INTEGER, DIMENSION(:), ALLOCATABLE ::    njmppt_crs,  njmppt_full   !: first, last indoor index for each j-domain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::    jpiall_crs,  jpiall_full   !: dimensions of every subdomain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::   nis0all_crs, nis0all_full   !: first, last indoor index for each i-domain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::   nie0all_crs, nie0all_full   !: first, last indoor index for each j-domain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::    nimppt_crs,  nimppt_full   !: first, last indoor index for each j-domain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::    jpjall_crs,  jpjall_full   !: dimensions of every subdomain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::   njs0all_crs, njs0all_full   !: first, last indoor index for each i-domain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::   nje0all_crs, nje0all_full   !: first, last indoor index for each j-domain
+!!$      INTEGER, DIMENSION(:), ALLOCATABLE ::    njmppt_crs,  njmppt_full   !: first, last indoor index for each j-domain
 
  
@@ -231,8 +211,8 @@
          &      hmlp_crs(jpi_crs,jpj_crs) , hmlpt_crs(jpi_crs,jpj_crs) , STAT=ierr(14) )
          
-      ALLOCATE( nimppt_crs (jpnij) , jpiall_crs (jpnij) , nis0all_crs (jpnij) , nie0all_crs (jpnij),   &
-         &      nimppt_full(jpnij) , jpiall_full(jpnij) , nis0all_full(jpnij) , nie0all_full(jpnij),   &
-                njmppt_crs (jpnij) , jpjall_crs (jpnij) , njs0all_crs (jpnij) , nje0all_crs (jpnij),   &
-         &      njmppt_full(jpnij) , jpjall_full(jpnij) , njs0all_full(jpnij) , nje0all_full(jpnij)  , STAT=ierr(15) )
+!!$      ALLOCATE( nimppt_crs (jpnij) , jpiall_crs (jpnij) , nis0all_crs (jpnij) , nie0all_crs (jpnij),   &
+!!$         &      nimppt_full(jpnij) , jpiall_full(jpnij) , nis0all_full(jpnij) , nie0all_full(jpnij),   &
+!!$                njmppt_crs (jpnij) , jpjall_crs (jpnij) , njs0all_crs (jpnij) , nje0all_crs (jpnij),   &
+!!$         &      njmppt_full(jpnij) , jpjall_full(jpnij) , njs0all_full(jpnij) , nje0all_full(jpnij)  , STAT=ierr(15) )
    
       crs_dom_alloc = MAXVAL(ierr)
@@ -269,7 +249,7 @@
       jpim1  = jpim1_full
       jpjm1  = jpjm1_full
-      jperio = nperio_full
-
-      npolj  = npolj_full
+!!$      jperio = nperio_full
+
+!!$      npolj  = npolj_full
       jpiglo = jpiglo_full
       jpjglo = jpjglo_full
@@ -284,12 +264,12 @@
       njmpp = njmpp_full
       
-      jpiall (:) = jpiall_full (:)
-      nis0all(:) = nis0all_full(:)
-      nie0all(:) = nie0all_full(:)
-      nimppt (:) = nimppt_full (:)
-      jpjall (:) = jpjall_full (:)
-      njs0all(:) = njs0all_full(:)
-      nje0all(:) = nje0all_full(:)
-      njmppt (:) = njmppt_full (:)
+!!$      jpiall (:) = jpiall_full (:)
+!!$      nis0all(:) = nis0all_full(:)
+!!$      nie0all(:) = nie0all_full(:)
+!!$      nimppt (:) = nimppt_full (:)
+!!$      jpjall (:) = jpjall_full (:)
+!!$      njs0all(:) = njs0all_full(:)
+!!$      nje0all(:) = nje0all_full(:)
+!!$      njmppt (:) = njmppt_full (:)
 
    END SUBROUTINE dom_grid_glo
@@ -308,7 +288,7 @@
       jpim1  = jpi_crsm1
       jpjm1  = jpj_crsm1
-      jperio = nperio_crs
-
-      npolj  = npolj_crs
+!!$      jperio = nperio_crs
+
+!!$      npolj  = npolj_crs
       jpiglo = jpiglo_crs
       jpjglo = jpjglo_crs
@@ -324,12 +304,12 @@
       njmpp = njmpp_crs
       
-      jpiall (:) = jpiall_crs (:)
-      nis0all(:) = nis0all_crs(:)
-      nie0all(:) = nie0all_crs(:)
-      nimppt (:) = nimppt_crs (:)
-      jpjall (:) = jpjall_crs (:)
-      njs0all(:) = njs0all_crs(:)
-      nje0all(:) = nje0all_crs(:)
-      njmppt (:) = njmppt_crs (:)
+!!$      jpiall (:) = jpiall_crs (:)
+!!$      nis0all(:) = nis0all_crs(:)
+!!$      nie0all(:) = nie0all_crs(:)
+!!$      nimppt (:) = nimppt_crs (:)
+!!$      jpjall (:) = jpjall_crs (:)
+!!$      njs0all(:) = njs0all_crs(:)
+!!$      nje0all(:) = nje0all_crs(:)
+!!$      njmppt (:) = njmppt_crs (:)
       !
    END SUBROUTINE dom_grid_crs
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crsdom.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crsdom.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crsdom.F90	(revision 14644)
@@ -30,5 +30,5 @@
    !!       Original.   May 2012.  (J. Simeon, C. Calone, G. Madec, C. Ethe)
    !!===================================================================
-   USE dom_oce        ! ocean space and time domain and to get jperio
+   USE dom_oce        ! ocean space and time domain
    USE crs            ! domain for coarse grid
    !
@@ -1877,183 +1877,183 @@
  
   
-     ! 1.a. Define global domain indices  : take into account the interior domain only ( removes i/j=1 , i/j=jpiglo/jpjglo ) then add 2/3 grid points 
-      jpiglo_crs   = INT( (jpiglo - 2) / nn_factx ) + 2
-  !    jpjglo_crs   = INT( (jpjglo - 2) / nn_facty ) + 2  ! the -2 removes j=1, j=jpj
-  !    jpjglo_crs   = INT( (jpjglo - 2) / nn_facty ) + 3
-      jpjglo_crs   = INT( (jpjglo - MOD(jpjglo, nn_facty)) / nn_facty ) + 3
-      jpiglo_crsm1 = jpiglo_crs - 1
-      jpjglo_crsm1 = jpjglo_crs - 1  
-
-      jpi_crs = ( jpiglo_crs   - 2 * nn_hls + (jpni-1) ) / jpni + 2 * nn_hls
-      jpj_crs = ( jpjglo_crsm1 - 2 * nn_hls + (jpnj-1) ) / jpnj + 2 * nn_hls   
-              
-      IF( noso < 0 ) jpj_crs = jpj_crs + 1    ! add a local band on southern processors  
-       
-      jpi_crsm1   = jpi_crs - 1
-      jpj_crsm1   = jpj_crs - 1
-      nperio_crs  = jperio
-      npolj_crs   = npolj
-      
-      ierr = crs_dom_alloc()          ! allocate most coarse grid arrays
-
-      ! 2.a Define processor domain
-      IF( .NOT. lk_mpp ) THEN
-         nimpp_crs = 1
-         njmpp_crs = 1
-         Nis0_crs  = 1
-         Njs0_crs  = 1
-         Nie0_crs  = jpi_crs
-         Nje0_crs  = jpj_crs
-      ELSE
-         ! Initialisation of most local variables -
-         nimpp_crs = 1
-         njmpp_crs = 1
-         Nis0_crs  = 1
-         Njs0_crs  = 1
-         Nie0_crs  = jpi_crs
-         Nje0_crs  = jpj_crs
-         
-        ! Calculs suivant une découpage en j
-        DO jn = 1, jpnij, jpni
-           IF( jn < ( jpnij - jpni + 1 ) ) THEN
-              nje0all_crs(jn) = AINT( REAL( ( jpjglo - (njmppt(jn     ) - 1) ) / nn_facty, wp ) ) &
-                       &    - AINT( REAL( ( jpjglo - (njmppt(jn+jpni) - 1) ) / nn_facty, wp ) )
-           ELSE                                             
-              nje0all_crs(jn) = AINT( REAL(  nje0all(jn) / nn_facty, wp ) ) + 1            
-           ENDIF
-           IF( noso < 0 ) nje0all_crs(jn) = nje0all_crs(jn) + 1             
-           SELECT CASE( ibonjt(jn) )
-              CASE ( -1 )
-                IF( MOD( jpjglo - njmppt(jn), nn_facty) > 0 )  nje0all_crs(jn) = nje0all_crs(jn) + 1
-                jpjall_crs (jn) = nje0all_crs(jn) + nn_hls
-                njs0all_crs(jn) = njs0all(jn)
-              
-              CASE ( 0 )
-              
-                njs0all_crs(jn) = njs0all(jn)
-                IF( njs0all(jn) == 1 )  nje0all_crs(jn) = nje0all_crs(jn) + 1
-                nje0all_crs(jn) = nje0all_crs(jn) + nn_hls
-                jpjall_crs (jn) = nje0all_crs(jn) + nn_hls
-                
-              CASE ( 1, 2 )
-              
-                nje0all_crs(jn) = nje0all_crs(jn) + nn_hls
-                jpjall_crs (jn) = nje0all_crs(jn)
-                njs0all_crs(jn) = njs0all(jn)
-                
-              CASE DEFAULT
-                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (1) ...' )
-           END SELECT
-           IF( jpjall_crs(jn) > jpj_crs )     jpj_crs = jpj_crs + 1
-
-           IF(njs0all_crs(jn) == 1 ) THEN
-              njmppt_crs(jn) = 1
-           ELSE
-              njmppt_crs(jn) = 2 + ANINT(REAL((njmppt(jn) + 1 - MOD( jpjglo , nn_facty )) / nn_facty, wp ) )
-           ENDIF           
-           
-           DO jj = jn + 1, jn + jpni - 1
-              nje0all_crs(jj) = nje0all_crs(jn) 
-              jpjall_crs (jj) = jpjall_crs(jn)
-              njs0all_crs(jj) = njs0all_crs(jn)
-              njmppt_crs (jj) = njmppt_crs(jn)
-           ENDDO
-        ENDDO 
-        Nje0_crs  = nje0all_crs(nproc + 1) 
-        jpj_crs   = jpjall_crs (nproc + 1)
-        Njs0_crs  = njs0all_crs(nproc + 1)
-        njmpp_crs = njmppt_crs (nproc + 1)
-
-        ! Calcul suivant un decoupage en i
-        DO jn = 1, jpni
-           IF( jn == 1 ) THEN          
-              nie0all_crs(jn) = AINT( REAL( ( nimppt(jn  ) - 1 + jpiall(jn  ) )  / nn_factx, wp) )
-           ELSE
-              nie0all_crs(jn) = AINT( REAL( ( nimppt(jn  ) - 1 + jpiall(jn  ) )  / nn_factx, wp) ) &
-                 &            - AINT( REAL( ( nimppt(jn-1) - 1 + jpiall(jn-1) )  / nn_factx, wp) )
-           ENDIF
-
-           SELECT CASE( ibonit(jn) )
-              CASE ( -1 )
-                 nie0all_crs(jn) = nie0all_crs(jn) + nn_hls           
-                 jpiall_crs (jn) = nie0all_crs(jn) + nn_hls
-                 nis0all_crs(jn) = nis0all(jn) 
-              
-              CASE ( 0 )
-                 nie0all_crs(jn) = nie0all_crs(jn) + nn_hls
-                 jpiall_crs (jn) = nie0all_crs(jn) + nn_hls
-                 nis0all_crs(jn) = nis0all(jn) 
-                
-              CASE ( 1, 2 )
-                 IF( MOD( jpiglo - nimppt(jn), nn_factx) > 0 )  nie0all_crs(jn) = nie0all_crs(jn) + 1
-                 nie0all_crs(jn) = nie0all_crs(jn) + nn_hls
-                 jpiall_crs (jn) = nie0all_crs(jn)
-                 nis0all_crs(jn) = nis0all(jn) 
-
-              CASE DEFAULT
-                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (2) ...' )
-           END SELECT
-
-           nimppt_crs(jn) = ANINT( REAL( (nimppt(jn) + 1 ) / nn_factx, wp ) ) + 1
-           DO jj = jn + jpni , jpnij, jpni
-              nie0all_crs(jj) = nie0all_crs(jn) 
-              jpiall_crs (jj) = jpiall_crs (jn)
-              nis0all_crs(jj) = nis0all_crs(jn)
-              nimppt_crs (jj) = nimppt_crs (jn)
-           ENDDO
-         ENDDO 
-        
-         Nie0_crs  = nie0all_crs(nproc + 1) 
-         jpi_crs   = jpiall_crs (nproc + 1)
-         Nis0_crs  = nis0all_crs(nproc + 1)
-         nimpp_crs = nimppt_crs (nproc + 1)
-
-         DO ji = 1, jpi_crs
-            mig_crs(ji) = ji + nimpp_crs - 1
-         ENDDO
-         DO jj = 1, jpj_crs
-            mjg_crs(jj) = jj + njmpp_crs - 1!
-         ENDDO
-       
-         DO ji = 1, jpiglo_crs
-            mi0_crs(ji) = MAX( 1, MIN( ji - nimpp_crs + 1 , jpi_crs + 1 ) )
-            mi1_crs(ji) = MAX( 0, MIN( ji - nimpp_crs + 1 , jpi_crs     ) )
-         ENDDO
-         
-         DO jj = 1, jpjglo_crs
-            mj0_crs(jj) = MAX( 1, MIN( jj - njmpp_crs + 1 , jpj_crs + 1 ) )
-            mj1_crs(jj) = MAX( 0, MIN( jj - njmpp_crs + 1 , jpj_crs     ) )
-         ENDDO
-
-      ENDIF
-      
-      !                         Save the parent grid information
-      jpi_full    = jpi
-      jpj_full    = jpj
-      jpim1_full  = jpim1
-      jpjm1_full  = jpjm1
-      nperio_full = jperio
-
-      npolj_full  = npolj
-      jpiglo_full = jpiglo
-      jpjglo_full = jpjglo
-
-      jpj_full   = jpj
-      jpi_full   = jpi
-      Nis0_full  = Nis0
-      Njs0_full  = Njs0
-      Nie0_full  = Nie0
-      Nje0_full  = Nje0
-      nimpp_full = nimpp     
-      njmpp_full = njmpp
-      
-      jpiall_full (:) = jpiall (:)
-      nis0all_full(:) = nis0all(:)
-      nie0all_full(:) = nie0all(:)
-      nimppt_full (:) = nimppt (:)
-      jpjall_full (:) = jpjall (:)
-      njs0all_full(:) = njs0all(:)
-      nje0all_full(:) = nje0all(:)
-      njmppt_full (:) = njmppt (:)
+!!$     ! 1.a. Define global domain indices  : take into account the interior domain only ( removes i/j=1 , i/j=jpiglo/jpjglo ) then add 2/3 grid points 
+!!$      jpiglo_crs   = INT( (jpiglo - 2) / nn_factx ) + 2
+!!$  !    jpjglo_crs   = INT( (jpjglo - 2) / nn_facty ) + 2  ! the -2 removes j=1, j=jpj
+!!$  !    jpjglo_crs   = INT( (jpjglo - 2) / nn_facty ) + 3
+!!$      jpjglo_crs   = INT( (jpjglo - MOD(jpjglo, nn_facty)) / nn_facty ) + 3
+!!$      jpiglo_crsm1 = jpiglo_crs - 1
+!!$      jpjglo_crsm1 = jpjglo_crs - 1  
+!!$
+!!$      jpi_crs = ( jpiglo_crs   - 2 * nn_hls + (jpni-1) ) / jpni + 2 * nn_hls
+!!$      jpj_crs = ( jpjglo_crsm1 - 2 * nn_hls + (jpnj-1) ) / jpnj + 2 * nn_hls   
+!!$              
+!!$      IF( noso < 0 ) jpj_crs = jpj_crs + 1    ! add a local band on southern processors  
+!!$       
+!!$      jpi_crsm1   = jpi_crs - 1
+!!$      jpj_crsm1   = jpj_crs - 1
+!!$      nperio_crs  = jperio
+!!$      npolj_crs   = npolj
+!!$      
+!!$      ierr = crs_dom_alloc()          ! allocate most coarse grid arrays
+!!$
+!!$      ! 2.a Define processor domain
+!!$      IF( .NOT. lk_mpp ) THEN
+!!$         nimpp_crs = 1
+!!$         njmpp_crs = 1
+!!$         Nis0_crs  = 1
+!!$         Njs0_crs  = 1
+!!$         Nie0_crs  = jpi_crs
+!!$         Nje0_crs  = jpj_crs
+!!$      ELSE
+!!$         ! Initialisation of most local variables -
+!!$         nimpp_crs = 1
+!!$         njmpp_crs = 1
+!!$         Nis0_crs  = 1
+!!$         Njs0_crs  = 1
+!!$         Nie0_crs  = jpi_crs
+!!$         Nje0_crs  = jpj_crs
+!!$         
+!!$        ! Calculs suivant une découpage en j
+!!$        DO jn = 1, jpnij, jpni
+!!$           IF( jn < ( jpnij - jpni + 1 ) ) THEN
+!!$              nje0all_crs(jn) = AINT( REAL( ( jpjglo - (njmppt(jn     ) - 1) ) / nn_facty, wp ) ) &
+!!$                       &    - AINT( REAL( ( jpjglo - (njmppt(jn+jpni) - 1) ) / nn_facty, wp ) )
+!!$           ELSE                                             
+!!$              nje0all_crs(jn) = AINT( REAL(  nje0all(jn) / nn_facty, wp ) ) + 1            
+!!$           ENDIF
+!!$           IF( noso < 0 ) nje0all_crs(jn) = nje0all_crs(jn) + 1             
+!!$           SELECT CASE( ibonjt(jn) )
+!!$              CASE ( -1 )
+!!$                IF( MOD( jpjglo - njmppt(jn), nn_facty) > 0 )  nje0all_crs(jn) = nje0all_crs(jn) + 1
+!!$                jpjall_crs (jn) = nje0all_crs(jn) + nn_hls
+!!$                njs0all_crs(jn) = njs0all(jn)
+!!$              
+!!$              CASE ( 0 )
+!!$              
+!!$                njs0all_crs(jn) = njs0all(jn)
+!!$                IF( njs0all(jn) == 1 )  nje0all_crs(jn) = nje0all_crs(jn) + 1
+!!$                nje0all_crs(jn) = nje0all_crs(jn) + nn_hls
+!!$                jpjall_crs (jn) = nje0all_crs(jn) + nn_hls
+!!$                
+!!$              CASE ( 1, 2 )
+!!$              
+!!$                nje0all_crs(jn) = nje0all_crs(jn) + nn_hls
+!!$                jpjall_crs (jn) = nje0all_crs(jn)
+!!$                njs0all_crs(jn) = njs0all(jn)
+!!$                
+!!$              CASE DEFAULT
+!!$                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (1) ...' )
+!!$           END SELECT
+!!$           IF( jpjall_crs(jn) > jpj_crs )     jpj_crs = jpj_crs + 1
+!!$
+!!$           IF(njs0all_crs(jn) == 1 ) THEN
+!!$              njmppt_crs(jn) = 1
+!!$           ELSE
+!!$              njmppt_crs(jn) = 2 + ANINT(REAL((njmppt(jn) + 1 - MOD( jpjglo , nn_facty )) / nn_facty, wp ) )
+!!$           ENDIF           
+!!$           
+!!$           DO jj = jn + 1, jn + jpni - 1
+!!$              nje0all_crs(jj) = nje0all_crs(jn) 
+!!$              jpjall_crs (jj) = jpjall_crs(jn)
+!!$              njs0all_crs(jj) = njs0all_crs(jn)
+!!$              njmppt_crs (jj) = njmppt_crs(jn)
+!!$           ENDDO
+!!$        ENDDO 
+!!$        Nje0_crs  = nje0all_crs(narea) 
+!!$        jpj_crs   = jpjall_crs (narea)
+!!$        Njs0_crs  = njs0all_crs(narea)
+!!$        njmpp_crs = njmppt_crs (narea)
+!!$
+!!$        ! Calcul suivant un decoupage en i
+!!$        DO jn = 1, jpni
+!!$           IF( jn == 1 ) THEN          
+!!$              nie0all_crs(jn) = AINT( REAL( ( nimppt(jn  ) - 1 + jpiall(jn  ) )  / nn_factx, wp) )
+!!$           ELSE
+!!$              nie0all_crs(jn) = AINT( REAL( ( nimppt(jn  ) - 1 + jpiall(jn  ) )  / nn_factx, wp) ) &
+!!$                 &            - AINT( REAL( ( nimppt(jn-1) - 1 + jpiall(jn-1) )  / nn_factx, wp) )
+!!$           ENDIF
+!!$
+!!$           SELECT CASE( ibonit(jn) )
+!!$              CASE ( -1 )
+!!$                 nie0all_crs(jn) = nie0all_crs(jn) + nn_hls           
+!!$                 jpiall_crs (jn) = nie0all_crs(jn) + nn_hls
+!!$                 nis0all_crs(jn) = nis0all(jn) 
+!!$              
+!!$              CASE ( 0 )
+!!$                 nie0all_crs(jn) = nie0all_crs(jn) + nn_hls
+!!$                 jpiall_crs (jn) = nie0all_crs(jn) + nn_hls
+!!$                 nis0all_crs(jn) = nis0all(jn) 
+!!$                
+!!$              CASE ( 1, 2 )
+!!$                 IF( MOD( jpiglo - nimppt(jn), nn_factx) > 0 )  nie0all_crs(jn) = nie0all_crs(jn) + 1
+!!$                 nie0all_crs(jn) = nie0all_crs(jn) + nn_hls
+!!$                 jpiall_crs (jn) = nie0all_crs(jn)
+!!$                 nis0all_crs(jn) = nis0all(jn) 
+!!$
+!!$              CASE DEFAULT
+!!$                 CALL ctl_stop( 'STOP', 'error from crs_dom_def, you should not be there (2) ...' )
+!!$           END SELECT
+!!$
+!!$           nimppt_crs(jn) = ANINT( REAL( (nimppt(jn) + 1 ) / nn_factx, wp ) ) + 1
+!!$           DO jj = jn + jpni , jpnij, jpni
+!!$              nie0all_crs(jj) = nie0all_crs(jn) 
+!!$              jpiall_crs (jj) = jpiall_crs (jn)
+!!$              nis0all_crs(jj) = nis0all_crs(jn)
+!!$              nimppt_crs (jj) = nimppt_crs (jn)
+!!$           ENDDO
+!!$         ENDDO 
+!!$        
+!!$         Nie0_crs  = nie0all_crs(narea) 
+!!$         jpi_crs   = jpiall_crs (narea)
+!!$         Nis0_crs  = nis0all_crs(narea)
+!!$         nimpp_crs = nimppt_crs (narea)
+!!$
+!!$         DO ji = 1, jpi_crs
+!!$            mig_crs(ji) = ji + nimpp_crs - 1
+!!$         ENDDO
+!!$         DO jj = 1, jpj_crs
+!!$            mjg_crs(jj) = jj + njmpp_crs - 1!
+!!$         ENDDO
+!!$       
+!!$         DO ji = 1, jpiglo_crs
+!!$            mi0_crs(ji) = MAX( 1, MIN( ji - nimpp_crs + 1 , jpi_crs + 1 ) )
+!!$            mi1_crs(ji) = MAX( 0, MIN( ji - nimpp_crs + 1 , jpi_crs     ) )
+!!$         ENDDO
+!!$         
+!!$         DO jj = 1, jpjglo_crs
+!!$            mj0_crs(jj) = MAX( 1, MIN( jj - njmpp_crs + 1 , jpj_crs + 1 ) )
+!!$            mj1_crs(jj) = MAX( 0, MIN( jj - njmpp_crs + 1 , jpj_crs     ) )
+!!$         ENDDO
+!!$
+!!$      ENDIF
+!!$      
+!!$      !                         Save the parent grid information
+!!$      jpi_full    = jpi
+!!$      jpj_full    = jpj
+!!$      jpim1_full  = jpim1
+!!$      jpjm1_full  = jpjm1
+!!$      nperio_full = jperio
+!!$
+!!$      npolj_full  = npolj
+!!$      jpiglo_full = jpiglo
+!!$      jpjglo_full = jpjglo
+!!$
+!!$      jpj_full   = jpj
+!!$      jpi_full   = jpi
+!!$      Nis0_full  = Nis0
+!!$      Njs0_full  = Njs0
+!!$      Nie0_full  = Nie0
+!!$      Nje0_full  = Nje0
+!!$      nimpp_full = nimpp     
+!!$      njmpp_full = njmpp
+!!$      
+!!$      jpiall_full (:) = jpiall (:)
+!!$      nis0all_full(:) = nis0all(:)
+!!$      nie0all_full(:) = nie0all(:)
+!!$      nimppt_full (:) = nimppt (:)
+!!$      jpjall_full (:) = jpjall (:)
+!!$      njs0all_full(:) = njs0all(:)
+!!$      nje0all_full(:) = nje0all(:)
+!!$      njmppt_full (:) = njmppt (:)
       
       CALL dom_grid_crs  !swich de grille
@@ -2068,5 +2068,5 @@
          WRITE(numout,*) '~~~~~~~   coarse domain local  j-dimension              jpj = ', jpj
          WRITE(numout,*)
-         WRITE(numout,*) ' nproc  = '     , nproc
+         WRITE(numout,*) ' narea  = '     , narea
          WRITE(numout,*) ' jpi    = '     , jpi
          WRITE(numout,*) ' jpj    = '     , jpj
@@ -2097,9 +2097,9 @@
       IF ( nresty == 0 ) THEN
          mybinctr = mybinctr - 1
-         IF ( jperio == 3 .OR. jperio == 4 )  nperio_crs = jperio + 2
-         IF ( jperio == 5 .OR. jperio == 6 )  nperio_crs = jperio - 2 
-
-         IF ( npolj == 3 ) npolj_crs = 5
-         IF ( npolj == 5 ) npolj_crs = 3
+!!$         IF ( jperio == 3 .OR. jperio == 4 )  nperio_crs = jperio + 2
+!!$         IF ( jperio == 5 .OR. jperio == 6 )  nperio_crs = jperio - 2 
+!!$
+!!$         IF ( npolj == 3 ) npolj_crs = 5
+!!$         IF ( npolj == 5 ) npolj_crs = 3
       ENDIF     
       
@@ -2117,64 +2117,64 @@
       CASE ( 0 ) 
 
-         SELECT CASE ( jperio )
-     
- 
-        CASE ( 0, 1, 3, 4 )    !   3, 4 : T-Pivot at North Fold
-        
-            DO ji = 2, jpiglo_crsm1
-               ijie = ( ji * nn_factx ) - nn_factx   !cc
-               ijis = ijie - nn_factx + 1
-               mis2_crs(ji) = ijis
-               mie2_crs(ji) = ijie
-            ENDDO
-            IF ( jpiglo - 1 - mie2_crs(jpiglo_crsm1) <= nn_factx ) mie2_crs(jpiglo_crsm1) = jpiglo - 2  
-
-            ! Handle first the northernmost bin
-            IF ( nn_facty == 2 ) THEN   ;    ijjgloT = jpjglo - 1 
-            ELSE                        ;    ijjgloT = jpjglo
-            ENDIF
-
-            DO jj = 2, jpjglo_crs
-                ijje = ijjgloT - nn_facty * ( jj - 3 )
-                ijjs = ijje - nn_facty + 1                   
-                mjs2_crs(jpjglo_crs-jj+2) = ijjs
-                mje2_crs(jpjglo_crs-jj+2) = ijje
-            ENDDO
-
-         CASE ( 2 ) 
-            WRITE(numout,*)  'crs_init, jperio=2 not supported' 
-        
-         CASE ( 5, 6 )    ! F-pivot at North Fold
-
-            DO ji = 2, jpiglo_crsm1
-               ijie = ( ji * nn_factx ) - nn_factx 
-               ijis = ijie - nn_factx + 1
-               mis2_crs(ji) = ijis
-               mie2_crs(ji) = ijie
-            ENDDO
-            IF ( jpiglo - 1 - mie2_crs(jpiglo_crsm1) <= nn_factx ) mie_crs(jpiglo_crsm1)  = jpiglo - 2 
-
-            ! Treat the northernmost bin separately.
-            jj = 2
-            ijje = jpj - nn_facty * ( jj - 2 )
-            IF ( nn_facty == 3 ) THEN   ;  ijjs = ijje - 1 
-            ELSE                        ;  ijjs = ijje - nn_facty + 1
-            ENDIF
-            mjs2_crs(jpj_crs-jj+1) = ijjs
-            mje2_crs(jpj_crs-jj+1) = ijje
-
-            ! Now bin the rest, any remainder at the south is lumped in the southern bin
-            DO jj = 3, jpjglo_crsm1
-                ijje = jpjglo - nn_facty * ( jj - 2 )
-                ijjs = ijje - nn_facty + 1                  
-                IF ( ijjs <= nn_facty )  ijjs = 2
-                mjs2_crs(jpj_crs-jj+1)   = ijjs
-                mje2_crs(jpj_crs-jj+1)   = ijje
-            ENDDO
-
-         CASE DEFAULT
-            WRITE(numout,*) 'crs_init. Only jperio = 0, 1, 3, 4, 5, 6 supported' 
- 
-         END SELECT
+!!$         SELECT CASE ( jperio )
+!!$     
+!!$ 
+!!$        CASE ( 0, 1, 3, 4 )    !   3, 4 : T-Pivot at North Fold
+!!$        
+!!$            DO ji = 2, jpiglo_crsm1
+!!$               ijie = ( ji * nn_factx ) - nn_factx   !cc
+!!$               ijis = ijie - nn_factx + 1
+!!$               mis2_crs(ji) = ijis
+!!$               mie2_crs(ji) = ijie
+!!$            ENDDO
+!!$            IF ( jpiglo - 1 - mie2_crs(jpiglo_crsm1) <= nn_factx ) mie2_crs(jpiglo_crsm1) = jpiglo - 2  
+!!$
+!!$            ! Handle first the northernmost bin
+!!$            IF ( nn_facty == 2 ) THEN   ;    ijjgloT = jpjglo - 1 
+!!$            ELSE                        ;    ijjgloT = jpjglo
+!!$            ENDIF
+!!$
+!!$            DO jj = 2, jpjglo_crs
+!!$                ijje = ijjgloT - nn_facty * ( jj - 3 )
+!!$                ijjs = ijje - nn_facty + 1                   
+!!$                mjs2_crs(jpjglo_crs-jj+2) = ijjs
+!!$                mje2_crs(jpjglo_crs-jj+2) = ijje
+!!$            ENDDO
+!!$
+!!$         CASE ( 2 ) 
+!!$            WRITE(numout,*)  'crs_init, jperio=2 not supported' 
+!!$        
+!!$         CASE ( 5, 6 )    ! F-pivot at North Fold
+!!$
+!!$            DO ji = 2, jpiglo_crsm1
+!!$               ijie = ( ji * nn_factx ) - nn_factx 
+!!$               ijis = ijie - nn_factx + 1
+!!$               mis2_crs(ji) = ijis
+!!$               mie2_crs(ji) = ijie
+!!$            ENDDO
+!!$            IF ( jpiglo - 1 - mie2_crs(jpiglo_crsm1) <= nn_factx ) mie_crs(jpiglo_crsm1)  = jpiglo - 2 
+!!$
+!!$            ! Treat the northernmost bin separately.
+!!$            jj = 2
+!!$            ijje = jpj - nn_facty * ( jj - 2 )
+!!$            IF ( nn_facty == 3 ) THEN   ;  ijjs = ijje - 1 
+!!$            ELSE                        ;  ijjs = ijje - nn_facty + 1
+!!$            ENDIF
+!!$            mjs2_crs(jpj_crs-jj+1) = ijjs
+!!$            mje2_crs(jpj_crs-jj+1) = ijje
+!!$
+!!$            ! Now bin the rest, any remainder at the south is lumped in the southern bin
+!!$            DO jj = 3, jpjglo_crsm1
+!!$                ijje = jpjglo - nn_facty * ( jj - 2 )
+!!$                ijjs = ijje - nn_facty + 1                  
+!!$                IF ( ijjs <= nn_facty )  ijjs = 2
+!!$                mjs2_crs(jpj_crs-jj+1)   = ijjs
+!!$                mje2_crs(jpj_crs-jj+1)   = ijje
+!!$            ENDDO
+!!$
+!!$         CASE DEFAULT
+!!$            WRITE(numout,*) 'crs_init. Only jperio = 0, 1, 3, 4, 5, 6 supported' 
+!!$ 
+!!$         END SELECT
 
       CASE (1 )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crslbclnk.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crslbclnk.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/CRS/crslbclnk.F90	(revision 14644)
@@ -50,5 +50,5 @@
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, kfillmode, pfillval )
+      CALL lbc_lnk( 'crslbclnk', pt3d1, cd_type1, psgn, kfillmode = kfillmode, pfillval = pfillval )
       !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_glo   ! Return to parent grid domain
@@ -80,5 +80,5 @@
       IF( .NOT.ll_grid_crs )   CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain
       !
-      CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, kfillmode, pfillval )
+      CALL lbc_lnk( 'crslbclnk', pt2d, cd_type, psgn, kfillmode = kfillmode, pfillval = pfillval )
       !
       IF( .NOT.ll_grid_crs )   CALL dom_grid_glo   ! Return to parent grid domain
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diacfl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diacfl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diacfl.F90	(revision 14644)
@@ -61,8 +61,8 @@
       IF( ln_timing )   CALL timing_start('dia_cfl')
       !
-      llmsk(   1:Nis1,:,:) = .FALSE.                                              ! exclude halos from the checked region
-      llmsk(Nie1: jpi,:,:) = .FALSE.
-      llmsk(:,   1:Njs1,:) = .FALSE.
-      llmsk(:,Nje1: jpj,:) = .FALSE.
+      llmsk(     1:nn_hls,:,:) = .FALSE.   ! exclude halos from the checked region
+      llmsk(Nie0+1:   jpi,:,:) = .FALSE.
+      llmsk(:,     1:nn_hls,:) = .FALSE.
+      llmsk(:,Nje0+1:   jpj,:) = .FALSE.
       !
       DO_3D( 0, 0, 0, 0, 1, jpk )      ! calculate Courant numbers
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diadetide.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diadetide.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diadetide.F90	(revision 14644)
@@ -13,5 +13,5 @@
    USE tide_mod
    USE par_kind
-#if defined key_iomput
+#if defined key_xios
    USE xios
 #endif
@@ -48,5 +48,5 @@
 
       lk_diadetide = .FALSE.
-#if defined key_iomput
+#if defined key_xios
       ! Enquire detiding activation state (test for presence of detiding-related
       ! weights field and output file group)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diamlr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diamlr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diamlr.F90	(revision 14644)
@@ -14,7 +14,7 @@
    USE in_out_manager , ONLY :   lwp, numout, ln_timing
    USE iom            , ONLY :   iom_put, iom_use, iom_update_file_name
-   USE timing         , ONLY :   timing_start, timing_stop
+   USE timing         , ONLY :   timing_start, timing_stop	
    USE par_kind
-#if defined key_iomput
+#if defined key_xios
    USE xios
 #endif
@@ -65,5 +65,5 @@
       !!
       !!----------------------------------------------------------------------
-#if defined key_iomput
+#if defined key_xios
 
       TYPE(xios_fieldgroup)                       ::   slxhdl_fldgrp
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diaptr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diaptr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diaptr.F90	(revision 14644)
@@ -382,5 +382,5 @@
             zts(:,:,:,:) = 0._wp
 
-            DO_3D( 1, 0, 1, 1, 1, jpkm1 )
+            DO_3D( 1, 1, 1, 0, 1, jpkm1 )
                zvfc = e1v(ji,jj) * e3v(ji,jj,jk,Kmm)
                zmask(ji,jj,jk)      = vmask(ji,jj,jk)      * zvfc
@@ -437,5 +437,5 @@
             zts(:,:,:,:) = 0._wp
 
-            DO_3D( 1, 0, 1, 1, 1, jpkm1 )
+            DO_3D( 1, 1, 1, 0, 1, jpkm1 )
                zvfc = e1v(ji,jj) * e3v(ji,jj,jk,Kmm)
                zts(ji,jj,jk,jp_tem) = (ts(ji,jj,jk,jp_tem,Kmm)+ts(ji,jj+1,jk,jp_tem,Kmm)) * 0.5 * zvfc  !Tracers averaged onto V grid
@@ -578,5 +578,5 @@
       REAL(wp), DIMENSION(A1Dj(nn_hls),nbasin), INTENT(in)            ::  pva    !
       INTEGER                                               ::  jj
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       INTEGER, DIMENSION(1)           ::  ish1d
       INTEGER, DIMENSION(2)           ::  ish2d
@@ -588,5 +588,5 @@
       END DO
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF( ntile == 0 .OR. ntile == nijtile ) THEN
          ish1d(1) = jpj*nbasin
@@ -614,5 +614,5 @@
       REAL(wp), DIMENSION(A1Dj(nn_hls),jpk,nbasin), INTENT(in)        ::  pva    !
       INTEGER                                               ::  jj, jk
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       INTEGER, DIMENSION(1)              ::  ish1d
       INTEGER, DIMENSION(3)              ::  ish3d
@@ -626,5 +626,5 @@
       END DO
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF( ntile == 0 .OR. ntile == nijtile ) THEN
          ish1d(1) = jpj*jpk*nbasin
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diawri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diawri.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diawri.F90	(revision 14644)
@@ -70,5 +70,5 @@
    PUBLIC   dia_wri_state
    PUBLIC   dia_wri_alloc           ! Called by nemogcm module
-#if ! defined key_iomput   
+#if ! defined key_xios   
    PUBLIC   dia_wri_alloc_abl       ! Called by sbcabl  module (if ln_abl = .true.)
 #endif
@@ -94,7 +94,7 @@
 CONTAINS
 
-#if defined key_iomput
+#if defined key_xios
    !!----------------------------------------------------------------------
-   !!   'key_iomput'                                        use IOM library
+   !!   'key_xios'                                        use IOM library
    !!----------------------------------------------------------------------
    INTEGER FUNCTION dia_wri_alloc()
@@ -250,18 +250,21 @@
       ENDIF
 
-      IF( ln_zad_Aimp ) ww = ww + wi               ! Recombine explicit and implicit parts of vertical velocity for diagnostic output
-      CALL iom_put( "woce", ww )                   ! vertical velocity
+      !                                            ! vertical velocity
+      IF( ln_zad_Aimp ) THEN   ;   CALL iom_put( "woce", ww + wi )   ! explicit plus implicit parts
+      ELSE                     ;   CALL iom_put( "woce", ww )
+      ENDIF
 
       IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
-         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
-         z2d(:,:) = rho0 * e1e2t(:,:)
+         !                     ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
          DO jk = 1, jpk
-            z3d(:,:,jk) = ww(:,:,jk) * z2d(:,:)
+            IF( ln_zad_Aimp ) THEN
+               z3d(:,:,jk) = rho0 * e1e2t(:,:) * ( ww(:,:,jk) + wi(:,:,jk) )
+            ELSE
+               z3d(:,:,jk) = rho0 * e1e2t(:,:) * ww(:,:,jk)
+            ENDIF
          END DO
          CALL iom_put( "w_masstr" , z3d )  
-         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
-      ENDIF
-      !
-      IF( ln_zad_Aimp ) ww = ww - wi               ! Remove implicit part of vertical velocity that was added for diagnostic output
+         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d * z3d )
+      ENDIF
 
       CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dom_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dom_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dom_oce.F90	(revision 14644)
@@ -65,12 +65,7 @@
    !! space domain parameters
    !!----------------------------------------------------------------------
-   INTEGER, PUBLIC ::   jperio   !: Global domain lateral boundary type (between 0 and 7)
-   !                                !  = 0 closed                 ;   = 1 cyclic East-West
-   !                                !  = 2 cyclic North-South     ;   = 3 North fold T-point pivot
-   !                                !  = 4 cyclic East-West AND North fold T-point pivot
-   !                                !  = 5 North fold F-point pivot
-   !                                !  = 6 cyclic East-West AND North fold F-point pivot
-   !                                !  = 7 bi-cyclic East-West AND North-South
-   LOGICAL, PUBLIC ::   l_Iperio, l_Jperio   !   should we explicitely take care I/J periodicity
+   LOGICAL         , PUBLIC ::   l_Iperio, l_Jperio   ! i- j-periodicity
+   LOGICAL         , PUBLIC ::   l_NFold              ! North Pole folding
+   CHARACTER(len=1), PUBLIC ::   c_NFtype             ! type of North pole Folding: T or F point
 
    ! Tiling namelist
@@ -85,21 +80,7 @@
 
    !                             !: domain MPP decomposition parameters
-   INTEGER             , PUBLIC ::   nimpp, njmpp     !: i- & j-indexes for mpp-subdomain left bottom
-   INTEGER             , PUBLIC ::   nproc            !: number for local processor
-   INTEGER             , PUBLIC ::   narea            !: number for local area
-   INTEGER             , PUBLIC ::   nbondi, nbondj   !: mark of i- and j-direction local boundaries
-   INTEGER, ALLOCATABLE, PUBLIC ::   nbondi_bdy(:)    !: mark i-direction local boundaries for BDY open boundaries
-   INTEGER, ALLOCATABLE, PUBLIC ::   nbondj_bdy(:)    !: mark j-direction local boundaries for BDY open boundaries
-   INTEGER, ALLOCATABLE, PUBLIC ::   nbondi_bdy_b(:)  !: mark i-direction of neighbours local boundaries for BDY open boundaries
-   INTEGER, ALLOCATABLE, PUBLIC ::   nbondj_bdy_b(:)  !: mark j-direction of neighbours local boundaries for BDY open boundaries
-
-   INTEGER, PUBLIC ::   npolj             !: north fold mark (0, 3 or 4)
-   INTEGER, PUBLIC ::   noea, nowe        !: index of the local neighboring processors in
-   INTEGER, PUBLIC ::   noso, nono        !: east, west, south and north directions
-   INTEGER, PUBLIC ::   nones, nonws        !: north-east, north-west directions for sending
-   INTEGER, PUBLIC ::   noses, nosws        !: south-east, south-west directions for sending
-   INTEGER, PUBLIC ::   noner, nonwr        !: north-east, north-west directions for receiving
-   INTEGER, PUBLIC ::   noser, noswr        !: south-east, south-west directions for receiving
-   INTEGER, PUBLIC ::   nidom             !: ???
+   INTEGER              , PUBLIC ::   nimpp, njmpp     !: i- & j-indexes for mpp-subdomain left bottom
+   INTEGER              , PUBLIC ::   narea            !: number for local area (starting at 1) = MPI rank + 1
+   INTEGER,               PUBLIC ::   nidom      !: IOIPSL things...
 
    INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mig        !: local ==> global domain, including halos (jpiglo), i-index
@@ -107,15 +88,8 @@
    INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mig0       !: local ==> global domain, excluding halos (Ni0glo), i-index
    INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mjg0       !: local ==> global domain, excluding halos (Nj0glo), j-index
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mig0_oldcmp !: local ==> global domain, excluding halos (Ni0glo), i-index
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mjg0_oldcmp !: local ==> global domain, excluding halos (Nj0glo), j-index
    INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mi0, mi1   !: global, including halos (jpiglo) ==> local domain i-index
    !                                                                !:    (mi0=1 and mi1=0 if global index not in local domain)
    INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   mj0, mj1   !: global, including halos (jpjglo) ==> local domain j-index
    !                                                                !:    (mj0=1 and mj1=0 if global index not in local domain)
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   nimppt,  njmppt   !: i-, j-indexes for each processor
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ibonit,  ibonjt   !: i-, j- processor neighbour existence
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   jpiall,  jpjall   !: dimensions of all subdomain
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   nis0all, njs0all  !: first, last indoor index for all i-subdomain
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   nie0all, nje0all  !: first, last indoor index for all j-subdomain
    INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   nfimpp, nfproc, nfjpi
 
@@ -301,5 +275,5 @@
       !
       ii = ii+1
-      ALLOCATE( mig(jpi), mjg(jpj), mig0(jpi), mjg0(jpj), mig0_oldcmp(jpi), mjg0_oldcmp(jpj), STAT=ierr(ii) )
+      ALLOCATE( mig(jpi), mjg(jpj), mig0(jpi), mjg0(jpj), STAT=ierr(ii) )
          !
       ii = ii+1
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domain.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domain.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domain.F90	(revision 14644)
@@ -113,19 +113,11 @@
          WRITE(numout,*)     '              jpnj    : ', jpnj, '   nn_hls  : ', nn_hls
          WRITE(numout,*)     '              jpnij   : ', jpnij
-         WRITE(numout,*)     '      lateral boundary of the Global domain : jperio  = ', jperio
-         SELECT CASE ( jperio )
-         CASE( 0 )   ;   WRITE(numout,*) '         (i.e. closed)'
-         CASE( 1 )   ;   WRITE(numout,*) '         (i.e. cyclic east-west)'
-         CASE( 2 )   ;   WRITE(numout,*) '         (i.e. cyclic north-south)'
-         CASE( 3 )   ;   WRITE(numout,*) '         (i.e. north fold with T-point pivot)'
-         CASE( 4 )   ;   WRITE(numout,*) '         (i.e. cyclic east-west and north fold with T-point pivot)'
-         CASE( 5 )   ;   WRITE(numout,*) '         (i.e. north fold with F-point pivot)'
-         CASE( 6 )   ;   WRITE(numout,*) '         (i.e. cyclic east-west and north fold with F-point pivot)'
-         CASE( 7 )   ;   WRITE(numout,*) '         (i.e. cyclic east-west and north-south)'
-         CASE DEFAULT
-            CALL ctl_stop( 'dom_init:   jperio is out of range' )
-         END SELECT
+         WRITE(numout,*)     '      lateral boundary of the Global domain:'
+         WRITE(numout,*)     '              cyclic east-west             :', l_Iperio
+         WRITE(numout,*)     '              cyclic north-south           :', l_Jperio
+         WRITE(numout,*)     '              North Pole folding           :', l_NFold
+         WRITE(numout,*)     '                 type of North pole Folding:', c_NFtype
          WRITE(numout,*)     '      Ocean model configuration used:'
-         WRITE(numout,*)     '         cn_cfg = ', TRIM( cn_cfg ), '   nn_cfg = ', nn_cfg
+         WRITE(numout,*)     '              cn_cfg = ', TRIM( cn_cfg ), '   nn_cfg = ', nn_cfg
       ENDIF
 
@@ -182,5 +174,5 @@
       !                                 != ssh initialization
       !
-      IF( l_offline .OR. l_SAS ) THEN        !* No ocean dynamics calculation : set to 0
+      IF( l_SAS ) THEN        !* No ocean dynamics calculation : set to 0
          ssh(:,:,:) = 0._wp
 #if defined key_agrif
@@ -283,10 +275,4 @@
       mig0(:) = mig(:) - nn_hls
       mjg0(:) = mjg(:) - nn_hls
-      ! WARNING: to keep compatibility with the trunk that was including periodocity into the input data,
-      ! we must define mig0 and mjg0 as bellow.
-      ! Once we decide to forget trunk compatibility, we must simply define mig0 and mjg0 as:
-      mig0_oldcmp(:) = mig0(:) + COUNT( (/ jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7 /) )
-      mjg0_oldcmp(:) = mjg0(:) + COUNT( (/ jperio == 2 .OR. jperio == 7 /) )
-      !
       !                              ! global domain, including halos, indices ==> local domain indices
       !                                   ! (return (m.0,m.1)=(1,0) if data domain gridpoint is to the west/south of the
@@ -429,5 +415,5 @@
             WRITE(numout,*) '      frequency of restart file       nn_stock        = ', nn_stock
          ENDIF
-#if ! defined key_iomput
+#if ! defined key_xios
          WRITE(numout,*) '      frequency of output file        nn_write        = ', nn_write
 #endif
@@ -506,5 +492,5 @@
          ENDIF
       ENDIF
-#if ! defined key_iomput
+#if ! defined key_xios
       IF( nn_write == -1 )   CALL ctl_warn( 'nn_write = -1 --> no output files will be done' )
       IF ( nn_write == 0 ) THEN
@@ -628,5 +614,5 @@
 
 
-   SUBROUTINE domain_cfg( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE domain_cfg( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE domain_cfg  ***
@@ -636,10 +622,13 @@
       !! ** Method  :   read the cn_domcfg NetCDF file
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c.
-      !
-      INTEGER ::   inum   ! local integer
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
+      !
+      CHARACTER(len=7) ::   catt                  ! 'T', 'F', '-' or 'UNKNOWN'
+      INTEGER ::   inum, iperio, iatt             ! local integer
       REAL(wp) ::   zorca_res                     ! local scalars
       REAL(wp) ::   zperio                        !   -      -
@@ -655,42 +644,58 @@
       CALL iom_open( cn_domcfg, inum )
       !
-      !                                   !- ORCA family specificity
-      IF(  iom_varid( inum, 'ORCA'       , ldstop = .FALSE. ) > 0  .AND.  &
-         & iom_varid( inum, 'ORCA_index' , ldstop = .FALSE. ) > 0    ) THEN
-         !
-         cd_cfg = 'ORCA'
-         CALL iom_get( inum, 'ORCA_index', zorca_res )   ;   kk_cfg = NINT( zorca_res )
-         !
-         IF(lwp) THEN
-            WRITE(numout,*) '   .'
-            WRITE(numout,*) '   ==>>>   ORCA configuration '
-            WRITE(numout,*) '   .'
+      CALL iom_getatt( inum,  'CfgName', cd_cfg )   ! returns 'UNKNOWN' if not found
+      CALL iom_getatt( inum, 'CfgIndex', kk_cfg )   ! returns      -999 if not found
+      !
+      ! ------- keep compatibility with OLD VERSION... start -------
+      IF( cd_cfg == 'UNKNOWN' .AND. kk_cfg == -999 ) THEN
+         IF(  iom_varid( inum, 'ORCA'       , ldstop = .FALSE. ) > 0  .AND.  &
+            & iom_varid( inum, 'ORCA_index' , ldstop = .FALSE. ) > 0    ) THEN
+            !
+            cd_cfg = 'ORCA'
+            CALL iom_get( inum, 'ORCA_index', zorca_res )   ;   kk_cfg = NINT( zorca_res )
+            !
+         ELSE
+            CALL iom_getatt( inum, 'cn_cfg', cd_cfg )  ! returns 'UNKNOWN' if not found
+            CALL iom_getatt( inum, 'nn_cfg', kk_cfg )  ! returns      -999 if not found
          ENDIF
-         !
-      ELSE                                !- cd_cfg & k_cfg are not used
-         cd_cfg = 'UNKNOWN'
-         kk_cfg = -9999999
-                                          !- or they may be present as global attributes
-                                          !- (netcdf only)
-         CALL iom_getatt( inum, 'cn_cfg', cd_cfg )  ! returns   !  if not found
-         CALL iom_getatt( inum, 'nn_cfg', kk_cfg )  ! returns -999 if not found
-         IF( TRIM(cd_cfg) == '!') cd_cfg = 'UNKNOWN'
-         IF( kk_cfg == -999     ) kk_cfg = -9999999
-         !
-      ENDIF
-       !
+      ENDIF
+      ! ------- keep compatibility with OLD VERSION... end -------
+      !
       idvar = iom_varid( inum, 'e3t_0', kdimsz = idimsz )   ! use e3t_0, that must exist, to get jp(ijk)glo
       kpi = idimsz(1)
       kpj = idimsz(2)
       kpk = idimsz(3)
-      CALL iom_get( inum, 'jperio', zperio )   ;   kperio = NINT( zperio )
+      !
+      CALL iom_getatt( inum, 'Iperio', iatt )   ;   ldIperio = iatt == 1   ! returns      -999 if not found -> default = .false.
+      CALL iom_getatt( inum, 'Jperio', iatt )   ;   ldJperio = iatt == 1   ! returns      -999 if not found -> default = .false.
+      CALL iom_getatt( inum,  'NFold', iatt )   ;   ldNFold  = iatt == 1   ! returns      -999 if not found -> default = .false.
+      CALL iom_getatt( inum, 'NFtype', catt )                              ! returns 'UNKNOWN' if not found
+      IF( LEN_TRIM(catt) == 1 ) THEN   ;   cdNFtype = TRIM(catt)
+      ELSE                             ;   cdNFtype = '-'
+      ENDIF
+      !
+      ! ------- keep compatibility with OLD VERSION... start -------
+      IF( iatt == -999 .AND. catt == 'UNKNOWN' .AND. iom_varid( inum, 'jperio', ldstop = .FALSE. ) > 0 ) THEN                    
+         CALL iom_get( inum, 'jperio', zperio )   ;   iperio = NINT( zperio )
+         ldIperio = iperio == 1  .OR. iperio == 4 .OR. iperio == 6 .OR. iperio == 7   ! i-periodicity
+         ldJperio = iperio == 2  .OR. iperio == 7                                     ! j-periodicity
+         ldNFold  = iperio >= 3 .AND. iperio <= 6                                     ! North pole folding
+         IF(     iperio == 3 .OR. iperio == 4 ) THEN   ;   cdNFtype = 'T'             !    folding at T point
+         ELSEIF( iperio == 5 .OR. iperio == 6 ) THEN   ;   cdNFtype = 'F'             !    folding at F point
+         ELSE                                          ;   cdNFtype = '-'             !    default value
+         ENDIF
+      ENDIF
+      ! ------- keep compatibility with OLD VERSION... end -------
+      !
       CALL iom_close( inum )
       !
       IF(lwp) THEN
-         WRITE(numout,*) '      cn_cfg = ', TRIM(cd_cfg), '   nn_cfg = ', kk_cfg
+         WRITE(numout,*) '   .'
+         WRITE(numout,*) '   ==>>>   ', TRIM(cn_cfg), ' configuration '
+         WRITE(numout,*) '   .'
+         WRITE(numout,*) '      nn_cfg = ', kk_cfg
          WRITE(numout,*) '      Ni0glo = ', kpi
          WRITE(numout,*) '      Nj0glo = ', kpj
          WRITE(numout,*) '      jpkglo = ', kpk
-         WRITE(numout,*) '      type of global domain lateral boundary   jperio = ', kperio
       ENDIF
       !
@@ -730,22 +735,24 @@
       CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE. )
       !
-      !                             !==  ORCA family specificities  ==!
-      IF( TRIM(cn_cfg) == "orca" .OR. TRIM(cn_cfg) == "ORCA" ) THEN
-         CALL iom_rstput( 0, 0, inum, 'ORCA'      , 1._wp            , ktype = jp_i4 )
-         CALL iom_rstput( 0, 0, inum, 'ORCA_index', REAL( nn_cfg, wp), ktype = jp_i4 )
-      ENDIF
+      !                             !==  Configuration specificities  ==!
+      !
+      CALL iom_putatt( inum,  'CfgName', TRIM(cn_cfg) )
+      CALL iom_putatt( inum, 'CfgIndex',      nn_cfg  )
       !
       !                             !==  domain characteristics  ==!
       !
       !                                   ! lateral boundary of the global domain
-      CALL iom_rstput( 0, 0, inum, 'jperio', REAL( jperio, dp), ktype = jp_i4 )
-      !
+      CALL iom_putatt( inum, 'Iperio', COUNT( (/l_Iperio/) ) )
+      CALL iom_putatt( inum, 'Jperio', COUNT( (/l_Jperio/) ) )
+      CALL iom_putatt( inum,  'NFold', COUNT( (/l_NFold /) ) )
+      CALL iom_putatt( inum, 'NFtype',          c_NFtype     )
+
       !                                   ! type of vertical coordinate
-      CALL iom_rstput( 0, 0, inum, 'ln_zco', REAL(COUNT((/ln_zco/)), dp), ktype = jp_i4 )
-      CALL iom_rstput( 0, 0, inum, 'ln_zps', REAL(COUNT((/ln_zps/)), dp), ktype = jp_i4 )
-      CALL iom_rstput( 0, 0, inum, 'ln_sco', REAL(COUNT((/ln_sco/)), dp), ktype = jp_i4 )
-      !
+      IF(ln_zco)   CALL iom_putatt( inum, 'VertCoord', 'zco' )
+      IF(ln_zps)   CALL iom_putatt( inum, 'VertCoord', 'zps' )
+      IF(ln_sco)   CALL iom_putatt( inum, 'VertCoord', 'sco' )
+      
       !                                   ! ocean cavities under iceshelves
-      CALL iom_rstput( 0, 0, inum, 'ln_isfcav', REAL(COUNT((/ln_isfcav/)), dp), ktype = jp_i4 )
+      CALL iom_putatt( inum, 'IsfCav', COUNT( (/ln_isfcav/) ) )
       !
       !                             !==  horizontal mesh  !
@@ -800,12 +807,7 @@
          CALL iom_rstput( 0, 0, inum, 'ht_0'   , ht_0   , ktype = jp_r8 )
       ENDIF
-      !
-      ! Add some global attributes ( netcdf only )
-      CALL iom_putatt( inum, 'nn_cfg', nn_cfg )
-      CALL iom_putatt( inum, 'cn_cfg', TRIM(cn_cfg) )
-      !
-      !                                ! ============================
-      !                                !        close the files
-      !                                ! ============================
+      !                       ! ============================ !
+      !                       !        close the files
+      !                       ! ============================ !
       CALL iom_close( inum )
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dommsk.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dommsk.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dommsk.F90	(revision 14644)
@@ -162,5 +162,5 @@
             &            * tmask(ji,jj+1,jk) * tmask(ji+1,jj+1,jk)
       END_3D
-      CALL lbc_lnk_multi( 'dommsk', umask, 'U', 1.0_wp, vmask, 'V', 1.0_wp, fmask, 'F', 1.0_wp )      ! Lateral boundary conditions
+      CALL lbc_lnk( 'dommsk', umask, 'U', 1.0_wp, vmask, 'V', 1.0_wp, fmask, 'F', 1.0_wp )      ! Lateral boundary conditions
  
       ! Ocean/land mask at wu-, wv- and w points    (computed from tmask)
@@ -182,5 +182,5 @@
       ssfmask(:,:) = MAXVAL( fmask(:,:,:), DIM=3 )
       IF( lk_SWE ) THEN      ! Shallow Water Eq. case : redefine ssfmask
-         DO_2D( 0,0 , 0,0 )
+         DO_2D( 0,0, 0,0  )
             ssfmask(ji,jj) = MAX(  ssmask(ji,jj+1), ssmask(ji+1,jj+1),  & 
                &                   ssmask(ji,jj  ), ssmask(ji+1,jj  )   )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domqco.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domqco.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domqco.F90	(revision 14644)
@@ -171,5 +171,5 @@
       !
       IF( .NOT.PRESENT( pr3f ) ) THEN              !- lbc on ratio at u-, v-points only
-         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )
+         CALL lbc_lnk( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp )
          !
          !
@@ -195,5 +195,5 @@
 #endif
          !                                                 ! lbc on ratio at u-,v-,f-points
-         CALL lbc_lnk_multi( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )
+         CALL lbc_lnk( 'dom_qco_r3c', pr3u, 'U', 1._wp, pr3v, 'V', 1._wp, pr3f, 'F', 1._wp )
          !
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domvvl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domvvl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domvvl.F90	(revision 14644)
@@ -425,5 +425,5 @@
          !                               ! d - thickness diffusion transport: boundary conditions
          !                             (stored for tracer advction and continuity equation)
-         CALL lbc_lnk_multi( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
+         CALL lbc_lnk( 'domvvl', un_td , 'U' , -1._wp, vn_td , 'V' , -1._wp)
          ! 4 - Time stepping of baroclinic scale factors
          ! ---------------------------------------------
@@ -438,8 +438,8 @@
          END_3D
          !
-         llmsk(   1:Nis1,:,:) = .FALSE.   ! exclude halos from the checked region
-         llmsk(Nie1: jpi,:,:) = .FALSE.
-         llmsk(:,   1:Njs1,:) = .FALSE.
-         llmsk(:,Nje1: jpj,:) = .FALSE.
+         llmsk(     1:nn_hls,:,:) = .FALSE.   ! exclude halos from the checked region
+         llmsk(Nie0+1:   jpi,:,:) = .FALSE.
+         llmsk(:,     1:nn_hls,:) = .FALSE.
+         llmsk(:,Nje0+1:   jpj,:) = .FALSE.
          !
          llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp                  ! define only the inner domain
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domwri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domwri.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domwri.F90	(revision 14644)
@@ -58,6 +58,4 @@
       CHARACTER(len=21) ::   clnam   ! filename (mesh and mask informations)
       INTEGER           ::   ji, jj, jk   ! dummy loop indices
-      INTEGER           ::   izco, izps, isco, icav
-      !                               
       REAL(wp), DIMENSION(jpi,jpj)     ::   zprt, zprw     ! 2D workspace
       REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdepu, zdepv   ! 3D workspace
@@ -74,17 +72,18 @@
       !                                  ! ============================
       CALL iom_open( TRIM(clnam), inum, ldwrt = .TRUE. )
-      !                                                         ! domain characteristics
-      CALL iom_rstput( 0, 0, inum, 'jperio', REAL( jperio, dp), ktype = jp_i4 )
+      !                                                         ! Configuration specificities
+      CALL iom_putatt( inum,  'CfgName', TRIM(cn_cfg) )
+      CALL iom_putatt( inum, 'CfgIndex',      nn_cfg  )
+      !                                                         ! lateral boundary of the global domain
+      CALL iom_putatt( inum,   'Iperio', COUNT( (/l_Iperio/) ) )
+      CALL iom_putatt( inum,   'Jperio', COUNT( (/l_Jperio/) ) )
+      CALL iom_putatt( inum,    'NFold', COUNT( (/l_NFold /) ) )
+      CALL iom_putatt( inum,   'NFtype',          c_NFtype     )
       !                                                         ! type of vertical coordinate
-      IF( ln_zco    ) THEN   ;   izco = 1   ;   ELSE   ;   izco = 0   ;   ENDIF
-      IF( ln_zps    ) THEN   ;   izps = 1   ;   ELSE   ;   izps = 0   ;   ENDIF
-      IF( ln_sco    ) THEN   ;   isco = 1   ;   ELSE   ;   isco = 0   ;   ENDIF
-      CALL iom_rstput( 0, 0, inum, 'ln_zco'   , REAL( izco, dp), ktype = jp_i4 )
-      CALL iom_rstput( 0, 0, inum, 'ln_zps'   , REAL( izps, dp), ktype = jp_i4 )
-      CALL iom_rstput( 0, 0, inum, 'ln_sco'   , REAL( isco, dp), ktype = jp_i4 )
+      IF(ln_zco)   CALL iom_putatt( inum, 'VertCoord', 'zco' )
+      IF(ln_zps)   CALL iom_putatt( inum, 'VertCoord', 'zps' )
+      IF(ln_sco)   CALL iom_putatt( inum, 'VertCoord', 'sco' )
       !                                                         ! ocean cavities under iceshelves
-      IF( ln_isfcav ) THEN   ;   icav = 1   ;   ELSE   ;   icav = 0   ;   ENDIF
-      CALL iom_rstput( 0, 0, inum, 'ln_isfcav', REAL( icav, dp), ktype = jp_i4 )
-  
+      CALL iom_putatt( inum,   'IsfCav', COUNT( (/ln_isfcav/) ) )  
       !                                                         ! masks
       CALL iom_rstput( 0, 0, inum, 'tmask', tmask, ktype = jp_i1 )     !    ! land-sea mask
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domzgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domzgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domzgr.F90	(revision 14644)
@@ -116,12 +116,12 @@
       !
       zmsk(:,:) = 1._wp                                       ! default: no closed boundaries
-      IF( jperio == 0 .OR. jperio == 2 .OR. jperio == 3 .OR. jperio == 5 ) THEN   ! E-W closed
+      IF( .NOT. l_Iperio ) THEN                                    ! E-W closed:
          zmsk(  mi0(     1+nn_hls):mi1(     1+nn_hls),:) = 0._wp   ! first column of inner global domain at 0
          zmsk(  mi0(jpiglo-nn_hls):mi1(jpiglo-nn_hls),:) = 0._wp   ! last  column of inner global domain at 0 
       ENDIF
-      IF( .NOT. ( jperio == 2 .OR. jperio == 7 ) ) THEN                           ! S closed
+      IF( .NOT. l_Jperio ) THEN                                    ! S closed:
          zmsk(:,mj0(     1+nn_hls):mj1(     1+nn_hls)  ) = 0._wp   ! first   line of inner global domain at 0
       ENDIF
-      IF( jperio == 0 .OR. jperio == 1 ) THEN                                     ! N closed
+      IF( .NOT. ( l_Jperio .OR. l_NFold ) ) THEN                   ! N closed:
          zmsk(:,mj0(jpjglo-nn_hls):mj1(jpjglo-nn_hls)  ) = 0._wp   ! last    line of inner global domain at 0
       ENDIF
@@ -227,7 +227,8 @@
       !
       INTEGER  ::   jk     ! dummy loop index
-      INTEGER  ::   inum   ! local logical unit
+      INTEGER  ::   inum, iatt
       REAL(WP) ::   z_zco, z_zps, z_sco, z_cav
       REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      CHARACTER(len=7) ::   catt   ! 'zco', 'zps, 'sco' or 'UNKNOWN'
       !!----------------------------------------------------------------------
       !
@@ -241,14 +242,22 @@
       !
       !                          !* type of vertical coordinate
-      CALL iom_get( inum, 'ln_zco'   , z_zco )
-      CALL iom_get( inum, 'ln_zps'   , z_zps )
-      CALL iom_get( inum, 'ln_sco'   , z_sco )
-      IF( z_zco == 0._wp ) THEN   ;   ld_zco = .false.   ;   ELSE   ;   ld_zco = .true.   ;   ENDIF
-      IF( z_zps == 0._wp ) THEN   ;   ld_zps = .false.   ;   ELSE   ;   ld_zps = .true.   ;   ENDIF
-      IF( z_sco == 0._wp ) THEN   ;   ld_sco = .false.   ;   ELSE   ;   ld_sco = .true.   ;   ENDIF
-      !
+      CALL iom_getatt( inum, 'VertCoord', catt )   ! returns 'UNKNOWN' if not found
+      ld_zco = catt == 'zco'          ! default = .false.
+      ld_zps = catt == 'zps'          ! default = .false.
+      ld_sco = catt == 'sco'          ! default = .false.
       !                          !* ocean cavities under iceshelves
-      CALL iom_get( inum, 'ln_isfcav', z_cav )
-      IF( z_cav == 0._wp ) THEN   ;   ld_isfcav = .false.   ;   ELSE   ;   ld_isfcav = .true.   ;   ENDIF
+      CALL iom_getatt( inum,    'IsfCav', iatt )   ! returns -999 if not found
+      ld_isfcav = iatt == 1           ! default = .false.
+      !
+      ! ------- keep compatibility with OLD VERSION... start -------
+      IF( catt == 'UNKNOWN' ) THEN
+         CALL iom_get( inum,    'ln_zco', z_zco )   ;   ld_zco = z_zco /= 0._wp
+         CALL iom_get( inum,    'ln_zps', z_zps )   ;   ld_zps = z_zps /= 0._wp
+         CALL iom_get( inum,    'ln_sco', z_sco )   ;   ld_sco = z_sco /= 0._wp
+      ENDIF
+      IF( iatt == -999 ) THEN
+         CALL iom_get( inum, 'ln_isfcav', z_cav )   ;   ld_isfcav = z_cav /= 0._wp
+      ENDIF
+      ! ------- keep compatibility with OLD VERSION... end -------
       !
       !                          !* vertical scale factors
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynadv_ubs.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynadv_ubs.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynadv_ubs.F90	(revision 14644)
@@ -127,8 +127,8 @@
          END_2D
       END DO
-      CALL lbc_lnk_multi( 'dynadv_ubs', zlu_uu(:,:,:,1), 'U', 1.0_wp , zlu_uv(:,:,:,1), 'U', 1.0_wp,  &
-                      &   zlu_uu(:,:,:,2), 'U', 1.0_wp , zlu_uv(:,:,:,2), 'U', 1.0_wp,  & 
-                      &   zlv_vv(:,:,:,1), 'V', 1.0_wp , zlv_vu(:,:,:,1), 'V', 1.0_wp,  &
-                      &   zlv_vv(:,:,:,2), 'V', 1.0_wp , zlv_vu(:,:,:,2), 'V', 1.0_wp   )
+      CALL lbc_lnk( 'dynadv_ubs', zlu_uu(:,:,:,1), 'U', 1.0_wp , zlu_uv(:,:,:,1), 'U', 1.0_wp,  &
+         &                        zlu_uu(:,:,:,2), 'U', 1.0_wp , zlu_uv(:,:,:,2), 'U', 1.0_wp,  & 
+         &                        zlv_vv(:,:,:,1), 'V', 1.0_wp , zlv_vu(:,:,:,1), 'V', 1.0_wp,  &
+         &                        zlv_vv(:,:,:,2), 'V', 1.0_wp , zlv_vu(:,:,:,2), 'V', 1.0_wp   )
       !
       !                                      ! ====================== !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf.F90	(revision 14644)
@@ -125,5 +125,5 @@
       REAL(dp)  :: zcoef
       REAL(wp) ::   zue3a, zue3n, zue3b    ! local scalars
-      REAL(wp) ::   zve3a, zve3n, zve3b, z1_2dt   !   -      -
+      REAL(wp) ::   zve3a, zve3n, zve3b           !   -      -
       REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zue, zve, zwfld
       REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zutau, zvtau
@@ -175,5 +175,5 @@
 # endif
       !
-      CALL lbc_lnk_multi( 'dynatf', puu(:,:,:,Kaa), 'U', -1.0_wp, pvv(:,:,:,Kaa), 'V', -1.0_wp )     !* local domain boundaries
+      CALL lbc_lnk( 'dynatf', puu(:,:,:,Kaa), 'U', -1.0_wp, pvv(:,:,:,Kaa), 'V', -1.0_wp )     !* local domain boundaries
       !
       !                                !* BDY open boundaries
@@ -326,6 +326,6 @@
       ENDIF
       IF( l_trddyn ) THEN                ! 3D output: asselin filter trends on momentum
-         zua(:,:,:) = ( puu(:,:,:,Kmm) - zua(:,:,:) ) * z1_2dt
-         zva(:,:,:) = ( pvv(:,:,:,Kmm) - zva(:,:,:) ) * z1_2dt
+         zua(:,:,:) = ( puu(:,:,:,Kmm) - zua(:,:,:) ) * r1_Dt
+         zva(:,:,:) = ( pvv(:,:,:,Kmm) - zva(:,:,:) ) * r1_Dt
          CALL trd_dyn( zua, zva, jpdyn_atf, kt, Kmm )
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf_qco.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf_qco.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf_qco.F90	(revision 14644)
@@ -43,4 +43,5 @@
    USE isf_oce   , ONLY: ln_isf     ! ice shelf
    USE isfdynatf , ONLY: isf_dynatf ! ice shelf volume filter correction subroutine
+   USE zdfdrg    , ONLY: ln_drgice_imp, rCdU_top
    !
    USE in_out_manager ! I/O manager
@@ -99,7 +100,8 @@
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   zue3a, zue3n, zue3b, zcoef    ! local scalars
-      REAL(wp) ::   zve3a, zve3n, zve3b, z1_2dt   !   -      -
+      REAL(wp) ::   zve3a, zve3n, zve3b           !   -      -
       REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zue, zve
       REAL(dp), ALLOCATABLE, DIMENSION(:,:,:) ::   zua, zva
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   ::   zutau, zvtau
       !!----------------------------------------------------------------------
       !
@@ -235,11 +237,39 @@
       ENDIF
       IF( l_trddyn ) THEN                ! 3D output: asselin filter trends on momentum
-         zua(:,:,:) = ( puu(:,:,:,Kmm) - zua(:,:,:) ) * z1_2dt
-         zva(:,:,:) = ( pvv(:,:,:,Kmm) - zva(:,:,:) ) * z1_2dt
+         zua(:,:,:) = ( puu(:,:,:,Kmm) - zua(:,:,:) ) * r1_Dt
+         zva(:,:,:) = ( pvv(:,:,:,Kmm) - zva(:,:,:) ) * r1_Dt
          CALL trd_dyn( zua, zva, jpdyn_atf, kt, Kmm )
       ENDIF
       !
-      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=CASTWP(puu(:,:,:,Kaa)), clinfo1=' nxt  - puu(:,:,:,Kaa): ', mask1=umask,   &
-         &                                  tab3d_2=CASTWP(pvv(:,:,:,Kaa)), clinfo2=' pvv(:,:,:,Kaa): '       , mask2=vmask )
+      IF ( iom_use("utau") ) THEN
+         IF ( ln_drgice_imp.OR.ln_isfcav ) THEN
+            ALLOCATE(zutau(jpi,jpj))
+            DO_2D( 0, 0, 0, 0 )
+               jk = miku(ji,jj)
+               zutau(ji,jj) = utau(ji,jj) + 0.5_wp * rho0 * ( rCdU_top(ji+1,jj)+rCdU_top(ji,jj) ) * puu(ji,jj,jk,Kaa)
+            END_2D
+            CALL iom_put(  "utau", zutau(:,:) )
+            DEALLOCATE(zutau)
+         ELSE
+            CALL iom_put(  "utau", utau(:,:) )
+         ENDIF
+      ENDIF
+      !
+      IF ( iom_use("vtau") ) THEN
+         IF ( ln_drgice_imp.OR.ln_isfcav ) THEN
+            ALLOCATE(zvtau(jpi,jpj))
+            DO_2D( 0, 0, 0, 0 )
+               jk = mikv(ji,jj)
+               zvtau(ji,jj) = vtau(ji,jj) + 0.5_wp * rho0 * ( rCdU_top(ji,jj+1)+rCdU_top(ji,jj) ) * pvv(ji,jj,jk,Kaa)
+            END_2D
+            CALL iom_put(  "vtau", zvtau(:,:) )
+            DEALLOCATE(zvtau)
+         ELSE
+            CALL iom_put(  "vtau", vtau(:,:) )
+         ENDIF
+      ENDIF
+      !
+      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=puu(:,:,:,Kaa), clinfo1=' nxt  - puu(:,:,:,Kaa): ', mask1=umask,   &
+         &                                  tab3d_2=pvv(:,:,:,Kaa), clinfo2=' pvv(:,:,:,Kaa): '       , mask2=vmask )
       !
       IF( ln_dynspg_ts )   DEALLOCATE( zue, zve )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynhpg.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynhpg.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynhpg.F90	(revision 14644)
@@ -420,5 +420,5 @@
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) 'dyn:hpg_sco : hydrostatic pressure gradient trend'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate case, OPA original scheme used'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   s-coordinate case, OCE original scheme used'
       ENDIF
       !
@@ -463,5 +463,5 @@
           END IF
         END_2D
-        CALL lbc_lnk_multi( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )
+        CALL lbc_lnk( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )
       END IF
       !
@@ -690,5 +690,5 @@
           END IF
         END_2D
-        CALL lbc_lnk_multi( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )
+        CALL lbc_lnk( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )
       END IF
 
@@ -794,5 +794,5 @@
       END_3D
 
-      CALL lbc_lnk_multi( 'dynhpg', zdrhox, 'U', 1._wp, zdzx, 'U', 1._wp, zdrhoy, 'V', 1._wp, zdzy, 'V', 1._wp ) 
+      CALL lbc_lnk( 'dynhpg', zdrhox, 'U', 1._wp, zdzx, 'U', 1._wp, zdrhoy, 'V', 1._wp, zdzy, 'V', 1._wp ) 
 
       !-------------------------------------------------------------------------
@@ -998,7 +998,7 @@
       DO_2D( 0, 0, 0, 0 )
          zpgu(ji,jj) = - grav * ( ssh(ji+1,jj,Kmm) - ssh(ji,jj,Kmm) ) * r1_e1u(ji,jj)
-         zpgv(ji,jj) = - grav * ( ssh(ji,jj+1,Kmm) - ssh(ji,jj,Kmm) ) * r1_e2v(ji,jj) 
-      END_2D 
-      ! 
+         zpgv(ji,jj) = - grav * ( ssh(ji,jj+1,Kmm) - ssh(ji,jj,Kmm) ) * r1_e2v(ji,jj)
+      END_2D
+      !
       IF( ln_wd_il ) THEN
          ALLOCATE( zcpx(jpi,jpj) , zcpy(jpi,jpj) )
@@ -1044,5 +1044,5 @@
             ENDIF
          END_2D
-         CALL lbc_lnk_multi( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )
+         CALL lbc_lnk( 'dynhpg', zcpx, 'U', 1.0_wp, zcpy, 'V', 1.0_wp )
       ENDIF
 
@@ -1114,5 +1114,5 @@
       END_2D
 
-      CALL lbc_lnk_multi ('dynhpg', zsshu_n, 'U', 1.0_wp, zsshv_n, 'V', 1.0_wp )
+      CALL lbc_lnk ('dynhpg', zsshu_n, 'U', 1.0_wp, zsshv_n, 'V', 1.0_wp )
 
       DO_2D( 0, 0, 0, 0 )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynldf_iso.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynldf_iso.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynldf_iso.F90	(revision 14644)
@@ -136,5 +136,5 @@
          END_3D
          ! Lateral boundary conditions on the slopes
-         CALL lbc_lnk_multi( 'dynldf_iso', uslp , 'U', -1.0_wp, vslp , 'V', -1.0_wp, wslpi, 'W', -1.0_wp, wslpj, 'W', -1.0_wp )
+         CALL lbc_lnk( 'dynldf_iso', uslp , 'U', -1.0_wp, vslp , 'V', -1.0_wp, wslpi, 'W', -1.0_wp, wslpj, 'W', -1.0_wp )
          !
        ENDIF
@@ -169,5 +169,5 @@
 
          IF( ln_zps ) THEN      ! z-coordinate - partial steps : min(e3u)
-            DO_2D( 0, 0, 0, 1 )
+            DO_2D( 0, 1, 0, 0 )
                zabe1 = ( ahmt(ji,jj,jk)+rn_ahm_b ) * e2t(ji,jj)   &
                   &    * MIN( e3u(ji  ,jj,jk,Kmm),                &
@@ -184,5 +184,5 @@
             END_2D
          ELSE                   ! other coordinate system (zco or sco) : e3t
-            DO_2D( 0, 0, 0, 1 )
+            DO_2D( 0, 1, 0, 0 )
                zabe1 = ( ahmt(ji,jj,jk)+rn_ahm_b )   &
                   &     * e2t(ji,jj) * e3t(ji,jj,jk,Kmm) * r1_e1t(ji,jj)
@@ -220,5 +220,5 @@
          ! i-flux at f-point              |   t   |
 
-         DO_2D( 0, 0, 1, 0 )
+         DO_2D( 1, 0, 0, 0 )
             zabe1 = ( ahmf(ji,jj,jk) + rn_ahm_b )   &
                &     * e2f(ji,jj) * e3f(ji,jj,jk) * r1_e1f(ji,jj)
@@ -236,5 +236,5 @@
          ! j-flux at t-point
          IF( ln_zps ) THEN      ! z-coordinate - partial steps : min(e3u)
-            DO_2D( 0, 1, 1, 0 )
+            DO_2D( 1, 0, 0, 1 )
                zabe2 = ( ahmt(ji,jj,jk)+rn_ahm_b ) * e1t(ji,jj)   &
                   &     * MIN( e3v(ji,jj  ,jk,Kmm),                 &
@@ -251,5 +251,5 @@
             END_2D
          ELSE                   ! other coordinate system (zco or sco) : e3t
-            DO_2D( 0, 1, 1, 0 )
+            DO_2D( 1, 0, 0, 1 )
                zabe2 = ( ahmt(ji,jj,jk)+rn_ahm_b )   &
                   &     * e1t(ji,jj) * e3t(ji,jj,jk,Kmm) * r1_e2t(ji,jj)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynldf_lap_blp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynldf_lap_blp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynldf_lap_blp.F90	(revision 14644)
@@ -186,5 +186,5 @@
       CALL dyn_ldf_lap( kt, Kbb, Kmm, pu, pv, zulap, zvlap, 1 )   ! rotated laplacian applied to pt (output in zlap,Kbb)
       !
-      CALL lbc_lnk_multi( 'dynldf_lap_blp', zulap, 'U', -1.0_wp, zvlap, 'V', -1.0_wp )             ! Lateral boundary conditions
+      CALL lbc_lnk( 'dynldf_lap_blp', zulap, 'U', -1.0_wp, zvlap, 'V', -1.0_wp )             ! Lateral boundary conditions
       !
       CALL dyn_ldf_lap( kt, Kbb, Kmm, CASTWP(zulap), CASTWP(zvlap), pu_rhs, pv_rhs, 2 )   ! rotated laplacian applied to zlap (output in pt(:,:,:,:,Krhs))
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg.F90	(revision 14644)
@@ -58,5 +58,5 @@
 CONTAINS
 
-   SUBROUTINE dyn_spg( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa )
+   SUBROUTINE dyn_spg( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa, k_only_ADV )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE dyn_spg  ***
@@ -81,4 +81,5 @@
       REAL(dp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) :: pssh                 ! SSH
       REAL(wp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) :: puu_b, pvv_b         !barotropic velocities at main time levels
+      INTEGER , OPTIONAL                  , INTENT( in )  ::  k_only_ADV          ! only Advection in the RHS
       !
       INTEGER  ::   ji, jj, jk                   ! dummy loop indices
@@ -99,5 +100,6 @@
       IF(      ln_apr_dyn                                                &   ! atmos. pressure
          .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. ln_tide) )   &   ! tide potential (no time slitting)
-         .OR.  ln_ice_embd ) THEN                                            ! embedded sea-ice
+         .OR.  ln_ice_embd                                               &   ! embedded sea-ice
+         .OR.  ( ln_wave .and. ln_bern_srfc ) ) THEN                         ! depth-independent Bernoulli head
          !
          DO_2D( 0, 0, 0, 0 )
@@ -167,5 +169,5 @@
       SELECT CASE ( nspg )                   !== surface pressure gradient computed and add to the general trend ==!
       CASE ( np_EXP )   ;   CALL dyn_spg_exp( kt,      Kmm,       puu, pvv, Krhs )                    ! explicit
-      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa ) ! time-splitting
+      CASE ( np_TS  )   ;   CALL dyn_spg_ts ( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa, k_only_ADV ) ! time-splitting
       END SELECT
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg_ts.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynspg_ts.F90	(revision 14644)
@@ -119,5 +119,5 @@
 
 
-   SUBROUTINE dyn_spg_ts( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa )
+   SUBROUTINE dyn_spg_ts( kt, Kbb, Kmm, Krhs, puu, pvv, pssh, puu_b, pvv_b, Kaa, k_only_ADV )
       !!----------------------------------------------------------------------
       !!
@@ -147,6 +147,7 @@
       INTEGER                             , INTENT( in )  ::  Kbb, Kmm, Krhs, Kaa ! ocean time level indices
       REAL(dp), DIMENSION(jpi,jpj,jpk,jpt), INTENT(inout) ::  puu, pvv            ! ocean velocities and RHS of momentum equation
-      REAL(dp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) ::  pssh                 ! SSH
-      REAL(wp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) ::  puu_b, pvv_b         ! barotropic velocities at main time levels
+      REAL(dp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) ::  pssh                ! SSH
+      REAL(wp), DIMENSION(jpi,jpj,jpt)    , INTENT(inout) ::  puu_b, pvv_b        ! barotropic velocities at main time levels
+      INTEGER , OPTIONAL                  , INTENT( in )  ::  k_only_ADV          ! only Advection in the RHS
       !
       INTEGER  ::   ji, jj, jk, jn        ! dummy loop indices
@@ -168,7 +169,7 @@
       REAL(wp), DIMENSION(jpi,jpj) :: zCdU_u, zCdU_v   ! top/bottom stress at u- & v-points
       REAL(wp), DIMENSION(jpi,jpj) :: zhU, zhV         ! fluxes
-#if defined key_qco 
-      REAL(wp), DIMENSION(jpi, jpj, jpk) :: ze3u, ze3v
-#endif
+!!st#if defined key_qco 
+!!st      REAL(wp), DIMENSION(jpi, jpj, jpk) :: ze3u, ze3v
+!!st#endif
       !
       REAL(wp) ::   zwdramp                     ! local scalar - only used if ln_wd_dl = .True. 
@@ -238,14 +239,9 @@
       !                                   !  ---------------------------  !
 #if defined key_qco 
-      DO jk = 1 , jpk
-         ze3u(:,:,jk) = e3u(:,:,jk,Kmm)
-         ze3v(:,:,jk) = e3v(:,:,jk,Kmm)
-      END DO
-      !
-      zu_frc(:,:) = SUM( ze3u(:,:,:) * uu(:,:,:,Krhs) * umask(:,:,:) , DIM=3 ) * r1_hu(:,:,Kmm)
-      zv_frc(:,:) = SUM( ze3v(:,:,:) * vv(:,:,:,Krhs) * vmask(:,:,:) , DIM=3 ) * r1_hv(:,:,Kmm)
+      zu_frc(:,:) = SUM( e3u_0(:,:,:  ) * puu(:,:,:,Krhs) * umask(:,:,:), DIM=3 ) * r1_hu_0(:,:)
+      zv_frc(:,:) = SUM( e3v_0(:,:,:  ) * pvv(:,:,:,Krhs) * vmask(:,:,:), DIM=3 ) * r1_hv_0(:,:)
 #else
-      zu_frc(:,:) = SUM( e3u(:,:,:,Kmm) * uu(:,:,:,Krhs) * umask(:,:,:) , DIM=3 ) * r1_hu(:,:,Kmm)
-      zv_frc(:,:) = SUM( e3v(:,:,:,Kmm) * vv(:,:,:,Krhs) * vmask(:,:,:) , DIM=3 ) * r1_hv(:,:,Kmm)
+      zu_frc(:,:) = SUM( e3u(:,:,:,Kmm) * puu(:,:,:,Krhs) * umask(:,:,:), DIM=3 ) * r1_hu(:,:,Kmm)
+      zv_frc(:,:) = SUM( e3v(:,:,:,Kmm) * pvv(:,:,:,Krhs) * vmask(:,:,:), DIM=3 ) * r1_hv(:,:,Kmm)
 #endif 
       !
@@ -253,6 +249,6 @@
       !                                   !=  U(Krhs) => baroclinic trend  =!   (remove its vertical mean)
       DO jk = 1, jpkm1                    !  -----------------------------  !
-         uu(:,:,jk,Krhs) = ( uu(:,:,jk,Krhs) - zu_frc(:,:) ) * umask(:,:,jk)
-         vv(:,:,jk,Krhs) = ( vv(:,:,jk,Krhs) - zv_frc(:,:) ) * vmask(:,:,jk)
+         puu(:,:,jk,Krhs) = ( puu(:,:,jk,Krhs) - zu_frc(:,:) ) * umask(:,:,jk)
+         pvv(:,:,jk,Krhs) = ( pvv(:,:,jk,Krhs) - zv_frc(:,:) ) * vmask(:,:,jk)
       END DO
       
@@ -266,19 +262,27 @@
       !                      ! recompute zwz = f/depth  at every time step for (.NOT.ln_linssh) as the water colomn height changes
       !
-      !                                         !* 2D Coriolis trends
-      zhU(:,:) = puu_b(:,:,Kmm) * hu(:,:,Kmm) * e2u(:,:)        ! now fluxes 
-      zhV(:,:) = pvv_b(:,:,Kmm) * hv(:,:,Kmm) * e1v(:,:)        ! NB: FULL domain : put a value in last row and column
-      !
-      CALL dyn_cor_2d( CASTWP(ht(:,:)), hu(:,:,Kmm), hv(:,:,Kmm), puu_b(:,:,Kmm), pvv_b(:,:,Kmm), zhU, zhV,  &   ! <<== in
-         &                                                                          zu_trd, zv_trd   )   ! ==>> out
-      !
-      DO_2D( 0, 0, 0, 0 )                          ! Remove coriolis term (and possibly spg) from barotropic trend
-          zu_frc(ji,jj) = zu_frc(ji,jj) - zu_trd(ji,jj) * ssumask(ji,jj)
-          zv_frc(ji,jj) = zv_frc(ji,jj) - zv_trd(ji,jj) * ssvmask(ji,jj)
-      END_2D
+      IF( .NOT. PRESENT(k_only_ADV) ) THEN   !* remove the 2D Coriolis trend  
+         zhU(:,:) = puu_b(:,:,Kmm) * hu(:,:,Kmm) * e2u(:,:)        ! now fluxes 
+         zhV(:,:) = pvv_b(:,:,Kmm) * hv(:,:,Kmm) * e1v(:,:)        ! NB: FULL domain : put a value in last row and column
+         !
+         CALL dyn_cor_2d( ht(:,:), hu(:,:,Kmm), hv(:,:,Kmm), puu_b(:,:,Kmm), pvv_b(:,:,Kmm), zhU, zhV,  &   ! <<== in
+            &                                                                          zu_trd, zv_trd   )   ! ==>> out
+         !
+         DO_2D( 0, 0, 0, 0 )                          ! Remove coriolis term (and possibly spg) from barotropic trend
+            zu_frc(ji,jj) = zu_frc(ji,jj) - zu_trd(ji,jj) * ssumask(ji,jj)
+            zv_frc(ji,jj) = zv_frc(ji,jj) - zv_trd(ji,jj) * ssvmask(ji,jj)
+         END_2D
+      ENDIF
       !
       !                                   !=  Add bottom stress contribution from baroclinic velocities  =!
       !                                   !  -----------------------------------------------------------  !
-      CALL dyn_drg_init( Kbb, Kmm, CASTWP(puu), CASTWP(pvv), puu_b ,pvv_b, zu_frc, zv_frc,  zCdU_u, zCdU_v )      ! also provide the barotropic drag coefficients
+      IF( PRESENT(k_only_ADV) ) THEN         !* only Advection in the RHS : provide the barotropic bottom drag coefficients
+         DO_2D( 0, 0, 0, 0 )
+            zCdU_u(ji,jj) = r1_2*( rCdU_bot(ji+1,jj)+rCdU_bot(ji,jj) )
+            zCdU_v(ji,jj) = r1_2*( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj) )
+         END_2D
+      ELSE				     !* remove baroclinic drag AND provide the barotropic drag coefficients
+         CALL dyn_drg_init( Kbb, Kmm, puu, pvv, puu_b, pvv_b, zu_frc, zv_frc, zCdU_u, zCdU_v )
+      ENDIF
       !
       !                                   !=  Add atmospheric pressure forcing  =!
@@ -472,18 +476,18 @@
 #if defined key_qcoTest_FluxForm
             !                                ! 'key_qcoTest_FluxForm' : simple ssh average
-            DO_2D( 1, 1, 1, 0 )   ! not jpi-column
+            DO_2D( 1, 0, 1, 1 )   ! not jpi-column
                zhup2_e(ji,jj) = hu_0(ji,jj) + r1_2 * (  zsshp2_e(ji,jj) + zsshp2_e(ji+1,jj  )  ) * ssumask(ji,jj)
             END_2D
-            DO_2D( 1, 0, 1, 1 )
+            DO_2D( 1, 1, 1, 0 )
                zhvp2_e(ji,jj) = hv_0(ji,jj) + r1_2 * (  zsshp2_e(ji,jj) + zsshp2_e(ji  ,jj+1)  ) * ssvmask(ji,jj)
             END_2D
 #else
             !                                ! no 'key_qcoTest_FluxForm' : surface weighted ssh average
-            DO_2D( 1, 1, 1, 0 )   ! not jpi-column
+            DO_2D( 1, 0, 1, 1 )   ! not jpi-column
                zhup2_e(ji,jj) = hu_0(ji,jj) + r1_2 * r1_e1e2u(ji,jj)                        &
                     &                              * (  e1e2t(ji  ,jj) * zsshp2_e(ji  ,jj)  &
                     &                                 + e1e2t(ji+1,jj) * zsshp2_e(ji+1,jj)  ) * ssumask(ji,jj)
             END_2D
-            DO_2D( 1, 0, 1, 1 )   ! not jpj-row
+            DO_2D( 1, 1, 1, 0 )   ! not jpj-row
                zhvp2_e(ji,jj) = hv_0(ji,jj) + r1_2 * r1_e1e2v(ji,jj)                        &
                     &                              * (  e1e2t(ji,jj  ) * zsshp2_e(ji,jj  )  &
@@ -526,10 +530,5 @@
          END_2D
          !
-#if defined key_single
-         CALL lbc_lnk      ( 'dynspg_ts', ssha_e, 'T', 1._wp )
-         CALL lbc_lnk_multi( 'dynspg_ts', zhU, 'U', -1._wp,  zhV, 'V', -1._wp )
-#else
-         CALL lbc_lnk_multi( 'dynspg_ts', ssha_e, 'T', 1._wp,  zhU, 'U', -1._wp,  zhV, 'V', -1._wp )
-#endif
+         CALL lbc_lnk( 'dynspg_ts', ssha_e, 'T', 1._wp,  zhU, 'U', -1._wp,  zhV, 'V', -1._wp )
          !
          ! Duplicate sea level across open boundaries (this is only cosmetic if linssh=T)
@@ -554,8 +553,8 @@
 #if defined key_qcoTest_FluxForm
             !                                ! 'key_qcoTest_FluxForm' : simple ssh average
+            DO_2D( 1, 0, 1, 1 )
+               zsshu_a(ji,jj) = r1_2 * (  ssha_e(ji,jj) + ssha_e(ji+1,jj  )  ) * ssumask(ji,jj)
+            END_2D
             DO_2D( 1, 1, 1, 0 )
-               zsshu_a(ji,jj) = r1_2 * (  ssha_e(ji,jj) + ssha_e(ji+1,jj  )  ) * ssumask(ji,jj)
-            END_2D
-            DO_2D( 1, 0, 1, 1 )
                zsshv_a(ji,jj) = r1_2 * (  ssha_e(ji,jj) + ssha_e(ji  ,jj+1)  ) * ssvmask(ji,jj)
             END_2D
@@ -684,9 +683,9 @@
          !
          IF( .NOT.ln_linssh ) THEN   !* Update ocean depth (variable volume case only)
-            CALL lbc_lnk_multi( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  &
-                 &                         , hu_e , 'U',  1._wp, hv_e , 'V',  1._wp  &
-                 &                         , hur_e, 'U',  1._wp, hvr_e, 'V',  1._wp  )
+            CALL lbc_lnk( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  &
+                 &                   , hu_e , 'U',  1._wp, hv_e , 'V',  1._wp  &
+                 &                   , hur_e, 'U',  1._wp, hvr_e, 'V',  1._wp  )
          ELSE
-            CALL lbc_lnk_multi( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  )
+            CALL lbc_lnk( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  )
          ENDIF
          !                                                 ! open boundaries
@@ -782,5 +781,5 @@
          END_2D
 #endif   
-         CALL lbc_lnk_multi( 'dynspg_ts', zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
+         CALL lbc_lnk( 'dynspg_ts', zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
          !
          DO jk=1,jpkm1
@@ -996,5 +995,5 @@
    SUBROUTINE dyn_spg_ts_init
       !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE dyn_spg_ts_init  ***
+      !!                   ***  ROUTINE dyn_spg_ts_init  ***dynspg_ts.F90.merge-right.r14642
       !!
       !! ** Purpose : Set time splitting options
@@ -1270,5 +1269,5 @@
       !!----------------------------------------------------------------------
       !
-      DO_2D( 1, 1, 1, 0 )   ! not jpi-column
+      DO_2D( 1, 0, 1, 1 )   ! not jpi-column
          IF ( phU(ji,jj) > 0._wp ) THEN   ;   pUmsk(ji,jj) = pTmsk(ji  ,jj) 
          ELSE                             ;   pUmsk(ji,jj) = pTmsk(ji+1,jj)  
@@ -1278,5 +1277,5 @@
       END_2D
       !
-      DO_2D( 1, 0, 1, 1 )   ! not jpj-row
+      DO_2D( 1, 1, 1, 0 )   ! not jpj-row
          IF ( phV(ji,jj) > 0._wp ) THEN   ;   pVmsk(ji,jj) = pTmsk(ji,jj  )
          ELSE                             ;   pVmsk(ji,jj) = pTmsk(ji,jj+1)  
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynvor.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynvor.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynvor.F90	(revision 14644)
@@ -941,5 +941,5 @@
                dj_e1v_2(ji,jj) = ( e1v(ji,jj) - e1v(ji  ,jj-1) ) * 0.5_wp
             END_2D
-            CALL lbc_lnk_multi( 'dynvor', di_e2u_2, 'T', -1.0_wp , dj_e1v_2, 'T', -1.0_wp )   ! Lateral boundary conditions
+            CALL lbc_lnk( 'dynvor', di_e2u_2, 'T', -1.0_wp , dj_e1v_2, 'T', -1.0_wp )   ! Lateral boundary conditions
             !
          CASE DEFAULT                        !* F-point metric term :   pre-compute di(e2u)/(2*e1e2f) and dj(e1v)/(2*e1e2f)
@@ -949,5 +949,5 @@
                dj_e1u_2e1e2f(ji,jj) = ( e1u(ji  ,jj+1) - e1u(ji,jj) )  * 0.5 * r1_e1e2f(ji,jj)
             END_2D
-            CALL lbc_lnk_multi( 'dynvor', di_e2v_2e1e2f, 'F', -1.0_wp , dj_e1u_2e1e2f, 'F', -1.0_wp )   ! Lateral boundary conditions
+            CALL lbc_lnk( 'dynvor', di_e2v_2e1e2f, 'F', -1.0_wp , dj_e1u_2e1e2f, 'F', -1.0_wp )   ! Lateral boundary conditions
          END SELECT
          !
@@ -977,4 +977,5 @@
                      &                   + e3t_0(ji  ,jj  ,jk)*tmask(ji  ,jj  ,jk)   &
                      &                   + e3t_0(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk)   ) / zmsk
+               ELSE ; e3f_0vor(ji,jj,jk) = 0._wp
                ENDIF
             END_3D
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/sshwzv.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/sshwzv.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/sshwzv.F90	(revision 14644)
@@ -54,5 +54,4 @@
 #  include "domzgr_substitute.h90"
 #  include "single_precision_substitute.h90"
-
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -263,5 +262,5 @@
 
 
-   SUBROUTINE ssh_atf( kt, Kbb, Kmm, Kaa, pssh, pssh_f )
+   SUBROUTINE ssh_atf( kt, Kbb, Kmm, Kaa, pssh )
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE ssh_atf  ***
@@ -280,9 +279,7 @@
       INTEGER                         , INTENT(in   ) ::   kt             ! ocean time-step index
       INTEGER                         , INTENT(in   ) ::   Kbb, Kmm, Kaa  ! ocean time level indices
-      REAL(dp), DIMENSION(jpi,jpj,jpt)          , TARGET, INTENT(inout) ::   pssh           ! SSH field
-      REAL(dp), DIMENSION(jpi,jpj    ), OPTIONAL, TARGET, INTENT(  out) ::   pssh_f         ! filtered SSH field
-      !
-      REAL(dp) ::   zcoef   ! local scalar
-      REAL(dp), POINTER, DIMENSION(:,:) ::   zssh   ! pointer for filtered SSH 
+      REAL(dp), DIMENSION(jpi,jpj,jpt), INTENT(inout) ::   pssh           ! SSH field
+      !
+      REAL(wp) ::   zcoef   ! local scalar
       !!----------------------------------------------------------------------
       !
@@ -294,22 +291,21 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~ '
       ENDIF
-      !              !==  Euler time-stepping: no filter, just swap  ==!
-      IF ( .NOT.( l_1st_euler ) ) THEN   ! Only do time filtering for leapfrog timesteps
-         IF( PRESENT( pssh_f ) ) THEN   ;   zssh => pssh_f
-         ELSE                           ;   zssh => pssh(:,:,Kmm)
-         ENDIF
-         !                                                  ! filtered "now" field
-         pssh(:,:,Kmm) = pssh(:,:,Kmm) + rn_atfp * ( pssh(:,:,Kbb) - 2 * pssh(:,:,Kmm) + pssh(:,:,Kaa) )
+      !
+      IF( .NOT.l_1st_euler ) THEN   ! Apply Asselin time filter on Kmm field (not on euler 1st)
          !
-         IF( .NOT.ln_linssh ) THEN                          ! "now" <-- with forcing removed
+         IF( ln_linssh ) THEN                ! filtered "now" field
+            pssh(:,:,Kmm) = pssh(:,:,Kmm) + rn_atfp * ( pssh(:,:,Kbb) - 2 * pssh(:,:,Kmm) + pssh(:,:,Kaa) )
+            !
+         ELSE                                ! filtered "now" field with forcing removed
             zcoef = rn_atfp * rn_Dt * r1_rho0
-            pssh(:,:,Kmm) = pssh(:,:,Kmm) - zcoef * (     emp_b(:,:) - emp   (:,:)   &
-               &                             - rnf_b(:,:)        + rnf   (:,:)       &
-               &                             + fwfisf_cav_b(:,:) - fwfisf_cav(:,:)   &
-               &                             + fwfisf_par_b(:,:) - fwfisf_par(:,:)   ) * ssmask(:,:)
+            pssh(:,:,Kmm) = pssh(:,:,Kmm) + rn_atfp * ( pssh(:,:,Kbb) - 2 * pssh(:,:,Kmm) + pssh(:,:,Kaa) )   &
+               &                          - zcoef   * (         emp_b(:,:) -        emp(:,:)   &
+               &                                              - rnf_b(:,:) +        rnf(:,:)   &
+               &                                       + fwfisf_cav_b(:,:) - fwfisf_cav(:,:)   &
+               &                                       + fwfisf_par_b(:,:) - fwfisf_par(:,:)   ) * ssmask(:,:)
 
             ! ice sheet coupling
             IF( ln_isf .AND. ln_isfcpl .AND. kt == nit000+1 )   &
-               &   pssh(:,:,Kbb) = pssh(:,:,Kbb) - rn_atfp * rn_Dt * ( risfcpl_ssh(:,:) - 0.0 ) * ssmask(:,:)
+               &   pssh(:,:,Kbb) = pssh(:,:,Kbb) - rn_atfp * rn_Dt * ( risfcpl_ssh(:,:) - 0._wp ) * ssmask(:,:)
 
          ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/wet_dry.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/wet_dry.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/wet_dry.F90	(revision 14644)
@@ -241,5 +241,5 @@
             ENDIF
          END_2D
-         CALL lbc_lnk_multi( 'wet_dry', zwdlmtu, 'U', 1.0_wp, zwdlmtv, 'V', 1.0_wp )
+         CALL lbc_lnk( 'wet_dry', zwdlmtu, 'U', 1.0_wp, zwdlmtv, 'V', 1.0_wp )
          !
          CALL mpp_max('wet_dry', jflag)   !max over the global domain
@@ -257,6 +257,6 @@
       !
 !!gm TO BE SUPPRESSED ?  these lbc_lnk are useless since zwdlmtu and zwdlmtv are defined everywhere !
-      CALL lbc_lnk_multi( 'wet_dry', puu(:,:,:,Kmm)  , 'U', -1.0_wp, pvv(:,:,:,Kmm)  , 'V', -1.0_wp )
-      CALL lbc_lnk_multi( 'wet_dry', uu_b(:,:,Kmm), 'U', -1.0_wp, vv_b(:,:,Kmm), 'V', -1.0_wp )
+      CALL lbc_lnk( 'wet_dry', puu(:,:,:,Kmm)  , 'U', -1.0_wp, pvv(:,:,:,Kmm)  , 'V', -1.0_wp )
+      CALL lbc_lnk( 'wet_dry', uu_b(:,:,Kmm), 'U', -1.0_wp, vv_b(:,:,Kmm), 'V', -1.0_wp )
 !!gm
       !
@@ -367,5 +367,5 @@
          END_2D
          !
-         CALL lbc_lnk_multi( 'wet_dry', zwdlmtu, 'U', 1.0_wp, zwdlmtv, 'V', 1.0_wp )
+         CALL lbc_lnk( 'wet_dry', zwdlmtu, 'U', 1.0_wp, zwdlmtv, 'V', 1.0_wp )
          !
          CALL mpp_max('wet_dry', jflag)   !max over the global domain
@@ -379,5 +379,5 @@
       !
 !!gm THIS lbc_lnk is useless since it is already done at the end of the jk1-loop
-      CALL lbc_lnk_multi( 'wet_dry', zflxu, 'U', -1.0_wp, zflxv, 'V', -1.0_wp )
+      CALL lbc_lnk( 'wet_dry', zflxu, 'U', -1.0_wp, zflxv, 'V', -1.0_wp )
 !!gm end
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/floblk.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/floblk.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/floblk.F90	(revision 14644)
@@ -105,5 +105,5 @@
       iloop = 0
 222   DO jfl = 1, jpnfl
-# if   defined key_mpp_mpi
+# if ! defined key_mpi_off
          IF( iil(jfl) >= mig(Nis0) .AND. iil(jfl) <= mig(Nie0) .AND.   &
              ijl(jfl) >= mjg(Njs0) .AND. ijl(jfl) <= mjg(Nje0)   ) THEN
@@ -329,5 +329,5 @@
             ! reinitialisation of the age of FLOAT
             zagefl(jfl) = zagenewfl(jfl)
-# if   defined key_mpp_mpi
+# if ! defined key_mpi_off
          ELSE
             ! we put zgifl, zgjfl, zgkfl, zagefl
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/flodom.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/flodom.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/flodom.F90	(revision 14644)
@@ -158,5 +158,5 @@
          ivtest(jfl) = 0
          ikmfl(jfl) = 0
-# if   defined key_mpp_mpi
+# if ! defined key_mpi_off
          DO ji = MAX(Nis0,2), Nie0
             DO jj = MAX(Njs0,2), Nje0   ! NO vector opt.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/flowri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/flowri.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/FLO/flowri.F90	(revision 14644)
@@ -199,5 +199,5 @@
       !----------------------
 
-#if defined key_iomput
+#if defined key_xios
          CALL iom_put( "traj_lon"     , zlon )
          CALL iom_put( "traj_lat"     , zlat )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbdia.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbdia.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbdia.F90	(revision 14644)
@@ -86,5 +86,5 @@
    INTEGER                       ::  nbergs_start, nbergs_end, nbergs_calved
    INTEGER                       ::  nbergs_melted
-   INTEGER                       ::  nspeeding_tickets
+   INTEGER                       ::  nspeeding_tickets, nspeeding_tickets_all
    INTEGER , DIMENSION(nclasses) ::  nbergs_calved_by_class
 
@@ -125,4 +125,5 @@
       nbergs_calved_by_class(:) = 0
       nspeeding_tickets         = 0
+      nspeeding_tickets_all     = 0
       stored_heat_end           = 0._wp
       floating_heat_end         = 0._wp
@@ -271,8 +272,8 @@
             CALL mpp_sum( 'icbdia', nsumbuf(1:nclasses+4), nclasses+4 )
             !
-            nbergs_end        = nsumbuf(1)
-            nbergs_calved     = nsumbuf(2)
-            nbergs_melted     = nsumbuf(3)
-            nspeeding_tickets = nsumbuf(4)
+            nbergs_end            = nsumbuf(1)
+            nbergs_calved         = nsumbuf(2)
+            nbergs_melted         = nsumbuf(3)
+            nspeeding_tickets_all = nsumbuf(4)
             DO ik = 1,nclasses
                nbergs_calved_by_class(ik)= nsumbuf(4+ik)
@@ -329,5 +330,8 @@
          IF (nn_verbose_level > 0) THEN
             WRITE( numicb, '("calved by class = ",i6,20(",",i6))') (nbergs_calved_by_class(ik),ik=1,nclasses)
-            IF( nspeeding_tickets > 0 )   WRITE( numicb, '("speeding tickets issued = ",i6)') nspeeding_tickets
+            IF( nspeeding_tickets_all > 0 ) THEN
+                WRITE( numicb, '("speeding tickets issued (this domain)  = ",i6)') nspeeding_tickets
+                WRITE( numicb, '("speeding tickets issued (all domains)  = ",i6)') nspeeding_tickets_all
+            END IF
          ENDIF
          !
@@ -338,4 +342,5 @@
          nbergs_calved_by_class(:) = 0
          nspeeding_tickets         = 0
+         nspeeding_tickets_all     = 0
          stored_heat_start         = stored_heat_end
          floating_heat_start       = floating_heat_end
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbdyn.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbdyn.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbdyn.F90	(revision 14644)
@@ -85,6 +85,6 @@
 
          !                                         !**   A1 = A(X1,V1)
-         CALL icb_accel( berg , zxi1, ze1, zuvel1, zuvel1, zax1,     &
-            &                   zyj1, ze2, zvvel1, zvvel1, zay1, zdt_2 )
+         CALL icb_accel( kt, berg , zxi1, ze1, zuvel1, zuvel1, zax1,     &
+            &                   zyj1, ze2, zvvel1, zvvel1, zay1, zdt_2, 0.5_wp )
          !
          zu1 = zuvel1 / ze1                           !**   V1 in d(i,j)/dt
@@ -102,6 +102,6 @@
 
          !                                         !**   A2 = A(X2,V2)
-         CALL icb_accel( berg , zxi2, ze1, zuvel2, zuvel1, zax2,    &
-            &                   zyj2, ze2, zvvel2, zvvel1, zay2, zdt_2 )
+         CALL icb_accel( kt, berg , zxi2, ze1, zuvel2, zuvel1, zax2,    &
+            &                   zyj2, ze2, zvvel2, zvvel1, zay2, zdt_2, 0.5_wp )
          !
          zu2 = zuvel2 / ze1                           !**   V2 in d(i,j)/dt
@@ -114,10 +114,10 @@
          zyj3  = zyj1  + zdt_2 * zv2   ;   zvvel3 = zvvel1 + zdt_2 * zay2
          !
-         CALL icb_ground( berg, zxi3, zxi1, zu3,   &
-            &                   zyj3, zyj1, zv3, ll_bounced )
+         CALL icb_ground( berg, zxi3, zxi1, zu2,   &
+            &                   zyj3, zyj1, zv2, ll_bounced )
 
          !                                         !**   A3 = A(X3,V3)
-         CALL icb_accel( berg , zxi3, ze1, zuvel3, zuvel1, zax3,    &
-            &                   zyj3, ze2, zvvel3, zvvel1, zay3, zdt )
+         CALL icb_accel( kt, berg , zxi3, ze1, zuvel3, zuvel1, zax3,    &
+            &                   zyj3, ze2, zvvel3, zvvel1, zay3, zdt, 1._wp )
          !
          zu3 = zuvel3 / ze1                           !**   V3 in d(i,j)/dt
@@ -130,10 +130,10 @@
          zyj4 = zyj1 + zdt * zv3   ;   zvvel4 = zvvel1 + zdt * zay3
 
-         CALL icb_ground( berg, zxi4, zxi1, zu4,   &
-            &                   zyj4, zyj1, zv4, ll_bounced )
+         CALL icb_ground( berg, zxi4, zxi1, zu3,   &
+            &                   zyj4, zyj1, zv3, ll_bounced )
 
          !                                         !**   A4 = A(X4,V4)
-         CALL icb_accel( berg , zxi4, ze1, zuvel4, zuvel1, zax4,    &
-            &                   zyj4, ze2, zvvel4, zvvel1, zay4, zdt )
+         CALL icb_accel( kt, berg , zxi4, ze1, zuvel4, zuvel1, zax4,    &
+            &                   zyj4, ze2, zvvel4, zvvel1, zay4, zdt, 1._wp )
 
          zu4 = zuvel4 / ze1                           !**   V4 in d(i,j)/dt
@@ -255,6 +255,6 @@
 
 
-   SUBROUTINE icb_accel( berg , pxi, pe1, puvel, puvel0, pax,                &
-      &                         pyj, pe2, pvvel, pvvel0, pay, pdt )
+   SUBROUTINE icb_accel( kt, berg , pxi, pe1, puvel, puvel0, pax,                 &
+      &                             pyj, pe2, pvvel, pvvel0, pay, pdt, pcfl_scale )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE icb_accel  ***
@@ -265,4 +265,6 @@
       !!----------------------------------------------------------------------
       TYPE(iceberg ), POINTER, INTENT(in   ) ::   berg             ! berg
+      INTEGER                , INTENT(in   ) ::   kt               ! time step
+      REAL(wp)               , INTENT(in   ) ::   pcfl_scale
       REAL(wp)               , INTENT(in   ) ::   pxi   , pyj      ! berg position in (i,j) referential
       REAL(wp)               , INTENT(in   ) ::   puvel , pvvel    ! berg velocity [m/s]
@@ -404,9 +406,20 @@
          zspeed = SQRT( zuveln*zuveln + zvveln*zvveln )    ! Speed of berg
          IF( zspeed > 0._wp ) THEN
-            zloc_dx = MIN( pe1, pe2 )                          ! minimum grid spacing
-            zspeed_new = zloc_dx / pdt * rn_speed_limit        ! Speed limit as a factor of dx / dt
+            zloc_dx = MIN( pe1, pe2 )                                ! minimum grid spacing
+            ! cfl scale is function of the RK4 step
+            zspeed_new = zloc_dx / pdt * rn_speed_limit * pcfl_scale ! Speed limit as a factor of dx / dt
             IF( zspeed_new < zspeed ) THEN
-               zuveln = zuveln * ( zspeed_new / zspeed )        ! Scale velocity to reduce speed
-               zvveln = zvveln * ( zspeed_new / zspeed )        ! without changing the direction
+               zuveln = zuveln * ( zspeed_new / zspeed )             ! Scale velocity to reduce speed
+               zvveln = zvveln * ( zspeed_new / zspeed )             ! without changing the direction
+               pax = (zuveln - puvel0)/pdt
+               pay = (zvveln - pvvel0)/pdt
+               !
+               ! print speeding ticket
+               IF (nn_verbose_level > 0) THEN
+                  WRITE(numicb, 9200) 'icb speeding : ',kt, nknberg, zspeed, &
+                       &                pxi, pyj, zuo, zvo, zua, zva, zui, zvi
+                  9200 FORMAT(a,i9,i6,f9.2,1x,4(1x,2f9.2))
+               END IF
+               !
                CALL icb_dia_speed()
             ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbini.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbini.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbini.F90	(revision 14644)
@@ -189,5 +189,5 @@
       
       ! north fold
-      IF( npolj > 0 ) THEN
+      IF( l_IdoNFold ) THEN
          !
          ! icebergs in row nicbej+1 get passed across fold
@@ -235,5 +235,5 @@
          WRITE(numicb,*) "j point"
          WRITE(numicb,*) (INT(src_calving(ji,jj)), jj=1,jpj)
-         IF( npolj > 0 ) THEN
+         IF( l_IdoNFold ) THEN
             WRITE(numicb,*) 'north fold destination points '
             WRITE(numicb,*) nicbfldpts
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icblbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icblbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icblbc.F90	(revision 14644)
@@ -36,5 +36,5 @@
    PRIVATE
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 
 !$AGRIF_DO_NOT_TREAT
@@ -105,5 +105,5 @@
       IF( l_Jperio)      CALL ctl_stop(' north-south periodicity not implemented for icebergs')
       ! north fold
-      IF( npolj /= 0 )   CALL icb_lbc_nfld()
+      IF( l_IdoNFold )   CALL icb_lbc_nfld()
       !
    END SUBROUTINE icb_lbc
@@ -145,7 +145,7 @@
    END SUBROUTINE icb_lbc_nfld
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    !!----------------------------------------------------------------------
-   !!   'key_mpp_mpi'             MPI massively parallel processing library
+   !!            MPI massively parallel processing library
    !!----------------------------------------------------------------------
 
@@ -179,11 +179,11 @@
       ipe_W = -1
       ipe_E = -1
-      IF( nbondi .EQ.  0 .OR. nbondi .EQ. 1) ipe_W = nowe
-      IF( nbondi .EQ. -1 .OR. nbondi .EQ. 0) ipe_E = noea
-      IF( nbondj .EQ.  0 .OR. nbondj .EQ. 1) ipe_S = noso
-      IF( nbondj .EQ. -1 .OR. nbondj .EQ. 0) ipe_N = nono
+      IF( mpinei(jpwe) >= 0 ) ipe_W = mpinei(jpwe)
+      IF( mpinei(jpea) >= 0 ) ipe_E = mpinei(jpea)
+      IF( mpinei(jpso) >= 0 ) ipe_S = mpinei(jpso)
+      IF( mpinei(jpno) >= 0 ) ipe_N = mpinei(jpno)
       !
       ! at northern line of processors with north fold handle bergs differently
-      IF( npolj > 0 ) ipe_N = -1
+      IF( l_IdoNFold )   ipe_N = -1
 
       ! if there's only one processor in x direction then don't let mpp try to handle periodicity
@@ -200,6 +200,4 @@
          WRITE(numicb,*) 'processor nimpp : ', nimpp
          WRITE(numicb,*) 'processor njmpp : ', njmpp
-         WRITE(numicb,*) 'processor nbondi: ', nbondi
-         WRITE(numicb,*) 'processor nbondj: ', nbondj
          CALL flush( numicb )
       ENDIF
@@ -271,91 +269,46 @@
       ! pattern here is copied from lib_mpp code
 
-      SELECT CASE ( nbondi )
-      CASE( -1 )
-         zwebergs(1) = ibergs_to_send_e
-         CALL mppsend( 12, zwebergs(1), 1, ipe_E, iml_req1)
-         CALL mpprecv( 11, zewbergs(2), 1, ipe_E )
-         CALL mpi_wait( iml_req1, iml_stat, iml_err )
-         ibergs_rcvd_from_e = INT( zewbergs(2) )
-      CASE(  0 )
-         zewbergs(1) = ibergs_to_send_w
-         zwebergs(1) = ibergs_to_send_e
-         CALL mppsend( 11, zewbergs(1), 1, ipe_W, iml_req2)
-         CALL mppsend( 12, zwebergs(1), 1, ipe_E, iml_req3)
-         CALL mpprecv( 11, zewbergs(2), 1, ipe_E )
-         CALL mpprecv( 12, zwebergs(2), 1, ipe_W )
-         CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         CALL mpi_wait( iml_req3, iml_stat, iml_err )
-         ibergs_rcvd_from_e = INT( zewbergs(2) )
-         ibergs_rcvd_from_w = INT( zwebergs(2) )
-      CASE(  1 )
-         zewbergs(1) = ibergs_to_send_w
-         CALL mppsend( 11, zewbergs(1), 1, ipe_W, iml_req4)
-         CALL mpprecv( 12, zwebergs(2), 1, ipe_W )
-         CALL mpi_wait( iml_req4, iml_stat, iml_err )
-         ibergs_rcvd_from_w = INT( zwebergs(2) )
-      END SELECT
+      IF( mpinei(jpwe) >= 0  )   zewbergs(1) = ibergs_to_send_w
+      IF( mpinei(jpea) >= 0  )   zwebergs(1) = ibergs_to_send_e
+      IF( mpinei(jpwe) >= 0  )   CALL mppsend( 11, zewbergs(1), 1, ipe_W, iml_req2)
+      IF( mpinei(jpea) >= 0  )   CALL mppsend( 12, zwebergs(1), 1, ipe_E, iml_req3)
+      IF( mpinei(jpea) >= 0  )   CALL mpprecv( 11, zewbergs(2), 1, ipe_E )
+      IF( mpinei(jpwe) >= 0  )   CALL mpprecv( 12, zwebergs(2), 1, ipe_W )
+      IF( mpinei(jpwe) >= 0  )   CALL mpi_wait( iml_req2, iml_stat, iml_err )
+      IF( mpinei(jpea) >= 0  )   CALL mpi_wait( iml_req3, iml_stat, iml_err )
+      IF( mpinei(jpea) >= 0  )   ibergs_rcvd_from_e = INT( zewbergs(2) )
+      IF( mpinei(jpwe) >= 0  )   ibergs_rcvd_from_w = INT( zwebergs(2) )
+      
       IF( nn_verbose_level >= 3) THEN
          WRITE(numicb,*) 'bergstep ',nktberg,' recv ew: ', ibergs_rcvd_from_w, ibergs_rcvd_from_e
          CALL flush(numicb)
       ENDIF
-
-      SELECT CASE ( nbondi )
-      CASE( -1 )
-         IF( ibergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, ibergs_to_send_e*jp_buffer_width, ipe_E, iml_req1 )
-         IF( ibergs_rcvd_from_e > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_e, ibergs_rcvd_from_e)
-            CALL mpprecv( 13, ibuffer_e%data, ibergs_rcvd_from_e*jp_buffer_width )
-         ENDIF
-         IF( ibergs_to_send_e > 0 ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
-         DO i = 1, ibergs_rcvd_from_e
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_e, i)
-         ENDDO
-      CASE(  0 )
-         IF( ibergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, ibergs_to_send_w*jp_buffer_width, ipe_W, iml_req2 )
-         IF( ibergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, ibergs_to_send_e*jp_buffer_width, ipe_E, iml_req3 )
-         IF( ibergs_rcvd_from_e > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_e, ibergs_rcvd_from_e)
-            CALL mpprecv( 13, ibuffer_e%data, ibergs_rcvd_from_e*jp_buffer_width )
-         ENDIF
-         IF( ibergs_rcvd_from_w > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_w, ibergs_rcvd_from_w)
-            CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*jp_buffer_width )
-         ENDIF
-         IF( ibergs_to_send_w > 0 ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         IF( ibergs_to_send_e > 0 ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
-         DO i = 1, ibergs_rcvd_from_e
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_e, i)
-         END DO
-         DO i = 1, ibergs_rcvd_from_w
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_w, i)
-         ENDDO
-      CASE(  1 )
-         IF( ibergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, ibergs_to_send_w*jp_buffer_width, ipe_W, iml_req4 )
-         IF( ibergs_rcvd_from_w > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_w, ibergs_rcvd_from_w)
-            CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*jp_buffer_width )
-         ENDIF
-         IF( ibergs_to_send_w > 0 ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
-         DO i = 1, ibergs_rcvd_from_w
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_w, i)
-         END DO
-      END SELECT
+      
+      IF( ibergs_to_send_w > 0 ) CALL mppsend( 13, obuffer_w%data, ibergs_to_send_w*jp_buffer_width, ipe_W, iml_req2 )
+      IF( ibergs_to_send_e > 0 ) CALL mppsend( 14, obuffer_e%data, ibergs_to_send_e*jp_buffer_width, ipe_E, iml_req3 )
+      IF( ibergs_rcvd_from_e > 0 ) THEN
+         CALL icb_increase_ibuffer(ibuffer_e, ibergs_rcvd_from_e)
+         CALL mpprecv( 13, ibuffer_e%data, ibergs_rcvd_from_e*jp_buffer_width )
+      ENDIF
+      IF( ibergs_rcvd_from_w > 0 ) THEN
+         CALL icb_increase_ibuffer(ibuffer_w, ibergs_rcvd_from_w)
+         CALL mpprecv( 14, ibuffer_w%data, ibergs_rcvd_from_w*jp_buffer_width )
+      ENDIF
+      IF( ibergs_to_send_w > 0 ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+      IF( ibergs_to_send_e > 0 ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+      DO i = 1, ibergs_rcvd_from_e
+         IF( nn_verbose_level >= 4 ) THEN
+            WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_e%data(16,i)),' from east'
+            CALL FLUSH( numicb )
+         ENDIF
+         CALL icb_unpack_from_buffer(first_berg, ibuffer_e, i)
+      END DO
+      DO i = 1, ibergs_rcvd_from_w
+         IF( nn_verbose_level >= 4 ) THEN
+            WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_w%data(16,i)),' from west'
+            CALL FLUSH( numicb )
+         ENDIF
+         CALL icb_unpack_from_buffer(first_berg, ibuffer_w, i)
+      END DO
 
       ! Find number of bergs that headed north/south
@@ -400,93 +353,48 @@
       ! send bergs north
       ! and receive bergs from south (ie ones sent north)
-
-      SELECT CASE ( nbondj )
-      CASE( -1 )
-         zsnbergs(1) = ibergs_to_send_n
-         CALL mppsend( 16, zsnbergs(1), 1, ipe_N, iml_req1)
-         CALL mpprecv( 15, znsbergs(2), 1, ipe_N )
-         CALL mpi_wait( iml_req1, iml_stat, iml_err )
-         ibergs_rcvd_from_n = INT( znsbergs(2) )
-      CASE(  0 )
-         znsbergs(1) = ibergs_to_send_s
-         zsnbergs(1) = ibergs_to_send_n
-         CALL mppsend( 15, znsbergs(1), 1, ipe_S, iml_req2)
-         CALL mppsend( 16, zsnbergs(1), 1, ipe_N, iml_req3)
-         CALL mpprecv( 15, znsbergs(2), 1, ipe_N )
-         CALL mpprecv( 16, zsnbergs(2), 1, ipe_S )
-         CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         CALL mpi_wait( iml_req3, iml_stat, iml_err )
-         ibergs_rcvd_from_n = INT( znsbergs(2) )
-         ibergs_rcvd_from_s = INT( zsnbergs(2) )
-      CASE(  1 )
-         znsbergs(1) = ibergs_to_send_s
-         CALL mppsend( 15, znsbergs(1), 1, ipe_S, iml_req4)
-         CALL mpprecv( 16, zsnbergs(2), 1, ipe_S )
-         CALL mpi_wait( iml_req4, iml_stat, iml_err )
-         ibergs_rcvd_from_s = INT( zsnbergs(2) )
-      END SELECT
-      if( nn_verbose_level >= 3) then
-         write(numicb,*) 'bergstep ',nktberg,' recv ns: ', ibergs_rcvd_from_s, ibergs_rcvd_from_n
-         call flush(numicb)
-      endif
-
-      SELECT CASE ( nbondj )
-      CASE( -1 )
-         IF( ibergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, ibergs_to_send_n*jp_buffer_width, ipe_N, iml_req1 )
-         IF( ibergs_rcvd_from_n > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_n, ibergs_rcvd_from_n)
-            CALL mpprecv( 17, ibuffer_n%data, ibergs_rcvd_from_n*jp_buffer_width )
-         ENDIF
-         IF( ibergs_to_send_n > 0 ) CALL mpi_wait( iml_req1, iml_stat, iml_err )
-         DO i = 1, ibergs_rcvd_from_n
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_n, i)
-         END DO
-      CASE(  0 )
-         IF( ibergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, ibergs_to_send_s*jp_buffer_width, ipe_S, iml_req2 )
-         IF( ibergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, ibergs_to_send_n*jp_buffer_width, ipe_N, iml_req3 )
-         IF( ibergs_rcvd_from_n > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_n, ibergs_rcvd_from_n)
-            CALL mpprecv( 17, ibuffer_n%data, ibergs_rcvd_from_n*jp_buffer_width )
-         ENDIF
-         IF( ibergs_rcvd_from_s > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_s, ibergs_rcvd_from_s)
-            CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*jp_buffer_width )
-         ENDIF
-         IF( ibergs_to_send_s > 0 ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
-         IF( ibergs_to_send_n > 0 ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
-         DO i = 1, ibergs_rcvd_from_n
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_n, i)
-         END DO
-         DO i = 1, ibergs_rcvd_from_s
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_s, i)
-         ENDDO
-      CASE(  1 )
-         IF( ibergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, ibergs_to_send_s*jp_buffer_width, ipe_S, iml_req4 )
-         IF( ibergs_rcvd_from_s > 0 ) THEN
-            CALL icb_increase_ibuffer(ibuffer_s, ibergs_rcvd_from_s)
-            CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*jp_buffer_width )
-         ENDIF
-         IF( ibergs_to_send_s > 0 ) CALL mpi_wait( iml_req4, iml_stat, iml_err )
-         DO i = 1, ibergs_rcvd_from_s
-            IF( nn_verbose_level >= 4 ) THEN
-               WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
-               CALL flush( numicb )
-            ENDIF
-            CALL icb_unpack_from_buffer(first_berg, ibuffer_s, i)
-         END DO
-      END SELECT
-
+      
+      IF( mpinei(jpso) >= 0  )   znsbergs(1) = ibergs_to_send_s
+      IF( mpinei(jpno) >= 0  )   zsnbergs(1) = ibergs_to_send_n
+      IF( mpinei(jpso) >= 0  )   CALL mppsend( 15, znsbergs(1), 1, ipe_S, iml_req2)
+      IF( mpinei(jpno) >= 0  )   CALL mppsend( 16, zsnbergs(1), 1, ipe_N, iml_req3)
+      IF( mpinei(jpno) >= 0  )   CALL mpprecv( 15, znsbergs(2), 1, ipe_N )
+      IF( mpinei(jpso) >= 0  )   CALL mpprecv( 16, zsnbergs(2), 1, ipe_S )
+      IF( mpinei(jpso) >= 0  )   CALL mpi_wait( iml_req2, iml_stat, iml_err )
+      IF( mpinei(jpno) >= 0  )   CALL mpi_wait( iml_req3, iml_stat, iml_err )
+      IF( mpinei(jpno) >= 0  )   ibergs_rcvd_from_n = INT( znsbergs(2) )
+      IF( mpinei(jpso) >= 0  )   ibergs_rcvd_from_s = INT( zsnbergs(2) )
+      
+      IF( nn_verbose_level >= 3) THEN
+         WRITE(numicb,*) 'bergstep ',nktberg,' recv ns: ', ibergs_rcvd_from_s, ibergs_rcvd_from_n
+         CALL FLUSH(numicb)
+      ENDIF
+
+      IF( ibergs_to_send_s > 0 ) CALL mppsend( 17, obuffer_s%data, ibergs_to_send_s*jp_buffer_width, ipe_S, iml_req2 )
+      IF( ibergs_to_send_n > 0 ) CALL mppsend( 18, obuffer_n%data, ibergs_to_send_n*jp_buffer_width, ipe_N, iml_req3 )
+      IF( ibergs_rcvd_from_n > 0 ) THEN
+         CALL icb_increase_ibuffer(ibuffer_n, ibergs_rcvd_from_n)
+         CALL mpprecv( 17, ibuffer_n%data, ibergs_rcvd_from_n*jp_buffer_width )
+      ENDIF
+      IF( ibergs_rcvd_from_s > 0 ) THEN
+         CALL icb_increase_ibuffer(ibuffer_s, ibergs_rcvd_from_s)
+         CALL mpprecv( 18, ibuffer_s%data, ibergs_rcvd_from_s*jp_buffer_width )
+      ENDIF
+      IF( ibergs_to_send_s > 0 ) CALL mpi_wait( iml_req2, iml_stat, iml_err )
+      IF( ibergs_to_send_n > 0 ) CALL mpi_wait( iml_req3, iml_stat, iml_err )
+      DO i = 1, ibergs_rcvd_from_n
+         IF( nn_verbose_level >= 4 ) THEN
+            WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_n%data(16,i)),' from north'
+            CALL FLUSH( numicb )
+         ENDIF
+         CALL icb_unpack_from_buffer(first_berg, ibuffer_n, i)
+      END DO
+      DO i = 1, ibergs_rcvd_from_s
+         IF( nn_verbose_level >= 4 ) THEN
+            WRITE(numicb,*) 'bergstep ',nktberg,' unpacking berg ',INT(ibuffer_s%data(16,i)),' from south'
+            CALL FLUSH( numicb )
+         ENDIF
+         CALL icb_unpack_from_buffer(first_berg, ibuffer_s, i)
+      END DO
+      
       IF( nn_verbose_level > 0 ) THEN
          ! compare the number of icebergs on this processor from the start to the end
@@ -527,5 +435,5 @@
       ! deal with north fold if we necessary when there is more than one top row processor
       ! note that for jpni=1 north fold has been dealt with above in call to icb_lbc
-      IF( npolj /= 0 .AND. jpni > 1 ) CALL icb_lbc_mpp_nfld( )
+      IF( l_IdoNFold .AND. jpni > 1 ) CALL icb_lbc_mpp_nfld( )
 
       IF( nn_verbose_level > 0 ) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbstp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbstp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbstp.F90	(revision 14644)
@@ -126,5 +126,5 @@
       !                                   !* Gridded diagnostics
       !                                   !  To get these iom_put's and those preceding to actually do something
-      !                                   !  use key_iomput in cpp file and create content for XML file
+      !                                   !  use key_xios in cpp file and create content for XML file
       !
       CALL iom_put( "calving"           , berg_grid%calving      (:,:)   )  ! 'calving mass input'
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbutl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbutl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbutl.F90	(revision 14644)
@@ -321,9 +321,12 @@
          !
          IF ( ierr > 0 ) THEN
-            WRITE(numout,*) 'bottom left corner T point out of bound'
-            WRITE(numout,*) pi, kii, mig( 1 ), mig(jpi)
-            WRITE(numout,*) pj, kij, mjg( 1 ), mjg(jpj)
-            WRITE(numout,*) pmsk
-            CALL ctl_stop('STOP','icb_utl_bilin_h: an icebergs coordinates is out of valid range (out of bound error)')
+            WRITE(numicb,*) 'bottom left corner T point out of bound'
+            WRITE(numicb,*) pi, kii, mig( 1 ), mig(jpi)
+            WRITE(numicb,*) pj, kij, mjg( 1 ), mjg(jpj)
+            WRITE(numicb,*) pmsk
+            CALL FLUSH(numicb)
+            CALL ctl_stop('STOP','icb_utl_bilin_e: an icebergs coordinates is out of valid range (out of bound error).'       , &
+                 &                                'This can be fixed using rn_speed_limit=0.4 in &namberg.'                   , &
+                 &                                'More details in the corresponding iceberg.stat file (nn_verbose_level > 0).' )
          END IF
       END IF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/in_out_manager.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/in_out_manager.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/in_out_manager.F90	(revision 14644)
@@ -175,4 +175,6 @@
    CHARACTER(LEN=lc) ::   cr_icerst_cxt     !: context name used in xios to read SI3 restart
    CHARACTER(LEN=lc) ::   cw_icerst_cxt     !: context name used in xios to write SI3 restart file
+   CHARACTER(LEN=lc) ::   cr_ablrst_cxt     !: context name used in xios to read ABL restart
+   CHARACTER(LEN=lc) ::   cw_ablrst_cxt     !: context name used in xios to write ABL restart file
    CHARACTER(LEN=lc) ::   cr_toprst_cxt     !: context name used in xios to read TOP restart
    CHARACTER(LEN=lc) ::   cw_toprst_cxt     !: context name used in xios to write TOP restart file
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/iom.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/iom.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/iom.F90	(revision 14644)
@@ -36,5 +36,5 @@
    USE phycst          ! physical constants
    USE dianam          ! build name of file
-#if defined key_iomput
+#if defined key_xios
    USE xios
 # endif
@@ -52,5 +52,5 @@
    PUBLIC   !   must be public to be able to access iom_def through iom
 
-#if defined key_iomput
+#if defined key_xios
    LOGICAL, PUBLIC, PARAMETER ::   lk_iomput = .TRUE.        !: iom_put flag
 #else
@@ -69,5 +69,5 @@
    PRIVATE iom_p1d_sp, iom_p2d_sp, iom_p3d_sp, iom_p4d_sp
    PRIVATE iom_p1d_dp, iom_p2d_dp, iom_p3d_dp, iom_p4d_dp
-#if defined key_iomput
+#if defined key_xios
    PRIVATE iom_set_domain_attr, iom_set_axis_attr, iom_set_field_attr, iom_set_file_attr, iom_get_file_attr, iom_set_grid_attr
    PRIVATE set_grid, set_grid_bounds, set_scalar, set_xmlatt, set_mooring, iom_sdate
@@ -116,5 +116,5 @@
       INTEGER         , OPTIONAL, INTENT(in)  :: kdid
       LOGICAL         , OPTIONAL, INTENT(in)  :: ld_closedef
-#if defined key_iomput
+#if defined key_xios
       !
       TYPE(xios_duration) :: dtime    = xios_duration(0, 0, 0, 0, 0, 0)
@@ -144,8 +144,10 @@
 
       llrstr = (cdname == cr_ocerst_cxt) .OR. (cdname == cr_icerst_cxt)
+      llrstr = llrstr .OR. (cdname == cr_ablrst_cxt)
       llrstr = llrstr .OR. (cdname == cr_toprst_cxt)
       llrstr = llrstr .OR. (cdname == cr_sedrst_cxt)
 
       llrstw = (cdname == cw_ocerst_cxt) .OR. (cdname == cw_icerst_cxt)
+      llrstw = llrstw .OR. (cdname == cw_ablrst_cxt)
       llrstw = llrstw .OR. (cdname == cw_toprst_cxt)
       llrstw = llrstw .OR. (cdname == cw_sedrst_cxt)
@@ -309,5 +311,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=*), OPTIONAL, INTENT(IN) :: cdname
-#if defined key_iomput
+#if defined key_xios
       LOGICAL :: llrstw
 
@@ -316,4 +318,5 @@
          llrstw = (cdname == cw_ocerst_cxt)
          llrstw = llrstw .OR. (cdname == cw_icerst_cxt)
+         llrstw = llrstw .OR. (cdname == cw_ablrst_cxt)
          llrstw = llrstw .OR. (cdname == cw_toprst_cxt)
          llrstw = llrstw .OR. (cdname == cw_sedrst_cxt)
@@ -344,5 +347,5 @@
       INTEGER, INTENT(IN) :: idnum
 
-#if defined key_iomput
+#if defined key_xios
       INTEGER                                    :: ndims, nvars, natts, unlimitedDimId, dimlen, xtype,mdims
       TYPE(xios_field)                           :: field_hdl
@@ -358,5 +361,5 @@
       LOGICAL                                    :: lmeta
 !metadata in restart file for restart read with XIOS
-      INTEGER, PARAMETER                         :: NMETA = 10
+      INTEGER, PARAMETER                         :: NMETA = 11
       CHARACTER(LEN=lc)                          :: meta(NMETA)
 
@@ -372,4 +375,5 @@
       meta(9) = "y"
       meta(10) = "numcat"
+      meta(11) = "nav_hgt"
 
       clinfo = '          iom_set_vars_active, file: '//TRIM(iom_file(idnum)%name)
@@ -450,5 +454,5 @@
       !!---------------------------------------------------------------------
       CHARACTER(len=*) :: cdrst_file
-#if defined key_iomput
+#if defined key_xios
       TYPE(xios_file) :: file_hdl
       TYPE(xios_filegroup) :: filegroup_hdl
@@ -489,5 +493,5 @@
       REAL(dp), OPTIONAL, INTENT(IN), DIMENSION(:, :, :) :: rd3
       REAL(sp), OPTIONAL, INTENT(IN), DIMENSION(:, :, :) :: rs3
-#if defined key_iomput
+#if defined key_xios
       TYPE(xios_field) :: field_hdl
       TYPE(xios_file) :: file_hdl
@@ -549,4 +553,6 @@
       IF(idlev == jpk) THEN
          axis_ref="nav_lev"
+      ELSEIF(idlev == jpka) THEN
+         axis_ref="nav_hgt"
 #if defined key_si3
       ELSEIF(idlev == jpl) THEN
@@ -594,5 +600,5 @@
       LOGICAL, INTENT(IN)               :: ld_rstr
       INTEGER :: ji
-#if defined key_iomput
+#if defined key_xios
       TYPE(xios_domaingroup)            :: domaingroup_hdl
       TYPE(xios_domain)                 :: domain_hdl
@@ -616,4 +622,6 @@
       CALL iom_set_axis_attr( "numcat", (/ (REAL(ji,wp), ji=1,jpl) /) )
 #endif
+      CALL xios_add_child(axisgroup_hdl, axis_hdl, "nav_hgt")
+      CALL iom_set_axis_attr( "nav_hgt", (/ (REAL(ji,wp), ji=1,jpka) /) )
       CALL xios_get_handle("scalar_definition", scalargroup_hdl)
       CALL xios_add_child(scalargroup_hdl, scalar_hdl, "grid_scalar")
@@ -639,4 +647,6 @@
          ELSEIF(kdid == numrir) THEN
             cdcont = cr_icerst_cxt
+         ELSEIF(kdid == numrar) THEN
+            cdcont = cr_ablrst_cxt
          ELSEIF(kdid == numrtr) THEN
             cdcont = cr_toprst_cxt
@@ -651,4 +661,6 @@
          ELSEIF(kdid == numriw) THEN
             cdcont = cw_icerst_cxt
+         ELSEIF(kdid == numraw) THEN
+            cdcont = cw_ablrst_cxt
          ELSEIF(kdid == numrtw) THEN
             cdcont = cw_toprst_cxt
@@ -667,5 +679,5 @@
       !!---------------------------------------------------------------------
       CHARACTER(len=*), INTENT(in) :: cdname
-#if defined key_iomput
+#if defined key_xios
       TYPE(xios_context) :: nemo_hdl
       IF( TRIM(Agrif_CFixed()) == '0' ) THEN
@@ -956,5 +968,5 @@
          ENDIF
       ELSE
-#if defined key_iomput
+#if defined key_xios
          IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar)
          CALL iom_swap(context)
@@ -1004,5 +1016,5 @@
          ENDIF
       ELSE
-#if defined key_iomput
+#if defined key_xios
          IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar)
          CALL iom_swap(context)
@@ -1368,5 +1380,5 @@
          !
       ELSE        ! read using XIOS. Only if KEY_IOMPUT is defined
-#if defined key_iomput
+#if defined key_xios
 !would be good to be able to check which context is active and swap only if current is not restart
          idvar = iom_varid( kiomid, cdvar )
@@ -1423,5 +1435,5 @@
       CHARACTER(LEN=*), INTENT(in ) ::   cdname
       REAL(wp), DIMENSION(jpi,jpj) ::   z2d
-#if defined key_iomput
+#if defined key_xios
       IF( xios_field_is_active( cdname, at_current_timestep_arg = .TRUE. ) ) THEN
          z2d(:,:) = 0._wp
@@ -1606,5 +1618,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
@@ -1646,5 +1658,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
@@ -1687,5 +1699,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
@@ -1727,5 +1739,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
@@ -1768,5 +1780,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
@@ -1808,5 +1820,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
@@ -1849,5 +1861,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
@@ -1889,5 +1901,5 @@
 
       IF( llx ) THEN
-#ifdef key_iomput
+#ifdef key_xios
          IF( kt == kwrite ) THEN
             IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
@@ -1967,5 +1979,5 @@
       REAL(sp)        , INTENT(in) ::   pfield0d
       !!      REAL(wp)        , DIMENSION(jpi,jpj) ::   zz     ! masson
-#if defined key_iomput
+#if defined key_xios
 !!clem      zz(:,:)=pfield0d
 !!clem      CALL xios_send_field(cdname, zz)
@@ -1980,5 +1992,5 @@
       REAL(dp)        , INTENT(in) ::   pfield0d
 !!      REAL(wp)        , DIMENSION(jpi,jpj) ::   zz     ! masson
-#if defined key_iomput
+#if defined key_xios
 !!clem      zz(:,:)=pfield0d
 !!clem      CALL xios_send_field(cdname, zz)
@@ -1993,5 +2005,5 @@
       CHARACTER(LEN=*)          , INTENT(in) ::   cdname
       REAL(sp),     DIMENSION(:), INTENT(in) ::   pfield1d
-#if defined key_iomput
+#if defined key_xios
       CALL xios_send_field( cdname, RESHAPE( (/pfield1d/), (/1,1,SIZE(pfield1d)/) ) )
 #else
@@ -2003,5 +2015,5 @@
       CHARACTER(LEN=*)          , INTENT(in) ::   cdname
       REAL(dp),     DIMENSION(:), INTENT(in) ::   pfield1d
-#if defined key_iomput
+#if defined key_xios
       CALL xios_send_field( cdname, RESHAPE( (/pfield1d/), (/1,1,SIZE(pfield1d)/) ) )
 #else
@@ -2014,5 +2026,5 @@
       REAL(sp),     DIMENSION(:,:), INTENT(in) ::   pfield2d
       IF( iom_use(cdname) ) THEN
-#if defined key_iomput
+#if defined key_xios
          CALL xios_send_field( cdname, pfield2d )
 #else
@@ -2026,5 +2038,5 @@
       REAL(dp),     DIMENSION(:,:), INTENT(in) ::   pfield2d
       IF( iom_use(cdname) ) THEN
-#if defined key_iomput
+#if defined key_xios
          CALL xios_send_field( cdname, pfield2d )
 #else
@@ -2038,5 +2050,5 @@
       REAL(sp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d
       IF( iom_use(cdname) ) THEN
-#if defined key_iomput
+#if defined key_xios
          CALL xios_send_field( cdname, pfield3d )
 #else
@@ -2050,5 +2062,5 @@
       REAL(dp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d
       IF( iom_use(cdname) ) THEN
-#if defined key_iomput
+#if defined key_xios
          CALL xios_send_field( cdname, pfield3d )
 #else
@@ -2062,5 +2074,5 @@
       REAL(sp),       DIMENSION(:,:,:,:), INTENT(in) ::   pfield4d
       IF( iom_use(cdname) ) THEN
-#if defined key_iomput
+#if defined key_xios
          CALL xios_send_field (cdname, pfield4d )
 #else
@@ -2074,5 +2086,5 @@
       REAL(dp),       DIMENSION(:,:,:,:), INTENT(in) ::   pfield4d
       IF( iom_use(cdname) ) THEN
-#if defined key_iomput
+#if defined key_xios
          CALL xios_send_field (cdname, pfield4d )
 #else
@@ -2082,7 +2094,7 @@
    END SUBROUTINE iom_p4d_dp
 
-#if defined key_iomput
+#if defined key_xios
    !!----------------------------------------------------------------------
-   !!   'key_iomput'                                         XIOS interface
+   !!   'key_xios'                                         XIOS interface
    !!----------------------------------------------------------------------
 
@@ -2714,5 +2726,5 @@
 #else
    !!----------------------------------------------------------------------
-   !!   NOT 'key_iomput'                               a few dummy routines
+   !!   NOT 'key_xios'                               a few dummy routines
    !!----------------------------------------------------------------------
    SUBROUTINE iom_setkt( kt, cdname )
@@ -2736,5 +2748,5 @@
    LOGICAL FUNCTION iom_use( cdname )
       CHARACTER(LEN=*), INTENT(in) ::   cdname
-#if defined key_iomput
+#if defined key_xios
       iom_use = xios_field_is_active( cdname )
 #else
@@ -2747,5 +2759,5 @@
       REAL(wp)        , INTENT(out) ::   pmiss_val
       REAL(dp)                      ::   ztmp_pmiss_val
-#if defined key_iomput
+#if defined key_xios
       ! get missing value
       CALL xios_get_field_attr( cdname, default_value = ztmp_pmiss_val )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/iom_nf90.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/iom_nf90.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/iom_nf90.F90	(revision 14644)
@@ -443,10 +443,9 @@
          IF(PRESENT(cdatt0d))   CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values = cdatt0d), clinfo)
       ELSE
-         CALL ctl_warn('iom_nf90_getatt: no attribute '//TRIM(cdatt)//' found')
          IF(PRESENT( katt0d))    katt0d    = -999
          IF(PRESENT( katt1d))    katt1d(:) = -999
          IF(PRESENT( patt0d))    patt0d    = -999._wp
          IF(PRESENT( patt1d))    patt1d(:) = -999._wp
-         IF(PRESENT(cdatt0d))   cdatt0d    = '!'
+         IF(PRESENT(cdatt0d))   cdatt0d    = 'UNKNOWN'
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/restart.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/restart.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/restart.F90	(revision 14644)
@@ -120,5 +120,5 @@
                CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. )
             ELSE
-#if defined key_iomput
+#if defined key_xios
                cw_ocerst_cxt = "rstw_"//TRIM(ADJUSTL(clkt))
                IF( TRIM(Agrif_CFixed()) == '0' ) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcav.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcav.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcav.F90	(revision 14644)
@@ -136,5 +136,5 @@
       !
       ! lbclnk on melt
-      CALL lbc_lnk_multi( 'isfmlt', zqh, 'T', 1.0_wp, pqfwf, 'T', 1.0_wp)
+      CALL lbc_lnk( 'isfmlt', zqh, 'T', 1.0_wp, pqfwf, 'T', 1.0_wp)
       !
       ! output fluxes
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcpl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcpl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcpl.F90	(revision 14644)
@@ -207,5 +207,5 @@
          zssmask0(:,:) = zssmask_b(:,:)
          !
-         CALL lbc_lnk_multi( 'iscplrst', zssh, 'T', 1.0_wp, zssmask0, 'T', 1.0_wp )
+         CALL lbc_lnk( 'iscplrst', zssh, 'T', 1.0_wp, zssmask0, 'T', 1.0_wp )
          !
       END DO
@@ -365,5 +365,5 @@
          ztmask0(:,:,:) = ztmask1(:,:,:)
          !
-         CALL lbc_lnk_multi( 'iscplrst', zts0(:,:,:,jp_tem), 'T', 1.0_wp, zts0(:,:,:,jp_sal), 'T', 1.0_wp, ztmask0, 'T', 1.0_wp)
+         CALL lbc_lnk( 'iscplrst', zts0(:,:,:,jp_tem), 'T', 1.0_wp, zts0(:,:,:,jp_sal), 'T', 1.0_wp, ztmask0, 'T', 1.0_wp)
          !
       END DO  ! nn_drown
@@ -693,6 +693,6 @@
       !
       ! add lbclnk
-      CALL lbc_lnk_multi( 'iscplrst', risfcpl_cons_tsc(:,:,:,jp_tem), 'T', 1.0_wp, risfcpl_cons_tsc(:,:,:,jp_sal), 'T', 1.0_wp, &
-         &                            risfcpl_cons_vol(:,:,:)       , 'T', 1.0_wp)
+      CALL lbc_lnk( 'iscplrst', risfcpl_cons_tsc(:,:,:,jp_tem), 'T', 1.0_wp, risfcpl_cons_tsc(:,:,:,jp_sal), 'T', 1.0_wp, &
+         &                      risfcpl_cons_vol(:,:,:)       , 'T', 1.0_wp)
       !
       ! ssh correction (for dynspg_ts)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfpar.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfpar.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfpar.F90	(revision 14644)
@@ -82,5 +82,5 @@
       !
       ! lbclnk on melt and heat fluxes
-      CALL lbc_lnk_multi( 'isfmlt', zqh, 'T', 1.0_wp, pqfwf, 'T', 1.0_wp)
+      CALL lbc_lnk( 'isfmlt', zqh, 'T', 1.0_wp, pqfwf, 'T', 1.0_wp)
       !
       ! output fluxes
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isftbl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isftbl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isftbl.F90	(revision 14644)
@@ -78,5 +78,5 @@
          ! compute tbl property at T point
          pvarout(1,:) = 0._wp
-         DO_2D( 1, 1, 0, 1 )
+         DO_2D( 0, 1, 1, 1 )
             pvarout(ji,jj) = 0.5_wp * (zvarout(ji,jj) + zvarout(ji-1,jj))
          END_2D
@@ -99,5 +99,5 @@
          ! pvarout is an averaging of wet point
          pvarout(:,1) = 0._wp
-         DO_2D( 0, 1, 1, 1 )
+         DO_2D( 1, 1, 0, 1 )
             pvarout(ji,jj) = 0.5_wp * (zvarout(ji,jj) + zvarout(ji,jj-1))
          END_2D
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_call_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_call_generic.h90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_call_generic.h90	(revision 14644)
@@ -0,0 +1,102 @@
+#if defined DIM_2d
+#   define XD     2d
+#   define DIMS   :,:
+#   define ISZ3   1 
+#   define ISZ4   1   
+#endif
+#if defined DIM_3d
+#   define XD     3d
+#   define DIMS   :,:,:
+#   define ISZ3   SIZE(ptab, dim=3)
+#   define ISZ4   1
+#endif
+#if defined DIM_4d
+#   define XD     4d
+#   define DIMS   :,:,:,:
+#   define ISZ3   SIZE(ptab, dim=3)
+#   define ISZ4   SIZE(ptab, dim=4)
+#endif
+
+   SUBROUTINE lbc_lnk_call_/**/XD/**/_/**/PRECISION(                                                              &
+      &                     cdname                                                                                  &
+      &                   , pt1 , cdna1 , psgn1 , pt2 , cdna2 , psgn2 , pt3 , cdna3 , psgn3 , pt4 , cdna4 , psgn4   &
+      &                   , pt5 , cdna5 , psgn5 , pt6 , cdna6 , psgn6 , pt7 , cdna7 , psgn7 , pt8 , cdna8 , psgn8   &
+      &                   , pt9 , cdna9 , psgn9 , pt10, cdna10, psgn10, pt11, cdna11, psgn11, pt12, cdna12, psgn12  &
+      &                   , pt13, cdna13, psgn13, pt14, cdna14, psgn14, pt15, cdna15, psgn15, pt16, cdna16, psgn16  &
+      &                   , kfillmode, pfillval, khls, lsend, lrecv, ld4only )
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*)     ,                   INTENT(in   ) ::   cdname  ! name of the calling subroutine
+      REAL(PRECISION), DIMENSION(DIMS)          , TARGET, CONTIGUOUS, INTENT(inout) ::   pt1        ! arrays on which the lbc is applied
+      REAL(PRECISION), DIMENSION(DIMS), OPTIONAL, TARGET, CONTIGUOUS, INTENT(inout) ::   pt2 , pt3 , pt4 , pt5 , pt6 , pt7 , pt8 , pt9, &
+         &                                                                    pt10, pt11, pt12, pt13, pt14, pt15, pt16
+      CHARACTER(len=1)                       , INTENT(in   ) ::   cdna1   ! nature of pt2D. array grid-points
+      CHARACTER(len=1)     , OPTIONAL        , INTENT(in   ) ::   cdna2 , cdna3 , cdna4 , cdna5 , cdna6 , cdna7 , cdna8 , cdna9, &
+         &                                                        cdna10, cdna11, cdna12, cdna13, cdna14, cdna15, cdna16
+      REAL(PRECISION)                        , INTENT(in   ) ::   psgn1   ! sign used across the north fold
+      REAL(PRECISION)      , OPTIONAL        , INTENT(in   ) ::   psgn2 , psgn3 , psgn4 , psgn5 , psgn6 , psgn7 , psgn8 , psgn9, &
+         &                                                        psgn10, psgn11, psgn12, psgn13, psgn14, psgn15, psgn16
+      INTEGER              , OPTIONAL        , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
+      REAL(PRECISION)      , OPTIONAL        , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER              , OPTIONAL        , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      LOGICAL, DIMENSION(4), OPTIONAL        , INTENT(in   ) ::   lsend, lrecv   ! indicate how communications are to be carried out
+      LOGICAL              , OPTIONAL        , INTENT(in   ) ::   ld4only     ! if .T., do only 4-neighbour comm (ignore corners)
+      !!
+      INTEGER                          ::   kfld        ! number of elements that will be attributed
+      TYPE(PTR_4d_/**/PRECISION), DIMENSION(16) ::   ptab_ptr    ! pointer array
+      CHARACTER(len=1) , DIMENSION(16) ::   cdna_ptr    ! nature of ptab_ptr grid-points
+      REAL(PRECISION)  , DIMENSION(16) ::   psgn_ptr    ! sign used across the north fold boundary
+      !!---------------------------------------------------------------------
+      !
+      kfld = 0          ! initial array of pointer size
+      !
+      !                 ! Load the first array
+      CALL load_ptr_/**/XD/**/_/**/PRECISION( pt1, cdna1, psgn1, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      !
+      !                 ! Look if more arrays are added
+      IF( PRESENT(psgn2 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt2 , cdna2 , psgn2 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn3 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt3 , cdna3 , psgn3 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn4 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt4 , cdna4 , psgn4 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn5 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt5 , cdna5 , psgn5 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn6 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt6 , cdna6 , psgn6 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn7 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt7 , cdna7 , psgn7 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn8 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt8 , cdna8 , psgn8 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn9 ) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt9 , cdna9 , psgn9 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn10) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt10, cdna10, psgn10, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn11) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt11, cdna11, psgn11, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn12) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt12, cdna12, psgn12, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn13) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt13, cdna13, psgn13, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn14) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt14, cdna14, psgn14, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn15) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt15, cdna15, psgn15, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      IF( PRESENT(psgn16) )   CALL load_ptr_/**/XD/**/_/**/PRECISION( pt16, cdna16, psgn16, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      !     
+      IF( nn_comm == 1 ) THEN 
+         CALL lbc_lnk_pt2pt(   cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, khls, lsend, lrecv, ld4only )
+      ELSE
+         CALL lbc_lnk_neicoll( cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, khls, lsend, lrecv, ld4only )
+      ENDIF
+      !
+   END SUBROUTINE lbc_lnk_call_/**/XD/**/_/**/PRECISION
+
+
+   SUBROUTINE load_ptr_/**/XD/**/_/**/PRECISION( ptab, cdna, psgn, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
+      !!---------------------------------------------------------------------
+      REAL(PRECISION), DIMENSION(DIMS), TARGET, INTENT(inout), CONTIGUOUS ::   ptab       ! arrays on which the lbc is applied
+      CHARACTER(len=1)              , INTENT(in   ) ::   cdna       ! nature of pt2d array grid-points
+      REAL(PRECISION)               , INTENT(in   ) ::   psgn       ! sign used across the north fold boundary
+      TYPE(PTR_4d_/**/PRECISION), DIMENSION(:), INTENT(inout) ::   ptab_ptr   ! array of pointers
+      CHARACTER(len=1), DIMENSION(:), INTENT(inout) ::   cdna_ptr   ! nature of pt2d_array array grid-points
+      REAL(PRECISION) , DIMENSION(:), INTENT(inout) ::   psgn_ptr   ! sign used across the north fold boundary
+      INTEGER                       , INTENT(inout) ::   kfld       ! number of elements that has been attributed
+      !!---------------------------------------------------------------------
+      !
+      kfld                    =  kfld + 1
+      ptab_ptr(kfld)%pt4d(1:SIZE(ptab, dim=1),1:SIZE(ptab, dim=2),1:ISZ3,1:ISZ4) => ptab
+      cdna_ptr(kfld)          =  cdna
+      psgn_ptr(kfld)          =  psgn
+      !
+   END SUBROUTINE load_ptr_/**/XD/**/_/**/PRECISION
+
+#undef XD
+#undef DIMS
+#undef ISZ3
+#undef ISZ4
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_multi_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_multi_generic.h90	(revision 14643)
+++ 	(revision )
@@ -1,113 +1,0 @@
-#if defined SINGLE_PRECISION
-#   if defined DIM_2d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j)
-#      define PTR_TYPE              TYPE(PTR_2D_sp)
-#      define PTR_ptab              pt2d
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j,k)
-#      define PTR_TYPE              TYPE(PTR_3D_sp)
-#      define PTR_ptab              pt3d
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j,k,l)
-#      define PTR_TYPE              TYPE(PTR_4D_sp)
-#      define PTR_ptab              pt4d
-#   endif
-#   define PRECISION sp
-#else
-#   if defined DIM_2d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j)
-#      define PTR_TYPE              TYPE(PTR_2D_dp)
-#      define PTR_ptab              pt2d
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j,k)
-#      define PTR_TYPE              TYPE(PTR_3D_dp)
-#      define PTR_ptab              pt3d
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j,k,l)
-#      define PTR_TYPE              TYPE(PTR_4D_dp)
-#      define PTR_ptab              pt4d
-#   endif
-#   define PRECISION dp
-#endif
-
-   SUBROUTINE ROUTINE_MULTI( cdname                                                                               &
-      &                    , pt1 , cdna1 , psgn1 , pt2 , cdna2 , psgn2 , pt3 , cdna3 , psgn3 , pt4 , cdna4 , psgn4   &
-      &                    , pt5 , cdna5 , psgn5 , pt6 , cdna6 , psgn6 , pt7 , cdna7 , psgn7 , pt8 , cdna8 , psgn8   &
-      &                    , pt9 , cdna9 , psgn9 , pt10, cdna10, psgn10, pt11, cdna11, psgn11, pt12, cdna12, psgn12  &
-      &                    , pt13, cdna13, psgn13, pt14, cdna14, psgn14, pt15, cdna15, psgn15, pt16, cdna16, psgn16  &
-      &                    , kfillmode, pfillval, lsend, lrecv, ncsten )
-      !!---------------------------------------------------------------------
-      CHARACTER(len=*)     ,                   INTENT(in   ) ::   cdname  ! name of the calling subroutine
-      ARRAY_TYPE(:,:,:,:)            , TARGET, INTENT(inout) ::   pt1     ! arrays on which the lbc is applied
-      ARRAY_TYPE(:,:,:,:)  , OPTIONAL, TARGET, INTENT(inout) ::   pt2   , pt3   , pt4   , pt5   , pt6   , pt7   , pt8   , pt9  , &
-         &                                                        pt10  , pt11  , pt12  , pt13  , pt14  , pt15  , pt16
-      CHARACTER(len=1)                       , INTENT(in   ) ::   cdna1   ! nature of pt2D. array grid-points
-      CHARACTER(len=1)     , OPTIONAL        , INTENT(in   ) ::   cdna2 , cdna3 , cdna4 , cdna5 , cdna6 , cdna7 , cdna8 , cdna9, &
-         &                                                        cdna10, cdna11, cdna12, cdna13, cdna14, cdna15, cdna16
-      REAL(wp)                               , INTENT(in   ) ::   psgn1   ! sign used across the north fold
-      REAL(wp)             , OPTIONAL        , INTENT(in   ) ::   psgn2 , psgn3 , psgn4 , psgn5 , psgn6 , psgn7 , psgn8 , psgn9, &
-         &                                                        psgn10, psgn11, psgn12, psgn13, psgn14, psgn15, psgn16
-      INTEGER              , OPTIONAL        , INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
-      REAL(wp)             , OPTIONAL        , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
-      LOGICAL, DIMENSION(4), OPTIONAL        , INTENT(in   ) ::   lsend, lrecv   ! indicate how communications are to be carried out
-      LOGICAL              , OPTIONAL        , INTENT(in   ) ::   ncsten
-      !!
-      INTEGER                          ::   kfld        ! number of elements that will be attributed
-      PTR_TYPE         , DIMENSION(16) ::   ptab_ptr    ! pointer array
-      CHARACTER(len=1) , DIMENSION(16) ::   cdna_ptr    ! nature of ptab_ptr grid-points
-      REAL(wp)         , DIMENSION(16) ::   psgn_ptr    ! sign used across the north fold boundary
-      !!---------------------------------------------------------------------
-      !
-      kfld = 0          ! initial array of pointer size
-      !
-      !                 ! Load the first array
-      CALL ROUTINE_LOAD( pt1, cdna1, psgn1, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      !
-      !                 ! Look if more arrays are added
-      IF( PRESENT(psgn2 ) )   CALL ROUTINE_LOAD( pt2 , cdna2 , psgn2 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn3 ) )   CALL ROUTINE_LOAD( pt3 , cdna3 , psgn3 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn4 ) )   CALL ROUTINE_LOAD( pt4 , cdna4 , psgn4 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn5 ) )   CALL ROUTINE_LOAD( pt5 , cdna5 , psgn5 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn6 ) )   CALL ROUTINE_LOAD( pt6 , cdna6 , psgn6 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn7 ) )   CALL ROUTINE_LOAD( pt7 , cdna7 , psgn7 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn8 ) )   CALL ROUTINE_LOAD( pt8 , cdna8 , psgn8 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn9 ) )   CALL ROUTINE_LOAD( pt9 , cdna9 , psgn9 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn10) )   CALL ROUTINE_LOAD( pt10, cdna10, psgn10, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn11) )   CALL ROUTINE_LOAD( pt11, cdna11, psgn11, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn12) )   CALL ROUTINE_LOAD( pt12, cdna12, psgn12, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn13) )   CALL ROUTINE_LOAD( pt13, cdna13, psgn13, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn14) )   CALL ROUTINE_LOAD( pt14, cdna14, psgn14, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn15) )   CALL ROUTINE_LOAD( pt15, cdna15, psgn15, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn16) )   CALL ROUTINE_LOAD( pt16, cdna16, psgn16, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      !
-      CALL lbc_lnk_ptr( cdname, ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
-      !
-   END SUBROUTINE ROUTINE_MULTI
-
-
-   SUBROUTINE ROUTINE_LOAD( ptab, cdna, psgn, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      !!---------------------------------------------------------------------
-      ARRAY_TYPE(:,:,:,:)   , TARGET, INTENT(inout) ::   ptab       ! arrays on which the lbc is applied
-      CHARACTER(len=1)              , INTENT(in   ) ::   cdna       ! nature of pt2d array grid-points
-      REAL(wp)                      , INTENT(in   ) ::   psgn       ! sign used across the north fold boundary
-      PTR_TYPE        , DIMENSION(:), INTENT(inout) ::   ptab_ptr   ! array of pointers
-      CHARACTER(len=1), DIMENSION(:), INTENT(inout) ::   cdna_ptr   ! nature of pt2d_array array grid-points
-      REAL(wp)        , DIMENSION(:), INTENT(inout) ::   psgn_ptr   ! sign used across the north fold boundary
-      INTEGER                       , INTENT(inout) ::   kfld       ! number of elements that has been attributed
-      !!---------------------------------------------------------------------
-      !
-      kfld                    =  kfld + 1
-      ptab_ptr(kfld)%PTR_ptab => ptab
-      cdna_ptr(kfld)          =  cdna
-      psgn_ptr(kfld)          =  psgn
-      !
-   END SUBROUTINE ROUTINE_LOAD
-
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef PTR_TYPE
-#undef PTR_ptab
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_nc_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_nc_generic.h90	(revision 14643)
+++ 	(revision )
@@ -1,113 +1,0 @@
-#if defined SINGLE_PRECISION
-#   if defined DIM_2d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j)
-#      define PTR_TYPE              TYPE(PTR_2D_sp)
-#      define PTR_ptab              pt2d
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j,k)
-#      define PTR_TYPE              TYPE(PTR_3D_sp)
-#      define PTR_ptab              pt3d
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j,k,l)
-#      define PTR_TYPE              TYPE(PTR_4D_sp)
-#      define PTR_ptab              pt4d
-#   endif
-#   define PRECISION sp
-#else
-#   if defined DIM_2d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j)
-#      define PTR_TYPE              TYPE(PTR_2D_dp)
-#      define PTR_ptab              pt2d
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j,k)
-#      define PTR_TYPE              TYPE(PTR_3D_dp)
-#      define PTR_ptab              pt3d
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j,k,l)
-#      define PTR_TYPE              TYPE(PTR_4D_dp)
-#      define PTR_ptab              pt4d
-#   endif
-#   define PRECISION dp
-#endif
-
-   SUBROUTINE ROUTINE_MULTI_NC( cdname                                                                             &
-      &                    , pt1 , cdna1 , psgn1 , pt2 , cdna2 , psgn2 , pt3 , cdna3 , psgn3 , pt4 , cdna4 , psgn4   &
-      &                    , pt5 , cdna5 , psgn5 , pt6 , cdna6 , psgn6 , pt7 , cdna7 , psgn7 , pt8 , cdna8 , psgn8   &
-      &                    , pt9 , cdna9 , psgn9 , pt10, cdna10, psgn10, pt11, cdna11, psgn11, pt12, cdna12, psgn12  &
-      &                    , pt13, cdna13, psgn13, pt14, cdna14, psgn14, pt15, cdna15, psgn15, pt16, cdna16, psgn16  &
-      &                    , kfillmode, pfillval, lsend, lrecv, ncsten )
-      !!---------------------------------------------------------------------
-      CHARACTER(len=*)   ,                   INTENT(in   ) :: cdname  ! name of the calling subroutine
-      ARRAY_TYPE(:,:,:,:)          , TARGET, INTENT(inout) :: pt1     ! arrays on which the lbc is applied
-      ARRAY_TYPE(:,:,:,:), OPTIONAL, TARGET, INTENT(inout) :: pt2  , pt3  , pt4  , pt5  , pt6  , pt7  , pt8  , pt9  , &
-         &                                                    pt10  , pt11  , pt12  , pt13  , pt14  , pt15  , pt16
-      CHARACTER(len=1)                     , INTENT(in   ) :: cdna1   ! nature of pt2D. array grid-points
-      CHARACTER(len=1)   , OPTIONAL        , INTENT(in   ) :: cdna2, cdna3, cdna4, cdna5, cdna6, cdna7, cdna8, cdna9, &
-         &                                                    cdna10, cdna11, cdna12, cdna13, cdna14, cdna15, cdna16
-      REAL(wp)                             , INTENT(in   ) :: psgn1   ! sign used across the north fold
-      REAL(wp)           , OPTIONAL        , INTENT(in   ) :: psgn2, psgn3, psgn4, psgn5, psgn6, psgn7, psgn8, psgn9, &
-         &                                                    psgn10, psgn11, psgn12, psgn13, psgn14, psgn15, psgn16
-      INTEGER            , OPTIONAL        , INTENT(in   ) :: kfillmode   ! filling method for halo over land (default = constant)
-      REAL(wp)           , OPTIONAL        , INTENT(in   ) :: pfillval    ! background value (used at closed boundaries)
-      LOGICAL, DIMENSION(4), OPTIONAL      , INTENT(in   ) :: lsend, lrecv   ! indicate how communications are to be carried out
-      LOGICAL            , OPTIONAL      , INTENT(in   ) :: ncsten
-      !!
-      INTEGER                          ::   kfld        ! number of elements that will be attributed
-      PTR_TYPE         , DIMENSION(16) ::   ptab_ptr    ! pointer array
-      CHARACTER(len=1) , DIMENSION(16) ::   cdna_ptr    ! nature of ptab_ptr grid-points
-      REAL(wp)         , DIMENSION(16) ::   psgn_ptr    ! sign used across the north fold boundary
-      !!---------------------------------------------------------------------
-      !
-      kfld = 0          ! initial array of pointer size
-      !
-      !                 ! Load the first array
-      CALL ROUTINE_NC_LOAD( pt1, cdna1, psgn1, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      !
-      !                 ! Look if more arrays are added
-      IF( PRESENT(psgn2 ) )   CALL ROUTINE_NC_LOAD( pt2 , cdna2 , psgn2 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn3 ) )   CALL ROUTINE_NC_LOAD( pt3 , cdna3 , psgn3 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn4 ) )   CALL ROUTINE_NC_LOAD( pt4 , cdna4 , psgn4 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn5 ) )   CALL ROUTINE_NC_LOAD( pt5 , cdna5 , psgn5 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn6 ) )   CALL ROUTINE_NC_LOAD( pt6 , cdna6 , psgn6 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn7 ) )   CALL ROUTINE_NC_LOAD( pt7 , cdna7 , psgn7 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn8 ) )   CALL ROUTINE_NC_LOAD( pt8 , cdna8 , psgn8 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn9 ) )   CALL ROUTINE_NC_LOAD( pt9 , cdna9 , psgn9 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn10) )   CALL ROUTINE_NC_LOAD( pt10, cdna10, psgn10, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn11) )   CALL ROUTINE_NC_LOAD( pt11, cdna11, psgn11, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn12) )   CALL ROUTINE_NC_LOAD( pt12, cdna12, psgn12, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn13) )   CALL ROUTINE_NC_LOAD( pt13, cdna13, psgn13, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn14) )   CALL ROUTINE_NC_LOAD( pt14, cdna14, psgn14, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn15) )   CALL ROUTINE_NC_LOAD( pt15, cdna15, psgn15, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      IF( PRESENT(psgn16) )   CALL ROUTINE_NC_LOAD( pt16, cdna16, psgn16, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      !
-      CALL lbc_lnk_nc    ( cdname,               ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
-      !
-   END SUBROUTINE ROUTINE_MULTI_NC
-
-
-   SUBROUTINE ROUTINE_NC_LOAD( ptab, cdna, psgn, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
-      !!---------------------------------------------------------------------
-      ARRAY_TYPE(:,:,:,:)   , TARGET, INTENT(inout) ::   ptab       ! arrays on which the lbc is applied
-      CHARACTER(len=1)              , INTENT(in   ) ::   cdna       ! nature of pt2d array grid-points
-      REAL(wp)                      , INTENT(in   ) ::   psgn       ! sign used across the north fold boundary
-      PTR_TYPE        , DIMENSION(:), INTENT(inout) ::   ptab_ptr   ! array of pointers
-      CHARACTER(len=1), DIMENSION(:), INTENT(inout) ::   cdna_ptr   ! nature of pt2d_array array grid-points
-      REAL(wp)        , DIMENSION(:), INTENT(inout) ::   psgn_ptr   ! sign used across the north fold boundary
-      INTEGER                       , INTENT(inout) ::   kfld       ! number of elements that has been attributed
-      !!---------------------------------------------------------------------
-      !
-      kfld                    =  kfld + 1
-      ptab_ptr(kfld)%PTR_ptab => ptab
-      cdna_ptr(kfld)          =  cdna
-      psgn_ptr(kfld)          =  psgn
-      !
-   END SUBROUTINE ROUTINE_NC_LOAD
-
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef PTR_TYPE
-#undef PTR_ptab
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_neicoll_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_neicoll_generic.h90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_neicoll_generic.h90	(revision 14644)
@@ -0,0 +1,260 @@
+
+   SUBROUTINE lbc_lnk_neicoll_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, khls, lsend, lrecv, ld4only )
+      CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
+      TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
+      CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  DIMENSION(:), INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
+      REAL(PRECISION),      OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
+      LOGICAL,              OPTIONAL, INTENT(in   ) ::   ld4only     ! if .T., do only 4-neighbour comm (ignore corners)
+      !
+      INTEGER  ::    ji,  jj,  jk , jl,  jf, jn      ! dummy loop indices
+      INTEGER  ::   ipi, ipj, ipk, ipl, ipf          ! dimension of the input array
+      INTEGER  ::   ip0i, ip1i, im0i, im1i
+      INTEGER  ::   ip0j, ip1j, im0j, im1j
+      INTEGER  ::   ishti, ishtj, ishti2, ishtj2
+      INTEGER  ::   iszS, iszR
+      INTEGER  ::   ierr
+      INTEGER  ::   ihls, idx
+      INTEGER  ::   impi_nc
+      INTEGER  ::   ifill_nfd
+      INTEGER, DIMENSION(4)  ::   iwewe, issnn
+      INTEGER, DIMENSION(8)  ::   isizei, ishtSi, ishtRi, ishtPi
+      INTEGER, DIMENSION(8)  ::   isizej, ishtSj, ishtRj, ishtPj
+      INTEGER, DIMENSION(8)  ::   ifill, iszall
+      INTEGER, DIMENSION(:), ALLOCATABLE  ::   iScnt, iRcnt    ! number of elements to be sent/received
+      INTEGER, DIMENSION(:), ALLOCATABLE  ::   iSdpl, iRdpl    ! displacement in halos arrays
+      LOGICAL, DIMENSION(8)  ::   llsend, llrecv
+      REAL(PRECISION) ::   zland
+      LOGICAL  ::   ll4only                                    ! default: 8 neighbourgs
+      LOGICAL  ::   ll_IdoNFold
+      !!----------------------------------------------------------------------
+      !
+      ! ----------------------------------------- !
+      !     1. local variables initialization     !
+      ! ----------------------------------------- !
+      !
+      ipi = SIZE(ptab(1)%pt4d,1)
+      ipj = SIZE(ptab(1)%pt4d,2)
+      ipk = SIZE(ptab(1)%pt4d,3)
+      ipl = SIZE(ptab(1)%pt4d,4)
+      ipf = kfld
+      !
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
+      !
+      ! take care of optional parameters
+      !
+      ihls = nn_hls       ! default definition
+      IF( PRESENT( khls ) )   ihls = khls
+      IF( ihls > n_hlsmax ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), '  is calling lbc_lnk with khls > n_hlsmax : ', khls, '>', n_hlsmax
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipi /= Ni_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along i: ', ipi, ihls, Ni_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipj /= Nj_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along j:', ipj, ihls , Nj_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      !
+      ll4only = .FALSE.    ! default definition
+      IF( PRESENT(ld4only) )   ll4only = ld4only
+      !
+      impi_nc = mpi_nc_com8(ihls)   ! default
+      IF( ll4only )   impi_nc = mpi_nc_com4(ihls)
+      !
+      zland = 0._wp                                     ! land filling value: zero by default
+      IF( PRESENT( pfillval ) )   zland = pfillval      ! set land value
+      !
+      ! define llsend and llrecv: logicals which say if mpi-neibourgs for send or receive exist or not.
+      IF     ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN   ! localy defined neighbourgs 
+         CALL ctl_stop( 'STOP', 'mpp_nc_generic+BDY not yet implemented')
+!!$         ---> llsend(:) = lsend(:)   ;   llrecv(:) = lrecv(:) ???
+      ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ELSE                                              ! default neighbours
+         llsend(:) = mpiSnei(ihls,:) >= 0
+         IF( ll4only )   llsend(5:8) = .FALSE.          ! exclude corners
+         llrecv(:) = mpiRnei(ihls,:) >= 0
+         IF( ll4only )   llrecv(5:8) = .FALSE.          ! exclude corners
+      ENDIF
+      !
+      ! define ifill: which method should be used to fill each parts (sides+corners) of the halos
+      ! default definition
+      DO jn = 1, 8
+         IF(             llrecv(jn) ) THEN   ;   ifill(jn) = jpfillmpi    ! with an mpi communication
+         ELSEIF(    l_SelfPerio(jn) ) THEN   ;   ifill(jn) = jpfillperio  ! with self-periodicity
+         ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill(jn) = kfillmode    ! localy defined
+         ELSE                                ;   ifill(jn) = jpfillcst    ! constant value (zland)
+         ENDIF
+      END DO
+      ! take care of "indirect self-periodicity" for the corners
+      DO jn = 5, 8
+         IF(.NOT.l_SelfPerio(jn) .AND. l_SelfPerio(jpwe))   ifill(jn) = jpfillnothing   ! no bi-perio but ew-perio: do corners later
+         IF(.NOT.l_SelfPerio(jn) .AND. l_SelfPerio(jpso))   ifill(jn) = jpfillnothing   ! no bi-perio but ns-perio: do corners later
+      END DO
+      ! north fold treatment
+      ll_IdoNFold = l_IdoNFold .AND. ifill(jpno) /= jpfillnothing
+      IF( ll_IdoNFold ) THEN
+         ifill_nfd = ifill(jpno)             ! if we are here, this means llrecv(jpno) = .false. and l_SelfPerio(jpno) = .false.
+         ifill( (/jpno/) ) = jpfillnothing   ! we do north fold -> do nothing for northern halo
+      ENDIF
+      
+      ! We first define the localization and size of the parts of the array that will be sent (s), received (r)
+      ! or used for periodocity (p). The localization is defined as "the bottom left corner - 1" in i and j directions.
+      ! This is a shift that will be applied later in the do loops to pick-up the appropriate part of the array
+      !
+      ! all definitions bellow do not refer to N[ij][se]0 so we can use it with any local value of ihls
+      !                   !                       ________________________
+      ip0i =          0   !          im0j = inner |__|________________|__|
+      ip1i =       ihls   !   im1j = inner - halo |  |__|__________|__|  |
+      im1i = ipi-2*ihls   !                       |  |  |          |  |  |
+      im0i = ipi - ihls   !                       |  |  |          |  |  |
+      ip0j =          0   !                       |  |  |          |  |  |
+      ip1j =       ihls   !                       |  |__|__________|__|  |
+      im1j = ipj-2*ihls   !           ip1j = halo |__|__|__________|__|__|
+      im0j = ipj - ihls   !              ip0j = 0 |__|________________|__|
+      !                   !                    ip0i ip1i        im1i im0i
+      !
+      iwewe(:) = (/ jpwe,jpea,jpwe,jpea /)   ;   issnn(:) = (/ jpso,jpso,jpno,jpno /)
+      !     sides:     west  east south north      ;   corners: so-we, so-ea, no-we, no-ea
+      isizei(1:4) = (/ ihls, ihls, Ni_0, Ni_0 /)   ;   isizei(5:8) = ihls              ! i- count
+      isizej(1:4) = (/ Nj_0, Nj_0, ihls, ihls /)   ;   isizej(5:8) = ihls              ! j- count
+      ishtSi(1:4) = (/ ip1i, im1i, ip1i, ip1i /)   ;   ishtSi(5:8) = ishtSi( iwewe )   ! i- shift send data
+      ishtSj(1:4) = (/ ip1j, ip1j, ip1j, im1j /)   ;   ishtSj(5:8) = ishtSj( issnn )   ! j- shift send data
+      ishtRi(1:4) = (/ ip0i, im0i, ip1i, ip1i /)   ;   ishtRi(5:8) = ishtRi( iwewe )   ! i- shift received data location
+      ishtRj(1:4) = (/ ip1j, ip1j, ip0j, im0j /)   ;   ishtRj(5:8) = ishtRj( issnn )   ! j- shift received data location
+      ishtPi(1:4) = (/ im1i, ip1i, ip1i, ip1i /)   ;   ishtPi(5:8) = ishtPi( iwewe )   ! i- shift data used for periodicity
+      ishtPj(1:4) = (/ ip1j, ip1j, im1j, ip1j /)   ;   ishtPj(5:8) = ishtPj( issnn )   ! j- shift data used for periodicity
+      !
+      ! -------------------------------- !
+      !     2. Prepare MPI exchanges     !
+      ! -------------------------------- !
+      !
+      ! Allocate local temporary arrays to be sent/received.
+      iszS = COUNT( llsend )
+      iszR = COUNT( llrecv )
+      ALLOCATE( iScnt(iszS), iRcnt(iszR), iSdpl(iszS), iRdpl(iszR) )   ! ok if iszS = 0 or iszR = 0
+      iszall(:) = isizei(:) * isizej(:) * ipk * ipl * ipf
+      iScnt(:) = PACK( iszall, mask = llsend )                                       ! ok if mask = .false.
+      iRcnt(:) = PACK( iszall, mask = llrecv )
+      iSdpl(1) = 0
+      DO jn = 2,iszS
+         iSdpl(jn) = iSdpl(jn-1) + iScnt(jn-1)   ! with _alltoallv: in units of sendtype
+      END DO
+      iRdpl(1) = 0
+      DO jn = 2,iszR
+         iRdpl(jn) = iRdpl(jn-1) + iRcnt(jn-1)   ! with _alltoallv: in units of sendtype
+      END DO
+      
+      ! Allocate buffer arrays to be sent/received if needed
+      iszS = SUM(iszall, mask = llsend)                             ! send buffer size
+      IF( ALLOCATED(BUFFSND) ) THEN
+         IF( SIZE(BUFFSND) < iszS )    DEALLOCATE(BUFFSND)          ! send buffer is too small
+      ENDIF
+      IF( .NOT. ALLOCATED(BUFFSND) )   ALLOCATE( BUFFSND(iszS) )
+      iszR = SUM(iszall, mask = llrecv)                             ! recv buffer size
+      IF( ALLOCATED(BUFFRCV) ) THEN
+         IF( SIZE(BUFFRCV) < iszR )    DEALLOCATE(BUFFRCV)          ! recv buffer is too small
+      ENDIF
+      IF( .NOT. ALLOCATED(BUFFRCV) )   ALLOCATE( BUFFRCV(iszR) )
+
+      ! fill sending buffer with ptab(jf)%pt4d
+      idx = 1
+      DO jn = 1, 8
+         IF( llsend(jn) ) THEN
+            ishti = ishtSi(jn)
+            ishtj = ishtSj(jn)
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               BUFFSND(idx) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl)
+               idx = idx + 1
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         ENDIF
+      END DO
+      !
+      ! ------------------------------------------------ !
+      !     3. Do all MPI exchanges in 1 unique call     !
+      ! ------------------------------------------------ !
+      !
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      CALL mpi_neighbor_alltoallv (BUFFSND, iScnt, iSdpl, MPI_TYPE, BUFFRCV, iRcnt, iRdpl, MPI_TYPE, impi_nc, ierr)
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+      !
+      ! ------------------------- !
+      !     4. Fill all halos     !
+      ! ------------------------- !
+      !
+      idx = 1
+      DO jn = 1, 8
+         ishti = ishtRi(jn)
+         ishtj = ishtRj(jn)
+         SELECT CASE ( ifill(jn) )
+         CASE ( jpfillnothing )               ! no filling 
+         CASE ( jpfillmpi   )                 ! fill with data received by MPI
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = BUFFRCV(idx)
+               idx = idx + 1
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillperio )                 ! use periodicity
+            ishti2 = ishtPi(jn)
+            ishtj2 = ishtPj(jn)
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillcopy  )                 ! filling with inner domain values
+            ishti2 = ishtSi(jn)
+            ishtj2 = ishtSj(jn)
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         CASE ( jpfillcst   )                 ! filling with constant value
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = zland
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         END SELECT
+      END DO
+
+      DEALLOCATE( iScnt, iRcnt, iSdpl, iRdpl )
+      IF( iszS > jpi*jpj )   DEALLOCATE(BUFFSND)                    ! blocking Send -> can directly deallocate
+      IF( iszR > jpi*jpj )   DEALLOCATE(BUFFRCV)                    ! blocking Recv -> can directly deallocate
+
+      ! potential "indirect self-periodicity" for the corners
+      DO jn = 5, 8
+         IF( .NOT. l_SelfPerio(jn) .AND. l_SelfPerio(jpwe)  ) THEN   ! no bi-perio but ew-perio: corners indirect definition
+            ishti  = ishtRi(jn)
+            ishtj  = ishtRj(jn)
+            ishti2 = ishtPi(jn)   ! use i- shift periodicity
+            ishtj2 = ishtRj(jn)   ! use j- shift recv location: use ew-perio -> ok as filling of the south and north halos now done
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         ENDIF
+         IF( .NOT. l_SelfPerio(jn) .AND. l_SelfPerio(jpso)  ) THEN   ! no bi-perio but ns-perio: corners indirect definition
+            ishti  = ishtRi(jn)
+            ishtj  = ishtRj(jn)
+            ishti2 = ishtRi(jn)   ! use i- shift recv location: use ns-perio -> ok as filling of the west and east halos now done
+            ishtj2 = ishtPj(jn)   ! use j- shift periodicity
+            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+               ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
+            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+         ENDIF
+      END DO
+      !
+      ! ------------------------------- !
+      !     5. north fold treatment     !
+      ! ------------------------------- !
+      !
+      IF( ll_IdoNFold ) THEN
+         IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ihls, ipf )   ! self NFold
+         ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ihls, ipf )   ! mpi  NFold
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE lbc_lnk_neicoll_/**/PRECISION
+
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_lnk_pt2pt_generic.h90	(revision 14644)
@@ -0,0 +1,304 @@
+  
+#if ! defined BLOCK_ISEND && ! defined BLOCK_FILL
+   SUBROUTINE lbc_lnk_pt2pt_/**/PRECISION( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, khls, lsend, lrecv, ld4only )
+      CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
+      TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
+      CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  DIMENSION(:), INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
+      REAL(PRECISION),      OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER ,             OPTIONAL, INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
+      LOGICAL,              OPTIONAL, INTENT(in   ) ::   ld4only     ! if .T., do only 4-neighbour comm (ignore corners)
+      !
+      INTEGER  ::     ji,   jj,  jk,  jl,  jf, jn     ! dummy loop indices
+      INTEGER  ::    ipi,  ipj, ipk, ipl, ipf         ! dimension of the input array
+      INTEGER  ::   ip0i, ip1i, im0i, im1i
+      INTEGER  ::   ip0j, ip1j, im0j, im1j
+      INTEGER  ::   ishti, ishtj, ishti2, ishtj2
+      INTEGER  ::   ifill_nfd, icomm, ierr
+      INTEGER  ::   ihls, idxs, idxr, iszS, iszR
+      INTEGER, DIMENSION(4)  ::   iwewe, issnn
+      INTEGER, DIMENSION(8)  ::   isizei, ishtSi, ishtRi, ishtPi
+      INTEGER, DIMENSION(8)  ::   isizej, ishtSj, ishtRj, ishtPj
+      INTEGER, DIMENSION(8)  ::   ifill, iszall, ishtS, ishtR
+      INTEGER, DIMENSION(8)  ::   ireq             ! mpi_request id
+      INTEGER, DIMENSION(8)  ::   iStag, iRtag     ! Send and Recv mpi_tag id
+      REAL(PRECISION) ::   zland
+      LOGICAL, DIMENSION(8)  ::   llsend, llrecv
+      LOGICAL  ::   ll4only                                        ! default: 8 neighbourgs
+      LOGICAL  ::   ll_IdoNFold
+      !!----------------------------------------------------------------------
+      !
+      ! ----------------------------------------- !
+      !     1. local variables initialization     !
+      ! ----------------------------------------- !
+      !
+      ipi = SIZE(ptab(1)%pt4d,1)
+      ipj = SIZE(ptab(1)%pt4d,2)
+      ipk = SIZE(ptab(1)%pt4d,3)
+      ipl = SIZE(ptab(1)%pt4d,4)
+      ipf = kfld
+      !
+      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
+      !
+      idxs = 1   ! initalize index for send buffer
+      idxr = 1   ! initalize index for recv buffer
+      icomm = mpi_comm_oce        ! shorter name
+      !
+      ! take care of optional parameters
+      !
+      ihls = nn_hls   ! default definition
+      IF( PRESENT( khls ) )   ihls = khls
+      IF( ihls > n_hlsmax ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with khls > n_hlsmax : ', khls, '>', n_hlsmax
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipi /= Ni_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along i: ', ipi, ihls, Ni_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      IF( ipj /= Nj_0+2*ihls ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with an input array which does not match ihls along j:', ipj, ihls , Nj_0
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
+      !
+      ll4only = .FALSE.    ! default definition
+      IF( PRESENT(ld4only) )   ll4only = ld4only
+      !
+      zland = 0._wp                                     ! land filling value: zero by default
+      IF( PRESENT( pfillval ) )   zland = pfillval      ! set land value
+      !
+      ! define llsend and llrecv: logicals which say if mpi-neibourgs for send or receive exist or not.
+      IF     ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN   ! localy defined neighbourgs 
+         llsend(1:4) = lsend(1:4)   ;   llrecv(1:4) = lrecv(1:4)
+      ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
+         WRITE(ctmp1,*) TRIM(cdname), ' is calling lbc_lnk with only one of the two arguments lsend or lrecv'
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ELSE                                              ! default neighbours
+         llsend(:) = mpiSnei(ihls,:) >= 0
+         IF( ll4only )   llsend(5:8) = .FALSE.          ! exclude corners
+         llrecv(:) = mpiRnei(ihls,:) >= 0
+         IF( ll4only )   llrecv(5:8) = .FALSE.          ! exclude corners
+      ENDIF
+      !
+      ! define ifill: which method should be used to fill each parts (sides+corners) of the halos
+      ! default definition
+      DO jn = 1, 4
+         IF(             llrecv(jn) ) THEN   ;   ifill(jn) = jpfillmpi    ! with an mpi communication
+         ELSEIF(    l_SelfPerio(jn) ) THEN   ;   ifill(jn) = jpfillperio  ! with self-periodicity
+         ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill(jn) = kfillmode    ! localy defined
+         ELSE                                ;   ifill(jn) = jpfillcst    ! constant value (zland)
+         ENDIF
+      END DO
+      DO jn = 5, 8
+         IF(             llrecv(jn) ) THEN   ;   ifill(jn) = jpfillmpi    ! with an mpi communication
+         ELSE                                ;   ifill(jn) = jpfillnothing! do nothing
+         ENDIF
+      END DO
+         !
+      ! north fold treatment
+      ll_IdoNFold = l_IdoNFold .AND. ifill(jpno) /= jpfillnothing
+      IF( ll_IdoNFold ) THEN
+         ifill_nfd = ifill(jpno)             ! if we are here, this means llrecv(jpno) = .false. and l_SelfPerio(jpno) = .false.
+         ifill( (/jpno/) ) = jpfillnothing   ! we do north fold -> do nothing for northern halo
+      ENDIF
+      
+      ! We first define the localization and size of the parts of the array that will be sent (s), received (r)
+      ! or used for periodocity (p). The localization is defined as "the bottom left corner - 1" in i and j directions.
+      ! This is a shift that will be applied later in the do loops to pick-up the appropriate part of the array
+      !
+      ! all definitions bellow do not refer to N[ij][se]0 so we can use it with any local value of ihls
+      !                   !                       ________________________
+      ip0i =          0   !          im0j = inner |__|__|__________|__|__|
+      ip1i =       ihls   !   im1j = inner - halo |__|__|__________|__|__|
+      im1i = ipi-2*ihls   !                       |  |  |          |  |  |
+      im0i = ipi - ihls   !                       |  |  |          |  |  |
+      ip0j =          0   !                       |  |  |          |  |  |
+      ip1j =       ihls   !                       |__|__|__________|__|__|
+      im1j = ipj-2*ihls   !           ip1j = halo |__|__|__________|__|__|
+      im0j = ipj - ihls   !              ip0j = 0 |__|__|__________|__|__|
+      !                   !                    ip0i ip1i        im1i im0i
+      !
+      iwewe(:) = (/ jpwe,jpea,jpwe,jpea /)   ;   issnn(:) = (/ jpso,jpso,jpno,jpno /)
+      !cd     sides:     west  east south north      ;   corners: so-we, so-ea, no-we, no-ea
+      isizei(1:4) = (/ ihls, ihls,  ipi,  ipi /)   ;   isizei(5:8) = ihls              ! i- count
+      isizej(1:4) = (/  ipj,  ipj, ihls, ihls /)   ;   isizej(5:8) = ihls              ! j- count
+      ishtSi(1:4) = (/ ip1i, im1i, ip0i, ip0i /)   ;   ishtSi(5:8) = ishtSi( iwewe )   ! i- shift send data
+      ishtSj(1:4) = (/ ip0j, ip0j, ip1j, im1j /)   ;   ishtSj(5:8) = ishtSj( issnn )   ! j- shift send data
+      ishtRi(1:4) = (/ ip0i, im0i, ip0i, ip0i /)   ;   ishtRi(5:8) = ishtRi( iwewe )   ! i- shift received data location
+      ishtRj(1:4) = (/ ip0j, ip0j, ip0j, im0j /)   ;   ishtRj(5:8) = ishtRj( issnn )   ! j- shift received data location
+      ishtPi(1:4) = (/ im1i, ip1i, ip0i, ip0i /)   ;   ishtPi(5:8) = ishtPi( iwewe )   ! i- shift data used for periodicity
+      ishtPj(1:4) = (/ ip0j, ip0j, im1j, ip1j /)   ;   ishtPj(5:8) = ishtPj( issnn )   ! j- shift data used for periodicity
+      !
+      ! -------------------------------- !
+      !     2. Prepare MPI exchanges     !
+      ! -------------------------------- !
+      !
+      iStag = (/ 1, 2, 3, 4, 5, 6, 7, 8 /)   ! any value but each one must be different
+      ! define iRtag with the corresponding iStag, e.g. data received at west where sent at east.
+      iRtag(jpwe) = iStag(jpea)   ;   iRtag(jpea) = iStag(jpwe)   ;   iRtag(jpso) = iStag(jpno)   ;   iRtag(jpno) = iStag(jpso)
+      iRtag(jpsw) = iStag(jpne)   ;   iRtag(jpse) = iStag(jpnw)   ;   iRtag(jpnw) = iStag(jpse)   ;   iRtag(jpne) = iStag(jpsw)
+      !
+      iszall(:) = isizei(:) * isizej(:) * ipk * ipl * ipf
+      ishtS(1) = 0
+      DO jn = 2, 8
+         ishtS(jn) = ishtS(jn-1) + iszall(jn-1) * COUNT( (/llsend(jn-1)/) )
+      END DO
+      ishtR(1) = 0
+      DO jn = 2, 8
+         ishtR(jn) = ishtR(jn-1) + iszall(jn-1) * COUNT( (/llrecv(jn-1)/) )
+      END DO
+
+      ! Allocate buffer arrays to be sent/received if needed
+      iszS = SUM(iszall, mask = llsend)                             ! send buffer size
+      IF( ALLOCATED(BUFFSND) ) THEN
+         CALL mpi_waitall(8, nreq_p2p, MPI_STATUSES_IGNORE, ierr)   ! wait for Isend from the PREVIOUS call
+         IF( SIZE(BUFFSND) < iszS )    DEALLOCATE(BUFFSND)          ! send buffer is too small
+      ENDIF
+      IF( .NOT. ALLOCATED(BUFFSND) )   ALLOCATE( BUFFSND(iszS) )
+      iszR = SUM(iszall, mask = llrecv)                             ! recv buffer size
+      IF( ALLOCATED(BUFFRCV) ) THEN
+         IF( SIZE(BUFFRCV) < iszR )    DEALLOCATE(BUFFRCV)          ! recv buffer is too small
+      ENDIF
+      IF( .NOT. ALLOCATED(BUFFRCV) )   ALLOCATE( BUFFRCV(iszR) )
+      !
+      ! default definition when no communication is done. understood by mpi_waitall
+      nreq_p2p(:) = MPI_REQUEST_NULL   ! WARNING: Must be done after the call to mpi_waitall just above
+      !
+      ! ----------------------------------------------- !
+      !     3. Do east and west MPI_Isend if needed     !
+      ! ----------------------------------------------- !
+      !
+      DO jn = 1, 2
+#define BLOCK_ISEND
+#  include "lbc_lnk_pt2pt_generic.h90"         
+#undef BLOCK_ISEND
+      END DO
+      !
+      ! ----------------------------------- !
+      !     4. Fill east and west halos     !
+      ! ----------------------------------- !
+      !
+      DO jn = 1, 2
+#define BLOCK_FILL
+#  include "lbc_lnk_pt2pt_generic.h90"         
+#undef BLOCK_FILL
+      END DO
+      !
+      ! ------------------------------------------------- !
+      !     5. Do north and south MPI_Isend if needed     !
+      ! ------------------------------------------------- !
+      !
+      DO jn = 3, 4
+#define BLOCK_ISEND
+#  include "lbc_lnk_pt2pt_generic.h90"         
+#undef BLOCK_ISEND
+      END DO
+      !
+      ! ------------------------------- !
+      !     6. north fold treatment     !
+      ! ------------------------------- !
+      !
+      ! Must be done after receiving data from East/West neighbourgs (as it is coded in mpp_nfd, to be changed one day...)
+      ! Do it after MPI_iSend to south/north neighbourgs so they won't wait (too much) to receive their data
+      ! Do if before MPI_Recv from south/north neighbourgs so we have more time to receive data
+      !
+      IF( ll_IdoNFold ) THEN
+         IF( jpni == 1 )  THEN   ;   CALL lbc_nfd( ptab, cd_nat, psgn                  , ihls, ipf )   ! self NFold
+         ELSE                    ;   CALL mpp_nfd( ptab, cd_nat, psgn, ifill_nfd, zland, ihls, ipf )   ! mpi  NFold
+         ENDIF
+      ENDIF
+      !
+      ! ------------------------------------- !
+      !     7. Fill south and north halos     !
+      ! ------------------------------------- !
+      !
+      DO jn = 3, 4
+#define BLOCK_FILL
+#  include "lbc_lnk_pt2pt_generic.h90"         
+#undef BLOCK_FILL
+      END DO
+      !
+      ! ----------------------------------------------- !
+      !     8. Specific problem in corner treatment     !
+      !              ( very rate case... )              !
+      ! ----------------------------------------------- !
+      !
+      DO jn = 5, 8
+#define BLOCK_ISEND
+#  include "lbc_lnk_pt2pt_generic.h90"         
+#undef BLOCK_ISEND
+      END DO
+      DO jn = 5, 8
+#define BLOCK_FILL
+#  include "lbc_lnk_pt2pt_generic.h90"         
+#undef BLOCK_FILL
+      END DO
+      !
+      ! -------------------------------------------- !
+      !     9. deallocate local temporary arrays     !
+      !        if they areg larger than jpi*jpj      !  <- arbitrary max size...
+      ! -------------------------------------------- !
+      !
+      IF( iszR > jpi*jpj )   DEALLOCATE(BUFFRCV)                    ! blocking receive -> can directly deallocate
+      IF( iszS > jpi*jpj ) THEN
+         CALL mpi_waitall(8, nreq_p2p, MPI_STATUSES_IGNORE, ierr)   ! must wait before deallocate send buffer
+         DEALLOCATE(BUFFSND)
+      ENDIF
+      !
+   END SUBROUTINE lbc_lnk_pt2pt_/**/PRECISION
+#endif
+
+#if defined BLOCK_ISEND
+   IF( llsend(jn) ) THEN
+      ishti = ishtSi(jn)
+      ishtj = ishtSj(jn)
+      DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+         BUFFSND(idxs) = ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl)
+         idxs = idxs + 1
+      END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+#if ! defined key_mpi_off
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      ! non-blocking send of the west/east side using local buffer
+      CALL MPI_ISEND( BUFFSND(ishtS(jn)+1), iszall(jn), MPI_TYPE, mpiSnei(ihls,jn), iStag(jn), icomm, nreq_p2p(jn), ierr )
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+#endif
+   ENDIF
+#endif
+
+#if defined BLOCK_FILL
+   ishti = ishtRi(jn)
+   ishtj = ishtRj(jn)
+   SELECT CASE ( ifill(jn) )
+   CASE ( jpfillnothing )               ! no filling 
+   CASE ( jpfillmpi   )                 ! fill with data received by MPI
+#if ! defined key_mpi_off
+      IF( ln_timing ) CALL tic_tac(.TRUE.)
+      !                                 ! blocking receive of the west/east halo in local temporary arrays
+      CALL MPI_RECV( BUFFRCV(ishtR(jn)+1), iszall(jn), MPI_TYPE, mpiRnei(ihls,jn), iRtag(jn), icomm, MPI_STATUS_IGNORE, ierr )
+      IF( ln_timing ) CALL tic_tac(.FALSE.)
+#endif
+      DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+         ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = BUFFRCV(idxr)
+         idxr = idxr + 1
+      END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+   CASE ( jpfillperio )                 ! use periodicity
+      ishti2 = ishtPi(jn)
+      ishtj2 = ishtPj(jn)
+      DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+         ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
+      END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+   CASE ( jpfillcopy  )                 ! filling with inner domain values
+      ishti2 = ishtSi(jn)
+      ishtj2 = ishtSj(jn)
+      DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+         ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = ptab(jf)%pt4d(ishti2+ji,ishtj2+jj,jk,jl)
+      END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+   CASE ( jpfillcst   )                 ! filling with constant value
+      DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1,isizej(jn)  ;  DO ji = 1,isizei(jn)
+         ptab(jf)%pt4d(ishti+ji,ishtj+jj,jk,jl) = zland
+      END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
+   END SELECT
+#endif
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_ext_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_ext_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_ext_generic.h90	(revision 14644)
@@ -1,35 +1,14 @@
-!                          !==  IN: ptab is an array  ==!
-#define NAT_IN(k)                cd_nat
-#define SGN_IN(k)                psgn
-#define F_SIZE(ptab)             1
-#if defined DIM_2d
-#   define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#   define K_SIZE(ptab)          1
-#   define L_SIZE(ptab)          1
-#endif
-#if defined SINGLE_PRECISION
-#   define ARRAY_TYPE(i,j,k,l,f)    REAL(sp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#   define PRECISION sp
-#else
-#   define ARRAY_TYPE(i,j,k,l,f)    REAL(dp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#   define PRECISION dp
-#endif
 
-   SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn, kextj )
+   SUBROUTINE lbc_nfd_ext_/**/PRECISION( ptab, cd_nat, psgn, kextj )
       !!----------------------------------------------------------------------
-      INTEGER          , INTENT(in   ) ::   kextj       ! extra halo width at north fold, declared before its use in ARRAY_TYPE
-      ARRAY_TYPE(:,1-kextj:,:,:,:)                      ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=1) , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)         , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
+      REAL(PRECISION), DIMENSION(:,1-kextj:),INTENT(inout) ::   ptab
+      CHARACTER(len=1), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER,          INTENT(in   ) ::   kextj       ! extra halo width at north fold
       !
-      INTEGER  ::    ji,  jj,  jk,  jl, jh,  jf   ! dummy loop indices
-      INTEGER  ::   ipi, ipj, ipk, ipl,     ipf   ! dimension of the input array
+      INTEGER  ::    ji,  jj,  jh   ! dummy loop indices
+      INTEGER  ::   ipj
       INTEGER  ::   ijt, iju, ipjm1
       !!----------------------------------------------------------------------
-      !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
       !
       SELECT CASE ( jpni )
@@ -39,126 +18,103 @@
       !
       ipjm1 = ipj-1
+      !
+      IF( c_NFtype == 'T' ) THEN            ! *  North fold  T-point pivot
+         !
+         SELECT CASE ( cd_nat  )
+         CASE ( 'T' , 'W' )                         ! T-, W-point
+            DO jh = 0, kextj
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  ptab(ji,ipj+jh) = psgn * ptab(ijt,ipj-2-jh)
+               END DO
+               ptab(1,ipj+jh) = psgn * ptab(3,ipj-2-jh)
+            END DO
+            DO ji = jpiglo/2+1, jpiglo
+               ijt = jpiglo-ji+2
+               ptab(ji,ipjm1) = psgn * ptab(ijt,ipjm1)
+            END DO
+         CASE ( 'U' )                               ! U-point
+            DO jh = 0, kextj
+               DO ji = 2, jpiglo-1
+                  iju = jpiglo-ji+1
+                  ptab(ji,ipj+jh) = psgn * ptab(iju,ipj-2-jh)
+               END DO
+               ptab(   1  ,ipj+jh) = psgn * ptab(    2   ,ipj-2-jh)
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-1,ipj-2-jh) 
+            END DO
+            DO ji = jpiglo/2, jpiglo-1
+               iju = jpiglo-ji+1
+               ptab(ji,ipjm1) = psgn * ptab(iju,ipjm1)
+            END DO
+         CASE ( 'V' )                               ! V-point
+            DO jh = 0, kextj
+               DO ji = 2, jpiglo
+                  ijt = jpiglo-ji+2
+                  ptab(ji,ipj-1+jh) = psgn * ptab(ijt,ipj-2-jh)
+                  ptab(ji,ipj+jh  ) = psgn * ptab(ijt,ipj-3-jh)
+               END DO
+               ptab(1,ipj+jh) = psgn * ptab(3,ipj-3-jh) 
+            END DO
+         CASE ( 'F' )                               ! F-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji+1
+                  ptab(ji,ipj-1+jh) = psgn * ptab(iju,ipj-2-jh)
+                  ptab(ji,ipj+jh  ) = psgn * ptab(iju,ipj-3-jh)
+               END DO
+            END DO
+            DO jh = 0, kextj
+               ptab(   1  ,ipj+jh) = psgn * ptab(    2   ,ipj-3-jh)
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-1,ipj-3-jh)
+            END DO
+         END SELECT
+         !
+      ENDIF   ! c_NFtype == 'T'
+      !
+      IF( c_NFtype == 'F' ) THEN            ! *  North fold  F-point pivot
+         !
+         SELECT CASE ( cd_nat  )
+         CASE ( 'T' , 'W' )                         ! T-, W-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  ptab(ji,ipj+jh) = psgn * ptab(ijt,ipj-1-jh)
+               END DO
+            END DO
+         CASE ( 'U' )                               ! U-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  ptab(ji,ipj+jh) = psgn * ptab(iju,ipj-1-jh)
+               END DO
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-2,ipj-1-jh)
+            END DO
+         CASE ( 'V' )                               ! V-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo
+                  ijt = jpiglo-ji+1
+                  ptab(ji,ipj+jh) = psgn * ptab(ijt,ipj-2-jh)
+               END DO
+            END DO
+            DO ji = jpiglo/2+1, jpiglo
+               ijt = jpiglo-ji+1
+               ptab(ji,ipjm1) = psgn * ptab(ijt,ipjm1)
+            END DO
+         CASE ( 'F' )                               ! F-point
+            DO jh = 0, kextj
+               DO ji = 1, jpiglo-1
+                  iju = jpiglo-ji
+                  ptab(ji,ipj+jh  ) = psgn * ptab(iju,ipj-2-jh)
+               END DO
+               ptab(jpiglo,ipj+jh) = psgn * ptab(jpiglo-2,ipj-2-jh)
+            END DO
+            DO ji = jpiglo/2+1, jpiglo-1
+               iju = jpiglo-ji
+               ptab(ji,ipjm1) = psgn * ptab(iju,ipjm1)
+            END DO
+         END SELECT
+         !
+      ENDIF   ! c_NFtype == 'F'
+      !
+   END SUBROUTINE lbc_nfd_ext_/**/PRECISION
 
-      !
-      DO jf = 1, ipf                      ! Loop on the number of arrays to be treated
-         !
-         SELECT CASE ( npolj )
-         !
-         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf)  )
-            CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO jh = 0, kextj
-                  DO ji = 2, jpiglo
-                     ijt = jpiglo-ji+2
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(1,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(3,ipj-2-jh,:,:,jf)
-               END DO
-               DO ji = jpiglo/2+1, jpiglo
-                  ijt = jpiglo-ji+2
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipjm1,:,:,jf)
-               END DO
-            CASE ( 'U' )                               ! U-point
-               DO jh = 0, kextj
-                  DO ji = 2, jpiglo-1
-                     iju = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
-                  END DO
-                 ARRAY_IN(   1  ,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(    2   ,ipj-2-jh,:,:,jf)
-                 ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-2-jh,:,:,jf) 
-               END DO
-               DO ji = jpiglo/2, jpiglo-1
-                  iju = jpiglo-ji+1
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipjm1,:,:,jf)
-               END DO
-            CASE ( 'V' )                               ! V-point
-               DO jh = 0, kextj
-                  DO ji = 2, jpiglo
-                     ijt = jpiglo-ji+2
-                     ARRAY_IN(ji,ipj-1+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2-jh,:,:,jf)
-                     ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-3-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(1,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(3,ipj-3-jh,:,:,jf) 
-               END DO
-            CASE ( 'F' )                               ! F-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
-                     iju = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj-1+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
-                     ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-3-jh,:,:,jf)
-                  END DO
-               END DO
-               DO jh = 0, kextj
-                  ARRAY_IN(   1  ,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(    2   ,ipj-3-jh,:,:,jf)
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-1,ipj-3-jh,:,:,jf)
-               END DO
-            END SELECT
-            !
-         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf)  )
-            CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo
-                     ijt = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-1-jh,:,:,jf)
-                  END DO
-               END DO
-            CASE ( 'U' )                               ! U-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
-                     iju = jpiglo-ji
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-1-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-2,ipj-1-jh,:,:,jf)
-               END DO
-            CASE ( 'V' )                               ! V-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo
-                     ijt = jpiglo-ji+1
-                     ARRAY_IN(ji,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipj-2-jh,:,:,jf)
-                  END DO
-               END DO
-               DO ji = jpiglo/2+1, jpiglo
-                  ijt = jpiglo-ji+1
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(ijt,ipjm1,:,:,jf)
-               END DO
-            CASE ( 'F' )                               ! F-point
-               DO jh = 0, kextj
-                  DO ji = 1, jpiglo-1
-                     iju = jpiglo-ji
-                     ARRAY_IN(ji,ipj+jh  ,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipj-2-jh,:,:,jf)
-                  END DO
-                  ARRAY_IN(jpiglo,ipj+jh,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(jpiglo-2,ipj-2-jh,:,:,jf)
-               END DO
-               DO ji = jpiglo/2+1, jpiglo-1
-                  iju = jpiglo-ji
-                  ARRAY_IN(ji,ipjm1,:,:,jf) = SGN_IN(jf)  * ARRAY_IN(iju,ipjm1,:,:,jf)
-               END DO
-            END SELECT
-            !
-         CASE DEFAULT                           ! *  closed : the code probably never go through
-            !
-            SELECT CASE ( NAT_IN(jf) )
-            CASE ( 'T' , 'U' , 'V' , 'W' )             ! T-, U-, V-, W-points
-               ARRAY_IN(:,  1:1-kextj  ,:,:,jf) = 0._wp
-               ARRAY_IN(:,ipj:ipj+kextj,:,:,jf) = 0._wp
-            CASE ( 'F' )                               ! F-point
-               ARRAY_IN(:,ipj:ipj+kextj,:,:,jf) = 0._wp
-            END SELECT
-            !
-         END SELECT     !  npolj
-         !
-      END DO
-      !
-   END SUBROUTINE ROUTINE_NFD
-
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef ARRAY_IN
-#undef NAT_IN
-#undef SGN_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_generic.h90	(revision 14644)
@@ -1,199 +1,282 @@
-#if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)   
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   if defined DIM_2d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_sp),INTENT(inout)::ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_dp),INTENT(inout)::ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define J_SIZE(ptab)             SIZE(ptab(1)%pt2d,2)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_sp),INTENT(inout)::ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_dp),INTENT(inout)::ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define J_SIZE(ptab)             SIZE(ptab(1)%pt3d,2)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_sp),INTENT(inout)::ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_dp),INTENT(inout)::ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define J_SIZE(ptab)             SIZE(ptab(1)%pt4d,2)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#else
-!                          !==  IN: ptab is an array  ==!
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define F_SIZE(ptab)             1
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define J_SIZE(ptab)          SIZE(ptab,2)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define J_SIZE(ptab)          SIZE(ptab,2)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define J_SIZE(ptab)          SIZE(ptab,2)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-#   if defined SINGLE_PRECISION
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(sp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#   else
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(dp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#   endif
-#endif
 
-#   if defined SINGLE_PRECISION
-#      define PRECISION sp
-#   else
-#      define PRECISION dp
-#   endif
-
-#if defined MULTI
-   SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn, kfld )
-      INTEGER          , INTENT(in   ) ::   kfld        ! number of pt3d arrays
-#else
-   SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn       )
-#endif
-      ARRAY_TYPE(:,:,:,:,:)                             ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=1) , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)         , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
+   SUBROUTINE lbc_nfd_/**/PRECISION( ptab, cd_nat, psgn, khls, kfld )
+      TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
+      CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  DIMENSION(:), INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                       , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
       !
       INTEGER  ::    ji,  jj,  jk,  jl,  jf   ! dummy loop indices
-      INTEGER  ::        ipj, ipk, ipl, ipf   ! dimension of the input array
+      INTEGER  ::   ipi, ipj, ipk, ipl, ipf   ! dimension of the input array
       INTEGER  ::   ii1, ii2, ij1, ij2
       !!----------------------------------------------------------------------
       !
-      ipj = J_SIZE(ptab)   ! 2nd dimension
-      ipk = K_SIZE(ptab)   ! 3rd    -
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
+      ipi = SIZE(ptab(1)%pt4d,1)
+      ipj = SIZE(ptab(1)%pt4d,2)
+      ipk = SIZE(ptab(1)%pt4d,3)
+      ipl = SIZE(ptab(1)%pt4d,4)
+      ipf = kfld
+      !
+      IF( ipi /= Ni0glo+2*khls ) THEN
+         WRITE(ctmp1,*) 'lbc_nfd input array does not match khls', ipi, khls, Ni0glo
+         CALL ctl_stop( 'STOP', ctmp1 )
+      ENDIF
       !
       DO jf = 1, ipf                      ! Loop on the number of arrays to be treated
          !
-         SELECT CASE ( npolj )
+         IF( c_NFtype == 'T' ) THEN            ! *  North fold  T-point pivot
+            !
+            SELECT CASE ( cd_nat(jf) )
+            CASE ( 'T' , 'W' )                         ! T-, W-point
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 2 - ji            ! ends at: 2*khls + 2 - khls = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls+1
+                        ii1 = khls + ji
+                        ii2 = ii1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from khls+2 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =   2 + khls + ji - 1        ! ends at: 2 + khls + ipi - 2*khls - 1 - 1 = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) + 1 = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls + 1
+                        ii1 = ipi - khls + ji
+                        ii2 =          khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls-1            ! last khls-1 points
+                        ii1 = ipi - khls + 1 + ji        ! ends at: ipi - khls + 1 + khls - 1 = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls + 1 = ipi - 2*khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2-1        ! points from ipi/2+2 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji + 1             ! ends at: ipi/2 + (ipi/2 - khls - 1) + 1 = ipi - khls
+                        ii2 = ipi/2 - ji + 1             ! ends at: ipi/2 - (ipi/2 - khls - 1) + 1 = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! first khls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-khls  
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 2 - ji            ! ends at: 2*khls + 2 - khls = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls-1 points: have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
+            CASE ( 'U' )                               ! U-point
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2          ! points from ipi/2+1 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji                 ! ends at: ipi/2 + (ipi/2 - khls) = ipi - khls
+                        ii2 = ipi/2 - ji + 1             ! ends at: ipi/2 - (ipi/2 - khls) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! first khls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-khls  
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls-1 points: have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
+            CASE ( 'V' )                               ! V-point
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last khls+1 lines (from ipj to ipj-khls) : full
+               	  DO jj = 1, khls+1
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - ( khls + 1 ) + 1 = ipj - khls
+                     ij2 = ipj - 2*khls + jj - 2         ! ends at: ipj - 2*khls + khls + 1 - 2 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 2 - ji            ! ends at: 2*khls + 2 - khls = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls+1
+                        ii1 = khls + ji
+                        ii2 = ii1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from khls+2 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =   2 + khls + ji - 1        ! ends at: 2 + khls + ipi - 2*khls - 1 - 1 = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) + 1 = khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls + 1
+                        ii1 = ipi - khls + ji
+                        ii2 =          khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls-1            ! last khls-1 points
+                        ii1 = ipi - khls + 1 + ji        ! ends at: ipi - khls + 1 + khls - 1 = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls + 1 = ipi - 2*khls + 2
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
+            CASE ( 'F' )                               ! F-point
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last khls+1 lines (from ipj to ipj-khls) : full
+               	  DO jj = 1, khls+1
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - ( khls + 1 ) + 1 = ipj - khls
+                     ij2 = ipj - 2*khls + jj - 2         ! ends at: ipj - 2*khls + khls + 1 - 2 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
+            END SELECT   ! cd_nat(jf)
+            !
+         ENDIF   ! c_NFtype == 'T'
          !
-         CASE ( 3 , 4 )                        ! *  North fold  T-point pivot
+         IF( c_NFtype == 'F' ) THEN            ! *  North fold  F-point pivot
             !
-            SELECT CASE ( NAT_IN(jf)  )
+            SELECT CASE ( cd_nat(jf) )
             CASE ( 'T' , 'W' )                         ! T-, W-point
                DO jl = 1, ipl; DO jk = 1, ipk
                   !
-                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
-               	  DO jj = 1, nn_hls
-               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
-                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
-                     !
-                     DO ji = 1, nn_hls            ! first nn_hls points
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 2 - ji          ! ends at: 2*nn_hls + 2 - nn_hls = nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls+1
-                        ii1 = nn_hls + ji
+                  ! first: line number ipj-khls : 3 points
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, 1                 ! points from ipi/2+1
+                        ii1 = ipi/2 + ji
+                        ii2 = ipi/2 - ji + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =            ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
+                     END DO
+                     DO ji = 1, 1                 ! points ipi - khls
+                        ii1 = ipi - khls + ji - 1
+                        ii2 =          khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =            ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
+                     END DO
+                     DO ji = 1, 1                 ! point khls: redo it just in case (if e-w periodocity already done)
+                        !                         ! as we just changed point ipi - khls
+                        ii1 = khls + ji - 1
+                        ii2 = khls + ji
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) =            ptab(jf)%pt4d(ii2,ij2,jk,jl)   ! Warning: pb with sign...
+                     END DO
+                  END DO
+                  !
+                  ! Second: last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj + 1      - jj             ! ends at: ipj + 1 - khls
+                     ij2 = ipj - 2*khls + jj             ! ends at: ipj - 2*khls + khls = ipj - khls
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1        ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji        ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO
+                  !
+               END DO; END DO
+            CASE ( 'U' )                               ! U-point
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj + 1      - jj             ! ends at: ipj + 1 - khls
+                     ij2 = ipj - 2*khls + jj             ! ends at: ipj - 2*khls + khls = ipj - khls
+                     !
+                     DO ji = 1, khls-1            ! first khls-1 points
+                        ii1 =          ji                ! ends at: khls-1
+                        ii2 = 2*khls - ji                ! ends at: 2*khls - ( khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls
+                        ii1 = khls + ji - 1
+                        ii2 = ipi - ii1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from khls+1 to ipi - khls - 1  (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ( ipi - 2*khls - 1 ) = ipi - khls - 1
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls
+                        ii1 = ipi - khls + ji - 1
                         ii2 = ii1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+2 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = 2 + nn_hls      + ji - 1   ! ends at: 2 + nn_hls + jpiglo - 2*nn_hls - 1 - 1 = jpiglo - nn_hls
-                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) + 1 = nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls + 1
-                        ii1 = jpiglo - nn_hls + ji
-                        ii2 =          nn_hls + ji
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls-1          ! last nn_hls-1 points
-                        ii1 = jpiglo - nn_hls + 1 + ji   ! ends at: jpiglo - nn_hls + 1 + nn_hls - 1 = jpiglo
-                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls + 1 = jpiglo - 2*nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO
-                  !
-                  ! line number ipj-nn_hls : right half
-               	  DO jj = 1, 1
-                     ij1 = ipj - nn_hls
-                     ij2 = ij1   ! same line
-                     !
-                     DO ji = 1, Ni0glo/2-1        ! points from jpiglo/2+2 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = jpiglo/2 + ji + 1          ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls - 1) + 1 = jpiglo - nn_hls
-                        ii2 = jpiglo/2 - ji + 1          ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls - 1) + 1 = nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! first nn_hls points: redo them just in case (if e-w periodocity already done)
-                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hls  
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 2 - ji          ! ends at: 2*nn_hls + 2 - nn_hls = nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     !                            ! last nn_hls-1 points: have been / will done by e-w periodicity 
-                  END DO
-                  !
-               END DO; END DO
-            CASE ( 'U' )                               ! U-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  !
-                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
-               	  DO jj = 1, nn_hls
-               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
-                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
-                     !
-                     DO ji = 1, nn_hls            ! first nn_hls points
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
-                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! last nn_hls points
-                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
-                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO
-                  !
-                  ! line number ipj-nn_hls : right half
-               	  DO jj = 1, 1
-                     ij1 = ipj - nn_hls
-                     ij2 = ij1   ! same line
-                     !
-                     DO ji = 1, Ni0glo/2          ! points from jpiglo/2+1 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = jpiglo/2 + ji              ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls) = jpiglo - nn_hls
-                        ii2 = jpiglo/2 - ji + 1          ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls) + 1 = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! first nn_hls points: redo them just in case (if e-w periodocity already done)
-                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hls  
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     !                            ! last nn_hls-1 points: have been / will done by e-w periodicity 
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - khls = ipi - 2*khls
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
                   END DO
                   !
@@ -202,268 +285,107 @@
                DO jl = 1, ipl; DO jk = 1, ipk
                   !
-                  ! last nn_hls+1 lines (from ipj to ipj-nn_hls) : full
-               	  DO jj = 1, nn_hls+1
-               	     ij1 = ipj            - jj + 1       ! ends at: ipj - ( nn_hls + 1 ) + 1 = ipj - nn_hls
-                     ij2 = ipj - 2*nn_hls + jj - 2       ! ends at: ipj - 2*nn_hls + nn_hls + 1 - 2 = ipj - nn_hls - 1
-                     !
-                     DO ji = 1, nn_hls            ! first nn_hls points
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 2 - ji          ! ends at: 2*nn_hls + 2 - nn_hls = nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls+1
-                        ii1 = nn_hls + ji
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls              ! first khls points
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo            ! points from khls to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji          ! ends at: khls + ipi - 2*khls = ipi - khls
+                        ii2 = ipi - khls - ji + 1      ! ends at: ipi - khls - ( ipi - 2*khls ) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls            ! last khls points
+                        ii1 = ipi - khls + ji          ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls + 1 - ji      ! ends at: ipi - khls + 1 - khls = ipi - 2*khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO   
+                  !
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2          ! points from ipi/2+1 to ipi - khls   (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji                 ! ends at: ipi/2 + (ipi/2 - khls) = ipi - khls
+                        ii2 = ipi/2 - ji + 1             ! ends at: ipi/2 - (ipi/2 - khls) + 1 = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! first khls points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-khls  
+                        ii1 =              ji            ! ends at: khls
+                        ii2 = 2*khls + 1 - ji            ! ends at: 2*khls + 1 - khls = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls points: have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
+            CASE ( 'F' )                               ! F-point
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  !
+                  ! last khls lines (from ipj to ipj-khls+1) : full
+               	  DO jj = 1, khls
+               	     ij1 = ipj          - jj + 1         ! ends at: ipj - khls + 1
+                     ij2 = ipj - 2*khls + jj - 1         ! ends at: ipj - 2*khls + khls - 1 = ipj - khls - 1
+                     !
+                     DO ji = 1, khls-1            ! first khls-1 points
+                        ii1 =          ji                ! ends at: khls-1
+                        ii2 = 2*khls - ji                ! ends at: 2*khls - ( khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point khls
+                        ii1 = khls + ji - 1
+                        ii2 = ipi - ii1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, Ni0glo - 1        ! points from khls+1 to ipi - khls - 1  (note: Ni0glo = ipi - 2*khls)
+                        ii1 =       khls + ji            ! ends at: khls + ( ipi - 2*khls - 1 ) = ipi - khls - 1
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - ( ipi - 2*khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, 1                 ! point ipi - khls
+                        ii1 = ipi - khls + ji - 1
                         ii2 = ii1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+2 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = 2 + nn_hls      + ji - 1   ! ends at: 2 + nn_hls + jpiglo - 2*nn_hls - 1 - 1 = jpiglo - nn_hls
-                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) + 1 = nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls + 1
-                        ii1 = jpiglo - nn_hls + ji
-                        ii2 =          nn_hls + ji
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls-1          ! last nn_hls-1 points
-                        ii1 = jpiglo - nn_hls + 1 + ji   ! ends at: jpiglo - nn_hls + 1 + nn_hls - 1 = jpiglo
-                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls + 1 = jpiglo - 2*nn_hls + 2
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO
-                  !
-               END DO; END DO
-            CASE ( 'F' )                               ! F-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  !
-                  ! last nn_hls+1 lines (from ipj to ipj-nn_hls) : full
-               	  DO jj = 1, nn_hls+1
-               	     ij1 = ipj            - jj + 1       ! ends at: ipj - ( nn_hls + 1 ) + 1 = ipj - nn_hls
-                     ij2 = ipj - 2*nn_hls + jj - 2       ! ends at: ipj - 2*nn_hls + nn_hls + 1 - 2 = ipj - nn_hls - 1
-                     !
-                     DO ji = 1, nn_hls            ! first nn_hls points
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
-                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! last nn_hls points
-                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
-                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO
-                  !
-               END DO; END DO
-            END SELECT   ! NAT_IN(jf)
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls              ! last khls points
+                        ii1 = ipi - khls + ji            ! ends at: ipi - khls + khls = ipi
+                        ii2 = ipi - khls - ji            ! ends at: ipi - khls - khls = ipi - 2*khls
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                  END DO   
+                  !
+                  ! line number ipj-khls : right half
+               	  DO jj = 1, 1
+                     ij1 = ipj - khls
+                     ij2 = ij1   ! same line
+                     !
+                     DO ji = 1, Ni0glo/2-1        ! points from ipi/2+1 to ipi - khls-1  (note: Ni0glo = ipi - 2*khls)
+                        ii1 = ipi/2 + ji                 ! ends at: ipi/2 + (ipi/2 - khls) = ipi - khls
+                        ii2 = ipi/2 - ji                 ! ends at: ipi/2 - (ipi/2 - khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     DO ji = 1, khls-1            ! first khls-1 points: redo them just in case (if e-w periodocity already done)
+                        !                         ! as we just changed points ipi-2khls+1 to ipi-nn_hl-1  
+                        ii1 =          ji                ! ends at: khls
+                        ii2 = 2*khls - ji                ! ends at: 2*khls - ( khls - 1 ) = khls + 1
+                        ptab(jf)%pt4d(ii1,ij1,jk,jl) = psgn(jf) * ptab(jf)%pt4d(ii2,ij2,jk,jl)
+                     END DO
+                     !                            ! last khls points: have been / will done by e-w periodicity 
+                  END DO
+                  !
+               END DO; END DO
+            END SELECT   ! cd_nat(jf)
             !
-         CASE ( 5 , 6 )                        ! *  North fold  F-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf)  )
-            CASE ( 'T' , 'W' )                         ! T-, W-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  !
-                  ! first: line number ipj-nn_hls : 3 points
-               	  DO jj = 1, 1
-                     ij1 = ipj - nn_hls
-                     ij2 = ij1   ! same line
-                     !
-                     DO ji = 1, 1            ! points from jpiglo/2+1
-                        ii1 = jpiglo/2 + ji
-                        ii2 = jpiglo/2 - ji + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) =              ARRAY_IN(ii2,ij2,jk,jl,jf)   ! Warning: pb with sign...
-                     END DO
-                     DO ji = 1, 1            ! points jpiglo - nn_hls
-                        ii1 = jpiglo - nn_hls + ji - 1
-                        ii2 =          nn_hls + ji
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) =              ARRAY_IN(ii2,ij2,jk,jl,jf)   ! Warning: pb with sign...
-                     END DO
-                     DO ji = 1, 1            ! point nn_hls: redo it just in case (if e-w periodocity already done)
-                        !                    ! as we just changed point jpiglo - nn_hls
-                        ii1 = nn_hls + ji - 1
-                        ii2 = nn_hls + ji
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) =              ARRAY_IN(ii2,ij2,jk,jl,jf)   ! Warning: pb with sign...
-                     END DO
-                  END DO
-                  !
-                  ! Second: last nn_hls lines (from ipj to ipj-nn_hls+1) : full
-               	  DO jj = 1, nn_hls
-               	     ij1 = ipj + 1        - jj           ! ends at: ipj + 1 - nn_hls
-                     ij2 = ipj - 2*nn_hls + jj           ! ends at: ipj - 2*nn_hls + nn_hls = ipj - nn_hls
-                     !
-                     DO ji = 1, nn_hls            ! first nn_hls points
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
-                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! last nn_hls points
-                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
-                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO
-                  !
-               END DO; END DO
-            CASE ( 'U' )                               ! U-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  !
-                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
-               	  DO jj = 1, nn_hls
-               	     ij1 = ipj + 1        - jj           ! ends at: ipj + 1 - nn_hls
-                     ij2 = ipj - 2*nn_hls + jj           ! ends at: ipj - 2*nn_hls + nn_hls = ipj - nn_hls
-                     !
-                     DO ji = 1, nn_hls-1          ! first nn_hls-1 points
-                        ii1 =            ji              ! ends at: nn_hls-1
-                        ii2 = 2*nn_hls - ji              ! ends at: 2*nn_hls - ( nn_hls - 1 ) = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls
-                        ii1 = nn_hls + ji - 1
-                        ii2 = jpiglo - ii1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+1 to jpiglo - nn_hls - 1  (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 =          nn_hls + ji       ! ends at: nn_hls + ( jpiglo - 2*nn_hls - 1 ) = jpiglo - nn_hls - 1
-                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls
-                        ii1 = jpiglo - nn_hls + ji - 1
-                        ii2 = ii1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! last nn_hls points
-                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
-                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - nn_hls = jpiglo - 2*nn_hls
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO
-                  !
-               END DO; END DO
-            CASE ( 'V' )                               ! V-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  !
-                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
-               	  DO jj = 1, nn_hls
-               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
-                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
-                     !
-                     DO ji = 1, nn_hls            ! first nn_hls points
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo            ! points from nn_hls to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = nn_hls          + ji       ! ends at: nn_hls + jpiglo - 2*nn_hls = jpiglo - nn_hls
-                        ii2 = jpiglo - nn_hls - ji + 1   ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls ) + 1 = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! last nn_hls points
-                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
-                        ii2 = jpiglo - nn_hls + 1 - ji   ! ends at: jpiglo - nn_hls + 1 - nn_hls = jpiglo - 2*nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO   
-                  !
-                  ! line number ipj-nn_hls : right half
-               	  DO jj = 1, 1
-                     ij1 = ipj - nn_hls
-                     ij2 = ij1   ! same line
-                     !
-                     DO ji = 1, Ni0glo/2          ! points from jpiglo/2+1 to jpiglo - nn_hls   (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = jpiglo/2 + ji              ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls) = jpiglo - nn_hls
-                        ii2 = jpiglo/2 - ji + 1          ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls) + 1 = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! first nn_hls points: redo them just in case (if e-w periodocity already done)
-                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hls  
-                        ii1 =                ji          ! ends at: nn_hls
-                        ii2 = 2*nn_hls + 1 - ji          ! ends at: 2*nn_hls + 1 - nn_hls = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     !                            ! last nn_hls points: have been / will done by e-w periodicity 
-                  END DO
-                  !
-               END DO; END DO
-            CASE ( 'F' )                               ! F-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  !
-                  ! last nn_hls lines (from ipj to ipj-nn_hls+1) : full
-               	  DO jj = 1, nn_hls
-               	     ij1 = ipj            - jj + 1       ! ends at: ipj - nn_hls + 1
-                     ij2 = ipj - 2*nn_hls + jj - 1       ! ends at: ipj - 2*nn_hls + nn_hls - 1 = ipj - nn_hls - 1
-                     !
-                     DO ji = 1, nn_hls-1          ! first nn_hls-1 points
-                        ii1 =            ji              ! ends at: nn_hls-1
-                        ii2 = 2*nn_hls - ji              ! ends at: 2*nn_hls - ( nn_hls - 1 ) = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point nn_hls
-                        ii1 = nn_hls + ji - 1
-                        ii2 = jpiglo - ii1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, Ni0glo - 1        ! points from nn_hls+1 to jpiglo - nn_hls - 1  (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 =          nn_hls + ji       ! ends at: nn_hls + ( jpiglo - 2*nn_hls - 1 ) = jpiglo - nn_hls - 1
-                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - ( jpiglo - 2*nn_hls - 1 ) = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, 1                 ! point jpiglo - nn_hls
-                        ii1 = jpiglo - nn_hls + ji - 1
-                        ii2 = ii1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls            ! last nn_hls points
-                        ii1 = jpiglo - nn_hls + ji       ! ends at: jpiglo - nn_hls + nn_hls = jpiglo
-                        ii2 = jpiglo - nn_hls - ji       ! ends at: jpiglo - nn_hls - nn_hls = jpiglo - 2*nn_hls
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                  END DO   
-                  !
-                  ! line number ipj-nn_hls : right half
-               	  DO jj = 1, 1
-                     ij1 = ipj - nn_hls
-                     ij2 = ij1   ! same line
-                     !
-                     DO ji = 1, Ni0glo/2-1        ! points from jpiglo/2+1 to jpiglo - nn_hls-1  (note: Ni0glo = jpiglo - 2*nn_hls)
-                        ii1 = jpiglo/2 + ji              ! ends at: jpiglo/2 + (jpiglo/2 - nn_hls) = jpiglo - nn_hls
-                        ii2 = jpiglo/2 - ji              ! ends at: jpiglo/2 - (jpiglo/2 - nn_hls - 1 ) = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     DO ji = 1, nn_hls-1          ! first nn_hls-1 points: redo them just in case (if e-w periodocity already done)
-                        !                         ! as we just changed points jpiglo-2nn_hls+1 to jpiglo-nn_hl-1  
-                        ii1 =            ji              ! ends at: nn_hls
-                        ii2 = 2*nn_hls - ji              ! ends at: 2*nn_hls - ( nn_hls - 1 ) = nn_hls + 1
-                        ARRAY_IN(ii1,ij1,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ii2,ij2,jk,jl,jf)
-                     END DO
-                     !                            ! last nn_hls points: have been / will done by e-w periodicity 
-                  END DO
-                  !
-               END DO; END DO
-            END SELECT   ! NAT_IN(jf)
-            !
-         END SELECT   ! npolj
+         ENDIF   ! c_NFtype == 'F'
          !
       END DO   ! ipf
       !
-   END SUBROUTINE ROUTINE_NFD
+   END SUBROUTINE lbc_nfd_/**/PRECISION
 
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef ARRAY_IN
-#undef NAT_IN
-#undef SGN_IN
-#undef J_SIZE
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_nogather_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbc_nfd_nogather_generic.h90	(revision 14644)
@@ -1,79 +1,4 @@
-#if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)   
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   if defined DIM_2d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_sp),INTENT(inout)::ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_dp),INTENT(inout)::ptab(f)
-#      endif 
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_sp),INTENT(inout)::ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_dp),INTENT(inout)::ptab(f)
-#      endif 
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_sp),INTENT(inout)::ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_dp),INTENT(inout)::ptab(f)
-#      endif 
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#   if defined SINGLE_PRECISION
-#      define ARRAY2_TYPE(i,j,k,l,f)   TYPE(PTR_4D_sp),INTENT(inout)::ptab2(f)
-#   else
-#      define ARRAY2_TYPE(i,j,k,l,f)   TYPE(PTR_4D_dp),INTENT(inout)::ptab2(f)
-#   endif
-#   define J_SIZE(ptab2)            SIZE(ptab2(1)%pt4d,2)
-#   define ARRAY2_IN(i,j,k,l,f)     ptab2(f)%pt4d(i,j,k,l)
-#else
-!                          !==  IN: ptab is an array  ==!
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define F_SIZE(ptab)             1
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-#   define J_SIZE(ptab2)             SIZE(ptab2,2)
-#   define ARRAY2_IN(i,j,k,l,f)   ptab2(i,j,k,l)
-#   if defined SINGLE_PRECISION
-#      define ARRAY_TYPE(i,j,k,l,f)     REAL(sp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#      define ARRAY2_TYPE(i,j,k,l,f)    REAL(sp),INTENT(inout)::ARRAY2_IN(i,j,k,l,f)
-#   else
-#      define ARRAY_TYPE(i,j,k,l,f)     REAL(dp),INTENT(inout)::ARRAY_IN(i,j,k,l,f)
-#      define ARRAY2_TYPE(i,j,k,l,f)    REAL(dp),INTENT(inout)::ARRAY2_IN(i,j,k,l,f)
-#   endif
-#   endif
-#   ifdef SINGLE_PRECISION
-#      define PRECISION sp
-#   else
-#      define PRECISION dp
-#   endif
-   SUBROUTINE ROUTINE_NFD( ptab, ptab2, cd_nat, psgn, kfld )
+
+   SUBROUTINE lbc_nfd_nogather_/**/PRECISION( ptab, ptab2, cd_nat, psgn, khls )
       !!----------------------------------------------------------------------
       !!
@@ -82,131 +7,119 @@
       !!
       !!----------------------------------------------------------------------
-      ARRAY_TYPE(:,:,:,:,:)
-      ARRAY2_TYPE(:,:,:,:,:) 
-      CHARACTER(len=1) , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)         , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      INTEGER, OPTIONAL, INTENT(in   ) ::   kfld        ! number of pt3d arrays
-      !
-      INTEGER  ::    ji,  jj,   jk, jn, ii,   jl,   jh,  jf   ! dummy loop indices
-      INTEGER  ::   ipi, ipj,  ipk,    ipl,  ipf, iij, ijj   ! dimension of the input array
+      REAL(PRECISION),  DIMENSION(:,:,:,:), INTENT(inout) ::   ptab        ! 
+      REAL(PRECISION),  DIMENSION(:,:,:,:), INTENT(inout) ::   ptab2       ! 
+      CHARACTER(len=1)                    , INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION)                     , INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                             , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      !
+      INTEGER  ::    ji,  jj, jk,  jn,  jl, jh       ! dummy loop indices
+      INTEGER  ::   ipk, ipl, ii, iij, ijj      ! dimension of the input array
       INTEGER  ::   ijt, iju, ijta, ijua, jia, startloop, endloop
       LOGICAL  ::   l_fast_exchanges
       !!----------------------------------------------------------------------
-      ipj = J_SIZE(ptab2)  ! 2nd dimension of input array
-      ipk = K_SIZE(ptab)   ! 3rd dimension of output array
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
-      ! Security check for further developments
-      IF ( ipf > 1 ) CALL ctl_stop( 'STOP', 'lbc_nfd_nogather: multiple fields not allowed. Revise implementation...' )
+      ipk = SIZE(ptab,3)
+      ipl = SIZE(ptab,4)
+      !
       ! 2nd dimension determines exchange speed
-      IF (ipj == 1 ) THEN
-        l_fast_exchanges = .TRUE.
-      ELSE
-        l_fast_exchanges = .FALSE.
-      ENDIF
-      !
-      DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
+      l_fast_exchanges = SIZE(ptab2,2) == 1
+      !
+      IF( c_NFtype == 'T' ) THEN          ! *  North fold  T-point pivot
          !
-         SELECT CASE ( npolj )
-         !
-         CASE ( 3, 4 )                       ! *  North fold  T-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf) )
-            !
-            CASE ( 'T' , 'W' )                         ! T-, W-point
-               IF ( nimpp /= 1 ) THEN  ;  startloop = 1 
-               ELSE                    ;  startloop = 1 + nn_hls
-               ENDIF
-               !
-               DO jl = 1, ipl; DO jk = 1, ipk
-               	  DO jj = 1, nn_hls
-               	     ijj = jpj -jj +1
+         SELECT CASE ( cd_nat )
+            !
+         CASE ( 'T' , 'W' )                         ! T-, W-point
+            IF ( nimpp /= 1 ) THEN  ;  startloop = 1 
+            ELSE                    ;  startloop = 1 + khls
+            ENDIF
+            !
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ji = startloop, jpi
+                     ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
+                     ptab(ji,ijj,jk,jl) = psgn * ptab2(ijt,jj,jk,jl)
+                  END DO
+               END DO
+            END DO; END DO
+            IF( nimpp == 1 ) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 1, khls
+                     ijj = jpj -jj +1
+                     DO ii = 0, khls-1
+                        ptab(ii+1,ijj,jk,jl) = psgn * ptab(2*khls-ii+1,jpj-2*khls+jj-1,jk,jl)
+                     END DO
+                  END DO
+               END DO; END DO
+            ENDIF
+            !
+            IF ( .NOT. l_fast_exchanges ) THEN
+               IF( nimpp >= Ni0glo/2+2 ) THEN
+                  startloop = 1
+               ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
+                  startloop = Ni0glo/2+2 - nimpp + khls
+               ELSE
+                  startloop = jpi + 1
+               ENDIF
+               IF( startloop <= jpi ) THEN
+                  DO jl = 1, ipl; DO jk = 1, ipk
                      DO ji = startloop, jpi
-                    	ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
-                     	ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,jj,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO; END DO
-               IF( nimpp == 1 ) THEN
-                  DO jl = 1, ipl; DO jk = 1, ipk
-                     DO jj = 1, nn_hls
-               	  	ijj = jpj -jj +1
-               	  	DO ii = 0, nn_hls-1
-                  	   ARRAY_IN(ii+1,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(2*nn_hls-ii+1,jpj-2*nn_hls+jj-1,jk,jl,jf)
-                  	END DO
+                        ijt  = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
+                        jia  = ji + nimpp - 1
+                        ijta = jpiglo - jia + 2
+                        IF( ijta >= startloop+nimpp-1 .AND. ijta < jia ) THEN
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab(ijta-nimpp+khls,jpj-khls,jk,jl)
+                        ELSE
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(ijt,khls+1,jk,jl)
+                        ENDIF
                      END DO
                   END DO; END DO
-               ENDIF              
-               !
-               IF ( .NOT. l_fast_exchanges ) THEN
-                  IF( nimpp >= Ni0glo/2+2 ) THEN
-                     startloop = 1
-                  ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
-                     startloop = Ni0glo/2+2 - nimpp + nn_hls
-                  ELSE
-                     startloop = jpi + 1
-                  ENDIF
-                  IF( startloop <= jpi ) THEN
-                     DO jl = 1, ipl; DO jk = 1, ipk
-                        DO ji = startloop, jpi
-                           ijt  = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
-                           jia  = ji + nimpp - 1
-                           ijta = jpiglo - jia + 2
-                           IF( ijta >= startloop+nimpp-1 .AND. ijta < jia ) THEN
-                              ARRAY_IN(ji,jpj-nn_hls,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ijta-nimpp+nn_hls,jpj-nn_hls,jk,jl,jf)
-                           ELSE
-                              ARRAY_IN(ji,jpj-nn_hls,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,nn_hls+1,jk,jl,jf)
-                           ENDIF
-                        END DO
-                     END DO; END DO
-                  ENDIF
-               ENDIF
-            CASE ( 'U' )                                     ! U-point
+               ENDIF
+            ENDIF
+         CASE ( 'U' )                                     ! U-point
+            IF( nimpp + jpi - 1 /= jpiglo ) THEN
+               endloop = jpi
+            ELSE
+               endloop = jpi - khls
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
+                     ptab(ji,ijj,jk,jl) = psgn * ptab2(iju,jj,jk,jl)
+                  END DO
+               END DO
+            END DO; END DO
+            IF (nimpp .eq. 1) THEN
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ii = 0, khls-1
+                     ptab(ii+1,ijj,:,:) = psgn * ptab(2*khls-ii,jpj-2*khls+jj-1,:,:)
+                  END DO
+               END DO
+            ENDIF
+            IF((nimpp + jpi - 1) .eq. jpiglo) THEN
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ii = 1, khls
+                     ptab(jpi-ii+1,ijj,:,:) = psgn * ptab(jpi-2*khls+ii,jpj-2*khls+jj-1,:,:)
+                  END DO
+               END DO
+            ENDIF
+            !
+            IF ( .NOT. l_fast_exchanges ) THEN
                IF( nimpp + jpi - 1 /= jpiglo ) THEN
                   endloop = jpi
                ELSE
-                  endloop = jpi - nn_hls
-               ENDIF
-               DO jl = 1, ipl; DO jk = 1, ipk
-		  DO jj = 1, nn_hls
-        	     ijj = jpj -jj +1
-                     DO ji = 1, endloop
-                        iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                        ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,jj,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO; END DO
-               IF (nimpp .eq. 1) THEN
-		  DO jj = 1, nn_hls
-		     ijj = jpj -jj +1
-		     DO ii = 0, nn_hls-1
-		 	ARRAY_IN(ii+1,ijj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2*nn_hls-ii,jpj-2*nn_hls+jj-1,:,:,jf)
-		     END DO
-                  END DO
-               ENDIF
-               IF((nimpp + jpi - 1) .eq. jpiglo) THEN
-                  DO jj = 1, nn_hls
-               	     ijj = jpj -jj +1
-			DO ii = 1, nn_hls
-		   	   ARRAY_IN(jpi-ii+1,ijj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(jpi-2*nn_hls+ii,jpj-2*nn_hls+jj-1,:,:,jf)
-			END DO
-		  END DO
-               ENDIF
-               !
-               IF ( .NOT. l_fast_exchanges ) THEN
-                  IF( nimpp + jpi - 1 /= jpiglo ) THEN
-                     endloop = jpi
-                  ELSE
-                     endloop = jpi - nn_hls
-                  ENDIF
-                  IF( nimpp >= Ni0glo/2+1 ) THEN
-                     startloop = nn_hls
-                  ELSEIF( ( nimpp + jpi - 1 >= Ni0glo/2+1 ) .AND. ( nimpp < Ni0glo/2+1 ) ) THEN
-                     startloop = Ni0glo/2+1 - nimpp + nn_hls 
-                  ELSE
-                     startloop = endloop + 1
-                  ENDIF
-                  IF( startloop <= endloop ) THEN
+                  endloop = jpi - khls
+               ENDIF
+               IF( nimpp >= Ni0glo/2+1 ) THEN
+                  startloop = khls
+               ELSEIF( ( nimpp + jpi - 1 >= Ni0glo/2+1 ) .AND. ( nimpp < Ni0glo/2+1 ) ) THEN
+                  startloop = Ni0glo/2+1 - nimpp + khls 
+               ELSE
+                  startloop = endloop + 1
+               ENDIF
+               IF( startloop <= endloop ) THEN
                   DO jl = 1, ipl; DO jk = 1, ipk
                      DO ji = startloop, endloop
@@ -215,235 +128,222 @@
                         ijua = jpiglo - jia + 1 
                         IF( ijua >= startloop+nimpp-1 .AND. ijua < jia ) THEN
-                           ARRAY_IN(ji,jpj-nn_hls,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(ijua-nimpp+1,jpj-nn_hls,jk,jl,jf)
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab(ijua-nimpp+1,jpj-khls,jk,jl)
                         ELSE
-                           ARRAY_IN(ji,jpj-nn_hls,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,nn_hls+1,jk,jl,jf)
+                           ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(iju,khls+1,jk,jl)
                         ENDIF
                      END DO
                   END DO; END DO
-                  ENDIF
-               ENDIF
-               !
-            CASE ( 'V' )                                     ! V-point
-               IF( nimpp /= 1 ) THEN
-                 startloop = 1 
-               ELSE
-                 startloop = 1 + nn_hls
-               ENDIF
+               ENDIF
+            ENDIF
+            !
+         CASE ( 'V' )                                     ! V-point
+            IF( nimpp /= 1 ) THEN
+               startloop = 1 
+            ELSE
+               startloop = 1 + khls
+            ENDIF
+            IF ( .NOT. l_fast_exchanges ) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 2, khls+1
+                     ijj = jpj -jj +1
+                     DO ji = startloop, jpi
+                        ijt=jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
+                        ptab(ji,ijj,jk,jl) = psgn * ptab2(ijt,jj,jk,jl)
+                     END DO
+                  END DO
+               END DO; END DO
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO ji = startloop, jpi
+                  ijt=jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
+                  ptab(ji,jpj,jk,jl) = psgn * ptab2(ijt,1,jk,jl)
+               END DO
+            END DO; END DO
+            IF (nimpp .eq. 1) THEN
+               DO jj = 1, khls
+                  ijj = jpj-jj+1
+                  DO ii = 0, khls-1
+                     ptab(ii+1,ijj,:,:) = psgn * ptab(2*khls-ii+1,jpj-2*khls+jj-1,:,:)
+                  END DO
+               END DO
+            ENDIF
+         CASE ( 'F' )                                     ! F-point
+            IF( nimpp + jpi - 1 /= jpiglo ) THEN
+               endloop = jpi
+            ELSE
+               endloop = jpi - khls
+            ENDIF
+            IF ( .NOT. l_fast_exchanges ) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 2, khls+1
+                     ijj = jpj -jj +1
+                     DO ji = 1, endloop
+                        iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
+                        ptab(ji,ijj,jk,jl) = psgn * ptab2(iju,jj,jk,jl)
+                     END DO
+                  END DO
+               END DO; END DO
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO ji = 1, endloop
+                  iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
+                  ptab(ji,jpj,jk,jl) = psgn * ptab2(iju,1,jk,jl)
+               END DO
+            END DO; END DO
+            IF (nimpp .eq. 1) THEN               
+               DO ii = 1, khls
+                  ptab(ii,jpj,:,:) = psgn * ptab(2*khls-ii,jpj-2*khls-1,:,:)
+               END DO
                IF ( .NOT. l_fast_exchanges ) THEN
+                  DO jj = 1, khls
+                     ijj = jpj -jj
+                     DO ii = 0, khls-1
+                        ptab(ii+1,ijj,:,:) = psgn * ptab(2*khls-ii,jpj-2*khls+jj-1,:,:)
+                     END DO
+                  END DO
+               ENDIF
+            ENDIF
+            IF((nimpp + jpi - 1 ) .eq. jpiglo) THEN
+               DO ii = 1, khls
+                  ptab(jpi-ii+1,jpj,:,:) = psgn * ptab(jpi-2*khls+ii,jpj-2*khls-1,:,:)
+               END DO
+               IF ( .NOT. l_fast_exchanges ) THEN
+                  DO jj = 1, khls
+                     ijj = jpj -jj
+                     DO ii = 1, khls
+                        ptab(jpi-ii+1,ijj,:,:) = psgn * ptab(jpi-2*khls+ii,jpj-2*khls+jj-1,:,:)
+                     END DO
+                  END DO
+               ENDIF
+            ENDIF
+            !
+         END SELECT
+         !
+      ENDIF   ! c_NFtype == 'T'
+      !
+      IF( c_NFtype == 'F' ) THEN           ! *  North fold  F-point pivot
+         !
+         SELECT CASE ( cd_nat )
+         CASE ( 'T' , 'W' )                               ! T-, W-point
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
+                  ijj = jpj-jj+1
+                  DO ji = 1, jpi
+                     ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
+                     ptab(ji,ijj,jk,jl) = psgn * ptab2(ijt,jj,jk,jl)
+                  END DO
+               END DO
+            END DO; END DO
+            !
+         CASE ( 'U' )                                     ! U-point
+            IF( nimpp + jpi - 1 /= jpiglo ) THEN
+               endloop = jpi
+            ELSE
+               endloop = jpi - khls
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
+                  ijj = jpj-jj+1
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
+                     ptab(ji,ijj,jk,jl) = psgn * ptab2(iju,jj,jk,jl)
+                  END DO
+               END DO
+            END DO; END DO
+            IF(nimpp + jpi - 1 .eq. jpiglo) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 1, khls
+                     ijj = jpj-jj+1
+                     DO ii = 1, khls
+                        iij = jpi-ii+1
+                        ptab(iij,ijj,jk,jl) = psgn * ptab(jpi-2*khls+ii-1,jpj-2*khls+jj,jk,jl)
+                     END DO
+                  END DO
+               END DO; END DO
+            ENDIF
+            !
+         CASE ( 'V' )                                     ! V-point
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ji = 1, jpi
+                     ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
+                     ptab(ji,ijj,jk,jl) = psgn * ptab2(ijt,jj,jk,jl)
+                  END DO
+               END DO
+            END DO; END DO
+
+            IF ( .NOT. l_fast_exchanges ) THEN
+               IF( nimpp >= Ni0glo/2+2 ) THEN
+                  startloop = 1
+               ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
+                  startloop = Ni0glo/2+2 - nimpp + khls
+               ELSE
+                  startloop = jpi + 1
+               ENDIF
+               IF( startloop <= jpi ) THEN
                   DO jl = 1, ipl; DO jk = 1, ipk
-               	     DO jj = 2, nn_hls+1
-               	  	ijj = jpj -jj +1
-                     	DO ji = startloop, jpi
-                           ijt=jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
-                           ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,jj,jk,jl,jf)
-                     	END DO
-                    END DO
+                     DO ji = startloop, jpi
+                        ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
+                        ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(ijt,khls+1,jk,jl)
+                     END DO
                   END DO; END DO
                ENDIF
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  DO ji = startloop, jpi
-                     ijt=jpiglo - ji - nimpp - nfimpp(isendto(1)) + 4
-                     ARRAY_IN(ji,jpj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,1,jk,jl,jf)
-                  END DO
-               END DO; END DO
-               IF (nimpp .eq. 1) THEN
-		  DO jj = 1, nn_hls
-               	     ijj = jpj-jj+1
-               	     DO ii = 0, nn_hls-1
-                        ARRAY_IN(ii+1,ijj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2*nn_hls-ii+1,jpj-2*nn_hls+jj-1,:,:,jf)
-		     END DO
-		  END DO
-               ENDIF
-            CASE ( 'F' )                                     ! F-point
+            ENDIF
+            !
+         CASE ( 'F' )                               ! F-point
+            IF( nimpp + jpi - 1 /= jpiglo ) THEN
+               endloop = jpi
+            ELSE
+               endloop = jpi - khls
+            ENDIF
+            DO jl = 1, ipl; DO jk = 1, ipk
+               DO jj = 1, khls
+                  ijj = jpj -jj +1
+                  DO ji = 1, endloop
+                     iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
+                     ptab(ji,ijj ,jk,jl) = psgn * ptab2(iju,jj,jk,jl)
+                  END DO
+               END DO
+            END DO; END DO
+            IF((nimpp + jpi - 1) .eq. jpiglo) THEN
+               DO jl = 1, ipl; DO jk = 1, ipk
+                  DO jj = 1, khls
+                     ijj = jpj -jj +1
+                     DO ii = 1, khls
+                        iij = jpi -ii+1
+                        ptab(iij,ijj,jk,jl) = psgn * ptab(jpi-2*khls+ii-1,jpj-2*khls+jj-1,jk,jl)
+                     END DO
+                  END DO
+               END DO; END DO
+            ENDIF
+            !
+            IF ( .NOT. l_fast_exchanges ) THEN
                IF( nimpp + jpi - 1 /= jpiglo ) THEN
                   endloop = jpi
                ELSE
-                  endloop = jpi - nn_hls
-               ENDIF
-               IF ( .NOT. l_fast_exchanges ) THEN
+                  endloop = jpi - khls
+               ENDIF
+               IF( nimpp >= Ni0glo/2+2 ) THEN
+                  startloop = 1 
+               ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
+                  startloop = Ni0glo/2+2 - nimpp + khls
+               ELSE
+                  startloop = endloop + 1
+               ENDIF
+               IF( startloop <= endloop ) THEN
                   DO jl = 1, ipl; DO jk = 1, ipk
-               	     DO jj = 2, nn_hls+1
-               	  	ijj = jpj -jj +1
-                     	DO ji = 1, endloop
-                           iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                           ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,jj,jk,jl,jf)
-                     	END DO
-                    END DO
+                     DO ji = startloop, endloop
+                        iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
+                        ptab(ji,jpj-khls,jk,jl) = psgn * ptab2(iju,khls+1,jk,jl)
+                     END DO
                   END DO; END DO
                ENDIF
-               DO jl = 1, ipl; DO jk = 1, ipk
-                  DO ji = 1, endloop
-                     iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                     ARRAY_IN(ji,jpj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,1,jk,jl,jf)
-                  END DO
-               END DO; END DO
-		IF (nimpp .eq. 1) THEN               
-		   DO ii = 1, nn_hls
-	              ARRAY_IN(ii,jpj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2*nn_hls-ii,jpj-2*nn_hls-1,:,:,jf)
-		   END DO
-		   IF ( .NOT. l_fast_exchanges ) THEN
-		      DO jj = 1, nn_hls
-               	 	 ijj = jpj -jj
-               		 DO ii = 0, nn_hls-1
-                    	    ARRAY_IN(ii+1,ijj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(2*nn_hls-ii,jpj-2*nn_hls+jj-1,:,:,jf)
-                 	 END DO
-                      END DO
-               	   ENDIF
-		ENDIF
-		IF((nimpp + jpi - 1 ) .eq. jpiglo) THEN
-                   DO ii = 1, nn_hls
-	              ARRAY_IN(jpi-ii+1,jpj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(jpi-2*nn_hls+ii,jpj-2*nn_hls-1,:,:,jf)
-		   END DO
-		   IF ( .NOT. l_fast_exchanges ) THEN
-		      DO jj = 1, nn_hls
-               	         ijj = jpj -jj
-	               	 DO ii = 1, nn_hls
-                    	    ARRAY_IN(jpi-ii+1,ijj,:,:,jf) = SGN_IN(jf) * ARRAY_IN(jpi-2*nn_hls+ii,jpj-2*nn_hls+jj-1,:,:,jf)
-                     	 END DO
-                      END DO
-               	   ENDIF
-               	ENDIF
-               	!
-	    END SELECT
-            !
-         CASE ( 5, 6 )                        ! *  North fold  F-point pivot
-            !
-            SELECT CASE ( NAT_IN(jf) )
-            CASE ( 'T' , 'W' )                               ! T-, W-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-		  DO jj = 1, nn_hls
- 		     ijj = jpj-jj+1
-		     DO ji = 1, jpi
-                     	ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                     	ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,jj,jk,jl,jf)
-                     END DO
-		  END DO
-               END DO; END DO
-               !
-            CASE ( 'U' )                                     ! U-point
-               IF( nimpp + jpi - 1 /= jpiglo ) THEN
-                  endloop = jpi
-               ELSE
-                  endloop = jpi - nn_hls
-               ENDIF
-               DO jl = 1, ipl; DO jk = 1, ipk
-		  DO jj = 1, nn_hls
- 		     ijj = jpj-jj+1
-                     DO ji = 1, endloop
-                        iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
-                        ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,jj,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO; END DO
-               IF(nimpp + jpi - 1 .eq. jpiglo) THEN
-                  DO jl = 1, ipl; DO jk = 1, ipk
-                     DO jj = 1, nn_hls
-               	        ijj = jpj-jj+1
-                        DO ii = 1, nn_hls
-			   iij = jpi-ii+1
-                           ARRAY_IN(iij,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(jpi-2*nn_hls+ii-1,jpj-2*nn_hls+jj,jk,jl,jf)
-                        END DO
-                     END DO
-                  END DO; END DO
-               ENDIF
-               !
-            CASE ( 'V' )                                     ! V-point
-               DO jl = 1, ipl; DO jk = 1, ipk
-		  DO jj = 1, nn_hls
-		     ijj = jpj -jj +1
-                     DO ji = 1, jpi
-                        ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                        ARRAY_IN(ji,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,jj,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO; END DO
+            ENDIF
+            !
+         END SELECT
+         !
+      ENDIF   ! c_NFtype == 'F'
+      !
+   END SUBROUTINE lbc_nfd_nogather_/**/PRECISION
 
-               IF ( .NOT. l_fast_exchanges ) THEN
-                  IF( nimpp >= Ni0glo/2+2 ) THEN
-                     startloop = 1
-                  ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
-                     startloop = Ni0glo/2+2 - nimpp + nn_hls
-                  ELSE
-                     startloop = jpi + 1
-                  ENDIF
-                  IF( startloop <= jpi ) THEN
-                  DO jl = 1, ipl; DO jk = 1, ipk
-                        DO ji = startloop, jpi
-                   	   ijt = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 3
-                           ARRAY_IN(ji,jpj-nn_hls,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(ijt,nn_hls+1,jk,jl,jf)
-                        END DO
-                  END DO; END DO
-                  ENDIF
-               ENDIF
-               !
-            CASE ( 'F' )                               ! F-point
-               IF( nimpp + jpi - 1 /= jpiglo ) THEN
-                  endloop = jpi
-               ELSE
-                  endloop = jpi - nn_hls
-               ENDIF
-               DO jl = 1, ipl; DO jk = 1, ipk
-		  DO jj = 1, nn_hls
-		    ijj = jpj -jj +1
-                    DO ji = 1, endloop
-                       iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
-                       ARRAY_IN(ji,ijj ,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,jj,jk,jl,jf)
-                     END DO
-                  END DO
-               END DO; END DO
-               IF((nimpp + jpi - 1) .eq. jpiglo) THEN
-                  DO jl = 1, ipl; DO jk = 1, ipk
-                     DO jj = 1, nn_hls
-                        ijj = jpj -jj +1
-                        DO ii = 1, nn_hls
-			   iij = jpi -ii+1
-                     	   ARRAY_IN(iij,ijj,jk,jl,jf) = SGN_IN(jf) * ARRAY_IN(jpi-2*nn_hls+ii-1,jpj-2*nn_hls+jj-1,jk,jl,jf)
-                        END DO
-                     END DO
-                  END DO; END DO
-               ENDIF
-               !
-               IF ( .NOT. l_fast_exchanges ) THEN
-                  IF( nimpp + jpi - 1 /= jpiglo ) THEN
-                     endloop = jpi
-                  ELSE
-                     endloop = jpi - nn_hls
-                  ENDIF
-                  IF( nimpp >= Ni0glo/2+2 ) THEN
-                     startloop = 1 
-                  ELSEIF( nimpp+jpi-1 >= Ni0glo/2+2 .AND. nimpp < Ni0glo/2+2 ) THEN
-                     startloop = Ni0glo/2+2 - nimpp + nn_hls
-                  ELSE
-                     startloop = endloop + 1
-                  ENDIF
-                  IF( startloop <= endloop ) THEN
-                     DO jl = 1, ipl; DO jk = 1, ipk
-                        DO ji = startloop, endloop
-                           iju = jpiglo - ji - nimpp - nfimpp(isendto(1)) + 2
-                           ARRAY_IN(ji,jpj-nn_hls,jk,jl,jf) = SGN_IN(jf) * ARRAY2_IN(iju,nn_hls+1,jk,jl,jf)
-                        END DO
-                     END DO; END DO
-                  ENDIF
-               ENDIF
-               !
-            END SELECT
-            !
-         CASE DEFAULT                           ! *  closed : the code probably never go through
-            !
-            WRITE(*,*) 'lbc_nfd_nogather_generic: You should not have seen this print! error?', npolj
-            !
-         END SELECT     !  npolj
-         !
-      END DO            ! End jf loop
-   END SUBROUTINE ROUTINE_NFD
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef ARRAY_IN
-#undef NAT_IN
-#undef SGN_IN
-#undef J_SIZE
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef ARRAY2_TYPE
-#undef ARRAY2_IN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbclnk.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbclnk.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbclnk.F90	(revision 14644)
@@ -23,4 +23,7 @@
    USE lbcnfd         ! north fold
    USE in_out_manager ! I/O manager
+#if ! defined key_mpi_off
+   USE MPI
+#endif
 
    IMPLICIT NONE
@@ -28,22 +31,14 @@
 
    INTERFACE lbc_lnk
-      MODULE PROCEDURE   mpp_lnk_2d_sp   , mpp_lnk_3d_sp   , mpp_lnk_4d_sp
-      MODULE PROCEDURE   mpp_lnk_2d_dp   , mpp_lnk_3d_dp   , mpp_lnk_4d_dp
-   END INTERFACE
-   INTERFACE lbc_lnk_ptr
-      MODULE PROCEDURE   mpp_lnk_2d_ptr_sp , mpp_lnk_3d_ptr_sp , mpp_lnk_4d_ptr_sp
-      MODULE PROCEDURE   mpp_lnk_2d_ptr_dp , mpp_lnk_3d_ptr_dp , mpp_lnk_4d_ptr_dp
-   END INTERFACE
-   INTERFACE lbc_lnk_multi
-      MODULE PROCEDURE   lbc_lnk_2d_multi_sp , lbc_lnk_3d_multi_sp, lbc_lnk_4d_multi_sp
-      MODULE PROCEDURE   lbc_lnk_2d_multi_dp , lbc_lnk_3d_multi_dp, lbc_lnk_4d_multi_dp
-   END INTERFACE
-   INTERFACE lbc_lnk_nc_multi
-      MODULE PROCEDURE   lbc_lnk_nc_2d_sp, lbc_lnk_nc_3d_sp, lbc_lnk_nc_4d_sp
-      MODULE PROCEDURE   lbc_lnk_nc_2d_dp, lbc_lnk_nc_3d_dp, lbc_lnk_nc_4d_dp
-   END INTERFACE
-   INTERFACE lbc_lnk_nc
-      MODULE PROCEDURE   mpp_lnk_nc_2d_sp, mpp_lnk_nc_3d_sp, mpp_lnk_nc_4d_sp
-      MODULE PROCEDURE   mpp_lnk_nc_2d_dp, mpp_lnk_nc_3d_dp, mpp_lnk_nc_4d_dp
+      MODULE PROCEDURE   lbc_lnk_call_2d_sp, lbc_lnk_call_3d_sp, lbc_lnk_call_4d_sp
+      MODULE PROCEDURE   lbc_lnk_call_2d_dp, lbc_lnk_call_3d_dp, lbc_lnk_call_4d_dp
+   END INTERFACE
+
+   INTERFACE lbc_lnk_pt2pt
+      MODULE PROCEDURE   lbc_lnk_pt2pt_sp, lbc_lnk_pt2pt_dp
+   END INTERFACE
+
+   INTERFACE lbc_lnk_neicoll
+      MODULE PROCEDURE   lbc_lnk_neicoll_sp ,lbc_lnk_neicoll_dp
    END INTERFACE
    !
@@ -52,32 +47,13 @@
    END INTERFACE
 
-   INTERFACE mpp_nfd
-      MODULE PROCEDURE   mpp_nfd_2d_sp    , mpp_nfd_3d_sp    , mpp_nfd_4d_sp
-      MODULE PROCEDURE   mpp_nfd_2d_dp    , mpp_nfd_3d_dp    , mpp_nfd_4d_dp
-      MODULE PROCEDURE   mpp_nfd_2d_ptr_sp, mpp_nfd_3d_ptr_sp, mpp_nfd_4d_ptr_sp
-      MODULE PROCEDURE   mpp_nfd_2d_ptr_dp, mpp_nfd_3d_ptr_dp, mpp_nfd_4d_ptr_dp
-
-   END INTERFACE
-
    PUBLIC   lbc_lnk            ! ocean/ice lateral boundary conditions
-   PUBLIC   lbc_lnk_multi      ! modified ocean/ice lateral boundary conditions
    PUBLIC   lbc_lnk_icb        ! iceberg lateral boundary conditions
-   PUBLIC   lbc_lnk_nc         ! ocean/ice lateral boundary conditions (MPI3 version)
-   PUBLIC   lbc_lnk_nc_multi   ! modified ocean/ice lateral boundary conditions (MPI3 version)
-
-#if   defined key_mpp_mpi
-!$AGRIF_DO_NOT_TREAT
-   INCLUDE 'mpif.h'
-!$AGRIF_END_DO_NOT_TREAT
-#endif
-
-   INTEGER, PUBLIC, PARAMETER ::   jpfillnothing = 1
-   INTEGER, PUBLIC, PARAMETER ::   jpfillcst     = 2
-   INTEGER, PUBLIC, PARAMETER ::   jpfillcopy    = 3
-   INTEGER, PUBLIC, PARAMETER ::   jpfillperio   = 4
-   INTEGER, PUBLIC, PARAMETER ::   jpfillmpi     = 5
-
+
+   REAL(dp), DIMENSION(:), ALLOCATABLE ::   buffsnd_dp, buffrcv_dp   ! MPI send/recv buffers
+   REAL(sp), DIMENSION(:), ALLOCATABLE ::   buffsnd_sp, buffrcv_sp   ! 
+   INTEGER,  DIMENSION(8)              ::   nreq_p2p                 ! request id for MPI_Isend in point-2-point communication
+   
    !! * Substitutions
-#  include "do_loop_substitute.h90"
+   !!#  include "do_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -88,8 +64,9 @@
 
    !!----------------------------------------------------------------------
-   !!                   ***   load_ptr_(2,3,4)d   ***
+   !!                   ***   lbc_lnk_call_[234]d_[sd]p   ***
    !!
    !!   * Dummy Argument :
-   !!       in    ==>   ptab       ! array to be loaded (2D, 3D or 4D)
+   !!       in    ==>   cdname     ! name of the calling subroutine (for monitoring)
+   !!                   ptab       ! array to be loaded (2D, 3D or 4D)
    !!                   cd_nat     ! nature of pt2d array grid-points
    !!                   psgn       ! sign used across the north fold boundary
@@ -99,406 +76,79 @@
    !!                   kfld       ! number of elements that has been attributed
    !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!                  ***   lbc_lnk_(2,3,4)d_multi   ***
-   !!                     ***   load_ptr_(2,3,4)d   ***
-   !!
-   !!   * Argument : dummy argument use in lbc_lnk_multi_... routines
-   !!
-   !!----------------------------------------------------------------------
-
+   !
+   !!----------------------------------------------------------------------
+   !!
+   !!                  ***   lbc_lnk_call_[234]d_[sd]p   ***
+   !!                  ***     load_ptr_[234]d_[sd]p     ***
+   !!
+   !!----------------------------------------------------------------------
    !!
    !!   ----   SINGLE PRECISION VERSIONS
    !!
-#  define SINGLE_PRECISION
-#  define DIM_2d
-#     define ROUTINE_LOAD           load_ptr_2d_sp
-#     define ROUTINE_MULTI          lbc_lnk_2d_multi_sp
-#     include "lbc_lnk_multi_generic.h90"
-#     undef ROUTINE_MULTI
-#     undef ROUTINE_LOAD
-#  undef DIM_2d
-
-#  define DIM_3d
-#     define ROUTINE_LOAD           load_ptr_3d_sp
-#     define ROUTINE_MULTI          lbc_lnk_3d_multi_sp
-#     include "lbc_lnk_multi_generic.h90"
-#     undef ROUTINE_MULTI
-#     undef ROUTINE_LOAD
-#  undef DIM_3d
-
-#  define DIM_4d
-#     define ROUTINE_LOAD           load_ptr_4d_sp
-#     define ROUTINE_MULTI          lbc_lnk_4d_multi_sp
-#     include "lbc_lnk_multi_generic.h90"
-#     undef ROUTINE_MULTI
-#     undef ROUTINE_LOAD
-#  undef DIM_4d
-#  undef SINGLE_PRECISION
+#define PRECISION sp
+# define DIM_2d
+#    include "lbc_lnk_call_generic.h90"
+# undef  DIM_2d
+# define DIM_3d
+#    include "lbc_lnk_call_generic.h90"
+# undef  DIM_3d
+# define DIM_4d
+#    include "lbc_lnk_call_generic.h90"
+# undef  DIM_4d
+#undef PRECISION
    !!
    !!   ----   DOUBLE PRECISION VERSIONS
    !!
-
-#  define DIM_2d
-#     define ROUTINE_LOAD           load_ptr_2d_dp
-#     define ROUTINE_MULTI          lbc_lnk_2d_multi_dp
-#     include "lbc_lnk_multi_generic.h90"
-#     undef ROUTINE_MULTI
-#     undef ROUTINE_LOAD
-#  undef DIM_2d
-
-#  define DIM_3d
-#     define ROUTINE_LOAD           load_ptr_3d_dp
-#     define ROUTINE_MULTI          lbc_lnk_3d_multi_dp
-#     include "lbc_lnk_multi_generic.h90"
-#     undef ROUTINE_MULTI
-#     undef ROUTINE_LOAD
-#  undef DIM_3d
-
-#  define DIM_4d
-#     define ROUTINE_LOAD           load_ptr_4d_dp
-#     define ROUTINE_MULTI          lbc_lnk_4d_multi_dp
-#     include "lbc_lnk_multi_generic.h90"
-#     undef ROUTINE_MULTI
-#     undef ROUTINE_LOAD
-#  undef DIM_4d
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine mpp_lnk_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in mpp_lnk_... routines
-   !!                ptab      :   array or pointer of arrays on which the boundary condition is applied
+#define PRECISION dp
+# define DIM_2d
+#    include "lbc_lnk_call_generic.h90"
+# undef  DIM_2d
+# define DIM_3d
+#    include "lbc_lnk_call_generic.h90"
+# undef  DIM_3d
+# define DIM_4d
+#    include "lbc_lnk_call_generic.h90"
+# undef  DIM_4d
+#undef PRECISION
+   !
+   !!----------------------------------------------------------------------
+   !!                   ***  lbc_lnk_pt2pt_[sd]p  ***
+   !!                  ***  lbc_lnk_neicoll_[sd]p  ***
+   !!
+   !!   * Argument : dummy argument use in lbc_lnk_... routines
+   !!                cdname    :   name of the calling subroutine (for monitoring)
+   !!                ptab      :   pointer of arrays on which the boundary condition is applied
    !!                cd_nat    :   nature of array grid-points
    !!                psgn      :   sign used across the north fold boundary
-   !!                kfld      :   optional, number of pt3d arrays
+   !!                kfld      :   number of pt3d arrays
    !!                kfillmode :   optional, method to be use to fill the halos (see jpfill* variables)
    !!                pfillval  :   optional, background value (used with jpfillcopy)
    !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
    !!
    !!   ----   SINGLE PRECISION VERSIONS
    !!
-# define SINGLE_PRECISION
-#  define DIM_2d
-#     define ROUTINE_LNK           mpp_lnk_2d_sp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_2d_ptr_sp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_LNK           mpp_lnk_3d_sp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_3d_ptr_sp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_LNK           mpp_lnk_4d_sp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_4d_ptr_sp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_4d
-# undef SINGLE_PRECISION
-
+#define PRECISION sp
+#  define MPI_TYPE MPI_REAL
+#  define BUFFSND buffsnd_sp
+#  define BUFFRCV buffrcv_sp
+#  include "lbc_lnk_pt2pt_generic.h90"
+#  include "lbc_lnk_neicoll_generic.h90"
+#  undef MPI_TYPE
+#  undef BUFFSND
+#  undef BUFFRCV
+#undef PRECISION
    !!
    !!   ----   DOUBLE PRECISION VERSIONS
    !!
-#  define DIM_2d
-#     define ROUTINE_LNK           mpp_lnk_2d_dp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_2d_ptr_dp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_LNK           mpp_lnk_3d_dp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_3d_ptr_dp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_LNK           mpp_lnk_4d_dp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     define MULTI
-#     define ROUTINE_LNK           mpp_lnk_4d_ptr_dp
-#     include "mpp_lnk_generic.h90"
-#     undef ROUTINE_LNK
-#     undef MULTI
-#  undef DIM_4d
-
-   !!----------------------------------------------------------------------
-   !!                   ***   load_ptr_(2,3,4)d   ***
-   !!
-   !!   * Dummy Argument :
-   !!       in    ==>   ptab       ! array to be loaded (2D, 3D or 4D)
-   !!                   cd_nat     ! nature of pt2d array grid-points
-   !!                   psgn       ! sign used across the north fold boundary
-   !!       inout <=>   ptab_ptr   ! array of 2D, 3D or 4D pointers
-   !!                   cdna_ptr   ! nature of ptab array grid-points
-   !!                   psgn_ptr   ! sign used across the north fold boundary
-   !!                   kfld       ! number of elements that has been attributed
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!                  ***   lbc_lnk_nc(2,3,4)d_multi   ***
-   !!                     ***   load_ptr_(2,3,4)d   ***
-   !!
-   !!   * Argument : dummy argument use in lbc_lnk_nc_multi_... routines
-   !!
-   !!----------------------------------------------------------------------
-
-   !!
-   !!   ----   SINGLE PRECISION VERSIONS
-   !!
-#  define SINGLE_PRECISION
-#  define DIM_2d
-#     define ROUTINE_NC_LOAD           load_ptr_nc_2d_sp
-#     define ROUTINE_MULTI_NC          lbc_lnk_nc_2d_sp
-#     include "lbc_lnk_nc_generic.h90"
-#     undef ROUTINE_MULTI_NC
-#     undef ROUTINE_NC_LOAD
-#  undef DIM_2d
-
-#  define DIM_3d
-#     define ROUTINE_NC_LOAD           load_ptr_nc_3d_sp
-#     define ROUTINE_MULTI_NC          lbc_lnk_nc_3d_sp
-#     include "lbc_lnk_nc_generic.h90"
-#     undef ROUTINE_MULTI_NC
-#     undef ROUTINE_NC_LOAD
-#  undef DIM_3d
-
-#  define DIM_4d
-#     define ROUTINE_NC_LOAD           load_ptr_nc_4d_sp
-#     define ROUTINE_MULTI_NC          lbc_lnk_nc_4d_sp
-#     include "lbc_lnk_nc_generic.h90"
-#     undef ROUTINE_MULTI_NC
-#     undef ROUTINE_NC_LOAD
-#  undef DIM_4d
-#  undef SINGLE_PRECISION
-   !!
-   !!   ----   DOUBLE PRECISION VERSIONS
-   !!
-
-#  define DIM_2d
-#     define ROUTINE_NC_LOAD           load_ptr_nc_2d_dp
-#     define ROUTINE_MULTI_NC          lbc_lnk_nc_2d_dp
-#     include "lbc_lnk_nc_generic.h90"
-#     undef ROUTINE_MULTI_NC
-#     undef ROUTINE_NC_LOAD
-#  undef DIM_2d
-
-#  define DIM_3d
-#     define ROUTINE_NC_LOAD           load_ptr_nc_3d_dp
-#     define ROUTINE_MULTI_NC          lbc_lnk_nc_3d_dp
-#     include "lbc_lnk_nc_generic.h90"
-#     undef ROUTINE_MULTI_NC
-#     undef ROUTINE_NC_LOAD
-#  undef DIM_3d
-
-#  define DIM_4d
-#     define ROUTINE_NC_LOAD           load_ptr_nc_4d_dp
-#     define ROUTINE_MULTI_NC          lbc_lnk_nc_4d_dp
-#     include "lbc_lnk_nc_generic.h90"
-#     undef ROUTINE_MULTI_NC
-#     undef ROUTINE_NC_LOAD
-#  undef DIM_4d
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine mpp_lnk_nc_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in mpp_lnk_... routines
-   !!                ptab      :   array or pointer of arrays on which the boundary condition is applied
-   !!                cd_nat    :   nature of array grid-points
-   !!                psgn      :   sign used across the north fold boundary
-   !!                kfld      :   optional, number of pt3d arrays
-   !!                kfillmode :   optional, method to be use to fill the halos (see jpfill* variables)
-   !!                pfillval  :   optional, background value (used with jpfillcopy)
-   !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-   !!
-   !!   ----   SINGLE PRECISION VERSIONS
-   !!
-# define SINGLE_PRECISION
-#  define DIM_2d
-#     define ROUTINE_NC           mpp_lnk_nc_2d_sp
-#     include "mpp_nc_generic.h90"
-#     undef ROUTINE_NC
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NC           mpp_lnk_nc_3d_sp
-#     include "mpp_nc_generic.h90"
-#     undef ROUTINE_NC
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NC           mpp_lnk_nc_4d_sp
-#     include "mpp_nc_generic.h90"
-#     undef ROUTINE_NC
-#  undef DIM_4d
-# undef SINGLE_PRECISION
-
-   !!
-   !!   ----   DOUBLE PRECISION VERSIONS
-   !!
-#  define DIM_2d
-#     define ROUTINE_NC           mpp_lnk_nc_2d_dp
-#     include "mpp_nc_generic.h90"
-#     undef ROUTINE_NC
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NC           mpp_lnk_nc_3d_dp
-#     include "mpp_nc_generic.h90"
-#     undef ROUTINE_NC
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NC           mpp_lnk_nc_4d_dp
-#     include "mpp_nc_generic.h90"
-#     undef ROUTINE_NC
-#  undef DIM_4d
-
-   !!----------------------------------------------------------------------
-   !!                   ***  routine mpp_nfd_(2,3,4)d  ***
-   !!
-   !!   * Argument : dummy argument use in mpp_nfd_... routines
-   !!                ptab      :   array or pointer of arrays on which the boundary condition is applied
-   !!                cd_nat    :   nature of array grid-points
-   !!                psgn      :   sign used across the north fold boundary
-   !!                kfld      :   optional, number of pt3d arrays
-   !!                kfillmode :   optional, method to be use to fill the halos (see jpfill* variables)
-   !!                pfillval  :   optional, background value (used with jpfillcopy)
-   !!----------------------------------------------------------------------
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-   !!
-   !!   ----   SINGLE PRECISION VERSIONS
-   !!
-#  define SINGLE_PRECISION
-#  define DIM_2d
-#     define ROUTINE_NFD           mpp_nfd_2d_sp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_2d_ptr_sp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           mpp_nfd_3d_sp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_3d_ptr_sp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           mpp_nfd_4d_sp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_4d_ptr_sp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_4d
-#  undef SINGLE_PRECISION
-
-   !!
-   !!   ----   DOUBLE PRECISION VERSIONS
-   !!
-#  define DIM_2d
-#     define ROUTINE_NFD           mpp_nfd_2d_dp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_2d_ptr_dp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           mpp_nfd_3d_dp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_3d_ptr_dp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           mpp_nfd_4d_dp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           mpp_nfd_4d_ptr_dp
-#     include "mpp_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_4d
-
-   !!======================================================================
-
+#define PRECISION dp
+#  define MPI_TYPE MPI_DOUBLE_PRECISION
+#  define BUFFSND buffsnd_dp
+#  define BUFFRCV buffrcv_dp
+#  include "lbc_lnk_pt2pt_generic.h90"
+#  include "lbc_lnk_neicoll_generic.h90"
+#  undef MPI_TYPE
+#  undef BUFFSND
+#  undef BUFFRCV
+#undef PRECISION
 
    !!======================================================================
@@ -541,12 +191,5 @@
       !!                    jpi    : first dimension of the local subdomain
       !!                    jpj    : second dimension of the local subdomain
-      !!                    kexti  : number of columns for extra outer halo
-      !!                    kextj  : number of rows for extra outer halo
-      !!                    nbondi : mark for "east-west local boundary"
-      !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors
-      !!                    nowe   : number for local neighboring processors
-      !!                    noso   : number for local neighboring processors
-      !!                    nono   : number for local neighboring processors
+      !!                    mpinei : number of neighboring domains (starting at 0, -1 if no neighbourg)
       !!----------------------------------------------------------------------
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbcnfd.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbcnfd.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lbcnfd.F90	(revision 14644)
@@ -21,49 +21,25 @@
    USE in_out_manager ! I/O manager
    USE lib_mpp        ! MPP library
+#if ! defined key_mpi_off
+   USE MPI
+#endif
 
    IMPLICIT NONE
    PRIVATE
 
-   INTERFACE lbc_nfd
-      MODULE PROCEDURE   lbc_nfd_2d_sp    , lbc_nfd_3d_sp    , lbc_nfd_4d_sp
-      MODULE PROCEDURE   lbc_nfd_2d_ptr_sp, lbc_nfd_3d_ptr_sp, lbc_nfd_4d_ptr_sp
-      MODULE PROCEDURE   lbc_nfd_2d_ext_sp
-      MODULE PROCEDURE   lbc_nfd_2d_dp    , lbc_nfd_3d_dp    , lbc_nfd_4d_dp
-      MODULE PROCEDURE   lbc_nfd_2d_ptr_dp, lbc_nfd_3d_ptr_dp, lbc_nfd_4d_ptr_dp
-      MODULE PROCEDURE   lbc_nfd_2d_ext_dp
-   END INTERFACE
-   !
-   INTERFACE lbc_nfd_nogather
-!                        ! Currently only 4d array version is needed
-     MODULE PROCEDURE   lbc_nfd_nogather_2d_sp    , lbc_nfd_nogather_3d_sp
-     MODULE PROCEDURE   lbc_nfd_nogather_4d_sp
-     MODULE PROCEDURE   lbc_nfd_nogather_2d_ptr_sp, lbc_nfd_nogather_3d_ptr_sp
-     MODULE PROCEDURE   lbc_nfd_nogather_2d_dp    , lbc_nfd_nogather_3d_dp
-     MODULE PROCEDURE   lbc_nfd_nogather_4d_dp
-     MODULE PROCEDURE   lbc_nfd_nogather_2d_ptr_dp, lbc_nfd_nogather_3d_ptr_dp
-!     MODULE PROCEDURE   lbc_nfd_nogather_4d_ptr
+   INTERFACE lbc_nfd            ! called by mpp_nfd, lbc_lnk_pt2pt or lbc_lnk_neicoll
+      MODULE PROCEDURE   lbc_nfd_sp, lbc_nfd_ext_sp
+      MODULE PROCEDURE   lbc_nfd_dp, lbc_nfd_ext_dp
    END INTERFACE
 
-   TYPE, PUBLIC ::   PTR_2D_dp   !: array of 2D pointers (also used in lib_mpp)
-      REAL(dp), DIMENSION (:,:)    , POINTER ::   pt2d
-   END TYPE PTR_2D_dp
-   TYPE, PUBLIC ::   PTR_3D_dp   !: array of 3D pointers (also used in lib_mpp)
-      REAL(dp), DIMENSION (:,:,:)  , POINTER ::   pt3d
-   END TYPE PTR_3D_dp
-   TYPE, PUBLIC ::   PTR_4D_dp   !: array of 4D pointers (also used in lib_mpp)
-      REAL(dp), DIMENSION (:,:,:,:), POINTER ::   pt4d
-   END TYPE PTR_4D_dp
+   INTERFACE mpp_nfd            ! called by lbc_lnk_pt2pt or lbc_lnk_neicoll
+      MODULE PROCEDURE   mpp_nfd_sp, mpp_nfd_dp
+   END INTERFACE
 
-   TYPE, PUBLIC ::   PTR_2D_sp   !: array of 2D pointers (also used in lib_mpp)
-      REAL(sp), DIMENSION (:,:)    , POINTER ::   pt2d
-   END TYPE PTR_2D_sp
-   TYPE, PUBLIC ::   PTR_3D_sp   !: array of 3D pointers (also used in lib_mpp)
-      REAL(sp), DIMENSION (:,:,:)  , POINTER ::   pt3d
-   END TYPE PTR_3D_sp
-   TYPE, PUBLIC ::   PTR_4D_sp   !: array of 4D pointers (also used in lib_mpp)
-      REAL(sp), DIMENSION (:,:,:,:), POINTER ::   pt4d
-   END TYPE PTR_4D_sp
-
-
+   INTERFACE lbc_nfd_nogather   ! called by mpp_nfd
+      MODULE PROCEDURE   lbc_nfd_nogather_sp, lbc_nfd_nogather_dp
+   END INTERFACE
+   
+   PUBLIC   mpp_nfd            ! mpi north fold conditions
    PUBLIC   lbc_nfd            ! north fold conditions
    PUBLIC   lbc_nfd_nogather   ! north fold conditions (no allgather case)
@@ -82,5 +58,7 @@
 
    !!----------------------------------------------------------------------
-   !!                   ***  routine lbc_nfd_(2,3,4)d  ***
+   !!                   ***  routine lbc_nfd_[sd]p  ***
+   !!               ***  routine lbc_nfd_nogather_[sd]p  ***
+   !!                   ***  routine lbc_nfd_ext_[sd]p  ***
    !!----------------------------------------------------------------------
    !!
@@ -95,191 +73,47 @@
    !                       !==  SINGLE PRECISION VERSIONS
    !
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define SINGLE_PRECISION
-#  define DIM_2d
-#     define ROUTINE_NFD           lbc_nfd_2d_sp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_2d_ptr_sp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  2D array with extra haloes  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_NFD           lbc_nfd_2d_ext_sp
-#     include "lbc_nfd_ext_generic.h90"
-#     undef ROUTINE_NFD
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           lbc_nfd_3d_sp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_3d_ptr_sp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           lbc_nfd_4d_sp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_4d_ptr_sp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_4d
-   !
-   !  lbc_nfd_nogather routines
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_NFD           lbc_nfd_nogather_2d_sp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_nogather_2d_ptr_sp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           lbc_nfd_nogather_3d_sp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_nogather_3d_ptr_sp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           lbc_nfd_nogather_4d_sp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-!#     define MULTI
-!#     define ROUTINE_NFD           lbc_nfd_nogather_4d_ptr
-!#     include "lbc_nfd_nogather_generic.h90"
-!#     undef ROUTINE_NFD
-!#     undef MULTI
-#  undef DIM_4d
-#  undef SINGLE_PRECISION
-
-   !!----------------------------------------------------------------------
+#define PRECISION sp
+#  include "lbc_nfd_generic.h90"
+#  include "lbc_nfd_nogather_generic.h90"
+#  include "lbc_nfd_ext_generic.h90"
+#undef PRECISION
    !
    !                       !==  DOUBLE PRECISION VERSIONS
    !
+#define PRECISION dp
+#  include "lbc_nfd_generic.h90"
+#  include "lbc_nfd_nogather_generic.h90"
+#  include "lbc_nfd_ext_generic.h90"
+#undef PRECISION
+
+   !!======================================================================
    !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_NFD           lbc_nfd_2d_dp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_2d_ptr_dp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  2D array with extra haloes  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_NFD           lbc_nfd_2d_ext_dp
-#     include "lbc_nfd_ext_generic.h90"
-#     undef ROUTINE_NFD
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           lbc_nfd_3d_dp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_3d_ptr_dp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           lbc_nfd_4d_dp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_4d_ptr_dp
-#     include "lbc_nfd_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_4d
-   !
-   !  lbc_nfd_nogather routines
-   !
-   !                       !==  2D array and array of 2D pointer  ==!
-   !
-#  define DIM_2d
-#     define ROUTINE_NFD           lbc_nfd_nogather_2d_dp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_nogather_2d_ptr_dp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_2d
-   !
-   !                       !==  3D array and array of 3D pointer  ==!
-   !
-#  define DIM_3d
-#     define ROUTINE_NFD           lbc_nfd_nogather_3d_dp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     define MULTI
-#     define ROUTINE_NFD           lbc_nfd_nogather_3d_ptr_dp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-#     undef MULTI
-#  undef DIM_3d
-   !
-   !                       !==  4D array and array of 4D pointer  ==!
-   !
-#  define DIM_4d
-#     define ROUTINE_NFD           lbc_nfd_nogather_4d_dp
-#     include "lbc_nfd_nogather_generic.h90"
-#     undef ROUTINE_NFD
-!#     define MULTI
-!#     define ROUTINE_NFD           lbc_nfd_nogather_4d_ptr
-!#     include "lbc_nfd_nogather_generic.h90"
-!#     undef ROUTINE_NFD
-!#     undef MULTI
-#  undef DIM_4d
-
    !!----------------------------------------------------------------------
-
-
+   !!                   ***  routine mpp_nfd_[sd]p  ***
+   !!
+   !!   * Argument : dummy argument use in mpp_nfd_... routines
+   !!                ptab      :   pointer of arrays on which the boundary condition is applied
+   !!                cd_nat    :   nature of array grid-points
+   !!                psgn      :   sign used across the north fold boundary
+   !!                kfld      :   optional, number of pt3d arrays
+   !!                kfillmode :   optional, method to be use to fill the halos (see jpfill* variables)
+   !!                pfillval  :   optional, background value (used with jpfillcopy)
+   !!----------------------------------------------------------------------
+   !!
+   !!   ----   SINGLE PRECISION VERSIONS
+   !!
+#define PRECISION sp
+#  define MPI_TYPE MPI_REAL
+#  include "mpp_nfd_generic.h90"
+#  undef MPI_TYPE
+#undef PRECISION
+   !!
+   !!   ----   DOUBLE PRECISION VERSIONS
+   !!
+#define PRECISION dp
+#  define MPI_TYPE MPI_DOUBLE_PRECISION
+#  include "mpp_nfd_generic.h90"
+#  undef MPI_TYPE
+#undef PRECISION
 
    !!======================================================================
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lib_mpp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lib_mpp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/lib_mpp.F90	(revision 14644)
@@ -55,4 +55,7 @@
    USE dom_oce        ! ocean space and time domain
    USE in_out_manager ! I/O manager
+#if ! defined key_mpi_off
+   USE MPI
+#endif
 
    IMPLICIT NONE
@@ -73,5 +76,5 @@
    PUBLIC   mpp_bcast_nml
    PUBLIC   tic_tac
-#if ! defined key_mpp_mpi
+#if defined key_mpp_off
    PUBLIC MPI_wait
    PUBLIC MPI_Wtime
@@ -107,11 +110,16 @@
    END INTERFACE
 
+   TYPE, PUBLIC ::   PTR_4D_sp   !: array of 4D pointers (used in lbclnk and lbcnfd)
+      REAL(sp), DIMENSION (:,:,:,:), POINTER ::   pt4d
+   END TYPE PTR_4D_sp
+
+   TYPE, PUBLIC ::   PTR_4D_dp   !: array of 4D pointers (used in lbclnk and lbcnfd)
+      REAL(dp), DIMENSION (:,:,:,:), POINTER ::   pt4d
+   END TYPE PTR_4D_dp
+
    !! ========================= !!
    !!  MPI  variable definition !!
    !! ========================= !!
-#if   defined key_mpp_mpi
-!$AGRIF_DO_NOT_TREAT
-   INCLUDE 'mpif.h'
-!$AGRIF_END_DO_NOT_TREAT
+#if ! defined key_mpi_off
    LOGICAL, PUBLIC, PARAMETER ::   lk_mpp = .TRUE.    !: mpp flag
 #else
@@ -122,6 +130,4 @@
 #endif
 
-   INTEGER, PARAMETER         ::   nprocmax = 2**10   ! maximun dimension (required to be a power of 2)
-
    INTEGER, PUBLIC ::   mppsize        ! number of process
    INTEGER, PUBLIC ::   mpprank        ! process number  [ 0 - size-1 ]
@@ -132,14 +138,31 @@
    INTEGER :: MPI_SUMDD
 
+   ! Neighbourgs informations
+   INTEGER,    PARAMETER, PUBLIC ::   n_hlsmax = 3
+   INTEGER, DIMENSION(         8), PUBLIC ::   mpinei      !: 8-neighbourg MPI indexes (starting at 0, -1 if no neighbourg)
+   INTEGER, DIMENSION(n_hlsmax,8), PUBLIC ::   mpiSnei     !: 8-neighbourg Send MPI indexes (starting at 0, -1 if no neighbourg)
+   INTEGER, DIMENSION(n_hlsmax,8), PUBLIC ::   mpiRnei     !: 8-neighbourg Recv MPI indexes (starting at 0, -1 if no neighbourg)
+   INTEGER,    PARAMETER, PUBLIC ::   jpwe = 1   !: WEst
+   INTEGER,    PARAMETER, PUBLIC ::   jpea = 2   !: EAst
+   INTEGER,    PARAMETER, PUBLIC ::   jpso = 3   !: SOuth
+   INTEGER,    PARAMETER, PUBLIC ::   jpno = 4   !: NOrth
+   INTEGER,    PARAMETER, PUBLIC ::   jpsw = 5   !: South-West
+   INTEGER,    PARAMETER, PUBLIC ::   jpse = 6   !: South-East
+   INTEGER,    PARAMETER, PUBLIC ::   jpnw = 7   !: North-West
+   INTEGER,    PARAMETER, PUBLIC ::   jpne = 8   !: North-East
+
+   LOGICAL, DIMENSION(8), PUBLIC ::   l_SelfPerio  !   should we explicitely take care of I/J periodicity
+   LOGICAL,               PUBLIC ::   l_IdoNFold
+
    ! variables used for zonal integration
-   INTEGER, PUBLIC ::   ncomm_znl       !: communicator made by the processors on the same zonal average
-   LOGICAL, PUBLIC ::   l_znl_root      !: True on the 'left'most processor on the same row
-   INTEGER         ::   ngrp_znl        !  group ID for the znl processors
-   INTEGER         ::   ndim_rank_znl   !  number of processors on the same zonal average
+   INTEGER, PUBLIC ::   ncomm_znl         !: communicator made by the processors on the same zonal average
+   LOGICAL, PUBLIC ::   l_znl_root        !: True on the 'left'most processor on the same row
+   INTEGER         ::   ngrp_znl          !: group ID for the znl processors
+   INTEGER         ::   ndim_rank_znl     !: number of processors on the same zonal average
    INTEGER, DIMENSION(:), ALLOCATABLE, SAVE ::   nrank_znl  ! dimension ndim_rank_znl, number of the procs into the same znl domain
 
    ! variables used for MPI3 neighbourhood collectives
-   INTEGER, PUBLIC :: mpi_nc_com                   ! MPI3 neighbourhood collectives communicator
-   INTEGER, PUBLIC :: mpi_nc_all_com               ! MPI3 neighbourhood collectives communicator (with diagionals)
+   INTEGER, DIMENSION(n_hlsmax), PUBLIC ::   mpi_nc_com4       ! MPI3 neighbourhood collectives communicator
+   INTEGER, DIMENSION(n_hlsmax), PUBLIC ::   mpi_nc_com8       ! MPI3 neighbourhood collectives communicator (with diagionals)
 
    ! North fold condition in mpp_mpi with jpni > 1 (PUBLIC for TAM)
@@ -187,5 +210,11 @@
 
    LOGICAL, PUBLIC ::   ln_nnogather                !: namelist control of northfold comms
-   LOGICAL, PUBLIC ::   l_north_nogather = .FALSE.  !: internal control of northfold comms
+   INTEGER, PUBLIC ::   nn_comm                     !: namelist control of comms
+
+   INTEGER, PUBLIC, PARAMETER ::   jpfillnothing = 1
+   INTEGER, PUBLIC, PARAMETER ::   jpfillcst     = 2
+   INTEGER, PUBLIC, PARAMETER ::   jpfillcopy    = 3
+   INTEGER, PUBLIC, PARAMETER ::   jpfillperio   = 4
+   INTEGER, PUBLIC, PARAMETER ::   jpfillmpi     = 5
 
    !! * Substitutions
@@ -209,5 +238,5 @@
       LOGICAL ::   llmpi_init
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       CALL mpi_initialized ( llmpi_init, ierr )
@@ -265,5 +294,5 @@
       INTEGER , INTENT(in   ) ::   kdest      ! receive process number
       INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
-      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      INTEGER , INTENT(inout) ::   md_req     ! argument for isend
       !!
       INTEGER ::   iflag
@@ -271,5 +300,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF (wp == dp) THEN
          mpi_working_type = mpi_double_precision
@@ -294,10 +323,10 @@
       INTEGER , INTENT(in   ) ::   kdest      ! receive process number
       INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
-      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      INTEGER , INTENT(inout) ::   md_req     ! argument for isend
       !!
       INTEGER ::   iflag
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_isend( pmess, kbytes, mpi_double_precision, kdest , ktyp, mpi_comm_oce, md_req, iflag )
 #endif
@@ -317,10 +346,10 @@
       INTEGER , INTENT(in   ) ::   kdest      ! receive process number
       INTEGER , INTENT(in   ) ::   ktyp       ! tag of the message
-      INTEGER , INTENT(in   ) ::   md_req     ! argument for isend
+      INTEGER , INTENT(inout) ::   md_req     ! argument for isend
       !!
       INTEGER ::   iflag
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_isend( pmess, kbytes, mpi_real, kdest , ktyp, mpi_comm_oce, md_req, iflag )
 #endif
@@ -347,5 +376,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -380,5 +409,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -409,5 +438,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! If a specific process number has been passed to the receive call,
       ! use that one. Default is to use mpi_any_source
@@ -437,5 +466,5 @@
       !
       itaille = jpi * jpj
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_gather( ptab, itaille, mpi_double_precision, pio, itaille     ,   &
          &                            mpi_double_precision, kp , mpi_comm_oce, ierror )
@@ -464,5 +493,5 @@
       itaille = jpi * jpj
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_scatter( pio, itaille, mpi_double_precision, ptab, itaille     ,   &
          &                            mpi_double_precision, kp  , mpi_comm_oce, ierror )
@@ -493,5 +522,5 @@
       COMPLEX(dp), ALLOCATABLE, DIMENSION(:) ::   ytmp
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ilocalcomm = mpi_comm_oce
       IF( PRESENT(kcom) )   ilocalcomm = kcom
@@ -568,5 +597,5 @@
       !!----------------------------------------------------------------------
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       if( wp == dp ) then
          MPI_TYPE = MPI_DOUBLE_PRECISION
@@ -640,5 +669,5 @@
       INTEGER ::   ierr
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
       ! test on ndelayid(kid) useless as mpi_wait return immediatly if the request handle is MPI_REQUEST_NULL
@@ -662,5 +691,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       call MPI_BCAST(kleng, 1, MPI_INT, 0, mpi_comm_oce, iflag)
       call MPI_BARRIER(mpi_comm_oce, iflag)
@@ -928,5 +957,5 @@
       !!-----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpi_barrier( mpi_comm_oce, ierror )
 #endif
@@ -944,12 +973,12 @@
       LOGICAL, OPTIONAL, INTENT(in) :: ld_abort    ! source process number
       LOGICAL ::   ll_abort
-      INTEGER ::   info
+      INTEGER ::   info, ierr
       !!----------------------------------------------------------------------
       ll_abort = .FALSE.
       IF( PRESENT(ld_abort) ) ll_abort = ld_abort
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF(ll_abort) THEN
-         CALL mpi_abort( MPI_COMM_WORLD )
+         CALL mpi_abort( MPI_COMM_WORLD, 123, info )
       ELSE
          CALL mppsync
@@ -964,10 +993,10 @@
    SUBROUTINE mpp_comm_free( kcom )
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kcom
+      INTEGER, INTENT(inout) ::   kcom
       !!
       INTEGER :: ierr
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL MPI_COMM_FREE(kcom, ierr)
 #endif
@@ -1001,8 +1030,8 @@
       INTEGER, ALLOCATABLE, DIMENSION(:) ::   kwork
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
-      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_world     : ', ngrp_world
-      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_world : ', mpi_comm_world
-      !-$$     WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - mpi_comm_oce   : ', mpi_comm_oce
+#if ! defined key_mpi_off
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ngrp_world     : ', ngrp_world
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - mpi_comm_world : ', mpi_comm_world
+      !-$$     WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - mpi_comm_oce   : ', mpi_comm_oce
       !
       ALLOCATE( kwork(jpnij), STAT=ierr )
@@ -1015,5 +1044,5 @@
          !
          CALL MPI_ALLGATHER ( njmpp, 1, mpi_integer, kwork, 1, mpi_integer, mpi_comm_oce, ierr )
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - kwork pour njmpp : ', kwork
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - kwork pour njmpp : ', kwork
          !-$$        CALL flush(numout)
          !
@@ -1025,5 +1054,5 @@
             ENDIF
          END DO
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ndim_rank_znl : ', ndim_rank_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ndim_rank_znl : ', ndim_rank_znl
          !-$$        CALL flush(numout)
          ! Allocate the right size to nrank_znl
@@ -1038,20 +1067,20 @@
             ENDIF
          END DO
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - nrank_znl : ', nrank_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - nrank_znl : ', nrank_znl
          !-$$        CALL flush(numout)
 
          ! Create the opa group
          CALL MPI_COMM_GROUP(mpi_comm_oce,ngrp_opa,ierr)
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_opa : ', ngrp_opa
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ngrp_opa : ', ngrp_opa
          !-$$        CALL flush(numout)
 
          ! Create the znl group from the opa group
          CALL MPI_GROUP_INCL  ( ngrp_opa, ndim_rank_znl, nrank_znl, ngrp_znl, ierr )
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ngrp_znl ', ngrp_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ngrp_znl ', ngrp_znl
          !-$$        CALL flush(numout)
 
          ! Create the znl communicator from the opa communicator, ie the pool of procs in the same row
          CALL MPI_COMM_CREATE ( mpi_comm_oce, ngrp_znl, ncomm_znl, ierr )
-         !-$$        WRITE (numout,*) 'mpp_ini_znl ', nproc, ' - ncomm_znl ', ncomm_znl
+         !-$$        WRITE (numout,*) 'mpp_ini_znl ', mpprank, ' - ncomm_znl ', ncomm_znl
          !-$$        CALL flush(numout)
          !
@@ -1073,5 +1102,6 @@
    END SUBROUTINE mpp_ini_znl
 
-   SUBROUTINE mpp_ini_nc
+   
+   SUBROUTINE mpp_ini_nc( khls )
       !!----------------------------------------------------------------------
       !!               ***  routine mpp_ini_nc  ***
@@ -1084,139 +1114,36 @@
       !
       !! ** output
-      !!         mpi_nc_com = MPI3 neighbourhood collectives communicator
-      !!         mpi_nc_all_com = MPI3 neighbourhood collectives communicator
-      !!                          (with diagonals)
-      !!
-      !!----------------------------------------------------------------------
-      INTEGER, DIMENSION(:), ALLOCATABLE :: ineigh, ineighalls, ineighallr
-      INTEGER :: ideg, idegalls, idegallr, icont, icont1
-      INTEGER :: ierr
-      LOGICAL, PARAMETER :: ireord = .FALSE.
-
-#if defined key_mpp_mpi
-
-      ideg = 0
-      idegalls = 0
-      idegallr = 0
-      icont = 0
-      icont1 = 0
-
-      IF (nbondi .eq. 1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondi .eq. -1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondi .eq. 0) THEN
-         ideg = ideg + 2
-      ENDIF
-
-      IF (nbondj .eq. 1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondj .eq. -1) THEN
-         ideg = ideg + 1
-      ELSEIF (nbondj .eq. 0) THEN
-         ideg = ideg + 2
-      ENDIF
-
-      idegalls = ideg
-      idegallr = ideg
-
-      IF (nones .ne. -1) idegalls = idegalls + 1
-      IF (nonws .ne. -1) idegalls = idegalls + 1
-      IF (noses .ne. -1) idegalls = idegalls + 1
-      IF (nosws .ne. -1) idegalls = idegalls + 1
-      IF (noner .ne. -1) idegallr = idegallr + 1
-      IF (nonwr .ne. -1) idegallr = idegallr + 1
-      IF (noser .ne. -1) idegallr = idegallr + 1
-      IF (noswr .ne. -1) idegallr = idegallr + 1
-
-      ALLOCATE(ineigh(ideg))
-      ALLOCATE(ineighalls(idegalls))
-      ALLOCATE(ineighallr(idegallr))
-
-      IF (nbondi .eq. 1) THEN
-         icont = icont + 1
-         ineigh(icont) = nowe
-         ineighalls(icont) = nowe
-         ineighallr(icont) = nowe
-      ELSEIF (nbondi .eq. -1) THEN
-         icont = icont + 1
-         ineigh(icont) = noea
-         ineighalls(icont) = noea
-         ineighallr(icont) = noea
-      ELSEIF (nbondi .eq. 0) THEN
-         icont = icont + 1
-         ineigh(icont) = nowe
-         ineighalls(icont) = nowe
-         ineighallr(icont) = nowe
-         icont = icont + 1
-         ineigh(icont) = noea
-         ineighalls(icont) = noea
-         ineighallr(icont) = noea
-      ENDIF
-
-      IF (nbondj .eq. 1) THEN
-         icont = icont + 1
-         ineigh(icont) = noso
-         ineighalls(icont) = noso
-         ineighallr(icont) = noso
-      ELSEIF (nbondj .eq. -1) THEN
-         icont = icont + 1
-         ineigh(icont) = nono
-         ineighalls(icont) = nono
-         ineighallr(icont) = nono
-      ELSEIF (nbondj .eq. 0) THEN
-         icont = icont + 1
-         ineigh(icont) = noso
-         ineighalls(icont) = noso
-         ineighallr(icont) = noso
-         icont = icont + 1
-         ineigh(icont) = nono
-         ineighalls(icont) = nono
-         ineighallr(icont) = nono
-      ENDIF
-
-      icont1 = icont
-      IF (nosws .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = nosws
-      ENDIF
-      IF (noses .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = noses
-      ENDIF
-      IF (nonws .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = nonws
-      ENDIF
-      IF (nones .ne. -1) THEN
-         icont = icont + 1
-         ineighalls(icont) = nones
-      ENDIF
-      IF (noswr .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = noswr
-      ENDIF
-      IF (noser .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = noser
-      ENDIF
-      IF (nonwr .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = nonwr
-      ENDIF
-      IF (noner .ne. -1) THEN
-         icont1 = icont1 + 1
-         ineighallr(icont1) = noner
-      ENDIF
-
-      CALL MPI_Dist_graph_create_adjacent(mpi_comm_oce, ideg, ineigh, MPI_UNWEIGHTED, ideg, ineigh, MPI_UNWEIGHTED, MPI_INFO_NULL, ireord, mpi_nc_com, ierr)
-      CALL MPI_Dist_graph_create_adjacent(mpi_comm_oce, idegallr, ineighallr, MPI_UNWEIGHTED, idegalls, ineighalls, MPI_UNWEIGHTED, MPI_INFO_NULL, ireord, mpi_nc_all_com, ierr)
-
-      DEALLOCATE (ineigh)
-      DEALLOCATE (ineighalls)
-      DEALLOCATE (ineighallr)
+      !!         mpi_nc_com4 = MPI3 neighbourhood collectives communicator
+      !!         mpi_nc_com8 = MPI3 neighbourhood collectives communicator (with diagonals)
+      !!----------------------------------------------------------------------
+      INTEGER,             INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      !
+      INTEGER, DIMENSION(:), ALLOCATABLE :: iSnei4, iRnei4, iSnei8, iRnei8
+      INTEGER                            :: iScnt4, iRcnt4, iScnt8, iRcnt8
+      INTEGER                            :: ierr
+      LOGICAL, PARAMETER                 :: ireord = .FALSE.
+      !!----------------------------------------------------------------------
+#if ! defined key_mpi_off && ! defined key_mpi2
+      
+      iScnt4 = COUNT( mpiSnei(khls,1:4) >= 0 )
+      iRcnt4 = COUNT( mpiRnei(khls,1:4) >= 0 )
+      iScnt8 = COUNT( mpiSnei(khls,1:8) >= 0 )
+      iRcnt8 = COUNT( mpiRnei(khls,1:8) >= 0 )
+
+      ALLOCATE( iSnei4(iScnt4), iRnei4(iRcnt4), iSnei8(iScnt8), iRnei8(iRcnt8) )   ! ok if icnt4 or icnt8 = 0
+
+      iSnei4 = PACK( mpiSnei(khls,1:4), mask = mpiSnei(khls,1:4) >= 0 )
+      iRnei4 = PACK( mpiRnei(khls,1:4), mask = mpiRnei(khls,1:4) >= 0 )
+      iSnei8 = PACK( mpiSnei(khls,1:8), mask = mpiSnei(khls,1:8) >= 0 )
+      iRnei8 = PACK( mpiRnei(khls,1:8), mask = mpiRnei(khls,1:8) >= 0 )
+
+      CALL MPI_Dist_graph_create_adjacent( mpi_comm_oce, iScnt4, iSnei4, MPI_UNWEIGHTED, iRcnt4, iRnei4, MPI_UNWEIGHTED,   &
+         &                                 MPI_INFO_NULL, ireord, mpi_nc_com4(khls), ierr )
+      CALL MPI_Dist_graph_create_adjacent( mpi_comm_oce, iScnt8, iSnei8, MPI_UNWEIGHTED, iRcnt8, iRnei8, MPI_UNWEIGHTED,   &
+         &                                 MPI_INFO_NULL, ireord, mpi_nc_com8(khls), ierr)
+
+      DEALLOCATE( iSnei4, iRnei4, iSnei8, iRnei8 )
 #endif
    END SUBROUTINE mpp_ini_nc
-
 
 
@@ -1234,5 +1161,4 @@
       !!
       !! ** output
-      !!      njmppmax = njmpp for northern procs
       !!      ndim_rank_north = number of processors in the northern line
       !!      nrank_north (ndim_rank_north) = number  of the northern procs.
@@ -1248,6 +1174,5 @@
       !!----------------------------------------------------------------------
       !
-#if defined key_mpp_mpi
-      njmppmax = MAXVAL( njmppt )
+#if ! defined key_mpi_off
       !
       ! Look for how many procs on the northern boundary
@@ -1330,5 +1255,5 @@
       INTEGER ::    ji,  jj,  jk,  jh, jf, jcount   ! dummy loop indices
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       ll_lbc = .FALSE.
@@ -1400,5 +1325,5 @@
          END DO
          IF ( crname_lbc(n_sequence_lbc) /= 'already counted' ) THEN
-            WRITE(numcom,'(A, I4, A, A)') ' - ', 1,' times by subroutine ', TRIM(crname_lbc(ncom_rec_max))
+            WRITE(numcom,'(A, I4, A, A)') ' - ', 1,' times by subroutine ', TRIM(crname_lbc(n_sequence_lbc))
          END IF
          WRITE(numcom,*) ' '
@@ -1451,5 +1376,5 @@
     REAL(dp),               SAVE :: tic_ct = 0._dp
     INTEGER :: ii
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 
     IF( ncom_stp <= nit000 ) RETURN
@@ -1471,5 +1396,5 @@
    END SUBROUTINE tic_tac
 
-#if ! defined key_mpp_mpi
+#if defined key_mpi_off
    SUBROUTINE mpi_wait(request, status, ierror)
       INTEGER                            , INTENT(in   ) ::   request
@@ -1792,5 +1717,5 @@
          !write(*,'(32A)') cdnambuff
       ENDIF
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL mpp_bcast_nml( cdnambuff, itot )
 #endif
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_allreduce_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_allreduce_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_allreduce_generic.h90	(revision 14644)
@@ -48,5 +48,5 @@
       INTEGER, OPTIONAL, INTENT(in   ) ::   kdim        ! optional pointer dimension
       INTEGER, OPTIONAL, INTENT(in   ) ::   kcom        ! optional communicator
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       INTEGER :: ipi, ii, ierr
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lbc_north_icb_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lbc_north_icb_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lbc_north_icb_generic.h90	(revision 14644)
@@ -31,5 +31,5 @@
       CHARACTER(len=1)        , INTENT(in   ) ::   cd_type  ! nature of pt3d grid-points
       !                                                     !   = T ,  U , V , F or W -points
-      REAL(wp)                , INTENT(in   ) ::   psgn     ! = -1. the sign change across the
+      REAL(PRECISION)         , INTENT(in   ) ::   psgn     ! = -1. the sign change across the
       !!                                                    ! north fold, =  1. otherwise
       INTEGER                 , INTENT(in   ) ::   kextj    ! Extra halo width at north fold
@@ -42,5 +42,5 @@
       REAL(PRECISION), DIMENSION(:,:,:), ALLOCATABLE  ::  znorthgloio_e
       !!----------------------------------------------------------------------
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       ipj=4
@@ -67,5 +67,5 @@
       !
       IF( ln_timing ) CALL tic_tac(.TRUE.)
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       CALL MPI_ALLGATHER( znorthloc_e(1,1-kextj)    , itaille, MPI_TYPE,    &
          &                znorthgloio_e(1,1-kextj,1), itaille, MPI_TYPE,    &
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_generic.h90	(revision 14643)
+++ 	(revision )
@@ -1,410 +1,0 @@
-#if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   define OPT_K(k)                 ,ipf
-#   if defined DIM_2d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_sp)                , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_dp)                , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_sp)                , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_dp)                , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_sp)                , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_dp)                , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#else
-#   if defined SINGLE_PRECISION
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(sp)                    , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   else
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(dp)                    , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   endif
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define F_SIZE(ptab)             1
-#   define OPT_K(k)
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-#endif
-
-# if defined SINGLE_PRECISION
-#    define PRECISION sp
-#    define SENDROUTINE mppsend_sp
-#    define RECVROUTINE mpprecv_sp
-# else
-#    define PRECISION dp
-#    define SENDROUTINE mppsend_dp
-#    define RECVROUTINE mpprecv_dp
-# endif
-
-#if defined MULTI
-   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
-      INTEGER             , INTENT(in   ) ::   kfld        ! number of pt3d arrays
-#else
-   SUBROUTINE ROUTINE_LNK( cdname, ptab, cd_nat, psgn      , kfillmode, pfillval, lsend, lrecv, ncsten )
-#endif
-      ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      CHARACTER(len=1)              , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)                      , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
-      REAL(wp),             OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
-      LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
-      LOGICAL,              OPTIONAL, INTENT(in   ) ::   ncsten      ! 5-point or 9-point stencil
-      !
-      INTEGER  ::    ji,  jj,  jk,  jl,  jf      ! dummy loop indices
-      INTEGER  ::   ipi, ipj, ipk, ipl, ipf      ! dimension of the input array
-      INTEGER  ::   isize, ishift, ishift2       ! local integers
-      INTEGER  ::   ireq_we, ireq_ea, ireq_so, ireq_no     ! mpi_request id
-      INTEGER  ::   ierr
-      INTEGER  ::   ifill_we, ifill_ea, ifill_so, ifill_no
-      REAL(wp) ::   zland
-      INTEGER , DIMENSION(MPI_STATUS_SIZE)        ::   istat          ! for mpi_isend
-      REAL(PRECISION), DIMENSION(:,:,:,:,:), ALLOCATABLE ::   zsnd_we, zrcv_we, zsnd_ea, zrcv_ea   ! east -west  & west - east  halos
-      REAL(PRECISION), DIMENSION(:,:,:,:,:), ALLOCATABLE ::   zsnd_so, zrcv_so, zsnd_no, zrcv_no   ! north-south & south-north  halos
-      LOGICAL  ::   llsend_we, llsend_ea, llsend_no, llsend_so       ! communication send
-      LOGICAL  ::   llrecv_we, llrecv_ea, llrecv_no, llrecv_so       ! communication receive
-      LOGICAL  ::   lldo_nfd                                     ! do north pole folding
-      !!----------------------------------------------------------------------
-      !
-#if defined key_mpi3
-#   if defined MULTI
-      CALL lbc_lnk_nc    ( cdname,  ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
-#   else
-      CALL lbc_lnk_nc_multi(cdname, ptab, cd_nat, psgn, kfillmode=kfillmode, pfillval=pfillval, lsend=lsend, lrecv=lrecv, ncsten=ncsten)
-#   endif
-#else
-
-      ! ----------------------------------------- !
-      !     0. local variables initialization     !
-      ! ----------------------------------------- !
-      !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
-      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
-      !
-      IF     ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN
-         llsend_we = lsend(1)   ;   llsend_ea = lsend(2)   ;   llsend_so = lsend(3)   ;   llsend_no = lsend(4)
-         llrecv_we = lrecv(1)   ;   llrecv_ea = lrecv(2)   ;   llrecv_so = lrecv(3)   ;   llrecv_no = lrecv(4)
-      ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
-         WRITE(ctmp1,*) ' E R R O R : Routine ', cdname, '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
-         WRITE(ctmp2,*) ' ========== '
-         CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
-      ELSE   ! send and receive with every neighbour
-         llsend_we = nbondi ==  1 .OR. nbondi == 0   ! keep for compatibility, should be defined in mppini
-         llsend_ea = nbondi == -1 .OR. nbondi == 0   ! keep for compatibility, should be defined in mppini
-         llsend_so = nbondj ==  1 .OR. nbondj == 0   ! keep for compatibility, should be defined in mppini
-         llsend_no = nbondj == -1 .OR. nbondj == 0   ! keep for compatibility, should be defined in mppini
-         llrecv_we = llsend_we   ;   llrecv_ea = llsend_ea   ;   llrecv_so = llsend_so   ;   llrecv_no = llsend_no
-      END IF
-
-
-      lldo_nfd = npolj /= 0                      ! keep for compatibility, should be defined in mppini
-
-      zland = 0._wp                                     ! land filling value: zero by default
-      IF( PRESENT( pfillval ) )   zland = pfillval      ! set land value
-
-      ! define the method we will use to fill the halos in each direction
-      IF(              llrecv_we ) THEN   ;   ifill_we = jpfillmpi
-      ELSEIF(           l_Iperio ) THEN   ;   ifill_we = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_we = kfillmode
-      ELSE                                ;   ifill_we = jpfillcst
-      END IF
-      !
-      IF(              llrecv_ea ) THEN   ;   ifill_ea = jpfillmpi
-      ELSEIF(           l_Iperio ) THEN   ;   ifill_ea = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_ea = kfillmode
-      ELSE                                ;   ifill_ea = jpfillcst
-      END IF
-      !
-      IF(              llrecv_so ) THEN   ;   ifill_so = jpfillmpi
-      ELSEIF(           l_Jperio ) THEN   ;   ifill_so = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_so = kfillmode
-      ELSE                                ;   ifill_so = jpfillcst
-      END IF
-      !
-      IF(              llrecv_no ) THEN   ;   ifill_no = jpfillmpi
-      ELSEIF(           l_Jperio ) THEN   ;   ifill_no = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_no = kfillmode
-      ELSE                                ;   ifill_no = jpfillcst
-      END IF
-      !
-#if defined PRINT_CAUTION
-      !
-      ! ================================================================================== !
-      ! CAUTION: semi-column notation is often impossible because of the cpp preprocessing !
-      ! ================================================================================== !
-      !
-#endif
-      !
-      ! -------------------------------------------------- !
-      !     1. Do east and west MPI exchange if needed     !
-      ! -------------------------------------------------- !
-      !
-      ! Must exchange the whole column (from 1 to jpj) to get the corners if we have no south/north neighbourg
-      isize = nn_hls * jpj * ipk * ipl * ipf
-      !
-      ! Allocate local temporary arrays to be sent/received. Fill arrays to be sent
-      IF( llsend_we )   ALLOCATE( zsnd_we(nn_hls,jpj,ipk,ipl,ipf) )
-      IF( llsend_ea )   ALLOCATE( zsnd_ea(nn_hls,jpj,ipk,ipl,ipf) )
-      IF( llrecv_we )   ALLOCATE( zrcv_we(nn_hls,jpj,ipk,ipl,ipf) )
-      IF( llrecv_ea )   ALLOCATE( zrcv_ea(nn_hls,jpj,ipk,ipl,ipf) )
-      !
-      IF( llsend_we ) THEN   ! copy western side of the inner mpi domain in local temporary array to be sent by MPI
-         ishift = nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            zsnd_we(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf)   ! nn_hls + 1 -> 2*nn_hls
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      ENDIF
-      !
-      IF(llsend_ea  ) THEN   ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI
-         ishift = jpi - 2 * nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            zsnd_ea(ji,jj,jk,jl,jf) = ARRAY_IN(ishift+ji,jj,jk,jl,jf)   ! jpi - 2*nn_hls + 1 -> jpi - nn_hls
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      ENDIF
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      !
-      ! non-blocking send of the western/eastern side using local temporary arrays
-      IF( llsend_we )   CALL SENDROUTINE( 1, zsnd_we(1,1,1,1,1), isize, nowe, ireq_we )
-      IF( llsend_ea )   CALL SENDROUTINE( 2, zsnd_ea(1,1,1,1,1), isize, noea, ireq_ea )
-      ! blocking receive of the western/eastern halo in local temporary arrays
-      IF( llrecv_we )   CALL RECVROUTINE( 2, zrcv_we(1,1,1,1,1), isize, nowe )
-      IF( llrecv_ea )   CALL RECVROUTINE( 1, zrcv_ea(1,1,1,1,1), isize, noea )
-      !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
-      !
-      ! ----------------------------------- !
-      !     2. Fill east and west halos     !
-      ! ----------------------------------- !
-      !
-      ! 2.1 fill weastern halo
-      ! ----------------------
-      ! ishift = 0                         ! fill halo from ji = 1 to nn_hls
-      SELECT CASE ( ifill_we )
-      CASE ( jpfillnothing )               ! no filling
-      CASE ( jpfillmpi   )                 ! use data received by MPI
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_we(ji,jj,jk,jl,jf)   ! 1 -> nn_hls
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillperio )                 ! use east-weast periodicity
-         ishift2 = jpi - 2 * nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcopy  )                 ! filling with inner domain values
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcst   )                 ! filling with constant value
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ji,jj,jk,jl,jf) = zland
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      END SELECT
-      !
-      ! 2.2 fill eastern halo
-      ! ---------------------
-      ishift = jpi - nn_hls                ! fill halo from ji = jpi-nn_hls+1 to jpi
-      SELECT CASE ( ifill_ea )
-      CASE ( jpfillnothing )               ! no filling
-      CASE ( jpfillmpi   )                 ! use data received by MPI
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv_ea(ji,jj,jk,jl,jf)   ! jpi - nn_hls + 1 -> jpi
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillperio )                 ! use east-weast periodicity
-         ishift2 = nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcopy  )                 ! filling with inner domain values
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcst   )                 ! filling with constant value
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-            ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      END SELECT
-      !
-      ! ------------------------------- !
-      !     3. north fold treatment     !
-      ! ------------------------------- !
-      !
-      ! do it before south directions so concerned processes can do it without waiting for the comm with the sourthern neighbor
-      !
-      IF( lldo_nfd .AND. ifill_no /= jpfillnothing ) THEN
-         !
-         SELECT CASE ( jpni )
-         CASE ( 1 )     ;   CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:)                  OPT_K(:) )   ! only 1 northern proc, no mpp
-         CASE DEFAULT   ;   CALL mpp_nfd( ptab, NAT_IN(:), SGN_IN(:), ifill_no, zland OPT_K(:) )   ! for all northern procs.
-         END SELECT
-         !
-         ifill_no = jpfillnothing  ! force to do nothing for the northern halo as we just done the north pole folding
-         !
-      ENDIF
-      !
-      ! ---------------------------------------------------- !
-      !     4. Do north and south MPI exchange if needed     !
-      ! ---------------------------------------------------- !
-      !
-      IF( llsend_so )   ALLOCATE( zsnd_so(jpi,nn_hls,ipk,ipl,ipf) )
-      IF( llsend_no )   ALLOCATE( zsnd_no(jpi,nn_hls,ipk,ipl,ipf) )
-      IF( llrecv_so )   ALLOCATE( zrcv_so(jpi,nn_hls,ipk,ipl,ipf) )
-      IF( llrecv_no )   ALLOCATE( zrcv_no(jpi,nn_hls,ipk,ipl,ipf) )
-      !
-      isize = jpi * nn_hls * ipk * ipl * ipf
-
-      ! allocate local temporary arrays to be sent/received. Fill arrays to be sent
-      IF( llsend_so ) THEN   ! copy sourhern side of the inner mpi domain in local temporary array to be sent by MPI
-         ishift = nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            zsnd_so(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf)   ! nn_hls+1 -> 2*nn_hls
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      ENDIF
-      !
-      IF( llsend_no ) THEN   ! copy eastern side of the inner mpi domain in local temporary array to be sent by MPI
-         ishift = jpj - 2 * nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            zsnd_no(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift+jj,jk,jl,jf)   ! jpj-2*nn_hls+1 -> jpj-nn_hls
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      ENDIF
-      !
-      IF( ln_timing ) CALL tic_tac(.TRUE.)
-      !
-      ! non-blocking send of the southern/northern side
-      IF( llsend_so )   CALL SENDROUTINE( 3, zsnd_so(1,1,1,1,1), isize, noso, ireq_so )
-      IF( llsend_no )   CALL SENDROUTINE( 4, zsnd_no(1,1,1,1,1), isize, nono, ireq_no )
-      ! blocking receive of the southern/northern halo
-      IF( llrecv_so )   CALL RECVROUTINE( 4, zrcv_so(1,1,1,1,1), isize, noso )
-      IF( llrecv_no )   CALL RECVROUTINE( 3, zrcv_no(1,1,1,1,1), isize, nono )
-      !
-      IF( ln_timing ) CALL tic_tac(.FALSE.)
-      !
-      ! ------------------------------------- !
-      !     5. Fill south and north halos     !
-      ! ------------------------------------- !
-      !
-      ! 5.1 fill southern halo
-      ! ----------------------
-      ! ishift = 0                         ! fill halo from jj = 1 to nn_hls
-      SELECT CASE ( ifill_so )
-      CASE ( jpfillnothing )               ! no filling
-      CASE ( jpfillmpi   )                 ! use data received by MPI
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,jj,jk,jl,jf) = zrcv_so(ji,jj,jk,jl,jf)   ! 1 -> nn_hls
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillperio )                 ! use north-south periodicity
-         ishift2 = jpj - 2 * nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcopy  )                 ! filling with inner domain values
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,nn_hls+1,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcst   )                 ! filling with constant value
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,jj,jk,jl,jf) = zland
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      END SELECT
-      !
-      ! 5.2 fill northern halo
-      ! ----------------------
-      ishift = jpj - nn_hls                ! fill halo from jj = jpj-nn_hls+1 to jpj
-      SELECT CASE ( ifill_no )
-      CASE ( jpfillnothing )               ! no filling
-      CASE ( jpfillmpi   )                 ! use data received by MPI
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zrcv_no(ji,jj,jk,jl,jf)   ! jpj-nn_hls+1 -> jpj
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillperio )                 ! use north-south periodicity
-         ishift2 = nn_hls
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcopy  )                 ! filling with inner domain values
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift,jk,jl,jf)
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      CASE ( jpfillcst   )                 ! filling with constant value
-         DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-            ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zland
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-      END SELECT
-      !
-      ! -------------------------------------------- !
-      !     6. deallocate local temporary arrays     !
-      ! -------------------------------------------- !
-      !
-      IF( llsend_we ) THEN
-         CALL mpi_wait(ireq_we, istat, ierr )
-         DEALLOCATE( zsnd_we )
-      ENDIF
-      IF( llsend_ea )  THEN
-         CALL mpi_wait(ireq_ea, istat, ierr )
-         DEALLOCATE( zsnd_ea )
-      ENDIF
-      IF( llsend_so ) THEN
-         CALL mpi_wait(ireq_so, istat, ierr )
-         DEALLOCATE( zsnd_so )
-      ENDIF
-      IF( llsend_no ) THEN
-         CALL mpi_wait(ireq_no, istat, ierr )
-         DEALLOCATE( zsnd_no )
-      ENDIF
-      !
-      IF( llrecv_we )   DEALLOCATE( zrcv_we )
-      IF( llrecv_ea )   DEALLOCATE( zrcv_ea )
-      IF( llrecv_so )   DEALLOCATE( zrcv_so )
-      IF( llrecv_no )   DEALLOCATE( zrcv_no )
-      !
-#endif
-   END SUBROUTINE ROUTINE_LNK
-#undef PRECISION
-#undef SENDROUTINE
-#undef RECVROUTINE
-#undef ARRAY_TYPE
-#undef NAT_IN
-#undef SGN_IN
-#undef ARRAY_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef OPT_K
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_icb_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_icb_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_lnk_icb_generic.h90	(revision 14644)
@@ -24,17 +24,12 @@
       !!                    jpi    : first dimension of the local subdomain
       !!                    jpj    : second dimension of the local subdomain
+      !!                    mpinei : number of neighboring domains (starting at 0, -1 if no neighbourg)
       !!                    kexti  : number of columns for extra outer halo
       !!                    kextj  : number of rows for extra outer halo
-      !!                    nbondi : mark for "east-west local boundary"
-      !!                    nbondj : mark for "north-south local boundary"
-      !!                    noea   : number for local neighboring processors
-      !!                    nowe   : number for local neighboring processors
-      !!                    noso   : number for local neighboring processors
-      !!                    nono   : number for local neighboring processors
       !!----------------------------------------------------------------------
       CHARACTER(len=*)                                        , INTENT(in   ) ::   cdname      ! name of the calling subroutine
       REAL(PRECISION), DIMENSION(1-kexti:jpi+kexti,1-kextj:jpj+kextj), INTENT(inout) ::   pt2d     ! 2D array with extra halo
       CHARACTER(len=1)                                        , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
-      REAL(wp)                                                , INTENT(in   ) ::   psgn     ! sign used across the north fold
+      REAL(PRECISION)                                         , INTENT(in   ) ::   psgn     ! sign used across the north fold
       INTEGER                                                 , INTENT(in   ) ::   kexti    ! extra i-halo width
       INTEGER                                                 , INTENT(in   ) ::   kextj    ! extra j-halo width
@@ -90,5 +85,5 @@
       ! north fold treatment
       ! -----------------------
-      IF( npolj /= 0 ) THEN
+      IF( l_IdoNFold ) THEN
          !
          SELECT CASE ( jpni )
@@ -103,6 +98,5 @@
       ! we play with the neigbours AND the row number because of the periodicity
       !
-      SELECT CASE ( nbondi )      ! Read Dirichlet lateral conditions
-      CASE ( -1, 0, 1 )                ! all exept 2 (i.e. close case)
+      IF( mpinei(jpwe) >= 0 .OR. mpinei(jpea) >= 0 ) THEN   ! Read Dirichlet lateral conditions: all exept 2 (i.e. close case)
          iihom = jpi - (2 * nn_hls) -kexti
          DO jl = 1, ipreci
@@ -110,5 +104,5 @@
             r2dwe(:,jl,1) = pt2d(iihom +jl,:)
          END DO
-      END SELECT
+      ENDIF
       !
       !                           ! Migrations
@@ -120,21 +114,10 @@
       IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
-         CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req1 )
-         CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, noea )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
-         CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, noea, ml_req2 )
-         CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, noea )
-         CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, nowe )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, nowe, ml_req1 )
-         CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, nowe )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
+      IF( mpinei(jpwe) >= 0  )   CALL SENDROUTINE( 1, r2dew(1-kextj,1,1), imigr, mpinei(jpwe), ml_req1 )
+      IF( mpinei(jpea) >= 0  )   CALL SENDROUTINE( 2, r2dwe(1-kextj,1,1), imigr, mpinei(jpea), ml_req2 )
+      IF( mpinei(jpwe) >= 0  )   CALL RECVROUTINE( 2, r2dwe(1-kextj,1,2), imigr, mpinei(jpwe) )
+      IF( mpinei(jpea) >= 0  )   CALL RECVROUTINE( 1, r2dew(1-kextj,1,2), imigr, mpinei(jpea) )
+      IF( mpinei(jpwe) >= 0  )   CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      IF( mpinei(jpea) >= 0  )   CALL mpi_wait(ml_req2,ml_stat,ml_err)
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -142,21 +125,14 @@
       !                           ! Write Dirichlet lateral conditions
       iihom = jpi - nn_hls
-      !
-      SELECT CASE ( nbondi )
-      CASE ( -1 )
+      IF( mpinei(jpwe) >= 0  ) THEN
+         DO jl = 1, ipreci
+            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
+         END DO
+      ENDIF
+      IF( mpinei(jpea) >= 0  ) THEN
          DO jl = 1, ipreci
             pt2d(iihom+jl,:) = r2dew(:,jl,2)
          END DO
-      CASE ( 0 )
-         DO jl = 1, ipreci
-            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
-            pt2d(iihom+jl,:) = r2dew(:,jl,2)
-         END DO
-      CASE ( 1 )
-         DO jl = 1, ipreci
-            pt2d(jl-kexti,:) = r2dwe(:,jl,2)
-         END DO
-      END SELECT
-
+      ENDIF
 
       ! 3. North and south directions
@@ -164,5 +140,5 @@
       ! always closed : we play only with the neigbours
       !
-      IF( nbondj /= 2 ) THEN      ! Read Dirichlet lateral conditions
+      IF( mpinei(jpso) >= 0 .OR. mpinei(jpno) >= 0 ) THEN   ! Read Dirichlet lateral conditions: all exept 2 (i.e. close case)
          ijhom = jpj - (2 * nn_hls) - kextj
          DO jl = 1, iprecj
@@ -177,21 +153,10 @@
       IF( ln_timing ) CALL tic_tac(.TRUE.)
       !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req1 )
-         CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, nono )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      CASE ( 0 )
-         CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
-         CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, nono, ml_req2 )
-         CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, nono )
-         CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, noso )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-         CALL mpi_wait(ml_req2,ml_stat,ml_err)
-      CASE ( 1 )
-         CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, noso, ml_req1 )
-         CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, noso )
-         CALL mpi_wait(ml_req1,ml_stat,ml_err)
-      END SELECT
+      IF( mpinei(jpso) >= 0  )   CALL SENDROUTINE( 3, r2dns(1-kexti,1,1), imigr, mpinei(jpso), ml_req1 )
+      IF( mpinei(jpno) >= 0  )   CALL SENDROUTINE( 4, r2dsn(1-kexti,1,1), imigr, mpinei(jpno), ml_req2 )
+      IF( mpinei(jpso) >= 0  )   CALL RECVROUTINE( 4, r2dsn(1-kexti,1,2), imigr, mpinei(jpso) )
+      IF( mpinei(jpno) >= 0  )   CALL RECVROUTINE( 3, r2dns(1-kexti,1,2), imigr, mpinei(jpno) )
+      IF( mpinei(jpso) >= 0  )   CALL mpi_wait(ml_req1,ml_stat,ml_err)
+      IF( mpinei(jpno) >= 0  )   CALL mpi_wait(ml_req2,ml_stat,ml_err)
       !
       IF( ln_timing ) CALL tic_tac(.FALSE.)
@@ -200,19 +165,14 @@
       ijhom = jpj - nn_hls
       !
-      SELECT CASE ( nbondj )
-      CASE ( -1 )
-         DO jl = 1, iprecj
-            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
-         END DO
-      CASE ( 0 )
-         DO jl = 1, iprecj
-            pt2d(:,jl-kextj) = r2dsn(:,jl,2)
-            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
-         END DO
-      CASE ( 1 )
+      IF( mpinei(jpso) >= 0  ) THEN
          DO jl = 1, iprecj
             pt2d(:,jl-kextj) = r2dsn(:,jl,2)
          END DO
-      END SELECT
+      ENDIF
+       IF( mpinei(jpno) >= 0  ) THEN
+        DO jl = 1, iprecj
+            pt2d(:,ijhom+jl) = r2dns(:,jl,2)
+         END DO
+      ENDIF
       !
    END SUBROUTINE ROUTINE_LNK
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_loc_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_loc_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_loc_generic.h90	(revision 14644)
@@ -2,5 +2,5 @@
 #   if defined SINGLE_PRECISION
 #      define ARRAY_TYPE(i,j,k)    REAL(sp)        , INTENT(in   ) ::   ARRAY_IN(i,j,k)
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 #      define MPI_TYPE MPI_2REAL
 #endif
@@ -8,5 +8,5 @@
 #   else
 #      define ARRAY_TYPE(i,j,k)    REAL(dp)        , INTENT(in   ) ::   ARRAY_IN(i,j,k)
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 #      define MPI_TYPE MPI_2DOUBLE_PRECISION
 #endif
@@ -95,5 +95,5 @@
       zain(2,:) = REAL(index0, PRECISION)
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF( ln_timing ) CALL tic_tac(.TRUE., ld_global = .TRUE.)
       CALL MPI_ALLREDUCE( zain, zaout, 1, MPI_TYPE, MPI_OPERATION ,MPI_COMM_OCE, ierror)
@@ -131,5 +131,5 @@
 #undef MASK_IN
 #undef K_SIZE
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 #   undef MPI_TYPE
 #endif
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_nc_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_nc_generic.h90	(revision 14643)
+++ 	(revision )
@@ -1,950 +1,0 @@
-#   define NAT_IN(k)                cd_nat(k)   
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   define OPT_K(k)                 ,ipf
-#   if defined DIM_2d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_sp)                , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_dp)                , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_sp)                , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_dp)                , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_sp)                , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_dp)                , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#   if defined SINGLE_PRECISION
-#      define PRECISION sp
-#      define MPI_TYPE MPI_REAL
-#   else
-#      define PRECISION dp
-#      define MPI_TYPE MPI_DOUBLE_PRECISION
-#   endif
-
-   SUBROUTINE ROUTINE_NC( cdname, ptab, cd_nat, psgn, kfld, kfillmode, pfillval, lsend, lrecv, ncsten )
-      INTEGER             , INTENT(in   ) ::   kfld        ! number of pt3d arrays
-      ARRAY_TYPE(:,:,:,:,:)                                        ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=*)              , INTENT(in   ) ::   cdname      ! name of the calling subroutine
-      CHARACTER(len=1)              , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)                      , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      INTEGER ,             OPTIONAL, INTENT(in   ) ::   kfillmode   ! filling method for halo over land (default = constant)
-      REAL(wp),             OPTIONAL, INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
-      LOGICAL, DIMENSION(4),OPTIONAL, INTENT(in   ) ::   lsend, lrecv  ! communication with other 4 proc
-      LOGICAL,              OPTIONAL, INTENT(in   ) ::   ncsten      ! 5-point or 9-point stencil
-      !
-      INTEGER  ::   ji,  jj,  jk,  jl,  jf                                      ! dummy loop indices
-      INTEGER  ::   ipi, ipj, ipk, ipl, ipf                                     ! dimension of the input array
-      INTEGER  ::   ishift, ishift2, idx, icount, icount1                       ! local integers
-      INTEGER  ::   idims, idimr, isizet, isizets, isizetr, izsnd, izrcv        ! local integers
-      INTEGER  ::   ierr
-      INTEGER  ::   ifill_we, ifill_ea, ifill_so, ifill_no
-      INTEGER  ::   ifill_web, ifill_eab
-      REAL(wp) ::   zland
-      INTEGER , DIMENSION(MPI_STATUS_SIZE)                        ::   istate              ! for mpi_isend
-      REAL(PRECISION), DIMENSION(:), ALLOCATABLE                  ::   zsnd, zrcv          ! halos arrays
-      INTEGER , DIMENSION(:), ALLOCATABLE                         ::   isizes              ! number of elements to be sent
-      INTEGER , DIMENSION(:), ALLOCATABLE                         ::   isizer              ! number of elements to be received
-      INTEGER , DIMENSION(:), ALLOCATABLE                         ::   idatatys, idatatyr  ! datatype of halos arrays
-      INTEGER (KIND=MPI_ADDRESS_KIND), DIMENSION (:), ALLOCATABLE ::   idispls, idisplr    ! displacement in halos arrays
-      LOGICAL  ::   llsend_we, llsend_ea, llsend_no, llsend_so       ! communication send
-      LOGICAL  ::   llrecv_we, llrecv_ea, llrecv_no, llrecv_so       ! communication receive 
-      LOGICAL  ::   lldo_nfd                                         ! do north pole folding
-      LOGICAL  ::   llncall                                          ! default: 9-point stencil
-
-      !!----------------------------------------------------------------------
-      !
-      ! ----------------------------------------- !
-      !     0. local variables initialization     !
-      ! ----------------------------------------- !
-      !
-      llncall = .TRUE. 
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
-      !
-      IF( narea == 1 .AND. numcom == -1 ) CALL mpp_report( cdname, ipk, ipl, ipf, ld_lbc = .TRUE. )
-      !
-      IF     ( PRESENT(lsend) .AND. PRESENT(lrecv) ) THEN
-         llsend_we = lsend(1)   ;   llsend_ea = lsend(2)   ;   llsend_so = lsend(3)   ;   llsend_no = lsend(4)
-         llrecv_we = lrecv(1)   ;   llrecv_ea = lrecv(2)   ;   llrecv_so = lrecv(3)   ;   llrecv_no = lrecv(4)
-      ELSE IF( PRESENT(lsend) .OR.  PRESENT(lrecv) ) THEN
-         WRITE(ctmp1,*) ' E R R O R : Routine ', cdname, '  is calling lbc_lnk with only one of the two arguments lsend or lrecv'
-         WRITE(ctmp2,*) ' ========== '
-         CALL ctl_stop( ' ', ctmp1, ctmp2, ' ' )
-      ELSE   ! send and receive with every neighbour
-         llsend_we = nbondi ==  1 .OR. nbondi == 0   ! keep for compatibility, should be defined in mppini
-         llsend_ea = nbondi == -1 .OR. nbondi == 0   ! keep for compatibility, should be defined in mppini
-         llsend_so = nbondj ==  1 .OR. nbondj == 0   ! keep for compatibility, should be defined in mppini
-         llsend_no = nbondj == -1 .OR. nbondj == 0   ! keep for compatibility, should be defined in mppini
-         llrecv_we = llsend_we   ;   llrecv_ea = llsend_ea   ;   llrecv_so = llsend_so   ;   llrecv_no = llsend_no
-      END IF
-         
-      lldo_nfd = npolj /= 0                      ! keep for compatibility, should be defined in mppini
-
-      zland = 0._wp                                     ! land filling value: zero by default
-      IF( PRESENT( pfillval ) )   zland = pfillval      ! set land value
-
-
-      ! define the method we will use to fill the halos in each direction
-      IF(              llrecv_we ) THEN   ;   ifill_we = jpfillmpi
-      ELSEIF(           l_Iperio ) THEN   ;   ifill_we = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_we = kfillmode
-      ELSE                                ;   ifill_we = jpfillcst
-      END IF
-      IF(               l_Iperio ) THEN   ;   ifill_web = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_web = kfillmode
-      ELSE                                ;   ifill_web = jpfillcst
-      END IF
-      !
-      IF(              llrecv_ea ) THEN   ;   ifill_ea = jpfillmpi
-      ELSEIF(           l_Iperio ) THEN   ;   ifill_ea = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_ea = kfillmode
-      ELSE                                ;   ifill_ea = jpfillcst
-      END IF
-      IF(               l_Iperio ) THEN   ;   ifill_eab = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_eab = kfillmode
-      ELSE                                ;   ifill_eab = jpfillcst
-      END IF
-      !
-      IF(              llrecv_so ) THEN   ;   ifill_so = jpfillmpi
-      ELSEIF(           l_Jperio ) THEN   ;   ifill_so = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_so = kfillmode
-      ELSE                                ;   ifill_so = jpfillcst
-      END IF
-      !
-      IF(              llrecv_no ) THEN   ;   ifill_no = jpfillmpi
-      ELSEIF(           l_Jperio ) THEN   ;   ifill_no = jpfillperio
-      ELSEIF( PRESENT(kfillmode) ) THEN   ;   ifill_no = kfillmode
-      ELSE                                ;   ifill_no = jpfillcst
-      END IF
-      !
-      IF(PRESENT(ncsten)) llncall = ncsten 
-#if defined PRINT_CAUTION
-      !
-      ! ================================================================================== !
-      ! CAUTION: semi-column notation is often impossible because of the cpp preprocessing !
-      ! ================================================================================== !
-      !
-#endif
-      !
-      ! -------------------------------------------------- !
-      !     1. Do west, east, south and north MPI exchange !
-      ! -------------------------------------------------- !
-      !
-      ! Allocate local temporary arrays to be sent/received. Fill arrays to be sent
-
-      idims = 0
-      idimr = 0
-      izsnd = 0
-      izrcv = 0
-
-      IF(llsend_we) idims = idims + 1
-      IF(llsend_ea) idims = idims + 1
-      IF(llsend_so) idims = idims + 1
-      IF(llsend_no) idims = idims + 1
-
-      idimr = idims
-
-      IF(llncall) THEN
-         IF(noswr .ne. -1) idimr = idimr + 1
-         IF(noser .ne. -1) idimr = idimr + 1
-         IF(nonwr .ne. -1) idimr = idimr + 1
-         IF(noner .ne. -1) idimr = idimr + 1
-      
-         IF(nosws .ne. -1) idims = idims + 1
-         IF(noses .ne. -1) idims = idims + 1
-         IF(nonws .ne. -1) idims = idims + 1
-         IF(nones .ne. -1) idims = idims + 1
-      END IF
-
-      IF(llsend_we) izsnd = izsnd + nn_hls * (jpj - 2*nn_hls) * ipk * ipl * ipf
-      IF(llsend_ea) izsnd = izsnd + nn_hls * (jpj - 2*nn_hls) * ipk * ipl * ipf
-      IF(llsend_so) izsnd = izsnd + (jpi - 2*nn_hls) * nn_hls * ipk * ipl * ipf
-      IF(llsend_no) izsnd = izsnd + (jpi - 2*nn_hls) * nn_hls * ipk * ipl * ipf
-
-      izrcv = izsnd
-      
-      IF(llncall) THEN
-         IF(noswr .ne. -1) izrcv = izrcv + nn_hls * nn_hls * ipk * ipl * ipf
-         IF(noser .ne. -1) izrcv = izrcv + nn_hls * nn_hls * ipk * ipl * ipf
-         IF(nonwr .ne. -1) izrcv = izrcv + nn_hls * nn_hls * ipk * ipl * ipf
-         IF(noner .ne. -1) izrcv = izrcv + nn_hls * nn_hls * ipk * ipl * ipf
-
-         IF(nosws .ne. -1) izsnd = izsnd + nn_hls * nn_hls * ipk * ipl * ipf
-         IF(noses .ne. -1) izsnd = izsnd + nn_hls * nn_hls * ipk * ipl * ipf
-         IF(nonws .ne. -1) izsnd = izsnd + nn_hls * nn_hls * ipk * ipl * ipf
-         IF(nones .ne. -1) izsnd = izsnd + nn_hls * nn_hls * ipk * ipl * ipf
-      END IF
-
-      ALLOCATE(zsnd(izsnd))
-      ALLOCATE(zrcv(izrcv))
-      ALLOCATE(isizes(idims))
-      ALLOCATE(isizer(idimr))
-      ALLOCATE(idatatys(idims))
-      ALLOCATE(idatatyr(idimr))
-      ALLOCATE(idispls(idims))
-      ALLOCATE(idisplr(idimr))
-
-      zrcv(:)=-1
-      zsnd(:)=-1
-      isizes(:) = 0
-      isizer(:) = 0
-      idispls(:) = 0
-      idisplr(:) = 0
-      isizet = 0 
-     
-      idx = 1
-      icount = 1
-
-      IF(llsend_we) THEN
-         DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = nn_hls + 1, jpj - nn_hls  ;  DO ji = 1, nn_hls
-            zsnd(idx) = ARRAY_IN(nn_hls+ji,jj,jk,jl,jf)
-            idx = idx + 1
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-         isizes(icount) = nn_hls * (jpj - 2*nn_hls) * ipk * ipl * ipf
-         IF(icount .gt. 1) isizet = isizet + isizes(icount - 1)
-         idispls(icount) = jpbyt*isizet
-         icount = icount + 1
-      END IF
-
-      IF(llsend_ea) THEN
-         ishift = jpi-2*nn_hls
-
-         DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = nn_hls + 1, jpj - nn_hls  ;  DO ji = 1, nn_hls
-            zsnd(idx) = ARRAY_IN(ishift+ji,jj,jk,jl,jf)
-            idx = idx + 1
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-         isizes(icount) = nn_hls * (jpj - 2*nn_hls) * ipk * ipl * ipf
-         IF(icount .gt. 1) isizet = isizet + isizes(icount - 1)
-         idispls(icount) = jpbyt*isizet
-         icount = icount + 1
-      END IF
-
-      IF(llsend_so) THEN
-         DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1, nn_hls  ;  DO ji = nn_hls + 1, jpi - nn_hls
-            zsnd(idx) = ARRAY_IN(ji,nn_hls+jj,jk,jl,jf)
-            idx = idx + 1
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-         isizes(icount) = (jpi - 2*nn_hls) * nn_hls * ipk * ipl * ipf
-         IF(icount .gt. 1) isizet = isizet + isizes(icount - 1)
-         idispls(icount) = jpbyt*isizet
-         icount = icount + 1
-      END IF
-
-      IF(llsend_no) THEN
-         ishift = jpj-2*nn_hls
-
-         DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1, nn_hls  ;  DO ji = nn_hls + 1, jpi - nn_hls
-            zsnd(idx) = ARRAY_IN(ji,ishift+jj,jk,jl,jf)
-            idx = idx + 1
-         END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-         isizes(icount) = (jpi - 2*nn_hls) * nn_hls * ipk * ipl * ipf
-         IF(icount .gt. 1) isizet = isizet + isizes(icount - 1)
-         idispls(icount) = jpbyt*isizet
-         icount = icount + 1
-      END IF
-
-      isizer(:) = isizes(:)
-      idisplr(:) = idispls(:)
-      
-      icount1 = icount
-      isizets = isizet 
-      isizetr = isizet 
-
-      IF(llncall) THEN
-         IF(noswr .ne. -1) THEN
-            isizer(icount1) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount1 .gt. 1) isizetr = isizetr + isizer(icount1 - 1)
-            idisplr(icount1) = jpbyt*isizetr
-            icount1 = icount1 + 1
-         END IF
-         IF(noser .ne. -1) THEN
-            isizer(icount1) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount1 .gt. 1) isizetr = isizetr + isizer(icount1 - 1)
-            idisplr(icount1) = jpbyt*isizetr
-            icount1 = icount1 + 1
-         END IF
-         IF(nonwr .ne. -1) THEN
-            isizer(icount1) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount1 .gt. 1) isizetr = isizetr + isizer(icount1 - 1)
-            idisplr(icount1) = jpbyt*isizetr
-            icount1 = icount1 + 1
-         END IF
-         IF(noner .ne. -1) THEN
-            isizer(icount1) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount1 .gt. 1) isizetr = isizetr + isizer(icount1 - 1)
-            idisplr(icount1) = jpbyt*isizetr
-            icount1 = icount1 + 1
-         END IF
-
-         IF(nosws .ne. -1) THEN
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1, nn_hls  ;  DO ji = 1, nn_hls
-               zsnd(idx) = ARRAY_IN(nn_hls+ji,nn_hls+jj,jk,jl,jf)
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-            isizes(icount) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount .gt. 1) isizets = isizets + isizes(icount - 1)
-            idispls(icount) = jpbyt*isizets
-            icount = icount + 1
-         END IF
-         IF(noses .ne. -1) THEN
-            ishift = jpi-2*nn_hls
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1, nn_hls  ;  DO ji = 1, nn_hls
-               zsnd(idx) = ARRAY_IN(ji+ishift,nn_hls+jj,jk,jl,jf)
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-            isizes(icount) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount .gt. 1) isizets = isizets + isizes(icount - 1)
-            idispls(icount) = jpbyt*isizets
-            icount = icount + 1
-         END IF
-         IF(nonws .ne. -1) THEN
-            ishift = jpj-2*nn_hls
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1, nn_hls  ;  DO ji = 1, nn_hls
-               zsnd(idx) = ARRAY_IN(nn_hls+ji,jj+ishift,jk,jl,jf)
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-            isizes(icount) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount .gt. 1) isizets = isizets + isizes(icount - 1)
-            idispls(icount) = jpbyt*isizets
-            icount = icount + 1
-         END IF
-         IF(nones .ne. -1) THEN
-            ishift = jpi-2*nn_hls
-            ishift2 = jpj-2*nn_hls
-            DO jf = 1, ipf  ;  DO jl = 1, ipl  ;  DO jk = 1, ipk  ;  DO jj = 1, nn_hls  ;  DO ji = 1, nn_hls
-               zsnd(idx) = ARRAY_IN(ji+ishift,jj+ishift2,jk,jl,jf)
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-            isizes(icount) = nn_hls * nn_hls * ipk * ipl * ipf
-            IF(icount .gt. 1) isizets = isizets + isizes(icount - 1)
-            idispls(icount) = jpbyt*isizets
-            icount = icount + 1
-         END IF
-      END IF
-
-      idatatys(:) = MPI_TYPE
-      idatatyr(:) = MPI_TYPE
-
-      IF(llncall) THEN
-         IF( ln_timing ) CALL tic_tac(.TRUE.)
-         CALL mpi_neighbor_alltoallw (zsnd, isizes, idispls, idatatys, zrcv, isizer, idisplr, idatatyr, mpi_nc_all_com, ierr)
-         IF( ln_timing ) CALL tic_tac(.FALSE.)
-      ELSE
-         IF( ln_timing ) CALL tic_tac(.TRUE.)
-         CALL mpi_neighbor_alltoallw (zsnd, isizes, idispls, idatatys, zrcv, isizer, idisplr, idatatyr, mpi_nc_com, ierr)
-         IF( ln_timing ) CALL tic_tac(.FALSE.)
-      END IF
-
-      ! --------------------------------------------------- !
-      !     2. Fill east and west north and south halos     !
-      ! --------------------------------------------------- !
-      !
-      !!! Patch to solve MPI3 bug when we have only two processes columns
-      IF(jpni .eq. 2) THEN
-         ! ---------------------
-         ! 2.2 fill eastern halo
-         ! ---------------------
-         idx = 1
-         ishift = jpi - nn_hls                ! fill halo from ji = jpi-nn_hls+1 to jpi
-         SELECT CASE ( ifill_ea )
-         CASE ( jpfillnothing )               ! no filling
-         CASE ( jpfillmpi   )                 ! use data received by MPI
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = nn_hls + 1, jpj - nn_hls   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv(idx)   ! jpi - nn_hls + 1 -> jpi
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillperio )                 ! use east-weast periodicity
-            ishift2 = nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-         ! ----------------------
-         ! 2.1 fill weastern halo
-         ! ----------------------
-         SELECT CASE ( ifill_we )
-         CASE ( jpfillnothing )               ! no filling
-         CASE ( jpfillmpi   )                 ! use data received by MPI
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = nn_hls + 1, jpj - nn_hls   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> nn_hls
-               idx = idx + 1
-            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillperio )                 ! use east-weast periodicity
-            ishift2 = jpi - 2 * nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-
-      ELSE
-
-         ! ----------------------
-         ! 2.1 fill weastern halo
-         ! ----------------------
-         idx = 1
-         SELECT CASE ( ifill_we )
-         CASE ( jpfillnothing )               ! no filling 
-         CASE ( jpfillmpi   )                 ! use data received by MPI 
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = nn_hls + 1, jpj - nn_hls   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> nn_hls
-               idx = idx + 1
-            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillperio )                 ! use east-weast periodicity
-            ishift2 = jpi - 2 * nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-         ! ---------------------
-         ! 2.2 fill eastern halo
-         ! ---------------------
-         ishift = jpi - nn_hls                ! fill halo from ji = jpi-nn_hls+1 to jpi 
-         SELECT CASE ( ifill_ea )
-         CASE ( jpfillnothing )               ! no filling 
-         CASE ( jpfillmpi   )                 ! use data received by MPI 
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = nn_hls + 1, jpj - nn_hls   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zrcv(idx)   ! jpi - nn_hls + 1 -> jpi
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillperio )                 ! use east-weast periodicity
-            ishift2 = nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, jpj   ;   DO ji = 1, nn_hls
-               ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-
-      ENDIF
-
-      !!! Patch to solve MPI3 bug when we have only two processes rows
-      IF(jpnj .eq. 2) THEN
-         ! ----------------------
-         ! 2.3 fill northern halo
-         ! ----------------------
-         ishift = jpj - nn_hls                ! fill halo from jj = jpj-nn_hls+1 to jpj 
-         SELECT CASE ( ifill_no )
-         CASE ( jpfillnothing )               ! no filling 
-         CASE ( jpfillmpi   )                 ! use data received by MPI 
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = nn_hls + 1, jpi - nn_hls
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zrcv(idx)   ! jpj-nn_hls+1 -> jpj
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-            IF(nonwr .eq. -1) THEN
-               ishift = jpj - nn_hls
-               SELECT CASE ( ifill_web )
-                  CASE ( jpfillperio )
-                     ishift2 = jpi - 2 * nn_hls
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-            IF(noner .eq. -1) THEN
-               ishift = jpi - nn_hls
-               ishift2 = jpj - nn_hls
-               SELECT CASE ( ifill_eab )
-                  CASE ( jpfillperio )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift2, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ji,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift2, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift2, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-         CASE ( jpfillperio )                 ! use north-south periodicity
-            ishift2 = nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-
-         ! ----------------------
-         ! 2.4 fill southern halo
-         ! ----------------------
-         SELECT CASE ( ifill_so )
-         CASE ( jpfillnothing )               ! no filling 
-         CASE ( jpfillmpi   )                 ! use data received by MPI 
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = nn_hls + 1, jpi - nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> nn_hls
-               idx = idx + 1
-            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-            IF(noswr .eq. -1) THEN
-               SELECT CASE ( ifill_web )
-                  CASE ( jpfillperio )
-                     ishift2 = jpi - 2 * nn_hls
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-            IF(noser .eq. -1) THEN
-               ishift = jpi - nn_hls
-               SELECT CASE ( ifill_eab )
-                  CASE ( jpfillperio )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ji+nn_hls,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-         CASE ( jpfillperio )                 ! use north-south periodicity
-            ishift2 = jpj - 2 * nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,nn_hls+1,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-      ELSE
-         ! ----------------------
-         ! 2.3 fill southern halo
-         ! ----------------------
-         SELECT CASE ( ifill_so )
-         CASE ( jpfillnothing )               ! no filling 
-         CASE ( jpfillmpi   )                 ! use data received by MPI 
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = nn_hls + 1, jpi - nn_hls
-               ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)   ! 1 -> nn_hls
-               idx = idx + 1
-            END DO;   END DO   ;   END DO   ;   END DO   ;   END DO
-            IF(noswr .eq. -1) THEN
-               SELECT CASE ( ifill_web )
-                  CASE ( jpfillperio )
-                     ishift2 = jpi - 2 * nn_hls
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-            IF(noser .eq. -1) THEN
-               ishift = jpi - nn_hls
-               SELECT CASE ( ifill_eab )
-                  CASE ( jpfillperio )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ji+nn_hls,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-         CASE ( jpfillperio )                 ! use north-south periodicity
-            ishift2 = jpj - 2 * nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ji,nn_hls+1,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-
-         ! ----------------------
-         ! 2.4 fill northern halo
-         ! ----------------------
-         ishift = jpj - nn_hls                ! fill halo from jj = jpj-nn_hls+1 to jpj 
-         SELECT CASE ( ifill_no )
-         CASE ( jpfillnothing )               ! no filling 
-         CASE ( jpfillmpi   )                 ! use data received by MPI 
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = nn_hls + 1, jpi - nn_hls
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zrcv(idx)   ! jpj-nn_hls+1 -> jpj
-               idx = idx + 1
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-            IF(nonwr .eq. -1) THEN
-               ishift = jpj - nn_hls
-               SELECT CASE ( ifill_web )
-                  CASE ( jpfillperio )
-                     ishift2 = jpi - 2 * nn_hls
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(ishift2+ji,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = ARRAY_IN(nn_hls+1,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-            IF(noner .eq. -1) THEN
-               ishift = jpi - nn_hls
-               ishift2 = jpj - nn_hls
-               SELECT CASE ( ifill_eab )
-                  CASE ( jpfillperio )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift2, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ji,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-
-                  CASE ( jpfillcopy  )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift2, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = ARRAY_IN(ishift,jj,jk,jl,jf)
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                  CASE ( jpfillcst   )
-                     DO jf = 1, ipf  ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1 + ishift2, jpj   ;  DO ji = 1, nn_hls
-                        ARRAY_IN(ishift+ji,jj,jk,jl,jf) = zland
-                     END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-               END SELECT
-            END IF
-         CASE ( jpfillperio )                 ! use north-south periodicity
-            ishift2 = nn_hls
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift2+jj,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcopy  )                 ! filling with inner domain values
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = ARRAY_IN(ji,ishift,jk,jl,jf)
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         CASE ( jpfillcst   )                 ! filling with constant value
-            DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;   DO ji = 1, jpi
-               ARRAY_IN(ji,ishift+jj,jk,jl,jf) = zland
-            END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-         END SELECT
-      ENDIF
-
-      IF(llncall) THEN
-
-         !!! Patch to solve MPI3 bug when we have only two processes columns
-         IF(jpni .eq. 2) THEN
-            !!! Patch to solve MPI3 bug when we have only two processes rows
-            IF(jpnj .eq. 2) THEN
-               ! ---------------------------
-               ! 2.5 fill east-nouthern halo
-               ! ---------------------------
-                 IF(noner .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    ishift2 = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj+ishift2,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.6 fill west-nouthern halo
-               ! ---------------------------
-                 IF(nonwr .ne. -1) THEN
-                    ishift = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj+ishift,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.7 fill east-southern halo
-               ! ---------------------------
-                 IF(noser .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.8 fill west-southern halo
-               ! ---------------------------
-                 IF(noswr .ne. -1) THEN
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-
-            ELSE
-               ! ---------------------------
-               ! 2.5 fill east-southern halo
-               ! ---------------------------
-                 IF(noser .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.6 fill west-southern halo
-               ! ---------------------------
-                 IF(noswr .ne. -1) THEN
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.7 fill east-nouthern halo
-               ! ---------------------------
-                 IF(noner .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    ishift2 = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj+ishift2,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.8 fill west-nouthern halo
-               ! ---------------------------
-                 IF(nonwr .ne. -1) THEN
-                    ishift = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj+ishift,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-            ENDIF
-         ELSE
-            !!! Patch to solve MPI3 bug when we have only two processes rows
-            IF(jpnj .eq. 2) THEN
-               ! ---------------------------
-               ! 2.5 fill west-nouthern halo
-               ! ---------------------------
-                 IF(nonwr .ne. -1) THEN
-                    ishift = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj+ishift,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.6 fill east-nouthern halo
-               ! ---------------------------
-                 IF(noner .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    ishift2 = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj+ishift2,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.7 fill west-southern halo
-               ! ---------------------------
-                 IF(noswr .ne. -1) THEN
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.8 fill east-southern halo
-               ! ---------------------------
-                 IF(noser .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-
-            ELSE
-               ! ---------------------------
-               ! 2.5 fill west-southern halo
-               ! ---------------------------
-                 IF(noswr .ne. -1) THEN
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.6 fill east-southern halo
-               ! ---------------------------
-                 IF(noser .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.7 fill west-nouthern halo
-               ! ---------------------------
-                 IF(nonwr .ne. -1) THEN
-                    ishift = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji,jj+ishift,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-               ! ---------------------------
-               ! 2.8 fill east-nouthern halo
-               ! ---------------------------
-                 IF(noner .ne. -1) THEN
-                    ishift = jpi - nn_hls
-                    ishift2 = jpj - nn_hls
-                    DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk   ;   DO jj = 1, nn_hls   ;  DO ji = 1, nn_hls
-                       ARRAY_IN(ji+ishift,jj+ishift2,jk,jl,jf) = zrcv(idx)
-                       idx = idx + 1
-                    END DO   ;   END DO   ;   END DO   ;   END DO   ;   END DO
-                 END IF
-            ENDIF
-         END IF
-      END IF
-
-
-      !
-      ! -------------------------------------------- !
-      !     3. deallocate local temporary arrays     !
-      ! -------------------------------------------- !
-      !
-      DEALLOCATE( zsnd )
-      DEALLOCATE( zrcv )
-      DEALLOCATE(isizes)
-      DEALLOCATE(isizer)
-      DEALLOCATE(idatatys)
-      DEALLOCATE(idatatyr)
-      DEALLOCATE(idispls)
-      DEALLOCATE(idisplr)
-      !
-      ! ------------------------------- !
-      !     4. north fold treatment     !
-      ! ------------------------------- !
-      !
-      IF( lldo_nfd .AND. ifill_no /= jpfillnothing ) THEN
-         !
-         SELECT CASE ( jpni )
-         CASE ( 1 )     ;   CALL lbc_nfd( ptab, NAT_IN(:), SGN_IN(:)                  OPT_K(:) )   ! only 1 northern proc, no mpp
-         CASE DEFAULT   ;   CALL mpp_nfd( ptab, NAT_IN(:), SGN_IN(:), ifill_no, zland OPT_K(:) )   ! for all northern procs.
-         END SELECT
-         !
-         ifill_no = jpfillnothing  ! force to do nothing for the northern halo as we just done the north pole folding
-         !
-      ENDIF
-
-   END SUBROUTINE ROUTINE_NC
-
-#undef PRECISION
-#undef ARRAY_TYPE
-#undef NAT_IN
-#undef SGN_IN
-#undef ARRAY_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef OPT_K
-#undef MPI_TYPE
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_nfd_generic.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_nfd_generic.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mpp_nfd_generic.h90	(revision 14644)
@@ -1,91 +1,11 @@
-#  define PASTE(a) a
-#  define ADD_TRAIL_USCORE(a) PASTE(a)_
-#  define CONCATENATE(a,b) ADD_TRAIL_USCORE(a)b
 
-#if defined MULTI
-#   define NAT_IN(k)                cd_nat(k)   
-#   define SGN_IN(k)                psgn(k)
-#   define F_SIZE(ptab)             kfld
-#   define LBC_ARG                  (jf)
-#   if defined DIM_2d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_sp)     , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_2D_dp)     , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt2d(i,j)
-#      define K_SIZE(ptab)             1
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_3d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_sp)     , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_3D_dp)     , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt3d(i,j,k)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt3d,3)
-#      define L_SIZE(ptab)             1
-#   endif
-#   if defined DIM_4d
-#      if defined SINGLE_PRECISION
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_sp)     , INTENT(inout) ::   ptab(f)
-#      else
-#         define ARRAY_TYPE(i,j,k,l,f)    TYPE(PTR_4D_dp)     , INTENT(inout) ::   ptab(f)
-#      endif
-#      define ARRAY_IN(i,j,k,l,f)      ptab(f)%pt4d(i,j,k,l)
-#      define K_SIZE(ptab)             SIZE(ptab(1)%pt4d,3)
-#      define L_SIZE(ptab)             SIZE(ptab(1)%pt4d,4)
-#   endif
-#else
-!                          !==  IN: ptab is an array  ==!
-#   if defined SINGLE_PRECISION
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(sp)         , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   else
-#      define ARRAY_TYPE(i,j,k,l,f)    REAL(dp)         , INTENT(inout) ::   ARRAY_IN(i,j,k,l,f)
-#   endif
-#   define NAT_IN(k)                cd_nat
-#   define SGN_IN(k)                psgn
-#   define F_SIZE(ptab)             1
-#   define LBC_ARG
-#   if defined DIM_2d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j)
-#      define K_SIZE(ptab)          1
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_3d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          1
-#   endif
-#   if defined DIM_4d
-#      define ARRAY_IN(i,j,k,l,f)   ptab(i,j,k,l)
-#      define K_SIZE(ptab)          SIZE(ptab,3)
-#      define L_SIZE(ptab)          SIZE(ptab,4)
-#   endif
-#endif
-
-# if defined SINGLE_PRECISION
-#    define PRECISION sp
-#    define SENDROUTINE mppsend_sp
-#    define RECVROUTINE mpprecv_sp
-#    define MPI_TYPE MPI_REAL
-#    define HUGEVAL(x)   HUGE(CONCATENATE(x,sp))
-# else
-#    define PRECISION dp
-#    define SENDROUTINE mppsend_dp
-#    define RECVROUTINE mpprecv_dp
-#    define MPI_TYPE MPI_DOUBLE_PRECISION
-#    define HUGEVAL(x)   HUGE(CONCATENATE(x,dp))
-# endif
-
-   SUBROUTINE ROUTINE_NFD( ptab, cd_nat, psgn, kfillmode, pfillval, kfld )
-      !!----------------------------------------------------------------------
-      ARRAY_TYPE(:,:,:,:,:)   ! array or pointer of arrays on which the boundary condition is applied
-      CHARACTER(len=1) , INTENT(in   ) ::   NAT_IN(:)   ! nature of array grid-points
-      REAL(wp)         , INTENT(in   ) ::   SGN_IN(:)   ! sign used across the north fold boundary
-      INTEGER          , INTENT(in   ) ::   kfillmode   ! filling method for halo over land 
-      REAL(wp)         , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
-      INTEGER, OPTIONAL, INTENT(in   ) ::   kfld        ! number of pt3d arrays
+   SUBROUTINE mpp_nfd_/**/PRECISION( ptab, cd_nat, psgn, kfillmode, pfillval, khls, kfld )
+      TYPE(PTR_4d_/**/PRECISION),  DIMENSION(:), INTENT(inout) ::   ptab        ! pointer of arrays on which apply the b.c.
+      CHARACTER(len=1), DIMENSION(:), INTENT(in   ) ::   cd_nat      ! nature of array grid-points
+      REAL(PRECISION),  DIMENSION(:), INTENT(in   ) ::   psgn        ! sign used across the north fold boundary
+      INTEGER                       , INTENT(in   ) ::   kfillmode   ! filling method for halo over land 
+      REAL(PRECISION)               , INTENT(in   ) ::   pfillval    ! background value (used at closed boundaries)
+      INTEGER                       , INTENT(in   ) ::   khls        ! halo size, default = nn_hls
+      INTEGER                       , INTENT(in   ) ::   kfld        ! number of pt3d arrays
       !
       LOGICAL  ::   ll_add_line
@@ -99,5 +19,4 @@
       INTEGER, DIMENSION (jpmaxngh)       ::   ml_req_nf   ! for mpi_isend when avoiding mpi_allgather
       INTEGER                             ::   ml_err      ! for mpi_isend when avoiding mpi_allgather
-      INTEGER, DIMENSION(MPI_STATUS_SIZE) ::   ml_stat     ! for mpi_isend when avoiding mpi_allgather
       !                                                    ! Workspace for message transfers avoiding mpi_allgather
       INTEGER                             ::   ipj_b       ! sum of lines for all multi fields
@@ -107,13 +26,14 @@
       INTEGER , DIMENSION(:)          , ALLOCATABLE ::   ipj_s ! number of sent lines
       REAL(PRECISION), DIMENSION(:,:,:,:)    , ALLOCATABLE ::   ztabb, ztabr, ztabw  ! buffer, receive and work arrays
-      REAL(PRECISION), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   ztabglo, znorthloc
+      REAL(PRECISION), DIMENSION(:,:,:,:,:)  , ALLOCATABLE ::   znorthloc
       REAL(PRECISION), DIMENSION(:,:,:,:,:,:), ALLOCATABLE ::   znorthglo
+      TYPE(PTR_4D_/**/PRECISION), DIMENSION(:), ALLOCATABLE ::   ztabglo        ! array or pointer of arrays on which apply the b.c.
       !!----------------------------------------------------------------------
       !
-      ipk = K_SIZE(ptab)   ! 3rd dimension
-      ipl = L_SIZE(ptab)   ! 4th    -
-      ipf = F_SIZE(ptab)   ! 5th    -      use in "multi" case (array of pointers)
+      ipk = SIZE(ptab(1)%pt4d,3)
+      ipl = SIZE(ptab(1)%pt4d,4)
+      ipf = kfld
       !
-      IF( l_north_nogather ) THEN      !==  no allgather exchanges  ==!
+      IF( ln_nnogather ) THEN      !==  no allgather exchanges  ==!
 
          !   ---   define number of exchanged lines   ---
@@ -122,12 +42,12 @@
          !
          ! However, some other points are duplicated in the north pole folding:
-         !  - jperio=[34], grid=T : half of the last line (jpiglo/2+2:jpiglo-nn_hls)
-         !  - jperio=[34], grid=U : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
-         !  - jperio=[34], grid=V : all the last line nn_hls+1 and (nn_hls+2:jpiglo-nn_hls)
-         !  - jperio=[34], grid=F : all the last line (nn_hls+1:jpiglo-nn_hls)
-         !  - jperio=[56], grid=T : 2 points of the last line (jpiglo/2+1 and jpglo-nn_hls)
-         !  - jperio=[56], grid=U : no points are duplicated
-         !  - jperio=[56], grid=V : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
-         !  - jperio=[56], grid=F : half of the last line (jpiglo/2+1:jpiglo-nn_hls-1)
+         !  - c_NFtype='T', grid=T : half of the last line (jpiglo/2+2:jpiglo-nn_hls)
+         !  - c_NFtype='T', grid=U : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
+         !  - c_NFtype='T', grid=V : all the last line nn_hls+1 and (nn_hls+2:jpiglo-nn_hls)
+         !  - c_NFtype='T', grid=F : all the last line (nn_hls+1:jpiglo-nn_hls)
+         !  - c_NFtype='F', grid=T : 2 points of the last line (jpiglo/2+1 and jpglo-nn_hls)
+         !  - c_NFtype='F', grid=U : no points are duplicated
+         !  - c_NFtype='F', grid=V : half of the last line (jpiglo/2+1:jpiglo-nn_hls)
+         !  - c_NFtype='F', grid=F : half of the last line (jpiglo/2+1:jpiglo-nn_hls-1)
          ! The order of the calculations may differ for these duplicated points (as, for example jj+1 becomes jj-1)
          ! This explain why these duplicated points may have different values even if they are at the exact same location.
@@ -145,8 +65,8 @@
          IF( ll_add_line ) THEN
             DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
-               ipj_s(jf) = nn_hls + COUNT( (/ npolj == 3 .OR. npolj == 4 .OR. NAT_IN(jf) == 'V' .OR. NAT_IN(jf) == 'F' /) ) 
+               ipj_s(jf) = khls + COUNT( (/ c_NFtype == 'T' .OR. cd_nat(jf) == 'V' .OR. cd_nat(jf) == 'F' /) ) 
             END DO
          ELSE
-            ipj_s(:) = nn_hls
+            ipj_s(:) = khls
          ENDIF
          
@@ -159,21 +79,21 @@
          DO jf = 1, ipf                      ! Loop over the number of arrays to be processed
             !
-            SELECT CASE ( npolj )
-            CASE ( 3, 4 )                       ! *  North fold  T-point pivot
-               SELECT CASE ( NAT_IN(jf) )
+            IF( c_NFtype == 'T' ) THEN          ! *  North fold  T-point pivot
+               SELECT CASE ( cd_nat(jf) )
                CASE ( 'T', 'W', 'U' )   ;   i012 = 1   ! T-, U-, W-point
                CASE ( 'V', 'F'      )   ;   i012 = 2   ! V-, F-point
                END SELECT
-            CASE ( 5, 6 )                       ! *  North fold  F-point pivot
-               SELECT CASE ( NAT_IN(jf) )
+            ENDIF
+            IF( c_NFtype == 'F' ) THEN          ! *  North fold  F-point pivot
+               SELECT CASE ( cd_nat(jf) )
                CASE ( 'T', 'W', 'U' )   ;   i012 = 0   ! T-, U-, W-point
                CASE ( 'V', 'F'      )   ;   i012 = 1   ! V-, F-point
                END SELECT
-            END SELECT
+            ENDIF
                !
             DO jj = 1, ipj_s(jf)
                ij1 = ij1 + 1
                jj_b(jj,jf) = ij1
-               jj_s(jj,jf) = jpj - 2*nn_hls + jj - i012
+               jj_s(jj,jf) = jpj - 2*khls + jj - i012
             END DO
             !
@@ -188,8 +108,8 @@
                ij2 = jj_s(jj,jf)
                DO ji = 1, jpi
-                  ztabb(ji,ij1,jk,jl) = ARRAY_IN(ji,ij2,jk,jl,jf)
+                  ztabb(ji,ij1,jk,jl) = ptab(jf)%pt4d(ji,ij2,jk,jl)
                END DO
                DO ji = jpi+1, jpimax
-                  ztabb(ji,ij1,jk,jl) = HUGEVAL(0.)   ! avoid sending uninitialized values (make sure we don't use it)
+                  ztabb(ji,ij1,jk,jl) = HUGE(0._/**/PRECISION)   ! avoid sending uninitialized values (make sure we don't use it)
                END DO
             END DO
@@ -203,5 +123,7 @@
             iproc = nfproc(isendto(jr))
             IF( iproc /= narea-1 .AND. iproc /= -1 ) THEN
-               CALL SENDROUTINE( 5, ztabb, ibuffsize, iproc, ml_req_nf(jr) )
+#if ! defined key_mpi_off
+               CALL MPI_ISEND( ztabb, ibuffsize, MPI_TYPE, iproc, 5, mpi_comm_oce, ml_req_nf(jr), ierr )
+#endif
             ENDIF
          END DO
@@ -216,9 +138,9 @@
             ipi   = nfjpi (ipni)
             !
-            IF( ipni ==   1  ) THEN   ;   iis0 =   1            ! domain  left side: as e-w comm already done -> from 1st column
-            ELSE                      ;   iis0 =   1 + nn_hls   ! default: -> from inner domain 
-            ENDIF
-            IF( ipni == jpni ) THEN   ;   iie0 = ipi            ! domain right side: as e-w comm already done -> until last column
-            ELSE                      ;   iie0 = ipi - nn_hls   ! default: -> until inner domain 
+            IF( ipni ==   1  ) THEN   ;   iis0 =   1          ! domain  left side: as e-w comm already done -> from 1st column
+            ELSE                      ;   iis0 =   1 + khls   ! default: -> from inner domain 
+            ENDIF
+            IF( ipni == jpni ) THEN   ;   iie0 = ipi          ! domain right side: as e-w comm already done -> until last column
+            ELSE                      ;   iie0 = ipi - khls   ! default: -> until inner domain 
             ENDIF
             impp = nfimpp(ipni) - nfimpp(isendto(1))
@@ -234,5 +156,5 @@
                         ij2 = jj_s(jj,jf)
                         DO ji = iis0, iie0
-                           ztabr(impp+ji,ij1,jk,jl) = ARRAY_IN(Nis0,ij2,jk,jl,jf)   ! chose to take the 1st iner domain point
+                           ztabr(impp+ji,ij1,jk,jl) = ptab(jf)%pt4d(Nis0,ij2,jk,jl)   ! chose to take the 1st iner domain point
                         END DO
                      END DO
@@ -255,5 +177,5 @@
                      ij2 = jj_s(jj,jf)
                      DO ji = iis0, iie0
-                        ztabr(impp+ji,ij1,jk,jl) = ARRAY_IN(ji,ij2,jk,jl,jf)
+                        ztabr(impp+ji,ij1,jk,jl) = ptab(jf)%pt4d(ji,ij2,jk,jl)
                      END DO
                   END DO
@@ -262,5 +184,7 @@
             ELSE                               ! get data from a neighbour trough communication
                !  
-               CALL RECVROUTINE(5, ztabw, ibuffsize, iproc)
+#if ! defined key_mpi_off
+               CALL MPI_RECV( ztabw, ibuffsize, MPI_TYPE, iproc, 5, mpi_comm_oce, MPI_STATUS_IGNORE, ierr )
+#endif
                DO jl = 1, ipl   ;   DO jk = 1, ipk
                   DO jj = 1, ipj_b
@@ -282,5 +206,5 @@
             ij1 = jj_b(       1 ,jf)
             ij2 = jj_b(ipj_s(jf),jf)
-            CALL lbc_nfd_nogather( ARRAY_IN(:,:,:,:,jf), ztabr(:,ij1:ij2,:,:), cd_nat LBC_ARG, psgn LBC_ARG )
+            CALL lbc_nfd_nogather( ptab(jf)%pt4d(:,:,:,:), ztabr(:,ij1:ij2,:,:), cd_nat(jf), psgn(jf), khls )
          END DO
          !
@@ -290,5 +214,5 @@
             iproc = nfproc(isendto(jr))
             IF( iproc /= narea-1 .AND. iproc /= -1 ) THEN
-               CALL mpi_wait( ml_req_nf(jr), ml_stat, ml_err )   ! put the wait at the very end just before the deallocate
+               CALL mpi_wait( ml_req_nf(jr), MPI_STATUS_IGNORE, ml_err )   ! put the wait at the very end just before the deallocate
             ENDIF
          END DO
@@ -298,9 +222,9 @@
          !
          ! how many lines do we exchange at max? -> ipj    (no further optimizations in this case...)
-         ipj =      nn_hls + 2
+         ipj =      khls + 2
          ! how many lines do we     need at max? -> ipj2   (no further optimizations in this case...)
-         ipj2 = 2 * nn_hls + 2
-         !
-         i0max = jpimax - 2 * nn_hls
+         ipj2 = 2 * khls + 2
+         !
+         i0max = jpimax - 2 * khls
          ibuffsize = i0max * ipj * ipk * ipl * ipf
          ALLOCATE( znorthloc(i0max,ipj,ipk,ipl,ipf), znorthglo(i0max,ipj,ipk,ipl,ipf,ndim_rank_north) )
@@ -311,8 +235,8 @@
                DO ji = 1, Ni_0
                   ii2 = Nis0 - 1 + ji                       ! inner domain: Nis0 to Nie0
-                  znorthloc(ji,jj,jk,jl,jf) = ARRAY_IN(ii2,ij2,jk,jl,jf)
+                  znorthloc(ji,jj,jk,jl,jf) = ptab(jf)%pt4d(ii2,ij2,jk,jl)
                END DO
                DO ji = Ni_0+1, i0max
-                  znorthloc(ji,jj,jk,jl,jf) = HUGEVAL(0.)   ! avoid sending uninitialized values (make sure we don't use it)
+                  znorthloc(ji,jj,jk,jl,jf) = HUGE(0._/**/PRECISION)   ! avoid sending uninitialized values (make sure we don't use it)
                END DO
             END DO
@@ -321,5 +245,5 @@
          ! start waiting time measurement
          IF( ln_timing ) CALL tic_tac(.TRUE.)
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
          CALL MPI_ALLGATHER( znorthloc, ibuffsize, MPI_TYPE, znorthglo, ibuffsize, MPI_TYPE, ncomm_north, ierr )
 #endif
@@ -327,12 +251,15 @@
          IF( ln_timing ) CALL tic_tac(.FALSE.)
          DEALLOCATE( znorthloc )
-         ALLOCATE( ztabglo(jpiglo,ipj2,ipk,ipl,ipf) )
-         !
-         ! need to fill only the first ipj lines of ztabglo as lbc_nfd don't use the last nn_hls lines
+         ALLOCATE( ztabglo(ipf) )
+         DO jf = 1, ipf
+            ALLOCATE( ztabglo(jf)%pt4d(jpiglo,ipj2,ipk,ipl) )
+         END DO
+         !
+         ! need to fill only the first ipj lines of ztabglo as lbc_nfd don't use the last khls lines
          ijnr = 0
          DO jr = 1, jpni                                                        ! recover the global north array
             iproc = nfproc(jr)
             impp  = nfimpp(jr)
-            ipi   = nfjpi( jr) - 2 * nn_hls                       ! corresponds to Ni_0 but for subdomain iproc
+            ipi   = nfjpi( jr) - 2 * khls                       ! corresponds to Ni_0 but for subdomain iproc
             IF( iproc == -1 ) THEN   ! No neighbour (land proc that was suppressed)
               !
@@ -344,6 +271,6 @@
                         ij2 = jpj - ipj2 + jj                    ! the first ipj lines of the last ipj2 lines
                         DO ji = 1, ipi
-                           ii1 = impp + nn_hls + ji - 1          ! corresponds to mig(nn_hls + ji) but for subdomain iproc
-                           ztabglo(ii1,jj,jk,jl,jf) = ARRAY_IN(Nis0,ij2,jk,jl,jf)   ! chose to take the 1st iner domain point
+                           ii1 = impp + khls + ji - 1            ! corresponds to mig(khls + ji) but for subdomain iproc
+                           ztabglo(jf)%pt4d(ii1,jj,jk,jl) = ptab(jf)%pt4d(Nis0,ij2,jk,jl) ! chose to take the 1st inner domain point
                         END DO
                      END DO
@@ -353,6 +280,6 @@
                      DO jj = 1, ipj
                         DO ji = 1, ipi
-                           ii1 = impp + nn_hls + ji - 1          ! corresponds to mig(nn_hls + ji) but for subdomain iproc
-                           ztabglo(ii1,jj,jk,jl,jf) = pfillval
+                           ii1 = impp + khls + ji - 1            ! corresponds to mig(khls + ji) but for subdomain iproc
+                           ztabglo(jf)%pt4d(ii1,jj,jk,jl) = pfillval
                         END DO
                      END DO
@@ -365,6 +292,6 @@
                   DO jj = 1, ipj
                      DO ji = 1, ipi
-                        ii1 = impp + nn_hls + ji - 1             ! corresponds to mig(nn_hls + ji) but for subdomain iproc
-                        ztabglo(ii1,jj,jk,jl,jf) = znorthglo(ji,jj,jk,jl,jf,ijnr)
+                        ii1 = impp + khls + ji - 1               ! corresponds to mig(khls + ji) but for subdomain iproc
+                        ztabglo(jf)%pt4d(ii1,jj,jk,jl) = znorthglo(ji,jj,jk,jl,jf,ijnr)
                      END DO
                   END DO
@@ -376,10 +303,10 @@
          !
          DO jf = 1, ipf
-            CALL lbc_nfd( ztabglo(:,:,:,:,jf), cd_nat LBC_ARG, psgn LBC_ARG )   ! North fold boundary condition
+            CALL lbc_nfd( ztabglo(jf:jf), cd_nat(jf:jf), psgn(jf:jf), khls, 1 )   ! North fold boundary condition
             DO jl = 1, ipl   ;   DO jk = 1, ipk                  ! e-w periodicity
-               DO jj = 1, nn_hls + 1
-                  ij1 = ipj2 - (nn_hls + 1) + jj                 ! need only the last nn_hls + 1 lines until ipj2
-                  ztabglo(              1:nn_hls,ij1,jk,jl,jf) = ztabglo(jpiglo-2*nn_hls+1:jpiglo-nn_hls,ij1,jk,jl,jf)
-                  ztabglo(jpiglo-nn_hls+1:jpiglo,ij1,jk,jl,jf) = ztabglo(         nn_hls+1:     2*nn_hls,ij1,jk,jl,jf)
+               DO jj = 1, khls + 1
+                  ij1 = ipj2 - (khls + 1) + jj                   ! need only the last khls + 1 lines until ipj2
+                  ztabglo(jf)%pt4d(            1:  khls,ij1,jk,jl) = ztabglo(jf)%pt4d(jpiglo-2*khls+1:jpiglo-khls,ij1,jk,jl)
+                  ztabglo(jf)%pt4d(jpiglo-khls+1:jpiglo,ij1,jk,jl) = ztabglo(jf)%pt4d(         khls+1:     2*khls,ij1,jk,jl)
                END DO
             END DO   ;   END DO
@@ -387,31 +314,21 @@
          !
          DO jf = 1, ipf   ;   DO jl = 1, ipl   ;   DO jk = 1, ipk               ! Scatter back to ARRAY_IN
-            DO jj = 1, nn_hls + 1
-               ij1 = jpj  - (nn_hls + 1) + jj   ! last nn_hls + 1 lines until jpj
-               ij2 = ipj2 - (nn_hls + 1) + jj   ! last nn_hls + 1 lines until ipj2
+            DO jj = 1, khls + 1
+               ij1 = jpj  - (khls + 1) + jj   ! last khls + 1 lines until jpj
+               ij2 = ipj2 - (khls + 1) + jj   ! last khls + 1 lines until ipj2
                DO ji= 1, jpi
                   ii2 = mig(ji)
-                  ARRAY_IN(ji,ij1,jk,jl,jf) = ztabglo(ii2,ij2,jk,jl,jf)
+                  ptab(jf)%pt4d(ji,ij1,jk,jl) = ztabglo(jf)%pt4d(ii2,ij2,jk,jl)
                END DO
             END DO
          END DO   ;   END DO   ;   END DO
          !
+         DO jf = 1, ipf
+            DEALLOCATE( ztabglo(jf)%pt4d )
+         END DO
          DEALLOCATE( ztabglo )
          !
       ENDIF   ! l_north_nogather
       !
-   END SUBROUTINE ROUTINE_NFD
+   END SUBROUTINE mpp_nfd_/**/PRECISION
 
-#undef PRECISION
-#undef MPI_TYPE
-#undef SENDROUTINE
-#undef RECVROUTINE
-#undef ARRAY_TYPE
-#undef NAT_IN
-#undef SGN_IN
-#undef ARRAY_IN
-#undef K_SIZE
-#undef L_SIZE
-#undef F_SIZE
-#undef LBC_ARG
-#undef HUGEVAL
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mppini.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mppini.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LBC/mppini.F90	(revision 14644)
@@ -47,5 +47,5 @@
 CONTAINS
 
-#if ! defined key_mpp_mpi
+#if defined key_mpi_off
    !!----------------------------------------------------------------------
    !!   Default option :                            shared memory computing
@@ -69,8 +69,5 @@
       jpi    = jpiglo
       jpj    = jpjglo
-      jpk    = jpkglo
-      jpim1  = jpi-1                         ! inner domain indices
-      jpjm1  = jpj-1                         !   "           "
-      jpkm1  = MAX( 1, jpk-1 )               !   "           "
+      jpk    = MAX( 2, jpkglo )
       jpij   = jpi*jpj
       jpni   = 1
@@ -79,12 +76,5 @@
       nimpp  = 1
       njmpp  = 1
-      nbondi = 2
-      nbondj = 2
       nidom  = FLIO_DOM_NONE
-      npolj = 0
-      IF( jperio == 3 .OR. jperio == 4 )   npolj = 3
-      IF( jperio == 5 .OR. jperio == 6 )   npolj = 5
-      l_Iperio = jpni == 1 .AND. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7)
-      l_Jperio = jpnj == 1 .AND. (jperio == 2 .OR. jperio == 7)
       !
       CALL init_doloop                       ! set start/end indices or do-loop depending on the halo width value (nn_hls)
@@ -95,5 +85,5 @@
          WRITE(numout,*) '~~~~~~~~ '
          WRITE(numout,*) '   l_Iperio = ', l_Iperio, '    l_Jperio = ', l_Jperio
-         WRITE(numout,*) '     npolj  = ',   npolj , '      njmpp  = ', njmpp
+         WRITE(numout,*) '     njmpp  = ', njmpp
       ENDIF
       !
@@ -107,5 +97,5 @@
 #else
    !!----------------------------------------------------------------------
-   !!   'key_mpp_mpi'                     MPI massively parallel processing
+   !!                   MPI massively parallel processing
    !!----------------------------------------------------------------------
 
@@ -123,7 +113,5 @@
       !! ** Method  :   Global domain is distributed in smaller local domains.
       !!      Periodic condition is a function of the local domain position
-      !!      (global boundary or neighbouring domain) and of the global
-      !!      periodic
-      !!      Type :         jperio global periodic condition
+      !!      (global boundary or neighbouring domain) and of the global periodic
       !!
       !! ** Action : - set domain parameters
@@ -131,33 +119,25 @@
       !!                    njmpp     : latitudinal  index
       !!                    narea     : number for local area
-      !!                    nbondi    : mark for "east-west local boundary"
-      !!                    nbondj    : mark for "north-south local boundary"
-      !!                    nproc     : number for local processor
-      !!                    noea      : number for local neighboring processor
-      !!                    nowe      : number for local neighboring processor
-      !!                    noso      : number for local neighboring processor
-      !!                    nono      : number for local neighboring processor
-      !!----------------------------------------------------------------------
-      INTEGER ::   ji, jj, jn, jproc, jarea   ! dummy loop indices
-      INTEGER ::   inijmin
-      INTEGER ::   inum                       ! local logical unit
-      INTEGER ::   idir, ifreq                ! local integers
-      INTEGER ::   ii, il1, ili, imil         !   -       -
-      INTEGER ::   ij, il2, ilj, ijm1         !   -       -
-      INTEGER ::   iino, ijno, iiso, ijso     !   -       -
-      INTEGER ::   iiea, ijea, iiwe, ijwe     !   -       -
-      INTEGER ::   iarea0                     !   -       -
-      INTEGER ::   ierr, ios                  !
-      INTEGER ::   inbi, inbj, iimax,  ijmax, icnt1, icnt2
+      !!                    mpinei    : number of neighboring domains (starting at 0, -1 if no neighbourg)
+      !!----------------------------------------------------------------------
+      INTEGER ::   ji, jj, jn, jp, jh
+      INTEGER ::   ii, ij, ii2, ij2
+      INTEGER ::   inijmin   ! number of oce subdomains
+      INTEGER ::   inum, inum0
+      INTEGER ::   ifreq, il1, imil, il2, ijm1
+      INTEGER ::   ierr, ios
+      INTEGER ::   inbi, inbj, iimax, ijmax, icnt1, icnt2
+      INTEGER, DIMENSION(16*n_hlsmax) :: ichanged
+      INTEGER, ALLOCATABLE, DIMENSION(:    ) ::   iin, ijn
+      INTEGER, ALLOCATABLE, DIMENSION(:,:  ) ::   iimppt, ijpi, ipproc
+      INTEGER, ALLOCATABLE, DIMENSION(:,:  ) ::   ijmppt, ijpj
+      INTEGER, ALLOCATABLE, DIMENSION(:,:  ) ::   impi
+      INTEGER, ALLOCATABLE, DIMENSION(:,:,:) ::   inei
       LOGICAL ::   llbest, llauto
       LOGICAL ::   llwrtlay
+      LOGICAL ::   llmpi_Iperio, llmpi_Jperio, llmpiNFold
       LOGICAL ::   ln_listonly
-      INTEGER, ALLOCATABLE, DIMENSION(:)     ::   iin, ii_nono, ii_noea          ! 1D workspace
-      INTEGER, ALLOCATABLE, DIMENSION(:)     ::   ijn, ii_noso, ii_nowe          !  -     -
-      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   iimppt, ijpi, ibondi, ipproc   ! 2D workspace
-      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   ijmppt, ijpj, ibondj, ipolj    !  -     -
-      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   iie0, iis0, iono, ioea         !  -     -
-      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   ije0, ijs0, ioso, iowe         !  -     -
-      LOGICAL, ALLOCATABLE, DIMENSION(:,:) ::   llisoce                        !  -     -
+      LOGICAL, ALLOCATABLE, DIMENSION(:,:  ) ::   llisOce  ! is not land-domain only?
+      LOGICAL, ALLOCATABLE, DIMENSION(:,:,:) ::   llnei    ! are neighbourgs existing?
       NAMELIST/nambdy/ ln_bdy, nb_bdy, ln_coords_file, cn_coords_file,           &
            &             ln_mask_file, cn_mask_file, cn_dyn2d, nn_dyn2d_dta,     &
@@ -166,5 +146,5 @@
            &             cn_ice, nn_ice_dta,                                     &
            &             ln_vol, nn_volctl, nn_rimwidth
-      NAMELIST/nammpp/ jpni, jpnj, nn_hls, ln_nnogather, ln_listonly
+      NAMELIST/nammpp/ jpni, jpnj, nn_hls, ln_nnogather, ln_listonly, nn_comm
       !!----------------------------------------------------------------------
       !
@@ -194,7 +174,4 @@
       IF(lwm)   WRITE( numond, nammpp )
       !
-!!!------------------------------------
-!!!  nn_hls shloud be read in nammpp
-!!!------------------------------------
       jpiglo = Ni0glo + 2 * nn_hls
       jpjglo = Nj0glo + 2 * nn_hls
@@ -214,5 +191,5 @@
       ! -----------------------------------
       !
-      ! If dimensions of processors grid weren't specified in the namelist file
+      ! If dimensions of MPI processes grid weren't specified in the namelist file
       ! then we calculate them here now that we have our communicator size
       IF(lwp) THEN
@@ -261,7 +238,7 @@
 
       ! look for land mpi subdomains...
-      ALLOCATE( llisoce(jpni,jpnj) )
-      CALL mpp_is_ocean( llisoce )
-      inijmin = COUNT( llisoce )   ! number of oce subdomains
+      ALLOCATE( llisOce(jpni,jpnj) )
+      CALL mpp_is_ocean( llisOce )
+      inijmin = COUNT( llisOce )   ! number of oce subdomains
 
       IF( mppsize < inijmin ) THEN   ! too many oce subdomains: can happen only if jpni and jpnj are prescribed...
@@ -320,15 +297,10 @@
 9003  FORMAT (a, i5)
 
-      ALLOCATE(  nfimpp(jpni ) , nfproc(jpni ) ,   nfjpi(jpni ) ,                     &
-         &       nimppt(jpnij) , ibonit(jpnij) ,  jpiall(jpnij) ,  jpjall(jpnij) ,    &
-         &       njmppt(jpnij) , ibonjt(jpnij) , nis0all(jpnij) , njs0all(jpnij) ,    &
-         &                                       nie0all(jpnij) , nje0all(jpnij) ,    &
-         &       iin(jpnij), ii_nono(jpnij), ii_noea(jpnij),   &
-         &       ijn(jpnij), ii_noso(jpnij), ii_nowe(jpnij),   &
-         &       iimppt(jpni,jpnj), ijpi(jpni,jpnj), ibondi(jpni,jpnj), ipproc(jpni,jpnj),   &
-         &       ijmppt(jpni,jpnj), ijpj(jpni,jpnj), ibondj(jpni,jpnj),  ipolj(jpni,jpnj),   &
-         &         iie0(jpni,jpnj), iis0(jpni,jpnj),   iono(jpni,jpnj),   ioea(jpni,jpnj),   &
-         &         ije0(jpni,jpnj), ijs0(jpni,jpnj),   ioso(jpni,jpnj),   iowe(jpni,jpnj),   &
-         &       STAT=ierr )
+      ALLOCATE( nfimpp(jpni), nfproc(jpni), nfjpi(jpni),   &
+         &      iin(jpnij), ijn(jpnij),   &
+         &      iimppt(jpni,jpnj), ijmppt(jpni,jpnj), ijpi(jpni,jpnj), ijpj(jpni,jpnj), ipproc(jpni,jpnj),   &
+         &      inei(8,jpni,jpnj), llnei(8,jpni,jpnj),   &
+         &      impi(8,jpnij),   &
+         &      STAT=ierr )
       CALL mpp_sum( 'mppini', ierr )
       IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'mpp_init: unable to allocate standard ocean arrays' )
@@ -344,17 +316,16 @@
       !
       CALL mpp_basesplit( jpiglo, jpjglo, nn_hls, jpni, jpnj, jpimax, jpjmax, iimppt, ijmppt, ijpi, ijpj )
-      CALL mpp_getnum( llisoce, ipproc, iin, ijn )
-      !
-      !DO jn = 1, jpni
-      !   jproc = ipproc(jn,jpnj)
-      !   ii = iin(jproc+1)
-      !   ij = ijn(jproc+1)
-      !   nfproc(jn) = jproc
-      !   nfimpp(jn) = iimppt(ii,ij)
-      !   nfjpi (jn) =   ijpi(ii,ij)
-      !END DO
-      nfproc(:) = ipproc(:,jpnj)
-      nfimpp(:) = iimppt(:,jpnj)
-      nfjpi (:) =   ijpi(:,jpnj)
+      CALL mpp_getnum( llisOce, ipproc, iin, ijn )
+      !
+      ii = iin(narea)
+      ij = ijn(narea)
+      jpi   = ijpi(ii,ij)
+      jpj   = ijpj(ii,ij)
+      jpk   = MAX( 2, jpkglo )
+      jpij  = jpi*jpj
+      nimpp = iimppt(ii,ij)
+      njmpp = ijmppt(ii,ij)
+      !
+      CALL init_doloop                          ! set start/end indices of do-loop, depending on the halo width value (nn_hls)
       !
       IF(lwp) THEN
@@ -366,120 +337,11 @@
          WRITE(numout,*) '      jpnj = ', jpnj
          WRITE(numout,*) '     jpnij = ', jpnij
+         WRITE(numout,*) '     nimpp = ', nimpp
+         WRITE(numout,*) '     njmpp = ', njmpp
          WRITE(numout,*)
          WRITE(numout,*) '      sum ijpi(i,1) = ', sum(ijpi(:,1)), ' jpiglo = ', jpiglo
-         WRITE(numout,*) '      sum ijpj(1,j) = ', sum(ijpj(1,:)), ' jpjglo = ', jpjglo
-      ENDIF
-
-      ! 3. Subdomain description in the Regular Case
-      ! --------------------------------------------
-      ! specific cases where there is no communication -> must do the periodicity by itself
-      ! Warning: because of potential land-area suppression, do not use nbond[ij] == 2
-      l_Iperio = jpni == 1 .AND. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7)
-      l_Jperio = jpnj == 1 .AND. (jperio == 2 .OR. jperio == 7)
-
-      DO jarea = 1, jpni*jpnj
-         !
-         iarea0 = jarea - 1
-         ii = 1 + MOD(iarea0,jpni)
-         ij = 1 +     iarea0/jpni
-         ili = ijpi(ii,ij)
-         ilj = ijpj(ii,ij)
-         ibondi(ii,ij) = 0                         ! default: has e-w neighbours
-         IF( ii   ==    1 )   ibondi(ii,ij) = -1   ! first column, has only e neighbour
-         IF( ii   == jpni )   ibondi(ii,ij) =  1   ! last column,  has only w neighbour
-         IF( jpni ==    1 )   ibondi(ii,ij) =  2   ! has no e-w neighbour
-         ibondj(ii,ij) = 0                         ! default: has n-s neighbours
-         IF( ij   ==    1 )   ibondj(ii,ij) = -1   ! first row, has only n neighbour
-         IF( ij   == jpnj )   ibondj(ii,ij) =  1   ! last row,  has only s neighbour
-         IF( jpnj ==    1 )   ibondj(ii,ij) =  2   ! has no n-s neighbour
-
-         ! Subdomain neighbors (get their zone number): default definition
-         ioso(ii,ij) = iarea0 - jpni
-         iowe(ii,ij) = iarea0 - 1
-         ioea(ii,ij) = iarea0 + 1
-         iono(ii,ij) = iarea0 + jpni
-         iis0(ii,ij) =  1  + nn_hls
-         iie0(ii,ij) = ili - nn_hls
-         ijs0(ii,ij) =  1  + nn_hls
-         ije0(ii,ij) = ilj - nn_hls
-
-         ! East-West periodicity: change ibondi, ioea, iowe
-         IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7 ) THEN
-            IF( jpni  /= 1 )   ibondi(ii,ij) = 0                        ! redefine: all have e-w neighbours
-            IF( ii ==    1 )   iowe(ii,ij) = iarea0 +        (jpni-1)   ! redefine: first column, address of w neighbour
-            IF( ii == jpni )   ioea(ii,ij) = iarea0 -        (jpni-1)   ! redefine: last column,  address of e neighbour
-         ENDIF
-
-         ! Simple North-South periodicity: change ibondj, ioso, iono
-         IF( jperio == 2 .OR. jperio == 7 ) THEN
-            IF( jpnj  /= 1 )   ibondj(ii,ij) = 0                        ! redefine: all have n-s neighbours
-            IF( ij ==    1 )   ioso(ii,ij) = iarea0 + jpni * (jpnj-1)   ! redefine: first row, address of s neighbour
-            IF( ij == jpnj )   iono(ii,ij) = iarea0 - jpni * (jpnj-1)   ! redefine: last row,  address of n neighbour
-         ENDIF
-
-         ! North fold: define ipolj, change iono. Warning: we do not change ibondj...
-         ipolj(ii,ij) = 0
-         IF( jperio == 3 .OR. jperio == 4 ) THEN
-            ijm1 = jpni*(jpnj-1)
-            imil = ijm1+(jpni+1)/2
-            IF( jarea > ijm1 ) ipolj(ii,ij) = 3
-            IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 4
-            IF( ipolj(ii,ij) == 3 ) iono(ii,ij) = jpni*jpnj-jarea+ijm1   ! MPI rank of northern neighbour
-         ENDIF
-         IF( jperio == 5 .OR. jperio == 6 ) THEN
-            ijm1 = jpni*(jpnj-1)
-            imil = ijm1+(jpni+1)/2
-            IF( jarea > ijm1) ipolj(ii,ij) = 5
-            IF( MOD(jpni,2) == 1 .AND. jarea == imil ) ipolj(ii,ij) = 6
-            IF( ipolj(ii,ij) == 5) iono(ii,ij) = jpni*jpnj-jarea+ijm1    ! MPI rank of northern neighbour
-         ENDIF
-         !
-      END DO
-
-      ! 4. deal with land subdomains
-      ! ----------------------------
-      !
-      ! neighbour treatment: change ibondi, ibondj if next to a land zone
-      DO jarea = 1, jpni*jpnj
-         ii = 1 + MOD( jarea-1  , jpni )
-         ij = 1 +     (jarea-1) / jpni
-         ! land-only area with an active n neigbour
-         IF ( ipproc(ii,ij) == -1 .AND. 0 <= iono(ii,ij) .AND. iono(ii,ij) <= jpni*jpnj-1 ) THEN
-            iino = 1 + MOD( iono(ii,ij) , jpni )                    ! ii index of this n neigbour
-            ijno = 1 +      iono(ii,ij) / jpni                      ! ij index of this n neigbour
-            ! In case of north fold exchange: I am the n neigbour of my n neigbour!! (#1057)
-            ! --> for northern neighbours of northern row processors (in case of north-fold)
-            !     need to reverse the LOGICAL direction of communication
-            idir = 1                                           ! we are indeed the s neigbour of this n neigbour
-            IF( ij == jpnj .AND. ijno == jpnj )   idir = -1    ! both are on the last row, we are in fact the n neigbour
-            IF( ibondj(iino,ijno) == idir     )   ibondj(iino,ijno) =   2     ! this n neigbour had only a s/n neigbour -> no more
-            IF( ibondj(iino,ijno) == 0        )   ibondj(iino,ijno) = -idir   ! this n neigbour had both, n-s neighbours -> keep 1
-         ENDIF
-         ! land-only area with an active s neigbour
-         IF( ipproc(ii,ij) == -1 .AND. 0 <= ioso(ii,ij) .AND. ioso(ii,ij) <= jpni*jpnj-1 ) THEN
-            iiso = 1 + MOD( ioso(ii,ij) , jpni )                    ! ii index of this s neigbour
-            ijso = 1 +      ioso(ii,ij) / jpni                      ! ij index of this s neigbour
-            IF( ibondj(iiso,ijso) == -1 )   ibondj(iiso,ijso) = 2   ! this s neigbour had only a n neigbour    -> no more neigbour
-            IF( ibondj(iiso,ijso) ==  0 )   ibondj(iiso,ijso) = 1   ! this s neigbour had both, n-s neighbours -> keep s neigbour
-         ENDIF
-         ! land-only area with an active e neigbour
-         IF( ipproc(ii,ij) == -1 .AND. 0 <= ioea(ii,ij) .AND. ioea(ii,ij) <= jpni*jpnj-1 ) THEN
-            iiea = 1 + MOD( ioea(ii,ij) , jpni )                    ! ii index of this e neigbour
-            ijea = 1 +      ioea(ii,ij) / jpni                      ! ij index of this e neigbour
-            IF( ibondi(iiea,ijea) == 1 )   ibondi(iiea,ijea) =  2   ! this e neigbour had only a w neigbour    -> no more neigbour
-            IF( ibondi(iiea,ijea) == 0 )   ibondi(iiea,ijea) = -1   ! this e neigbour had both, e-w neighbours -> keep e neigbour
-         ENDIF
-         ! land-only area with an active w neigbour
-         IF( ipproc(ii,ij) == -1 .AND. 0 <= iowe(ii,ij) .AND. iowe(ii,ij) <= jpni*jpnj-1) THEN
-            iiwe = 1 + MOD( iowe(ii,ij) , jpni )                    ! ii index of this w neigbour
-            ijwe = 1 +      iowe(ii,ij) / jpni                      ! ij index of this w neigbour
-            IF( ibondi(iiwe,ijwe) == -1 )   ibondi(iiwe,ijwe) = 2   ! this w neigbour had only a e neigbour    -> no more neigbour
-            IF( ibondi(iiwe,ijwe) ==  0 )   ibondi(iiwe,ijwe) = 1   ! this w neigbour had both, e-w neighbours -> keep w neigbour
-         ENDIF
-      END DO
-
-      ! 5. Subdomain print
-      ! ------------------
-      IF(lwp) THEN
+         WRITE(numout,*) '      sum ijpj(1,j) = ', SUM(ijpj(1,:)), ' jpjglo = ', jpjglo
+         
+         ! Subdomain grid print
          ifreq = 4
          il1 = 1
@@ -504,225 +366,209 @@
  9404    FORMAT('           *  '   ,20('     ' ,i4,'   *   ') )
       ENDIF
-
-      ! just to save nono etc for all proc
-      ! warning ii*ij (zone) /= nproc (processors)!
-      ! ioso = zone number, ii_noso = proc number
-      ii_noso(:) = -1
-      ii_nono(:) = -1
-      ii_noea(:) = -1
-      ii_nowe(:) = -1
-      DO jproc = 1, jpnij
-         ii = iin(jproc)
-         ij = ijn(jproc)
-         IF( 0 <= ioso(ii,ij) .AND. ioso(ii,ij) <= (jpni*jpnj-1) ) THEN
-            iiso = 1 + MOD( ioso(ii,ij) , jpni )
-            ijso = 1 +      ioso(ii,ij) / jpni
-            ii_noso(jproc) = ipproc(iiso,ijso)
-         ENDIF
-         IF( 0 <= iowe(ii,ij) .AND. iowe(ii,ij) <= (jpni*jpnj-1) ) THEN
-          iiwe = 1 + MOD( iowe(ii,ij) , jpni )
-          ijwe = 1 +      iowe(ii,ij) / jpni
-          ii_nowe(jproc) = ipproc(iiwe,ijwe)
-         ENDIF
-         IF( 0 <= ioea(ii,ij) .AND. ioea(ii,ij) <= (jpni*jpnj-1) ) THEN
-            iiea = 1 + MOD( ioea(ii,ij) , jpni )
-            ijea = 1 +      ioea(ii,ij) / jpni
-            ii_noea(jproc)= ipproc(iiea,ijea)
-         ENDIF
-         IF( 0 <= iono(ii,ij) .AND. iono(ii,ij) <= (jpni*jpnj-1) ) THEN
-            iino = 1 + MOD( iono(ii,ij) , jpni )
-            ijno = 1 +      iono(ii,ij) / jpni
-            ii_nono(jproc)= ipproc(iino,ijno)
-         ENDIF
-      END DO
-
-      ! 6. Change processor name
-      ! ------------------------
-      ii = iin(narea)
-      ij = ijn(narea)
-      !
-      jpi    = ijpi(ii,ij)
-!!$      Nis0  = iis0(ii,ij)
-!!$      Nie0  = iie0(ii,ij)
-      jpj    = ijpj(ii,ij)
-!!$      Njs0  = ijs0(ii,ij)
-!!$      Nje0  = ije0(ii,ij)
-      nbondi = ibondi(ii,ij)
-      nbondj = ibondj(ii,ij)
-      nimpp = iimppt(ii,ij)
-      njmpp = ijmppt(ii,ij)
-      jpk = jpkglo                              ! third dim
-
-      ! set default neighbours
-      noso = ii_noso(narea)
-      nowe = ii_nowe(narea)
-      noea = ii_noea(narea)
-      nono = ii_nono(narea)
-
-      nones = -1
-      nonws = -1
-      noses = -1
-      nosws = -1
-
-      noner = -1
-      nonwr = -1
-      noser = -1
-      noswr = -1
-
-      IF((nbondi .eq. -1) .or. (nbondi .eq. 0)) THEN ! east neighbour exists
-         IF(ibondj(iin(noea+1),ijn(noea+1)) .eq. 0) THEN
-            nones = ii_nono(noea+1)                  ! east neighbour has north and south neighbours
-            noses = ii_noso(noea+1)
-         ELSEIF(ibondj(iin(noea+1),ijn(noea+1)) .eq. -1) THEN
-            nones = ii_nono(noea+1)                  ! east neighbour has north neighbour
-         ELSEIF(ibondj(iin(noea+1),ijn(noea+1)) .eq. 1) THEN
-            noses = ii_noso(noea+1)                  ! east neighbour has south neighbour
-         END IF
-      END IF
-      IF((nbondi .eq. 1) .or. (nbondi .eq. 0)) THEN  ! west neighbour exists
-         IF(ibondj(iin(nowe+1),ijn(nowe+1)) .eq. 0) THEN
-            nonws = ii_nono(nowe+1)                  ! west neighbour has north and south neighbours
-            nosws = ii_noso(nowe+1)
-         ELSEIF(ibondj(iin(nowe+1),ijn(nowe+1)) .eq. -1) THEN
-            nonws = ii_nono(nowe+1)                  ! west neighbour has north neighbour
-         ELSEIF(ibondj(iin(nowe+1),ijn(nowe+1)) .eq. 1)  THEN
-            nosws = ii_noso(nowe+1)                  ! west neighbour has north neighbour
-         END IF
-      END IF
-
-      IF((nbondj .eq. -1) .or. (nbondj .eq. 0)) THEN ! north neighbour exists
-         IF(ibondi(iin(nono+1),ijn(nono+1)) .eq. 0) THEN
-            noner = ii_noea(nono+1)                  ! north neighbour has east and west neighbours
-            nonwr = ii_nowe(nono+1)
-         ELSEIF(ibondi(iin(nono+1),ijn(nono+1)) .eq. -1) THEN
-            noner = ii_noea(nono+1)                  ! north neighbour has east neighbour
-         ELSEIF(ibondi(iin(nono+1),ijn(nono+1)) .eq. 1) THEN
-            nonwr = ii_nowe(nono+1)                  ! north neighbour has west neighbour
-         END IF
-      END IF
-      IF((nbondj .eq. 1) .or. (nbondj .eq. 0)) THEN  ! south neighbour exists
-         IF(ibondi(iin(noso+1),ijn(noso+1)) .eq. 0) THEN
-            noser = ii_noea(noso+1)                  ! south neighbour has east and west neighbours
-            noswr = ii_nowe(noso+1)
-         ELSEIF(ibondi(iin(noso+1),ijn(noso+1)) .eq. -1) THEN
-            noser = ii_noea(noso+1)                  ! south neighbour has east neighbour
-         ELSEIF(ibondi(iin(noso+1),ijn(noso+1)) .eq. 1) THEN
-            noswr = ii_nowe(noso+1)                  ! south neighbour has west neighbour
-         END IF
-      END IF
-
-      !
-      CALL init_doloop                          ! set start/end indices of do-loop, depending on the halo width value (nn_hls)
-      !
-      jpim1 = jpi-1                             ! inner domain indices
-      jpjm1 = jpj-1                             !   "           "
-      jpkm1 = MAX( 1, jpk-1 )                   !   "           "
-      jpij  = jpi*jpj                           !  jpi x j
-      DO jproc = 1, jpnij
-         ii = iin(jproc)
-         ij = ijn(jproc)
-         jpiall (jproc) = ijpi(ii,ij)
-         nis0all(jproc) = iis0(ii,ij)
-         nie0all(jproc) = iie0(ii,ij)
-         jpjall (jproc) = ijpj(ii,ij)
-         njs0all(jproc) = ijs0(ii,ij)
-         nje0all(jproc) = ije0(ii,ij)
-         ibonit(jproc) = ibondi(ii,ij)
-         ibonjt(jproc) = ibondj(ii,ij)
-         nimppt(jproc) = iimppt(ii,ij)
-         njmppt(jproc) = ijmppt(ii,ij)
-      END DO
-
+      !
+      ! Store informations for the north pole folding communications
+      nfproc(:) = ipproc(:,jpnj)
+      nfimpp(:) = iimppt(:,jpnj)
+      nfjpi (:) =   ijpi(:,jpnj)
+      !
+      ! 3. Define Western, Eastern, Southern and Northern neighbors + corners in the subdomain grid reference
+      ! ------------------------------------------------------------------------------------------------------
+      !
+      ! note that North fold is has specific treatment for its MPI communications.
+      ! This must not be treated as a "usual" communication with a northern neighbor.
+      !    -> North fold processes have no Northern neighbor in the definition done bellow
+      !
+      llmpi_Iperio = jpni > 1 .AND. l_Iperio                         ! do i-periodicity with an MPI communication?
+      llmpi_Jperio = jpnj > 1 .AND. l_Jperio                         ! do j-periodicity with an MPI communication?
+      !
+      l_SelfPerio(1:2) = l_Iperio .AND. jpni == 1                    !  west,  east periodicity by itself
+      l_SelfPerio(3:4) = l_Jperio .AND. jpnj == 1                    ! south, north periodicity by itself
+      l_SelfPerio(5:8) = l_SelfPerio(jpwe) .AND. l_SelfPerio(jpso)   ! corners bi-periodicity by itself
+      !
+      ! define neighbors mapping (1/2): default definition: ignore if neighbours are land-only subdomains or not
+      DO jj = 1, jpnj
+         DO ji = 1, jpni
+            !
+            IF ( llisOce(ji,jj) ) THEN                     ! this subdomain has some ocean: it has neighbours
+               !
+               inum0 = ji - 1 + ( jj - 1 ) * jpni             ! index in the subdomains grid. start at 0
+               !
+               ! Is there a neighbor?
+               llnei(jpwe,ji,jj) = ji >   1  .OR. llmpi_Iperio           ! West  nei exists if not the first column or llmpi_Iperio
+               llnei(jpea,ji,jj) = ji < jpni .OR. llmpi_Iperio           ! East  nei exists if not the last  column or llmpi_Iperio
+               llnei(jpso,ji,jj) = jj >   1  .OR. llmpi_Jperio           ! South nei exists if not the first line   or llmpi_Jperio
+               llnei(jpno,ji,jj) = jj < jpnj .OR. llmpi_Jperio           ! North nei exists if not the last  line   or llmpi_Jperio
+               llnei(jpsw,ji,jj) = llnei(jpwe,ji,jj) .AND. llnei(jpso,ji,jj)   ! So-We nei exists if both South and West nei exist
+               llnei(jpse,ji,jj) = llnei(jpea,ji,jj) .AND. llnei(jpso,ji,jj)   ! So-Ea nei exists if both South and East nei exist
+               llnei(jpnw,ji,jj) = llnei(jpwe,ji,jj) .AND. llnei(jpno,ji,jj)   ! No-We nei exists if both North and West nei exist
+               llnei(jpne,ji,jj) = llnei(jpea,ji,jj) .AND. llnei(jpno,ji,jj)   ! No-Ea nei exists if both North and East nei exist
+               !
+               ! Which index (starting at 0) have neighbors in the subdomains grid?
+               IF( llnei(jpwe,ji,jj) )   inei(jpwe,ji,jj) =            inum0 -    1 + jpni        * COUNT( (/ ji ==    1 /) )
+               IF( llnei(jpea,ji,jj) )   inei(jpea,ji,jj) =            inum0 +    1 - jpni        * COUNT( (/ ji == jpni /) )
+               IF( llnei(jpso,ji,jj) )   inei(jpso,ji,jj) =            inum0 - jpni + jpni * jpnj * COUNT( (/ jj ==    1 /) )
+               IF( llnei(jpno,ji,jj) )   inei(jpno,ji,jj) =            inum0 + jpni - jpni * jpnj * COUNT( (/ jj == jpnj /) )
+               IF( llnei(jpsw,ji,jj) )   inei(jpsw,ji,jj) = inei(jpso,ji,jj) -    1 + jpni        * COUNT( (/ ji ==    1 /) )
+               IF( llnei(jpse,ji,jj) )   inei(jpse,ji,jj) = inei(jpso,ji,jj) +    1 - jpni        * COUNT( (/ ji == jpni /) )
+               IF( llnei(jpnw,ji,jj) )   inei(jpnw,ji,jj) = inei(jpno,ji,jj) -    1 + jpni        * COUNT( (/ ji ==    1 /) )
+               IF( llnei(jpne,ji,jj) )   inei(jpne,ji,jj) = inei(jpno,ji,jj) +    1 - jpni        * COUNT( (/ ji == jpni /) )
+               !
+            ELSE                                           ! land-only domain has no neighbour
+               llnei(:,ji,jj) = .FALSE.
+            ENDIF
+            !
+         END DO
+      END DO
+      !
+      ! define neighbors mapping (2/2): check if neighbours are not land-only subdomains
+      DO jj = 1, jpnj
+         DO ji = 1, jpni
+            DO jn = 1, 8
+               IF( llnei(jn,ji,jj) ) THEN   ! if a neighbour is existing -> this should not be a land-only domain
+                  ii = 1 + MOD( inei(jn,ji,jj) , jpni )
+                  ij = 1 +      inei(jn,ji,jj) / jpni
+                  llnei(jn,ji,jj) = llisOce( ii, ij )
+               ENDIF
+            END DO
+         END DO
+      END DO
+      !
+      ! update index of the neighbours in the subdomains grid
+      WHERE( .NOT. llnei )   inei = -1
+      !
       ! Save processor layout in ascii file
       IF (llwrtlay) THEN
          CALL ctl_opn( inum, 'layout.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
-         WRITE(inum,'(a)') '   jpnij   jpimax  jpjmax    jpk  jpiglo  jpjglo'//&
-   &           ' ( local:    narea     jpi     jpj )'
-         WRITE(inum,'(6i8,a,3i8,a)') jpnij,jpimax,jpjmax,jpk,jpiglo,jpjglo,&
-   &           ' ( local: ',narea,jpi,jpj,' )'
-         WRITE(inum,'(a)') 'nproc   jpi  jpj Nis0 Njs0 Nie0 Nje0 nimp njmp nono noso nowe noea nbondi nbondj '
-
-         DO jproc = 1, jpnij
-            WRITE(inum,'(13i5,2i7)')   jproc-1,  jpiall(jproc),  jpjall(jproc),   &
-               &                                nis0all(jproc), njs0all(jproc),   &
-               &                                nie0all(jproc), nje0all(jproc),   &
-               &                                nimppt (jproc), njmppt (jproc),   &
-               &                                ii_nono(jproc), ii_noso(jproc),   &
-               &                                ii_nowe(jproc), ii_noea(jproc),   &
-               &                                ibonit (jproc), ibonjt (jproc)
+         WRITE(inum,'(a)') '  jpnij jpimax jpjmax    jpk jpiglo jpjglo ( local:   narea    jpi    jpj )'
+         WRITE(inum,'(6i7,a,3i7,a)') jpnij,jpimax,jpjmax,jpk,jpiglo,jpjglo,' ( local: ',narea,jpi,jpj,' )'
+         WRITE(inum,*) 
+         WRITE(inum,       *) '------------------------------------'
+         WRITE(inum,'(a,i2)') ' Mapping of the default neighnourgs '
+         WRITE(inum,       *) '------------------------------------'
+         WRITE(inum,*) 
+         WRITE(inum,'(a)') '  rank    ii    ij   jpi   jpj nimpp njmpp mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
+         DO jp = 1, jpnij
+            ii = iin(jp)
+            ij = ijn(jp)
+            WRITE(inum,'(15i6)')  jp-1, ii, ij, ijpi(ii,ij), ijpj(ii,ij), iimppt(ii,ij), ijmppt(ii,ij), inei(:,ii,ij)
          END DO
-      END IF
-
-      !                          ! north fold parameter
-      ! Defined npolj, either 0, 3 , 4 , 5 , 6
-      ! In this case the important thing is that npolj /= 0
-      ! Because if we go through these line it is because jpni >1 and thus
-      ! we must use lbcnorthmpp, which tests only npolj =0 or npolj /= 0
-      npolj = 0
-      ij = ijn(narea)
-      IF( jperio == 3 .OR. jperio == 4 ) THEN
-         IF( ij == jpnj )   npolj = 3
-      ENDIF
-      IF( jperio == 5 .OR. jperio == 6 ) THEN
-         IF( ij == jpnj )   npolj = 5
-      ENDIF
-      !
-      nproc = narea-1
+      ENDIF
+
+      !
+      ! 4. Define Western, Eastern, Southern and Northern neighbors + corners for each mpi process
+      ! ------------------------------------------------------------------------------------------
+      ! 
+      ! rewrite information from "subdomain grid" to mpi process list
+      ! Warning, for example:
+      !    position of the northern neighbor in the "subdomain grid"
+      !    position of the northern neighbor in the "mpi process list"
+      
+      ! default definition: no neighbors
+      impi(:,:) = -1   ! (starting at 0, -1 if no neighbourg)
+      
+      DO jp = 1, jpnij
+         ii = iin(jp)
+         ij = ijn(jp)
+         DO jn = 1, 8
+            IF( llnei(jn,ii,ij) ) THEN   ! must be tested as some land-domain can be kept to fit mppsize
+               ii2 = 1 + MOD( inei(jn,ii,ij) , jpni )
+               ij2 = 1 +      inei(jn,ii,ij) / jpni
+               impi(jn,jp) = ipproc( ii2, ij2 )
+            ENDIF
+         END DO
+      END DO
+
+      !
+      ! 4. keep information for the local process
+      ! -----------------------------------------
+      !
+      ! set default neighbours
+      mpinei(:) = impi(:,narea)
+      DO jh = 1, n_hlsmax
+         mpiSnei(jh,:) = impi(:,narea)   ! default definition
+         mpiRnei(jh,:) = impi(:,narea)
+      END DO
+      !
       IF(lwp) THEN
          WRITE(numout,*)
          WRITE(numout,*) '   resulting internal parameters : '
-         WRITE(numout,*) '      nproc  = ', nproc
-         WRITE(numout,*) '      nowe   = ', nowe  , '   noea  =  ', noea
-         WRITE(numout,*) '      nono   = ', nono  , '   noso  =  ', noso
-         WRITE(numout,*) '      nbondi = ', nbondi
-         WRITE(numout,*) '      nbondj = ', nbondj
-         WRITE(numout,*) '      npolj  = ', npolj
-         WRITE(numout,*) '    l_Iperio = ', l_Iperio
-         WRITE(numout,*) '    l_Jperio = ', l_Jperio
-         WRITE(numout,*) '      nimpp  = ', nimpp
-         WRITE(numout,*) '      njmpp  = ', njmpp
-      ENDIF
-
+         WRITE(numout,*) '      narea = ', narea
+         WRITE(numout,*) '      mpi nei  west = ', mpinei(jpwe)  , '   mpi nei  east = ', mpinei(jpea)
+         WRITE(numout,*) '      mpi nei south = ', mpinei(jpso)  , '   mpi nei north = ', mpinei(jpno)
+         WRITE(numout,*) '      mpi nei so-we = ', mpinei(jpsw)  , '   mpi nei so-ea = ', mpinei(jpse)
+         WRITE(numout,*) '      mpi nei no-we = ', mpinei(jpnw)  , '   mpi nei no-ea = ', mpinei(jpne)
+      ENDIF
       !                          ! Prepare mpp north fold
-      IF( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ) THEN
+      !
+      llmpiNFold =          jpni  > 1 .AND. l_NFold   ! is the North fold done with an MPI communication?
+      l_IdoNFold = ijn(narea) == jpnj .AND. l_NFold   ! is this process doing North fold?
+      !
+      IF( llmpiNFold ) THEN
          CALL mpp_ini_north
          IF (lwp) THEN
             WRITE(numout,*)
             WRITE(numout,*) '   ==>>>   North fold boundary prepared for jpni >1'
-            ! additional prints in layout.dat
-         ENDIF
-         IF (llwrtlay) THEN
+         ENDIF
+         IF (llwrtlay) THEN      ! additional prints in layout.dat
             WRITE(inum,*)
             WRITE(inum,*)
-            WRITE(inum,*) 'number of subdomains located along the north fold : ', ndim_rank_north
+            WRITE(inum,*) 'Number of subdomains located along the north fold : ', ndim_rank_north
             WRITE(inum,*) 'Rank of the subdomains located along the north fold : ', ndim_rank_north
-            DO jproc = 1, ndim_rank_north, 5
-               WRITE(inum,*) nrank_north( jproc:MINVAL( (/jproc+4,ndim_rank_north/) ) )
+            DO jp = 1, ndim_rank_north, 5
+               WRITE(inum,*) nrank_north( jp:MINVAL( (/jp+4,ndim_rank_north/) ) )
             END DO
          ENDIF
-      ENDIF
-
-      !
-      CALL mpp_ini_nc        ! Initialize communicator for neighbourhood collective communications
-      !
-      CALL init_ioipsl       ! Prepare NetCDF output file (if necessary)
-      !
-      IF (( jperio >= 3 .AND. jperio <= 6 .AND. jpni > 1 ).AND.( ln_nnogather )) THEN
-         CALL init_nfdcom     ! northfold neighbour lists
-         IF (llwrtlay) THEN
-            WRITE(inum,*)
-            WRITE(inum,*)
-            WRITE(inum,*) 'north fold exchanges with explicit point-to-point messaging :'
-            WRITE(inum,*) 'nsndto : ', nsndto
-            WRITE(inum,*) 'isendto : ', isendto
-         ENDIF
-      ENDIF
+         IF ( l_IdoNFold .AND. ln_nnogather ) THEN
+            CALL init_nfdcom     ! northfold neighbour lists
+            IF (llwrtlay) THEN
+               WRITE(inum,*)
+               WRITE(inum,*) 'north fold exchanges with explicit point-to-point messaging :'
+               WRITE(inum,*) '   nsndto  : ', nsndto
+               WRITE(inum,*) '   isendto : ', isendto(1:nsndto)
+            ENDIF
+         ENDIF
+      ENDIF
+      !
+      CALL mpp_ini_nc(nn_hls)    ! Initialize communicator for neighbourhood collective communications
+      DO jh = 1, n_hlsmax
+         mpi_nc_com4(jh) = mpi_nc_com4(nn_hls)   ! default definition
+         mpi_nc_com8(jh) = mpi_nc_com8(nn_hls)
+      END DO
+      !
+      CALL init_excl_landpt      ! exclude exchanges which contain only land points
+      !
+      ! Save processor layout changes in ascii file
+      DO jh = 1, n_hlsmax    ! different halo size
+         DO ji = 1, 8
+            ichanged(16*(jh-1)  +ji) = COUNT( mpinei(ji:ji) /= mpiSnei(jh,ji:ji) )
+            ichanged(16*(jh-1)+8+ji) = COUNT( mpinei(ji:ji) /= mpiRnei(jh,ji:ji) )
+         END DO
+      END DO
+      CALL mpp_sum( "mpp_init", ichanged )   ! must be called by all processes
+      IF (llwrtlay) THEN
+         WRITE(inum,*) 
+         WRITE(inum,       *) '----------------------------------------------------------------------'
+         WRITE(inum,'(a,i2)') ' Mapping of the neighnourgs once excluding comm with only land points '
+         WRITE(inum,       *) '----------------------------------------------------------------------'
+         DO jh = 1, n_hlsmax    ! different halo size
+            WRITE(inum,*) 
+            WRITE(inum,'(a,i2)') 'halo size: ', jh
+            WRITE(inum,       *) '---------'
+            WRITE(inum,'(a)') '  rank    ii    ij mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
+            WRITE(inum,   '(11i6,a)')  narea-1, iin(narea), ijn(narea),   mpinei(:), ' <- Org'
+            WRITE(inum,'(18x,8i6,a,i1,a)')   mpiSnei(jh,:), ' <- Send ', COUNT( mpinei(:) /= mpiSnei(jh,:) ), ' modif'
+            WRITE(inum,'(18x,8i6,a,i1,a)')   mpiRnei(jh,:), ' <- Recv ', COUNT( mpinei(:) /= mpiRnei(jh,:) ), ' modif'
+            WRITE(inum,*) ' total changes among all mpi tasks:'
+            WRITE(inum,*) '       mpiwe mpiea mpiso mpino mpisw mpise mpinw mpine'
+            WRITE(inum,'(a,8i6)') ' Send: ', ichanged(jh*16-15:jh*16-8)
+            WRITE(inum,'(a,8i6)') ' Recv: ', ichanged(jh*16 -7:jh*16  )
+         END DO
+      ENDIF
+      !
+      CALL init_ioipsl           ! Prepare NetCDF output file (if necessary)
       !
       IF (llwrtlay) CLOSE(inum)
       !
-      DEALLOCATE(iin, ijn, ii_nono, ii_noea, ii_noso, ii_nowe,    &
-         &       iimppt, ijmppt, ibondi, ibondj, ipproc, ipolj,   &
-         &       ijpi, ijpj, iie0, ije0, iis0, ijs0,              &
-         &       iono, ioea, ioso, iowe, llisoce)
+      DEALLOCATE(iin, ijn, iimppt, ijmppt, ijpi, ijpj, ipproc, inei, llnei, impi, llisOce)
       !
     END SUBROUTINE mpp_init
@@ -791,11 +637,11 @@
         CALL ctl_stop( 'STOP', ctmp1, ctmp2 )
       ENDIF
-      IF( jperio == 3 .OR. jperio == 4 .OR. jperio == 5 .OR. jperio == 6 ) THEN
+      IF( l_NFold ) THEN
          ! minimize the size of the last row to compensate for the north pole folding coast
-         IF( jperio == 3 .OR. jperio == 4 )   ijpjmin = 2+3*khls   ! V and F folding must be outside of southern halos
-         IF( jperio == 5 .OR. jperio == 6 )   ijpjmin = 1+3*khls   ! V and F folding must be outside of southern halos
-         irm = knbj - irestj                                       ! total number of lines to be removed
-         klcj(:,knbj) = MAX( ijpjmin, kjmax-irm )                  ! we must have jpj >= ijpjmin in the last row
-         irm = irm - ( kjmax - klcj(1,knbj) )                      ! remaining number of lines to remove
+         IF( c_NFtype == 'T' )   ijpjmin = 2+3*khls   ! V and F folding must be outside of southern halos
+         IF( c_NFtype == 'F' )   ijpjmin = 1+3*khls   ! V and F folding must be outside of southern halos
+         irm = knbj - irestj                          ! total number of lines to be removed
+         klcj(:,knbj) = MAX( ijpjmin, kjmax-irm )     ! we must have jpj >= ijpjmin in the last row
+         irm = irm - ( kjmax - klcj(1,knbj) )         ! remaining number of lines to remove
          irestj = knbj - 1 - irm
          klcj(:, irestj+1:knbj-1) = kjmax-1
@@ -862,5 +708,5 @@
       LOGICAL :: llist
       LOGICAL, DIMENSION(:,:), ALLOCATABLE :: llmsk2d                 ! max size of the subdomains along i,j
-      LOGICAL, DIMENSION(:,:), ALLOCATABLE :: llisoce              !  -     -
+      LOGICAL, DIMENSION(:,:), ALLOCATABLE :: llisOce              !  -     -
       REAL(wp)::   zpropland
       !!----------------------------------------------------------------------
@@ -885,6 +731,6 @@
       iszimin = 4*nn_hls          ! minimum size of the MPI subdomain so halos are always adressing neighbor inner domain
       iszjmin = 4*nn_hls
-      IF( jperio == 3 .OR. jperio == 4 )   iszjmin = MAX(iszjmin, 2+3*nn_hls)   ! V and F folding must be outside of southern halos
-      IF( jperio == 5 .OR. jperio == 6 )   iszjmin = MAX(iszjmin, 1+3*nn_hls)   ! V and F folding must be outside of southern halos
+      IF( c_NFtype == 'T' )   iszjmin = MAX(iszjmin, 2+3*nn_hls)   ! V and F folding must be outside of southern halos
+      IF( c_NFtype == 'F' )   iszjmin = MAX(iszjmin, 1+3*nn_hls)   ! V and F folding must be outside of southern halos
       !
       ! get the list of knbi that gives a smaller jpimax than knbi-1
@@ -935,5 +781,5 @@
                iszi1(ii) = iszi0(ji)
                iszj1(ii) = iszj0(jj)
-            END IF
+            ENDIF
          END DO
       END DO
@@ -991,15 +837,15 @@
             WRITE(numout,*) '  -----------------------------------------------------'
             WRITE(numout,*)
-         END IF
+         ENDIF
          ji = isz0   ! initialization with the largest value
-         ALLOCATE( llisoce(inbi0(ji), inbj0(ji)) )
-         CALL mpp_is_ocean( llisoce )   ! Warning: must be call by all cores (call mpp_sum)
-         inbijold = COUNT(llisoce)
-         DEALLOCATE( llisoce )
+         ALLOCATE( llisOce(inbi0(ji), inbj0(ji)) )
+         CALL mpp_is_ocean( llisOce )   ! Warning: must be call by all cores (call mpp_sum)
+         inbijold = COUNT(llisOce)
+         DEALLOCATE( llisOce )
          DO ji =isz0-1,1,-1
-            ALLOCATE( llisoce(inbi0(ji), inbj0(ji)) )
-            CALL mpp_is_ocean( llisoce )   ! Warning: must be call by all cores (call mpp_sum)
-            inbij = COUNT(llisoce)
-            DEALLOCATE( llisoce )
+            ALLOCATE( llisOce(inbi0(ji), inbj0(ji)) )
+            CALL mpp_is_ocean( llisOce )   ! Warning: must be call by all cores (call mpp_sum)
+            inbij = COUNT(llisOce)
+            DEALLOCATE( llisOce )
             IF(lwp .AND. inbij < inbijold) THEN
                WRITE(numout,'(a, i6, a, i6, a, f4.1, a, i9, a, i6, a, i6, a)')                                 &
@@ -1008,5 +854,5 @@
                   &   '%), largest oce domain: ', iszi0(ji)*iszj0(ji), ' ( ', iszi0(ji),' x ', iszj0(ji), ' )'
                inbijold = inbij
-            END IF
+            ENDIF
          END DO
          DEALLOCATE( inbi0, inbj0, iszi0, iszj0 )
@@ -1024,8 +870,8 @@
       DO WHILE( inbij > knbij )   ! while the number of ocean subdomains exceed the number of procs
          ii = ii -1
-         ALLOCATE( llisoce(inbi0(ii), inbj0(ii)) )
-         CALL mpp_is_ocean( llisoce )            ! must be done by all core
-         inbij = COUNT(llisoce)
-         DEALLOCATE( llisoce )
+         ALLOCATE( llisOce(inbi0(ii), inbj0(ii)) )
+         CALL mpp_is_ocean( llisOce )            ! must be done by all core
+         inbij = COUNT(llisOce)
+         DEALLOCATE( llisOce )
       END DO
       knbi = inbi0(ii)
@@ -1075,5 +921,5 @@
          !
          ALLOCATE( lloce(Ni0glo, ijsz) )                                     ! allocate the strip
-         CALL readbot_strip( ijstr, ijsz, lloce )
+         CALL read_mask( 1, ijstr, Ni0glo, ijsz, lloce )
          inboce = COUNT(lloce)                                               ! number of ocean point in the stripe
          DEALLOCATE(lloce)
@@ -1089,5 +935,5 @@
 
 
-   SUBROUTINE mpp_is_ocean( ldisoce )
+   SUBROUTINE mpp_is_ocean( ldIsOce )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE mpp_is_ocean  ***
@@ -1097,5 +943,5 @@
       !!              at least 1 ocean point.
       !!              We must indeed ensure that each subdomain that is a neighbour
-      !!              of a land subdomain as only land points on its boundary
+      !!              of a land subdomain, has only land points on its boundary
       !!              (inside the inner subdomain) with the land subdomain.
       !!              This is needed to get the proper bondary conditions on
@@ -1104,5 +950,5 @@
       !! ** Method  : read inbj strips (of length Ni0glo) of the land-sea mask
       !!----------------------------------------------------------------------
-      LOGICAL, DIMENSION(:,:), INTENT(  out) ::   ldisoce        ! .true. if a sub domain constains 1 ocean point
+      LOGICAL, DIMENSION(:,:), INTENT(  out) ::   ldIsOce        ! .true. if a sub domain constains 1 ocean point
       !
       INTEGER :: idiv, iimax, ijmax, iarea
@@ -1117,10 +963,10 @@
       ! do nothing if there is no land-sea mask
       IF( numbot == -1 .AND. numbdy == -1 ) THEN
-         ldisoce(:,:) = .TRUE.
+         ldIsOce(:,:) = .TRUE.
          RETURN
       ENDIF
       !
-      inbi = SIZE( ldisoce, dim = 1 )
-      inbj = SIZE( ldisoce, dim = 2 )
+      inbi = SIZE( ldIsOce, dim = 1 )
+      inbj = SIZE( ldIsOce, dim = 2 )
       !
       ! we want to read inbj strips of the land-sea mask. -> pick up inbj processes every idiv processes starting at 1
@@ -1145,9 +991,9 @@
             inry = iny - COUNT( (/ iarea == 1, iarea == inbj /) )      ! number of point to read in y-direction
             isty = 1 + COUNT( (/ iarea == 1 /) )                       ! read from the first or the second line?
-            CALL readbot_strip( ijmppt(1,iarea) - 2 + isty, inry, lloce(2:inx-1, isty:inry+isty-1) )   ! read the strip
+            CALL read_mask( 1, ijmppt(1,iarea) - 2 + isty, Ni0glo, inry, lloce(2:inx-1, isty:inry+isty-1) )   ! read the strip
             !
             IF( iarea == 1    ) THEN                                   ! the first line was not read
-               IF( jperio == 2 .OR. jperio == 7 ) THEN                 !   north-south periodocity
-                  CALL readbot_strip( Nj0glo, 1, lloce(2:inx-1, 1) )   !   read the last line -> first line of lloce
+               IF( l_Jperio ) THEN                                     !   north-south periodocity
+                  CALL read_mask( 1, Nj0glo, Ni0glo, 1, lloce(2:inx-1, 1) )   !   read the last line -> first line of lloce
                ELSE
                   lloce(2:inx-1,  1) = .FALSE.                         !   closed boundary
@@ -1155,7 +1001,7 @@
             ENDIF
             IF( iarea == inbj ) THEN                                   ! the last line was not read
-               IF( jperio == 2 .OR. jperio == 7 ) THEN                 !   north-south periodocity
-                  CALL readbot_strip( 1, 1, lloce(2:inx-1,iny) )       !      read the first line -> last line of lloce
-               ELSEIF( jperio == 3 .OR. jperio == 4 ) THEN             !   north-pole folding T-pivot, T-point
+               IF( l_Jperio ) THEN                                     !   north-south periodocity
+                  CALL read_mask( 1, 1, Ni0glo, 1, lloce(2:inx-1,iny) )   !      read the first line -> last line of lloce
+               ELSEIF( c_NFtype == 'T' ) THEN                          !   north-pole folding T-pivot, T-point
                   lloce(2,iny) = lloce(2,iny-2)                        !      here we have 1 halo (even if nn_hls>1)
                   DO ji = 3,inx-1
@@ -1165,5 +1011,5 @@
                      lloce(ji,iny-1) = lloce(inx-ji+2,iny-1)
                   END DO
-               ELSEIF( jperio == 5 .OR. jperio == 6 ) THEN             !   north-pole folding F-pivot, T-point, 1 halo
+               ELSEIF( c_NFtype == 'F' ) THEN                          !   north-pole folding F-pivot, T-point, 1 halo
                   lloce(inx/2+1,iny-1) = lloce(inx/2,iny-1)            !      here we have 1 halo (even if nn_hls>1)
                   lloce(inx  -1,iny-1) = lloce(2    ,iny-1)
@@ -1176,5 +1022,5 @@
             ENDIF
             !                                                          ! first and last column were not read
-            IF( jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7 ) THEN
+            IF( l_Iperio ) THEN
                lloce(1,:) = lloce(inx-1,:)   ;   lloce(inx,:) = lloce(2,:)   ! east-west periodocity
             ELSE
@@ -1195,5 +1041,5 @@
       CALL mpp_sum( 'mppini', inboce_1d )
       inboce = RESHAPE(inboce_1d, (/inbi, inbj/))
-      ldisoce(:,:) = inboce(:,:) /= 0
+      ldIsOce(:,:) = inboce(:,:) /= 0
       DEALLOCATE(inboce, inboce_1d)
       !
@@ -1201,7 +1047,7 @@
 
 
-   SUBROUTINE readbot_strip( kjstr, kjcnt, ldoce )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE readbot_strip  ***
+   SUBROUTINE read_mask( kistr, kjstr, kicnt, kjcnt, ldoce )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE read_mask  ***
       !!
       !! ** Purpose : Read relevant bathymetric information in order to
@@ -1211,10 +1057,10 @@
       !! ** Method  : read stipe of size (Ni0glo,...)
       !!----------------------------------------------------------------------
-      INTEGER                         , INTENT(in   ) ::   kjstr       ! starting j position of the reading
-      INTEGER                         , INTENT(in   ) ::   kjcnt       ! number of lines to read
-      LOGICAL, DIMENSION(Ni0glo,kjcnt), INTENT(  out) ::   ldoce       ! ldoce(i,j) = .true. if the point (i,j) is ocean
-      !
-      INTEGER                           ::   inumsave                ! local logical unit
-      REAL(wp), DIMENSION(Ni0glo,kjcnt) ::   zbot, zbdy
+      INTEGER                        , INTENT(in   ) ::   kistr, kjstr   ! starting i and j position of the reading
+      INTEGER                        , INTENT(in   ) ::   kicnt, kjcnt   ! number of points to read in i and j directions
+      LOGICAL, DIMENSION(kicnt,kjcnt), INTENT(  out) ::   ldoce          ! ldoce(i,j) = .true. if the point (i,j) is ocean
+      !
+      INTEGER                          ::   inumsave                     ! local logical unit
+      REAL(wp), DIMENSION(kicnt,kjcnt) ::   zbot, zbdy
       !!----------------------------------------------------------------------
       !
@@ -1222,5 +1068,5 @@
       !
       IF( numbot /= -1 ) THEN
-         CALL iom_get( numbot, jpdom_unknown, 'bottom_level', zbot, kstart = (/1,kjstr/), kcount = (/Ni0glo, kjcnt/) )
+         CALL iom_get( numbot, jpdom_unknown, 'bottom_level', zbot, kstart = (/kistr,kjstr/), kcount = (/kicnt, kjcnt/) )
       ELSE
          zbot(:,:) = 1._wp                      ! put a non-null value
@@ -1228,15 +1074,15 @@
       !
       IF( numbdy /= -1 ) THEN                   ! Adjust with bdy_msk if it exists
-         CALL iom_get ( numbdy, jpdom_unknown,     'bdy_msk', zbdy, kstart = (/1,kjstr/), kcount = (/Ni0glo, kjcnt/) )
+         CALL iom_get ( numbdy, jpdom_unknown,     'bdy_msk', zbdy, kstart = (/kistr,kjstr/), kcount = (/kicnt, kjcnt/) )
          zbot(:,:) = zbot(:,:) * zbdy(:,:)
       ENDIF
       !
-      ldoce(:,:) = zbot(:,:) > 0._wp
+      ldoce(:,:) = NINT(zbot(:,:)) > 0
       numout = inumsave
       !
-   END SUBROUTINE readbot_strip
-
-
-   SUBROUTINE mpp_getnum( ldisoce, kproc, kipos, kjpos )
+   END SUBROUTINE read_mask
+
+
+   SUBROUTINE mpp_getnum( ldIsOce, kproc, kipos, kjpos )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE mpp_getnum  ***
@@ -1246,6 +1092,6 @@
       !! ** Method  : start from bottom left. First skip land subdomain, and finally use them if needed
       !!----------------------------------------------------------------------
-      LOGICAL, DIMENSION(:,:), INTENT(in   ) ::   ldisoce     ! F if land process
-      INTEGER, DIMENSION(:,:), INTENT(  out) ::   kproc       ! subdomain number (-1 if supressed, starting at 0)
+      LOGICAL, DIMENSION(:,:), INTENT(in   ) ::   ldIsOce     ! F if land process
+      INTEGER, DIMENSION(:,:), INTENT(  out) ::   kproc       ! subdomain number (-1 if not existing, starting at 0)
       INTEGER, DIMENSION(  :), INTENT(  out) ::   kipos       ! i-position of the subdomain (from 1 to jpni)
       INTEGER, DIMENSION(  :), INTENT(  out) ::   kjpos       ! j-position of the subdomain (from 1 to jpnj)
@@ -1255,6 +1101,6 @@
       !!----------------------------------------------------------------------
       !
-      ini = SIZE(ldisoce, dim = 1)
-      inj = SIZE(ldisoce, dim = 2)
+      ini = SIZE(ldIsOce, dim = 1)
+      inj = SIZE(ldIsOce, dim = 2)
       inij = SIZE(kipos)
       !
@@ -1266,5 +1112,5 @@
          ii = 1 + MOD(iarea0,ini)
          ij = 1 +     iarea0/ini
-         IF( ldisoce(ii,ij) ) THEN
+         IF( ldIsOce(ii,ij) ) THEN
             icont = icont + 1
             kproc(ii,ij) = icont
@@ -1274,10 +1120,10 @@
       END DO
       ! if needed add some land subdomains to reach inij active subdomains
-      i2add = inij - COUNT( ldisoce )
+      i2add = inij - COUNT( ldIsOce )
       DO jarea = 1, ini*inj
          iarea0 = jarea - 1
          ii = 1 + MOD(iarea0,ini)
          ij = 1 +     iarea0/ini
-         IF( .NOT. ldisoce(ii,ij) .AND. i2add > 0 ) THEN
+         IF( .NOT. ldIsOce(ii,ij) .AND. i2add > 0 ) THEN
             icont = icont + 1
             kproc(ii,ij) = icont
@@ -1289,4 +1135,93 @@
       !
    END SUBROUTINE mpp_getnum
+
+
+   SUBROUTINE init_excl_landpt
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE   ***
+      !!
+      !! ** Purpose : exclude exchanges which contain only land points
+      !!
+      !! ** Method  : if a send or receive buffer constains only land point we
+      !!              flag off the corresponding communication
+      !!              Warning: this selection depend on the halo size -> loop on halo size
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER ::   inumsave
+      INTEGER ::   jh
+      INTEGER ::   ipi, ipj
+      INTEGER ::   iiwe, iiea, iist, iisz 
+      INTEGER ::   ijso, ijno, ijst, ijsz 
+      LOGICAL ::   llsave
+      REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   zmsk
+      LOGICAL , DIMENSION(Ni_0,Nj_0,1)      ::   lloce
+      !!----------------------------------------------------------------------
+      !
+      ! read the land-sea mask on the inner domain
+      CALL read_mask( nimpp, njmpp, Ni_0, Nj_0, lloce(:,:,1) )
+      !
+      ! Here we look only at communications excluding the NP folding.
+      ! As lbcnfd not validated if halo size /= nn_hls, we switch if off temporary...
+      llsave = l_IdoNFold
+      l_IdoNFold = .FALSE.
+      !
+      DO jh = 1, n_hlsmax    ! different halo size
+         !
+         ipi = Ni_0 + 2*jh   ! local domain size
+         ipj = Nj_0 + 2*jh
+         !
+         ALLOCATE( zmsk(ipi,ipj) )
+         zmsk(jh+1:jh+Ni_0,jh+1:jh+Nj_0) = REAL(COUNT(lloce, dim = 3), wp)   ! define inner domain -> need REAL to use lbclnk
+         CALL lbc_lnk('mppini', zmsk, 'T', 1._wp, khls = jh)                 ! fill halos
+         !        
+         iiwe = jh   ;   iiea = Ni_0   ! bottom-left corfer - 1 of the sent data
+         ijso = jh   ;   ijno = Nj_0
+         IF( nn_comm == 1 ) THEN 
+            iist =  0   ;   iisz = ipi
+            ijst =  0   ;   ijsz = ipj
+         ELSE
+            iist = jh   ;   iisz = Ni_0
+            ijst = jh   ;   ijsz = Nj_0
+         ENDIF
+IF( nn_comm == 1 ) THEN       ! SM: NOT WORKING FOR NEIGHBOURHOOD COLLECTIVE COMMUNICATIONS, I DON'T KNOW WHY... 
+         ! do not send if we send only land points
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiSnei(jh,jpwe) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiSnei(jh,jpea) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijso+1:ijso+jh  ) )) == 0 )   mpiSnei(jh,jpso) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijno+1:ijno+jh  ) )) == 0 )   mpiSnei(jh,jpno) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiSnei(jh,jpsw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiSnei(jh,jpse) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiSnei(jh,jpnw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiSnei(jh,jpne) = -1
+         !
+         iiwe = iiwe-jh   ;   iiea = iiea+jh   ! bottom-left corfer - 1 of the received data
+         ijso = ijso-jh   ;   ijno = ijno+jh
+         ! do not send if we send only land points
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiRnei(jh,jpwe) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijst+1:ijst+ijsz) )) == 0 )   mpiRnei(jh,jpea) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijso+1:ijso+jh  ) )) == 0 )   mpiRnei(jh,jpso) = -1
+         IF( NINT(SUM( zmsk(iist+1:iist+iisz,ijno+1:ijno+jh  ) )) == 0 )   mpiRnei(jh,jpno) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiRnei(jh,jpsw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijso+1:ijso+jh  ) )) == 0 )   mpiRnei(jh,jpse) = -1
+         IF( NINT(SUM( zmsk(iiwe+1:iiwe+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiRnei(jh,jpnw) = -1
+         IF( NINT(SUM( zmsk(iiea+1:iiea+jh  ,ijno+1:ijno+jh  ) )) == 0 )   mpiRnei(jh,jpne) = -1
+ENDIF
+         !
+         ! Specific (and rare) problem in corner treatment because we do 1st West-East comm, next South-North comm
+         IF( nn_comm == 1 ) THEN
+            IF( mpiSnei(jh,jpwe) > -1 )   mpiSnei(jh, (/jpsw,jpnw/) ) = -1   ! SW and NW corners already sent through West nei
+            IF( mpiSnei(jh,jpea) > -1 )   mpiSnei(jh, (/jpse,jpne/) ) = -1   ! SE and NE corners already sent through East nei
+            IF( mpiRnei(jh,jpso) > -1 )   mpiRnei(jh, (/jpsw,jpse/) ) = -1   ! SW and SE corners will be received through South nei
+            IF( mpiRnei(jh,jpno) > -1 )   mpiRnei(jh, (/jpnw,jpne/) ) = -1   ! NW and NE corners will be received through North nei
+        ENDIF
+         !
+         DEALLOCATE( zmsk )
+         !
+         CALL mpp_ini_nc(jh)    ! Initialize/Update communicator for neighbourhood collective communications
+         !
+      END DO
+      l_IdoNFold = llsave
+
+   END SUBROUTINE init_excl_landpt
 
 
@@ -1326,5 +1261,5 @@
       ENDIF
       !
-      CALL flio_dom_set ( jpnij, nproc, idid, iglo, iloc, iabsf, iabsl, ihals, ihale, 'BOX', nidom)
+      CALL flio_dom_set ( jpnij, narea-1, idid, iglo, iloc, iabsf, iabsl, ihals, ihale, 'BOX', nidom)
       !
    END SUBROUTINE init_ioipsl
@@ -1345,38 +1280,30 @@
       !!----------------------------------------------------------------------
       !
-      !initializes the north-fold communication variables
-      isendto(:) = 0
-      nsndto     = 0
-      !
-      IF ( njmpp == MAXVAL( njmppt ) ) THEN      ! if I am a process in the north
+      !sxM is the first point (in the global domain) needed to compute the north-fold for the current process
+      sxM = jpiglo - nimpp - jpi + 1
+      !dxM is the last point (in the global domain) needed to compute the north-fold for the current process
+      dxM = jpiglo - nimpp + 2
+      !
+      ! loop over the other north-fold processes to find the processes
+      ! managing the points belonging to the sxT-dxT range
+      !
+      nsndto = 0
+      DO jn = 1, jpni
          !
-         !sxM is the first point (in the global domain) needed to compute the north-fold for the current process
-         sxM = jpiglo - nimppt(narea) - jpiall(narea) + 1
-         !dxM is the last point (in the global domain) needed to compute the north-fold for the current process
-         dxM = jpiglo - nimppt(narea) + 2
+         sxT = nfimpp(jn)                    ! sxT = 1st  point (in the global domain) of the jn process
+         dxT = nfimpp(jn) + nfjpi(jn) - 1    ! dxT = last point (in the global domain) of the jn process
          !
-         ! loop over the other north-fold processes to find the processes
-         ! managing the points belonging to the sxT-dxT range
+         IF    ( sxT < sxM  .AND.  sxM < dxT ) THEN
+            nsndto          = nsndto + 1
+            isendto(nsndto) = jn
+         ELSEIF( sxM <= sxT  .AND.  dxM >= dxT ) THEN
+            nsndto          = nsndto + 1
+            isendto(nsndto) = jn
+         ELSEIF( dxM <  dxT  .AND.  sxT <  dxM ) THEN
+            nsndto          = nsndto + 1
+            isendto(nsndto) = jn
+         ENDIF
          !
-         DO jn = 1, jpni
-            !
-            sxT = nfimpp(jn)                    ! sxT = 1st  point (in the global domain) of the jn process
-            dxT = nfimpp(jn) + nfjpi(jn) - 1    ! dxT = last point (in the global domain) of the jn process
-            !
-            IF    ( sxT < sxM  .AND.  sxM < dxT ) THEN
-               nsndto          = nsndto + 1
-               isendto(nsndto) = jn
-            ELSEIF( sxM <= sxT  .AND.  dxM >= dxT ) THEN
-               nsndto          = nsndto + 1
-               isendto(nsndto) = jn
-            ELSEIF( dxM <  dxT  .AND.  sxT <  dxM ) THEN
-               nsndto          = nsndto + 1
-               isendto(nsndto) = jn
-            ENDIF
-            !
-         END DO
-         !
-      ENDIF
-      l_north_nogather = .TRUE.
+      END DO
       !
    END SUBROUTINE init_nfdcom
@@ -1391,28 +1318,16 @@
       !!----------------------------------------------------------------------
       !
-      Nis0 =   1+nn_hls   ;   Nis1 = Nis0-1   ;   Nis2 = MAX(  1, Nis0-2)
-      Njs0 =   1+nn_hls   ;   Njs1 = Njs0-1   ;   Njs2 = MAX(  1, Njs0-2)
-      !
-      Nie0 = jpi-nn_hls   ;   Nie1 = Nie0+1   ;   Nie2 = MIN(jpi, Nie0+2)
-      Nje0 = jpj-nn_hls   ;   Nje1 = Nje0+1   ;   Nje2 = MIN(jpj, Nje0+2)
-      !
-      IF( nn_hls == 1 ) THEN          !* halo size of 1
-         !
-         Nis1nxt2 = Nis0   ;   Njs1nxt2 = Njs0
-         Nie1nxt2 = Nie0   ;   Nje1nxt2 = Nje0
-         !
-      ELSE                            !* larger halo size...
-         !
-         Nis1nxt2 = Nis1   ;   Njs1nxt2 = Njs1
-         Nie1nxt2 = Nie1   ;   Nje1nxt2 = Nje1
-         !
-      ENDIF
+      Nis0 =   1+nn_hls
+      Njs0 =   1+nn_hls
+      Nie0 = jpi-nn_hls
+      Nje0 = jpj-nn_hls
       !
       Ni_0 = Nie0 - Nis0 + 1
       Nj_0 = Nje0 - Njs0 + 1
-      Ni_1 = Nie1 - Nis1 + 1
-      Nj_1 = Nje1 - Njs1 + 1
-      Ni_2 = Nie2 - Nis2 + 1
-      Nj_2 = Nje2 - Njs2 + 1
+      !
+      ! old indices to be removed...
+      jpim1 = jpi-1                             ! inner domain indices
+      jpjm1 = jpj-1                             !   "           "
+      jpkm1 = jpk-1                             !   "           "
       !
    END SUBROUTINE init_doloop
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfc1d_c2d.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfc1d_c2d.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfc1d_c2d.F90	(revision 14644)
@@ -95,5 +95,5 @@
          END_3D
          ! Lateral boundary conditions
-         CALL lbc_lnk_multi( 'ldfc1d_c2d', pah1, 'U', 1.0_wp , pah2, 'V', 1.0_wp )
+         CALL lbc_lnk( 'ldfc1d_c2d', pah1, 'U', 1.0_wp , pah2, 'V', 1.0_wp )
          !
       CASE DEFAULT                        ! error
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfdyn.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfdyn.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfdyn.F90	(revision 14644)
@@ -99,7 +99,7 @@
       !!    nn_ahm_ijk_t  =  0 => = constant
       !!                  = 10 => = F(z) :     = constant with a reduction of 1/4 with depth 
-      !!                  =-20 => = F(i,j)     = shape read in 'eddy_viscosity.nc' file
+      !!                  =-20 => = F(i,j)     = shape read in 'eddy_viscosity_2D.nc' file
       !!                  = 20    = F(i,j)     = F(e1,e2) or F(e1^3,e2^3) (lap or bilap case)
-      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_viscosity.nc'  file
+      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_viscosity_3D.nc'  file
       !!                  = 30    = F(i,j,k)   = 2D (case 20) + decrease with depth (case 10)
       !!                  = 31    = F(i,j,k,t) = F(local velocity) (  |u|e  /12   laplacian operator
@@ -412,5 +412,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( 'ldfdyn', ahmt, 'T', 1.0_wp,  ahmf, 'F', 1.0_wp )
+         CALL lbc_lnk( 'ldfdyn', ahmt, 'T', 1.0_wp,  ahmf, 'F', 1.0_wp )
          !
          !
@@ -444,5 +444,5 @@
             END DO
             !
-            CALL lbc_lnk_multi( 'ldfdyn', dtensq, 'T', 1.0_wp )  ! lbc_lnk on dshesq not needed
+            CALL lbc_lnk( 'ldfdyn', dtensq, 'T', 1.0_wp )  ! lbc_lnk on dshesq not needed
             !
             DO jk = 1, jpkm1
@@ -495,5 +495,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( 'ldfdyn', ahmt, 'T', 1.0_wp , ahmf, 'F', 1.0_wp )
+         CALL lbc_lnk( 'ldfdyn', ahmt, 'T', 1.0_wp , ahmf, 'F', 1.0_wp )
          !
       END SELECT
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfslp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfslp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfslp.F90	(revision 14644)
@@ -229,5 +229,5 @@
 !!gm end modif
       END_3D
-      CALL lbc_lnk_multi( 'ldfslp', zwz, 'U', -1.0_wp,  zww, 'V', -1.0_wp )      ! lateral boundary conditions
+      CALL lbc_lnk( 'ldfslp', zwz, 'U', -1.0_wp,  zww, 'V', -1.0_wp )      ! lateral boundary conditions
       !
       !                                    !* horizontal Shapiro filter
@@ -245,18 +245,4 @@
                &                       + 4.*  zww(ji,jj    ,jk)                       )
          END_2D
-         DO jj = 3, jpj-2                                    ! other rows
-            DO ji = 2, jpim1   ! vector opt.
-               uslp(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
-                  &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
-                  &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
-                  &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
-                  &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
-               vslp(ji,jj,jk) = z1_16 * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
-                  &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
-                  &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
-                  &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
-                  &                       + 4.*  zww(ji,jj    ,jk)                       )
-            END DO
-         END DO
          !                                 !* decrease along coastal boundaries
          DO_2D( 0, 0, 0, 0 )
@@ -303,5 +289,5 @@
 !!gm end modif
       END_3D
-      CALL lbc_lnk_multi( 'ldfslp', zwz, 'T', -1.0_wp,  zww, 'T', -1.0_wp )      ! lateral boundary conditions
+      CALL lbc_lnk( 'ldfslp', zwz, 'T', -1.0_wp,  zww, 'T', -1.0_wp )      ! lateral boundary conditions
       !
       !                                           !* horizontal Shapiro filter
@@ -321,20 +307,4 @@
                  &               + 4.*  zww(ji  ,jj  ,jk)                         ) * zcofw
          END_2D
-         DO jj = 3, jpj-2                               ! other rows
-            DO ji = 2, jpim1   ! vector opt.
-               zcofw = wmask(ji,jj,jk) * z1_16
-               wslpi(ji,jj,jk) = (         zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
-                    &               +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
-                    &               + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
-                    &               +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
-                    &               + 4.*  zwz(ji  ,jj  ,jk)                         ) * zcofw
-
-               wslpj(ji,jj,jk) = (         zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
-                    &               +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
-                    &               + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
-                    &               +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
-                    &               + 4.*  zww(ji  ,jj  ,jk)                         ) * zcofw
-            END DO
-         END DO
          !                                        !* decrease in vicinity of topography
          DO_2D( 0, 0, 0, 0 )
@@ -348,5 +318,5 @@
       ! IV. Lateral boundary conditions
       ! ===============================
-      CALL lbc_lnk_multi( 'ldfslp', uslp , 'U', -1.0_wp , vslp , 'V', -1.0_wp , wslpi, 'W', -1.0_wp, wslpj, 'W', -1.0_wp )
+      CALL lbc_lnk( 'ldfslp', uslp , 'U', -1.0_wp , vslp , 'V', -1.0_wp , wslpi, 'W', -1.0_wp, wslpj, 'W', -1.0_wp )
 
       IF(sn_cfctl%l_prtctl) THEN
@@ -689,5 +659,5 @@
       END_2D
       !!gm this lbc_lnk should be useless....
-      CALL lbc_lnk_multi( 'ldfslp', uslpml , 'U', -1.0_wp , vslpml , 'V', -1.0_wp , wslpiml, 'W', -1.0_wp , wslpjml, 'W', -1.0_wp ) 
+      CALL lbc_lnk( 'ldfslp', uslpml , 'U', -1.0_wp , vslpml , 'V', -1.0_wp , wslpiml, 'W', -1.0_wp , wslpjml, 'W', -1.0_wp ) 
       !
    END SUBROUTINE ldf_slp_mxl
@@ -757,5 +727,5 @@
 !               END DO
 !            END DO
-!            CALL lbc_lnk_multi( 'ldfslp', uslp , 'U', -1. ; CALL lbc_lnk( 'ldfslp', vslp , 'V', -1.,  wslpi, 'W', -1.,  wslpj, 'W', -1. )
+!            CALL lbc_lnk( 'ldfslp', uslp , 'U', -1. ; CALL lbc_lnk( 'ldfslp', vslp , 'V', -1.,  wslpi, 'W', -1.,  wslpj, 'W', -1. )
 !!gm         ENDIF
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldftra.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldftra.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldftra.F90	(revision 14644)
@@ -118,9 +118,9 @@
       !!                  = 10 => = F(z) : constant with a reduction of 1/4 with depth
       !!                  !
-      !!                  =-20 => = F(i,j)   = shape read in 'eddy_diffusivity.nc' file
+      !!                  =-20 => = F(i,j)   = shape read in 'eddy_diffusivity_2D.nc' file
       !!                  = 20    = F(i,j)   = F(e1,e2) or F(e1^3,e2^3) (lap or bilap case)
       !!                  = 21    = F(i,j,t) = F(growth rate of baroclinic instability)
       !!                  !
-      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_diffusivity.nc' file
+      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_diffusivity_3D.nc' file
       !!                  = 30    = F(i,j,k)   = 2D (case 20) + decrease with depth (case 10)
       !!                  = 31    = F(i,j,k,t) = F(local velocity) (  1/2  |u|e     laplacian operator
@@ -481,9 +481,9 @@
       !!                  = 10 => = F(z) : constant with a reduction of 1/4 with depth
       !!                  !
-      !!                  =-20 => = F(i,j)   = shape read in 'eddy_diffusivity.nc' file
+      !!                  =-20 => = F(i,j)   = shape read in 'eddy_induced_velocity_2D.nc' file
       !!                  = 20    = F(i,j)   = F(e1,e2) or F(e1^3,e2^3) (lap or bilap case)
       !!                  = 21    = F(i,j,t) = F(growth rate of baroclinic instability)
       !!                  !
-      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_diffusivity.nc' file
+      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_induced_velocity_3D.nc' file
       !!                  = 30    = F(i,j,k)   = 2D (case 20) + decrease with depth (case 10)
       !!
@@ -697,5 +697,5 @@
          paeiv(ji,jj,1) = 0.5_wp * ( zaeiw(ji,jj) + zaeiw(ji  ,jj+1) ) * vmask(ji,jj,1)
       END_2D
-      CALL lbc_lnk_multi( 'ldftra', paeiu(:,:,1), 'U', 1.0_wp , paeiv(:,:,1), 'V', 1.0_wp )      ! lateral boundary condition
+      CALL lbc_lnk( 'ldftra', paeiu(:,:,1), 'U', 1.0_wp , paeiv(:,:,1), 'V', 1.0_wp )      ! lateral boundary condition
 
       DO jk = 2, jpkm1                          !==  deeper values equal the surface one  ==!
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/mpp_map.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/mpp_map.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/mpp_map.F90	(revision 14644)
@@ -13,5 +13,5 @@
    USE par_oce , ONLY :   jpi, jpj, Nis0, Nie0, Njs0, Nje0   ! Ocean parameters
    USE dom_oce , ONLY :   mig, mjg, narea                    ! Ocean space and time domain variables
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    USE lib_mpp , ONLY :   mpi_comm_oce   ! MPP library
 #endif
@@ -45,5 +45,5 @@
       !!----------------------------------------------------------------------
       INTEGER, DIMENSION(:,:), ALLOCATABLE ::   imppmap   !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       INTEGER :: ierr
 
@@ -69,5 +69,5 @@
       ! Get global data
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
 
       ! Call the MPI library to find the max across processors
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_averg_h2d.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_averg_h2d.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_averg_h2d.F90	(revision 14644)
@@ -21,6 +21,5 @@
       & e1t, e2t, &
       & e1f, e2f, &
-      & glamt, gphit, &
-      & nproc
+      & glamt, gphit
    USE in_out_manager
    USE obs_const, ONLY : &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_grid.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_grid.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_grid.F90	(revision 14644)
@@ -134,5 +134,5 @@
                CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             1, jpi, 1, jpj,           &
-                  &                             nproc, jpnij,             &
+                  &                             narea-1, jpnij,           &
                   &                             CASTWP(glamt), CASTWP(gphit), tmask,      &
                   &                             kobsin, plam, pphi,       &
@@ -141,5 +141,5 @@
                CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             1, jpi, 1, jpj,           &
-                  &                             nproc, jpnij,             &
+                  &                             narea-1, jpnij,           &
                   &                             glamu, gphiu, umask,      &
                   &                             kobsin, plam, pphi,       &
@@ -148,5 +148,5 @@
                CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             1, jpi, 1, jpj,           &
-                  &                             nproc, jpnij,             &
+                  &                             narea-1, jpnij,           &
                   &                             glamv, gphiv, vmask,      &
                   &                             kobsin, plam, pphi,       &
@@ -155,5 +155,5 @@
                CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo, &
                   &                             1, jpi, 1, jpj,           &
-                  &                             nproc, jpnij,             &
+                  &                             narea-1, jpnij,           &
                   &                             CASTWP(glamf), CASTWP(gphif), fmask,      &
                   &                             kobsin, plam, pphi,       &
@@ -180,5 +180,5 @@
       !!
       !! ** Action  : Return kproc holding the observation and kiobsi,kobsj
-      !!              valid on kproc=nproc processor only.
+      !!              valid on kproc=narea-1 processor only.
       !!   
       !! History :
@@ -252,5 +252,5 @@
          jlon     = jpiglo
          jlat     = jpjglo
-         joffset  = nproc
+         joffset  = narea-1
          jostride = jpnij
       ELSE
@@ -517,10 +517,10 @@
                         IF ( ABS( zlam - zplam(jo) ) < 1e-6 ) THEN
                            IF ( llinvalidcell(ji,jj) ) THEN
-                              kproc(jo) = nproc + 1000000
+                              kproc(jo) = narea-1 + 1000000
                               kobsi(jo) = ji + 1
                               kobsj(jo) = jj + 1
                               CYCLE
                            ELSE
-                              kproc(jo) = nproc
+                              kproc(jo) = narea-1
                               kobsi(jo) = ji + 1
                               kobsj(jo) = jj + 1
@@ -556,10 +556,10 @@
                            &          zlamtm(:,ji,jj), zphitm(:,ji,jj) ) ) THEN
                            IF ( llinvalidcell(ji,jj) ) THEN
-                              kproc(jo) = nproc + 1000000
+                              kproc(jo) = narea-1 + 1000000
                               kobsi(jo) = ji + 1
                               kobsj(jo) = jj + 1
                               CYCLE
                            ELSE
-                              kproc(jo) = nproc
+                              kproc(jo) = narea-1
                               kobsi(jo) = ji + 1
                               kobsj(jo) = jj + 1
@@ -588,10 +588,10 @@
                            &          zlamtm(:,ji,jj), zphitm(:,ji,jj) ) ) THEN
                            IF ( llinvalidcell(ji,jj) ) THEN
-                              kproc(jo) = nproc + 1000000
+                              kproc(jo) = narea-1 + 1000000
                               kobsi(jo) = ji + 1
                               kobsj(jo) = jj + 1
                               CYCLE
                            ELSE
-                              kproc(jo) = nproc
+                              kproc(jo) = narea-1
                               kobsi(jo) = ji + 1
                               kobsj(jo) = jj + 1
@@ -720,5 +720,5 @@
             ! define the following format: "(a,a,ix.x,a,ix.x,a,ix.x,a)"
             WRITE(clfmt, "('(a,a,i', i1, '.', i1',a,i', i1, '.', i1',a,i', i1, '.', i1',a)')") idg, idg, idg, idg, idg, idg
-            WRITE(cfname,      clfmt     ) TRIM(cn_gridsearchfile),'_', nproc,'of', jpni,'by', jpnj,'.nc'
+            WRITE(cfname,      clfmt     ) TRIM(cn_gridsearchfile),'_', narea-1,'of', jpni,'by', jpnj,'.nc'
          ENDIF
 
@@ -824,5 +824,5 @@
             CALL obs_grd_bruteforce( jpi, jpj, jpiglo, jpjglo,  &
                &                     1, jpi, 1, jpj,            &
-               &                     nproc, jpnij,              &
+               &                     narea-1, jpnij,            &
                &                     CASTWP(glamt), CASTWP(gphit), tmask,       &
                &                     nlons*nlats, lonsi, latsi, &
@@ -1074,5 +1074,5 @@
 
             IF ( ( .NOT. ln_grid_global ) .OR. &
-               & ( ( ln_grid_global ) .AND. ( nproc==0 ) ) ) THEN
+               & ( ( ln_grid_global ) .AND. ( narea-1==0 ) ) ) THEN
 
                CALL chkerr( nf90_create (TRIM(cfname), nf90_clobber, idfile), &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_mpp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_mpp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_mpp.F90	(revision 14644)
@@ -18,8 +18,7 @@
    !! obs_mpp_sum_integer   : Sum an integer from all processors
    !!----------------------------------------------------------------------
-   USE dom_oce, ONLY :   nproc, mig, mjg   ! Ocean space and time domain variables
    USE mpp_map, ONLY :   mppmap
    USE in_out_manager
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    USE lib_mpp, ONLY :   mpi_comm_oce      ! MPP library
 #endif
@@ -61,5 +60,5 @@
       INTEGER, DIMENSION(kno), INTENT(inout) ::   kvals   ! Array to send on kroot, receive for non-kroot
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       INTEGER :: ierr 
@@ -95,5 +94,5 @@
       INTEGER, DIMENSION(kno), INTENT(inout) ::   kvals   ! Array to send on kroot, receive for non-kroot  
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       INTEGER :: ierr 
@@ -134,5 +133,5 @@
       INTEGER, DIMENSION(kno), INTENT(inout) ::   kobsp
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       !
@@ -192,5 +191,5 @@
       INTEGER, DIMENSION(kno), INTENT(  out) ::   kvalsout
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       INTEGER :: ierr
@@ -230,5 +229,5 @@
       INTEGER, INTENT(  out) ::   kvalout
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
       INTEGER :: ierr
@@ -270,5 +269,5 @@
       INTEGER :: ierr
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
 INCLUDE 'mpif.h'
@@ -318,5 +317,5 @@
       INTEGER :: ierr
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
 INCLUDE 'mpif.h'
@@ -360,5 +359,5 @@
       INTEGER :: jproc
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
 INCLUDE 'mpif.h'
@@ -412,5 +411,5 @@
       INTEGER :: jproc
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       !
 INCLUDE 'mpif.h'
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_prep.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_prep.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_prep.F90	(revision 14644)
@@ -66,5 +66,5 @@
       !! * Modules used
       USE par_oce             ! Ocean parameters
-      USE dom_oce, ONLY       :   glamt, gphit, tmask, nproc   ! Geographical information
+      USE dom_oce, ONLY       :   glamt, gphit, tmask   ! Geographical information
       !! * Arguments
       TYPE(obs_surf), INTENT(INOUT) :: surfdata    ! Full set of surface data
@@ -267,6 +267,5 @@
       USE par_oce             ! Ocean parameters
       USE dom_oce, ONLY : &   ! Geographical information
-         & gdept_1d,             &
-         & nproc
+         & gdept_1d
 
       !! * Arguments
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_read_prof.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_read_prof.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_read_prof.F90	(revision 14644)
@@ -404,8 +404,8 @@
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
-                  IF ( nproc == 0 ) THEN
-                     IF ( inpfiles(jj)%iproc(ji,1) >  nproc ) CYCLE
+                  IF ( narea == 1 ) THEN
+                     IF ( inpfiles(jj)%iproc(ji,1) >  narea-1 ) CYCLE
                   ELSE
-                     IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE
+                     IF ( inpfiles(jj)%iproc(ji,1) /= narea-1 ) CYCLE
                   ENDIF
                   llvalprof = .FALSE.
@@ -538,8 +538,8 @@
             & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
 
-            IF ( nproc == 0 ) THEN
-               IF ( inpfiles(jj)%iproc(ji,1) >  nproc ) CYCLE
+            IF ( narea == 1 ) THEN
+               IF ( inpfiles(jj)%iproc(ji,1) >  narea-1 ) CYCLE
             ELSE
-               IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE
+               IF ( inpfiles(jj)%iproc(ji,1) /= narea-1 ) CYCLE
             ENDIF
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_read_surf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_read_surf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_read_surf.F90	(revision 14644)
@@ -300,8 +300,8 @@
                IF ( ( inpfiles(jj)%ptim(ji) >  djulini(jj) ) .AND. &
                   & ( inpfiles(jj)%ptim(ji) <= djulend(jj) )       ) THEN
-                  IF ( nproc == 0 ) THEN
-                     IF ( inpfiles(jj)%iproc(ji,1) >  nproc ) CYCLE
+                  IF ( narea == 1 ) THEN
+                     IF ( inpfiles(jj)%iproc(ji,1) >  narea-1 ) CYCLE
                   ELSE
-                     IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE
+                     IF ( inpfiles(jj)%iproc(ji,1) /= narea-1 ) CYCLE
                   ENDIF
                   llvalprof = .FALSE.
@@ -371,8 +371,8 @@
             & ( inpfiles(jj)%ptim(ji) <= djulend(jj) ) ) THEN
 
-            IF ( nproc == 0 ) THEN
-               IF ( inpfiles(jj)%iproc(ji,1) >  nproc ) CYCLE
+            IF ( narea == 1 ) THEN
+               IF ( inpfiles(jj)%iproc(ji,1) >  narea-1 ) CYCLE
             ELSE
-               IF ( inpfiles(jj)%iproc(ji,1) /= nproc ) CYCLE
+               IF ( inpfiles(jj)%iproc(ji,1) /= narea-1 ) CYCLE
             ENDIF
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_utils.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_utils.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_utils.F90	(revision 14644)
@@ -66,6 +66,4 @@
       !! * Modules used
       USE netcdf             ! NetCDF library
-      USE dom_oce, ONLY : &  ! Ocean space and time domain variables
-         & nproc
 
       !! * Arguments
@@ -102,6 +100,4 @@
       !! * Modules used
       USE netcdf             ! NetCDF library
-      USE dom_oce, ONLY : &  ! Ocean space and time domain variables
-         & nproc
 
       !! * Arguments
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_write.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_write.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/OBS/obs_write.F90	(revision 14644)
@@ -210,5 +210,5 @@
       idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 )            ! how many digits to we need to write? min=4, max=9
       WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg   ! '(a,a,ix.x,a)'
-      WRITE(clfname,clfmt) TRIM(clfiletype), '_fdbk_', nproc, '.nc'
+      WRITE(clfname,clfmt) TRIM(clfiletype), '_fdbk_', narea-1, '.nc'
 
       IF(lwp) THEN
@@ -475,5 +475,5 @@
       idg = MAX( INT(LOG10(REAL(jpnij,wp))) + 1, 4 )            ! how many digits to we need to write? min=4, max=9
       WRITE(clfmt, "('(a,a,i', i1, '.', i1, ',a)')") idg, idg   ! '(a,a,ix.x,a)'
-      WRITE(clfname,clfmt) TRIM(clfiletype), '_fdbk_', nproc, '.nc'
+      WRITE(clfname,clfmt) TRIM(clfiletype), '_fdbk_', narea-1, '.nc'
 
       IF(lwp) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/cpl_oasis3.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/cpl_oasis3.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/cpl_oasis3.F90	(revision 14644)
@@ -115,5 +115,5 @@
 
       !------------------------------------------------------------------
-      ! 3rd Get an MPI communicator for OPA local communication
+      ! 3rd Get an MPI communicator for OCE local communication
       !------------------------------------------------------------------
 
@@ -294,5 +294,6 @@
       !
 #if defined key_agrif
-      IF( agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN
+      ! Warning: Agrif_Nb_Fine_Grids not yet defined at this stage for Agrif_Root -> must use Agrif_Root_Only()
+      IF( Agrif_Root_Only() .OR. agrif_fixed() == Agrif_Nb_Fine_Grids() ) THEN
 #endif
       CALL oasis_enddef(nerror)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/fldread.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/fldread.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/fldread.F90	(revision 14644)
@@ -211,5 +211,5 @@
             !
             IF( sd(jf)%ln_tint ) THEN              ! temporal interpolation
-               IF(lwp .AND. kt - nit000 <= 100 ) THEN 
+               IF(lwp .AND. ( kt - nit000 <= 20 .OR. nitend - kt <= 20 ) ) THEN 
                   clfmt = "('   fld_read: var ', a, ' kt = ', i8, ' (', f9.4,' days), Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   &
                      &    "', records b/a: ', i6.4, '/', i6.4, ' (days ', f9.4,'/', f9.4, ')')"
@@ -223,5 +223,5 @@
                sd(jf)%fnow(:,:,:) = ztintb * sd(jf)%fdta(:,:,:,ibb) + ztinta * sd(jf)%fdta(:,:,:,iaa)
             ELSE   ! nothing to do...
-               IF(lwp .AND. kt - nit000 <= 100 ) THEN
+               IF(lwp .AND. ( kt - nit000 <= 20 .OR. nitend - kt <= 20 ) ) THEN
                   clfmt = "('   fld_read: var ', a, ' kt = ', i8,' (', f9.4,' days), Y/M/D = ', i4.4,'/', i2.2,'/', i2.2," //   &
                      &    "', record: ', i6.4, ' (days ', f9.4, ' <-> ', f9.4, ')')"
@@ -251,5 +251,5 @@
       !!---------------------------------------------------------------------
       !
-      IF( nflag == 0 )   nflag = -( HUGE(0) - 10 )
+      IF( nflag == 0 )   nflag = -HUGE(0)
       !
       CALL fld_def( sdjf )
@@ -908,10 +908,10 @@
       TYPE(FLD)        , INTENT(inout) ::   sdjf       ! input field related variables
       !
-      INTEGER, DIMENSION(2)  :: isave
+      INTEGER  :: isave
       LOGICAL  :: llprev, llnext, llstop
       !!----------------------------------------------------------------------
       !
       llprev = sdjf%nrecsec(sdjf%nreclast) < nsec000_1jan000   ! file ends before the beginning of the job -> file may not exist
-      llnext = sdjf%nrecsec(       0     ) > nsecend_1jan000   ! file begins after the end of the job -> file may not exist 
+      llnext = sdjf%nrecsec(      1      ) > nsecend_1jan000   ! file begins after the end of the job -> file may not exist 
 
       llstop = sdjf%ln_clim .OR. .NOT. ( llprev .OR. llnext )
@@ -926,18 +926,17 @@
          IF( llprev ) THEN   ! previous file does not exist : go back to current and accept to read only the first record
             CALL ctl_warn('previous file: '//TRIM(sdjf%clname)//' not found -> go back to current year/month/week/day file')
-            isave(1:2) = sdjf%nrecsec(sdjf%nreclast-1:sdjf%nreclast)   ! save previous file info
-            CALL fld_def( sdjf )   ! go back to current file
-            sdjf%nreclast = 1   ! force to use only the first record (do as if other were not existing...)
-            sdjf%nrecsec(0:1) = isave(1:2)
+            isave = sdjf%nrecsec(sdjf%nreclast)   ! save previous file info
+            CALL fld_def( sdjf )                  ! go back to current file
+            sdjf%nreclast = 1                     ! force to use only the first record (do as if other were not existing...)
          ENDIF
          !
          IF( llnext ) THEN   ! next     file does not exist : go back to current and accept to read only the last  record 
             CALL ctl_warn('next file: '//TRIM(sdjf%clname)//' not found -> go back to current year/month/week/day file')
-            isave(1:2) = sdjf%nrecsec(0:1)    ! save next file info
-            CALL fld_def( sdjf )   ! go back to current file
-            ! -> read last record but keep record info from the first record of next file
-            sdjf%nrecsec(sdjf%nreclast-1:sdjf%nreclast) = isave(1:2)
-            sdjf%nrecsec(0:sdjf%nreclast-2) = nflag
-         ENDIF
+            isave = sdjf%nrecsec(1)               ! save next file info
+            CALL fld_def( sdjf )                  ! go back to current file
+         ENDIF
+         ! -> read "last" record but keep record info from the first record of next file
+         sdjf%nrecsec(  sdjf%nreclast  ) = isave
+         sdjf%nrecsec(0:sdjf%nreclast-1) = nflag
          !
          CALL iom_open( sdjf%clname, sdjf%num, ldiof = LEN_TRIM(sdjf%wgtname) > 0 )   
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/geo2ocean.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/geo2ocean.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/geo2ocean.F90	(revision 14644)
@@ -161,5 +161,5 @@
       ! (computation done on the north stereographic polar plane)
       !
-      DO_2D( 0, 0, 0, 1 )
+      DO_2D( 0, 1, 0, 0 )
          !                  
          zlam = plamt(ji,jj)     ! north pole direction & modulous (at t-point)
@@ -250,5 +250,5 @@
       ! =============== !
 
-      DO_2D( 0, 0, 0, 1 )
+      DO_2D( 0, 1, 0, 0 )
          IF( MOD( ABS( plamv(ji,jj) - plamv(ji,jj-1) ), 360. ) < 1.e-8 ) THEN
             gsint(ji,jj) = 0.
@@ -273,6 +273,6 @@
       ! =========================== !
       !           ! lateral boundary cond.: T-, U-, V-, F-pts, sgn
-      CALL lbc_lnk_multi( 'geo2ocean', gcost, 'T', -1.0_wp, gsint, 'T', -1.0_wp, gcosu, 'U', -1.0_wp, gsinu, 'U', -1.0_wp, & 
-                      &   gcosv, 'V', -1.0_wp, gsinv, 'V', -1.0_wp, gcosf, 'F', -1.0_wp, gsinf, 'F', -1.0_wp  )
+      CALL lbc_lnk( 'geo2ocean', gcost, 'T', -1.0_wp, gsint, 'T', -1.0_wp, gcosu, 'U', -1.0_wp, gsinu, 'U', -1.0_wp, & 
+         &                       gcosv, 'V', -1.0_wp, gsinv, 'V', -1.0_wp, gcosf, 'F', -1.0_wp, gsinf, 'F', -1.0_wp  )
       !
    END SUBROUTINE angle
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbc_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbc_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbc_oce.F90	(revision 14644)
@@ -87,5 +87,5 @@
    INTEGER , PUBLIC, PARAMETER ::   jp_abl     = 4        !: Atmospheric boundary layer    formulation
    INTEGER , PUBLIC, PARAMETER ::   jp_purecpl = 5        !: Pure ocean-atmosphere Coupled formulation
-   INTEGER , PUBLIC, PARAMETER ::   jp_none    = 6        !: for OPA when doing coupling via SAS module
+   INTEGER , PUBLIC, PARAMETER ::   jp_none    = 6        !: for OCE when doing coupling via SAS module
    !
    !!----------------------------------------------------------------------
@@ -94,5 +94,5 @@
    INTEGER , PUBLIC, PARAMETER ::   jp_iam_nemo = 0      !: Initial single executable configuration
    !  (no internal OASIS coupling)
-   INTEGER , PUBLIC, PARAMETER ::   jp_iam_opa  = 1      !: Multi executable configuration - OPA component
+   INTEGER , PUBLIC, PARAMETER ::   jp_iam_oce  = 1      !: Multi executable configuration - OCE component
    !  (internal OASIS coupling)
    INTEGER , PUBLIC, PARAMETER ::   jp_iam_sas  = 2      !: Multi executable configuration - SAS component
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcblk.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcblk.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcblk.F90	(revision 14644)
@@ -40,5 +40,5 @@
    USE sbcdcy         ! surface boundary condition: diurnal cycle
    USE sbcwave , ONLY :   cdn_wave ! wave module
-   USE lib_fortran    ! to use key_nosignedzero
+   USE lib_fortran    ! to use key_nosignedzero and glob_sum
    !
 #if defined key_si3
@@ -348,4 +348,7 @@
       !                                      !- fill the bulk structure with namelist informations
       CALL fld_fill( sf, slf_i, cn_dir, 'sbc_blk_init', 'surface boundary condition -- bulk formulae', 'namsbc_blk' )
+      sf(jp_wndi )%zsgn = -1._wp   ;   sf(jp_wndj )%zsgn = -1._wp   ! vector field at T point: overwrite default definition of zsgn
+      sf(jp_uoatm)%zsgn = -1._wp   ;   sf(jp_voatm)%zsgn = -1._wp   ! vector field at T point: overwrite default definition of zsgn
+      sf(jp_hpgi )%zsgn = -1._wp   ;   sf(jp_hpgj )%zsgn = -1._wp   ! vector field at T point: overwrite default definition of zsgn
       !
       DO jfpr= 1, jpfld
@@ -501,5 +504,6 @@
       !!----------------------------------------------------------------------
       REAL(wp), DIMENSION(jpi,jpj) ::   zssq, zcd_du, zsen, zlat, zevp
-      REAL(wp) :: ztmp
+      REAL(wp) :: ztst
+      LOGICAL  :: llerr
       !!----------------------------------------------------------------------
       !
@@ -508,31 +512,29 @@
       ! Sanity/consistence test on humidity at first time step to detect potential screw-up:
       IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*) ''
-#if defined key_agrif
-         IF(lwp) WRITE(numout,*) ' === AGRIF => Sanity/consistence test on air humidity SKIPPED! :( ==='
-#else
-         ztmp = SUM(tmask(:,:,1)) ! number of ocean points on local proc domain
-         IF( ztmp > 8._wp ) THEN ! test only on proc domains with at least 8 ocean points!
-            ztmp = SUM(sf(jp_humi)%fnow(:,:,1)*tmask(:,:,1))/ztmp ! mean humidity over ocean on proc
-            SELECT CASE( nhumi )
-            CASE( np_humi_sph ) ! specific humidity => expect: 0. <= something < 0.065 [kg/kg] (0.061 is saturation at 45degC !!!)
-               IF(  (ztmp < 0._wp) .OR. (ztmp > 0.065)  ) ztmp = -1._wp
-            CASE( np_humi_dpt ) ! dew-point temperature => expect: 110. <= something < 320. [K]
-               IF( (ztmp < 110._wp).OR.(ztmp > 320._wp) ) ztmp = -1._wp
-            CASE( np_humi_rlh ) ! relative humidity => expect: 0. <= something < 100. [%]
-               IF(  (ztmp < 0._wp) .OR.(ztmp > 100._wp) ) ztmp = -1._wp
-            END SELECT
-            IF(ztmp < 0._wp) THEN
-               IF (lwp) WRITE(numout,'("   Mean humidity value found on proc #",i6.6," is: ",f10.5)') narea, ztmp
-               CALL ctl_stop( 'STOP', 'Something is wrong with air humidity!!!', &
-                  &   ' ==> check the unit in your input files'       , &
-                  &   ' ==> check consistence of namelist choice: specific? relative? dew-point?', &
-                  &   ' ==> ln_humi_sph -> [kg/kg] | ln_humi_rlh -> [%] | ln_humi_dpt -> [K] !!!' )
-            END IF
-         END IF
-         IF(lwp) WRITE(numout,*) ' === Sanity/consistence test on air humidity sucessfuly passed! ==='
-#endif
-         IF(lwp) WRITE(numout,*) ''
-      END IF !IF( kt == nit000 )
+         ! mean humidity over ocean on proc
+         ztst = glob_sum( 'sbcblk', sf(jp_humi)%fnow(:,:,1) * e1e2t(:,:) * tmask(:,:,1) ) / glob_sum( 'sbcblk', e1e2t(:,:) * tmask(:,:,1) )
+         llerr = .FALSE.
+         SELECT CASE( nhumi )
+         CASE( np_humi_sph ) ! specific humidity => expect: 0. <= something < 0.065 [kg/kg] (0.061 is saturation at 45degC !!!)
+            IF( (ztst <   0._wp) .OR. (ztst > 0.065_wp) )   llerr = .TRUE.
+         CASE( np_humi_dpt ) ! dew-point temperature => expect: 110. <= something < 320. [K]
+            IF( (ztst < 110._wp) .OR. (ztst >  320._wp) )   llerr = .TRUE.
+         CASE( np_humi_rlh ) ! relative humidity => expect: 0. <= something < 100. [%]
+            IF( (ztst <   0._wp) .OR. (ztst >  100._wp) )   llerr = .TRUE.
+         END SELECT
+         IF(llerr) THEN
+            WRITE(ctmp1,'("   Error on mean humidity value: ",f10.5)') ztst
+            CALL ctl_stop( 'STOP', ctmp1, 'Something is wrong with air humidity!!!', &
+               &   ' ==> check the unit in your input files'       , &
+               &   ' ==> check consistence of namelist choice: specific? relative? dew-point?', &
+               &   ' ==> ln_humi_sph -> [kg/kg] | ln_humi_rlh -> [%] | ln_humi_dpt -> [K] !!!' )
+         ENDIF
+         IF(lwp) THEN
+            WRITE(numout,*) ''
+            WRITE(numout,*) ' Global mean humidity at kt = nit000: ', ztst
+            WRITE(numout,*) ' === Sanity/consistence test on air humidity sucessfuly passed! ==='
+            WRITE(numout,*) ''
+         ENDIF
+      ENDIF   !IF( kt == nit000 )
       !                                            ! compute the surface ocean fluxes using bulk formulea
       IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
@@ -620,6 +622,6 @@
       !!---------------------------------------------------------------------
       INTEGER , INTENT(in   )                 ::   kt     ! time step index
-      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pwndi  ! atmospheric wind at U-point              [m/s]
-      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pwndj  ! atmospheric wind at V-point              [m/s]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pwndi  ! atmospheric wind at T-point              [m/s]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pwndj  ! atmospheric wind at T-point              [m/s]
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqair  ! specific humidity at T-points            [kg/kg]
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   ptair  ! potential temperature at T-points        [Kelvin]
@@ -830,7 +832,7 @@
 
          IF( ln_crt_fbk ) THEN
-            CALL lbc_lnk_multi( 'sbcblk', utau, 'U', -1._wp, vtau, 'V', -1._wp, taum, 'T', -1._wp )
+            CALL lbc_lnk( 'sbcblk', utau, 'U', -1._wp, vtau, 'V', -1._wp, taum, 'T', 1._wp )
          ELSE
-            CALL lbc_lnk_multi( 'sbcblk', utau, 'U', -1._wp, vtau, 'V', -1._wp )
+            CALL lbc_lnk( 'sbcblk', utau, 'U', -1._wp, vtau, 'V', -1._wp )
          ENDIF
 
@@ -1066,5 +1068,5 @@
             pvtaui(ji,jj) = zztmp2 * ( pvtaui(ji,jj) + pvtaui(ji  ,jj+1) )
          END_2D
-         CALL lbc_lnk_multi( 'sbcblk', putaui, 'U', -1._wp, pvtaui, 'V', -1._wp )
+         CALL lbc_lnk( 'sbcblk', putaui, 'U', -1._wp, pvtaui, 'V', -1._wp )
          !
          IF(sn_cfctl%l_prtctl)  CALL prt_ctl( tab2d_1=putaui  , clinfo1=' blk_ice: putaui : '   &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbccpl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbccpl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbccpl.F90	(revision 14644)
@@ -129,4 +129,5 @@
    INTEGER, PARAMETER ::   jpr_icb    = 61
    INTEGER, PARAMETER ::   jpr_ts_ice = 62   ! Sea ice surface temp
+   !!INTEGER, PARAMETER ::   jpr_qtrice = 63   ! Transmitted solar thru sea-ice
 
    INTEGER, PARAMETER ::   jprcv      = 62   ! total number of fields received
@@ -157,5 +158,5 @@
    INTEGER, PARAMETER ::   jps_rnf    = 24   ! runoffs
    INTEGER, PARAMETER ::   jps_taum   = 25   ! wind stress module
-   INTEGER, PARAMETER ::   jps_fice2  = 26   ! ice fraction sent to OPA (by SAS when doing SAS-OPA coupling)
+   INTEGER, PARAMETER ::   jps_fice2  = 26   ! ice fraction sent to OCE (by SAS when doing SAS-OCE coupling)
    INTEGER, PARAMETER ::   jps_e3t1st = 27   ! first level depth (vvl)
    INTEGER, PARAMETER ::   jps_fraqsr = 28   ! fraction of solar net radiation absorbed in the first ocean level
@@ -202,4 +203,5 @@
       &             sn_rcv_wstrf, sn_rcv_wdrag, sn_rcv_charn, sn_rcv_taw, sn_rcv_bhd, sn_rcv_tusd, sn_rcv_tvsd
    !                                   ! Other namelist parameters
+!!   TYPE(FLD_C) ::   sn_rcv_qtrice
    INTEGER     ::   nn_cplmodel           ! Maximum number of models to/from which NEMO is potentialy sending/receiving data
    LOGICAL     ::   ln_usecplmask         !  use a coupling mask file to merge data received from several models
@@ -238,5 +240,5 @@
       !!             ***  FUNCTION sbc_cpl_alloc  ***
       !!----------------------------------------------------------------------
-      INTEGER :: ierr(5)
+      INTEGER :: ierr(4)
       !!----------------------------------------------------------------------
       ierr(:) = 0
@@ -248,9 +250,6 @@
 #endif
       ALLOCATE( xcplmask(jpi,jpj,0:nn_cplmodel) , STAT=ierr(3) )
-#if defined key_si3 || defined key_cice
-      ALLOCATE( a_i_last_couple(jpi,jpj,jpl) , STAT=ierr(4) )
-#endif
-      !
-      IF( .NOT. ln_apr_dyn ) ALLOCATE( ssh_ib(jpi,jpj), ssh_ibb(jpi,jpj), apr(jpi, jpj), STAT=ierr(5) )
+      !
+      IF( .NOT. ln_apr_dyn ) ALLOCATE( ssh_ib(jpi,jpj), ssh_ibb(jpi,jpj), apr(jpi, jpj), STAT=ierr(4) )
 
       sbc_cpl_alloc = MAXVAL( ierr )
@@ -287,5 +286,5 @@
          &                  sn_rcv_charn , sn_rcv_taw   , sn_rcv_bhd  , sn_rcv_tusd  , sn_rcv_tvsd,    &
          &                  sn_rcv_wdrag , sn_rcv_qns   , sn_rcv_emp  , sn_rcv_rnf   , sn_rcv_cal  ,   &
-         &                  sn_rcv_iceflx, sn_rcv_co2   , sn_rcv_icb  , sn_rcv_isf   , sn_rcv_ts_ice
+         &                  sn_rcv_iceflx, sn_rcv_co2   , sn_rcv_icb  , sn_rcv_isf   , sn_rcv_ts_ice !!, sn_rcv_qtrice
 
       !!---------------------------------------------------------------------
@@ -328,4 +327,5 @@
          WRITE(numout,*)'      ice shelf                       = ', TRIM(sn_rcv_isf%cldes   ), ' (', TRIM(sn_rcv_isf%clcat   ), ')'
          WRITE(numout,*)'      sea ice heat fluxes             = ', TRIM(sn_rcv_iceflx%cldes), ' (', TRIM(sn_rcv_iceflx%clcat), ')'
+!!       WRITE(numout,*)'      transmitted solar thru sea-ice  = ', TRIM(sn_rcv_qtrice%cldes), ' (', TRIM(sn_rcv_qtrice%clcat), ')'
          WRITE(numout,*)'      atm co2                         = ', TRIM(sn_rcv_co2%cldes   ), ' (', TRIM(sn_rcv_co2%clcat   ), ')'
          WRITE(numout,*)'      Sea ice surface skin temperature= ', TRIM(sn_rcv_ts_ice%cldes), ' (', TRIM(sn_rcv_ts_ice%clcat), ')'
@@ -603,7 +603,7 @@
       srcv(jpr_mslp)%clname = 'O_MSLP'     ;   IF( TRIM(sn_rcv_mslp%cldes  ) == 'coupled' )    srcv(jpr_mslp)%laction = .TRUE.
       !
-      !                                                      ! ------------------------- !
-      !                                                      !  ice topmelt and botmelt  !
-      !                                                      ! ------------------------- !
+      !                                                      ! --------------------------------- !
+      !                                                      !  ice topmelt and conduction flux  !   
+      !                                                      ! --------------------------------- !
       srcv(jpr_topm )%clname = 'OTopMlt'
       srcv(jpr_botm )%clname = 'OBotMlt'
@@ -616,4 +616,16 @@
          srcv(jpr_topm:jpr_botm)%laction = .TRUE.
       ENDIF
+!!      !                                                      ! --------------------------- !
+!!      !                                                      ! transmitted solar thru ice  !   
+!!      !                                                      ! --------------------------- !
+!!      srcv(jpr_qtrice)%clname = 'OQtr'
+!!      IF( TRIM(sn_rcv_qtrice%cldes) == 'coupled' ) THEN
+!!         IF ( TRIM( sn_rcv_qtrice%clcat ) == 'yes' ) THEN
+!!            srcv(jpr_qtrice)%nct = nn_cats_cpl
+!!         ELSE
+!!           CALL ctl_stop( 'sbc_cpl_init: sn_rcv_qtrice%clcat should always be set to yes currently' )
+!!         ENDIF
+!!         srcv(jpr_qtrice)%laction = .TRUE.
+!!      ENDIF
       !                                                      ! ------------------------- !
       !                                                      !    ice skin temperature   !
@@ -707,10 +719,10 @@
       !
       !                                                      ! ------------------------------- !
-      !                                                      !   OPA-SAS coupling - rcv by opa !
+      !                                                      !   OCE-SAS coupling - rcv by opa !
       !                                                      ! ------------------------------- !
       srcv(jpr_sflx)%clname = 'O_SFLX'
       srcv(jpr_fice)%clname = 'RIceFrc'
       !
-      IF( nn_components == jp_iam_opa ) THEN    ! OPA coupled to SAS via OASIS: force received field by OPA (sent by SAS)
+      IF( nn_components == jp_iam_oce ) THEN    ! OCE coupled to SAS via OASIS: force received field by OCE (sent by SAS)
          srcv(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
          srcv(:)%clgrid  = 'T'       ! force default definition in case of opa <-> sas coupling
@@ -728,6 +740,6 @@
          IF(lwp) THEN                        ! control print
             WRITE(numout,*)
-            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
-            WRITE(numout,*)'               OPA component  '
+            WRITE(numout,*)'               Special conditions for SAS-OCE coupling  '
+            WRITE(numout,*)'               OCE component  '
             WRITE(numout,*)
             WRITE(numout,*)'  received fields from SAS component '
@@ -743,5 +755,5 @@
       ENDIF
       !                                                      ! -------------------------------- !
-      !                                                      !   OPA-SAS coupling - rcv by sas  !
+      !                                                      !   OCE-SAS coupling - rcv by sas  !
       !                                                      ! -------------------------------- !
       srcv(jpr_toce  )%clname = 'I_SSTSST'
@@ -763,7 +775,7 @@
          ! Vectors: change of sign at north fold ONLY if on the local grid
          srcv(jpr_ocx1:jpr_ocy1)%nsgn = -1.
-         ! Change first letter to couple with atmosphere if already coupled OPA
+         ! Change first letter to couple with atmosphere if already coupled OCE
          ! this is nedeed as each variable name used in the namcouple must be unique:
-         ! for example O_Runoff received by OPA from SAS and therefore S_Runoff received by SAS from the Atmosphere
+         ! for example O_Runoff received by OCE from SAS and therefore S_Runoff received by SAS from the Atmosphere
          DO jn = 1, jprcv
             IF( srcv(jn)%clname(1:1) == "O" ) srcv(jn)%clname = "S"//srcv(jn)%clname(2:LEN(srcv(jn)%clname))
@@ -772,11 +784,11 @@
          IF(lwp) THEN                        ! control print
             WRITE(numout,*)
-            WRITE(numout,*)'               Special conditions for SAS-OPA coupling  '
+            WRITE(numout,*)'               Special conditions for SAS-OCE coupling  '
             WRITE(numout,*)'               SAS component  '
             WRITE(numout,*)
             IF( .NOT. ln_cpl ) THEN
-               WRITE(numout,*)'  received fields from OPA component '
+               WRITE(numout,*)'  received fields from OCE component '
             ELSE
-               WRITE(numout,*)'  Additional received fields from OPA component : '
+               WRITE(numout,*)'  Additional received fields from OCE component : '
             ENDIF
             WRITE(numout,*)'               sea surface temperature (Celsius) '
@@ -889,8 +901,4 @@
       END SELECT
 
-      ! Initialise ice fractions from last coupling time to zero (needed by Met-Office)
-#if defined key_si3 || defined key_cice
-       a_i_last_couple(:,:,:) = 0._wp
-#endif
       !                                                      ! ------------------------- !
       !                                                      !      Ice Meltponds        !
@@ -1029,5 +1037,5 @@
 
       !                                                      ! ------------------------------- !
-      !                                                      !   OPA-SAS coupling - snd by opa !
+      !                                                      !   OCE-SAS coupling - snd by opa !
       !                                                      ! ------------------------------- !
       ssnd(jps_ssh   )%clname = 'O_SSHght'
@@ -1036,5 +1044,5 @@
       ssnd(jps_fraqsr)%clname = 'O_FraQsr'
       !
-      IF( nn_components == jp_iam_opa ) THEN
+      IF( nn_components == jp_iam_oce ) THEN
          ssnd(:)%laction = .FALSE.   ! force default definition in case of opa <-> sas coupling
          ssnd( (/jps_toce, jps_soce, jps_ssh, jps_fraqsr, jps_ocx1, jps_ocy1/) )%laction = .TRUE.
@@ -1060,5 +1068,5 @@
       ENDIF
       !                                                      ! ------------------------------- !
-      !                                                      !   OPA-SAS coupling - snd by sas !
+      !                                                      !   OCE-SAS coupling - snd by sas !
       !                                                      ! ------------------------------- !
       ssnd(jps_sflx  )%clname = 'I_SFLX'
@@ -1078,5 +1086,5 @@
          ! Change first letter to couple with atmosphere if already coupled with sea_ice
          ! this is nedeed as each variable name used in the namcouple must be unique:
-         ! for example O_SSTSST sent by OPA to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
+         ! for example O_SSTSST sent by OCE to SAS and therefore S_SSTSST sent by SAS to the Atmosphere
          DO jn = 1, jpsnd
             IF( ssnd(jn)%clname(1:1) == "O" ) ssnd(jn)%clname = "S"//ssnd(jn)%clname(2:LEN(ssnd(jn)%clname))
@@ -1086,7 +1094,7 @@
             WRITE(numout,*)
             IF( .NOT. ln_cpl ) THEN
-               WRITE(numout,*)'  sent fields to OPA component '
+               WRITE(numout,*)'  sent fields to OCE component '
             ELSE
-               WRITE(numout,*)'  Additional sent fields to OPA component : '
+               WRITE(numout,*)'  Additional sent fields to OCE component : '
             ENDIF
             WRITE(numout,*)'                  ice cover '
@@ -1249,5 +1257,5 @@
                   frcv(jpr_oty1)%z3(ji,jj,1) = 0.5 * ( frcv(jpr_oty1)%z3(ji  ,jj+1,1) + frcv(jpr_oty1)%z3(ji,jj,1) )
                END_2D
-               CALL lbc_lnk_multi( 'sbccpl', frcv(jpr_otx1)%z3(:,:,1), 'U',  -1.0_wp, frcv(jpr_oty1)%z3(:,:,1), 'V',  -1.0_wp )
+               CALL lbc_lnk( 'sbccpl', frcv(jpr_otx1)%z3(:,:,1), 'U',  -1.0_wp, frcv(jpr_oty1)%z3(:,:,1), 'V',  -1.0_wp )
             ENDIF
             llnewtx = .TRUE.
@@ -1526,5 +1534,5 @@
          ENDIF
          ! update qns over the free ocean with:
-         IF( nn_components /= jp_iam_opa ) THEN
+         IF( nn_components /= jp_iam_oce ) THEN
             zqns(:,:) =  zqns(:,:) - zemp(:,:) * sst_m(:,:) * rcp         ! remove heat content due to mass flux (assumed to be at SST)
             IF( srcv(jpr_snow  )%laction ) THEN
@@ -1590,6 +1598,6 @@
       !! ** Action  :   return ptau_i, ptau_j, the stress over the ice
       !!----------------------------------------------------------------------
-      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
-      REAL(wp), INTENT(out), DIMENSION(:,:) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
+      REAL(wp), INTENT(inout), DIMENSION(:,:) ::   p_taui   ! i- & j-components of atmos-ice stress [N/m2]
+      REAL(wp), INTENT(inout), DIMENSION(:,:) ::   p_tauj   ! at I-point (B-grid) or U & V-point (C-grid)
       !!
       INTEGER ::   ji, jj   ! dummy loop indices
@@ -1598,4 +1606,6 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   ztx, zty
       !!----------------------------------------------------------------------
+      !
+#if defined key_si3 || defined key_cice
       !
       IF( srcv(jpr_itx1)%laction ) THEN   ;   itx =  jpr_itx1
@@ -1667,13 +1677,21 @@
                p_tauj(ji,jj) = zztmp2 * ( frcv(jpr_ity1)%z3(ji  ,jj+1,1) + frcv(jpr_ity1)%z3(ji,jj,1) )
             END_2D
+<<<<<<< .working
             CALL lbc_lnk_multi( 'sbccpl', p_taui, 'U',  -1._wp, p_tauj, 'V',  -1._wp )
+||||||| .merge-left.r14199
+            CALL lbc_lnk_multi( 'sbccpl', p_taui, 'U',  -1., p_tauj, 'V',  -1. )
+=======
+            CALL lbc_lnk( 'sbccpl', p_taui, 'U',  -1., p_tauj, 'V',  -1. )
+>>>>>>> .merge-right.r14642
          END SELECT
 
       ENDIF
       !
+#endif
+      !
    END SUBROUTINE sbc_cpl_ice_tau
 
 
-   SUBROUTINE sbc_cpl_ice_flx( picefr, palbi, psst, pist, phs, phi )
+   SUBROUTINE sbc_cpl_ice_flx( kt, picefr, palbi, psst, pist, phs, phi )
       !!----------------------------------------------------------------------
       !!             ***  ROUTINE sbc_cpl_ice_flx  ***
@@ -1717,4 +1735,11 @@
       !!                                                                      are provided but not included in emp here. Only runoff will
       !!                                                                      be included in emp in other parts of NEMO code
+      !!
+      !! ** Note : In case of the ice-atm coupling with conduction fluxes (such as Jules interface for the Met-Office),
+      !!              qsr_ice and qns_ice are not provided and they are not supposed to be used in the ice code.
+      !!              However, by precaution we also "fake" qns_ice and qsr_ice this way:
+      !!              qns_ice = qml_ice + qcn_ice ??
+      !!              qsr_ice = qtr_ice_top ??
+      !!
       !! ** Action  :   update at each nf_ice time step:
       !!                   qns_tot, qsr_tot  non-solar and solar total heat fluxes
@@ -1725,4 +1750,5 @@
       !!                   sprecip           solid precipitation over the ocean
       !!----------------------------------------------------------------------
+      INTEGER,  INTENT(in)                                ::   kt         ! ocean model time step index (only for a_i_last_couple)
       REAL(wp), INTENT(in)   , DIMENSION(:,:)             ::   picefr     ! ice fraction                [0 to 1]
       !                                                   !!           ! optional arguments, used only in 'mixed oce-ice' case or for Met-Office coupling
@@ -1741,4 +1767,13 @@
       REAL(wp), DIMENSION(jpi,jpj)     ::   ztri
       !!----------------------------------------------------------------------
+      !
+#if defined key_si3 || defined key_cice
+      !
+      IF( kt == nit000 ) THEN
+         ! allocate ice fractions from last coupling time here and not in sbc_cpl_init because of jpl
+         IF( .NOT.ALLOCATED(a_i_last_couple) )   ALLOCATE( a_i_last_couple(jpi,jpj,jpl) )
+         ! initialize to a_i for the 1st time step
+         a_i_last_couple(:,:,:) = a_i(:,:,:)
+      ENDIF
       !
       IF( ln_mixcpl )   zmsk(:,:) = 1. - xcplmask(:,:,0)
@@ -1768,6 +1803,4 @@
          CALL ctl_stop('STOP', 'sbccpl/sbc_cpl_ice_flx: some fields are not defined. Change sn_rcv_emp value in namelist namsbc_cpl')
       END SELECT
-
-#if defined key_si3
 
       ! --- evaporation over ice (kg/m2/s) --- !
@@ -1861,38 +1894,34 @@
       ENDIF
 
-#else
-      zsnw(:,:) = picefr(:,:)
-      ! --- Continental fluxes --- !
-      IF( srcv(jpr_rnf)%laction ) THEN   ! runoffs (included in emp later on)
-         rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
-      ENDIF
-      IF( srcv(jpr_cal)%laction ) THEN   ! calving (put in emp_tot)
-         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
-      ENDIF
-      IF( srcv(jpr_icb)%laction ) THEN   ! iceberg added to runoffs
-         fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
-         rnf(:,:)    = rnf(:,:) + fwficb(:,:)
-      ENDIF
-      IF( srcv(jpr_isf)%laction ) THEN   ! iceshelf (fwfisf <0 mean melting)
-        fwfisf_oasis(:,:) = - frcv(jpr_isf)%z3(:,:,1)
-      ENDIF
-      !
-      IF( ln_mixcpl ) THEN
-         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
-         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
-         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
-         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
-      ELSE
-         emp_tot(:,:) =                                  zemp_tot(:,:)
-         emp_ice(:,:) =                                  zemp_ice(:,:)
-         sprecip(:,:) =                                  zsprecip(:,:)
-         tprecip(:,:) =                                  ztprecip(:,:)
-      ENDIF
-      !
-#endif
-
+!! for CICE ??
+!!$      zsnw(:,:) = picefr(:,:)
+!!$      ! --- Continental fluxes --- !
+!!$      IF( srcv(jpr_rnf)%laction ) THEN   ! runoffs (included in emp later on)
+!!$         rnf(:,:) = frcv(jpr_rnf)%z3(:,:,1)
+!!$      ENDIF
+!!$      IF( srcv(jpr_cal)%laction ) THEN   ! calving (put in emp_tot)
+!!$         zemp_tot(:,:) = zemp_tot(:,:) - frcv(jpr_cal)%z3(:,:,1)
+!!$      ENDIF
+!!$      IF( srcv(jpr_icb)%laction ) THEN   ! iceberg added to runoffs
+!!$         fwficb(:,:) = frcv(jpr_icb)%z3(:,:,1)
+!!$         rnf(:,:)    = rnf(:,:) + fwficb(:,:)
+!!$      ENDIF
+!!$      IF( srcv(jpr_isf)%laction ) THEN   ! iceshelf (fwfisf <0 mean melting)
+!!$        fwfisf_oasis(:,:) = - frcv(jpr_isf)%z3(:,:,1)
+!!$      ENDIF
+!!$      !
+!!$      IF( ln_mixcpl ) THEN
+!!$         emp_tot(:,:) = emp_tot(:,:) * xcplmask(:,:,0) + zemp_tot(:,:) * zmsk(:,:)
+!!$         emp_ice(:,:) = emp_ice(:,:) * xcplmask(:,:,0) + zemp_ice(:,:) * zmsk(:,:)
+!!$         sprecip(:,:) = sprecip(:,:) * xcplmask(:,:,0) + zsprecip(:,:) * zmsk(:,:)
+!!$         tprecip(:,:) = tprecip(:,:) * xcplmask(:,:,0) + ztprecip(:,:) * zmsk(:,:)
+!!$      ELSE
+!!$         emp_tot(:,:) =                                  zemp_tot(:,:)
+!!$         emp_ice(:,:) =                                  zemp_ice(:,:)
+!!$         sprecip(:,:) =                                  zsprecip(:,:)
+!!$         tprecip(:,:) =                                  ztprecip(:,:)
+!!$      ENDIF
+      !
       ! outputs
-!!      IF( srcv(jpr_rnf)%laction )   CALL iom_put( 'runoffs' , rnf(:,:) * tmask(:,:,1)                                 )  ! runoff
-!!      IF( srcv(jpr_isf)%laction )   CALL iom_put( 'iceshelf_cea', -fwfisf(:,:) * tmask(:,:,1)                         )  ! iceshelf
       IF( srcv(jpr_cal)%laction )    CALL iom_put( 'calving_cea' , frcv(jpr_cal)%z3(:,:,1) * tmask(:,:,1)                )  ! calving
       IF( srcv(jpr_icb)%laction )    CALL iom_put( 'iceberg_cea' , frcv(jpr_icb)%z3(:,:,1) * tmask(:,:,1)                )  ! icebergs
@@ -1907,4 +1936,24 @@
          &                                                         - frcv(jpr_ievp)%z3(:,:,1) * picefr(:,:) ) * tmask(:,:,1) ) ! ice-free oce evap (cell average)
       ! note: runoff output is done in sbcrnf (which includes icebergs too) and iceshelf output is done in sbcisf
+!!      IF( srcv(jpr_rnf)%laction )   CALL iom_put( 'runoffs' , rnf(:,:) * tmask(:,:,1)                                 )  ! runoff
+!!      IF( srcv(jpr_isf)%laction )   CALL iom_put( 'iceshelf_cea', -fwfisf(:,:) * tmask(:,:,1)                         )  ! iceshelf
+      !
+      !                                                      ! ========================= !
+      SELECT CASE( TRIM( sn_rcv_iceflx%cldes ) )             !  ice topmelt and botmelt  !
+      !                                                      ! ========================= !
+      CASE ('coupled')
+         IF (ln_scale_ice_flux) THEN
+            WHERE( a_i(:,:,:) > 1.e-10_wp )
+               qml_ice(:,:,:) = frcv(jpr_topm)%z3(:,:,:) * a_i_last_couple(:,:,:) / a_i(:,:,:)
+               qcn_ice(:,:,:) = frcv(jpr_botm)%z3(:,:,:) * a_i_last_couple(:,:,:) / a_i(:,:,:)
+            ELSEWHERE
+               qml_ice(:,:,:) = 0.0_wp
+               qcn_ice(:,:,:) = 0.0_wp
+            END WHERE
+         ELSE
+            qml_ice(:,:,:) = frcv(jpr_topm)%z3(:,:,:)
+            qcn_ice(:,:,:) = frcv(jpr_botm)%z3(:,:,:)
+         ENDIF
+      END SELECT
       !
       !                                                      ! ========================= !
@@ -1912,8 +1961,13 @@
       !                                                      ! ========================= !
       CASE( 'oce only' )         ! the required field is directly provided
-         zqns_tot(:,:) = frcv(jpr_qnsoce)%z3(:,:,1)
-         ! For Met Office sea ice non-solar fluxes are already delt with by JULES so setting to zero
-         ! here so the only flux is the ocean only one.
-         zqns_ice(:,:,:) = 0._wp
+         ! Get the sea ice non solar heat flux from conductive, melting and sublimation fluxes
+         IF( TRIM(sn_rcv_iceflx%cldes) == 'coupled' ) THEN
+            zqns_ice(:,:,:) = qml_ice(:,:,:) + qcn_ice(:,:,:)
+         ELSE
+            zqns_ice(:,:,:) = 0._wp
+         ENDIF
+         ! Calculate the total non solar heat flux. The ocean only non solar heat flux (zqns_oce) will be recalculated after this CASE
+         ! statement to be consistent with other coupling methods even though .zqns_oce = frcv(jpr_qnsoce)%z3(:,:,1)
+         zqns_tot(:,:) = frcv(jpr_qnsoce)%z3(:,:,1) + SUM( zqns_ice(:,:,:) * a_i(:,:,:), dim=3 )
       CASE( 'conservative' )     ! the required fields are directly provided
          zqns_tot(:,:) = frcv(jpr_qnsmix)%z3(:,:,1)
@@ -1962,5 +2016,4 @@
       IF( srcv(jpr_icb)%laction )   zqns_tot(:,:) = zqns_tot(:,:) - frcv(jpr_icb)%z3(:,:,1) * rLfus  ! remove latent heat of iceberg melting
 
-#if defined key_si3
       ! --- non solar flux over ocean --- !
       !         note: ziceld cannot be = 0 since we limit the ice concentration to amax
@@ -2015,26 +2068,26 @@
       ENDIF
 
-#else
-      zcptsnw (:,:) = zcptn(:,:)
-      zcptrain(:,:) = zcptn(:,:)
-
-      ! clem: this formulation is certainly wrong... but better than it was...
-      zqns_tot(:,:) = zqns_tot(:,:)                             &          ! zqns_tot update over free ocean with:
-         &          - (  ziceld(:,:) * zsprecip(:,:) * rLfus )  &          ! remove the latent heat flux of solid precip. melting
-         &          - (  zemp_tot(:,:)                          &          ! remove the heat content of mass flux (assumed to be at SST)
-         &             - zemp_ice(:,:) ) * zcptn(:,:)
-
-     IF( ln_mixcpl ) THEN
-         qns_tot(:,:) = qns(:,:) * ziceld(:,:) + SUM( qns_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
-         qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) +  zqns_tot(:,:)* zmsk(:,:)
-         DO jl=1,jpl
-            qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:)
-         ENDDO
-      ELSE
-         qns_tot(:,:  ) = zqns_tot(:,:  )
-         qns_ice(:,:,:) = zqns_ice(:,:,:)
-      ENDIF
-
-#endif
+!! for CICE ??
+!!$      ! --- non solar flux over ocean --- !
+!!$      zcptsnw (:,:) = zcptn(:,:)
+!!$      zcptrain(:,:) = zcptn(:,:)
+!!$
+!!$      ! clem: this formulation is certainly wrong... but better than it was...
+!!$      zqns_tot(:,:) = zqns_tot(:,:)                             &          ! zqns_tot update over free ocean with:
+!!$         &          - (  ziceld(:,:) * zsprecip(:,:) * rLfus )  &          ! remove the latent heat flux of solid precip. melting
+!!$         &          - (  zemp_tot(:,:)                          &          ! remove the heat content of mass flux (assumed to be at SST)
+!!$         &             - zemp_ice(:,:) ) * zcptn(:,:)
+!!$
+!!$     IF( ln_mixcpl ) THEN
+!!$         qns_tot(:,:) = qns(:,:) * ziceld(:,:) + SUM( qns_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
+!!$         qns_tot(:,:) = qns_tot(:,:) * xcplmask(:,:,0) +  zqns_tot(:,:)* zmsk(:,:)
+!!$         DO jl=1,jpl
+!!$            qns_ice(:,:,jl) = qns_ice(:,:,jl) * xcplmask(:,:,0) +  zqns_ice(:,:,jl)* zmsk(:,:)
+!!$         ENDDO
+!!$      ELSE
+!!$         qns_tot(:,:  ) = zqns_tot(:,:  )
+!!$         qns_ice(:,:,:) = zqns_ice(:,:,:)
+!!$      ENDIF
+
       ! outputs
       IF ( srcv(jpr_cal)%laction ) CALL iom_put('hflx_cal_cea' , - frcv(jpr_cal)%z3(:,:,1) * rLfus ) ! latent heat from calving
@@ -2057,10 +2110,33 @@
       !
       !                                                      ! ========================= !
+      SELECT CASE( TRIM( sn_rcv_dqnsdt%cldes ) )             !          d(qns)/dt        !
+      !                                                      ! ========================= !
+      CASE ('coupled')
+         IF( TRIM(sn_rcv_dqnsdt%clcat) == 'yes' ) THEN
+            zdqns_ice(:,:,1:jpl) = frcv(jpr_dqnsdt)%z3(:,:,1:jpl)
+         ELSE
+            ! Set all category values equal for the moment
+            DO jl=1,jpl
+               zdqns_ice(:,:,jl) = frcv(jpr_dqnsdt)%z3(:,:,1)
+            ENDDO
+         ENDIF
+      CASE( 'none' )
+         zdqns_ice(:,:,:) = 0._wp
+      END SELECT
+
+      IF( ln_mixcpl ) THEN
+         DO jl=1,jpl
+            dqns_ice(:,:,jl) = dqns_ice(:,:,jl) * xcplmask(:,:,0) + zdqns_ice(:,:,jl) * zmsk(:,:)
+         ENDDO
+      ELSE
+         dqns_ice(:,:,:) = zdqns_ice(:,:,:)
+      ENDIF
+      !                                                      ! ========================= !
       SELECT CASE( TRIM( sn_rcv_qsr%cldes ) )                !      solar heat fluxes    !   (qsr)
       !                                                      ! ========================= !
       CASE( 'oce only' )
          zqsr_tot(:,:  ) = MAX( 0._wp , frcv(jpr_qsroce)%z3(:,:,1) )
-         ! For Met Office sea ice solar fluxes are already delt with by JULES so setting to zero
-         ! here so the only flux is the ocean only one.
+         ! For the Met Office the only sea ice solar flux is the transmitted qsr which is added onto zqsr_ice
+         ! further down. Therefore start zqsr_ice off at zero.
          zqsr_ice(:,:,:) = 0._wp
       CASE( 'conservative' )
@@ -2115,68 +2191,4 @@
          END DO
       ENDIF
-
-#if defined key_si3
-      ! --- solar flux over ocean --- !
-      !         note: ziceld cannot be = 0 since we limit the ice concentration to amax
-      zqsr_oce = 0._wp
-      WHERE( ziceld /= 0._wp )  zqsr_oce(:,:) = ( zqsr_tot(:,:) - SUM( a_i * zqsr_ice, dim=3 ) ) / ziceld(:,:)
-
-      IF( ln_mixcpl ) THEN   ;   qsr_oce(:,:) = qsr_oce(:,:) * xcplmask(:,:,0) +  zqsr_oce(:,:)* zmsk(:,:)
-      ELSE                   ;   qsr_oce(:,:) = zqsr_oce(:,:)   ;   ENDIF
-#endif
-
-      IF( ln_mixcpl ) THEN
-         qsr_tot(:,:) = qsr(:,:) * ziceld(:,:) + SUM( qsr_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
-         qsr_tot(:,:) = qsr_tot(:,:) * xcplmask(:,:,0) +  zqsr_tot(:,:)* zmsk(:,:)
-         DO jl = 1, jpl
-            qsr_ice(:,:,jl) = qsr_ice(:,:,jl) * xcplmask(:,:,0) +  zqsr_ice(:,:,jl)* zmsk(:,:)
-         END DO
-      ELSE
-         qsr_tot(:,:  ) = zqsr_tot(:,:  )
-         qsr_ice(:,:,:) = zqsr_ice(:,:,:)
-      ENDIF
-
-      !                                                      ! ========================= !
-      SELECT CASE( TRIM( sn_rcv_dqnsdt%cldes ) )             !          d(qns)/dt        !
-      !                                                      ! ========================= !
-      CASE ('coupled')
-         IF( TRIM(sn_rcv_dqnsdt%clcat) == 'yes' ) THEN
-            zdqns_ice(:,:,1:jpl) = frcv(jpr_dqnsdt)%z3(:,:,1:jpl)
-         ELSE
-            ! Set all category values equal for the moment
-            DO jl=1,jpl
-               zdqns_ice(:,:,jl) = frcv(jpr_dqnsdt)%z3(:,:,1)
-            ENDDO
-         ENDIF
-      CASE( 'none' )
-         zdqns_ice(:,:,:) = 0._wp
-      END SELECT
-
-      IF( ln_mixcpl ) THEN
-         DO jl=1,jpl
-            dqns_ice(:,:,jl) = dqns_ice(:,:,jl) * xcplmask(:,:,0) + zdqns_ice(:,:,jl) * zmsk(:,:)
-         ENDDO
-      ELSE
-         dqns_ice(:,:,:) = zdqns_ice(:,:,:)
-      ENDIF
-
-#if defined key_si3
-      !                                                      ! ========================= !
-      SELECT CASE( TRIM( sn_rcv_iceflx%cldes ) )             !  ice topmelt and botmelt  !
-      !                                                      ! ========================= !
-      CASE ('coupled')
-         IF (ln_scale_ice_flux) THEN
-            WHERE( a_i(:,:,:) > 1.e-10_wp )
-               qml_ice(:,:,:) = frcv(jpr_topm)%z3(:,:,:) * a_i_last_couple(:,:,:) / a_i(:,:,:)
-               qcn_ice(:,:,:) = frcv(jpr_botm)%z3(:,:,:) * a_i_last_couple(:,:,:) / a_i(:,:,:)
-            ELSEWHERE
-               qml_ice(:,:,:) = 0.0_wp
-               qcn_ice(:,:,:) = 0.0_wp
-            END WHERE
-         ELSE
-            qml_ice(:,:,:) = frcv(jpr_topm)%z3(:,:,:)
-            qcn_ice(:,:,:) = frcv(jpr_botm)%z3(:,:,:)
-         ENDIF
-      END SELECT
       !                                                      ! ========================= !
       !                                                      !      Transmitted Qsr      !   [W/m2]
@@ -2210,17 +2222,50 @@
       ELSEIF( ln_cndflx .AND. .NOT.ln_cndemulate ) THEN      !==  conduction flux as surface forcing  ==!
          !
-         !          ! ===> here we must receive the qtr_ice_top array from the coupler
-         !                 for now just assume zero (fully opaque ice)
+!!         SELECT CASE( TRIM( sn_rcv_qtrice%cldes ) )
+!!            !
+!!            !      ! ===> here we receive the qtr_ice_top array from the coupler
+!!         CASE ('coupled')
+!!            IF (ln_scale_ice_flux) THEN
+!!               WHERE( a_i(:,:,:) > 1.e-10_wp )
+!!                  zqtr_ice_top(:,:,:) = frcv(jpr_qtrice)%z3(:,:,:) * a_i_last_couple(:,:,:) / a_i(:,:,:)
+!!               ELSEWHERE
+!!                  zqtr_ice_top(:,:,:) = 0.0_wp
+!!               ENDWHERE
+!!            ELSE
+!!               zqtr_ice_top(:,:,:) = frcv(jpr_qtrice)%z3(:,:,:)
+!!            ENDIF
+!!           
+!!            ! Add retrieved transmitted solar radiation onto the ice and total solar radiation
+!!            zqsr_ice(:,:,:) = zqsr_ice(:,:,:) + zqtr_ice_top(:,:,:)
+!!            zqsr_tot(:,:)   = zqsr_tot(:,:) + SUM( zqtr_ice_top(:,:,:) * a_i(:,:,:), dim=3 )
+!!            
+!!            !      if we are not getting this data from the coupler then assume zero (fully opaque ice)
+!!         CASE ('none')
          zqtr_ice_top(:,:,:) = 0._wp
-         !
-      ENDIF
-      !
+!!         END SELECT
+            !
+      ENDIF
+
       IF( ln_mixcpl ) THEN
-         DO jl=1,jpl
+         qsr_tot(:,:) = qsr(:,:) * ziceld(:,:) + SUM( qsr_ice(:,:,:) * a_i(:,:,:), dim=3 )   ! total flux from blk
+         qsr_tot(:,:) = qsr_tot(:,:) * xcplmask(:,:,0) + zqsr_tot(:,:) * zmsk(:,:)
+         DO jl = 1, jpl
+            qsr_ice    (:,:,jl) = qsr_ice    (:,:,jl) * xcplmask(:,:,0) + zqsr_ice    (:,:,jl) * zmsk(:,:)
             qtr_ice_top(:,:,jl) = qtr_ice_top(:,:,jl) * xcplmask(:,:,0) + zqtr_ice_top(:,:,jl) * zmsk(:,:)
-         ENDDO
+         END DO
       ELSE
+         qsr_tot    (:,:  ) = zqsr_tot    (:,:  )
+         qsr_ice    (:,:,:) = zqsr_ice    (:,:,:)
          qtr_ice_top(:,:,:) = zqtr_ice_top(:,:,:)
       ENDIF
+      
+      ! --- solar flux over ocean --- !
+      !         note: ziceld cannot be = 0 since we limit the ice concentration to amax
+      zqsr_oce = 0._wp
+      WHERE( ziceld /= 0._wp )  zqsr_oce(:,:) = ( zqsr_tot(:,:) - SUM( a_i * zqsr_ice, dim=3 ) ) / ziceld(:,:)
+
+      IF( ln_mixcpl ) THEN   ;   qsr_oce(:,:) = qsr_oce(:,:) * xcplmask(:,:,0) +  zqsr_oce(:,:)* zmsk(:,:)
+      ELSE                   ;   qsr_oce(:,:) = zqsr_oce(:,:)   ;   ENDIF
+
       !                                                      ! ================== !
       !                                                      !   ice skin temp.   !
@@ -2276,8 +2321,8 @@
       IF( ssnd(jps_toce)%laction .OR. ssnd(jps_tice)%laction .OR. ssnd(jps_tmix)%laction ) THEN
 
-         IF( nn_components == jp_iam_opa ) THEN
+         IF( nn_components == jp_iam_oce ) THEN
             ztmp1(:,:) = ts(:,:,1,jp_tem,Kmm)   ! send temperature as it is (potential or conservative) -> use of l_useCT on the received part
          ELSE
-            ! we must send the surface potential temperature 
+            ! we must send the surface potential temperature
             IF( l_useCT )  THEN    ;   ztmp1(:,:) = eos_pt_from_ct( CASTWP(ts(:,:,1,jp_tem,Kmm)),CASTWP(ts(:,:,1,jp_sal,Kmm)) )
             ELSE                   ;   ztmp1(:,:) = ts(:,:,1,jp_tem,Kmm)
@@ -2428,5 +2473,5 @@
       ENDIF
 
-      ! Send ice fraction field to OPA (sent by SAS in SAS-OPA coupling)
+      ! Send ice fraction field to OCE (sent by SAS in SAS-OCE coupling)
       IF( ssnd(jps_fice2)%laction ) THEN
          ztmp3(:,:,1) = fr_i(:,:)
@@ -2544,5 +2589,5 @@
          !                                                              i-1  i   i
          !                                                               i      i+1 (for I)
-         IF( nn_components == jp_iam_opa ) THEN
+         IF( nn_components == jp_iam_oce ) THEN
             zotx1(:,:) = uu(:,:,1,Kmm)
             zoty1(:,:) = vv(:,:,1,Kmm)
@@ -2561,5 +2606,5 @@
                   zity1(ji,jj) = 0.5 * ( v_ice(ji,jj  )     + v_ice(ji  ,jj-1  )     ) *  fr_i(ji,jj)
                END_2D
-               CALL lbc_lnk_multi( 'sbccpl', zitx1, 'T', -1.0_wp, zity1, 'T', -1.0_wp )
+               CALL lbc_lnk( 'sbccpl', zitx1, 'T', -1.0_wp, zity1, 'T', -1.0_wp )
             CASE( 'mixed oce-ice'        )      ! Ocean and Ice on C-grid ==> T
                DO_2D( 0, 0, 0, 0 )
@@ -2570,5 +2615,5 @@
                END_2D
             END SELECT
-            CALL lbc_lnk_multi( 'sbccpl', zotx1, ssnd(jps_ocx1)%clgrid, -1.0_wp,  zoty1, ssnd(jps_ocy1)%clgrid, -1.0_wp )
+            CALL lbc_lnk( 'sbccpl', zotx1, ssnd(jps_ocx1)%clgrid, -1.0_wp,  zoty1, ssnd(jps_ocy1)%clgrid, -1.0_wp )
             !
          ENDIF
@@ -2638,5 +2683,5 @@
                 zity1(ji,jj) = 0.5 * ( v_ice(ji,jj  ) + v_ice(ji  ,jj-1  ) ) *  fr_i(ji,jj)
              END_2D
-             CALL lbc_lnk_multi( 'sbccpl', zitx1, 'T', -1.0_wp,  zity1, 'T', -1.0_wp )
+             CALL lbc_lnk( 'sbccpl', zitx1, 'T', -1.0_wp,  zity1, 'T', -1.0_wp )
           CASE( 'mixed oce-ice'        )      ! Ocean and Ice on C-grid ==> T
              DO_2D( 0, 0, 0, 0 )
@@ -2647,5 +2692,5 @@
              END_2D
           END SELECT
-         CALL lbc_lnk_multi( 'sbccpl', zotx1, ssnd(jps_ocxw)%clgrid, -1.0_wp, zoty1, ssnd(jps_ocyw)%clgrid, -1.0_wp )
+         CALL lbc_lnk( 'sbccpl', zotx1, ssnd(jps_ocxw)%clgrid, -1.0_wp, zoty1, ssnd(jps_ocyw)%clgrid, -1.0_wp )
          !
          !
@@ -2701,5 +2746,5 @@
       ENDIF
       !
-      !  Fields sent by OPA to SAS when doing OPA<->SAS coupling
+      !  Fields sent by OCE to SAS when doing OCE<->SAS coupling
       !                                                        ! SSH
       IF( ssnd(jps_ssh )%laction )  THEN
@@ -2725,5 +2770,5 @@
       ENDIF
       !
-      !  Fields sent by SAS to OPA when OASIS coupling
+      !  Fields sent by SAS to OCE when OASIS coupling
       !                                                        ! Solar heat flux
       IF( ssnd(jps_qsroce)%laction )  CALL cpl_snd( jps_qsroce, isec, RESHAPE ( qsr , (/jpi,jpj,1/) ), info )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcflx.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcflx.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcflx.F90	(revision 14644)
@@ -119,4 +119,6 @@
          !                                         ! fill sf with slf_i and control print
          CALL fld_fill( sf, slf_i, cn_dir, 'sbc_flx', 'flux formulation for ocean surface boundary condition', 'namsbc_flx' )
+         sf(jp_utau)%cltype = 'U'   ;   sf(jp_utau)%zsgn = -1._wp   ! vector field at U point: overwrite default definition of cltype and zsgn
+         sf(jp_vtau)%cltype = 'V'   ;   sf(jp_vtau)%zsgn = -1._wp   ! vector field at V point: overwrite default definition of cltype and zsgn
          !
       ENDIF
@@ -129,9 +131,9 @@
             qsr(:,:) = sbc_dcy( sf(jp_qsr)%fnow(:,:,1) ) * tmask(:,:,1)
          ELSE
-            DO_2D( 0, 0, 0, 0 )
-               qsr(ji,jj) =          sf(jp_qsr)%fnow(ji,jj,1)   * tmask(ji,jj,1)
+            DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+               qsr(ji,jj) =     sf(jp_qsr)%fnow(ji,jj,1) * tmask(ji,jj,1)
             END_2D
          ENDIF
-         DO_2D( 0, 0, 0, 0 )                                      ! set the ocean fluxes from read fields
+         DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )                  ! set the ocean fluxes from read fields
             utau(ji,jj) =   sf(jp_utau)%fnow(ji,jj,1)                              * umask(ji,jj,1)
             vtau(ji,jj) =   sf(jp_vtau)%fnow(ji,jj,1)                              * vmask(ji,jj,1)
@@ -143,8 +145,4 @@
          !!clem: I do not think it is needed
          !!qns(:,:) = qns(:,:) - emp(:,:) * sst_m(:,:) * rcp        ! mass flux is at SST
-         !
-         ! clem: without these lbc calls, it seems that the northfold is not ok (true in 3.6, not sure in 4.x)
-         CALL lbc_lnk_multi( 'sbcflx', utau, 'U', -1._wp, vtau, 'V', -1._wp, &
-            &                           qns, 'T',  1._wp, emp , 'T',  1._wp, qsr, 'T', 1._wp ) !! sfx, 'T', 1._wp  )
          !
          IF( nitend-nit000 <= 100 .AND. lwp ) THEN                ! control print (if less than 100 time-step asked)
@@ -172,5 +170,5 @@
       END_2D
       !
-      CALL lbc_lnk_multi( 'sbcflx', taum, 'T', 1._wp, wndm, 'T', 1._wp )
+      CALL lbc_lnk( 'sbcflx', taum, 'T', 1._wp, wndm, 'T', 1._wp )
       !
    END SUBROUTINE sbc_flx
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcice_cice.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcice_cice.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcice_cice.F90	(revision 14644)
@@ -139,5 +139,5 @@
             CALL cice_sbc_force(kt)
          ELSE IF( ksbc == jp_purecpl ) THEN
-            CALL sbc_cpl_ice_flx( fr_i )
+            CALL sbc_cpl_ice_flx( kt, fr_i )
          ENDIF
 
@@ -222,5 +222,5 @@
       END_2D
 
-      CALL lbc_lnk_multi( 'sbcice_cice', fr_iu , 'U', 1.0_wp,  fr_iv , 'V', 1.0_wp )
+      CALL lbc_lnk( 'sbcice_cice', fr_iu , 'U', 1.0_wp,  fr_iv , 'V', 1.0_wp )
 
       ! set the snow+ice mass
@@ -312,5 +312,5 @@
 ! x comp of wind stress (CI_1)
 ! U point to F point
-         DO_2D( 1, 0, 1, 1 )
+         DO_2D( 1, 1, 1, 0 )
             ztmp(ji,jj) = 0.5 * (  fr_iu(ji,jj) * utau(ji,jj)      &
                                  + fr_iu(ji,jj+1) * utau(ji,jj+1) ) * fmask(ji,jj,1)
@@ -320,5 +320,5 @@
 ! y comp of wind stress (CI_2)
 ! V point to F point
-         DO_2D( 1, 1, 1, 0 )
+         DO_2D( 1, 0, 1, 1 )
             ztmp(ji,jj) = 0.5 * (  fr_iv(ji,jj) * vtau(ji,jj)      &
                                  + fr_iv(ji+1,jj) * vtau(ji+1,jj) ) * fmask(ji,jj,1)
@@ -437,5 +437,5 @@
 ! x comp and y comp of surface ocean current
 ! U point to F point
-      DO_2D( 1, 0, 1, 1 )
+      DO_2D( 1, 1, 1, 0 )
          ztmp(ji,jj)=0.5*(ssu_m(ji,jj)+ssu_m(ji,jj+1))*fmask(ji,jj,1)
       END_2D
@@ -443,5 +443,5 @@
 
 ! V point to F point
-      DO_2D( 1, 1, 1, 0 )
+      DO_2D( 1, 0, 1, 1 )
          ztmp(ji,jj)=0.5*(ssv_m(ji,jj)+ssv_m(ji+1,jj))*fmask(ji,jj,1)
       END_2D
@@ -513,5 +513,5 @@
 ! F point to V point
 
-      DO_2D( 1, 0, 0, 0 )
+      DO_2D( 0, 0, 1, 0 )
          ss_iov(ji,jj) = 0.5 * ( ztmp1(ji-1,jj) + ztmp1(ji,jj) ) * vmask(ji,jj,1)
       END_2D
@@ -569,5 +569,5 @@
       fmmflx(:,:) = ztmp1(:,:) !!Joakim edit
       
-      CALL lbc_lnk_multi( 'sbcice_cice', emp , 'T', 1.0_wp, sfx , 'T', 1.0_wp )
+      CALL lbc_lnk( 'sbcice_cice', emp , 'T', 1.0_wp, sfx , 'T', 1.0_wp )
 
 ! Solar penetrative radiation and non solar surface heat flux
@@ -626,5 +626,5 @@
       END_2D
 
-      CALL lbc_lnk_multi( 'sbcice_cice', fr_iu , 'U', 1.0_wp, fr_iv , 'V', 1.0_wp )
+      CALL lbc_lnk( 'sbcice_cice', fr_iu , 'U', 1.0_wp, fr_iv , 'V', 1.0_wp )
 
       ! set the snow+ice mass
@@ -877,5 +877,5 @@
 ! (may be OK but not 100% sure)
 
-      IF(nproc==0) THEN     
+      IF(narea==1) THEN     
 !        pcg(:,:)=0.0
          DO jn=1,jpnij
@@ -998,5 +998,5 @@
 ! the lbclnk call on pn will replace these with sensible values
 
-      IF(nproc==0) THEN
+      IF(narea==1) THEN
          png(:,:,:)=0.0
          DO jn=1,jpnij
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcmod.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcmod.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcmod.F90	(revision 14644)
@@ -121,5 +121,5 @@
       IF(lwm) WRITE( numond, namsbc )
       !
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ncom_fsbc = nn_fsbc    ! make nn_fsbc available for lib_mpp
 #endif
@@ -164,17 +164,17 @@
       !                       !**  check option consistency
       !
-      IF(lwp) WRITE(numout,*)       !* Single / Multi - executable (NEMO / OPA+SAS)
+      IF(lwp) WRITE(numout,*)       !* Single / Multi - executable (NEMO / OCE+SAS)
       SELECT CASE( nn_components )
       CASE( jp_iam_nemo )
-         IF(lwp) WRITE(numout,*) '   ==>>>   NEMO configured as a single executable (i.e. including both OPA and Surface module)'
-      CASE( jp_iam_opa  )
-         IF(lwp) WRITE(numout,*) '   ==>>>   Multi executable configuration. Here, OPA component'
-         IF( .NOT.lk_oasis )   CALL ctl_stop( 'sbc_init : OPA-SAS coupled via OASIS, but key_oasis3 disabled' )
-         IF( ln_cpl        )   CALL ctl_stop( 'sbc_init : OPA-SAS coupled via OASIS, but ln_cpl = T in OPA'   )
-         IF( ln_mixcpl     )   CALL ctl_stop( 'sbc_init : OPA-SAS coupled via OASIS, but ln_mixcpl = T in OPA' )
+         IF(lwp) WRITE(numout,*) '   ==>>>   NEMO configured as a single executable (i.e. including both OCE and Surface module)'
+      CASE( jp_iam_oce  )
+         IF(lwp) WRITE(numout,*) '   ==>>>   Multi executable configuration. Here, OCE component'
+         IF( .NOT.lk_oasis )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but key_oasis3 disabled' )
+         IF( ln_cpl        )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but ln_cpl = T in OCE'   )
+         IF( ln_mixcpl     )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but ln_mixcpl = T in OCE' )
       CASE( jp_iam_sas  )
          IF(lwp) WRITE(numout,*) '   ==>>>   Multi executable configuration. Here, SAS component'
-         IF( .NOT.lk_oasis )   CALL ctl_stop( 'sbc_init : OPA-SAS coupled via OASIS, but key_oasis3 disabled' )
-         IF( ln_mixcpl     )   CALL ctl_stop( 'sbc_init : OPA-SAS coupled via OASIS, but ln_mixcpl = T in OPA' )
+         IF( .NOT.lk_oasis )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but key_oasis3 disabled' )
+         IF( ln_mixcpl     )   CALL ctl_stop( 'sbc_init : OCE-SAS coupled via OASIS, but ln_mixcpl = T in OCE' )
       CASE DEFAULT
          CALL ctl_stop( 'sbc_init : unsupported value for nn_components' )
@@ -225,5 +225,5 @@
       !
       IF( nn_ice == 0 ) THEN        !* No sea-ice in the domain : ice fraction is always zero
-         IF( nn_components /= jp_iam_opa )   fr_i(:,:) = 0._wp    ! except for OPA in SAS-OPA coupled case
+         IF( nn_components /= jp_iam_oce )   fr_i(:,:) = 0._wp    ! except for OCE in SAS-OCE coupled case
       ENDIF
       !
@@ -238,5 +238,5 @@
       IF( ln_dm2dc ) THEN           !* daily mean to diurnal cycle
          !LB:nday_qsr = -1   ! allow initialization at the 1st call
-         IF( .NOT.( ln_flx .OR. ln_blk .OR. ln_abl ) .AND. nn_components /= jp_iam_opa )   &
+         IF( .NOT.( ln_flx .OR. ln_blk .OR. ln_abl ) .AND. nn_components /= jp_iam_oce )   &
             &   CALL ctl_stop( 'qsr diurnal cycle from daily values requires flux, bulk or abl formulation' )
       ENDIF
@@ -245,5 +245,5 @@
       !
       ll_purecpl  = ln_cpl .AND. .NOT.ln_mixcpl
-      ll_opa      = nn_components == jp_iam_opa
+      ll_opa      = nn_components == jp_iam_oce
       ll_not_nemo = nn_components /= jp_iam_nemo
       icpt = 0
@@ -267,5 +267,5 @@
          CASE( jp_purecpl )   ;   WRITE(numout,*) '   ==>>>   pure coupled formulation'
 !!gm abusive use of jp_none ??   ===>>> need to be check and changed by adding a jp_sas parameter
-         CASE( jp_none    )   ;   WRITE(numout,*) '   ==>>>   OPA coupled to SAS via oasis'
+         CASE( jp_none    )   ;   WRITE(numout,*) '   ==>>>   OCE coupled to SAS via oasis'
             IF( ln_mixcpl )       WRITE(numout,*) '               + forced-coupled mixed formulation'
          END SELECT
@@ -277,13 +277,13 @@
       IF( lk_oasis )   CALL sbc_cpl_init( nn_ice )   ! Must be done before: (1) first time step
       !                                              !                      (2) the use of nn_fsbc
-      !     nn_fsbc initialization if OPA-SAS coupling via OASIS
+      !     nn_fsbc initialization if OCE-SAS coupling via OASIS
       !     SAS time-step has to be declared in OASIS (mandatory) -> nn_fsbc has to be modified accordingly
       IF( nn_components /= jp_iam_nemo ) THEN
-         IF( nn_components == jp_iam_opa )   nn_fsbc = cpl_freq('O_SFLX') / NINT(rn_Dt)
+         IF( nn_components == jp_iam_oce )   nn_fsbc = cpl_freq('O_SFLX') / NINT(rn_Dt)
          IF( nn_components == jp_iam_sas )   nn_fsbc = cpl_freq('I_SFLX') / NINT(rn_Dt)
          !
          IF(lwp)THEN
             WRITE(numout,*)
-            WRITE(numout,*)"   OPA-SAS coupled via OASIS : nn_fsbc re-defined from OASIS namcouple ", nn_fsbc
+            WRITE(numout,*)"   OCE-SAS coupled via OASIS : nn_fsbc re-defined from OASIS namcouple ", nn_fsbc
             WRITE(numout,*)
          ENDIF
@@ -405,5 +405,5 @@
       !
       ll_sas = nn_components == jp_iam_sas               ! component flags
-      ll_opa = nn_components == jp_iam_opa
+      ll_opa = nn_components == jp_iam_oce
       !
       IF( .NOT.ll_sas )   CALL sbc_ssm ( kt, Kbb, Kmm )  ! mean ocean sea surface variables (sst_m, sss_m, ssu_m, ssv_m)
@@ -417,8 +417,8 @@
       CASE( jp_flx     )   ;   CALL sbc_flx       ( kt )                             ! flux formulation
       CASE( jp_blk     )
-         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OPA-SAS coupling: SAS receiving fields from OPA
+         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-SAS coupling: SAS receiving fields from OCE
 !!!!!!!!!!! ATTENTION:ln_wave is not only used for oasis coupling !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          IF( ln_wave )   THEN
-             IF ( lk_oasis )  CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OPA-wave coupling
+             IF ( lk_oasis )  CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-wave coupling
              CALL sbc_wave ( kt, Kmm )
          ENDIF
@@ -426,10 +426,10 @@
                                !
       CASE( jp_abl     )
-         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OPA-SAS coupling: SAS receiving fields from OPA
+         IF( ll_sas    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! OCE-SAS coupling: SAS receiving fields from OCE
                                CALL sbc_abl       ( kt )                    ! ABL  formulation for the ocean
                                !
       CASE( jp_purecpl )   ;   CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )   ! pure coupled formulation
       CASE( jp_none    )
-         IF( ll_opa    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )  ! OPA-SAS coupling: OPA receiving fields from SAS
+         IF( ll_opa    )       CALL sbc_cpl_rcv   ( kt, nn_fsbc, nn_ice, Kbb, Kmm )  ! OCE-SAS coupling: OCE receiving fields from SAS
       END SELECT
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcwave.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcwave.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcwave.F90	(revision 14644)
@@ -211,5 +211,5 @@
       ENDIF
 
-      CALL lbc_lnk_multi( 'sbcwave', usd, 'U', -1.0_wp, vsd, 'V', -1.0_wp )
+      CALL lbc_lnk( 'sbcwave', usd, 'U', -1.0_wp, vsd, 'V', -1.0_wp )
 
       !
@@ -503,4 +503,5 @@
                !
                CALL fld_fill( sf_sd, slf_i, cn_dir, 'sbc_wave_init', 'Wave module ', 'namsbc_wave' )
+               sf_sd(jp_usd)%zsgn = -1._wp   ;  sf_sd(jp_vsd)%zsgn = -1._wp   ! vector field at T point: overwrite default definition of zsgn
             ENDIF
             !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TDE/tide.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TDE/tide.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TDE/tide.h90	(revision 14644)
@@ -67,5 +67,6 @@
    !                         |                                                              Diurnal tidal constituents                                                                |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   tide_components( 8) = tide( 'K1'   , -0.142486_wp ,  1 ,  0 ,  1 ,  0 ,   0 ,    90 ,   0 ,    0 ,   -1 ,    0 ,  0 , 227 )      ! CE73           | S54 (Table 2)         | Note 1 |
+   tide_components( 8) = tide( 'K1'   ,  0.142486_wp ,  1 ,  0 ,  1 ,  0 ,   0 ,   -90 ,   0 ,    0 ,   -1 ,    0 ,  0 , 227 )      ! CE73, sign     | S54 (Table 2)         | Note 1 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | change         |                       |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
    tide_components( 9) = tide( 'O1'   ,  0.101316_wp ,  1 , -2 ,  1 ,  0 ,   0 ,    90 ,   2 ,   -1 ,    0 ,    0 ,  0 ,  75 )      ! CE73           | S54 (Table 2, A14)    |        |
@@ -75,5 +76,6 @@
    tide_components(11) = tide( 'Q1'   ,  0.019396_wp ,  1 , -3 ,  1 ,  1 ,   0 ,    90 ,   2 ,   -1 ,    0 ,    0 ,  0 ,  75 )      ! CE73           | S54 (Table 2, A15)    |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   tide_components(12) = tide( 'J1'   , -0.007967_wp ,  1 ,  1 ,  1 , -1 ,   0 ,    90 ,   0 ,   -1 ,    0 ,    0 ,  0 ,  76 )      ! CE73           | S54 (Table 2, A24)    | Note 1 |
+   tide_components(12) = tide( 'J1'   ,  0.007967_wp ,  1 ,  1 ,  1 , -1 ,   0 ,   -90 ,   0 ,   -1 ,    0 ,    0 ,  0 ,  76 )      ! CE73, sign     | S54 (Table 2, A24)    | Note 1 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | change         |                       |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
    tide_components(13) = tide( 'S1'   ,  0.000000_wp ,  1 ,  0 ,  0 ,  0 ,   0 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! Meteorological | S54 (Table 2, B71)    |        |
@@ -96,5 +98,6 @@
    tide_components(20) = tide( '2N2'  ,  0.006184_wp ,  2 , -4 ,  2 ,  2 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A42)    |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   tide_components(21) = tide( 'L2'   , -0.006899_wp ,  2 , -1 ,  2 , -1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 , -1 , 215 )      ! CE73           | S54 (Table 2)         | Note 1 |
+   tide_components(21) = tide( 'L2'   ,  0.006899_wp ,  2 , -1 ,  2 , -1 ,   0 ,   180 ,   2 ,   -2 ,    0 ,    0 , -1 , 215 )      ! CE73, sign     | S54 (Table 2)         | Note 1 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | change         |                       |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
    tide_components(22) = tide( 'T2'   ,  0.006655_wp ,  2 ,  0 , -1 ,  0 ,   1 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B40)    |        |
@@ -103,11 +106,14 @@
    !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            |                | algorithm)            |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   tide_components(24) = tide( 'lam2' , -0.001800_wp ,  2 , -1 ,  0 ,  1 ,   0 ,     0 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73           | S54 (Table 2, A44)    | Note 1 |
+   tide_components(24) = tide( 'lam2' ,  0.001800_wp ,  2 , -1 ,  0 ,  1 ,   0 ,   180 ,   2 ,   -2 ,    0 ,    0 ,  0 ,  78 )      ! CE73, sign     | S54 (Table 2, A44)    | Note 1 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | change         |                       |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   tide_components(25) = tide( 'R2'   , -0.000952_wp ,  2 ,  0 ,  1 ,  0 ,  -1 ,     0 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73           | S54 (Table 2, B41)    | Note 1 |
+   tide_components(25) = tide( 'R2'   ,  0.000952_wp ,  2 ,  0 ,  1 ,  0 ,  -1 ,   180 ,   0 ,    0 ,    0 ,    0 ,  0 ,   0 )      ! CE73, sign     | S54 (Table 2, B41)    | Note 1 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | change         |                       |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
    !                         |                                                            Terdiurnal tidal constituents                                                               |
    !                         +--------+-------------+-----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   tide_components(26) = tide( 'M3'   , -0.003192_wp ,  3 , -3 ,  3 ,  0 ,   0 ,   180 ,   3 ,   -3 ,    0 ,    0 ,  0 , 149 )      ! CT71           | S54 (Table 2, A82)    | Note 2 |
+   tide_components(26) = tide( 'M3'   ,  0.003192_wp ,  3 , -3 ,  3 ,  0 ,   0 ,     0 ,   3 ,   -3 ,    0 ,    0 ,  0 , 149 )      ! CT71, sign     | S54 (Table 2, A82)    | Note 2 |
+   !                         |        |              |    |    |    |    |     |       |     |      |      |      |    |            | change         |                       |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
    !                         |                                                                    Compound tides                                                                      |
@@ -135,6 +141,6 @@
    tide_components(34) = tide( 'M8'   ,  0.000000_wp ,  8 , -8 ,  8 ,  0 ,  0  ,     0 ,   8 ,   -8 ,    0 ,    0 ,  0 ,  20 )      ! Overtide       | S54                   |        |
    !                         +--------+--------------+----+----+----+----+-----+-------+-----+------+------+------+----+------------+----------------+-----------------------+--------+
-   !   Note 1: the phase shift from Table 2 of S54 has been adjusted to accomodate the negative sign of the equilibrium-tide value derived from CE73.
-   !   Note 2: the phase shift from Table 2 of S54 has been adjusted to accomodate the negative sign of the equilibrium-tide value derived from CT71.
+   !   Note 1: the negative sign of the equilibrium-tide value derived from CE73 has been changed to accomodate the phase shift from Table 2 of S54.
+   !   Note 2: the negative sign of the equilibrium-tide value derived from CT71 has been changed to accomodate the phase shift from Table 2 of S54.
    !   Note 3: the nodal correction factor formulas from FES2014 and S54 differ; here, the version from FES2014 has been selected.
 #else
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv.F90	(revision 14644)
@@ -183,6 +183,6 @@
          CASE ( np_FCT )                                 ! FCT scheme      : 2nd / 4th order
             IF (nn_hls.EQ.2) THEN
-               CALL lbc_lnk_multi( 'traadv', pts(:,:,:,:,Kbb), 'T', 1._wp, pts(:,:,:,:,Kmm), 'T', 1._wp)
-               CALL lbc_lnk_multi( 'traadv', zuu(:,:,:), 'U', -1._wp, zvv(:,:,:), 'V', -1._wp, zww(:,:,:), 'W', 1._wp)
+               CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1._wp, pts(:,:,:,:,Kmm), 'T', 1._wp)
+               CALL lbc_lnk( 'traadv', zuu(:,:,:), 'U', -1._wp, zvv(:,:,:), 'V', -1., zww(:,:,:), 'W', 1._wp)
 #if defined key_loop_fusion
                CALL tra_adv_fct_lf ( kt, nit000, 'TRA', rDt, zuu, zvv, zww, Kbb, Kmm, pts, jpts, Krhs, nn_fct_h, nn_fct_v )
@@ -209,5 +209,5 @@
          CASE ( np_QCK )                                 ! QUICKEST
             IF (nn_hls.EQ.2) THEN
-               CALL lbc_lnk_multi( 'traadv', zuu(:,:,:), 'U', -1._wp, zvv(:,:,:), 'V', -1._wp)
+               CALL lbc_lnk( 'traadv', zuu(:,:,:), 'U', -1._wp, zvv(:,:,:), 'V', -1._wp)
                CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1._wp)
             END IF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_cen.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_cen.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_cen.F90	(revision 14644)
@@ -120,5 +120,5 @@
                ztv(ji,jj,jk) = ( pt(ji  ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk)
             END_3D
-            IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_cen', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp )   ! Lateral boundary cond.
+            IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_cen', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp )   ! Lateral boundary cond.
             !
             DO_3D( nn_hls-1, 0, nn_hls-1, 0, 1, jpkm1 )           ! Horizontal advective fluxes
@@ -132,5 +132,5 @@
                zwy(ji,jj,jk) =  0.5_wp * pV(ji,jj,jk) * zC4t_v
             END_3D
-            IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_cen', zwx, 'U', -1._wp , zwy, 'V', -1._wp )
+            IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_cen', zwx, 'U', -1._wp , zwy, 'V', -1._wp )
             !
          CASE DEFAULT
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct.F90	(revision 14644)
@@ -90,6 +90,6 @@
       REAL(wp) ::   zfp_ui, zfp_vj, zfp_wk, zC2t_u, zC4t_u   !   -      -
       REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk, zC2t_v, zC4t_v   !   -      -
-      REAL(dp), DIMENSION(jpi,jpj,jpk)        ::   zwx, zwy, zwz
-      REAL(wp), DIMENSION(jpi,jpj,jpk)        ::   zwi, ztu, ztv, zltu, zltv, ztw
+      REAL(dp), DIMENSION(A2D(nn_hls),jpk)        ::   zwx, zwy, zwz
+      REAL(wp), DIMENSION(A2D(nn_hls),jpk)        ::   zwi, ztu, ztv, zltu, zltv, ztw
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdx, ztrdy, ztrdz, zptry
       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   zwinf, zwdia, zwsup
@@ -240,5 +240,5 @@
                END_2D
             END DO
-            CALL lbc_lnk_multi( 'traadv_fct', zltu, 'T', 1.0_wp , zltv, 'T', 1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            CALL lbc_lnk( 'traadv_fct', zltu, 'T', 1.0_wp , zltv, 'T', 1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
             !
             DO_3D( 1, 0, 1, 0, 1, jpkm1 )
@@ -249,5 +249,5 @@
                zwy(ji,jj,jk) =  0.5_wp * pV(ji,jj,jk) * ( zC2t_v + zltv(ji,jj,jk) - zltv(ji,jj+1,jk) ) - zwy(ji,jj,jk)
             END_3D
-            IF (nn_hls.EQ.2) CALL lbc_lnk_multi( 'traadv_fct', zwx, 'U', -1.0_wp, zwy, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            IF (nn_hls.EQ.2) CALL lbc_lnk( 'traadv_fct', zwx, 'U', -1.0_wp, zwy, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
             !
          CASE(  41 )                   !- 4th order centered       ==>>   !!gm coding attempt   need to be tested
@@ -258,5 +258,5 @@
                ztv(ji,jj,jk) = ( pt(ji  ,jj+1,jk,jn,Kmm) - pt(ji,jj,jk,jn,Kmm) ) * vmask(ji,jj,jk)
             END_3D
-            IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_fct', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_fct', ztu, 'U', -1.0_wp , ztv, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
             !
             DO_3D( 0, 0, 0, 0, 1, jpkm1 )    ! Horizontal advective fluxes
@@ -270,5 +270,5 @@
                zwy(ji,jj,jk) =  0.5_wp * pV(ji,jj,jk) * zC4t_v - zwy(ji,jj,jk)
             END_3D
-            IF (nn_hls.EQ.2) CALL lbc_lnk_multi( 'traadv_fct', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            IF (nn_hls.EQ.2) CALL lbc_lnk( 'traadv_fct', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
             !
          END SELECT
@@ -294,21 +294,5 @@
          !
          IF (nn_hls.EQ.1) THEN
-#if defined key_single
-            CALL lbc_lnk      ( 'traadv_fct', zwi, 'T', 1.0_wp )
-            CALL lbc_lnk_multi( 'traadv_fct',                   zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp )
-#else
-            CALL lbc_lnk_multi( 'traadv_fct', zwi, 'T', 1.0_wp, zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp )
-#endif
-         ELSE
-            CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp)
-         END IF
-         !
-         IF (nn_hls.EQ.1) THEN
-#if defined key_single
-            CALL lbc_lnk      ( 'traadv_fct', zwi, 'T', 1.0_wp )
-            CALL lbc_lnk_multi( 'traadv_fct',                   zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp )
-#else
-            CALL lbc_lnk_multi( 'traadv_fct', zwi, 'T', 1.0_wp, zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp )
-#endif
+            CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp, zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp, zwz, 'T', 1.0_wp )
          ELSE
             CALL lbc_lnk( 'traadv_fct', zwi, 'T', 1.0_wp)
@@ -467,5 +451,5 @@
          END_2D
       END DO
-      IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_fct', zbetup, 'T', 1.0_wp , zbetdo, 'T', 1.0_wp )   ! lateral boundary cond. (unchanged sign)
+      IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_fct', zbetup, 'T', 1.0_wp , zbetdo, 'T', 1.0_wp )   ! lateral boundary cond. (unchanged sign)
 
       ! 3. monotonic flux in the i & j direction (paa & pbb)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct_lf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct_lf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct_lf.F90	(revision 14644)
@@ -270,5 +270,5 @@
                END_2D
             END DO
-            CALL lbc_lnk_multi( 'traadv_fct', zltu_3d, 'T', 1.0_wp , zltv_3d, 'T', 1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            CALL lbc_lnk( 'traadv_fct', zltu_3d, 'T', 1.0_wp , zltv_3d, 'T', 1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
 !            !
             DO_3D( nn_hls, nn_hls-1, nn_hls, nn_hls-1, 1, jpkm1 )
@@ -280,5 +280,5 @@
             END_3D
             !
-            CALL lbc_lnk_multi( 'traadv_fct', zwx_3d, 'U', -1.0_wp , zwy_3d, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            CALL lbc_lnk( 'traadv_fct', zwx_3d, 'U', -1.0_wp , zwy_3d, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
          CASE(  41 )                   !- 4th order centered       ==>>   !!gm coding attempt   need to be tested
             DO_3D( 0, 0, 0, 0, 1, jpkm1 )    ! Horizontal advective fluxes
@@ -298,5 +298,5 @@
                zwy_3d(ji,jj,jk) =  0.5_wp * pV(ji,jj,jk) * zC4t_v - zwy_3d(ji,jj,jk)
             END_3D
-            CALL lbc_lnk_multi( 'traadv_fct', zwx_3d, 'U', -1.0_wp , zwy_3d, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+            CALL lbc_lnk( 'traadv_fct', zwx_3d, 'U', -1.0_wp , zwy_3d, 'V', -1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
             !
          END SELECT
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_mus.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_mus.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_mus.F90	(revision 14644)
@@ -141,5 +141,5 @@
          END_3D
          ! lateral boundary conditions   (changed sign)
-         IF ( nn_hls.EQ.1 ) CALL lbc_lnk_multi( 'traadv_mus', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )
+         IF ( nn_hls.EQ.1 ) CALL lbc_lnk( 'traadv_mus', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )
          !                                !-- Slopes of tracer
          zslpx(:,:,jpk) = 0._wp                 ! bottom values
@@ -177,5 +177,5 @@
             zwy(ji,jj,jk) = pV(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
          END_3D
-         IF ( nn_hls.EQ.1 ) CALL lbc_lnk_multi( 'traadv_mus', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )   ! lateral boundary conditions   (changed sign)
+         IF ( nn_hls.EQ.1 ) CALL lbc_lnk( 'traadv_mus', zwx, 'U', -1.0_wp , zwy, 'V', -1.0_wp )   ! lateral boundary conditions   (changed sign)
          !
          DO_3D( 0, 0, 0, 0, 1, jpkm1 )    !-- Tracer advective trend
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_qck.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_qck.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_qck.F90	(revision 14644)
@@ -146,19 +146,19 @@
          !
 !!gm why not using a SHIFT instruction...
-         DO_3D( 0, 0, nn_hls-1, nn_hls-1, 1, jpkm1 )     !--- Computation of the ustream and downstream value of the tracer and the mask
+         DO_3D( nn_hls-1, nn_hls-1, 0, 0, 1, jpkm1 )     !--- Computation of the ustream and downstream value of the tracer and the mask
             zfc(ji,jj,jk) = pt(ji-1,jj,jk,jn,Kbb)        ! Upstream   in the x-direction for the tracer
             zfd(ji,jj,jk) = pt(ji+1,jj,jk,jn,Kbb)        ! Downstream in the x-direction for the tracer
          END_3D
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp )   ! Lateral boundary conditions
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp )   ! Lateral boundary conditions
 
          !
          ! Horizontal advective fluxes
          ! ---------------------------
-         DO_3D( 0, 0, nn_hls-1, 0, 1, jpkm1 )
+         DO_3D( nn_hls-1, 0, 0, 0, 1, jpkm1 )
             zdir = 0.5 + SIGN( 0.5_wp, pU(ji,jj,jk) )   ! if pU > 0 : zdir = 1 otherwise zdir = 0
             zfu(ji,jj,jk) = zdir * zfc(ji,jj,jk ) + ( 1. - zdir ) * zfd(ji+1,jj,jk)  ! FU in the x-direction for T
          END_3D
          !
-         DO_3D( 0, 0, nn_hls-1, 0, 1, jpkm1 )
+         DO_3D( nn_hls-1, 0, 0, 0, 1, jpkm1 )
             zdir = 0.5 + SIGN( 0.5_wp, pU(ji,jj,jk) )   ! if pU > 0 : zdir = 1 otherwise zdir = 0
             zdx = ( zdir * e1t(ji,jj) + ( 1. - zdir ) * e1t(ji+1,jj) ) * e2u(ji,jj) * e3u(ji,jj,jk,Kmm)
@@ -168,5 +168,5 @@
          END_3D
          !--- Lateral boundary conditions
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp,  zwx(:,:,:), 'T', 1.0_wp )
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp,  zwx(:,:,:), 'T', 1.0_wp )
 
          !--- QUICKEST scheme
@@ -174,5 +174,5 @@
          !
          ! Mask at the T-points in the x-direction (mask=0 or mask=1)
-         DO_3D( 0, 0, nn_hls-1, nn_hls-1, 1, jpkm1 )
+         DO_3D( nn_hls-1, nn_hls-1, 0, 0, 1, jpkm1 )
             zfu(ji,jj,jk) = tmask(ji-1,jj,jk) + tmask(ji,jj,jk) + tmask(ji+1,jj,jk) - 2.
          END_3D
@@ -181,5 +181,5 @@
          !
          ! Tracer flux on the x-direction
-         DO_3D( 0, 0, 1, 0, 1, jpkm1 )
+         DO_3D( 1, 0, 0, 0, 1, jpkm1 )
             zdir = 0.5 + SIGN( 0.5_wp, pU(ji,jj,jk) )   ! if pU > 0 : zdir = 1 otherwise zdir = 0
             !--- If the second ustream point is a land point
@@ -233,5 +233,5 @@
             !
             !--- Computation of the ustream and downstream value of the tracer and the mask
-            DO_2D( nn_hls-1, nn_hls-1, 0, 0 )
+            DO_2D( 0, 0, nn_hls-1, nn_hls-1 )
                ! Upstream in the x-direction for the tracer
                zfc(ji,jj,jk) = pt(ji,jj-1,jk,jn,Kbb)
@@ -240,5 +240,5 @@
             END_2D
          END DO
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp )   ! Lateral boundary conditions
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_qck', zfc(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp )   ! Lateral boundary conditions
 
          !
@@ -246,10 +246,10 @@
          ! ---------------------------
          !
-         DO_3D( nn_hls-1, 0, 0, 0, 1, jpkm1 )
+         DO_3D( 0, 0, nn_hls-1, 0, 1, jpkm1 )
             zdir = 0.5 + SIGN( 0.5_wp, pV(ji,jj,jk) )   ! if pU > 0 : zdir = 1 otherwise zdir = 0
             zfu(ji,jj,jk) = zdir * zfc(ji,jj,jk ) + ( 1. - zdir ) * zfd(ji,jj+1,jk)  ! FU in the x-direction for T
          END_3D
          !
-         DO_3D( nn_hls-1, 0, 0, 0, 1, jpkm1 )
+         DO_3D( 0, 0, nn_hls-1, 0, 1, jpkm1 )
             zdir = 0.5 + SIGN( 0.5_wp, pV(ji,jj,jk) )   ! if pU > 0 : zdir = 1 otherwise zdir = 0
             zdx = ( zdir * e2t(ji,jj) + ( 1. - zdir ) * e2t(ji,jj+1) ) * e1v(ji,jj) * e3v(ji,jj,jk,Kmm)
@@ -260,5 +260,5 @@
 
          !--- Lateral boundary conditions
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp, zwy(:,:,:), 'T', 1.0_wp )
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_qck', zfu(:,:,:), 'T', 1.0_wp , zfd(:,:,:), 'T', 1.0_wp, zfc(:,:,:), 'T', 1.0_wp, zwy(:,:,:), 'T', 1.0_wp )
 
          !--- QUICKEST scheme
@@ -266,5 +266,5 @@
          !
          ! Mask at the T-points in the x-direction (mask=0 or mask=1)
-         DO_3D( nn_hls-1, nn_hls-1, 0, 0, 1, jpkm1 )
+         DO_3D( 0, 0, nn_hls-1, nn_hls-1, 1, jpkm1 )
             zfu(ji,jj,jk) = tmask(ji,jj-1,jk) + tmask(ji,jj,jk) + tmask(ji,jj+1,jk) - 2.
          END_3D
@@ -272,5 +272,5 @@
          !
          ! Tracer flux on the x-direction
-         DO_3D( 1, 0, 0, 0, 1, jpkm1 )
+         DO_3D( 0, 0, 1, 0, 1, jpkm1 )
             zdir = 0.5 + SIGN( 0.5_wp, pV(ji,jj,jk) )   ! if pU > 0 : zdir = 1 otherwise zdir = 0
             !--- If the second ustream point is a land point
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_ubs.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_ubs.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_ubs.F90	(revision 14644)
@@ -141,5 +141,5 @@
             !
          END DO
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'traadv_ubs', zltu, 'T', 1.0_wp, zltv, 'T', 1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'traadv_ubs', zltu, 'T', 1.0_wp, zltv, 'T', 1.0_wp )   ! Lateral boundary cond. (unchanged sgn)
          !
          DO_3D( 1, 0, 1, 0, 1, jpkm1 )   !==  Horizontal advective fluxes  ==!     (UBS)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traatf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traatf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traatf.F90	(revision 14644)
@@ -111,5 +111,5 @@
 #endif
       !                                              ! local domain boundaries  (T-point, unchanged sign)
-      CALL lbc_lnk_multi( 'traatf', pts(:,:,:,jp_tem,Kaa), 'T', 1.0_wp, pts(:,:,:,jp_sal,Kaa), 'T', 1.0_wp )
+      CALL lbc_lnk( 'traatf', pts(:,:,:,jp_tem,Kaa), 'T', 1.0_wp, pts(:,:,:,jp_sal,Kaa), 'T', 1.0_wp )
       !
       IF( ln_bdy )   CALL bdy_tra( kt, Kbb, pts, Kaa )  ! BDY open boundaries
@@ -157,5 +157,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( 'traatf',  pts(:,:,:,jp_tem,Kmm) , 'T', 1.0_wp, pts(:,:,:,jp_sal,Kmm) , 'T', 1.0_wp )
+         CALL lbc_lnk( 'traatf',  pts(:,:,:,jp_tem,Kmm) , 'T', 1.0_wp, pts(:,:,:,jp_sal,Kmm) , 'T', 1.0_wp )
 
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traatf_qco.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traatf_qco.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traatf_qco.F90	(revision 14644)
@@ -147,5 +147,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( 'traatfqco', pts(:,:,:,jp_tem,Kmm) , 'T', 1._wp, pts(:,:,:,jp_sal,Kmm) , 'T', 1._wp )
+         CALL lbc_lnk( 'traatfqco', pts(:,:,:,jp_tem,Kmm) , 'T', 1._wp, pts(:,:,:,jp_sal,Kmm) , 'T', 1._wp )
          !
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trabbl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trabbl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trabbl.F90	(revision 14644)
@@ -142,5 +142,5 @@
          IF( ntile == 0 .OR. ntile == nijtile ) THEN                       ! Do only on the last tile
             ! lateral boundary conditions ; just need for outputs
-            CALL lbc_lnk_multi( 'trabbl', utr_bbl, 'U', 1.0_wp , vtr_bbl, 'V', 1.0_wp )
+            CALL lbc_lnk( 'trabbl', utr_bbl, 'U', 1.0_wp , vtr_bbl, 'V', 1.0_wp )
             CALL iom_put( "uoce_bbl", utr_bbl )  ! bbl i-transport
             CALL iom_put( "voce_bbl", vtr_bbl )  ! bbl j-transport
@@ -249,5 +249,5 @@
       DO jn = 1, kjpt                                            ! tracer loop
          !                                                       ! ===========
-         DO_2D( isj, 0, isi, 0 )            ! CAUTION start from i=1 to update i=2 when cyclic east-west
+         DO_2D( isi, 0, isj, 0 )            ! CAUTION start from i=1 to update i=2 when cyclic east-west
             IF( utr_bbl(ji,jj) /= 0.e0 ) THEN            ! non-zero i-direction bbl advection
                ! down-slope i/k-indices (deep)      &   up-slope i/k indices (shelf)
@@ -523,5 +523,5 @@
       ! converte into REAL to use lbc_lnk ; impose a min value of 1 as a zero can be set in lbclnk
       zmbku(:,:) = REAL( mbku_d(:,:), wp )   ;     zmbkv(:,:) = REAL( mbkv_d(:,:), wp )
-      CALL lbc_lnk_multi( 'trabbl', zmbku,'U',1.0_wp, zmbkv,'V',1.0_wp)
+      CALL lbc_lnk( 'trabbl', zmbku,'U',1.0_wp, zmbkv,'V',1.0_wp)
       mbku_d(:,:) = MAX( INT( zmbku(:,:) ), 1 ) ;  mbkv_d(:,:) = MAX( NINT( zmbkv(:,:) ), 1 )
       !
@@ -542,5 +542,5 @@
          e3v_bbl_0(ji,jj) = MIN( e3v_0(ji,jj,mbkt(ji  ,jj+1)), e3v_0(ji,jj,mbkt(ji,jj)) )
       END_2D
-      CALL lbc_lnk_multi( 'trabbl', e3u_bbl_0, 'U', 1.0_wp , e3v_bbl_0, 'V', 1.0_wp )      ! lateral boundary conditions
+      CALL lbc_lnk( 'trabbl', e3u_bbl_0, 'U', 1.0_wp , e3v_bbl_0, 'V', 1.0_wp )      ! lateral boundary conditions
       !
       !                             !* masked diffusive flux coefficients
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_lap_blp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_lap_blp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_lap_blp.F90	(revision 14644)
@@ -165,5 +165,5 @@
          ENDIF
          !
-         DO_3D( isj, iej, isi, iei, 1, jpkm1 )            !== Second derivative (divergence) added to the general tracer trends  ==!
+         DO_3D( isi, iei, isj, iej, 1, jpkm1 )            !== Second derivative (divergence) added to the general tracer trends  ==!
             pt_rhs(ji,jj,jk,jn) = pt_rhs(ji,jj,jk,jn) + (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)     &
                &                                      +    ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )   &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_triad.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_triad.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_triad.F90	(revision 14644)
@@ -387,5 +387,5 @@
          !                                !==  add the vertical 33 flux  ==!
          IF( ln_traldf_lap ) THEN               ! laplacian case: eddy coef = ah_wslp2 - akz
-            DO_3D( 1, 0, 0, 0, 2, jpkm1 )
+            DO_3D( 0, 0, 1, 0, 2, jpkm1 )
                ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * tmask(ji,jj,jk)   &
                   &                            * ( ah_wslp2(ji,jj,jk) - akz(ji,jj,jk) )             &
@@ -395,10 +395,10 @@
             SELECT CASE( kpass )
             CASE(  1  )                            ! 1st pass : eddy coef = ah_wslp2
-               DO_3D( 1, 0, 0, 0, 2, jpkm1 )
+               DO_3D( 0, 0, 1, 0, 2, jpkm1 )
                   ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * tmask(ji,jj,jk)             &
                      &                            * ah_wslp2(ji,jj,jk) * ( pt(ji,jj,jk-1,jn) - pt(ji,jj,jk,jn) )
                END_3D
             CASE(  2  )                            ! 2nd pass : eddy flux = ah_wslp2 and akz applied on pt  and pt2 gradients, resp.
-               DO_3D( 1, 0, 0, 0, 2, jpkm1 )
+               DO_3D( 0, 0, 1, 0, 2, jpkm1 )
                   ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / e3w(ji,jj,jk,Kmm) * tmask(ji,jj,jk)                      &
                      &                            * (  ah_wslp2(ji,jj,jk) * ( pt (ji,jj,jk-1,jn) - pt (ji,jj,jk,jn) )   &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tramle.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tramle.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tramle.F90	(revision 14644)
@@ -246,6 +246,6 @@
          zmvw = MAX(  0._wp , ( 1._wp - zcvw ) * ( 1._wp + r5_21 * zcvw )  )
          !
-         zpsi_uw(ji,jj,jk) = zpsim_u(ji,jj) * zmuw * umask(ji,jj,jk)
-         zpsi_vw(ji,jj,jk) = zpsim_v(ji,jj) * zmvw * vmask(ji,jj,jk)
+         zpsi_uw(ji,jj,jk) = zpsim_u(ji,jj) * zmuw * wumask(ji,jj,jk) * wumask(ji,jj,1)
+         zpsi_vw(ji,jj,jk) = zpsim_v(ji,jj) * zmvw * wvmask(ji,jj,jk) * wvmask(ji,jj,1)
       END_3D
       !
@@ -258,5 +258,5 @@
          DO_2D( 0, 0, 0, 0 )
             pw(ji,jj,jk) = pw(ji,jj,jk) - ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji-1,jj,jk)   &
-               &                          + zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj-1,jk) )
+               &                          + zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj-1,jk) ) * wmask(ji,jj,1)
          END_2D
       END DO
@@ -361,5 +361,5 @@
                rfv(ji,jj) = SQRT(  zfv * zfv + z1_t2 )
             END_2D
-            CALL lbc_lnk_multi( 'tramle', rfu, 'U', 1.0_wp , rfv, 'V', 1.0_wp )
+            CALL lbc_lnk( 'tramle', rfu, 'U', 1.0_wp , rfv, 'V', 1.0_wp )
             !
          ELSEIF( nn_mle == 1 ) THEN           ! MLE array allocation & initialisation
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tranpc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tranpc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tranpc.F90	(revision 14644)
@@ -113,5 +113,5 @@
          IF( ntej == Nje0 ) THEN ; iej = nn_hls ; ELSE ; iej = 0 ; ENDIF
          !
-         DO_2D( isj, iej, isi, iei )                        ! interior column only
+         DO_2D( isi, iei, isj, iej )                        ! interior column only
             !
             IF( tmask(ji,jj,2) == 1 ) THEN      ! At least 2 ocean points
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traqsr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traqsr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traqsr.F90	(revision 14644)
@@ -152,5 +152,5 @@
          ELSE                                           ! No restart or Euler forward at 1st time step
             z1_2 = 1._wp
-            DO_3D( isj, iej, isi, iei, 1, jpk )
+            DO_3D( isi, iei, isj, iej, 1, jpk )
                qsr_hc_b(ji,jj,jk) = 0._wp
             END_3D
@@ -158,5 +158,5 @@
       ELSE                             !==  Swap of qsr heat content  ==!
          z1_2 = 0.5_wp
-         DO_3D( isj, iej, isi, iei, 1, jpk )
+         DO_3D( isi, iei, isj, iej, 1, jpk )
             qsr_hc_b(ji,jj,jk) = qsr_hc(ji,jj,jk)
          END_3D
@@ -169,5 +169,5 @@
       CASE( np_BIO )                   !==  bio-model fluxes  ==!
          !
-         DO_3D( isj, iej, isi, iei, 1, nksr )
+         DO_3D( isi, iei, isj, iej, 1, nksr )
             qsr_hc(ji,jj,jk) = r1_rho0_rcp * ( etot3(ji,jj,jk) - etot3(ji,jj,jk+1) )
          END_3D
@@ -191,5 +191,5 @@
             ! most expensive calculations)
             !
-            DO_2D( isj, iej, isi, iei )
+            DO_2D( isi, iei, isj, iej )
                        ! zlogc = log(zchl)
                zlogc = LOG ( MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) ) )
@@ -210,5 +210,5 @@
 
 !
-            DO_3D( isj, iej, isi, iei, 1, nksr + 1 )
+            DO_3D( isi, iei, isj, iej, 1, nksr + 1 )
                ! zchl    = ALOG( ze0(ji,jj) )
                zlogc = ze0(ji,jj)
@@ -240,5 +240,5 @@
          !
          zcoef  = ( 1. - rn_abs ) / 3._wp    !* surface equi-partition in R-G-B
-         DO_2D( isj, iej, isi, iei )
+         DO_2D( isi, iei, isj, iej )
             ze0(ji,jj) = rn_abs * qsr(ji,jj)
             ze1(ji,jj) = zcoef  * qsr(ji,jj)
@@ -251,5 +251,5 @@
          !
          !                                    !* interior equi-partition in R-G-B depending on vertical profile of Chl
-         DO_3D( isj, iej, isi, iei, 2, nksr + 1 )
+         DO_3D( isi, iei, isj, iej, 2, nksr + 1 )
             ze3t = e3t(ji,jj,jk-1,Kmm)
             irgb = NINT( ztmp3d(ji,jj,jk) )
@@ -265,5 +265,5 @@
          END_3D
          !
-         DO_3D( isj, iej, isi, iei, 1, nksr )          !* now qsr induced heat content
+         DO_3D( isi, iei, isj, iej, 1, nksr )          !* now qsr induced heat content
             qsr_hc(ji,jj,jk) = r1_rho0_rcp * ( ztmp3d(ji,jj,jk) - ztmp3d(ji,jj,jk+1) )
          END_3D
@@ -275,5 +275,5 @@
          zz0 =        rn_abs   * r1_rho0_rcp      ! surface equi-partition in 2-bands
          zz1 = ( 1. - rn_abs ) * r1_rho0_rcp
-         DO_3D( isj, iej, isi, iei, 1, nksr )          !* now qsr induced heat content
+         DO_3D( isi, iei, isj, iej, 1, nksr )          !* now qsr induced heat content
             zc0 = zz0 * EXP( -gdepw(ji,jj,jk  ,Kmm)*xsi0r ) + zz1 * EXP( -gdepw(ji,jj,jk  ,Kmm)*xsi1r )
             zc1 = zz0 * EXP( -gdepw(ji,jj,jk+1,Kmm)*xsi0r ) + zz1 * EXP( -gdepw(ji,jj,jk+1,Kmm)*xsi1r )
@@ -293,5 +293,5 @@
       !
       ! sea-ice: store the 1st ocean level attenuation coefficient
-      DO_2D( isj, iej, isi, iei )
+      DO_2D( isi, iei, isj, iej )
          IF( qsr(ji,jj) /= 0._wp ) THEN   ;   fraqsr_1lev(ji,jj) = qsr_hc(ji,jj,1) / ( r1_rho0_rcp * qsr(ji,jj) )
          ELSE                             ;   fraqsr_1lev(ji,jj) = 1._wp
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trasbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trasbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trasbc.F90	(revision 14644)
@@ -106,5 +106,5 @@
 !!gm  This should be moved into sbcmod.F90 module ? (especially now that ln_traqsr is read in namsbc namelist)
       IF( .NOT.ln_traqsr ) THEN     ! no solar radiation penetration
-         DO_2D( isj, iej, isi, iei )
+         DO_2D( isi, iei, isj, iej )
             qns(ji,jj) = qns(ji,jj) + qsr(ji,jj)      ! total heat flux in qns
             qsr(ji,jj) = 0._wp                        ! qsr set to zero
@@ -127,5 +127,5 @@
          ELSE                                             ! No restart or restart not found: Euler forward time stepping
             zfact = 1._wp
-            DO_2D( isj, iej, isi, iei )
+            DO_2D( isi, iei, isj, iej )
                sbc_tsc(ji,jj,:) = 0._wp
                sbc_tsc_b(ji,jj,:) = 0._wp
@@ -134,15 +134,15 @@
       ELSE                                !* other time-steps: swap of forcing fields
          zfact = 0.5_wp
-         DO_2D( isj, iej, isi, iei )
+         DO_2D( isi, iei, isj, iej )
             sbc_tsc_b(ji,jj,:) = sbc_tsc(ji,jj,:)
          END_2D
       ENDIF
       !                             !==  Now sbc tracer content fields  ==!
-      DO_2D( isj, iej, isi, iei )
+      DO_2D( isi, iei, isj, iej )
          sbc_tsc(ji,jj,jp_tem) = r1_rho0_rcp * qns(ji,jj)   ! non solar heat flux
          sbc_tsc(ji,jj,jp_sal) = r1_rho0     * sfx(ji,jj)   ! salt flux due to freezing/melting
       END_2D
       IF( ln_linssh ) THEN                !* linear free surface
-         DO_2D( isj, iej, isi, iei )                    !==>> add concentration/dilution effect due to constant volume cell
+         DO_2D( isi, iei, isj, iej )                    !==>> add concentration/dilution effect due to constant volume cell
             sbc_tsc(ji,jj,jp_tem) = sbc_tsc(ji,jj,jp_tem) + r1_rho0 * emp(ji,jj) * pts(ji,jj,1,jp_tem,Kmm)
             sbc_tsc(ji,jj,jp_sal) = sbc_tsc(ji,jj,jp_sal) + r1_rho0 * emp(ji,jj) * pts(ji,jj,1,jp_sal,Kmm)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trazdf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trazdf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trazdf.F90	(revision 14644)
@@ -103,5 +103,5 @@
          END DO
 !!gm this should be moved in trdtra.F90 and done on all trends
-         CALL lbc_lnk_multi( 'trazdf', ztrdt, 'T', 1.0_wp , ztrds, 'T', 1.0_wp )
+         CALL lbc_lnk( 'trazdf', ztrdt, 'T', 1.0_wp , ztrds, 'T', 1.0_wp )
 !!gm
          CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/zpshde.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/zpshde.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/zpshde.F90	(revision 14644)
@@ -173,5 +173,5 @@
       END DO
       !
-      IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp )   ! Lateral boundary cond.
+      IF (nn_hls.EQ.1) CALL lbc_lnk( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp )   ! Lateral boundary cond.
       !
       IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
@@ -206,5 +206,5 @@
             ENDIF
          END_2D
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp )   ! Lateral boundary conditions
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp )   ! Lateral boundary conditions
          !
       END IF
@@ -359,5 +359,5 @@
       END DO
       !
-      IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp )   ! Lateral boundary cond.
+      IF (nn_hls.EQ.1) CALL lbc_lnk( 'zpshde', pgtu(:,:,:), 'U', -1.0_wp , pgtv(:,:,:), 'V', -1.0_wp )   ! Lateral boundary cond.
 
       ! horizontal derivative of density anomalies (rd)
@@ -401,5 +401,5 @@
          END_2D
 
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp )   ! Lateral boundary conditions
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'zpshde', pgru , 'U', -1.0_wp , pgrv , 'V', -1.0_wp )   ! Lateral boundary conditions
          !
       END IF
@@ -452,5 +452,5 @@
          !
       END DO
-      IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'zpshde', pgtui(:,:,:), 'U', -1.0_wp , pgtvi(:,:,:), 'V', -1.0_wp )   ! Lateral boundary cond.
+      IF (nn_hls.EQ.1) CALL lbc_lnk( 'zpshde', pgtui(:,:,:), 'U', -1.0_wp , pgtvi(:,:,:), 'V', -1.0_wp )   ! Lateral boundary cond.
 
       IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
@@ -491,5 +491,5 @@
 
          END_2D
-         IF (nn_hls.EQ.1) CALL lbc_lnk_multi( 'zpshde', pgrui, 'U', -1.0_wp , pgrvi, 'V', -1.0_wp )   ! Lateral boundary conditions
+         IF (nn_hls.EQ.1) CALL lbc_lnk( 'zpshde', pgrui, 'U', -1.0_wp , pgrvi, 'V', -1.0_wp )   ! Lateral boundary conditions
          !
       END IF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trd_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trd_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trd_oce.F90	(revision 14644)
@@ -27,5 +27,5 @@
    LOGICAL , PUBLIC ::   l_trddyn        !: momentum trend flag (set from namelist in trdini)
    
-# if ( defined key_trdtrc && defined key_iomput )  ||  defined key_trdmxl_trc
+# if ( defined key_trdtrc && defined key_xios )  ||  defined key_trdmxl_trc
    LOGICAL , PUBLIC ::   l_trdtrc = .TRUE.        !: tracers  trend flag
 # else
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trddyn.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trddyn.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trddyn.F90	(revision 14644)
@@ -128,5 +128,5 @@
                                  z3dy(ji,jj,jk) = vv(ji,jj,jk,Kmm) * ( vv(ji,jj+1,jk,Kmm) - vv(ji,jj-1,jk,Kmm) ) / ( 2._wp * e2v(ji,jj) )
                               END_3D
-                              CALL lbc_lnk_multi( 'trddyn', z3dx, 'U', -1.0_wp, z3dy, 'V', -1.0_wp )
+                              CALL lbc_lnk( 'trddyn', z3dx, 'U', -1.0_wp, z3dy, 'V', -1.0_wp )
                               CALL iom_put( "utrd_udx", z3dx  )
                               CALL iom_put( "vtrd_vdy", z3dy  )
@@ -164,5 +164,5 @@
 !                                 END DO
 !                              END DO
-!                              CALL lbc_lnk_multi( 'trddyn', z3dx, 'U', -1.0_wp, z3dy, 'V', -1.0_wp )
+!                              CALL lbc_lnk( 'trddyn', z3dx, 'U', -1.0_wp, z3dy, 'V', -1.0_wp )
 !                              CALL iom_put( "utrd_bfr", z3dx )
 !                              CALL iom_put( "vtrd_bfr", z3dy )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdken.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdken.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdken.F90	(revision 14644)
@@ -90,5 +90,5 @@
       !!----------------------------------------------------------------------
       !
-      CALL lbc_lnk_multi( 'trdken', putrd, 'U', -1.0_wp , pvtrd, 'V', -1.0_wp )      ! lateral boundary conditions
+      CALL lbc_lnk( 'trdken', putrd, 'U', -1.0_wp , pvtrd, 'V', -1.0_wp )      ! lateral boundary conditions
       !
       nkstp = kt
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdmxl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdmxl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdmxl.F90	(revision 14644)
@@ -154,5 +154,5 @@
 !!gm to be put juste before the output !
 !      ! Lateral boundary conditions
-!      CALL lbc_lnk_multi( 'trdmxl', tmltrd(:,:,jl), 'T', 1.0_wp , smltrd(:,:,jl), 'T', 1.0_wp )
+!      CALL lbc_lnk( 'trdmxl', tmltrd(:,:,jl), 'T', 1.0_wp , smltrd(:,:,jl), 'T', 1.0_wp )
 !!gm end
 
@@ -472,7 +472,7 @@
          !-- Lateral boundary conditions
          !         ... temperature ...                    ... salinity ...
-         CALL lbc_lnk_multi( 'trdmxl', ztmltot , 'T', 1.0_wp, zsmltot , 'T', 1.0_wp, &
-                  &          ztmlres , 'T', 1.0_wp, zsmlres , 'T', 1.0_wp, &
-                  &          ztmlatf , 'T', 1.0_wp, zsmlatf , 'T', 1.0_wp )
+         CALL lbc_lnk( 'trdmxl', ztmltot , 'T', 1.0_wp, zsmltot , 'T', 1.0_wp, &
+            &                    ztmlres , 'T', 1.0_wp, zsmlres , 'T', 1.0_wp, &
+            &                    ztmlatf , 'T', 1.0_wp, zsmlatf , 'T', 1.0_wp )
 
 
@@ -523,8 +523,8 @@
          !-- Lateral boundary conditions
          !         ... temperature ...                    ... salinity ...
-         CALL lbc_lnk_multi( 'trdmxl', ztmltot2, 'T', 1.0_wp, zsmltot2, 'T', 1.0_wp, &
-                  &          ztmlres2, 'T', 1.0_wp, zsmlres2, 'T', 1.0_wp )
-         !
-         CALL lbc_lnk_multi( 'trdmxl', ztmltrd2(:,:,:), 'T', 1.0_wp, zsmltrd2(:,:,:), 'T', 1.0_wp ) ! /  in the NetCDF trends file
+         CALL lbc_lnk( 'trdmxl', ztmltot2, 'T', 1.0_wp, zsmltot2, 'T', 1.0_wp, &
+            &                    ztmlres2, 'T', 1.0_wp, zsmlres2, 'T', 1.0_wp )
+         !
+         CALL lbc_lnk( 'trdmxl', ztmltrd2(:,:,:), 'T', 1.0_wp, zsmltrd2(:,:,:), 'T', 1.0_wp ) ! /  in the NetCDF trends file
          
          ! III.3 Time evolution array swap
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdvor.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdvor.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdvor.F90	(revision 14644)
@@ -162,5 +162,5 @@
 
       zudpvor(:,:) = 0._wp                 ;   zvdpvor(:,:) = 0._wp                    ! Initialisation
-      CALL lbc_lnk_multi( 'trdvor', putrdvor, 'U', -1.0_wp , pvtrdvor, 'V', -1.0_wp )      ! lateral boundary condition
+      CALL lbc_lnk( 'trdvor', putrdvor, 'U', -1.0_wp , pvtrdvor, 'V', -1.0_wp )      ! lateral boundary condition
       
 
@@ -251,5 +251,5 @@
       zvdpvor(:,:) = 0._wp
       !                            ! lateral boundary condition on input momentum trends
-      CALL lbc_lnk_multi( 'trdvor', putrdvor, 'U', -1.0_wp , pvtrdvor, 'V', -1.0_wp )
+      CALL lbc_lnk( 'trdvor', putrdvor, 'U', -1.0_wp , pvtrdvor, 'V', -1.0_wp )
 
       !  =====================================
@@ -400,5 +400,5 @@
 
          ! Boundary conditions
-         CALL lbc_lnk_multi( 'trdvor', vor_avrtot, 'F', 1.0_wp , vor_avrres, 'F', 1.0_wp )
+         CALL lbc_lnk( 'trdvor', vor_avrtot, 'F', 1.0_wp , vor_avrres, 'F', 1.0_wp )
 
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/README.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/README.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/README.rst	(revision 14644)
@@ -37,5 +37,5 @@
 .. code-block:: console
 
-   $ ./makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' -m 'my_arch' del_key 'key_iomput' add_key 'key_diahth'
+   $ ./makenemo –n 'ORCA2_ICE_PISCES_MINE' -r 'ORCA2_ICE_PISCES' -m 'my_arch' del_key 'key_xios' add_key 'key_diahth'
 
 Option 3: Use the SIREN tools to subset an existing model
@@ -58,4 +58,9 @@
 
 .. _here: https://prodn.idris.fr/thredds/catalog/ipsl_public/rron463/catalog.html
+
+Option 4: Use the nesting tools to create embedded zooms or regional configurations from an existing grid
+---------------------------------------------------------------------------------------------------------
+(see :download:`NESTING README <../../../tools/NESTING/README>`).
+
 
 Creating a completely new configuration
@@ -111,8 +116,6 @@
    /* configuration name, configuration resolution                 */
    int    ORCA, ORCA_index
-   /* global domain sizes                                          */
-   int    jpiglo, jpjglo, jpkglo
    /* lateral global domain b.c.                                   */
-   int    jperio
+   int    Iperio, Jperio, NFoldT, NFoldF
    /* flags for z-coord, z-coord with partial steps and s-coord    */
    int    ln_zco, ln_zps, ln_sco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_hgr.F90	(revision 14644)
@@ -125,7 +125,7 @@
       ENDIF
       !   
-      DO_2D( 1, 1, 1, 1 )
-         zim1 = REAL( mig0_oldcmp(ji), wp ) - 1.   ;   zim05 = REAL( mig0_oldcmp(ji), wp ) - 1.5
-         zjm1 = REAL( mjg0_oldcmp(jj), wp ) - 1.   ;   zjm05 = REAL( mjg0_oldcmp(jj), wp ) - 1.5
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         zim1 = REAL( mig0(ji), wp ) - 1.   ;   zim05 = REAL( mig0(ji), wp ) - 1.5
+         zjm1 = REAL( mjg0(jj), wp ) - 1.   ;   zjm05 = REAL( mjg0(jj), wp ) - 1.5
          !   
          !glamt(i,j) longitude at T-point
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_nam.F90	(revision 14644)
@@ -37,5 +37,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -49,8 +49,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER         , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER         , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes
-      INTEGER         , INTENT(out) ::   kperio          ! lateral global domain b.c.
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -82,5 +84,6 @@
       kpk = jpkglo
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! GYRE configuration : closed domain
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! GYRE configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -102,5 +105,4 @@
          WRITE(numout,*) '      number of model levels                           jpkglo = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral b.c. of the global domain set to closed     jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/USR/usrdef_sbc.F90	(revision 14644)
@@ -181,5 +181,5 @@
          wndm(ji,jj) = SQRT( zmod * zcoef )
       END_2D
-      CALL lbc_lnk_multi( 'usrdef_sbc', taum(:,:), 'T', 1.0_wp , wndm(:,:), 'T', 1.0_wp )
+      CALL lbc_lnk( 'usrdef_sbc', taum(:,:), 'T', 1.0_wp , wndm(:,:), 'T', 1.0_wp )
 
       ! ---------------------------------- !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfmfc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfmfc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfmfc.F90	(revision 14644)
@@ -378,5 +378,5 @@
       !
       !
-      CALL lbc_lnk_multi( 'zdfmfc', edmfm,'T',1._wp, edmfa,'T',1._wp, edmfb,'T',1._wp, edmfc,'T',1._wp, edmftra(:,:,:,jp_tem),'T',1._wp, edmftra(:,:,:,jp_sal),'T',1._wp)
+      CALL lbc_lnk( 'zdfmfc', edmfm,'T',1._wp, edmfa,'T',1._wp, edmfb,'T',1._wp, edmfc,'T',1._wp, edmftra(:,:,:,jp_tem),'T',1._wp, edmftra(:,:,:,jp_sal),'T',1._wp)
       !
    END SUBROUTINE tra_mfc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfosm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfosm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfosm.F90	(revision 14644)
@@ -1164,6 +1164,6 @@
      END_3D
       ! Lateral boundary conditions on ghamu and ghamv, currently on W-grid  (sign unchanged), needed to caclulate gham[uv] on u and v grids
-     CALL lbc_lnk_multi( 'zdfosm', p_avt, 'W', 1.0_wp , p_avm, 'W', 1.0_wp,   &
-      &                  ghamu, 'W', 1.0_wp , ghamv, 'W', 1.0_wp )
+     CALL lbc_lnk( 'zdfosm', p_avt, 'W', 1.0_wp , p_avm, 'W', 1.0_wp,   &
+        &                    ghamu, 'W', 1.0_wp , ghamv, 'W', 1.0_wp )
        DO_3D( 0, 0, 0, 0, 2, jpkm1 )
             ghamu(ji,jj,jk) = ( ghamu(ji,jj,jk) + ghamu(ji+1,jj,jk) ) &
@@ -1177,9 +1177,9 @@
        END_3D
         ! Lateral boundary conditions on final outputs for hbl,  on T-grid (sign unchanged)
-        CALL lbc_lnk_multi( 'zdfosm', hbl, 'T', 1._wp, dh, 'T', 1._wp, hmle, 'T', 1._wp )
+        CALL lbc_lnk( 'zdfosm', hbl, 'T', 1._wp, dh, 'T', 1._wp, hmle, 'T', 1._wp )
         ! Lateral boundary conditions on final outputs for gham[ts],  on W-grid  (sign unchanged)
         ! Lateral boundary conditions on final outputs for gham[uv],  on [UV]-grid  (sign changed)
-        CALL lbc_lnk_multi( 'zdfosm', ghamt, 'W',  1.0_wp , ghams, 'W',  1.0_wp,   &
-         &                            ghamu, 'U', -1.0_wp , ghamv, 'V', -1.0_wp )
+        CALL lbc_lnk( 'zdfosm', ghamt, 'W',  1.0_wp , ghams, 'W',  1.0_wp,   &
+           &                    ghamu, 'U', -1.0_wp , ghamv, 'V', -1.0_wp )
 
       IF(ln_dia_osm) THEN
@@ -2348,5 +2348,5 @@
       ! calculate horizontal gradients at u & v points
 
-      DO_2D( 0, 0, 1, 0 )
+      DO_2D( 1, 0, 0, 0 )
          zdtdx(ji,jj) = ( ztm(ji+1,jj) - ztm( ji,jj) )  * umask(ji,jj,1) / e1u(ji,jj)
          zdsdx(ji,jj) = ( zsm(ji+1,jj) - zsm( ji,jj) )  * umask(ji,jj,1) / e1u(ji,jj)
@@ -2356,5 +2356,5 @@
       END_2D
 
-      DO_2D( 1, 0, 0, 0 )
+      DO_2D( 0, 0, 1, 0 )
          zdtdy(ji,jj) = ( ztm(ji,jj+1) - ztm( ji,jj) ) * vmask(ji,jj,1) / e1v(ji,jj)
          zdsdy(ji,jj) = ( zsm(ji,jj+1) - zsm( ji,jj) ) * vmask(ji,jj,1) / e1v(ji,jj)
@@ -2367,8 +2367,8 @@
       CALL eos_rab(ztsm_midv, zmld_midv, zabv, Kmm)
 
-      DO_2D( 0, 0, 1, 0 )
+      DO_2D( 1, 0, 0, 0 )
          dbdx_mle(ji,jj) = grav*(zdtdx(ji,jj)*zabu(ji,jj,jp_tem) - zdsdx(ji,jj)*zabu(ji,jj,jp_sal))
       END_2D
-      DO_2D( 1, 0, 0, 0 )
+      DO_2D( 0, 0, 1, 0 )
          dbdy_mle(ji,jj) = grav*(zdtdy(ji,jj)*zabv(ji,jj,jp_tem) - zdsdy(ji,jj)*zabv(ji,jj,jp_sal))
       END_2D
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfphy.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfphy.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfphy.F90	(revision 14644)
@@ -323,13 +323,13 @@
       !                                         !* Lateral boundary conditions (sign unchanged)
       IF( l_zdfsh2 ) THEN
-         CALL lbc_lnk_multi( 'zdfphy', avm_k, 'W', 1.0_wp , avt_k, 'W', 1.0_wp,   &
-            &                avm  , 'W', 1.0_wp , avt  , 'W', 1.0_wp , avs , 'W', 1.0_wp )
+         CALL lbc_lnk( 'zdfphy', avm_k, 'W', 1.0_wp , avt_k, 'W', 1.0_wp,   &
+            &                    avm  , 'W', 1.0_wp , avt  , 'W', 1.0_wp , avs , 'W', 1.0_wp )
       ELSE
-         CALL lbc_lnk_multi( 'zdfphy', avm  , 'W', 1.0_wp , avt  , 'W', 1.0_wp , avs , 'W', 1.0_wp )
+         CALL lbc_lnk( 'zdfphy', avm  , 'W', 1.0_wp , avt  , 'W', 1.0_wp , avs , 'W', 1.0_wp )
       ENDIF
       !
       IF( l_zdfdrg ) THEN     ! drag  have been updated (non-linear cases)
-         IF( ln_isfcav ) THEN   ;  CALL lbc_lnk_multi( 'zdfphy', rCdU_top, 'T', 1.0_wp , rCdU_bot, 'T', 1.0_wp )   ! top & bot drag
-         ELSE                   ;  CALL lbc_lnk      ( 'zdfphy', rCdU_bot, 'T', 1.0_wp )                       ! bottom drag only
+         IF( ln_isfcav ) THEN   ;  CALL lbc_lnk( 'zdfphy', rCdU_top, 'T', 1.0_wp , rCdU_bot, 'T', 1.0_wp )   ! top & bot drag
+         ELSE                   ;  CALL lbc_lnk( 'zdfphy', rCdU_bot, 'T', 1.0_wp )                       ! bottom drag only
          ENDIF
       ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/do_loop_substitute.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/do_loop_substitute.h90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/do_loop_substitute.h90	(revision 14644)
@@ -2,5 +2,5 @@
 ! These comments are not intended to be retained during preprocessing; i.e. do not define "show_comments"
 !!----------------------------------------------------------------------
-!! NEMO/OCE 4.0 , NEMO Consortium (2018)
+!! NEMO/OCE 4.x , NEMO Consortium (2020)
 !! Software governed by the CeCILL license (see ./LICENSE)
 !!----------------------------------------------------------------------
@@ -25,9 +25,9 @@
 ! Upper limits of jpi, jpim1 or fs_jpim1 (for ji) or jpj, jpjm1 or fs_jpjm1 (for jj)
 !
-! The macro naming convention takes the form: DO_2D( B, T, L, R) where:
+! The macro naming convention takes the form: DO_2D( L, R, B, T) where:
+!   L is the Left   offset from the PE's inner domain;
+!   R is the Right  offset from the PE's inner domain
 !   B is the Bottom offset from the PE's inner domain;
 !   T is the Top    offset from the PE's inner domain;
-!   L is the Left   offset from the PE's inner domain;
-!   R is the Right  offset from the PE's inner domain
 !
 ! So, given an inner domain of 2,jpim1 and 2,jpjm1, a typical example would replace:
@@ -42,5 +42,5 @@
 ! with:
 !
-!   DO_2D( 0, 1, 1, 0 )
+!   DO_2D( 1, 0, 0, 1 )
 !      .
 !      .
@@ -59,5 +59,5 @@
 #endif
 
-#define DO_2D(B, T, L, R) DO jj = ntsj-(B), ntej+(T)   ;   DO ji = ntsi-(L), ntei+(R)
+#define DO_2D(L, R, B, T) DO jj = ntsj-(B), ntej+(T)   ;   DO ji = ntsi-(L), ntei+(R)
 #define A1Di(H) ntsi-H:ntei+H
 #define A1Dj(H) ntsj-H:ntej+H
@@ -70,7 +70,7 @@
 #define KJPT  :
 
-#define DO_3D(B, T, L, R, ks, ke) DO jk = ks, ke   ;   DO_2D(B, T, L, R)
+#define DO_3D(L, R, B, T, ks, ke) DO jk = ks, ke   ;   DO_2D(L, R, B, T)
 
-#define DO_3DS(B, T, L, R, ks, ke, ki) DO jk = ks, ke, ki   ;   DO_2D(B, T, L, R)
+#define DO_3DS(L, R, B, T, ks, ke, ki) DO jk = ks, ke, ki   ;   DO_2D(L, R, B, T)
 
 #define END_2D   END DO   ;   END DO
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_cray.f90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_cray.f90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_cray.f90	(revision 14644)
@@ -1,3 +1,3 @@
-!  Cray subroutines or functions used by OPA model and possibly 
+!  Cray subroutines or functions used by OCE model and possibly 
 !  not found on other platforms.
 !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_fortran.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_fortran.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/lib_fortran.F90	(revision 14644)
@@ -169,5 +169,5 @@
       !
       DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
-         IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &
+         IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &              ! 1st bottom left corner always at (Nis0-1, Njs0-1)
            & MOD(mjg(jj), 3) == MOD(nn_hls, 3)         ) THEN         ! bottom left corner of a 3x3 box
             ji2 = MIN(mig(ji)+2, jpiglo) - nimpp + 1                  ! right position of the box
@@ -179,19 +179,21 @@
       END_2D
       CALL lbc_lnk( 'lib_fortran', p2d, 'T', 1.0_wp )
-      ! no need for 2nd exchange when nn_hls = 2
-      IF( nn_hls /= 2 ) THEN
-         IF( nbondi /= -1 ) THEN
-            IF( MOD(mig(    1), 3) == 1 )   p2d(    1,:) = p2d(    2,:)
-            IF( MOD(mig(    1), 3) == 2 )   p2d(    2,:) = p2d(    1,:)
-         ENDIF
-         IF( nbondi /=  1 ) THEN
+      ! no need for 2nd exchange when nn_hls > 1
+      IF( nn_hls == 1 ) THEN
+         IF( mpiRnei(nn_hls,jpwe) > -1 ) THEN   ! 1st column was changed during the previous call to lbc_lnk
+            IF( MOD(mig(    1), 3) == 1 )   &   ! 1st box start at i=1 -> column 1 to 3 correctly computed locally
+               p2d(    1,:) = p2d(    2,:)      ! previous lbc_lnk corrupted column 1 -> put it back using column 2 
+            IF( MOD(mig(    1), 3) == 2 )   &   ! 1st box start at i=3 -> column 1 and 2 correctly computed on west neighbourh
+               p2d(    2,:) = p2d(    1,:)      !  previous lbc_lnk fix column 1 -> copy it to column 2 
+         ENDIF
+         IF( mpiRnei(nn_hls,jpea) > -1 ) THEN
             IF( MOD(mig(jpi-2), 3) == 1 )   p2d(  jpi,:) = p2d(jpi-1,:)
             IF( MOD(mig(jpi-2), 3) == 0 )   p2d(jpi-1,:) = p2d(  jpi,:)
          ENDIF
-         IF( nbondj /= -1 ) THEN
+         IF( mpiRnei(nn_hls,jpso) > -1 ) THEN
             IF( MOD(mjg(    1), 3) == 1 )   p2d(:,    1) = p2d(:,    2)
             IF( MOD(mjg(    1), 3) == 2 )   p2d(:,    2) = p2d(:,    1)
          ENDIF
-         IF( nbondj /=  1 ) THEN
+         IF( mpiRnei(nn_hls,jpno) > -1 ) THEN
             IF( MOD(mjg(jpj-2), 3) == 1 )   p2d(:,  jpj) = p2d(:,jpj-1)
             IF( MOD(mjg(jpj-2), 3) == 0 )   p2d(:,jpj-1) = p2d(:,  jpj)
@@ -223,5 +225,5 @@
          !
          DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
-            IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &
+            IF( MOD(mig(ji), 3) == MOD(nn_hls, 3) .AND.   &              ! 1st bottom left corner always at (Nis0-1, Njs0-1)
               & MOD(mjg(jj), 3) == MOD(nn_hls, 3)         ) THEN         ! bottom left corner of a 3x3 box
                ji2 = MIN(mig(ji)+2, jpiglo) - nimpp + 1                  ! right position of the box
@@ -234,19 +236,21 @@
       END DO
       CALL lbc_lnk( 'lib_fortran', p3d, 'T', 1.0_wp )
-      ! no need for 2nd exchange when nn_hls = 2
-      IF( nn_hls /= 2 ) THEN
-         IF( nbondi /= -1 ) THEN
-            IF( MOD(mig(    1), 3) == 1 )   p3d(    1,:,:) = p3d(    2,:,:)
-            IF( MOD(mig(    1), 3) == 2 )   p3d(    2,:,:) = p3d(    1,:,:)
-         ENDIF
-         IF( nbondi /=  1 ) THEN
+      ! no need for 2nd exchange when nn_hls > 1
+      IF( nn_hls == 1 ) THEN
+         IF( mpiRnei(nn_hls,jpwe) > -1 ) THEN    ! 1st column was changed during the previous call to lbc_lnk
+            IF( MOD(mig(    1), 3) == 1 )   &    ! 1st box start at i=1 -> column 1 to 3 correctly computed locally
+               p3d(    1,:,:) = p3d(    2,:,:)   ! previous lbc_lnk corrupted column 1 -> put it back using column 2 
+            IF( MOD(mig(    1), 3) == 2 )   &    ! 1st box start at i=3 -> column 1 and 2 correctly computed on west neighbourh
+               p3d(    2,:,:) = p3d(    1,:,:)   !  previous lbc_lnk fix column 1 -> copy it to column 2 
+         ENDIF
+         IF( mpiRnei(nn_hls,jpea) > -1 ) THEN
             IF( MOD(mig(jpi-2), 3) == 1 )   p3d(  jpi,:,:) = p3d(jpi-1,:,:)
             IF( MOD(mig(jpi-2), 3) == 0 )   p3d(jpi-1,:,:) = p3d(  jpi,:,:)
          ENDIF
-         IF( nbondj /= -1 ) THEN
+         IF( mpiRnei(nn_hls,jpso) > -1 ) THEN
             IF( MOD(mjg(    1), 3) == 1 )   p3d(:,    1,:) = p3d(:,    2,:)
             IF( MOD(mjg(    1), 3) == 2 )   p3d(:,    2,:) = p3d(:,    1,:)
          ENDIF
-         IF( nbondj /=  1 ) THEN
+         IF( mpiRnei(nn_hls,jpno) > -1 ) THEN
             IF( MOD(mjg(jpj-2), 3) == 1 )   p3d(:,  jpj,:) = p3d(:,jpj-1,:)
             IF( MOD(mjg(jpj-2), 3) == 0 )   p3d(:,jpj-1,:) = p3d(:,  jpj,:)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/module_example.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/module_example.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/module_example.F90	(revision 14644)
@@ -127,7 +127,5 @@
       ! WARNING! the lbc_lnk call could not be compatible with the tiling approach
       ! please refer to the manual for how to adapt your code
-      CALL lbc_lnk( 'module_example', avm, 'T', 1., ncsten=true )     ! Lateral boundary conditions (unchanged sign)
-      !                                                                ! ncsten=false for 5-points stencil communication
-      !                                                                ! ncsten=true (default)  for 9-points stencil communication
+      CALL lbc_lnk( 'module_example', avm, 'T', 1. )     ! Lateral boundary conditions (unchanged sign)
       !
    END SUBROUTINE exa_mpl
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/nemogcm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/nemogcm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/nemogcm.F90	(revision 14644)
@@ -87,5 +87,5 @@
    CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    ! need MPI_Wtime
    INCLUDE 'mpif.h'
@@ -233,5 +233,5 @@
       CALL nemo_closefile
       !
-#if defined key_iomput
+#if defined key_xios
                                     CALL xios_finalize  ! end mpp communications with xios
       IF( lk_oasis     )            CALL cpl_finalize   ! end coupling and mpp communications with OASIS
@@ -271,5 +271,5 @@
       !                             !-------------------------------------------------!
       !
-#if defined key_iomput
+#if defined key_xios
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
@@ -378,7 +378,7 @@
       !
       IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
-         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ELSE                              ! user-defined namelist
-         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ENDIF
       !
@@ -589,5 +589,5 @@
       !!                     ***  ROUTINE nemo_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!
       !! ** Method  :
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/par_kind.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/par_kind.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/par_kind.F90	(revision 14644)
@@ -10,7 +10,4 @@
    IMPLICIT NONE
    PRIVATE
-
-   INTEGER, PUBLIC, PARAMETER ::   jpbyt   = 8    !: real size for mpp communications
-   INTEGER, PUBLIC, PARAMETER ::   jpbytda = 4    !: real size in input data files 4 or 8
 
    ! Number model from which the SELECTED_*_KIND are requested:
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/par_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/par_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/par_oce.F90	(revision 14644)
@@ -91,11 +91,11 @@
 
    ! halo with and starting/inding DO-loop indices
-   INTEGER, PUBLIC ::   nn_hls   !: halo width (applies to both rows and columns)
-   INTEGER, PUBLIC ::   Nis0, Nis1, Nis1nxt2, Nis2   !: start I-index (_0: without halo, _1 or _2: with 1 or 2 halos)
-   INTEGER, PUBLIC ::   Nie0, Nie1, Nie1nxt2, Nie2   !: end   I-index (_0: without halo, _1 or _2: with 1 or 2 halos)
-   INTEGER, PUBLIC ::   Njs0, Njs1, Njs1nxt2, Njs2   !: start J-index (_0: without halo, _1 or _2: with 1 or 2 halos)
-   INTEGER, PUBLIC ::   Nje0, Nje1, Nje1nxt2, Nje2   !: end   J-index (_0: without halo, _1 or _2: with 1 or 2 halos)
-   INTEGER, PUBLIC ::   Ni_0, Nj_0, Ni_1, Nj_1, Ni_2, Nj_2   !: domain size (_0: without halo, _1 or _2: with 1 or 2 halos)
-   INTEGER, PUBLIC ::   Ni0glo, Nj0glo
+   INTEGER, PUBLIC ::   nn_hls           !: halo width (applies to both rows and columns)
+   INTEGER, PUBLIC ::   Nis0             !: start I-index without halo
+   INTEGER, PUBLIC ::   Nie0             !: end   I-index without halo
+   INTEGER, PUBLIC ::   Njs0             !: start J-index without halo
+   INTEGER, PUBLIC ::   Nje0             !: end   J-index without halo
+   INTEGER, PUBLIC ::   Ni_0, Nj_0       !: local domain size without halo
+   INTEGER, PUBLIC ::   Ni0glo, Nj0glo   !: global domain size without halo
 
    !!----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step.F90	(revision 14644)
@@ -33,4 +33,5 @@
    !!            4.1  !  2019-08  (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme
    !!----------------------------------------------------------------------
+
 #if defined key_qco   ||   defined key_linssh
    !!----------------------------------------------------------------------
@@ -41,5 +42,5 @@
 #else
    !!----------------------------------------------------------------------
-   !!   stp             : OPA system time-stepping
+   !!   stp             : OCE system time-stepping
    !!----------------------------------------------------------------------
    USE step_oce         ! time stepping definition modules
@@ -50,13 +51,10 @@
    PUBLIC   stp   ! called by nemogcm.F90
 
-   !!----------------------------------------------------------------------
-   !! time level indices
-   !!----------------------------------------------------------------------
-   INTEGER, PUBLIC :: Nbb, Nnn, Naa, Nrhs          !! used by nemo_init
+   !                                          !**  time level indices  **!
+   INTEGER, PUBLIC ::   Nbb, Nnn, Naa, Nrhs   !: used by nemo_init
 
    !! * Substitutions
 #  include "do_loop_substitute.h90"
 #  include "single_precision_substitute.h90"
-
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -76,5 +74,5 @@
       !!                     ***  ROUTINE stp  ***
       !!
-      !! ** Purpose : - Time stepping of OPA  (momentum and active tracer eqs.)
+      !! ** Purpose : - Time stepping of OCE  (momentum and active tracer eqs.)
       !!              - Time stepping of SI3 (dynamic and thermodynamic eqs.)
       !!              - Time stepping of TRC  (passive tracer eqs.)
@@ -90,6 +88,4 @@
       !!----------------------------------------------------------------------
       INTEGER ::   ji, jj, jk, jtile   ! dummy loop indice
-!!gm kcall can be removed, I guess
-      INTEGER ::   kcall        ! optional integer argument (dom_vvl_sf_nxt)
       !! ---------------------------------------------------------------------
 #if defined key_agrif
@@ -102,5 +98,5 @@
       ENDIF
       IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
-# if defined key_iomput
+# if defined key_xios
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
 # endif
@@ -113,7 +109,6 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !
-      IF( l_1st_euler ) THEN
-         ! start or restart with Euler 1st time-step
-         rDt =  rn_Dt
+      IF( l_1st_euler ) THEN     ! start or restart with Euler 1st time-step
+         rDt   = rn_Dt   
          r1_Dt = 1._wp / rDt
       ENDIF
@@ -122,4 +117,5 @@
       ! update I/O and calendar
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
       IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS)
                              CALL iom_init( cxios_context, ld_closedef=.FALSE. )   ! for model grid (including possible AGRIF zoom)
@@ -128,21 +124,26 @@
          IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid
       ENDIF
-      IF((kstp == nitrst) .AND. lwxios) THEN
-         CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_init_closedef(cw_ocerst_cxt)
-         CALL iom_setkt( kstp - nit000 + 1,      cw_ocerst_cxt          )
+      IF( kstp == nitrst .AND. lwxios ) THEN
+                             CALL iom_swap(                     cw_ocerst_cxt )
+                             CALL iom_init_closedef(            cw_ocerst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_ocerst_cxt )
 #if defined key_top
-         CALL iom_swap(      cw_toprst_cxt          )
-         CALL iom_init_closedef(cw_toprst_cxt)
-         CALL iom_setkt( kstp - nit000 + 1,      cw_toprst_cxt          )
-#endif
-      ENDIF
+                             CALL iom_swap(                     cw_toprst_cxt )
+                             CALL iom_init_closedef(            cw_toprst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_toprst_cxt )
+#endif
+      ENDIF
+      IF( kstp + nn_fsbc - 1 == nitrst .AND. lwxios ) THEN
 #if defined key_si3
-      IF(((kstp + nn_fsbc - 1) == nitrst) .AND. lwxios) THEN
-         CALL iom_swap(      cw_icerst_cxt          )
-         CALL iom_init_closedef(cw_icerst_cxt)
-         CALL iom_setkt( kstp - nit000 + 1,      cw_icerst_cxt          )
-      ENDIF
-#endif
+                             CALL iom_swap(                     cw_icerst_cxt )
+                             CALL iom_init_closedef(            cw_icerst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_icerst_cxt )
+#endif
+         IF( ln_abl      ) THEN
+                             CALL iom_swap(                     cw_ablrst_cxt )
+                             CALL iom_init_closedef(            cw_ablrst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_ablrst_cxt )
+         ENDIF
+      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
@@ -161,6 +162,6 @@
       ! 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( ts(:,:,:,:,Nnn)  )          ! Random T/S fluctuations
+      IF( ln_sto_eos )   CALL sto_par( kstp )                         ! Stochastic parameters
+      IF( ln_sto_eos )   CALL sto_pts( ts(:,:,:,:,Nnn)  )             ! Random T/S fluctuations
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -202,9 +203,10 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-                            CALL ssh_nxt       ( kstp, Nbb, Nnn, ssh, Naa )    ! after ssh (includes call to div_hor)
-      IF( .NOT.ln_linssh )  CALL dom_vvl_sf_nxt( kstp, Nbb, Nnn,      Naa )    ! after vertical scale factors
-                            CALL wzv           ( kstp, Nbb, Nnn, Naa, ww  )    ! now cross-level velocity
-      IF( ln_zad_Aimp )     CALL wAimp         ( kstp,      Nnn           )  ! Adaptive-implicit vertical advection partitioning
-                            CALL eos    ( CASTWP(ts(:,:,:,:,Nnn)), rhd, rhop, CASTWP(gdept(:,:,:,Nnn)) )  ! now in situ density for hpg computation
+                         CALL ssh_nxt       ( kstp, Nbb, Nnn, ssh, Naa )   ! after ssh (includes call to div_hor)
+      IF( .NOT.ln_linssh )   &
+                       & CALL dom_vvl_sf_nxt( kstp, Nbb, Nnn,      Naa )   ! after vertical scale factors
+                         CALL wzv           ( kstp, Nbb, Nnn, Naa, ww  )   ! now cross-level velocity
+      IF( ln_zad_Aimp )  CALL wAimp         ( kstp,      Nnn           )   ! Adaptive-implicit vertical advection partitioning
+                         CALL eos    ( ts(:,:,:,:,Nnn), rhd, rhop, gdept(:,:,:,Nnn) )  ! now in situ density for hpg computation
 
 
@@ -233,5 +235,5 @@
                             CALL dyn_zdf    ( kstp, Nbb, Nnn, Nrhs, uu, vv, Naa  )  ! vertical diffusion
       IF( ln_dynspg_ts ) THEN                                                       ! vertical scale factors and vertical velocity need to be updated
-                            CALL wzv        ( kstp, Nbb, Nnn, Naa, ww )             ! now cross-level velocity
+                            CALL wzv        ( kstp, Nbb, Nnn, Naa, ww )             ! Nnn cross-level velocity
          IF( ln_zad_Aimp )  CALL wAimp      ( kstp,      Nnn )                      ! Adaptive-implicit vertical advection partitioning
       ENDIF
@@ -261,5 +263,5 @@
       ! Passive Tracer Model
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL trc_stp       ( kstp, Nbb, Nnn, Nrhs, Naa )  ! time-stepping
+                         CALL trc_stp    ( kstp, Nbb, Nnn, Nrhs, Naa )           ! time-stepping
 #endif
 
@@ -269,8 +271,8 @@
       ! Loop over tile domains
       DO jtile = 1, nijtile
-         IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )
+         IF( ln_tile    )   CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )
 
          DO_3D( 0, 0, 0, 0, 1, jpk )
-            ts(ji,jj,jk,:,Nrhs) = 0._wp                                         ! set tracer trends to zero
+            ts(ji,jj,jk,:,Nrhs) = 0._wp                                   ! set tracer trends to zero
          END_3D
 
@@ -287,19 +289,20 @@
 
 #if defined key_agrif
-         IF(.NOT. Agrif_Root()) THEN
-            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )
-            CALL Agrif_Sponge_tra        ! tracers sponge
-         ENDIF
+      IF(.NOT. Agrif_Root() )   THEN
+         IF( ln_tile    )   CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )
+                            CALL Agrif_Sponge_tra        ! tracers sponge
+      ENDIF
 #endif
 
       ! TEMP: [tiling] Separate loop over tile domains (due to tra_adv workarounds for tiling)
       DO jtile = 1, nijtile
-         IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )
+         IF( ln_tile    )   CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )
 
                             CALL tra_adv    ( kstp, Nbb, Nnn, ts, Nrhs )  ! hor. + vert. advection	==> RHS
          IF( ln_zdfmfc  )   CALL tra_mfc    ( kstp, Nbb,      ts, Nrhs )  ! Mass Flux Convection
-         IF( ln_zdfosm  )   CALL tra_osm    ( kstp,      Nnn, ts, Nrhs )  ! OSMOSIS non-local tracer fluxes ==> RHS
-         IF( lrst_oce .AND. ln_zdfosm ) &
-              &             CALL osm_rst    ( kstp,      Nnn, 'WRITE'  )  ! write OSMOSIS outputs + ww (so must do here) to restarts
+         IF( ln_zdfosm  ) THEN
+                            CALL tra_osm    ( kstp,      Nnn, ts, Nrhs )  ! OSMOSIS non-local tracer fluxes ==> RHS
+            IF( lrst_oce )  CALL osm_rst    ( kstp,      Nnn, 'WRITE'  )  ! write OSMOSIS outputs + ww (so must do here) to restarts
+         ENDIF
                             CALL tra_ldf    ( kstp, Nbb, Nnn, ts, Nrhs )  ! lateral mixing
 
@@ -365,10 +368,10 @@
       ! AGRIF update
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( Agrif_NbStepint() == 0 .AND. nstop == 0 ) THEN
-                         CALL Agrif_update_all( )                  ! Update all components
-      ENDIF
-
-#endif
-      IF( ln_diaobs .AND. nstop == 0 )  CALL dia_obs( kstp, Nnn )  ! obs-minus-model (assimilation) diags (after dynamics update)
+      IF( Agrif_NbStepint() == 0 .AND. nstop == 0 )   &
+         &               CALL Agrif_update_all( )                  ! Update all components
+
+#endif
+      IF( ln_diaobs .AND. nstop == 0 )   &
+         &               CALL dia_obs( kstp, Nnn )  ! obs-minus-model (assimilation) diags (after dynamics update)
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -377,5 +380,5 @@
       IF( kstp == nit000 ) THEN                          ! 1st time step only
                                         CALL iom_close( numror )   ! close input  ocean restart file
-         IF( lrxios )                   CALL iom_context_finalize(      cr_ocerst_cxt         )
+         IF( lrxios )                   CALL iom_context_finalize( cr_ocerst_cxt )
          IF(lwm)                        CALL FLUSH    ( numond )   ! flush output namelist oce
          IF(lwm .AND. numoni /= -1 )    CALL FLUSH    ( numoni )   ! flush output namelist ice (if exist)
@@ -387,5 +390,5 @@
       IF( lk_oasis .AND. nstop == 0 )   CALL sbc_cpl_snd( kstp, Nbb, Nnn )     ! coupled mode : field exchanges
       !
-#if defined key_iomput
+#if defined key_xios
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Finalize contextes if end of simulation or error detected
@@ -398,5 +401,5 @@
       !
       IF( l_1st_euler ) THEN         ! recover Leap-frog timestep
-         rDt = 2._wp * rn_Dt
+         rDt   = 2._wp * rn_Dt
          r1_Dt = 1._wp / rDt
          l_1st_euler = .FALSE.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step_oce.F90	(revision 14644)
@@ -104,5 +104,5 @@
    USE timing          ! Timing
 
-#if defined key_iomput
+#if defined key_xios
    USE xios            ! I/O server
 #endif
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpctl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpctl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpctl.F90	(revision 14644)
@@ -15,5 +15,4 @@
    !!----------------------------------------------------------------------
    !!   stp_ctl      : Control the run
-   !!   stp_ctl_SWE  : Control the run (SWE only)
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers variables
@@ -34,9 +33,8 @@
 
    PUBLIC stp_ctl           ! routine called by step.F90
-   PUBLIC stp_ctl_SWE       ! routine called by stpmlf.F90
-
-   INTEGER                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(8)  ::   nvarid   ! netcdf variable id
-   INTEGER, DIMENSION(2)  ::   nvarid_SWE   ! netcdf variable id (SWE only)
+
+   INTEGER, PARAMETER         ::   jpvar = 8
+   INTEGER                    ::   nrunid   ! netcdf file id
+   INTEGER, DIMENSION(jpvar)  ::   nvarid   ! netcdf variable id
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -49,5 +47,5 @@
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE stp_ctl  ***
-      !!                     
+      !!
       !! ** Purpose :   Control the run
       !!
@@ -65,11 +63,12 @@
       INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index
       !!
+      INTEGER, PARAMETER              ::   jptst = 4
       INTEGER                         ::   ji                                    ! dummy loop indices
       INTEGER                         ::   idtime, istatus
-      INTEGER , DIMENSION(9)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
+      INTEGER , DIMENSION(jptst)      ::   iareasum, iareamin, iareamax
+      INTEGER , DIMENSION(3,jptst)    ::   iloc                                  ! min/max loc indices
       REAL(dp)                        ::   zzz, zminsal, zmaxsal                 ! local real 
-      REAL(dp), DIMENSION(9)          :: zmax
-      REAL(wp), DIMENSION(9)          :: zmaxlocal
+      REAL(dp), DIMENSION(jpvar+1)    ::   zmax
+      REAL(wp), DIMENSION(jptst)      ::   zmaxlocal
       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
       LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk
@@ -79,5 +78,5 @@
       !
       ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
-      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 
+      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1
       ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm
       !
@@ -112,5 +111,5 @@
             istatus = NF90_ENDDEF(nrunid)
          ENDIF
-         !    
+         !
       ENDIF
       !
@@ -124,8 +123,8 @@
       !                                   !==  done by all processes at every time step  ==!
       !
-      llmsk(   1:Nis1,:,:) = .FALSE.                                              ! exclude halos from the checked region
-      llmsk(Nie1: jpi,:,:) = .FALSE.
-      llmsk(:,   1:Njs1,:) = .FALSE.
-      llmsk(:,Nje1: jpj,:) = .FALSE.
+      llmsk(     1:nn_hls,:,:) = .FALSE.                                          ! exclude halos from the checked region
+      llmsk(Nie0+1:   jpi,:,:) = .FALSE.
+      llmsk(:,     1:nn_hls,:) = .FALSE.
+      llmsk(:,Nje0+1:   jpj,:) = .FALSE.
       !
       llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0) == 1._wp         ! define only the inner domain
@@ -156,29 +155,26 @@
          zmax(5:8) = 0._wp
       ENDIF
-      zmax(9) = REAL( nstop, wp )                                                 ! stop indicator
+      zmax(jpvar+1) = REAL( nstop, wp )                                           ! stop indicator
       !
       !                                   !==               get global extrema             ==!
       !                                   !==  done by all processes if writting run.stat  ==!
       IF( ll_colruns ) THEN
-         zmaxlocal(:) = zmax(:)
+         zmaxlocal(:) = zmax(1:jptst)
          CALL mpp_max( "stpctl", zmax )          ! max over the global domain: ok even of ll_0oce = .true. 
-         nstop = NINT( zmax(9) )                 ! update nstop indicator (now sheared among all local domains)
+         nstop = NINT( zmax(jpvar+1) )           ! update nstop indicator (now sheared among all local domains)
       ELSE
          ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow.
-         IF( ll_0oce )   zmax(1:4) = (/ 0._wp, 0._wp, -1._wp, 1._wp /)   ! default "valid" values...
-      ENDIF
-      !
-      zmax(3) = -zmax(3)                         ! move back from max(-zz) to min(zz) : easier to manage! 
-      zmax(5) = -zmax(5)                         ! move back from max(-zz) to min(zz) : easier to manage!
-      IF( ll_colruns ) THEN
-         zmaxlocal(3) = -zmaxlocal(3)            ! move back from max(-zz) to min(zz) : easier to manage! 
-         zmaxlocal(5) = -zmaxlocal(5)            ! move back from max(-zz) to min(zz) : easier to manage!
-      ENDIF
+         IF( ll_0oce )   zmax(1:jptst) = (/ 0._wp, 0._wp, -1._wp, 1._wp /)   ! default "valid" values...
+      ENDIF
+      !
+      zmax(3) = -zmax(3)                              ! move back from max(-zz) to min(zz) : easier to manage! 
+      zmax(5) = -zmax(5)                              ! move back from max(-zz) to min(zz) : easier to manage!
+      IF( ll_colruns ) zmaxlocal(3) = -zmaxlocal(3)   ! move back from max(-zz) to min(zz) : easier to manage!
       !
       !                                   !==              write "run.stat" files              ==!
       !                                   !==  done only by 1st subdomain at writting timestep  ==!
       IF( ll_wrtruns ) THEN
-         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3), zmax(4)
-         DO ji = 1, 6 + 2 * COUNT( (/ln_zad_Aimp/) )
+         WRITE(numrun,9500) kt, zmax(1:jptst)
+         DO ji = 1, jpvar - 2 * COUNT( .NOT. (/ln_zad_Aimp/) )
             istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
          END DO
@@ -189,6 +185,6 @@
       !
       IF ( ln_SEOS.AND.(rn_b0==0._wp) ) THEN             ! Discard checks on salinity
-         zmaxsal = +HUGE(1._dp)                                ! if not used in eos
-         zminsal = -HUGE(1._dp) 
+         zmaxsal =  HUGE(1._dp)                               ! if not used in eos
+         zminsal = -HUGE(1._dp)
       ELSE
          zmaxsal = 100._wp
@@ -196,11 +192,11 @@
       ENDIF 
       ! 
-      IF(  zmax(1) >   20._wp .OR.   &                   ! too large sea surface height ( > 20 m )
-         & zmax(2) >   10._wp .OR.   &                   ! too large velocity ( > 10 m/s)
-         & zmax(3) <= zminsal .OR.   &                   ! negative or zero sea surface salinity
-         & zmax(4) >= zmaxsal .OR.   &                   ! too large sea surface salinity ( > 100 )
-         & zmax(4) <  zminsal .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice)
-         & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests
-         & ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
+      IF(  zmax(1) >   20._wp .OR.   &                        ! too large sea surface height ( > 20 m )
+         & zmax(2) >   10._wp .OR.   &                        ! too large velocity ( > 10 m/s)
+         & zmax(3) <= zminsal .OR.   &                        ! negative or zero sea surface salinity
+         & zmax(4) >= zmaxsal .OR.   &                        ! too large sea surface salinity ( > 100 )
+         & zmax(4) <  zminsal .OR.   &                        ! too large sea surface salinity (keep this line for sea-ice)
+         & ISNAN( SUM(zmax(1:jptst)) ) .OR.   &               ! NaN encounter in the tests
+         & ABS(   SUM(zmax(1:jptst)) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
          !
          iloc(:,:) = 0
@@ -218,5 +214,5 @@
             ! find which subdomain has the max.
             iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 9
+            DO ji = 1, jptst
                IF( zmaxlocal(ji) == zmax(ji) ) THEN
                   iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1
@@ -235,5 +231,5 @@
             iloc(1:3,3) = MINLOC(       ts(:,:,:,jp_sal,Kmm) , mask = llmsk(:,:,:) )
             iloc(1:3,4) = MAXLOC(       ts(:,:,:,jp_sal,Kmm) , mask = llmsk(:,:,:) )
-            DO ji = 1, 4   ! local domain indices ==> global domain indices, excluding halos
+            DO ji = 1, jptst   ! local domain indices ==> global domain indices, excluding halos
                iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /)
             END DO
@@ -254,5 +250,5 @@
          CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file
          !
-         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
+         IF( ll_colruns .OR. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
             IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 )
             ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
@@ -272,181 +268,4 @@
       !
    END SUBROUTINE stp_ctl
-
-
-   SUBROUTINE stp_ctl_SWE( kt, Kmm )
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE stp_ctl_SWE  ***
-      !!                     
-      !! ** Purpose :   Control the run
-      !!
-      !! ** Method  : - Save the time step in numstp
-      !!              - Print it each 50 time steps
-      !!              - Stop the run IF problem encountered by setting nstop > 0
-      !!                Problems checked: e3t0+ssh minimum smaller that 0
-      !!                                  |U|   maximum larger than 10 m/s 
-      !!                                  ( not for SWE : negative sea surface salinity )
-      !!
-      !! ** Actions :   "time.step" file = last ocean time-step
-      !!                "run.stat"  file = run statistics
-      !!                 nstop indicator sheared among all local domain
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index
-      !!
-      INTEGER                         ::   ji                                    ! dummy loop indices
-      INTEGER                         ::   idtime, istatus
-      INTEGER , DIMENSION(3)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
-      REAL(dp)                        ::   zzz                                   ! local real 
-      REAL(dp), DIMENSION(3)          ::   zmax, zmaxlocal
-      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
-      LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk
-      CHARACTER(len=20)               ::   clname
-      !!----------------------------------------------------------------------
-      !
-      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid
-      !
-      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
-      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 
-      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm
-      !
-      IF( kt == nit000 ) THEN
-         !
-         IF( lwp ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'stp_ctl_SWE : time-stepping control'
-            WRITE(numout,*) '~~~~~~~~~~~'
-         ENDIF
-         !                                ! open time.step    ascii file, done only by 1st subdomain
-         IF( lwm )   CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-         !
-         IF( ll_wrtruns ) THEN
-            !                             ! open run.stat     ascii file, done only by 1st subdomain
-            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-            !                             ! open run.stat.nc netcdf file, done only by 1st subdomain
-            clname = 'run.stat.nc'
-            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
-            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid )
-            istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime )
-            istatus = NF90_DEF_VAR( nrunid, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), nvarid_SWE(1) )
-            istatus = NF90_DEF_VAR( nrunid,   'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid_SWE(2) )
-            istatus = NF90_ENDDEF(nrunid)
-         ENDIF
-         !    
-      ENDIF
-      !
-      !                                   !==              write current time step              ==!
-      !                                   !==  done only by 1st subdomain at writting timestep  ==!
-      IF( lwm .AND. ll_wrtstp ) THEN
-         WRITE ( numstp, '(1x, i8)' )   kt
-         REWIND( numstp )
-      ENDIF
-      !                                   !==            test of local extrema           ==!
-      !                                   !==  done by all processes at every time step  ==!
-      !
-      llmsk(   1:Nis1,:,:) = .FALSE.                                              ! exclude halos from the checked region
-      llmsk(Nie1: jpi,:,:) = .FALSE.
-      llmsk(:,   1:Njs1,:) = .FALSE.
-      llmsk(:,Nje1: jpj,:) = .FALSE.
-      !
-      llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0) == 1._wp         ! define only the inner domain
-      !
-      ll_0oce = .NOT. ANY( llmsk(:,:,1) )                                         ! no ocean point in the inner domain?
-      !
-      zmax(1) = MINVAL( -e3t_0(:,:,1)-ssh(:,:,Kmm)  , mask = llmsk(:,:,1)  )       ! e3t_Kmm min
-      !
-      llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) )      , mask = llmsk(:,:,:) )        ! velocity max (zonal only)
-      zmax(3) = REAL( nstop , wp )                                                ! stop indicator
-
-      !                                   !==               get global extrema             ==!
-      !                                   !==  done by all processes if writting run.stat  ==!
-      IF( ll_colruns ) THEN
-         zmaxlocal(:) = zmax(:)
-         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
-         nstop = NINT( zmax(3) )                 ! update nstop indicator (now sheared among all local domains)
-      ELSE
-         ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow.
-         IF( ll_0oce )   zmax(1:4) = (/ 0._wp, 0._wp, -1._wp, 1._wp /)   ! default "valid" values...
-      ENDIF
-      !
-      zmax(1) = -zmax(1)                         ! move back from max(-zz) to min(zz) : easier to manage!
-      !
-      !                                   !==              write "run.stat" files              ==!
-      !                                   !==  done only by 1st subdomain at writting timestep  ==!
-      IF( ll_wrtruns ) THEN
-         WRITE(numrun,9500) kt, zmax(1), zmax(2)
-         istatus = NF90_PUT_VAR( nrunid, nvarid_SWE(1), (/ zmax(1)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid_SWE(2), (/ zmax(2)/), (/kt/), (/1/) )
-         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
-      ENDIF
-      !                                   !==               error handling               ==!
-      !                                   !==  done by all processes at every time step  ==!
-      !
-!!SWE specific : start
-      IF(   zmax(1) <=   0._wp .OR.           &               ! negative e3t_Kmm
-         &  zmax(2) >   10._wp .OR.           &               ! too large velocity ( > 10 m/s)
-         &  ISNAN( zmax(1) + zmax(2) ) .OR.   &               ! NaN encounter in the tests
-         &  ABS(   zmax(1) + zmax(2) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
-         !
-         iloc(:,:) = 0
-         IF( ll_colruns ) THEN   ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc
-            ! first: close the netcdf file, so we can read it
-            IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid)
-            ! get global loc on the min/max
-            llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp         ! define only the inner domain
-            CALL mpp_minloc( 'stpctl', e3t_0(:,:,1) + ssh(:,:,Kmm), llmsk(:,:,1), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F
-            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-            CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,Kmm))        , llmsk(:,:,:), zzz, iloc(1:3,2) )
-            ! find which subdomain has the max.
-            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 3
-               IF( zmaxlocal(ji) == zmax(ji) ) THEN
-                  iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1
-               ENDIF
-            END DO
-            CALL mpp_min( "stpctl", iareamin )         ! min over the global domain
-            CALL mpp_max( "stpctl", iareamax )         ! max over the global domain
-            CALL mpp_sum( "stpctl", iareasum )         ! sum over the global domain
-         ELSE                    ! find local min and max locations:
-            ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc
-            llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp        ! define only the inner domain
-            iloc(1:2,1) = MINLOC( e3t_0(:,:,1) + ssh(:,:,Kmm), mask = llmsk(:,:,1) )
-            !
-            llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-            iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask = llmsk(:,:,:) )
-            iareamin(:) = narea   ;   iareamax(:) = narea   ;   iareasum(:) = 1         ! this is local information
-         ENDIF
-         !
-         WRITE(ctmp1,*) ' stp_ctl_SWE:  e3t0+ssh < 0 m  or  |U| > 10 m/s  or  NaN encounter in the tests'
-         CALL wrt_line( ctmp2, kt, 'e3t0+ssh min',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) )
-         CALL wrt_line( ctmp3, kt, '|U|   max'   ,  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) )
-         IF( Agrif_Root() ) THEN
-            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files'
-         ELSE
-            WRITE(ctmp6,*) '      ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files'
-         ENDIF
-         !
-         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file
-         !
-         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
-            IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ' ', ctmp6 )
-            ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
-            ENDIF
-         ELSE                                    ! only mpi subdomains with errors are here -> STOP now
-            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ' ', ctmp6 )
-         ENDIF
-         !
-      ENDIF
-!!SWE specific : end
-      !
-      IF( nstop > 0 ) THEN                                                  ! an error was detected and we did not abort yet...
-         ngrdstop = Agrif_Fixed()                                           ! store which grid got this error
-         IF( .NOT. ll_colruns .AND. jpnij > 1 )   CALL ctl_stop( 'STOP' )   ! we must abort here to avoid MPI deadlock
-      ENDIF
-      !
-9500  FORMAT(' it :', i8, '      e3t_min: ', D23.16, ' |U|_max: ', D23.16)
-      !
-   END SUBROUTINE stp_ctl_SWE
 
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpmlf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpmlf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpmlf.F90	(revision 14644)
@@ -35,5 +35,4 @@
    !!            4.x  !  2020-08  (S. Techene, G. Madec)  quasi eulerian coordinate time stepping
    !!----------------------------------------------------------------------
-
 #if defined key_qco   ||   defined key_linssh
    !!----------------------------------------------------------------------
@@ -42,5 +41,5 @@
    !!   'key_linssh                       Fixed in time vertical coordinate
    !!----------------------------------------------------------------------
-
+   !!
    !!----------------------------------------------------------------------
    !!   stp_MLF       : NEMO modified Leap Frog time-stepping with qco or linssh
@@ -49,16 +48,10 @@
    !
    USE domqco         ! quasi-eulerian coordinate
-   USE traatf_qco     ! time filtering                   (tra_atf_qco routine)
-   USE dynatf_qco     ! time filtering                   (dyn_atf_qco routine)
-   
-   USE bdydyn         ! ocean open boundary conditions (define bdy_dyn)
-
-#if defined key_agrif
-   USE agrif_oce_interp
-#endif
+   USE traatf_qco     ! time filtering                 (tra_atf_qco routine)
+   USE dynatf_qco     ! time filtering                 (dyn_atf_qco routine)
 
    IMPLICIT NONE
    PRIVATE
-   
+
    PUBLIC   stp_MLF   ! called by nemogcm.F90
 
@@ -67,6 +60,8 @@
 
    !! * Substitutions
+#  include "do_loop_substitute.h90"
 #  include "domzgr_substitute.h90"
 #  include "single_precision_substitute.h90"
+#  include "do_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -86,5 +81,5 @@
       !!                     ***  ROUTINE stp_MLF  ***
       !!
-      !! ** Purpose : - Time stepping of OPA  (momentum and active tracer eqs.)
+      !! ** Purpose : - Time stepping of OCE  (momentum and active tracer eqs.)
       !!              - Time stepping of SI3 (dynamic and thermodynamic eqs.)
       !!              - Time stepping of TRC  (passive tracer eqs.)
@@ -99,10 +94,9 @@
       !!              -8- Outputs and diagnostics
       !!----------------------------------------------------------------------
-      INTEGER ::   ji, jj, jk   ! dummy loop indice
-      INTEGER ::   indic        ! error indicator if < 0
-      REAL(wp),              DIMENSION(jpi,jpj,jpk) ::   zgdept
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:)         ::   zssh_f
+      INTEGER ::   ji, jj, jk, jtile   ! dummy loop indice
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   zgdept
       !! ---------------------------------------------------------------------
 #if defined key_agrif
+      IF( nstop > 0 ) RETURN   ! avoid to go further if an error was detected during previous time step (child grid)
       kstp = nit000 + Agrif_Nb_Step()
       Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
@@ -112,5 +106,5 @@
       ENDIF
       IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
-# if defined key_iomput
+# if defined key_xios
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
 # endif
@@ -131,11 +125,32 @@
       ! 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, ld_closedef=.FALSE. )   ! for model grid (including passible AGRIF zoom)
+                             CALL iom_init( cxios_context, ld_closedef=.FALSE. )   ! for model grid (including possible AGRIF zoom)
          IF( lk_diamlr   )   CALL dia_mlr_iom_init    ! with additional setup for multiple-linear-regression analysis
                              CALL iom_init_closedef
          IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid
+      ENDIF
+      IF( kstp == nitrst .AND. lwxios ) THEN
+                             CALL iom_swap(                     cw_ocerst_cxt )
+                             CALL iom_init_closedef(            cw_ocerst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_ocerst_cxt )
+#if defined key_top
+                             CALL iom_swap(                     cw_toprst_cxt )
+                             CALL iom_init_closedef(            cw_toprst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_toprst_cxt )
+#endif
+      ENDIF
+      IF( kstp + nn_fsbc - 1 == nitrst .AND. lwxios ) THEN
+#if defined key_si3
+                             CALL iom_swap(                     cw_icerst_cxt )
+                             CALL iom_init_closedef(            cw_icerst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_icerst_cxt )
+#endif
+         IF( ln_abl      ) THEN
+                             CALL iom_swap(                     cw_ablrst_cxt )
+                             CALL iom_init_closedef(            cw_ablrst_cxt )
+                             CALL iom_setkt( kstp - nit000 + 1, cw_ablrst_cxt )
+         ENDIF
       ENDIF
       IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
@@ -155,6 +170,6 @@
       ! 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( ts(:,:,:,:,Nnn)  )          ! Random T/S fluctuations
+      IF( ln_sto_eos )   CALL sto_par( kstp )                         ! Stochastic parameters
+      IF( ln_sto_eos )   CALL sto_pts( ts(:,:,:,:,Nnn)  )             ! Random T/S fluctuations
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -195,16 +210,19 @@
       !  Ocean dynamics : hdiv, ssh, e3, u, v, w
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      DO jk = 1, jpk
-         zgdept(:,:,jk) = gdept(:,:,jk,Nnn)
-      END DO
-                            CALL ssh_nxt    ( kstp, Nbb, Nnn, ssh,  Naa )   ! after ssh (includes call to div_hor)
-      IF( .NOT.lk_linssh )  THEN
-                             CALL dom_qco_r3c( CASTWP(ssh(:,:,Naa)), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa)           )   ! "after" ssh/h_0 ratio at t,u,v pts
-         IF( ln_dynspg_exp ) CALL dom_qco_r3c( CASTWP(ssh(:,:,Nnn)), r3t(:,:,Nnn), r3u(:,:,Nnn), r3v(:,:,Nnn), r3f(:,:) )   ! spg_exp : needed only for "now" ssh/h_0 ratio at f point
-      ENDIF
-                            CALL wzv        ( kstp, Nbb, Nnn, Naa, ww  )    ! Nnn cross-level velocity
-      IF( ln_zad_Aimp )     CALL wAimp      ( kstp,      Nnn           )    ! Adaptive-implicit vertical advection partitioning
-                            CALL eos        ( CASTWP(ts(:,:,:,:,Nnn)), rhd, rhop, zgdept ) ! now in situ density for hpg computation
-
+      
+                         CALL ssh_nxt    ( kstp, Nbb, Nnn, ssh,  Naa )   ! after ssh (includes call to div_hor)
+      IF( .NOT.lk_linssh ) THEN
+                         CALL dom_qco_r3c( CASTWP(ssh(:,:,Naa)), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa)           )   ! "after" ssh/h_0 ratio at t,u,v pts
+         IF( ln_dynspg_exp )   &
+            &            CALL dom_qco_r3c( CASTWP(ssh(:,:,Nnn)), r3t(:,:,Nnn), r3u(:,:,Nnn), r3v(:,:,Nnn), r3f(:,:) )   ! spg_exp : needed only for "now" ssh/h_0 ratio at f point
+      ENDIF
+                         CALL wzv        ( kstp, Nbb, Nnn, Naa, ww  )    ! Nnn cross-level velocity
+      IF( ln_zad_Aimp )  CALL wAimp      ( kstp,      Nnn           )    ! Adaptive-implicit vertical advection partitioning
+                         ALLOCATE( zgdept(jpi,jpj,jpk) )
+                         DO jk = 1, jpk
+                            zgdept(:,:,jk) = gdept(:,:,jk,Nnn)
+                         END DO
+                         CALL eos        ( CASTWP(ts(:,:,:,:,Nnn)), rhd, rhop, zgdept ) ! now in situ density for hpg computation
+                         DEALLOCATE( zgdept )
 
                          uu(:,:,:,Nrhs) = 0._wp            ! set dynamics trends to zero
@@ -224,9 +242,9 @@
                          CALL dyn_hpg( kstp,      Nnn      , uu, vv, Nrhs )  ! horizontal gradient of Hydrostatic pressure
                          CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa )  ! surface pressure gradient
-                                                      ! With split-explicit free surface, since now transports have been updated and ssh(:,:,Nrhs) as well
-
-      IF( ln_dynspg_ts ) THEN                         ! vertical scale factors and vertical velocity need to be updated
+                         
+      IF( ln_dynspg_ts ) THEN      ! With split-explicit free surface, since now transports have been updated and ssh(:,:,Nrhs)
+                                   ! as well as vertical scale factors and vertical velocity need to be updated
                             CALL div_hor    ( kstp, Nbb, Nnn )                ! Horizontal divergence  (2nd call in time-split case)
-         IF(.NOT.lk_linssh) CALL dom_qco_r3c ( CASTWP(ssh(:,:,Naa)), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa), r3f(:,:) )   ! update ssh/h_0 ratio at t,u,v,f pts 
+         IF(.NOT.lk_linssh) CALL dom_qco_r3c( CASTWP(ssh(:,:,Naa)), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa), r3f(:,:) )   ! update ssh/h_0 ratio at t,u,v,f pts 
       ENDIF
                             CALL dyn_zdf    ( kstp, Nbb, Nnn, Nrhs, uu, vv, Naa  )  ! vertical diffusion
@@ -271,28 +289,47 @@
       ! Active tracers
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         ts(:,:,:,:,Nrhs) = 0._wp         ! set tracer trends to zero
-
-      IF(  lk_asminc .AND. ln_asmiau .AND. &
-         & ln_trainc )   CALL tra_asm_inc( kstp, Nbb, Nnn, ts, Nrhs )  ! apply tracer assimilation increment
-                         CALL tra_sbc    ( kstp,      Nnn, ts, Nrhs )  ! surface boundary condition
-      IF( ln_traqsr  )   CALL tra_qsr    ( kstp,      Nnn, ts, Nrhs )  ! penetrative solar radiation qsr
-      IF( ln_isf     )   CALL tra_isf    ( kstp,      Nnn, ts, Nrhs )  ! ice shelf heat flux
-      IF( ln_trabbc  )   CALL tra_bbc    ( kstp,      Nnn, ts, Nrhs )  ! bottom heat flux
-      IF( ln_trabbl  )   CALL tra_bbl    ( kstp, Nbb, Nnn, ts, Nrhs )  ! advective (and/or diffusive) bottom boundary layer scheme
-      IF( ln_tradmp  )   CALL tra_dmp    ( kstp, Nbb, Nnn, ts, Nrhs )  ! internal damping trends
-      IF( ln_bdy     )   CALL bdy_tra_dmp( kstp, Nbb,      ts, Nrhs )  ! bdy damping trends
-#if defined key_agrif
-      IF(.NOT. Agrif_Root())  &
-               &         CALL Agrif_Sponge_tra        ! tracers sponge
-#endif
-                         CALL tra_adv    ( kstp, Nbb, Nnn, ts, Nrhs )  ! hor. + vert. advection	==> RHS
-      IF( ln_zdfosm  )   CALL tra_osm    ( kstp,      Nnn, ts, Nrhs )  ! OSMOSIS non-local tracer fluxes ==> RHS
-      IF( lrst_oce .AND. ln_zdfosm ) &
-           &             CALL osm_rst    ( kstp,      Nnn, 'WRITE'  )  ! write OSMOSIS outputs + ww (so must do here) to restarts
-                         CALL tra_ldf    ( kstp, Nbb, Nnn, ts, Nrhs )  ! lateral mixing
-
-                         CALL tra_zdf    ( kstp, Nbb, Nnn, Nrhs, ts, Naa  )  ! vertical mixing and after tracer fields
-      IF( ln_zdfnpc  )   CALL tra_npc    ( kstp,      Nnn, Nrhs, ts, Naa  )  ! update after fields by non-penetrative convection
-
+      ! Loop over tile domains
+      DO jtile = 1, nijtile
+         IF( ln_tile    )   CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )
+
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            ts(ji,jj,jk,:,Nrhs) = 0._wp                                   ! set tracer trends to zero
+         END_3D
+
+         IF(  lk_asminc .AND. ln_asmiau .AND. &
+            & ln_trainc )   CALL tra_asm_inc( kstp, Nbb, Nnn, ts, Nrhs )  ! apply tracer assimilation increment
+                            CALL tra_sbc    ( kstp,      Nnn, ts, Nrhs )  ! surface boundary condition
+         IF( ln_traqsr  )   CALL tra_qsr    ( kstp,      Nnn, ts, Nrhs )  ! penetrative solar radiation qsr
+         IF( ln_isf     )   CALL tra_isf    ( kstp,      Nnn, ts, Nrhs )  ! ice shelf heat flux
+         IF( ln_trabbc  )   CALL tra_bbc    ( kstp,      Nnn, ts, Nrhs )  ! bottom heat flux
+         IF( ln_trabbl  )   CALL tra_bbl    ( kstp, Nbb, Nnn, ts, Nrhs )  ! advective (and/or diffusive) bottom boundary layer scheme
+         IF( ln_tradmp  )   CALL tra_dmp    ( kstp, Nbb, Nnn, ts, Nrhs )  ! internal damping trends
+         IF( ln_bdy     )   CALL bdy_tra_dmp( kstp, Nbb,      ts, Nrhs )  ! bdy damping trends
+      END DO
+
+#if defined key_agrif
+      IF(.NOT. Agrif_Root() ) THEN
+         IF( ln_tile    )   CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )
+                            CALL Agrif_Sponge_tra        ! tracers sponge
+      ENDIF
+#endif
+
+      ! TEMP: [tiling] Separate loop over tile domains (due to tra_adv workarounds for tiling)
+      DO jtile = 1, nijtile
+         IF( ln_tile    )   CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = jtile )
+
+                            CALL tra_adv    ( kstp, Nbb, Nnn, ts, Nrhs )  ! hor. + vert. advection	==> RHS
+         IF( ln_zdfmfc  )   CALL tra_mfc    ( kstp, Nbb,      ts, Nrhs )  ! Mass Flux Convection
+         IF( ln_zdfosm  ) THEN
+                            CALL tra_osm    ( kstp,      Nnn, ts, Nrhs )  ! OSMOSIS non-local tracer fluxes ==> RHS
+            IF( lrst_oce )  CALL osm_rst    ( kstp,      Nnn, 'WRITE'  )  ! write OSMOSIS outputs + ww (so must do here) to restarts
+         ENDIF
+                            CALL tra_ldf    ( kstp, Nbb, Nnn, ts, Nrhs )  ! lateral mixing
+
+                            CALL tra_zdf    ( kstp, Nbb, Nnn, Nrhs, ts, Naa  )  ! vertical mixing and after tracer fields
+         IF( ln_zdfnpc  )   CALL tra_npc    ( kstp,      Nnn, Nrhs, ts, Naa  )  ! update after fields by non-penetrative convection
+      END DO
+
+      IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 ) ! Revert to tile over full domain
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Set boundary conditions, time filter and swap time levels
@@ -320,5 +357,4 @@
                          r3v(:,:,Nnn) = r3v_f(:,:)
       ENDIF
-
       !
       ! Swap time levels
@@ -341,15 +377,10 @@
 #if defined key_agrif
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! AGRIF
+      ! AGRIF recursive integration
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                          Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs      ! agrif_oce module copies of time level indices
                          CALL Agrif_Integrate_ChildGrids( stp_MLF )       ! allows to finish all the Child Grids before updating
 
-                         IF( Agrif_NbStepint() == 0 ) THEN
-                            CALL Agrif_update_all( )                  ! Update all components
-                         ENDIF
-#endif
-      IF( ln_diaobs  )   CALL dia_obs      ( kstp, Nnn )      ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
-
+#endif
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Control
@@ -357,6 +388,21 @@
                          CALL stp_ctl      ( kstp, Nnn )
 
+#if defined key_agrif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! AGRIF update
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( Agrif_NbStepint() == 0 .AND. nstop == 0 )   &
+         &               CALL Agrif_update_all( )                  ! Update all components
+
+#endif
+      IF( ln_diaobs .AND. nstop == 0 )   &
+         &               CALL dia_obs( kstp, Nnn )  ! obs-minus-model (assimilation) diags (after dynamics update)
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! File manipulation at the end of the first time step
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       IF( kstp == nit000 ) THEN                          ! 1st time step only
                                         CALL iom_close( numror )   ! close input  ocean restart file
+         IF( lrxios )                   CALL iom_context_finalize( cr_ocerst_cxt )
          IF(lwm)                        CALL FLUSH    ( numond )   ! flush output namelist oce
          IF(lwm .AND. numoni /= -1 )    CALL FLUSH    ( numoni )   ! flush output namelist ice (if exist)
@@ -366,9 +412,11 @@
       ! Coupled mode
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-!!gm why lk_oasis and not lk_cpl ????
-      IF( lk_oasis   )   CALL sbc_cpl_snd( kstp, Nbb, Nnn )        ! coupled mode : field exchanges
-      !
-#if defined key_iomput
-      IF( kstp == nitend .OR. indic < 0 ) THEN
+      IF( lk_oasis .AND. nstop == 0 )   CALL sbc_cpl_snd( kstp, Nbb, Nnn )     ! coupled mode : field exchanges
+      !
+#if defined key_xios
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Finalize contextes if end of simulation or error detected
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( kstp == nitend .OR. nstop > 0 ) THEN
                       CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
          IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) !
@@ -377,7 +425,7 @@
       !
       IF( l_1st_euler ) THEN         ! recover Leap-frog timestep
-         rDt   = 2._wp * rn_Dt   
+         rDt   = 2._wp * rn_Dt
          r1_Dt = 1._wp / rDt
-         l_1st_euler = .FALSE.      
+         l_1st_euler = .FALSE.
       ENDIF
       !
@@ -448,4 +496,9 @@
       !! ** Action :   puu(Kaa),pvv(Kaa)   after horizontal velocity and tracers
       !!----------------------------------------------------------------------
+#if defined key_agrif
+      USE agrif_oce_interp
+#endif
+      USE bdydyn         ! ocean open boundary conditions (define bdy_dyn)
+      !!
       INTEGER                                  , INTENT(in   ) ::   kt         ! ocean time-step index
       INTEGER                                  , INTENT(in   ) ::   Kbb, Kaa   ! before and after time level indices
@@ -461,6 +514,6 @@
 # endif
       !                                        ! local domain boundaries  (T-point, unchanged sign)
-      CALL lbc_lnk_multi( 'finalize_lbc', puu(:,:,:,       Kaa), 'U', -1._wp, pvv(:,:,:       ,Kaa), 'V', -1._wp   &
-                       &                , pts(:,:,:,jp_tem,Kaa), 'T',  1._wp, pts(:,:,:,jp_sal,Kaa), 'T',  1._wp )
+      CALL lbc_lnk( 'finalize_lbc', puu(:,:,:,       Kaa), 'U', -1._wp, pvv(:,:,:       ,Kaa), 'V', -1._wp   &
+                       &          , pts(:,:,:,jp_tem,Kaa), 'T',  1._wp, pts(:,:,:,jp_sal,Kaa), 'T',  1._wp )
       !
       !                                        !* BDY open boundaries
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/timing.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/timing.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/timing.F90	(revision 14644)
@@ -31,5 +31,5 @@
    PUBLIC   timing_start, timing_stop      ! called in each routine to time
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    INCLUDE 'mpif.h'
 #endif
@@ -116,5 +116,5 @@
       CALL CPU_TIME( s_timer%t_cpu  )
       ! clock time collection
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       s_timer%t_clock= MPI_Wtime()
 #else
@@ -142,5 +142,5 @@
 
       ! clock time collection
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       zmpitime = MPI_Wtime()
 #else
@@ -166,5 +166,5 @@
 
       ! clock time correction
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       zclock_raw = zmpitime - s_timer%t_clock - t_overclock ! total time including child
       s_timer%t_clock = zclock_raw - t_overclock - s_timer%tsub_clock
@@ -249,5 +249,5 @@
 
       ! Compute clock function overhead
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       t_overclock = MPI_WTIME()
       t_overclock = MPI_WTIME() - t_overclock
@@ -274,5 +274,5 @@
 
       CALL CPU_TIME(t_cpu(1))
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! Start elapsed and CPU time counters
       t_elaps(1) = MPI_WTIME()
@@ -305,5 +305,5 @@
       CALL CPU_TIME(t_cpu(2))
       t_cpu(2)   = t_cpu(2)    - t_cpu(1)   - t_overcpu
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       t_elaps(2) = MPI_WTIME() - t_elaps(1) - t_overclock
 #else
@@ -336,5 +336,5 @@
       ENDIF
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ! in MPI gather some info
       ALLOCATE( all_etime(jpnij), all_ctime(jpnij) )
@@ -360,5 +360,5 @@
       IF( lwriter ) WRITE(numtime,'(5x,f12.3,1x,f12.3)')  tot_etime, tot_ctime
       IF( lwriter ) WRITE(numtime,*)
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       IF( ll_averep ) CALL waver_info
       CALL wmpi_info
@@ -377,5 +377,5 @@
       &       czone(1:3),    czone(4:5)
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
       ALLOCATE(timing_glob(4*jpnij), stat=icode)
       CALL MPI_GATHER( (/compute_time, waiting_time(1), waiting_time(2), elapsed_time/),   &
@@ -458,5 +458,5 @@
    END SUBROUTINE wcurrent_info
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    SUBROUTINE waver_info
       !!----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OFF/dtadyn.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OFF/dtadyn.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OFF/dtadyn.F90	(revision 14644)
@@ -53,15 +53,16 @@
    PUBLIC   dta_dyn_init       ! called by nemo_init
    PUBLIC   dta_dyn            ! called by nemo_gcm
-   PUBLIC   dta_dyn_sed_init   ! called by nemo_init
-   PUBLIC   dta_dyn_sed        ! called by nemo_gcm
    PUBLIC   dta_dyn_atf        ! called by nemo_gcm
 #if ! defined key_qco
    PUBLIC   dta_dyn_sf_interp  ! called by nemo_gcm
 #endif
+#if defined key_sed_off
+   PUBLIC   dta_dyn_sed_init   ! called by nemo_init
+   PUBLIC   dta_dyn_sed        ! called by nemo_gcm
+#endif
 
    CHARACTER(len=100) ::   cn_dir          !: Root directory for location of ssr files
    LOGICAL            ::   ln_dynrnf       !: read runoff data in file (T) or set to zero (F)
    LOGICAL            ::   ln_dynrnf_depth       !: read runoff data in file (T) or set to zero (F)
-   REAL(wp)           ::   fwbcorr
 
 
@@ -138,17 +139,17 @@
       ts(:,:,:,jp_tem,Kmm) = sf_dyn(jf_tem)%fnow(:,:,:)  * tmask(:,:,:)    ! temperature
       ts(:,:,:,jp_sal,Kmm) = sf_dyn(jf_sal)%fnow(:,:,:)  * tmask(:,:,:)    ! salinity
-      wndm(:,:)         = sf_dyn(jf_wnd)%fnow(:,:,1)  * tmask(:,:,1)    ! wind speed - needed for gas exchange
-      fmmflx(:,:)       = sf_dyn(jf_fmf)%fnow(:,:,1)  * tmask(:,:,1)    ! downward salt flux (v3.5+)
-      fr_i(:,:)         = sf_dyn(jf_ice)%fnow(:,:,1)  * tmask(:,:,1)    ! Sea-ice fraction
-      qsr (:,:)         = sf_dyn(jf_qsr)%fnow(:,:,1)  * tmask(:,:,1)    ! solar radiation
-      emp (:,:)         = sf_dyn(jf_emp)%fnow(:,:,1)  * tmask(:,:,1)    ! E-P
+      wndm(:,:)            = sf_dyn(jf_wnd)%fnow(:,:,1)  * tmask(:,:,1)    ! wind speed - needed for gas exchange
+      fmmflx(:,:)          = sf_dyn(jf_fmf)%fnow(:,:,1)  * tmask(:,:,1)    ! downward salt flux (v3.5+)
+      fr_i(:,:)            = sf_dyn(jf_ice)%fnow(:,:,1)  * tmask(:,:,1)    ! Sea-ice fraction
+      qsr (:,:)            = sf_dyn(jf_qsr)%fnow(:,:,1)  * tmask(:,:,1)    ! solar radiation
+      emp (:,:)            = sf_dyn(jf_emp)%fnow(:,:,1)  * tmask(:,:,1)    ! E-P
       IF( ln_dynrnf ) THEN 
-         rnf (:,:)      = sf_dyn(jf_rnf)%fnow(:,:,1) * tmask(:,:,1)    ! E-P
-         IF( ln_dynrnf_depth .AND. .NOT. ln_linssh )    CALL  dta_dyn_hrnf(Kmm)
+         rnf (:,:)         = sf_dyn(jf_rnf)%fnow(:,:,1) * tmask(:,:,1)    ! E-P
+         IF( ln_dynrnf_depth .AND. .NOT. ln_linssh )    CALL  dta_dyn_rnf( Kmm )
       ENDIF
       !
       uu(:,:,:,Kmm)        = sf_dyn(jf_uwd)%fnow(:,:,:) * umask(:,:,:)    ! effective u-transport
       vv(:,:,:,Kmm)        = sf_dyn(jf_vwd)%fnow(:,:,:) * vmask(:,:,:)    ! effective v-transport
-      ww(:,:,:)        = sf_dyn(jf_wwd)%fnow(:,:,:) * tmask(:,:,:)    ! effective v-transport
+      ww(:,:,:)            = sf_dyn(jf_wwd)%fnow(:,:,:) * tmask(:,:,:)    ! effective v-transport
       !
       IF( .NOT.ln_linssh ) THEN
@@ -156,5 +157,5 @@
          zhdivtr(:,:,:) = sf_dyn(jf_div)%fnow(:,:,:)  * tmask(:,:,:)    ! effective u-transport
          emp_b  (:,:)   = sf_dyn(jf_empb)%fnow(:,:,1) * tmask(:,:,1)    ! E-P
-         zemp   (:,:)   = ( 0.5_wp * ( emp(:,:) + emp_b(:,:) ) + rnf(:,:) + fwbcorr ) * tmask(:,:,1)
+         zemp   (:,:)   = ( 0.5_wp * ( emp(:,:) + emp_b(:,:) ) + rnf(:,:) ) * tmask(:,:,1)
 #if defined key_qco
          CALL dta_dyn_ssh( kt, zhdivtr, ssh(:,:,Kbb), zemp, ssh(:,:,Kaa) )
@@ -225,7 +226,4 @@
       INTEGER  :: ios                                ! Local integer output status for namelist read
       INTEGER  :: ji, jj, jk
-      REAL(wp) :: zcoef
-      INTEGER  :: nkrnf_max
-      REAL(wp) :: hrnf_max
       !!
       CHARACTER(len=100)            ::  cn_dir        !   Root directory for location of core files
@@ -237,5 +235,5 @@
       TYPE(FLD_N) :: sn_div  ! informations about the fields to be read
       !!
-      NAMELIST/namdta_dyn/cn_dir, ln_dynrnf, ln_dynrnf_depth,  fwbcorr, &
+      NAMELIST/namdta_dyn/cn_dir, ln_dynrnf, ln_dynrnf_depth, &
          &                sn_uwd, sn_vwd, sn_wwd, sn_emp,               &
          &                sn_avt, sn_tem, sn_sal, sn_mld , sn_qsr ,     &
@@ -259,5 +257,4 @@
          WRITE(numout,*) '      runoffs option enabled (T) or not (F)            ln_dynrnf        = ', ln_dynrnf
          WRITE(numout,*) '      runoffs is spread in vertical                    ln_dynrnf_depth  = ', ln_dynrnf_depth
-         WRITE(numout,*) '      annual global mean of empmr for ssh correction   fwbcorr          = ', fwbcorr
          WRITE(numout,*)
       ENDIF
@@ -355,42 +352,147 @@
         DO jk = 1, jpkm1
            e3t(:,:,jk,Kmm) = e3t_0(:,:,jk) * ( 1._wp + ssh(:,:,Kmm) * r1_ht_0(:,:) * tmask(:,:,jk) )
+           e3t(:,:,jk,Kbb) = e3t_0(:,:,jk) * ( 1._wp + ssh(:,:,Kbb) * r1_ht_0(:,:) * tmask(:,:,jk) )
         ENDDO
-        e3t(:,:,jpk,Kaa) = e3t_0(:,:,jpk)
-
-        ! Horizontal scale factor interpolations
-        ! --------------------------------------
-        CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3u(:,:,:,Kmm), 'U' )
-        CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3v(:,:,:,Kmm), 'V' )
-
-        ! Vertical scale factor interpolations
-        ! ------------------------------------
-        CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3w(:,:,:,Kmm), 'W' )
-!!gm this should be computed from ssh(Kbb)  
-        e3t(:,:,:,Kbb)  = e3t(:,:,:,Kmm)
-        e3u(:,:,:,Kbb)  = e3u(:,:,:,Kmm)
-        e3v(:,:,:,Kbb)  = e3v(:,:,:,Kmm)
-
-        ! t- and w- points depth
-        ! ----------------------
-        gdept(:,:,1,Kmm) = 0.5_wp * e3w(:,:,1,Kmm)
-        gdepw(:,:,1,Kmm) = 0.0_wp
-
-        DO_3D( 1, 1, 1, 1, 2, jpk )
-          !    zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))   ! 0 everywhere
-          !    tmask = wmask, ie everywhere expect at jk = mikt
-                                                             ! 1 for jk =
-                                                             ! mikt
-           zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
-           gdepw(ji,jj,jk,Kmm) = gdepw(ji,jj,jk-1,Kmm) + e3t(ji,jj,jk-1,Kmm)
-           gdept(ji,jj,jk,Kmm) =      zcoef  * ( gdepw(ji,jj,jk  ,Kmm) + 0.5 * e3w(ji,jj,jk,Kmm))  &
-               &                + (1-zcoef) * ( gdept(ji,jj,jk-1,Kmm) + e3w(ji,jj,jk,Kmm))
-        END_3D
-
-        gdept(:,:,:,Kbb) = gdept(:,:,:,Kmm)
-        gdepw(:,:,:,Kbb) = gdepw(:,:,:,Kmm)
-        !
+
+        CALL dta_dyn_sf_interp( nit000, Kmm )
+        CALL dta_dyn_sf_interp( nit000, Kbb )
 #endif
       ENDIF
       !
+      CALL dta_dyn_rnf_init( Kmm )
+      !
+      CALL dta_dyn( nit000, Kbb, Kmm, Kaa )
+      !
+   END SUBROUTINE dta_dyn_init
+
+   SUBROUTINE dta_dyn_atf( kt, Kbb, Kmm, Kaa )
+     !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE dta_dyn_swp  ***
+      !!
+      !! ** Purpose :   Asselin time filter of now SSH
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt             ! time step
+      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa  ! ocean time level indices
+      !
+      !!---------------------------------------------------------------------
+
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dta_dyn_atf : Asselin time filter of sea surface height'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+      ENDIF
+
+      ssh(:,:,Kmm) = ssh(:,:,Kmm) + rn_atfp * ( ssh(:,:,Kbb) - 2 * ssh(:,:,Kmm) + ssh(:,:,Kaa))  
+
+      !
+   END SUBROUTINE dta_dyn_atf
+   
+   
+#if ! defined key_qco  
+
+   SUBROUTINE dta_dyn_sf_interp( kt, Kmm )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE dta_dyn_sf_interp  ***
+      !!
+      !! ** Purpose :   Calculate scale factors at U/V/W points and depths
+      !!                given the after e3t field
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) :: kt   ! time step
+      INTEGER, INTENT(in) :: Kmm  ! ocean time level indices
+      !
+      INTEGER             :: ji, jj, jk
+      REAL(wp)            :: zcoef
+      !!---------------------------------------------------------------------
+
+      ! Horizontal scale factor interpolations
+      ! --------------------------------------
+      CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3u(:,:,:,Kmm), 'U' )
+      CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3v(:,:,:,Kmm), 'V' )
+
+      ! Vertical scale factor interpolations
+      ! ------------------------------------
+      CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3w (:,:,:,Kmm), 'W' )
+
+      ! t- and w- points depth
+      ! ----------------------
+      gdept(:,:,1,Kmm) = 0.5_wp * e3w(:,:,1,Kmm)
+      gdepw(:,:,1,Kmm) = 0.0_wp
+      !
+      DO_3D( 1, 1, 1, 1, 2, jpk )
+         zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
+         gdepw(ji,jj,jk,Kmm) = gdepw(ji,jj,jk-1,Kmm) + e3t(ji,jj,jk-1,Kmm)
+         gdept(ji,jj,jk,Kmm) =      zcoef  * ( gdepw(ji,jj,jk  ,Kmm) + 0.5 * e3w(ji,jj,jk,Kmm))  &
+            &                + (1-zcoef) * ( gdept(ji,jj,jk-1,Kmm) + e3w(ji,jj,jk,Kmm))
+      END_3D
+      !
+   END SUBROUTINE dta_dyn_sf_interp
+
+#endif
+
+   SUBROUTINE dta_dyn_ssh( kt, phdivtr, psshb,  pemp, pssha, pe3ta )
+      !!----------------------------------------------------------------------
+      !!                ***  ROUTINE dta_dyn_wzv  ***
+      !!                   
+      !! ** Purpose :   compute the after ssh (ssh(:,:,Kaa)) and the now vertical velocity
+      !!
+      !! ** Method  : Using the incompressibility hypothesis, 
+      !!        - the ssh increment is computed by integrating the horizontal divergence 
+      !!          and multiply by the time step.
+      !!
+      !!        - compute the after scale factor : repartition of ssh INCREMENT proportionnaly
+      !!                                           to the level thickness ( z-star case )
+      !!
+      !!        - the vertical velocity is computed by integrating the horizontal divergence  
+      !!          from the bottom to the surface minus the scale factor evolution.
+      !!          The boundary conditions are w=0 at the bottom (no flux)
+      !!
+      !! ** action  :   ssh(:,:,Kaa) / e3t(:,:,k,Kaa) / ww
+      !!
+      !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
+      !!----------------------------------------------------------------------
+      INTEGER,                                   INTENT(in )    :: kt        !  time-step
+      REAL(wp), DIMENSION(jpi,jpj,jpk)          , INTENT(in )   :: phdivtr   ! horizontal divergence transport
+      REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(in )   :: psshb     ! now ssh
+      REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(in )   :: pemp      ! evaporation minus precipitation
+      REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(inout) :: pssha     ! after ssh
+      REAL(wp), DIMENSION(jpi,jpj,jpk), OPTIONAL, INTENT(out)   :: pe3ta     ! after vertical scale factor
+      !
+      INTEGER                       :: jk
+      REAL(wp), DIMENSION(jpi,jpj)  :: zhdiv  
+      REAL(wp)  :: z2dt  
+      !!----------------------------------------------------------------------
+      !
+      z2dt = 2._wp * rn_Dt
+      !
+      zhdiv(:,:) = 0._wp
+      DO jk = 1, jpkm1
+         zhdiv(:,:) = zhdiv(:,:) +  phdivtr(:,:,jk) * tmask(:,:,jk)
+      END DO
+      !                                                ! Sea surface  elevation time-stepping
+      pssha(:,:) = ( psshb(:,:) - z2dt * ( r1_rho0 * pemp(:,:)  + zhdiv(:,:) ) ) * ssmask(:,:)
+      !
+      IF( PRESENT( pe3ta ) ) THEN                      ! After acale factors at t-points ( z_star coordinate )
+      DO jk = 1, jpkm1
+            pe3ta(:,:,jk) = e3t_0(:,:,jk) * ( 1._wp + pssha(:,:) * r1_ht_0(:,:) * tmask(:,:,jk) )
+      END DO
+      ENDIF
+      !
+   END SUBROUTINE dta_dyn_ssh
+
+   SUBROUTINE dta_dyn_rnf_init( Kmm )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn_rnf_init  ***
+      !!
+      !! ** Purpose :   Initialisation of the runoffs if (ln_rnf=T)
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) :: Kmm  ! ocean time level indices
+      !
+      INTEGER  :: inum                   ! local integer
+      INTEGER  :: ji, jj, jk
+      REAL(wp) :: zcoef
+      INTEGER  :: nkrnf_max
+      REAL(wp) :: hrnf_max
+
       IF( ln_dynrnf .AND. ln_dynrnf_depth ) THEN       ! read depht over which runoffs are distributed
          IF(lwp) WRITE(numout,*) 
@@ -435,252 +537,12 @@
       IF(lwp) WRITE(numout,*) ' '
       !
-      CALL dta_dyn( nit000, Kbb, Kmm, Kaa )
-      !
-   END SUBROUTINE dta_dyn_init
-
-   
-   SUBROUTINE dta_dyn_sed( kt, Kmm )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dta_dyn  ***
-      !!
-      !! ** Purpose :  Prepares dynamics and physics fields from a NEMO run
-      !!               for an off-line simulation of passive tracers
-      !!
-      !! ** Method : calculates the position of data
-      !!             - computes slopes if needed
-      !!             - interpolates data if needed
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      INTEGER, INTENT(in) ::   Kmm  ! ocean time level index
-      !
-      !!----------------------------------------------------------------------
-      !
-      IF( ln_timing )   CALL timing_start( 'dta_dyn_sed')
-      !
-      nsecdyn = nsec_year + nsec1jan000   ! number of seconds between Jan. 1st 00h of nit000 year and the middle of time step
-      !
-      IF( kt == nit000 ) THEN    ;    nprevrec = 0
-      ELSE                       ;    nprevrec = sf_dyn(jf_tem)%nrec(2,sf_dyn(jf_tem)%naa)
-      ENDIF
-      CALL fld_read( kt, 1, sf_dyn )      !=  read data at kt time step   ==!
-      !
-      ts(:,:,:,jp_tem,Kmm) = sf_dyn(jf_tem)%fnow(:,:,:)  * tmask(:,:,:)    ! temperature
-      ts(:,:,:,jp_sal,Kmm) = sf_dyn(jf_sal)%fnow(:,:,:)  * tmask(:,:,:)    ! salinity
-      !
-      CALL eos    ( ts(:,:,:,:,Kmm), rhd, rhop, gdept_0(:,:,:) ) ! In any case, we need rhop
-
-      IF(sn_cfctl%l_prtctl) THEN                     ! print control
-         CALL prt_ctl(tab3d_1=ts(:,:,:,jp_tem,Kmm), clinfo1=' tn      - : ', mask1=tmask,  kdim=jpk   )
-         CALL prt_ctl(tab3d_1=ts(:,:,:,jp_sal,Kmm), clinfo1=' sn      - : ', mask1=tmask,  kdim=jpk   )
-      ENDIF
-      !
-      IF( ln_timing )   CALL timing_stop( 'dta_dyn_sed')
-      !
-   END SUBROUTINE dta_dyn_sed
-
-
-   SUBROUTINE dta_dyn_sed_init( Kmm )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dta_dyn_init  ***
-      !!
-      !! ** Purpose :   Initialisation of the dynamical data
-      !! ** Method  : - read the data namdta_dyn namelist
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) :: Kmm                   ! ocean time level index
-      !
-      INTEGER  :: ierr, ierr0, ierr1, ierr2, ierr3   ! return error code
-      INTEGER  :: ifpr                               ! dummy loop indice
-      INTEGER  :: jfld                               ! dummy loop arguments
-      INTEGER  :: inum, idv, idimv                   ! local integer
-      INTEGER  :: ios                                ! Local integer output status for namelist read
-      !!
-      CHARACTER(len=100)            ::  cn_dir        !   Root directory for location of core files
-      TYPE(FLD_N), DIMENSION(2) ::  slf_d         ! array of namelist informations on the fields to read
-      TYPE(FLD_N) :: sn_tem , sn_sal   !   "                 "
-      !!
-      NAMELIST/namdta_dyn/cn_dir, ln_dynrnf, ln_dynrnf_depth,  fwbcorr, &
-         &                sn_tem, sn_sal
-      !!----------------------------------------------------------------------
-      !
-      READ  ( numnam_ref, namdta_dyn, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdta_dyn in reference namelist' )
-      READ  ( numnam_cfg, namdta_dyn, IOSTAT = ios, ERR = 902 )
-902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdta_dyn in configuration namelist' )
-      IF(lwm) WRITE ( numond, namdta_dyn )
-      !                                         ! store namelist information in an array
-      !                                         ! Control print
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'dta_dyn : offline dynamics '
-         WRITE(numout,*) '~~~~~~~ '
-         WRITE(numout,*) '   Namelist namdta_dyn'
-         WRITE(numout,*) '      runoffs option enabled (T) or not (F)            ln_dynrnf        = ', ln_dynrnf
-         WRITE(numout,*) '      runoffs is spread in vertical                    ln_dynrnf_depth  = ', ln_dynrnf_depth
-         WRITE(numout,*) '      annual global mean of empmr for ssh correction   fwbcorr          = ', fwbcorr
-         WRITE(numout,*)
-      ENDIF
-      !
-      jf_tem  = 1     ;   jf_sal  = 2    ;   jfld   = jf_sal
-      !
-      slf_d(jf_tem)  = sn_tem    ;   slf_d(jf_sal)  = sn_sal
-      !
-      ALLOCATE( sf_dyn(jfld), STAT=ierr )         ! set sf structure
-      IF( ierr > 0 )  THEN
-         CALL ctl_stop( 'dta_dyn: unable to allocate sf structure' )   ;   RETURN
-      ENDIF
-      !                                         ! fill sf with slf_i and control print
-      CALL fld_fill( sf_dyn, slf_d, cn_dir, 'dta_dyn_init', 'Data in file', 'namdta_dyn' )
-      !
-      ! Open file for each variable to get his number of dimension
-      DO ifpr = 1, jfld
-         CALL fld_def( sf_dyn(ifpr) )
-         CALL iom_open( sf_dyn(ifpr)%clname, sf_dyn(ifpr)%num )
-         idv   = iom_varid( sf_dyn(ifpr)%num , slf_d(ifpr)%clvar )        ! id of the variable sdjf%clvar
-         idimv = iom_file ( sf_dyn(ifpr)%num )%ndims(idv)                 ! number of dimension for variable sdjf%clvar
-         CALL iom_close( sf_dyn(ifpr)%num )                               ! close file if already open
-         ierr1=0
-         IF( idimv == 3 ) THEN    ! 2D variable
-                                      ALLOCATE( sf_dyn(ifpr)%fnow(jpi,jpj,1)    , STAT=ierr0 )
-            IF( slf_d(ifpr)%ln_tint ) ALLOCATE( sf_dyn(ifpr)%fdta(jpi,jpj,1,2)  , STAT=ierr1 )
-         ELSE                     ! 3D variable
-                                      ALLOCATE( sf_dyn(ifpr)%fnow(jpi,jpj,jpk)  , STAT=ierr0 )
-            IF( slf_d(ifpr)%ln_tint ) ALLOCATE( sf_dyn(ifpr)%fdta(jpi,jpj,jpk,2), STAT=ierr1 )
-         ENDIF
-         IF( ierr0 + ierr1 > 0 ) THEN
-            CALL ctl_stop( 'dta_dyn_init : unable to allocate sf_dyn array structure' )   ;   RETURN
-         ENDIF
-      END DO
-      !
-      CALL dta_dyn_sed( nit000, Kmm )
-      !
-   END SUBROUTINE dta_dyn_sed_init
-
-   
-   SUBROUTINE dta_dyn_atf( kt, Kbb, Kmm, Kaa )
-     !!---------------------------------------------------------------------
-      !!                    ***  ROUTINE dta_dyn_swp  ***
-      !!
-      !! ** Purpose :   Asselin time filter of now SSH
-      !!---------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kt             ! time step
-      INTEGER, INTENT(in) :: Kbb, Kmm, Kaa  ! ocean time level indices
-      !
-      !!---------------------------------------------------------------------
-
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dta_dyn_atf : Asselin time filter of sea surface height'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
-      ENDIF
-
-      ssh(:,:,Kmm) = ssh(:,:,Kmm) + rn_atfp * ( ssh(:,:,Kbb) - 2 * ssh(:,:,Kmm) + ssh(:,:,Kaa))  
-
-      !! Do we also need to time filter e3t??
-      !
-   END SUBROUTINE dta_dyn_atf
-   
-   
-#if ! defined key_qco    
-   SUBROUTINE dta_dyn_sf_interp( kt, Kmm )
-      !!---------------------------------------------------------------------
-      !!                    ***  ROUTINE dta_dyn_sf_interp  ***
-      !!
-      !! ** Purpose :   Calculate scale factors at U/V/W points and depths
-      !!                given the after e3t field
-      !!---------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kt   ! time step
-      INTEGER, INTENT(in) :: Kmm  ! ocean time level indices
-      !
-      INTEGER             :: ji, jj, jk
-      REAL(wp)            :: zcoef
-      !!---------------------------------------------------------------------
-
-      ! Horizontal scale factor interpolations
-      ! --------------------------------------
-      CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3u(:,:,:,Kmm), 'U' )
-      CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3v(:,:,:,Kmm), 'V' )
-
-      ! Vertical scale factor interpolations
-      ! ------------------------------------
-      CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3w (:,:,:,Kmm), 'W' )
-
-      ! t- and w- points depth
-      ! ----------------------
-      gdept(:,:,1,Kmm) = 0.5_wp * e3w(:,:,1,Kmm)
-      gdepw(:,:,1,Kmm) = 0.0_wp
-      !
-      DO_3D( 1, 1, 1, 1, 2, jpk )
-         zcoef = (tmask(ji,jj,jk) - wmask(ji,jj,jk))
-         gdepw(ji,jj,jk,Kmm) = gdepw(ji,jj,jk-1,Kmm) + e3t(ji,jj,jk-1,Kmm)
-         gdept(ji,jj,jk,Kmm) =      zcoef  * ( gdepw(ji,jj,jk  ,Kmm) + 0.5 * e3w(ji,jj,jk,Kmm))  &
-            &                + (1-zcoef) * ( gdept(ji,jj,jk-1,Kmm) + e3w(ji,jj,jk,Kmm))
-      END_3D
-      !
-   END SUBROUTINE dta_dyn_sf_interp
-#endif
-
-
-   SUBROUTINE dta_dyn_ssh( kt, phdivtr, psshb,  pemp, pssha, pe3ta )
-      !!----------------------------------------------------------------------
-      !!                ***  ROUTINE dta_dyn_wzv  ***
-      !!                   
-      !! ** Purpose :   compute the after ssh (ssh(:,:,Kaa)) and the now vertical velocity
-      !!
-      !! ** Method  : Using the incompressibility hypothesis, 
-      !!        - the ssh increment is computed by integrating the horizontal divergence 
-      !!          and multiply by the time step.
-      !!
-      !!        - compute the after scale factor : repartition of ssh INCREMENT proportionnaly
-      !!                                           to the level thickness ( z-star case )
-      !!
-      !!        - the vertical velocity is computed by integrating the horizontal divergence  
-      !!          from the bottom to the surface minus the scale factor evolution.
-      !!          The boundary conditions are w=0 at the bottom (no flux)
-      !!
-      !! ** action  :   ssh(:,:,Kaa) / e3t(:,:,k,Kaa) / ww
-      !!
-      !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
-      !!----------------------------------------------------------------------
-      INTEGER,                                   INTENT(in )    :: kt        !  time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk)          , INTENT(in )   :: phdivtr   ! horizontal divergence transport
-      REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(in )   :: psshb     ! now ssh
-      REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(in )   :: pemp      ! evaporation minus precipitation
-      REAL(wp), DIMENSION(jpi,jpj)    , OPTIONAL, INTENT(inout) :: pssha     ! after ssh
-      REAL(wp), DIMENSION(jpi,jpj,jpk), OPTIONAL, INTENT(out)   :: pe3ta     ! after vertical scale factor
-      !
-      INTEGER                       :: jk
-      REAL(wp), DIMENSION(jpi,jpj)  :: zhdiv  
-      REAL(wp)  :: z2dt  
-      !!----------------------------------------------------------------------
-      !
-      z2dt = 2._wp * rn_Dt
-      !
-      zhdiv(:,:) = 0._wp
-      DO jk = 1, jpkm1
-         zhdiv(:,:) = zhdiv(:,:) +  phdivtr(:,:,jk) * tmask(:,:,jk)
-      END DO
-      !                                                ! Sea surface  elevation time-stepping
-      pssha(:,:) = ( psshb(:,:) - z2dt * ( r1_rho0 * pemp(:,:)  + zhdiv(:,:) ) ) * ssmask(:,:)
-      !
-      IF( PRESENT( pe3ta ) ) THEN                      ! After acale factors at t-points ( z_star coordinate )
-      DO jk = 1, jpkm1
-            pe3ta(:,:,jk) = e3t_0(:,:,jk) * ( 1._wp + pssha(:,:) * r1_ht_0(:,:) * tmask(:,:,jk) )
-      END DO
-      ENDIF
-      !
-   END SUBROUTINE dta_dyn_ssh
-
-
-   SUBROUTINE dta_dyn_hrnf( Kmm )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE sbc_rnf  ***
+   END SUBROUTINE dta_dyn_rnf_init
+
+   SUBROUTINE dta_dyn_rnf( Kmm )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn_rnf  ***
       !!
       !! ** Purpose :   update the horizontal divergence with the runoff inflow
       !!
-      !! ** Method  :
-      !!                CAUTION : rnf is positive (inflow) decreasing the
-      !!                          divergence and expressed in m/s
-      !!
-      !! ** Action  :   phdivn   decreased by the runoff inflow
       !!----------------------------------------------------------------------
       !!
@@ -697,7 +559,5 @@
       END_2D
       !
-   END SUBROUTINE dta_dyn_hrnf
-
-
+   END SUBROUTINE dta_dyn_rnf
 
    SUBROUTINE dta_dyn_slp( kt, Kbb, Kmm )
@@ -790,5 +650,4 @@
    END SUBROUTINE dta_dyn_slp
 
-
    SUBROUTINE compute_slopes( kt, pts, puslp, pvslp, pwslpi, pwslpj, Kbb, Kmm )
       !!---------------------------------------------------------------------
@@ -835,4 +694,121 @@
    END SUBROUTINE compute_slopes
 
+#if defined key_sed_off
+
+   SUBROUTINE dta_dyn_sed( kt, Kmm )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn  ***
+      !!
+      !! ** Purpose :  Prepares dynamics and physics fields from a NEMO run
+      !!               for an off-line simulation of passive tracers
+      !!
+      !! ** Method : calculates the position of data
+      !!             - computes slopes if needed
+      !!             - interpolates data if needed
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      INTEGER, INTENT(in) ::   Kmm  ! ocean time level index
+      !
+      !!----------------------------------------------------------------------
+      !
+      IF( ln_timing )   CALL timing_start( 'dta_dyn_sed')
+      !
+      nsecdyn = nsec_year + nsec1jan000   ! number of seconds between Jan. 1st 00h of nit000 year and the middle of time step
+      !
+      IF( kt == nit000 ) THEN    ;    nprevrec = 0
+      ELSE                       ;    nprevrec = sf_dyn(jf_tem)%nrec(2,sf_dyn(jf_tem)%naa)
+      ENDIF
+      CALL fld_read( kt, 1, sf_dyn )      !=  read data at kt time step   ==!
+      !
+      ts(:,:,:,jp_tem,Kmm) = sf_dyn(jf_tem)%fnow(:,:,:)  * tmask(:,:,:)    ! temperature
+      ts(:,:,:,jp_sal,Kmm) = sf_dyn(jf_sal)%fnow(:,:,:)  * tmask(:,:,:)    ! salinity
+      !
+      CALL eos    ( ts(:,:,:,:,Kmm), rhd, rhop, gdept_0(:,:,:) ) ! In any case, we need rhop
+
+      IF(sn_cfctl%l_prtctl) THEN                     ! print control
+         CALL prt_ctl(tab3d_1=ts(:,:,:,jp_tem,Kmm), clinfo1=' tn      - : ', mask1=tmask,  kdim=jpk   )
+         CALL prt_ctl(tab3d_1=ts(:,:,:,jp_sal,Kmm), clinfo1=' sn      - : ', mask1=tmask,  kdim=jpk   )
+      ENDIF
+      !
+      IF( ln_timing )   CALL timing_stop( 'dta_dyn_sed')
+      !
+   END SUBROUTINE dta_dyn_sed
+
+
+   SUBROUTINE dta_dyn_sed_init( Kmm )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dta_dyn_init  ***
+      !!
+      !! ** Purpose :   Initialisation of the dynamical data
+      !! ** Method  : - read the data namdta_dyn namelist
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT( in ) :: Kmm                   ! ocean time level index
+      !
+      INTEGER  :: ierr, ierr0, ierr1, ierr2, ierr3   ! return error code
+      INTEGER  :: ifpr                               ! dummy loop indice
+      INTEGER  :: jfld                               ! dummy loop arguments
+      INTEGER  :: inum, idv, idimv                   ! local integer
+      INTEGER  :: ios                                ! Local integer output status for namelist read
+      !!
+      CHARACTER(len=100)            ::  cn_dir        !   Root directory for location of core files
+      TYPE(FLD_N), DIMENSION(2) ::  slf_d         ! array of namelist informations on the fields to read
+      TYPE(FLD_N) :: sn_tem , sn_sal   !   "                 "
+      !!
+      NAMELIST/namdta_dyn/cn_dir, ln_dynrnf, ln_dynrnf_depth,  &
+         &                sn_tem, sn_sal
+      !!----------------------------------------------------------------------
+      !
+      READ  ( numnam_ref, namdta_dyn, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namdta_dyn in reference namelist' )
+      READ  ( numnam_cfg, namdta_dyn, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namdta_dyn in configuration namelist' )
+      IF(lwm) WRITE ( numond, namdta_dyn )
+      !                                         ! store namelist information in an array
+      !                                         ! Control print
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dta_dyn : offline dynamics '
+         WRITE(numout,*) '~~~~~~~ '
+         WRITE(numout,*) '   Namelist namdta_dyn'
+         WRITE(numout,*) '      runoffs option enabled (T) or not (F)            ln_dynrnf        = ', ln_dynrnf
+         WRITE(numout,*) '      runoffs is spread in vertical                    ln_dynrnf_depth  = ', ln_dynrnf_depth
+         WRITE(numout,*)
+      ENDIF
+      !
+      jf_tem  = 1     ;   jf_sal  = 2    ;   jfld   = jf_sal
+      !
+      slf_d(jf_tem)  = sn_tem    ;   slf_d(jf_sal)  = sn_sal
+      !
+      ALLOCATE( sf_dyn(jfld), STAT=ierr )         ! set sf structure
+      IF( ierr > 0 )  THEN
+         CALL ctl_stop( 'dta_dyn: unable to allocate sf structure' )   ;   RETURN
+      ENDIF
+      !                                         ! fill sf with slf_i and control print
+      CALL fld_fill( sf_dyn, slf_d, cn_dir, 'dta_dyn_init', 'Data in file', 'namdta_dyn' )
+      !
+      ! Open file for each variable to get his number of dimension
+      DO ifpr = 1, jfld
+         CALL fld_def( sf_dyn(ifpr) )
+         CALL iom_open( sf_dyn(ifpr)%clname, sf_dyn(ifpr)%num )
+         idv   = iom_varid( sf_dyn(ifpr)%num , slf_d(ifpr)%clvar )        ! id of the variable sdjf%clvar
+         idimv = iom_file ( sf_dyn(ifpr)%num )%ndims(idv)                 ! number of dimension for variable sdjf%clvar
+         CALL iom_close( sf_dyn(ifpr)%num )                               ! close file if already open
+         ierr1=0
+         IF( idimv == 3 ) THEN    ! 2D variable
+                                      ALLOCATE( sf_dyn(ifpr)%fnow(jpi,jpj,1)    , STAT=ierr0 )
+            IF( slf_d(ifpr)%ln_tint ) ALLOCATE( sf_dyn(ifpr)%fdta(jpi,jpj,1,2)  , STAT=ierr1 )
+         ELSE                     ! 3D variable
+                                      ALLOCATE( sf_dyn(ifpr)%fnow(jpi,jpj,jpk)  , STAT=ierr0 )
+            IF( slf_d(ifpr)%ln_tint ) ALLOCATE( sf_dyn(ifpr)%fdta(jpi,jpj,jpk,2), STAT=ierr1 )
+         ENDIF
+         IF( ierr0 + ierr1 > 0 ) THEN
+            CALL ctl_stop( 'dta_dyn_init : unable to allocate sf_dyn array structure' )   ;   RETURN
+         ENDIF
+      END DO
+      !
+      CALL dta_dyn_sed( nit000, Kmm )
+      !
+   END SUBROUTINE dta_dyn_sed_init
+#endif
    !!======================================================================
 END MODULE dtadyn
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OFF/nemogcm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OFF/nemogcm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OFF/nemogcm.F90	(revision 14644)
@@ -57,5 +57,5 @@
    USE mppini         ! shared/distributed memory setting (mpp_init routine)
    USE lib_mpp        ! distributed memory computing
-#if defined key_iomput
+#if defined key_xios
    USE xios           ! xIOserver
 #endif 
@@ -77,5 +77,5 @@
 
    CHARACTER (len=64) ::   cform_aaa="( /, 'AAAAAAAA', / ) "   ! flag for output listing
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    ! need MPI_Wtime
    INCLUDE 'mpif.h'
@@ -138,10 +138,6 @@
          IF( istp /= nit000 )   CALL day        ( istp )         ! Calendar (day was already called at nit000 in day_init)
                                 CALL iom_setkt  ( istp - nit000 + 1, cxios_context )   ! say to iom that we are at time step kstp
-#if defined key_sed_off
-                                CALL dta_dyn_sed( istp,      Nnn      )       ! Interpolation of the dynamical fields
-#else
+#if ! defined key_sed_off
                                 CALL dta_dyn    ( istp, Nbb, Nnn, Naa )       ! Interpolation of the dynamical fields
-#endif
-#if ! defined key_sed_off
          IF( .NOT.ln_linssh ) THEN
                                 CALL dta_dyn_atf( istp, Nbb, Nnn, Naa )       ! time filter of sea  surface height and vertical scale factors
@@ -151,21 +147,18 @@
          ENDIF
                                 CALL trc_stp    ( istp, Nbb, Nnn, Nrhs, Naa ) ! time-stepping
-# if defined key_qco
-                                !r3t(:,:,Nnn) = r3t_f(:,:)                     ! update ssh to h0 ratio
-                                !r3u(:,:,Nnn) = r3u_f(:,:)
-                                !r3v(:,:,Nnn) = r3v_f(:,:)
-# endif
-#endif
          ! Swap time levels
          Nrhs = Nbb
-         Nbb = Nnn
-         Nnn = Naa
-         Naa = Nrhs
+         Nbb  = Nnn
+         Nnn  = Naa
+         Naa  = Nrhs
          !
 #if ! defined key_qco
-# if ! defined key_sed_off
          IF( .NOT.ln_linssh )   CALL dta_dyn_sf_interp( istp, Nnn )  ! calculate now grid parameters
-# endif
-#endif         
+#endif  
+
+#else
+                                CALL dta_dyn_sed( istp,      Nnn      )       ! Interpolation of the dynamical fields
+
+#endif
          CALL stp_ctl    ( istp )             ! Time loop: control and print
          istp = istp + 1
@@ -175,5 +168,5 @@
       END DO
       !
-#if defined key_iomput
+#if defined key_xios
       CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
 #endif
@@ -194,5 +187,5 @@
       CALL nemo_closefile
       !
-#if defined key_iomput
+#if defined key_xios
                      CALL xios_finalize   ! end mpp communications with xios
 #else
@@ -230,5 +223,5 @@
       !                             !-------------------------------------------------!
       !
-#if defined key_iomput
+#if defined key_xios
       CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
       CALL mpp_start( ilocal_comm )
@@ -316,7 +309,7 @@
       !
       IF( ln_read_cfg ) THEN              ! Read sizes in domain configuration file
-         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ELSE                                ! user-defined namelist
-         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ENDIF
       !
@@ -456,5 +449,5 @@
       !!                     ***  ROUTINE nemo_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!
       !! ** Method  :
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAO/nemogcm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAO/nemogcm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAO/nemogcm.F90	(revision 14644)
@@ -35,5 +35,5 @@
    USE lbcnfd  , ONLY : isendto, nsndto ! Setup of north fold exchanges 
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-#if defined key_iomput
+#if defined key_xios
    USE xios           ! xIOserver
 #endif
@@ -107,5 +107,5 @@
       !                             !-------------------------------------------------!
       !
-#if defined key_iomput
+#if defined key_xios
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
@@ -207,7 +207,7 @@
       !
       IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
-         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ELSE                              ! user-defined namelist
-         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ENDIF
       !
@@ -323,5 +323,5 @@
       !!                     ***  ROUTINE nemo_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!
       !! ** Method  :
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/diawri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/diawri.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/diawri.F90	(revision 14644)
@@ -52,5 +52,5 @@
    PUBLIC   dia_wri_state
    PUBLIC   dia_wri_alloc           ! Called by nemogcm module
-#if ! defined key_iomput   
+#if ! defined key_xios   
    PUBLIC   dia_wri_alloc_abl       ! Called by sbcabl  module (if ln_abl = .true.)
 #endif
@@ -71,7 +71,7 @@
 CONTAINS
 
-# if defined key_iomput
-   !!----------------------------------------------------------------------
-   !!   'key_iomput'                                        use IOM library
+# if defined key_xios
+   !!----------------------------------------------------------------------
+   !!   'key_xios'                                        use IOM library
    !!----------------------------------------------------------------------
    INTEGER FUNCTION dia_wri_alloc()
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/nemogcm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/nemogcm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/nemogcm.F90	(revision 14644)
@@ -42,5 +42,5 @@
    USE lbcnfd  , ONLY : isendto, nsndto ! Setup of north fold exchanges
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-#if defined key_iomput
+#if defined key_xios
    USE xios           ! xIOserver
 #endif
@@ -58,5 +58,5 @@
    CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    ! need MPI_Wtime
    INCLUDE 'mpif.h'
@@ -185,5 +185,5 @@
       CALL nemo_closefile
       !
-#if defined key_iomput
+#if defined key_xios
                                     CALL xios_finalize  ! end mpp communications with xios
       IF( lk_oasis     )            CALL cpl_finalize   ! end coupling and mpp communications with OASIS
@@ -228,5 +228,5 @@
       !                             !-------------------------------------------------!
       !
-#if defined key_iomput
+#if defined key_xios
       IF( Agrif_Root() ) THEN
          IF( lk_oasis ) THEN
@@ -340,7 +340,7 @@
       !
       IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
-         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ELSE                              ! user-defined namelist
-         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ENDIF
       !
@@ -391,5 +391,5 @@
 
       ! ==> clem: open boundaries init. is mandatory for sea-ice because ice BDY is not decoupled from  
-      !           the environment of ocean BDY. Therefore bdy is called in both OPA and SAS modules. 
+      !           the environment of ocean BDY. Therefore bdy is called in both OCE and SAS modules. 
       !           This is not clean and should be changed in the future. 
                            CALL bdy_init
@@ -489,5 +489,5 @@
       !!                     ***  ROUTINE nemo_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!
       !! ** Method  :
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/sbcssm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/sbcssm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/sbcssm.F90	(revision 14644)
@@ -102,8 +102,18 @@
                e3t_m(:,:) = e3t_0(:,:,1)                                 ! vertical scale factor
             ENDIF
+            IF( TRIM(sf_ssm_2d(jf_usp)%clrootname) == 'NOT USED' ) &
+               &     sf_ssm_2d(jf_usp)%fnow(:,:,1) = 0._wp
+            IF( TRIM(sf_ssm_2d(jf_vsp)%clrootname) == 'NOT USED' ) &
+               &     sf_ssm_2d(jf_vsp)%fnow(:,:,1) = 0._wp
             ssu_m(:,:) = sf_ssm_2d(jf_usp)%fnow(:,:,1) * umask(:,:,1)    ! u-velocity
             ssv_m(:,:) = sf_ssm_2d(jf_vsp)%fnow(:,:,1) * vmask(:,:,1)    ! v-velocity
          ENDIF
          !
+         IF( TRIM(sf_ssm_2d(jf_sal)%clrootname) == 'NOT USED' ) &
+            &     sf_ssm_2d(jf_sal)%fnow(:,:,1) = 35._wp
+         IF( TRIM(sf_ssm_2d(jf_tem)%clrootname) == 'NOT USED' ) &
+            &     CALL eos_fzp( sf_ssm_2d(jf_sal)%fnow(:,:,1), sf_ssm_2d(jf_tem)%fnow(:,:,1) )
+         IF( TRIM(sf_ssm_2d(jf_ssh)%clrootname) == 'NOT USED' ) &
+            &     sf_ssm_2d(jf_ssh)%fnow(:,:,1) = 0._wp
          sst_m(:,:) = sf_ssm_2d(jf_tem)%fnow(:,:,1) * tmask(:,:,1)    ! temperature
          sss_m(:,:) = sf_ssm_2d(jf_sal)%fnow(:,:,1) * tmask(:,:,1)    ! salinity
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/step.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/step.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/step.F90	(revision 14644)
@@ -12,5 +12,5 @@
 
    !!----------------------------------------------------------------------
-   !!   stp             : OPA system time-stepping
+   !!   stp             : OCE system time-stepping
    !!----------------------------------------------------------------------
    USE oce              ! ocean dynamics and tracers variables
@@ -32,5 +32,5 @@
    USE lbclnk           !
    USE timing           ! Timing            
-#if defined key_iomput
+#if defined key_xios
    USE xios
 #endif
@@ -84,5 +84,5 @@
       ENDIF
       IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
-# if defined key_iomput
+# if defined key_xios
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
 # endif   
@@ -111,5 +111,5 @@
 
       ! ==> clem: open boundaries is mandatory for sea-ice because ice BDY is not decoupled from  
-      !           the environment of ocean BDY. Therefore bdy is called in both OPA and SAS modules.
+      !           the environment of ocean BDY. Therefore bdy is called in both OCE and SAS modules.
       !           From SAS: ocean bdy data are wrong  (but we do not care) and ice bdy data are OK.  
       !           This is not clean and should be changed in the future. 
@@ -156,5 +156,5 @@
       IF( lk_oasis .AND. nstop == 0 ) CALL sbc_cpl_snd( kstp, Nbb, Nnn )       ! coupled mode : field exchanges if OASIS-coupled ice
 
-#if defined key_iomput
+#if defined key_xios
       IF( kstp == nitrst ) THEN
          IF(.NOT.lwxios) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/stpctl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/stpctl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SAS/stpctl.F90	(revision 14644)
@@ -34,6 +34,7 @@
    PUBLIC stp_ctl           ! routine called by step.F90
 
-   INTEGER                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(3)  ::   nvarid   ! netcdf variable id
+   INTEGER, PARAMETER         ::   jpvar = 3
+   INTEGER                    ::   nrunid   ! netcdf file id
+   INTEGER, DIMENSION(jpvar)  ::   nvarid   ! netcdf variable id
    !!----------------------------------------------------------------------
    !! NEMO/SAS 4.0 , NEMO Consortium (2018)
@@ -46,5 +47,5 @@
       !!----------------------------------------------------------------------
       !!                    ***  ROUTINE stp_ctl  ***
-      !!                     
+      !!
       !! ** Purpose :   Control the run
       !!
@@ -62,10 +63,12 @@
       INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index
       !!
+      INTEGER, PARAMETER              ::   jptst = 3
       INTEGER                         ::   ji                                    ! dummy loop indices
       INTEGER                         ::   idtime, istatus
-      INTEGER , DIMENSION(4)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,3)        ::   iloc                                  ! min/max loc indices
+      INTEGER , DIMENSION(jptst)      ::   iareasum, iareamin, iareamax
+      INTEGER , DIMENSION(3,jptst)    ::   iloc                                  ! min/max loc indices
       REAL(wp)                        ::   zzz                                   ! local real 
-      REAL(wp), DIMENSION(4)          ::   zmax, zmaxlocal
+      REAL(wp), DIMENSION(jpvar+1)    ::   zmax
+      REAL(wp), DIMENSION(jptst)      ::   zmaxlocal
       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
       LOGICAL, DIMENSION(jpi,jpj)     ::   llmsk
@@ -75,5 +78,5 @@
       !
       ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
-      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1 
+      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1
       ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm
       !
@@ -107,5 +110,5 @@
             istatus = NF90_ENDDEF(nrunid)
          ENDIF
-         !    
+         !
       ENDIF
       !
@@ -119,8 +122,8 @@
       !                                   !==  done by all processes at every time step  ==!
       !
-      llmsk(   1:Nis1,:) = .FALSE.                                              ! exclude halos from the checked region
-      llmsk(Nie1: jpi,:) = .FALSE.
-      llmsk(:,   1:Njs1) = .FALSE.
-      llmsk(:,Nje1: jpj) = .FALSE.
+      llmsk(     1:nn_hls,:) = .FALSE.                                          ! exclude halos from the checked region
+      llmsk(Nie0+1:   jpi,:) = .FALSE.
+      llmsk(:,     1:nn_hls) = .FALSE.
+      llmsk(:,Nje0+1:   jpj) = .FALSE.
       !
       llmsk(Nis0:Nie0,Njs0:Nje0) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp        ! test only the inner domain
@@ -131,15 +134,15 @@
       zmax(2) = MAXVAL( ABS( u_ice(:,:) )    , mask = llmsk )                   ! max ice velocity (zonal only)
       zmax(3) = MAXVAL(     -tm_i (:,:) + rt0, mask = llmsk )                   ! min ice temperature (in degC)
-      zmax(4) = REAL( nstop, wp )                                               ! stop indicator
+      zmax(jpvar+1) = REAL( nstop, wp )                                         ! stop indicator
       !
       !                                   !==               get global extrema             ==!
       !                                   !==  done by all processes if writting run.stat  ==!
       IF( ll_colruns ) THEN
-         zmaxlocal(:) = zmax(:)
+         zmaxlocal(:) = zmax(1:jptst)
          CALL mpp_max( "stpctl", zmax )          ! max over the global domain: ok even of ll_0oce = .true.
-         nstop = NINT( zmax(4) )                 ! update nstop indicator (now sheared among all local domains)
+         nstop = NINT( zmax(jpvar+1) )           ! update nstop indicator (now sheared among all local domains)
       ELSE
          ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow.
-         IF( ll_0oce )   zmax(1:3) = 0._wp       ! default "valid" values...
+         IF( ll_0oce )   zmax(1:jptst) = 0._wp        ! default "valid" values...
       ENDIF
       !
@@ -150,6 +153,6 @@
       !                                   !==  done only by 1st subdomain at writting timestep  ==!
       IF( ll_wrtruns ) THEN
-         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3)
-         DO ji = 1, 3
+         WRITE(numrun,9500) kt, zmax(1:jptst)
+         DO ji = 1, jpvar
             istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
          END DO
@@ -159,9 +162,9 @@
       !                                   !==  done by all processes at every time step  ==!
       !
-      IF(   zmax(1) >  100._wp .OR.   &                   ! too large ice thickness maximum ( > 100 m)
-         &  zmax(2) >   10._wp .OR.   &                   ! too large ice velocity ( > 10 m/s)
-         &  zmax(3) < -101._wp .OR.   &                   ! too cold ice temperature ( < -100 degC)
-         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests
-         &  ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
+      IF(   zmax(1) >  100._wp .OR.   &                       ! too large ice thickness maximum ( > 100 m)
+         &  zmax(2) >   10._wp .OR.   &                       ! too large ice velocity ( > 10 m/s)
+         &  zmax(3) < -101._wp .OR.   &                       ! too cold ice temperature ( < -100 degC)
+         & ISNAN( SUM(zmax(1:jptst)) ) .OR.   &               ! NaN encounter in the tests
+         & ABS(   SUM(zmax(1:jptst)) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
          !
          iloc(:,:) = 0
@@ -175,5 +178,5 @@
             ! find which subdomain has the max.
             iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 4
+            DO ji = 1, jptst
                IF( zmaxlocal(ji) == zmax(ji) ) THEN
                   iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1
@@ -188,5 +191,5 @@
             iloc(1:2,2) = MAXLOC( ABS( u_ice(:,:) )    , mask = llmsk )
             iloc(1:2,3) = MINLOC(       tm_i(:,:) - rt0, mask = llmsk )
-            DO ji = 1, 3   ! local domain indices ==> global domain indices, excluding halos
+            DO ji = 1, jptst   ! local domain indices ==> global domain indices, excluding halos
                iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /)
             END DO
@@ -206,5 +209,5 @@
          CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file
          !
-         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
+         IF( ll_colruns .OR. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
             IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 )
             ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
@@ -247,5 +250,5 @@
       !!----------------------------------------------------------------------
       WRITE(clkt , '(i9)') kt
-      
+
       WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij  ,wp))) + 1     ! how many digits to we need to write ? (we decide max = 9)
       !!! WRITE(clsum, '(i'//clfmt//')') ksum                   ! this is creating a compilation error with AGRIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/nemogcm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/nemogcm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/nemogcm.F90	(revision 14644)
@@ -44,5 +44,5 @@
    CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    ! need MPI_Wtime
    INCLUDE 'mpif.h'
@@ -135,5 +135,5 @@
       CALL nemo_closefile
       !
-#if defined key_iomput
+#if defined key_xios
                        CALL xios_finalize  ! end mpp communications with xios
 #else
@@ -170,5 +170,5 @@
       !                             !-------------------------------------------------!
       !
-#if defined key_iomput
+#if defined key_xios
       CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
       CALL mpp_start( ilocal_comm )
@@ -261,7 +261,7 @@
       !
       IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
-         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ELSE                              ! user-defined namelist
-         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ENDIF
       !
@@ -413,5 +413,5 @@
       !!                     ***  ROUTINE nemo_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!
       !! ** Method  :
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stp_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stp_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stp_oce.F90	(revision 14644)
@@ -93,5 +93,5 @@
    !                                                   (dyn_asm_inc routine)
    USE asmbkg          ! writing out state trajectory
-   USE stpctl          ! time stepping control            (stp_ctl_SWE routine)
+   USE stpctl          ! time stepping control            (stp_ctl routine)
    USE restart         ! ocean restart                    (rst_wri routine)
    USE prtctl          ! Print control                    (prt_ctl routine)
@@ -102,5 +102,5 @@
    USE timing          ! Timing
 
-#if defined key_iomput
+#if defined key_xios
    USE xios            ! I/O server
 #endif
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpctl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpctl.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpctl.F90	(revision 14644)
@@ -0,0 +1,281 @@
+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
+   !!            3.7  ! 2016-09  (G. Madec)  Remove solver
+   !!            4.0  ! 2017-04  (G. Madec)  regroup global communications
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   stp_ctl      : Control the run
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers variables
+   USE dom_oce         ! ocean space and time domain variables 
+   !  
+   USE diawri          ! Standard run outputs       (dia_wri_state routine)
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distributed memory computing
+   !
+   USE netcdf          ! NetCDF library
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC stp_ctl           ! routine called by step.F90
+
+   INTEGER, PARAMETER         ::   jpvar = 2
+   INTEGER                    ::   nrunid   ! netcdf file id
+   INTEGER, DIMENSION(jpvar)  ::   nvarid   ! netcdf variable id
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: stpctl.F90 14143 2020-12-09 21:26:04Z techene $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE stp_ctl( kt, Kmm )
+      !!----------------------------------------------------------------------
+      !!                    ***  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 encountered by setting nstop > 0
+      !!                Problems checked: e3t0+ssh minimum smaller that 0
+      !!                                  |U|   maximum larger than 10 m/s 
+      !!                                  ( not for SWE : negative sea surface salinity )
+      !!
+      !! ** Actions :   "time.step" file = last ocean time-step
+      !!                "run.stat"  file = run statistics
+      !!                 nstop indicator sheared among all local domain
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
+      INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index
+      !!
+      INTEGER, PARAMETER              ::   jptst = 2
+      INTEGER                         ::   ji                                    ! dummy loop indices
+      INTEGER                         ::   idtime, istatus
+      INTEGER , DIMENSION(jptst)      ::   iareasum, iareamin, iareamax
+      INTEGER , DIMENSION(3,jptst)    ::   iloc                                  ! min/max loc indices
+      REAL(wp)                        ::   zzz                                   ! local real 
+      REAL(wp), DIMENSION(jpvar+1)    ::   zmax
+      REAL(wp), DIMENSION(jptst)      ::   zmaxlocal
+      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
+      LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk
+      CHARACTER(len=20)               ::   clname
+      !!----------------------------------------------------------------------
+      !
+      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid
+      !
+      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend )
+      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1
+      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm
+      !
+      IF( kt == nit000 ) THEN
+         !
+         IF( lwp ) THEN
+            WRITE(numout,*)
+            WRITE(numout,*) 'stp_ctl : time-stepping control'
+            WRITE(numout,*) '~~~~~~~'
+         ENDIF
+         !                                ! open time.step    ascii file, done only by 1st subdomain
+         IF( lwm )   CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+         !
+         IF( ll_wrtruns ) THEN
+            !                             ! open run.stat     ascii file, done only by 1st subdomain
+            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
+            !                             ! open run.stat.nc netcdf file, done only by 1st subdomain
+            clname = 'run.stat.nc'
+            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname)
+            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid )
+            istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime )
+            istatus = NF90_DEF_VAR( nrunid, 'e3t0ssh_min', NF90_DOUBLE, (/ idtime /), nvarid(1) )
+            istatus = NF90_DEF_VAR( nrunid,   'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) )
+            istatus = NF90_ENDDEF(nrunid)
+         ENDIF
+         !
+      ENDIF
+      !
+      !                                   !==              write current time step              ==!
+      !                                   !==  done only by 1st subdomain at writting timestep  ==!
+      IF( lwm .AND. ll_wrtstp ) THEN
+         WRITE ( numstp, '(1x, i8)' )   kt
+         REWIND( numstp )
+      ENDIF
+      !                                   !==            test of local extrema           ==!
+      !                                   !==  done by all processes at every time step  ==!
+      !
+      llmsk(     1:nn_hls,:,:) = .FALSE.                                          ! exclude halos from the checked region
+      llmsk(Nie0+1:   jpi,:,:) = .FALSE.
+      llmsk(:,     1:nn_hls,:) = .FALSE.
+      llmsk(:,Nje0+1:   jpj,:) = .FALSE.
+      !
+      llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0) == 1._wp         ! define only the inner domain
+      !
+      ll_0oce = .NOT. ANY( llmsk(:,:,1) )                                         ! no ocean point in the inner domain?
+      !
+      zmax(1) = MAXVAL( -e3t_0(:,:,1)-ssh(:,:,Kmm) , mask = llmsk(:,:,1)  )       ! e3t_Kmm min
+      !
+      llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
+      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) )      , mask = llmsk(:,:,:) )        ! velocity max (zonal only)
+      zmax(jpvar+1) = REAL( nstop, wp )                                           ! stop indicator
+
+      !                                   !==               get global extrema             ==!
+      !                                   !==  done by all processes if writting run.stat  ==!
+      IF( ll_colruns ) THEN
+         zmaxlocal(:) = zmax(1:jptst)
+         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
+         nstop = NINT( zmax(jpvar+1) )           ! update nstop indicator (now sheared among all local domains)
+      ELSE
+         ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow.
+         IF( ll_0oce )   zmax(1:jptst) = 0._wp        ! default "valid" values...
+      ENDIF
+      !
+      zmax(1) = -zmax(1)                              ! move back from max(-zz) to min(zz) : easier to manage!
+      IF( ll_colruns ) zmaxlocal(1) = -zmaxlocal(1)   ! move back from max(-zz) to min(zz) : easier to manage! 
+      !
+      !                                   !==              write "run.stat" files              ==!
+      !                                   !==  done only by 1st subdomain at writting timestep  ==!
+      IF( ll_wrtruns ) THEN
+         WRITE(numrun,9500) kt, zmax(1:jptst)
+         DO ji = 1, jpvar
+            istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
+         END DO
+         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
+      ENDIF
+      !                                   !==               error handling               ==!
+      !                                   !==  done by all processes at every time step  ==!
+      !
+      IF(   zmax(1) <=   0._wp .OR.           &               ! negative e3t_Kmm
+         &  zmax(2) >   10._wp .OR.           &               ! too large velocity ( > 10 m/s)
+         & ISNAN( SUM(zmax(1:jptst)) ) .OR.   &               ! NaN encounter in the tests
+         & ABS(   SUM(zmax(1:jptst)) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
+         !
+         iloc(:,:) = 0
+         IF( ll_colruns ) THEN   ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc
+            ! first: close the netcdf file, so we can read it
+            IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid)
+            ! get global loc on the min/max
+            llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp         ! define only the inner domain
+            CALL mpp_minloc( 'stpctl', e3t_0(:,:,1) + ssh(:,:,Kmm), llmsk(:,:,1), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F
+            llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
+            CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,Kmm))        , llmsk(:,:,:), zzz, iloc(1:3,2) )
+            ! find which subdomain has the max.
+            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
+            DO ji = 1, jptst
+               IF( zmaxlocal(ji) == zmax(ji) ) THEN
+                  iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1
+               ENDIF
+            END DO
+            CALL mpp_min( "stpctl", iareamin )         ! min over the global domain
+            CALL mpp_max( "stpctl", iareamax )         ! max over the global domain
+            CALL mpp_sum( "stpctl", iareasum )         ! sum over the global domain
+         ELSE                    ! find local min and max locations:
+            ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc
+            llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp        ! define only the inner domain
+            iloc(1:2,1) = MINLOC( e3t_0(:,:,1) + ssh(:,:,Kmm), mask = llmsk(:,:,1) )
+            !
+            llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
+            iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask = llmsk(:,:,:) )
+            DO ji = 1, jptst   ! local domain indices ==> global domain indices, excluding halos
+               iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /)
+            END DO
+            iareamin(:) = narea   ;   iareamax(:) = narea   ;   iareasum(:) = 1         ! this is local information
+         ENDIF
+         !
+         WRITE(ctmp1,*) ' stp_ctl:  e3t0+ssh <= 0 m  or  |U| > 10 m/s  or  NaN encounter in the tests'
+         CALL wrt_line( ctmp2, kt, 'e3t0+ssh min',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) )
+         CALL wrt_line( ctmp3, kt, '   |U|   max',  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) )
+         IF( Agrif_Root() ) THEN
+            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files'
+         ELSE
+            WRITE(ctmp6,*) '      ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files'
+         ENDIF
+         !
+         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file
+         !
+         IF( ll_colruns .OR. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
+            IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ' ', ctmp6 )
+            ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
+            ENDIF
+         ELSE                                    ! only mpi subdomains with errors are here -> STOP now
+            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ' ', ctmp6 )
+         ENDIF
+         !
+      ENDIF
+      !
+      IF( nstop > 0 ) THEN                                                  ! an error was detected and we did not abort yet...
+         ngrdstop = Agrif_Fixed()                                           ! store which grid got this error
+         IF( .NOT. ll_colruns .AND. jpnij > 1 )   CALL ctl_stop( 'STOP' )   ! we must abort here to avoid MPI deadlock
+      ENDIF
+      !
+9500  FORMAT(' it :', i8, ' e3t0+ssh_min: ', D23.16, ' |U|_max: ', D23.16)
+      !
+   END SUBROUTINE stp_ctl
+
+
+   SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE wrt_line  ***
+      !!
+      !! ** Purpose :   write information line
+      !!
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*),      INTENT(  out) ::   cdline
+      CHARACTER(len=*),      INTENT(in   ) ::   cdprefix
+      REAL(wp),              INTENT(in   ) ::   pval
+      INTEGER, DIMENSION(3), INTENT(in   ) ::   kloc
+      INTEGER,               INTENT(in   ) ::   kt, ksum, kmin, kmax
+      !
+      CHARACTER(len=80) ::   clsuff
+      CHARACTER(len=9 ) ::   clkt, clsum, clmin, clmax
+      CHARACTER(len=9 ) ::   cli, clj, clk
+      CHARACTER(len=1 ) ::   clfmt
+      CHARACTER(len=4 ) ::   cl4   ! needed to be able to compile with Agrif, I don't know why
+      INTEGER           ::   ifmtk
+      !!----------------------------------------------------------------------
+      WRITE(clkt , '(i9)') kt
+      
+      WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij  ,wp))) + 1     ! how many digits to we need to write ? (we decide max = 9)
+      !!! WRITE(clsum, '(i'//clfmt//')') ksum                   ! this is creating a compilation error with AGRIF
+      cl4 = '(i'//clfmt//')'   ;   WRITE(clsum, cl4) ksum
+      WRITE(clfmt, '(i1)') INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1    ! how many digits to we need to write ? (we decide max = 9)
+      cl4 = '(i'//clfmt//')'   ;   WRITE(clmin, cl4) kmin-1
+                                   WRITE(clmax, cl4) kmax-1
+      !
+      WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1      ! how many digits to we need to write jpiglo? (we decide max = 9)
+      cl4 = '(i'//clfmt//')'   ;   WRITE(cli, cl4) kloc(1)      ! this is ok with AGRIF
+      WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpjglo,wp))) + 1      ! how many digits to we need to write jpjglo? (we decide max = 9)
+      cl4 = '(i'//clfmt//')'   ;   WRITE(clj, cl4) kloc(2)      ! this is ok with AGRIF
+      !
+      IF( ksum == 1 ) THEN   ;   WRITE(clsuff,9100) TRIM(clmin)
+      ELSE                   ;   WRITE(clsuff,9200) TRIM(clsum), TRIM(clmin), TRIM(clmax)
+      ENDIF
+      IF(kloc(3) == 0) THEN
+         ifmtk = INT(LOG10(REAL(jpk,wp))) + 1                   ! how many digits to we need to write jpk? (we decide max = 9)
+         clk = REPEAT(' ', ifmtk)                               ! create the equivalent in blank string
+         WRITE(cdline,9300) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj), clk(1:ifmtk), TRIM(clsuff)
+      ELSE
+         WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1      ! how many digits to we need to write jpk? (we decide max = 9)
+         !!! WRITE(clk, '(i'//clfmt//')') kloc(3)               ! this is creating a compilation error with AGRIF
+         cl4 = '(i'//clfmt//')'   ;   WRITE(clk, cl4) kloc(3)   ! this is ok with AGRIF
+         WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj),    TRIM(clk), TRIM(clsuff)
+      ENDIF
+      !
+9100  FORMAT('MPI rank ', a)
+9200  FORMAT('found in ', a, ' MPI tasks, spread out among ranks ', a, ' to ', a)
+9300  FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j   ', a, ' ', a, ' ', a, ' ', a)
+9400  FORMAT('kt ', a, ' ', a, ' ', 1pg11.4, ' at i j k ', a, ' ', a, ' ', a, ' ', a)
+      !
+   END SUBROUTINE wrt_line
+
+
+   !!======================================================================
+END MODULE stpctl
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpmlf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpmlf.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpmlf.F90	(revision 14644)
@@ -197,6 +197,6 @@
       ENDIF
 
-      CALL lbc_lnk_multi( 'stp_MLF', uu(:,:,:,Nnn), 'U', -1., vv(:,:,:,Nnn), 'V', -1.,   &   !* local domain boundaries
-         &                           uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1.    )     
+      CALL lbc_lnk( 'stp_MLF', uu(:,:,:,Nnn), 'U', -1., vv(:,:,:,Nnn), 'V', -1.,   &   !* local domain boundaries
+         &                     uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1.    )     
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -222,5 +222,5 @@
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL stp_ctl_SWE   ( kstp, Nnn )
+                         CALL stp_ctl  ( kstp, Nnn )
 
       IF( kstp == nit000 ) THEN                          ! 1st time step only
@@ -231,5 +231,5 @@
 
       !
-#if defined key_iomput
+#if defined key_xios
       IF( kstp == nitend .OR. indic < 0 ) THEN
 !!st : cxios_context needed ? because opened earlier ???         
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stprk3.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stprk3.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stprk3.F90	(revision 14644)
@@ -171,5 +171,5 @@
       ENDIF
       !
-      CALL lbc_lnk_multi( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. )
+      CALL lbc_lnk( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. )
       !
       !                                 !==  Swap time levels  ==!
@@ -236,5 +236,5 @@
       ENDIF
       !
-      CALL lbc_lnk_multi( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. )
+      CALL lbc_lnk( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. )
       !
       !                                 !==  Swap time levels  ==!
@@ -299,5 +299,5 @@
       ENDIF
       !
-      CALL lbc_lnk_multi( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. )
+      CALL lbc_lnk( 'stp_RK3', uu(:,:,:,Naa), 'U', -1., vv(:,:,:,Naa), 'V', -1. )
       !
       !                                 !==  Swap time levels  ==!
@@ -319,5 +319,5 @@
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL stp_ctl_SWE  ( kstp     , Nbb )
+                         CALL stp_ctl      ( kstp     , Nbb )
 
       IF( kstp == nit000 ) THEN                          ! 1st time step only
@@ -328,5 +328,5 @@
 
       !
-#if defined key_iomput
+#if defined key_xios
       IF( kstp == nitend .OR. indic < 0 ) THEN 
          CALL iom_context_finalize( cxios_context )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/AGE/trcwri_age.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/AGE/trcwri_age.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/AGE/trcwri_age.F90	(revision 14644)
@@ -6,5 +6,5 @@
    !! History :   1.0  !  2009-05 (C. Ethe)  Original code
    !!----------------------------------------------------------------------
-#if defined key_top &&  defined key_iomput
+#if defined key_top &&  defined key_xios
    !!----------------------------------------------------------------------
    !! trc_wri_age   :  outputs of concentration fields
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/C14/trcwri_c14.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/C14/trcwri_c14.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/C14/trcwri_c14.F90	(revision 14644)
@@ -7,5 +7,5 @@
    !! History :   2.0  !  2015 (A. Mouchet)  adapted code for C14
    !!----------------------------------------------------------------------
-#if defined key_top && defined key_iomput
+#if defined key_top && defined key_xios
    !!----------------------------------------------------------------------
    !! trc_wri_c14   :  outputs of ventilation fields
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/CFC/trcwri_cfc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/CFC/trcwri_cfc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/CFC/trcwri_cfc.F90	(revision 14644)
@@ -6,5 +6,5 @@
    !! History :   1.0  !  2009-05 (C. Ethe)  Original code
    !!----------------------------------------------------------------------
-#if defined key_top && defined key_iomput
+#if defined key_top && defined key_xios
    !!----------------------------------------------------------------------
    !! trc_wri_cfc   :  outputs of concentration fields
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/MY_TRC/trcwri_my_trc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/MY_TRC/trcwri_my_trc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/MY_TRC/trcwri_my_trc.F90	(revision 14644)
@@ -4,5 +4,5 @@
    !!     trc_wri_my_trc   :  outputs of concentration fields
    !!======================================================================
-#if defined key_top && defined key_iomput
+#if defined key_top && defined key_xios
    !!----------------------------------------------------------------------
    !! History :      !  2007  (C. Ethe, G. Madec)  Original code
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P2Z/p2zbio.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P2Z/p2zbio.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P2Z/p2zbio.F90	(revision 14644)
@@ -341,5 +341,5 @@
       IF( lk_iomput ) THEN
          CALL lbc_lnk( 'p2zbio', zw2d(:,:,:),'T', 1.0_wp )
-         CALL lbc_lnk_multi( 'p2zbio', zw3d(:,:,:,1),'T', 1.0_wp, zw3d(:,:,:,2),'T', 1.0_wp, zw3d(:,:,:,3),'T', 1.0_wp )
+         CALL lbc_lnk( 'p2zbio', zw3d(:,:,:,1),'T', 1.0_wp, zw3d(:,:,:,2),'T', 1.0_wp, zw3d(:,:,:,3),'T', 1.0_wp )
          ! Save diagnostics
          CALL iom_put( "TNO3PHY", zw2d(:,:,1) )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P4Z/p4zopt.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P4Z/p4zopt.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/P4Z/p4zopt.F90	(revision 14644)
@@ -236,6 +236,8 @@
       IF( lk_iomput .AND.  knt == nrdttrc ) THEN
          CALL iom_put( "Heup" , heup(:,:  ) * tmask(:,:,1) )  ! euphotic layer deptht
-         CALL iom_put( "PARDM", zpar(:,:,:) * tmask(:,:,:) )  ! Photosynthetically Available Radiation
-         CALL iom_put( "PAR"  , emoy(:,:,:) * tmask(:,:,:) )  ! Photosynthetically Available Radiation
+         IF( iom_use( "PAR" ) ) THEN
+            zpar(:,:,1) = zpar(:,:,1) * ( 1._wp - fr_i(:,:) )
+            CALL iom_put( "PAR", zpar(:,:,:) * tmask(:,:,:) )  ! Photosynthetically Available Radiation
+         ENDIF
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/SED/sedrst.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/SED/sedrst.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/SED/sedrst.F90	(revision 14644)
@@ -84,5 +84,5 @@
             CALL iom_open( TRIM(clpath)//TRIM(clname), numrsw, ldwrt = .TRUE., kdlev = jpksed, cdcomp = 'SED' )
          ELSE
-#if defined key_iomput
+#if defined key_xios
             cw_sedrst_cxt = "rstws_"//TRIM(ADJUSTL(clkt))
             IF( TRIM(Agrif_CFixed()) == '0' ) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/sms_pisces.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/sms_pisces.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/sms_pisces.F90	(revision 14644)
@@ -70,8 +70,4 @@
 
    !!*  Biological fluxes for light : variables shared by pisces & lobster
-   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  neln  !: number of T-levels + 1 in the euphotic layer
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  heup  !: euphotic layer depth
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  etot  !: par (photosynthetic available radiation)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  etot_ndcy      !: PAR over 24h in case of diurnal cycle
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  enano, ediat   !: PAR for phyto, nano and diat 
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  enanom, ediatm !: PAR for phyto, nano and diat 
@@ -79,5 +75,4 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  epicom         !: PAR for pico
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  emoy           !: averaged PAR in the mixed layer
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  heup_01 !: Absolute euphotic layer depth
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  xksi  !:  LOBSTER : zooplakton closure
 
@@ -139,6 +134,5 @@
       ierr(:) = 0
       !*  Biological fluxes for light : shared variables for pisces & lobster
-      ALLOCATE( etot(jpi,jpj,jpk), neln(jpi,jpj), heup(jpi,jpj),    &
-        &       heup_01(jpi,jpj) , xksi(jpi,jpj)               ,  STAT=ierr(1) )
+      ALLOCATE( xksi(jpi,jpj)                                  ,  STAT=ierr(1) )
       !
   
@@ -147,5 +141,5 @@
          ALLOCATE(  enano(jpi,jpj,jpk)    , ediat(jpi,jpj,jpk) ,   &
            &        enanom(jpi,jpj,jpk)   , ediatm(jpi,jpj,jpk),   &
-           &        etot_ndcy(jpi,jpj,jpk), emoy(jpi,jpj,jpk)  ,  STAT=ierr(2) ) 
+           &        emoy(jpi,jpj,jpk)                          ,  STAT=ierr(2) ) 
 
          !*  Biological fluxes for primary production
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/trcwri_pisces.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/trcwri_pisces.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/PISCES/trcwri_pisces.F90	(revision 14644)
@@ -6,5 +6,5 @@
    !! History :   1.0  !  2009-05 (C. Ethe)  Original code
    !!----------------------------------------------------------------------
-#if defined key_top && defined key_iomput 
+#if defined key_top && defined key_xios 
    !!----------------------------------------------------------------------
    !! trc_wri_pisces   :  outputs of concentration fields
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/README.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/README.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/README.rst	(revision 14644)
@@ -62,5 +62,5 @@
 Here below the list of preprocessing keys that applies to the TOP interface (beside ``key_top``):
 
-``key_iomput``
+``key_xios``
    use XIOS I/O
 
@@ -320,5 +320,5 @@
 .. code-block:: perl
 
-   bld::tool::fppkeys key_iomput key_mpp_mpi key_top
+   bld::tool::fppkeys key_xios key_top
 
 the compilation with :file:`makenemo` will be executed through the following syntax
@@ -348,5 +348,5 @@
 .. code-block:: perl
 
-   bld::tool::fppkeys  key_iomput key_mpp_mpi key_top
+   bld::tool::fppkeys  key_xios key_top
 
    src::MYBGC::initialization         <MYBGCPATH>/initialization
@@ -376,5 +376,5 @@
    .. code-block:: perl
 
-      bld::tool::fppkeys  key_zdftke key_dynspg_ts key_iomput key_mpp_mpi key_top
+      bld::tool::fppkeys key_xios key_top
       inc <MYBGCPATH>/MYBGC.fcm
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcadv.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcadv.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcadv.F90	(revision 14644)
@@ -132,6 +132,14 @@
       CASE ( np_FCT )                                 ! FCT      : 2nd / 4th order
          IF (nn_hls.EQ.2) THEN
+<<<<<<< .working
             CALL lbc_lnk_multi( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1._wp, ptr(:,:,:,:,Kmm), 'T', 1._wp)
             CALL lbc_lnk_multi( 'traadv', zuu(:,:,:), 'U', -1._wp, zvv(:,:,:), 'V', -1._wp, zww(:,:,:), 'W', 1._wp)
+||||||| .merge-left.r14199
+            CALL lbc_lnk_multi( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1., ptr(:,:,:,:,Kmm), 'T', 1.)
+            CALL lbc_lnk_multi( 'traadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1., zww(:,:,:), 'W', 1.)
+=======
+            CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1., ptr(:,:,:,:,Kmm), 'T', 1.)
+            CALL lbc_lnk( 'traadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1., zww(:,:,:), 'W', 1.)
+>>>>>>> .merge-right.r14642
 #if defined key_loop_fusion
             CALL tra_adv_fct_lf( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, nn_fct_h, nn_fct_v )
@@ -144,5 +152,11 @@
       CASE ( np_MUS )                                 ! MUSCL
          IF (nn_hls.EQ.2) THEN
+<<<<<<< .working
             IF (nn_hls.EQ.2) CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1._wp)
+||||||| .merge-left.r14199
+            IF (nn_hls.EQ.2) CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1.)
+=======
+            CALL lbc_lnk( 'trcadv', ptr(:,:,:,:,Kbb), 'T', 1.)
+>>>>>>> .merge-right.r14642
 #if defined key_loop_fusion
             CALL tra_adv_mus_lf( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs, ln_mus_ups ) 
@@ -158,6 +172,14 @@
       CASE ( np_QCK )                                 ! QUICKEST
          IF (nn_hls.EQ.2) THEN
+<<<<<<< .working
             CALL lbc_lnk_multi( 'trcadv', zuu(:,:,:), 'U', -1._wp, zvv(:,:,:), 'V', -1._wp)
             CALL lbc_lnk( 'traadv', ptr(:,:,:,:,Kbb), 'T', 1._wp)
+||||||| .merge-left.r14199
+            CALL lbc_lnk_multi( 'trcadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1.)
+            CALL lbc_lnk( 'traadv', ptr(:,:,:,:,Kbb), 'T', 1.)
+=======
+            CALL lbc_lnk( 'trcadv', zuu(:,:,:), 'U', -1., zvv(:,:,:), 'V', -1.)
+            CALL lbc_lnk( 'traadv', ptr(:,:,:,:,Kbb), 'T', 1.)
+>>>>>>> .merge-right.r14642
          END IF
          CALL tra_adv_qck( kt, nittrc000,'TRC', rDt_trc, zuu, zvv, zww, Kbb, Kmm, ptr, jptra, Krhs                     )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcsbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcsbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcsbc.F90	(revision 14644)
@@ -123,5 +123,5 @@
          !
          DO jn = 1, jptra
-            DO_2D( 0, 1, 0, 0 )
+            DO_2D( 0, 0, 0, 1 )
                sbc_trc(ji,jj,jn) = zsfx(ji,jj) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
             END_2D
@@ -131,5 +131,5 @@
          !
          DO jn = 1, jptra
-            DO_2D( 0, 1, 0, 0 )
+            DO_2D( 0, 0, 0, 1 )
                sbc_trc(ji,jj,jn) = ( zsfx(ji,jj) + fmmflx(ji,jj) ) * r1_rho0 * ptr(ji,jj,1,jn,Kmm)
             END_2D
@@ -139,5 +139,5 @@
          !
          DO jn = 1, jptra
-            DO_2D( 0, 1, 0, 0 )
+            DO_2D( 0, 0, 0, 1 )
                zse3t = 1. / e3t(ji,jj,1,Kmm)
                ! tracer flux at the ice/ocean interface (tracer/m2/s)
@@ -163,5 +163,5 @@
          IF( l_trdtrc )   ztrtrd(:,:,:) = ptr(:,:,:,jn,Krhs)  ! save trends
          !
-         DO_2D( 0, 1, 0, 0 )
+         DO_2D( 0, 0, 0, 1 )
             zse3t = zfact / e3t(ji,jj,1,Kmm)
             ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + ( sbc_trc_b(ji,jj,jn) + sbc_trc(ji,jj,jn) ) * zse3t
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trdmxl_trc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trdmxl_trc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trdmxl_trc.F90	(revision 14644)
@@ -419,6 +419,6 @@
          !-- Lateral boundary conditions
                IF ( cn_cfg .NE. 'gyre' ) THEN
-                  CALL lbc_lnk_multi( 'trdmxl_trc', ztmltot(:,:,jn) , 'T', 1._wp , ztmlres(:,:,jn) , 'T', 1._wp, &
-                     &                ztmlatf(:,:,jn) , 'T', 1._wp , ztmlrad(:,:,jn) , 'T', 1._wp )
+                  CALL lbc_lnk( 'trdmxl_trc', ztmltot(:,:,jn) , 'T', 1._wp , ztmlres(:,:,jn) , 'T', 1._wp, &
+                     &                        ztmlatf(:,:,jn) , 'T', 1._wp , ztmlrad(:,:,jn) , 'T', 1._wp )
                ENDIF
 
@@ -470,5 +470,5 @@
          !-- Lateral boundary conditions 
                IF ( cn_cfg .NE. 'gyre' ) THEN            ! other than GYRE configuration    
-                  CALL lbc_lnk_multi( 'trdmxl_trc', ztmltot2(:,:,jn), 'T', 1., ztmlres2(:,:,jn), 'T', 1.)
+                  CALL lbc_lnk( 'trdmxl_trc', ztmltot2(:,:,jn), 'T', 1._wp, ztmlres2(:,:,jn), 'T', 1._wp )
                   DO jl = 1, jpltrd_trc
                      CALL lbc_lnk( 'trdmxl_trc', ztmltrd2(:,:,jl,jn), 'T', 1. )       ! will be output in the NetCDF trends file
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trdtrc_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trdtrc_oce.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trdtrc_oce.F90	(revision 14644)
@@ -24,5 +24,5 @@
    LOGICAL, DIMENSION(:), ALLOCATABLE ::   ln_trdtrc   !: large trends diagnostic to write or not (namelist)
 
-# if defined key_trdtrc && defined key_iomput
+# if defined key_trdtrc && defined key_xios
    LOGICAL, PARAMETER ::   lk_trdtrc = .TRUE. 
 # else
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/oce_trc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/oce_trc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/oce_trc.F90	(revision 14644)
@@ -19,26 +19,10 @@
    USE par_oce , ONLY :   jp_sal   =>   jp_sal     !: indice for salinity
    USE par_oce , ONLY :   nn_hls   =>   nn_hls     !: 
-   USE par_oce , ONLY :   Nis0    =>   Nis0      !: 
-   USE par_oce , ONLY :   Njs0    =>   Njs0      !: 
-   USE par_oce , ONLY :   Nie0    =>   Nie0      !: 
-   USE par_oce , ONLY :   Nje0    =>   Nje0      !: 
-   USE par_oce , ONLY :   Nis1    =>   Nis1      !: 
-   USE par_oce , ONLY :   Njs1    =>   Njs1      !: 
-   USE par_oce , ONLY :   Nie1    =>   Nie1      !: 
-   USE par_oce , ONLY :   Nje1    =>   Nje1      !: 
-   USE par_oce , ONLY :   Nis1nxt2    =>   Nis1nxt2      !: 
-   USE par_oce , ONLY :   Njs1nxt2    =>   Njs1nxt2      !: 
-   USE par_oce , ONLY :   Nie1nxt2    =>   Nie1nxt2      !: 
-   USE par_oce , ONLY :   Nje1nxt2    =>   Nje1nxt2      !: 
-   USE par_oce , ONLY :   Nis2    =>   Nis2      !: 
-   USE par_oce , ONLY :   Njs2    =>   Njs2      !: 
-   USE par_oce , ONLY :   Nie2    =>   Nie2      !: 
-   USE par_oce , ONLY :   Nje2    =>   Nje2      !: 
-   USE par_oce , ONLY :   Ni_0    =>   Ni_0      !: 
-   USE par_oce , ONLY :   Nj_0    =>   Nj_0      !: 
-   USE par_oce , ONLY :   Ni_1    =>   Ni_1      !: 
-   USE par_oce , ONLY :   Nj_1    =>   Nj_1      !: 
-   USE par_oce , ONLY :   Ni_2    =>   Ni_2      !: 
-   USE par_oce , ONLY :   Nj_2    =>   Nj_2      !: 
+   USE par_oce , ONLY :   Nis0     =>   Nis0       !: 
+   USE par_oce , ONLY :   Njs0     =>   Njs0       !: 
+   USE par_oce , ONLY :   Nie0     =>   Nie0       !: 
+   USE par_oce , ONLY :   Nje0     =>   Nje0       !: 
+   USE par_oce , ONLY :   Ni_0     =>   Ni_0       !: 
+   USE par_oce , ONLY :   Nj_0     =>   Nj_0       !: 
 
    USE in_out_manager                           !* IO manager *
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trc.F90	(revision 14644)
@@ -82,4 +82,12 @@
    CHARACTER(len=2), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   cn_trc_o         !: choice of ocean tracer cc
 
+   !! Information for the optics module
+   !! ---------------------------------
+   INTEGER , ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  neln       !: number of T-levels + 1 in the euphotic layer
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  heup       !: euphotic layer depth
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::  heup_01    !: Absolute euphotic layer depth
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  etot       !: par (photosynthetic available radiation)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  etot_ndcy  !: PAR over 24h in case of diurnal cycle
+
 
    !! information for outputs
@@ -156,4 +164,6 @@
          &      gtrui(jpi,jpj,jptra)  , gtrvi(jpi,jpj,jptra)                          ,       &
          &      trc_ice_ratio(jptra)  , trc_ice_prescr(jptra) , cn_trc_o(jptra)       ,       &
+         &      neln(jpi,jpj)         , heup(jpi,jpj)         , heup_01(jpi,jpj)      ,       &
+         &      etot(jpi,jpj,jpk)     , etot_ndcy(jpi,jpj,jpk)                        ,       &
          &      sbc_trc_b(jpi,jpj,jptra), sbc_trc(jpi,jpj,jptra)                      ,       &  
          &      cvol(jpi,jpj,jpk)     , trai(jptra)           , qsr_mean(jpi,jpj)     ,       &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcbc.F90	(revision 14644)
@@ -415,5 +415,5 @@
          ! Remove river dilution for tracers with absent river load
          IF( ln_rnf_ctl .AND. .NOT.ln_trc_cbc(jn) ) THEN
-            DO_2D( 0, 1, 0, 0 )
+            DO_2D( 0, 0, 0, 1 )
                DO jk = 1, nk_rnf(ji,jj)
                   zrnf = (rnf(ji,jj) + rnf_b(ji,jj)) * 0.5_wp * r1_rho0 / h_rnf(ji,jj)
@@ -429,5 +429,5 @@
             jl = n_trc_indsbc(jn)
             sf_trcsbc(jl)%fnow(:,:,1) = MAX( rtrn, sf_trcsbc(jl)%fnow(:,:,1) ) ! avoid nedgative value due to interpolation
-            DO_2D( 0, 1, 0, 0 )
+            DO_2D( 0, 0, 0, 1 )
                zfact = 1. / ( e3t(ji,jj,1,Kmm) * rn_sbc_time )
                ptr(ji,jj,1,jn,Krhs) = ptr(ji,jj,1,jn,Krhs) + rf_trsfac(jl) * sf_trcsbc(jl)%fnow(ji,jj,1) * zfact
@@ -439,5 +439,5 @@
             IF( l_offline )   rn_rfact = 1._wp
             jl = n_trc_indcbc(jn)
-            DO_2D( 0, 1, 0, 0 )
+            DO_2D( 0, 0, 0, 1 )
                DO jk = 1, nk_rnf(ji,jj)
                   zfact = rn_rfact / ( e1e2t(ji,jj) * h_rnf(ji,jj) * rn_cbc_time ) * tmask(ji,jj,1)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcini.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcini.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcini.F90	(revision 14644)
@@ -210,5 +210,5 @@
       !!                     ***  ROUTINE trc_ini_trp  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!----------------------------------------------------------------------
       USE trcdmp , ONLY:  trc_dmp_ini
@@ -282,5 +282,5 @@
       !!                     ***  ROUTINE top_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!----------------------------------------------------------------------
       USE trc           , ONLY:   trc_alloc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcnam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcnam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcnam.F90	(revision 14644)
@@ -31,5 +31,5 @@
    PUBLIC   trc_nam      ! called in trcini
 
-   TYPE(PTRACER), DIMENSION(jpmaxtrc), PUBLIC  :: sn_tracer  !: type of tracer for saving if not key_iomput
+   TYPE(PTRACER), DIMENSION(jpmaxtrc), PUBLIC  :: sn_tracer  !: type of tracer for saving if not key_xios
 
    !!----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcopt.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcopt.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcopt.F90	(revision 14644)
@@ -0,0 +1,359 @@
+MODULE trcopt
+   !!======================================================================
+   !!                         ***  MODULE trcopt  ***
+   !! TOP :   Compute the light in the water column for RGB wavelengths
+   !!======================================================================
+   !! History :  1.0  !  2020     (T. Lovato) Initial code
+   !!----------------------------------------------------------------------
+   !!   trc_opt       : light availability in the water column
+   !!----------------------------------------------------------------------
+   USE trc            ! tracer variables
+   USE oce_trc        ! tracer-ocean share variables
+   USE iom            ! I/O manager
+   USE fldread        ! time interpolation
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   trc_opt       ! called in spefici BGC model routines
+   PUBLIC   trc_opt_ini   ! called in trcini.F90
+   PUBLIC   trc_opt_alloc
+
+   !! * Shared module variables
+
+   LOGICAL  ::   ln_varpar   ! boolean for variable PAR fraction
+   REAL(wp) ::   parlux      ! Fraction of shortwave as PAR
+   CHARACTER (len=25) :: light_loc ! Light location in the water cell ('center', 'integral')
+
+   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_par        ! structure of input par
+   INTEGER                              ::   ntimes_par    ! number of time steps in par file
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   par_varsw      ! PAR fraction of shortwave
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ekb, ekg, ekr  ! wavelength (Red-Green-Blue)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xeps  ! weighted diffusion coefficient
+
+   INTEGER  ::   nksrp   ! levels below which the light cannot penetrate ( depth larger than 391 m)
+
+   ! TL: This array should come directly from traqsr module
+   REAL(wp), DIMENSION(3,61) ::   xkrgb   ! tabulated attenuation coefficients for RGB absorption
+   
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/TOP 4.0 , NEMO Consortium (2020)
+   !! $Id: trcopt.F90 12377 2020-02-12 14:39:06Z acc $ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE trc_opt( kt, knt, Kbb, Kmm, zchl, ze1, ze2, ze3)
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_opt  ***
+      !!
+      !! ** Purpose : Compute the light availability in the water column
+      !!              depending on depth and chlorophyll concentration
+      !!
+      !! ** Method  : Morel
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt, knt   ! ocean time step
+      INTEGER, INTENT(in) ::   Kbb, Kmm  ! time level indices
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in) ::   zchl  ! chlorophyll field
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(out),OPTIONAL :: ze1, ze2, ze3 ! PAR for individual wavelength
+      !
+      INTEGER  ::   ji, jj, jk, irgb
+      REAL(wp) ::   ztmp
+      REAL(wp), DIMENSION(jpi,jpj    ) :: parsw, zqsr100, zqsr_corr
+      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ze0
+      !!---------------------------------------------------------------------
+      !
+      IF( ln_timing )   CALL timing_start('trc_opt')
+
+      !     Initialisation of variables used to compute PAR
+      !     -----------------------------------------------
+      ze0(:,:,:) = 0._wp
+      ze1(:,:,:) = 0._wp
+      ze2(:,:,:) = 0._wp
+      ze3(:,:,:) = 0._wp
+
+      !     PAR conversion factor
+      !     --------------------
+      IF( knt == 1 .AND. ln_varpar )   CALL trc_opt_sbc( kt )
+      !
+      IF( ln_varpar ) THEN  ;  parsw(:,:) = par_varsw(:,:)
+      ELSE                  ;  parsw(:,:) = parlux / 3.0
+      ENDIF
+
+      !     Attenuation coef. function of Chlorophyll and wavelength (RGB)
+      !     --------------------------------------------------------------
+      DO_3D( 1, 1, 1, 1, 1, jpkm1 )
+         ztmp = ( zchl(ji,jj,jk) + rtrn ) * 1.e6
+         ztmp = MIN(  10. , MAX( 0.05, ztmp )  )
+         irgb = NINT( 41 + 20.* LOG10( ztmp ) + rtrn )
+         !                                                         
+         ekb(ji,jj,jk) = xkrgb(1,irgb) * e3t(ji,jj,jk,Kmm)
+         ekg(ji,jj,jk) = xkrgb(2,irgb) * e3t(ji,jj,jk,Kmm)
+         ekr(ji,jj,jk) = xkrgb(3,irgb) * e3t(ji,jj,jk,Kmm)
+      END_3D
+
+      !     Heat flux across w-level (used in the dynamics)
+      !     -----------------------------------------------
+      IF( ln_qsr_bio ) THEN
+         !
+         zqsr_corr(:,:) = parsw(:,:) * qsr(:,:)
+         !
+         ze0(:,:,1) = (1._wp - 3._wp * parsw(:,:)) * qsr(:,:)  !  ( 1 - 3 * alpha ) * q
+         ze1(:,:,1) = zqsr_corr(:,:)
+         ze2(:,:,1) = zqsr_corr(:,:)
+         ze3(:,:,1) = zqsr_corr(:,:)
+         !
+         DO jk = 2, nksrp + 1
+            DO_2D(1, 1, 1, 1)
+                  ze0(ji,jj,jk) = ze0(ji,jj,jk-1) * EXP( -e3t(ji,jj,jk-1,Kmm) * (1. / rn_si0) )
+                  ze1(ji,jj,jk) = ze1(ji,jj,jk-1) * EXP( -ekb  (ji,jj,jk-1 )        )
+                  ze2(ji,jj,jk) = ze2(ji,jj,jk-1) * EXP( -ekg  (ji,jj,jk-1 )        )
+                  ze3(ji,jj,jk) = ze3(ji,jj,jk-1) * EXP( -ekr  (ji,jj,jk-1 )        )
+            END_2D
+         END DO
+         !
+         etot3(:,:,1) = qsr(:,:) * tmask(:,:,1)
+         DO jk = 2, nksrp + 1
+            etot3(:,:,jk) =  ( ze0(:,:,jk) + ze1(:,:,jk) + ze2(:,:,jk) + ze3(:,:,jk) ) * tmask(:,:,jk)
+         END DO
+         !                                     !  ------------------------
+      ENDIF
+
+      !     Photosynthetically Available Radiation (PAR)
+      !     --------------------------------------------
+      zqsr_corr(:,:) = parsw(:,:) * qsr(:,:) / ( 1.-fr_i(:,:) + rtrn )
+      !
+      CALL trc_opt_par( kt, zqsr_corr, ze1, ze2, ze3 )
+      !
+      DO jk = 1, nksrp
+         etot (:,:,jk) = ze1(:,:,jk) + ze2(:,:,jk) + ze3(:,:,jk)
+      ENDDO
+
+      ! No Diurnal cycle PAR
+      IF( l_trcdm2dc ) THEN
+         zqsr_corr(:,:) = parsw(:,:) * qsr_mean(:,:) / ( 1.-fr_i(:,:) + rtrn )
+         !
+         CALL trc_opt_par( kt, zqsr_corr, ze1, ze2, ze3 )
+         DO jk = 1, nksrp
+            etot_ndcy(:,:,jk) = ze1(:,:,jk) + ze2(:,:,jk) + ze3(:,:,jk)
+         END DO
+      ELSE
+         etot_ndcy(:,:,:) = etot(:,:,:)
+      ENDIF
+
+      !     Weighted broadband attenuation coefficient
+      !     ------------------------------------------
+      DO_3D( 1, 1, 1, 1, 1, jpkm1 )
+         ztmp = ze1(ji,jj,jk)* ekb(ji,jj,jk) + ze2(ji,jj,jk) * ekg(ji,jj,jk) + ze3(ji,jj,jk) * ekr(ji,jj,jk)
+         xeps(ji,jj,jk) = ztmp / e3t(ji,jj,jk,Kmm) / (etot(ji,jj,jk) + rtrn)
+      END_3D
+      !xeps = (ze1(:,:,:) * ekb(:,:,:) + ze2(:,:,:) * ekg(:,:,:) + ze3(:,:,:) * ekr(:,:,:)) / e3t(:,:,:,Kmm) / (etot(:,:,:) + rtrn)
+
+      !     Light at the euphotic depth
+      !     ---------------------------
+      zqsr100 = 0.01 * 3. * zqsr_corr(:,:)
+
+      !     Euphotic depth and level
+      !     ------------------------
+      neln   (:,:) = 1
+      heup   (:,:) = gdepw(:,:,2,Kmm)
+      heup_01(:,:) = gdepw(:,:,2,Kmm)
+      !
+      DO_3D( 1, 1, 1, 1, 2, nksrp )
+        IF( etot_ndcy(ji,jj,jk) * tmask(ji,jj,jk) >=  zqsr100(ji,jj) )  THEN
+           ! Euphotic level (1st T-level strictly below Euphotic layer)
+           ! NOTE: ensure compatibility with nmld_trc definition in trdmxl_trc
+           neln(ji,jj) = jk+1
+           !
+           ! Euphotic layer depth
+           heup(ji,jj) = gdepw(ji,jj,jk+1,Kmm)
+        ENDIF
+        ! Euphotic layer depth (light level definition)
+        IF( etot_ndcy(ji,jj,jk) * tmask(ji,jj,jk) >= 0.50 )  THEN
+           heup_01(ji,jj) = gdepw(ji,jj,jk+1,Kmm)
+        ENDIF
+      END_3D
+      !
+      heup   (:,:) = MIN( 300., heup   (:,:) )
+      heup_01(:,:) = MIN( 300., heup_01(:,:) )
+      !
+      IF( lk_iomput ) THEN
+         CALL iom_put( "xeps" , xeps(:,:,:) * tmask(:,:,:) )
+         CALL iom_put( "Heup" , heup(:,:  ) * tmask(:,:,1) )
+      ENDIF
+      !
+      IF( ln_timing )   CALL timing_stop('trc_opt')
+      !
+   END SUBROUTINE trc_opt
+
+
+   SUBROUTINE trc_opt_par( kt, zqsr, pe1, pe2, pe3) 
+      !!----------------------------------------------------------------------
+      !!                  ***  routine trc_opt_par  ***
+      !!
+      !! ** purpose :   compute PAR of each wavelength (Red-Green-Blue)
+      !!                from given surface shortwave radiation
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER                         , INTENT(in)      ::   kt                ! ocean time-step
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in)      ::   zqsr              ! real shortwave
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(out)     ::   pe1 , pe2 , pe3   ! PAR (R-G-B)
+      !
+      INTEGER                       ::   ji, jj, jk        ! dummy loop indices
+      REAL(wp), DIMENSION(jpi,jpj)  ::   we1, we2, we3     ! PAR (R-G-B) at w-level
+      !!----------------------------------------------------------------------
+      pe1(:,:,:) = 0. ; pe2(:,:,:) = 0. ; pe3(:,:,:) = 0.
+      !
+      IF ( TRIM(light_loc) == 'center' ) THEN
+         ! cell-center (t-pivot)
+         pe1(:,:,1) = zqsr(:,:) * EXP( -0.5 * ekb(:,:,1) )
+         pe2(:,:,1) = zqsr(:,:) * EXP( -0.5 * ekg(:,:,1) )
+         pe3(:,:,1) = zqsr(:,:) * EXP( -0.5 * ekr(:,:,1) )
+         !
+         DO_3D( 1, 1, 1, 1, 2, nksrp )
+            pe1(ji,jj,jk) = pe1(ji,jj,jk-1) * EXP( -0.5 * ( ekb(ji,jj,jk-1) + ekb(ji,jj,jk) ) )
+            pe2(ji,jj,jk) = pe2(ji,jj,jk-1) * EXP( -0.5 * ( ekg(ji,jj,jk-1) + ekg(ji,jj,jk) ) )
+            pe3(ji,jj,jk) = pe3(ji,jj,jk-1) * EXP( -0.5 * ( ekr(ji,jj,jk-1) + ekr(ji,jj,jk) ) )
+         END_3D
+         !
+      ELSE IF ( TRIM(light_loc) == 'integral' ) THEN
+         ! integrate over cell thickness
+         we1(:,:) = zqsr(:,:)
+         we2(:,:) = zqsr(:,:)
+         we3(:,:) = zqsr(:,:)
+         !
+         DO_3D( 1, 1, 1, 1, 1, nksrp )
+            ! integrate PAR over current t-level
+            pe1(ji,jj,jk) = we1(ji,jj) / (ekb(ji,jj,jk) + rtrn) * (1. - EXP( -ekb(ji,jj,jk) ))
+            pe2(ji,jj,jk) = we2(ji,jj) / (ekg(ji,jj,jk) + rtrn) * (1. - EXP( -ekg(ji,jj,jk) ))
+            pe3(ji,jj,jk) = we3(ji,jj) / (ekr(ji,jj,jk) + rtrn) * (1. - EXP( -ekr(ji,jj,jk) ))
+            ! PAR at next w-level
+            we1(ji,jj) = we1(ji,jj) * EXP( -ekb(ji,jj,jk) )
+            we2(ji,jj) = we2(ji,jj) * EXP( -ekg(ji,jj,jk) )
+            we3(ji,jj) = we3(ji,jj) * EXP( -ekr(ji,jj,jk) )
+         END_3D
+         !
+      ENDIF 
+      !
+      ! 
+   END SUBROUTINE trc_opt_par
+
+
+   SUBROUTINE trc_opt_sbc( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  routine trc_opt_sbc  ***
+      !!
+      !! ** purpose :   read and interpolate the variable PAR fraction
+      !!                of shortwave radiation
+      !!
+      !! ** method  :   read the files and interpolate the appropriate variables
+      !!
+      !! ** input   :   external netcdf files
+      !!
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !
+      INTEGER  :: ji,jj
+      REAL(wp) :: zcoef
+      !!---------------------------------------------------------------------
+      !
+      IF( ln_timing )  CALL timing_start('trc_opt_sbc')
+      !
+      ! Compute par_varsw at nit000 or only if there is more than 1 time record in par coefficient file
+      IF( ln_varpar ) THEN
+         IF( kt == nit000 .OR. ( kt /= nit000 .AND. ntimes_par > 1 ) ) THEN
+            CALL fld_read( kt, 1, sf_par )
+            par_varsw(:,:) = ( sf_par(1)%fnow(:,:,1) ) / 3.0
+         ENDIF
+      ENDIF
+      !
+      IF( ln_timing )  CALL timing_stop('trc_opt_sbc')
+      !
+   END SUBROUTINE trc_opt_sbc
+
+
+   SUBROUTINE trc_opt_ini
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_opt_ini  ***
+      !!
+      !! ** Purpose :   Initialization of tabulated attenuation coefficients
+      !!                and percentage of PAR in Shortwave
+      !!
+      !! ** Input   :   external ascii and netcdf files
+      !!----------------------------------------------------------------------
+      INTEGER :: numpar, ierr, ios   ! Local integer 
+      !
+      CHARACTER(len=100) ::  cn_dir          ! Root directory for location of ssr files
+      TYPE(FLD_N) ::   sn_par                ! informations about the fields to be read
+      !
+      NAMELIST/namtrc_opt/cn_dir, sn_par, ln_varpar, parlux, light_loc
+      !!----------------------------------------------------------------------
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_opt_ini : Initialize light module'
+         WRITE(numout,*) '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
+      ENDIF
+      READ  ( numnat_ref, namtrc_opt, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtrc_opt in reference namelist' )
+      READ  ( numnat_cfg, namtrc_opt, IOSTAT = ios, ERR = 902 )
+902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtrc_opt in configuration namelist' )
+      IF(lwm) WRITE ( numont, namtrc_opt )
+
+      IF(lwp) THEN
+         WRITE(numout,*) '   Namelist : namtrc_opt '
+         WRITE(numout,*) '      PAR as a variable fraction of SW     ln_varpar      = ', ln_varpar
+         WRITE(numout,*) '      Fraction of shortwave as PAR         parlux         = ', parlux
+         WRITE(numout,*) '      Light location in the water cell     light_loc      = ', light_loc
+      ENDIF
+      !
+      ! Variable PAR at the surface of the ocean
+      ! ----------------------------------------
+      IF( ln_varpar ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) '   ==>>>   initialize variable par fraction (ln_varpar=T)'
+         !
+         ALLOCATE( par_varsw(jpi,jpj) )
+         !
+         ALLOCATE( sf_par(1), STAT=ierr )           !* allocate and fill sf_par (forcing structure) with sn_par
+         IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'trc_opt_ini: unable to allocate sf_par structure' )
+         !
+         CALL fld_fill( sf_par, (/ sn_par /), cn_dir, 'trc_opt_ini', 'Initialize prescribed PAR forcing ', 'namtrc_opt' )
+                                   ALLOCATE( sf_par(1)%fnow(jpi,jpj,1)   )
+         IF( sn_par%ln_tint )      ALLOCATE( sf_par(1)%fdta(jpi,jpj,1,2) )
+
+         CALL iom_open (  TRIM( sn_par%clname ) , numpar )
+         ntimes_par = iom_getszuld( numpar )   ! get number of record in file
+      ENDIF
+      !
+      CALL trc_oce_rgb( xkrgb )                  ! tabulated attenuation coefficients
+      nksrp = trc_oce_ext_lev( r_si2, 0.33e2 )   ! max level of light extinction (Blue Chl=0.01)
+      !
+      IF(lwp) WRITE(numout,*) '        level of light extinction = ', nksrp, ' ref depth = ', gdepw_1d(nksrp+1), ' m'
+      !
+                         ekr      (:,:,:) = 0._wp
+                         ekb      (:,:,:) = 0._wp
+                         ekg      (:,:,:) = 0._wp
+                         etot     (:,:,:) = 0._wp
+                         etot_ndcy(:,:,:) = 0._wp
+      IF( ln_qsr_bio )   etot3    (:,:,:) = 0._wp
+      ! 
+   END SUBROUTINE trc_opt_ini
+
+
+   INTEGER FUNCTION trc_opt_alloc()
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_opt_alloc  ***
+      !!----------------------------------------------------------------------
+      !
+      ALLOCATE( ekb(jpi,jpj,jpk), ekr(jpi,jpj,jpk),  &
+                ekg(jpi,jpj,jpk), xeps(jpi,jpj,jpk), STAT= trc_opt_alloc  ) 
+      !
+      IF( trc_opt_alloc /= 0 ) CALL ctl_stop( 'STOP', 'trc_opt_alloc : failed to allocate arrays.' )
+      !
+   END FUNCTION trc_opt_alloc
+
+   !!======================================================================
+END MODULE trcopt
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcrst.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcrst.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcrst.F90	(revision 14644)
@@ -96,5 +96,5 @@
             CALL iom_open( TRIM(clpath)//TRIM(clname), numrtw, ldwrt = .TRUE. )
          ELSE
-#if defined key_iomput
+#if defined key_xios
             cw_toprst_cxt = "rstwt_"//TRIM(ADJUSTL(clkt))
             IF( TRIM(Agrif_CFixed()) == '0' ) THEN
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcwri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcwri.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcwri.F90	(revision 14644)
@@ -6,5 +6,5 @@
    !! History :   1.0  !  2009-05 (C. Ethe)  Original code
    !!----------------------------------------------------------------------
-#if defined key_top && defined key_iomput
+#if defined key_top && defined key_xios
    !!----------------------------------------------------------------------
    !!   'key_top'                                           TOP models
@@ -28,4 +28,8 @@
    PUBLIC trc_wri      
 
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
+
 CONTAINS
 
@@ -39,8 +43,9 @@
       INTEGER, INTENT( in )     :: Kmm  ! time level indices
       !
-      INTEGER                   :: jn
+      INTEGER                   :: jk, jn
       CHARACTER (len=20)        :: cltra
       CHARACTER (len=40)        :: clhstnam
       INTEGER ::   inum = 11            ! temporary logical unit
+      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
       !!---------------------------------------------------------------------
       !
@@ -53,18 +58,34 @@
            WRITE(inum,*) clhstnam
            CLOSE(inum)
-        ENDIF
+         ENDIF
 
-       ! Output of initial vertical scale factor
-       CALL iom_put( "e3t_0", e3t_0(:,:,:) )
-       CALL iom_put( "e3u_0", e3u_0(:,:,:) )
-       CALL iom_put( "e3v_0", e3v_0(:,:,:) )
-       !
-#if ! defined key_qco
-       CALL iom_put( "e3t" , e3t(:,:,:,Kmm) )
-       CALL iom_put( "e3u" , e3u(:,:,:,Kmm) )
-       CALL iom_put( "e3v" , e3v(:,:,:,Kmm) )
-#endif 
-       !
+         ! Output of initial vertical scale factor
+         CALL iom_put( "e3t_0", e3t_0(:,:,:) )
+         CALL iom_put( "e3u_0", e3u_0(:,:,:) )
+         CALL iom_put( "e3v_0", e3v_0(:,:,:) )
+         !
+         IF( .NOT.ln_linssh )  CALL iom_put( "ssh" , ssh(:,:,Kmm) )              ! sea surface height
+         !
+         IF ( iom_use("e3t") ) THEN  ! time-varying e3t
+            DO jk = 1, jpk
+               z3d(:,:,jk) =  e3t(:,:,jk,Kmm)
+            END DO
+            CALL iom_put( "e3t", z3d(:,:,:) )
+         ENDIF
+         IF ( iom_use("e3u") ) THEN                         ! time-varying e3u
+            DO jk = 1, jpk
+               z3d(:,:,jk) =  e3u(:,:,jk,Kmm)
+            END DO
+            CALL iom_put( "e3u", z3d(:,:,:) )
+         ENDIF
+         IF ( iom_use("e3v") ) THEN                         ! time-varying e3v
+            DO jk = 1, jpk
+               z3d(:,:,jk) =  e3v(:,:,jk,Kmm)
+            END DO
+            CALL iom_put( "e3v", z3d(:,:,:) )
+         ENDIF
+         !
       ENDIF
+      !
       ! write the tracer concentrations in the file
       ! ---------------------------------------
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca025_like
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca025_like	(revision 14644)
@@ -18,8 +18,11 @@
    nn_jsize   =   1206  !!  1049    ! number of point in j-direction of global(local) domain if >0 (<0)  
    nn_ksize   =   75       ! total number of point in k-direction
-   nn_perio   =   4        ! periodicity
-/
-!-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+   ln_Iperio  =   .true.   ! i-periodicity
+   ln_Jperio  =  .false.   ! j-periodicity
+   ln_NFold   =   .true.   ! North pole folding
+      cn_NFtype   =   'T'  ! Folding type: T or F
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    ln_nnogather=  .true.   !  activate code to avoid mpi_allgather use at the northfold
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca12_like
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca12_like	(revision 14644)
@@ -18,8 +18,11 @@
    nn_jsize   =   3146     ! number of point in j-direction of global(local) domain if >0 (<0)  
    nn_ksize   =   75       ! total number of point in k-direction
-   nn_perio   =   4        ! periodicity
-/
-!-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+   ln_Iperio  =   .true.   ! i-periodicity
+   ln_Jperio  =  .false.   ! j-periodicity
+   ln_NFold   =   .true.   ! North pole folding
+      cn_NFtype   =   'T'  ! Folding type: T or F
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    ln_nnogather=  .true.   !  activate code to avoid mpi_allgather use at the northfold
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca1_like
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/EXPREF/namelist_cfg_orca1_like	(revision 14644)
@@ -18,8 +18,11 @@
    nn_jsize   =   331      ! number of point in j-direction of global(local) domain if >0 (<0)  
    nn_ksize   =   75       ! total number of point in k-direction
-   nn_perio   =   6        ! periodicity
-/
-!-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+   ln_Iperio  =   .true.   ! i-periodicity
+   ln_Jperio  =  .false.   ! j-periodicity
+   ln_NFold   =   .true.   ! North pole folding
+      cn_NFtype   =   'F'  ! Folding type: T or F
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    ln_nnogather=  .true.   !  activate code to avoid mpi_allgather use at the northfold
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -74,8 +74,8 @@
       ! Position coordinates (in grid points)
       !                          ==========
-      DO_2D( 1, 1, 1, 1 )
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
          
-         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
-         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
+         zti = REAL( mig0(ji), wp ) - 0.5_wp  ! start at i=0.5 in the global grid without halos
+         ztj = REAL( mjg0(jj), wp ) - 0.5_wp  ! start at j=0.5 in the global grid without halos
          
          plamt(ji,jj) = zti
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_istate.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_istate.F90	(revision 14644)
@@ -53,10 +53,8 @@
       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] 
-!!st      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height
       !
       REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
       REAL(wp) ::   zfact
       INTEGER  ::   ji, jj, jk
-      INTEGER  ::   igloi, igloj   ! to be removed in the future, see comment bellow
       !!----------------------------------------------------------------------
       !
@@ -67,28 +65,17 @@
       ! define unique value on each point of the inner global domain. z2d ranging from 0.05 to -0.05
       !
-      ! WARNING: to keep compatibility with the trunk that was including periodocity into the input data, 
-      ! we must define z2d as bellow.
-      ! Once we decide to forget trunk compatibility, we must simply define z2d as:
-!!$      DO_2D( 0, 0, 0, 0 )
-!!$         z2d(ji,jj) = 0.1 * ( 0.5 - REAL( mig0_oldcmp(ji) + (mjg0_oldcmp(jj)-1) * Ni0glo, wp ) / REAL( Ni0glo * Nj0glo, wp ) )
-!!$      END_2D
-      igloi = Ni0glo + 2 * COUNT( (/ jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7 /) )
-      igloj = Nj0glo + 2 * COUNT( (/ jperio == 2 .OR. jperio == 7 /) ) + 1 * COUNT( (/ jperio >= 4 .AND. jperio <= 6 /) )
-      DO_2D( 0, 0, 0, 0 )
-         z2d(ji,jj) = 0.1 * ( 0.5 - REAL( mig0_oldcmp(ji) + (mjg0_oldcmp(jj)-1) * igloi, wp ) / REAL( igloi * igloj, wp ) )
+      DO_2D( 0, 0, 0, 0 )   !  +/- 0.05
+         z2d(ji,jj) = 0.1 * ( 0.5 - REAL( mig0(ji) + (mjg0(jj)-1) * Ni0glo, wp ) / REAL( Ni0glo * Nj0glo, wp ) )
       END_2D
-      !
-      ! sea level:
-!!st      pssh(:,:) = z2d(:,:)                                                ! +/- 0.05 m
       !
       DO_3D( 0, 0, 0, 0, 1, jpkm1 )
          zfact = REAL(jk-1,wp) / REAL(jpk-1,wp)   ! 0 to 1 to add a basic stratification
          ! temperature choosen to lead to ~50% ice at the beginning if rn_thres_sst = 0.5
-         pts(:,:,jk,jp_tem) = 20._wp*z2d(:,:) - 1._wp - 0.5_wp * zfact    ! -1 to -1.5 +/-1.0 degG
+         pts(ji,jj,jk,jp_tem) = 20._wp*z2d(ji,jj) - 1._wp - 0.5_wp * zfact    ! -1 to -1.5 +/- 1.0 degG
          ! salinity:  
-         pts(:,:,jk,jp_sal) = 30._wp + 1._wp * zfact + z2d(:,:)           ! 30 to 31 +/- 0.05 psu
+         pts(ji,jj,jk,jp_sal) = 30._wp + 1._wp * zfact + z2d(ji,jj)           ! 30 to 31   +/- 0.05 psu
          ! velocities:
-         pu(:,:,jk) = z2d(:,:) *  0.1_wp * umask(:,:,jk)                  ! +/- 0.005  m/s
-         pv(:,:,jk) = z2d(:,:) * 0.01_wp * vmask(:,:,jk)                  ! +/- 0.0005 m/s
+         pu(ji,jj,jk) = z2d(ji,jj) *  0.1_wp * umask(ji,jj,jk)                ! +/- 0.005  m/s
+         pv(ji,jj,jk) = z2d(ji,jj) * 0.01_wp * vmask(ji,jj,jk)                ! +/- 0.0005 m/s
       END_3D
       pts(:,:,jpk,:) = 0._wp
@@ -96,5 +83,4 @@
       pv( :,:,jpk  ) = 0._wp
       !
-!!st      CALL lbc_lnk('usrdef_istate', pssh, 'T',  1. )            ! apply boundary conditions
       CALL lbc_lnk('usrdef_istate',  pts, 'T',  1. )            ! apply boundary conditions
       CALL lbc_lnk('usrdef_istate',   pu, 'U', -1. )            ! apply boundary conditions
@@ -117,5 +103,4 @@
       !
       INTEGER  ::   ji, jj
-      INTEGER  ::   igloi, igloj   ! to be removed in the future, see usr_def_istate comment 
       !!----------------------------------------------------------------------
       !
@@ -123,12 +108,9 @@
       IF(lwp) WRITE(numout,*) 'usr_def_istate_ssh : BENCH configuration, analytical definition of initial ssh'
       !
-      igloi = Ni0glo + 2 * COUNT( (/ jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7 /) )
-      igloj = Nj0glo + 2 * COUNT( (/ jperio == 2 .OR. jperio == 7 /) ) + 1 * COUNT( (/ jperio >= 4 .AND. jperio <= 6 /) )
-      ! sea level:  +/- 0.05 m
-      DO_2D( 0, 0, 0, 0 )
-         pssh(ji,jj) = 0.1 * ( 0.5 - REAL( mig0_oldcmp(ji) + (mjg0_oldcmp(jj)-1) * igloi, wp ) / REAL( igloi * igloj, wp ) )
+      DO_2D( 0, 0, 0, 0 )                              ! sea level:  +/- 0.05 m
+         pssh(ji,jj) = 0.1 * ( 0.5 - REAL( mig0(ji) + (mjg0(jj)-1) * Ni0glo, wp ) / REAL( Ni0glo * Nj0glo, wp ) )
       END_2D
       !
-      CALL lbc_lnk('usrdef_istate', pssh, 'T',  1. )            ! apply boundary conditions
+      CALL lbc_lnk('usrdef_istate', pssh, 'T',  1. )   ! apply boundary conditions
       !
    END SUBROUTINE usr_def_istate_ssh
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -29,5 +29,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -41,9 +41,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
-      !
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes 
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios         ! Local integer
@@ -52,11 +53,13 @@
       INTEGER ::   nn_jsize    ! number of point in j-direction of global(local) domain if >0 (<0)  
       INTEGER ::   nn_ksize    ! total number of point in k-direction
-      INTEGER ::   nn_perio    ! periodicity
       !                              !!* nammpp namelist *!!
       INTEGER          ::   jpni, jpnj
-      LOGICAL          ::   ln_nnogather, ln_listonly
+      LOGICAL          ::   ln_listonly
+      LOGICAL          ::   ln_Iperio, ln_Jperio
+      LOGICAL          ::   ln_NFold
+      character(len=1) ::   cn_NFtype
       !!
-      NAMELIST/namusr_def/ nn_isize, nn_jsize, nn_ksize, nn_perio
-      NAMELIST/nammpp/ jpni, jpnj, nn_hls, ln_nnogather, ln_listonly
+      NAMELIST/namusr_def/ nn_isize, nn_jsize, nn_ksize, ln_Iperio, ln_Jperio, ln_NFold, cn_NFtype
+      NAMELIST/nammpp/ jpni, jpnj, nn_hls, ln_nnogather, ln_listonly, nn_comm
       !!----------------------------------------------------------------------     
       !
@@ -83,7 +86,9 @@
          kpj = nn_jsize
       ENDIF
+      kpk = nn_ksize
       !
-      kpk = nn_ksize
-      kperio = nn_perio
+      ldIperio = ln_Iperio   ;   ldJperio = ln_Jperio
+      ldNFold  = ln_NFold    ;   cdNFtype = cn_NFtype
+      !
       !                             ! control print
       IF(lwp) THEN
@@ -107,5 +112,5 @@
          ENDIF
          WRITE(numout,*) '      global domain size-z            nn_ksize = ', nn_ksize
-         WRITE(numout,*) '      LBC of the global domain          kperio = ', kperio
+         WRITE(numout,*) '   '
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -30,7 +30,7 @@
    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
+   PUBLIC   usrdef_sbc_oce      ! routine called by sbcmod.F90 for sbc ocean
+   PUBLIC   usrdef_sbc_ice_tau  ! routine called by icestp.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by icestp.F90 for ice thermo
 
    !! * Substitutions
@@ -83,5 +83,4 @@
          !
       ENDIF
-      
       !
    END SUBROUTINE usrdef_sbc_oce
@@ -97,7 +96,6 @@
       INTEGER, INTENT(in) ::   kt   ! ocean time step
       !
-      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      REAL(wp) ::   zztmp
       INTEGER  ::   ji, jj
-      INTEGER  ::   igloi, igloj   ! to be removed in the future, see comment bellow
       !!---------------------------------------------------------------------
 #if defined key_si3
@@ -106,19 +104,11 @@
       ! define unique value on each point. z2d ranging from 0.05 to -0.05
       !
-      ! WARNING: to keep compatibility with the trunk that was including periodocity into the input data, 
-      ! we must define z2d as bellow.
-      ! Once we decide to forget trunk compatibility, we must simply define z2d as:
-!!$      DO_2D( 0, 0, 0, 0 )
-!!$         z2d(ji,jj) = 0.1 * ( 0.5 - REAL( mig0_oldcmp(ji) + (mjg0_oldcmp(jj)-1) * Ni0glo, wp ) / REAL( Ni0glo * Nj0glo, wp ) )
-!!$      END_2D
-      igloi = Ni0glo + 2 * COUNT( (/ jperio == 1 .OR. jperio == 4 .OR. jperio == 6 .OR. jperio == 7 /) )
-      igloj = Nj0glo + 2 * COUNT( (/ jperio == 2 .OR. jperio == 7 /) ) + 1 * COUNT( (/ jperio >= 4 .AND. jperio <= 6 /) )
       DO_2D( 0, 0, 0, 0 )
-         z2d(ji,jj) = 0.1 * ( 0.5 - REAL( mig0_oldcmp(ji) + (mjg0_oldcmp(jj)-1) * igloi, wp ) / REAL( igloi * igloj, wp ) )
+         zztmp = 0.1 * ( 0.5 - REAL( mig0(ji) + (mjg0(jj)-1) * Ni0glo, wp ) / REAL( Ni0glo * Nj0glo, wp ) )
+         utau_ice(ji,jj) = 0.1_wp + zztmp
+         vtau_ice(ji,jj) = 0.1_wp + zztmp
       END_2D
-      utau_ice(:,:) = 0.1_wp + z2d(:,:)
-      vtau_ice(:,:) = 0.1_wp + z2d(:,:)
 
-      CALL lbc_lnk_multi( 'usrdef_sbc', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_sbc', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
 #endif
       !
@@ -130,6 +120,5 @@
       !!                     ***  ROUTINE usrdef_sbc_ice_flx  ***
       !!
-      !! ** Purpose :   provide the surface boundary (flux) condition over
-      !sea-ice
+      !! ** Purpose :   provide the surface boundary (flux) condition over sea-ice
       !!---------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt   ! ocean time step
@@ -139,6 +128,6 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zsnw   ! snw distribution after wind blowing
       !!---------------------------------------------------------------------
+#if defined key_si3
       !
-#if defined key_si3
       IF( kt==nit000 .AND. lwp)   WRITE(numout,*)' usrdef_sbc_ice : BENCH case: NO flux forcing'
       !
@@ -146,10 +135,11 @@
       emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
       qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
-      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar heat flux
 
       ! ice variables
       alb_ice (:,:,:) = 0.7_wp  ! useless
       qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
-      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar heat flux
+      dqns_ice(:,:,:) = 0._wp   ! uniform value for non solar heat flux sensitivity for ice
       sprecip (:,:)   = 0._wp   ! uniform value for snow precip
       evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
@@ -157,6 +147,5 @@
       ! ice fields deduced from above
       zsnw(:,:) = 1._wp
-      !!CALL lim_thd_snwblow( at_i_b, zsnw )  ! snow distribution over ice after
-      !wind blowing 
+      !!CALL lim_thd_snwblow( at_i_b, zsnw )  ! snow distribution over ice after wind blowing 
       emp_ice  (:,:)   = SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) - sprecip(:,:) * zsnw(:,:)
       emp_oce  (:,:)   = emp_oce(:,:) - sprecip(:,:) * (1._wp - zsnw(:,:) )
@@ -173,5 +162,4 @@
       ! --- shortwave radiation transmitted thru the surface scattering layer (W/m2) --- !
       qtr_ice_top(:,:,:) = 0._wp
-
 #endif
 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -197,5 +197,5 @@
       !
       
-!!$      IF( jperio == 3 .OR. jperio == 4 ) THEN   ! add a small island in the upper corners to avoid model instabilities...
+!!$      IF( c_NFtype == 'T' ) THEN   ! add a small island in the upper corners to avoid model instabilities...
 !!$         z2d(mi0(       nn_hls):mi1(                  nn_hls+2 ),mj0(jpjglo-nn_hls-1):mj1(jpjglo-nn_hls+1)) = 0.
 !!$         z2d(mi0(jpiglo-nn_hls):mi1(MIN(jpiglo,jpiglo-nn_hls+2)),mj0(jpjglo-nn_hls-1):mj1(jpjglo-nn_hls+1)) = 0.
@@ -203,5 +203,5 @@
 !!$      ENDIF
 !!$      !
-!!$      IF( jperio == 5 .OR. jperio == 6 ) THEN   ! add a small island in the upper corners to avoid model instabilities...
+!!$      IF( c_NFtype == 'F' ) THEN   ! add a small island in the upper corners to avoid model instabilities...
 !!$         z2d(mi0(       nn_hls):mi1(       nn_hls+1),mj0(jpjglo-nn_hls):mj1(jpjglo-nn_hls+1)) = 0.
 !!$         z2d(mi0(jpiglo-nn_hls):mi1(jpiglo-nn_hls+1),mj0(jpjglo-nn_hls):mj1(jpjglo-nn_hls+1)) = 0.
@@ -210,5 +210,5 @@
 
       !
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (closed boundaries)
       !
       k_bot(:,:) = INT( z2d(:,:) )           ! =jpkm1 over the ocean point, =0 elsewhere
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/cpp_BENCH.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/cpp_BENCH.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/cpp_BENCH.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_mpp_mpi key_si3 key_top key_qco
+ bld::tool::fppkeys key_si3 key_top key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/EXP00/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/EXP00/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/EXP00/namelist_cfg	(revision 14644)
@@ -488,5 +488,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -494,5 +494,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,8 +51,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -72,7 +74,8 @@
       kpi = 3
       kpj = 3
-      kpk = 75 
+      kpk = 75
       !                             ! Set the lateral boundary condition of the global domain
-      kperio =  7                   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
+      ldIperio = .TRUE.    ;   ldJperio = .true.   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -90,6 +93,5 @@
          WRITE(numout,*) '                                               jpjglo = ', kpj
          WRITE(numout,*) '                                               jpkglo = ', kpk
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      C1D : closed basin                       jperio = ', kperio
+      WRITE(numout,*) '   '
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/cpp_C1D_ASICS.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/cpp_C1D_ASICS.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/cpp_C1D_ASICS.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_c1d key_qco key_mpp_mpi key_iomput
+ bld::tool::fppkeys   key_c1d key_qco key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/EXPREF/file_def_nemo-oce.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/EXPREF/file_def_nemo-oce.xml	(revision 14644)
@@ -16,5 +16,5 @@
 	  <field field_ref="ssh"  />
 	  <field field_ref="socegrad"  />
-	  <field field_ref="eken_int"  />
+	  <field field_ref="ke_int"  />
 	  <field field_ref="relvor"  />
 	  <field field_ref="potvor"  />
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/EXPREF/namelist_cfg	(revision 14644)
@@ -49,5 +49,6 @@
    ln_sshnoise =  .FALSE.  !  add random noise on initial ssh
    rn_lambda   =     50.   !  gaussian lambda
-   nn_perio    = 1
+   ln_Iperio   =   .true.  ! i-periodicity
+   ln_Jperio   =  .false.  ! j-periodicity
 /
 !-----------------------------------------------------------------------
@@ -231,11 +232,13 @@
 &namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false.  !  energy conserving scheme
-   ln_dynvor_ens = .false.  !  enstrophy conserving scheme
-   ln_dynvor_mix = .false.  !  mixed scheme
-   ln_dynvor_een = .false.  !  energy & enstrophy scheme
-r_enT = .false.  !  energy conserving scheme (T-point)
-   ln_dynvor_eeT = .true.   !  energy conserving scheme (een using e3t)
-      nn_e3f_typ = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   ln_dynvor_ene = .false. !  energy    conserving scheme
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_enT = .false. !  energy conserving scheme (T-point)
+   ln_dynvor_eeT =  .true. !  energy conserving scheme (een using e3t)
+   ln_dynvor_een = .false. !  energy & enstrophy scheme
+   !
+   nn_e3f_typ = 0          !  type of e3f (EEN, ENE, ENS, MIX only)  =0  e3f = mi(mj(e3t))/4
+   !                       !                                         =1  e3f = mi(mj(e3t))/mi(mj( tmask))
 /
 !-----------------------------------------------------------------------
@@ -350,5 +353,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -356,5 +359,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 !!   jpni        =   8       !  jpni   number of processors following i (set automatically if < 1)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -64,5 +64,6 @@
       !
       INTEGER  ::   ji, jj     ! dummy loop indices
-      REAL(wp) ::   zphi0, zlam0, zbeta, zf0
+      INTEGER  ::   ii0, ij0   ! dummy loop indices
+      REAL(wp) ::   zbeta, zf0
       REAL(wp) ::   zti, ztj   ! local scalars
       !!-------------------------------------------------------------------------------
@@ -77,28 +78,25 @@
       ! Position coordinates (in kilometers)
       !                          ==========
-      zlam0 = -REAL(NINT(Ni0glo*rn_0xratio)-1, wp) * rn_dx
-      zphi0 = -REAL(NINT(Nj0glo*rn_0yratio)-1, wp) * rn_dy 
+      ii0 = NINT( REAL(Ni0glo, wp) * rn_0xratio )
+      ij0 = NINT( REAL(Nj0glo, wp) * rn_0yratio )
 
 #if defined key_agrif
       ! ! let lower left longitude and latitude from parent
       IF (.NOT.Agrif_root()) THEN
-          zlam0 = (0.5_wp-(Agrif_parent(jpiglo)-1)/2)*Agrif_irhox()*rn_dx &
-             &+(Agrif_Ix()+nbghostcells-1)*Agrif_irhox()*rn_dx-(0.5_wp+nbghostcells)*rn_dx
-          zphi0 = (0.5_wp-(Agrif_parent(jpjglo)-1)/2)*Agrif_irhoy()*rn_dy &
-             &+(Agrif_Iy()+nbghostcells-1)*Agrif_irhoy()*rn_dy-(0.5_wp+nbghostcells)*rn_dy
+          to be coded...
       ENDIF 
 #endif
          
-      DO_2D( 1, 1, 1, 1 )         
-         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
-         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )         
+         zti = REAL( mig0(ji)-ii0, wp )   ! =0 at i=ii0 in the global grid without halos
+         ztj = REAL( mjg0(jj)-ij0, wp )   ! =0 at i=ij0 in the global grid without halos
          
-         plamt(ji,jj) = zlam0 + rn_dx *   zti
-         plamu(ji,jj) = zlam0 + rn_dx * ( zti + 0.5_wp ) 
+         plamt(ji,jj) = rn_dx *   zti
+         plamu(ji,jj) = rn_dx * ( zti + 0.5_wp ) 
          plamv(ji,jj) = plamt(ji,jj) 
          plamf(ji,jj) = plamu(ji,jj) 
          
-         pphit(ji,jj) = zphi0 + rn_dy *   ztj
-         pphiv(ji,jj) = zphi0 + rn_dy * ( ztj + 0.5_wp ) 
+         pphit(ji,jj) = rn_dy *   ztj
+         pphiv(ji,jj) = rn_dy * ( ztj + 0.5_wp ) 
          pphiu(ji,jj) = pphit(ji,jj) 
          pphif(ji,jj) = pphiv(ji,jj) 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 14644)
@@ -76,6 +76,4 @@
       CASE(-1)    ! stratif at rest
 
-         ! sea level:
-         pssh(:,:) = 0.
          ! temperature:
          pts(:,:,1,jp_tem) = 25. !!30._wp
@@ -146,5 +144,5 @@
          ! salinity:  
          DO jk=1, jpkm1
-            pts(:,:,jk,jp_sal) = pssh(:,:)
+            pts(:,:,jk,jp_sal) = gphit(:,:)
          END DO
          ! velocities:
@@ -241,5 +239,5 @@
       !
       CALL lbc_lnk( 'usrdef_istate', pts , 'T',  1. )
-      CALL lbc_lnk_multi( 'usrdef_istate', pu, 'U', -1., pv, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_istate', pu, 'U', -1., pv, 'V', -1. )
 
    END SUBROUTINE usr_def_istate
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -50,5 +50,4 @@
    LOGICAL , PUBLIC ::   ln_sshnoise=.false. ! add random noise on initial ssh
    REAL(wp), PUBLIC ::   rn_lambda  = 50.    ! gaussian lambda
-   INTEGER , PUBLIC ::   nn_perio   =    0   ! periodicity of the channel (0=closed, 1=E-W)
 
    !!----------------------------------------------------------------------
@@ -59,5 +58,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -71,16 +70,19 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios      ! Local integer
       REAL(wp)::   zh       ! Local scalars
+      LOGICAL ::   ln_Iperio, ln_Jperio
       !!
       NAMELIST/namusr_def/  rn_domszx, rn_domszy, rn_domszz, rn_dx, rn_dy, rn_dz, rn_0xratio, rn_0yratio   &
          &                 , nn_fcase, rn_ppgphi0, rn_u10, rn_windszx, rn_windszy & !!, rn_uofac   &
          &                 , rn_vtxmax, rn_uzonal, rn_ujetszx, rn_ujetszy  &
-         &                 , nn_botcase, nn_initcase, ln_sshnoise, rn_lambda, nn_perio
+         &                 , nn_botcase, nn_initcase, ln_sshnoise, rn_lambda, ln_Iperio, ln_Jperio
       !!----------------------------------------------------------------------
       !
@@ -102,6 +104,4 @@
 #endif
       !
-      IF(lwm)   WRITE( numond, namusr_def )
-      !
       cd_cfg = 'EW_CANAL'             ! name & resolution (not used)
       kk_cfg = INT( rn_dx )
@@ -109,5 +109,5 @@
       IF( Agrif_Root() ) THEN        ! Global Domain size:  EW_CANAL global domain is  1800 km x 1800 Km x 5000 m
          kpi = NINT( rn_domszx / rn_dx ) + 1
-         kpj = NINT( rn_domszy / rn_dy ) + 3
+         kpj = NINT( rn_domszy / rn_dy ) + 1
       ELSE                           ! Global Domain size: add nbghostcells + 1 "land" point on each side
          kpi  = nbcellsx + nbghostcells_x   + nbghostcells_x   + 2
@@ -117,6 +117,4 @@
       !
       zh  = (kpk-1)*rn_dz
-      !                             ! Set the lateral boundary condition of the global domain
-      kperio = 1                    ! EW_CANAL configuration : closed basin
       !                             ! control print
       IF(lwp) THEN
@@ -149,8 +147,10 @@
          WRITE(numout,*) '      add random noise on initial ssh   ln_sshnoise= ', ln_sshnoise
          WRITE(numout,*) '      Gaussian lambda parameter          rn_lambda = ', rn_lambda
-         WRITE(numout,*) '      Periodicity of the basin            nn_perio = ', nn_perio
+         WRITE(numout,*) '      i and j Periodicity     ln_Iperio, ln_Jperio = ', ln_Iperio, ln_Jperio
+         WRITE(numout,*) '   '
       ENDIF
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = nn_perio                    ! EW_CANAL configuration : closed basin
+      ldIperio = ln_Iperio   ;   ldJperio = ln_Jperio   ! CANAL configuration
+      ldNFold  =  .FALSE.    ;   cdNFtype = '-'
       !
    END SUBROUTINE usr_def_nam
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -202,5 +202,5 @@
       END SELECT
       !
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (closed boundaries)
       !
       k_bot(:,:) = NINT( z2d(:,:) )          ! =jpkm1 over the ocean point, =0 elsewhere
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/cpp_CANAL.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/cpp_CANAL.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/cpp_CANAL.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_qco 
+ bld::tool::fppkeys key_xios key_qco 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/EXPREF/namelist_cfg	(revision 14644)
@@ -466,5 +466,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -472,5 +472,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/cpp_CPL_OASIS.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/cpp_CPL_OASIS.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/cpp_CPL_OASIS.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_oasis3 key_qco
+bld::tool::fppkeys   key_si3 key_top key_xios key_oasis3 key_qco
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/1_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/1_namelist_cfg	(revision 14644)
@@ -18,4 +18,15 @@
 /
 !-----------------------------------------------------------------------
+&namusr_def    !   User defined :   OVERFLOW configuration
+!-----------------------------------------------------------------------
+   !                       !  type of vertical coordinate
+   ln_zco      = .false.      ! z-coordinate
+   ln_zps      = .true.       ! z-partial-step coordinate
+   ln_sco      = .false.      ! s-coordinate
+   rn_dx       =   5000.   !  horizontal resolution   [meters]
+   rn_dz       =     60.   !  vertical   resolution   [meters]
+   rn_f0       =  1.e-4    !  coriolis [s-1]
+/
+!-----------------------------------------------------------------------
 &namrun        !   parameters of the run
 !-----------------------------------------------------------------------
@@ -36,5 +47,5 @@
 !-----------------------------------------------------------------------
    ln_linssh  = .true.
-   rn_Dt      =   240.    !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_Dt      =   150.    !  time step for the dynamics (and tracer if nn_acc=0)
    rn_atfp    =    0.1    !  asselin time filter parameter
    ln_meshmask = .false.  !  =T create a mesh file
@@ -164,9 +175,8 @@
 &namdyn_vor    !   option of physics/algorithm
 !-----------------------------------------------------------------------
-   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)
+   !
+   nn_e3f_typ = 1          !  type of e3f (EEN, ENE, ENS, MIX only)  =0  e3f = mi(mj(e3t))/4
+   !
 /
 !-----------------------------------------------------------------------
@@ -174,5 +184,5 @@
 !-----------------------------------------------------------------------
    ln_hpg_zps  = .false.  !  z-coordinate - partial steps (interpolation)
-   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_djc  = .true.   !  s-coordinate (standard jacobian formulation)
 /
 !-----------------------------------------------------------------------
@@ -200,10 +210,10 @@
 &namzdf        !   vertical physics                                     (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_zad_Aimp = .true.       !  Courant number dependent scheme (Shchepetkin 2015)
+   ln_zad_Aimp = .false.       !  Courant number dependent scheme (Shchepetkin 2015)
    !                       ! type of vertical closure (required)
-   ln_zdfcst   = .true.       !  constant mixing
+   ln_zdfcst   = .false.      !  constant mixing
    ln_zdfric   = .false.      !  local Richardson dependent formulation (T =>   fill namzdf_ric)
    ln_zdftke   = .false.      !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
-   ln_zdfgls   = .false.      !  Generic Length Scale closure           (T =>   fill namzdf_gls)
+   ln_zdfgls   = .true.       !  Generic Length Scale closure           (T =>   fill namzdf_gls)
    ln_zdfosm   = .false.      !  OSMOSIS BL closure                     (T =>   fill namzdf_osm)
    !   
@@ -225,6 +235,6 @@
    !   
    !                       ! coefficients
-   rn_avm0     =   5.e-2     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avm0     =   1.e-5     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   1.e-6     !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/AGRIF_FixedGrids.in
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/AGRIF_FixedGrids.in	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/AGRIF_FixedGrids.in	(revision 14644)
@@ -1,3 +1,3 @@
 1
-118 178 40 80 2 2 2 
+278 358 88 162 2 2 2   
 0
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/anim_dome.py
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/anim_dome.py	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/anim_dome.py	(revision 14644)
@@ -0,0 +1,99 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+""" Draw a plot (or and animation)
+    of passive tracer at the bottom
+    in the DOME experiment
+"""
+
+from netCDF4 import Dataset
+import matplotlib.pyplot as plt
+import numpy as np
+from matplotlib.animation import FuncAnimation
+# from mpl_toolkits.axes_grid1.inset_locator import inset_axes
+#
+# Parent grid data:
+ncid = Dataset('DOME_grid_T.nc')
+lon0 = ncid.variables['nav_lon'][:, :]
+lat0 = ncid.variables['nav_lat'][:, :]
+work = ncid.variables['btra'][:, :, :]
+zos = ncid.variables['zos'][:, :, :]
+ncid.close()
+#
+(jpt0, jpj0, jpi0) = np.shape(work)
+mask = np.where((zos == 0.), True, False)
+tra0 = np.ma.array(work, mask=mask, hard_mask=True)
+
+#
+# Child grid data:
+ncid = Dataset('1_DOME_grid_T.nc')
+lon1 = ncid.variables['nav_lon'][:, :]
+lat1 = ncid.variables['nav_lat'][:, :]
+work = ncid.variables['btra'][:, :, :]
+zos = ncid.variables['zos'][:, :, :]
+sp = ncid.variables['Agrif_sponge'][:, :, :]
+ncid.close()
+#
+(jpt1, jpj1, jpi1) = np.shape(work)
+mask = np.where((zos == 0.), True, False)
+tra1 = np.ma.array(work, mask=mask, hard_mask=True)
+
+# Get resolution in km:
+res0 = np.abs(lon0[0, 1] - lon0[1, 0])
+res1 = np.abs(lon1[0, 1] - lon1[0, 0])
+
+# Shift lon, lat in order to have a pixel centred around the right location:
+lon0 = lon0 - res0/2.
+lat0 = lat0 - res0/2.
+lon1 = lon1 - res1/2.
+lat1 = lat1 - res1/2.
+
+# Indexes to skip ghost zone:
+nghost = 3 # + int(res0/res1)*2 - 1
+imin = nghost + 1
+jmin = nghost + 1
+imax = jpi1 - nghost - 1
+jmax = jpj1 - nghost - 1
+#
+fig, ax = plt.subplots()
+fig.set_tight_layout(True)
+mycmap = plt.cm.nipy_spectral
+plt.set_cmap(mycmap)
+i = 0 
+label = ' Bottom tracer concentration day: {00}'.format(i+1)
+pcol = plt.pcolor(lon0, lat0, np.squeeze(tra0[i, :, :]),
+                  vmin=0.01, vmax=1., edgecolor='0.9', cmap=mycmap)
+pcol = plt.pcolor(lon1[jmin:jmax, imin:imax], lat1[jmin:jmax, imin:imax], np.squeeze(tra1[i, jmin:jmax, imin:imax]),
+                  vmin=0.01, vmax=1., edgecolor='0.4', cmap=mycmap)
+# plt.contour(lon1[jmin:jmax, imin:imax], lat1[jmin:jmax, imin:imax], np.squeeze(sp[i, jmin:jmax, imin:imax]))
+
+plt.axis('scaled')
+# plt.xlim((-800., 250.))
+# plt.ylim((-500.,  50.))
+plt.xlim((-1400., 200.))
+plt.ylim((-300.,  50.))
+plt.gcf().set_size_inches(6, 3)
+
+plt.ylabel('Y (km)', fontsize=14)
+plt.xlabel('X (km)', fontsize=14)
+cbar = plt.colorbar(pcol, shrink=0.5)
+cbar.ax.tick_params(labelsize=14)
+
+plt.title(label)
+
+
+def update(t):
+    txt = ' Bottom tracer concentration day: {00}'.format(t+1)
+    print('Process day', t+1)
+    pcol = plt.pcolor(lon0, lat0, np.squeeze(tra0[t, :, :]),
+                      vmin=0.01, vmax=1., edgecolor='0.9', cmap=mycmap)
+    pcol = plt.pcolor(lon1[jmin:jmax, imin:imax], lat1[jmin:jmax, imin:imax], np.squeeze(tra1[t, jmin:jmax, imin:imax]),
+                      vmin=0.01, vmax=1., edgecolor='0.4', cmap=mycmap)
+    plt.title(txt)
+    return pcol
+
+
+anim = FuncAnimation(fig, update, frames=np.arange(1, 39), interval=150)
+anim.save('DOME_anim_btra.gif', dpi=80, writer='imagemagick')
+# plt.savefig('DOME_bottom_tracer.png')
+# plt.show()
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/field_def_nemo-oce.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/field_def_nemo-oce.xml	(revision 14644)
@@ -1,1141 +1,1 @@
-<?xml version="1.0"?>
-    <!-- $id$ -->
-
-    <field_definition level="1" prec="4" operation="average" enabled=".TRUE." default_value="1.e20" > <!-- time step automaticaly defined -->
-
-    <!--
-       =====================================================================================================
-       =                                   Configurable diagnostics                                        =
-       =====================================================================================================
-      -->
-
-    <field_group id="diamlr_fields">
-
-    <!--
-       =====================================================================================================
-                         Configuration of multiple-linear-regression analysis (diamlr)
-       =====================================================================================================
-
-       This field group configures diamlr for tidal harmonic analysis of field
-       ssh: in addition to a regressor for fitting the mean value (diamlr_r101),
-       it includes the regressors for the analysis of the tidal constituents
-       that are available in the tidal-forcing implementation (see
-       ./src/OCE/SBC/tide.h90).
-
-      -->
-
-      <!-- Time -->
-      <field id="diamlr_time" grid_ref="diamlr_grid_T_2D" prec="8" />
-
-      <!-- Regressors for tidal harmonic analysis -->
-      <field id="diamlr_r001"  field_ref="diamlr_time" expr="sin( __TDE_M2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:M2"   />
-      <field id="diamlr_r002"  field_ref="diamlr_time" expr="cos( __TDE_M2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:M2"   />
-      <field id="diamlr_r003"  field_ref="diamlr_time" expr="sin( __TDE_N2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:N2"   />
-      <field id="diamlr_r004"  field_ref="diamlr_time" expr="cos( __TDE_N2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:N2"   />
-      <field id="diamlr_r005"  field_ref="diamlr_time" expr="sin( __TDE_2N2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:2N2"  />
-      <field id="diamlr_r006"  field_ref="diamlr_time" expr="cos( __TDE_2N2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:2N2"  />
-      <field id="diamlr_r007"  field_ref="diamlr_time" expr="sin( __TDE_S2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:S2"   />
-      <field id="diamlr_r008"  field_ref="diamlr_time" expr="cos( __TDE_S2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:S2"   />
-      <field id="diamlr_r009"  field_ref="diamlr_time" expr="sin( __TDE_K2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:K2"   />
-      <field id="diamlr_r010"  field_ref="diamlr_time" expr="cos( __TDE_K2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:K2"   />
-      <field id="diamlr_r011"  field_ref="diamlr_time" expr="sin( __TDE_K1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:K1"   />
-      <field id="diamlr_r012"  field_ref="diamlr_time" expr="cos( __TDE_K1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:K1"   />
-      <field id="diamlr_r013"  field_ref="diamlr_time" expr="sin( __TDE_O1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:O1"   />
-      <field id="diamlr_r014"  field_ref="diamlr_time" expr="cos( __TDE_O1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:O1"   />
-      <field id="diamlr_r015"  field_ref="diamlr_time" expr="sin( __TDE_Q1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Q1"   />
-      <field id="diamlr_r016"  field_ref="diamlr_time" expr="cos( __TDE_Q1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Q1"   />
-      <field id="diamlr_r017"  field_ref="diamlr_time" expr="sin( __TDE_P1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:P1"   />
-      <field id="diamlr_r018"  field_ref="diamlr_time" expr="cos( __TDE_P1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:P1"   />
-      <field id="diamlr_r019"  field_ref="diamlr_time" expr="sin( __TDE_M4_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:M4"   />
-      <field id="diamlr_r020"  field_ref="diamlr_time" expr="cos( __TDE_M4_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:M4"   />
-      <field id="diamlr_r021"  field_ref="diamlr_time" expr="sin( __TDE_Mf_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Mf"   />
-      <field id="diamlr_r022"  field_ref="diamlr_time" expr="cos( __TDE_Mf_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Mf"   />
-      <field id="diamlr_r023"  field_ref="diamlr_time" expr="sin( __TDE_Mm_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Mm"   />
-      <field id="diamlr_r024"  field_ref="diamlr_time" expr="cos( __TDE_Mm_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Mm"   />
-      <field id="diamlr_r025"  field_ref="diamlr_time" expr="sin( __TDE_Msqm_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Msqm" />
-      <field id="diamlr_r026"  field_ref="diamlr_time" expr="cos( __TDE_Msqm_omega__ * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Msqm" />
-      <field id="diamlr_r027"  field_ref="diamlr_time" expr="sin( __TDE_Mtm_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:Mtm"  />
-      <field id="diamlr_r028"  field_ref="diamlr_time" expr="cos( __TDE_Mtm_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:Mtm"  />
-      <field id="diamlr_r029"  field_ref="diamlr_time" expr="sin( __TDE_S1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:S1"   />
-      <field id="diamlr_r030"  field_ref="diamlr_time" expr="cos( __TDE_S1_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:S1"   />
-      <field id="diamlr_r031"  field_ref="diamlr_time" expr="sin( __TDE_MU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:MU2"  />
-      <field id="diamlr_r032"  field_ref="diamlr_time" expr="cos( __TDE_MU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:MU2"  />
-      <field id="diamlr_r033"  field_ref="diamlr_time" expr="sin( __TDE_NU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:NU2"  />
-      <field id="diamlr_r034"  field_ref="diamlr_time" expr="cos( __TDE_NU2_omega__  * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:NU2"  />
-      <field id="diamlr_r035"  field_ref="diamlr_time" expr="sin( __TDE_L2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:L2"   />
-      <field id="diamlr_r036"  field_ref="diamlr_time" expr="cos( __TDE_L2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:L2"   />
-      <field id="diamlr_r037"  field_ref="diamlr_time" expr="sin( __TDE_T2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:sin:T2"   />
-      <field id="diamlr_r038"  field_ref="diamlr_time" expr="cos( __TDE_T2_omega__   * diamlr_time )" enabled=".TRUE."  comment="harmonic:cos:T2"   />
-      <field id="diamlr_r101"  field_ref="diamlr_time" expr="diamlr_time^0.0"                         enabled=".TRUE."  comment="mean"              />
-
-      <!-- Fields selected for regression analysis -->
-      <field id="diamlr_f001" field_ref="ssh" enabled=".TRUE." />
-
-    </field_group>
-
-    <!--
-============================================================================================================
-=                                  definition of all existing variables                                    =
-=                                            DO NOT CHANGE                                                 =
-============================================================================================================
-    -->
-
-    <field_group id="diadetide_fields">
-
-    <!--
-       =====================================================================================================
-                 Weight fields for the computation of daily detided model diagnostics (diadetide)
-       =====================================================================================================
-
-       -->
-
-      <field id="diadetide_weight" grid_ref="diadetide_grid_T_2D" enabled=".TRUE." />
-      <field id="diadetide_weight_grid_T_2D" field_ref="diadetide_weight" grid_ref="diadetide_grid_T_2D" enabled=".TRUE." > this </field>
-      <field id="diadetide_weight_grid_U_2D" field_ref="diadetide_weight" grid_ref="diadetide_grid_U_2D" enabled=".TRUE." > this </field>
-      <field id="diadetide_weight_grid_V_2D" field_ref="diadetide_weight" grid_ref="diadetide_grid_V_2D" enabled=".TRUE." > this </field>
-      <field id="diadetide_weight_grid_T_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_T_3D" enabled=".TRUE." > this </field>
-      <field id="diadetide_weight_grid_U_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_U_3D" enabled=".TRUE." > this </field>
-      <field id="diadetide_weight_grid_V_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_V_3D" enabled=".TRUE." > this </field>
-      <field id="diadetide_weight_grid_W_3D" field_ref="diadetide_weight" grid_ref="diadetide_grid_2D_to_grid_W_3D" enabled=".TRUE." > this </field>
-
-    </field_group>
-
-    <!--
-============================================================================================================
-                                  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="e3ts"         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="e3tb"         long_name="bottom T-cell thickness"             standard_name="bottom_cell_thickness" unit="m"   grid_ref="grid_T_2D"/>
-        <field id="e3t_300"      field_ref="e3t"                grid_ref="grid_T_zoom_300"       detect_missing_value="true" />
-        <field id="e3t_vsum300"  field_ref="e3t_300"            grid_ref="grid_T_vsum"   detect_missing_value="true" />
-	<field id="masscello"    long_name="Sea Water Mass per unit area"   standard_name="sea_water_mass_per_unit_area"   unit="kg/m2"   grid_ref="grid_T_3D"/>
-        <field id="volcello"     long_name="Ocean Volume"                   standard_name="ocean_volume"   unit="m3"       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 >
-
-        <field id="toce_e3t_300"      field_ref="toce_e3t"          unit="degree_C"     grid_ref="grid_T_zoom_300"      detect_missing_value="true" />
-        <field id="toce_e3t_vsum300"  field_ref="toce_e3t_300"      unit="degress_C*m"  grid_ref="grid_T_vsum"  detect_missing_value="true" />
-        <field id="toce_vmean300"     field_ref="toce_e3t_vsum300"  unit="degree_C"     grid_ref="grid_T_vsum"  detect_missing_value="true" > toce_e3t_vsum300/e3t_vsum300 </field>
-
-        <!-- AGRIF sponge -->
-        <field id="agrif_spt"         long_name=" AGRIF t-sponge coefficient"   unit=" " />
-
-        <!-- 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="Bulk sea surface temperature"                       standard_name="bulk_sea_surface_temperature"        unit="degC"     />
-        <field id="t_skin"       long_name="Skin temperature aka SSST"                          standard_name="skin_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="sbh"          long_name="bottom thickness"                                                                                       unit="m"    />
-
-        <field id="taubot"       long_name="bottom stress module"                                                                                   unit="N/m2"     />
-
-         <!-- Case EOS = TEOS-10 : output potential temperature -->
-	<field id="toce_pot"     long_name="Sea Water Potential Temperature"              standard_name="sea_water_potential_temperature"   unit="degC"     grid_ref="grid_T_3D"/>
-        <field id="sst_pot"      long_name="potential sea surface temperature"             standard_name="sea_surface_temperature"             unit="degC"     />
-        <field id="tosmint_pot"  long_name="vertical integral of potential temperature times density"   standard_name="integral_wrt_depth_of_product_of_density_and_potential_temperature"  unit="(kg m2) degree_C" />
-
-
-        <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 ln_zad_Aimp=.true. -->
-        <field id="Courant"      long_name="Courant number"                                                                 unit="#"   grid_ref="grid_T_3D" />
-        <field id="wimp"         long_name="Implicit vertical velocity"                                                     unit="m/s" grid_ref="grid_T_3D" />
-        <field id="wexp"         long_name="Explicit vertical velocity"                                                     unit="m/s" grid_ref="grid_T_3D" />
-        <field id="wi_cff"       long_name="Fraction of implicit vertical velocity"                                         unit="#"   grid_ref="grid_T_3D" />
-
-        <!-- 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="26d"          long_name="Depth of 26C isotherm"                          standard_name="depth_of_isosurface_of_sea_water_potential_temperature"                            unit="m"   axis_ref="iax_26C"   />
-        <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"                      />
-        <field id="hc700"        long_name="Heat content 0-700m"                            standard_name="integral_of_sea_water_potential_temperature_wrt_depth_expressed_as_heat_content"   unit="J/m2"                      />
-        <field id="hc2000"       long_name="Heat content 0-2000m"                           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" />
-
-        <!-- variables available with ln_diacfl=.true. -->
-        <field id="cfl_cu"       long_name="u-courant number"   unit="#" />
-        <field id="cfl_cv"       long_name="v-courant number"   unit="#" />
-        <field id="cfl_cw"       long_name="w-courant number"   unit="#" />
-
-      </field_group> <!-- grid_T -->
-
-      <!-- Tides -->
-
-      <field_group id="Tides_T" grid_ref="grid_T_2D" operation="once" >
-        <!-- Tidal potential -->
-        <field id="tide_pot"      long_name="Total tidal potential" unit="m" />
-        <field id="tide_pot_M2"   long_name="M2 tidal potential"    unit="m" />
-        <field id="tide_pot_N2"   long_name="N2 tidal potential"    unit="m" />
-        <field id="tide_pot_2N2"  long_name="2N2 tidal potential"   unit="m" />
-        <field id="tide_pot_S2"   long_name="S2 tidal potential"    unit="m" />
-        <field id="tide_pot_K2"   long_name="K2 tidal potential"    unit="m" />
-        <field id="tide_pot_K1"   long_name="K1 tidal potential"    unit="m" />
-        <field id="tide_pot_O1"   long_name="O1 tidal potential"    unit="m" />
-        <field id="tide_pot_Q1"   long_name="Q1 tidal potential"    unit="m" />
-        <field id="tide_pot_P1"   long_name="P1 tidal potential"    unit="m" />
-        <field id="tide_pot_M4"   long_name="M4 tidal potential"    unit="m" />
-        <field id="tide_pot_Mf"   long_name="Mf tidal potential"    unit="m" />
-        <field id="tide_pot_Mm"   long_name="Mm tidal potential"    unit="m" />
-        <field id="tide_pot_Msqm" long_name="Msqm tidal potential"  unit="m" />
-        <field id="tide_pot_Mtm"  long_name="Mtm tidal potential"   unit="m" />
-        <field id="tide_pot_S1"   long_name="S1 tidal potential"    unit="m" />
-        <field id="tide_pot_MU2"  long_name="MU2 tidal potential"   unit="m" />
-        <field id="tide_pot_NU2"  long_name="NU2 tidal potential"   unit="m" />
-        <field id="tide_pot_L2"   long_name="L2 tidal potential"    unit="m" />
-        <field id="tide_pot_T2"   long_name="T2 tidal potential"    unit="m" />
-      </field_group>
-
-      <!-- OSMOSIS variables (available with ln_zdfosm=.true.) -->
-
-      <field_group id="OSMOSIS_T" grid_ref="grid_T_2D">
-        <field id="zwth0"               long_name="surface non-local temperature flux"       unit="deg m/s" />
-        <field id="zws0"                long_name="surface non-local salinity flux"          unit="psu m/s" />
-        <field id="hbl"                 long_name="boundary layer depth"                     unit="m"       />
-        <field id="hbli"                long_name="initial boundary layer depth"             unit="m"       />
-        <field id="dstokes"             long_name="stokes drift  depth scale"                unit="m"       />
-        <field id="zustke"              long_name="magnitude of stokes drift  at T-points"   unit="m/s"     />
-        <field id="zwstrc"              long_name="convective velocity scale"                unit="m/s"     />
-        <field id="zwstrl"              long_name="langmuir velocity scale"                  unit="m/s"     />
-        <field id="zustar"              long_name="friction velocity"                        unit="m/s"     />
-        <field id="zhbl"                long_name="boundary layer depth"                     unit="m"       />
-        <field id="zhml"                long_name="mixed layer depth"                        unit="m"       />
-        <field id="wind_wave_abs_power" long_name="\rho |U_s| x u*^2"                        unit="mW"      />
-        <field id="wind_wave_power"     long_name="U_s \dot  tau"                            unit="mW"      />
-        <field id="wind_power"          long_name="\rho  u*^3"                               unit="mW"      />
-
-        <!-- extra OSMOSIS diagnostics -->
-        <field id="zwthav"              long_name="av turb flux of T in ml"                  unit="deg m/s" />
-        <field id="zt_ml"               long_name="av T in ml"                               unit="deg"     />
-        <field id="zwth_ent"            long_name="entrainment turb flux of T"               unit="deg m/s" />
-        <field id="zhol"                long_name="Hoenekker number"                         unit="#"       />
-        <field id="zdh"                 long_name="Pycnocline  depth - grid"                 unit=" m"      />
-      </field_group>
-
-      <field_group id="OSMOSIS_W" grid_ref="grid_W_3D" operation="instant" >
-        <field id="ghamt"       long_name="non-local temperature flux"                       unit="deg m/s" />
-        <field id="ghams"       long_name="non-local salinity flux"                          unit="psu m/s" />
-        <field id="zdtdz_pyc"   long_name="Pycnocline temperature gradient"                  unit=" deg/m"  />
-      </field_group>
-
-      <field_group id="OSMOSIS_U" grid_ref="grid_U_2D" >
-        <field id="ghamu"       long_name="non-local u-momentum flux"   grid_ref="grid_U_3D" unit="m^2/s^2" />
-        <field id="us_x"        long_name="i component of Stokes drift"                      unit="m/s"     />
-      </field_group>
-
-      <field_group id="OSMOSIS_V" grid_ref="grid_V_2D" >
-        <field id="ghamv"       long_name="non-local v-momentum flux"   grid_ref="grid_V_3D" unit="m^2/s^2" />
-        <field id="us_y"        long_name="j component of Stokes drift"                      unit="m/s"     />
-      </field_group>
-
-      <!-- SBC -->
-      <field_group id="SBC" > <!-- time step automaticaly defined based on nn_fsbc -->
-
-        <field_group id="SBC_2D" grid_ref="grid_T_2D" >
-
-          <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="wclosea"      long_name="closed sea empmr correction"          standard_name="closea_empmr"                                                         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="qclosea"      long_name="closed sea heat content flux"          standard_name="closea_heat_content_downward_flux"                                    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"                            />
-
-          <!-- * 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="isftfrz_cav"     long_name="freezing point temperature at ocean/isf interface"                unit="degC"     />
-          <field id="isftfrz_par"     long_name="freezing point temperature in the parametrization boundary layer" unit="degC"     />
-          <field id="fwfisf_cav"      long_name="Ice shelf melt rate"                           unit="kg/m2/s"  />
-          <field id="fwfisf_par"      long_name="Ice shelf melt rate"                           unit="kg/m2/s"  />
-          <field id="qoceisf_cav"     long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     />
-          <field id="qoceisf_par"     long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     />
-          <field id="qlatisf_cav"     long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
-          <field id="qlatisf_par"     long_name="Ice shelf latent heat flux"                    unit="W/m2"     />
-          <field id="qhcisf_cav"      long_name="Ice shelf heat content flux of injected water" unit="W/m2"     />
-          <field id="qhcisf_par"      long_name="Ice shelf heat content flux of injected water" unit="W/m2"     />
-          <field id="fwfisf3d_cav"    long_name="Ice shelf melt rate"                           unit="kg/m2/s"  grid_ref="grid_T_3D" />
-          <field id="fwfisf3d_par"    long_name="Ice shelf melt rate"                           unit="kg/m2/s"  grid_ref="grid_T_3D" />
-          <field id="qoceisf3d_cav"   long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="qoceisf3d_par"   long_name="Ice shelf ocean  heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="qlatisf3d_cav"   long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="qlatisf3d_par"   long_name="Ice shelf latent heat flux"                    unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="qhcisf3d_cav"    long_name="Ice shelf heat content flux of injected water" unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="qhcisf3d_par"    long_name="Ice shelf heat content flux of injected water" unit="W/m2"     grid_ref="grid_T_3D" />
-          <field id="ttbl_cav"        long_name="temperature in Losch tbl"                      unit="degC"     />
-          <field id="ttbl_par"        long_name="temperature in the parametrisation boundary layer" unit="degC" />
-          <field id="isfthermald_cav" long_name="thermal driving of ice shelf melting"          unit="degC"     />
-          <field id="isfthermald_par" long_name="thermal driving of ice shelf melting"          unit="degC"     />
-          <field id="isfgammat"       long_name="Ice shelf heat-transfert velocity"             unit="m/s"      />
-          <field id="isfgammas"       long_name="Ice shelf salt-transfert velocity"             unit="m/s"      />
-          <field id="stbl"            long_name="salinity in the Losh tbl"                      unit="1e-3"     />
-          <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="isfustar"        long_name="ustar at T point used in ice shelf melting"    unit="m/s"      />
-          <field id="qconisf"         long_name="Conductive heat flux through the ice shelf"    unit="W/m2"     />
-
-          <!-- *_oce variables available with ln_blk_clio or ln_blk_core -->
-          <field id="rho_air"      long_name="Air density at 10m above sea surface"         standard_name="rho_air_10m"                                        unit="kg/m3" />
-          <field id="dt_skin"      long_name="SSST-SST temperature difference"              standard_name="SSST-SST"                                             unit="K"   />
-          <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="evap_oce"     long_name="Evaporation over open ocean"                  standard_name="evaporation"                                        unit="kg/m2/s" />
-          <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="qns_oce"      long_name="non-solar heat flux at ocean surface (including E-P)"                                                            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"  />
-
-          <!-- variables computed by the bulk parameterization algorithms (ln_blk) -->
-          <field id="Cd_oce"      long_name="Drag coefficient over open ocean"              standard_name="drag_coefficient_water"                unit=""  />
-          <field id="Ce_oce"      long_name="Evaporaion coefficient over open ocean"        standard_name="evap_coefficient_water"                unit=""  />
-          <field id="Ch_oce"      long_name="Sensible heat coefficient over open ocean"     standard_name="sensible_heat_coefficient_water"       unit=""  />
-          <field id="theta_zt"    long_name="Potential air temperature at z=zt"             standard_name="potential_air_temperature_at_zt"       unit="degC" />
-          <field id="q_zt"        long_name="Specific air humidity at z=zt"                 standard_name="specific_air_humidity_at_zt"           unit="kg/kg" />
-          <field id="theta_zu"    long_name="Potential air temperature at z=zu"             standard_name="potential_air_temperature_at_zu"       unit="degC" />
-          <field id="q_zu"        long_name="Specific air humidity at z=zu"                 standard_name="specific_air_humidity_at_zu"           unit="kg/kg" />
-          <field id="ssq"         long_name="Saturation specific humidity of air at z=0"    standard_name="surface_air_saturation_spec_humidity"  unit="kg/kg" />
-          <field id="wspd_blk"    long_name="Bulk wind speed at z=zu"                       standard_name="bulk_wind_speed_at_zu"                 unit="m/s"   />
-          <!-- ln_blk + key_si3 -->
-          <field id="Cd_ice"      long_name="Drag coefficient over ice"                     standard_name="drag_coefficient_ice"                 unit=""  />
-          <field id="Ce_ice"      long_name="Evaporaion coefficient over ice"               standard_name="evap_coefficient_ice"                 unit=""  />
-          <field id="Ch_ice"      long_name="Sensible heat coefficient over ice"            standard_name="sensible_heat_coefficient_ice"        unit=""  />
-
-          <!-- 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="rain_ao_cea"   long_name="Liquid precipitation over ice-free ocean (cell average)"  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_prec_cea" long_name="heat flux due to all precip"                              standard_name="temperature_flux_due_to_all_precip_expressed_as_heat_flux_into_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>
-
-
-      </field_group> <!-- SBC -->
-
-      <!-- ABL -->
-      <field_group id="ABL" > <!-- time step automaticaly defined based on nn_fsbc -->
-
-	<!-- variables available with ABL on atmospheric T grid-->
-	<field_group id="grid_ABL3D" grid_ref="grid_TA_3D" >
-          <field id="u_abl"      long_name="ABL i-horizontal velocity"     standard_name="abl_x_velocity" unit="m/s"      />
-          <field id="v_abl"      long_name="ABL j-horizontal velocity"     standard_name="abl_y_velocity" unit="m/s"      />
-          <field id="t_abl"      long_name="ABL potential temperature"     standard_name="abl_theta"      unit="K"        />
-          <field id="q_abl"      long_name="ABL specific humidity"         standard_name="abl_qspe"       unit="kg/kg"    />
-          <!-- debug (to be removed) -->
-          <field id="u_dta"      long_name="DTA i-horizontal velocity"     standard_name="dta_x_velocity" unit="m/s"      />
-          <field id="v_dta"      long_name="DTA j-horizontal velocity"     standard_name="dta_y_velocity" unit="m/s"      />
-          <field id="t_dta"      long_name="DTA potential temperature"     standard_name="dta_theta"      unit="K"        />
-          <field id="q_dta"      long_name="DTA specific humidity"         standard_name="dta_qspe"       unit="kg/kg"    />
-          <field id="u_geo"      long_name="GEO i-horizontal velocity"     standard_name="geo_x_velocity" unit="m/s"      />
-          <field id="v_geo"      long_name="GEO j-horizontal velocity"     standard_name="geo_y_velocity" unit="m/s"      />
-          <field id="tke_abl"    long_name="ABL turbulent kinetic energy"  standard_name="abl_tke"        unit="m2/s2"    />
-          <field id="avm_abl"    long_name="ABL turbulent viscosity"       standard_name="abl_avm"        unit="m2/s"     />
-          <field id="avt_abl"    long_name="ABL turbulent diffusivity"     standard_name="abl_avt"        unit="m2/s"     />
-          <field id="mxlm_abl"   long_name="ABL master mixing length"      standard_name="abl_mxlm"       unit="m"        />
-          <field id="mxld_abl"   long_name="ABL dissipative mixing length" standard_name="abl_mxld"       unit="m"        />
-	</field_group>
-
-	<field_group id="grid_ABL2D" grid_ref="grid_TA_2D" >
-          <field id="pblh"       long_name="ABL height"                    standard_name="abl_height"     unit="m"        />
-          <field id="uz1_abl"    long_name="ABL i-horizontal velocity"     standard_name="abl_x_velocity" unit="m/s"      />
-          <field id="vz1_abl"    long_name="ABL j-horizontal velocity"     standard_name="abl_y_velocity" unit="m/s"      />
-          <field id="uvz1_abl"   long_name="ABL wind speed module"         standard_name="abl_wind_speed" unit="m/s"       > sqrt( uz1_abl^2 + vz1_abl^2 ) </field>
-          <field id="tz1_abl"    long_name="ABL potential temperature"     standard_name="abl_theta"      unit="K"        />
-          <field id="qz1_abl"    long_name="ABL specific humidity"         standard_name="abl_qspe"       unit="kg/kg"    />
-          <field id="uz1_dta"    long_name="DTA i-horizontal velocity"     standard_name="dta_x_velocity" unit="m/s"      />
-          <field id="vz1_dta"    long_name="DTA j-horizontal velocity"     standard_name="dta_y_velocity" unit="m/s"      />
-          <field id="uvz1_dta"   long_name="DTA wind speed module"         standard_name="dta_wind_speed" unit="m/s"       > sqrt( uz1_dta^2 + vz1_dta^2 ) </field>
-          <field id="tz1_dta"    long_name="DTA potential temperature"     standard_name="dta_theta"      unit="K"        />
-          <field id="qz1_dta"    long_name="DTA specific humidity"         standard_name="dta_qspe"       unit="kg/kg"    />
-          <!-- debug (to be removed) -->
-          <field id="uz1_geo"    long_name="GEO i-horizontal velocity"     standard_name="geo_x_velocity" unit="m/s"      />
-          <field id="vz1_geo"    long_name="GEO j-horizontal velocity"     standard_name="geo_y_velocity" unit="m/s"      />
-          <field id="uvz1_geo"   long_name="GEO wind speed module"         standard_name="geo_wind_speed" unit="m/s"       > sqrt( uz1_geo^2 + vz1_geo^2 ) </field>
-	</field_group>
-
-      </field_group> <!-- ABL -->
-
-
-      <!-- U grid -->
-
-      <field_group id="grid_U"   grid_ref="grid_U_2D">
-        <field id="e2u"           long_name="U-cell width in meridional direction"                   standard_name="cell_width"                  unit="m"                               />
-        <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="uoce_e3u_vsum" long_name="ocean current along i-axis * e3u summed on the vertical"  field_ref="uoce_e3u"    unit="m3/s"       grid_ref="grid_U_vsum"/>
-        <field id="uocetr_vsum"   long_name="ocean transport along i-axis  summed on the vertical"         field_ref="e2u"       unit="m3/s"> this * uoce_e3u_vsum  </field>
-
-        <field id="uocetr_vsum_op"    long_name="ocean current along i-axis * e3u * e2u summed on the vertical"  read_access="true"  freq_op="1mo"    field_ref="e2u"       unit="m3/s"> @uocetr_vsum </field>
-        <field id="uocetr_vsum_cumul" long_name="ocean current along i-axis * e3u * e2u cumulated from southwest point" freq_offset="_reset_" operation="instant" freq_op="1mo"  unit="m3/s" />
-        <field id="msftbarot"         long_name="ocean_barotropic_mass_streamfunction"   unit="kg s-1" > uocetr_vsum_cumul * $rau0 </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" />
-        <field id="ssuww"        long_name="ocean surface wind work along i-axis"                   standard_name="surface_x_wind_work"         unit="N/m*s"                            > utau * ssu </field>
-        <!-- AGRIF sponge -->
-        <field id="agrif_spu"    long_name=" AGRIF u-sponge coefficient"   unit=" " />
-        <!-- u-eddy diffusivity coefficients (available if ln_traldf_OFF=F) -->
-        <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"/>
-        <!-- u-eiv diffusivity coefficients (available if ln_ldfeiv=F) -->
-        <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 (ln_mle=T) -->
-        <field id="psiu_mle"     long_name="MLE streamfunction along i-axis"   unit="m3/s"   grid_ref="grid_U_3D" />
-
-        <!-- uoce_eiv: available EIV (ln_ldfeiv=T and ln_ldfeiv_dia=T) -->
-    	<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" />
-        <field id="ueiv_masstr"   long_name="EIV Ocean Mass X Transport"                                      standard_name="bolus_ocean_mass_x_transport"                   unit="kg/s"  grid_ref="grid_U_3D" />
-        <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" />
-
-        <!-- uoce_bbl: available with ln_trabbl=T and nn_bbl_adv=1 -->
-        <field id="uoce_bbl"     long_name="BBL ocean current along i-axis"    unit="m/s"  />
-        <!-- ahu_bbl : available with ln_trabbl=T and nn_bbl_ldf=1 -->
-        <field id="ahu_bbl"      long_name="BBL diffusive flux along i-axis"   unit="m3/s" />
-
-        <!-- variables available with WAVE (ln_wave=T) -->
-        <field id="ustokes"      long_name="Stokes Drift Velocity i-axis"      standard_name="StokesDrift_x_velocity"      unit="m/s"        grid_ref="grid_U_3D" />
-        <field id="ustokes_e3u"  long_name="Stokes Drift Velocity i-axis  (thickness weighted)"                            unit="m/s"        grid_ref="grid_U_3D"  > ustokes * e3u </field>
-
-        <!-- variable for ice shelves -->
-        <field id="utbl"         long_name="zonal current in the Losh tbl"     unit="m/s" />
-
-        <!-- variables available with diaar5 -->
-        <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="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="e1v"          long_name="V-cell width in longitudinal direction"                 standard_name="cell_width"                  unit="m"                              />
-        <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" />
-        <field id="ssvww"        long_name="ocean surface wind work along j-axis"                   standard_name="surface_y_wind_work"         unit="N/m*s"                            > vtau * ssv </field>
-        <!-- AGRIF sponge -->
-        <field id="agrif_spv"    long_name=" AGRIF v-sponge coefficient"   unit=" " />
-        <!-- v-eddy diffusivity coefficients (available if ln_traldf_OFF=F) -->
-        <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"/>
-        <!-- v-eiv diffusivity coefficients (available if ln_ldfeiv=F) -->
-        <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 (ln_mle=T) -->
-        <field id="psiv_mle"     long_name="MLE streamfunction along j-axis"   unit="m3/s"   grid_ref="grid_V_3D" />
-
-        <!-- voce_eiv: available EIV (ln_ldfeiv=T and ln_ldfeiv_dia=T)  -->
-	<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" />
-        <field id="veiv_masstr"  long_name="EIV Ocean Mass Y Transport"      standard_name="bolus_ocean_mass_y_transport"   unit="kg/s"  grid_ref="grid_V_3D" />
-        <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" />
-
-
-        <!-- voce_bbl: available with ln_trabbl=T and nn_bbl_adv=1 -->
-        <field id="voce_bbl"     long_name="BBL ocean current along j-axis"    unit="m/s"  />
-        <!-- ahu_bbl : available with ln_trabbl=T and nn_bbl_ldf=1 -->
-        <field id="ahv_bbl"      long_name="BBL diffusive flux along j-axis"   unit="m3/s" />
-
-        <!-- variables available with WAVE (ln_wave=T) -->
-        <field id="vstokes"      long_name="Stokes Drift Velocity j-axis"      standard_name="StokesDrift_y_velocity"      unit="m/s"        grid_ref="grid_V_3D" />
-        <field id="vstokes_e3v"  long_name="Stokes Drift Velocity j-axis  (thickness weighted)"                            unit="m/s"        grid_ref="grid_V_3D"  > vstokes * e3v </field>
-
-        <!-- 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="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="woce_e3w"     long_name="ocean vertical velocity * e3w"                                                                        unit="m2/s"  > woce * e3w </field>
-        <field id="wocetr_eff"   long_name="effective ocean vertical transport"                                                                   unit="m3/s" />
-
-        <!-- woce_eiv: available with EIV  (ln_ldfeiv=T and ln_ldfeiv_dia=T)  -->
-        <field id="woce_eiv"     long_name="EIV ocean vertical velocity"                    standard_name="bolus_upward_sea_water_velocity"       unit="m/s"  />
-        <field id="weiv_masstr"  long_name="EIV Upward Ocean Mass Transport"  standard_name="bolus_upward_ocean_mass_transport"             unit="kg/s"   />
-        <field id="weiv_heattr3d" long_name="ocean bolus heat transport"    standard_name="ocean_heat_z_transport_due_to_bolus_advection"   unit="W"    />
-        <field id="weiv_salttr3d" long_name="ocean bolus salt transport"    standard_name="ocean_salt_z_transport_due_to_bolus_advection"   unit="kg"   />
-
-	<field id="avt"          long_name="vertical eddy diffusivity"                      standard_name="ocean_vertical_heat_diffusivity"       unit="m2/s" />
-        <field id="avt_e3w"      long_name="vertical heat diffusivity * e3w"                unit="m3/s" > avt * e3w </field>
-        <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" />
-        <field id="avm_e3w"      long_name="vertical eddy viscosity * e3w"   unit="m3/s" > avm * e3w </field>
-
-        <!-- avs: /= avt with ln_zdfddm=T -->
-        <field id="avs"          long_name="salt vertical eddy diffusivity"                 standard_name="ocean_vertical_salt_diffusivity"       unit="m2/s" />
-        <field id="avs_e3w"      long_name="vertical salt diffusivity * e3w"   unit="m3/s" > avs * e3w </field>
-	<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="avt_evd_e3w"  long_name="convective enhancement to vertical diffusivity * e3w "    unit="m3/s" > avt_evd * e3w </field>
-	<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 ln_zdfiwm=T -->
-        <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="internal wave-induced vertical diffusivity"     standard_name="ocean_vertical_tracer_diffusivity_due_to_internal_waves"         unit="m2/s" />
-        <field id="bflx_iwm"     long_name="internal wave-induced buoyancy flux"            standard_name="buoyancy_flux_due_to_internal_waves"                             unit="W/kg" />
-        <field id="pcmap_iwm"    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_iwm"     long_name="power density available for mixing"             standard_name="power_available_for_mixing_from_breaking_internal_waves"         unit="W/kg" />
-
-        <!-- variables available with WAVE (ln_wave=T) -->
-        <field id="wstokes"      long_name="Stokes Drift vertical velocity"                 standard_name="upward_StokesDrift_velocity"   unit="m/s" />
-
-        <!-- 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" />
-
-      </field_group>
-
-      <!-- F grid -->
-      <!-- AGRIF sponge -->
-      <field id="agrif_spf"    long_name=" AGRIF f-sponge coefficient"   unit=" " />
-      <!-- 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_scalar"  >
-      	<!-- Need to have a salinity reference climatological file : sali_ref_clim_monthly -->
-        <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="ssttot"     long_name="global mean sea surface temperature"          standard_name="sea_water_conservative_temperature"             unit="degC" />
-         <!-- EOS = TEOS-10 -->
-        <field id="temptot_pot" long_name="global mean potential temperature"            standard_name="sea_water_potential_temperature"               unit="degC" />
-
-      	<!-- 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>
-
-
-      <!-- transects -->
-      <field_group id="oce_straits">
-         <field id="uoce_e3u_ave"         long_name="Monthly average of u*e3u"                        field_ref="uoce_e3u"                    freq_op="1mo"   freq_offset="_reset_" > @uoce_e3u </field>
-         <field id="uoce_e3u_ave_vsum"    long_name="Vertical sum of u*e3u"                           field_ref="uoce_e3u_ave"         grid_ref="grid_U_vsum"     />
-         <field id="uocetr_vsum_section"  long_name="Total 2D transport in i-direction"               field_ref="uoce_e3u_ave_vsum"    grid_ref="grid_U_scalar"  detect_missing_value="true"> this * e2u </field>
-         <field id="uocetr_strait"        long_name="Total transport across lines in i-direction"     field_ref="uocetr_vsum_section"  grid_ref="grid_U_4strait" />
-         <field id="u_masstr_strait"      long_name="Sea water transport across line in i-direction"  field_ref="uocetr_strait"        grid_ref="grid_U_4strait_hsum" unit="kg/s"> this * maskMFO_u * $rau0 </field>
-
-         <field id="voce_e3v_ave"         long_name="Monthly average of v*e3v"                        field_ref="voce_e3v"                    freq_op="1mo"   freq_offset="_reset_" > @voce_e3v </field>
-         <field id="voce_e3v_ave_vsum"    long_name="Vertical sum of v*e3v"                           field_ref="voce_e3v_ave"         grid_ref="grid_V_vsum"      />
-         <field id="vocetr_vsum_section"  long_name="Total 2D transport of in j-direction"            field_ref="voce_e3v_ave_vsum"    grid_ref="grid_V_scalar"  detect_missing_value="true"> this * e1v </field>
-         <field id="vocetr_strait"        long_name="Total transport across lines in j-direction"     field_ref="vocetr_vsum_section"  grid_ref="grid_V_4strait"  />
-         <field id="v_masstr_strait"      long_name="Sea water transport across line in j-direction"  field_ref="vocetr_strait"        grid_ref="grid_V_4strait_hsum" unit="kg/s"> this * maskMFO_v * $rau0 </field>
-
-         <field id="masstr_strait"        long_name="Sea water transport across line"                                                  grid_ref="grid_4strait"  > u_masstr_strait + v_masstr_strait </field>
-      </field_group>
-
-
-      <!-- variables available with ln_floats -->
-
-      <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_melt_hcflx"    long_name="icb heat flux to ocean due to melting heat content"   unit="J/m2/s"                />
-        <field id="berg_melt_qlat"     long_name="icb heat flux to ocean due to melting latent heat"    unit="J/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="zomsf"         long_name="Overturning Stream-Function : All basins"                     unit="Sv"         grid_ref="grid_znl_W_3D" />
-        <field id="zotem"         long_name="Zonal Mean Temperature : All basins"                          unit="degree_C"   grid_ref="grid_znl_T_3D" />
-        <field id="zosal"         long_name="Zonal Mean Salinity : All basins"                             unit="0.001"      grid_ref="grid_znl_T_3D" />
-        <field id="zosrf"         long_name="Zonal Mean Surface : All basins"                              unit="m2"         grid_ref="grid_znl_T_3D" />
-        <field id="sophtove"      long_name="Overturning Heat Transport: All basins"                       unit="PW"         grid_ref="grid_znl_T_2D" />
-        <field id="sopstove"      long_name="Overturning Salt Transport: All basins"                       unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-        <field id="sophtbtr"      long_name="Barotropic Heat Transport: All basins"                        unit="PW"         grid_ref="grid_znl_T_2D" />
-        <field id="sopstbtr"      long_name="Barotropic Salt Transport: All basins"                        unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-        <field id="sophtadv"      long_name="Advective Heat Transport: All basins"                         unit="PW"         grid_ref="grid_znl_T_2D" />
-        <field id="sopstadv"      long_name="Advective Salt Transport: All basins"                         unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-        <field id="sophtldf"      long_name="Diffusive Heat Transport: All basins"                         unit="PW"         grid_ref="grid_znl_T_2D" />
-        <field id="sopstldf"      long_name="Diffusive Salt Transport: All basins"                         unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-        <field id="sophtvtr"      long_name="Heat Transport : All basins"                                  unit="PW"         grid_ref="grid_znl_T_2D" />
-        <field id="sopstvtr"      long_name="Salt Transport : All basins"                                  unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-        <field id="sophteiv"      long_name="Heat Transport from mesoscale eddy advection: All basins"     unit="PW"         grid_ref="grid_znl_T_2D" />
-        <field id="sopsteiv"      long_name="Salt Transport from mesoscale eddy advection : All basins"    unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-	<field id="sopstadv"      long_name="Advective Salt Transport"                                     unit="Giga g/s"   grid_ref="grid_znl_T_2D" />
-        <field id="sophtgyre"     long_name="Overturning heat transport due to gyre" field_ref="sophtove"  unit="W"          grid_ref="grid_znl_T_2D" > sophtvtr - sophtove  </field>
-	<field id="sopstgyre"     long_name="Overturning salt transport due to gyre" field_ref="sopstove"  unit="kg/s"       grid_ref="grid_znl_T_2D" > sophtvtr - sopstove  </field>
-       </field_group>
-
-       <field_group id="constant_fields"  grid_ref="grid_T_2D"  operation="once" >
-         <field id="bathy"       long_name="Sea floor depth below geoid"               standard_name="sea_floor_depth_below_geoid"               unit="m"/>
-         <field id="areacello"   long_name="Horizontal area of ocean grid cells"       standard_name="cell_area"                                 unit="m2" />
-         <field id="hfgeou"      long_name="Upward geothermal heat flux at sea floor"  standard_name="upward_geothermal_heat_flux_at_sea_floor"  unit="W/m2"/>
-         <field id="basins"      long_name="ocean tracer region masks"                 standard_name="ocean_tracer_region_masks"   unit="none" grid_ref="grid_basin"  />
-       </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 * e3ts </field>
-     <field id="strd_cdt_e3t"      unit="degC/s * m"  >  strd_cdt * e3ts </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 when explicit lateral mixing is used (ln_dynldf_OFF=F) -->
-     <field id="dispkexyfo"    long_name="KE-trend: lateral  mixing induced dissipation"   standard_name="ocean_kinetic_energy_dissipation_per_unit_area_due_to_xy_friction"                   unit="W/m^2" grid_ref="grid_T_2D" />
-     <field id="dispkevfo"     long_name="KE-trend: vertical mixing induced dissipation"   standard_name="ocean_kinetic_energy_dissipation_per_unit_area_due_to_vertical_friction"             unit="W/m^2" grid_ref="grid_T_2D" />
-     <!-- variables available with ln_traadv_eiv=T and ln_diaeiv=T -->
-     <field id="eketrd_eiv"    long_name="EKE-trend due to parameterized eddy advection"   standard_name="tendency_of_ocean_eddy_kinetic_energy_content_due_to_parameterized_eddy_advection"   unit="W/m^2" grid_ref="grid_T_2D" />
-
-     <!-- 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="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="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>
-
-    <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="vovecrtz25h"         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>
+link ../../../cfgs/SHARED/field_def_nemo-oce.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/file_def_nemo-oce.xml	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/file_def_nemo-oce.xml	(revision 14644)
@@ -17,5 +17,4 @@
           <field field_ref="sbt"        name="sbt"           operation="instant" />
           <field field_ref="sbs"        name="btra"          operation="instant" />
-          <field field_ref="sbh"        name="thick"         operation="instant" />
           <field field_ref="agrif_spt"  name="Agrif_sponge" />
 	</file>
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/EXPREF/namelist_cfg	(revision 14644)
@@ -3,5 +3,15 @@
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 !
-!
+!-----------------------------------------------------------------------
+&namusr_def    !   User defined :   OVERFLOW configuration
+!-----------------------------------------------------------------------
+   !                       !  type of vertical coordinate
+   ln_zco      = .false.      ! z-coordinate
+   ln_zps      = .true.       ! z-partial-step coordinate
+   ln_sco      = .false.      ! s-coordinate
+   rn_dx       =   5000.   !  horizontal resolution   [meters]
+   rn_dz       =     60.   !  vertical   resolution   [meters]
+   rn_f0       =  1.e-4    !  coriolis [s-1]
+/
 !-----------------------------------------------------------------------
 &namrun        !   parameters of the run
@@ -10,5 +20,5 @@
    cn_exp      =    "DOME" !  experience name
    nn_it000    =       1   !  first time step
-   nn_itend    =   16200   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
+   nn_itend    =   11520   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
    nn_stock    =       0   !  frequency of creation of a restart file (modulo referenced to 1)
 /
@@ -25,5 +35,5 @@
 !-----------------------------------------------------------------------
    ln_linssh  = .true.
-   rn_Dt      =   480.    !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_Dt      =   300.    !  time step for the dynamics (and tracer if nn_acc=0)
    rn_atfp    =    0.1    !  asselin time filter parameter
    ln_meshmask = .false.  !  =T create a mesh file
@@ -92,5 +102,5 @@
 !-----------------------------------------------------------------------
 &namtra_adv    !   advection scheme for tracer
-!-----------------------------------------------------------------------
+!----------------------------------------------------------------------
    ln_traadv_fct = .true. !  FCT scheme
       nn_fct_h   =  2            !  =2/4, horizontal 2nd / 4th order
@@ -153,9 +163,8 @@
 &namdyn_vor    !   option of physics/algorithm
 !-----------------------------------------------------------------------
-   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)
+   !
+   nn_e3f_typ = 1          !  type of e3f (EEN, ENE, ENS, MIX only)  =0  e3f = mi(mj(e3t))/4
+   !                       !                                         =1  e3f = mi(mj(e3t))/mi(mj( tmask))
 /
 !-----------------------------------------------------------------------
@@ -163,5 +172,5 @@
 !-----------------------------------------------------------------------
    ln_hpg_zps  = .false.  !  z-coordinate - partial steps (interpolation)
-   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+   ln_hpg_djc  = .true.   !  s-coordinate (standard jacobian formulation)
 /
 !-----------------------------------------------------------------------
@@ -189,10 +198,10 @@
 &namzdf        !   vertical physics                                     (default: NO selection)
 !-----------------------------------------------------------------------
-   ln_zad_Aimp = .true.       !  Courant number dependent scheme (Shchepetkin 2015)
+   ln_zad_Aimp = .false.       !  Courant number dependent scheme (Shchepetkin 2015)
    !                       ! type of vertical closure (required)
-   ln_zdfcst   = .true.       !  constant mixing
+   ln_zdfcst   = .false.      !  constant mixing
    ln_zdfric   = .false.      !  local Richardson dependent formulation (T =>   fill namzdf_ric)
    ln_zdftke   = .false.      !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
-   ln_zdfgls   = .false.      !  Generic Length Scale closure           (T =>   fill namzdf_gls)
+   ln_zdfgls   = .true.       !  Generic Length Scale closure           (T =>   fill namzdf_gls)
    ln_zdfosm   = .false.      !  OSMOSIS BL closure                     (T =>   fill namzdf_osm)
    !   
@@ -214,6 +223,6 @@
    !   
    !                       ! coefficients
-   rn_avm0     =   5.e-2     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
-   rn_avt0     =   0.0       !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avm0     =   1.e-5     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   1.e-6     !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
    nn_avb      =    0        !  profile for background avt & avm (=1) or not (=0)
    nn_havtb    =    0        !  horizontal shape for avtb (=1) or not (=0)
@@ -261,5 +270,5 @@
    ctypebdy='W'
    nbdyind = 2 
-   nbdybeg = 1
-   nbdyend = 87 
-/
+   nbdybeg = 1 
+   nbdyend = 164 
+/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/diawri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/diawri.F90	(revision 14643)
+++ 	(revision )
@@ -1,1066 +1,0 @@
-MODULE diawri
-   !!======================================================================
-   !!                     ***  MODULE  diawri  ***
-   !! Ocean diagnostics :  write ocean output files
-   !!=====================================================================
-   !! History :  OPA  ! 1991-03  (M.-A. Foujols)  Original code
-   !!            4.0  ! 1991-11  (G. Madec)
-   !!                 ! 1992-06  (M. Imbard)  correction restart file
-   !!                 ! 1992-07  (M. Imbard)  split into diawri and rstwri
-   !!                 ! 1993-03  (M. Imbard)  suppress writibm
-   !!                 ! 1998-01  (C. Levy)  NETCDF format using ioipsl INTERFACE
-   !!                 ! 1999-02  (E. Guilyardi)  name of netCDF files + variables
-   !!            8.2  ! 2000-06  (M. Imbard)  Original code (diabort.F)
-   !!   NEMO     1.0  ! 2002-06  (A.Bozec, E. Durand)  Original code (diainit.F)
-   !!             -   ! 2002-09  (G. Madec)  F90: Free form and module
-   !!             -   ! 2002-12  (G. Madec)  merge of diabort and diainit, F90
-   !!                 ! 2005-11  (V. Garnier) Surface pressure gradient organization
-   !!            3.2  ! 2008-11  (B. Lemaire) creation from old diawri
-   !!            3.7  ! 2014-01  (G. Madec) remove eddy induced velocity from no-IOM output
-   !!                 !                     change name of output variables in dia_wri_state
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   dia_wri       : create the standart output files
-   !!   dia_wri_state : create an output NetCDF file for a single instantaeous ocean state and forcing fields
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers 
-   USE isf_oce
-   USE isfcpl
-   USE abl            ! abl variables in case ln_abl = .true.
-   USE dom_oce        ! ocean space and time domain
-   USE phycst         ! physical constants
-   USE dianam         ! build name of file (routine)
-   USE diahth         ! thermocline diagnostics
-   USE dynadv   , ONLY: ln_dynadv_vec
-   USE icb_oce        ! Icebergs
-   USE icbdia         ! Iceberg budgets
-   USE ldftra         ! lateral physics: eddy diffusivity coef.
-   USE ldfdyn         ! lateral physics: eddy viscosity   coef.
-   USE sbc_oce        ! Surface boundary condition: ocean fields
-   USE sbc_ice        ! Surface boundary condition: ice fields
-   USE sbcssr         ! restoring term toward SST/SSS climatology
-   USE sbcwave        ! wave parameters
-   USE wet_dry        ! wetting and drying
-   USE zdf_oce        ! ocean vertical physics
-   USE zdfdrg         ! ocean vertical physics: top/bottom friction
-   USE zdfmxl         ! mixed layer
-   !
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE in_out_manager ! I/O manager
-   USE dia25h         ! 25h Mean output
-   USE iom            ! 
-   USE ioipsl         ! 
-
-#if defined key_si3
-   USE ice 
-   USE icewri 
-#endif
-   USE lib_mpp         ! MPP library
-   USE timing          ! preformance summary
-   USE diu_bulk        ! diurnal warm layer
-   USE diu_coolskin    ! Cool skin
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   dia_wri                 ! routines called by step.F90
-   PUBLIC   dia_wri_state
-   PUBLIC   dia_wri_alloc           ! Called by nemogcm module
-#if ! defined key_iomput   
-   PUBLIC   dia_wri_alloc_abl       ! Called by sbcabl  module (if ln_abl = .true.)
-#endif
-   INTEGER ::   nid_T, nz_T, nh_T, ndim_T, ndim_hT   ! grid_T file
-   INTEGER ::          nb_T              , ndim_bT   ! grid_T file
-   INTEGER ::   nid_U, nz_U, nh_U, ndim_U, ndim_hU   ! grid_U file
-   INTEGER ::   nid_V, nz_V, nh_V, ndim_V, ndim_hV   ! grid_V file
-   INTEGER ::   nid_W, nz_W, nh_W                    ! grid_W file
-   INTEGER ::   nid_A, nz_A, nh_A, ndim_A, ndim_hA   ! grid_ABL file   
-   INTEGER ::   ndex(1)                              ! ???
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hT, ndex_hU, ndex_hV
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_hA, ndex_A ! ABL
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_T, ndex_U, ndex_V
-   INTEGER, SAVE, ALLOCATABLE, DIMENSION(:) :: ndex_bT
-
-   !! * Substitutions
-#  include "do_loop_substitute.h90"
-#  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: diawri.F90 13565 2020-10-05 14:18:53Z jchanut $
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-#if defined key_iomput
-   !!----------------------------------------------------------------------
-   !!   'key_iomput'                                        use IOM library
-   !!----------------------------------------------------------------------
-   INTEGER FUNCTION dia_wri_alloc()
-      !
-      dia_wri_alloc = 0
-      !
-   END FUNCTION dia_wri_alloc
-
-   
-   SUBROUTINE dia_wri( kt, Kmm )
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE dia_wri  ***
-      !!                   
-      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
-      !!      NETCDF format is used by default 
-      !!
-      !! ** Method  :  use iom_put
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-      INTEGER, INTENT( in ) ::   Kmm     ! ocean time level index
-      !!
-      INTEGER ::   ji, jj, jk       ! dummy loop indices
-      INTEGER ::   ikbot            ! local integer
-      REAL(wp)::   zztmp , zztmpx   ! local scalar
-      REAL(wp)::   zztmp2, zztmpy   !   -      -
-      REAL(wp), DIMENSION(jpi,jpj)     ::   z2d   ! 2D workspace
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   z3d   ! 3D workspace
-      !!----------------------------------------------------------------------
-      ! 
-      IF( ln_timing )   CALL timing_start('dia_wri')
-      ! 
-      ! Output the initial state and forcings
-      IF( ninist == 1 ) THEN                       
-         CALL dia_wri_state( Kmm, 'output.init' )
-         ninist = 0
-      ENDIF
-
-      ! Output of initial vertical scale factor
-      CALL iom_put("e3t_0", e3t_0(:,:,:) )
-      CALL iom_put("e3u_0", e3u_0(:,:,:) )
-      CALL iom_put("e3v_0", e3v_0(:,:,:) )
-      !
-      IF ( iom_use("tpt_dep") ) THEN
-         DO jk = 1, jpk
-            z3d(:,:,jk) = gdept(:,:,jk,Kmm)
-         END DO
-         CALL iom_put( "tpt_dep",     z3d(:,:,:) )
-      ENDIF
-
-      IF ( iom_use("e3t") .OR. iom_use("e3tdef") ) THEN  ! time-varying e3t
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3t(:,:,jk,Kmm)
-         END DO
-         CALL iom_put( "e3t"     ,     z3d(:,:,:) )
-         CALL iom_put( "e3tdef"  , ( ( z3d(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2 ) 
-      ENDIF 
-      IF ( iom_use("e3u") ) THEN                         ! time-varying e3u
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3u(:,:,jk,Kmm)
-         END DO 
-         CALL iom_put( "e3u" , z3d(:,:,:) )
-      ENDIF
-      IF ( iom_use("e3v") ) THEN                         ! time-varying e3v
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3v(:,:,jk,Kmm)
-         END DO 
-         CALL iom_put( "e3v" , z3d(:,:,:) )
-      ENDIF
-      IF ( iom_use("e3w") ) THEN                         ! time-varying e3w
-         DO jk = 1, jpk
-            z3d(:,:,jk) =  e3w(:,:,jk,Kmm)
-         END DO 
-         CALL iom_put( "e3w" , z3d(:,:,:) )
-      ENDIF
-
-      IF( ll_wd ) THEN                                   ! sea surface height (brought back to the reference used for wetting and drying)
-         CALL iom_put( "ssh" , (ssh(:,:,Kmm)+ssh_ref)*tmask(:,:,1) )
-      ELSE
-         CALL iom_put( "ssh" , ssh(:,:,Kmm) )              ! sea surface height
-      ENDIF
-
-      IF( iom_use("wetdep") )   &                  ! wet depth
-         CALL iom_put( "wetdep" , ht_0(:,:) + ssh(:,:,Kmm) )
-      
-      CALL iom_put( "toce", ts(:,:,:,jp_tem,Kmm) )    ! 3D temperature
-      CALL iom_put(  "sst", ts(:,:,1,jp_tem,Kmm) )    ! surface temperature
-      IF ( iom_use("sbt") ) THEN
-         DO_2D( 1, 1, 1, 1 )
-            ikbot = mbkt(ji,jj)
-            z2d(ji,jj) = ts(ji,jj,ikbot,jp_tem,Kmm)
-         END_2D
-         CALL iom_put( "sbt", z2d )                ! bottom temperature
-      ENDIF
-      
-      CALL iom_put( "soce", ts(:,:,:,jp_sal,Kmm) )    ! 3D salinity
-      CALL iom_put(  "sss", ts(:,:,1,jp_sal,Kmm) )    ! surface salinity
-      IF ( iom_use("sbs") ) THEN
-         DO_2D( 1, 1, 1, 1 )
-            ikbot = mbkt(ji,jj)
-            z2d(ji,jj) = ts(ji,jj,ikbot,jp_sal,Kmm)
-         END_2D
-         CALL iom_put( "sbs", z2d )                ! bottom salinity
-      ENDIF
-
-      ! Plume thickness
-      IF ( iom_use("sbh") ) THEN
-         z2d(:,:) = 0._wp
-         DO_2D( 1, 1, 1, 1 )
-            ikbot = mbkt(ji,jj)
-            DO jk = ikbot,1,-1
-               IF ( ts(ji,jj,jk,jp_sal,Kmm) > 0.01_wp ) THEN 
-                  z2d(ji,jj) = z2d(ji,jj) + e3t(ji,jj,jk,Kmm)*tmask(ji,jj,jk)
-               ELSE ; exit 
-               END IF
-            END DO
-         END_2D
-         CALL iom_put( "sbh", z2d )                ! bottom salinity
-      ENDIF
-
-#if ! defined key_qco
-      CALL iom_put( "rhop", rhop(:,:,:) )          ! 3D potential density (sigma0)
-#endif
-
-      IF ( iom_use("taubot") ) THEN                ! bottom stress
-         zztmp = rho0 * 0.25
-         z2d(:,:) = 0._wp
-         DO_2D( 0, 0, 0, 0 )
-            zztmp2 = (  ( rCdU_bot(ji+1,jj)+rCdU_bot(ji  ,jj) ) * uu(ji  ,jj,mbku(ji  ,jj),Kmm)  )**2   &
-               &   + (  ( rCdU_bot(ji  ,jj)+rCdU_bot(ji-1,jj) ) * uu(ji-1,jj,mbku(ji-1,jj),Kmm)  )**2   &
-               &   + (  ( rCdU_bot(ji,jj+1)+rCdU_bot(ji,jj  ) ) * vv(ji,jj  ,mbkv(ji,jj  ),Kmm)  )**2   &
-               &   + (  ( rCdU_bot(ji,jj  )+rCdU_bot(ji,jj-1) ) * vv(ji,jj-1,mbkv(ji,jj-1),Kmm)  )**2
-            z2d(ji,jj) = zztmp * SQRT( zztmp2 ) * tmask(ji,jj,1) 
-            !
-         END_2D
-         CALL lbc_lnk( 'diawri', z2d, 'T', 1.0_wp )
-         CALL iom_put( "taubot", z2d )           
-      ENDIF
-         
-      CALL iom_put( "uoce", uu(:,:,:,Kmm) )            ! 3D i-current
-      CALL iom_put(  "ssu", uu(:,:,1,Kmm) )            ! surface i-current
-      IF ( iom_use("sbu") ) THEN
-         DO_2D( 1, 1, 1, 1 )
-            ikbot = mbku(ji,jj)
-            z2d(ji,jj) = uu(ji,jj,ikbot,Kmm)
-         END_2D
-         CALL iom_put( "sbu", z2d )                ! bottom i-current
-      ENDIF
-      
-      CALL iom_put( "voce", vv(:,:,:,Kmm) )            ! 3D j-current
-      CALL iom_put(  "ssv", vv(:,:,1,Kmm) )            ! surface j-current
-      IF ( iom_use("sbv") ) THEN
-         DO_2D( 1, 1, 1, 1 )
-            ikbot = mbkv(ji,jj)
-            z2d(ji,jj) = vv(ji,jj,ikbot,Kmm)
-         END_2D
-         CALL iom_put( "sbv", z2d )                ! bottom j-current
-      ENDIF
-
-      IF( ln_zad_Aimp ) ww = ww + wi               ! Recombine explicit and implicit parts of vertical velocity for diagnostic output
-      CALL iom_put( "woce", ww )                   ! vertical velocity
-
-      IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
-         ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
-         z2d(:,:) = rho0 * e1e2t(:,:)
-         DO jk = 1, jpk
-            z3d(:,:,jk) = ww(:,:,jk) * z2d(:,:)
-         END DO
-         CALL iom_put( "w_masstr" , z3d )  
-         IF( iom_use('w_masstr2') )   CALL iom_put( "w_masstr2", z3d(:,:,:) * z3d(:,:,:) )
-      ENDIF
-      !
-      IF( ln_zad_Aimp ) ww = ww - wi               ! Remove implicit part of vertical velocity that was added for diagnostic output
-
-      CALL iom_put( "avt" , avt )                  ! T vert. eddy diff. coef.
-      CALL iom_put( "avs" , avs )                  ! S vert. eddy diff. coef.
-      CALL iom_put( "avm" , avm )                  ! T vert. eddy visc. coef.
-
-      IF( iom_use('logavt') )   CALL iom_put( "logavt", LOG( MAX( 1.e-20_wp, avt(:,:,:) ) ) )
-      IF( iom_use('logavs') )   CALL iom_put( "logavs", LOG( MAX( 1.e-20_wp, avs(:,:,:) ) ) )
-
-      IF ( iom_use("sstgrad") .OR. iom_use("sstgrad2") ) THEN
-         DO_2D( 0, 0, 0, 0 )
-            zztmp  = ts(ji,jj,1,jp_tem,Kmm)
-            zztmpx = ( ts(ji+1,jj,1,jp_tem,Kmm) - zztmp ) * r1_e1u(ji,jj) + ( zztmp - ts(ji-1,jj  ,1,jp_tem,Kmm) ) * r1_e1u(ji-1,jj)
-            zztmpy = ( ts(ji,jj+1,1,jp_tem,Kmm) - zztmp ) * r1_e2v(ji,jj) + ( zztmp - ts(ji  ,jj-1,1,jp_tem,Kmm) ) * r1_e2v(ji,jj-1)
-            z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
-               &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
-         END_2D
-         CALL lbc_lnk( 'diawri', z2d, 'T', 1.0_wp )
-         CALL iom_put( "sstgrad2",  z2d )          ! square of module of sst gradient
-         z2d(:,:) = SQRT( z2d(:,:) )
-         CALL iom_put( "sstgrad" ,  z2d )          ! module of sst gradient
-      ENDIF
-         
-      ! heat and salt contents
-      IF( iom_use("heatc") ) THEN
-         z2d(:,:)  = 0._wp 
-         DO_3D( 1, 1, 1, 1, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_tem,Kmm) * tmask(ji,jj,jk)
-         END_3D
-         CALL iom_put( "heatc", rho0_rcp * z2d )   ! vertically integrated heat content (J/m2)
-      ENDIF
-
-      IF( iom_use("saltc") ) THEN
-         z2d(:,:)  = 0._wp 
-         DO_3D( 1, 1, 1, 1, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_sal,Kmm) * tmask(ji,jj,jk)
-         END_3D
-         CALL iom_put( "saltc", rho0 * z2d )          ! vertically integrated salt content (PSU*kg/m2)
-      ENDIF
-      !
-      IF ( iom_use("eken") ) THEN
-         z3d(:,:,jpk) = 0._wp 
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            zztmp  = 0.25_wp * r1_e1e2t(ji,jj) / e3t(ji,jj,jk,Kmm)
-            z3d(ji,jj,jk) = zztmp * (  uu(ji-1,jj,jk,Kmm)**2 * e2u(ji-1,jj) * e3u(ji-1,jj,jk,Kmm)   &
-               &                     + uu(ji  ,jj,jk,Kmm)**2 * e2u(ji  ,jj) * e3u(ji  ,jj,jk,Kmm)   &
-               &                     + vv(ji,jj-1,jk,Kmm)**2 * e1v(ji,jj-1) * e3v(ji,jj-1,jk,Kmm)   &
-               &                     + vv(ji,jj  ,jk,Kmm)**2 * e1v(ji,jj  ) * e3v(ji,jj  ,jk,Kmm)   )
-         END_3D
-         CALL lbc_lnk( 'diawri', z3d, 'T', 1.0_wp )
-         CALL iom_put( "eken", z3d )                 ! kinetic energy
-      ENDIF
-      !
-      CALL iom_put( "hdiv", hdiv )                  ! Horizontal divergence
-      !
-      IF( iom_use("u_masstr") .OR. iom_use("u_masstr_vint") .OR. iom_use("u_heattr") .OR. iom_use("u_salttr") ) THEN
-         z3d(:,:,jpk) = 0.e0
-         z2d(:,:) = 0.e0
-         DO jk = 1, jpkm1
-            z3d(:,:,jk) = rho0 * uu(:,:,jk,Kmm) * e2u(:,:) * e3u(:,:,jk,Kmm) * umask(:,:,jk)
-            z2d(:,:) = z2d(:,:) + z3d(:,:,jk)
-         END DO
-         CALL iom_put( "u_masstr"     , z3d )         ! mass transport in i-direction
-         CALL iom_put( "u_masstr_vint", z2d )         ! mass transport in i-direction vertical sum
-      ENDIF
-      
-      IF( iom_use("u_heattr") ) THEN
-         z2d(:,:) = 0._wp 
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( ts(ji,jj,jk,jp_tem,Kmm) + ts(ji+1,jj,jk,jp_tem,Kmm) )
-         END_3D
-         CALL lbc_lnk( 'diawri', z2d, 'U', -1.0_wp )
-         CALL iom_put( "u_heattr", 0.5*rcp * z2d )    ! heat transport in i-direction
-      ENDIF
-
-      IF( iom_use("u_salttr") ) THEN
-         z2d(:,:) = 0.e0 
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( ts(ji,jj,jk,jp_sal,Kmm) + ts(ji+1,jj,jk,jp_sal,Kmm) )
-         END_3D
-         CALL lbc_lnk( 'diawri', z2d, 'U', -1.0_wp )
-         CALL iom_put( "u_salttr", 0.5 * z2d )        ! heat transport in i-direction
-      ENDIF
-
-      
-      IF( iom_use("v_masstr") .OR. iom_use("v_heattr") .OR. iom_use("v_salttr") ) THEN
-         z3d(:,:,jpk) = 0.e0
-         DO jk = 1, jpkm1
-            z3d(:,:,jk) = rho0 * vv(:,:,jk,Kmm) * e1v(:,:) * e3v(:,:,jk,Kmm) * vmask(:,:,jk)
-         END DO
-         CALL iom_put( "v_masstr", z3d )              ! mass transport in j-direction
-      ENDIF
-      
-      IF( iom_use("v_heattr") ) THEN
-         z2d(:,:) = 0.e0 
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( ts(ji,jj,jk,jp_tem,Kmm) + ts(ji,jj+1,jk,jp_tem,Kmm) )
-         END_3D
-         CALL lbc_lnk( 'diawri', z2d, 'V', -1.0_wp )
-         CALL iom_put( "v_heattr", 0.5*rcp * z2d )    !  heat transport in j-direction
-      ENDIF
-
-      IF( iom_use("v_salttr") ) THEN
-         z2d(:,:) = 0._wp 
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + z3d(ji,jj,jk) * ( ts(ji,jj,jk,jp_sal,Kmm) + ts(ji,jj+1,jk,jp_sal,Kmm) )
-         END_3D
-         CALL lbc_lnk( 'diawri', z2d, 'V', -1.0_wp )
-         CALL iom_put( "v_salttr", 0.5 * z2d )        !  heat transport in j-direction
-      ENDIF
-
-      IF( iom_use("tosmint") ) THEN
-         z2d(:,:) = 0._wp
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + e3t(ji,jj,jk,Kmm) *  ts(ji,jj,jk,jp_tem,Kmm)
-         END_3D
-         CALL lbc_lnk( 'diawri', z2d, 'T', -1.0_wp )
-         CALL iom_put( "tosmint", rho0 * z2d )        ! Vertical integral of temperature
-      ENDIF
-      IF( iom_use("somint") ) THEN
-         z2d(:,:)=0._wp
-         DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-            z2d(ji,jj) = z2d(ji,jj) + e3t(ji,jj,jk,Kmm) * ts(ji,jj,jk,jp_sal,Kmm)
-         END_3D
-         CALL lbc_lnk( 'diawri', z2d, 'T', -1.0_wp )
-         CALL iom_put( "somint", rho0 * z2d )         ! Vertical integral of salinity
-      ENDIF
-
-      CALL iom_put( "bn2", rn2 )                      ! Brunt-Vaisala buoyancy frequency (N^2)
-      !
-      
-      IF (ln_dia25h)   CALL dia_25h( kt, Kmm )        ! 25h averaging
-
-      IF( ln_timing )   CALL timing_stop('dia_wri')
-      !
-   END SUBROUTINE dia_wri
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                  use IOIPSL  library
-   !!----------------------------------------------------------------------
-
-   INTEGER FUNCTION dia_wri_alloc()
-      !!----------------------------------------------------------------------
-      INTEGER, DIMENSION(2) :: ierr
-      !!----------------------------------------------------------------------
-      IF( nn_write == -1 ) THEN
-         dia_wri_alloc = 0
-      ELSE    
-         ierr = 0
-         ALLOCATE( ndex_hT(jpi*jpj) , ndex_T(jpi*jpj*jpk) ,     &
-            &      ndex_hU(jpi*jpj) , ndex_U(jpi*jpj*jpk) ,     &
-            &      ndex_hV(jpi*jpj) , ndex_V(jpi*jpj*jpk) , STAT=ierr(1) )
-         !
-         dia_wri_alloc = MAXVAL(ierr)
-         CALL mpp_sum( 'diawri', dia_wri_alloc )
-         !
-      ENDIF
-      !
-   END FUNCTION dia_wri_alloc
- 
-   INTEGER FUNCTION dia_wri_alloc_abl()
-      !!----------------------------------------------------------------------
-	  ALLOCATE(   ndex_hA(jpi*jpj), ndex_A (jpi*jpj*jpkam1), STAT=dia_wri_alloc_abl)
-      CALL mpp_sum( 'diawri', dia_wri_alloc_abl )
-      !
-   END FUNCTION dia_wri_alloc_abl
-
-   
-   SUBROUTINE dia_wri( kt, Kmm )
-      !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE dia_wri  ***
-      !!                   
-      !! ** Purpose :   Standard output of opa: dynamics and tracer fields 
-      !!      NETCDF format is used by default 
-      !!
-      !! ** Method  :   At the beginning of the first time step (nit000), 
-      !!      define all the NETCDF files and fields
-      !!      At each time step call histdef to compute the mean if ncessary
-      !!      Each nn_write time step, output the instantaneous or mean fields
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
-      INTEGER, INTENT( in ) ::   Kmm  ! ocean time level index
-      !
-      LOGICAL ::   ll_print = .FALSE.                        ! =T print and flush numout
-      CHARACTER (len=40) ::   clhstnam, clop, clmx           ! local names
-      INTEGER  ::   inum = 11                                ! temporary logical unit
-      INTEGER  ::   ji, jj, jk                               ! dummy loop indices
-      INTEGER  ::   ierr                                     ! error code return from allocation
-      INTEGER  ::   iimi, iima, ipk, it, itmod, ijmi, ijma   ! local integers
-      INTEGER  ::   ipka                                     ! ABL
-      INTEGER  ::   jn, ierror                               ! local integers
-      REAL(wp) ::   zsto, zout, zmax, zjulian                ! local scalars
-      !
-      REAL(wp), DIMENSION(jpi,jpj)   :: zw2d       ! 2D workspace
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: zw3d, ze3t, zgdept       ! 3D workspace
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zw3d_abl   ! ABL 3D workspace
-      !!----------------------------------------------------------------------
-      !
-      IF( ninist == 1 ) THEN     !==  Output the initial state and forcings  ==!
-         CALL dia_wri_state( Kmm, 'output.init' )
-         ninist = 0
-      ENDIF
-      !
-      IF( nn_write == -1 )   RETURN   ! we will never do any output
-      ! 
-      IF( ln_timing )   CALL timing_start('dia_wri')
-      !
-      ! 0. Initialisation
-      ! -----------------
-
-      ll_print = .FALSE.                  ! local variable for debugging
-      ll_print = ll_print .AND. lwp
-
-      ! Define frequency of output and means
-      clop = "x"         ! no use of the mask value (require less cpu time and otherwise the model crashes)
-#if defined key_diainstant
-      zsto = nn_write * rn_Dt
-      clop = "inst("//TRIM(clop)//")"
-#else
-      zsto=rn_Dt
-      clop = "ave("//TRIM(clop)//")"
-#endif
-      zout = nn_write * rn_Dt
-      zmax = ( nitend - nit000 + 1 ) * rn_Dt
-
-      ! Define indices of the horizontal output zoom and vertical limit storage
-      iimi = Nis0   ;   iima = Nie0
-      ijmi = Njs0   ;   ijma = Nje0
-      ipk = jpk
-      IF(ln_abl) ipka = jpkam1
-
-      ! define time axis
-      it = kt
-      itmod = kt - nit000 + 1
-
-      ! store e3t for subsitute
-      DO jk = 1, jpk
-         ze3t  (:,:,jk) =  e3t  (:,:,jk,Kmm)
-         zgdept(:,:,jk) =  gdept(:,:,jk,Kmm)
-      END DO
-
-
-      ! 1. Define NETCDF files and fields at beginning of first time step
-      ! -----------------------------------------------------------------
-
-      IF( kt == nit000 ) THEN
-
-         ! Define the NETCDF files (one per grid)
-
-         ! Compute julian date from starting date of the run
-         CALL ymds2ju( nyear, nmonth, nday, rn_Dt, zjulian )
-         zjulian = zjulian - adatrj   !   set calendar origin to the beginning of the experiment
-         IF(lwp)WRITE(numout,*)
-         IF(lwp)WRITE(numout,*) 'Date 0 used :', nit000, ' YEAR ', nyear,   &
-            &                    ' MONTH ', nmonth, ' DAY ', nday, 'Julian day : ', zjulian
-         IF(lwp)WRITE(numout,*) ' indexes of zoom = ', iimi, iima, ijmi, ijma,   &
-                                 ' limit storage in depth = ', ipk
-
-         ! WRITE root name in date.file for use by postpro
-         IF(lwp) THEN
-            CALL dia_nam( clhstnam, nn_write,' ' )
-            CALL ctl_opn( inum, 'date.file', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-            WRITE(inum,*) clhstnam
-            CLOSE(inum)
-         ENDIF
-
-         ! Define the T grid FILE ( nid_T )
-
-         CALL dia_nam( clhstnam, nn_write, 'grid_T' )
-         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
-         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
-            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
-            &          nit000-1, zjulian, rn_Dt, nh_T, nid_T, domain_id=nidom, snc4chunks=snc4set )
-         CALL histvert( nid_T, "deptht", "Vertical T levels",      &  ! Vertical grid: gdept
-            &           "m", ipk, gdept_1d, nz_T, "down" )
-         !                                                            ! Index of ocean points
-         CALL wheneq( jpi*jpj*ipk, tmask, 1, 1., ndex_T , ndim_T  )      ! volume
-         CALL wheneq( jpi*jpj    , tmask, 1, 1., ndex_hT, ndim_hT )      ! surface
-         !
-         IF( ln_icebergs ) THEN
-            !
-            !! allocation cant go in dia_wri_alloc because ln_icebergs is only set after 
-            !! that routine is called from nemogcm, so do it here immediately before its needed
-            ALLOCATE( ndex_bT(jpi*jpj*nclasses), STAT=ierror )
-            CALL mpp_sum( 'diawri', ierror )
-            IF( ierror /= 0 ) THEN
-               CALL ctl_stop('dia_wri: failed to allocate iceberg diagnostic array')
-               RETURN
-            ENDIF
-            !
-            !! iceberg vertical coordinate is class number
-            CALL histvert( nid_T, "class", "Iceberg class",      &  ! Vertical grid: class
-               &           "number", nclasses, class_num, nb_T )
-            !
-            !! each class just needs the surface index pattern
-            ndim_bT = 3
-            DO jn = 1,nclasses
-               ndex_bT((jn-1)*jpi*jpj+1:jn*jpi*jpj) = ndex_hT(1:jpi*jpj)
-            ENDDO
-            !
-         ENDIF
-
-         ! Define the U grid FILE ( nid_U )
-
-         CALL dia_nam( clhstnam, nn_write, 'grid_U' )
-         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
-         CALL histbeg( clhstnam, jpi, glamu, jpj, gphiu,           &  ! Horizontal grid: glamu and gphiu
-            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
-            &          nit000-1, zjulian, rn_Dt, nh_U, nid_U, domain_id=nidom, snc4chunks=snc4set )
-         CALL histvert( nid_U, "depthu", "Vertical U levels",      &  ! Vertical grid: gdept
-            &           "m", ipk, gdept_1d, nz_U, "down" )
-         !                                                            ! Index of ocean points
-         CALL wheneq( jpi*jpj*ipk, umask, 1, 1., ndex_U , ndim_U  )      ! volume
-         CALL wheneq( jpi*jpj    , umask, 1, 1., ndex_hU, ndim_hU )      ! surface
-
-         ! Define the V grid FILE ( nid_V )
-
-         CALL dia_nam( clhstnam, nn_write, 'grid_V' )                   ! filename
-         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
-         CALL histbeg( clhstnam, jpi, glamv, jpj, gphiv,           &  ! Horizontal grid: glamv and gphiv
-            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
-            &          nit000-1, zjulian, rn_Dt, nh_V, nid_V, domain_id=nidom, snc4chunks=snc4set )
-         CALL histvert( nid_V, "depthv", "Vertical V levels",      &  ! Vertical grid : gdept
-            &          "m", ipk, gdept_1d, nz_V, "down" )
-         !                                                            ! Index of ocean points
-         CALL wheneq( jpi*jpj*ipk, vmask, 1, 1., ndex_V , ndim_V  )      ! volume
-         CALL wheneq( jpi*jpj    , vmask, 1, 1., ndex_hV, ndim_hV )      ! surface
-
-         ! Define the W grid FILE ( nid_W )
-
-         CALL dia_nam( clhstnam, nn_write, 'grid_W' )                   ! filename
-         IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam
-         CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
-            &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
-            &          nit000-1, zjulian, rn_Dt, nh_W, nid_W, domain_id=nidom, snc4chunks=snc4set )
-         CALL histvert( nid_W, "depthw", "Vertical W levels",      &  ! Vertical grid: gdepw
-            &          "m", ipk, gdepw_1d, nz_W, "down" )
-
-         IF( ln_abl ) THEN 
-         ! Define the ABL grid FILE ( nid_A )
-            CALL dia_nam( clhstnam, nn_write, 'grid_ABL' )
-            IF(lwp) WRITE(numout,*) " Name of NETCDF file ", clhstnam    ! filename
-            CALL histbeg( clhstnam, jpi, glamt, jpj, gphit,           &  ! Horizontal grid: glamt and gphit
-               &          iimi, iima-iimi+1, ijmi, ijma-ijmi+1,       &
-               &          nit000-1, zjulian, rn_Dt, nh_A, nid_A, domain_id=nidom, snc4chunks=snc4set )
-            CALL histvert( nid_A, "ght_abl", "Vertical T levels",      &  ! Vertical grid: gdept
-               &           "m", ipka, ght_abl(2:jpka), nz_A, "up" )
-            !                                                            ! Index of ocean points
-			ALLOCATE( zw3d_abl(jpi,jpj,ipka) ) 
-			zw3d_abl(:,:,:) = 1._wp 
-			CALL wheneq( jpi*jpj*ipka, zw3d_abl, 1, 1., ndex_A , ndim_A  )      ! volume
-            CALL wheneq( jpi*jpj     , zw3d_abl, 1, 1., ndex_hA, ndim_hA )      ! surface
-			DEALLOCATE(zw3d_abl)
-         ENDIF
-         !
-
-         ! Declare all the output fields as NETCDF variables
-
-         !                                                                                      !!! nid_T : 3D
-         CALL histdef( nid_T, "votemper", "Temperature"                        , "C"      ,   &  ! tn
-            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
-         CALL histdef( nid_T, "vosaline", "Salinity"                           , "PSU"    ,   &  ! sn
-            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
-         IF(  .NOT.ln_linssh  ) THEN
-            CALL histdef( nid_T, "vovvle3t", "Level thickness"                    , "m"      ,&  ! e3t n
-            &             jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
-            CALL histdef( nid_T, "vovvldep", "T point depth"                      , "m"      ,&  ! e3t n
-            &             jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
-            CALL histdef( nid_T, "vovvldef", "Squared level deformation"          , "%^2"    ,&  ! e3t n
-            &             jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
-         ENDIF
-         !                                                                                      !!! nid_T : 2D
-         CALL histdef( nid_T, "sosstsst", "Sea Surface temperature"            , "C"      ,   &  ! sst
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sosaline", "Sea Surface Salinity"               , "PSU"    ,   &  ! sss
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sossheig", "Sea Surface Height"                 , "m"      ,   &  ! ssh
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sowaflup", "Net Upward Water Flux"              , "Kg/m2/s",   &  ! (emp-rnf)
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sorunoff", "River runoffs"                      , "Kg/m2/s",   &  ! runoffs
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sosfldow", "downward salt flux"                 , "PSU/m2/s",  &  ! sfx
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         IF(  ln_linssh  ) THEN
-            CALL histdef( nid_T, "sosst_cd", "Concentration/Dilution term on temperature"     &  ! emp * ts(:,:,1,jp_tem,Kmm)
-            &                                                                  , "KgC/m2/s",  &  ! sosst_cd
-            &             jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sosss_cd", "Concentration/Dilution term on salinity"        &  ! emp * ts(:,:,1,jp_sal,Kmm)
-            &                                                                  , "KgPSU/m2/s",&  ! sosss_cd
-            &             jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         ENDIF
-         CALL histdef( nid_T, "sohefldo", "Net Downward Heat Flux"             , "W/m2"   ,   &  ! qns + qsr
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "soshfldo", "Shortwave Radiation"                , "W/m2"   ,   &  ! qsr
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "somixhgt", "Turbocline Depth"                   , "m"      ,   &  ! hmld
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "somxl010", "Mixed Layer Depth 0.01"             , "m"      ,   &  ! hmlp
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "soicecov", "Ice fraction"                       , "[0,1]"  ,   &  ! fr_i
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sowindsp", "wind speed at 10m"                  , "m/s"    ,   &  ! wndm
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         !
-         IF( ln_abl ) THEN
-            CALL histdef( nid_A, "t_abl", "Potential Temperature"     , "K"        ,       &  ! t_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout )
-            CALL histdef( nid_A, "q_abl", "Humidity"                  , "kg/kg"    ,       &  ! q_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout ) 
-            CALL histdef( nid_A, "u_abl", "Atmospheric U-wind   "     , "m/s"        ,     &  ! u_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout )
-            CALL histdef( nid_A, "v_abl", "Atmospheric V-wind   "     , "m/s"    ,         &  ! v_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout ) 
-            CALL histdef( nid_A, "tke_abl", "Atmospheric TKE   "     , "m2/s2"    ,        &  ! tke_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout ) 
-            CALL histdef( nid_A, "avm_abl", "Atmospheric turbulent viscosity", "m2/s"   ,  &  ! avm_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout ) 
-            CALL histdef( nid_A, "avt_abl", "Atmospheric turbulent diffusivity", "m2/s2",  &  ! avt_abl
-               &          jpi, jpj, nh_A, ipka, 1, ipka, nz_A, 32, clop, zsto, zout ) 
-            CALL histdef( nid_A, "pblh", "Atmospheric boundary layer height "  , "m",      &  ! pblh
-               &          jpi, jpj, nh_A,  1  , 1, 1   , -99 , 32, clop, zsto, zout )		 			   
-#if defined key_si3
-            CALL histdef( nid_A, "oce_frac", "Fraction of open ocean"  , " ",      &  ! ato_i
-               &          jpi, jpj, nh_A,  1  , 1, 1   , -99 , 32, clop, zsto, zout )
-#endif
-            CALL histend( nid_A, snc4chunks=snc4set )
-         ENDIF
-         !
-         IF( ln_icebergs ) THEN
-            CALL histdef( nid_T, "calving"             , "calving mass input"                       , "kg/s"   , &
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "calving_heat"        , "calving heat flux"                        , "XXXX"   , &
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "berg_floating_melt"  , "Melt rate of icebergs + bits"             , "kg/m2/s", &
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "berg_stored_ice"     , "Accumulated ice mass by class"            , "kg"     , &
-               &          jpi, jpj, nh_T, nclasses  , 1, nclasses  , nb_T , 32, clop, zsto, zout )
-            IF( ln_bergdia ) THEN
-               CALL histdef( nid_T, "berg_melt"           , "Melt rate of icebergs"                    , "kg/m2/s", &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_buoy_melt"      , "Buoyancy component of iceberg melt rate"  , "kg/m2/s", &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_eros_melt"      , "Erosion component of iceberg melt rate"   , "kg/m2/s", &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_conv_melt"      , "Convective component of iceberg melt rate", "kg/m2/s", &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_virtual_area"   , "Virtual coverage by icebergs"             , "m2"     , &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "bits_src"           , "Mass source of bergy bits"                , "kg/m2/s", &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "bits_melt"          , "Melt rate of bergy bits"                  , "kg/m2/s", &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "bits_mass"          , "Bergy bit density field"                  , "kg/m2"  , &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_mass"           , "Iceberg density field"                    , "kg/m2"  , &
-                  &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-               CALL histdef( nid_T, "berg_real_calving"   , "Calving into iceberg class"               , "kg/s"   , &
-                  &          jpi, jpj, nh_T, nclasses  , 1, nclasses  , nb_T , 32, clop, zsto, zout )
-            ENDIF
-         ENDIF
-
-         IF( ln_ssr ) THEN
-            CALL histdef( nid_T, "sohefldp", "Surface Heat Flux: Damping"         , "W/m2"   ,   &  ! qrp
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sowafldp", "Surface Water Flux: Damping"        , "Kg/m2/s",   &  ! erp
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-            CALL histdef( nid_T, "sosafldp", "Surface salt flux: damping"         , "Kg/m2/s",   &  ! erp * sn
-               &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         ENDIF
-       
-         clmx ="l_max(only(x))"    ! max index on a period
-!         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
-!            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clmx, zsto, zout )
-#if defined key_diahth
-         CALL histdef( nid_T, "sothedep", "Thermocline Depth"                  , "m"      ,   & ! hth
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "so20chgt", "Depth of 20C isotherm"              , "m"      ,   & ! hd20
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "so28chgt", "Depth of 28C isotherm"              , "m"      ,   & ! hd28
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-         CALL histdef( nid_T, "sohtc300", "Heat content 300 m"                 , "J/m2"   ,   & ! htc3
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
-#endif
-
-         CALL histend( nid_T, snc4chunks=snc4set )
-
-         !                                                                                      !!! nid_U : 3D
-         CALL histdef( nid_U, "vozocrtx", "Zonal Current"                      , "m/s"    ,   &  ! uu(:,:,:,Kmm)
-            &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
-         IF( ln_wave .AND. ln_sdw) THEN
-            CALL histdef( nid_U, "sdzocrtx", "Stokes Drift Zonal Current"         , "m/s"    ,   &  ! usd
-               &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
-         ENDIF
-         !                                                                                      !!! nid_U : 2D
-         CALL histdef( nid_U, "sozotaux", "Wind Stress along i-axis"           , "N/m2"   ,   &  ! utau
-            &          jpi, jpj, nh_U, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
-
-         CALL histend( nid_U, snc4chunks=snc4set )
-
-         !                                                                                      !!! nid_V : 3D
-         CALL histdef( nid_V, "vomecrty", "Meridional Current"                 , "m/s"    ,   &  ! vv(:,:,:,Kmm)
-            &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
-         IF( ln_wave .AND. ln_sdw) THEN
-            CALL histdef( nid_V, "sdmecrty", "Stokes Drift Meridional Current"    , "m/s"    ,   &  ! vsd
-               &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
-         ENDIF
-         !                                                                                      !!! nid_V : 2D
-         CALL histdef( nid_V, "sometauy", "Wind Stress along j-axis"           , "N/m2"   ,   &  ! vtau
-            &          jpi, jpj, nh_V, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
-
-         CALL histend( nid_V, snc4chunks=snc4set )
-
-         !                                                                                      !!! nid_W : 3D
-         CALL histdef( nid_W, "vovecrtz", "Vertical Velocity"                  , "m/s"    ,   &  ! ww
-            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-         CALL histdef( nid_W, "votkeavt", "Vertical Eddy Diffusivity"          , "m2/s"   ,   &  ! avt
-            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-         CALL histdef( nid_W, "votkeavm", "Vertical Eddy Viscosity"             , "m2/s"  ,   &  ! avm
-            &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-
-         IF( ln_zdfddm ) THEN
-            CALL histdef( nid_W,"voddmavs","Salt Vertical Eddy Diffusivity"    , "m2/s"   ,   &  ! avs
-               &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-         ENDIF
-         
-         IF( ln_wave .AND. ln_sdw) THEN
-            CALL histdef( nid_W, "sdvecrtz", "Stokes Drift Vertical Current"   , "m/s"    ,   &  ! wsd
-               &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-         ENDIF
-         !                                                                                      !!! nid_W : 2D
-         CALL histend( nid_W, snc4chunks=snc4set )
-
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'End of NetCDF Initialization'
-         IF(ll_print) CALL FLUSH(numout )
-
-      ENDIF
-
-      ! 2. Start writing data
-      ! ---------------------
-
-      ! ndex(1) est utilise ssi l'avant dernier argument est different de 
-      ! la taille du tableau en sortie. Dans ce cas , l'avant dernier argument
-      ! donne le nombre d'elements, et ndex la liste des indices a sortir
-
-      IF( lwp .AND. MOD( itmod, nn_write ) == 0 ) THEN 
-         WRITE(numout,*) 'dia_wri : write model outputs in NetCDF files at ', kt, 'time-step'
-         WRITE(numout,*) '~~~~~~ '
-      ENDIF
-
-      IF( .NOT.ln_linssh ) THEN
-         CALL histwrite( nid_T, "votemper", it, ts(:,:,:,jp_tem,Kmm) * ze3t(:,:,:) , ndim_T , ndex_T  )   ! heat content
-         CALL histwrite( nid_T, "vosaline", it, ts(:,:,:,jp_sal,Kmm) * ze3t(:,:,:) , ndim_T , ndex_T  )   ! salt content
-         CALL histwrite( nid_T, "sosstsst", it, ts(:,:,1,jp_tem,Kmm) * ze3t(:,:,1) , ndim_hT, ndex_hT )   ! sea surface heat content
-         CALL histwrite( nid_T, "sosaline", it, ts(:,:,1,jp_sal,Kmm) * ze3t(:,:,1) , ndim_hT, ndex_hT )   ! sea surface salinity content
-      ELSE
-         CALL histwrite( nid_T, "votemper", it, ts(:,:,:,jp_tem,Kmm) , ndim_T , ndex_T  )   ! temperature
-         CALL histwrite( nid_T, "vosaline", it, ts(:,:,:,jp_sal,Kmm) , ndim_T , ndex_T  )   ! salinity
-         CALL histwrite( nid_T, "sosstsst", it, ts(:,:,1,jp_tem,Kmm) , ndim_hT, ndex_hT )   ! sea surface temperature
-         CALL histwrite( nid_T, "sosaline", it, ts(:,:,1,jp_sal,Kmm) , ndim_hT, ndex_hT )   ! sea surface salinity
-      ENDIF
-      IF( .NOT.ln_linssh ) THEN
-         zw3d(:,:,:) = ( ( ze3t(:,:,:) - e3t_0(:,:,:) ) / e3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2
-         CALL histwrite( nid_T, "vovvle3t", it, ze3t (:,:,:)     , ndim_T , ndex_T  )   ! level thickness
-         CALL histwrite( nid_T, "vovvldep", it, zgdept , ndim_T , ndex_T  )   ! t-point depth 
-         CALL histwrite( nid_T, "vovvldef", it, zw3d             , ndim_T , ndex_T  )   ! level thickness deformation
-      ENDIF
-      CALL histwrite( nid_T, "sossheig", it, ssh(:,:,Kmm)          , ndim_hT, ndex_hT )   ! sea surface height
-      CALL histwrite( nid_T, "sowaflup", it, ( emp-rnf )   , ndim_hT, ndex_hT )   ! upward water flux
-      CALL histwrite( nid_T, "sorunoff", it, rnf           , ndim_hT, ndex_hT )   ! river runoffs
-      CALL histwrite( nid_T, "sosfldow", it, sfx           , ndim_hT, ndex_hT )   ! downward salt flux 
-                                                                                  ! (includes virtual salt flux beneath ice 
-                                                                                  ! in linear free surface case)
-      IF( ln_linssh ) THEN
-         zw2d(:,:) = emp (:,:) * ts(:,:,1,jp_tem,Kmm)
-         CALL histwrite( nid_T, "sosst_cd", it, zw2d, ndim_hT, ndex_hT )          ! c/d term on sst
-         zw2d(:,:) = emp (:,:) * ts(:,:,1,jp_sal,Kmm)
-         CALL histwrite( nid_T, "sosss_cd", it, zw2d, ndim_hT, ndex_hT )          ! c/d term on sss
-      ENDIF
-      CALL histwrite( nid_T, "sohefldo", it, qns + qsr     , ndim_hT, ndex_hT )   ! total heat flux
-      CALL histwrite( nid_T, "soshfldo", it, qsr           , ndim_hT, ndex_hT )   ! solar heat flux
-      CALL histwrite( nid_T, "somixhgt", it, hmld          , ndim_hT, ndex_hT )   ! turbocline depth
-      CALL histwrite( nid_T, "somxl010", it, hmlp          , ndim_hT, ndex_hT )   ! mixed layer depth
-      CALL histwrite( nid_T, "soicecov", it, fr_i          , ndim_hT, ndex_hT )   ! ice fraction   
-      CALL histwrite( nid_T, "sowindsp", it, wndm          , ndim_hT, ndex_hT )   ! wind speed   
-      !
-      IF( ln_abl ) THEN 
-         ALLOCATE( zw3d_abl(jpi,jpj,jpka) )
-         IF( ln_mskland )   THEN 
-            DO jk=1,jpka
-               zw3d_abl(:,:,jk) = tmask(:,:,1)
-            END DO       
-         ELSE
-            zw3d_abl(:,:,:) = 1._wp		 
-         ENDIF			
-         CALL histwrite( nid_A,  "pblh"   , it, pblh(:,:)                  *zw3d_abl(:,:,1     ), ndim_hA, ndex_hA )   ! pblh 
-         CALL histwrite( nid_A,  "u_abl"  , it, u_abl   (:,:,2:jpka,nt_n  )*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! u_abl
-         CALL histwrite( nid_A,  "v_abl"  , it, v_abl   (:,:,2:jpka,nt_n  )*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! v_abl
-         CALL histwrite( nid_A,  "t_abl"  , it, tq_abl  (:,:,2:jpka,nt_n,1)*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! t_abl
-         CALL histwrite( nid_A,  "q_abl"  , it, tq_abl  (:,:,2:jpka,nt_n,2)*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! q_abl		 
-         CALL histwrite( nid_A,  "tke_abl", it, tke_abl (:,:,2:jpka,nt_n  )*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! tke_abl
-         CALL histwrite( nid_A,  "avm_abl", it, avm_abl (:,:,2:jpka       )*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! avm_abl
-         CALL histwrite( nid_A,  "avt_abl", it, avt_abl (:,:,2:jpka       )*zw3d_abl(:,:,2:jpka), ndim_A , ndex_A  )   ! avt_abl	
-#if defined key_si3
-         CALL histwrite( nid_A,  "oce_frac"   , it, ato_i(:,:)                                  , ndim_hA, ndex_hA )   ! ato_i
-#endif
-         DEALLOCATE(zw3d_abl)
-      ENDIF
-      !
-      IF( ln_icebergs ) THEN
-         !
-         CALL histwrite( nid_T, "calving"             , it, berg_grid%calving      , ndim_hT, ndex_hT )  
-         CALL histwrite( nid_T, "calving_heat"        , it, berg_grid%calving_hflx , ndim_hT, ndex_hT )         
-         CALL histwrite( nid_T, "berg_floating_melt"  , it, berg_grid%floating_melt, ndim_hT, ndex_hT )  
-         !
-         CALL histwrite( nid_T, "berg_stored_ice"     , it, berg_grid%stored_ice   , ndim_bT, ndex_bT )
-         !
-         IF( ln_bergdia ) THEN
-            CALL histwrite( nid_T, "berg_melt"           , it, berg_melt        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_buoy_melt"      , it, buoy_melt        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_eros_melt"      , it, eros_melt        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_conv_melt"      , it, conv_melt        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_virtual_area"   , it, virtual_area     , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "bits_src"            , it, bits_src         , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "bits_melt"           , it, bits_melt        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "bits_mass"           , it, bits_mass        , ndim_hT, ndex_hT   )  
-            CALL histwrite( nid_T, "berg_mass"           , it, berg_mass        , ndim_hT, ndex_hT   )  
-            !
-            CALL histwrite( nid_T, "berg_real_calving"   , it, real_calving     , ndim_bT, ndex_bT   )
-         ENDIF
-      ENDIF
-
-      IF( ln_ssr ) THEN
-         CALL histwrite( nid_T, "sohefldp", it, qrp           , ndim_hT, ndex_hT )   ! heat flux damping
-         CALL histwrite( nid_T, "sowafldp", it, erp           , ndim_hT, ndex_hT )   ! freshwater flux damping
-         zw2d(:,:) = erp(:,:) * ts(:,:,1,jp_sal,Kmm) * tmask(:,:,1)
-         CALL histwrite( nid_T, "sosafldp", it, zw2d          , ndim_hT, ndex_hT )   ! salt flux damping
-      ENDIF
-!      zw2d(:,:) = FLOAT( nmln(:,:) ) * tmask(:,:,1)
-!      CALL histwrite( nid_T, "sobowlin", it, zw2d          , ndim_hT, ndex_hT )   ! ???
-
-#if defined key_diahth
-      CALL histwrite( nid_T, "sothedep", it, hth           , ndim_hT, ndex_hT )   ! depth of the thermocline
-      CALL histwrite( nid_T, "so20chgt", it, hd20          , ndim_hT, ndex_hT )   ! depth of the 20 isotherm
-      CALL histwrite( nid_T, "so28chgt", it, hd28          , ndim_hT, ndex_hT )   ! depth of the 28 isotherm
-      CALL histwrite( nid_T, "sohtc300", it, htc3          , ndim_hT, ndex_hT )   ! first 300m heaat content
-#endif
-
-      CALL histwrite( nid_U, "vozocrtx", it, uu(:,:,:,Kmm)            , ndim_U , ndex_U )    ! i-current
-      CALL histwrite( nid_U, "sozotaux", it, utau          , ndim_hU, ndex_hU )   ! i-wind stress
-
-      CALL histwrite( nid_V, "vomecrty", it, vv(:,:,:,Kmm)            , ndim_V , ndex_V  )   ! j-current
-      CALL histwrite( nid_V, "sometauy", it, vtau          , ndim_hV, ndex_hV )   ! j-wind stress
-
-      IF( ln_zad_Aimp ) THEN
-         CALL histwrite( nid_W, "vovecrtz", it, ww + wi     , ndim_T, ndex_T )    ! vert. current
-      ELSE
-         CALL histwrite( nid_W, "vovecrtz", it, ww          , ndim_T, ndex_T )    ! vert. current
-      ENDIF
-      CALL histwrite( nid_W, "votkeavt", it, avt            , ndim_T, ndex_T )    ! T vert. eddy diff. coef.
-      CALL histwrite( nid_W, "votkeavm", it, avm            , ndim_T, ndex_T )    ! T vert. eddy visc. coef.
-      IF( ln_zdfddm ) THEN
-         CALL histwrite( nid_W, "voddmavs", it, avs         , ndim_T, ndex_T )    ! S vert. eddy diff. coef.
-      ENDIF
-
-      IF( ln_wave .AND. ln_sdw ) THEN
-         CALL histwrite( nid_U, "sdzocrtx", it, usd         , ndim_U , ndex_U )    ! i-StokesDrift-current
-         CALL histwrite( nid_V, "sdmecrty", it, vsd         , ndim_V , ndex_V )    ! j-StokesDrift-current
-         CALL histwrite( nid_W, "sdvecrtz", it, wsd         , ndim_T , ndex_T )    ! StokesDrift vert. current
-      ENDIF
-
-      ! 3. Close all files
-      ! ---------------------------------------
-      IF( kt == nitend ) THEN
-         CALL histclo( nid_T )
-         CALL histclo( nid_U )
-         CALL histclo( nid_V )
-         CALL histclo( nid_W )
-         IF(ln_abl) CALL histclo( nid_A )
-      ENDIF
-      !
-      IF( ln_timing )   CALL timing_stop('dia_wri')
-      !
-   END SUBROUTINE dia_wri
-#endif
-
-   SUBROUTINE dia_wri_state( Kmm, cdfile_name )
-      !!---------------------------------------------------------------------
-      !!                 ***  ROUTINE dia_wri_state  ***
-      !!        
-      !! ** Purpose :   create a NetCDF file named cdfile_name which contains 
-      !!      the instantaneous ocean state and forcing fields.
-      !!        Used to find errors in the initial state or save the last
-      !!      ocean state in case of abnormal end of a simulation
-      !!
-      !! ** Method  :   NetCDF files using ioipsl
-      !!      File 'output.init.nc'  is created if ninist = 1 (namelist)
-      !!      File 'output.abort.nc' is created in case of abnormal job end
-      !!----------------------------------------------------------------------
-      INTEGER           , INTENT( in ) ::   Kmm              ! time level index
-      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created
-      !!
-      INTEGER :: inum, jk
-      REAL(wp), DIMENSION(jpi,jpj,jpk) :: ze3t, zgdept      ! 3D workspace !!st patch to use substitution
-      !!----------------------------------------------------------------------
-      ! 
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'dia_wri_state : single instantaneous ocean state'
-         WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
-         WRITE(numout,*) '                and named :', cdfile_name, '...nc'
-      ENDIF 
-      !
-      DO jk = 1, jpk
-         ze3t(:,:,jk) =  e3t(:,:,jk,Kmm)
-         zgdept(:,:,jk) =  gdept(:,:,jk,Kmm)
-      END DO
-      !
-      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
-      !
-      CALL iom_rstput( 0, 0, inum, 'votemper', ts(:,:,:,jp_tem,Kmm) )    ! now temperature
-      CALL iom_rstput( 0, 0, inum, 'vosaline', ts(:,:,:,jp_sal,Kmm) )    ! now salinity
-      CALL iom_rstput( 0, 0, inum, 'sossheig', ssh(:,:,Kmm)              )    ! sea surface height
-      CALL iom_rstput( 0, 0, inum, 'vozocrtx', uu(:,:,:,Kmm)                )    ! now i-velocity
-      CALL iom_rstput( 0, 0, inum, 'vomecrty', vv(:,:,:,Kmm)                )    ! now j-velocity
-      IF( ln_zad_Aimp ) THEN
-         CALL iom_rstput( 0, 0, inum, 'vovecrtz', ww + wi        )    ! now k-velocity
-      ELSE
-         CALL iom_rstput( 0, 0, inum, 'vovecrtz', ww             )    ! now k-velocity
-      ENDIF
-      CALL iom_rstput( 0, 0, inum, 'risfdep', risfdep            )    ! now k-velocity
-      CALL iom_rstput( 0, 0, inum, 'ht'     , ht(:,:)            )    ! now water column height
-      !
-      IF ( ln_isf ) THEN
-         IF (ln_isfcav_mlt) THEN
-            CALL iom_rstput( 0, 0, inum, 'fwfisf_cav', fwfisf_cav          )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'rhisf_cav_tbl', rhisf_tbl_cav    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'rfrac_cav_tbl', rfrac_tbl_cav    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkb_cav', REAL(misfkb_cav,wp) )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkt_cav', REAL(misfkt_cav,wp) )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'mskisf_cav', REAL(mskisf_cav,wp), ktype = jp_i1 )
-         END IF
-         IF (ln_isfpar_mlt) THEN
-            CALL iom_rstput( 0, 0, inum, 'isfmsk_par', REAL(mskisf_par,wp) )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'fwfisf_par', fwfisf_par          )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'rhisf_par_tbl', rhisf_tbl_par    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'rfrac_par_tbl', rfrac_tbl_par    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkb_par', REAL(misfkb_par,wp) )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkt_par', REAL(misfkt_par,wp) )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'mskisf_par', REAL(mskisf_par,wp), ktype = jp_i1 )
-         END IF
-      END IF
-      !
-      IF( ALLOCATED(ahtu) ) THEN
-         CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
-         CALL iom_rstput( 0, 0, inum,  'ahtv', ahtv              )    ! aht at v-point
-      ENDIF
-      IF( ALLOCATED(ahmt) ) THEN
-         CALL iom_rstput( 0, 0, inum,  'ahmt', ahmt              )    ! ahmt at u-point
-         CALL iom_rstput( 0, 0, inum,  'ahmf', ahmf              )    ! ahmf at v-point
-      ENDIF
-      CALL iom_rstput( 0, 0, inum, 'sowaflup', emp - rnf         )    ! freshwater budget
-      CALL iom_rstput( 0, 0, inum, 'sohefldo', qsr + qns         )    ! total heat flux
-      CALL iom_rstput( 0, 0, inum, 'soshfldo', qsr               )    ! solar heat flux
-      CALL iom_rstput( 0, 0, inum, 'soicecov', fr_i              )    ! ice fraction
-      CALL iom_rstput( 0, 0, inum, 'sozotaux', utau              )    ! i-wind stress
-      CALL iom_rstput( 0, 0, inum, 'sometauy', vtau              )    ! j-wind stress
-      IF(  .NOT.ln_linssh  ) THEN             
-         CALL iom_rstput( 0, 0, inum, 'vovvldep', zgdept        )    !  T-cell depth 
-         CALL iom_rstput( 0, 0, inum, 'vovvle3t', ze3t          )    !  T-cell thickness  
-      END IF
-      IF( ln_wave .AND. ln_sdw ) THEN
-         CALL iom_rstput( 0, 0, inum, 'sdzocrtx', usd            )    ! now StokesDrift i-velocity
-         CALL iom_rstput( 0, 0, inum, 'sdmecrty', vsd            )    ! now StokesDrift j-velocity
-         CALL iom_rstput( 0, 0, inum, 'sdvecrtz', wsd            )    ! now StokesDrift k-velocity
-      ENDIF
-      IF ( ln_abl ) THEN
-         CALL iom_rstput ( 0, 0, inum, "uz1_abl",   u_abl(:,:,2,nt_a  ) )   ! now first level i-wind
-         CALL iom_rstput ( 0, 0, inum, "vz1_abl",   v_abl(:,:,2,nt_a  ) )   ! now first level j-wind
-         CALL iom_rstput ( 0, 0, inum, "tz1_abl",  tq_abl(:,:,2,nt_a,1) )   ! now first level temperature
-         CALL iom_rstput ( 0, 0, inum, "qz1_abl",  tq_abl(:,:,2,nt_a,2) )   ! now first level humidity
-      ENDIF
-      !
-      CALL iom_close( inum )
-      ! 
-#if defined key_si3
-      IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
-         CALL iom_open( TRIM(cdfile_name)//'_ice', inum, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
-         CALL ice_wri_state( inum )
-         CALL iom_close( inum )
-      ENDIF
-      !
-#endif
-   END SUBROUTINE dia_wri_state
-
-   !!======================================================================
-END MODULE diawri
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_hgr.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -0,0 +1,127 @@
+MODULE usrdef_hgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_hgr  ***
+   !!
+   !!                      ===  DOME configuration  ===
+   !!
+   !! User defined :   mesh and Coriolis parameter of a user configuration
+   !!======================================================================
+   !! History :  NEMO  ! 2017-11  (J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_hgr    : initialize the horizontal mesh for DOME configuration
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE par_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE usrdef_nam, ONLY: rn_dx, rn_dy, rn_f0   ! horizontal resolution in meters
+   !                                             and Coriolis freq. 
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_hgr   ! called by domhgr.F90
+
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_hgr.F90 13295 2020-07-10 18:24:21Z acc $ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
+      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
+      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
+      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
+      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
+      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE usr_def_hgr  ***
+      !!
+      !! ** Purpose :   user defined mesh and Coriolis parameter
+      !!
+      !! ** Method  :   set all intent(out) argument to a proper value
+      !!                DOME configuration : beta-plance with uniform grid spacing (rn_dx)
+      !!
+      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees) 
+      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
+      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
+      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
+      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
+      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise 
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
+      !
+      INTEGER  ::   ji, jj     ! dummy loop indices
+      REAL(wp) ::   zphi0, zlam0 
+      REAL(wp) ::   zti, ztj   ! local scalars
+      !!-------------------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_hgr : DOME configuration bassin'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          f-plane with regular grid-spacing'
+      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
+      !
+      !                          
+      ! Position coordinates (in kilometers)
+      !                          ==========
+      zlam0 = -REAL( 0.5 + 1700._wp * 1.e3 / rn_dx)
+      zphi0 = -REAL( 0.5 +  800._wp * 1.e3 / rn_dy)
+#if defined key_agrif
+      IF( .NOT.Agrif_Root() ) THEN 
+         zlam0 = - REAL( 0.5 + 1700._wp * 1.e3 / rn_dx + nbghostcells) &
+               & + REAL((nbghostcells + Agrif_Ix() - 1)*Agrif_irhox())  
+         zphi0 = - REAL( 0.5 +  800._wp * 1.e3 / rn_dy + nbghostcells) &
+               & + REAL((nbghostcells + Agrif_Iy() - 1)*Agrif_irhoy())  
+      ENDIF 
+#endif
+         
+      DO_2D( 1, 1, 1, 1 )
+         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
+         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
+         
+         plamt(ji,jj) = rn_dx * 1.e-3 * ( zlam0 + zti )
+         plamu(ji,jj) = rn_dx * 1.e-3 * ( zlam0 + zti + 0.5_wp )
+         plamv(ji,jj) = plamt(ji,jj) 
+         plamf(ji,jj) = plamu(ji,jj) 
+         
+         pphit(ji,jj) = rn_dy * 1.e-3 * ( zphi0 + ztj )
+         pphiv(ji,jj) = rn_dy * 1.e-3 * ( zphi0 + ztj + 0.5_wp )
+         pphiu(ji,jj) = pphit(ji,jj) 
+         pphif(ji,jj) = pphiv(ji,jj) 
+      END_2D
+      !     
+      ! Horizontal scale factors (in meters)
+      !                              ======
+      pe1t(:,:) = rn_dx  ;   pe2t(:,:) = rn_dy 
+      pe1u(:,:) = rn_dx  ;   pe2u(:,:) = rn_dy 
+      pe1v(:,:) = rn_dx  ;   pe2v(:,:) = rn_dy 
+      pe1f(:,:) = rn_dx  ;   pe2f(:,:) = rn_dy 
+
+      !                             ! NO reduction of grid size in some straits 
+      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
+      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
+      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
+      !
+      !
+      !                       !==  Coriolis parameter  ==!
+      kff = 1                       !  indicate not to compute Coriolis parameter afterward
+      !
+      pff_f(:,:) = rn_f0
+      pff_t(:,:) = rn_f0
+      !
+   END SUBROUTINE usr_def_hgr
+
+   !!======================================================================
+END MODULE usrdef_hgr
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_istate.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_istate.F90	(revision 14644)
@@ -16,4 +16,5 @@
    USE phycst         ! physical constants
    USE eosbn2, ONLY: rn_a0
+   USE dom_oce
    !
    USE in_out_manager ! I/O manager
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_nam.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -0,0 +1,129 @@
+MODULE usrdef_nam
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_nam  ***
+   !!
+   !!                      ===  DOME configuration  ===
+   !!
+   !! User defined : set the domain characteristics of a user configuration
+   !!======================================================================
+   !! History :  NEMO ! 2020-12  (J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_nam   : read user defined namelist and set global domain size
+   !!   usr_def_hgr   : initialize the horizontal mesh 
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE par_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE timing         ! Timing
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_nam   ! called by nemogcm.F90
+
+   !                              !!* namusr_def namelist *!!
+   REAL(wp), PUBLIC ::   rn_dx      ! resolution in meters defining the horizontal domain size
+   REAL(wp), PUBLIC ::   rn_dy      ! resolution in meters defining the horizontal domain size
+   REAL(wp), PUBLIC ::   rn_dz      ! vertical resolution 
+   REAL(wp), PUBLIC ::   rn_f0      ! Coriolis frequency 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_nam.F90 14086 2020-12-04 11:37:14Z cetlod $ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read user defined namelist and define the domain size
+      !!
+      !! ** Method  :   read in namusr_def containing all the user specific namelist parameter
+      !!
+      !!                Here DOME configuration
+      !!
+      !! ** input   : - namusr_def namelist found in namelist_cfg
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
+      !
+      INTEGER ::   ios          ! Local integer
+      REAL(wp)::   zlx, zly, zh ! Local scalars
+      !!
+      NAMELIST/namusr_def/  ln_zco, ln_zps, ln_sco, rn_dx, rn_dz, rn_f0
+      !!----------------------------------------------------------------------
+      !
+      READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
+      !
+      rn_dy = rn_dx
+#if defined key_agrif 
+      ! Domain parameters are taken from parent:
+      IF( .NOT. Agrif_Root() ) THEN
+         rn_dx = Agrif_Parent(rn_dx)/Agrif_Rhox()
+         rn_dy = Agrif_Parent(rn_dy)/Agrif_Rhoy()
+         rn_dz = Agrif_Parent(rn_dz)
+         rn_f0 = Agrif_Parent(rn_f0)
+      ENDIF
+#endif
+      !
+      IF(lwm)   WRITE( numond, namusr_def )
+      !
+      cd_cfg = 'DOME'               ! name & resolution (not used)
+      kk_cfg = nINT( rn_dx )
+      !
+      IF( Agrif_Root() ) THEN       ! Global Domain size:  DOME  global domain is  2000 km x 850 Km x 3600 m
+         kpi = NINT( 2000.e3  / rn_dx ) + 2  
+         kpj = NINT(  850.e3  / rn_dy ) + 2 + 1 
+      ELSE                          ! Global Domain size: add nbghostcells + 1 "land" point on each side
+         kpi  = nbcellsx + 2 * ( nbghostcells + 1 )
+         kpj  = nbcellsy + 2 * ( nbghostcells + 1 )
+!!$         kpi  = nbcellsx + nbghostcells_x   + nbghostcells_x   + 2
+!!$         kpj  = nbcellsy + nbghostcells_y_s + nbghostcells_y_n + 2
+      ENDIF
+      kpk = NINT( 3600._wp / rn_dz ) + 1
+      !
+      zlx = (kpi-2)*rn_dx*1.e-3
+      zly = (kpj-2-1)*rn_dy*1.e-3
+      zh  = (kpk-1)*rn_dz
+      !                             ! Set the lateral boundary condition of the global domain
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! DOME configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
+      !
+      !                             ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : DOME test case'
+         WRITE(numout,*) '      z-coordinate flag                 ln_zco = ', ln_zco
+         WRITE(numout,*) '      z-partial-step coordinate flag    ln_zps = ', ln_zps 
+         WRITE(numout,*) '      s-coordinate flag                 ln_sco = ', ln_sco  
+         WRITE(numout,*) '      horizontal resolution             rn_dx  = ', rn_dx, ' m'
+         WRITE(numout,*) '      vertical resolution               rn_dz  = ', rn_dz, ' m'
+         WRITE(numout,*) '      resulting global domain size :    Ni0glo = ', kpi
+         WRITE(numout,*) '                                        Nj0glo = ', kpj
+         WRITE(numout,*) '                                        jpkglo = ', kpk
+         WRITE(numout,*) '      DOME domain: '
+         WRITE(numout,*) '         LX [km]: ', zlx
+         WRITE(numout,*) '         LY [km]: ', zly
+         WRITE(numout,*) '          H [m] : ', zh
+         WRITE(numout,*) '      Coriolis frequency                rn_f0 = ', rn_f0, ' s-1'
+         WRITE(numout,*) '   '
+      ENDIF
+      !
+   END SUBROUTINE usr_def_nam
+
+   !!======================================================================
+END MODULE usrdef_nam
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_zgr.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -0,0 +1,262 @@
+MODULE usrdef_zgr
+   !!======================================================================
+   !!                     ***  MODULE usrdef_zgr  ***
+   !!
+   !!                       ===  DOME case  ===
+   !!
+   !! user defined :  vertical coordinate system of a user configuration
+   !!======================================================================
+   !! History :  4.0  ! 2020-12  (J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_zgr   : user defined vertical coordinate system (required)
+   !!       zgr_z1d   : reference 1D z-coordinate 
+   !!---------------------------------------------------------------------
+   USE oce            ! ocean variables
+   USE dom_oce ,  ONLY: mi0, mi1          ! ocean space and time domain
+   USE dom_oce ,  ONLY: glamt, gphit      ! ocean space and time domain
+   USE usrdef_nam     ! User defined : namelist variables
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! distributed memory computing library
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_zgr   ! called by domzgr.F90
+
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_zgr.F90 14053 2020-12-03 13:48:38Z techene $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS             
+
+   SUBROUTINE usr_def_zgr( ld_zco  , ld_zps  , ld_sco  , ld_isfcav,    &   ! type of vertical coordinate
+      &                    pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d  ,    &   ! 1D reference vertical coordinate
+      &                    pdept , pdepw ,                             &   ! 3D t & w-points depth
+      &                    pe3t  , pe3u  , pe3v , pe3f ,               &   ! vertical scale factors
+      &                    pe3w  , pe3uw , pe3vw,                      &   !     -      -      -
+      &                    k_top  , k_bot    )                             ! top & bottom ocean level
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE usr_def_zgr  ***
+      !!
+      !! ** Purpose :   User defined the vertical coordinates
+      !!
+      !!----------------------------------------------------------------------
+      LOGICAL                   , INTENT(in   ) ::   ld_zco, ld_zps, ld_sco      ! vertical coordinate flags ( read in namusr_def )
+      LOGICAL                   , INTENT(  out) ::   ld_isfcav                   ! under iceshelf cavity flag
+      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:)    , INTENT(  out) ::   pe3t_1d , pe3w_1d           ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdept, pdepw                ! grid-point depth        [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors  [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3w , pe3uw, pe3vw         ! i-scale factors 
+      INTEGER , DIMENSION(:,:)  , INTENT(  out) ::   k_top, k_bot                ! first & last ocean level
+      !
+      INTEGER  ::   ji, jj, jk        ! dummy indices
+      INTEGER  ::   ik                ! local integers
+      REAL(wp) ::   zfact, z1_jpkm1   ! local scalar
+      REAL(wp) ::   ze3min            ! local scalar
+      REAL(wp), DIMENSION(jpi,jpj) ::   zht, zhu, zhv, zhf, z2d   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_zgr : DOME configuration (z(ps)- or s-coordinate closed box ocean without cavities)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      !
+      !
+      ! type of vertical coordinate
+      ! ---------------------------
+      ! already set in usrdef_nam.F90 by reading the namusr_def namelist except for ISF
+      ld_isfcav = .FALSE.
+      !
+      !
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+      !
+      !                       !==  UNmasked meter bathymetry  ==!
+      !
+      zht(:,:) = MIN(3600._wp, MAX( 600._wp,  600._wp - gphit(:,:)*1.e3*0.01 ))
+      !
+      ! at u/v/f-point: averaging zht
+      zhu(:,:) = 600_wp ; zhv(:,:) = 600_wp ; zhf(:,:) = 600_wp
+      DO ji = 1, jpim1
+         zhu(ji,:) = 0.5_wp * ( zht(ji,:) + zht(ji+1,:) )
+      END DO
+      DO jj = 1, jpjm1
+         zhv(:,jj) = 0.5_wp * ( zht(:,jj) + zht(:,jj+1) )
+      END DO
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            zhf(ji,jj) = 0.25_wp * (  zht(ji,jj  ) + zht(ji+1,jj  ) &
+                       &            + zht(ji,jj+1) + zht(ji+1,jj+1) ) 
+         END DO
+      END DO
+      CALL lbc_lnk( 'usrdef_zgr', zhu, 'U', 1.0_wp, zhv, 'V', 1.0_wp, zhf, 'F', 1.0_wp)      
+      !     
+      CALL zgr_z1d( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! Reference z-coordinate system
+      !
+      !
+      !                       !==  top masked level bathymetry  ==!  (all coordinates)
+      !
+      ! no ocean cavities : top ocean level is ONE, except over land
+      ! the ocean basin surrounded by land (1+nn_hls grid-point) set through lbc_lnk call
+      z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
+      WHERE (gphit(:,:)>0._wp) z2d(:,:) = 0._wp
+      ! Dig inlet:
+      WHERE ((gphit(:,:)>0._wp).AND.(glamt(:,:)>-50._wp).AND.(glamt(:,:)<50._wp)) z2d(:,:) = 1._wp
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin, see userdef_nam.F90
+      k_top(:,:) = NINT( z2d(:,:) )
+      !
+      !                              
+      !
+      IF ( ld_sco ) THEN      !==  s-coordinate  ==!   (terrain-following coordinate)
+         !
+         k_bot(:,:) = jpkm1 * k_top(:,:)  !* bottom ocean = jpk-1 (here use k_top as a land mask)
+         !
+         !                                !* terrain-following coordinate with e3.(k)=cst)
+         z1_jpkm1 = 1._wp / REAL( jpkm1 , wp)
+         DO jk = 1, jpk
+            pdept(:,:,jk) = zht(:,:) * z1_jpkm1 * ( REAL( jk   , wp ) - 0.5_wp )
+            pdepw(:,:,jk) = zht(:,:) * z1_jpkm1 * ( REAL( jk-1 , wp )          )
+            pe3t (:,:,jk) = zht(:,:) * z1_jpkm1
+            pe3u (:,:,jk) = zhu(:,:) * z1_jpkm1
+            pe3v (:,:,jk) = zhv(:,:) * z1_jpkm1
+            pe3f (:,:,jk) = zhf(:,:) * z1_jpkm1
+            pe3w (:,:,jk) = zht(:,:) * z1_jpkm1
+            pe3uw(:,:,jk) = zhu(:,:) * z1_jpkm1
+            pe3vw(:,:,jk) = zhv(:,:) * z1_jpkm1
+         END DO      
+      ENDIF
+      !
+      !
+      IF ( ld_zco ) THEN      !==  z-coordinate  ==!   (step-like topography)
+         !
+         !                                !* bottom ocean compute from the depth of grid-points
+         k_bot(:,:) = jpkm1 * k_top(:,:)     ! here use k_top as a land mask
+         DO jk = 1, jpkm1
+            WHERE( pdept_1d(jk) < zht(:,:) .AND. zht(:,:) <= pdept_1d(jk+1) )   k_bot(:,:) = jk * k_top(:,:)
+         END DO
+         !                                !* horizontally uniform coordinate (reference z-co everywhere)
+         DO jk = 1, jpk
+            pdept(:,:,jk) = pdept_1d(jk)
+            pdepw(:,:,jk) = pdepw_1d(jk)
+            pe3t (:,:,jk) = pe3t_1d (jk)
+            pe3u (:,:,jk) = pe3t_1d (jk)
+            pe3v (:,:,jk) = pe3t_1d (jk)
+            pe3f (:,:,jk) = pe3t_1d (jk)
+            pe3w (:,:,jk) = pe3w_1d (jk)
+            pe3uw(:,:,jk) = pe3w_1d (jk)
+            pe3vw(:,:,jk) = pe3w_1d (jk)
+         END DO
+      ENDIF
+      !
+      !
+      IF ( ld_zps ) THEN      !==  zps-coordinate  ==!   (partial bottom-steps)
+         !
+         ze3min = 0.1_wp * rn_dz
+         IF(lwp) WRITE(numout,*) '   minimum thickness of the partial cells = 10 % of e3 = ', ze3min
+         !
+         !
+         !                                !* bottom ocean compute from the depth of grid-points
+         k_bot(:,:) = jpkm1
+         DO jk = jpkm1, 1, -1
+            WHERE( zht(:,:) < pdepw_1d(jk) + ze3min )   k_bot(:,:) = jk-1
+         END DO
+         !
+         !                                !* vertical coordinate system
+         DO jk = 1, jpk                      ! initialization to the reference z-coordinate
+            pdept(:,:,jk) = pdept_1d(jk)
+            pdepw(:,:,jk) = pdepw_1d(jk)
+            pe3t (:,:,jk) = pe3t_1d (jk)
+            pe3u (:,:,jk) = pe3t_1d (jk)
+            pe3v (:,:,jk) = pe3t_1d (jk)
+            pe3f (:,:,jk) = pe3t_1d (jk)
+            pe3w (:,:,jk) = pe3w_1d (jk)
+            pe3uw(:,:,jk) = pe3w_1d (jk)
+            pe3vw(:,:,jk) = pe3w_1d (jk)
+         END DO
+         DO_2D( 1, 1, 1, 1 )
+            ik = k_bot(ji,jj)
+            pdepw(ji,jj,ik+1) = MIN( zht(ji,jj) , pdepw_1d(ik+1) )
+            pe3t (ji,jj,ik  ) = pdepw(ji,jj,ik+1) - pdepw(ji,jj,ik)
+            pe3t (ji,jj,ik+1) = pe3t (ji,jj,ik  ) 
+            !
+            pdept(ji,jj,ik  ) = pdepw(ji,jj,ik  ) + pe3t (ji,jj,ik  ) * 0.5_wp
+            pdept(ji,jj,ik+1) = pdepw(ji,jj,ik+1) + pe3t (ji,jj,ik+1) * 0.5_wp
+            pe3w (ji,jj,ik+1) = pdept(ji,jj,ik+1) - pdept(ji,jj,ik)              ! = pe3t (ji,jj,ik  )
+            pe3w (ji,jj,ik  ) = pdept(ji,jj,ik  ) - pdept(ji,jj,ik-1)            ! st caution ik > 1
+         END_2D         
+         !                                   ! bottom scale factors and depth at  U-, V-, UW and VW-points
+         !                                   ! usually Computed as the minimum of neighbooring scale factors
+         pe3u (:,:,:) = pe3t(:,:,:)          ! HERE DOME configuration : 
+         pe3v (:,:,:) = pe3t(:,:,:)          !    e3 increases with i-index and identical with j-index
+         pe3f (:,:,:) = pe3t(:,:,:)          !    so e3 minimum of (i,i+1) points is (i) point
+         pe3uw(:,:,:) = pe3w(:,:,:)          !    in j-direction e3v=e3t and e3f=e3v
+         pe3vw(:,:,:) = pe3w(:,:,:)          !    ==>>  no need of lbc_lnk calls
+         !      
+      ENDIF
+      !
+   END SUBROUTINE usr_def_zgr
+
+
+   SUBROUTINE zgr_z1d( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! 1D reference vertical coordinate
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zgr_z1d  ***
+      !!
+      !! ** Purpose :   set the depth of model levels and the resulting 
+      !!      vertical scale factors.
+      !!
+      !! ** Method  :   1D z-coordinate system (use in all type of coordinate)
+      !!       The depth of model levels is set from dep(k), an analytical function:
+      !!                   w-level: depw_1d  = dep(k)
+      !!                   t-level: dept_1d  = dep(k+0.5)
+      !!       The scale factors are the discrete derivative of the depth:
+      !!                   e3w_1d(jk) = dk[ dept_1d ] 
+      !!                   e3t_1d(jk) = dk[ depw_1d ]
+      !!
+      !!            ===    Here constant vertical resolution   ===
+      !!
+      !! ** Action  : - pdept_1d, pdepw_1d : depth of T- and W-point (m)
+      !!              - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:), INTENT(out) ::   pdept_1d, pdepw_1d   ! 1D grid-point depth        [m]
+      REAL(wp), DIMENSION(:), INTENT(out) ::   pe3t_1d , pe3w_1d    ! 1D vertical scale factors  [m]
+      !
+      INTEGER  ::   jk       ! dummy loop indices
+      REAL(wp) ::   zt, zw   ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN                         ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) '    zgr_z1d : Reference vertical z-coordinates: uniform dz = ', rn_dz
+         WRITE(numout,*) '    ~~~~~~~'
+      ENDIF
+      !
+      ! Reference z-coordinate (depth - scale factor at T- and W-points)   ! Madec & Imbard 1996 function
+      ! ----------------------
+      DO jk = 1, jpk
+         zw = REAL( jk , wp )
+         zt = REAL( jk , wp ) + 0.5_wp
+         pdepw_1d(jk) =    rn_dz *   REAL( jk-1 , wp )
+         pdept_1d(jk) =    rn_dz * ( REAL( jk-1 , wp ) + 0.5_wp )
+         pe3w_1d (jk) =    rn_dz
+         pe3t_1d (jk) =    rn_dz
+      END DO
+      !
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference 1D z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
+      ENDIF
+      !
+   END SUBROUTINE zgr_z1d
+   
+   !!======================================================================
+END MODULE usrdef_zgr
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/cpp_DOME.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/cpp_DOME.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/cpp_DOME.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif key_linssh
+ bld::tool::fppkeys key_xios key_agrif key_linssh
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/context_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/context_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/context_nemo.xml	(revision 14644)
@@ -0,0 +1,38 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+<!-- $id$ -->
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-oce.xml"/>    <!--  NEMO ocean dynamics     --> 
+    <field_definition src="./field_def_nemo-ice.xml"/>    <!--  NEMO sea-ice model      --> 
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo-oce.xml"/>     <!--  NEMO ocean dynamics      --> 
+    <file_definition src="./file_def_nemo-ice.xml"/>     <!--  NEMO sea-ice model       --> 
+    <!-- 
+============================================================================================================
+= 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="profsed" long_name="Vertical S levels" unit="cm" 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 src="./grid_def_nemo.xml"/>
+    
+</context>
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/domain_def_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/domain_def_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/domain_def_nemo.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/domain_def_nemo.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/field_def_nemo-ice.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/field_def_nemo-ice.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/field_def_nemo-ice.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/field_def_nemo-ice.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/field_def_nemo-oce.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/field_def_nemo-oce.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/field_def_nemo-oce.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/file_def_nemo-ice.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/file_def_nemo-ice.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/file_def_nemo-ice.xml	(revision 14644)
@@ -0,0 +1,111 @@
+<?xml version="1.0"?>
+    <!-- $id$ -->
+    
+ <!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                      Define your own files for sea ice                                   =
+=                                         put the variables you want...                                    =
+============================================================================================================
+ -->
+    
+ <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+   
+   <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE.">  <!-- 1ts files -->   	
+     <file id="file21" name_suffix="_icemod" description="ice variables" enabled=".true." >
+
+       <!-- ice mask -->
+       <field field_ref="icemask"          name="simsk"   />
+       <field field_ref="icemask05"        name="simsk05" />
+       <field field_ref="icemask15"        name="simsk15" />
+       
+       <!-- general -->
+       <field field_ref="snwvolu"          name="snvolu" />
+       <field field_ref="icethic"          name="sithic" />
+       <field field_ref="icevolu"          name="sivolu" />
+       <field field_ref="iceconc"          name="siconc" />
+       <field field_ref="icesalt"          name="sisali" />
+       <field field_ref="iceapnd"          name="siapnd" />
+       <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="sst_m"            name="sst_m"  />
+       <field field_ref="sss_m"            name="sss_m"  />
+       
+       <!-- heat -->
+       <field field_ref="icetemp"          name="sitemp" />
+       <field field_ref="snwtemp"          name="sntemp" />
+       <field field_ref="icettop"          name="sittop" />
+       <field field_ref="icetbot"          name="sitbot" />
+       <field field_ref="icetsni"          name="sitsni" />
+       
+       <!-- momentum -->
+       <field field_ref="uice"             name="sivelu"  />
+       <field field_ref="vice"             name="sivelv"  />
+       <field field_ref="icevel"           name="sivelo"  />
+       <field field_ref="utau_ai"          name="utau_ai" />
+       <field field_ref="vtau_ai"          name="vtau_ai" />
+       <field field_ref="utau_oi"          name="utau_oi" />
+       <field field_ref="vtau_oi"          name="vtau_oi" />
+       
+       <!-- rheology -->
+       <field field_ref="icediv"           name="sidive"  />
+       <field field_ref="iceshe"           name="sishea"  />
+       <field field_ref="icestr"           name="sistre"  />
+       <field field_ref="normstr"          name="normstr" />
+       <field field_ref="sheastr"          name="sheastr" />
+       <field field_ref="sig1_pnorm"       name="sig1_pnorm"/>
+       <field field_ref="sig2_pnorm"       name="sig2_pnorm"/>
+       
+       <!-- heat fluxes -->
+       <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+       <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+       <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+       <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+       <field field_ref="qt_ice"           name="qt_ice"     />
+       <field field_ref="qsr_ice"          name="qsr_ice"    />
+       <field field_ref="qns_ice"          name="qns_ice"    />
+       <field field_ref="qemp_ice"         name="qemp_ice"   />
+       <field field_ref="albedo"           name="albedo"     />
+       
+       <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+       <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+       <field field_ref="hfxsensib"        name="hfxsensib"  />
+       
+       <!-- salt fluxes -->
+       <field field_ref="sfxice"           name="sfxice" />
+       
+       <!-- mass fluxes -->
+       <field field_ref="vfxice"           name="vfxice" />
+       <field field_ref="vfxsnw"           name="vfxsnw" />
+
+       <!-- categories -->
+       <field field_ref="icemask_cat"      name="simskcat"/>
+       <field field_ref="snwthic_cat"      name="snthicat"/>
+       <field field_ref="iceconc_cat"      name="siconcat"/>
+       <field field_ref="icethic_cat"      name="sithicat"/>
+       <field field_ref="icesalt_cat"      name="sisalcat"/>
+       <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="snwtemp_cat"      name="sntemcat"/>
+       <field field_ref="icettop_cat"      name="sitopcat"/>
+
+     </file>
+     
+   </file_group>
+   
+   <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="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="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>
+ 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/file_def_nemo-oce.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/file_def_nemo-oce.xml	(revision 14644)
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context               =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1d" min_digits="4">
+    
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE.">  <!-- 1d files -->   
+        <file id="file11" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="e3t"      />
+          <field field_ref="toce"         name="thetao"  operation="instant" freq_op="1d" > @toce_e3t / @e3t </field>
+          <field field_ref="soce"         name="so"      operation="instant" freq_op="1d" > @soce_e3t / @e3t </field>
+          <field field_ref="sst"          name="tos"   />
+          <field field_ref="sss"          name="sos"   />
+          <field field_ref="ssh"          name="zos"   />
+          <field field_ref="sbt"      />
+          <field field_ref="heatc"        name="heatc" />
+          <field field_ref="saltc"        name="saltc" />
+
+	  <field field_ref="empmr"        name="wfo"      />
+	  <field field_ref="qsr_oce"      name="qsr_oce"  />
+	  <field field_ref="qns_oce"      name="qns_oce"  />
+	  <field field_ref="qt_oce"       name="qt_oce"   />
+	  <field field_ref="saltflx"      name="sfx"      />
+	  <field field_ref="taum"         name="taum"     />
+	  <field field_ref="wspd"         name="windsp"   />
+	  <field field_ref="precip"       name="precip"   />
+	</file>
+
+	<file id="file12" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="e3u" />
+	  <field field_ref="ssu"          name="uos"      />
+	  <field field_ref="uoce"         name="uo"       operation="instant" freq_op="1d" > @uoce_e3u / @e3u </field>
+	  <field field_ref="utau"         name="tauuo"    />
+	</file>
+	
+	<file id="file13" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="e3v" />
+	  <field field_ref="ssv"          name="vos"      />
+	  <field field_ref="voce"         name="vo"       operation="instant" freq_op="1d" > @voce_e3v / @e3v </field>
+	  <field field_ref="vtau"         name="tauvo"    />
+	</file>
+	
+      </file_group> 
+
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+      </file_group>
+
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."> <!-- real yearly files -->
+      </file_group>
+	
+      
+      <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+      <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="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="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>
+    
+
+
+
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/grid_def_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/grid_def_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/grid_def_nemo.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/grid_def_nemo.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/iodef.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/iodef.xml	(revision 14644)
@@ -0,0 +1,26 @@
+<?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">false</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>
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_cfg	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_cfg	(revision 14644)
@@ -0,0 +1,265 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  BENCH Configuration namelist : overwrite some defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =   'DONUT' !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =   480  !   96 !   last time step 
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints                                       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_timing   = .false.   !  timing by routine write out in timing.output file
+/
+!-----------------------------------------------------------------------
+&namdom        !   time and space domain
+!-----------------------------------------------------------------------
+   rn_Dt       =    900.   !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_atfp     =   0.05    !  asselin time filter parameter
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration                      (default: use namusr_def in namelist_cfg)
+!-----------------------------------------------------------------------
+   ln_read_cfg =  .true.   !  (=T) read the domain configuration file
+      !                    !  (=F) user defined configuration           (F => create/check namusr_def)
+      cn_domcfg = "donut_cfg"  ! domain configuration filename
+/
+!-----------------------------------------------------------------------
+&namtsd        !    Temperature & Salinity Data  (init/dmp)             (default: OFF)
+!-----------------------------------------------------------------------
+   !                       ! =T  read T-S fields for:
+   ln_tsd_init =  .true.         !  ocean initialisation
+   ln_tsd_dmp  = .false.         !  T-S restoring   (see namtra_dmp)
+   
+   cn_dir      = './'      !  root directory for the T-S data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   sn_tem = 'donut_istate',  -12      , 'tn',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+   sn_sal = 'donut_istate',  -12      , 'sn',   .true.    , .true. , 'yearly'  ,    ''            ,    ''    ,    ''
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***          !!
+!!                                                                    !!
+!!   namsbc          surface boundary condition manager                 (default: NO selection)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+  nn_fsbc     = 1         !  frequency of SBC module call
+  ln_usr      = .true.    !  user defined formulation                  (T => check usrdef_sbc)
+  ln_traqsr   = .true.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+  nn_ice      = 2         !  =0 no ice boundary condition
+     !                    !  =1 use observed ice-cover                 (  => fill namsbc_iif )
+     !                    !  =2 or 3 for SI3 and CICE, respectively
+/
+
+!
+!!======================================================================
+!!               ***  Lateral boundary condition  ***                 !!
+!!                                                                    !!
+!!   namlbc        lateral momentum boundary condition                  (default: NO selection)
+!!   namagrif      agrif nested grid   (read by child model only)       ("key_agrif")
+!!   nam_tide      Tidal forcing                                        (default: OFF)
+!!   nambdy        Unstructured open boundaries                         (default: OFF)
+!!   nambdy_dta    Unstructured open boundaries - external data         (see  nambdy)
+!!   nambdy_tide   tidal forcing at open boundaries                     (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition                  (default: NO selection)
+!-----------------------------------------------------------------------
+   rn_shlat    =    2.     !  free slip
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          (default: OFF)
+!-----------------------------------------------------------------------
+   ln_bdy         = .true.    !  Use unstructured open boundaries
+   nb_bdy         = 2         !  number of open boundary sets
+   ln_coords_file = .true.,.true.    !  =T : read bdy coordinates from file
+      cn_coords_file = 'bdy_outer_cfg.nc','bdy_inner_cfg.nc'  !  bdy coordinates files
+   cn_dyn2d    = 'flather','flather'    !
+   nn_dyn2d_dta   =  1,1        !  = 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','frs'     !
+   nn_dyn3d_dta  =  1,1         !  = 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    =  1,1         !  = 0, bdy data are equal to the initial state
+   !                          !  = 1, bdy data are read in 'bdydata.nc' files
+   cn_ice        =  'frs','frs'     !
+   nn_ice_dta    =  1,1         !  = 0, bdy data are equal to the initial state
+   !                          !  = 1, bdy data are read in 'bdydata.nc' files
+   !
+   nn_rimwidth   = 2,1          !  width of the relaxation zone
+/
+!-----------------------------------------------------------------------
+&nambdy_dta    !  open boundaries - external data                       (see nam_bdy)
+!-----------------------------------------------------------------------
+   ln_full_vel = .true.      !  ???
+
+   cn_dir      = './'    !  root directory for the BDY data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !            !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   bn_ssh      = 'bdy_outer_dta'  ,  -12        ,   'ssh',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_u3d      = 'bdy_outer_dta'  ,  -12        ,    'un',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_v3d      = 'bdy_outer_dta'  ,  -12        ,    'vn',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_tem      = 'bdy_outer_dta'  ,  -12        ,    'tn',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_sal      = 'bdy_outer_dta'  ,  -12        ,    'sn',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+!* for si3
+   bn_a_i      = 'bdy_outer_dta'  ,  -12        ,   'a_i',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_h_i      = 'bdy_outer_dta'  ,  -12        ,   'h_i',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_h_s      = 'bdy_outer_dta'  ,  -12        ,   'h_s',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+/
+!-----------------------------------------------------------------------
+&nambdy_dta    !  open boundaries - external data                       (see nam_bdy)
+!-----------------------------------------------------------------------
+   ln_full_vel = .true.      !  ???
+
+   cn_dir      = './'    !  root directory for the BDY data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !            !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   bn_ssh      = 'bdy_inner_dta'  ,  -12        ,   'ssh',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_u3d      = 'bdy_inner_dta'  ,  -12        ,    'un',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_v3d      = 'bdy_inner_dta'  ,  -12        ,    'vn',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_tem      = 'bdy_inner_dta'  ,  -12        ,    'tn',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_sal      = 'bdy_inner_dta'  ,  -12        ,    'sn',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+!* for si3
+   bn_a_i      = 'bdy_inner_dta'  ,  -12        ,   'a_i',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_h_i      = 'bdy_inner_dta'  ,  -12        ,   'h_i',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+   bn_h_s      = 'bdy_inner_dta'  ,  -12        ,   'h_s',    .false.   , .true., 'yearly'  ,    ''            ,   ''     ,     ''
+/
+!!======================================================================
+!!                ***  Top/Bottom boundary condition  ***             !!
+!!                                                                    !!
+!!   namdrg        top/bottom drag coefficient                          (default: NO selection)
+!!   namdrg_top    top    friction                                      (ln_OFF =F & ln_isfcav=T)
+!!   namdrg_bot    bottom friction                                      (ln_OFF =F)
+!!   nambbc        bottom temperature boundary condition                (default: OFF)
+!!   nambbl        bottom boundary layer scheme                         (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
+!-----------------------------------------------------------------------
+   !                       !  type of penetration                        (default: NO selection)
+   ln_qsr_rgb  = .true.      !  RGB light penetration (Red-Green-Blue)
+   nn_chldta   =      0      !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&namdrg        !   top/bottom drag coefficient                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_non_lin  = .true.   !  non-linear  drag: Cd = Cd0 |U|
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbl   = .true.   !  Bottom Boundary Layer parameterisation flag
+/
+
+!!======================================================================
+!!                        Tracer (T & S) namelists                    !!
+!!                                                                    !!
+!!   nameos        equation of state                                    (default: NO selection)
+!!   namtra_adv    advection scheme                                     (default: NO selection)
+!!   namtra_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namtra_mle    mixed layer eddy param. (Fox-Kemper param.)          (default: OFF)
+!!   namtra_eiv    eddy induced velocity param.                         (default: OFF)
+!!   namtra_dmp    T & S newtonian damping                              (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean Equation Of Seawater                           (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_eos80    = .true.         !  = Use EOS80
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traadv_fct = .true.  !  FCT scheme
+      nn_fct_h   =  4            !  =2/4, horizontal 2nd / 4th order
+      nn_fct_v   =  2            !  =2/4, vertical   2nd / COMPACT 4th order
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traldf_blp   = .true.   !    laplacian operator
+   ln_traldf_iso   = .true.   !  iso-neutral (standard operator)
+   !
+   ln_traldf_msc   = .true.   !  Method of Stabilizing Correction      (both operators)
+   nn_aht_ijk_t    = 31       !  space/time variation of eddy coefficient:
+/
+
+!!======================================================================
+!!                      ***  Dynamics namelists  ***                  !!
+!!                                                                    !!
+!!   nam_vvl       vertical coordinate options                          (default: z-star)
+!!   namdyn_adv    formulation of the momentum advection                (default: NO selection)
+!!   namdyn_vor    advection scheme                                     (default: NO selection)
+!!   namdyn_hpg    hydrostatic pressure gradient                        (default: NO selection)
+!!   namdyn_spg    surface pressure gradient                            (default: NO selection)
+!!   namdyn_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namdta_dyn    offline TOP: dynamics read in files                  (OFF_SRC only)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nam_vvl       !   vertical coordinate options                          (default: z-star)
+!-----------------------------------------------------------------------
+   ln_vvl_zstar  = .true.           !  z-star vertical coordinate
+   ln_vvl_dbg    = .false.          !  debug prints    (T/F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true. !  vector form (T) or flux form (F)
+      nn_dynkeg     = 1       ! scheme for grad(KE): =0   C2  ;  =1   Hollingsworth correction
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynvor_eeT = .true. !  energy conserving scheme (een using e3t)
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynspg_ts   = .true.   ! split-explicit free surface
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynldf_blp =  .true.    !    laplacian operator
+   ln_dynldf_hor =  .true.    !  horizontal (geopotential)
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 31           !  space/time variation of eddy coef
+/
+
+!!======================================================================
+!!                     vertical physics namelists                     !!
+!!                                                                    !!
+!!    namzdf        vertical physics manager                            (default: NO selection)
+!!    namzdf_ric    richardson number vertical mixing                   (ln_zdfric=T)
+!!    namzdf_tke    TKE vertical mixing                                 (ln_zdftke=T)
+!!    namzdf_gls    GLS vertical mixing                                 (ln_zdfgls=T)
+!!    namzdf_osm    OSM vertical diffusion                              (ln_zdfosm=T)
+!!    namzdf_iwm    tidal mixing parameterization                       (ln_zdfiwm=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics                                     (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zdftke   = .true.       !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
+   ln_zdfevd   = .true.       !  enhanced vertical diffusion
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ice_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ice_cfg	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ice_cfg	(revision 14644)
@@ -0,0 +1,85 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! SI3 configuration namelist: Overwrites SHARED/namelist_ice_ref
+!!              1 - Generic parameters                 (nampar)
+!!              2 - Ice thickness discretization       (namitd)
+!!              3 - Ice dynamics                       (namdyn)
+!!              4 - Ice ridging/rafting                (namdyn_rdgrft)
+!!              5 - Ice rheology                       (namdyn_rhg)
+!!              6 - Ice advection                      (namdyn_adv)
+!!              7 - Ice surface forcing                (namforcing)
+!!              8 - Ice thermodynamics                 (namthd)
+!!              9 - Ice heat diffusion                 (namthd_zdf)
+!!             10 - Ice lateral melting                (namthd_da)
+!!             11 - Ice growth in open water           (namthd_do)
+!!             12 - Ice salinity                       (namthd_sal)
+!!             13 - Ice melt ponds                     (namthd_pnd)
+!!             14 - Ice initialization                 (namini)
+!!             15 - Ice/snow albedos                   (namalb)
+!!             16 - Ice diagnostics                    (namdia)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!------------------------------------------------------------------------------
+&nampar         !   Generic parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namitd         !   Ice discretization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn         !   Ice dynamics
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_rdgrft  !   Ice ridging/rafting
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_rhg     !   Ice rheology
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_adv     !   Ice advection
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namforcing     !   Ice surface forcing
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd         !   Ice thermodynamics
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_zdf     !   Ice heat diffusion
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_da      !   Ice lateral melting
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_do      !   Ice growth in open water
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_sal     !   Ice salinity
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_pnd     !   Melt ponds
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namini         !   Ice initialization
+!------------------------------------------------------------------------------
+   rn_thres_sst     =   0.5           !  max delta temp. above Tfreeze with initial ice = (sst - tfreeze)
+/
+!------------------------------------------------------------------------------
+&namalb         !   albedo parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdia         !   Diagnostics
+!------------------------------------------------------------------------------
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ice_ref
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ice_ref	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ice_ref	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ice_ref
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ref
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ref	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/EXPREF/namelist_ref	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/MY_SRC/usrdef_sbc.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -0,0 +1,152 @@
+MODULE usrdef_sbc
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_sbc  ***
+   !! 
+   !!                      ===  DONUT configuration  ===
+   !!
+   !! User defined :   surface forcing of a user configuration
+   !!======================================================================
+   !! History :  4.0   ! 2016-03  (S. Flavoni, G. Madec)  user defined interface
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_sbc    : user defined surface bounday conditions in DONUT case
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE sbc_ice         ! Surface boundary condition: ice fields
+   USE in_out_manager  ! I/O manager
+   USE phycst          ! physical constants
+#if defined key_si3
+   USE ice, ONLY       : at_i_b, a_i_b
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usrdef_sbc_oce      ! routine called by sbcmod.F90 for sbc ocean
+   PUBLIC   usrdef_sbc_ice_tau  ! routine called by icestp.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by icestp.F90 for ice thermo
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_sbc.F90 10074 2018-08-28 16:15:49Z nicolasmartin $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usrdef_sbc_oce( kt, Kbb )
+      !!---------------------------------------------------------------------
+      !!                    ***  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 DONUT 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
+      INTEGER, INTENT(in) ::   Kbb  ! ocean time index
+      !!---------------------------------------------------------------------
+      !
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp)   WRITE(numout,*)' usrdef_sbc_oce : DONUT case: NO surface forcing'
+         ! --- oce variables --- !
+         utau(:,:) = 0._wp 
+         vtau(:,:) = 0._wp
+         taum(:,:) = 0._wp
+         wndm(:,:) = 0._wp
+         !
+         emp (:,:) = 0._wp
+         sfx (:,:) = 0._wp
+         qns (:,:) = 0._wp
+         qsr (:,:) = 0._wp
+         !
+         utau_b(:,:) = 0._wp 
+         vtau_b(:,:) = 0._wp
+         emp_b (:,:) = 0._wp
+         sfx_b (:,:) = 0._wp
+         qns_b (:,:) = 0._wp
+         !
+      ENDIF
+      !
+   END SUBROUTINE usrdef_sbc_oce
+
+
+   SUBROUTINE usrdef_sbc_ice_tau( kt )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE usrdef_sbc_ice_tau  ***
+      !!
+      !! ** Purpose :   provide the surface boundary (momentum) condition over sea-ice
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      !!---------------------------------------------------------------------
+#if defined key_si3
+      IF( kt==nit000 .AND. lwp)   WRITE(numout,*)' usrdef_sbc_ice : DONUT case: NO stress forcing'
+      !
+      utau_ice(:,:) = 0._wp
+      vtau_ice(:,:) = 0._wp
+#endif
+      !
+   END SUBROUTINE usrdef_sbc_ice_tau
+
+
+   SUBROUTINE usrdef_sbc_ice_flx( kt, phs, phi )
+      !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE usrdef_sbc_ice_flx  ***
+      !!
+      !! ** Purpose :   provide the surface boundary (flux) condition over sea-ice
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      REAL(wp), DIMENSION(:,:,:), INTENT(in) ::   phs    ! snow thickness
+      REAL(wp), DIMENSION(:,:,:), INTENT(in) ::   phi    ! ice thickness
+      !!
+      REAL(wp), DIMENSION(jpi,jpj) ::   zsnw   ! snw distribution after wind blowing
+      !!---------------------------------------------------------------------
+#if defined key_si3
+      !
+      IF( kt==nit000 .AND. lwp)   WRITE(numout,*)' usrdef_sbc_ice : DONUT case: NO flux forcing'
+      !
+      ! ocean variables (renaming)
+      emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
+      qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar heat flux
+
+      ! ice variables
+      alb_ice (:,:,:) = 0.7_wp  ! useless
+      qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar heat flux
+      dqns_ice(:,:,:) = 0._wp   ! uniform value for non solar heat flux sensitivity for ice
+      sprecip (:,:)   = 0._wp   ! uniform value for snow precip
+      evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
+
+      ! ice fields deduced from above
+      zsnw(:,:) = 1._wp
+      !!CALL lim_thd_snwblow( at_i_b, zsnw )  ! snow distribution over ice after wind blowing 
+      emp_ice  (:,:)   = SUM( a_i_b(:,:,:) * evap_ice(:,:,:), dim=3 ) - sprecip(:,:) * zsnw(:,:)
+      emp_oce  (:,:)   = emp_oce(:,:) - sprecip(:,:) * (1._wp - zsnw(:,:) )
+      qevap_ice(:,:,:) =   0._wp
+      qprec_ice(:,:)   =   rhos * ( sst_m(:,:) * rcpi - rLfus ) * tmask(:,:,1) !  in J/m3
+      qemp_oce (:,:)   = - emp_oce(:,:) * sst_m(:,:) * rcp
+      qemp_ice (:,:)   =   sprecip(:,:) * zsnw * ( sst_m(:,:) * rcpi - rLfus ) * tmask(:,:,1) ! solid precip (only)
+
+      ! total fluxes
+      emp_tot (:,:) = emp_ice  + emp_oce
+      qns_tot (:,:) = at_i_b(:,:) * qns_oce(:,:) + SUM( a_i_b(:,:,:) * qns_ice(:,:,:), dim=3 ) + qemp_ice(:,:) + qemp_oce(:,:)
+      qsr_tot (:,:) = at_i_b(:,:) * qsr_oce(:,:) + SUM( a_i_b(:,:,:) * qsr_ice(:,:,:), dim=3 )
+
+      ! --- shortwave radiation transmitted thru the surface scattering layer (W/m2) --- !
+      qtr_ice_top(:,:,:) = 0._wp
+#endif
+
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+
+   !!======================================================================
+END MODULE usrdef_sbc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/cpp_DONUT.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/cpp_DONUT.fcm	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DONUT/cpp_DONUT.fcm	(revision 14644)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys key_si3 key_qco key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/EXPREF/namelist_cfg	(revision 14644)
@@ -464,5 +464,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -470,5 +470,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/MY_SRC/step.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/MY_SRC/step.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/MY_SRC/step.F90	(revision 14644)
@@ -39,5 +39,5 @@
 #else
    !!----------------------------------------------------------------------
-   !!   stp             : OPA system time-stepping
+   !!   stp             : OCE system time-stepping
    !!----------------------------------------------------------------------
    USE step_oce         ! time stepping definition modules
@@ -72,5 +72,5 @@
       !!                     ***  ROUTINE stp  ***
       !!
-      !! ** Purpose : - Time stepping of OPA  (momentum and active tracer eqs.)
+      !! ** Purpose : - Time stepping of OCE  (momentum and active tracer eqs.)
       !!              - Time stepping of SI3 (dynamic and thermodynamic eqs.)
       !!              - Time stepping of TRC  (passive tracer eqs.)
@@ -98,5 +98,5 @@
       ENDIF
       IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
-# if defined key_iomput
+# if defined key_xios
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
 # endif
@@ -150,5 +150,5 @@
       ENDIF
       !
-#if defined key_iomput
+#if defined key_xios
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Finalize contextes if end of simulation or error detected
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -42,5 +42,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -54,8 +54,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -78,5 +80,6 @@
       !
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! ICB configuration : box
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! ICB configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -99,6 +102,4 @@
          WRITE(numout,*) '                                               jpkglo   = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      ICB : closed basin                    jperio   = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/cpp_ICB.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/cpp_ICB.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/cpp_ICB.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi key_qco 
+ bld::tool::fppkeys   key_xios key_qco 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_120pts	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_240pts	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/EXPREF/namelist_cfg_60pts	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -75,10 +75,10 @@
 
       !                          ==========
-      zlam0 = -REAL( (Ni0glo-2)/2, wp) * 1.e-3 * rn_dx
-      zphi0 = -REAL( (Nj0glo-2)/2, wp) * 1.e-3 * rn_dy
+      zlam0 = -REAL(Ni0glo, wp) * 0.5 * 1.e-3 * rn_dx
+      zphi0 = -REAL(Nj0glo, wp) * 0.5 * 1.e-3 * rn_dy
 
-      DO_2D( 1, 1, 1, 1 )
-         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
-         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         zti = REAL( mig0(ji), wp ) - 0.5_wp  ! start at i=0.5 in the global grid without halos
+         ztj = REAL( mjg0(jj), wp ) - 0.5_wp  ! start at j=0.5 in the global grid without halos
          
          plamt(ji,jj) = zlam0 + rn_dx * 1.e-3 *   zti
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -39,5 +39,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -51,8 +51,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios       ! Local integer
@@ -78,5 +80,7 @@
       zly = kpj*rn_dy*1.e-3
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! ICE_ADV1D configuration : bi-periodic basin
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! ICE_ADV1D configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
+      !
       !                             ! control print
       IF(lwp) THEN
@@ -95,6 +99,4 @@
          WRITE(numout,*) '         Coriolis:', ln_corio
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      ICE_ADV1D : closed basin                 jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -120,10 +120,11 @@
       emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
       qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
-      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar heat flux
 
       ! ice variables
       alb_ice (:,:,:) = 0.7_wp  ! useless
       qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
-      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar heat flux
+      dqns_ice(:,:,:) = 0._wp   ! uniform value for non solar heat flux sensitivity for ice
       sprecip (:,:)   = 0._wp   ! uniform value for snow precip
       evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/cpp_ICE_ADV1D.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/cpp_ICE_ADV1D.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/cpp_ICE_ADV1D.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_si3 key_mpp_mpi key_nosignedzero key_iomput key_linssh
+bld::tool::fppkeys key_si3 key_xios key_linssh
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/EXPREF/namelist_cfg	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -76,6 +76,6 @@
 
       !                          ==========
-      zlam0 = -REAL( (Ni0glo-2)/2, wp) * 1.e-3 * rn_dx
-      zphi0 = -REAL( (Nj0glo-2)/2, wp) * 1.e-3 * rn_dy 
+      zlam0 = -REAL(Ni0glo, wp) * 0.5 * 1.e-3 * rn_dx
+      zphi0 = -REAL(Nj0glo, wp) * 0.5 * 1.e-3 * rn_dy
 
 #if defined key_agrif 
@@ -90,7 +90,7 @@
 #endif         
 
-      DO_2D( 1, 1, 1, 1 )
-         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
-         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         zti = REAL( mig0(ji), wp ) - 0.5_wp  ! start at i=0.5 in the global grid without halos
+         ztj = REAL( mjg0(jj), wp ) - 0.5_wp  ! start at j=0.5 in the global grid without halos
          
          plamt(ji,jj) = zlam0 + rn_dx * 1.e-3 *   zti
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,8 +52,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes 
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios       ! Local integer
@@ -96,7 +98,9 @@
       zly = kpj*rn_dy*1.e-3
       !
-      IF( Agrif_Root() ) THEN   ;   kperio = 7     ! ICE_AGRIF configuration : bi-periodic basin
-      ELSE                      ;   kperio = 0     ! closed periodicity for the zoom
+      IF( Agrif_Root() ) THEN   ;   ldIperio =  .TRUE.   ;   ldJperio =  .TRUE.     ! ICE_ADV2D configuration : bi-periodic basin
+      ELSE                      ;   ldIperio = .FALSE.   ;   ldJperio = .FALSE.     ! closed periodicity for the zoom
       ENDIF
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
+      !
       !                             ! control print
       IF(lwp) THEN
@@ -115,6 +119,4 @@
          WRITE(numout,*) '         Coriolis:', ln_corio
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      ICE_ADV2D : bi-periodic basin            jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -118,10 +118,11 @@
       emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
       qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
-      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar heat flux
 
       ! ice variables
       alb_ice (:,:,:) = 0.7_wp  ! useless
       qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
-      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar heat flux
+      dqns_ice(:,:,:) = 0._wp   ! uniform value for non solar heat flux sensitivity for ice
       sprecip (:,:)   = 0._wp   ! uniform value for snow precip
       evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/cpp_ICE_ADV2D.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/cpp_ICE_ADV2D.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/cpp_ICE_ADV2D.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_si3 key_linssh key_mpp_mpi key_nosignedzero key_iomput
+bld::tool::fppkeys key_si3 key_linssh key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/EXPREF/1_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/EXPREF/1_namelist_cfg	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/EXPREF/namelist_cfg	(revision 14644)
@@ -216,5 +216,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -222,5 +222,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -79,9 +79,6 @@
       IF( Agrif_Root() ) THEN
 #endif
-         ! Compatibility WITH old version: 
-         ! jperio = 7 =>  Ni0glo = jpigo_old_version - 2
-         !            =>  jpiglo-1 replaced by Ni0glo+1
-         zlam0 = -REAL( (Ni0glo+1)/2, wp) * 1.e-3 * rn_dx
-         zphi0 = -REAL( (Nj0glo+1)/2, wp) * 1.e-3 * rn_dy   ! +1 for compatibility with old version --> to be replaced by -1 as before
+         zlam0 = -REAL(Ni0glo, wp) * 0.5 * 1.e-3 * rn_dx
+         zphi0 = -REAL(Nj0glo, wp) * 0.5 * 1.e-3 * rn_dy
 #if defined key_agrif 
       ELSE
@@ -89,18 +86,15 @@
 !clem         zlam0  = Agrif_Parent(zlam0) + (Agrif_ix())*Agrif_Parent(rn_dx) * 1.e-5
 !clem         zphi0  = Agrif_Parent(zphi0) + (Agrif_iy())*Agrif_Parent(rn_dy) * 1.e-5
-         ! Compatibility WITH old version: 
-         ! jperio = 0 =>  Ni0glo = jpigo_old_version
-         !            =>  Agrif_parent(jpiglo)-1 replaced by  Agrif_parent(Ni0glo)-1
-         zlam0 = ( 0.5_wp - REAL( ( Agrif_parent(Ni0glo)-1 ) / 2, wp) ) * 1.e-3 * Agrif_irhox() * rn_dx  &
+         zlam0 = ( 0.5_wp - REAL(Ni0glo, wp) * 0.5 ) * 1.e-3 * Agrif_irhox() * rn_dx  &
             &  + ( Agrif_Ix() + nbghostcells - 1 ) * Agrif_irhox() * rn_dx * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dx * 1.e-3
-         zphi0 = ( 0.5_wp - REAL( ( Agrif_parent(Nj0glo)-1 ) / 2, wp) ) * 1.e-3 * Agrif_irhoy() * rn_dy  &
+         zphi0 = ( 0.5_wp - REAL(Nj0glo, wp) * 0.5 ) * 1.e-3 * Agrif_irhoy() * rn_dy  &
             &  + ( Agrif_Iy() + nbghostcells - 1 ) * Agrif_irhoy() * rn_dy * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dy * 1.e-3
       ENDIF
 #endif         
 
-      DO_2D( 1, 1, 1, 1 )
-         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
-         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
-         
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         zti = REAL( mig0(ji), wp ) - 0.5_wp  ! start at i=0.5 in the global grid without halos
+         ztj = REAL( mjg0(jj), wp ) - 0.5_wp  ! start at j=0.5 in the global grid without halos
+          
          plamt(ji,jj) = zlam0 + rn_dx * 1.e-3 *   zti
          plamu(ji,jj) = zlam0 + rn_dx * 1.e-3 * ( zti + 0.5_wp )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,8 +52,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes 
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios       ! Local integer
@@ -83,8 +85,6 @@
       !
       IF( Agrif_Root() ) THEN        ! Global Domain size:  ICE_AGRIF domain is  300 km x 300 Km x 10 m
-         kpi = NINT( 300.e3 / rn_dx ) - 1
-         kpj = NINT( 300.e3 / rn_dy ) - 1
-         kpi = kpi - 2   ! for compatibility with old version (because kerio=7) --> to be removed
-         kpj = kpj - 2   ! for compatibility with old version (because kerio=7) --> to be removed
+         kpi = NINT( 300.e3 / rn_dx ) - 3 
+         kpj = NINT( 300.e3 / rn_dy ) - 3
       ELSE                           ! Global Domain size: add nbghostcells + 1 "land" point on each side
          kpi  = nbcellsx + 2 * ( nbghostcells + 1 )
@@ -100,7 +100,9 @@
       zly = kpj*rn_dy*1.e-3
       !
-      IF( Agrif_Root() ) THEN   ;   kperio = 7     ! ICE_AGRIF configuration : bi-periodic basin
-      ELSE                      ;   kperio = 0     ! closed periodicity for the zoom
+      IF( Agrif_Root() ) THEN   ;   ldIperio =  .TRUE.   ;   ldJperio =  .TRUE.     ! ICE_AGRIF configuration : bi-periodic basin
+      ELSE                      ;   ldIperio = .FALSE.   ;   ldJperio = .FALSE.     ! closed periodicity for the zoom
       ENDIF
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
+      !
       !                             ! control print
       IF(lwp) THEN
@@ -119,6 +121,4 @@
          WRITE(numout,*) '         Coriolis:', ln_corio
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      ICE_AGRIF : bi-periodic basin            jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -119,10 +119,11 @@
       emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
       qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
-      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar heat flux
 
       ! ice variables
       alb_ice (:,:,:) = 0.7_wp  ! useless
       qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
-      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar heat flux
+      dqns_ice(:,:,:) = 0._wp   ! uniform value for non solar heat flux sensitivity for ice
       sprecip (:,:)   = 0._wp   ! uniform value for snow precip
       evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/cpp_ICE_AGRIF.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/cpp_ICE_AGRIF.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/cpp_ICE_AGRIF.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_agrif key_si3 key_linssh key_mpp_mpi key_iomput
+bld::tool::fppkeys key_agrif key_si3 key_linssh key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/EXPREF/namelist_cfg	(revision 14644)
@@ -245,5 +245,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -251,5 +251,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_eap.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_eap.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_eap.F90	(revision 14644)
@@ -354,5 +354,5 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_eap', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
+      CALL lbc_lnk( 'icedyn_rhg_eap', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
       !
       !                                  !== Landfast ice parameterization ==!
@@ -492,5 +492,5 @@
             zs2(ji,jj) = ( zs2(ji,jj) * zalph1 + zstressmtmp ) * z1_alph1
          END_2D
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zstress12tmp, 'T', 1.0_wp , paniso_11, 'T', 1.0_wp , paniso_12, 'T', 1.0_wp)
+         CALL lbc_lnk( 'icedyn_rhg_eap', zstress12tmp, 'T', 1.0_wp , paniso_11, 'T', 1.0_wp , paniso_12, 'T', 1.0_wp)
 
         ! Save beta at T-points for further computations
@@ -520,5 +520,5 @@
 
          END_2D
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zs1, 'T', 1.0_wp, zs2, 'T', 1.0_wp, zs12, 'F', 1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zs1, 'T', 1.0_wp, zs2, 'T', 1.0_wp, zs12, 'F', 1.0_wp )
 
          ! --- Ice internal stresses (Appendix C of Hunke and Dukowicz, 2002) --- !
@@ -832,7 +832,7 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_eap', pshear_i, 'T', 1.0_wp, pdivu_i, 'T', 1.0_wp, pdelta_i, 'T', 1.0_wp, &
-         &                                    zten_i, 'T', 1.0_wp, zs1    , 'T', 1.0_wp, zs2     , 'T', 1.0_wp, &
-         &                                      zs12, 'F', 1.0_wp )
+      CALL lbc_lnk( 'icedyn_rhg_eap', pshear_i, 'T', 1.0_wp, pdivu_i, 'T', 1.0_wp, pdelta_i, 'T', 1.0_wp, &
+         &                              zten_i, 'T', 1.0_wp, zs1    , 'T', 1.0_wp, zs2     , 'T', 1.0_wp, &
+         &                                zs12, 'F', 1.0_wp )
 
       ! --- Store the stress tensor for the next time step --- !
@@ -849,6 +849,6 @@
          & iom_use('utau_bi') .OR. iom_use('vtau_bi') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, ztaux_ai, 'U', -1.0_wp, &
-            &                                  ztauy_ai, 'V', -1.0_wp, ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, ztaux_ai, 'U', -1.0_wp, &
+            &                            ztauy_ai, 'V', -1.0_wp, ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
          !
          CALL iom_put( 'utau_oi' , ztaux_oi * aimsk00 )
@@ -934,5 +934,5 @@
       IF( iom_use('yield11') .OR. iom_use('yield12') .OR. iom_use('yield22')) THEN
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zyield11, 'T', 1.0_wp, zyield22, 'T', 1.0_wp, zyield12, 'T', 1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zyield11, 'T', 1.0_wp, zyield22, 'T', 1.0_wp, zyield12, 'T', 1.0_wp )
 
          CALL iom_put( 'yield11', zyield11 * aimsk00 )
@@ -951,7 +951,7 @@
          & iom_use('corstrx') .OR. iom_use('corstry') .OR. iom_use('intstrx') .OR. iom_use('intstry') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
-            &                                  zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, &
-            &                                    zfU, 'U', -1.0_wp,   zfV, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
+            &                            zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, &
+            &                              zfU, 'U', -1.0_wp,   zfV, 'V', -1.0_wp )
 
          CALL iom_put( 'dssh_dx' , zspgU * aimsk00 )   ! Sea-surface tilt term in force balance (x)
@@ -985,7 +985,7 @@
          END_2D
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_eap', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
-            &                                  zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
-            &                                  zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_eap', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
+            &                            zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
+            &                            zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
 
          CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_evp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_evp.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_evp.F90	(revision 14644)
@@ -320,5 +320,5 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_evp', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
+      CALL lbc_lnk( 'icedyn_rhg_evp', zmf, 'T', 1.0_wp, zdt_m, 'T', 1.0_wp )
       !
       !                                  !== Landfast ice parameterization ==!
@@ -770,6 +770,6 @@
 
       END_2D
-      CALL lbc_lnk_multi( 'icedyn_rhg_evp', pshear_i, 'T', 1._wp, pdivu_i, 'T', 1._wp, pdelta_i, 'T', 1._wp, zten_i, 'T', 1._wp, &
-         &                                  zs1     , 'T', 1._wp, zs2    , 'T', 1._wp, zs12    , 'F', 1._wp )
+      CALL lbc_lnk( 'icedyn_rhg_evp', pshear_i, 'T', 1._wp, pdivu_i, 'T', 1._wp, pdelta_i, 'T', 1._wp, zten_i, 'T', 1._wp, &
+         &                            zs1     , 'T', 1._wp, zs2    , 'T', 1._wp, zs12    , 'F', 1._wp )
       
       ! --- Store the stress tensor for the next time step --- !
@@ -786,6 +786,7 @@
          & iom_use('utau_bi') .OR. iom_use('vtau_bi') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp, ztaux_ai, 'U', -1.0_wp, ztauy_ai, 'V', -1.0_wp, &
-            &                                  ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_evp', ztaux_oi, 'U', -1.0_wp, ztauy_oi, 'V', -1.0_wp,   &
+            &                            ztaux_ai, 'U', -1.0_wp, ztauy_ai, 'V', -1.0_wp,   &
+            &                            ztaux_bi, 'U', -1.0_wp, ztauy_bi, 'V', -1.0_wp )
          !
          CALL iom_put( 'utau_oi' , ztaux_oi * zmsk00 )
@@ -871,6 +872,6 @@
          & iom_use('corstrx') .OR. iom_use('corstry') .OR. iom_use('intstrx') .OR. iom_use('intstry') ) THEN
          !
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
-            &                                  zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, zfU, 'U', -1.0_wp, zfV, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_evp', zspgU, 'U', -1.0_wp, zspgV, 'V', -1.0_wp, &
+            &                            zCorU, 'U', -1.0_wp, zCorV, 'V', -1.0_wp, zfU, 'U', -1.0_wp, zfV, 'V', -1.0_wp )
 
          CALL iom_put( 'dssh_dx' , zspgU * zmsk00 )   ! Sea-surface tilt term in force balance (x)
@@ -904,7 +905,7 @@
          END_2D
 
-         CALL lbc_lnk_multi( 'icedyn_rhg_evp', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
-            &                                  zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
-            &                                  zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
+         CALL lbc_lnk( 'icedyn_rhg_evp', zdiag_xmtrp_ice, 'U', -1.0_wp, zdiag_ymtrp_ice, 'V', -1.0_wp, &
+            &                            zdiag_xmtrp_snw, 'U', -1.0_wp, zdiag_ymtrp_snw, 'V', -1.0_wp, &
+            &                            zdiag_xatrp    , 'U', -1.0_wp, zdiag_yatrp    , 'V', -1.0_wp )
 
          CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,8 +52,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios       ! Local integer
@@ -81,5 +83,7 @@
       zly = kpj*rn_dy*1.e-3
       !
-      kperio = 0     ! closed periodicity for the zoom
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! ICE_RHEO configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
+      !
       !                             ! control print
       IF(lwp) THEN
@@ -98,6 +102,4 @@
          WRITE(numout,*) '         Coriolis:', ln_corio
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      ICE_RHEO closed basin                    jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -126,5 +126,5 @@
          windv(ji,jj) = Umax/sqrt(d*1000)*(d-2*mjg(jj)*res)/((d-2*mig(ji)*res)**2+(d-2*mjg(jj)*res)**2*Rwind**2)**(1/4)*Rwind*min(kt*30./21600,1.)
       END_2D
-      CALL lbc_lnk_multi( 'usrdef_sbc', windu, 'U', -1., windv, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_sbc', windu, 'U', -1., windv, 'V', -1. )
 
       wndm_ice(:,:) = 0._wp      !!gm brutal....
@@ -156,5 +156,5 @@
             &          * ( 0.5 * (windv(ji,jj+1) + windv(ji,jj) ) - r_vfac * v_ice(ji,jj) )
       END_2D
-      CALL lbc_lnk_multi( 'usrdef_sbc', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_sbc', utau_ice, 'U', -1., vtau_ice, 'V', -1. )
       !
    END SUBROUTINE usrdef_sbc_ice_tau
@@ -179,10 +179,11 @@
       emp_oce (:,:)   = 0._wp   ! uniform value for freshwater budget (E-P)
       qsr_oce (:,:)   = 0._wp   ! uniform value for     solar radiation
-      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar radiation
+      qns_oce (:,:)   = 0._wp   ! uniform value for non-solar heat flux
 
       ! ice variables
       alb_ice (:,:,:) = 0.7_wp  ! useless
       qsr_ice (:,:,:) = 0._wp   ! uniform value for     solar radiation
-      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar radiation
+      qns_ice (:,:,:) = 0._wp   ! uniform value for non-solar heat flux
+      dqns_ice(:,:,:) = 0._wp   ! uniform value for non solar heat flux sensitivity for ice
       sprecip (:,:)   = 0._wp   ! uniform value for snow precip
       evap_ice(:,:,:) = 0._wp   ! uniform value for sublimation
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/cpp_ICE_RHEO.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/cpp_ICE_RHEO.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/cpp_ICE_RHEO.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_si3 key_linssh key_mpp_mpi key_nosignedzero key_iomput
+bld::tool::fppkeys key_si3 key_linssh key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/EXPREF/namelist_cfg	(revision 14644)
@@ -528,5 +528,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -534,5 +534,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/cpp_ISOMIP+.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/cpp_ISOMIP+.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/cpp_ISOMIP+.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi 
+ bld::tool::fppkeys   key_xios 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/EXPREF/namelist_cfg	(revision 14644)
@@ -488,5 +488,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -494,5 +494,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -77,19 +77,19 @@
       !
       !                       !==  grid point position  ==!   (in degrees)
-      DO_2D( 1, 1, 1, 1 )
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
          !                       ! longitude   (west coast at lon=0°)
-         plamt(ji,jj) = rn_e1deg * (  - 0.5 + REAL( mig0_oldcmp(ji)-1 , wp )  )  
-         plamu(ji,jj) = rn_e1deg * (          REAL( mig0_oldcmp(ji)-1 , wp )  )
+         plamt(ji,jj) = rn_e1deg * (  - 0.5 + REAL( mig0(ji)-1 , wp )  )  
+         plamu(ji,jj) = rn_e1deg * (          REAL( mig0(ji)-1 , wp )  )
          plamv(ji,jj) = plamt(ji,jj)
          plamf(ji,jj) = plamu(ji,jj)
-         !                       ! latitude   (south coast at lat= 81°)
-         pphit(ji,jj) = rn_e2deg * (  - 0.5 + REAL( mjg0_oldcmp(jj)-1 , wp )  ) - 80._wp
+         !                       ! latitude   (south coast at lat=-80°)
+         pphit(ji,jj) = rn_e2deg * (  - 0.5 + REAL( mjg0(jj)-1 , wp )  ) - 80._wp
          pphiu(ji,jj) = pphit(ji,jj)
-         pphiv(ji,jj) = rn_e2deg * (          REAL( mjg0_oldcmp(jj)-1 , wp )  ) - 80_wp
+         pphiv(ji,jj) = rn_e2deg * (          REAL( mjg0(jj)-1 , wp )  ) - 80._wp
          pphif(ji,jj) = pphiv(ji,jj)
       END_2D
       !
       !                       !==  Horizontal scale factors  ==!   (in meters)
-      DO_2D( 1, 1, 1, 1 )
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
          !                       ! e1   (zonal)
          pe1t(ji,jj) = ra * rad * COS( rad * pphit(ji,jj) ) * rn_e1deg
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -41,5 +41,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -53,8 +53,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -77,5 +79,6 @@
       !
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! ISOMIP configuration : close basin
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! ISOMIP configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -98,6 +101,4 @@
          WRITE(numout,*) '                                               jpkglo   = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      ISOMIP : closed basin                    jperio   = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/cpp_ISOMIP.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/cpp_ISOMIP.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP/cpp_ISOMIP.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi 
+ bld::tool::fppkeys   key_xios 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_cen2_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_cen2_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_cen2_cfg	(revision 14644)
@@ -190,5 +190,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_flux_ubs_cfg	(revision 14644)
@@ -289,5 +289,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -295,5 +295,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_eenH_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_eenH_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_eenH_cfg	(revision 14644)
@@ -189,5 +189,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_een_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_een_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_een_cfg	(revision 14644)
@@ -188,5 +188,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_ene_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_ene_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_ene_cfg	(revision 14644)
@@ -188,5 +188,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_ens_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_ens_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT2_vect_ens_cfg	(revision 14644)
@@ -188,5 +188,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_flux_cen2_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_flux_cen2_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_flux_cen2_cfg	(revision 14644)
@@ -189,5 +189,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_flux_ubs_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_flux_ubs_cfg	(revision 14644)
@@ -189,5 +189,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_eenH_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_eenH_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_eenH_cfg	(revision 14644)
@@ -188,5 +188,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_een_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_een_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_een_cfg	(revision 14644)
@@ -189,5 +189,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_ene_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_ene_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_ene_cfg	(revision 14644)
@@ -190,5 +190,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_ens_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_ens_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/EXPREF/namelist_FCT4_vect_ens_cfg	(revision 14644)
@@ -189,5 +189,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -74,14 +74,14 @@
       !                       !==  grid point position  ==!   (in kilometers)
       zfact = rn_dx * 1.e-3         ! conversion in km
-      DO_2D( 1, 1, 1, 1 )
-         !                       ! longitude
-         plamt(ji,jj) = zfact * (  - 0.5 + REAL( mig0_oldcmp(ji)-1 , wp )  )  
-         plamu(ji,jj) = zfact * (          REAL( mig0_oldcmp(ji)-1 , wp )  )
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         !                       ! longitude   (west coast at lon=0°)
+         plamt(ji,jj) = zfact * (  - 0.5 + REAL( mig0(ji)-1 , wp )  )  
+         plamu(ji,jj) = zfact * (          REAL( mig0(ji)-1 , wp )  )
          plamv(ji,jj) = plamt(ji,jj)
          plamf(ji,jj) = plamu(ji,jj)
-         !                       ! latitude
-         pphit(ji,jj) = zfact * (  - 0.5 + REAL( mjg0_oldcmp(jj)-1 , wp )  )
+         !                       ! latitude   (south coast at lat= 0°)
+         pphit(ji,jj) = zfact * (  - 0.5 + REAL( mjg0(jj)-1 , wp )  )
          pphiu(ji,jj) = pphit(ji,jj)
-         pphiv(ji,jj) = zfact * (          REAL( mjg0_oldcmp(jj)-1 , wp )  )
+         pphiv(ji,jj) = zfact * (          REAL( mjg0(jj)-1 , wp )  )
          pphif(ji,jj) = pphiv(ji,jj)
       END_2D
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -37,5 +37,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -49,8 +49,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -73,5 +75,6 @@
       kpk = INT(  20.  / rn_dz ) + 1
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! LOCK_EXCHANGE configuration : closed domain
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! LOCK_EXCHANGE configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -88,6 +91,4 @@
          WRITE(numout,*) '                                               jpkglo = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      closed                                   jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -84,7 +84,7 @@
       !
       ! no ocean cavities : top ocean level is ONE, except over land
-      ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0 
+      ! the ocean basin surrounded by land (1+nn_hls grid-points) set through lbc_lnk call
       z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin, see userdef_nam.F90
       k_top(:,:) = NINT( z2d(:,:) )
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_qco key_iomput key_mpp_mpi 
+ bld::tool::fppkeys   key_qco key_xios 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/1_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/1_namelist_cfg	(revision 14644)
@@ -11,5 +11,5 @@
    ln_sco      = .false.      ! s-coordinate   
    rn_dx       =   1000.   !  horizontal resolution   [meters]
-   rn_dz       =     20.   !  vertical   resolution   [meters]
+   rn_dz       =     50.   !  vertical   resolution   [meters]
 /
 !
@@ -26,5 +26,5 @@
    cn_exp      =    "OVF"  !  experience name
    nn_it000    =       1   !  first time step
-   nn_itend    =    2040   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
+   nn_itend    =    1530   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
    nn_istate   =       0   !  output the initial state (1) or not (0)
    nn_stock    =    9999   !  frequency of creation of a restart file (modulo referenced to 1)
@@ -42,5 +42,5 @@
 &namdom        !   space and time domain (bathymetry, mesh, timestep)
 !-----------------------------------------------------------------------
-   rn_Dt      =   10.     !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_Dt      =   40.     !  time step for the dynamics (and tracer if nn_acc=0)
    rn_atfp    =    0.1    !  asselin time filter parameter
    ln_meshmask = .false.  !  =T create a mesh file
@@ -150,5 +150,4 @@
    ln_dynvor_mix = .false. !  mixed scheme
    ln_dynvor_een = .false. !  energy & enstrophy scheme
-      nn_een_e3f = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -227,5 +226,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    jpni        =  12       !  number of processors following i (set automatically if < 1), see also ln_listonly = T
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/AGRIF_FixedGrids.in
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/AGRIF_FixedGrids.in	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/AGRIF_FixedGrids.in	(revision 14644)
@@ -1,3 +1,3 @@
 1
-10 41 1 4 4 1 4 
+10 41 1 4 1 1 1 
 0
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/README.txt
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/README.txt	(revision 14643)
+++ 	(revision )
@@ -1,14 +1,0 @@
-! Overflow test case with an embedded zoom
-! J. Chanut December 2020
-!
-! ** Compilation: ./makenemo -a OVERFLOW add_key "key_agrif"
-! ** Files contained in that directory override the ones in EXPREF
-! ** OVF_domcfg.nc and 1_OVF_domcfg.nc files containing parent and child domain
-!    definitions are needed. These need to be suitably matched !
-! ** The zoom, as defined in the shipped in AGRIF_FixedGrids.in file, has an
-!    horizontal and temporal refinement of 4 in the x direction only and a vertical
-!    refinement of 2 (both parent and child have geopotential vertical grids).
-!    Have a look at the figure "Overflow_agrif.png".
-! ** Warning: The domain has only 5 points in the y directio and automatic
-!    definition of mpp layout (i.e. jpni=jpnj=0) fails in that case. One has
-!    to manually define jpni=your_number_of_process and jpnj=1.
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/AGRIF/namelist_cfg	(revision 14644)
@@ -11,5 +11,5 @@
    ln_sco      = .false.      ! s-coordinate   
    rn_dx       =   1000.   !  horizontal resolution   [meters]
-   rn_dz       =     20.   !  vertical   resolution   [meters]
+   rn_dz       =     50.   !  vertical   resolution   [meters]
 /
 !
@@ -20,5 +20,5 @@
    cn_exp      =    "OVF"  !  experience name
    nn_it000    =       1   !  first time step
-   nn_itend    =    2040   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
+   nn_itend    =    1530   ! here 16h of simulation  (=5760 time-step) abort after 5802 for zps: pb of physics conditions
    nn_istate   =       0   !  output the initial state (1) or not (0)
    nn_stock    =    9999   !  frequency of creation of a restart file (modulo referenced to 1)
@@ -144,5 +144,4 @@
    ln_dynvor_mix = .false. !  mixed scheme
    ln_dynvor_een = .false. !  energy & enstrophy scheme
-      nn_een_e3f = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -221,5 +220,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
    jpni        =  12       !  number of processors following i (set automatically if < 1), see also ln_listonly = T
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_cen-ahm1000_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_cen-ahm1000_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_cen-ahm1000_cfg	(revision 14644)
@@ -213,5 +213,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_ubs_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT2_flux_ubs_cfg	(revision 14644)
@@ -213,5 +213,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_cen-ahm1000_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_cen-ahm1000_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_cen-ahm1000_cfg	(revision 14644)
@@ -213,5 +213,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_ubs_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_sco_FCT4_flux_ubs_cfg	(revision 14644)
@@ -213,5 +213,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT2_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT2_flux_ubs_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT2_flux_ubs_cfg	(revision 14644)
@@ -214,5 +214,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_flux_ubs_cfg	(revision 14644)
@@ -307,5 +307,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -313,5 +313,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_vect_een_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_vect_een_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/EXPREF/namelist_zps_FCT4_vect_een_cfg	(revision 14644)
@@ -213,5 +213,5 @@
 /
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -74,14 +74,14 @@
       !                       !==  grid point position  ==!   (in kilometers)
       zfact = rn_dx * 1.e-3         ! conversion in km
-      DO_2D( 1, 1, 1, 1 )
-         !                       ! longitude
-         plamt(ji,jj) = zfact * (  - 0.5 + REAL( mig0_oldcmp(ji)-1 , wp )  )  
-         plamu(ji,jj) = zfact * (          REAL( mig0_oldcmp(ji)-1 , wp )  )
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         !                       ! longitude   (west coast at lon=0°)
+         plamt(ji,jj) = zfact * (  - 0.5 + REAL( mig0(ji)-1 , wp )  )  
+         plamu(ji,jj) = zfact * (          REAL( mig0(ji)-1 , wp )  )
          plamv(ji,jj) = plamt(ji,jj)
          plamf(ji,jj) = plamu(ji,jj)
-         !                       ! latitude
-         pphit(ji,jj) = zfact * (  - 0.5 + REAL( mjg0_oldcmp(jj)-1 , wp )  )
+         !                       ! latitude   (south coast at lat= 0°)
+         pphit(ji,jj) = zfact * (  - 0.5 + REAL( mjg0(jj)-1 , wp )  )
          pphiu(ji,jj) = pphit(ji,jj)
-         pphiv(ji,jj) = zfact * (          REAL( mjg0_oldcmp(jj)-1 , wp )  )
+         pphiv(ji,jj) = zfact * (          REAL( mjg0(jj)-1 , wp )  )
          pphif(ji,jj) = pphiv(ji,jj)
       END_2D
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -38,5 +38,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -50,8 +50,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -88,11 +90,9 @@
       WRITE(numout,*) '                                               Nj0glo = ', kpj
       WRITE(numout,*) '                                               jpkglo = ', kpk
+      WRITE(numout,*) '   '
       !
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! OVERFLOW configuration : close basin
-      !
-      WRITE(numout,*) '   '
-      WRITE(numout,*) '   Lateral boundary condition of the global domain'
-      WRITE(numout,*) '      OVERFLOW : closed basin                  jperio = ', kperio
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! OVERFLOW configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
    END SUBROUTINE usr_def_nam
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -110,7 +110,7 @@
       !
       ! no ocean cavities : top ocean level is ONE, except over land
-      ! the ocean basin surrounded by land (1 grid-point) set through lbc_lnk call as jperio=0 
+      ! the ocean basin surrounded by land (1+nn_hls grid-points) set through lbc_lnk call
       z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin, see userdef_nam.F90
       k_top(:,:) = NINT( z2d(:,:) )
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/cpp_OVERFLOW.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/cpp_OVERFLOW.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/cpp_OVERFLOW.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_qco key_mpp_mpi key_iomput 
+bld::tool::fppkeys   key_qco key_xios 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/README.rst
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/README.rst	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/README.rst	(revision 14644)
@@ -206,6 +206,57 @@
    :labelprefix: T
 
+ICE_RHEO
+--------
+| 
+
+BENCH
+-----
+| Benchmark configuration. Allow to run any configuration (including ORCA type or BDY) with idealized grid
+  and initial state so it does not need any input file other than the namelists.
+  As usual, all configuration changes can be done through the namelist. 
+  We provide 3 example of namelist_cfg to mimic ORCA1, OR025 or ORCA12 configurations.
+  By default do not produce any output file. An extensive description of BENCH will be abailable in 
+  Irrmann et al. 2021.
+
 CPL_OASIS
 ---------
 | This test case checks the OASIS interface in OCE/SBC, allowing to set up 
-a coupled configuration through OASIS. See CPL_OASIS/README.md for more information.
+  a coupled configuration through OASIS. See CPL_OASIS/README.md for more information.
+
+TSUNAMI
+---------
+| just use dynspg_ts to simulate the propagation of an ssh anomaly (cosinus) in a box configuration
+  with flat bottom and jpk=2.
+
+DONUT
+-----
+| Donut shaped configuration to test MPI decomposition with bdy.
+
+C1D_ASICS
+---------
+| 
+
+DOME
+----
+| 
+
+ICB
+----
+| ICB is a very idealized configuration used to test and debug the icb module.
+  The configuration is box with a shallow shelf (40m) on the east and west part of the domain 
+  with a deep central trough (> 100m).
+  ICB are generating using the test capability of the icb model along a E-W line (this can easily be tuned).
+
+STATION_ASF
+-----------
+| this demonstration test case can be used to perform a sanity test of the SBCBLK interface of
+  NEMO.  It will test all the bulk-parameterization algorithms using an idealized
+  forcing that includes a wide range of *SSX / surface atmospheric state*
+  conditions to detect potential error / inconsistencies.  Both a short report and
+  boolean output: *passed* or *failed* is provided as an output.
+
+SWG
+---
+| Square bassin blown with an analytical wind. Vertical structure allows only one mode
+  associated with reduced gravity to develop. This configuration is based on Adcroft & Marshall 1998.
+  Also run with RK3 time stepping. 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-an05_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-an05_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-an05_cfg	(revision 14644)
@@ -265,5 +265,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -271,5 +271,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-cstc_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-cstc_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-cstc_cfg	(revision 14644)
@@ -265,5 +265,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -271,5 +271,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-lg15_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-lg15_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-lg15_cfg	(revision 14644)
@@ -265,5 +265,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -271,5 +271,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-lu12_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-lu12_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce+ice/namelist_ecmwf-lu12_cfg	(revision 14644)
@@ -265,5 +265,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -271,5 +271,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_andreas_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_andreas_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_andreas_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_coare3p6_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_coare3p6_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_coare3p6_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_ecmwf_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_ecmwf_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_ecmwf_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_ncar_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_ncar_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/ERA5/oce/namelist_ncar_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_andreas_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_andreas_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_andreas_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_coare3p6_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_coare3p6_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_coare3p6_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_ecmwf_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_ecmwf_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_ecmwf_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_ncar_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_ncar_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/EXPREF/PAPA/oce/namelist_ncar_cfg	(revision 14644)
@@ -251,5 +251,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -257,5 +257,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/diawri.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/diawri.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/diawri.F90	(revision 14644)
@@ -63,7 +63,7 @@
 CONTAINS
 
-#if defined key_iomput
-   !!----------------------------------------------------------------------
-   !!   'key_iomput'                                        use IOM library
+#if defined key_xios
+   !!----------------------------------------------------------------------
+   !!   'key_xios'                                        use IOM library
    !!----------------------------------------------------------------------
    INTEGER FUNCTION dia_wri_alloc()
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/icesbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/icesbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/icesbc.F90	(revision 14644)
@@ -91,5 +91,5 @@
          vtau_ice(ji,jj) = vtau_ice(ji,jj) * xcplmask(ji,jj,0) + zvtau_ice(ji,jj) * ( 1. - xcplmask(ji,jj,0) )
          END_2D
-         CALL lbc_lnk_multi( 'icesbc', utau_ice, 'U', -1.0_wp, vtau_ice, 'V', -1.0_wp )
+         CALL lbc_lnk( 'icesbc', utau_ice, 'U', -1.0_wp, vtau_ice, 'V', -1.0_wp )
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/nemogcm.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/nemogcm.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/nemogcm.F90	(revision 14644)
@@ -34,5 +34,5 @@
    USE mppini         ! shared/distributed memory setting (mpp_init routine)
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-#if defined key_iomput
+#if defined key_xios
    USE xios           ! xIOserver
 #endif
@@ -46,5 +46,5 @@
    CHARACTER(lc) ::   cform_aaa="( /, 'AAAAAAAA', / ) "     ! flag for output listing
 
-#if defined key_mpp_mpi
+#if ! defined key_mpi_off
    ! need MPI_Wtime
    INCLUDE 'mpif.h'
@@ -113,5 +113,5 @@
       CALL nemo_closefile
       !
-#if defined key_iomput
+#if defined key_xios
       CALL xios_finalize  ! end mpp communications with xios
 #else
@@ -148,5 +148,5 @@
       !                             !-------------------------------------------------!
       !
-#if defined key_iomput
+#if defined key_xios
       IF( Agrif_Root() ) THEN
          CALL xios_initialize( "for_xios_mpi_id", return_comm=ilocal_comm )   ! nemo local communicator given by xios
@@ -243,7 +243,7 @@
       !
       IF( ln_read_cfg ) THEN            ! Read sizes in domain configuration file
-         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL domain_cfg ( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ELSE                              ! user-defined namelist
-         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, jperio )
+         CALL usr_def_nam( cn_cfg, nn_cfg, Ni0glo, Nj0glo, jpkglo, l_Iperio, l_Jperio, l_NFold, c_NFtype )
       ENDIF
       !
@@ -373,5 +373,5 @@
       !!                     ***  ROUTINE nemo_alloc  ***
       !!
-      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !! ** Purpose :   Allocate all the dynamic arrays of the OCE modules
       !!
       !! ** Method  :
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/step_c1d.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/step_c1d.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/step_c1d.F90	(revision 14644)
@@ -36,5 +36,5 @@
       !!
       !! ** Purpose :  - Time stepping of SBC including sea ice (dynamic and thermodynamic eqs.)
-      !!               - Time stepping of OPA (momentum and active tracer eqs.)
+      !!               - Time stepping of OCE (momentum and active tracer eqs.)
       !!               - Time stepping of TOP (passive tracer eqs.)
       !!
@@ -79,5 +79,5 @@
       IF( lrst_oce       )   CALL rst_write( kstp, Nbb, Nnn )  ! write output ocean restart file
       !
-#if defined key_iomput
+#if defined key_xios
       IF( kstp == nitend .OR. nstop > 0 )   CALL xios_context_finalize()   ! needed for XIOS
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/stpctl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/stpctl.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/stpctl.F90	(revision 14644)
@@ -31,6 +31,7 @@
    PUBLIC stp_ctl           ! routine called by step.F90
 
-   INTEGER                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(3)  ::   nvarid   ! netcdf variable id
+   INTEGER, PARAMETER         ::   jpvar = 3
+   INTEGER                    ::   nrunid   ! netcdf file id
+   INTEGER, DIMENSION(jpvar)  ::   nvarid   ! netcdf variable id
    !!----------------------------------------------------------------------
    !! NEMO/SAS 4.0 , NEMO Consortium (2018)
@@ -59,10 +60,12 @@
       INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index
       !!
+      INTEGER, PARAMETER              ::   jptst = 3
       INTEGER                         ::   ji                                    ! dummy loop indices
       INTEGER                         ::   idtime, istatus
-      INTEGER , DIMENSION(4)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,3)        ::   iloc                                  ! min/max loc indices
-      REAL(wp)                        ::   zzz                                   ! local real
-      REAL(wp), DIMENSION(4)          ::   zmax, zmaxlocal
+      INTEGER , DIMENSION(jptst)      ::   iareasum, iareamin, iareamax
+      INTEGER , DIMENSION(3,jptst)    ::   iloc                                  ! min/max loc indices
+      REAL(wp)                        ::   zzz                                   ! local real 
+      REAL(wp), DIMENSION(jpvar+1)    ::   zmax
+      REAL(wp), DIMENSION(jptst)      ::   zmaxlocal
       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
       LOGICAL, DIMENSION(jpi,jpj)     ::   llmsk
@@ -110,8 +113,8 @@
       !                                   !==  done by all processes at every time step  ==!
       !
-      llmsk(   1:Nis1,:) = .FALSE.                                              ! exclude halos from the checked region
-      llmsk(Nie1: jpi,:) = .FALSE.
-      llmsk(:,   1:Njs1) = .FALSE.
-      llmsk(:,Nje1: jpj) = .FALSE.
+      llmsk(     1:nn_hls,:) = .FALSE.                                          ! exclude halos from the checked region
+      llmsk(Nie0+1:   jpi,:) = .FALSE.
+      llmsk(:,     1:nn_hls) = .FALSE.
+      llmsk(:,Nje0+1:   jpj) = .FALSE.
       !
       llmsk(Nis0:Nie0,Njs0:Nje0) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp        ! test only the inner domain
@@ -122,34 +125,33 @@
       zmax(2) = MAXVAL( ABS( qns(:,:) ), mask = llmsk )                         ! max non-solar heat flux
       zmax(3) = MAXVAL( ABS( emp(:,:) ), mask = llmsk )                         ! max E-P
-      zmax(4) = REAL( nstop, wp )                                               ! stop indicator
+      zmax(jpvar+1) = REAL( nstop, wp )                                         ! stop indicator
       !
       !                                   !==               get global extrema             ==!
       !                                   !==  done by all processes if writting run.stat  ==!
       IF( ll_colruns ) THEN
-         zmaxlocal(:) = zmax(:)
-         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
-         nstop = NINT( zmax(4) )                 ! update nstop indicator (now sheared among all local domains)
+         zmaxlocal(:) = zmax(1:jptst)
+         CALL mpp_max( "stpctl", zmax )          ! max over the global domain: ok even of ll_0oce = .true.
+         nstop = NINT( zmax(jpvar+1) )           ! update nstop indicator (now sheared among all local domains)
       ELSE
          ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow.
-         IF( ll_0oce )   zmax(1:3) = 0._wp       ! default "valid" values...
-      ENDIF
-      !                                   !==               error handling               ==!
+         IF( ll_0oce )   zmax(1:jptst) = 0._wp        ! default "valid" values...
+      ENDIF
       !                                   !==              write "run.stat" files              ==!
       !                                   !==  done only by 1st subdomain at writting timestep  ==!
       IF( ll_wrtruns ) THEN
-         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3)
-         DO ji = 1, 3
+         WRITE(numrun,9500) kt, zmax(1:jptst)
+         DO ji = 1, jpvar
             istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
          END DO
-         IF( kt == nitend ) istatus = NF90_CLOSE(nrunid)
+         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
       END IF
       !                                   !==               error handling               ==!
       !                                   !==  done by all processes at every time step  ==!
       !
-      IF(   zmax(1) >    5._wp .OR.   &                   ! too large wind stress         ( > 5 N/m^2 )
-         &  zmax(2) > 2000._wp .OR.   &                   ! too large non-solar heat flux ( > 2000 W/m^2 )
-         &  zmax(3) > 1.E-3_wp .OR.   &                   ! too large net freshwater flux ( > 1.E-3 kg/m^2/s )
-         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests
-         &  ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
+      IF(   zmax(1) >    5._wp .OR.   &                       ! too large wind stress         ( > 5 N/m^2 )
+         &  zmax(2) > 2000._wp .OR.   &                       ! too large non-solar heat flux ( > 2000 W/m^2 )
+         &  zmax(3) > 1.E-3_wp .OR.   &                       ! too large net freshwater flux ( > 1.E-3 kg/m^2/s )
+         & ISNAN( SUM(zmax(1:jptst)) ) .OR.   &               ! NaN encounter in the tests
+         & ABS(   SUM(zmax(1:jptst)) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
          !
          iloc(:,:) = 0
@@ -163,5 +165,5 @@
             ! find which subdomain has the max.
             iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 4
+            DO ji = 1, jptst
                IF( zmaxlocal(ji) == zmax(ji) ) THEN
                   iareamin(ji) = narea   ;   iareamax(ji) = narea   ;   iareasum(ji) = 1
@@ -176,5 +178,5 @@
             iloc(1:2,2) = MAXLOC( ABS( qns(:,:) ), mask = llmsk )
             iloc(1:2,3) = MINLOC( ABS( emp(:,:) ), mask = llmsk )
-            DO ji = 1, 3   ! local domain indices ==> global domain indices, excluding halos
+            DO ji = 1, jptst   ! local domain indices ==> global domain indices, excluding halos
                iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /)
             END DO
@@ -195,8 +197,6 @@
          !
          IF( ll_colruns .OR. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files
-            IF(lwp) THEN
-               CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 )
-            ELSE
-               nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
+            IF(lwp) THEN   ;   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 )
+            ELSE           ;   nstop = MAX(1, nstop)   ! make sure nstop > 0 (automatically done when calling ctl_stop)
             ENDIF
          ELSE                                    ! only mpi subdomains with errors are here -> STOP now
@@ -239,9 +239,9 @@
 
       WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpnij  ,wp))) + 1     ! how many digits to we need to write ? (we decide max = 9)
-!!! WRITE(clsum, '(i'//clfmt//')') ksum                   ! this is creating a compilation error with AGRIF
+      !!! WRITE(clsum, '(i'//clfmt//')') ksum                   ! this is creating a compilation error with AGRIF
       cl4 = '(i'//clfmt//')'   ;   WRITE(clsum, cl4) ksum
       WRITE(clfmt, '(i1)') INT(LOG10(REAL(MAX(1,jpnij-1),wp))) + 1    ! how many digits to we need to write ? (we decide max = 9)
       cl4 = '(i'//clfmt//')'   ;   WRITE(clmin, cl4) kmin-1
-      WRITE(clmax, cl4) kmax-1
+                                   WRITE(clmax, cl4) kmax-1
       !
       WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpiglo,wp))) + 1      ! how many digits to we need to write jpiglo? (we decide max = 9)
@@ -259,5 +259,5 @@
       ELSE
          WRITE(clfmt, '(i1)') INT(LOG10(REAL(jpk,wp))) + 1      ! how many digits to we need to write jpk? (we decide max = 9)
-!!! WRITE(clk, '(i'//clfmt//')') kloc(3)               ! this is creating a compilation error with AGRIF
+         !!! WRITE(clk, '(i'//clfmt//')') kloc(3)               ! this is creating a compilation error with AGRIF
          cl4 = '(i'//clfmt//')'   ;   WRITE(clk, cl4) kloc(3)   ! this is ok with AGRIF
          WRITE(cdline,9400) TRIM(ADJUSTL(clkt)), TRIM(ADJUSTL(cdprefix)), pval, TRIM(cli), TRIM(clj),    TRIM(clk), TRIM(clsuff)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -37,5 +37,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -49,8 +49,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER         , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER         , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes
-      INTEGER         , INTENT(out) ::   kperio          ! lateral global domain b.c.
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -73,5 +75,6 @@
       !
       !                             ! Set the lateral boundary condition of the global domain
-      kperio =  7                   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
+      ldIperio = .TRUE.    ;   ldJperio = .true.   ! C1D configuration : 3x3 basin with cyclic Est-West and Norht-South condition
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
       !                             ! control print
@@ -85,5 +88,4 @@
          WRITE(numout,*) '      number of model levels                              kpk = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral b.c. of the domain set to       jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_andreas_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_andreas_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_andreas_cfg	(revision 14644)
@@ -256,5 +256,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -262,5 +262,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_coare3p0_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_coare3p0_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_coare3p0_cfg	(revision 14644)
@@ -256,5 +256,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -262,5 +262,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_coare3p6_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_coare3p6_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_coare3p6_cfg	(revision 14644)
@@ -256,5 +256,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -262,5 +262,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_ecmwf_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_ecmwf_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_ecmwf_cfg	(revision 14644)
@@ -256,5 +256,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -262,5 +262,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_ncar_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_ncar_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/SANITY_CHECK/IDEALIZED/oce/namelist_ncar_cfg	(revision 14644)
@@ -256,5 +256,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -262,5 +262,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/cpp_STATION_ASF.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/cpp_STATION_ASF.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/cpp_STATION_ASF.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_si3 key_c1d key_qco key_iomput key_mpp_mpi
+ bld::tool::fppkeys   key_si3 key_c1d key_qco key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/EXPREF/namelist_cfg	(revision 14644)
@@ -224,5 +224,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -231,5 +231,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -57,5 +57,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -69,8 +69,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER         , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER         , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER         , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER  ::   ios             ! Local integer
@@ -110,5 +112,6 @@
       kpk = jpkglo
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! SWG configuration : closed domain
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! SWG configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       !
 # if defined key_bvp
@@ -131,5 +134,4 @@
          WRITE(numout,*) '      number of model levels                              jpkglo = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral b.c. of the global domain set to closed        jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_sbc.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -104,5 +104,5 @@
       END DO
       
-      CALL lbc_lnk_multi( 'usrdef_sbc', taum(:,:), 'T', 1. , wndm(:,:), 'T', 1. )
+      CALL lbc_lnk( 'usrdef_sbc', taum(:,:), 'T', 1. , wndm(:,:), 'T', 1. )
       !
    END SUBROUTINE usrdef_sbc_oce
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -190,7 +190,6 @@
       z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
       !
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
-      !
-      ! 
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (closed boundaries)
+      !
       zylim0 =   10000._wp    ! +10km 
       zylim1 = 2010000._wp    ! 2010km
@@ -215,5 +214,5 @@
       END DO
       ! mask the lonely corners
-      DO jj = 2, jpim1
+      DO jj = 2, jpjm1
          DO ji = 2, jpim1
          zcoeff = k_top(ji+1,jj) + k_top(ji,jj+1)   &
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/cpp_SWG.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/cpp_SWG.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/cpp_SWG.fcm	(revision 14644)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys  key_mpp_mpi key_iomput key_qco key_RK3
+bld::tool::fppkeys key_xios key_qco key_RK3
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/axis_def_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/axis_def_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/axis_def_nemo.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/axis_def_nemo.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/context_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/context_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/context_nemo.xml	(revision 14644)
@@ -0,0 +1,37 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+    <!-- $id$ -->
+    <variable_definition>
+       <!-- Year/Month/Day of time origin for NetCDF files; defaults to 1800-01-01 -->
+       <variable id="ref_year"  type="int"> 1900 </variable>
+       <variable id="ref_month" type="int"> 01 </variable>
+       <variable id="ref_day"   type="int"> 01 </variable>
+       <variable id="rho0"      type="float" > 1026.0 </variable>
+       <variable id="cpocean"   type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu"  type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"     type="float" > 917.0 </variable>
+       <variable id="rhosn"     type="float" > 330.0 </variable>
+       <variable id="missval"  type="float" > 1.e20 </variable>	       
+    </variable_definition>
+
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-oce.xml"/>   <!--  NEMO ocean dynamics                     -->
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo-oce.xml"/>     <!--  NEMO ocean dynamics                     -->
+
+<!-- Axis definition -->
+    <axis_definition src="./axis_def_nemo.xml"/>
+ 
+<!-- Domain definition -->
+    <domain_definition src="./domain_def_nemo.xml"/>
+
+<!-- Grids definition -->
+    <grid_definition   src="./grid_def_nemo.xml"/>
+  
+
+</context>
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/domain_def_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/domain_def_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/domain_def_nemo.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/domain_def_nemo.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/field_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/field_def_nemo-oce.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/field_def_nemo-oce.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/field_def_nemo-oce.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/file_def_nemo-oce.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/file_def_nemo-oce.xml	(revision 14644)
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition type="one_file" name="@expname@" sync_freq="10d" min_digits="4">
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE." >  <!-- 5d files -->  
+ 
+	<file id="file1" >
+	  <field field_ref="baro_u" />
+	  <field field_ref="baro_v" />
+	  <field field_ref="ssh"    />
+	</file>
+
+      </file_group>
+
+   </file_definition>
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/grid_def_nemo.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/grid_def_nemo.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/grid_def_nemo.xml	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/grid_def_nemo.xml
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/iodef.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/iodef.xml	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/iodef.xml	(revision 14644)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<simulation>
+
+<!-- ============================================================================================ -->
+<!-- XIOS context                                                                                 -->
+<!-- ============================================================================================ -->
+
+  <context id="xios" >
+
+      <variable_definition>
+
+          <variable id="info_level"                type="int">10</variable>
+          <variable id="using_server"              type="bool">false</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>
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/namelist_cfg	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/namelist_cfg	(revision 14644)
@@ -0,0 +1,199 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO Configuration namelist : overwrite some defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!!                          CANAL configuration                       !!
+!!======================================================================
+!!              ***  Domain & Run management namelists  ***           !!
+!!                                                                    !!
+!!   namrun       parameters of the run
+!!   namdom       space and time domain
+!!   namcfg       parameters of the configuration                       (default: user defined GYRE)
+!!   namwad       Wetting and drying                                    (default: OFF)
+!!   namtsd       data: temperature & salinity                          (default: OFF)
+!!   namcrs       coarsened grid (for outputs and/or TOP)               (ln_crs =T)
+!!   namc1d       1D configuration optgions                              ("key_c1d")
+!!   namc1d_dyndmp 1D newtonian damping applied on currents             ("key_c1d")
+!!   namc1d_uvd   1D data (currents)                                    ("key_c1d")
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namusr_def    !   User defined :   CANAL configuration: Flat bottom, beta-plane
+!-----------------------------------------------------------------------
+   rn_domszx   =   2000.   !  x horizontal size         [km]
+   rn_domszy   =   2000.   !  y horizontal size         [km]
+   rn_domszz   =    100.   !  z vertical size            [m]
+   rn_dx       =     10.   !  x horizontal resolution   [km]
+   rn_dy       =     10.   !  y horizontal resolution   [km]
+   rn_0xratio  =      0.2  !  x-domain ratio of the 0
+   rn_0yratio  =      0.4  !  y-domain ratio of the 0
+   nn_fcase    =      0    !  Coriolis frequency(f) computation (0:f0, 1:Beta plan, 2:real)
+   rn_ppgphi0  =    38.5   !  Reference latitude      [degrees]
+   ln_Iperio  =   .true.   ! i-periodicity
+   ln_Jperio  =   .true.   ! j-periodicity
+/
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   nn_no       =       0   !  job number (no more used...)
+   cn_exp      = 'TSUNAMI' !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =     100   !  last time step 
+   nn_stock    =      -1   !  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =      -1   !  frequency of write in the output file   (modulo referenced to nn_it000)
+/
+!-----------------------------------------------------------------------
+&namdom        !   time and space domain
+!-----------------------------------------------------------------------
+   ln_linssh   =  .false.  !  =T  linear free surface  ==>>  model level are fixed in time
+   rn_Dt      =     1000.  !  time step for the dynamics (and tracer if nn_acc=0)
+   ln_meshmask =  .false.  !  =T create a mesh file
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***          !!
+!!                                                                    !!
+!!   namsbc          surface boundary condition manager                 (default: NO selection)
+!!   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                         (SAS_SRC  only)
+!!   namsbc_iif      Ice-IF: use observed ice cover                     (nn_ice = 1   )
+!!   namtra_qsr      penetrative solar radiation                        (ln_traqsr  =T)
+!!   namsbc_ssr      sea surface restoring term (for T and/or S)        (ln_ssr     =T)
+!!   namsbc_rnf      river runoffs                                      (ln_rnf     =T)
+!!   namsbc_apr      Atmospheric Pressure                               (ln_apr_dyn =T)
+!!   namsbc_isf      ice shelf melting/freezing                         (ln_isfcav  =T : read (ln_read_cfg=T) or set or usr_def_zgr )
+!!   namsbc_iscpl    coupling option between land ice model and ocean   (ln_isfcav  =T)
+!!   namsbc_wave     external fields from wave model                    (ln_wave    =T)
+!!   namberg         iceberg floats                                     (ln_icebergs=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition manager                   (default: NO selection)
+!-----------------------------------------------------------------------
+  nn_fsbc     = 1         !  frequency of surface boundary condition computation
+  ln_usr      = .true.    !  user defined formulation                  (T => check usrdef_sbc)
+/
+!!======================================================================
+!!               ***  Lateral boundary condition  ***                 !!
+!!                                                                    !!
+!!   namlbc        lateral momentum boundary condition                  (default: NO selection)
+!!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
+!!   nam_tide      Tidal forcing                                        (default: OFF)
+!!   nambdy        Unstructured open boundaries                         (default: OFF)
+!!   nambdy_dta    Unstructured open boundaries - external data         (see  nambdy)
+!!   nambdy_tide   tidal forcing at open boundaries                     (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition                  (default: NO selection)
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  free slip
+/
+!!======================================================================
+!!                ***  Top/Bottom boundary condition  ***             !!
+!!                                                                    !!
+!!   namdrg        top/bottom drag coefficient                          (default: NO selection)
+!!   namdrg_top    top    friction                                      (ln_drg_OFF =F & ln_isfcav=T)
+!!   namdrg_bot    bottom friction                                      (ln_drg_OFF =F)
+!!   nambbc        bottom temperature boundary condition                (default: OFF)
+!!   nambbl        bottom boundary layer scheme                         (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdrg        !   top/bottom drag coefficient                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_drg_OFF = .true.    !  free-slip       : Cd = 0                  (F => fill namdrg_bot
+/
+!!======================================================================
+!!                        Tracer (T & S) namelists                    !!
+!!                                                                    !!
+!!   nameos        equation of state                                    (default: NO selection)
+!!   namtra_adv    advection scheme                                     (default: NO selection)
+!!   namtra_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namtra_mle    mixed layer eddy param. (Fox-Kemper param.)          (default: OFF)
+!!   namtra_eiv    eddy induced velocity param.                         (default: OFF)
+!!   namtra_dmp    T & S newtonian damping                              (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean Equation Of Seawater                           (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_seos     = .true.         !  = Use simplified equation of state (S-EOS)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traadv_OFF = .true.    !  No tracer advection
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traldf_OFF = .true.    !  No explicit diffusion
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***                  !!
+!!                                                                    !!
+!!   nam_vvl       vertical coordinate options                          (default: z-star)
+!!   namdyn_adv    formulation of the momentum advection                (default: NO selection)
+!!   namdyn_vor    advection scheme                                     (default: NO selection)
+!!   namdyn_hpg    hydrostatic pressure gradient                        (default: NO selection)
+!!   namdyn_spg    surface pressure gradient                            (default: NO selection)
+!!   namdyn_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namdta_dyn    offline TOP: dynamics read in files                  (OFF_SRC only)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynadv_OFF = .true. !  linear dynamics (no momentum advection)
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynvor_eeT = .true. !  energy conserving scheme (een using e3t)
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO selection)
+!-----------------------------------------------------------------------
+   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_e sub-steps
+         !                          !                     = 2 Boxcar over 2*nn_e  "    "
+      ln_bt_auto    = .true.    ! Number of sub-step defined from:
+         nn_e      =  24         ! =F : the number of sub-step in rn_Dt seconds
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO selection)
+!-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   ln_dynldf_OFF =  .true.    !  No operator (i.e. no explicit diffusion)
+/
+!!======================================================================
+!!                     vertical physics namelists                     !!
+!!                                                                    !!
+!!    namzdf        vertical physics manager                            (default: NO selection)
+!!    namzdf_ric    richardson number vertical mixing                   (ln_zdfric=T)
+!!    namzdf_tke    TKE vertical mixing                                 (ln_zdftke=T)
+!!    namzdf_gls    GLS vertical mixing                                 (ln_zdfgls=T)
+!!    namzdf_osm    OSM vertical diffusion                              (ln_zdfosm=T)
+!!    namzdf_iwm    tidal mixing parameterization                       (ln_zdfiwm=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics                                     (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zdfcst   = .true.       !  constant mixing
+/
+
+!-----------------------------------------------------------------------
+&namctl        !   Control prints                                       (default: OFF)
+!-----------------------------------------------------------------------
+   ln_timing   = .true.   !  timing by routine write out in timing.output file
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/namelist_ref
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/namelist_ref	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/EXPREF/namelist_ref	(revision 14644)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/stpmlf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/stpmlf.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/stpmlf.F90	(revision 14644)
@@ -0,0 +1,209 @@
+MODULE stpmlf
+   !!======================================================================
+   !!                       ***  MODULE stpMLF  ***
+   !! Time-stepping   : manager of the ocean, tracer and ice time stepping
+   !!                   using Modified Leap Frog for OCE
+   !!                   TSUNAMI version: call only dynspg_ts
+   !!======================================================================
+   !! 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 (remove filtered free surface)
+   !!            4.0  !  2017-05  (G. Madec)  introduction of the vertical physics manager (zdfphy)
+   !!            4.1  !  2019-08  (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme
+   !!            4.x  !  2020-08  (S. Techene, G. Madec)  quasi eulerian coordinate time stepping
+   !!----------------------------------------------------------------------
+#if defined key_qco   ||   defined key_linssh
+   !!----------------------------------------------------------------------
+   !!   'key_qco'                        Quasi-Eulerian vertical coordinate
+   !!                          OR
+   !!   'key_linssh                       Fixed in time vertical coordinate
+   !!----------------------------------------------------------------------
+   !!
+   !!----------------------------------------------------------------------
+   !!   stp_MLF       : NEMO modified Leap Frog time-stepping with qco or linssh
+   !!----------------------------------------------------------------------
+   USE step_oce       ! time stepping definition modules
+   !
+   USE domqco         ! quasi-eulerian coordinate
+   USE traatf_qco     ! time filtering                 (tra_atf_qco routine)
+   USE dynatf_qco     ! time filtering                 (dyn_atf_qco routine)
+   
+   USE bdydyn         ! ocean open boundary conditions (define bdy_dyn)
+
+#if defined key_agrif
+   USE agrif_oce_interp
+#endif
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   stp_MLF   ! called by nemogcm.F90
+
+   !                                          !**  time level indices  **!
+   INTEGER, PUBLIC ::   Nbb, Nnn, Naa, Nrhs   !: used by nemo_init
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: step.F90 12377 2020-02-12 14:39:06Z acc $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+#if defined key_agrif
+   RECURSIVE SUBROUTINE stp_MLF( )
+      INTEGER             ::   kstp   ! ocean time-step index
+#else
+   SUBROUTINE stp_MLF( kstp )
+      INTEGER, INTENT(in) ::   kstp   ! ocean time-step index
+#endif
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE stp_MLF  ***
+      !!
+      !! ** Purpose : - Time stepping of OCE  (momentum and active tracer eqs.)
+      !!
+      !! ** Method  : - call dynspg_ts
+      !!----------------------------------------------------------------------
+#if defined key_agrif
+      IF( nstop > 0 ) RETURN   ! avoid to go further if an error was detected during previous time step (child grid)
+      kstp = nit000 + Agrif_Nb_Step()
+      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
+      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_xios
+      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
+# endif
+#endif
+      !
+      IF( ln_timing )   CALL timing_start('stp_MLF')
+      !
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! model timestep
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      IF( l_1st_euler ) THEN     ! start or restart with Euler 1st time-step
+         rDt   = rn_Dt   
+         r1_Dt = 1._wp / rDt
+      ENDIF
+      !
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! update I/O and calendar
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS)
+                         CALL iom_init( cxios_context, ld_closedef=.FALSE. )   ! for model grid (including possible AGRIF zoom)
+                         CALL iom_init_closedef
+                         ts  (:,:,:,:,Naa) = ts (:,:,:,:,Nnn)                  ! needed for stpctl
+      ELSE
+                         CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)    
+      ENDIF
+                         CALL iom_setkt( kstp - nit000 + 1, cxios_context )   ! tell IOM we are at time step kstp
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Update external forcing (tides, open boundaries, ice shelf interaction and surface boundary condition (including sea-ice)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL sbc     ( kstp, Nbb, Nnn )              ! Sea Boundary Condition (including sea-ice)
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      !  Ocean dynamics : hdiv, ssh, e3, u, v, w
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( .NOT.lk_linssh ) THEN
+                         CALL dom_qco_r3c( ssh(:,:,Naa), r3t(:,:,Naa), r3u(:,:,Naa), r3v(:,:,Naa)           )   ! "after" ssh/h_0 ratio at t,u,v pts
+         IF( ln_dynspg_exp )   &
+            &            CALL dom_qco_r3c( ssh(:,:,Nnn), r3t(:,:,Nnn), r3u(:,:,Nnn), r3v(:,:,Nnn), r3f(:,:) )   ! spg_exp : needed only for "now" ssh/h_0 ratio at f point
+      ENDIF
+                         uu(:,:,:,Nrhs) = 0._wp            ! set dynamics trends to zero
+                         vv(:,:,:,Nrhs) = 0._wp
+                         CALL dyn_spg( kstp, Nbb, Nnn, Nrhs, uu, vv, ssh, uu_b, vv_b, Naa, 1 )  ! surface pressure gradient
+                         CALL iom_put( "ssh" , ssh(:,:,Nnn) )              ! sea surface height
+      ! Swap time levels
+      Nrhs = Nbb
+      Nbb = Nnn
+      Nnn = Naa
+      Naa = Nrhs
+
+#if defined key_agrif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! AGRIF recursive integration
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs      ! agrif_oce module copies of time level indices
+                         CALL Agrif_Integrate_ChildGrids( stp_MLF )       ! allows to finish all the Child Grids before updating
+
+#endif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Control
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         CALL stp_ctl      ( kstp, Nnn )
+
+#if defined key_agrif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! AGRIF update
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( Agrif_NbStepint() == 0 .AND. nstop == 0 )   &
+         &               CALL Agrif_update_all( )                  ! Update all components
+      ENDIF
+
+#endif
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! File manipulation at the end of the first time step
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( kstp == nit000 ) THEN                          ! 1st time step only
+                                        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
+
+#if defined key_xios
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Finalize contextes if end of simulation or error detected
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( kstp == nitend .OR. nstop > 0 ) THEN
+                      CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
+      ENDIF
+#endif
+      !
+      IF( l_1st_euler ) THEN         ! recover Leap-frog timestep
+         rDt   = 2._wp * rn_Dt
+         r1_Dt = 1._wp / rDt
+         l_1st_euler = .FALSE.
+      ENDIF
+      !
+      IF( ln_timing )   CALL timing_stop('stp_MLF')
+      !
+   END SUBROUTINE stp_MLF
+
+#else
+   !!----------------------------------------------------------------------
+   !!   default option             EMPTY MODULE           qco not activated
+   !!----------------------------------------------------------------------
+#endif
+   
+   !!======================================================================
+END MODULE stpmlf
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_hgr.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -0,0 +1,139 @@
+MODULE usrdef_hgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_hgr  ***
+   !!
+   !!                      ===  TSUNAMI configuration  ===
+   !!
+   !! User defined :   mesh and Coriolis parameter of a user configuration
+   !!======================================================================
+   !! History :  NEMO  ! 2017-11  (J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_hgr    : initialize the horizontal mesh for TSUNAMI configuration
+   !!----------------------------------------------------------------------
+   USE dom_oce         ! ocean space and time domain
+   USE par_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE usrdef_nam, ONLY: rn_dx, rn_dy, rn_0xratio, rn_0yratio, rn_ppgphi0, nn_fcase
+   !                                                  and reference latitude
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! MPP library
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_hgr   ! called by domhgr.F90
+
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_hgr.F90 14223 2020-12-19 10:22:45Z smasson $ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_hgr( plamt , plamu , plamv  , plamf  ,   &   ! geographic position (required)
+      &                    pphit , pphiu , pphiv  , pphif  ,   &   !
+      &                    kff   , pff_f , pff_t  ,            &   ! Coriolis parameter  (if domain not on the sphere)
+      &                    pe1t  , pe1u  , pe1v   , pe1f   ,   &   ! scale factors       (required)
+      &                    pe2t  , pe2u  , pe2v   , pe2f   ,   &   !
+      &                    ke1e2u_v      , pe1e2u , pe1e2v     )   ! u- & v-surfaces (if gridsize reduction is used in strait(s))
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE usr_def_hgr  ***
+      !!
+      !! ** Purpose :   user defined mesh and Coriolis parameter
+      !!
+      !! ** Method  :   set all intent(out) argument to a proper value
+      !!                TSUNAMI configuration : beta-plance with uniform grid spacing (rn_dx)
+      !!
+      !! ** Action  : - define longitude & latitude of t-, u-, v- and f-points (in degrees) 
+      !!              - define coriolis parameter at f-point if the domain in not on the sphere (on beta-plane)
+      !!              - define i- & j-scale factors at t-, u-, v- and f-points (in meters)
+      !!              - define u- & v-surfaces (if gridsize reduction is used in some straits) (in m2)
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   plamt, plamu, plamv, plamf   ! longitude outputs                     [degrees]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pphit, pphiu, pphiv, pphif   ! latitude outputs                      [degrees]
+      INTEGER                 , INTENT(out) ::   kff                          ! =1 Coriolis parameter computed here, =0 otherwise
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pff_f, pff_t                 ! Coriolis factor at f-point                [1/s]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1t, pe1u, pe1v, pe1f       ! i-scale factors                             [m]
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe2t, pe2u, pe2v, pe2f       ! j-scale factors                             [m]
+      INTEGER                 , INTENT(out) ::   ke1e2u_v                     ! =1 u- & v-surfaces computed here, =0 otherwise 
+      REAL(wp), DIMENSION(:,:), INTENT(out) ::   pe1e2u, pe1e2v               ! u- & v-surfaces (if reduction in strait)   [m2]
+      !
+      INTEGER  ::   ji, jj     ! dummy loop indices
+      INTEGER  ::   ii0, ij0   ! dummy loop indices
+      REAL(wp) ::   zbeta, zf0
+      REAL(wp) ::   zti, ztj   ! local scalars
+      !!-------------------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_hgr : TSUNAMI configuration bassin'
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '          Beta-plane with regular grid-spacing'
+      IF(lwp) WRITE(numout,*) '          given by rn_dx and rn_dy' 
+      !
+      !                          
+      ! Position coordinates (in kilometers)
+      !                          ==========
+      ii0 = NINT( REAL(Ni0glo, wp) * rn_0xratio )
+      ij0 = NINT( REAL(Nj0glo, wp) * rn_0yratio )
+
+#if defined key_agrif
+      ! ! let lower left longitude and latitude from parent
+      IF (.NOT.Agrif_root()) THEN
+          to be coded...
+      ENDIF 
+#endif
+         
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )         
+         zti = REAL( mig0(ji)-ii0, wp )   ! =0 at i=ii0 in the global grid without halos
+         ztj = REAL( mjg0(jj)-ij0, wp )   ! =0 at i=ij0 in the global grid without halos
+         
+         plamt(ji,jj) = rn_dx *   zti
+         plamu(ji,jj) = rn_dx * ( zti + 0.5_wp ) 
+         plamv(ji,jj) = plamt(ji,jj) 
+         plamf(ji,jj) = plamu(ji,jj) 
+         
+         pphit(ji,jj) = rn_dy *   ztj
+         pphiv(ji,jj) = rn_dy * ( ztj + 0.5_wp ) 
+         pphiu(ji,jj) = pphit(ji,jj) 
+         pphif(ji,jj) = pphiv(ji,jj) 
+      END_2D
+      !     
+      ! Horizontal scale factors (in meters)
+      !                              ======
+      pe1t(:,:) = rn_dx * 1.e+3  ;   pe2t(:,:) = rn_dy * 1.e+3 
+      pe1u(:,:) = rn_dx * 1.e+3  ;   pe2u(:,:) = rn_dy * 1.e+3
+      pe1v(:,:) = rn_dx * 1.e+3  ;   pe2v(:,:) = rn_dy * 1.e+3
+      pe1f(:,:) = rn_dx * 1.e+3  ;   pe2f(:,:) = rn_dy * 1.e+3 
+
+      !                             ! NO reduction of grid size in some straits 
+      ke1e2u_v = 0                  !    ==>> u_ & v_surfaces will be computed in dom_hgr routine
+      pe1e2u(:,:) = 0._wp           !    CAUTION: set to zero to avoid error with some compilers that
+      pe1e2v(:,:) = 0._wp           !             require an initialization of INTENT(out) arguments
+      !
+      !
+      !                       !==  Coriolis parameter  ==!
+      kff = 1                       !  indicate not to compute Coriolis parameter afterward
+      !
+      SELECT CASE(nn_fcase)
+      CASE(0)
+         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
+         pff_f(:,:) = zf0
+         pff_t(:,:) = zf0
+      CASE(1)
+         zbeta = 2._wp * omega * COS( rad * rn_ppgphi0 ) / ra
+         zf0   = 2._wp * omega * SIN( rad * rn_ppgphi0 )
+         pff_f(:,:) = zf0 + zbeta * pphif(:,:) * 1.e+3
+         pff_t(:,:) = zf0 + zbeta * pphit(:,:) * 1.e+3
+      CASE(2)
+         pff_f(:,:) = 2._wp * omega * SIN( rad * ( rn_ppgphi0 + pphif(:,:)/110. ) )
+         pff_t(:,:) = 2._wp * omega * SIN( rad * ( rn_ppgphi0 + pphit(:,:)/110. ) )
+      END SELECT
+      !
+   END SUBROUTINE usr_def_hgr
+
+   !!======================================================================
+END MODULE usrdef_hgr
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_istate.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_istate.F90	(revision 14644)
@@ -0,0 +1,111 @@
+MODULE usrdef_istate
+   !!======================================================================
+   !!                     ***  MODULE usrdef_istate   ***
+   !!
+   !!                      ===  TSUNAMI configuration  ===
+   !!
+   !! User defined : set the initial state of a user configuration
+   !!======================================================================
+   !! History :  NEMO !
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  usr_def_istate : initial state in Temperature and salinity
+   !!----------------------------------------------------------------------
+   USE par_oce        ! ocean space and time domain
+   USE dom_oce        
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE lbclnk          ! lateral boundary conditions - mpp exchanges
+   !   
+   USE usrdef_nam
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_istate       ! called by istate.F90
+   PUBLIC   usr_def_istate_ssh   ! called by domqco.F90
+
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! 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 )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of the dynamics and tracers
+      !!                Here TSUNAMI configuration 
+      !!
+      !! ** Method  :   Set a gaussian anomaly of pressure and associated
+      !!                geostrophic velocities
+      !!----------------------------------------------------------------------
+      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) ::   z2d   ! 2D workspace
+      REAL(wp) ::   zfact
+      INTEGER  ::   ji, jj, jk
+      INTEGER  ::   igloi, igloj   ! to be removed in the future, see comment bellow
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate : TSUNAMI configuration, analytical definition of initial state'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~   '
+      !
+      pts(:,:,:,jp_tem) = 20._wp
+      pts(:,:,:,jp_sal) = 30._wp
+      pu( :,:,:       ) =  0._wp
+      pv( :,:,:       ) =  0._wp
+      
+   END SUBROUTINE usr_def_istate
+
+
+   SUBROUTINE usr_def_istate_ssh( ptmask, pssh )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate_ssh  ***
+      !! 
+      !! ** Purpose :   Initialization of ssh
+      !!                Here TSUNAMI configuration 
+      !!
+      !! ** Method  :   Set ssh
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   ptmask  ! t-point ocean mask   [m]
+      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height   [m]
+      !
+      INTEGER  ::   ji, jj
+      REAL(wp), DIMENSION(jpi,jpj) ::  zdist
+      REAL(wp)                     ::  zmax
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_istate_ssh : TSUNAMI configuration, analytical definition of initial ssh'
+      !
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         zdist(ji,jj) = SQRT( glamt(ji,jj)**2 + gphit(ji,jj)**2 )
+      END_2D
+      zmax = MAXVAL( zdist ) / 20._wp
+      CALL mpp_max( 'usrdef_istate', zmax )
+
+      pssh(:,:) = 0 
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         IF( zdist(ji,jj) <= zmax )   pssh(ji,jj) = 0.1 * COS( zdist(ji,jj) / zmax * rpi * 0.5_wp )
+      END_2D
+
+      !
+      CALL lbc_lnk('usrdef_istate', pssh, 'T',  1. )            ! apply boundary conditions
+      !
+   END SUBROUTINE usr_def_istate_ssh
+   
+   !!======================================================================
+END MODULE usrdef_istate
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_nam.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -0,0 +1,126 @@
+MODULE usrdef_nam
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_nam  ***
+   !!
+   !!                      ===  TSUNAMI configuration  ===
+   !!
+   !! User defined : set the domain characteristics of a user configuration
+   !!======================================================================
+   !! History :  NEMO ! 2017-10  (J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_nam   : read user defined namelist and set global domain size
+   !!   usr_def_hgr   : initialize the horizontal mesh 
+   !!----------------------------------------------------------------------
+   USE dom_oce
+   USE par_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE timing         ! Timing
+   
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_nam   ! called by nemogcm.F90
+
+   !                              !!* namusr_def namelist *!!
+   REAL(wp)         ::   rn_domszx  = 1800.  ! x horizontal size         [km]
+   REAL(wp)         ::   rn_domszy  = 1800.  ! y horizontal size         [km]
+   REAL(wp), PUBLIC ::   rn_domszz  = 5000.  ! z horizontal size          [m]
+   REAL(wp), PUBLIC ::   rn_dx      =   30.  ! x horizontal resolution   [km]
+   REAL(wp), PUBLIC ::   rn_dy      =   30.  ! y horizontal resolution   [km]
+   REAL(wp), PUBLIC ::   rn_0xratio =    0.5 ! x domain ratio of the 0
+   REAL(wp), PUBLIC ::   rn_0yratio =    0.5 ! x domain ratio of the 0
+   INTEGER , PUBLIC ::   nn_fcase   =    1   ! F computation (0:f0, 1:Beta, 2:real)
+   REAL(wp), PUBLIC ::   rn_ppgphi0 =   38.5 ! reference latitude for beta-plane 
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_nam.F90 13472 2020-09-16 13:05:19Z smasson $ 
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_nam  ***
+      !!                    
+      !! ** Purpose :   read user defined namelist and define the domain size
+      !!
+      !! ** Method  :   read in namusr_def containing all the user specific namelist parameter
+      !!
+      !!                Here TSUNAMI configuration
+      !!
+      !! ** input   : - namusr_def namelist found in namelist_cfg
+      !!----------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
+      !
+      INTEGER ::   ios      ! Local integer
+      LOGICAL ::   ln_Iperio, ln_Jperio
+      !!
+      NAMELIST/namusr_def/  rn_domszx, rn_domszy, rn_domszz, rn_dx, rn_dy, rn_0xratio, rn_0yratio   &
+         &                 , nn_fcase, rn_ppgphi0, ln_Iperio, ln_Jperio
+      !!----------------------------------------------------------------------
+      !
+      READ  ( numnam_cfg, namusr_def, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namusr_def in configuration namelist' )
+      !
+      IF(lwm)   WRITE( numond, namusr_def )
+      !
+#if defined key_agrif 
+      ! Domain parameters are taken from parent:
+      IF( .NOT. Agrif_Root() ) THEN
+         rn_dx = Agrif_Parent(rn_dx)/Agrif_Rhox()
+         rn_dy = Agrif_Parent(rn_dy)/Agrif_Rhoy()
+         rn_ppgphi0 = Agrif_Parent(rn_ppgphi0)
+      ENDIF
+      rn_0xratio = 0.5   ! not really working I guess... 
+      rn_0yratio = 0.5
+#endif
+      !
+      cd_cfg = 'TSUNAMI'             ! name & resolution (not used)
+      kk_cfg = INT( rn_dx )
+      !
+      IF( Agrif_Root() ) THEN        ! Global Domain size:  TSUNAMI global domain is  1800 km x 1800 Km x 5000 m
+         kpi = NINT( rn_domszx / rn_dx ) + 1
+         kpj = NINT( rn_domszy / rn_dy ) + 1
+      ELSE                           ! Global Domain size: add nbghostcells + 1 "land" point on each side
+         kpi  = nbcellsx + nbghostcells_x   + nbghostcells_x   + 2
+         kpj  = nbcellsy + nbghostcells_y_s + nbghostcells_y_n + 2
+      ENDIF
+      kpk = 2
+      !                              ! Set the lateral boundary condition of the global domain
+      !
+      ldIperio = ln_Iperio   ;   ldJperio = ln_Jperio
+      ldNFold  =  .FALSE.    ;   cdNFtype = '-'
+      !
+      !                              ! control print
+      IF(lwp) THEN
+         WRITE(numout,*) '   '
+         WRITE(numout,*) 'usr_def_nam  : read the user defined namelist (namusr_def) in namelist_cfg'
+         WRITE(numout,*) '~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namusr_def : TSUNAMI test case'
+         WRITE(numout,*) '      horizontal domain size-x          rn_domszx  = ', rn_domszx, ' km'
+         WRITE(numout,*) '      horizontal domain size-y          rn_domszy  = ', rn_domszy, ' km'
+         WRITE(numout,*) '      vertical   domain size-z          rn_domszz  = ', rn_domszz, '  m'
+         WRITE(numout,*) '      horizontal x-resolution           rn_dx      = ',     rn_dx, ' km'
+         WRITE(numout,*) '      horizontal y-resolution           rn_dy      = ',     rn_dy, ' km'
+         WRITE(numout,*) '      x-domain ratio of the 0           rn_0xratio = ', rn_0xratio
+         WRITE(numout,*) '      y-domain ratio of the 0           rn_0yratio = ', rn_0yratio
+         WRITE(numout,*) '      F computation                     nn_fcase   = ',   nn_fcase
+         WRITE(numout,*) '      Reference latitude                rn_ppgphi0 = ', rn_ppgphi0
+         WRITE(numout,*) '   '
+      ENDIF
+      !
+   END SUBROUTINE usr_def_nam
+
+   !!======================================================================
+END MODULE usrdef_nam
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_sbc.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_sbc.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_sbc.F90	(revision 14644)
@@ -0,0 +1,88 @@
+MODULE usrdef_sbc
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_sbc  ***
+   !! 
+   !!                      ===  TSUNAMI configuration  ===
+   !!
+   !! User defined :   surface forcing of a user configuration
+   !!======================================================================
+   !! History :  4.0   ! 2017-11  (J.Chanut)  user defined interface
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_sbc    : user defined surface bounday conditions in OVERFLOW 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 icestp.F90 for ice dynamics
+   PUBLIC   usrdef_sbc_ice_flx  ! routine called by icestp.F90 for ice thermo
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_sbc.F90 13472 2020-09-16 13:05:19Z smasson $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE usrdef_sbc_oce( kt, Kbb )
+      !!---------------------------------------------------------------------
+      !!                    ***  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 TSUNAMI 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
+      INTEGER, INTENT(in) ::   Kbb       ! ocean time index
+      !!---------------------------------------------------------------------
+      !      
+      IF( kt == nit000 ) THEN
+         !
+         IF(lwp) WRITE(numout,*)' usr_sbc : TSUNAMI case: surface forcing'
+         IF(lwp) WRITE(numout,*)' ~~~~~~~~~~~   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, phs, phi )
+      INTEGER, INTENT(in) ::   kt   ! ocean time step
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   phs    ! snow thickness
+      REAL(wp), DIMENSION(:,:,:), INTENT(in)  ::   phi    ! ice thickness
+   END SUBROUTINE usrdef_sbc_ice_flx
+
+   !!======================================================================
+END MODULE usrdef_sbc
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_zgr.F90	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -0,0 +1,232 @@
+MODULE usrdef_zgr
+   !!======================================================================
+   !!                       ***  MODULE  usrdef_zgr  ***
+   !!
+   !!                      ===  TSUNAMI configuration  ===
+   !!
+   !! User defined : vertical coordinate system of a user configuration
+   !!======================================================================
+   !! History :  4.0  ! 2017-11  (J. Chanut)  Original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   usr_def_zgr   : user defined vertical coordinate system
+   !!      zgr_z      : reference 1D z-coordinate 
+   !!      zgr_top_bot: ocean top and bottom level indices
+   !!      zgr_zco    : 3D verticl coordinate in pure z-coordinate case
+   !!---------------------------------------------------------------------
+   USE oce            ! ocean variables
+   USE dom_oce        ! ocean domain
+   USE phycst         ! physical constants
+   USE usrdef_nam, ONLY: rn_domszz
+   USE depth_e3       ! depth <=> e3
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! distributed memory computing library
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   usr_def_zgr        ! called by domzgr.F90
+
+   !!----------------------------------------------------------------------
+   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
+   !! $Id: usrdef_zgr.F90 13472 2020-09-16 13:05:19Z smasson $
+   !! Software governed by the CeCILL license (see ./LICENSE)
+   !!----------------------------------------------------------------------
+CONTAINS             
+
+   SUBROUTINE usr_def_zgr( ld_zco  , ld_zps  , ld_sco  , ld_isfcav,    &   ! type of vertical coordinate
+      &                    pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d  ,    &   ! 1D reference vertical coordinate
+      &                    pdept , pdepw ,                             &   ! 3D t & w-points depth
+      &                    pe3t  , pe3u  , pe3v   , pe3f ,             &   ! vertical scale factors
+      &                    pe3w  , pe3uw , pe3vw         ,             &   !     -      -      -
+      &                    k_top  , k_bot    )                             ! top & bottom ocean level
+      !!---------------------------------------------------------------------
+      !!              ***  ROUTINE usr_def_zgr  ***
+      !!
+      !! ** Purpose :   User defined the vertical coordinates
+      !!
+      !!----------------------------------------------------------------------
+      LOGICAL                   , INTENT(out) ::   ld_zco, ld_zps, ld_sco      ! vertical coordinate flags
+      LOGICAL                   , INTENT(out) ::   ld_isfcav                   ! under iceshelf cavity flag
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d           ! 1D grid-point depth     [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pdept, pdepw                ! grid-point depth        [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors  [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(out) ::   pe3w , pe3uw, pe3vw         ! i-scale factors 
+      INTEGER , DIMENSION(:,:)  , INTENT(out) ::   k_top, k_bot                ! first & last ocean level
+      !
+      INTEGER  ::   inum   ! local logical unit
+      REAL(WP) ::   z_zco, z_zps, z_sco, z_cav
+      REAL(wp), DIMENSION(jpi,jpj) ::   z2d   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'usr_def_zgr : TSUNAMI configuration (z-coordinate closed flat box ocean)'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      !
+      !
+      ! type of vertical coordinate
+      ! ---------------------------
+      ld_zco    = .TRUE.         ! TSUNAMI case:  z-coordinate without ocean cavities
+      ld_zps    = .FALSE.
+      ld_sco    = .FALSE.
+      ld_isfcav = .FALSE.
+      !
+      !
+      ! Build the vertical coordinate system
+      ! ------------------------------------
+      CALL zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! Reference z-coordinate system
+      !
+      CALL zgr_msk_top_bot( k_top , k_bot )                 ! masked top and bottom ocean t-level indices
+      !
+      !                                                     ! z-coordinate (3D arrays) from the 1D z-coord.
+      CALL zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in  : 1D reference vertical coordinate
+         &          pdept   , pdepw   ,                     &   ! out : 3D t & w-points depth
+         &          pe3t    , pe3u    , pe3v   , pe3f   ,   &   !       vertical scale factors
+         &          pe3w    , pe3uw   , pe3vw             )     !           -      -      -
+      !
+   END SUBROUTINE usr_def_zgr
+
+
+   SUBROUTINE zgr_z( pdept_1d, pdepw_1d, pe3t_1d , pe3w_1d )   ! 1D reference vertical coordinate
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE zgr_z  ***
+      !!
+      !! ** Purpose :   set the 1D depth of model levels and the resulting 
+      !!              vertical scale factors.
+      !!
+      !! ** Method  :   1D z-coordinate system (use in all type of coordinate)
+      !!       The depth of model levels is set from dep(k), an analytical function:
+      !!                   w-level: depw_1d  = dep(k)
+      !!                   t-level: dept_1d  = dep(k+0.5)
+      !!       The scale factors are the discrete derivative of the depth:
+      !!                   e3w_1d(jk) = dk[ dept_1d ] 
+      !!                   e3t_1d(jk) = dk[ depw_1d ]
+      !!           with at top and bottom :
+      !!                   e3w_1d( 1 ) = 2 * ( dept_1d( 1 ) - depw_1d( 1 ) )
+      !!                   e3t_1d(jpk) = 2 * ( dept_1d(jpk) - depw_1d(jpk) )
+      !!       The depth are then re-computed from the sum of e3. This ensures 
+      !!    that depths are identical when reading domain configuration file. 
+      !!    Indeed, only e3. are saved in this file, depth are compute by a call
+      !!    to the e3_to_depth subroutine.
+      !!
+      !!       Here the Madec & Imbard (1996) function is used.
+      !!
+      !! ** Action  : - pdept_1d, pdepw_1d : depth of T- and W-point (m)
+      !!              - pe3t_1d , pe3w_1d  : scale factors at T- and W-levels (m)
+      !!
+      !! Reference : Marti, Madec & Delecluse, 1992, JGR, 97, No8, 12,763-12,766.
+      !!             Madec and Imbard, 1996, Clim. Dyn.
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pdept_1d, pdepw_1d   ! 1D grid-point depth        [m]
+      REAL(wp), DIMENSION(:)    , INTENT(out) ::   pe3t_1d , pe3w_1d    ! 1D vertical scale factors  [m]
+      !
+      INTEGER  ::   jk       ! dummy loop indices
+      REAL(wp) ::   zd       ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      zd = rn_domszz/FLOAT(jpkm1)
+      !
+      IF(lwp) THEN            ! Parameter print
+         WRITE(numout,*)
+         WRITE(numout,*) '    zgr_z   : Reference vertical z-coordinates '
+         WRITE(numout,*) '    ~~~~~~~'
+         WRITE(numout,*) '       TSUNAMI case : uniform vertical grid :'
+         WRITE(numout,*) '                     with thickness = ', zd
+      ENDIF
+
+      !
+      ! 1D Reference z-coordinate    (using Madec & Imbard 1996 function)
+      ! -------------------------
+      !
+      pdepw_1d(1) = 0._wp
+      pdept_1d(1) = 0.5_wp * zd
+      ! 
+      DO jk = 2, jpk          ! depth at T and W-points
+         pdepw_1d(jk) = pdepw_1d(jk-1) + zd 
+         pdept_1d(jk) = pdept_1d(jk-1) + zd 
+      END DO
+      !
+      !                       ! e3t and e3w from depth
+      CALL depth_to_e3( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d ) 
+      !
+      !                       ! recompute depths from SUM(e3)  <== needed
+      CALL e3_to_depth( pe3t_1d, pe3w_1d, pdept_1d, pdepw_1d ) 
+      !
+      IF(lwp) THEN                        ! control print
+         WRITE(numout,*)
+         WRITE(numout,*) '              Reference 1D z-coordinate depth and scale factors:'
+         WRITE(numout, "(9x,' level  gdept_1d  gdepw_1d  e3t_1d   e3w_1d  ')" )
+         WRITE(numout, "(10x, i4, 4f9.2)" ) ( jk, pdept_1d(jk), pdepw_1d(jk), pe3t_1d(jk), pe3w_1d(jk), jk = 1, jpk )
+      ENDIF
+      !
+   END SUBROUTINE zgr_z
+
+
+   SUBROUTINE zgr_msk_top_bot( k_top , k_bot )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE zgr_msk_top_bot  ***
+      !!
+      !! ** Purpose :   set the masked top and bottom ocean t-levels
+      !!
+      !! ** Method  :   TSUNAMI case = closed flat box ocean without ocean cavities
+      !!                   k_top = 1     except along north, south, east and west boundaries
+      !!                   k_bot = jpk-1 except along north, south, east and west boundaries
+      !!
+      !! ** Action  : - k_top : first wet ocean level index
+      !!              - k_bot : last  wet ocean level index
+      !!----------------------------------------------------------------------
+      INTEGER , DIMENSION(:,:), INTENT(out) ::   k_top , k_bot   ! first & last wet ocean level
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '    zgr_top_bot : defines the top and bottom wet ocean levels.'
+      IF(lwp) WRITE(numout,*) '    ~~~~~~~~~~~'
+      IF(lwp) WRITE(numout,*) '       TSUNAMI case : closed flat box ocean without ocean cavities'
+      !
+      k_bot(:,:) = jpkm1        ! =jpkm1 over the ocean point, =0 elsewhere
+      !
+      k_top(:,:) = 1            ! = 1    over the ocean point, =0 elsewhere
+      !
+   END SUBROUTINE zgr_msk_top_bot
+   
+
+   SUBROUTINE zgr_zco( pdept_1d, pdepw_1d, pe3t_1d, pe3w_1d,   &   ! in : 1D reference vertical coordinate
+      &                pdept   , pdepw   ,                     &   ! out: 3D t & w-points depth
+      &                pe3t    , pe3u    , pe3v   , pe3f   ,   &   !      vertical scale factors
+      &                pe3w    , pe3uw   , pe3vw             )     !          -      -      -
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE zgr_zco  ***
+      !!
+      !! ** Purpose :   define the reference z-coordinate system
+      !!
+      !! ** Method  :   set 3D coord. arrays to reference 1D array 
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pdept_1d, pdepw_1d          ! 1D grid-point depth       [m]
+      REAL(wp), DIMENSION(:)    , INTENT(in   ) ::   pe3t_1d , pe3w_1d           ! 1D vertical scale factors [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pdept, pdepw                ! grid-point depth          [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3t , pe3u , pe3v , pe3f   ! vertical scale factors    [m]
+      REAL(wp), DIMENSION(:,:,:), INTENT(  out) ::   pe3w , pe3uw, pe3vw         !    -       -      -
+      !
+      INTEGER  ::   jk
+      !!----------------------------------------------------------------------
+      !
+      DO jk = 1, jpk
+         pdept(:,:,jk) = pdept_1d(jk)
+         pdepw(:,:,jk) = pdepw_1d(jk)
+         pe3t (:,:,jk) = pe3t_1d (jk)
+         pe3u (:,:,jk) = pe3t_1d (jk)
+         pe3v (:,:,jk) = pe3t_1d (jk)
+         pe3f (:,:,jk) = pe3t_1d (jk)
+         pe3w (:,:,jk) = pe3w_1d (jk)
+         pe3uw(:,:,jk) = pe3w_1d (jk)
+         pe3vw(:,:,jk) = pe3w_1d (jk)
+      END DO
+      !
+   END SUBROUTINE zgr_zco
+
+   !!======================================================================
+END MODULE usrdef_zgr
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/cpp_TSUNAMI.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/cpp_TSUNAMI.fcm	(revision 14644)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/TSUNAMI/cpp_TSUNAMI.fcm	(revision 14644)
@@ -0,0 +1,1 @@
+ bld::tool::fppkeys key_qco key_xios
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/EXPREF/1_namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 14644)
@@ -284,5 +284,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -290,5 +290,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/EXPREF/namelist_cfg	(revision 14644)
@@ -277,5 +277,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -283,5 +283,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -80,25 +80,19 @@
       IF( Agrif_Root() ) THEN
 #endif
-         ! Compatibility WITH old version: 
-         ! jperio = 0 =>  Ni0glo = jpigo_old_version
-         !            =>  jpiglo-1 replaced by Ni0glo-1
-         zlam0 = -REAL( (Ni0glo-1)/2, wp) * 1.e-3 * rn_dx
-         zphi0 = -REAL( (Nj0glo-1)/2, wp) * 1.e-3 * rn_dy 
+         zlam0 = -REAL(Ni0glo, wp) * 0.5 * 1.e-3 * rn_dx
+         zphi0 = -REAL(Nj0glo, wp) * 0.5 * 1.e-3 * rn_dy
 #if defined key_agrif
       ELSE
          ! ! let lower left longitude and latitude from parent
-         ! Compatibility WITH old version: 
-         ! jperio = 0 =>  Ni0glo = jpigo_old_version
-         !            =>  Agrif_parent(jpiglo)-1 replaced by  Agrif_parent(Ni0glo)-1
-         zlam0 = ( 0.5_wp - REAL( ( Agrif_parent(Ni0glo)-1 ) / 2, wp) ) * 1.e-3 * Agrif_irhox() * rn_dx  &
+         zlam0 = ( 0.5_wp - REAL(Ni0glo, wp) * 0.5 ) * 1.e-3 * Agrif_irhox() * rn_dx  &
             &  + ( Agrif_Ix() + nbghostcells - 1 ) * Agrif_irhox() * rn_dx * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dx * 1.e-3
-         zphi0 = ( 0.5_wp - REAL( ( Agrif_parent(Nj0glo)-1 ) / 2, wp) ) * 1.e-3 * Agrif_irhoy() * rn_dy  &
+         zphi0 = ( 0.5_wp - REAL(Nj0glo, wp) * 0.5 ) * 1.e-3 * Agrif_irhoy() * rn_dy  &
             &  + ( Agrif_Iy() + nbghostcells - 1 ) * Agrif_irhoy() * rn_dy * 1.e-3 - ( 0.5_wp + nbghostcells ) * rn_dy * 1.e-3
       ENDIF 
 #endif
          
-      DO_2D( 1, 1, 1, 1 )
-         zti = REAL( mig0_oldcmp(ji) - 1, wp )   ! start at i=0 in the global grid without halos
-         ztj = REAL( mjg0_oldcmp(jj) - 1, wp )   ! start at j=0 in the global grid without halos
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         zti = REAL( mig0(ji), wp ) - 0.5_wp  ! start at i=0.5 in the global grid without halos
+         ztj = REAL( mjg0(jj), wp ) - 0.5_wp  ! start at j=0.5 in the global grid without halos
          
          plamt(ji,jj) = zlam0 + rn_dx * 1.e-3 *   zti
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_istate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_istate.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_istate.F90	(revision 14644)
@@ -123,5 +123,5 @@
       END_2D
       !
-      CALL lbc_lnk_multi( 'usrdef_istate', pu, 'U', -1., pv, 'V', -1. )
+      CALL lbc_lnk( 'usrdef_istate', pu, 'U', -1., pv, 'V', -1. )
       !   
    END SUBROUTINE usr_def_istate
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -40,5 +40,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -52,8 +52,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios          ! Local integer
@@ -96,5 +98,7 @@
       zh  = (kpk-1)*rn_dz
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! VORTEX configuration : closed basin
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.   ! VORTEX configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
+      !
       !                             ! control print
       IF(lwp) THEN
@@ -115,6 +119,4 @@
          WRITE(numout,*) '      Reference latitude            rn_ppgphi0 = ', rn_ppgphi0
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      VORTEX : closed basin            jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -190,5 +190,5 @@
       z2d(:,:) = REAL( jpkm1 , wp )          ! flat bottom
       !
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (here jperio=0 ==>> closed)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )           ! set surrounding land to zero (closed boundaries)
       !
       k_bot(:,:) = NINT( z2d(:,:) )          ! =jpkm1 over the ocean point, =0 elsewhere
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/cpp_VORTEX.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/cpp_VORTEX.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/cpp_VORTEX.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif key_qco 
+ bld::tool::fppkeys key_xios key_agrif key_qco 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/EXPREF/namelist_cfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/EXPREF/namelist_cfg	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/EXPREF/namelist_cfg	(revision 14644)
@@ -456,5 +456,5 @@
 !!                  ***  Miscellaneous namelists  ***                 !!
 !!                                                                    !!
-!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   nammpp            Massively Parallel Processing
 !!   namctl            Control prints                                   (default: OFF)
 !!   namsto            Stochastic parametrization of EOS                (default: OFF)
@@ -462,5 +462,5 @@
 !
 !-----------------------------------------------------------------------
-&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+&nammpp        !   Massively Parallel Processing
 !-----------------------------------------------------------------------
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_hgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_hgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_hgr.F90	(revision 14644)
@@ -74,14 +74,14 @@
       !                       !==  grid point position  ==!   (in kilometers)
       zfact = rn_dx * 1.e-3         ! conversion in km
-      DO_2D( 1, 1, 1, 1 )
-         !                       ! longitude
-         plamt(ji,jj) = zfact * (  - 0.5 + REAL( mig0_oldcmp(ji)-1 , wp )  )  
-         plamu(ji,jj) = zfact * (          REAL( mig0_oldcmp(ji)-1 , wp )  )
+      DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
+         !                       ! longitude   (west coast at lon=0°)
+         plamt(ji,jj) = zfact * (  - 0.5 + REAL( mig0(ji)-1 , wp )  )  
+         plamu(ji,jj) = zfact * (          REAL( mig0(ji)-1 , wp )  )
          plamv(ji,jj) = plamt(ji,jj)
          plamf(ji,jj) = plamu(ji,jj)
-         !                       ! latitude
-         pphit(ji,jj) = zfact * (  - 0.5 + REAL( mjg0_oldcmp(jj)-1 , wp )  )
+         !                       ! latitude   (south coast at lat= 0°)
+         pphit(ji,jj) = zfact * (  - 0.5 + REAL( mjg0(jj)-1 , wp )  )
          pphiu(ji,jj) = pphit(ji,jj)
-         pphiv(ji,jj) = zfact * (          REAL( mjg0_oldcmp(jj)-1 , wp )  )
+         pphiv(ji,jj) = zfact * (          REAL( mjg0(jj)-1 , wp )  )
          pphif(ji,jj) = pphiv(ji,jj)
       END_2D
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_nam.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_nam.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_nam.F90	(revision 14644)
@@ -38,5 +38,5 @@
 CONTAINS
 
-   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, kperio )
+   SUBROUTINE usr_def_nam( cd_cfg, kk_cfg, kpi, kpj, kpk, ldIperio, ldJperio, ldNFold, cdNFtype )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_nam  ***
@@ -50,8 +50,10 @@
       !! ** input   : - namusr_def namelist found in namelist_cfg
       !!----------------------------------------------------------------------
-      CHARACTER(len=*)              , INTENT(out) ::   cd_cfg          ! configuration name
-      INTEGER                       , INTENT(out) ::   kk_cfg          ! configuration resolution
-      INTEGER                       , INTENT(out) ::   kpi, kpj, kpk   ! global domain sizes 
-      INTEGER                       , INTENT(out) ::   kperio          ! lateral global domain b.c. 
+      CHARACTER(len=*), INTENT(out) ::   cd_cfg               ! configuration name
+      INTEGER         , INTENT(out) ::   kk_cfg               ! configuration resolution
+      INTEGER         , INTENT(out) ::   kpi, kpj, kpk        ! global domain sizes
+      LOGICAL         , INTENT(out) ::   ldIperio, ldJperio   ! i- and j- periodicity
+      LOGICAL         , INTENT(out) ::   ldNFold              ! North pole folding
+      CHARACTER(len=1), INTENT(out) ::   cdNFtype             ! Folding type: T or F
       !
       INTEGER ::   ios   ! Local integer
@@ -75,7 +77,8 @@
       kpk = INT(  10.  / rn_dz ) + 1
       !                             ! Set the lateral boundary condition of the global domain
-      kperio = 0                    ! WAD_TEST_CASES configuration : closed domain
+      ldIperio = .FALSE.   ;   ldJperio = .FALSE.    ! WAD_TEST_CASES configuration : closed domain
+      ldNFold  = .FALSE.   ;   cdNFtype = '-'
       IF( nn_wad_test == 8 ) THEN
-         kperio = 7         ! North-South cyclic test
+         ldIperio = .TRUE.   ;   ldJperio = .TRUE.   ! WAD_TEST_CASES configuration : bi-periodic
          kpi = kpi - 2      ! no closed boundary
          kpj = kpj - 2      ! no closed boundary
@@ -95,6 +98,4 @@
          WRITE(numout,*) '                                               jpkglo = ', kpk
          WRITE(numout,*) '   '
-         WRITE(numout,*) '   Lateral boundary condition of the global domain'
-         WRITE(numout,*) '      closed                                   jperio = ', kperio
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_zgr.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_zgr.F90	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/MY_SRC/usrdef_zgr.F90	(revision 14644)
@@ -260,5 +260,5 @@
       !
       ! no ocean cavities : top ocean level is ONE, except over land
-      ! the ocean basin surrounnded by land (1 grid-point) set through lbc_lnk call as jperio=0 
+      ! the ocean basin surrounnded by land (1+nn_hls grid-points) set through lbc_lnk call
       z2d(:,:) = 1._wp                    ! surface ocean is the 1st level
       z2d(mi0(1):mi1(1),:) = 0._wp
@@ -267,9 +267,5 @@
       z2d(:,mj0(jpjglo):mj1(jpjglo)) = 0._wp
 
-
-
-
-
-      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin since jperio = 0 (see userdef_nam.F90)
+      CALL lbc_lnk( 'usrdef_zgr', z2d, 'T', 1. )        ! closed basin, see userdef_nam.F90
       k_top(:,:) = NINT( z2d(:,:) )
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/cpp_WAD.fcm
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/cpp_WAD.fcm	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/cpp_WAD.fcm	(revision 14644)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi key_qco 
+ bld::tool::fppkeys   key_xios key_qco 
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/demo_cfgs.txt
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/demo_cfgs.txt	(revision 14643)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/demo_cfgs.txt	(revision 14644)
@@ -16,2 +16,4 @@
 ICE_RHEO OCE SAS ICE
 DOME OCE NST
+TSUNAMI OCE
+DONUT OCE ICE
