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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AGRIF_DEMO/cpp_AGRIF_DEMO.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_agrif
+bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_agrif key_qco
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/AMM12/cpp_AMM12.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_diainstant key_mpp_mpi key_iomput
+ bld::tool::fppkeys   key_diainstant key_mpp_mpi key_iomput key_qco
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/C1D_PAPA/cpp_C1D_PAPA.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_c1d key_mpp_mpi key_iomput
+ bld::tool::fppkeys   key_c1d key_mpp_mpi key_iomput key_linssh
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_BFM/cpp_GYRE_BFM.fcm	(revision 14200)
@@ -1,2 +1,2 @@
-bld::tool::fppkeys   key_top key_my_trc key_mpp_mpi key_iomput
+bld::tool::fppkeys   key_top key_my_trc key_mpp_mpi key_iomput key_linssh
 inc $BFMDIR/src/nemo/bfm.fcm
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/GYRE_PISCES/cpp_GYRE_PISCES.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_top key_mpp_mpi key_iomput
+bld::tool::fppkeys   key_top key_linssh key_mpp_mpi key_iomput
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_ABL/cpp_ORCA2_ICE_ABL.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_mpp_mpi key_si3 key_iomput
+bld::tool::fppkeys   key_mpp_mpi key_si3 key_iomput key_qco
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_ICE_PISCES/cpp_ORCA2_ICE_PISCES.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi 
+bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_qco 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/ORCA2_SAS_ICE/cpp_ORCA2_SAS_ICE.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_si3 key_iomput key_mpp_mpi
+ bld::tool::fppkeys   key_si3 key_linssh key_iomput key_mpp_mpi
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/field_def_nemo-oce.xml	(revision 14200)
@@ -740,13 +740,13 @@
   <!-- F grid -->
   <field_group id="grid_F" grid_ref="grid_F_2D">
-    <field id="e3f"          long_name="F-cell thickness"                    standard_name="cell_thickness"        unit="m"   grid_ref="grid_F_3D" />
-    <field id="e3f_0"        long_name="F-cell thickness"                    standard_name="cell_thickness"        unit="m"   grid_ref="grid_F_3D" />
-    <field id="hf"           long_name="water column height at F point"    standard_name="water_column_height_F"  unit="m"                     />
-    <field id="sKEf"         long_name="surface kinetic energy at F point" standard_name="specific_kinetic_energy_of_sea_water"   unit="m2/s2" />
-    <field id="relvor"       long_name="relative vorticity"                standard_name="relative_vorticity"     unit="1/s"                   />
-    <field id="plavor"       long_name="planetary vorticity"               standard_name="planetary_vorticity"    unit="1/s"                   />
-    <field id="relpotvor"    long_name="relative potential vorticity"      standard_name="relpot_vorticity"       unit="1/m.s"                 />
-    <field id="abspotvor"    long_name="absolute potential vorticity"      standard_name="abspot_vorticity"       unit="1/m.s"                 />
-    <field id="Ens"          long_name="enstrophy"                         standard_name="enstrophy"              unit="1/m2.s2"               />
+    <field id="e3f"          long_name="F-cell thickness"                      standard_name="cell_thickness"         unit="m"   grid_ref="grid_F_3D" />
+    <field id="e3f_0"        long_name="F-cell thickness"                      standard_name="cell_thickness"         unit="m"   grid_ref="grid_F_3D" />
+    <field id="hf"           long_name="water column height at F point"        standard_name="water_column_height_F"  unit="m"                     />
+    <field id="ssKEf"        long_name="surface kinetic energy at F point"     standard_name="specific_kinetic_energy_of_sea_water"   unit="m2/s2" />
+    <field id="ssrelvor"     long_name="surface relative vorticity"            standard_name="relative_vorticity"     unit="1/s"                   />
+    <field id="ssplavor"     long_name="surface planetary vorticity"           standard_name="planetary_vorticity"    unit="1/s"                   />
+    <field id="ssrelpotvor"  long_name="surface relative potential vorticity"  standard_name="relpot_vorticity"       unit="1/m.s"                 />
+    <field id="ssabspotvor"  long_name="surface absolute potential vorticity"  standard_name="abspot_vorticity"       unit="1/m.s"                 />
+    <field id="ssEns"        long_name="surface enstrophy"                     standard_name="enstrophy"              unit="1/m2.s2"               />
   </field_group>
 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SHARED/namelist_ref	(revision 14200)
@@ -202,4 +202,5 @@
 !!   namsbc_wave     external fields from wave model                    (ln_wave    =T)
 !!   namberg         iceberg floats                                     (ln_icebergs=T)
+!!   namsbc_fwb      freshwater-budget adjustment                       (nn_fwb > 0)
 !!======================================================================
 !
@@ -382,17 +383,17 @@
    sn_rcv_isf    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
    sn_rcv_icb    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
-   sn_rcv_hsig   =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
+   sn_rcv_hsig   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
    sn_rcv_phioc  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
    sn_rcv_sdrfx  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
-   sn_rcv_sdrfy  =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
-   sn_rcv_wper   =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
-   sn_rcv_wnum   =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
-   sn_rcv_wstrf  =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
-   sn_rcv_wdrag  =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
+   sn_rcv_sdrfy  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
+   sn_rcv_wper   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
+   sn_rcv_wnum   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
+   sn_rcv_wstrf  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
+   sn_rcv_wdrag  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
    sn_rcv_charn  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
    sn_rcv_taw    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'U,V'
-   sn_rcv_bhd    =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
-   sn_rcv_tusd   =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
-   sn_rcv_tvsd   =   'none'                 ,    'no'    ,     ''      '         ''           ,   'T'
+   sn_rcv_bhd    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
+   sn_rcv_tusd   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
+   sn_rcv_tvsd   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   'T'
 /
 !-----------------------------------------------------------------------
@@ -653,4 +654,9 @@
    !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
    sn_icb     =  'calving'              ,         -1.        ,'calvingmask',  .true.   , .true. , 'yearly'  , ''               , ''       , ''
+/
+!-----------------------------------------------------------------------
+&namsbc_fwb    !   freshwater-budget adjustment                         (nn_fwb > 0)
+!-----------------------------------------------------------------------
+   rn_fwb0     = 0.0          ! Initial freshwater adjustment flux [kg/m2/s] (nn_fwb = 2)
 /
 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/cfgs/SPITZ12/cpp_SPITZ12.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_mpp_mpi key_iomput key_si3
+ bld::tool::fppkeys key_mpp_mpi key_iomput key_si3 key_qco
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/apdx_DOMAINcfg.tex	(revision 14200)
@@ -46,5 +46,38 @@
 
 \begin{listing}
-  \nlst{namdom_domcfg}
+%  \nlst{namdom_domcfg}
+  \begin{forlines}
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    1      !  compute analyticaly (=0) or read (=1) the bathymetry file
+                           !  or compute (2) from external bathymetry
+   nn_interp   =    1                          ! type of interpolation (nn_bathy =2)                       
+   cn_topo     =  'bathymetry_ORCA12_V3.3.nc'  ! external topo file (nn_bathy =2)
+   cn_bath     =  'Bathymetry'                 ! topo name in file  (nn_bathy =2)
+   cn_lon      =  'nav_lon'                    ! lon  name in file  (nn_bathy =2)
+   cn_lat      =  'nav_lat'                    ! lat  name in file  (nn_bathy =2)
+   rn_scale    = 1
+   rn_bathy    =    0.     !  value of the bathymetry. if (=0) bottom flat at jpkm1
+   jphgr_msh   =       0               !  type of horizontal mesh
+   ppglam0     =  999999.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =  999999.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0             !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0             !  meridional grid-spacing (degrees)
+   ppsur       =   -4762.96143546300   !  ORCA r4, r2 and r05 coefficients
+   ppa0        =     255.58049070440   ! (default coefficients)
+   ppa1        =     245.58132232490   !
+   ppkth       =      21.43336197938   !
+   ppacr       =       3.0             !
+   ppdzmin     =  999999.              !  Minimum vertical spacing
+   pphmax      =  999999.              !  Maximum depth
+   ldbletanh   =  .FALSE.              !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.              !  Double tanh function parameters
+   ppkth2      =  999999.              !
+   ppacr2      =  999999.              !
+/
+  \end{forlines}
   \caption{\forcode{&namdom_domcfg}}
   \label{lst:namdom_domcfg}
@@ -383,10 +416,39 @@
 \subsubsection[$S$-coordinate (\forcode{ln_sco})]{$S$-coordinate (\protect\np{ln_sco}{ln\_sco})}
 \label{sec:DOMCFG_sco}
+
 \begin{listing}
-  \nlst{namzgr_sco_domcfg}
+%  \nlst{namzgr_sco_domcfg}
   \caption{\forcode{&namzgr_sco_domcfg}}
   \label{lst:namzgr_sco_domcfg}
+  \begin{forlines}
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate                (default: OFF)
+!-----------------------------------------------------------------------
+   ln_s_sh94   = .false.    !  Song & Haidvogel 1994 hybrid S-sigma   (T)|
+   ln_s_sf12   = .false.   !  Siddorn & Furner 2012 hybrid S-z-sigma (T)| if both are false the NEMO tanh stretching is applied
+   ln_sigcrit  = .false.   !  use sigma coordinates below critical depth (T) or Z coordinates (F) for Siddorn & Furner stretch
+                           !  stretching coefficients for all functions
+   rn_sbot_min =   10.0    !  minimum depth of s-bottom surface (>0) (m)
+   rn_sbot_max = 7000.0    !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
+   rn_hc       =  150.0    !  critical depth for transition to stretched coordinates
+                        !!!!!!!  Envelop bathymetry
+   rn_rmax     =    0.3    !  maximum cut-off r-value allowed (0<r_max<1)
+                        !!!!!!!  SH94 stretching coefficients  (ln_s_sh94 = .true.)
+   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
+   rn_bb       =    0.8    !  stretching with SH94 s-sigma
+                        !!!!!!!  SF12 stretching coefficient  (ln_s_sf12 = .true.)
+   rn_alpha    =    4.4    !  stretching with SF12 s-sigma
+   rn_efold    =    0.0    !  efold length scale for transition to stretched coord
+   rn_zs       =    1.0    !  depth of surface grid box
+                           !  bottom cell depth (Zb) is a linear function of water depth Zb = H*a + b
+   rn_zb_a     =    0.024  !  bathymetry scaling factor for calculating Zb
+   rn_zb_b     =   -0.2    !  offset for calculating Zb
+                        !!!!!!!! Other stretching (not SH94 or SF12) [also uses rn_theta above]
+   rn_thetb    =    1.0    !  bottom control parameter  (0<=thetb<= 1)
+/
+  \end{forlines}
 \end{listing}
-Options are defined in \nam{zgr_sco}{zgr\_sco} (\texttt{DOMAINcfg} only).
+
+Options are defined in \forcode{&zgr_sco} (\texttt{DOMAINcfg} only).
 In $s$-coordinate (\np[=.true.]{ln_sco}{ln\_sco}), the depth and thickness of the model levels are defined from
 the product of a depth field and either a stretching function or its derivative, respectively:
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_DYN.tex	(revision 14200)
@@ -763,5 +763,5 @@
 which imposes a very small time step when an explicit time stepping is used.
 Two methods are proposed to allow a longer time step for the three-dimensional equations:
-the filtered free surface, which is a modification of the continuous equations (see \autoref{eq:MB_flt?}),
+the filtered free surface, which is a modification of the continuous equations \iffalse (see \autoref{eq:MB_flt?}) \fi
 and the split-explicit free surface described below.
 The extra term introduced in the filtered method is calculated implicitly,
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_LBC.tex	(revision 14200)
@@ -372,5 +372,5 @@
 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 \nam{bdy_index}{bdy\_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).
+(\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.
 In the example above, there are two boundary sets, the first of which is defined via a file and
@@ -569,8 +569,8 @@
 \autoref{fig:LBC_bdy_geom} shows an example of an irregular boundary.
 
-The boundary geometry for each set may be defined in a namelist nambdy\_index or
+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 nambdy\_index namelist defines a series of straight-line segments for north, east, south and west boundaries.
-One nambdy\_index namelist block is needed for each boundary condition defined by indexes.
+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.
 For the northern boundary, \texttt{nbdysegn} gives the number of segments,
 \jp{jpjnob} gives the $j$ index for each segment and \jp{jpindt} and
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_OBS.tex	(revision 14200)
@@ -892,5 +892,5 @@
 \subsubsection{Running}
 
-The simplest way to use the executable is to edit and append the \textbf{sao.nml} namelist to
+The simplest way to use the executable is to edit and append the \nam{sao}{sao} namelist to
 a full \NEMO\ namelist and then to run the executable as if it were nemo.exe.
 
@@ -914,5 +914,7 @@
 For example, to read the second time counter from a single file the namelist would be.
 
-\begin{forlines}
+\begin{listing}
+%  \nlst{namsao}
+  \begin{forlines}
 !----------------------------------------------------------------------
 !       namsao Standalone obs_oper namelist
@@ -924,5 +926,8 @@
    nn_sao_idx = 2
 /
-\end{forlines}
+  \end{forlines}
+  \caption{\forcode{&namsao}}
+  \label{lst:namsao}
+\end{listing}
 
 %% =================================================================================================
@@ -1119,7 +1124,7 @@
 To plot some data run IDL and then:
 
-\begin{minted}{idl}
+\begin{verbatim}
 IDL> dataplot, "filename"
-\end{minted}
+\end{verbatim}
 
 To read multiple files into dataplot,
@@ -1127,8 +1132,8 @@
 the easiest method is to use the spawn command to generate a list of files which can then be passed to dataplot.
 
-\begin{minted}{idl}
+\begin{verbatim}
 IDL> spawn, 'ls profb*.nc', files
 IDL> dataplot, files
-\end{minted}
+\end{verbatim}
 
 \autoref{fig:OBS_dataplotmain} shows the main window which is launched when dataplot starts.
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 14200)
@@ -16,5 +16,5 @@
     Release & Author(s) & Modifications \\
     \hline
-    {\em  next} & {\em Simon M{\" u}ller} & {\em Update of \autoref{sec:SBC_TDE}}\\[2mm]
+    {\em  next} & {\em Simon M{\" u}ller} & {\em Update of \autoref{sec:SBC_TDE}; revision of \autoref{subsec:SBC_fwb}}\\[2mm]
     {\em   4.0} & {\em ...} & {\em ...} \\
     {\em   3.6} & {\em ...} & {\em ...} \\
@@ -664,5 +664,5 @@
 For the cool-skin scheme parametrization COARE and ECMWF algorithms share the same
 basis: \citet{fairall.bradley.ea_JGRO96}. With some minor updates based
-on \citet{zeng.beljaars_GRL05} for ECMWF, and \citet{fairall.ea_19} for COARE
+on \citet{zeng.beljaars_GRL05} for ECMWF \iffalse, and \citet{fairall.ea_19?} for COARE \fi
 3.6.
 
@@ -671,5 +671,5 @@
 turbulence input from Langmuir circulation).
 
-Importantly, COARE warm-layer scheme \citep{fairall.ea_19} includes a prognostic
+Importantly, COARE warm-layer scheme \iffalse \citep{fairall.ea_19?} \fi includes a prognostic
 equation for the thickness of the warm-layer, while it is considered as constant
 in the ECWMF algorithm.
@@ -971,6 +971,6 @@
 and tidal analysis in the model framework. This includes the computation of the gravitational
 surface forcing, as well as support for lateral forcing at open boundaries (see
-\autoref{subsec:LBC_bdy_tides}) and tidal harmonic analysis (see
-\autoref{subsec:DIA_diamlr} and \autoref{subsec:DIA_diadetide}). The module is
+\autoref{subsec:LBC_bdy_tides}) and tidal harmonic analysis \iffalse (see
+\autoref{subsec:DIA_diamlr?} and \autoref{subsec:DIA_diadetide?}) \fi . The module is
 activated with \np[=.true.]{ln_tide}{ln\_tide} in namelist
 \nam{_tide}{\_tide}. It provides the same 34 tidal constituents that are
@@ -1777,18 +1777,28 @@
 \label{subsec:SBC_fwb}
 
-For global ocean simulation, it can be useful to introduce a control of the mean sea level in order to
-prevent unrealistic drift of the sea surface height due to inaccuracy in the freshwater fluxes.
-In \NEMO, two way of controlling the freshwater budget are proposed:
+\begin{listing}
+  \nlst{namsbc_fwb}
+  \caption{\forcode{&namsbc_fwb}}
+  \label{lst:namsbc_fwb}
+\end{listing}
+
+For global ocean simulations, it can be useful to introduce a control of the
+mean sea level in order to prevent unrealistic drifting of the sea surface
+height due to unbalanced freshwater fluxes. In \NEMO, two options for
+controlling the freshwater budget are proposed.
 
 \begin{description}
-\item [{\np[=0]{nn_fwb}{nn\_fwb}}] no control at all.
-  The mean sea level is free to drift, and will certainly do so.
-\item [{\np[=1]{nn_fwb}{nn\_fwb}}] global mean \textit{emp} set to zero at each model time step.
+\item [{\np[=0]{nn_fwb}{nn\_fwb}}:] No control at all; the mean sea level is
+  free to drift, and will certainly do so.
+\item [{\np[=1]{nn_fwb}{nn\_fwb}}:] The global mean \textit{emp} is set to zero at each model time step.
   %GS: comment below still relevant ?
   %Note that with a sea-ice model, this technique only controls the mean sea level with linear free surface and no mass flux between ocean and ice (as it is implemented in the current ice-ocean coupling).
-\item [{\np[=2]{nn_fwb}{nn\_fwb}}] freshwater budget is adjusted from the previous year annual mean budget which
-  is read in the \textit{EMPave\_old.dat} file.
-  As the model uses the Boussinesq approximation, the annual mean fresh water budget is simply evaluated from
-  the change in the mean sea level at January the first and saved in the \textit{EMPav.dat} file.
+\item [{\np[=2]{nn_fwb}{nn\_fwb}}:] \textit{emp} is adjusted by adding a
+  spatially uniform, annual-mean freshwater flux that balances the freshwater
+  budget at the end of the previous year; as the model uses the Boussinesq
+  approximation, the freshwater budget can be evaluated from the change in the
+  mean sea level and in the ice and snow mass after the end of each simulation
+  year; at the start of the model run, an initial adjustment flux can be set
+  using parameter \np{rn_rwb0}{rn\_fwb0} in namelist \nam{sbc_fwb}{sbc\_fwb}.
 \end{description}
 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_ZDF.tex	(revision 14200)
@@ -731,5 +731,5 @@
 \subsubsection{Evolution of the boundary layer depth}
 
-The prognostic equation for the depth of the neutral/unstable boundary layer is given by \citep{grant+etal18},
+The prognostic equation for the depth of the neutral/unstable boundary layer is given by \iffalse \citep{grant+etal18?}, \fi
 
 \begin{equation}
@@ -747,5 +747,5 @@
 equation for the case when the pycnocline has a finite thickness,
 based on the potential energy budget of the OSBL, is the leading term
-\citep{grant+etal18} of a generalization of that used in mixed-layer
+\iffalse \citep{grant+etal18?} \fi of a generalization of that used in mixed-layer
 models e.g.\ \citet{kraus.turner_T67}, in which the thickness of the pycnocline is taken to be zero.
 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_cfgs.tex	(revision 14200)
@@ -243,15 +243,29 @@
 Through \np[=.false.]{ln_read_cfg}{ln\_read\_cfg} in \nam{cfg}{cfg} namelist defined in
 the reference configuration \path{./cfgs/GYRE_PISCES/EXPREF/namelist_cfg}
-analytical definition of grid in GYRE is done in usrdef\_hrg, usrdef\_zgr routines.
+analytical definition of grid in GYRE is done in mdl{usrdef\_hrg}, \mdl{usrdef\_zgr} routines.
 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}: \\
-
-\jp{jpiglo} $= 30 \times$ \np{nn_GYRE}{nn\_GYRE} + 2   \\
-
-\jp{jpjglo} $= 20 \times$ \np{nn_GYRE}{nn\_GYRE} + 2   \\
+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}}
+\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}).
+
+\begin{listing}
+  \begin{forlines}
+!-----------------------------------------------------------------------
+&namusr_def    !   GYRE user defined namelist  
+!-----------------------------------------------------------------------
+   nn_GYRE     =     1     !  GYRE resolution [1/degrees]
+   ln_bench    = .false.   !  ! =T benchmark with gyre: the gridsize is kept constant
+   jpkglo      =    31     !  number of model levels
+/
+  \end{forlines}
+  \caption{\forcode{&namusr_def}}
+  \label{lst:namusr_def}
+\end{listing}
 
 The GYRE configuration is also used in benchmark test as it is very simple to increase its resolution and
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/NEMO/subfiles/chap_model_basics_zstar.tex	(revision 14200)
@@ -95,5 +95,5 @@
 which imposes a very small time step when an explicit time stepping is used.
 Two methods are proposed to allow a longer time step for the three-dimensional equations:
-the filtered free surface, which is a modification of the continuous equations %(see \autoref{eq:MB_flt?}),
+the filtered free surface, which is a modification of the continuous equations \iffalse (see \autoref{eq:MB_flt?}) \fi ,
 and the split-explicit free surface described below.
 The extra term introduced in the filtered method is calculated implicitly,
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/namelists/namdyn_adv
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/namelists/namdyn_adv	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/namelists/namdyn_adv	(revision 14200)
@@ -2,6 +2,6 @@
 &namdyn_adv     !   Ice advection
 !------------------------------------------------------------------------------
-   ln_adv_Pra       = .true.         !  Advection scheme (Prather)
-   ln_adv_UMx       = .false.          !  Advection scheme (Ultimate-Macho)
+   ln_adv_Pra       = .true.          !  Advection scheme (Prather)
+   ln_adv_UMx       = .false.         !  Advection scheme (Ultimate-Macho)
       nn_UMx        =   5             !     order of the scheme for UMx (1-5 ; 20=centered 2nd order)
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/namelists/namsbc
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/namelists/namsbc	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/latex/SI3/namelists/namsbc	(revision 14200)
@@ -3,5 +3,9 @@
 !------------------------------------------------------------------------------
    rn_cio           =   5.0e-03       !  ice-ocean drag coefficient (-)
-   rn_blow_s        =   0.66          !  mesure of snow blowing into the leads
+   nn_snwfra        =   2             !  calculate the fraction of ice covered by snow (for zdf and albedo)
+                                      !     = 0  fraction = 1 (if snow) or 0 (if no snow)
+                                      !     = 1  fraction = 1-exp(-0.2*rhos*hsnw) [MetO formulation]
+                                      !     = 2  fraction = hsnw / (hsnw+0.02)    [CICE formulation]
+   rn_snwblow       =   0.66          !  mesure of snow blowing into the leads
                                       !     = 1 => no snow blowing, < 1 => some snow blowing
    nn_flxdist       =  -1             !  Redistribute heat flux over ice categories
@@ -12,3 +16,6 @@
    ln_cndflx        = .false.         !  Use conduction flux as surface boundary conditions (i.e. for Jules coupling)
       ln_cndemulate = .false.         !     emulate conduction flux (if not provided in the inputs)
+   nn_qtrice        =   1             !  Solar flux transmitted thru the surface scattering layer:
+                                      !     = 0  Grenfell and Maykut 1977 (depends on cloudiness and is 0 when there is snow) 
+                                      !     = 1  Lebrun 2019 (equals 0.3 anytime with different melting/dry snw conductivities)
 /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namclo
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namclo	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namclo	(revision 14200)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&namclo        !   parameters of the closed sea (cs) behavior                (default: OFF)
+!-----------------------------------------------------------------------
+   ln_maskcs = .false.        ! (=T) cs are masked ; So, in this case ln_mask_csundef and ln_clo_rnf have no effect.
+      !                       ! (=F => set ln_mask_csundef and ln_clo_rnf) 
+      !                       ! cs masks are read and net evap/precip over closed sea spread out depending on domain_cfg.nc masks.
+      !                       ! See ln_mask_csundef and ln_clo_rnf for specific option related to this case
+      !
+      ln_mask_csundef = .true.   ! (=T) undefined closed seas are masked ; 
+      !                          ! (=F) undefined closed seas are kept and no specific treatment is done for these closed seas
+      !
+      ln_clo_rnf = .true.        ! (=T) river mouth specified in domain_cfg.nc masks (rnf and emp case) are added to the runoff mask.
+      !                          !      allow the treatment of closed sea outflow grid-points to be the same as river mouth grid-points
+/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namdom_domcfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namdom_domcfg	(revision 14199)
+++ 	(revision )
@@ -1,39 +1,0 @@
-!-----------------------------------------------------------------------
-&namdom        !   space and time domain (bathymetry, mesh, timestep)
-!-----------------------------------------------------------------------
-   nn_bathy    =    1      !  compute (=0) or read (=1) the bathymetry file
-   rn_bathy    =    0.     !  value of the bathymetry. if (=0) bottom flat at jpkm1
-   nn_closea   =    0      !  remove (=0) or keep (=1) closed seas and lakes (ORCA)
-   nn_msh      =    1      !  create (=1) a mesh file or not (=0)
-   rn_hmin     =   -3.     !  min depth of the ocean (>0) or min number of ocean level (<0)
-   rn_isfhmin  =    1.00   !  treshold (m) to discriminate grounding ice to floating ice
-   rn_e3zps_min=   20.     !  partial step thickness is set larger than the minimum of
-   rn_e3zps_rat=    0.1    !  rn_e3zps_min and rn_e3zps_rat*e3t, with 0<rn_e3zps_rat<1
-                           !
-   rn_rdt      = 5760.     !  time step for the dynamics (and tracer if nn_acc=0)
-   rn_atfp     =    0.1    !  asselin time filter parameter
-   ln_crs      = .false.      !  Logical switch for coarsening module
-   jphgr_msh   =       0               !  type of horizontal mesh
-                                       !  = 0 curvilinear coordinate on the sphere read in coordinate.nc
-                                       !  = 1 geographical mesh on the sphere with regular grid-spacing
-                                       !  = 2 f-plane with regular grid-spacing
-                                       !  = 3 beta-plane with regular grid-spacing
-                                       !  = 4 Mercator grid with T/U point at the equator
-   ppglam0     =       0.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
-   ppgphi0     =     -35.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
-   ppe1_deg    =       1.0             !  zonal      grid-spacing (degrees)
-   ppe2_deg    =       0.5             !  meridional grid-spacing (degrees)
-   ppe1_m      =    5000.0             !  zonal      grid-spacing (degrees)
-   ppe2_m      =    5000.0             !  meridional grid-spacing (degrees)
-   ppsur       =    -4762.96143546300  !  ORCA r4, r2 and r05 coefficients
-   ppa0        =      255.58049070440  ! (default coefficients)
-   ppa1        =      245.58132232490  !
-   ppkth       =       21.43336197938  !
-   ppacr       =        3.0            !
-   ppdzmin     =       10.             !  Minimum vertical spacing
-   pphmax      =     5000.             !  Maximum depth
-   ldbletanh   =    .TRUE.             !  Use/do not use double tanf function for vertical coordinates
-   ppa2        =      100.760928500000 !  Double tanh function parameters
-   ppkth2      =       48.029893720000 !
-   ppacr2      =       13.000000000000 !
-/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namisf
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namisf	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namisf	(revision 14200)
@@ -0,0 +1,66 @@
+!-----------------------------------------------------------------------
+&namisf       !  Top boundary layer (ISF)                               (default: OFF)
+!-----------------------------------------------------------------------
+   !
+   ! ---------------- ice shelf load -------------------------------
+   !
+   cn_isfload = 'uniform'      ! scheme to compute ice shelf load (ln_isfcav = .true. in domain_cfg.nc)
+      rn_isfload_T = -1.9
+      rn_isfload_S = 34.4
+   !
+   ! ---------------- ice shelf melt formulation -------------------------------
+   !
+   ln_isf = .false.           ! activate ice shelf module
+      ln_isfdebug = .false.      ! add debug print in ISF code (global min/max/sum of specific variable)
+      cn_isfdir   = './'         ! directory for all ice shelf input file
+      !
+      ! ---------------- cavities opened -------------------------------
+      !
+      ln_isfcav_mlt = .false.    ! ice shelf melting into the cavity (need ln_isfcav = .true. in domain_cfg.nc)
+         cn_isfcav_mlt = '3eq'   ! ice shelf melting formulation (spe/2eq/3eq/oasis)
+         !                       ! spe = fwfisf is read from a forcing field
+         !                       ! 2eq = ISOMIP  like: 2 equations formulation (Hunter et al., 2006 for a short description)
+         !                       ! 3eq = ISOMIP+ like: 3 equations formulation (Asay-Davis et al., 2016 for a short description)
+         !                       ! oasis = fwfisf is given by oasis and pattern by file sn_isfcav_fwf
+         !              !  cn_isfcav_mlt = 2eq or 3eq cases:
+         cn_gammablk = 'vel'     ! scheme to compute gammat/s (spe,ad15,hj99)
+         !                       ! spe      = constant transfert velocity (rn_gammat0, rn_gammas0)
+         !                       ! vel      = velocity dependent transfert velocity (u* * gammat/s) (Asay-Davis et al. 2016 for a short description)
+         !                       ! vel_stab = velocity and stability dependent transfert coeficient (Holland et al. 1999 for a complete description)
+         rn_gammat0  = 1.4e-2    ! gammat coefficient used in spe, vel and vel_stab gamma computation method
+         rn_gammas0  = 4.0e-4    ! gammas coefficient used in spe, vel and vel_stab gamma computation method
+         !
+         rn_htbl     =  30.      ! thickness of the top boundary layer    (Losh et al. 2008)
+         !                       ! 0 => thickness of the tbl = thickness of the first wet cell
+         !
+         !* 'spe' and 'oasis' case
+         !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
+         !           !  file name  ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+         !           !             !  (if <0  months)  !   name    !  (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
+         sn_isfcav_fwf = 'isfmlt_cav',      -12.      , 'fwflisf'  ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !
+      ! ---------------- cavities parametrised -------------------------------
+      !
+      ln_isfpar_mlt = .false.   ! ice shelf melting parametrised
+         cn_isfpar_mlt = 'spe'  ! ice shelf melting parametrisation (spe/bg03/oasis)
+         !                      ! spe   = fwfisf is read from a forcing field
+         !                      ! bg03  = melt computed using Beckmann and Goosse parametrisation
+         !                      ! oasis = fwfisf is given by oasis and pattern by file sn_isfpar_fwf
+         !
+         !* all cases
+         !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
+         !           !  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_isfpar_zmax = 'isfmlt_par',       0.       ,'sozisfmax',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+         sn_isfpar_zmin = 'isfmlt_par',       0.       ,'sozisfmin',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+         !* 'spe' and 'oasis' case
+         sn_isfpar_fwf = 'isfmlt_par' ,      -12.      ,'sofwfisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+         !* 'bg03' case
+         sn_isfpar_Leff = 'isfmlt_par',       0.       ,'Leff'     ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
+      !
+      ! ---------------- ice sheet coupling -------------------------------
+      !
+      ln_isfcpl = .false.
+         nn_drown       = 10        ! number of iteration of the extrapolation loop (fill the new wet cells)
+         ln_isfcpl_cons = .false.
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namosm_mle
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namosm_mle	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namosm_mle	(revision 14200)
@@ -0,0 +1,14 @@
+!-----------------------------------------------------------------------
+&namosm_mle    !   mixed layer eddy parametrisation (Fox-Kemper)       (default: OFF)
+!-----------------------------------------------------------------------
+   rn_osm_mle_ce       = 0.06      ! magnitude of the MLE (typical value: 0.06 to 0.08)
+   nn_osm_mle          = 0         ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
+   rn_osm_mle_lf       = 5.e+3     ! typical scale of mixed layer front (meters)                      (case rn_osm_mle=0)
+   rn_osm_mle_time     = 172800.   ! time scale for mixing momentum across the mixed layer (seconds)  (case rn_osm_mle=0)
+   rn_osm_mle_lat      = 20.       ! reference latitude (degrees) of MLE coef.                        (case rn_mle=1)
+   rn_osm_mle_rho_c =    0.01      ! delta rho criterion used to calculate MLD for FK
+   rn_osm_mle_thresh  = 0.0005     ! delta b criterion used for FK MLE criterion
+   rn_osm_mle_tau     = 172800.    ! time scale for FK-OSM (seconds)  (case rn_osm_mle=0)
+   ln_osm_hmle_limit   = .false.   ! limit hmle to rn_osm_hmle_limit*hbl
+   rn_osm_hmle_limit   = 1.2
+   /
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampisbc
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampisbc	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampisbc	(revision 14200)
@@ -0,0 +1,22 @@
+!-----------------------------------------------------------------------
+&nampisbc     !   parameters for inputs deposition
+!-----------------------------------------------------------------------
+!              !  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_dust     = 'dust.orca'       ,     -1            , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_ironsed  = 'bathy.orca'      ,    -12            , 'bathy'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   sn_hydrofe  = 'hydrofe.orca'    ,    -12            , 'epsdb'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+!
+   cn_dir      = './'      !  root directory for the location of the dynamical files
+   ln_ironsed  =  .false.   ! boolean for Fe input from sediments
+   ln_ironice  =  .false.   ! boolean for Fe input from sea ice
+   ln_hydrofe  =  .false.   ! boolean for from hydrothermal vents
+   sedfeinput  =  2.e-9    ! Coastal release of Iron
+   distcoast   =  5.e3     ! Distance off the coast for Iron from sediments
+   mfrac       =  0.035    ! Fe mineral fraction of dust
+   wdust       =  2.0      ! Dust sinking speed 
+   icefeinput  =  15.e-9   ! Iron concentration in sea ice
+   hratio      =  1.e+7    ! Fe to 3He ratio assumed for vent iron supply 
+!                          ! ln_ligand
+   lgw_rath    =  0.5      ! Weak ligand ratio from sed hydro sources 
+/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampissbc
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampissbc	(revision 14199)
+++ 	(revision )
@@ -1,39 +1,0 @@
-!-----------------------------------------------------------------------
-&nampissbc     !   parameters for inputs deposition
-!-----------------------------------------------------------------------
-!              !  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_dust     = 'dust.orca'       ,     -1.           , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_solub    = 'solubility.orca' ,    -12.           , 'solubility1' ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdic = 'river.orca'      ,    120.           , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdoc = 'river.orca'      ,    120.           , 'riverdoc'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdin = 'river.orca'      ,    120.           , 'riverdin'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdon = 'river.orca'      ,    120.           , 'riverdon'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdip = 'river.orca'      ,    120.           , 'riverdip'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdop = 'river.orca'      ,    120.           , 'riverdop'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_riverdsi = 'river.orca'      ,    120.           , 'riverdsi'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
-   sn_ndepo    = 'ndeposition.orca',    -12.           , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_ironsed  = 'bathy.orca'      ,    -12.           , 'bathy'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-   sn_hydrofe  = 'hydrofe.orca'    ,    -12.           , 'epsdb'       ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
-!
-   cn_dir      = './'      !  root directory for the location of the dynamical files
-   ln_dust     =  .true.   ! boolean for dust input from the atmosphere
-   ln_solub    =  .true.   ! boolean for variable solubility of atm. Iron
-   ln_river    =  .true.   ! boolean for river input of nutrients
-   ln_ndepo    =  .true.   ! boolean for atmospheric deposition of N
-   ln_ironsed  =  .true.   ! boolean for Fe input from sediments
-   ln_ironice  =  .true.   ! boolean for Fe input from sea ice
-   ln_hydrofe  =  .true.   ! boolean for from hydrothermal vents
-   sedfeinput  =  2.e-9    ! Coastal release of Iron
-   distcoast   =  5.e3     ! Distance off the coast for Iron from sediments
-   dustsolub   =  0.02     ! Solubility of the dusta
-   mfrac       =  0.035    ! Fe mineral fraction of dust
-   wdust       =  2.0      ! Dust sinking speed 
-   icefeinput  =  15.e-9   ! Iron concentration in sea ice
-   nitrfix     =  1.e-7    ! Nitrogen fixation rate
-   diazolight  =  50.      ! Diazotrophs sensitivity to light (W/m2)
-   concfediaz  =  1.e-10   ! Diazotrophs half-saturation Cste for Iron
-   hratio      =  1.e+7    ! Fe to 3He ratio assumed for vent iron supply 
-!                          ! ln_ligand
-   lgw_rath    =  0.5      ! Weak ligand ratio from sed hydro sources 
-/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampissed
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampissed	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/nampissed	(revision 14200)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&nampissed     !   parameters for sediments mobilization
+!-----------------------------------------------------------------------
+   nitrfix     =  1.e-7    ! Nitrogen fixation rate
+   diazolight  =  50.      ! Diazotrophs sensitivity to light (W/m2)
+   concfediaz  =  1.e-10   ! Diazotrophs half-saturation Cste for Iron
+/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namptr
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namptr	(revision 14199)
+++ 	(revision )
@@ -1,6 +1,0 @@
-!-----------------------------------------------------------------------
-&namptr        !   Poleward Transport Diagnostic                        (default: OFF)
-!-----------------------------------------------------------------------
-   ln_diaptr   = .false.   !  Poleward heat and salt transport (T) or not (F)
-   ln_subbas   = .false.   !  Atlantic/Pacific/Indian basins computation (T) or not
-/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsao
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsao	(revision 14199)
+++ 	(revision )
@@ -1,10 +1,0 @@
-!----------------------------------------------------------------------
-!       namsao Stand Alone Observation operator namelist
-!----------------------------------------------------------------------
-!   sao_files     specifies the files containing the model counterpart
-!   nn_sao_idx    specifies the index within the model file
-!   nn_sao_freq   specifies the number of timesteps between file reads
-&namsao
-   sao_files = 'fcst.0.nc'
-   nn_sao_idx = 1
-/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_abl
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_abl	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_abl	(revision 14200)
@@ -0,0 +1,33 @@
+!-----------------------------------------------------------------------
+&namsbc_abl    !   Atmospheric Boundary Layer formulation           (ln_abl = T)
+!-----------------------------------------------------------------------
+   cn_dir           = './'      !  root directory for the location of the ABL grid file
+   cn_dom           = 'dom_cfg_abl.nc'
+
+   cn_ablrst_in     = "restart_abl"   !  suffix of abl restart name (input)
+   cn_ablrst_out    = "restart_abl"   !  suffix of abl restart name (output)
+   cn_ablrst_indir  = "."             !  directory to read   input abl restarts
+   cn_ablrst_outdir = "."             !  directory to write output abl restarts
+
+   ln_rstart_abl  = .false.
+   ln_hpgls_frc   = .false.
+   ln_geos_winds  = .false.
+   ln_smth_pblh   = .false.
+   nn_dyn_restore = 0         ! restoring option for dynamical ABL variables: = 0 no restoring
+                              !                                               = 1 equatorial restoring
+                              !                                               = 2 global restoring
+   rn_ldyn_min   =  4.5       ! dynamics nudging magnitude inside the ABL [hour] (~3 rn_Dt)
+   rn_ldyn_max   =  1.5       ! dynamics nudging magnitude above  the ABL [hour] (~1 rn_Dt)
+   rn_ltra_min   =  4.5       ! tracers  nudging magnitude inside the ABL [hour] (~3 rn_Dt)
+   rn_ltra_max   =  1.5       ! tracers  nudging magnitude above  the ABL [hour] (~1 rn_Dt)
+   nn_amxl       =  0         ! mixing length: = 0 Deardorff 80 length-scale
+                              !                = 1 length-scale based on the distance to the PBL height
+                              !                = 2 Bougeault & Lacarrere 89 length-scale
+                              ! CBR00  ! CCH02  ! MesoNH !
+   rn_Cm          = 0.0667    ! 0.0667 ! 0.1260 ! 0.1260 !
+   rn_Ct          = 0.1667    ! 0.1667 ! 0.1430 ! 0.1430 !
+   rn_Ce          = 0.40      ! 0.40   ! 0.34   ! 0.40   !
+   rn_Ceps        = 0.700     ! 0.700  ! 0.845  ! 0.850  !
+   rn_Ric         = 0.139     ! 0.139  ! 0.143  !   ?    ! Critical Richardson number (to compute PBL height and diffusivities)
+   rn_Rod         = 0.15      ! c0 in RMCA17 mixing length formulation (not yet implemented)
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_fwb
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_fwb	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_fwb	(revision 14200)
@@ -0,0 +1,5 @@
+!-----------------------------------------------------------------------
+&namsbc_fwb    !   freshwater-budget adjustment                         (nn_fwb > 0)
+!-----------------------------------------------------------------------
+   rn_fwb0     = 0.0          ! Initial freshwater adjustment flux [kg/m2/s] (nn_fwb = 2)
+/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_iscpl
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_iscpl	(revision 14199)
+++ 	(revision )
@@ -1,7 +1,0 @@
-!-----------------------------------------------------------------------
-&namsbc_iscpl  !   land ice / ocean coupling option                     (ln_isfcav =T : read (ln_read_cfg=T) 
-!-----------------------------------------------------------------------             or set or usr_def_zgr )
-   nn_drown    = 10        ! number of iteration of the extrapolation loop (fill the new wet cells)
-   ln_hsb      = .false.   ! activate conservation module (conservation exact after a time of rn_fiscpl)
-   nn_fiscpl   = 43800     ! (number of time step) conservation period (maybe should be fix to the coupling frequencey of restart frequency)
-/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_isf
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namsbc_isf	(revision 14199)
+++ 	(revision )
@@ -1,34 +1,0 @@
-!-----------------------------------------------------------------------
-&namsbc_isf    !  Top boundary layer (ISF)                              (ln_isfcav =T : read (ln_read_cfg=T) 
-!-----------------------------------------------------------------------             or set or usr_def_zgr )
-   !                 ! type of top boundary layer 
-   nn_isf      = 1         !  ice shelf melting/freezing
-                           !  1 = presence of ISF   ;  2 = bg03 parametrisation 
-                           !  3 = rnf file for ISF  ;  4 = ISF specified freshwater flux
-                           !  options 1 and 4 need ln_isfcav = .true. (domzgr)
-      !              !  nn_isf = 1 or 2 cases:
-      rn_gammat0  = 1.e-4     ! gammat coefficient used in blk formula
-      rn_gammas0  = 1.e-4     ! gammas coefficient used in blk formula
-      !              !  nn_isf = 1 or 4 cases:
-      rn_hisf_tbl =  30.      ! thickness of the top boundary layer    (Losh et al. 2008)
-      !                       ! 0 => thickness of the tbl = thickness of the first wet cell
-      !              ! nn_isf = 1 case
-      nn_isfblk   = 1         ! 1 ISOMIP  like: 2 equations formulation (Hunter et al., 2006)
-      !                       ! 2 ISOMIP+ like: 3 equations formulation (Asay-Davis et al., 2015)
-      nn_gammablk = 1         ! 0 = cst Gammat (= gammat/s)
-      !                       ! 1 = velocity dependend Gamma (u* * gammat/s)  (Jenkins et al. 2010)
-      !                       ! 2 = velocity and stability dependent Gamma    (Holland et al. 1999)
-
-   !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
-   !           !  file name  ! frequency (hours) ! variable  ! time interp.!  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
-   !           !             !  (if <0  months)  !   name    !  (logical)  !  (T/F)  ! 'monthly' ! filename ! pairing  ! filename      !
-!* nn_isf = 4 case
-   sn_fwfisf   = 'rnfisf'    ,         -12.      ,'sowflisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-!* nn_isf = 3 case
-   sn_rnfisf   = 'rnfisf'    ,         -12.      ,'sofwfisf' ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-!* nn_isf = 2 and 3 cases 
-   sn_depmax_isf ='rnfisf'   ,         -12.      ,'sozisfmax',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-   sn_depmin_isf ='rnfisf'   ,         -12.      ,'sozisfmin',  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-!* nn_isf = 2 case
-   sn_Leff_isf = 'rnfisf'    ,         -12.      ,'Leff'     ,  .false.    , .true.  , 'yearly'  ,    ''    ,   ''     ,    ''
-/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namtile
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namtile	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namtile	(revision 14200)
@@ -0,0 +1,7 @@
+!-----------------------------------------------------------------------
+&namtile        !   parameters of the tiling
+!-----------------------------------------------------------------------
+   ln_tile = .false.     !  Use tiling (T) or not (F)
+   nn_ltile_i = 10       !  Length of tiles in i
+   nn_ltile_j = 10       !  Length of tiles in j
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namtrc_ais
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namtrc_ais	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namtrc_ais	(revision 14200)
@@ -0,0 +1,8 @@
+!-----------------------------------------------------------------------
+&namtrc_ais      !  Representation of Antarctic Ice Sheet tracers supply
+!-----------------------------------------------------------------------
+   nn_ais_tr     =  1        !  tracer concentration in iceberg and ice shelf
+                             !    = 0 (null concentrations)
+                             !    = 1 prescribed concentrations
+   rn_icbdep     =  120.     ! Mean underwater depth of iceberg (m)
+/
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzdf_mfc
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzdf_mfc	(revision 14200)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzdf_mfc	(revision 14200)
@@ -0,0 +1,11 @@
+!-----------------------------------------------------------------------
+&namzdf_mfc     !   Mass Flux Convection
+!-----------------------------------------------------------------------
+   ln_edmfuv  = .false.        ! Activate on velocity fields (Not available yet)
+   rn_cemf    =  1.            ! entrain/detrain coef. (<0 => cte; >0 % depending on dW/dz
+   rn_cwmf    = -0.            ! entrain/detrain coef. (<0 => cte; >0 % depending on dW/dz
+   rn_cent    = 2.e-5          ! entrain of convective area
+   rn_cdet    = 3.e-5          ! detrain of convective area 
+   rn_cap     = 0.9            ! Coef. for CAP estimation
+   App_max    = 0.1            ! Maximum convection area (% of the cell)
+/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzgr_domcfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzgr_domcfg	(revision 14199)
+++ 	(revision )
@@ -1,9 +1,0 @@
-!-----------------------------------------------------------------------
-&namzgr        !   vertical coordinate                                  (default: NO selection)
-!-----------------------------------------------------------------------
-   ln_zco      = .false.   !  z-coordinate - full    steps
-   ln_zps      = .false.   !  z-coordinate - partial steps
-   ln_sco      = .false.   !  s- or hybrid z-s-coordinate
-   ln_isfcav   = .false.   !  ice shelf cavity
-   ln_linssh   = .false.   !  linear free surface
-/
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzgr_sco_domcfg
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/doc/namelists/namzgr_sco_domcfg	(revision 14199)
+++ 	(revision )
@@ -1,25 +1,0 @@
-!-----------------------------------------------------------------------
-&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate                (default F)
-!-----------------------------------------------------------------------
-   ln_s_sh94   = .false.    !  Song & Haidvogel 1994 hybrid S-sigma   (T)|
-   ln_s_sf12   = .false.   !  Siddorn & Furner 2012 hybrid S-z-sigma (T)| if both are false the NEMO tanh stretching is applied
-   ln_sigcrit  = .false.   !  use sigma coordinates below critical depth (T) or Z coordinates (F) for Siddorn & Furner stretch
-                           !  stretching coefficients for all functions
-   rn_sbot_min =   10.0    !  minimum depth of s-bottom surface (>0) (m)
-   rn_sbot_max = 7000.0    !  maximum depth of s-bottom surface (= ocean depth) (>0) (m)
-   rn_hc       =  150.0    !  critical depth for transition to stretched coordinates
-                        !!!!!!!  Envelop bathymetry
-   rn_rmax     =    0.3    !  maximum cut-off r-value allowed (0<r_max<1)
-                        !!!!!!!  SH94 stretching coefficients  (ln_s_sh94 = .true.)
-   rn_theta    =    6.0    !  surface control parameter (0<=theta<=20)
-   rn_bb       =    0.8    !  stretching with SH94 s-sigma
-                        !!!!!!!  SF12 stretching coefficient  (ln_s_sf12 = .true.)
-   rn_alpha    =    4.4    !  stretching with SF12 s-sigma
-   rn_efold    =    0.0    !  efold length scale for transition to stretched coord
-   rn_zs       =    1.0    !  depth of surface grid box
-                           !  bottom cell depth (Zb) is a linear function of water depth Zb = H*a + b
-   rn_zb_a     =    0.024  !  bathymetry scaling factor for calculating Zb
-   rn_zb_b     =   -0.2    !  offset for calculating Zb
-                        !!!!!!!! Other stretching (not SH94 or SF12) [also uses rn_theta above]
-   rn_thetb    =    1.0    !  bottom control parameter  (0<=thetb<= 1)
-/
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/icedyn_rhg_eap.F90	(revision 14200)
@@ -16,5 +16,5 @@
    !!                                           CICE code (Tsamados, Heorton)
    !!----------------------------------------------------------------------
-#if defined key_si3 && ! defined key_agrif
+#if defined key_si3
    !!----------------------------------------------------------------------
    !!   'key_si3'                                       SI3 sea-ice model
@@ -66,5 +66,6 @@
    INTEGER ::   ncvgid   ! netcdf file id
    INTEGER ::   nvarid   ! netcdf variable id
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zmsk00, zmsk15
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   aimsk00
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   eap_res  , aimsk15
    !!----------------------------------------------------------------------
    !! NEMO/ICE 4.0 , NEMO Consortium (2018)
@@ -202,10 +203,20 @@
       IF( kt == nit000 .AND. lwp )   WRITE(numout,*) '-- ice_dyn_rhg_eap: EAP sea-ice rheology'
       !
-      ! for diagnostics and convergence tests
-      ALLOCATE( zmsk00(jpi,jpj), zmsk15(jpi,jpj) )
+      IF( kt == nit000 )  THEN 
+         !
+         ! for diagnostics 
+         ALLOCATE( aimsk00(jpi,jpj) )
+         ! for convergence tests
+         IF( nn_rhg_chkcvg > 0 ) ALLOCATE( eap_res(jpi,jpj), aimsk15(jpi,jpj) )
+      ENDIF
+      !
       DO_2D( 1, 1, 1, 1 )
-         zmsk00(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06  ) ) ! 1 if ice    , 0 if no ice
-         zmsk15(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - 0.15_wp ) ) ! 1 if 15% ice, 0 if less
+         aimsk00(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06  ) ) ! 1 if ice    , 0 if no ice
       END_2D
+      IF( nn_rhg_chkcvg > 0 ) THEN
+         DO_2D( 1, 1, 1, 1 )
+            aimsk15(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - 0.15_wp ) ) ! 1 if 15% ice, 0 if less
+         END_2D
+      ENDIF
       !
 !!gm for Clem:  OPTIMIZATION:  I think zfmask can be computed one for all at the initialization....
@@ -349,11 +360,11 @@
             zvV = 0.5_wp * ( vt_i(ji,jj) * e1e2t(ji,jj) + vt_i(ji,jj+1) * e1e2t(ji,jj+1) ) * r1_e1e2v(ji,jj) * vmask(ji,jj,1)
             ! ice-bottom stress at U points
-            zvCr = zaU(ji,jj) * rn_lf_depfra * hu(ji,jj,Kmm)
+            zvCr = zaU(ji,jj) * rn_lf_depfra * hu(ji,jj,Kmm) * ( 1._wp - icb_mask(ji,jj) ) ! if grounded icebergs are read: ocean depth = 0
             ztaux_base(ji,jj) = - rn_lf_bfr * MAX( 0._wp, zvU - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaU(ji,jj) ) )
             ! ice-bottom stress at V points
-            zvCr = zaV(ji,jj) * rn_lf_depfra * hv(ji,jj,Kmm)
+            zvCr = zaV(ji,jj) * rn_lf_depfra * hv(ji,jj,Kmm) * ( 1._wp - icb_mask(ji,jj) ) ! if grounded icebergs are read: ocean depth = 0
             ztauy_base(ji,jj) = - rn_lf_bfr * MAX( 0._wp, zvV - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaV(ji,jj) ) )
             ! ice_bottom stress at T points
-            zvCr = at_i(ji,jj) * rn_lf_depfra * ht(ji,jj)
+            zvCr = at_i(ji,jj) * rn_lf_depfra * ht(ji,jj) * ( 1._wp - icb_mask(ji,jj) )    ! if grounded icebergs are read: ocean depth = 0
             tau_icebfr(ji,jj) = - rn_lf_bfr * MAX( 0._wp, vt_i(ji,jj) - zvCr ) * EXP( -rn_crhg * ( 1._wp - at_i(ji,jj) ) )
          END_2D
@@ -749,5 +760,5 @@
 
          ! convergence test
-         IF( nn_rhg_chkcvg == 2 )   CALL rhg_cvg( kt, jter, nn_nevp, u_ice, v_ice, zu_ice, zv_ice )
+         IF( nn_rhg_chkcvg == 2 )   CALL rhg_cvg_eap( kt, jter, nn_nevp, u_ice, v_ice, zu_ice, zv_ice )
          !
          !                                                ! ==================== !
@@ -819,17 +830,17 @@
             &                                  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 )
-         CALL iom_put( 'vtau_oi' , ztauy_oi * zmsk00 )
-         CALL iom_put( 'utau_ai' , ztaux_ai * zmsk00 )
-         CALL iom_put( 'vtau_ai' , ztauy_ai * zmsk00 )
-         CALL iom_put( 'utau_bi' , ztaux_bi * zmsk00 )
-         CALL iom_put( 'vtau_bi' , ztauy_bi * zmsk00 )
+         CALL iom_put( 'utau_oi' , ztaux_oi * aimsk00 )
+         CALL iom_put( 'vtau_oi' , ztauy_oi * aimsk00 )
+         CALL iom_put( 'utau_ai' , ztaux_ai * aimsk00 )
+         CALL iom_put( 'vtau_ai' , ztauy_ai * aimsk00 )
+         CALL iom_put( 'utau_bi' , ztaux_bi * aimsk00 )
+         CALL iom_put( 'vtau_bi' , ztauy_bi * aimsk00 )
       ENDIF
 
       ! --- divergence, shear and strength --- !
-      IF( iom_use('icediv') )   CALL iom_put( 'icediv' , pdivu_i  * zmsk00 )   ! divergence
-      IF( iom_use('iceshe') )   CALL iom_put( 'iceshe' , pshear_i * zmsk00 )   ! shear
-      IF( iom_use('icedlt') )   CALL iom_put( 'icedlt' , pdelta_i * zmsk00 )   ! delta
-      IF( iom_use('icestr') )   CALL iom_put( 'icestr' , strength * zmsk00 )   ! strength
+      IF( iom_use('icediv') )   CALL iom_put( 'icediv' , pdivu_i  * aimsk00 )   ! divergence
+      IF( iom_use('iceshe') )   CALL iom_put( 'iceshe' , pshear_i * aimsk00 )   ! shear
+      IF( iom_use('icedlt') )   CALL iom_put( 'icedlt' , pdelta_i * aimsk00 )   ! delta
+      IF( iom_use('icestr') )   CALL iom_put( 'icestr' , strength * aimsk00 )   ! strength
 
       ! --- Stress tensor invariants (SIMIP diags) --- !
@@ -856,6 +867,6 @@
          !
          ! Stress tensor invariants (normal and shear stress N/m) - SIMIP diags - definitions following Coon (1974) and Feltham (2008)
-         IF( iom_use('normstr') )   CALL iom_put( 'normstr', zsig_I (:,:) * zmsk00(:,:) ) ! Normal stress
-         IF( iom_use('sheastr') )   CALL iom_put( 'sheastr', zsig_II(:,:) * zmsk00(:,:) ) ! Maximum shear stress
+         IF( iom_use('normstr') )   CALL iom_put( 'normstr', zsig_I (:,:) * aimsk00(:,:) ) ! Normal stress
+         IF( iom_use('sheastr') )   CALL iom_put( 'sheastr', zsig_II(:,:) * aimsk00(:,:) ) ! Maximum shear stress
 
          DEALLOCATE ( zsig_I, zsig_II )
@@ -903,7 +914,7 @@
          CALL lbc_lnk_multi( 'icedyn_rhg_eap', zyield11, 'T', 1.0_wp, zyield22, 'T', 1.0_wp, zyield12, 'T', 1.0_wp )
 
-         CALL iom_put( 'yield11', zyield11 * zmsk00 )
-         CALL iom_put( 'yield22', zyield22 * zmsk00 )
-         CALL iom_put( 'yield12', zyield12 * zmsk00 )
+         CALL iom_put( 'yield11', zyield11 * aimsk00 )
+         CALL iom_put( 'yield22', zyield22 * aimsk00 )
+         CALL iom_put( 'yield12', zyield12 * aimsk00 )
       ENDIF
 
@@ -911,5 +922,5 @@
       IF( iom_use('aniso') ) THEN
          CALL lbc_lnk( 'icedyn_rhg_eap', paniso_11, 'T', 1.0_wp )
-         CALL iom_put( 'aniso' , paniso_11 * zmsk00 )
+         CALL iom_put( 'aniso' , paniso_11 * aimsk00 )
       ENDIF
 
@@ -922,10 +933,10 @@
             &                                    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)
-         CALL iom_put( 'dssh_dy' , zspgV * zmsk00 )   ! Sea-surface tilt term in force balance (y)
-         CALL iom_put( 'corstrx' , zCorU * zmsk00 )   ! Coriolis force term in force balance (x)
-         CALL iom_put( 'corstry' , zCorV * zmsk00 )   ! Coriolis force term in force balance (y)
-         CALL iom_put( 'intstrx' , zfU   * zmsk00 )   ! Internal force term in force balance (x)
-         CALL iom_put( 'intstry' , zfV   * zmsk00 )   ! Internal force term in force balance (y)
+         CALL iom_put( 'dssh_dx' , zspgU * aimsk00 )   ! Sea-surface tilt term in force balance (x)
+         CALL iom_put( 'dssh_dy' , zspgV * aimsk00 )   ! Sea-surface tilt term in force balance (y)
+         CALL iom_put( 'corstrx' , zCorU * aimsk00 )   ! Coriolis force term in force balance (x)
+         CALL iom_put( 'corstry' , zCorV * aimsk00 )   ! Coriolis force term in force balance (y)
+         CALL iom_put( 'intstrx' , zfU   * aimsk00 )   ! Internal force term in force balance (x)
+         CALL iom_put( 'intstry' , zfV   * aimsk00 )   ! Internal force term in force balance (y)
       ENDIF
 
@@ -938,6 +949,6 @@
          DO_2D( 0, 0, 0, 0 )
             ! 2D ice mass, snow mass, area transport arrays (X, Y)
-            zfac_x = 0.5 * u_ice(ji,jj) * e2u(ji,jj) * zmsk00(ji,jj)
-            zfac_y = 0.5 * v_ice(ji,jj) * e1v(ji,jj) * zmsk00(ji,jj)
+            zfac_x = 0.5 * u_ice(ji,jj) * e2u(ji,jj) * aimsk00(ji,jj)
+            zfac_y = 0.5 * v_ice(ji,jj) * e1v(ji,jj) * aimsk00(ji,jj)
 
             zdiag_xmtrp_ice(ji,jj) = rhoi * zfac_x * ( vt_i(ji+1,jj) + vt_i(ji,jj) ) ! ice mass transport, X-component
@@ -973,20 +984,18 @@
             IF( ln_aEVP ) THEN   ! output: beta * ( u(t=nn_nevp) - u(t=nn_nevp-1) )
                CALL iom_put( 'uice_cvg', MAX( ABS( u_ice(:,:) - zu_ice(:,:) ) * zbeta(:,:) * umask(:,:,1) , &
-                  &                           ABS( v_ice(:,:) - zv_ice(:,:) ) * zbeta(:,:) * vmask(:,:,1) ) * zmsk15(:,:) )
+                  &                           ABS( v_ice(:,:) - zv_ice(:,:) ) * zbeta(:,:) * vmask(:,:,1) ) * aimsk15(:,:) )
             ELSE                 ! output: nn_nevp * ( u(t=nn_nevp) - u(t=nn_nevp-1) )
                CALL iom_put( 'uice_cvg', REAL( nn_nevp ) * MAX( ABS( u_ice(:,:) - zu_ice(:,:) ) * umask(:,:,1) , &
-                  &                                             ABS( v_ice(:,:) - zv_ice(:,:) ) * vmask(:,:,1) ) * zmsk15(:,:) )
+                  &                                             ABS( v_ice(:,:) - zv_ice(:,:) ) * vmask(:,:,1) ) * aimsk15(:,:) )
             ENDIF
          ENDIF
       ENDIF
       !
-      DEALLOCATE( zmsk00, zmsk15 )
-      !
    END SUBROUTINE ice_dyn_rhg_eap
 
 
-   SUBROUTINE rhg_cvg( kt, kiter, kitermax, pu, pv, pub, pvb )
+   SUBROUTINE rhg_cvg_eap( kt, kiter, kitermax, pu, pv, pub, pvb )
       !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE rhg_cvg  ***
+      !!                    ***  ROUTINE rhg_cvg_eap  ***
       !!
       !! ** Purpose :   check convergence of oce rheology
@@ -1006,5 +1015,4 @@
       REAL(wp)          ::   zresm           ! local real
       CHARACTER(len=20) ::   clname
-      REAL(wp), DIMENSION(jpi,jpj) ::   zres           ! check convergence
       !!----------------------------------------------------------------------
 
@@ -1014,5 +1022,5 @@
          IF( lwp ) THEN
             WRITE(numout,*)
-            WRITE(numout,*) 'rhg_cvg : ice rheology convergence control'
+            WRITE(numout,*) 'rhg_cvg_eap : ice rheology convergence control'
             WRITE(numout,*) '~~~~~~~'
          ENDIF
@@ -1037,8 +1045,9 @@
       ELSE
          DO_2D( 1, 1, 1, 1 )
-            zres(ji,jj) = MAX( ABS( pu(ji,jj) - pub(ji,jj) ) * umask(ji,jj,1), &
-               &               ABS( pv(ji,jj) - pvb(ji,jj) ) * vmask(ji,jj,1) ) * zmsk15(ji,jj)
+            eap_res(ji,jj) = MAX( ABS( pu(ji,jj) - pub(ji,jj) ) * umask(ji,jj,1), &
+               &               ABS( pv(ji,jj) - pvb(ji,jj) ) * vmask(ji,jj,1) ) * aimsk15(ji,jj)
          END_2D
-         zresm = MAXVAL( zres )
+
+         zresm = MAXVAL( eap_res )
          CALL mpp_max( 'icedyn_rhg_evp', zresm )   ! max over the global domain
       ENDIF
@@ -1051,5 +1060,5 @@
       ENDIF
 
-   END SUBROUTINE rhg_cvg
+   END SUBROUTINE rhg_cvg_eap
 
 
@@ -1080,20 +1089,18 @@
       REAL(wp) ::   zsig11, zsig12, zsig22
       REAL(wp) ::   zsgprm11, zsgprm12, zsgprm22
-      REAL(wp) ::   zinvstressconviso
       REAL(wp) ::   zAngle_denom_gamma,  zAngle_denom_alpha
       REAL(wp) ::   zTany_1, zTany_2
-      REAL(wp) ::   zx, zy, zdx, zdy, zda, zkxw, kyw, kaw
+      REAL(wp) ::   zx, zy, zkxw, kyw, kaw
       REAL(wp) ::   zinvdx, zinvdy, zinvda
-      REAL(wp) ::   zdtemp1, zdtemp2, zatempprime, zinvsin
-
-      REAL(wp), PARAMETER ::   kfriction = 0.45_wp
-      !!---------------------------------------------------------------------
+      REAL(wp) ::   zdtemp1, zdtemp2, zatempprime
+
+      REAL(wp), PARAMETER ::   ppkfriction = 0.45_wp
       ! Factor to maintain the same stress as in EVP (see Section 3)
       ! Can be set to 1 otherwise
-!      zinvstressconviso = 1._wp/(1._wp+kfriction*kfriction)
-      zinvstressconviso = 1._wp
-
-      zinvsin = 1._wp/sin(2._wp*pphi) * zinvstressconviso
-      !now uses phi as set in higher code
+!     REAL(wp), PARAMETER ::   ppinvstressconviso = 1._wp/(1._wp+ppkfriction*ppkfriction)
+      REAL(wp), PARAMETER ::   ppinvstressconviso = 1._wp
+
+      ! next statement uses pphi set in main module (icedyn_rhg_eap)
+      REAL(wp), PARAMETER ::   ppinvsin = 1._wp/sin(2._wp*pphi) * ppinvstressconviso
 
       ! compute eigenvalues, eigenvectors and angles for structure tensor, strain
@@ -1175,10 +1182,7 @@
 
       ! 3) update anisotropic stress tensor
-      zdx   = rpi/real(nx_yield-1,kind=wp)
-      zdy   = rpi/real(ny_yield-1,kind=wp)
-      zda   = 0.5_wp/real(na_yield-1,kind=wp)
-      zinvdx = 1._wp/zdx
-      zinvdy = 1._wp/zdy
-      zinvda = 1._wp/zda
+      zinvdx = real(nx_yield-1,kind=wp)/rpi
+      zinvdy = real(ny_yield-1,kind=wp)/rpi
+      zinvda = 2._wp*real(na_yield-1,kind=wp)
 
       ! % need 8 coords and 8 weights
@@ -1258,7 +1262,7 @@
       ! Tsamados 2013)
 
-      zsig11  = pstrength*(zstemp11r + kfriction*zstemp11s) * zinvsin
-      zsig12  = pstrength*(zstemp12r + kfriction*zstemp12s) * zinvsin
-      zsig22  = pstrength*(zstemp22r + kfriction*zstemp22s) * zinvsin
+      zsig11  = pstrength*(zstemp11r + ppkfriction*zstemp11s) * ppinvsin
+      zsig12  = pstrength*(zstemp12r + ppkfriction*zstemp12s) * ppinvsin
+      zsig22  = pstrength*(zstemp22r + ppkfriction*zstemp22s) * ppinvsin
 
       ! Back - rotation of the stress from principal axes into general coordinates
@@ -1319,7 +1323,7 @@
       REAL (wp) ::   zQ11, zQ12, zQ11Q11, zQ11Q12, zQ12Q12
 
-!!$      REAL (wp), PARAMETER ::   kfrac = 0.0001_wp   ! rate of fracture formation
-      REAL (wp), PARAMETER ::   kfrac = 1.e-3_wp   ! rate of fracture formation
-      REAL (wp), PARAMETER ::   threshold = 0.3_wp  ! critical confinement ratio
+!!$   REAL (wp), PARAMETER ::   ppkfrac = 0.0001_wp   ! rate of fracture formation
+      REAL (wp), PARAMETER ::   ppkfrac = 1.e-3_wp    ! rate of fracture formation
+      REAL (wp), PARAMETER ::   ppthreshold = 0.3_wp  ! critical confinement ratio
       !!---------------------------------------------------------------
       !
@@ -1363,6 +1367,6 @@
       ! which leads to the loss of their shape, so we again model it through diffusion
       ELSEIF ((zsigma_1 >= 0.0_wp).AND.(zsigma_2 < 0.0_wp))  THEN
-         pmresult11 = - kfrac * (pa11 - zQ12Q12)
-         pmresult12 = - kfrac * (pa12 + zQ11Q12)
+         pmresult11 = - ppkfrac * (pa11 - zQ12Q12)
+         pmresult12 = - ppkfrac * (pa12 + zQ11Q12)
 
       ! Shear faulting
@@ -1370,7 +1374,7 @@
          pmresult11 = 0.0_wp
          pmresult12 = 0.0_wp
-      ELSEIF ((zsigma_1 <= 0.0_wp).AND.(zsigma_1/zsigma_2 <= threshold)) THEN
-         pmresult11 = - kfrac * (pa11 - zQ12Q12)
-         pmresult12 = - kfrac * (pa12 + zQ11Q12)
+      ELSEIF ((zsigma_1 <= 0.0_wp).AND.(zsigma_1/zsigma_2 <= ppthreshold)) THEN
+         pmresult11 = - ppkfrac * (pa11 - zQ12Q12)
+         pmresult12 = - ppkfrac * (pa12 + zQ11Q12)
 
       ! Horizontal spalling
@@ -1405,5 +1409,6 @@
       !!clem
       REAL(wp) ::   zw1, zw2, zfac, ztemp
-      REAL(wp) ::   idx, idy, idz
+      REAL(wp) ::   zidx, zidy, zidz
+      REAL(wp) ::   zsaak(6)                  ! temporary array
 
       REAL(wp), PARAMETER           ::   eps6 = 1.0e-6_wp
@@ -1522,33 +1527,36 @@
             zw2 = w2(ainit+ia*da)
             DO iz = 1, nz
-               idz = zinit+iz*dz
+               zidz = zinit+iz*dz
                ztemp = zw1 * EXP(-zw2*(zinit+iz*dz)*(zinit+iz*dz))
                DO iy = 1, ny_yield
-                  idy = yinit+iy*dy
+                  zidy = yinit+iy*dy
                   DO ix = 1, nx_yield
-                     idx = xinit+ix*dx
-                     s11r(ix,iy,ia) = s11r(ix,iy,ia) + ztemp * s11kr(idx,idy,idz)*zfac
-                     s12r(ix,iy,ia) = s12r(ix,iy,ia) + ztemp * s12kr(idx,idy,idz)*zfac
-                     s22r(ix,iy,ia) = s22r(ix,iy,ia) + ztemp * s22kr(idx,idy,idz)*zfac
-                     s11s(ix,iy,ia) = s11s(ix,iy,ia) + ztemp * s11ks(idx,idy,idz)*zfac
-                     s12s(ix,iy,ia) = s12s(ix,iy,ia) + ztemp * s12ks(idx,idy,idz)*zfac
-                     s22s(ix,iy,ia) = s22s(ix,iy,ia) + ztemp * s22ks(idx,idy,idz)*zfac
+                     zidx = xinit+ix*dx
+                     call all_skr_sks(zidx,zidy,zidz,zsaak)
+                     zsaak = ztemp*zsaak*zfac
+                     s11r(ix,iy,ia) = s11r(ix,iy,ia) + zsaak(1)
+                     s12r(ix,iy,ia) = s12r(ix,iy,ia) + zsaak(2)
+                     s22r(ix,iy,ia) = s22r(ix,iy,ia) + zsaak(3)
+                     s11s(ix,iy,ia) = s11s(ix,iy,ia) + zsaak(4)
+                     s12s(ix,iy,ia) = s12s(ix,iy,ia) + zsaak(5)
+                     s22s(ix,iy,ia) = s22s(ix,iy,ia) + zsaak(6)
                   END DO
                END DO
             END DO
          END DO
-
          zfac = 1._wp/sin(2._wp*pphi)
          ia = na_yield
          DO iy = 1, ny_yield
-            idy = yinit+iy*dy
+            zidy = yinit+iy*dy
             DO ix = 1, nx_yield
-               idx = xinit+ix*dx
-               s11r(ix,iy,ia) = 0.5_wp*s11kr(idx,idy,0._wp)*zfac
-               s12r(ix,iy,ia) = 0.5_wp*s12kr(idx,idy,0._wp)*zfac
-               s22r(ix,iy,ia) = 0.5_wp*s22kr(idx,idy,0._wp)*zfac
-               s11s(ix,iy,ia) = 0.5_wp*s11ks(idx,idy,0._wp)*zfac
-               s12s(ix,iy,ia) = 0.5_wp*s12ks(idx,idy,0._wp)*zfac
-               s22s(ix,iy,ia) = 0.5_wp*s22ks(idx,idy,0._wp)*zfac
+               zidx = xinit+ix*dx
+               call all_skr_sks(zidx,zidy,0._wp,zsaak)
+               zsaak = 0.5_wp*zsaak*zfac
+               s11r(ix,iy,ia) = zsaak(1)
+               s12r(ix,iy,ia) = zsaak(2)
+               s22r(ix,iy,ia) = zsaak(3)
+               s11s(ix,iy,ia) = zsaak(4)
+               s12s(ix,iy,ia) = zsaak(5)
+               s22s(ix,iy,ia) = zsaak(6)
             ENDDO
          ENDDO
@@ -1616,12 +1624,12 @@
    END FUNCTION w2
 
-   FUNCTION s11kr(px,py,pz)
-      !!-------------------------------------------------------------------
-      !! Function : s11kr
-      !!-------------------------------------------------------------------
+   SUBROUTINE all_skr_sks( px, py, pz, allsk )
       REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s11kr, zpih
-
+      REAL(wp), INTENT(out  ) ::   allsk(6)
+
+      REAL(wp) ::   zs12r0, zs21r0
+      REAL(wp) ::   zs12s0, zs21s0
+
+      REAL(wp) ::   zpih
       REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
       REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
@@ -1673,296 +1681,34 @@
       ENDIF
 
-      s11kr = (- zHen1t2 * zn1t2i11 - zHen2t1 * zn2t1i11)
-
-   END FUNCTION s11kr
-
-   FUNCTION s12kr(px,py,pz)
+      !!-------------------------------------------------------------------
+      !! Function : s11kr
+      !!-------------------------------------------------------------------
+      allsk(1) = (- zHen1t2 * zn1t2i11 - zHen2t1 * zn2t1i11)
       !!-------------------------------------------------------------------
       !! Function : s12kr
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s12kr, zs12r0, zs21r0, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
       zs12r0 = (- zHen1t2 * zn1t2i12 - zHen2t1 * zn2t1i12)
       zs21r0 = (- zHen1t2 * zn1t2i21 - zHen2t1 * zn2t1i21)
-      s12kr=0.5_wp*(zs12r0+zs21r0)
-
-   END FUNCTION s12kr
-
-   FUNCTION s22kr(px,py,pz)
+      allsk(2)=0.5_wp*(zs12r0+zs21r0)
       !!-------------------------------------------------------------------
       !! Function : s22kr
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s22kr, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
-      s22kr = (- zHen1t2 * zn1t2i22 - zHen2t1 * zn2t1i22)
-
-   END FUNCTION s22kr
-
-   FUNCTION s11ks(px,py,pz)
+      allsk(3) = (- zHen1t2 * zn1t2i22 - zHen2t1 * zn2t1i22)
       !!-------------------------------------------------------------------
       !! Function : s11ks
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s11ks, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
-      s11ks = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i11 + zHen2t1 * zt2t1i11)
-
-   END FUNCTION s11ks
-
-   FUNCTION s12ks(px,py,pz)
+
+      allsk(4) = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i11 + zHen2t1 * zt2t1i11)
       !!-------------------------------------------------------------------
       !! Function : s12ks
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s12ks, zs12s0, zs21s0, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
       zs12s0 = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i12 + zHen2t1 * zt2t1i12)
       zs21s0 = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i21 + zHen2t1 * zt2t1i21)
-      s12ks=0.5_wp*(zs12s0+zs21s0)
-
-   END FUNCTION s12ks
-
-   FUNCTION s22ks(px,py,pz)
+      allsk(5)=0.5_wp*(zs12s0+zs21s0)
       !!-------------------------------------------------------------------
       !! Function : s22ks
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s22ks, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
-      s22ks = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i22 + zHen2t1 * zt2t1i22)
-
-   END FUNCTION s22ks
+      allsk(6) = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i22 + zHen2t1 * zt2t1i22)
+   END SUBROUTINE all_skr_sks
 
 #else
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/iceistate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/iceistate.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/ICE/iceistate.F90	(revision 14200)
@@ -22,5 +22,7 @@
    USE eosbn2         ! equation of state
 # if defined key_qco
-   USE domqco         ! Variable volume
+   USE domqco         ! Quasi-Eulerian coord.
+# elif defined key_linssh
+   !                  ! Fix in time coord.
 # else
    USE domvvl         ! Variable volume
@@ -424,5 +426,7 @@
          !
 #if defined key_qco
-         IF( .NOT.ln_linssh )   CALL dom_qco_zgr( Kbb, Kmm )        ! interpolation scale factor, depth and water column
+         IF( .NOT.ln_linssh )   CALL dom_qco_zgr( Kbb, Kmm )        ! upadte of r3=ssh/h0 ratios
+#elif defined key_linssh
+         !                                                          ! fix in time coord. : no update of vertical coord.
 #else
          IF( .NOT.ln_linssh )   CALL dom_vvl_zgr( Kbb, Kmm, Kaa )   ! interpolation scale factor, depth and water column
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_ice_interp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_ice_interp.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_ice_interp.F90	(revision 14200)
@@ -69,24 +69,7 @@
       Agrif_UseSpecialValue = .FALSE.
       ! lbc ????
-      ! JC: do we really need the 3 lines below ?
+      !
       CALL ice_var_glo2eqv
-      CALL ice_var_zapsmall
-      CALL ice_var_agg(2)
-
-      ! Melt ponds
-      WHERE( a_i > epsi10 )
-         a_ip_frac(:,:,:) = a_ip(:,:,:) / a_i(:,:,:)
-      ELSEWHERE
-         a_ip_frac(:,:,:) = 0._wp
-      END WHERE
-      WHERE( a_ip > 0._wp )       ! ???????    
-         h_ip(:,:,:) = v_ip(:,:,:) / a_ip(:,:,:)
-      ELSEWHERE
-         h_ip(:,:,:) = 0._wp
-      END WHERE   
-
-      tn_ice(:,:,:) = t_su(:,:,:)
-      t1_ice(:,:,:) = t_i (:,:,1,:) 
-
+      !
    END SUBROUTINE agrif_istate_ice
 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_interp.F90	(revision 14200)
@@ -76,7 +76,4 @@
       IF(lwp) WRITE(numout,*) ' '
 
-      IF ( ln_rstart ) & 
-         & CALL ctl_stop('AGRIF hot start should be desactivated in restarting mode')
-
       IF ( .NOT.Agrif_Parent(l_1st_euler) ) & 
          & CALL ctl_stop('AGRIF hot start requires to force Euler first step on parent')
@@ -86,13 +83,11 @@
       Agrif_UseSpecialValue = .TRUE.
 
-      ts(:,:,:,:,:) = 0.0_wp
-      uu(:,:,:,:)   = 0.0_wp
-      vv(:,:,:,:)   = 0.0_wp 
-      ssh(:,:,:)    = 0._wp
+      ts(:,:,:,:,Kbb) = 0.0_wp
+      uu(:,:,:,Kbb)   = 0.0_wp
+      vv(:,:,:,Kbb)   = 0.0_wp 
        
       Krhs_a = Kbb   ;   Kmm_a = Kbb
 
       CALL Agrif_Init_Variable(tsini_id, procname=interptsn)
-      CALL Agrif_Init_Variable(sshini_id, procname=interpsshn)
 
       Agrif_UseSpecialValue = ln_spc_dyn
@@ -108,6 +103,4 @@
       Krhs_a = Kaa   ;   Kmm_a = Kmm
 
-      ssh(:,:,Kbb) = ssh(:,:,Kbb) * tmask(:,:,1)
-
       DO jn = 1, jpts
          ts(:,:,:,jn,Kbb) = ts(:,:,:,jn,Kbb) * tmask(:,:,:)
@@ -118,10 +111,9 @@
       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', ts(:,:,:,:,Kbb), 'T',  1.0_wp )
-      CALL lbc_lnk( 'agrif_istate_oce', ssh(:,:,Kbb), 'T', 1.0_wp )
 
    END SUBROUTINE Agrif_istate_oce
 
 
-   SUBROUTINE Agrif_istate_ssh( Kbb, Kmm )
+   SUBROUTINE Agrif_istate_ssh( Kbb, Kmm, Kaa )
       !!----------------------------------------------------------------------
       !!                 *** ROUTINE agrif_istate_ssh ***
@@ -132,5 +124,5 @@
       IMPLICIT NONE
       !
-      INTEGER, INTENT(in)  :: Kbb, Kmm 
+      INTEGER, INTENT(in)  :: Kbb, Kmm, Kaa 
       !!----------------------------------------------------------------------
       IF(lwp) WRITE(numout,*) ' '
@@ -139,22 +131,25 @@
       IF(lwp) WRITE(numout,*) ' '
 
-      IF ( ln_rstart ) & 
-         & CALL ctl_stop('AGRIF hot start should be desactivated in restarting mode')
-
       IF ( .NOT.Agrif_Parent(l_1st_euler) ) & 
          & CALL ctl_stop('AGRIF hot start requires to force Euler first step on parent')
 
-      Kmm_a = Kmm
-      ssh(:,:,Kmm) = 0._wp
-
+      Krhs_a = Kbb   ;   Kmm_a = Kbb
+      !
       Agrif_SpecialValue    = 0._wp
       Agrif_UseSpecialValue = .TRUE.
       l_ini_child           = .TRUE.
       !
+      ssh(:,:,Kbb) = 0._wp
       CALL Agrif_Init_Variable(sshini_id, procname=interpsshn)
       !
       Agrif_UseSpecialValue = .FALSE.
       l_ini_child           = .FALSE.
-      CALL lbc_lnk( 'dom_vvl_rst', ssh(:,:,Kmm), 'T', 1._wp )
+      !
+      Krhs_a = Kaa   ;   Kmm_a = Kmm
+      !
+      CALL lbc_lnk( 'Agrif_istate_ssh', ssh(:,:,Kbb), 'T', 1._wp )
+      !
+      ssh(:,:,Kmm) = ssh(:,:,Kbb)
+      ssh(:,:,Kaa) = 0._wp
 
    END SUBROUTINE Agrif_istate_ssh
@@ -203,5 +198,6 @@
 
       IF( .NOT.ln_dynspg_ts ) THEN ! Get transports
-         ubdy(:,:) = 0._wp   ;   vbdy(:,:) = 0._wp 
+         ubdy(:,:) = 0._wp    ;  vbdy(:,:) = 0._wp
+         utint_stage(:,:) = 0 ;  vtint_stage(:,:) = 0
          CALL Agrif_Bc_variable( unb_interp_id, procname=interpunb )
          CALL Agrif_Bc_variable( vnb_interp_id, procname=interpvnb )
@@ -274,10 +270,4 @@
          IF( .NOT.ln_dynspg_ts ) THEN 
             DO ji = mi0(ibdy1), mi1(ibdy2)
-               uu_b(ji,:,Krhs_a) = 0._wp
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     uu_b(ji,jj,Krhs_a) = uu_b(ji,jj,Krhs_a) + e3u(ji,jj,jk,Krhs_a) * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
-                  END DO
-               END DO
                DO jj = 1, jpj
                   uu_b(ji,jj,Krhs_a) = ubdy(ji,jj) * r1_hu(ji,jj,Krhs_a)
@@ -304,13 +294,8 @@
          !
          ibdy1 = jpiglo - ( nn_hls + nbghostcells ) - nn_shift_bar*Agrif_Rhox() 
-         ibdy2 = jpiglo - ( nn_hls + 1 )              !
+         ibdy2 = jpiglo - ( nn_hls + 1 )     
+         !
          IF( .NOT.ln_dynspg_ts ) THEN 
             DO ji = mi0(ibdy1), mi1(ibdy2)
-               vv_b(ji,:,Krhs_a) = 0._wp
-               DO jk = 1, jpkm1
-                  DO jj = 1, jpj
-                     vv_b(ji,jj,Krhs_a) = vv_b(ji,jj,Krhs_a) + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
-                  END DO
-               END DO
                DO jj = 1, jpj
                   vv_b(ji,jj,Krhs_a) = vbdy(ji,jj) * r1_hv(ji,jj,Krhs_a)
@@ -318,5 +303,5 @@
             END DO
          ENDIF
-
+         !
          DO ji = mi0(ibdy1), mi1(ibdy2)
             zvb(ji,:) = 0._wp
@@ -345,13 +330,7 @@
          IF( .NOT.ln_dynspg_ts ) THEN
             DO jj = mj0(jbdy1), mj1(jbdy2)
-               vv_b(:,jj,Krhs_a) = 0._wp
-               DO jk = 1, jpkm1
-                  DO ji = 1, jpi
-                     vv_b(ji,jj,Krhs_a) = vv_b(ji,jj,Krhs_a) + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
-                  END DO
-               END DO
-               DO ji=1,jpi
-                  vv_b(ji,jj,Krhs_a) = vv_b(ji,jj,Krhs_a) * r1_hv(ji,jj,Krhs_a) 
-                  uu_b(ji,jj,Krhs_a) = uu_b(ji,jj,Krhs_a) * r1_hu(ji,jj,Krhs_a)
+               DO ji = 1, jpi
+                  uu_b(ji,jj,Krhs_a) = ubdy(ji,jj) * r1_hu(ji,jj,Krhs_a)
+                  vv_b(ji,jj,Krhs_a) = vbdy(ji,jj) * r1_hv(ji,jj,Krhs_a)
                END DO
             END DO
@@ -401,11 +380,5 @@
          IF( .NOT.ln_dynspg_ts ) THEN
             DO jj = mj0(jbdy1), mj1(jbdy2)
-               vv_b(:,jj,Krhs_a) = 0._wp
-               DO jk = 1, jpkm1
-                  DO ji = 1, jpi
-                     vv_b(ji,jj,Krhs_a) = vv_b(ji,jj,Krhs_a) + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
-                  END DO
-               END DO
-               DO ji=1,jpi
+               DO ji = 1, jpi
                   vv_b(ji,jj,Krhs_a) = vbdy(ji,jj) * r1_hv(ji,jj,Krhs_a)
                END DO
@@ -432,18 +405,13 @@
          jbdy1 = jpjglo - ( nn_hls + nbghostcells ) - nn_shift_bar*Agrif_Rhoy()  
          jbdy2 = jpjglo - ( nn_hls + 1 )
+         !
          IF( .NOT.ln_dynspg_ts ) THEN
             DO jj = mj0(jbdy1), mj1(jbdy2)
-               uu_b(:,jj,Krhs_a) = 0._wp
-               DO jk = 1, jpkm1
-                  DO ji = 1, jpi
-                     uu_b(ji,jj,Krhs_a) = uu_b(ji,jj,Krhs_a) + e3u(ji,jj,jk,Krhs_a) * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
-                  END DO
-               END DO
-               DO ji=1,jpi
+               DO ji = 1, jpi
                   uu_b(ji,jj,Krhs_a) = ubdy(ji,jj) * r1_hu(ji,jj,Krhs_a)
                END DO
             END DO
          ENDIF
-
+         !
          DO jj = mj0(jbdy1), mj1(jbdy2)
             zub(:,jj) = 0._wp
@@ -651,9 +619,10 @@
       IF( ll_int_cons ) THEN  ! Conservative interpolation
          IF ( lk_tint2d_notinterp ) THEN
+            Agrif_UseSpecialValue = .FALSE.
             CALL Agrif_Bc_variable( ub2b_interp_id, calledweight=1._wp, procname=interpub2b_const )
             CALL Agrif_Bc_variable( vb2b_interp_id, calledweight=1._wp, procname=interpvb2b_const ) 
             ! Divergence conserving correction terms:
-            CALL Agrif_Bc_variable(    ub2b_cor_id, calledweight=1._wp, procname=        ub2b_cor )
-            CALL Agrif_Bc_variable(    vb2b_cor_id, calledweight=1._wp, procname=        vb2b_cor )
+            IF ( Agrif_Rhox()>1 ) CALL Agrif_Bc_variable(    ub2b_cor_id, calledweight=1._wp, procname=ub2b_cor )
+            IF ( Agrif_Rhoy()>1 ) CALL Agrif_Bc_variable(    vb2b_cor_id, calledweight=1._wp, procname=vb2b_cor )
          ELSE
             ! order matters here !!!!!!
@@ -990,5 +959,5 @@
       ELSE
          IF( l_ini_child ) THEN
-            ssh(i1:i2,j1:j2,Kmm_a) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
+            ssh(i1:i2,j1:j2,Krhs_a) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
          ELSE
             hbdy(i1:i2,j1:j2) = ptab(i1:i2,j1:j2) * tmask(i1:i2,j1:j2,1)
@@ -1438,5 +1407,5 @@
          ptab(:,:) = 0._wp
          DO ji=i1+1,i2-1
-            DO jj=j1+1,j2
+            DO jj=j1+1,j2-1
                ptab(ji,jj) = 0.25_wp*( ( vb2_b(ji+1,jj  )*e1v(ji+1,jj  )   & 
                            &            -vb2_b(ji-1,jj  )*e1v(ji-1,jj  ) ) &
@@ -1542,5 +1511,5 @@
          ptab(:,:) = 0._wp
          DO ji=i1+1,i2-1
-            DO jj=j1+1,j2
+            DO jj=j1+1,j2-1
                ptab(ji,jj) = 0.25_wp*( ( ub2_b(ji  ,jj+1)*e2u(ji  ,jj+1)   & 
                            &            -ub2_b(ji  ,jj-1)*e2u(ji  ,jj-1) ) &
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_sponge.F90	(revision 14200)
@@ -441,20 +441,21 @@
                   N_in = mbkt_parent(ji,jj)
                   ! Input grid (account for partial cells if any):
-                  DO jk=1,N_in
-                     z_in(jk) = tabres(ji,jj,jk,n2) - tabres(ji,jj,k2,n2)
-                     tabin(jk,1:jpts) = tabres(ji,jj,jk,1:jpts)
-                  END DO
+                  IF ( N_in > 0 ) THEN 
+                     DO jk=1,N_in
+                        z_in(jk) = tabres(ji,jj,jk,n2) - tabres(ji,jj,k2,n2)
+                        tabin(jk,1:jpts) = tabres(ji,jj,jk,1:jpts)
+                     END DO
                   
-                  ! Intermediate grid:
-                  DO jk = 1, N_in
-                     h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
-                       &       (1._wp + tabres(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)  - tabres(ji,jj,k2,n2)
-
+                     ! Intermediate grid:
+                     DO jk = 1, N_in
+                        h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
+                          &       (1._wp + tabres(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)  - tabres(ji,jj,k2,n2)
+                  END IF
                   ! Output (Child) grid:
                   N_out = mbkt(ji,jj)
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_oce_update.F90	(revision 14200)
@@ -192,5 +192,11 @@
       IF (lwp.AND.lk_agrif_debug) Write(*,*) 'Update e3 from grid Number',Agrif_Fixed(), 'Step', Agrif_Nb_Step()
       !
-#if ! defined key_qco
+#if defined key_qco
+      CALL Agrif_ChildGrid_To_ParentGrid()
+      CALL Agrif_Update_qco
+      CALL Agrif_ParentGrid_To_ChildGrid()
+#elif defined key_linssh
+      !
+#else
       Agrif_UseSpecialValueInUpdate = .TRUE.
       Agrif_SpecialValueFineGrid = 0.
@@ -204,8 +210,4 @@
       CALL Agrif_ChildGrid_To_ParentGrid()
       CALL dom_vvl_update_UVF
-      CALL Agrif_ParentGrid_To_ChildGrid()
-#else
-      CALL Agrif_ChildGrid_To_ParentGrid()
-      CALL Agrif_Update_qco
       CALL Agrif_ParentGrid_To_ChildGrid()
 #endif
@@ -232,5 +234,5 @@
 
 
-#if ! defined key_qco
+#if ! defined key_qco   &&   ! defined key_linssh
    SUBROUTINE dom_vvl_update_UVF
       !!---------------------------------------------
@@ -1163,5 +1165,5 @@
    END SUBROUTINE updateAVM
 
-#if ! defined key_qco
+#if ! defined key_qco   &&   ! defined key_linssh
    SUBROUTINE updatee3t(ptab_dum, i1, i2, j1, j2, k1, k2, before )
       !!---------------------------------------------
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_interp.F90	(revision 14200)
@@ -27,4 +27,6 @@
    PUBLIC Agrif_trc, interptrn
 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
   !!----------------------------------------------------------------------
    !! NEMO/NST 4.0 , NEMO Consortium (2018)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_sponge.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_sponge.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_sponge.F90	(revision 14200)
@@ -30,4 +30,6 @@
    PUBLIC Agrif_Sponge_trc, interptrn_sponge
 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/NST 4.0 , NEMO Consortium (2018)
@@ -128,20 +130,21 @@
                   N_in = mbkt_parent(ji,jj)
                   ! Input grid (account for partial cells if any):
-                  DO jk=1,N_in
-                     z_in(jk) = tabres(ji,jj,jk,n2) - tabres(ji,jj,k2,n2)
-                     tabin(jk,1:jptra) = tabres(ji,jj,jk,1:jptra)
-                  END DO
+                  IF ( N_in > 0 ) THEN 
+                     DO jk=1,N_in
+                        z_in(jk) = tabres(ji,jj,jk,n2) - tabres(ji,jj,k2,n2)
+                        tabin(jk,1:jptra) = tabres(ji,jj,jk,1:jptra)
+                     END DO
                   
-                  ! Intermediate grid:
-                  DO jk = 1, N_in
-                     h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
-                       &       (1._wp + tabres(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)  - tabres(ji,jj,k2,n2)
-
+                     ! Intermediate grid:
+                     DO jk = 1, N_in
+                        h_in_i(jk) = e3t0_parent(ji,jj,jk) * & 
+                          &       (1._wp + tabres(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)  - tabres(ji,jj,k2,n2)
+                  END IF
                   ! Output (Child) grid:
                   N_out = mbkt(ji,jj)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_update.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_update.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_top_update.F90	(revision 14200)
@@ -26,4 +26,6 @@
    PUBLIC Agrif_Update_Trc
 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/NST 4.0 , NEMO Consortium (2018)
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/NST/agrif_user.F90	(revision 14200)
@@ -365,15 +365,17 @@
          use_sign_north = .TRUE.
          sign_north = -1.
+         CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b)   ! must be called before unb_id to define ubdy
+         CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b)   ! must be called before vnb_id to define vbdy
          CALL Agrif_Bc_variable( unb_interp_id,calledweight=1.,procname=interpunb )
          CALL Agrif_Bc_variable( vnb_interp_id,calledweight=1.,procname=interpvnb )
-         CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b)   ! must be called before unb_id to define ubdy
-         CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b)   ! must be called before vnb_id to define vbdy
          use_sign_north = .FALSE.
          ubdy(:,:) = 0._wp
          vbdy(:,:) = 0._wp
-      ELSE
+      ELSEIF ( ln_dynspg_EXP ) THEN 
          Agrif_UseSpecialValue = ln_spc_dyn
          use_sign_north = .TRUE.
          sign_north = -1.
+         ubdy(:,:) = 0._wp
+         vbdy(:,:) = 0._wp
          CALL Agrif_Bc_variable( unb_interp_id,calledweight=1.,procname=interpunb )
          CALL Agrif_Bc_variable( vnb_interp_id,calledweight=1.,procname=interpvnb )
@@ -875,4 +877,6 @@
       !
       ! Some checks
+      IF( (.NOT.ln_vert_remap).AND.(jpkglo>Agrif_Parent(jpkglo)) )                    CALL ctl_stop( 'STOP',    &
+         &   'agrif_nemo_init: Agrif children must have less or equal number of vertical levels without ln_vert_remap defined' ) 
       IF( jpiglo /= nbcellsx + 2 + 2*nn_hls + nbghostcells_x   + nbghostcells_x   )   CALL ctl_stop( 'STOP',    &
          &   'agrif_nemo_init: Agrif children requires jpiglo == nbcellsx + 2 + 2*nn_hls + 2*nbghostcells_x' )
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdytides.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdytides.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/BDY/bdytides.F90	(revision 14200)
@@ -162,11 +162,11 @@
                !
                ! SSH fields
-               IF( ASSOCIATED(dta%ssh) ) THEN   ! we use bdy ssh on this mpi subdomain
-                  clfile = TRIM(filtide)//'_grid_T.nc'
-                  CALL iom_open( clfile , inum ) 
-                  igrd = 1                       ! Everything is at T-points here
-                  DO itide = 1, nb_harmo
-                     CALL iom_get( inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_z1', ztr(:,:) )
-                     CALL iom_get( inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_z2', zti(:,:) ) 
+               clfile = TRIM(filtide)//'_grid_T.nc'
+               CALL iom_open( clfile , inum ) 
+               igrd = 1                       ! Everything is at T-points here
+               DO itide = 1, nb_harmo
+                  CALL iom_get( inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_z1', ztr(:,:) )
+                  CALL iom_get( inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_z2', zti(:,:) ) 
+                  IF( ASSOCIATED(dta%ssh) ) THEN   ! we use bdy ssh on this mpi subdomain
                      DO ib = 1, SIZE(dta%ssh)
                         ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -175,16 +175,16 @@
                         td%ssh0(ib,itide,2) = zti(ii,ij)
                      END DO
-                  END DO
-                  CALL iom_close( inum )
-               ENDIF
+                  ENDIF
+               END DO
+               CALL iom_close( inum )
                !
                ! U fields
-               IF( ASSOCIATED(dta%u2d) ) THEN   ! we use bdy u2d on this mpi subdomain
-                  clfile = TRIM(filtide)//'_grid_U.nc'
-                  CALL iom_open( clfile , inum ) 
-                  igrd = 2                       ! Everything is at U-points here
-                  DO itide = 1, nb_harmo
-                     CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_u1', ztr(:,:),cd_type='U',psgn=-1._wp)
-                     CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_u2', zti(:,:),cd_type='U',psgn=-1._wp)
+               clfile = TRIM(filtide)//'_grid_U.nc'
+               CALL iom_open( clfile , inum ) 
+               igrd = 2                       ! Everything is at U-points here
+               DO itide = 1, nb_harmo
+                  CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_u1', ztr(:,:),cd_type='U',psgn=-1._wp)
+                  CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_u2', zti(:,:),cd_type='U',psgn=-1._wp)
+                  IF( ASSOCIATED(dta%u2d) ) THEN   ! we use bdy u2d on this mpi subdomain
                      DO ib = 1, SIZE(dta%u2d)
                         ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -193,16 +193,16 @@
                         td%u0(ib,itide,2) = zti(ii,ij)
                      END DO
-                  END DO
-                  CALL iom_close( inum )
-               ENDIF
+                  ENDIF 
+               END DO 
+               CALL iom_close( inum )
                !
                ! V fields
-               IF( ASSOCIATED(dta%v2d) ) THEN   ! we use bdy v2d on this mpi subdomain
-                  clfile = TRIM(filtide)//'_grid_V.nc'
-                  CALL iom_open( clfile , inum ) 
-                  igrd = 3                       ! Everything is at V-points here
-                  DO itide = 1, nb_harmo
-                     CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_v1', ztr(:,:),cd_type='V',psgn=-1._wp)
-                     CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_v2', zti(:,:),cd_type='V',psgn=-1._wp)
+               clfile = TRIM(filtide)//'_grid_V.nc'
+               CALL iom_open( clfile , inum ) 
+               igrd = 3                       ! Everything is at V-points here
+               DO itide = 1, nb_harmo
+                  CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_v1', ztr(:,:),cd_type='V',psgn=-1._wp)
+                  CALL iom_get(inum, jpdom_auto, TRIM(tide_harmonics(itide)%cname_tide)//'_v2', zti(:,:),cd_type='V',psgn=-1._wp)
+                  IF( ASSOCIATED(dta%v2d) ) THEN   ! we use bdy v2d on this mpi subdomain
                      DO ib = 1, SIZE(dta%v2d)
                         ii = idx_bdy(ib_bdy)%nbi(ib,igrd)
@@ -211,7 +211,7 @@
                         td%v0(ib,itide,2) = zti(ii,ij)
                      END DO
-                  END DO
-                  CALL iom_close( inum )
-               ENDIF
+                  ENDIF 
+               END DO
+               CALL iom_close( inum )
                !
                DEALLOCATE( ztr, zti ) 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DIA/diawri.F90	(revision 14200)
@@ -215,7 +215,5 @@
       ENDIF
 
-#if ! defined key_qco
-      CALL iom_put( "rhop", rhop(:,:,:) )          ! 3D potential density (sigma0)
-#endif
+      IF( .NOT.lk_SWE )   CALL iom_put( "rhop", rhop(:,:,:) )          ! 3D potential density (sigma0)
 
       IF ( iom_use("taubot") ) THEN                ! bottom stress
@@ -360,5 +358,5 @@
       ENDIF
       !    
-      IF ( iom_use("sKEf") ) THEN                        ! surface kinetic energy at F point
+      IF ( iom_use("ssKEf") ) THEN                        ! surface kinetic energy at F point
          z2d(:,:) = 0._wp                                ! CAUTION : only valid in SWE, not with bathymetry
          DO_2D( 0, 0, 0, 0 )
@@ -370,5 +368,5 @@
          END_2D
          CALL lbc_lnk( 'diawri', z2d, 'F', 1. )
-         CALL iom_put( "sKEf", z2d )                     
+         CALL iom_put( "ssKEf", z2d )                     
       ENDIF
       !
@@ -473,8 +471,8 @@
       IF (ln_dia25h)   CALL dia_25h( kt, Kmm )        ! 25h averaging
       
-      ! Output of vorticity terms
-      IF ( iom_use("relvor")    .OR. iom_use("plavor")    .OR.   &
-         & iom_use("relpotvor") .OR. iom_use("abspotvor") .OR.   &
-         & iom_use("Ens")                                        ) THEN
+      ! Output of surface vorticity terms
+      IF ( iom_use("ssrelvor")    .OR. iom_use("ssplavor")    .OR.   &
+         & iom_use("ssrelpotvor") .OR. iom_use("ssabspotvor") .OR.   &
+         & iom_use("ssEns")                                        ) THEN
          !
          z2d(:,:) = 0._wp 
@@ -485,7 +483,7 @@
          END_2D
          CALL lbc_lnk( 'diawri', z2d, 'F', 1. )
-         CALL iom_put( "relvor", z2d )                  ! relative vorticity ( zeta ) 
-         !
-         CALL iom_put( "plavor", ff_f )                 ! planetary vorticity ( f )
+         CALL iom_put( "ssrelvor", z2d )                  ! relative vorticity ( zeta ) 
+         !
+         CALL iom_put( "ssplavor", ff_f )                 ! planetary vorticity ( f )
          !
          DO_2D( 1, 0, 1, 0 )  
@@ -498,5 +496,5 @@
          END_2D
          CALL lbc_lnk( 'diawri', z2d, 'F', 1. )
-         CALL iom_put( "relpotvor", z2d )                  ! relative potential vorticity (zeta/h)
+         CALL iom_put( "ssrelpotvor", z2d )                  ! relative potential vorticity (zeta/h)
          !
          DO_2D( 1, 0, 1, 0 )
@@ -509,5 +507,5 @@
          END_2D
          CALL lbc_lnk( 'diawri', z2d, 'F', 1. )
-         CALL iom_put( "abspotvor", z2d )                  ! absolute potential vorticity ( q )
+         CALL iom_put( "ssabspotvor", z2d )                  ! absolute potential vorticity ( q )
          !
          DO_2D( 1, 0, 1, 0 )  
@@ -515,5 +513,5 @@
          END_2D
          CALL lbc_lnk( 'diawri', z2d, 'F', 1. )
-         CALL iom_put( "Ens", z2d )                        ! potential enstrophy ( 1/2*q2 )
+         CALL iom_put( "ssEns", z2d )                        ! potential enstrophy ( 1/2*q2 )
          !
       ENDIF
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dom_oce.F90	(revision 14200)
@@ -136,7 +136,18 @@
    !
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ff_f  , ff_t                    !: Coriolis factor at f- & t-points  [1/s]
+   
    !!----------------------------------------------------------------------
    !! vertical coordinate and scale factors
    !! ---------------------------------------------------------------------
+#if defined key_qco
+   LOGICAL, PUBLIC, PARAMETER ::   lk_qco    = .TRUE.   !: qco key flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_qco    = .FALSE.  !: qco key flag
+#endif
+#if defined key_linssh
+   LOGICAL, PUBLIC, PARAMETER ::   lk_linssh = .TRUE.   !: linssh key flag
+#else
+   LOGICAL, PUBLIC, PARAMETER ::   lk_linssh = .FALSE.  !: linssh key flag
+#endif
    LOGICAL, PUBLIC ::   ln_zco       !: z-coordinate - full step
    LOGICAL, PUBLIC ::   ln_zps       !: z-coordinate - partial step
@@ -151,10 +162,10 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::    e3uw_0   !: uw-vert. scale factor [m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::    e3vw_0   !: vw-vert. scale factor [m]
-   !                                                        !  time-dependent scale factors
-#if ! defined key_qco
+
+   !                                                        !  time-dependent scale factors     (domvvl)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   e3t, e3u, e3v, e3w, e3uw, e3vw  !: vert. scale factor [m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   e3f                             !: F-point vert. scale factor [m]
-#endif
-   !                                                        !  time-dependent ratio ssh / h_0
+
+   !                                                        !  time-dependent ratio ssh / h_0   (domqco)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   r3t, r3u, r3v                   !: time-dependent    ratio at t-, u- and v-point [-]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)     ::   r3f                             !: mid-time-level    ratio at f-point            [-]
@@ -165,5 +176,6 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   gdepw_0  !: w- depth              [m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   gde3w_0  !: w- depth (sum of e3w) [m]
-   !                                                        !  time-dependent depths of cells
+   
+   !                                                        !  time-dependent depths of cells   (domvvl)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::  gdept, gdepw
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  gde3w
@@ -174,8 +186,7 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)     ::   hv_0, r1_hv_0   !: v-depth        [m] and [1/m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)     ::   hf_0, r1_hf_0   !: f-depth        [m] and [1/m]
-   !                                                        ! time-dependent heights of ocean water column
-#if ! defined key_qco
+   
+   !                                                        ! time-dependent heights of ocean water column   (domvvl)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)     ::   ht          !: t-points           [m]
-#endif
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hu, r1_hu   !: u-depth            [m] and [1/m]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hv, r1_hv   !: v-depth            [m] and [1/m]
@@ -207,7 +218,6 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET ::   tmask, umask, vmask, wmask, fmask   !: land/ocean mask at T-, U-, V-, W- and F-pts
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET ::   wumask, wvmask                      !: land/ocean mask at WU- and WV-pts
-#if defined key_qco
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET ::   fe3mask                             !: land/ocean mask at F-pts for qco
-#endif
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:), TARGET ::   fe3mask                             !: land/ocean mask at F-pts (qco only)
+
    !!----------------------------------------------------------------------
    !! calendar variables
@@ -301,29 +311,39 @@
          !
       ii = ii+1
-      ALLOCATE( gdept_0(jpi,jpj,jpk)     , gdepw_0(jpi,jpj,jpk)     , gde3w_0(jpi,jpj,jpk) ,      &
-         &      gdept  (jpi,jpj,jpk,jpt) , gdepw  (jpi,jpj,jpk,jpt) , gde3w  (jpi,jpj,jpk) , STAT=ierr(ii) )
-         !
-      ii = ii+1
-      ALLOCATE(  e3t_0(jpi,jpj,jpk) , e3u_0 (jpi,jpj,jpk) , e3v_0 (jpi,jpj,jpk) , e3f_0(jpi,jpj,jpk) ,      &
-         &       e3w_0(jpi,jpj,jpk) , e3uw_0(jpi,jpj,jpk) , e3vw_0(jpi,jpj,jpk)                      ,  STAT=ierr(ii) )
+      ALLOCATE( gdept_0 (jpi,jpj,jpk) , gdepw_0 (jpi,jpj,jpk) , gde3w_0(jpi,jpj,jpk) ,     &
+         &      gdept_1d(        jpk) , gdepw_1d(        jpk)                        , STAT=ierr(ii) )
+         !
+      ii = ii+1
+      ALLOCATE(  e3t_0 (jpi,jpj,jpk) , e3u_0 (jpi,jpj,jpk) , e3v_0 (jpi,jpj,jpk) , e3f_0(jpi,jpj,jpk) ,     &
+         &       e3w_0 (jpi,jpj,jpk) , e3uw_0(jpi,jpj,jpk) , e3vw_0(jpi,jpj,jpk)                      ,     &
+         &       e3t_1d(        jpk) , e3w_1d(        jpk)                                            , STAT=ierr(ii) )
+         !
+      ii = ii+1
+      ALLOCATE( ht_0(jpi,jpj) ,    hu_0(jpi,jpj)    ,    hv_0(jpi,jpj)     , hf_0(jpi,jpj) ,       &
+         &   r1_ht_0(jpi,jpj) , r1_hu_0(jpi,jpj) ,    r1_hv_0(jpi,jpj),   r1_hf_0(jpi,jpj) ,   STAT=ierr(ii)  )
          !
 #if defined key_qco
-      ii = ii+1
-      ALLOCATE( r3t  (jpi,jpj,jpt)   , r3u  (jpi,jpj,jpt)    , r3v  (jpi,jpj,jpt)    , r3f  (jpi,jpj) ,      &
-         &      r3t_f(jpi,jpj)       , r3u_f(jpi,jpj)        , r3v_f(jpi,jpj)                         ,  STAT=ierr(ii) )
+         ! qco : ssh to h ratio and specific fmask
+      ii = ii+1
+      ALLOCATE( r3t  (jpi,jpj,jpt) , r3u  (jpi,jpj,jpt) , r3v  (jpi,jpj,jpt) , r3f  (jpi,jpj) ,      &
+         &      r3t_f(jpi,jpj)     , r3u_f(jpi,jpj)     , r3v_f(jpi,jpj)                      ,  STAT=ierr(ii) )
+         !
+      ii = ii+1
+      ALLOCATE( fe3mask(jpi,jpj,jpk) , STAT=ierr(ii) )
+         !
+#elif defined key_linssh
+         ! linear ssh no time varying coordinate arrays
 #else
+         ! vvl : time varation for all vertical coordinate variables
+      ii = ii+1
+      ALLOCATE( gdept  (jpi,jpj,jpk,jpt) , gdepw  (jpi,jpj,jpk,jpt) , gde3w  (jpi,jpj,jpk) , STAT=ierr(ii) )
+         !
       ii = ii+1
       ALLOCATE( e3t(jpi,jpj,jpk,jpt) , e3u (jpi,jpj,jpk,jpt) , e3v (jpi,jpj,jpk,jpt) , e3f(jpi,jpj,jpk) ,      &
          &      e3w(jpi,jpj,jpk,jpt) , e3uw(jpi,jpj,jpk,jpt) , e3vw(jpi,jpj,jpk,jpt)                    ,  STAT=ierr(ii) )
-#endif
-         !
-      ii = ii+1
-      ALLOCATE( ht_0(jpi,jpj) ,    hu_0(jpi,jpj)    ,    hv_0(jpi,jpj)     , hf_0(jpi,jpj) ,       &
-         &   r1_ht_0(jpi,jpj) , r1_hu_0(jpi,jpj) ,    r1_hv_0(jpi,jpj),   r1_hf_0(jpi,jpj) ,   STAT=ierr(ii)  )
-         !
-#if ! defined key_qco
-      ii = ii+1
-      ALLOCATE( ht  (jpi,jpj) ,    hu  (jpi,jpj,jpt),    hv  (jpi,jpj,jpt)                 ,       &
-         &                      r1_hu  (jpi,jpj,jpt), r1_hv  (jpi,jpj,jpt)                 ,   STAT=ierr(ii)  )
+         !
+      ii = ii+1
+      ALLOCATE( ht  (jpi,jpj) ,    hu  (jpi,jpj,jpt),    hv  (jpi,jpj,jpt) ,       &
+         &                      r1_hu  (jpi,jpj,jpt), r1_hv  (jpi,jpj,jpt) ,   STAT=ierr(ii)  )
 #endif
          !
@@ -332,10 +352,7 @@
          !
       ii = ii+1
-      ALLOCATE( gdept_1d(jpk) , gdepw_1d(jpk) , e3t_1d(jpk) , e3w_1d(jpk) , STAT=ierr(ii) )
-         !
-      ii = ii+1
-      ALLOCATE( tmask_i(jpi,jpj) , tmask_h(jpi,jpj) ,                        &
+      ALLOCATE( tmask_i(jpi,jpj) , tmask_h(jpi,jpj) ,                                           &
          &      ssmask (jpi,jpj) , ssumask(jpi,jpj) , ssvmask(jpi,jpj) , ssfmask(jpi,jpj) ,     &
-         &      mbkt   (jpi,jpj) , mbku   (jpi,jpj) , mbkv   (jpi,jpj) ,                    STAT=ierr(ii) )
+         &      mbkt   (jpi,jpj) , mbku   (jpi,jpj) , mbkv   (jpi,jpj)                    , STAT=ierr(ii) )
          !
       ii = ii+1
@@ -348,9 +365,4 @@
       ii = ii+1
       ALLOCATE( wmask(jpi,jpj,jpk) , wumask(jpi,jpj,jpk), wvmask(jpi,jpj,jpk) , STAT=ierr(ii) )
-#if defined key_qco
-         !
-      ii = ii+1
-      ALLOCATE( fe3mask(jpi,jpj,jpk) , STAT=ierr(ii) )
-#endif
       !
       dom_oce_alloc = MAXVAL(ierr)
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domain.F90	(revision 14200)
@@ -28,10 +28,15 @@
    USE oce            ! ocean variables
    USE dom_oce        ! domain: ocean
+   USE domtile        ! tiling utilities
 #if defined key_qco
-   USE domqco         ! quasi-eulerian
+   USE domqco         ! quasi-eulerian coord.
+#elif defined key_linssh
+   !                  ! fix in time coord.
 #else
-   USE domvvl         ! variable volume
-#endif
-   USE sshwzv  , ONLY : ssh_init_rst   ! set initial ssh
+   USE domvvl         ! variable volume coord.
+#endif
+#if defined key_agrif
+   USE agrif_oce_interp, ONLY : Agrif_istate_ssh ! ssh interpolated from parent
+#endif
    USE sbc_oce        ! surface boundary condition: ocean
    USE trc_oce        ! shared ocean & passive tracers variab
@@ -39,5 +44,4 @@
    USE domhgr         ! domain: set the horizontal mesh
    USE domzgr         ! domain: set the vertical mesh
-   USE domtile
    USE dommsk         ! domain: set the mask system
    USE domwri         ! domain: write the meshmask file
@@ -51,5 +55,5 @@
    USE lbclnk         ! ocean lateral boundary condition (or mpp link)
    USE lib_mpp        ! distributed memory computing library
-   USE restart        ! only for lrst_oce
+   USE restart        ! only for lrst_oce and rst_read_ssh
 
    IMPLICIT NONE
@@ -169,5 +173,5 @@
          DO_2D( 1, 1, 1, 1 )
             IF( ht_0(ji,jj) < 0._wp .AND. ssmask(ji,jj) == 1._wp ) THEN
-               CALL ctl_stop( 'ssh_init_rst : ht_0 must be positive at potentially wet points' )
+               CALL ctl_stop( 'dom_init : ht_0 must be positive at potentially wet points' )
             ENDIF
          END_2D
@@ -177,14 +181,22 @@
       !
       !                                 != ssh initialization
-      IF( .NOT.l_offline .AND. .NOT.l_SAS ) THEN
-         CALL ssh_init_rst( Kbb, Kmm, Kaa )
-      ELSE
+      !
+      IF( l_offline .OR. l_SAS ) THEN        !* No ocean dynamics calculation : set to 0
          ssh(:,:,:) = 0._wp
-      ENDIF
-      !
+#if defined key_agrif
+      ELSEIF( .NOT.Agrif_root() .AND.    &
+         &     ln_init_chfrpar ) THEN        !* Interpolate initial ssh from parent
+         CALL Agrif_istate_ssh( Kbb, Kmm, Kaa )
+#endif
+      ELSE                                   !* Read in restart file or set by user
+         CALL rst_read_ssh( Kbb, Kmm, Kaa )
+      ENDIF
+      !     
 #if defined key_qco
       !                                 != Quasi-Euerian coordinate case
       !
       IF( .NOT.l_offline )   CALL dom_qco_init( Kbb, Kmm, Kaa )
+#elif defined key_linssh
+      !                                 != Fix in time : key_linssh case, set through domzgr_substitute.h90
 #else
       !
@@ -345,4 +357,8 @@
       IF(lwm) WRITE( numond, namdom )
       !
+#if defined key_linssh
+      ln_linssh = lk_linssh      ! overwrite ln_linssh with the logical associated with key_linssh
+#endif
+      !
 #if defined key_agrif
       IF( .NOT. Agrif_Root() ) THEN    ! AGRIF child, subdivide the Parent timestep
@@ -371,5 +387,5 @@
       !
 #if defined key_qco
-      IF( ln_linssh )   CALL ctl_stop( 'STOP','domain: key_qco and ln_linssh = T are incompatible' )
+      IF( ln_linssh )   CALL ctl_stop( 'STOP','domain: key_qco and ln_linssh=T or key_linssh are incompatible' )
 #endif
       !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domqco.F90	(revision 14200)
@@ -116,6 +116,11 @@
       !                    !== Set of all other vertical scale factors  ==!  (now and before)
       !                                ! Horizontal interpolation of e3t
+#if defined key_RK3
+      CALL dom_qco_r3c( ssh(:,:,Kbb), r3t(:,:,Kbb), r3u(:,:,Kbb), r3v(:,:,Kbb), r3f(:,:) )
+      CALL dom_qco_r3c( ssh(:,:,Kmm), r3t(:,:,Kmm), r3u(:,:,Kmm), r3v(:,:,Kmm)           )
+#else
       CALL dom_qco_r3c( ssh(:,:,Kbb), r3t(:,:,Kbb), r3u(:,:,Kbb), r3v(:,:,Kbb)           )
       CALL dom_qco_r3c( ssh(:,:,Kmm), r3t(:,:,Kmm), r3u(:,:,Kmm), r3v(:,:,Kmm), r3f(:,:) )
+#endif
       !
    END SUBROUTINE dom_qco_zgr
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domvvl.F90	(revision 14200)
@@ -2,5 +2,5 @@
    !!======================================================================
    !!                       ***  MODULE domvvl   ***
-   !! Ocean : 
+   !! Ocean :
    !!======================================================================
    !! History :  2.0  !  2006-06  (B. Levier, L. Marie)  original code
@@ -26,9 +26,4 @@
    USE timing          ! Timing
 
-#if defined key_agrif
-   USE agrif_oce       ! initial state interpolation
-   USE agrif_oce_interp 
-#endif
-
    IMPLICIT NONE
    PRIVATE
@@ -55,7 +50,9 @@
    REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   :: frq_rst_hdv                 ! retoring period for low freq. divergence
 
-#if defined key_qco
+#if defined key_qco   ||   defined key_linssh
    !!----------------------------------------------------------------------
-   !!   'key_qco'      EMPTY MODULE      Quasi-Eulerian vertical coordonate
+   !!   'key_qco'                        Quasi-Eulerian vertical coordinate
+   !!       OR         EMPTY MODULE
+   !!   'key_linssh'                        Fix in time vertical coordinate
    !!----------------------------------------------------------------------
 #else
@@ -63,5 +60,5 @@
    !!   Default key      Old management of time varying vertical coordinate
    !!----------------------------------------------------------------------
-   
+
    !!----------------------------------------------------------------------
    !!   dom_vvl_init     : define initial vertical scale factors, depths and column thickness
@@ -78,5 +75,5 @@
    PUBLIC  dom_vvl_sf_update  ! called by step.F90
    PUBLIC  dom_vvl_interpol   ! called by dynnxt.F90
-   
+
    !! * Substitutions
 #  include "do_loop_substitute.h90"
@@ -114,5 +111,5 @@
       !!----------------------------------------------------------------------
       !!                ***  ROUTINE dom_vvl_init  ***
-      !!                   
+      !!
       !! ** Purpose :  Initialization of all scale factors, depths
       !!               and water column heights
@@ -123,8 +120,8 @@
       !! ** Action  : - e3t_(n/b) and tilde_e3t_(n/b)
       !!              - Regrid: e3[u/v](:,:,:,Kmm)
-      !!                        e3[u/v](:,:,:,Kmm)       
-      !!                        e3w(:,:,:,Kmm)           
+      !!                        e3[u/v](:,:,:,Kmm)
+      !!                        e3w(:,:,:,Kmm)
       !!                        e3[u/v]w_b
-      !!                        e3[u/v]w_n      
+      !!                        e3[u/v]w_n
       !!                        gdept(:,:,:,Kmm), gdepw(:,:,:,Kmm) and gde3w
       !!              - h(t/u/v)_0
@@ -156,6 +153,6 @@
       !!----------------------------------------------------------------------
       !!                ***  ROUTINE dom_vvl_init  ***
-      !!                   
-      !! ** Purpose :  Interpolation of all scale factors, 
+      !!
+      !! ** Purpose :  Interpolation of all scale factors,
       !!               depths and water column heights
       !!
@@ -164,8 +161,8 @@
       !! ** Action  : - e3t_(n/b) and tilde_e3t_(n/b)
       !!              - Regrid: e3(u/v)_n
-      !!                        e3(u/v)_b       
-      !!                        e3w_n           
-      !!                        e3(u/v)w_b      
-      !!                        e3(u/v)w_n      
+      !!                        e3(u/v)_b
+      !!                        e3w_n
+      !!                        e3(u/v)w_b
+      !!                        e3(u/v)w_n
       !!                        gdept_n, gdepw_n and gde3w_n
       !!              - h(t/u/v)_0
@@ -185,8 +182,8 @@
       CALL dom_vvl_interpol( e3t(:,:,:,Kbb), e3u(:,:,:,Kbb), 'U' )    ! from T to U
       CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3u(:,:,:,Kmm), 'U' )
-      CALL dom_vvl_interpol( e3t(:,:,:,Kbb), e3v(:,:,:,Kbb), 'V' )    ! from T to V 
+      CALL dom_vvl_interpol( e3t(:,:,:,Kbb), e3v(:,:,:,Kbb), 'V' )    ! from T to V
       CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3v(:,:,:,Kmm), 'V' )
       CALL dom_vvl_interpol( e3u(:,:,:,Kmm), e3f(:,:,:), 'F' )    ! from U to F
-      !                                ! Vertical interpolation of e3t,u,v 
+      !                                ! Vertical interpolation of e3t,u,v
       CALL dom_vvl_interpol( e3t(:,:,:,Kmm), e3w (:,:,:,Kmm), 'W'  )  ! from T to W
       CALL dom_vvl_interpol( e3t(:,:,:,Kbb), e3w (:,:,:,Kbb), 'W'  )
@@ -210,14 +207,14 @@
          !    zcoef = tmask - wmask    ! 0 everywhere tmask = wmask, ie everywhere expect at jk = mikt
          !                             ! 1 everywhere from mbkt to mikt + 1 or 1 (if no isf)
-         !                             ! 0.5 where jk = mikt     
+         !                             ! 0.5 where jk = mikt
 !!gm ???????   BUG ?  gdept(:,:,:,Kmm) as well as gde3w  does not include the thickness of ISF ??
          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)) 
+            &                + (1-zcoef) * ( gdept(ji,jj,jk-1,Kmm) +       e3w(ji,jj,jk,Kmm))
          gde3w(ji,jj,jk) = gdept(ji,jj,jk,Kmm) - ssh(ji,jj,Kmm)
          gdepw(ji,jj,jk,Kbb) = gdepw(ji,jj,jk-1,Kbb) + e3t(ji,jj,jk-1,Kbb)
          gdept(ji,jj,jk,Kbb) =      zcoef  * ( gdepw(ji,jj,jk  ,Kbb) + 0.5 * e3w(ji,jj,jk,Kbb))  &
-            &                + (1-zcoef) * ( gdept(ji,jj,jk-1,Kbb) +       e3w(ji,jj,jk,Kbb)) 
+            &                + (1-zcoef) * ( gdept(ji,jj,jk-1,Kbb) +       e3w(ji,jj,jk,Kbb))
       END_3D
       !
@@ -278,5 +275,5 @@
             IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA" ) THEN
                IF( nn_cfg == 3 ) THEN   ! ORCA2: Suppress ztilde in the Foxe Basin for ORCA2
-                  ii0 = 103 + nn_hls - 1   ;   ii1 = 111 + nn_hls - 1      
+                  ii0 = 103 + nn_hls - 1   ;   ii1 = 111 + nn_hls - 1
                   ij0 = 128 + nn_hls       ;   ij1 = 135 + nn_hls
                   frq_rst_e3t( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  0.0_wp
@@ -290,13 +287,13 @@
 
 
-   SUBROUTINE dom_vvl_sf_nxt( kt, Kbb, Kmm, Kaa, kcall ) 
+   SUBROUTINE dom_vvl_sf_nxt( kt, Kbb, Kmm, Kaa, kcall )
       !!----------------------------------------------------------------------
       !!                ***  ROUTINE dom_vvl_sf_nxt  ***
-      !!                   
+      !!
       !! ** Purpose :  - compute the after scale factors used in tra_zdf, dynnxt,
       !!                 tranxt and dynspg routines
       !!
       !! ** Method  :  - z_star case:  Repartition of ssh INCREMENT proportionnaly to the level thickness.
-      !!               - z_tilde_case: after scale factor increment = 
+      !!               - z_tilde_case: after scale factor increment =
       !!                                    high frequency part of horizontal divergence
       !!                                  + retsoring towards the background grid
@@ -306,5 +303,5 @@
       !!
       !! ** Action  :  - hdiv_lf    : restoring towards full baroclinic divergence in z_tilde case
-      !!               - tilde_e3t_a: after increment of vertical scale factor 
+      !!               - tilde_e3t_a: after increment of vertical scale factor
       !!                              in z_tilde case
       !!               - e3(t/u/v)_a
@@ -410,5 +407,5 @@
             un_td(ji,jj,jk) = rn_ahe3 * umask(ji,jj,jk) * e2_e1u(ji,jj)           &
                &            * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji+1,jj  ,jk) )
-            vn_td(ji,jj,jk) = rn_ahe3 * vmask(ji,jj,jk) * e1_e2v(ji,jj)           & 
+            vn_td(ji,jj,jk) = rn_ahe3 * vmask(ji,jj,jk) * e1_e2v(ji,jj)           &
                &            * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji  ,jj+1,jk) )
             zwu(ji,jj) = zwu(ji,jj) + un_td(ji,jj,jk)
@@ -455,5 +452,5 @@
                WRITE(numout, *) 'at i, j, k=', ijk_max
                WRITE(numout, *) 'MIN( tilde_e3t_a(:,:,:) / e3t_0(:,:,:) ) =', z_tmin
-               WRITE(numout, *) 'at i, j, k=', ijk_min            
+               WRITE(numout, *) 'at i, j, k=', ijk_min
                CALL ctl_stop( 'STOP', 'MAX( ABS( tilde_e3t_a(:,:,: ) ) / e3t_0(:,:,:) ) too high')
             ENDIF
@@ -571,6 +568,6 @@
       !!----------------------------------------------------------------------
       !!                ***  ROUTINE dom_vvl_sf_update  ***
-      !!                   
-      !! ** Purpose :  for z tilde case: compute time filter and swap of scale factors 
+      !!
+      !! ** Purpose :  for z tilde case: compute time filter and swap of scale factors
       !!               compute all depths and related variables for next time step
       !!               write outputs and restart file
@@ -582,8 +579,8 @@
       !! ** Action  :  - tilde_e3t_(b/n) ready for next time step
       !!               - Recompute:
-      !!                    e3(u/v)_b       
-      !!                    e3w(:,:,:,Kmm)           
-      !!                    e3(u/v)w_b      
-      !!                    e3(u/v)w_n      
+      !!                    e3(u/v)_b
+      !!                    e3w(:,:,:,Kmm)
+      !!                    e3(u/v)w_b
+      !!                    e3(u/v)w_n
       !!                    gdept(:,:,:,Kmm), gdepw(:,:,:,Kmm)  and gde3w
       !!                    h(u/v) and h(u/v)r
@@ -616,5 +613,5 @@
             tilde_e3t_b(:,:,:) = tilde_e3t_n(:,:,:)
          ELSE
-            tilde_e3t_b(:,:,:) = tilde_e3t_n(:,:,:) & 
+            tilde_e3t_b(:,:,:) = tilde_e3t_n(:,:,:) &
             &         + rn_atfp * ( tilde_e3t_b(:,:,:) - 2.0_wp * tilde_e3t_n(:,:,:) + tilde_e3t_a(:,:,:) )
          ENDIF
@@ -628,7 +625,7 @@
       ! - ML - e3u(:,:,:,Kbb) and e3v(:,:,:,Kbb) are already computed in dynnxt
       ! - JC - hu(:,:,:,Kbb), hv(:,:,:,:,Kbb), hur_b, hvr_b also
-      
+
       CALL dom_vvl_interpol( e3u(:,:,:,Kmm), e3f(:,:,:), 'F'  )
-      
+
       ! Vertical scale factor interpolations
       CALL dom_vvl_interpol( e3t(:,:,:,Kmm),  e3w(:,:,:,Kmm), 'W'  )
@@ -649,5 +646,5 @@
          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) ) 
+             &             + (1-zcoef) * ( gdept(ji,jj,jk-1,Kmm) +       e3w(ji,jj,jk,Kmm) )
          gde3w(ji,jj,jk) = gdept(ji,jj,jk,Kmm) - ssh(ji,jj,Kmm)
       END_3D
@@ -768,5 +765,5 @@
       !!---------------------------------------------------------------------
       !!                   ***  ROUTINE dom_vvl_rst  ***
-      !!                     
+      !!
       !! ** Purpose :   Read or write VVL file in restart file
       !!
@@ -800,10 +797,4 @@
          IF( ln_rstart ) THEN                   !==  Read the restart file  ==!
             !
-#if defined key_agrif
-            IF ( (.NOT.Agrif_root()).AND.(ln_init_chfrpar) ) THEN
-               ! skip reading restart if initialized from parent:
-               id3 = -1 ; id4 = -1 ; id5 = -1
-            ELSE
-#endif
             CALL rst_read_open                                          !*  open the restart file if necessary
             !                                         ! --------- !
@@ -815,20 +806,17 @@
             id5 = iom_varid( numror, 'hdiv_lf'    , ldstop = .FALSE. )
             !
-#if defined key_agrif
-            ENDIF
-#endif
             !                                                           !*  scale factors
             IF(lwp) WRITE(numout,*)    '          Kmm scale factor read in the restart file'
             CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
-            WHERE ( tmask(:,:,:) == 0.0_wp ) 
+            WHERE ( tmask(:,:,:) == 0.0_wp )
                e3t(:,:,:,Kmm) = e3t_0(:,:,:)
             END WHERE
             IF( l_1st_euler ) THEN                       ! euler
                IF(lwp) WRITE(numout,*) '          Euler first time step : e3t(Kbb) = e3t(Kmm)'
-               e3t(:,:,:,Kmm) = e3t(:,:,:,Kbb)
+               e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
             ELSE                                         ! leap frog
                IF(lwp) WRITE(numout,*) '          Kbb scale factor read in the restart file'
                CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
-               WHERE ( tmask(:,:,:) == 0.0_wp ) 
+               WHERE ( tmask(:,:,:) == 0.0_wp )
                   e3t(:,:,:,Kbb) = e3t_0(:,:,:)
                END WHERE
@@ -854,7 +842,7 @@
                      CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
                   ENDIF
-               ELSE 
-                 tilde_e3t_b(:,:,:) = 0.0_wp
-                 tilde_e3t_n(:,:,:) = 0.0_wp
+               ELSE
+                  tilde_e3t_b(:,:,:) = 0.0_wp
+                  tilde_e3t_n(:,:,:) = 0.0_wp
                ENDIF
                !                                      ! ------------ !
@@ -864,5 +852,5 @@
                      CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:) )
                   ELSE                ! array is missing
-                     hdiv_lf(:,:,:) = 0.0_wp 
+                     hdiv_lf(:,:,:) = 0.0_wp
                   ENDIF
                ENDIF
@@ -885,17 +873,4 @@
       ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN       !  Create restart file  !
          !                                       !=======================!
-#if defined key_agrif
-         IF ( .NOT.Agrif_root().AND.(ln_init_chfrpar) ) THEN
-            ! Interpolate initial ssh from parent:
-            CALL Agrif_istate_ssh( Kbb, Kmm )
-            !
-            DO jk = 1, jpk
-               e3t(:,:,jk,Kmm) =  e3t_0(:,:,jk) * ( ht_0(:,:) + ssh(:,:,Kmm)  ) &
-                 &                              / ( ht_0(:,:) + 1._wp - ssmask(:,:) ) * tmask(:,:,jk)   &
-                 &              + e3t_0(:,:,jk) * ( 1._wp - tmask(:,:,jk) )
-            END DO
-            e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
-         ENDIF
-#endif
          !
          IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
@@ -911,5 +886,5 @@
             CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:))
          END IF
-         !                                           ! -------------!    
+         !                                           ! -------------!
          IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
             !                                        ! ------------ !
@@ -925,5 +900,5 @@
       !!---------------------------------------------------------------------
       !!                  ***  ROUTINE dom_vvl_ctl  ***
-      !!                
+      !!
       !! ** Purpose :   Control the consistency between namelist options
       !!                for vertical coordinate
@@ -934,5 +909,5 @@
          &              ln_vvl_zstar_at_eqtor      , rn_ahe3     , rn_rst_e3t            , &
          &              rn_lf_cutoff               , rn_zdef_max , ln_vvl_dbg                ! not yet implemented: ln_vvl_kepe
-      !!---------------------------------------------------------------------- 
+      !!----------------------------------------------------------------------
       !
       READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domzgr_substitute.h90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domzgr_substitute.h90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/domzgr_substitute.h90	(revision 14200)
@@ -28,7 +28,22 @@
 #   define  gdepw(i,j,k,t) (gdepw_0(i,j,k)*(1._wp+r3t(i,j,t)))
 #   define  gde3w(i,j,k)   (gdept_0(i,j,k)*(1._wp+r3t(i,j,Kmm))-ssh(i,j,Kmm))
+#elif defined key_linssh
+#   define  e3t(i,j,k,t)   e3t_0(i,j,k)
+#   define  e3u(i,j,k,t)   e3u_0(i,j,k)
+#   define  e3v(i,j,k,t)   e3v_0(i,j,k)
+#   define  e3f(i,j,k)     e3f_0(i,j,k)
+#   define  e3f_vor(i,j,k) e3f_0vor(i,j,k)
+#   define  e3w(i,j,k,t)   e3w_0(i,j,k)
+#   define  e3uw(i,j,k,t)  e3uw_0(i,j,k)
+#   define  e3vw(i,j,k,t)  e3vw_0(i,j,k)
+#   define  ht(i,j)        ht_0(i,j)
+#   define  hu(i,j,t)      hu_0(i,j)
+#   define  hv(i,j,t)      hv_0(i,j)
+#   define  r1_hu(i,j,t)   r1_hu_0(i,j)
+#   define  r1_hv(i,j,t)   r1_hv_0(i,j)
+#   define  gdept(i,j,k,t) gdept_0(i,j,k)
+#   define  gdepw(i,j,k,t) gdepw_0(i,j,k)
+#   define  gde3w(i,j,k)   (gdept_0(i,j,k)-ssh(i,j,Kmm))
 #endif
 !!----------------------------------------------------------------------
-!!#   define  e3t_f(i,j,k)   (e3t_0(i,j,k)*(1._wp+r3t_f(i,j)*tmask(i,j,k)))
-!!#   define  e3u_f(i,j,k)   (e3u_0(i,j,k)*(1._wp+r3u_f(i,j)*umask(i,j,k)))
-!!#   define  e3v_f(i,j,k)   (e3v_0(i,j,k)*(1._wp+r3v_f(i,j)*vmask(i,j,k)))
+
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dtatsd.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dtatsd.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/dtatsd.F90	(revision 14200)
@@ -142,4 +142,5 @@
       INTEGER ::   ik, il0, il1, ii0, ii1, ij0, ij1   ! local integers
       INTEGER ::   itile
+      INTEGER, DIMENSION(jpts), SAVE :: irec_b, irec_n
       REAL(wp)::   zl, zi                             ! local scalars
       REAL(wp), DIMENSION(jpk) ::  ztp, zsp   ! 1D workspace
@@ -157,19 +158,33 @@
          IF( cn_cfg == "orca" .OR. cn_cfg == "ORCA" ) THEN
             IF( nn_cfg == 2 .AND. ln_tsd_dmp ) THEN    ! some hand made alterations
+               irec_n(jp_tem) = sf_tsd(jp_tem)%nrec(2,sf_tsd(jp_tem)%naa)            ! Determine if there is new data (ln_tint = F)
+               irec_n(jp_sal) = sf_tsd(jp_sal)%nrec(2,sf_tsd(jp_sal)%naa)            ! If not, then do not apply the increments
+               IF( kt == nit000 ) irec_b(:) = -1
                !
                ij0 = 101 + nn_hls       ;   ij1 = 109 + nn_hls                       ! Reduced T & S in the Alboran Sea
                ii0 = 141 + nn_hls - 1   ;   ii1 = 155 + nn_hls - 1
-               DO jj = mj0(ij0), mj1(ij1)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     sf_tsd(jp_tem)%fnow(ji,jj,13:13) = sf_tsd(jp_tem)%fnow(ji,jj,13:13) - 0.20_wp
-                     sf_tsd(jp_tem)%fnow(ji,jj,14:15) = sf_tsd(jp_tem)%fnow(ji,jj,14:15) - 0.35_wp
-                     sf_tsd(jp_tem)%fnow(ji,jj,16:25) = sf_tsd(jp_tem)%fnow(ji,jj,16:25) - 0.40_wp
-                     !
-                     sf_tsd(jp_sal)%fnow(ji,jj,13:13) = sf_tsd(jp_sal)%fnow(ji,jj,13:13) - 0.15_wp
-                     sf_tsd(jp_sal)%fnow(ji,jj,14:15) = sf_tsd(jp_sal)%fnow(ji,jj,14:15) - 0.25_wp
-                     sf_tsd(jp_sal)%fnow(ji,jj,16:17) = sf_tsd(jp_sal)%fnow(ji,jj,16:17) - 0.30_wp
-                     sf_tsd(jp_sal)%fnow(ji,jj,18:25) = sf_tsd(jp_sal)%fnow(ji,jj,18:25) - 0.35_wp
+               IF( sf_tsd(jp_tem)%ln_tint .OR. irec_n(jp_tem) /= irec_b(jp_tem) ) THEN
+                  DO jj = mj0(ij0), mj1(ij1)
+                     DO ji = mi0(ii0), mi1(ii1)
+                        sf_tsd(jp_tem)%fnow(ji,jj,13:13) = sf_tsd(jp_tem)%fnow(ji,jj,13:13) - 0.20_wp
+                        sf_tsd(jp_tem)%fnow(ji,jj,14:15) = sf_tsd(jp_tem)%fnow(ji,jj,14:15) - 0.35_wp
+                        sf_tsd(jp_tem)%fnow(ji,jj,16:25) = sf_tsd(jp_tem)%fnow(ji,jj,16:25) - 0.40_wp
+                     END DO
                   END DO
-               END DO
+                  irec_b(jp_tem) = irec_n(jp_tem)
+               ENDIF
+               !
+               IF( sf_tsd(jp_sal)%ln_tint .OR. irec_n(jp_sal) /= irec_b(jp_sal) ) THEN
+                  DO jj = mj0(ij0), mj1(ij1)
+                     DO ji = mi0(ii0), mi1(ii1)
+                        sf_tsd(jp_sal)%fnow(ji,jj,13:13) = sf_tsd(jp_sal)%fnow(ji,jj,13:13) - 0.15_wp
+                        sf_tsd(jp_sal)%fnow(ji,jj,14:15) = sf_tsd(jp_sal)%fnow(ji,jj,14:15) - 0.25_wp
+                        sf_tsd(jp_sal)%fnow(ji,jj,16:17) = sf_tsd(jp_sal)%fnow(ji,jj,16:17) - 0.30_wp
+                        sf_tsd(jp_sal)%fnow(ji,jj,18:25) = sf_tsd(jp_sal)%fnow(ji,jj,18:25) - 0.35_wp
+                     END DO
+                  END DO
+                  irec_b(jp_sal) = irec_n(jp_sal)
+               ENDIF
+               !
                ij0 =  87 + nn_hls       ;   ij1 =  96 + nn_hls                       ! Reduced temperature in Red Sea
                ii0 = 148 + nn_hls - 1   ;   ii1 = 160 + nn_hls - 1
@@ -197,5 +212,4 @@
          ENDIF
          !
-         ! NOTE: [tiling-comms-merge] This fix was necessary to take out tra_adv lbc_lnk statements in the zps case, but did not work in the zco case
          DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )                  ! vertical interpolation of T & S
             DO jk = 1, jpk                        ! determines the intepolated T-S profiles at each (i,j) points
@@ -233,5 +247,4 @@
          !
          IF( ln_zps ) THEN                      ! zps-coordinate (partial steps) interpolation at the last ocean level
-            ! NOTE: [tiling-comms-merge] This fix was necessary to take out tra_adv lbc_lnk statements in the zps case
             DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
                ik = mbkt(ji,jj)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/istate.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/istate.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DOM/istate.F90	(revision 14200)
@@ -90,5 +90,5 @@
 
 #if defined key_agrif
-      IF ( (.NOT.Agrif_root()).AND.ln_init_chfrpar ) THEN
+      IF ( .NOT.Agrif_root() .AND. ln_init_chfrpar ) THEN
          numror = 0                           ! define numror = 0 -> no restart file to read
          ln_1st_euler = .true.                ! Set time-step indicator at nit000 (euler forward)
@@ -97,8 +97,4 @@
          !
          ts (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)
-!!st
-!!st need for a recent agrif version to be displaced toward ssh_init_rst with agrif_istate_ssh
-         ssh(:,:,    Kmm) = ssh(:,:    ,Kbb)
-!!st end
          uu (:,:,:  ,Kmm) = uu (:,:,:  ,Kbb)
          vv (:,:,:  ,Kmm) = vv (:,:,:  ,Kbb)
@@ -116,22 +112,10 @@
             CALL day_init                        ! model calendar (using both namelist and restart infos)
             !                                    ! Initialization of ocean to zero
+            !
             IF( ln_tsd_init ) THEN               
                CALL dta_tsd( nit000, ts(:,:,:,:,Kbb) )       ! read 3D T and S data at nit000
                !
-               ssh(:,:,Kbb)   = 0._wp               ! set the ocean at rest
-               uu  (:,:,:,Kbb) = 0._wp
+               uu  (:,:,:,Kbb) = 0._wp               ! set the ocean at rest
                vv  (:,:,:,Kbb) = 0._wp  
-               !
-               IF( ll_wd ) THEN
-                  ssh(:,:,Kbb) =  -ssh_ref  ! Added in 30 here for bathy that adds 30 as Iterative test CEOD 
-                  !
-                  ! Apply minimum wetdepth criterion
-                  !
-                  DO_2D( 1, 1, 1, 1 )
-                     IF( ht_0(ji,jj) + ssh(ji,jj,Kbb)  < rn_wdmin1 ) THEN
-                        ssh(ji,jj,Kbb) = tmask(ji,jj,1)*( rn_wdmin1 - (ht_0(ji,jj)) )
-                     ENDIF
-                  END_2D
-               ENDIF 
                !
             ELSE                                 ! user defined initial T and S
@@ -142,7 +126,6 @@
             ENDIF
             ts  (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb)       ! set now values from to before ones
-            ssh (:,:,Kmm)     = ssh(:,:,Kbb)   
-            uu   (:,:,:,Kmm)   = uu  (:,:,:,Kbb)
-            vv   (:,:,:,Kmm)   = vv  (:,:,:,Kbb)
+            uu    (:,:,:,Kmm) = uu   (:,:,:,Kbb)
+            vv    (:,:,:,Kmm) = vv   (:,:,:,Kbb)
 
          !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf.F90	(revision 14200)
@@ -60,11 +60,13 @@
    PUBLIC    dyn_atf   ! routine called by step.F90
 
-#if defined key_qco
+#if defined key_qco   ||   defined key_linssh
    !!----------------------------------------------------------------------
-   !!   'key_qco'      EMPTY ROUTINE     Quasi-Eulerian vertical coordonate
+   !!   'key_qco'                        Quasi-Eulerian vertical coordinate
+   !!       OR         EMPTY MODULE
+   !!   'key_linssh'                        Fix in time vertical coordinate
    !!----------------------------------------------------------------------
 CONTAINS
 
-   SUBROUTINE dyn_atf ( kt, Kbb, Kmm, Kaa, puu, pvv, pe3t, pe3u, pe3v )
+   SUBROUTINE dyn_atf( kt, Kbb, Kmm, Kaa, puu, pvv, pe3t, pe3u, pe3v )
       INTEGER                             , INTENT(in   ) :: kt               ! ocean time-step index
       INTEGER                             , INTENT(in   ) :: Kbb, Kmm, Kaa    ! before and after time level indices
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynatf_qco.F90	(revision 14200)
@@ -66,5 +66,5 @@
 CONTAINS
 
-   SUBROUTINE dyn_atf_qco ( kt, Kbb, Kmm, Kaa, puu, pvv )
+   SUBROUTINE dyn_atf_qco( kt, Kbb, Kmm, Kaa, puu, pvv )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE dyn_atf_qco  ***
@@ -196,5 +196,21 @@
       ! JC: Would be more clever to swap variables than to make a full vertical
       ! integration
-      ! CAUTION : calculation need to be done in the same way than see GM  
+      ! CAUTION : calculation need to be done in the same way than see GM
+#if defined key_linssh
+      uu_b(:,:,Kaa) = e3u(:,:,1,Kaa) * puu(:,:,1,Kaa) * umask(:,:,1)
+      uu_b(:,:,Kmm) = e3u(:,:,1,Kmm) * puu(:,:,1,Kmm) * umask(:,:,1)
+      vv_b(:,:,Kaa) = e3v(:,:,1,Kaa) * pvv(:,:,1,Kaa) * vmask(:,:,1)
+      vv_b(:,:,Kmm) = e3v(:,:,1,Kmm) * pvv(:,:,1,Kmm) * vmask(:,:,1)
+      DO jk = 2, jpkm1
+         uu_b(:,:,Kaa) = uu_b(:,:,Kaa) + e3u(:,:,jk,Kaa) * puu(:,:,jk,Kaa) * umask(:,:,jk)
+         uu_b(:,:,Kmm) = uu_b(:,:,Kmm) + e3u(:,:,jk,Kmm) * puu(:,:,jk,Kmm) * umask(:,:,jk)
+         vv_b(:,:,Kaa) = vv_b(:,:,Kaa) + e3v(:,:,jk,Kaa) * pvv(:,:,jk,Kaa) * vmask(:,:,jk)
+         vv_b(:,:,Kmm) = vv_b(:,:,Kmm) + e3v(:,:,jk,Kmm) * pvv(:,:,jk,Kmm) * vmask(:,:,jk)
+      END DO
+      uu_b(:,:,Kaa) = uu_b(:,:,Kaa) * r1_hu(:,:,Kaa)
+      vv_b(:,:,Kaa) = vv_b(:,:,Kaa) * r1_hv(:,:,Kaa)
+      uu_b(:,:,Kmm) = uu_b(:,:,Kmm) * r1_hu(:,:,Kmm)
+      vv_b(:,:,Kmm) = vv_b(:,:,Kmm) * r1_hv(:,:,Kmm)
+#else
       uu_b(:,:,Kaa) = e3u(:,:,1,Kaa) * puu(:,:,1,Kaa) * umask(:,:,1)
       uu_b(:,:,Kmm) = (e3u_0(:,:,1) * ( 1._wp + r3u_f(:,:) * umask(:,:,1) )) * puu(:,:,1,Kmm) * umask(:,:,1)
@@ -211,4 +227,5 @@
       uu_b(:,:,Kmm) = uu_b(:,:,Kmm) * (r1_hu_0(:,:)/( 1._wp + r3u_f(:,:) ))
       vv_b(:,:,Kmm) = vv_b(:,:,Kmm) * (r1_hv_0(:,:)/( 1._wp + r3v_f(:,:) ))
+#endif
       !
       IF( .NOT.ln_dynspg_ts ) THEN        ! output the barotropic currents
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynhpg.F90	(revision 14200)
@@ -183,14 +183,15 @@
       ENDIF
       !
-      IF( .NOT.ln_linssh .AND. .NOT.(ln_hpg_sco.OR.ln_hpg_prj.OR.ln_hpg_isf.OR.ln_hpg_djc) )          &
-         &   CALL ctl_stop('dyn_hpg_init : non-linear free surface requires either ',   &
-         &                 '   the standard jacobian formulation hpg_sco    or '    ,   &
-         &                 '   the pressure jacobian formulation hpg_prj'             )
-         !
+      IF( .NOT.ln_linssh .AND. (ln_hpg_zco.OR.ln_hpg_zps) )   &
+         &   CALL ctl_stop( 'dyn_hpg_init : non-linear free surface incompatible with hpg_zco or hpg_zps' )
+      !
+      IF( (.NOT.ln_hpg_isf .AND. ln_isfcav) .OR. (ln_hpg_isf .AND. .NOT.ln_isfcav) )                  &
+         &   CALL ctl_stop( 'dyn_hpg_init : ln_hpg_isf=T requires ln_isfcav=T and vice versa' )  
+      !
+#if defined key_qco
       IF( ln_hpg_isf ) THEN
-         IF( .NOT. ln_isfcav )   CALL ctl_stop( ' hpg_isf not available if ln_isfcav = false ' )
-       ELSE
-         IF(       ln_isfcav )   CALL ctl_stop( 'Only hpg_isf has been corrected to work with ice shelf cavity.' )
+         CALL ctl_stop( 'dyn_hpg_init : key_qco and ln_hpg_isf not yet compatible' )
       ENDIF
+#endif
       !
       !                               ! Set nhpg from ln_hpg_... flags & consistency check
@@ -239,4 +240,5 @@
          END IF
       END IF
+      !
    END SUBROUTINE dyn_hpg_init
 
@@ -756,5 +758,5 @@
       ! 4. a) Upper half of top-most grid box, compute and store
       !-------------------------------------------------------------
-! *** AY note: ssh(ji,jj,Kmm) + gde3w(ji,jj,1) = e3w(ji,jj,1)
+! *** AY note: ssh(ji,jj,Kmm) + gde3w(ji,jj,1) = e3w(ji,jj,1,Kmm)
       DO_2D( 0, 1, 0, 1)
          z_rho_k(ji,jj,1) =  grav * ( ssh(ji,jj,Kmm) + gde3w(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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/dynvor.F90	(revision 14200)
@@ -406,5 +406,5 @@
          END SELECT
          !
-#if defined key_qco
+#if defined key_qco   ||   defined key_linssh
          DO_2D( 1, 0, 1, 0 )                 !==  potential vorticity  ==!   (key_qco)
             zwz(ji,jj) = zwz(ji,jj) / e3f_vor(ji,jj,jk)
@@ -533,5 +533,5 @@
          !
          !
-#if defined key_qco
+#if defined key_qco   ||   defined key_linssh
          DO_2D( 1, 0, 1, 0 )                 !==  potential vorticity  ==!   (key_qco)
             zwz(ji,jj) = zwz(ji,jj) / e3f_vor(ji,jj,jk)
@@ -624,5 +624,5 @@
          !                                             ! ===============
          !
-#if defined key_qco
+#if defined key_qco   ||   defined key_linssh
          DO_2D( 1, 0, 1, 0 )                 ! == reciprocal of e3 at F-point (key_qco)
             z1_e3f(ji,jj) = 1._wp / e3f_vor(ji,jj,jk)
@@ -952,6 +952,6 @@
          !
       END SELECT
-#if defined key_qco
-      SELECT CASE( nvor_scheme )    ! qco case: pre-computed a specific e3f_0 for some vorticity schemes
+#if defined key_qco   ||   defined key_linssh
+      SELECT CASE( nvor_scheme )    ! qco or linssh cases : pre-computed a specific e3f_0 for some vorticity schemes
       CASE( np_ENS , np_ENE , np_EEN , np_MIX )
          !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/DYN/sshwzv.F90	(revision 14200)
@@ -18,5 +18,4 @@
    !!   ssh_atf       : time filter the ssh arrays
    !!   wzv           : compute now vertical velocity
-   !!   ssh_init_rst  : ssh set from restart or domcfg.nc file or usr_def_istat_ssh
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers variables
@@ -29,4 +28,5 @@
    USE bdy_oce , ONLY : ln_bdy, bdytmask   ! Open BounDarY
    USE bdydyn2d       ! bdy_ssh routine
+   USE wet_dry        ! Wetting/Drying flux limiting
 #if defined key_agrif
    USE agrif_oce
@@ -41,6 +41,4 @@
    USE lib_mpp        ! MPP library
    USE timing         ! Timing
-   USE wet_dry        ! Wetting/Drying flux limiting
-   USE usrdef_istate, ONLY : usr_def_istate_ssh   ! user defined ssh initial state 
    
    IMPLICIT NONE
@@ -51,5 +49,4 @@
    PUBLIC   wAimp          ! called by step.F90
    PUBLIC   ssh_atf        ! called by step.F90
-   PUBLIC   ssh_init_rst   ! called by domain.F90
 
    !! * Substitutions
@@ -436,86 +433,4 @@
       !
    END SUBROUTINE wAimp
-
-
-   SUBROUTINE ssh_init_rst( Kbb, Kmm, Kaa )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE ssh_init_rst  ***
-      !!
-      !! ** Purpose :   ssh initialization of the sea surface height (ssh)
-      !!
-      !! ** Method  :   set ssh from restart or read configuration, or user_def
-      !!              * ln_rstart = T
-      !!                   USE of IOM library to read ssh in the restart file
-      !!                   Leap-Frog: Kbb and Kmm are read except for l_1st_euler=T
-      !!
-      !!              * otherwise 
-      !!                   call user defined ssh or
-      !!                   set to -ssh_ref in wet and drying case with domcfg.nc
-      !!
-      !!              NB: ssh_b/n are written by restart.F90
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   Kbb, Kmm, Kaa   ! ocean time level indices
-      !
-      INTEGER ::   ji, jj, jk
-      !!----------------------------------------------------------------------
-      !
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'ssh_init_rst : ssh initialization'
-         WRITE(numout,*) '~~~~~~~~~~~~ '
-      ENDIF
-      !
-      !                            !=============================!
-      IF( ln_rstart ) THEN         !==  Read the restart file  ==!
-         !                         !=============================!
-         !
-         !                                     !*  Read ssh at Kmm
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*)    '      Kmm sea surface height read in the restart file'
-         CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm) )
-         !
-         IF( l_1st_euler ) THEN                !* Euler at first time-step
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '      Euler first time step : ssh(Kbb) = ssh(Kmm)'
-            ssh(:,:,Kbb) = ssh(:,:,Kmm)
-            !
-         ELSE                                  !* read ssh at Kbb
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '      Kbb sea surface height read in the restart file'
-            CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb) )
-         ENDIF
-         !                         !============================!
-      ELSE                         !==  Initialize at "rest"  ==!
-         !                         !============================!
-         !
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*)    '      initialization at rest'
-         !
-         IF( ll_wd ) THEN                      !* wet and dry 
-            !
-            IF( ln_read_cfg  ) THEN                 ! read configuration : ssh_ref is read in domain_cfg file
-!!st  why ssh is not masked : i.e. ssh(:,:,Kmm) = -ssh_ref*ssmask(:,:),
-!!st  since at the 1st time step lbclnk will be applied on ssh at Kaa but not initially at Kbb and Kmm
-               ssh(:,:,Kbb) = -ssh_ref
-               !
-               DO_2D( 1, 1, 1, 1 )
-                  IF( ht_0(ji,jj)-ssh_ref <  rn_wdmin1 ) THEN   ! if total depth is less than min depth
-                     ssh(ji,jj,Kbb) = rn_wdmin1 - ht_0(ji,jj)
-                  ENDIF
-               END_2D
-            ELSE                                    ! user define configuration case  
-               CALL usr_def_istate_ssh( tmask, ssh(:,:,Kbb) )
-            ENDIF
-            !
-         ELSE                                  !* user defined configuration
-            CALL usr_def_istate_ssh( tmask, ssh(:,:,Kbb) )
-            !
-         ENDIF
-         !
-         ssh(:,:,Kmm) = ssh(:,:,Kbb)           !* set now values from to before ones
-         ssh(:,:,Kaa) = 0._wp 
-      ENDIF
-      !
-   END SUBROUTINE ssh_init_rst
       
    !!======================================================================
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ICB/icbutl.F90	(revision 14200)
@@ -57,4 +57,6 @@
    PUBLIC   icb_utl_heat          ! routine called in icbdia module
 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -127,7 +129,8 @@
             CALL lbc_lnk_icb( 'icbutl', ztmp, 'V', -1._wp, 1, 1 )
             voce_e(:,:,jk) = ztmp(:,:)
+            !
+            e3t_e(1:jpi,1:jpj,jk) = e3t(:,:,jk,Kmm)
          END DO
-         toce_e(1:jpi,1:jpj,1:jpk) = ts(:,:,:,1,Kmm)
-         e3t_e (1:jpi,1:jpj,1:jpk) = e3t(:,:,:,Kmm)
+         toce_e(1:jpi,1:jpj,:) = ts(:,:,:,1,Kmm)
       END IF
       !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/IOM/restart.F90	(revision 14200)
@@ -11,32 +11,41 @@
    !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
    !!             -   !  2014-12  (G. Madec) remove KPP scheme
-   !!            4.1  !  2020-11  (S. Techene, G. Madec)  move ssh initiatlisation in DYN/sshwzv:ssh_init_rst
+   !!            4.1  !  2020-11  (S. Techene, G. Madec)  move ssh initiatlisation in rst_read_ssh
+   !!             -   !                                   add restart in Shallow Water Eq. case
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   rst_opn    : open the ocean restart file
-   !!   rst_write  : write the ocean restart file
-   !!   rst_read   : read the ocean restart file
+   !!   rst_opn       : open the ocean restart file for writting
+   !!   rst_write     : write the ocean restart file
+   !!   rst_read_open : open the restart file for reading 
+   !!   rst_read      : read the ocean restart file
+   !!   rst_read_ssh  : ssh set from restart or domcfg.nc file or usr_def_istat_ssh
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_ice         ! only lk_si3
-   USE phycst          ! physical constants
-   USE eosbn2          ! equation of state            (eos bn2 routine)
-   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE sbc_ice        ! only lk_si3
+   USE phycst         ! physical constants
+   USE eosbn2         ! equation of state
+   USE wet_dry        ! Wetting/Drying flux limiting
+   USE usrdef_istate, ONLY : usr_def_istate_ssh   ! user defined ssh initial state 
+   USE trdmxl_oce     ! ocean active mixed layer tracers trends variables
+   USE diu_bulk       ! ???
    !
-   USE in_out_manager  ! I/O manager
-   USE iom             ! I/O module
-   USE diu_bulk
-   USE lib_mpp         ! distribued memory computing library
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O module
+   USE lib_mpp        ! distribued memory computing library
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   rst_opn         ! routine called by step module
-   PUBLIC   rst_write       ! routine called by step module
-   PUBLIC   rst_read        ! routine called by istate module
-   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init
-
+   PUBLIC   rst_opn         ! called by step.F90
+   PUBLIC   rst_write       ! called by step.F90
+   PUBLIC   rst_read_open   ! called in rst_read_ssh
+   PUBLIC   rst_read        ! called by istate.F90
+   PUBLIC   rst_read_ssh    ! called by domain.F90
+   
+   !! * Substitutions
+#  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -142,30 +151,38 @@
       !!
       !!                NB: ssh is written here (rst_write)
-      !!                    but is read or set in DYN/sshwzv:shh_init_rst
+      !!                    but is read or set in rst_read_ssh
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt         ! ocean time-step
       INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
       !!----------------------------------------------------------------------
-                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_Dt       )   ! dynamics time step
-                     IF(.NOT.lwxios) CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
-
-      IF ( .NOT. ln_diurnal_only ) THEN
-                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , uu(:,:,:       ,Kbb) )     ! before fields
-                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vv(:,:,:       ,Kbb) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , ts(:,:,:,jp_tem,Kbb) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , ts(:,:,:,jp_sal,Kbb) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , ssh(:,:         ,Kbb))
-                     !
-                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , uu(:,:,:       ,Kmm) )     ! now fields
-                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vv(:,:,:       ,Kmm) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , ts(:,:,:,jp_tem,Kmm) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , ts(:,:,:,jp_sal,Kmm) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , ssh(:,:         ,Kmm))
-                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      )
-      ENDIF
-
-      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst )
+      !
+         CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_Dt       )   ! dynamics time step
+      !
+      IF( .NOT.lwxios )   CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
+      !
+      IF( .NOT.ln_diurnal_only ) THEN
+         CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , ssh(:,:        ,Kbb) )     ! before fields
+         CALL iom_rstput( kt, nitrst, numrow, 'ub'     , uu(:,:,:       ,Kbb) )
+         CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vv(:,:,:       ,Kbb) )
+         IF( .NOT.lk_SWE ) THEN
+            CALL iom_rstput( kt, nitrst, numrow, 'tb'  , ts(:,:,:,jp_tem,Kbb) )
+            CALL iom_rstput( kt, nitrst, numrow, 'sb'  , ts(:,:,:,jp_sal,Kbb) )
+         ENDIF
+         !
+#if ! defined key_RK3
+         CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , ssh(:,:        ,Kmm) )     ! now fields
+         CALL iom_rstput( kt, nitrst, numrow, 'un'     , uu(:,:,:       ,Kmm) )
+         CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vv(:,:,:       ,Kmm) )
+         IF( .NOT.lk_SWE ) THEN
+            CALL iom_rstput( kt, nitrst, numrow, 'tn'  , ts(:,:,:,jp_tem,Kmm) )
+            CALL iom_rstput( kt, nitrst, numrow, 'sn'  , ts(:,:,:,jp_sal,Kmm) )
+            CALL iom_rstput( kt, nitrst, numrow, 'rhop', rhop                 )
+         ENDIF
+#endif
+      ENDIF
+
+      IF( ln_diurnal )   CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst )
       IF( kt == nitrst ) THEN
-         IF(.NOT.lwxios) THEN
+         IF( .NOT.lwxios ) THEN
             CALL iom_close( numrow )     ! close the restart file (only at last time step)
          ELSE
@@ -177,8 +194,8 @@
 !!gm  not sure what to do here   ===>>>  ask to Sebastian
          lrst_oce = .FALSE.
-            IF( ln_rst_list ) THEN
-               nrst_lst = MIN(nrst_lst + 1, SIZE(nn_stocklist,1))
-               nitrst = nn_stocklist( nrst_lst )
-            ENDIF
+         IF( ln_rst_list ) THEN
+            nrst_lst = MIN(nrst_lst + 1, SIZE(nn_stocklist,1))
+            nitrst   = nn_stocklist( nrst_lst )
+         ENDIF
       ENDIF
       !
@@ -245,17 +262,17 @@
       !!                    (sshb)
       !!
-      !!                NB: ssh is read or set in DYN/sshwzv:shh_init_rst
-      !!                    but is written     in IOM/restart:rst_write
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
+      !!                NB: ssh is read or set in rst_read_ssh
+      !!----------------------------------------------------------------------
+      INTEGER          , INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
       INTEGER  ::   jk
       REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
-      !!----------------------------------------------------------------------
-      !
-      IF(.NOT.lrxios ) CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   :: zgdept       ! 3D workspace for QCO
+      !!----------------------------------------------------------------------
+      !
+      IF(.NOT.lrxios )   CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
       !
       !                             !*  Diurnal DSST
       IF( ln_diurnal )   CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst )
-      IF ( ln_diurnal_only ) THEN
+      IF( ln_diurnal_only ) THEN
          IF(lwp) WRITE( numout, * ) &
          &   "rst_read:- ln_diurnal_only set, setting rhop=rho0"
@@ -266,31 +283,157 @@
       ENDIF
       !
-      !                             !*  Read Kmm fields
+#if defined key_RK3
+      !                             !*  Read Kbb fields   (NB: in RK3 Kmm = Kbb = Nbb)
+      IF(lwp) WRITE(numout,*) '           Kbb u, v and T-S fields read in the restart file'
+      CALL iom_get( numror, jpdom_auto, 'ub'   , uu(:,:,:       ,Kbb), cd_type = 'U', psgn = -1._wp )
+      CALL iom_get( numror, jpdom_auto, 'vb'   , vv(:,:,:       ,Kbb), cd_type = 'V', psgn = -1._wp )
+      IF( .NOT.lk_SWE ) THEN
+         CALL iom_get( numror, jpdom_auto, 'tb', ts(:,:,:,jp_tem,Kbb) )
+         CALL iom_get( numror, jpdom_auto, 'sb', ts(:,:,:,jp_sal,Kbb) )
+      ENDIF
+#else
+      !                             !*  Read Kmm fields   (MLF only)
       IF(lwp) WRITE(numout,*)    '           Kmm u, v and T-S fields read in the restart file'
-      CALL iom_get( numror, jpdom_auto, 'un'     , uu(:,:,:       ,Kmm), cd_type = 'U', psgn = -1._wp )
-      CALL iom_get( numror, jpdom_auto, 'vn'     , vv(:,:,:       ,Kmm), cd_type = 'V', psgn = -1._wp )
-      CALL iom_get( numror, jpdom_auto, 'tn'     , ts(:,:,:,jp_tem,Kmm) )
-      CALL iom_get( numror, jpdom_auto, 'sn'     , ts(:,:,:,jp_sal,Kmm) )
-      !
-      IF( l_1st_euler ) THEN        !*  Euler restart
+      CALL iom_get( numror, jpdom_auto, 'un'   , uu(:,:,:       ,Kmm), cd_type = 'U', psgn = -1._wp )
+      CALL iom_get( numror, jpdom_auto, 'vn'   , vv(:,:,:       ,Kmm), cd_type = 'V', psgn = -1._wp )
+      IF( .NOT.lk_SWE ) THEN
+         CALL iom_get( numror, jpdom_auto, 'tn', ts(:,:,:,jp_tem,Kmm) )
+         CALL iom_get( numror, jpdom_auto, 'sn', ts(:,:,:,jp_sal,Kmm) )
+      ENDIF
+      !
+      IF( l_1st_euler ) THEN        !*  Euler restart   (MLF only)
          IF(lwp) WRITE(numout,*) '           Kbb u, v and T-S fields set to Kmm values'
-         ts(:,:,:,:,Kbb) = ts(:,:,:,:,Kmm)         ! all before fields set to now values
-         uu(:,:,:  ,Kbb) = uu(:,:,:  ,Kmm)
+         uu(:,:,:  ,Kbb) = uu(:,:,:  ,Kmm)         ! all before fields set to now values
          vv(:,:,:  ,Kbb) = vv(:,:,:  ,Kmm)
-      ELSE                          !* Leap frog restart
+         IF( .NOT.lk_SWE ) ts(:,:,:,:,Kbb) = ts(:,:,:,:,Kmm)
+         !
+      ELSE                          !* Leap frog restart   (MLF only)
          IF(lwp) WRITE(numout,*) '           Kbb u, v and T-S fields read in the restart file'
-         CALL iom_get( numror, jpdom_auto, 'ub'     , uu(:,:,:       ,Kbb), cd_type = 'U', psgn = -1._wp )
-         CALL iom_get( numror, jpdom_auto, 'vb'     , vv(:,:,:       ,Kbb), cd_type = 'V', psgn = -1._wp )
-         CALL iom_get( numror, jpdom_auto, 'tb'     , ts(:,:,:,jp_tem,Kbb) )
-         CALL iom_get( numror, jpdom_auto, 'sb'     , ts(:,:,:,jp_sal,Kbb) )
-      ENDIF
-      !
-      IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_auto, 'rhop'   , rhop )   ! now    potential density
-      ELSE
-         CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) )
+         CALL iom_get( numror, jpdom_auto, 'ub'   , uu(:,:,:       ,Kbb), cd_type = 'U', psgn = -1._wp )
+         CALL iom_get( numror, jpdom_auto, 'vb'   , vv(:,:,:       ,Kbb), cd_type = 'V', psgn = -1._wp )
+         IF( .NOT.lk_SWE ) THEN
+            CALL iom_get( numror, jpdom_auto, 'tb', ts(:,:,:,jp_tem,Kbb) )
+            CALL iom_get( numror, jpdom_auto, 'sb', ts(:,:,:,jp_sal,Kbb) )
+         ENDIF
+      ENDIF
+#endif
+      !
+      IF( .NOT.lk_SWE ) THEN
+         IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
+            CALL iom_get( numror, jpdom_auto, 'rhop'   , rhop )   ! now    potential density
+         ELSE
+#if defined key_qco
+            ALLOCATE( zgdept(jpi,jpj,jpk) )
+            DO jk = 1, jpk
+               zgdept(:,:,jk) = gdept(:,:,jk,Kmm)
+            END DO
+            CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, zgdept )
+            DEALLOCATE( zgdept )
+#else
+            CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) )
+#endif
+         ENDIF
       ENDIF
       !
    END SUBROUTINE rst_read
+
+
+   SUBROUTINE rst_read_ssh( Kbb, Kmm, Kaa )
+      !!---------------------------------------------------------------------
+      !!                   ***  ROUTINE rst_read_ssh  ***
+      !!
+      !! ** Purpose :   ssh initialization of the sea surface height (ssh)
+      !!
+      !! ** Method  :   set ssh from restart or read configuration, or user_def
+      !!              * ln_rstart = T
+      !!                   USE of IOM library to read ssh in the restart file
+      !!                   Leap-Frog: Kbb and Kmm are read except for l_1st_euler=T
+      !!
+      !!              * otherwise 
+      !!                   call user defined ssh or
+      !!                   set to -ssh_ref in wet and drying case with domcfg.nc
+      !!
+      !!              NB: ssh_b/n are written by restart.F90
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   Kbb, Kmm, Kaa   ! ocean time level indices
+      !
+      INTEGER ::   ji, jj, jk
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'rst_read_ssh : ssh initialization'
+         WRITE(numout,*) '~~~~~~~~~~~~ '
+      ENDIF
+      !
+      !                            !=============================!
+      IF( ln_rstart ) THEN         !==  Read the restart file  ==!
+         !                         !=============================!
+         !
+#if defined key_RK3
+         !                                     !*  RK3: Read ssh at Kbb
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)    '      Kbb sea surface height read in the restart file'
+         CALL iom_get( numror, jpdom_auto, 'sshb'   , ssh(:,:,Kbb) )
+         !
+         !                                     !*  RK3: Set ssh at Kmm for AGRIF
+         ssh(:,:,Kmm) = 0._wp
+#else
+         !                                     !*  MLF: Read ssh at Kmm
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)    '      Kmm sea surface height read in the restart file'
+         CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm) )
+         !
+         IF( l_1st_euler ) THEN                !*  MLF: Euler at first time-step
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '      Euler first time step : ssh(Kbb) = ssh(Kmm)'
+            ssh(:,:,Kbb) = ssh(:,:,Kmm)
+            !
+         ELSE                                  !*  MLF: read ssh at Kbb
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) '      Kbb sea surface height read in the restart file'
+            CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb) )
+         ENDIF
+#endif
+         !                         !============================!
+      ELSE                         !==  Initialize at "rest"  ==!
+         !                         !============================!
+         !
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*)    '      initialization at rest'
+         !
+         IF( ll_wd ) THEN                      !* wet and dry 
+            !
+            IF( ln_read_cfg  ) THEN                 ! read configuration : ssh_ref is read in domain_cfg file
+!!st  why ssh is not masked : i.e. ssh(:,:,Kmm) = -ssh_ref*ssmask(:,:),
+!!st  since at the 1st time step lbclnk will be applied on ssh at Kaa but not initially at Kbb and Kmm
+               ssh(:,:,Kbb) = -ssh_ref
+               !
+               DO_2D( 1, 1, 1, 1 )
+                  IF( ht_0(ji,jj)-ssh_ref <  rn_wdmin1 ) THEN   ! if total depth is less than min depth
+                     ssh(ji,jj,Kbb) = rn_wdmin1 - ht_0(ji,jj)
+                  ENDIF
+               END_2D
+            ELSE                                    ! user define configuration case  
+               CALL usr_def_istate_ssh( tmask, ssh(:,:,Kbb) )
+            ENDIF
+            !
+         ELSE                                  !* user defined configuration
+            CALL usr_def_istate_ssh( tmask, ssh(:,:,Kbb) )
+            !
+         ENDIF
+         !
+#if defined key_RK3
+         ssh(:,:,Kmm) = 0._wp                  !* RK3: set Kmm to 0 for AGRIF
+#else
+         ssh(:,:,Kmm) = ssh(:,:,Kbb)           !* MLF: set now values from to before ones 
+#endif
+      ENDIF
+      !
+      !                            !==========================!
+      ssh(:,:,Kaa) = 0._wp         !==  Set to 0 for AGRIF  ==!
+      !                            !==========================!
+      !
+   END SUBROUTINE rst_read_ssh
 
    !!=====================================================================
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfcpl.F90	(revision 14200)
@@ -15,4 +15,6 @@
 #if defined key_qco
    USE domqco  , ONLY : dom_qco_zgr      ! vertical scale factor interpolation
+#elif defined key_linssh
+   !                                     ! fix in time coordinate
 #else
    USE domvvl  , ONLY : dom_vvl_zgr      ! vertical scale factor interpolation
@@ -117,5 +119,5 @@
       vv   (:,:,:,Kbb)   = vv   (:,:,:,Kmm)
       ssh (:,:,Kbb)     = ssh (:,:,Kmm)
-#if ! defined key_qco
+#if ! defined key_qco   &&   ! defined key_linssh
       e3t(:,:,:,Kbb)   = e3t(:,:,:,Kmm)
 #endif
@@ -217,5 +219,9 @@
       IF(lwp) write(numout,*) 'isfcpl_ssh : recompute scale factor from ssh (new wet cell,Kmm)'
       IF(lwp) write(numout,*) '~~~~~~~~~~~'
-#if ! defined key_qco
+#if defined key_qco
+      CALL dom_qco_zgr(Kbb, Kmm)
+#elif defined key_linssh
+      ! linear ssh : fix in time coord.
+#else
       DO jk = 1, jpk
          e3t(:,:,jk,Kmm) = e3t_0(:,:,jk) * ( 1._wp + (ht_0(:,:) + ssh(:,:,Kmm)) * r1_ht_0(:,:) )
@@ -223,6 +229,4 @@
       e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
       CALL dom_vvl_zgr(Kbb, Kmm, Kaa)
-#else
-      CALL dom_qco_zgr(Kbb, Kmm)
 #endif
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfstp.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfstp.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ISF/isfstp.F90	(revision 14200)
@@ -87,7 +87,7 @@
             ze3t(:,:,jk) = e3t(:,:,jk,Kmm)
          END DO 
-         CALL isf_tbl_lvl( ht(:,:), ze3t, misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
+         CALL isf_tbl_lvl( ht(:,:), ze3t           , misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
 #else
-         CALL isf_tbl_lvl( ht(:,:),  e3t, misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
+         CALL isf_tbl_lvl( ht(:,:),  e3t(:,:,:,Kmm), misfkt_cav, misfkb_cav, rhisf_tbl_cav, rfrac_tbl_cav )
 #endif
          !
@@ -116,7 +116,7 @@
             ze3t(:,:,jk) = e3t(:,:,jk,Kmm)
          END DO
-         CALL isf_tbl_lvl( ht(:,:), ze3t, misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+         CALL isf_tbl_lvl( ht(:,:), ze3t           , misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
 #else
-         CALL isf_tbl_lvl( ht(:,:),  e3t, misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
+         CALL isf_tbl_lvl( ht(:,:),  e3t(:,:,:,Kmm), misfkt_par, misfkb_par, rhisf_tbl_par, rfrac_tbl_par )
 #endif
          !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldfc1d_c2d.F90	(revision 14200)
@@ -140,5 +140,4 @@
          END_2D
       CASE( 'TRA' )                       ! U- and V-points
-         ! NOTE: [tiling-comms-merge] Change needed to preserve results with respect to the trunk
          DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
             pah1(ji,jj,1) = pUfac * MAX( e1u(ji,jj), e2u(ji,jj) )**knn
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/LDF/ldftra.F90	(revision 14200)
@@ -427,5 +427,4 @@
          zaht_min = 0.2_wp * aht0                                       ! minimum value for aht
          zDaht    = aht0 - zaht_min
-         ! NOTE: [tiling-comms-merge] Change needed to preserve results with respect to the trunk
          DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
             !!gm CAUTION : here we assume lat/lon grid in 20deg N/S band (like all ORCA cfg)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcfwb.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcfwb.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/SBC/sbcfwb.F90	(revision 14200)
@@ -24,4 +24,5 @@
    !
    USE in_out_manager ! I/O manager
+   USE iom            ! IOM
    USE lib_mpp        ! distribued memory computing library
    USE timing         ! Timing
@@ -34,7 +35,7 @@
    PUBLIC   sbc_fwb    ! routine called by step
 
-   REAL(wp) ::   a_fwb_b   ! annual domain averaged freshwater budget
-   REAL(wp) ::   a_fwb     ! for 2 year before (_b) and before year.
-   REAL(wp) ::   fwfold    ! fwfold to be suppressed
+   REAL(wp) ::   rn_fwb0   ! initial freshwater adjustment flux [kg/m2/s] (nn_fwb = 2 only)
+   REAL(wp) ::   a_fwb     ! annual domain averaged freshwater budget from the
+                           ! previous year
    REAL(wp) ::   area      ! global mean ocean surface (interior domain)
 
@@ -65,5 +66,5 @@
       INTEGER, INTENT( in ) ::   Kmm      ! ocean time level index
       !
-      INTEGER  ::   inum, ikty, iyear     ! local integers
+      INTEGER  ::   ios, inum, ikty       ! local integers
       REAL(wp) ::   z_fwf, z_fwf_nsrf, zsum_fwf, zsum_erp                ! local scalars
       REAL(wp) ::   zsurf_neg, zsurf_pos, zsurf_tospread, zcoef          !   -      -
@@ -72,7 +73,14 @@
       REAL(wp)   ,DIMENSION(1) ::   z_fwfprv  
       COMPLEX(dp),DIMENSION(1) ::   y_fwfnow  
+      !
+      NAMELIST/namsbc_fwb/rn_fwb0
       !!----------------------------------------------------------------------
       !
       IF( kt == nit000 ) THEN
+         READ( numnam_ref, namsbc_fwb, IOSTAT = ios, ERR = 901 )
+901      IF( ios /= 0 ) CALL ctl_nam( ios, 'namsbc_fwb in reference namelist'     )
+         READ( numnam_cfg, namsbc_fwb, IOSTAT = ios, ERR = 902 )
+902      IF( ios >  0 ) CALL ctl_nam( ios, 'namsbc_fwb in configuration namelist' )
+         IF(lwm) WRITE( numond, namsbc_fwb )
          IF(lwp) THEN
             WRITE(numout,*)
@@ -80,6 +88,11 @@
             WRITE(numout,*) '~~~~~~~'
             IF( kn_fwb == 1 )   WRITE(numout,*) '          instantaneously set to zero'
-            IF( kn_fwb == 2 )   WRITE(numout,*) '          adjusted from previous year budget'
             IF( kn_fwb == 3 )   WRITE(numout,*) '          fwf set to zero and spread out over erp area'
+            IF( kn_fwb == 2 ) THEN
+               WRITE(numout,*) '          adjusted from previous year budget'
+               WRITE(numout,*)
+               WRITE(numout,*) '   Namelist namsbc_fwb'
+               WRITE(numout,*) '      Initial freshwater adjustment flux [kg/m2/s] = ', rn_fwb0
+            END IF
          ENDIF
          !
@@ -112,41 +125,43 @@
          ENDIF
          !
-      CASE ( 2 )                             !==  fwf budget adjusted from the previous year  ==!
-         !
-         IF( kt == nit000 ) THEN                      ! initialisation
-            !                                         ! Read the corrective factor on precipitations (fwfold)
-            CALL ctl_opn( inum, 'EMPave_old.dat', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. )
-            READ ( inum, "(24X,I8,2ES24.16)" ) iyear, a_fwb_b, a_fwb
-            CLOSE( inum )
-            fwfold = a_fwb                            ! current year freshwater budget correction
-            !                                         ! estimate from the previous year budget
+      CASE ( 2 )                             !==  fw adjustment based on fw budget at the end of the previous year  ==!
+         !
+         IF( kt == nit000 ) THEN                                                                    ! initialisation
+            !                                                                                       ! set the fw adjustment (a_fwb)
+            IF ( ln_rstart .AND. iom_varid( numror, 'a_fwb',   ldstop = .FALSE. ) > 0 ) THEN        !    as read from restart file
+               IF(lwp) WRITE(numout,*) 'sbc_fwb : reading FW-budget adjustment from restart file'
+               CALL iom_get( numror, 'a_fwb',   a_fwb )
+            ELSE                                                                                    !    as specified in namelist
+               a_fwb = rn_fwb0
+            END IF
+            !
             IF(lwp)WRITE(numout,*)
-            IF(lwp)WRITE(numout,*)'sbc_fwb : year = ',iyear  , ' freshwater budget correction = ', fwfold
-            IF(lwp)WRITE(numout,*)'          year = ',iyear-1, ' freshwater budget read       = ', a_fwb
-            IF(lwp)WRITE(numout,*)'          year = ',iyear-2, ' freshwater budget read       = ', a_fwb_b
+            IF(lwp)WRITE(numout,*)'sbc_fwb : initial freshwater-budget adjustment = ', a_fwb, 'kg/m2/s'
+            !
          ENDIF   
-         !                                         ! Update fwfold if new year start
+         !                                         ! Update a_fwb if new year start
          ikty = 365 * 86400 / rn_Dt                  !!bug  use of 365 days leap year or 360d year !!!!!!!
          IF( MOD( kt, ikty ) == 0 ) THEN
-            a_fwb_b = a_fwb                           ! mean sea level taking into account the ice+snow
+                                                      ! mean sea level taking into account the ice+snow
                                                       ! sum over the global domain
             a_fwb   = glob_sum( 'sbcfwb', e1e2t(:,:) * ( ssh(:,:,Kmm) + snwice_mass(:,:) * r1_rho0 ) )
             a_fwb   = a_fwb * 1.e+3 / ( area * rday * 365. )     ! convert in Kg/m3/s = mm/s
 !!gm        !                                                      !!bug 365d year 
-            fwfold =  a_fwb                           ! current year freshwater budget correction
-            !                                         ! estimate from the previous year budget
          ENDIF
          ! 
          IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN         ! correct the freshwater fluxes
-            zcoef = fwfold * rcp
-            emp(:,:) = emp(:,:) + fwfold             * tmask(:,:,1)
+            zcoef = a_fwb * rcp
+            emp(:,:) = emp(:,:) + a_fwb              * tmask(:,:,1)
             qns(:,:) = qns(:,:) - zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction
          ENDIF
-         !
-         IF( kt == nitend .AND. lwm ) THEN            ! save fwfold value in a file (only one required)
-            CALL ctl_opn( inum, 'EMPave.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea )
-            WRITE( inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb
-            CLOSE( inum )
-         ENDIF
+         ! Output restart information
+         IF( lrst_oce ) THEN
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'sbc_fwb : writing FW-budget adjustment to ocean restart file at it = ', kt
+            IF(lwp) WRITE(numout,*) '~~~~'
+            CALL iom_rstput( kt, nitrst, numrow, 'a_fwb',   a_fwb )
+         END IF
+         !
+         IF( kt == nitend .AND. lwp ) WRITE(numout,*) 'sbc_fwb : final freshwater-budget adjustment = ', a_fwb, 'kg/m2/s'
          !
       CASE ( 3 )                             !==  global fwf set to zero and spread out over erp area  ==!
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/eosbn2.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/eosbn2.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/eosbn2.F90	(revision 14200)
@@ -89,6 +89,6 @@
 
    !                               !!!  simplified eos coefficients (default value: Vallis 2006)
-   REAL(wp) ::   rn_a0      = 1.6550e-1_wp     ! thermal expansion coeff.
-   REAL(wp) ::   rn_b0      = 7.6554e-1_wp     ! saline  expansion coeff.
+   REAL(wp), PUBLIC ::   rn_a0      = 1.6550e-1_wp     ! thermal expansion coeff.
+   REAL(wp), PUBLIC ::   rn_b0      = 7.6554e-1_wp     ! saline  expansion coeff.
    REAL(wp) ::   rn_lambda1 = 5.9520e-2_wp     ! cabbeling coeff. in T^2
    REAL(wp) ::   rn_lambda2 = 5.4914e-4_wp     ! cabbeling coeff. in S^2
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv.F90	(revision 14200)
@@ -175,5 +175,4 @@
          ENDIF
          !
-         ! NOTE: [tiling-comms-merge] These lbc_lnk calls are still needed (pts in the zco case because zps_hde is not called in step, zuu/zvv/zww in all cases, I think because DO loop bounds need to be updated in DYN as done in TRA)
          SELECT CASE ( nadv )                      !==  compute advection trend and add it to general trend  ==!
          !
@@ -194,5 +193,4 @@
             END IF
          CASE ( np_MUS )                                 ! MUSCL
-            ! NOTE: [tiling-comms-merge] I added this lbc_lnk as it did not validate against the trunk when using ln_zco
             IF (nn_hls.EQ.2) THEN
                 CALL lbc_lnk( 'traadv', pts(:,:,:,:,Kbb), 'T', 1.)
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_fct.F90	(revision 14200)
@@ -82,5 +82,4 @@
       REAL(wp)                                 , INTENT(in   ) ::   p2dt            ! tracer time-step
       ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)
-      ! NOTE: [tiling-comms-merge] These were changed to INTENT(inout) but they are not modified, so it is reverted
       REAL(wp), DIMENSION(jpi,jpj,jpk         ), INTENT(in   ) ::   pU, pV, pW      ! 3 ocean volume flux components
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) ::   pt              ! tracers and RHS of tracer equation
@@ -102,5 +101,4 @@
             IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
          ENDIF
-         ! NOTE: [tiling-comms-merge] Bug fix- move array zeroing out of this IF block
          !
          l_trd = .FALSE.            ! set local switches
@@ -353,6 +351,4 @@
             END_3D
          END IF
-         ! NOTE: [tiling-comms-merge] I tested this
-         ! NOT TESTED - NEED l_trd OR l_hst TRUE
          IF( l_trd .OR. l_hst ) THEN   ! trend diagnostics // heat/salt transport
             ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:)  ! <<< add anti-diffusive fluxes
@@ -369,6 +365,4 @@
             !
          ENDIF
-         ! NOTE: [tiling-comms-merge] I tested this
-         ! NOT TESTED - NEED l_ptr TRUE
          IF( l_ptr ) THEN              ! "Poleward" transports
             zptry(:,:,:) = zptry(:,:,:) + zwy(:,:,:)  ! <<< add anti-diffusive fluxes
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traadv_qck.F90	(revision 14200)
@@ -92,5 +92,4 @@
       REAL(wp)                                 , INTENT(in   ) ::   p2dt            ! tracer time-step
       ! TEMP: [tiling] This can be A2D(nn_hls) if using XIOS (subdomain support)
-      ! NOTE: [tiling-comms-merge] These were changed to INTENT(inout) but they are not modified, so it is reverted
       REAL(wp), DIMENSION(jpi,jpj,jpk         ), INTENT(in   ) ::   pU, pV, pW      ! 3 ocean volume transport components
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) ::   pt              ! tracers and RHS of tracer equation
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trabbl.F90	(revision 14200)
@@ -141,5 +141,4 @@
          IF( ntile == 0 .OR. ntile == nijtile ) THEN                       ! Do only on the last tile
             ! lateral boundary conditions ; just need for outputs
-            ! NOTE: [tiling-comms-merge] The diagnostic results change along the north fold if this is removed
             CALL lbc_lnk_multi( 'trabbl', utr_bbl, 'U', 1.0_wp , vtr_bbl, 'V', 1.0_wp )
             CALL iom_put( "uoce_bbl", utr_bbl )  ! bbl i-transport
@@ -249,5 +248,4 @@
       DO jn = 1, kjpt                                            ! tracer loop
          !                                                       ! ===========
-         ! NOTE: [tiling-comms-merge] Bug fix- correct order of indices
          DO_2D( isj, 0, isi, 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
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf.F90	(revision 14200)
@@ -92,5 +92,4 @@
             CALL tra_ldf_triad( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs), jpts,  1 )
          CASE ( np_blp , np_blp_i , np_blp_it )             ! bilaplacian: iso-level & iso-neutral operators
-            ! NOTE: [tiling-comms-merge] This lbc_lnk is still needed in the zco case, because zps_hde is not called in step
             IF(nn_hls.EQ.2) CALL lbc_lnk( 'tra_ldf', pts(:,:,:,:,Kbb), 'T',1.)
             CALL tra_ldf_blp  ( kt, Kmm, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, pts(:,:,:,:,Kbb), pts(:,:,:,:,Krhs),             jpts, nldf_tra )
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traldf_lap_blp.F90	(revision 14200)
@@ -158,5 +158,4 @@
          ENDIF
          !
-         ! NOTE: [tiling-comms-merge] Bounds changed to avoid repeating this calculation for overlapping rows when using tiling
          DO_3D( isj, iej, isi, iei, 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)     &
@@ -236,5 +235,4 @@
       END SELECT
       !
-      ! NOTE: [tiling-comms-merge] Needed for both nn_hls as tra_ldf_iso and tra_ldf_triad have not yet been adjusted to work with nn_hls = 2. In the zps case the lbc_lnk in zps_hde handles this, but in the zco case zlap always needs this lbc_lnk. I did try adjusting the bounds in tra_ldf_iso and tra_ldf_triad so this lbc_lnk was only needed for nn_hls = 1, but this was not correct and I did not have time to figure out why
       CALL lbc_lnk( 'traldf_lap_blp', zlap(:,:,:,:) , 'T', 1.0_wp )     ! Lateral boundary conditions (unchanged sign)
       !                                               ! Partial top/bottom cell: GRADh( zlap )
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/tranpc.F90	(revision 14200)
@@ -112,5 +112,4 @@
          IF( ntej == Nje0 ) THEN ; iej = nn_hls ; ELSE ; iej = 0 ; ENDIF
          !
-         ! NOTE: [tiling-comms-merge] Bounds changed to avoid repeating this calculation for overlapping rows when using tiling
          DO_2D( isj, iej, isi, iei )                        ! interior column only
             !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/traqsr.F90	(revision 14200)
@@ -137,5 +137,4 @@
       !                         !  before qsr induced heat content  !
       !                         !-----------------------------------!
-      ! NOTE: [tiling-comms-merge] Many DO loop bounds changed (probably more than necessary) to avoid changing results when using tiling. Some bounds were also adjusted to account for those changed in tra_atf
       IF( ntsi == Nis0 ) THEN ; isi = nn_hls ; ELSE ; isi = 0 ; ENDIF    ! Avoid double-counting when using tiling
       IF( ntsj == Njs0 ) THEN ; isj = nn_hls ; ELSE ; isj = 0 ; ENDIF
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trasbc.F90	(revision 14200)
@@ -98,5 +98,4 @@
       ENDIF
       !
-      ! NOTE: [tiling-comms-merge] Many DO loop bounds changed to avoid changing results when using tiling. Some bounds were also adjusted to account for those changed in tra_atf
       IF( ntsi == Nis0 ) THEN ; isi = nn_hls ; ELSE ; isi = 0 ; ENDIF    ! Avoid double-counting when using tiling
       IF( ntsj == Njs0 ) THEN ; isj = nn_hls ; ELSE ; isj = 0 ; ENDIF
@@ -155,5 +154,4 @@
       !
       DO jn = 1, jpts               !==  update tracer trend  ==!
-         ! NOTE: [tiling-comms-merge] This looped over nn_hls, which changes the results when using tiling
          DO_2D( 0, 0, 0, 0 )
             pts(ji,jj,1,jn,Krhs) = pts(ji,jj,1,jn,Krhs) + zfact * ( sbc_tsc_b(ji,jj,jn) + sbc_tsc(ji,jj,jn) )    &
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/trazdf.F90	(revision 14200)
@@ -23,4 +23,5 @@
    USE trd_oce        ! trends: ocean variables
    USE trdtra         ! trends: tracer trend manager
+   USE eosbn2, ONLY: ln_SEOS, rn_b0
    !
    USE in_out_manager ! I/O manager
@@ -83,5 +84,8 @@
       ! JMM avoid negative salinities near river outlet ! Ugly fix
       ! JMM : restore negative salinities to small salinities:
-      WHERE( pts(A2D(0),:,jp_sal,Kaa) < 0._wp )   pts(A2D(0),:,jp_sal,Kaa) = 0.1_wp
+!!jc: discard this correction in case salinity is not used in eos
+      IF ( .NOT.(ln_SEOS.AND.(rn_b0==0._wp)) ) THEN
+         WHERE( pts(A2D(0),:,jp_sal,Kaa) < 0._wp )   pts(A2D(0),:,jp_sal,Kaa) = 0.1_wp
+      ENDIF
 !!gm
 
@@ -97,5 +101,4 @@
                &          - ztrds(:,:,jk)
          END DO
-         ! NOTE: [tiling-comms-merge] The diagnostic results change along the north fold if this is removed
 !!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 )
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRA/zpshde.F90	(revision 14200)
@@ -124,5 +124,4 @@
       !
       IF( ln_timing )   CALL timing_start( 'zps_hde')
-      ! NOTE: [tiling-comms-merge] Some lbc_lnks in tra_adv and tra_ldf can be taken out in the zps case, because this lbc_lnk is called when zps_hde is called in the stp routine. In the zco case they are still needed.
       IF (nn_hls.EQ.2) THEN
          CALL lbc_lnk( 'zpshde', pta, 'T', 1.0_wp)
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdtra.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdtra.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/TRD/trdtra.F90	(revision 14200)
@@ -91,4 +91,5 @@
       IF( .NOT. ALLOCATED( trdtx ) ) THEN      ! allocate trdtra arrays
          IF( trd_tra_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'trd_tra : unable to allocate arrays' )
+         avt_evd(:,:,:) = 0._wp
       ENDIF
       !
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfgls.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfgls.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/ZDF/zdfgls.F90	(revision 14200)
@@ -187,6 +187,6 @@
       IF( .NOT.ln_drg_OFF ) THEN     !== top/bottom friction   (explicit before friction)
          DO_2D( 0, 0, 0, 0 )         ! bottom friction (explicit before friction)
-            zmsku = ( 2._wp - umask(ji-1,jj,mbkt(ji,jj)) * umask(ji,jj,mbkt(ji,jj)) )
-            zmskv = ( 2._wp - vmask(ji,jj-1,mbkt(ji,jj)) * vmask(ji,jj,mbkt(ji,jj)) )     ! (CAUTION: CdU<0)
+            zmsku = 0.5_wp * ( 2._wp - umask(ji-1,jj,mbkt(ji,jj)) * umask(ji,jj,mbkt(ji,jj)) )
+            zmskv = 0.5_wp * ( 2._wp - vmask(ji,jj-1,mbkt(ji,jj)) * vmask(ji,jj,mbkt(ji,jj)) )     ! (CAUTION: CdU<0)
             ustar2_bot(ji,jj) = - rCdU_bot(ji,jj) * SQRT(  ( zmsku*( uu(ji,jj,mbkt(ji,jj),Kbb)+uu(ji-1,jj,mbkt(ji,jj),Kbb) ) )**2  &
                &                                         + ( zmskv*( vv(ji,jj,mbkt(ji,jj),Kbb)+vv(ji,jj-1,mbkt(ji,jj),Kbb) ) )**2  )
@@ -194,6 +194,6 @@
          IF( ln_isfcav ) THEN
             DO_2D( 0, 0, 0, 0 )      ! top friction
-               zmsku = ( 2. - umask(ji-1,jj,mikt(ji,jj)) * umask(ji,jj,mikt(ji,jj)) )
-               zmskv = ( 2. - vmask(ji,jj-1,mikt(ji,jj)) * vmask(ji,jj,mikt(ji,jj)) )     ! (CAUTION: CdU<0)
+               zmsku = 0.5_wp * ( 2. - umask(ji-1,jj,mikt(ji,jj)) * umask(ji,jj,mikt(ji,jj)) )
+               zmskv = 0.5_wp * ( 2. - vmask(ji,jj-1,mikt(ji,jj)) * vmask(ji,jj,mikt(ji,jj)) )     ! (CAUTION: CdU<0)
                ustar2_top(ji,jj) = - rCdU_top(ji,jj) * SQRT(  ( zmsku*( uu(ji,jj,mikt(ji,jj),Kbb)+uu(ji-1,jj,mikt(ji,jj),Kbb) ) )**2  &
                   &                                         + ( zmskv*( vv(ji,jj,mikt(ji,jj),Kbb)+vv(ji,jj-1,mikt(ji,jj),Kbb) ) )**2  )
@@ -396,4 +396,5 @@
             zdiag(ji,jj,ibot) = 1._wp   ;   zdiag(ji,jj,ibotm1) = zdiag(ji,jj,ibotm1) + zd_up(ji,jj,ibotm1)
             zd_up(ji,jj,ibot) = 0._wp   ;   zd_up(ji,jj,ibotm1) = 0._wp
+            en   (ji,jj,ibot) = z_en
          END_2D
          IF( ln_isfcav) THEN     ! top boundary   (ocean cavity)
@@ -410,4 +411,5 @@
                zdiag(ji,jj,itop) = 1._wp   ;   zdiag(ji,jj,itopp1) = zdiag(ji,jj,itopp1) + zd_up(ji,jj,itopp1)
                zd_up(ji,jj,itop) = 0._wp   ;   zd_up(ji,jj,itopp1) = 0._wp
+               en   (ji,jj,itop) = z_en
             END_2D
          ENDIF
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/nemogcm.F90	(revision 14200)
@@ -51,16 +51,4 @@
    USE istate         ! initial state setting          (istate_init routine)
    USE trdini         ! dyn/tra trends initialization     (trd_init routine)
-   USE asminc         ! assimilation increments     
-   USE asmbkg         ! writing out state trajectory
-   USE diadct         ! sections transports           (dia_dct_init routine)
-   USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
-   USE diacfl         ! CFL diagnostics               (dia_cfl_init routine)
-   USE diamlr         ! IOM context management for multiple-linear-regression analysis
-#if defined key_qco
-   USE stepMLF        ! NEMO time-stepping               (stp_MLF   routine)
-#else
-   USE step           ! NEMO time-stepping                 (stp     routine)
-#endif
-   USE isfstp         ! ice shelf                     (isf_stp_init routine)
    USE icbini         ! handle bergs, initialisation
    USE icbstp  , ONLY : icb_end     ! handle bergs, close iceberg files
@@ -78,5 +66,5 @@
    USE ice_domain_size, only: nx_global, ny_global
 #endif
-#if defined key_qco
+#if defined key_qco   ||   defined key_linssh
    USE stpmlf         ! NEMO time-stepping               (stp_MLF   routine)
 #else
@@ -88,12 +76,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
-   USE xios           ! xIOserver
-#endif
-#if defined key_agrif
-   USE agrif_all_update   ! Master Agrif update
-   USE agrif_oce_update
-#endif
-   USE halo_mng
+   USE halo_mng       ! halo manager
 
    IMPLICIT NONE
@@ -180,5 +161,6 @@
       !
       DO WHILE( istp <= nitend .AND. nstop == 0 )
-#  if defined key_qco
+         !
+#  if defined key_qco   ||   defined key_linssh
          CALL stp_MLF
 #  else
@@ -201,8 +183,8 @@
             ENDIF
             !
-#  if defined key_qco
-            CALL stp_MLF      ( istp )
+#  if defined key_qco   ||   defined key_linssh
+            CALL stp_MLF( istp )
 #  else
-            CALL stp        ( istp )
+            CALL stp    ( istp )
 #  endif
             istp = istp + 1
@@ -348,5 +330,5 @@
       IF(lwp) THEN                      ! open listing units
          !
-         IF( .NOT.lwm )   &            ! alreay opened for narea == 1
+         IF( .NOT. lwm )   &            ! alreay opened for narea == 1
             &            CALL ctl_opn( numout, 'ocean.output', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, -1, .FALSE., narea )
          !
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step.F90	(revision 14200)
@@ -33,7 +33,9 @@
    !!            4.1  !  2019-08  (A. Coward, D. Storkey) rewrite in preparation for new timestepping scheme
    !!----------------------------------------------------------------------
-#if defined key_qco
-   !!----------------------------------------------------------------------
-   !!   'key_qco'      EMPTY MODULE      Quasi-Eulerian vertical coordonate
+#if defined key_qco   ||   defined key_linssh
+   !!----------------------------------------------------------------------
+   !!   'key_qco'      EMPTY MODULE      Quasi-Eulerian vertical coordinate
+   !!                                OR
+   !!   'key_linssh    EMPTY MODULE       Fixed in time vertical coordinate
    !!----------------------------------------------------------------------
 #else
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/step_oce.F90	(revision 14200)
@@ -110,4 +110,5 @@
    USE agrif_oce_sponge ! Momemtum and tracers sponges
    USE agrif_all_update ! Main update driver
+   USE agrif_oce_update
 #endif
 #if defined key_top
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpctl.F90	(revision 14200)
@@ -15,4 +15,5 @@
    !!----------------------------------------------------------------------
    !!   stp_ctl      : Control the run
+   !!   stp_ctl_SWE  : Control the run (SWE only)
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers variables
@@ -26,13 +27,16 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp         ! distributed memory computing
+   USE eosbn2, ONLY: ln_SEOS, rn_b0
+   !
    USE netcdf          ! NetCDF library
-
    IMPLICIT NONE
    PRIVATE
 
    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)
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -65,5 +69,5 @@
       INTEGER , DIMENSION(9)          ::   iareasum, iareamin, iareamax
       INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
-      REAL(wp)                        ::   zzz                                   ! local real 
+      REAL(wp)                        ::   zzz, zminsal, zmaxsal                 ! local real 
       REAL(wp), DIMENSION(9)          ::   zmax, zmaxlocal
       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
@@ -71,5 +75,4 @@
       CHARACTER(len=20)               ::   clname
       !!----------------------------------------------------------------------
-      !
       IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid
       !
@@ -180,13 +183,21 @@
          END DO
          IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
-      ENDIF
+      END IF
       !                                   !==               error handling               ==!
       !                                   !==  done by all processes at every time step  ==!
       !
+      IF ( ln_SEOS.AND.(rn_b0==0._wp) ) THEN             ! Discard checks on salinity
+         zmaxsal = +1.e38                                ! if not used in eos
+         zminsal = -1.e38 
+      ELSE
+         zmaxsal = 100._wp
+         zminsal =   0._wp
+      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) <=   0._wp .OR.   &                   ! negative or zero sea surface salinity
-         & zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 )
-         & zmax(4) <    0._wp .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice)
+         & 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
@@ -262,4 +273,181 @@
 
 
+   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(wp)                        ::   zzz                                   ! local real 
+      REAL(wp), 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
+
+
    SUBROUTINE wrt_line( cdline, kt, cdprefix, pval, kloc, ksum, kmin, kmax )
       !!----------------------------------------------------------------------
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/OCE/stpmlf.F90	(revision 14200)
@@ -36,11 +36,13 @@
    !!----------------------------------------------------------------------
 
-#if defined key_qco
-   !!----------------------------------------------------------------------
-   !!   'key_qco'       Quasi-Eulerian vertical coordonate
-   !!----------------------------------------------------------------------
-   
-   !!----------------------------------------------------------------------
-   !!   stp_MLF       : NEMO modified Leap Frog time-stepping with qco
+#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
@@ -196,5 +198,5 @@
       END DO
                             CALL ssh_nxt    ( kstp, Nbb, Nnn, ssh,  Naa )   ! after ssh (includes call to div_hor)
-      IF( .NOT.ln_linssh )  THEN
+      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
@@ -225,5 +227,5 @@
       IF( ln_dynspg_ts ) THEN                         ! 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.ln_linssh) CALL dom_qco_r3c ( 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 ( 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
@@ -257,5 +259,5 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                          CALL ssh_atf    ( kstp, Nbb, Nnn, Naa, ssh )            ! time filtering of "now" sea surface height
-                         CALL dom_qco_r3c( ssh(:,:,Nnn), r3t_f, r3u_f, r3v_f )   ! "now" ssh/h_0 ratio from filtrered ssh
+      IF(.NOT.lk_linssh) CALL dom_qco_r3c( ssh(:,:,Nnn), r3t_f, r3u_f, r3v_f )   ! "now" ssh/h_0 ratio from filtrered ssh
 #if defined key_top
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -311,8 +313,10 @@
                          CALL finalize_lbc  ( kstp, Nbb     , Naa, uu, vv, ts )   ! boundary conditions
                          CALL tra_atf_qco   ( kstp, Nbb, Nnn, Naa        , ts )   ! time filtering of "now" tracer arrays
-                         CALL dyn_atf_qco   ( kstp, Nbb, Nnn, Naa, uu, vv     )   ! time filtering of "now" velocities 
+                         CALL dyn_atf_qco   ( kstp, Nbb, Nnn, Naa, uu, vv     )   ! time filtering of "now" velocities
+      IF(.NOT.lk_linssh) THEN
                          r3t(:,:,Nnn) = r3t_f(:,:)                                ! update now ssh/h_0 with time filtered values
                          r3u(:,:,Nnn) = r3u_f(:,:)
                          r3v(:,:,Nnn) = r3v_f(:,:)
+      ENDIF
 
       !
@@ -367,5 +371,4 @@
       IF( kstp == nitend .OR. indic < 0 ) THEN
                       CALL iom_context_finalize(      cxios_context          ) ! needed for XIOS+AGRIF
-         IF( lrxios ) CALL iom_context_finalize(      crxios_context          )
          IF( ln_crs ) CALL iom_context_finalize( trim(cxios_context)//"_crs" ) !
       ENDIF
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/nemogcm.F90	(revision 14200)
@@ -33,5 +33,5 @@
    USE lbcnfd  , ONLY : isendto, nsndto  ! Setup of north fold exchanges 
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-   USE halo_mng       ! Halo manager
+   USE halo_mng       ! halo manager
 
    IMPLICIT NONE
@@ -127,5 +127,6 @@
       IF( nstop /= 0 .AND. lwp ) THEN        ! error print
          WRITE(ctmp1,*) '   ==>>>   nemo_gcm: a total of ', nstop, ' errors have been found'
-         CALL ctl_stop( ctmp1 )
+         WRITE(ctmp2,*) '           Look for "E R R O R" messages in all existing ocean_output* files'
+         CALL ctl_stop( ' ', ctmp1, ' ', ctmp2 )
       ENDIF
       !
@@ -216,5 +217,8 @@
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                NEMO version 4.0  (2019) '
+         WRITE(numout,*) '                NEMO version 4.0  (2020) '
+         WRITE(numout,*)
+         WRITE(numout,*) '                 Shallow Water Equation'
+         WRITE(numout,*) '                 ======================'
          WRITE(numout,*)
          WRITE(numout,*) "           ._      ._      ._      ._      ._    "
@@ -232,14 +236,14 @@
          WRITE(numout,*) "     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "
          WRITE(numout,*)
-         
-         ! Print the working precision to ocean.output
-         IF (wp == dp) THEN
-            WRITE(numout,*) "Working precision = double-precision"
-         ELSE
-            WRITE(numout,*) "Working precision = single-precision"
+         !
+         WRITE(numout,cform_aaa)    ! Flag AAAAAAA
+         !
+         !                          ! Control print of the working precision
+         WRITE(numout,*)
+         IF( wp == dp ) THEN   ;   WRITE(numout,*) "par_kind : wp = Working precision = dp = double-precision"
+         ELSE                  ;   WRITE(numout,*) "par_kind : wp = Working precision = sp = single-precision"
          ENDIF
-         WRITE(numout,*)
-         !
-         WRITE(numout,cform_aaa)                                        ! Flag AAAAAAA
+                                   WRITE(numout,*) "~~~~~~~~                                 ****************"
+                                   WRITE(numout,*)
          !
       ENDIF
@@ -280,5 +284,5 @@
       !                             !-------------------------------!
 
-      CALL nemo_ctl                          ! Control prints
+      CALL nemo_ctl                          ! Control prints of namctl and namcfg
       !
       !                                      ! General initialization
@@ -429,5 +433,5 @@
    END SUBROUTINE nemo_alloc
 
-   
+
    SUBROUTINE nemo_set_cfctl(sn_cfctl, setto )
       !!----------------------------------------------------------------------
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/restart.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/restart.F90	(revision 14199)
+++ 	(revision )
@@ -1,279 +1,0 @@
-MODULE restart
-   !!======================================================================
-   !!                     ***  MODULE  restart  ***
-   !! Ocean restart :  write the ocean restart file
-   !!======================================================================
-   !! History :  OPA  !  1999-11  (M. Imbard)  Original code
-   !!   NEMO     1.0  !  2002-08  (G. Madec)  F90: Free form
-   !!            2.0  !  2006-07  (S. Masson)  use IOM for restart
-   !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
-   !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D)
-   !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
-   !!             -   !  2014-12  (G. Madec) remove KPP scheme
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   rst_opn    : open the ocean restart file
-   !!   rst_write  : write the ocean restart file
-   !!   rst_read   : read the ocean restart file
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers 
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_ice         ! only lk_si3 
-   USE phycst          ! physical constants
-!!st   USE eosbn2          ! equation of state            (eos bn2 routine)
-!!st   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
-   !
-   USE in_out_manager  ! I/O manager
-   USE iom             ! I/O module
-   USE diu_bulk
-   USE lib_mpp         ! distribued memory computing library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   rst_opn         ! routine called by step module
-   PUBLIC   rst_write       ! routine called by step module
-   PUBLIC   rst_read        ! routine called by istate module
-   PUBLIC   rst_read_open   ! routine called in rst_read and (possibly) in dom_vvl_init
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: restart.F90 13427 2020-08-21 16:26:57Z techene $
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE rst_opn( kt )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE rst_opn  ***
-      !!                     
-      !! ** Purpose : + initialization (should be read in the namelist) of nitrst 
-      !!              + open the restart when we are one time step before nitrst
-      !!                   - restart header is defined when kt = nitrst-1
-      !!                   - restart data  are written when kt = nitrst
-      !!              + define lrst_oce to .TRUE. when we need to define or write the restart
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt     ! ocean time-step
-      !!
-      CHARACTER(LEN=20)   ::   clkt      ! ocean time-step deine as a character
-      CHARACTER(LEN=50)   ::   clname    ! ocean output restart file name
-      CHARACTER(lc)       ::   clpath    ! full path to ocean output restart file
-      CHARACTER(LEN=52)   ::   clpname   ! ocean output restart file name including prefix for AGRIF
-      CHARACTER(LEN=256)  ::   clinfo    ! info character
-      !!----------------------------------------------------------------------
-      !
-      IF( kt == nit000 ) THEN   ! default definitions
-         lrst_oce = .FALSE.   
-         IF( ln_rst_list ) THEN
-            nrst_lst = 1
-            nitrst = nn_stocklist( nrst_lst )
-         ELSE
-            nitrst = nitend
-         ENDIF
-      ENDIF
-      
-      IF( .NOT. ln_rst_list .AND. nn_stock == -1 )   RETURN   ! we will never do any restart
-
-      ! frequency-based restart dumping (nn_stock)
-      IF( .NOT. ln_rst_list .AND. MOD( kt - 1, nn_stock ) == 0 ) THEN   
-         ! we use kt - 1 and not kt - nit000 to keep the same periodicity from the beginning of the experiment
-         nitrst = kt + nn_stock - 1                  ! define the next value of nitrst for restart writing
-         IF( nitrst > nitend )   nitrst = nitend   ! make sure we write a restart at the end of the run
-      ENDIF
-      ! to get better performances with NetCDF format:
-      ! we open and define the ocean restart file one time step before writing the data (-> at nitrst - 1)
-      ! except if we write ocean restart files every time step or if an ocean restart file was writen at nitend - 1
-      IF( kt == nitrst - 1 .OR. nn_stock == 1 .OR. ( kt == nitend .AND. .NOT. lrst_oce ) ) THEN
-         IF( nitrst <= nitend .AND. nitrst > 0 ) THEN 
-            ! beware of the format used to write kt (default is i8.8, that should be large enough...)
-            IF( nitrst > 999999999 ) THEN   ;   WRITE(clkt, *       ) nitrst
-            ELSE                            ;   WRITE(clkt, '(i8.8)') nitrst
-            ENDIF
-            ! create the file
-            clname = TRIM(cexper)//"_"//TRIM(ADJUSTL(clkt))//"_"//TRIM(cn_ocerst_out)
-            clpath = TRIM(cn_ocerst_outdir)
-            IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-            IF(lwp) THEN
-               WRITE(numout,*)
-               IF(.NOT.lwxios) THEN
-                  WRITE(numout,*) '             open ocean restart NetCDF file: ',TRIM(clpath)//TRIM(clname)
-                  IF ( snc4set%luse )      WRITE(numout,*) '             opened for NetCDF4 chunking and compression'
-                  IF( kt == nitrst - 1 ) THEN   ;   WRITE(numout,*) '             kt = nitrst - 1 = ', kt
-                  ELSE                          ;   WRITE(numout,*) '             kt = '             , kt
-                  ENDIF
-               ENDIF
-            ENDIF
-            !
-            IF(.NOT.lwxios) THEN
-               CALL iom_open( TRIM(clpath)//TRIM(clname), numrow, ldwrt = .TRUE. )
-            ELSE
-#if defined key_iomput
-               cwxios_context = "rstw_"//TRIM(ADJUSTL(clkt))
-               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-                  clpname = clname
-               ELSE
-                  clpname = TRIM(Agrif_CFixed())//"_"//clname   
-               ENDIF
-               CALL iom_init( cwxios_context, TRIM(clpath)//TRIM(clpname), .false. )
-               CALL xios_update_calendar(nitrst)
-               CALL iom_swap(      cxios_context          )
-#else
-               clinfo = 'Can not use XIOS in rst_opn'
-               CALL ctl_stop(TRIM(clinfo))
-#endif
-            ENDIF
-            lrst_oce = .TRUE.
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE rst_opn
-
-
-   SUBROUTINE rst_write( kt, Kbb, Kmm )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE rstwrite  ***
-      !!                     
-      !! ** Purpose :   Write restart fields in NetCDF format
-      !!
-      !! ** Method  :   Write in numrow when kt == nitrst in NetCDF
-      !!              file, save fields which are necessary for restart
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt         ! ocean time-step
-      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
-      !!----------------------------------------------------------------------
-      IF(lwxios) CALL iom_swap(      cwxios_context          )
-      CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_Dt       , ldxios = lwxios)   ! dynamics time step
-      CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
-      
-      CALL iom_rstput( kt, nitrst, numrow, 'ub'  , uu(:,:,:,Kbb), ldxios = lwxios )     ! before fields
-      CALL iom_rstput( kt, nitrst, numrow, 'vb'  , vv(:,:,:,Kbb), ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'sshb',ssh(:,:  ,Kbb), ldxios = lwxios )
-      !
-      CALL iom_rstput( kt, nitrst, numrow, 'un'  , uu(:,:,:,Kmm), ldxios = lwxios )     ! now fields
-      CALL iom_rstput( kt, nitrst, numrow, 'vn'  , vv(:,:,:,Kmm), ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'sshn',ssh(:,:  ,Kmm), ldxios = lwxios )
-      
-      IF(lwxios) CALL iom_swap(      cxios_context          )
-      IF( kt == nitrst ) THEN
-         IF(.NOT.lwxios) THEN
-            CALL iom_close( numrow )     ! close the restart file (only at last time step)
-         ELSE
-            CALL iom_context_finalize(      cwxios_context          )
-         ENDIF
-         lrst_oce = .FALSE.
-         IF( ln_rst_list ) THEN
-            nrst_lst = MIN(nrst_lst + 1, SIZE(nn_stocklist,1))
-            nitrst = nn_stocklist( nrst_lst )
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE rst_write
-
-
-   SUBROUTINE rst_read_open
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE rst_read_open  ***
-      !! 
-      !! ** Purpose :   Open read files for NetCDF restart
-      !! 
-      !! ** Method  :   Use a non-zero, positive value of numror to assess whether or not
-      !!                the file has already been opened
-      !!----------------------------------------------------------------------
-      LOGICAL        ::   llok
-      CHARACTER(lc)  ::   clpath   ! full path to ocean output restart file
-      !!----------------------------------------------------------------------
-      !
-      IF( numror <= 0 ) THEN
-         IF(lwp) THEN                                             ! Contol prints
-            WRITE(numout,*)
-            WRITE(numout,*) 'rst_read : read oce NetCDF restart file'
-            IF ( snc4set%luse )      WRITE(numout,*) 'rst_read : configured with NetCDF4 support'
-            WRITE(numout,*) '~~~~~~~~'
-         ENDIF
-         lxios_sini = .FALSE.
-         clpath = TRIM(cn_ocerst_indir)
-         IF( clpath(LEN_TRIM(clpath):) /= '/' ) clpath = TRIM(clpath) // '/'
-         CALL iom_open( TRIM(clpath)//cn_ocerst_in, numror )
-! are we using XIOS to read the data? Part above will have to modified once XIOS
-! can handle checking if variable is in the restart file (there will be no need to open
-! restart)
-         IF(.NOT.lxios_set) lrxios = lrxios.AND.lxios_sini
-         IF( lrxios) THEN
-             crxios_context = 'nemo_rst'
-             IF( .NOT.lxios_set ) THEN
-                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
-                 CALL iom_init( crxios_context )
-                 lxios_set = .TRUE.
-             ENDIF
-         ENDIF
-         IF( TRIM(Agrif_CFixed()) /= '0' .AND. lrxios) THEN
-             CALL iom_init( crxios_context )
-             IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for AGRIF'
-             lxios_set = .TRUE.
-         ENDIF 
-      ENDIF
-
-   END SUBROUTINE rst_read_open
-
-
-   SUBROUTINE rst_read( Kbb, Kmm )
-      !!---------------------------------------------------------------------- 
-      !!                   ***  ROUTINE rst_read  ***
-      !! 
-      !! ** Purpose :   Read files for NetCDF restart
-      !! 
-      !! ** Method  :   Read in restart.nc file fields which are necessary for restart
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
-      REAL(wp) ::   zrdt
-      INTEGER  ::   jk
-      REAL(wp), DIMENSION(jpi, jpj, jpk) :: w3d
-      !!----------------------------------------------------------------------
-
-      CALL rst_read_open           ! open restart for reading (if not already opened)
-
-      ! Check dynamics and tracer time-step consistency and force Euler restart if changed
-      IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
-         IF( zrdt /= rn_Dt ) THEN
-            IF(lwp) WRITE( numout,*)
-            IF(lwp) WRITE( numout,*) 'rst_read:  rdt not equal to the read one'
-            IF(lwp) WRITE( numout,*)
-            IF(lwp) WRITE( numout,*) '      ==>>>   forced euler first time-step'
-            l_1st_euler =  .TRUE.
-         ENDIF
-      ENDIF
-
-      CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
-      
-      IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
-         ! before fields
-         CALL iom_get( numror, jpdom_auto, 'ub'     , uu(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
-         CALL iom_get( numror, jpdom_auto, 'vb'     , vv(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
-#if ! defined key_qco
-         CALL iom_get( numror, jpdom_auto, 'sshb'   ,ssh(:,:         ,Kbb), ldxios = lrxios )
-#endif
-      ELSE
-         l_1st_euler =  .TRUE.      ! before field not found, forced euler 1st time-step
-      ENDIF
-      !
-      ! now fields
-      CALL iom_get( numror, jpdom_auto, 'un'     , uu(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
-      CALL iom_get( numror, jpdom_auto, 'vn'     , vv(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
-#if ! defined key_qco
-      CALL iom_get( numror, jpdom_auto, 'sshn'   ,ssh(:,:         ,Kmm), ldxios = lrxios )
-#endif
-      !
-      IF( l_1st_euler ) THEN                                  ! Euler restart 
-         uu   (:,:,:  ,Kbb) = uu   (:,:,:  ,Kmm)              ! all before fields set to now values
-         vv   (:,:,:  ,Kbb) = vv   (:,:,:  ,Kmm)
-         ssh  (:,:    ,Kbb) = ssh  (:,:    ,Kmm)
-      ENDIF
-      !
-      ww (:,:,:) = 0._wp !!st  gm is right 3D only !! 
-      !
-   END SUBROUTINE rst_read
-
-   !!=====================================================================
-END MODULE restart
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stp_oce.F90	(revision 14200)
@@ -93,5 +93,5 @@
    !                                                   (dyn_asm_inc routine)
    USE asmbkg          ! writing out state trajectory
-   USE stpctl          ! time stepping control            (stp_ctl routine)
+   USE stpctl          ! time stepping control            (stp_ctl_SWE routine)
    USE restart         ! ocean restart                    (rst_wri routine)
    USE prtctl          ! Print control                    (prt_ctl routine)
Index: MO/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 14199)
+++ 	(revision )
@@ -1,261 +1,0 @@
-MODULE stpctl
-   !!======================================================================
-   !!                       ***  MODULE  stpctl  ***
-   !! Ocean run control :  gross check of the ocean time stepping
-   !!              *** Shallow Water Equation (SWE) case ***
-   !!               ( No test on temperature and salinity )
-   !!======================================================================
-   !! History :  SWE  ! 2020-09  (A. Nasser, S. Techene ) OCE/stpctl adaptated to SWE
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   stp_ctl      : Control the run
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables 
-   USE c1d             ! 1D vertical configuration
-   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables
-   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy
-   !
-   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                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(2)  ::   nvarid   ! netcdf variable id
-
-#  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: stpctl.F90 13216 2020-07-02 09:25:49Z rblod $
-   !! 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                         ::   ji                                    ! dummy loop indices
-      INTEGER                         ::   idtime, istatus
-      INTEGER , DIMENSION(3)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
-      REAL(wp)                        ::   zzz                                   ! local real 
-      REAL(wp), DIMENSION(3)          ::   zmax, zmaxlocal
-      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns
-      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
-      !
-      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, 'abs_ssh_max', 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  ==!
-      zmax(1) = MINVAL( e3t_0(:,:,1)+ssh(:,:,Kmm)  )                              ! e3t_Kmm min
-      llmsk(:,:,:) = umask(:,:,:) == 1._wp
-      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  ==!
-      llmsk(Nis0:Nie0,Njs0:Nje0,1) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp         ! define only the inner domain
-      zmax(1) = MAXVAL(     -e3t(:,:,1,Kmm) ), mask = llmsk(:,:,1) )      ! ssh max
-      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)
-      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)
-         istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(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
-            CALL mpp_minloc( 'stpctl', e3t_0(:,:,1) + ssh(:,:,Kmm), ssmask(:,:  ), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F 
-            CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,Kmm))        ,  umask(:,:,:), 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
-            iloc(1:2,1) = MINLOC( e3t_0(:,:,1) + ssh(:,:,Kmm), mask = ssmask(:,:  ) == 1._wp ) + (/ nimpp - 1, njmpp - 1    /)
-            iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask =  umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /)
-            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
-!!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
-
-
-   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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stpmlf.F90	(revision 14200)
@@ -70,5 +70,5 @@
       ENDIF
 
-      IF( kstp == nit000 )   ww(:,:,:) = 0._wp   ! initialize vertical velocity one for all to zero
+      IF( kstp == nit000 )   ww(:,:,:) = 0._wp   ! initialize vertical velocity once for all to zero
 
       !
@@ -222,5 +222,5 @@
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL stp_ctl      ( kstp, Nnn )
+                         CALL stp_ctl_SWE   ( kstp, Nnn )
 
       IF( kstp == nit000 ) THEN                          ! 1st time step only
@@ -235,6 +235,4 @@
 !!st : cxios_context needed ? because opened earlier ???         
          CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF
-!!st : crxios_context not needed associated with coarsening ! 
-         IF(lrxios) CALL iom_context_finalize( crxios_context )
       ENDIF
 #endif
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/SWE/stprk3.F90	(revision 14200)
@@ -129,22 +129,4 @@
       CALL dyn_ldf( kstp, Nbb, Nbb, uu, vv, Nrhs )  ! lateral mixing
 #endif
-!!st       !
-!!st       DO_3D( 0,0, 0,0, 1,jpkm1 )
-!!st          !                                          ! horizontal pressure gradient
-!!st          uu(ji,jj,jk,Nrhs) = uu(ji,jj,jk,Nrhs) - grav * ( ssh(ji+1,jj,Nbb) - ssh(ji,jj,Nbb) ) * r1_e1u(ji,jj)
-!!st          vv(ji,jj,jk,Nrhs) = vv(ji,jj,jk,Nrhs) - grav * ( ssh(ji,jj+1,Nbb) - ssh(ji,jj,Nbb) ) * r1_e2v(ji,jj)
-!!st       END_3D
-!!st       !
-!!st #if defined key_RK3all 
-!!st       !                                             ! wind stress and layer friction
-!!st       z5_6 = 5._wp/6._wp
-!!st       DO_3D( 0, 0, 0, 0,1,jpkm1)
-!!st          uu(ji,jj,jk,Nrhs) = uu(ji,jj,jk,Nrhs) + r1_rho0 * ( z5_6*utau_b(ji,jj) + (1._wp - z5_6)*utau(ji,jj) ) / e3u(ji,jj,jk,Nbb)   &
-!!st             &                                  - rn_rfr * uu(ji,jj,jk,Nbb)
-!!st          vv(ji,jj,jk,Nrhs) = vv(ji,jj,jk,Nrhs) + r1_rho0 * ( z5_6*vtau_b(ji,jj) + (1._wp - z5_6)*vtau(ji,jj) ) / e3v(ji,jj,jk,Nbb)   &
-!!st             &                                  - rn_rfr * vv(ji,jj,jk,Nbb)
-!!st       END_3D
-!!st #endif
-!!st why not ?
       z5_6 = 5._wp/6._wp
       DO_3D( 0, 0, 0, 0, 1, jpkm1 )
@@ -163,5 +145,4 @@
          vv(ji,jj,jk,Nrhs) = vv(ji,jj,jk,Nrhs) + zrhs_v
       END_3D
-!!st end
       !
       !                                 !==  Time stepping of ssh Eq.  ==!   (and update r3_Naa)
@@ -229,21 +210,4 @@
          vv(ji,jj,jk,Nrhs) = vv(ji,jj,jk,Nrhs) + zrhs_v
       END_3D
-!!st       !
-!!st       DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-!!st          !                                          ! horizontal pressure gradient
-!!st          uu(ji,jj,jk,Nrhs) = uu(ji,jj,jk,Nrhs) - grav * ( ssh(ji+1,jj,Nnn) - ssh(ji,jj,Nnn) ) * r1_e1u(ji,jj)
-!!st          vv(ji,jj,jk,Nrhs) = vv(ji,jj,jk,Nrhs) - grav * ( ssh(ji,jj+1,Nnn) - ssh(ji,jj,Nnn) ) * r1_e2v(ji,jj)
-!!st       END_3D
-!!st       !
-!!st #if defined key_RK3all
-!!st       !                                             ! wind stress and layer friction
-!!st       z3_4 = 3._wp/4._wp
-!!st       DO_3D( 0, 0, 0, 0,1,jpkm1)
-!!st          uu(ji,jj,jk,Nrhs) = uu(ji,jj,jk,Nrhs) + r1_rho0 * ( z3_4*utau_b(ji,jj) + (1._wp - z3_4)*utau(ji,jj) ) / e3u(ji,jj,jk,Nbb)   &
-!!st             &                                  - rn_rfr * uu(ji,jj,jk,Nbb)
-!!st          vv(ji,jj,jk,Nrhs) = vv(ji,jj,jk,Nrhs) + r1_rho0 * ( z3_4*vtau_b(ji,jj) + (1._wp - z3_4)*vtau(ji,jj) ) / e3v(ji,jj,jk,Nbb)   &
-!!st             &                                  - rn_rfr * vv(ji,jj,jk,Nbb)
-!!st       END_3D
-!!st #endif
       !
       !                                 !==  Time stepping of ssh Eq.  ==!   (and update r3_Naa)
@@ -344,16 +308,16 @@
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! diagnostics and outputs
+      ! diagnostics and outputs at Nbb (i.e. the just computed time step)
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       
-      IF( ln_diacfl  )   CALL dia_cfl   ( kstp,      Nnn )      ! Courant number diagnostics
-                         CALL dia_wri   ( kstp,      Nnn )      ! ocean model: outputs
-      !
-      IF( lrst_oce   )   CALL rst_write    ( kstp, Nbb, Nnn )   ! write output ocean restart file
+      IF( ln_diacfl  )   CALL dia_cfl      ( kstp,      Nbb )      ! Courant number diagnostics
+                         CALL dia_wri      ( kstp,      Nbb )      ! ocean model: outputs
+      !
+      IF( lrst_oce   )   CALL rst_write    ( kstp, Nbb, Nbb )   ! write output ocean restart file
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL stp_ctl      ( kstp, Nnn )
+                         CALL stp_ctl_SWE  ( kstp     , Nbb )
 
       IF( kstp == nit000 ) THEN                          ! 1st time step only
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/AGE/trcsms_age.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/AGE/trcsms_age.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/AGE/trcsms_age.F90	(revision 14200)
@@ -56,4 +56,8 @@
       IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
 
+      IF( l_1st_euler .OR. ln_top_euler ) THEN
+         tr(:,:,:,jp_age,Kbb) = tr(:,:,:,jp_age,Kmm)
+      ENDIF
+
 
       DO jk = 1, nla_age
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcatf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcatf.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/TRP/trcatf.F90	(revision 14200)
@@ -25,24 +25,24 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-   !!   trc_atf     : time stepping on passive tracers
+   !!   trc_atf       : time stepping on passive tracers
    !!----------------------------------------------------------------------
    USE par_trc        ! need jptra, number of passive tracers
-   USE oce_trc         ! ocean dynamics and tracers variables
-   USE trc             ! ocean passive tracers variables
+   USE oce_trc        ! ocean dynamics and tracers variables
+   USE trc            ! ocean passive tracers variables
    USE trd_oce
    USE trdtra
-# if defined key_qco
-   USE traatf_qco
+# if defined key_qco   ||   defined key_linssh
+   USE traatf_qco     ! tracer : Asselin filter (qco)
 # else
-   USE traatf
+   USE traatf         ! tracer : Asselin filter (vvl)
 # endif
    USE bdy_oce   , ONLY: ln_bdy
-   USE trcbdy          ! BDY open boundaries
+   USE trcbdy         ! BDY open boundaries
 # if defined key_agrif
    USE agrif_top_interp
 # endif
    !
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl          ! Print control for debbuging
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE prtctl         ! Print control for debbuging
 
    IMPLICIT NONE
@@ -103,5 +103,5 @@
 #endif
       ! Update after tracer on domain lateral boundaries
-      CALL lbc_lnk( 'trcatf', ptr(:,:,:,:,Kaa), 'T', 1. )   
+      CALL lbc_lnk( 'trcatf', ptr(:,:,:,:,Kaa), 'T', 1._wp )   
 
       IF( ln_bdy )  CALL trc_bdy( kt, Kbb, Kmm, Kaa )
@@ -157,10 +157,10 @@
       ELSE     
          IF( .NOT. l_offline ) THEN ! Leap-Frog + Asselin filter time stepping
-# if defined key_qco
+# if defined key_qco   ||   defined key_linssh
             IF( ln_linssh ) THEN   ;   CALL tra_atf_fix_lf( kt, Kbb, Kmm, Kaa, nittrc000,        'TRC', ptr, jptra )                     !     linear ssh
             ELSE                   ;   CALL tra_atf_qco_lf( kt, Kbb, Kmm, Kaa, nittrc000, rn_Dt, 'TRC', ptr, sbc_trc, sbc_trc_b, jptra ) ! non-linear ssh
 # else
-            IF( ln_linssh ) THEN   ;   CALL tra_atf_fix( kt, Kbb, Kmm, Kaa, nittrc000,         'TRC', ptr, jptra )                     !     linear ssh
-            ELSE                   ;   CALL tra_atf_vvl( kt, Kbb, Kmm, Kaa, nittrc000, rn_Dt, 'TRC', ptr, sbc_trc, sbc_trc_b, jptra ) ! non-linear ssh
+            IF( ln_linssh ) THEN   ;   CALL tra_atf_fix( kt, Kbb, Kmm, Kaa, nittrc000,         'TRC', ptr, jptra )                       !     linear ssh
+            ELSE                   ;   CALL tra_atf_vvl( kt, Kbb, Kmm, Kaa, nittrc000, rn_Dt, 'TRC', ptr, sbc_trc, sbc_trc_b, jptra )    ! non-linear ssh
 # endif
             ENDIF
@@ -169,5 +169,5 @@
          ENDIF
          !
-         CALL lbc_lnk_multi( 'trcatf', ptr(:,:,:,:,Kmm), 'T', 1._wp, ptr(:,:,:,:,Kaa), 'T', 1._wp, ptr(:,:,:,:,Kaa), 'T', 1._wp )
+         CALL lbc_lnk( 'trcatf', ptr(:,:,:,:,Kmm), 'T', 1._wp )
       ENDIF
       !
@@ -193,5 +193,5 @@
    END SUBROUTINE trc_atf
 
-# if ! defined key_qco
+# if defined key_qco   ||   defined key_linssh
    SUBROUTINE trc_atf_off( kt, Kbb, Kmm, Kaa, ptr )
       !!----------------------------------------------------------------------
@@ -225,5 +225,5 @@
       INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices
       REAL(wp) ::   ztc_a , ztc_n , ztc_b , ztc_f , ztc_d    ! local scalar
-      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f, ze3t_d   !   -      -
+      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f           !   -      -
       !!----------------------------------------------------------------------
       !
@@ -241,20 +241,18 @@
       DO jn = 1, jptra      
          DO_3D( 1, 1, 1, 1, 1, jpkm1 )
-            ze3t_b = e3t(ji,jj,jk,Kbb)
-            ze3t_n = e3t(ji,jj,jk,Kmm)
-            ze3t_a = e3t(ji,jj,jk,Kaa)
+            ze3t_b = 1._wp + r3t(ji,jj,Kbb) * tmask(ji,jj,jk)
+            ze3t_n = 1._wp + r3t(ji,jj,Kmm) * tmask(ji,jj,jk)
+            ze3t_a = 1._wp + r3t(ji,jj,Kaa) * tmask(ji,jj,jk)
             !                                         ! tracer content at Before, now and after
-            ztc_b  = ptr(ji,jj,jk,jn,Kbb)  * ze3t_b
-            ztc_n  = ptr(ji,jj,jk,jn,Kmm)  * ze3t_n
+            ztc_b  = ptr(ji,jj,jk,jn,Kbb) * ze3t_b
+            ztc_n  = ptr(ji,jj,jk,jn,Kmm) * ze3t_n
             ztc_a  = ptr(ji,jj,jk,jn,Kaa) * ze3t_a
             !
-            ze3t_d = ze3t_a - 2. * ze3t_n + ze3t_b
             ztc_d  = ztc_a  - 2. * ztc_n  + ztc_b
             !
-            ze3t_f = ze3t_n + rn_atfp * ze3t_d
+            ze3t_f = 1._wp + r3t_f(ji,jj)*tmask(ji,jj,jk)
             ztc_f  = ztc_n  + rn_atfp * ztc_d
             !
             IF( .NOT. ln_linssh .AND. jk == mikt(ji,jj) ) THEN           ! first level 
-               ze3t_f = ze3t_f - rfact2 * ( emp_b(ji,jj)      - emp(ji,jj)   ) 
                ztc_f  = ztc_f  - rfact1 * ( sbc_trc(ji,jj,jn) - sbc_trc_b(ji,jj,jn) )
             ENDIF
@@ -300,5 +298,5 @@
       INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices
       REAL(wp) ::   ztc_a , ztc_n , ztc_b , ztc_f , ztc_d    ! local scalar
-      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f           !   -      -
+      REAL(wp) ::   ze3t_b, ze3t_n, ze3t_a, ze3t_f, ze3t_d   !   -      -
       !!----------------------------------------------------------------------
       !
@@ -316,18 +314,20 @@
       DO jn = 1, jptra      
          DO_3D( 1, 1, 1, 1, 1, jpkm1 )
-            ze3t_b = 1._wp + r3t(ji,jj,Kbb) * tmask(ji,jj,jk)
-            ze3t_n = 1._wp + r3t(ji,jj,Kmm) * tmask(ji,jj,jk)
-            ze3t_a = 1._wp + r3t(ji,jj,Kaa) * tmask(ji,jj,jk)
+            ze3t_b = e3t(ji,jj,jk,Kbb)
+            ze3t_n = e3t(ji,jj,jk,Kmm)
+            ze3t_a = e3t(ji,jj,jk,Kaa)
             !                                         ! tracer content at Before, now and after
-            ztc_b  = ptr(ji,jj,jk,jn,Kbb) * ze3t_b
-            ztc_n  = ptr(ji,jj,jk,jn,Kmm) * ze3t_n
+            ztc_b  = ptr(ji,jj,jk,jn,Kbb)  * ze3t_b
+            ztc_n  = ptr(ji,jj,jk,jn,Kmm)  * ze3t_n
             ztc_a  = ptr(ji,jj,jk,jn,Kaa) * ze3t_a
             !
+            ze3t_d = ze3t_a - 2. * ze3t_n + ze3t_b
             ztc_d  = ztc_a  - 2. * ztc_n  + ztc_b
             !
-            ze3t_f = 1._wp + r3t_f(ji,jj)*tmask(ji,jj,jk)
+            ze3t_f = ze3t_n + rn_atfp * ze3t_d
             ztc_f  = ztc_n  + rn_atfp * ztc_d
             !
             IF( .NOT. ln_linssh .AND. jk == mikt(ji,jj) ) THEN           ! first level 
+               ze3t_f = ze3t_f - rfact2 * ( emp_b(ji,jj)      - emp(ji,jj)   ) 
                ztc_f  = ztc_f  - rfact1 * ( sbc_trc(ji,jj,jn) - sbc_trc_b(ji,jj,jn) )
             ENDIF
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcais.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcais.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/src/TOP/trcais.F90	(revision 14200)
@@ -38,4 +38,5 @@
    !! * Substitutions
 #  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 4.0 , NEMO Consortium (2018)
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/BENCH/cpp_BENCH.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_mpp_mpi key_si3 key_top
+ bld::tool::fppkeys key_mpp_mpi key_si3 key_top key_qco
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/C1D_ASICS/cpp_C1D_ASICS.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_c1d key_mpp_mpi key_iomput
+ bld::tool::fppkeys   key_c1d key_qco key_mpp_mpi key_iomput
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/stpctl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/stpctl.F90	(revision 14199)
+++ 	(revision )
@@ -1,320 +1,0 @@
-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 c1d             ! 1D vertical configuration
-   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables
-   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy
-   !  
-   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                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(8)  ::   nvarid   ! netcdf variable id
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! 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
-      !!              - Stop the run IF problem encountered by setting nstop > 0
-      !!                Problems checked: |ssh| maximum larger than 10 m
-      !!                                  |U|   maximum larger than 10 m/s 
-      !!                                  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(9)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
-      REAL(wp)                        ::   zzz                                   ! local real 
-      REAL(wp), DIMENSION(9)          ::   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 : 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(1) )
-            istatus = NF90_DEF_VAR( nrunid,   'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) )
-            istatus = NF90_DEF_VAR( nrunid,       's_min', NF90_DOUBLE, (/ idtime /), nvarid(3) )
-            istatus = NF90_DEF_VAR( nrunid,       's_max', NF90_DOUBLE, (/ idtime /), nvarid(4) )
-            istatus = NF90_DEF_VAR( nrunid,       't_min', NF90_DOUBLE, (/ idtime /), nvarid(5) )
-            istatus = NF90_DEF_VAR( nrunid,       't_max', NF90_DOUBLE, (/ idtime /), nvarid(6) )
-            IF( ln_zad_Aimp ) THEN
-               istatus = NF90_DEF_VAR( nrunid,   'Cf_max', NF90_DOUBLE, (/ idtime /), nvarid(7) )
-               istatus = NF90_DEF_VAR( nrunid,'abs_wi_max',NF90_DOUBLE, (/ idtime /), nvarid(8) )
-            ENDIF
-            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?
-      !
-      IF( ll_wd ) THEN
-         zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max
-      ELSE
-         zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm)           ), mask = llmsk(:,:,1) )   ! ssh max
-      ENDIF
-      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)
-      llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-      zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk )                     ! minus salinity max
-      zmax(4) = MAXVAL(  ts(:,:,:,jp_sal,Kmm), mask = llmsk )                     !       salinity max
-      IF( ll_colruns .OR. jpnij == 1 ) THEN     ! following variables are used only in the netcdf file
-         zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm), mask = llmsk )                  ! minus temperature max
-         zmax(6) = MAXVAL(  ts(:,:,:,jp_tem,Kmm), mask = llmsk )                  !       temperature max
-         IF( ln_zad_Aimp ) THEN
-            zmax(7) = MAXVAL(   Cu_adv(:,:,:)   , mask = llmsk )                  ! partitioning coeff. max
-            llmsk(:,:,:) = wmask(:,:,:) == 1._wp
-            zmax(8) = MAXVAL(  ABS( wi(:,:,:) ) , mask = llmsk )                  ! implicit vertical vel. max
-         ELSE
-            zmax(7:8) = 0._wp
-         ENDIF
-      ELSE
-         zmax(5:8) = 0._wp
-      ENDIF
-      zmax(9) = 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: ok even of ll_0oce = .true. 
-         nstop = NINT( zmax(9) )                 ! 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
-      !
-      !                                   !==              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/) )
-            istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
-         END DO
-         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
-      END IF
-      !                                   !==               error handling               ==!
-      !                                   !==  done by all processes at every time step  ==!
-      !
-      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) <=   0._wp .OR.   &                   ! negative or zero sea surface salinity
-!!$         & zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 )
-!!$         & zmax(4) <    0._wp .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
-         !
-         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_maxloc( 'stpctl', ABS(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) )
-            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-            CALL mpp_minloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,3) )
-            CALL mpp_maxloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,4) )
-            ! find which subdomain has the max.
-            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 9
-               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) = MAXLOC( ABS( 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(:,:,:) )
-            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-            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
-               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: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
-         CALL wrt_line( ctmp2, kt, '|ssh| max', 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) )
-         CALL wrt_line( ctmp4, kt, 'Sal   min', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) )
-         CALL wrt_line( ctmp5, kt, 'Sal   max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) )
-         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, 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
-            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', 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, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_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: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/trazdf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/trazdf.F90	(revision 14199)
+++ 	(revision )
@@ -1,247 +1,0 @@
-MODULE trazdf
-   !!==============================================================================
-   !!                 ***  MODULE  trazdf  ***
-   !! Ocean active tracers:  vertical component of the tracer mixing trend
-   !!==============================================================================
-   !! History :  1.0  !  2005-11  (G. Madec)  Original code
-   !!            3.0  !  2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
-   !!            4.0  !  2017-06  (G. Madec)  remove explict time-stepping option
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_zdf       : Update the tracer trend with the vertical diffusion
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers variables
-   USE dom_oce        ! ocean space and time domain variables 
-   USE domvvl         ! variable volume
-   USE phycst         ! physical constant
-   USE zdf_oce        ! ocean vertical physics variables
-   USE sbc_oce        ! surface boundary condition: ocean
-   USE ldftra         ! lateral diffusion: eddy diffusivity
-   USE ldfslp         ! lateral diffusion: iso-neutral slope 
-   USE trd_oce        ! trends: ocean variables
-   USE trdtra         ! trends: tracer trend manager
-   !
-   USE in_out_manager ! I/O manager
-   USE prtctl         ! Print control
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp        ! MPP library
-   USE timing         ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_zdf       ! called by step.F90
-   PUBLIC   tra_zdf_imp   ! called by trczdf.F90
-
-   !! * Substitutions
-#  include "do_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id$
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_zdf( kt, Kbb, Kmm, Krhs, pts, Kaa )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_zdf  ***
-      !!
-      !! ** Purpose :   compute the vertical ocean tracer physics.
-      !!---------------------------------------------------------------------
-      INTEGER                                  , INTENT(in)    :: kt                  ! ocean time-step index
-      INTEGER                                  , INTENT(in)    :: Kbb, Kmm, Krhs, Kaa ! time level indices
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts                 ! active tracers and RHS of tracer equation
-      !
-      INTEGER  ::   ji, jj, jk   ! Dummy loop indices
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdt, ztrds   ! 3D workspace
-      !!---------------------------------------------------------------------
-      !
-      IF( ln_timing )   CALL timing_start('tra_zdf')
-      !
-      IF( kt == nit000 )  THEN
-         IF( ntile == 0 .OR. ntile == 1 )  THEN                   ! Do only on the first tile
-            IF(lwp)WRITE(numout,*)
-            IF(lwp)WRITE(numout,*) 'tra_zdf : implicit vertical mixing on T & S'
-            IF(lwp)WRITE(numout,*) '~~~~~~~ '
-         ENDIF
-      ENDIF
-      !
-      IF( l_trdtra )   THEN                  !* Save ta and sa trends
-         ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) )
-         ztrdt(:,:,:) = pts(:,:,:,jp_tem,Kaa)
-         ztrds(:,:,:) = pts(:,:,:,jp_sal,Kaa)
-      ENDIF
-      !
-      !                                      !* compute lateral mixing trend and add it to the general trend
-      CALL tra_zdf_imp( kt, nit000, 'TRA', rDt, Kbb, Kmm, Krhs, pts, Kaa, jpts ) 
-
-!!gm WHY here !   and I don't like that !
-      ! DRAKKAR SSS control {
-      ! JMM avoid negative salinities near river outlet ! Ugly fix
-      ! JMM : restore negative salinities to small salinities:
-!!$      WHERE( pts(:,:,:,jp_sal,Kaa) < 0._wp )   pts(:,:,:,jp_sal,Kaa) = 0.1_wp
-!!gm
-
-      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
-         DO jk = 1, jpk
-            ztrdt(:,:,jk) = (   (  pts(:,:,jk,jp_tem,Kaa)*e3t(:,:,jk,Kaa)     &
-               &                 - pts(:,:,jk,jp_tem,Kbb)*e3t(:,:,jk,Kbb)  )  &
-               &              / (  e3t(:,:,jk,Kmm)*rDt  )   )                 &
-               &          - ztrdt(:,:,jk)
-            ztrds(:,:,jk) = (   (  pts(:,:,jk,jp_sal,Kaa)*e3t(:,:,jk,Kaa)     &
-               &                 - pts(:,:,jk,jp_sal,Kbb)*e3t(:,:,jk,Kbb)  )  &
-               &             / (   e3t(:,:,jk,Kmm)*rDt  )   )                 &
-               &          - ztrds(:,:,jk)
-         END DO
-!!gm this should be moved in trdtra.F90 and done on all trends
-         CALL lbc_lnk_multi( 'trazdf', ztrdt, 'T', 1. , ztrds, 'T', 1. )
-!!gm
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_zdf, ztrds )
-         DEALLOCATE( ztrdt , ztrds )
-      ENDIF
-      !                                          ! print mean trends (used for debugging)
-      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Kaa), clinfo1=' zdf  - Ta: ', mask1=tmask,               &
-         &                                  tab3d_2=pts(:,:,:,jp_sal,Kaa), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-      !
-      IF( ln_timing )   CALL timing_stop('tra_zdf')
-      !
-   END SUBROUTINE tra_zdf
-
- 
-   SUBROUTINE tra_zdf_imp( kt, kit000, cdtype, p2dt, Kbb, Kmm, Krhs, pt, Kaa, kjpt ) 
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_zdf_imp  ***
-      !!
-      !! ** Purpose :   Compute the after tracer through a implicit computation
-      !!     of the vertical tracer diffusion (including the vertical component 
-      !!     of lateral mixing (only for 2nd order operator, for fourth order 
-      !!     it is already computed and add to the general trend in traldf) 
-      !!
-      !! ** Method  :  The vertical diffusion of a tracer ,t , is given by:
-      !!          difft = dz( avt dz(t) ) = 1/e3t dk+1( avt/e3w dk(t) )
-      !!      It is computed using a backward time scheme (t=after field)
-      !!      which provide directly the after tracer field.
-      !!      If ln_zdfddm=T, use avs for salinity or for passive tracers
-      !!      Surface and bottom boundary conditions: no diffusive flux on
-      !!      both tracers (bottom, applied through the masked field avt).
-      !!      If iso-neutral mixing, add to avt the contribution due to lateral mixing.
-      !!
-      !! ** Action  : - pt(:,:,:,:,Kaa)  becomes the after tracer
-      !!---------------------------------------------------------------------
-      INTEGER                                  , INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER                                  , INTENT(in   ) ::   Kbb, Kmm, Krhs, Kaa  ! ocean time level indices
-      INTEGER                                  , INTENT(in   ) ::   kit000   ! first time step index
-      CHARACTER(len=3)                         , INTENT(in   ) ::   cdtype   ! =TRA or TRC (tracer indicator)
-      INTEGER                                  , INTENT(in   ) ::   kjpt     ! number of tracers
-      REAL(wp)                                 , INTENT(in   ) ::   p2dt     ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) ::   pt       ! tracers and RHS of tracer equation
-      !
-      INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) ::  zrhs, zzwi, zzws ! local scalars
-      REAL(wp), DIMENSION(A2D(nn_hls),jpk) ::  zwi, zwt, zwd, zws
-      !!---------------------------------------------------------------------
-      !
-      !                                               ! ============= !
-      DO jn = 1, kjpt                                 !  tracer loop  !
-         !                                            ! ============= !
-         !  Matrix construction
-         ! --------------------
-         ! Build matrix if temperature or salinity (only in double diffusion case) or first passive tracer
-         !
-         IF(  ( cdtype == 'TRA' .AND. ( jn == jp_tem .OR. ( jn == jp_sal .AND. ln_zdfddm ) ) ) .OR.   &
-            & ( cdtype == 'TRC' .AND. jn == 1 )  )  THEN
-            !
-            ! vertical mixing coef.: avt for temperature, avs for salinity and passive tracers
-            IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN
-               DO_3D( 1, 1, 1, 1, 2, jpk )
-                  zwt(ji,jj,jk) = avt(ji,jj,jk)
-               END_3D
-            ELSE
-               DO_3D( 1, 1, 1, 1, 2, jpk )
-                  zwt(ji,jj,jk) = avs(ji,jj,jk)
-               END_3D
-            ENDIF
-            zwt(:,:,1) = 0._wp
-            !
-            IF( l_ldfslp ) THEN            ! isoneutral diffusion: add the contribution 
-               IF( ln_traldf_msc  ) THEN     ! MSC iso-neutral operator 
-                  DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-                     zwt(ji,jj,jk) = zwt(ji,jj,jk) + akz(ji,jj,jk)  
-                  END_3D
-               ELSE                          ! standard or triad iso-neutral operator
-                  DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-                     zwt(ji,jj,jk) = zwt(ji,jj,jk) + ah_wslp2(ji,jj,jk)
-                  END_3D
-               ENDIF
-            ENDIF
-            !
-            ! Diagonal, lower (i), upper (s)  (including the bottom boundary condition since avt is masked)
-            IF( ln_zad_Aimp ) THEN         ! Adaptive implicit vertical advection
-               DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-                  zzwi = - p2dt * zwt(ji,jj,jk  ) / e3w(ji,jj,jk  ,Kmm)
-                  zzws = - p2dt * zwt(ji,jj,jk+1) / e3w(ji,jj,jk+1,Kmm)
-                  zwd(ji,jj,jk) = e3t(ji,jj,jk,Kaa) - zzwi - zzws   &
-                     &                 + p2dt * ( MAX( wi(ji,jj,jk  ) , 0._wp ) - MIN( wi(ji,jj,jk+1) , 0._wp ) )
-                  zwi(ji,jj,jk) = zzwi + p2dt *   MIN( wi(ji,jj,jk  ) , 0._wp )
-                  zws(ji,jj,jk) = zzws - p2dt *   MAX( wi(ji,jj,jk+1) , 0._wp )
-               END_3D
-            ELSE
-               DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-                  zwi(ji,jj,jk) = - p2dt * zwt(ji,jj,jk  ) / e3w(ji,jj,jk,Kmm)
-                  zws(ji,jj,jk) = - p2dt * zwt(ji,jj,jk+1) / e3w(ji,jj,jk+1,Kmm)
-                  zwd(ji,jj,jk) = e3t(ji,jj,jk,Kaa) - zwi(ji,jj,jk) - zws(ji,jj,jk)
-               END_3D
-            ENDIF
-            !
-            !! Matrix inversion from the first level
-            !!----------------------------------------------------------------------
-            !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
-            !
-            !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
-            !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
-            !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
-            !        (        ...               )( ...  ) ( ...  )
-            !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
-            !
-            !   m is decomposed in the product of an upper and lower triangular matrix.
-            !   The 3 diagonal terms are in 3d arrays: zwd, zws, zwi.
-            !   Suffices i,s and d indicate "inferior" (below diagonal), diagonal
-            !   and "superior" (above diagonal) components of the tridiagonal system.
-            !   The solution will be in the 4d array pta.
-            !   The 3d array zwt is used as a work space array.
-            !   En route to the solution pt(:,:,:,:,Kaa) is used a to evaluate the rhs and then 
-            !   used as a work space array: its value is modified.
-            !
-            DO_2D( 0, 0, 0, 0 )
-               zwt(ji,jj,1) = zwd(ji,jj,1)
-            END_2D
-            DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwt(ji,jj,jk-1)
-            END_3D
-            !
-         ENDIF 
-         !         
-         DO_2D( 0, 0, 0, 0 )
-            pt(ji,jj,1,jn,Kaa) = e3t(ji,jj,1,Kbb) * pt(ji,jj,1,jn,Kbb) + p2dt * e3t(ji,jj,1,Kmm) * pt(ji,jj,1,jn,Krhs)
-         END_2D
-         DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-            zrhs = e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb) + p2dt * e3t(ji,jj,jk,Kmm) * pt(ji,jj,jk,jn,Krhs)   ! zrhs=right hand side
-            pt(ji,jj,jk,jn,Kaa) = zrhs - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * pt(ji,jj,jk-1,jn,Kaa)
-         END_3D
-         !
-         DO_2D( 0, 0, 0, 0 )
-            pt(ji,jj,jpkm1,jn,Kaa) = pt(ji,jj,jpkm1,jn,Kaa) / zwt(ji,jj,jpkm1) * tmask(ji,jj,jpkm1)
-         END_2D
-         DO_3DS( 0, 0, 0, 0, jpk-2, 1, -1 )
-            pt(ji,jj,jk,jn,Kaa) = ( pt(ji,jj,jk,jn,Kaa) - zws(ji,jj,jk) * pt(ji,jj,jk+1,jn,Kaa) )   &
-               &             / zwt(ji,jj,jk) * tmask(ji,jj,jk)
-         END_3D
-         !                                            ! ================= !
-      END DO                                          !  end tracer loop  !
-      !                                               ! ================= !
-   END SUBROUTINE tra_zdf_imp
-
-   !!==============================================================================
-END MODULE trazdf
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/MY_SRC/usrdef_istate.F90	(revision 14200)
@@ -16,4 +16,5 @@
    USE dom_oce        
    USE phycst         ! physical constants
+   USE eosbn2, ONLY: rn_a0
    !
    USE in_out_manager ! I/O manager
@@ -197,6 +198,6 @@
                   zrho1 = zrho1 - zdzF * zpsurf / grav    ! -1/g Dz(P) = -1/g * F'(z) * Psurf(x,y)
                ENDIF
-               !               pts(ji,jj,jk,jp_tem) = (20._wp + (rho0-zrho1) / 0.28_wp) * ptmask(ji,jj,jk)
-               pts(ji,jj,jk,jp_tem) = (10._wp + (rho0-zrho1) / 0.28_wp) * ptmask(ji,jj,jk)
+               !               pts(ji,jj,jk,jp_tem) = (20._wp + (rho0-zrho1) / rn_a0) * ptmask(ji,jj,jk)
+               pts(ji,jj,jk,jp_tem) = (10._wp + (rho0-zrho1) / rn_a0) * ptmask(ji,jj,jk)
             END DO
          END_2D
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CANAL/cpp_CANAL.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi 
+ bld::tool::fppkeys key_iomput key_mpp_mpi key_qco 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/CPL_OASIS/cpp_CPL_OASIS.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_oasis3
+bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_oasis3 key_qco
Index: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/stpctl.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/stpctl.F90	(revision 14199)
+++ 	(revision )
@@ -1,326 +1,0 @@
-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 c1d             ! 1D vertical configuration
-   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables
-   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy
-   !  
-   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 eosbn2
-   !
-   USE netcdf          ! NetCDF library
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC stp_ctl           ! routine called by step.F90
-
-   INTEGER                ::   nrunid   ! netcdf file id
-   INTEGER, DIMENSION(8)  ::   nvarid   ! netcdf variable id
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: stpctl.F90 13942 2020-12-01 16:14:18Z jchanut $
-   !! 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
-      !!              - Stop the run IF problem encountered by setting nstop > 0
-      !!                Problems checked: |ssh| maximum larger than 10 m
-      !!                                  |U|   maximum larger than 10 m/s 
-      !!                                  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(9)          ::   iareasum, iareamin, iareamax
-      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices
-      REAL(wp)                        ::   zzz                                   ! local real 
-      REAL(wp), DIMENSION(9)          ::   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 : 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(1) )
-            istatus = NF90_DEF_VAR( nrunid,   'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) )
-            istatus = NF90_DEF_VAR( nrunid,       's_min', NF90_DOUBLE, (/ idtime /), nvarid(3) )
-            istatus = NF90_DEF_VAR( nrunid,       's_max', NF90_DOUBLE, (/ idtime /), nvarid(4) )
-            istatus = NF90_DEF_VAR( nrunid,       't_min', NF90_DOUBLE, (/ idtime /), nvarid(5) )
-            istatus = NF90_DEF_VAR( nrunid,       't_max', NF90_DOUBLE, (/ idtime /), nvarid(6) )
-            IF( ln_zad_Aimp ) THEN
-               istatus = NF90_DEF_VAR( nrunid,   'Cf_max', NF90_DOUBLE, (/ idtime /), nvarid(7) )
-               istatus = NF90_DEF_VAR( nrunid,'abs_wi_max',NF90_DOUBLE, (/ idtime /), nvarid(8) )
-            ENDIF
-            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?
-      !
-      IF( ll_wd ) THEN
-         zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max
-      ELSE
-         zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm)           ), mask = llmsk(:,:,1) )   ! ssh max
-      ENDIF
-      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)
-      llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-      IF ( ln_seos.AND.(rn_lambda2==0._wp) ) THEN ! Discard checks on salinity
-         zmax(3) = -99._wp
-         zmax(4) = 99._wp
-      ELSE
-         zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk )                  ! minus salinity max
-         zmax(4) = MAXVAL(  ts(:,:,:,jp_sal,Kmm), mask = llmsk )                  !       salinity max
-      ENDIF
-      IF( ll_colruns .OR. jpnij == 1 ) THEN     ! following variables are used only in the netcdf file
-         zmax(5) = MAXVAL( -ts(:,:,:,jp_tem,Kmm), mask = llmsk )                  ! minus temperature max
-         zmax(6) = MAXVAL(  ts(:,:,:,jp_tem,Kmm), mask = llmsk )                  !       temperature max
-         IF( ln_zad_Aimp ) THEN
-            zmax(7) = MAXVAL(   Cu_adv(:,:,:)   , mask = llmsk )                  ! partitioning coeff. max
-            llmsk(:,:,:) = wmask(:,:,:) == 1._wp
-            zmax(8) = MAXVAL(  ABS( wi(:,:,:) ) , mask = llmsk )                  ! implicit vertical vel. max
-         ELSE
-            zmax(7:8) = 0._wp
-         ENDIF
-      ELSE
-         zmax(5:8) = 0._wp
-      ENDIF
-      zmax(9) = 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: ok even of ll_0oce = .true. 
-         nstop = NINT( zmax(9) )                 ! 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
-      !
-      !                                   !==              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/) )
-            istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
-         END DO
-         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
-      END IF
-      !                                   !==               error handling               ==!
-      !                                   !==  done by all processes at every time step  ==!
-      !
-      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) <=   0._wp .OR.   &                   ! negative or zero sea surface salinity
-         & zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 )
-         & zmax(4) <    0._wp .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
-         !
-         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_maxloc( 'stpctl', ABS(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) )
-            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-            CALL mpp_minloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,3) )
-            CALL mpp_maxloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,4) )
-            ! find which subdomain has the max.
-            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0
-            DO ji = 1, 9
-               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) = MAXLOC( ABS( 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(:,:,:) )
-            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain
-            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
-               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: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
-         CALL wrt_line( ctmp2, kt, '|ssh| max', 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) )
-         CALL wrt_line( ctmp4, kt, 'Sal   min', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) )
-         CALL wrt_line( ctmp5, kt, 'Sal   max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) )
-         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, 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
-            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', 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, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_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: MO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/trazdf.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/trazdf.F90	(revision 14199)
+++ 	(revision )
@@ -1,245 +1,0 @@
-MODULE trazdf
-   !!==============================================================================
-   !!                 ***  MODULE  trazdf  ***
-   !! Ocean active tracers:  vertical component of the tracer mixing trend
-   !!==============================================================================
-   !! History :  1.0  !  2005-11  (G. Madec)  Original code
-   !!            3.0  !  2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
-   !!            4.0  !  2017-06  (G. Madec)  remove explict time-stepping option
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_zdf       : Update the tracer trend with the vertical diffusion
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers variables
-   USE dom_oce        ! ocean space and time domain variables 
-   USE domvvl         ! variable volume
-   USE phycst         ! physical constant
-   USE zdf_oce        ! ocean vertical physics variables
-   USE sbc_oce        ! surface boundary condition: ocean
-   USE ldftra         ! lateral diffusion: eddy diffusivity
-   USE ldfslp         ! lateral diffusion: iso-neutral slope 
-   USE trd_oce        ! trends: ocean variables
-   USE trdtra         ! trends: tracer trend manager
-   !
-   USE in_out_manager ! I/O manager
-   USE prtctl         ! Print control
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp        ! MPP library
-   USE timing         ! Timing
-   USE eosbn2
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_zdf       ! called by step.F90
-   PUBLIC   tra_zdf_imp   ! called by trczdf.F90
-
-   !! * Substitutions
-#  include "do_loop_substitute.h90"
-#  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
-   !! $Id: trazdf.F90 13295 2020-07-10 18:24:21Z acc $
-   !! Software governed by the CeCILL license (see ./LICENSE)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_zdf( kt, Kbb, Kmm, Krhs, pts, Kaa )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_zdf  ***
-      !!
-      !! ** Purpose :   compute the vertical ocean tracer physics.
-      !!---------------------------------------------------------------------
-      INTEGER                                  , INTENT(in)    :: kt                  ! ocean time-step index
-      INTEGER                                  , INTENT(in)    :: Kbb, Kmm, Krhs, Kaa ! time level indices
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts                 ! active tracers and RHS of tracer equation
-      !
-      INTEGER  ::   jk   ! Dummy loop indices
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdt, ztrds   ! 3D workspace
-      !!---------------------------------------------------------------------
-      !
-      IF( ln_timing )   CALL timing_start('tra_zdf')
-      !
-      IF( kt == nit000 )  THEN
-         IF(lwp)WRITE(numout,*)
-         IF(lwp)WRITE(numout,*) 'tra_zdf : implicit vertical mixing on T & S'
-         IF(lwp)WRITE(numout,*) '~~~~~~~ '
-      ENDIF
-      !
-      IF( l_trdtra )   THEN                  !* Save ta and sa trends
-         ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) )
-         ztrdt(:,:,:) = pts(:,:,:,jp_tem,Kaa)
-         ztrds(:,:,:) = pts(:,:,:,jp_sal,Kaa)
-      ENDIF
-      !
-      !                                      !* compute lateral mixing trend and add it to the general trend
-      CALL tra_zdf_imp( kt, nit000, 'TRA', rDt, Kbb, Kmm, Krhs, pts, Kaa, jpts ) 
-
-!!gm WHY here !   and I don't like that !
-      ! DRAKKAR SSS control {
-      ! JMM avoid negative salinities near river outlet ! Ugly fix
-      ! JMM : restore negative salinities to small salinities:
-      IF ( .NOT.(ln_seos.AND.(rn_lambda2==0._wp)) ) THEN
-         WHERE( pts(:,:,:,jp_sal,Kaa) < 0._wp )   pts(:,:,:,jp_sal,Kaa) = 0.1_wp
-      ENDIF
-!!gm
-
-      IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
-         DO jk = 1, jpkm1
-            ztrdt(:,:,jk) = (   (  pts(:,:,jk,jp_tem,Kaa)*e3t(:,:,jk,Kaa)     &
-               &                 - pts(:,:,jk,jp_tem,Kbb)*e3t(:,:,jk,Kbb)  )  &
-               &              / (  e3t(:,:,jk,Kmm)*rDt  )   )                 &
-               &          - ztrdt(:,:,jk)
-            ztrds(:,:,jk) = (   (  pts(:,:,jk,jp_sal,Kaa)*e3t(:,:,jk,Kaa)     &
-               &                 - pts(:,:,jk,jp_sal,Kbb)*e3t(:,:,jk,Kbb)  )  &
-               &             / (   e3t(:,:,jk,Kmm)*rDt  )   )                 &
-               &          - ztrds(:,:,jk)
-         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 )
-!!gm
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_zdf, ztrds )
-         DEALLOCATE( ztrdt , ztrds )
-      ENDIF
-      !                                          ! print mean trends (used for debugging)
-      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Kaa), clinfo1=' zdf  - Ta: ', mask1=tmask,               &
-         &                                  tab3d_2=pts(:,:,:,jp_sal,Kaa), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-      !
-      IF( ln_timing )   CALL timing_stop('tra_zdf')
-      !
-   END SUBROUTINE tra_zdf
-
- 
-   SUBROUTINE tra_zdf_imp( kt, kit000, cdtype, p2dt, Kbb, Kmm, Krhs, pt, Kaa, kjpt ) 
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_zdf_imp  ***
-      !!
-      !! ** Purpose :   Compute the after tracer through a implicit computation
-      !!     of the vertical tracer diffusion (including the vertical component 
-      !!     of lateral mixing (only for 2nd order operator, for fourth order 
-      !!     it is already computed and add to the general trend in traldf) 
-      !!
-      !! ** Method  :  The vertical diffusion of a tracer ,t , is given by:
-      !!          difft = dz( avt dz(t) ) = 1/e3t dk+1( avt/e3w dk(t) )
-      !!      It is computed using a backward time scheme (t=after field)
-      !!      which provide directly the after tracer field.
-      !!      If ln_zdfddm=T, use avs for salinity or for passive tracers
-      !!      Surface and bottom boundary conditions: no diffusive flux on
-      !!      both tracers (bottom, applied through the masked field avt).
-      !!      If iso-neutral mixing, add to avt the contribution due to lateral mixing.
-      !!
-      !! ** Action  : - pt(:,:,:,:,Kaa)  becomes the after tracer
-      !!---------------------------------------------------------------------
-      INTEGER                                  , INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER                                  , INTENT(in   ) ::   Kbb, Kmm, Krhs, Kaa  ! ocean time level indices
-      INTEGER                                  , INTENT(in   ) ::   kit000   ! first time step index
-      CHARACTER(len=3)                         , INTENT(in   ) ::   cdtype   ! =TRA or TRC (tracer indicator)
-      INTEGER                                  , INTENT(in   ) ::   kjpt     ! number of tracers
-      REAL(wp)                                 , INTENT(in   ) ::   p2dt     ! tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt,jpt), INTENT(inout) ::   pt       ! tracers and RHS of tracer equation
-      !
-      INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) ::  zrhs, zzwi, zzws ! local scalars
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zwi, zwt, zwd, zws
-      !!---------------------------------------------------------------------
-      !
-      !                                               ! ============= !
-      DO jn = 1, kjpt                                 !  tracer loop  !
-         !                                            ! ============= !
-         !  Matrix construction
-         ! --------------------
-         ! Build matrix if temperature or salinity (only in double diffusion case) or first passive tracer
-         !
-         IF(  ( cdtype == 'TRA' .AND. ( jn == jp_tem .OR. ( jn == jp_sal .AND. ln_zdfddm ) ) ) .OR.   &
-            & ( cdtype == 'TRC' .AND. jn == 1 )  )  THEN
-            !
-            ! vertical mixing coef.: avt for temperature, avs for salinity and passive tracers
-            IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN   ;   zwt(:,:,2:jpk) = avt(:,:,2:jpk)
-            ELSE                                            ;   zwt(:,:,2:jpk) = avs(:,:,2:jpk)
-            ENDIF
-            zwt(:,:,1) = 0._wp
-            !
-            IF( l_ldfslp ) THEN            ! isoneutral diffusion: add the contribution 
-               IF( ln_traldf_msc  ) THEN     ! MSC iso-neutral operator 
-                  DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-                     zwt(ji,jj,jk) = zwt(ji,jj,jk) + akz(ji,jj,jk)  
-                  END_3D
-               ELSE                          ! standard or triad iso-neutral operator
-                  DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-                     zwt(ji,jj,jk) = zwt(ji,jj,jk) + ah_wslp2(ji,jj,jk)
-                  END_3D
-               ENDIF
-            ENDIF
-            !
-            ! Diagonal, lower (i), upper (s)  (including the bottom boundary condition since avt is masked)
-            IF( ln_zad_Aimp ) THEN         ! Adaptive implicit vertical advection
-               DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-                  zzwi = - p2dt * zwt(ji,jj,jk  ) / e3w(ji,jj,jk  ,Kmm)
-                  zzws = - p2dt * zwt(ji,jj,jk+1) / e3w(ji,jj,jk+1,Kmm)
-                  zwd(ji,jj,jk) = e3t(ji,jj,jk,Kaa) - zzwi - zzws   &
-                     &                 + p2dt * ( MAX( wi(ji,jj,jk  ) , 0._wp ) - MIN( wi(ji,jj,jk+1) , 0._wp ) )
-                  zwi(ji,jj,jk) = zzwi + p2dt *   MIN( wi(ji,jj,jk  ) , 0._wp )
-                  zws(ji,jj,jk) = zzws - p2dt *   MAX( wi(ji,jj,jk+1) , 0._wp )
-               END_3D
-            ELSE
-               DO_3D( 0, 0, 0, 0, 1, jpkm1 )
-                  zwi(ji,jj,jk) = - p2dt * zwt(ji,jj,jk  ) / e3w(ji,jj,jk,Kmm)
-                  zws(ji,jj,jk) = - p2dt * zwt(ji,jj,jk+1) / e3w(ji,jj,jk+1,Kmm)
-                  zwd(ji,jj,jk) = e3t(ji,jj,jk,Kaa) - zwi(ji,jj,jk) - zws(ji,jj,jk)
-               END_3D
-            ENDIF
-            !
-            !! Matrix inversion from the first level
-            !!----------------------------------------------------------------------
-            !   solve m.x = y  where m is a tri diagonal matrix ( jpk*jpk )
-            !
-            !        ( zwd1 zws1   0    0    0  )( zwx1 ) ( zwy1 )
-            !        ( zwi2 zwd2 zws2   0    0  )( zwx2 ) ( zwy2 )
-            !        (  0   zwi3 zwd3 zws3   0  )( zwx3 )=( zwy3 )
-            !        (        ...               )( ...  ) ( ...  )
-            !        (  0    0    0   zwik zwdk )( zwxk ) ( zwyk )
-            !
-            !   m is decomposed in the product of an upper and lower triangular matrix.
-            !   The 3 diagonal terms are in 3d arrays: zwd, zws, zwi.
-            !   Suffices i,s and d indicate "inferior" (below diagonal), diagonal
-            !   and "superior" (above diagonal) components of the tridiagonal system.
-            !   The solution will be in the 4d array pta.
-            !   The 3d array zwt is used as a work space array.
-            !   En route to the solution pt(:,:,:,:,Kaa) is used a to evaluate the rhs and then 
-            !   used as a work space array: its value is modified.
-            !
-            DO_2D( 0, 0, 0, 0 )
-               zwt(ji,jj,1) = zwd(ji,jj,1)
-            END_2D
-            DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) / zwt(ji,jj,jk-1)
-            END_3D
-            !
-         ENDIF 
-         !         
-         DO_2D( 0, 0, 0, 0 )
-            pt(ji,jj,1,jn,Kaa) =        e3t(ji,jj,1,Kbb) * pt(ji,jj,1,jn,Kbb)    &
-               &               + p2dt * e3t(ji,jj,1,Kmm) * pt(ji,jj,1,jn,Krhs)
-         END_2D
-         DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-            zrhs =        e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb)    & 
-               & + p2dt * e3t(ji,jj,jk,Kmm) * pt(ji,jj,jk,jn,Krhs)   ! zrhs=right hand side
-            pt(ji,jj,jk,jn,Kaa) = zrhs - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * pt(ji,jj,jk-1,jn,Kaa)
-         END_3D
-         !
-         DO_2D( 0, 0, 0, 0 )
-            pt(ji,jj,jpkm1,jn,Kaa) = pt(ji,jj,jpkm1,jn,Kaa) / zwt(ji,jj,jpkm1) * tmask(ji,jj,jpkm1)
-         END_2D
-         DO_3DS( 0, 0, 0, 0, jpk-2, 1, -1 )
-            pt(ji,jj,jk,jn,Kaa) = ( pt(ji,jj,jk,jn,Kaa) - zws(ji,jj,jk) * pt(ji,jj,jk+1,jn,Kaa) )   &
-               &             / zwt(ji,jj,jk) * tmask(ji,jj,jk)
-         END_3D
-         !                                            ! ================= !
-      END DO                                          !  end tracer loop  !
-      !                                               ! ================= !
-   END SUBROUTINE tra_zdf_imp
-
-   !!==============================================================================
-END MODULE trazdf
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/MY_SRC/usrdef_istate.F90	(revision 14200)
@@ -15,4 +15,5 @@
    USE par_oce        ! ocean space and time domain
    USE phycst         ! physical constants
+   USE eosbn2, ONLY: rn_a0
    !
    USE in_out_manager ! I/O manager
@@ -23,5 +24,5 @@
 
    PUBLIC   usr_def_istate   ! called by istate.F90
-
+   PUBlIC   usr_def_istate_ssh
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -34,5 +35,5 @@
 CONTAINS
   
-   SUBROUTINE usr_def_istate( pdept, ptmask, pts, pu, pv, pssh )
+   SUBROUTINE usr_def_istate( pdept, ptmask, pts, pu, pv )
       !!----------------------------------------------------------------------
       !!                   ***  ROUTINE usr_def_istate  ***
@@ -54,5 +55,4 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pu      ! i-component of the velocity  [m/s] 
       REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(  out) ::   pv      ! j-component of the velocity  [m/s] 
-      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    ! sea-surface height
       !
       INTEGER  :: ji,jj,jk     ! dummy loop indices
@@ -70,5 +70,4 @@
       pu  (:,:,:) = 0._wp        ! ocean at rest
       pv  (:,:,:) = 0._wp
-      pssh(:,:)   = 0._wp
       pts(:,:,:,:) = 0._wp
       !
@@ -100,15 +99,15 @@
                zf = 1._wp
             ENDIF   
-            zrho1 = rho0*zn2*zdt/grav/0.2_wp
+            zrho1 = rho0*zn2*zdt/grav/rn_a0
             pts(ji,jj,jk,jp_tem) = (15._wp - zrho1) * ptmask(ji,jj,jk)
 ! Mass conserving initialization:
-!            ztd = 15._wp*gdepw_0(ji,jj,jk+1)-0.5*rho0*zn2/(0.2_wp*grav)*gdepw_0(ji,jj,jk+1)**2
-!            ztu = 15._wp*gdepw_0(ji,jj,jk  )-0.5*rho0*zn2/(0.2_wp*grav)*gdepw_0(ji,jj,jk  )**2
-!            pts(ji,jj,jk,jp_tem) = (ztd - ztu)/e3t_0(ji,jj,jk) * ptmask(ji,jj,jk)
+            ztd = 15._wp*gdepw_0(ji,jj,jk+1)-0.5*rho0*zn2/(rn_a0*grav)*gdepw_0(ji,jj,jk+1)**2
+            ztu = 15._wp*gdepw_0(ji,jj,jk  )-0.5*rho0*zn2/(rn_a0*grav)*gdepw_0(ji,jj,jk  )**2
+            pts(ji,jj,jk,jp_tem) = (ztd - ztu)/e3t_0(ji,jj,jk) * ptmask(ji,jj,jk)
             IF (Agrif_root().AND.(  mjg0(jj) == Nj0glo-2 ) )  THEN
                pv(ji,jj,jk) = -sqrt(zdb*zh0)*exp(-zxw/zro)*(1._wp-zf) * ptmask(ji,jj,jk)
             ENDIF
             IF (Agrif_root().AND.(  mjg0(jj) == Nj0glo-1 ) )  THEN
-               pts(ji,jj,jk,jp_tem) = MIN(pts(ji,jj,jk,jp_tem), 15._wp - zdb*rho0/grav/0.2_wp*(1._wp-zf)) * ptmask(ji,jj,jk) 
+               pts(ji,jj,jk,jp_tem) = MIN(pts(ji,jj,jk,jp_tem), 15._wp - zdb*rho0/grav/rn_a0*(1._wp-zf)) * ptmask(ji,jj,jk) 
                pts(ji,jj,jk,jp_sal) = 1._wp * ptmask(ji,jj,jk) 
             ENDIF
@@ -118,4 +117,24 @@
    END SUBROUTINE usr_def_istate
 
+  
+   SUBROUTINE usr_def_istate_ssh( ptmask, pssh )
+      !!----------------------------------------------------------------------
+      !!                   ***  ROUTINE usr_def_istate  ***
+      !! 
+      !! ** Purpose :   Initialization of ssh
+      !!                Here DOME configuration 
+      !!
+      !! ** Method  :   set no initial sea level anomaly
+      !!  
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   ptmask  !
+      REAL(wp), DIMENSION(jpi,jpj)         , INTENT(  out) ::   pssh    !
+      !
+      !!----------------------------------------------------------------------
+      !
+      pssh(:,:) = 0._wp
+      !
+   END SUBROUTINE usr_def_istate_ssh
+
    !!======================================================================
 END MODULE usrdef_istate
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/DOME/cpp_DOME.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif
+ bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif key_linssh
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICB/cpp_ICB.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi 
+ bld::tool::fppkeys   key_iomput key_mpp_mpi key_qco 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV1D/cpp_ICE_ADV1D.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_si3 key_mpp_mpi key_nosignedzero key_iomput
+bld::tool::fppkeys key_si3 key_mpp_mpi key_nosignedzero key_iomput key_linssh
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_ADV2D/cpp_ICE_ADV2D.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_si3 key_mpp_mpi key_nosignedzero key_iomput
+bld::tool::fppkeys key_si3 key_linssh key_mpp_mpi key_nosignedzero key_iomput
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_AGRIF/cpp_ICE_AGRIF.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_agrif key_si3 key_mpp_mpi key_iomput
+bld::tool::fppkeys key_agrif key_si3 key_linssh key_mpp_mpi key_iomput
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/MY_SRC/icedyn_rhg_eap.F90	(revision 14200)
@@ -6,7 +6,7 @@
    !! History :   -   !  2007-03  (M.A. Morales Maqueda, S. Bouillon) Original code
    !!            3.0  !  2008-03  (M. Vancoppenolle) adaptation to new model
-   !!             -   !  2008-11  (M. Vancoppenolle, S. Bouillon, Y. Aksenov) add surface tilt in ice rheolohy 
+   !!             -   !  2008-11  (M. Vancoppenolle, S. Bouillon, Y. Aksenov) add surface tilt in ice rheolohy
    !!            3.3  !  2009-05  (G.Garric)    addition of the evp case
-   !!            3.4  !  2011-01  (A. Porter)   dynamical allocation 
+   !!            3.4  !  2011-01  (A. Porter)   dynamical allocation
    !!            3.5  !  2012-08  (R. Benshila) AGRIF
    !!            3.6  !  2016-06  (C. Rousset)  Rewriting + landfast ice + mEVP (Bouillon 2013)
@@ -14,5 +14,5 @@
    !!            4.0  !  2018     (many people) SI3 [aka Sea Ice cube]
    !!                 !  2019     (S. Rynders, Y. Aksenov, C. Rousset)  change into eap rheology from
-   !!                                           CICE code (Tsamados, Heorton) 
+   !!                                           CICE code (Tsamados, Heorton)
    !!----------------------------------------------------------------------
 #if defined key_si3
@@ -30,6 +30,6 @@
    USE icevar         ! ice_var_sshdyn
    USE icedyn_rdgrft  ! sea-ice: ice strength
-   USE bdy_oce , ONLY : ln_bdy 
-   USE bdyice 
+   USE bdy_oce , ONLY : ln_bdy
+   USE bdyice
 #if defined key_agrif
    USE agrif_ice_interp
@@ -66,5 +66,6 @@
    INTEGER ::   ncvgid   ! netcdf file id
    INTEGER ::   nvarid   ! netcdf variable id
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zmsk00, zmsk15
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   aimsk00
+   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   eap_res  , aimsk15
    !!----------------------------------------------------------------------
    !! NEMO/ICE 4.0 , NEMO Consortium (2018)
@@ -80,7 +81,7 @@
       !!
       !! ** purpose : determines sea ice drift from wind stress, ice-ocean
-      !!  stress and sea-surface slope. Ice-ice interaction is described by 
-      !!  a non-linear elasto-anisotropic-plastic (EAP) law including shear 
-      !!  strength and a bulk rheology .	
+      !!  stress and sea-surface slope. Ice-ice interaction is described by
+      !!  a non-linear elasto-anisotropic-plastic (EAP) law including shear
+      !!  strength and a bulk rheology .
       !!
       !!  The points in the C-grid look like this, dear reader
@@ -90,9 +91,9 @@
       !!                                 |
       !!                      (ji-1,jj)  |  (ji,jj)
-      !!                             ---------   
+      !!                             ---------
       !!                            |         |
       !!                            | (ji,jj) |------(ji,jj)
       !!                            |         |
-      !!                             ---------   
+      !!                             ---------
       !!                     (ji-1,jj-1)     (ji,jj-1)
       !!
@@ -101,5 +102,5 @@
       !!                snow total volume (vt_s) per unit area
       !!
-      !! ** Action  : - compute u_ice, v_ice : the components of the 
+      !! ** Action  : - compute u_ice, v_ice : the components of the
       !!                sea-ice velocity vector
       !!              - compute delta_i, shear_i, divu_i, which are inputs
@@ -107,5 +108,5 @@
       !!
       !! ** Steps   : 0) compute mask at F point
-      !!              1) Compute ice snow mass, ice strength 
+      !!              1) Compute ice snow mass, ice strength
       !!              2) Compute wind, oceanic stresses, mass terms and
       !!                 coriolis terms of the momentum equation
@@ -166,5 +167,5 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zmU_t, zmV_t                    ! (ice-snow_mass / dt) on U/V points
       REAL(wp), DIMENSION(jpi,jpj) ::   zmf                             ! coriolis parameter at T points
-      REAL(wp), DIMENSION(jpi,jpj) ::   v_oceU, u_oceV, v_iceU, u_iceV  ! ocean/ice u/v component on V/U points                           
+      REAL(wp), DIMENSION(jpi,jpj) ::   v_oceU, u_oceV, v_iceU, u_iceV  ! ocean/ice u/v component on V/U points
       !
       REAL(wp), DIMENSION(jpi,jpj) ::   zds                             ! shear
@@ -172,5 +173,5 @@
       REAL(wp), DIMENSION(jpi,jpj) ::   zsshdyn                         ! array used for the calculation of ice surface slope:
       !                                                                 !    ocean surface (ssh_m) if ice is not embedded
-      !                                                                 !    ice bottom surface if ice is embedded   
+      !                                                                 !    ice bottom surface if ice is embedded
       REAL(wp), DIMENSION(jpi,jpj) ::   zfU  , zfV                      ! internal stresses
       REAL(wp), DIMENSION(jpi,jpj) ::   zspgU, zspgV                    ! surface pressure gradient at U/V points
@@ -192,5 +193,5 @@
       !! --- diags
       REAL(wp) ::   zsig1, zsig2, zsig12, zfac, z1_strength
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zsig_I, zsig_II, zsig1_p, zsig2_p         
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zsig_I, zsig_II, zsig1_p, zsig2_p
       !! --- SIMIP diags
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_xmtrp_ice ! X-component of ice mass transport (kg/s)
@@ -199,15 +200,25 @@
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_ymtrp_snw ! Y-component of snow mass transport (kg/s)
       REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_xatrp     ! X-component of area transport (m2/s)
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_yatrp     ! Y-component of area transport (m2/s)      
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   zdiag_yatrp     ! Y-component of area transport (m2/s)
       !!-------------------------------------------------------------------
 
       IF( kt == nit000 .AND. lwp )   WRITE(numout,*) '-- ice_dyn_rhg_eap: EAP sea-ice rheology'
       !
-      ! for diagnostics and convergence tests
-      ALLOCATE( zmsk00(jpi,jpj), zmsk15(jpi,jpj) )
+      IF( kt == nit000 )  THEN 
+         !
+         ! for diagnostics 
+         ALLOCATE( aimsk00(jpi,jpj) )
+         ! for convergence tests
+         IF( nn_rhg_chkcvg > 0 ) ALLOCATE( eap_res(jpi,jpj), aimsk15(jpi,jpj) )
+      ENDIF
+      !
       DO_2D( 1, 1, 1, 1 )
-         zmsk00(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06  ) ) ! 1 if ice    , 0 if no ice
-         zmsk15(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - 0.15_wp ) ) ! 1 if 15% ice, 0 if less
+         aimsk00(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - epsi06  ) ) ! 1 if ice    , 0 if no ice
       END_2D
+      IF( nn_rhg_chkcvg > 0 ) THEN
+         DO_2D( 1, 1, 1, 1 )
+            aimsk15(ji,jj) = MAX( 0._wp , SIGN( 1._wp , at_i(ji,jj) - 0.15_wp ) ) ! 1 if 15% ice, 0 if less
+         END_2D
+      ENDIF
       !
 !!gm for Clem:  OPTIMIZATION:  I think zfmask can be computed one for all at the initialization....
@@ -249,5 +260,5 @@
       ! 1) define some variables and initialize arrays
       !------------------------------------------------------------------------------!
-      zrhoco = rho0 * rn_cio 
+      zrhoco = rho0 * rn_cio
 !extra code for test case boundary conditions
       zinvw=1._wp/(zrhoco*0.5_wp)
@@ -270,7 +281,7 @@
       ENDIF
       z1_dtevp = 1._wp / zdtevp
-         
-      ! Initialise stress tensor 
-      zs1 (:,:) = pstress1_i (:,:) 
+
+      ! Initialise stress tensor
+      zs1 (:,:) = pstress1_i (:,:)
       zs2 (:,:) = pstress2_i (:,:)
       zs12(:,:) = pstress12_i(:,:)
@@ -319,9 +330,9 @@
          ! dt/m at T points (for alpha and beta coefficients)
          zdt_m(ji,jj)    = zdtevp / MAX( zm1, zmmin )
-         
+
          ! m/dt
          zmU_t(ji,jj)    = zmassU * z1_dtevp
          zmV_t(ji,jj)    = zmassV * z1_dtevp
-         
+
          ! Drag ice-atm.
          ztaux_ai(ji,jj) = zaU(ji,jj) * utau_ice(ji,jj)
@@ -353,11 +364,11 @@
             zvV = 0.5_wp * ( vt_i(ji,jj) * e1e2t(ji,jj) + vt_i(ji,jj+1) * e1e2t(ji,jj+1) ) * r1_e1e2v(ji,jj) * vmask(ji,jj,1)
             ! ice-bottom stress at U points
-            zvCr = zaU(ji,jj) * rn_lf_depfra * hu(ji,jj,Kmm)
+            zvCr = zaU(ji,jj) * rn_lf_depfra * hu(ji,jj,Kmm) * ( 1._wp - icb_mask(ji,jj) ) ! if grounded icebergs are read: ocean depth = 0
             ztaux_base(ji,jj) = - rn_lf_bfr * MAX( 0._wp, zvU - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaU(ji,jj) ) )
             ! ice-bottom stress at V points
-            zvCr = zaV(ji,jj) * rn_lf_depfra * hv(ji,jj,Kmm)
+            zvCr = zaV(ji,jj) * rn_lf_depfra * hv(ji,jj,Kmm) * ( 1._wp - icb_mask(ji,jj) ) ! if grounded icebergs are read: ocean depth = 0
             ztauy_base(ji,jj) = - rn_lf_bfr * MAX( 0._wp, zvV - zvCr ) * EXP( -rn_crhg * ( 1._wp - zaV(ji,jj) ) )
             ! ice_bottom stress at T points
-            zvCr = at_i(ji,jj) * rn_lf_depfra * ht(ji,jj)
+            zvCr = at_i(ji,jj) * rn_lf_depfra * ht(ji,jj) * ( 1._wp - icb_mask(ji,jj) )    ! if grounded icebergs are read: ocean depth = 0
             tau_icebfr(ji,jj) = - rn_lf_bfr * MAX( 0._wp, vt_i(ji,jj) - zvCr ) * EXP( -rn_crhg * ( 1._wp - at_i(ji,jj) ) )
          END_2D
@@ -377,5 +388,5 @@
       !                                               ! ==================== !
       DO jter = 1 , nn_nevp                           !    loop over jter    !
-         !                                            ! ==================== !        
+         !                                            ! ==================== !
          l_full_nf_update = jter == nn_nevp   ! false: disable full North fold update (performances) for iter = 1 to nn_nevp-1
          !
@@ -404,5 +415,5 @@
                &   + zds(ji,jj-1) * zds(ji,jj-1) * e1e2f(ji,jj-1) + zds(ji-1,jj-1) * zds(ji-1,jj-1) * e1e2f(ji-1,jj-1)  &
                &   ) * 0.25_wp * r1_e1e2t(ji,jj)
-           
+
             ! divergence at T points
             zdiv  = ( e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj) * u_ice(ji-1,jj)   &
@@ -410,5 +421,5 @@
                &    ) * r1_e1e2t(ji,jj)
             zdiv2 = zdiv * zdiv
-            
+
             ! tension at T points
             zdt  = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
@@ -418,9 +429,9 @@
 
             ! delta at T points
-            zdelta(ji,jj) = SQRT( zdiv2 + ( zdt2 + zds2 ) * z1_ecc2 )  
+            zdelta(ji,jj) = SQRT( zdiv2 + ( zdt2 + zds2 ) * z1_ecc2 )
 
          END_2D
          CALL lbc_lnk( 'icedyn_rhg_eap', zdelta, 'T', 1.0_wp )
-               
+
          ! P/delta at T points
          DO_2D( 1, 1, 1, 1 )
@@ -430,14 +441,14 @@
          DO_2D( 0, 1, 0, 1 )   ! loop ends at jpi,jpj so that no lbc_lnk are needed for zs1 and zs2
 
-             ! shear at T points 
+             ! shear at T points
             zdsT = ( zds(ji,jj  ) * e1e2f(ji,jj  ) + zds(ji-1,jj  ) * e1e2f(ji-1,jj  )  &
                &   + zds(ji,jj-1) * e1e2f(ji,jj-1) + zds(ji-1,jj-1) * e1e2f(ji-1,jj-1)  &
                &   ) * 0.25_wp * r1_e1e2t(ji,jj)
-            
+
            ! divergence at T points (duplication to avoid communications)
             zdiv  = ( e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj) * u_ice(ji-1,jj)   &
                &    + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji,jj-1) * v_ice(ji,jj-1)   &
                &    ) * r1_e1e2t(ji,jj)
-            
+
             ! tension at T points (duplication to avoid communications)
             zdt  = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
@@ -459,5 +470,5 @@
                zyield22(ji,jj) = 0.5_wp * (zstressptmp - zstressmtmp)
                zyield12(ji,jj) = zstress12tmp(ji,jj)
-               prdg_conv(ji,jj) = -min( zalphar, 0._wp)    
+               prdg_conv(ji,jj) = -min( zalphar, 0._wp)
             ENDIF
 
@@ -491,5 +502,5 @@
 
          DO_2D( 1, 0, 1, 0 )
-            ! stress12tmp at F points 
+            ! stress12tmp at F points
             zstress12tmpF = ( zstress12tmp(ji,jj+1) * e1e2t(ji,jj+1) + zstress12tmp(ji+1,jj+1) * e1e2t(ji+1,jj+1)  &
                &            + zstress12tmp(ji,jj  ) * e1e2t(ji,jj  ) + zstress12tmp(ji+1,jj  ) * e1e2t(ji+1,jj  )  &
@@ -504,5 +515,5 @@
                ! zalph2 = zalph2 - 1._wp
             ENDIF
-            
+
             ! stress at F points (zkt/=0 if landfast)
             zs12(ji,jj) = ( zs12(ji,jj) * zalph1 + zstress12tmpF ) * z1_alph1
@@ -570,5 +581,5 @@
                      &                                    + zRHS + zTauO * v_ice(ji,jj)                                       & ! F + tau_ia + Coriolis + spg + tau_io(only ocean part)
                      &                                    ) / MAX( zepsi, zmV_t(ji,jj) * ( zbetav + 1._wp ) + zTauO - zTauB ) & ! m/dt + tau_io(only ice part) + landfast
-                     &            + ( 1._wp - rswitch ) * (  v_ice_b(ji,jj)                                                   & 
+                     &            + ( 1._wp - rswitch ) * (  v_ice_b(ji,jj)                                                   &
                      &                                     + v_ice  (ji,jj) * MAX( 0._wp, zbetav - zdtevp * rn_lf_relax )     & ! static friction => slow decrease to v=0
                      &                                    ) / ( zbetav + 1._wp )                                              &
@@ -630,5 +641,5 @@
                      &                                     + u_ice  (ji,jj) * MAX( 0._wp, zbetau - zdtevp * rn_lf_relax )     & ! static friction => slow decrease to v=0
                      &                                    ) / ( zbetau + 1._wp )                                              &
-                     &             ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                   & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
+                     &             ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                   & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
                      &           )   * zmsk00x(ji,jj)
                ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
@@ -637,5 +648,5 @@
                      &                                    ) / MAX( zepsi, zmU_t(ji,jj) + zTauO - zTauB )                      & ! m/dt + tau_io(only ice part) + landfast
                      &            + ( 1._wp - rswitch ) *   u_ice(ji,jj) * MAX( 0._wp, 1._wp - zdtevp * rn_lf_relax )         & ! static friction => slow decrease to v=0
-                     &              ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                  & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
+                     &              ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                  & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
                      &            )   * zmsk00x(ji,jj)
                ENDIF
@@ -689,5 +700,5 @@
                      &                                     + u_ice  (ji,jj) * MAX( 0._wp, zbetau - zdtevp * rn_lf_relax )     & ! static friction => slow decrease to v=0
                      &                                    ) / ( zbetau + 1._wp )                                              &
-                     &             ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                   & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin 
+                     &             ) * zmsk01x(ji,jj) + u_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01x(ji,jj) )                   & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
                      &           )   * zmsk00x(ji,jj)
                ELSE               !--- ice velocity using EVP implicit formulation (cf Madec doc & Bouillon 2009)
@@ -744,5 +755,5 @@
                      &            + ( 1._wp - rswitch ) * (  v_ice_b(ji,jj)                                                   &
                      &                                     + v_ice  (ji,jj) * MAX( 0._wp, zbetav - zdtevp * rn_lf_relax )     & ! static friction => slow decrease to v=0
-                     &                                    ) / ( zbetav + 1._wp )                                              & 
+                     &                                    ) / ( zbetav + 1._wp )                                              &
                      &             ) * zmsk01y(ji,jj) + v_oce(ji,jj) * 0.01_wp * ( 1._wp - zmsk01y(ji,jj) )                   & ! v_ice = v_oce/100 if mass < zmmin & conc < zamin
                      &           )   * zmsk00y(ji,jj)
@@ -771,5 +782,5 @@
 
          ! convergence test
-         IF( nn_rhg_chkcvg == 2 )   CALL rhg_cvg( kt, jter, nn_nevp, u_ice, v_ice, zu_ice, zv_ice )
+         IF( nn_rhg_chkcvg == 2 )   CALL rhg_cvg_eap( kt, jter, nn_nevp, u_ice, v_ice, zu_ice, zv_ice )
          !
          !                                                ! ==================== !
@@ -781,5 +792,5 @@
       !
       !------------------------------------------------------------------------------!
-      ! 4) Recompute delta, shear and div (inputs for mechanical redistribution) 
+      ! 4) Recompute delta, shear and div (inputs for mechanical redistribution)
       !------------------------------------------------------------------------------!
       DO_2D( 1, 0, 1, 0 )
@@ -791,7 +802,7 @@
 
       END_2D
-      
+
       DO_2D( 0, 0, 0, 0 )
-         
+
          ! tension**2 at T points
          zdt  = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
@@ -799,5 +810,5 @@
             &   ) * r1_e1e2t(ji,jj)
          zdt2 = zdt * zdt
-         
+
          zten_i(ji,jj) = zdt
 
@@ -806,5 +817,5 @@
             &   + zds(ji,jj-1) * zds(ji,jj-1) * e1e2f(ji,jj-1) + zds(ji-1,jj-1) * zds(ji-1,jj-1) * e1e2f(ji-1,jj-1)  &
             &   ) * 0.25_wp * r1_e1e2t(ji,jj)
-         
+
          ! shear at T points
          pshear_i(ji,jj) = SQRT( zdt2 + zds2 )
@@ -814,7 +825,7 @@
             &             + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji,jj-1) * v_ice(ji,jj-1)   &
             &             ) * r1_e1e2t(ji,jj)
-         
+
          ! delta at T points
-         zfac            = SQRT( pdivu_i(ji,jj) * pdivu_i(ji,jj) + ( zdt2 + zds2 ) * z1_ecc2 ) ! delta  
+         zfac            = SQRT( pdivu_i(ji,jj) * pdivu_i(ji,jj) + ( zdt2 + zds2 ) * z1_ecc2 ) ! delta
          rswitch         = 1._wp - MAX( 0._wp, SIGN( 1._wp, -zfac ) ) ! 0 if delta=0
          pdelta_i(ji,jj) = zfac + rn_creepl * rswitch ! delta+creepl
@@ -824,5 +835,5 @@
          &                                    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 --- !
       pstress1_i (:,:) = zs1 (:,:)
@@ -841,17 +852,17 @@
             &                                  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 )
-         CALL iom_put( 'vtau_oi' , ztauy_oi * zmsk00 )
-         CALL iom_put( 'utau_ai' , ztaux_ai * zmsk00 )
-         CALL iom_put( 'vtau_ai' , ztauy_ai * zmsk00 )
-         CALL iom_put( 'utau_bi' , ztaux_bi * zmsk00 )
-         CALL iom_put( 'vtau_bi' , ztauy_bi * zmsk00 )
-      ENDIF
-       
+         CALL iom_put( 'utau_oi' , ztaux_oi * aimsk00 )
+         CALL iom_put( 'vtau_oi' , ztauy_oi * aimsk00 )
+         CALL iom_put( 'utau_ai' , ztaux_ai * aimsk00 )
+         CALL iom_put( 'vtau_ai' , ztauy_ai * aimsk00 )
+         CALL iom_put( 'utau_bi' , ztaux_bi * aimsk00 )
+         CALL iom_put( 'vtau_bi' , ztauy_bi * aimsk00 )
+      ENDIF
+
       ! --- divergence, shear and strength --- !
-      IF( iom_use('icediv') )   CALL iom_put( 'icediv' , pdivu_i  * zmsk00 )   ! divergence
-      IF( iom_use('iceshe') )   CALL iom_put( 'iceshe' , pshear_i * zmsk00 )   ! shear
-      IF( iom_use('icedlt') )   CALL iom_put( 'icedlt' , pdelta_i * zmsk00 )   ! delta
-      IF( iom_use('icestr') )   CALL iom_put( 'icestr' , strength * zmsk00 )   ! strength
+      IF( iom_use('icediv') )   CALL iom_put( 'icediv' , pdivu_i  * aimsk00 )   ! divergence
+      IF( iom_use('iceshe') )   CALL iom_put( 'iceshe' , pshear_i * aimsk00 )   ! shear
+      IF( iom_use('icedlt') )   CALL iom_put( 'icedlt' , pdelta_i * aimsk00 )   ! delta
+      IF( iom_use('icestr') )   CALL iom_put( 'icestr' , strength * aimsk00 )   ! strength
 
       ! --- Stress tensor invariants (SIMIP diags) --- !
@@ -859,28 +870,28 @@
          !
          ALLOCATE( zsig_I(jpi,jpj) , zsig_II(jpi,jpj) )
-         !         
+         !
          DO_2D( 1, 1, 1, 1 )
-         
+
             ! Ice stresses
             ! sigma1, sigma2, sigma12 are some useful recombination of the stresses (Hunke and Dukowicz MWR 2002, Bouillon et al., OM2013)
             ! These are NOT stress tensor components, neither stress invariants, neither stress principal components
             ! I know, this can be confusing...
-            zfac             =   strength(ji,jj) / ( pdelta_i(ji,jj) + rn_creepl ) 
+            zfac             =   strength(ji,jj) / ( pdelta_i(ji,jj) + rn_creepl )
             zsig1            =   zfac * ( pdivu_i(ji,jj) - pdelta_i(ji,jj) )
             zsig2            =   zfac * z1_ecc2 * zten_i(ji,jj)
             zsig12           =   zfac * z1_ecc2 * pshear_i(ji,jj)
-            
+
             ! Stress invariants (sigma_I, sigma_II, Coon 1974, Feltham 2008)
             zsig_I (ji,jj)   =   zsig1 * 0.5_wp                                           ! 1st stress invariant, aka average normal stress, aka negative pressure
             zsig_II(ji,jj)   =   SQRT ( MAX( 0._wp, zsig2 * zsig2 * 0.25_wp + zsig12 ) )  ! 2nd  ''       '', aka maximum shear stress
-            
+
          END_2D
          !
          ! Stress tensor invariants (normal and shear stress N/m) - SIMIP diags - definitions following Coon (1974) and Feltham (2008)
-         IF( iom_use('normstr') )   CALL iom_put( 'normstr', zsig_I (:,:) * zmsk00(:,:) ) ! Normal stress
-         IF( iom_use('sheastr') )   CALL iom_put( 'sheastr', zsig_II(:,:) * zmsk00(:,:) ) ! Maximum shear stress
-         
+         IF( iom_use('normstr') )   CALL iom_put( 'normstr', zsig_I (:,:) * aimsk00(:,:) ) ! Normal stress
+         IF( iom_use('sheastr') )   CALL iom_put( 'sheastr', zsig_II(:,:) * aimsk00(:,:) ) ! Maximum shear stress
+
          DEALLOCATE ( zsig_I, zsig_II )
-         
+
       ENDIF
 
@@ -891,9 +902,9 @@
       IF( iom_use('sig1_pnorm') .OR. iom_use('sig2_pnorm') ) THEN
          !
-         ALLOCATE( zsig1_p(jpi,jpj) , zsig2_p(jpi,jpj) , zsig_I(jpi,jpj) , zsig_II(jpi,jpj) )         
-         !         
+         ALLOCATE( zsig1_p(jpi,jpj) , zsig2_p(jpi,jpj) , zsig_I(jpi,jpj) , zsig_II(jpi,jpj) )
+         !
          DO_2D( 1, 1, 1, 1 )
-         
-            ! Ice stresses computed with **viscosities** (delta, p/delta) at **previous** iterates 
+
+            ! Ice stresses computed with **viscosities** (delta, p/delta) at **previous** iterates
             !                        and **deformations** at current iterates
             !                        following Lemieux & Dupont (2020)
@@ -902,9 +913,9 @@
             zsig2            =   zfac * z1_ecc2 * zten_i(ji,jj)
             zsig12           =   zfac * z1_ecc2 * pshear_i(ji,jj)
-            
+
             ! Stress invariants (sigma_I, sigma_II, Coon 1974, Feltham 2008), T-point
             zsig_I(ji,jj)    =   zsig1 * 0.5_wp                                           ! 1st stress invariant, aka average normal stress, aka negative pressure
             zsig_II(ji,jj)   =   SQRT ( MAX( 0._wp, zsig2 * zsig2 * 0.25_wp + zsig12 ) )  ! 2nd  ''       '', aka maximum shear stress
-   
+
             ! Normalized  principal stresses (used to display the ellipse)
             z1_strength      =   1._wp / MAX( 1._wp, strength(ji,jj) )
@@ -913,9 +924,9 @@
          END_2D
          !
-         CALL iom_put( 'sig1_pnorm' , zsig1_p ) 
-         CALL iom_put( 'sig2_pnorm' , zsig2_p ) 
-      
+         CALL iom_put( 'sig1_pnorm' , zsig1_p )
+         CALL iom_put( 'sig2_pnorm' , zsig2_p )
+
          DEALLOCATE( zsig1_p , zsig2_p , zsig_I, zsig_II )
-         
+
       ENDIF
 
@@ -925,15 +936,15 @@
          CALL lbc_lnk_multi( 'icedyn_rhg_eap', zyield11, 'T', 1.0_wp, zyield22, 'T', 1.0_wp, zyield12, 'T', 1.0_wp )
 
-         CALL iom_put( 'yield11', zyield11 * zmsk00 )
-         CALL iom_put( 'yield22', zyield22 * zmsk00 )
-         CALL iom_put( 'yield12', zyield12 * zmsk00 )
+         CALL iom_put( 'yield11', zyield11 * aimsk00 )
+         CALL iom_put( 'yield22', zyield22 * aimsk00 )
+         CALL iom_put( 'yield12', zyield12 * aimsk00 )
       ENDIF
 
       ! --- anisotropy tensor --- !
-      IF( iom_use('aniso') ) THEN       
-         CALL lbc_lnk( 'icedyn_rhg_eap', paniso_11, 'T', 1.0_wp ) 
-         CALL iom_put( 'aniso' , paniso_11 * zmsk00 )
-      ENDIF
-      
+      IF( iom_use('aniso') ) THEN
+         CALL lbc_lnk( 'icedyn_rhg_eap', paniso_11, 'T', 1.0_wp )
+         CALL iom_put( 'aniso' , paniso_11 * aimsk00 )
+      ENDIF
+
       ! --- SIMIP --- !
       IF(  iom_use('dssh_dx') .OR. iom_use('dssh_dy') .OR. &
@@ -944,10 +955,10 @@
             &                                    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)
-         CALL iom_put( 'dssh_dy' , zspgV * zmsk00 )   ! Sea-surface tilt term in force balance (y)
-         CALL iom_put( 'corstrx' , zCorU * zmsk00 )   ! Coriolis force term in force balance (x)
-         CALL iom_put( 'corstry' , zCorV * zmsk00 )   ! Coriolis force term in force balance (y)
-         CALL iom_put( 'intstrx' , zfU   * zmsk00 )   ! Internal force term in force balance (x)
-         CALL iom_put( 'intstry' , zfV   * zmsk00 )   ! Internal force term in force balance (y)
+         CALL iom_put( 'dssh_dx' , zspgU * aimsk00 )   ! Sea-surface tilt term in force balance (x)
+         CALL iom_put( 'dssh_dy' , zspgV * aimsk00 )   ! Sea-surface tilt term in force balance (y)
+         CALL iom_put( 'corstrx' , zCorU * aimsk00 )   ! Coriolis force term in force balance (x)
+         CALL iom_put( 'corstry' , zCorV * aimsk00 )   ! Coriolis force term in force balance (y)
+         CALL iom_put( 'intstrx' , zfU   * aimsk00 )   ! Internal force term in force balance (x)
+         CALL iom_put( 'intstry' , zfV   * aimsk00 )   ! Internal force term in force balance (y)
       ENDIF
 
@@ -960,6 +971,6 @@
          DO_2D( 0, 0, 0, 0 )
             ! 2D ice mass, snow mass, area transport arrays (X, Y)
-            zfac_x = 0.5 * u_ice(ji,jj) * e2u(ji,jj) * zmsk00(ji,jj)
-            zfac_y = 0.5 * v_ice(ji,jj) * e1v(ji,jj) * zmsk00(ji,jj)
+            zfac_x = 0.5 * u_ice(ji,jj) * e2u(ji,jj) * aimsk00(ji,jj)
+            zfac_y = 0.5 * v_ice(ji,jj) * e1v(ji,jj) * aimsk00(ji,jj)
 
             zdiag_xmtrp_ice(ji,jj) = rhoi * zfac_x * ( vt_i(ji+1,jj) + vt_i(ji,jj) ) ! ice mass transport, X-component
@@ -979,5 +990,5 @@
 
          CALL iom_put( 'xmtrpice' , zdiag_xmtrp_ice )   ! X-component of sea-ice mass transport (kg/s)
-         CALL iom_put( 'ymtrpice' , zdiag_ymtrp_ice )   ! Y-component of sea-ice mass transport 
+         CALL iom_put( 'ymtrpice' , zdiag_ymtrp_ice )   ! Y-component of sea-ice mass transport
          CALL iom_put( 'xmtrpsnw' , zdiag_xmtrp_snw )   ! X-component of snow mass transport (kg/s)
          CALL iom_put( 'ymtrpsnw' , zdiag_ymtrp_snw )   ! Y-component of snow mass transport
@@ -995,21 +1006,19 @@
             IF( ln_aEVP ) THEN   ! output: beta * ( u(t=nn_nevp) - u(t=nn_nevp-1) )
                CALL iom_put( 'uice_cvg', MAX( ABS( u_ice(:,:) - zu_ice(:,:) ) * zbeta(:,:) * umask(:,:,1) , &
-                  &                           ABS( v_ice(:,:) - zv_ice(:,:) ) * zbeta(:,:) * vmask(:,:,1) ) * zmsk15(:,:) )
+                  &                           ABS( v_ice(:,:) - zv_ice(:,:) ) * zbeta(:,:) * vmask(:,:,1) ) * aimsk15(:,:) )
             ELSE                 ! output: nn_nevp * ( u(t=nn_nevp) - u(t=nn_nevp-1) )
                CALL iom_put( 'uice_cvg', REAL( nn_nevp ) * MAX( ABS( u_ice(:,:) - zu_ice(:,:) ) * umask(:,:,1) , &
-                  &                                             ABS( v_ice(:,:) - zv_ice(:,:) ) * vmask(:,:,1) ) * zmsk15(:,:) )
+                  &                                             ABS( v_ice(:,:) - zv_ice(:,:) ) * vmask(:,:,1) ) * aimsk15(:,:) )
             ENDIF
          ENDIF
-      ENDIF      
-      !
-      DEALLOCATE( zmsk00, zmsk15 )
+      ENDIF
       !
    END SUBROUTINE ice_dyn_rhg_eap
 
-   
-   SUBROUTINE rhg_cvg( kt, kiter, kitermax, pu, pv, pub, pvb )
+
+   SUBROUTINE rhg_cvg_eap( kt, kiter, kitermax, pu, pv, pub, pvb )
       !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE rhg_cvg  ***
-      !!                     
+      !!                    ***  ROUTINE rhg_cvg_eap  ***
+      !!
       !! ** Purpose :   check convergence of oce rheology
       !!
@@ -1019,5 +1028,5 @@
       !!                This routine is called every sub-iteration, so it is cpu expensive
       !!
-      !! ** Note    :   for the first sub-iteration, uice_cvg is set to 0 (too large otherwise)   
+      !! ** Note    :   for the first sub-iteration, uice_cvg is set to 0 (too large otherwise)
       !!----------------------------------------------------------------------
       INTEGER ,                 INTENT(in) ::   kt, kiter, kitermax       ! ocean time-step index
@@ -1026,7 +1035,6 @@
       INTEGER           ::   it, idtime, istatus
       INTEGER           ::   ji, jj          ! dummy loop indices
-      REAL(wp)          ::   zresm           ! local real 
+      REAL(wp)          ::   zresm           ! local real
       CHARACTER(len=20) ::   clname
-      REAL(wp), DIMENSION(jpi,jpj) ::   zres           ! check convergence
       !!----------------------------------------------------------------------
 
@@ -1036,5 +1044,5 @@
          IF( lwp ) THEN
             WRITE(numout,*)
-            WRITE(numout,*) 'rhg_cvg : ice rheology convergence control'
+            WRITE(numout,*) 'rhg_cvg_eap : ice rheology convergence control'
             WRITE(numout,*) '~~~~~~~'
          ENDIF
@@ -1053,5 +1061,5 @@
       ! time
       it = ( kt - 1 ) * kitermax + kiter
-      
+
       ! convergence
       IF( kiter == 1 ) THEN ! remove the first iteration for calculations of convergence (always very large)
@@ -1059,13 +1067,13 @@
       ELSE
          DO_2D( 1, 1, 1, 1 )
-            zres(ji,jj) = MAX( ABS( pu(ji,jj) - pub(ji,jj) ) * umask(ji,jj,1), &
-               &               ABS( pv(ji,jj) - pvb(ji,jj) ) * vmask(ji,jj,1) ) * zmsk15(ji,jj)
+            eap_res(ji,jj) = MAX( ABS( pu(ji,jj) - pub(ji,jj) ) * umask(ji,jj,1), &
+               &               ABS( pv(ji,jj) - pvb(ji,jj) ) * vmask(ji,jj,1) ) * aimsk15(ji,jj)
+            ! cut of the boundary of the box (forced velocities)
+            IF (mjg(jj)<=30 .or. mjg(jj)>970 .or. mig(ji)<=30 .or. mig(ji)>970) THEN
+               eap_res(ji,jj) = 0._wp
+            END IF
          END_2D
 
-         ! cut of the boundary of the box (forced velocities)
-         IF (mjg(jj)<=30 .or. mjg(jj)>970 .or. mig(ji)<=30 .or. mig(ji)>970) THEN
-            zres(ji,jj) = 0._wp
-         END IF
-         zresm = MAXVAL( zres )
+         zresm = MAXVAL( eap_res )
          CALL mpp_max( 'icedyn_rhg_evp', zresm )   ! max over the global domain
       ENDIF
@@ -1077,6 +1085,6 @@
          IF( kt == nitend )   istatus = NF90_CLOSE(ncvgid)
       ENDIF
-      
-   END SUBROUTINE rhg_cvg
+
+   END SUBROUTINE rhg_cvg_eap
 
 
@@ -1085,5 +1093,5 @@
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE update_stress_rdg  ***
-      !!                     
+      !!
       !! ** Purpose :   Updates the stress depending on values of strain rate and structure
       !!                tensor and for the last subcycle step it computes closing and sliding rate
@@ -1098,30 +1106,28 @@
       INTEGER  ::   kx ,ky, ka
 
-      REAL(wp) ::   zstemp11r, zstemp12r, zstemp22r   
-      REAL(wp) ::   zstemp11s, zstemp12s, zstemp22s 
-      REAL(wp) ::   za22, zQd11Qd11, zQd11Qd12, zQd12Qd12 
-      REAL(wp) ::   zQ11Q11, zQ11Q12, zQ12Q12 
-      REAL(wp) ::   zdtemp11, zdtemp12, zdtemp22 
-      REAL(wp) ::   zrotstemp11r, zrotstemp12r, zrotstemp22r   
+      REAL(wp) ::   zstemp11r, zstemp12r, zstemp22r
+      REAL(wp) ::   zstemp11s, zstemp12s, zstemp22s
+      REAL(wp) ::   za22, zQd11Qd11, zQd11Qd12, zQd12Qd12
+      REAL(wp) ::   zQ11Q11, zQ11Q12, zQ12Q12
+      REAL(wp) ::   zdtemp11, zdtemp12, zdtemp22
+      REAL(wp) ::   zrotstemp11r, zrotstemp12r, zrotstemp22r
       REAL(wp) ::   zrotstemp11s, zrotstemp12s, zrotstemp22s
-      REAL(wp) ::   zsig11, zsig12, zsig22 
-      REAL(wp) ::   zsgprm11, zsgprm12, zsgprm22 
-      REAL(wp) ::   zinvstressconviso 
-      REAL(wp) ::   zAngle_denom_gamma,  zAngle_denom_alpha 
-      REAL(wp) ::   zTany_1, zTany_2 
-      REAL(wp) ::   zx, zy, zdx, zdy, zda, zkxw, kyw, kaw
-      REAL(wp) ::   zinvdx, zinvdy, zinvda   
-      REAL(wp) ::   zdtemp1, zdtemp2, zatempprime, zinvsin
-
-      REAL(wp), PARAMETER ::   kfriction = 0.45_wp
-      !!---------------------------------------------------------------------
+      REAL(wp) ::   zsig11, zsig12, zsig22
+      REAL(wp) ::   zsgprm11, zsgprm12, zsgprm22
+      REAL(wp) ::   zAngle_denom_gamma,  zAngle_denom_alpha
+      REAL(wp) ::   zTany_1, zTany_2
+      REAL(wp) ::   zx, zy, zkxw, kyw, kaw
+      REAL(wp) ::   zinvdx, zinvdy, zinvda
+      REAL(wp) ::   zdtemp1, zdtemp2, zatempprime
+
+      REAL(wp), PARAMETER ::   ppkfriction = 0.45_wp
       ! Factor to maintain the same stress as in EVP (see Section 3)
       ! Can be set to 1 otherwise
-!      zinvstressconviso = 1._wp/(1._wp+kfriction*kfriction)
-      zinvstressconviso = 1._wp
- 
-      zinvsin = 1._wp/sin(2._wp*pphi) * zinvstressconviso 
-      !now uses phi as set in higher code
-       
+!     REAL(wp), PARAMETER ::   ppinvstressconviso = 1._wp/(1._wp+ppkfriction*ppkfriction)
+      REAL(wp), PARAMETER ::   ppinvstressconviso = 1._wp
+
+      ! next statement uses pphi set in main module (icedyn_rhg_eap)
+      REAL(wp), PARAMETER ::   ppinvsin = 1._wp/sin(2._wp*pphi) * ppinvstressconviso
+
       ! compute eigenvalues, eigenvectors and angles for structure tensor, strain
       ! rates
@@ -1132,22 +1138,22 @@
       zQ12Q12 = rsmall
       zQ11Q12 = rsmall
- 
-      ! gamma: angle between general coordiantes and principal axis of A 
-      ! here Tan2gamma = 2 a12 / (a11 - a22) 
-      IF((ABS(pa11 - za22) > rsmall).OR.(ABS(pa12) > rsmall)) THEN      
+
+      ! gamma: angle between general coordiantes and principal axis of A
+      ! here Tan2gamma = 2 a12 / (a11 - a22)
+      IF((ABS(pa11 - za22) > rsmall).OR.(ABS(pa12) > rsmall)) THEN
          zAngle_denom_gamma = 1._wp/sqrt( ( pa11 - za22 )*( pa11 - za22) + &
                               4._wp*pa12*pa12 )
-   
-         zQ11Q11 = 0.5_wp + ( pa11 - za22 )*0.5_wp*zAngle_denom_gamma   !Cos^2 
+
+         zQ11Q11 = 0.5_wp + ( pa11 - za22 )*0.5_wp*zAngle_denom_gamma   !Cos^2
          zQ12Q12 = 0.5_wp - ( pa11 - za22 )*0.5_wp*zAngle_denom_gamma   !Sin^2
-         zQ11Q12 = pa12*zAngle_denom_gamma                     !CosSin 
-      ENDIF
- 
+         zQ11Q12 = pa12*zAngle_denom_gamma                     !CosSin
+      ENDIF
+
       ! rotation Q*atemp*Q^T
-      zatempprime = zQ11Q11*pa11 + 2.0_wp*zQ11Q12*pa12 + zQ12Q12*za22 
-      
+      zatempprime = zQ11Q11*pa11 + 2.0_wp*zQ11Q12*pa12 + zQ12Q12*za22
+
       ! make first principal value the largest
       zatempprime = max(zatempprime, 1.0_wp - zatempprime)
- 
+
       ! 2) strain rate
       zdtemp11 = 0.5_wp*(pdivu + ptension)
@@ -1155,5 +1161,5 @@
       zdtemp22 = 0.5_wp*(pdivu - ptension)
 
-      ! here Tan2alpha = 2 dtemp12 / (dtemp11 - dtemp22) 
+      ! here Tan2alpha = 2 dtemp12 / (dtemp11 - dtemp22)
 
       zQd11Qd11 = 1.0_wp
@@ -1166,5 +1172,5 @@
                              ( zdtemp11 - zdtemp22 ) + 4.0_wp*zdtemp12*zdtemp12)
 
-         zQd11Qd11 = 0.5_wp + ( zdtemp11 - zdtemp22 )*0.5_wp*zAngle_denom_alpha !Cos^2 
+         zQd11Qd11 = 0.5_wp + ( zdtemp11 - zdtemp22 )*0.5_wp*zAngle_denom_alpha !Cos^2
          zQd12Qd12 = 0.5_wp - ( zdtemp11 - zdtemp22 )*0.5_wp*zAngle_denom_alpha !Sin^2
          zQd11Qd12 = zdtemp12*zAngle_denom_alpha !CosSin
@@ -1177,35 +1183,32 @@
       IF ((ABS(zdtemp1) > rsmall).OR.(ABS(zdtemp2) > rsmall)) THEN
          zx = atan2(zdtemp2,zdtemp1)
-      ENDIF      
-               
-      ! to ensure the angle lies between pi/4 and 9 pi/4 
+      ENDIF
+
+      ! to ensure the angle lies between pi/4 and 9 pi/4
       IF (zx < rpi*0.25_wp) zx = zx + rpi*2.0_wp
-      
+
       ! y: angle between major principal axis of strain rate and structure
       ! tensor
-      ! y = gamma - alpha 
+      ! y = gamma - alpha
       ! Expressesed componently with
       ! Tany = (Singamma*Cosgamma - Sinalpha*Cosgamma)/(Cos^2gamma - Sin^alpha)
-      
+
       zTany_1 = zQ11Q12 - zQd11Qd12
       zTany_2 = zQ11Q11 - zQd12Qd12
-      
+
       zy = 0._wp
-      
+
       IF ((ABS(zTany_1) > rsmall).OR.(ABS(zTany_2) > rsmall)) THEN
          zy = atan2(zTany_1,zTany_2)
       ENDIF
-      
+
       ! to make sure y is between 0 and pi
       IF (zy > rpi) zy = zy - rpi
       IF (zy < 0)  zy = zy + rpi
 
-      ! 3) update anisotropic stress tensor 
-      zdx   = rpi/real(nx_yield-1,kind=wp)
-      zdy   = rpi/real(ny_yield-1,kind=wp)
-      zda   = 0.5_wp/real(na_yield-1,kind=wp)
-      zinvdx = 1._wp/zdx
-      zinvdy = 1._wp/zdy
-      zinvda = 1._wp/zda
+      ! 3) update anisotropic stress tensor
+      zinvdx = real(nx_yield-1,kind=wp)/rpi
+      zinvdy = real(ny_yield-1,kind=wp)/rpi
+      zinvda = 2._wp*real(na_yield-1,kind=wp)
 
       ! % need 8 coords and 8 weights
@@ -1213,14 +1216,14 @@
       kx  = int((zx-rpi*0.25_wp-rpi)*zinvdx) + 1
       !!clem kx  = MAX( 1, MIN( nx_yield-1, INT((zx-rpi*0.25_wp-rpi)*zinvdx) + 1  ) )
-      zkxw = kx - (zx-rpi*0.25_wp-rpi)*zinvdx  
-      
+      zkxw = kx - (zx-rpi*0.25_wp-rpi)*zinvdx
+
       ky  = int(zy*zinvdy) + 1
       !!clem ky  = MAX( 1, MIN( ny_yield-1, INT(zy*zinvdy) + 1 ) )
-      kyw = ky - zy*zinvdy 
-      
+      kyw = ky - zy*zinvdy
+
       ka  = int((zatempprime-0.5_wp)*zinvda) + 1
       !!clem ka  = MAX( 1, MIN( na_yield-1, INT((zatempprime-0.5_wp)*zinvda) + 1 ) )
       kaw = ka - (zatempprime-0.5_wp)*zinvda
-      
+
       ! % Determine sigma_r(A1,Zeta,y) and sigma_s (see Section A1 of Tsamados 2013)
 !!$      zstemp11r =  zkxw  * kyw         * kaw         * s11r(kx  ,ky  ,ka  ) &
@@ -1248,5 +1251,5 @@
 !!$        & + zkxw         * (1._wp-kyw) * (1._wp-kaw) * s22r(kx  ,ky+1,ka+1) &
 !!$        & + (1._wp-zkxw) * (1._wp-kyw) * (1._wp-kaw) * s22r(kx+1,ky+1,ka+1)
-!!$      
+!!$
 !!$      zstemp11s =  zkxw  * kyw         * kaw         * s11s(kx  ,ky  ,ka  ) &
 !!$        & + (1._wp-zkxw) * kyw         * kaw         * s11s(kx+1,ky  ,ka  ) &
@@ -1280,12 +1283,12 @@
       zstemp12s = s12s(kx,ky,ka)
       zstemp22s = s22s(kx,ky,ka)
-      
-      
+
+
       ! Calculate mean ice stress over a collection of floes (Equation 3 in
       ! Tsamados 2013)
 
-      zsig11  = pstrength*(zstemp11r + kfriction*zstemp11s) * zinvsin
-      zsig12  = pstrength*(zstemp12r + kfriction*zstemp12s) * zinvsin
-      zsig22  = pstrength*(zstemp22r + kfriction*zstemp22s) * zinvsin
+      zsig11  = pstrength*(zstemp11r + ppkfriction*zstemp11s) * ppinvsin
+      zsig12  = pstrength*(zstemp12r + ppkfriction*zstemp12s) * ppinvsin
+      zsig22  = pstrength*(zstemp22r + ppkfriction*zstemp22s) * ppinvsin
 
       ! Back - rotation of the stress from principal axes into general coordinates
@@ -1300,5 +1303,5 @@
       pstressm  = zsgprm11 - zsgprm22
 
-      ! Compute ridging and sliding functions in general coordinates 
+      ! Compute ridging and sliding functions in general coordinates
       ! (Equation 11 in Tsamados 2013)
       IF (ksub == kndte) THEN
@@ -1307,5 +1310,5 @@
          zrotstemp12r = zQ11Q11*zstemp12r +       zQ11Q12*(zstemp11r-zstemp22r) &
                       - zQ12Q12*zstemp12r
-         zrotstemp22r = zQ12Q12*zstemp11r + 2._wp*zQ11Q12* zstemp12r & 
+         zrotstemp22r = zQ12Q12*zstemp11r + 2._wp*zQ11Q12* zstemp12r &
                       + zQ11Q11*zstemp22r
 
@@ -1314,5 +1317,5 @@
          zrotstemp12s = zQ11Q11*zstemp12s +       zQ11Q12*(zstemp11s-zstemp22s) &
                       - zQ12Q12*zstemp12s
-         zrotstemp22s = zQ12Q12*zstemp11s + 2._wp*zQ11Q12* zstemp12s & 
+         zrotstemp22s = zQ12Q12*zstemp11s + 2._wp*zQ11Q12* zstemp12s &
                       + zQ11Q11*zstemp22s
 
@@ -1322,5 +1325,5 @@
                   + zrotstemp22s*zdtemp22
       ENDIF
-   END SUBROUTINE update_stress_rdg 
+   END SUBROUTINE update_stress_rdg
 
 !=======================================================================
@@ -1331,5 +1334,5 @@
       !!---------------------------------------------------------------------
       !!                   ***  ROUTINE calc_ffrac  ***
-      !!                     
+      !!
       !! ** Purpose :   Computes term in evolution equation for structure tensor
       !!                which determines the ice floe re-orientation due to fracture
@@ -1346,20 +1349,20 @@
       REAL (wp) ::   zQ11, zQ12, zQ11Q11, zQ11Q12, zQ12Q12
 
-!!$      REAL (wp), PARAMETER ::   kfrac = 0.0001_wp   ! rate of fracture formation 
-      REAL (wp), PARAMETER ::   kfrac = 1.e-3_wp   ! rate of fracture formation 
-      REAL (wp), PARAMETER ::   threshold = 0.3_wp  ! critical confinement ratio 
+!!$   REAL (wp), PARAMETER ::   ppkfrac = 0.0001_wp   ! rate of fracture formation
+      REAL (wp), PARAMETER ::   ppkfrac = 1.e-3_wp    ! rate of fracture formation
+      REAL (wp), PARAMETER ::   ppthreshold = 0.3_wp  ! critical confinement ratio
       !!---------------------------------------------------------------
       !
-      zsigma11 = 0.5_wp*(pstressp+pstressm) 
-      zsigma12 = pstress12 
-      zsigma22 = 0.5_wp*(pstressp-pstressm) 
+      zsigma11 = 0.5_wp*(pstressp+pstressm)
+      zsigma12 = pstress12
+      zsigma22 = 0.5_wp*(pstressp-pstressm)
 
       ! Here's the change - no longer calculate gamma,
       ! use trig formulation, angle signs are kept correct, don't worry
-   
+
       ! rotate tensor to get into sigma principal axis
-   
-      ! here Tan2gamma = 2 sig12 / (sig11 - sig12) 
-      ! add rsmall to the denominator to stop 1/0 errors, makes very little 
+
+      ! here Tan2gamma = 2 sig12 / (sig11 - sig12)
+      ! add rsmall to the denominator to stop 1/0 errors, makes very little
       ! error to the calculated angles < rsmall
 
@@ -1373,7 +1376,7 @@
                        zsigma22 ) + 4.0_wp*zsigma12*zsigma12)
 
-         zQ11Q11 = 0.5_wp + ( zsigma11 - zsigma22 )*0.5_wp*zAngle_denom   !Cos^2 
+         zQ11Q11 = 0.5_wp + ( zsigma11 - zsigma22 )*0.5_wp*zAngle_denom   !Cos^2
          zQ12Q12 = 0.5_wp - ( zsigma11 - zsigma22 )*0.5_wp*zAngle_denom   !Sin^2
-         zQ11Q12 = zsigma12*zAngle_denom                      !CosSin 
+         zQ11Q12 = zsigma12*zAngle_denom                      !CosSin
       ENDIF
 
@@ -1390,6 +1393,6 @@
       ! which leads to the loss of their shape, so we again model it through diffusion
       ELSEIF ((zsigma_1 >= 0.0_wp).AND.(zsigma_2 < 0.0_wp))  THEN
-         pmresult11 = - kfrac * (pa11 - zQ12Q12)
-         pmresult12 = - kfrac * (pa12 + zQ11Q12)
+         pmresult11 = - ppkfrac * (pa11 - zQ12Q12)
+         pmresult12 = - ppkfrac * (pa12 + zQ11Q12)
 
       ! Shear faulting
@@ -1397,10 +1400,10 @@
          pmresult11 = 0.0_wp
          pmresult12 = 0.0_wp
-      ELSEIF ((zsigma_1 <= 0.0_wp).AND.(zsigma_1/zsigma_2 <= threshold)) THEN
-         pmresult11 = - kfrac * (pa11 - zQ12Q12)
-         pmresult12 = - kfrac * (pa12 + zQ11Q12)
+      ELSEIF ((zsigma_1 <= 0.0_wp).AND.(zsigma_1/zsigma_2 <= ppthreshold)) THEN
+         pmresult11 = - ppkfrac * (pa11 - zQ12Q12)
+         pmresult12 = - ppkfrac * (pa12 + zQ11Q12)
 
       ! Horizontal spalling
-      ELSE 
+      ELSE
          pmresult11 = 0.0_wp
          pmresult12 = 0.0_wp
@@ -1413,7 +1416,7 @@
       !!---------------------------------------------------------------------
       !!                   ***  ROUTINE rhg_eap_rst  ***
-      !!                     
+      !!
       !! ** Purpose :   Read or write RHG file in restart file
-      !!      
+      !!
       !! ** Method  :   use of IOM library
       !!----------------------------------------------------------------------
@@ -1424,7 +1427,7 @@
       INTEGER  ::   id1, id2, id3, id4, id5   ! local integers
       INTEGER  ::   ix, iy, ip, iz, n, ia     ! local integers
-    
+
       INTEGER, PARAMETER            ::    nz = 100
-      
+
       REAL(wp) ::   ainit, xinit, yinit, pinit, zinit
       REAL(wp) ::   da, dx, dy, dp, dz, a1
@@ -1432,5 +1435,6 @@
       !!clem
       REAL(wp) ::   zw1, zw2, zfac, ztemp
-      REAL(wp) ::   idx, idy, idz
+      REAL(wp) ::   zidx, zidy, zidz
+      REAL(wp) ::   zsaak(6)                  ! temporary array
 
       REAL(wp), PARAMETER           ::   eps6 = 1.0e-6_wp
@@ -1508,5 +1512,5 @@
 !!$                        s22r(ix,iy,ia) = s22r(ix,iy,ia) + 1*w1(ainit+ia*da)* &
 !!$                           exp(-w2(ainit+ia*da)*(zinit+iz*dz)*(zinit+iz*dz))* &
-!!$                           s22kr(xinit+ix*dx,yinit+iy*dy,zinit+iz*dz)*dz/sin(2._wp*pphi) 
+!!$                           s22kr(xinit+ix*dx,yinit+iy*dy,zinit+iz*dz)*dz/sin(2._wp*pphi)
 !!$                        s11s(ix,iy,ia) = s11s(ix,iy,ia) + 1*w1(ainit+ia*da)* &
 !!$                           exp(-w2(ainit+ia*da)*(zinit+iz*dz)*(zinit+iz*dz))* &
@@ -1543,5 +1547,5 @@
 !!$         ENDDO
 
-         !! faster but still very slow => to be improved         
+         !! faster but still very slow => to be improved
          zfac = dz/sin(2._wp*pphi)
          DO ia = 1, na_yield-1
@@ -1549,33 +1553,36 @@
             zw2 = w2(ainit+ia*da)
             DO iz = 1, nz
-               idz = zinit+iz*dz
+               zidz = zinit+iz*dz
                ztemp = zw1 * EXP(-zw2*(zinit+iz*dz)*(zinit+iz*dz))
                DO iy = 1, ny_yield
-                  idy = yinit+iy*dy
+                  zidy = yinit+iy*dy
                   DO ix = 1, nx_yield
-                     idx = xinit+ix*dx
-                     s11r(ix,iy,ia) = s11r(ix,iy,ia) + ztemp * s11kr(idx,idy,idz)*zfac
-                     s12r(ix,iy,ia) = s12r(ix,iy,ia) + ztemp * s12kr(idx,idy,idz)*zfac
-                     s22r(ix,iy,ia) = s22r(ix,iy,ia) + ztemp * s22kr(idx,idy,idz)*zfac 
-                     s11s(ix,iy,ia) = s11s(ix,iy,ia) + ztemp * s11ks(idx,idy,idz)*zfac
-                     s12s(ix,iy,ia) = s12s(ix,iy,ia) + ztemp * s12ks(idx,idy,idz)*zfac
-                     s22s(ix,iy,ia) = s22s(ix,iy,ia) + ztemp * s22ks(idx,idy,idz)*zfac
+                     zidx = xinit+ix*dx
+                     call all_skr_sks(zidx,zidy,zidz,zsaak)
+                     zsaak = ztemp*zsaak*zfac
+                     s11r(ix,iy,ia) = s11r(ix,iy,ia) + zsaak(1)
+                     s12r(ix,iy,ia) = s12r(ix,iy,ia) + zsaak(2)
+                     s22r(ix,iy,ia) = s22r(ix,iy,ia) + zsaak(3)
+                     s11s(ix,iy,ia) = s11s(ix,iy,ia) + zsaak(4)
+                     s12s(ix,iy,ia) = s12s(ix,iy,ia) + zsaak(5)
+                     s22s(ix,iy,ia) = s22s(ix,iy,ia) + zsaak(6)
                   END DO
                END DO
             END DO
          END DO
-
          zfac = 1._wp/sin(2._wp*pphi)
          ia = na_yield
          DO iy = 1, ny_yield
-            idy = yinit+iy*dy
+            zidy = yinit+iy*dy
             DO ix = 1, nx_yield
-               idx = xinit+ix*dx                  
-               s11r(ix,iy,ia) = 0.5_wp*s11kr(idx,idy,0._wp)*zfac
-               s12r(ix,iy,ia) = 0.5_wp*s12kr(idx,idy,0._wp)*zfac
-               s22r(ix,iy,ia) = 0.5_wp*s22kr(idx,idy,0._wp)*zfac
-               s11s(ix,iy,ia) = 0.5_wp*s11ks(idx,idy,0._wp)*zfac
-               s12s(ix,iy,ia) = 0.5_wp*s12ks(idx,idy,0._wp)*zfac
-               s22s(ix,iy,ia) = 0.5_wp*s22ks(idx,idy,0._wp)*zfac
+               zidx = xinit+ix*dx
+               call all_skr_sks(zidx,zidy,0._wp,zsaak)
+               zsaak = 0.5_wp*zsaak*zfac
+               s11r(ix,iy,ia) = zsaak(1)
+               s12r(ix,iy,ia) = zsaak(2)
+               s22r(ix,iy,ia) = zsaak(3)
+               s11s(ix,iy,ia) = zsaak(4)
+               s12s(ix,iy,ia) = zsaak(5)
+               s22s(ix,iy,ia) = zsaak(6)
             ENDDO
          ENDDO
@@ -1611,5 +1618,5 @@
       REAL(wp) ::   w1
       !!-------------------------------------------------------------------
-   
+
       w1 = -   223.87569446_wp &
        &   +  2361.21986630_wp*pa &
@@ -1620,5 +1627,5 @@
        &   - 16789.98003081_wp*pa*pa*pa*pa*pa*pa &
        &   +  3495.82839237_wp*pa*pa*pa*pa*pa*pa*pa
-   
+
    END FUNCTION w1
 
@@ -1631,5 +1638,5 @@
       REAL(wp) ::   w2
       !!-------------------------------------------------------------------
-   
+
       w2 = -    6670.68911883_wp &
        &   +   70222.33061536_wp*pa &
@@ -1640,15 +1647,15 @@
        &   -  493379.44906738_wp*pa*pa*pa*pa*pa*pa &
        &   +  102356.55151800_wp*pa*pa*pa*pa*pa*pa*pa
-   
+
    END FUNCTION w2
 
-   FUNCTION s11kr(px,py,pz) 
-      !!-------------------------------------------------------------------
-      !! Function : s11kr
-      !!-------------------------------------------------------------------
+   SUBROUTINE all_skr_sks( px, py, pz, allsk )
       REAL(wp), INTENT(in   ) ::   px,py,pz
-   
-      REAL(wp) ::   s11kr, zpih
-   
+      REAL(wp), INTENT(out  ) ::   allsk(6)
+
+      REAL(wp) ::   zs12r0, zs21r0
+      REAL(wp) ::   zs12s0, zs21s0
+
+      REAL(wp) ::   zpih
       REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
       REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
@@ -1659,7 +1666,7 @@
       REAL(wp) ::   zHen1t2, zHen2t1
       !!-------------------------------------------------------------------
-   
+
       zpih = 0.5_wp*rpi
-   
+
       zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
       zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
@@ -1687,5 +1694,5 @@
       zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
       zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-   
+
       IF (-zIIn1t2>=rsmall) THEN
       zHen1t2 = 1._wp
@@ -1693,5 +1700,5 @@
       zHen1t2 = 0._wp
       ENDIF
-   
+
       IF (-zIIn2t1>=rsmall) THEN
       zHen2t1 = 1._wp
@@ -1699,297 +1706,35 @@
       zHen2t1 = 0._wp
       ENDIF
-   
-      s11kr = (- zHen1t2 * zn1t2i11 - zHen2t1 * zn2t1i11)
-
-   END FUNCTION s11kr
-
-   FUNCTION s12kr(px,py,pz)
+
+      !!-------------------------------------------------------------------
+      !! Function : s11kr
+      !!-------------------------------------------------------------------
+      allsk(1) = (- zHen1t2 * zn1t2i11 - zHen2t1 * zn2t1i11)
       !!-------------------------------------------------------------------
       !! Function : s12kr
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s12kr, zs12r0, zs21r0, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-   
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-   
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-   
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-   
       zs12r0 = (- zHen1t2 * zn1t2i12 - zHen2t1 * zn2t1i12)
       zs21r0 = (- zHen1t2 * zn1t2i21 - zHen2t1 * zn2t1i21)
-      s12kr=0.5_wp*(zs12r0+zs21r0)
-   
-   END FUNCTION s12kr
-
-   FUNCTION s22kr(px,py,pz)
+      allsk(2)=0.5_wp*(zs12r0+zs21r0)
       !!-------------------------------------------------------------------
       !! Function : s22kr
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s22kr, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
-      s22kr = (- zHen1t2 * zn1t2i22 - zHen2t1 * zn2t1i22)
-
-   END FUNCTION s22kr
-
-   FUNCTION s11ks(px,py,pz)
+      allsk(3) = (- zHen1t2 * zn1t2i22 - zHen2t1 * zn2t1i22)
       !!-------------------------------------------------------------------
       !! Function : s11ks
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s11ks, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
-      s11ks = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i11 + zHen2t1 * zt2t1i11)
-
-   END FUNCTION s11ks
-
-   FUNCTION s12ks(px,py,pz)
+
+      allsk(4) = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i11 + zHen2t1 * zt2t1i11)
       !!-------------------------------------------------------------------
       !! Function : s12ks
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s12ks, zs12s0, zs21s0, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
       zs12s0 = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i12 + zHen2t1 * zt2t1i12)
       zs21s0 = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i21 + zHen2t1 * zt2t1i21)
-      s12ks=0.5_wp*(zs12s0+zs21s0)
-
-   END FUNCTION s12ks
-
-   FUNCTION s22ks(px,py,pz) 
+      allsk(5)=0.5_wp*(zs12s0+zs21s0)
       !!-------------------------------------------------------------------
       !! Function : s22ks
       !!-------------------------------------------------------------------
-      REAL(wp), INTENT(in   ) ::   px,py,pz
-
-      REAL(wp) ::   s22ks, zpih
-
-      REAL(wp) ::   zn1t2i11, zn1t2i12, zn1t2i21, zn1t2i22
-      REAL(wp) ::   zn2t1i11, zn2t1i12, zn2t1i21, zn2t1i22
-      REAL(wp) ::   zt1t2i11, zt1t2i12, zt1t2i21, zt1t2i22
-      REAL(wp) ::   zt2t1i11, zt2t1i12, zt2t1i21, zt2t1i22
-      REAL(wp) ::   zd11, zd12, zd22
-      REAL(wp) ::   zIIn1t2, zIIn2t1, zIIt1t2
-      REAL(wp) ::   zHen1t2, zHen2t1
-      !!-------------------------------------------------------------------
-      zpih = 0.5_wp*rpi
-
-      zn1t2i11 = cos(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i12 = cos(pz+zpih-pphi) * sin(pz+pphi)
-      zn1t2i21 = sin(pz+zpih-pphi) * cos(pz+pphi)
-      zn1t2i22 = sin(pz+zpih-pphi) * sin(pz+pphi)
-      zn2t1i11 = cos(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i12 = cos(pz-zpih+pphi) * sin(pz-pphi)
-      zn2t1i21 = sin(pz-zpih+pphi) * cos(pz-pphi)
-      zn2t1i22 = sin(pz-zpih+pphi) * sin(pz-pphi)
-      zt1t2i11 = cos(pz-pphi) * cos(pz+pphi)
-      zt1t2i12 = cos(pz-pphi) * sin(pz+pphi)
-      zt1t2i21 = sin(pz-pphi) * cos(pz+pphi)
-      zt1t2i22 = sin(pz-pphi) * sin(pz+pphi)
-      zt2t1i11 = cos(pz+pphi) * cos(pz-pphi)
-      zt2t1i12 = cos(pz+pphi) * sin(pz-pphi)
-      zt2t1i21 = sin(pz+pphi) * cos(pz-pphi)
-      zt2t1i22 = sin(pz+pphi) * sin(pz-pphi)
-      zd11 = cos(py)*cos(py)*(cos(px)+sin(px)*tan(py)*tan(py))
-      zd12 = cos(py)*cos(py)*tan(py)*(-cos(px)+sin(px))
-      zd22 = cos(py)*cos(py)*(sin(px)+cos(px)*tan(py)*tan(py))
-      zIIn1t2 = zn1t2i11 * zd11 + (zn1t2i12 + zn1t2i21) * zd12 + zn1t2i22 * zd22
-      zIIn2t1 = zn2t1i11 * zd11 + (zn2t1i12 + zn2t1i21) * zd12 + zn2t1i22 * zd22
-      zIIt1t2 = zt1t2i11 * zd11 + (zt1t2i12 + zt1t2i21) * zd12 + zt1t2i22 * zd22
-
-      IF (-zIIn1t2>=rsmall) THEN
-      zHen1t2 = 1._wp
-      ELSE
-      zHen1t2 = 0._wp
-      ENDIF
-
-      IF (-zIIn2t1>=rsmall) THEN
-      zHen2t1 = 1._wp
-      ELSE
-      zHen2t1 = 0._wp
-      ENDIF
-
-      s22ks = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i22 + zHen2t1 * zt2t1i22)
-
-   END FUNCTION s22ks
+      allsk(6) = sign(1._wp,zIIt1t2+rsmall)*(zHen1t2 * zt1t2i22 + zHen2t1 * zt2t1i22)
+   END SUBROUTINE all_skr_sks
 
 #else
@@ -1997,4 +1742,20 @@
    !!   Default option         Empty module           NO SI3 sea-ice model
    !!----------------------------------------------------------------------
+   USE par_kind
+   USE lib_mpp
+   CONTAINS
+   SUBROUTINE ice_dyn_rhg_eap( kt, Kmm, pstress1_i, pstress2_i, pstress12_i, pshear_i, pdivu_i, pdelta_i, paniso_11, paniso_12, prdg_conv )
+      INTEGER                 , INTENT(in   ) ::   kt                                    ! time step
+      INTEGER                 , INTENT(in   ) ::   Kmm                                   ! ocean time level index
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   pstress1_i, pstress2_i, pstress12_i   !
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   pshear_i  , pdivu_i   , pdelta_i      !
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   paniso_11 , paniso_12                 ! structure tensor components
+      REAL(wp), DIMENSION(:,:), INTENT(in   ) ::   prdg_conv                             ! for ridging
+      CALL ctl_stop('EAP rheology is currently dsabled due to issues with AGRIF preprocessing')
+   END SUBROUTINE ice_dyn_rhg_eap
+   SUBROUTINE rhg_eap_rst( cdrw, kt )
+      CHARACTER(len=*) , INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
+      INTEGER, OPTIONAL, INTENT(in) ::   kt     ! ice time-step
+   END SUBROUTINE rhg_eap_rst
 #endif
 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ICE_RHEO/cpp_ICE_RHEO.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_si3 key_mpp_mpi key_nosignedzero key_iomput
+bld::tool::fppkeys key_si3 key_linssh key_mpp_mpi key_nosignedzero key_iomput
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/MY_SRC/eosbn2.F90
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/MY_SRC/eosbn2.F90	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/ISOMIP+/MY_SRC/eosbn2.F90	(revision 14200)
@@ -91,6 +91,6 @@
 
    !                               !!!  simplified eos coefficients (default value: Vallis 2006)
-   REAL(wp) ::   rn_a0      = 1.6550e-1_wp     ! thermal expansion coeff. 
-   REAL(wp) ::   rn_b0      = 7.6554e-1_wp     ! saline  expansion coeff. 
+   REAL(wp), PUBLIC ::   rn_a0      = 1.6550e-1_wp     ! thermal expansion coeff. 
+   REAL(wp), PUBLIC ::   rn_b0      = 7.6554e-1_wp     ! saline  expansion coeff. 
    REAL(wp) ::   rn_lambda1 = 5.9520e-2_wp     ! cabbeling coeff. in T^2        
    REAL(wp) ::   rn_lambda2 = 5.4914e-4_wp     ! cabbeling coeff. in S^2        
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/LOCK_EXCHANGE/cpp_LOCK_EXCHANGE.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi 
+ bld::tool::fppkeys   key_qco key_iomput key_mpp_mpi 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/OVERFLOW/cpp_OVERFLOW.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys   key_mpp_mpi key_iomput 
+bld::tool::fppkeys   key_qco key_mpp_mpi key_iomput 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/STATION_ASF/cpp_STATION_ASF.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_si3 key_c1d key_iomput key_mpp_mpi
+ bld::tool::fppkeys   key_si3 key_c1d key_qco key_iomput key_mpp_mpi
Index: /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/EXPREF/file_def_nemo-oce.xml
===================================================================
--- /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/EXPREF/file_def_nemo-oce.xml	(revision 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/EXPREF/file_def_nemo-oce.xml	(revision 14200)
@@ -46,14 +46,14 @@
         </file>
         
-        <file id="file5" name_suffix="_grid_F" description="ocean F grid variables put on T grid" >
-          <field field_ref="e3f"            name="e3f"       operation = "instant" />
-          <field field_ref="e3f_0"          name="e3f_0"     operation = "instant" />
-          <field field_ref="hf"             name="hf"        operation = "instant" />
-          <field field_ref="sKEf"           name="sKEf"      operation = "instant" />
-          <field field_ref="relvor"         name="relvor"    operation = "instant" />
-          <field field_ref="plavor"         name="plavor"    operation = "instant" />
-          <field field_ref="abspotvor"      name="abspotvor" operation = "instant" />
-          <field field_ref="relpotvor"      name="relpotvor" operation = "instant" />
-          <field field_ref="Ens"            name="enstro"    operation = "instant" />
+        <file id="file5" name_suffix="_grid_F" description="ocean F grid variables" >
+          <field field_ref="e3f"            name="e3f"         operation = "instant" />
+          <field field_ref="e3f_0"          name="e3f_0"       operation = "instant" />
+          <field field_ref="hf"             name="hf"          operation = "instant" />
+          <field field_ref="ssKEf"          name="ssKEf"       operation = "instant" />
+          <field field_ref="ssrelvor"       name="ssrelvor"    operation = "instant" />
+          <field field_ref="ssplavor"       name="ssplavor"    operation = "instant" />
+          <field field_ref="ssabspotvor"    name="ssabspotvor" operation = "instant" />
+          <field field_ref="ssrelpotvor"    name="ssrelpotvor" operation = "instant" />
+          <field field_ref="ssEns"          name="ssenstro"    operation = "instant" />
         </file>
       
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/SWG/cpp_SWG.fcm	(revision 14200)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys  key_mpp_mpi key_iomput key_qco 
+bld::tool::fppkeys  key_mpp_mpi key_iomput key_qco key_RK3
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/MY_SRC/usrdef_istate.F90	(revision 14200)
@@ -17,4 +17,5 @@
    USE dom_oce , ONLY : glamt, gphit, glamu, gphiu, glamv, gphiv  
    USE phycst         ! physical constants
+   USE eosbn2  , ONLY : rn_a0
    !
    USE in_out_manager ! I/O manager
@@ -85,5 +86,5 @@
                   & * EXP(-(zx**2+zy**2)/zlambda**2) / (grav*(zH -1._wp + EXP(-zH)));
             ENDIF
-            pts(ji,jj,jk,jp_tem) = (20._wp + (rho0-zrho1) / 0.28_wp) * ptmask(ji,jj,jk)
+            pts(ji,jj,jk,jp_tem) = (20._wp + (rho0-zrho1) / rn_a0 ) * ptmask(ji,jj,jk)
          END DO
       END_2D
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/VORTEX/cpp_VORTEX.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif 
+ bld::tool::fppkeys key_iomput key_mpp_mpi key_agrif key_qco 
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 14199)
+++ /NEMO/branches/2020/dev_r14116_HPC-04_mcastril_Mixed_Precision_implementation_final/tests/WAD/cpp_WAD.fcm	(revision 14200)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys   key_iomput key_mpp_mpi 
+ bld::tool::fppkeys   key_iomput key_mpp_mpi key_qco 
