Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/1_namelist_cfg	(revision 13229)
@@ -95,22 +95,4 @@
    !                    !  bulk algorithm :
    ln_NCAR      = .true.    ! "NCAR"      algorithm   (Large and Yeager 2008)
-   ln_COARE_3p0 = .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
-   ln_COARE_3p6 = .false.   ! "COARE 3.6" algorithm   (Edson et al. 2013)
-   ln_ECMWF     = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
-      !
-      rn_zqt      = 10.       !  Air temperature & humidity reference height (m)
-      rn_zu       = 10.       !  Wind vector reference height (m)
-      ln_Cd_L12   = .false.   !  air-ice drags = F(ice concentration) (Lupkes et al. 2012)
-      ln_Cd_L15   = .false.   !  air-ice drags = F(ice concentration) (Lupkes et al. 2015)
-      rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
-      rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
-      rn_vfac     = 0.        !  multiplicative factor for ocean & ice velocity used to
-      !                       !  calculate the wind stress (0.=absolute or 1.=relative winds)
-      ln_skin_cs = .false.  !  use the cool-skin parameterization (only available in ECMWF and COARE algorithms) !LB
-      ln_skin_wl = .false.  !  use the warm-layer        "               "                    "
-      !
-      ln_humi_sph = .true.     !  humidity specified below in "sn_humi" is specific humidity     [kg/kg] if .true.
-      ln_humi_dpt = .false.    !  humidity specified below in "sn_humi" is dew-point temperature   [K]   if .true.
-      ln_humi_rlh = .false.    !  humidity specified below in "sn_humi" is relative humidity       [%]   if .true.
    !
    cn_dir = './'  !  root directory for the bulk data location
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/2_namelist_cfg	(revision 13229)
@@ -92,22 +92,4 @@
    !                    !  bulk algorithm :
    ln_NCAR      = .true.    ! "NCAR"      algorithm   (Large and Yeager 2008)
-   ln_COARE_3p0 = .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
-   ln_COARE_3p6 = .false.   ! "COARE 3.6" algorithm   (Edson et al. 2013)
-   ln_ECMWF     = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
-      !
-      rn_zqt      = 10.       !  Air temperature & humidity reference height (m)
-      rn_zu       = 10.       !  Wind vector reference height (m)
-      ln_Cd_L12   = .false.   !  air-ice drags = F(ice concentration) (Lupkes et al. 2012)
-      ln_Cd_L15   = .false.   !  air-ice drags = F(ice concentration) (Lupkes et al. 2015)
-      rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
-      rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
-      rn_vfac     = 0.        !  multiplicative factor for ocean & ice velocity used to
-      !                       !  calculate the wind stress (0.=absolute or 1.=relative winds)
-      ln_skin_cs = .false.  !  use the cool-skin parameterization (only available in ECMWF and COARE algorithms) !LB
-      ln_skin_wl = .false.  !  use the warm-layer        "               "                    "
-      !
-      ln_humi_sph = .true.     !  humidity specified below in "sn_humi" is specific humidity     [kg/kg] if .true.
-      ln_humi_dpt = .false.    !  humidity specified below in "sn_humi" is dew-point temperature   [K]   if .true.
-      ln_humi_rlh = .false.    !  humidity specified below in "sn_humi" is relative humidity       [%]   if .true.
    !
    cn_dir      = './'      !  root directory for the bulk data location
@@ -176,6 +158,4 @@
 !-----------------------------------------------------------------------
    ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
-   rn_sponge_tra = 1440.   !  coefficient for tracer   sponge layer [m2/s]
-   rn_sponge_dyn = 1440.   !  coefficient for dynamics sponge layer [m2/s]
    ln_chk_bathy  = .true.  !  =T  check the parent bathymetry
 /
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/3_namelist_cfg	(revision 13229)
@@ -158,6 +158,4 @@
 !-----------------------------------------------------------------------
    ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
-   rn_sponge_tra =  480.   !  coefficient for tracer   sponge layer [m2/s]
-   rn_sponge_dyn =  480.   !  coefficient for dynamics sponge layer [m2/s]
    ln_chk_bathy  = .true.  !  =T  check the parent bathymetry
 /
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/AGRIF_DEMO/EXPREF/namelist_cfg	(revision 13229)
@@ -95,6 +95,11 @@
 !-----------------------------------------------------------------------
    !                    !  bulk algorithm :
+<<<<<<< .locale
    ln_NCAR    = .true.     ! "NCAR"      algorithm   (Large and Yeager 2008)
 
+=======
+   ln_NCAR      = .true.    ! "NCAR"      algorithm   (Large and Yeager 2008)
+   !
+>>>>>>> .merge-dx.r13218
    cn_dir = './'  !  root directory for the bulk data location
    !___________!_________________________!___________________!___________!_____________!________!___________!______________________________________!__________!_______________!
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_ABL/EXPREF/file_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_ABL/EXPREF/file_def_nemo-oce.xml	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_ABL/EXPREF/file_def_nemo-oce.xml	(revision 13229)
@@ -56,4 +56,10 @@
 	  <field field_ref="t_abl" />
 	  <field field_ref="q_abl" />
+	  <field field_ref="uvz1_abl" />
+	  <field field_ref="tz1_abl" />
+	  <field field_ref="qz1_abl" />
+	  <field field_ref="uvz1_dta" />
+	  <field field_ref="tz1_dta" />
+	  <field field_ref="qz1_dta" />
 	  <field field_ref="pblh" />
 	</file>
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_ABL/EXPREF/namelist_cfg	(revision 13229)
@@ -110,17 +110,4 @@
    !                    !  bulk algorithm :
    ln_NCAR      = .true.    ! "NCAR"      algorithm   (Large and Yeager 2008)
-   ln_COARE_3p0 = .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
-   ln_COARE_3p6 = .false.   ! "COARE 3.6" algorithm   (Edson et al. 2013)
-   ln_ECMWF     = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
-      rn_zqt      = 10.     !  Air temperature & humidity reference height (m)
-      rn_zu       = 10.     !  Wind vector reference height (m)
-      !
-      ! Skin is ONLY available in ECMWF and COARE algorithms:
-      ln_skin_cs = .false.  !  use the cool-skin parameterization => set nn_fsbc=1 and ln_dm2dc=.true.!
-      ln_skin_wl = .false.  !  use the warm-layer        "        => set nn_fsbc=1 and ln_dm2dc=.true.!
-      !
-      ln_humi_sph = .true.  !  humidity specified below in "sn_humi" is specific humidity     [kg/kg] if .true.
-      ln_humi_dpt = .false. !  humidity specified below in "sn_humi" is dew-point temperature   [K]   if .true.
-      ln_humi_rlh = .false. !  humidity specified below in "sn_humi" is relative humidity       [%]   if .true.
    !
    cn_dir = './'  !  root directory for the bulk data location
@@ -132,7 +119,4 @@
    sn_tair     = 'tair_drwnlnd_ERAI_L25Z10_GLOBAL_F128R_ana1d',  24., 'tair'    , .false. , .false. , 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bilinear' , ''    , ''
    sn_humi     = 'humi_drwnlnd_ERAI_L25Z10_GLOBAL_F128R_ana1d',  24., 'humi'    , .false. , .false. , 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bilinear' , ''    , ''
-   sn_hpgi     = 'uhpg_drwnlnd_ERAI_L25Z10_GLOBAL_F128R_ana1d',  24., 'uhpg'    , .false. , .false. , 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic'  , 'UG'  , ''
-   sn_hpgj     = 'vhpg_drwnlnd_ERAI_L25Z10_GLOBAL_F128R_ana1d',  24., 'vhpg'    , .false. , .false. , 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic'  , 'VG'  , ''
-
    sn_qsr      = 'ncar_rad.15JUNE2009_fill'                    , 24., 'SWDN_MOD', .false. , .true.  ,  'yearly' , 'weights_core_orca2_bilinear_noc.nc'      , ''    , ''
    sn_qlw      = 'ncar_rad.15JUNE2009_fill'                    , 24., 'LWDN_MOD', .false. , .true.  ,  'yearly' , 'weights_core_orca2_bilinear_noc.nc'      , ''    , ''
@@ -140,4 +124,6 @@
    sn_snow     = 'ncar_precip.15JUNE2009_fill'                 , -1., 'SNOW'    , .false. , .true.  ,  'yearly' , 'weights_core_orca2_bilinear_noc.nc'      , ''    , ''
    sn_slp      = 'slp.15JUNE2009_fill'                         ,  6., 'SLP'     , .false. , .true.  ,  'yearly' , 'weights_core_orca2_bilinear_noc.nc'      , ''    , ''
+   sn_hpgi     = 'uhpg_drwnlnd_ERAI_L25Z10_GLOBAL_F128R_ana1d',  24., 'uhpg'    , .false. , .false. , 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic'  , 'UG'  , ''
+   sn_hpgj     = 'vhpg_drwnlnd_ERAI_L25Z10_GLOBAL_F128R_ana1d',  24., 'vhpg'    , .false. , .false. , 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic'  , 'VG'  , ''
 /
 
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_ICE_PISCES/EXPREF/namelist_cfg	(revision 13229)
@@ -121,4 +121,8 @@
 /
 !-----------------------------------------------------------------------
+&namsbc_abl    !   Atmospheric Boundary Layer formulation           (ln_abl = T)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
 &namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
 !-----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/ORCA2_SAS_ICE/EXPREF/namelist_cfg	(revision 13229)
@@ -68,22 +68,4 @@
    !                    !  bulk algorithm :
    ln_NCAR      = .true.    ! "NCAR"      algorithm   (Large and Yeager 2008)
-   ln_COARE_3p0 = .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
-   ln_COARE_3p6 = .false.   ! "COARE 3.6" algorithm   (Edson et al. 2013)
-   ln_ECMWF     = .false.   ! "ECMWF"     algorithm   (IFS cycle 31)
-      !
-      rn_zqt      = 10.       !  Air temperature & humidity reference height (m)
-      rn_zu       = 10.       !  Wind vector reference height (m)
-      ln_Cd_L12   = .false.   !  air-ice drags = F(ice concentration) (Lupkes et al. 2012)
-      ln_Cd_L15   = .false.   !  air-ice drags = F(ice concentration) (Lupkes et al. 2015)
-      rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
-      rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
-      rn_vfac     = 0.        !  multiplicative factor for ocean & ice velocity used to
-      !                       !  calculate the wind stress (0.=absolute or 1.=relative winds)
-      ln_skin_cs = .false.  !  use the cool-skin parameterization (only available in ECMWF and COARE algorithms) !LB
-      ln_skin_wl = .false.  !  use the warm-layer        "               "                    "
-      !
-      ln_humi_sph = .true.     !  humidity specified below in "sn_humi" is specific humidity     [kg/kg] if .true.
-      ln_humi_dpt = .false.    !  humidity specified below in "sn_humi" is dew-point temperature   [K]   if .true.
-      ln_humi_rlh = .false.    !  humidity specified below in "sn_humi" is relative humidity       [%]   if .true.
    !
    cn_dir      = './'      !  root directory for the bulk data location
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/SHARED/field_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/SHARED/field_def_nemo-oce.xml	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/SHARED/field_def_nemo-oce.xml	(revision 13229)
@@ -455,9 +455,11 @@
           <field id="t_dta"      long_name="DTA potential temperature"     standard_name="dta_theta"      unit="K"        />
           <field id="q_dta"      long_name="DTA specific humidity"         standard_name="dta_qspe"       unit="kg/kg"    />
-          <field id="coeft"      long_name="ABL nudging coefficient"       standard_name="coeft"          unit=""         />
+          <field id="u_geo"      long_name="GEO i-horizontal velocity"     standard_name="geo_x_velocity" unit="m/s"      />
+          <field id="v_geo"      long_name="GEO j-horizontal velocity"     standard_name="geo_y_velocity" unit="m/s"      />
           <field id="tke_abl"    long_name="ABL turbulent kinetic energy"  standard_name="abl_tke"        unit="m2/s2"    />
           <field id="avm_abl"    long_name="ABL turbulent viscosity"       standard_name="abl_avm"        unit="m2/s"     />
           <field id="avt_abl"    long_name="ABL turbulent diffusivity"     standard_name="abl_avt"        unit="m2/s"     />
-          <field id="mxl_abl"    long_name="ABL mixing length"             standard_name="abl_mxl"        unit="m"        />
+          <field id="mxlm_abl"   long_name="ABL master mixing length"      standard_name="abl_mxlm"       unit="m"        />
+          <field id="mxld_abl"   long_name="ABL dissipative mixing length" standard_name="abl_mxld"       unit="m"        />
 	</field_group>
 
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/SHARED/namelist_ref
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/SHARED/namelist_ref	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/SHARED/namelist_ref	(revision 13229)
@@ -268,10 +268,9 @@
       ln_Cd_L12  = .false.  !  air-ice drags = F(ice conc.) (Lupkes et al. 2012)
       ln_Cd_L15  = .false.  !  air-ice drags = F(ice conc.) (Lupkes et al. 2015)
-      !                     !  - module of the mean stress" data
+      ln_crt_fbk = .false.     !  Add surface current feedback to the wind stress (Renault et al. 2020, doi: 10.1029/2019MS001715)
+         rn_stau_a = -2.9e-3   !     Alpha from eq. 10: Stau = Alpha * Wnd + Beta
+         rn_stau_b =  8.0e-3   !     Beta 
       rn_pfac    = 1.       !  multipl. factor for precipitation (total & snow)
       rn_efac    = 1.       !  multipl. factor for evaporation (0. or 1.)
-      rn_vfac    = 0.       !  multipl. factor for ocean & ice velocity
-      !                     !  used to calculate the wind stress
-      !                     ! (0. => absolute or 1. => relative winds)
       ln_skin_cs = .false.  !  use the cool-skin parameterization
       ln_skin_wl = .false.  !  use the warm-layer parameterization
@@ -280,4 +279,5 @@
       ln_humi_dpt = .false. !  humidity "sn_humi" is dew-point temperature [K]
       ln_humi_rlh = .false. !  humidity "sn_humi" is relative humidity     [%]
+      ln_tpot     = .true.  !!GS: compute potential temperature or not
    !
    cn_dir      = './'      !  root directory for the bulk data location
@@ -291,9 +291,11 @@
    sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
    sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
-   sn_hpgi     = 'NOT USED'                   ,   24.        , 'uhpg'    ,   .false.   , .false., 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic', 'UG'     , ''
-   sn_hpgj     = 'NOT USED'                   ,   24.        , 'vhpg'    ,   .false.   , .false., 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic', 'VG'     , ''
    sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
    sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
    sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_uoatm    = 'NOT USED'                   ,    6.        , 'UOATM'   ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , 'Uoceatm', ''
+   sn_voatm    = 'NOT USED'                   ,    6.        , 'VOATM'   ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , 'Voceatm', ''
+   sn_hpgi     = 'NOT USED'                   ,   24.        , 'uhpg'    ,   .false.   , .false., 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic', 'UG'     , ''
+   sn_hpgj     = 'NOT USED'                   ,   24.        , 'vhpg'    ,   .false.   , .false., 'monthly' , 'weights_ERAI3D_F128_2_ORCA2_bicubic', 'VG'     , ''
 /
 !-----------------------------------------------------------------------
@@ -308,22 +310,25 @@
    cn_ablrst_outdir = "."             !  directory to write output abl restarts
 
+   ln_rstart_abl  = .false.
    ln_hpgls_frc   = .false.
    ln_geos_winds  = .false.
-   nn_dyn_restore = 2         ! restoring option for dynamical ABL variables: = 0 no restoring
+   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       !  magnitude of the nudging on ABL dynamics at the bottom of the ABL   [hour]
-   rn_ldyn_max   =  1.5       !  magnitude of the nudging on ABL dynamics at the top of the ABL   [hour]
-   rn_ltra_min   =  4.5       !  magnitude of the nudging on ABL tracers  at the bottom of the ABL   [hour]
-   rn_ltra_max   =  1.5       !  magnitude of the nudging on ABL tracers  at the top of the ABL   [hour]
+   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
-   rn_Cm         = 0.0667     ! 0.126 in MesoNH
-   rn_Ct         = 0.1667     ! 0.143 in MesoNH
-   rn_Ce         = 0.4        ! 0.4   in MesoNH
-   rn_Ceps       = 0.7        ! 0.85  in MesoNH
-   rn_Rod        = 0.15       ! c0 in RMCA17 mixing length formulation (not yet implemented)
-   rn_Ric        = 0.139      !  Critical Richardson number (to compute PBL height and diffusivities)
+                              ! 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)
 /
 !-----------------------------------------------------------------------
@@ -638,11 +643,12 @@
 &namagrif      !  AGRIF zoom                                            ("key_agrif")
 !-----------------------------------------------------------------------
-   ln_agrif_2way = .true.  !  activate two way nesting
-   ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
-   rn_sponge_tra = 2880.   !  coefficient for tracer   sponge layer [m2/s]
-   rn_sponge_dyn = 2880.   !  coefficient for dynamics sponge layer [m2/s]
-   rn_trelax_tra = 0.01    !  inverse of relaxation time (in steps) for tracers []
-   rn_trelax_dyn = 0.01    !  inverse of relaxation time (in steps) for dynamics []
-   ln_chk_bathy  = .false. !  =T  check the parent bathymetry
+   ln_agrif_2way   = .true.  !  activate two way nesting
+   ln_init_chfrpar = .false. !  initialize child grids from parent
+   ln_spc_dyn      = .true.  !  use 0 as special value for dynamics
+   rn_sponge_tra   = 0.002   !  coefficient for tracer   sponge layer []
+   rn_sponge_dyn   = 0.002   !  coefficient for dynamics sponge layer []
+   rn_trelax_tra   = 0.01    !  inverse of relaxation time (in steps) for tracers []
+   rn_trelax_dyn   = 0.01    !  inverse of relaxation time (in steps) for dynamics []
+   ln_chk_bathy    = .false. !  =T  check the parent bathymetry
 /
 !-----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/WED025/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/WED025/EXPREF/namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/cfgs/WED025/EXPREF/namelist_cfg	(revision 13229)
@@ -138,9 +138,9 @@
 !-----------------------------------------------------------------------
    !                    !  bulk algorithm :
-   ln_NCAR     = .true.   ! "NCAR"      algorithm   (Large and Yeager 2008)
+   ln_NCAR     = .true.     ! "NCAR"      algorithm   (Large and Yeager 2008)
    ln_COARE_3p0 = .false.   ! "COARE 3.0" algorithm   (Fairall et al. 2003)
    ln_COARE_3p6 = .false.   ! "COARE 3.6" algorithm   (Edson et al. 2013)
    ln_ECMWF     = .false.   ! "ECMWF"     algorithm   (IFS cycle 45r1)
-
+   !
    cn_dir      = './'      !  root directory for the bulk data location
    !___________!_________________________!___________________!___________!_____________!________!___________!______________________________________!__________!_______________!
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/doc/latex/NEMO/subfiles/chap_SBC.tex
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/doc/latex/NEMO/subfiles/chap_SBC.tex	(revision 13229)
@@ -832,5 +832,5 @@
     Solid precipitation                  & snow           & $Kg.m^{-2}.s^{-1}$ & T     \\
     \hline
-    Mean sea-level pressure              & slp            & $hPa$              & T     \\
+    Mean sea-level pressure              & slp            & $Pa$              & T     \\
     \hline
     \end{tabular}
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/abl.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/abl.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/abl.F90	(revision 13229)
@@ -29,5 +29,6 @@
    REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)     ::   avm_abl      !: turbulent viscosity   [m2/s]
    REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)     ::   avt_abl      !: turbulent diffusivity [m2/s]
-   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)     ::   mxl_abl      !: mixing length         [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)     ::   mxld_abl     !: dissipative mixing length    [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:)     ::   mxlm_abl     !: master mixing length         [m]
    REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:,:,:)   ::   tke_abl      !: turbulent kinetic energy [m2/s2]
    REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:)       ::   fft_abl      !: Coriolis parameter    [1/s]
@@ -55,16 +56,18 @@
       !!----------------------------------------------------------------------
       !
-      ALLOCATE( u_abl  (1:jpi,1:jpj,1:jpka,jptime), &
-         &      v_abl  (1:jpi,1:jpj,1:jpka,jptime), &
-         &      tq_abl (1:jpi,1:jpj,1:jpka,jptime,jptq), &
-         &      avm_abl(1:jpi,1:jpj,1:jpka), &
-         &      avt_abl(1:jpi,1:jpj,1:jpka), &
-         &      mxl_abl(1:jpi,1:jpj,1:jpka), &         
-         &      tke_abl(1:jpi,1:jpj,1:jpka,jptime), &
-         &      fft_abl(1:jpi,1:jpj), &
-         &      pblh   (1:jpi,1:jpj), &         
-         &      msk_abl(1:jpi,1:jpj), &
-         &      rest_eq(1:jpi,1:jpj), &         
-         &      e3t_abl(1:jpka), e3w_abl(1:jpka), ght_abl(1:jpka), ghw_abl(1:jpka),                 STAT=ierr )
+      ALLOCATE( u_abl   (1:jpi,1:jpj,1:jpka,jptime     ), &
+         &      v_abl   (1:jpi,1:jpj,1:jpka,jptime     ), &
+         &      tq_abl  (1:jpi,1:jpj,1:jpka,jptime,jptq), &
+         &      tke_abl (1:jpi,1:jpj,1:jpka,jptime     ), &
+         &      avm_abl (1:jpi,1:jpj,1:jpka            ), &
+         &      avt_abl (1:jpi,1:jpj,1:jpka            ), &
+         &      mxld_abl(1:jpi,1:jpj,1:jpka            ), &
+         &      mxlm_abl(1:jpi,1:jpj,1:jpka            ), &
+         &      fft_abl (1:jpi,1:jpj                   ), &
+         &      pblh    (1:jpi,1:jpj                   ), &
+         &      msk_abl (1:jpi,1:jpj                   ), &
+         &      rest_eq (1:jpi,1:jpj                   ), &
+         &      e3t_abl (1:jpka), e3w_abl(1:jpka)       , &
+         &      ght_abl (1:jpka), ghw_abl(1:jpka)       , STAT=ierr )
          !
       abl_alloc = ierr
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/ablmod.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/ablmod.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/ablmod.F90	(revision 13229)
@@ -2,10 +2,10 @@
    !!======================================================================
    !!                       ***  MODULE  ablmod  ***
-   !! Surface module :  ABL computation to provide atmospheric data 
+   !! Surface module :  ABL computation to provide atmospheric data
    !!                   for surface fluxes computation
    !!======================================================================
    !! History :  3.6  ! 2019-03  (F. Lemarié & G. Samson)  Original code
    !!----------------------------------------------------------------------
-   
+
    !!----------------------------------------------------------------------
    !!   abl_stp       : ABL single column model
@@ -16,7 +16,7 @@
 
    USE phycst         ! physical constants
-   USE dom_oce, ONLY  : tmask  
+   USE dom_oce, ONLY  : tmask
    USE sbc_oce, ONLY  : ght_abl, ghw_abl, e3t_abl, e3w_abl, jpka, jpkam1, rhoa
-   USE sbcblk         ! use rn_?fac
+   USE sbcblk         ! use rn_efac, cdn_oce
    USE sbcblk_phy     ! use some physical constants for flux computation
    !
@@ -30,5 +30,5 @@
 
    PUBLIC   abl_stp   ! called by sbcabl.F90
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ustar2
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ustar2, zrough
    !! * Substitutions
 #  include "do_loop_substitute.h90"
@@ -38,15 +38,16 @@
 
 !===================================================================================================
-   SUBROUTINE abl_stp( kt, psst, pssu, pssv, pssq, &                            ! in
-              &            pu_dta, pv_dta, pt_dta, pq_dta,    & 
+   SUBROUTINE abl_stp( kt, psst, pssu, pssv, pssq,            &     ! in
+              &            pu_dta, pv_dta, pt_dta, pq_dta,    &
               &            pslp_dta, pgu_dta, pgv_dta,        &
-              &            pcd_du, psen, pevp,                &                            ! in/out
-              &            pwndm, ptaui, ptauj, ptaum         & 
-#if defined key_si3			  
-              &          , ptm_su,pssu_ice,pssv_ice,pssq_ice,pcd_du_ice  & 
-              &          , psen_ice, pevp_ice, pwndm_ice, pfrac_oce      & 
-              &          , ptaui_ice, ptauj_ice                          &
-#endif			  
-			  &   )
+              &            pcd_du, psen, pevp,                &     ! in/out
+              &            pwndm, ptaui, ptauj, ptaum         &
+#if defined key_si3
+              &          , ptm_su, pssu_ice, pssv_ice         &
+              &          , pssq_ice, pcd_du_ice, psen_ice     &
+              &          , pevp_ice, pwndm_ice, pfrac_oce     &
+              &          , ptaui_ice, ptauj_ice               &
+#endif
+              &      )
 !---------------------------------------------------------------------------------------------------
 
@@ -54,9 +55,9 @@
       !!                    ***  ROUTINE abl_stp ***
       !!
-      !! ** Purpose :   Time-integration of the ABL model 
+      !! ** Purpose :   Time-integration of the ABL model
       !!
-      !! ** Method  :   Compute atmospheric variables : vertical turbulence 
+      !! ** Method  :   Compute atmospheric variables : vertical turbulence
       !!                             + Coriolis term + newtonian relaxation
-      !!                
+      !!
       !! ** Action  : - Advance TKE to time n+1 and compute Avm_abl, Avt_abl, PBLh
       !!              - Advance tracers to time n+1 (Euler backward scheme)
@@ -70,5 +71,5 @@
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   psst       ! sea-surface temperature [Celsius]
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssu       ! sea-surface u (U-point)
-      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssv       ! sea-surface v (V-point) 
+      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssv       ! sea-surface v (V-point)
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssq       ! sea-surface humidity
       REAL(wp) , INTENT(in   ), DIMENSION(:,:,:) ::   pu_dta     ! large-scale windi
@@ -82,37 +83,36 @@
       REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   psen       ! Ch x Du
       REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   pevp       ! Ce x Du
-      REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   pwndm      ! ||uwnd||      
+      REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   pwndm      ! ||uwnd||
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptaui      ! taux
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptauj      ! tauy
-      REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptaum      ! ||tau|| 
-      !
-#if defined key_si3	  
+      REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptaum      ! ||tau||
+      !
+#if defined key_si3
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   ptm_su       ! ice-surface temperature [K]
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssu_ice     ! ice-surface u (U-point)
-      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssv_ice     ! ice-surface v (V-point) 	  
-      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssq_ice     ! ice-surface humidity 
+      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssv_ice     ! ice-surface v (V-point)
+      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pssq_ice     ! ice-surface humidity
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pcd_du_ice   ! Cd x Du over ice (T-point)
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   psen_ice     ! Ch x Du over ice (T-point)
       REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pevp_ice     ! Ce x Du over ice (T-point)
-      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pwndm_ice    ! ||uwnd - uice||  
-      !REAL(wp) , INTENT(inout), DIMENSION(:,:  ) ::   pfrac_oce	   !!GS: out useless ?
-      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pfrac_oce	   !
+      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pwndm_ice    ! ||uwnd - uice||
+      REAL(wp) , INTENT(in   ), DIMENSION(:,:  ) ::   pfrac_oce    ! ocean fraction
       REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptaui_ice    ! ice-surface taux stress (U-point)
-      REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptauj_ice    ! ice-surface tauy stress (V-point) 	  
-#endif	  
-      !
-      REAL(wp), DIMENSION(1:jpi,1:jpj   )        ::   zwnd_i, zwnd_j
-      REAL(wp), DIMENSION(1:jpi,2:jpka  )        ::   zCF    
-      REAL(wp), DIMENSION(1:jpi,1:jpj,1:jpka)    ::   z_cft      !--FL--to be removed after the test phase   
-      !
-      REAL(wp), DIMENSION(1:jpi,1:jpka  )        ::   z_elem_a
-      REAL(wp), DIMENSION(1:jpi,1:jpka  )        ::   z_elem_b
-      REAL(wp), DIMENSION(1:jpi,1:jpka  )        ::   z_elem_c
+      REAL(wp) , INTENT(  out), DIMENSION(:,:  ) ::   ptauj_ice    ! ice-surface tauy stress (V-point)
+#endif
+      !
+      REAL(wp), DIMENSION(1:jpi,1:jpj       )    ::   zwnd_i, zwnd_j
+      REAL(wp), DIMENSION(1:jpi      ,2:jpka)    ::   zCF
+      !
+      REAL(wp), DIMENSION(1:jpi      ,1:jpka)    ::   z_elem_a
+      REAL(wp), DIMENSION(1:jpi      ,1:jpka)    ::   z_elem_b
+      REAL(wp), DIMENSION(1:jpi      ,1:jpka)    ::   z_elem_c
       !
       INTEGER             ::   ji, jj, jk, jtra, jbak               ! dummy loop indices
       REAL(wp)            ::   zztmp, zcff, ztemp, zhumi, zcff1, zztmp1, zztmp2
       REAL(wp)            ::   zcff2, zfcor, zmsk, zsig, zcffu, zcffv, zzice,zzoce
-      !
-      !!---------------------------------------------------------------------      
+      LOGICAL             ::   SemiImp_Cor = .TRUE.
+      !
+      !!---------------------------------------------------------------------
       !
       IF(lwp .AND. kt == nit000) THEN                  ! control print
@@ -120,18 +120,20 @@
          WRITE(numout,*) 'abl_stp : ABL time stepping'
          WRITE(numout,*) '~~~~~~'
-      ENDIF 
+      ENDIF
       !
       IF( kt == nit000 ) ALLOCATE ( ustar2( 1:jpi, 1:jpj ) )
-      !! Compute ustar squared as Cd || Uatm-Uoce ||^2 
-      !! needed for surface boundary condition of TKE 
+      IF( kt == nit000 ) ALLOCATE ( zrough( 1:jpi, 1:jpj ) )
+      !! Compute ustar squared as Cd || Uatm-Uoce ||^2
+      !! needed for surface boundary condition of TKE
       !! pwndm contains | U10m - U_oce | (see blk_oce_1 in sbcblk)
       DO_2D_11_11
          zzoce         = pCd_du    (ji,jj) * pwndm    (ji,jj)
 #if defined key_si3
-         zzice         = pCd_du_ice(ji,jj) * pwndm_ice(ji,jj) 
-         ustar2(ji,jj) = zzoce * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * zzice 
+         zzice         = pCd_du_ice(ji,jj) * pwndm_ice(ji,jj)
+         ustar2(ji,jj) = zzoce * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * zzice
 #else
-         ustar2(ji,jj) = zzoce	
+         ustar2(ji,jj) = zzoce
 #endif
+         zrough(ji,jj) = ght_abl(2) * EXP( - vkarmn / SQRT( MAX( Cdn_oce(ji,jj), 1.e-4 ) ) ) !<-- recover the value of z0 from Cdn_oce
       END_2D
       !
@@ -140,201 +142,247 @@
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 
-      CALL abl_zdf_tke( )                       !--> Avm_abl, Avt_abl, pblh defined on (1,jpi) x (1,jpj) 
-         
+      CALL abl_zdf_tke( )                       !--> Avm_abl, Avt_abl, pblh defined on (1,jpi) x (1,jpj)
+
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !                            !  2 *** Advance tracers to time n+1
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      
+
       !-------------
       DO jj = 1, jpj    ! outer loop             !--> tq_abl computed on (1:jpi) x (1:jpj)
-      !-------------    
-         ! Compute matrix elements for interior points 
+      !-------------
+         ! Compute matrix elements for interior points
          DO jk = 3, jpkam1
             DO ji = 1, jpi   ! vector opt.
-               z_elem_a( ji,     jk              ) = - rDt_abl * Avt_abl( ji, jj, jk-1 ) / e3w_abl( jk-1 )   ! lower-diagonal
-               z_elem_c( ji,     jk              ) = - rDt_abl * Avt_abl( ji, jj, jk   ) / e3w_abl( jk   )   ! upper-diagonal       
-               z_elem_b( ji,     jk              ) = e3t_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )   !       diagonal           
-            END DO
-         END DO  
-         ! Boundary conditions  
-         DO ji = 1, jpi   ! vector opt. 
-            ! Neumann at the bottom          
-            z_elem_a( ji,     2              ) = 0._wp
-            z_elem_c( ji,     2              ) = - rDt_abl * Avt_abl( ji, jj, 2   ) / e3w_abl( 2   )                                         
+               z_elem_a( ji, jk ) = - rDt_abl * Avt_abl( ji, jj, jk-1 ) / e3w_abl( jk-1 )   ! lower-diagonal
+               z_elem_c( ji, jk ) = - rDt_abl * Avt_abl( ji, jj, jk   ) / e3w_abl( jk   )   ! upper-diagonal
+               z_elem_b( ji, jk ) = e3t_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )   !       diagonal
+            END DO
+         END DO
+         ! Boundary conditions
+         DO ji = 1, jpi   ! vector opt.
+            ! Neumann at the bottom
+            z_elem_a( ji,    2 ) = 0._wp
+            z_elem_c( ji,    2 ) = - rDt_abl * Avt_abl( ji, jj,    2 ) / e3w_abl(    2 )
             ! Homogeneous Neumann at the top
-            z_elem_a( ji,     jpka           ) = - rDt_abl * Avt_abl( ji, jj, jpka ) / e3w_abl( jpka ) 
-            z_elem_c( ji,     jpka           ) = 0._wp
-            z_elem_b( ji,     jpka           ) = e3t_abl( jpka ) - z_elem_a( ji,     jpka )
-         END DO            
+            z_elem_a( ji, jpka ) = - rDt_abl * Avt_abl( ji, jj, jpka ) / e3w_abl( jpka )
+            z_elem_c( ji, jpka ) = 0._wp
+            z_elem_b( ji, jpka ) = e3t_abl( jpka ) - z_elem_a( ji, jpka )
+         END DO
 
          DO jtra = 1,jptq  ! loop on active tracers
-               
+
             DO jk = 3, jpkam1
-               DO ji = 1,jpi
-                  tq_abl  ( ji, jj, jk, nt_a, jtra ) = e3t_abl(jk) * tq_abl  ( ji, jj, jk, nt_n, jtra )   ! initialize right-hand-side
+               !DO ji = 2, jpim1
+               DO ji = 1,jpi  !!GS: to be checked if needed
+                  tq_abl( ji, jj, jk, nt_a, jtra ) = e3t_abl(jk) * tq_abl( ji, jj, jk, nt_n, jtra )   ! initialize right-hand-side
                END DO
             END DO
 
             IF(jtra == jp_ta) THEN
-               DO ji = 1,jpi  ! boundary conditions for temperature              
-                  zztmp1 = psen(ji, jj) 
-                  zztmp2 = psen(ji, jj) * ( psst(ji, jj) + rt0 )	
-#if defined key_si3				  
-                  zztmp1 = zztmp1 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * psen_ice(ji,jj) 
+               DO ji = 1,jpi  ! surface boundary condition for temperature
+                  zztmp1 = psen(ji, jj)
+                  zztmp2 = psen(ji, jj) * ( psst(ji, jj) + rt0 )
+#if defined key_si3
+                  zztmp1 = zztmp1 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * psen_ice(ji,jj)
                   zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * psen_ice(ji,jj) * ptm_su(ji,jj)
-#endif				  
-                  z_elem_b( ji,     2                ) = e3t_abl( 2 ) - z_elem_c( ji, 2 ) + rDt_abl * zztmp1				  
-                  tq_abl  ( ji, jj, 2   , nt_a, jtra ) = e3t_abl( 2    ) * tq_abl  ( ji, jj, 2   , nt_n, jtra ) + rDt_abl * zztmp2               
+#endif
+                  z_elem_b( ji,        2             ) = e3t_abl(    2 ) - z_elem_c( ji,        2             ) + rDt_abl * zztmp1
+                  tq_abl  ( ji, jj,    2, nt_a, jtra ) = e3t_abl(    2 ) * tq_abl  ( ji, jj,    2, nt_n, jtra ) + rDt_abl * zztmp2
                   tq_abl  ( ji, jj, jpka, nt_a, jtra ) = e3t_abl( jpka ) * tq_abl  ( ji, jj, jpka, nt_n, jtra )
-               END DO 
-            ELSE   
-               DO ji = 1,jpi  ! boundary conditions for humidity              
-                  zztmp1 = pevp(ji, jj) 
-                  zztmp2 = pevp(ji, jj) * pssq(ji, jj)   
-#if defined key_si3				  
-                  zztmp1 = zztmp1 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pevp_ice(ji,jj) 
-                  zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pevp_ice(ji, jj) * pssq_ice(ji, jj)    
-#endif	
-                  z_elem_b( ji,     2                ) = e3t_abl( 2 ) - z_elem_c( ji, 2 ) + rDt_abl * zztmp1
-                  tq_abl  ( ji, jj, 2   , nt_a, jtra ) = e3t_abl( 2    ) * tq_abl  ( ji, jj, 2   , nt_n, jtra ) + rDt_abl * zztmp2               
+               END DO
+            ELSE ! jp_qa
+               DO ji = 1,jpi  ! surface boundary condition for humidity
+                  zztmp1 = pevp(ji, jj)
+                  zztmp2 = pevp(ji, jj) * pssq(ji, jj)
+#if defined key_si3
+                  zztmp1 = zztmp1 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pevp_ice(ji,jj)
+                  zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pevp_ice(ji, jj) * pssq_ice(ji, jj)
+#endif
+                  z_elem_b( ji,     2                ) = e3t_abl(    2 ) - z_elem_c( ji,        2             ) + rDt_abl * zztmp1
+                  tq_abl  ( ji, jj, 2   , nt_a, jtra ) = e3t_abl(    2 ) * tq_abl  ( ji, jj,    2, nt_n, jtra ) + rDt_abl * zztmp2
                   tq_abl  ( ji, jj, jpka, nt_a, jtra ) = e3t_abl( jpka ) * tq_abl  ( ji, jj, jpka, nt_n, jtra )
-               END DO                                     
+               END DO
             END IF
             !!
             !! Matrix inversion
             !! ----------------------------------------------------------
-            DO ji = 1,jpi            
-               zcff                       =  1._wp / z_elem_b( ji, 2 )
-               zCF   (ji,   2           ) = - zcff * z_elem_c( ji, 2 )
-               tq_abl(ji,jj,2,nt_a,jtra) =    zcff * tq_abl(ji,jj,2,nt_a,jtra)
-            END DO             
-
-            DO jk = 3, jpka            
-               DO ji = 1,jpi            
-                  zcff = 1._wp / ( z_elem_b( ji, jk ) + z_elem_a( ji, jk ) * zCF   (ji, jk-1 ) )
+            DO ji = 1,jpi
+               zcff                            =  1._wp / z_elem_b( ji, 2 )
+               zCF   ( ji,     2             ) = - zcff * z_elem_c( ji, 2 )
+               tq_abl( ji, jj, 2, nt_a, jtra ) =   zcff * tq_abl( ji, jj, 2, nt_a, jtra )
+            END DO
+
+            DO jk = 3, jpka
+               DO ji = 1,jpi
+                  zcff = 1._wp / ( z_elem_b( ji, jk ) + z_elem_a( ji, jk ) * zCF( ji, jk-1 ) )
                   zCF(ji,jk) = - zcff * z_elem_c( ji, jk )
                   tq_abl(ji,jj,jk,nt_a,jtra) = zcff * ( tq_abl(ji,jj,jk  ,nt_a,jtra)   &
-                  &                - z_elem_a(ji, jk) * tq_abl(ji,jj,jk-1,nt_a,jtra) )
-               END DO
-            END DO
-!!FL at this point we could check positivity of tq_abl(:,:,:,nt_a,jp_qa) ... test to do ...         
-            DO jk = jpkam1,2,-1            
-               DO ji = 1,jpi  
+                     &           - z_elem_a(ji, jk) *   tq_abl(ji,jj,jk-1,nt_a,jtra) )
+               END DO
+            END DO
+            !!FL at this point we could check positivity of tq_abl(:,:,:,nt_a,jp_qa) ... test to do ...
+            DO jk = jpkam1,2,-1
+               DO ji = 1,jpi
                   tq_abl(ji,jj,jk,nt_a,jtra) = tq_abl(ji,jj,jk,nt_a,jtra) +    &
                      &                        zCF(ji,jk) * tq_abl(ji,jj,jk+1,nt_a,jtra)
                END DO
             END DO
-         
-         END DO   !<-- loop on tracers                    
-         !! 
-      !-------------
-      END DO             ! end outer loop 
-      !-------------   
-      
-      
+
+         END DO   !<-- loop on tracers
+         !!
+      !-------------
+      END DO             ! end outer loop
+      !-------------
+
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !                            !  3 *** Compute Coriolis term with geostrophic guide
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
-      !-------------        
-      DO jk = 2, jpka    ! outer loop
-      !-------------
-         !             
-         ! Advance u_abl & v_abl to time n+1
-         DO_2D_11_11
-            zcff = ( fft_abl(ji,jj) * rDt_abl )*( fft_abl(ji,jj) * rDt_abl )  ! (f dt)**2
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( SemiImp_Cor ) THEN
+
+         !-------------
+         DO jk = 2, jpka    ! outer loop
+         !-------------
+            !
+            ! Advance u_abl & v_abl to time n+1
+            DO_2D_11_11
+               zcff = ( fft_abl(ji,jj) * rDt_abl )*( fft_abl(ji,jj) * rDt_abl )  ! (f dt)**2
+
+               u_abl( ji, jj, jk, nt_a ) = e3t_abl(jk) *(                                          &
+                  &        (1._wp-gamma_Cor*(1._wp-gamma_Cor)*zcff) * u_abl( ji, jj, jk, nt_n )    &
+                  &                     + rDt_abl * fft_abl(ji, jj) * v_abl( ji, jj, jk, nt_n ) )  &
+                  &                               / (1._wp + gamma_Cor*gamma_Cor*zcff)
    
-            u_abl( ji, jj, jk, nt_a ) = e3t_abl(jk) *(  &
-               &        (1._wp-gamma_Cor*(1._wp-gamma_Cor)*zcff)*u_abl( ji, jj, jk, nt_n )    &
-               &                 +  rDt_abl * fft_abl(ji, jj) * v_abl ( ji , jj  , jk, nt_n ) )  &
-               &                               / (1._wp + gamma_Cor*gamma_Cor*zcff)
-               
-            v_abl( ji, jj, jk, nt_a ) =  e3t_abl(jk) *(  &
-               &        (1._wp-gamma_Cor*(1._wp-gamma_Cor)*zcff)*v_abl( ji, jj, jk, nt_n )   &
-               &                 -  rDt_abl * fft_abl(ji, jj) * u_abl ( ji   , jj, jk, nt_n )  ) &
-               &                                / (1._wp + gamma_Cor*gamma_Cor*zcff)                
-         END_2D
-         !                                   
-      !-------------
-      END DO             ! end outer loop  !<-- u_abl and v_abl are properly updated on (1:jpi) x (1:jpj)
-      !-------------                
-      !
-      IF( ln_geos_winds ) THEN
-         DO jj = 1, jpj    ! outer loop       
-            DO jk = 1, jpka
-               DO ji = 1, jpi 
-                  u_abl( ji, jj, jk, nt_a ) = u_abl( ji, jj, jk, nt_a )   &
-                     &                      - rDt_abl * e3t_abl(jk) * fft_abl(ji  , jj) * pgv_dta(ji  ,jj  ,jk)
-                  v_abl( ji, jj, jk, nt_a ) = v_abl( ji, jj, jk, nt_a )   &
-                     &                      + rDt_abl * e3t_abl(jk) * fft_abl(ji, jj  ) * pgu_dta(ji  ,jj  ,jk)
-               END DO
-            END DO
-         END DO      
-      END IF 
-      !-------------            
-      !
-      IF( ln_hpgls_frc ) THEN
-         DO jj = 1, jpj    ! outer loop       
-            DO jk = 1, jpka
-               DO ji = 1, jpi 
-                  u_abl( ji, jj, jk, nt_a ) = u_abl( ji, jj, jk, nt_a ) - rDt_abl * e3t_abl(jk) * pgu_dta(ji,jj,jk)
-                  v_abl( ji, jj, jk, nt_a ) = v_abl( ji, jj, jk, nt_a ) - rDt_abl * e3t_abl(jk) * pgv_dta(ji,jj,jk)  
+               v_abl( ji, jj, jk, nt_a ) =  e3t_abl(jk) *(                                         &
+                  &        (1._wp-gamma_Cor*(1._wp-gamma_Cor)*zcff) * v_abl( ji, jj, jk, nt_n )    &
+                  &                     - rDt_abl * fft_abl(ji, jj) * u_abl( ji, jj, jk, nt_n ) )  &
+                  &                               / (1._wp + gamma_Cor*gamma_Cor*zcff)
+            END_2D
+            !
+         !-------------
+         END DO             ! end outer loop  !<-- u_abl and v_abl are properly updated on (1:jpi) x (1:jpj)
+         !-------------
+         !
+         IF( ln_geos_winds ) THEN
+            DO jj = 1, jpj    ! outer loop
+               DO jk = 1, jpka
+                  DO ji = 1, jpi
+                     u_abl( ji, jj, jk, nt_a ) = u_abl( ji, jj, jk, nt_a )   &
+                        &                      - rDt_abl * e3t_abl(jk) * fft_abl(ji  , jj) * pgv_dta(ji  ,jj  ,jk)
+                     v_abl( ji, jj, jk, nt_a ) = v_abl( ji, jj, jk, nt_a )   &
+                        &                      + rDt_abl * e3t_abl(jk) * fft_abl(ji, jj  ) * pgu_dta(ji  ,jj  ,jk)
+                  END DO
+               END DO
+            END DO
+         END IF
+         !
+         IF( ln_hpgls_frc ) THEN
+            DO jj = 1, jpj    ! outer loop
+               DO jk = 1, jpka
+                  DO ji = 1, jpi
+                     u_abl( ji, jj, jk, nt_a ) = u_abl( ji, jj, jk, nt_a ) - rDt_abl * e3t_abl(jk) * pgu_dta(ji,jj,jk)
+                     v_abl( ji, jj, jk, nt_a ) = v_abl( ji, jj, jk, nt_a ) - rDt_abl * e3t_abl(jk) * pgv_dta(ji,jj,jk)
+                  ENDDO
                ENDDO
             ENDDO
-         ENDDO 
-      END IF
-	  
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      !                            !  4 *** Advance u,v to time n+1 
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
-      !
-      !  Vertical diffusion for u_abl     
+         END IF
+
+      ELSE ! SemiImp_Cor = .FALSE.
+
+         IF( ln_geos_winds ) THEN
+
+            !-------------
+            DO jk = 2, jpka    ! outer loop
+            !-------------
+               !
+               IF( MOD( kt, 2 ) == 0 ) then
+                  ! Advance u_abl & v_abl to time n+1
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        zcff = fft_abl(ji,jj) * ( v_abl ( ji , jj  , jk, nt_n ) - pgv_dta(ji  ,jj  ,jk)  )
+                        u_abl( ji, jj, jk, nt_a ) =                u_abl( ji, jj, jk, nt_n ) + rDt_abl * zcff
+                        zcff = fft_abl(ji,jj) * ( u_abl ( ji , jj  , jk, nt_a ) - pgu_dta(ji  ,jj  ,jk)  )
+                        v_abl( ji, jj, jk, nt_a ) = e3t_abl(jk) *( v_abl( ji, jj, jk, nt_n ) - rDt_abl * zcff )
+                        u_abl( ji, jj, jk, nt_a ) = e3t_abl(jk) *  u_abl( ji, jj, jk, nt_a )
+                     END DO
+                  END DO
+               ELSE
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        zcff = fft_abl(ji,jj) * ( u_abl ( ji , jj  , jk, nt_n ) - pgu_dta(ji  ,jj  ,jk)  )
+                        v_abl( ji, jj, jk, nt_a ) =                v_abl( ji, jj, jk, nt_n ) - rDt_abl * zcff
+                        zcff = fft_abl(ji,jj) * ( v_abl ( ji , jj  , jk, nt_a ) - pgv_dta(ji  ,jj  ,jk)  )
+                        u_abl( ji, jj, jk, nt_a ) = e3t_abl(jk) *( u_abl( ji, jj, jk, nt_n ) + rDt_abl * zcff )
+                        v_abl( ji, jj, jk, nt_a ) = e3t_abl(jk) *  v_abl( ji, jj, jk, nt_a )
+                     END DO
+                  END DO
+               END IF
+               !
+            !-------------
+            END DO             ! end outer loop  !<-- u_abl and v_abl are properly updated on (1:jpi) x (1:jpj)
+            !-------------
+
+         ENDIF ! ln_geos_winds
+
+      ENDIF ! SemiImp_Cor
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                            !  4 *** Advance u,v to time n+1
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      !  Vertical diffusion for u_abl
       !-------------
       DO jj = 1, jpj    ! outer loop
-      !-------------    
+      !-------------
 
          DO jk = 3, jpkam1
-            DO ji = 1, jpi  
-               z_elem_a( ji,     jk ) = - rDt_abl * Avm_abl( ji, jj, jk-1 ) / e3w_abl( jk-1 )  ! lower-diagonal
-               z_elem_c( ji,     jk ) = - rDt_abl * Avm_abl( ji, jj, jk   ) / e3w_abl( jk   )  ! upper-diagonal                
-               z_elem_b( ji,     jk ) = e3t_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )                             !       diagonal
-            END DO
-         END DO  
-            
-         DO ji = 2, jpi   ! boundary conditions   (Avm_abl and pcd_du must be available at ji=jpi)            
+            DO ji = 1, jpi
+               z_elem_a( ji, jk ) = - rDt_abl * Avm_abl( ji, jj, jk-1 ) / e3w_abl( jk-1 )  ! lower-diagonal
+               z_elem_c( ji, jk ) = - rDt_abl * Avm_abl( ji, jj, jk   ) / e3w_abl( jk   )  ! upper-diagonal
+               z_elem_b( ji, jk ) = e3t_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )  !       diagonal
+            END DO
+         END DO
+
+         DO ji = 2, jpi   ! boundary conditions   (Avm_abl and pcd_du must be available at ji=jpi)
             !++ Surface boundary condition
-            z_elem_a( ji,     2    ) = 0._wp
-            z_elem_c( ji,     2    ) = - rDt_abl * Avm_abl( ji, jj, 2   ) / e3w_abl( 2   )                                       
-            !
-			zztmp1  = pcd_du(ji, jj)
-			zztmp2  = 0.5_wp * pcd_du(ji, jj) * ( pssu(ji-1, jj) + pssu(ji,jj) )			
-#if defined key_si3				  
+            z_elem_a( ji, 2 ) = 0._wp
+            z_elem_c( ji, 2 ) = - rDt_abl * Avm_abl( ji, jj, 2 ) / e3w_abl( 2 )
+            !
+            zztmp1  = pcd_du(ji, jj)
+            zztmp2  = 0.5_wp * pcd_du(ji, jj) * ( pssu(ji-1, jj) + pssu(ji,jj) )
+#if defined key_si3
             zztmp1 = zztmp1 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pcd_du_ice(ji, jj)
-			zzice  = 0.5_wp * ( pssu_ice(ji-1, jj) + pssu_ice(ji,jj) )
-			zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pcd_du_ice(ji, jj) * zzice
-#endif           
-			z_elem_b( ji,     2       ) = e3t_abl( 2 ) - z_elem_c( ji, 2 ) + rDt_abl * zztmp1 			
+            zzice  = 0.5_wp * ( pssu_ice(ji-1, jj) + pssu_ice(ji, jj) )
+            zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pcd_du_ice(ji, jj) * zzice
+#endif
+            z_elem_b( ji,     2       ) = e3t_abl( 2 ) - z_elem_c( ji, 2 ) + rDt_abl * zztmp1
             u_abl( ji, jj,    2, nt_a ) =      u_abl( ji, jj,    2, nt_a ) + rDt_abl * zztmp2
-			
-            !++ Top Neumann B.C.
-            !z_elem_a( ji,     jpka ) = - 0.5_wp * rDt_abl * ( Avm_abl( ji, jj, jpka )+ Avm_abl( ji+1, jj, jpka ) ) / e3w_abl( jpka ) 
-            !z_elem_c( ji,     jpka ) = 0._wp
-            !z_elem_b( ji,     jpka ) = e3t_abl( jpka ) - z_elem_a( ji,     jpka )                                               
-            !++ Top Dirichlet B.C.
-            z_elem_a( ji,     jpka )       = 0._wp
-            z_elem_c( ji,     jpka )       = 0._wp
-            z_elem_b( ji,     jpka )       = e3t_abl( jpka )
-            u_abl   ( ji, jj, jpka, nt_a ) = e3t_abl( jpka ) * pu_dta(ji,jj,jk)              
-         END DO 
+
+            ! idealized test cases only
+            !IF( ln_topbc_neumann ) THEN
+            !   !++ Top Neumann B.C.
+            !   z_elem_a( ji,     jpka ) = - rDt_abl * Avm_abl( ji, jj, jpka ) / e3w_abl( jpka )
+            !   z_elem_c( ji,     jpka ) = 0._wp
+            !   z_elem_b( ji,     jpka ) = e3t_abl( jpka ) - z_elem_a( ji,     jpka )
+            !   !u_abl   ( ji, jj, jpka, nt_a ) = e3t_abl( jpka ) * u_abl   ( ji, jj, jpka, nt_a )
+            !ELSE
+               !++ Top Dirichlet B.C.
+               z_elem_a( ji,     jpka )       = 0._wp
+               z_elem_c( ji,     jpka )       = 0._wp
+               z_elem_b( ji,     jpka )       = e3t_abl( jpka )
+               u_abl   ( ji, jj, jpka, nt_a ) = e3t_abl( jpka ) * pu_dta(ji,jj,jk)
+            !ENDIF
+
+         END DO
          !!
          !! Matrix inversion
          !! ----------------------------------------------------------
-         DO ji = 2, jpi          
+         !DO ji = 2, jpi
+         DO ji = 1, jpi  !!GS: TBI
             zcff                 =   1._wp / z_elem_b( ji, 2 )
-            zCF   (ji,   2     ) =  - zcff * z_elem_c( ji, 2 ) 
+            zCF   (ji,   2     ) =  - zcff * z_elem_c( ji, 2 )
             u_abl (ji,jj,2,nt_a) =    zcff * u_abl(ji,jj,2,nt_a)
-         END DO             
-
-         DO jk = 3, jpka            
-            DO ji = 2, jpi              
+         END DO
+
+         DO jk = 3, jpka
+            DO ji = 2, jpi
                zcff = 1._wp / ( z_elem_b( ji, jk ) + z_elem_a( ji, jk ) * zCF   (ji, jk-1 ) )
                zCF(ji,jk) = - zcff * z_elem_c( ji, jk )
@@ -343,64 +391,71 @@
             END DO
          END DO
-            
-         DO jk = jpkam1,2,-1            
+
+         DO jk = jpkam1,2,-1
             DO ji = 2, jpi
                u_abl(ji,jj,jk,nt_a) = u_abl(ji,jj,jk,nt_a) + zCF(ji,jk) * u_abl(ji,jj,jk+1,nt_a)
             END DO
          END DO
-                                          
-      !-------------
-      END DO             ! end outer loop 
-      !-------------   
-
-      !
-      !  Vertical diffusion for v_abl     
+
+      !-------------
+      END DO             ! end outer loop
+      !-------------
+
+      !
+      !  Vertical diffusion for v_abl
       !-------------
       DO jj = 2, jpj   ! outer loop
-      !-------------    
+      !-------------
          !
          DO jk = 3, jpkam1
-            DO ji = 1, jpi   
-               z_elem_a( ji,     jk ) = -rDt_abl * Avm_abl( ji, jj, jk-1 ) / e3w_abl( jk-1 )   ! lower-diagonal
-               z_elem_c( ji,     jk ) = -rDt_abl * Avm_abl( ji, jj, jk   ) / e3w_abl( jk   )   ! upper-diagonal              
-               z_elem_b( ji,     jk ) = e3t_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )                              !       diagonal
-            END DO
-         END DO
-
-         DO ji = 1, jpi   ! boundary conditions (Avm_abl and pcd_du must be available at jj=jpj)          
+            DO ji = 1, jpi
+               z_elem_a( ji, jk ) = -rDt_abl * Avm_abl( ji, jj, jk-1 ) / e3w_abl( jk-1 )   ! lower-diagonal
+               z_elem_c( ji, jk ) = -rDt_abl * Avm_abl( ji, jj, jk   ) / e3w_abl( jk   )   ! upper-diagonal
+               z_elem_b( ji, jk ) = e3t_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )                              !       diagonal
+            END DO
+         END DO
+
+         DO ji = 1, jpi   ! boundary conditions (Avm_abl and pcd_du must be available at jj=jpj)
             !++ Surface boundary condition
-            z_elem_a( ji,     2    ) = 0._wp
-            z_elem_c( ji,     2    ) = - rDt_abl * Avm_abl( ji, jj, 2   ) / e3w_abl( 2   )        
-            !
-			zztmp1 = pcd_du(ji, jj)
-			zztmp2 = 0.5_wp * pcd_du(ji, jj) * ( pssv(ji, jj) + pssv(ji, jj-1) )  
-#if defined key_si3				  
+            z_elem_a( ji, 2 ) = 0._wp
+            z_elem_c( ji, 2 ) = - rDt_abl * Avm_abl( ji, jj, 2 ) / e3w_abl( 2 )
+            !
+            zztmp1 = pcd_du(ji, jj)
+            zztmp2 = 0.5_wp * pcd_du(ji, jj) * ( pssv(ji, jj) + pssv(ji, jj-1) )
+#if defined key_si3
             zztmp1 = zztmp1 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pcd_du_ice(ji, jj)
-			zzice  = 0.5_wp * ( pssv_ice(ji, jj) + pssv_ice(ji,jj-1) )
-			zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pcd_du_ice(ji, jj) * zzice
-#endif 			
-            z_elem_b( ji,     2       ) = e3t_abl( 2 ) - z_elem_c( ji, 2 ) + rDt_abl * zztmp1 
+            zzice  = 0.5_wp * ( pssv_ice(ji, jj) + pssv_ice(ji, jj-1) )
+            zztmp2 = zztmp2 * pfrac_oce(ji,jj) + (1._wp - pfrac_oce(ji,jj)) * pcd_du_ice(ji, jj) * zzice
+#endif
+            z_elem_b( ji,     2       ) = e3t_abl( 2 ) - z_elem_c( ji, 2 ) + rDt_abl * zztmp1
             v_abl( ji, jj,    2, nt_a ) =         v_abl( ji, jj, 2, nt_a ) + rDt_abl * zztmp2
-            !++ Top Neumann B.C.            
-            !z_elem_a( ji,     jpka ) = -rDt_abl * Avm_abl( ji, jj, jpka ) / e3w_abl( jpka ) 
-            !z_elem_c( ji,     jpka ) = 0._wp
-            !z_elem_b( ji,     jpka ) = e3t_abl( jpka ) - z_elem_a( ji,     jpka )                                               
-            !++ Top Dirichlet B.C.
-            z_elem_a( ji,     jpka )       = 0._wp
-            z_elem_c( ji,     jpka )       = 0._wp
-            z_elem_b( ji,     jpka )       = e3t_abl( jpka )
-            v_abl   ( ji, jj, jpka, nt_a ) = e3t_abl( jpka ) * pv_dta(ji,jj,jk)             
-         END DO 
+
+            ! idealized test cases only
+            !IF( ln_topbc_neumann ) THEN
+            !   !++ Top Neumann B.C.
+            !   z_elem_a( ji,     jpka ) = - rDt_abl * Avm_abl( ji, jj, jpka ) / e3w_abl( jpka )
+            !   z_elem_c( ji,     jpka ) = 0._wp
+            !   z_elem_b( ji,     jpka ) = e3t_abl( jpka ) - z_elem_a( ji,     jpka )
+            !   !v_abl   ( ji, jj, jpka, nt_a ) = e3t_abl( jpka ) * v_abl   ( ji, jj, jpka, nt_a )
+            !ELSE
+               !++ Top Dirichlet B.C.
+               z_elem_a( ji,     jpka )       = 0._wp
+               z_elem_c( ji,     jpka )       = 0._wp
+               z_elem_b( ji,     jpka )       = e3t_abl( jpka )
+               v_abl   ( ji, jj, jpka, nt_a ) = e3t_abl( jpka ) * pv_dta(ji,jj,jk)
+            !ENDIF
+
+         END DO
          !!
          !! Matrix inversion
          !! ----------------------------------------------------------
-         DO ji = 1, jpi              
+         DO ji = 1, jpi
             zcff                 =  1._wp / z_elem_b( ji, 2 )
-            zCF   (ji,   2     ) =   - zcff * z_elem_c( ji,     2       ) 
-            v_abl (ji,jj,2,nt_a) =     zcff * v_abl   ( ji, jj, 2, nt_a ) 
-         END DO             
-
-         DO jk = 3, jpka            
-            DO ji = 1, jpi                   
+            zCF   (ji,   2     ) =   - zcff * z_elem_c( ji,     2       )
+            v_abl (ji,jj,2,nt_a) =     zcff * v_abl   ( ji, jj, 2, nt_a )
+         END DO
+
+         DO jk = 3, jpka
+            DO ji = 1, jpi
                zcff = 1._wp / ( z_elem_b( ji, jk ) + z_elem_a( ji, jk ) * zCF   (ji, jk-1 ) )
                zCF(ji,jk) = - zcff * z_elem_c( ji, jk )
@@ -409,37 +464,35 @@
             END DO
          END DO
-            
-         DO jk = jpkam1,2,-1            
-            DO ji = 1, jpi    
+
+         DO jk = jpkam1,2,-1
+            DO ji = 1, jpi
                v_abl(ji,jj,jk,nt_a) = v_abl(ji,jj,jk,nt_a) + zCF(ji,jk) * v_abl(ji,jj,jk+1,nt_a)
             END DO
          END DO
-         !                                          
-      !-------------
-      END DO             ! end outer loop 
-      !-------------   
-    
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      !                            !  5 *** Apply nudging on the dynamics and the tracers 
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
-      z_cft(:,:,:) = 0._wp      
-      
+         !
+      !-------------
+      END DO             ! end outer loop
+      !-------------
+
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                            !  5 *** Apply nudging on the dynamics and the tracers
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
       IF( nn_dyn_restore > 0  ) THEN
-         !------------- 
+         !-------------
          DO jk = 2, jpka    ! outer loop
-         !-------------       
+         !-------------
             DO_2D_01_01
                zcff1 = pblh( ji, jj )
-               zsig  = ght_abl(jk) / MAX( jp_pblh_min,  MIN(  jp_pblh_max, zcff1  ) )                        
-               zsig  =               MIN( jp_bmax    ,  MAX(         zsig, jp_bmin) ) 
+               zsig  = ght_abl(jk) / MAX( jp_pblh_min,  MIN(  jp_pblh_max, zcff1  ) )
+               zsig  =               MIN( jp_bmax    ,  MAX(         zsig, jp_bmin) )
                zmsk  = msk_abl(ji,jj)
                zcff2 = jp_alp3_dyn * zsig**3 + jp_alp2_dyn * zsig**2   &
                   &  + jp_alp1_dyn * zsig    + jp_alp0_dyn
                zcff  = (1._wp-zmsk) + zmsk * zcff2 * rn_Dt   ! zcff = 1 for masked points
-                                                             ! rn_Dt = rDt_abl / nn_fsbc                          
+                                                             ! rn_Dt = rDt_abl / nn_fsbc
                zcff  = zcff * rest_eq(ji,jj)
-               z_cft( ji, jj, jk ) = zcff
                u_abl( ji, jj, jk, nt_a ) = (1._wp - zcff ) *  u_abl( ji, jj, jk, nt_a )   &
-                  &                               + zcff   * pu_dta( ji, jj, jk       )                      
+                  &                               + zcff   * pu_dta( ji, jj, jk       )
                v_abl( ji, jj, jk, nt_a ) = (1._wp - zcff ) *  v_abl( ji, jj, jk, nt_a )   &
                   &                               + zcff   * pv_dta( ji, jj, jk       )
@@ -447,38 +500,39 @@
          !-------------
          END DO             ! end outer loop
-         !-------------               
+         !-------------
       END IF
 
-      !------------- 
+      !-------------
       DO jk = 2, jpka    ! outer loop
-      !-------------       
+      !-------------
          DO_2D_11_11
             zcff1 = pblh( ji, jj )
             zsig  = ght_abl(jk) / MAX( jp_pblh_min,  MIN(  jp_pblh_max, zcff1  ) )
-            zsig  =               MIN( jp_bmax    ,  MAX(         zsig, jp_bmin) ) 
+            zsig  =               MIN( jp_bmax    ,  MAX(         zsig, jp_bmin) )
             zmsk  = msk_abl(ji,jj)
             zcff2 = jp_alp3_tra * zsig**3 + jp_alp2_tra * zsig**2   &
                &  + jp_alp1_tra * zsig    + jp_alp0_tra
             zcff  = (1._wp-zmsk) + zmsk * zcff2 * rn_Dt   ! zcff = 1 for masked points
-                                                          ! rn_Dt = rDt_abl / nn_fsbc                          
-            !z_cft( ji, jj, jk ) = zcff
+                                                          ! rn_Dt = rDt_abl / nn_fsbc
             tq_abl( ji, jj, jk, nt_a, jp_ta ) = (1._wp - zcff ) * tq_abl( ji, jj, jk, nt_a, jp_ta )   &
                &                                       + zcff   * pt_dta( ji, jj, jk )
-            
+
             tq_abl( ji, jj, jk, nt_a, jp_qa ) = (1._wp - zcff ) * tq_abl( ji, jj, jk, nt_a, jp_qa )   &
                &                                       + zcff   * pq_dta( ji, jj, jk )
-            
+
          END_2D
       !-------------
       END DO             ! end outer loop
-      !------------- 	  
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      !                            !  6 *** MPI exchanges  
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      !
-      CALL lbc_lnk_multi( 'ablmod',  u_abl(:,:,:,nt_a      ), 'T', -1.,  v_abl(:,:,:,nt_a      ), 'T', -1. )
+      !-------------
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !                            !  6 *** MPI exchanges
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
+      CALL lbc_lnk_multi( 'ablmod',  u_abl(:,:,:,nt_a      ), 'T', -1.,  v_abl(:,:,:,nt_a)      , 'T', -1.                            )
       CALL lbc_lnk_multi( 'ablmod', tq_abl(:,:,:,nt_a,jp_ta), 'T',  1., tq_abl(:,:,:,nt_a,jp_qa), 'T',  1., kfillmode = jpfillnothing )   ! ++++ this should not be needed...
       !
-      ! first ABL level
+#if defined key_iomput
+      ! 2D & first ABL level
+      IF ( iom_use("pblh"   ) ) CALL iom_put (    "pblh",    pblh(:,:             ) )
       IF ( iom_use("uz1_abl") ) CALL iom_put ( "uz1_abl",   u_abl(:,:,2,nt_a      ) )
       IF ( iom_use("vz1_abl") ) CALL iom_put ( "vz1_abl",   v_abl(:,:,2,nt_a      ) )
@@ -489,49 +543,55 @@
       IF ( iom_use("tz1_dta") ) CALL iom_put ( "tz1_dta",  pt_dta(:,:,2           ) )
       IF ( iom_use("qz1_dta") ) CALL iom_put ( "qz1_dta",  pq_dta(:,:,2           ) )
-      ! all ABL levels
-      IF ( iom_use("u_abl"  ) ) CALL iom_put ( "u_abl"  ,   u_abl(:,:,2:jpka,nt_a      ) )
-      IF ( iom_use("v_abl"  ) ) CALL iom_put ( "v_abl"  ,   v_abl(:,:,2:jpka,nt_a      ) )
-      IF ( iom_use("t_abl"  ) ) CALL iom_put ( "t_abl"  ,  tq_abl(:,:,2:jpka,nt_a,jp_ta) )
-      IF ( iom_use("q_abl"  ) ) CALL iom_put ( "q_abl"  ,  tq_abl(:,:,2:jpka,nt_a,jp_qa) )
-      IF ( iom_use("tke_abl") ) CALL iom_put ( "tke_abl", tke_abl(:,:,2:jpka,nt_a      ) )
-      IF ( iom_use("avm_abl") ) CALL iom_put ( "avm_abl", avm_abl(:,:,2:jpka           ) )
-      IF ( iom_use("avt_abl") ) CALL iom_put ( "avt_abl", avm_abl(:,:,2:jpka           ) )
-      IF ( iom_use("mxl_abl") ) CALL iom_put ( "mxl_abl", mxl_abl(:,:,2:jpka           ) )
-      IF ( iom_use("pblh"   ) ) CALL iom_put (  "pblh"  ,    pblh(:,:                  ) )
-      ! debug (to be removed)
+      ! debug 2D
+      IF( ln_geos_winds ) THEN
+         IF ( iom_use("uz1_geo") ) CALL iom_put ( "uz1_geo", pgu_dta(:,:,2) )
+         IF ( iom_use("vz1_geo") ) CALL iom_put ( "vz1_geo", pgv_dta(:,:,2) )
+      END IF
+      IF( ln_hpgls_frc ) THEN
+         IF ( iom_use("uz1_geo") ) CALL iom_put ( "uz1_geo",  pgu_dta(:,:,2)/MAX(fft_abl(:,:),2.5e-5_wp) )
+         IF ( iom_use("vz1_geo") ) CALL iom_put ( "vz1_geo", -pgv_dta(:,:,2)/MAX(fft_abl(:,:),2.5e-5_wp) )
+      END IF
+      ! 3D (all ABL levels)
+      IF ( iom_use("u_abl"   ) ) CALL iom_put ( "u_abl"   ,    u_abl(:,:,2:jpka,nt_a      ) )
+      IF ( iom_use("v_abl"   ) ) CALL iom_put ( "v_abl"   ,    v_abl(:,:,2:jpka,nt_a      ) )
+      IF ( iom_use("t_abl"   ) ) CALL iom_put ( "t_abl"   ,   tq_abl(:,:,2:jpka,nt_a,jp_ta) )
+      IF ( iom_use("q_abl"   ) ) CALL iom_put ( "q_abl"   ,   tq_abl(:,:,2:jpka,nt_a,jp_qa) )
+      IF ( iom_use("tke_abl" ) ) CALL iom_put ( "tke_abl" ,  tke_abl(:,:,2:jpka,nt_a      ) )
+      IF ( iom_use("avm_abl" ) ) CALL iom_put ( "avm_abl" ,  avm_abl(:,:,2:jpka           ) )
+      IF ( iom_use("avt_abl" ) ) CALL iom_put ( "avt_abl" ,  avt_abl(:,:,2:jpka           ) )
+      IF ( iom_use("mxlm_abl") ) CALL iom_put ( "mxlm_abl", mxlm_abl(:,:,2:jpka           ) )
+      IF ( iom_use("mxld_abl") ) CALL iom_put ( "mxld_abl", mxld_abl(:,:,2:jpka           ) )
+      ! debug 3D
       IF ( iom_use("u_dta") ) CALL iom_put ( "u_dta",  pu_dta(:,:,2:jpka) )
       IF ( iom_use("v_dta") ) CALL iom_put ( "v_dta",  pv_dta(:,:,2:jpka) )
       IF ( iom_use("t_dta") ) CALL iom_put ( "t_dta",  pt_dta(:,:,2:jpka) )
       IF ( iom_use("q_dta") ) CALL iom_put ( "q_dta",  pq_dta(:,:,2:jpka) )
-      IF ( iom_use("coeft") ) CALL iom_put ( "coeft",   z_cft(:,:,2:jpka) )
       IF( ln_geos_winds ) THEN
-         IF ( iom_use("uz1_geo") ) CALL iom_put ( "uz1_geo", pgu_dta(:,:,2           ) )
-         IF ( iom_use("vz1_geo") ) CALL iom_put ( "vz1_geo", pgv_dta(:,:,2           ) )
+         IF ( iom_use("u_geo") ) CALL iom_put ( "u_geo", pgu_dta(:,:,2:jpka) )
+         IF ( iom_use("v_geo") ) CALL iom_put ( "v_geo", pgv_dta(:,:,2:jpka) )
       END IF
       IF( ln_hpgls_frc ) THEN
-         IF ( iom_use("uz1_geo") ) CALL iom_put ( "uz1_geo",  pgu_dta(:,:,2)/MAX(fft_abl(:,:),2.5e-5_wp)   )
-         IF ( iom_use("vz1_geo") ) CALL iom_put ( "vz1_geo", -pgv_dta(:,:,2)/MAX(fft_abl(:,:),2.5e-5_wp)   )
+         IF ( iom_use("u_geo") ) CALL iom_put ( "u_geo",  pgu_dta(:,:,2:jpka)/MAX( RESHAPE( fft_abl(:,:), (/jpi,jpj,jpka-1/), fft_abl(:,:)), 2.5e-5_wp) )
+         IF ( iom_use("v_geo") ) CALL iom_put ( "v_geo", -pgv_dta(:,:,2:jpka)/MAX( RESHAPE( fft_abl(:,:), (/jpi,jpj,jpka-1/), fft_abl(:,:)), 2.5e-5_wp) )
       END IF
-      !
+#endif
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !                            !  7 *** Finalize flux computation
-      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
-
+      !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      !
       DO_2D_11_11
-         ztemp             = tq_abl  ( ji, jj, 2, nt_a, jp_ta ) 
-         zhumi             = tq_abl  ( ji, jj, 2, nt_a, jp_qa ) 
-         !zcff              = pslp_dta( ji, jj ) /   &              !<-- At this point ztemp and zhumi should not be zero ...
-         !   &                        (  R_dry*ztemp * ( 1._wp + rctv0*zhumi )  )
-         zcff              = rho_air( ztemp, zhumi, pslp_dta( ji, jj ) )
-         psen ( ji, jj )   =      cp_air(zhumi) * zcff * psen(ji,jj) * ( psst(ji,jj) + rt0 - ztemp )
-         pevp ( ji, jj )   = rn_efac*MAX( 0._wp,  zcff * pevp(ji,jj) * ( pssq(ji,jj)       - zhumi ) )
-         rhoa( ji, jj )   = zcff              
+         ztemp          =  tq_abl( ji, jj, 2, nt_a, jp_ta )
+         zhumi          =  tq_abl( ji, jj, 2, nt_a, jp_qa )
+         zcff           = rho_air( ztemp, zhumi, pslp_dta( ji, jj ) )
+         psen( ji, jj ) =    - cp_air(zhumi) * zcff * psen(ji,jj) * ( psst(ji,jj) + rt0 - ztemp )   !GS: negative sign to respect aerobulk convention
+         pevp( ji, jj ) = rn_efac*MAX( 0._wp,  zcff * pevp(ji,jj) * ( pssq(ji,jj)       - zhumi ) )
+         rhoa( ji, jj ) = zcff
       END_2D
-      
+
       DO_2D_01_01
-         zwnd_i(ji,jj) = u_abl(ji  ,jj,2,nt_a) - 0.5_wp * rn_vfac * ( pssu(ji  ,jj) + pssu(ji-1,jj) )  
-         zwnd_j(ji,jj) = v_abl(ji,jj  ,2,nt_a) - 0.5_wp * rn_vfac * ( pssv(ji,jj  ) + pssv(ji,jj-1) ) 
+         zwnd_i(ji,jj) = u_abl(ji  ,jj,2,nt_a) - 0.5_wp * ( pssu(ji  ,jj) + pssu(ji-1,jj) )  
+         zwnd_j(ji,jj) = v_abl(ji,jj  ,2,nt_a) - 0.5_wp * ( pssv(ji,jj  ) + pssv(ji,jj-1) ) 
       END_2D
-      ! 
+      !
       CALL lbc_lnk_multi( 'ablmod', zwnd_i(:,:) , 'T', -1., zwnd_j(:,:) , 'T', -1. )
       !
@@ -539,7 +599,7 @@
       DO_2D_11_11
          zcff          = SQRT(  zwnd_i(ji,jj) * zwnd_i(ji,jj)   &
-            &                 + zwnd_j(ji,jj) * zwnd_j(ji,jj)  )  ! * msk_abl(ji,jj)
+            &                 + zwnd_j(ji,jj) * zwnd_j(ji,jj) )   ! * msk_abl(ji,jj)
          zztmp         = rhoa(ji,jj) * pcd_du(ji,jj)
-         
+
          pwndm (ji,jj) =         zcff
          ptaum (ji,jj) = zztmp * zcff
@@ -564,29 +624,44 @@
 
       IF(sn_cfctl%l_prtctl) THEN
-         CALL prt_ctl( tab2d_1=pwndm  , clinfo1=' abl_stp: wndm   : ' )
-         CALL prt_ctl( tab2d_1=ptaui  , clinfo1=' abl_stp: utau   : ',   &
-            &          tab2d_2=ptauj  , clinfo2=          'vtau   : ' )
+         CALL prt_ctl( tab2d_1=ptaui , clinfo1=' abl_stp: utau   : ', mask1=umask,   &
+            &          tab2d_2=ptauj , clinfo2='          vtau   : ', mask2=vmask )
+         CALL prt_ctl( tab2d_1=pwndm , clinfo1=' abl_stp: wndm   : ' )
       ENDIF
 
 #if defined key_si3
-         ! ------------------------------------------------------------ !
-         !    Wind stress relative to the moving ice ( U10m - U_ice )   !
-         ! ------------------------------------------------------------ !
-         DO_2D_00_00
-            
-            zztmp1 = 0.5_wp * ( u_abl(ji+1,jj,2,nt_a) + u_abl(ji,jj,2,nt_a) )
-            zztmp2 = 0.5_wp * ( v_abl(ji,jj+1,2,nt_a) + v_abl(ji,jj,2,nt_a) )
-   
-            ptaui_ice(ji,jj) = 0.5_wp * (  rhoa(ji+1,jj) * pCd_du_ice(ji+1,jj)             &
-               &                      +    rhoa(ji  ,jj) * pCd_du_ice(ji  ,jj)  )          &
-               &         * ( zztmp1 - rn_vfac * pssu_ice(ji,jj) )
-            ptauj_ice(ji,jj) = 0.5_wp * (  rhoa(ji,jj+1) * pCd_du_ice(ji,jj+1)             &
-               &                      +    rhoa(ji,jj  ) * pCd_du_ice(ji,jj  )  )          &
-               &         * ( zztmp2 - rn_vfac * pssv_ice(ji,jj) )
-         END_2D
-         CALL lbc_lnk_multi( 'ablmod', ptaui_ice, 'U', -1., ptauj_ice, 'V', -1. )
-         !
-         IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab2d_1=ptaui_ice  , clinfo1=' abl_stp: putaui : '   &
-            &                                , tab2d_2=ptauj_ice  , clinfo2='          pvtaui : ' )
+      ! ------------------------------------------------------------ !
+      !    Wind stress relative to the moving ice ( U10m - U_ice )   !
+      ! ------------------------------------------------------------ !
+      DO_2D_00_00           
+         ptaui_ice(ji,jj) = 0.5_wp * ( rhoa(ji+1,jj) * pCd_du_ice(ji+1,jj) + rhoa(ji,jj) * pCd_du_ice(ji,jj)      )   &
+            &                      * ( 0.5_wp * ( u_abl(ji+1,jj,2,nt_a) + u_abl(ji,jj,2,nt_a) ) - pssu_ice(ji,jj) )
+         ptauj_ice(ji,jj) = 0.5_wp * ( rhoa(ji,jj+1) * pCd_du_ice(ji,jj+1) + rhoa(ji,jj) * pCd_du_ice(ji,jj)      )   &
+            &                      * ( 0.5_wp * ( v_abl(ji,jj+1,2,nt_a) + v_abl(ji,jj,2,nt_a) ) - pssv_ice(ji,jj) )
+      END_2D
+      CALL lbc_lnk_multi( 'ablmod', ptaui_ice, 'U', -1., ptauj_ice, 'V', -1. )
+      !
+      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab2d_1=ptaui_ice  , clinfo1=' abl_stp: putaui : '   &
+         &                                , tab2d_2=ptauj_ice  , clinfo2='          pvtaui : ' )
+      ! ------------------------------------------------------------ !
+      !    Wind stress relative to the moving ice ( U10m - U_ice )   !
+      ! ------------------------------------------------------------ !
+      DO_2D_00_00
+
+         zztmp1 = 0.5_wp * ( u_abl(ji+1,jj  ,2,nt_a) + u_abl(ji,jj,2,nt_a) )
+         zztmp2 = 0.5_wp * ( v_abl(ji  ,jj+1,2,nt_a) + v_abl(ji,jj,2,nt_a) )
+
+         ptaui_ice(ji,jj) = 0.5_wp * (  rhoa(ji+1,jj) * pCd_du_ice(ji+1,jj)             &
+            &                      +    rhoa(ji  ,jj) * pCd_du_ice(ji  ,jj)  )          &
+            &         * ( zztmp1 - pssu_ice(ji,jj) )
+         ptauj_ice(ji,jj) = 0.5_wp * (  rhoa(ji,jj+1) * pCd_du_ice(ji,jj+1)             &
+            &                      +    rhoa(ji,jj  ) * pCd_du_ice(ji,jj  )  )          &
+            &         * ( zztmp2 - pssv_ice(ji,jj) )
+      END_2D
+      CALL lbc_lnk_multi( 'ablmod', ptaui_ice, 'U', -1., ptauj_ice, 'V', -1. )
+      !
+      IF(sn_cfctl%l_prtctl) THEN
+         CALL prt_ctl( tab2d_1=ptaui_ice , clinfo1=' abl_stp: utau_ice : ', mask1=umask,   &
+            &          tab2d_2=ptauj_ice , clinfo2='          vtau_ice : ', mask2=vmask )
+      END IF
 #endif
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -599,17 +674,4 @@
    END SUBROUTINE abl_stp
 !===================================================================================================
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 
@@ -634,13 +696,13 @@
       !!                (= Kz dz[Ub] * dz[Un] )
       !! ---------------------------------------------------------------------
-      INTEGER                                 ::   ji, jj, jk, tind, jbak, jkup, jkdwn 
+      INTEGER                                 ::   ji, jj, jk, tind, jbak, jkup, jkdwn
       INTEGER, DIMENSION(1:jpi          )     ::   ikbl
       REAL(wp)                                ::   zcff, zcff2, ztken, zesrf, zetop, ziRic, ztv
-      REAL(wp)                                ::   zdU, zdV, zcff1,zshear,zbuoy,zsig, zustar2
-      REAL(wp)                                ::   zdU2,zdV2      
-      REAL(wp)                                ::   zwndi,zwndj
+      REAL(wp)                                ::   zdU , zdV , zcff1, zshear, zbuoy, zsig, zustar2
+      REAL(wp)                                ::   zdU2, zdV2, zbuoy1, zbuoy2    ! zbuoy for BL89
+      REAL(wp)                                ::   zwndi, zwndj
       REAL(wp), DIMENSION(1:jpi,      1:jpka) ::   zsh2
       REAL(wp), DIMENSION(1:jpi,1:jpj,1:jpka) ::   zbn2
-      REAL(wp), DIMENSION(1:jpi,1:jpka  )     ::   zFC, zRH, zCF       
+      REAL(wp), DIMENSION(1:jpi,1:jpka  )     ::   zFC, zRH, zCF
       REAL(wp), DIMENSION(1:jpi,1:jpka  )     ::   z_elem_a
       REAL(wp), DIMENSION(1:jpi,1:jpka  )     ::   z_elem_b
@@ -648,5 +710,5 @@
       LOGICAL                                 ::   ln_Patankar    = .FALSE.
       LOGICAL                                 ::   ln_dumpvar     = .FALSE.
-      LOGICAL , DIMENSION(1:jpi         )     ::   ln_foundl 
+      LOGICAL , DIMENSION(1:jpi         )     ::   ln_foundl
       !
       tind  = nt_n
@@ -660,18 +722,18 @@
       !-------------
          !
-         ! Compute vertical shear         
+         ! Compute vertical shear
          DO jk = 2, jpkam1
-            DO ji = 1,jpi  
-               zcff        = 1.0_wp / e3w_abl( jk )**2                
-               zdU         = zcff* Avm_abl(ji,jj,jk) * (u_abl( ji, jj, jk+1, tind)-u_abl( ji, jj, jk  , tind) )**2                           
+            DO ji = 1, jpi
+               zcff        = 1.0_wp / e3w_abl( jk )**2
+               zdU         = zcff* Avm_abl(ji,jj,jk) * (u_abl( ji, jj, jk+1, tind)-u_abl( ji, jj, jk  , tind) )**2
                zdV         = zcff* Avm_abl(ji,jj,jk) * (v_abl( ji, jj, jk+1, tind)-v_abl( ji, jj, jk  , tind) )**2
-               zsh2(ji,jk) = zdU+zdV
-            END DO
-         END DO   
+               zsh2(ji,jk) = zdU+zdV   !<-- zsh2 = Km ( ( du/dz )^2 + ( dv/dz )^2 )
+            END DO
+         END DO
          !
          ! Compute brunt-vaisala frequency
          DO jk = 2, jpkam1
-            DO ji = 1,jpi 
-               zcff  = grav * itvref / e3w_abl( jk )  
+            DO ji = 1,jpi
+               zcff  = grav * itvref / e3w_abl( jk )
                zcff1 =  tq_abl( ji, jj, jk+1, tind, jp_ta) - tq_abl( ji, jj, jk  , tind, jp_ta)
                zcff2 =  tq_abl( ji, jj, jk+1, tind, jp_ta) * tq_abl( ji, jj, jk+1, tind, jp_qa)        &
@@ -679,40 +741,54 @@
                zbn2(ji,jj,jk) = zcff * ( zcff1 + rctv0 * zcff2 )  !<-- zbn2 defined on (2,jpi)
             END DO
-         END DO 
+         END DO
          !
          ! Terms for the tridiagonal problem
          DO jk = 2, jpkam1
-            DO ji = 1,jpi 
-               zshear       =                 zsh2( ji,     jk )   ! zsh2 is already multiplied by Avm_abl at this point
-               zsh2(ji,jk)  = zsh2( ji, jk ) / Avm_abl( ji, jj, jk )   ! reformulate zsh2 as a 'true' vertical shear for PBLH computation          
-               zbuoy        = - Avt_abl( ji, jj, jk ) * zbn2( ji, jj, jk ) 
-               
-               z_elem_a( ji,     jk )   = - 0.5_wp * rDt_abl * rn_Sch * ( Avm_abl( ji, jj, jk   )+Avm_abl( ji, jj, jk-1 ) ) / e3t_abl( jk   ) ! lower-diagonal
-               z_elem_c( ji,     jk )   = - 0.5_wp * rDt_abl * rn_Sch * ( Avm_abl( ji, jj, jk   )+Avm_abl( ji, jj, jk+1 ) ) / e3t_abl( jk+1 ) ! upper-diagonal          
+            DO ji = 1, jpi
+               zshear      = zsh2( ji, jk )                           ! zsh2 is already multiplied by Avm_abl at this point
+               zsh2(ji,jk) = zsh2( ji, jk ) / Avm_abl( ji, jj, jk )   ! reformulate zsh2 as a 'true' vertical shear for PBLH computation
+               zbuoy       = - Avt_abl( ji, jj, jk ) * zbn2( ji, jj, jk )
+
+               z_elem_a( ji, jk ) = - 0.5_wp * rDt_abl * rn_Sch * ( Avm_abl( ji, jj, jk ) + Avm_abl( ji, jj, jk-1 ) ) / e3t_abl( jk   ) ! lower-diagonal
+               z_elem_c( ji, jk ) = - 0.5_wp * rDt_abl * rn_Sch * ( Avm_abl( ji, jj, jk ) + Avm_abl( ji, jj, jk+1 ) ) / e3t_abl( jk+1 ) ! upper-diagonal
                IF( (zbuoy + zshear) .gt. 0.) THEN    ! Patankar trick to avoid negative values of TKE
-                  z_elem_b( ji,     jk )   = e3w_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )   &
-                     &                     + e3w_abl(jk) * rDt_abl * rn_Ceps * sqrt(tke_abl( ji, jj, jk, nt_n )) / mxl_abl(ji,jj,jk)     ! diagonal       
-                  tke_abl( ji, jj, jk, nt_a )  = e3w_abl(jk) * ( tke_abl( ji, jj, jk, nt_n ) + rDt_abl * ( zbuoy + zshear ) )             ! right-hand-side
+                  z_elem_b( ji, jk ) = e3w_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )   &
+                     &               + e3w_abl(jk) * rDt_abl * rn_Ceps * sqrt(tke_abl( ji, jj, jk, nt_n )) / mxld_abl(ji,jj,jk)    ! diagonal
+                  tke_abl( ji, jj, jk, nt_a ) = e3w_abl(jk) * ( tke_abl( ji, jj, jk, nt_n ) + rDt_abl * ( zbuoy + zshear ) )       ! right-hand-side
                ELSE
-                  z_elem_b( ji,     jk )   = e3w_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )   &
-                     &                     + e3w_abl(jk) * rDt_abl * rn_Ceps * sqrt(tke_abl( ji, jj, jk, nt_n )) / mxl_abl(ji,jj,jk)   &  ! diagonal    
-                     &                     - e3w_abl(jk) * rDt_abl * zbuoy   
-                  tke_abl( ji, jj, jk, nt_a )  = e3w_abl(jk) * ( tke_abl( ji, jj, jk, nt_n ) + rDt_abl *  zshear )             ! right-hand-side                     
+                  z_elem_b( ji, jk ) = e3w_abl(jk) - z_elem_a( ji, jk ) - z_elem_c( ji, jk )   &
+                     &               + e3w_abl(jk) * rDt_abl * rn_Ceps * sqrt(tke_abl( ji, jj, jk, nt_n )) / mxld_abl(ji,jj,jk)   &  ! diagonal
+                     &               - e3w_abl(jk) * rDt_abl * zbuoy
+                  tke_abl( ji, jj, jk, nt_a ) = e3w_abl(jk) * ( tke_abl( ji, jj, jk, nt_n ) + rDt_abl *  zshear )                    ! right-hand-side
                END IF
             END DO
-         END DO  
-                            
-         DO ji = 1,jpi    ! vector opt.            
-            zesrf   =  MAX( 4.63_wp * ustar2(ji,jj), tke_min )           
-            zetop   = tke_min             
-            z_elem_a ( ji,     1    ) = 0._wp; z_elem_c ( ji,     1    ) = 0._wp; z_elem_b ( ji,     1    ) = 1._wp                                                   
-            z_elem_a ( ji,     jpka ) = 0._wp; z_elem_c ( ji,     jpka ) = 0._wp; z_elem_b ( ji,     jpka ) = 1._wp            
-            tke_abl( ji, jj,    1, nt_a ) = zesrf
-            tke_abl( ji, jj, jpka, nt_a ) = zetop 
-            zbn2(ji,jj,   1) = zbn2( ji,jj,   2) 
-            zsh2(ji,      1) = zsh2( ji,      2)                                      
-            zbn2(ji,jj,jpka) = zbn2( ji,jj,jpkam1) 
-            zsh2(ji,   jpka) = zsh2( ji  , jpkam1)
-         END DO        
+         END DO
+
+         DO ji = 1,jpi    ! vector opt.
+            zesrf = MAX( rn_Esfc * ustar2(ji,jj), tke_min )
+            zetop = tke_min
+
+            z_elem_a ( ji,     1       ) = 0._wp
+            z_elem_c ( ji,     1       ) = 0._wp
+            z_elem_b ( ji,     1       ) = 1._wp
+            tke_abl  ( ji, jj, 1, nt_a ) = zesrf
+
+            !++ Top Neumann B.C.
+            !z_elem_a ( ji,     jpka       ) = - 0.5 * rDt_abl * rn_Sch * (Avm_abl(ji,jj, jpka-1 )+Avm_abl(ji,jj, jpka ))  / e3t_abl( jpka )
+            !z_elem_c ( ji,     jpka       ) = 0._wp
+            !z_elem_b ( ji,     jpka       ) = e3w_abl(jpka) - z_elem_a(ji, jpka )
+            !tke_abl  ( ji, jj, jpka, nt_a ) = e3w_abl(jpka) * tke_abl( ji,jj, jpka, nt_n )
+
+            !++ Top Dirichlet B.C.
+            z_elem_a ( ji,     jpka       ) = 0._wp
+            z_elem_c ( ji,     jpka       ) = 0._wp
+            z_elem_b ( ji,     jpka       ) = 1._wp
+            tke_abl  ( ji, jj, jpka, nt_a ) = zetop
+
+            zbn2 ( ji, jj,    1 ) = zbn2 ( ji, jj,      2 )
+            zsh2 ( ji,        1 ) = zsh2 ( ji,          2 )
+            zbn2 ( ji, jj, jpka ) = zbn2 ( ji, jj, jpkam1 )
+            zsh2 ( ji,     jpka ) = zsh2 ( ji    , jpkam1 )
+         END DO
          !!
          !! Matrix inversion
@@ -720,9 +796,9 @@
          DO ji = 1,jpi
             zcff                  =  1._wp / z_elem_b( ji, 1 )
-            zCF    (ji,   1     ) = - zcff * z_elem_c( ji,     1       ) 
-            tke_abl(ji,jj,1,nt_a) =   zcff * tke_abl ( ji, jj, 1, nt_a ) 
-         END DO             
-
-         DO jk = 2, jpka            
+            zCF    (ji,   1     ) = - zcff * z_elem_c( ji,     1       )
+            tke_abl(ji,jj,1,nt_a) =   zcff * tke_abl ( ji, jj, 1, nt_a )
+         END DO
+
+         DO jk = 2, jpka
             DO ji = 1,jpi
                zcff = 1._wp / ( z_elem_b( ji, jk ) + z_elem_a( ji, jk ) * zCF(ji, jk-1 ) )
@@ -732,12 +808,12 @@
             END DO
          END DO
-            
-         DO jk = jpkam1,1,-1            
+
+         DO jk = jpkam1,1,-1
             DO ji = 1,jpi
                tke_abl(ji,jj,jk,nt_a) = tke_abl(ji,jj,jk,nt_a) + zCF(ji,jk) * tke_abl(ji,jj,jk+1,nt_a)
             END DO
          END DO
-         
-!!FL should not be needed because of Patankar procedure  
+
+!!FL should not be needed because of Patankar procedure
          tke_abl(2:jpi,jj,1:jpka,nt_a) = MAX( tke_abl(2:jpi,jj,1:jpka,nt_a), tke_min )
 
@@ -745,15 +821,15 @@
          !! Diagnose PBL height
          !! ----------------------------------------------------------
-         
-         
-         !                                                       
+
+
+         !
          ! arrays zRH, zFC and zCF are available at this point
          ! and zFC(:, 1 ) = 0.
          ! diagnose PBL height based on zsh2 and zbn2
          zFC (  :  ,1) = 0._wp
-         ikbl( 1:jpi ) = 0 
-         
+         ikbl( 1:jpi ) = 0
+
          DO jk = 2,jpka
-            DO ji = 1, jpi 
+            DO ji = 1, jpi
                zcff  = ghw_abl( jk-1 )
                zcff1 = zcff / ( zcff + rn_epssfc * pblh ( ji, jj ) )
@@ -781,15 +857,15 @@
             ELSE
                pblh( ji, jj ) = ghw_abl(jpka)
-            END IF 
-         END DO
-      !-------------      
-      END DO      
-      !-------------
-      !
-      ! Optional : could add pblh smoothing if pblh is noisy horizontally ... 
+            END IF
+         END DO
+      !-------------
+      END DO
+      !-------------
+      !
+      ! Optional : could add pblh smoothing if pblh is noisy horizontally ...
       IF(ln_smth_pblh) THEN
-         CALL lbc_lnk( 'ablmod', pblh, 'T', 1.)
+         CALL lbc_lnk( 'ablmod', pblh, 'T', 1.) !, kfillmode = jpfillnothing)
          CALL smooth_pblh( pblh, msk_abl )
-         CALL lbc_lnk( 'ablmod', pblh, 'T', 1.)	  
+         CALL lbc_lnk( 'ablmod', pblh, 'T', 1.) !, kfillmode = jpfillnothing)
       ENDIF
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
@@ -799,92 +875,147 @@
       SELECT CASE ( nn_amxl )
       !
-      CASE ( 0 )           ! Deardroff 80 length-scale bounded by the distance to surface and bottom         
-#   define zlup zRH      
-#   define zldw zFC 
+      CASE ( 0 )           ! Deardroff 80 length-scale bounded by the distance to surface and bottom
+#   define zlup zRH
+#   define zldw zFC
          DO jj = 1, jpj     ! outer loop
             !
             DO ji = 1, jpi
-               mxl_abl ( ji, jj,    1 )  = 0._wp
-               mxl_abl ( ji, jj, jpka )  = mxl_min
-               zldw( ji,        1 )  = 0._wp              
-               zlup( ji,     jpka )  = 0._wp
-            END DO
-            !
-            DO jk = 2, jpkam1   
-               DO ji = 1, jpi  
-                  zbuoy             = MAX( zbn2(ji, jj, jk), rsmall )  
-                  mxl_abl( ji, jj, jk ) = MAX( mxl_min,  &
-                     &               SQRT( 2._wp * tke_abl( ji, jj, jk, nt_a ) / zbuoy )   ) 
-               END DO
-            END DO   
+               mxld_abl( ji, jj,    1 ) = mxl_min
+               mxld_abl( ji, jj, jpka ) = mxl_min
+               mxlm_abl( ji, jj,    1 ) = mxl_min
+               mxlm_abl( ji, jj, jpka ) = mxl_min
+               zldw    ( ji,        1 ) = zrough(ji,jj) * rn_Lsfc
+               zlup    ( ji,     jpka ) = mxl_min
+            END DO
+            !
+            DO jk = 2, jpkam1
+               DO ji = 1, jpi
+                  zbuoy = MAX( zbn2(ji, jj, jk), rsmall )
+                  mxlm_abl( ji, jj, jk ) = MAX( mxl_min,  &
+                     &               SQRT( 2._wp * tke_abl( ji, jj, jk, nt_a ) / zbuoy ) )
+               END DO
+            END DO
             !
             ! Limit mxl
-            DO jk = jpkam1,1,-1   
-               DO ji = 1, jpi 
-                  zlup(ji,jk) = MIN( zlup(ji,jk+1) + (ghw_abl(jk+1)-ghw_abl(jk)) , mxl_abl(ji, jj, jk) )
-               END DO
-            END DO   
+            DO jk = jpkam1,1,-1
+               DO ji = 1, jpi
+                  zlup(ji,jk) = MIN( zlup(ji,jk+1) + (ghw_abl(jk+1)-ghw_abl(jk)) , mxlm_abl(ji, jj, jk) )
+               END DO
+            END DO
             !
             DO jk = 2, jpka
-               DO ji = 1, jpi  
-                  zldw(ji,jk) = MIN( zldw(ji,jk-1) + (ghw_abl(jk)-ghw_abl(jk-1)) , mxl_abl(ji, jj, jk) )   
-               END DO
-            END DO 
+               DO ji = 1, jpi
+                  zldw(ji,jk) = MIN( zldw(ji,jk-1) + (ghw_abl(jk)-ghw_abl(jk-1)) , mxlm_abl(ji, jj, jk) )
+               END DO
+            END DO
+            !
+!            DO jk = 1, jpka
+!               DO ji = 1, jpi
+!                  mxlm_abl( ji, jj, jk ) = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )
+!                  mxld_abl( ji, jj, jk ) = MIN ( zldw( ji, jk ),  zlup( ji, jk ) )
+!               END DO
+!            END DO
             !
             DO jk = 1, jpka
                DO ji = 1, jpi
-                  mxl_abl( ji, jj, jk ) = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )   
-               END DO
-            END DO                         
-            !
-         END DO
-#   undef zlup      
-#   undef zldw  
-         !
-         !
-      CASE ( 1 )             ! length-scale computed as the distance to the PBL height
-         DO jj = 1,jpj      ! outer loop
-            !
-            DO ji = 1, jpi   ! vector opt.
-               zcff = 1._wp / pblh( ji, jj )     ! inverse of hbl              
-               DO jk = 1, jpka              
-                  zsig  = MIN( zcff * ghw_abl( jk ), 1. )    
-                  zcff1 = pblh( ji, jj )                 
-                  mxl_abl( ji, jj, jk ) =  mxl_min                           &
-                     &  +  zsig         * (  amx1*zcff1 + bmx1*mxl_min ) &
-                     &  +  zsig *  zsig * (  amx2*zcff1 + bmx2*mxl_min ) &
-                     &  +  zsig**3      * (  amx3*zcff1 + bmx3*mxl_min ) &
-                     &  +  zsig**4      * (  amx4*zcff1 + bmx4*mxl_min ) &
-                     &  +  zsig**5      * (  amx5*zcff1 + bmx5*mxl_min )
-               END DO
-            END DO 
-            !            
-         END DO            
+!                  zcff = 2.*SQRT(2.)*(  zldw( ji, jk )**(-2._wp/3._wp) + zlup( ji, jk )**(-2._wp/3._wp)  )**(-3._wp/2._wp)
+                  zcff = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )
+                  mxlm_abl( ji, jj, jk ) = MAX( zcff, mxl_min )
+                  mxld_abl( ji, jj, jk ) = MAX( MIN( zldw( ji, jk ),  zlup( ji, jk ) ), mxl_min )
+               END DO
+            END DO
+            !
+         END DO
+#   undef zlup
+#   undef zldw
+         !
+         !
+      CASE ( 1 )           ! Modified Deardroff 80 length-scale bounded by the distance to surface and bottom
+#   define zlup zRH
+#   define zldw zFC
+         DO jj = 1, jpj     ! outer loop
+            !
+            DO jk = 2, jpkam1
+               DO ji = 1,jpi
+                              zcff        = 1.0_wp / e3w_abl( jk )**2
+                  zdU         = zcff* (u_abl( ji, jj, jk+1, tind)-u_abl( ji, jj, jk  , tind) )**2
+                  zdV         = zcff* (v_abl( ji, jj, jk+1, tind)-v_abl( ji, jj, jk  , tind) )**2
+                  zsh2(ji,jk) = SQRT(zdU+zdV)   !<-- zsh2 = SQRT ( ( du/dz )^2 + ( dv/dz )^2 )
+                           ENDDO
+                        ENDDO
+                        !
+            DO ji = 1, jpi
+               zcff                      = zrough(ji,jj) * rn_Lsfc
+               mxld_abl ( ji, jj,    1 ) = zcff
+               mxld_abl ( ji, jj, jpka ) = mxl_min
+               mxlm_abl ( ji, jj,    1 ) = zcff
+               mxlm_abl ( ji, jj, jpka ) = mxl_min
+               zldw     ( ji,        1 ) = zcff
+               zlup     ( ji,     jpka ) = mxl_min
+            END DO
+            !
+            DO jk = 2, jpkam1
+               DO ji = 1, jpi
+                  zbuoy    = MAX( zbn2(ji, jj, jk), rsmall )
+                  zcff     = 2.*SQRT(tke_abl( ji, jj, jk, nt_a )) / ( rn_Rod*zsh2(ji,jk) &
+                                &             + SQRT( rn_Rod*rn_Rod*zsh2(ji,jk)*zsh2(ji,jk)+2.*zbuoy ) )
+                                  mxlm_abl( ji, jj, jk ) = MAX( mxl_min, zcff )
+               END DO
+            END DO
+            !
+            ! Limit mxl
+            DO jk = jpkam1,1,-1
+               DO ji = 1, jpi
+                  zlup(ji,jk) = MIN( zlup(ji,jk+1) + (ghw_abl(jk+1)-ghw_abl(jk)) , mxlm_abl(ji, jj, jk) )
+               END DO
+            END DO
+            !
+            DO jk = 2, jpka
+               DO ji = 1, jpi
+                  zldw(ji,jk) = MIN( zldw(ji,jk-1) + (ghw_abl(jk)-ghw_abl(jk-1)) , mxlm_abl(ji, jj, jk) )
+               END DO
+            END DO
+            !
+            DO jk = 1, jpka
+               DO ji = 1, jpi
+                  !mxlm_abl( ji, jj, jk ) = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )
+                  !zcff = 2.*SQRT(2.)*(  zldw( ji, jk )**(-2._wp/3._wp) + zlup( ji, jk )**(-2._wp/3._wp)  )**(-3._wp/2._wp)
+                  zcff = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )
+                  mxlm_abl( ji, jj, jk ) = MAX( zcff, mxl_min )
+                  !mxld_abl( ji, jj, jk ) = MIN( zldw( ji, jk ), zlup( ji, jk ) )
+                  mxld_abl( ji, jj, jk ) = MAX( MIN( zldw( ji, jk ),  zlup( ji, jk ) ), mxl_min )
+               END DO
+            END DO
+ !
+         END DO
+#   undef zlup
+#   undef zldw
          !
       CASE ( 2 )           ! Bougeault & Lacarrere 89 length-scale
          !
-#   define zlup zRH      
-#   define zldw zFC           
+#   define zlup zRH
+#   define zldw zFC
 ! zCF is used for matrix inversion
-!             
+!
        DO jj = 1, jpj      ! outer loop
-         
-         DO ji = 1, jpi           
-            zlup( ji,    1 ) = mxl_min
-            zldw( ji,    1 ) = mxl_min               
+
+         DO ji = 1, jpi
+            zcff             = zrough(ji,jj) * rn_Lsfc
+            zlup( ji,    1 ) = zcff
+            zldw( ji,    1 ) = zcff
             zlup( ji, jpka ) = mxl_min
-            zldw( ji, jpka ) = mxl_min                
-         END DO            
-         
+            zldw( ji, jpka ) = mxl_min
+         END DO
+
          DO jk = 2,jpka-1
             DO ji = 1, jpi
                zlup(ji,jk) = ghw_abl(jpka) - ghw_abl(jk)
-               zldw(ji,jk) = ghw_abl(jk  ) - ghw_abl( 1)        
-            END DO
-         END DO         
+               zldw(ji,jk) = ghw_abl(jk  ) - ghw_abl( 1)
+            END DO
+         END DO
          !!
          !! BL89 search for lup
-         !! ----------------------------------------------------------           
-         DO jk=2,jpka-1 
+         !! ----------------------------------------------------------
+         DO jk=2,jpka-1
             !
             DO ji = 1, jpi
@@ -892,17 +1023,20 @@
                zCF(ji,  jk  ) = - tke_abl( ji, jj, jk, nt_a )
                ln_foundl(ji ) = .false.
-            END DO   
-            !           
+            END DO
+            !
             DO jkup=jk+1,jpka-1
                DO ji = 1, jpi
+                  zbuoy1 = MAX( zbn2(ji,jj,jkup  ), rsmall )
+                  zbuoy2 = MAX( zbn2(ji,jj,jkup-1), rsmall )
                   zCF (ji,jkup) = zCF (ji,jkup-1) + 0.5_wp * e3t_abl(jkup) * &
-                     &               ( zbn2(ji,jj,jkup  )*(ghw_abl(jkup  )-ghw_abl(jk)) &
-                     &               + zbn2(ji,jj,jkup-1)*(ghw_abl(jkup-1)-ghw_abl(jk)) )
+                     &               ( zbuoy1*(ghw_abl(jkup  )-ghw_abl(jk)) &
+                     &               + zbuoy2*(ghw_abl(jkup-1)-ghw_abl(jk)) )
                   IF( zCF (ji,jkup) * zCF (ji,jkup-1) .le. 0._wp .and. .not. ln_foundl(ji) ) THEN
                      zcff2 = ghw_abl(jkup  ) - ghw_abl(jk)
-                     zcff1 = ghw_abl(jkup-1) - ghw_abl(jk)                   
+                     zcff1 = ghw_abl(jkup-1) - ghw_abl(jk)
                      zcff  = ( zcff1 * zCF(ji,jkup) - zcff2 * zCF(ji,jkup-1) ) /   &
-                        &    (         zCF(ji,jkup) -         zCF(ji,jkup-1) ) 
-                     zlup(ji,jk) = zcff                
+                        &    (         zCF(ji,jkup) -         zCF(ji,jkup-1) )
+                     zlup(ji,jk) = zcff
+                     zlup(ji,jk) = ghw_abl(jkup  ) - ghw_abl(jk)
                      ln_foundl(ji) = .true.
                   END IF
@@ -910,9 +1044,9 @@
             END DO
             !
-         END DO   
+         END DO
          !!
          !! BL89 search for ldwn
-         !! ----------------------------------------------------------          
-         DO jk=2,jpka-1         
+         !! ----------------------------------------------------------
+         DO jk=2,jpka-1
             !
             DO ji = 1, jpi
@@ -920,55 +1054,179 @@
                zCF(ji,  jk  ) = - tke_abl( ji, jj, jk, nt_a )
                ln_foundl(ji ) = .false.
-            END DO  
-            !   
+            END DO
+            !
             DO jkdwn=jk-1,1,-1
-               DO ji = 1, jpi             
+               DO ji = 1, jpi
+                  zbuoy1 = MAX( zbn2(ji,jj,jkdwn+1), rsmall )
+                  zbuoy2 = MAX( zbn2(ji,jj,jkdwn  ), rsmall )
                   zCF (ji,jkdwn) = zCF (ji,jkdwn+1) + 0.5_wp * e3t_abl(jkdwn+1)  &
-                     &               * ( zbn2(ji,jj,jkdwn+1)*(ghw_abl(jk)-ghw_abl(jkdwn+1)) &
-                                       + zbn2(ji,jj,jkdwn  )*(ghw_abl(jk)-ghw_abl(jkdwn  )) )   
-                  IF(zCF (ji,jkdwn) * zCF (ji,jkdwn+1) .le. 0._wp  .and. .not. ln_foundl(ji) ) THEN 
+                     &               * ( zbuoy1*(ghw_abl(jk)-ghw_abl(jkdwn+1)) &
+                                       + zbuoy2*(ghw_abl(jk)-ghw_abl(jkdwn  )) )
+                  IF(zCF (ji,jkdwn) * zCF (ji,jkdwn+1) .le. 0._wp  .and. .not. ln_foundl(ji) ) THEN
                      zcff2 = ghw_abl(jk) - ghw_abl(jkdwn+1)
-                     zcff1 = ghw_abl(jk) - ghw_abl(jkdwn  )              
+                     zcff1 = ghw_abl(jk) - ghw_abl(jkdwn  )
                      zcff  = ( zcff1 * zCF(ji,jkdwn+1) - zcff2 * zCF(ji,jkdwn) ) /   &
-                        &    (         zCF(ji,jkdwn+1) -         zCF(ji,jkdwn) ) 
-                     zldw(ji,jk) = zcff 
-                     ln_foundl(ji) = .true.               
-                  END IF                                   
-               END DO
-            END DO
-            !      
+                        &    (         zCF(ji,jkdwn+1) -         zCF(ji,jkdwn) )
+                     zldw(ji,jk) = zcff
+                     zldw(ji,jk) = ghw_abl(jk) - ghw_abl(jkdwn  )
+                     ln_foundl(ji) = .true.
+                  END IF
+               END DO
+            END DO
+            !
          END DO
 
          DO jk = 1, jpka
-            DO ji = 1, jpi  
-               mxl_abl( ji, jj, jk ) = MAX( SQRT( zldw( ji, jk ) * zlup( ji, jk ) ), mxl_min )  
-            END DO
-         END DO  
+            DO ji = 1, jpi
+               !zcff = 2.*SQRT(2.)*(  zldw( ji, jk )**(-2._wp/3._wp) + zlup( ji, jk )**(-2._wp/3._wp)  )**(-3._wp/2._wp)
+               zcff = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )
+               mxlm_abl( ji, jj, jk ) = MAX( zcff, mxl_min )
+               mxld_abl( ji, jj, jk ) = MAX( MIN( zldw( ji, jk ),  zlup( ji, jk ) ), mxl_min )
+            END DO
+         END DO
 
       END DO
-#   undef zlup      
-#   undef zldw           
-         !
-      END SELECT      
+#   undef zlup
+#   undef zldw
+         !
+     CASE ( 3 )           ! Bougeault & Lacarrere 89 length-scale
+         !
+#   define zlup zRH
+#   define zldw zFC
+! zCF is used for matrix inversion
+!
+       DO jj = 1, jpj      ! outer loop
+          !
+          DO jk = 2, jpkam1
+             DO ji = 1,jpi
+                            zcff        = 1.0_wp / e3w_abl( jk )**2
+                zdU         = zcff* (u_abl( ji, jj, jk+1, tind)-u_abl( ji, jj, jk  , tind) )**2
+                zdV         = zcff* (v_abl( ji, jj, jk+1, tind)-v_abl( ji, jj, jk  , tind) )**2
+                zsh2(ji,jk) = SQRT(zdU+zdV)   !<-- zsh2 = SQRT ( ( du/dz )^2 + ( dv/dz )^2 )
+                         ENDDO
+                  ENDDO
+          zsh2(:,      1) = zsh2( :,      2)
+          zsh2(:,   jpka) = zsh2( :, jpkam1)
+
+                 DO ji = 1, jpi
+            zcff              = zrough(ji,jj) * rn_Lsfc
+                        zlup( ji,    1 )  = zcff
+            zldw( ji,    1 )  = zcff
+            zlup( ji, jpka ) = mxl_min
+            zldw( ji, jpka ) = mxl_min
+         END DO
+
+         DO jk = 2,jpka-1
+            DO ji = 1, jpi
+               zlup(ji,jk) = ghw_abl(jpka) - ghw_abl(jk)
+               zldw(ji,jk) = ghw_abl(jk  ) - ghw_abl( 1)
+            END DO
+         END DO
+         !!
+         !! BL89 search for lup
+         !! ----------------------------------------------------------
+         DO jk=2,jpka-1
+            !
+            DO ji = 1, jpi
+               zCF(ji,1:jpka) = 0._wp
+               zCF(ji,  jk  ) = - tke_abl( ji, jj, jk, nt_a )
+               ln_foundl(ji ) = .false.
+            END DO
+            !
+            DO jkup=jk+1,jpka-1
+               DO ji = 1, jpi
+                  zbuoy1             = MAX( zbn2(ji,jj,jkup  ), rsmall )
+                  zbuoy2             = MAX( zbn2(ji,jj,jkup-1), rsmall )
+                  zCF (ji,jkup) = zCF (ji,jkup-1) + 0.5_wp * e3t_abl(jkup) *                 &
+                     &               ( zbuoy1*(ghw_abl(jkup  )-ghw_abl(jk))      &
+                     &               + zbuoy2*(ghw_abl(jkup-1)-ghw_abl(jk)) )    &
+                                         &                            + 0.5_wp * e3t_abl(jkup) * rn_Rod *        &
+                                         &               ( SQRT(tke_abl( ji, jj, jkup  , nt_a ))*zsh2(ji,jkup  ) &
+                                         &               + SQRT(tke_abl( ji, jj, jkup-1, nt_a ))*zsh2(ji,jkup-1) )
+
+                  IF( zCF (ji,jkup) * zCF (ji,jkup-1) .le. 0._wp .and. .not. ln_foundl(ji) ) THEN
+                     zcff2 = ghw_abl(jkup  ) - ghw_abl(jk)
+                     zcff1 = ghw_abl(jkup-1) - ghw_abl(jk)
+                     zcff  = ( zcff1 * zCF(ji,jkup) - zcff2 * zCF(ji,jkup-1) ) /   &
+                        &    (         zCF(ji,jkup) -         zCF(ji,jkup-1) )
+                     zlup(ji,jk) = zcff
+                     zlup(ji,jk) = ghw_abl(jkup  ) - ghw_abl(jk)
+                     ln_foundl(ji) = .true.
+                  END IF
+               END DO
+            END DO
+            !
+         END DO
+         !!
+         !! BL89 search for ldwn
+         !! ----------------------------------------------------------
+         DO jk=2,jpka-1
+            !
+            DO ji = 1, jpi
+               zCF(ji,1:jpka) = 0._wp
+               zCF(ji,  jk  ) = - tke_abl( ji, jj, jk, nt_a )
+               ln_foundl(ji ) = .false.
+            END DO
+            !
+            DO jkdwn=jk-1,1,-1
+               DO ji = 1, jpi
+                  zbuoy1             = MAX( zbn2(ji,jj,jkdwn+1), rsmall )
+                  zbuoy2             = MAX( zbn2(ji,jj,jkdwn  ), rsmall )
+                  zCF (ji,jkdwn) = zCF (ji,jkdwn+1) + 0.5_wp * e3t_abl(jkdwn+1)  &
+                     &               * (zbuoy1*(ghw_abl(jk)-ghw_abl(jkdwn+1))    &
+                     &                 +zbuoy2*(ghw_abl(jk)-ghw_abl(jkdwn  )) )  &
+                                         &                            + 0.5_wp * e3t_abl(jkup) * rn_Rod *          &
+                                         &               ( SQRT(tke_abl( ji, jj, jkdwn+1, nt_a ))*zsh2(ji,jkdwn+1) &
+                                         &               + SQRT(tke_abl( ji, jj, jkdwn  , nt_a ))*zsh2(ji,jkdwn  ) )
+
+                  IF(zCF (ji,jkdwn) * zCF (ji,jkdwn+1) .le. 0._wp  .and. .not. ln_foundl(ji) ) THEN
+                     zcff2 = ghw_abl(jk) - ghw_abl(jkdwn+1)
+                     zcff1 = ghw_abl(jk) - ghw_abl(jkdwn  )
+                     zcff  = ( zcff1 * zCF(ji,jkdwn+1) - zcff2 * zCF(ji,jkdwn) ) /   &
+                        &    (         zCF(ji,jkdwn+1) -         zCF(ji,jkdwn) )
+                     zldw(ji,jk) = zcff
+                     zldw(ji,jk) = ghw_abl(jk) - ghw_abl(jkdwn  )
+                     ln_foundl(ji) = .true.
+                  END IF
+               END DO
+            END DO
+            !
+         END DO
+
+         DO jk = 1, jpka
+            DO ji = 1, jpi
+               !zcff = 2.*SQRT(2.)*(  zldw( ji, jk )**(-2._wp/3._wp) + zlup( ji, jk )**(-2._wp/3._wp)  )**(-3._wp/2._wp)
+               zcff = SQRT( zldw( ji, jk ) * zlup( ji, jk ) )
+               mxlm_abl( ji, jj, jk ) = MAX( zcff, mxl_min )
+               mxld_abl( ji, jj, jk ) = MAX(  MIN( zldw( ji, jk ),  zlup( ji, jk ) ), mxl_min )
+            END DO
+         END DO
+
+      END DO
+#   undef zlup
+#   undef zldw
+         !
+         !
+      END SELECT
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !                            !  Finalize the computation of turbulent visc./diff.
       !                            !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      
+
       !-------------
       DO jj = 1, jpj     ! outer loop
       !-------------
-         DO jk = 1, jpka   
+         DO jk = 1, jpka
             DO ji = 1, jpi  ! vector opt.
-               zcff              = MAX( rn_phimax, rn_Ric * mxl_abl( ji, jj, jk ) * mxl_abl( ji, jj, jk )  &
-                  &                                       * zbn2(ji, jj, jk) / tke_abl( ji, jj, jk, nt_a ) ) 
-               zcff2             =  1. / ( 1. + zcff )   !<-- phi_z(z)
-               zcff              = mxl_abl( ji, jj, jk ) * SQRT( tke_abl( ji, jj, jk, nt_a ) )
-!!FL: MAX function probably useless because of the definition of mxl_min             
+               zcff  = MAX( rn_phimax, rn_Ric * mxlm_abl( ji, jj, jk ) * mxld_abl( ji, jj, jk )  &
+               &     * MAX( zbn2(ji, jj, jk), rsmall ) / tke_abl( ji, jj, jk, nt_a ) )
+               zcff2 =  1. / ( 1. + zcff )   !<-- phi_z(z)
+               zcff  = mxlm_abl( ji, jj, jk ) * SQRT( tke_abl( ji, jj, jk, nt_a ) )
+               !!FL: MAX function probably useless because of the definition of mxl_min
                Avm_abl( ji, jj, jk ) = MAX( rn_Cm * zcff         , avm_bak   )
-               Avt_abl( ji, jj, jk ) = MAX( rn_Ct * zcff * zcff2 , avt_bak   )                              
-            END DO
-         END DO
-      !-------------         
-      END DO      
+               Avt_abl( ji, jj, jk ) = MAX( rn_Ct * zcff * zcff2 , avt_bak   )
+            END DO
+         END DO
+      !-------------
+      END DO
       !-------------
 
@@ -988,10 +1246,10 @@
       !!
       !! ---------------------------------------------------------------------
-	  REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: msk   
-	  REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pvar2d
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   ) :: msk
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) :: pvar2d
       INTEGER                                     :: ji,jj
-	  REAL(wp)                                    :: smth_a, smth_b
-	  REAL(wp), DIMENSION(jpi,jpj)                :: zdX,zdY,zFX,zFY
-	  REAL(wp)                                    :: zumsk,zvmsk
+      REAL(wp)                                    :: smth_a, smth_b
+      REAL(wp), DIMENSION(jpi,jpj)                :: zdX,zdY,zFX,zFY
+      REAL(wp)                                    :: zumsk,zvmsk
       !!
       !!=========================================================
@@ -1005,15 +1263,15 @@
          zdX ( ji, jj ) = ( pvar2d( ji+1,jj ) - pvar2d( ji  ,jj ) ) * zumsk
       END_2D
-      
-	  DO_2D_10_11
+
+      DO_2D_10_11
          zvmsk = msk(ji,jj) * msk(ji,jj+1)
          zdY ( ji, jj ) = ( pvar2d( ji, jj+1 ) - pvar2d( ji  ,jj ) ) * zvmsk
-	  END_2D
-      
-	  DO_2D_10_00
+      END_2D
+
+      DO_2D_10_00
          zFY ( ji, jj  ) =   zdY ( ji, jj   )                        &
             & +  smth_a*  ( (zdX ( ji, jj+1 ) - zdX( ji-1, jj+1 ))   &
             &            -  (zdX ( ji, jj   ) - zdX( ji-1, jj   ))  )
-	  END_2D
+      END_2D
 
       DO_2D_00_10
@@ -1029,5 +1287,5 @@
   &                 +zFY( ji, jj ) - zFY( ji, jj-1 )  )
       END_2D
-	  !!
+
 !---------------------------------------------------------------------------------------------------
    END SUBROUTINE smooth_pblh
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/ablrst.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/ablrst.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/ablrst.F90	(revision 13229)
@@ -109,5 +109,5 @@
       CALL iom_delay_rst( 'WRITE', 'ABL', numraw )   ! save only abl delayed global communication variables
 
-      ! Prognostic variables
+      ! Prognostic (after timestep + swap time indices = now timestep) variables
       CALL iom_rstput( iter, nitrst, numraw,   'u_abl',   u_abl(:,:,:,nt_n      ) )
       CALL iom_rstput( iter, nitrst, numraw,   'v_abl',   v_abl(:,:,:,nt_n      ) )
@@ -117,5 +117,5 @@
       CALL iom_rstput( iter, nitrst, numraw, 'avm_abl', avm_abl(:,:,:           ) )
       CALL iom_rstput( iter, nitrst, numraw, 'avt_abl', avt_abl(:,:,:           ) )
-      CALL iom_rstput( iter, nitrst, numraw, 'mxl_abl', mxl_abl(:,:,:           ) )
+      CALL iom_rstput( iter, nitrst, numraw,'mxld_abl',mxld_abl(:,:,:           ) )
       CALL iom_rstput( iter, nitrst, numraw,    'pblh',    pblh(:,:             ) )
       !
@@ -172,5 +172,5 @@
       CALL iom_get( numrar, jpdom_auto, 'avm_abl', avm_abl(:,:,:           ) )
       CALL iom_get( numrar, jpdom_auto, 'avt_abl', avt_abl(:,:,:           ) )
-      CALL iom_get( numrar, jpdom_auto, 'mxl_abl', mxl_abl(:,:,:           ) )
+      CALL iom_get( numrar, jpdom_auto,'mxld_abl',mxld_abl(:,:,:           ) )
       CALL iom_get( numrar, jpdom_auto,    'pblh',    pblh(:,:             ) )
       CALL iom_delay_rst( 'READ', 'ABL', numrar )   ! read only abl delayed global communication variables
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/par_abl.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/par_abl.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/par_abl.F90	(revision 13229)
@@ -28,10 +28,11 @@
    LOGICAL , PUBLIC            ::   ln_hpgls_frc   !: forcing of ABL winds by large-scale pressure gradient 
    LOGICAL , PUBLIC            ::   ln_smth_pblh   !: smoothing of atmospheric PBL height 
+   !LOGICAL , PUBLIC            ::   ln_topbc_neumann = .FALSE.  !: idealised testcases only
 
-   LOGICAL           , PUBLIC ::   ln_rstart_abl    !: (de)activate abl restart
-   CHARACTER(len=256), PUBLIC ::   cn_ablrst_in     !: suffix of abl restart name (input)
-   CHARACTER(len=256), PUBLIC ::   cn_ablrst_out    !: suffix of abl restart name (output)
-   CHARACTER(len=256), PUBLIC ::   cn_ablrst_indir  !: abl restart input directory
-   CHARACTER(len=256), PUBLIC ::   cn_ablrst_outdir !: abl restart output directory
+   LOGICAL           , PUBLIC  ::   ln_rstart_abl    !: (de)activate abl restart
+   CHARACTER(len=256), PUBLIC  ::   cn_ablrst_in     !: suffix of abl restart name (input)
+   CHARACTER(len=256), PUBLIC  ::   cn_ablrst_out    !: suffix of abl restart name (output)
+   CHARACTER(len=256), PUBLIC  ::   cn_ablrst_indir  !: abl restart input directory
+   CHARACTER(len=256), PUBLIC  ::   cn_ablrst_outdir !: abl restart output directory
 
    !!---------------------------------------------------------------------
@@ -46,10 +47,12 @@
    REAL(wp), PUBLIC, PARAMETER ::   rn_Cek    = 258._wp                   !: Ekman constant for Richardson number 
    REAL(wp), PUBLIC, PARAMETER ::   rn_epssfc = 1._wp / ( 1._wp + 2.8_wp * 2.8_wp )
-   REAL(wp), PUBLIC            ::   rn_ceps                       !: namelist parameter
-   REAL(wp), PUBLIC            ::   rn_cm                         !: namelist parameter
-   REAL(wp), PUBLIC            ::   rn_ct                         !: namelist parameter
-   REAL(wp), PUBLIC            ::   rn_ce                         !: namelist parameter 
+   REAL(wp), PUBLIC            ::   rn_Ceps                       !: namelist parameter
+   REAL(wp), PUBLIC            ::   rn_Cm                         !: namelist parameter
+   REAL(wp), PUBLIC            ::   rn_Ct                         !: namelist parameter
+   REAL(wp), PUBLIC            ::   rn_Ce                         !: namelist parameter 
    REAL(wp), PUBLIC            ::   rn_Rod                        !: namelist parameter   
    REAL(wp), PUBLIC            ::   rn_Sch    
+   REAL(wp), PUBLIC            ::   rn_Esfc
+   REAL(wp), PUBLIC            ::   rn_Lsfc
    REAL(wp), PUBLIC            ::   mxl_min    
    REAL(wp), PUBLIC            ::   rn_ldyn_min                   !: namelist parameter
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/sbcabl.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/sbcabl.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ABL/sbcabl.F90	(revision 13229)
@@ -71,12 +71,13 @@
          &                 ln_hpgls_frc, ln_geos_winds, nn_dyn_restore,           &
          &                 rn_ldyn_min , rn_ldyn_max, rn_ltra_min, rn_ltra_max,   &
-         &                 nn_amxl, rn_cm, rn_ct, rn_ce, rn_ceps, rn_Rod, rn_Ric, &
+         &                 nn_amxl, rn_Cm, rn_Ct, rn_Ce, rn_Ceps, rn_Rod, rn_Ric, &
          &                 ln_smth_pblh
       !!---------------------------------------------------------------------
 
-      ! Namelist namsbc_abl in reference namelist : ABL parameters
+                                        ! Namelist namsbc_abl in reference namelist : ABL parameters
       READ  ( numnam_ref, namsbc_abl, IOSTAT = ios, ERR = 901 )
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_abl in reference namelist' )
-      ! Namelist namsbc_abl in configuration namelist : ABL parameters
+      !
+                                        ! Namelist namsbc_abl in configuration namelist : ABL parameters
       READ  ( numnam_cfg, namsbc_abl, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_abl in configuration namelist' )
@@ -165,4 +166,6 @@
       rn_Sch  = rn_ce / rn_cm
       mxl_min = (avm_bak / rn_cm) / sqrt( tke_min )
+      rn_Esfc =  1._wp / SQRT(rn_cm*rn_ceps)
+      rn_Lsfc = vkarmn * SQRT(SQRT(rn_cm*rn_ceps)) / rn_cm
 
       IF(lwp) THEN
@@ -171,5 +174,7 @@
          WRITE(numout,*) '    ~~~~~~~~~~~'
          IF(nn_amxl==0) WRITE(numout,*) 'Deardorff 80 length-scale '
-         IF(nn_amxl==1) WRITE(numout,*) 'length-scale based on the distance to the PBL height '
+         IF(nn_amxl==1) WRITE(numout,*) 'Modified Deardorff 80 length-scale '
+         IF(nn_amxl==2) WRITE(numout,*) 'Bougeault and Lacarrere length-scale '		 
+         IF(nn_amxl==3) WRITE(numout,*) 'Rodier et al. length-scale '	
          WRITE(numout,*) ' Minimum value of atmospheric TKE           = ',tke_min,' m^2 s^-2'
          WRITE(numout,*) ' Minimum value of atmospheric mixing length = ',mxl_min,' m'
@@ -178,4 +183,6 @@
          WRITE(numout,*) ' Constant for Schmidt number                = ',rn_Sch
          WRITE(numout,*) ' Constant for TKE dissipation               = ',rn_Ceps
+         WRITE(numout,*) ' Constant for TKE sfc boundary condition    = ',rn_Esfc
+         WRITE(numout,*) ' Constant for mxl sfc boundary condition    = ',rn_Lsfc
       END IF
 
@@ -202,4 +209,5 @@
       ! ABL timestep
       rDt_abl = nn_fsbc * rn_Dt
+      IF(lwp) WRITE(numout,*) ' ABL timestep = ', rDt_abl,' s'
 
       ! Check parameters for dynamics
@@ -248,7 +256,4 @@
          zcff         = 2._wp * omega * SIN( rad * 90._wp )   !++ fmax
          rest_eq(:,:) = SIN( 0.5_wp*rpi*( (fft_abl(:,:) - zcff) / zcff ) )**8
-         !!GS: alternative shape
-         !rest_eq(:,:) = SIN( 0.5_wp*rpi*(zcff - ABS(ff_t(:,:))) / (zcff - 3.e-5) )**8
-         !WHERE(ABS(ff_t(:,:)).LE.3.e-5) rest_eq(:,:) = 1._wp
       ELSE
          rest_eq(:,:) = 1._wp
@@ -271,6 +276,6 @@
          CALL fld_read( nit000, nn_fsbc, sf ) ! input fields provided at the first time-step
 
-         u_abl(:,:,:,nt_n      ) = sf(jp_wndi)%fnow(:,:,:)
-         v_abl(:,:,:,nt_n      ) = sf(jp_wndj)%fnow(:,:,:)
+          u_abl(:,:,:,nt_n      ) = sf(jp_wndi)%fnow(:,:,:)
+          v_abl(:,:,:,nt_n      ) = sf(jp_wndj)%fnow(:,:,:)
          tq_abl(:,:,:,nt_n,jp_ta) = sf(jp_tair)%fnow(:,:,:)
          tq_abl(:,:,:,nt_n,jp_qa) = sf(jp_humi)%fnow(:,:,:)
@@ -279,5 +284,4 @@
          avm_abl(:,:,:          ) = avm_bak
          avt_abl(:,:,:          ) = avt_bak
-         mxl_abl(:,:,:          ) = mxl_min
          pblh   (:,:            ) = ghw_abl( 3 )  !<-- assume that the pbl contains 3 grid points
          u_abl  (:,:,:,nt_a     ) = 0._wp
@@ -285,4 +289,7 @@
          tq_abl (:,:,:,nt_a,:   ) = 0._wp
          tke_abl(:,:,:,nt_a     ) = 0._wp
+
+         mxlm_abl(:,:,:         ) = mxl_min
+         mxld_abl(:,:,:         ) = mxl_min
       ENDIF
 
@@ -335,4 +342,5 @@
             &                tq_abl(:,:,2,nt_n,jp_ta), tq_abl(:,:,2,nt_n,jp_qa),   &   !   <<= in
             &                sf(jp_slp )%fnow(:,:,1) , sst_m, ssu_m, ssv_m     ,   &   !   <<= in
+            &                sf(jp_uoatm)%fnow(:,:,1), sf(jp_voatm)%fnow(:,:,1),   &   !   <<= in
             &                sf(jp_qsr )%fnow(:,:,1) , sf(jp_qlw )%fnow(:,:,1) ,   &   !   <<= in
             &                tsk_m, zssq, zcd_du, zsen, zevp                       )   !   =>> out
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ICE/iceistate.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ICE/iceistate.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ICE/iceistate.F90	(revision 13229)
@@ -32,4 +32,10 @@
    USE lib_fortran    ! fortran utilities (glob_sum + no signed zero)
    USE fldread        ! read input fields
+
+# if defined key_agrif
+   USE agrif_oce
+   USE agrif_ice
+   USE agrif_ice_interp 
+# endif   
 
    IMPLICIT NONE
@@ -168,198 +174,242 @@
       ! 2) overwrite some of the fields with namelist parameters or netcdf file
       !------------------------------------------------------------------------
+
+
       IF( ln_iceini ) THEN
          !                             !---------------!
-         IF( ln_iceini_file )THEN      ! Read a file   !
-            !                          !---------------!
-            WHERE( ff_t(:,:) >= 0._wp )   ;   zswitch(:,:) = 1._wp
-            ELSEWHERE                     ;   zswitch(:,:) = 0._wp
+         
+         IF( Agrif_Root() ) THEN
+
+            IF( ln_iceini_file )THEN      ! Read a file   !
+               !                          !---------------!
+               WHERE( ff_t(:,:) >= 0._wp )   ;   zswitch(:,:) = 1._wp
+               ELSEWHERE                     ;   zswitch(:,:) = 0._wp
+               END WHERE
+               !
+               CALL fld_read( kt, 1, si ) ! input fields provided at the current time-step
+               !
+               ! -- mandatory fields -- !
+               zht_i_ini(:,:) = si(jp_hti)%fnow(:,:,1) * tmask(:,:,1)
+               zht_s_ini(:,:) = si(jp_hts)%fnow(:,:,1) * tmask(:,:,1)
+               zat_i_ini(:,:) = si(jp_ati)%fnow(:,:,1) * tmask(:,:,1)
+
+               ! -- optional fields -- !
+               !    if fields do not exist then set them to the values present in the namelist (except for snow and surface temperature)
+               !
+               ! ice salinity
+               IF( TRIM(si(jp_smi)%clrootname) == 'NOT USED' ) &
+                  &     si(jp_smi)%fnow(:,:,1) = ( rn_smi_ini_n * zswitch + rn_smi_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+               !
+               ! temperatures
+               IF    ( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. &
+                  &    TRIM(si(jp_tms)%clrootname) == 'NOT USED' ) THEN
+                  si(jp_tmi)%fnow(:,:,1) = ( rn_tmi_ini_n * zswitch + rn_tmi_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+                  si(jp_tsu)%fnow(:,:,1) = ( rn_tsu_ini_n * zswitch + rn_tsu_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+                  si(jp_tms)%fnow(:,:,1) = ( rn_tms_ini_n * zswitch + rn_tms_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+               ELSEIF( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tms)%clrootname) /= 'NOT USED' ) THEN ! if T_s is read and not T_i, set T_i = (T_s + T_freeze)/2
+                  si(jp_tmi)%fnow(:,:,1) = 0.5_wp * ( si(jp_tms)%fnow(:,:,1) + 271.15 )
+               ELSEIF( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tsu)%clrootname) /= 'NOT USED' ) THEN ! if T_su is read and not T_i, set T_i = (T_su + T_freeze)/2
+                  si(jp_tmi)%fnow(:,:,1) = 0.5_wp * ( si(jp_tsu)%fnow(:,:,1) + 271.15 )
+               ELSEIF( TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tms)%clrootname) /= 'NOT USED' ) THEN ! if T_s is read and not T_su, set T_su = T_s
+                  si(jp_tsu)%fnow(:,:,1) = si(jp_tms)%fnow(:,:,1)
+               ELSEIF( TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) /= 'NOT USED' ) THEN ! if T_i is read and not T_su, set T_su = T_i
+                  si(jp_tsu)%fnow(:,:,1) = si(jp_tmi)%fnow(:,:,1)
+               ELSEIF( TRIM(si(jp_tms)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tsu)%clrootname) /= 'NOT USED' ) THEN ! if T_su is read and not T_s, set T_s = T_su
+                  si(jp_tms)%fnow(:,:,1) = si(jp_tsu)%fnow(:,:,1)
+               ELSEIF( TRIM(si(jp_tms)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) /= 'NOT USED' ) THEN ! if T_i is read and not T_s, set T_s = T_i
+                  si(jp_tms)%fnow(:,:,1) = si(jp_tmi)%fnow(:,:,1)
+               ENDIF
+               !
+               ! pond concentration
+               IF( TRIM(si(jp_apd)%clrootname) == 'NOT USED' ) &
+                  &     si(jp_apd)%fnow(:,:,1) = ( rn_apd_ini_n * zswitch + rn_apd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1) & ! rn_apd = pond fraction => rn_apnd * a_i = pond conc.
+                  &                              * si(jp_ati)%fnow(:,:,1) 
+               !
+               ! pond depth
+               IF( TRIM(si(jp_hpd)%clrootname) == 'NOT USED' ) &
+                  &     si(jp_hpd)%fnow(:,:,1) = ( rn_hpd_ini_n * zswitch + rn_hpd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
+               !
+               zsm_i_ini(:,:) = si(jp_smi)%fnow(:,:,1) * tmask(:,:,1)
+               ztm_i_ini(:,:) = si(jp_tmi)%fnow(:,:,1) * tmask(:,:,1)
+               zt_su_ini(:,:) = si(jp_tsu)%fnow(:,:,1) * tmask(:,:,1)
+               ztm_s_ini(:,:) = si(jp_tms)%fnow(:,:,1) * tmask(:,:,1)
+               zapnd_ini(:,:) = si(jp_apd)%fnow(:,:,1) * tmask(:,:,1)
+               zhpnd_ini(:,:) = si(jp_hpd)%fnow(:,:,1) * tmask(:,:,1)
+               !
+               ! change the switch for the following
+               WHERE( zat_i_ini(:,:) > 0._wp )   ;   zswitch(:,:) = tmask(:,:,1) 
+               ELSEWHERE                         ;   zswitch(:,:) = 0._wp
+               END WHERE
+
+               !                          !---------------!
+            ELSE                          ! Read namelist !
+               !                          !---------------!
+               ! no ice if (sst - Tfreez) >= thresold
+               WHERE( ( sst_m(:,:) - (t_bo(:,:) - rt0) ) * tmask(:,:,1) >= rn_thres_sst )   ;   zswitch(:,:) = 0._wp 
+               ELSEWHERE                                                                    ;   zswitch(:,:) = tmask(:,:,1)
+               END WHERE
+               !
+               ! assign initial thickness, concentration, snow depth and salinity to an hemisphere-dependent array
+               WHERE( ff_t(:,:) >= 0._wp )
+                  zht_i_ini(:,:) = rn_hti_ini_n * zswitch(:,:)
+                  zht_s_ini(:,:) = rn_hts_ini_n * zswitch(:,:)
+                  zat_i_ini(:,:) = rn_ati_ini_n * zswitch(:,:)
+                  zsm_i_ini(:,:) = rn_smi_ini_n * zswitch(:,:)
+                  ztm_i_ini(:,:) = rn_tmi_ini_n * zswitch(:,:)
+                  zt_su_ini(:,:) = rn_tsu_ini_n * zswitch(:,:)
+                  ztm_s_ini(:,:) = rn_tms_ini_n * zswitch(:,:)
+                  zapnd_ini(:,:) = rn_apd_ini_n * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc. 
+                  zhpnd_ini(:,:) = rn_hpd_ini_n * zswitch(:,:)
+               ELSEWHERE
+                  zht_i_ini(:,:) = rn_hti_ini_s * zswitch(:,:)
+                  zht_s_ini(:,:) = rn_hts_ini_s * zswitch(:,:)
+                  zat_i_ini(:,:) = rn_ati_ini_s * zswitch(:,:)
+                  zsm_i_ini(:,:) = rn_smi_ini_s * zswitch(:,:)
+                  ztm_i_ini(:,:) = rn_tmi_ini_s * zswitch(:,:)
+                  zt_su_ini(:,:) = rn_tsu_ini_s * zswitch(:,:)
+                  ztm_s_ini(:,:) = rn_tms_ini_s * zswitch(:,:)
+                  zapnd_ini(:,:) = rn_apd_ini_s * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc.
+                  zhpnd_ini(:,:) = rn_hpd_ini_s * zswitch(:,:)
+               END WHERE
+               !
+            ENDIF
+
+
+
+            ! make sure ponds = 0 if no ponds scheme
+            IF ( .NOT.ln_pnd ) THEN
+               zapnd_ini(:,:) = 0._wp
+               zhpnd_ini(:,:) = 0._wp
+            ENDIF
+            
+            !-------------!
+            ! fill fields !
+            !-------------!
+            ! select ice covered grid points
+            npti = 0 ; nptidx(:) = 0
+            DO_2D_11_11
+               IF ( zht_i_ini(ji,jj) > 0._wp ) THEN
+                  npti         = npti  + 1
+                  nptidx(npti) = (jj - 1) * jpi + ji
+               ENDIF
+            END_2D
+
+            ! move to 1D arrays: (jpi,jpj) -> (jpi*jpj)
+            CALL tab_2d_1d( npti, nptidx(1:npti), h_i_1d (1:npti)  , zht_i_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), h_s_1d (1:npti)  , zht_s_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), at_i_1d(1:npti)  , zat_i_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), t_i_1d (1:npti,1), ztm_i_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), t_s_1d (1:npti,1), ztm_s_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), t_su_1d(1:npti)  , zt_su_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), s_i_1d (1:npti)  , zsm_i_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_1d(1:npti)  , zapnd_ini )
+            CALL tab_2d_1d( npti, nptidx(1:npti), h_ip_1d(1:npti)  , zhpnd_ini )
+
+            ! allocate temporary arrays
+            ALLOCATE( zhi_2d(npti,jpl), zhs_2d(npti,jpl), zai_2d (npti,jpl), &
+               &      zti_2d(npti,jpl), zts_2d(npti,jpl), ztsu_2d(npti,jpl), zsi_2d(npti,jpl), zaip_2d(npti,jpl), zhip_2d(npti,jpl) )
+            
+            ! distribute 1-cat into jpl-cat: (jpi*jpj) -> (jpi*jpj,jpl)
+            CALL ice_var_itd( h_i_1d(1:npti)  , h_s_1d(1:npti)  , at_i_1d(1:npti),                                                   &
+               &              zhi_2d          , zhs_2d          , zai_2d         ,                                                   &
+               &              t_i_1d(1:npti,1), t_s_1d(1:npti,1), t_su_1d(1:npti), s_i_1d(1:npti), a_ip_1d(1:npti), h_ip_1d(1:npti), &
+               &              zti_2d          , zts_2d          , ztsu_2d        , zsi_2d        , zaip_2d        , zhip_2d )
+
+            ! move to 3D arrays: (jpi*jpj,jpl) -> (jpi,jpj,jpl)
+            DO jl = 1, jpl
+               zti_3d(:,:,jl) = rt0 * tmask(:,:,1)
+               zts_3d(:,:,jl) = rt0 * tmask(:,:,1)
+            END DO
+            CALL tab_2d_3d( npti, nptidx(1:npti), zhi_2d   , h_i    )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zhs_2d   , h_s    )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zai_2d   , a_i    )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zti_2d   , zti_3d )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zts_2d   , zts_3d )
+            CALL tab_2d_3d( npti, nptidx(1:npti), ztsu_2d  , t_su   )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zsi_2d   , s_i    )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zaip_2d  , a_ip   )
+            CALL tab_2d_3d( npti, nptidx(1:npti), zhip_2d  , h_ip   )
+
+            ! deallocate temporary arrays
+            DEALLOCATE( zhi_2d, zhs_2d, zai_2d , &
+               &        zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d )
+
+            ! calculate extensive and intensive variables
+            CALL ice_var_salprof ! for sz_i
+            DO jl = 1, jpl
+               DO_2D_11_11
+                  v_i (ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)
+                  v_s (ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)
+                  sv_i(ji,jj,jl) = MIN( MAX( rn_simin , s_i(ji,jj,jl) ) , rn_simax ) * v_i(ji,jj,jl)
+               END_2D
+            END DO
+            !
+            DO jl = 1, jpl
+               DO_3D_11_11( 1, nlay_s )
+                  t_s(ji,jj,jk,jl) = zts_3d(ji,jj,jl)
+                  e_s(ji,jj,jk,jl) = zswitch(ji,jj) * v_s(ji,jj,jl) * r1_nlay_s * &
+                     &               rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus )
+               END_3D
+            END DO
+            !
+            DO jl = 1, jpl
+               DO_3D_11_11( 1, nlay_i )
+                  t_i (ji,jj,jk,jl) = zti_3d(ji,jj,jl) 
+                  ztmelts          = - rTmlt * sz_i(ji,jj,jk,jl) + rt0 ! melting temperature in K
+                  e_i(ji,jj,jk,jl) = zswitch(ji,jj) * v_i(ji,jj,jl) * r1_nlay_i * &
+                     &               rhoi * (  rcpi  * ( ztmelts - t_i(ji,jj,jk,jl) ) + &
+                     &                         rLfus * ( 1._wp - (ztmelts-rt0) / MIN( (t_i(ji,jj,jk,jl)-rt0), -epsi20 ) ) &
+                     &                       - rcp   * ( ztmelts - rt0 ) )
+               END_3D
+            END DO
+
+            ! Melt ponds
+            WHERE( a_i > epsi10 )
+               a_ip_frac(:,:,:) = a_ip(:,:,:) / a_i(:,:,:)
+            ELSEWHERE
+               a_ip_frac(:,:,:) = 0._wp
             END WHERE
+            v_ip(:,:,:) = h_ip(:,:,:) * a_ip(:,:,:)
+             
+            ! specific temperatures for coupled runs
+            tn_ice(:,:,:) = t_su(:,:,:)
+            t1_ice(:,:,:) = t_i (:,:,1,:)
             !
-            CALL fld_read( kt, 1, si ) ! input fields provided at the current time-step
-            !
-            ! -- mandatory fields -- !
-            zht_i_ini(:,:) = si(jp_hti)%fnow(:,:,1) * tmask(:,:,1)
-            zht_s_ini(:,:) = si(jp_hts)%fnow(:,:,1) * tmask(:,:,1)
-            zat_i_ini(:,:) = si(jp_ati)%fnow(:,:,1) * tmask(:,:,1)
-
-            ! -- optional fields -- !
-            !    if fields do not exist then set them to the values present in the namelist (except for snow and surface temperature)
-            !
-            ! ice salinity
-            IF( TRIM(si(jp_smi)%clrootname) == 'NOT USED' ) &
-               &     si(jp_smi)%fnow(:,:,1) = ( rn_smi_ini_n * zswitch + rn_smi_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
-            !
-            ! temperatures
-            IF    ( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. &
-               &    TRIM(si(jp_tms)%clrootname) == 'NOT USED' ) THEN
-               si(jp_tmi)%fnow(:,:,1) = ( rn_tmi_ini_n * zswitch + rn_tmi_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
-               si(jp_tsu)%fnow(:,:,1) = ( rn_tsu_ini_n * zswitch + rn_tsu_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
-               si(jp_tms)%fnow(:,:,1) = ( rn_tms_ini_n * zswitch + rn_tms_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
-            ELSEIF( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tms)%clrootname) /= 'NOT USED' ) THEN ! if T_s is read and not T_i, set T_i = (T_s + T_freeze)/2
-               si(jp_tmi)%fnow(:,:,1) = 0.5_wp * ( si(jp_tms)%fnow(:,:,1) + 271.15 )
-            ELSEIF( TRIM(si(jp_tmi)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tsu)%clrootname) /= 'NOT USED' ) THEN ! if T_su is read and not T_i, set T_i = (T_su + T_freeze)/2
-               si(jp_tmi)%fnow(:,:,1) = 0.5_wp * ( si(jp_tsu)%fnow(:,:,1) + 271.15 )
-            ELSEIF( TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tms)%clrootname) /= 'NOT USED' ) THEN ! if T_s is read and not T_su, set T_su = T_s
-               si(jp_tsu)%fnow(:,:,1) = si(jp_tms)%fnow(:,:,1)
-            ELSEIF( TRIM(si(jp_tsu)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) /= 'NOT USED' ) THEN ! if T_i is read and not T_su, set T_su = T_i
-               si(jp_tsu)%fnow(:,:,1) = si(jp_tmi)%fnow(:,:,1)
-            ELSEIF( TRIM(si(jp_tms)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tsu)%clrootname) /= 'NOT USED' ) THEN ! if T_su is read and not T_s, set T_s = T_su
-               si(jp_tms)%fnow(:,:,1) = si(jp_tsu)%fnow(:,:,1)
-            ELSEIF( TRIM(si(jp_tms)%clrootname) == 'NOT USED' .AND. TRIM(si(jp_tmi)%clrootname) /= 'NOT USED' ) THEN ! if T_i is read and not T_s, set T_s = T_i
-               si(jp_tms)%fnow(:,:,1) = si(jp_tmi)%fnow(:,:,1)
-            ENDIF
-            !
-            ! pond concentration
-            IF( TRIM(si(jp_apd)%clrootname) == 'NOT USED' ) &
-               &     si(jp_apd)%fnow(:,:,1) = ( rn_apd_ini_n * zswitch + rn_apd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1) & ! rn_apd = pond fraction => rn_apnd * a_i = pond conc.
-               &                              * si(jp_ati)%fnow(:,:,1) 
-            !
-            ! pond depth
-            IF( TRIM(si(jp_hpd)%clrootname) == 'NOT USED' ) &
-               &     si(jp_hpd)%fnow(:,:,1) = ( rn_hpd_ini_n * zswitch + rn_hpd_ini_s * (1._wp - zswitch) ) * tmask(:,:,1)
-            !
-            zsm_i_ini(:,:) = si(jp_smi)%fnow(:,:,1) * tmask(:,:,1)
-            ztm_i_ini(:,:) = si(jp_tmi)%fnow(:,:,1) * tmask(:,:,1)
-            zt_su_ini(:,:) = si(jp_tsu)%fnow(:,:,1) * tmask(:,:,1)
-            ztm_s_ini(:,:) = si(jp_tms)%fnow(:,:,1) * tmask(:,:,1)
-            zapnd_ini(:,:) = si(jp_apd)%fnow(:,:,1) * tmask(:,:,1)
-            zhpnd_ini(:,:) = si(jp_hpd)%fnow(:,:,1) * tmask(:,:,1)
-            !
-            ! change the switch for the following
-            WHERE( zat_i_ini(:,:) > 0._wp )   ;   zswitch(:,:) = tmask(:,:,1) 
-            ELSEWHERE                         ;   zswitch(:,:) = 0._wp
+         
+#if  defined key_agrif
+         ELSE
+ 
+            Agrif_SpecialValue    = -9999.
+            Agrif_UseSpecialValue = .TRUE.
+            CALL Agrif_init_variable(tra_iceini_id,procname=interp_tra_ice)
+            use_sign_north = .TRUE.
+            sign_north = -1.
+            CALL Agrif_init_variable(u_iceini_id  ,procname=interp_u_ice)
+            CALL Agrif_init_variable(v_iceini_id  ,procname=interp_v_ice)
+            Agrif_SpecialValue    = 0._wp
+            use_sign_north = .FALSE.
+            Agrif_UseSpecialValue = .FALSE.
+        ! lbc ???? 
+   ! Here we know : a_i, v_i, v_s, sv_i, oa_i, a_ip, v_ip, t_su, e_s, e_i
+            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
-            !                          !---------------!
-         ELSE                          ! Read namelist !
-            !                          !---------------!
-            ! no ice if (sst - Tfreez) >= thresold
-            WHERE( ( sst_m(:,:) - (t_bo(:,:) - rt0) ) * tmask(:,:,1) >= rn_thres_sst )   ;   zswitch(:,:) = 0._wp 
-            ELSEWHERE                                                                    ;   zswitch(:,:) = tmask(:,:,1)
-            END WHERE
-            !
-            ! assign initial thickness, concentration, snow depth and salinity to an hemisphere-dependent array
-            WHERE( ff_t(:,:) >= 0._wp )
-               zht_i_ini(:,:) = rn_hti_ini_n * zswitch(:,:)
-               zht_s_ini(:,:) = rn_hts_ini_n * zswitch(:,:)
-               zat_i_ini(:,:) = rn_ati_ini_n * zswitch(:,:)
-               zsm_i_ini(:,:) = rn_smi_ini_n * zswitch(:,:)
-               ztm_i_ini(:,:) = rn_tmi_ini_n * zswitch(:,:)
-               zt_su_ini(:,:) = rn_tsu_ini_n * zswitch(:,:)
-               ztm_s_ini(:,:) = rn_tms_ini_n * zswitch(:,:)
-               zapnd_ini(:,:) = rn_apd_ini_n * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc. 
-               zhpnd_ini(:,:) = rn_hpd_ini_n * zswitch(:,:)
+            WHERE( a_ip > 0._wp )       ! ???????    
+               h_ip(:,:,:) = v_ip(:,:,:) / a_ip(:,:,:)
             ELSEWHERE
-               zht_i_ini(:,:) = rn_hti_ini_s * zswitch(:,:)
-               zht_s_ini(:,:) = rn_hts_ini_s * zswitch(:,:)
-               zat_i_ini(:,:) = rn_ati_ini_s * zswitch(:,:)
-               zsm_i_ini(:,:) = rn_smi_ini_s * zswitch(:,:)
-               ztm_i_ini(:,:) = rn_tmi_ini_s * zswitch(:,:)
-               zt_su_ini(:,:) = rn_tsu_ini_s * zswitch(:,:)
-               ztm_s_ini(:,:) = rn_tms_ini_s * zswitch(:,:)
-               zapnd_ini(:,:) = rn_apd_ini_s * zswitch(:,:) * zat_i_ini(:,:) ! rn_apd = pond fraction => rn_apd * a_i = pond conc.
-               zhpnd_ini(:,:) = rn_hpd_ini_s * zswitch(:,:)
-            END WHERE
-            !
-         ENDIF
-
-         ! make sure ponds = 0 if no ponds scheme
-         IF ( .NOT.ln_pnd ) THEN
-            zapnd_ini(:,:) = 0._wp
-            zhpnd_ini(:,:) = 0._wp
-         ENDIF
-         
-         !-------------!
-         ! fill fields !
-         !-------------!
-         ! select ice covered grid points
-         npti = 0 ; nptidx(:) = 0
-         DO_2D_11_11
-            IF ( zht_i_ini(ji,jj) > 0._wp ) THEN
-               npti         = npti  + 1
-               nptidx(npti) = (jj - 1) * jpi + ji
-            ENDIF
-         END_2D
-
-         ! move to 1D arrays: (jpi,jpj) -> (jpi*jpj)
-         CALL tab_2d_1d( npti, nptidx(1:npti), h_i_1d (1:npti)  , zht_i_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), h_s_1d (1:npti)  , zht_s_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), at_i_1d(1:npti)  , zat_i_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), t_i_1d (1:npti,1), ztm_i_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), t_s_1d (1:npti,1), ztm_s_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), t_su_1d(1:npti)  , zt_su_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), s_i_1d (1:npti)  , zsm_i_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), a_ip_1d(1:npti)  , zapnd_ini )
-         CALL tab_2d_1d( npti, nptidx(1:npti), h_ip_1d(1:npti)  , zhpnd_ini )
-
-         ! allocate temporary arrays
-         ALLOCATE( zhi_2d(npti,jpl), zhs_2d(npti,jpl), zai_2d (npti,jpl), &
-            &      zti_2d(npti,jpl), zts_2d(npti,jpl), ztsu_2d(npti,jpl), zsi_2d(npti,jpl), zaip_2d(npti,jpl), zhip_2d(npti,jpl) )
-         
-         ! distribute 1-cat into jpl-cat: (jpi*jpj) -> (jpi*jpj,jpl)
-         CALL ice_var_itd( h_i_1d(1:npti)  , h_s_1d(1:npti)  , at_i_1d(1:npti),                                                   &
-            &              zhi_2d          , zhs_2d          , zai_2d         ,                                                   &
-            &              t_i_1d(1:npti,1), t_s_1d(1:npti,1), t_su_1d(1:npti), s_i_1d(1:npti), a_ip_1d(1:npti), h_ip_1d(1:npti), &
-            &              zti_2d          , zts_2d          , ztsu_2d        , zsi_2d        , zaip_2d        , zhip_2d )
-
-         ! move to 3D arrays: (jpi*jpj,jpl) -> (jpi,jpj,jpl)
-         DO jl = 1, jpl
-            zti_3d(:,:,jl) = rt0 * tmask(:,:,1)
-            zts_3d(:,:,jl) = rt0 * tmask(:,:,1)
-         END DO
-         CALL tab_2d_3d( npti, nptidx(1:npti), zhi_2d   , h_i    )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zhs_2d   , h_s    )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zai_2d   , a_i    )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zti_2d   , zti_3d )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zts_2d   , zts_3d )
-         CALL tab_2d_3d( npti, nptidx(1:npti), ztsu_2d  , t_su   )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zsi_2d   , s_i    )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zaip_2d  , a_ip   )
-         CALL tab_2d_3d( npti, nptidx(1:npti), zhip_2d  , h_ip   )
-
-         ! deallocate temporary arrays
-         DEALLOCATE( zhi_2d, zhs_2d, zai_2d , &
-            &        zti_2d, zts_2d, ztsu_2d, zsi_2d, zaip_2d, zhip_2d )
-
-         ! calculate extensive and intensive variables
-         CALL ice_var_salprof ! for sz_i
-         DO jl = 1, jpl
-            DO_2D_11_11
-               v_i (ji,jj,jl) = h_i(ji,jj,jl) * a_i(ji,jj,jl)
-               v_s (ji,jj,jl) = h_s(ji,jj,jl) * a_i(ji,jj,jl)
-               sv_i(ji,jj,jl) = MIN( MAX( rn_simin , s_i(ji,jj,jl) ) , rn_simax ) * v_i(ji,jj,jl)
-            END_2D
-         END DO
-         !
-         DO jl = 1, jpl
-            DO_3D_11_11( 1, nlay_s )
-               t_s(ji,jj,jk,jl) = zts_3d(ji,jj,jl)
-               e_s(ji,jj,jk,jl) = zswitch(ji,jj) * v_s(ji,jj,jl) * r1_nlay_s * &
-                  &               rhos * ( rcpi * ( rt0 - t_s(ji,jj,jk,jl) ) + rLfus )
-            END_3D
-         END DO
-         !
-         DO jl = 1, jpl
-            DO_3D_11_11( 1, nlay_i )
-               t_i (ji,jj,jk,jl) = zti_3d(ji,jj,jl) 
-               ztmelts          = - rTmlt * sz_i(ji,jj,jk,jl) + rt0 ! melting temperature in K
-               e_i(ji,jj,jk,jl) = zswitch(ji,jj) * v_i(ji,jj,jl) * r1_nlay_i * &
-                  &               rhoi * (  rcpi  * ( ztmelts - t_i(ji,jj,jk,jl) ) + &
-                  &                         rLfus * ( 1._wp - (ztmelts-rt0) / MIN( (t_i(ji,jj,jk,jl)-rt0), -epsi20 ) ) &
-                  &                       - rcp   * ( ztmelts - rt0 ) )
-            END_3D
-         END DO
-
-         ! Melt ponds
-         WHERE( a_i > epsi10 )
-            a_ip_frac(:,:,:) = a_ip(:,:,:) / a_i(:,:,:)
-         ELSEWHERE
-            a_ip_frac(:,:,:) = 0._wp
-         END WHERE
-         v_ip(:,:,:) = h_ip(:,:,:) * a_ip(:,:,:)
-          
-         ! specific temperatures for coupled runs
-         tn_ice(:,:,:) = t_su(:,:,:)
-         t1_ice(:,:,:) = t_i (:,:,1,:)
-         !
+               h_ip(:,:,:) = 0._wp
+            END WHERE   
+
+            tn_ice(:,:,:) = t_su(:,:,:)
+            t1_ice(:,:,:) = t_i (:,:,1,:)
+#endif
+          ENDIF ! Agrif_Root
       ENDIF ! ln_iceini
       !
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ICE/icestp.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ICE/icestp.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/ICE/icestp.F90	(revision 13229)
@@ -240,4 +240,8 @@
       CALL par_init                ! set some ice run parameters
       !
+#if defined key_agrif
+      CALL Agrif_Declare_Var_ice  !  "      "   "   "      "  Sea ice
+#endif
+      !
       !                                ! Allocate the ice arrays (sbc_ice already allocated in sbc_init)
       ierr =        ice_alloc        ()      ! ice variables
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice.F90	(revision 13229)
@@ -16,4 +16,5 @@
 
    INTEGER, PUBLIC ::  u_ice_id, v_ice_id, tra_ice_id
+   INTEGER, PUBLIC ::  u_iceini_id, v_iceini_id, tra_iceini_id
    INTEGER, PUBLIC ::  nbstep_ice = 0    ! child time position in sea-ice model
 
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice_interp.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice_interp.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice_interp.F90	(revision 13229)
@@ -14,7 +14,7 @@
    !!----------------------------------------------------------------------
    !!  agrif_interp_ice    : interpolation of ice at "after" sea-ice time step
-   !!  agrif_interp_u_ice   : atomic routine to interpolate u_ice 
-   !!  agrif_interp_v_ice   : atomic routine to interpolate v_ice 
-   !!  agrif_interp_tra_ice : atomic routine to interpolate ice properties 
+   !!  interp_u_ice   : atomic routine to interpolate u_ice 
+   !!  interp_v_ice   : atomic routine to interpolate v_ice 
+   !!  interp_tra_ice : atomic routine to interpolate ice properties 
    !!----------------------------------------------------------------------
    USE par_oce
@@ -23,4 +23,5 @@
    USE ice
    USE agrif_ice
+   USE agrif_oce
    USE phycst , ONLY: rt0
    
@@ -29,4 +30,5 @@
 
    PUBLIC   agrif_interp_ice   ! called by agrif_user.F90
+   PUBLIC   interp_tra_ice, interp_u_ice, interp_v_ice  ! called by iceistate.F90
 
    !!----------------------------------------------------------------------
@@ -68,4 +70,9 @@
       Agrif_SpecialValue    = -9999.
       Agrif_UseSpecialValue = .TRUE.
+
+      use_sign_north = .TRUE.
+      sign_north = -1.
+      if (cd_type == 'T') use_sign_north = .FALSE.
+
       SELECT CASE( cd_type )
       CASE('U')   ;   CALL Agrif_Bc_variable( u_ice_id  , procname=interp_u_ice  , calledweight=zbeta )
@@ -75,4 +82,6 @@
       Agrif_SpecialValue    = 0._wp
       Agrif_UseSpecialValue = .FALSE.
+      
+      use_sign_north = .FALSE.
       !
    END SUBROUTINE agrif_interp_ice
@@ -156,5 +165,5 @@
       ! and it is ok since we conserve tracers (same as in the ocean).
       ALLOCATE( ztab(SIZE(a_i,1),SIZE(a_i,2),SIZE(ptab,3)) )
-     
+
       IF( before ) THEN  ! parent grid
          jm = 1
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice_update.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice_update.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_ice_update.F90	(revision 13229)
@@ -66,4 +66,7 @@
       CALL Agrif_Update_Variable( tra_ice_id , locupdate=(/1,0/), procname = update_tra_ice  )
 #endif
+      use_sign_north = .TRUE.
+      sign_north = -1.
+
 # if ! defined DECAL_FEEDBACK
       CALL Agrif_Update_Variable( u_ice_id   , procname = update_u_ice    )
@@ -73,4 +76,5 @@
       CALL Agrif_Update_Variable( v_ice_id   , locupdate1=(/1,-2/),locupdate2=(/0,-1/),procname=update_v_ice)
 #endif
+      use_sign_north = .FALSE.
 !      CALL Agrif_Update_Variable( tra_ice_id , locupdate=(/0,2/), procname = update_tra_ice  )
 !      CALL Agrif_Update_Variable( u_ice_id   , locupdate=(/0,1/), procname = update_u_ice    )
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce.F90	(revision 13229)
@@ -19,4 +19,5 @@
   
    !                                              !!* Namelist namagrif: AGRIF parameters
+   LOGICAL , PUBLIC ::   ln_init_chfrpar = .FALSE. !: set child grids initial state from parent
    LOGICAL , PUBLIC ::   ln_agrif_2way = .TRUE.    !: activate two way nesting 
    LOGICAL , PUBLIC ::   ln_spc_dyn    = .FALSE.   !: use zeros (.false.) or not (.true.) in
@@ -29,4 +30,5 @@
    !
    INTEGER , PUBLIC, PARAMETER ::   nn_sponge_len = 2  !: Sponge width (in number of parent grid points)
+
    LOGICAL , PUBLIC :: spongedoneT = .FALSE.       !: tracer   sponge layer indicator
    LOGICAL , PUBLIC :: spongedoneU = .FALSE.       !: dynamics sponge layer indicator
@@ -49,8 +51,6 @@
    INTEGER , PUBLIC,              SAVE                 ::  Kbb_a, Kmm_a, Krhs_a   !: AGRIF module-specific copies of time-level indices
 
-# if defined key_vertical
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: ht0_parent, hu0_parent, hv0_parent
    INTEGER,  PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: mbkt_parent, mbku_parent, mbkv_parent
-# endif
 
    INTEGER, PUBLIC :: tsn_id                                                  ! AGRIF profile for tracers interpolation and update
@@ -58,4 +58,5 @@
    INTEGER, PUBLIC :: un_update_id, vn_update_id                              ! AGRIF profiles for udpates
    INTEGER, PUBLIC :: tsn_sponge_id, un_sponge_id, vn_sponge_id               ! AGRIF profiles for sponge layers
+   INTEGER, PUBLIC :: tsini_id, uini_id, vini_id, sshini_id                   ! AGRIF profile for initialization
 # if defined key_top
    INTEGER, PUBLIC :: trn_id, trn_sponge_id
@@ -69,4 +70,16 @@
    INTEGER, PUBLIC :: glamt_id, gphit_id
    INTEGER, PUBLIC :: kindic_agr
+
+   ! North fold
+!$AGRIF_DO_NOT_TREAT
+   LOGICAL, PUBLIC :: use_sign_north
+   REAL, PUBLIC :: sign_north
+   LOGICAL, PUBLIC :: l_ini_child = .FALSE.
+# if defined key_vertical
+   LOGICAL, PUBLIC :: l_vremap    = .TRUE.
+# else
+   LOGICAL, PUBLIC :: l_vremap    = .FALSE.
+# endif
+!$AGRIF_END_DO_NOT_TREAT
    
    !!----------------------------------------------------------------------
@@ -92,9 +105,7 @@
          &      tabspongedone_trn(jpi,jpj),           &
 # endif   
-# if defined key_vertical
          &      ht0_parent(jpi,jpj), mbkt_parent(jpi,jpj),  &
          &      hu0_parent(jpi,jpj), mbku_parent(jpi,jpj),  &
          &      hv0_parent(jpi,jpj), mbkv_parent(jpi,jpj),  &
-# endif      
          &      tabspongedone_u  (jpi,jpj),           &
          &      tabspongedone_v  (jpi,jpj), STAT = ierr(1) )
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_interp.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_interp.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_interp.F90	(revision 13229)
@@ -95,245 +95,253 @@
       !
       ! --- West --- !
-      ibdy1 = nn_hls + 2                  ! halo + land + 1
-      ibdy2 = nn_hls + 1 + nbghostcells   ! halo + land + nbghostcells
-      !
-      IF( .NOT.ln_dynspg_ts ) THEN  ! Store tangential transport
+      IF( lk_west ) THEN
+         ibdy1 = nn_hls + 2                  ! halo + land + 1
+         ibdy2 = nn_hls + 1 + nbghostcells   ! halo + land + nbghostcells
+         !
+         IF( .NOT.ln_dynspg_ts ) THEN  ! Store tangential transport
+            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) = uu_b(ji,jj,Krhs_a) * r1_hu(ji,jj,Krhs_a)
+               END DO
+            END DO
+         ENDIF
+         !
          DO ji = mi0(ibdy1), mi1(ibdy2)
-            uu_b(ji,:,Krhs_a) = 0._wp
-
+            zub(ji,:) = 0._wp    ! Correct tangential transport
             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) = uu_b(ji,jj,Krhs_a) * r1_hu(ji,jj,Krhs_a)
-            END DO
-         END DO
-      ENDIF
-      !
-      DO ji = mi0(ibdy1), mi1(ibdy2)
-         zub(ji,:) = 0._wp    ! Correct tangential transport
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               zub(ji,jj) = zub(ji,jj) & 
-                  & + e3u(ji,jj,jk,Krhs_a)  * uu(ji,jj,jk,Krhs_a)*umask(ji,jj,jk)
-            END DO
-         END DO
-         DO jj=1,jpj
-            zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
-         END DO
+                  zub(ji,jj) = zub(ji,jj) & 
+                     & + e3u(ji,jj,jk,Krhs_a)  * uu(ji,jj,jk,Krhs_a)*umask(ji,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
+            END DO
             
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) + uu_b(ji,jj,Krhs_a)-zub(ji,jj)) * umask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-            
-      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-         DO ji = mi0(ibdy1), mi1(ibdy2)
-            zvb(ji,:) = 0._wp
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  zvb(ji,jj) = zvb(ji,jj) + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
-               END DO
-            END DO
-            DO jj = 1, jpj
-               zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
-            END DO
+                  uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) + uu_b(ji,jj,Krhs_a)-zub(ji,jj)) * umask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+            
+         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+            DO ji = mi0(ibdy1), mi1(ibdy2)
+               zvb(ji,:) = 0._wp
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     zvb(ji,jj) = zvb(ji,jj) + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
+                  END DO
+               END DO
+               DO jj = 1, jpj
+                  zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
+               END DO
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) + vv_b(ji,jj,Krhs_a)-zvb(ji,jj))*vmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+
+      ! --- East --- !
+      IF( lk_east ) THEN
+         ibdy1 = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+         ibdy2 = jpiglo - ( nn_hls + 2 )                 ! halo + land + 1
+         !
+         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+            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) = uu_b(ji,jj,Krhs_a) * r1_hu(ji,jj,Krhs_a)
+               END DO
+            END DO
+         ENDIF
+         !
+         DO ji = mi0(ibdy1), mi1(ibdy2)
+            zub(ji,:) = 0._wp    ! Correct transport
             DO jk = 1, jpkm1
                DO jj = 1, jpj
-                  vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) + vv_b(ji,jj,Krhs_a)-zvb(ji,jj))*vmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-      ENDIF
-
-      ! --- East --- !
-      ibdy1 = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-      ibdy2 = jpiglo - ( nn_hls + 2 )                 ! halo + land + 1
-      !
-      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-         DO ji = mi0(ibdy1), mi1(ibdy2)
-            uu_b(ji,:,Krhs_a) = 0._wp
+                  zub(ji,jj) = zub(ji,jj) & 
+                     & + e3u(ji,jj,jk,Krhs_a)  * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
+            END DO
+            
             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) = uu_b(ji,jj,Krhs_a) * r1_hu(ji,jj,Krhs_a)
-            END DO
-         END DO
-      ENDIF
-      !
-      DO ji = mi0(ibdy1), mi1(ibdy2)
-         zub(ji,:) = 0._wp    ! Correct transport
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               zub(ji,jj) = zub(ji,jj) & 
-                  & + e3u(ji,jj,jk,Krhs_a)  * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
-            END DO
-         END DO
-         DO jj=1,jpj
-            zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
+                  uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) & 
+                    & + uu_b(ji,jj,Krhs_a)-zub(ji,jj))*umask(ji,jj,jk)
+               END DO
+            END DO
          END DO
             
-         DO jk = 1, jpkm1
-            DO jj = 1, jpj
-               uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) & 
-                 & + uu_b(ji,jj,Krhs_a)-zub(ji,jj))*umask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-            
-      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-         ibdy1 = jpiglo - ( nn_hls + nbghostcells )   ! halo + land + nbghostcells - 1
-         ibdy2 = jpiglo - ( nn_hls + 1 )              ! halo + land + 1            - 1
-         DO ji = mi0(ibdy1), mi1(ibdy2)
-            zvb(ji,:) = 0._wp
-            DO jk = 1, jpkm1
+         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+            ibdy1 = jpiglo - ( nn_hls + nbghostcells )   ! halo + land + nbghostcells - 1
+            ibdy2 = jpiglo - ( nn_hls + 1 )              ! halo + land + 1            - 1
+            DO ji = mi0(ibdy1), mi1(ibdy2)
+               zvb(ji,:) = 0._wp
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     zvb(ji,jj) = zvb(ji,jj) &
+                        & + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
+                  END DO
+               END DO
                DO jj = 1, jpj
-                  zvb(ji,jj) = zvb(ji,jj) &
+                  zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
+               END DO
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpj
+                     vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) & 
+                         & + vv_b(ji,jj,Krhs_a)-zvb(ji,jj)) * vmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+
+      ! --- South --- !
+      IF( lk_south ) THEN
+         jbdy1 = nn_hls + 2                  ! halo + land + 1
+         jbdy2 = nn_hls + 1 + nbghostcells   ! halo + land + nbghostcells
+         !
+         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+            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)     
+               END DO
+            END DO
+         ENDIF
+         !
+         DO jj = mj0(jbdy1), mj1(jbdy2)
+            zvb(:,jj) = 0._wp    ! Correct transport
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  zvb(ji,jj) = zvb(ji,jj) & 
                      & + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
                END DO
             END DO
-            DO jj = 1, jpj
+            DO ji = 1, jpi
                zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
             END DO
-            DO jk = 1, jpkm1
-               DO jj = 1, jpj
-                  vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) & 
-                      & + vv_b(ji,jj,Krhs_a)-zvb(ji,jj)) * vmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-      ENDIF
-
-      ! --- South --- !
-      jbdy1 = nn_hls + 2                  ! halo + land + 1
-      jbdy2 = nn_hls + 1 + nbghostcells   ! halo + land + nbghostcells
-      !
-      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-         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)     
-            END DO
-         END DO
-      ENDIF
-      !
-      DO jj = mj0(jbdy1), mj1(jbdy2)
-         zvb(:,jj) = 0._wp    ! Correct transport
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               zvb(ji,jj) = zvb(ji,jj) & 
-                  & + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
-            END DO
-         END DO
-         DO ji = 1, jpi
-            zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
-         END DO
-
-         DO jk = 1, jpkm1
+                  vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) & 
+                    & + vv_b(ji,jj,Krhs_a) - zvb(ji,jj) ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+            
+         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+            DO jj = mj0(jbdy1), mj1(jbdy2)
+               zub(:,jj) = 0._wp
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     zub(ji,jj) = zub(ji,jj) & 
+                        & + e3u(ji,jj,jk,Krhs_a) * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
+                  END DO
+               END DO
+               DO ji = 1, jpi
+                  zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
+               END DO
+               
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) & 
+                        & + uu_b(ji,jj,Krhs_a) - zub(ji,jj) ) * umask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+      ENDIF
+
+      ! --- North --- !
+      IF( lk_north ) THEN
+         jbdy1 = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+         jbdy2 = jpjglo - ( nn_hls + 2 )                 ! halo + land + 1
+         !
+         IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
+            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)
+               END DO
+            END DO
+         ENDIF
+         !
+         DO jj = mj0(jbdy1), mj1(jbdy2)
+            zvb(:,jj) = 0._wp    ! Correct transport
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  zvb(ji,jj) = zvb(ji,jj) & 
+                     & + 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(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) & 
-                 & + vv_b(ji,jj,Krhs_a) - zvb(ji,jj) ) * vmask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-            
-      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-         DO jj = mj0(jbdy1), mj1(jbdy2)
-            zub(:,jj) = 0._wp
+               zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
+            END DO
+
             DO jk = 1, jpkm1
                DO ji = 1, jpi
-                  zub(ji,jj) = zub(ji,jj) & 
-                     & + e3u(ji,jj,jk,Krhs_a) * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
-               END DO
-            END DO
-            DO ji = 1, jpi
-               zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
-            END DO
+                  vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) & 
+                     & + vv_b(ji,jj,Krhs_a) - zvb(ji,jj) ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+            
+         IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
+            jbdy1 = jpjglo - ( nn_hls + nbghostcells )   ! halo + land + nbghostcells - 1
+            jbdy2 = jpjglo - ( nn_hls + 1 )              ! halo + land + 1            - 1
+            DO jj = mj0(jbdy1), mj1(jbdy2)
+               zub(:,jj) = 0._wp
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     zub(ji,jj) = zub(ji,jj) & 
+                        & + e3u(ji,jj,jk,Krhs_a) * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
+                  END DO
+               END DO
+               DO ji = 1, jpi
+                  zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
+               END DO
                
-            DO jk = 1, jpkm1
-               DO ji = 1, jpi
-                  uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) & 
-                    & + uu_b(ji,jj,Krhs_a) - zub(ji,jj) ) * umask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-      ENDIF
-
-      ! --- North --- !
-      jbdy1 = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-      jbdy2 = jpjglo - ( nn_hls + 2 )                 ! halo + land + 1
-      !
-      IF( .NOT.ln_dynspg_ts ) THEN  ! Store transport
-         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)
-            END DO
-         END DO
-      ENDIF
-      !
-      DO jj = mj0(jbdy1), mj1(jbdy2)
-         zvb(:,jj) = 0._wp    ! Correct transport
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               zvb(ji,jj) = zvb(ji,jj) & 
-                  & + e3v(ji,jj,jk,Krhs_a) * vv(ji,jj,jk,Krhs_a) * vmask(ji,jj,jk)
-            END DO
-         END DO
-         DO ji = 1, jpi
-            zvb(ji,jj) = zvb(ji,jj) * r1_hv(ji,jj,Krhs_a)
-         END DO
-
-         DO jk = 1, jpkm1
-            DO ji = 1, jpi
-               vv(ji,jj,jk,Krhs_a) = ( vv(ji,jj,jk,Krhs_a) & 
-                 & + vv_b(ji,jj,Krhs_a) - zvb(ji,jj) ) * vmask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-            
-      IF( ln_dynspg_ts ) THEN       ! Set tangential velocities to time splitting estimate
-         jbdy1 = jpjglo - ( nn_hls + nbghostcells )   ! halo + land + nbghostcells - 1
-         jbdy2 = jpjglo - ( nn_hls + 1 )              ! halo + land + 1            - 1
-         DO jj = mj0(jbdy1), mj1(jbdy2)
-            zub(:,jj) = 0._wp
-            DO jk = 1, jpkm1
-               DO ji = 1, jpi
-                  zub(ji,jj) = zub(ji,jj) & 
-                     & + e3u(ji,jj,jk,Krhs_a) * uu(ji,jj,jk,Krhs_a) * umask(ji,jj,jk)
-               END DO
-            END DO
-            DO ji = 1, jpi
-               zub(ji,jj) = zub(ji,jj) * r1_hu(ji,jj,Krhs_a)
-            END DO
-               
-            DO jk = 1, jpkm1
-               DO ji = 1, jpi
-                  uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) & 
-                    & + uu_b(ji,jj,Krhs_a) - zub(ji,jj) ) * umask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
+               DO jk = 1, jpkm1
+                  DO ji = 1, jpi
+                     uu(ji,jj,jk,Krhs_a) = ( uu(ji,jj,jk,Krhs_a) & 
+                       & + uu_b(ji,jj,Krhs_a) - zub(ji,jj) ) * umask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
       ENDIF
       !
@@ -354,54 +362,62 @@
       !
       !--- West ---!
-      istart = nn_hls + 2                              ! halo + land + 1
-      iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO ji = mi0(istart), mi1(iend)
-         DO jj=1,jpj
-            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
-            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
-         END DO
-      END DO
+      IF( lk_west ) THEN
+         istart = nn_hls + 2                              ! halo + land + 1
+         iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO ji = mi0(istart), mi1(iend)
+            DO jj=1,jpj
+               va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+               ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
       !--- East ---!
-      istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO ji = mi0(istart), mi1(iend)
-         DO jj=1,jpj
-            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
-         END DO
-      END DO
-      istart = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-      iend   = jpiglo - ( nn_hls + 2 )                 ! halo + land + 1
-      DO ji = mi0(istart), mi1(iend)
-         DO jj=1,jpj
-            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
-         END DO
-      END DO
+      IF( lk_east ) THEN
+         istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO ji = mi0(istart), mi1(iend)
+            DO jj=1,jpj
+               va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+            END DO
+         END DO
+         istart = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+         iend   = jpiglo - ( nn_hls + 2 )                 ! halo + land + 1
+         DO ji = mi0(istart), mi1(iend)
+            DO jj=1,jpj
+               ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
       !--- South ---!
-      jstart = nn_hls + 2                              ! halo + land + 1
-      jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji=1,jpi
-            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
-            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
-         END DO
-      END DO
+      IF( lk_south ) THEN
+         jstart = nn_hls + 2                              ! halo + land + 1
+         jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji=1,jpi
+               ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+               va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
       !--- North ---!
-      jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji=1,jpi
-            ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
-         END DO
-      END DO
-      jstart = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-      jend   = jpjglo - ( nn_hls + 2 )                 ! halo + land + 1
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji=1,jpi
-            va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
-         END DO
-      END DO
+      IF( lk_north ) THEN
+         jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji=1,jpi
+               ua_e(ji,jj) = ubdy(ji,jj) * hur_e(ji,jj)
+            END DO
+         END DO
+         jstart = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+         jend   = jpjglo - ( nn_hls + 2 )                 ! halo + land + 1
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji=1,jpi
+               va_e(ji,jj) = vbdy(ji,jj) * hvr_e(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
    END SUBROUTINE Agrif_dyn_ts
@@ -421,54 +437,62 @@
       !
       !--- West ---!
-      istart = nn_hls + 2                              ! halo + land + 1
-      iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO ji = mi0(istart), mi1(iend)
-         DO jj=1,jpj
-            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
-            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
-         END DO
-      END DO
+      IF( lk_west ) THEN
+         istart = nn_hls + 2                              ! halo + land + 1
+         iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO ji = mi0(istart), mi1(iend)
+            DO jj=1,jpj
+               zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+               zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
       !--- East ---!
-      istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO ji = mi0(istart), mi1(iend)
-         DO jj=1,jpj
-            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
-         END DO
-      END DO
-      istart = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-      iend   = jpiglo - ( nn_hls + 2 )                 ! halo + land + 1
-      DO ji = mi0(istart), mi1(iend)
-         DO jj=1,jpj
-            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
-         END DO
-      END DO
+      IF( lk_east ) THEN
+         istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO ji = mi0(istart), mi1(iend)
+            DO jj=1,jpj
+               zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+            END DO
+         END DO
+         istart = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+         iend   = jpiglo - ( nn_hls + 2 )                 ! halo + land + 1
+         DO ji = mi0(istart), mi1(iend)
+            DO jj=1,jpj
+               zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
       !--- South ---!
-      jstart = nn_hls + 2                              ! halo + land + 1
-      jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji=1,jpi
-            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
-            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
-         END DO
-      END DO
+      IF( lk_south ) THEN
+         jstart = nn_hls + 2                              ! halo + land + 1
+         jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji=1,jpi
+               zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+               zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
       !--- North ---!
-      jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji=1,jpi
-            zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
-         END DO
-      END DO
-      jstart = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-      jend   = jpjglo - ( nn_hls + 2 )                 ! halo + land + 1
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji=1,jpi
-            zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
-         END DO
-      END DO
+      IF( lk_north ) THEN
+         jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji=1,jpi
+               zu(ji,jj) = ubdy(ji,jj) * e2u(ji,jj)
+            END DO
+         END DO
+         jstart = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+         jend   = jpjglo - ( nn_hls + 2 )                 ! halo + land + 1
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji=1,jpi
+               zv(ji,jj) = vbdy(ji,jj) * e1v(ji,jj)
+            END DO
+         END DO
+      ENDIF
       !
    END SUBROUTINE Agrif_dyn_ts_flux
@@ -489,5 +513,5 @@
       !
       ! Enforce volume conservation if no time refinement:  
-      IF ( Agrif_rhot()==1 ) ll_int_cons=.TRUE.  
+      IF    ( Agrif_rhot()==1 ) ll_int_cons=.TRUE.  
       !
       ! Interpolate barotropic fluxes
@@ -542,38 +566,46 @@
       !
       ! --- West --- !
-      istart = nn_hls + 2                              ! halo + land + 1
-      iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO ji = mi0(istart), mi1(iend)
-         DO jj = 1, jpj
-            ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+      IF( lk_west ) THEN
+        istart = nn_hls + 2                              ! halo + land + 1
+         iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO ji = mi0(istart), mi1(iend)
+            DO jj = 1, jpj
+               ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
       ! --- East --- !
-      istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO ji = mi0(istart), mi1(iend)
-         DO jj = 1, jpj
-            ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+      IF( lk_east ) THEN
+         istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO ji = mi0(istart), mi1(iend)
+            DO jj = 1, jpj
+               ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
       ! --- South --- !
-      jstart = nn_hls + 2                              ! halo + land + 1
-      jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji = 1, jpi
-            ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+      IF( lk_south ) THEN
+         jstart = nn_hls + 2                              ! halo + land + 1
+         jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji = 1, jpi
+               ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
       ! --- North --- !
-      jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji = 1, jpi
-            ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+      IF( lk_north ) THEN
+         jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji = 1, jpi
+               ssh(ji,jj,Krhs_a) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
    END SUBROUTINE Agrif_ssh
@@ -593,38 +625,46 @@
       !
       ! --- West --- !
-      istart = nn_hls + 2                              ! halo + land + 1
-      iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO ji = mi0(istart), mi1(iend)
-         DO jj = 1, jpj
-            ssha_e(ji,jj) = hbdy(ji,jj)
+      IF( lk_west ) THEN
+         istart = nn_hls + 2                              ! halo + land + 1
+         iend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO ji = mi0(istart), mi1(iend)
+            DO jj = 1, jpj
+               ssha_e(ji,jj) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
       ! --- East --- !
-      istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO ji = mi0(istart), mi1(iend)
-         DO jj = 1, jpj
-            ssha_e(ji,jj) = hbdy(ji,jj)
+      IF( lk_east ) THEN
+         istart = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         iend   = jpiglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO ji = mi0(istart), mi1(iend)
+            DO jj = 1, jpj
+               ssha_e(ji,jj) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
       ! --- South --- !
-      jstart = nn_hls + 2                              ! halo + land + 1
-      jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji = 1, jpi
-            ssha_e(ji,jj) = hbdy(ji,jj)
+      IF( lk_south ) THEN
+         jstart = nn_hls + 2                              ! halo + land + 1
+         jend   = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji = 1, jpi
+               ssha_e(ji,jj) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
       ! --- North --- !
-      jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-      jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
-      DO jj = mj0(jstart), mj1(jend)
-         DO ji = 1, jpi
-            ssha_e(ji,jj) = hbdy(ji,jj)
+      IF( lk_north ) THEN
+         jstart = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+         jend   = jpjglo - ( nn_hls + 1 )                 ! halo + land + 1            - 1
+         DO jj = mj0(jstart), mj1(jend)
+            DO ji = 1, jpi
+               ssha_e(ji,jj) = hbdy(ji,jj)
+            ENDDO
          ENDDO
-      ENDDO
+      ENDIF
       !
    END SUBROUTINE Agrif_ssh_ts
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_sponge.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_sponge.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_sponge.F90	(revision 13229)
@@ -131,42 +131,50 @@
 
          ! --- West --- !
-         ztabramp(:,:) = 0._wp
-         ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-         DO ji = mi0(ind1), mi1(ind1)                
-            ztabramp(ji,:) = ssumask(ji,:)
-         END DO
-         !
-         zmskwest(1:jpj) = MAXVAL(ztabramp(:,:), dim=1)
-         zmskwest(jpj+1:jpjmax) = 0._wp
+         IF( lk_west ) THEN
+            ztabramp(:,:) = 0._wp
+            ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            DO ji = mi0(ind1), mi1(ind1)                
+               ztabramp(ji,:) = ssumask(ji,:)
+            END DO
+            !
+            zmskwest(1:jpj) = MAXVAL(ztabramp(:,:), dim=1)
+            zmskwest(jpj+1:jpjmax) = 0._wp
+         ENDIF
 
          ! --- East --- !
-         ztabramp(:,:) = 0._wp
-         ind1 = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-         DO ji = mi0(ind1), mi1(ind1)                 
-            ztabramp(ji,:) = ssumask(ji,:)
-         END DO
-         !
-         zmskeast(1:jpj) = MAXVAL(ztabramp(:,:), dim=1)
-         zmskeast(jpj+1:jpjmax) = 0._wp
+         IF( lk_east ) THEN
+            ztabramp(:,:) = 0._wp
+            ind1 = jpiglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+            DO ji = mi0(ind1), mi1(ind1)                 
+               ztabramp(ji,:) = ssumask(ji,:)
+            END DO
+            !
+            zmskeast(1:jpj) = MAXVAL(ztabramp(:,:), dim=1)
+            zmskeast(jpj+1:jpjmax) = 0._wp
+         ENDIF
 
          ! --- South --- !
-         ztabramp(:,:) = 0._wp
-         ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-         DO jj = mj0(ind1), mj1(ind1)                 
-            ztabramp(:,jj) = ssvmask(:,jj)
-         END DO
-         !
-         zmsksouth(1:jpi) = MAXVAL(ztabramp(:,:), dim=2)
-         zmsksouth(jpi+1:jpimax) = 0._wp
+         IF( lk_south ) THEN
+            ztabramp(:,:) = 0._wp
+            ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            DO jj = mj0(ind1), mj1(ind1)                 
+               ztabramp(:,jj) = ssvmask(:,jj)
+            END DO
+            !
+            zmsksouth(1:jpi) = MAXVAL(ztabramp(:,:), dim=2)
+            zmsksouth(jpi+1:jpimax) = 0._wp
+         ENDIF
 
          ! --- North --- !
-         ztabramp(:,:) = 0._wp
-         ind1 = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
-         DO jj = mj0(ind1), mj1(ind1)                 
-            ztabramp(:,jj) = ssvmask(:,jj)
-         END DO
-         !
-         zmsknorth(1:jpi) = MAXVAL(ztabramp(:,:), dim=2)
-         zmsknorth(jpi+1:jpimax) = 0._wp
+         IF( lk_north ) THEN
+            ztabramp(:,:) = 0._wp
+            ind1 = jpjglo - ( nn_hls + nbghostcells + 1)   ! halo + land + nbghostcells
+            DO jj = mj0(ind1), mj1(ind1)                 
+               ztabramp(:,jj) = ssvmask(:,jj)
+            END DO
+            !
+            zmsknorth(1:jpi) = MAXVAL(ztabramp(:,:), dim=2)
+            zmsknorth(jpi+1:jpimax) = 0._wp
+         ENDIF
 
          ! JC: SPONGE MASKING TO BE SORTED OUT:
@@ -197,74 +205,82 @@
 
          ! --- West --- !
-         ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-         ind2 = nn_hls + 1 + nbghostcells + ispongearea 
-         DO ji = mi0(ind1), mi1(ind2)   
-            DO jj = 1, jpj               
-               ztabramp(ji,jj) = REAL( ind2 - mig(ji) ) * z1_ispongearea * zmskwest(jj)
-            END DO
-         END DO
-
-         ! ghost cells:
-         ind1 = 1
-         ind2 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-         DO ji = mi0(ind1), mi1(ind2)   
-            DO jj = 1, jpj               
-               ztabramp(ji,jj) = zmskwest(jj)
-            END DO
-         END DO
+         IF( lk_west ) THEN
+            ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            ind2 = nn_hls + 1 + nbghostcells + ispongearea 
+            DO ji = mi0(ind1), mi1(ind2)   
+               DO jj = 1, jpj               
+                  ztabramp(ji,jj) = REAL( ind2 - mig(ji) ) * z1_ispongearea * zmskwest(jj)
+               END DO
+            END DO
+
+            ! ghost cells:
+            ind1 = 1
+            ind2 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            DO ji = mi0(ind1), mi1(ind2)   
+               DO jj = 1, jpj               
+                  ztabramp(ji,jj) = zmskwest(jj)
+               END DO
+            END DO
+         ENDIF
 
          ! --- East --- !
-         ind1 = jpiglo - ( nn_hls + nbghostcells ) - ispongearea
-         ind2 = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-         DO ji = mi0(ind1), mi1(ind2)
-            DO jj = 1, jpj
-               ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( mig(ji) - ind1 ) * z1_ispongearea) * zmskeast(jj)
-            ENDDO
-         END DO
-
-         ! ghost cells:
-         ind1 = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-         ind2 = jpiglo
-         DO ji = mi0(ind1), mi1(ind2)
-            DO jj = 1, jpj
-               ztabramp(ji,jj) = zmskeast(jj)
-            ENDDO
-         END DO
+         IF( lk_east ) THEN
+            ind1 = jpiglo - ( nn_hls + nbghostcells ) - ispongearea
+            ind2 = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+            DO ji = mi0(ind1), mi1(ind2)
+               DO jj = 1, jpj
+                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( mig(ji) - ind1 ) * z1_ispongearea) * zmskeast(jj)
+               ENDDO
+            END DO
+
+            ! ghost cells:
+            ind1 = jpiglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+            ind2 = jpiglo
+            DO ji = mi0(ind1), mi1(ind2)
+               DO jj = 1, jpj
+                  ztabramp(ji,jj) = zmskeast(jj)
+               ENDDO
+            END DO
+         ENDIF
 
          ! --- South --- !
-         ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-         ind2 = nn_hls + 1 + nbghostcells + jspongearea 
-         DO jj = mj0(ind1), mj1(ind2) 
-            DO ji = 1, jpi
-               ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( ind2 - mjg(jj) ) * z1_jspongearea) * zmsksouth(ji)
-            END DO
-         END DO
-
-         ! ghost cells:
-         ind1 = 1
-         ind2 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
-         DO jj = mj0(ind1), mj1(ind2) 
-            DO ji = 1, jpi
-               ztabramp(ji,jj) = zmsksouth(ji)
-            END DO
-         END DO
+         IF( lk_south ) THEN
+            ind1 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            ind2 = nn_hls + 1 + nbghostcells + jspongearea 
+            DO jj = mj0(ind1), mj1(ind2) 
+               DO ji = 1, jpi
+                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( ind2 - mjg(jj) ) * z1_jspongearea) * zmsksouth(ji)
+               END DO
+            END DO
+
+            ! ghost cells:
+            ind1 = 1
+            ind2 = nn_hls + 1 + nbghostcells               ! halo + land + nbghostcells
+            DO jj = mj0(ind1), mj1(ind2) 
+               DO ji = 1, jpi
+                  ztabramp(ji,jj) = zmsksouth(ji)
+               END DO
+            END DO
+         ENDIF
 
          ! --- North --- !
-         ind1 = jpjglo - ( nn_hls + nbghostcells ) - jspongearea
-         ind2 = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-         DO jj = mj0(ind1), mj1(ind2)
-            DO ji = 1, jpi
-               ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( mjg(jj) - ind1 ) * z1_jspongearea) * zmsknorth(ji)
-            END DO
-         END DO
-
-         ! ghost cells:
-         ind1 = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
-         ind2 = jpjglo
-         DO jj = mj0(ind1), mj1(ind2)
-            DO ji = 1, jpi
-               ztabramp(ji,jj) = zmsknorth(ji)
-            END DO
-         END DO
+         IF( lk_north ) THEN
+            ind1 = jpjglo - ( nn_hls + nbghostcells ) - jspongearea
+            ind2 = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+            DO jj = mj0(ind1), mj1(ind2)
+               DO ji = 1, jpi
+                  ztabramp(ji,jj) = MAX( ztabramp(ji,jj), REAL( mjg(jj) - ind1 ) * z1_jspongearea) * zmsknorth(ji)
+               END DO
+            END DO
+
+            ! ghost cells:
+            ind1 = jpjglo - ( nn_hls + nbghostcells )      ! halo + land + nbghostcells - 1
+            ind2 = jpjglo
+            DO jj = mj0(ind1), mj1(ind2)
+               DO ji = 1, jpi
+                  ztabramp(ji,jj) = zmsknorth(ji)
+               END DO
+            END DO
+         ENDIF
 
       ENDIF
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_update.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_update.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_oce_update.F90	(revision 13229)
@@ -26,4 +26,5 @@
    USE domvvl         ! Need interpolation routines 
    USE vremap         ! Vertical remapping
+   USE lbclnk 
 
    IMPLICIT NONE
@@ -85,4 +86,8 @@
       Agrif_UseSpecialValueInUpdate = .FALSE.
       Agrif_SpecialValueFineGrid = 0.
+
+      use_sign_north = .TRUE.
+      sign_north = -1.
+
       !     
 # if ! defined DECAL_FEEDBACK
@@ -127,4 +132,6 @@
       END IF
       !
+      use_sign_north = .FALSE.
+      !
    END SUBROUTINE Agrif_Update_Dyn
 
@@ -148,4 +155,6 @@
 #  if defined VOL_REFLUX
       IF ( ln_dynspg_ts.AND.ln_bt_fw ) THEN
+         use_sign_north = .TRUE.
+         sign_north = -1.
          ! Refluxing on ssh:
 #  if defined DECAL_FEEDBACK_2D
@@ -156,4 +165,5 @@
          CALL Agrif_Update_Variable(vb2b_update_id,locupdate1=(/ 0, 0/),locupdate2=(/-1,-1/),procname = reflux_sshv)
 #  endif
+         use_sign_north = .FALSE.
       END IF
 #  endif
@@ -826,5 +836,5 @@
    SUBROUTINE correct_v_bdy( tabres, i1, i2, j1, j2, k1, k2, n1, n2, before, nb, ndir )
       !!---------------------------------------------
-      !!           *** ROUTINE correct_u_bdy ***
+      !!           *** ROUTINE correct_v_bdy ***
       !!---------------------------------------------
       INTEGER                                     , INTENT(in   ) :: i1, i2, j1, j2, k1, k2, n1, n2
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_top_interp.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_top_interp.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_top_interp.F90	(revision 13229)
@@ -119,5 +119,4 @@
             tr(i1:i2,j1:j2,1:jpk,jn,Krhs_a)=ptab_child(i1:i2,j1:j2,1:jpk,jn)*tmask(i1:i2,j1:j2,1:jpk) 
          END DO
-
       ENDIF
       !
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_user.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_user.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/NST/agrif_user.F90	(revision 13229)
@@ -28,6 +28,4 @@
       !
       !                    !* Agrif initialization
-      CALL agrif_nemo_init
-      CALL Agrif_InitValues_cont_dom
       CALL Agrif_InitValues_cont
 # if defined key_top
@@ -40,41 +38,152 @@
    END SUBROUTINE Agrif_initvalues
 
-   SUBROUTINE Agrif_InitValues_cont_dom
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE Agrif_InitValues_cont_dom ***
-      !!----------------------------------------------------------------------
-      !
-      CALL agrif_declare_var_dom
-      !
-   END SUBROUTINE Agrif_InitValues_cont_dom
-
-   SUBROUTINE agrif_declare_var_dom
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE agrif_declare_var_dom ***
-      !!----------------------------------------------------------------------
-      USE par_oce, ONLY:  nbghostcells      
+   SUBROUTINE agrif_istate( Kbb, Kmm, Kaa )
+
+       USE domvvl
+       USE domain
+       USE par_oce
+       USE agrif_oce
+       USE agrif_oce_interp
+       USE oce
+       USE lib_mpp
+       USe lbclnk
+
+      INTEGER, INTENT(in)  :: Kbb, Kmm, Kaa
+      INTEGER :: jn
+
+      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*) 'AGRIF: interp child initial state from parent'
+      IF(lwp) WRITE(numout,*) ' '
+
+      l_ini_child = .TRUE.
+      Agrif_SpecialValue    = 0._wp
+      Agrif_UseSpecialValue = .TRUE.
+      uu(:,:,:,:) = 0.  ;  vv(:,:,:,:) = 0.   ;  ts(:,:,:,:,:) = 0.
+       
+      Krhs_a = Kbb ; Kmm_a = Kbb
+
+      ! Brutal fix to pas 1x1 refinment. 
+  !    IF(Agrif_Irhox() == 1) THEN
+  !       CALL Agrif_Init_Variable(tsini_id, procname=agrif_initts)
+  !    ELSE
+      CALL Agrif_Init_Variable(tsini_id, procname=interptsn)
+
+  !    ENDIF
+! just for VORTEX because Parent velocities can actually be exactly zero
+!      Agrif_UseSpecialValue = .FALSE.
+      Agrif_UseSpecialValue = ln_spc_dyn
+      use_sign_north = .TRUE.
+      sign_north = -1.
+      CALL Agrif_Init_Variable(uini_id , procname=interpun )
+      CALL Agrif_Init_Variable(vini_id , procname=interpvn )
+      use_sign_north = .FALSE.
+
+      Agrif_UseSpecialValue = .FALSE.            !
+      l_ini_child = .FALSE.
+
+      Krhs_a = Kaa ; Kmm_a = Kmm
+
+      DO jn = 1, jpts
+         ts(:,:,:,jn,Kbb) = ts(:,:,:,jn,Kbb)*tmask(:,:,:)
+      END DO
+      uu(:,:,:,Kbb) =  uu(:,:,:,Kbb) * umask(:,:,:)     
+      vv(:,:,:,Kbb) =  vv(:,:,:,Kbb) * vmask(:,:,:) 
+
+
+      CALL lbc_lnk_multi( 'agrif_istate', uu(:,:,:,Kbb), 'U', -1. , vv(:,:,:,Kbb), 'V', -1. )
+      CALL lbc_lnk( 'agrif_istate', ts(:,:,:,:,Kbb), 'T', 1. )
+
+   END SUBROUTINE agrif_istate   
+
+   SUBROUTINE agrif_declare_var_ini
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE agrif_declare_var ***
+      !!----------------------------------------------------------------------
+      USE agrif_util
+      USE agrif_oce
+      USE par_oce
+      USE zdf_oce 
+      USE oce
+      USE dom_oce
       !
       IMPLICIT NONE
       !
       INTEGER :: ind1, ind2, ind3
-      !!----------------------------------------------------------------------
+      External :: nemo_mapping
+      !!----------------------------------------------------------------------
+
+! In case of East-West periodicity, prevent AGRIF interpolation at east and west boundaries
+! The procnames will not be called at these boundaries
+      IF (jperio == 1) THEN
+         CALL Agrif_Set_NearCommonBorderX(.TRUE.)
+         CALL Agrif_Set_DistantCommonBorderX(.TRUE.)
+      ENDIF
+
+      IF ( .NOT. lk_south ) THEN
+         CALL Agrif_Set_NearCommonBorderY(.TRUE.)
+      ENDIF
 
       ! 1. Declaration of the type of variable which have to be interpolated
       !---------------------------------------------------------------------
-      ind1 =          nbghostcells       ! do the interpolation over nbghostcells points
-      ind2 = nn_hls + nbghostcells + 1   ! U/V points: array index of the first point in the reference grid 
-      ind3 = nn_hls + nbghostcells + 2   ! T   points: array index of the first point in the reference grid 
-      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),e1u_id)
-      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),e2v_id)
-
+      ind1 =              nbghostcells
+      ind2 = nn_hls + 2 + nbghostcells_x
+      ind3 = nn_hls + 2 + nbghostcells_y_s
+
+      CALL agrif_declare_variable((/2,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),e3t_id)
+      CALL agrif_declare_variable((/2,2/)  ,(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),mbkt_id)
+      CALL agrif_declare_variable((/2,2/)  ,(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ht0_id)
+
+      CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),e1u_id)
+      CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),e2v_id)
+
+   
+      ! Initial or restart velues
+      
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2  ,ind3  ,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsini_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3  ,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/)     ,uini_id ) 
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2  ,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/)     ,vini_id )
+      CALL agrif_declare_variable((/2,2/)    ,(/ind2,ind3/)        ,(/'x','y'/),(/1,1/),(/jpi,jpj/),sshini_id)
+      ! 
+     
       ! 2. Type of interpolation
       !-------------------------
+      CALL Agrif_Set_bcinterp(e3t_id,interp=AGRIF_constant)
+
+      CALL Agrif_Set_bcinterp(mbkt_id,interp=AGRIF_constant)
+      CALL Agrif_Set_interp  (mbkt_id,interp=AGRIF_constant)
+      CALL Agrif_Set_bcinterp(ht0_id ,interp=AGRIF_constant)
+      CALL Agrif_Set_interp  (ht0_id ,interp=AGRIF_constant)
+
       CALL Agrif_Set_bcinterp( e1u_id, interp1=Agrif_linear, interp2=AGRIF_ppm    )
       CALL Agrif_Set_bcinterp( e2v_id, interp1=AGRIF_ppm   , interp2=Agrif_linear )
 
-      ! 3. Location of interpolation
+      ! Initial fields
+      CALL Agrif_Set_bcinterp(tsini_id ,interp=AGRIF_linear)
+      CALL Agrif_Set_interp  (tsini_id ,interp=AGRIF_linear)
+      CALL Agrif_Set_bcinterp(uini_id  ,interp=AGRIF_linear)
+      CALL Agrif_Set_interp  (uini_id  ,interp=AGRIF_linear)
+      CALL Agrif_Set_bcinterp(vini_id  ,interp=AGRIF_linear)
+      CALL Agrif_Set_interp  (vini_id  ,interp=AGRIF_linear)
+      CALL Agrif_Set_bcinterp(sshini_id,interp=AGRIF_linear)
+      CALL Agrif_Set_interp  (sshini_id,interp=AGRIF_linear)
+
+       ! 3. Location of interpolation
       !-----------------------------
+!      CALL Agrif_Set_bc(  e3t_id, (/-nn_sponge_len*Agrif_irhox(),ind1-1/) )  
+! JC: check near the boundary only until matching in sponge has been sorted out:
+      CALL Agrif_Set_bc(  e3t_id, (/0,ind1-1/) )  
+
+      ! extend the interpolation zone by 1 more point than necessary:
+      ! RB check here
+      CALL Agrif_Set_bc(  mbkt_id, (/-nn_sponge_len*Agrif_irhox()-2,ind1/) )
+      CALL Agrif_Set_bc(  ht0_id,  (/-nn_sponge_len*Agrif_irhox()-2,ind1/) )
+      
       CALL Agrif_Set_bc(e1u_id,(/0,ind1-1/))
-      CALL Agrif_Set_bc(e2v_id,(/0,ind1-1/))
+      CALL Agrif_Set_bc(e2v_id,(/0,ind1-1/))  
+
+      CALL Agrif_Set_bc( tsini_id , (/0,ind1-1/) ) ! if west,  rhox=3 and nbghost=3: columns 2 to 4
+      CALL Agrif_Set_bc( uini_id  , (/0,ind1-1/) ) 
+      CALL Agrif_Set_bc( vini_id  , (/0,ind1-1/) )
+      CALL Agrif_Set_bc( sshini_id, (/0,ind1-1/) )
 
       ! 4. Update type
@@ -87,37 +196,48 @@
       CALL Agrif_Set_Updatetype(e2v_id,update1 = Agrif_Update_Average, update2=Agrif_Update_Copy)
 #endif
-
-   END SUBROUTINE agrif_declare_var_dom
-
-   SUBROUTINE Agrif_InitValues_cont
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE Agrif_InitValues_cont ***
-      !!----------------------------------------------------------------------
-      USE agrif_oce
+      
+   !   CALL Agrif_Set_ExternalMapping(nemo_mapping)
+      !
+   END SUBROUTINE agrif_declare_var_ini
+
+
+   SUBROUTINE Agrif_Init_Domain( Kbb, Kmm, Kaa ) 
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues_cont_dom ***
+      !!----------------------------------------------------------------------
+  
+         !!----------------------------------------------------------------------
+         !!                 *** ROUTINE Agrif_InitValues_cont ***
+         !!
+         !! ** Purpose ::   Declaration of variables to be interpolated
+         !!----------------------------------------------------------------------
+      USE agrif_oce_update
       USE agrif_oce_interp
       USE agrif_oce_sponge
+      USE Agrif_Util
+      USE oce 
       USE dom_oce
-      USE oce
+      USE zdf_oce
+      USE nemogcm
+      USE agrif_oce
+      !
+      USE lbclnk
       USE lib_mpp
-      USE lbclnk
+      USE in_out_manager
       !
       IMPLICIT NONE
       !
-      INTEGER :: ji, jj
+      INTEGER, INTENT(in) ::  Kbb, Kmm, Kaa
+      !
       LOGICAL :: check_namelist
       CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 
-#if defined key_vertical
       REAL(wp), DIMENSION(jpi,jpj) ::   zk   ! workspace
-#endif
-      !!----------------------------------------------------------------------
-
-      ! 1. Declaration of the type of variable which have to be interpolated
-      !---------------------------------------------------------------------
-      CALL agrif_declare_var
-
-      ! 2. First interpolations of potentially non zero fields
-      !-------------------------------------------------------
-
-#if defined key_vertical
+      INTEGER :: ji, jj, jk
+      !!----------------------------------------------------------------------
+    
+     ! CALL Agrif_Declare_Var_ini
+
+      IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed')
+
       ! Build consistent parent bathymetry and number of levels
       ! on the child grid 
@@ -126,6 +246,8 @@
       mbkt_parent(:,:) = 0
       !
-      CALL Agrif_Bc_variable(ht0_id ,calledweight=1.,procname=interpht0 )
-      CALL Agrif_Bc_variable(mbkt_id,calledweight=1.,procname=interpmbkt)
+  !    CALL Agrif_Bc_variable(ht0_id ,calledweight=1.,procname=interpht0 )
+  !    CALL Agrif_Bc_variable(mbkt_id,calledweight=1.,procname=interpmbkt)
+      CALL Agrif_Init_Variable(ht0_id , procname=interpht0 )
+      CALL Agrif_Init_Variable(mbkt_id, procname=interpmbkt)
       !
       ! Assume step wise change of bathymetry near interface
@@ -149,12 +271,98 @@
       ENDIF
       !
-      CALL lbc_lnk( 'Agrif_InitValues_cont', hu0_parent, 'U', 1. )
-      CALL lbc_lnk( 'Agrif_InitValues_cont', hv0_parent, 'V', 1. )
+      CALL lbc_lnk( 'Agrif_Init_Domain', hu0_parent, 'U', 1. )
+      CALL lbc_lnk( 'Agrif_Init_Domain', hv0_parent, 'V', 1. )
       zk(:,:) = REAL( mbku_parent(:,:), wp )   ;   CALL lbc_lnk( 'Agrif_InitValues_cont', zk, 'U', 1. )
-      mbku_parent(:,:) = MAX( NINT( zk(:,:) ), 1 )
+      mbku_parent(:,:) = MAX( NINT( zk(:,:) ), 1 ) ;
       zk(:,:) = REAL( mbkv_parent(:,:), wp )   ;   CALL lbc_lnk( 'Agrif_InitValues_cont', zk, 'V', 1. )
       mbkv_parent(:,:) = MAX( NINT( zk(:,:) ), 1 )   
-#endif
-
+
+      IF ( ln_init_chfrpar ) THEN 
+         CALL Agrif_Init_Variable(sshini_id, procname=agrif_initssh)
+         CALL lbc_lnk( 'Agrif_Init_Domain', ssh(:,:,Kbb), 'T', 1. )
+         DO jk = 1, jpk
+               e3t(:,:,jk,Kbb) =  e3t_0(:,:,jk) * ( ht_0(:,:) + ssh(:,:,Kbb)  ) &
+                        &             / ( ht_0(:,:) + 1._wp - ssmask(:,:) ) * tmask(:,:,jk)   &
+                        &              + e3t_0(:,:,jk) * ( 1._wp - tmask(:,:,jk) )
+         END DO
+      ENDIF
+
+      ! check if masks and bathymetries match
+      IF(ln_chk_bathy) THEN
+         Agrif_UseSpecialValue = .FALSE.
+         !
+         IF(lwp) WRITE(numout,*) ' '
+         IF(lwp) WRITE(numout,*) 'AGRIF: Check Bathymetry and masks near bdys. Level: ', Agrif_Level()
+         !
+         kindic_agr = 0
+         IF( .NOT. l_vremap ) THEN
+            !
+            ! check if tmask and vertical scale factors agree with parent in sponge area:
+            CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
+            !
+         ELSE
+            !
+            ! In case of vertical interpolation, check only that total depths agree between child and parent:
+            DO ji = 1, jpi
+               DO jj = 1, jpj
+                  IF ((mbkt_parent(ji,jj)/=0).AND.(ABS(ht0_parent(ji,jj)-ht_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1
+                  IF ((mbku_parent(ji,jj)/=0).AND.(ABS(hu0_parent(ji,jj)-hu_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1
+                  IF ((mbkv_parent(ji,jj)/=0).AND.(ABS(hv0_parent(ji,jj)-hv_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1
+               END DO
+            END DO
+
+            CALL mpp_sum( 'agrif_user', kindic_agr )
+            IF( kindic_agr /= 0 ) THEN
+               CALL ctl_stop('==> Child Bathymetry is NOT correct near boundaries.')
+            ELSE
+               IF(lwp) WRITE(numout,*) '==> Child Bathymetry is ok near boundaries.'
+               IF(lwp) WRITE(numout,*) ' '
+            ENDIF  
+         ENDIF
+      ENDIF
+
+      IF( l_vremap ) THEN
+      ! Additional constrain that should be removed someday:
+         IF ( Agrif_Parent(jpk).GT.jpk ) THEN
+            CALL ctl_stop( ' With l_vremap, child grids must have jpk greater or equal to the parent value' )
+         ENDIF
+      ENDIF
+      !
+   END SUBROUTINE Agrif_Init_Domain
+
+
+   SUBROUTINE Agrif_InitValues_cont
+         !!----------------------------------------------------------------------
+         !!                 *** ROUTINE Agrif_InitValues_cont ***
+         !!
+         !! ** Purpose ::   Declaration of variables to be interpolated
+         !!----------------------------------------------------------------------
+      USE agrif_oce_update
+      USE agrif_oce_interp
+      USE agrif_oce_sponge
+      USE Agrif_Util
+      USE oce 
+      USE dom_oce
+      USE zdf_oce
+      USE nemogcm
+      USE agrif_oce
+      !
+      USE lbclnk
+      USE lib_mpp
+      USE in_out_manager
+      !
+      IMPLICIT NONE
+      !
+      LOGICAL :: check_namelist
+      CHARACTER(len=15) :: cl_check1, cl_check2, cl_check3, cl_check4 
+      REAL(wp), DIMENSION(jpi,jpj) ::   zk   ! workspace
+      INTEGER :: ji, jj
+
+      ! 1. Declaration of the type of variable which have to be interpolated
+      !---------------------------------------------------------------------
+      CALL agrif_declare_var
+
+      ! 2. First interpolations of potentially non zero fields
+      !-------------------------------------------------------
       Agrif_SpecialValue    = 0._wp
       Agrif_UseSpecialValue = .TRUE.
@@ -163,8 +371,10 @@
       tabspongedone_tsn = .FALSE.
       CALL Agrif_Bc_variable(tsn_sponge_id,calledweight=1.,procname=interptsn_sponge)
-      ! reset ts(:,:,:,:,Krhs_a) to zero
+      ! reset tsa to zero
       ts(:,:,:,:,Krhs_a) = 0._wp
 
       Agrif_UseSpecialValue = ln_spc_dyn
+      use_sign_north = .TRUE.
+      sign_north = -1.
       CALL Agrif_Bc_variable(un_interp_id,calledweight=1.,procname=interpun)
       CALL Agrif_Bc_variable(vn_interp_id,calledweight=1.,procname=interpvn)
@@ -175,4 +385,5 @@
       tabspongedone_v = .FALSE.
       CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge)
+      use_sign_north = .FALSE.
       uu(:,:,:,Krhs_a) = 0._wp
       vv(:,:,:,Krhs_a) = 0._wp
@@ -185,43 +396,20 @@
       IF ( ln_dynspg_ts ) THEN
          Agrif_UseSpecialValue = ln_spc_dyn
+         use_sign_north = .TRUE.
+         sign_north = -1.
          CALL Agrif_Bc_variable(unb_id,calledweight=1.,procname=interpunb)
          CALL Agrif_Bc_variable(vnb_id,calledweight=1.,procname=interpvnb)
          CALL Agrif_Bc_variable(ub2b_interp_id,calledweight=1.,procname=interpub2b)
          CALL Agrif_Bc_variable(vb2b_interp_id,calledweight=1.,procname=interpvb2b)
+         use_sign_north = .FALSE.
          ubdy(:,:) = 0._wp
          vbdy(:,:) = 0._wp
       ENDIF
-
-      Agrif_UseSpecialValue = .FALSE.
-
-      ! 3. Some controls
+      Agrif_UseSpecialValue = .FALSE. 
+
       !-----------------
       check_namelist = .TRUE.
 
       IF( check_namelist ) THEN 
-
-         ! Check time steps           
-         IF( NINT(Agrif_Rhot()) * NINT(rn_Dt) .NE. Agrif_Parent(rn_Dt) ) THEN
-            WRITE(cl_check1,*)  NINT(Agrif_Parent(rn_Dt))
-            WRITE(cl_check2,*)  NINT(rn_Dt)
-            WRITE(cl_check3,*)  NINT(Agrif_Parent(rn_Dt)/Agrif_Rhot())
-            CALL ctl_stop( 'Incompatible time step between ocean grids',   &
-                  &               'parent grid value : '//cl_check1    ,   & 
-                  &               'child  grid value : '//cl_check2    ,   & 
-                  &               'value on child grid should be changed to : '//cl_check3 )
-         ENDIF
-
-         ! Check run length
-         IF( Agrif_IRhot() * (Agrif_Parent(nitend)- &
-               Agrif_Parent(nit000)+1) .NE. (nitend-nit000+1) ) THEN
-            WRITE(cl_check1,*)  (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
-            WRITE(cl_check2,*)   Agrif_Parent(nitend)   *Agrif_IRhot()
-            CALL ctl_warn( 'Incompatible run length between grids'                      ,   &
-                  &               'nit000 on fine grid will be changed to : '//cl_check1,   &
-                  &               'nitend on fine grid will be changed to : '//cl_check2    )
-            nit000 = (Agrif_Parent(nit000)-1)*Agrif_IRhot() + 1
-            nitend =  Agrif_Parent(nitend)   *Agrif_IRhot()
-         ENDIF
-
          ! Check free surface scheme
          IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.&
@@ -251,71 +439,6 @@
             STOP
          ENDIF
-
-      ENDIF
-
-      ! check if masks and bathymetries match
-      IF(ln_chk_bathy) THEN
-         Agrif_UseSpecialValue = .FALSE.
-         !
-         IF(lwp) WRITE(numout,*) ' '
-         IF(lwp) WRITE(numout,*) 'AGRIF: Check Bathymetry and masks near bdys. Level: ', Agrif_Level()
-         !
-         kindic_agr = 0
-# if ! defined key_vertical
-         !
-         ! check if tmask and vertical scale factors agree with parent in sponge area:
-         CALL Agrif_Bc_variable(e3t_id,calledweight=1.,procname=interpe3t)
-         !
-# else
-         !
-         ! In case of vertical interpolation, check only that total depths agree between child and parent:
-         DO_2D_00_00
-            IF ((mbkt_parent(ji,jj)/=0).AND.(ABS(ht0_parent(ji,jj)-ht_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1
-            IF ((mbku_parent(ji,jj)/=0).AND.(ABS(hu0_parent(ji,jj)-hu_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1
-            IF ((mbkv_parent(ji,jj)/=0).AND.(ABS(hv0_parent(ji,jj)-hv_0(ji,jj))>1.e-3)) kindic_agr = kindic_agr + 1
-         END_2D
-# endif
-         CALL mpp_sum( 'agrif_user', kindic_agr )
-         IF( kindic_agr /= 0 ) THEN
-            CALL ctl_stop('==> Child Bathymetry is NOT correct near boundaries.')
-         ELSE
-            IF(lwp) WRITE(numout,*) '==> Child Bathymetry is ok near boundaries.'
-            IF(lwp) WRITE(numout,*) ' '
-         END IF  
-         !    
-!!$         IF(lwp) WRITE(numout,*) ' '
-!!$         IF(lwp) WRITE(numout,*) 'AGRIF: Check longitude and latitude near bdys. Level: ', Agrif_Level()
-!!$         !
-!!$         ! check glamt in sponge area:
-!!$         kindic_agr = 0
-!!$         CALL Agrif_Bc_variable(glamt_id,calledweight=1.,procname=interpglamt)
-!!$         CALL mpp_sum( 'agrif_user', kindic_agr )
-!!$         IF( kindic_agr /= 0 ) THEN
-!!$            CALL ctl_stop('==> Child glamt is NOT correct near boundaries.')1
-!!$         ELSE
-!!$            IF(lwp) WRITE(numout,*) '==> Child glamt is ok near boundaries.'
-!!$            IF(lwp) WRITE(numout,*) ' '
-!!$         END IF  
-!!$         !
-!!$         ! check gphit in sponge area:
-!!$         kindic_agr = 0
-!!$         CALL Agrif_Bc_variable(gphit_id,calledweight=1.,procname=interpgphit)
-!!$         CALL mpp_sum( 'agrif_user', kindic_agr )
-!!$         IF( kindic_agr /= 0 ) THEN
-!!$            CALL ctl_stop('==> Child gphit is NOT correct near boundaries.')
-!!$         ELSE
-!!$            IF(lwp) WRITE(numout,*) '==> Child gphit is ok near boundaries.'
-!!$            IF(lwp) WRITE(numout,*) ' '
-!!$         END IF  
-         !
-      ENDIF
-
-# if defined key_vertical
-      ! Additional constrain that should be removed someday:
-      IF ( Agrif_Parent(jpk).GT.jpk ) THEN
-	 CALL ctl_stop( ' With key_vertical, child grids must have jpk greater or equal to the parent value' )
-      ENDIF
-# endif
-      ! 
+      ENDIF
+
    END SUBROUTINE Agrif_InitValues_cont
 
@@ -337,67 +460,57 @@
       ! 1. Declaration of the type of variable which have to be interpolated
       !---------------------------------------------------------------------
-      ind1 =          nbghostcells       ! do the interpolation over nbghostcells points
-      ind2 = nn_hls + nbghostcells + 1   ! U/V points: array index of the first point in the reference grid 
-      ind3 = nn_hls + nbghostcells + 2   ! T   points: array index of the first point in the reference grid 
+      ind1 =              nbghostcells
+      ind2 = nn_hls + 2 + nbghostcells_x
+      ind3 = nn_hls + 2 + nbghostcells_y_s
 # if defined key_vertical
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsn_id)
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsn_sponge_id)
-
-      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_interp_id)
-      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_interp_id)
-      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_update_id)
-      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_update_id)
-      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_sponge_id)
-      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts+1/),tsn_sponge_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_interp_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_interp_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_update_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_update_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),un_sponge_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),vn_sponge_id)
 # else
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts/),tsn_id)
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts/),tsn_sponge_id)
-
-      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_interp_id)
-      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_interp_id)
-      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_update_id)
-      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_update_id)
-      CALL agrif_declare_variable((/1,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_sponge_id)
-      CALL agrif_declare_variable((/2,1,0,0/),(/ind3,ind2,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts/),tsn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jpts/),tsn_sponge_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_interp_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_interp_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_update_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_update_id)
+      CALL agrif_declare_variable((/1,2,0,0/),(/ind2-1,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),un_sponge_id)
+      CALL agrif_declare_variable((/2,1,0,0/),(/ind2,ind3-1,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),vn_sponge_id)
 # endif
-
-      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),e3t_id)
-      CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),glamt_id)
-      CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),gphit_id)
-
-# if defined key_vertical
-      CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),mbkt_id)
-      CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ht0_id)
-# endif
-
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,3/),scales_t_id)
-
-      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),unb_id)
-      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vnb_id)
-      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ub2b_interp_id)
-      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vb2b_interp_id)
-      CALL agrif_declare_variable((/1,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ub2b_update_id)
-      CALL agrif_declare_variable((/2,1/),(/ind3,ind2/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vb2b_update_id)
-
-      CALL agrif_declare_variable((/2,2/),(/ind3,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),sshn_id)
-
-      IF( ln_zdftke.OR.ln_zdfgls ) THEN
+      CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),unb_id)
+      CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vnb_id)
+      CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ub2b_interp_id)
+      CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vb2b_interp_id)
+      CALL agrif_declare_variable((/1,2/),(/ind2-1,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),ub2b_update_id)
+      CALL agrif_declare_variable((/2,1/),(/ind2,ind3-1/),(/'x','y'/),(/1,1/),(/jpi,jpj/),vb2b_update_id)
+
+!      CALL agrif_declare_variable((/2,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),glamt_id)
+!      CALL agrif_declare_variable((/2,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),gphit_id)
+      CALL agrif_declare_variable((/2,2/),(/ind2,ind3/),(/'x','y'/),(/1,1/),(/jpi,jpj/),sshn_id)
+
+
+      IF( ln_zdftke.OR.ln_zdfgls ) THEN  ! logical not known at this point
 !         CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/), en_id)
 !         CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpk/),avt_id)
 # if defined key_vertical
-         CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),avm_id)
+         CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,2/),avm_id)
 # else
-         CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),avm_id)
+         CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,1/),avm_id)
 # endif
       ENDIF
-
+     
       ! 2. Type of interpolation
       !-------------------------
       CALL Agrif_Set_bcinterp(tsn_id,interp=AGRIF_linear)
-
       CALL Agrif_Set_bcinterp(un_interp_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
       CALL Agrif_Set_bcinterp(vn_interp_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
 
       CALL Agrif_Set_bcinterp(tsn_sponge_id,interp=AGRIF_linear)
+      CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
+      CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
 
       CALL Agrif_Set_bcinterp(sshn_id,interp=AGRIF_linear)
@@ -415,17 +528,9 @@
 !<
 
-      CALL Agrif_Set_bcinterp(un_sponge_id,interp1=Agrif_linear,interp2=AGRIF_ppm)
-      CALL Agrif_Set_bcinterp(vn_sponge_id,interp1=AGRIF_ppm,interp2=Agrif_linear)
-
-      CALL Agrif_Set_bcinterp(  e3t_id,interp=AGRIF_constant)
-      CALL Agrif_Set_bcinterp(gphit_id,interp=AGRIF_constant)
-      CALL Agrif_Set_bcinterp(glamt_id,interp=AGRIF_constant)
-
-# if defined key_vertical
-      CALL Agrif_Set_bcinterp(mbkt_id,interp=AGRIF_constant)
-      CALL Agrif_Set_bcinterp(ht0_id ,interp=AGRIF_constant)
-# endif
-
-      IF( ln_zdftke.OR.ln_zdfgls )   CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear )
+      IF( ln_zdftke.OR.ln_zdfgls )  CALL Agrif_Set_bcinterp( avm_id, interp=AGRIF_linear )
+    
+
+!      CALL Agrif_Set_bcinterp(gphit_id,interp=AGRIF_constant)
+!      CALL Agrif_Set_bcinterp(glamt_id,interp=AGRIF_constant)
 
       ! 3. Location of interpolation
@@ -445,21 +550,10 @@
       CALL Agrif_Set_bc( vb2b_interp_id, (/0,ind1-1/) )
 
-!      CALL Agrif_Set_bc(  e3t_id, (/-nn_sponge_len*Agrif_irhox(),ind1-1/) )  
-! JC: check near the boundary only until matching in sponge has been sorted out:
-      CALL Agrif_Set_bc(  e3t_id, (/0,ind1-1/) )  
+      IF( ln_zdftke.OR.ln_zdfgls ) CALL Agrif_Set_bc( avm_id, (/0,ind1/) )
       CALL Agrif_Set_bc(glamt_id, (/0,ind1-1/) )  
       CALL Agrif_Set_bc(gphit_id, (/0,ind1-1/) )  
 
-# if defined key_vertical 
-      ! extend the interpolation zone by 1 more point than necessary:
-      CALL Agrif_Set_bc(  mbkt_id, (/-nn_sponge_len*Agrif_irhox()-2,ind1/) )
-      CALL Agrif_Set_bc(  ht0_id,  (/-nn_sponge_len*Agrif_irhox()-2,ind1/) )
-# endif
-
-      IF( ln_zdftke.OR.ln_zdfgls )   CALL Agrif_Set_bc( avm_id, (/0,ind1/) )
-
       ! 4. Update type
       !--------------- 
-      CALL Agrif_Set_Updatetype(scales_t_id, update = AGRIF_Update_Average)
 
 # if defined UPD_HIGH
@@ -473,9 +567,9 @@
       CALL Agrif_Set_Updatetype(e3t_id, update = Agrif_Update_Full_Weighting)
 
-      IF( ln_zdftke.OR.ln_zdfgls ) THEN
+  !    IF( ln_zdftke.OR.ln_zdfgls ) THEN
 !         CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Full_Weighting)
 !         CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Full_Weighting)
 !         CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Full_Weighting)
-      ENDIF
+   !   ENDIF
 
 #else
@@ -489,9 +583,9 @@
       CALL Agrif_Set_Updatetype(e3t_id, update = AGRIF_Update_Average)
 
-      IF( ln_zdftke.OR.ln_zdfgls ) THEN
+ !     IF( ln_zdftke.OR.ln_zdfgls ) THEN
 !         CALL Agrif_Set_Updatetype( en_id, update = AGRIF_Update_Average)
 !         CALL Agrif_Set_Updatetype(avt_id, update = AGRIF_Update_Average)
 !         CALL Agrif_Set_Updatetype(avm_id, update = AGRIF_Update_Average)
-      ENDIF
+ !     ENDIF
 
 #endif
@@ -501,7 +595,4 @@
 #if defined key_si3
 SUBROUTINE Agrif_InitValues_cont_ice
-      !!----------------------------------------------------------------------
-      !!                 *** ROUTINE Agrif_InitValues_cont_ice ***
-      !!----------------------------------------------------------------------
       USE Agrif_Util
       USE sbc_oce, ONLY : nn_fsbc  ! clem: necessary otherwise Agrif_Parent(nn_fsbc) = nn_fsbc
@@ -511,11 +602,7 @@
       USE agrif_ice_interp
       USE lib_mpp
-      !
-      IMPLICIT NONE
-      !!----------------------------------------------------------------------
-      !
-      ! Declaration of the type of variable which have to be interpolated (parent=>child)
-      !----------------------------------------------------------------------------------
-      CALL agrif_declare_var_ice
+      !!----------------------------------------------------------------------
+      !!                 *** ROUTINE Agrif_InitValues_cont_ice ***
+      !!----------------------------------------------------------------------
 
       ! Controls
@@ -524,5 +611,5 @@
       !          the run must satisfy CFL=Uice/(dx/dt) < 0.6/nn_fsbc(child)
       !          therefore, if nn_fsbc(child)>1 one must reduce the time-step in proportion to nn_fsbc(child), which is not acceptable
-      !       If a solution is found, the following stop could be removed because the rest of the code take nn_fsbc(child) into account
+      !       If a solution is found, the following stop could be removed because the rest of the code take nn_fsbc(child) into account     
       IF( nn_fsbc > 1 )  CALL ctl_stop('nn_fsbc(child) must be set to 1 otherwise agrif and sea-ice may not work properly')
 
@@ -545,12 +632,13 @@
       !!                 *** ROUTINE agrif_declare_var_ice ***
       !!----------------------------------------------------------------------
+
       USE Agrif_Util
       USE ice
-      USE par_oce, ONLY : nbghostcells
+      USE par_oce, ONLY : nbghostcells, nbghostcells_x, nbghostcells_y_s
       !
       IMPLICIT NONE
       !
       INTEGER :: ind1, ind2, ind3
-      !!----------------------------------------------------------------------
+         !!----------------------------------------------------------------------
       !
       ! 1. Declaration of the type of variable which have to be interpolated (parent=>child)
@@ -561,10 +649,14 @@
       !                            2,2 = two ghost lines
       !-------------------------------------------------------------------------------------
-      ind1 =          nbghostcells       ! do the interpolation over nbghostcells points
-      ind2 = nn_hls + nbghostcells + 1   ! U/V points: array index of the first point in the reference grid 
-      ind3 = nn_hls + nbghostcells + 2   ! T   points: array index of the first point in the reference grid 
-      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpl*(8+nlay_s+nlay_i)/),tra_ice_id)
-      CALL agrif_declare_variable((/1,2/)  ,(/ind2,ind3/)  ,(/'x','y'/)    ,(/1,1/)  ,(/jpi,jpj/)                      ,u_ice_id  )
-      CALL agrif_declare_variable((/2,1/)  ,(/ind3,ind2/)  ,(/'x','y'/)    ,(/1,1/)  ,(/jpi,jpj/)                      ,v_ice_id  )
+      ind1 =              nbghostcells
+      ind2 = nn_hls + 2 + nbghostcells_x
+      ind3 = nn_hls + 2 + nbghostcells_y_s
+      CALL agrif_declare_variable((/2,2,0/),(/ind2,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpl*(8+nlay_s+nlay_i)/),tra_ice_id)
+      CALL agrif_declare_variable((/1,2/)  ,(/ind2-1,ind3/)  ,(/'x','y'/)    ,(/1,1/)  ,(/jpi,jpj/)                      ,u_ice_id  )
+      CALL agrif_declare_variable((/2,1/)  ,(/ind2,ind3-1/)  ,(/'x','y'/)    ,(/1,1/)  ,(/jpi,jpj/)                      ,v_ice_id  )
+
+      CALL agrif_declare_variable((/2,2,0/),(/ind3,ind3,0/),(/'x','y','N'/),(/1,1,1/),(/jpi,jpj,jpl*(8+nlay_s+nlay_i)/),tra_iceini_id)
+      CALL agrif_declare_variable((/1,2/)  ,(/ind2-1,ind3/)  ,(/'x','y'/)    ,(/1,1/)  ,(/jpi,jpj/)                      ,u_iceini_id  )
+      CALL agrif_declare_variable((/2,1/)  ,(/ind2,ind3-1/)  ,(/'x','y'/)    ,(/1,1/)  ,(/jpi,jpj/)                      ,v_iceini_id  )
 
       ! 2. Set interpolations (normal & tangent to the grid cell for velocities)
@@ -574,4 +666,11 @@
       CALL Agrif_Set_bcinterp(v_ice_id  , interp1 = AGRIF_ppm   ,interp2 = Agrif_linear)
 
+      CALL Agrif_Set_bcinterp(tra_iceini_id, interp  = AGRIF_linear)
+      CALL Agrif_Set_interp  (tra_iceini_id, interp  = AGRIF_linear)
+      CALL Agrif_Set_bcinterp(u_iceini_id  , interp  = AGRIF_linear  )
+      CALL Agrif_Set_interp  (u_iceini_id  , interp  = AGRIF_linear   )
+      CALL Agrif_Set_bcinterp(v_iceini_id  , interp  = AGRIF_linear)
+      CALL Agrif_Set_interp  (v_iceini_id  , interp  = AGRIF_linear)
+
       ! 3. Set location of interpolations
       !----------------------------------
@@ -579,4 +678,8 @@
       CALL Agrif_Set_bc(u_ice_id  ,(/0,ind1/))
       CALL Agrif_Set_bc(v_ice_id  ,(/0,ind1/))
+
+      CALL Agrif_Set_bc(tra_iceini_id,(/0,ind1/))
+      CALL Agrif_Set_bc(u_iceini_id  ,(/0,ind1/))
+      CALL Agrif_Set_bc(v_iceini_id  ,(/0,ind1/))
 
       ! 4. Set update type in case 2 ways (child=>parent) (normal & tangent to the grid cell for velocities)
@@ -586,9 +689,9 @@
       CALL Agrif_Set_Updatetype(u_ice_id  , update1 = Agrif_Update_Average       , update2 = Agrif_Update_Full_Weighting)
       CALL Agrif_Set_Updatetype(v_ice_id  , update1 = Agrif_Update_Full_Weighting, update2 = Agrif_Update_Average       )
-#else
+# else
       CALL Agrif_Set_Updatetype(tra_ice_id, update  = AGRIF_Update_Average)
       CALL Agrif_Set_Updatetype(u_ice_id  , update1 = Agrif_Update_Copy   , update2 = Agrif_Update_Average)
       CALL Agrif_Set_Updatetype(v_ice_id  , update1 = Agrif_Update_Average, update2 = Agrif_Update_Copy   )
-#endif
+# endif
 
    END SUBROUTINE agrif_declare_var_ice
@@ -614,36 +717,39 @@
       USE agrif_top_sponge
       !!
-      IMPLICIT NONE
-      !
-      CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3
-      LOGICAL :: check_namelist
-      !!----------------------------------------------------------------------
-
-      ! 1. Declaration of the type of variable which have to be interpolated
-      !---------------------------------------------------------------------
-      CALL agrif_declare_var_top
-
-      ! 2. First interpolations of potentially non zero fields
-      !-------------------------------------------------------
-      Agrif_SpecialValue=0._wp
-      Agrif_UseSpecialValue = .TRUE.
-      CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn)
-      Agrif_UseSpecialValue = .FALSE.
-      CALL Agrif_Sponge
-      tabspongedone_trn = .FALSE.
-      CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge)
-      ! reset ts(:,:,:,:,Krhs_a) to zero
-      tr(:,:,:,:,Krhs_a) = 0._wp
-
-      ! 3. Some controls
-      !-----------------
-      check_namelist = .TRUE.
-
-      IF( check_namelist ) THEN
-         ! Check time steps
-      IF( NINT(Agrif_Rhot()) * NINT(rn_Dt) .NE. Agrif_Parent(rn_Dt) ) THEN
-         WRITE(cl_check1,*)  Agrif_Parent(rn_Dt)
-         WRITE(cl_check2,*)  rn_Dt
-         WRITE(cl_check3,*)  rn_Dt*Agrif_Rhot()
+  
+   !!
+   IMPLICIT NONE
+   !
+   CHARACTER(len=10) :: cl_check1, cl_check2, cl_check3
+   LOGICAL :: check_namelist
+      !!----------------------------------------------------------------------
+
+
+   ! 1. Declaration of the type of variable which have to be interpolated
+   !---------------------------------------------------------------------
+   CALL agrif_declare_var_top
+
+   ! 2. First interpolations of potentially non zero fields
+   !-------------------------------------------------------
+   Agrif_SpecialValue=0.
+   Agrif_UseSpecialValue = .TRUE.
+   CALL Agrif_Bc_variable(trn_id,calledweight=1.,procname=interptrn)
+   Agrif_UseSpecialValue = .FALSE.
+   CALL Agrif_Sponge
+   tabspongedone_trn = .FALSE.
+   CALL Agrif_Bc_variable(trn_sponge_id,calledweight=1.,procname=interptrn_sponge)
+   ! reset tsa to zero
+   tra(:,:,:,:) = 0.
+
+   ! 3. Some controls
+   !-----------------
+   check_namelist = .TRUE.
+
+   IF( check_namelist ) THEN
+      ! Check time steps
+      IF( NINT(Agrif_Rhot()) * NINT(rdt) .NE. Agrif_Parent(rdt) ) THEN
+         WRITE(cl_check1,*)  Agrif_Parent(rdt)
+         WRITE(cl_check2,*)  rdt
+         WRITE(cl_check3,*)  rdt*Agrif_Rhot()
          CALL ctl_stop( 'incompatible time step between grids',   &
                &               'parent grid value : '//cl_check1    ,   & 
@@ -664,5 +770,4 @@
          nitend =  Agrif_Parent(nitend)   *Agrif_IRhot()
       ENDIF
-
    ENDIF
    !
@@ -684,15 +789,19 @@
       !!----------------------------------------------------------------------
 
+
+
+!RB_CMEMS : declare here init for top      
       ! 1. Declaration of the type of variable which have to be interpolated
       !---------------------------------------------------------------------
-      ind1 =          nbghostcells       ! do the interpolation over nbghostcells points
-      ind2 = nn_hls + nbghostcells + 1   ! U/V points: array index of the first point in the reference grid 
-      ind3 = nn_hls + nbghostcells + 2   ! T   points: array index of the first point in the reference grid 
+      ind1 =              nbghostcells
+      ind2 = nn_hls + 2 + nbghostcells_x
+      ind3 = nn_hls + 2 + nbghostcells_y_s
 # if defined key_vertical
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra+1/),trn_id)
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra+1/),trn_sponge_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra+1/),trn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/ind2,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra+1/),trn_sponge_id)
 # else
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_id)
-      CALL agrif_declare_variable((/2,2,0,0/),(/ind3,ind3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_sponge_id)
+! LAURENT: STRANGE why (3,3) here ?
+      CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_id)
+      CALL agrif_declare_variable((/2,2,0,0/),(/3,3,0,0/),(/'x','y','N','N'/),(/1,1,1,1/),(/jpi,jpj,jpk,jptra/),trn_sponge_id)
 # endif
 
@@ -734,13 +843,14 @@
       !!                     *** ROUTINE agrif_init ***
       !!----------------------------------------------------------------------
-      USE agrif_oce 
-      USE agrif_ice
-      USE in_out_manager
-      USE lib_mpp
+   USE agrif_oce 
+   USE agrif_ice
+   USE dom_oce
+   USE in_out_manager
+   USE lib_mpp
       !!
       IMPLICIT NONE
       !
       INTEGER  ::   ios                 ! Local integer output status for namelist read
-      NAMELIST/namagrif/ ln_agrif_2way, rn_sponge_tra, rn_sponge_dyn, rn_trelax_tra, rn_trelax_dyn, &
+      NAMELIST/namagrif/ ln_agrif_2way, ln_init_chfrpar, rn_sponge_tra, rn_sponge_dyn, rn_trelax_tra, rn_trelax_dyn, &
                        & ln_spc_dyn, ln_chk_bathy
       !!--------------------------------------------------------------------------------------
@@ -758,19 +868,37 @@
          WRITE(numout,*) '   Namelist namagrif : set AGRIF parameters'
          WRITE(numout,*) '      Two way nesting activated ln_agrif_2way         = ', ln_agrif_2way
-         WRITE(numout,*) '      sponge coefficient for tracers    rn_sponge_tra = ', rn_sponge_tra, ' m^2/s'
-         WRITE(numout,*) '      sponge coefficient for dynamics   rn_sponge_tra = ', rn_sponge_dyn, ' m^2/s'
-         WRITE(numout,*) '      time relaxation for tracers       rn_trelax_tra = ', rn_trelax_tra, ' ad.'
-         WRITE(numout,*) '      time relaxation for dynamics      rn_trelax_dyn = ', rn_trelax_dyn, ' ad.'
+         WRITE(numout,*) '      child initial state from parent ln_init_chfrpar = ', ln_init_chfrpar
+         WRITE(numout,*) '      ad. sponge coeft for tracers      rn_sponge_tra = ', rn_sponge_tra
+         WRITE(numout,*) '      ad. sponge coeft for dynamics     rn_sponge_tra = ', rn_sponge_dyn
+         WRITE(numout,*) '      ad. time relaxation for tracers   rn_trelax_tra = ', rn_trelax_tra
+         WRITE(numout,*) '      ad. time relaxation for dynamics  rn_trelax_dyn = ', rn_trelax_dyn
          WRITE(numout,*) '      use special values for dynamics   ln_spc_dyn    = ', ln_spc_dyn
          WRITE(numout,*) '      check bathymetry                  ln_chk_bathy  = ', ln_chk_bathy
       ENDIF
-      !
-      !
-      IF( agrif_oce_alloc()  > 0 )   CALL ctl_warn('agrif agrif_oce_alloc: allocation of arrays failed')
+
+      lk_west  = .NOT. ( Agrif_Ix() == 1 )
+      lk_east  = .NOT. ( Agrif_Ix() + nbcellsx/AGRIF_Irhox() == Agrif_Parent(jpiglo) -1 )
+      lk_south = .NOT. ( Agrif_Iy() == 1 )
+      lk_north = .NOT. ( Agrif_Iy() + nbcellsy/AGRIF_Irhoy() == Agrif_Parent(jpjglo) -1 )
+
+      !
+      ! Set the number of ghost cells according to periodicity
+      nbghostcells_x = nbghostcells
+      nbghostcells_y_s = nbghostcells
+      nbghostcells_y_n = nbghostcells
+      !
+      IF ( jperio == 1 ) nbghostcells_x = 0
+      IF ( .NOT. lk_south ) nbghostcells_y_s = 0
+
+      ! Some checks
+      IF( jpiglo /= nbcellsx + 2 + 2*nbghostcells_x )   &
+          CALL ctl_stop( 'STOP', 'agrif_nemo_init: Agrif children requires jpiglo == nbcellsx + 2 + 2*nbghostcells_x' )
+      IF( jpjglo /= nbcellsy + 2 + nbghostcells_y_s + nbghostcells_y_n )   &
+          CALL ctl_stop( 'STOP', 'agrif_nemo_init: Agrif children requires jpjglo == nbcellsy + 2 + nbghostcells_y_s + nbghostcells_y_n' )
+      IF( ln_use_jattr )   CALL ctl_stop( 'STOP', 'agrif_nemo_init:Agrif children requires ln_use_jattr = .false. ' )
       !
    END SUBROUTINE agrif_nemo_init
 
 # if defined key_mpp_mpi
-
    SUBROUTINE Agrif_InvLoc( indloc, nprocloc, i, indglob )
       !!----------------------------------------------------------------------
@@ -831,4 +959,231 @@
 # endif
 
+   SUBROUTINE nemo_mapping(ndim,ptx,pty,bounds,bounds_chunks,correction_required,nb_chunks)
+      !!----------------------------------------------------------------------
+      !!                   *** ROUTINE Nemo_mapping ***
+      !!----------------------------------------------------------------------
+      USE dom_oce
+      !!
+      IMPLICIT NONE
+      !
+      INTEGER :: ndim
+      INTEGER :: ptx, pty
+      INTEGER, DIMENSION(ndim,2,2) :: bounds
+      INTEGER, DIMENSION(:,:,:,:), ALLOCATABLE :: bounds_chunks
+      LOGICAL, DIMENSION(:), ALLOCATABLE :: correction_required
+      INTEGER :: nb_chunks
+      !
+      INTEGER :: i
+
+      IF (agrif_debug_interp) THEN
+         DO i=1,ndim
+            WRITE(*,*) 'direction = ',i,bounds(i,1,2),bounds(i,2,2)
+         ENDDO
+      ENDIF
+
+      IF( bounds(2,2,2) > jpjglo) THEN
+         IF( bounds(2,1,2) <=jpjglo) THEN
+            nb_chunks = 2
+            ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2))
+            ALLOCATE(correction_required(nb_chunks))
+            DO i = 1,nb_chunks
+               bounds_chunks(i,:,:,:) = bounds
+            END DO
+        
+      ! FIRST CHUNCK (for j<=jpjglo)   
+
+      ! Original indices
+            bounds_chunks(1,1,1,1) = bounds(1,1,2)
+            bounds_chunks(1,1,2,1) = bounds(1,2,2)
+            bounds_chunks(1,2,1,1) = bounds(2,1,2)
+            bounds_chunks(1,2,2,1) = jpjglo
+
+            bounds_chunks(1,1,1,2) = bounds(1,1,2)
+            bounds_chunks(1,1,2,2) = bounds(1,2,2)
+            bounds_chunks(1,2,1,2) = bounds(2,1,2)
+            bounds_chunks(1,2,2,2) = jpjglo
+
+      ! Correction required or not
+            correction_required(1)=.FALSE.
+       
+      ! SECOND CHUNCK (for j>jpjglo)
+
+      ! Original indices
+            bounds_chunks(2,1,1,1) = bounds(1,1,2)
+            bounds_chunks(2,1,2,1) = bounds(1,2,2)
+            bounds_chunks(2,2,1,1) = jpjglo-2
+            bounds_chunks(2,2,2,1) = bounds(2,2,2)
+
+      ! Where to find them
+      ! We use the relation TAB(ji,jj)=TAB(jpiglo-ji+2,jpjglo-2-(jj-jpjglo))
+
+            IF( ptx == 2) THEN ! T, V points
+               bounds_chunks(2,1,1,2) = jpiglo-bounds(1,2,2)+2
+               bounds_chunks(2,1,2,2) = jpiglo-bounds(1,1,2)+2
+            ELSE ! U, F points
+               bounds_chunks(2,1,1,2) = jpiglo-bounds(1,2,2)+1
+               bounds_chunks(2,1,2,2) = jpiglo-bounds(1,1,2)+1       
+            ENDIF
+
+            IF( pty == 2) THEN ! T, U points
+               bounds_chunks(2,2,1,2) = jpjglo-2-(bounds(2,2,2) -jpjglo)
+               bounds_chunks(2,2,2,2) = jpjglo-2-(jpjglo-2      -jpjglo)
+            ELSE ! V, F points
+               bounds_chunks(2,2,1,2) = jpjglo-3-(bounds(2,2,2) -jpjglo)
+               bounds_chunks(2,2,2,2) = jpjglo-3-(jpjglo-2      -jpjglo)
+            ENDIF
+      ! Correction required or not
+            correction_required(2)=.TRUE.
+
+         ELSE
+            nb_chunks = 1
+            ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2))
+            ALLOCATE(correction_required(nb_chunks))
+            DO i=1,nb_chunks
+               bounds_chunks(i,:,:,:) = bounds
+            END DO
+
+            bounds_chunks(1,1,1,1) = bounds(1,1,2)
+            bounds_chunks(1,1,2,1) = bounds(1,2,2)
+            bounds_chunks(1,2,1,1) = bounds(2,1,2)
+            bounds_chunks(1,2,2,1) = bounds(2,2,2)
+
+            bounds_chunks(1,1,1,2) = jpiglo-bounds(1,2,2)+2
+            bounds_chunks(1,1,2,2) = jpiglo-bounds(1,1,2)+2
+
+            bounds_chunks(1,2,1,2) = jpjglo-2-(bounds(2,2,2)-jpjglo)
+            bounds_chunks(1,2,2,2) = jpjglo-2-(bounds(2,1,2)-jpjglo)
+
+            IF( ptx == 2) THEN ! T, V points
+               bounds_chunks(1,1,1,2) = jpiglo-bounds(1,2,2)+2
+               bounds_chunks(1,1,2,2) = jpiglo-bounds(1,1,2)+2
+            ELSE ! U, F points
+               bounds_chunks(1,1,1,2) = jpiglo-bounds(1,2,2)+1
+               bounds_chunks(1,1,2,2) = jpiglo-bounds(1,1,2)+1    	
+            ENDIF
+
+            IF (pty == 2) THEN ! T, U points
+               bounds_chunks(1,2,1,2) = jpjglo-2-(bounds(2,2,2) -jpjglo)
+               bounds_chunks(1,2,2,2) = jpjglo-2-(bounds(2,1,2) -jpjglo)
+            ELSE ! V, F points
+               bounds_chunks(1,2,1,2) = jpjglo-3-(bounds(2,2,2) -jpjglo)
+               bounds_chunks(1,2,2,2) = jpjglo-3-(bounds(2,1,2) -jpjglo)
+            ENDIF
+
+            correction_required(1)=.TRUE.          
+         ENDIF
+
+      ELSE IF (bounds(1,1,2) < 1) THEN
+         IF (bounds(1,2,2) > 0) THEN
+            nb_chunks = 2
+            ALLOCATE(correction_required(nb_chunks))
+            correction_required=.FALSE.
+            ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2))
+            DO i=1,nb_chunks
+               bounds_chunks(i,:,:,:) = bounds
+            END DO
+              
+            bounds_chunks(1,1,1,2) = bounds(1,1,2)+jpiglo-2
+            bounds_chunks(1,1,2,2) = 1+jpiglo-2
+          
+            bounds_chunks(1,1,1,1) = bounds(1,1,2)
+            bounds_chunks(1,1,2,1) = 1
+       
+            bounds_chunks(2,1,1,2) = 2
+            bounds_chunks(2,1,2,2) = bounds(1,2,2)
+          
+            bounds_chunks(2,1,1,1) = 2
+            bounds_chunks(2,1,2,1) = bounds(1,2,2)
+
+         ELSE
+            nb_chunks = 1
+            ALLOCATE(correction_required(nb_chunks))
+            correction_required=.FALSE.
+            ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2))
+            DO i=1,nb_chunks
+               bounds_chunks(i,:,:,:) = bounds
+            END DO    
+            bounds_chunks(1,1,1,2) = bounds(1,1,2)+jpiglo-2
+            bounds_chunks(1,1,2,2) = bounds(1,2,2)+jpiglo-2
+          
+            bounds_chunks(1,1,1,1) = bounds(1,1,2)
+           bounds_chunks(1,1,2,1) = bounds(1,2,2)
+         ENDIF
+      ELSE
+         nb_chunks=1  
+         ALLOCATE(correction_required(nb_chunks))
+         correction_required=.FALSE.
+         ALLOCATE(bounds_chunks(nb_chunks,ndim,2,2))
+         DO i=1,nb_chunks
+            bounds_chunks(i,:,:,:) = bounds
+         END DO
+         bounds_chunks(1,1,1,2) = bounds(1,1,2)
+         bounds_chunks(1,1,2,2) = bounds(1,2,2)
+         bounds_chunks(1,2,1,2) = bounds(2,1,2)
+         bounds_chunks(1,2,2,2) = bounds(2,2,2)
+          
+         bounds_chunks(1,1,1,1) = bounds(1,1,2)
+         bounds_chunks(1,1,2,1) = bounds(1,2,2)
+         bounds_chunks(1,2,1,1) = bounds(2,1,2)
+         bounds_chunks(1,2,2,1) = bounds(2,2,2)              
+      ENDIF
+        
+   END SUBROUTINE nemo_mapping
+
+   FUNCTION agrif_external_switch_index(ptx,pty,i1,isens)
+
+   USE dom_oce
+
+   INTEGER :: ptx, pty, i1, isens
+   INTEGER :: agrif_external_switch_index
+
+   IF( isens == 1 ) THEN
+      IF( ptx == 2 ) THEN ! T, V points
+         agrif_external_switch_index = jpiglo-i1+2
+      ELSE ! U, F points
+         agrif_external_switch_index = jpiglo-i1+1      
+      ENDIF
+   ELSE IF( isens ==2 ) THEN
+      IF ( pty == 2 ) THEN ! T, U points
+         agrif_external_switch_index = jpjglo-2-(i1 -jpjglo)
+      ELSE ! V, F points
+         agrif_external_switch_index = jpjglo-3-(i1 -jpjglo)
+      ENDIF
+   ENDIF
+
+   END FUNCTION agrif_external_switch_index
+
+   SUBROUTINE Correct_field(tab2d,i1,i2,j1,j2)
+      !!----------------------------------------------------------------------
+      !!                   *** ROUTINE Correct_field ***
+      !!----------------------------------------------------------------------
+   
+   USE dom_oce
+   USE agrif_oce
+
+   INTEGER :: i1,i2,j1,j2
+   REAL(wp), DIMENSION(i1:i2,j1:j2) :: tab2d
+
+   INTEGER :: i,j
+   REAL(wp), DIMENSION(i1:i2,j1:j2) :: tab2dtemp
+
+   tab2dtemp = tab2d
+
+   IF( .NOT. use_sign_north ) THEN
+      DO j=j1,j2
+         DO i=i1,i2
+            tab2d(i,j)=tab2dtemp(i2-(i-i1),j2-(j-j1))
+         END DO
+      END DO
+   ELSE
+      DO j=j1,j2
+         DO i=i1,i2
+            tab2d(i,j)=sign_north * tab2dtemp(i2-(i-i1),j2-(j-j1))
+         END DO
+      END DO
+   ENDIF
+
+   END SUBROUTINE Correct_field
+
 #else
    SUBROUTINE Subcalledbyagrif
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/dom_oce.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/dom_oce.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/dom_oce.F90	(revision 13229)
@@ -214,4 +214,5 @@
 #if defined key_agrif
    LOGICAL, PUBLIC, PARAMETER ::   lk_agrif = .TRUE.    !: agrif flag
+   LOGICAL, PUBLIC            ::   lk_south, lk_north, lk_west, lk_east !: Child grid boundaries (interpolation or not)
 #else
    LOGICAL, PUBLIC, PARAMETER ::   lk_agrif = .FALSE.   !: agrif flag
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/domain.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/domain.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/domain.F90	(revision 13229)
@@ -187,6 +187,11 @@
       ENDIF
       !
+
       IF( lk_c1d         )   CALL cor_c1d       ! 1D configuration: Coriolis set at T-point
       !
+
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() ) CALL Agrif_Init_Domain( Kbb, Kmm, Kaa )
+#endif
       IF( ln_meshmask    )   CALL dom_wri       ! Create a domain file
       IF( .NOT.ln_rstart )   CALL dom_ctl       ! Domain control
@@ -296,4 +301,11 @@
 902   IF( ios >  0 )   CALL ctl_nam ( ios , 'namrun in configuration namelist' )
       IF(lwm) WRITE ( numond, namrun )
+
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() ) THEN
+            nn_it000 = (Agrif_Parent(nn_it000)-1)*Agrif_IRhot() + 1
+            nn_itend =  Agrif_Parent(nn_itend)   *Agrif_IRhot()
+      ENDIF
+#endif
       !
       IF(lwp) THEN                  ! control print
@@ -388,4 +400,10 @@
       IF(lwm) WRITE( numond, namdom )
       !
+#if defined key_agrif
+      IF( .NOT. Agrif_Root() ) THEN
+            rn_Dt = Agrif_Parent(rn_Dt) / Agrif_Rhot()
+      ENDIF
+#endif
+      !
       IF(lwp) THEN
          WRITE(numout,*)
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/istate.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/istate.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DOM/istate.F90	(revision 13229)
@@ -34,4 +34,8 @@
    USE lib_mpp         ! MPP library
    USE restart         ! restart
+#if defined key_agrif
+   USE agrif_oce_interp
+   USE agrif_oce
+#endif   
 
    IMPLICIT NONE
@@ -69,5 +73,5 @@
 !!gm  Why not include in the first call of dta_tsd ?  
 !!gm  probably associated with the use of internal damping...
-                     CALL dta_tsd_init        ! Initialisation of T & S input data
+       CALL dta_tsd_init        ! Initialisation of T & S input data
 !!gm to be moved in usrdef of C1D case
 !      IF( lk_c1d )   CALL dta_uvd_init        ! Initialization of U & V input data
@@ -83,4 +87,17 @@
 #endif
 
+#if defined key_agrif
+      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)
+         CALL day_init 
+         CALL agrif_istate( Kbb, Kmm, Kaa )   ! Interp from parent
+         !
+         ts  (:,:,:,:,Kmm) = ts (:,:,:,:,Kbb) 
+         ssh (:,:,Kmm)     = ssh(:,:,Kbb)
+         uu   (:,:,:,Kmm)   = uu  (:,:,:,Kbb)
+         vv   (:,:,:,Kmm)   = vv  (:,:,:,Kbb)
+      ELSE
+#endif
       IF( ln_rstart ) THEN                    ! Restart from a file
          !                                    ! -------------------
@@ -99,4 +116,7 @@
             !
             ssh(:,:,Kbb)   = 0._wp               ! set the ocean at rest
+            uu  (:,:,:,Kbb) = 0._wp
+            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 
@@ -110,7 +130,5 @@
                END_2D
             ENDIF 
-            uu  (:,:,:,Kbb) = 0._wp
-            vv  (:,:,:,Kbb) = 0._wp  
-            !
+             !
          ELSE                                 ! user defined initial T and S
             CALL usr_def_istate( gdept(:,:,:,Kbb), tmask, ts(:,:,:,:,Kbb), uu(:,:,:,Kbb), vv(:,:,:,Kbb), ssh(:,:,Kbb)  )         
@@ -147,4 +165,7 @@
          ! 
       ENDIF 
+#if defined key_agrif
+      ENDIF
+#endif
       ! 
       ! Initialize "now" and "before" barotropic velocities:
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DYN/dynspg_ts.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DYN/dynspg_ts.F90	(revision 13229)
@@ -513,4 +513,10 @@
          END_2D
          !
+         ! Duplicate sea level across open boundaries (this is only cosmetic if linssh=T)
+         IF( ln_bdy )   CALL bdy_ssh( ssha_e )
+#if defined key_agrif
+         IF( .NOT.Agrif_Root() )   CALL agrif_ssh_ts( jn )
+#endif
+
          CALL lbc_lnk_multi( 'dynspg_ts', ssha_e, 'T', 1._wp,  zhU, 'U', -1._wp,  zhV, 'V', -1._wp )
          !
@@ -525,9 +531,4 @@
          END IF
          !
-         ! Duplicate sea level across open boundaries (this is only cosmetic if linssh=T)
-         IF( ln_bdy )   CALL bdy_ssh( ssha_e )
-#if defined key_agrif
-         IF( .NOT.Agrif_Root() )   CALL agrif_ssh_ts( jn )
-#endif
          !  
          ! Sea Surface Height at u-,v-points (vvl case only)
@@ -643,9 +644,17 @@
          ENDIF
        
-         IF( .NOT.ln_linssh ) THEN   !* Update ocean depth (variable volume case only)
+         IF( .NOT.ln_linssh ) THEN !* Update ocean depth (variable volume case only)
             hu_e (2:jpim1,2:jpjm1) = hu_0(2:jpim1,2:jpjm1) + zsshu_a(2:jpim1,2:jpjm1)
             hur_e(2:jpim1,2:jpjm1) = ssumask(2:jpim1,2:jpjm1) / ( hu_e(2:jpim1,2:jpjm1) + 1._wp - ssumask(2:jpim1,2:jpjm1) )
             hv_e (2:jpim1,2:jpjm1) = hv_0(2:jpim1,2:jpjm1) + zsshv_a(2:jpim1,2:jpjm1)
             hvr_e(2:jpim1,2:jpjm1) = ssvmask(2:jpim1,2:jpjm1) / ( hv_e(2:jpim1,2:jpjm1) + 1._wp - ssvmask(2:jpim1,2:jpjm1) )
+         ENDIF
+         !                                                 ! open boundaries
+         IF( ln_bdy )   CALL bdy_dyn2d( jn, ua_e, va_e, un_e, vn_e, hur_e, hvr_e, ssha_e )
+#if defined key_agrif                                                           
+         IF( .NOT.Agrif_Root() )  CALL agrif_dyn_ts( jn )  ! Agrif
+#endif
+         !
+         IF( .NOT.ln_linssh ) THEN   !* Update ocean depth (variable volume case only)
             CALL lbc_lnk_multi( 'dynspg_ts', ua_e , 'U', -1._wp, va_e , 'V', -1._wp  &
                  &                         , hu_e , 'U',  1._wp, hv_e , 'V',  1._wp  &
@@ -655,10 +664,4 @@
          ENDIF
          !
-         !
-         !                                                 ! open boundaries
-         IF( ln_bdy )   CALL bdy_dyn2d( jn, ua_e, va_e, un_e, vn_e, hur_e, hvr_e, ssha_e )
-#if defined key_agrif                                                           
-         IF( .NOT.Agrif_Root() )  CALL agrif_dyn_ts( jn )  ! Agrif
-#endif
          !                                             !* Swap
          !                                             !  ----
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DYN/sshwzv.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DYN/sshwzv.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/DYN/sshwzv.F90	(revision 13229)
@@ -200,4 +200,5 @@
       ENDIF
       !
+#if defined key_agrif 
       IF( .NOT. AGRIF_Root() ) THEN
          !
@@ -206,33 +207,42 @@
          DO jk = 1, jpkm1
             ! --- West --- !
-            DO ji = mi0(2+nn_hls), mi1(2+nn_hls)
-               DO jj = 1, jpj
-                  pww(ji,jj,jk) = 0._wp 
+            IF( lk_west ) THEN
+               DO ji = mi0(2+nn_hls), mi1(2+nn_hls)
+                  DO jj = 1, jpj
+                     pww(ji,jj,jk) = 0._wp 
+                  END DO
                END DO
-            END DO
+            ENDIF
             !
             ! --- East --- !
-            DO ji = mi0(jpiglo-1-nn_hls), mi1(jpiglo-1-nn_hls)
-               DO jj = 1, jpj
-                  pww(ji,jj,jk) = 0._wp
+            IF( lk_east ) THEN
+               DO ji = mi0(jpiglo-1-nn_hls), mi1(jpiglo-1-nn_hls)
+                  DO jj = 1, jpj
+                     pww(ji,jj,jk) = 0._wp
+                  END DO
                END DO
-            END DO
+            ENDIF
             !
             ! --- South --- !
-            DO jj = mj0(2+nn_hls), mj1(2+nn_hls)
-               DO ji = 1, jpi
-                  pww(ji,jj,jk) = 0._wp
+            IF( lk_south ) THEN
+               DO jj = mj0(2+nn_hls), mj1(2+nn_hls)
+                  DO ji = 1, jpi
+                     pww(ji,jj,jk) = 0._wp
+                  END DO
                END DO
-            END DO
+            ENDIF
             !
             ! --- North --- !
-            DO jj = mj0(jpjglo-1-nn_hls), mj1(jpjglo-1-nn_hls)
-               DO ji = 1, jpi
-                  pww(ji,jj,jk) = 0._wp
+            IF( lk_north ) THEN
+               DO jj = mj0(jpjglo-1-nn_hls), mj1(jpjglo-1-nn_hls)
+                  DO ji = 1, jpi
+                     pww(ji,jj,jk) = 0._wp
+                  END DO
                END DO
-            END DO
+            ENDIF
          END DO
          !
       ENDIF 
+#endif
       !
       IF( ln_timing )   CALL timing_stop('wzv')
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/FLO/floblk.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/FLO/floblk.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/FLO/floblk.F90	(revision 13229)
@@ -41,4 +41,8 @@
       INTEGER, INTENT( in  ) ::   Kbb, Kmm ! ocean time level indices
       !!
+#ifndef key_agrif
+
+!RB super quick fix to compile with agrif
+
       INTEGER :: jfl              ! dummy loop arguments
       INTEGER :: ind, ifin, iloop
@@ -364,4 +368,5 @@
          GO TO 222
       ENDIF
+#endif
       !
       !
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/IOM/iom.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/IOM/iom.F90	(revision 13229)
@@ -1112,8 +1112,9 @@
                            &         'we accept this case, even if there is a possible mix-up between z and time dimension' )   
                      idmspc = idmspc - 1
-                  ELSE
-                     CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,'         ,   &
-                        &                         'we do not accept data with '//cldmspc//' spatial dimensions',   &
-                        &                         'Use ncwa -a to suppress the unnecessary dimensions' )
+                  !!GS: possibility to read 3D ABL atmopsheric forcing and use 1st level to force BULK simulation
+                  !ELSE
+                  !   CALL ctl_stop( TRIM(clinfo), 'To keep iom lisibility, when reading a '//clrankpv//'D array,',   &
+                  !      &                         'we do not accept data with '//cldmspc//' spatial dimensions'  ,   &
+                  !      &                         'Use ncwa -a to suppress the unnecessary dimensions' )
                   ENDIF
             ENDIF
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/lib_mpp.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/lib_mpp.F90	(revision 13229)
@@ -137,7 +137,7 @@
 
    ! Communications summary report
-   CHARACTER(len=128), DIMENSION(:), ALLOCATABLE ::   crname_lbc                   !: names of lbc_lnk calling routines
-   CHARACTER(len=128), DIMENSION(:), ALLOCATABLE ::   crname_glb                   !: names of global comm calling routines
-   CHARACTER(len=128), DIMENSION(:), ALLOCATABLE ::   crname_dlg                   !: names of delayed global comm calling routines
+   CHARACTER(len=lca), DIMENSION(:), ALLOCATABLE ::   crname_lbc                   !: names of lbc_lnk calling routines
+   CHARACTER(len=lca), DIMENSION(:), ALLOCATABLE ::   crname_glb                   !: names of global comm calling routines
+   CHARACTER(len=lca), DIMENSION(:), ALLOCATABLE ::   crname_dlg                   !: names of delayed global comm calling routines
    INTEGER, PUBLIC                               ::   ncom_stp = 0                 !: copy of time step # istp
    INTEGER, PUBLIC                               ::   ncom_fsbc = 1                !: copy of sbc time step # nn_fsbc
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/mppini.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/mppini.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/LBC/mppini.F90	(revision 13229)
@@ -103,4 +103,9 @@
             &           'the domain is lay out for distributed memory computing!' )
          !
+#if defined key_agrif
+    IF (.NOT.agrif_root()) THEN
+      call agrif_nemo_init()
+    ENDIF
+#endif
    END SUBROUTINE mpp_init
 
@@ -341,4 +346,5 @@
             CALL ctl_stop( 'STOP', 'mpp_init: Agrif children requires jpjglo == nbcellsy + 2*( nbghostcells + 1 + nn_hls )' )
          IF( ln_use_jattr )   CALL ctl_stop( 'STOP', 'mpp_init:Agrif children requires ln_use_jattr = .false. ' )
+         CALL agrif_nemo_init()
       ENDIF
 #endif
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/OBS/diaobs.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/OBS/diaobs.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/OBS/diaobs.F90	(revision 13229)
@@ -94,5 +94,5 @@
    TYPE(obs_prof), PUBLIC, POINTER, DIMENSION(:) ::   profdataqc   !: Profile data after quality control
 
-   CHARACTER(len=6), PUBLIC, DIMENSION(:), ALLOCATABLE ::   cobstypesprof, cobstypessurf   !: Profile & surface obs types
+   CHARACTER(len=lca), PUBLIC, DIMENSION(:), ALLOCATABLE ::   cobstypesprof, cobstypessurf   !: Profile & surface obs types
 
    !!----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcblk.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcblk.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcblk.F90	(revision 13229)
@@ -74,17 +74,22 @@
 #endif
 
-   INTEGER , PUBLIC            ::   jpfld         ! maximum number of files to read
-   INTEGER , PUBLIC, PARAMETER ::   jp_wndi = 1   ! index of 10m wind velocity (i-component) (m/s)    at T-point
-   INTEGER , PUBLIC, PARAMETER ::   jp_wndj = 2   ! index of 10m wind velocity (j-component) (m/s)    at T-point
-   INTEGER , PUBLIC, PARAMETER ::   jp_tair = 3   ! index of 10m air temperature             (Kelvin)
-   INTEGER , PUBLIC, PARAMETER ::   jp_humi = 4   ! index of specific humidity               ( % )
-   INTEGER , PUBLIC, PARAMETER ::   jp_qsr  = 5   ! index of solar heat                      (W/m2)
-   INTEGER , PUBLIC, PARAMETER ::   jp_qlw  = 6   ! index of Long wave                       (W/m2)
-   INTEGER , PUBLIC, PARAMETER ::   jp_prec = 7   ! index of total precipitation (rain+snow) (Kg/m2/s)
-   INTEGER , PUBLIC, PARAMETER ::   jp_snow = 8   ! index of snow (solid prcipitation)       (kg/m2/s)
-   INTEGER , PUBLIC, PARAMETER ::   jp_slp  = 9   ! index of sea level pressure              (Pa)
-   INTEGER , PUBLIC, PARAMETER ::   jp_hpgi =10   ! index of ABL geostrophic wind or hpg (i-component) (m/s) at T-point
-   INTEGER , PUBLIC, PARAMETER ::   jp_hpgj =11   ! index of ABL geostrophic wind or hpg (j-component) (m/s) at T-point
-
+   INTEGER , PUBLIC, PARAMETER ::   jp_wndi  =  1   ! index of 10m wind velocity (i-component) (m/s)    at T-point
+   INTEGER , PUBLIC, PARAMETER ::   jp_wndj  =  2   ! index of 10m wind velocity (j-component) (m/s)    at T-point
+   INTEGER , PUBLIC, PARAMETER ::   jp_tair  =  3   ! index of 10m air temperature             (Kelvin)
+   INTEGER , PUBLIC, PARAMETER ::   jp_humi  =  4   ! index of specific humidity               ( % )
+   INTEGER , PUBLIC, PARAMETER ::   jp_qsr   =  5   ! index of solar heat                      (W/m2)
+   INTEGER , PUBLIC, PARAMETER ::   jp_qlw   =  6   ! index of Long wave                       (W/m2)
+   INTEGER , PUBLIC, PARAMETER ::   jp_prec  =  7   ! index of total precipitation (rain+snow) (Kg/m2/s)
+   INTEGER , PUBLIC, PARAMETER ::   jp_snow  =  8   ! index of snow (solid prcipitation)       (kg/m2/s)
+   INTEGER , PUBLIC, PARAMETER ::   jp_slp   =  9   ! index of sea level pressure              (Pa)
+   INTEGER , PUBLIC, PARAMETER ::   jp_uoatm = 10   ! index of surface current (i-component)
+   !                                                !          seen by the atmospheric forcing (m/s) at T-point
+   INTEGER , PUBLIC, PARAMETER ::   jp_voatm = 11   ! index of surface current (j-component)
+   !                                                !          seen by the atmospheric forcing (m/s) at T-point
+   INTEGER , PUBLIC, PARAMETER ::   jp_hpgi  = 12   ! index of ABL geostrophic wind or hpg (i-component) (m/s) at T-point
+   INTEGER , PUBLIC, PARAMETER ::   jp_hpgj  = 13   ! index of ABL geostrophic wind or hpg (j-component) (m/s) at T-point
+   INTEGER , PUBLIC, PARAMETER ::   jpfld    = 13   ! maximum number of files to read
+
+   ! Warning: keep this structure allocatable for Agrif...
    TYPE(FLD), PUBLIC, ALLOCATABLE, DIMENSION(:) ::   sf   ! structure of input atmospheric fields (file informations, fields read)
 
@@ -98,13 +103,16 @@
    LOGICAL  ::   ln_Cd_L15      ! ice-atm drag = F( ice concentration, atmospheric stability ) (Lupkes et al. JGR2015)
    !
+   LOGICAL  ::   ln_crt_fbk     ! Add surface current feedback to the wind stress computation  (Renault et al. 2020)
+   REAL(wp) ::   rn_stau_a      ! Alpha and Beta coefficients of Renault et al. 2020, eq. 10: Stau = Alpha * Wnd + Beta
+   REAL(wp) ::   rn_stau_b      ! 
+   !
    REAL(wp)         ::   rn_pfac   ! multiplication factor for precipitation
    REAL(wp), PUBLIC ::   rn_efac   ! multiplication factor for evaporation
-   REAL(wp), PUBLIC ::   rn_vfac   ! multiplication factor for ice/ocean velocity in the calculation of wind stress
    REAL(wp)         ::   rn_zqt    ! z(q,t) : height of humidity and temperature measurements
    REAL(wp)         ::   rn_zu     ! z(u)   : height of wind measurements
    !
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   Cd_ice , Ch_ice , Ce_ice   ! transfert coefficients over ice
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   Cdn_oce, Chn_oce, Cen_oce  ! neutral coeffs over ocean (L15 bulk scheme)
-   REAL(wp), ALLOCATABLE, DIMENSION(:,:) ::   t_zu, q_zu                 ! air temp. and spec. hum. at wind speed height (L15 bulk scheme)
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION(:,:) ::   Cdn_oce, Chn_oce, Cen_oce  ! neutral coeffs over ocean (L15 bulk scheme and ABL)
+   REAL(wp),         ALLOCATABLE, DIMENSION(:,:) ::   Cd_ice , Ch_ice , Ce_ice   ! transfert coefficients over ice
+   REAL(wp),         ALLOCATABLE, DIMENSION(:,:) ::   t_zu, q_zu                 ! air temp. and spec. hum. at wind speed height (L15 bulk scheme)
 
    LOGICAL  ::   ln_skin_cs     ! use the cool-skin (only available in ECMWF and COARE algorithms) !LB
@@ -113,4 +121,5 @@
    LOGICAL  ::   ln_humi_dpt    ! humidity read in files ("sn_humi") is dew-point temperature [K] if .true. !LB
    LOGICAL  ::   ln_humi_rlh    ! humidity read in files ("sn_humi") is relative humidity     [%] if .true. !LB
+   LOGICAL  ::   ln_tpot        !!GS: flag to compute or not potential temperature
    !
    INTEGER  ::   nhumi          ! choice of the bulk algorithm
@@ -162,13 +171,17 @@
       !!
       CHARACTER(len=100)            ::   cn_dir                ! Root directory for location of atmospheric forcing files
-      TYPE(FLD_N), ALLOCATABLE, DIMENSION(:) ::   slf_i        ! array of namelist informations on the fields to read
-      TYPE(FLD_N) ::   sn_wndi, sn_wndj, sn_humi, sn_qsr       ! informations about the fields to be read
-      TYPE(FLD_N) ::   sn_qlw , sn_tair, sn_prec, sn_snow      !       "                        "
-      TYPE(FLD_N) ::   sn_slp , sn_hpgi, sn_hpgj               !       "                        "
+      TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i                 ! array of namelist informations on the fields to read
+      TYPE(FLD_N) ::   sn_wndi, sn_wndj , sn_humi, sn_qsr      ! informations about the fields to be read
+      TYPE(FLD_N) ::   sn_qlw , sn_tair , sn_prec, sn_snow     !       "                        "
+      TYPE(FLD_N) ::   sn_slp , sn_uoatm, sn_voatm             !       "                        "
+      TYPE(FLD_N) ::   sn_hpgi, sn_hpgj                        !       "                        "
+      INTEGER     ::   ipka                                    ! number of levels in the atmospheric variable
       NAMELIST/namsbc_blk/ sn_wndi, sn_wndj, sn_humi, sn_qsr, sn_qlw ,                &   ! input fields
-         &                 sn_tair, sn_prec, sn_snow, sn_slp, sn_hpgi, sn_hpgj,       &
+         &                 sn_tair, sn_prec, sn_snow, sn_slp, sn_uoatm, sn_voatm,     &
+         &                 sn_hpgi, sn_hpgj,                                          &
          &                 ln_NCAR, ln_COARE_3p0, ln_COARE_3p6, ln_ECMWF,             &   ! bulk algorithm
          &                 cn_dir , rn_zqt, rn_zu,                                    &
-         &                 rn_pfac, rn_efac, rn_vfac, ln_Cd_L12, ln_Cd_L15,           &
+         &                 rn_pfac, rn_efac, ln_Cd_L12, ln_Cd_L15, ln_tpot,           &
+         &                 ln_crt_fbk, rn_stau_a, rn_stau_b,                          &   ! current feedback
          &                 ln_skin_cs, ln_skin_wl, ln_humi_sph, ln_humi_dpt, ln_humi_rlh  ! cool-skin / warm-layer !LB
       !!---------------------------------------------------------------------
@@ -242,16 +255,17 @@
       !                                   !* set the bulk structure
       !                                      !- store namelist information in an array
-      IF( ln_blk ) jpfld = 9
-      IF( ln_abl ) jpfld = 11
-      ALLOCATE( slf_i(jpfld) )
-      !
-      slf_i(jp_wndi) = sn_wndi   ;   slf_i(jp_wndj) = sn_wndj
-      slf_i(jp_qsr ) = sn_qsr    ;   slf_i(jp_qlw ) = sn_qlw
-      slf_i(jp_tair) = sn_tair   ;   slf_i(jp_humi) = sn_humi
-      slf_i(jp_prec) = sn_prec   ;   slf_i(jp_snow) = sn_snow
-      slf_i(jp_slp ) = sn_slp
-      IF( ln_abl ) THEN
-         slf_i(jp_hpgi) = sn_hpgi   ;   slf_i(jp_hpgj) = sn_hpgj
-      END IF
+      !
+      slf_i(jp_wndi ) = sn_wndi    ;   slf_i(jp_wndj ) = sn_wndj
+      slf_i(jp_qsr  ) = sn_qsr     ;   slf_i(jp_qlw  ) = sn_qlw
+      slf_i(jp_tair ) = sn_tair    ;   slf_i(jp_humi ) = sn_humi
+      slf_i(jp_prec ) = sn_prec    ;   slf_i(jp_snow ) = sn_snow
+      slf_i(jp_slp  ) = sn_slp
+      slf_i(jp_uoatm) = sn_uoatm   ;   slf_i(jp_voatm) = sn_voatm
+      slf_i(jp_hpgi ) = sn_hpgi    ;   slf_i(jp_hpgj ) = sn_hpgj
+      !
+      IF( .NOT. ln_abl ) THEN   ! force to not use jp_hpgi and jp_hpgj, should already be done in namelist_* but we never know...
+         slf_i(jp_hpgi)%clname = 'NOT USED'
+         slf_i(jp_hpgj)%clname = 'NOT USED'
+      ENDIF
       !
       !                                      !- allocate the bulk structure
@@ -264,17 +278,27 @@
       DO jfpr= 1, jpfld
          !
-         IF( TRIM(sf(jfpr)%clrootname) == 'NOT USED' ) THEN    !--  not used field  --!   (only now allocated and set to zero)
-            ALLOCATE( sf(jfpr)%fnow(jpi,jpj,1) )
-            sf(jfpr)%fnow(:,:,1) = 0._wp
+         IF(   ln_abl    .AND.                                                      &
+            &    ( jfpr == jp_wndi .OR. jfpr == jp_wndj .OR. jfpr == jp_humi .OR.   &
+            &      jfpr == jp_hpgi .OR. jfpr == jp_hpgj .OR. jfpr == jp_tair     )  ) THEN
+            ipka = jpka   ! ABL: some fields are 3D input
+         ELSE
+            ipka = 1
+         ENDIF
+         !
+         ALLOCATE( sf(jfpr)%fnow(jpi,jpj,ipka) )
+         !
+         IF( TRIM(sf(jfpr)%clrootname) == 'NOT USED' ) THEN    !--  not used field  --!   (only now allocated and set to default)
+            IF(     jfpr == jp_slp  ) THEN
+               sf(jfpr)%fnow(:,:,1:ipka) = 101325._wp   ! use standard pressure in Pa
+            ELSEIF( jfpr == jp_prec .OR. jfpr == jp_snow .OR. jfpr == jp_uoatm .OR. jfpr == jp_voatm ) THEN
+               sf(jfpr)%fnow(:,:,1:ipka) = 0._wp        ! no precip or no snow or no surface currents
+            ELSEIF( ( jfpr == jp_hpgi .OR. jfpr == jp_hpgj ) .AND. .NOT. ln_abl ) THEN
+               DEALLOCATE( sf(jfpr)%fnow )              ! deallocate as not used in this case
+            ELSE
+               WRITE(ctmp1,*) 'sbc_blk_init: no default value defined for field number', jfpr
+               CALL ctl_stop( ctmp1 )
+            ENDIF
          ELSE                                                  !-- used field  --!
-            IF(   ln_abl    .AND.                                                      &
-               &    ( jfpr == jp_wndi .OR. jfpr == jp_wndj .OR. jfpr == jp_humi .OR.   &
-               &      jfpr == jp_hpgi .OR. jfpr == jp_hpgj .OR. jfpr == jp_tair     )  ) THEN   ! ABL: some fields are 3D input
-               ALLOCATE( sf(jfpr)%fnow(jpi,jpj,jpka) )
-               IF( sf(jfpr)%ln_tint )   ALLOCATE( sf(jfpr)%fdta(jpi,jpj,jpka,2) )
-            ELSE                                                                                ! others or Bulk fields are 2D fiels
-               ALLOCATE( sf(jfpr)%fnow(jpi,jpj,1) )
-               IF( sf(jfpr)%ln_tint )   ALLOCATE( sf(jfpr)%fdta(jpi,jpj,1,2) )
-            ENDIF
+            IF( sf(jfpr)%ln_tint )   ALLOCATE( sf(jfpr)%fdta(jpi,jpj,ipka,2) )   ! allocate array for temporal interpolation
             !
             IF( sf(jfpr)%freqh > 0. .AND. MOD( NINT(3600. * sf(jfpr)%freqh), nn_fsbc * NINT(rn_Dt) ) /= 0 )   &
@@ -327,8 +351,13 @@
          WRITE(numout,*) '      factor applied on precipitation (total & snow)      rn_pfac      = ', rn_pfac
          WRITE(numout,*) '      factor applied on evaporation                       rn_efac      = ', rn_efac
-         WRITE(numout,*) '      factor applied on ocean/ice velocity                rn_vfac      = ', rn_vfac
          WRITE(numout,*) '         (form absolute (=0) to relative winds(=1))'
          WRITE(numout,*) '      use ice-atm drag from Lupkes2012                    ln_Cd_L12    = ', ln_Cd_L12
          WRITE(numout,*) '      use ice-atm drag from Lupkes2015                    ln_Cd_L15    = ', ln_Cd_L15
+         WRITE(numout,*) '      use surface current feedback on wind stress         ln_crt_fbk   = ', ln_crt_fbk
+         IF(ln_crt_fbk) THEN
+         WRITE(numout,*) '         Renault et al. 2020, eq. 10: Stau = Alpha * Wnd + Beta'
+         WRITE(numout,*) '            Alpha                                         rn_stau_a    = ', rn_stau_a
+         WRITE(numout,*) '            Beta                                          rn_stau_b    = ', rn_stau_b
+         ENDIF
          !
          WRITE(numout,*)
@@ -429,14 +458,15 @@
       !                                            ! compute the surface ocean fluxes using bulk formulea
       IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN
-         CALL blk_oce_1( kt, sf(jp_wndi)%fnow(:,:,1), sf(jp_wndj)%fnow(:,:,1),   &   !   <<= in
-            &                sf(jp_tair)%fnow(:,:,1), sf(jp_humi)%fnow(:,:,1),   &   !   <<= in
-            &                sf(jp_slp )%fnow(:,:,1), sst_m, ssu_m, ssv_m,       &   !   <<= in
-            &                sf(jp_qsr )%fnow(:,:,1), sf(jp_qlw )%fnow(:,:,1),   &   !   <<= in (wl/cs)
-            &                tsk_m, zssq, zcd_du, zsen, zevp )                       !   =>> out
-
-         CALL blk_oce_2(     sf(jp_tair)%fnow(:,:,1), sf(jp_qsr )%fnow(:,:,1),   &   !   <<= in
-            &                sf(jp_qlw )%fnow(:,:,1), sf(jp_prec)%fnow(:,:,1),   &   !   <<= in
-            &                sf(jp_snow)%fnow(:,:,1), tsk_m,                     &   !   <<= in
-            &                zsen, zevp )                                            !   <=> in out
+         CALL blk_oce_1( kt, sf(jp_wndi )%fnow(:,:,1), sf(jp_wndj )%fnow(:,:,1),   &   !   <<= in
+            &                sf(jp_tair )%fnow(:,:,1), sf(jp_humi )%fnow(:,:,1),   &   !   <<= in
+            &                sf(jp_slp  )%fnow(:,:,1), sst_m, ssu_m, ssv_m,        &   !   <<= in
+            &                sf(jp_uoatm)%fnow(:,:,1), sf(jp_voatm)%fnow(:,:,1),   &   !   <<= in
+            &                sf(jp_qsr  )%fnow(:,:,1), sf(jp_qlw  )%fnow(:,:,1),   &   !   <<= in (wl/cs)
+            &                tsk_m, zssq, zcd_du, zsen, zevp )                         !   =>> out
+
+         CALL blk_oce_2(     sf(jp_tair )%fnow(:,:,1), sf(jp_qsr  )%fnow(:,:,1),   &   !   <<= in
+            &                sf(jp_qlw  )%fnow(:,:,1), sf(jp_prec )%fnow(:,:,1),   &   !   <<= in
+            &                sf(jp_snow )%fnow(:,:,1), tsk_m,                      &   !   <<= in
+            &                zsen, zevp )                                              !   <=> in out
       ENDIF
       !
@@ -470,8 +500,8 @@
 
 
-   SUBROUTINE blk_oce_1( kt, pwndi, pwndj , ptair, phumi, &  ! inp
-      &                  pslp , pst   , pu   , pv,        &  ! inp
-      &                  pqsr , pqlw  ,                   &  ! inp
-      &                  ptsk, pssq , pcd_du, psen , pevp   )  ! out
+   SUBROUTINE blk_oce_1( kt, pwndi, pwndj, ptair, phumi,         &  ! inp
+      &                      pslp , pst  , pu   , pv,            &  ! inp
+      &                      puatm, pvatm, pqsr , pqlw ,         &  ! inp
+      &                      ptsk , pssq , pcd_du, psen, pevp   )   ! out
       !!---------------------------------------------------------------------
       !!                     ***  ROUTINE blk_oce_1  ***
@@ -498,4 +528,6 @@
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pu     ! surface current at U-point (i-component) [m/s]
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pv     ! surface current at V-point (j-component) [m/s]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   puatm  ! surface current seen by the atm at T-point (i-component) [m/s]
+      REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pvatm  ! surface current seen by the atm at T-point (j-component) [m/s]
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqsr   !
       REAL(wp), INTENT(in   ), DIMENSION(:,:) ::   pqlw   !
@@ -508,5 +540,9 @@
       INTEGER  ::   ji, jj               ! dummy loop indices
       REAL(wp) ::   zztmp                ! local variable
+      REAL(wp) ::   zstmax, zstau
+#if defined key_cyclone
       REAL(wp), DIMENSION(jpi,jpj) ::   zwnd_i, zwnd_j    ! wind speed components at T-point
+#endif
+      REAL(wp), DIMENSION(jpi,jpj) ::   ztau_i, ztau_j    ! wind stress components at T-point
       REAL(wp), DIMENSION(jpi,jpj) ::   zU_zu             ! bulk wind speed at height zu  [m/s]
       REAL(wp), DIMENSION(jpi,jpj) ::   ztpot             ! potential temperature of air at z=rn_zqt [K]
@@ -532,18 +568,16 @@
       zwnd_j(:,:) = 0._wp
       CALL wnd_cyc( kt, zwnd_i, zwnd_j )    ! add analytical tropical cyclone (Vincent et al. JGR 2012)
-      DO_2D_00_00
-         pwndi(ji,jj) = pwndi(ji,jj) + zwnd_i(ji,jj)
-         pwndj(ji,jj) = pwndj(ji,jj) + zwnd_j(ji,jj)
+      DO_2D_11_11
+         zwnd_i(ji,jj) = pwndi(ji,jj) + zwnd_i(ji,jj)
+         zwnd_j(ji,jj) = pwndj(ji,jj) + zwnd_j(ji,jj)
+         ! ... scalar wind at T-point (not masked)
+         wndm(ji,jj) = SQRT( zwnd_i(ji,jj) * zwnd_i(ji,jj) + zwnd_j(ji,jj) * zwnd_j(ji,jj) )
+      END_2D
+#else
+      ! ... scalar wind module at T-point (not masked)
+      DO_2D_11_11
+         wndm(ji,jj) = SQRT(  pwndi(ji,jj) * pwndi(ji,jj) + pwndj(ji,jj) * pwndj(ji,jj)  )
       END_2D
 #endif
-      DO_2D_00_00
-         zwnd_i(ji,jj) = (  pwndi(ji,jj) - rn_vfac * 0.5 * ( pu(ji-1,jj  ) + pu(ji,jj) )  )
-         zwnd_j(ji,jj) = (  pwndj(ji,jj) - rn_vfac * 0.5 * ( pv(ji  ,jj-1) + pv(ji,jj) )  )
-      END_2D
-      CALL lbc_lnk_multi( 'sbcblk', zwnd_i, 'T', -1., zwnd_j, 'T', -1. )
-      ! ... scalar wind ( = | U10m - U_oce | ) at T-point (masked)
-      wndm(:,:) = SQRT(  zwnd_i(:,:) * zwnd_i(:,:)   &
-         &             + zwnd_j(:,:) * zwnd_j(:,:)  ) * tmask(:,:,1)
-
       ! ----------------------------------------------------------------------------- !
       !      I   Solar FLUX                                                           !
@@ -593,10 +627,12 @@
          !#LB: because AGRIF hates functions that return something else than a scalar, need to
          !     use scalar version of gamma_moist() ...
-         DO_2D_11_11
-            ztpot(ji,jj) = ptair(ji,jj) + gamma_moist( ptair(ji,jj), zqair(ji,jj) ) * rn_zqt
-         END_2D
-      ENDIF
-
-
+         IF( ln_tpot ) THEN
+            DO_2D_11_11
+               ztpot(ji,jj) = ptair(ji,jj) + gamma_moist( ptair(ji,jj), zqair(ji,jj) ) * rn_zqt
+            END_2D
+         ELSE
+            ztpot = ptair(:,:)
+         ENDIF
+      ENDIF
 
       !! Time to call the user-selected bulk parameterization for
@@ -674,22 +710,47 @@
          pevp(:,:) = pevp(:,:) * tmask(:,:,1)
 
-         ! Tau i and j component on T-grid points, using array "zcd_oce" as a temporary array...
-         zcd_oce = 0._wp
-         WHERE ( wndm > 0._wp ) zcd_oce = taum / wndm
-         zwnd_i = zcd_oce * zwnd_i
-         zwnd_j = zcd_oce * zwnd_j
-
-         CALL iom_put( "taum_oce", taum )   ! output wind stress module
+         DO_2D_11_11
+            IF( wndm(ji,jj) > 0._wp ) THEN
+               zztmp = taum(ji,jj) / wndm(ji,jj)
+#if defined key_cyclone
+               ztau_i(ji,jj) = zztmp * zwnd_i(ji,jj)
+               ztau_j(ji,jj) = zztmp * zwnd_j(ji,jj)
+#else
+               ztau_i(ji,jj) = zztmp * pwndi(ji,jj)
+               ztau_j(ji,jj) = zztmp * pwndj(ji,jj)
+#endif
+            ELSE
+               ztau_i(ji,jj) = 0._wp
+               ztau_j(ji,jj) = 0._wp                 
+            ENDIF
+         END_2D
+
+         IF( ln_crt_fbk ) THEN   ! aply eq. 10 and 11 of Renault et al. 2020 (doi: 10.1029/2019MS001715)
+            zstmax = MIN( rn_stau_a * 3._wp + rn_stau_b, 0._wp )   ! set the max value of Stau corresponding to a wind of 3 m/s (<0)
+            DO_2D_01_01   ! end at jpj and jpi, as ztau_j(ji,jj+1) ztau_i(ji+1,jj) used in the next loop
+               zstau = MIN( rn_stau_a * wndm(ji,jj) + rn_stau_b, zstmax )   ! stau (<0) must be smaller than zstmax
+               ztau_i(ji,jj) = ztau_i(ji,jj) + zstau * ( 0.5_wp * ( pu(ji-1,jj  ) + pu(ji,jj) ) - puatm(ji,jj) )
+               ztau_j(ji,jj) = ztau_j(ji,jj) + zstau * ( 0.5_wp * ( pv(ji  ,jj-1) + pv(ji,jj) ) - pvatm(ji,jj) )
+               taum(ji,jj) = SQRT( ztau_i(ji,jj) * ztau_i(ji,jj) + ztau_j(ji,jj) * ztau_j(ji,jj) )
+            END_2D
+         ENDIF
 
          ! ... utau, vtau at U- and V_points, resp.
          !     Note the use of 0.5*(2-umask) in order to unmask the stress along coastlines
          !     Note that coastal wind stress is not used in the code... so this extra care has no effect
-         DO_2D_00_00
-            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( zwnd_i(ji,jj) + zwnd_i(ji+1,jj  ) ) &
-               &          * MAX(tmask(ji,jj,1),tmask(ji+1,jj,1))
-            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( zwnd_j(ji,jj) + zwnd_j(ji  ,jj+1) ) &
-               &          * MAX(tmask(ji,jj,1),tmask(ji,jj+1,1))
+         DO_2D_00_00              ! start loop at 2, in case ln_crt_fbk = T
+            utau(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( ztau_i(ji,jj) + ztau_i(ji+1,jj  ) ) &
+               &              * MAX(tmask(ji,jj,1),tmask(ji+1,jj,1))
+            vtau(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( ztau_j(ji,jj) + ztau_j(ji  ,jj+1) ) &
+               &              * MAX(tmask(ji,jj,1),tmask(ji,jj+1,1))
          END_2D
-         CALL lbc_lnk_multi( 'sbcblk', utau, 'U', -1., vtau, 'V', -1. )
+
+         IF( ln_crt_fbk ) THEN
+            CALL lbc_lnk_multi( 'sbcblk', utau, 'U', -1., vtau, 'V', -1., taum, 'T', -1. )
+         ELSE
+            CALL lbc_lnk_multi( 'sbcblk', utau, 'U', -1., vtau, 'V', -1. )
+         ENDIF
+
+         CALL iom_put( "taum_oce", taum )   ! output wind stress module
 
          IF(sn_cfctl%l_prtctl) THEN
@@ -862,5 +923,4 @@
       !
       INTEGER  ::   ji, jj    ! dummy loop indices
-      REAL(wp) ::   zwndi_t , zwndj_t             ! relative wind components at T-point
       REAL(wp) ::   zootm_su                      ! sea-ice surface mean temperature
       REAL(wp) ::   zztmp1, zztmp2                ! temporary arrays
@@ -873,10 +933,7 @@
       ! ------------------------------------------------------------ !
       ! C-grid ice dynamics :   U & V-points (same as ocean)
-      DO_2D_00_00
-         zwndi_t = (  pwndi(ji,jj) - rn_vfac * 0.5_wp * ( puice(ji-1,jj  ) + puice(ji,jj) )  )
-         zwndj_t = (  pwndj(ji,jj) - rn_vfac * 0.5_wp * ( pvice(ji  ,jj-1) + pvice(ji,jj) )  )
-         wndm_ice(ji,jj) = SQRT( zwndi_t * zwndi_t + zwndj_t * zwndj_t ) * tmask(ji,jj,1)
+      DO_2D_11_11
+         wndm_ice(ji,jj) = SQRT( pwndi(ji,jj) * pwndi(ji,jj) + pwndj(ji,jj) * pwndj(ji,jj) )
       END_2D
-      CALL lbc_lnk( 'sbcblk', wndm_ice, 'T',  1. )
       !
       ! Make ice-atm. drag dependent on ice concentration
@@ -898,11 +955,11 @@
 
       IF( ln_blk ) THEN
-         ! ------------------------------------------------------------- !
-         !    Wind stress relative to the moving ice ( U10m - U_ice )    !
-         ! ------------------------------------------------------------- !
-         zztmp1 = rn_vfac * 0.5_wp
+         ! ---------------------------------------------------- !
+         !    Wind stress relative to nonmoving ice ( U10m )    !
+         ! ---------------------------------------------------- !
+         ! supress moving ice in wind stress computation as we don't know how to do it properly...
          DO_2D_01_01    ! at T point 
-            putaui(ji,jj) = rhoa(ji,jj) * zcd_dui(ji,jj) * ( pwndi(ji,jj) - zztmp1 * ( puice(ji-1,jj  ) + puice(ji,jj) ) )
-            pvtaui(ji,jj) = rhoa(ji,jj) * zcd_dui(ji,jj) * ( pwndj(ji,jj) - zztmp1 * ( pvice(ji  ,jj-1) + pvice(ji,jj) ) )
+            putaui(ji,jj) = rhoa(ji,jj) * zcd_dui(ji,jj) * pwndi(ji,jj)
+            pvtaui(ji,jj) = rhoa(ji,jj) * zcd_dui(ji,jj) * pwndj(ji,jj)
          END_2D
          !
@@ -918,5 +975,5 @@
          IF(sn_cfctl%l_prtctl)  CALL prt_ctl( tab2d_1=putaui  , clinfo1=' blk_ice: putaui : '   &
             &                               , tab2d_2=pvtaui  , clinfo2='          pvtaui : ' )
-      ELSE
+      ELSE ! ln_abl
          zztmp1 = 11637800.0_wp
          zztmp2 =    -5897.8_wp
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcblk_phy.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcblk_phy.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcblk_phy.F90	(revision 13229)
@@ -640,5 +640,5 @@
       !!                           ***  FUNCTION alpha_sw_vctr  ***
       !!
-      !! ** Purpose : ROUGH estimate of the thermal expansion coefficient of sea-water at the surface (P =~ 1010 hpa)
+      !! ** Purpose : ROUGH estimate of the thermal expansion coefficient of sea-water at the surface (i.e. P =~ 101000 Pa)
       !!
       !! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
@@ -654,5 +654,5 @@
       !!                           ***  FUNCTION alpha_sw_sclr  ***
       !!
-      !! ** Purpose : ROUGH estimate of the thermal expansion coefficient of sea-water at the surface (P =~ 1010 hpa)
+      !! ** Purpose : ROUGH estimate of the thermal expansion coefficient of sea-water at the surface (i.e. P =~ 101000 Pa)
       !!
       !! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcmod.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcmod.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/SBC/sbcmod.F90	(revision 13229)
@@ -121,4 +121,5 @@
 #endif
       !
+      !
       IF(lwp) THEN                  !* Control print
          WRITE(numout,*) '   Namelist namsbc (partly overwritten with CPP key setting)'
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/STO/stopar.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/STO/stopar.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/STO/stopar.F90	(revision 13229)
@@ -56,6 +56,6 @@
    INTEGER,          DIMENSION(:),       ALLOCATABLE :: sto3d_ord  ! order of autoregressive process
 
-   CHARACTER(len=1), DIMENSION(:),       ALLOCATABLE :: sto2d_typ  ! nature of grid point (T, U, V, W, F, I)
-   CHARACTER(len=1), DIMENSION(:),       ALLOCATABLE :: sto3d_typ  ! nature of grid point (T, U, V, W, F, I)
+   CHARACTER(len=lca), DIMENSION(:),       ALLOCATABLE :: sto2d_typ  ! nature of grid point (T, U, V, W, F, I)
+   CHARACTER(len=lca), DIMENSION(:),       ALLOCATABLE :: sto3d_typ  ! nature of grid point (T, U, V, W, F, I)
    REAL(wp),         DIMENSION(:),       ALLOCATABLE :: sto2d_sgn  ! control of the sign accross the north fold
    REAL(wp),         DIMENSION(:),       ALLOCATABLE :: sto3d_sgn  ! control of the sign accross the north fold
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/TRA/traqsr.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/TRA/traqsr.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/TRA/traqsr.F90	(revision 13229)
@@ -110,10 +110,9 @@
       REAL(wp) ::   zc0 , zc1 , zc2 , zc3    !    -         -
       REAL(wp) ::   zzc0, zzc1, zzc2, zzc3   !    -         -
-      REAL(wp) ::   zz0 , zz1                !    -         -
-      REAL(wp) ::   zCb, zCmax, zze, zpsi, zpsimax, zdelpsi, zCtot, zCze
-      REAL(wp) ::   zlogc, zlogc2, zlogc3 
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   :: zekb, zekg, zekr
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: ze0, ze1, ze2, ze3, zea, ztrdt
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: zetot, zchl3d
+      REAL(wp) ::   zz0 , zz1 , ze3t, zlui   !    -         -
+      REAL(wp) ::   zCb, zCmax, zpsi, zpsimax, zrdpsi, zCze
+      REAL(wp) ::   zlogc, zlogze, zlogCtot, zlogCze
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:)   :: ze0, ze1, ze2, ze3
+      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) :: ztrdt, zetot, ztmp3d
       !!----------------------------------------------------------------------
       !
@@ -160,75 +159,95 @@
       CASE( np_RGB , np_RGBc )         !==  R-G-B fluxes  ==!
          !
-         ALLOCATE( zekb(jpi,jpj)     , zekg(jpi,jpj)     , zekr  (jpi,jpj)     , &
-            &      ze0 (jpi,jpj,jpk) , ze1 (jpi,jpj,jpk) , ze2   (jpi,jpj,jpk) , &
-            &      ze3 (jpi,jpj,jpk) , zea (jpi,jpj,jpk) , zchl3d(jpi,jpj,jpk)   ) 
+         ALLOCATE( ze0 (jpi,jpj)           , ze1 (jpi,jpj) ,   &
+            &      ze2 (jpi,jpj)           , ze3 (jpi,jpj) ,   &
+            &      ztmp3d(jpi,jpj,nksr + 1)                     )
          !
          IF( nqsr == np_RGBc ) THEN          !*  Variable Chlorophyll
             CALL fld_read( kt, 1, sf_chl )         ! Read Chl data and provides it at the current time step
+            !
+            ! Separation in R-G-B depending on the surface Chl
+            ! perform and store as many of the 2D calculations as possible
+            ! before the 3D loop (use the temporary 2D arrays to replace the
+            ! most expensive calculations)
+            !
+            DO_2D_00_00
+                       ! zlogc = log(zchl)
+               zlogc = LOG ( MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) ) )     
+                       ! zc1 : log(zCze)  = log (1.12  * zchl**0.803)
+               zc1   = 0.113328685307 + 0.803 * zlogc                         
+                       ! zc2 : log(zCtot) = log(40.6  * zchl**0.459)
+               zc2   = 3.703768066608 + 0.459 * zlogc                           
+                       ! zc3 : log(zze)   = log(568.2 * zCtot**(-0.746))
+               zc3   = 6.34247346942  - 0.746 * zc2                           
+                       ! IF( log(zze) > log(102.) ) log(zze) = log(200.0 * zCtot**(-0.293))
+               IF( zc3 > 4.62497281328 ) zc3 = 5.298317366548 - 0.293 * zc2        
+               !   
+               ze0(ji,jj) = zlogc                                                 ! ze0 = log(zchl)
+               ze1(ji,jj) = EXP( zc1 )                                            ! ze1 = zCze
+               ze2(ji,jj) = 1._wp / ( 0.710 + zlogc * ( 0.159 + zlogc * 0.021 ) ) ! ze2 = 1/zdelpsi
+               ze3(ji,jj) = EXP( - zc3 )                                          ! ze3 = 1/zze
+            END_2D
+            
+!
+            DO_3D_00_00 ( 1, nksr + 1 )
+               ! zchl    = ALOG( ze0(ji,jj) )
+               zlogc = ze0(ji,jj)
+               !
+               zCb       = 0.768 + zlogc * ( 0.087 - zlogc * ( 0.179 + zlogc * 0.025 ) )
+               zCmax     = 0.299 - zlogc * ( 0.289 - zlogc * 0.579 )
+               zpsimax   = 0.6   - zlogc * ( 0.640 - zlogc * ( 0.021 + zlogc * 0.115 ) )
+               ! zdelpsi = 0.710 + zlogc * ( 0.159 + zlogc * 0.021 )
+               !
+               zCze   = ze1(ji,jj)
+               zrdpsi = ze2(ji,jj)                                                 ! 1/zdelpsi
+               zpsi   = ze3(ji,jj) * gdepw(ji,jj,jk,Kmm)                           ! gdepw/zze
+               !
+               ! NB. make sure zchl value is such that: zchl = MIN( 10. , MAX( 0.03, zchl ) )
+               zchl = MIN( 10. , MAX( 0.03, zCze * ( zCb + zCmax * EXP( -( (zpsi - zpsimax) * zrdpsi )**2 ) ) ) )
+               ! Convert chlorophyll value to attenuation coefficient look-up table index
+               ztmp3d(ji,jj,jk) = 41 + 20.*LOG10(zchl) + 1.e-15
+            END_3D
+         ELSE                                !* constant chlorophyll
+            zchl = 0.05
+            ! NB. make sure constant value is such that: 
+            zchl = MIN( 10. , MAX( 0.03, zchl ) )
+            ! Convert chlorophyll value to attenuation coefficient look-up table index
+            zlui = 41 + 20.*LOG10(zchl) + 1.e-15
             DO jk = 1, nksr + 1
-               DO jj = 2, jpjm1                       ! Separation in R-G-B depending of the surface Chl
-                  DO ji = 2, jpim1
-                     zchl    = MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) )
-                     zCtot   = 40.6  * zchl**0.459
-                     zze     = 568.2 * zCtot**(-0.746)
-                     IF( zze > 102. ) zze = 200.0 * zCtot**(-0.293)
-                     zpsi    = gdepw(ji,jj,jk,Kmm) / zze
-                     !
-                     zlogc   = LOG( zchl )
-                     zlogc2  = zlogc * zlogc
-                     zlogc3  = zlogc * zlogc * zlogc
-                     zCb     = 0.768 + 0.087 * zlogc - 0.179 * zlogc2 - 0.025 * zlogc3
-                     zCmax   = 0.299 - 0.289 * zlogc + 0.579 * zlogc2
-                     zpsimax = 0.6   - 0.640 * zlogc + 0.021 * zlogc2 + 0.115 * zlogc3
-                     zdelpsi = 0.710 + 0.159 * zlogc + 0.021 * zlogc2
-                     zCze    = 1.12  * (zchl)**0.803 
-                     !
-                     zchl3d(ji,jj,jk) = zCze * ( zCb + zCmax * EXP( -( (zpsi - zpsimax) / zdelpsi )**2 ) )
-                  END DO
-                  !
-               END DO
+               ztmp3d(:,:,jk) = zlui 
             END DO
-         ELSE                                !* constant chrlorophyll
-           DO jk = 1, nksr + 1
-              zchl3d(:,:,jk) = 0.05 
-            ENDDO
          ENDIF
          !
          zcoef  = ( 1. - rn_abs ) / 3._wp    !* surface equi-partition in R-G-B
          DO_2D_00_00
-            ze0(ji,jj,1) = rn_abs * qsr(ji,jj)
-            ze1(ji,jj,1) = zcoef  * qsr(ji,jj)
-            ze2(ji,jj,1) = zcoef  * qsr(ji,jj)
-            ze3(ji,jj,1) = zcoef  * qsr(ji,jj)
-            zea(ji,jj,1) =          qsr(ji,jj)
+            ze0(ji,jj) = rn_abs * qsr(ji,jj)
+            ze1(ji,jj) = zcoef  * qsr(ji,jj)
+            ze2(ji,jj) = zcoef  * qsr(ji,jj)
+            ze3(ji,jj) = zcoef  * qsr(ji,jj)
+            ! store the surface SW radiation; re-use the surface ztmp3d array 
+            ! since the surface attenuation coefficient is not used
+            ztmp3d(ji,jj,1) =       qsr(ji,jj)
          END_2D
          !
-         DO jk = 2, nksr+1                   !* interior equi-partition in R-G-B depending of vertical profile of Chl
-            DO_2D_00_00
-               zchl = MIN( 10. , MAX( 0.03, zchl3d(ji,jj,jk) ) )
-               irgb = NINT( 41 + 20.*LOG10(zchl) + 1.e-15 )
-               zekb(ji,jj) = rkrgb(1,irgb)
-               zekg(ji,jj) = rkrgb(2,irgb)
-               zekr(ji,jj) = rkrgb(3,irgb)
-            END_2D
-
-            DO_2D_00_00
-               zc0 = ze0(ji,jj,jk-1) * EXP( - e3t(ji,jj,jk-1,Kmm) * xsi0r       )
-               zc1 = ze1(ji,jj,jk-1) * EXP( - e3t(ji,jj,jk-1,Kmm) * zekb(ji,jj) )
-               zc2 = ze2(ji,jj,jk-1) * EXP( - e3t(ji,jj,jk-1,Kmm) * zekg(ji,jj) )
-               zc3 = ze3(ji,jj,jk-1) * EXP( - e3t(ji,jj,jk-1,Kmm) * zekr(ji,jj) )
-               ze0(ji,jj,jk) = zc0
-               ze1(ji,jj,jk) = zc1
-               ze2(ji,jj,jk) = zc2
-               ze3(ji,jj,jk) = zc3
-               zea(ji,jj,jk) = ( zc0 + zc1 + zc2 + zc3 ) * wmask(ji,jj,jk)
-            END_2D
-         END DO
+         !* interior equi-partition in R-G-B depending on vertical profile of Chl
+         DO_3D_00_00 ( 2, nksr + 1 )
+            ze3t = e3t(ji,jj,jk-1,Kmm)
+            irgb = NINT( ztmp3d(ji,jj,jk) )
+            zc0 = ze0(ji,jj) * EXP( - ze3t * xsi0r )
+            zc1 = ze1(ji,jj) * EXP( - ze3t * rkrgb(1,irgb) )
+            zc2 = ze2(ji,jj) * EXP( - ze3t * rkrgb(2,irgb) )
+            zc3 = ze3(ji,jj) * EXP( - ze3t * rkrgb(3,irgb) )
+            ze0(ji,jj) = zc0
+            ze1(ji,jj) = zc1
+            ze2(ji,jj) = zc2
+            ze3(ji,jj) = zc3
+            ztmp3d(ji,jj,jk) = ( zc0 + zc1 + zc2 + zc3 ) * wmask(ji,jj,jk)
+         END_3D
          !
          DO_3D_00_00( 1, nksr )
-            qsr_hc(ji,jj,jk) = r1_rho0_rcp * ( zea(ji,jj,jk) - zea(ji,jj,jk+1) )
+            qsr_hc(ji,jj,jk) = r1_rho0_rcp * ( ztmp3d(ji,jj,jk) - ztmp3d(ji,jj,jk+1) )
          END_3D
          !
-         DEALLOCATE( zekb , zekg , zekr , ze0 , ze1 , ze2 , ze3 , zea , zchl3d ) 
+         DEALLOCATE( ze0 , ze1 , ze2 , ze3 , ztmp3d ) 
          !
       CASE( np_2BD  )            !==  2-bands fluxes  ==!
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/USR/usrdef_hgr.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/USR/usrdef_hgr.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/USR/usrdef_hgr.F90	(revision 13229)
@@ -95,4 +95,5 @@
 #if defined key_agrif
       ! ! Upper left longitude and latitude from parent:
+      ! Laurent: Should be modify in case of an east-west cyclic parent grid
       IF (.NOT.Agrif_root()) THEN
          zlam0 = zlam1 + Agrif_irhox() * REAL(Agrif_Parent(Ni0glo) -2, wp) * ze1deg * zcos_alpha  &
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/USR/usrdef_nam.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/USR/usrdef_nam.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/USR/usrdef_nam.F90	(revision 13229)
@@ -73,6 +73,6 @@
 #if defined key_agrif
       IF( .NOT. Agrif_Root() ) THEN
-         kpi  = nbcellsx + 2 * ( nbghostcells + 1 )   ! Global Domain size: add nbghostcells + 1 "land" point on each side
-         kpj  = nbcellsy + 2 * ( nbghostcells + 1 )
+         kpi  = nbcellsx + 2 * ( nbghostcells_x   + 1 )   ! Global Domain size: add nbghostcells + 1 "land" point on each side
+         kpj  = nbcellsy + nbghostcells_y_s + nbghostcells_y_n + 2
       ENDIF
 #endif
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/nemogcm.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/nemogcm.F90	(revision 13229)
@@ -145,11 +145,7 @@
 #if defined key_agrif
       Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
-      CALL Agrif_Declare_Var_dom   ! AGRIF: set the meshes for DOM
-      CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA 
+      CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA
 # if defined key_top
       CALL Agrif_Declare_Var_top   !  "      "   "   "      "  TOP
-# endif
-# if defined key_si3
-      CALL Agrif_Declare_Var_ice   !  "      "   "   "      "  Sea ice
 # endif
 #endif
@@ -402,5 +398,7 @@
       ! Initialise time level indices
       Nbb = 1; Nnn = 2; Naa = 3; Nrhs = Naa
-
+#if defined key_agrif
+      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
+#endif 
       !                             !-------------------------------!
       !                             !  NEMO general initialization  !
@@ -417,5 +415,12 @@
       IF( lk_c1d       )   CALL     c1d_init        ! 1D column configuration
                            CALL     wad_init        ! Wetting and drying options
+
+#if defined key_agrif
+     CALL Agrif_Declare_Var_ini   !  "      "   "   "      "  DOM
+#endif
                            CALL     dom_init( Nbb, Nnn, Naa, "OPA") ! Domain
+
+
+
       IF( ln_crs       )   CALL     crs_init(      Nnn )       ! coarsened grid: domain initialization 
       IF( sn_cfctl%l_prtctl )   &
@@ -438,5 +443,5 @@
       ENDIF
       !
-      
+
                            CALL  istate_init( Nbb, Nnn, Naa )    ! ocean initial state (Dynamics and tracers)
 
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/par_kind.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/par_kind.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/par_kind.F90	(revision 13229)
@@ -31,5 +31,6 @@
    
    !                                                                !!** Integer **
-   INTEGER, PUBLIC, PARAMETER ::   lc = 256                          !: Lenght of Character strings
+   INTEGER, PUBLIC, PARAMETER ::   lc  = 256                          !: Lenght of Character strings
+   INTEGER, PUBLIC, PARAMETER ::   lca = 400                          !: Lenght of Character arrays
 
    !!----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/par_oce.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/par_oce.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/par_oce.F90	(revision 13229)
@@ -47,7 +47,10 @@
    ! global domain size for AGRIF     !!! * total AGRIF computational domain *
    INTEGER, PUBLIC            ::   nbug_in_agrif_conv_do_not_remove_or_modify = 1 - 1
-   INTEGER, PUBLIC, PARAMETER ::   nbghostcells = 3                                          !: number of ghost cells
-   INTEGER, PUBLIC            ::   nbcellsx   ! = jpiglo - 2 * (nbghostcells + 1 + nn_hls)   !: number of cells in i-direction
-   INTEGER, PUBLIC            ::   nbcellsy   ! = jpjglo - 2 * (nbghostcells + 1 + nn_hls)   !: number of cells in j-direction
+   INTEGER, PUBLIC, PARAMETER ::   nbghostcells = 3 !: number of ghost cells: default value
+   INTEGER, PUBLIC            ::   nbghostcells_x   !: number of ghost cells in i-direction
+   INTEGER, PUBLIC            ::   nbghostcells_y_s   !: number of ghost cells in j-direction at south
+   INTEGER, PUBLIC            ::   nbghostcells_y_n   !: number of ghost cells in j-direction at north                       !: number of ghost cells
+   INTEGER, PUBLIC            ::   nbcellsx   ! = jpiglo - 2 - 2*nbghostcells_x   !: number of cells in i-direction
+   INTEGER, PUBLIC            ::   nbcellsy   ! = jpjglo - 2 - 2*nbghostcells-y   !: number of cells in j-direction
 
    ! local domain size                !!! * local computational domain *
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/stpctl.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/stpctl.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/OCE/stpctl.F90	(revision 13229)
@@ -119,37 +119,27 @@
       !                                   !==            test of local extrema           ==!
       !                                   !==  done by all processes at every time step  ==!
-      !
-      ! define zmax default value. needed for land processors
-      IF( ll_colruns ) THEN    ! default value: must not be kept when calling mpp_max -> must be as small as possible
-         zmax(:) = -HUGE(1._wp)
-      ELSE                     ! default value: must not give true for any of the tests bellow (-> avoid manipulating HUGE...)
-         zmax(:) =  0._wp
-         zmax(3) = -1._wp      ! avoid salinity minimum at 0.
-      ENDIF
-      !
       llmsk(:,:,1) = ssmask(:,:) == 1._wp
-      IF( COUNT( llmsk(:,:,1) ) > 0 ) THEN   ! avoid huge values sent back for land processors...
-         IF( ll_wd ) THEN
-            zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max
+      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(:,:,:) = umask(:,:,:) == 1._wp
+      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) ), mask = llmsk )                     ! velocity max (zonal only)
+      llmsk(:,:,:) = tmask(:,:,:) == 1._wp
+      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(1) = MAXVAL( ABS( ssh(:,:,Kmm)           ), mask = llmsk(:,:,1) )   ! ssh max
-         ENDIF
-      ENDIF
-      zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ) )                                       ! velocity max (zonal only)
-      llmsk(:,:,:) = tmask(:,:,:) == 1._wp
-      IF( COUNT( llmsk(:,:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors...
-         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
-               IF( COUNT( llmsk(:,:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors...
-                  zmax(8) = MAXVAL(ABS( wi(:,:,:) ), mask = llmsk )                  ! implicit vertical vel. max
-               ENDIF
-            ENDIF
-         ENDIF
+            zmax(7:8) = 0._wp
+         ENDIF
+      ELSE
+         zmax(5:8) = 0._wp
       ENDIF
       zmax(9) = REAL( nstop, wp )                                              ! stop indicator
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAS/nemogcm.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAS/nemogcm.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/src/SAS/nemogcm.F90	(revision 13229)
@@ -93,11 +93,7 @@
 #if defined key_agrif
       Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
-      CALL Agrif_Declare_Var_dom   ! AGRIF: set the meshes for DOM
       CALL Agrif_Declare_Var       !  "      "   "   "      "  DYN/TRA 
 # if defined key_top
       CALL Agrif_Declare_Var_top   !  "      "   "   "      "  TOP
-# endif
-# if defined key_si3
-      CALL Agrif_Declare_Var_ice   !  "      "   "   "      "  Sea ice
 # endif
 #endif
@@ -348,4 +344,7 @@
       ! Initialise time level indices
       Nbb = 1; Nnn = 2; Naa = 3; Nrhs = Naa
+#if defined key_agrif
+      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices
+#endif 
 
       !                             !-------------------------------!
@@ -361,4 +360,7 @@
                            CALL phy_cst         ! Physical constants
                            CALL eos_init        ! Equation of seawater
+#if defined key_agrif
+     CALL Agrif_Declare_Var_ini   !  "      "   "   "      "  DOM
+#endif
                            CALL dom_init( Nbb, Nnn, Naa, 'SAS') ! Domain
       IF( sn_cfctl%l_prtctl )   &
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CANAL/MY_SRC/stpctl.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CANAL/MY_SRC/stpctl.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CANAL/MY_SRC/stpctl.F90	(revision 13229)
@@ -119,37 +119,27 @@
       !                                   !==            test of local extrema           ==!
       !                                   !==  done by all processes at every time step  ==!
-      !
-      ! define zmax default value. needed for land processors
-      IF( ll_colruns ) THEN    ! default value: must not be kept when calling mpp_max -> must be as small as possible
-         zmax(:) = -HUGE(1._wp)
-      ELSE                     ! default value: must not give true for any of the tests bellow (-> avoid manipulating HUGE...)
-         zmax(:) =  0._wp
-         zmax(3) = -1._wp      ! avoid salinity minimum at 0.
-      ENDIF
-      !
       llmsk(:,:,1) = ssmask(:,:) == 1._wp
-      IF( COUNT( llmsk(:,:,1) ) > 0 ) THEN   ! avoid huge values sent back for land processors...
-         IF( ll_wd ) THEN
-            zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max
+      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(:,:,:) = umask(:,:,:) == 1._wp
+      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) ), mask = llmsk )                     ! velocity max (zonal only)
+      llmsk(:,:,:) = tmask(:,:,:) == 1._wp
+      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(1) = MAXVAL( ABS( ssh(:,:,Kmm)           ), mask = llmsk(:,:,1) )   ! ssh max
-         ENDIF
-      ENDIF
-      zmax(2) = MAXVAL( ABS( uu(:,:,:,Kmm) ) )                                       ! velocity max (zonal only)
-      llmsk(:,:,:) = tmask(:,:,:) == 1._wp
-      IF( COUNT( llmsk(:,:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors...
-         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
-               IF( COUNT( llmsk(:,:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors...
-                  zmax(8) = MAXVAL(ABS( wi(:,:,:) ), mask = llmsk )                  ! implicit vertical vel. max
-               ENDIF
-            ENDIF
-         ENDIF
+            zmax(7:8) = 0._wp
+         ENDIF
+      ELSE
+         zmax(5:8) = 0._wp
       ENDIF
       zmax(9) = REAL( nstop, wp )                                              ! stop indicator
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/axis_def_nemo.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/axis_def_nemo.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/axis_def_nemo.xml	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/axis_def_nemo.xml
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/context_nemo.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/context_nemo.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/context_nemo.xml	(revision 13229)
@@ -0,0 +1,42 @@
+<!--
+ ============================================================================================== 
+    NEMO context
+============================================================================================== 
+-->
+<context id="nemo">
+    <!-- $id$ -->
+    <variable_definition>
+       <!-- Year/Month/Day of time origin for NetCDF files; defaults to 1800-01-01 -->
+       <variable id="ref_year"  type="int"> 1900 </variable>
+       <variable id="ref_month" type="int"> 01 </variable>
+       <variable id="ref_day"   type="int"> 01 </variable>
+       <variable id="rau0"      type="float" > 1026.0 </variable>
+       <variable id="cpocean"   type="float" > 3991.86795711963 </variable>
+       <variable id="convSpsu"  type="float" > 0.99530670233846  </variable>
+       <variable id="rhoic"     type="float" > 917.0 </variable>
+       <variable id="rhosn"     type="float" > 330.0 </variable>
+       <variable id="missval"   type="float" > 1.e20 </variable>
+    </variable_definition>
+
+<!-- Fields definition -->
+    <field_definition src="./field_def_nemo-oce.xml"/>    <!--  NEMO ocean dynamics     -->
+    <field_definition src="./field_def_nemo-ice.xml"/>    <!--  NEMO sea-ice model      -->
+    <field_definition src="./field_def_nemo-pisces.xml"/> <!--  NEMO ocean biology      -->
+
+<!-- Files definition -->
+    <file_definition src="./file_def_nemo-oce.xml"/>     <!--  NEMO ocean dynamics      -->
+    <file_definition src="./file_def_nemo-ice.xml"/>     <!--  NEMO sea-ice model       -->
+    <file_definition src="./file_def_nemo-pisces.xml"/>  <!--  NEMO ocean biology       -->
+
+
+<!-- Axis definition -->
+    <axis_definition src="./axis_def_nemo.xml"/>
+ 
+<!-- Domain definition -->
+    <domain_definition src="./domain_def_nemo.xml"/>
+
+<!-- Grids definition -->
+    <grid_definition   src="./grid_def_nemo.xml"/>
+  
+
+</context>
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/domain_def_nemo.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/domain_def_nemo.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/domain_def_nemo.xml	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/domain_def_nemo.xml
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-ice.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-ice.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-ice.xml	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/field_def_nemo-ice.xml
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-oce.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-oce.xml	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/field_def_nemo-oce.xml
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-pisces.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-pisces.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/field_def_nemo-pisces.xml	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/field_def_nemo-pisces.xml
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-ice.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-ice.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-ice.xml	(revision 13229)
@@ -0,0 +1,156 @@
+<?xml version="1.0"?>
+    <!-- $id$ -->
+    
+ <!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                      Define your own files for sea ice                                   =
+=                                         put the variables you want...                                    =
+============================================================================================================
+ -->
+    
+ <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+   
+   <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   	
+     <file id="file21" name_suffix="_icemod" description="ice variables" enabled=".true." >
+
+       <!-- ice mask -->
+       <field field_ref="icemask"          name="simsk"   />
+       <field field_ref="icemask05"        name="simsk05" />
+       <field field_ref="icemask15"        name="simsk15" />
+       
+       <!-- general -->
+       <field field_ref="snwvolu"          name="snvolu" />
+       <field field_ref="icethic"          name="sithic" />
+       <field field_ref="icevolu"          name="sivolu" />
+       <field field_ref="iceconc"          name="siconc" />
+       <field field_ref="icesalt"          name="sisali" />
+       <field field_ref="iceapnd"          name="siapnd" />
+       <field field_ref="icevpnd"          name="sivpnd" />
+       <field field_ref="sst_m"            name="sst_m"  />
+       <field field_ref="sss_m"            name="sss_m"  />
+       
+       <!-- heat -->
+       <field field_ref="icetemp"          name="sitemp" />
+       <field field_ref="snwtemp"          name="sntemp" />
+       <field field_ref="icettop"          name="sittop" />
+       <field field_ref="icetbot"          name="sitbot" />
+       <field field_ref="icetsni"          name="sitsni" />
+       
+       <!-- momentum -->
+       <field field_ref="uice"             name="sivelu"  />
+       <field field_ref="vice"             name="sivelv"  />
+       <field field_ref="icevel"           name="sivelo"  />
+       <field field_ref="utau_ai"          name="utau_ai" />
+       <field field_ref="vtau_ai"          name="vtau_ai" />
+       <field field_ref="utau_oi"          name="utau_oi" />
+       <field field_ref="vtau_oi"          name="vtau_oi" />
+       
+       <!-- rheology -->
+       <field field_ref="icediv"           name="sidive"  />
+       <field field_ref="iceshe"           name="sishea"  />
+       <field field_ref="icestr"           name="sistre"  />
+       <field field_ref="normstr"          name="normstr" />
+       <field field_ref="sheastr"          name="sheastr" />
+       <field field_ref="isig1"            name="isig1"   />
+       <field field_ref="isig2"            name="isig2"   />
+       <field field_ref="isig3"            name="isig3"   />
+       
+       <!-- heat fluxes -->
+       <field field_ref="qt_oce_ai"        name="qt_oce_ai"  />
+       <field field_ref="qt_atm_oi"        name="qt_atm_oi"  />
+       <field field_ref="qtr_ice_top"      name="qtr_ice_top"/>
+       <field field_ref="qtr_ice_bot"      name="qtr_ice_bot"/>
+       <field field_ref="qt_ice"           name="qt_ice"     />
+       <field field_ref="qsr_ice"          name="qsr_ice"    />
+       <field field_ref="qns_ice"          name="qns_ice"    />
+       <field field_ref="qemp_ice"         name="qemp_ice"   />
+       <field field_ref="albedo"           name="albedo"     />
+       
+       <field field_ref="hfxcndtop"        name="hfxcndtop"  />
+       <field field_ref="hfxcndbot"        name="hfxcndbot"  />
+       <field field_ref="hfxsensib"        name="hfxsensib"  />
+       
+       <!-- salt fluxes -->
+       <field field_ref="sfxice"           name="sfxice" />
+       
+       <!-- mass fluxes -->
+       <field field_ref="vfxice"           name="vfxice" />
+       <field field_ref="vfxsnw"           name="vfxsnw" />
+
+       <!-- categories -->
+       <field field_ref="icemask_cat"      name="simskcat"/>
+       <field field_ref="snwthic_cat"      name="snthicat"/>
+       <field field_ref="iceconc_cat"      name="siconcat"/>
+       <field field_ref="icethic_cat"      name="sithicat"/>
+       <field field_ref="icesalt_cat"      name="sisalcat"/>
+       <field field_ref="icetemp_cat"      name="sitemcat"/>
+       <field field_ref="snwtemp_cat"      name="sntemcat"/>
+       <field field_ref="icettop_cat"      name="sitopcat"/>
+
+     </file>
+     
+     <file id="file22" name_suffix="_SBC_scalar" description="scalar variables" enabled=".true." >
+       <!-- global contents -->
+       <field field_ref="ibgvol_tot"     name="ibgvol_tot"   />
+       <field field_ref="sbgvol_tot"     name="sbgvol_tot"   />
+       <field field_ref="ibgarea_tot"    name="ibgarea_tot"  />
+       <field field_ref="ibgsalt_tot"    name="ibgsalt_tot"  />
+       <field field_ref="ibgheat_tot"    name="ibgheat_tot"  />
+       <field field_ref="sbgheat_tot"    name="sbgheat_tot"  />
+       
+       <!-- global drifts (conservation checks) -->
+       <field field_ref="ibgvolume"      name="ibgvolume"    />
+       <field field_ref="ibgsaltco"      name="ibgsaltco"    />
+       <field field_ref="ibgheatco"      name="ibgheatco"    />
+       <field field_ref="ibgheatfx"      name="ibgheatfx"    />
+       
+       <!-- global forcings  -->
+       <field field_ref="ibgfrcvoltop"   name="ibgfrcvoltop" />
+       <field field_ref="ibgfrcvolbot"   name="ibgfrcvolbot" />
+       <field field_ref="ibgfrctemtop"   name="ibgfrctemtop" />
+       <field field_ref="ibgfrctembot"   name="ibgfrctembot" />
+       <field field_ref="ibgfrcsal"      name="ibgfrcsal"    />
+       <field field_ref="ibgfrchfxtop"   name="ibgfrchfxtop" />
+       <field field_ref="ibgfrchfxbot"   name="ibgfrchfxbot" />
+     </file>
+     
+   </file_group>
+   
+   <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+   <file_group id="1h"  output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+   <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+   <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+   <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+   <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->      
+
+   <file_group id="1m"  output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+
+     <!-- To compute transport through straits : need to read ice mask at ice iteration at freq_offset = 1mo - nn_fsbc
+      <file id="file23" name_suffix="_strait_ice" description="transport variables through straits" >
+          <field field_ref="strait_mifl"      name="simassacrossline"  freq_offset="1mo-4ts" />
+          <field field_ref="strait_msfl"      name="snmassacrossline"  freq_offset="1mo-4ts" />
+          <field field_ref="strait_arfl"      name="siareaacrossline"  freq_offset="1mo-4ts" />
+        </file>
+     -->
+
+    </file_group>
+
+   <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+   <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+   <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+   <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+   <file_group id="1y"  output_freq="1y"  output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+   <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+   <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+   <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+ 
+   <!-- To compute transport through straits : need to read ice mask at ice iteration at freq_offset = - nn_fsbc + 1
+   <file id="maskMFO" name="maskMFO" enabled="true" mode="read" output_freq="1mo" cyclic="true"  >
+      <field id="maskMFO_u_ice" operation="instant"  freq_offset="-3ts"  grid_ref="grid_U_4strait_ice" />
+      <field id="maskMFO_v_ice" operation="instant"  freq_offset="-3ts"  grid_ref="grid_V_4strait_ice" />
+   </file>
+
+     -->
+ </file_definition>
+ 
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-oce.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-oce.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-oce.xml	(revision 13229)
@@ -0,0 +1,173 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context               =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+    
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   
+        <file id="file11" name_suffix="_grid_T" description="ocean T grid variables" >
+          <field field_ref="e3t"      />
+          <field field_ref="toce"         name="thetao"                                                                      operation="instant" freq_op="5d" > @toce_e3t / @e3t </field>
+          <field field_ref="soce"         name="so"                                                                          operation="instant" freq_op="5d" > @soce_e3t / @e3t </field>
+          <field field_ref="sst"          name="tos"   />
+          <field field_ref="sss"          name="sos"   />
+          <field field_ref="ssh"          name="zos"   />
+          <field field_ref="sst"          name="tosstd"       long_name="sea surface temperature standard deviation"         operation="instant" freq_op="5d" > sqrt( @sst2 - @sst * @sst ) </field>
+          <field field_ref="ssh"          name="zosstd"       long_name="sea surface height above geoid standard deviation"  operation="instant" freq_op="5d" > sqrt( @ssh2 - @ssh * @ssh ) </field>
+          <field field_ref="sst"          name="sstdcy"       long_name="amplitude of sst diurnal cycle"                     operation="average" freq_op="1d" > @sstmax - @sstmin </field>
+          <field field_ref="mldkz5"   />
+          <field field_ref="mldr10_1" />
+          <field field_ref="mldr10_1"     name="mldr10_1dcy"  long_name="amplitude of mldr10_1 diurnal cycle"                operation="average" freq_op="1d" > @mldr10_1max - @mldr10_1min </field>
+          <field field_ref="sbt"      />
+          <field field_ref="heatc"        name="heatc" />
+          <field field_ref="saltc"        name="saltc" />
+
+	  <field field_ref="empmr"        name="wfo"      />
+	  <field field_ref="qsr_oce"      name="qsr_oce"  />
+	  <field field_ref="qns_oce"      name="qns_oce"  />
+	  <field field_ref="qt_oce"       name="qt_oce"   />
+	  <field field_ref="saltflx"      name="sfx"      />
+	  <field field_ref="taum"         name="taum"     />
+	  <field field_ref="wspd"         name="windsp"   />
+	  <field field_ref="precip"       name="precip"   />
+	  <!-- ice and snow -->
+	  <field field_ref="snowpre" />
+	</file>
+
+	<file id="file12" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="e3u" />
+	  <field field_ref="ssu"          name="uos"      />
+	  <field field_ref="uoce"         name="uo"       operation="instant" freq_op="5d" > @uoce_e3u / @e3u </field>
+	  <field field_ref="utau"         name="tauuo"    />
+          <field field_ref="uocetr_eff"   name="uocetr_eff"  />
+          <!-- available with diaar5 -->
+	  <field field_ref="u_masstr"     name="vozomatr" />
+	  <field field_ref="u_heattr"     name="sozohetr" />
+	  <field field_ref="u_salttr"     name="sozosatr" />
+	</file>
+	
+	<file id="file13" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="e3v" />
+	  <field field_ref="ssv"          name="vos"      />
+	  <field field_ref="voce"         name="vo"       operation="instant" freq_op="5d" > @voce_e3v / @e3v </field>
+	  <field field_ref="vtau"         name="tauvo"    />
+          <field field_ref="vocetr_eff"   name="vocetr_eff"  />
+          <!-- available with diaar5 -->
+	  <field field_ref="v_masstr"     name="vomematr" />
+	  <field field_ref="v_heattr"     name="somehetr" />
+          <field field_ref="v_salttr"     name="somesatr" />
+	</file>
+	
+	<file id="file14" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="e3w" />
+	  <field field_ref="woce"         name="wo"       />
+	  <field field_ref="avt"          name="difvho"   />
+	  <field field_ref="w_masstr"     name="vovematr" />
+         <!-- variables available with ln_zdfiwm =T -->
+          <field field_ref="av_wave"      name="av_wave"    />
+          <field field_ref="bn2"          name="bn2"        />
+          <field field_ref="bflx_iwm"     name="bflx_iwm"   />
+          <field field_ref="pcmap_iwm"    name="pcmap_iwm"  />
+          <field field_ref="emix_iwm"     name="emix_iwm"   />
+          <field field_ref="av_ratio"     name="av_ratio"   />
+	</file>
+
+        <file id="file15" name_suffix="_scalar" description="scalar variables" >
+          <!-- global drifts (conservation checks) -->
+          <field field_ref="bgtemper"     name="bgtemper"    />
+          <field field_ref="bgsaline"     name="bgsaline"    />
+          <field field_ref="bgheatco"     name="bgheatco"    />
+          <field field_ref="bgheatfx"     name="bgheatfx"    />
+          <field field_ref="bgsaltco"     name="bgsaltco"    />
+          <field field_ref="bgvolssh"     name="bgvolssh"    />
+          <field field_ref="bgvole3t"     name="bgvole3t"    />
+
+          <!-- global surface forcings  -->
+          <field field_ref="bgfrcvol"     name="bgfrcvol"    />
+          <field field_ref="bgfrctem"     name="bgfrctem"    />
+          <field field_ref="bgfrchfx"     name="bgfrchfx"    />
+	  <field field_ref="bgfrcsal"     name="bgfrcsal"    />
+
+	  <field field_ref="masstot"      name="masso"  />
+          <field field_ref="voltot"       name="volo"  />
+          <field field_ref="sshthster"    name="zostoga"  />
+          <field field_ref="temptot"      name="bigthetaoga"  />
+          <field field_ref="saltot"       name="soga"  />
+          <field field_ref="ssttot"       name="tosga"  />
+        </file>
+
+      </file_group> 
+
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+
+        <file id="file16" name_suffix="_diaptr2D" description="zonal mean variables" >
+          <field field_ref="sophtove"    name="htovovrt"      grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopstove"    name="sltovovrt"     grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sophtgyre"   name="htovgyre"      grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopstgyre"   name="sltogyre"      grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sophtbtr"    name="htbtr"         grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopstbtr"    name="sltbtr"        grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sophtadv"    name="htadv"         grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopstadv"    name="sltadv"        grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sophtldf"    name="htldf"         grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopstldf"    name="sltldf"        grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sophtvtr"    name="hfbasin"       grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopstvtr"    name="sltbasin"      grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sophteiv"    name="hfbasinpmadv"  grid_ref="grid_ptr_T_2D"  />
+          <field field_ref="sopsteiv"    name="sltbasinpmadv" grid_ref="grid_ptr_T_2D"  />
+        </file>
+
+
+         <file id="file17" name_suffix="_diaptr3D" description="zonal mean variables" >
+          <field field_ref="zomsf"       name="msftyz"        grid_ref="grid_ptr_W_3D"  />
+          <field field_ref="zotem"       name="znltem"        grid_ref="grid_ptr_T_3D"  />
+          <field field_ref="zosal"       name="znlsal"        grid_ref="grid_ptr_T_3D"  />
+          <field field_ref="zosrf"       name="znlsrf"        grid_ref="grid_ptr_T_3D"  />
+        </file>
+
+      <!--  
+         <file id="file18" name_suffix="_strait_oce" description="transport variables through straits" >
+           <field field_ref="masstr_strait"        name="mfo"               />
+         </file>	   
+      -->
+
+      </file_group>
+
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."> <!-- real yearly files -->
+      </file_group>
+
+      <!--  To compute transport through straits : need to read mask file ( every month is the best otherwise costly )
+
+      <file id="maskMFO"  name="maskMFO" enabled="true" mode="read" output_freq="1mo" cyclic="true"  >
+        <field id="maskMFO_u" operation="instant" freq_offset="1mo" grid_ref="grid_U_4strait" />
+        <field id="maskMFO_v" operation="instant" freq_offset="1mo" grid_ref="grid_V_4strait" />
+      </file>
+
+    -->
+
+      
+      <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+      <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+      <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+      <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+
+
+
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-pisces.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-pisces.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/file_def_nemo-pisces.xml	(revision 13229)
@@ -0,0 +1,128 @@
+<?xml version="1.0"?>
+
+<!--
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own filesfor ocean dynamics context               =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+   
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="1mo" min_digits="4">
+    
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   
+
+        <file id="file31" name_suffix="_bioscalar" description="pisces sms variables" >
+          <field field_ref="tdenit"   name="tdenit"    unit="TgN/yr" operation="instant" > tdenit * 14. * 86400. * 365. / 1e12 </field>
+          <field field_ref="tnfix"    name="tnfix"     unit="TgN/yr" operation="instant" > tnfix * 14. * 86400. * 365. / 1e12 </field>
+          <field field_ref="tcflx"    name="tcflx"     unit="PgC/yr" operation="instant" > tcflx * -1. * 12. * 86400. * 365. / 1e15 </field>
+          <field field_ref="tcflxcum" name="tcflxcum"  unit="PgC"    operation="instant" > tcflxcum * -1. * 12. / 1e15 </field>
+          <field field_ref="tcexp"    name="tcexp"     unit="PgC/yr" operation="instant" > tcexp * 12. * 86400. * 365. / 1e15 </field>
+          <field field_ref="tintpp"   name="tintpp"    unit="PgC/yr" operation="instant" > tintpp * 12. * 86400. * 365. / 1e15 </field>
+          <field field_ref="pno3tot"  name="pno3tot"   unit="umolN"  > pno3tot * 16. / 122. * 1e6 </field>
+          <field field_ref="ppo4tot"  name="ppo4tot"   unit="umolP"  > ppo4tot * 1. / 122. * 1e6 </field>
+          <field field_ref="psiltot"  name="psiltot"   unit="umolC"  > psiltot * 1e6  </field>
+          <field field_ref="palktot"  name="palktot"   unit="umolC"  > palktot * 1e6  </field>
+          <field field_ref="pfertot"  name="pfertot"   unit="nmolFe" > pfertot * 1e9  </field>
+        </file>
+
+      </file_group> 
+
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+
+        <file id="file32" name_suffix="_ptrc_T" description="pisces sms variables" >
+          <field field_ref="DIC"      />
+          <field field_ref="Alkalini" />
+          <field field_ref="O2"       />
+          <field field_ref="PO4"      />
+          <field field_ref="Si"       />
+          <field field_ref="Fer"      />
+          <field field_ref="NCHL"     />
+          <field field_ref="DCHL"     />
+          <field field_ref="NO3"      />
+        </file>
+
+        <file id="file33" name_suffix="_diad_T" description="additional pisces diagnostics" >
+          <field field_ref="Cflx"     />
+          <field field_ref="Dpco2"    />
+        </file>
+
+      </file_group>
+
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."> <!-- real yearly files -->
+
+        <file id="file34" name_suffix="_ptrc_T" description="pisces sms variables" >
+          <field field_ref="DIC"      />
+          <field field_ref="Alkalini" />
+          <field field_ref="O2"       />
+          <field field_ref="CaCO3"    />
+          <field field_ref="PO4"      />
+          <field field_ref="POC"      />
+          <field field_ref="Si"       />
+          <field field_ref="PHY"      />
+          <field field_ref="ZOO"      />
+          <field field_ref="DOC"      />
+          <field field_ref="PHY2"     />
+          <field field_ref="ZOO2"     />
+          <field field_ref="DSi"      />
+          <field field_ref="Fer"      />
+          <field field_ref="BFe"      />
+          <field field_ref="GOC"      />
+          <field field_ref="SFe"      />
+          <field field_ref="DFe"      />
+          <field field_ref="GSi"      />
+          <field field_ref="NFe"      />
+          <field field_ref="NCHL"     />
+          <field field_ref="DCHL"     />
+          <field field_ref="NO3"      />
+          <field field_ref="NH4"      />
+        </file>
+
+        <file id="file35" name_suffix="_diad_T" description="additional pisces diagnostics" >
+          <field field_ref="PH"       />
+          <field field_ref="PAR"      />
+          <field field_ref="PPPHYN"    />
+          <field field_ref="PPPHYD"   />
+          <field field_ref="PPPHYP"   />
+          <field field_ref="PPNEWN"   />
+          <field field_ref="PPNEWD"   />
+          <field field_ref="PPNEWP"   />
+          <field field_ref="PBSi"     />
+          <field field_ref="PFeN"     />
+          <field field_ref="PFeD"     />
+          <field field_ref="PCAL"     />
+          <field field_ref="DCAL"     />
+          <field field_ref="GRAZ1"    />
+          <field field_ref="GRAZ2"    />
+          <field field_ref="EPC100"   />
+          <field field_ref="EPFE100"  />
+          <field field_ref="EPSI100"  />
+          <field field_ref="EPCAL100" />
+          <field field_ref="Cflx"     />
+          <field field_ref="Dpco2"    />
+          <field field_ref="Heup"     />
+          <field field_ref="Nfix"     />
+        </file>
+     </file_group>
+	
+	
+      
+      <file_group id="1ts" output_freq="1ts" output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+      <file_group id="2h"  output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h"  output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h"  output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h"  output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->     
+      <file_group id="2m"  output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m"  output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m"  output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m"  output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+      <file_group id="2y"  output_freq="2y"  output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y"  output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+
+
+
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/gen_report.sh
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/gen_report.sh	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/gen_report.sh	(revision 13229)
@@ -0,0 +1,95 @@
+#!/bin/bash
+#set -vx
+# ncmax $var_nm $fl_nm : What is maximum of variable?
+function ncmax { ncap2 -O -C -v -s "foo=${1}.max();print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; }
+# ncmin $var_nm $fl_nm : What is minimum of variable?
+function ncmin { ncap2 -O -C -v -s "foo=${1}.min();print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; }
+# ncmdn $var_nm $fl_nm : What is median of variable?
+function ncmdn { ncap2 -O -C -v -s "foo=gsl_stats_median_from_sorted_data(${1}.sort());print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; }
+
+##
+## simple report generator for the test case
+##
+
+##
+## Variables which may need to be adapted to your experiment:
+##
+#  RUNDIR = directory where the test case is executed: contains all outputs
+RUNDIR=/gpfswork/rech/omr/romr001/OUT/CPLTESTCASE/2020-03-31120816
+#  NB_NEMO_IT = expected total number of NEMO iterations
+NB_NEMO_IT=160
+#  NB_OASIS_OUTFILES = number of debug.root.0* OASIS output files
+NB_OASIS_OUTFILES=2
+##
+## END of variables to be checked - Nothing need to be changed below
+##
+# check if directory is here
+  if [ ! -d $RUNDIR ]; then
+    printf "%-27s %s %s\n" $RUNDIR  "directory does not exist. Check RUNDIR variable in script. Stop" 
+    return
+  fi
+
+cd $RUNDIR
+
+echo " "
+echo "Check results of test case in directory: " `pwd`
+echo " "
+##
+## Check if OASIS execution has been successful
+##
+echo "      OASIS successful (true if OASIS outputs in debug.root.0? includes SUCCESSFUL RUN)  : "
+count=0
+for file in debug.root.0*
+do
+  echo $file ; grep "SUCCESSFUL RUN" $file
+  count=`expr $count + 1`
+done
+echo "OASIS success checked on $count files"
+[ $count = $NB_OASIS_OUTFILES ] && echo true || echo false
+##
+## Check if NEMO execution has been sucessful
+##
+echo " "
+echo "      NEMO execution is successful if the run.stat file contains one line for each of NB_NEMO_IT iterations, indicating they have indeed been computed"
+ if [ ! -f ./run.stat ]; then
+   echo " the run.stat file does not exist: NEMO did not end its first time step"
+   echo " NEMO UNSUCESSFUL. Stop"
+   return
+ fi
+echo "From run.stat NEMO output file, NEMO has executed the 160 time steps:"
+nemo_iterations=`wc -l ./run.stat | awk {'print $1'} `; [ $nemo_iterations = $NB_NEMO_IT ] && echo true || echo false
+
+##
+## Check mean value of sst field seen by toyatm
+##
+ if [ ! -f ./ATSSTSST_toyatm_01.nc ]; then
+   echo " the ATSSTSST_toyatm_01.nc file does not exist: the test is not successful"
+   echo " Test case UNSUCESSFUL. Stop"
+   return
+ fi
+echo " "
+echo "Examining ATSSTSST variable sea surface temperature as seen by toyatm, unit is degree Kelvin (min. should be around 271., max. around 302., median around 280.)" 
+ASSTmin=`ncmin ATSSTSST ATSSTSST_toyatm_01.nc`
+ASSTmax=`ncmax ATSSTSST ATSSTSST_toyatm_01.nc` 
+ASSTmed=`ncmdn  ATSSTSST ATSSTSST_toyatm_01.nc`
+echo "Minimum value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmin
+echo "Maximum value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmax
+echo "Median value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = "  $ASSTmed
+MINMAX=0
+if [ ${ASSTmin%%.*} -lt 270 -o ${ASSTmax%%.*} -gt 310 ]; then
+echo " Min. or max. values of ATSSTSST do not look reasonable. Check the test again "
+MINMAX=1
+fi
+##
+## Summary
+##
+echo " "  
+if [ $count = $NB_OASIS_OUTFILES ] && [ $nemo_iterations = $NB_NEMO_IT ] && [ $MINMAX = 0 ] 
+then
+  echo " The run looks very succesful!"
+  echo " Have a look to the ASTSSTSST.nc file (using ncview for example): sea surface temperatures as seen by the toyatm and compare it to the reference file (CPL/ref_ATSSTSST_last_time_step.jpg) "
+  echo " Units are in degrees Kelvin and it will confirm the test is successful"
+  echo " "
+else
+  echo "The test case is unsuccessful. Check all inputs and outputs"
+fi
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/grid_def_nemo.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/grid_def_nemo.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/grid_def_nemo.xml	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/grid_def_nemo.xml
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/iodef.xml
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/iodef.xml	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/iodef.xml	(revision 13229)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<simulation>
+
+<!-- ============================================================================================ -->
+<!-- XIOS context                                                                                 -->
+<!-- ============================================================================================ -->
+
+  <context id="xios" >
+
+      <variable_definition>
+
+          <variable id="info_level"                type="int">10</variable>
+          <variable id="using_server"              type="bool">false</variable>
+          <variable id="using_oasis"               type="bool">true</variable>
+          <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+
+      </variable_definition>
+  </context>
+
+<!-- ============================================================================================ -->
+<!-- NEMO  CONTEXT add and suppress the components you need                                       -->
+<!-- ============================================================================================ -->
+
+  <context id="nemo" src="./context_nemo.xml"/>       <!--  NEMO       -->
+
+</simulation>
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_cfg	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_cfg	(revision 13229)
@@ -0,0 +1,486 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OCE  Configuration namelist : overwrite default values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!!             ORCA2 - ICE - PISCES configuration                     !!
+!!======================================================================
+!!              ***  Domain & Run management namelists  ***           !!
+!!                                                                    !!
+!!   namrun       parameters of the run
+!!   namdom       space and time domain
+!!   namcfg       parameters of the configuration                       (default: user defined GYRE)
+!!   namwad       Wetting and drying                                    (default: OFF)
+!!   namtsd       data: temperature & salinity                          (default: OFF)
+!!   namcrs       coarsened grid (for outputs and/or TOP)               (ln_crs =T)
+!!   namc1d       1D configuration options                              ("key_c1d")
+!!   namc1d_dyndmp 1D newtonian damping applied on currents             ("key_c1d")
+!!   namc1d_uvd   1D data (currents)                                    ("key_c1d")
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  "ORCA2"  !  experience name
+   nn_it000    =       1   !  first time step
+   nn_itend    =     160   !  last  time step (std 5475)
+   nn_istate   =       0   !  output the initial state (1) or not (0)
+/
+!-----------------------------------------------------------------------
+&namdom        !   time and space domain
+!-----------------------------------------------------------------------
+   rn_Dt       = 5400.     !  time step for the dynamics and tracer
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration                      (default: use namusr_def in namelist_cfg)
+!-----------------------------------------------------------------------
+   ln_read_cfg = .true.    !  (=T) read the domain configuration file
+      cn_domcfg = "ORCA_R2_zps_domcfg"    ! domain configuration filename
+      !
+      ln_closea    = .false.    !  F => suppress closed seas (defined by closea_mask field) 
+      !                         !       from the bathymetry at runtime.
+/
+!-----------------------------------------------------------------------
+&namtsd        !    Temperature & Salinity Data  (init/dmp)             (default: OFF)
+!-----------------------------------------------------------------------
+   !                       ! =T  read T-S fields for:
+   ln_tsd_init = .true.          !  ocean initialisation
+   ln_tsd_dmp  = .true.          !  T-S restoring   (see namtra_dmp)
+
+   cn_dir = './'     !  root directory for the T-S data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   sn_tem = 'data_1m_potential_temperature_nomask',     -1.     ,'votemper',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+   sn_sal = 'data_1m_salinity_nomask'             ,     -1.     ,'vosaline',   .true.    , .true. , 'yearly'  ,    ''    ,    ''    ,    ''
+/
+!!======================================================================
+!!            ***  Surface Boundary Condition namelists  ***          !!
+!!                                                                    !!
+!!   namsbc          surface boundary condition manager                 (default: NO selection)
+!!   namsbc_flx      flux               formulation                     (ln_flx     =T)
+!!   namsbc_blk      Bulk formulae formulation                          (ln_blk     =T)
+!!   namsbc_cpl      CouPLed            formulation                     ("key_oasis3" )
+!!   namsbc_sas      Stand-Alone Surface module                         (SAS_SRC  only)
+!!   namsbc_iif      Ice-IF: use observed ice cover                     (nn_ice = 1   )
+!!   namtra_qsr      penetrative solar radiation                        (ln_traqsr  =T)
+!!   namsbc_ssr      sea surface restoring term (for T and/or S)        (ln_ssr     =T)
+!!   namsbc_rnf      river runoffs                                      (ln_rnf     =T)
+!!   namsbc_apr      Atmospheric Pressure                               (ln_apr_dyn =T)
+!!   namsbc_isf      ice shelf melting/freezing                         (ln_isfcav  =T : read (ln_read_cfg=T) or set or usr_def_zgr )
+!!   namsbc_iscpl    coupling option between land ice model and ocean   (ln_isfcav  =T)
+!!   namsbc_wave     external fields from wave model                    (ln_wave    =T)
+!!   namberg         iceberg floats                                     (ln_icebergs=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition manager                   (default: NO selection)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of SBC module call
+                           !     (also = the frequency of sea-ice & iceberg model call)
+                     ! Type of air-sea fluxes 
+   ln_cpl      = .true.     !  atmosphere coupled   formulation          ( requires key_oasis3 )
+                     ! Sea-ice :
+   nn_ice      = 2         !  =2 or 3 automatically for SI3 or CICE    ("key_si3" or "key_cice")
+                           !          except in AGRIF zoom where it has to be specified
+                     ! Misc. options of sbc : 
+   ln_traqsr   = .true.    !  Light penetration in the ocean            (T => fill namtra_qsr)
+   ln_ssr      = .true.    !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   ln_rnf      = .true.    !  runoffs                                   (T => fill namsbc_rnf)
+   nn_fwb      = 2         !  FreshWater Budget: 
+   !                       !    =2 annual global mean of e-p-r set to zero
+   ln_wave     = .false.   !  Activate coupling with wave  (T => fill namsbc_wave)
+   ln_cdgw     = .false.   !  Neutral drag coefficient read from wave model (T => ln_wave=.true. & fill namsbc_wave)
+   ln_sdw      = .false.   !  Read 2D Surf Stokes Drift & Computation of 3D stokes drift (T => ln_wave=.true. & fill namsbc_wave) 
+   nn_sdrift   =  0        !  Parameterization for the calculation of 3D-Stokes drift from the surface Stokes drift
+      !                    !   = 0 Breivik 2015 parameterization: v_z=v_0*[exp(2*k*z)/(1-8*k*z)]
+      !                    !   = 1 Phillips:                      v_z=v_o*[exp(2*k*z)-beta*sqrt(-2*k*pi*z)*erfc(sqrt(-2*k*z))]
+      !                    !   = 2 Phillips as (1) but using the wave frequency from a wave model
+   ln_tauwoc   = .false.   !  Activate ocean stress modified by external wave induced stress (T => ln_wave=.true. & fill namsbc_wave)
+   ln_tauw     = .false.   !  Activate ocean stress components from wave model
+   ln_stcor    = .false.   !  Activate Stokes Coriolis term (T => ln_wave=.true. & ln_sdw=.true. & fill namsbc_wave)
+/
+!-----------------------------------------------------------------------
+&namsbc_blk    !   namsbc_blk  generic Bulk formula                     (ln_blk =T)
+!-----------------------------------------------------------------------
+   !                    !  bulk algorithm :
+   ln_NCAR    = .true.     ! "NCAR"      algorithm   (Large and Yeager 2008)
+
+   cn_dir = './'  !  root directory for the bulk data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!______________________________________!__________!_______________!
+   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ !          weights filename            ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                                      ! pairing  !    filename   !
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,    6.        , 'U_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,    6.        , 'V_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bicubic_noc.nc'  , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'SWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,   24.        , 'LWDN_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,    6.        , 'T_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,    6.        , 'Q_10_MOD',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'PRC_MOD1',   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',   -1.        , 'SNOW'    ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+   sn_slp      = 'slp.15JUNE2009_fill'        ,    6.        , 'SLP'     ,   .false.   , .true. , 'yearly'  , 'weights_core_orca2_bilinear_noc.nc' , ''       , ''
+/
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
+!-----------------------------------------------------------------------
+   nn_cplmodel   =     1   !  Maximum number of models to/from which NEMO is potentially sending/receiving data
+   ln_usecplmask = .false. !  use a coupling mask file to merge data received from several models
+   !                       !   -> file cplmask.nc with the float variable called cplmask (jpi,jpj,nn_cplmodel)
+   nn_cats_cpl   =     5   !  Number of sea ice categories over which coupling is to be carried out (if not 1)
+
+   !_____________!__________________________!____________!_____________!______________________!________!
+   !             !        description       !  multiple  !    vector   !       vector         ! vector !
+   !             !                          ! categories !  reference  !     orientation      ! grids  !
+!***   send    ***
+!!   sn_snd_temp   =   'weighted oce and ice' ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_temp   =   'mixed oce-ice'        ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_ttilyr =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_alb    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_thick  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_ifrac  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_crt    =   'none'                 ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+   sn_snd_co2    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_cond   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_mpnd   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_sstfrz =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_crtw   =   'none'                 ,    'no'    ,     ''      ,         ''           , 'U,V'
+   sn_snd_wlev   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_snd_thick1 =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+!***  receive  ***
+   sn_rcv_w10m   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_taumod =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_tau    =   'oce only'             ,    'no'    , 'spherical' , 'eastward-northward' ,  'T'
+   sn_rcv_dqnsdt =   'coupled'              ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_qsr    =   'conservative'         ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_qns    =   'conservative'         ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_emp    =   'conservative'         ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_rnf    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_cal    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_icb    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_isf    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_iceflx =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_co2    =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_hsig   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_phioc  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_sdrfx  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_sdrfy  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_wper   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_wnum   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_wfreq  =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_tauwoc =   'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_tauw   =   'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_wdrag  =   'none'                 ,    'no'    ,     ''      ,         ''          ,   ''
+   sn_rcv_ts_ice =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+   sn_rcv_mslp   =   'none'                 ,    'no'    ,     ''      ,         ''           ,   ''
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation                          (ln_traqsr =T)
+!-----------------------------------------------------------------------
+   !                       ! type of penetration                        (default: NO selection)
+   ln_qsr_rgb  = .true.       !  RGB light penetration (Red-Green-Blue)
+   !
+   nn_chldta   =      1       !  RGB : Chl data (=1) or cst value (=0)
+
+   cn_dir = './'  !  root directory for the chlorophyl data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   sn_chl      ='chlorophyll'            ,        -1.        , 'CHLA'    ,   .true.    , .true. , 'yearly'  , ''               , ''       , ''
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring   (ln_ssr =T)
+!-----------------------------------------------------------------------
+   nn_sssr     =     2     !  add a damping term to the surface freshwater flux
+      rn_deds     =  -166.67  !  magnitude of the damping on salinity   [mm/day]
+      ln_sssr_bnd =  .true.   !  flag to bound erp term (associated with nn_sssr=2)
+      rn_sssr_bnd =   4.e0    !  ABS(Max/Min) value of the damping erp term [mm/day]
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs                                              (ln_rnf =T)
+!-----------------------------------------------------------------------
+   ln_rnf_mouth = .true.    !  specific treatment at rivers mouths
+      rn_hrnf     =  15.e0    !  depth over which enhanced vertical mixing is used    (ln_rnf_mouth=T)
+      rn_avt_rnf  =   1.e-3   !  value of the additional vertical mixing coef. [m2/s] (ln_rnf_mouth=T)
+   rn_rfact    =   1.e0    !  multiplicative factor for runoff
+
+   cn_dir = './'  !  root directory for the location of the runoff files
+   !___________!_____________!___________________!___________!_____________!_________!___________!__________!__________!_______________!
+   !           !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+   !           !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_rnf      = 'runoff_core_monthly',    -1.   , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'runoff_core_monthly',     0.   , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+   sn_s_rnf    = 'runoffs'            ,    24.   , 'rosaline',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_t_rnf    = 'runoffs'            ,    24.   , 'rotemper',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_dep_rnf  = 'runoffs'            ,     0.   , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''       , ''
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model                        (ln_wave=T)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters                                   (default: OFF)
+!-----------------------------------------------------------------------
+   ln_icebergs = .true.    ! activate iceberg floats (force =F with "key_agrif")
+
+   cn_dir = './'  !  root directory for the location of drag coefficient files
+   !______!___________!___________________!______________!______________!_________!___________!__________!__________!_______________!
+   !      ! file name ! frequency (hours) !   variable   ! time interp. !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+   !      !           !  (if <0  months)  !     name     !   (logical)  !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_icb =  'calving',       -1.         , 'calving'    ,   .true.     , .true.  , 'yearly'  , ''       , ''       , ''
+/
+!!======================================================================
+!!               ***  Lateral boundary condition  ***                 !!
+!!                                                                    !!
+!!   namlbc        lateral momentum boundary condition                  (default: NO selection)
+!!   namagrif      agrif nested grid   (read by child model only)       ("key_agrif")
+!!   nam_tide      Tidal forcing                                        (default: OFF)
+!!   nambdy        Unstructured open boundaries                         (default: OFF)
+!!   nambdy_dta    Unstructured open boundaries - external data         (see  nambdy)
+!!   nambdy_tide   tidal forcing at open boundaries                     (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition                  (default: NO selection)
+!-----------------------------------------------------------------------
+   rn_shlat    =    2.     !  no slip
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+   ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
+   rn_sponge_tra = 2880.   !  coefficient for tracer   sponge layer [m2/s]
+   rn_sponge_dyn = 2880.   !  coefficient for dynamics sponge layer [m2/s]
+   ln_chk_bathy  = .false. !  =T  check the parent bathymetry
+/
+!!======================================================================
+!!                ***  Top/Bottom boundary condition  ***             !!
+!!                                                                    !!
+!!   namdrg        top/bottom drag coefficient                          (default: NO selection)
+!!   namdrg_top    top    friction                                      (ln_OFF=F & ln_isfcav=T)
+!!   namdrg_bot    bottom friction                                      (ln_OFF=F)
+!!   nambbc        bottom temperature boundary condition                (default: OFF)
+!!   nambbl        bottom boundary layer scheme                         (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdrg        !   top/bottom drag coefficient                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_lin = .true.         !     linear  drag: Cd = Cd0 Uc0
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition                (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbc   = .true.    !  Apply a geothermal heating at the ocean bottom
+      nn_geoflx   =    2      !  geothermal heat flux: = 2 read variable flux [mW/m2]
+
+   cn_dir = './'  !  root directory for the geothermal data location
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   sn_qgh      ='geothermal_heating.nc'  ,       -12.        , 'heatflow',   .false.   , .true. , 'yearly'  ,   ''             ,   ''     ,   ''
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_trabbl   = .true.    !  Bottom Boundary Layer parameterisation flag
+      nn_bbl_ldf  =  1        !  diffusive bbl (=1)   or not (=0)
+      nn_bbl_adv  =  0        !  advective bbl (=1/2) or not (=0)
+      rn_ahtbbl   =  1000.    !  lateral mixing coefficient in the bbl  [m2/s]
+      rn_gambbl   =  10.      !  advective bbl coefficient                 [s]
+/
+!!======================================================================
+!!                        Tracer (T-S) namelists                      !!
+!!                                                                    !!
+!!   nameos        equation of state                                    (default: NO selection)
+!!   namtra_adv    advection scheme                                     (default: NO selection)
+!!   namtra_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namtra_mle    mixed layer eddy param. (Fox-Kemper param.)          (default: OFF)
+!!   namtra_eiv    eddy induced velocity param.                         (default: OFF)
+!!   namtra_dmp    T & S newtonian damping                              (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nameos        !   ocean Equation Of Seawater                           (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_eos80    = .true.          !  = Use EOS80
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traadv_fct = .true.     !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_traldf_lap   = .true.    !    laplacian operator
+   ln_traldf_iso   = .true.    !  iso-neutral (Standard operator)
+   ln_traldf_msc   = .true.    !  Method of Stabilizing Correction      (both operators)
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+      !                             !   = 20     aht = 1/2  Ud. max(e1,e2)
+      rn_Ud        = 0.018          !  lateral diffusive velocity [m/s] (nn_aht_ijk_t= 0, 10, 20, 30)
+      rn_Ld        = 200.e+3        !  lateral diffusive length   [m]   (nn_aht_ijk_t= 0, 10)
+/
+!-----------------------------------------------------------------------
+&namtra_mle    !   mixed layer eddy parametrisation (Fox-Kemper)        (default: OFF)
+!-----------------------------------------------------------------------
+   ln_mle      = .true.   ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+/
+!-----------------------------------------------------------------------
+&namtra_eiv    !   eddy induced velocity param.                         (default: OFF)
+!-----------------------------------------------------------------------
+   ln_ldfeiv   = .true.    ! use eddy induced velocity parameterization
+      !                        !  Coefficients:
+      nn_aei_ijk_t  = 21          ! space/time variation of the eiv coeficient
+      !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+      !                           !  time invariant coefficients:  aei0 = 1/2  Ue*Le 
+      rn_Ue        = 0.03              !  lateral diffusive velocity [m/s] (nn_aht_ijk_t= 0, 10, 20, 30)
+      rn_Le        = 200.e+3           !  lateral diffusive length   [m]   (nn_aht_ijk_t= 0, 10)
+      !
+      ln_ldfeiv_dia =.true.   ! diagnose eiv stream function and velocities
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping                      (default: OFF)
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .true.   !  add a damping term (using resto.nc coef.)
+      nn_zdmp  =    0         !  vertical shape =0    damping throughout the water column
+/
+!!======================================================================
+!!                      ***  Dynamics namelists  ***                  !!
+!!                                                                    !!
+!!   nam_vvl       vertical coordinate options                          (default: z-star)
+!!   namdyn_adv    formulation of the momentum advection                (default: NO selection)
+!!   namdyn_vor    advection scheme                                     (default: NO selection)
+!!   namdyn_hpg    hydrostatic pressure gradient                        (default: NO selection)
+!!   namdyn_spg    surface pressure gradient                            (default: NO selection)
+!!   namdyn_ldf    lateral diffusion scheme                             (default: NO selection)
+!!   namdta_dyn    offline TOP: dynamics read in files                  (OFF_SRC only)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form - 2nd centered scheme
+     nn_dynkeg     = 0        ! grad(KE) scheme: =0   C2  ;  =1   Hollingsworth correction
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   Vorticity / Coriolis scheme                          (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 0          ! =0   e3f = mean masked e3t divided by 4
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option                 (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_hpg_sco  = .true.   !  s-coordinate (standard jacobian formulation)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient                            (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum                        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_lev =  .true.     !  iso-level
+   nn_ahm_ijk_t  = -30         !  =-30  3D coeff. read in eddy_diffusivity_3D.nc
+/
+!!======================================================================
+!!                     vertical physics namelists                     !!
+!!                                                                    !!
+!!    namzdf        vertical physics manager                            (default: NO selection)
+!!    namzdf_ric    richardson number vertical mixing                   (ln_zdfric=T)
+!!    namzdf_tke    TKE vertical mixing                                 (ln_zdftke=T)
+!!    namzdf_gls    GLS vertical mixing                                 (ln_zdfgls=T)
+!!    namzdf_osm    OSM vertical diffusion                              (ln_zdfosm=T)
+!!    namzdf_iwm    tidal mixing parameterization                       (ln_zdfiwm=T)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics manager                             (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_zdftke   = .true.       !  Turbulent Kinetic Energy closure       (T =>   fill namzdf_tke)
+   ln_zdfevd   = .true.       !  Enhanced Vertical Diffusion scheme
+      nn_evdm  =    0            !  evd apply on tracer (=0) or on tracer and momentum (=1)
+      rn_evd   =  100.           !  evd mixing coefficient [m2/s]
+   ln_zdfddm   = .true.    ! double diffusive mixing
+      rn_avts  =    1.e-4     !  maximum avs (vertical mixing on salinity)
+      rn_hsbfr =    1.6       !  heat/salt buoyancy flux ratio
+   ln_zdfiwm   = .true.       ! internal wave-induced mixing            (T =>   fill namzdf_iwm)
+   !                       !  Coefficients
+   rn_avm0     =   1.2e-4     !  vertical eddy viscosity   [m2/s]       (background Kz if ln_zdfcst=F)
+   rn_avt0     =   1.2e-5     !  vertical eddy diffusivity [m2/s]       (background Kz if ln_zdfcst=F)
+   nn_avb      =    0         !  profile for background avt & avm (=1) or not (=0)
+   nn_havtb    =    1         !  horizontal shape for avtb (=1) or not (=0)
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  (ln_zdftke =T)
+!-----------------------------------------------------------------------
+      nn_mxl      =   3       !  mixing length: = 0 bounded by the distance to surface and bottom
+      !                       !                 = 1 bounded by the local vertical scale factor
+      !                       !                 = 2 first vertical derivative of mixing length bounded by 1
+      !                       !                 = 3 as =2 with distinct dissipative an mixing length scale
+      nn_etau     =   1       !  penetration of tke below the mixed layer (ML) due to NIWs
+                               !        = 0 none ; = 1 add a tke source below the ML
+                               !        = 2 add a tke source just at the base of the ML
+                               !        = 3 as = 1 applied on HF part of the stress           (ln_cpl=T)
+      rn_eice     =   0       !  below sea ice: =0 ON ; =4 OFF when ice fraction > 1/4   
+/
+!-----------------------------------------------------------------------
+&namzdf_iwm    !    internal wave-driven mixing parameterization        (ln_zdfiwm =T)
+!-----------------------------------------------------------------------
+   nn_zpyc     = 2         !  pycnocline-intensified dissipation scales as N (=1) or N^2 (=2)
+   ln_mevar    = .true.    !  variable (T) or constant (F) mixing efficiency
+   ln_tsdiff   = .true.    !  account for differential T/S mixing (T) or not (F)
+
+   cn_dir      = './'      !  root directory for the iwm data location                                                                           
+   !___________!_________________________!___________________!___________!_____________!________!___________!__________________!__________!_______________!
+   !           !  file name              ! frequency (hours) ! variable  ! time interp.!  clim  ! 'yearly'/ ! weights filename ! rotation ! land/sea mask !
+   !           !                         !  (if <0  months)  !   name    !   (logical) !  (T/F) ! 'monthly' !                  ! pairing  !    filename   !
+   sn_mpb      = 'mixing_power_bot'      , -12               , 'field'   , .false.  , .true. , 'yearly' , '' , ''  , ''
+   sn_mpp      = 'mixing_power_pyc'      , -12               , 'field'   , .false.  , .true. , 'yearly' , '' , ''  , ''
+   sn_mpc      = 'mixing_power_cri'      , -12               , 'field'   , .false.  , .true. , 'yearly' , '' , ''  , ''
+   sn_dsb      = 'decay_scale_bot'       , -12               , 'field'   , .false.  , .true. , 'yearly' , '' , ''  , ''
+   sn_dsc      = 'decay_scale_cri'       , -12               , 'field'   , .false.  , .true. , 'yearly' , '' , ''  , ''
+/
+!!======================================================================
+!!                  ***  Diagnostics namelists  ***                   !!
+!!                                                                    !!
+!!   namtrd       dynamics and/or tracer trends                         (default: OFF)
+!!   namptr       Poleward Transport Diagnostics                        (default: OFF)
+!!   namhsb       Heat and salt budgets                                 (default: OFF)
+!!   namdiu       Cool skin and warm layer models                       (default: OFF)
+!!   namdiu       Cool skin and warm layer models                       (default: OFF)
+!!   namflo       float parameters                                      (default: OFF)
+!!   nam_diadct   transports through some sections                      (default: OFF)
+!!   nam_dia25h   25h Mean Output                                       (default: OFF)
+!!   namnc4       netcdf4 chunking and compression settings             ("key_netcdf4")
+!!======================================================================
+!
+!!======================================================================
+!!               ***  Observation & Assimilation  ***                 !!
+!!                                                                    !!
+!!   namobs       observation and model comparison                      (default: OFF)
+!!   nam_asminc   assimilation increments                               ('key_asminc')
+!!======================================================================
+!
+!!======================================================================
+!!                  ***  Miscellaneous namelists  ***                 !!
+!!                                                                    !!
+!!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi")
+!!   namctl            Control prints                                   (default: OFF)
+!!   namsto            Stochastic parametrization of EOS                (default: OFF)
+!!======================================================================
+!
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints                                       (default: OFF)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsto        ! Stochastic parametrization of EOS                      (default: OFF)
+!-----------------------------------------------------------------------
+/
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ice_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ice_cfg	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ice_cfg	(revision 13229)
@@ -0,0 +1,84 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! SI3 configuration namelist: Overwrites SHARED/namelist_ice_ref
+!!              1 - Generic parameters                 (nampar)
+!!              2 - Ice thickness discretization       (namitd)
+!!              3 - Ice dynamics                       (namdyn)
+!!              4 - Ice ridging/rafting                (namdyn_rdgrft)
+!!              5 - Ice rheology                       (namdyn_rhg)
+!!              6 - Ice advection                      (namdyn_adv)
+!!              7 - Ice surface boundary conditions    (namsbc)
+!!              8 - Ice thermodynamics                 (namthd)
+!!              9 - Ice heat diffusion                 (namthd_zdf)
+!!             10 - Ice lateral melting                (namthd_da)
+!!             11 - Ice growth in open water           (namthd_do)
+!!             12 - Ice salinity                       (namthd_sal)
+!!             13 - Ice melt ponds                     (namthd_pnd)
+!!             14 - Ice initialization                 (namini)
+!!             15 - Ice/snow albedos                   (namalb)
+!!             16 - Ice diagnostics                    (namdia)
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!------------------------------------------------------------------------------
+&nampar         !   Generic parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namitd         !   Ice discretization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn         !   Ice dynamics
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_rdgrft  !   Ice ridging/rafting
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_rhg     !   Ice rheology
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdyn_adv     !   Ice advection
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namsbc         !   Ice surface boundary conditions
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd         !   Ice thermodynamics
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_zdf     !   Ice heat diffusion
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_da      !   Ice lateral melting
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_do      !   Ice growth in open water
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_sal     !   Ice salinity
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namthd_pnd     !   Melt ponds
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namini         !   Ice initialization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namalb         !   albedo parameters
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namdia         !   Diagnostics
+!------------------------------------------------------------------------------
+/
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ice_ref
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ice_ref	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ice_ref	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ice_ref
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_pisces_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_pisces_cfg	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_pisces_cfg	(revision 13229)
@@ -0,0 +1,141 @@
+!-----------------------------------------------------------------------
+&nampismod     !  Model used 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisext     !   air-sea exchange
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisatm     !  Atmospheric prrssure 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisbio     !   biological parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zlim     !   parameters for nutrient limitations for PISCES std  - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zlim     !   parameters for nutrient limitations PISCES QUOTA    - ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zquota   !   parameters for nutrient limitations PISCES quota    - ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisopt     !   parameters for optics
+!-----------------------------------------------------------------------
+/ 
+!-----------------------------------------------------------------------
+&namp4zprod    !   parameters for phytoplankton growth for PISCES std  - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zprod    !   parameters for phytoplankton growth for PISCES quota- ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zmort    !   parameters for phytoplankton sinks for PISCES std   - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zmort    !   parameters for phytoplankton sinks for PISCES quota - ln_p5z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zmes     !   parameters for mesozooplankton for PISCES std       - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zmes     !   parameters for mesozooplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp4zzoo     !   parameters for microzooplankton for PISCES std      - ln_p4z
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namp5zzoo     !   parameters for microzooplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisfer     !   parameters for iron chemistry
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------  
+&nampisrem     !   parameters for remineralization
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampispoc     !   parameters for organic particles
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampiscal     !   parameters for Calcite chemistry
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisbc      !   parameters for inputs deposition
+!-----------------------------------------------------------------------
+   sn_dust     = 'dust.orca.new'       ,     -1            , 'dust'        ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   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
+/
+!-----------------------------------------------------------------------
+&nampissed     !   parameters for sediments mobilization
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampislig     !   Namelist parameters for ligands, nampislig
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisice     !   Prescribed sea ice tracers
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nampisdmp     !   Damping 
+!-----------------------------------------------------------------------
+   nn_pisdmp    =  5840       !  Frequency of Relaxation
+/
+!-----------------------------------------------------------------------
+&nampismass    !   Mass conservation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobphy     !   biological parameters for phytoplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobnut     !   biological parameters for nutrients
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobzoo     !   biological parameters for zooplankton
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobdet     !   biological parameters for detritus
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobdom     !   biological parameters for DOM
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobsed     !   parameters from aphotic layers to sediment
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobrat     !   general coefficients
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlobopt     !   optical parameters
+!-----------------------------------------------------------------------
+/
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_pisces_ref
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_pisces_ref	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_pisces_ref	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_pisces_ref
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ref
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ref	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_ref	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_ref
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_top_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_top_cfg	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_top_cfg	(revision 13229)
@@ -0,0 +1,141 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/TOP1 :  Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_top_ref
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namtrc_run      !   run information
+!-----------------------------------------------------------------------
+   ln_top_euler  = .true.
+/
+!-----------------------------------------------------------------------
+&namtrc          !   tracers definition
+!-----------------------------------------------------------------------
+   jp_bgc        =  24
+!
+   ln_pisces     =  .true.
+   ln_my_trc     =  .false.
+   ln_age        =  .false.
+   ln_cfc11      =  .false.
+   ln_cfc12      =  .false.
+   ln_c14        =  .false.
+!
+   ln_trcdta     =  .true.  !  Initialisation from data input file (T) or not (F)
+   ln_trcbc      =  .false.   !  Enables Boundary conditions
+!                !           !                                           !             !         !
+!                !    name   !           title of the field              !   units     ! init    ! sbc    ! cbc    !  obc  ! 
+   sn_tracer(1)   = 'DIC     ' , 'Dissolved inorganic Concentration      ',  'mol-C/L' , .true.  , .false., .true. , .false. 
+   sn_tracer(2)   = 'Alkalini' , 'Total Alkalinity Concentration         ',  'eq/L '   , .true.  , .false., .true. , .false.
+   sn_tracer(3)   = 'O2      ' , 'Dissolved Oxygen Concentration         ',  'mol-C/L' , .true.  , .false., .false., .false. 
+   sn_tracer(4)   = 'CaCO3   ' , 'Calcite Concentration                  ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(5)   = 'PO4     ' , 'Phosphate Concentration                ',  'mol-C/L' , .true.  , .true. , .true. , .false.
+   sn_tracer(6)   = 'POC     ' , 'Small organic carbon Concentration     ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(7)   = 'Si      ' , 'Silicate Concentration                 ',  'mol-C/L' , .true.  , .true. , .true. , .false.
+   sn_tracer(8)   = 'PHY     ' , 'Nanophytoplankton Concentration        ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(9)   = 'ZOO     ' , 'Microzooplankton Concentration         ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(10)  = 'DOC     ' , 'Dissolved organic Concentration        ',  'mol-C/L' , .true.  , .false., .true. , .false.
+   sn_tracer(11)  = 'PHY2    ' , 'Diatoms Concentration                  ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(12)  = 'ZOO2    ' , 'Mesozooplankton Concentration          ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(13)  = 'DSi     ' , 'Diatoms Silicate Concentration         ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(14)  = 'Fer     ' , 'Dissolved Iron Concentration           ',  'mol-C/L' , .true.  , .true. , .true. , .false.
+   sn_tracer(15)  = 'BFe     ' , 'Big iron particles Concentration       ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(16)  = 'GOC     ' , 'Big organic carbon Concentration       ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(17)  = 'SFe     ' , 'Small iron particles Concentration     ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(18)  = 'DFe     ' , 'Diatoms iron  Concentration            ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(19)  = 'GSi     ' , 'Sinking biogenic Silicate Concentration',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(20)  = 'NFe     ' , 'Nano iron Concentration                ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(21)  = 'NCHL    ' , 'Nano chlorophyl Concentration          ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(22)  = 'DCHL    ' , 'Diatoms chlorophyl Concentration       ',  'mol-C/L' , .false. , .false., .false., .false.
+   sn_tracer(23)  = 'NO3     ' , 'Nitrates Concentration                 ',  'mol-C/L' , .true.  , .true. , .true. , .false.
+   sn_tracer(24)  = 'NH4     ' , 'Ammonium Concentration                 ',  'mol-C/L' , .false. , .false., .false., .false.
+/
+!-----------------------------------------------------------------------
+&namage          !   AGE 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_dta      !    Initialisation from data input file
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_trcdta(1)  = 'data_DIC_nomask'        ,        -12.       ,  'DIC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(2)  = 'data_Alkalini_nomask'   ,        -12.       ,  'Alkalini',    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(3)  = 'data_O2_nomask'         ,        -1.        ,  'O2'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(5)  = 'data_PO4_nomask'        ,        -1.        ,  'PO4'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(7)  = 'data_Si_nomask'         ,        -1.        ,  'Si'      ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(10) = 'data_DOC_nomask'        ,        -12.       ,  'DOC'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(14) = 'data_Fer_nomask'        ,        -12.       ,  'Fer'     ,    .false.   , .true. , 'yearly'  , ''       , ''   , ''
+   sn_trcdta(23) = 'data_NO3_nomask'        ,        -1.        ,  'NO3'     ,    .true.    , .true. , 'yearly'  , ''       , ''   , ''
+   rn_trfac(1)   =   1.0e-06  !  multiplicative factor
+   rn_trfac(2)   =   1.0e-06  !  -      -      -     -
+   rn_trfac(3)   =  44.6e-06  !  -      -      -     -
+   rn_trfac(5)   = 122.0e-06  !  -      -      -     -
+   rn_trfac(7)   =   1.0e-06  !  -      -      -     -
+   rn_trfac(10)  =   1.0      !  -      -      -     -
+   rn_trfac(14)  =   1.0      !  -      -      -     -
+   rn_trfac(23)  =   7.6e-06  !  -      -      -     -
+/
+!-----------------------------------------------------------------------
+&namtrc_adv      !   advection scheme for passive tracer                (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_trcadv_mus =  .true.   !  MUSCL scheme
+      ln_mus_ups =  .false.         !  use upstream scheme near river mouths
+/
+!-----------------------------------------------------------------------
+&namtrc_ldf      !   lateral diffusion scheme for passive tracer        (default: NO selection)
+!-----------------------------------------------------------------------
+   ln_trcldf_tra   =  .true.     !  use active tracer setting
+/
+!-----------------------------------------------------------------------
+&namtrc_rad      !  treatment of negative concentrations 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_snk      !  sedimentation of particles
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_dmp      !   passive tracer newtonian damping   
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_ice      !    Representation of sea ice growth & melt effects
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_trd      !   diagnostics on tracer trends                       ('key_trdtrc')
+!----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------
+&namtrc_bc       !   data for boundary conditions
+!-----------------------------------------------------------------------
+!                !  file name        ! frequency (hours) ! variable      ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!                !                   !  (if <0  months)  !   name        !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_trcsbc(5)  = 'dust.orca.new'   ,       -1          , 'dustpo4'     ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(7)  = 'dust.orca.new'   ,       -1          , 'dustsi'      ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(14) = 'dust.orca.new'   ,       -1          , 'dustfer'     ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trcsbc(23) = 'ndeposition.orca',      -12          , 'ndep'        ,  .false.     , .true. , 'yearly'  , ''       , ''    , ''
+   rn_trsfac(5)  = 8.264e-02   !  (  0.021 / 31. * 122 )
+   rn_trsfac(7)  = 3.313e-01     !  ( 8.8   / 28.1 )
+   rn_trsfac(14) = 6.266e-04   !  (  0.035 / 55.85 )
+   rn_trsfac(23) =  5.4464e-01  !  ( From kgN m-2 s-1 to molC l-1 ====> zfact = 7.625/14 )
+   rn_sbc_time   =  1.          !  Time scaling factor for SBC and CBC data (seconds in a day)
+   !
+   sn_trccbc(1)  = 'river.orca'      ,    120            , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trccbc(2)  = 'river.orca'      ,    120            , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trccbc(5)  = 'river.orca'      ,    120            , 'riverdip'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trccbc(7)  = 'river.orca'      ,    120            , 'riverdsi'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trccbc(10) = 'river.orca'      ,    120            , 'riverdoc'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trccbc(14) = 'river.orca'      ,    120            , 'riverdic'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   sn_trccbc(23) = 'river.orca'      ,    120            , 'riverdin'    ,  .true.      , .true. , 'yearly'  , ''       , ''    , ''
+   rn_trcfac(1)  = 8.333e+01   !  ( data in Mg/m2/yr : 1e3/12/ryyss)
+   rn_trcfac(2)  = 8.333e+01   !  ( 1e3 /12 )
+   rn_trcfac(5)  = 3.935e+04   !  ( 1e3 / 31. * 122 )
+   rn_trcfac(7)  = 3.588e+01   !  ( 1e3 / 28.1 )
+   rn_trcfac(10) = 8.333e+01   !  ( 1e3 / 12
+   rn_trcfac(14) = 4.166e-03   !  ( 1e3 / 12 * 5e-5 )
+   rn_trcfac(23) = 5.446e+02   !  (  1e3 / 14 * 7.625 )
+   rn_cbc_time   = 3.1536e+7   !  Time scaling factor for CBC data (seconds in a year)
+/
+!----------------------------------------------------------------------
+&namtrc_bdy      !   Setup of tracer boundary conditions
+!-----------------------------------------------------------------------
+/
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_top_ref
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_top_ref	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/EXPREF/namelist_top_ref	(revision 13229)
@@ -0,0 +1,1 @@
+link ../../../cfgs/SHARED/namelist_top_ref
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/README.md
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/README.md	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/README.md	(revision 13229)
@@ -0,0 +1,65 @@
+# Coupling with OASIS test case
+The CPL_OASIS test case allows to set up and check a basic coupling of NEMOto a simple TOYATM fake tmposhere through the OASIS coupler. A very limited number of fields are exchanged between NEMO and the TOYATM. The tests checks that the fields are indeed exchanged through OASIS and that the ATSSTSST field of sea surface temparture received by the TOYATM makes sense. If the test is sucessful, it states that the set up of NEMO-OASIS interface in the NEMO SBC module is working fine. 
+<br>
+We here provide a description of details of this experiment so as as how to run it and check test is sucessful. This experiment is **created and tested** for NEMO ** revision 12573 (to be replace by NEMO release 4.2 by end 2020)**. 
+
+## Objectives
+This test case enables the OASIS interface in NEMO (in the OCE/SBC module). A few fields are sent and received by NEMO and by TOYATM (the simplified "atmosphere"). The success of this test (see below ** Verification**) indicates that 
+* the OASIS interface in NEMO is functionnal (some fields are sent and received)
+* The sea surface temperature received by the TOYATM makes sense
+
+This test case can be seen as a template to set up a coupling between NEMO and an atmospheric model through OASIS.
+
+## Detailed description
+
+This test case is a set up of NEMO (dynamics, sea-ice and biogeochemistry) on a global 2° grid (as in ithe ORCA2_ICE_PISCES reference configuration), except NEMO is here coupled to a "toyatm" through OASIS.
+
+NEMO is running 160 time-steps (10 days). The coupling is done at each timestep (nn_fsbc=1 in namelist_cfg). The fields exchanged with the toyatm are defined in the &namsbc_cpl namelist in namelist_cfg file.
+
+
+This test case requires:
+* NEMO (no mofication of source code, from rev 12573 or higher (e.g. compatible with NEMO reease 4.2
+* OASIS (need to be downloaded and compiled, with correct paths set in your arch file for NEMO
+* TOYATM (the simple toy in place of an atmospheric model) (located in NEMO/tools directory, need to created executable using tools/maketools command)
+
+This tests/CPL_OASIS directory contains all the need files:
+* cpp_CPL_OASIS.fcm defining the active cpp keys for NEMO
+* EXPREF directory containing all the input files: namelists, xml files, a template job tu run the test case, and a script to check the results and produce the report
+  	 * More specifically, the fields exchanged by NEMO through OASIS ae defined in the namelist_cfg input file (see &namsbc_cpl variables)
+
+
+## Building the CPL_OASIS test case
+* Download and compile OASIS
+* Build the NEMO executable for this CPL_OASIS test case. In your local NEMO root directory:
+``` 
+./makenemo -a CPL_OASIS -n MYCPL_OASIS -m "your arch file"
+```
+This makenemo command will create the test case in cfgs/MYCPL_OASIS
+* Build the TOYATM executable
+```
+cd tools 
+./maketools -n TOYATM -m "your arch file"
+```
+
+## Running the test case 
+```
+cd tests/MYCPL_OASIS/EXP00
+cp ../../CPL_OASIS/job_run_CPL_TESTCASE .
+Adapt the job_run_CPL_TESTCASE to your target computer and run it
+```
+In this directory the job_run_cpl_testcase contains all the steps to run the testcase. These steps are commented in the file.
+** After adapting the headers for your batch system and the paths for the files **, run this script through the batch system of your target computer.
+
+## Verification and validation of the test case
+The script gen_report.sh located in the CPL_OASIS directory allows to check if the run came to a sucessful ending:
+```
+cd MYCPL_OASIS/EXP00
+cp ../../CPL_OASIS/gen_report.sh .
+./gen_report.sh
+```
+If the report is successful, a final check sould be done by visualising the ATSSTSST_toyatm_01.nc (using ncview or any other visualiser for NETCDF files) and comparing it to the reference ref_ATSSTSST_last_time_step.jpg image in the CPL_OASIS directory: the two visualisations must look alike.
+
+reference ref_ATSSTSST_last_time_step.jpg
+.. image:: ref_ATSSTSST_last_time_step.jpg
+
+
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/cpp_CPL_OASIS.fcm
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/cpp_CPL_OASIS.fcm	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/cpp_CPL_OASIS.fcm	(revision 13229)
@@ -0,0 +1,1 @@
+bld::tool::fppkeys   key_si3 key_top key_iomput key_mpp_mpi key_oasis3
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/gen_report.sh
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/gen_report.sh	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/gen_report.sh	(revision 13229)
@@ -0,0 +1,95 @@
+#!/bin/bash
+#set -vx
+# ncmax $var_nm $fl_nm : What is maximum of variable?
+function ncmax { ncap2 -O -C -v -s "foo=${1}.max();print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; }
+# ncmin $var_nm $fl_nm : What is minimum of variable?
+function ncmin { ncap2 -O -C -v -s "foo=${1}.min();print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; }
+# ncmdn $var_nm $fl_nm : What is median of variable?
+function ncmdn { ncap2 -O -C -v -s "foo=gsl_stats_median_from_sorted_data(${1}.sort());print(foo)" ${2} ~/foo.nc | cut -f 3- -d ' ' ; }
+
+##
+## simple report generator for the test case
+##
+
+##
+## Variables which may need to be adapted to your experiment:
+##
+#  RUNDIR = directory where the test case is executed: contains all outputs
+RUNDIR=/gpfswork/rech/omr/romr001/OUT/CPLTESTCASE/2020-03-31120816
+#  NB_NEMO_IT = expected total number of NEMO iterations
+NB_NEMO_IT=160
+#  NB_OASIS_OUTFILES = number of debug.root.0* OASIS output files
+NB_OASIS_OUTFILES=2
+##
+## END of variables to be checked - Nothing need to be changed below
+##
+# check if directory is here
+  if [ ! -d $RUNDIR ]; then
+    printf "%-27s %s %s\n" $RUNDIR  "directory does not exist. Check RUNDIR variable in script. Stop" 
+    return
+  fi
+
+cd $RUNDIR
+
+echo " "
+echo "Check results of test case in directory: " `pwd`
+echo " "
+##
+## Check if OASIS execution has been successful
+##
+echo "      OASIS successful (true if OASIS outputs in debug.root.0? includes SUCCESSFUL RUN)  : "
+count=0
+for file in debug.root.0*
+do
+  echo $file ; grep "SUCCESSFUL RUN" $file
+  count=`expr $count + 1`
+done
+echo "OASIS success checked on $count files"
+[ $count = $NB_OASIS_OUTFILES ] && echo true || echo false
+##
+## Check if NEMO execution has been sucessful
+##
+echo " "
+echo "      NEMO execution is successful if the run.stat file contains one line for each of NB_NEMO_IT iterations, indicating they have indeed been computed"
+ if [ ! -f ./run.stat ]; then
+   echo " the run.stat file does not exist: NEMO did not end its first time step"
+   echo " NEMO UNSUCESSFUL. Stop"
+   return
+ fi
+echo "From run.stat NEMO output file, NEMO has executed the 160 time steps:"
+nemo_iterations=`wc -l ./run.stat | awk {'print $1'} `; [ $nemo_iterations = $NB_NEMO_IT ] && echo true || echo false
+
+##
+## Check mean value of sst field seen by toyatm
+##
+ if [ ! -f ./ATSSTSST_toyatm_01.nc ]; then
+   echo " the ATSSTSST_toyatm_01.nc file does not exist: the test is not successful"
+   echo " Test case UNSUCESSFUL. Stop"
+   return
+ fi
+echo " "
+echo "Examining ATSSTSST variable sea surface temperature as seen by toyatm, unit is degree Kelvin (min. should be around 271., max. around 302., median around 280.)" 
+ASSTmin=`ncmin ATSSTSST ATSSTSST_toyatm_01.nc`
+ASSTmax=`ncmax ATSSTSST ATSSTSST_toyatm_01.nc` 
+ASSTmed=`ncmdn  ATSSTSST ATSSTSST_toyatm_01.nc`
+echo "Minimum value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmin
+echo "Maximum value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = " $ASSTmax
+echo "Median value of ATSSTSST variable in ATSSTSST_toyatm_01.nc file = "  $ASSTmed
+MINMAX=0
+if [ ${ASSTmin%%.*} -lt 270 -o ${ASSTmax%%.*} -gt 310 ]; then
+echo " Min. or max. values of ATSSTSST do not look reasonable. Check the test again "
+MINMAX=1
+fi
+##
+## Summary
+##
+echo " "  
+if [ $count = $NB_OASIS_OUTFILES ] && [ $nemo_iterations = $NB_NEMO_IT ] && [ $MINMAX = 0 ] 
+then
+  echo " The run looks very succesful!"
+  echo " Have a look to the ASTSSTSST.nc file (using ncview for example): sea surface temperatures as seen by the toyatm and compare it to the reference file (CPL/ref_ATSSTSST_last_time_step.jpg) "
+  echo " Units are in degrees Kelvin and it will confirm the test is successful"
+  echo " "
+else
+  echo "The test case is unsuccessful. Check all inputs and outputs"
+fi
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/job_run_CPL_TESTCASE
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/job_run_CPL_TESTCASE	(revision 13229)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/CPL_OASIS/job_run_CPL_TESTCASE	(revision 13229)
@@ -0,0 +1,78 @@
+#!/bin/bash
+###################################
+## Definitions for batch system
+#SBATCH -A omr@cpu                 # Accounting information
+#SBATCH --job-name=CPL_TESTCASE    # Job name
+##SBATCH --partition=cpu_p1        # Partition Name
+#SBATCH --ntasks=29                # Total number of MPI processes
+#SBATCH --ntasks-per-node=40       # Number of MPI processes per node
+#SBATCH --hint=nomultithread       # 1  MPI process per node  (no hyperthreading)
+#SBATCH --time=00:10:00            # Maximum execution time (HH:MM:SS)
+#SBATCH --output=cpltestcase_%j    # Name of output listing file
+#SBATCH --error=cpltestcase_%j     # Name of error listing file (the same)
+###################################
+##
+## Go to submission directory
+##
+cd ${SLURM_SUBMIT_DIR}
+pwd
+CONFIG_DIR=${SLURM_SUBMIT_DIR}
+##
+## Define and create execution directory and move there
+##
+XXD=`date +%F%H%M%S`
+echo " XXD " $XXD
+mkdir -p $WORK/OUT/CPLTESTCASE/$XXD
+cd $WORK/OUT/CPLTESTCASE/$XXD
+echo "RUN directory " `pwd`
+##
+## Get input files for NEMO
+##
+DATA1DIR=$WORK/FORCING/ORCA2_ICE_PISCES_v4.0
+for file in $DATA1DIR/* 
+do
+ln -s $file . || exit 2
+done
+# Get input namelist  and xml files
+for file in $CONFIG_DIR/*namelist*_ref $CONFIG_DIR/*namelist*_cfg $CONFIG_DIR/*.xml
+do
+    cp $file . || exit 3
+done
+##
+## Get input files for TOYATM, including the namcouple file
+##
+TOYATM_DIR=$CONFIG_DIR/../../../tools/TOYATM/EXP
+for file in $TOYATM_DIR/*
+do
+    cp $file . || exit 4
+done
+##
+## Get Executables
+##
+cp $CONFIG_DIR/nemo nemo.exe  || exit 5
+cp $TOYATM_DIR/../toyatm.exe . || exit 5
+
+echo "DIR BEFORE EXEC"
+ls -l
+echo '(3) Prepare launch of the run'
+echo '----------------'
+export MPIRUN="srun --mpi=pmi2 --cpu-bind=cores -K1"
+NB_PROCS_NEMO=28
+NB_PROCS_OASIS=1
+NB_PROCS_TOYATM=1
+date  
+touch ./run_file
+echo 0-27 ./nemo.exe >>./run_file
+echo 28 ./toyatm.exe >>./run_file
+echo run_file
+cat ./run_file
+##
+## Run the CPL test case using 27 processes for nemo and 1 for toyatm
+##
+echo '(4) Run the code'
+echo '----------------'
+time srun --multi-prog ./run_file
+echo "DIR AFTER EXEC"
+ls -l
+date
+pwd
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/README.rst
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/README.rst	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/README.rst	(revision 13229)
@@ -205,2 +205,7 @@
    :style: unsrt
    :labelprefix: T
+
+CPL_OASIS
+---------
+| This test case checks the OASIS interface in OCE/SBC, allowing to set up 
+a coupled configuration through OASIS. See CPL_OASIS/README.md for more information.
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/STATION_ASF/EXPREF/launch_sasf.sh
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/STATION_ASF/EXPREF/launch_sasf.sh	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/STATION_ASF/EXPREF/launch_sasf.sh	(revision 13229)
@@ -1,78 +1,50 @@
 #!/bin/bash
 
-################################################################
-#
-# Script to launch a set of STATION_ASF simulations
-#
-# L. Brodeau, 2020
-#
-################################################################
+# NEMO directory where to fetch compiled STATION_ASF nemo.exe + setup:
+NEMO_DIR=`pwd | sed -e "s|/tests/STATION_ASF/EXPREF||g"`
 
-# What directory inside "tests" actually contains the compiled "nemo.exe" for STATION_ASF ?
+echo "Using NEMO_DIR=${NEMO_DIR}"
+
+# what directory inside "tests" actually contains the compiled test-case?
 TC_DIR="STATION_ASF2"
 
-# DATA_IN_DIR => Directory containing sea-surface + atmospheric forcings
+# => so the executable to use is:
+NEMO_EXE="${NEMO_DIR}/tests/${TC_DIR}/BLD/bin/nemo.exe"
+
+# Directory where to run the simulation:
+WORK_DIR="${HOME}/tmp/STATION_ASF"
+
+
+# FORC_DIR => Directory containing sea-surface + atmospheric forcings
 #             (get it there https://drive.google.com/file/d/1MxNvjhRHmMrL54y6RX7WIaM9-LGl--ZP/):
 if [ `hostname` = "merlat"        ]; then
-    DATA_IN_DIR="/MEDIA/data/STATION_ASF/input_data_STATION_ASF_2016-2018"
+    FORC_DIR="/MEDIA/data/STATION_ASF/input_data_STATION_ASF_2016-2018"
 elif [ `hostname` = "luitel"        ]; then
-    DATA_IN_DIR="/data/gcm_setup/STATION_ASF/input_data_STATION_ASF_2016-2018"
+    FORC_DIR="/data/gcm_setup/STATION_ASF/input_data_STATION_ASF_2016-2018"
 elif [ `hostname` = "ige-meom-cal1" ]; then
-    DATA_IN_DIR="/mnt/meom/workdir/brodeau/STATION_ASF/input_data_STATION_ASF_2016-2018"
+    FORC_DIR="/mnt/meom/workdir/brodeau/STATION_ASF/input_data_STATION_ASF_2016-2018"
 elif [ `hostname` = "salvelinus" ]; then
-    DATA_IN_DIR="/opt/data/STATION_ASF/input_data_STATION_ASF_2016-2018"
+    FORC_DIR="/opt/data/STATION_ASF/input_data_STATION_ASF_2016-2018"
 else
-    echo "Oops! We don't know `hostname` yet! Define 'DATA_IN_DIR' in the script!"; exit 
+    echo "Boo!"; exit
 fi
-
-expdir=`basename ${PWD}`; # we expect "EXPREF" or "EXP00" normally...
-
-# NEMOGCM root directory where to fetch compiled STATION_ASF nemo.exe + setup:
-NEMO_WRK_DIR=`pwd | sed -e "s|/tests/STATION_ASF/${expdir}||g"`
-
-# Directory where to run the simulation:
-PROD_DIR="${HOME}/tmp/STATION_ASF"
+#======================
+mkdir -p ${WORK_DIR}
 
 
-####### End of normal user configurable section #######
+if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled nemo.exe found into ${NEMO_DIR}/tests/STATION_ASF/BLD/bin !"; exit; fi
 
-#================================================================================
-
-# NEMO executable to use is:
-NEMO_EXE="${NEMO_WRK_DIR}/tests/${TC_DIR}/BLD/bin/nemo.exe"
-
-
-echo "###########################################################"
-echo "#        S T A T I O N   A i r  -  S e a   F l u x        #"
-echo "###########################################################"
-echo
-echo " We shall work in here: ${STATION_ASF_DIR}/"
-echo " NEMOGCM   work    depository is: ${NEMO_WRK_DIR}/"
-echo "   ==> NEMO EXE to use: ${NEMO_EXE}"
-echo " Input forcing data into: ${DATA_IN_DIR}/"
-echo " Production will be done into: ${PROD_DIR}/"
-echo
-
-mkdir -p ${PROD_DIR}
-
-if [ ! -f ${NEMO_EXE} ]; then echo " Mhhh, no compiled 'nemo.exe' found into `dirname ${NEMO_EXE}` !"; exit; fi
-
-echo
-echo " *** Using the following NEMO executable:"
-echo "  ${NEMO_EXE} "
-echo
-
-NEMO_EXPREF="${NEMO_WRK_DIR}/tests/STATION_ASF/EXPREF"
+NEMO_EXPREF="${NEMO_DIR}/tests/STATION_ASF/EXPREF"
 if [ ! -d ${NEMO_EXPREF} ]; then echo " Mhhh, no EXPREF directory ${NEMO_EXPREF} !"; exit; fi
 
-rsync -avP ${NEMO_EXE}          ${PROD_DIR}/
+rsync -avP ${NEMO_EXE}          ${WORK_DIR}/
 
 for ff in "context_nemo.xml" "domain_def_nemo.xml" "field_def_nemo-oce.xml" "file_def_nemo-oce.xml" "grid_def_nemo.xml" "iodef.xml" "namelist_ref"; do
     if [ ! -f ${NEMO_EXPREF}/${ff} ]; then echo " Mhhh, ${ff} not found into ${NEMO_EXPREF} !"; exit; fi
-    rsync -avPL ${NEMO_EXPREF}/${ff} ${PROD_DIR}/
+    rsync -avPL ${NEMO_EXPREF}/${ff} ${WORK_DIR}/
 done
 
 # Copy forcing to work directory:
-rsync -avP ${DATA_IN_DIR}/Station_PAPA_50N-145W*.nc ${PROD_DIR}/
+rsync -avP ${FORC_DIR}/Station_PAPA_50N-145W*.nc ${WORK_DIR}/
 
 for CASE in "ECMWF" "COARE3p6" "NCAR" "ECMWF-noskin" "COARE3p6-noskin"; do
@@ -86,8 +58,8 @@
     scase=`echo "${CASE}" | tr '[:upper:]' '[:lower:]'`
 
-    rm -f ${PROD_DIR}/namelist_cfg
-    rsync -avPL ${NEMO_EXPREF}/namelist_${scase}_cfg ${PROD_DIR}/namelist_cfg
+    rm -f ${WORK_DIR}/namelist_cfg
+    rsync -avPL ${NEMO_EXPREF}/namelist_${scase}_cfg ${WORK_DIR}/namelist_cfg
 
-    cd ${PROD_DIR}/
+    cd ${WORK_DIR}/
     echo
     echo "Launching NEMO !"
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/STATION_ASF/MY_SRC/step_c1d.F90
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/STATION_ASF/MY_SRC/step_c1d.F90	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/STATION_ASF/MY_SRC/step_c1d.F90	(revision 13229)
@@ -78,11 +78,10 @@
       ! Control and restarts
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      CALL stp_ctl( kstp, Nnn )
-
+      CALL stp_ctl( kstp, Nbb, Nnn, indic )
       IF( kstp == nit000 )   CALL iom_close( numror )          ! close input  ocean restart file
       IF( lrst_oce       )   CALL rst_write( kstp, Nbb, Nnn )  ! write output ocean restart file
       !
 #if defined key_iomput
-      IF( kstp == nitend .OR. nstop > 0 )   CALL xios_context_finalize()   ! needed for XIOS
+      IF( kstp == nitend .OR. indic < 0 )   CALL xios_context_finalize()   ! needed for XIOS
       !
 #endif
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/VORTEX/EXPREF/1_namelist_cfg
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/VORTEX/EXPREF/1_namelist_cfg	(revision 13229)
@@ -98,8 +98,6 @@
 &namagrif      !  AGRIF zoom                                            ("key_agrif")
 !-----------------------------------------------------------------------
-   ln_spc_dyn    = .true.  !  use 0 as special value for dynamics
-   rn_sponge_tra =  800.   !  coefficient for tracer   sponge layer [m2/s]
-   rn_sponge_dyn =  800.   !  coefficient for dynamics sponge layer [m2/s]
-   ln_chk_bathy  = .FALSE. !
+   rn_sponge_tra =  0.00768   !  coefficient for tracer   sponge layer []
+   rn_sponge_dyn =  0.00768   !  coefficient for dynamics sponge layer []
 /
 !!======================================================================
Index: NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/demo_cfgs.txt
===================================================================
--- NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/demo_cfgs.txt	(revision 13228)
+++ NEMO/branches/2020/dev_r12558_HPC-08_epico_Extra_Halo/tests/demo_cfgs.txt	(revision 13229)
@@ -11,2 +11,3 @@
 BENCH OCE ICE TOP
 STATION_ASF OCE
+CPL_OASIS  OCE TOP ICE NST
