Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/ARCH/arch-openmpi_NAVITI_MERCATOR.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/ARCH/arch-openmpi_NAVITI_MERCATOR.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/ARCH/arch-openmpi_NAVITI_MERCATOR.fcm	(revision 6041)
@@ -23,5 +23,5 @@
 %CPP	             cpp
 %FC                  mpif90
-%FCFLAGS             -O2 -fp-model precise  -traceback -r8  -convert big_endian -assume byterecl
+%FCFLAGS             -O1 -fp-model precise  -traceback -r8  -convert big_endian -assume byterecl
 %FFLAGS              %FCFLAGS
 %LD                   mpif90
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/AMM12/EXP00/namelist_cfg	(revision 6041)
@@ -72,11 +72,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-   ln_bt_nn_auto =    .FALSE.          !  Set nn_baro automatically to be just below
-                                       !  a user defined maximum courant number (rn_bt_cmax)
-   nn_baro       =    30               !  Number of iterations of barotropic mode
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -194,12 +187,4 @@
    rn_shlat    =     0     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
                            !  free slip  !   partial slip  !   no slip   ! strong slip
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
 /
 !-----------------------------------------------------------------------
@@ -281,4 +266,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -289,8 +279,36 @@
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
-   ln_traldf_hor    =  .true.   !  horizontal (geopotential)   (needs "key_ldfslp" when ln_sco=T)
-   ln_traldf_iso    =  .false.  !  iso-neutral                 (needs "key_ldfslp")
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =    50.    !  horizontal eddy diffusivity for tracers [m2/s]
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .true.   !  horizontal (geopotential)
+   ln_traldf_iso   =  .false.  !  iso-neutral
+   ln_traldf_triad =  .false.  !  iso-neutral using Griffies triads
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML     (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom         (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        =   50.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -306,4 +324,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -314,22 +337,35 @@
 /
 !-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
-!                          !  explicit free surface                     ("key_dynspg_exp")
-!                          !  filtered free surface                     ("key_dynspg_flt")
-!                          !  split-explicit free surface               ("key_dynspg_ts")
-
+&namdyn_spg    !   surface pressure gradient 
+!-----------------------------------------------------------------------
+   ln_dynspg_ts   = .true.    ! split-explicit free surface
+      ln_bt_auto    = .false.   ! Number of sub-step defined from:
+         nn_baro      = 30        ! =F : the number of sub-step in rn_rdt seconds
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
    !                       !  Type of the operator :
-   ln_dynldf_bilap  =  .true.   !  bilaplacian operator
-   ln_dynldf_lap    =  .false.  !  bilaplacian operator
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .true.     !  bilaplacian operator
    !                       !  Direction of action  :
-   ln_dynldf_level  =  .true.   !  iso-level
-   ln_dynldf_hor    =  .false.  !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
-                           !  Coefficient
-   rn_ahm_0_lap     = 60.0      !  horizontal laplacian eddy viscosity   [m2/s]
-   rn_ahm_0_blp     = -1.0e+10  !  horizontal bilaplacian eddy viscosity [m4/s]
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =     60.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.0e+10     !  horizontal bilaplacian eddy viscosity [m4/s]
+   !
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
 /
 !-----------------------------------------------------------------------
@@ -349,8 +385,4 @@
 !-----------------------------------------------------------------------
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-/
 !-----------------------------------------------------------------------
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
@@ -369,8 +401,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/AMM12/cpp_AMM12.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/AMM12/cpp_AMM12.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/AMM12/cpp_AMM12.fcm	(revision 6041)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys  key_bdy key_tide key_dynspg_ts key_ldfslp  key_zdfgls  key_vvl key_diainstant key_mpp_mpi key_iomput
+ bld::tool::fppkeys  key_bdy key_tide  key_zdfgls  key_vvl key_diainstant key_mpp_mpi key_iomput
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/C1D_PAPA/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/C1D_PAPA/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/C1D_PAPA/EXP00/namelist_cfg	(revision 6041)
@@ -64,8 +64,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -141,4 +137,7 @@
 &namtra_qsr    !   penetrative solar radiation
 !-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_chl      ='chlorophyll_PAPASTATION', -1    , 'CHLA'    ,   .true.     , .true. , 'yearly'  , ''       , ''       , ''
 /
 !-----------------------------------------------------------------------
@@ -170,12 +169,4 @@
 !-----------------------------------------------------------------------
    rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
 /
 !-----------------------------------------------------------------------
@@ -226,4 +217,5 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
+! C1D : no advection scheme 
 /
 !-----------------------------------------------------------------------
@@ -231,12 +223,13 @@
 !-----------------------------------------------------------------------
 /
-!----------------------------------------------------------------------------------
+!-----------------------------------------------------------------------
 &namtra_ldf    !   lateral diffusion scheme for tracers
-!----------------------------------------------------------------------------------
-!----------------------------------------------------------------------------------
-   ln_traldf_hor    =  .true.   !  horizontal (geopotential)   (needs "key_ldfslp" when ln_sco=T)
-   ln_traldf_iso    =  .false.  !  iso-neutral                 (needs "key_ldfslp")
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =     0.    !  horizontal eddy diffusivity for tracers [m2/s]
+!-----------------------------------------------------------------------
+! C1D : no lateral diffusion  
+/
+!-----------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!-----------------------------------------------------------------------
+! C1D : no eiv  
 /
 !-----------------------------------------------------------------------
@@ -248,4 +241,5 @@
 &namdyn_adv    !   formulation of the momentum advection
 !-----------------------------------------------------------------------
+! C1D : no advection scheme 
 /
 !-----------------------------------------------------------------------
@@ -266,6 +260,7 @@
 /
 !-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
@@ -286,8 +281,4 @@
 !-----------------------------------------------------------------------
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-/
 !-----------------------------------------------------------------------
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
@@ -302,11 +293,4 @@
 !-----------------------------------------------------------------------
    ln_tmx_itf  = .false.   !  ITF specific parameterisation
-/
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-   nn_nmin     =    210    !  minimum of iterations for the SOR solver
-   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE/EXP00/namelist_cfg	(revision 6041)
@@ -66,8 +66,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -154,12 +150,4 @@
 !-----------------------------------------------------------------------
    rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
 /
 !-----------------------------------------------------------------------
@@ -223,11 +211,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.   !  2nd order centered scheme
-   ln_traadv_tvd    =  .true.    !  TVD scheme
-   ln_traadv_muscl  =  .false.   !  MUSCL scheme
-   ln_traadv_muscl2 =  .false.   !  MUSCL2 scheme + cen2 at boundaries
-   ln_traadv_ubs    =  .false.   !  UBS scheme
-   ln_traadv_qck    =  .false.   !  QUICKEST scheme
-   ln_traadv_msc_ups=  .false.   !  use upstream scheme within muscl
+   ln_traadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -238,6 +224,36 @@
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral
+   ln_traldf_triad =  .false.  !  iso-neutral using Griffies triads
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .false.  !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML     (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom         (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -253,7 +269,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .true.  !  energy    conserving scheme  
-   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
+   ln_dynvor_ene = .true.  !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
    ln_dynvor_een = .false. !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -264,11 +282,31 @@
 /
 !-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
-
+&namdyn_spg    !   surface pressure gradient 
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   rn_ahm_0_lap     = 100000.   !  horizontal laplacian eddy viscosity   [m2/s]
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      = 100000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      =      0.     !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 !-----------------------------------------------------------------------
@@ -286,8 +324,4 @@
    nn_etau     =   0       !  penetration of tke below the mixed layer (ML) due to internal & intertial waves
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-/
 !-----------------------------------------------------------------------
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
@@ -302,11 +336,4 @@
 !-----------------------------------------------------------------------
    ln_tmx_itf  = .false.   !  ITF specific parameterisation
-/
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-   nn_nmin     =    210    !  minimum of iterations for the SOR solver
-   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE/cpp_GYRE.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE/cpp_GYRE.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE/cpp_GYRE.fcm	(revision 6041)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_dynspg_flt key_ldfslp key_zdftke key_iomput key_mpp_mpi key_nosignedzero
+ bld::tool::fppkeys key_zdftke key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_cfg	(revision 6041)
@@ -69,8 +69,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -159,12 +155,4 @@
 !-----------------------------------------------------------------------
    rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
 /
 !-----------------------------------------------------------------------
@@ -228,5 +216,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
-   ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl 
+   ln_traadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -237,6 +229,36 @@
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -252,7 +274,5 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .true.  !  energy    conserving scheme  
-   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
-   ln_dynvor_een = .false. !  energy & enstrophy scheme
+   ln_dynvor_ene = .true.  !  enstrophy conserving scheme
 /
 !-----------------------------------------------------------------------
@@ -263,9 +283,34 @@
 /
 !-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      = 100000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      =      0.     !  horizontal bilaplacian eddy viscosity [m4/s]
+   !
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
+/
    rn_ahm_0_lap     = 100000.   !  horizontal laplacian eddy viscosity   [m2/s]
 /
@@ -284,8 +329,4 @@
    nn_etau     =   0       !  penetration of tke below the mixed layer (ML) due to internal & intertial waves
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-/
 !-----------------------------------------------------------------------
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
@@ -300,11 +341,4 @@
 !-----------------------------------------------------------------------
    ln_tmx_itf  = .false.   !  ITF specific parameterisation
-/
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-   nn_nmin     =    210    !  minimum of iterations for the SOR solver
-   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_top_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/EXP00/namelist_top_cfg	(revision 6041)
@@ -23,7 +23,10 @@
 !-----------------------------------------------------------------------
 &namtrc_adv    !   advection scheme for passive tracer 
-!-----------------------------------------------------------------------  
-   ln_trcadv_tvd     =  .true.   !  TVD scheme
-   ln_trcadv_muscl   =  .false.  !  MUSCL scheme
+!-----------------------------------------------------------------------
+   ln_trcadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/cpp_GYRE_BFM.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/cpp_GYRE_BFM.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_BFM/cpp_GYRE_BFM.fcm	(revision 6041)
@@ -1,2 +1,2 @@
-bld::tool::fppkeys key_dynspg_flt key_ldfslp key_zdftke key_vectopt_loop key_top key_my_trc key_mpp_mpi key_iomput
+bld::tool::fppkeys key_zdftke key_top key_my_trc key_mpp_mpi key_iomput
 inc $BFMDIR/src/nemo/bfm.fcm
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_cfg	(revision 6041)
@@ -59,8 +59,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -102,8 +98,4 @@
 !-----------------------------------------------------------------------
    rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
 /
 !-----------------------------------------------------------------------
@@ -143,11 +135,45 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
-   ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl 
+   ln_traadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !----------------------------------------------------------------------------------
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -163,7 +189,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .true.  !  energy    conserving scheme  
-   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
+   ln_dynvor_ene = .true.  !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
    ln_dynvor_een = .false. !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -174,6 +202,34 @@
 /
 !-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.    !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.    !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      = 100000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      =      0.      !  horizontal bilaplacian eddy viscosity [m4/s]
+   !
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
+/
    rn_ahm_0_lap     = 100000.   !  horizontal laplacian eddy viscosity   [m2/s]
 /
@@ -189,11 +245,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-   nn_nmin     =    210    !  minimum of iterations for the SOR solver
-   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_top_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/EXP00/namelist_top_cfg	(revision 6041)
@@ -24,6 +24,9 @@
 &namtrc_adv    !   advection scheme for passive tracer 
 !-----------------------------------------------------------------------   
-   ln_trcadv_tvd     =  .true.   !  TVD scheme
-   ln_trcadv_muscl   =  .false.  !  MUSCL scheme
+   ln_trcadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/cpp_GYRE_PISCES.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/cpp_GYRE_PISCES.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_PISCES/cpp_GYRE_PISCES.fcm	(revision 6041)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys  key_dynspg_flt key_ldfslp key_zdftke key_top key_pisces_reduced key_iomput key_mpp_mpi
+bld::tool::fppkeys key_zdftke key_top key_pisces_reduced key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_XIOS/EXP00/namelist_cfg	(revision 6041)
@@ -41,5 +41,4 @@
    nn_bathy    =    0      !  compute (=0) or read (=1) the bathymetry file
    rn_rdt      = 7200.     !  time step for the dynamics (and tracer if nn_acc=0)
-!   nn_baro     =   60      !  number of barotropic time step            ("key_dynspg_ts")
    rn_rdtmin   = 7200.           !  minimum time step on tracers (used if nn_acc=1)
    rn_rdtmax   = 7200.           !  maximum time step on tracers (used if nn_acc=1)
@@ -150,12 +149,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namagrif      !  AGRIF zoom                                            ("key_agrif")
 !-----------------------------------------------------------------------
@@ -200,5 +191,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
-   ln_traadv_msc_ups=  .false.  !  use upstream scheme within muscl 
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -209,6 +204,36 @@
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -235,6 +260,8 @@
 /
 !-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
@@ -274,11 +301,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-   nn_nmin     =    210    !  minimum of iterations for the SOR solver
-   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_XIOS/cpp_GYRE_XIOS.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_XIOS/cpp_GYRE_XIOS.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/GYRE_XIOS/cpp_GYRE_XIOS.fcm	(revision 6041)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_dynspg_flt key_ldfslp key_zdftke key_iomput key_mpp_mpi
+ bld::tool::fppkeys key_zdftke key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/1_namelist_cfg	(revision 6041)
@@ -4,10 +4,11 @@
 !-----------------------------------------------------------------------
 &namrun        !   parameters of the run
+ nn_it000=1
 !-----------------------------------------------------------------------
    cn_exp      = "Agulhas" !  experience name 
-   nn_itend    =   10950   !  last  time step
+   nn_itend    =   10950
    nn_stock    =   10950   !  frequency of creation of a restart file (modulo referenced to 1)
    nn_write    =   10950   !  frequency of write in the output file   (modulo referenced to nn_it000)
-   ln_clobber  = .true.    !  clobber (overwrite) an existing file
+   ln_clobber  =  .true.
 /
 !-----------------------------------------------------------------------
@@ -55,8 +56,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -116,8 +113,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namagrif      !  AGRIF zoom                                            ("key_agrif")
 !-----------------------------------------------------------------------
@@ -145,13 +138,47 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namtra_ldf    !   lateral diffusion scheme for tracers 
-!-----------------------------------------------------------------------
-
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!-----------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -162,4 +189,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -168,10 +200,31 @@
 /
 !-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_dynldf_lap    =  .false.  !  laplacian operator         
-   ln_dynldf_bilap  =  .true.   !  bilaplacian operator    
-   rn_ahm_0_blp     = -8.5e+11  !  horizontal bilaplacian eddy viscosity [m4/s] 
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .true.     !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  =   0         !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 8.5e+11      !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 !-----------------------------------------------------------------------
@@ -193,8 +246,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/EXP00/namelist_cfg	(revision 6041)
@@ -48,8 +48,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -93,8 +89,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nambfr        !   bottom friction
 !-----------------------------------------------------------------------
@@ -115,4 +107,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  > 1 , 2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -120,11 +117,48 @@
 !-----------------------------------------------------------------------
 /
-!-----------------------------------------------------------------------
-&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
-!-----------------------------------------------------------------------
-/
 !----------------------------------------------------------------------------------
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.true.   ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.true.   ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.   ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21      ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
@@ -139,4 +173,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -145,6 +184,31 @@
 /
 !-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = -30         !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 !-----------------------------------------------------------------------
@@ -165,8 +229,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/cpp_ORCA2_LIM.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/cpp_ORCA2_LIM.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM/cpp_ORCA2_LIM.fcm	(revision 6041)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_asminc 
+bld::tool::fppkeys key_trabbl key_lim2 key_zdftke key_zdfddm key_zdftmx  key_mpp_mpi key_iomput
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/1_namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/1_namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/1_namelist_cfg	(revision 6041)
@@ -55,8 +55,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -116,8 +112,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namagrif      !  AGRIF zoom                                            ("key_agrif")
 !-----------------------------------------------------------------------
@@ -145,13 +137,47 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namtra_ldf    !   lateral diffusion scheme for tracers 
-!-----------------------------------------------------------------------
-
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (Standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (Triads   operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -162,4 +188,10 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   ln_dynvor_msk = .false. !  vorticity multiplied by fmask (=T) or not (=F) (all vorticity schemes)
 /
 !-----------------------------------------------------------------------
@@ -168,10 +200,31 @@
 /
 !-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_dynldf_lap    =  .false.  !  laplacian operator         
-   ln_dynldf_bilap  =  .true.   !  bilaplacian operator    
-   rn_ahm_0_blp     = -8.5e+11  !  horizontal bilaplacian eddy viscosity [m4/s] 
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .true.     !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = 20          !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 8.5e+11     !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 !-----------------------------------------------------------------------
@@ -193,8 +246,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/EXP00/namelist_cfg	(revision 6041)
@@ -48,8 +48,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -93,8 +89,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nambfr        !   bottom friction
 !-----------------------------------------------------------------------
@@ -115,4 +107,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  > 1 , 2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -123,6 +120,46 @@
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (Standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (Triads   operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.true.   ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.true.   ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.   ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21      ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+/!-----------------------------------------------------------------------
 &namtra_dmp    !   tracer: T & S newtonian damping
 !-----------------------------------------------------------------------
@@ -135,4 +172,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -144,10 +186,35 @@
    ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
    ln_hpg_prj  = .true.    !  s-coordinate (Pressure Jacobian scheme)
-   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
-                                 !           centered      time scheme  (F)
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
 /
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = -30         !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
+   !
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
 /
 !-----------------------------------------------------------------------
@@ -168,8 +235,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
@@ -191,2 +254,10 @@
 !-----------------------------------------------------------------------
 /
+!-----------------------------------------------------------------------
+&namobs       !  observation usage                                      ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/cpp_ORCA2_LIM3.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/cpp_ORCA2_LIM3.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM3/cpp_ORCA2_LIM3.fcm	(revision 6041)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_trabbl key_lim3 key_vvl key_dynspg_ts key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_asminc 
+ bld::tool::fppkeys key_trabbl key_lim3 key_vvl key_zdftke key_zdfddm key_zdftmx  key_mpp_mpi key_diaobs key_asminc key_iomput key_nosignedzero
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist_cfg	(revision 6041)
@@ -5,5 +5,5 @@
 !!                                    namsbc_cpl, namtra_qsr, namsbc_rnf, 
 !!                                    namsbc_apr, namsbc_ssr, namsbc_alb)
-!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              4 - lateral boundary (namlbc, namagrif, nambdy, nambdy_tide)
 !!              5 - bottom  boundary (nambfr, nambbc, nambbl)
 !!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
@@ -11,5 +11,5 @@
 !!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
 !!              9 - diagnostics      (namnc4, namtrd, namspr, namflo, namptr, namhsb)
-!!             10 - miscellaneous    (namsol, nammpp, nammpp_dyndist, namctl)
+!!             10 - miscellaneous    (nammpp, nammpp_dyndist, namctl)
 !!             11 - Obs & Assim      (namobs, nam_asminc)
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -86,5 +86,4 @@
                            !
    rn_rdt      = 2880.     !  time step for the dynamics (and tracer if nn_acc=0)
-   nn_baro     =   64      !  number of barotropic time step            ("key_dynspg_ts")
    rn_atfp     =    0.1    !  asselin time filter parameter
    nn_acc      =    0      !  acceleration of convergence : =1      used, rdt < rdttra(k)
@@ -302,6 +301,4 @@
 !!======================================================================
 !!   namlbc        lateral momentum boundary condition
-!!   namcla        cross land advection
-!!   namobc        open boundaries parameters                           ("key_obc")
 !!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif") 
 !!   nambdy        Unstructured open boundaries                         ("key_bdy")
@@ -314,30 +311,4 @@
    rn_shlat    =    2.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
                            !  free slip  !   partial slip  !   no slip   ! strong slip
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-   nn_cla      =    0      !  advection between 2 ocean pts separates by land
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
-   ln_obc_clim = .false.   !  climatological obc data files (T) or not (F)
-   ln_vol_cst  = .true.    !  impose the total volume conservation (T) or not (F)
-   ln_obc_fla  = .false.   !  Flather open boundary condition 
-   nn_obcdta   =    1      !  = 0 the obc data are equal to the initial state
-                           !  = 1 the obc data are read in 'obc.dta' files
-   cn_obcdta   = 'annual'  !  set to annual if obc datafile hold 1 year of data
-                           !  set to monthly if obc datafile hold 1 month of data
-   rn_dpein    =    1.     !  damping time scale for inflow at east  open boundary
-   rn_dpwin    =    1.     !     -           -         -       west    -      -
-   rn_dpnin    =    1.     !     -           -         -       north   -      -
-   rn_dpsin    =    1.     !     -           -         -       south   -      -
-   rn_dpeob    = 3000.     !  time relaxation (days) for the east  open boundary
-   rn_dpwob    =   15.     !     -           -         -     west    -      -
-   rn_dpnob    = 3000.     !     -           -         -     north   -      -
-   rn_dpsob    =   15.     !     -           -         -     south   -      -
-   rn_volemp   =    1.     !  = 0 the total volume change with the surface flux (E-P-R)
-                           !  = 1 the total volume remains constant
 /
 !-----------------------------------------------------------------------
@@ -394,5 +365,5 @@
 &nambdy_tide     ! tidal forcing at open boundaries              
 !-----------------------------------------------------------------------
-   filtide      = 'bdydta/amm12_bdytide_'         !  file name root of tidal forcing files
+    filtide       = 'bdydta/amm12_bdytide_'         !  file name root of tidal forcing files
     tide_cpt(1)   ='Q1'  !  names of tidal components used
     tide_cpt(2)   ='O1'  !  names of tidal components used
@@ -485,29 +456,48 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.  !  2nd order centered scheme   
-   ln_traadv_tvd    =  .true.   !  TVD scheme                
-   ln_traadv_muscl  =  .false.  !  MUSCL scheme             
-   ln_traadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries  
-   ln_traadv_ubs    =  .false.  !  UBS scheme                 
-   ln_traadv_qck    =  .false.  !  QUCIKEST scheme                 
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
 &namtra_ldf    !   lateral diffusion scheme for tracer 
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_traldf_lap    =  .true.   !  laplacian operator       
-   ln_traldf_bilap  =  .false.  !  bilaplacian operator     
-   !                       !  Direction of action  :
-   ln_traldf_level  =  .false.  !  iso-level                
-   ln_traldf_hor    =  .false.  !  horizontal (geopotential)            (require "key_ldfslp" when ln_sco=T)
-   ln_traldf_iso    =  .true.   !  iso-neutral                          (require "key_ldfslp")
-   ln_traldf_grif   =  .false.  !  griffies skew flux formulation       (require "key_ldfslp")  ! UNDER TEST, DO NOT USE
-   ln_traldf_gdia   =  .false.  !  griffies operator strfn diagnostics  (require "key_ldfslp")  ! UNDER TEST, DO NOT USE
-   !                       !  Coefficient
-   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
-   rn_ahtb_0        =     0.    !  background eddy diffusivity for ldf_iso [m2/s]
-   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+   !                       !  Operator type:
+   !                           !  no diffusion: set ln_traldf_lap=..._blp=F 
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity and grid-spacing)
+   rn_aht_0        = 1000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
 /
 !-----------------------------------------------------------------------
@@ -546,8 +536,10 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
-   ln_dynvor_ene = .false. !  enstrophy conserving scheme  
-   ln_dynvor_ens = .false. !  energy conserving scheme    
-   ln_dynvor_mix = .false. !  mixed scheme               
-   ln_dynvor_een = .true.  !  energy & enstrophy scheme  
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   ln_dynvor_msk = .true.  !  vorticity multiplied by fmask (=T) or not (=F) (all vorticity schemes)
 /
 !-----------------------------------------------------------------------
@@ -559,28 +551,33 @@
    ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
    ln_hpg_prj  = .false.   !  s-coordinate (Pressure Jacobian scheme)
-   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
-                                 !           centered      time scheme  (F)
-/
-!-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
-!                          !  explicit free surface                     ("key_dynspg_exp")
-!                          !  filtered free surface                     ("key_dynspg_flt")
-!                          !  split-explicit free surface               ("key_dynspg_ts")
-
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
-   !                       !  Type of the operator : 
-   ln_dynldf_lap    =  .false.  !  laplacian operator         
-   ln_dynldf_bilap  =  .true.   !  bilaplacian operator    
-   !                       !  Direction of action  : 
-   ln_dynldf_level  =  .false.  !  iso-level               
-   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
-   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .true.     !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
    !                       !  Coefficient
-   rn_ahm_0_lap     = 40000.    !  horizontal laplacian eddy viscosity   [m2/s]
-   rn_ahmb_0        =     0.    !  background eddy viscosity for ldf_iso [m2/s]
-   rn_ahm_0_blp     = -8.5e+11  !  horizontal bilaplacian eddy viscosity [m4/s] 
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 8.5e+11     !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 
@@ -700,20 +697,6 @@
 !!   nammpp_dyndist    Massively Parallel domain decomposition          ("key_agrif" && "key_mpp_dyndist")
 !!   namctl            Control prints & Benchmark
-!!   namsol            elliptic solver / island / free surface 
-!!======================================================================
-!
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
-!-----------------------------------------------------------------------
-   nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-                           !                   =2 successive-over-relaxation (sor)
-   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
-   rn_eps      =  1.e-6    !  absolute precision of the solver
-   nn_nmin     =    300    !  minimum of iterations for the SOR solver
-   nn_nmax     =    800    !  maximum of iterations for the SOR solver
-   nn_nmod     =     10    !  frequency of test for the SOR solver
-   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
-   rn_sor      =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
-/
+!!======================================================================
+!
 !-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist_top_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/1_namelist_top_cfg	(revision 6041)
@@ -39,10 +39,9 @@
 &namtrc_adv    !   advection scheme for passive tracer 
 !-----------------------------------------------------------------------
-   ln_trcadv_cen2   =  .false.  !  2nd order centered scheme   
-   ln_trcadv_tvd    =  .true.  !  TVD scheme
-   ln_trcadv_muscl  =  .false.   !  MUSCL scheme
-   ln_trcadv_muscl2 =  .false.  !  MUSCL2 scheme + cen2 at boundaries
-   ln_trcadv_ubs    =  .false.  !  UBS scheme
-   ln_trcadv_qck    =  .false.  !  QUICKEST scheme
+   ln_trcadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_cfg	(revision 6041)
@@ -67,8 +67,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -132,12 +128,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namagrif      !  AGRIF zoom                                            ("key_agrif")
 !-----------------------------------------------------------------------
@@ -176,10 +164,57 @@
 /
 !-----------------------------------------------------------------------
-&namtra_adv    !   advection scheme for tracer 
-!-----------------------------------------------------------------------     
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !----------------------------------------------------------------------------------
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   !                           !  no diffusion: set ln_traldf_lap=..._blp=F 
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity and grid-spacing)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.true.    ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.false.   ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.    ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21       ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
@@ -188,14 +223,19 @@
 /
 !-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
 &namdyn_adv    !   formulation of the momentum advection
 !-----------------------------------------------------------------------
 /  
 !-----------------------------------------------------------------------
-&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -204,9 +244,31 @@
 /
 !-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------      
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = -30         !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 !-----------------------------------------------------------------------
@@ -222,8 +284,4 @@
 !-----------------------------------------------------------------------
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-/
 !-----------------------------------------------------------------------
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
@@ -236,8 +294,4 @@
 !-----------------------------------------------------------------------
 &namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface 
 !-----------------------------------------------------------------------
 /
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_top_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/EXP00/namelist_top_cfg	(revision 6041)
@@ -24,6 +24,9 @@
 &namtrc_adv    !   advection scheme for passive tracer 
 !-----------------------------------------------------------------------   
-   ln_trcadv_tvd     =  .true.   !  TVD scheme
-   ln_trcadv_muscl   =  .false.  !  MUSCL scheme
+   ln_trcadv_fct =  .true.   !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/cpp_ORCA2_LIM_CFC_C14b.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/cpp_ORCA2_LIM_CFC_C14b.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_CFC_C14b/cpp_ORCA2_LIM_CFC_C14b.fcm	(revision 6041)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_top key_cfc key_c14b key_iomput key_mpp_mpi
+bld::tool::fppkeys key_trabbl key_lim2 key_zdftke key_zdfddm key_zdftmx key_top key_cfc key_c14b key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_cfg	(revision 6041)
@@ -48,8 +48,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -93,8 +89,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nambfr        !   bottom friction
 !-----------------------------------------------------------------------
@@ -115,4 +107,9 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
+   ln_traadv_fct =  .true.    !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  > 1 , 2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
 /
 !-----------------------------------------------------------------------
@@ -120,11 +117,48 @@
 !-----------------------------------------------------------------------
 /
-!-----------------------------------------------------------------------
-&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
-!-----------------------------------------------------------------------
-/
 !----------------------------------------------------------------------------------
 &namtra_ldf    !   lateral diffusion scheme for tracers
 !----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 20        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.true.   ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.true.   ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.   ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21      ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
@@ -139,4 +173,9 @@
 &namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
 !-----------------------------------------------------------------------
+   ln_dynvor_ene = .false. !  enstrophy conserving scheme
+   ln_dynvor_ens = .false. !  energy conserving scheme
+   ln_dynvor_mix = .false. !  mixed scheme
+   ln_dynvor_een = .true.  !  energy & enstrophy scheme
+      nn_een_e3f = 0             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
 /
 !-----------------------------------------------------------------------
@@ -145,6 +184,31 @@
 /
 !-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_ts  = .true.  !  split-explicit free surface
+/
+!-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .true.     !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_lev =  .true.     !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
+   !                       !  Coefficient
+   nn_ahm_ijk_t  = -30         !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
 /
 !-----------------------------------------------------------------------
@@ -165,8 +229,4 @@
 /
 !-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_top_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/EXP00/namelist_top_cfg	(revision 6041)
@@ -62,6 +62,6 @@
 &namtrc_adv    !   advection scheme for passive tracer 
 !-----------------------------------------------------------------------
-   ln_trcadv_tvd     =  .false.  !  TVD scheme
-   ln_trcadv_muscl   =  .true.   !  MUSCL scheme
+   ln_trcadv_mus  =  .true.  !  MUSCL scheme
+      ln_mus_ups  =  .false.         !  use upstream scheme near river mouths
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/cpp_ORCA2_LIM_PISCES.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/cpp_ORCA2_LIM_PISCES.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_LIM_PISCES/cpp_ORCA2_LIM_PISCES.fcm	(revision 6041)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_top key_pisces key_iomput key_mpp_mpi
+bld::tool::fppkeys key_trabbl key_lim2 key_zdftke key_zdfddm key_zdftmx key_top key_pisces key_mpp_mpi key_iomput
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_cfg	(revision 6041)
@@ -55,8 +55,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -78,9 +74,4 @@
 !-----------------------------------------------------------------------
 /      
-
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
 !-----------------------------------------------------------------------
 &nambbl        !   bottom boundary layer scheme
@@ -91,8 +82,48 @@
 !-----------------------------------------------------------------------
 /
-!-----------------------------------------------------------------------
-&namtra_ldf    !   lateral diffusion scheme for tracer 
-!-----------------------------------------------------------------------
-   ln_triad_iso     =  .true.  !  griffies operator calculates triads twice => pure lateral mixing in ML (require "key_ldfslp")
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+   !                       !  Operator type:
+   ln_traldf_lap   =  .true.   !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .true.   !  iso-neutral
+   ln_traldf_triad =  .false.  !  iso-neutral using Griffies triads
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .true.   !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML     (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom         (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0        !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.true.   ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.false.   ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.   ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 0      ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant
+   !                                !   = 10 F(k)      =ldf_c1d
+   !                                !   = 20 F(i,j)    =ldf_c2d
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
@@ -115,13 +146,6 @@
    sn_ubl  = 'dyna_grid_U' ,    120            , 'sobblcox' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
    sn_vbl  = 'dyna_grid_V' ,    120            , 'sobblcoy' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
-   sn_ahu  = 'dyna_grid_U' ,    120            , 'vozoahtu' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
-   sn_ahv  = 'dyna_grid_V' ,    120            , 'vomeahtv' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
-   sn_ahw  = 'dyna_grid_W' ,    120            , 'voveahtz' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
-   sn_eiu  = 'dyna_grid_U' ,    120            , 'vozoaeiu' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
-   sn_eiv  = 'dyna_grid_V' ,    120            , 'vomeaeiv' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
-   sn_eiw  = 'dyna_grid_W' ,    120            , 'soleaeiw' ,  .true.    , .true. ,   'yearly'  , ''       , ''    , ''
 !
    cn_dir      = './'      !  root directory for the location of the dynamical files
-   ln_degrad   =  .false.  !  flag for degradation -                requires ("key_degrad")
    ln_dynwzv   =  .true.   !  computation of vertical velocity instead of using the one read in file
    ln_dynbbl   =  .true.   !  bbl coef are in files, so read them - requires ("key_trabbl")
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_top_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/EXP00/namelist_top_cfg	(revision 6041)
@@ -65,6 +65,6 @@
 &namtrc_adv    !   advection scheme for passive tracer 
 !-----------------------------------------------------------------------
-   ln_trcadv_tvd     =  .false.  !  TVD scheme
-   ln_trcadv_muscl   =  .true.   !  MUSCL scheme
+   ln_trcadv_mus =  .true.   !  MUSCL scheme
+      ln_mus_ups =  .false.         !  use upstream scheme near river mouths
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/cpp_ORCA2_OFF_PISCES.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/cpp_ORCA2_OFF_PISCES.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_OFF_PISCES/cpp_ORCA2_OFF_PISCES.fcm	(revision 6041)
@@ -1,1 +1,1 @@
-bld::tool::fppkeys key_trabbl key_ldfslp key_traldf_c2d key_traldf_eiv key_top key_offline key_pisces key_iomput key_mpp_mpi
+bld::tool::fppkeys key_trabbl key_top key_offline key_pisces key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist_cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_SAS_LIM/EXP00/namelist_cfg	(revision 6041)
@@ -50,8 +50,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -87,8 +83,4 @@
 /
 !-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-/
-!-----------------------------------------------------------------------
 &nameos        !   ocean physical parameters
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_SAS_LIM/cpp_ORCA2_SAS_LIM.fcm
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_SAS_LIM/cpp_ORCA2_SAS_LIM.fcm	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/ORCA2_SAS_LIM/cpp_ORCA2_SAS_LIM.fcm	(revision 6041)
@@ -1,1 +1,1 @@
- bld::tool::fppkeys key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi
+ bld::tool::fppkeys key_trabbl key_lim2 key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/domain_def.xml
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/domain_def.xml	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/domain_def.xml	(revision 6041)
@@ -163,4 +163,5 @@
 
       <domain id="grid_V" long_name="grid V"/>
+      
       <domain_group id="grid_W">
          <domain id="grid_W" long_name="grid W"/>
@@ -168,4 +169,6 @@
          <domain id="EqW" zoom_ibegin="1" zoom_jbegin="0000" zoom_ni="0000" zoom_nj="1" />
       </domain_group>
+
+      <domain id="grid_F" long_name="grid F"/>
 
       <domain_group id="scalarpoint"> 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/field_def.xml
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/field_def.xml	(revision 6041)
@@ -25,7 +25,11 @@
 
          <field id="toce"         long_name="temperature"         standard_name="sea_water_potential_temperature"   unit="degC"     grid_ref="grid_T_3D"/>
-         <field id="toce_e3t"     long_name="temperature * e3t"                                                     unit="degC*m"   grid_ref="grid_T_3D" > toce * e3t </field >
+         <field id="toce_e3t"     long_name="temperature (thickness weighted)"                                      unit="degC"     grid_ref="grid_T_3D" > toce * e3t </field >
          <field id="soce"         long_name="salinity"            standard_name="sea_water_practical_salinity"      unit="1e-3"     grid_ref="grid_T_3D"/>
-         <field id="soce_e3t"     long_name="salinity * e3t"                                                        unit="1e-3*m"   grid_ref="grid_T_3D" > soce * e3t </field >
+         <field id="soce_e3t"     long_name="salinity    (thickness weighted)"                                      unit="1e-3"     grid_ref="grid_T_3D" > soce * e3t </field >
+
+	      <!-- t-eddy viscosity coefficients (ldfdyn) -->
+	      <field id="ahmt_2d"      long_name=" surface t-eddy viscosity coefficient"   unit="m2/s or m4/s" />
+	      <field id="ahmt_3d"      long_name=" 3D      t-eddy viscosity coefficient"   unit="m2/s or m4/s"                           grid_ref="grid_T_3D"/>
 
          <field id="sst"          long_name="sea surface temperature"             standard_name="sea_surface_temperature"             unit="degC"     />
@@ -367,5 +371,5 @@
          <field id="utau"         long_name="Wind Stress along i-axis"                               standard_name="surface_downward_x_stress"   unit="N/m2"                            />
          <field id="uoce"         long_name="ocean current along i-axis"                             standard_name="sea_water_x_velocity"        unit="m/s"        grid_ref="grid_U_3D" />
-         <field id="uoce_e3u"     long_name="ocean current along i-axis * e3u"                                                                   unit="m2/s"       grid_ref="grid_U_3D"  > uoce * e3u </field>
+         <field id="uoce_e3u"     long_name="ocean current along i-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_U_3D"  > uoce * e3u </field>
          <field id="ssu"          long_name="ocean surface current along i-axis"                                                                 unit="m/s"                             />
          <field id="sbu"          long_name="ocean bottom current along i-axis"                                                                  unit="m/s"                             />
@@ -375,8 +379,14 @@
          <field id="uoces"        long_name="ocean transport along i-axis times salinity (CRS)"                                                  unit="1e-3*m/s"   grid_ref="grid_U_3D" />
 
+	      <!-- u-eddy coefficients (ldftra) -->
+	      <field id="ahtu_2d"      long_name=" surface u-eddy diffusivity coefficient"   unit="m2/s or m4/s" />
+	      <field id="ahtu_3d"      long_name=" 3D u-EIV coefficient"                     unit="m2/s or m4/s"      grid_ref="grid_U_3D"/>
+	      <field id="aeiu_2d"      long_name=" surface u-EIV coefficient"                unit="m2/s" />
+	      <field id="aeiu_3d"      long_name=" 3D u-EIV coefficient"                     unit="m2/s"              grid_ref="grid_U_3D"/>
+
          <!-- variables available with MLE -->
          <field id="psiu_mle"     long_name="MLE streamfunction along i-axis"   unit="m3/s"   grid_ref="grid_U_3D" />
 
-         <!-- uoce_eiv: available with key_traldf_eiv and key_diaeiv -->
+         <!-- uoce_eiv: available EIV -->
          <field id="uoce_eiv"     long_name="EIV ocean current along i-axis"   standard_name="bolus_sea_water_x_velocity"   unit="m/s"   grid_ref="grid_U_3D" />
 
@@ -402,5 +412,5 @@
          <field id="vtau"         long_name="Wind Stress along j-axis"                               standard_name="surface_downward_y_stress"   unit="N/m2"                            />
          <field id="voce"         long_name="ocean current along j-axis"                             standard_name="sea_water_y_velocity"        unit="m/s"        grid_ref="grid_V_3D" />
-         <field id="voce_e3v"     long_name="ocean current along j-axis * e3v"                                                                   unit="m2/s"       grid_ref="grid_V_3D"  > voce * e3v </field>
+         <field id="voce_e3v"     long_name="ocean current along j-axis  (thickness weighted)"                                                   unit="m/s"        grid_ref="grid_V_3D"  > voce * e3v </field>
          <field id="ssv"          long_name="ocean surface current along j-axis"                                                                 unit="m/s"                             />
          <field id="sbv"          long_name="ocean bottom current along j-axis"                                                                  unit="m/s"                             />
@@ -410,8 +420,14 @@
          <field id="voces"        long_name="ocean transport along j-axis times salinity (CRS)"                                                  unit="1e-3*m/s"   grid_ref="grid_V_3D" />
 
+	      <!-- v-eddy coefficients (ldftra, ldfdyn) -->
+	      <field id="ahtv_2d"      long_name=" surface v-eddy diffusivity coefficient"     unit="m2/s or (m4/s)^1/2" />
+	      <field id="ahtv_3d"      long_name=" 3D v-eddy diffusivity coefficient"          unit="m2/s or (m4/s)^1/2"           grid_ref="grid_V_3D"/>
+	      <field id="aeiv_2d"      long_name=" surface v-EIV coefficient"                  unit="m2/s" />
+	      <field id="aeiv_3d"      long_name=" 3D v-EIV coefficient"                       unit="m2/s"                         grid_ref="grid_V_3D" />
+
          <!-- variables available with MLE -->
          <field id="psiv_mle"     long_name="MLE streamfunction along j-axis"   unit="m3/s"   grid_ref="grid_V_3D" />
 
-         <!-- voce_eiv: available with key_traldf_eiv and key_diaeiv -->
+         <!-- voce_eiv: available with EIV -->
          <field id="voce_eiv"     long_name="EIV ocean current along j-axis"   standard_name="bolus_sea_water_y_velocity"   unit="m/s"   grid_ref="grid_V_3D" />
 
@@ -438,5 +454,5 @@
         <field id="wocetr_eff"   long_name="effective ocean vertical transport"                                               unit="m3/s" />
 
-        <!-- woce_eiv: available with key_traldf_eiv and key_diaeiv -->
+        <!-- woce_eiv: available with EIV -->
         <field id="woce_eiv"     long_name="EIV ocean vertical velocity"   standard_name="bolus_upward_sea_water_velocity"   unit="m/s" />
 
@@ -449,6 +465,6 @@
 
         <!-- avt_evd and avm_evd: available with ln_zdfevd -->
-        <field id="avt_evd"      long_name="convective enhancement to vertical diffusivity"   standard_name="ocean_vertical_tracer_diffusivity_due_to_convection"     unit="m2/s" />
-        <field id="avm_evd"      long_name="convective enhancement to vertical viscosity"     standard_name="ocean_vertical_momentum_diffusivity_due_to_convection"   unit="m2/s" />
+        <field id="avt_evd"      long_name="convective enhancement of vertical diffusivity"   standard_name="ocean_vertical_tracer_diffusivity_due_to_convection"     unit="m2/s" />
+        <field id="avm_evd"      long_name="convective enhancement of vertical viscosity"     standard_name="ocean_vertical_momentum_diffusivity_due_to_convection"   unit="m2/s" />
 
         <!-- avt_tide: available with key_zdftmx -->
@@ -459,9 +475,14 @@
         <field id="w_masstr2"    long_name="square of vertical mass transport"   standard_name="square_of_upward_ocean_mass_transport"   unit="kg2/s2" />
 
-        <!-- aht2d and  aht2d_eiv: available with key_traldf_eiv and key_traldf_c2d -->
+        <!-- aht2d and  aht2d_eiv -->
         <field id="aht2d"        long_name="lateral eddy diffusivity"       standard_name="ocean_tracer_xy_laplacian_diffusivity"      unit="m2/s"   grid_ref="grid_W_2D" />
         <field id="aht2d_eiv"    long_name="EIV lateral eddy diffusivity"   standard_name="ocean_tracer_bolus_laplacian_diffusivity"   unit="m2/s"   grid_ref="grid_W_2D" />
       </field_group>
-          
+        
+      <!-- F grid -->
+	      <!-- f-eddy viscosity coefficients (ldfdyn) -->
+	      <field id="ahmf_2d"      long_name=" surface f-eddy viscosity coefficient"   unit="m2/s or m4/s" />
+	      <field id="ahmf_3d"      long_name=" 3D      f-eddy viscosity coefficient"   unit="m2/s or m4/s"                           grid_ref="grid_T_3D"/>
+
       <!-- scalar variables available with key_diaar5 -->
 
@@ -651,7 +672,4 @@
       <field id="ketrd_hpg"     long_name="ke-trend: hydrostatic pressure gradient"          unit="W/s^3"                        />
       <field id="ketrd_spg"     long_name="ke-trend: surface     pressure gradient"          unit="W/s^3"                        />
-      <field id="ketrd_spgexp"  long_name="ke-trend: surface pressure gradient (explicit)"   unit="W/s^3"                        />
-      <field id="ketrd_spgflt"  long_name="ke-trend: surface pressure gradient (filter)"     unit="W/s^3"                        />
-      <field id="ssh_flt"       long_name="filtered contribution to ssh (dynspg_flt)"        unit="m"       grid_ref="grid_T_2D" />
       <field id="w0"            long_name="surface vertical velocity"                        unit="m/s"     grid_ref="grid_T_2D" />
       <field id="pw0_exp"       long_name="surface pressure flux due to ssh"                 unit="W/s^2"   grid_ref="grid_T_2D" />
@@ -695,6 +713,4 @@
      <field id="utrd_hpg"       long_name="i-trend: hydrostatic pressure gradient"          unit="m/s^2"                        />
      <field id="utrd_spg"       long_name="i-trend: surface     pressure gradient"          unit="m/s^2"                        />
-     <field id="utrd_spgexp"    long_name="i-trend: surface pressure gradient (explicit)"   unit="m/s^2"                        />
-     <field id="utrd_spgflt"    long_name="i-trend: surface pressure gradient (filtered)"   unit="m/s^2"                        />
      <field id="utrd_keg"       long_name="i-trend: KE gradient         or hor. adv."       unit="m/s^2"                        />
      <field id="utrd_rvo"       long_name="i-trend: relative  vorticity or metric term"     unit="m/s^2"                        />
@@ -715,6 +731,4 @@
      <field id="vtrd_hpg"       long_name="j-trend: hydrostatic pressure gradient"          unit="m/s^2"                        />
      <field id="vtrd_spg"       long_name="j-trend: surface     pressure gradient"          unit="m/s^2"                        />
-     <field id="vtrd_spgexp"    long_name="j-trend: surface pressure gradient (explicit)"   unit="m/s^2"                        />
-     <field id="vtrd_spgflt"    long_name="j-trend: surface pressure gradient (filtered)"   unit="m/s^2"                        />
      <field id="vtrd_keg"       long_name="j-trend: KE gradient         or hor. adv."       unit="m/s^2"                        />
      <field id="vtrd_rvo"       long_name="j-trend: relative  vorticity or metric term"     unit="m/s^2"                        />
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/namelist_ref
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/namelist_ref	(revision 6041)
@@ -1,2 +1,4 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!!                            namelist_ref
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
 !! NEMO/OPA  :  1 - run manager      (namrun)
@@ -5,11 +7,11 @@
 !!                                    namsbc_cpl, namtra_qsr, namsbc_rnf,
 !!                                    namsbc_apr, namsbc_ssr, namsbc_alb)
-!!              4 - lateral boundary (namlbc, namcla, namobc, namagrif, nambdy, nambdy_tide)
+!!              4 - lateral boundary (namlbc, namagrif, nambdy, nambdy_tide)
 !!              5 - bottom  boundary (nambfr, nambbc, nambbl)
-!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_dmp)
+!!              6 - Tracer           (nameos, namtra_adv, namtra_ldf, namtra_ldfeiv, namtra_dmp)
 !!              7 - dynamics         (namdyn_adv, namdyn_vor, namdyn_hpg, namdyn_spg, namdyn_ldf)
-!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_kpp, namzdf_ddm, namzdf_tmx)
+!!              8 - Verical physics  (namzdf, namzdf_ric, namzdf_tke, namzdf_ddm, namzdf_tmx)
 !!              9 - diagnostics      (namnc4, namtrd, namspr, namflo, namhsb, namsto)
-!!             10 - miscellaneous    (namsol, nammpp, namctl)
+!!             10 - miscellaneous    (nammpp, namctl)
 !!             11 - Obs & Assim      (namobs, nam_asminc)
 !!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -161,19 +163,4 @@
 /
 !-----------------------------------------------------------------------
-&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
-!-----------------------------------------------------------------------
-   ln_bt_fw      =    .TRUE.           !  Forward integration of barotropic equations
-   ln_bt_av      =    .TRUE.           !  Time filtering of barotropic variables
-   ln_bt_nn_auto =    .TRUE.           !  Set nn_baro automatically to be just below
-                                       !  a user defined maximum courant number (rn_bt_cmax)
-   nn_baro       =    30               !  Number of iterations of barotropic mode
-                                       !  during rn_rdt seconds. Only used if ln_bt_nn_auto=F
-   rn_bt_cmax    =    0.8              !  Maximum courant number allowed if ln_bt_nn_auto=T
-   nn_bt_flt     =    1                !  Time filter choice
-                                       !  = 0 None
-                                       !  = 1 Boxcar over   nn_baro barotropic steps
-                                       !  = 2 Boxcar over 2*nn_baro     "        "
-/
-!-----------------------------------------------------------------------
 &namcrs        !   Grid coarsening for dynamics output and/or
                !   passive tracer coarsened online simulations
@@ -200,5 +187,4 @@
 !-----------------------------------------------------------------------
 &namtsd    !   data : Temperature  & Salinity
-!-----------------------------------------------------------------------
 !-----------------------------------------------------------------------
 !          !  file name                            ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
@@ -545,5 +531,4 @@
 !!======================================================================
 !!   namlbc        lateral momentum boundary condition
-!!   namcla        cross land advection
 !!   namobc        open boundaries parameters                           ("key_obc")
 !!   namagrif      agrif nested grid ( read by child model only )       ("key_agrif")
@@ -558,30 +543,4 @@
                            !  free slip  !   partial slip  !   no slip   ! strong slip
    ln_vorlat   = .false.   !  consistency of vorticity boundary condition with analytical eqs.
-/
-!-----------------------------------------------------------------------
-&namcla        !   cross land advection
-!-----------------------------------------------------------------------
-   nn_cla      =    0      !  advection between 2 ocean pts separates by land
-/
-!-----------------------------------------------------------------------
-&namobc        !   open boundaries parameters                           ("key_obc")
-!-----------------------------------------------------------------------
-   ln_obc_clim = .false.   !  climatological obc data files (T) or not (F)
-   ln_vol_cst  = .true.    !  impose the total volume conservation (T) or not (F)
-   ln_obc_fla  = .false.   !  Flather open boundary condition
-   nn_obcdta   =    1      !  = 0 the obc data are equal to the initial state
-                           !  = 1 the obc data are read in 'obc.dta' files
-   cn_obcdta   = 'annual'  !  set to annual if obc datafile hold 1 year of data
-                           !  set to monthly if obc datafile hold 1 month of data
-   rn_dpein    =    1.     !  damping time scale for inflow at east  open boundary
-   rn_dpwin    =    1.     !     -           -         -       west    -      -
-   rn_dpnin    =    1.     !     -           -         -       north   -      -
-   rn_dpsin    =    1.     !     -           -         -       south   -      -
-   rn_dpeob    = 3000.     !  time relaxation (days) for the east  open boundary
-   rn_dpwob    =   15.     !     -           -         -     west    -      -
-   rn_dpnob    = 3000.     !     -           -         -     north   -      -
-   rn_dpsob    =   15.     !     -           -         -     south   -      -
-   rn_volemp   =    1.     !  = 0 the total volume change with the surface flux (E-P-R)
-                           !  = 1 the total volume remains constant
 /
 !-----------------------------------------------------------------------
@@ -711,5 +670,4 @@
                            !     = 2 variable flux (read in geothermal_heating.nc in mW/m2)
    rn_geoflx_cst = 86.4e-3 !  Constant value of geothermal heat flux [W/m2]
-
 /
 !-----------------------------------------------------------------------
@@ -725,9 +683,10 @@
 !!                        Tracer (T & S ) namelists
 !!======================================================================
-!!   nameos        equation of state
-!!   namtra_adv    advection scheme
+!!   nameos           equation of state
+!!   namtra_adv       advection scheme
 !!   namtra_adv_mle   mixed layer eddy param. (Fox-Kemper param.)
-!!   namtra_ldf    lateral diffusion scheme
-!!   namtra_dmp    T & S newtonian damping
+!!   namtra_ldf       lateral diffusion scheme
+!!   namtra_ldfeiv    eddy induced velocity param.
+!!   namtra_dmp       T & S newtonian damping
 !!======================================================================
 !
@@ -740,7 +699,7 @@
                                  !  = 1, S-EOS   (simplified eos)
    ln_useCT    = .true.  ! use of Conservative Temp. ==> surface CT converted in Pot. Temp. in sbcssm
-   !                             !
+                                 !
    !                     ! S-EOS coefficients :
-   !                             !  rd(T,S,Z)*rau0 = -a0*(1+.5*lambda*dT+mu*Z+nu*dS)*dT+b0*dS
+                                 !  rd(T,S,Z)*rau0 = -a0*(1+.5*lambda*dT+mu*Z+nu*dS)*dT+b0*dS
    rn_a0       =  1.6550e-1      !  thermal expension coefficient (nn_eos= 1)
    rn_b0       =  7.6554e-1      !  saline  expension coefficient (nn_eos= 1)
@@ -754,17 +713,22 @@
 &namtra_adv    !   advection scheme for tracer
 !-----------------------------------------------------------------------
-   ln_traadv_cen2   =  .false.   !  2nd order centered scheme
-   ln_traadv_tvd    =  .true.    !  TVD scheme
-   ln_traadv_muscl  =  .false.   !  MUSCL scheme
-   ln_traadv_muscl2 =  .false.   !  MUSCL2 scheme + cen2 at boundaries
-   ln_traadv_ubs    =  .false.   !  UBS scheme
-   ln_traadv_qck    =  .false.   !  QUICKEST scheme
-   ln_traadv_msc_ups=  .false.   !  use upstream scheme within muscl
-   ln_traadv_tvd_zts=  .false.  !  TVD scheme with sub-timestepping of vertical tracer advection
+   ln_traadv_cen =  .false.  !  2nd order centered scheme
+      nn_cen_h   =  4               !  =2/4, horizontal 2nd order CEN / 4th order CEN
+      nn_cen_v   =  4               !  =2/4, vertical   2nd order CEN / 4th order COMPACT
+   ln_traadv_fct =  .false.  !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
+   ln_traadv_mus =  .false.  !  MUSCL scheme
+      ln_mus_ups =  .false.         !  use upstream scheme near river mouths
+   ln_traadv_ubs =  .false.  !  UBS scheme
+      nn_ubs_v   =  2               !  =2  , vertical 2nd order FCT
+   ln_traadv_qck =  .false.  !  QUICKEST scheme
 /
 !-----------------------------------------------------------------------
 &namtra_adv_mle !   mixed layer eddy parametrisation (Fox-Kemper param)
 !-----------------------------------------------------------------------
-   ln_mle    = .true.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
+   ln_mle    = .false.      ! (T) use the Mixed Layer Eddy (MLE) parameterisation
    rn_ce     = 0.06        ! magnitude of the MLE (typical value: 0.06 to 0.08)
    nn_mle    = 1           ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
@@ -780,27 +744,45 @@
 !----------------------------------------------------------------------------------
    !                       !  Operator type:
-   ln_traldf_lap    =  .true.   !  laplacian operator
-   ln_traldf_bilap  =  .false.  !  bilaplacian operator
+   !                           !  no diffusion: set ln_traldf_lap=..._blp=F 
+   ln_traldf_lap   =  .false.  !    laplacian operator
+   ln_traldf_blp   =  .false.  !  bilaplacian operator
    !                       !  Direction of action:
-   ln_traldf_level  =  .false.  !  iso-level
-   ln_traldf_hor    =  .false.  !  horizontal (geopotential)   (needs "key_ldfslp" when ln_sco=T)
-   ln_traldf_iso    =  .true.   !  iso-neutral                 (needs "key_ldfslp")
-   !		       	   !  Griffies parameters              (all need "key_ldfslp")
-   ln_traldf_grif   =  .false.  !  use griffies triads
-   ln_traldf_gdia   =  .false.  !  output griffies eddy velocities
-   ln_triad_iso     =  .false.  !  pure lateral mixing in ML
-   ln_botmix_grif   =  .false.  !  lateral mixing on bottom
-   !                       !  Coefficients
-   ! Eddy-induced (GM) advection always used with Griffies; otherwise needs "key_traldf_eiv"
-   ! Value rn_aeiv_0 is ignored unless = 0 with Held-Larichev spatially varying aeiv
-   !                                  (key_traldf_c2d & key_traldf_eiv & key_orca_r2, _r1 or _r05)
-   rn_aeiv_0        =  2000.    !  eddy induced velocity coefficient [m2/s]
-   rn_aht_0         =  2000.    !  horizontal eddy diffusivity for tracers [m2/s]
-   rn_ahtb_0        =     0.    !  background eddy diffusivity for ldf_iso [m2/s]
-   !                                           (normally=0; not used with Griffies)
-   rn_slpmax        =     0.01  !  slope limit
-   rn_chsmag        =     1.    !  multiplicative factor in Smagorinsky diffusivity
-   rn_smsh          =     1.    !  Smagorinsky diffusivity: = 0 - use only sheer
-   rn_aht_m         =  2000.    !  upper limit or stability criteria for lateral eddy diffusivity (m2/s)
+   ln_traldf_lev   =  .false.  !  iso-level
+   ln_traldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_traldf_iso   =  .false.  !  iso-neutral (standard operator)
+   ln_traldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !
+   !		       	         !  iso-neutral options:        
+   ln_traldf_msc   =  .false.  !  Method of Stabilizing Correction (both operators)
+   rn_slpmax       =   0.01    !  slope limit                      (both operators)
+   ln_triad_iso    =  .false.  !  pure horizontal mixing in ML              (triad only)
+   rn_sw_triad     =  1        !  =1 switching triad ; =0 all 4 triads used (triad only)
+   ln_botmix_triad =  .false.  !  lateral mixing on bottom                  (triad only)
+   !
+   !                       !  Coefficients:
+   nn_aht_ijk_t    = 0         !  space/time variation of eddy coef
+   !                                !   =-20 (=-30)    read in eddy_diffusivity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d * ldf_c1d
+   !                                !   = 31 F(i,j,k,t)=F(local velocity and grid-spacing)
+   rn_aht_0        = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bht_0        = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
+/
+!----------------------------------------------------------------------------------
+&namtra_ldfeiv !   eddy induced velocity param.
+!----------------------------------------------------------------------------------
+   ln_ldfeiv     =.false.   ! use eddy induced velocity parameterization
+   ln_ldfeiv_dia =.false.   ! diagnose eiv stream function and velocities
+   rn_aeiv_0     = 2000.    ! eddy induced velocity coefficient   [m2/s]
+   nn_aei_ijk_t  = 21       ! space/time variation of the eiv coeficient
+   !                                !   =-20 (=-30)    read in eddy_induced_velocity_2D.nc (..._3D.nc) file
+   !                                !   =  0           constant 
+   !                                !   = 10 F(k)      =ldf_c1d 
+   !                                !   = 20 F(i,j)    =ldf_c2d 
+   !                                !   = 21 F(i,j,t)  =Treguier et al. JPO 1997 formulation
+   !                                !   = 30 F(i,j,k)  =ldf_c2d + ldf_c1d
 /
 !-----------------------------------------------------------------------
@@ -820,5 +802,5 @@
 !!   namdyn_vor    advection scheme
 !!   namdyn_hpg    hydrostatic pressure gradient
-!!   namdyn_spg    surface pressure gradient                            (CPP key only)
+!!   namdyn_spg    surface pressure gradient
 !!   namdyn_ldf    lateral diffusion scheme
 !!======================================================================
@@ -853,6 +835,7 @@
    ln_dynvor_ens = .false. !  energy conserving scheme
    ln_dynvor_mix = .false. !  mixed scheme
-   ln_dynvor_een = .true.  !  energy & enstrophy scheme
-   ln_dynvor_een_old = .false.  !  energy & enstrophy scheme - original formulation
+   ln_dynvor_een = .false. !  energy & enstrophy scheme
+      nn_een_e3f = 1             !  e3f = masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   ln_dynvor_msk = .false. !  vorticity multiplied by fmask (=T) or not (=F) (all vorticity schemes)  ! PLEASE DO NOT USE
 /
 !-----------------------------------------------------------------------
@@ -865,33 +848,44 @@
    ln_hpg_djc  = .false.   !  s-coordinate (Density Jacobian with Cubic polynomial)
    ln_hpg_prj  = .false.   !  s-coordinate (Pressure Jacobian scheme)
-   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
-                                 !           centered      time scheme  (F)
-/
-!-----------------------------------------------------------------------
-!namdyn_spg    !   surface pressure gradient   (CPP key only)
-!-----------------------------------------------------------------------
-!                          !  explicit free surface                     ("key_dynspg_exp")
-!                          !  filtered free surface                     ("key_dynspg_flt")
-!                          !  split-explicit free surface               ("key_dynspg_ts")
-
+/
+!-----------------------------------------------------------------------
+&namdyn_spg    !   surface pressure gradient
+!-----------------------------------------------------------------------
+   ln_dynspg_exp  = .false.   ! explicit free surface
+   ln_dynspg_ts   = .false.   ! split-explicit free surface
+      ln_bt_fw      = .true.    ! Forward integration of barotropic Eqs.
+      ln_bt_av      = .true.    ! Time filtering of barotropic variables
+         nn_bt_flt    =  1        ! Time filter choice  = 0 None
+         !                        !                     = 1 Boxcar over   nn_baro sub-steps
+         !                        !                     = 2 Boxcar over 2*nn_baro  "    "
+      ln_bt_auto    = .true.    ! Number of sub-step defined from:
+         rn_bt_cmax   =  0.8      ! =T : the Maximum Courant Number allowed
+         nn_baro      = 30        ! =F : the number of sub-step in rn_rdt seconds
+/
 !-----------------------------------------------------------------------
 &namdyn_ldf    !   lateral diffusion on momentum
 !-----------------------------------------------------------------------
    !                       !  Type of the operator :
-   ln_dynldf_lap    =  .true.   !  laplacian operator
-   ln_dynldf_bilap  =  .false.  !  bilaplacian operator
+   !                           !  no diffusion: set ln_dynldf_lap=..._blp=F 
+   ln_dynldf_lap =  .false.    !    laplacian operator
+   ln_dynldf_blp =  .false.    !  bilaplacian operator
    !                       !  Direction of action  :
-   ln_dynldf_level  =  .false.  !  iso-level
-   ln_dynldf_hor    =  .true.   !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
-   ln_dynldf_iso    =  .false.  !  iso-neutral                          (require "key_ldfslp")
+   ln_dynldf_lev =  .false.    !  iso-level
+   ln_dynldf_hor =  .false.    !  horizontal (geopotential)
+   ln_dynldf_iso =  .false.    !  iso-neutral
    !                       !  Coefficient
-   rn_ahm_0_lap     = 40000.    !  horizontal laplacian eddy viscosity   [m2/s]
-   rn_ahmb_0        =     0.    !  background eddy viscosity for ldf_iso [m2/s]
-   rn_ahm_0_blp     =     0.    !  horizontal bilaplacian eddy viscosity [m4/s]
-   rn_cmsmag_1      =     3.    !  constant in laplacian Smagorinsky viscosity
-   rn_cmsmag_2      =     3     !  constant in bilaplacian Smagorinsky viscosity
-   rn_cmsh          =     1.    !  1 or 0 , if 0 -use only shear for Smagorinsky viscosity
-   rn_ahm_m_blp     =    -1.e12 !  upper limit for bilap  abs(ahm) < min( dx^4/128rdt, rn_ahm_m_blp)
-   rn_ahm_m_lap     = 40000.    !  upper limit for lap  ahm < min(dx^2/16rdt, rn_ahm_m_lap)
+   nn_ahm_ijk_t  = 0           !  space/time variation of eddy coef
+   !                                !  =-30  read in eddy_viscosity_3D.nc file
+   !                                !  =-20  read in eddy_viscosity_2D.nc file
+   !                                !  =  0  constant 
+   !                                !  = 10  F(k)=c1d
+   !                                !  = 20  F(i,j)=F(grid spacing)=c2d
+   !                                !  = 30  F(i,j,k)=c2d*c1d
+   !                                !  = 31  F(i,j,k)=F(grid spacing and local velocity)
+   rn_ahm_0      =  40000.     !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_b      =      0.     !  background eddy viscosity for ldf_iso [m2/s]
+   rn_bhm_0      = 1.e+12      !  horizontal bilaplacian eddy viscosity [m4/s]
+   !
+   ! Caution in 20 and 30 cases the coefficient have to be given for a 1 degree grid (~111km)
 /
 
@@ -902,5 +896,4 @@
 !!    namzdf_ric    richardson number dependent vertical mixing         ("key_zdfric")
 !!    namzdf_tke    TKE dependent vertical mixing                       ("key_zdftke")
-!!    namzdf_kpp    KPP dependent vertical mixing                       ("key_zdfkpp")
 !!    namzdf_ddm    double diffusive mixing parameterization            ("key_zdfddm")
 !!    namzdf_tmx    tidal mixing parameterization                       ("key_zdftmx")
@@ -964,17 +957,4 @@
                            !        = 1  0.5m at the equator to 30m poleward of 40 degrees
 /
-!------------------------------------------------------------------------
-&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
-!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
-   ln_kpprimix = .true.    !  shear instability mixing
-   rn_difmiw   =  1.0e-04  !  constant internal wave viscosity [m2/s]
-   rn_difsiw   =  0.1e-04  !  constant internal wave diffusivity [m2/s]
-   rn_riinfty  =  0.8      !  local Richardson Number limit for shear instability
-   rn_difri    =  0.0050   !  maximum shear mixing at Rig = 0    [m2/s]
-   rn_bvsqcon  = -0.01e-07 !  Brunt-Vaisala squared for maximum convection [1/s2]
-   rn_difcon   =  1.       !  maximum mixing in interior convection [m2/s]
-   nn_avb      =  0        !  horizontal averaged (=1) or not (=0) on avt and amv
-   nn_ave      =  1        !  constant (=0) or profile (=1) background on avt
-/
 !-----------------------------------------------------------------------
 &namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
@@ -1015,5 +995,4 @@
 !!                  ***  Miscellaneous namelists  ***
 !!======================================================================
-!!   namsol            elliptic solver / island / free surface
 !!   nammpp            Massively Parallel Processing                    ("key_mpp_mpi)
 !!   namctl            Control prints & Benchmark
@@ -1024,17 +1003,4 @@
 !!======================================================================
 !
-!-----------------------------------------------------------------------
-&namsol        !   elliptic solver / island / free surface
-!-----------------------------------------------------------------------
-   nn_solv     =      1    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
-                           !                   =2 successive-over-relaxation (sor)
-   nn_sol_arp  =      0    !  absolute/relative (0/1) precision convergence test
-   rn_eps      =  1.e-6    !  absolute precision of the solver
-   nn_nmin     =    300    !  minimum of iterations for the SOR solver
-   nn_nmax     =    800    !  maximum of iterations for the SOR solver
-   nn_nmod     =     10    !  frequency of test for the SOR solver
-   rn_resmax   =  1.e-10   !  absolute precision for the SOR solver
-   rn_sor      =  1.92     !  optimal coefficient for SOR solver (to be adjusted with the domain)
-/
 !-----------------------------------------------------------------------
 &nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/namelist_top_ref
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/namelist_top_ref	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/CONFIG/SHARED/namelist_top_ref	(revision 6041)
@@ -41,25 +41,32 @@
 &namtrc_adv    !   advection scheme for passive tracer 
 !-----------------------------------------------------------------------
-   ln_trcadv_cen2    =  .false.  !  2nd order centered scheme   
-   ln_trcadv_tvd     =  .true.  !  TVD scheme
-   ln_trcadv_muscl   =  .false.   !  MUSCL scheme
-   ln_trcadv_muscl2  =  .false.  !  MUSCL2 scheme + cen2 at boundaries
-   ln_trcadv_ubs     =  .false.  !  UBS scheme
-   ln_trcadv_qck     =  .false.  !  QUICKEST scheme
-   ln_trcadv_msc_ups =  .false.  !  use upstream scheme within muscl
+   ln_trcadv_cen =  .false.  !  2nd order centered scheme
+      nn_cen_h   =  4               !  =2/4, horizontal 2nd order CEN / 4th order CEN
+      nn_cen_v   =  4               !  =2/4, vertical   2nd order CEN / 4th order COMPACT
+   ln_trcadv_fct =  .false.  !  FCT scheme
+      nn_fct_h   =  2               !  =2/4, horizontal 2nd / 4th order 
+      nn_fct_v   =  2               !  =2/4, vertical   2nd / COMPACT 4th order 
+      nn_fct_zts =  0               !  >=1,  2nd order FCT scheme with vertical sub-timestepping
+      !                             !        (number of sub-timestep = nn_fct_zts)
+   ln_trcadv_mus =  .false.  !  MUSCL scheme
+      ln_mus_ups =  .false.         !  use upstream scheme near river mouths
+   ln_trcadv_ubs =  .false.  !  UBS scheme
+      nn_ubs_v   =  2               !  =2  , vertical 2nd order FCT
+   ln_trcadv_qck =  .false.  !  QUICKEST scheme
 /
 !-----------------------------------------------------------------------
 &namtrc_ldf    !   lateral diffusion scheme for passive tracer 
 !-----------------------------------------------------------------------
-!                               !  Type of the operator : 
-   ln_trcldf_lap    =  .true.   !     laplacian operator       
-   ln_trcldf_bilap  =  .false.  !     bilaplacian operator     
-                                !  Direction of action  :
-   ln_trcldf_level  =  .false.  !     iso-level                
-   ln_trcldf_hor    =  .false.  !     horizontal (geopotential)         (require "key_ldfslp" when ln_sco=T)
-   ln_trcldf_iso    =  .true.   !     iso-neutral                       (require "key_ldfslp")
-!                               !  Coefficient
-   rn_ahtrc_0       =  2000.    !  horizontal eddy diffusivity for tracers [m2/s]
-   rn_ahtrb_0       =     0.    !     background eddy diffusivity for ldf_iso [m2/s]
+!                          !  Type of the operator:  
+   ln_trcldf_lap   =  .true.   !    laplacian operator
+   ln_trcldf_blp   =  .false.  !  bilaplacian operator
+   !                       !  Direction of action:
+   ln_trcldf_lev   =  .false.  !  iso-level
+   ln_trcldf_hor   =  .false.  !  horizontal (geopotential)
+   ln_trcldf_iso   =  .true.   !  iso-neutral (standard operator)
+   ln_trcldf_triad =  .false.  !  iso-neutral (triad    operator)
+   !                       !  Coefficient 
+   rn_ahtrc_0      = 2000.     !  lateral eddy diffusivity   (lap. operator) [m2/s]
+   rn_bhtrc_0      = 1.e+12    !  lateral eddy diffusivity (bilap. operator) [m4/s]
 /
 !-----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limdmp_2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limdmp_2.F90	(revision 6041)
@@ -71,8 +71,6 @@
          CALL fld_read( kt, nn_fsbc, sf_icedmp )
          !
-!CDIR COLLAPSE
          hicif(:,:) = MAX( 0._wp,                     &        ! h >= 0         avoid spurious out of physical range
             &         hicif(:,:) - rdt_ice * resto_ice(:,:,1) * ( hicif(:,:) - sf_icedmp(jp_hicif)%fnow(:,:,1) )  ) 
-!CDIR COLLAPSE
          frld (:,:) = MAX( 0._wp, MIN( 1._wp,         &        ! 0<= frld<=1    values which blow the run up
             &         frld (:,:) - rdt_ice * resto_ice(:,:,1) * ( frld (:,:) - sf_icedmp(jp_frld )%fnow(:,:,1) )  )  )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limrhg_2.F90	(revision 6041)
@@ -160,7 +160,5 @@
       !-------------------------------------------------------------------
 
-!CDIR NOVERRCHK
       DO jj = k_j1 , k_jpj-1
-!CDIR NOVERRCHK
          DO ji = 1 , jpi
             ! only the sinus changes its sign with the hemisphere
@@ -245,7 +243,5 @@
          ! Computation of free drift field for free slip boundary conditions.
 
-!CDIR NOVERRCHK
          DO jj = k_j1, k_jpj-1
-!CDIR NOVERRCHK
             DO ji = 1, fs_jpim1
                !- Rate of strain tensor.
@@ -401,7 +397,5 @@
 iflag:   DO jter = 1 , nbitdr                                   !    Relaxation    !
             !                                                   ! ================ !
-!CDIR NOVERRCHK
             DO jj = k_j1+1, k_jpj-1
-!CDIR NOVERRCHK
                DO ji = 2, fs_jpim1   ! NO vector opt.
                   !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limsbc_2.F90	(revision 6041)
@@ -319,7 +319,6 @@
          !
          IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !==  Ice time-step only  ==! (i.e. surface module time-step)
-!CDIR NOVERRCHK
+            !
             DO jj = 1, jpj                               !* modulus of ice-ocean relative velocity at I-point
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   zu_i  = u_ice(ji,jj) - u_oce(ji,jj)                   ! ice-ocean relative velocity at I-point
@@ -328,7 +327,5 @@
                END DO
             END DO
-!CDIR NOVERRCHK
             DO jj = 1, jpjm1                             !* update the modulus of stress at ocean surface (T-point)
-!CDIR NOVERRCHK
                DO ji = 1, jpim1   ! NO vector opt.
                   !                                               ! modulus of U_ice-U_oce at T-point
@@ -383,7 +380,6 @@
          !
          IF( MOD( kt-1, nn_fsbc ) == 0 ) THEN     !==  Ice time-step only  ==! (i.e. surface module time-step)
-!CDIR NOVERRCHK
+            !
             DO jj = 2, jpjm1                          !* modulus of the ice-ocean velocity at T-point
-!CDIR NOVERRCHK
                DO ji = fs_2, fs_jpim1
                   zu_t  = u_ice(ji,jj) + u_ice(ji-1,jj) - u_oce(ji,jj) - u_oce(ji-1,jj)   ! 2*(U_ice-U_oce) at T-point
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limthd_2.F90	(revision 6041)
@@ -196,7 +196,5 @@
       !--------------------------------------------------------------------------
 
-      !CDIR NOVERRCHK
       DO jj = 1, jpj
-         !CDIR NOVERRCHK
          DO ji = 1, jpi
             zthsnice       = hsnif(ji,jj) + hicif(ji,jj)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limthd_lac_2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_2/limthd_lac_2.F90	(revision 6041)
@@ -134,5 +134,4 @@
       !---------------------------------------------------------------------
       
-!CDIR NOVERRCHK
       DO ji = kideb , kiut
          iicefr       = 1 - MAX( 0, INT( SIGN( 1.5 * zone , zfrl_old(ji) - 1.0 + epsi13 ) ) )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limadv.F90	(revision 6041)
@@ -97,5 +97,5 @@
 
       !  Initialize volumes of boxes  (=area if adv_x first called, =psm otherwise)                                     
-      psm (:,:)  = MAX( pcrh * e12t(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
+      psm (:,:)  = MAX( pcrh * e1e2t(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20 )
 
       !  Calculate fluxes and moments between boxes i<-->i+1              
@@ -282,5 +282,5 @@
 
       !  Initialize volumes of boxes (=area if adv_x first called, =psm otherwise)
-      psm(:,:)  = MAX(  pcrh * e12t(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20  )
+      psm(:,:)  = MAX(  pcrh * e1e2t(:,:) + ( 1.0 - pcrh ) * psm(:,:) , epsi20  )
 
       !  Calculate fluxes and moments between boxes j<-->j+1              
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limcons.F90	(revision 6041)
@@ -185,23 +185,23 @@
          zfs_b  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
             &                  sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:)                                  &
-            &                ) *  e12t(:,:) * tmask(:,:,1) * zconv )
+            &                ) *  e1e2t(:,:) * tmask(:,:,1) * zconv )
 
          ! water flux
          zfw_b  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) + wfx_opw(:,:) +  &
             &                  wfx_res(:,:) + wfx_dyn(:,:) + wfx_snw(:,:) + wfx_sub(:,:) + wfx_spr(:,:)    &
-            &                ) *  e12t(:,:) * tmask(:,:,1) * zconv )
+            &                ) *  e1e2t(:,:) * tmask(:,:,1) * zconv )
 
          ! heat flux
          zft_b  = glob_sum(  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
             &                - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
-            &                ) *  e12t(:,:) * tmask(:,:,1) * zconv )
-
-         zvi_b  = glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 ) * e12t * tmask(:,:,1) * zconv )
-
-         zsmv_b = glob_sum( SUM( smv_i * rhoic            , dim=3 ) * e12t * tmask(:,:,1) * zconv )
+            &                ) *  e1e2t(:,:) * tmask(:,:,1) * zconv )
+
+         zvi_b  = glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 ) * e1e2t * tmask(:,:,1) * zconv )
+
+         zsmv_b = glob_sum( SUM( smv_i * rhoic            , dim=3 ) * e1e2t * tmask(:,:,1) * zconv )
 
          zei_b  = glob_sum( ( SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 ) +  &
             &                 SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 )    &
-                            ) * e12t * tmask(:,:,1) * zconv )
+                            ) * e1e2t * tmask(:,:,1) * zconv )
 
       ELSEIF( icount == 1 ) THEN
@@ -210,30 +210,30 @@
          zfs  = glob_sum(  ( sfx_bri(:,:) + sfx_bog(:,:) + sfx_bom(:,:) + sfx_sum(:,:) + sfx_sni(:,:) +  &
             &                sfx_opw(:,:) + sfx_res(:,:) + sfx_dyn(:,:)                                  & 
-            &              ) * e12t(:,:) * tmask(:,:,1) * zconv ) - zfs_b
+            &              ) * e1e2t(:,:) * tmask(:,:,1) * zconv ) - zfs_b
 
          ! water flux
          zfw  = glob_sum( -( wfx_bog(:,:) + wfx_bom(:,:) + wfx_sum(:,:) + wfx_sni(:,:) + wfx_opw(:,:) +  &
             &                wfx_res(:,:) + wfx_dyn(:,:) + wfx_snw(:,:) + wfx_sub(:,:) + wfx_spr(:,:)    &
-            &              ) * e12t(:,:) * tmask(:,:,1) * zconv ) - zfw_b
+            &              ) * e1e2t(:,:) * tmask(:,:,1) * zconv ) - zfw_b
 
          ! heat flux
          zft  = glob_sum(  ( hfx_sum(:,:) + hfx_bom(:,:) + hfx_bog(:,:) + hfx_dif(:,:) + hfx_opw(:,:) + hfx_snw(:,:)  & 
             &              - hfx_thd(:,:) - hfx_dyn(:,:) - hfx_res(:,:) - hfx_sub(:,:) - hfx_spr(:,:)   &
-            &              ) * e12t(:,:) * tmask(:,:,1) * zconv ) - zft_b
+            &              ) * e1e2t(:,:) * tmask(:,:,1) * zconv ) - zft_b
  
          ! outputs
          zvi  = ( ( glob_sum( SUM( v_i * rhoic + v_s * rhosn, dim=3 )  &
-            &                    * e12t * tmask(:,:,1) * zconv ) - zvi_b ) * r1_rdtice - zfw ) * rday
+            &                    * e1e2t * tmask(:,:,1) * zconv ) - zvi_b ) * r1_rdtice - zfw ) * rday
 
          zsmv = ( ( glob_sum( SUM( smv_i * rhoic            , dim=3 )  &
-            &                    * e12t * tmask(:,:,1) * zconv ) - zsmv_b ) * r1_rdtice + zfs ) * rday
+            &                    * e1e2t * tmask(:,:,1) * zconv ) - zsmv_b ) * r1_rdtice + zfs ) * rday
 
          zei  =   glob_sum( ( SUM( SUM( e_i(:,:,1:nlay_i,:), dim=4 ), dim=3 ) +  &
             &                 SUM( SUM( e_s(:,:,1:nlay_s,:), dim=4 ), dim=3 )    &
-            &                ) * e12t * tmask(:,:,1) * zconv ) * r1_rdtice - zei_b * r1_rdtice + zft
+            &                ) * e1e2t * tmask(:,:,1) * zconv ) * r1_rdtice - zei_b * r1_rdtice + zft
 
          ! zvtrp and zetrp must be close to 0 if the advection scheme is conservative
-         zvtrp = glob_sum( ( diag_trp_vi * rhoic + diag_trp_vs * rhosn ) * e12t * tmask(:,:,1) * zconv ) * rday 
-         zetrp = glob_sum( ( diag_trp_ei         + diag_trp_es         ) * e12t * tmask(:,:,1) * zconv )
+         zvtrp = glob_sum( ( diag_trp_vi * rhoic + diag_trp_vs * rhosn ) * e1e2t * tmask(:,:,1) * zconv ) * rday 
+         zetrp = glob_sum( ( diag_trp_ei         + diag_trp_es         ) * e1e2t * tmask(:,:,1) * zconv )
 
          zvmin = glob_min( v_i )
@@ -242,5 +242,5 @@
 
          ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice) 
-         zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e12t * zconv ) ! in 1.e9 m2
+         zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e1e2t * zconv ) ! in 1.e9 m2
          zv_sill = zarea * 2.5e-5
          zs_sill = zarea * 25.e-5
@@ -286,12 +286,12 @@
 #if ! defined key_bdy
       ! heat flux
-      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es - hfx_sub ) * e12t * tmask(:,:,1) * zconv ) 
+      zhfx  = glob_sum( ( hfx_in - hfx_out - diag_heat - diag_trp_ei - diag_trp_es - hfx_sub ) * e1e2t * tmask(:,:,1) * zconv ) 
       ! salt flux
-      zsfx  = glob_sum( ( sfx + diag_smvi ) * e12t * tmask(:,:,1) * zconv ) * rday
+      zsfx  = glob_sum( ( sfx + diag_smvi ) * e1e2t * tmask(:,:,1) * zconv ) * rday
       ! water flux
-      zvfx  = glob_sum( ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e12t * tmask(:,:,1) * zconv ) * rday
+      zvfx  = glob_sum( ( wfx_ice + wfx_snw + wfx_spr + wfx_sub + diag_vice + diag_vsnw ) * e1e2t * tmask(:,:,1) * zconv ) * rday
 
       ! set threshold values and calculate the ice area (+epsi10 to set a threshold > 0 when there is no ice) 
-      zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e12t * zconv ) ! in 1.e9 m2
+      zarea   = glob_sum( SUM( a_i + epsi10, dim=3 ) * e1e2t * zconv ) ! in 1.e9 m2
       zv_sill = zarea * 2.5e-5
       zs_sill = zarea * 25.e-5
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limctl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limctl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limctl.F90	(revision 6041)
@@ -306,5 +306,5 @@
                WRITE(numout,*) ' - Cell values '
                WRITE(numout,*) '   ~~~~~~~~~~~ '
-               WRITE(numout,*) ' cell area     : ', e12t(ji,jj)
+               WRITE(numout,*) ' cell area     : ', e1e2t(ji,jj)
                WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
                WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
@@ -350,5 +350,5 @@
                WRITE(numout,*) ' - Cell values '
                WRITE(numout,*) '   ~~~~~~~~~~~ '
-               WRITE(numout,*) ' cell area     : ', e12t(ji,jj)
+               WRITE(numout,*) ' cell area     : ', e1e2t(ji,jj)
                WRITE(numout,*) ' at_i          : ', at_i(ji,jj)       
                WRITE(numout,*) ' vt_i          : ', vt_i(ji,jj)       
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limdiahsb.F90	(revision 6041)
@@ -71,72 +71,72 @@
 
       ! 1/area
-      z1_area = 1._wp / MAX( glob_sum( e12t(:,:) * tmask(:,:,1) ), epsi06 )
-
-      rswitch = MAX( 0._wp , SIGN( 1._wp , glob_sum( e12t(:,:) * tmask(:,:,1) ) - epsi06 ) )
+      z1_area = 1._wp / MAX( glob_sum( e1e2t(:,:) * tmask(:,:,1) ), epsi06 )
+
+      rswitch = MAX( 0._wp , SIGN( 1._wp , glob_sum( e1e2t(:,:) * tmask(:,:,1) ) - epsi06 ) )
       ! ----------------------- !
       ! 1 -  Content variations !
       ! ----------------------- !
-      zbg_ivo = glob_sum( vt_i(:,:) * e12t(:,:) * tmask(:,:,1) ) ! volume ice 
-      zbg_svo = glob_sum( vt_s(:,:) * e12t(:,:) * tmask(:,:,1) ) ! volume snow
-      zbg_are = glob_sum( at_i(:,:) * e12t(:,:) * tmask(:,:,1) ) ! area
-      zbg_sal = glob_sum( SUM( smv_i(:,:,:), dim=3 ) * e12t(:,:) * tmask(:,:,1) )       ! mean salt content
-      zbg_tem = glob_sum( ( tm_i(:,:) - rt0 ) * vt_i(:,:) * e12t(:,:) * tmask(:,:,1) )  ! mean temp content
-
-      !zbg_ihc = glob_sum( et_i(:,:) * e12t(:,:) * tmask(:,:,1) ) / MAX( zbg_ivo,epsi06 ) ! ice heat content
-      !zbg_shc = glob_sum( et_s(:,:) * e12t(:,:) * tmask(:,:,1) ) / MAX( zbg_svo,epsi06 ) ! snow heat content
+      zbg_ivo = glob_sum( vt_i(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! volume ice 
+      zbg_svo = glob_sum( vt_s(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! volume snow
+      zbg_are = glob_sum( at_i(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! area
+      zbg_sal = glob_sum( SUM( smv_i(:,:,:), dim=3 ) * e1e2t(:,:) * tmask(:,:,1) )       ! mean salt content
+      zbg_tem = glob_sum( ( tm_i(:,:) - rt0 ) * vt_i(:,:) * e1e2t(:,:) * tmask(:,:,1) )  ! mean temp content
+
+      !zbg_ihc = glob_sum( et_i(:,:) * e1e2t(:,:) * tmask(:,:,1) ) / MAX( zbg_ivo,epsi06 ) ! ice heat content
+      !zbg_shc = glob_sum( et_s(:,:) * e1e2t(:,:) * tmask(:,:,1) ) / MAX( zbg_svo,epsi06 ) ! snow heat content
 
       ! Volume
       ztmp = rswitch * z1_area * r1_rau0 * rday
-      zbg_vfx     = ztmp * glob_sum(     emp(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_bog = ztmp * glob_sum( wfx_bog(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_opw = ztmp * glob_sum( wfx_opw(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_sni = ztmp * glob_sum( wfx_sni(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_dyn = ztmp * glob_sum( wfx_dyn(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_bom = ztmp * glob_sum( wfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_sum = ztmp * glob_sum( wfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_res = ztmp * glob_sum( wfx_res(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_spr = ztmp * glob_sum( wfx_spr(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_snw = ztmp * glob_sum( wfx_snw(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_vfx_sub = ztmp * glob_sum( wfx_sub(:,:) * e12t(:,:) * tmask(:,:,1) )
+      zbg_vfx     = ztmp * glob_sum(     emp(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_bog = ztmp * glob_sum( wfx_bog(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_opw = ztmp * glob_sum( wfx_opw(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_sni = ztmp * glob_sum( wfx_sni(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_dyn = ztmp * glob_sum( wfx_dyn(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_bom = ztmp * glob_sum( wfx_bom(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_sum = ztmp * glob_sum( wfx_sum(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_res = ztmp * glob_sum( wfx_res(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_spr = ztmp * glob_sum( wfx_spr(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_snw = ztmp * glob_sum( wfx_snw(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_vfx_sub = ztmp * glob_sum( wfx_sub(:,:) * e1e2t(:,:) * tmask(:,:,1) )
 
       ! Salt
-      zbg_sfx     = ztmp * glob_sum(     sfx(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_bri = ztmp * glob_sum( sfx_bri(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_res = ztmp * glob_sum( sfx_res(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_dyn = ztmp * glob_sum( sfx_dyn(:,:) * e12t(:,:) * tmask(:,:,1) )
-
-      zbg_sfx_bog = ztmp * glob_sum( sfx_bog(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_opw = ztmp * glob_sum( sfx_opw(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_sni = ztmp * glob_sum( sfx_sni(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_bom = ztmp * glob_sum( sfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) )
-      zbg_sfx_sum = ztmp * glob_sum( sfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) )
+      zbg_sfx     = ztmp * glob_sum(     sfx(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_bri = ztmp * glob_sum( sfx_bri(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_res = ztmp * glob_sum( sfx_res(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_dyn = ztmp * glob_sum( sfx_dyn(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+
+      zbg_sfx_bog = ztmp * glob_sum( sfx_bog(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_opw = ztmp * glob_sum( sfx_opw(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_sni = ztmp * glob_sum( sfx_sni(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_bom = ztmp * glob_sum( sfx_bom(:,:) * e1e2t(:,:) * tmask(:,:,1) )
+      zbg_sfx_sum = ztmp * glob_sum( sfx_sum(:,:) * e1e2t(:,:) * tmask(:,:,1) )
 
       ! Heat budget
-      zbg_ihc      = glob_sum( et_i(:,:) * e12t(:,:) * 1.e-20 ) ! ice heat content  [1.e20 J]
-      zbg_shc      = glob_sum( et_s(:,:) * e12t(:,:) * 1.e-20 ) ! snow heat content [1.e20 J]
-      zbg_hfx_dhc  = glob_sum( diag_heat(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_spr  = glob_sum( hfx_spr(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-
-      zbg_hfx_thd  = glob_sum( hfx_thd(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_dyn  = glob_sum( hfx_dyn(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_res  = glob_sum( hfx_res(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_sub  = glob_sum( hfx_sub(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_snw  = glob_sum( hfx_snw(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_sum  = glob_sum( hfx_sum(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_bom  = glob_sum( hfx_bom(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_bog  = glob_sum( hfx_bog(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_dif  = glob_sum( hfx_dif(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_opw  = glob_sum( hfx_opw(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_out  = glob_sum( hfx_out(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
-      zbg_hfx_in   = glob_sum(  hfx_in(:,:) * e12t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_ihc      = glob_sum( et_i(:,:) * e1e2t(:,:) ) * 1.e-20  ! ice heat content  [1.e20 J]
+      zbg_shc      = glob_sum( et_s(:,:) * e1e2t(:,:) ) * 1.e-20  ! snow heat content [1.e20 J]
+      zbg_hfx_dhc  = glob_sum( diag_heat(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_spr  = glob_sum( hfx_spr(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+
+      zbg_hfx_thd  = glob_sum( hfx_thd(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_dyn  = glob_sum( hfx_dyn(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_res  = glob_sum( hfx_res(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_sub  = glob_sum( hfx_sub(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_snw  = glob_sum( hfx_snw(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_sum  = glob_sum( hfx_sum(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_bom  = glob_sum( hfx_bom(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_bog  = glob_sum( hfx_bog(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_dif  = glob_sum( hfx_dif(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_opw  = glob_sum( hfx_opw(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_out  = glob_sum( hfx_out(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
+      zbg_hfx_in   = glob_sum(  hfx_in(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! [in W]
     
       ! --------------------------------------------- !
       ! 2 - Trends due to forcing and ice growth/melt !
       ! --------------------------------------------- !
-      z_frc_vol = r1_rau0 * glob_sum( - emp(:,:) * e12t(:,:) * tmask(:,:,1) ) ! volume fluxes
-      z_frc_sal = r1_rau0 * glob_sum(   sfx(:,:) * e12t(:,:) * tmask(:,:,1) ) ! salt fluxes
+      z_frc_vol = r1_rau0 * glob_sum( - emp(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! volume fluxes
+      z_frc_sal = r1_rau0 * glob_sum(   sfx(:,:) * e1e2t(:,:) * tmask(:,:,1) ) ! salt fluxes
       z_bg_grme = glob_sum( - ( wfx_bog(:,:) + wfx_opw(:,:) + wfx_sni(:,:) + wfx_dyn(:,:) + &
                           &     wfx_bom(:,:) + wfx_sum(:,:) + wfx_res(:,:) + wfx_snw(:,:) + &
-                          &     wfx_sub(:,:) ) * e12t(:,:) * tmask(:,:,1) ) ! volume fluxes
+                          &     wfx_sub(:,:) ) * e1e2t(:,:) * tmask(:,:,1) ) ! volume fluxes
       !
       frc_vol  = frc_vol  + z_frc_vol  * rdt_ice
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limdyn.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limdyn.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limdyn.F90	(revision 6041)
@@ -191,5 +191,5 @@
          CALL prt_ctl(tab2d_1=delta_i   , clinfo1=' lim_dyn  : delta_i   :')
          CALL prt_ctl(tab2d_1=strength  , clinfo1=' lim_dyn  : strength  :')
-         CALL prt_ctl(tab2d_1=e12t      , clinfo1=' lim_dyn  : cell area :')
+         CALL prt_ctl(tab2d_1=e1e2t     , clinfo1=' lim_dyn  : cell area :')
          CALL prt_ctl(tab2d_1=at_i      , clinfo1=' lim_dyn  : at_i      :')
          CALL prt_ctl(tab2d_1=vt_i      , clinfo1=' lim_dyn  : vt_i      :')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limhdf.F90	(revision 6041)
@@ -76,5 +76,5 @@
          DO jj = 2, jpjm1  
             DO ji = fs_2 , fs_jpim1   ! vector opt.
-               efact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj) + e1v(ji,jj) + e1v(ji,jj-1) ) * r1_e12t(ji,jj)
+               efact(ji,jj) = ( e2u(ji,jj) + e2u(ji-1,jj) + e1v(ji,jj) + e1v(ji,jj-1) ) * r1_e1e2t(ji,jj)
             END DO
          END DO
@@ -107,5 +107,5 @@
          DO jj= 2, jpjm1                                 ! diffusive trend : divergence of the fluxes
             DO ji = fs_2 , fs_jpim1   ! vector opt. 
-               zdiv(ji,jj) = ( zflu(ji,jj) - zflu(ji-1,jj) + zflv(ji,jj) - zflv(ji,jj-1) ) * r1_e12t(ji,jj)
+               zdiv(ji,jj) = ( zflu(ji,jj) - zflu(ji-1,jj) + zflv(ji,jj) - zflv(ji,jj-1) ) * r1_e1e2t(ji,jj)
             END DO
          END DO
@@ -149,5 +149,5 @@
       DO jj= 2, jpjm1                                 ! diffusive trend : divergence of the fluxes
          DO ji = fs_2 , fs_jpim1   ! vector opt. 
-            zdiv(ji,jj) = ( zflu(ji,jj) - zflu(ji-1,jj) + zflv(ji,jj) - zflv(ji,jj-1) ) * r1_e12t(ji,jj)
+            zdiv(ji,jj) = ( zflu(ji,jj) - zflu(ji-1,jj) + zflv(ji,jj) - zflv(ji,jj-1) ) * r1_e1e2t(ji,jj)
             ptab(ji,jj) = ztab0(ji,jj) + 0.5 * ( zdiv(ji,jj) + zdiv0(ji,jj) )
          END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limitd_me.F90	(revision 6041)
@@ -377,5 +377,5 @@
          CALL prt_ctl_info(' - Cell values : ')
          CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
-         CALL prt_ctl(tab2d_1=e12t , clinfo1=' lim_itd_me  : cell area :')
+         CALL prt_ctl(tab2d_1=e1e2t, clinfo1=' lim_itd_me  : cell area :')
          CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_itd_me  : at_i      :')
          CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_itd_me  : vt_i      :')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limrhg.F90	(revision 6041)
@@ -355,14 +355,14 @@
                divu_i(ji,jj) = (  e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj) * u_ice(ji-1,jj)   &
                   &             + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji,jj-1) * v_ice(ji,jj-1)   &
-                  &            ) * r1_e12t(ji,jj)
+                  &            ) * r1_e1e2t(ji,jj)
 
                zdt(ji,jj) = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)   &
                   &         - ( v_ice(ji,jj) * r1_e1v(ji,jj) - v_ice(ji,jj-1) * r1_e1v(ji,jj-1) ) * e1t(ji,jj) * e1t(ji,jj)   &
-                  &         ) * r1_e12t(ji,jj)
+                  &         ) * r1_e1e2t(ji,jj)
 
                !
                zds(ji,jj) = ( ( u_ice(ji,jj+1) * r1_e1u(ji,jj+1) - u_ice(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)   &
                   &         + ( v_ice(ji+1,jj) * r1_e2v(ji+1,jj) - v_ice(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)   &
-                  &         ) * r1_e12f(ji,jj) * ( 2._wp - fmask(ji,jj,1) )   &
+                  &         ) * r1_e1e2f(ji,jj) * ( 2._wp - fmask(ji,jj,1) )   &
                   &         * zmask(ji,jj) * zmask(ji,jj+1) * zmask(ji+1,jj) * zmask(ji+1,jj+1)
 
@@ -386,5 +386,5 @@
                zdst          = ( e2u(ji,jj) * v_ice1(ji,jj) - e2u(ji-1,jj  ) * v_ice1(ji-1,jj  )   &
                   &            + e1v(ji,jj) * u_ice2(ji,jj) - e1v(ji  ,jj-1) * u_ice2(ji  ,jj-1)   &
-                  &            ) * r1_e12t(ji,jj)
+                  &            ) * r1_e1e2t(ji,jj)
 
                delta          = SQRT( divu_i(ji,jj)**2 + ( zdt(ji,jj)**2 + zdst**2 ) * usecc2 )  
@@ -394,9 +394,9 @@
                zddc  = (  ( v_ice1(ji,jj+1) * r1_e1u(ji,jj+1) - v_ice1(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)  &
                   &     + ( u_ice2(ji+1,jj) * r1_e2v(ji+1,jj) - u_ice2(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)  &
-                  &    ) * r1_e12f(ji,jj)
+                  &    ) * r1_e1e2f(ji,jj)
 
                zdtc  = (- ( v_ice1(ji,jj+1) * r1_e1u(ji,jj+1) - v_ice1(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)  &
                   &     + ( u_ice2(ji+1,jj) * r1_e2v(ji+1,jj) - u_ice2(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)  &
-                  &    ) * r1_e12f(ji,jj)
+                  &    ) * r1_e1e2f(ji,jj)
 
                zddc = SQRT( zddc**2 + ( zdtc**2 + zds(ji,jj)**2 ) * usecc2 ) + rn_creepl
@@ -423,10 +423,10 @@
                   &             + ( zs2(ji+1,jj) * e2t(ji+1,jj)**2 - zs2(ji,jj) * e2t(ji,jj)**2 ) * r1_e2u(ji,jj)          &
                   &             + 2.0 * ( zs12(ji,jj) * e1f(ji,jj)**2 - zs12(ji,jj-1) * e1f(ji,jj-1)**2 ) * r1_e1u(ji,jj)  &
-                  &                ) * r1_e12u(ji,jj)
+                  &                ) * r1_e1e2u(ji,jj)
                ! contribution of zs1, zs2 and zs12 to zf2
                zf2(ji,jj) = 0.5 * ( ( zs1(ji,jj+1) - zs1(ji,jj) ) * e1v(ji,jj)  &
                   &             - ( zs2(ji,jj+1) * e1t(ji,jj+1)**2 - zs2(ji,jj) * e1t(ji,jj)**2 ) * r1_e1v(ji,jj)          &
                   &             + 2.0 * ( zs12(ji,jj) * e2f(ji,jj)**2 - zs12(ji-1,jj) * e2f(ji-1,jj)**2 ) * r1_e2v(ji,jj)  &
-                  &               )  * r1_e12v(ji,jj)
+                  &               )  * r1_e1e2v(ji,jj)
             END DO
          END DO
@@ -607,18 +607,18 @@
                divu_i(ji,jj) = (  e2u(ji,jj) * u_ice(ji,jj) - e2u(ji-1,jj  ) * u_ice(ji-1,jj  )   &
                   &             + e1v(ji,jj) * v_ice(ji,jj) - e1v(ji  ,jj-1) * v_ice(ji  ,jj-1)   &
-                  &            ) * r1_e12t(ji,jj)
+                  &            ) * r1_e1e2t(ji,jj)
 
                zdt(ji,jj) = ( ( u_ice(ji,jj) * r1_e2u(ji,jj) - u_ice(ji-1,jj) * r1_e2u(ji-1,jj) ) * e2t(ji,jj) * e2t(ji,jj)  &
                   &          -( v_ice(ji,jj) * r1_e1v(ji,jj) - v_ice(ji,jj-1) * r1_e1v(ji,jj-1) ) * e1t(ji,jj) * e1t(ji,jj)  &
-                  &         ) * r1_e12t(ji,jj)
+                  &         ) * r1_e1e2t(ji,jj)
                !
                ! SB modif because ocean has no slip boundary condition 
                zds(ji,jj) = ( ( u_ice(ji,jj+1) * r1_e1u(ji,jj+1) - u_ice(ji,jj) * r1_e1u(ji,jj) ) * e1f(ji,jj) * e1f(ji,jj)  &
                   &          +( v_ice(ji+1,jj) * r1_e2v(ji+1,jj) - v_ice(ji,jj) * r1_e2v(ji,jj) ) * e2f(ji,jj) * e2f(ji,jj)  &
-                  &         ) * r1_e12f(ji,jj) * ( 2.0 - fmask(ji,jj,1) )                                     &
+                  &         ) * r1_e1e2f(ji,jj) * ( 2.0 - fmask(ji,jj,1) )                                     &
                   &         * zmask(ji,jj) * zmask(ji,jj+1) * zmask(ji+1,jj) * zmask(ji+1,jj+1)
 
                zdst = ( e2u(ji,jj) * v_ice1(ji,jj) - e2u(ji-1,jj  ) * v_ice1(ji-1,jj  )    &
-                  &   + e1v(ji,jj) * u_ice2(ji,jj) - e1v(ji  ,jj-1) * u_ice2(ji  ,jj-1) ) * r1_e12t(ji,jj)
+                  &   + e1v(ji,jj) * u_ice2(ji,jj) - e1v(ji  ,jj-1) * u_ice2(ji  ,jj-1) ) * r1_e1e2t(ji,jj)
 
                delta = SQRT( divu_i(ji,jj)**2 + ( zdt(ji,jj)**2 + zdst**2 ) * usecc2 )  
@@ -637,5 +637,5 @@
          DO ji = fs_2, fs_jpim1
             zdst           = (  e2u(ji,jj) * v_ice1(ji,jj) - e2u( ji-1, jj   ) * v_ice1(ji-1,jj)  &   
-               &              + e1v(ji,jj) * u_ice2(ji,jj) - e1v( ji  , jj-1 ) * u_ice2(ji,jj-1) ) * r1_e12t(ji,jj) 
+               &              + e1v(ji,jj) * u_ice2(ji,jj) - e1v( ji  , jj-1 ) * u_ice2(ji,jj-1) ) * r1_e1e2t(ji,jj) 
             shear_i(ji,jj) = SQRT( zdt(ji,jj) * zdt(ji,jj) + zdst * zdst )
          END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limthd.F90	(revision 6041)
@@ -325,5 +325,5 @@
          CALL prt_ctl_info(' - Cell values : ')
          CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
-         CALL prt_ctl(tab2d_1=e12t , clinfo1=' lim_thd  : cell area :')
+         CALL prt_ctl(tab2d_1=e1e2t, clinfo1=' lim_thd  : cell area :')
          CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_thd  : at_i      :')
          CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_thd  : vt_i      :')
@@ -382,5 +382,5 @@
          CALL prt_ctl_info(' - Cell values : ')
          CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
-         CALL prt_ctl(tab2d_1=e12t , clinfo1=' lim_itd_th  : cell area :')
+         CALL prt_ctl(tab2d_1=e1e2t, clinfo1=' lim_itd_th  : cell area :')
          CALL prt_ctl(tab2d_1=at_i , clinfo1=' lim_itd_th  : at_i      :')
          CALL prt_ctl(tab2d_1=vt_i , clinfo1=' lim_itd_th  : vt_i      :')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limtrp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limtrp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limtrp.F90	(revision 6041)
@@ -95,5 +95,5 @@
       ENDIF
 
-      zsm(:,:) = e12t(:,:)
+      zsm(:,:) = e1e2t(:,:)
       
       !                             !-------------------------------------!
@@ -162,14 +162,14 @@
          ! transported fields                                        
          !-------------------------
-         z0opw(:,:,1) = ato_i(:,:) * e12t(:,:)             ! Open water area 
-         DO jl = 1, jpl
-            z0snw (:,:,jl)  = v_s  (:,:,jl) * e12t(:,:)    ! Snow volume
-            z0ice(:,:,jl)   = v_i  (:,:,jl) * e12t(:,:)    ! Ice  volume
-            z0ai  (:,:,jl)  = a_i  (:,:,jl) * e12t(:,:)    ! Ice area
-            z0smi (:,:,jl)  = smv_i(:,:,jl) * e12t(:,:)    ! Salt content
-            z0oi (:,:,jl)   = oa_i (:,:,jl) * e12t(:,:)    ! Age content
-            z0es (:,:,jl)   = e_s  (:,:,1,jl) * e12t(:,:)  ! Snow heat content
+         z0opw(:,:,1) = ato_i(:,:) * e1e2t(:,:)             ! Open water area 
+         DO jl = 1, jpl
+            z0snw (:,:,jl)  = v_s  (:,:,  jl) * e1e2t(:,:)  ! Snow volume
+            z0ice(:,:,jl)   = v_i  (:,:,  jl) * e1e2t(:,:)  ! Ice  volume
+            z0ai  (:,:,jl)  = a_i  (:,:,  jl) * e1e2t(:,:)  ! Ice area
+            z0smi (:,:,jl)  = smv_i(:,:,  jl) * e1e2t(:,:)  ! Salt content
+            z0oi (:,:,jl)   = oa_i (:,:,  jl) * e1e2t(:,:)  ! Age content
+            z0es (:,:,jl)   = e_s  (:,:,1,jl) * e1e2t(:,:)  ! Snow heat content
             DO jk = 1, nlay_i
-               z0ei  (:,:,jk,jl) = e_i  (:,:,jk,jl) * e12t(:,:) ! Ice  heat content
+               z0ei  (:,:,jk,jl) = e_i  (:,:,jk,jl) * e1e2t(:,:) ! Ice  heat content
             END DO
          END DO
@@ -263,14 +263,14 @@
          ! Recover the properties from their contents
          !-------------------------------------------
-         ato_i(:,:) = z0opw(:,:,1) * r1_e12t(:,:)
-         DO jl = 1, jpl
-            v_i  (:,:,jl)   = z0ice(:,:,jl) * r1_e12t(:,:)
-            v_s  (:,:,jl)   = z0snw(:,:,jl) * r1_e12t(:,:)
-            smv_i(:,:,jl)   = z0smi(:,:,jl) * r1_e12t(:,:)
-            oa_i (:,:,jl)   = z0oi (:,:,jl) * r1_e12t(:,:)
-            a_i  (:,:,jl)   = z0ai (:,:,jl) * r1_e12t(:,:)
-            e_s  (:,:,1,jl) = z0es (:,:,jl) * r1_e12t(:,:)
+         ato_i(:,:) = z0opw(:,:,1) * r1_e1e2t(:,:)
+         DO jl = 1, jpl
+            v_i  (:,:,  jl) = z0ice(:,:,jl) * r1_e1e2t(:,:)
+            v_s  (:,:,  jl) = z0snw(:,:,jl) * r1_e1e2t(:,:)
+            smv_i(:,:,  jl) = z0smi(:,:,jl) * r1_e1e2t(:,:)
+            oa_i (:,:,  jl) = z0oi (:,:,jl) * r1_e1e2t(:,:)
+            a_i  (:,:,  jl) = z0ai (:,:,jl) * r1_e1e2t(:,:)
+            e_s  (:,:,1,jl) = z0es (:,:,jl) * r1_e1e2t(:,:)
             DO jk = 1, nlay_i
-               e_i(:,:,jk,jl) = z0ei(:,:,jk,jl) * r1_e12t(:,:)
+               e_i(:,:,jk,jl) = z0ei(:,:,jk,jl) * r1_e1e2t(:,:)
             END DO
          END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limupdate1.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limupdate1.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limupdate1.F90	(revision 6041)
@@ -146,5 +146,5 @@
          CALL prt_ctl_info(' - Cell values : ')
          CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
-         CALL prt_ctl(tab2d_1=e12t       , clinfo1=' lim_update1  : cell area   :')
+         CALL prt_ctl(tab2d_1=e1e2t      , clinfo1=' lim_update1  : cell area   :')
          CALL prt_ctl(tab2d_1=at_i       , clinfo1=' lim_update1  : at_i        :')
          CALL prt_ctl(tab2d_1=vt_i       , clinfo1=' lim_update1  : vt_i        :')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limupdate2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limupdate2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/LIM_SRC_3/limupdate2.F90	(revision 6041)
@@ -191,5 +191,5 @@
          CALL prt_ctl_info(' - Cell values : ')
          CALL prt_ctl_info('   ~~~~~~~~~~~~~ ')
-         CALL prt_ctl(tab2d_1=e12t       , clinfo1=' lim_update2  : cell area   :')
+         CALL prt_ctl(tab2d_1=e1e2t      , clinfo1=' lim_update2  : cell area   :')
          CALL prt_ctl(tab2d_1=at_i       , clinfo1=' lim_update2  : at_i        :')
          CALL prt_ctl(tab2d_1=vt_i       , clinfo1=' lim_update2  : vt_i        :')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_interp.F90	(revision 6041)
@@ -22,5 +22,4 @@
    USE oce
    USE dom_oce      
-   USE sol_oce
    USE agrif_oce
    USE phycst
@@ -29,5 +28,4 @@
    USE lib_mpp
    USE wrk_nemo
-   USE dynspg_oce
    USE zdf_oce
  
@@ -38,5 +36,5 @@
 
    PUBLIC   Agrif_tra, Agrif_dyn, Agrif_ssh, Agrif_dyn_ts, Agrif_ssh_ts, Agrif_dta_ts
-   PUBLIC   interpun, interpvn, interpun2d, interpvn2d 
+   PUBLIC   interpun, interpvn
    PUBLIC   interptsn,  interpsshn
    PUBLIC   interpunb, interpvnb, interpub2b, interpvb2b
@@ -80,13 +78,10 @@
       !!
       INTEGER :: ji,jj,jk, j1,j2, i1,i2
-      REAL(wp) :: timeref
-      REAL(wp) :: z2dt, znugdt
-      REAL(wp) :: zrhox, zrhoy
-      REAL(wp), POINTER, DIMENSION(:,:) :: spgv1, spgu1
+      REAL(wp), POINTER, DIMENSION(:,:) :: zub, zvb
       !!----------------------------------------------------------------------  
 
       IF( Agrif_Root() )   RETURN
 
-      CALL wrk_alloc( jpi, jpj, spgv1, spgu1 )
+      CALL wrk_alloc( jpi, jpj, zub, zvb )
 
       Agrif_SpecialValue=0.
@@ -96,22 +91,6 @@
       CALL Agrif_Bc_variable(vn_interp_id,procname=interpvn)
 
-#if defined key_dynspg_flt
-      CALL Agrif_Bc_variable(e1u_id,calledweight=1., procname=interpun2d)
-      CALL Agrif_Bc_variable(e2v_id,calledweight=1., procname=interpvn2d)
-#endif
-
       Agrif_UseSpecialValue = .FALSE.
-
-      zrhox = Agrif_Rhox()
-      zrhoy = Agrif_Rhoy()
-
-      timeref = 1.
-      ! time step: leap-frog
-      z2dt = 2. * rdt
-      ! time step: Euler if restart from rest
-      IF( neuler == 0 .AND. kt == nit000 ) z2dt = rdt
-      ! coefficients
-      znugdt =  grav * z2dt    
-
+ 
       ! prevent smoothing in ghost cells
       i1=1
@@ -126,295 +105,279 @@
 
       IF((nbondi == -1).OR.(nbondi == 2)) THEN
-#if defined key_dynspg_flt
-         DO jk=1,jpkm1
+
+         ! Smoothing
+         ! ---------
+         IF ( .NOT.ln_dynspg_ts ) THEN ! Store transport
+            ua_b(2,:)=0._wp
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  ua_b(2,jj) = ua_b(2,jj) + fse3u_a(2,jj,jk) * ua(2,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               ua_b(2,jj) = ua_b(2,jj) * hur_a(2,jj)            
+            END DO
+         ENDIF
+
+         DO jk=1,jpkm1                 ! Smooth
             DO jj=j1,j2
-               ua(2,jj,jk) = (ua(2,jj,jk) - z2dt * znugdt * laplacu(2,jj))*umask(2,jj,jk)
-            END DO
-         END DO
-
-         spgu(2,:)=0.
-
+               ua(2,jj,jk) = 0.25_wp*(ua(1,jj,jk)+2._wp*ua(2,jj,jk)+ua(3,jj,jk))
+               ua(2,jj,jk) = ua(2,jj,jk) * umask(2,jj,jk)
+            END DO
+         END DO
+
+         zub(2,:)=0._wp                ! Correct transport
          DO jk=1,jpkm1
             DO jj=1,jpj
-               spgu(2,jj)=spgu(2,jj)+fse3u(2,jj,jk)*ua(2,jj,jk)
-            END DO
-         END DO
-
+               zub(2,jj) = zub(2,jj) + fse3u_a(2,jj,jk) * ua(2,jj,jk)
+            END DO
+         END DO
          DO jj=1,jpj
-            IF (umask(2,jj,1).NE.0.) THEN
-               spgu(2,jj)=spgu(2,jj)/hu(2,jj)
-            ENDIF
-         END DO
-#else
-         spgu(2,:) = ua_b(2,:)
-#endif
-
-         DO jk=1,jpkm1
+            zub(2,jj) = zub(2,jj) * hur_a(2,jj)
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(2,jj,jk) = (ua(2,jj,jk)+ua_b(2,jj)-zub(2,jj))*umask(2,jj,jk)
+            END DO
+         END DO
+
+         ! Set tangential velocities to time splitting estimate
+         !-----------------------------------------------------
+         IF ( ln_dynspg_ts) THEN
+            zvb(2,:)=0._wp
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  zvb(2,jj) = zvb(2,jj) + fse3v_a(2,jj,jk) * va(2,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               zvb(2,jj) = zvb(2,jj) * hvr_a(2,jj)
+            END DO
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  va(2,jj,jk) = (va(2,jj,jk)+va_b(2,jj)-zvb(2,jj))*vmask(2,jj,jk)
+               END DO
+            END DO
+         ENDIF
+
+         ! Mask domain edges:
+         !-------------------
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(1,jj,jk) = 0._wp
+               va(1,jj,jk) = 0._wp
+            END DO
+         END DO         
+
+      ENDIF
+
+      IF((nbondi == 1).OR.(nbondi == 2)) THEN
+
+         ! Smoothing
+         ! ---------
+         IF ( .NOT.ln_dynspg_ts ) THEN ! Store transport
+            ua_b(nlci-2,:)=0._wp
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  ua_b(nlci-2,jj) = ua_b(nlci-2,jj) + fse3u_a(nlci-2,jj,jk) * ua(nlci-2,jj,jk)
+               END DO
+            END DO
+            DO jj=1,jpj
+               ua_b(nlci-2,jj) = ua_b(nlci-2,jj) * hur_a(nlci-2,jj)            
+            END DO
+         ENDIF
+
+         DO jk=1,jpkm1                 ! Smooth
             DO jj=j1,j2
-               ua(2,jj,jk) = 0.25*(ua(1,jj,jk)+2.*ua(2,jj,jk)+ua(3,jj,jk))
-               ua(2,jj,jk) = ua(2,jj,jk) * umask(2,jj,jk)
-            END DO
-         END DO
-
-         spgu1(2,:)=0.
-
+               ua(nlci-2,jj,jk) = 0.25_wp*(ua(nlci-3,jj,jk)+2._wp*ua(nlci-2,jj,jk)+ua(nlci-1,jj,jk))
+               ua(nlci-2,jj,jk) = ua(nlci-2,jj,jk) * umask(nlci-2,jj,jk)
+            END DO
+         END DO
+
+         zub(nlci-2,:)=0._wp           ! Correct transport
          DO jk=1,jpkm1
             DO jj=1,jpj
-               spgu1(2,jj)=spgu1(2,jj)+fse3u(2,jj,jk)*ua(2,jj,jk)
-            END DO
-         END DO
-
+               zub(nlci-2,jj) = zub(nlci-2,jj) + fse3u_a(nlci-2,jj,jk) * ua(nlci-2,jj,jk)
+            END DO
+         END DO
          DO jj=1,jpj
-            IF (umask(2,jj,1).NE.0.) THEN
-               spgu1(2,jj)=spgu1(2,jj)/hu(2,jj)
-            ENDIF
-         END DO
-
-         DO jk=1,jpkm1
-            DO jj=j1,j2
-               ua(2,jj,jk) = (ua(2,jj,jk)+spgu(2,jj)-spgu1(2,jj))*umask(2,jj,jk)
-            END DO
-         END DO
-
-#if defined key_dynspg_ts
+            zub(nlci-2,jj) = zub(nlci-2,jj) * hur_a(nlci-2,jj)
+         END DO
+
+         DO jk=1,jpkm1
+            DO jj=1,jpj
+               ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)+ua_b(nlci-2,jj)-zub(nlci-2,jj))*umask(nlci-2,jj,jk)
+            END DO
+         END DO
+
          ! Set tangential velocities to time splitting estimate
-         spgv1(2,:)=0.
-         DO jk=1,jpkm1
+         !-----------------------------------------------------
+         IF ( ln_dynspg_ts) THEN
+            zvb(nlci-1,:)=0._wp
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  zvb(nlci-1,jj) = zvb(nlci-1,jj) + fse3v_a(nlci-1,jj,jk) * va(nlci-1,jj,jk)
+               END DO
+            END DO
             DO jj=1,jpj
-               spgv1(2,jj)=spgv1(2,jj)+fse3v_a(2,jj,jk)*va(2,jj,jk)
-            END DO
-         END DO
-         DO jj=1,jpj
-            spgv1(2,jj)=spgv1(2,jj)*hvr_a(2,jj)
-         END DO
+               zvb(nlci-1,jj) = zvb(nlci-1,jj) * hvr_a(nlci-1,jj)
+            END DO
+            DO jk=1,jpkm1
+               DO jj=1,jpj
+                  va(nlci-1,jj,jk) = (va(nlci-1,jj,jk)+va_b(nlci-1,jj)-zvb(nlci-1,jj))*vmask(nlci-1,jj,jk)
+               END DO
+            END DO
+         ENDIF
+
+         ! Mask domain edges:
+         !-------------------
          DO jk=1,jpkm1
             DO jj=1,jpj
-               va(2,jj,jk) = (va(2,jj,jk)+va_b(2,jj)-spgv1(2,jj))*vmask(2,jj,jk)
-            END DO
-         END DO
-#endif
-
-      ENDIF
-
-      IF((nbondi == 1).OR.(nbondi == 2)) THEN
-#if defined key_dynspg_flt
-         DO jk=1,jpkm1
-            DO jj=j1,j2
-               ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)- z2dt * znugdt * laplacu(nlci-2,jj))*umask(nlci-2,jj,jk)
-            END DO
-         END DO
-         spgu(nlci-2,:)=0.
-         DO jk=1,jpkm1
-            DO jj=1,jpj
-               spgu(nlci-2,jj)=spgu(nlci-2,jj)+fse3u(nlci-2,jj,jk)*ua(nlci-2,jj,jk)
-            ENDDO
-         ENDDO
-         DO jj=1,jpj
-            IF (umask(nlci-2,jj,1).NE.0.) THEN
-               spgu(nlci-2,jj)=spgu(nlci-2,jj)/hu(nlci-2,jj)
-            ENDIF
-         END DO
-#else
-         spgu(nlci-2,:) = ua_b(nlci-2,:)
-#endif
-         DO jk=1,jpkm1
-            DO jj=j1,j2
-               ua(nlci-2,jj,jk) = 0.25*(ua(nlci-3,jj,jk)+2.*ua(nlci-2,jj,jk)+ua(nlci-1,jj,jk))
-
-               ua(nlci-2,jj,jk) = ua(nlci-2,jj,jk) * umask(nlci-2,jj,jk)
-
-            END DO
-         END DO
-         spgu1(nlci-2,:)=0.
-         DO jk=1,jpkm1
-            DO jj=1,jpj
-               spgu1(nlci-2,jj)=spgu1(nlci-2,jj)+fse3u(nlci-2,jj,jk)*ua(nlci-2,jj,jk)*umask(nlci-2,jj,jk)
-            END DO
-         END DO
-         DO jj=1,jpj
-            IF (umask(nlci-2,jj,1).NE.0.) THEN
-               spgu1(nlci-2,jj)=spgu1(nlci-2,jj)/hu(nlci-2,jj)
-            ENDIF
-         END DO
-         DO jk=1,jpkm1
-            DO jj=j1,j2
-               ua(nlci-2,jj,jk) = (ua(nlci-2,jj,jk)+spgu(nlci-2,jj)-spgu1(nlci-2,jj))*umask(nlci-2,jj,jk)
-            END DO
-         END DO
-
-#if defined key_dynspg_ts
+               ua(nlci-1,jj,jk) = 0._wp
+               va(nlci  ,jj,jk) = 0._wp
+            END DO
+         END DO 
+
+      ENDIF
+
+      IF((nbondj == -1).OR.(nbondj == 2)) THEN
+
+         ! Smoothing
+         ! ---------
+         IF ( .NOT.ln_dynspg_ts ) THEN ! Store transport
+            va_b(:,2)=0._wp
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  va_b(ji,2) = va_b(ji,2) + fse3v_a(ji,2,jk) * va(ji,2,jk)
+               END DO
+            END DO
+            DO ji=1,jpi
+               va_b(ji,2) = va_b(ji,2) * hvr_a(ji,2)            
+            END DO
+         ENDIF
+
+         DO jk=1,jpkm1                 ! Smooth
+            DO ji=i1,i2
+               va(ji,2,jk)=0.25_wp*(va(ji,1,jk)+2._wp*va(ji,2,jk)+va(ji,3,jk))
+               va(ji,2,jk)=va(ji,2,jk)*vmask(ji,2,jk)
+            END DO
+         END DO
+
+         zvb(:,2)=0._wp                ! Correct transport
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               zvb(ji,2) = zvb(ji,2) + fse3v_a(ji,2,jk) * va(ji,2,jk) * vmask(ji,2,jk)
+            END DO
+         END DO
+         DO ji=1,jpi
+            zvb(ji,2) = zvb(ji,2) * hvr_a(ji,2)
+         END DO
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               va(ji,2,jk) = (va(ji,2,jk)+va_b(ji,2)-zvb(ji,2))*vmask(ji,2,jk)
+            END DO
+         END DO
+
          ! Set tangential velocities to time splitting estimate
-         spgv1(nlci-1,:)=0._wp
-         DO jk=1,jpkm1
-            DO jj=1,jpj
-               spgv1(nlci-1,jj)=spgv1(nlci-1,jj)+fse3v_a(nlci-1,jj,jk)*va(nlci-1,jj,jk)*vmask(nlci-1,jj,jk)
-            END DO
-         END DO
-
-         DO jj=1,jpj
-            spgv1(nlci-1,jj)=spgv1(nlci-1,jj)*hvr_a(nlci-1,jj)
-         END DO
-
-         DO jk=1,jpkm1
-            DO jj=1,jpj
-               va(nlci-1,jj,jk) = (va(nlci-1,jj,jk)+va_b(nlci-1,jj)-spgv1(nlci-1,jj))*vmask(nlci-1,jj,jk)
-            END DO
-         END DO
-#endif
-
-      ENDIF
-
-      IF((nbondj == -1).OR.(nbondj == 2)) THEN
-
-#if defined key_dynspg_flt
-         DO jk=1,jpkm1
+         !-----------------------------------------------------
+         IF ( ln_dynspg_ts ) THEN
+            zub(:,2)=0._wp
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  zub(ji,2) = zub(ji,2) + fse3u_a(ji,2,jk) * ua(ji,2,jk) * umask(ji,2,jk)
+               END DO
+            END DO
             DO ji=1,jpi
-               va(ji,2,jk) = (va(ji,2,jk) - z2dt * znugdt * laplacv(ji,2))*vmask(ji,2,jk)
-            END DO
-         END DO
-
-         spgv(:,2)=0.
-
+               zub(ji,2) = zub(ji,2) * hur_a(ji,2)
+            END DO
+
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  ua(ji,2,jk) = (ua(ji,2,jk)+ua_b(ji,2)-zub(ji,2))*umask(ji,2,jk)
+               END DO
+            END DO
+         ENDIF
+
+         ! Mask domain edges:
+         !-------------------
          DO jk=1,jpkm1
             DO ji=1,jpi
-               spgv(ji,2)=spgv(ji,2)+fse3v(ji,2,jk)*va(ji,2,jk)
-            END DO
-         END DO
-
+               ua(ji,1,jk) = 0._wp
+               va(ji,1,jk) = 0._wp
+            END DO
+         END DO 
+
+      ENDIF
+
+      IF((nbondj == 1).OR.(nbondj == 2)) THEN
+         ! Smoothing
+         ! ---------
+         IF ( .NOT.ln_dynspg_ts ) THEN ! Store transport
+            va_b(:,nlcj-2)=0._wp
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  va_b(ji,nlcj-2) = va_b(ji,nlcj-2) + fse3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk)
+               END DO
+            END DO
+            DO ji=1,jpi
+               va_b(ji,nlcj-2) = va_b(ji,nlcj-2) * hvr_a(ji,nlcj-2)            
+            END DO
+         ENDIF
+
+         DO jk=1,jpkm1                 ! Smooth
+            DO ji=i1,i2
+               va(ji,nlcj-2,jk)=0.25_wp*(va(ji,nlcj-3,jk)+2._wp*va(ji,nlcj-2,jk)+va(ji,nlcj-1,jk))
+               va(ji,nlcj-2,jk)=va(ji,nlcj-2,jk)*vmask(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+         zvb(:,nlcj-2)=0._wp           ! Correct transport
+         DO jk=1,jpkm1
+            DO ji=1,jpi
+               zvb(ji,nlcj-2) = zvb(ji,nlcj-2) + fse3v_a(ji,nlcj-2,jk) * va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)
+            END DO
+         END DO
          DO ji=1,jpi
-            IF (vmask(ji,2,1).NE.0.) THEN
-               spgv(ji,2)=spgv(ji,2)/hv(ji,2)
-            ENDIF
-         END DO
-#else
-         spgv(:,2)=va_b(:,2)
-#endif
-
-         DO jk=1,jpkm1
-            DO ji=i1,i2
-               va(ji,2,jk)=0.25*(va(ji,1,jk)+2.*va(ji,2,jk)+va(ji,3,jk))
-               va(ji,2,jk)=va(ji,2,jk)*vmask(ji,2,jk)
-            END DO
-         END DO
-
-         spgv1(:,2)=0.
-
+            zvb(ji,nlcj-2) = zvb(ji,nlcj-2) * hvr_a(ji,nlcj-2)
+         END DO
          DO jk=1,jpkm1
             DO ji=1,jpi
-               spgv1(ji,2)=spgv1(ji,2)+fse3v(ji,2,jk)*va(ji,2,jk)*vmask(ji,2,jk)
-            END DO
-         END DO
-
-         DO ji=1,jpi
-            IF (vmask(ji,2,1).NE.0.) THEN
-               spgv1(ji,2)=spgv1(ji,2)/hv(ji,2)
-            ENDIF
-         END DO
-
-         DO jk=1,jpkm1
+               va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)+va_b(ji,nlcj-2)-zvb(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
+            END DO
+         END DO
+
+         ! Set tangential velocities to time splitting estimate
+         !-----------------------------------------------------
+         IF ( ln_dynspg_ts ) THEN
+            zub(:,nlcj-1)=0._wp
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  zub(ji,nlcj-1) = zub(ji,nlcj-1) + fse3u_a(ji,nlcj-1,jk) * ua(ji,nlcj-1,jk) * umask(ji,nlcj-1,jk)
+               END DO
+            END DO
             DO ji=1,jpi
-               va(ji,2,jk) = (va(ji,2,jk)+spgv(ji,2)-spgv1(ji,2))*vmask(ji,2,jk)
-            END DO
-         END DO
-
-#if defined key_dynspg_ts
-         ! Set tangential velocities to time splitting estimate
-         spgu1(:,2)=0._wp
+               zub(ji,nlcj-1) = zub(ji,nlcj-1) * hur_a(ji,nlcj-1)
+            END DO
+
+            DO jk=1,jpkm1
+               DO ji=1,jpi
+                  ua(ji,nlcj-1,jk) = (ua(ji,nlcj-1,jk)+ua_b(ji,nlcj-1)-zub(ji,nlcj-1))*umask(ji,nlcj-1,jk)
+               END DO
+            END DO
+         ENDIF
+
+         ! Mask domain edges:
+         !-------------------
          DO jk=1,jpkm1
             DO ji=1,jpi
-               spgu1(ji,2)=spgu1(ji,2)+fse3u_a(ji,2,jk)*ua(ji,2,jk)*umask(ji,2,jk)
-            END DO
-         END DO
-
-         DO ji=1,jpi
-            spgu1(ji,2)=spgu1(ji,2)*hur_a(ji,2)
-         END DO
-
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               ua(ji,2,jk) = (ua(ji,2,jk)+ua_b(ji,2)-spgu1(ji,2))*umask(ji,2,jk)
-            END DO
-         END DO
-#endif
-      ENDIF
-
-      IF((nbondj == 1).OR.(nbondj == 2)) THEN
-
-#if defined key_dynspg_flt
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)-z2dt * znugdt * laplacv(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
-            END DO
-         END DO
-
-
-         spgv(:,nlcj-2)=0.
-
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               spgv(ji,nlcj-2)=spgv(ji,nlcj-2)+fse3v(ji,nlcj-2,jk)*va(ji,nlcj-2,jk)
-            END DO
-         END DO
-
-         DO ji=1,jpi
-            IF (vmask(ji,nlcj-2,1).NE.0.) THEN
-               spgv(ji,nlcj-2)=spgv(ji,nlcj-2)/hv(ji,nlcj-2)
-            ENDIF
-         END DO
-
-#else
-         spgv(:,nlcj-2)=va_b(:,nlcj-2)
-#endif
-
-         DO jk=1,jpkm1
-            DO ji=i1,i2
-               va(ji,nlcj-2,jk)=0.25*(va(ji,nlcj-3,jk)+2.*va(ji,nlcj-2,jk)+va(ji,nlcj-1,jk))
-               va(ji,nlcj-2,jk) = va(ji,nlcj-2,jk) * vmask(ji,nlcj-2,jk)
-            END DO
-         END DO
-
-         spgv1(:,nlcj-2)=0.
-
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               spgv1(ji,nlcj-2)=spgv1(ji,nlcj-2)+fse3v(ji,nlcj-2,jk)*va(ji,nlcj-2,jk)
-            END DO
-         END DO
-
-         DO ji=1,jpi
-            IF (vmask(ji,nlcj-2,1).NE.0.) THEN
-               spgv1(ji,nlcj-2)=spgv1(ji,nlcj-2)/hv(ji,nlcj-2)
-            ENDIF
-         END DO
-
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               va(ji,nlcj-2,jk) = (va(ji,nlcj-2,jk)+spgv(ji,nlcj-2)-spgv1(ji,nlcj-2))*vmask(ji,nlcj-2,jk)
-            END DO
-         END DO
-
-#if defined key_dynspg_ts
-         ! Set tangential velocities to time splitting estimate
-         spgu1(:,nlcj-1)=0._wp
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               spgu1(ji,nlcj-1)=spgu1(ji,nlcj-1)+fse3u_a(ji,nlcj-1,jk)*ua(ji,nlcj-1,jk)
-            END DO
-         END DO
-
-         DO ji=1,jpi
-            spgu1(ji,nlcj-1)=spgu1(ji,nlcj-1)*hur_a(ji,nlcj-1)
-         END DO
-
-         DO jk=1,jpkm1
-            DO ji=1,jpi
-               ua(ji,nlcj-1,jk) = (ua(ji,nlcj-1,jk)+ua_b(ji,nlcj-1)-spgu1(ji,nlcj-1))*umask(ji,nlcj-1,jk)
-            END DO
-         END DO
-#endif
-
-      ENDIF
-      !
-      CALL wrk_dealloc( jpi, jpj, spgv1, spgu1 )
+               ua(ji,nlcj  ,jk) = 0._wp
+               va(ji,nlcj-1,jk) = 0._wp
+            END DO
+         END DO 
+
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi, jpj, zub, zvb )
       !
    END SUBROUTINE Agrif_dyn
@@ -687,4 +650,5 @@
                   END DO
                END DO
+               tsa(nlci,j1:j2,k1:k2,jn) = 0._wp
             ENDDO
          ENDIF
@@ -706,4 +670,5 @@
                   END DO
                END DO
+               tsa(i1:i2,nlcj,k1:k2,jn) = 0._wp
             ENDDO
          ENDIF
@@ -724,4 +689,5 @@
                   END DO
                END DO
+               tsa(1,j1:j2,k1:k2,jn) = 0._wp
             END DO
          ENDIF
@@ -742,4 +708,5 @@
                   END DO
                END DO
+               tsa(i1:i2,1,k1:k2,jn) = 0._wp
             ENDDO
          ENDIF
@@ -828,37 +795,4 @@
    END SUBROUTINE interpun
 
-
-   SUBROUTINE interpun2d(ptab,i1,i2,j1,j2,before)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpun ***
-      !!---------------------------------------------    
-      !
-      INTEGER, INTENT(in) :: i1,i2,j1,j2
-      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: ptab
-      LOGICAL, INTENT(in) :: before
-      !
-      INTEGER :: ji,jj
-      REAL(wp) :: ztref
-      REAL(wp) :: zrhoy	
-      !!---------------------------------------------    
-      !
-      ztref = 1.
-
-      IF (before) THEN 
-         DO jj=j1,j2
-            DO ji=i1,MIN(i2,nlci-1)
-               ptab(ji,jj) = e2u(ji,jj) * ((gcx(ji+1,jj) - gcx(ji,jj))/e1u(ji,jj)) 
-            END DO
-         END DO
-      ELSE
-         zrhoy = Agrif_Rhoy()
-         DO jj=j1,j2
-            laplacu(i1:i2,jj) = ztref * (ptab(i1:i2,jj)/(zrhoy*e2u(i1:i2,jj))) !*umask(i1:i2,jj,1)
-         END DO
-      ENDIF
-      ! 
-   END SUBROUTINE interpun2d
-
-
    SUBROUTINE interpvn(ptab,i1,i2,j1,j2,k1,k2, before)
       !!---------------------------------------------
@@ -895,35 +829,4 @@
       !        
    END SUBROUTINE interpvn
-
-   SUBROUTINE interpvn2d(ptab,i1,i2,j1,j2,before)
-      !!---------------------------------------------
-      !!   *** ROUTINE interpvn ***
-      !!---------------------------------------------    
-      !
-      INTEGER, INTENT(in) :: i1,i2,j1,j2
-      REAL(wp), DIMENSION(i1:i2,j1:j2), INTENT(inout) :: ptab
-      LOGICAL, INTENT(in) :: before
-      !
-      INTEGER :: ji,jj
-      REAL(wp) :: zrhox	
-      REAL(wp) :: ztref
-      !!---------------------------------------------    
-      ! 
-      ztref = 1.    
-      IF (before) THEN 
-         !interpv entre 1 et k2 et interpv2d en jpkp1
-         DO jj=j1,MIN(j2,nlcj-1)
-            DO ji=i1,i2
-               ptab(ji,jj) = e1v(ji,jj) * ((gcx(ji,jj+1) - gcx(ji,jj))/e2v(ji,jj)) * vmask(ji,jj,1)
-            END DO
-         END DO
-      ELSE           
-         zrhox = Agrif_Rhox()
-         DO ji=i1,i2
-            laplacv(ji,j1:j2) = ztref * (ptab(ji,j1:j2)/(zrhox*e1v(ji,j1:j2)))
-         END DO
-      ENDIF
-      !      
-   END SUBROUTINE interpvn2d
 
    SUBROUTINE interpunb(ptab,i1,i2,j1,j2,before,nb,ndir)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_sponge.F90	(revision 6041)
@@ -210,6 +210,6 @@
                DO jj = j1,j2-1
                   DO ji = i1,i2-1
-                     zabe1 = fsaht_spu(ji,jj) * umask(ji,jj,jk) * re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk)
-                     zabe2 = fsaht_spv(ji,jj) * vmask(ji,jj,jk) * re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk)
+                     zabe1 = fsaht_spu(ji,jj) * umask(ji,jj,jk) * e2_e1u(ji,jj) * fse3u_n(ji,jj,jk)
+                     zabe2 = fsaht_spv(ji,jj) * vmask(ji,jj,jk) * e1_e2v(ji,jj) * fse3v_n(ji,jj,jk)
                      ztu(ji,jj,jk) = zabe1 * ( tsbdiff(ji+1,jj  ,jk,jn) - tsbdiff(ji,jj,jk,jn) ) 
                      ztv(ji,jj,jk) = zabe2 * ( tsbdiff(ji  ,jj+1,jk,jn) - tsbdiff(ji,jj,jk,jn) )
@@ -239,5 +239,5 @@
 
                      IF (.NOT. tabspongedone_tsn(ji,jj)) THEN 
-                        zbtr = r1_e12t(ji,jj) / fse3t_n(ji,jj,jk)
+                        zbtr = r1_e1e2t(ji,jj) / fse3t_n(ji,jj,jk)
                         ! horizontal diffusive trends
                         ztsa = zbtr * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji  ,jj-1,jk)  )
@@ -290,5 +290,5 @@
             DO jj = j1,j2
                DO ji = i1+1,i2   ! vector opt.
-                  zbtr = r1_e12t(ji,jj) / fse3t_n(ji,jj,jk) * fsahm_spt(ji,jj)
+                  zbtr = r1_e1e2t(ji,jj) / fse3t_n(ji,jj,jk) * fsahm_spt(ji,jj)
                   hdivdiff(ji,jj,jk) = (  e2u(ji  ,jj)*fse3u_n(ji  ,jj,jk) * ubdiff(ji  ,jj,jk) &
                                      &   -e2u(ji-1,jj)*fse3u_n(ji-1,jj,jk) * ubdiff(ji-1,jj,jk) ) * zbtr
@@ -298,5 +298,5 @@
             DO jj = j1,j2-1
                DO ji = i1,i2   ! vector opt.
-                  zbtr = r1_e12f(ji,jj) * fse3f_n(ji,jj,jk) * fsahm_spf(ji,jj)
+                  zbtr = r1_e1e2f(ji,jj) * fse3f_n(ji,jj,jk) * fsahm_spf(ji,jj)
                   rotdiff(ji,jj,jk) = (-e1u(ji,jj+1) * ubdiff(ji,jj+1,jk) &
                                        +e1u(ji,jj  ) * ubdiff(ji,jj  ,jk) & 
@@ -396,5 +396,5 @@
             DO jj = j1+1,j2
                DO ji = i1,i2   ! vector opt.
-                  zbtr = r1_e12t(ji,jj) / fse3t_n(ji,jj,jk) * fsahm_spt(ji,jj)
+                  zbtr = r1_e1e2t(ji,jj) / fse3t_n(ji,jj,jk) * fsahm_spt(ji,jj)
                   hdivdiff(ji,jj,jk) = ( e1v(ji,jj  ) * fse3v(ji,jj  ,jk) * vbdiff(ji,jj  ,jk)  &
                                      &  -e1v(ji,jj-1) * fse3v(ji,jj-1,jk) * vbdiff(ji,jj-1,jk)  ) * zbtr
@@ -403,5 +403,5 @@
             DO jj = j1,j2
                DO ji = i1,i2-1   ! vector opt.
-                  zbtr = r1_e12f(ji,jj) * fse3f_n(ji,jj,jk) * fsahm_spf(ji,jj)
+                  zbtr = r1_e1e2f(ji,jj) * fse3f_n(ji,jj,jk) * fsahm_spf(ji,jj)
                   rotdiff(ji,jj,jk) = ( e2v(ji+1,jj) * vbdiff(ji+1,jj,jk) & 
                                     &  -e2v(ji  ,jj) * vbdiff(ji  ,jj,jk) &
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_opa_update.F90	(revision 6041)
@@ -11,5 +11,4 @@
    USE lib_mpp
    USE wrk_nemo  
-   USE dynspg_oce
    USE zdf_oce        ! vertical physics: ocean variables 
 
@@ -107,6 +106,5 @@
 # endif
 
-# if defined key_dynspg_ts
-      IF (ln_bt_fw) THEN
+      IF ( ln_dynspg_ts.AND.ln_bt_fw ) THEN
          ! Update time integrated transports
          IF (mod(nbcline,nbclineupdate) == 0) THEN
@@ -128,5 +126,4 @@
          ENDIF
       END IF
-# endif
       !
       nbcline = nbcline + 1
@@ -360,10 +357,10 @@
                !
                ! Update barotropic velocities:
-#if defined key_dynspg_ts
-               IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part
-                  zcorr = tabres(ji,jj) - un_b(ji,jj)
-                  ub_b(ji,jj) = ub_b(ji,jj) + atfp * zcorr * umask(ji,jj,1)
-               END IF
-#endif               
+               IF ( .NOT.ln_dynspg_ts .OR. (ln_dynspg_ts.AND.(.NOT.ln_bt_fw)) ) THEN
+                  IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part
+                     zcorr = tabres(ji,jj) - un_b(ji,jj)
+                     ub_b(ji,jj) = ub_b(ji,jj) + atfp * zcorr * umask(ji,jj,1)
+                  END IF
+               ENDIF             
                un_b(ji,jj) = tabres(ji,jj) * umask(ji,jj,1)
                !       
@@ -425,10 +422,10 @@
                !
                ! Update barotropic velocities:
-#if defined key_dynspg_ts
-               IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part
-                  zcorr = tabres(ji,jj) - vn_b(ji,jj)
-                  vb_b(ji,jj) = vb_b(ji,jj) + atfp * zcorr * vmask(ji,jj,1)
-               END IF
-#endif               
+               IF ( .NOT.ln_dynspg_ts .OR. (ln_dynspg_ts.AND.(.NOT.ln_bt_fw)) ) THEN
+                  IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN ! Add asselin part
+                     zcorr = tabres(ji,jj) - vn_b(ji,jj)
+                     vb_b(ji,jj) = vb_b(ji,jj) + atfp * zcorr * vmask(ji,jj,1)
+                  END IF
+               ENDIF              
                vn_b(ji,jj) = tabres(ji,jj) * vmask(ji,jj,1)
                !       
@@ -470,14 +467,15 @@
          END DO
       ELSE
-#if ! defined key_dynspg_ts
-         IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN
-            DO jj=j1,j2
-               DO ji=i1,i2
-                  sshb(ji,jj) =   sshb(ji,jj) &
-                        & + atfp * ( tabres(ji,jj) - sshn(ji,jj) ) * tmask(ji,jj,1)
-               END DO
-            END DO
+         IF ( .NOT.ln_dynspg_ts .OR. (ln_dynspg_ts.AND.(.NOT.ln_bt_fw)) ) THEN
+            IF (.NOT.(lk_agrif_fstep.AND.(neuler==0))) THEN
+               DO jj=j1,j2
+                  DO ji=i1,i2
+                     sshb(ji,jj) =   sshb(ji,jj) &
+                           & + atfp * ( tabres(ji,jj) - sshn(ji,jj) ) * tmask(ji,jj,1)
+                  END DO
+               END DO
+            ENDIF
          ENDIF
-#endif
+
          DO jj=j1,j2
             DO ji=i1,i2
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_top_interp.F90	(revision 6041)
@@ -4,5 +4,4 @@
    USE oce
    USE dom_oce      
-   USE sol_oce
    USE agrif_oce
    USE agrif_top_sponge
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_top_sponge.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_top_sponge.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_top_sponge.F90	(revision 6041)
@@ -74,6 +74,6 @@
                DO jj = j1,j2-1
                   DO ji = i1,i2-1
-                     zabe1 = fsaht_spu(ji,jj) * umask(ji,jj,jk) * re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk)
-                     zabe2 = fsaht_spv(ji,jj) * vmask(ji,jj,jk) * re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk)
+                     zabe1 = fsaht_spu(ji,jj) * umask(ji,jj,jk) * e2_e1u(ji,jj) * fse3u_n(ji,jj,jk)
+                     zabe2 = fsaht_spv(ji,jj) * vmask(ji,jj,jk) * e1_e2v(ji,jj) * fse3v_n(ji,jj,jk)
                      ztu(ji,jj) = zabe1 * ( trbdiff(ji+1,jj  ,jk,jn) - trbdiff(ji,jj,jk,jn) )
                      ztv(ji,jj) = zabe2 * ( trbdiff(ji  ,jj+1,jk,jn) - trbdiff(ji,jj,jk,jn) )
@@ -85,5 +85,5 @@
 
                      IF (.NOT. tabspongedone_trn(ji,jj)) THEN 
-                        zbtr = r1_e12t(ji,jj) / fse3t(ji,jj,jk)
+                        zbtr = r1_e1e2t(ji,jj) / fse3t(ji,jj,jk)
                         ! horizontal diffusive trends
                         ztra = zbtr * (  ztu(ji,jj) - ztu(ji-1,jj  ) + ztv(ji,jj) - ztv(ji  ,jj-1)  )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_user.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/NST_SRC/agrif_user.F90	(revision 6041)
@@ -104,5 +104,4 @@
    USE dom_oce
    USE nemogcm
-   USE sol_oce
    USE in_out_manager
    USE agrif_opa_update
@@ -172,5 +171,4 @@
    USE dom_oce
    USE nemogcm
-   USE sol_oce
    USE lib_mpp
    USE in_out_manager
@@ -210,18 +208,18 @@
    CALL Agrif_Bc_variable(vn_sponge_id,calledweight=1.,procname=interpvn_sponge)
 
-#if defined key_dynspg_ts
    Agrif_UseSpecialValue = .TRUE.
    CALL Agrif_Bc_variable(sshn_id,calledweight=1., procname=interpsshn )
 
-   Agrif_UseSpecialValue = ln_spc_dyn
-   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)
-   ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 ; hbdy_w(:) =0.e0
-   ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 ; hbdy_e(:) =0.e0 
-   ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 ; hbdy_n(:) =0.e0 
-   ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 ; hbdy_s(:) =0.e0
-#endif
+   IF ( ln_dynspg_ts ) THEN
+      Agrif_UseSpecialValue = ln_spc_dyn
+      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)
+      ubdy_w(:) = 0.e0 ; vbdy_w(:) = 0.e0 ; hbdy_w(:) =0.e0
+      ubdy_e(:) = 0.e0 ; vbdy_e(:) = 0.e0 ; hbdy_e(:) =0.e0 
+      ubdy_n(:) = 0.e0 ; vbdy_n(:) = 0.e0 ; hbdy_n(:) =0.e0 
+      ubdy_s(:) = 0.e0 ; vbdy_s(:) = 0.e0 ; hbdy_s(:) =0.e0
+   ENDIF
 
    Agrif_UseSpecialValue = .FALSE. 
@@ -278,4 +276,17 @@
          ENDIF
       ENDIF
+
+      ! Check free surface scheme
+      IF ( ( Agrif_Parent(ln_dynspg_ts ).AND.ln_dynspg_exp ).OR.&
+         & ( Agrif_Parent(ln_dynspg_exp).AND.ln_dynspg_ts ) ) THEN
+         WRITE(*,*) 'incompatible free surface scheme between grids'
+         WRITE(*,*) 'parent grid ln_dynspg_ts  :', Agrif_Parent(ln_dynspg_ts )
+         WRITE(*,*) 'parent grid ln_dynspg_exp :', Agrif_Parent(ln_dynspg_exp)
+         WRITE(*,*) 'child grid  ln_dynspg_ts  :', ln_dynspg_ts
+         WRITE(*,*) 'child grid  ln_dynspg_exp :', ln_dynspg_exp
+         WRITE(*,*) 'those logicals should be identical'                  
+         STOP
+      ENDIF
+
       ! check if masks and bathymetries match
       IF(ln_chk_bathy) THEN
@@ -319,5 +330,5 @@
    !
    Agrif_UseSpecialValueInUpdate = .FALSE.
-   nbcline = 0
+   nbcline = 0 
    lk_agrif_doupd = .FALSE.
    !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/domrea.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/domrea.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/domrea.F90	(revision 6041)
@@ -4,4 +4,11 @@
    !! Ocean initialization : domain initialization
    !!==============================================================================
+   !! History :  OPA  ! 1990-10  (C. Levy - G. Madec)  Original code
+   !!                 ! 1992-01  (M. Imbard) insert time step initialization
+   !!                 ! 1996-06  (G. Madec) generalized vertical coordinate 
+   !!                 ! 1997-02  (G. Madec) creation of domwri.F
+   !!                 ! 2001-05  (E.Durand - G. Madec) insert closed sea
+   !!  NEMO      1.0  ! 2002-08  (G. Madec)  F90: Free form and module
+   !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
@@ -10,15 +17,13 @@
    !!   dom_ctl        : control print for the ocean domain
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE oce             ! 
+   USE trc_oce         ! shared ocean/biogeochemical variables
    USE dom_oce         ! ocean space and time domain
    USE phycst          ! physical constants
+   USE domstp          ! domain: set the time-step
+   !
    USE in_out_manager  ! I/O manager
    USE lib_mpp         ! distributed memory computing library
-
-   USE domstp          ! domain: set the time-step
-
    USE lbclnk          ! lateral boundary condition - MPP exchanges
-   USE trc_oce         ! shared ocean/biogeochemical variables
    USE wrk_nemo  
    
@@ -26,6 +31,5 @@
    PRIVATE
 
-   !! * Routine accessibility
-   PUBLIC dom_rea       ! called by opa.F90
+   PUBLIC   dom_rea    ! called by nemogcm.F90
 
    !! * Substitutions
@@ -33,9 +37,8 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OFF 3.3 , NEMO Consortium (2010)
+   !! NEMO/OFF 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -51,19 +54,9 @@
       !!      - dom_stp: defined the model time step
       !!      - dom_rea: read the meshmask file if nmsh=1
-      !!
-      !! History :
-      !!        !  90-10  (C. Levy - G. Madec)  Original code
-      !!        !  91-11  (G. Madec)
-      !!        !  92-01  (M. Imbard) insert time step initialization
-      !!        !  96-06  (G. Madec) generalized vertical coordinate 
-      !!        !  97-02  (G. Madec) creation of domwri.F
-      !!        !  01-05  (E.Durand - G. Madec) insert closed sea
-      !!   8.5  !  02-08  (G. Madec)  F90: Free form and module
-      !!----------------------------------------------------------------------
-      !! * Local declarations
-      INTEGER ::   jk                ! dummy loop argument
-      INTEGER ::   iconf = 0         ! temporary integers
-      !!----------------------------------------------------------------------
-
+      !!----------------------------------------------------------------------
+      INTEGER ::   jk          ! dummy loop index
+      INTEGER ::   iconf = 0   ! local integers
+      !!----------------------------------------------------------------------
+      !
       IF(lwp) THEN
          WRITE(numout,*)
@@ -71,25 +64,25 @@
          WRITE(numout,*) '~~~~~~~~'
       ENDIF
-
-      CALL dom_nam      ! read namelist ( namrun, namdom, namcla )
+      !
+      CALL dom_nam      ! read namelist ( namrun, namdom )
       CALL dom_zgr      ! Vertical mesh and bathymetry option
       CALL dom_grd      ! Create a domain file
-
-     !
-      ! - ML - Used in dom_vvl_sf_nxt and lateral diffusion routines
-      !        but could be usefull in many other routines
-      e12t    (:,:) = e1t(:,:) * e2t(:,:)
-      e1e2t   (:,:) = e1t(:,:) * e2t(:,:)
-      e12u    (:,:) = e1u(:,:) * e2u(:,:)
-      e12v    (:,:) = e1v(:,:) * e2v(:,:)
-      e12f    (:,:) = e1f(:,:) * e2f(:,:)
-      r1_e12t (:,:) = 1._wp    / e12t(:,:)
-      r1_e12u (:,:) = 1._wp    / e12u(:,:)
-      r1_e12v (:,:) = 1._wp    / e12v(:,:)
-      r1_e12f (:,:) = 1._wp    / e12f(:,:)
-      re2u_e1u(:,:) = e2u(:,:) / e1u(:,:)
-      re1v_e2v(:,:) = e1v(:,:) / e2v(:,:)
-      !
-      hu(:,:) = 0._wp                          ! Ocean depth at U- and V-points
+      !
+      !                                      ! associated horizontal metrics
+      !
+      r1_e1t(:,:) = 1._wp / e1t(:,:)   ;   r1_e2t (:,:) = 1._wp / e2t(:,:)
+      r1_e1u(:,:) = 1._wp / e1u(:,:)   ;   r1_e2u (:,:) = 1._wp / e2u(:,:)
+      r1_e1v(:,:) = 1._wp / e1v(:,:)   ;   r1_e2v (:,:) = 1._wp / e2v(:,:)
+      r1_e1f(:,:) = 1._wp / e1f(:,:)   ;   r1_e2f (:,:) = 1._wp / e2f(:,:)
+      !
+      e1e2t (:,:) = e1t(:,:) * e2t(:,:)   ;   r1_e1e2t(:,:) = 1._wp / e1e2t(:,:)
+      e1e2u (:,:) = e1u(:,:) * e2u(:,:)   ;   r1_e1e2u(:,:) = 1._wp / e1e2u(:,:)
+      e1e2v (:,:) = e1v(:,:) * e2v(:,:)   ;   r1_e1e2v(:,:) = 1._wp / e1e2v(:,:)
+      e1e2f (:,:) = e1f(:,:) * e2f(:,:)   ;   r1_e1e2f(:,:) = 1._wp / e1e2f(:,:)
+      !   
+      e2_e1u(:,:) = e2u(:,:) / e1u(:,:)
+      e1_e2v(:,:) = e1v(:,:) / e2v(:,:)
+      !
+      hu(:,:) = 0._wp                        ! Ocean depth at U- and V-points
       hv(:,:) = 0._wp
       DO jk = 1, jpk
@@ -100,10 +93,11 @@
       hur(:,:) = 1._wp / ( hu(:,:) + 1._wp - umask(:,:,1) ) * umask(:,:,1)
       hvr(:,:) = 1._wp / ( hv(:,:) + 1._wp - vmask(:,:,1) ) * vmask(:,:,1)
-
+      !
       CALL dom_stp      ! Time step
       CALL dom_msk      ! Masks
       CALL dom_ctl      ! Domain control
-
+      !
    END SUBROUTINE dom_rea
+
 
    SUBROUTINE dom_nam
@@ -115,8 +109,8 @@
       !! ** input   : - namrun namelist
       !!              - namdom namelist
-      !!              - namcla namelist
       !!----------------------------------------------------------------------
       USE ioipsl
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
+      INTEGER  ::   ios   ! Local integer output status for namelist read
+      !
       NAMELIST/namrun/ cn_ocerst_indir, cn_ocerst_outdir, nn_stocklist, ln_rst_list,               &
          &             nn_no   , cn_exp    , cn_ocerst_in, cn_ocerst_out, ln_rstart , nn_rstctl,   &
@@ -130,5 +124,4 @@
          &             ppsur, ppa0, ppa1, ppkth, ppacr, ppdzmin, pphmax, ldbletanh, &
          &             ppa2, ppkth2, ppacr2
-      NAMELIST/namcla/ nn_cla
 #if defined key_netcdf4
       NAMELIST/namnc4/ nn_nchunks_i, nn_nchunks_j, nn_nchunks_k, ln_nc4zip
@@ -178,6 +171,5 @@
       nstocklist = nn_stocklist
       nwrite = nn_write
-
-
+      !
       !                             ! control of output frequency
       IF ( nstock == 0 .OR. nstock > nitend ) THEN
@@ -275,19 +267,4 @@
       rdth      = rn_rdth
 
-      REWIND( numnam_ref )              ! Namelist namcla in reference namelist : Cross land advection
-      READ  ( numnam_ref, namcla, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcla in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namcla in configuration namelist : Cross land advection
-      READ  ( numnam_cfg, namcla, IOSTAT = ios, ERR = 906 )
-906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcla in configuration namelist', lwp )
-      IF(lwm) WRITE( numond, namcla )
-
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '   Namelist namcla'
-         WRITE(numout,*) '      cross land advection                 nn_cla    = ', nn_cla
-      ENDIF
-
 #if defined key_netcdf4
       !                             ! NetCDF 4 case   ("key_netcdf4" defined)
@@ -321,4 +298,5 @@
    END SUBROUTINE dom_nam
 
+
    SUBROUTINE dom_zgr
       !!----------------------------------------------------------------------
@@ -374,4 +352,5 @@
    END SUBROUTINE dom_zgr
 
+
    SUBROUTINE dom_ctl
       !!----------------------------------------------------------------------
@@ -382,8 +361,5 @@
       !! ** Method  :   compute and print extrema of masked scale factors
       !!
-      !! History :
-      !!   8.5  !  02-08  (G. Madec)    Original code
-      !!----------------------------------------------------------------------
-      !! * Local declarations
+      !!----------------------------------------------------------------------
       INTEGER ::   iimi1, ijmi1, iimi2, ijmi2, iima1, ijma1, iima2, ijma2
       INTEGER, DIMENSION(2) ::   iloc      ! 
@@ -421,5 +397,5 @@
          ijma2 = iloc(2) + njmpp - 1
       ENDIF
-
+      !
       IF(lwp) THEN
          WRITE(numout,"(14x,'e1t maxi: ',1f10.2,' at i = ',i5,' j= ',i5)") ze1max, iima1, ijma1
@@ -428,6 +404,7 @@
          WRITE(numout,"(14x,'e2t mini: ',1f10.2,' at i = ',i5,' j= ',i5)") ze2min, iimi2, ijmi2
       ENDIF
-
+      !
    END SUBROUTINE dom_ctl
+
 
    SUBROUTINE dom_grd
@@ -538,5 +515,4 @@
          CALL iom_get( inum2, jpdom_data, 'facvolt', facvol )
 #endif
-
          !                                                         ! horizontal mesh (inum3)
          CALL iom_get( inum3, jpdom_data, 'glamt', glamt )
@@ -756,5 +732,4 @@
       !!                                     (min value = 1 over land)
       !!----------------------------------------------------------------------
-      !
       INTEGER ::   ji, jj   ! dummy loop indices
       REAL(wp), POINTER, DIMENSION(:,:) :: zmbk
@@ -785,4 +760,5 @@
    END SUBROUTINE zgr_bot_level
 
+
    SUBROUTINE dom_msk
       !!---------------------------------------------------------------------
@@ -799,9 +775,7 @@
       !!               tpol     : ???
       !!----------------------------------------------------------------------
-      !
-      INTEGER  ::   ji, jj, jk                   ! dummy loop indices
-      INTEGER  ::   iif, iil, ijf, ijl       ! local integers
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      INTEGER  ::   iif, iil, ijf, ijl   ! local integers
       INTEGER, POINTER, DIMENSION(:,:) ::  imsk 
-      !
       !!---------------------------------------------------------------------
       
@@ -853,11 +827,11 @@
       ! 3. Ocean/land mask at wu-, wv- and w points 
       !----------------------------------------------
-      wmask (:,:,1) = tmask(:,:,1) ! ????????
-      wumask(:,:,1) = umask(:,:,1) ! ????????
-      wvmask(:,:,1) = vmask(:,:,1) ! ????????
-      DO jk=2,jpk
-         wmask (:,:,jk)=tmask(:,:,jk) * tmask(:,:,jk-1)
-         wumask(:,:,jk)=umask(:,:,jk) * umask(:,:,jk-1)   
-         wvmask(:,:,jk)=vmask(:,:,jk) * vmask(:,:,jk-1)
+      wmask (:,:,1) = tmask(:,:,1)        ! surface value
+      wumask(:,:,1) = umask(:,:,1) 
+      wvmask(:,:,1) = vmask(:,:,1)
+      DO jk = 2, jpk                      ! deeper value
+         wmask (:,:,jk) = tmask(:,:,jk) * tmask(:,:,jk-1)
+         wumask(:,:,jk) = umask(:,:,jk) * umask(:,:,jk-1)   
+         wvmask(:,:,jk) = vmask(:,:,jk) * vmask(:,:,jk-1)
       END DO
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/dtadyn.F90	(revision 6041)
@@ -26,8 +26,7 @@
    USE trc_oce         ! share ocean/biogeo variables
    USE phycst          ! physical constants
+   USE ldftra          ! lateral diffusivity coefficients
    USE trabbl          ! active tracer: bottom boundary layer
    USE ldfslp          ! lateral diffusion: iso-neutral slopes
-   USE ldfeiv          ! eddy induced velocity coef. 
-   USE ldftra_oce      ! ocean tracer   lateral physics
    USE zdfmxl          ! vertical physics: mixed layer depth
    USE eosbn2          ! equation of state - Brunt Vaisala frequency
@@ -40,4 +39,5 @@
    USE fldread         ! read input fields 
    USE timing          ! Timing
+   USE wrk_nemo
 
    IMPLICIT NONE
@@ -50,8 +50,7 @@
    LOGICAL            ::   ln_dynwzv    !: vertical velocity read in a file (T) or computed from u/v (F)
    LOGICAL            ::   ln_dynbbl    !: bbl coef read in a file (T) or computed (F)
-   LOGICAL            ::   ln_degrad    !: degradation option enabled or not
    LOGICAL            ::   ln_dynrnf    !: read runoff data in file (T) or set to zero (F)
 
-   INTEGER  , PARAMETER ::   jpfld = 21     ! maximum number of fields to read
+   INTEGER  , PARAMETER ::   jpfld = 15     ! maximum number of fields to read
    INTEGER  , SAVE      ::   jf_tem         ! index of temperature
    INTEGER  , SAVE      ::   jf_sal         ! index of salinity
@@ -68,10 +67,4 @@
    INTEGER  , SAVE      ::   jf_ubl         ! index of u-bbl coef
    INTEGER  , SAVE      ::   jf_vbl         ! index of v-bbl coef
-   INTEGER  , SAVE      ::   jf_ahu         ! index of u-diffusivity coef
-   INTEGER  , SAVE      ::   jf_ahv         ! index of v-diffusivity coef 
-   INTEGER  , SAVE      ::   jf_ahw         ! index of w-diffusivity coef
-   INTEGER  , SAVE      ::   jf_eiu         ! index of u-eiv
-   INTEGER  , SAVE      ::   jf_eiv         ! index of v-eiv
-   INTEGER  , SAVE      ::   jf_eiw         ! index of w-eiv
    INTEGER  , SAVE      ::   jf_fmf         ! index of downward salt flux
 
@@ -112,11 +105,15 @@
       !!             - interpolates data if needed
       !!----------------------------------------------------------------------
-      !
-      USE oce, ONLY:  zts    => tsa 
+      USE oce, ONLY:  zts    => tsa
       USE oce, ONLY:  zuslp  => ua   , zvslp  => va
-      USE oce, ONLY:  zwslpi => rotb , zwslpj => rotn
-      USE oce, ONLY:  zu     => ub   , zv     => vb,  zw => hdivb
+      USE zdf_oce, ONLY:  zwslpi => avmu , zwslpj => avmv 
+      USE oce, ONLY:  zu     => ub   , zv     => vb,  zw => rke
       !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
+!      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts)  :: zts
+!      REAL(wp), DIMENSION(jpi,jpj,jpk     )  :: zuslp, zvslp, zwslpi, zwslpj
+!      REAL(wp), DIMENSION(jpi,jpj,jpk     )  :: zu, zv, zw
+      !
       !
       INTEGER  ::   ji, jj     ! dummy loop indices
@@ -138,5 +135,5 @@
          CALL fld_read( kt, 1, sf_dyn )      !==   read data at kt time step   ==!
          !
-         IF( lk_ldfslp .AND. .NOT.lk_c1d .AND. sf_dyn(jf_tem)%ln_tint ) THEN    ! Computes slopes (here avt is used as workspace)                       
+         IF( l_ldfslp .AND. .NOT.lk_c1d .AND. sf_dyn(jf_tem)%ln_tint ) THEN    ! Computes slopes (here avt is used as workspace)                       
             zts(:,:,:,jp_tem) = sf_dyn(jf_tem)%fdta(:,:,:,1) * tmask(:,:,:)   ! temperature
             zts(:,:,:,jp_sal) = sf_dyn(jf_sal)%fdta(:,:,:,1) * tmask(:,:,:)   ! salinity 
@@ -162,5 +159,5 @@
       ENDIF
       ! 
-      IF( lk_ldfslp .AND. .NOT.lk_c1d ) THEN    ! Computes slopes (here avt is used as workspace)                       
+      IF( l_ldfslp .AND. .NOT.lk_c1d ) THEN    ! Computes slopes (here avt is used as workspace)                       
          iswap_tem = 0
          IF(  kt /= nit000 .AND. ( sf_dyn(jf_tem)%nrec_a(2) - nrecprev_tem ) /= 0 )  iswap_tem = 1
@@ -267,4 +264,6 @@
       rnf (:,:)        = sf_dyn(jf_rnf)%fnow(:,:,1) * tmask(:,:,1)    ! river runoffs 
 
+      !                                               ! update eddy diffusivity coeff. and/or eiv coeff. at kt
+      IF( l_ldftra_time .OR. l_ldfeiv_time )   CALL ldf_tra( kt ) 
       !                                                      ! bbl diffusive coef
 #if defined key_trabbl && ! defined key_c1d
@@ -276,27 +275,4 @@
          CALL bbl( kt, nit000, 'TRC')
       END IF
-#endif
-#if ( ! defined key_degrad && defined key_traldf_c2d && defined key_traldf_eiv ) && ! defined key_c1d 
-      aeiw(:,:)        = sf_dyn(jf_eiw)%fnow(:,:,1) * tmask(:,:,1)    ! w-eiv
-      !                                                           ! Computes the horizontal values from the vertical value
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            aeiu(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji+1,jj  ) )  ! Average the diffusive coefficient at u- v- points
-            aeiv(ji,jj) = .5 * ( aeiw(ji,jj) + aeiw(ji  ,jj+1) )  ! at u- v- points
-         END DO
-      END DO
-      CALL lbc_lnk( aeiu, 'U', 1. )   ;   CALL lbc_lnk( aeiv, 'V', 1. )    ! lateral boundary condition
-#endif
-      
-#if defined key_degrad && ! defined key_c1d 
-      !                                          ! degrad option : diffusive and eiv coef are 3D
-      ahtu(:,:,:) = sf_dyn(jf_ahu)%fnow(:,:,:) * umask(:,:,:)
-      ahtv(:,:,:) = sf_dyn(jf_ahv)%fnow(:,:,:) * vmask(:,:,:)
-      ahtw(:,:,:) = sf_dyn(jf_ahw)%fnow(:,:,:) * tmask(:,:,:)
-#  if defined key_traldf_eiv 
-      aeiu(:,:,:) = sf_dyn(jf_eiu)%fnow(:,:,:) * umask(:,:,:)
-      aeiv(:,:,:) = sf_dyn(jf_eiv)%fnow(:,:,:) * vmask(:,:,:)
-      aeiw(:,:,:) = sf_dyn(jf_eiw)%fnow(:,:,:) * tmask(:,:,:)
-#  endif
 #endif
       !
@@ -339,12 +315,9 @@
       TYPE(FLD_N), DIMENSION(jpfld) ::  slf_d    ! array of namelist informations on the fields to read
       TYPE(FLD_N) :: sn_tem, sn_sal, sn_mld, sn_emp, sn_ice, sn_qsr, sn_wnd, sn_rnf  ! informations about the fields to be read
-      TYPE(FLD_N) :: sn_uwd, sn_vwd, sn_wwd, sn_avt, sn_ubl, sn_vbl          !   "                                 "
-      TYPE(FLD_N) :: sn_ahu, sn_ahv, sn_ahw, sn_eiu, sn_eiv, sn_eiw, sn_fmf  !   "                                 "
-      !!----------------------------------------------------------------------
-      !
-      NAMELIST/namdta_dyn/cn_dir, ln_dynwzv, ln_dynbbl, ln_degrad, ln_dynrnf,    &
+      TYPE(FLD_N) :: sn_uwd, sn_vwd, sn_wwd, sn_avt, sn_ubl, sn_vbl, sn_fmf          !   "                                 "
+      NAMELIST/namdta_dyn/cn_dir, ln_dynwzv, ln_dynbbl, ln_dynrnf,    &
          &                sn_tem, sn_sal, sn_mld, sn_emp, sn_ice, sn_qsr, sn_wnd, sn_rnf,  &
-         &                sn_uwd, sn_vwd, sn_wwd, sn_avt, sn_ubl, sn_vbl,          &
-         &                sn_ahu, sn_ahv, sn_ahw, sn_eiu, sn_eiv, sn_eiw, sn_fmf
+         &                sn_uwd, sn_vwd, sn_wwd, sn_avt, sn_ubl, sn_vbl, sn_fmf  
+      !!----------------------------------------------------------------------
       !
       REWIND( numnam_ref )              ! Namelist namdta_dyn in reference namelist : Offline: init. of dynamical data
@@ -365,13 +338,8 @@
          WRITE(numout,*) '      vertical velocity read from file (T) or computed (F) ln_dynwzv  = ', ln_dynwzv
          WRITE(numout,*) '      bbl coef read from file (T) or computed (F)          ln_dynbbl  = ', ln_dynbbl
-         WRITE(numout,*) '      degradation option enabled (T) or not (F)            ln_degrad  = ', ln_degrad
          WRITE(numout,*) '      river runoff option enabled (T) or not (F)           ln_dynrnf  = ', ln_dynrnf
          WRITE(numout,*)
       ENDIF
       ! 
-      IF( ln_degrad .AND. .NOT.lk_degrad ) THEN
-         CALL ctl_warn( 'dta_dyn_init: degradation option requires key_degrad activated ; force ln_degrad to false' )
-         ln_degrad = .FALSE.
-      ENDIF
       IF( ln_dynbbl .AND. ( .NOT.lk_trabbl .OR. lk_c1d ) ) THEN
          CALL ctl_warn( 'dta_dyn_init: bbl option requires key_trabbl activated ; force ln_dynbbl to false' )
@@ -395,36 +363,10 @@
       ENDIF
 
-      !
-      IF( .NOT.ln_degrad ) THEN     ! no degrad option
-         IF( lk_traldf_eiv .AND. ln_dynbbl ) THEN        ! eiv & bbl
-                 jf_ubl  = jfld + 1 ;        jf_vbl  = jfld + 2 ;        jf_eiw  = jfld + 3   ;   jfld = jf_eiw
-           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl  ;   slf_d(jf_eiw) = sn_eiw
-         ENDIF
-         IF( .NOT.lk_traldf_eiv .AND. ln_dynbbl ) THEN   ! no eiv & bbl
+      IF( ln_dynbbl ) THEN         ! eiv & bbl
                  jf_ubl  = jfld + 1 ;        jf_vbl  = jfld + 2 ;  jfld = jf_vbl
            slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl
-         ENDIF
-         IF( lk_traldf_eiv .AND. .NOT.ln_dynbbl ) THEN   ! eiv & no bbl
-           jf_eiw = jfld + 1 ; jfld = jf_eiw ; slf_d(jf_eiw) = sn_eiw
-         ENDIF
-      ELSE
-              jf_ahu  = jfld + 1 ;        jf_ahv  = jfld + 2 ;        jf_ahw  = jfld + 3  ;  jfld = jf_ahw
-        slf_d(jf_ahu) = sn_ahu  ;   slf_d(jf_ahv) = sn_ahv  ;   slf_d(jf_ahw) = sn_ahw
-        IF( lk_traldf_eiv .AND. ln_dynbbl ) THEN         ! eiv & bbl
-                 jf_ubl  = jfld + 1 ;        jf_vbl  = jfld + 2 ;
-           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl
-                 jf_eiu  = jfld + 3 ;        jf_eiv  = jfld + 4 ;    jf_eiw  = jfld + 5   ;  jfld = jf_eiw 
-           slf_d(jf_eiu) = sn_eiu  ;   slf_d(jf_eiv) = sn_eiv  ;    slf_d(jf_eiw) = sn_eiw
-        ENDIF
-        IF( .NOT.lk_traldf_eiv .AND. ln_dynbbl ) THEN    ! no eiv & bbl
-                 jf_ubl  = jfld + 1 ;        jf_vbl  = jfld + 2 ;  jfld = jf_vbl
-           slf_d(jf_ubl) = sn_ubl  ;   slf_d(jf_vbl) = sn_vbl
-        ENDIF
-        IF( lk_traldf_eiv .AND. .NOT.ln_dynbbl ) THEN    ! eiv & no bbl
-                 jf_eiu  = jfld + 1 ;         jf_eiv  = jfld + 2 ;    jf_eiw  = jfld + 3   ; jfld = jf_eiw 
-           slf_d(jf_eiu) = sn_eiu  ;   slf_d(jf_eiv) = sn_eiv  ;   slf_d(jf_eiw) = sn_eiw
-        ENDIF
-      ENDIF
-  
+      ENDIF
+
+
       ALLOCATE( sf_dyn(jfld), STAT=ierr )         ! set sf structure
       IF( ierr > 0 ) THEN
@@ -452,5 +394,5 @@
       END DO
       !
-      IF( lk_ldfslp .AND. .NOT.lk_c1d ) THEN                  ! slopes 
+      IF( l_ldfslp .AND. .NOT.lk_c1d ) THEN                  ! slopes 
          IF( sf_dyn(jf_tem)%ln_tint ) THEN      ! time interpolation
             ALLOCATE( uslpdta (jpi,jpj,jpk,2), vslpdta (jpi,jpj,jpk,2),    &
@@ -511,11 +453,13 @@
                zv  = pv(ji  ,jj  ,jk) * vmask(ji  ,jj  ,jk) * e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk)
                zv1 = pv(ji  ,jj-1,jk) * vmask(ji  ,jj-1,jk) * e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk)
-               zet = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+               zet = 1. / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
                zhdiv(ji,jj,jk) = ( zu - zu1 + zv - zv1 ) * zet 
             END DO
          END DO
       END DO
+      !                              !  update the horizontal divergence with the runoff inflow
+      IF( ln_dynrnf )  zhdiv(:,:,1) = zhdiv(:,:,1) - rnf(:,:) * r1_rau0 / fse3t(:,:,1)
+      !
       CALL lbc_lnk( zhdiv, 'T', 1. )      ! Lateral boundary conditions on zhdiv
-      !
       ! computation of vertical velocity from the bottom
       pw(:,:,jpk) = 0._wp
@@ -540,31 +484,31 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(out) :: pwslpj   ! meridional diapycnal slopes
       !!---------------------------------------------------------------------
-#if defined key_ldfslp && ! defined key_c1d
-      CALL eos    ( pts, rhd, rhop, gdept_0(:,:,:) )
-      CALL eos_rab( pts, rab_n )       ! now local thermal/haline expension ratio at T-points
-      CALL bn2    ( pts, rab_n, rn2  ) ! now    Brunt-Vaisala
-
-      ! Partial steps: before Horizontal DErivative
-      IF( ln_zps  .AND. .NOT. ln_isfcav)                            &
-         &            CALL zps_hde    ( kt, jpts, pts, gtsu, gtsv,  &  ! Partial steps: before horizontal gradient
-         &                                        rhd, gru , grv    )  ! of t, s, rd at the last ocean level
-      IF( ln_zps .AND.        ln_isfcav)                            &
-         &            CALL zps_hde_isf( kt, jpts, pts, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
-         &                                        rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-         &                                 gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the first ocean level
-
-      rn2b(:,:,:) = rn2(:,:,:)         ! need for zdfmxl
-      CALL zdf_mxl( kt )            ! mixed layer depth
-      CALL ldf_slp( kt, rhd, rn2 )  ! slopes
-      puslp (:,:,:) = uslp (:,:,:) 
-      pvslp (:,:,:) = vslp (:,:,:) 
-      pwslpi(:,:,:) = wslpi(:,:,:) 
-      pwslpj(:,:,:) = wslpj(:,:,:) 
-#else
-      puslp (:,:,:) = 0.            ! to avoid warning when compiling
-      pvslp (:,:,:) = 0.
-      pwslpi(:,:,:) = 0.
-      pwslpj(:,:,:) = 0.
-#endif
+      IF( l_ldfslp .AND. .NOT.lk_c1d ) THEN    ! Computes slopes (here avt is used as workspace)                       
+         CALL eos    ( pts, rhd, rhop, gdept_0(:,:,:) )
+         CALL eos_rab( pts, rab_n )       ! now local thermal/haline expension ratio at T-points
+         CALL bn2    ( pts, rab_n, rn2  ) ! now    Brunt-Vaisala
+
+         ! Partial steps: before Horizontal DErivative
+         IF( ln_zps  .AND. .NOT. ln_isfcav)                            &
+            &            CALL zps_hde    ( kt, jpts, pts, gtsu, gtsv,  &  ! Partial steps: before horizontal gradient
+            &                                        rhd, gru , grv    )  ! of t, s, rd at the last ocean level
+         IF( ln_zps .AND.        ln_isfcav)                            &
+            &            CALL zps_hde_isf( kt, jpts, pts, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
+            &                                        rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
+            &                                 gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the first ocean level
+
+         rn2b(:,:,:) = rn2(:,:,:)         ! need for zdfmxl
+         CALL zdf_mxl( kt )            ! mixed layer depth
+         CALL ldf_slp( kt, rhd, rn2 )  ! slopes
+         puslp (:,:,:) = uslp (:,:,:) 
+         pvslp (:,:,:) = vslp (:,:,:) 
+         pwslpi(:,:,:) = wslpi(:,:,:) 
+         pwslpj(:,:,:) = wslpj(:,:,:) 
+     ELSE
+         puslp (:,:,:) = 0.            ! to avoid warning when compiling
+         pvslp (:,:,:) = 0.
+         pwslpi(:,:,:) = 0.
+         pwslpj(:,:,:) = 0.
+     ENDIF
       !
    END SUBROUTINE dta_dyn_slp
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OFF_SRC/nemogcm.F90	(revision 6041)
@@ -26,4 +26,5 @@
    USE traqsr          ! solar radiation penetration    (tra_qsr_init routine)
    USE trabbl          ! bottom boundary layer          (tra_bbl_init routine)
+   USE traldf          ! lateral physics                (tra_ldf_init routine)
    USE zdfini          ! vertical physics: initialization
    USE sbcmod          ! surface boundary condition       (sbc_init     routine)
@@ -283,8 +284,8 @@
                             CALL     sbc_init   ! Forcings : surface module
 
-#if ! defined key_degrad
                             CALL ldf_tra_init   ! Lateral ocean tracer physics
-#endif
-      IF( lk_ldfslp )       CALL ldf_slp_init   ! slope of lateral mixing
+                            CALL ldf_eiv_init   ! Eddy induced velocity param
+                            CALL tra_ldf_init   ! lateral mixing
+      IF( l_ldfslp )        CALL ldf_slp_init   ! slope of lateral mixing
 
                             CALL tra_qsr_init   ! penetrative solar radiation qsr
@@ -444,5 +445,4 @@
       USE dom_oce,      ONLY: dom_oce_alloc
       USE zdf_oce,      ONLY: zdf_oce_alloc
-      USE ldftra_oce,   ONLY: ldftra_oce_alloc
       USE trc_oce,      ONLY: trc_oce_alloc
       !
@@ -453,5 +453,4 @@
       ierr = ierr + dia_wri_alloc   ()
       ierr = ierr + dom_oce_alloc   ()          ! ocean domain
-      ierr = ierr + ldftra_oce_alloc()          ! ocean lateral  physics : tracers
       ierr = ierr + zdf_oce_alloc   ()          ! ocean vertical physics
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asmbkg.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asmbkg.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asmbkg.F90	(revision 6041)
@@ -18,6 +18,4 @@
 
    !!----------------------------------------------------------------------
-   !!   'key_asminc' : Switch on the assimilation increment interface
-   !!----------------------------------------------------------------------
    !!   asm_bkg_wri  : Write out the background state
    !!   asm_trj_wri  : Write out the model state trajectory (used with 4D-Var)
@@ -27,6 +25,6 @@
    USE zdf_oce            ! Vertical mixing variables
    USE zdfddm             ! Double diffusion mixing parameterization
-   USE ldftra_oce         ! Lateral tracer mixing coefficient defined in memory
-   USE ldfslp             ! Slopes of neutral surfaces
+   USE ldftra             ! Lateral diffusion: eddy diffusivity coefficients
+   USE ldfslp             ! Lateral diffusion: slopes of neutral surfaces
    USE tradmp             ! Tracer damping
 #if defined key_zdftke
@@ -36,12 +34,8 @@
    USE zdfmxl             ! Mixed layer depth
    USE dom_oce, ONLY :   ndastp
-   USE sol_oce, ONLY :   gcx   ! Solver variables defined in memory
    USE in_out_manager     ! I/O manager
    USE iom                ! I/O module
    USE asmpar             ! Parameters for the assmilation interface
    USE zdfmxl             ! mixed layer depth
-#if defined key_traldf_c2d
-   USE ldfeiv             ! eddy induced velocity coef.      (ldf_eiv routine)
-#endif
 #if defined key_lim2
    USE ice_2
@@ -119,5 +113,4 @@
             CALL iom_rstput( kt, nitbkg_r, inum, 'en'     , en                )
 #endif
-            CALL iom_rstput( kt, nitbkg_r, inum, 'gcx'    , gcx               )
             !
             CALL iom_close( inum )
@@ -155,10 +148,10 @@
             CALL iom_rstput( kt, nitdin_r, inum, 'sshn'   , sshn              )
 #if defined key_lim2 || defined key_lim3
-            IF(( nn_ice == 2 ) .OR. ( nn_ice == 3 )) THEN
-	       IF(ALLOCATED(frld)) THEN
-                  CALL iom_rstput( kt, nitdin_r, inum, 'iceconc', 1.0 - frld(:,:)   )
+            IF( nn_ice == 2  .OR.  nn_ice == 3 ) THEN
+	            IF( ALLOCATED(frld) ) THEN
+                  CALL iom_rstput( kt, nitdin_r, inum, 'iceconc', 1._wp - frld(:,:)   )
                ELSE
-		  CALL ctl_warn('Ice concentration not written to background as ice variable frld not allocated on this timestep')
-	       ENDIF
+		            CALL ctl_warn('Ice concentration not written to background as ice variable frld not allocated on this timestep')
+	            ENDIF
             ENDIF
 #endif
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asminc.F90	(revision 6041)
@@ -14,6 +14,4 @@
 
    !!----------------------------------------------------------------------
-   !!   'key_asminc'   : Switch on the assimilation increment interface
-   !!----------------------------------------------------------------------
    !!   asm_inc_init   : Initialize the increment arrays and IAU weights
    !!   calc_date      : Compute the calendar date YYYYMMDD on a given step
@@ -28,5 +26,5 @@
    USE domvvl           ! domain: variable volume level
    USE oce              ! Dynamics and active tracers defined in memory
-   USE ldfdyn_oce       ! ocean dynamics: lateral physics
+   USE ldfdyn           ! lateral diffusion: eddy viscosity coefficients
    USE eosbn2           ! Equation of state - in situ and potential density
    USE zpshde           ! Partial step : Horizontal Derivative
@@ -56,14 +54,14 @@
     LOGICAL, PUBLIC, PARAMETER :: lk_asminc = .FALSE.  !: No assimilation increments
 #endif
-   LOGICAL, PUBLIC :: ln_bkgwri = .FALSE.      !: No output of the background state fields
-   LOGICAL, PUBLIC :: ln_asmiau = .FALSE.      !: No applying forcing with an assimilation increment
-   LOGICAL, PUBLIC :: ln_asmdin = .FALSE.      !: No direct initialization
-   LOGICAL, PUBLIC :: ln_trainc = .FALSE.      !: No tracer (T and S) assimilation increments
-   LOGICAL, PUBLIC :: ln_dyninc = .FALSE.      !: No dynamics (u and v) assimilation increments
-   LOGICAL, PUBLIC :: ln_sshinc = .FALSE.      !: No sea surface height assimilation increment
-   LOGICAL, PUBLIC :: ln_seaiceinc             !: No sea ice concentration increment
-   LOGICAL, PUBLIC :: ln_salfix = .FALSE.      !: Apply minimum salinity check
+   LOGICAL, PUBLIC :: ln_bkgwri     !: No output of the background state fields
+   LOGICAL, PUBLIC :: ln_asmiau     !: No applying forcing with an assimilation increment
+   LOGICAL, PUBLIC :: ln_asmdin     !: No direct initialization
+   LOGICAL, PUBLIC :: ln_trainc     !: No tracer (T and S) assimilation increments
+   LOGICAL, PUBLIC :: ln_dyninc     !: No dynamics (u and v) assimilation increments
+   LOGICAL, PUBLIC :: ln_sshinc     !: No sea surface height assimilation increment
+   LOGICAL, PUBLIC :: ln_seaiceinc  !: No sea ice concentration increment
+   LOGICAL, PUBLIC :: ln_salfix     !: Apply minimum salinity check
    LOGICAL, PUBLIC :: ln_temnofreeze = .FALSE. !: Don't allow the temperature to drop below freezing
-   INTEGER, PUBLIC :: nn_divdmp                !: Apply divergence damping filter nn_divdmp times
+   INTEGER, PUBLIC :: nn_divdmp     !: Apply divergence damping filter nn_divdmp times
 
    REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE ::   t_bkg   , s_bkg      !: Background temperature and salinity
@@ -90,5 +88,4 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldfdyn_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
@@ -139,5 +136,5 @@
       ! Read Namelist nam_asminc : assimilation increment interface
       !-----------------------------------------------------------------------
-      ln_seaiceinc = .FALSE.
+      ln_seaiceinc   = .FALSE.
       ln_temnofreeze = .FALSE.
 
@@ -428,13 +425,11 @@
 
       IF ( ln_dyninc .AND. nn_divdmp > 0 ) THEN
-
-         CALL wrk_alloc(jpi,jpj,hdiv) 
-
-         DO  jt = 1, nn_divdmp
-
+         !
+         CALL wrk_alloc( jpi,jpj,   hdiv ) 
+         !
+         DO jt = 1, nn_divdmp
+            !
             DO jk = 1, jpkm1
-
                hdiv(:,:) = 0._wp
-
                DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -444,30 +439,26 @@
                          + e1v(ji  ,jj  ) * fse3v(ji  ,jj  ,jk) * v_bkginc(ji  ,jj  ,jk)     &
                          - e1v(ji  ,jj-1) * fse3v(ji  ,jj-1,jk) * v_bkginc(ji  ,jj-1,jk)  )  &
-                         / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                         / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
                   END DO
                END DO
-
                CALL lbc_lnk( hdiv, 'T', 1. )   ! lateral boundary cond. (no sign change)
-
+               !
                DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1   ! vector opt.
-                     u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk) + 0.2_wp * ( e1t(ji+1,jj)*e2t(ji+1,jj) * hdiv(ji+1,jj)   &
-                                                                        - e1t(ji  ,jj)*e2t(ji  ,jj) * hdiv(ji  ,jj) ) &
-                                                                      / e1u(ji,jj) * umask(ji,jj,jk) 
-                     v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk) + 0.2_wp * ( e1t(ji,jj+1)*e2t(ji,jj+1) * hdiv(ji,jj+1)   &
-                                                                        - e1t(ji,jj  )*e2t(ji,jj  ) * hdiv(ji,jj  ) ) &
-                                                                      / e2v(ji,jj) * vmask(ji,jj,jk) 
+                     u_bkginc(ji,jj,jk) = u_bkginc(ji,jj,jk) + 0.2_wp * ( e1e2t(ji+1,jj) * hdiv(ji+1,jj)   &
+                        &                                               - e1e2t(ji  ,jj) * hdiv(ji  ,jj) ) &
+                        &                                             * r1_e1u(ji,jj) * umask(ji,jj,jk) 
+                     v_bkginc(ji,jj,jk) = v_bkginc(ji,jj,jk) + 0.2_wp * ( e1e2t(ji,jj+1) * hdiv(ji,jj+1)   &
+                        &                                               - e1e2t(ji,jj  ) * hdiv(ji,jj  ) ) &
+                        &                                             * r1_e2v(ji,jj) * vmask(ji,jj,jk) 
                   END DO
                END DO
-
             END DO
-
+            !
          END DO
-
-         CALL wrk_dealloc(jpi,jpj,hdiv) 
-
+         !
+         CALL wrk_dealloc( jpi,jpj,   hdiv ) 
+         !
       ENDIF
-
-
 
       !-----------------------------------------------------------------------
@@ -476,5 +467,5 @@
 
       IF ( ln_asmdin ) THEN
-
+         !
          ALLOCATE( t_bkg(jpi,jpj,jpk) )
          ALLOCATE( s_bkg(jpi,jpj,jpk) )
@@ -482,30 +473,29 @@
          ALLOCATE( v_bkg(jpi,jpj,jpk) )
          ALLOCATE( ssh_bkg(jpi,jpj)   )
-
-         t_bkg(:,:,:) = 0.0
-         s_bkg(:,:,:) = 0.0
-         u_bkg(:,:,:) = 0.0
-         v_bkg(:,:,:) = 0.0
-         ssh_bkg(:,:) = 0.0
-
+         !
+         t_bkg(:,:,:) = 0._wp
+         s_bkg(:,:,:) = 0._wp
+         u_bkg(:,:,:) = 0._wp
+         v_bkg(:,:,:) = 0._wp
+         ssh_bkg(:,:) = 0._wp
+         !
          !--------------------------------------------------------------------
          ! Read from file the background state at analysis time
          !--------------------------------------------------------------------
-
+         !
          CALL iom_open( c_asmdin, inum )
-
+         !
          CALL iom_get( inum, 'rdastp', zdate_bkg ) 
-        
+         !
          IF(lwp) THEN
             WRITE(numout,*) 
-            WRITE(numout,*) 'asm_inc_init : Assimilation background state valid at : ', &
-               &  NINT( zdate_bkg )
+            WRITE(numout,*) 'asm_inc_init : Assimilation background state valid at : ', NINT( zdate_bkg )
             WRITE(numout,*) '~~~~~~~~~~~~'
          ENDIF
-
+         !
          IF ( NINT( zdate_bkg ) /= iitdin_date ) &
             & CALL ctl_warn( ' Validity time of assimilation background state does', &
             &                ' not agree with Direct Initialization time' )
-
+         !
          IF ( ln_trainc ) THEN   
             CALL iom_get( inum, jpdom_autoglo, 'tn', t_bkg )
@@ -514,5 +504,5 @@
             s_bkg(:,:,:) = s_bkg(:,:,:) * tmask(:,:,:)
          ENDIF
-
+         !
          IF ( ln_dyninc ) THEN   
             CALL iom_get( inum, jpdom_autoglo, 'un', u_bkg )
@@ -521,12 +511,12 @@
             v_bkg(:,:,:) = v_bkg(:,:,:) * vmask(:,:,:)
          ENDIF
-        
+         !
          IF ( ln_sshinc ) THEN
             CALL iom_get( inum, jpdom_autoglo, 'sshn', ssh_bkg )
             ssh_bkg(:,:) = ssh_bkg(:,:) * tmask(:,:,1)
          ENDIF
-
+         !
          CALL iom_close( inum )
-
+         !
       ENDIF
       !
@@ -574,8 +564,6 @@
       ! If kt = kit000 - 1 then set the date to the restart date
       IF ( kt == kit000 - 1 ) THEN
-
          kdate = ndastp
          RETURN
-
       ENDIF
 
@@ -646,30 +634,27 @@
       !! ** Action  : 
       !!----------------------------------------------------------------------
-      INTEGER, INTENT(IN) :: kt               ! Current time step
-      !
-      INTEGER :: ji,jj,jk
-      INTEGER :: it
+      INTEGER, INTENT(IN) ::   kt   ! Current time step
+      !
+      INTEGER  :: ji, jj, jk
+      INTEGER  :: it
       REAL(wp) :: zincwgt  ! IAU weight for current time step
       REAL (wp), DIMENSION(jpi,jpj,jpk) :: fzptnz ! 3d freezing point values
       !!----------------------------------------------------------------------
-
+      !
       ! freezing point calculation taken from oc_fz_pt (but calculated for all depths) 
       ! used to prevent the applied increments taking the temperature below the local freezing point 
-
       DO jk = 1, jpkm1
         CALL eos_fzp( tsn(:,:,jk,jp_sal), fzptnz(:,:,jk), fsdept(:,:,jk) )
       END DO
-
-      IF ( ln_asmiau ) THEN
-
-         !--------------------------------------------------------------------
-         ! Incremental Analysis Updating
-         !--------------------------------------------------------------------
-
+         !
+         !                             !--------------------------------------
+      IF ( ln_asmiau ) THEN            ! Incremental Analysis Updating
+         !                             !--------------------------------------
+         !
          IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN
-
+            !
             it = kt - nit000 + 1
             zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step
-
+            !
             IF(lwp) THEN
                WRITE(numout,*) 
@@ -677,5 +662,5 @@
                WRITE(numout,*) '~~~~~~~~~~~~'
             ENDIF
-
+            !
             ! Update the tracer tendencies
             DO jk = 1, jpkm1
@@ -700,23 +685,19 @@
                ENDIF
             END DO
-
-         ENDIF
-
+            !
+         ENDIF
+         !
          IF ( kt == nitiaufin_r + 1  ) THEN   ! For bias crcn to work
             DEALLOCATE( t_bkginc )
             DEALLOCATE( s_bkginc )
          ENDIF
-
-
-      ELSEIF ( ln_asmdin ) THEN
-
-         !--------------------------------------------------------------------
-         ! Direct Initialization
-         !--------------------------------------------------------------------
-            
+         !                             !--------------------------------------
+      ELSEIF ( ln_asmdin ) THEN        ! Direct Initialization
+         !                             !--------------------------------------
+         !            
          IF ( kt == nitdin_r ) THEN
-
+            !
             neuler = 0  ! Force Euler forward step
-
+            !
             ! Initialize the now fields with the background + increment
             IF (ln_temnofreeze) THEN
@@ -745,18 +726,15 @@
 !!gm
 
-
-            IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav)      &
-               &  CALL zps_hde    ( kt, jpts, tsb, gtsu, gtsv,        &  ! Partial steps: before horizontal gradient
-               &                              rhd, gru , grv          )  ! of t, s, rd at the last ocean level
-            IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav)      &
-               &  CALL zps_hde_isf( nit000, jpts, tsb, gtsu, gtsv,    &    ! Partial steps for top cell (ISF)
-               &                                  rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-               &                           gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level
-
-#if defined key_zdfkpp
-            CALL eos( tsn, rhd, fsdept_n(:,:,:) )                      ! Compute rhd
-!!gm fabien            CALL eos( tsn, rhd )                      ! Compute rhd
-#endif
-
+            IF( ln_zps .AND. .NOT. lk_c1d ) THEN      ! Partial steps: before horizontal gradient
+               IF(ln_isfcav) THEN                        ! ocean cavities: top and bottom cells (ISF)
+                  CALL zps_hde_isf( nit000, jpts, tsb, gtsu, gtsv, gtui, gtvi,     &
+                     &                            rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
+                     &                     grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    )
+               ELSE                                      ! no ocean cavities: bottom cells
+                  CALL zps_hde    ( kt, jpts, tsb, gtsu, gtsv,        &  ! 
+                     &                        rhd, gru , grv          )  ! of t, s, rd at the last ocean level
+               ENDIF
+            ENDIF
+            !
             DEALLOCATE( t_bkginc )
             DEALLOCATE( s_bkginc )
@@ -767,5 +745,5 @@
       ENDIF
       ! Perhaps the following call should be in step
-      IF   ( ln_seaiceinc  )   CALL seaice_asm_inc ( kt )   ! apply sea ice concentration increment
+      IF ( ln_seaiceinc  )   CALL seaice_asm_inc ( kt )   ! apply sea ice concentration increment
       !
    END SUBROUTINE tra_asm_inc
@@ -788,23 +766,20 @@
       REAL(wp) :: zincwgt  ! IAU weight for current time step
       !!----------------------------------------------------------------------
-
-      IF ( ln_asmiau ) THEN
-
-         !--------------------------------------------------------------------
-         ! Incremental Analysis Updating
-         !--------------------------------------------------------------------
-
+      !
+      !                          !--------------------------------------------
+      IF ( ln_asmiau ) THEN      ! Incremental Analysis Updating
+         !                       !--------------------------------------------
+         !
          IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN
-
+            !
             it = kt - nit000 + 1
             zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step
-
+            !
             IF(lwp) THEN
                WRITE(numout,*) 
-               WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', &
-                  &  kt,' with IAU weight = ', wgtiau(it)
+               WRITE(numout,*) 'dyn_asm_inc : Dynamics IAU at time step = ', kt,' with IAU weight = ', wgtiau(it)
                WRITE(numout,*) '~~~~~~~~~~~~'
             ENDIF
-
+            !
             ! Update the dynamic tendencies
             DO jk = 1, jpkm1
@@ -812,29 +787,26 @@
                va(:,:,jk) = va(:,:,jk) + v_bkginc(:,:,jk) * zincwgt
             END DO
-           
+            !
             IF ( kt == nitiaufin_r ) THEN
                DEALLOCATE( u_bkginc )
                DEALLOCATE( v_bkginc )
             ENDIF
-
-         ENDIF
-
-      ELSEIF ( ln_asmdin ) THEN 
-
-         !--------------------------------------------------------------------
-         ! Direct Initialization
-         !--------------------------------------------------------------------
-         
+            !
+         ENDIF
+         !                          !-----------------------------------------
+      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization
+         !                          !-----------------------------------------
+         !         
          IF ( kt == nitdin_r ) THEN
-
+            !
             neuler = 0                    ! Force Euler forward step
-
+            !
             ! Initialize the now fields with the background + increment
             un(:,:,:) = u_bkg(:,:,:) + u_bkginc(:,:,:)
             vn(:,:,:) = v_bkg(:,:,:) + v_bkginc(:,:,:)  
-
+            !
             ub(:,:,:) = un(:,:,:)         ! Update before fields
             vb(:,:,:) = vn(:,:,:)
- 
+            !
             DEALLOCATE( u_bkg    )
             DEALLOCATE( v_bkg    )
@@ -864,16 +836,14 @@
       REAL(wp) :: zincwgt  ! IAU weight for current time step
       !!----------------------------------------------------------------------
-
-      IF ( ln_asmiau ) THEN
-
-         !--------------------------------------------------------------------
-         ! Incremental Analysis Updating
-         !--------------------------------------------------------------------
-
+      !
+      !                             !-----------------------------------------
+      IF ( ln_asmiau ) THEN         ! Incremental Analysis Updating
+         !                          !-----------------------------------------
+         !
          IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN
-
+            !
             it = kt - nit000 + 1
             zincwgt = wgtiau(it) / rdt   ! IAU weight for the current time step
-
+            !
             IF(lwp) THEN
                WRITE(numout,*) 
@@ -882,5 +852,5 @@
                WRITE(numout,*) '~~~~~~~~~~~~'
             ENDIF
-
+            !
             ! Save the tendency associated with the IAU weighted SSH increment
             ! (applied in dynspg.*)
@@ -891,23 +861,18 @@
                DEALLOCATE( ssh_bkginc )
             ENDIF
-
-         ENDIF
-
-      ELSEIF ( ln_asmdin ) THEN
-
-         !--------------------------------------------------------------------
-         ! Direct Initialization
-         !--------------------------------------------------------------------
-
+            !
+         ENDIF
+         !                          !-----------------------------------------
+      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization
+         !                          !-----------------------------------------
+         !
          IF ( kt == nitdin_r ) THEN
-
-            neuler = 0                    ! Force Euler forward step
-
-            ! Initialize the now fields the background + increment
-            sshn(:,:) = ssh_bkg(:,:) + ssh_bkginc(:,:)  
-
-            ! Update before fields
-            sshb(:,:) = sshn(:,:)         
-
+            !
+            neuler = 0                                   ! Force Euler forward step
+            !
+            sshn(:,:) = ssh_bkg(:,:) + ssh_bkginc(:,:)   ! Initialize the now fields the background + increment
+            !
+            sshb(:,:) = sshn(:,:)                        ! Update before fields
+            !
             IF( lk_vvl ) THEN
                DO jk = 1, jpk
@@ -915,8 +880,8 @@
                END DO
             ENDIF
-
+            !
             DEALLOCATE( ssh_bkg    )
             DEALLOCATE( ssh_bkginc )
-
+            !
          ENDIF
          !
@@ -937,7 +902,5 @@
       !!
       !!----------------------------------------------------------------------
-      IMPLICIT NONE
-      !
-      INTEGER, INTENT(in)           ::   kt   ! Current time step
+      INTEGER, INTENT(in)           ::   kt       ! Current time step
       INTEGER, INTENT(in), OPTIONAL ::   kindic   ! flag for disabling the deallocation
       !
@@ -949,26 +912,23 @@
 #endif
       !!----------------------------------------------------------------------
-
-      IF ( ln_asmiau ) THEN
-
-         !--------------------------------------------------------------------
-         ! Incremental Analysis Updating
-         !--------------------------------------------------------------------
-
+      !
+      !                             !-----------------------------------------
+      IF ( ln_asmiau ) THEN         ! Incremental Analysis Updating
+         !                          !-----------------------------------------
+         !
          IF ( ( kt >= nitiaustr_r ).AND.( kt <= nitiaufin_r ) ) THEN
-
+            !
             it = kt - nit000 + 1
             zincwgt = wgtiau(it)      ! IAU weight for the current time step 
             ! note this is not a tendency so should not be divided by rdt (as with the tracer and other increments)
-
+            !
             IF(lwp) THEN
                WRITE(numout,*) 
-               WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', &
-                  &  kt,' with IAU weight = ', wgtiau(it)
+               WRITE(numout,*) 'seaice_asm_inc : sea ice conc IAU at time step = ', kt,' with IAU weight = ', wgtiau(it)
                WRITE(numout,*) '~~~~~~~~~~~~'
             ENDIF
-
+            !
             ! Sea-ice : LIM-3 case (to add)
-
+            !
 #if defined key_lim2
             ! Sea-ice : LIM-2 case
@@ -1008,22 +968,18 @@
 
 #if defined key_cice && defined key_asminc
-            ! Sea-ice : CICE case. Zero ice increment tendency into CICE
-            ndaice_da(:,:) = 0.0_wp
-#endif
-
-         ENDIF
-
-      ELSEIF ( ln_asmdin ) THEN
-
-         !--------------------------------------------------------------------
-         ! Direct Initialization
-         !--------------------------------------------------------------------
-
+            ndaice_da(:,:) = 0._wp        ! Sea-ice : CICE case. Zero ice increment tendency into CICE
+#endif
+
+         ENDIF
+         !                          !-----------------------------------------
+      ELSEIF ( ln_asmdin ) THEN     ! Direct Initialization
+         !                          !-----------------------------------------
+         !
          IF ( kt == nitdin_r ) THEN
-
+            !
             neuler = 0                    ! Force Euler forward step
-
+            !
             ! Sea-ice : LIM-3 case (to add)
-
+            !
 #if defined key_lim2
             ! Sea-ice : LIM-2 case.
@@ -1041,5 +997,5 @@
                zhicifinc(:,:) = (zhicifmin - hicif(:,:)) * zincwgt    
             ELSEWHERE
-               zhicifinc(:,:) = 0.0_wp
+               zhicifinc(:,:) = 0._wp
             END WHERE
             !
@@ -1050,20 +1006,20 @@
             ! seaice salinity balancing (to add)
 #endif
- 
+            !
 #if defined key_cice && defined key_asminc
             ! Sea-ice : CICE case. Pass ice increment tendency into CICE
            ndaice_da(:,:) = seaice_bkginc(:,:) / rdt
 #endif
-           IF ( .NOT. PRESENT(kindic) ) THEN
-              DEALLOCATE( seaice_bkginc )
-           END IF
-
+            IF ( .NOT. PRESENT(kindic) ) THEN
+               DEALLOCATE( seaice_bkginc )
+            END IF
+            !
          ELSE
-
+            !
 #if defined key_cice && defined key_asminc
-            ! Sea-ice : CICE case. Zero ice increment tendency into CICE 
-            ndaice_da(:,:) = 0.0_wp
-#endif
-         
+            ndaice_da(:,:) = 0._wp     ! Sea-ice : CICE case. Zero ice increment tendency into CICE
+
+#endif
+            !
          ENDIF
 
@@ -1142,7 +1098,7 @@
 !
 !#endif
-
+         !
       ENDIF
-
+      !
    END SUBROUTINE seaice_asm_inc
    
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asmpar.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asmpar.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ASM/asmpar.F90	(revision 6041)
@@ -6,27 +6,19 @@
 
    IMPLICIT NONE
-
-   !! * Routine accessibility
    PRIVATE
 
-   !! * Shared Modules variables
-   CHARACTER (LEN=40), PUBLIC, PARAMETER :: &
-      & c_asmbkg = 'assim_background_state_Jb',  & !: Filename for storing the 
-                                                   !: background state for use 
-                                                   !: in the Jb term
-      & c_asmdin = 'assim_background_state_DI',  & !: Filename for storing the 
-                                                   !: background state for direct 
-                                                   !: initialization
-      & c_asmtrj = 'assim_trj',                  & !: Filename for storing the 
-                                                   !: reference trajectory
-      & c_asminc = 'assim_background_increments'   !: Filename for storing the 
-                                                   !: increments to the background
-                                                   !: state
+   CHARACTER(LEN=40), PUBLIC, PARAMETER ::   c_asmbkg = 'assim_background_state_Jb'   !: Filename for storing the background state
+   !                                                                                  !  for use in the Jb term
+   CHARACTER(LEN=40), PUBLIC, PARAMETER ::   c_asmdin = 'assim_background_state_DI'   !: Filename for storing the background state
+   !                                                                                  !  for direct initialization
+   CHARACTER(LEN=40), PUBLIC, PARAMETER ::   c_asmtrj = 'assim_trj'                   !: Filename for storing the reference trajectory
+   CHARACTER(LEN=40), PUBLIC, PARAMETER ::   c_asminc = 'assim_background_increments' !: Filename for storing the increments 
+   !                                                                                  !  to the background state
 
-   INTEGER, PUBLIC :: nitbkg_r      !: Background time step referenced to nit000
-   INTEGER, PUBLIC :: nitdin_r      !: Direct Initialization time step referenced to nit000
-   INTEGER, PUBLIC :: nitiaustr_r   !: IAU starting time step referenced to nit000
-   INTEGER, PUBLIC :: nitiaufin_r   !: IAU final time step referenced to nit000
-   INTEGER, PUBLIC :: nittrjfrq     !: Frequency of trajectory output for 4D-VAR
+   INTEGER, PUBLIC ::   nitbkg_r      !: Background time step referenced to nit000
+   INTEGER, PUBLIC ::   nitdin_r      !: Direct Initialization time step referenced to nit000
+   INTEGER, PUBLIC ::   nitiaustr_r   !: IAU starting time step referenced to nit000
+   INTEGER, PUBLIC ::   nitiaufin_r   !: IAU final time step referenced to nit000
+   INTEGER, PUBLIC ::   nittrjfrq     !: Frequency of trajectory output for 4D-VAR
 
    !!----------------------------------------------------------------------
@@ -34,5 +26,4 @@
    !! $Id$
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
+   !!======================================================================
 END MODULE asmpar
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdy_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdy_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdy_oce.F90	(revision 6041)
@@ -8,5 +8,5 @@
    !!            3.3  !  2010-09  (D. Storkey) add ice boundary conditions
    !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
-   !!            3.6  !  2012-01  (C. Rousset) add ice boundary conditions for lim3
+   !!            3.6  !  2014-01  (C. Rousset) add ice boundary conditions for lim3
    !!----------------------------------------------------------------------
 #if defined key_bdy 
@@ -22,15 +22,15 @@
 
    TYPE, PUBLIC ::   OBC_INDEX    !: Indices and weights which define the open boundary
-      INTEGER,          DIMENSION(jpbgrd) ::  nblen
-      INTEGER,          DIMENSION(jpbgrd) ::  nblenrim
-      INTEGER, POINTER, DIMENSION(:,:)   ::  nbi
-      INTEGER, POINTER, DIMENSION(:,:)   ::  nbj
-      INTEGER, POINTER, DIMENSION(:,:)   ::  nbr
-      INTEGER, POINTER, DIMENSION(:,:)   ::  nbmap
-      REAL(wp)   , POINTER, DIMENSION(:,:)   ::  nbw
-      REAL(wp)   , POINTER, DIMENSION(:,:)   ::  nbd
-      REAL(wp)   , POINTER, DIMENSION(:,:)   ::  nbdout
-      REAL(wp)   , POINTER, DIMENSION(:,:)   ::  flagu
-      REAL(wp)   , POINTER, DIMENSION(:,:)   ::  flagv
+      INTEGER ,          DIMENSION(jpbgrd) ::  nblen
+      INTEGER ,          DIMENSION(jpbgrd) ::  nblenrim
+      INTEGER , POINTER, DIMENSION(:,:)    ::  nbi
+      INTEGER , POINTER, DIMENSION(:,:)    ::  nbj
+      INTEGER , POINTER, DIMENSION(:,:)    ::  nbr
+      INTEGER , POINTER, DIMENSION(:,:)    ::  nbmap
+      REAL(wp), POINTER, DIMENSION(:,:)    ::  nbw
+      REAL(wp), POINTER, DIMENSION(:,:)    ::  nbd
+      REAL(wp), POINTER, DIMENSION(:,:)    ::  nbdout
+      REAL(wp), POINTER, DIMENSION(:,:)    ::  flagu
+      REAL(wp), POINTER, DIMENSION(:,:)    ::  flagv
    END TYPE OBC_INDEX
 
@@ -41,33 +41,33 @@
 
    TYPE, PUBLIC ::   OBC_DATA     !: Storage for external data
-      INTEGER,       DIMENSION(2)     ::  nread
-      LOGICAL                         ::  ll_ssh
-      LOGICAL                         ::  ll_u2d
-      LOGICAL                         ::  ll_v2d
-      LOGICAL                         ::  ll_u3d
-      LOGICAL                         ::  ll_v3d
-      LOGICAL                         ::  ll_tem
-      LOGICAL                         ::  ll_sal
-      REAL(wp), POINTER, DIMENSION(:)     ::  ssh
-      REAL(wp), POINTER, DIMENSION(:)     ::  u2d
-      REAL(wp), POINTER, DIMENSION(:)     ::  v2d
-      REAL(wp), POINTER, DIMENSION(:,:)   ::  u3d
-      REAL(wp), POINTER, DIMENSION(:,:)   ::  v3d
-      REAL(wp), POINTER, DIMENSION(:,:)   ::  tem
-      REAL(wp), POINTER, DIMENSION(:,:)   ::  sal
+      INTEGER          , DIMENSION(2)   ::  nread
+      LOGICAL                           ::  ll_ssh
+      LOGICAL                           ::  ll_u2d
+      LOGICAL                           ::  ll_v2d
+      LOGICAL                           ::  ll_u3d
+      LOGICAL                           ::  ll_v3d
+      LOGICAL                           ::  ll_tem
+      LOGICAL                           ::  ll_sal
+      REAL(wp), POINTER, DIMENSION(:)   ::  ssh
+      REAL(wp), POINTER, DIMENSION(:)   ::  u2d
+      REAL(wp), POINTER, DIMENSION(:)   ::  v2d
+      REAL(wp), POINTER, DIMENSION(:,:) ::  u3d
+      REAL(wp), POINTER, DIMENSION(:,:) ::  v3d
+      REAL(wp), POINTER, DIMENSION(:,:) ::  tem
+      REAL(wp), POINTER, DIMENSION(:,:) ::  sal
 #if defined key_lim2
-      LOGICAL                         ::  ll_frld
-      LOGICAL                         ::  ll_hicif
-      LOGICAL                         ::  ll_hsnif
-      REAL(wp), POINTER, DIMENSION(:)     ::  frld
-      REAL(wp), POINTER, DIMENSION(:)     ::  hicif
-      REAL(wp), POINTER, DIMENSION(:)     ::  hsnif
+      LOGICAL                           ::   ll_frld
+      LOGICAL                           ::   ll_hicif
+      LOGICAL                           ::   ll_hsnif
+      REAL(wp), POINTER, DIMENSION(:)   ::   frld
+      REAL(wp), POINTER, DIMENSION(:)   ::   hicif
+      REAL(wp), POINTER, DIMENSION(:)   ::   hsnif
 #elif defined key_lim3
-      LOGICAL                         ::  ll_a_i
-      LOGICAL                         ::  ll_ht_i
-      LOGICAL                         ::  ll_ht_s
-      REAL, POINTER, DIMENSION(:,:)   ::  a_i   !: now ice leads fraction climatology
-      REAL, POINTER, DIMENSION(:,:)   ::  ht_i  !: Now ice  thickness climatology
-      REAL, POINTER, DIMENSION(:,:)   ::  ht_s  !: now snow thickness
+      LOGICAL                           ::   ll_a_i
+      LOGICAL                           ::   ll_ht_i
+      LOGICAL                           ::   ll_ht_s
+      REAL(wp), POINTER, DIMENSION(:,:) ::   a_i    !: now ice leads fraction climatology
+      REAL(wp), POINTER, DIMENSION(:,:) ::   ht_i   !: Now ice  thickness climatology
+      REAL(wp), POINTER, DIMENSION(:,:) ::   ht_s   !: now snow thickness
 #endif
    END TYPE OBC_DATA
@@ -99,15 +99,15 @@
    INTEGER, DIMENSION(jp_bdy)           ::   nn_tra_dta     !: = 0 use the initial state as bdy dta ; 
                                                             !: = 1 read it in a NetCDF file
-   LOGICAL, DIMENSION(jp_bdy) ::   ln_tra_dmp               !: =T Tracer damping
-   LOGICAL, DIMENSION(jp_bdy) ::   ln_dyn3d_dmp             !: =T Baroclinic velocity damping
-   REAL(wp),    DIMENSION(jp_bdy) ::   rn_time_dmp              !: Damping time scale in days
-   REAL(wp),    DIMENSION(jp_bdy) ::   rn_time_dmp_out          !: Damping time scale in days at radiation outflow points
+   LOGICAL , DIMENSION(jp_bdy) ::   ln_tra_dmp              !: =T Tracer damping
+   LOGICAL , DIMENSION(jp_bdy) ::   ln_dyn3d_dmp            !: =T Baroclinic velocity damping
+   REAL(wp), DIMENSION(jp_bdy) ::   rn_time_dmp             !: Damping time scale in days
+   REAL(wp), DIMENSION(jp_bdy) ::   rn_time_dmp_out         !: Damping time scale in days at radiation outflow points
 
    CHARACTER(len=20), DIMENSION(jp_bdy) ::   cn_ice_lim       ! Choice of boundary condition for sea ice variables 
-   INTEGER, DIMENSION(jp_bdy)           ::   nn_ice_lim_dta   !: = 0 use the initial state as bdy dta ; 
+   INTEGER , DIMENSION(jp_bdy)          ::   nn_ice_lim_dta   !: = 0 use the initial state as bdy dta ; 
                                                               !: = 1 read it in a NetCDF file
-   REAL(wp),    DIMENSION(jp_bdy) ::   rn_ice_tem             !: choice of the temperature of incoming sea ice
-   REAL(wp),    DIMENSION(jp_bdy) ::   rn_ice_sal             !: choice of the salinity    of incoming sea ice
-   REAL(wp),    DIMENSION(jp_bdy) ::   rn_ice_age             !: choice of the age         of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rn_ice_tem              !: choice of the temperature of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rn_ice_sal              !: choice of the salinity    of incoming sea ice
+   REAL(wp), DIMENSION(jp_bdy) ::   rn_ice_age              !: choice of the age         of incoming sea ice
    !
    
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydta.F90	(revision 6041)
@@ -29,5 +29,4 @@
    USE iom             ! IOM library
    USE in_out_manager  ! I/O logical units
-   USE dynspg_oce, ONLY: lk_dynspg_ts ! Split-explicit free surface flag
 #if defined key_lim2
    USE ice_2
@@ -388,10 +387,21 @@
       END DO  ! ib_bdy
 
-      ! bg jchanut tschanges
 #if defined key_tide
-      ! Add tides if not split-explicit free surface else this is done in ts loop
-      IF (.NOT.lk_dynspg_ts) CALL bdy_dta_tides( kt=kt, time_offset=time_offset )
-#endif
-      ! end jchanut tschanges
+      IF (ln_dynspg_ts) THEN      ! Fill temporary arrays with slow-varying bdy data                           
+         DO ib_bdy = 1, nb_bdy    ! Tidal component added in ts loop
+            IF ( nn_dyn2d_dta(ib_bdy) .ge. 2 ) THEN
+               nblen => idx_bdy(ib_bdy)%nblen
+               nblenrim => idx_bdy(ib_bdy)%nblenrim
+               IF( cn_dyn2d(ib_bdy) == 'frs' ) THEN; ilen1(:)=nblen(:) ; ELSE ; ilen1(:)=nblenrim(:) ; ENDIF 
+               IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy_s(ib_bdy)%ssh(1:ilen1(1)) = dta_bdy(ib_bdy)%ssh(1:ilen1(1))
+               IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy_s(ib_bdy)%u2d(1:ilen1(2)) = dta_bdy(ib_bdy)%u2d(1:ilen1(2))
+               IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy_s(ib_bdy)%v2d(1:ilen1(3)) = dta_bdy(ib_bdy)%v2d(1:ilen1(3))
+            ENDIF
+         END DO
+      ELSE ! Add tides if not split-explicit free surface else this is done in ts loop
+         !
+         CALL bdy_dta_tides( kt=kt, time_offset=time_offset )
+      ENDIF
+#endif
 
       IF ( ln_apr_obc ) THEN
@@ -423,5 +433,4 @@
       !!                
       !!----------------------------------------------------------------------
-      USE dynspg_oce, ONLY: lk_dynspg_ts
       !!
       INTEGER     ::  ib_bdy, jfld, jstart, jend, ierror  ! local indices
@@ -430,4 +439,5 @@
       CHARACTER(len=100)                     ::   cn_dir        ! Root directory for location of data files
       CHARACTER(len=100), DIMENSION(nb_bdy)  ::   cn_dir_array  ! Root directory for location of data files
+      CHARACTER(len = 256)::   clname                           ! temporary file name
       LOGICAL                                ::   ln_full_vel   ! =T => full velocities in 3D boundary data
                                                                 ! =F => baroclinic velocities in 3D boundary data
@@ -669,12 +679,20 @@
             ! sea ice
             IF( nn_ice_lim_dta(ib_bdy) .eq. 1 ) THEN
-
                ! Test for types of ice input (lim2 or lim3) 
-               CALL iom_open ( bn_a_i%clname, inum )
-               id1 = iom_varid ( inum, bn_a_i%clvar, kdimsz=zdimsz, kndims=zndims, ldstop = .FALSE. )
+               ! Build file name to find dimensions 
+               clname=TRIM(bn_a_i%clname)
+               IF( .NOT. bn_a_i%ln_clim ) THEN   
+                                                  WRITE(clname, '(a,"_y",i4.4)' ) TRIM( bn_a_i%clname ), nyear    ! add year
+                  IF( bn_a_i%cltype /= 'yearly' ) WRITE(clname, '(a,"m" ,i2.2)' ) TRIM( clname        ), nmonth   ! add month
+               ELSE
+                  IF( bn_a_i%cltype /= 'yearly' ) WRITE(clname, '(a,"_m",i2.2)' ) TRIM( bn_a_i%clname ), nmonth   ! add month
+               ENDIF
+               IF( bn_a_i%cltype == 'daily' .OR. bn_a_i%cltype(1:4) == 'week' ) &
+               &                                  WRITE(clname, '(a,"d" ,i2.2)' ) TRIM( clname        ), nday     ! add day
+               !
+               CALL iom_open  ( clname, inum )
+               id1 = iom_varid( inum, bn_a_i%clvar, kdimsz=zdimsz, kndims=zndims, ldstop = .FALSE. )
                CALL iom_close ( inum )
-               !CALL fld_clopn ( bn_a_i, nyear, nmonth, nday, ldstop=.TRUE. )
-               !CALL iom_open ( bn_a_i%clname, inum )
-               !id1 = iom_varid ( bn_a_i%num, bn_a_i%clvar, kdimsz=zdimsz, kndims=zndims, ldstop = .FALSE. )
+
       	       IF ( zndims == 4 ) THEN
                  ll_bdylim3 = .TRUE.   ! lim3 input
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn.F90	(revision 6041)
@@ -24,5 +24,4 @@
    USE oce             ! ocean dynamics and tracers 
    USE dom_oce         ! ocean space and time domain
-   USE dynspg_oce      
    USE bdy_oce         ! ocean open boundary conditions
    USE bdydyn2d        ! open boundary conditions for barotropic solution
@@ -35,6 +34,5 @@
    PRIVATE
 
-   PUBLIC   bdy_dyn     ! routine called in dynspg_flt (if lk_dynspg_flt) or 
-                        ! dyn_nxt (if lk_dynspg_ts or lk_dynspg_exp)
+   PUBLIC   bdy_dyn    ! routine called in dyn_nxt
 
 #  include "domzgr_substitute.h90"
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn2d.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn2d.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdydyn2d.F90	(revision 6041)
@@ -23,5 +23,4 @@
    USE bdy_oce         ! ocean open boundary conditions
    USE bdylib          ! BDY library routines
-   USE dynspg_oce      ! for barotropic variables
    USE phycst          ! physical constants
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyice_lim.F90	(revision 6041)
@@ -59,13 +59,15 @@
       !!
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) :: kt     ! Main time step counter
-      INTEGER               :: ib_bdy ! Loop index
-
+      INTEGER, INTENT( in ) ::   kt   ! Main time step counter
+      !
+      INTEGER ::   ib_bdy   ! Loop index
+      !!----------------------------------------------------------------------
+      !
 #if defined key_lim3
       CALL lim_var_glo2eqv
 #endif
-
+      !
       DO ib_bdy=1, nb_bdy
-
+         !
          SELECT CASE( cn_ice_lim(ib_bdy) )
          CASE('none')
@@ -76,13 +78,14 @@
             CALL ctl_stop( 'bdy_ice_lim : unrecognised option for open boundaries for ice fields' )
          END SELECT
-
+         !
       END DO
-
+      !
 #if defined key_lim3
       CALL lim_var_zapsmall
       CALL lim_var_agg(1)
 #endif
-
+      !
    END SUBROUTINE bdy_ice_lim
+
 
    SUBROUTINE bdy_ice_frs( idx, dta, kt, ib_bdy )
@@ -96,11 +99,11 @@
       !!             dimensional baroclinic ocean model with realistic topography. Tellus, 365-382.
       !!------------------------------------------------------------------------------
-      TYPE(OBC_INDEX), INTENT(in) ::   idx  ! OBC indices
-      TYPE(OBC_DATA),  INTENT(in) ::   dta  ! OBC external data
-      INTEGER,         INTENT(in) ::   kt   ! main time-step counter
+      TYPE(OBC_INDEX), INTENT(in) ::   idx     ! OBC indices
+      TYPE(OBC_DATA),  INTENT(in) ::   dta     ! OBC external data
+      INTEGER,         INTENT(in) ::   kt      ! main time-step counter
       INTEGER,         INTENT(in) ::   ib_bdy  ! BDY set index
-
+      !
       INTEGER  ::   jpbound            ! 0 = incoming ice
-                                       ! 1 = outgoing ice
+      !                                ! 1 = outgoing ice
       INTEGER  ::   jb, jk, jgrd, jl   ! dummy loop indices
       INTEGER  ::   ji, jj, ii, ij     ! local scalar
@@ -111,8 +114,7 @@
      USE ice_2, vt_i => hicm
 #endif
-
-      !!------------------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 ) CALL timing_start('bdy_ice_frs')
+      !!------------------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('bdy_ice_frs')
       !
       jgrd = 1      ! Everything is at T-points here
@@ -181,30 +183,29 @@
             ! condition on ice thickness depends on the ice velocity
             ! if velocity is outward (strictly), then ice thickness, volume... must be equal to adjacent values
-            jpbound = 0; ii = ji; ij = jj;
-
+            jpbound = 0   ;   ii = ji   ;   ij = jj
+            !
             IF( u_ice(ji+1,jj  ) < 0. .AND. umask(ji-1,jj  ,1) == 0. ) jpbound = 1; ii = ji+1; ij = jj
             IF( u_ice(ji-1,jj  ) > 0. .AND. umask(ji+1,jj  ,1) == 0. ) jpbound = 1; ii = ji-1; ij = jj
             IF( v_ice(ji  ,jj+1) < 0. .AND. vmask(ji  ,jj-1,1) == 0. ) jpbound = 1; ii = ji  ; ij = jj+1
             IF( v_ice(ji  ,jj-1) > 0. .AND. vmask(ji  ,jj+1,1) == 0. ) jpbound = 1; ii = ji  ; ij = jj-1
-
+            !
             IF( nn_ice_lim_dta(ib_bdy) == 0 ) jpbound = 0; ii = ji; ij = jj   ! case ice boundaries = initial conditions
-                                                                              !      do not make state variables dependent on velocity
-               
-
+            !                                                                 !      do not make state variables dependent on velocity
+            !
             rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ii,ij) - 0.01 ) ) ! 0 if no ice
-
+            !
             ! concentration and thickness
             a_i (ji,jj,jl) = a_i (ii,ij,jl) * rswitch
             ht_i(ji,jj,jl) = ht_i(ii,ij,jl) * rswitch
             ht_s(ji,jj,jl) = ht_s(ii,ij,jl) * rswitch
-
+            !
             ! Ice and snow volumes
             v_i(ji,jj,jl) = ht_i(ji,jj,jl) * a_i(ji,jj,jl)
             v_s(ji,jj,jl) = ht_s(ji,jj,jl) * a_i(ji,jj,jl)
-
+            !
             SELECT CASE( jpbound )
-
-            CASE( 0 ) ! velocity is inward
-
+            !
+            CASE( 0 )   ! velocity is inward
+               !
                ! Ice salinity, age, temperature
                sm_i(ji,jj,jl)   = rswitch * rn_ice_sal(ib_bdy)  + ( 1.0 - rswitch ) * rn_simin
@@ -218,7 +219,7 @@
                   s_i(ji,jj,jk,jl) = rswitch * rn_ice_sal(ib_bdy) + ( 1.0 - rswitch ) * rn_simin
                END DO
-               
-            CASE( 1 ) ! velocity is outward
- 
+               !
+            CASE( 1 )   ! velocity is outward
+               !
                ! Ice salinity, age, temperature
                sm_i(ji,jj,jl)   = rswitch * sm_i(ii,ij,jl)  + ( 1.0 - rswitch ) * rn_simin
@@ -232,13 +233,12 @@
                   s_i(ji,jj,jk,jl) = rswitch * s_i(ii,ij,jk,jl) + ( 1.0 - rswitch ) * rn_simin
                END DO
-
+               !
             END SELECT
-
-            ! if salinity is constant, then overwrite rn_ice_sal
-            IF( nn_icesal == 1 ) THEN
-               sm_i(ji,jj,jl)   = rn_icesal
+            !
+            IF( nn_icesal == 1 ) THEN     ! constant salinity : overwrite rn_ice_sal
+               sm_i(ji,jj  ,jl) = rn_icesal
                s_i (ji,jj,:,jl) = rn_icesal
             ENDIF
-
+            !
             ! contents
             smv_i(ji,jj,jl)  = MIN( sm_i(ji,jj,jl) , sss_m(ji,jj) ) * v_i(ji,jj,jl)
@@ -259,7 +259,7 @@
                e_i(ji,jj,jk,jl) = e_i(ji,jj,jk,jl) * a_i(ji,jj,jl) * ht_i(ji,jj,jl) * r1_nlay_i
             END DO
-
+            !
          END DO
- 
+         !
          CALL lbc_bdy_lnk(  a_i(:,:,jl), 'T', 1., ib_bdy )
          CALL lbc_bdy_lnk( ht_i(:,:,jl), 'T', 1., ib_bdy )
@@ -267,5 +267,5 @@
          CALL lbc_bdy_lnk(  v_i(:,:,jl), 'T', 1., ib_bdy )
          CALL lbc_bdy_lnk(  v_s(:,:,jl), 'T', 1., ib_bdy )
- 
+         !
          CALL lbc_bdy_lnk( smv_i(:,:,jl), 'T', 1., ib_bdy )
          CALL lbc_bdy_lnk(  sm_i(:,:,jl), 'T', 1., ib_bdy )
@@ -280,10 +280,10 @@
             CALL lbc_bdy_lnk(e_i(:,:,jk,jl), 'T', 1., ib_bdy )
          END DO
-
+         !
       END DO !jl
-    
+      !
 #endif
       !      
-      IF( nn_timing == 1 ) CALL timing_stop('bdy_ice_frs')
+      IF( nn_timing == 1 )   CALL timing_stop('bdy_ice_frs')
       !
    END SUBROUTINE bdy_ice_frs
@@ -300,11 +300,11 @@
       !! 2013-06 : C. Rousset
       !!------------------------------------------------------------------------------
-      !!
       CHARACTER(len=1), INTENT(in)  ::   cd_type   ! nature of velocity grid-points
+      !
       INTEGER  ::   jb, jgrd           ! dummy loop indices
       INTEGER  ::   ji, jj             ! local scalar
       INTEGER  ::   ib_bdy             ! Loop index
       REAL(wp) ::   zmsk1, zmsk2, zflag
-     !!------------------------------------------------------------------------------
+      !!------------------------------------------------------------------------------
       !
       IF( nn_timing == 1 ) CALL timing_start('bdy_ice_lim_dyn')
@@ -313,18 +313,15 @@
          !
          SELECT CASE( cn_ice_lim(ib_bdy) )
-
+         !
          CASE('none')
-
             CYCLE
-            
+            !
          CASE('frs')
-            
+            !
             IF( nn_ice_lim_dta(ib_bdy) == 0 ) CYCLE            ! case ice boundaries = initial conditions 
-                                                               !      do not change ice velocity (it is only computed by rheology)
- 
+            !                                                  !      do not change ice velocity (it is only computed by rheology)
             SELECT CASE ( cd_type )
-               
-            CASE ( 'U' )
-               
+            !     
+            CASE ( 'U' )  
                jgrd = 2      ! u velocity
                DO jb = 1, idx_bdy(ib_bdy)%nblen(jgrd)
@@ -332,10 +329,10 @@
                   jj    = idx_bdy(ib_bdy)%nbj(jb,jgrd)
                   zflag = idx_bdy(ib_bdy)%flagu(jb,jgrd)
-                  
+                  !
                   IF ( ABS( zflag ) == 1. ) THEN  ! eastern and western boundaries
                      ! one of the two zmsk is always 0 (because of zflag)
                      zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji+1,jj) ) ) ! 0 if no ice
                      zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji-1,jj) ) ) ! 0 if no ice
-                     
+                     !  
                      ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then u_ice = u_oce)
                      u_ice (ji,jj) = u_ice(ji+1,jj) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
@@ -349,11 +346,9 @@
                   rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ji,jj) - 0.01_wp ) ) ! 0 if no ice
                   u_ice(ji,jj) = rswitch * u_ice(ji,jj)
-                  
-               ENDDO
-               
+                  !
+               END DO
                CALL lbc_bdy_lnk( u_ice(:,:), 'U', -1., ib_bdy )
-               
+               !
             CASE ( 'V' )
-               
                jgrd = 3      ! v velocity
                DO jb = 1, idx_bdy(ib_bdy)%nblen(jgrd)
@@ -361,10 +356,10 @@
                   jj    = idx_bdy(ib_bdy)%nbj(jb,jgrd)
                   zflag = idx_bdy(ib_bdy)%flagv(jb,jgrd)
-                  
+                  !
                   IF ( ABS( zflag ) == 1. ) THEN  ! northern and southern boundaries
                      ! one of the two zmsk is always 0 (because of zflag)
                      zmsk1 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj+1) ) ) ! 0 if no ice
                      zmsk2 = 1._wp - MAX( 0.0_wp, SIGN ( 1.0_wp , - vt_i(ji,jj-1) ) ) ! 0 if no ice
-                     
+                     !  
                      ! u_ice = u_ice of the adjacent grid point except if this grid point is ice-free (then u_ice = u_oce)
                      v_ice (ji,jj) = v_ice(ji,jj+1) * 0.5_wp * ABS( zflag + 1._wp ) * zmsk1 + &
@@ -378,19 +373,18 @@
                   rswitch = MAX( 0.0_wp , SIGN ( 1.0_wp , at_i(ji,jj) - 0.01 ) ) ! 0 if no ice
                   v_ice(ji,jj) = rswitch * v_ice(ji,jj)
-                  
-               ENDDO
-               
+                  !
+               END DO
                CALL lbc_bdy_lnk( v_ice(:,:), 'V', -1., ib_bdy )
-                  
+               !
             END SELECT
-            
+            !
          CASE DEFAULT
             CALL ctl_stop( 'bdy_ice_lim_dyn : unrecognised option for open boundaries for ice fields' )
          END SELECT
-         
-      ENDDO
-
+         !
+      END DO
+      !
       IF( nn_timing == 1 ) CALL timing_stop('bdy_ice_lim_dyn')
-      
+      !
     END SUBROUTINE bdy_ice_lim_dyn
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyini.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyini.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyini.F90	(revision 6041)
@@ -76,5 +76,5 @@
       INTEGER  ::   ib_bdy, ii, ij, ik, igrd, ib, ir, iseg ! dummy loop indices
       INTEGER  ::   icount, icountr, ibr_max, ilen1, ibm1  ! local integers
-      INTEGER  ::   iwe, ies, iso, ino, inum, id_dummy         !   -       -
+      INTEGER  ::   iwe, ies, iso, ino, inum, id_dummy     !   -       -
       INTEGER  ::   igrd_start, igrd_end, jpbdta           !   -       -
       INTEGER  ::   jpbdtau, jpbdtas                       !   -       -
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdytides.F90	(revision 6041)
@@ -33,5 +33,4 @@
 !   USE tide_mod       ! Useless ??
    USE fldread
-   USE dynspg_oce, ONLY: lk_dynspg_ts
 
    IMPLICIT NONE
@@ -54,5 +53,5 @@
    TYPE(TIDES_DATA), PUBLIC, DIMENSION(jp_bdy), TARGET :: tides  !: External tidal harmonics data
 !$AGRIF_END_DO_NOT_TREAT
-   TYPE(OBC_DATA)  , PRIVATE, DIMENSION(jp_bdy) :: dta_bdy_s  !: bdy external data (slow component)
+   TYPE(OBC_DATA)  , PUBLIC, DIMENSION(jp_bdy) :: dta_bdy_s  !: bdy external data (slow component)
 
    !!----------------------------------------------------------------------
@@ -270,13 +269,12 @@
             ENDIF
             !
-            IF ( lk_dynspg_ts ) THEN ! Allocate arrays to save slowly varying boundary data during
-                                     ! time splitting integration
-               ALLOCATE( dta_bdy_s(ib_bdy)%ssh ( ilen0(1) ) )
-               ALLOCATE( dta_bdy_s(ib_bdy)%u2d ( ilen0(2) ) )
-               ALLOCATE( dta_bdy_s(ib_bdy)%v2d ( ilen0(3) ) )
-               dta_bdy_s(ib_bdy)%ssh(:) = 0.e0
-               dta_bdy_s(ib_bdy)%u2d(:) = 0.e0
-               dta_bdy_s(ib_bdy)%v2d(:) = 0.e0
-            ENDIF
+            ! Allocate slow varying data in the case of time splitting:
+            ! Do it anyway because at this stage knowledge of free surface scheme is unknown
+            ALLOCATE( dta_bdy_s(ib_bdy)%ssh ( ilen0(1) ) )
+            ALLOCATE( dta_bdy_s(ib_bdy)%u2d ( ilen0(2) ) )
+            ALLOCATE( dta_bdy_s(ib_bdy)%v2d ( ilen0(3) ) )
+            dta_bdy_s(ib_bdy)%ssh(:) = 0.e0
+            dta_bdy_s(ib_bdy)%u2d(:) = 0.e0
+            dta_bdy_s(ib_bdy)%v2d(:) = 0.e0
             !
          ENDIF ! nn_dyn2d_dta(ib_bdy) .ge. 2
@@ -397,5 +395,5 @@
       !!
       LOGICAL  :: lk_first_btstp  ! =.TRUE. if time splitting and first barotropic step
-      INTEGER,          DIMENSION(jpbgrd) :: ilen0 
+      INTEGER, DIMENSION(jpbgrd) :: ilen0 
       INTEGER, DIMENSION(1:jpbgrd) :: nblen, nblenrim  ! short cuts
       INTEGER  :: itide, ib_bdy, ib, igrd                     ! loop indices
@@ -416,5 +414,5 @@
       ! Absolute time from model initialization:   
       IF( PRESENT(kit) ) THEN  
-         z_arg = ( kt + (kit+0.5_wp*(time_add-1)) / REAL(nn_baro,wp) ) * rdt
+         z_arg = ( kt + (kit+time_add-1) / REAL(nn_baro,wp) ) * rdt
       ELSE                              
          z_arg = ( kt + time_add ) * rdt
@@ -456,16 +454,9 @@
             zoff = -kt_tide * rdt ! time offset relative to nodal factor computation time
             !
-            ! If time splitting, save data at first barotropic iteration
-            IF ( PRESENT(kit) ) THEN
-               IF ( lk_first_btstp ) THEN ! Save slow varying open boundary data:
-                  IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy_s(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy(ib_bdy)%ssh(1:ilen0(1))
-                  IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy_s(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy(ib_bdy)%u2d(1:ilen0(2))
-                  IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy_s(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy(ib_bdy)%v2d(1:ilen0(3))
-
-               ELSE ! Initialize arrays from slow varying open boundary data:            
-                  IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1))
-                  IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2))
-                  IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3))
-               ENDIF
+            ! If time splitting, initialize arrays from slow varying open boundary data:
+            IF ( PRESENT(kit) ) THEN           
+               IF ( dta_bdy(ib_bdy)%ll_ssh ) dta_bdy(ib_bdy)%ssh(1:ilen0(1)) = dta_bdy_s(ib_bdy)%ssh(1:ilen0(1))
+               IF ( dta_bdy(ib_bdy)%ll_u2d ) dta_bdy(ib_bdy)%u2d(1:ilen0(2)) = dta_bdy_s(ib_bdy)%u2d(1:ilen0(2))
+               IF ( dta_bdy(ib_bdy)%ll_v2d ) dta_bdy(ib_bdy)%v2d(1:ilen0(3)) = dta_bdy_s(ib_bdy)%v2d(1:ilen0(3))
             ENDIF
             !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyvol.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyvol.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/BDY/bdyvol.F90	(revision 6041)
@@ -10,28 +10,29 @@
    !!            3.4  !  2011     (D. Storkey) rewrite in preparation for OBC-BDY merge
    !!----------------------------------------------------------------------
-#if   defined key_bdy   &&   defined key_dynspg_flt
+#if   defined key_bdy
    !!----------------------------------------------------------------------
-   !!   'key_bdy'            AND      unstructured open boundary conditions
-   !!   'key_dynspg_flt'                              filtered free surface
+   !!   'key_bdy'      unstructured open boundary conditions
    !!----------------------------------------------------------------------
-   USE timing          ! Timing
    USE oce             ! ocean dynamics and tracers 
-   USE sbcisf          ! ice shelf
+   USE bdy_oce         ! ocean open boundary conditions
+   USE sbc_oce         ! ocean surface boundary conditions
    USE dom_oce         ! ocean space and time domain 
    USE phycst          ! physical constants
-   USE bdy_oce         ! ocean open boundary conditions
+   USE sbcisf          ! ice shelf
+   !
+   USE in_out_manager  ! I/O manager
    USE lib_mpp         ! for mppsum
-   USE in_out_manager  ! I/O manager
-   USE sbc_oce         ! ocean surface boundary conditions
+   USE timing          ! Timing
+   USE lib_fortran     ! Fortran routines library
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC bdy_vol        ! routine called by dynspg_flt.h90
+   PUBLIC bdy_vol      
 
    !! * Substitutions
 #  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.6 , NEMO Consortium (2014)
    !! $Id$ 
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
@@ -43,6 +44,6 @@
       !!                      ***  ROUTINE bdyvol  ***
       !!
-      !! ** Purpose :   This routine is called in dynspg_flt to control 
-      !!      the volume of the system. A correction velocity is calculated
+      !! ** Purpose :   This routine controls the volume of the system. 
+      !!      A correction velocity is calculated
       !!      to correct the total transport through the unstructured OBC. 
       !!      The total depth used is constant (H0) to be consistent with the 
@@ -78,9 +79,9 @@
       TYPE(OBC_INDEX), POINTER :: idx
       !!-----------------------------------------------------------------------------
-
-      IF( nn_timing == 1 ) CALL timing_start('bdy_vol')
-
+      !
+      IF( nn_timing == 1 )   CALL timing_start('bdy_vol')
+      !
       IF( ln_vol ) THEN
-
+      !
       IF( kt == nit000 ) THEN 
          IF(lwp) WRITE(numout,*)
@@ -91,13 +92,17 @@
       ! Calculate the cumulate surface Flux z_cflxemp (m3/s) over all the domain
       ! -----------------------------------------------------------------------
-      z_cflxemp = SUM ( ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1t(:,:) * e2t(:,:) ) / rau0
+!!gm replace these lines :
+      z_cflxemp = SUM ( ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:) ) / rau0
       IF( lk_mpp )   CALL mpp_sum( z_cflxemp )     ! sum over the global domain
+!!gm   by :
+!!gm      z_cflxemp = glob_sum(  ( emp(:,:)-rnf(:,:)+fwfisf(:,:) ) * bdytmask(:,:) * e1e2t(:,:)  ) / rau0
+!!gm
 
       ! Transport through the unstructured open boundary
       ! ------------------------------------------------
-      zubtpecor = 0.e0
+      zubtpecor = 0._wp
       DO ib_bdy = 1, nb_bdy
          idx => idx_bdy(ib_bdy)
-
+         !
          jgrd = 2                               ! cumulate u component contribution first 
          DO jb = 1, idx%nblenrim(jgrd)
@@ -116,5 +121,5 @@
             END DO
          END DO
-
+         !
       END DO
       IF( lk_mpp )   CALL mpp_sum( zubtpecor )   ! sum over the global domain
@@ -123,13 +128,13 @@
       ! ------------------------------
       IF( nn_volctl==1 ) THEN   ;   zubtpecor = ( zubtpecor - z_cflxemp) / bdysurftot 
-      ELSE                   ;   zubtpecor =   zubtpecor             / bdysurftot
+      ELSE                      ;   zubtpecor =   zubtpecor             / bdysurftot
       END IF
 
       ! Correction of the total velocity on the unstructured boundary to respect the mass flux conservation
       ! -------------------------------------------------------------
-      ztranst = 0.e0
+      ztranst = 0._wp
       DO ib_bdy = 1, nb_bdy
          idx => idx_bdy(ib_bdy)
-
+         !
          jgrd = 2                               ! correct u component
          DO jb = 1, idx%nblenrim(jgrd)
@@ -150,5 +155,5 @@
             END DO
          END DO
-
+         !
       END DO
       IF( lk_mpp )   CALL mpp_sum( ztranst )   ! sum over the global domain
@@ -169,5 +174,5 @@
       !
       END IF ! ln_vol
-
+      !
    END SUBROUTINE bdy_vol
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/c1d.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/c1d.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/c1d.F90	(revision 6041)
@@ -48,5 +48,4 @@
       !!----------------------------------------------------------------------
       !
-
       REWIND( numnam_ref )              ! Namelist namc1d in reference namelist : Tracer advection scheme
       READ  ( numnam_ref, namc1d, IOSTAT = ios, ERR = 901)
@@ -57,5 +56,4 @@
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namc1d in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namc1d )
-
       !
       IF(lwp) THEN                    ! Control print
@@ -69,5 +67,4 @@
       ENDIF
       !
-      !
    END SUBROUTINE c1d_init
 
@@ -77,14 +74,10 @@
    !!----------------------------------------------------------------------
    USE par_kind         ! kind parameters
-
    LOGICAL, PUBLIC, PARAMETER ::   lk_c1d = .FALSE.   !: 1D config. flag de-activated
    REAL(wp)                   ::   rn_lat1d, rn_lon1d
    LOGICAL , PUBLIC           ::   ln_c1d_locpt = .FALSE. 
-
 CONTAINS
-
    SUBROUTINE c1d_init               ! Dummy routine
    END SUBROUTINE c1d_init
-
 #endif
 
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/dynnxt_c1d.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/dynnxt_c1d.F90	(revision 6040)
+++ 	(revision )
@@ -1,103 +1,0 @@
-MODULE dynnxt_c1d
-   !!======================================================================
-   !!                       ***  MODULE  dynnxt_c1d  ***
-   !! Ocean dynamics: time stepping in 1D configuration
-   !!======================================================================
-   !! History :  2.0  !  2004-10  (C. Ethe)  Original code from dynnxt.F90
-   !!            3.0  !  2008-04  (G.madec)  Style only
-   !!----------------------------------------------------------------------
-#if defined key_c1d
-   !!----------------------------------------------------------------------
-   !!   'key_c1d'                                          1D Configuration
-   !!----------------------------------------------------------------------  
-   !!   dyn_nxt_c1d : update the horizontal velocity from the momentum trend
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! lateral boundary condition (or mpp link)
-   USE prtctl          ! Print control
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC dyn_nxt_c1d                ! routine called by step.F90
-   !!----------------------------------------------------------------------
-   !! NEMO/C1D 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE dyn_nxt_c1d ( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dyn_nxt_c1d  ***
-      !!                   
-      !! ** Purpose :   Compute the after horizontal velocity from the momentum trend.
-      !!
-      !! ** Method  :   Apply lateral boundary conditions on the trends (ua,va) 
-      !!      through calls to routine lbc_lnk.
-      !!      After velocity is compute using a leap-frog scheme environment:
-      !!         (ua,va) = (ub,vb) + 2 rdt (ua,va)
-      !!      Time filter applied on now horizontal velocity to avoid the
-      !!      divergence of two consecutive time-steps and swap of dynamics
-      !!      arrays to start the next time step:
-      !!         (ub,vb) = (un,vn) + atfp [ (ub,vb) + (ua,va) - 2 (un,vn) ]
-      !!         (un,vn) = (ua,va) 
-      !!
-      !! ** Action : - Update ub,vb arrays, the before horizontal velocity
-      !!             - Update un,vn arrays, the now horizontal velocity
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-      !!
-      INTEGER  ::   jk           ! dummy loop indices
-      REAL(wp) ::   z2dt         ! temporary scalar
-      !!----------------------------------------------------------------------
-
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dyn_nxt_c1d : time stepping on 1D configuation'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-      ENDIF
-
-      z2dt = 2._wp * rdt                                                   ! Local constant initialization
-      IF( neuler == 0 .AND. kt == nit000 )  z2dt = rdt
-
-      CALL lbc_lnk( ua, 'U', -1. )   ;   CALL lbc_lnk( va, 'V', -1. )      ! Lateral boundary conditions
-
-      DO jk = 1, jpkm1                                                     ! Next Velocity
-         ua(:,:,jk) = ( ub(:,:,jk) + z2dt * ua(:,:,jk) ) * umask(:,:,jk)
-         va(:,:,jk) = ( vb(:,:,jk) + z2dt * va(:,:,jk) ) * vmask(:,:,jk)
-      END DO 
- 
-      DO jk = 1, jpkm1                                                     ! Time filter and swap of dynamics arrays
-         IF( neuler == 0 .AND. kt == nit000 ) THEN                               ! Euler (forward) time stepping
-             ub(:,:,jk) = un(:,:,jk)
-             vb(:,:,jk) = vn(:,:,jk)
-             un(:,:,jk) = ua(:,:,jk)
-             vn(:,:,jk) = va(:,:,jk)
-         ELSE                                                                    ! Leap-frog time stepping
-             ub(:,:,jk) = atfp * ( ub(:,:,jk) + ua(:,:,jk) ) + atfp1 * un(:,:,jk)
-             vb(:,:,jk) = atfp * ( vb(:,:,jk) + va(:,:,jk) ) + atfp1 * vn(:,:,jk)
-             un(:,:,jk) = ua(:,:,jk)
-             vn(:,:,jk) = va(:,:,jk)
-         ENDIF
-      END DO
-
-      IF(ln_ctl)   CALL prt_ctl( tab3d_1=un, clinfo1=' nxt_c1d  - Un: ', mask1=umask,   &
-         &                       tab3d_2=vn, clinfo2=' Vn: '           , mask2=vmask )
-      !
-   END SUBROUTINE dyn_nxt_c1d
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default key                                     NO 1D Config
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE dyn_nxt_c1d ( kt )
-      WRITE(*,*) 'dyn_nxt_c1d: You should not have seen this print! error?', kt
-   END SUBROUTINE dyn_nxt_c1d
-#endif
-
-   !!======================================================================
-END MODULE dynnxt_c1d
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/step_c1d.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/step_c1d.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/C1D/step_c1d.F90	(revision 6041)
@@ -18,5 +18,5 @@
 #endif
    USE dyncor_c1d      ! Coriolis term (c1d case)         (dyn_cor_1d     )
-   USE dynnxt_c1d      ! time-stepping                    (dyn_nxt routine)
+   USE dynnxt          ! time-stepping                    (dyn_nxt routine)
    USE dyndmp          ! U & V momentum damping           (dyn_dmp routine)
    USE restart         ! restart 
@@ -82,5 +82,4 @@
       IF( lk_zdftke  )   CALL zdf_tke( kstp )            ! TKE closure scheme for Kz
       IF( lk_zdfgls  )   CALL zdf_gls( kstp )            ! GLS closure scheme for Kz
-      IF( lk_zdfkpp  )   CALL zdf_kpp( kstp )            ! KPP closure scheme for Kz
       IF( lk_zdfcst  )   THEN                            ! Constant Kz (reset avt, avm[uv] to the background value)
          avt (:,:,:) = rn_avt0 * tmask(:,:,:)
@@ -93,10 +92,6 @@
       ENDIF
       IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
-
       IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
-
-      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
-         &               CALL zdf_ddm( kstp )         ! double diffusive mixing
-         
+      IF( lk_zdfddm  )   CALL zdf_ddm( kstp )         ! double diffusive mixing
                          CALL zdf_mxl( kstp )         ! mixed layer depth
 
@@ -128,5 +123,4 @@
       IF( ln_traqsr )   CALL tra_qsr( kstp )       ! penetrative solar radiation qsr
       IF( ln_tradmp )   CALL tra_dmp( kstp )       ! internal damping trends- tracers
-      IF( lk_zdfkpp )   CALL tra_kpp( kstp )       ! KPP non-local tracer fluxes
                         CALL tra_zdf( kstp )       ! vertical mixing
                         CALL eos( tsn, rhd, rhop, gdept_0(:,:,:) )   ! now potential density for zdfmxl
@@ -145,5 +139,5 @@
                         CALL dyn_cor_c1d( kstp )   ! vorticity term including Coriolis
                         CALL dyn_zdf    ( kstp )   ! vertical diffusion
-                        CALL dyn_nxt_c1d( kstp )   ! lateral velocity at next time step
+                        CALL dyn_nxt    ( kstp )   ! lateral velocity at next time step
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/CRS/crsfld.F90	(revision 6041)
@@ -11,18 +11,19 @@
    !!                       other variables needed to be passed to TOP
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers 
-   USE dom_oce         ! ocean space and time domain
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE sbc_oce         ! Surface boundary condition: ocean fields
-   USE zdf_oce         ! vertical  physics: ocean fields
-   USE zdfddm          ! vertical  physics: double diffusion
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE in_out_manager  ! I/O manager
-   USE timing          ! preformance summary
-   USE wrk_nemo        ! working array
    USE crs
    USE crsdom
    USE crslbclnk
-   USE iom
+   USE oce             ! ocean dynamics and tracers 
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce         ! Surface boundary condition: ocean fields
+   USE zdf_oce         ! vertical  physics: ocean fields
+   USE ldftra          ! ocean active tracers: lateral diffusivity & EIV coefficients
+   USE zdfddm          ! vertical  physics: double diffusion
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! 
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE timing          ! preformance summary
+   USE wrk_nemo        ! working array
 
    IMPLICIT NONE
@@ -30,5 +31,4 @@
 
    PUBLIC   crs_fld                 ! routines called by step.F90
-
 
    !! * Substitutions
@@ -37,5 +37,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -56,24 +56,20 @@
       !! ** Method  :  
       !!----------------------------------------------------------------------
-      !!
-      
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-      !!
-      INTEGER               ::   ji, jj, jk              ! dummy loop indices
-      !!
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zfse3t, zfse3u, zfse3v, zfse3w ! 3D workspace for e3
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zt, zs 
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zt_crs, zs_crs !
-      REAL(wp)       :: z2dcrsu, z2dcrsv
-      !!
-       !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk        ! dummy loop indices
+      REAL(wp) ::   z2dcrsu, z2dcrsv  ! local scalars
+      !
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zfse3t, zfse3u, zfse3v, zfse3w   ! 3D workspace for e3
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zt, zt_crs
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zs, zs_crs  
+      !!----------------------------------------------------------------------
       ! 
-
       IF( nn_timing == 1 )   CALL timing_start('crs_fld')
 
       !  Initialize arrays
-      CALL wrk_alloc( jpi, jpj, jpk, zfse3t, zfse3w )
-      CALL wrk_alloc( jpi, jpj, jpk, zfse3u, zfse3v )
-      CALL wrk_alloc( jpi, jpj, jpk, zt, zs       )
+      CALL wrk_alloc( jpi,jpj,jpk,   zfse3t, zfse3w )
+      CALL wrk_alloc( jpi,jpj,jpk,   zfse3u, zfse3v )
+      CALL wrk_alloc( jpi,jpj,jpk,   zt    , zs     )
       !
       CALL wrk_alloc( jpi_crs, jpj_crs, jpk, zt_crs, zs_crs )
@@ -169,5 +165,5 @@
       CALL iom_put( "eken", rke_crs )
 
-      !  Horizontal divergence ( following OPA_SRC/DYN/divcur.F90 ) 
+      !  Horizontal divergence ( following OPA_SRC/DYN/divhor.F90 ) 
       DO jk = 1, jpkm1
          DO ji = 2, jpi_crsm1
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/CRS/crsini.F90	(revision 6041)
@@ -7,27 +7,32 @@
    !!----------------------------------------------------------------------
 
-   USE timing                   ! Timing
+   !!----------------------------------------------------------------------
+   !!  crs_init    : 
+   !!----------------------------------------------------------------------
+   USE par_kind, ONLY: wp
    USE par_oce                  ! For parameter jpi,jpj,jphgr_msh
    USE dom_oce                  ! For parameters in par_oce (jperio, lk_vvl)
-   USE crs                  ! Coarse grid domain
+   USE crs                      ! Coarse grid domain
    USE phycst, ONLY: omega, rad ! physical constants
-   USE wrk_nemo 
-   USE in_out_manager
-   USE par_kind, ONLY: wp
-   USE iom
    USE crsdom
    USE crsdomwri
    USE crslbclnk
+   !
+   USE iom
+   USE in_out_manager
    USE lib_mpp
+   USE wrk_nemo 
+   USE timing                   ! Timing
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC  crs_init
+   PUBLIC   crs_init   ! called by nemogcm.F90 module
 
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-
+   !!----------------------------------------------------------------------
    !! $Id$
+   !!----------------------------------------------------------------------
 CONTAINS
    
@@ -65,5 +70,4 @@
       !!               - Read in pertinent data ?
       !!-------------------------------------------------------------------
-      !! Local variables
       INTEGER  :: ji,jj,jk      ! dummy indices
       INTEGER  :: ierr                                ! allocation error status
@@ -183,5 +187,5 @@
      
      !
-     CALL wrk_alloc(jpi, jpj, jpk, zfse3t, zfse3u, zfse3v, zfse3w )
+     CALL wrk_alloc( jpi,jpj,jpk,   zfse3t, zfse3u, zfse3v, zfse3w )
      !
      zfse3t(:,:,:) = fse3t(:,:,:)
@@ -200,6 +204,4 @@
      !    3.d.3   Vertical scale factors
      !
-   
-  
      CALL crs_dom_e3( e1t, e2t, zfse3t, e1e2w_crs, 'T', tmask, e3t_crs, e3t_max_crs)
      CALL crs_dom_e3( e1u, e2u, zfse3u, e2e3u_crs, 'U', umask, e3u_crs, e3u_max_crs)
@@ -207,5 +209,5 @@
      CALL crs_dom_e3( e1t, e2t, zfse3w, e1e2w_crs, 'W', tmask, e3w_crs, e3w_max_crs)
 
-     ! Reset 0 to e3t_0 or e3w_0
+     ! Replace 0 by e3t_0 or e3w_0
      DO jk = 1, jpk
         DO ji = 1, jpi_crs
@@ -247,13 +249,11 @@
      ENDIF
      
-     !---------------------------------------------------------
-     ! 7. Finish and clean-up
-     !---------------------------------------------------------
-     CALL wrk_dealloc(jpi, jpj, jpk, zfse3t, zfse3u, zfse3v, zfse3w )
-
-
+      !---------------------------------------------------------
+      ! 7. Finish and clean-up
+      !---------------------------------------------------------
+      CALL wrk_dealloc( jpi,jpj,jpk,   zfse3t, zfse3u, zfse3v, zfse3w )
+      !
    END SUBROUTINE crs_init
     
    !!======================================================================
-
 END MODULE crsini
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diaar5.F90	(revision 6041)
@@ -7,5 +7,5 @@
    !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA
    !!----------------------------------------------------------------------
-#if defined key_diaar5   || defined key_esopa
+#if defined key_diaar5
    !!----------------------------------------------------------------------
    !!   'key_diaar5'  :                           activate ar5 diagnotics
@@ -237,5 +237,5 @@
       IF( dia_ar5_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dia_ar5_init : unable to allocate arrays' )
 
-      area(:,:) = e1t(:,:) * e2t(:,:) * tmask_i(:,:)
+      area(:,:) = e1e2t(:,:) * tmask_i(:,:)
 
       area_tot = SUM( area(:,:) )   ;   IF( lk_mpp )   CALL mpp_sum( area_tot )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diafwb.F90	(revision 6041)
@@ -74,5 +74,5 @@
          a_salb   = 0.e0 ! valeur de sal au debut de la simulation
          ! sshb used because diafwb called after tranxt (i.e. after the swap)
-         a_sshb = SUM( e1t(:,:) * e2t(:,:) * sshb(:,:) * tmask_i(:,:) )
+         a_sshb = SUM( e1e2t(:,:) * sshb(:,:) * tmask_i(:,:) )
          IF( lk_mpp )   CALL mpp_sum( a_sshb )      ! sum over the global domain
 
@@ -80,5 +80,5 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zwei  = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+                  zwei  = e1e2t(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
                   a_salb = a_salb + ( tsb(ji,jj,jk,jp_sal) - zsm0 ) * zwei
                END DO
@@ -88,5 +88,5 @@
       ENDIF
       
-      a_fwf    = SUM( e1t(:,:) * e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:) ) 
+      a_fwf    = SUM( e1e2t(:,:) * ( emp(:,:)-rnf(:,:) ) * tmask_i(:,:) ) 
       IF( lk_mpp )   CALL mpp_sum( a_fwf    )       ! sum over the global domain
 
@@ -98,7 +98,7 @@
          zfwfnew = 0.e0
          ! Mean sea level at nitend
-         a_sshn = SUM( e1t(:,:) * e2t(:,:) * sshn(:,:) * tmask_i(:,:) )
+         a_sshn = SUM( e1e2t(:,:) * sshn(:,:) * tmask_i(:,:) )
          IF( lk_mpp )   CALL mpp_sum( a_sshn )      ! sum over the global domain
-         zarea  = SUM( e1t(:,:) * e2t(:,:) *             tmask_i(:,:) )
+         zarea  = SUM( e1e2t(:,:) *             tmask_i(:,:) )
          IF( lk_mpp )   CALL mpp_sum( zarea  )      ! sum over the global domain
          
@@ -106,5 +106,5 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zwei  = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+                  zwei  = e1e2t(ji,jj) * fse3t(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
                   a_saln = a_saln + ( tsn(ji,jj,jk,jp_sal) - zsm0 ) * zwei
                   zvol  = zvol  + zwei
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diaharm.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diaharm.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diaharm.F90	(revision 6041)
@@ -14,6 +14,4 @@
    USE dom_oce         ! ocean space and time domain
    USE phycst
-   USE dynspg_oce
-   USE dynspg_ts
    USE daymod
    USE tide_mod
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diahth.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diahth.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diahth.F90	(revision 6041)
@@ -8,8 +8,8 @@
    !!                 !  1997-08  (G. Madec)  optimization
    !!                 !  1999-07  (E. Guilyardi)  hd28 + heat content 
-   !!            8.5  !  2002-06  (G. Madec)  F90: Free form and module
-   !!   NEMO     3.2  !  2009-07  (S. Masson) hc300 bugfix + cleaning + add new diag
-   !!----------------------------------------------------------------------
-#if   defined key_diahth   ||   defined key_esopa
+   !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
+   !!            3.2  !  2009-07  (S. Masson) hc300 bugfix + cleaning + add new diag
+   !!----------------------------------------------------------------------
+#if   defined key_diahth
    !!----------------------------------------------------------------------
    !!   'key_diahth' :                              thermocline depth diag.
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 6041)
@@ -17,4 +17,6 @@
    !!                 ! 2005-11  (V. Garnier) Surface pressure gradient organization
    !!            3.2  ! 2008-11  (B. Lemaire) creation from old diawri
+   !!            3.7  ! 2014-01  (G. Madec) remove eddy induced velocity from no-IOM output
+   !!                 !                     change name of output variables in dia_wri_state
    !!----------------------------------------------------------------------
 
@@ -27,8 +29,5 @@
    USE dynadv, ONLY: ln_dynadv_vec
    USE zdf_oce         ! ocean vertical physics
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldfdyn_oce      ! ocean dynamics: lateral physics
-   USE traldf_iso_grif, ONLY : psix_eiv, psiy_eiv
-   USE sol_oce         ! solver variables
+   USE ldftra          ! lateral physics: eddy diffusivity coef.
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
@@ -46,5 +45,4 @@
    USE iom
    USE ioipsl
-   USE dynspg_oce, ONLY: un_adv, vn_adv ! barotropic velocities     
 
 #if defined key_lim2
@@ -206,9 +204,10 @@
          CALL iom_put( "sbu", z2d )                ! bottom i-current
       ENDIF
-#if defined key_dynspg_ts
-      CALL iom_put(  "ubar", un_adv(:,:)      )    ! barotropic i-current
-#else
-      CALL iom_put(  "ubar", un_b(:,:)        )    ! barotropic i-current
-#endif
+
+      IF ( ln_dynspg_ts ) THEN
+         CALL iom_put(  "ubar", un_adv(:,:)      )    ! barotropic i-current
+      ELSE
+         CALL iom_put(  "ubar", un_b(:,:)        )    ! barotropic i-current
+      ENDIF
       
       CALL iom_put( "voce", vn(:,:,:)         )    ! 3D j-current
@@ -223,14 +222,15 @@
          CALL iom_put( "sbv", z2d )                ! bottom j-current
       ENDIF
-#if defined key_dynspg_ts
-      CALL iom_put(  "vbar", vn_adv(:,:)      )    ! barotropic j-current
-#else
-      CALL iom_put(  "vbar", vn_b(:,:)        )    ! barotropic j-current
-#endif
+
+      IF ( ln_dynspg_ts ) THEN
+         CALL iom_put(  "vbar", vn_adv(:,:)      )    ! barotropic j-current
+      ELSE
+         CALL iom_put(  "vbar", vn_b(:,:)        )    ! barotropic j-current
+      ENDIF
 
       CALL iom_put( "woce", wn )                   ! vertical velocity
       IF( iom_use('w_masstr') .OR. iom_use('w_masstr2') ) THEN   ! vertical mass transport & its square value
          ! Caution: in the VVL case, it only correponds to the baroclinic mass transport.
-         z2d(:,:) = rau0 * e12t(:,:)
+         z2d(:,:) = rau0 * e1e2t(:,:)
          DO jk = 1, jpk
             z3d(:,:,jk) = wn(:,:,jk) * z2d(:,:)
@@ -247,7 +247,7 @@
          DO jj = 2, jpjm1                                    ! sst gradient
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zztmp      = tsn(ji,jj,1,jp_tem)
-               zztmpx     = ( tsn(ji+1,jj  ,1,jp_tem) - zztmp ) / e1u(ji,jj) + ( zztmp - tsn(ji-1,jj  ,1,jp_tem) ) / e1u(ji-1,jj  )
-               zztmpy     = ( tsn(ji  ,jj+1,1,jp_tem) - zztmp ) / e2v(ji,jj) + ( zztmp - tsn(ji  ,jj-1,1,jp_tem) ) / e2v(ji  ,jj-1)
+               zztmp  = tsn(ji,jj,1,jp_tem)
+               zztmpx = ( tsn(ji+1,jj,1,jp_tem) - zztmp ) * r1_e1u(ji,jj) + ( zztmp - tsn(ji-1,jj  ,1,jp_tem) ) * r1_e1u(ji-1,jj)
+               zztmpy = ( tsn(ji,jj+1,1,jp_tem) - zztmp ) * r1_e2v(ji,jj) + ( zztmp - tsn(ji  ,jj-1,1,jp_tem) ) * r1_e2v(ji,jj-1)
                z2d(ji,jj) = 0.25 * ( zztmpx * zztmpx + zztmpy * zztmpy )   &
                   &              * umask(ji,jj,1) * umask(ji-1,jj,1) * vmask(ji,jj,1) * umask(ji,jj-1,1)
@@ -401,7 +401,6 @@
       !!      Each nwrite time step, output the instantaneous or mean fields
       !!----------------------------------------------------------------------
-      !!
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-      !!
+      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
+      !
       LOGICAL ::   ll_print = .FALSE.                        ! =T print and flush numout
       CHARACTER (len=40) ::   clhstnam, clop, clmx           ! local names
@@ -412,5 +411,5 @@
       INTEGER  ::   jn, ierror                               ! local integers
       REAL(wp) ::   zsto, zout, zmax, zjulian, zdt           ! local scalars
-      !!
+      !
       REAL(wp), POINTER, DIMENSION(:,:)   :: zw2d       ! 2D workspace
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zw3d       ! 3D workspace
@@ -419,6 +418,6 @@
       IF( nn_timing == 1 )   CALL timing_start('dia_wri')
       !
-      CALL wrk_alloc( jpi , jpj      , zw2d )
-      IF ( ln_traldf_gdia .OR. lk_vvl )  call wrk_alloc( jpi , jpj , jpk  , zw3d )
+                     CALL wrk_alloc( jpi,jpj      , zw2d )
+      IF( lk_vvl )   CALL wrk_alloc( jpi,jpj,jpk  , zw3d )
       !
       ! Output the initial state and forcings
@@ -657,6 +656,6 @@
          
          clmx ="l_max(only(x))"    ! max index on a period
-         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
-            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clmx, zsto, zout )
+!         CALL histdef( nid_T, "sobowlin", "Bowl Index"                         , "W-point",   &  ! bowl INDEX 
+!            &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clmx, zsto, zout )
 #if defined key_diahth
          CALL histdef( nid_T, "sothedep", "Thermocline Depth"                  , "m"      ,   & ! hth
@@ -682,13 +681,4 @@
          CALL histdef( nid_U, "vozocrtx", "Zonal Current"                      , "m/s"    ,   &  ! un
             &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
-         IF( ln_traldf_gdia ) THEN
-            CALL histdef( nid_U, "vozoeivu", "Zonal EIV Current"                  , "m/s"    ,   &  ! u_eiv
-                 &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
-         ELSE
-#if defined key_diaeiv
-            CALL histdef( nid_U, "vozoeivu", "Zonal EIV Current"                  , "m/s"    ,   &  ! u_eiv
-            &          jpi, jpj, nh_U, ipk, 1, ipk, nz_U, 32, clop, zsto, zout )
-#endif
-         END IF
          !                                                                                      !!! nid_U : 2D
          CALL histdef( nid_U, "sozotaux", "Wind Stress along i-axis"           , "N/m2"   ,   &  ! utau
@@ -700,13 +690,4 @@
          CALL histdef( nid_V, "vomecrty", "Meridional Current"                 , "m/s"    ,   &  ! vn
             &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
-         IF( ln_traldf_gdia ) THEN
-            CALL histdef( nid_V, "vomeeivv", "Meridional EIV Current"             , "m/s"    ,   &  ! v_eiv
-                 &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
-         ELSE 
-#if defined key_diaeiv
-            CALL histdef( nid_V, "vomeeivv", "Meridional EIV Current"             , "m/s"    ,   &  ! v_eiv
-            &          jpi, jpj, nh_V, ipk, 1, ipk, nz_V, 32, clop, zsto, zout )
-#endif
-         END IF
          !                                                                                      !!! nid_V : 2D
          CALL histdef( nid_V, "sometauy", "Wind Stress along j-axis"           , "N/m2"   ,   &  ! vtau
@@ -718,13 +699,4 @@
          CALL histdef( nid_W, "vovecrtz", "Vertical Velocity"                  , "m/s"    ,   &  ! wn
             &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-         IF( ln_traldf_gdia ) THEN
-            CALL histdef( nid_W, "voveeivw", "Vertical EIV Velocity"              , "m/s"    ,   &  ! w_eiv
-                 &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-         ELSE
-#if defined key_diaeiv
-            CALL histdef( nid_W, "voveeivw", "Vertical EIV Velocity"              , "m/s"    ,   &  ! w_eiv
-                 &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
-#endif
-         END IF
          CALL histdef( nid_W, "votkeavt", "Vertical Eddy Diffusivity"          , "m2/s"   ,   &  ! avt
             &          jpi, jpj, nh_W, ipk, 1, ipk, nz_W, 32, clop, zsto, zout )
@@ -737,13 +709,4 @@
          ENDIF
          !                                                                                      !!! nid_W : 2D
-#if defined key_traldf_c2d
-         CALL histdef( nid_W, "soleahtw", "lateral eddy diffusivity"           , "m2/s"   ,   &  ! ahtw
-            &          jpi, jpj, nh_W, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
-# if defined key_traldf_eiv 
-            CALL histdef( nid_W, "soleaeiw", "eddy induced vel. coeff. at w-point", "m2/s",   &  ! aeiw
-               &       jpi, jpj, nh_W, 1  , 1, 1  , - 99, 32, clop, zsto, zout )
-# endif
-#endif
-
          CALL histend( nid_W, snc4chunks=snc4set )
 
@@ -853,55 +816,10 @@
 
       CALL histwrite( nid_U, "vozocrtx", it, un            , ndim_U , ndex_U )    ! i-current
-      IF( ln_traldf_gdia ) THEN
-         IF (.not. ALLOCATED(psix_eiv))THEN
-            ALLOCATE( psix_eiv(jpi,jpj,jpk) , psiy_eiv(jpi,jpj,jpk) , STAT=ierr )
-            IF( lk_mpp   )   CALL mpp_sum ( ierr )
-            IF( ierr > 0 )   CALL ctl_stop('STOP', 'diawri: unable to allocate psi{x,y}_eiv')
-            psix_eiv(:,:,:) = 0.0_wp
-            psiy_eiv(:,:,:) = 0.0_wp
-         ENDIF
-         DO jk=1,jpkm1
-            zw3d(:,:,jk) = (psix_eiv(:,:,jk+1) - psix_eiv(:,:,jk))/fse3u(:,:,jk)  ! u_eiv = -dpsix/dz
-         END DO
-         zw3d(:,:,jpk) = 0._wp
-         CALL histwrite( nid_U, "vozoeivu", it, zw3d, ndim_U , ndex_U )           ! i-eiv current
-      ELSE
-#if defined key_diaeiv
-         CALL histwrite( nid_U, "vozoeivu", it, u_eiv, ndim_U , ndex_U )          ! i-eiv current
-#endif
-      ENDIF
       CALL histwrite( nid_U, "sozotaux", it, utau          , ndim_hU, ndex_hU )   ! i-wind stress
 
       CALL histwrite( nid_V, "vomecrty", it, vn            , ndim_V , ndex_V  )   ! j-current
-      IF( ln_traldf_gdia ) THEN
-         DO jk=1,jpk-1
-            zw3d(:,:,jk) = (psiy_eiv(:,:,jk+1) - psiy_eiv(:,:,jk))/fse3v(:,:,jk)  ! v_eiv = -dpsiy/dz
-         END DO
-         zw3d(:,:,jpk) = 0._wp
-         CALL histwrite( nid_V, "vomeeivv", it, zw3d, ndim_V , ndex_V )           ! j-eiv current
-      ELSE
-#if defined key_diaeiv
-         CALL histwrite( nid_V, "vomeeivv", it, v_eiv, ndim_V , ndex_V )          ! j-eiv current
-#endif
-      ENDIF
       CALL histwrite( nid_V, "sometauy", it, vtau          , ndim_hV, ndex_hV )   ! j-wind stress
 
       CALL histwrite( nid_W, "vovecrtz", it, wn             , ndim_T, ndex_T )    ! vert. current
-      IF( ln_traldf_gdia ) THEN
-         DO jk=1,jpk-1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1  ! vector opt.
-                  zw3d(ji,jj,jk) = (psiy_eiv(ji,jj,jk) - psiy_eiv(ji,jj-1,jk))/e2v(ji,jj) + &
-                       &    (psix_eiv(ji,jj,jk) - psix_eiv(ji-1,jj,jk))/e1u(ji,jj) ! w_eiv = dpsiy/dy + dpsiy/dx
-               END DO
-            END DO
-         END DO
-         zw3d(:,:,jpk) = 0._wp
-         CALL histwrite( nid_W, "voveeivw", it, zw3d          , ndim_T, ndex_T )    ! vert. eiv current
-      ELSE
-#   if defined key_diaeiv
-         CALL histwrite( nid_W, "voveeivw", it, w_eiv          , ndim_T, ndex_T )    ! vert. eiv current
-#   endif
-      ENDIF
       CALL histwrite( nid_W, "votkeavt", it, avt            , ndim_T, ndex_T )    ! T vert. eddy diff. coef.
       CALL histwrite( nid_W, "votkeavm", it, avmu           , ndim_T, ndex_T )    ! T vert. eddy visc. coef.
@@ -909,10 +827,4 @@
          CALL histwrite( nid_W, "voddmavs", it, fsavs(:,:,:), ndim_T, ndex_T )    ! S vert. eddy diff. coef.
       ENDIF
-#if defined key_traldf_c2d
-      CALL histwrite( nid_W, "soleahtw", it, ahtw          , ndim_hT, ndex_hT )   ! lateral eddy diff. coef.
-# if defined key_traldf_eiv
-         CALL histwrite( nid_W, "soleaeiw", it, aeiw       , ndim_hT, ndex_hT )   ! EIV coefficient at w-point
-# endif
-#endif
 
       ! 3. Close all files
@@ -925,6 +837,6 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi , jpj      , zw2d )
-      IF ( ln_traldf_gdia .OR. lk_vvl )  call wrk_dealloc( jpi , jpj , jpk  , zw3d )
+                     CALL wrk_dealloc( jpi , jpj        , zw2d )
+      IF( lk_vvl )   CALL wrk_dealloc( jpi , jpj , jpk  , zw3d )
       !
       IF( nn_timing == 1 )   CALL timing_stop('dia_wri')
@@ -958,6 +870,4 @@
       !!----------------------------------------------------------------------
       ! 
-!     IF( nn_timing == 1 )   CALL timing_start('dia_wri_state') ! not sure this works for routines not called in first timestep
-
       ! 0. Initialisation
       ! -----------------
@@ -1018,5 +928,5 @@
          CALL histdef( id_i, "vovvldep", "T point depth"         , "m"      ,   &   ! t-point depth
             &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
-      END IF
+      ENDIF
 
 #if defined key_lim2
@@ -1042,5 +952,5 @@
       CALL histwrite( id_i, "vomecrty", kt, vn               , jpi*jpj*jpk, idex )    ! now j-velocity
       CALL histwrite( id_i, "vovecrtz", kt, wn               , jpi*jpj*jpk, idex )    ! now k-velocity
-      CALL histwrite( id_i, "sowaflup", kt, (emp-rnf )       , jpi*jpj    , idex )    ! freshwater budget
+      CALL histwrite( id_i, "sowaflup", kt, emp-rnf          , jpi*jpj    , idex )    ! freshwater budget
       CALL histwrite( id_i, "sohefldo", kt, qsr + qns        , jpi*jpj    , idex )    ! total heat flux
       CALL histwrite( id_i, "soshfldo", kt, qsr              , jpi*jpj    , idex )    ! solar heat flux
@@ -1060,8 +970,5 @@
       ENDIF
 #endif
-       
-!     IF( nn_timing == 1 )   CALL timing_stop('dia_wri_state') ! not sure this works for routines not called in first timestep
       ! 
-
    END SUBROUTINE dia_wri_state
    !!======================================================================
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/closea.F90	(revision 6041)
@@ -71,19 +71,19 @@
       !!                                   =2 put at location runoff
       !!----------------------------------------------------------------------
-      INTEGER ::   jc            ! dummy loop indices
-      INTEGER :: isrow           ! local index
-      !!----------------------------------------------------------------------
-      
+      INTEGER ::   jc      ! dummy loop indices
+      INTEGER ::   isrow   ! local index
+      !!----------------------------------------------------------------------
+      !
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*)'dom_clo : closed seas '
       IF(lwp) WRITE(numout,*)'~~~~~~~'
-
+      !
       ! initial values
       ncsnr(:) = 1  ;  ncsi1(:) = 1  ;  ncsi2(:) = 1  ;  ncsir(:,:) = 1
       ncstt(:) = 0  ;  ncsj1(:) = 1  ;  ncsj2(:) = 1  ;  ncsjr(:,:) = 1
-
+      !
       ! set the closed seas (in data domain indices)
       ! -------------------
-
+      !
       IF( cp_cfg == "orca" ) THEN
          !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dom_oce.F90	(revision 6041)
@@ -7,7 +7,8 @@
    !! History :  1.0  ! 2005-10  (A. Beckmann, G. Madec)  reactivate s-coordinate 
    !!            3.3  ! 2010-11  (G. Madec) add mbk. arrays associated to the deepest ocean level
-   !!            4.0  ! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
+   !!            3.4  ! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
    !!            3.5  ! 2012     (S. Mocavero, I. Epicoco) Add arrays associated
    !!                             to the optimization of BDY communications
+   !!            3.7  ! 2015-11  (G. Madec) introduce surface and scale factor ratio
    !!----------------------------------------------------------------------
 
@@ -20,6 +21,5 @@
 
    IMPLICIT NONE
-   PUBLIC             ! allows the acces to par_oce when dom_oce is used
-   !                  ! exception to coding rules... to be suppressed ???
+   PUBLIC             ! allows the acces to par_oce when dom_oce is used (exception to coding rules)
 
    PUBLIC dom_oce_alloc  ! Called from nemogcm.F90
@@ -45,12 +45,17 @@
    LOGICAL , PUBLIC ::   ln_crs          !: Apply grid coarsening to dynamical model output or online passive tracers
 
+   !! Free surface parameters
+   !! =======================
+   LOGICAL, PUBLIC :: ln_dynspg_exp      !: Explicit free surface flag
+   LOGICAL, PUBLIC :: ln_dynspg_ts       !: Split-Explicit free surface flag
+
    !! Time splitting parameters
    !! =========================
    LOGICAL,  PUBLIC :: ln_bt_fw          !: Forward integration of barotropic sub-stepping
    LOGICAL,  PUBLIC :: ln_bt_av          !: Time averaging of barotropic variables
-   LOGICAL,  PUBLIC :: ln_bt_nn_auto     !: Set number of barotropic iterations automatically
+   LOGICAL,  PUBLIC :: ln_bt_auto        !: Set number of barotropic iterations automatically
    INTEGER,  PUBLIC :: nn_bt_flt         !: Filter choice
    INTEGER,  PUBLIC :: nn_baro           !: Number of barotropic iterations during one baroclinic step (rdt)
-   REAL(wp), PUBLIC :: rn_bt_cmax        !: Maximum allowed courant number (used if ln_bt_nn_auto=T)
+   REAL(wp), PUBLIC :: rn_bt_cmax        !: Maximum allowed courant number (used if ln_bt_auto=T)
 
    !! Horizontal grid parameters for domhgr
@@ -107,7 +112,4 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dtra  !: = 2*rdttra except at nit000 (=rdttra) if neuler=0
 
-   !                                         !!* Namelist namcla : cross land advection
-   INTEGER, PUBLIC ::   nn_cla               !: =1 cross land advection for exchanges through some straits (ORCA2)
-
    !!----------------------------------------------------------------------
    !! space domain parameters
@@ -158,14 +160,17 @@
    !! horizontal curvilinear coordinate and scale factors
    !! ---------------------------------------------------------------------
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  glamt, glamu   !: longitude of t-, u-, v- and f-points (degre)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  glamv, glamf   !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  gphit, gphiu   !: latitude  of t-, u-, v- and f-points (degre)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  gphiv, gphif   !:
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::  e1t, e2t, r1_e1t, r1_e2t   !: horizontal scale factors and inverse at t-point (m)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::  e1u, e2u, r1_e1u, r1_e2u   !: horizontal scale factors and inverse at u-point (m)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::  e1v, e2v, r1_e1v, r1_e2v   !: horizontal scale factors and inverse at v-point (m)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::  e1f, e2f, r1_e1f, r1_e2f   !: horizontal scale factors and inverse at f-point (m)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  e1e2t          !: surface at t-point (m2)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ff             !: coriolis factor (2.*omega*sin(yphi) ) (s-1)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   glamt , glamu, glamv , glamf    !: longitude at t, u, v, f-points [degree]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   gphit , gphiu, gphiv , gphif    !: latitude  at t, u, v, f-points [degree]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::   e1t   , e2t  , r1_e1t, r1_e2t   !: t-point horizontal scale factors    [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::   e1u   , e2u  , r1_e1u, r1_e2u   !: horizontal scale factors at u-point [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::   e1v   , e2v  , r1_e1v, r1_e2v   !: horizontal scale factors at v-point [m]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, TARGET, DIMENSION(:,:) ::   e1f   , e2f  , r1_e1f, r1_e2f   !: horizontal scale factors at f-point [m]
+   !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e1e2t , r1_e1e2t                !: associated metrics at t-point
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e1e2u , r1_e1e2u , e2_e1u       !: associated metrics at u-point
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e1e2v , r1_e1e2v , e1_e2v       !: associated metrics at v-point
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e1e2f , r1_e1e2f                !: associated metrics at f-point
+   !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ff                              !: coriolis factor                   [1/s]
 
    !!----------------------------------------------------------------------
@@ -216,10 +221,4 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ht_0           !: reference depth at t-       points (meters)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hu_0 , hv_0    !: reference depth at u- and v-points (meters)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   re2u_e1u       !: scale factor coeffs at u points (e2u/e1u)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   re1v_e2v       !: scale factor coeffs at v points (e1v/e2v)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e12t , r1_e12t !: horizontal cell surface and inverse at t points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e12u , r1_e12u !: horizontal cell surface and inverse at u points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e12v , r1_e12v !: horizontal cell surface and inverse at v points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   e12f , r1_e12f !: horizontal cell surface and inverse at f points
 
    INTEGER, PUBLIC ::   nla10              !: deepest    W level Above  ~10m (nlb10 - 1)
@@ -265,9 +264,4 @@
 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   tpol, fpol          !: north fold mask (jperio= 3 or 4)
-
-#if defined key_noslip_accurate
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:  )  :: npcoa              !: ???
-   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)  :: nicoa, njcoa       !: ???
-#endif
 
    !!----------------------------------------------------------------------
@@ -333,5 +327,5 @@
    INTEGER FUNCTION dom_oce_alloc()
       !!----------------------------------------------------------------------
-      INTEGER, DIMENSION(12) :: ierr
+      INTEGER, DIMENSION(13) :: ierr
       !!----------------------------------------------------------------------
       ierr(:) = 0
@@ -346,9 +340,15 @@
          &      tpol(jpiglo)  , fpol(jpiglo)                               , STAT=ierr(2) )
          !
-      ALLOCATE( glamt(jpi,jpj) , gphit(jpi,jpj) , e1t(jpi,jpj) , e2t(jpi,jpj) , r1_e1t(jpi,jpj) , r1_e2t(jpi,jpj) ,   & 
-         &      glamu(jpi,jpj) , gphiu(jpi,jpj) , e1u(jpi,jpj) , e2u(jpi,jpj) , r1_e1u(jpi,jpj) , r1_e2u(jpi,jpj) ,   &  
-         &      glamv(jpi,jpj) , gphiv(jpi,jpj) , e1v(jpi,jpj) , e2v(jpi,jpj) , r1_e1v(jpi,jpj) , r1_e2v(jpi,jpj) ,   &  
-         &      glamf(jpi,jpj) , gphif(jpi,jpj) , e1f(jpi,jpj) , e2f(jpi,jpj) , r1_e1f(jpi,jpj) , r1_e2f(jpi,jpj) ,   &
-         &      e1e2t(jpi,jpj) , ff   (jpi,jpj) , STAT=ierr(3) )     
+      ALLOCATE( glamt(jpi,jpj) ,    glamu(jpi,jpj) ,  glamv(jpi,jpj) ,  glamf(jpi,jpj) ,     &
+         &      gphit(jpi,jpj) ,    gphiu(jpi,jpj) ,  gphiv(jpi,jpj) ,  gphif(jpi,jpj) ,     &
+         &       e1t (jpi,jpj) ,     e2t (jpi,jpj) , r1_e1t(jpi,jpj) , r1_e2t(jpi,jpj) ,     &
+         &       e1u (jpi,jpj) ,     e2u (jpi,jpj) , r1_e1u(jpi,jpj) , r1_e2u(jpi,jpj) ,     &
+         &       e1v (jpi,jpj) ,     e2v (jpi,jpj) , r1_e1v(jpi,jpj) , r1_e2v(jpi,jpj) ,     &
+         &       e1f (jpi,jpj) ,     e2f (jpi,jpj) , r1_e1f(jpi,jpj) , r1_e2f(jpi,jpj) ,     &
+         &      e1e2t(jpi,jpj) , r1_e1e2t(jpi,jpj)                                     ,     &
+         &      e1e2u(jpi,jpj) , r1_e1e2u(jpi,jpj) , e2_e1u(jpi,jpj)                   ,     &
+         &      e1e2v(jpi,jpj) , r1_e1e2v(jpi,jpj) , e1_e2v(jpi,jpj)                   ,     &
+         &      e1e2f(jpi,jpj) , r1_e1e2f(jpi,jpj)                                     ,     &
+         &        ff (jpi,jpj)                                                         , STAT=ierr(3) )
          !
       ALLOCATE( gdep3w_0(jpi,jpj,jpk) , e3v_0(jpi,jpj,jpk) , e3f_0 (jpi,jpj,jpk) ,                         &
@@ -364,17 +364,12 @@
          &      gdept_b (jpi,jpj,jpk) ,gdepw_b(jpi,jpj,jpk) , e3w_b (jpi,jpj,jpk) ,                           &
          &      e3t_a   (jpi,jpj,jpk) , e3u_a (jpi,jpj,jpk) , e3v_a (jpi,jpj,jpk) ,                           &
-         &      ehu_a    (jpi,jpj)    , ehv_a  (jpi,jpj),                                                     &
-         &      ehur_a   (jpi,jpj)    , ehvr_a (jpi,jpj),                                                     &
-         &      ehu_b    (jpi,jpj)    , ehv_b  (jpi,jpj),                                                     &
-         &      ehur_b   (jpi,jpj)    , ehvr_b (jpi,jpj),                                  STAT=ierr(5) )                          
+         &      ehu_a   (jpi,jpj)     , ehv_a (jpi,jpj),                                                     &
+         &      ehur_a  (jpi,jpj)     , ehvr_a(jpi,jpj),                                                     &
+         &      ehu_b   (jpi,jpj)     , ehv_b (jpi,jpj),                                                     &
+         &      ehur_b  (jpi,jpj)     , ehvr_b(jpi,jpj),                                  STAT=ierr(5) )                          
 #endif
          !
-      ALLOCATE( hu      (jpi,jpj) , hur     (jpi,jpj) , hu_0(jpi,jpj) , ht_0  (jpi,jpj) ,     &
-         &      hv      (jpi,jpj) , hvr     (jpi,jpj) , hv_0(jpi,jpj) , ht    (jpi,jpj) ,     &
-         &      re2u_e1u(jpi,jpj) , re1v_e2v(jpi,jpj) ,                                       &
-         &      e12t    (jpi,jpj) , r1_e12t (jpi,jpj) ,                                       &
-         &      e12u    (jpi,jpj) , r1_e12u (jpi,jpj) ,                                       &
-         &      e12v    (jpi,jpj) , r1_e12v (jpi,jpj) ,                                       &
-         &      e12f    (jpi,jpj) , r1_e12f (jpi,jpj) ,                                   STAT=ierr(6)  )
+      ALLOCATE( hu(jpi,jpj) , hur(jpi,jpj) , hu_0(jpi,jpj) , ht_0(jpi,jpj) ,     &
+         &      hv(jpi,jpj) , hvr(jpi,jpj) , hv_0(jpi,jpj) , ht  (jpi,jpj) , STAT=ierr(6)  )
          !
       ALLOCATE( gdept_1d(jpk) , gdepw_1d(jpk) ,                                     &
@@ -387,15 +382,15 @@
          &      scosrf(jpi,jpj) , scobot(jpi,jpj) ,     &
          &      hifv  (jpi,jpj) , hiff  (jpi,jpj) ,     &
-         &      hift  (jpi,jpj) , hifu  (jpi,jpj) , rx1 (jpi,jpj) , STAT=ierr(8) )
+         &      hift  (jpi,jpj) , hifu  (jpi,jpj) , rx1(jpi,jpj) , STAT=ierr(8) )
 
       ALLOCATE( mbathy(jpi,jpj) , bathy(jpi,jpj) ,                                      &
          &     tmask_i(jpi,jpj) , umask_i(jpi,jpj), vmask_i(jpi,jpj), fmask_i(jpi,jpj), &
-         &     bmask(jpi,jpj)   ,                                                       &
+         &     bmask  (jpi,jpj) ,                                                       &
          &     mbkt   (jpi,jpj) , mbku (jpi,jpj) , mbkv(jpi,jpj) , STAT=ierr(9) )
 
 ! (ISF) Allocation of basic array   
-      ALLOCATE( misfdep(jpi,jpj) , risfdep(jpi,jpj),     &
-         &     mikt(jpi,jpj), miku(jpi,jpj), mikv(jpi,jpj) ,           &
-         &     mikf(jpi,jpj), ssmask(jpi,jpj), STAT=ierr(10) )
+      ALLOCATE( misfdep(jpi,jpj) , risfdep(jpi,jpj),                   &
+         &      mikt(jpi,jpj), miku(jpi,jpj), mikv(jpi,jpj) ,           &
+         &      mikf(jpi,jpj), ssmask(jpi,jpj), STAT=ierr(10) )
 
       ALLOCATE( tmask(jpi,jpj,jpk) , umask(jpi,jpj,jpk),     & 
@@ -403,8 +398,4 @@
 
       ALLOCATE( wmask(jpi,jpj,jpk) , wumask(jpi,jpj,jpk), wvmask(jpi,jpj,jpk) , STAT=ierr(12) )
-
-#if defined key_noslip_accurate
-      ALLOCATE( npcoa(4,jpk), nicoa(2*(jpi+jpj),4,jpk), njcoa(2*(jpi+jpj),4,jpk), STAT=ierr(12) )
-#endif
       !
       dom_oce_alloc = MAXVAL(ierr)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domain.F90	(revision 6041)
@@ -19,4 +19,5 @@
    !!   dom_nam        : read and contral domain namelists
    !!   dom_ctl        : control print for the ocean domain
+   !!   dom_stiff      : diagnose maximum grid stiffness/hydrostatic consistency (s-coordinate)
    !!----------------------------------------------------------------------
    USE oce             ! ocean variables
@@ -25,7 +26,4 @@
    USE phycst          ! physical constants
    USE closea          ! closed seas
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! distributed memory computing library
-
    USE domhgr          ! domain: set the horizontal mesh
    USE domzgr          ! domain: set the vertical mesh
@@ -36,6 +34,9 @@
    USE c1d             ! 1D vertical configuration
    USE dyncor_c1d      ! Coriolis term (c1d case)         (cor_c1d routine)
+   !
+   USE in_out_manager  ! I/O manager
+   USE lib_mpp         ! distributed memory computing library
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
    USE timing          ! Timing
-   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
 
    IMPLICIT NONE
@@ -81,5 +82,5 @@
       ENDIF
       !
-                             CALL dom_nam      ! read namelist ( namrun, namdom, namcla )
+                             CALL dom_nam      ! read namelist ( namrun, namdom )
                              CALL dom_clo      ! Closed seas and lake
                              CALL dom_hgr      ! Horizontal mesh
@@ -88,7 +89,7 @@
       IF( ln_sco )           CALL dom_stiff    ! Maximum stiffness ratio/hydrostatic consistency
       !
-      ht_0(:,:) = 0.0_wp                       ! Reference ocean depth at T-points
-      hu_0(:,:) = 0.0_wp                       ! Reference ocean depth at U-points
-      hv_0(:,:) = 0.0_wp                       ! Reference ocean depth at V-points
+      ht_0(:,:) = 0._wp                        ! Reference ocean depth at T-points
+      hu_0(:,:) = 0._wp                        ! Reference ocean depth at U-points
+      hv_0(:,:) = 0._wp                        ! Reference ocean depth at V-points
       DO jk = 1, jpk
          ht_0(:,:) = ht_0(:,:) + e3t_0(:,:,jk) * tmask(:,:,jk)
@@ -97,5 +98,5 @@
       END DO
       !
-      IF( lk_vvl )           CALL dom_vvl_init ! Vertical variable mesh
+      IF( lk_vvl         )   CALL dom_vvl_init ! Vertical variable mesh
       !
       IF( lk_c1d         )   CALL cor_c1d      ! 1D configuration: Coriolis set at T-point
@@ -131,5 +132,4 @@
       !! ** input   : - namrun namelist
       !!              - namdom namelist
-      !!              - namcla namelist
       !!              - namnc4 namelist   ! "key_netcdf4" only
       !!----------------------------------------------------------------------
@@ -146,5 +146,4 @@
          &             ppsur, ppa0, ppa1, ppkth, ppacr, ppdzmin, pphmax, ldbletanh, &
          &             ppa2, ppkth2, ppacr2
-      NAMELIST/namcla/ nn_cla
 #if defined key_netcdf4
       NAMELIST/namnc4/ nn_nchunks_i, nn_nchunks_j, nn_nchunks_k, ln_nc4zip
@@ -155,9 +154,9 @@
       REWIND( numnam_ref )              ! Namelist namrun in reference namelist : Parameters of the run
       READ  ( numnam_ref, namrun, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namrun in reference namelist', lwp )
+901   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namrun in reference namelist', lwp )
 
       REWIND( numnam_cfg )              ! Namelist namrun in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, namrun, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namrun in configuration namelist', lwp )
+902   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namrun in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namrun )
       !
@@ -251,5 +250,5 @@
 904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdom in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namdom )
-
+      !
       IF(lwp) THEN
          WRITE(numout,*)
@@ -293,5 +292,5 @@
          WRITE(numout,*) '                                      ppacr2            = ', ppacr2
       ENDIF
-
+      !
       ntopo     = nn_bathy          ! conversion DOCTOR names into model names (this should disappear soon)
       e3zps_min = rn_e3zps_min
@@ -304,26 +303,4 @@
       rdtmax    = rn_rdtmin
       rdth      = rn_rdth
-
-      REWIND( numnam_ref )              ! Namelist namcla in reference namelist : Cross land advection
-      READ  ( numnam_ref, namcla, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcla in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namcla in configuration namelist : Cross land advection
-      READ  ( numnam_cfg, namcla, IOSTAT = ios, ERR = 906 )
-906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namcla in configuration namelist', lwp )
-      IF(lwm) WRITE( numond, namcla )
-
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '   Namelist namcla'
-         WRITE(numout,*) '      cross land advection                 nn_cla    = ', nn_cla
-      ENDIF
-      IF ( nn_cla .EQ. 1 ) THEN
-         IF  ( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA R2 
-            CONTINUE
-         ELSE
-            CALL ctl_stop( 'STOP', 'Cross land advation iplemented only for ORCA2 configuration: cp_cfg = "orca" and jp_cfg = 2 ' )
-         ENDIF
-      ENDIF
 
 #if defined key_netcdf4
@@ -409,4 +386,5 @@
    END SUBROUTINE dom_ctl
 
+
    SUBROUTINE dom_stiff
       !!----------------------------------------------------------------------
@@ -427,8 +405,8 @@
       REAL(wp), DIMENSION(4) :: zr1
       !!----------------------------------------------------------------------
-      rx1(:,:) = 0.e0
-      zrxmax   = 0.e0
-      zr1(:)   = 0.e0
-      
+      rx1(:,:) = 0._wp
+      zrxmax   = 0._wp
+      zr1(:)   = 0._wp
+      !
       DO ji = 2, jpim1
          DO jj = 2, jpjm1
@@ -455,11 +433,10 @@
          END DO
       END DO
-
       CALL lbc_lnk( rx1, 'T', 1. )
-
-      zrxmax = MAXVAL(rx1)
-
+      !
+      zrxmax = MAXVAL( rx1 )
+      !
       IF( lk_mpp )   CALL mpp_max( zrxmax ) ! max over the global domain
-
+      !
       IF(lwp) THEN
          WRITE(numout,*)
@@ -467,8 +444,6 @@
          WRITE(numout,*) '~~~~~~~~~'
       ENDIF
-
+      !
    END SUBROUTINE dom_stiff
-
-
 
    !!======================================================================
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domhgr.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domhgr.F90	(revision 6041)
@@ -14,5 +14,6 @@
    !!                            use of parameters in par_CONFIG-Rxx.h90, not in namelist
    !!             -   ! 2004-05  (A. Koch-Larrouy) Add Gyre configuration 
-   !!            4.0  ! 2011-02  (G. Madec) add cell surface (e1e2t)
+   !!            3.7  ! 2015-09  (G. Madec, S. Flavoni) add cell surface and their inverse
+   !!                                       add optional read of e1e2u & e1e2v
    !!----------------------------------------------------------------------
 
@@ -23,4 +24,6 @@
    USE dom_oce        ! ocean space and time domain
    USE phycst         ! physical constants
+   USE domwri         ! write 'meshmask.nc' & 'coordinate_e1e2u_v.nc' files
+   !
    USE in_out_manager ! I/O manager
    USE lib_mpp        ! MPP library
@@ -35,5 +38,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$ 
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -106,5 +109,5 @@
       REAL(wp) ::   zphi1, zsin_alpha, zim05, zjm05
       INTEGER  ::   isrow                ! index for ORCA1 starting row
-
+      INTEGER  ::   ie1e2u_v             ! fag for u- & v-surface read in coordinate file or not
       !!----------------------------------------------------------------------
       !
@@ -122,167 +125,35 @@
          WRITE(numout,*) '             meridional grid-spacing (meters)  ppe2_m   = ', ppe2_m  
       ENDIF
-
-
-      SELECT CASE( jphgr_msh )   ! type of horizontal mesh
-
-      CASE ( 0 )                     !  curvilinear coordinate on the sphere read in coordinate.nc file
-
+      !
+      !
+      SELECT CASE( jphgr_msh )   !  type of horizontal mesh  
+      !
+      CASE ( 0 )                     !==  read in coordinate.nc file  ==!
+         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          curvilinear coordinate on the sphere read in "coordinate" file'
-
-         CALL hgr_read           ! Defaultl option  :   NetCDF file
-
-         !                                                ! =====================
-         IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
-            !                                             ! =====================
-            IF( nn_cla == 0 ) THEN
-               !
-               ii0 = 139   ;   ii1 = 140        ! Gibraltar Strait (e2u = 20 km)
-               ij0 = 102   ;   ij1 = 102   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  20.e3
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) '             orca_r2: Gibraltar    : e2u reduced to 20 km'
-               !
-               ii0 = 160   ;   ii1 = 160        ! Bab el Mandeb (e2u = 18 km)
-               ij0 =  88   ;   ij1 =  88   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  18.e3
-                                               e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  30.e3
-               IF(lwp) WRITE(numout,*)
-               IF(lwp) WRITE(numout,*) '             orca_r2: Bab el Mandeb: e2u reduced to 30 km'
-               IF(lwp) WRITE(numout,*) '                                     e1v reduced to 18 km'
-            ENDIF
-
-            ii0 = 145   ;   ii1 = 146        ! Danish Straits (e2u = 10 km)
-            ij0 = 116   ;   ij1 = 116   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r2: Danish Straits : e2u reduced to 10 km'
-            !
+         !
+         ie1e2u_v = 0                  ! set to unread e1e2u and e1e2v
+         !
+         CALL hgr_read( ie1e2u_v )     ! read the coordinate.nc file
+         !
+         IF( ie1e2u_v == 0 ) THEN      ! e1e2u and e1e2v have not been read: compute them
+            !                          ! e2u and e1v does not include a reduction in some strait: apply reduction
+            e1e2u (:,:) = e1u(:,:) * e2u(:,:)   
+            e1e2v (:,:) = e1v(:,:) * e2v(:,:) 
          ENDIF
-
-            !                                             ! =====================
-         IF( cp_cfg == "orca" .AND. jp_cfg == 1 ) THEN    ! ORCA R1 configuration
-            !                                             ! =====================
-            ! This dirty section will be suppressed by simplification process: all this will come back in input files
-            ! Currently these hard-wired indices relate to configuration with
-            ! extend grid (jpjglo=332)
-            ! which had a grid-size of 362x292.
-            ! 
-            isrow = 332 - jpjglo
-            !
-            ii0 = 282           ;   ii1 = 283        ! Gibraltar Strait (e2u = 20 km)
-            ij0 = 241 - isrow   ;   ij1 = 241 - isrow   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  20.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: Gibraltar : e2u reduced to 20 km'
-
-            ii0 = 314           ;   ii1 = 315        ! Bhosporus Strait (e2u = 10 km)
-            ij0 = 248 - isrow   ;   ij1 = 248 - isrow   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: Bhosporus : e2u reduced to 10 km'
-
-            ii0 =  44           ;   ii1 =  44        ! Lombok Strait (e1v = 13 km)
-            ij0 = 164 - isrow   ;   ij1 = 165 - isrow   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  13.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: Lombok : e1v reduced to 10 km'
-
-            ii0 =  48           ;   ii1 =  48        ! Sumba Strait (e1v = 8 km) [closed from bathy_11 on]
-            ij0 = 164 - isrow   ;   ij1 = 165 - isrow   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  8.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: Sumba : e1v reduced to 8 km'
-
-            ii0 =  53           ;   ii1 =  53        ! Ombai Strait (e1v = 13 km)
-            ij0 = 164 - isrow   ;   ij1 = 165 - isrow   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 13.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: Ombai : e1v reduced to 13 km'
-
-            ii0 =  56           ;   ii1 =  56        ! Timor Passage (e1v = 20 km)
-            ij0 = 164 - isrow   ;   ij1 = 145 - isrow   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 20.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: Timor Passage : e1v reduced to 20 km'
-
-            ii0 =  55           ;   ii1 =  55        ! West Halmahera Strait (e1v = 30 km)
-            ij0 = 181 - isrow   ;   ij1 = 182 - isrow   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 30.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: W Halmahera : e1v reduced to 30 km'
-
-            ii0 =  58           ;   ii1 =  58        ! East Halmahera Strait (e1v = 50 km)
-            ij0 = 181 - isrow   ;   ij1 = 182 - isrow   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 50.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r1: E Halmahera : e1v reduced to 50 km'
-            !
-            !
-         ENDIF
-
-         !                                                ! ======================
-         IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN   ! ORCA R05 configuration
-            !                                             ! ======================
-            ii0 = 563   ;   ii1 = 564        ! Gibraltar Strait (e2u = 20 km)
-            ij0 = 327   ;   ij1 = 327   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  20.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Gibraltar Strait'
-            !
-            ii0 = 627   ;   ii1 = 628        ! Bosphore Strait (e2u = 10 km)
-            ij0 = 343   ;   ij1 = 343   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Bosphore Strait'
-            !
-            ii0 =  93   ;   ii1 =  94        ! Sumba Strait (e2u = 40 km)
-            ij0 = 232   ;   ij1 = 232   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  40.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Sumba Strait'
-            !
-            ii0 = 103   ;   ii1 = 103        ! Ombai Strait (e2u = 15 km)
-            ij0 = 232   ;   ij1 = 232   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  15.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Ombai Strait'
-            !
-            ii0 =  15   ;   ii1 =  15        ! Palk Strait (e2u = 10 km)
-            ij0 = 270   ;   ij1 = 270   ;   e2u( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e2u at the Palk Strait'
-            !
-            ii0 =  87   ;   ii1 =  87        ! Lombok Strait (e1v = 10 km)
-            ij0 = 232   ;   ij1 = 233   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  10.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e1v at the Lombok Strait'
-            !
-            !
-            ii0 = 662   ;   ii1 = 662        ! Bab el Mandeb (e1v = 25 km)
-            ij0 = 276   ;   ij1 = 276   ;   e1v( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) =  25.e3
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '             orca_r05: Reduced e1v at the Bab el Mandeb'
-            !
-         ENDIF
-
-
-         ! N.B. :  General case, lat and long function of both i and j indices:
-         !     e1t(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphit(ji,jj) ) * fsdila( zti, ztj ) )**2   &
-         !                                  + (                           fsdiph( zti, ztj ) )**2  )
-         !     e1u(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiu(ji,jj) ) * fsdila( zui, zuj ) )**2   &
-         !                                  + (                           fsdiph( zui, zuj ) )**2  )
-         !     e1v(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiv(ji,jj) ) * fsdila( zvi, zvj ) )**2   &
-         !                                  + (                           fsdiph( zvi, zvj ) )**2  )
-         !     e1f(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphif(ji,jj) ) * fsdila( zfi, zfj ) )**2   &
-         !                                  + (                           fsdiph( zfi, zfj ) )**2  )
-         !
-         !     e2t(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphit(ji,jj) ) * fsdjla( zti, ztj ) )**2   &
-         !                                  + (                           fsdjph( zti, ztj ) )**2  )
-         !     e2u(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiu(ji,jj) ) * fsdjla( zui, zuj ) )**2   &
-         !                                  + (                           fsdjph( zui, zuj ) )**2  )
-         !     e2v(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphiv(ji,jj) ) * fsdjla( zvi, zvj ) )**2   &
-         !                                  + (                           fsdjph( zvi, zvj ) )**2  )
-         !     e2f(ji,jj) = ra * rad * SQRT(  ( cos( rad*gphif(ji,jj) ) * fsdjla( zfi, zfj ) )**2   &
-         !                                  + (                           fsdjph( zfi, zfj ) )**2  )
-
-
-      CASE ( 1 )                     ! geographical mesh on the sphere with regular grid-spacing
-
+         !
+      CASE ( 1 )                     !==  geographical mesh on the sphere with regular (in degree) grid-spacing  ==!
+         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          geographical mesh on the sphere with regular grid-spacing'
          IF(lwp) WRITE(numout,*) '          given by ppe1_deg and ppe2_deg' 
-
+         !
          DO jj = 1, jpj
             DO ji = 1, jpi
-               zti = FLOAT( ji - 1 + nimpp - 1 )         ;   ztj = FLOAT( jj - 1 + njmpp - 1 )
-               zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = FLOAT( jj - 1 + njmpp - 1 )
-               zvi = FLOAT( ji - 1 + nimpp - 1 )         ;   zvj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
-               zfi = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = FLOAT( jj - 1 + njmpp - 1 ) + 0.5
+               zti = REAL( ji - 1 + nimpp - 1 )         ;   ztj = REAL( jj - 1 + njmpp - 1 )
+               zui = REAL( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = REAL( jj - 1 + njmpp - 1 )
+               zvi = REAL( ji - 1 + nimpp - 1 )         ;   zvj = REAL( jj - 1 + njmpp - 1 ) + 0.5
+               zfi = REAL( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = REAL( jj - 1 + njmpp - 1 ) + 0.5
          ! Longitude
                glamt(ji,jj) = ppglam0 + ppe1_deg * zti
@@ -307,17 +178,16 @@
             END DO
          END DO
-
-
-      CASE ( 2:3 )                   ! f- or beta-plane with regular grid-spacing
-
+         !
+      CASE ( 2:3 )                   !==  f- or beta-plane with regular grid-spacing  ==!
+         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          f- or beta-plane with regular grid-spacing'
          IF(lwp) WRITE(numout,*) '          given by ppe1_m and ppe2_m' 
-
+         !
          ! Position coordinates (in kilometers)
          !                          ==========
-         glam0 = 0.e0
+         glam0 = 0._wp
          gphi0 = - ppe2_m * 1.e-3
-         
+         !
 #if defined key_agrif 
          IF ( cp_cfg == 'eel' .AND. jp_cfg == 6 ) THEN    ! for EEL6 configuration only
@@ -332,16 +202,16 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               glamt(ji,jj) = glam0 + ppe1_m * 1.e-3 * ( FLOAT( ji - 1 + nimpp - 1 )       )
-               glamu(ji,jj) = glam0 + ppe1_m * 1.e-3 * ( FLOAT( ji - 1 + nimpp - 1 ) + 0.5 )
+               glamt(ji,jj) = glam0 + ppe1_m * 1.e-3 * ( REAL( ji - 1 + nimpp - 1 )       )
+               glamu(ji,jj) = glam0 + ppe1_m * 1.e-3 * ( REAL( ji - 1 + nimpp - 1 ) + 0.5 )
                glamv(ji,jj) = glamt(ji,jj)
                glamf(ji,jj) = glamu(ji,jj)
-   
-               gphit(ji,jj) = gphi0 + ppe2_m * 1.e-3 * ( FLOAT( jj - 1 + njmpp - 1 )       )
+               !
+               gphit(ji,jj) = gphi0 + ppe2_m * 1.e-3 * ( REAL( jj - 1 + njmpp - 1 )       )
                gphiu(ji,jj) = gphit(ji,jj)
-               gphiv(ji,jj) = gphi0 + ppe2_m * 1.e-3 * ( FLOAT( jj - 1 + njmpp - 1 ) + 0.5 )
+               gphiv(ji,jj) = gphi0 + ppe2_m * 1.e-3 * ( REAL( jj - 1 + njmpp - 1 ) + 0.5 )
                gphif(ji,jj) = gphiv(ji,jj)
             END DO
          END DO
-
+         !
          ! Horizontal scale factors (in meters)
          !                              ======
@@ -350,12 +220,12 @@
          e1v(:,:) = ppe1_m      ;      e2v(:,:) = ppe2_m
          e1f(:,:) = ppe1_m      ;      e2f(:,:) = ppe2_m
-
-      CASE ( 4 )                     ! geographical mesh on the sphere, isotropic MERCATOR type
-
+         !
+      CASE ( 4 )                     !==  geographical mesh on the sphere, isotropic MERCATOR type  ==!
+         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          geographical mesh on the sphere, MERCATOR type'
          IF(lwp) WRITE(numout,*) '          longitudinal/latitudinal spacing given by ppe1_deg'
          IF ( ppgphi0 == -90 ) CALL ctl_stop( ' Mercator grid cannot start at south pole !!!! ' )
-
+         !
          !  Find index corresponding to the equator, given the grid spacing e1_deg
          !  and the (approximate) southern latitude ppgphi0.
@@ -365,13 +235,13 @@
          ijeq = ABS( 180./rpi * LOG( COS( zarg ) / SIN( zarg ) ) / ppe1_deg )
          IF(  ppgphi0 > 0 )  ijeq = -ijeq
-
+         !
          IF(lwp) WRITE(numout,*) '          Index of the equator on the MERCATOR grid:', ijeq
-
+         !
          DO jj = 1, jpj
             DO ji = 1, jpi
-               zti = FLOAT( ji - 1 + nimpp - 1 )         ;   ztj = FLOAT( jj - ijeq + njmpp - 1 )
-               zui = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = FLOAT( jj - ijeq + njmpp - 1 )
-               zvi = FLOAT( ji - 1 + nimpp - 1 )         ;   zvj = FLOAT( jj - ijeq + njmpp - 1 ) + 0.5
-               zfi = FLOAT( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = FLOAT( jj - ijeq + njmpp - 1 ) + 0.5
+               zti = REAL( ji - 1 + nimpp - 1 )         ;   ztj = REAL( jj - ijeq + njmpp - 1 )
+               zui = REAL( ji - 1 + nimpp - 1 ) + 0.5   ;   zuj = REAL( jj - ijeq + njmpp - 1 )
+               zvi = REAL( ji - 1 + nimpp - 1 )         ;   zvj = REAL( jj - ijeq + njmpp - 1 ) + 0.5
+               zfi = REAL( ji - 1 + nimpp - 1 ) + 0.5   ;   zfj = REAL( jj - ijeq + njmpp - 1 ) + 0.5
          ! Longitude
                glamt(ji,jj) = ppglam0 + ppe1_deg * zti
@@ -396,53 +266,53 @@
             END DO
          END DO
-
-      CASE ( 5 )                   ! beta-plane with regular grid-spacing and rotated domain (GYRE configuration)
-
+         !
+      CASE ( 5 )                   !==  beta-plane with regular grid-spacing and rotated domain ==! (GYRE configuration)
+         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) '          beta-plane with regular grid-spacing and rotated domain (GYRE configuration)'
          IF(lwp) WRITE(numout,*) '          given by ppe1_m and ppe2_m'
-
+         !
          ! Position coordinates (in kilometers)
          !                          ==========
-
+         !
          ! angle 45deg and ze1=106.e+3 / jp_cfg forced -> zlam1 = -85deg, zphi1 = 29degN
-         zlam1 = -85
-         zphi1 = 29
+         zlam1 = -85._wp
+         zphi1 =  29._wp
          ! resolution in meters
-         ze1 = 106000. / FLOAT(jp_cfg)            
+         ze1 = 106000. / REAL( jp_cfg , wp )            
          ! benchmark: forced the resolution to be about 100 km
-         IF( nbench /= 0 )   ze1 = 106000.e0     
-         zsin_alpha = - SQRT( 2. ) / 2.
-         zcos_alpha =   SQRT( 2. ) / 2.
+         IF( nbench /= 0 )   ze1 = 106000._wp     
+         zsin_alpha = - SQRT( 2._wp ) * 0.5_wp
+         zcos_alpha =   SQRT( 2._wp ) * 0.5_wp
          ze1deg = ze1 / (ra * rad)
-         IF( nbench /= 0 )   ze1deg = ze1deg / FLOAT(jp_cfg)        ! benchmark: keep the lat/+lon
-         !                                                          ! at the right jp_cfg resolution
-         glam0 = zlam1 + zcos_alpha * ze1deg * FLOAT( jpjglo-2 )
-         gphi0 = zphi1 + zsin_alpha * ze1deg * FLOAT( jpjglo-2 )
-
+         IF( nbench /= 0 )   ze1deg = ze1deg / REAL( jp_cfg , wp )   ! benchmark: keep the lat/+lon
+         !                                                           ! at the right jp_cfg resolution
+         glam0 = zlam1 + zcos_alpha * ze1deg * REAL( jpjglo-2 , wp )
+         gphi0 = zphi1 + zsin_alpha * ze1deg * REAL( jpjglo-2 , wp )
+         !
          IF( nprint==1 .AND. lwp )   THEN
             WRITE(numout,*) '          ze1', ze1, 'cosalpha', zcos_alpha, 'sinalpha', zsin_alpha
             WRITE(numout,*) '          ze1deg', ze1deg, 'glam0', glam0, 'gphi0', gphi0
          ENDIF
-
+         !
          DO jj = 1, jpj
-           DO ji = 1, jpi
-             zim1 = FLOAT( ji + nimpp - 1 ) - 1.   ;   zim05 = FLOAT( ji + nimpp - 1 ) - 1.5
-             zjm1 = FLOAT( jj + njmpp - 1 ) - 1.   ;   zjm05 = FLOAT( jj + njmpp - 1 ) - 1.5
-
-             glamf(ji,jj) = glam0 + zim1  * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
-             gphif(ji,jj) = gphi0 - zim1  * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
-
-             glamt(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
-             gphit(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
-
-             glamu(ji,jj) = glam0 + zim1  * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
-             gphiu(ji,jj) = gphi0 - zim1  * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
-
-             glamv(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
-             gphiv(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
-           END DO
-          END DO
-
+            DO ji = 1, jpi
+               zim1 = REAL( ji + nimpp - 1 ) - 1.   ;   zim05 = REAL( ji + nimpp - 1 ) - 1.5
+               zjm1 = REAL( jj + njmpp - 1 ) - 1.   ;   zjm05 = REAL( jj + njmpp - 1 ) - 1.5
+               !
+               glamf(ji,jj) = glam0 + zim1  * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
+               gphif(ji,jj) = gphi0 - zim1  * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
+               !
+               glamt(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
+               gphit(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
+               !
+               glamu(ji,jj) = glam0 + zim1  * ze1deg * zcos_alpha + zjm05 * ze1deg * zsin_alpha
+               gphiu(ji,jj) = gphi0 - zim1  * ze1deg * zsin_alpha + zjm05 * ze1deg * zcos_alpha
+               !
+               glamv(ji,jj) = glam0 + zim05 * ze1deg * zcos_alpha + zjm1  * ze1deg * zsin_alpha
+               gphiv(ji,jj) = gphi0 - zim05 * ze1deg * zsin_alpha + zjm1  * ze1deg * zcos_alpha
+            END DO
+         END DO
+         !
          ! Horizontal scale factors (in meters)
          !                              ======
@@ -451,40 +321,32 @@
          e1v(:,:) =  ze1     ;      e2v(:,:) = ze1
          e1f(:,:) =  ze1     ;      e2f(:,:) = ze1
-
+         !
       CASE DEFAULT
          WRITE(ctmp1,*) '          bad flag value for jphgr_msh = ', jphgr_msh
          CALL ctl_stop( ctmp1 )
-
+         !
       END SELECT
       
-      ! T-cell surface
-      ! --------------
-      e1e2t(:,:) = e1t(:,:) * e2t(:,:)
-    
-      ! Useful shortcuts (JC: note the duplicated e2e2t array ! Need some cleaning)
-      ! ---------------------------------------------------------------------------
-      e12t    (:,:) = e1t(:,:) * e2t(:,:)
-      e12u    (:,:) = e1u(:,:) * e2u(:,:)
-      e12v    (:,:) = e1v(:,:) * e2v(:,:)
-      e12f    (:,:) = e1f(:,:) * e2f(:,:)
-      r1_e12t (:,:) = 1._wp    / e12t(:,:)
-      r1_e12u (:,:) = 1._wp    / e12u(:,:)
-      r1_e12v (:,:) = 1._wp    / e12v(:,:)
-      r1_e12f (:,:) = 1._wp    / e12f(:,:)
-      re2u_e1u(:,:) = e2u(:,:) / e1u(:,:)
-      re1v_e2v(:,:) = e1v(:,:) / e2v(:,:)
-      r1_e1t  (:,:) = 1._wp    / e1t(:,:)
-      r1_e1u  (:,:) = 1._wp    / e1u(:,:)
-      r1_e1v  (:,:) = 1._wp    / e1v(:,:)
-      r1_e1f  (:,:) = 1._wp    / e1f(:,:)
-      r1_e2t  (:,:) = 1._wp    / e2t(:,:)
-      r1_e2u  (:,:) = 1._wp    / e2u(:,:)
-      r1_e2v  (:,:) = 1._wp    / e2v(:,:)
-      r1_e2f  (:,:) = 1._wp    / e2f(:,:)
-
-      ! Control printing : Grid informations (if not restart)
-      ! ----------------
-
-      IF( lwp .AND. .NOT.ln_rstart ) THEN
+      ! associated horizontal metrics
+      ! -----------------------------
+      !
+      r1_e1t(:,:) = 1._wp / e1t(:,:)   ;   r1_e2t (:,:) = 1._wp / e2t(:,:)
+      r1_e1u(:,:) = 1._wp / e1u(:,:)   ;   r1_e2u (:,:) = 1._wp / e2u(:,:)
+      r1_e1v(:,:) = 1._wp / e1v(:,:)   ;   r1_e2v (:,:) = 1._wp / e2v(:,:)
+      r1_e1f(:,:) = 1._wp / e1f(:,:)   ;   r1_e2f (:,:) = 1._wp / e2f(:,:)
+      !
+      e1e2t (:,:) = e1t(:,:) * e2t(:,:)   ;   r1_e1e2t(:,:) = 1._wp / e1e2t(:,:)
+      e1e2f (:,:) = e1f(:,:) * e2f(:,:)   ;   r1_e1e2f(:,:) = 1._wp / e1e2f(:,:)
+      IF( jphgr_msh /= 0 ) THEN               ! e1e2u and e1e2v have not been set: compute them
+         e1e2u (:,:) = e1u(:,:) * e2u(:,:)   
+         e1e2v (:,:) = e1v(:,:) * e2v(:,:) 
+      ENDIF
+      r1_e1e2u(:,:) = 1._wp / e1e2u(:,:)     ! compute their invert in both cases
+      r1_e1e2v(:,:) = 1._wp / e1e2v(:,:)
+      !   
+      e2_e1u(:,:) = e2u(:,:) / e1u(:,:)
+      e1_e2v(:,:) = e1v(:,:) / e2v(:,:)
+
+      IF( lwp .AND. .NOT.ln_rstart ) THEN      ! Control print : Grid informations (if not restart)
          WRITE(numout,*)
          WRITE(numout,*) '          longitude and e1 scale factors'
@@ -496,5 +358,5 @@
 9300     FORMAT( 1x, i4, f8.2,1x, f8.2,1x, f8.2,1x, f8.2, 1x,    &
             f19.10, 1x, f19.10, 1x, f19.10, 1x, f19.10 )
-         
+            !
          WRITE(numout,*)
          WRITE(numout,*) '          latitude and e2 scale factors'
@@ -506,17 +368,4 @@
       ENDIF
 
-      
-      IF( nprint == 1 .AND. lwp ) THEN
-         WRITE(numout,*) '          e1u e2u '
-         CALL prihre( e1u,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
-         CALL prihre( e2u,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
-         WRITE(numout,*) '          e1v e2v  '
-         CALL prihre( e1v,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
-         CALL prihre( e2v,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
-         WRITE(numout,*) '          e1f e2f  '
-         CALL prihre( e1f,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
-         CALL prihre( e2f,jpi,jpj,jpi-5,jpi,1,jpj-5,jpj,1,0.,numout )
-      ENDIF
-
 
       ! ================= !
@@ -525,32 +374,31 @@
 
       SELECT CASE( jphgr_msh )   ! type of horizontal mesh
-
+      !
       CASE ( 0, 1, 4 )               ! mesh on the sphere
-
+         !
          ff(:,:) = 2. * omega * SIN( rad * gphif(:,:) ) 
-
+         !
       CASE ( 2 )                     ! f-plane at ppgphi0 
-
+         !
          ff(:,:) = 2. * omega * SIN( rad * ppgphi0 )
-
+         !
          IF(lwp) WRITE(numout,*) '          f-plane: Coriolis parameter = constant = ', ff(1,1)
-
+         !
       CASE ( 3 )                     ! beta-plane
-
+         !
          zbeta   = 2. * omega * COS( rad * ppgphi0 ) / ra                       ! beta at latitude ppgphi0
-         zphi0   = ppgphi0 - FLOAT( jpjglo/2) * ppe2_m / ( ra * rad )           ! latitude of the first row F-points
-         
+         zphi0   = ppgphi0 - REAL( jpjglo/2) * ppe2_m / ( ra * rad )           ! latitude of the first row F-points
+         !
 #if defined key_agrif
          IF ( cp_cfg == 'eel' .AND. jp_cfg == 6 ) THEN    ! for EEL6 configuration only
             IF( .NOT. Agrif_Root() ) THEN
-              zphi0 = ppgphi0 - FLOAT( Agrif_Parent(jpjglo)/2)*Agrif_Parent(ppe2_m)   & 
-                    &           / (ra * rad)
+              zphi0 = ppgphi0 - REAL( Agrif_Parent(jpjglo)/2)*Agrif_Parent(ppe2_m) / (ra * rad)
             ENDIF
          ENDIF
 #endif         
          zf0     = 2. * omega * SIN( rad * zphi0 )                              ! compute f0 1st point south
-
+         !
          ff(:,:) = ( zf0  + zbeta * gphif(:,:) * 1.e+3 )                        ! f = f0 +beta* y ( y=0 at south)
-         
+         !
          IF(lwp) THEN
             WRITE(numout,*) 
@@ -565,13 +413,13 @@
             IF(lwp) WRITE(numout,*) '          Coriolis parameter varies globally from ', zminff,' to ', zmaxff
          END IF
-
+         !
       CASE ( 5 )                     ! beta-plane and rotated domain (gyre configuration)
-
+         !
          zbeta = 2. * omega * COS( rad * ppgphi0 ) / ra                     ! beta at latitude ppgphi0
-         zphi0 = 15.e0                                                      ! latitude of the first row F-points
+         zphi0 = 15._wp                                                     ! latitude of the first row F-points
          zf0   = 2. * omega * SIN( rad * zphi0 )                            ! compute f0 1st point south
-
+         !
          ff(:,:) = ( zf0 + zbeta * ABS( gphif(:,:) - zphi0 ) * rad * ra )   ! f = f0 +beta* y ( y=0 at south)
-
+         !
          IF(lwp) THEN
             WRITE(numout,*) 
@@ -579,5 +427,5 @@
             WRITE(numout,*) '          Coriolis parameter varies in this processor from ', ff(nldi,nldj),' to ', ff(nldi,nlej)
          ENDIF
-
+         !
          IF( lk_mpp ) THEN 
             zminff=ff(nldi,nldj)
@@ -587,5 +435,5 @@
             IF(lwp) WRITE(numout,*) '          Coriolis parameter varies globally from ', zminff,' to ', zmaxff
          END IF
-
+         !
       END SELECT
 
@@ -596,5 +444,5 @@
 
       IF( nperio == 2 ) THEN
-         znorme = SQRT( SUM( gphiu(:,2) * gphiu(:,2) ) ) / FLOAT( jpi )
+         znorme = SQRT( SUM( gphiu(:,2) * gphiu(:,2) ) ) / REAL( jpi )
          IF( znorme > 1.e-13 ) CALL ctl_stop( ' ===>>>> : symmetrical condition: rerun with good equator line' )
       ENDIF
@@ -605,19 +453,18 @@
 
 
-   SUBROUTINE hgr_read
+   SUBROUTINE hgr_read( ke1e2u_v )
       !!---------------------------------------------------------------------
       !!              ***  ROUTINE hgr_read  ***
       !!
-      !! ** Purpose :   Read a coordinate file in NetCDF format 
-      !!
-      !! ** Method  :   The mesh file has been defined trough a analytical 
-      !!      or semi-analytical method. It is read in a NetCDF file. 
-      !!     
+      !! ** Purpose :   Read a coordinate file in NetCDF format using IOM
+      !!
       !!----------------------------------------------------------------------
       USE iom
-
+      !!
+      INTEGER, INTENT( inout ) ::   ke1e2u_v   ! fag: e1e2u & e1e2v read in coordinate file (=1) or not (=0)
+      !
       INTEGER ::   inum   ! temporary logical unit
       !!----------------------------------------------------------------------
-
+      !
       IF(lwp) THEN
          WRITE(numout,*)
@@ -625,29 +472,40 @@
          WRITE(numout,*) '~~~~~~~~      jpiglo = ', jpiglo, ' jpjglo = ', jpjglo, ' jpk = ', jpk
       ENDIF
-      
+      !
       CALL iom_open( 'coordinates', inum )
-      
+      !
       CALL iom_get( inum, jpdom_data, 'glamt', glamt, lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'glamu', glamu, lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'glamv', glamv, lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'glamf', glamf, lrowattr=ln_use_jattr )
-      
+      !
       CALL iom_get( inum, jpdom_data, 'gphit', gphit, lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'gphiu', gphiu, lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'gphiv', gphiv, lrowattr=ln_use_jattr )
       CALL iom_get( inum, jpdom_data, 'gphif', gphif, lrowattr=ln_use_jattr )
-      
-      CALL iom_get( inum, jpdom_data, 'e1t', e1t, lrowattr=ln_use_jattr )
-      CALL iom_get( inum, jpdom_data, 'e1u', e1u, lrowattr=ln_use_jattr )
-      CALL iom_get( inum, jpdom_data, 'e1v', e1v, lrowattr=ln_use_jattr )
-      CALL iom_get( inum, jpdom_data, 'e1f', e1f, lrowattr=ln_use_jattr )
-      
-      CALL iom_get( inum, jpdom_data, 'e2t', e2t, lrowattr=ln_use_jattr )
-      CALL iom_get( inum, jpdom_data, 'e2u', e2u, lrowattr=ln_use_jattr )
-      CALL iom_get( inum, jpdom_data, 'e2v', e2v, lrowattr=ln_use_jattr )
-      CALL iom_get( inum, jpdom_data, 'e2f', e2f, lrowattr=ln_use_jattr )
-      
+      !
+      CALL iom_get( inum, jpdom_data, 'e1t'  , e1t  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e1u'  , e1u  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e1v'  , e1v  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e1f'  , e1f  , lrowattr=ln_use_jattr )
+      !
+      CALL iom_get( inum, jpdom_data, 'e2t'  , e2t  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e2u'  , e2u  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e2v'  , e2v  , lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e2f'  , e2f  , lrowattr=ln_use_jattr )
+      !
+      IF( iom_varid( inum, 'e1e2u', ldstop = .FALSE. ) > 0 ) THEN
+         IF(lwp) WRITE(numout,*) 'hgr_read : e1e2u & e1e2v read in coordinates file'
+         CALL iom_get( inum, jpdom_data, 'e1e2u'  , e1e2u  , lrowattr=ln_use_jattr )
+         CALL iom_get( inum, jpdom_data, 'e1e2v'  , e1e2v  , lrowattr=ln_use_jattr )
+         ke1e2u_v = 1
+      ELSE
+         ke1e2u_v = 0
+      ENDIF
+      !
       CALL iom_close( inum )
       
+!!gm   THIS is TO BE REMOVED !!!!!!!
+
 ! need to be define for the extended grid south of -80S
 ! some point are undefined but you need to have e1 and e2 .NE. 0
@@ -676,4 +534,5 @@
          e2f=1.0e2
       END WHERE
+!!gm end
        
     END SUBROUTINE hgr_read
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dommsk.F90	(revision 6041)
@@ -17,9 +17,9 @@
    !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
    !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
+   !!            3.6  ! 2015-05  (P. Mathiot) ISF: add wmask,wumask and wvmask
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
    !!   dom_msk        : compute land/ocean mask
-   !!   dom_msk_nsa    : update land/ocean mask when no-slip accurate option is used.
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers
@@ -28,5 +28,4 @@
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp
-   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
    USE wrk_nemo        ! Memory allocation
    USE timing          ! Timing
@@ -36,5 +35,4 @@
 
    PUBLIC   dom_msk         ! routine called by inidom.F90
-   PUBLIC   dom_msk_alloc   ! routine called by nemogcm.F90
 
    !                            !!* Namelist namlbc : lateral boundary condition *
@@ -42,7 +40,4 @@
    LOGICAL, PUBLIC :: ln_vorlat  !  consistency of vorticity boundary condition 
    !                                            with analytical eqs.
-
-
-   INTEGER, ALLOCATABLE, SAVE, DIMENSION(:,:) ::  icoord ! Workspace for dom_msk_nsa()
 
    !! * Substitutions
@@ -54,17 +49,4 @@
    !!----------------------------------------------------------------------
 CONTAINS
-   
-   INTEGER FUNCTION dom_msk_alloc()
-      !!---------------------------------------------------------------------
-      !!                 ***  FUNCTION dom_msk_alloc  ***
-      !!---------------------------------------------------------------------
-      dom_msk_alloc = 0
-#if defined key_noslip_accurate
-      ALLOCATE(icoord(jpi*jpj*jpk,3), STAT=dom_msk_alloc)
-#endif
-      IF( dom_msk_alloc /= 0 )   CALL ctl_warn('dom_msk_alloc: failed to allocate icoord array')
-      !
-   END FUNCTION dom_msk_alloc
-
 
    SUBROUTINE dom_msk
@@ -129,6 +111,5 @@
       !!               tmask_i  : interior ocean mask
       !!----------------------------------------------------------------------
-      !
-      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      INTEGER  ::   ji, jj, jk               ! dummy loop indices
       INTEGER  ::   iif, iil, ii0, ii1, ii   ! local integers
       INTEGER  ::   ijf, ijl, ij0, ij1       !   -       -
@@ -199,24 +180,4 @@
       END DO  
 
-!!gm  ????
-#if defined key_zdfkpp
-      IF( cp_cfg == 'orca' ) THEN
-         IF( jp_cfg == 2 )   THEN       ! land point on Bab el Mandeb zonal section
-            ij0 =  87   ;   ij1 =  88
-            ii0 = 160   ;   ii1 = 161
-            tmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) = 0._wp
-         ELSE
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,cform_war)
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*)'          A mask must be applied on Bab el Mandeb strait'
-            IF(lwp) WRITE(numout,*)'          in case of ORCAs configurations'
-            IF(lwp) WRITE(numout,*)'          This is a problem which is not yet solved'
-            IF(lwp) WRITE(numout,*)
-         ENDIF
-      ENDIF
-#endif
-!!gm end
-
       ! Interior domain mask (used for global sum)
       ! --------------------
@@ -284,11 +245,11 @@
       ! 3. Ocean/land mask at wu-, wv- and w points 
       !----------------------------------------------
-      wmask (:,:,1) = tmask(:,:,1) ! ????????
-      wumask(:,:,1) = umask(:,:,1) ! ????????
-      wvmask(:,:,1) = vmask(:,:,1) ! ????????
-      DO jk=2,jpk
-         wmask (:,:,jk)=tmask(:,:,jk) * tmask(:,:,jk-1)
-         wumask(:,:,jk)=umask(:,:,jk) * umask(:,:,jk-1)   
-         wvmask(:,:,jk)=vmask(:,:,jk) * vmask(:,:,jk-1)
+      wmask (:,:,1) = tmask(:,:,1)     ! surface
+      wumask(:,:,1) = umask(:,:,1)
+      wvmask(:,:,1) = vmask(:,:,1)
+      DO jk = 2, jpk                   ! interior values
+         wmask (:,:,jk) = tmask(:,:,jk) * tmask(:,:,jk-1)
+         wumask(:,:,jk) = umask(:,:,jk) * umask(:,:,jk-1)   
+         wvmask(:,:,jk) = vmask(:,:,jk) * vmask(:,:,jk-1)
       END DO
 
@@ -339,10 +300,4 @@
       ENDIF
 
-
-      ! mask for second order calculation of vorticity
-      ! ----------------------------------------------
-      CALL dom_msk_nsa
-
-      
       ! Lateral boundary conditions on velocity (modify fmask)
       ! ---------------------------------------     
@@ -377,18 +332,16 @@
       IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA_R2 configuration
          !                                                 ! Increased lateral friction near of some straits
-         IF( nn_cla == 0 ) THEN
-            !                                ! Gibraltar strait  : partial slip (fmask=0.5)
-            ij0 = 101   ;   ij1 = 101
-            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
-            ij0 = 102   ;   ij1 = 102
-            ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
-            !
-            !                                ! Bab el Mandeb : partial slip (fmask=1)
-            ij0 =  87   ;   ij1 =  88
-            ii0 = 160   ;   ii1 = 160   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
-            ij0 =  88   ;   ij1 =  88
-            ii0 = 159   ;   ii1 = 159   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
-            !
-         ENDIF
+         !                                ! Gibraltar strait  : partial slip (fmask=0.5)
+         ij0 = 101   ;   ij1 = 101
+         ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
+         ij0 = 102   ;   ij1 = 102
+         ii0 = 139   ;   ii1 = 140   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  0.5_wp
+         !
+         !                                ! Bab el Mandeb : partial slip (fmask=1)
+         ij0 =  87   ;   ij1 =  88
+         ii0 = 160   ;   ii1 = 160   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
+         ij0 =  88   ;   ij1 =  88
+         ii0 = 159   ;   ii1 = 159   ;   fmask( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 1:jpk ) =  1._wp
+         !
          !                                ! Danish straits  : strong slip (fmask > 2)
 ! We keep this as an example but it is instable in this case 
@@ -500,197 +453,4 @@
       !
    END SUBROUTINE dom_msk
-
-#if defined key_noslip_accurate
-   !!----------------------------------------------------------------------
-   !!   'key_noslip_accurate' :         accurate no-slip boundary condition
-   !!----------------------------------------------------------------------
-   
-   SUBROUTINE dom_msk_nsa
-      !!---------------------------------------------------------------------
-      !!                 ***  ROUTINE dom_msk_nsa  ***
-      !! 
-      !! ** Purpose :
-      !!
-      !! ** Method  :
-      !!
-      !! ** Action :
-      !!----------------------------------------------------------------------
-      INTEGER  ::   ji, jj, jk, jl      ! dummy loop indices
-      INTEGER  ::   ine, inw, ins, inn, itest, ierror, iind, ijnd
-      REAL(wp) ::   zaa
-      !!---------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dom_msk_nsa')
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'dom_msk_nsa : noslip accurate boundary condition'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   using Schchepetkin and O Brian scheme'
-      IF( lk_mpp )   CALL ctl_stop( ' mpp version is not yet implemented' )
-
-      ! mask for second order calculation of vorticity
-      ! ----------------------------------------------
-      ! noslip boundary condition: fmask=1  at convex corner, store
-      ! index of straight coast meshes ( 'west', refering to a coast,
-      ! means west of the ocean, aso)
-      
-      DO jk = 1, jpk
-         DO jl = 1, 4
-            npcoa(jl,jk) = 0
-            DO ji = 1, 2*(jpi+jpj)
-               nicoa(ji,jl,jk) = 0
-               njcoa(ji,jl,jk) = 0
-            END DO
-         END DO
-      END DO
-      
-      IF( jperio == 2 ) THEN
-         WRITE(numout,*) ' '
-         WRITE(numout,*) ' symetric boundary conditions need special'
-         WRITE(numout,*) ' treatment not implemented. we stop.'
-         STOP
-      ENDIF
-      
-      ! convex corners
-      
-      DO jk = 1, jpkm1
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               zaa = tmask(ji  ,jj,jk) + tmask(ji  ,jj+1,jk)   &
-                  &+ tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk)
-               IF( ABS(zaa-3._wp) <= 0.1_wp )   fmask(ji,jj,jk) = 1._wp
-            END DO
-         END DO
-      END DO
-
-      ! north-south straight coast
-
-      DO jk = 1, jpkm1
-         inw = 0
-         ine = 0
-         DO jj = 2, jpjm1
-            DO ji = 2, jpim1
-               zaa = tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk)
-               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
-                  inw = inw + 1
-                  nicoa(inw,1,jk) = ji
-                  njcoa(inw,1,jk) = jj
-                  IF( nprint == 1 ) WRITE(numout,*) ' west  : ', jk, inw, ji, jj
-               ENDIF
-               zaa = tmask(ji,jj,jk) + tmask(ji,jj+1,jk)
-               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
-                  ine = ine + 1
-                  nicoa(ine,2,jk) = ji
-                  njcoa(ine,2,jk) = jj
-                  IF( nprint == 1 ) WRITE(numout,*) ' east  : ', jk, ine, ji, jj
-               ENDIF
-            END DO
-         END DO
-         npcoa(1,jk) = inw
-         npcoa(2,jk) = ine
-      END DO
-
-      ! west-east straight coast
-
-      DO jk = 1, jpkm1
-         ins = 0
-         inn = 0
-         DO jj = 2, jpjm1
-            DO ji =2, jpim1
-               zaa = tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk)
-               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
-                  ins = ins + 1
-                  nicoa(ins,3,jk) = ji
-                  njcoa(ins,3,jk) = jj
-                  IF( nprint == 1 ) WRITE(numout,*) ' south : ', jk, ins, ji, jj
-               ENDIF
-               zaa = tmask(ji+1,jj,jk) + tmask(ji,jj,jk)
-               IF( ABS(zaa-2._wp) <= 0.1_wp .AND. fmask(ji,jj,jk) == 0._wp ) THEN
-                  inn = inn + 1
-                  nicoa(inn,4,jk) = ji
-                  njcoa(inn,4,jk) = jj
-                  IF( nprint == 1 ) WRITE(numout,*) ' north : ', jk, inn, ji, jj
-               ENDIF
-            END DO
-         END DO
-         npcoa(3,jk) = ins
-         npcoa(4,jk) = inn
-      END DO
-
-      itest = 2 * ( jpi + jpj )
-      DO jk = 1, jpk
-         IF( npcoa(1,jk) > itest .OR. npcoa(2,jk) > itest .OR.   &
-             npcoa(3,jk) > itest .OR. npcoa(4,jk) > itest ) THEN
-            
-            WRITE(ctmp1,*) ' level jk = ',jk
-            WRITE(ctmp2,*) ' straight coast index arraies are too small.:'
-            WRITE(ctmp3,*) ' npe, npw, nps, npn = ', npcoa(1,jk), npcoa(2,jk),   &
-                &                                     npcoa(3,jk), npcoa(4,jk)
-            WRITE(ctmp4,*) ' 2*(jpi+jpj) = ',itest,'. we stop.'
-            CALL ctl_stop( ctmp1, ctmp2, ctmp3, ctmp4 )
-        ENDIF
-      END DO
-
-      ierror = 0
-      iind = 0
-      ijnd = 0
-      IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6 )   iind = 2
-      IF( nperio == 3 .OR. nperio == 4 .OR. nperio == 5 .OR. nperio == 6 )   ijnd = 2
-      DO jk = 1, jpk
-         DO jl = 1, npcoa(1,jk)
-            IF( nicoa(jl,1,jk)+3 > jpi+iind ) THEN
-               ierror = ierror+1
-               icoord(ierror,1) = nicoa(jl,1,jk)
-               icoord(ierror,2) = njcoa(jl,1,jk)
-               icoord(ierror,3) = jk
-            ENDIF
-         END DO
-         DO jl = 1, npcoa(2,jk)
-            IF(nicoa(jl,2,jk)-2 < 1-iind ) THEN
-               ierror = ierror + 1
-               icoord(ierror,1) = nicoa(jl,2,jk)
-               icoord(ierror,2) = njcoa(jl,2,jk)
-               icoord(ierror,3) = jk
-            ENDIF
-         END DO
-         DO jl = 1, npcoa(3,jk)
-            IF( njcoa(jl,3,jk)+3 > jpj+ijnd ) THEN
-               ierror = ierror + 1
-               icoord(ierror,1) = nicoa(jl,3,jk)
-               icoord(ierror,2) = njcoa(jl,3,jk)
-               icoord(ierror,3) = jk
-            ENDIF
-         END DO
-         DO jl = 1, npcoa(4,jk)
-            IF( njcoa(jl,4,jk)-2 < 1) THEN
-               ierror=ierror + 1
-               icoord(ierror,1) = nicoa(jl,4,jk)
-               icoord(ierror,2) = njcoa(jl,4,jk)
-               icoord(ierror,3) = jk
-            ENDIF
-         END DO
-      END DO
-      
-      IF( ierror > 0 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '              Problem on lateral conditions'
-         IF(lwp) WRITE(numout,*) '                 Bad marking off at points:'
-         DO jl = 1, ierror
-            IF(lwp) WRITE(numout,*) 'Level:',icoord(jl,3),   &
-               &                  '  Point(',icoord(jl,1),',',icoord(jl,2),')'
-         END DO
-         CALL ctl_stop( 'We stop...' )
-      ENDIF
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('dom_msk_nsa')
-      !
-   END SUBROUTINE dom_msk_nsa
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option :                                      Empty routine
-   !!----------------------------------------------------------------------
-   SUBROUTINE dom_msk_nsa       
-   END SUBROUTINE dom_msk_nsa
-#endif
    
    !!======================================================================
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domngb.F90	(revision 6041)
@@ -37,5 +37,4 @@
       !!                -> not good if located at too high latitude...
       !!----------------------------------------------------------------------
-      !
       REAL(wp)        , INTENT(in   ) ::   plon, plat   ! longitude,latitude of the point
       INTEGER         , INTENT(  out) ::   kii, kjj     ! i-,j-index of the closes grid point
@@ -49,5 +48,5 @@
       IF( nn_timing == 1 )  CALL timing_start('dom_ngb')
       !
-      CALL wrk_alloc( jpi, jpj, zglam, zgphi, zmask, zdist )
+      CALL wrk_alloc( jpi,jpj,   zglam, zgphi, zmask, zdist )
       !
       zmask(:,:) = 0._wp
@@ -76,5 +75,5 @@
       ENDIF
       !
-      CALL wrk_dealloc( jpi, jpj, zglam, zgphi, zmask, zdist )
+      CALL wrk_dealloc( jpi,jpj,   zglam, zgphi, zmask, zdist )
       !
       IF( nn_timing == 1 )  CALL timing_stop('dom_ngb')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 6041)
@@ -10,6 +10,5 @@
    !!            3.6  !  2014-11  (P. Mathiot) add ice shelf capability
    !!----------------------------------------------------------------------
-   !!   'key_vvl'                              variable volume
-   !!----------------------------------------------------------------------
+
    !!----------------------------------------------------------------------
    !!   dom_vvl_init     : define initial vertical scale factors, depths and column thickness
@@ -19,8 +18,5 @@
    !!   dom_vvl_rst      : read/write restart file
    !!   dom_vvl_ctl      : Check the vvl options
-   !!   dom_vvl_orca_fix : Recompute some area-weighted interpolations of vertical scale factors 
-   !!                    : to account for manual changes to e[1,2][u,v] in some Straits 
    !!----------------------------------------------------------------------
-   !! * Modules used
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
@@ -37,32 +33,29 @@
    PRIVATE
 
-   !! * Routine accessibility
    PUBLIC  dom_vvl_init       ! called by domain.F90
    PUBLIC  dom_vvl_sf_nxt     ! called by step.F90
    PUBLIC  dom_vvl_sf_swp     ! called by step.F90
    PUBLIC  dom_vvl_interpol   ! called by dynnxt.F90
-   PRIVATE dom_vvl_orca_fix   ! called by dom_vvl_interpol
-
-   !!* Namelist nam_vvl
-   LOGICAL , PUBLIC                                      :: ln_vvl_zstar = .FALSE.              ! zstar  vertical coordinate
-   LOGICAL , PUBLIC                                      :: ln_vvl_ztilde = .FALSE.             ! ztilde vertical coordinate
-   LOGICAL , PUBLIC                                      :: ln_vvl_layer = .FALSE.              ! level  vertical coordinate
-   LOGICAL , PUBLIC                                      :: ln_vvl_ztilde_as_zstar = .FALSE.    ! ztilde vertical coordinate
-   LOGICAL , PUBLIC                                      :: ln_vvl_zstar_at_eqtor = .FALSE.     ! ztilde vertical coordinate
-   LOGICAL , PUBLIC                                      :: ln_vvl_kepe = .FALSE.               ! kinetic/potential energy transfer
-   !                                                                                            ! conservation: not used yet
-   REAL(wp)                                              :: rn_ahe3                   ! thickness diffusion coefficient
-   REAL(wp)                                              :: rn_rst_e3t                ! ztilde to zstar restoration timescale [days]
-   REAL(wp)                                              :: rn_lf_cutoff              ! cutoff frequency for low-pass filter  [days]
-   REAL(wp)                                              :: rn_zdef_max               ! maximum fractional e3t deformation
-   LOGICAL , PUBLIC                                      :: ln_vvl_dbg = .FALSE.      ! debug control prints
-
-   !! * Module variables
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: un_td, vn_td                       ! thickness diffusion transport
-   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: hdiv_lf                            ! low frequency part of hz divergence
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: tilde_e3t_b, tilde_e3t_n           ! baroclinic scale factors
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: tilde_e3t_a, dtilde_e3t_a          ! baroclinic scale factors
-   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   :: frq_rst_e3t                        ! retoring period for scale factors
-   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   :: frq_rst_hdv                        ! retoring period for low freq. divergence
+
+   !                                                      !!* Namelist nam_vvl
+   LOGICAL , PUBLIC :: ln_vvl_zstar           = .FALSE.    ! zstar  vertical coordinate
+   LOGICAL , PUBLIC :: ln_vvl_ztilde          = .FALSE.    ! ztilde vertical coordinate
+   LOGICAL , PUBLIC :: ln_vvl_layer           = .FALSE.    ! level  vertical coordinate
+   LOGICAL , PUBLIC :: ln_vvl_ztilde_as_zstar = .FALSE.    ! ztilde vertical coordinate
+   LOGICAL , PUBLIC :: ln_vvl_zstar_at_eqtor  = .FALSE.    ! ztilde vertical coordinate
+   LOGICAL , PUBLIC :: ln_vvl_kepe            = .FALSE.    ! kinetic/potential energy transfer
+   !                                                       ! conservation: not used yet
+   REAL(wp)         :: rn_ahe3                             ! thickness diffusion coefficient
+   REAL(wp)         :: rn_rst_e3t                          ! ztilde to zstar restoration timescale [days]
+   REAL(wp)         :: rn_lf_cutoff                        ! cutoff frequency for low-pass filter  [days]
+   REAL(wp)         :: rn_zdef_max                         ! maximum fractional e3t deformation
+   LOGICAL , PUBLIC :: ln_vvl_dbg = .FALSE.                ! debug control prints
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: un_td, vn_td                ! thickness diffusion transport
+   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: hdiv_lf                     ! low frequency part of hz divergence
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: tilde_e3t_b, tilde_e3t_n    ! baroclinic scale factors
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: tilde_e3t_a, dtilde_e3t_a   ! baroclinic scale factors
+   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   :: frq_rst_e3t                 ! retoring period for scale factors
+   REAL(wp)        , ALLOCATABLE, SAVE, DIMENSION(:,:)   :: frq_rst_hdv                 ! retoring period for low freq. divergence
 
    !! * Substitutions
@@ -372,8 +365,8 @@
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  un_td(ji,jj,jk) = rn_ahe3 * umask(ji,jj,jk) * re2u_e1u(ji,jj) &
-                                  & * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji+1,jj  ,jk) )
-                  vn_td(ji,jj,jk) = rn_ahe3 * vmask(ji,jj,jk) * re1v_e2v(ji,jj) & 
-                                  & * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji  ,jj+1,jk) )
+                  un_td(ji,jj,jk) = rn_ahe3 * umask(ji,jj,jk) * e2_e1u(ji,jj)           &
+                     &            * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji+1,jj  ,jk) )
+                  vn_td(ji,jj,jk) = rn_ahe3 * vmask(ji,jj,jk) * e1_e2v(ji,jj)           & 
+                     &            * ( tilde_e3t_b(ji,jj,jk) - tilde_e3t_b(ji  ,jj+1,jk) )
                   zwu(ji,jj) = zwu(ji,jj) + un_td(ji,jj,jk)
                   zwv(ji,jj) = zwv(ji,jj) + vn_td(ji,jj,jk)
@@ -394,5 +387,5 @@
                   tilde_e3t_a(ji,jj,jk) = tilde_e3t_a(ji,jj,jk) + (   un_td(ji-1,jj  ,jk) - un_td(ji,jj,jk)    &
                      &                                          +     vn_td(ji  ,jj-1,jk) - vn_td(ji,jj,jk)    &
-                     &                                            ) * r1_e12t(ji,jj)
+                     &                                            ) * r1_e1e2t(ji,jj)
                END DO
             END DO
@@ -695,99 +688,80 @@
       !!                - vertical interpolation: simple averaging
       !!----------------------------------------------------------------------
-      !! * Arguments
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in    ) ::  pe3_in     ! input e3 to be interpolated
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::  pe3_out    ! output interpolated e3
-      CHARACTER(LEN=*), INTENT( in )                    ::  pout       ! grid point of out scale factors
-      !                                                                !   =  'U', 'V', 'W, 'F', 'UW' or 'VW'
-      !! * Local declarations
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::  pe3_in    ! input e3 to be interpolated
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::  pe3_out   ! output interpolated e3
+      CHARACTER(LEN=*)                , INTENT(in   ) ::  pout      ! grid point of out scale factors
+      !                                                             !   =  'U', 'V', 'W, 'F', 'UW' or 'VW'
+      !
       INTEGER ::   ji, jj, jk                                          ! dummy loop indices
-      LOGICAL ::   l_is_orca                                           ! local logical
-      !!----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      !
       IF( nn_timing == 1 )  CALL timing_start('dom_vvl_interpol')
-         !
-      l_is_orca = .FALSE.
-      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) l_is_orca = .TRUE.      ! ORCA R2 configuration - will need to correct some locations
-
-      SELECT CASE ( pout )
-         !               ! ------------------------------------- !
-      CASE( 'U' )        ! interpolation from T-point to U-point !
-         !               ! ------------------------------------- !
-         ! horizontal surface weighted interpolation
+      !
+      SELECT CASE ( pout )    !==  type of interpolation  ==!
+         !
+      CASE( 'U' )                   !* from T- to U-point : hor. surface weighted mean
          DO jk = 1, jpk
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * r1_e12u(ji,jj)                                   &
-                     &                       * (   e12t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) )     &
-                     &                           + e12t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) )
+                  pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * r1_e1e2u(ji,jj)                                   &
+                     &                       * (   e1e2t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) )     &
+                     &                           + e1e2t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) )
                END DO
             END DO
          END DO
-         !
-         IF( l_is_orca ) CALL dom_vvl_orca_fix( pe3_in, pe3_out, pout )
-         ! boundary conditions
          CALL lbc_lnk( pe3_out(:,:,:), 'U', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3u_0(:,:,:)
-         !               ! ------------------------------------- !
-      CASE( 'V' )        ! interpolation from T-point to V-point !
-         !               ! ------------------------------------- !
-         ! horizontal surface weighted interpolation
+         !
+      CASE( 'V' )                   !* from T- to V-point : hor. surface weighted mean
          DO jk = 1, jpk
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) * r1_e12v(ji,jj)                                   &
-                     &                       * (   e12t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) )     &
-                     &                           + e12t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) )
+                  pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk) * r1_e1e2v(ji,jj)                                   &
+                     &                       * (   e1e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) )     &
+                     &                           + e1e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) )
                END DO
             END DO
          END DO
-         !
-         IF( l_is_orca ) CALL dom_vvl_orca_fix( pe3_in, pe3_out, pout )
-         ! boundary conditions
          CALL lbc_lnk( pe3_out(:,:,:), 'V', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3v_0(:,:,:)
-         !               ! ------------------------------------- !
-      CASE( 'F' )        ! interpolation from U-point to F-point !
-         !               ! ------------------------------------- !
-         ! horizontal surface weighted interpolation
+         !
+      CASE( 'F' )                   !* from U-point to F-point : hor. surface weighted mean
          DO jk = 1, jpk
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) * r1_e12f(ji,jj)               &
-                     &                       * (   e12u(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3u_0(ji,jj  ,jk) )     &
-                     &                           + e12u(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3u_0(ji,jj+1,jk) ) )
+                  pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) * r1_e1e2f(ji,jj)               &
+                     &                       * (   e1e2u(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3u_0(ji,jj  ,jk) )     &
+                     &                           + e1e2u(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3u_0(ji,jj+1,jk) ) )
                END DO
             END DO
          END DO
-         !
-         IF( l_is_orca ) CALL dom_vvl_orca_fix( pe3_in, pe3_out, pout )
-         ! boundary conditions
          CALL lbc_lnk( pe3_out(:,:,:), 'F', 1._wp )
          pe3_out(:,:,:) = pe3_out(:,:,:) + e3f_0(:,:,:)
-         !               ! ------------------------------------- !
-      CASE( 'W' )        ! interpolation from T-point to W-point !
-         !               ! ------------------------------------- !
-         ! vertical simple interpolation
+         !
+      CASE( 'W' )                   !* from T- to W-point : vertical simple mean
+         !
          pe3_out(:,:,1) = e3w_0(:,:,1) + pe3_in(:,:,1) - e3t_0(:,:,1)
-         ! - ML - The use of mask in this formaula enables the special treatment of the last w- point without indirect adressing
+         ! - ML - The use of mask in this formulea enables the special treatment of the last w-point without indirect adressing
+!!gm BUG? use here wmask in case of ISF ?  to be checked
          DO jk = 2, jpk
             pe3_out(:,:,jk) = e3w_0(:,:,jk) + ( 1.0_wp - 0.5_wp * tmask(:,:,jk) ) * ( pe3_in(:,:,jk-1) - e3t_0(:,:,jk-1) )   &
                &                            +            0.5_wp * tmask(:,:,jk)   * ( pe3_in(:,:,jk  ) - e3t_0(:,:,jk  ) )
          END DO
-         !               ! -------------------------------------- !
-      CASE( 'UW' )       ! interpolation from U-point to UW-point !
-         !               ! -------------------------------------- !
-         ! vertical simple interpolation
+         !
+      CASE( 'UW' )                  !* from U- to UW-point : vertical simple mean
+         !
          pe3_out(:,:,1) = e3uw_0(:,:,1) + pe3_in(:,:,1) - e3u_0(:,:,1)
          ! - ML - The use of mask in this formaula enables the special treatment of the last w- point without indirect adressing
+!!gm BUG? use here wumask in case of ISF ?  to be checked
          DO jk = 2, jpk
             pe3_out(:,:,jk) = e3uw_0(:,:,jk) + ( 1.0_wp - 0.5_wp * umask(:,:,jk) ) * ( pe3_in(:,:,jk-1) - e3u_0(:,:,jk-1) )   &
                &                             +            0.5_wp * umask(:,:,jk)   * ( pe3_in(:,:,jk  ) - e3u_0(:,:,jk  ) )
          END DO
-         !               ! -------------------------------------- !
-      CASE( 'VW' )       ! interpolation from V-point to VW-point !
-         !               ! -------------------------------------- !
-         ! vertical simple interpolation
+         !
+      CASE( 'VW' )                  !* from V- to VW-point : vertical simple mean
+         !
          pe3_out(:,:,1) = e3vw_0(:,:,1) + pe3_in(:,:,1) - e3v_0(:,:,1)
          ! - ML - The use of mask in this formaula enables the special treatment of the last w- point without indirect adressing
+!!gm BUG? use here wvmask in case of ISF ?  to be checked
          DO jk = 2, jpk
             pe3_out(:,:,jk) = e3vw_0(:,:,jk) + ( 1.0_wp - 0.5_wp * vmask(:,:,jk) ) * ( pe3_in(:,:,jk-1) - e3v_0(:,:,jk-1) )   &
@@ -796,8 +770,8 @@
       END SELECT
       !
-
       IF( nn_timing == 1 )  CALL timing_stop('dom_vvl_interpol')
-
+      !
    END SUBROUTINE dom_vvl_interpol
+
 
    SUBROUTINE dom_vvl_rst( kt, cdrw )
@@ -813,8 +787,7 @@
       !!                they are set to 0.
       !!----------------------------------------------------------------------
-      !! * Arguments
       INTEGER         , INTENT(in) ::   kt     ! ocean time-step
       CHARACTER(len=*), INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
-      !! * Local declarations
+      !
       INTEGER ::   jk
       INTEGER ::   id1, id2, id3, id4, id5     ! local integers
@@ -911,5 +884,5 @@
             END IF
          ENDIF
-
+         !
       ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN   ! Create restart file
          !                                   ! ===================
@@ -931,8 +904,9 @@
             CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:) )
          ENDIF
-
-      ENDIF
+         !
+      ENDIF
+      !
       IF( nn_timing == 1 )  CALL timing_stop('dom_vvl_rst')
-
+      !
    END SUBROUTINE dom_vvl_rst
 
@@ -945,21 +919,20 @@
       !!                for vertical coordinate
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio
-      INTEGER ::   ios
-
+      INTEGER ::   ioptio, ios
+      !!
       NAMELIST/nam_vvl/ ln_vvl_zstar, ln_vvl_ztilde, ln_vvl_layer, ln_vvl_ztilde_as_zstar, &
-                      & ln_vvl_zstar_at_eqtor      , rn_ahe3     , rn_rst_e3t            , &
-                      & rn_lf_cutoff               , rn_zdef_max , ln_vvl_dbg                ! not yet implemented: ln_vvl_kepe
+         &              ln_vvl_zstar_at_eqtor      , rn_ahe3     , rn_rst_e3t            , &
+         &              rn_lf_cutoff               , rn_zdef_max , ln_vvl_dbg                ! not yet implemented: ln_vvl_kepe
       !!---------------------------------------------------------------------- 
-
+      !
       REWIND( numnam_ref )              ! Namelist nam_vvl in reference namelist : 
       READ  ( numnam_ref, nam_vvl, IOSTAT = ios, ERR = 901)
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_vvl in reference namelist', lwp )
-
+      !
       REWIND( numnam_cfg )              ! Namelist nam_vvl in configuration namelist : Parameters of the run
       READ  ( numnam_cfg, nam_vvl, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_vvl in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, nam_vvl )
-
+      !
       IF(lwp) THEN                    ! Namelist print
          WRITE(numout,*)
@@ -994,14 +967,14 @@
          WRITE(numout,*) '                                         ln_vvl_dbg     = ', ln_vvl_dbg
       ENDIF
-
+      !
       ioptio = 0                      ! Parameter control
-      IF( ln_vvl_ztilde_as_zstar ) ln_vvl_ztilde = .true.
-      IF( ln_vvl_zstar           )        ioptio = ioptio + 1
-      IF( ln_vvl_ztilde          )        ioptio = ioptio + 1
-      IF( ln_vvl_layer           )        ioptio = ioptio + 1
-
+      IF( ln_vvl_ztilde_as_zstar )   ln_vvl_ztilde = .true.
+      IF( ln_vvl_zstar           )   ioptio = ioptio + 1
+      IF( ln_vvl_ztilde          )   ioptio = ioptio + 1
+      IF( ln_vvl_layer           )   ioptio = ioptio + 1
+      !
       IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE vertical coordinate in namelist nam_vvl' )
       IF( .NOT. ln_vvl_zstar .AND. nn_isf .NE. 0) CALL ctl_stop( 'Only vvl_zstar has been tested with ice shelf cavity' )
-
+      !
       IF(lwp) THEN                   ! Print the choice
          WRITE(numout,*)
@@ -1014,400 +987,10 @@
          ! IF( .NOT. ln_vvl_kepe ) WRITE(numout,*) '              kinetic to potential energy transfer : option not used'
       ENDIF
-
+      !
 #if defined key_agrif
       IF (.NOT.Agrif_Root()) CALL ctl_stop( 'AGRIF not implemented with non-linear free surface (key_vvl)' )
 #endif
-
+      !
    END SUBROUTINE dom_vvl_ctl
-
-   SUBROUTINE dom_vvl_orca_fix( pe3_in, pe3_out, pout )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE dom_vvl_orca_fix  ***
-      !!                     
-      !! ** Purpose :   Correct surface weighted, horizontally interpolated, 
-      !!                scale factors at locations that have been individually
-      !!                modified in domhgr. Such modifications break the
-      !!                relationship between e12t and e1u*e2u etc.
-      !!                Recompute some scale factors ignoring the modified metric.
-      !!----------------------------------------------------------------------
-      !! * Arguments
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( in    ) ::  pe3_in     ! input e3 to be interpolated
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT( inout ) ::  pe3_out    ! output interpolated e3
-      CHARACTER(LEN=*), INTENT( in )                    ::  pout       ! grid point of out scale factors
-      !                                                                !   =  'U', 'V', 'W, 'F', 'UW' or 'VW'
-      !! * Local declarations
-      INTEGER ::   ji, jj, jk                                          ! dummy loop indices
-      INTEGER ::   ij0, ij1, ii0, ii1                                  ! dummy loop indices
-      INTEGER ::   isrow                                               ! index for ORCA1 starting row
-      !! acc
-      !! Hmm with the time splitting these "fixes" seem to do more harm than good. Temporarily disabled for
-      !! the ORCA2 tests (by changing jp_cfg test from 2 to 3) pending further investigations
-      !! 
-      !                                                ! =====================
-      IF( cp_cfg == "orca" .AND. jp_cfg == 3 ) THEN    ! ORCA R2 configuration
-         !                                             ! =====================
-      !! acc
-         IF( nn_cla == 0 ) THEN
-            !
-            ii0 = 139   ;   ii1 = 140        ! Gibraltar Strait (e2u was modified)
-            ij0 = 102   ;   ij1 = 102
-            DO jk = 1, jpkm1
-               DO jj = mj0(ij0), mj1(ij1)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     SELECT CASE ( pout )
-                     CASE( 'U' )
-                        pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                       &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                       &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                       &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                     CASE( 'F' )
-                        pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                       &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                       &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                       &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                     END SELECT
-                  END DO
-               END DO
-            END DO
-            !
-            ii0 = 160   ;   ii1 = 160        ! Bab el Mandeb (e2u and e1v were modified)
-            ij0 =  88   ;   ij1 =  88
-            DO jk = 1, jpkm1
-               DO jj = mj0(ij0), mj1(ij1)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     SELECT CASE ( pout )
-                     CASE( 'U' )
-                        pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                       &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                       &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                       &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                     CASE( 'V' )
-                        pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                       &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                       &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                       &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                     CASE( 'F' )
-                        pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                       &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                       &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                       &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                     END SELECT
-                  END DO
-               END DO
-            END DO
-         ENDIF
-
-         ii0 = 145   ;   ii1 = 146        ! Danish Straits (e2u was modified)
-         ij0 = 116   ;   ij1 = 116
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-      ENDIF
-      !
-         !                                             ! =====================
-      IF( cp_cfg == "orca" .AND. jp_cfg == 1 ) THEN    ! ORCA R1 configuration
-         !                                             ! =====================
-         ! This dirty section will be suppressed by simplification process:
-         ! all this will come back in input files
-         ! Currently these hard-wired indices relate to configuration with
-         ! extend grid (jpjglo=332)
-         ! which had a grid-size of 362x292.
-         isrow = 332 - jpjglo
-         !
-         ii0 = 282           ;   ii1 = 283        ! Gibraltar Strait (e2u was modified)
-         ij0 = 241 - isrow   ;   ij1 = 241 - isrow
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 = 314           ;   ii1 = 315        ! Bhosporus Strait (e2u was modified)
-         ij0 = 248 - isrow   ;   ij1 = 248 - isrow
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &  
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &  
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  44           ;   ii1 =  44        ! Lombok Strait (e1v was modified)
-         ij0 = 164 - isrow   ;   ij1 = 165 - isrow
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  48           ;   ii1 =  48        ! Sumba Strait (e1v was modified) [closed from bathy_11 on]
-         ij0 = 164 - isrow   ;   ij1 = 165 - isrow
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  53          ;   ii1 =  53        ! Ombai Strait (e1v was modified)
-         ij0 = 164 - isrow  ;   ij1 = 165  - isrow  
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  56            ;   ii1 =  56        ! Timor Passage (e1v was modified)
-         ij0 = 164 - isrow    ;   ij1 = 165  - isrow  
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  55            ;   ii1 =  55        ! West Halmahera Strait (e1v was modified)
-         ij0 = 181 - isrow    ;   ij1 = 182 - isrow  
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  58            ;   ii1 =  58        ! East Halmahera Strait (e1v was modified)
-         ij0 = 181 - isrow    ;   ij1 = 182 - isrow  
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-      ENDIF
-         !                                             ! =====================
-      IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN   ! ORCA R05 configuration
-         !                                             ! =====================
-         !
-         ii0 = 563   ;   ii1 = 564        ! Gibraltar Strait (e2u was modified)
-         ij0 = 327   ;   ij1 = 327
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 = 627   ;   ii1 = 628        ! Bosphorus Strait (e2u was modified)
-         ij0 = 343   ;   ij1 = 343
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &  
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &  
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  93   ;   ii1 =  94        ! Sumba Strait (e2u was modified)
-         ij0 = 232   ;   ij1 = 232
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 = 103   ;   ii1 = 103        ! Ombai Strait (e2u was modified)
-         ij0 = 232   ;   ij1 = 232
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  15   ;   ii1 =  15        ! Palk Strait (e2u was modified)
-         ij0 = 270   ;   ij1 = 270
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'U' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk)                                        &
-                    &                    * (   e1t(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3t_0(ji  ,jj,jk) ) &
-                    &                    +     e1t(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3t_0(ji+1,jj,jk) ) &
-                    &                      ) / e1u(ji,jj)   +   e3u_0(ji,jj,jk)
-                  CASE( 'F' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk)                    &
-                    &                    * (   e1u(ji  ,jj) * ( pe3_in(ji  ,jj,jk) - e3u_0(ji  ,jj,jk) ) &
-                    &                    +     e1u(ji+1,jj) * ( pe3_in(ji+1,jj,jk) - e3u_0(ji+1,jj,jk) ) &
-                    &                      ) / e1f(ji,jj)   +   e3f_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 =  87   ;   ii1 =  87        ! Lombok Strait (e1v was modified)
-         ij0 = 232   ;   ij1 = 233
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-         !
-         ii0 = 662   ;   ii1 = 662        ! Bab el Mandeb (e1v was modified)
-         ij0 = 276   ;   ij1 = 276
-         DO jk = 1, jpkm1
-            DO jj = mj0(ij0), mj1(ij1)
-               DO ji = mi0(ii0), mi1(ii1)
-                  SELECT CASE ( pout )
-                  CASE( 'V' )
-                     pe3_out(ji,jj,jk) = 0.5_wp * vmask(ji,jj,jk)                                        &
-                    &                    * (   e2t(ji,jj  ) * ( pe3_in(ji,jj  ,jk) - e3t_0(ji,jj  ,jk) ) &
-                    &                    +     e2t(ji,jj+1) * ( pe3_in(ji,jj+1,jk) - e3t_0(ji,jj+1,jk) ) &
-                    &                      ) / e2v(ji,jj)   +   e3v_0(ji,jj,jk)
-                  END SELECT
-               END DO
-            END DO
-         END DO
-      ENDIF
-   END SUBROUTINE dom_vvl_orca_fix
 
    !!======================================================================
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domwri.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domwri.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domwri.F90	(revision 6041)
@@ -7,11 +7,10 @@
    !!            8.1  ! 1999-11  (M. Imbard)  NetCDF FORMAT with IOIPSL
    !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90 and several file
-   !!            3.0  ! 2008-01  (S. Masson) add dom_uniq 
-   !!            4.0  ! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
+   !!            3.0  ! 2008-01  (S. Masson)  add dom_uniq 
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
    !!   dom_wri        : create and write mesh and mask file(s)
-   !!   dom_uniq       :
+   !!   dom_uniq       : identify unique point of a grid (TUVF)
    !!----------------------------------------------------------------------
    USE dom_oce         ! ocean space and time domain
@@ -26,6 +25,6 @@
    PRIVATE
 
-   PUBLIC dom_wri        ! routine called by inidom.F90
-
+   PUBLIC   dom_wri              ! routine called by inidom.F90
+   PUBLIC   dom_wri_coordinate   ! routine called by domhgr.F90
    !! * Substitutions
 #  include "vectopt_loop_substitute.h90"
@@ -36,4 +35,69 @@
    !!----------------------------------------------------------------------
 CONTAINS
+
+   SUBROUTINE dom_wri_coordinate
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE dom_wri_coordinate  ***
+      !!                   
+      !! ** Purpose :   Create the NetCDF file which contains all the
+      !!              standard coordinate information plus the surface,
+      !!              e1e2u and e1e2v. By doing so, those surface will
+      !!              not be changed by the reduction of e1u or e2v scale 
+      !!              factors in some straits. 
+      !!                 NB: call just after the read of standard coordinate
+      !!              and the reduction of scale factors in some straits
+      !!
+      !! ** output file :   coordinate_e1e2u_v.nc
+      !!----------------------------------------------------------------------
+      INTEGER           ::   inum0    ! temprary units for 'coordinate_e1e2u_v.nc' file
+      CHARACTER(len=21) ::   clnam0   ! filename (mesh and mask informations)
+      !                                   !  workspaces
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: zprt, zprw 
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdepu, zdepv
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dom_wri_coordinate')
+      !
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) 'dom_wri_coordinate : create NetCDF coordinate file'
+      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~~'
+      
+      clnam0 = 'coordinate_e1e2u_v'  ! filename (mesh and mask informations)
+      
+      !  create 'coordinate_e1e2u_v.nc' file
+      ! ============================
+      !
+      CALL iom_open( TRIM(clnam0), inum0, ldwrt = .TRUE., kiolib = jprstlib )
+      !
+      !                                                         ! horizontal mesh (inum3)
+      CALL iom_rstput( 0, 0, inum0, 'glamt', glamt, ktype = jp_r4 )     !    ! latitude
+      CALL iom_rstput( 0, 0, inum0, 'glamu', glamu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'glamv', glamv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'glamf', glamf, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'gphit', gphit, ktype = jp_r4 )     !    ! longitude
+      CALL iom_rstput( 0, 0, inum0, 'gphiu', gphiu, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'gphiv', gphiv, ktype = jp_r4 )
+      CALL iom_rstput( 0, 0, inum0, 'gphif', gphif, ktype = jp_r4 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'e1t', e1t, ktype = jp_r8 )         !    ! e1 scale factors
+      CALL iom_rstput( 0, 0, inum0, 'e1u', e1u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e1v', e1v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e1f', e1f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'e2t', e2t, ktype = jp_r8 )         !    ! e2 scale factors
+      CALL iom_rstput( 0, 0, inum0, 'e2u', e2u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e2v', e2v, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e2f', e2f, ktype = jp_r8 )
+      
+      CALL iom_rstput( 0, 0, inum0, 'e1e2u', e1e2u, ktype = jp_r8 )
+      CALL iom_rstput( 0, 0, inum0, 'e1e2v', e1e2v, ktype = jp_r8 )
+
+      CALL iom_close( inum0 )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dom_wri_coordinate')
+      !
+   END SUBROUTINE dom_wri_coordinate
+
 
    SUBROUTINE dom_wri
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/domzgr.F90	(revision 6041)
@@ -501,25 +501,24 @@
             IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
                !                                             ! =====================
-               IF( nn_cla == 0 ) THEN
-                  ii0 = 140   ;   ii1 = 140                  ! Gibraltar Strait open 
-                  ij0 = 102   ;   ij1 = 102                  ! (Thomson, Ocean Modelling, 1995)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     DO jj = mj0(ij0), mj1(ij1)
-                        mbathy(ji,jj) = 15
-                     END DO
+               !
+               ii0 = 140   ;   ii1 = 140                  ! Gibraltar Strait open 
+               ij0 = 102   ;   ij1 = 102                  ! (Thomson, Ocean Modelling, 1995)
+               DO ji = mi0(ii0), mi1(ii1)
+                  DO jj = mj0(ij0), mj1(ij1)
+                     mbathy(ji,jj) = 15
                   END DO
-                  IF(lwp) WRITE(numout,*)
-                  IF(lwp) WRITE(numout,*) '      orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
-                  !
-                  ii0 = 160   ;   ii1 = 160                  ! Bab el mandeb Strait open
-                  ij0 = 88    ;   ij1 = 88                   ! (Thomson, Ocean Modelling, 1995)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     DO jj = mj0(ij0), mj1(ij1)
-                        mbathy(ji,jj) = 12
-                     END DO
+               END DO
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '      orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
+               !
+               ii0 = 160   ;   ii1 = 160                  ! Bab el mandeb Strait open
+               ij0 = 88    ;   ij1 = 88                   ! (Thomson, Ocean Modelling, 1995)
+               DO ji = mi0(ii0), mi1(ii1)
+                  DO jj = mj0(ij0), mj1(ij1)
+                     mbathy(ji,jj) = 12
                   END DO
-                  IF(lwp) WRITE(numout,*)
-                  IF(lwp) WRITE(numout,*) '      orca_r2: Bab el Mandeb strait open at i=',ii0,' j=',ij0
-               ENDIF
+               END DO
+               IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '      orca_r2: Bab el Mandeb strait open at i=',ii0,' j=',ij0
                !
             ENDIF
@@ -545,26 +544,24 @@
             !       
             IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN    ! ORCA R2 configuration
-               !
-              IF( nn_cla == 0 ) THEN
-                 ii0 = 140   ;   ii1 = 140                   ! Gibraltar Strait open 
-                 ij0 = 102   ;   ij1 = 102                   ! (Thomson, Ocean Modelling, 1995)
-                 DO ji = mi0(ii0), mi1(ii1)
-                    DO jj = mj0(ij0), mj1(ij1)
-                       bathy(ji,jj) = 284._wp
-                    END DO
+            !
+              ii0 = 140   ;   ii1 = 140                   ! Gibraltar Strait open 
+              ij0 = 102   ;   ij1 = 102                   ! (Thomson, Ocean Modelling, 1995)
+              DO ji = mi0(ii0), mi1(ii1)
+                 DO jj = mj0(ij0), mj1(ij1)
+                    bathy(ji,jj) = 284._wp
                  END DO
-                 IF(lwp) WRITE(numout,*)     
-                 IF(lwp) WRITE(numout,*) '      orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
-                 !
-                 ii0 = 160   ;   ii1 = 160                   ! Bab el mandeb Strait open
-                 ij0 = 88    ;   ij1 = 88                    ! (Thomson, Ocean Modelling, 1995)
-                 DO ji = mi0(ii0), mi1(ii1)
-                    DO jj = mj0(ij0), mj1(ij1)
-                       bathy(ji,jj) = 137._wp
-                    END DO
+               END DO
+              IF(lwp) WRITE(numout,*)     
+              IF(lwp) WRITE(numout,*) '      orca_r2: Gibraltar strait open at i=',ii0,' j=',ij0
+              !
+              ii0 = 160   ;   ii1 = 160                   ! Bab el mandeb Strait open
+              ij0 = 88    ;   ij1 = 88                    ! (Thomson, Ocean Modelling, 1995)
+               DO ji = mi0(ii0), mi1(ii1)
+                 DO jj = mj0(ij0), mj1(ij1)
+                    bathy(ji,jj) = 137._wp
                  END DO
-                 IF(lwp) WRITE(numout,*)
-                 IF(lwp) WRITE(numout,*) '             orca_r2: Bab el Mandeb strait open at i=',ii0,' j=',ij0
-              ENDIF
+              END DO
+              IF(lwp) WRITE(numout,*)
+               IF(lwp) WRITE(numout,*) '             orca_r2: Bab el Mandeb strait open at i=',ii0,' j=',ij0
               !
            ENDIF
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/dtatsd.F90	(revision 6041)
@@ -174,34 +174,9 @@
             END DO
          END DO
-         IF( nn_cla == 1 ) THEN                          ! Cross Land advection
-            il0 = 138   ;   il1 = 138                          ! set T & S profile at Gibraltar Strait
-            ij0 = 101   ;   ij1 = 102
-            ii0 = 139   ;   ii1 = 139
-            DO jl = mi0(il0), mi1(il1)
-               DO jj = mj0(ij0), mj1(ij1)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     sf_tsd(jp_tem)%fnow(ji,jj,:) = sf_tsd(jp_tem)%fnow(jl,jj,:)
-                     sf_tsd(jp_sal)%fnow(ji,jj,:) = sf_tsd(jp_sal)%fnow(jl,jj,:)
-                  END DO
-               END DO
-            END DO
-            il0 = 164   ;   il1 = 164                          ! set T & S profile at Bab el Mandeb Strait
-            ij0 =  87   ;   ij1 =  88
-            ii0 = 161   ;   ii1 = 163
-            DO jl = mi0(il0), mi1(il1)
-               DO jj = mj0(ij0), mj1(ij1)
-                  DO ji = mi0(ii0), mi1(ii1)
-                     sf_tsd(jp_tem)%fnow(ji,jj,:) = sf_tsd(jp_tem)%fnow(jl,jj,:)
-                     sf_tsd(jp_sal)%fnow(ji,jj,:) = sf_tsd(jp_sal)%fnow(jl,jj,:)
-                  END DO
-               END DO
-            END DO
-         ELSE                                            ! No Cross Land advection
-            ij0 =  87   ;   ij1 =  96                          ! Reduced temperature in Red Sea
-            ii0 = 148   ;   ii1 = 160
-            sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 ) = 7.0_wp
-            sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 ) = 6.5_wp
-            sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp
-         ENDIF
+         ij0 =  87   ;   ij1 =  96                          ! Reduced temperature in Red Sea
+         ii0 = 148   ;   ii1 = 160
+         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ,  4:10 ) = 7.0_wp
+         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 11:13 ) = 6.5_wp
+         sf_tsd(jp_tem)%fnow( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , 14:20 ) = 6.0_wp
       ENDIF
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DOM/istate.F90	(revision 6041)
@@ -29,15 +29,10 @@
    USE daymod          ! calendar
    USE eosbn2          ! eq. of state, Brunt Vaisala frequency (eos     routine)
-   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldftra          ! lateral physics: ocean active tracers
    USE zdf_oce         ! ocean vertical physics
    USE phycst          ! physical constants
    USE dtatsd          ! data temperature and salinity   (dta_tsd routine)
    USE dtauvd          ! data: U & V current             (dta_uvd routine)
-   USE zpshde          ! partial step: hor. derivative (zps_hde routine)
-   USE eosbn2          ! equation of state            (eos bn2 routine)
    USE domvvl          ! varying vertical mesh
-   USE dynspg_oce      ! pressure gradient schemes
-   USE dynspg_flt      ! filtered free surface
-   USE sol_oce         ! ocean solver variables
    !
    USE in_out_manager  ! I/O manager
@@ -76,10 +71,10 @@
       !
 
-      IF(lwp) WRITE(numout,*) ' '
+      IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'istate_ini : Initialization of the dynamics and tracers'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
 
-      CALL dta_tsd_init                       ! Initialisation of T & S input data
-      IF( lk_c1d ) CALL dta_uvd_init          ! Initialization of U & V input data
+                     CALL dta_tsd_init        ! Initialisation of T & S input data
+      IF( lk_c1d )   CALL dta_uvd_init        ! Initialization of U & V input data
 
       rhd  (:,:,:  ) = 0._wp   ;   rhop (:,:,:  ) = 0._wp      ! set one for all to 0 at level jpk
@@ -103,6 +98,5 @@
          ub   (:,:,:) = 0._wp   ;   un   (:,:,:) = 0._wp
          vb   (:,:,:) = 0._wp   ;   vn   (:,:,:) = 0._wp  
-         rotb (:,:,:) = 0._wp   ;   rotn (:,:,:) = 0._wp
-         hdivb(:,:,:) = 0._wp   ;   hdivn(:,:,:) = 0._wp
+                                    hdivn(:,:,:) = 0._wp
          !
          IF( cp_cfg == 'eel' ) THEN
@@ -119,22 +113,11 @@
             ENDIF
             IF ( ln_uvd_init .AND. lk_c1d ) THEN ! read 3D U and V data at nit000
-               CALL wrk_alloc( jpi, jpj, jpk, 2, zuvd )
+               CALL wrk_alloc( jpi,jpj,jpk,2,   zuvd )
                CALL dta_uvd( nit000, zuvd )
                ub(:,:,:) = zuvd(:,:,:,1) ;  un(:,:,:) = ub(:,:,:)
                vb(:,:,:) = zuvd(:,:,:,2) ;  vn(:,:,:) = vb(:,:,:)
-               CALL wrk_dealloc( jpi, jpj, jpk, 2, zuvd )
+               CALL wrk_dealloc( jpi,jpj,jpk,2,   zuvd )
             ENDIF
          ENDIF
-         !
-         CALL eos( tsb, rhd, rhop, gdept_0(:,:,:) )        ! before potential and in situ densities
-#if ! defined key_c1d
-         IF( ln_zps .AND. .NOT. ln_isfcav)                                 &
-            &            CALL zps_hde    ( nit000, jpts, tsb, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient
-            &                                            rhd, gru , grv    )  ! of t, s, rd at the last ocean level
-         IF( ln_zps .AND.       ln_isfcav)                                 &
-            &            CALL zps_hde_isf( nit000, jpts, tsb, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
-            &                                            rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-            &                                     gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level
-#endif
          !   
          ! - ML - sshn could be modified by istate_eel, so that initialization of fse3t_b is done here
@@ -142,17 +125,7 @@
             DO jk = 1, jpk
                fse3t_b(:,:,jk) = fse3t_n(:,:,jk)
-            ENDDO
+            END DO
          ENDIF
          ! 
-      ENDIF
-      !
-      IF( lk_agrif ) THEN                  ! read free surface arrays in restart file
-         IF( ln_rstart ) THEN
-            IF( lk_dynspg_flt )  THEN      ! read or initialize the following fields
-               !                           ! gcx, gcxb for agrif_opa_init
-               IF( sol_oce_alloc()  > 0 )   CALL ctl_stop('agrif sol_oce_alloc: allocation of arrays failed')
-               CALL flt_rst( nit000, 'READ' )
-            ENDIF
-         ENDIF                             ! explicit case not coded yet with AGRIF
       ENDIF
       !
@@ -163,6 +136,6 @@
       !
       !
-      un_b(:,:) = 0._wp ; vn_b(:,:) = 0._wp
-      ub_b(:,:) = 0._wp ; vb_b(:,:) = 0._wp
+      un_b(:,:) = 0._wp   ;   vn_b(:,:) = 0._wp
+      ub_b(:,:) = 0._wp   ;   vb_b(:,:) = 0._wp
       !
       DO jk = 1, jpkm1
@@ -202,6 +175,6 @@
       !! References :  Philander ???
       !!----------------------------------------------------------------------
-      INTEGER  :: ji, jj, jk
-      REAL(wp) ::   zsal = 35.50
+      INTEGER  ::   ji, jj, jk
+      REAL(wp) ::   zsal = 35.50_wp
       !!----------------------------------------------------------------------
       !
@@ -233,5 +206,5 @@
       !!                and relative vorticity fields
       !!----------------------------------------------------------------------
-      USE divcur     ! hor. divergence & rel. vorticity      (div_cur routine)
+      USE divhor     ! hor. divergence      (div_hor routine)
       USE iom
       !
@@ -282,5 +255,5 @@
             tsb(:,:,:,jp_sal) = tsn(:,:,:,jp_sal)
             !
-            ! set the dynamics: U,V, hdiv, rot (and ssh if necessary)
+            ! set the dynamics: U,V, hdiv (and ssh if necessary)
             ! ----------------
             ! Start EEL5 configuration with barotropic geostrophic velocities 
@@ -318,5 +291,7 @@
             ENDIF
             !
-            CALL div_cur( nit000 )                  ! horizontal divergence and relative vorticity (curl)
+!!gm  Check  here call to div_hor should not be necessary
+!!gm         div_hor call runoffs  not sure they are defined at that level
+            CALL div_hor( nit000 )                  ! horizontal divergence and relative vorticity (curl)
             ! N.B. the vertical velocity will be computed from the horizontal divergence field
             ! in istate by a call to wzv routine
@@ -371,5 +346,5 @@
       !!
       !! ** Method  : - set temprature field
-      !!              - set salinity field
+      !!              - set salinity   field
       !!----------------------------------------------------------------------
       INTEGER :: ji, jj, jk  ! dummy loop indices
@@ -457,15 +432,13 @@
       !!                 p=integral [ rau*g dz ]
       !!----------------------------------------------------------------------
-      USE dynspg          ! surface pressure gradient             (dyn_spg routine)
-      USE divcur          ! hor. divergence & rel. vorticity      (div_cur routine)
+      USE divhor          ! hor. divergence                       (div_hor routine)
       USE lbclnk          ! ocean lateral boundary condition (or mpp link)
       !
       INTEGER ::   ji, jj, jk        ! dummy loop indices
-      INTEGER ::   indic             ! ???
       REAL(wp) ::   zmsv, zphv, zmsu, zphu, zalfg     ! temporary scalars
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zprn
       !!----------------------------------------------------------------------
       !
-      CALL wrk_alloc( jpi, jpj, jpk, zprn)
+      CALL wrk_alloc( jpi,jpj,jpk,   zprn)
       !
       IF(lwp) WRITE(numout,*) 
@@ -529,40 +502,10 @@
       vb(:,:,:) = vn(:,:,:)
       
-      ! WARNING !!!!!
-      ! after initializing u and v, we need to calculate the initial streamfunction bsf.
-      ! Otherwise, only the trend will be computed and the model will blow up (inconsistency).
-      ! to do that, we call dyn_spg with a special trick:
-      ! we fill ua and va with the velocities divided by dt, and the streamfunction will be brought to the
-      ! right value assuming the velocities have been set up in one time step.
-      ! we then set bsfd to zero (first guess for next step is d(psi)/dt = 0.)
-      !  sets up s false trend to calculate the barotropic streamfunction.
-
-      ua(:,:,:) = ub(:,:,:) / rdt
-      va(:,:,:) = vb(:,:,:) / rdt
-
-      ! calls dyn_spg. we assume euler time step, starting from rest.
-      indic = 0
-      CALL dyn_spg( nit000, indic )       ! surface pressure gradient
-
-      ! the new velocity is ua*rdt
-
-      CALL lbc_lnk( ua, 'U', -1. )
-      CALL lbc_lnk( va, 'V', -1. )
-
-      ub(:,:,:) = ua(:,:,:) * rdt
-      vb(:,:,:) = va(:,:,:) * rdt
-      ua(:,:,:) = 0.e0
-      va(:,:,:) = 0.e0
-      un(:,:,:) = ub(:,:,:)
-      vn(:,:,:) = vb(:,:,:)
-       
-      ! Compute the divergence and curl
-
-      CALL div_cur( nit000 )            ! now horizontal divergence and curl
-
-      hdivb(:,:,:) = hdivn(:,:,:)       ! set the before to the now value
-      rotb (:,:,:) = rotn (:,:,:)       ! set the before to the now value
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zprn)
+      !
+!!gm  Check  here call to div_hor should not be necessary
+!!gm         div_hor call runoffs  not sure they are defined at that level
+      CALL div_hor( nit000 )            ! now horizontal divergence
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zprn)
       !
    END SUBROUTINE istate_uvg
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/divcur.F90	(revision 6040)
+++ 	(revision )
@@ -1,341 +1,0 @@
-MODULE divcur
-   !!==============================================================================
-   !!                       ***  MODULE  divcur  ***
-   !! Ocean diagnostic variable : horizontal divergence and relative vorticity
-   !!==============================================================================
-   !! History :  OPA  ! 1987-06  (P. Andrich, D. L Hostis)  Original code
-   !!            4.0  ! 1991-11  (G. Madec)
-   !!            6.0  ! 1993-03  (M. Guyon)  symetrical conditions
-   !!            7.0  ! 1996-01  (G. Madec)  s-coordinates
-   !!            8.0  ! 1997-06  (G. Madec)  lateral boundary cond., lbc
-   !!            8.1  ! 1997-08  (J.M. Molines)  Open boundaries
-   !!            8.2  ! 2000-03  (G. Madec)  no slip accurate
-   !!  NEMO      1.0  ! 2002-09  (G. Madec, E. Durand)  Free form, F90
-   !!             -   ! 2005-01  (J. Chanut) Unstructured open boundaries
-   !!             -   ! 2003-08  (G. Madec)  merged of cur and div, free form, F90
-   !!             -   ! 2005-01  (J. Chanut, A. Sellar) unstructured open boundaries
-   !!            3.3  ! 2010-09  (D.Storkey and E.O'Dea) bug fixes for BDY module
-   !!             -   ! 2010-10  (R. Furner, G. Madec) runoff and cla added directly here
-   !!            3.6  ! 2014-11  (P. Mathiot)          isf            added directly here
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   div_cur    : Compute the horizontal divergence and relative
-   !!                vorticity fields
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_oce, ONLY : ln_rnf, nn_isf ! surface boundary condition: ocean
-   USE sbcrnf          ! river runoff 
-   USE sbcisf          ! ice shelf 
-   USE cla             ! cross land advection             (cla_div routine)
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   div_cur    ! routine called by step.F90 and istate.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-#if defined key_noslip_accurate
-   !!----------------------------------------------------------------------
-   !!   'key_noslip_accurate'   2nd order interior + 4th order at the coast
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE div_cur( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE div_cur  ***
-      !!
-      !! ** Purpose :   compute the horizontal divergence and the relative
-      !!              vorticity at before and now time-step
-      !!
-      !! ** Method  : I.  divergence :
-      !!         - save the divergence computed at the previous time-step
-      !!      (note that the Asselin filter has not been applied on hdivb)
-      !!         - compute the now divergence given by :
-      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
-      !!      correct hdiv with runoff inflow (div_rnf), ice shelf melting (div_isf)
-      !!      and cross land flow (div_cla) 
-      !!              II. vorticity :
-      !!         - save the curl computed at the previous time-step
-      !!            rotb = rotn
-      !!      (note that the Asselin time filter has not been applied to rotb)
-      !!         - compute the now curl in tensorial formalism:
-      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
-      !!         - Coastal boundary condition: 'key_noslip_accurate' defined,
-      !!      the no-slip boundary condition is computed using Schchepetkin
-      !!      and O'Brien (1996) scheme (i.e. 4th order at the coast).
-      !!      For example, along east coast, the one-sided finite difference
-      !!      approximation used for di[v] is:
-      !!         di[e2v vn] =  1/(e1f*e2f) * ( (e2v vn)(i) + (e2v vn)(i-1) + (e2v vn)(i-2) )
-      !!
-      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
-      !!              - update rotb , rotn , the before & now rel. vorticity
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !
-      INTEGER ::   ji, jj, jk, jl           ! dummy loop indices
-      INTEGER ::   ii, ij, ijt, iju, ierr   ! local integer
-      REAL(wp) ::  zraur, zdep              ! local scalar
-      REAL(wp), POINTER,  DIMENSION(:,:) ::   zwu   ! specific 2D workspace
-      REAL(wp), POINTER,  DIMENSION(:,:) ::   zwv   ! specific 2D workspace
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('div_cur')
-      !
-      CALL wrk_alloc( jpi  , jpj+2, zwu               )
-      CALL wrk_alloc( jpi+4, jpj  , zwv, kistart = -1 )
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and relative vorticity'
-         IF(lwp) WRITE(numout,*) '~~~~~~~   NOT optimal for auto-tasking case'
-      ENDIF
-
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         !
-         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
-         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
-         !
-         !                                             ! --------
-         ! Horizontal divergence                       !   div
-         !                                             ! --------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               hdivn(ji,jj,jk) =   &
-                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * un(ji-1,jj  ,jk)       &
-                   + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * vn(ji  ,jj-1,jk)  )    &
-                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-            END DO
-         END DO
-
-         IF( .NOT. AGRIF_Root() ) THEN
-            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
-            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
-            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
-            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
-         ENDIF
-
-         !                                             ! --------
-         ! relative vorticity                          !   rot 
-         !                                             ! --------
-         ! contravariant velocity (extended for lateral b.c.)
-         ! inside the model domain
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zwu(ji,jj) = e1u(ji,jj) * un(ji,jj,jk)
-               zwv(ji,jj) = e2v(ji,jj) * vn(ji,jj,jk)
-            END DO  
-         END DO  
- 
-         ! East-West boundary conditions
-         IF( nperio == 1 .OR. nperio == 4 .OR. nperio == 6) THEN
-            zwv(  0  ,:) = zwv(jpi-2,:)
-            zwv( -1  ,:) = zwv(jpi-3,:)
-            zwv(jpi+1,:) = zwv(  3  ,:)
-            zwv(jpi+2,:) = zwv(  4  ,:)
-         ELSE
-            zwv(  0  ,:) = 0.e0
-            zwv( -1  ,:) = 0.e0
-            zwv(jpi+1,:) = 0.e0
-            zwv(jpi+2,:) = 0.e0
-         ENDIF
-
-         ! North-South boundary conditions
-         IF( nperio == 3 .OR. nperio == 4 ) THEN
-            ! north fold ( Grid defined with a T-point pivot) ORCA 2 degre
-            zwu(jpi,jpj+1) = 0.e0
-            zwu(jpi,jpj+2) = 0.e0
-            DO ji = 1, jpi-1
-               iju = jpi - ji + 1
-               zwu(ji,jpj+1) = - zwu(iju,jpj-3)
-               zwu(ji,jpj+2) = - zwu(iju,jpj-4)
-            END DO
-         ELSEIF( nperio == 5 .OR. nperio == 6 ) THEN
-            ! north fold ( Grid defined with a F-point pivot) ORCA 0.5 degre\
-            zwu(jpi,jpj+1) = 0.e0
-            zwu(jpi,jpj+2) = 0.e0
-            DO ji = 1, jpi-1
-               iju = jpi - ji
-               zwu(ji,jpj  ) = - zwu(iju,jpj-1)
-               zwu(ji,jpj+1) = - zwu(iju,jpj-2)
-               zwu(ji,jpj+2) = - zwu(iju,jpj-3)
-            END DO
-            DO ji = -1, jpi+2
-               ijt = jpi - ji + 1
-               zwv(ji,jpj) = - zwv(ijt,jpj-2)
-            END DO
-            DO ji = jpi/2+1, jpi+2
-               ijt = jpi - ji + 1
-               zwv(ji,jpjm1) = - zwv(ijt,jpjm1)
-            END DO
-         ELSE
-            ! closed
-            zwu(:,jpj+1) = 0.e0
-            zwu(:,jpj+2) = 0.e0
-         ENDIF
-
-         ! relative vorticity (vertical component of the velocity curl) 
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               rotn(ji,jj,jk) = (  zwv(ji+1,jj  ) - zwv(ji,jj)      &
-                  &              - zwu(ji  ,jj+1) + zwu(ji,jj)  ) * fmask(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) )
-            END DO
-         END DO
-
-         ! second order accurate scheme along straight coast
-         DO jl = 1, npcoa(1,jk)
-            ii = nicoa(jl,1,jk)
-            ij = njcoa(jl,1,jk)
-            rotn(ii,ij,jk) = 1. / ( e1f(ii,ij) * e2f(ii,ij) )   &
-                           * ( + 4. * zwv(ii+1,ij) - zwv(ii+2,ij) + 0.2 * zwv(ii+3,ij) )
-         END DO
-         DO jl = 1, npcoa(2,jk)
-            ii = nicoa(jl,2,jk)
-            ij = njcoa(jl,2,jk)
-            rotn(ii,ij,jk) = 1./(e1f(ii,ij)*e2f(ii,ij))   &
-               *(-4.*zwv(ii,ij)+zwv(ii-1,ij)-0.2*zwv(ii-2,ij))
-         END DO
-         DO jl = 1, npcoa(3,jk)
-            ii = nicoa(jl,3,jk)
-            ij = njcoa(jl,3,jk)
-            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
-               * ( +4. * zwu(ii,ij+1) - zwu(ii,ij+2) + 0.2 * zwu(ii,ij+3) )
-         END DO
-         DO jl = 1, npcoa(4,jk)
-            ii = nicoa(jl,4,jk)
-            ij = njcoa(jl,4,jk)
-            rotn(ii,ij,jk) = -1. / ( e1f(ii,ij)*e2f(ii,ij) )   &
-               * ( -4. * zwu(ii,ij) + zwu(ii,ij-1) - 0.2 * zwu(ii,ij-2) )
-         END DO
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-
-      IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )          ! runoffs   (update hdivn field)
-      IF( ln_divisf .AND. (nn_isf /= 0) )   CALL sbc_isf_div( hdivn )          ! ice shelf (update hdivn field)
-      IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (Update Hor. divergence)
-      
-      ! 4. Lateral boundary conditions on hdivn and rotn
-      ! ---------------------------------=======---======
-      CALL lbc_lnk( hdivn, 'T', 1. )   ;   CALL lbc_lnk( rotn , 'F', 1. )    ! lateral boundary cond. (no sign change)
-      !
-      CALL wrk_dealloc( jpi  , jpj+2, zwu               )
-      CALL wrk_dealloc( jpi+4, jpj  , zwv, kistart = -1 )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('div_cur')
-      !
-   END SUBROUTINE div_cur
-   
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                           2nd order centered schemes
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE div_cur( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE div_cur  ***
-      !!                    
-      !! ** Purpose :   compute the horizontal divergence and the relative
-      !!      vorticity at before and now time-step
-      !!
-      !! ** Method  : - Divergence:
-      !!      - save the divergence computed at the previous time-step
-      !!      (note that the Asselin filter has not been applied on hdivb)
-      !!      - compute the now divergence given by :
-      !!         hdivn = 1/(e1t*e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
-      !!      correct hdiv with runoff inflow (div_rnf) and cross land flow (div_cla) 
-      !!              - Relavtive Vorticity :
-      !!      - save the curl computed at the previous time-step (rotb = rotn)
-      !!      (note that the Asselin time filter has not been applied to rotb)
-      !!      - compute the now curl in tensorial formalism:
-      !!            rotn = 1/(e1f*e2f) ( di[e2v vn] - dj[e1u un] )
-      !!      Note: Coastal boundary condition: lateral friction set through
-      !!      the value of fmask along the coast (see dommsk.F90) and shlat
-      !!      (namelist parameter)
-      !!
-      !! ** Action  : - update hdivb, hdivn, the before & now hor. divergence
-      !!              - update rotb , rotn , the before & now rel. vorticity
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !
-      INTEGER  ::   ji, jj, jk    ! dummy loop indices
-      REAL(wp) ::   zraur, zdep   ! local scalars
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('div_cur')
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'div_cur : horizontal velocity divergence and'
-         IF(lwp) WRITE(numout,*) '~~~~~~~   relative vorticity'
-      ENDIF
-
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         !
-         hdivb(:,:,jk) = hdivn(:,:,jk)    ! time swap of div arrays
-         rotb (:,:,jk) = rotn (:,:,jk)    ! time swap of rot arrays
-         !
-         !                                             ! --------
-         ! Horizontal divergence                       !   div 
-         !                                             ! --------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               hdivn(ji,jj,jk) =   &
-                  (  e2u(ji,jj)*fse3u(ji,jj,jk) * un(ji,jj,jk) - e2u(ji-1,jj)*fse3u(ji-1,jj,jk) * un(ji-1,jj,jk)       &
-                   + e1v(ji,jj)*fse3v(ji,jj,jk) * vn(ji,jj,jk) - e1v(ji,jj-1)*fse3v(ji,jj-1,jk) * vn(ji,jj-1,jk)  )    &
-                  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-            END DO  
-         END DO  
-
-         IF( .NOT. AGRIF_Root() ) THEN
-            IF ((nbondi ==  1).OR.(nbondi == 2)) hdivn(nlci-1 , :     ,jk) = 0.e0      ! east
-            IF ((nbondi == -1).OR.(nbondi == 2)) hdivn(2      , :     ,jk) = 0.e0      ! west
-            IF ((nbondj ==  1).OR.(nbondj == 2)) hdivn(:      ,nlcj-1 ,jk) = 0.e0      ! north
-            IF ((nbondj == -1).OR.(nbondj == 2)) hdivn(:      ,2      ,jk) = 0.e0      ! south
-         ENDIF
-
-         !                                             ! --------
-         ! relative vorticity                          !   rot 
-         !                                             ! --------
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               rotn(ji,jj,jk) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
-                  &              - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
-                  &           * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
-            END DO
-         END DO
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-
-      IF( ln_rnf      )   CALL sbc_rnf_div( hdivn )                            ! runoffs (update hdivn field)
-      IF( ln_divisf .AND. (nn_isf .GT. 0) )   CALL sbc_isf_div( hdivn )          ! ice shelf (update hdivn field)
-      IF( nn_cla == 1 )   CALL cla_div    ( kt )             ! Cross Land Advection (update hdivn field)
-      !
-      CALL lbc_lnk( hdivn, 'T', 1. )   ;   CALL lbc_lnk( rotn , 'F', 1. )     ! lateral boundary cond. (no sign change)
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('div_cur')
-      !
-   END SUBROUTINE div_cur
-   
-#endif
-   !!======================================================================
-END MODULE divcur
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/divhor.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/divhor.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/divhor.F90	(revision 6041)
@@ -0,0 +1,102 @@
+MODULE divhor
+   !!==============================================================================
+   !!                       ***  MODULE  divhor  ***
+   !! Ocean diagnostic variable : now horizontal divergence
+   !!==============================================================================
+   !! History :  1.0  ! 2002-09  (G. Madec, E. Durand)  Free form, F90
+   !!             -   ! 2005-01  (J. Chanut) Unstructured open boundaries
+   !!             -   ! 2003-08  (G. Madec)  merged of cur and div, free form, F90
+   !!             -   ! 2005-01  (J. Chanut, A. Sellar) unstructured open boundaries
+   !!            3.3  ! 2010-09  (D.Storkey and E.O'Dea) bug fixes for BDY module
+   !!             -   ! 2010-10  (R. Furner, G. Madec) runoff and cla added directly here
+   !!            3.7  ! 2014-01  (G. Madec) suppression of velocity curl from in-core memory
+   !!             -   ! 2014-12  (G. Madec) suppression of cross land advection option
+   !!             -   ! 2015-10  (G. Madec) add velocity and rnf flag in argument of div_hor
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   div_hor    : Compute the horizontal divergence field
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and tracers
+   USE dom_oce         ! ocean space and time domain
+   USE sbc_oce, ONLY : ln_rnf, nn_isf ! surface boundary condition: ocean
+   USE sbcrnf          ! river runoff 
+   USE sbcisf          ! ice shelf
+   !
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
+   USE wrk_nemo        ! Memory Allocation
+   USE timing          ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   div_hor    ! routine called by step.F90 and istate.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE div_hor( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE div_hor  ***
+      !!                    
+      !! ** Purpose :   compute the horizontal divergence at now time-step
+      !!
+      !! ** Method  :   the now divergence is computed as :
+      !!         hdivn = 1/(e1e2t*e3t) ( di[e2u*e3u un] + dj[e1v*e3v vn] )
+      !!      and correct with runoff inflow (div_rnf) and cross land flow (div_cla) 
+      !!
+      !! ** Action  : - update hdivn, the now horizontal divergence
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
+      !
+      INTEGER  ::   ji, jj, jk    ! dummy loop indices
+      REAL(wp) ::   zraur, zdep   ! local scalars
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('div_hor')
+      !
+      IF( kt == nit000 ) THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'div_hor : horizontal velocity divergence '
+         IF(lwp) WRITE(numout,*) '~~~~~~~   '
+      ENDIF
+      !
+      DO jk = 1, jpkm1                                      !==  Horizontal divergence  ==!
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               hdivn(ji,jj,jk) = (  e2u(ji  ,jj) * fse3u_n(ji  ,jj,jk) * un(ji  ,jj,jk)        &
+                  &               - e2u(ji-1,jj) * fse3u_n(ji-1,jj,jk) * un(ji-1,jj,jk)        &
+                  &               + e1v(ji,jj  ) * fse3v_n(ji,jj  ,jk) * vn(ji,jj  ,jk)        &
+                  &               - e1v(ji,jj-1) * fse3v_n(ji,jj-1,jk) * vn(ji,jj-1,jk)   )    &
+                  &            / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
+            END DO  
+         END DO  
+         IF( .NOT. AGRIF_Root() ) THEN
+            IF( nbondi ==  1 .OR. nbondi == 2 )   hdivn(nlci-1,   :  ,jk) = 0._wp      ! east
+            IF( nbondi == -1 .OR. nbondi == 2 )   hdivn(  2   ,   :  ,jk) = 0._wp      ! west
+            IF( nbondj ==  1 .OR. nbondj == 2 )   hdivn(  :   ,nlcj-1,jk) = 0._wp      ! north
+            IF( nbondj == -1 .OR. nbondj == 2 )   hdivn(  :   ,  2   ,jk) = 0._wp      ! south
+         ENDIF
+      END DO
+      !
+      IF( ln_rnf                     )   CALL sbc_rnf_div( hdivn )      !==  runoffs    ==!   (update hdivn field)
+      !
+      IF( ln_divisf .AND. nn_isf > 0 )   CALL sbc_isf_div( hdivn )      !==  ice shelf  ==!   (update hdivn field)
+      !
+      CALL lbc_lnk( hdivn, 'T', 1. )                       !==  lateral boundary cond.  ==!   (no sign change)
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('div_hor')
+      !
+   END SUBROUTINE div_hor
+   
+   !!======================================================================
+END MODULE divhor
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv.F90	(revision 6041)
@@ -76,10 +76,4 @@
       CASE ( 3 )   
                       CALL dyn_adv_ubs ( kt )               ! 3rd order UBS      scheme
-      !
-      CASE (-1 )                                            ! esopa: test all possibility with control print
-                      CALL dyn_keg     ( kt, nn_dynkeg )
-                      CALL dyn_zad     ( kt )
-                      CALL dyn_adv_cen2( kt )
-                      CALL dyn_adv_ubs ( kt )
       END SELECT
       !
@@ -126,5 +120,4 @@
       IF( ln_dynadv_cen2 )   ioptio = ioptio + 1
       IF( ln_dynadv_ubs  )   ioptio = ioptio + 1
-      IF( lk_esopa       )   ioptio =          1
 
       IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE advection scheme in namelist namdyn_adv' )
@@ -139,5 +132,4 @@
       IF( ln_dynadv_cen2 )   nadv =  2
       IF( ln_dynadv_ubs  )   nadv =  3
-      IF( lk_esopa       )   nadv = -1
 
       IF(lwp) THEN                    ! Print the choice
@@ -151,5 +143,4 @@
          IF( nadv ==  2 )   WRITE(numout,*) '         flux form   : 2nd order scheme is used'
          IF( nadv ==  3 )   WRITE(numout,*) '         flux form   : UBS       scheme is used'
-         IF( nadv == -1 )   WRITE(numout,*) '         esopa test: use all advection formulation'
       ENDIF
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_cen2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_cen2.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_cen2.F90	(revision 6041)
@@ -90,6 +90,6 @@
          DO jj = 2, jpjm1                          ! divergence of horizontal momentum fluxes
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+               zbu = e1e2u(ji,jj) * fse3u(ji,jj,jk)
+               zbv = e1e2v(ji,jj) * fse3v(ji,jj,jk)
                !
                ua(ji,jj,jk) = ua(ji,jj,jk) - (  zfu_t(ji+1,jj  ,jk) - zfu_t(ji  ,jj  ,jk)    &
@@ -114,5 +114,5 @@
       DO jk = 1, jpkm1                       ! ==================== !
          !                                         ! Vertical volume fluxesÊ
-         zfw(:,:,jk) = 0.25 * e1t(:,:) * e2t(:,:) * wn(:,:,jk)
+         zfw(:,:,jk) = 0.25 * e1e2t(:,:) * wn(:,:,jk)
          !
          IF( jk == 1 ) THEN                        ! surface/bottom advective fluxes                   
@@ -144,7 +144,7 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ua(ji,jj,jk) =  ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) )    &
-                  &  / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
+                  &  / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
                va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) )    &
-                  &  / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+                  &  / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
             END DO
          END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 6041)
@@ -181,6 +181,6 @@
          DO jj = 2, jpjm1                          ! divergence of horizontal momentum fluxes
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
+               zbu = e1e2u(ji,jj) * fse3u(ji,jj,jk)
+               zbv = e1e2v(ji,jj) * fse3v(ji,jj,jk)
                !
                ua(ji,jj,jk) = ua(ji,jj,jk) - (  zfu_t(ji+1,jj  ,jk) - zfu_t(ji  ,jj  ,jk)    &
@@ -203,5 +203,5 @@
       DO jk = 1, jpkm1                       ! ==================== !
          !                                         ! Vertical volume fluxesÊ
-         zfw(:,:,jk) = 0.25 * e1t(:,:) * e2t(:,:) * wn(:,:,jk)
+         zfw(:,:,jk) = 0.25 * e1e2t(:,:) * wn(:,:,jk)
          !
          IF( jk == 1 ) THEN                        ! surface/bottom advective fluxes                   
@@ -233,7 +233,7 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ua(ji,jj,jk) =  ua(ji,jj,jk) - ( zfu_uw(ji,jj,jk) - zfu_uw(ji,jj,jk+1) )    &
-                  &  / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
+                  &  / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
                va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) )    &
-                  &  / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+                  &  / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
             END DO
          END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90	(revision 6041)
@@ -36,4 +36,5 @@
    USE trd_oce         ! trends: ocean variables
    USE trddyn          ! trend manager: dynamics
+!jc   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
    !
    USE in_out_manager  ! I/O manager
@@ -58,5 +59,4 @@
    LOGICAL , PUBLIC ::   ln_hpg_prj      !: s-coordinate (Pressure Jacobian scheme)
    LOGICAL , PUBLIC ::   ln_hpg_isf      !: s-coordinate similar to sco modify for isf
-   LOGICAL , PUBLIC ::   ln_dynhpg_imp   !: semi-implicite hpg flag
 
    INTEGER , PUBLIC ::   nhpg  =  0   ! = 0 to 7, type of pressure gradient scheme used ! (deduced from ln_hpg_... flags) (PUBLIC for TAM)
@@ -132,5 +132,5 @@
       !!
       NAMELIST/namdyn_hpg/ ln_hpg_zco, ln_hpg_zps, ln_hpg_sco,     &
-         &                 ln_hpg_djc, ln_hpg_prj, ln_hpg_isf, ln_dynhpg_imp
+         &                 ln_hpg_djc, ln_hpg_prj, ln_hpg_isf
       !!----------------------------------------------------------------------
       !
@@ -155,5 +155,4 @@
          WRITE(numout,*) '      s-coord. (Density Jacobian: Cubic polynomial)     ln_hpg_djc    = ', ln_hpg_djc
          WRITE(numout,*) '      s-coord. (Pressure Jacobian: Cubic polynomial)    ln_hpg_prj    = ', ln_hpg_prj
-         WRITE(numout,*) '      time stepping: centered (F) or semi-implicit (T)  ln_dynhpg_imp = ', ln_dynhpg_imp
       ENDIF
       !
@@ -293,4 +292,6 @@
       ENDIF
 
+      ! Partial steps: bottom before horizontal gradient of t, s, rd at the last ocean level
+!jc      CALL zps_hde    ( kt, jpts, tsn, gtsu, gtsv, rhd, gru , grv )
 
       ! Local constant initialization
@@ -491,4 +492,9 @@
       ! iniitialised to 0. zhpi zhpi 
       zhpi(:,:,:)=0._wp ; zhpj(:,:,:)=0._wp
+
+      ! Partial steps: top & bottom before horizontal gradient
+!jc      CALL zps_hde_isf( kt, jpts, tsn, gtsu, gtsv, gtui, gtvi,   & 
+!jc               &       rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
+!jc               &      grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi  )
 
 !==================================================================================     
@@ -1046,8 +1052,8 @@
       DO jj = 2, jpjm1
         DO ji = 2, jpim1
-          zsshu_n(ji,jj) = (e12u(ji,jj) * sshn(ji,jj) + e12u(ji+1, jj) * sshn(ji+1,jj)) * &
-                         & r1_e12u(ji,jj) * umask(ji,jj,1) * 0.5_wp 
-          zsshv_n(ji,jj) = (e12v(ji,jj) * sshn(ji,jj) + e12v(ji+1, jj) * sshn(ji,jj+1)) * &
-                         & r1_e12v(ji,jj) * vmask(ji,jj,1) * 0.5_wp 
+          zsshu_n(ji,jj) = (e1e2u(ji,jj) * sshn(ji,jj) + e1e2u(ji+1, jj) * sshn(ji+1,jj)) * &
+                         & r1_e1e2u(ji,jj) * umask(ji,jj,1) * 0.5_wp 
+          zsshv_n(ji,jj) = (e1e2v(ji,jj) * sshn(ji,jj) + e1e2v(ji+1, jj) * sshn(ji,jj+1)) * &
+                         & r1_e1e2v(ji,jj) * vmask(ji,jj,1) * 0.5_wp 
         END DO
       END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf.F90	(revision 6041)
@@ -4,5 +4,7 @@
    !! Ocean physics:  lateral diffusivity trends 
    !!=====================================================================
-   !! History :  9.0  !  05-11  (G. Madec)  Original code (new step architecture)
+   !! History :  2.0  ! 2005-11  (G. Madec)  Original code (new step architecture)
+   !!            3.7  ! 2014-01  (F. Lemarie, G. Madec)  restructuration/simplification of ahm specification,
+   !!                 !                                  add velocity dependent coefficient and optional read in file
    !!----------------------------------------------------------------------
 
@@ -14,13 +16,10 @@
    USE dom_oce        ! ocean space and time domain
    USE phycst         ! physical constants
-   USE ldfdyn_oce     ! ocean dynamics lateral physics
-   USE ldftra_oce     ! ocean tracers  lateral physics
-   USE ldfslp         ! lateral mixing: slopes of mixing orientation
-   USE dynldf_bilapg  ! lateral mixing            (dyn_ldf_bilapg routine)
-   USE dynldf_bilap   ! lateral mixing            (dyn_ldf_bilap  routine)
-   USE dynldf_iso     ! lateral mixing            (dyn_ldf_iso    routine)
-   USE dynldf_lap     ! lateral mixing            (dyn_ldf_lap    routine)
+   USE ldfdyn         ! lateral diffusion: eddy viscosity coef.
+   USE ldfslp         ! lateral diffusion: slopes of mixing orientation
+   USE dynldf_lap_blp ! lateral mixing   (dyn_ldf_lap & dyn_ldf_blp routines)
+   USE dynldf_iso     ! lateral mixing                 (dyn_ldf_iso routine )
    USE trd_oce        ! trends: ocean variables
-   USE trddyn         ! trend manager: dynamics   (trd_dyn        routine)
+   USE trddyn         ! trend manager: dynamics   (trd_dyn      routine)
    !
    USE prtctl         ! Print control
@@ -28,6 +27,6 @@
    USE lib_mpp        ! distribued memory computing library
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
 
    IMPLICIT NONE
@@ -37,5 +36,12 @@
    PUBLIC   dyn_ldf_init  ! called by opa  module 
 
-   INTEGER ::   nldf = -2   ! type of lateral diffusion used defined from ln_dynldf_... namlist logicals)
+   !                      ! Flag to control the type of lateral viscous operator
+   INTEGER, PARAMETER, PUBLIC ::   np_ERROR  =-10   ! error in setting the operator
+   INTEGER, PARAMETER, PUBLIC ::   np_no_ldf = 00   ! without operator (i.e. no lateral viscous trend)
+   !                          !!      laplacian     !    bilaplacian    !
+   INTEGER, PARAMETER, PUBLIC ::   np_lap    = 10   ,   np_blp    = 20  ! iso-level operator
+   INTEGER, PARAMETER, PUBLIC ::   np_lap_i  = 11                       ! iso-neutral or geopotential operator
+
+   INTEGER ::   nldf   ! type of lateral diffusion used defined from ln_dynldf_... (namlist logicals)
 
    !! * Substitutions
@@ -43,5 +49,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -62,6 +68,6 @@
       IF( nn_timing == 1 )  CALL timing_start('dyn_ldf')
       !
-      IF( l_trddyn )   THEN                      ! temporary save of ta and sa trends
-         CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
+      IF( l_trddyn )   THEN                      ! temporary save of momentum trends
+         CALL wrk_alloc( jpi,jpj,jpk,   ztrdu, ztrdv )
          ztrdu(:,:,:) = ua(:,:,:) 
          ztrdv(:,:,:) = va(:,:,:) 
@@ -70,35 +76,8 @@
       SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
       !
-      CASE ( 0 )    ;   CALL dyn_ldf_lap    ( kt )      ! iso-level laplacian
-      CASE ( 1 )    ;   CALL dyn_ldf_iso    ( kt )      ! rotated laplacian (except dk[ dk[.] ] part)
-      CASE ( 2 )    ;   CALL dyn_ldf_bilap  ( kt )      ! iso-level bilaplacian
-      CASE ( 3 )    ;   CALL dyn_ldf_bilapg ( kt )      ! s-coord. horizontal bilaplacian
-      CASE ( 4 )                                        ! iso-level laplacian + bilaplacian
-         CALL dyn_ldf_lap    ( kt )
-         CALL dyn_ldf_bilap  ( kt )
-      CASE ( 5 )                                        ! rotated laplacian + bilaplacian (s-coord)
-         CALL dyn_ldf_iso    ( kt )
-         CALL dyn_ldf_bilapg ( kt )
+      CASE ( np_lap   )    ;   CALL dyn_ldf_lap  ( kt, ub, vb, ua, va, 1 )      ! iso-level    laplacian
+      CASE ( np_lap_i )    ;   CALL dyn_ldf_iso  ( kt )                         ! rotated      laplacian
+      CASE ( np_blp   )    ;   CALL dyn_ldf_blp  ( kt, ub, vb, ua, va    )      ! iso-level bi-laplacian
       !
-      CASE ( -1 )                                       ! esopa: test all possibility with control print
-                        CALL dyn_ldf_lap    ( kt )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf0 - Ua: ', mask1=umask,   &
-            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-                        CALL dyn_ldf_iso    ( kt )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf1 - Ua: ', mask1=umask,   &
-            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-                        CALL dyn_ldf_bilap  ( kt )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf2 - Ua: ', mask1=umask,   &
-            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-                        CALL dyn_ldf_bilapg ( kt )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' ldf3 - Ua: ', mask1=umask,   &
-            &                         tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-      !
-      CASE ( -2 )                                       ! neither laplacian nor bilaplacian schemes used
-         IF( kt == nit000 ) THEN
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) 'dyn_ldf : no lateral diffusion on momentum setup'
-            IF(lwp) WRITE(numout,*) '~~~~~~~ '
-         ENDIF
       END SELECT
 
@@ -107,5 +86,5 @@
          ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
          CALL trd_dyn( ztrdu, ztrdv, jpdyn_ldf, kt )
-         CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv )
+         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdu, ztrdv )
       ENDIF
       !                                          ! print sum trends (used for debugging)
@@ -126,7 +105,7 @@
       INTEGER ::   ioptio, ierr         ! temporary integers 
       !!----------------------------------------------------------------------
-    
+      !
       !                                   ! Namelist nam_dynldf: already read in ldfdyn module
-
+      !
       IF(lwp) THEN                        ! Namelist print
          WRITE(numout,*)
@@ -134,99 +113,76 @@
          WRITE(numout,*) '~~~~~~~~~~~'
          WRITE(numout,*) '       Namelist nam_dynldf : set lateral mixing parameters (type, direction, coefficients)'
-         WRITE(numout,*) '          laplacian operator          ln_dynldf_lap   = ', ln_dynldf_lap
-         WRITE(numout,*) '          bilaplacian operator        ln_dynldf_bilap = ', ln_dynldf_bilap
-         WRITE(numout,*) '          iso-level                   ln_dynldf_level = ', ln_dynldf_level
-         WRITE(numout,*) '          horizontal (geopotential)   ln_dynldf_hor   = ', ln_dynldf_hor
-         WRITE(numout,*) '          iso-neutral                 ln_dynldf_iso   = ', ln_dynldf_iso
+         WRITE(numout,*) '          laplacian operator          ln_dynldf_lap = ', ln_dynldf_lap
+         WRITE(numout,*) '          bilaplacian operator        ln_dynldf_blp = ', ln_dynldf_blp
+         WRITE(numout,*) '          iso-level                   ln_dynldf_lev = ', ln_dynldf_lev
+         WRITE(numout,*) '          horizontal (geopotential)   ln_dynldf_hor = ', ln_dynldf_hor
+         WRITE(numout,*) '          iso-neutral                 ln_dynldf_iso = ', ln_dynldf_iso
       ENDIF
-
-      !                                   ! control the consistency
+      !                                   ! use of lateral operator or not
+      nldf = np_ERROR
       ioptio = 0
-      IF( ln_dynldf_lap   )   ioptio = ioptio + 1
-      IF( ln_dynldf_bilap )   ioptio = ioptio + 1
-      IF( ioptio <  1 ) CALL ctl_warn( '          neither laplacian nor bilaplacian operator set for dynamics' )
-      ioptio = 0
-      IF( ln_dynldf_level )   ioptio = ioptio + 1
-      IF( ln_dynldf_hor   )   ioptio = ioptio + 1
-      IF( ln_dynldf_iso   )   ioptio = ioptio + 1
-      IF( ioptio >  1 ) CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
-
-      IF( ln_dynldf_iso .AND. ln_traldf_hor ) CALL ctl_stop &
-      &   ( 'Not sensible to use geopotential diffusion for tracers with isoneutral diffusion for dynamics' )
-
-      !                                   ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
-      ierr = 0
-      IF ( ln_dynldf_lap ) THEN      ! laplacian operator
-         IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_dynldf_level )   nldf = 0      ! iso-level  (no rotation)
-            IF ( ln_dynldf_hor   )   nldf = 0      ! horizontal (no rotation)
-            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+      IF( ln_dynldf_lap )   ioptio = ioptio + 1
+      IF( ln_dynldf_blp )   ioptio = ioptio + 1
+      IF( ioptio >  1   )   CALL ctl_stop( 'dyn_ldf_init: use ONE or NONE of the 2 lap/bilap operator type on momentum' )
+      IF( ioptio == 0   )   nldf = np_no_ldf     ! No lateral mixing operator
+      !
+      IF( nldf /= np_no_ldf ) THEN        ! direction ==>> type of operator  
+         ioptio = 0
+         IF( ln_dynldf_lev )   ioptio = ioptio + 1
+         IF( ln_dynldf_hor )   ioptio = ioptio + 1
+         IF( ln_dynldf_iso )   ioptio = ioptio + 1
+         IF( ioptio >  1   )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
+         IF( ioptio == 0   )   CALL ctl_stop( '          use at least ONE direction (level/hor/iso)' )
+         !
+         !                                   ! Set nldf, the type of lateral diffusion, from ln_dynldf_... logicals
+         ierr = 0
+         IF ( ln_dynldf_lap ) THEN      ! laplacian operator
+            IF ( ln_zco ) THEN                ! z-coordinate
+               IF ( ln_dynldf_lev )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+               IF ( ln_dynldf_hor )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+               IF ( ln_dynldf_iso )   nldf = np_lap_i   ! iso-neutral            (   rotation)
+            ENDIF
+            IF ( ln_zps ) THEN             ! z-coordinate with partial step
+               IF ( ln_dynldf_lev )   nldf = np_lap     ! iso-level              (no rotation)
+               IF ( ln_dynldf_hor )   nldf = np_lap     ! iso-level              (no rotation)
+               IF ( ln_dynldf_iso )   nldf = np_lap_i   ! iso-neutral            (   rotation)
+            ENDIF
+            IF ( ln_sco ) THEN             ! s-coordinate
+               IF ( ln_dynldf_lev )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+               IF ( ln_dynldf_hor )   nldf = np_lap_i   ! horizontal             (   rotation)
+               IF ( ln_dynldf_iso )   nldf = np_lap_i   ! iso-neutral            (   rotation)
+            ENDIF
          ENDIF
-         IF ( ln_zps ) THEN             ! z-coordinate
-            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed
-            IF ( ln_dynldf_hor   )   nldf = 0      ! horizontal (no rotation)
-            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         !
+         IF( ln_dynldf_blp ) THEN          ! bilaplacian operator
+            IF ( ln_zco ) THEN                ! z-coordinate
+               IF ( ln_dynldf_lev )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+               IF ( ln_dynldf_hor )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+               IF ( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
+            ENDIF
+            IF ( ln_zps ) THEN             ! z-coordinate with partial step
+               IF ( ln_dynldf_lev )   nldf = np_blp     ! iso-level              (no rotation)
+               IF ( ln_dynldf_hor )   nldf = np_blp     ! iso-level              (no rotation)
+               IF ( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
+            ENDIF
+            IF ( ln_sco ) THEN             ! s-coordinate
+               IF ( ln_dynldf_lev )   nldf = np_blp     ! iso-level              (no rotation)
+               IF ( ln_dynldf_hor )   ierr = 2          ! horizontal             (   rotation)
+               IF ( ln_dynldf_iso )   ierr = 2          ! iso-neutral            (   rotation)
+            ENDIF
          ENDIF
-         IF ( ln_sco ) THEN             ! s-coordinate
-            IF ( ln_dynldf_level )   nldf = 0      ! iso-level  (no rotation)
-            IF ( ln_dynldf_hor   )   nldf = 1      ! horizontal (   rotation)
-            IF ( ln_dynldf_iso   )   nldf = 1      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-
-      IF( ln_dynldf_bilap ) THEN      ! bilaplacian operator
-         IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_dynldf_level )   nldf = 2      ! iso-level  (no rotation)
-            IF ( ln_dynldf_hor   )   nldf = 2      ! horizontal (no rotation)
-            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_zps ) THEN             ! z-coordinate
-            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed 
-            IF ( ln_dynldf_hor   )   nldf = 2      ! horizontal (no rotation)
-            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_sco ) THEN             ! s-coordinate
-            IF ( ln_dynldf_level )   nldf = 2      ! iso-level  (no rotation)
-            IF ( ln_dynldf_hor   )   nldf = 3      ! horizontal (   rotation)
-            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-      
-      IF( ln_dynldf_lap .AND. ln_dynldf_bilap ) THEN  ! mixed laplacian and bilaplacian operators
-         IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_dynldf_level )   nldf = 4      ! iso-level  (no rotation)
-            IF ( ln_dynldf_hor   )   nldf = 4      ! horizontal (no rotation)
-            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_zps ) THEN             ! z-coordinate
-            IF ( ln_dynldf_level )   ierr = 1      ! iso-level not allowed 
-            IF ( ln_dynldf_hor   )   nldf = 4      ! horizontal (no rotation)
-            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_sco ) THEN             ! s-coordinate
-            IF ( ln_dynldf_level )   nldf = 4      ! iso-level  (no rotation)
-            IF ( ln_dynldf_hor   )   nldf = 5      ! horizontal (   rotation)
-            IF ( ln_dynldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-
-      IF( lk_esopa )                 nldf = -1     ! esopa test
-
-      IF( ierr == 1 )   CALL ctl_stop( 'iso-level in z-coordinate - partial step, not allowed' )
-      IF( ierr == 2 )   CALL ctl_stop( 'isoneutral bilaplacian operator does not exist' )
-      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
-         IF( .NOT.lk_ldfslp )   CALL ctl_stop( 'the rotation of the diffusive tensor require key_ldfslp' )
+         !
+         IF( ierr == 2 )   CALL ctl_stop( 'rotated bi-laplacian operator does not exist' )
+         !
+         IF( nldf == np_lap_i )   l_ldfslp = .TRUE.      ! rotation require the computation of the slopes
+         !
       ENDIF
 
       IF(lwp) THEN
          WRITE(numout,*)
-         IF( nldf == -2 )   WRITE(numout,*) '              neither laplacian nor bilaplacian schemes used'
-         IF( nldf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
-         IF( nldf ==  0 )   WRITE(numout,*) '              laplacian operator'
-         IF( nldf ==  1 )   WRITE(numout,*) '              rotated laplacian operator'
-         IF( nldf ==  2 )   WRITE(numout,*) '              bilaplacian operator'
-         IF( nldf ==  3 )   WRITE(numout,*) '              rotated bilaplacian'
-         IF( nldf ==  4 )   WRITE(numout,*) '              laplacian and bilaplacian operators'
-         IF( nldf ==  5 )   WRITE(numout,*) '              rotated laplacian and bilaplacian operators'
+         IF( nldf == np_no_ldf )   WRITE(numout,*) '              NO lateral viscosity'
+         IF( nldf == np_lap    )   WRITE(numout,*) '              iso-level laplacian operator'
+         IF( nldf == np_lap_i  )   WRITE(numout,*) '              rotated laplacian operator with iso-level background'
+         IF( nldf == np_blp    )   WRITE(numout,*) '              iso-level bi-laplacian operator'
       ENDIF
       !
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilap.F90	(revision 6040)
+++ 	(revision )
@@ -1,215 +1,0 @@
-MODULE dynldf_bilap
-   !!======================================================================
-   !!                     ***  MODULE  dynldf_bilap  ***
-   !! Ocean dynamics:  lateral viscosity trend
-   !!======================================================================
-   !! History :  OPA  ! 1990-09  (G. Madec)  Original code
-   !!            4.0  ! 1993-03  (M. Guyon)  symetrical conditions (M. Guyon)
-   !!            6.0  ! 1996-01  (G. Madec)  statement function for e3
-   !!            8.0  ! 1997-07  (G. Madec)  lbc calls
-   !!   NEMO     1.0  ! 2002-08  (G. Madec)  F90: Free form and module
-   !!            2.0  ! 2004-08  (C. Talandier) New trends organization
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   dyn_ldf_bilap : update the momentum trend with the lateral diffusion
-   !!                   using an iso-level bilaplacian operator
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE ldfdyn_oce      ! ocean dynamics: lateral physics
-   !
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   dyn_ldf_bilap   ! called by step.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldfdyn_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE dyn_ldf_bilap( kt )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE dyn_ldf_bilap  ***
-      !!
-      !! ** Purpose :   Compute the before trend of the lateral momentum
-      !!      diffusion and add it to the general trend of momentum equation.
-      !!
-      !! ** Method  :   The before horizontal momentum diffusion trend is a 
-      !!      bi-harmonic operator (bilaplacian type) which separates the
-      !!      divergent and rotational parts of the flow.
-      !!      Its horizontal components are computed as follow:
-      !!      laplacian:
-      !!          zlu = 1/e1u di[ hdivb ] - 1/(e2u*e3u) dj-1[ e3f rotb ]
-      !!          zlv = 1/e2v dj[ hdivb ] + 1/(e1v*e3v) di-1[ e3f rotb ]
-      !!      third derivative:
-      !!       * multiply by the eddy viscosity coef. at u-, v-point, resp.
-      !!          zlu = ahmu * zlu
-      !!          zlv = ahmv * zlv
-      !!       * curl and divergence of the laplacian
-      !!          zuf = 1/(e1f*e2f) ( di[e2v zlv] - dj[e1u zlu] )
-      !!          zut = 1/(e1t*e2t*e3t) ( di[e2u*e3u zlu] + dj[e1v*e3v zlv] )
-      !!      bilaplacian:
-      !!              diffu = 1/e1u di[ zut ] - 1/(e2u*e3u) dj-1[ e3f zuf ]
-      !!              diffv = 1/e2v dj[ zut ] + 1/(e1v*e3v) di-1[ e3f zuf ]
-      !!      If ln_sco=F and ln_zps=F, the vertical scale factors in the
-      !!      rotational part of the diffusion are simplified
-      !!      Add this before trend to the general trend (ua,va):
-      !!            (ua,va) = (ua,va) + (diffu,diffv)
-      !!
-      !! ** Action : - Update (ua,va) with the before iso-level biharmonic
-      !!               mixing trend.
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !
-      INTEGER  ::   ji, jj, jk                  ! dummy loop indices
-      REAL(wp) ::   zua, zva, zbt, ze2u, ze2v   ! temporary scalar
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zcu, zcv
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zuf, zut, zlu, zlv
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dyn_ldf_bilap')
-      !
-      CALL wrk_alloc( jpi, jpj,      zcu, zcv           )
-      CALL wrk_alloc( jpi, jpj, jpk, zuf, zut, zlu, zlv ) 
-      !
-      IF( kt == nit000 .AND. lwp ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'dyn_ldf_bilap : iso-level bilaplacian operator'
-         WRITE(numout,*) '~~~~~~~~~~~~~'
-      ENDIF
-
-!!bug gm this should be enough
-!!$      zuf(:,:,jpk) = 0.e0
-!!$      zut(:,:,jpk) = 0.e0
-!!$      zlu(:,:,jpk) = 0.e0
-!!$      zlv(:,:,jpk) = 0.e0
-      zuf(:,:,:) = 0._wp
-      zut(:,:,:) = 0._wp
-      zlu(:,:,:) = 0._wp
-      zlv(:,:,:) = 0._wp
-
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         ! Laplacian
-         ! ---------
-
-         IF( ln_sco .OR. ln_zps ) THEN   ! s-coordinate or z-coordinate with partial steps
-            zuf(:,:,jk) = rotb(:,:,jk) * fse3f(:,:,jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zlu(ji,jj,jk) = - ( zuf(ji,jj,jk) - zuf(ji,jj-1,jk) ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
-                     &         + ( hdivb(ji+1,jj,jk) - hdivb(ji,jj,jk) ) / e1u(ji,jj)
-   
-                  zlv(ji,jj,jk) = + ( zuf(ji,jj,jk) - zuf(ji-1,jj,jk) ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
-                     &         + ( hdivb(ji,jj+1,jk) - hdivb(ji,jj,jk) ) / e2v(ji,jj)
-               END DO
-            END DO
-         ELSE                            ! z-coordinate - full step
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zlu(ji,jj,jk) = - ( rotb (ji  ,jj,jk) - rotb (ji,jj-1,jk) ) / e2u(ji,jj)   &
-                     &         + ( hdivb(ji+1,jj,jk) - hdivb(ji,jj  ,jk) ) / e1u(ji,jj)
-   
-                  zlv(ji,jj,jk) = + ( rotb (ji,jj  ,jk) - rotb (ji-1,jj,jk) ) / e1v(ji,jj)   &
-                     &         + ( hdivb(ji,jj+1,jk) - hdivb(ji  ,jj,jk) ) / e2v(ji,jj)
-               END DO  
-            END DO  
-         ENDIF
-      END DO
-      CALL lbc_lnk( zlu, 'U', -1. )   ;   CALL lbc_lnk( zlv, 'V', -1. )   ! Boundary conditions
-
-         
-      DO jk = 1, jpkm1
-   
-         ! Third derivative
-         ! ----------------
-         
-         ! Multiply by the eddy viscosity coef. (at u- and v-points)
-         zlu(:,:,jk) = zlu(:,:,jk) * ( fsahmu(:,:,jk) * (1-nkahm_smag) + nkahm_smag)
-
-         zlv(:,:,jk) = zlv(:,:,jk) * ( fsahmv(:,:,jk) * (1-nkahm_smag) + nkahm_smag)
-         
-         ! Contravariant "laplacian"
-         zcu(:,:) = e1u(:,:) * zlu(:,:,jk)
-         zcv(:,:) = e2v(:,:) * zlv(:,:,jk)
-         
-         ! Laplacian curl ( * e3f if s-coordinates or z-coordinate with partial steps)
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zuf(ji,jj,jk) = fmask(ji,jj,jk) * (  zcv(ji+1,jj  ) - zcv(ji,jj)      &
-                  &                            - zcu(ji  ,jj+1) + zcu(ji,jj)  )   &
-                  &       * fse3f(ji,jj,jk) / ( e1f(ji,jj)*e2f(ji,jj) )
-            END DO  
-         END DO  
-
-         ! Laplacian Horizontal fluxes
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zlu(ji,jj,jk) = e2u(ji,jj) * fse3u(ji,jj,jk) * zlu(ji,jj,jk)
-               zlv(ji,jj,jk) = e1v(ji,jj) * fse3v(ji,jj,jk) * zlv(ji,jj,jk)
-            END DO
-         END DO
-
-         ! Laplacian divergence
-         DO jj = 2, jpj
-            DO ji = fs_2, jpi   ! vector opt.
-               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk)
-               zut(ji,jj,jk) = (  zlu(ji,jj,jk) - zlu(ji-1,jj  ,jk)   &
-                  &             + zlv(ji,jj,jk) - zlv(ji  ,jj-1,jk) ) / zbt
-            END DO
-         END DO
-      END DO
-
-
-      ! boundary conditions on the laplacian curl and div (zuf,zut)
-!!bug gm no need to do this 2 following lbc...
-      CALL lbc_lnk( zuf, 'F', 1. )
-      CALL lbc_lnk( zut, 'T', 1. )
-
-      DO jk = 1, jpkm1      
-   
-         ! Bilaplacian
-         ! -----------
-
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ze2u = e2u(ji,jj) * fse3u(ji,jj,jk)
-               ze2v = e1v(ji,jj) * fse3v(ji,jj,jk)
-               ! horizontal biharmonic diffusive trends
-               zua = - ( zuf(ji  ,jj,jk) - zuf(ji,jj-1,jk) ) / ze2u   &
-                  &  + ( zut(ji+1,jj,jk) - zut(ji,jj  ,jk) ) / e1u(ji,jj)
-
-               zva = + ( zuf(ji,jj  ,jk) - zuf(ji-1,jj,jk) ) / ze2v   &
-                  &  + ( zut(ji,jj+1,jk) - zut(ji  ,jj,jk) ) / e2v(ji,jj)
-               ! add it to the general momentum trends
-               ua(ji,jj,jk) = ua(ji,jj,jk) + zua * ( fsahmu(ji,jj,jk)*nkahm_smag +(1 -nkahm_smag ))
-               va(ji,jj,jk) = va(ji,jj,jk) + zva * ( fsahmv(ji,jj,jk)*nkahm_smag +(1 -nkahm_smag ))
-            END DO
-         END DO
-
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-      CALL wrk_dealloc( jpi, jpj,      zcu, zcv           )
-      CALL wrk_dealloc( jpi, jpj, jpk, zuf, zut, zlu, zlv ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf_bilap')
-      !
-   END SUBROUTINE dyn_ldf_bilap
-
-   !!======================================================================
-END MODULE dynldf_bilap
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_bilapg.F90	(revision 6040)
+++ 	(revision )
@@ -1,493 +1,0 @@
-MODULE dynldf_bilapg
-   !!======================================================================
-   !!                       ***  MODULE  dynldf_bilapg  ***
-   !! Ocean dynamics:  lateral viscosity trend
-   !!======================================================================
-   !! History :  OPA  !  1997-07  (G. Madec)  Original code
-   !!  NEMO      1.0  !  2002-08  (G. Madec)  F90: Free form and module
-   !!            2.0  !  2004-08  (C. Talandier) New trends organization
-   !!----------------------------------------------------------------------
-#if defined key_ldfslp   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!   'key_ldfslp'                              Rotation of mixing tensor
-   !!----------------------------------------------------------------------
-   !!   dyn_ldf_bilapg : update the momentum trend with the horizontal part
-   !!                    of the horizontal s-coord. bilaplacian diffusion
-   !!   ldfguv         : 
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE ldfdyn_oce      ! ocean dynamics lateral physics
-   USE zdf_oce         ! ocean vertical physics
-   USE ldfslp          ! iso-neutral slopes available
-   USE ldftra_oce, ONLY: ln_traldf_iso
-   !
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! MPP library
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl          ! Print control
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   dyn_ldf_bilapg       ! called by step.F90
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  zfuw, zfvw , zdiu, zdiv   ! 2D workspace (ldfguv)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  zdju, zdj1u, zdjv, zdj1v  ! 2D workspace (ldfguv)
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldfdyn_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION dyn_ldf_bilapg_alloc()
-      !!----------------------------------------------------------------------
-      !!               ***  ROUTINE dyn_ldf_bilapg_alloc  ***
-      !!----------------------------------------------------------------------
-      ALLOCATE( zfuw(jpi,jpk) , zfvw (jpi,jpk) , zdiu(jpi,jpk) , zdiv (jpi,jpk) ,     &
-         &      zdju(jpi,jpk) , zdj1u(jpi,jpk) , zdjv(jpi,jpk) , zdj1v(jpi,jpk) , STAT=dyn_ldf_bilapg_alloc )
-         !
-      IF( dyn_ldf_bilapg_alloc /= 0 )   CALL ctl_warn('dyn_ldf_bilapg_alloc: failed to allocate arrays')
-   END FUNCTION dyn_ldf_bilapg_alloc
-
-
-   SUBROUTINE dyn_ldf_bilapg( kt )
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE dyn_ldf_bilapg  ***
-      !!                      
-      !! ** Purpose :   Compute the before trend of the horizontal momentum
-      !!      diffusion and add it to the general trend of momentum equation.
-      !!
-      !! ** Method  :   The lateral momentum diffusive trends is provided by a 
-      !!      a 4th order operator rotated along geopotential surfaces. It is 
-      !!      computed using before fields (forward in time) and geopotential
-      !!      slopes computed in routine inildf.
-      !!         -1- compute the geopotential harmonic operator applied to
-      !!      (ub,vb) and multiply it by the eddy diffusivity coefficient
-      !!      (done by a call to ldfgpu and ldfgpv routines) The result is in
-      !!      (zwk1,zwk2) arrays. Applied the domain lateral boundary conditions
-      !!      by call to lbc_lnk.
-      !!         -2- applied to (zwk1,zwk2) the geopotential harmonic operator
-      !!      by a second call to ldfgpu and ldfgpv routines respectively. The
-      !!      result is in (zwk3,zwk4) arrays.
-      !!         -3- Add this trend to the general trend (ta,sa):
-      !!            (ua,va) = (ua,va) + (zwk3,zwk4)
-      !!
-      !! ** Action  : - Update (ua,va) arrays with the before geopotential
-      !!                biharmonic mixing trend.
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt           ! ocean time-step index
-      !
-      INTEGER ::   ji, jj, jk                 ! dummy loop indices
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwk1, zwk2, zwk3, zwk4
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dyn_ldf_bilapg')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zwk1, zwk2, zwk3, zwk4 ) 
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dyn_ldf_bilapg : horizontal biharmonic operator in s-coordinate'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'
-         !                                      ! allocate dyn_ldf_bilapg arrays
-         IF( dyn_ldf_bilapg_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_ldf_bilapg: failed to allocate arrays')
-      ENDIF
-
-      ! s-coordinate: Iso-level diffusion on tracer, but geopotential level diffusion on momentum
-      IF( ln_dynldf_hor .AND. ln_traldf_iso ) THEN
-         !
-         DO jk = 1, jpk         ! set the slopes of iso-level
-            DO jj = 2, jpjm1
-               DO ji = 2, jpim1
-                  uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept_b(ji+1,jj,jk) - fsdept_b(ji ,jj ,jk) ) * umask(ji,jj,jk)
-                  vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept_b(ji,jj+1,jk) - fsdept_b(ji ,jj ,jk) ) * vmask(ji,jj,jk)
-                  wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw_b(ji+1,jj,jk) - fsdepw_b(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
-                  wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw_b(ji,jj+1,jk) - fsdepw_b(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
-               END DO
-            END DO
-         END DO
-         ! Lateral boundary conditions on the slopes
-         CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
-         CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
- 
-!!bug
-         IF( kt == nit000 ) then
-            IF(lwp) WRITE(numout,*) ' max slop: u', SQRT( MAXVAL(uslp*uslp)), ' v ', SQRT(MAXVAL(vslp)),  &
-               &                             ' wi', sqrt(MAXVAL(wslpi))     , ' wj', sqrt(MAXVAL(wslpj))
-         endif
-!!end
-      ENDIF
-
-      zwk1(:,:,:) = 0.e0   ;   zwk3(:,:,:) = 0.e0
-      zwk2(:,:,:) = 0.e0   ;   zwk4(:,:,:) = 0.e0
-
-      ! Laplacian of (ub,vb) multiplied by ahm
-      ! --------------------------------------  
-      CALL ldfguv( ub, vb, zwk1, zwk2, 1 )      ! rotated harmonic operator applied to (ub,vb)
-      !                                         ! and multiply by ahmu, ahmv (output in (zwk1,zwk2) )
-      CALL lbc_lnk( zwk1, 'U', -1. )   ;   CALL lbc_lnk( zwk2, 'V', -1. )     ! Lateral boundary conditions
-
-      ! Bilaplacian of (ub,vb)
-      ! ---------------------- 
-      CALL ldfguv( zwk1, zwk2, zwk3, zwk4, 2 )  ! rotated harmonic operator applied to (zwk1,zwk2) 
-      !                                         ! (output in (zwk3,zwk4) )
-
-      ! Update the momentum trends
-      ! --------------------------
-      DO jj = 2, jpjm1               ! add the diffusive trend to the general momentum trends
-         DO jk = 1, jpkm1
-            DO ji = 2, jpim1
-               ua(ji,jj,jk) = ua(ji,jj,jk) + zwk3(ji,jj,jk)
-               va(ji,jj,jk) = va(ji,jj,jk) + zwk4(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zwk1, zwk2, zwk3, zwk4 ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf_bilapg')
-      !
-   END SUBROUTINE dyn_ldf_bilapg
-
-
-   SUBROUTINE ldfguv( pu, pv, plu, plv, kahm )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldfguv  ***
-      !!      
-      !! ** Purpose :   Apply a geopotential harmonic operator to (pu,pv)
-      !!      (defined at u- and v-points) and multiply it by the eddy
-      !!      viscosity coefficient (if kahm=1).
-      !!
-      !! ** Method  :   The harmonic operator rotated along geopotential 
-      !!      surfaces is applied to (pu,pv) using the slopes of geopotential
-      !!      surfaces computed in inildf routine. The result is provided in
-      !!      (plu,plv) arrays. It is computed in 2 stepv:
-      !!
-      !!      First step: horizontal part of the operator. It is computed on
-      !!      ==========  pu as follows (idem on pv)
-      !!      horizontal fluxes :
-      !!         zftu = e2u*e3u/e1u di[ pu ] - e2u*uslp dk[ mi(mk(pu)) ]
-      !!         zftv = e1v*e3v/e2v dj[ pu ] - e1v*vslp dk[ mj(mk(pu)) ]
-      !!      take the horizontal divergence of the fluxes (no divided by
-      !!      the volume element :
-      !!         plu  = di-1[ zftu ] +  dj-1[ zftv ]
-      !!
-      !!      Second step: vertical part of the operator. It is computed on
-      !!      ===========  pu as follows (idem on pv)
-      !!      vertical fluxes :
-      !!         zftw = e1t*e2t/e3w * (wslpi^2+wslpj^2)  dk-1[ pu ]
-      !!              -     e2t     *       wslpi        di[ mi(mk(pu)) ]
-      !!              -     e1t     *       wslpj        dj[ mj(mk(pu)) ]
-      !!      take the vertical divergence of the fluxes add it to the hori-
-      !!      zontal component, divide the result by the volume element and
-      !!      if kahm=1, multiply by the eddy diffusivity coefficient:
-      !!         plu  = aht / (e1t*e2t*e3t) { plu + dk[ zftw ] }
-      !!      else:
-      !!         plu  =  1  / (e1t*e2t*e3t) { plu + dk[ zftw ] }
-      !!
-      !! ** Action :
-      !!        plu, plv        : partial harmonic operator applied to
-      !!                          pu and pv (all the components except
-      !!                          second order vertical derivative term)
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   pu , pv    ! 1st call: before horizontal velocity 
-      !                                                               ! 2nd call: ahm x these fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   plu, plv   ! partial harmonic operator applied to
-      !                                                               ! pu and pv (all the components except
-      !                                                               ! second order vertical derivative term)
-      INTEGER                         , INTENT(in   ) ::   kahm       ! =1 1st call ; =2 2nd call
-      !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zabe1 , zabe2 , zcof1 , zcof2        ! local scalar
-      REAL(wp) ::   zcoef0, zcoef3, zcoef4               !   -      -
-      REAL(wp) ::   zbur, zbvr, zmkt, zmkf, zuav, zvav   !   -      -
-      REAL(wp) ::   zuwslpi, zuwslpj, zvwslpi, zvwslpj   !   -      -
-      !
-      REAL(wp), POINTER, DIMENSION(:,:) :: ziut, zjuf, zjvt, zivf, zdku, zdk1u, zdkv, zdk1v
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ldfguv')
-      !
-      CALL wrk_alloc( jpi, jpj, ziut, zjuf, zjvt, zivf, zdku, zdk1u, zdkv, zdk1v ) 
-      !
-      !                               ! ********** !   ! ===============
-      DO jk = 1, jpkm1                ! First step !   ! Horizontal slab
-         !                            ! ********** !   ! ===============
-
-         ! I.1 Vertical gradient of pu and pv at level jk and jk+1
-         ! -------------------------------------------------------
-         ! surface boundary condition: zdku(jk=1)=zdku(jk=2)
-         !                             zdkv(jk=1)=zdkv(jk=2)
-
-         zdk1u(:,:) = ( pu(:,:,jk) - pu(:,:,jk+1) ) * umask(:,:,jk+1)
-         zdk1v(:,:) = ( pv(:,:,jk) - pv(:,:,jk+1) ) * vmask(:,:,jk+1)
-
-         IF( jk == 1 ) THEN
-            zdku(:,:) = zdk1u(:,:)
-            zdkv(:,:) = zdk1v(:,:)
-         ELSE
-            zdku(:,:) = ( pu(:,:,jk-1) - pu(:,:,jk) ) * umask(:,:,jk)
-            zdkv(:,:) = ( pv(:,:,jk-1) - pv(:,:,jk) ) * vmask(:,:,jk)
-         ENDIF
-
-         !                                -----f-----
-         ! I.2 Horizontal fluxes on U          |
-         ! ------------------------===     t   u   t
-         !                                     |
-         ! i-flux at t-point              -----f-----
-         DO jj = 1, jpjm1
-            DO ji = 2, jpi
-               zabe1 = e2t(ji,jj) * fse3t(ji,jj,jk) / e1t(ji,jj)
-
-               zmkt  = 1./MAX(  umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)   &
-                              + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ), 1. )
-
-               zcof1 = -e2t(ji,jj) * zmkt   &
-                     * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
-
-               ziut(ji,jj) = tmask(ji,jj,jk) *   &
-                           (  zabe1 * ( pu(ji,jj,jk) - pu(ji-1,jj,jk) )   &
-                            + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)     &
-                                       +zdk1u(ji,jj) + zdku (ji-1,jj) )  )
-            END DO
-         END DO
-
-         ! j-flux at f-point
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               zabe2 = e1f(ji,jj) * fse3f(ji,jj,jk) / e2f(ji,jj)
-
-               zmkf  = 1./MAX(  umask(ji,jj+1,jk  )+umask(ji,jj,jk+1)   &
-                              + umask(ji,jj+1,jk+1)+umask(ji,jj,jk  ), 1. )
-
-               zcof2 = -e1f(ji,jj) * zmkf   &
-                     * 0.5  * ( vslp(ji+1,jj,jk) + vslp(ji,jj,jk) )
-
-               zjuf(ji,jj) = fmask(ji,jj,jk) *   &
-                           (  zabe2 * ( pu(ji,jj+1,jk) - pu(ji,jj,jk) )   &
-                            + zcof2 * ( zdku (ji,jj+1) + zdk1u(ji,jj)     &
-                                       +zdk1u(ji,jj+1) + zdku (ji,jj) )  )
-            END DO
-         END DO
-
-         !                                 |   t   |
-         ! I.3 Horizontal fluxes on V      |       |
-         ! ------------------------===     f---v---f
-         !                                 |       |
-         ! i-flux at f-point               |   t   |
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               zabe1 = e2f(ji,jj) * fse3f(ji,jj,jk) / e1f(ji,jj)
-
-               zmkf  = 1./MAX(  vmask(ji+1,jj,jk  )+vmask(ji,jj,jk+1)   &
-                              + vmask(ji+1,jj,jk+1)+vmask(ji,jj,jk  ), 1. )
-
-               zcof1 = -e2f(ji,jj) * zmkf   &
-                     * 0.5 * ( uslp(ji,jj+1,jk) + uslp(ji,jj,jk) )
-
-               zivf(ji,jj) = fmask(ji,jj,jk) *   &
-                           (  zabe1 * ( pu(ji+1,jj,jk) - pu(ji,jj,jk) )   &
-                            + zcof1 * ( zdku (ji,jj) + zdk1u(ji+1,jj)     &
-                                       +zdk1u(ji,jj) + zdku (ji+1,jj) )  )
-            END DO
-         END DO
-
-         ! j-flux at t-point
-         DO jj = 2, jpj
-            DO ji = 1, jpim1
-               zabe2 = e1t(ji,jj) * fse3t(ji,jj,jk) / e2t(ji,jj)
-
-               zmkt  = 1./MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)   &
-                              + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ), 1. )
-
-               zcof2 = -e1t(ji,jj) * zmkt   &
-                     * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
-
-               zjvt(ji,jj) = tmask(ji,jj,jk) *   &
-                           (  zabe2 * ( pu(ji,jj,jk) - pu(ji,jj-1,jk) )   &
-                            + zcof2 * ( zdku (ji,jj-1) + zdk1u(ji,jj)     &
-                                       +zdk1u(ji,jj-1) + zdku (ji,jj) )  )
-            END DO
-         END DO
-
-
-         ! I.4 Second derivative (divergence) (not divided by the volume)
-         ! ---------------------
-
-         DO jj = 2, jpjm1
-            DO ji = 2, jpim1
-               plu(ji,jj,jk) = ziut (ji+1,jj) - ziut (ji,jj  )   &
-                             + zjuf (ji  ,jj) - zjuf (ji,jj-1)
-               plv(ji,jj,jk) = zivf (ji,jj  ) - zivf (ji-1,jj)   &
-                             + zjvt (ji,jj+1) - zjvt (ji,jj  ) 
-            END DO
-         END DO
-
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-
-      !,,,,,,,,,,,,,,,,,,,,,,,,,,,,,synchro,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
-
-      !                             ! ************ !   ! ===============
-      DO jj = 2, jpjm1              !  Second step !   ! Horizontal slab
-         !                          ! ************ !   ! ===============
-
-         ! II.1 horizontal (pu,pv) gradients
-         ! ---------------------------------
-
-         DO jk = 1, jpk
-            DO ji = 2, jpi
-               ! i-gradient of u at jj
-               zdiu (ji,jk) = tmask(ji,jj  ,jk) * ( pu(ji,jj  ,jk) - pu(ji-1,jj  ,jk) )
-               ! j-gradient of u and v at jj
-               zdju (ji,jk) = fmask(ji,jj  ,jk) * ( pu(ji,jj+1,jk) - pu(ji  ,jj  ,jk) )
-               zdjv (ji,jk) = tmask(ji,jj  ,jk) * ( pv(ji,jj  ,jk) - pv(ji  ,jj-1,jk) )
-               ! j-gradient of u and v at jj+1
-               zdj1u(ji,jk) = fmask(ji,jj-1,jk) * ( pu(ji,jj  ,jk) - pu(ji  ,jj-1,jk) )
-               zdj1v(ji,jk) = tmask(ji,jj+1,jk) * ( pv(ji,jj+1,jk) - pv(ji  ,jj  ,jk) )
-            END DO
-         END DO
-         DO jk = 1, jpk
-            DO ji = 1, jpim1
-               ! i-gradient of v at jj
-               zdiv (ji,jk) = fmask(ji,jj  ,jk) * ( pv(ji+1,jj,jk) - pv(ji  ,jj  ,jk) )
-            END DO
-         END DO
-
-
-         ! II.2 Vertical fluxes
-         ! --------------------
-
-         ! Surface and bottom vertical fluxes set to zero
-
-         zfuw(:, 1 ) = 0.e0
-         zfvw(:, 1 ) = 0.e0
-         zfuw(:,jpk) = 0.e0
-         zfvw(:,jpk) = 0.e0
-
-         ! interior (2=<jk=<jpk-1) on pu field
-
-         DO jk = 2, jpkm1
-            DO ji = 2, jpim1
-               ! i- and j-slopes at uw-point
-               zuwslpi = 0.5 * ( wslpi(ji+1,jj,jk) + wslpi(ji,jj,jk) )
-               zuwslpj = 0.5 * ( wslpj(ji+1,jj,jk) + wslpj(ji,jj,jk) )
-               ! coef. for the vertical dirative
-               zcoef0 = e1u(ji,jj) * e2u(ji,jj) / fse3u(ji,jj,jk)   &
-                      * ( zuwslpi * zuwslpi + zuwslpj * zuwslpj )
-               ! weights for the i-k, j-k averaging at t- and f-points, resp.
-               zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji+1,jj,jk-1)   &
-                             + tmask(ji,jj,jk  )+tmask(ji+1,jj,jk  ), 1. )
-               zmkf = 1./MAX(  fmask(ji,jj-1,jk-1)+fmask(ji,jj,jk-1)   &
-                             + fmask(ji,jj-1,jk  )+fmask(ji,jj,jk  ), 1. )
-               ! coef. for the horitontal derivative
-               zcoef3 = - e2u(ji,jj) * zmkt * zuwslpi
-               zcoef4 = - e1u(ji,jj) * zmkf * zuwslpj
-               ! vertical flux on u field
-               zfuw(ji,jk) = umask(ji,jj,jk) *   &
-                           (  zcoef0 * ( pu  (ji,jj,jk-1) - pu  (ji,jj,jk) )   &
-                            + zcoef3 * ( zdiu (ji,jk-1) + zdiu (ji+1,jk-1)     &
-                                        +zdiu (ji,jk  ) + zdiu (ji+1,jk  ) )   &
-                            + zcoef4 * ( zdj1u(ji,jk-1) + zdju (ji  ,jk-1)     &
-                                        +zdj1u(ji,jk  ) + zdju (ji  ,jk  ) ) )
-            END DO
-         END DO
-
-         ! interior (2=<jk=<jpk-1) on pv field
-
-         DO jk = 2, jpkm1
-            DO ji = 2, jpim1
-               ! i- and j-slopes at vw-point
-               zvwslpi = 0.5 * ( wslpi(ji,jj+1,jk) + wslpi(ji,jj,jk) )
-               zvwslpj = 0.5 * ( wslpj(ji,jj+1,jk) + wslpj(ji,jj,jk) )
-               ! coef. for the vertical derivative
-               zcoef0 = e1v(ji,jj) * e2v(ji,jj) / fse3v(ji,jj,jk)   &
-                      * ( zvwslpi * zvwslpi + zvwslpj * zvwslpj )
-               ! weights for the i-k, j-k averaging at f- and t-points, resp.
-               zmkf = 1./MAX(  fmask(ji-1,jj,jk-1)+fmask(ji,jj,jk-1)   &
-                             + fmask(ji-1,jj,jk  )+fmask(ji,jj,jk  ), 1. )
-               zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji,jj+1,jk-1)   &
-                             + tmask(ji,jj,jk  )+tmask(ji,jj+1,jk  ), 1. )
-               ! coef. for the horizontal derivatives
-               zcoef3 = - e2v(ji,jj) * zmkf * zvwslpi
-               zcoef4 = - e1v(ji,jj) * zmkt * zvwslpj
-               ! vertical flux on pv field
-               zfvw(ji,jk) = vmask(ji,jj,jk) *   &
-                           (  zcoef0 * ( pv  (ji,jj,jk-1) - pv  (ji,jj,jk) )   &
-                            + zcoef3 * ( zdiv (ji,jk-1) + zdiv (ji-1,jk-1)     &
-                                        +zdiv (ji,jk  ) + zdiv (ji-1,jk  ) )   &
-                            + zcoef4 * ( zdjv (ji,jk-1) + zdj1v(ji  ,jk-1)     &
-                                        +zdjv (ji,jk  ) + zdj1v(ji  ,jk  ) )  )
-            END DO
-         END DO
-
-
-         ! II.3 Divergence of vertical fluxes added to the horizontal divergence
-         ! ---------------------------------------------------------------------
-         IF( (kahm -nkahm_smag) ==1 ) THEN
-            ! multiply the laplacian by the eddy viscosity coefficient
-            DO jk = 1, jpkm1
-               DO ji = 2, jpim1
-                  ! eddy coef. divided by the volume element
-                  zbur = fsahmu(ji,jj,jk) / ( e1u(ji,jj)*e2u(ji,jj)*fse3u(ji,jj,jk) )
-                  zbvr = fsahmv(ji,jj,jk) / ( e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,jk) )
-                  ! vertical divergence
-                  zuav = zfuw(ji,jk) - zfuw(ji,jk+1)
-                  zvav = zfvw(ji,jk) - zfvw(ji,jk+1)
-                  ! harmonic operator applied to (pu,pv) and multiply by ahm
-                  plu(ji,jj,jk) = ( plu(ji,jj,jk) + zuav ) * zbur
-                  plv(ji,jj,jk) = ( plv(ji,jj,jk) + zvav ) * zbvr
-               END DO
-            END DO
-         ELSEIF( (kahm +nkahm_smag ) == 2 ) THEN
-            ! second call, no multiplication
-            DO jk = 1, jpkm1
-               DO ji = 2, jpim1
-                  ! inverse of the volume element
-                  zbur = 1. / ( e1u(ji,jj)*e2u(ji,jj)*fse3u(ji,jj,jk) )
-                  zbvr = 1. / ( e1v(ji,jj)*e2v(ji,jj)*fse3v(ji,jj,jk) )
-                  ! vertical divergence
-                  zuav = zfuw(ji,jk) - zfuw(ji,jk+1)
-                  zvav = zfvw(ji,jk) - zfvw(ji,jk+1)
-                  ! harmonic operator applied to (pu,pv) 
-                  plu(ji,jj,jk) = ( plu(ji,jj,jk) + zuav ) * zbur
-                  plv(ji,jj,jk) = ( plv(ji,jj,jk) + zvav ) * zbvr
-               END DO
-            END DO
-         ELSE
-            IF(lwp)WRITE(numout,*) ' ldfguv: kahm= 1 or 2, here =', kahm
-            IF(lwp)WRITE(numout,*) '         We stop'
-            STOP 'ldfguv'
-         ENDIF
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-
-      CALL wrk_dealloc( jpi, jpj, ziut, zjuf, zjvt, zivf, zdku, zdk1u, zdkv, zdk1v ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ldfguv')
-      !
-   END SUBROUTINE ldfguv
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Dummy module :                         NO rotation of mixing tensor
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE dyn_ldf_bilapg( kt )               ! Dummy routine
-      INTEGER, INTENT(in) :: kt
-      WRITE(*,*) 'dyn_ldf_bilapg: You should not have seen this print! error?', kt
-   END SUBROUTINE dyn_ldf_bilapg
-#endif
-
-   !!======================================================================
-END MODULE dynldf_bilapg
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_iso.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_iso.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_iso.F90	(revision 6041)
@@ -2,5 +2,5 @@
    !!======================================================================
    !!                     ***  MODULE  dynldf_iso  ***
-   !! Ocean dynamics:  lateral viscosity trend
+   !! Ocean dynamics:   lateral viscosity trend (rotated laplacian operator)
    !!======================================================================
    !! History :  OPA  !  97-07  (G. Madec)  Original code
@@ -8,8 +8,8 @@
    !!             -   !  2004-08  (C. Talandier) New trends organization
    !!            2.0  !  2005-11  (G. Madec)  s-coordinate: horizontal diffusion
+   !!            3.7  !  2014-01  (F. Lemarie, G. Madec)  restructuration/simplification of ahm specification,
+   !!                 !                                   add velocity dependent coefficient and optional read in file
    !!----------------------------------------------------------------------
-#if defined key_ldfslp   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!   'key_ldfslp'                      slopes of the direction of mixing
+
    !!----------------------------------------------------------------------
    !!   dyn_ldf_iso  : update the momentum trend with the horizontal part
@@ -19,12 +19,12 @@
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
-   USE ldfdyn_oce      ! ocean dynamics lateral physics
-   USE ldftra_oce      ! ocean tracer   lateral physics
+   USE ldfdyn          ! lateral diffusion: eddy viscosity coef.
+   USE ldftra          ! lateral physics: eddy diffusivity
    USE zdf_oce         ! ocean vertical physics
    USE ldfslp          ! iso-neutral slopes 
    !
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE in_out_manager  ! I/O manager
    USE lib_mpp         ! MPP library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE prtctl          ! Print control
    USE wrk_nemo        ! Memory Allocation
@@ -42,5 +42,4 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldfdyn_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
@@ -83,13 +82,13 @@
       !!      horizontal fluxes associated with the rotated lateral mixing:
       !!      u-component:
-      !!         ziut = ( ahmt + ahmb0 ) e2t * e3t / e1t  di[ ub ]
-      !!               -      ahmt       e2t * mi-1(uslp) dk[ mi(mk(ub)) ]
-      !!         zjuf = ( ahmf + ahmb0 ) e1f * e3f / e2f  dj[ ub ]
-      !!               -      ahmf       e1f * mi(vslp)   dk[ mj(mk(ub)) ]
+      !!         ziut = ( ahmt + rn_ahm_b ) e2t * e3t / e1t  di[ ub ]
+      !!               -  ahmt              e2t * mi-1(uslp) dk[ mi(mk(ub)) ]
+      !!         zjuf = ( ahmf + rn_ahm_b ) e1f * e3f / e2f  dj[ ub ]
+      !!               -  ahmf              e1f * mi(vslp)   dk[ mj(mk(ub)) ]
       !!      v-component:
-      !!         zivf = ( ahmf + ahmb0 ) e2t * e3t / e1t  di[ vb ]
-      !!               -      ahmf       e2t * mj(uslp)   dk[ mi(mk(vb)) ]
-      !!         zjvt = ( ahmt + ahmb0 ) e1f * e3f / e2f  dj[ ub ]
-      !!               -      ahmt       e1f * mj-1(vslp) dk[ mj(mk(vb)) ]
+      !!         zivf = ( ahmf + rn_ahm_b ) e2t * e3t / e1t  di[ vb ]
+      !!               -  ahmf              e2t * mj(uslp)   dk[ mi(mk(vb)) ]
+      !!         zjvt = ( ahmt + rn_ahm_b ) e1f * e3f / e2f  dj[ ub ]
+      !!               -  ahmt              e1f * mj-1(vslp) dk[ mj(mk(vb)) ]
       !!      take the horizontal divergence of the fluxes:
       !!         diffu = 1/(e1u*e2u*e3u) {  di  [ ziut ] + dj-1[ zjuf ]  }
@@ -106,10 +105,9 @@
       !!      of the rotated operator in dynzdf module
       !!----------------------------------------------------------------------
-      !
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
       !
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   zabe1, zabe2, zcof1, zcof2                       ! local scalars
-      REAL(wp) ::   zmskt, zmskf, zbu, zbv, zuah, zvah               !   -      -
+      REAL(wp) ::   zmskt, zmskf                                     !   -      -
       REAL(wp) ::   zcoef0, zcoef3, zcoef4, zmkt, zmkf               !   -      -
       REAL(wp) ::   zuav, zvav, zuwslpi, zuwslpj, zvwslpi, zvwslpj   !   -      -
@@ -130,5 +128,6 @@
       ENDIF
 
-      ! s-coordinate: Iso-level diffusion on tracer, but geopotential level diffusion on momentum
+!!gm bug is dyn_ldf_iso called before tra_ldf_iso ....   <<<<<===== TO BE CHECKED
+      ! s-coordinate: Iso-level diffusion on momentum but not on tracer
       IF( ln_dynldf_hor .AND. ln_traldf_iso ) THEN
          !
@@ -136,8 +135,8 @@
             DO jj = 2, jpjm1
                DO ji = 2, jpim1
-                  uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept_b(ji+1,jj,jk) - fsdept_b(ji ,jj ,jk) ) * umask(ji,jj,jk)
-                  vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept_b(ji,jj+1,jk) - fsdept_b(ji ,jj ,jk) ) * vmask(ji,jj,jk)
-                  wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw_b(ji+1,jj,jk) - fsdepw_b(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
-                  wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw_b(ji,jj+1,jk) - fsdepw_b(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
+                  uslp (ji,jj,jk) = - ( fsdept_b(ji+1,jj,jk) - fsdept_b(ji ,jj ,jk) ) * r1_e1u(ji,jj) * umask(ji,jj,jk)
+                  vslp (ji,jj,jk) = - ( fsdept_b(ji,jj+1,jk) - fsdept_b(ji ,jj ,jk) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk)
+                  wslpi(ji,jj,jk) = - ( fsdepw_b(ji+1,jj,jk) - fsdepw_b(ji-1,jj,jk) ) * r1_e1t(ji,jj) * tmask(ji,jj,jk) * 0.5
+                  wslpj(ji,jj,jk) = - ( fsdepw_b(ji,jj+1,jk) - fsdepw_b(ji,jj-1,jk) ) * r1_e2t(ji,jj) * tmask(ji,jj,jk) * 0.5
                END DO
             END DO
@@ -184,11 +183,26 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, jpi   ! vector opt.
-                  zabe1 = (fsahmt(ji,jj,jk)+ahmb0) * e2t(ji,jj) * MIN( fse3u(ji,jj,jk), fse3u(ji-1,jj,jk) ) / e1t(ji,jj)
-
-                  zmskt = 1./MAX(  umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)   &
-                     &           + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ), 1. )
-
-                  zcof1 = - aht0 * e2t(ji,jj) * zmskt * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
+                  zabe1 = ( ahmt(ji,jj,jk)+rn_ahm_b ) * e2t(ji,jj) * MIN( fse3u(ji,jj,jk), fse3u(ji-1,jj,jk) ) * r1_e1t(ji,jj)
+
+                  zmskt = 1._wp / MAX(   umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)     &
+                     &                 + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ) , 1._wp )
+
+                  zcof1 = - rn_aht_0 * e2t(ji,jj) * zmskt * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
    
+                  ziut(ji,jj) = (  zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) )    &
+                     &           + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)      &
+                     &                      +zdk1u(ji,jj) + zdku (ji-1,jj) )  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ELSE                   ! other coordinate system (zco or sco) : e3t
+            DO jj = 2, jpjm1
+               DO ji = fs_2, jpi   ! vector opt.
+                  zabe1 = ( ahmt(ji,jj,jk)+rn_ahm_b ) * e2t(ji,jj) * fse3t(ji,jj,jk) * r1_e1t(ji,jj)
+
+                  zmskt = 1._wp / MAX(   umask(ji-1,jj,jk  ) + umask(ji,jj,jk+1)     &
+                     &                 + umask(ji-1,jj,jk+1) + umask(ji,jj,jk  ) , 1._wp )
+
+                  zcof1 = - rn_aht_0 * e2t(ji,jj) * zmskt * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
+
                   ziut(ji,jj) = (  zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) )   &
                      &           + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)     &
@@ -196,19 +210,4 @@
                END DO
             END DO
-         ELSE                   ! other coordinate system (zco or sco) : e3t
-            DO jj = 2, jpjm1
-               DO ji = fs_2, jpi   ! vector opt.
-                  zabe1 = (fsahmt(ji,jj,jk)+ahmb0) * e2t(ji,jj) * fse3t(ji,jj,jk) / e1t(ji,jj)
-
-                  zmskt = 1./MAX(  umask(ji-1,jj,jk  )+umask(ji,jj,jk+1)   &
-                     &           + umask(ji-1,jj,jk+1)+umask(ji,jj,jk  ), 1. )
-
-                  zcof1 = - aht0 * e2t(ji,jj) * zmskt * 0.5  * ( uslp(ji-1,jj,jk) + uslp(ji,jj,jk) )
-
-                  ziut(ji,jj) = (  zabe1 * ( ub(ji,jj,jk) - ub(ji-1,jj,jk) )   &
-                     &           + zcof1 * ( zdku (ji,jj) + zdk1u(ji-1,jj)     &
-                     &                      +zdk1u(ji,jj) + zdku (ji-1,jj) )  ) * tmask(ji,jj,jk)
-               END DO
-            END DO
          ENDIF
 
@@ -216,10 +215,10 @@
          DO jj = 1, jpjm1
             DO ji = 1, fs_jpim1   ! vector opt.
-               zabe2 = ( fsahmf(ji,jj,jk) + ahmb0 ) * e1f(ji,jj) * fse3f(ji,jj,jk) / e2f(ji,jj)
-
-               zmskf = 1./MAX(  umask(ji,jj+1,jk  )+umask(ji,jj,jk+1)   &
-                  &           + umask(ji,jj+1,jk+1)+umask(ji,jj,jk  ), 1. )
-
-               zcof2 = - aht0 * e1f(ji,jj) * zmskf * 0.5  * ( vslp(ji+1,jj,jk) + vslp(ji,jj,jk) )
+               zabe2 = ( ahmf(ji,jj,jk) + rn_ahm_b ) * e1f(ji,jj) * fse3f(ji,jj,jk) * r1_e2f(ji,jj)
+
+               zmskf = 1._wp / MAX(   umask(ji,jj+1,jk  )+umask(ji,jj,jk+1)     &
+                  &                 + umask(ji,jj+1,jk+1)+umask(ji,jj,jk  ) , 1._wp )
+
+               zcof2 = - rn_aht_0 * e1f(ji,jj) * zmskf * 0.5  * ( vslp(ji+1,jj,jk) + vslp(ji,jj,jk) )
 
                zjuf(ji,jj) = (  zabe2 * ( ub(ji,jj+1,jk) - ub(ji,jj,jk) )   &
@@ -237,14 +236,14 @@
          DO jj = 2, jpjm1
             DO ji = 1, fs_jpim1   ! vector opt.
-               zabe1 = ( fsahmf(ji,jj,jk) + ahmb0 ) * e2f(ji,jj) * fse3f(ji,jj,jk) / e1f(ji,jj)
-
-               zmskf = 1./MAX(  vmask(ji+1,jj,jk  )+vmask(ji,jj,jk+1)   &
-                  &           + vmask(ji+1,jj,jk+1)+vmask(ji,jj,jk  ), 1. )
-
-               zcof1 = - aht0 * e2f(ji,jj) * zmskf * 0.5 * ( uslp(ji,jj+1,jk) + uslp(ji,jj,jk) )
-
-               zivf(ji,jj) = (  zabe1 * ( vb(ji+1,jj,jk) - vb(ji,jj,jk) )   &
-                  &           + zcof1 * ( zdkv (ji,jj) + zdk1v(ji+1,jj)     &
-                  &                      +zdk1v(ji,jj) + zdkv (ji+1,jj) )  ) * fmask(ji,jj,jk)
+               zabe1 = ( ahmf(ji,jj,jk) + rn_ahm_b ) * e2f(ji,jj) * fse3f(ji,jj,jk) * r1_e1f(ji,jj)
+
+               zmskf = 1._wp / MAX(  vmask(ji+1,jj,jk  )+vmask(ji,jj,jk+1)     &
+                  &                + vmask(ji+1,jj,jk+1)+vmask(ji,jj,jk  ) , 1._wp )
+
+               zcof1 = - rn_aht_0 * e2f(ji,jj) * zmskf * 0.5 * ( uslp(ji,jj+1,jk) + uslp(ji,jj,jk) )
+
+               zivf(ji,jj) = (  zabe1 * ( vb(ji+1,jj,jk) - vb(ji,jj,jk) )    &
+                  &           + zcof1 * (  zdkv (ji,jj) + zdk1v(ji+1,jj)      &
+                  &                      + zdk1v(ji,jj) + zdkv (ji+1,jj) )  ) * fmask(ji,jj,jk)
             END DO
          END DO
@@ -254,10 +253,25 @@
             DO jj = 2, jpj
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zabe2 = (fsahmt(ji,jj,jk)+ahmb0) * e1t(ji,jj) * MIN( fse3v(ji,jj,jk), fse3v(ji,jj-1,jk) ) / e2t(ji,jj)
+                  zabe2 = ( ahmt(ji,jj,jk)+rn_ahm_b ) * e1t(ji,jj) * MIN( fse3v(ji,jj,jk), fse3v(ji,jj-1,jk) ) * r1_e2t(ji,jj)
+
+                  zmskt = 1._wp / MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)     &
+                     &                + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ) , 1._wp )
+
+                  zcof2 = - rn_aht_0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
+
+                  zjvt(ji,jj) = (  zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) )    &
+                     &           + zcof2 * ( zdkv (ji,jj-1) + zdk1v(ji,jj)      &
+                     &                      +zdk1v(ji,jj-1) + zdkv (ji,jj) )  ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         ELSE                   ! other coordinate system (zco or sco) : e3t
+            DO jj = 2, jpj
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zabe2 = ( ahmt(ji,jj,jk)+rn_ahm_b ) * e1t(ji,jj) * fse3t(ji,jj,jk) * r1_e2t(ji,jj)
 
                   zmskt = 1./MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)   &
                      &           + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ), 1. )
 
-                  zcof2 = - aht0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
+                  zcof2 = - rn_aht_0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
 
                   zjvt(ji,jj) = (  zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) )   &
@@ -266,19 +280,4 @@
                END DO
             END DO
-         ELSE                   ! other coordinate system (zco or sco) : e3t
-            DO jj = 2, jpj
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zabe2 = (fsahmt(ji,jj,jk)+ahmb0) * e1t(ji,jj) * fse3t(ji,jj,jk) / e2t(ji,jj)
-
-                  zmskt = 1./MAX(  vmask(ji,jj-1,jk  )+vmask(ji,jj,jk+1)   &
-                     &           + vmask(ji,jj-1,jk+1)+vmask(ji,jj,jk  ), 1. )
-
-                  zcof2 = - aht0 * e1t(ji,jj) * zmskt * 0.5 * ( vslp(ji,jj-1,jk) + vslp(ji,jj,jk) )
-
-                  zjvt(ji,jj) = (  zabe2 * ( vb(ji,jj,jk) - vb(ji,jj-1,jk) )   &
-                     &           + zcof2 * ( zdkv (ji,jj-1) + zdk1v(ji,jj)     &
-                     &                      +zdk1v(ji,jj-1) + zdkv (ji,jj) )  ) * tmask(ji,jj,jk)
-               END DO
-            END DO
          ENDIF
 
@@ -286,18 +285,10 @@
          ! Second derivative (divergence) and add to the general trend
          ! -----------------------------------------------------------
-
          DO jj = 2, jpjm1
-            DO ji = 2, jpim1          !! Question vectop possible??? !!bug
-               ! volume elements
-               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
-               ! horizontal component of isopycnal momentum diffusive trends
-               zuah =( ziut (ji+1,jj) - ziut (ji,jj  ) +   &
-                  &    zjuf (ji  ,jj) - zjuf (ji,jj-1)  ) / zbu
-               zvah =( zivf (ji,jj  ) - zivf (ji-1,jj) +   &
-                  &    zjvt (ji,jj+1) - zjvt (ji,jj  )  ) / zbv
-               ! add the trends to the general trends
-               ua (ji,jj,jk) = ua (ji,jj,jk) + zuah
-               va (ji,jj,jk) = va (ji,jj,jk) + zvah
+            DO ji = 2, jpim1          !!gm Question vectop possible??? !!bug
+               ua(ji,jj,jk) = ua(ji,jj,jk) + ( ziut(ji+1,jj) - ziut(ji,jj  )    &
+                  &                          + zjuf(ji  ,jj) - zjuf(ji,jj-1)  ) / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
+               va(ji,jj,jk) = va(ji,jj,jk) + ( zivf(ji,jj  ) - zivf(ji-1,jj)    &
+                  &                          + zjvt(ji,jj+1) - zjvt(ji,jj  )  ) / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
             END DO
          END DO
@@ -358,13 +349,13 @@
          DO jk = 2, jpkm1
             DO ji = 2, jpim1
-               zcoef0= 0.5 * aht0 * umask(ji,jj,jk)
-
+               zcoef0= 0.5 * rn_aht_0 * umask(ji,jj,jk)
+               !
                zuwslpi = zcoef0 * ( wslpi(ji+1,jj,jk) + wslpi(ji,jj,jk) )
                zuwslpj = zcoef0 * ( wslpj(ji+1,jj,jk) + wslpj(ji,jj,jk) )
-
+               !
                zmkt = 1./MAX(  tmask(ji,jj,jk-1)+tmask(ji+1,jj,jk-1)   &
                              + tmask(ji,jj,jk  )+tmask(ji+1,jj,jk  ), 1. )
-               zmkf = 1./MAX(  fmask(ji,jj-1,jk-1)+fmask(ji,jj,jk-1)   &
-                             + fmask(ji,jj-1,jk  )+fmask(ji,jj,jk  ), 1. )
+               zmkf = 1./MAX(  fmask(ji,jj-1,jk-1) + fmask(ji,jj,jk-1)   &
+                             + fmask(ji,jj-1,jk  ) + fmask(ji,jj,jk  ), 1. )
 
                zcoef3 = - e2u(ji,jj) * zmkt * zuwslpi
@@ -376,6 +367,6 @@
                                        +zdj1u(ji,jk  ) + zdju (ji  ,jk  ) )
                ! update avmu (add isopycnal vertical coefficient to avmu)
-               ! Caution: zcoef0 include aht0, so divided by aht0 to obtain slp^2 * aht0
-               avmu(ji,jj,jk) = avmu(ji,jj,jk) + ( zuwslpi * zuwslpi + zuwslpj * zuwslpj ) / aht0
+               ! Caution: zcoef0 include rn_aht_0, so divided by rn_aht_0 to obtain slp^2 * rn_aht_0
+               avmu(ji,jj,jk) = avmu(ji,jj,jk) + ( zuwslpi * zuwslpi + zuwslpj * zuwslpj ) / rn_aht_0
             END DO
          END DO
@@ -384,5 +375,5 @@
          DO jk = 2, jpkm1
             DO ji = 2, jpim1
-               zcoef0= 0.5 * aht0 * vmask(ji,jj,jk)
+               zcoef0 = 0.5 * rn_aht_0 * vmask(ji,jj,jk)
 
                zvwslpi = zcoef0 * ( wslpi(ji,jj+1,jk) + wslpi(ji,jj,jk) )
@@ -398,10 +389,10 @@
                ! vertical flux on v field
                zfvw(ji,jk) = zcoef3 * ( zdiv (ji,jk-1) + zdiv (ji-1,jk-1)     &
-                                       +zdiv (ji,jk  ) + zdiv (ji-1,jk  ) )   &
-                           + zcoef4 * ( zdjv (ji,jk-1) + zdj1v(ji  ,jk-1)     &
-                                       +zdjv (ji,jk  ) + zdj1v(ji  ,jk  ) )
+                  &                    +zdiv (ji,jk  ) + zdiv (ji-1,jk  ) )   &
+                  &        + zcoef4 * ( zdjv (ji,jk-1) + zdj1v(ji  ,jk-1)     &
+                  &                    +zdjv (ji,jk  ) + zdj1v(ji  ,jk  ) )
                ! update avmv (add isopycnal vertical coefficient to avmv)
-               ! Caution: zcoef0 include aht0, so divided by aht0 to obtain slp^2 * aht0
-               avmv(ji,jj,jk) = avmv(ji,jj,jk) + ( zvwslpi * zvwslpi + zvwslpj * zvwslpj ) / aht0
+               ! Caution: zcoef0 include rn_aht_0, so divided by rn_aht_0 to obtain slp^2 * rn_aht_0
+               avmv(ji,jj,jk) = avmv(ji,jj,jk) + ( zvwslpi * zvwslpi + zvwslpj * zvwslpj ) / rn_aht_0
             END DO
          END DO
@@ -412,13 +403,6 @@
          DO jk = 1, jpkm1
             DO ji = 2, jpim1
-               ! volume elements
-               zbu = e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-               zbv = e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
-               ! part of the k-component of isopycnal momentum diffusive trends
-               zuav = ( zfuw(ji,jk) - zfuw(ji,jk+1) ) / zbu
-               zvav = ( zfvw(ji,jk) - zfvw(ji,jk+1) ) / zbv
-               ! add the trends to the general trends
-               ua(ji,jj,jk) = ua(ji,jj,jk) + zuav
-               va(ji,jj,jk) = va(ji,jj,jk) + zvav
+               ua(ji,jj,jk) = ua(ji,jj,jk) + ( zfuw(ji,jk) - zfuw(ji,jk+1) ) / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
+               va(ji,jj,jk) = va(ji,jj,jk) + ( zfvw(ji,jk) - zfvw(ji,jk+1) ) / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
             END DO
          END DO
@@ -432,15 +416,4 @@
    END SUBROUTINE dyn_ldf_iso
 
-# else
-   !!----------------------------------------------------------------------
-   !!   Dummy module                           NO rotation of mixing tensor
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE dyn_ldf_iso( kt )               ! Empty routine
-      INTEGER, INTENT(in) :: kt
-      WRITE(*,*) 'dyn_ldf_iso: You should not have seen this print! error?', kt
-   END SUBROUTINE dyn_ldf_iso
-#endif
-
    !!======================================================================
 END MODULE dynldf_iso
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_lap.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_lap.F90	(revision 6040)
+++ 	(revision )
@@ -1,100 +1,0 @@
-MODULE dynldf_lap
-   !!======================================================================
-   !!                       ***  MODULE  dynldf_lap  ***
-   !! Ocean dynamics:  lateral viscosity trend
-   !!======================================================================
-   !! History :  OPA  ! 1990-09 (G. Madec) Original code
-   !!            4.0  ! 1991-11 (G. Madec)
-   !!            6.0  ! 1996-01 (G. Madec) statement function for e3 and ahm
-   !!   NEMO     1.0  ! 2002-06 (G. Madec)  F90: Free form and module
-   !!             -   ! 2004-08 (C. Talandier) New trends organization
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   dyn_ldf_lap  : update the momentum trend with the lateral diffusion
-   !!                  using an iso-level harmonic operator
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE ldfdyn_oce      ! ocean dynamics: lateral physics
-   USE zdf_oce         ! ocean vertical physics
-   !
-   USE in_out_manager  ! I/O manager
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC dyn_ldf_lap  ! called by step.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldfdyn_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE dyn_ldf_lap( kt )
-      !!----------------------------------------------------------------------
-      !!                     ***  ROUTINE dyn_ldf_lap  ***
-      !!                       
-      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
-      !!      trend and add it to the general trend of tracer equation.
-      !!
-      !! ** Method  :   The before horizontal momentum diffusion trend is an
-      !!      harmonic operator (laplacian type) which separates the divergent
-      !!      and rotational parts of the flow.
-      !!      Its horizontal components are computed as follow:
-      !!         difu = 1/e1u di[ahmt hdivb] - 1/(e2u*e3u) dj-1[e3f ahmf rotb]
-      !!         difv = 1/e2v dj[ahmt hdivb] + 1/(e1v*e3v) di-1[e3f ahmf rotb]
-      !!      in the rotational part of the diffusion.
-      !!      Add this before trend to the general trend (ua,va):
-      !!            (ua,va) = (ua,va) + (diffu,diffv)
-      !!
-      !! ** Action : - Update (ua,va) with the iso-level harmonic mixing trend
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
-      !
-      INTEGER  ::   ji, jj, jk             ! dummy loop indices
-      REAL(wp) ::   zua, zva, ze2u, ze1v   ! local scalars
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dyn_ldf_lap')
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dyn_ldf : iso-level harmonic (laplacian) operator'
-         IF(lwp) WRITE(numout,*) '~~~~~~~ '
-      ENDIF
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ze2u = rotb (ji,jj,jk) * fsahmf(ji,jj,jk) * fse3f(ji,jj,jk)
-               ze1v = hdivb(ji,jj,jk) * fsahmt(ji,jj,jk)
-               ! horizontal diffusive trends
-               zua = - ( ze2u - rotb (ji,jj-1,jk)*fsahmf(ji,jj-1,jk)*fse3f(ji,jj-1,jk) ) / ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
-                     + ( hdivb(ji+1,jj,jk)*fsahmt(ji+1,jj,jk) - ze1v                   ) / e1u(ji,jj)
-
-               zva = + ( ze2u - rotb (ji-1,jj,jk)*fsahmf(ji-1,jj,jk)*fse3f(ji-1,jj,jk) ) / ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
-                     + ( hdivb(ji,jj+1,jk)*fsahmt(ji,jj+1,jk) - ze1v                   ) / e2v(ji,jj)
-
-               ! add it to the general momentum trends
-               ua(ji,jj,jk) = ua(ji,jj,jk) + zua
-               va(ji,jj,jk) = va(ji,jj,jk) + zva
-            END DO
-         END DO
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf_lap')
-      !
-   END SUBROUTINE dyn_ldf_lap
-
-   !!======================================================================
-END MODULE dynldf_lap
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_lap_blp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_lap_blp.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynldf_lap_blp.F90	(revision 6041)
@@ -0,0 +1,169 @@
+MODULE dynldf_lap_blp
+   !!======================================================================
+   !!                   ***  MODULE  dynldf_lap_blp  ***
+   !! Ocean dynamics:  lateral viscosity trend (laplacian and bilaplacian)
+   !!======================================================================
+   !! History :  OPA  ! 1990-09 (G. Madec) Original code
+   !!            4.0  ! 1991-11 (G. Madec)
+   !!            6.0  ! 1996-01 (G. Madec) statement function for e3 and ahm
+   !!   NEMO     1.0  ! 2002-06 (G. Madec)  F90: Free form and module
+   !!             -   ! 2004-08 (C. Talandier) New trends organization
+   !!            3.7  ! 2014-01  (F. Lemarie, G. Madec)  restructuration/simplification of ahm specification,
+   !!                 !                                  add velocity dependent coefficient and optional read in file
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_ldf_lap   : update the momentum trend with the lateral viscosity using an iso-level   laplacian operator
+   !!   dyn_ldf_blp   : update the momentum trend with the lateral viscosity using an iso-level bilaplacian operator
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE ldfdyn         ! lateral diffusion: eddy viscosity coef.
+   USE ldfslp         ! iso-neutral slopes 
+   USE zdf_oce        ! ocean vertical physics
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC dyn_ldf_lap  ! called by dynldf.F90
+   PUBLIC dyn_ldf_blp  ! called by dynldf.F90
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE dyn_ldf_lap( kt, pub, pvb, pua, pva, kpass )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dyn_ldf_lap  ***
+      !!                       
+      !! ** Purpose :   Compute the before horizontal momentum diffusive 
+      !!      trend and add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   The Laplacian operator apply on horizontal velocity is 
+      !!      writen as :   grad_h( ahmt div_h(U )) - curl_h( ahmf curl_z(U) ) 
+      !!
+      !! ** Action : - pua, pva increased by the harmonic operator applied on pub, pvb.
+      !!----------------------------------------------------------------------
+      INTEGER                         , INTENT(in   ) ::   kt         ! ocean time-step index
+      INTEGER                         , INTENT(in   ) ::   kpass      ! =1/2 first or second passage
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   pub, pvb   ! before velocity  [m/s]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pua, pva   ! velocity trend   [m/s2]
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zsign        ! local scalars
+      REAL(wp) ::   zua, zva     ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:) ::  zcur, zdiv
+      !!----------------------------------------------------------------------
+      !
+      IF( kt == nit000 .AND. lwp ) THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'dyn_ldf : iso-level harmonic (laplacian) operator, pass=', kpass
+         WRITE(numout,*) '~~~~~~~ '
+      ENDIF
+      !
+      IF( nn_timing == 1 )   CALL timing_start('dyn_ldf_lap')
+      !
+      CALL wrk_alloc( jpi, jpj, zcur, zdiv ) 
+      !
+      IF( kpass == 1 ) THEN   ;   zsign =  1._wp      ! bilaplacian operator require a minus sign
+      ELSE                    ;   zsign = -1._wp      !  (eddy viscosity coef. >0)
+      ENDIF
+      !
+      !                                                ! ===============
+      DO jk = 1, jpkm1                                 ! Horizontal slab
+         !                                             ! ===============
+         DO jj = 2, jpj
+            DO ji = fs_2, jpi   ! vector opt.
+               !                                      ! ahm * e3 * curl  (computed from 1 to jpim1/jpjm1)
+!!gm open question here : fse3f  at before or now ?    probably now...
+!!gm note that ahmf has already been multiplied by fmask
+               zcur(ji-1,jj-1) = ahmf(ji-1,jj-1,jk) * fse3f(ji-1,jj-1,jk) * r1_e1e2f(ji-1,jj-1)       &
+                  &     * (  e2v(ji  ,jj-1) * pvb(ji  ,jj-1,jk) - e2v(ji-1,jj-1) * pvb(ji-1,jj-1,jk)  &
+                  &        - e1u(ji-1,jj  ) * pub(ji-1,jj  ,jk) + e1u(ji-1,jj-1) * pub(ji-1,jj-1,jk)  ) 
+               !                                      ! ahm * div        (computed from 2 to jpi/jpj)
+               zdiv(ji,jj)     = ahmt(ji,jj,jk) * r1_e1e2t(ji,jj) / fse3t_b(ji,jj,jk) * tmask(ji,jj,jk)                           &
+                  &     * (  e2u(ji,jj)*fse3u_b(ji,jj,jk) * pub(ji,jj,jk) - e2u(ji-1,jj)*fse3u_b(ji-1,jj,jk) * pub(ji-1,jj,jk)  &
+                  &        + e1v(ji,jj)*fse3v_b(ji,jj,jk) * pvb(ji,jj,jk) - e1v(ji,jj-1)*fse3v_b(ji,jj-1,jk) * pvb(ji,jj-1,jk)  )
+            END DO  
+         END DO  
+         !
+         DO jj = 2, jpjm1                             ! - curl( curl) + grad( div )
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               pua(ji,jj,jk) = pua(ji,jj,jk) + zsign * (                                                   &
+                  &              - ( zcur(ji  ,jj) - zcur(ji,jj-1) ) /  ( e2u(ji,jj) * fse3u(ji,jj,jk) )   &
+                  &              + ( zdiv(ji+1,jj) - zdiv(ji,jj  ) ) * r1_e1u(ji,jj)                     )
+                  !
+               pva(ji,jj,jk) = pva(ji,jj,jk) + zsign * (                                                   &
+                  &                ( zcur(ji,jj  ) - zcur(ji-1,jj) ) /  ( e1v(ji,jj) * fse3v(ji,jj,jk) )   &
+                  &              + ( zdiv(ji,jj+1) - zdiv(ji  ,jj) ) * r1_e2v(ji,jj)                     )
+            END DO
+         END DO
+         !                                             ! ===============
+      END DO                                           !   End of slab
+      !                                                ! ===============
+      CALL wrk_dealloc( jpi, jpj, zcur, zdiv ) 
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf_lap')
+      !
+   END SUBROUTINE dyn_ldf_lap
+
+
+   SUBROUTINE dyn_ldf_blp( kt, pub, pvb, pua, pva )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE dyn_ldf_blp  ***
+      !!                    
+      !! ** Purpose :   Compute the before lateral momentum viscous trend 
+      !!              and add it to the general trend of momentum equation.
+      !!
+      !! ** Method  :   The lateral viscous trends is provided by a bilaplacian
+      !!      operator applied to before field (forward in time).
+      !!      It is computed by two successive calls to dyn_ldf_lap routine
+      !!
+      !! ** Action :   pta   updated with the before rotated bilaplacian diffusion
+      !!----------------------------------------------------------------------
+      INTEGER                         , INTENT(in   ) ::   kt         ! ocean time-step index
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   pub, pvb   ! before velocity fields
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pua, pva   ! momentum trend
+      !
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zulap, zvlap   ! laplacian at u- and v-point
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('dyn_ldf_blp')
+      !
+      CALL wrk_alloc( jpi, jpj, jpk, zulap, zvlap ) 
+      !
+      IF( kt == nit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'dyn_ldf_blp : bilaplacian operator momentum '
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~'
+      ENDIF
+      !
+      zulap(:,:,:) = 0._wp
+      zvlap(:,:,:) = 0._wp
+      !
+      CALL dyn_ldf_lap( kt, pub, pvb, zulap, zvlap, 1 )   ! rotated laplacian applied to ptb (output in zlap)
+      !
+      CALL lbc_lnk( zulap(:,:,:) , 'U', -1. )             ! Lateral boundary conditions
+      CALL lbc_lnk( zvlap(:,:,:) , 'V', -1. )
+      !
+      CALL dyn_ldf_lap( kt, zulap, zvlap, pua, pva, 2 )   ! rotated laplacian applied to zlap (output in pta)
+      !
+      CALL wrk_dealloc( jpi, jpj, jpk, zulap, zvlap ) 
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('dyn_ldf_blp')
+      !
+   END SUBROUTINE dyn_ldf_blp
+
+   !!======================================================================
+END MODULE dynldf_lap_blp
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynnept.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynnept.F90	(revision 6040)
+++ 	(revision )
@@ -1,597 +1,0 @@
-MODULE dynnept
-   !!======================================================================
-   !!                       ***  MODULE  dynnept  ***
-   !! Ocean dynamics: Neptune effect as proposed by Greg Holloway,
-   !!                 recoded version of simplest case (u*, v* only)
-   !!======================================================================
-   !! History :  1.0  !  2007-06  (Michael Dunphy)  Modular form: - new namelist parameters
-   !!                                                             - horizontal diffusion for Neptune
-   !!                                                             - vertical diffusion for gm in momentum eqns
-   !!                                                             - option to use Neptune in Coriolis eqn
-   !!                    2011-08  (Jeff Blundell, NOCS) Simplified form for temporally invariant u*, v*
-   !!                                               Horizontal and vertical diffusivity formulations removed
-   !!                                               Dynamic allocation of storage added
-   !!                                               Option of ramping Neptune vel. down
-   !!                                               to zero added in shallow depths added
-   !!----------------------------------------------------------------------
-   !! dynnept_alloc        :
-   !! dyn_nept_init        :
-   !! dyn_nept_div_cur_init:
-   !! dyn_nept_cor         :
-   !! dyn_nept_vel         :
-   !! dyn_nept_smooth_vel  :
-   !!----------------------------------------------------------------------
-   USE oce              ! ocean dynamics and tracers
-   USE dom_oce          ! ocean space and time domain
-   USE in_out_manager   ! I/O manager
-   USE lib_mpp          ! distributed memory computing
-   USE prtctl           ! Print control
-   USE phycst
-   USE lbclnk
-   USE wrk_nemo        ! Memory Allocation
-
-   IMPLICIT NONE
-   PRIVATE
-
-   !! * Routine accessibility
-   PUBLIC dyn_nept_init      ! routine called by nemogcm.F90
-   PUBLIC dyn_nept_cor       ! routine called by step.F90
-   !! dynnept_alloc()         is called only by dyn_nept_init, within this module
-   !! dyn_nept_div_cur_init   is called only by dyn_nept_init, within this module
-   !! dyn_nept_vel            is called only by dyn_nept_cor,  within this module
-
-   !! * Shared module variables
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)    :: zunep, zvnep  ! Neptune u and v
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)  :: zhdivnep      ! hor. div for Neptune vel.
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)  :: zmrotnep      ! curl for Neptune vel.
-
-
-   !! * Namelist namdyn_nept variables
-   LOGICAL, PUBLIC  ::  ln_neptsimp          ! yes/no simplified neptune
-
-   LOGICAL          ::  ln_smooth_neptvel    ! yes/no smooth zunep, zvnep
-   REAL(wp)         ::  rn_tslse             ! value of lengthscale L at the equator
-   REAL(wp)         ::  rn_tslsp             ! value of lengthscale L at the pole
-!! Specify whether to ramp down the Neptune velocity in shallow
-!! water, and the depth range controlling such ramping down
-   LOGICAL          ::  ln_neptramp          ! ramp down Neptune velocity in shallow water
-   REAL(wp)         ::  rn_htrmin            ! min. depth of transition range
-   REAL(wp)         ::  rn_htrmax            ! max. depth of transition range
-
-   !! * Module variables
-
-
-   !! * Substitutions
-#  include "vectopt_loop_substitute.h90"
-#  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !!   OPA 9.0 , implemented by Bedford Institute of Oceanography
-   !!----------------------------------------------------------------------
-
-   !! $Id$
- CONTAINS
-
-   INTEGER FUNCTION dynnept_alloc()
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE dynnept_alloc  ***
-      !!----------------------------------------------------------------------
-      ALLOCATE( zunep(jpi,jpj) , zvnep(jpi,jpj) ,     &
-         &      zhdivnep(jpi,jpj,jpk) , zmrotnep(jpi,jpj,jpk) , STAT=dynnept_alloc )
-         !
-      IF( dynnept_alloc /= 0 )   CALL ctl_warn('dynnept_alloc: array allocate failed.')
-   END FUNCTION dynnept_alloc
-
-
-   SUBROUTINE dyn_nept_init
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dyn_nept_init  ***
-      !!
-      !! ** Purpose :   Read namelist parameters, initialise arrays
-      !!                and compute the arrays zunep and zvnep
-      !!
-      !! ** Method  :   zunep =
-      !!                zvnep =
-      !!
-      !! ** History :  1.0  !   07-05  (Zeliang Wang)   Original code for zunep, zvnep
-      !!               1.1  !   07-06  (Michael Dunphy) namelist and  initialisation
-      !!               2.0  ! 2011-07  (Jeff Blundell, NOCS)
-      !!                    ! Simplified form for temporally invariant u*, v*
-      !!                    ! Horizontal and vertical diffusivity formulations removed
-      !!                    ! Includes optional tapering-off in shallow depths
-      !!----------------------------------------------------------------------
-      USE iom
-      !!
-      INTEGER  ::   ji, jj, jk    ! dummy loop indices
-      REAL(wp) :: unemin,unemax,vnemin,vnemax   ! extrema of (u*, v*) fields
-      REAL(wp) :: zhdivmin,zhdivmax             ! extrema of horizontal divergence of (u*, v*) fields
-      REAL(wp) :: zmrotmin,zmrotmax             ! extrema of the curl of the (u*, v*) fields
-      REAL(wp) :: ustar,vstar                   ! (u*, v*) before tapering in shallow water
-      REAL(wp) :: hramp                         ! depth over which Neptune vel. is ramped down
-      !
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zht, htn, tscale, tsp, hur_n, hvr_n, hu_n, hv_n      
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: znmask
-      !!
-      NAMELIST/namdyn_nept/ ln_neptsimp, ln_smooth_neptvel, rn_tslse, rn_tslsp,      &
-                            ln_neptramp, rn_htrmin, rn_htrmax
-      INTEGER  ::   ios
-      !!----------------------------------------------------------------------
-      ! Define the (simplified) Neptune parameters
-      ! ==========================================
-
-      REWIND( numnam_ref )              ! Namelist namdyn_nept in reference namelist : Simplified Neptune
-      READ  ( numnam_ref, namdyn_nept, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_nept in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namdyn_nept in reference namelist : Simplified Neptune
-      READ  ( numnam_cfg, namdyn_nept, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_nept in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, namdyn_nept )
-
-      IF(lwp) THEN                      ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'dyn_nept_init : Simplified Neptune module'
-         WRITE(numout,*) '~~~~~~~~~~~~~'
-         WRITE(numout,*) ' -->   Reading namelist namdyn_nept parameters:'
-         WRITE(numout,*) '       ln_neptsimp          = ', ln_neptsimp
-         WRITE(numout,*)
-         IF( ln_neptsimp ) THEN
-            WRITE(numout,*) '       ln_smooth_neptvel    = ', ln_smooth_neptvel
-            WRITE(numout,*) '       rn_tslse             = ', rn_tslse
-            WRITE(numout,*) '       rn_tslsp             = ', rn_tslsp
-            WRITE(numout,*)
-            WRITE(numout,*) '       ln_neptramp          = ', ln_neptramp
-            WRITE(numout,*) '       rn_htrmin            = ', rn_htrmin
-            WRITE(numout,*) '       rn_htrmax            = ', rn_htrmax
-            WRITE(numout,*)
-         ENDIF
-      ENDIF
-      !
-      IF( .NOT. ln_neptsimp ) RETURN
-      !                                 ! Dynamically allocate local work arrays
-      CALL wrk_alloc( jpi, jpj     , zht, htn, tscale, tsp, hur_n, hvr_n, hu_n, hv_n  ) 
-      CALL wrk_alloc( jpi, jpj, jpk, znmask                                          ) 
-
-      IF( ln_smooth_neptvel ) THEN
-         IF(lwp) WRITE(numout,*) ' -->   neptune velocities will be smoothed'
-      ELSE
-         IF(lwp) WRITE(numout,*) ' -->   neptune velocities will not be smoothed'
-      ENDIF
-
-      IF( ln_neptramp ) THEN
-          IF(lwp) WRITE(numout,*) ' -->   ln_neptramp enabled, ramp down Neptune'
-          IF(lwp) WRITE(numout,*) ' -->   velocity components in shallow water'
-      ELSE
-          IF(lwp) WRITE(numout,*) ' -->   ln_neptramp disabled'
-      ENDIF
-
-
-!!    Perform dynamic allocation of shared module variables
-      IF( dynnept_alloc() /= 0 )   CALL ctl_warn('dynnept_alloc: array allocate failed.')
-
-      IF( .not. ln_rstart ) THEN      ! If restarting, these arrays are read from the restart file
-         zhdivnep(:,:,:) = 0.0_wp
-         zmrotnep(:,:,:) = 0.0_wp
-      END IF
-
-      ! Computation of nmask: same as fmask, but fmask cannot be used
-      ! because it is modified after it is computed in dom_msk
-      ! (this can be optimised to save memory, such as merge into next loop)
-      DO jk = 1, jpk
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector loop
-               znmask(ji,jj,jk) = tmask(ji,jj  ,jk) * tmask(ji+1,jj  ,jk)   &
-                   &            * tmask(ji,jj+1,jk) * tmask(ji+1,jj+1,jk)
-            END DO
-         END DO
-      END DO
-
-      CALL lbc_lnk( znmask, 'F', 1.0_wp )
-
-
-      ! now compute zunep, zvnep (renamed from earlier versions)
-
-      zunep(:,:) = 0.0_wp
-      zvnep(:,:) = 0.0_wp
-
-      htn(:,:) = 0.0_wp            ! ocean depth at F-point
-      DO jk = 1, jpk
-         htn(:,:) = htn(:,:) + fse3f(:,:,jk) * znmask(:,:,jk)
-      END DO
-
-      IF( ln_smooth_neptvel ) THEN
-         CALL dyn_nept_smooth_vel( htn, zht, .TRUE. )
-      !! overwrites zht with a smoothed version of htn
-      ELSE
-         zht(:,:) = htn(:,:)
-      !! use unsmoothed version of htn
-      ENDIF
-      CALL lbc_lnk( zht, 'F', 1.0_wp )
-
-      !! Compute tsp, a stream function for the Neptune velocity,
-      !! with the usual geophysical sign convention
-      !! Then zunep = -latitudinal derivative "-(1/H)*d(tsp)/dy"
-      !!      zvnep = longitudinal derivative " (1/H)*d(tsp)/dx"
-
-      tsp(:,:)    = 0.0_wp
-      tscale(:,:) = 0.0_wp
-
-      tscale(:,:) = rn_tslsp + (rn_tslse - rn_tslsp) *   &
-                   ( 0.5_wp + 0.5_wp * COS( 2.0_wp * rad * gphif(:,:) )  )
-      tsp   (:,:) = -2.0_wp * omega * SIN( rad * gphif(:,:) ) * tscale(:,:) * tscale(:,:) * zht(:,:)
-
-
-      IF( ln_smooth_neptvel ) THEN
-         CALL dyn_nept_smooth_vel( hu, hu_n, .TRUE. )
-      !! overwrites hu_n with a smoothed version of hu
-      ELSE
-         hu_n(:,:) = hu(:,:)
-      !! use unsmoothed version of hu
-      ENDIF
-      CALL lbc_lnk( hu_n, 'U', 1.0_wp )
-      hu_n(:,:) = hu_n(:,:) * umask(:,:,1)
-
-      WHERE( hu_n(:,:) == 0.0_wp )
-         hur_n(:,:) = 0.0_wp
-      ELSEWHERE
-         hur_n(:,:) = 1.0_wp / hu_n(:,:)
-      END WHERE
-
-
-      IF( ln_smooth_neptvel ) THEN
-         CALL dyn_nept_smooth_vel( hv, hv_n, .TRUE. )
-      !! overwrites hv_n with a smoothed version of hv
-      ELSE
-         hv_n(:,:) = hv(:,:)
-      !! use unsmoothed version of hv
-      ENDIF
-      CALL lbc_lnk( hv_n, 'V', 1.0_wp )
-      hv_n(:,:) = hv_n(:,:) * vmask(:,:,1)
-
-      WHERE( hv_n == 0.0_wp )
-         hvr_n(:,:) = 0.0_wp
-      ELSEWHERE
-         hvr_n(:,:) = 1.0_wp / hv_n(:,:)
-      END WHERE
-
-
-      unemin =  1.0e35
-      unemax = -1.0e35
-      vnemin =  1.0e35
-      vnemax = -1.0e35
-      hramp = rn_htrmax - rn_htrmin
-      DO jj = 2, jpj-1
-         DO ji = 2, jpi-1
-            if ( umask(ji,jj,1) /= 0.0_wp ) then
-               ustar =-1.0_wp/e2u(ji,jj) * hur_n(ji,jj) * ( tsp(ji,jj)-tsp(ji,jj-1) ) * umask(ji,jj,1)
-               if ( ln_neptramp ) then
-!!                Apply ramp down to velocity component
-                  if ( hu_n(ji,jj) <= rn_htrmin ) then
-                    zunep(ji,jj) = 0.0_wp
-                   else if ( hu_n(ji,jj) >= rn_htrmax ) then
-                    zunep(ji,jj) = ustar
-                   else if ( hramp > 0.0_wp ) then
-                    zunep(ji,jj) = ( hu_n(ji,jj) - rn_htrmin) * ustar/hramp
-                  endif
-                else
-                 zunep(ji,jj) = ustar
-               endif 
-             else
-              zunep(ji,jj) = 0.0_wp
-            endif
-            if ( vmask(ji,jj,1) /= 0.0_wp ) then
-               vstar = 1.0_wp/e1v(ji,jj) * hvr_n(ji,jj) * ( tsp(ji,jj)-tsp(ji-1,jj) ) * vmask(ji,jj,1)
-               if ( ln_neptramp ) then
-!!                Apply ramp down to velocity component
-                  if ( hv_n(ji,jj) <= rn_htrmin ) then
-                    zvnep(ji,jj) = 0.0_wp
-                   else if ( hv_n(ji,jj) >= rn_htrmax ) then
-                    zvnep(ji,jj) = vstar
-                   else if ( hramp > 0.0_wp ) then
-                    zvnep(ji,jj) = ( hv_n(ji,jj) - rn_htrmin) * vstar/hramp
-                  endif
-                else
-                  zvnep(ji,jj) = vstar
-               endif
-             else
-              zvnep(ji,jj) = 0.0_wp
-            endif
-            unemin = min( unemin, zunep(ji,jj) )
-            unemax = max( unemax, zunep(ji,jj) )
-            vnemin = min( vnemin, zvnep(ji,jj) )
-            vnemax = max( vnemax, zvnep(ji,jj) )
-         END DO
-      END DO
-      CALL lbc_lnk( zunep, 'U', -1.0_wp )
-      CALL lbc_lnk( zvnep, 'V', -1.0_wp )
-      WRITE(numout,*) '      zunep: min, max       = ', unemin,unemax
-      WRITE(numout,*) '      zvnep: min, max       = ', vnemin,vnemax
-      WRITE(numout,*)
-
-      !!  Compute, once and for all, the horizontal divergence (zhdivnep)
-      !!  and the curl (zmrotnep) of the Neptune velocity field (zunep, zvnep)
-      CALL dyn_nept_div_cur_init
-
-      !! Check the ranges of the computed divergence & vorticity
-      zhdivmin =  1.0e35
-      zhdivmax = -1.0e35
-      zmrotmin =  1.0e35
-      zmrotmax = -1.0e35
-      hramp = rn_htrmax - rn_htrmin
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         DO jj = 2, jpj-1
-            DO ji = 2, jpi-1
-               zhdivmin = min( zhdivmin, zhdivnep(ji,jj,jk) )
-               zhdivmax = max( zhdivmax, zhdivnep(ji,jj,jk) )
-               zmrotmin = min( zmrotmin, zmrotnep(ji,jj,jk) )
-               zmrotmax = max( zmrotmax, zmrotnep(ji,jj,jk) )
-            END DO
-         END DO
-      END DO
-      WRITE(numout,*) '   zhdivnep: min, max       = ', zhdivmin,zhdivmax
-      WRITE(numout,*) '   zmrotnep: min, max       = ', zmrotmin,zmrotmax
-      WRITE(numout,*)
-
-!!    Deallocate temporary workspace arrays, which are all local to
-!!    this routine, except where passed as arguments to other routines
-      CALL wrk_dealloc( jpi, jpj     , zht, htn, tscale, tsp, hur_n, hvr_n, hu_n, hv_n  ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, znmask                                          ) 
-      !
-   END SUBROUTINE dyn_nept_init
-
-
-   SUBROUTINE dyn_nept_div_cur_init
-      !!----------------------------------------------------------------------
-      !!             ***  ROUTINE dyn_nept_div_cur_init  ***
-      !!
-      !! ** Purpose :   compute the horizontal divergence and the relative
-      !!                vorticity of the time-invariant u* and v* Neptune
-      !!                effect velocities (called zunep, zvnep)
-      !!
-      !! ** Method  : - Divergence:
-      !!      - compute the divergence given by :
-      !!         zhdivnep = 1/(e1t*e2t*e3t) ( di[e2u*e3u zunep] + dj[e1v*e3v zvnep] )
-      !!      - compute the curl in tensorial formalism:
-      !!         zmrotnep = 1/(e1f*e2f) ( di[e2v zvnep] - dj[e1u zunep] )
-      !!      Note: Coastal boundary condition: lateral friction set through
-      !!      the value of fmask along the coast (see dommsk.F90) and shlat
-      !!      (namelist parameter)
-      !!
-      !! ** Action  : - compute zhdivnep, the hor. divergence of (u*, v*)
-      !!              - compute zmrotnep, the rel. vorticity  of (u*, v*)
-      !!
-      !! History :  OPA  ! 1987-06  (P. Andrich, D. L Hostis)  Original code
-      !!            4.0  ! 1991-11  (G. Madec)
-      !!            6.0  ! 1993-03  (M. Guyon)  symetrical conditions
-      !!            7.0  ! 1996-01  (G. Madec)  s-coordinates
-      !!            8.0  ! 1997-06  (G. Madec)  lateral boundary cond., lbc
-      !!            8.1  ! 1997-08  (J.M. Molines)  Open boundaries
-      !!            8.2  ! 2000-03  (G. Madec)  no slip accurate
-      !!  NEMO      1.0  ! 2002-09  (G. Madec, E. Durand)  Free form, F90
-      !!             -   ! 2005-01  (J. Chanut) Unstructured open boundaries
-      !!             -   ! 2003-08  (G. Madec)  merged of cur and div, free form, F90
-      !!             -   ! 2005-01  (J. Chanut, A. Sellar) unstructured open boundaries
-      !!            3.3  ! 2010-09  (D.Storkey and E.O'Dea) bug fixes for BDY module
-      !!                 ! 2011-06  (Jeff Blundell, NOCS) Adapt code from divcur.F90
-      !!                 !           to compute Neptune effect fields only
-      !!----------------------------------------------------------------------
-      !
-      INTEGER  ::   ji, jj, jk          ! dummy loop indices
-      !!----------------------------------------------------------------------
-      !    
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'dyn_nept_div_cur_init :'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~~~~~'
-      IF(lwp) WRITE(numout,*) 'horizontal velocity divergence and'
-      IF(lwp) WRITE(numout,*) 'relative vorticity of Neptune flow'
-#if defined key_noslip_accurate
-   !!----------------------------------------------------------------------
-   !!   'key_noslip_accurate'                     2nd order centered scheme
-   !!                                                4th order at the coast
-   !!----------------------------------------------------------------------
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'WARNING: key_noslip_accurate option'
-      IF(lwp) WRITE(numout,*) 'not implemented in simplified Neptune'
-      CALL ctl_warn( ' noslip_accurate option not implemented' )
-#endif
-
-   !!----------------------------------------------------------------------
-   !!   Default option                           2nd order centered schemes
-   !!----------------------------------------------------------------------
-
-      ! Apply the div and curl operators to the depth-dependent velocity
-      ! field produced by multiplying (zunep, zvnep) by (umask, vmask), exactly
-      ! equivalent to the equivalent calculation in the unsimplified code
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         !                                             ! --------
-         ! Horizontal divergence                       !   div
-         !                                             ! --------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zhdivnep(ji,jj,jk) =   &
-               &   (  e2u(ji  ,jj  )*fse3u(ji  ,jj  ,jk) * zunep(ji  ,jj  ) * umask(ji  ,jj  ,jk)    &
-               &    - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * zunep(ji-1,jj  ) * umask(ji-1,jj  ,jk)    &
-               &    + e1v(ji  ,jj  )*fse3v(ji  ,jj  ,jk) * zvnep(ji  ,jj  ) * vmask(ji  ,jj  ,jk)    &
-               &    - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * zvnep(ji  ,jj-1) * vmask(ji  ,jj-1,jk) )  &
-               &  / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-            END DO
-         END DO
-
-         IF( .NOT. AGRIF_Root() ) THEN
-            IF ((nbondi ==  1).OR.(nbondi == 2))  zhdivnep(nlci-1 , :     ,jk) = 0.0_wp   ! east
-            IF ((nbondi == -1).OR.(nbondi == 2))  zhdivnep(2      , :     ,jk) = 0.0_wp   ! west
-            IF ((nbondj ==  1).OR.(nbondj == 2))  zhdivnep(:      ,nlcj-1 ,jk) = 0.0_wp   ! north
-            IF ((nbondj == -1).OR.(nbondj == 2))  zhdivnep(:      ,2      ,jk) = 0.0_wp   ! south
-         ENDIF
-
-         !                                             ! --------
-         ! relative vorticity                          !   rot
-         !                                             ! --------
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zmrotnep(ji,jj,jk) =   &
-                  &       (  e2v(ji+1,jj  ) * zvnep(ji+1,jj  ) * vmask(ji+1,jj  ,jk)     &
-                  &        - e2v(ji  ,jj  ) * zvnep(ji  ,jj  ) * vmask(ji  ,jj  ,jk)     &
-                  &        - e1u(ji  ,jj+1) * zunep(ji  ,jj+1) * umask(ji  ,jj+1,jk)     &
-                  &        + e1u(ji  ,jj  ) * zunep(ji  ,jj  ) * umask(ji  ,jj  ,jk)  )  &
-                  &       * fmask(ji,jj,jk) / ( e1f(ji,jj) * e2f(ji,jj) )
-            END DO
-         END DO
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-
-      ! 4. Lateral boundary conditions on zhdivnep and zmrotnep
-      ! ----------------------------------=======-----=======
-      CALL lbc_lnk( zhdivnep, 'T', 1. )   ;   CALL lbc_lnk( zmrotnep , 'F', 1. )     ! lateral boundary cond. (no sign change)
-      !
-   END SUBROUTINE dyn_nept_div_cur_init
-
-
-   SUBROUTINE dyn_nept_cor( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dyn_nept_cor  ***
-      !!
-      !! ** Purpose :  Add or subtract the Neptune velocity from the now velocities
-      !!
-      !! ** Method  :  First call : kt not equal to lastkt -> subtract zunep, zvnep
-      !!               Second call: kt     equal to lastkt -> add zunep, zvnep
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index
-      !!
-      INTEGER, SAVE :: lastkt             ! store previous kt
-      DATA lastkt/-1/                     ! initialise previous kt
-      !!----------------------------------------------------------------------
-      !
-      IF( ln_neptsimp ) THEN
-         !
-         IF( lastkt /= kt ) THEN          ! 1st call for this kt: subtract the Neptune velocities zunep, zvnep from un, vn
-            CALL dyn_nept_vel( -1 )      ! -1 = subtract
-            !
-         ELSE                              ! 2nd call for this kt: add the Neptune velocities zunep, zvnep to un, vn
-            CALL dyn_nept_vel(  1 )      !  1 = add
-            !
-         ENDIF
-         !
-         lastkt = kt     ! Store kt
-         !
-      ENDIF
-      !
-   END SUBROUTINE dyn_nept_cor
-
-
-   SUBROUTINE dyn_nept_vel( ksign )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dyn_nept_vel  ***
-      !!
-      !! ** Purpose :  Add or subtract the Neptune velocity from the now
-      !!               velocities based on ksign
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   ksign    ! 1 or -1 to add or subtract neptune velocities
-      !!
-      INTEGER :: jk                       ! dummy loop index
-      !!----------------------------------------------------------------------
-      !
-      ! Adjust the current velocity un, vn by adding or subtracting the
-      ! Neptune velocities zunep, zvnep, as determined by argument ksign
-      DO jk=1, jpk
-         un(:,:,jk) = un(:,:,jk) + ksign * zunep(:,:) * umask(:,:,jk)
-         vn(:,:,jk) = vn(:,:,jk) + ksign * zvnep(:,:) * vmask(:,:,jk)
-      END DO
-      !
-   END SUBROUTINE dyn_nept_vel
-
-
-   SUBROUTINE dyn_nept_smooth_vel( htold, htnew, ld_option )
-
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE dyn_nept_smooth_vel  ***
-      !!
-      !! ** Purpose :  Compute smoothed topography field.
-      !!
-      !! ** Action : - Updates the array htnew (output) with a smoothed
-      !!               version of the (input) array htold. Form of smoothing
-      !!               algorithm is controlled by the (logical) argument ld_option.
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(in   )  ::  htold      ! temporary 2D workspace
-      LOGICAL                     , INTENT(in   )  ::  ld_option  ! temporary 2D workspace
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(inout)  ::  htnew      ! temporary 2D workspace
-      !
-      INTEGER                           ::  ji, jj  ! dummy loop indices
-      INTEGER , POINTER, DIMENSION(:,:) ::  nb, iwork
-      REAL(wp), POINTER, DIMENSION(:,:) ::  work    ! temporary 2D workspace
-      !!----------------------------------------------------------------------
-      !
-      CALL wrk_alloc( jpi, jpj, nb, iwork ) 
-      CALL wrk_alloc( jpi, jpj, work      ) 
-      !
-      iwork(:,:) = 0
-
-      !! iwork is a mask of gridpoints: iwork = 1 => ocean, iwork = 0 => land
-      WHERE( htold(:,:) > 0 )
-         iwork(:,:) = 1
-         htnew(:,:) = htold(:,:)
-      ELSEWHERE
-         iwork(:,:) = 0
-         htnew(:,:) = 0.0_wp
-      END WHERE
-      !! htnew contains valid ocean depths from htold, or zero
-
-      !! set work to a smoothed/averaged version of htnew; choice controlled by ld_option
-      !! nb is set to the sum of the weights of the valid values used in work
-      IF( ld_option ) THEN
-
-         !! Apply scale-selective smoothing in determining work from htnew
-         DO jj=2,jpj-1
-            DO ji=2,jpi-1
-               work(ji,jj) = 4.0*htnew( ji , jj ) +                        &
-                           & 2.0*htnew(ji+1, jj ) + 2.0*htnew(ji-1, jj ) + &
-                           & 2.0*htnew( ji ,jj+1) + 2.0*htnew( ji ,jj-1) + &
-                           &     htnew(ji+1,jj+1) +     htnew(ji+1,jj-1) + &
-                           &     htnew(ji-1,jj+1) +     htnew(ji-1,jj-1)
-
-               nb(ji,jj)   = 4 * iwork( ji , jj ) +                        &
-                           & 2 * iwork(ji+1, jj ) + 2 * iwork(ji-1, jj ) + &
-                           & 2 * iwork( ji ,jj+1) + 2 * iwork( ji ,jj-1) + &
-                           &     iwork(ji+1,jj+1) +     iwork(ji+1,jj-1) + &
-                           &     iwork(ji-1,jj+1) +     iwork(ji-1,jj-1)
-            END DO
-         END DO
-
-      ELSE
-
-         !! Apply simple 9-point averaging in determining work from htnew
-         DO jj=2,jpj-1
-            DO ji=2,jpi-1
-               work(ji,jj) =  htnew( ji , jj ) +                    &
-                           &  htnew(ji+1, jj ) + htnew(ji-1, jj ) + &
-                           &  htnew( ji ,jj+1) + htnew( ji ,jj-1) + &
-                           &  htnew(ji+1,jj+1) + htnew(ji+1,jj-1) + &
-                           &  htnew(ji-1,jj+1) + htnew(ji-1,jj-1)
-
-               nb(ji,jj) =    iwork( ji , jj ) +                    &
-                           &  iwork(ji+1, jj ) + iwork(ji-1, jj ) + &
-                           &  iwork( ji ,jj+1) + iwork( ji ,jj-1) + &
-                           &  iwork(ji+1,jj+1) + iwork(ji+1,jj-1) + &
-                           &  iwork(ji-1,jj+1) + iwork(ji-1,jj-1)
-            END DO
-         END DO
-
-      ENDIF
-
-      !! write averaged value of work into htnew,
-      !! if average is valid and point is unmasked
-      WHERE( (htold(:,:) /= 0.0_wp ) .AND. ( nb(:,:) /= 0 ) )
-         htnew(:,:) = work(:,:)/real(nb(:,:))
-      ELSEWHERE
-         htnew(:,:) = 0.0_wp
-      END WHERE
-
-      !!    Deallocate temporary workspace arrays, all local to this routine
-      CALL wrk_dealloc( jpi, jpj, nb, iwork ) 
-      CALL wrk_dealloc( jpi, jpj, work      ) 
-      !
-   END SUBROUTINE dyn_nept_smooth_vel
-
-END MODULE dynnept
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynnxt.F90	(revision 6041)
@@ -19,4 +19,5 @@
    !!            3.5  !  2013-07  (J. Chanut) Compliant with time splitting changes
    !!            3.7  !  2014-04  (G. Madec) add the diagnostic of the time filter trends
+   !!            3.7  !  2015-11  (J. Chanut) Free surface simplification
    !!-------------------------------------------------------------------------
   
@@ -28,5 +29,4 @@
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE phycst          ! physical constants
-   USE dynspg_oce      ! type of surface pressure gradient
    USE dynadv          ! dynamics: vector invariant versus flux form
    USE domvvl          ! variable volume
@@ -68,16 +68,11 @@
       !!                  ***  ROUTINE dyn_nxt  ***
       !!                   
-      !! ** Purpose :   Compute the after horizontal velocity. Apply the boundary 
-      !!             condition on the after velocity, achieved the time stepping 
+      !! ** Purpose :   Finalize after horizontal velocity. Apply the boundary 
+      !!             condition on the after velocity, achieve the time stepping 
       !!             by applying the Asselin filter on now fields and swapping 
       !!             the fields.
       !!
-      !! ** Method  : * After velocity is compute using a leap-frog scheme:
-      !!                       (ua,va) = (ub,vb) + 2 rdt (ua,va)
-      !!             Note that with flux form advection and variable volume layer
-      !!             (lk_vvl=T), the leap-frog is applied on thickness weighted
-      !!             velocity.
-      !!             Note also that in filtered free surface (lk_dynspg_flt=T),
-      !!             the time stepping has already been done in dynspg module
+      !! ** Method  : * Ensure after velocities transport matches time splitting
+      !!             estimate (ln_dynspg_ts=T)
       !!
       !!              * Apply lateral boundary conditions on after velocity 
@@ -101,8 +96,5 @@
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       INTEGER  ::   iku, ikv     ! local integers
-#if ! defined key_dynspg_flt
-      REAL(wp) ::   z2dt         ! temporary scalar
-#endif
-      REAL(wp) ::   zue3a, zue3n, zue3b, zuf, zec      ! local scalars
+      REAL(wp) ::   zue3a, zue3n, zue3b, zuf           ! local scalars
       REAL(wp) ::   zve3a, zve3n, zve3b, zvf, z1_2dt   !   -      -
       REAL(wp), POINTER, DIMENSION(:,:)   ::  zue, zve
@@ -112,6 +104,7 @@
       IF( nn_timing == 1 )   CALL timing_start('dyn_nxt')
       !
-      CALL wrk_alloc( jpi,jpj,jpk,  ze3u_f, ze3v_f, zua, zva )
-      IF( lk_dynspg_ts )   CALL wrk_alloc( jpi,jpj, zue, zve )
+      IF( ln_dynspg_ts )   CALL wrk_alloc( jpi,jpj, zue, zve )
+      IF( lk_vvl.AND.(.NOT.ln_dynadv_vec ) ) CALL wrk_alloc( jpi,jpj,jpk, ze3u_f, ze3v_f )
+      IF( l_trddyn     )   CALL wrk_alloc( jpi,jpj,jpk, zua, zva )
       !
       IF( kt == nit000 ) THEN
@@ -121,86 +114,48 @@
       ENDIF
 
-#if defined key_dynspg_flt
-      !
-      ! Next velocity :   Leap-frog time stepping already done in dynspg_flt.F routine
-      ! -------------
-
-      ! Update after velocity on domain lateral boundaries      (only local domain required)
-      ! --------------------------------------------------
-      CALL lbc_lnk( ua, 'U', -1. )         ! local domain boundaries
-      CALL lbc_lnk( va, 'V', -1. ) 
-      !
-#else
-
-# if defined key_dynspg_exp
-      ! Next velocity :   Leap-frog time stepping
-      ! -------------
-      z2dt = 2. * rdt                                 ! Euler or leap-frog time step 
-      IF( neuler == 0 .AND. kt == nit000 )  z2dt = rdt
-      !
-      IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN      ! applied on velocity
+      IF ( ln_dynspg_ts ) THEN
+         ! Ensure below that barotropic velocities match time splitting estimate
+         ! Compute actual transport and replace it with ts estimate at "after" time step
+         zue(:,:) = fse3u_a(:,:,1) * ua(:,:,1) * umask(:,:,1)
+         zve(:,:) = fse3v_a(:,:,1) * va(:,:,1) * vmask(:,:,1)
+         DO jk = 2, jpkm1
+            zue(:,:) = zue(:,:) + fse3u_a(:,:,jk) * ua(:,:,jk) * umask(:,:,jk)
+            zve(:,:) = zve(:,:) + fse3v_a(:,:,jk) * va(:,:,jk) * vmask(:,:,jk)
+         END DO
          DO jk = 1, jpkm1
-            ua(:,:,jk) = ( ub(:,:,jk) + z2dt * ua(:,:,jk) ) * umask(:,:,jk)
-            va(:,:,jk) = ( vb(:,:,jk) + z2dt * va(:,:,jk) ) * vmask(:,:,jk)
-         END DO
-      ELSE                                            ! applied on thickness weighted velocity
-         DO jk = 1, jpkm1
-            ua(:,:,jk) = (          ub(:,:,jk) * fse3u_b(:,:,jk)      &
-               &           + z2dt * ua(:,:,jk) * fse3u_n(:,:,jk)  )   &
-               &         / fse3u_a(:,:,jk) * umask(:,:,jk)
-            va(:,:,jk) = (          vb(:,:,jk) * fse3v_b(:,:,jk)      &
-               &           + z2dt * va(:,:,jk) * fse3v_n(:,:,jk)  )   &
-               &         / fse3v_a(:,:,jk) * vmask(:,:,jk)
-         END DO
-      ENDIF
-# endif
-
-# if defined key_dynspg_ts
-!!gm IF ( lk_dynspg_ts ) THEN ....
-      ! Ensure below that barotropic velocities match time splitting estimate
-      ! Compute actual transport and replace it with ts estimate at "after" time step
-      zue(:,:) = fse3u_a(:,:,1) * ua(:,:,1) * umask(:,:,1)
-      zve(:,:) = fse3v_a(:,:,1) * va(:,:,1) * vmask(:,:,1)
-      DO jk = 2, jpkm1
-         zue(:,:) = zue(:,:) + fse3u_a(:,:,jk) * ua(:,:,jk) * umask(:,:,jk)
-         zve(:,:) = zve(:,:) + fse3v_a(:,:,jk) * va(:,:,jk) * vmask(:,:,jk)
-      END DO
-      DO jk = 1, jpkm1
-         ua(:,:,jk) = ( ua(:,:,jk) - zue(:,:) * hur_a(:,:) + ua_b(:,:) ) * umask(:,:,jk)
-         va(:,:,jk) = ( va(:,:,jk) - zve(:,:) * hvr_a(:,:) + va_b(:,:) ) * vmask(:,:,jk)
-      END DO
-
-      IF (lk_dynspg_ts.AND.(.NOT.ln_bt_fw)) THEN
-         ! Remove advective velocity from "now velocities" 
-         ! prior to asselin filtering     
-         ! In the forward case, this is done below after asselin filtering   
-         ! so that asselin contribution is removed at the same time 
-         DO jk = 1, jpkm1
-            un(:,:,jk) = ( un(:,:,jk) - un_adv(:,:) + un_b(:,:) )*umask(:,:,jk)
-            vn(:,:,jk) = ( vn(:,:,jk) - vn_adv(:,:) + vn_b(:,:) )*vmask(:,:,jk)
-         END DO  
-      ENDIF
-!!gm ENDIF
-# endif
+            ua(:,:,jk) = ( ua(:,:,jk) - zue(:,:) * hur_a(:,:) + ua_b(:,:) ) * umask(:,:,jk)
+            va(:,:,jk) = ( va(:,:,jk) - zve(:,:) * hvr_a(:,:) + va_b(:,:) ) * vmask(:,:,jk)
+         END DO
+
+         IF ( .NOT.ln_bt_fw ) THEN
+            ! Remove advective velocity from "now velocities" 
+            ! prior to asselin filtering     
+            ! In the forward case, this is done below after asselin filtering   
+            ! so that asselin contribution is removed at the same time 
+            DO jk = 1, jpkm1
+               un(:,:,jk) = ( un(:,:,jk) - un_adv(:,:) + un_b(:,:) )*umask(:,:,jk)
+               vn(:,:,jk) = ( vn(:,:,jk) - vn_adv(:,:) + vn_b(:,:) )*vmask(:,:,jk)
+            END DO  
+         ENDIF
+      ENDIF
 
       ! Update after velocity on domain lateral boundaries
       ! --------------------------------------------------      
-      CALL lbc_lnk( ua, 'U', -1. )     !* local domain boundaries
-      CALL lbc_lnk( va, 'V', -1. ) 
-      !
-# if defined key_bdy
-      !                                !* BDY open boundaries
-      IF( lk_bdy .AND. lk_dynspg_exp ) CALL bdy_dyn( kt )
-      IF( lk_bdy .AND. lk_dynspg_ts  ) CALL bdy_dyn( kt, dyn3d_only=.true. )
-
-!!$   Do we need a call to bdy_vol here??
-      !
-# endif
-      !
 # if defined key_agrif
       CALL Agrif_dyn( kt )             !* AGRIF zoom boundaries
 # endif
-#endif
-
+      !
+      CALL lbc_lnk( ua, 'U', -1. )     !* local domain boundaries
+      CALL lbc_lnk( va, 'V', -1. ) 
+      !
+# if defined key_bdy
+      !                                !* BDY open boundaries
+      IF( lk_bdy .AND. ln_dynspg_exp ) CALL bdy_dyn( kt )
+      IF( lk_bdy .AND. ln_dynspg_ts  ) CALL bdy_dyn( kt, dyn3d_only=.true. )
+
+!!$   Do we need a call to bdy_vol here??
+      !
+# endif
+      !
       IF( l_trddyn ) THEN             ! prepare the atf trend computation + some diagnostics
          z1_2dt = 1._wp / (2. * rdt)        ! Euler or leap-frog time step 
@@ -259,7 +214,7 @@
             ! (used as a now filtered scale factor until the swap)
             ! ----------------------------------------------------
-            IF (lk_dynspg_ts.AND.ln_bt_fw) THEN
+            IF (ln_dynspg_ts.AND.ln_bt_fw) THEN
                ! No asselin filtering on thicknesses if forward time splitting
-                  fse3t_b(:,:,:) = fse3t_n(:,:,:)
+               fse3t_b(:,:,:) = fse3t_n(:,:,:)
             ELSE
                fse3t_b(:,:,:) = fse3t_n(:,:,:) + atfp * ( fse3t_b(:,:,:) - 2._wp * fse3t_n(:,:,:) + fse3t_a(:,:,:) )
@@ -336,5 +291,5 @@
          ENDIF
          !
-         IF (lk_dynspg_ts.AND.ln_bt_fw) THEN
+         IF (ln_dynspg_ts.AND.ln_bt_fw) THEN
             ! Revert "before" velocities to time split estimate
             ! Doing it here also means that asselin filter contribution is removed  
@@ -400,7 +355,8 @@
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=un, clinfo1=' nxt  - Un: ', mask1=umask,   &
          &                       tab3d_2=vn, clinfo2=' Vn: '       , mask2=vmask )
-      ! 
-      CALL wrk_dealloc( jpi,jpj,jpk,  ze3u_f, ze3v_f, zua, zva )
-      IF( lk_dynspg_ts )   CALL wrk_dealloc( jpi,jpj, zue, zve )
+      !
+      IF( ln_dynspg_ts )   CALL wrk_dealloc( jpi,jpj, zue, zve )
+      IF( lk_vvl.AND.(.NOT.ln_dynadv_vec ) ) CALL wrk_dealloc( jpi,jpj,jpk, ze3u_f, ze3v_f )
+      IF( l_trddyn     )   CALL wrk_dealloc( jpi,jpj,jpk, zua, zva )
       !
       IF( nn_timing == 1 )  CALL timing_stop('dyn_nxt')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg.F90	(revision 6041)
@@ -6,9 +6,10 @@
    !! History :  1.0  ! 2005-12  (C. Talandier, G. Madec, V. Garnier)  Original code
    !!            3.2  ! 2009-07  (R. Benshila)  Suppression of rigid-lid option
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   dyn_spg     : update the dynamics trend with the lateral diffusion
-   !!   dyn_spg_ctl : initialization, namelist read, and parameters control
+   !!            3.7  ! 2015-11  (J. Chanut) Suppression of filtered free surface 
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   dyn_spg     : update the dynamics trend with surface pressure gradient 
+   !!   dyn_spg_init: initialization, namelist read, and parameters control
    !!----------------------------------------------------------------------
    USE oce            ! ocean dynamics and tracers variables
@@ -18,10 +19,6 @@
    USE sbc_oce        ! surface boundary condition: ocean
    USE sbcapr         ! surface boundary condition: atmospheric pressure
-   USE dynspg_oce     ! surface pressure gradient variables
    USE dynspg_exp     ! surface pressure gradient     (dyn_spg_exp routine)
    USE dynspg_ts      ! surface pressure gradient     (dyn_spg_ts  routine)
-   USE dynspg_flt     ! surface pressure gradient     (dyn_spg_flt routine)
-   USE dynadv         ! dynamics: vector invariant versus flux form
-   USE dynhpg, ONLY: ln_dynhpg_imp
    USE sbctide
    USE updtide
@@ -32,5 +29,4 @@
    USE in_out_manager ! I/O manager
    USE lib_mpp        ! MPP library
-   USE solver         ! solver initialization
    USE wrk_nemo       ! Memory Allocation
    USE timing         ! Timing
@@ -43,5 +39,5 @@
    PUBLIC   dyn_spg_init   ! routine called by opa module
 
-   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from lk_dynspg_... 
+   INTEGER ::   nspg = 0   ! type of surface pressure gradient scheme defined from ln_dynspg_... 
 
    !! * Substitutions
@@ -55,5 +51,5 @@
 CONTAINS
 
-   SUBROUTINE dyn_spg( kt, kindic )
+   SUBROUTINE dyn_spg( kt )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE dyn_spg  ***
@@ -66,7 +62,6 @@
       !!gm            the after velocity, in the 2 other (ua,va) are still the trends
       !!
-      !! ** Method  :   Three schemes:
+      !! ** Method  :   Two schemes:
       !!              - explicit computation      : the spg is evaluated at now
-      !!              - filtered computation      : the Roulet & madec (2000) technique is used
       !!              - split-explicit computation: a time splitting technique is used
       !!
@@ -77,11 +72,7 @@
       !!             Note that as all external forcing a time averaging over a two rdt
       !!             period is used to prevent the divergence of odd and even time step.
-      !!
-      !! N.B. : When key_esopa is used all the scheme are tested, regardless 
-      !!        of the physical meaning of the results. 
       !!----------------------------------------------------------------------
       !
       INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER, INTENT(  out) ::   kindic   ! solver flag
       !
       INTEGER  ::   ji, jj, jk                             ! dummy loop indices
@@ -106,5 +97,5 @@
 
       IF(      ln_apr_dyn                                                &   ! atmos. pressure
-         .OR.  ( .NOT.lk_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
+         .OR.  ( .NOT.ln_dynspg_ts .AND. (ln_tide_pot .AND. lk_tide) )   &   ! tide potential (no time slitting)
          .OR.  nn_ice_embd == 2  ) THEN                                      ! embedded sea-ice
          !
@@ -116,12 +107,12 @@
          END DO         
          !
-         IF( ln_apr_dyn .AND. (.NOT. lk_dynspg_ts) ) THEN                    !==  Atmospheric pressure gradient (added later in time-split case) ==!
+         IF( ln_apr_dyn .AND. (.NOT. ln_dynspg_ts) ) THEN                    !==  Atmospheric pressure gradient (added later in time-split case) ==!
             zg_2 = grav * 0.5
             DO jj = 2, jpjm1                          ! gradient of Patm using inverse barometer ssh
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   spgu(ji,jj) = spgu(ji,jj) + zg_2 * (  ssh_ib (ji+1,jj) - ssh_ib (ji,jj)    &
-                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) /e1u(ji,jj)
+                     &                      + ssh_ibb(ji+1,jj) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
                   spgv(ji,jj) = spgv(ji,jj) + zg_2 * (  ssh_ib (ji,jj+1) - ssh_ib (ji,jj)    &
-                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) /e2v(ji,jj)
+                     &                      + ssh_ibb(ji,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
                END DO
             END DO
@@ -129,5 +120,5 @@
          !
          !                                    !==  tide potential forcing term  ==!
-         IF( .NOT.lk_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
+         IF( .NOT.ln_dynspg_ts .AND. ( ln_tide_pot .AND. lk_tide )  ) THEN   ! N.B. added directly at sub-time-step in ts-case
             !
             CALL upd_tide( kt )                      ! update tide potential
@@ -135,6 +126,6 @@
             DO jj = 2, jpjm1                         ! add tide potential forcing
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) / e1u(ji,jj)
-                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) / e2v(ji,jj)
+                  spgu(ji,jj) = spgu(ji,jj) + grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
                END DO 
             END DO
@@ -149,6 +140,6 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) / e1u(ji,jj)
-                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) / e2v(ji,jj)
+                  spgu(ji,jj) = spgu(ji,jj) + ( zpice(ji+1,jj) - zpice(ji,jj) ) * r1_e1u(ji,jj)
+                  spgv(ji,jj) = spgv(ji,jj) + ( zpice(ji,jj+1) - zpice(ji,jj) ) * r1_e2v(ji,jj)
                END DO
             END DO
@@ -174,29 +165,10 @@
       CASE (  0 )   ;   CALL dyn_spg_exp( kt )              ! explicit
       CASE (  1 )   ;   CALL dyn_spg_ts ( kt )              ! time-splitting
-      CASE (  2 )   ;   CALL dyn_spg_flt( kt, kindic )      ! filtered
       !                                                    
-      CASE ( -1 )                                ! esopa: test all possibility with control print
-                        CALL dyn_spg_exp( kt )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg0 - Ua: ', mask1=umask, &
-         &                            tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-                        CALL dyn_spg_ts ( kt )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg1 - Ua: ', mask1=umask, &
-         &                           tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-                        CALL dyn_spg_flt( kt, kindic )
-                        CALL prt_ctl( tab3d_1=ua, clinfo1=' spg2 - Ua: ', mask1=umask, &
-         &                            tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       END SELECT
       !                    
       IF( l_trddyn )   THEN                      ! save the surface pressure gradient trends for further diagnostics
-         SELECT CASE ( nspg )
-         CASE ( 0, 1 )
-            ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
-            ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-         CASE( 2 )
-            z2dt = 2. * rdt
-            IF( neuler == 0 .AND. kt == nit000 )   z2dt = rdt
-            ztrdu(:,:,:) = ( ua(:,:,:) - ub(:,:,:) ) / z2dt - ztrdu(:,:,:)
-            ztrdv(:,:,:) = ( va(:,:,:) - vb(:,:,:) ) / z2dt - ztrdv(:,:,:)
-         END SELECT
+         ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
+         ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
          CALL trd_dyn( ztrdu, ztrdv, jpdyn_spg, kt )
          !
@@ -216,26 +188,36 @@
       !!                  ***  ROUTINE dyn_spg_init  ***
       !!                
-      !! ** Purpose :   Control the consistency between cpp options for 
+      !! ** Purpose :   Control the consistency between namelist options for 
       !!              surface pressure gradient schemes
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio
+      INTEGER ::   ioptio, ios
+      !
+      NAMELIST/namdyn_spg/ ln_dynspg_exp, ln_dynspg_ts, &
+      &                    ln_bt_fw, ln_bt_av, ln_bt_auto, &
+      &                    nn_baro, rn_bt_cmax, nn_bt_flt
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('dyn_spg_init')
       !
-      IF(lwp) THEN             ! Control print
+      REWIND( numnam_ref )              ! Namelist namdyn_spg in reference namelist : Free surface
+      READ  ( numnam_ref, namdyn_spg, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_spg in reference namelist', lwp )
+
+      REWIND( numnam_cfg )              ! Namelist namdyn_spg in configuration namelist : Free surface
+      READ  ( numnam_cfg, namdyn_spg, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namdyn_spg in configuration namelist', lwp )
+      IF(lwm) WRITE ( numond, namdyn_spg )
+      !
+      IF(lwp) THEN             ! Namelist print
          WRITE(numout,*)
          WRITE(numout,*) 'dyn_spg_init : choice of the surface pressure gradient scheme'
          WRITE(numout,*) '~~~~~~~~~~~'
-         WRITE(numout,*) '     Explicit free surface                  lk_dynspg_exp = ', lk_dynspg_exp
-         WRITE(numout,*) '     Free surface with time splitting       lk_dynspg_ts  = ', lk_dynspg_ts
-         WRITE(numout,*) '     Filtered free surface cst volume       lk_dynspg_flt = ', lk_dynspg_flt
-      ENDIF
-
-      IF( lk_dynspg_ts ) CALL dyn_spg_ts_init( nit000 )
-      ! (do it now, to set nn_baro, used to allocate some arrays later on)
-      !                        ! allocate dyn_spg arrays
-      IF( lk_dynspg_ts ) THEN
-         IF( dynspg_oce_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_oce arrays')
+         WRITE(numout,*) '     Explicit free surface                  ln_dynspg_exp = ', ln_dynspg_exp
+         WRITE(numout,*) '     Free surface with time splitting       ln_dynspg_ts  = ', ln_dynspg_ts
+      ENDIF
+
+      IF( ln_dynspg_ts ) THEN
+         CALL dyn_spg_ts_init( nit000  ) ! do it first, to set nn_baro, used to allocate some arrays later on
+         !                               ! allocate dyn_spg arrays
          IF( dyn_spg_ts_alloc() /= 0 )   CALL ctl_stop('STOP', 'dyn_spg_init: failed to allocate dynspg_ts  arrays')
          IF ((neuler/=0).AND.(ln_bt_fw)) CALL ts_rst( nit000, 'READ' )
@@ -244,40 +226,19 @@
       !                        ! Control of surface pressure gradient scheme options
       ioptio = 0
-      IF(lk_dynspg_exp)   ioptio = ioptio + 1
-      IF(lk_dynspg_ts )   ioptio = ioptio + 1
-      IF(lk_dynspg_flt)   ioptio = ioptio + 1
-      !
-      IF( ( ioptio > 1 .AND. .NOT. lk_esopa ) .OR. ( ioptio == 0 .AND. .NOT. lk_c1d ) )   &
-           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme with a key cpp' )
-      IF( ( lk_dynspg_ts .OR. lk_dynspg_exp ) .AND. ln_isfcav )   &
-           &   CALL ctl_stop( ' dynspg_ts and dynspg_exp not tested with ice shelf cavity ' )
-      !
-      IF( lk_esopa     )   nspg = -1
-      IF( lk_dynspg_exp)   nspg =  0
-      IF( lk_dynspg_ts )   nspg =  1
-      IF( lk_dynspg_flt)   nspg =  2
-      !
-      IF( lk_esopa     )   nspg = -1
+      IF(ln_dynspg_exp)   ioptio = ioptio + 1
+      IF(ln_dynspg_ts )   ioptio = ioptio + 1
+      !
+      IF(  ioptio > 1  .OR. ( ioptio == 0 .AND. .NOT. lk_c1d ) )   &
+           &   CALL ctl_stop( ' Choose only one surface pressure gradient scheme' )
+      IF( ln_dynspg_ts .AND. ln_isfcav )   &
+           &   CALL ctl_stop( ' dynspg_ts not tested with ice shelf cavity ' )
+      !
+      IF( ln_dynspg_exp)   nspg =  0
+      IF( ln_dynspg_ts )   nspg =  1
       !
       IF(lwp) THEN
          WRITE(numout,*)
-         IF( nspg == -1 )   WRITE(numout,*) '     ESOPA test All scheme used'
          IF( nspg ==  0 )   WRITE(numout,*) '     explicit free surface'
          IF( nspg ==  1 )   WRITE(numout,*) '     free surface with time splitting scheme'
-         IF( nspg ==  2 )   WRITE(numout,*) '     filtered free surface'
-      ENDIF
-
-#if defined key_dynspg_flt || defined key_esopa
-      CALL solver_init( nit000 )   ! Elliptic solver initialisation
-#endif
-
-      !                        ! Control of timestep choice
-      IF( lk_dynspg_ts .OR. lk_dynspg_exp ) THEN
-         IF( nn_cla == 1 )   CALL ctl_stop( 'Crossland advection not implemented for this free surface formulation' )
-      ENDIF
-
-      !			       ! Control of hydrostatic pressure choice
-      IF( lk_dynspg_ts .AND. ln_dynhpg_imp ) THEN
-         CALL ctl_stop( 'Semi-implicit hpg not compatible with time splitting' )
       ENDIF
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_exp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_exp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_exp.F90	(revision 6041)
@@ -7,7 +7,6 @@
    !!            3.2  !  2009-06  (G. Madec, M. Leclair, R. Benshila) introduce sshwzv module
    !!----------------------------------------------------------------------
-#if defined key_dynspg_exp   ||   defined key_esopa
    !!----------------------------------------------------------------------
-   !!   'key_dynspg_exp'                              explicit free surface
+   !!                     explicit free surface
    !!----------------------------------------------------------------------
    !!   dyn_spg_exp  : update the momentum trend with the surface 
@@ -31,5 +30,5 @@
    PRIVATE
 
-   PUBLIC   dyn_spg_exp   ! routine called by step.F90
+   PUBLIC   dyn_spg_exp   ! routine called by dyn_spg 
 
    !! * Substitutions
@@ -101,14 +100,4 @@
    END SUBROUTINE dyn_spg_exp
 
-#else
-   !!----------------------------------------------------------------------
-   !!   Default case :   Empty module   No standart explicit free surface 
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE dyn_spg_exp( kt )       ! Empty routine
-      WRITE(*,*) 'dyn_spg_exp: You should not have seen this print! error?', kt
-   END SUBROUTINE dyn_spg_exp
-#endif
-
    !!======================================================================
 END MODULE dynspg_exp
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_flt.F90	(revision 6040)
+++ 	(revision )
@@ -1,426 +1,0 @@
-MODULE dynspg_flt
-   !!======================================================================
-   !!                   ***  MODULE  dynspg_flt  ***
-   !! Ocean dynamics:  surface pressure gradient trend
-   !!======================================================================
-   !! History    OPA  !  1998-05  (G. Roullet)  free surface
-   !!                 !  1998-10  (G. Madec, M. Imbard)  release 8.2
-   !!   NEMO     O.1  !  2002-08  (G. Madec)  F90: Free form and module
-   !!             -   !  2002-11  (C. Talandier, A-M Treguier) Open boundaries
-   !!            1.0  !  2004-08  (C. Talandier) New trends organization
-   !!             -   !  2005-11  (V. Garnier) Surface pressure gradient organization
-   !!            2.0  !  2006-07  (S. Masson)  distributed restart using iom
-   !!             -   !  2006-08  (J.Chanut, A.Sellar) Calls to BDY routines. 
-   !!            3.2  !  2009-03  (G. Madec, M. Leclair, R. Benshila) introduce sshwzv module
-   !!            3.7  !  2014-04  (F. Roquet, G. Madec)  add some trends diag
-   !!----------------------------------------------------------------------
-#if defined key_dynspg_flt   ||   defined key_esopa  
-   !!----------------------------------------------------------------------
-   !!   'key_dynspg_flt'                              filtered free surface
-   !!----------------------------------------------------------------------
-   !!   dyn_spg_flt  : update the momentum trend with the surface pressure gradient in the filtered free surface case 
-   !!   flt_rst      : read/write the time-splitting restart fields in the ocean restart file
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers 
-   USE dom_oce         ! ocean space and time domain 
-   USE zdf_oce         ! ocean vertical physics
-   USE sbc_oce         ! surface boundary condition: ocean
-   USE bdy_oce         ! Lateral open boundary condition
-   USE sol_oce         ! ocean elliptic solver
-   USE phycst          ! physical constants
-   USE domvvl          ! variable volume
-   USE dynadv          ! advection 
-   USE solmat          ! matrix construction for elliptic solvers
-   USE solpcg          ! preconditionned conjugate gradient solver
-   USE solsor          ! Successive Over-relaxation solver
-   USE bdydyn          ! ocean open boundary condition on dynamics
-   USE bdyvol          ! ocean open boundary condition (bdy_vol routine)
-   USE cla             ! cross land advection
-   USE trd_oce         ! trends: ocean variables
-   USE trddyn          ! trend manager: dynamics
-   !
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! distributed memory computing library
-   USE wrk_nemo        ! Memory Allocation
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl          ! Print control
-   USE iom
-   USE lib_fortran
-   USE timing          ! Timing
-#if defined key_agrif
-   USE agrif_opa_interp
-#endif
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   dyn_spg_flt  ! routine called by step.F90
-   PUBLIC   flt_rst      ! routine called by istate.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE dyn_spg_flt( kt, kindic )
-      !!----------------------------------------------------------------------
-      !!                  ***  routine dyn_spg_flt  ***
-      !!
-      !! ** Purpose :   Compute the now trend due to the surface pressure 
-      !!      gradient in case of filtered free surface formulation  and add
-      !!      it to the general trend of momentum equation.
-      !!
-      !! ** Method  :   Filtered free surface formulation. The surface
-      !!      pressure gradient is given by:
-      !!         spgu = 1/rau0 d/dx(ps) =  1/e1u di( sshn + btda )
-      !!         spgv = 1/rau0 d/dy(ps) =  1/e2v dj( sshn + btda )
-      !!      where sshn is the free surface elevation and btda is the after
-      !!      time derivative of the free surface elevation
-      !!       -1- evaluate the surface presure trend (including the addi-
-      !!      tional force) in three steps:
-      !!        a- compute the right hand side of the elliptic equation:
-      !!            gcb = 1/(e1t e2t) [ di(e2u spgu) + dj(e1v spgv) ]
-      !!         where (spgu,spgv) are given by:
-      !!            spgu = vertical sum[ e3u (ub+ 2 rdt ua ) ]
-      !!                 - grav 2 rdt hu /e1u di[sshn + (emp-rnf)]
-      !!            spgv = vertical sum[ e3v (vb+ 2 rdt va) ]
-      !!                 - grav 2 rdt hv /e2v dj[sshn + (emp-rnf)]
-      !!         and define the first guess from previous computation :
-      !!            zbtd = btda
-      !!            btda = 2 zbtd - btdb
-      !!            btdb = zbtd
-      !!        b- compute the relative accuracy to be reached by the
-      !!         iterative solver
-      !!        c- apply the solver by a call to sol... routine
-      !!       -2- compute and add the free surface pressure gradient inclu-
-      !!      ding the additional force used to stabilize the equation.
-      !!
-      !! ** Action : - Update (ua,va) with the surf. pressure gradient trend
-      !!
-      !! References : Roullet and Madec, JGR, 2000.
-      !!---------------------------------------------------------------------
-      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER, INTENT(  out) ::   kindic   ! solver convergence flag (<0 if not converge)
-      !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   z2dt, z2dtg, zgcb, zbtd, ztdgu, ztdgv   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrdu, ztrdv
-      REAL(wp), POINTER, DIMENSION(:,:)   ::  zpw
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('dyn_spg_flt')
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dyn_spg_flt : surface pressure gradient trend'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   (free surface constant volume case)'
-       
-         ! set to zero free surface specific arrays
-         spgu(:,:) = 0._wp                     ! surface pressure gradient (i-direction)
-         spgv(:,:) = 0._wp                     ! surface pressure gradient (j-direction)
-
-         ! read filtered free surface arrays in restart file
-         ! when using agrif, sshn, gcx have to be read in istate
-         IF(.NOT. lk_agrif)   CALL flt_rst( nit000, 'READ' )      ! read or initialize the following fields:
-         !                                                        ! gcx, gcxb
-      ENDIF
-
-      ! Local constant initialization
-      z2dt = 2. * rdt                                             ! time step: leap-frog
-      IF( neuler == 0 .AND. kt == nit000   )   z2dt = rdt         ! time step: Euler if restart from rest
-      IF( neuler == 0 .AND. kt == nit000+1 )   CALL sol_mat( kt )
-      z2dtg  = grav * z2dt
-
-      ! Evaluate the masked next velocity (effect of the additional force not included)
-      ! ---------------------------------  
-      IF( lk_vvl ) THEN          ! variable volume  (surface pressure gradient already included in dyn_hpg)
-         !
-         IF( ln_dynadv_vec ) THEN      ! vector form : applied on velocity
-            DO jk = 1, jpkm1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
-                     ua(ji,jj,jk) = (  ub(ji,jj,jk) + z2dt * ua(ji,jj,jk)  ) * umask(ji,jj,jk)
-                     va(ji,jj,jk) = (  vb(ji,jj,jk) + z2dt * va(ji,jj,jk)  ) * vmask(ji,jj,jk)
-                  END DO
-               END DO
-            END DO
-            !
-         ELSE                          ! flux form : applied on thickness weighted velocity
-            DO jk = 1, jpkm1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
-                     ua(ji,jj,jk) = (        ub(ji,jj,jk) * fse3u_b(ji,jj,jk)      &
-                        &           + z2dt * ua(ji,jj,jk) * fse3u_n(ji,jj,jk)  )   &
-                        &         / fse3u_a(ji,jj,jk) * umask(ji,jj,jk)
-                     va(ji,jj,jk) = (        vb(ji,jj,jk) * fse3v_b(ji,jj,jk)      &
-                        &           + z2dt * va(ji,jj,jk) * fse3v_n(ji,jj,jk)  )   &
-                        &         / fse3v_a(ji,jj,jk) * vmask(ji,jj,jk)
-                 END DO
-               END DO
-            END DO
-            !
-         ENDIF
-         !
-      ELSE                       ! fixed volume  (add the surface pressure gradient + unweighted time stepping)
-         !
-         DO jj = 2, jpjm1              ! Surface pressure gradient (now)
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               spgu(ji,jj) = - grav * ( sshn(ji+1,jj) - sshn(ji,jj) ) / e1u(ji,jj)
-               spgv(ji,jj) = - grav * ( sshn(ji,jj+1) - sshn(ji,jj) ) / e2v(ji,jj)
-            END DO 
-         END DO 
-         DO jk = 1, jpkm1              ! unweighted time stepping 
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ua(ji,jj,jk) = (  ub(ji,jj,jk) + z2dt * ( ua(ji,jj,jk) + spgu(ji,jj) )  ) * umask(ji,jj,jk)
-                  va(ji,jj,jk) = (  vb(ji,jj,jk) + z2dt * ( va(ji,jj,jk) + spgv(ji,jj) )  ) * vmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         !
-         IF( l_trddyn )   THEN                      ! temporary save of spg trends
-            CALL wrk_alloc( jpi, jpj, jpk, ztrdu, ztrdv )
-            DO jk = 1, jpkm1              ! unweighted time stepping 
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
-                     ztrdu(ji,jj,jk) = spgu(ji,jj) * umask(ji,jj,jk)
-                     ztrdv(ji,jj,jk) = spgv(ji,jj) * vmask(ji,jj,jk)
-                  END DO
-               END DO
-            END DO
-            CALL trd_dyn( ztrdu, ztrdv, jpdyn_spgexp, kt )
-         ENDIF
-         !
-      ENDIF
-
-#if defined key_bdy
-      IF( lk_bdy ) CALL bdy_dyn( kt )   ! Update velocities on each open boundary
-      IF( lk_bdy ) CALL bdy_vol( kt )   ! Correction of the barotropic component velocity to control the volume of the system
-#endif
-#if defined key_agrif
-      CALL Agrif_dyn( kt )    ! Update velocities on each coarse/fine interfaces 
-#endif
-      IF( nn_cla == 1 .AND. cp_cfg == 'orca' .AND. jp_cfg == 2 )   CALL cla_dynspg( kt )      ! Cross Land Advection (update (ua,va))
-
-      ! compute the next vertically averaged velocity (effect of the additional force not included)
-      ! ---------------------------------------------
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            spgu(ji,jj) = fse3u_a(ji,jj,1) * ua(ji,jj,1)
-            spgv(ji,jj) = fse3v_a(ji,jj,1) * va(ji,jj,1)
-         END DO
-      END DO
-      DO jk = 2, jpkm1                     ! vertical sum
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               spgu(ji,jj) = spgu(ji,jj) + fse3u_a(ji,jj,jk) * ua(ji,jj,jk)
-               spgv(ji,jj) = spgv(ji,jj) + fse3v_a(ji,jj,jk) * va(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-
-      DO jj = 2, jpjm1                     ! transport: multiplied by the horizontal scale factor
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            spgu(ji,jj) = spgu(ji,jj) * e2u(ji,jj)
-            spgv(ji,jj) = spgv(ji,jj) * e1v(ji,jj)
-         END DO
-      END DO
-      CALL lbc_lnk( spgu, 'U', -1. )       ! lateral boundary conditions 
-      CALL lbc_lnk( spgv, 'V', -1. )
-
-      IF( lk_vvl ) CALL sol_mat( kt )      ! build the matrix at kt (vvl case only)
-
-      ! Right hand side of the elliptic equation and first guess
-      ! --------------------------------------------------------
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            ! Divergence of the after vertically averaged velocity
-            zgcb =  spgu(ji,jj) - spgu(ji-1,jj)   &
-                  + spgv(ji,jj) - spgv(ji,jj-1)
-            gcb(ji,jj) = gcdprc(ji,jj) * zgcb
-            ! First guess of the after barotropic transport divergence
-            zbtd = gcx(ji,jj)
-            gcx (ji,jj) = 2. * zbtd   - gcxb(ji,jj)
-            gcxb(ji,jj) =      zbtd
-         END DO
-      END DO
-      ! applied the lateral boundary conditions
-      IF( nn_solv == 2 .AND. MAX( jpr2di, jpr2dj ) > 0 )   CALL lbc_lnk_e( gcb, c_solver_pt, 1., jpr2di, jpr2dj )   
-
-#if defined key_agrif
-      IF( .NOT. AGRIF_ROOT() ) THEN
-         ! add contribution of gradient of after barotropic transport divergence 
-         IF( nbondi == -1 .OR. nbondi == 2 )   gcb(3     ,:) =   &
-            &    gcb(3     ,:) - z2dtg * z2dt * laplacu(2     ,:) * gcdprc(3     ,:) * hu(2     ,:) * e2u(2     ,:)
-         IF( nbondi ==  1 .OR. nbondi == 2 )   gcb(nlci-2,:) =   &
-            &    gcb(nlci-2,:) + z2dtg * z2dt * laplacu(nlci-2,:) * gcdprc(nlci-2,:) * hu(nlci-2,:) * e2u(nlci-2,:)
-         IF( nbondj == -1 .OR. nbondj == 2 )   gcb(:     ,3) =   &
-            &    gcb(:,3     ) - z2dtg * z2dt * laplacv(:,2     ) * gcdprc(:,3     ) * hv(:,2     ) * e1v(:,2     )
-         IF( nbondj ==  1 .OR. nbondj == 2 )   gcb(:,nlcj-2) =   &
-            &    gcb(:,nlcj-2) + z2dtg * z2dt * laplacv(:,nlcj-2) * gcdprc(:,nlcj-2) * hv(:,nlcj-2) * e1v(:,nlcj-2)
-      ENDIF
-#endif
-
-
-      ! Relative precision (computation on one processor)
-      ! ------------------
-      rnorme =0.e0
-      rnorme = GLOB_SUM( gcb(1:jpi,1:jpj) * gcdmat(1:jpi,1:jpj) * gcb(1:jpi,1:jpj) * bmask(:,:) )
-
-      epsr = eps * eps * rnorme
-      ncut = 0
-      ! if rnorme is 0, the solution is 0, the solver is not called
-      IF( rnorme == 0._wp ) THEN
-         gcx(:,:) = 0._wp
-         res   = 0._wp
-         niter = 0
-         ncut  = 999
-      ENDIF
-
-      ! Evaluate the next transport divergence
-      ! --------------------------------------
-      !    Iterarive solver for the elliptic equation (except IF sol.=0)
-      !    (output in gcx with boundary conditions applied)
-      kindic = 0
-      IF( ncut == 0 ) THEN
-         IF    ( nn_solv == 1 ) THEN   ;   CALL sol_pcg( kindic )      ! diagonal preconditioned conjuguate gradient
-         ELSEIF( nn_solv == 2 ) THEN   ;   CALL sol_sor( kindic )      ! successive-over-relaxation
-         ENDIF
-      ENDIF
-
-      ! Transport divergence gradient multiplied by z2dt
-      ! --------------------------------------------====
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            ! trend of Transport divergence gradient
-            ztdgu = z2dtg * (gcx(ji+1,jj  ) - gcx(ji,jj) ) / e1u(ji,jj)
-            ztdgv = z2dtg * (gcx(ji  ,jj+1) - gcx(ji,jj) ) / e2v(ji,jj)
-            ! multiplied by z2dt
-#if defined key_bdy
-            IF(lk_bdy) THEN
-            ! caution : grad D = 0 along open boundaries
-               spgu(ji,jj) = z2dt * ztdgu * bdyumask(ji,jj)
-               spgv(ji,jj) = z2dt * ztdgv * bdyvmask(ji,jj)
-            ELSE
-               spgu(ji,jj) = z2dt * ztdgu
-               spgv(ji,jj) = z2dt * ztdgv
-            ENDIF
-#else
-            spgu(ji,jj) = z2dt * ztdgu
-            spgv(ji,jj) = z2dt * ztdgv
-#endif
-         END DO
-      END DO
-
-#if defined key_agrif      
-      IF( .NOT. Agrif_Root() ) THEN
-         ! caution : grad D (fine) = grad D (coarse) at coarse/fine interface
-         IF( nbondi == -1 .OR. nbondi == 2 ) spgu(2     ,:) = z2dtg * z2dt * laplacu(2     ,:) * umask(2     ,:,1)
-         IF( nbondi ==  1 .OR. nbondi == 2 ) spgu(nlci-2,:) = z2dtg * z2dt * laplacu(nlci-2,:) * umask(nlci-2,:,1)
-         IF( nbondj == -1 .OR. nbondj == 2 ) spgv(:,2     ) = z2dtg * z2dt * laplacv(:,2     ) * vmask(:     ,2,1)
-         IF( nbondj ==  1 .OR. nbondj == 2 ) spgv(:,nlcj-2) = z2dtg * z2dt * laplacv(:,nlcj-2) * vmask(:,nlcj-2,1)
-      ENDIF
-#endif      
-
-      IF( l_trddyn )   THEN                     
-         ztrdu(:,:,:) = ua(:,:,:)                 ! save the after velocity before the filtered SPG
-         ztrdv(:,:,:) = va(:,:,:)
-         !
-         CALL wrk_alloc( jpi, jpj, zpw )
-         !
-         zpw(:,:) = - z2dt * gcx(:,:)
-         CALL iom_put( "ssh_flt" , zpw )          ! output equivalent ssh modification due to implicit filter
-         !
-         !                                        ! save surface pressure flux: -pw at z=0
-         zpw(:,:) = - rau0 * grav * sshn(:,:) * wn(:,:,1) * tmask(:,:,1)
-         CALL iom_put( "pw0_exp" , zpw )
-         zpw(:,:) = wn(:,:,1)
-         CALL iom_put( "w0" , zpw )
-         zpw(:,:) =  rau0 * z2dtg * gcx(:,:) * wn(:,:,1) * tmask(:,:,1)
-         CALL iom_put( "pw0_flt" , zpw )
-         !
-         CALL wrk_dealloc( jpi, jpj, zpw ) 
-         !                                   
-      ENDIF
-      
-      ! Add the trends multiplied by z2dt to the after velocity
-      ! -------------------------------------------------------
-      !     ( c a u t i o n : (ua,va) here are the after velocity not the
-      !                       trend, the leap-frog time stepping will not
-      !                       be done in dynnxt.F90 routine)
-      DO jk = 1, jpkm1
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ua(ji,jj,jk) = ( ua(ji,jj,jk) + spgu(ji,jj) ) * umask(ji,jj,jk)
-               va(ji,jj,jk) = ( va(ji,jj,jk) + spgv(ji,jj) ) * vmask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-
-      IF( l_trddyn )   THEN                      ! save the explicit SPG trends for further diagnostics
-         ztrdu(:,:,:) = ( ua(:,:,:) - ztrdu(:,:,:) ) / z2dt
-         ztrdv(:,:,:) = ( va(:,:,:) - ztrdv(:,:,:) ) / z2dt
-         CALL trd_dyn( ztrdu, ztrdv, jpdyn_spgflt, kt )
-         !
-         CALL wrk_dealloc( jpi, jpj, jpk, ztrdu, ztrdv ) 
-      ENDIF
-
-      IF( lrst_oce )   CALL flt_rst( kt, 'WRITE' )      ! write filtered free surface arrays in restart file
-      !
-      IF( nn_timing == 1 )   CALL timing_stop('dyn_spg_flt')
-      !
-   END SUBROUTINE dyn_spg_flt
-
-
-   SUBROUTINE flt_rst( kt, cdrw )
-      !!---------------------------------------------------------------------
-      !!                   ***  ROUTINE ts_rst  ***
-      !!
-      !! ** Purpose : Read or write filtered free surface arrays in restart file
-      !!----------------------------------------------------------------------
-      INTEGER         , INTENT(in) ::   kt     ! ocean time-step
-      CHARACTER(len=*), INTENT(in) ::   cdrw   ! "READ"/"WRITE" flag
-      !!----------------------------------------------------------------------
-      !
-      IF( TRIM(cdrw) == 'READ' ) THEN
-         IF( iom_varid( numror, 'gcx', ldstop = .FALSE. ) > 0 ) THEN
-! Caution : extra-hallow
-! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
-            CALL iom_get( numror, jpdom_autoglo, 'gcx' , gcx (1:jpi,1:jpj) )
-            CALL iom_get( numror, jpdom_autoglo, 'gcxb', gcxb(1:jpi,1:jpj) )
-            IF( neuler == 0 )   gcxb(:,:) = gcx (:,:)
-         ELSE
-            gcx (:,:) = 0.e0
-            gcxb(:,:) = 0.e0
-         ENDIF
-      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
-! Caution : extra-hallow
-! gcx and gcxb are defined as: DIMENSION(1-jpr2di:jpi+jpr2di,1-jpr2dj:jpj+jpr2dj)
-         CALL iom_rstput( kt, nitrst, numrow, 'gcx' , gcx (1:jpi,1:jpj) )
-         CALL iom_rstput( kt, nitrst, numrow, 'gcxb', gcxb(1:jpi,1:jpj) )
-      ENDIF
-      !
-   END SUBROUTINE flt_rst
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default case :   Empty module   No standart free surface cst volume
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE dyn_spg_flt( kt, kindic )       ! Empty routine
-      WRITE(*,*) 'dyn_spg_flt: You should not have seen this print! error?', kt, kindic
-   END SUBROUTINE dyn_spg_flt
-   SUBROUTINE flt_rst    ( kt, cdrw )         ! Empty routine
-      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
-      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
-      WRITE(*,*) 'flt_rst: You should not have seen this print! error?', kt, cdrw
-   END SUBROUTINE flt_rst
-#endif
-   
-   !!======================================================================
-END MODULE dynspg_flt
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_oce.F90	(revision 6040)
+++ 	(revision )
@@ -1,71 +1,0 @@
-MODULE dynspg_oce
-   !!======================================================================
-   !!                       ***  MODULE dynspg_oce  ***
-   !!       
-   !! Ocean dynamics: Define in memory some surface pressure gradient variables
-   !!======================================================================
-   !! History :  1.0  ! 2005-12  (C. Talandier, G. Madec)  Original code
-   !!            3.2  ! 2009-07  (R. Benshila) Suppression of rigid-lid option
-   !!----------------------------------------------------------------------
-   USE par_oce        ! ocean parameters
-   USE lib_mpp        ! MPP library
-
-   IMPLICIT NONE
-   PUBLIC           
-
-   PUBLIC   dynspg_oce_alloc   ! called in dynspg.F90
-   
-   !                                                       !!! Surface pressure gradient logicals
-#if   defined key_dynspg_exp  ||  defined key_esopa
-   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_exp = .TRUE.   !: Explicit free surface flag
-#else
-   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_exp = .FALSE.  !: Explicit free surface flag
-#endif
-#if   defined key_dynspg_ts   ||  defined key_esopa
-   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_ts  = .TRUE.   !: Free surface with time splitting flag
-#else
-   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_ts  = .FALSE.  !: Free surface with time splitting flag
-#endif
-#if   defined key_dynspg_flt  ||  defined key_esopa
-   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_flt = .TRUE.   !: Filtered free surface cst volume flag
-#else
-   LOGICAL, PUBLIC, PARAMETER ::   lk_dynspg_flt = .FALSE.  !: Filtered free surface cst volume flag
-#endif
-
-  !                                                                         !!! Time splitting scheme (key_dynspg_ts) 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshn_e, ssha_e   ! sea surface heigth (now, after)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ua_e  , va_e     ! barotropic velocities (after)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hu_e  , hv_e     ! now ocean depth ( = Ho+sshn_e )
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   hur_e , hvr_e    ! inverse of hu_e and hv_e
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   un_adv, vn_adv   ! Advection vel. at "now" barocl. step
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ub2_b,  vb2_b    ! Half step fluxes (ln_bt_fw=T)
-#if defined key_agrif
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ub2_i_b,  vb2_i_b! Half step time integrated fluxes 
-#endif
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION dynspg_oce_alloc()
-      !!----------------------------------------------------------------------
-      !!                  ***  routine dynspg_oce_alloc  ***
-      !!----------------------------------------------------------------------
-      ALLOCATE( sshn_e(jpi,jpj) , ua_e(jpi,jpj) , hu_e(jpi,jpj) , hur_e(jpi,jpj) ,      &
-         &      ssha_e(jpi,jpj) , va_e(jpi,jpj) , hv_e(jpi,jpj) , hvr_e(jpi,jpj) ,      &
-         &      ub2_b(jpi,jpj)  , vb2_b(jpi,jpj)                                 ,      &
-#if defined key_agrif
-         &      ub2_i_b(jpi,jpj), vb2_i_b(jpi,jpj)                               ,      &
-#endif
-         &      un_adv(jpi,jpj) , vn_adv(jpi,jpj)                                , STAT = dynspg_oce_alloc )
-         !
-      IF( lk_mpp                )   CALL mpp_sum ( dynspg_oce_alloc )
-      IF( dynspg_oce_alloc /= 0 )   CALL ctl_warn('dynspg_oce_alloc: failed to allocate arrays')
-      !
-   END FUNCTION dynspg_oce_alloc
-
-   !!======================================================================
-END MODULE dynspg_oce
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynspg_ts.F90	(revision 6041)
@@ -11,8 +11,8 @@
    !!             3.5  ! 2013-07  (J. Chanut) Switch to Forward-backward time stepping
    !!             3.6  ! 2013-11  (A. Coward) Update for z-tilde compatibility
+   !!             3.7  ! 2015-11  (J. Chanut) free surface simplification
    !!---------------------------------------------------------------------
-#if defined key_dynspg_ts   ||   defined key_esopa
    !!----------------------------------------------------------------------
-   !!   'key_dynspg_ts'         split explicit free surface
+   !!                       split explicit free surface
    !!----------------------------------------------------------------------
    !!   dyn_spg_ts  : compute surface pressure gradient trend using a time-
@@ -23,9 +23,8 @@
    USE sbc_oce         ! surface boundary condition: ocean
    USE sbcisf          ! ice shelf variable (fwfisf)
-   USE dynspg_oce      ! surface pressure gradient variables
    USE phycst          ! physical constants
    USE dynvor          ! vorticity term
    USE bdy_par         ! for lk_bdy
-   USE bdytides        ! open boundary condition data     
+   USE bdytides        ! open boundary condition data
    USE bdydyn2d        ! open boundary conditions on barotropic variables
    USE sbctide         ! tides
@@ -68,10 +67,4 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  ftsw, ftse   ! (only used with een vorticity scheme)
 
-   ! Arrays below are saved to allow testing of the "no time averaging" option
-   ! If this option is not retained, these could be replaced by temporary arrays
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::  sshbb_e, sshb_e, & ! Instantaneous barotropic arrays
-                                                   ubb_e, ub_e,     &
-                                                   vbb_e, vb_e
-
    !! * Substitutions
 #  include "domzgr_substitute.h90"
@@ -88,23 +81,31 @@
       !!                  ***  routine dyn_spg_ts_alloc  ***
       !!----------------------------------------------------------------------
-      INTEGER :: ierr(3)
+      INTEGER :: ierr(4)
       !!----------------------------------------------------------------------
       ierr(:) = 0
 
-      ALLOCATE( sshb_e(jpi,jpj), sshbb_e(jpi,jpj), &
-         &      ub_e(jpi,jpj)  , vb_e(jpi,jpj)   , &
-         &      ubb_e(jpi,jpj) , vbb_e(jpi,jpj)  , STAT= ierr(1) )
+      ALLOCATE( ssha_e(jpi,jpj),  sshn_e(jpi,jpj), sshb_e(jpi,jpj), sshbb_e(jpi,jpj), &
+         &        ua_e(jpi,jpj),    un_e(jpi,jpj),   ub_e(jpi,jpj),   ubb_e(jpi,jpj), &
+         &        va_e(jpi,jpj),    vn_e(jpi,jpj),   vb_e(jpi,jpj),   vbb_e(jpi,jpj), &
+         &        hu_e(jpi,jpj),   hur_e(jpi,jpj),   hv_e(jpi,jpj),   hvr_e(jpi,jpj), STAT= ierr(1) )
 
       ALLOCATE( wgtbtp1(3*nn_baro), wgtbtp2(3*nn_baro), zwz(jpi,jpj), STAT= ierr(2) )
 
-      IF( ln_dynvor_een .or. ln_dynvor_een_old ) ALLOCATE( ftnw(jpi,jpj) , ftne(jpi,jpj) , & 
-                                                    &      ftsw(jpi,jpj) , ftse(jpi,jpj) , STAT=ierr(3) )
+      IF( ln_dynvor_een ) ALLOCATE( ftnw(jpi,jpj) , ftne(jpi,jpj) , & 
+         &                          ftsw(jpi,jpj) , ftse(jpi,jpj) , STAT=ierr(3) )
+
+      ALLOCATE( ub2_b(jpi,jpj), vb2_b(jpi,jpj), un_adv(jpi,jpj), vn_adv(jpi,jpj), &
+#if defined key_agrif
+         &      ub2_i_b(jpi,jpj), vb2_i_b(jpi,jpj)                              , &
+#endif
+         &      STAT= ierr(4))
 
       dyn_spg_ts_alloc = MAXVAL(ierr(:))
 
       IF( lk_mpp                )   CALL mpp_sum( dyn_spg_ts_alloc )
-      IF( dyn_spg_ts_alloc /= 0 )   CALL ctl_warn('dynspg_oce_alloc: failed to allocate arrays')
+      IF( dyn_spg_ts_alloc /= 0 )   CALL ctl_warn('dyn_spg_ts_alloc: failed to allocate arrays')
       !
    END FUNCTION dyn_spg_ts_alloc
+
 
    SUBROUTINE dyn_spg_ts( kt )
@@ -145,13 +146,13 @@
       INTEGER  ::   ikbu, ikbv, noffset    	! local integers
       REAL(wp) ::   zraur, z1_2dt_b, z2dt_bf  	! local scalars
-      REAL(wp) ::   zx1, zy1, zx2, zy2         !   -      -
-      REAL(wp) ::   z1_12, z1_8, z1_4, z1_2 	  !   -      -
-      REAL(wp) ::   zu_spg, zv_spg             !   -      -
-      REAL(wp) ::   zhura, zhvra         	     !   -      -
-      REAL(wp) ::   za0, za1, za2, za3		       !   -      -
-      !
-      REAL(wp), POINTER, DIMENSION(:,:) :: zun_e, zvn_e, zsshp2_e
+      REAL(wp) ::   zx1, zy1, zx2, zy2          !   -      -
+      REAL(wp) ::   z1_12, z1_8, z1_4, z1_2 	!   -      -
+      REAL(wp) ::   zu_spg, zv_spg              !   -      -
+      REAL(wp) ::   zhura, zhvra         	!   -      -
+      REAL(wp) ::   za0, za1, za2, za3		!   -      -
+      !
+      REAL(wp), POINTER, DIMENSION(:,:) :: zsshp2_e
       REAL(wp), POINTER, DIMENSION(:,:) :: zu_trd, zv_trd, zu_frc, zv_frc, zssh_frc
-      REAL(wp), POINTER, DIMENSION(:,:) :: zu_sum, zv_sum, zwx, zwy, zhdiv
+      REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zhdiv
       REAL(wp), POINTER, DIMENSION(:,:) :: zhup2_e, zhvp2_e, zhust_e, zhvst_e
       REAL(wp), POINTER, DIMENSION(:,:) :: zsshu_a, zsshv_a
@@ -163,6 +164,6 @@
       !                                         !* Allocate temporary arrays
       CALL wrk_alloc( jpi, jpj, zsshp2_e, zhdiv )
-      CALL wrk_alloc( jpi, jpj, zu_trd, zv_trd, zun_e, zvn_e  )
-      CALL wrk_alloc( jpi, jpj, zwx, zwy, zu_sum, zv_sum, zssh_frc, zu_frc, zv_frc)
+      CALL wrk_alloc( jpi, jpj, zu_trd, zv_trd)
+      CALL wrk_alloc( jpi, jpj, zwx, zwy, zssh_frc, zu_frc, zv_frc)
       CALL wrk_alloc( jpi, jpj, zhup2_e, zhvp2_e, zhust_e, zhvst_e)
       CALL wrk_alloc( jpi, jpj, zsshu_a, zsshv_a                                   )
@@ -187,5 +188,5 @@
       !
                                      	                ! time offset in steps for bdy data update
-      IF (.NOT.ln_bt_fw) THEN ; noffset=-2*nn_baro ; ELSE ;  noffset = 0 ; ENDIF
+      IF (.NOT.ln_bt_fw) THEN ; noffset=-nn_baro ; ELSE ;  noffset = 0 ; ENDIF
       !
       IF( kt == nit000 ) THEN             	!* initialisation
@@ -219,18 +220,30 @@
       !
       IF ( kt == nit000 .OR. lk_vvl ) THEN
-         IF ( ln_dynvor_een_old ) THEN
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zwz(ji,jj) =   ( ht(ji  ,jj+1) + ht(ji+1,jj+1) +                    &
-                        &          ht(ji  ,jj  ) + ht(ji+1,jj  )   ) / 4._wp  
-                  IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = 1._wp / zwz(ji,jj)
-               END DO
-            END DO
+         IF ( ln_dynvor_een ) THEN              !==  EEN scheme  ==!
+            SELECT CASE( nn_een_e3f )              !* ff/e3 at F-point
+            CASE ( 0 )                                   ! original formulation  (masked averaging of e3t divided by 4)
+               DO jj = 1, jpjm1
+                  DO ji = 1, jpim1
+                     zwz(ji,jj) =   ( ht(ji  ,jj+1) + ht(ji+1,jj+1) +                    &
+                        &             ht(ji  ,jj  ) + ht(ji+1,jj  )   ) / 4._wp  
+                     IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = ff(ji,jj) / zwz(ji,jj)
+                  END DO
+               END DO
+            CASE ( 1 )                                   ! new formulation  (masked averaging of e3t divided by the sum of mask)
+               DO jj = 1, jpjm1
+                  DO ji = 1, jpim1
+                     zwz(ji,jj) =   ( ht(ji  ,jj+1) + ht(ji+1,jj+1) +                     &
+                        &             ht(ji  ,jj  ) + ht(ji+1,jj  )   )                   &
+                        &       / ( MAX( 1._wp, tmask(ji  ,jj+1, 1) + tmask(ji+1,jj+1, 1) +    &
+                        &                       tmask(ji  ,jj  , 1) + tmask(ji+1,jj  , 1) ) )
+                     IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = ff(ji,jj) / zwz(ji,jj)
+                  END DO
+               END DO
+            END SELECT
             CALL lbc_lnk( zwz, 'F', 1._wp )
-            zwz(:,:) = ff(:,:) * zwz(:,:)
-
+            !
             ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
             DO jj = 2, jpj
-               DO ji = fs_2, jpi   ! vector opt.
+               DO ji = 2, jpi
                   ftne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
                   ftnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
@@ -239,30 +252,12 @@
                END DO
             END DO
-         ELSE IF ( ln_dynvor_een ) THEN
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zwz(ji,jj) =   ( ht(ji  ,jj+1) + ht(ji+1,jj+1) +                     &
-                        &          ht(ji  ,jj  ) + ht(ji+1,jj  )   )                   &
-                        &      / ( MAX( 1.0_wp, tmask(ji  ,jj+1, 1) + tmask(ji+1,jj+1, 1) +    &
-                        &                       tmask(ji  ,jj  , 1) + tmask(ji+1,jj  , 1) ) )
-                  IF( zwz(ji,jj) /= 0._wp )   zwz(ji,jj) = 1._wp / zwz(ji,jj)
-               END DO
-            END DO
-            CALL lbc_lnk( zwz, 'F', 1._wp )
-            zwz(:,:) = ff(:,:) * zwz(:,:)
-
-            ftne(1,:) = 0._wp ; ftnw(1,:) = 0._wp ; ftse(1,:) = 0._wp ; ftsw(1,:) = 0._wp
-            DO jj = 2, jpj
-               DO ji = fs_2, jpi   ! vector opt.
-                  ftne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
-                  ftnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
-                  ftse(ji,jj) = zwz(ji  ,jj  ) + zwz(ji  ,jj-1) + zwz(ji-1,jj-1)
-                  ftsw(ji,jj) = zwz(ji  ,jj-1) + zwz(ji-1,jj-1) + zwz(ji-1,jj  )
-               END DO
-            END DO
-         ELSE
+            !
+         ELSE                                !== all other schemes (ENE, ENS, MIX)
             zwz(:,:) = 0._wp
-            zhf(:,:) = 0.
+            zhf(:,:) = 0._wp
             IF ( .not. ln_sco ) THEN
+
+!!gm  agree the JC comment  : this should be done in a much clear way
+
 ! JC: It not clear yet what should be the depth at f-points over land in z-coordinate case
 !     Set it to zero for the time being 
@@ -276,5 +271,5 @@
 
             DO jj = 1, jpjm1
-               zhf(:,jj) = zhf(:,jj)*(1._wp- umask(:,jj,1) * umask(:,jj+1,1))
+               zhf(:,jj) = zhf(:,jj) * (1._wp- umask(:,jj,1) * umask(:,jj+1,1))
             END DO
 
@@ -297,5 +292,5 @@
       ! If forward start at previous time step, and centered integration, 
       ! then update averaging weights:
-      IF ((.NOT.ln_bt_fw).AND.((neuler==0).AND.(kt==nit000+1))) THEN
+      IF (.NOT.ln_bt_fw .AND.( neuler==0 .AND. kt==nit000+1 ) ) THEN
          ll_fw_start=.FALSE.
          CALL ts_wgt(ln_bt_av, ll_fw_start, icycle, wgtbtp1, wgtbtp2)
@@ -338,8 +333,8 @@
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
-               zy2 = ( zwy(ji,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
-               zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
-               zx2 = ( zwx(ji  ,jj) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+               zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) * r1_e1u(ji,jj)
+               zy2 = ( zwy(ji,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
+               zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) * r1_e2v(ji,jj)
+               zx2 = ( zwx(ji  ,jj) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
                ! energy conserving formulation for planetary vorticity term
                zu_trd(ji,jj) = z1_4 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
@@ -352,7 +347,7 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                zy1 =   z1_8 * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) &
-                 &            + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+                 &            + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
                zx1 = - z1_8 * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) &
-                 &            + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+                 &            + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
                zu_trd(ji,jj)  = zy1 * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
                zv_trd(ji,jj)  = zx1 * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
@@ -360,15 +355,15 @@
          END DO
          !
-      ELSEIF ( ln_dynvor_een .or. ln_dynvor_een_old ) THEN  ! enstrophy and energy conserving scheme
+      ELSEIF ( ln_dynvor_een ) THEN  ! enstrophy and energy conserving scheme
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zu_trd(ji,jj) = + z1_12 / e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) &
-                &                                      + ftnw(ji+1,jj) * zwy(ji+1,jj  ) &
-                &                                      + ftse(ji,jj  ) * zwy(ji  ,jj-1) &
-                &                                      + ftsw(ji+1,jj) * zwy(ji+1,jj-1) )
-               zv_trd(ji,jj) = - z1_12 / e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) &
-                &                                      + ftse(ji,jj+1) * zwx(ji  ,jj+1) &
-                &                                      + ftnw(ji,jj  ) * zwx(ji-1,jj  ) &
-                &                                      + ftne(ji,jj  ) * zwx(ji  ,jj  ) )
+               zu_trd(ji,jj) = + z1_12 * r1_e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) &
+                &                                         + ftnw(ji+1,jj) * zwy(ji+1,jj  ) &
+                &                                         + ftse(ji,jj  ) * zwy(ji  ,jj-1) &
+                &                                         + ftsw(ji+1,jj) * zwy(ji+1,jj-1) )
+               zv_trd(ji,jj) = - z1_12 * r1_e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) &
+                &                                         + ftse(ji,jj+1) * zwx(ji  ,jj+1) &
+                &                                         + ftnw(ji,jj  ) * zwx(ji-1,jj  ) &
+                &                                         + ftne(ji,jj  ) * zwx(ji  ,jj  ) )
             END DO
          END DO
@@ -381,6 +376,6 @@
          DO jj = 2, jpjm1 
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zu_trd(ji,jj) = zu_trd(ji,jj) - grav * (  sshn(ji+1,jj  ) - sshn(ji  ,jj  )  ) / e1u(ji,jj)
-               zv_trd(ji,jj) = zv_trd(ji,jj) - grav * (  sshn(ji  ,jj+1) - sshn(ji  ,jj  )  ) / e2v(ji,jj)
+               zu_trd(ji,jj) = zu_trd(ji,jj) - grav * (  sshn(ji+1,jj  ) - sshn(ji  ,jj  )  ) * r1_e1u(ji,jj)
+               zv_trd(ji,jj) = zv_trd(ji,jj) - grav * (  sshn(ji  ,jj+1) - sshn(ji  ,jj  )  ) * r1_e2v(ji,jj)
             END DO
          END DO
@@ -431,6 +426,6 @@
             DO jj = 2, jpjm1              
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_spg =  grav * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj) ) /e1u(ji,jj)
-                  zv_spg =  grav * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj) ) /e2v(ji,jj)
+                  zu_spg =  grav * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj) ) * r1_e1u(ji,jj)
+                  zv_spg =  grav * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj) ) * r1_e2v(ji,jj)
                   zu_frc(ji,jj) = zu_frc(ji,jj) + zu_spg
                   zv_frc(ji,jj) = zv_frc(ji,jj) + zv_spg
@@ -441,7 +436,7 @@
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   zu_spg =  grav * z1_2 * (  ssh_ib (ji+1,jj  ) - ssh_ib (ji,jj)    &
-                      &                    + ssh_ibb(ji+1,jj  ) - ssh_ibb(ji,jj)  ) /e1u(ji,jj)
+                      &                    + ssh_ibb(ji+1,jj  ) - ssh_ibb(ji,jj)  ) * r1_e1u(ji,jj)
                   zv_spg =  grav * z1_2 * (  ssh_ib (ji  ,jj+1) - ssh_ib (ji,jj)    &
-                      &                    + ssh_ibb(ji  ,jj+1) - ssh_ibb(ji,jj)  ) /e2v(ji,jj)
+                      &                    + ssh_ibb(ji  ,jj+1) - ssh_ibb(ji,jj)  ) * r1_e2v(ji,jj)
                   zu_frc(ji,jj) = zu_frc(ji,jj) + zu_spg
                   zv_frc(ji,jj) = zv_frc(ji,jj) + zv_spg
@@ -490,6 +485,6 @@
       IF (ln_bt_fw) THEN                  ! FORWARD integration: start from NOW fields                    
          sshn_e(:,:) = sshn (:,:)            
-         zun_e (:,:) = un_b (:,:)            
-         zvn_e (:,:) = vn_b (:,:)
+         un_e  (:,:) = un_b (:,:)            
+         vn_e  (:,:) = vn_b (:,:)
          !
          hu_e  (:,:) = hu   (:,:)       
@@ -499,6 +494,6 @@
       ELSE                                ! CENTRED integration: start from BEFORE fields
          sshn_e(:,:) = sshb (:,:)
-         zun_e (:,:) = ub_b (:,:)         
-         zvn_e (:,:) = vb_b (:,:)
+         un_e  (:,:) = ub_b (:,:)         
+         vn_e  (:,:) = vb_b (:,:)
          !
          hu_e  (:,:) = hu_b (:,:)       
@@ -514,6 +509,6 @@
       va_b  (:,:) = 0._wp
       ssha  (:,:) = 0._wp       ! Sum for after averaged sea level
-      zu_sum(:,:) = 0._wp       ! Sum for now transport issued from ts loop
-      zv_sum(:,:) = 0._wp
+      un_adv(:,:) = 0._wp       ! Sum for now transport issued from ts loop
+      vn_adv(:,:) = 0._wp
       !                                             ! ==================== !
       DO jn = 1, icycle                             !  sub-time-step loop  !
@@ -523,6 +518,6 @@
          ! Update only tidal forcing at open boundaries
 #if defined key_tide
-         IF ( lk_bdy .AND. lk_tide )      CALL bdy_dta_tides( kt, kit=jn, time_offset=(noffset+1) )
-         IF ( ln_tide_pot .AND. lk_tide ) CALL upd_tide( kt, kit=jn, koffset=noffset )
+         IF ( lk_bdy .AND. lk_tide ) CALL bdy_dta_tides( kt, kit=jn, time_offset=(noffset+1) )
+         IF ( ln_tide_pot .AND. lk_tide ) CALL upd_tide( kt, kit=jn, time_offset=noffset )
 #endif
          !
@@ -539,6 +534,6 @@
 
          ! Extrapolate barotropic velocities at step jit+0.5:
-         ua_e(:,:) = za1 * zun_e(:,:) + za2 * ub_e(:,:) + za3 * ubb_e(:,:)
-         va_e(:,:) = za1 * zvn_e(:,:) + za2 * vb_e(:,:) + za3 * vbb_e(:,:)
+         ua_e(:,:) = za1 * un_e(:,:) + za2 * ub_e(:,:) + za3 * ubb_e(:,:)
+         va_e(:,:) = za1 * vn_e(:,:) + za2 * vb_e(:,:) + za3 * vbb_e(:,:)
 
          IF( lk_vvl ) THEN                                !* Update ocean depth (variable volume case only)
@@ -549,10 +544,10 @@
             DO jj = 2, jpjm1                                    ! Sea Surface Height at u- & v-points
                DO ji = 2, fs_jpim1   ! Vector opt.
-                  zwx(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e12u(ji,jj)     &
-                     &              * ( e12t(ji  ,jj) * zsshp2_e(ji  ,jj)  &
-                     &              +   e12t(ji+1,jj) * zsshp2_e(ji+1,jj) )
-                  zwy(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e12v(ji,jj)     &
-                     &              * ( e12t(ji,jj  ) * zsshp2_e(ji,jj  )  &
-                     &              +   e12t(ji,jj+1) * zsshp2_e(ji,jj+1) )
+                  zwx(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e1e2u(ji,jj)     &
+                     &              * ( e1e2t(ji  ,jj) * zsshp2_e(ji  ,jj)  &
+                     &              +   e1e2t(ji+1,jj) * zsshp2_e(ji+1,jj) )
+                  zwy(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e1e2v(ji,jj)     &
+                     &              * ( e1e2t(ji,jj  ) * zsshp2_e(ji,jj  )  &
+                     &              +   e1e2t(ji,jj+1) * zsshp2_e(ji,jj+1) )
                END DO
             END DO
@@ -602,6 +597,6 @@
          ! Sum over sub-time-steps to compute advective velocities
          za2 = wgtbtp2(jn)
-         zu_sum  (:,:) = zu_sum  (:,:) + za2 * zwx  (:,:) / e2u  (:,:)
-         zv_sum  (:,:) = zv_sum  (:,:) + za2 * zwy  (:,:) / e1v  (:,:)
+         un_adv(:,:) = un_adv(:,:) + za2 * zwx(:,:) * r1_e2u(:,:)
+         vn_adv(:,:) = vn_adv(:,:) + za2 * zwy(:,:) * r1_e1v(:,:)
          !
          ! Set next sea level:
@@ -609,5 +604,5 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                zhdiv(ji,jj) = (   zwx(ji,jj) - zwx(ji-1,jj)   &
-                  &             + zwy(ji,jj) - zwy(ji,jj-1)   ) * r1_e12t(ji,jj)
+                  &             + zwy(ji,jj) - zwy(ji,jj-1)   ) * r1_e1e2t(ji,jj)
             END DO
          END DO
@@ -627,10 +622,10 @@
             DO jj = 2, jpjm1
                DO ji = 2, jpim1      ! NO Vector Opt.
-                  zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e12u(ji,jj)  &
-                     &              * ( e12t(ji  ,jj  ) * ssha_e(ji  ,jj  ) &
-                     &              +   e12t(ji+1,jj  ) * ssha_e(ji+1,jj  ) )
-                  zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e12v(ji,jj)  &
-                     &              * ( e12t(ji  ,jj  ) * ssha_e(ji  ,jj  ) &
-                     &              +   e12t(ji  ,jj+1) * ssha_e(ji  ,jj+1) )
+                  zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e1e2u(ji,jj)  &
+                     &              * ( e1e2t(ji  ,jj  ) * ssha_e(ji  ,jj  ) &
+                     &              +   e1e2t(ji+1,jj  ) * ssha_e(ji+1,jj  ) )
+                  zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e1e2v(ji,jj)  &
+                     &              * ( e1e2t(ji  ,jj  ) * ssha_e(ji  ,jj  ) &
+                     &              +   e1e2t(ji  ,jj+1) * ssha_e(ji  ,jj+1) )
                END DO
             END DO
@@ -666,10 +661,10 @@
             DO jj = 2, jpjm1                            
                DO ji = 2, jpim1
-                  zx1 = z1_2 * umask(ji  ,jj,1) *  r1_e12u(ji  ,jj)    &
-                     &      * ( e12t(ji  ,jj  ) * zsshp2_e(ji  ,jj)    &
-                     &      +   e12t(ji+1,jj  ) * zsshp2_e(ji+1,jj  ) )
-                  zy1 = z1_2 * vmask(ji  ,jj,1) *  r1_e12v(ji  ,jj  )  &
-                     &       * ( e12t(ji ,jj  ) * zsshp2_e(ji  ,jj  )  &
-                     &       +   e12t(ji ,jj+1) * zsshp2_e(ji  ,jj+1) )
+                  zx1 = z1_2 * umask(ji  ,jj,1) *  r1_e1e2u(ji  ,jj)    &
+                     &      * ( e1e2t(ji  ,jj  ) * zsshp2_e(ji  ,jj)    &
+                     &      +   e1e2t(ji+1,jj  ) * zsshp2_e(ji+1,jj  ) )
+                  zy1 = z1_2 * vmask(ji  ,jj,1) *  r1_e1e2v(ji  ,jj  )  &
+                     &       * ( e1e2t(ji ,jj  ) * zsshp2_e(ji  ,jj  )  &
+                     &       +   e1e2t(ji ,jj+1) * zsshp2_e(ji  ,jj+1) )
                   zhust_e(ji,jj) = hu_0(ji,jj) + zx1 
                   zhvst_e(ji,jj) = hv_0(ji,jj) + zy1
@@ -688,8 +683,8 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zy1 = ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
-                  zy2 = ( zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
-                  zx1 = ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
-                  zx2 = ( zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+                  zy1 = ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) ) * r1_e1u(ji,jj)
+                  zy2 = ( zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
+                  zx1 = ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) ) * r1_e2v(ji,jj)
+                  zx2 = ( zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
                   zu_trd(ji,jj) = z1_4 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
                   zv_trd(ji,jj) =-z1_4 * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 )
@@ -701,7 +696,7 @@
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   zy1 =   z1_8 * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1) &
-                   &             + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
+                   &             + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) ) * r1_e1u(ji,jj)
                   zx1 = - z1_8 * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1) &
-                   &             + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
+                   &             + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) ) * r1_e2v(ji,jj)
                   zu_trd(ji,jj)  = zy1 * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
                   zv_trd(ji,jj)  = zx1 * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
@@ -709,15 +704,15 @@
             END DO
             !
-         ELSEIF ( ln_dynvor_een .or. ln_dynvor_een_old ) THEN !==  energy and enstrophy conserving scheme  ==!
+         ELSEIF ( ln_dynvor_een ) THEN !==  energy and enstrophy conserving scheme  ==!
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_trd(ji,jj) = + z1_12 / e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) &
-                     &                                    + ftnw(ji+1,jj) * zwy(ji+1,jj  ) &
-                     &                                    + ftse(ji,jj  ) * zwy(ji  ,jj-1) & 
-                     &                                    + ftsw(ji+1,jj) * zwy(ji+1,jj-1) )
-                  zv_trd(ji,jj) = - z1_12 / e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) & 
-                     &                                    + ftse(ji,jj+1) * zwx(ji  ,jj+1) &
-                     &                                    + ftnw(ji,jj  ) * zwx(ji-1,jj  ) & 
-                     &                                    + ftne(ji,jj  ) * zwx(ji  ,jj  ) )
+                  zu_trd(ji,jj) = + z1_12 * r1_e1u(ji,jj) * (  ftne(ji,jj  ) * zwy(ji  ,jj  ) &
+                     &                                       + ftnw(ji+1,jj) * zwy(ji+1,jj  ) &
+                     &                                       + ftse(ji,jj  ) * zwy(ji  ,jj-1) & 
+                     &                                       + ftsw(ji+1,jj) * zwy(ji+1,jj-1) )
+                  zv_trd(ji,jj) = - z1_12 * r1_e2v(ji,jj) * (  ftsw(ji,jj+1) * zwx(ji-1,jj+1) & 
+                     &                                       + ftse(ji,jj+1) * zwx(ji  ,jj+1) &
+                     &                                       + ftnw(ji,jj  ) * zwx(ji-1,jj  ) & 
+                     &                                       + ftne(ji,jj  ) * zwx(ji  ,jj  ) )
                END DO
             END DO
@@ -729,6 +724,6 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zu_spg = grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) / e1u(ji,jj)
-                  zv_spg = grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) / e2v(ji,jj)
+                  zu_spg = grav * ( pot_astro(ji+1,jj) - pot_astro(ji,jj) ) * r1_e1u(ji,jj)
+                  zv_spg = grav * ( pot_astro(ji,jj+1) - pot_astro(ji,jj) ) * r1_e2v(ji,jj)
                   zu_trd(ji,jj) = zu_trd(ji,jj) + zu_spg
                   zv_trd(ji,jj) = zv_trd(ji,jj) + zv_spg
@@ -738,6 +733,6 @@
          !
          ! Add bottom stresses:
-         zu_trd(:,:) = zu_trd(:,:) + bfrua(:,:) * zun_e(:,:) * hur_e(:,:)
-         zv_trd(:,:) = zv_trd(:,:) + bfrva(:,:) * zvn_e(:,:) * hvr_e(:,:)
+         zu_trd(:,:) = zu_trd(:,:) + bfrua(:,:) * un_e(:,:) * hur_e(:,:)
+         zv_trd(:,:) = zv_trd(:,:) + bfrva(:,:) * vn_e(:,:) * hvr_e(:,:)
          !
          ! Surface pressure trend:
@@ -745,6 +740,6 @@
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ! Add surface pressure gradient
-               zu_spg = - grav * ( zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj) ) / e1u(ji,jj)
-               zv_spg = - grav * ( zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj) ) / e2v(ji,jj)
+               zu_spg = - grav * ( zsshp2_e(ji+1,jj) - zsshp2_e(ji,jj) ) * r1_e1u(ji,jj)
+               zv_spg = - grav * ( zsshp2_e(ji,jj+1) - zsshp2_e(ji,jj) ) * r1_e2v(ji,jj)
                zwx(ji,jj) = zu_spg
                zwy(ji,jj) = zv_spg
@@ -756,5 +751,5 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ua_e(ji,jj) = (                                zun_e(ji,jj)   & 
+                  ua_e(ji,jj) = (                                 un_e(ji,jj)   & 
                             &     + rdtbt * (                      zwx(ji,jj)   &
                             &                                 + zu_trd(ji,jj)   &
@@ -762,5 +757,5 @@
                             &   ) * umask(ji,jj,1)
 
-                  va_e(ji,jj) = (                                zvn_e(ji,jj)   &
+                  va_e(ji,jj) = (                                 vn_e(ji,jj)   &
                             &     + rdtbt * (                      zwy(ji,jj)   &
                             &                                 + zv_trd(ji,jj)   &
@@ -777,5 +772,5 @@
                   zhvra = vmask(ji,jj,1)/(hv_0(ji,jj) + zsshv_a(ji,jj) + 1._wp - vmask(ji,jj,1))
 
-                  ua_e(ji,jj) = (                hu_e(ji,jj)  *  zun_e(ji,jj)   & 
+                  ua_e(ji,jj) = (                hu_e(ji,jj)  *   un_e(ji,jj)   & 
                             &     + rdtbt * ( zhust_e(ji,jj)  *    zwx(ji,jj)   & 
                             &               + zhup2_e(ji,jj)  * zu_trd(ji,jj)   &
@@ -783,5 +778,5 @@
                             &   ) * zhura
 
-                  va_e(ji,jj) = (                hv_e(ji,jj)  *  zvn_e(ji,jj)   &
+                  va_e(ji,jj) = (                hv_e(ji,jj)  *   vn_e(ji,jj)   &
                             &     + rdtbt * ( zhvst_e(ji,jj)  *    zwy(ji,jj)   &
                             &               + zhvp2_e(ji,jj)  * zv_trd(ji,jj)   &
@@ -807,5 +802,5 @@
 #if defined key_bdy  
                                                            ! open boundaries
-         IF( lk_bdy ) CALL bdy_dyn2d( jn, ua_e, va_e, zun_e, zvn_e, hur_e, hvr_e, ssha_e )
+         IF( lk_bdy ) CALL bdy_dyn2d( jn, ua_e, va_e, un_e, vn_e, hur_e, hvr_e, ssha_e )
 #endif
 #if defined key_agrif                                                           
@@ -815,10 +810,10 @@
          !                                             !  ----
          ubb_e  (:,:) = ub_e  (:,:)
-         ub_e   (:,:) = zun_e (:,:)
-         zun_e  (:,:) = ua_e  (:,:)
+         ub_e   (:,:) = un_e  (:,:)
+         un_e   (:,:) = ua_e  (:,:)
          !
          vbb_e  (:,:) = vb_e  (:,:)
-         vb_e   (:,:) = zvn_e (:,:)
-         zvn_e  (:,:) = va_e  (:,:)
+         vb_e   (:,:) = vn_e  (:,:)
+         vn_e   (:,:) = va_e  (:,:)
          !
          sshbb_e(:,:) = sshb_e(:,:)
@@ -845,32 +840,18 @@
       ! -----------------------------------------------------------------------------
       !
-      ! At this stage ssha holds a time averaged value
-      !                                                ! Sea Surface Height at u-,v- and f-points
-      IF( lk_vvl ) THEN                                ! (required only in key_vvl case)
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1      ! NO Vector Opt.
-               zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e12u(ji,jj) &
-                  &              * ( e12t(ji  ,jj) * ssha(ji  ,jj)    &
-                  &              +   e12t(ji+1,jj) * ssha(ji+1,jj) )
-               zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e12v(ji,jj) &
-                  &              * ( e12t(ji,jj  ) * ssha(ji,jj  )    &
-                  &              +   e12t(ji,jj+1) * ssha(ji,jj+1) )
-            END DO
-         END DO
-         CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
-      ENDIF
-      !
       ! Set advection velocity correction:
+      zwx(:,:) = un_adv(:,:)
+      zwy(:,:) = vn_adv(:,:)
       IF (((kt==nit000).AND.(neuler==0)).OR.(.NOT.ln_bt_fw)) THEN     
-         un_adv(:,:) = zu_sum(:,:)*hur(:,:)
-         vn_adv(:,:) = zv_sum(:,:)*hvr(:,:)
+         un_adv(:,:) = zwx(:,:)*hur(:,:)
+         vn_adv(:,:) = zwy(:,:)*hvr(:,:)
       ELSE
-         un_adv(:,:) = z1_2 * ( ub2_b(:,:) + zu_sum(:,:)) * hur(:,:)
-         vn_adv(:,:) = z1_2 * ( vb2_b(:,:) + zv_sum(:,:)) * hvr(:,:)
+         un_adv(:,:) = z1_2 * ( ub2_b(:,:) + zwx(:,:)) * hur(:,:)
+         vn_adv(:,:) = z1_2 * ( vb2_b(:,:) + zwy(:,:)) * hvr(:,:)
       END IF
 
       IF (ln_bt_fw) THEN ! Save integrated transport for next computation
-         ub2_b(:,:) = zu_sum(:,:)
-         vb2_b(:,:) = zv_sum(:,:)
+         ub2_b(:,:) = zwx(:,:)
+         vb2_b(:,:) = zwy(:,:)
       ENDIF
       !
@@ -882,4 +863,17 @@
          END DO
       ELSE
+         ! At this stage, ssha has been corrected: compute new depths at velocity points
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1      ! NO Vector Opt.
+               zsshu_a(ji,jj) = z1_2 * umask(ji,jj,1)  * r1_e1e2u(ji,jj) &
+                  &              * ( e1e2t(ji  ,jj) * ssha(ji  ,jj)    &
+                  &              +   e1e2t(ji+1,jj) * ssha(ji+1,jj) )
+               zsshv_a(ji,jj) = z1_2 * vmask(ji,jj,1)  * r1_e1e2v(ji,jj) &
+                  &              * ( e1e2t(ji,jj  ) * ssha(ji,jj  )    &
+                  &              +   e1e2t(ji,jj+1) * ssha(ji,jj+1) )
+            END DO
+         END DO
+         CALL lbc_lnk_multi( zsshu_a, 'U', 1._wp, zsshv_a, 'V', 1._wp ) ! Boundary conditions
+         !
          DO jk=1,jpkm1
             ua(:,:,jk) = ua(:,:,jk) + hur(:,:) * ( ua_b(:,:) - ub_b(:,:) * hu_b(:,:) ) * z1_2dt_b
@@ -920,6 +914,6 @@
       !
       CALL wrk_dealloc( jpi, jpj, zsshp2_e, zhdiv )
-      CALL wrk_dealloc( jpi, jpj, zu_trd, zv_trd, zun_e, zvn_e )
-      CALL wrk_dealloc( jpi, jpj, zwx, zwy, zu_sum, zv_sum, zssh_frc, zu_frc, zv_frc )
+      CALL wrk_dealloc( jpi, jpj, zu_trd, zv_trd )
+      CALL wrk_dealloc( jpi, jpj, zwx, zwy, zssh_frc, zu_frc, zv_frc )
       CALL wrk_dealloc( jpi, jpj, zhup2_e, zhvp2_e, zhust_e, zhvst_e )
       CALL wrk_dealloc( jpi, jpj, zsshu_a, zsshv_a                                   )
@@ -1069,50 +1063,28 @@
       !
       INTEGER  :: ji ,jj
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
       REAL(wp) :: zxr2, zyr2, zcmax
       REAL(wp), POINTER, DIMENSION(:,:) :: zcu
       !!
-      NAMELIST/namsplit/ ln_bt_fw, ln_bt_av, ln_bt_nn_auto, &
-      &                  nn_baro, rn_bt_cmax, nn_bt_flt
       !!----------------------------------------------------------------------
       !
-      REWIND( numnam_ref )              ! Namelist namsplit in reference namelist : time splitting parameters
-      READ  ( numnam_ref, namsplit, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsplit in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namsplit in configuration namelist : time splitting parameters
-      READ  ( numnam_cfg, namsplit, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsplit in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, namsplit )
-      !
-      !         ! Max courant number for ext. grav. waves
+      ! Max courant number for ext. grav. waves
       !
       CALL wrk_alloc( jpi, jpj, zcu )
       !
-      IF (lk_vvl) THEN 
-         DO jj = 1, jpj
-            DO ji =1, jpi
-               zxr2 = 1./(e1t(ji,jj)*e1t(ji,jj))
-               zyr2 = 1./(e2t(ji,jj)*e2t(ji,jj))
-               zcu(ji,jj) = sqrt(grav*ht_0(ji,jj)*(zxr2 + zyr2) )
-            END DO
-         END DO
-      ELSE
-         DO jj = 1, jpj
-            DO ji =1, jpi
-               zxr2 = 1./(e1t(ji,jj)*e1t(ji,jj))
-               zyr2 = 1./(e2t(ji,jj)*e2t(ji,jj))
-               zcu(ji,jj) = sqrt(grav*ht(ji,jj)*(zxr2 + zyr2) )
-            END DO
-         END DO
-      ENDIF
-
-      zcmax = MAXVAL(zcu(:,:))
+      DO jj = 1, jpj
+         DO ji =1, jpi
+            zxr2 = r1_e1t(ji,jj) * r1_e1t(ji,jj)
+            zyr2 = r1_e2t(ji,jj) * r1_e2t(ji,jj)
+            zcu(ji,jj) = SQRT( grav * ht_0(ji,jj) * (zxr2 + zyr2) )
+         END DO
+      END DO
+      !
+      zcmax = MAXVAL( zcu(:,:) )
       IF( lk_mpp )   CALL mpp_max( zcmax )
 
       ! Estimate number of iterations to satisfy a max courant number= rn_bt_cmax
-      IF (ln_bt_nn_auto) nn_baro = CEILING( rdt / rn_bt_cmax * zcmax)
+      IF (ln_bt_auto) nn_baro = CEILING( rdt / rn_bt_cmax * zcmax)
       
-      rdtbt = rdt / FLOAT(nn_baro)
+      rdtbt = rdt / REAL( nn_baro , wp )
       zcmax = zcmax * rdtbt
 							! Print results
@@ -1120,9 +1092,9 @@
       IF(lwp) WRITE(numout,*) 'dyn_spg_ts : split-explicit free surface'
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
-      IF( ln_bt_nn_auto ) THEN
-         IF(lwp) WRITE(numout,*) '     ln_ts_nn_auto=.true. Automatically set nn_baro '
+      IF( ln_bt_auto ) THEN
+         IF(lwp) WRITE(numout,*) '     ln_ts_auto=.true. Automatically set nn_baro '
          IF(lwp) WRITE(numout,*) '     Max. courant number allowed: ', rn_bt_cmax
       ELSE
-         IF(lwp) WRITE(numout,*) '     ln_ts_nn_auto=.false.: Use nn_baro in namelist '
+         IF(lwp) WRITE(numout,*) '     ln_ts_auto=.false.: Use nn_baro in namelist '
       ENDIF
 
@@ -1169,30 +1141,4 @@
    END SUBROUTINE dyn_spg_ts_init
 
-#else
-   !!---------------------------------------------------------------------------
-   !!   Default case :   Empty module   No split explicit free surface
-   !!---------------------------------------------------------------------------
-CONTAINS
-   INTEGER FUNCTION dyn_spg_ts_alloc()    ! Dummy function
-      dyn_spg_ts_alloc = 0
-   END FUNCTION dyn_spg_ts_alloc
-   SUBROUTINE dyn_spg_ts( kt )            ! Empty routine
-      INTEGER, INTENT(in) :: kt
-      WRITE(*,*) 'dyn_spg_ts: You should not have seen this print! error?', kt
-   END SUBROUTINE dyn_spg_ts
-   SUBROUTINE ts_rst( kt, cdrw )          ! Empty routine
-      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
-      CHARACTER(len=*), INTENT(in) ::   cdrw       ! "READ"/"WRITE" flag
-      WRITE(*,*) 'ts_rst    : You should not have seen this print! error?', kt, cdrw
-   END SUBROUTINE ts_rst  
-   SUBROUTINE dyn_spg_ts_init( kt )       ! Empty routine
-      INTEGER         , INTENT(in) ::   kt         ! ocean time-step
-      WRITE(*,*) 'dyn_spg_ts_init   : You should not have seen this print! error?', kt
-   END SUBROUTINE dyn_spg_ts_init
-#endif
-   
    !!======================================================================
 END MODULE dynspg_ts
-
-
-
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 6041)
@@ -16,4 +16,5 @@
    !!            3.3  ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
    !!            3.7  ! 2014-04  (G. Madec) trend simplification: suppress jpdyn_trd_dat vorticity 
+   !!             -   ! 2014-06  (G. Madec) suppression of velocity curl from in-core memory
    !!----------------------------------------------------------------------
 
@@ -22,5 +23,4 @@
    !!       vor_ens  : enstrophy conserving scheme       (ln_dynvor_ens=T)
    !!       vor_ene  : energy conserving scheme          (ln_dynvor_ene=T)
-   !!       vor_mix  : mixed enstrophy/energy conserving (ln_dynvor_mix=T)
    !!       vor_een  : energy and enstrophy conserving   (ln_dynvor_een=T)
    !!   dyn_vor_init : set and control of the different vorticity option
@@ -32,4 +32,6 @@
    USE trd_oce        ! trends: ocean variables
    USE trddyn         ! trend manager: dynamics
+   USE c1d            ! 1D vertical configuration
+   !
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
    USE prtctl         ! Print control
@@ -44,23 +46,38 @@
 
    PUBLIC   dyn_vor        ! routine called by step.F90
-   PUBLIC   dyn_vor_init   ! routine called by opa.F90
+   PUBLIC   dyn_vor_init   ! routine called by nemogcm.F90
 
    !                                   !!* Namelist namdyn_vor: vorticity term
-   LOGICAL, PUBLIC ::   ln_dynvor_ene   !: energy conserving scheme
-   LOGICAL, PUBLIC ::   ln_dynvor_ens   !: enstrophy conserving scheme
-   LOGICAL, PUBLIC ::   ln_dynvor_mix   !: mixed scheme
-   LOGICAL, PUBLIC ::   ln_dynvor_een   !: energy and enstrophy conserving scheme
-   LOGICAL, PUBLIC ::   ln_dynvor_een_old !: energy and enstrophy conserving scheme (original formulation)
-
-   INTEGER ::   nvor = 0   ! type of vorticity trend used
-   INTEGER ::   ncor = 1   ! coriolis
-   INTEGER ::   nrvm = 2   ! =2 relative vorticity ; =3 metric term
-   INTEGER ::   ntot = 4   ! =4 total vorticity (relative + planetary) ; =5 coriolis + metric term
-
+   LOGICAL, PUBLIC ::   ln_dynvor_ene   !: energy conserving scheme    (ENE)
+   LOGICAL, PUBLIC ::   ln_dynvor_ens   !: enstrophy conserving scheme (ENS)
+   LOGICAL, PUBLIC ::   ln_dynvor_mix   !: mixed scheme                (MIX)
+   LOGICAL, PUBLIC ::   ln_dynvor_een   !: energy and enstrophy conserving scheme (EEN)
+   INTEGER, PUBLIC ::      nn_een_e3f      !: e3f=masked averaging of e3t divided by 4 (=0) or by the sum of mask (=1)
+   LOGICAL, PUBLIC ::   ln_dynvor_msk   !: vorticity multiplied by fmask (=T) or not (=F) (all vorticity schemes)
+
+   INTEGER ::   nvor_scheme        ! choice of the type of advection scheme
+   !                               ! associated indices:
+   INTEGER, PUBLIC, PARAMETER ::   np_ENE = 1   ! ENE scheme
+   INTEGER, PUBLIC, PARAMETER ::   np_ENS = 2   ! ENS scheme
+   INTEGER, PUBLIC, PARAMETER ::   np_MIX = 3   ! MIX scheme
+   INTEGER, PUBLIC, PARAMETER ::   np_EEN = 4   ! EEN scheme
+
+   INTEGER ::   ncor, nrvm, ntot   ! choice of calculated vorticity 
+   !                               ! associated indices:
+   INTEGER, PARAMETER ::   np_COR = 1         ! Coriolis (planetary)
+   INTEGER, PARAMETER ::   np_RVO = 2         ! relative vorticity
+   INTEGER, PARAMETER ::   np_MET = 3         ! metric term
+   INTEGER, PARAMETER ::   np_CRV = 4         ! relative + planetary (total vorticity)
+   INTEGER, PARAMETER ::   np_CME = 5         ! Coriolis + metric term
+   
+   REAL(wp) ::   r1_4  = 0.250_wp         ! =1/4
+   REAL(wp) ::   r1_8  = 0.125_wp         ! =1/8
+   REAL(wp) ::   r1_12 = 1._wp / 12._wp   ! 1/12
+   
    !! * Substitutions
 #  include "domzgr_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -87,26 +104,11 @@
       IF( l_trddyn )   CALL wrk_alloc( jpi,jpj,jpk, ztrdu, ztrdv )
       !
-      !                                          ! vorticity term 
-      SELECT CASE ( nvor )                       ! compute the vorticity trend and add it to the general trend
-      !
-      CASE ( -1 )                                      ! esopa: test all possibility with control print
-         CALL vor_ene( kt, ntot, ua, va )
-         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor0 - Ua: ', mask1=umask, &
-            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-         CALL vor_ens( kt, ntot, ua, va )
-         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor1 - Ua: ', mask1=umask, &
-            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-         CALL vor_mix( kt )
-         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor2 - Ua: ', mask1=umask, &
-            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-         CALL vor_een( kt, ntot, ua, va )
-         CALL prt_ctl( tab3d_1=ua, clinfo1=' vor3 - Ua: ', mask1=umask, &
-            &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-         !
-      CASE ( 0 )                                       ! energy conserving scheme
-         IF( l_trddyn )   THEN
-            ztrdu(:,:,:) = ua(:,:,:)
-            ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_ene( kt, nrvm, ua, va )                ! relative vorticity or metric trend
+      SELECT CASE ( nvor_scheme )               !==  vorticity trend added to the general trend  ==!
+      !
+      CASE ( np_ENE )                                 !* energy conserving scheme
+         IF( l_trddyn ) THEN                                ! trend diagnostics: split the trend in two
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ene( kt, nrvm, ua, va )                      ! relative vorticity or metric trend
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
@@ -114,17 +116,17 @@
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_ene( kt, ncor, ua, va )                ! planetary vorticity trend
+            CALL vor_ene( kt, ncor, ua, va )                      ! planetary vorticity trend
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
             CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
-            CALL vor_ene( kt, ntot, ua, va )                ! total vorticity
-         ENDIF
-         !
-      CASE ( 1 )                                       ! enstrophy conserving scheme
-         IF( l_trddyn )   THEN    
-            ztrdu(:,:,:) = ua(:,:,:)
-            ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_ens( kt, nrvm, ua, va )                ! relative vorticity or metric trend
+            CALL vor_ene( kt, ntot, ua, va )                ! total vorticity trend
+         ENDIF
+         !
+      CASE ( np_ENS )                                 !* enstrophy conserving scheme
+         IF( l_trddyn ) THEN                                ! trend diagnostics: splitthe trend in two    
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ens( kt, nrvm, ua, va )                      ! relative vorticity or metric trend
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
@@ -132,17 +134,17 @@
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_ens( kt, ncor, ua, va )                ! planetary vorticity trend
+            CALL vor_ens( kt, ncor, ua, va )                      ! planetary vorticity trend
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
             CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
-            CALL vor_ens( kt, ntot, ua, va )                ! total vorticity
-         ENDIF
-         !
-      CASE ( 2 )                                       ! mixed ene-ens scheme
-         IF( l_trddyn )   THEN
-            ztrdu(:,:,:) = ua(:,:,:)
-            ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_ens( kt, nrvm, ua, va )                ! relative vorticity or metric trend (ens)
+            CALL vor_ens( kt, ntot, ua, va )                ! total vorticity trend
+         ENDIF
+         !
+      CASE ( np_MIX )                                 !* mixed ene-ens scheme
+         IF( l_trddyn ) THEN                                ! trend diagnostics: split the trend in two
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_ens( kt, nrvm, ua, va )                      ! relative vorticity or metric trend (ens)
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
@@ -150,17 +152,18 @@
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_ene( kt, ncor, ua, va )                ! planetary vorticity trend (ene)
+            CALL vor_ene( kt, ncor, ua, va )                      ! planetary vorticity trend (ene)
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
             CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
-            CALL vor_mix( kt )                               ! total vorticity (mix=ens-ene)
-         ENDIF
-         !
-      CASE ( 3 )                                       ! energy and enstrophy conserving scheme
-         IF( l_trddyn )   THEN
-            ztrdu(:,:,:) = ua(:,:,:)
-            ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_een( kt, nrvm, ua, va )                ! relative vorticity or metric trend
+            CALL vor_ens( kt, nrvm, ua, va )                ! relative vorticity or metric trend (ens)
+            CALL vor_ene( kt, ncor, ua, va )                ! planetary vorticity trend (ene)
+        ENDIF
+         !
+      CASE ( np_EEN )                                 !* energy and enstrophy conserving scheme
+         IF( l_trddyn ) THEN                                ! trend diagnostics: split the trend in two
+            ztrdu(:,:,:) = ua(:,:,:)
+            ztrdv(:,:,:) = va(:,:,:)
+            CALL vor_een( kt, nrvm, ua, va )                      ! relative vorticity or metric trend
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
@@ -168,10 +171,10 @@
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
-            CALL vor_een( kt, ncor, ua, va )                ! planetary vorticity trend
+            CALL vor_een( kt, ncor, ua, va )                      ! planetary vorticity trend
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
             CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
-            CALL vor_een( kt, ntot, ua, va )                ! total vorticity
+            CALL vor_een( kt, ntot, ua, va )                ! total vorticity trend
          ENDIF
          !
@@ -197,15 +200,11 @@
       !!
       !! ** Method  :   Trend evaluated using now fields (centered in time) 
-      !!      and the Sadourny (1975) flux form formulation : conserves the
-      !!      horizontal kinetic energy.
-      !!      The trend of the vorticity term is given by:
-      !!       * s-coordinate (ln_sco=T), the e3. are inside the derivatives:
-      !!          voru = 1/e1u  mj-1[ (rotn+f)/e3f  mi(e1v*e3v vn) ]
-      !!          vorv = 1/e2v  mi-1[ (rotn+f)/e3f  mj(e2u*e3u un) ]
-      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
-      !!          voru = 1/e1u  mj-1[ (rotn+f)  mi(e1v vn) ]
-      !!          vorv = 1/e2v  mi-1[ (rotn+f)  mj(e2u un) ]
-      !!      Add this trend to the general momentum trend (ua,va):
-      !!          (ua,va) = (ua,va) + ( voru , vorv )
+      !!       and the Sadourny (1975) flux form formulation : conserves the
+      !!       horizontal kinetic energy.
+      !!         The general trend of momentum is increased due to the vorticity 
+      !!       term which is given by:
+      !!          voru = 1/e1u  mj-1[ (rvor+f)/e3f  mi(e1v*e3v vn) ]
+      !!          vorv = 1/e2v  mi-1[ (rvor+f)/e3f  mj(e2u*e3u un) ]
+      !!       where rvor is the relative vorticity
       !!
       !! ** Action : - Update (ua,va) with the now vorticity term trend
@@ -213,5 +212,4 @@
       !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
       !!----------------------------------------------------------------------
-      !
       INTEGER , INTENT(in   )                         ::   kt     ! ocean time-step index
       INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ;
@@ -220,7 +218,7 @@
       REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
       !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zx1, zy1, zfact2, zx2, zy2   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zwz
+      INTEGER  ::   ji, jj, jk           ! dummy loop indices
+      REAL(wp) ::   zx1, zy1, zx2, zy2   ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zwx, zwy, zwz   ! 2D workspace
       !!----------------------------------------------------------------------
       !
@@ -234,37 +232,55 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
       ENDIF
-
-      zfact2 = 0.5 * 0.5      ! Local constant initialization
-
-!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz )
+      !
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
          !                                             ! ===============
          !
-         ! Potential vorticity and horizontal fluxes
-         ! -----------------------------------------
-         SELECT CASE( kvor )      ! vorticity considered
-         CASE ( 1 )   ;   zwz(:,:) =                  ff(:,:)      ! planetary vorticity (Coriolis)
-         CASE ( 2 )   ;   zwz(:,:) =   rotn(:,:,jk)                ! relative  vorticity
-         CASE ( 3 )                                                ! metric term
+         SELECT CASE( kvor )                 !==  vorticity considered  ==!
+         CASE ( np_COR )                           !* Coriolis (planetary vorticity)
+            zwz(:,:) = ff(:,:) 
+         CASE ( np_RVO )                           !* relative vorticity
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                     &          - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_MET )                           !* metric term
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
                   zwz(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
                        &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                       &     * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )
-               END DO
-            END DO
-         CASE ( 4 )   ;   zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) )    ! total (relative + planetary vorticity)
-         CASE ( 5 )                                                ! total (coriolis + metric)
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ( ff (ji,jj)                                                                       &
-                       &       + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
-                       &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                       &       * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )                                               &
-                       &       )
-               END DO
-            END DO
+                       &     * 0.5 * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_CRV )                           !* Coriolis + relative vorticity
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ff(ji,jj) + (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                     &                      - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
+                     &                   * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_CME )                           !* Coriolis + metric
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ff(ji,jj)                                                                        &
+                       &     + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &     * 0.5 * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE DEFAULT                                             ! error
+            CALL ctl_stop('STOP','dyn_vor: wrong value for kvor'  )
          END SELECT
+         !
+         IF( ln_dynvor_msk ) THEN          !==  mask/unmask vorticity ==!
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
 
          IF( ln_sco ) THEN
@@ -276,7 +292,5 @@
             zwy(:,:) = e1v(:,:) * vn(:,:,jk)
          ENDIF
-
-         ! Compute and add the vorticity term trend
-         ! ----------------------------------------
+         !                                   !==  compute and add the vorticity term trend  =!
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -285,6 +299,6 @@
                zx1 = zwx(ji-1,jj) + zwx(ji-1,jj+1)
                zx2 = zwx(ji  ,jj) + zwx(ji  ,jj+1)
-               pua(ji,jj,jk) = pua(ji,jj,jk) + zfact2 / e1u(ji,jj) * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
-               pva(ji,jj,jk) = pva(ji,jj,jk) - zfact2 / e2v(ji,jj) * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 ) 
+               pua(ji,jj,jk) = pua(ji,jj,jk) + r1_4 * r1_e1u(ji,jj) * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
+               pva(ji,jj,jk) = pva(ji,jj,jk) - r1_4 * r1_e2v(ji,jj) * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 ) 
             END DO  
          END DO  
@@ -299,123 +313,4 @@
 
 
-   SUBROUTINE vor_mix( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE vor_mix  ***
-      !!
-      !! ** Purpose :   Compute the now total vorticity trend and add it to
-      !!      the general trend of the momentum equation.
-      !!
-      !! ** Method  :   Trend evaluated using now fields (centered in time)
-      !!      Mixte formulation : conserves the potential enstrophy of a hori-
-      !!      zontally non-divergent flow for (rotzu x uh), the relative vor-
-      !!      ticity term and the horizontal kinetic energy for (f x uh), the
-      !!      coriolis term. the now trend of the vorticity term is given by:
-      !!       * s-coordinate (ln_sco=T), the e3. are inside the derivatives:
-      !!          voru = 1/e1u  mj-1(rotn/e3f) mj-1[ mi(e1v*e3v vn) ]
-      !!              +1/e1u  mj-1[ f/e3f          mi(e1v*e3v vn) ]
-      !!          vorv = 1/e2v  mi-1(rotn/e3f) mi-1[ mj(e2u*e3u un) ]
-      !!              +1/e2v  mi-1[ f/e3f          mj(e2u*e3u un) ]
-      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
-      !!          voru = 1/e1u  mj-1(rotn) mj-1[ mi(e1v vn) ]
-      !!              +1/e1u  mj-1[ f          mi(e1v vn) ]
-      !!          vorv = 1/e2v  mi-1(rotn) mi-1[ mj(e2u un) ]
-      !!              +1/e2v  mi-1[ f          mj(e2u un) ]
-      !!      Add this now trend to the general momentum trend (ua,va):
-      !!          (ua,va) = (ua,va) + ( voru , vorv )
-      !!
-      !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
-      !!
-      !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
-      !!----------------------------------------------------------------------
-      !
-      INTEGER, INTENT(in) ::   kt   ! ocean timestep index
-      !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zfact1, zua, zcua, zx1, zy1   ! local scalars
-      REAL(wp) ::   zfact2, zva, zcva, zx2, zy2   !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zwz, zww
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('vor_mix')
-      !
-      CALL wrk_alloc( jpi, jpj, zwx, zwy, zwz, zww ) 
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'dyn:vor_mix : vorticity term: mixed energy/enstrophy conserving scheme'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-      ENDIF
-
-      zfact1 = 0.5 * 0.25      ! Local constant initialization
-      zfact2 = 0.5 * 0.5
-
-!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz, zww )
-      !                                                ! ===============
-      DO jk = 1, jpkm1                                 ! Horizontal slab
-         !                                             ! ===============
-         !
-         ! Relative and planetary potential vorticity and horizontal fluxes
-         ! ----------------------------------------------------------------
-         IF( ln_sco ) THEN        
-            IF( ln_dynadv_vec ) THEN
-               zww(:,:) = rotn(:,:,jk) / fse3f(:,:,jk)
-            ELSE                       
-               DO jj = 1, jpjm1
-                  DO ji = 1, fs_jpim1   ! vector opt.
-                     zww(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
-                        &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                        &       * 0.5 / ( e1f(ji,jj) * e2f (ji,jj) * fse3f(ji,jj,jk) )
-                  END DO
-               END DO
-            ENDIF
-            zwz(:,:) = ff  (:,:)    / fse3f(:,:,jk)
-            zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
-            zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
-         ELSE
-            IF( ln_dynadv_vec ) THEN
-               zww(:,:) = rotn(:,:,jk)
-            ELSE                       
-               DO jj = 1, jpjm1
-                  DO ji = 1, fs_jpim1   ! vector opt.
-                     zww(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
-                        &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                        &       * 0.5 / ( e1f(ji,jj) * e2f (ji,jj) )
-                  END DO
-               END DO
-            ENDIF
-            zwz(:,:) = ff (:,:)
-            zwx(:,:) = e2u(:,:) * un(:,:,jk)
-            zwy(:,:) = e1v(:,:) * vn(:,:,jk)
-         ENDIF
-
-         ! Compute and add the vorticity term trend
-         ! ----------------------------------------
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zy1 = ( zwy(ji,jj-1) + zwy(ji+1,jj-1) ) / e1u(ji,jj)
-               zy2 = ( zwy(ji,jj  ) + zwy(ji+1,jj  ) ) / e1u(ji,jj)
-               zx1 = ( zwx(ji-1,jj) + zwx(ji-1,jj+1) ) / e2v(ji,jj)
-               zx2 = ( zwx(ji  ,jj) + zwx(ji  ,jj+1) ) / e2v(ji,jj)
-               ! enstrophy conserving formulation for relative vorticity term
-               zua = zfact1 * ( zww(ji  ,jj-1) + zww(ji,jj) ) * ( zy1 + zy2 )
-               zva =-zfact1 * ( zww(ji-1,jj  ) + zww(ji,jj) ) * ( zx1 + zx2 )
-               ! energy conserving formulation for planetary vorticity term
-               zcua = zfact2 * ( zwz(ji  ,jj-1) * zy1 + zwz(ji,jj) * zy2 )
-               zcva =-zfact2 * ( zwz(ji-1,jj  ) * zx1 + zwz(ji,jj) * zx2 )
-               ! mixed vorticity trend added to the momentum trends
-               ua(ji,jj,jk) = ua(ji,jj,jk) + zcua + zua
-               va(ji,jj,jk) = va(ji,jj,jk) + zcva + zva
-            END DO  
-         END DO  
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-      CALL wrk_dealloc( jpi, jpj, zwx, zwy, zwz, zww ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('vor_mix')
-      !
-   END SUBROUTINE vor_mix
-
-
    SUBROUTINE vor_ens( kt, kvor, pua, pva )
       !!----------------------------------------------------------------------
@@ -429,10 +324,6 @@
       !!      potential enstrophy of a horizontally non-divergent flow. the
       !!      trend of the vorticity term is given by:
-      !!       * s-coordinate (ln_sco=T), the e3. are inside the derivative:
-      !!          voru = 1/e1u  mj-1[ (rotn+f)/e3f ]  mj-1[ mi(e1v*e3v vn) ]
-      !!          vorv = 1/e2v  mi-1[ (rotn+f)/e3f ]  mi-1[ mj(e2u*e3u un) ]
-      !!       * z-coordinate (default key), e3t=e3u=e3v, the trend becomes:
-      !!          voru = 1/e1u  mj-1[ rotn+f ]  mj-1[ mi(e1v vn) ]
-      !!          vorv = 1/e2v  mi-1[ rotn+f ]  mi-1[ mj(e2u un) ]
+      !!          voru = 1/e1u  mj-1[ (rvor+f)/e3f ]  mj-1[ mi(e1v*e3v vn) ]
+      !!          vorv = 1/e2v  mi-1[ (rvor+f)/e3f ]  mi-1[ mj(e2u*e3u un) ]
       !!      Add this trend to the general momentum trend (ua,va):
       !!          (ua,va) = (ua,va) + ( voru , vorv )
@@ -442,5 +333,4 @@
       !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
       !!----------------------------------------------------------------------
-      !
       INTEGER , INTENT(in   )                         ::   kt     ! ocean time-step index
       INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ;
@@ -449,7 +339,7 @@
       REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
       !
-      INTEGER  ::   ji, jj, jk           ! dummy loop indices
-      REAL(wp) ::   zfact1, zuav, zvau   ! temporary scalars
-      REAL(wp), POINTER, DIMENSION(:,:) :: zwx, zwy, zwz, zww
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zuav, zvau   ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:) ::   zwx, zwy, zwz, zww   ! 2D workspace
       !!----------------------------------------------------------------------
       !
@@ -463,63 +353,70 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
       ENDIF
-
-      zfact1 = 0.5 * 0.25      ! Local constant initialization
-
-!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz )
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
          !                                             ! ===============
          !
-         ! Potential vorticity and horizontal fluxes
-         ! -----------------------------------------
-         SELECT CASE( kvor )      ! vorticity considered
-         CASE ( 1 )   ;   zwz(:,:) =                  ff(:,:)      ! planetary vorticity (Coriolis)
-         CASE ( 2 )   ;   zwz(:,:) =   rotn(:,:,jk)                ! relative  vorticity
-         CASE ( 3 )                                                ! metric term
+         SELECT CASE( kvor )                 !==  vorticity considered  ==!
+         CASE ( np_COR )                           !* Coriolis (planetary vorticity)
+            zwz(:,:) = ff(:,:) 
+         CASE ( np_RVO )                           !* relative vorticity
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                     &          - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_MET )                           !* metric term
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
                   zwz(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
                        &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                       &     * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )
-               END DO
-            END DO
-         CASE ( 4 )   ;   zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) )    ! total (relative + planetary vorticity)
-         CASE ( 5 )                                                ! total (coriolis + metric)
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ( ff (ji,jj)                                                                       &
-                       &       + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
-                       &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                       &       * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )                                                &
-                       &       )
-               END DO
-            END DO
+                       &     * 0.5 * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_CRV )                           !* Coriolis + relative vorticity
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ff(ji,jj) + (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                     &                      - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
+                     &                   * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_CME )                           !* Coriolis + metric
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ff(ji,jj)                                                                       &
+                       &     + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &     * 0.5 * r1_e1e2f(ji,jj)
+               END DO
+            END DO
+         CASE DEFAULT                                             ! error
+            CALL ctl_stop('STOP','dyn_vor: wrong value for kvor'  )
          END SELECT
          !
-         IF( ln_sco ) THEN
-            DO jj = 1, jpj                      ! caution: don't use (:,:) for this loop 
-               DO ji = 1, jpi                   ! it causes optimization problems on NEC in auto-tasking
-                  zwz(ji,jj) = zwz(ji,jj) / fse3f(ji,jj,jk)
-                  zwx(ji,jj) = e2u(ji,jj) * fse3u(ji,jj,jk) * un(ji,jj,jk)
-                  zwy(ji,jj) = e1v(ji,jj) * fse3v(ji,jj,jk) * vn(ji,jj,jk)
-               END DO
-            END DO
+         IF( ln_dynvor_msk ) THEN           !==  mask/unmask vorticity ==!
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+         !
+         IF( ln_sco ) THEN                   !==  horizontal fluxes  ==!
+            zwz(:,:) = zwz(:,:) / fse3f(:,:,jk)
+            zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
+            zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
          ELSE
-            DO jj = 1, jpj                      ! caution: don't use (:,:) for this loop 
-               DO ji = 1, jpi                   ! it causes optimization problems on NEC in auto-tasking
-                  zwx(ji,jj) = e2u(ji,jj) * un(ji,jj,jk)
-                  zwy(ji,jj) = e1v(ji,jj) * vn(ji,jj,jk)
-               END DO
-            END DO
-         ENDIF
-         !
-         ! Compute and add the vorticity term trend
-         ! ----------------------------------------
+            zwx(:,:) = e2u(:,:) * un(:,:,jk)
+            zwy(:,:) = e1v(:,:) * vn(:,:,jk)
+         ENDIF
+         !                                   !==  compute and add the vorticity term trend  =!
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zuav = zfact1 / e1u(ji,jj) * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1)   &
-                  &                         + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) )
-               zvau =-zfact1 / e2v(ji,jj) * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1)   &
-                  &                         + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) )
+               zuav = r1_8 * r1_e1u(ji,jj) * ( zwy(ji  ,jj-1) + zwy(ji+1,jj-1)   &
+                  &                       + zwy(ji  ,jj  ) + zwy(ji+1,jj  ) )
+               zvau =-r1_8 * r1_e2v(ji,jj) * ( zwx(ji-1,jj  ) + zwx(ji-1,jj+1)   &
+                  &                       + zwx(ji  ,jj  ) + zwx(ji  ,jj+1) )
                pua(ji,jj,jk) = pua(ji,jj,jk) + zuav * ( zwz(ji  ,jj-1) + zwz(ji,jj) )
                pva(ji,jj,jk) = pva(ji,jj,jk) + zvau * ( zwz(ji-1,jj  ) + zwz(ji,jj) )
@@ -553,32 +450,22 @@
       !! References : Arakawa and Lamb 1980, Mon. Wea. Rev., 109, 18-36
       !!----------------------------------------------------------------------
-      !
       INTEGER , INTENT(in   )                         ::   kt     ! ocean time-step index
-      INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ;
-      !                                                           ! =nrvm (relative vorticity or metric)
+      INTEGER , INTENT(in   )                         ::   kvor   ! =ncor (planetary) ; =ntot (total) ; =nrvm (relative or metric)
       REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pua    ! total u-trend
       REAL(wp), INTENT(inout), DIMENSION(jpi,jpj,jpk) ::   pva    ! total v-trend
-      !!
-      INTEGER  ::   ji, jj, jk                                    ! dummy loop indices
-      INTEGER  ::   ierr                                          ! local integer
-      REAL(wp) ::   zfac12, zua, zva                              ! local scalars
-      REAL(wp) ::   zmsk, ze3                                     ! local scalars
-      !                                                           !  3D workspace 
-      REAL(wp), POINTER    , DIMENSION(:,:  )         :: zwx, zwy, zwz
-      REAL(wp), POINTER    , DIMENSION(:,:  )         :: ztnw, ztne, ztsw, ztse
-#if defined key_vvl
-      REAL(wp), POINTER    , DIMENSION(:,:,:)         :: ze3f     !  3D workspace (lk_vvl=T)
-#else
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:), SAVE   :: ze3f     ! lk_vvl=F, ze3f=1/e3f saved one for all
-#endif
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ierr         ! local integer
+      REAL(wp) ::   zua, zva     ! local scalars
+      REAL(wp) ::   zmsk, ze3    ! local scalars
+      !
+      REAL(wp), POINTER, DIMENSION(:,:)   :: zwx, zwy, zwz, z1_e3f
+      REAL(wp), POINTER, DIMENSION(:,:)   :: ztnw, ztne, ztsw, ztse
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('vor_een')
       !
-      CALL wrk_alloc( jpi, jpj,      zwx , zwy , zwz        ) 
-      CALL wrk_alloc( jpi, jpj,      ztnw, ztne, ztsw, ztse ) 
-#if defined key_vvl
-      CALL wrk_alloc( jpi, jpj, jpk, ze3f                   )
-#endif
+      CALL wrk_alloc( jpi,jpj,   zwx , zwy , zwz , z1_e3f ) 
+      CALL wrk_alloc( jpi,jpj,   ztnw, ztne, ztsw, ztse   ) 
       !
       IF( kt == nit000 ) THEN
@@ -586,90 +473,97 @@
          IF(lwp) WRITE(numout,*) 'dyn:vor_een : vorticity term: energy and enstrophy conserving scheme'
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-#if ! defined key_vvl
-         IF( .NOT.ALLOCATED(ze3f) ) THEN
-            ALLOCATE( ze3f(jpi,jpj,jpk) , STAT=ierr )
-            IF( lk_mpp    )   CALL mpp_sum ( ierr )
-            IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'dyn:vor_een : unable to allocate arrays' )
-         ENDIF
-         ze3f(:,:,:) = 0._wp
-#endif
       ENDIF
-
-      IF( kt == nit000 .OR. lk_vvl ) THEN      ! reciprocal of e3 at F-point (masked averaging of e3t over ocean points)
-
-         IF( ln_dynvor_een_old ) THEN ! original formulation
-            DO jk = 1, jpk
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
-                        &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
-                     IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = 4.0_wp / ze3
-                  END DO
-               END DO
-            END DO
-         ELSE ! new formulation from NEMO 3.6
-            DO jk = 1, jpk
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
-                        &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
-                     zmsk = (                   tmask(ji,jj+1,jk) +                     tmask(ji+1,jj+1,jk)   &
-                        &                     + tmask(ji,jj  ,jk) +                     tmask(ji+1,jj  ,jk) )
-                     IF( ze3 /= 0._wp )   ze3f(ji,jj,jk) = zmsk / ze3
-                  END DO
-               END DO
-            END DO
-         ENDIF
-
-         CALL lbc_lnk( ze3f, 'F', 1. )
-      ENDIF
-
-      zfac12 = 1._wp / 12._wp    ! Local constant initialization
-
-      
-!CDIR PARALLEL DO PRIVATE( zwx, zwy, zwz, ztnw, ztne, ztsw, ztse )
+      !
       !                                                ! ===============
       DO jk = 1, jpkm1                                 ! Horizontal slab
          !                                             ! ===============
-         
-         ! Potential vorticity and horizontal fluxes
-         ! -----------------------------------------
-         SELECT CASE( kvor )      ! vorticity considered
-         CASE ( 1 )                                                ! planetary vorticity (Coriolis)
-            zwz(:,:) = ff(:,:)      * ze3f(:,:,jk)
-         CASE ( 2 )                                                ! relative  vorticity
-            zwz(:,:) = rotn(:,:,jk) * ze3f(:,:,jk)
-         CASE ( 3 )                                                ! metric term
+         !
+         SELECT CASE( nn_een_e3f )           ! == reciprocal of e3 at F-point
+         CASE ( 0 )                                   ! original formulation  (masked averaging of e3t divided by 4)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
+                     &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
+                  IF( ze3 /= 0._wp ) THEN   ;   z1_e3f(ji,jj) = 4.0_wp / ze3
+                  ELSE                      ;   z1_e3f(ji,jj) = 0.0_wp
+                  ENDIF
+               END DO
+            END DO
+         CASE ( 1 )                                   ! new formulation  (masked averaging of e3t divided by the sum of mask)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ze3  = ( fse3t(ji,jj+1,jk)*tmask(ji,jj+1,jk) + fse3t(ji+1,jj+1,jk)*tmask(ji+1,jj+1,jk)   &
+                     &   + fse3t(ji,jj  ,jk)*tmask(ji,jj  ,jk) + fse3t(ji+1,jj  ,jk)*tmask(ji+1,jj  ,jk) )
+                  zmsk = (                   tmask(ji,jj+1,jk) +                     tmask(ji+1,jj+1,jk)   &
+                     &                     + tmask(ji,jj  ,jk) +                     tmask(ji+1,jj  ,jk) )
+                  IF( ze3 /= 0._wp ) THEN   ;   z1_e3f(ji,jj) = zmsk / ze3
+                  ELSE                      ;   z1_e3f(ji,jj) = 0.0_wp
+                  ENDIF
+               END DO
+            END DO
+         END SELECT
+         !
+         SELECT CASE( kvor )                 !==  vorticity considered  ==!
+         CASE ( np_COR )                           !* Coriolis (planetary vorticity)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = ff(ji,jj) * z1_e3f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_RVO )                           !* relative vorticity
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                     &          - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
+                     &       * r1_e1e2f(ji,jj) * z1_e3f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_MET )                           !* metric term
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
                   zwz(ji,jj) = (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
                        &         - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                       &     * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) ) * ze3f(ji,jj,jk)
-               END DO
-            END DO
-            CALL lbc_lnk( zwz, 'F', 1. )
-        CASE ( 4 )                                                ! total (relative + planetary vorticity)
-            zwz(:,:) = ( rotn(:,:,jk) + ff(:,:) ) * ze3f(:,:,jk)
-         CASE ( 5 )                                                ! total (coriolis + metric)
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwz(ji,jj) = ( ff (ji,jj)                                                                       &
-                       &       + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
-                       &           - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
-                       &       * 0.5 / ( e1f(ji,jj) * e2f(ji,jj) )                                                &
-                       &       ) * ze3f(ji,jj,jk)
-               END DO
-            END DO
-            CALL lbc_lnk( zwz, 'F', 1. )
+                       &     * 0.5 * r1_e1e2f(ji,jj) * z1_e3f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_CRV )                           !* Coriolis + relative vorticity
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (  ff(ji,jj) + (  e2v(ji+1,jj  ) * vn(ji+1,jj  ,jk) - e2v(ji,jj) * vn(ji,jj,jk)    &
+                     &                         - e1u(ji  ,jj+1) * un(ji  ,jj+1,jk) + e1u(ji,jj) * un(ji,jj,jk)  ) &
+                     &                      * r1_e1e2f(ji,jj)    ) * z1_e3f(ji,jj)
+               END DO
+            END DO
+         CASE ( np_CME )                           !* Coriolis + metric
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = (  ff(ji,jj)                                                                        &
+                       &        + (   ( vn(ji+1,jj  ,jk) + vn (ji,jj,jk) ) * ( e2v(ji+1,jj  ) - e2v(ji,jj) )       &
+                       &            - ( un(ji  ,jj+1,jk) + un (ji,jj,jk) ) * ( e1u(ji  ,jj+1) - e1u(ji,jj) )   )   &
+                       &        * 0.5 * r1_e1e2f(ji,jj)   ) * z1_e3f(ji,jj)
+               END DO
+            END DO
+         CASE DEFAULT                                             ! error
+            CALL ctl_stop('STOP','dyn_vor: wrong value for kvor'  )
          END SELECT
-
+         !
+         IF( ln_dynvor_msk ) THEN          !==  mask/unmask vorticity ==!
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwz(ji,jj) = zwz(ji,jj) * fmask(ji,jj,jk)
+               END DO
+            END DO
+         ENDIF
+         !
+         CALL lbc_lnk( zwz, 'F', 1. )
+         !
+         !                                   !==  horizontal fluxes  ==!
          zwx(:,:) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)
          zwy(:,:) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
 
-         ! Compute and add the vorticity term trend
-         ! ----------------------------------------
+         !                                   !==  compute and add the vorticity term trend  =!
          jj = 2
          ztne(1,:) = 0   ;   ztnw(1,:) = 0   ;   ztse(1,:) = 0   ;   ztsw(1,:) = 0
-         DO ji = 2, jpi   
+         DO ji = 2, jpi          ! split in 2 parts due to vector opt.
                ztne(ji,jj) = zwz(ji-1,jj  ) + zwz(ji  ,jj  ) + zwz(ji  ,jj-1)
                ztnw(ji,jj) = zwz(ji-1,jj-1) + zwz(ji-1,jj  ) + zwz(ji  ,jj  )
@@ -687,8 +581,8 @@
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               zua = + zfac12 / e1u(ji,jj) * (  ztne(ji,jj  ) * zwy(ji  ,jj  ) + ztnw(ji+1,jj) * zwy(ji+1,jj  )   &
-                  &                           + ztse(ji,jj  ) * zwy(ji  ,jj-1) + ztsw(ji+1,jj) * zwy(ji+1,jj-1) )
-               zva = - zfac12 / e2v(ji,jj) * (  ztsw(ji,jj+1) * zwx(ji-1,jj+1) + ztse(ji,jj+1) * zwx(ji  ,jj+1)   &
-                  &                           + ztnw(ji,jj  ) * zwx(ji-1,jj  ) + ztne(ji,jj  ) * zwx(ji  ,jj  ) )
+               zua = + r1_12 * r1_e1u(ji,jj) * (  ztne(ji,jj  ) * zwy(ji  ,jj  ) + ztnw(ji+1,jj) * zwy(ji+1,jj  )   &
+                  &                             + ztse(ji,jj  ) * zwy(ji  ,jj-1) + ztsw(ji+1,jj) * zwy(ji+1,jj-1) )
+               zva = - r1_12 * r1_e2v(ji,jj) * (  ztsw(ji,jj+1) * zwx(ji-1,jj+1) + ztse(ji,jj+1) * zwx(ji  ,jj+1)   &
+                  &                             + ztnw(ji,jj  ) * zwx(ji-1,jj  ) + ztne(ji,jj  ) * zwx(ji  ,jj  ) )
                pua(ji,jj,jk) = pua(ji,jj,jk) + zua
                pva(ji,jj,jk) = pva(ji,jj,jk) + zva
@@ -698,9 +592,7 @@
       END DO                                           !   End of slab
       !                                                ! ===============
-      CALL wrk_dealloc( jpi, jpj,      zwx , zwy , zwz        ) 
-      CALL wrk_dealloc( jpi, jpj,      ztnw, ztne, ztsw, ztse ) 
-#if defined key_vvl
-      CALL wrk_dealloc( jpi, jpj, jpk, ze3f                   )
-#endif
+      !
+      CALL wrk_dealloc( jpi,jpj,   zwx , zwy , zwz , z1_e3f ) 
+      CALL wrk_dealloc( jpi,jpj,   ztnw, ztne, ztsw, ztse   ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('vor_een')
@@ -720,5 +612,5 @@
       INTEGER ::   ios             ! Local integer output status for namelist read
       !!
-      NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een, ln_dynvor_een_old
+      NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een, nn_een_e3f, ln_dynvor_msk
       !!----------------------------------------------------------------------
 
@@ -737,13 +629,17 @@
          WRITE(numout,*) '~~~~~~~~~~~~'
          WRITE(numout,*) '        Namelist namdyn_vor : choice of the vorticity term scheme'
-         WRITE(numout,*) '           energy    conserving scheme                ln_dynvor_ene = ', ln_dynvor_ene
-         WRITE(numout,*) '           enstrophy conserving scheme                ln_dynvor_ens = ', ln_dynvor_ens
-         WRITE(numout,*) '           mixed enstrophy/energy conserving scheme   ln_dynvor_mix = ', ln_dynvor_mix
-         WRITE(numout,*) '           enstrophy and energy conserving scheme     ln_dynvor_een = ', ln_dynvor_een
-         WRITE(numout,*) '           enstrophy and energy conserving scheme (old) ln_dynvor_een_old= ', ln_dynvor_een_old
+         WRITE(numout,*) '           energy    conserving scheme                    ln_dynvor_ene = ', ln_dynvor_ene
+         WRITE(numout,*) '           enstrophy conserving scheme                    ln_dynvor_ens = ', ln_dynvor_ens
+         WRITE(numout,*) '           mixed enstrophy/energy conserving scheme       ln_dynvor_mix = ', ln_dynvor_mix
+         WRITE(numout,*) '           enstrophy and energy conserving scheme         ln_dynvor_een = ', ln_dynvor_een
+         WRITE(numout,*) '              e3f = averaging /4 (=0) or /sum(tmask) (=1)    nn_een_e3f = ', nn_een_e3f
+         WRITE(numout,*) '           masked (=1) or unmasked(=0) vorticity          ln_dynvor_msk = ', ln_dynvor_msk
       ENDIF
 
+!!gm  this should be removed when choosing a unique strategy for fmask at the coast
       ! If energy, enstrophy or mixed advection of momentum in vector form change the value for masks
       ! at angles with three ocean points and one land point
+      IF(lwp) WRITE(numout,*)
+      IF(lwp) WRITE(numout,*) '           namlbc: change fmask value in the angles (T)   ln_vorlat = ', ln_vorlat
       IF( ln_vorlat .AND. ( ln_dynvor_ene .OR. ln_dynvor_ens .OR. ln_dynvor_mix ) ) THEN
          DO jk = 1, jpk
@@ -759,42 +655,32 @@
           !
       ENDIF
-
-      ioptio = 0                     ! Control of vorticity scheme options
-      IF( ln_dynvor_ene )   ioptio = ioptio + 1
-      IF( ln_dynvor_ens )   ioptio = ioptio + 1
-      IF( ln_dynvor_mix )   ioptio = ioptio + 1
-      IF( ln_dynvor_een )   ioptio = ioptio + 1
-      IF( ln_dynvor_een_old )   ioptio = ioptio + 1
-      IF( lk_esopa      )   ioptio =          1
-
-      IF( ioptio /= 1 ) CALL ctl_stop( ' use ONE and ONLY one vorticity scheme' )
-
-      !                              ! Set nvor (type of scheme for vorticity)
-      IF( ln_dynvor_ene )   nvor =  0
-      IF( ln_dynvor_ens )   nvor =  1
-      IF( ln_dynvor_mix )   nvor =  2
-      IF( ln_dynvor_een .or. ln_dynvor_een_old )   nvor =  3
-      IF( lk_esopa      )   nvor = -1
-      
-      !                              ! Set ncor, nrvm, ntot (type of vorticity)
-      IF(lwp) WRITE(numout,*)
-      ncor = 1
+!!gm end
+
+      ioptio = 0                     ! type of scheme for vorticity (set nvor_scheme)
+      IF( ln_dynvor_ene ) THEN   ;   ioptio = ioptio + 1   ;    nvor_scheme = np_ENE   ;   ENDIF
+      IF( ln_dynvor_ens ) THEN   ;   ioptio = ioptio + 1   ;    nvor_scheme = np_ENS   ;   ENDIF
+      IF( ln_dynvor_mix ) THEN   ;   ioptio = ioptio + 1   ;    nvor_scheme = np_MIX   ;   ENDIF
+      IF( ln_dynvor_een ) THEN   ;   ioptio = ioptio + 1   ;    nvor_scheme = np_EEN   ;   ENDIF
+      !
+      IF( ( ioptio /= 1).AND.( .NOT.lk_c1d ) ) CALL ctl_stop( ' use ONE and ONLY one vorticity scheme' )
+      !                      
+      IF(lwp) WRITE(numout,*)        ! type of calculated vorticity (set ncor, nrvm, ntot)
+      ncor = np_COR
       IF( ln_dynadv_vec ) THEN     
          IF(lwp) WRITE(numout,*) '         Vector form advection : vorticity = Coriolis + relative vorticity'
-         nrvm = 2
-         ntot = 4
+         nrvm = np_RVO        ! relative vorticity
+         ntot = np_CRV        ! relative + planetary vorticity
       ELSE                        
          IF(lwp) WRITE(numout,*) '         Flux form advection   : vorticity = Coriolis + metric term'
-         nrvm = 3
-         ntot = 5
+         nrvm = np_MET        ! metric term
+         ntot = np_CME        ! Coriolis + metric term
       ENDIF
       
       IF(lwp) THEN                   ! Print the choice
          WRITE(numout,*)
-         IF( nvor ==  0 )   WRITE(numout,*) '         vorticity scheme : energy conserving scheme'
-         IF( nvor ==  1 )   WRITE(numout,*) '         vorticity scheme : enstrophy conserving scheme'
-         IF( nvor ==  2 )   WRITE(numout,*) '         vorticity scheme : mixed enstrophy/energy conserving scheme'
-         IF( nvor ==  3 )   WRITE(numout,*) '         vorticity scheme : energy and enstrophy conserving scheme'
-         IF( nvor == -1 )   WRITE(numout,*) '         esopa test: use all lateral physics options'
+         IF( nvor_scheme ==  np_ENE )   WRITE(numout,*) '         vorticity scheme ==>> energy conserving scheme'
+         IF( nvor_scheme ==  np_ENS )   WRITE(numout,*) '         vorticity scheme ==>> enstrophy conserving scheme'
+         IF( nvor_scheme ==  np_MIX )   WRITE(numout,*) '         vorticity scheme ==>> mixed enstrophy/energy conserving scheme'
+         IF( nvor_scheme ==  np_EEN )   WRITE(numout,*) '         vorticity scheme ==>> energy and enstrophy conserving scheme'
       ENDIF
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzad.F90	(revision 6041)
@@ -49,6 +49,6 @@
       !!
       !! ** Method  :   The now vertical advection of momentum is given by:
-      !!         w dz(u) = ua + 1/(e1u*e2u*e3u) mk+1[ mi(e1t*e2t*wn) dk(un) ]
-      !!         w dz(v) = va + 1/(e1v*e2v*e3v) mk+1[ mj(e1t*e2t*wn) dk(vn) ]
+      !!         w dz(u) = ua + 1/(e1e2u*e3u) mk+1[ mi(e1e2t*wn) dk(un) ]
+      !!         w dz(v) = va + 1/(e1e2v*e3v) mk+1[ mj(e1e2t*wn) dk(vn) ]
       !!      Add this trend to the general trend (ua,va):
       !!         (ua,va) = (ua,va) + w dz(u,v)
@@ -85,5 +85,5 @@
          DO jj = 2, jpj                   ! vertical fluxes 
             DO ji = fs_2, jpi             ! vector opt.
-               zww(ji,jj) = 0.25_wp * e1t(ji,jj) * e2t(ji,jj) * wn(ji,jj,jk)
+               zww(ji,jj) = 0.25_wp * e1e2t(ji,jj) * wn(ji,jj,jk)
             END DO
          END DO
@@ -121,6 +121,6 @@
             DO ji = fs_2, fs_jpim1       ! vector opt.
                !                         ! vertical momentum advective trends
-               zua = - ( zwuw(ji,jj,jk) + zwuw(ji,jj,jk+1) ) / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
-               zva = - ( zwvw(ji,jj,jk) + zwvw(ji,jj,jk+1) ) / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+               zua = - ( zwuw(ji,jj,jk) + zwuw(ji,jj,jk+1) ) / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
+               zva = - ( zwvw(ji,jj,jk) + zwvw(ji,jj,jk+1) ) / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
                !                         ! add the trends to the general momentum trends
                ua(ji,jj,jk) = ua(ji,jj,jk) + zua
@@ -146,4 +146,5 @@
       !
    END SUBROUTINE dyn_zad
+
 
    SUBROUTINE dyn_zad_zts ( kt )
@@ -182,6 +183,6 @@
       IF( nn_timing == 1 )  CALL timing_start('dyn_zad_zts')
       !
-      CALL wrk_alloc( jpi,jpj,jpk, zwuw , zwvw, zww ) 
-      CALL wrk_alloc( jpi,jpj,jpk,3, zus, zvs ) 
+      CALL wrk_alloc( jpi,jpj,jpk,     zwuw, zwvw, zww ) 
+      CALL wrk_alloc( jpi,jpj,jpk,3,   zus , zvs ) 
       !
       IF( kt == nit000 ) THEN
@@ -205,12 +206,12 @@
          DO jj = 2, jpj                   
             DO ji = fs_2, jpi             ! vector opt.
-               zww(ji,jj,jk) = 0.25_wp * e1t(ji,jj) * e2t(ji,jj) * wn(ji,jj,jk)
+               zww(ji,jj,jk) = 0.25_wp * e1e2t(ji,jj) * wn(ji,jj,jk)
             END DO
          END DO
       END DO
-      !
-      ! Surface and bottom advective fluxes set to zero
-      DO jj = 2, jpjm1        
+
+      DO jj = 2, jpjm1                    ! Surface and bottom advective fluxes set to zero
          DO ji = fs_2, fs_jpim1           ! vector opt.
+ !!gm missing ISF boundary condition
             zwuw(ji,jj, 1 ) = 0._wp
             zwvw(ji,jj, 1 ) = 0._wp
@@ -251,6 +252,6 @@
                DO ji = fs_2, fs_jpim1       ! vector opt.
                   !                         ! vertical momentum advective trends
-                  zua = - ( zwuw(ji,jj,jk) + zwuw(ji,jj,jk+1) ) / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
-                  zva = - ( zwvw(ji,jj,jk) + zwvw(ji,jj,jk+1) ) / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
+                  zua = - ( zwuw(ji,jj,jk) + zwuw(ji,jj,jk+1) ) / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
+                  zva = - ( zwvw(ji,jj,jk) + zwvw(ji,jj,jk+1) ) / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
                   zus(ji,jj,jk,jta) = zus(ji,jj,jk,jtb) + zua * zts
                   zvs(ji,jj,jk,jta) = zvs(ji,jj,jk,jtb) + zva * zts
@@ -283,6 +284,6 @@
          &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       !
-      CALL wrk_dealloc( jpi,jpj,jpk, zwuw , zwvw, zww ) 
-      CALL wrk_dealloc( jpi,jpj,jpk,3, zus, zvs ) 
+      CALL wrk_dealloc( jpi,jpj,jpk,     zwuw, zwvw, zww ) 
+      CALL wrk_dealloc( jpi,jpj,jpk,3,   zus , zvs ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('dyn_zad_zts')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf.F90	(revision 6041)
@@ -9,22 +9,21 @@
 
    !!----------------------------------------------------------------------
-   !!   dyn_zdf      : Update the momentum trend with the vertical diffusion
-   !!   dyn_zdf_init : initializations of the vertical diffusion scheme
+   !!   dyn_zdf       : Update the momentum trend with the vertical diffusion
+   !!   dyn_zdf_init  : initializations of the vertical diffusion scheme
    !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables 
-   USE zdf_oce         ! ocean vertical physics variables
-
-   USE dynzdf_exp      ! vertical diffusion: explicit (dyn_zdf_exp     routine)
-   USE dynzdf_imp      ! vertical diffusion: implicit (dyn_zdf_imp     routine)
-
-   USE ldfdyn_oce      ! ocean dynamics: lateral physics
-   USE trd_oce         ! trends: ocean variables
-   USE trddyn          ! trend manager: dynamics
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! MPP library
-   USE prtctl          ! Print control
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables 
+   USE zdf_oce        ! ocean vertical physics variables
+   USE dynzdf_exp     ! vertical diffusion: explicit (dyn_zdf_exp     routine)
+   USE dynzdf_imp     ! vertical diffusion: implicit (dyn_zdf_imp     routine)
+   USE ldfdyn         ! lateral diffusion: eddy viscosity coef.
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE prtctl         ! Print control
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
 
    IMPLICIT NONE
@@ -61,5 +60,5 @@
       !!---------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('dyn_zdf')
+      IF( nn_timing == 1 )   CALL timing_start('dyn_zdf')
       !
       !                                          ! set time step
@@ -79,11 +78,4 @@
       CASE ( 1 )   ;   CALL dyn_zdf_imp( kt, r2dt )      ! implicit scheme
       !
-      CASE ( -1 )                                        ! esopa: test all possibility with control print
-                       CALL dyn_zdf_exp( kt, r2dt )
-                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf0 - Ua: ', mask1=umask,               &
-                          &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-                       CALL dyn_zdf_imp( kt, r2dt )
-                       CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf1 - Ua: ', mask1=umask,               &
-                          &          tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
       END SELECT
 
@@ -96,7 +88,7 @@
       !                                          ! print mean trends (used for debugging)
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' zdf  - Ua: ', mask1=umask,               &
-            &                    tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('dyn_zdf')
+         &                       tab3d_2=va, clinfo2=       ' Va: ', mask2=vmask, clinfo3='dyn' )
+         !
+      IF( nn_timing == 1 )   CALL timing_stop('dyn_zdf')
       !
    END SUBROUTINE dyn_zdf
@@ -114,5 +106,4 @@
       USE zdftke
       USE zdfgls
-      USE zdfkpp
       !!----------------------------------------------------------------------
       !
@@ -123,9 +114,7 @@
       !
       ! Force implicit schemes
-      IF( lk_zdftke .OR. lk_zdfgls .OR. lk_zdfkpp )   nzdf = 1   ! TKE, GLS or KPP physics
-      IF( ln_dynldf_iso                           )   nzdf = 1   ! iso-neutral lateral physics
-      IF( ln_dynldf_hor .AND. ln_sco              )   nzdf = 1   ! horizontal lateral physics in s-coordinate
-      !
-      IF( lk_esopa )    nzdf = -1                   ! Esopa key: All schemes used
+      IF( lk_zdftke .OR. lk_zdfgls   )   nzdf = 1   ! TKE or GLS physics
+      IF( ln_dynldf_iso              )   nzdf = 1   ! iso-neutral lateral physics
+      IF( ln_dynldf_hor .AND. ln_sco )   nzdf = 1   ! horizontal lateral physics in s-coordinate
       !
       IF(lwp) THEN                                  ! Print the choice
@@ -133,5 +122,4 @@
          WRITE(numout,*) 'dyn_zdf_init : vertical dynamics physics scheme'
          WRITE(numout,*) '~~~~~~~~~~~'
-         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
          IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
          IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_exp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_exp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_exp.F90	(revision 6041)
@@ -8,4 +8,5 @@
    !!   NEMO     0.5  !  2002-08  (G. Madec)  F90: Free form and module
    !!            3.3  !  2010-04  (M. Leclair, G. Madec)  Forcing averaged over 2 time steps
+   !!            3.7  !  2015-11  (J. Chanut) output velocities instead of trends
    !!----------------------------------------------------------------------
 
@@ -18,4 +19,5 @@
    USE phycst          ! physical constants
    USE zdf_oce         ! ocean vertical physics
+   USE dynadv, ONLY: ln_dynadv_vec ! Momentum advection form
    USE sbc_oce         ! surface boundary condition: ocean
    USE lib_mpp         ! MPP library
@@ -118,4 +120,22 @@
          !
       END DO                           ! End of time splitting
+
+      ! Time step momentum here to be compliant with what is done in the implicit case
+      !
+      IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN      ! applied on velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = ( ub(:,:,jk) + p2dt * ua(:,:,jk) ) * umask(:,:,jk)
+            va(:,:,jk) = ( vb(:,:,jk) + p2dt * va(:,:,jk) ) * vmask(:,:,jk)
+         END DO
+      ELSE                                            ! applied on thickness weighted velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = (          ub(:,:,jk) * fse3u_b(:,:,jk)      &
+               &           + p2dt * ua(:,:,jk) * fse3u_n(:,:,jk)  )   &
+               &         / fse3u_a(:,:,jk) * umask(:,:,jk)
+            va(:,:,jk) = (          vb(:,:,jk) * fse3v_b(:,:,jk)      &
+               &           + p2dt * va(:,:,jk) * fse3v_n(:,:,jk)  )   &
+               &         / fse3v_a(:,:,jk) * vmask(:,:,jk)
+         END DO
+      ENDIF
       !
       CALL wrk_dealloc( jpi,jpj,jpk, zwx, zwy, zwz, zww ) 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/dynzdf_imp.F90	(revision 6041)
@@ -25,6 +25,5 @@
    USE wrk_nemo        ! Memory Allocation
    USE timing          ! Timing
-   USE dynadv          ! dynamics: vector invariant versus flux form
-   USE dynspg_oce, ONLY: lk_dynspg_ts
+   USE dynadv, ONLY: ln_dynadv_vec ! Momentum advection form
 
    IMPLICIT NONE
@@ -87,9 +86,24 @@
       ENDIF
 
-      ! 0. Local constant initialization
-      ! --------------------------------
-      z1_p2dt = 1._wp / p2dt      ! inverse of the timestep
-
-      ! 1. Apply semi-implicit bottom friction
+      ! 1. Time step dynamics
+      ! ---------------------
+
+      IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN      ! applied on velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = ( ub(:,:,jk) + p2dt * ua(:,:,jk) ) * umask(:,:,jk)
+            va(:,:,jk) = ( vb(:,:,jk) + p2dt * va(:,:,jk) ) * vmask(:,:,jk)
+         END DO
+      ELSE                                            ! applied on thickness weighted velocity
+         DO jk = 1, jpkm1
+            ua(:,:,jk) = (          ub(:,:,jk) * fse3u_b(:,:,jk)      &
+               &           + p2dt * ua(:,:,jk) * fse3u_n(:,:,jk)  )   &
+               &                               / fse3u_a(:,:,jk) * umask(:,:,jk)
+            va(:,:,jk) = (          vb(:,:,jk) * fse3v_b(:,:,jk)      &
+               &           + p2dt * va(:,:,jk) * fse3v_n(:,:,jk)  )   &
+               &                               / fse3v_a(:,:,jk) * vmask(:,:,jk)
+         END DO
+      ENDIF
+
+      ! 2. Apply semi-implicit bottom friction
       ! --------------------------------------
       ! Only needed for semi-implicit bottom friction setup. The explicit
@@ -97,5 +111,4 @@
       ! column vector of the tri-diagonal matrix equation
       !
-
       IF( ln_bfrimp ) THEN
          DO jj = 2, jpjm1
@@ -119,22 +132,9 @@
       ENDIF
 
-#if defined key_dynspg_ts
-      IF( ln_dynadv_vec .OR. .NOT. lk_vvl ) THEN      ! applied on velocity
-         DO jk = 1, jpkm1
-            ua(:,:,jk) = ( ub(:,:,jk) + p2dt * ua(:,:,jk) ) * umask(:,:,jk)
-            va(:,:,jk) = ( vb(:,:,jk) + p2dt * va(:,:,jk) ) * vmask(:,:,jk)
-         END DO
-      ELSE                                            ! applied on thickness weighted velocity
-         DO jk = 1, jpkm1
-            ua(:,:,jk) = (          ub(:,:,jk) * fse3u_b(:,:,jk)      &
-               &           + p2dt * ua(:,:,jk) * fse3u_n(:,:,jk)  )   &
-               &                               / fse3u_a(:,:,jk) * umask(:,:,jk)
-            va(:,:,jk) = (          vb(:,:,jk) * fse3v_b(:,:,jk)      &
-               &           + p2dt * va(:,:,jk) * fse3v_n(:,:,jk)  )   &
-               &                               / fse3v_a(:,:,jk) * vmask(:,:,jk)
-         END DO
-      ENDIF
-
-      IF ( ln_bfrimp .AND.lk_dynspg_ts ) THEN
+      ! With split-explicit free surface, barotropic stress is treated explicitly
+      ! Update velocities at the bottom.
+      ! J. Chanut: The bottom stress is computed considering after barotropic velocities, which does 
+      !            not lead to the effective stress seen over the whole barotropic loop. 
+      IF ( ln_bfrimp .AND.ln_dynspg_ts ) THEN
          ! remove barotropic velocities:
          DO jk = 1, jpkm1
@@ -166,7 +166,6 @@
          END IF
       ENDIF
-#endif
-
-      ! 2. Vertical diffusion on u
+
+      ! 3. Vertical diffusion on u
       ! ---------------------------
       ! Matrix and second member construction
@@ -209,6 +208,5 @@
       !-----------------------------------------------------------------------
       !
-      !==  First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)  ==
-      DO jk = 2, jpkm1
+      DO jk = 2, jpkm1        !==  First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)  ==
          DO jj = 2, jpjm1   
             DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -220,13 +218,7 @@
       DO jj = 2, jpjm1        !==  second recurrence:    SOLk = RHSk - Lk / Dk-1  Lk-1  ==
          DO ji = fs_2, fs_jpim1   ! vector opt.
-#if defined key_dynspg_ts
             ze3ua =  ( 1._wp - r_vvl ) * fse3u_n(ji,jj,1) + r_vvl   * fse3u_a(ji,jj,1) 
             ua(ji,jj,1) = ua(ji,jj,1) + p2dt * 0.5_wp * ( utau_b(ji,jj) + utau(ji,jj) )   &
                &                                      / ( ze3ua * rau0 ) * umask(ji,jj,1) 
-#else
-            ua(ji,jj,1) = ub(ji,jj,1) &
-               &                   + p2dt *(ua(ji,jj,1) +  0.5_wp * ( utau_b(ji,jj) + utau(ji,jj) )   &
-               &                                      / ( fse3u(ji,jj,1) * rau0     ) * umask(ji,jj,1) ) 
-#endif
          END DO
       END DO
@@ -234,9 +226,5 @@
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1
-#if defined key_dynspg_ts
                zrhs = ua(ji,jj,jk)   ! zrhs=right hand side
-#else
-               zrhs = ub(ji,jj,jk) + p2dt * ua(ji,jj,jk)
-#endif
                ua(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * ua(ji,jj,jk-1)
             END DO
@@ -257,16 +245,5 @@
       END DO
 
-#if ! defined key_dynspg_ts
-      ! Normalization to obtain the general momentum trend ua
-      DO jk = 1, jpkm1
-         DO jj = 2, jpjm1   
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ua(ji,jj,jk) = ( ua(ji,jj,jk) - ub(ji,jj,jk) ) * z1_p2dt
-            END DO
-         END DO
-      END DO
-#endif
-
-      ! 3. Vertical diffusion on v
+      ! 4. Vertical diffusion on v
       ! ---------------------------
       ! Matrix and second member construction
@@ -309,6 +286,5 @@
       !-----------------------------------------------------------------------
       !
-      !==  First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)  ==
-      DO jk = 2, jpkm1        
+      DO jk = 2, jpkm1        !==  First recurrence : Dk = Dk - Lk * Uk-1 / Dk-1   (increasing k)  ==
          DO jj = 2, jpjm1   
             DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -319,14 +295,8 @@
       !
       DO jj = 2, jpjm1        !==  second recurrence:    SOLk = RHSk - Lk / Dk-1  Lk-1  ==
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-#if defined key_dynspg_ts            
+         DO ji = fs_2, fs_jpim1   ! vector opt.          
             ze3va =  ( 1._wp - r_vvl ) * fse3v_n(ji,jj,1) + r_vvl   * fse3v_a(ji,jj,1) 
             va(ji,jj,1) = va(ji,jj,1) + p2dt * 0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) )   &
                &                                      / ( ze3va * rau0 ) 
-#else
-            va(ji,jj,1) = vb(ji,jj,1) &
-               &                   + p2dt *(va(ji,jj,1) +  0.5_wp * ( vtau_b(ji,jj) + vtau(ji,jj) )   &
-               &                                                       / ( fse3v(ji,jj,1) * rau0     )  )
-#endif
          END DO
       END DO
@@ -334,9 +304,5 @@
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
-#if defined key_dynspg_ts
                zrhs = va(ji,jj,jk)   ! zrhs=right hand side
-#else
-               zrhs = vb(ji,jj,jk) + p2dt * va(ji,jj,jk)
-#endif
                va(ji,jj,jk) = zrhs - zwi(ji,jj,jk) / zwd(ji,jj,jk-1) * va(ji,jj,jk-1)
             END DO
@@ -357,17 +323,6 @@
       END DO
 
-      ! Normalization to obtain the general momentum trend va
-#if ! defined key_dynspg_ts
-      DO jk = 1, jpkm1
-         DO jj = 2, jpjm1   
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               va(ji,jj,jk) = ( va(ji,jj,jk) - vb(ji,jj,jk) ) * z1_p2dt
-            END DO
-         END DO
-      END DO
-#endif
-
       ! J. Chanut: Lines below are useless ?
-      !! restore bottom layer avmu(v) 
+      !! restore avmu(v)=0. at bottom (and top if ln_isfcav=T interfaces)
       IF( ln_bfrimp ) THEN
         DO jj = 2, jpjm1
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/DYN/sshwzv.F90	(revision 6041)
@@ -20,11 +20,6 @@
    USE sbc_oce         ! surface boundary condition: ocean
    USE domvvl          ! Variable volume
-   USE divcur          ! hor. divergence and curl      (div & cur routines)
-   USE restart         ! only for lrst_oce
-   USE in_out_manager  ! I/O manager
-   USE prtctl          ! Print control
-   USE phycst
-   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
-   USE lib_mpp         ! MPP library
+   USE divhor          ! horizontal divergence
+   USE phycst          ! physical constants
    USE bdy_oce
    USE bdy_par         
@@ -36,4 +31,9 @@
    USE asminc          ! Assimilation increment
 #endif
+   USE in_out_manager  ! I/O manager
+   USE restart         ! only for lrst_oce
+   USE prtctl          ! Print control
+   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
+   USE lib_mpp         ! MPP library
    USE wrk_nemo        ! Memory Allocation
    USE timing          ! Timing
@@ -66,29 +66,26 @@
       !!      by the time step.
       !!
-      !! ** action  :   ssha    : after sea surface height
+      !! ** action  :   ssha, after sea surface height
       !!
       !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
       !!----------------------------------------------------------------------
-      !
-      REAL(wp), POINTER, DIMENSION(:,:  ) ::  zhdiv
-      INTEGER, INTENT(in) ::   kt                      ! time step
+      INTEGER, INTENT(in) ::   kt   ! time step
       ! 
-      INTEGER             ::   jk                      ! dummy loop indice
-      REAL(wp)            ::   z2dt, z1_rau0           ! local scalars
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ssh_nxt')
-      !
-      CALL wrk_alloc( jpi, jpj, zhdiv ) 
+      INTEGER  ::   jk            ! dummy loop indice
+      REAL(wp) ::   z2dt, zcoef   ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zhdiv   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('ssh_nxt')
+      !
+      CALL wrk_alloc( jpi,jpj,   zhdiv ) 
       !
       IF( kt == nit000 ) THEN
-         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) 'ssh_nxt : after sea surface height'
          IF(lwp) WRITE(numout,*) '~~~~~~~ '
-         !
-      ENDIF
-      !
-      CALL div_cur( kt )                              ! Horizontal divergence & Relative vorticity
+      ENDIF
+      !
+      CALL div_hor( kt )                              ! Horizontal divergence
       !
       z2dt = 2._wp * rdt                              ! set time step size (Euler/Leapfrog)
@@ -106,29 +103,27 @@
       ! compute the vertical velocity which can be used to compute the non-linear terms of the momentum equations.
       ! 
-      z1_rau0 = 0.5_wp * r1_rau0
-      ssha(:,:) = (  sshb(:,:) - z2dt * ( z1_rau0 * ( emp_b(:,:) + emp(:,:) ) + zhdiv(:,:) )  ) * ssmask(:,:)
-
-#if ! defined key_dynspg_ts
-      ! These lines are not necessary with time splitting since
-      ! boundary condition on sea level is set during ts loop
-#if defined key_agrif
-      CALL agrif_ssh( kt )
-#endif
-#if defined key_bdy
-      IF (lk_bdy) THEN
-         CALL lbc_lnk( ssha, 'T', 1. ) ! Not sure that's necessary
-         CALL bdy_ssh( ssha ) ! Duplicate sea level across open boundaries
-      ENDIF
-#endif
-#endif
+      zcoef = 0.5_wp * r1_rau0
+      ssha(:,:) = (  sshb(:,:) - z2dt * ( zcoef * ( emp_b(:,:) + emp(:,:) ) + zhdiv(:,:) )  ) * ssmask(:,:)
+
+      IF ( .NOT.ln_dynspg_ts ) THEN
+         ! These lines are not necessary with time splitting since
+         ! boundary condition on sea level is set during ts loop
+# if defined key_agrif
+         CALL agrif_ssh( kt )
+# endif
+# if defined key_bdy
+         IF( lk_bdy ) THEN
+            CALL lbc_lnk( ssha, 'T', 1. )    ! Not sure that's necessary
+            CALL bdy_ssh( ssha )             ! Duplicate sea level across open boundaries
+         ENDIF
+# endif
+      ENDIF
 
 #if defined key_asminc
-      !                                                ! Include the IAU weighted SSH increment
-      IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN
+      IF( lk_asminc .AND. ln_sshinc .AND. ln_asmiau ) THEN     ! Include the IAU weighted SSH increment
          CALL ssh_asm_inc( kt )
          ssha(:,:) = ssha(:,:) + z2dt * ssh_iau(:,:)
       ENDIF
 #endif
-
       !                                           !------------------------------!
       !                                           !           outputs            !
@@ -159,17 +154,15 @@
       !! Reference  : Leclair, M., and G. Madec, 2009, Ocean Modelling.
       !!----------------------------------------------------------------------
-      !
-      INTEGER, INTENT(in) ::   kt           ! time step
+      INTEGER, INTENT(in) ::   kt   ! time step
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   z1_2dt       ! local scalars
       REAL(wp), POINTER, DIMENSION(:,:  ) ::  z2d
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  z3d, zhdiv
-      !
-      INTEGER             ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp)            ::   z1_2dt       ! local scalars
-      !!----------------------------------------------------------------------
-      
-      IF( nn_timing == 1 )  CALL timing_start('wzv')
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('wzv')
       !
       IF( kt == nit000 ) THEN
-         !
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) 'wzv : now vertical velocity '
@@ -177,5 +170,4 @@
          !
          wn(:,:,jpk) = 0._wp                  ! bottom boundary condition: w=0 (set once for all)
-         !
       ENDIF
       !                                           !------------------------------!
@@ -193,5 +185,5 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zhdiv(ji,jj,jk) = r1_e12t(ji,jj) * ( un_td(ji,jj,jk) - un_td(ji-1,jj,jk) + vn_td(ji,jj,jk) - vn_td(ji,jj-1,jk) )
+                  zhdiv(ji,jj,jk) = r1_e1e2t(ji,jj) * ( un_td(ji,jj,jk) - un_td(ji-1,jj,jk) + vn_td(ji,jj,jk) - vn_td(ji,jj-1,jk) )
                END DO
             END DO
@@ -216,5 +208,5 @@
 
 #if defined key_bdy
-      IF (lk_bdy) THEN
+      IF( lk_bdy ) THEN
          DO jk = 1, jpkm1
             wn(:,:,jk) = wn(:,:,jk) * bdytmask(:,:)
@@ -224,7 +216,7 @@
       !
       IF( nn_timing == 1 )  CALL timing_stop('wzv')
-
-
+      !
    END SUBROUTINE wzv
+
 
    SUBROUTINE ssh_swp( kt )
@@ -258,11 +250,9 @@
       ENDIF
 
-# if defined key_dynspg_ts
-      IF( ( neuler == 0 .AND. kt == nit000 ) .OR. ln_bt_fw ) THEN    !** Euler time-stepping: no filter
-# else
-      IF ( neuler == 0 .AND. kt == nit000 ) THEN   !** Euler time-stepping at first time-step : no filter
-#endif
+      IF( ( neuler == 0 .AND. kt == nit000 ) .OR. ( ln_bt_fw .AND. ln_dynspg_ts ) ) THEN 
+                                                   !** Euler time-stepping: no filter
          sshb(:,:) = sshn(:,:)                           ! before <-- now
          sshn(:,:) = ssha(:,:)                           ! now    <-- after  (before already = now)
+         !
       ELSE                                         !** Leap-Frog time-stepping: Asselin filter + swap
          sshb(:,:) = sshn(:,:) + atfp * ( sshb(:,:) - 2 * sshn(:,:) + ssha(:,:) )     ! before <-- now filtered
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flo4rk.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flo4rk.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flo4rk.F90	(revision 6041)
@@ -4,5 +4,5 @@
    !! Ocean floats :   trajectory computation using a 4th order Runge-Kutta
    !!======================================================================
-#if   defined key_floats   ||   defined key_esopa
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                     float trajectories
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flo_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flo_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flo_oce.F90	(revision 6041)
@@ -7,5 +7,5 @@
    !!   NEMO      1.0  ! 2002-11  (G. Madec, A. Bozec)  F90: Free form and module
    !!----------------------------------------------------------------------
-#if   defined key_floats   ||   defined key_esopa
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                        drifting floats
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/floats.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/floats.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/floats.F90	(revision 6041)
@@ -7,5 +7,5 @@
    !!   NEMO     1.0  ! 2002-06  (A. Bozec)  F90, Free form and module
    !!----------------------------------------------------------------------
-#if   defined key_floats   ||   defined key_esopa
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                     float trajectories
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/floblk.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/floblk.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/floblk.F90	(revision 6041)
@@ -4,5 +4,5 @@
    !! Ocean floats :   trajectory computation
    !!======================================================================
-#if   defined key_floats   ||   defined key_esopa
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                     float trajectories
@@ -125,5 +125,5 @@
 
             ! for a isobar float zsurfz is put to zero. The vertical velocity will be zero too.
-            zsurfz = e1t(iiloc(jfl),ijloc(jfl)) * e2t(iiloc(jfl),ijloc(jfl))
+            zsurfz =          e1e2t(iiloc(jfl),ijloc(jfl))
             zvol   = zsurfz * fse3t(iiloc(jfl),ijloc(jfl),-ikl(jfl))
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flodom.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flodom.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flodom.F90	(revision 6041)
@@ -4,9 +4,8 @@
    !! Ocean floats :   domain
    !!======================================================================
-   !! History :  OPA          ! 1998-07 (Y.Drillet, CLIPPER)  Original code
-   !!            NEMO_3.3.1   ! 2011-09 (C.Bricaud,S.Law-Chune Mercator-Ocean): 
-                              ! add Ariane convention, Comsecitc changes
-   !!----------------------------------------------------------------------
-#if   defined key_floats   ||   defined key_esopa
+   !! History :  OPA  ! 1998-07 (Y.Drillet, CLIPPER)  Original code
+   !!  NEMO      3.3  ! 2011-09 (C.Bricaud,S.Law-Chune Mercator-Ocean): add ARIANE convention + comsecitc changes
+   !!----------------------------------------------------------------------
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                     float trajectories
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/florst.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/florst.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/florst.F90	(revision 6041)
@@ -2,21 +2,15 @@
    !!======================================================================
    !!                       ***  MODULE  florst  ***
-   !!
-   !!
-   !! write floats restart files
-   !!
+   !! Ocean floats : write floats restart files
    !!======================================================================
-   !!  History :
-   !!    8.0  !  99-09  (Y. Drillet)    : Original code
-   !!         !  00-06  (J.-M. Molines) : Profiling floats for CLS 
-   !!    8.5  !  02-10  (A. Bozec)  F90 : Free form and module
-   !!    3.2  !  10-08  (slaw, cbricaud): netcdf outputs and others 
+   !!  History :  OPA  !  1999-09  (Y. Drillet)    : Original code
+   !!              -   !  2000-06  (J.-M. Molines) : Profiling floats for CLS 
+   !!   NEMO      1.0  !  2002-10  (A. Bozec)  F90 : Free form and module
+   !!             3.2  !  2010-08  (slaw, cbricaud): netcdf outputs and others 
    !!----------------------------------------------------------------------
-#if   defined key_floats   ||   defined key_esopa
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                     float trajectories
    !!----------------------------------------------------------------------
-
-   !! * Modules used
    USE flo_oce         ! ocean drifting floats
    USE dom_oce         ! ocean space and time domain
@@ -37,7 +31,6 @@
    !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
    !! $Id$
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flowri.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flowri.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/FLO/flowri.F90	(revision 6041)
@@ -3,21 +3,16 @@
    !!                       ***  MODULE  flowri  ***
    !!
-   !! write floats trajectory in ascii                    ln_flo_ascii = T
-   !!                      or in netcdf ( IOM or IOSPSL ) ln_flo_ascii = F           
-   !! 
-   !!
+   !! Ocean floats: write floats trajectory in ascii                    ln_flo_ascii = T
+   !!                                    or in netcdf ( IOM or IOSPSL ) ln_flo_ascii = F           
    !!======================================================================
-   !!  History :
-   !!    8.0  !  99-09  (Y. Drillet)    : Original code
-   !!         !  00-06  (J.-M. Molines) : Profiling floats for CLS 
-   !!    8.5  !  02-10  (A. Bozec)  F90 : Free form and module
-   !!    3.2  !  10-08  (slaw, cbricaud): netcdf outputs and others 
-   !!----------------------------------------------------------------------
-#if   defined key_floats   ||   defined key_esopa
+   !!  History :  OPA  !  1999-09  (Y. Drillet)    : Original code
+   !!              -   !  2000-06  (J.-M. Molines) : Profiling floats for CLS 
+   !!   NEMO      1.0  !  2002-10  (A. Bozec)  F90 : Free form and module
+   !!             3.2  !  2010-08  (slaw, cbricaud): netcdf outputs and others 
+   !!----------------------------------------------------------------------
+#if   defined key_floats
    !!----------------------------------------------------------------------
    !!   'key_floats'                                     float trajectories
    !!----------------------------------------------------------------------
-
-   !! * Modules used
    USE flo_oce         ! ocean drifting floats
    USE oce             ! ocean dynamics and tracers
@@ -30,5 +25,4 @@
    USE iom             ! I/O library
 
-
    IMPLICIT NONE
    PRIVATE
@@ -51,7 +45,6 @@
    !! NEMO/OPA 3.2 , LODYC-IPSL  (2009)
    !! $Id$
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
-   !!----------------------------------------------------------------------
-
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ICB/icbdia.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ICB/icbdia.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ICB/icbdia.F90	(revision 6041)
@@ -191,5 +191,5 @@
 
          nbergs_end        = icb_utl_count()
-         zgrdd_berg_mass   = SUM( berg_mass (:,:)*e1e2t(:,:)*tmask_i(:,:) )
+         zgrdd_berg_mass   = SUM( berg_mass(:,:)*e1e2t(:,:)*tmask_i(:,:) )
          zgrdd_bits_mass   = SUM( bits_mass(:,:)*e1e2t(:,:)*tmask_i(:,:) )
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ICB/icbthm.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ICB/icbthm.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ICB/icbthm.F90	(revision 6041)
@@ -156,5 +156,5 @@
          ! use tmask rather than tmask_i when dealing with icebergs
          IF( tmask(ii,ij,1) /= 0._wp ) THEN    ! Add melting to the grid and field diagnostics
-            z1_e1e2    = 1._wp / e1e2t(ii,ij) * this%mass_scaling
+            z1_e1e2    = r1_e1e2t(ii,ij) * this%mass_scaling
             z1_dt_e1e2 = z1_dt * z1_e1e2
             zmelt    = ( zdM - ( zdMbitsE - zdMbitsM ) ) * z1_dt   ! kg/s
@@ -195,5 +195,5 @@
             !
          ELSE                            ! Diagnose mass distribution on grid
-            z1_e1e2 = 1._wp / e1e2t(ii,ij) * this%mass_scaling
+            z1_e1e2 = r1_e1e2t(ii,ij) * this%mass_scaling
             CALL icb_dia_size( ii, ij, zWn, zLn, zAbits,   &
             &                  this%mass_scaling, zMnew, znMbits, z1_e1e2)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90	(revision 6041)
@@ -129,8 +129,8 @@
          !
          IF( ln_cfmeta ) THEN   ! Add additional grid metadata
-            CALL iom_set_domain_attr("grid_T", area = e12t(nldi:nlei, nldj:nlej))
-            CALL iom_set_domain_attr("grid_U", area = e12u(nldi:nlei, nldj:nlej))
-            CALL iom_set_domain_attr("grid_V", area = e12v(nldi:nlei, nldj:nlej))
-            CALL iom_set_domain_attr("grid_W", area = e12t(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_T", area = e1e2t(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_U", area = e1e2u(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_V", area = e1e2v(nldi:nlei, nldj:nlej))
+            CALL iom_set_domain_attr("grid_W", area = e1e2t(nldi:nlei, nldj:nlej))
             CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit )
             CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu )
@@ -903,12 +903,8 @@
                IF( zofs /= 0. )   pv_r1d(:) = pv_r1d(:) + zofs
             ELSEIF( PRESENT(pv_r2d) ) THEN
-!CDIR COLLAPSE
                IF( zscf /= 1.)   pv_r2d(:,:) = pv_r2d(:,:) * zscf
-!CDIR COLLAPSE
                IF( zofs /= 0.)   pv_r2d(:,:) = pv_r2d(:,:) + zofs
             ELSEIF( PRESENT(pv_r3d) ) THEN
-!CDIR COLLAPSE
                IF( zscf /= 1.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) * zscf
-!CDIR COLLAPSE
                IF( zofs /= 0.)   pv_r3d(:,:,:) = pv_r3d(:,:,:) + zofs
             ENDIF
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/IOM/restart.F90	(revision 6041)
@@ -9,4 +9,6 @@
    !!            3.3  !  2010-04  (M. Leclair, G. Madec)  modified LF-RA
    !!            - -  !  2010-10  (C. Ethe, G. Madec) TRC-TRA merge (T-S in 4D)
+   !!            3.7  !  2014-01  (G. Madec) suppression of curl and hdiv from the restart
+   !!             -   !  2014-12  (G. Madec) remove KPP scheme
    !!----------------------------------------------------------------------
 
@@ -18,10 +20,11 @@
    USE oce             ! ocean dynamics and tracers 
    USE dom_oce         ! ocean space and time domain
+   USE sbc_ice         ! only lk_lim3 
    USE phycst          ! physical constants
+   USE eosbn2          ! equation of state            (eos bn2 routine)
+   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
+   !
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O module
-   USE eosbn2          ! equation of state            (eos bn2 routine)
-   USE trdmxl_oce      ! ocean active mixed layer tracers trends variables
-   USE divcur          ! hor. divergence and curl      (div & cur routines)
 
    IMPLICIT NONE
@@ -130,6 +133,4 @@
                      CALL iom_rstput( kt, nitrst, numrow, 'tb'     , tsb(:,:,:,jp_tem) )
                      CALL iom_rstput( kt, nitrst, numrow, 'sb'     , tsb(:,:,:,jp_sal) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rotb'   , rotb      )
-                     CALL iom_rstput( kt, nitrst, numrow, 'hdivb'  , hdivb     )
                      CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , sshb      )
                      !
@@ -138,11 +139,6 @@
                      CALL iom_rstput( kt, nitrst, numrow, 'tn'     , tsn(:,:,:,jp_tem) )
                      CALL iom_rstput( kt, nitrst, numrow, 'sn'     , tsn(:,:,:,jp_sal) )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rotn'   , rotn      )
-                     CALL iom_rstput( kt, nitrst, numrow, 'hdivn'  , hdivn     )
                      CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , sshn      )
                      CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      )
-#if defined key_zdfkpp
-                     CALL iom_rstput( kt, nitrst, numrow, 'rhd'    , rhd       )
-#endif
       IF( kt == nitrst ) THEN
          CALL iom_close( numrow )     ! close the restart file (only at last time step)
@@ -197,4 +193,5 @@
    END SUBROUTINE rst_read_open
 
+
    SUBROUTINE rst_read
       !!---------------------------------------------------------------------- 
@@ -227,6 +224,4 @@
          CALL iom_get( numror, jpdom_autoglo, 'tb'     , tsb(:,:,:,jp_tem) )
          CALL iom_get( numror, jpdom_autoglo, 'sb'     , tsb(:,:,:,jp_sal) )
-         CALL iom_get( numror, jpdom_autoglo, 'rotb'   , rotb    )
-         CALL iom_get( numror, jpdom_autoglo, 'hdivb'  , hdivb   )
          CALL iom_get( numror, jpdom_autoglo, 'sshb'   , sshb    )
       ELSE
@@ -239,10 +234,4 @@
       CALL iom_get( numror, jpdom_autoglo, 'sn'     , tsn(:,:,:,jp_sal) )
       CALL iom_get( numror, jpdom_autoglo, 'sshn'   , sshn    )
-      IF( iom_varid( numror, 'rotn', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'rotn'   , rotn    )
-         CALL iom_get( numror, jpdom_autoglo, 'hdivn'  , hdivn   )
-      ELSE
-         CALL div_cur( 0 )                              ! Horizontal divergence & Relative vorticity
-      ENDIF
       IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
          CALL iom_get( numror, jpdom_autoglo, 'rhop'   , rhop    )   ! now    potential density
@@ -250,11 +239,4 @@
          CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )   
       ENDIF
-#if defined key_zdfkpp
-      IF( iom_varid( numror, 'rhd', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_autoglo, 'rhd'    , rhd     )   ! now    in situ density anomaly
-      ELSE
-         CALL eos( tsn, rhd, fsdept_n(:,:,:) )   ! compute rhd
-      ENDIF
-#endif
       !
       IF( neuler == 0 ) THEN                                  ! Euler restart (neuler=0)
@@ -262,8 +244,6 @@
          ub   (:,:,:)   = un   (:,:,:)
          vb   (:,:,:)   = vn   (:,:,:)
-         rotb (:,:,:)   = rotn (:,:,:)
-         hdivb(:,:,:)   = hdivn(:,:,:)
          sshb (:,:)     = sshn (:,:)
-
+         !
          IF( lk_vvl ) THEN
             DO jk = 1, jpk
@@ -271,5 +251,5 @@
             END DO
          ENDIF
-
+         !
       ENDIF
       !
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LBC/cla.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LBC/cla.F90	(revision 6040)
+++ 	(revision )
@@ -1,732 +1,0 @@
-MODULE cla
-   !!======================================================================
-   !!                    ***  MODULE  cla  ***
-   !! Cross Land Advection : specific update of the horizontal divergence,
-   !!                        tracer trends and after velocity
-   !!
-   !!                 ---   Specific to ORCA_R2   ---
-   !!
-   !!======================================================================
-   !! History :  1.0  ! 2002-11 (A. Bozec)  Original code
-   !!            3.2  ! 2009-07 (G. Madec)  merge cla, cla_div, tra_cla, cla_dynspg
-   !!                 !                     and correct a mpp bug reported by A.R. Porter
-   !!----------------------------------------------------------------------
-   !!   cla_div           : update of horizontal divergence at cla straits
-   !!   tra_cla           : update of tracers at cla straits
-   !!   cla_dynspg        : update of after horizontal velocities at cla straits
-   !!   cla_init          : initialisation - control check
-   !!   cla_bab_el_mandeb : cross land advection for Bab-el-mandeb strait
-   !!   cla_gibraltar     : cross land advection for Gibraltar strait
-   !!   cla_hormuz        : cross land advection for Hormuz strait
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and tracers
-   USE dom_oce        ! ocean space and time domain
-   USE sbc_oce        ! surface boundary condition: ocean
-   USE dynspg_oce     ! ocean dynamics: surface pressure gradient variables
-   USE in_out_manager ! I/O manager
-   USE lib_mpp        ! distributed memory computing library
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp        ! MPP library
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   PUBLIC   cla_init     ! routine called by opa.F90
-   PUBLIC   cla_div      ! routine called by divcur.F90
-   PUBLIC   cla_traadv   ! routine called by traadv.F90
-   PUBLIC   cla_dynspg   ! routine called by dynspg_flt.F90
-
-   INTEGER  ::   nbab, ngib, nhor   ! presence or not of required grid-point on local domain
-   !                                ! for Bab-el-Mandeb, Gibraltar, and Hormuz straits
-   
-   !                                           !   fixed part  !  time evolving    !!! profile of hdiv for some straits
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_139_101, hdiv_139_101_kt    ! Gibraltar     (i,j)=(172,101)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_139_102                     ! Gibraltar     (i,j)=(139,102)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_141_102, hdiv_141_102_kt    ! Gibraltar     (i,j)=(141,102)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_161_88 , hdiv_161_88_kt     ! Bab-el-Mandeb (i,j)=(161,88)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_161_87                      ! Bab-el-Mandeb (i,j)=(161,87)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_160_89 , hdiv_160_89_kt     ! Bab-el-Mandeb (i,j)=(160,89)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   hdiv_172_94                      ! Hormuz        (i,j)=(172, 94)
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION (:) ::   t_171_94_hor, s_171_94_hor       ! Temperature, salinity in Hormuz strait
-   
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE cla_div( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE div_cla  ***
-      !!
-      !! ** Purpose :   update the horizontal divergence of the velocity field
-      !!              at some straits ( Gibraltar, Bab el Mandeb and Hormuz ).
-      !!
-      !! ** Method  : - first time-step: initialisation of cla
-      !!              - all   time-step: using imposed transport at each strait, 
-      !!              the now horizontal divergence is updated
-      !!
-      !! ** Action  :   phdivn   updted now horizontal divergence at cla straits
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index
-      !!----------------------------------------------------------------------
-      !     
-      IF( kt == nit000 ) THEN
-         !
-         CALL cla_init                                        ! control check 
-         !
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'div_cla : cross land advection on hdiv '
-         IF(lwp) WRITE(numout,*) '~~~~~~~~'
-         !
-         IF( nbab == 1 )   CALL cla_bab_el_mandeb('ini')    ! Bab el Mandeb ( Red Sea - Indian ocean )
-         IF( ngib == 1 )   CALL cla_gibraltar    ('ini')    ! Gibraltar strait (Med Sea - Atlantic ocean)
-         IF( nhor == 1 )   CALL cla_hormuz       ('ini')    ! Hormuz Strait ( Persian Gulf - Indian ocean )
-         !
-      ENDIF                           
-      !
-      IF( nbab == 1    )   CALL cla_bab_el_mandeb('div')    ! Bab el Mandeb ( Red Sea - Indian ocean )
-      IF( ngib == 1    )   CALL cla_gibraltar    ('div')    ! Gibraltar strait (Med Sea - Atlantic ocean)
-      IF( nhor == 1    )   CALL cla_hormuz       ('div')    ! Hormuz Strait ( Persian Gulf - Indian ocean )
-      !
-!!gm  lbc useless here, no?
-!!gm      CALL lbc_lnk( hdivn, 'T', 1. )                    ! Lateral boundary conditions on hdivn
-      !
-   END SUBROUTINE cla_div
-   
-   
-   SUBROUTINE cla_traadv( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE tra_cla  ***
-      !!                   
-      !! ** Purpose :   Update the now trend due to the advection of tracers
-      !!      and add it to the general trend of passive tracer equations
-      !!      at some straits ( Bab el Mandeb, Gibraltar, Hormuz ).
-      !!
-      !! ** Method  :   using both imposed transport at each strait and T & S
-      !!              budget, the now tracer trends is updated
-      !!
-      !! ** Action  :   (ta,sa)   updated now tracer trends at cla straits
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
-      !!----------------------------------------------------------------------
-      !
-      IF( kt == nit000 ) THEN 
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_cla : cross land advection on tracers '
-         IF(lwp) WRITE(numout,*) '~~~~~~~~'
-      ENDIF
-      !
-      IF( nbab == 1    )   CALL cla_bab_el_mandeb('tra')      ! Bab el Mandeb strait
-      IF( ngib == 1    )   CALL cla_gibraltar    ('tra')      ! Gibraltar strait
-      IF( nhor == 1    )   CALL cla_hormuz       ('tra')      ! Hormuz Strait ( Persian Gulf)
-      !
-   END SUBROUTINE cla_traadv
-
-   
-   SUBROUTINE cla_dynspg( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE cla_dynspg  ***
-      !!                   
-      !! ** Purpose :   Update the after velocity at some straits 
-      !!              (Bab el Mandeb, Gibraltar, Hormuz).
-      !!
-      !! ** Method  :   required to compute the filtered surface pressure gradient 
-      !!
-      !! ** Action  :   (ua,va)   after velocity at the cla straits
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
-      !!----------------------------------------------------------------------
-      !
-      IF( kt == nit000 ) THEN 
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'cla_dynspg : cross land advection on (ua,va) '
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
-      ENDIF
-      !
-      IF( nbab == 1    )   CALL cla_bab_el_mandeb('spg')      ! Bab el Mandeb strait
-      IF( ngib == 1    )   CALL cla_gibraltar    ('spg')      ! Gibraltar strait
-      IF( nhor == 1    )   CALL cla_hormuz       ('spg')      ! Hormuz Strait ( Persian Gulf)
-      !
-!!gm lbc is needed here, not?
-!!gm      CALL lbc_lnk( hdivn, 'U', -1. )   ;   CALL lbc_lnk( hdivn, 'V', -1. )      ! Lateral boundary conditions 
-      !
-   END SUBROUTINE cla_dynspg
-
-
-   SUBROUTINE cla_init
-      !! -------------------------------------------------------------------
-      !!                   ***  ROUTINE cla_init  ***
-      !!           
-      !! ** Purpose :   control check for mpp computation  
-      !!
-      !! ** Method  : - All the strait grid-points must be inside one of the 
-      !!              local domain interior for the cla advection to work
-      !!              properly in mpp (i.e. inside (2:jpim1,2:jpjm1) ).
-      !!              Define the corresponding indicators (nbab, ngib, nhor)
-      !!              - The profiles of cross-land fluxes are currently hard
-      !!              coded for L31 levels. Stop if jpk/=31
-      !!
-      !! ** Action  :   nbab, ngib, nhor   strait inside the local domain or not
-      !!---------------------------------------------------------------------
-      REAL(wp) ::   ztemp   ! local scalar
-      INTEGER  ::   ierr    ! local integer
-      !!---------------------------------------------------------------------
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'cla_init : cross land advection initialisation '
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~'
-      !
-      !                           ! Allocate arrays for this module
-      ALLOCATE( hdiv_139_101(jpk) , hdiv_139_101_kt(jpk) ,     &    ! Gibraltar
-         &      hdiv_139_102(jpk) ,                            &
-         &      hdiv_141_102(jpk) , hdiv_141_102_kt(jpk) ,     &
-         &      hdiv_161_88 (jpk) , hdiv_161_88_kt (jpk) ,     &    ! Bab-el-Mandeb
-         &      hdiv_161_87 (jpk) ,                            &                     
-         &      hdiv_160_89 (jpk) , hdiv_160_89_kt (jpk) ,     &     ! Hormuz
-         &      hdiv_172_94 (jpk) ,                            &
-         &      t_171_94_hor(jpk) , s_171_94_hor   (jpk) , STAT=ierr )
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
-      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'cla_init: unable to allocate arrays' )
-      !
-      IF( .NOT.lk_dynspg_flt )   CALL ctl_stop( 'cla_init: Cross Land Advection works only with lk_dynspg_flt=T ' )
-      !
-      IF( lk_vvl             )   CALL ctl_stop( 'cla_init: Cross Land Advection does not work with lk_vvl=T option' )
-      !
-      IF( jpk /= 31          )   CALL ctl_stop( 'cla_init: Cross Land Advection hard coded for ORCA_R2_L31' )
-      !
-      !                                        _|_______|_______|_
-      !                                     89  |       |///////|  
-      !                                        _|_______|_______|_
-      ! ------------------------ !          88  |///////|       | 
-      !   Bab el Mandeb strait   !             _|_______|_______|_
-      ! ------------------------ !          87  |///////|       | 
-      !                                        _|_______|_______|_
-      !                                         |  160  |  161  |  
-      !
-      ! The 6 Bab el Mandeb grid-points must be inside one of the interior of the
-      ! local domain for the cla advection to work properly (i.e. (2:jpim1,2:jpjm1)
-      nbab = 0
-      IF(  ( 1 <= mj0( 88) .AND. mj1( 89) <= jpj ) .AND.    &  !* (161,89), (161,88) and (161,88) on the local pocessor
-         & ( 1 <= mi0(160) .AND. mi1(161) <= jpi )       )    nbab = 1 
-      !
-      ! test if there is no local domain that includes all required grid-points
-      ztemp = REAL( nbab )
-      IF( lk_mpp )   CALL mpp_sum( ztemp )      ! sum with other processors value
-      IF( ztemp == 0 ) THEN                     ! Only 2 points in each direction, this should never be a problem
-         CALL ctl_stop( ' cross land advection at Bab-el_Mandeb does not work with your processor cutting: change it' )
-      ENDIF
-      !                                        ___________________________
-      ! ------------------------ !         102  |       |///////|       |
-      !     Gibraltar strait     !             _|_______|_______|_______|_
-      ! ------------------------ !         101  |       |///////|       |
-      !                                        _|_______|_______|_______|_ 
-      !                                         |  139  |  140  |  141  |
-      !
-      ! The 6 Gibraltar grid-points must be inside one of the interior of the
-      ! local domain for the cla advection to work properly (i.e. (2:jpim1,2:jpjm1)
-      ngib = 0
-      IF(  ( 2 <= mj0(101) .AND. mj1(102) <= jpjm1 ) .AND.    &  !* (139:141,101:102) on the local pocessor
-         & ( 2 <= mi0(139) .AND. mi1(141) <= jpim1 )       )    ngib = 1 
-      !
-      ! test if there is no local domain that includes all required grid-points
-      ztemp = REAL( ngib )
-      IF( lk_mpp )   CALL mpp_sum( ztemp )      ! sum with other processors value
-      IF( ztemp == 0 ) THEN                     ! 3 points in i-direction, this may be a problem with some cutting
-           CALL ctl_stop( ' cross land advection at Gibraltar does not work with your processor cutting: change it' )
-      ENDIF
-      !                                        _______________
-      ! ------------------------ !          94  |/////|     | 
-      !       Hormuz strait      !             _|_____|_____|_
-      ! ------------------------ !                171   172     
-      !           
-      ! The 2 Hormuz grid-points must be inside one of the interior of the
-      ! local domain for the cla advection to work properly (i.e. (2:jpim1,2:jpjm1)
-      nhor = 0
-      IF(    2 <= mj0( 94) .AND. mj1( 94) <= jpjm1  .AND.  & 
-         &   2 <= mi0(171) .AND. mi1(172) <= jpim1         )   nhor = 1 
-      !
-      ! test if there is no local domain that includes all required grid-points
-      ztemp = REAL( nhor )
-      IF( lk_mpp )   CALL mpp_sum( ztemp )      ! sum with other processors value
-      IF( ztemp == 0 ) THEN                     ! 3 points in i-direction, this may be a problem with some cutting
-           CALL ctl_stop( ' cross land advection at Hormuz does not work with your processor cutting: change it' )
-      ENDIF
-      !
-   END SUBROUTINE cla_init
-
-
-   SUBROUTINE cla_bab_el_mandeb( cd_td )
-      !!----------------------------------------------------------------------
-      !!                ***  ROUTINE cla_bab_el_mandeb  ***
-      !!       
-      !! ** Purpose :   update the now horizontal divergence, the tracer tendancy
-      !!              and the after velocity in vicinity of Bab el Mandeb ( Red Sea - Indian ocean).
-      !!
-      !! ** Method  :   compute the exchanges at each side of the strait :
-      !!
-      !!       surf. zio_flow
-      !! (+ balance of emp) /\  |\\\\\\\\\\\|
-      !!                    ||  |\\\\\\\\\\\|  
-      !!    deep zio_flow   ||  |\\\\\\\\\\\|  
-      !!            |  ||   ||  |\\\\\\\\\\\|  
-      !!        89  |  ||   ||  |\\\\\\\\\\\|  
-      !!            |__\/_v_||__|____________ 
-      !!            !\\\\\\\\\\\|          surf. zio_flow
-      !!            |\\\\\\\\\\\|<===    (+ balance of emp)
-      !!            |\\\\\\\\\\\u
-      !!        88  |\\\\\\\\\\\|<---      deep  zrecirc (upper+deep at 2 different levels)
-      !!            |___________|__________   
-      !!            !\\\\\\\\\\\|         
-      !!            |\\\\\\\\\\\| ---\     deep  zrecirc (upper+deep) 
-      !!        87  !\\\\\\\\\\\u ===/   + deep  zio_flow   (all at the same level)
-      !!            !\\\\\\\\\\\|  
-      !!            !___________|__________ 
-      !!                160         161
-      !!
-      !!----------------------------------------------------------------------
-      CHARACTER(len=1), INTENT(in) ::   cd_td   ! ='div' update the divergence
-      !                                         ! ='tra' update the tracers
-      !                                         ! ='spg' update after velocity
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zemp_red     ! temporary scalar
-      REAL(wp) ::   zio_flow, zrecirc_upp, zrecirc_mid, zrecirc_bot
-      !!---------------------------------------------------------------------
-      !
-      SELECT CASE( cd_td ) 
-      !                     ! ---------------- !
-      CASE( 'ini' )         !  initialisation  ! 
-         !                  ! ---------------- ! 
-         !                                   
-         zio_flow    = 0.4e6                       ! imposed in/out flow
-         zrecirc_upp = 0.2e6                       ! imposed upper recirculation water
-         zrecirc_bot = 0.5e6                       ! imposed bottom  recirculation water
-
-         hdiv_161_88(:) = 0.e0                     ! (161,88) Gulf of Aden side, north point
-         hdiv_161_87(:) = 0.e0                     ! (161,87) Gulf of Aden side, south point
-         hdiv_160_89(:) = 0.e0                     ! (160,89) Red sea side
-
-         DO jj = mj0(88), mj1(88)              !** profile of hdiv at (161,88)   (Gulf of Aden side, north point)
-            DO ji = mi0(161), mi1(161)         !------------------------------
-               DO jk = 1, 8                        ! surface in/out flow   (Ind -> Red)   (div >0)
-                  hdiv_161_88(jk) = + zio_flow / ( 8. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               !                                   ! recirculation water   (Ind -> Red)   (div >0)
-               hdiv_161_88(20) =                 + zrecirc_upp   / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,20) )
-               hdiv_161_88(21) = + ( zrecirc_bot - zrecirc_upp ) / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,21) )
-            END DO
-         END DO
-         !
-         DO jj = mj0(87), mj1(87)              !** profile of hdiv at (161,88)   (Gulf of Aden side, south point)
-            DO ji = mi0(161), mi1(161)         !------------------------------
-               !                                   ! deep out flow + recirculation   (Red -> Ind)   (div <0)
-               hdiv_161_87(21) = - ( zio_flow + zrecirc_bot ) / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,21) )
-            END DO
-         END DO
-         !
-         DO jj = mj0(89), mj1(89)              !** profile of hdiv at (161,88)   (Red sea side)
-            DO ji = mi0(160), mi1(160)         !------------------------------
-               DO jk = 1, 8                        ! surface inflow    (Ind -> Red)   (div <0)
-                  hdiv_160_89(jk) = - zio_flow / ( 8. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               !                                   ! deep    outflow   (Red -> Ind)   (div >0)
-               hdiv_160_89(16)    = + zio_flow / (      e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,16) )
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'div' )         !   update hdivn   ! (call by divcur module)
-         !                  ! ---------=====-- ! 
-         !                                     !** emp on the Red Sea   (div >0) 
-         zemp_red = 0.e0                       !---------------------
-         DO jj = mj0(87), mj1(96)                  ! sum over the Red sea
-            DO ji = mi0(148), mi1(160) 
-               zemp_red = zemp_red + emp(ji,jj) * e1t(ji,jj) * e2t(ji,jj) * tmask_i(ji,jj)
-            END DO
-         END DO
-         IF( lk_mpp )   CALL mpp_sum( zemp_red )   ! sum with other processors value
-         zemp_red = zemp_red * 1.e-3               ! convert in m3
-         !
-         !                                     !** Correct hdivn (including emp adjustment)
-         !                                     !-------------------------------------------
-         DO jj = mj0(88), mj1(88)                  !* profile of hdiv at (161,88)   (Gulf of Aden side, north point)
-            DO ji = mi0(161), mi1(161) 
-               hdiv_161_88_kt(:) = hdiv_161_88(:)
-               DO jk = 1, 8                              ! increase the inflow from the Indian   (div >0) 
-                  hdiv_161_88_kt(jk) = hdiv_161_88(jk) + zemp_red / (8. * e2u(ji,jj) * fse3u(ji,jj,jk) )
-               END DO
-               hdivn(ji,jj,:) = hdivn(ji,jj,:) + hdiv_161_88_kt(:)
-            END DO
-         END DO
-         DO jj = mj0(87), mj1(87)                  !* profile of divergence at (161,87)   (Gulf of Aden side, south point)
-            DO ji = mi0(161), mi1(161) 
-               hdivn(ji,jj,:) = hdivn(ji,jj,:) + hdiv_161_87(:)
-            END DO
-         END DO
-         DO jj = mj0(89), mj1(89)                  !* profile of divergence at (160,89)   (Red sea side)
-            DO ji = mi0(160), mi1(160) 
-               hdiv_160_89_kt(:) = hdiv_160_89(:)
-               DO jk = 1, 18                              ! increase the inflow from the Indian   (div <0) 
-                  hdiv_160_89_kt(jk) = hdiv_160_89(jk) - zemp_red / (10. * e1v(ji,jj) * fse3v(ji,jj,jk) )
-               END DO
-               hdivn(ji, jj,:) = hdivn(ji, jj,:) + hdiv_160_89_kt(:)
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'tra' )         !  update (ta,sa)  ! (call by traadv module)
-         !                  ! --------=======- !
-         !
-         DO jj = mj0(88), mj1(88)              !** (161,88)   (Gulf of Aden side, north point)
-            DO ji = mi0(161), mi1(161) 
-               DO jk = 1, jpkm1                         ! surf inflow + reciculation (from Gulf of Aden)
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_161_88_kt(jk) * tsn(ji,jj,jk,jp_tem)
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_161_88_kt(jk) * tsn(ji,jj,jk,jp_sal)
-               END DO
-            END DO
-         END DO
-         DO jj = mj0(87), mj1(87)              !** (161,87)   (Gulf of Aden side, south point)
-            DO ji = mi0(161), mi1(161) 
-               jk =  21                                 ! deep outflow + recirulation (combined flux)
-               tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + hdiv_161_88(20) * tsn(ji  ,jj+1,20,jp_tem)   &  ! upper recirculation from Gulf of Aden
-                  &                        + hdiv_161_88(21) * tsn(ji  ,jj+1,21,jp_tem)   &  ! deep  recirculation from Gulf of Aden
-                  &                        + hdiv_160_89(16) * tsn(ji-1,jj+2,16,jp_tem)      ! deep inflow from Red sea
-               tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + hdiv_161_88(20) * tsn(ji  ,jj+1,20,jp_sal)   &
-                  &                        + hdiv_161_88(21) * tsn(ji  ,jj+1,21,jp_sal)   &
-                  &                        + hdiv_160_89(16) * tsn(ji-1,jj+2,16,jp_sal)   
-            END DO
-         END DO
-         DO jj = mj0(89), mj1(89)              !** (161,88)   (Red sea side)
-            DO ji = mi0(160), mi1(160)
-               DO jk = 1, 14                            ! surface inflow (from Gulf of Aden)
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_160_89_kt(jk) * tsn(ji+1,jj-1,jk,jp_tem)
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_160_89_kt(jk) * tsn(ji+1,jj-1,jk,jp_sal)
-               END DO
-               !                                  ! deep    outflow (from Red sea)
-               tsa(ji,jj,16,jp_tem) = tsa(ji,jj,16,jp_tem) - hdiv_160_89(16) * tsn(ji,jj,16,jp_tem)
-               tsa(ji,jj,16,jp_sal) = tsa(ji,jj,16,jp_sal) - hdiv_160_89(16) * tsn(ji,jj,16,jp_sal)
-            END DO
-         END DO
-         !
-         !                  ! ---------------- !
-      CASE( 'spg' )         !  update (ua,va)  ! (call by dynspg module)
-         !                  ! --------=======- !
-         ! at this stage, (ua,va) are the after velocity, not the tendancy
-         ! compute the velocity from the divergence at T-point
-         !
-         DO jj = mj0(88), mj1(88)              !** (160,88)   (Gulf of Aden side, north point)
-            DO ji = mi0(160), mi1(160)                   ! 160, not 161 as it is a U-point) 
-               ua(ji,jj,:) = - hdiv_161_88_kt(:) / ( e1t(ji+1,jj) * e2t(ji+1,jj) * fse3t(ji+1,jj,:) )   &
-                  &                              * e2u(ji,jj) * fse3u(ji,jj,:)
-            END DO
-         END DO
-         DO jj = mj0(87), mj1(87)              !** (160,87)   (Gulf of Aden side, south point)
-            DO ji = mi0(160), mi1(160)                   ! 160, not 161 as it is a U-point) 
-               ua(ji,jj,:) = - hdiv_161_87(:) / ( e1t(ji+1,jj) * e2t(ji+1,jj) * fse3t(ji+1,jj,:) )   &
-                  &                           * e2u(ji,jj) * fse3u(ji,jj,:)
-            END DO
-         END DO
-         DO jj = mj0(88), mj1(88)              !** profile of divergence at (160,89)   (Red sea side)
-            DO ji = mi0(160), mi1(160)                   ! 88, not 89 as it is a V-point)
-               va(ji,jj,:) = - hdiv_160_89_kt(:) / ( e1t(ji,jj+1) * e2t(ji,jj+1) * fse3t(ji,jj+1,:) )   &
-                  &                              * e1v(ji,jj) * fse3v(ji,jj,:)
-            END DO
-         END DO
-      END SELECT
-      !
-   END SUBROUTINE cla_bab_el_mandeb
-   
-
-   SUBROUTINE cla_gibraltar( cd_td )
-      !! -------------------------------------------------------------------
-      !!                 ***  ROUTINE cla_gibraltar  ***
-      !!        
-      !! ** Purpose :   update the now horizontal divergence, the tracer 
-      !!              tendancyand the after velocity in vicinity of Gibraltar 
-      !!              strait ( Persian Gulf - Indian ocean ).
-      !!
-      !! ** Method :
-      !!                     _______________________            
-      !!      deep  zio_flow /====|///////|====> surf. zio_flow
-      !!    + deep  zrecirc  \----|///////|     (+balance of emp)
-      !! 102                      u///////u
-      !!      mid.  recicul    <--|///////|<==== deep  zio_flow
-      !!                     _____|_______|_____  
-      !!      surf. zio_flow ====>|///////|       
-      !!    (+balance of emp)     |///////|
-      !! 101                      u///////|             
-      !!      mid.  recicul    -->|///////|               Caution: zrecirc split into 
-      !!      deep  zrecirc  ---->|///////|                  upper & bottom recirculation
-      !!                   _______|_______|_______ 
-      !!                     139     140     141  
-      !!
-      !!---------------------------------------------------------------------
-      CHARACTER(len=1), INTENT(in) ::   cd_td   ! ='div' update the divergence
-      !                                         ! ='tra' update the tracers
-      !                                         ! ='spg' update after velocity
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zemp_med     ! temporary scalar
-      REAL(wp) ::   zio_flow, zrecirc_upp, zrecirc_mid, zrecirc_bot
-      !!---------------------------------------------------------------------
-      !
-      SELECT CASE( cd_td ) 
-      !                     ! ---------------- !
-      CASE( 'ini' )         !  initialisation  ! 
-         !                  ! ---------------- ! 
-         !                                     !** initialization of the velocity
-         hdiv_139_101(:) = 0.e0                     !  139,101 (Atlantic side, south point)
-         hdiv_139_102(:) = 0.e0                     !  139,102 (Atlantic side, north point)
-         hdiv_141_102(:) = 0.e0                     !  141,102 (Med sea  side)
-            
-         !                                     !** imposed transport
-         zio_flow    = 0.8e6                        ! inflow surface  water
-         zrecirc_mid = 0.7e6                        ! middle recirculation water
-         zrecirc_upp = 2.5e6                        ! upper  recirculation water
-         zrecirc_bot = 3.5e6                        ! bottom recirculation water
-         !
-         DO jj = mj0(101), mj1(101)            !** profile of hdiv at 139,101 (Atlantic side, south point)
-            DO ji = mi0(139), mi1(139)         !-----------------------------
-               DO jk = 1, 14                        ! surface in/out flow (Atl -> Med)   (div >0)
-                  hdiv_139_101(jk) = + zio_flow / ( 14. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               DO jk = 15, 20                       ! middle  reciculation (Atl 101 -> Atl 102)   (div >0)   
-                  hdiv_139_101(jk) = + zrecirc_mid / ( 6. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               !                                    ! upper reciculation (Atl 101 -> Atl 101)   (div >0)
-               hdiv_139_101(21) =               + zrecirc_upp / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               !
-               !                                    ! upper & bottom reciculation (Atl 101 -> Atl 101 & 102)   (div >0)
-               hdiv_139_101(22) = ( zrecirc_bot - zrecirc_upp ) / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)            !** profile of hdiv at 139,102 (Atlantic side, north point)
-            DO ji = mi0(139), mi1(139)         !-----------------------------
-               DO jk = 15, 20                       ! middle reciculation (Atl 101 -> Atl 102)   (div <0)                
-                  hdiv_139_102(jk) = - zrecirc_mid / ( 6. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               !                                    ! outflow of Mediterranean sea + deep recirculation   (div <0) 
-               hdiv_139_102(22) = - ( zio_flow + zrecirc_bot ) / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)            !** velocity profile at 141,102  (Med sea side)
-            DO ji = mi0(141), mi1(141)         !------------------------------
-               DO  jk = 1, 14                       ! surface inflow in the Med     (div <0)
-                  hdiv_141_102(jk) = - zio_flow / ( 14. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               !                                    ! deep    outflow toward the Atlantic    (div >0) 
-               hdiv_141_102(21)    = + zio_flow / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'div' )         !   update hdivn   ! (call by divcur module)
-         !                  ! ---------=====-- ! 
-         !                                     !** emp on the Mediterranean Sea  (div >0) 
-         zemp_med = 0.e0                       !-------------------------------
-         DO jj = mj0(96), mj1(110)                  ! sum over the Med sea
-            DO ji = mi0(141),mi1(181)
-               zemp_med = zemp_med + emp(ji,jj) * e1t(ji,jj) * e2t(ji,jj) * tmask_i(ji,jj) 
-            END DO
-         END DO
-         DO jj = mj0(96), mj1(96)                   ! minus 2 points in Red Sea 
-            DO ji = mi0(148),mi1(148)
-               zemp_med = zemp_med - emp(ji,jj) * e1t(ji,jj) * e2t(ji,jj) * tmask_i(ji,jj)
-            END DO
-            DO ji = mi0(149),mi1(149)
-               zemp_med = zemp_med - emp(ji,jj) * e1t(ji,jj) * e2t(ji,jj) * tmask_i(ji,jj)
-            END DO
-         END DO
-         IF( lk_mpp )   CALL mpp_sum( zemp_med )    ! sum with other processors value
-         zemp_med = zemp_med * 1.e-3                ! convert in m3
-         !
-         !                                     !** Correct hdivn (including emp adjustment)
-         !                                     !-------------------------------------------
-         DO jj = mj0(101), mj1(101)                 !* 139,101 (Atlantic side, south point)
-            DO ji = mi0(139), mi1(139) 
-               hdiv_139_101_kt(:) = hdiv_139_101(:)      
-               DO jk = 1, 14                              ! increase the inflow from the Atlantic   (div >0) 
-                  hdiv_139_101_kt(jk) = hdiv_139_101(jk) + zemp_med / ( 14. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               hdivn(ji, jj,:) = hdivn(ji, jj,:) + hdiv_139_101_kt(:)
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)                 !* 139,102 (Atlantic side, north point)
-            DO ji = mi0(139), mi1(139) 
-               hdivn(ji,jj,:) = hdivn(ji,jj,:) + hdiv_139_102(:)
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)                 !* 141,102 (Med side)
-            DO ji = mi0(141), mi1(141) 
-               hdiv_141_102(:) = hdiv_141_102(:)
-               DO jk = 1, 14                              ! increase the inflow from the Atlantic   (div <0)
-                  hdiv_141_102_kt(jk) = hdiv_141_102(jk) - zemp_med / ( 14. * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               hdivn(ji, jj,:) = hdivn(ji, jj,:) + hdiv_141_102_kt(:)
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'tra' )         !  update (ta,sa)  ! (call by traadv module)
-         !                  ! --------=======- !
-         !
-         DO jj = mj0(101), mj1(101)            !** 139,101 (Atlantic side, south point)   (div >0)
-            DO ji = mi0(139), mi1(139) 
-               DO jk = 1, jpkm1                         ! surf inflow + mid. & bottom reciculation (from Atlantic)	
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_139_101_kt(jk) * tsn(ji,jj,jk,jp_tem)
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_139_101_kt(jk) * tsn(ji,jj,jk,jp_sal)
-               END DO
-            END DO
-         END DO
-         !
-         DO jj = mj0(102), mj1(102)            !** 139,102 (Atlantic side, north point)   (div <0)
-            DO ji = mi0(139), mi1(139) 
-               DO jk = 15, 20                            ! middle  reciculation (Atl 101 -> Atl 102)   (div <0)
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_139_102(jk) * tsn(ji,jj-1,jk,jp_tem)  ! middle Atlantic recirculation
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_139_102(jk) * tsn(ji,jj-1,jk,jp_sal)
-               END DO
-               !                                         ! upper & bottom Atl. reciculation (Atl 101 -> Atl 102) - (div <0)
-               !                                         ! deep Med flow                    (Med 102 -> Atl 102) - (div <0)
-               tsa(ji,jj,22,jp_tem) = tsa(ji,jj,22,jp_tem) + hdiv_141_102(21) * tsn(ji+2,jj,21,jp_tem)   &  ! deep Med flow  
-                  &                        + hdiv_139_101(21) * tsn(ji,jj-1,21,jp_tem)   &  ! upper  Atlantic recirculation  
-                  &                        + hdiv_139_101(22) * tsn(ji,jj-1,22,jp_tem)      ! bottom Atlantic recirculation  
-               tsa(ji,jj,22,jp_sal) = tsa(ji,jj,22,jp_sal) + hdiv_141_102(21) * tsn(ji+2,jj,21,jp_sal)   &
-                  &                        + hdiv_139_101(21) * tsn(ji,jj-1,21,jp_sal)   &
-                  &                        + hdiv_139_101(22) * tsn(ji,jj-1,22,jp_sal) 
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)                 !* 141,102 (Med side)   (div <0)
-            DO ji = mi0(141), mi1(141) 
-               DO jk = 1, 14                             ! surface flow from Atlantic to Med sea
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_141_102_kt(jk) * tsn(ji-2,jj-1,jk,jp_tem)
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_141_102_kt(jk) * tsn(ji-2,jj-1,jk,jp_sal)
-               END DO
-               !                                         ! deeper flow from Med sea to Atlantic
-               tsa(ji,jj,21,jp_tem) = tsa(ji,jj,21,jp_tem) - hdiv_141_102(21) * tsn(ji,jj,21,jp_tem)
-               tsa(ji,jj,21,jp_sal) = tsa(ji,jj,21,jp_sal) - hdiv_141_102(21) * tsn(ji,jj,21,jp_sal)
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'spg' )         !  update (ua,va)  ! (call by dynspg module)
-         !                  ! --------=======- !
-         ! at this stage, (ua,va) are the after velocity, not the tendancy
-         ! compute the velocity from the divergence at T-point
-         !
-         DO jj = mj0(101), mj1(101)            !** 139,101 (Atlantic side, south point)
-            DO ji = mi0(139), mi1(139)                    ! div >0 => ua >0, same sign
-               ua(ji,jj,:) = hdiv_139_101_kt(:) / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,:) )   &
-                  &                             * e2u(ji,jj) * fse3u(ji,jj,:)
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)            !** 139,102 (Atlantic side, north point)
-            DO ji = mi0(139), mi1(139)                    ! div <0 => ua <0, same sign
-               ua(ji,jj,:) = hdiv_139_102(:) / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,:) )   &
-                  &                          * e2u(ji,jj) * fse3u(ji,jj,:)   
-            END DO
-         END DO
-         DO jj = mj0(102), mj1(102)            !** 140,102 (Med side) (140 not 141 as it is a U-point)
-            DO ji = mi0(140), mi1(140)                    ! div >0 => ua <0, opposite sign
-               ua(ji,jj,:) = - hdiv_141_102(:) / ( e1t(ji+1,jj) * e2t(ji+1,jj) * fse3t(ji+1,jj,:) )   &
-                  &                            * e2u(ji,jj) * fse3u(ji,jj,:)
-            END DO
-         END DO
-         !
-      END SELECT
-      !
-   END SUBROUTINE cla_gibraltar
-
-
-   SUBROUTINE cla_hormuz( cd_td )
-      !! -------------------------------------------------------------------
-      !!                   ***  ROUTINE div_hormuz  ***
-      !!              
-      !! ** Purpose :   update the now horizontal divergence, the tracer 
-      !!              tendancyand the after velocity in vicinity of Hormuz 
-      !!              strait ( Persian Gulf - Indian ocean ).
-      !!
-      !! ** Method  :   Hormuz strait
-      !!            ______________   
-      !!            |/////|<==      surface inflow
-      !!        94  |/////|     
-      !!            |/////|==>      deep    outflow
-      !!            |_____|_______
-      !!              171    172     
-      !!---------------------------------------------------------------------
-      CHARACTER(len=1), INTENT(in) ::   cd_td   ! ='ini' initialisation
-      !!                                        ! ='div' update the divergence
-      !!                                        ! ='tra' update the tracers
-      !!                                        ! ='spg' update after velocity
-      !!
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zio_flow     ! temporary scalar
-      !!---------------------------------------------------------------------
-      !
-      SELECT CASE( cd_td ) 
-      !                     ! ---------------- !
-      CASE( 'ini' )         !  initialisation  ! 
-         !                  ! ---------------- ! 
-         !                                     !** profile of horizontal divergence due to cross-land advection
-         zio_flow  = 1.e6                          ! imposed in/out flow
-         !
-         hdiv_172_94(:) = 0.e0         
-         !
-         DO jj = mj0(94), mj1(94)                  ! in/out flow at (i,j) = (172,94)
-            DO ji = mi0(172), mi1(172) 
-               DO jk = 1, 8                            ! surface inflow  (Indian ocean to Persian Gulf) (div<0)
-                  hdiv_172_94(jk) = - ( zio_flow / 8.e0 * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-               DO jk = 16, 18                          ! deep    outflow (Persian Gulf to Indian ocean) (div>0)
-                  hdiv_172_94(jk) = + ( zio_flow / 3.e0 * e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-            END DO
-         END DO
-         !                                     !** T & S profile in the Hormuz strait (use in deep outflow)
-         !      Temperature       and         Salinity
-         t_171_94_hor(:)  = 0.e0   ;   s_171_94_hor(:)  = 0.e0
-         t_171_94_hor(16) = 18.4   ;   s_171_94_hor(16) = 36.27
-         t_171_94_hor(17) = 17.8   ;   s_171_94_hor(17) = 36.4
-         t_171_94_hor(18) = 16.    ;   s_171_94_hor(18) = 36.27
-         !
-         !                  ! ---------------- !
-      CASE( 'div' )         !   update hdivn   ! (call by divcur module)
-         !                  ! ---------=====-- ! 
-         !                                   
-         DO jj = mj0(94), mj1(94)              !** 172,94 (Indian ocean side)
-            DO ji = mi0(172), mi1(172) 
-               hdivn(ji,jj,:) = hdivn(ji,jj,:) + hdiv_172_94(:)
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'tra' )         !  update (ta,sa)  ! (call by traadv module)
-         !                  ! --------=======- !
-         !                          
-         DO jj = mj0(94), mj1(94)              !** 172,94 (Indian ocean side)
-            DO ji = mi0(172), mi1(172) 
-               DO jk = 1, 8                          ! surface inflow   (Indian ocean to Persian Gulf) (div<0)
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_172_94(jk) * tsn(ji,jj,jk,jp_tem) 
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_172_94(jk) * tsn(ji,jj,jk,jp_sal) 
-               END DO
-               DO jk = 16, 18                        ! deep outflow     (Persian Gulf to Indian ocean) (div>0)
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) - hdiv_172_94(jk) * t_171_94_hor(jk)
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) - hdiv_172_94(jk) * s_171_94_hor(jk)
-               END DO
-            END DO
-         END DO
-         !                  ! ---------------- !
-      CASE( 'spg' )         !  update (ua,va)  ! (call by dynspg module)
-         !                  ! --------=======- !
-         ! No barotropic flow through Hormuz strait
-         ! at this stage, (ua,va) are the after velocity, not the tendancy
-         ! compute the velocity from the divergence at T-point
-         DO jj = mj0(94), mj1(94)              !** 171,94 (Indian ocean side) (171 not 172 as it is the western U-point)
-            DO ji = mi0(171), mi1(171)                ! div >0 => ua >0, opposite sign
-               ua(ji,jj,:) = - hdiv_172_94(:) / ( e1t(ji+1,jj) * e2t(ji+1,jj) * fse3t(ji+1,jj,:) )   &
-                  &                           * e2u(ji,jj) * fse3u(ji,jj,:)
-            END DO
-         END DO
-         !
-      END SELECT
-      !
-   END SUBROUTINE cla_hormuz
-   
-   !!======================================================================
-END MODULE cla
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 6041)
@@ -3744,9 +3744,9 @@
       LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
       INTEGER, OPTIONAL, INTENT(in   ) ::   karea     ! proc number
-      !!
+      !
       CHARACTER(len=80) ::   clfile
       INTEGER           ::   iost
       !!----------------------------------------------------------------------
-
+      !
       ! adapt filename
       ! ----------------
@@ -3761,5 +3761,5 @@
       knum=get_unit()
 #endif
-
+      !
       iost=0
       IF( cdacce(1:6) == 'DIRECT' )  THEN
@@ -3794,7 +3794,8 @@
          STOP 'ctl_opn bad opening'
       ENDIF
-
+      !
    END SUBROUTINE ctl_opn
 
+
    SUBROUTINE ctl_nam ( kios, cdnam, ldwp )
       !!----------------------------------------------------------------------
@@ -3805,26 +3806,25 @@
       !! ** Method  :   Fortan open
       !!----------------------------------------------------------------------
-      INTEGER          , INTENT(inout) ::   kios      ! IO status after reading the namelist
-      CHARACTER(len=*) , INTENT(in   ) ::   cdnam     ! group name of namelist for which error occurs
-      CHARACTER(len=4)                 ::   clios     ! string to convert iostat in character for print
-      LOGICAL          , INTENT(in   ) ::   ldwp      ! boolean term for print
-      !!----------------------------------------------------------------------
-
-      ! 
-      ! ----------------
-      WRITE (clios, '(I4.0)') kios
+      INTEGER         , INTENT(inout) ::   kios    ! IO status after reading the namelist
+      CHARACTER(len=*), INTENT(in   ) ::   cdnam   ! group name of namelist for which error occurs
+      CHARACTER(len=4)                ::   clios   ! string to convert iostat in character for print
+      LOGICAL         , INTENT(in   ) ::   ldwp    ! boolean term for print
+      !!----------------------------------------------------------------------
+      !
+      WRITE (clios, '(I4.0)')   kios
       IF( kios < 0 ) THEN         
-         CALL ctl_warn( 'W A R N I N G:  end of record or file while reading namelist ' &
- &           // TRIM(cdnam) // ' iostat = ' // TRIM(clios) )
-      ENDIF
-
+         CALL ctl_warn( 'end of record or file while reading namelist '   &
+            &           // TRIM(cdnam) // ' iostat = ' // TRIM(clios) )
+      ENDIF
+      !
       IF( kios > 0 ) THEN
-         CALL ctl_stop( 'E R R O R :   misspelled variable in namelist ' &
- &           // TRIM(cdnam) // ' iostat = ' // TRIM(clios) )
+         CALL ctl_stop( 'misspelled variable in namelist '   &
+            &           // TRIM(cdnam) // ' iostat = ' // TRIM(clios) )
       ENDIF
       kios = 0
       RETURN
-      
+      !
    END SUBROUTINE ctl_nam
+
 
    INTEGER FUNCTION get_unit()
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfc1d_c2d.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfc1d_c2d.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfc1d_c2d.F90	(revision 6041)
@@ -0,0 +1,209 @@
+MODULE ldfc1d_c2d
+   !!======================================================================
+   !!                    ***  MODULE  ldfc1d_c2d  ***
+   !! Ocean physics:  profile and horizontal shape of lateral eddy coefficients 
+   !!=====================================================================
+   !! History :  3.7  ! 2013-12  (G. Madec)  restructuration/simplification of aht/aeiv specification,
+   !!                 !                      add velocity dependent coefficient and optional read in file
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ldf_c1d       : ah reduced by 1/4 on the vertical (tanh profile, inflection at 300m) 
+   !!   ldf_c2d       : ah = F(e1,e2) (laplacian or = F(e1^3,e2^3) (bilaplacian)
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! distribued memory computing library
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   ldf_c1d   ! called by ldftra and ldfdyn modules
+   PUBLIC   ldf_c2d   ! called by ldftra and ldfdyn modules
+
+ 
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE ldf_c1d( cd_type, prat, pahs1, pahs2, pah1, pah2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_c1d  ***
+      !!              
+      !! ** Purpose :   1D eddy diffusivity/viscosity coefficients
+      !!
+      !! ** Method  :   1D eddy diffusivity coefficients F( depth )
+      !!                Reduction by prat from surface to bottom 
+      !!                hyperbolic tangent profile with inflection point 
+      !!                at zh=500m and a width of zw=200m
+      !!
+      !!   cd_type = TRA      pah1, pah2 defined at U- and V-points
+      !!             DYN      pah1, pah2 defined at T- and F-points
+      !!----------------------------------------------------------------------
+      CHARACTER(len=2)                , INTENT(in   ) ::   cd_type        ! DYNamique or TRAcers
+      REAL(wp)                        , INTENT(in   ) ::   prat           ! ratio surface/deep values           [-]
+      REAL(wp), DIMENSION(jpi,jpj)    , INTENT(in   ) ::   pahs1, pahs2   ! surface value of eddy coefficient   [m2/s]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pah1 , pah2    ! eddy coefficient                    [m2/s]
+      !
+      INTEGER  ::   ji, jj, jk      ! dummy loop indices
+      REAL(wp) ::   zh, zc, zdep1   ! local scalars
+      REAL(wp) ::   zw    , zdep2   !   -      -
+      !!----------------------------------------------------------------------
+
+      ! initialization of the profile
+      zh =  500._wp              ! depth    of the inflection point [m]
+      zw =  1._wp / 200._wp      ! width^-1     -        -      -   [1/m]
+      !                          ! associated coefficient           [-]
+      zc = ( 1._wp - prat ) / ( 1._wp + TANH( zh * zw) )
+      !
+      !
+      SELECT CASE( cd_type )        ! point of calculation
+      !
+      CASE( 'DYN' )                     ! T- and F-points
+         DO jk = 1, jpk                      ! pah1 at T-point
+            pah1(:,:,jk) = pahs1(:,:) * (  prat + zc * ( 1._wp + TANH( - ( fsdept(:,:,jk) - zh ) * zw) )  ) * tmask(:,:,jk)
+         END DO
+         DO jk = 1, jpk                      ! pah2 at F-point (zdep2 is an approximation in zps-coord.)
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  zdep2 = (  fsdept(ji,jj+1,jk) + fsdept(ji+1,jj+1,jk)   &
+                     &     + fsdept(ji,jj  ,jk) + fsdept(ji+1,jj  ,jk)  ) * 0.25_wp
+                  pah2(ji,jj,jk) = pahs2(ji,jj) * (  prat + zc * ( 1._wp + TANH( - ( zdep2 - zh ) * zw) )  ) * fmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( pah2, 'F', 1. )   ! Lateral boundary conditions
+         !
+      CASE( 'TRA' )                     ! U- and V-points (zdep1 & 2 are an approximation in zps-coord.)
+         DO jk = 1, jpk
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1
+                  zdep1 = (  fsdept(ji,jj,jk) + fsdept(ji+1,jj,jk)  ) * 0.5_wp
+                  zdep2 = (  fsdept(ji,jj,jk) + fsdept(ji,jj+1,jk)  ) * 0.5_wp
+                  pah1(ji,jj,jk) = pahs1(ji,jj) * (  prat + zc * ( 1._wp + TANH( - ( zdep1 - zh ) * zw) )  ) * umask(ji,jj,jk)
+                  pah2(ji,jj,jk) = pahs2(ji,jj) * (  prat + zc * ( 1._wp + TANH( - ( zdep2 - zh ) * zw) )  ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( pah1, 'U', 1. )   ! Lateral boundary conditions
+         CALL lbc_lnk( pah2, 'V', 1. )   
+         !
+      END SELECT
+      !
+   END SUBROUTINE ldf_c1d
+
+
+   SUBROUTINE ldf_c2d( cd_type, cd_op, pah0, pah1, pah2 )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_c2d  ***
+      !!              
+      !! ** Purpose :   2D eddy diffusivity/viscosity coefficients
+      !!
+      !! ** Method  :   2D eddy diffusivity coefficients F( e1 , e2 )
+      !!       laplacian   operator :   ah proportional to the scale factor      [m2/s]
+      !!       bilaplacian operator :   ah proportional to the (scale factor)^3  [m4/s]
+      !!       In both cases, pah0 is the maximum value reached by the coefficient 
+      !!       at the Equator in case of e1=ra*rad= ~111km, not over the whole domain.
+      !!
+      !!   cd_type = TRA      pah1, pah2 defined at U- and V-points
+      !!             DYN      pah1, pah2 defined at T- and F-points
+      !!----------------------------------------------------------------------
+      CHARACTER(len=3)                , INTENT(in   ) ::   cd_type      ! DYNamique or TRAcers
+      CHARACTER(len=3)                , INTENT(in   ) ::   cd_op        ! operator: LAPlacian BiLaPlacian
+      REAL(wp)                        , INTENT(in   ) ::   pah0         ! eddy coefficient   [m2/s or m4/s]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   pah1, pah2   ! eddy coefficient   [m2/s or m4/s]
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   za00, zd_max, zemax1, zemax2   ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      zd_max = ra * rad       ! = 1 degree at the equator in meters
+      !
+      IF(lwp) THEN
+         WRITE(numout,*) 'ldf_c2d :     aht = rn_aht0 *  max(e1,e2)/e_equator     (  laplacian) '
+         WRITE(numout,*) '~~~~~~~       or  = rn_bht0 * [max(e1,e2)/e_equator]**3 (bilaplacian)'
+         WRITE(numout,*)
+      ENDIF
+      !
+      SELECT CASE( cd_type )        !==  surface values  ==!  (depending on DYN/TRA)
+      !
+      CASE( 'DYN' )                     ! T- and F-points
+         IF( cd_op == 'LAP' ) THEN            ! laplacian operator
+            IF(lwp) WRITE(numout,*) '              momentum laplacian coeffcients = rn_aht0/e_equ * max(e1,e2)'
+            za00 = pah0 / zd_max
+            DO jj = 1, jpj 
+               DO ji = 1, jpi 
+                  zemax1 = MAX( e1t(ji,jj), e2t(ji,jj) ) * tmask(ji,jj,1)
+                  zemax2 = MAX( e1f(ji,jj), e2f(ji,jj) ) * fmask(ji,jj,1)
+                  pah1(ji,jj,1) = za00 * zemax1
+                  pah2(ji,jj,1) = za00 * zemax2
+               END DO
+            END DO
+         ELSEIF( cd_op == 'BLP' ) THEN     ! bilaplacian operator
+            IF(lwp) WRITE(numout,*) '              momentum bilaplacian coeffcients = rn_bht0/e_equ * max(e1,e2)**3'
+            za00 = pah0 / ( zd_max * zd_max * zd_max )
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zemax1 = MAX( e1t(ji,jj), e2t(ji,jj) ) * tmask(ji,jj,1)
+                  zemax2 = MAX( e1f(ji,jj), e2f(ji,jj) ) * fmask(ji,jj,1)
+                  pah1(ji,jj,1) = za00 * zemax1 * zemax1 * zemax1 
+                  pah2(ji,jj,1) = za00 * zemax2 * zemax2 * zemax2 
+               END DO
+            END DO
+         ELSE                                ! NO diffusion/viscosity
+            CALL ctl_stop( 'ldf_c2d: ', cd_op, ' case. Unknown lateral operator ' )
+         ENDIF
+         !                                !  deeper values  (LAP and BLP cases)
+         DO jk = 2, jpk
+            pah1(:,:,jk) = pah1(:,:,1) * tmask(:,:,jk) 
+            pah2(:,:,jk) = pah2(:,:,1) * fmask(:,:,jk) 
+         END DO
+         !
+      CASE( 'TRA' )                     ! U- and V-points (approximation in zps-coord.)
+         IF( cd_op == 'LAP' ) THEN            ! laplacian operator
+            IF(lwp) WRITE(numout,*) '              tracer laplacian coeffcients = rn_aht0/e_equ * max(e1,e2)'
+            za00 = pah0 / zd_max
+            DO jj = 1, jpj 
+               DO ji = 1, jpi 
+                  zemax1 = MAX( e1u(ji,jj), e2u(ji,jj) ) * umask(ji,jj,1)
+                  zemax2 = MAX( e1v(ji,jj), e2v(ji,jj) ) * vmask(ji,jj,1)
+                  pah1(ji,jj,1) = za00 * zemax1
+                  pah2(ji,jj,1) = za00 * zemax2
+               END DO
+            END DO
+         ELSEIF( cd_op == 'BLP' ) THEN      ! bilaplacian operator (NB: square root of the coeff)
+            IF(lwp) WRITE(numout,*) '              tracer bilaplacian coeffcients = rn_bht0/e_equ * max(e1,e2)**3'
+            za00 = pah0 / ( zd_max * zd_max * zd_max )
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zemax1 = MAX( e1u(ji,jj), e2u(ji,jj) ) * umask(ji,jj,1) 
+                  zemax2 = MAX( e1v(ji,jj), e2v(ji,jj) ) * vmask(ji,jj,1) 
+                  pah1(ji,jj,1) = za00 * zemax1 * zemax1 * zemax1 
+                  pah2(ji,jj,1) = za00 * zemax2 * zemax2 * zemax2 
+               END DO
+            END DO
+         ELSE                                ! NO diffusion/viscosity
+            CALL ctl_stop( 'ldf_c2d: ', cd_op, ' case. Unknown lateral operator ' )
+         ENDIF
+         !                                !  deeper values  (LAP and BLP cases)
+         DO jk = 2, jpk
+            pah1(:,:,jk) = pah1(:,:,1) * umask(:,:,jk) 
+            pah2(:,:,jk) = pah2(:,:,1) * vmask(:,:,jk) 
+         END DO
+         !
+      END SELECT
+      !
+   END SUBROUTINE ldf_c2d
+
+   !!======================================================================
+END MODULE ldfc1d_c2d
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn.F90	(revision 6041)
@@ -6,19 +6,20 @@
    !! History :  OPA  ! 1997-07  (G. Madec)  multi dimensional coefficients
    !!   NEMO     1.0  ! 2002-09  (G. Madec)  F90: Free form and module
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   ldf_dyn_init : initialization, namelist read, and parameters control
-   !!   ldf_dyn_c3d   : 3D eddy viscosity coefficient initialization
-   !!   ldf_dyn_c2d   : 2D eddy viscosity coefficient initialization
-   !!   ldf_dyn_c1d   : 1D eddy viscosity coefficient initialization
+   !!            3.7  ! 2014-01  (F. Lemarie, G. Madec)  restructuration/simplification of ahm specification,
+   !!                 !                                  add velocity dependent coefficient and optional read in file
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   ldf_dyn_init  : initialization, namelist read, and parameters control
+   !!   ldf_dyn       : update lateral eddy viscosity coefficients at each time step 
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers   
    USE dom_oce         ! ocean space and time domain 
-   USE ldfdyn_oce      ! ocean dynamics lateral physics
    USE phycst          ! physical constants
-   USE ldfslp          ! ???
-   USE ioipsl
+   USE ldfc1d_c2d      ! lateral diffusion: 1D and 2D cases
+   !
    USE in_out_manager  ! I/O manager
+   USE iom             ! I/O module for ehanced bottom friction file
+   USE timing          ! Timing
    USE lib_mpp         ! distribued memory computing library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
@@ -28,14 +29,31 @@
    PRIVATE
 
-   PUBLIC   ldf_dyn_init   ! called by opa.F90
-
-  INTERFACE ldf_zpf
-     MODULE PROCEDURE ldf_zpf_1d, ldf_zpf_1d_3d, ldf_zpf_3d
-  END INTERFACE
+   PUBLIC   ldf_dyn_init   ! called by nemogcm.F90
+   PUBLIC   ldf_dyn        ! called by step.F90
+
+   !                                                !!* Namelist namdyn_ldf : lateral mixing on momentum *
+   LOGICAL , PUBLIC ::   ln_dynldf_lap   !: laplacian operator
+   LOGICAL , PUBLIC ::   ln_dynldf_blp   !: bilaplacian operator
+   LOGICAL , PUBLIC ::   ln_dynldf_lev   !: iso-level direction
+   LOGICAL , PUBLIC ::   ln_dynldf_hor   !: horizontal (geopotential) direction
+   LOGICAL , PUBLIC ::   ln_dynldf_iso   !: iso-neutral direction
+   INTEGER , PUBLIC ::   nn_ahm_ijk_t    !: choice of time & space variations of the lateral eddy viscosity coef.
+   REAL(wp), PUBLIC ::   rn_ahm_0        !: lateral laplacian eddy viscosity            [m2/s]
+   REAL(wp), PUBLIC ::   rn_ahm_b        !: lateral laplacian background eddy viscosity [m2/s]
+   REAL(wp), PUBLIC ::   rn_bhm_0        !: lateral bilaplacian eddy viscosity          [m4/s]
+
+   LOGICAL , PUBLIC ::   l_ldfdyn_time   !: flag for time variation of the lateral eddy viscosity coef.
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ahmt, ahmf   !: eddy diffusivity coef. at U- and V-points   [m2/s or m4/s]
+
+   REAL(wp) ::   r1_12   = 1._wp / 12._wp    ! =1/12
+   REAL(wp) ::   r1_4    = 0.25_wp           ! =1/4
+   REAL(wp) ::   r1_288  = 1._wp / 288._wp   ! =1/( 12^2 * 2 )
 
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$ 
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -49,29 +67,27 @@
       !! ** Purpose :   set the horizontal ocean dynamics physics
       !!
-      !! ** Method  :  
-      !!      -  default option : ahm = constant coef. = rn_ahm_0 (namelist)
-      !!      - 'key_dynldf_c1d': ahm = F(depth)                     see ldf_dyn_c1d.h90
-      !!      - 'key_dynldf_c2d': ahm = F(latitude,longitude)        see ldf_dyn_c2d.h90
-      !!      - 'key_dynldf_c3d': ahm = F(latitude,longitude,depth)  see ldf_dyn_c3d.h90
-      !!
-      !!      N.B. User defined include files.  By default, 3d and 2d coef.
-      !!      are set to a constant value given in the namelist and the 1d
-      !!      coefficients are initialized to a hyperbolic tangent vertical
-      !!      profile.
-      !!
-      !! Reference :   Madec, G. and M. Imbard, 1996: Climate Dynamics, 12, 381-388.
-      !!----------------------------------------------------------------------
-      INTEGER ::   ioptio         ! ???
-      INTEGER ::   ios            ! Local : output status for namelist read
-      LOGICAL ::   ll_print = .FALSE.    ! Logical flag for printing viscosity coef.
-      !! 
-      NAMELIST/namdyn_ldf/ ln_dynldf_lap  , ln_dynldf_bilap,                  &
-         &                 ln_dynldf_level, ln_dynldf_hor  , ln_dynldf_iso,   &
-         &                 rn_ahm_0_lap   , rn_ahmb_0      , rn_ahm_0_blp ,   &
-         &                 rn_cmsmag_1    , rn_cmsmag_2    , rn_cmsh,         &
-         &                 rn_ahm_m_lap   , rn_ahm_m_blp
-
-   !!----------------------------------------------------------------------
-
+      !! ** Method  :   the eddy viscosity coef. specification depends on:
+      !!              - the operator:
+      !!             ln_dynldf_lap = T     laplacian operator
+      !!             ln_dynldf_blp = T   bilaplacian operator
+      !!              - the parameter nn_ahm_ijk_t:
+      !!    nn_ahm_ijk_t  =  0 => = constant
+      !!                  = 10 => = F(z) :     = constant with a reduction of 1/4 with depth 
+      !!                  =-20 => = F(i,j)     = shape read in 'eddy_viscosity.nc' file
+      !!                  = 20    = F(i,j)     = F(e1,e2) or F(e1^3,e2^3) (lap or bilap case)
+      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_viscosity.nc'  file
+      !!                  = 30    = F(i,j,k)   = 2D (case 20) + decrease with depth (case 10)
+      !!                  = 31    = F(i,j,k,t) = F(local velocity) (  |u|e  /12   laplacian operator
+      !!                                                           or |u|e^3/12 bilaplacian operator )
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk                ! dummy loop indices
+      INTEGER  ::   ierr, inum, ios   ! local integer
+      REAL(wp) ::   zah0              ! local scalar
+      !
+      NAMELIST/namdyn_ldf/ ln_dynldf_lap, ln_dynldf_blp,                  &
+         &                 ln_dynldf_lev, ln_dynldf_hor, ln_dynldf_iso,   &
+         &                 nn_ahm_ijk_t , rn_ahm_0, rn_ahm_b, rn_bhm_0
+      !!----------------------------------------------------------------------
+      !
       REWIND( numnam_ref )              ! Namelist namdyn_ldf in reference namelist : Lateral physics
       READ  ( numnam_ref, namdyn_ldf, IOSTAT = ios, ERR = 901)
@@ -88,210 +104,191 @@
          WRITE(numout,*) '~~~~~~~'
          WRITE(numout,*) '   Namelist namdyn_ldf : set lateral mixing parameters'
-         WRITE(numout,*) '      laplacian operator                      ln_dynldf_lap   = ', ln_dynldf_lap
-         WRITE(numout,*) '      bilaplacian operator                    ln_dynldf_bilap = ', ln_dynldf_bilap
-         WRITE(numout,*) '      iso-level                               ln_dynldf_level = ', ln_dynldf_level
-         WRITE(numout,*) '      horizontal (geopotential)               ln_dynldf_hor   = ', ln_dynldf_hor
-         WRITE(numout,*) '      iso-neutral                             ln_dynldf_iso   = ', ln_dynldf_iso
-         WRITE(numout,*) '      horizontal laplacian eddy viscosity     rn_ahm_0_lap    = ', rn_ahm_0_lap
-         WRITE(numout,*) '      background viscosity                    rn_ahmb_0       = ', rn_ahmb_0
-         WRITE(numout,*) '      horizontal bilaplacian eddy viscosity   rn_ahm_0_blp    = ', rn_ahm_0_blp
-         WRITE(numout,*) '      upper limit for laplacian eddy visc     rn_ahm_m_lap    = ', rn_ahm_m_lap
-         WRITE(numout,*) '      upper limit for bilap eddy viscosity    rn_ahm_m_blp    = ', rn_ahm_m_blp
-
-      ENDIF
-
-      ahm0     = rn_ahm_0_lap              ! OLD namelist variables defined from DOCTOR namelist variables
-      ahmb0    = rn_ahmb_0
-      ahm0_blp = rn_ahm_0_blp
-
-      ! ... check of lateral diffusive operator on tracers
-      !           ==> will be done in trazdf module
-
-      ! ... Space variation of eddy coefficients
-      ioptio = 0
-#if defined key_dynldf_c3d
-      IF(lwp) WRITE(numout,*) '   momentum mixing coef. = F( latitude, longitude, depth)'
-      ioptio = ioptio+1
-#endif
-#if defined key_dynldf_c2d
-      IF(lwp) WRITE(numout,*) '   momentum mixing coef. = F( latitude, longitude)'
-      ioptio = ioptio+1
-#endif
-#if defined key_dynldf_c1d
-      IF(lwp) WRITE(numout,*) '   momentum mixing coef. = F( depth )'
-      ioptio = ioptio+1
-      IF( ln_sco ) CALL ctl_stop( 'key_dynldf_c1d cannot be used in s-coordinate (ln_sco)' )
-#endif
-      IF( ioptio == 0 ) THEN
-          IF(lwp) WRITE(numout,*) '   momentum mixing coef. = constant  (default option)'
-        ELSEIF( ioptio > 1 ) THEN
-           CALL ctl_stop( 'use only one of the following keys: key_dynldf_c3d, key_dynldf_c2d, key_dynldf_c1d' )
-      ENDIF
-
-
-      IF( ln_dynldf_bilap ) THEN
-         IF(lwp) WRITE(numout,*) '   biharmonic momentum diffusion'
-         IF( .NOT. ln_dynldf_lap ) ahm0 = ahm0_blp   ! Allow spatially varying coefs, which use ahm0 as input
-         IF( ahm0_blp > 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal viscosity coef. ahm0 must be negative' )
-      ELSE
-         IF(lwp) WRITE(numout,*) '   harmonic momentum diff. (default)'
-         IF( ahm0 < 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal viscosity coef. ahm0 must be positive' )
-      ENDIF
-
-
-      ! Lateral eddy viscosity
-      ! ======================
-#if defined key_dynldf_c3d
-      CALL ldf_dyn_c3d( ll_print )   ! ahm = 3D coef. = F( longitude, latitude, depth )
-#elif defined key_dynldf_c2d
-      CALL ldf_dyn_c2d( ll_print )   ! ahm = 1D coef. = F( longitude, latitude )
-#elif defined key_dynldf_c1d
-      CALL ldf_dyn_c1d( ll_print )   ! ahm = 1D coef. = F( depth )
-#else
-                                     ! Constant coefficients
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'inildf: constant eddy viscosity coef. '
-      IF(lwp) WRITE(numout,*) '~~~~~~'
-      IF(lwp) WRITE(numout,*) '        ahm1 = ahm2 = ahm0 =  ',ahm0
-#endif
-     nkahm_smag = 0
-#if defined key_dynldf_smag
-     nkahm_smag = 1
-#endif
-
+         !
+         WRITE(numout,*) '      type :'
+         WRITE(numout,*) '         laplacian operator                   ln_dynldf_lap = ', ln_dynldf_lap
+         WRITE(numout,*) '         bilaplacian operator                 ln_dynldf_blp = ', ln_dynldf_blp
+         !
+         WRITE(numout,*) '      direction of action :'
+         WRITE(numout,*) '         iso-level                            ln_dynldf_lev = ', ln_dynldf_lev
+         WRITE(numout,*) '         horizontal (geopotential)            ln_dynldf_hor = ', ln_dynldf_hor
+         WRITE(numout,*) '         iso-neutral                          ln_dynldf_iso = ', ln_dynldf_iso
+         !
+         WRITE(numout,*) '      coefficients :'
+         WRITE(numout,*) '         type of time-space variation         nn_ahm_ijk_t  = ', nn_ahm_ijk_t
+         WRITE(numout,*) '         lateral laplacian eddy viscosity     rn_ahm_0_lap  = ', rn_ahm_0, ' m2/s'
+         WRITE(numout,*) '         background viscosity (iso case)      rn_ahm_b      = ', rn_ahm_b, ' m2/s'
+         WRITE(numout,*) '         lateral bilaplacian eddy viscosity   rn_ahm_0_blp  = ', rn_bhm_0, ' m4/s'
+      ENDIF
+
+      !                                ! Parameter control
+      IF( .NOT.ln_dynldf_lap .AND. .NOT.ln_dynldf_blp ) THEN
+         IF(lwp) WRITE(numout,*) '   No viscous operator selected. ahmt and ahmf are not allocated'
+         l_ldfdyn_time = .FALSE.
+         RETURN
+      ENDIF
+      !
+      IF( ln_dynldf_blp .AND. ln_dynldf_iso ) THEN     ! iso-neutral bilaplacian not implemented
+         CALL ctl_stop( 'dyn_ldf_init: iso-neutral bilaplacian not coded yet' ) 
+      ENDIF
+
+      ! ... Space/Time variation of eddy coefficients
+      !                                               ! allocate the ahm arrays
+      ALLOCATE( ahmt(jpi,jpj,jpk) , ahmf(jpi,jpj,jpk) , STAT=ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'ldf_dyn_init: failed to allocate arrays')
+      !
+      ahmt(:,:,jpk) = 0._wp                           ! last level always 0  
+      ahmf(:,:,jpk) = 0._wp
+      !
+      !                                               ! value of eddy mixing coef.
+      IF    ( ln_dynldf_lap ) THEN   ;   zah0 =      rn_ahm_0         !   laplacian operator
+      ELSEIF( ln_dynldf_blp ) THEN   ;   zah0 = ABS( rn_bhm_0 )       ! bilaplacian operator
+      ELSE                                                                  ! NO viscous  operator
+         CALL ctl_warn( 'ldf_dyn_init: No lateral viscous operator used ' )
+      ENDIF
+      !
+      l_ldfdyn_time = .FALSE.                         ! no time variation except in case defined below
+      !
+      IF( ln_dynldf_lap .OR. ln_dynldf_blp ) THEN     ! only if a lateral diffusion operator is used
+         !
+         SELECT CASE(  nn_ahm_ijk_t  )                ! Specification of space time variations of ahmt, ahmf
+         !
+         CASE(   0  )      !==  constant  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = constant '
+            ahmt(:,:,:) = zah0 * tmask(:,:,:)
+            ahmf(:,:,:) = zah0 * fmask(:,:,:)
+            !
+         CASE(  10  )      !==  fixed profile  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = F( depth )'
+            ahmt(:,:,1) = zah0 * tmask(:,:,1)                      ! constant surface value
+            ahmf(:,:,1) = zah0 * fmask(:,:,1)
+            CALL ldf_c1d( 'DYN', r1_4, ahmt(:,:,1), ahmf(:,:,1), ahmt, ahmf )
+            !
+         CASE ( -20 )      !== fixed horizontal shape read in file  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = F(i,j) read in eddy_viscosity.nc file'
+            CALL iom_open( 'eddy_viscosity_2D.nc', inum )
+            CALL iom_get ( inum, jpdom_data, 'ahmt_2d', ahmt(:,:,1) )
+            CALL iom_get ( inum, jpdom_data, 'ahmf_2d', ahmf(:,:,1) )
+            CALL iom_close( inum )
+!!gm Question : info for LAP or BLP case  to take into account the SQRT in the bilaplacian case ???
+!!              do we introduce a scaling by the max value of the array, and then multiply by zah0 ????
+!!              better:  check that the max is <=1  i.e. it is a shape from 0 to 1, not a coef that has physical dimension
+            DO jk = 2, jpkm1
+               ahmt(:,:,jk) = ahmt(:,:,1) * tmask(:,:,jk)
+               ahmf(:,:,jk) = ahmf(:,:,1) * fmask(:,:,jk)
+            END DO
+            !
+         CASE(  20  )      !== fixed horizontal shape  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = F( e1, e2 ) or F( e1^3, e2^3 ) (lap. or blp. case)'
+            IF( ln_dynldf_lap )   CALL ldf_c2d( 'DYN', 'LAP', zah0, ahmt, ahmf )    ! surface value proportional to scale factor
+            IF( ln_dynldf_blp )   CALL ldf_c2d( 'DYN', 'BLP', zah0, ahmt, ahmf )    ! surface value proportional to scale factor^3
+            !
+         CASE( -30  )      !== fixed 3D shape read in file  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = F(i,j,k) read in eddy_diffusivity_3D.nc file'
+            CALL iom_open( 'eddy_viscosity_3D.nc', inum )
+            CALL iom_get ( inum, jpdom_data, 'ahmt_3d', ahmt )
+            CALL iom_get ( inum, jpdom_data, 'ahmf_3d', ahmf )
+            CALL iom_close( inum )
+!!gm Question : info for LAP or BLP case  to take into account the SQRT in the bilaplacian case ????
+!!              do we introduce a scaling by the max value of the array, and then multiply by zah0 ????
+            DO jk = 1, jpkm1
+               ahmt(:,:,jk) = ahmt(:,:,jk) * tmask(:,:,jk)
+               ahmf(:,:,jk) = ahmf(:,:,jk) * fmask(:,:,jk)
+            END DO
+            !
+         CASE(  30  )       !==  fixed 3D shape  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = F( latitude, longitude, depth )'
+            IF( ln_dynldf_lap )   CALL ldf_c2d( 'DYN', 'LAP', zah0, ahmt, ahmf )    ! surface value proportional to scale factor
+            IF( ln_dynldf_blp )   CALL ldf_c2d( 'DYN', 'BLP', zah0, ahmt, ahmf )    ! surface value proportional to scale factor
+            !                                                    ! reduction with depth
+            CALL ldf_c1d( 'DYN', r1_4, ahmt(:,:,1), ahmf(:,:,1), ahmt, ahmf )
+            !
+         CASE(  31  )       !==  time varying 3D field  ==!
+            IF(lwp) WRITE(numout,*) '          momentum mixing coef. = F( latitude, longitude, depth , time )'
+            IF(lwp) WRITE(numout,*) '                                proportional to the velocity : |u|e/12 or |u|e^3/12'
+            !
+            l_ldfdyn_time = .TRUE.     ! will be calculated by call to ldf_dyn routine in step.F90
+            !
+         CASE DEFAULT
+            CALL ctl_stop('ldf_dyn_init: wrong choice for nn_ahm_ijk_t, the type of space-time variation of ahm')
+         END SELECT
+         !
+         IF( ln_dynldf_blp .AND. .NOT. l_ldfdyn_time ) THEN       ! bilapcian and no time variation:
+            ahmt(:,:,:) = SQRT( ahmt(:,:,:) )                     ! take the square root of the coefficient
+            ahmf(:,:,:) = SQRT( ahmf(:,:,:) )
+         ENDIF
+         !
+      ENDIF
       !
    END SUBROUTINE ldf_dyn_init
 
-#if defined key_dynldf_c3d
-#   include "ldfdyn_c3d.h90"
-#elif defined key_dynldf_c2d
-#   include "ldfdyn_c2d.h90"
-#elif defined key_dynldf_c1d
-#   include "ldfdyn_c1d.h90"
-#endif
-
-
-   SUBROUTINE ldf_zpf_1d( ld_print, pdam, pwam, pbot, pdep, pah )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_zpf  ***
-      !!                   
-      !! ** Purpose :   vertical adimensional profile for eddy coefficient
-      !!
-      !! ** Method  :   1D eddy viscosity coefficients ( depth )
-      !!----------------------------------------------------------------------
-      LOGICAL , INTENT(in   )                 ::   ld_print   ! If true, output arrays on numout
-      REAL(wp), INTENT(in   )                 ::   pdam       ! depth of the inflection point
-      REAL(wp), INTENT(in   )                 ::   pwam       ! width of inflection
-      REAL(wp), INTENT(in   )                 ::   pbot       ! bottom value (0<pbot<= 1)
-      REAL(wp), INTENT(in   ), DIMENSION(jpk) ::   pdep       ! depth of the gridpoint (T, U, V, F)
-      REAL(wp), INTENT(inout), DIMENSION(jpk) ::   pah        ! adimensional vertical profile
-      !!
-      INTEGER  ::   jk           ! dummy loop indices
-      REAL(wp) ::   zm00, zm01, zmhb, zmhs       ! temporary scalars
-      !!----------------------------------------------------------------------
-
-      zm00 = TANH( ( pdam - gdept_1d(1    ) ) / pwam )
-      zm01 = TANH( ( pdam - gdept_1d(jpkm1) ) / pwam )
-      zmhs = zm00 / zm01
-      zmhb = ( 1.e0 - pbot ) / ( 1.e0 - zmhs ) / zm01
-
-      DO jk = 1, jpk
-         pah(jk) = 1.e0 + zmhb * ( zm00 - TANH( ( pdam - pdep(jk) ) / pwam )  )
-      END DO
-
-      IF(lwp .AND. ld_print ) THEN      ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm profile : '
-         WRITE(numout,*)
-         WRITE(numout,'("  jk      ahm       ","  depth t-level " )')
-         DO jk = 1, jpk
-            WRITE(numout,'(i6,2f12.4,3x,2f12.4)') jk, pah(jk), pdep(jk)
-         END DO
-      ENDIF
-      !
-   END SUBROUTINE ldf_zpf_1d
-
-
-   SUBROUTINE ldf_zpf_1d_3d( ld_print, pdam, pwam, pbot, pdep, pah )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_zpf  ***
-      !!
-      !! ** Purpose :   vertical adimensional profile for eddy coefficient
-      !!
-      !! ** Method  :   1D eddy viscosity coefficients ( depth )
-      !!----------------------------------------------------------------------
-      LOGICAL , INTENT(in   )                         ::   ld_print   ! If true, output arrays on numout
-      REAL(wp), INTENT(in   )                         ::   pdam       ! depth of the inflection point
-      REAL(wp), INTENT(in   )                         ::   pwam       ! width of inflection
-      REAL(wp), INTENT(in   )                         ::   pbot       ! bottom value (0<pbot<= 1)
-      REAL(wp), INTENT(in   ), DIMENSION          (:) ::   pdep       ! depth of the gridpoint (T, U, V, F)
-      REAL(wp), INTENT(inout), DIMENSION      (:,:,:) ::   pah        ! adimensional vertical profile
-      !!
-      INTEGER  ::   jk           ! dummy loop indices
-      REAL(wp) ::   zm00, zm01, zmhb, zmhs, zcf  ! temporary scalars
-      !!----------------------------------------------------------------------
-
-      zm00 = TANH( ( pdam - gdept_1d(1    ) ) / pwam )
-      zm01 = TANH( ( pdam - gdept_1d(jpkm1) ) / pwam )
-      zmhs = zm00 / zm01
-      zmhb = ( 1.e0 - pbot ) / ( 1.e0 - zmhs ) / zm01
-
-      DO jk = 1, jpk
-         zcf = 1.e0 + zmhb * ( zm00 - TANH( ( pdam - pdep(jk) ) / pwam )  )
-         pah(:,:,jk) = zcf
-      END DO
-
-      IF(lwp .AND. ld_print ) THEN      ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm profile : '
-         WRITE(numout,*)
-         WRITE(numout,'("  jk      ahm       ","  depth t-level " )')
-         DO jk = 1, jpk
-            WRITE(numout,'(i6,2f12.4,3x,2f12.4)') jk, pah(1,1,jk), pdep(jk)
-         END DO
-      ENDIF
-      !
-   END SUBROUTINE ldf_zpf_1d_3d
-
-
-   SUBROUTINE ldf_zpf_3d( ld_print, pdam, pwam, pbot, pdep, pah )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_zpf  ***
-      !!
-      !! ** Purpose :   vertical adimensional profile for eddy coefficient
-      !!
-      !! ** Method  :   3D for partial step or s-coordinate
-      !!----------------------------------------------------------------------
-      LOGICAL , INTENT(in   )                         ::   ld_print   ! If true, output arrays on numout
-      REAL(wp), INTENT(in   )                         ::   pdam       ! depth of the inflection point
-      REAL(wp), INTENT(in   )                         ::   pwam       ! width of inflection
-      REAL(wp), INTENT(in   )                         ::   pbot       ! bottom value (0<pbot<= 1)
-      REAL(wp), INTENT(in   ), DIMENSION      (:,:,:) ::   pdep       ! dep of the gridpoint (T, U, V, F)
-      REAL(wp), INTENT(inout), DIMENSION      (:,:,:) ::   pah        ! adimensional vertical profile
-      !!
-      INTEGER  ::   jk           ! dummy loop indices
-      REAL(wp) ::   zm00, zm01, zmhb, zmhs       ! temporary scalars
-      !!----------------------------------------------------------------------
-
-      zm00 = TANH( ( pdam - gdept_1d(1    ) ) / pwam )   
-      zm01 = TANH( ( pdam - gdept_1d(jpkm1) ) / pwam )
-      zmhs = zm00 / zm01
-      zmhb = ( 1.e0 - pbot ) / ( 1.e0 - zmhs ) / zm01
-
-      DO jk = 1, jpk
-         pah(:,:,jk) = 1.e0 + zmhb * ( zm00 - TANH( ( pdam - pdep(:,:,jk) ) / pwam )  )
-      END DO
-
-      IF(lwp .AND. ld_print ) THEN      ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm profile : '
-         WRITE(numout,*)
-         WRITE(numout,'("  jk      ahm       ","  depth t-level " )')
-         DO jk = 1, jpk
-            WRITE(numout,'(i6,2f12.4,3x,2f12.4)') jk, pah(1,1,jk), pdep(1,1,jk)
-         END DO
-      ENDIF
-      !
-   END SUBROUTINE ldf_zpf_3d
+
+   SUBROUTINE ldf_dyn( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_dyn  ***
+      !! 
+      !! ** Purpose :   update at kt the momentum lateral mixing coeff. (ahmt and ahmf)
+      !!
+      !! ** Method  :   time varying eddy viscosity coefficients:
+      !!
+      !!    nn_ahm_ijk_t = 31    ahmt, ahmf = F(i,j,k,t) = F(local velocity) 
+      !!                         ( |u|e /12  or  |u|e^3/12 for laplacian or bilaplacian operator )
+      !!                BLP case : sqrt of the eddy coef, since bilaplacian is en re-entrant laplacian
+      !!
+      !! ** action  :    ahmt, ahmf   update at each time step
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! time step index
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zu2pv2_ij_p1, zu2pv2_ij, zu2pv2_ij_m1, zetmax, zefmax   ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('ldf_dyn')
+      !
+      SELECT CASE(  nn_ahm_ijk_t  )       !== Eddy vicosity coefficients ==!
+      !
+      CASE(  31  )       !==  time varying 3D field  ==!   = F( local velocity )
+         !
+         IF( ln_dynldf_lap   ) THEN          !   laplacian operator : |u| e /12 = |u/144| e
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zu2pv2_ij_p1 = ub(ji  ,jj+1,jk) * ub(ji  ,jj+1,jk) + vb(ji+1,jj  ,jk) * vb(ji+1,jj  ,jk)
+                     zu2pv2_ij    = ub(ji  ,jj  ,jk) * ub(ji  ,jj  ,jk) + vb(ji  ,jj  ,jk) * vb(ji  ,jj  ,jk)
+                     zu2pv2_ij_m1 = ub(ji-1,jj  ,jk) * ub(ji-1,jj  ,jk) + vb(ji  ,jj-1,jk) * vb(ji  ,jj-1,jk)
+                     zetmax = MAX( e1t(ji,jj) , e2t(ji,jj) )
+                     zefmax = MAX( e1f(ji,jj) , e2f(ji,jj) )
+                     ahmt(ji,jj,jk) = SQRT( (zu2pv2_ij + zu2pv2_ij_m1) * r1_288 ) * zetmax * tmask(ji,jj,jk)      ! 288= 12*12 * 2
+                     ahmf(ji,jj,jk) = SQRT( (zu2pv2_ij + zu2pv2_ij_p1) * r1_288 ) * zefmax * fmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ELSEIF( ln_dynldf_blp ) THEN      ! bilaplacian operator : sqrt( |u| e^3 /12 ) = sqrt( |u/144| e ) * e
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zu2pv2_ij_p1 = ub(ji  ,jj+1,jk) * ub(ji  ,jj+1,jk) + vb(ji+1,jj  ,jk) * vb(ji+1,jj  ,jk)
+                     zu2pv2_ij    = ub(ji  ,jj  ,jk) * ub(ji  ,jj  ,jk) + vb(ji  ,jj  ,jk) * vb(ji  ,jj  ,jk)
+                     zu2pv2_ij_m1 = ub(ji-1,jj  ,jk) * ub(ji-1,jj  ,jk) + vb(ji  ,jj-1,jk) * vb(ji  ,jj-1,jk)
+                     zetmax = MAX( e1t(ji,jj) , e2t(ji,jj) )
+                     zefmax = MAX( e1f(ji,jj) , e2f(ji,jj) )
+                     ahmt(ji,jj,jk) = SQRT(  SQRT( (zu2pv2_ij + zu2pv2_ij_m1) * r1_288 ) * zetmax  ) * zetmax * tmask(ji,jj,jk)
+                     ahmf(ji,jj,jk) = SQRT(  SQRT( (zu2pv2_ij + zu2pv2_ij_p1) * r1_288 ) * zefmax  ) * zefmax * fmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+         ENDIF
+         !
+         CALL lbc_lnk( ahmt, 'T', 1. )   ;   CALL lbc_lnk( ahmf, 'F', 1. )
+         !
+      END SELECT
+      !
+      CALL iom_put( "ahmt_2d", ahmt(:,:,1) )   ! surface u-eddy diffusivity coeff.
+      CALL iom_put( "ahmf_2d", ahmf(:,:,1) )   ! surface v-eddy diffusivity coeff.
+      CALL iom_put( "ahmt_3d", ahmt(:,:,:) )   ! 3D      u-eddy diffusivity coeff.
+      CALL iom_put( "ahmf_3d", ahmf(:,:,:) )   ! 3D      v-eddy diffusivity coeff.
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('ldf_dyn')
+      !
+   END SUBROUTINE ldf_dyn
 
    !!======================================================================
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c1d.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c1d.h90	(revision 6040)
+++ 	(revision )
@@ -1,124 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                     ***  ldfdyn_c1d.h90  ***
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_dyn_c1d( ld_print )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_dyn_c1d  ***
-      !!                   
-      !! ** Purpose :   initializations of the horizontal ocean physics
-      !!
-      !! ** Method  :   1D eddy viscosity coefficients ( depth )
-      !!      ahm3, ahm4 never used
-      !!      harmonic   operator : ahm1 defined at T-level
-      !!      biharmonic operator : ahm2 defined at T-level
-      !!      isopycnal or geopotential harmonic operator
-      !!                                      : ahm1 defined at T-level
-      !!                                      : ahm2 defined at w-level
-      !!
-      !!----------------------------------------------------------------------
-      LOGICAL, INTENT(in) :: ld_print   ! If true, output arrays on numout
-      !
-      INTEGER  ::   jk   ! dummy loop indice
-      REAL(wp) ::   zdam,  zwam,  zm00,  zm01,  zmhf,  zmhs
-      REAL(wp) ::   zdam2, zwam2, zm200, zm201, zmh2f, zmh2s
-      REAL(wp) ::   zahmf, zahms
-      !!----------------------------------------------------------------------
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'inildf: 1D eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~  --'
-
-      ! Set ahm1 for laplacian     (always at t-level)
-      ! =============
-      ! (USER: modify ahm1 following your desiderata)
-
-      ! initialization of the profile
-      ! ahms, ahmf: surface and bottom values
-      zahms = ahm0
-      zahmf = ahm0/4.
-      ! zdam, zwam: depth of the inflection pt and width of inflection
-      zdam  = -300.
-      zwam  =  300.
-      ! computation coefficients
-      zm00 = TANH( (0-zdam)/zwam )
-      zm01 = TANH( (-fsdept(1,1,jpk)-zdam)/zwam )
-      zmhf = (zahms-zahmf)/(zm00-zm01)
-      zmhs = zahms-zmhf * zm00
-
-      ! Set ahm2 for bilaplacian   (always at t-level)
-      ! =============
-      ! (USER: modify ahm2 following your desiderata)
-
-      ! initialization of the profile
-      ! ahms, ahmf: surface and bottom values
-      zahm2s = ahm0_blp
-      zahm2f = ahm0_blp/4.
-      ! zdam, zwam: depth of the inflection pt and width of inflection
-      zdam2  = -300.
-      zwam2  =  300.
-      ! computation coefficients
-      zm200 = TANH( (0-zdam2)/zwam2 )
-      zm201 = TANH( (-fsdept(1,1,jpk)-zdam2)/zwam2 )
-      zmh2f = (zahm2s-zahm2f)/(zm200-zm201)
-      zmh2s = zahm2s-zmh2f * zm00
-
-
-      ! set ahm1 and ahm2 at T-level
-      DO jk = 1, jpk
-         ahm1(jk) = zmhs  + zmhf  * TANH( (-fsdept(1,1,jk)-zdam ) / zwam  )
-         ahm2(jk) = zmh2s + zmh2f * TANH( (-fsdept(1,1,jk)-zdam2) / zwam2 )
-      END DO
-
-      ! Control print
-      IF(lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm profile (laplacian): '
-         WRITE(numout,*)
-         WRITE(numout,9100)
-         DO jk = 1, jpk
-            WRITE(numout,9110) jk, ahm1(jk), fsdept(1,1,jk)
-         END DO
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm profile (bilaplacian): '
-         WRITE(numout,*)
-         WRITE(numout,9100)
-         DO jk = 1, jpk
-            WRITE(numout,9110) jk, ahm2(jk), fsdept(1,1,jk)
-         END DO
-      ENDIF
- 9100 FORMAT('  jk      ahm       ','  depth t-level ' )
- 9110 FORMAT(i6,2f12.4,3x,2f12.4)
-
-
-      ! Set ahm3=ahm4   (always defined at w-level)
-      ! =============
-
-      ! define ahm3 from the same vertical profile used for ahm4
-      ! (always defined at w-level)
-      ! (USER: modify ahm1 following your desiderata)
-
-      DO jk = 1, jpk
-         ahm3(jk) = zmhs + zmhf * TANH( (-fsdepw(1,1,jk)-zdam) / zwam )
-         ahm4(jk) = ahm3(jk)
-      END DO
-
-      ! Control print
-      IF(lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm3=ahm4 profile : '
-         WRITE(numout,*)
-         WRITE(numout,9120)
-         DO jk = 1, jpk
-            WRITE(numout,9110) jk, ahm3(jk), fsdepw(1,1,jk)
-         END DO
-      ENDIF
- 9120 FORMAT('  jk      ahm       ','  depth w-level ' )
-      !
-   END SUBROUTINE ldf_dyn_c1d
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c2d.h90	(revision 6040)
+++ 	(revision )
@@ -1,523 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                      ***  ldfdyn_c2d.h90  ***
-   !!----------------------------------------------------------------------
-   !!   ldf_dyn_c2d  : set the lateral viscosity coefficients
-   !!   ldf_dyn_c2d_orca : specific case for orca r2 and r4
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_dyn_c2d( ld_print )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE ldf_dyn_c2d  ***
-      !!                  
-      !! ** Purpose :   initializations of the horizontal ocean physics
-      !!
-      !! ** Method :
-      !!      2D eddy viscosity coefficients ( longitude, latitude )
-      !!
-      !!       harmonic operator   : ahm1 is defined at t-point
-      !!                             ahm2 is defined at f-point
-      !!           + isopycnal     : ahm3 is defined at u-point
-      !!           or geopotential   ahm4 is defined at v-point
-      !!           iso-model level : ahm3, ahm4 not used
-      !!
-      !!       biharmonic operator : ahm3 is defined at u-point
-      !!                             ahm4 is defined at v-point
-      !!                           : ahm1, ahm2 not used
-      !!
-      !!----------------------------------------------------------------------
-      LOGICAL, INTENT (in) :: ld_print   ! If true, output arrays on numout
-      !
-      INTEGER  ::   ji, jj
-      REAL(wp) ::   za00, zd_max, zetmax, zeumax, zefmax, zevmax
-      !!----------------------------------------------------------------------
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'ldf_dyn_c2d : 2d lateral eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-
-      ! harmonic operator (ahm1, ahm2) : ( T- and F- points) (used for laplacian operators
-      ! ===============================                       whatever its orientation is)
-      IF( ln_dynldf_lap ) THEN
-         ! define ahm1 and ahm2 at the right grid point position
-         ! (USER: modify ahm1 and ahm2 following your desiderata)
-
-         zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
-         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
-
-         IF(lwp) WRITE(numout,*) '              laplacian operator: ahm proportional to e1'
-         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
-
-         za00 = ahm0 / zd_max
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
-               zefmax = MAX( e1f(ji,jj), e2f(ji,jj) )
-               ahm1(ji,jj) = za00 * zetmax
-               ahm2(ji,jj) = za00 * zefmax
-            END DO
-         END DO
-
-         IF( ln_dynldf_iso ) THEN
-            IF(lwp) WRITE(numout,*) '              Caution, as implemented now, the isopycnal part of momentum'
-            IF(lwp) WRITE(numout,*) '                 mixing use aht0 as eddy viscosity coefficient. Thus, it is'
-            IF(lwp) WRITE(numout,*) '                 uniform and you must be sure that your ahm is greater than'
-            IF(lwp) WRITE(numout,*) '                 aht0 everywhere in the model domain.'
-         ENDIF
-
-         ! Special case for ORCA R1, R2 and R4 configurations (overwrite the value of ahm1 ahm2)
-         ! ==============================================
-         IF( cp_cfg == "orca" .AND. ( jp_cfg == 2 .OR. jp_cfg == 4 ) )   CALL ldf_dyn_c2d_orca( ld_print )
-         IF( cp_cfg == "orca" .AND.   jp_cfg == 1)                       CALL ldf_dyn_c2d_orca_R1( ld_print )
-
-         ! Control print
-         IF( lwp .AND. ld_print ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: 2D ahm1 array'
-            CALL prihre(ahm1,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: 2D ahm2 array'
-            CALL prihre(ahm2,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         ENDIF
-      ENDIF
-
-      ! biharmonic operator (ahm3, ahm4) : at U- and V-points (used for bilaplacian operator
-      ! =================================                      whatever its orientation is)
-      IF( ln_dynldf_bilap ) THEN
-         ! (USER: modify ahm3 and ahm4 following your desiderata)
-         ! Here: ahm is proportional to the cube of the maximum of the gridspacing
-         !       in the to horizontal direction
-
-         zd_max = MAX( MAXVAL( e1u(:,:) ), MAXVAL( e2u(:,:) ) )
-         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
-
-         IF(lwp) WRITE(numout,*) '              bi-laplacian operator: ahm proportional to e1**3 '
-         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
-
-         za00 = ahm0_blp / ( zd_max * zd_max * zd_max )
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zeumax = MAX( e1u(ji,jj), e2u(ji,jj) )
-               zevmax = MAX( e1v(ji,jj), e2v(ji,jj) )
-               ahm3(ji,jj) = za00 * zeumax * zeumax * zeumax
-               ahm4(ji,jj) = za00 * zevmax * zevmax * zevmax
-            END DO
-         END DO
-
-         ! Control print
-         IF( lwp .AND. ld_print ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahm3 array'
-            CALL prihre(ahm3,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahm4 array'
-            CALL prihre(ahm4,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         ENDIF
-      ENDIF
-      !
-   END SUBROUTINE ldf_dyn_c2d
-
-
-   SUBROUTINE ldf_dyn_c2d_orca( ld_print )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE ldf_dyn_c2d  ***
-      !!
-      !!                   **** W A R N I N G ****
-      !!
-      !!                ORCA R2 and R4 configurations
-      !!                  
-      !!                   **** W A R N I N G ****
-      !!                  
-      !! ** Purpose :   initializations of the lateral viscosity for orca R2
-      !!
-      !! ** Method  :   blah blah blah...
-      !!
-      !!----------------------------------------------------------------------
-      USE ldftra_oce, ONLY:   aht0
-      USE iom
-      !
-      LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
-      !
-      INTEGER  ::   ji, jj, jn   ! dummy loop indices
-      INTEGER  ::   inum, iim, ijm            ! local integers
-      INTEGER  ::   ifreq, il1, il2, ij, ii
-      INTEGER  ::   ijpt0,ijpt1, ierror
-      REAL(wp) ::   zahmeq, zcoft, zcoff, zmsk
-      CHARACTER (len=15) ::   clexp
-      INTEGER,     POINTER, DIMENSION(:,:)  :: icof
-      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztemp2d  ! temporary array to read ahmcoef file
-      !!----------------------------------------------------------------------
-      !                                
-      CALL wrk_alloc( jpi   , jpj   , icof  )
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'inildf: 2d eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~  --'
-      IF(lwp) WRITE(numout,*) '        orca ocean configuration'
-
-      IF( cp_cfg == "orca" .AND. cp_cfz == "antarctic" ) THEN
-!
-! 1.2 Modify ahm
-! --------------
-         IF(lwp)WRITE(numout,*) ' inildf: Antarctic ocean'
-         IF(lwp)WRITE(numout,*) '         no tropics, no reduction of ahm'
-         IF(lwp)WRITE(numout,*) '         north boundary increase'
-
-         ahm1(:,:) = ahm0
-         ahm2(:,:) = ahm0
-
-         ijpt0=max(1,min(49 -njmpp+1,jpj))
-         ijpt1=max(0,min(49-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*2.
-            ahm1(:,jj)=ahm0*2.
-         END DO
-         ijpt0=max(1,min(48 -njmpp+1,jpj))
-         ijpt1=max(0,min(48-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.9
-            ahm1(:,jj)=ahm0*1.75
-         END DO
-         ijpt0=max(1,min(47 -njmpp+1,jpj))
-         ijpt1=max(0,min(47-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.5
-            ahm1(:,jj)=ahm0*1.25
-         END DO
-         ijpt0=max(1,min(46 -njmpp+1,jpj))
-         ijpt1=max(0,min(46-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.1
-         END DO
-
-      ELSE IF( cp_cfg == "orca" .AND. cp_cfz == "arctic" ) THEN
-! 1.2 Modify ahm 
-! --------------
-         IF(lwp)WRITE(numout,*) ' inildf: Arctic ocean'
-         IF(lwp)WRITE(numout,*) '         no tropics, no reduction of ahm'
-         IF(lwp)WRITE(numout,*) '         south and west boundary increase'
-
-
-         ahm1(:,:) = ahm0
-         ahm2(:,:) = ahm0
-
-         ijpt0=max(1,min(98-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(98-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*2.
-            ahm1(:,jj)=ahm0*2.
-         END DO
-         ijpt0=max(1,min(99-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(99-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.9
-            ahm1(:,jj)=ahm0*1.75
-         END DO
-         ijpt0=max(1,min(100-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(100-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.5
-            ahm1(:,jj)=ahm0*1.25
-         END DO
-         ijpt0=max(1,min(101-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(101-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.1
-         END DO
-      ELSE
-         ! Read 2d integer array to specify western boundary increase in the
-         ! ===================== equatorial strip (20N-20S) defined at t-points
-         !
-         ALLOCATE( ztemp2d(jpi,jpj) )
-         ztemp2d(:,:) = 0.
-         CALL iom_open ( 'ahmcoef.nc', inum )
-         CALL iom_get  ( inum, jpdom_data, 'icof', ztemp2d)
-         icof(:,:)  = NINT(ztemp2d(:,:))
-         CALL iom_close( inum )
-         DEALLOCATE(ztemp2d)
-
-         ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
-         ! =================
-         ! define ahm1 and ahm2 at the right grid point position
-         ! (USER: modify ahm1 and ahm2 following your desiderata)
-
-
-         ! Decrease ahm to zahmeq m2/s in the tropics
-         ! (from 90 to 20 degre: ahm = constant
-         ! from 20 to  2.5 degre: ahm = decrease in (1-cos)/2
-         ! from  2.5 to  0 degre: ahm = constant
-         ! symmetric in the south hemisphere)
-
-         zahmeq = aht0
-
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( ABS( gphif(ji,jj) ) >= 20. ) THEN
-                  ahm2(ji,jj) =  ahm0
-               ELSEIF( ABS( gphif(ji,jj) ) <= 2.5 ) THEN
-                  ahm2(ji,jj) =  zahmeq
-               ELSE
-                  ahm2(ji,jj) = zahmeq + (ahm0-zahmeq)/2.   &
-                     * ( 1. - COS( rad * ( ABS(gphif(ji,jj))-2.5 ) * 180. / 17.5 ) )
-               ENDIF
-               IF( ABS( gphit(ji,jj) ) >= 20. ) THEN
-                  ahm1(ji,jj) =  ahm0
-               ELSEIF( ABS( gphit(ji,jj) ) <= 2.5 ) THEN
-                  ahm1(ji,jj) =  zahmeq
-               ELSE
-                  ahm1(ji,jj) = zahmeq + (ahm0-zahmeq)/2.   &
-                     * ( 1. - COS( rad * ( ABS(gphit(ji,jj))-2.5 ) * 180. / 17.5 ) )
-               ENDIF
-            END DO
-         END DO
-
-         ! increase along western boundaries of equatorial strip
-         ! t-point
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               zcoft = FLOAT( icof(ji,jj) ) / 100.
-               ahm1(ji,jj) = zcoft * ahm0 + (1.-zcoft) * ahm1(ji,jj) 
-            END DO
-         END DO
-         ! f-point
-         icof(:,:) = icof(:,:) * tmask(:,:,1)
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1   ! NO vector opt.
-               zmsk = tmask(ji,jj+1,1) + tmask(ji+1,jj+1,1) + tmask(ji,jj,1) + tmask(ji,jj+1,1)
-               IF( zmsk == 0. ) THEN
-                  zcoff = 1.
-               ELSE
-                  zcoff = FLOAT( icof(ji,jj+1) + icof(ji+1,jj+1) + icof(ji,jj) + icof(ji,jj+1) )   &
-                     / (zmsk * 100.)
-               ENDIF
-               ahm2(ji,jj) = zcoff * ahm0 + (1.-zcoff) * ahm2(ji,jj)
-            END DO
-         END DO
-      ENDIF
-      
-      ! Lateral boundary conditions on ( ahm1, ahm2 )
-      !                                ==============
-      CALL lbc_lnk( ahm1, 'T', 1. )   ! T-point, unchanged sign
-      CALL lbc_lnk( ahm2, 'F', 1. )   ! F-point, unchanged sign
-
-      ! Control print
-      IF( lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: 2D ahm1 array'
-         CALL prihre(ahm1,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: 2D ahm2 array'
-         CALL prihre(ahm2,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-      ENDIF
-      !
-      CALL wrk_dealloc( jpi   , jpj   , icof  )
-      !
-   END SUBROUTINE ldf_dyn_c2d_orca
-
-
-   SUBROUTINE ldf_dyn_c2d_orca_R1( ld_print )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE ldf_dyn_c2d  ***
-      !!
-      !!                   **** W A R N I N G ****
-      !!
-      !!                ORCA R1 configuration
-      !!                  
-      !!                   **** W A R N I N G ****
-      !!                  
-      !! ** Purpose :   initializations of the lateral viscosity for orca R1
-      !!
-      !! ** Method  :   blah blah blah...
-      !!
-      !!----------------------------------------------------------------------
-      USE ldftra_oce, ONLY:   aht0
-      USE iom
-      !
-      LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
-      !
-      INTEGER ::   ji, jj, jn      ! dummy loop indices
-      INTEGER ::   inum            ! temporary logical unit
-      INTEGER ::   iim, ijm
-      INTEGER ::   ifreq, il1, il2, ij, ii
-      INTEGER ::   ijpt0,ijpt1, ierror
-      REAL(wp) ::   zahmeq, zcoft, zcoff, zmsk, zam20s
-      CHARACTER (len=15) ::   clexp
-      INTEGER,     POINTER, DIMENSION(:,:)  :: icof
-      REAL(wp), DIMENSION(:,:), ALLOCATABLE :: ztemp2d  ! temporary array to read ahmcoef file
-      !!----------------------------------------------------------------------
-      !                                
-      CALL wrk_alloc( jpi   , jpj   , icof  )
-      !                                
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'inildf: 2d eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~  --'
-      IF(lwp) WRITE(numout,*) '        orca_r1 configuration'
-
-      IF( cp_cfg == "orca" .AND. cp_cfz == "antarctic" ) THEN
-!
-! 1.2 Modify ahm
-! --------------
-         IF(lwp)WRITE(numout,*) ' inildf: Antarctic ocean'
-         IF(lwp)WRITE(numout,*) '         no tropics, no reduction of ahm'
-         IF(lwp)WRITE(numout,*) '         north boundary increase'
-
-         ahm1(:,:) = ahm0
-         ahm2(:,:) = ahm0
-
-         ijpt0=max(1,min(49 -njmpp+1,jpj))
-         ijpt1=max(0,min(49-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*2.
-            ahm1(:,jj)=ahm0*2.
-         END DO
-         ijpt0=max(1,min(48 -njmpp+1,jpj))
-         ijpt1=max(0,min(48-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.9
-            ahm1(:,jj)=ahm0*1.75
-         END DO
-         ijpt0=max(1,min(47 -njmpp+1,jpj))
-         ijpt1=max(0,min(47-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.5
-            ahm1(:,jj)=ahm0*1.25
-         END DO
-         ijpt0=max(1,min(46 -njmpp+1,jpj))
-         ijpt1=max(0,min(46-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.1
-         END DO
-
-      ELSE IF( cp_cfg == "orca" .AND. cp_cfz == "arctic" ) THEN
-! 1.2 Modify ahm 
-! --------------
-         IF(lwp)WRITE(numout,*) ' inildf: Arctic ocean'
-         IF(lwp)WRITE(numout,*) '         no tropics, no reduction of ahm'
-         IF(lwp)WRITE(numout,*) '         south and west boundary increase'
-
-
-         ahm1(:,:) = ahm0
-         ahm2(:,:) = ahm0
-
-         ijpt0=max(1,min(98-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(98-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*2.
-            ahm1(:,jj)=ahm0*2.
-         END DO
-         ijpt0=max(1,min(99-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(99-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.9
-            ahm1(:,jj)=ahm0*1.75
-         END DO
-         ijpt0=max(1,min(100-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(100-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.5
-            ahm1(:,jj)=ahm0*1.25
-         END DO
-         ijpt0=max(1,min(101-jpjzoom+1-njmpp+1,jpj))
-         ijpt1=max(0,min(101-jpjzoom+1-njmpp+1,jpj-1))
-         DO jj=ijpt0,ijpt1
-            ahm2(:,jj)=ahm0*1.1
-         END DO
-      ELSE
-         
-         ! Read 2d integer array to specify western boundary increase in the
-         ! ===================== equatorial strip (20N-20S) defined at t-points
-         ALLOCATE( ztemp2d(jpi,jpj) )
-         ztemp2d(:,:) = 0.
-         CALL iom_open ( 'ahmcoef.nc', inum )
-         CALL iom_get  ( inum, jpdom_data, 'icof', ztemp2d)
-         icof(:,:)  = NINT(ztemp2d(:,:))
-         CALL iom_close( inum )
-         DEALLOCATE(ztemp2d)
-
-         ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operator)
-         ! =================
-         ! define ahm1 and ahm2 at the right grid point position
-         ! (USER: modify ahm1 and ahm2 following your desiderata)
-
-
-         ! Decrease ahm to zahmeq m2/s in the tropics
-         ! (from 90   to 20   degrees: ahm = scaled by local metrics
-         !  from 20   to  2.5 degrees: ahm = decrease in (1-cos)/2
-         !  from  2.5 to  0   degrees: ahm = constant
-         ! symmetric in the south hemisphere)
-
-         zahmeq = aht0
-         zam20s = ahm0*COS( rad * 20. )
-
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               IF( ABS( gphif(ji,jj) ) >= 20. ) THEN
-                  !              leave as set in ldf_dyn_c2d
-               ELSEIF( ABS( gphif(ji,jj) ) <= 2.5 ) THEN
-                  ahm2(ji,jj) =  zahmeq
-               ELSE
-                  ahm2(ji,jj) =  zahmeq + (zam20s-zahmeq)/2.   &
-                     * ( 1. - COS( rad * ( ABS(gphif(ji,jj))-2.5 ) * 180. / 17.5 ) )
-               ENDIF
-               IF( ABS( gphit(ji,jj) ) >= 20. ) THEN
-                  !             leave as set in ldf_dyn_c2d
-               ELSEIF( ABS( gphit(ji,jj) ) <= 2.5 ) THEN
-                  ahm1(ji,jj) =  zahmeq
-               ELSE
-                  ahm1(ji,jj) =  zahmeq + (zam20s-zahmeq)/2.   &
-                     * ( 1. - COS( rad * ( ABS(gphit(ji,jj))-2.5 ) * 180. / 17.5 ) )
-               ENDIF
-            END DO
-         END DO
-
-         ! increase along western boundaries of equatorial strip
-         ! t-point
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               IF( ABS( gphit(ji,jj) ) < 20. ) THEN
-                  zcoft = FLOAT( icof(ji,jj) ) / 100.
-                  ahm1(ji,jj) = zcoft * ahm0 + (1.-zcoft) * ahm1(ji,jj) 
-               ENDIF
-            END DO
-         END DO
-         ! f-point
-         icof(:,:) = icof(:,:) * tmask(:,:,1)
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               IF( ABS( gphif(ji,jj) ) < 20. ) THEN
-                  zmsk = tmask(ji,jj+1,1) + tmask(ji+1,jj+1,1) + tmask(ji,jj,1) + tmask(ji,jj+1,1)
-                  IF( zmsk == 0. ) THEN
-                     zcoff = 1.
-                  ELSE
-                     zcoff = FLOAT( icof(ji,jj+1) + icof(ji+1,jj+1) + icof(ji,jj) + icof(ji,jj+1) )   &
-                        / (zmsk * 100.)
-                  ENDIF
-                  ahm2(ji,jj) = zcoff * ahm0 + (1.-zcoff) * ahm2(ji,jj)
-               ENDIF
-            END DO
-         END DO
-      ENDIF
-      
-      ! Lateral boundary conditions on ( ahm1, ahm2 )
-      !                                ==============
-      CALL lbc_lnk( ahm1, 'T', 1. )   ! T-point, unchanged sign
-      CALL lbc_lnk( ahm2, 'F', 1. )   ! F-point, unchanged sign
-
-      ! Control print
-      IF( lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: 2D ahm1 array'
-         CALL prihre(ahm1,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: 2D ahm2 array'
-         CALL prihre(ahm2,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-      ENDIF
-      !
-      CALL wrk_dealloc( jpi   , jpj   , icof  )
-      !
-   END SUBROUTINE ldf_dyn_c2d_orca_R1
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_c3d.h90	(revision 6040)
+++ 	(revision )
@@ -1,433 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                        ***  ldfdyn_c3d.h90  ***
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   'key_dynldf_c3d'             3D lateral eddy viscosity coefficients
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_dyn_c3d( ld_print )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_dyn_c3d  ***
-      !!                   
-      !! ** Purpose :   initializations of the horizontal ocean physics
-      !!
-      !! ** Method  :   3D eddy viscosity coef. ( longitude, latitude, depth )
-      !!       laplacian operator   : ahm1, ahm2 defined at T- and F-points
-      !!                              ahm2, ahm4 never used
-      !!       bilaplacian operator : ahm1, ahm2 never used
-      !!                           :  ahm3, ahm4 defined at U- and V-points
-      !!       ??? explanation of the default is missing
-      !!----------------------------------------------------------------------
-      USE ldftra_oce, ONLY :   aht0
-      USE iom
-      !!
-      LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
-      !!
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zr = 0.2     ! maximum of the reduction factor at the bottom ocean ( 0 < zr < 1 )
-      REAL(wp) ::   zh = 500.    ! depth of at which start the reduction ( > dept(1) )
-      REAL(wp) ::   zd_max       ! maximum grid spacing over the global domain
-      REAL(wp) ::   za00, zc, zd, zetmax, zefmax, zeumax, zevmax   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:) :: zcoef   
-      !!----------------------------------------------------------------------
-      !
-      CALL wrk_alloc( jpk, zcoef )
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'ldf_dyn_c3d : 3D lateral eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-
-      
-      ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operators
-      ! =================                       whatever its orientation is)
-      IF( ln_dynldf_lap ) THEN
-         ! define ahm1 and ahm2 at the right grid point position
-         ! (USER: modify ahm1 and ahm2 following your desiderata)
-
-         zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
-         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
-
-         IF(lwp) WRITE(numout,*) '              laplacian operator: ahm proportional to e1'
-         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
-
-         za00 = ahm0 / zd_max
-
-         IF( ln_dynldf_iso ) THEN
-            IF(lwp) WRITE(numout,*) '              Caution, as implemented now, the isopycnal part of momentum'
-            IF(lwp) WRITE(numout,*) '                 mixing use aht0 as eddy viscosity coefficient. Thus, it is'
-            IF(lwp) WRITE(numout,*) '                 uniform and you must be sure that your ahm is greater than'
-            IF(lwp) WRITE(numout,*) '                 aht0 everywhere in the model domain.'
-         ENDIF
-
-         CALL ldf_zpf( .TRUE. , 1000., 500., 0.25, fsdept(:,:,:), ahm1 )   ! vertical profile
-         CALL ldf_zpf( .TRUE. , 1000., 500., 0.25, fsdept(:,:,:), ahm2 )   ! vertical profile
-         DO jk = 1,jpk
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
-                  zefmax = MAX( e1f(ji,jj), e2f(ji,jj) )
-                  ahm1(ji,jj,jk) = za00 * zetmax * ahm1(ji,jj,jk)
-                  ahm2(ji,jj,jk) = za00 * zefmax * ahm2(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-
-
-         ! Special case for ORCA R1, R2 and R4 configurations (overwrite the value of ahm1 ahm2)
-         ! ==============================================
-         IF( cp_cfg == "orca" .AND. ( jp_cfg == 1 .OR. jp_cfg == 2 .OR. jp_cfg == 4 ) ) THEN 
-            IF(lwp) WRITE(numout,*)
-            IF(lwp) WRITE(numout,*) '              ORCA R1, R2 or R4: overwrite the previous definition of ahm'
-            IF(lwp) WRITE(numout,*) '              ================='
-            CALL ldf_dyn_c3d_orca( ld_print )
-         ENDIF
-
-      ENDIF
-      
-      ! Control print
-      IF(lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '         3D ahm1 array (k=1)'
-         CALL prihre( ahm1(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) '         3D ahm2 array (k=1)'
-         CALL prihre( ahm2(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
-      ENDIF
-
-
-      ! ahm3 and ahm4 at U- and V-points (used for bilaplacian operator
-      ! ================================  whatever its orientation is)
-      ! (USER: modify ahm3 and ahm4 following your desiderata)
-      ! Here: ahm is proportional to the cube of the maximum of the gridspacing
-      !       in the to horizontal direction
-
-      IF( ln_dynldf_bilap ) THEN
-
-         zd_max = MAX( MAXVAL( e1u(:,:) ), MAXVAL( e2u(:,:) ) )
-         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
-
-         IF(lwp) WRITE(numout,*) '              bi-laplacian operator: ahm proportional to e1**3 '
-         IF(lwp) WRITE(numout,*) '              maximum grid-spacing = ', zd_max, ' maximum value for ahm = ', ahm0
-
-         za00 = ahm0_blp / ( zd_max * zd_max * zd_max )
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zeumax = MAX( e1u(ji,jj), e2u(ji,jj) )
-               zevmax = MAX( e1v(ji,jj), e2v(ji,jj) )
-               ahm3(ji,jj,1) = za00 * zeumax * zeumax * zeumax
-               ahm4(ji,jj,1) = za00 * zevmax * zevmax * zevmax
-            END DO
-         END DO
-
-         zh = MAX( zh, fsdept(1,1,1) )   ! at least the first reach ahm0
-         IF( ln_zco ) THEN               ! z-coordinate, same profile everywhere
-            IF(lwp) WRITE(numout,'(36x," ahm ", 7x)')
-            DO jk = 1, jpk
-               IF( fsdept(1,1,jk) <= zh ) THEN
-                  zcoef(jk) = 1.e0
-               ELSE
-                  zcoef(jk) = 1.e0 + ( zr - 1.e0 )   &
-                     &               * (  1. - EXP( ( fsdept(1,1,jk   ) - zh ) / zh )  )   &
-                     &               / (  1. - EXP( ( fsdept(1,1,jpkm1) - zh ) / zh )  )
-               ENDIF
-               ahm3(:,:,jk) = ahm3(:,:,1) * zcoef(jk)
-               ahm4(:,:,jk) = ahm4(:,:,1) * zcoef(jk)
-               IF(lwp) WRITE(numout,'(34x,E7.2,8x,i3)') zcoef(jk) * ahm0, jk
-            END DO
-         ELSE                            ! partial steps or s-ccordinate
-            zc = MAXVAL( fsdept(:,:,jpkm1) )
-            IF( lk_mpp )   CALL mpp_max( zc )   ! max over the global domain
-
-            zc = 1. / (  1. - EXP( ( zc - zh ) / zh )  )
-            DO jk = 2, jpkm1
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     IF( fsdept(ji,jj,jk) <= zh ) THEN
-                        ahm3(ji,jj,jk) = ahm3(ji,jj,1)
-                        ahm4(ji,jj,jk) = ahm4(ji,jj,1)
-                     ELSE
-                        zd = 1.e0 + ( zr - 1.e0 ) * (  1. - EXP( ( fsdept(ji,jj,jk) - zh ) / zh )  ) * zc
-                        ahm3(ji,jj,jk) = ahm3(ji,jj,1) * zd
-                        ahm4(ji,jj,jk) = ahm4(ji,jj,1) * zd
-                     ENDIF
-                  END DO
-               END DO
-            END DO
-            ahm3(:,:,jpk) = ahm3(:,:,jpkm1)
-            ahm4(:,:,jpk) = ahm4(:,:,jpkm1)
-            IF(lwp) WRITE(numout,'(36x," ahm ", 7x)')
-            DO jk = 1, jpk
-               IF(lwp) WRITE(numout,'(30x,E10.2,8x,i3)') ahm3(1,1,jk), jk
-            END DO
-         ENDIF
-
-         ! Control print
-         IF( lwp .AND. ld_print ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahm3 array at level 1'
-            CALL prihre(ahm3(:,:,1  ),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahm4 array at level 1'
-            CALL prihre(ahm4(:,:,jpk),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         ENDIF
-      ENDIF
-      !
-      CALL wrk_dealloc( jpk, zcoef )
-      !
-   END SUBROUTINE ldf_dyn_c3d
-
-
-   SUBROUTINE ldf_dyn_c3d_orca( ld_print )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_dyn_c3d  ***
-      !!                   
-      !! ** Purpose :   ORCA R1, R2 and R4 only
-      !!
-      !! ** Method  :   blah blah blah ....
-      !!----------------------------------------------------------------------
-      USE ldftra_oce, ONLY:   aht0
-      USE iom
-      !!
-      LOGICAL, INTENT(in) ::   ld_print   ! If true, output arrays on numout
-      !!
-      INTEGER ::   ji, jj, jk, jn      ! dummy loop indices
-      INTEGER ::   ii0, ii1, ij0, ij1  ! local integers
-      INTEGER ::   inum, iim, ijm      ! 
-      INTEGER ::   ifreq, il1, il2, ij, ii
-      REAL(wp) ::   zahmeq, zcoff, zcoft, zmsk   ! local scalars
-      REAL(wp) ::   zemax , zemin, zeref, zahmm
-      CHARACTER (len=15) ::   clexp
-      INTEGER , POINTER, DIMENSION(:,:)  :: icof
-      REAL(wp), POINTER, DIMENSION(:  )  :: zcoef   
-      REAL(wp), POINTER, DIMENSION(:,:)  :: zahm0
-      !
-      REAL(wp), DIMENSION(:,:), ALLOCATABLE ::   ztemp2d  ! temporary array to read ahmcoef file
-      !!----------------------------------------------------------------------
-      !
-      CALL wrk_alloc( jpi   , jpj   , icof  )
-      CALL wrk_alloc( jpk   ,         zcoef )
-      CALL wrk_alloc( jpi   , jpj   , zahm0 )
-      !
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'ldfdyn_c3d_orca : 3D eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~'
-      IF(lwp) WRITE(numout,*) '        orca R1, R2 or R4 configuration: reduced in the surface Eq. strip '
-
-      ! Read 2d integer array to specify western boundary increase in the
-      ! ===================== equatorial strip (20N-20S) defined at t-points
-      ALLOCATE( ztemp2d(jpi,jpj) )
-      ztemp2d(:,:) = 0.
-      CALL iom_open ( 'ahmcoef.nc', inum )
-      CALL iom_get  ( inum, jpdom_data, 'icof', ztemp2d)
-      icof(:,:)  = NINT(ztemp2d(:,:))
-      CALL iom_close( inum )
-      DEALLOCATE(ztemp2d)
-
-      ! Set ahm1 and ahm2
-      ! =================
-      
-      ! define ahm1 and ahm2 at the right grid point position
-      ! (USER: modify ahm1 and ahm2 following your desiderata)
-      ! biharmonic : ahm1 (ahm2) defined at u- (v-) point
-      ! harmonic   : ahm1 (ahm2) defined at t- (f-) point
-      
-      ! first level : as for 2D coefficients
-      
-      ! Decrease ahm to zahmeq m2/s in the tropics
-      ! (from 90 to 20 degre: ahm = constant
-      ! from 20 to  2.5 degre: ahm = decrease in (1-cos)/2
-      ! from  2.5 to  0 degre: ahm = constant
-      ! symmetric in the south hemisphere)
-      
-      IF( jp_cfg == 4 )   THEN
-         zahmeq = 5.0 * aht0
-         zahmm  = min( 160000.0, ahm0)
-         zemax = MAXVAL ( e1t(:,:) * e2t(:,:), tmask(:,:,1) .GE. 0.5 )
-         zemin = MINVAL ( e1t(:,:) * e2t(:,:), tmask(:,:,1) .GE. 0.5 )
-         zeref = MAXVAL ( e1t(:,:) * e2t(:,:),   &
-             &   tmask(:,:,1) .GE. 0.5 .AND. ABS(gphit(:,:)) .GT. 50. )
- 
-         DO jj = 1, jpj
-           DO ji = 1, jpi
-              zmsk = e1t(ji,jj) * e2t(ji,jj)
-              IF( abs(gphit(ji,jj)) .LE. 15 ) THEN 
-                 zahm0(ji,jj) = ahm0
-              ELSE 
-                 IF( zmsk .GE. zeref ) THEN 
-                    zahm0(ji,jj) = ahm0
-                 ELSE 
-                    zahm0(ji,jj) = zahmm + (ahm0-zahmm)*(1.0 -   &
-                        &          cos((rpi*0.5*(zmsk-zemin)/(zeref-zemin))))
-                 ENDIF 
-              ENDIF 
-           END DO 
-         END DO 
-      ENDIF
-
-      IF( jp_cfg == 2 )   THEN
-         zahmeq     = aht0
-         zahmm      = ahm0
-         zahm0(:,:) = ahm0
-      ENDIF
-
-      IF( jp_cfg == 1 )   THEN
-         zahmeq     = aht0  ! reduced to aht0 on equator; set to ahm0 if no tropical reduction is required
-         zahmm      = ahm0
-         zahm0(:,:) = ahm0
-      ENDIF
-
-      DO jj = 1, jpj
-         DO ji = 1, jpi
-            IF( ABS(gphif(ji,jj)) >= 20.) THEN
-               ahm2(ji,jj,1) =  zahm0(ji,jj)
-            ELSEIF( ABS(gphif(ji,jj)) <= 2.5) THEN
-               ahm2(ji,jj,1) =  zahmeq
-            ELSE
-               ahm2(ji,jj,1) = zahmeq + (zahm0(ji,jj)-zahmeq)/2.   &
-                  &            *(1.-COS( rad*(ABS(gphif(ji,jj))-2.5)*180./17.5 ) )
-            ENDIF
-            IF( ABS(gphit(ji,jj)) >= 20.) THEN
-               ahm1(ji,jj,1) =  zahm0(ji,jj)
-            ELSEIF( ABS(gphit(ji,jj)) <= 2.5) THEN
-               ahm1(ji,jj,1) =  zahmeq
-            ELSE
-               ahm1(ji,jj,1) = zahmeq + (zahm0(ji,jj)-zahmeq)/2.   &
-                  &            *(1.-COS( rad*(ABS(gphit(ji,jj))-2.5)*180./17.5 ) )
-            ENDIF
-         END DO
-      END DO
-      
-      ! increase along western boundaries of equatorial strip
-      ! t-point
-      DO jj = 1, jpjm1
-         DO ji = 1, jpim1
-            zcoft = float( icof(ji,jj) ) / 100.
-            ahm1(ji,jj,1) = zcoft * zahm0(ji,jj) + (1.-zcoft) * ahm1(ji,jj,1)
-         END DO
-      END DO
-      ! f-point
-      icof(:,:) = icof(:,:) * tmask(:,:,1)
-      DO jj = 1, jpjm1
-         DO ji = 1, jpim1   ! NO vector opt.
-            zmsk = tmask(ji,jj+1,1) + tmask(ji+1,jj+1,1) + tmask(ji,jj,1) + tmask(ji,jj+1,1)
-            IF( zmsk == 0. ) THEN
-               zcoff = 1.
-            ELSE
-               zcoff = FLOAT( icof(ji,jj+1) + icof(ji+1,jj+1) + icof(ji,jj) + icof(ji,jj+1) )   &
-                     / (zmsk * 100.)
-            ENDIF
-            ahm2(ji,jj,1) = zcoff * zahm0(ji,jj) + (1.-zcoff) * ahm2(ji,jj,1)
-         END DO
-      END DO
-
-      ! other level: re-increase the coef in the deep ocean
-      !==================================================================
-      ! Prior to v3.3, zcoeff was hardwired according to k-index jk.
-      !
-      ! From v3.3 onwards this has been generalised to a function of 
-      ! depth so that it can be used with any number of levels.
-      !
-      ! The function has been chosen to match the original values (shown
-      ! in the following comments) when using the standard 31 ORCA levels.  
-      !     DO jk = 1, 21
-      !        zcoef(jk) = 1._wp
-      !     END DO
-      !     zcoef(22) = 2._wp
-      !     zcoef(23) = 3._wp
-      !     zcoef(24) = 5._wp
-      !     zcoef(25) = 7._wp
-      !     zcoef(26) = 9._wp
-      !     DO jk = 27, jpk
-      !        zcoef(jk) = 10._wp
-      !     END DO
-      !==================================================================
-
-       IF(lwp) THEN
-          WRITE(numout,*)
-          WRITE(numout,*) '         1D zcoef array '
-          WRITE(numout,*) '         ~~~~~~~~~~~~~~ '
-          WRITE(numout,*)
-          WRITE(numout,*) '    jk        zcoef '
-       ENDIF
-
-      DO jk=1, jpk
-         zcoef(jk) = 1.0_wp + NINT(9.0_wp*(gdept_1d(jk)-800.0_wp)/(3000.0_wp-800.0_wp))
-         zcoef(jk) = MIN(10.0_wp, MAX(1.0_wp, zcoef(jk)))
-         IF(lwp) WRITE(numout,'(4x,i3,6x,f7.3)') jk,zcoef(jk)
-      END DO
-
-      DO jk = 2, jpk
-         ahm1(:,:,jk) = MIN( zahm0(:,:), zcoef(jk) * ahm1(:,:,1) )
-         ahm2(:,:,jk) = MIN( zahm0(:,:), zcoef(jk) * ahm2(:,:,1) )
-      END DO
-
-      IF( jp_cfg == 4 )   THEN         ! Limit AHM in Gibraltar strait
-         ij0 = 50   ;   ij1 = 53
-         ii0 = 69   ;   ii1 = 71
-         DO jk = 1, jpk
-            ahm1(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) = MIN( zahmm, ahm1(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) ) 
-            ahm2(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) = MIN( zahmm, ahm2(mi0(ii0):mi1(ii1),mj0(ij0):mj1(ij1),jk) )
-         END DO
-      ENDIF
-      CALL lbc_lnk( ahm1, 'T', 1. )   ! Lateral boundary conditions (unchanged sign)
-      CALL lbc_lnk( ahm2, 'F', 1. )
-
-
-      IF(lwp) THEN                    ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) '         3D ahm1 array (k=1)'
-         CALL prihre( ahm1(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) '         3D ahm2 array (k=1)'
-         CALL prihre( ahm2(:,:,1), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) '         3D ahm2 array (k=jpk)'
-         CALL prihre( ahm2(:,:,jpk), jpi, jpj, 1, jpi, 20, 1, jpj, 20, 1.e-3, numout )
-      ENDIF
-
-
-      ! Set ahm3 and ahm4
-      ! =================
-
-      ! define ahm3 and ahm4 at the right grid point position
-      ! initialization to a constant value
-      !     (USER: modify ahm3 and ahm4 following your desiderata)
-      !     harmonic isopycnal or geopotential:
-      !                          ahm3 (ahm4) defined at u- (v-) point
-      DO jk = 1, jpk
-         DO jj = 2, jpj
-            DO ji = 2, jpi
-               ahm3(ji,jj,jk) = 0.5 * ( ahm2(ji,jj,jk) + ahm2(ji  ,jj-1,jk) )
-               ahm4(ji,jj,jk) = 0.5 * ( ahm2(ji,jj,jk) + ahm2(ji-1,jj  ,jk) )
-            END DO
-         END DO
-      END DO
-      ahm3 ( :, 1, :) = ahm3 ( :, 2, :)
-      ahm4 ( :, 1, :) = ahm4 ( :, 2, :)
-      
-      CALL lbc_lnk( ahm3, 'U', 1. )    ! Lateral boundary conditions (unchanged sign)
-      CALL lbc_lnk( ahm4, 'V', 1. )
-
-      ! Control print
-
-      IF( lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm3 array level 1'
-         CALL prihre(ahm3(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) '         ahm4 array level 1'
-         CALL prihre(ahm4(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-      ENDIF
-      !
-      CALL wrk_dealloc( jpi   , jpj   , icof  )
-      CALL wrk_dealloc( jpk   ,         zcoef )
-      CALL wrk_dealloc( jpi   , jpj   , zahm0 )
-      !
-   END SUBROUTINE ldf_dyn_c3d_orca
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_oce.F90	(revision 6040)
+++ 	(revision )
@@ -1,68 +1,0 @@
-MODULE ldfdyn_oce
-   !!======================================================================
-   !!                  ***  MODULE  ldfdyn_oce  ***
-   !! Ocean physics:  lateral momentum mixing coefficient defined in memory 
-   !!======================================================================
-   !! History :  1.0  ! 2002-11  (G. Madec)  F90: Free form and module
-   !!----------------------------------------------------------------------
-   USE par_oce        ! ocean parameters
-   USE in_out_manager ! I/O manager
-   USE lib_mpp         ! MPP library
-
-   IMPLICIT NONE
-   PUBLIC
-
-   !                                       !!* Namelist namdyn_ldf : lateral mixing *
-   LOGICAL , PUBLIC ::   ln_dynldf_lap      !: laplacian operator
-   LOGICAL , PUBLIC ::   ln_dynldf_bilap    !: bilaplacian operator
-   LOGICAL , PUBLIC ::   ln_dynldf_level    !: iso-level direction
-   LOGICAL , PUBLIC ::   ln_dynldf_hor      !: horizontal (geopotential) direction
-   LOGICAL , PUBLIC ::   ln_dynldf_iso      !: iso-neutral direction
-   REAL(wp), PUBLIC ::   rn_ahm_0_lap       !: lateral laplacian eddy viscosity (m2/s)
-   REAL(wp), PUBLIC ::   rn_ahmb_0          !: lateral laplacian background eddy viscosity (m2/s)
-   REAL(wp), PUBLIC ::   rn_ahm_0_blp       !: lateral bilaplacian eddy viscosity (m4/s)
-   REAL(wp), PUBLIC ::   ahm0, ahmb0, ahm0_blp         !: OLD namelist names
-   REAL(wp), PUBLIC ::   rn_cmsmag_1        !: constant in laplacian Smagorinsky viscosity
-   REAL(wp), PUBLIC ::   rn_cmsmag_2        !: constant in bilaplacian Smagorinsky viscosity
-   REAL(wp), PUBLIC ::   rn_cmsh            !: 1 or 0 , if 0 -use only shear for Smagorinsky viscosity
-   REAL(wp), PUBLIC ::   rn_ahm_m_blp       !: upper limit for bilap  abs(ahm) < min( dx^4/128rdt, rn_ahm_m_blp)
-   REAL(wp), PUBLIC ::   rn_ahm_m_lap       !: upper limit for lap  ahm < min(dx^2/16rdt, rn_ahm_m_lap)
-
-   INTEGER , PUBLIC ::   nkahm_smag      =  0          !: 
-
-   !                                                                                  !!! eddy coeff. at U-,V-,W-pts [m2/s]
-#if defined key_dynldf_c3d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ahm1, ahm2, ahm3, ahm4   !: ** 3D coefficients **
-#elif defined key_dynldf_c2d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ahm1, ahm2, ahm3, ahm4   !: ** 2D coefficients **
-#elif defined key_dynldf_c1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:)     ::   ahm1, ahm2, ahm3, ahm4   !: ** 2D coefficients **
-#else
-   REAL(wp), PUBLIC                                      ::   ahm1, ahm2, ahm3, ahm4   !: ** 0D coefficients **
-#endif
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION ldfdyn_oce_alloc()
-      !!----------------------------------------------------------------------
-      !!                 ***  FUNCTION ldfdyn_oce_alloc  ***
-      !!----------------------------------------------------------------------
-      ldfdyn_oce_alloc = 0
-#if defined key_dynldf_c3d
-      ALLOCATE( ahm1(jpi,jpj,jpk) , ahm2(jpi,jpj,jpk) , ahm3(jpi,jpj,jpk) , ahm4(jpi,jpj,jpk) , STAT=ldfdyn_oce_alloc )
-#elif defined key_dynldf_c2d
-      ALLOCATE( ahm1(jpi,jpj    ) , ahm2(jpi,jpj    ) , ahm3(jpi,jpj    ) , ahm4(jpi,jpj    ) , STAT=ldfdyn_oce_alloc )
-#elif defined key_dynldf_c1d
-      ALLOCATE( ahm1(        jpk) , ahm2(        jpk) , ahm3(        jpk) , ahm4(        jpk) , STAT=ldfdyn_oce_alloc )
-#endif
-      IF( ldfdyn_oce_alloc /= 0 )   CALL ctl_warn('ldfdyn_oce_alloc: failed to allocate arrays')
-      !
-   END FUNCTION ldfdyn_oce_alloc
-
-   !!======================================================================
-END MODULE ldfdyn_oce
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_smag.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_smag.F90	(revision 6040)
+++ 	(revision )
@@ -1,301 +1,0 @@
-MODULE ldfdyn_smag
-   !!======================================================================
-   !!                     ***  MODULE  ldftrasmag  ***
-   !! Ocean physics:  variable eddy induced velocity coefficients
-   !!======================================================================
-#if   defined key_dynldf_smag   &&   defined key_dynldf_c3d
-   !!----------------------------------------------------------------------
-   !!   'key_dynldf_smag'      and           smagorinsky  diffusivity
-   !!   'key_dynldf_c3d'                    3D tracer lateral  mixing coef.
-   !!----------------------------------------------------------------------
-   !!   ldf_eiv      : compute the eddy induced velocity coefficients
-   !!----------------------------------------------------------------------
-   !! * Modules used
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_oce         ! surface boundary condition: ocean
-   USE sbcrnf          ! river runoffs
-   USE ldfdyn_oce      ! ocean tracer   lateral physics
-   USE phycst          ! physical constants
-   USE ldfslp          ! iso-neutral slopes
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl          ! Print control
-   USE iom
-   USE wrk_nemo
-   IMPLICIT NONE
-   PRIVATE
-
-   !! * Routine accessibility
-   PUBLIC ldf_dyn_smag               ! routine called by step.F90
-   !!----------------------------------------------------------------------
-   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
-   !! $Id$
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
-   !!----------------------------------------------------------------------
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-
-CONTAINS
-
-
-
-
-
-   !!----------------------------------------------------------------------
-   !!                        ***  ldfdyn_smag.F90  ***
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
-   !! $Id$ 
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   'key_dynldf_smag'             3D lateral eddy viscosity coefficients
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_dyn_smag( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_dyn_smag  ***
-      !!                   
-      !! ** Purpose :   initializations of the horizontal ocean physics
-      !!
-      !! ** Method  :   3D eddy viscosity coef. 
-      !!    M.Griffies, R.Hallberg AMS, 2000
-      !! for laplacian:
-      !!   Asmag=(C/pi)^2*dx*dy sqrt(D^2), C=3-4
-      !! for bilaplacian:
-      !!   Bsmag=Asmag*dx*dy/8
-      !!   D^2=(du/dx-dv/dy)^2+(dv/dx+du/dy)^2 for Cartesian coordinates
-      !!  in general case du/dx ==> e2 d(u/e2)/dx;  du/dy ==> e1 d(u/e1)/dy; 
-      !!                  dv/dx ==> e2 d(v/e2)/dx;  dv/dy ==> e1 d(v/e1)/dy
-      !!
-      !!       laplacian operator   : ahm1, ahm2 defined at T- and F-points
-      !!                              ahm3, ahm4 never used
-      !!       bilaplacian operator : ahm1, ahm2 never used
-      !!                           :  ahm3, ahm4 defined at U- and V-points
-      !!       explanation of the default is missingi
-      !!  last modified : Maria Luneva, September 2011
-      !!----------------------------------------------------------------------
-      !! * Modules used
-      !! ahm0 here is a background viscosity
-
-      !! * Arguments
-
-      !! * local variables
-
-      INTEGER              :: kt                   ! timestep
-
-      INTEGER  ::   ji, jj, jk                     ! dummy loop indices
-      REAL (wp):: zdeltat,zdeltaf,zdeltau,zdeltav  ! temporary scalars
-      REAL (wp), POINTER, DIMENSION (:,:) ::   zux, zuy , zvx ,zvy, zue1, zue2, zve1, zve2 
-      REAL (wp)::  zcmsmag_1, zcmsmag_2 , zcmsh
-
-
-      !!----------------------------------------------------------------------
-
-      CALL wrk_alloc( jpi,jpj,zux,zuy,zvx,zvy )
-      CALL wrk_alloc( jpi,jpj,zue1,zue2,zve1,zve2 )
-
-
-      IF(  kt == nit000 ) THEN
-
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) 'ldf_dyn_smag : 3D lateral eddy viscosity coefficient'
-      IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-     
-      ENDIF
-      
-      zcmsmag_1 = rn_cmsmag_1
-      zcmsmag_2 = rn_cmsmag_2
-      zcmsh     = rn_cmsh
-
-   
-
-
-      ! Set ahm1 and ahm2  ( T- and F- points) (used for laplacian operators
-      ! =================                       whatever its orientation is)
-      IF( ln_dynldf_lap ) THEN
-         ! define ahm1 and ahm2 at the right grid point position
-         ! (USER: modify ahm1 and ahm2 following your desiderata)
-         
-         DO jk=1,jpk
-           zue2(:,:)=un(:,:,jk)/e2u(:,:)
-           zve1(:,:)=vn(:,:,jk)/e1v(:,:)
-           zue1(:,:)=un(:,:,jk)/e1u(:,:)
-           zve2(:,:)=vn(:,:,jk)/e2v(:,:)
-
- 
-           DO jj=2,jpj
-            DO ji=2,jpi
-            zux(ji,jj)=(zue2(ji,jj)-zue2(ji-1,jj))/e1t(ji,jj)*e2t(ji,jj)*tmask(ji,jj,jk) * zcmsh
-            zvy(ji,jj)=(zve1(ji,jj)-zve1(ji,jj-1))/e2t(ji,jj)*e1t(ji,jj)*tmask(ji,jj,jk) * zcmsh
-            ENDDO
-           ENDDO
-
-           DO jj=1,jpjm1
-            DO ji=1,jpim1
-            zuy(ji,jj)=(zue1(ji,jj+1)-zue1(ji,jj))/e2f(ji,jj)*e1f(ji,jj)*fmask(ji,jj,jk)
-            zvx(ji,jj)=(zve2(ji+1,jj)-zve2(ji,jj))/e1f(ji,jj)*e2f(ji,jj)*fmask(ji,jj,jk)
-            ENDDO
-           ENDDO
-             
-          DO jj=2,jpjm1
-           DO ji=2,jpim1
-
-            zdeltat=2._wp /(e1t(ji,jj)**(-2)+e2t(ji,jj)**(-2))
-            zdeltaf=2._wp /(e1f(ji,jj)**(-2)+e2f(ji,jj)**(-2))   
-            ahm1(ji,jj,jk)=(zcmsmag_1/rpi)**2*zdeltat*                                         &
-                            sqrt( (zux(ji,jj)-zvy(ji,jj))**2+                                    &
-                     0.0625_wp*(zuy(ji,jj)+zuy(ji,jj-1)+zuy(ji-1,jj)+zuy(ji-1,jj-1)+             &
-                            zvx(ji,jj)+zvx(ji,jj-1)+zvx(ji-1,jj)+zvx(ji-1,jj-1))**2)
-
-            ahm2(ji,jj,jk)=(zcmsmag_1/rpi)**2*zdeltaf*                                         &
-                            sqrt( (zuy(ji,jj)+zvx(ji,jj))**2+                                    &
-                     0.0625_wp*(zux(ji,jj)+zux(ji,jj+1)+zux(ji+1,jj)+zux(ji+1,jj+1)-             &
-                             zvy(ji,jj)-zvy(ji,jj+1)-zvy(ji+1,jj)-zvy(ji+1,jj+1))**2)
-
-            ahm1(ji,jj,jk)=MAX(ahm1(ji,jj,jk),rn_ahm_0_lap)
-            ahm2(ji,jj,jk)=MAX(ahm2(ji,jj,jk),rn_ahm_0_lap)
-
-! stability criteria or upper limit set from namelist
-            ahm1(ji,jj,jk)=MIN(ahm1(ji,jj,jk),zdeltat / (16_wp*rdt),rn_ahm_m_lap)
-            ahm2(ji,jj,jk)=MIN(ahm2(ji,jj,jk),zdeltaf / (16_wp*rdt),rn_ahm_m_lap)
-
-            ENDDO
-           ENDDO
-
-         ENDDO ! jpk
-            ahm1(:,:,jpk) = ahm1(:,:,jpkm1)
-            ahm2(:,:,jpk) = ahm2(:,:,jpkm1)
-            IF(lwp.and.kt==nit000) WRITE(numout,'(36x," ahm ", 7x)')
-            DO jk = 1, jpk
-
-               IF(lwp.and.kt==nit000) WRITE(numout,'(30x,E10.2,8x,i3)') ahm1(jpi/2,jpj/2,jk), jk
-            END DO
-      CALL lbc_lnk( ahm1, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
-      CALL lbc_lnk( ahm2, 'F', 1. )   ! Lateral boundary conditions on ( ahtt )
-
-      ENDIF    ! ln_dynldf_lap
-      
-
-
-      ! ahm3 and ahm4 at U- and V-points (used for bilaplacian operator
-      ! ================================  whatever its orientation is)
-      ! Here: ahm is proportional to the cube of the maximum of the grid spacing
-      !       in the to horizontal direction
-
-      IF( ln_dynldf_bilap ) THEN
-         DO jk=1,jpk
-           zue2(:,:) = un(:,:,jk)/e2u(:,:)
-           zve1(:,:) = vn(:,:,jk)/e1v(:,:)
-           zue1(:,:) = un(:,:,jk)/e1u(:,:)
-           zve2(:,:) = vn(:,:,jk)/e2v(:,:)
-
-
-           DO jj=2,jpj
-            DO ji=2,jpi
-            zux(ji,jj) = (zue2(ji,jj)-zue2(ji-1,jj))/e1t(ji,jj)*e2t(ji,jj)*tmask(ji,jj,jk)
-            zvy(ji,jj) = (zve1(ji,jj)-zve1(ji,jj-1))/e2t(ji,jj)*e1t(ji,jj)*tmask(ji,jj,jk)
-            ENDDO
-           ENDDO
-
-           DO jj=1,jpjm1
-            DO ji=1,jpim1
-            zuy(ji,jj) = (zue1(ji,jj+1)-zue1(ji,jj))/e2f(ji,jj)*e1f(ji,jj)*fmask(ji,jj,jk)
-            zvx(ji,jj) = (zve2(ji+1,jj)-zve2(ji,jj))/e1f(ji,jj)*e2f(ji,jj)*fmask(ji,jj,jk)
-            ENDDO
-           ENDDO
-
-
-          DO jj=2,jpjm1
-           DO ji=2,jpim1
-            zdeltau = 2._wp/(e1u(ji,jj)**(-2)+e2u(ji,jj)**(-2))
-            zdeltav = 2._wp/(e1v(ji,jj)**(-2)+e2v(ji,jj)**(-2))
-
-            ahm3(ji,jj,jk) = -(zcmsmag_2/rpi)**2/8.0_wp*zdeltau**2*                          &
-
-                         sqrt(0.25_wp*(zux(ji,jj)+zux(ji+1,jj)-zvy(ji,jj)-zvy(ji+1,jj))**2+    &
-                              0.25_wp*(zuy(ji,jj)+zuy(ji,jj-1)+zvx(ji,jj)+zvx(ji,jj-1))**2)
-
-            ahm4(ji,jj,jk) = -(zcmsmag_2/rpi)**2/8.0_wp*zdeltav**2*                           &
-
-                         sqrt(0.25_wp*(zux(ji,jj)+zux(ji,jj+1)-zvy(ji,jj)-zvy(ji,jj+1))**2+    &
-                              0.25_wp*(zuy(ji,jj)+zuy(ji-1,jj)+zvx(ji-1,jj)+zvx(ji,jj))**2)
-
-            ahm3(ji,jj,jk) = MIN (rn_ahm_0_blp , ahm3(ji,jj,jk) )
-            ahm4(ji,jj,jk) = MIN (rn_ahm_0_blp , ahm4(ji,jj,jk) ) 
-
-! stability criteria or upper limit set in namelist
-
-            ahm3(ji,jj,jk) = MAX( ahm3(ji,jj,jk),-zdeltau**2/( 128._wp*rdt ),rn_ahm_m_blp )
-            ahm4(ji,jj,jk) = MAX( ahm4(ji,jj,jk),-zdeltav**2/( 128._wp*rdt ),rn_ahm_m_blp )
-            
-
-            ENDDO
-           ENDDO
-
-         ENDDO
-            ahm3(:,:,jpk) = ahm3(:,:,jpkm1)
-            ahm4(:,:,jpk) = ahm4(:,:,jpkm1)
-
-      DO jk = 1, jpk
-      IF(  kt == nit000 ) THEN
-
-               IF(lwp) WRITE(numout,'(30x,E10.2,8x,i3)') ahm3(jpi/2,jpj/2,jk), jk
-      ENDIF   
-      END DO
-      CALL lbc_lnk( ahm3, 'U', 1. )   ! Lateral boundary conditions
-      CALL lbc_lnk( ahm4, 'V', 1. )
-   ENDIF
-
-      CALL wrk_dealloc( jpi,jpj,zux,zuy,zvx,zvy )
-      CALL wrk_dealloc( jpi,jpj,zue1,zue2,zve1,zve2 )
-   !    zumax = MAXVAL( ABS( ahm3(:,:,:) ) )                ! slower than the following loop on NEC SX5
-      zdeltat = 0._wp
-   If(ln_dynldf_lap)THEN
-      DO jk = 1, jpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zdeltat = MAX(zdeltat,ABS(ahm1(ji,jj,jk)),ABS(ahm2(ji,jj,jk)) )
-          END DO
-        END DO
-      END DO
-      IF( lk_mpp )   CALL mpp_max( zdeltat )                 ! max over the global domain
-      !
-      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,'dynlap:  abs(ahm) max: ', zdeltat
-    ENDIF
-    If(ln_dynldf_bilap)THEN
-     zdeltat = 0._wp
-      DO jk = 1, jpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zdeltat = MAX(zdeltat,ABS(ahm3(ji,jj,jk)),ABS(ahm3(ji,jj,jk)) )
-          END DO
-        END DO
-      END DO
-      IF( lk_mpp )   CALL mpp_max( zdeltat )                 ! max over the global domain
-      !
-      IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,'dyn_bilap abs(ahm) max: ', zdeltat
-      !
-   ENDIF
-      !
-
-END SUBROUTINE ldf_dyn_smag
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Dummy module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE ldf_dyn_smag( kt )       ! Empty routine
-      WRITE(*,*) 'ldf_dyn_smag: You should not have seen this print! error? check keys ldf:c3d+smag', kt
-   END SUBROUTINE ldf_dyn_smag
-#endif
-
-   END MODULE ldfdyn_smag
-
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_substitute.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfdyn_substitute.h90	(revision 6040)
+++ 	(revision )
@@ -1,40 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                    ***  ldfdyn_substitute.h90  ***
-   !!----------------------------------------------------------------------
-   !! ** purpose :   substitute fsahm., the lateral eddy viscosity coeff. 
-   !!      with a constant, or 1D, or 2D or 3D array, using CPP macro.
-   !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-   !!
-   !! fsahmt, fsahmf - used for laplaian operator only
-   !! fsahmu, fsahmv - used for bilaplacian operator only
-   !!
-#if defined key_dynldf_c3d
-!   ' key_dynldf_c3d' :                  3D coefficient
-#    define   fsahmt(i,j,k)    ahm1(i,j,k)
-#    define   fsahmf(i,j,k)    ahm2(i,j,k)
-#    define   fsahmu(i,j,k)    ahm3(i,j,k)
-#    define   fsahmv(i,j,k)    ahm4(i,j,k)
-#elif defined key_dynldf_c2d
-!   ' key_dynldf_c2d' :                 2D coefficient
-#  define   fsahmt(i,j,k)    ahm1(i,j)
-#  define   fsahmf(i,j,k)    ahm2(i,j)
-#  define   fsahmu(i,j,k)    ahm3(i,j)
-#  define   fsahmv(i,j,k)    ahm4(i,j)
-#elif defined key_dynldf_c1d
-!   'key_dynldf_c1d' :                  1D coefficient
-#  define   fsahmt(i,j,k)    ahm1(k)
-#  define   fsahmf(i,j,k)    ahm1(k)
-#  define   fsahmu(i,j,k)    ahm2(k)
-#  define   fsahmv(i,j,k)    ahm2(k)
-#else
-!   default option :               Constant coefficient
-#  define   fsahmt(i,j,k)   ahm0
-#  define   fsahmf(i,j,k)   ahm0
-#  define   fsahmu(i,j,k)   ahm0_blp
-#  define   fsahmv(i,j,k)   ahm0_blp
-#endif
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv.F90	(revision 6040)
+++ 	(revision )
@@ -1,224 +1,0 @@
-MODULE ldfeiv
-   !!======================================================================
-   !!                     ***  MODULE  ldfeiv  ***
-   !! Ocean physics:  variable eddy induced velocity coefficients
-   !!======================================================================
-   !! History :  OPA  ! 1999-03  (G. Madec, A. Jouzeau)  Original code
-   !!   NEMO     1.0  ! 2002-06  (G. Madec)  Free form, F90
-   !!----------------------------------------------------------------------
-#if   defined key_traldf_eiv   &&   defined key_traldf_c2d
-   !!----------------------------------------------------------------------
-   !!   'key_traldf_eiv'      and                     eddy induced velocity
-   !!   'key_traldf_c2d'                    2D tracer lateral  mixing coef.
-   !!----------------------------------------------------------------------
-   !!   ldf_eiv      : compute the eddy induced velocity coefficients
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_oce         ! surface boundary condition: ocean
-   USE sbcrnf          ! river runoffs
-   USE ldftra_oce      ! ocean tracer   lateral physics
-   USE phycst          ! physical constants
-   USE ldfslp          ! iso-neutral slopes
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl          ! Print control
-   USE iom             ! I/O library
-   USE wrk_nemo        ! work arrays
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-   
-   PUBLIC   ldf_eiv    ! routine called by step.F90
-   
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE ldf_eiv( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_eiv  ***
-      !!
-      !! ** Purpose :   Compute the eddy induced velocity coefficient from the
-      !!              growth rate of baroclinic instability.
-      !!
-      !! ** Method :
-      !!
-      !! ** Action : - uslp , vslp  : i- and j-slopes of neutral surfaces at u- & v-points
-      !!             - wslpi, wslpj : i- and j-slopes of neutral surfaces at w-points. 
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step inedx
-      !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zfw, ze3w, zn2, zf20, zaht, zaht_min      ! temporary scalars
-      REAL(wp), DIMENSION(:,:), POINTER ::   zn, zah, zhw, zross   ! 2D workspace
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ldf_eiv')
-      !
-      CALL wrk_alloc( jpi,jpj, zn, zah, zhw, zross )
-
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'ldf_eiv : eddy induced velocity coefficients'
-         IF(lwp) WRITE(numout,*) '~~~~~~~'
-      ENDIF
-      
-      ! 0. Local initialization
-      ! -----------------------
-      zn   (:,:) = 0._wp
-      zhw  (:,:) = 5._wp
-      zah  (:,:) = 0._wp
-      zross(:,:) = 0._wp
-
-
-      ! 1. Compute lateral diffusive coefficient 
-      ! ----------------------------------------
-      IF( ln_traldf_grif ) THEN
-         DO jk = 1, jpk
-            DO jj = 2, jpjm1
-               DO ji = 2, jpim1
-                  ! Take the max of N^2 and zero then take the vertical sum 
-                  ! of the square root of the resulting N^2 ( required to compute 
-                  ! internal Rossby radius Ro = .5 * sum_jpk(N) / f 
-                  zn2 = MAX( rn2b(ji,jj,jk), 0._wp )
-                  zn(ji,jj) = zn(ji,jj) + SQRT( zn2 ) * fse3w(ji,jj,jk)
-                  ! Compute elements required for the inverse time scale of baroclinic
-                  ! eddies using the isopycnal slopes calculated in ldfslp.F : 
-                  ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
-                  ze3w = fse3w(ji,jj,jk) * tmask(ji,jj,jk)
-                  zah(ji,jj) = zah(ji,jj) + zn2 * wslp2(ji,jj,jk) * ze3w
-                  zhw(ji,jj) = zhw(ji,jj) + ze3w
-               END DO
-            END DO
-         END DO
-      ELSE
-         DO jk = 1, jpk
-            DO jj = 2, jpjm1
-               DO ji = 2, jpim1
-                  ! Take the max of N^2 and zero then take the vertical sum 
-                  ! of the square root of the resulting N^2 ( required to compute 
-                  ! internal Rossby radius Ro = .5 * sum_jpk(N) / f 
-                  zn2 = MAX( rn2b(ji,jj,jk), 0._wp )
-                  zn(ji,jj) = zn(ji,jj) + SQRT( zn2 ) * fse3w(ji,jj,jk)
-                  ! Compute elements required for the inverse time scale of baroclinic
-                  ! eddies using the isopycnal slopes calculated in ldfslp.F : 
-                  ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
-                  ze3w = fse3w(ji,jj,jk) * tmask(ji,jj,jk)
-                  zah(ji,jj) = zah(ji,jj) + zn2 * ( wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
-                     &                            + wslpj(ji,jj,jk) * wslpj(ji,jj,jk) ) * ze3w
-                  zhw(ji,jj) = zhw(ji,jj) + ze3w
-               END DO
-            END DO
-         END DO
-      END IF
-
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            zfw = MAX( ABS( 2. * omega * SIN( rad * gphit(ji,jj) ) ) , 1.e-10 )
-            ! Rossby radius at w-point taken < 40km and  > 2km
-            zross(ji,jj) = MAX( MIN( .4 * zn(ji,jj) / zfw, 40.e3 ), 2.e3 )
-            ! Compute aeiw by multiplying Ro^2 and T^-1
-            aeiw(ji,jj) = zross(ji,jj) * zross(ji,jj) * SQRT( zah(ji,jj) / zhw(ji,jj) ) * ssmask(ji,jj)
-         END DO
-      END DO
-
-      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA R2
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK 
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               ! Take the minimum between aeiw and 1000 m2/s over shelves (depth shallower than 650 m)
-               IF( mbkt(ji,jj) <= 20 )   aeiw(ji,jj) = MIN( aeiw(ji,jj), 1000. )
-            END DO
-         END DO
-      ENDIF
-
-      ! Decrease the coefficient in the tropics (20N-20S) 
-      zf20 = 2._wp * omega * sin( rad * 20._wp )
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            aeiw(ji,jj) = MIN( 1., ABS( ff(ji,jj) / zf20 ) ) * aeiw(ji,jj)
-         END DO
-      END DO
-
-      ! ORCA R05: Take the minimum between aeiw  and aeiv0
-      IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               aeiw(ji,jj) = MIN( aeiw(ji,jj), aeiv0 )
-            END DO
-         END DO
-      ENDIF
-      CALL lbc_lnk( aeiw, 'W', 1. )      ! lateral boundary condition on aeiw 
-
-
-      ! Average the diffusive coefficient at u- v- points 
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1   ! vector opt.
-            aeiu(ji,jj) = 0.5_wp * ( aeiw(ji,jj) + aeiw(ji+1,jj  ) )
-            aeiv(ji,jj) = 0.5_wp * ( aeiw(ji,jj) + aeiw(ji  ,jj+1) )
-         END DO 
-      END DO 
-      CALL lbc_lnk( aeiu, 'U', 1. )   ;   CALL lbc_lnk( aeiv, 'V', 1. )      ! lateral boundary condition
-
-
-      IF(ln_ctl) THEN
-         CALL prt_ctl(tab2d_1=aeiu, clinfo1=' eiv  - u: ', ovlap=1)
-         CALL prt_ctl(tab2d_1=aeiv, clinfo1=' eiv  - v: ', ovlap=1)
-      ENDIF
-
-      ! ORCA R05: add a space variation on aht (=aeiv except at the equator and river mouth)
-      IF( cp_cfg == "orca" .AND. jp_cfg == 05 ) THEN
-         zf20     = 2._wp * omega * SIN( rad * 20._wp )
-         zaht_min = 100._wp                           ! minimum value for aht
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zaht      = ( 1._wp -  MIN( 1._wp , ABS( ff(ji,jj) / zf20 ) ) ) * ( aht0 - zaht_min )  &
-                  &      + aht0 * rnfmsk(ji,jj)                          ! enhanced near river mouths
-               ahtu(ji,jj) = MAX( MAX( zaht_min, aeiu(ji,jj) ) + zaht, aht0 )
-               ahtv(ji,jj) = MAX( MAX( zaht_min, aeiv(ji,jj) ) + zaht, aht0 )
-               ahtw(ji,jj) = MAX( MAX( zaht_min, aeiw(ji,jj) ) + zaht, aht0 )
-            END DO
-         END DO
-         IF(ln_ctl) THEN
-            CALL prt_ctl(tab2d_1=ahtu, clinfo1=' aht  - u: ', ovlap=1)
-            CALL prt_ctl(tab2d_1=ahtv, clinfo1=' aht  - v: ', ovlap=1)
-            CALL prt_ctl(tab2d_1=ahtw, clinfo1=' aht  - w: ', ovlap=1)
-         ENDIF
-      ENDIF
-
-      IF( aeiv0 == 0._wp ) THEN
-         aeiu(:,:) = 0._wp
-         aeiv(:,:) = 0._wp
-         aeiw(:,:) = 0._wp
-      ENDIF
-
-      CALL iom_put( "aht2d"    , ahtw )   ! lateral eddy diffusivity
-      CALL iom_put( "aht2d_eiv", aeiw )   ! EIV lateral eddy diffusivity
-      !  
-      CALL wrk_dealloc( jpi,jpj, zn, zah, zhw, zross )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ldf_eiv')
-      !
-   END SUBROUTINE ldf_eiv
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Dummy module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE ldf_eiv( kt )       ! Empty routine
-      INTEGER :: kt
-      WRITE(*,*) 'ldf_eiv: You should not have seen this print! error?', kt
-   END SUBROUTINE ldf_eiv
-#endif
-
-   !!======================================================================
-END MODULE ldfeiv
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv_substitute.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfeiv_substitute.h90	(revision 6040)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#if defined key_traldf_eiv   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!                   ***  ldfeiv_substitute.h90  ***
-   !!----------------------------------------------------------------------
-   !! ** purpose :   substitute fsaei. the eddy induced velocity coeff.
-   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
-   !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-#  if defined key_traldf_c3d
-!   'traldf_c3d' :                           eiv: 3D coefficient
-#    define   fsaeiu(i,j,k)   aeiu(i,j,k)
-#    define   fsaeiv(i,j,k)   aeiv(i,j,k)
-#    define   fsaeiw(i,j,k)   aeiw(i,j,k)
-#  elif defined key_traldf_c2d
-!   'traldf_c2d' :                           eiv: 2D coefficient
-#    define   fsaeiu(i,j,k)   aeiu(i,j)
-#    define   fsaeiv(i,j,k)   aeiv(i,j)
-#    define   fsaeiw(i,j,k)   aeiw(i,j)
-#  elif defined key_traldf_c1d
-!   'traldf_c1d' :                           eiv: 1D coefficient
-#    define   fsaeiu(i,j,k)   aeiu(k)
-#    define   fsaeiv(i,j,k)   aeiv(k)
-#    define   fsaeiw(i,j,k)   aeiw(k)
-#  else
-!   Default option :                          eiv: Constant coefficient
-#    define   fsaeiu(i,j,k)   aeiv0
-#    define   fsaeiv(i,j,k)   aeiv0
-#    define   fsaeiw(i,j,k)   aeiv0
-#  endif
-#else
-!   Default option :                         eiv: dummy variables
-#    define   fsaeiu(i,j,k)   aeiv0
-#    define   fsaeiv(i,j,k)   aeiv0
-#    define   fsaeiw(i,j,k)   aeiv0
-#endif
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldfslp.F90	(revision 6041)
@@ -11,11 +11,10 @@
    !!            3.3  ! 2010-10  (G. Nurser, C. Harris, G. Madec)  add Griffies operator
    !!             -   ! 2010-11  (F. Dupond, G. Madec)  bug correction in slopes just below the ML
+   !!            3.7  ! 2013-12  (F. Lemarie, G. Madec)  add limiter on triad slopes
    !!----------------------------------------------------------------------
-#if   defined key_ldfslp   ||   defined key_esopa
+
    !!----------------------------------------------------------------------
-   !!   'key_ldfslp'                      Rotation of lateral mixing tensor
-   !!----------------------------------------------------------------------
-   !!   ldf_slp_grif  : calculates the triads of isoneutral slopes (Griffies operator)
    !!   ldf_slp       : calculates the slopes of neutral surface   (Madec operator)
+   !!   ldf_slp_triad : calculates the triads of isoneutral slopes (Griffies operator)
    !!   ldf_slp_mxl   : calculates the slopes at the base of the mixed layer (Madec operator)
    !!   ldf_slp_init  : initialization of the slopes computation
@@ -23,6 +22,5 @@
    USE oce            ! ocean dynamics and tracers
    USE dom_oce        ! ocean space and time domain
-   USE ldftra_oce     ! lateral diffusion: traceur
-   USE ldfdyn_oce     ! lateral diffusion: dynamics
+   USE ldfdyn         ! lateral diffusion: eddy viscosity coef.
    USE phycst         ! physical constants
    USE zdfmxl         ! mixed layer depth
@@ -30,29 +28,42 @@
    !
    USE in_out_manager ! I/O manager
+   USE prtctl         ! Print control
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl         ! Print control
+   USE lib_mpp        ! distribued memory computing library
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
    USE wrk_nemo       ! work arrays
    USE timing         ! Timing
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   ldf_slp        ! routine called by step.F90
-   PUBLIC   ldf_slp_grif   ! routine called by step.F90
-   PUBLIC   ldf_slp_init   ! routine called by opa.F90
-
-   LOGICAL , PUBLIC, PARAMETER ::   lk_ldfslp = .TRUE.     !: slopes flag
-   !                                                                             !! Madec operator
-   !  Arrays allocated in ldf_slp_init() routine once we know whether we're using the Griffies or Madec operator
+   PUBLIC   ldf_slp         ! routine called by step.F90
+   PUBLIC   ldf_slp_triad   ! routine called by step.F90
+   PUBLIC   ldf_slp_init    ! routine called by nemogcm.F90
+
+   LOGICAL , PUBLIC ::   l_ldfslp = .FALSE.     !: slopes flag
+
+   LOGICAL , PUBLIC ::   ln_traldf_iso   = .TRUE.       !: iso-neutral direction
+   LOGICAL , PUBLIC ::   ln_traldf_triad = .FALSE.      !: griffies triad scheme
+
+   LOGICAL , PUBLIC ::   ln_triad_iso    = .FALSE.      !: pure horizontal mixing in ML
+   LOGICAL , PUBLIC ::   ln_botmix_triad = .FALSE.      !: mixing on bottom
+   REAL(wp), PUBLIC ::   rn_sw_triad     = 1._wp        !: =1 switching triads ; =0 all four triads used 
+   REAL(wp), PUBLIC ::   rn_slpmax       = 0.01_wp      !: slope limit
+
+   LOGICAL , PUBLIC ::   l_grad_zps = .FALSE.           !: special treatment for Horz Tgradients w partial steps (triad operator)
+   
+   !                                                     !! Classic operator (Madec)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   uslp, wslpi          !: i_slope at U- and W-points
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   vslp, wslpj          !: j-slope at V- and W-points
-   !                                                                !! Griffies operator
+   !                                                     !! triad operator (Griffies)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   wslp2                !: wslp**2 from Griffies quarter cells
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:,:) ::   triadi_g, triadj_g   !: skew flux  slopes relative to geopotentials
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:,:) ::   triadi  , triadj     !: isoneutral slopes relative to model-coordinate
-
-   !                                                              !! Madec operator
-   !  Arrays allocated in ldf_slp_init() routine once we know whether we're using the Griffies or Madec operator
+   !                                                     !! both operators
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   ah_wslp2             !: ah * slope^2 at w-point
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)     ::   akz                  !: stabilizing vertical diffusivity
+   
+   !                                                     !! Madec operator
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   omlmask           ! mask of the surface mixed layer at T-pt
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   uslpml, wslpiml   ! i_slope at U- and W-points just below the mixed layer
@@ -63,9 +74,7 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
-#  include "ldfeiv_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -105,13 +114,11 @@
       INTEGER  ::   ii0, ii1, iku   ! temporary integer
       INTEGER  ::   ij0, ij1, ikv   ! temporary integer
-      REAL(wp) ::   zeps, zm1_g, zm1_2g, z1_16, zcofw ! local scalars
+      REAL(wp) ::   zeps, zm1_g, zm1_2g, z1_16, zcofw, z1_slpmax ! local scalars
       REAL(wp) ::   zci, zfi, zau, zbu, zai, zbi   !   -      -
       REAL(wp) ::   zcj, zfj, zav, zbv, zaj, zbj   !   -      -
       REAL(wp) ::   zck, zfk,      zbw             !   -      -
-      REAL(wp) ::   zdepv, zdepu         !   -      -
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwz, zww
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  zdzr
       REAL(wp), POINTER, DIMENSION(:,:,:) ::  zgru, zgrv
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zhmlpu, zhmlpv
       !!----------------------------------------------------------------------
       !
@@ -119,349 +126,225 @@
       !
       CALL wrk_alloc( jpi,jpj,jpk, zwz, zww, zdzr, zgru, zgrv )
-      CALL wrk_alloc( jpi,jpj, zhmlpu, zhmlpv )
-
-      IF ( ln_traldf_iso .OR. ln_dynldf_iso ) THEN 
-     
-         zeps   =  1.e-20_wp        !==   Local constant initialization   ==!
-         z1_16  =  1.0_wp / 16._wp
-         zm1_g  = -1.0_wp / grav
-         zm1_2g = -0.5_wp / grav
-         !
-         zww(:,:,:) = 0._wp
-         zwz(:,:,:) = 0._wp
-         !
-         DO jk = 1, jpk             !==   i- & j-gradient of density   ==!
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zgru(ji,jj,jk) = umask(ji,jj,jk) * ( prd(ji+1,jj  ,jk) - prd(ji,jj,jk) )
-                  zgrv(ji,jj,jk) = vmask(ji,jj,jk) * ( prd(ji  ,jj+1,jk) - prd(ji,jj,jk) )
-               END DO
-            END DO
-         END DO
-         IF( ln_zps ) THEN                           ! partial steps correction at the bottom ocean level
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zgru(ji,jj,mbku(ji,jj)) = gru(ji,jj)
-                  zgrv(ji,jj,mbkv(ji,jj)) = grv(ji,jj)
-               END DO
-            END DO
-         ENDIF
-         IF( ln_zps .AND. ln_isfcav ) THEN           ! partial steps correction at the bottom ocean level
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-               IF ( miku(ji,jj) > 1 ) zgru(ji,jj,miku(ji,jj)) = grui(ji,jj) 
-               IF ( mikv(ji,jj) > 1 ) zgrv(ji,jj,mikv(ji,jj)) = grvi(ji,jj)
-               END DO
-            END DO
-         ENDIF
-         !
-         !==   Local vertical density gradient at T-point   == !   (evaluated from N^2)
-         ! interior value
-         DO jk = 2, jpkm1
-            !                                ! zdzr = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
-            !                                !   trick: tmask(ik  )  = 0   =>   all pn2   = 0   =>   zdzr = 0
-            !                                !    else  tmask(ik+1)  = 0   =>   pn2(ik+1) = 0   =>   zdzr divides by 1
-            !                                !          umask(ik+1) /= 0   =>   all pn2  /= 0   =>   zdzr divides by 2
-            !                                ! NB: 1/(tmask+1) = (1-.5*tmask)  substitute a / by a *  ==> faster
-            zdzr(:,:,jk) = zm1_g * ( prd(:,:,jk) + 1._wp )              &
-               &                 * ( pn2(:,:,jk) + pn2(:,:,jk+1) ) * ( 1._wp - 0.5_wp * tmask(:,:,jk+1) )
-         END DO
-         ! surface initialisation 
-         zdzr(:,:,1) = 0._wp 
-         IF ( ln_isfcav ) THEN
-            ! if isf need to overwrite the interior value at at the first ocean point
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zdzr(ji,jj,1:mikt(ji,jj)) = 0._wp
-               END DO
-            END DO
-         END IF
-         !
-         !                          !==   Slopes just below the mixed layer   ==!
-         CALL ldf_slp_mxl( prd, pn2, zgru, zgrv, zdzr )        ! output: uslpml, vslpml, wslpiml, wslpjml
-
-
-         ! I.  slopes at u and v point      | uslp = d/di( prd ) / d/dz( prd )
-         ! ===========================      | vslp = d/dj( prd ) / d/dz( prd )
-         !
-         IF ( ln_isfcav ) THEN
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF (miku(ji,jj) .GT. miku(ji+1,jj)) zhmlpu(ji,jj) = MAX(hmlpt(ji  ,jj  ),                   5._wp)
-                  IF (miku(ji,jj) .LT. miku(ji+1,jj)) zhmlpu(ji,jj) = MAX(hmlpt(ji+1,jj  ),                   5._wp)
-                  IF (miku(ji,jj) .EQ. miku(ji+1,jj)) zhmlpu(ji,jj) = MAX(hmlpt(ji  ,jj  ), hmlpt(ji+1,jj  ), 5._wp)
-                  IF (mikv(ji,jj) .GT. miku(ji,jj+1)) zhmlpv(ji,jj) = MAX(hmlpt(ji  ,jj  ),                   5._wp)
-                  IF (mikv(ji,jj) .LT. miku(ji,jj+1)) zhmlpv(ji,jj) = MAX(hmlpt(ji  ,jj+1),                   5._wp)
-                  IF (mikv(ji,jj) .EQ. miku(ji,jj+1)) zhmlpv(ji,jj) = MAX(hmlpt(ji  ,jj  ), hmlpt(ji  ,jj+1), 5._wp)
-               ENDDO
-            ENDDO
-         ELSE
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zhmlpu(ji,jj) = MAX(hmlpt(ji,jj), hmlpt(ji+1,jj  ), 5._wp)
-                  zhmlpv(ji,jj) = MAX(hmlpt(ji,jj), hmlpt(ji  ,jj+1), 5._wp)
-               ENDDO
-            ENDDO
-         END IF
-         DO jk = 2, jpkm1                            !* Slopes at u and v points
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  !                                      ! horizontal and vertical density gradient at u- and v-points
-                  zau = zgru(ji,jj,jk) / e1u(ji,jj)
-                  zav = zgrv(ji,jj,jk) / e2v(ji,jj)
-                  zbu = 0.5_wp * ( zdzr(ji,jj,jk) + zdzr(ji+1,jj  ,jk) )
-                  zbv = 0.5_wp * ( zdzr(ji,jj,jk) + zdzr(ji  ,jj+1,jk) )
-                  !                                      ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
-                  !                                      ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
-                  zbu = MIN(  zbu, -100._wp* ABS( zau ) , -7.e+3_wp/fse3u(ji,jj,jk)* ABS( zau )  )
-                  zbv = MIN(  zbv, -100._wp* ABS( zav ) , -7.e+3_wp/fse3v(ji,jj,jk)* ABS( zav )  )
-                  !                                      ! uslp and vslp output in zwz and zww, resp.
-                  zfi = MAX( omlmask(ji,jj,jk), omlmask(ji+1,jj  ,jk) )
-                  zfj = MAX( omlmask(ji,jj,jk), omlmask(ji  ,jj+1,jk) )
-                  ! thickness of water column between surface and level k at u/v point
-                  zdepu = 0.5_wp * ( ( fsdept(ji,jj,jk) + fsdept(ji+1,jj  ,jk) )                              &
-                                   - 2 * MAX( risfdep(ji,jj), risfdep(ji+1,jj  ) ) - fse3u(ji,jj,miku(ji,jj)) )
-                  zdepv = 0.5_wp * ( ( fsdept(ji,jj,jk) + fsdept(ji  ,jj+1,jk) )                              &
-                                   - 2 * MAX( risfdep(ji,jj), risfdep(ji  ,jj+1) ) - fse3v(ji,jj,mikv(ji,jj)) )
-                  !
-                  zwz(ji,jj,jk) = ( 1. - zfi) * zau / ( zbu - zeps )                                          &
-                     &                 + zfi  * uslpml(ji,jj) * zdepu / zhmlpu(ji,jj)
-                  zwz(ji,jj,jk) = zwz(ji,jj,jk) * wumask(ji,jj,jk)
-                  zww(ji,jj,jk) = ( 1. - zfj) * zav / ( zbv - zeps )                                          &
-                     &                 + zfj  * vslpml(ji,jj) * zdepv / zhmlpv(ji,jj) 
-                  zww(ji,jj,jk) = zww(ji,jj,jk) * wvmask(ji,jj,jk)
-                  
-                 
+
+      zeps   =  1.e-20_wp        !==   Local constant initialization   ==!
+      z1_16  =  1.0_wp / 16._wp
+      zm1_g  = -1.0_wp / grav
+      zm1_2g = -0.5_wp / grav
+      z1_slpmax = 1._wp / rn_slpmax
+      !
+      zww(:,:,:) = 0._wp
+      zwz(:,:,:) = 0._wp
+      !
+      DO jk = 1, jpk             !==   i- & j-gradient of density   ==!
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zgru(ji,jj,jk) = umask(ji,jj,jk) * ( prd(ji+1,jj  ,jk) - prd(ji,jj,jk) )
+               zgrv(ji,jj,jk) = vmask(ji,jj,jk) * ( prd(ji  ,jj+1,jk) - prd(ji,jj,jk) )
+            END DO
+         END DO
+      END DO
+      IF( ln_zps ) THEN                           ! partial steps correction at the bottom ocean level
+         DO jj = 1, jpjm1
+            DO ji = 1, jpim1
+               zgru(ji,jj,mbku(ji,jj)) = gru(ji,jj)
+               zgrv(ji,jj,mbkv(ji,jj)) = grv(ji,jj)
+            END DO
+         END DO
+      ENDIF
+      !
+      zdzr(:,:,1) = 0._wp        !==   Local vertical density gradient at T-point   == !   (evaluated from N^2)
+      DO jk = 2, jpkm1
+         !                                ! zdzr = d/dz(prd)= - ( prd ) / grav * mk(pn2) -- at t point
+         !                                !   trick: tmask(ik  )  = 0   =>   all pn2   = 0   =>   zdzr = 0
+         !                                !    else  tmask(ik+1)  = 0   =>   pn2(ik+1) = 0   =>   zdzr divides by 1
+         !                                !          umask(ik+1) /= 0   =>   all pn2  /= 0   =>   zdzr divides by 2
+         !                                ! NB: 1/(tmask+1) = (1-.5*tmask)  substitute a / by a *  ==> faster
+         zdzr(:,:,jk) = zm1_g * ( prd(:,:,jk) + 1._wp )              &
+            &                 * ( pn2(:,:,jk) + pn2(:,:,jk+1) ) * ( 1._wp - 0.5_wp * tmask(:,:,jk+1) )
+      END DO
+      !
+      !                          !==   Slopes just below the mixed layer   ==!
+      CALL ldf_slp_mxl( prd, pn2, zgru, zgrv, zdzr )        ! output: uslpml, vslpml, wslpiml, wslpjml
+
+
+      ! I.  slopes at u and v point      | uslp = d/di( prd ) / d/dz( prd )
+      ! ===========================      | vslp = d/dj( prd ) / d/dz( prd )
+      !
+      DO jk = 2, jpkm1                            !* Slopes at u and v points
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               !                                      ! horizontal and vertical density gradient at u- and v-points
+               zau = zgru(ji,jj,jk) * r1_e1u(ji,jj)
+               zav = zgrv(ji,jj,jk) * r1_e2v(ji,jj)
+               zbu = 0.5_wp * ( zdzr(ji,jj,jk) + zdzr(ji+1,jj  ,jk) )
+               zbv = 0.5_wp * ( zdzr(ji,jj,jk) + zdzr(ji  ,jj+1,jk) )
+               !                                      ! bound the slopes: abs(zw.)<= 1/100 and zb..<0
+               !                                      ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+               zbu = MIN(  zbu, - z1_slpmax * ABS( zau ) , -7.e+3_wp/fse3u(ji,jj,jk)* ABS( zau )  )
+               zbv = MIN(  zbv, - z1_slpmax * ABS( zav ) , -7.e+3_wp/fse3v(ji,jj,jk)* ABS( zav )  )
+               !                                      ! uslp and vslp output in zwz and zww, resp.
+               zfi = MAX( omlmask(ji,jj,jk), omlmask(ji+1,jj,jk) )
+               zfj = MAX( omlmask(ji,jj,jk), omlmask(ji,jj+1,jk) )
+               zwz(ji,jj,jk) = ( ( 1. - zfi) * zau / ( zbu - zeps )                                              &
+                  &                   + zfi  * uslpml(ji,jj)                                                     &
+                  &                          * 0.5_wp * ( fsdept(ji+1,jj,jk)+fsdept(ji,jj,jk)-fse3u(ji,jj,1) )   &
+                  &                          / MAX( hmlpt(ji,jj), hmlpt(ji+1,jj), 5._wp ) ) * umask(ji,jj,jk)
+               zww(ji,jj,jk) = ( ( 1. - zfj) * zav / ( zbv - zeps )                                              &
+                  &                   + zfj  * vslpml(ji,jj)                                                     &
+                  &                          * 0.5_wp * ( fsdept(ji,jj+1,jk)+fsdept(ji,jj,jk)-fse3v(ji,jj,1) )   &
+                  &                          / MAX( hmlpt(ji,jj), hmlpt(ji,jj+1), 5. ) ) * vmask(ji,jj,jk)
 !!gm  modif to suppress omlmask.... (as in Griffies case)
-!                  !                                         ! jk must be >= ML level for zf=1. otherwise  zf=0.
-!                  zfi = REAL( 1 - 1/(1 + jk / MAX( nmln(ji+1,jj), nmln(ji,jj) ) ), wp )
-!                  zfj = REAL( 1 - 1/(1 + jk / MAX( nmln(ji,jj+1), nmln(ji,jj) ) ), wp )
-!                  zci = 0.5 * ( fsdept(ji+1,jj,jk)+fsdept(ji,jj,jk) ) / MAX( hmlpt(ji,jj), hmlpt(ji+1,jj), 10. ) )
-!                  zcj = 0.5 * ( fsdept(ji,jj+1,jk)+fsdept(ji,jj,jk) ) / MAX( hmlpt(ji,jj), hmlpt(ji,jj+1), 10. ) )
-!                  zwz(ji,jj,jk) = ( zfi * zai / ( zbi - zeps ) + ( 1._wp - zfi ) * wslpiml(ji,jj) * zci ) * tmask(ji,jj,jk)
-!                  zww(ji,jj,jk) = ( zfj * zaj / ( zbj - zeps ) + ( 1._wp - zfj ) * wslpjml(ji,jj) * zcj ) * tmask(ji,jj,jk)
+!               !                                         ! jk must be >= ML level for zf=1. otherwise  zf=0.
+!               zfi = REAL( 1 - 1/(1 + jk / MAX( nmln(ji+1,jj), nmln(ji,jj) ) ), wp )
+!               zfj = REAL( 1 - 1/(1 + jk / MAX( nmln(ji,jj+1), nmln(ji,jj) ) ), wp )
+!               zci = 0.5 * ( fsdept(ji+1,jj,jk)+fsdept(ji,jj,jk) ) / MAX( hmlpt(ji,jj), hmlpt(ji+1,jj), 10. ) )
+!               zcj = 0.5 * ( fsdept(ji,jj+1,jk)+fsdept(ji,jj,jk) ) / MAX( hmlpt(ji,jj), hmlpt(ji,jj+1), 10. ) )
+!               zwz(ji,jj,jk) = ( zfi * zai / ( zbi - zeps ) + ( 1._wp - zfi ) * wslpiml(ji,jj) * zci ) * tmask(ji,jj,jk)
+!               zww(ji,jj,jk) = ( zfj * zaj / ( zbj - zeps ) + ( 1._wp - zfj ) * wslpjml(ji,jj) * zcj ) * tmask(ji,jj,jk)
 !!gm end modif
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( zwz, 'U', -1. )   ;   CALL lbc_lnk( zww, 'V', -1. )      ! lateral boundary conditions
-         !
-         !                                            !* horizontal Shapiro filter
-         DO jk = 2, jpkm1
-            DO jj = 2, jpjm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
-               DO ji = 2, jpim1
-                  uslp(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
-                     &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
-                     &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
-                     &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
-                     &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
-                  vslp(ji,jj,jk) = z1_16 * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
-                     &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
-                     &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
-                     &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
-                     &                       + 4.*  zww(ji,jj    ,jk)                       )
-               END DO
-            END DO
-            DO jj = 3, jpj-2                               ! other rows
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  uslp(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
-                     &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
-                     &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
-                     &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
-                     &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
-                  vslp(ji,jj,jk) = z1_16 * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
-                     &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
-                     &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)         &
-                     &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
-                     &                       + 4.*  zww(ji,jj    ,jk)                       )
-               END DO
-            END DO
-            !                                        !* decrease along coastal boundaries
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  uslp(ji,jj,jk) = uslp(ji,jj,jk) * ( umask(ji,jj+1,jk) + umask(ji,jj-1,jk  ) ) * 0.5_wp   &
-                     &                            * ( umask(ji,jj  ,jk) + umask(ji,jj  ,jk+1) ) * 0.5_wp   &
-                     &                            *   umask(ji,jj,jk-1)
-                  vslp(ji,jj,jk) = vslp(ji,jj,jk) * ( vmask(ji+1,jj,jk) + vmask(ji-1,jj,jk  ) ) * 0.5_wp   &
-                     &                            * ( vmask(ji  ,jj,jk) + vmask(ji  ,jj,jk+1) ) * 0.5_wp   &
-                     &                            *   vmask(ji,jj,jk-1)
-               END DO
-            END DO
-         END DO
-
-
-         ! II.  slopes at w point           | wslpi = mij( d/di( prd ) / d/dz( prd )
-         ! ===========================      | wslpj = mij( d/dj( prd ) / d/dz( prd )
-         !
-         DO jk = 2, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  !                                  !* Local vertical density gradient evaluated from N^2
-                  zbw = zm1_2g * pn2 (ji,jj,jk) * ( prd (ji,jj,jk) + prd (ji,jj,jk-1) + 2. ) * wmask(ji,jj,jk)
-                  !                                  !* Slopes at w point
-                  !                                        ! i- & j-gradient of density at w-points
-                  zci = MAX(  umask(ji-1,jj,jk  ) + umask(ji,jj,jk  )           &
-                     &      + umask(ji-1,jj,jk-1) + umask(ji,jj,jk-1) , zeps  ) * e1t(ji,jj)
-                  zcj = MAX(  vmask(ji,jj-1,jk  ) + vmask(ji,jj,jk-1)           &
-                     &      + vmask(ji,jj-1,jk-1) + vmask(ji,jj,jk  ) , zeps  ) *  e2t(ji,jj)
-                  zai =    (  zgru (ji-1,jj,jk  ) + zgru (ji,jj,jk-1)           &
-                     &      + zgru (ji-1,jj,jk-1) + zgru (ji,jj,jk  )   ) / zci
-                  zaj =    (  zgrv (ji,jj-1,jk  ) + zgrv (ji,jj,jk-1)           &
-                     &      + zgrv (ji,jj-1,jk-1) + zgrv (ji,jj,jk  )   ) / zcj
-                  !                                        ! bound the slopes: abs(zw.)<= 1/100 and zb..<0.
-                  !                                        ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
-                  zbi = MIN( zbw ,- 100._wp* ABS( zai ) , -7.e+3_wp/fse3w(ji,jj,jk)* ABS( zai )  )
-                  zbj = MIN( zbw , -100._wp* ABS( zaj ) , -7.e+3_wp/fse3w(ji,jj,jk)* ABS( zaj )  )
-                  !                                        ! wslpi and wslpj with ML flattening (output in zwz and zww, resp.)
-                  zfk = MAX( omlmask(ji,jj,jk), omlmask(ji,jj,jk-1) )   ! zfk=1 in the ML otherwise zfk=0
-                  zck = ( fsdepw(ji,jj,jk) - fsdepw(ji,jj,mikt(ji,jj) ) ) / MAX( hmlp(ji,jj), 10._wp )
-                  zwz(ji,jj,jk) = (  zai / ( zbi - zeps ) * ( 1._wp - zfk ) &
-                     &            + zck * wslpiml(ji,jj) * zfk  ) * wmask(ji,jj,jk)
-                  zww(ji,jj,jk) = (  zaj / ( zbj - zeps ) * ( 1._wp - zfk ) &
-                     &            + zck * wslpjml(ji,jj) * zfk  ) * wmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zwz, 'U', -1. )   ;   CALL lbc_lnk( zww, 'V', -1. )      ! lateral boundary conditions
+      !
+      !                                            !* horizontal Shapiro filter
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
+            DO ji = 2, jpim1
+               uslp(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
+                  &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
+                  &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
+               vslp(ji,jj,jk) = z1_16 * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
+                  &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
+                  &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zww(ji,jj    ,jk)                       )
+            END DO
+         END DO
+         DO jj = 3, jpj-2                               ! other rows
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               uslp(ji,jj,jk) = z1_16 * (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)      &
+                  &                       +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)      &
+                  &                       +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zwz(ji  ,jj  ,jk)                       )
+               vslp(ji,jj,jk) = z1_16 * (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)      &
+                  &                       +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)      &
+                  &                       + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)      &
+                  &                       +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )    &
+                  &                       + 4.*  zww(ji,jj    ,jk)                       )
+            END DO
+         END DO
+         !                                        !* decrease along coastal boundaries
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               uslp(ji,jj,jk) = uslp(ji,jj,jk) * ( umask(ji,jj+1,jk) + umask(ji,jj-1,jk  ) ) * 0.5_wp   &
+                  &                            * ( umask(ji,jj  ,jk) + umask(ji,jj  ,jk+1) ) * 0.5_wp
+               vslp(ji,jj,jk) = vslp(ji,jj,jk) * ( vmask(ji+1,jj,jk) + vmask(ji-1,jj,jk  ) ) * 0.5_wp   &
+                  &                            * ( vmask(ji  ,jj,jk) + vmask(ji  ,jj,jk+1) ) * 0.5_wp
+            END DO
+         END DO
+      END DO
+
+
+      ! II.  slopes at w point           | wslpi = mij( d/di( prd ) / d/dz( prd )
+      ! ===========================      | wslpj = mij( d/dj( prd ) / d/dz( prd )
+      !
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               !                                  !* Local vertical density gradient evaluated from N^2
+               zbw = zm1_2g * pn2 (ji,jj,jk) * ( prd (ji,jj,jk) + prd (ji,jj,jk-1) + 2. )
+               !                                  !* Slopes at w point
+               !                                        ! i- & j-gradient of density at w-points
+               zci = MAX(  umask(ji-1,jj,jk  ) + umask(ji,jj,jk  )           &
+                  &      + umask(ji-1,jj,jk-1) + umask(ji,jj,jk-1) , zeps  ) * e1t(ji,jj)
+               zcj = MAX(  vmask(ji,jj-1,jk  ) + vmask(ji,jj,jk-1)           &
+                  &      + vmask(ji,jj-1,jk-1) + vmask(ji,jj,jk  ) , zeps  ) * e2t(ji,jj)
+               zai =    (  zgru (ji-1,jj,jk  ) + zgru (ji,jj,jk-1)           &
+                  &      + zgru (ji-1,jj,jk-1) + zgru (ji,jj,jk  )   ) / zci * tmask (ji,jj,jk)
+               zaj =    (  zgrv (ji,jj-1,jk  ) + zgrv (ji,jj,jk-1)           &
+                  &      + zgrv (ji,jj-1,jk-1) + zgrv (ji,jj,jk  )   ) / zcj * tmask (ji,jj,jk)
+               !                                        ! bound the slopes: abs(zw.)<= 1/100 and zb..<0.
+               !                                        ! + kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
+               zbi = MIN( zbw ,- 100._wp* ABS( zai ) , -7.e+3_wp/fse3w(ji,jj,jk)* ABS( zai )  )
+               zbj = MIN( zbw , -100._wp* ABS( zaj ) , -7.e+3_wp/fse3w(ji,jj,jk)* ABS( zaj )  )
+               !                                        ! wslpi and wslpj with ML flattening (output in zwz and zww, resp.)
+               zfk = MAX( omlmask(ji,jj,jk), omlmask(ji,jj,jk-1) )   ! zfk=1 in the ML otherwise zfk=0
+               zck = fsdepw(ji,jj,jk) / MAX( hmlp(ji,jj), 10._wp )
+               zwz(ji,jj,jk) = (  zai / ( zbi - zeps ) * ( 1._wp - zfk ) + zck * wslpiml(ji,jj) * zfk  ) * tmask(ji,jj,jk)
+               zww(ji,jj,jk) = (  zaj / ( zbj - zeps ) * ( 1._wp - zfk ) + zck * wslpjml(ji,jj) * zfk  ) * tmask(ji,jj,jk)
 
 !!gm  modif to suppress omlmask....  (as in Griffies operator)
-!                  !                                         ! jk must be >= ML level for zfk=1. otherwise  zfk=0.
-!                  zfk = REAL( 1 - 1/(1 + jk / nmln(ji+1,jj)), wp )
-!                  zck = fsdepw(ji,jj,jk)    / MAX( hmlp(ji,jj), 10. )
-!                  zwz(ji,jj,jk) = ( zfk * zai / ( zbi - zeps ) + ( 1._wp - zfk ) * wslpiml(ji,jj) * zck ) * tmask(ji,jj,jk)
-!                  zww(ji,jj,jk) = ( zfk * zaj / ( zbj - zeps ) + ( 1._wp - zfk ) * wslpjml(ji,jj) * zck ) * tmask(ji,jj,jk)
+!               !                                         ! jk must be >= ML level for zfk=1. otherwise  zfk=0.
+!               zfk = REAL( 1 - 1/(1 + jk / nmln(ji+1,jj)), wp )
+!               zck = fsdepw(ji,jj,jk)    / MAX( hmlp(ji,jj), 10. )
+!               zwz(ji,jj,jk) = ( zfk * zai / ( zbi - zeps ) + ( 1._wp - zfk ) * wslpiml(ji,jj) * zck ) * tmask(ji,jj,jk)
+!               zww(ji,jj,jk) = ( zfk * zaj / ( zbj - zeps ) + ( 1._wp - zfk ) * wslpjml(ji,jj) * zck ) * tmask(ji,jj,jk)
 !!gm end modif
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( zwz, 'T', -1. )   ;    CALL lbc_lnk( zww, 'T', -1. )      ! lateral boundary conditions
-         !
-         !                                           !* horizontal Shapiro filter
-         DO jk = 2, jpkm1
-            DO jj = 2, jpjm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
-               DO ji = 2, jpim1
-                  zcofw = tmask(ji,jj,jk) * z1_16
-                  wslpi(ji,jj,jk) = (          zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
-                       &                +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
-                       &                + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
-                       &                +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
-                       &                + 4.*  zwz(ji  ,jj  ,jk)                         ) * zcofw
-
-                  wslpj(ji,jj,jk) = (          zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
-                       &                +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
-                       &                + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
-                       &                +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
-                       &                + 4.*  zww(ji  ,jj  ,jk)                         ) * zcofw
-               END DO
-            END DO
-            DO jj = 3, jpj-2                               ! other rows
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zcofw = tmask(ji,jj,jk) * z1_16
-                  wslpi(ji,jj,jk) = (        zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
-                       &                +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
-                       &                + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
-                       &                +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
-                       &                + 4.*  zwz(ji  ,jj  ,jk)                         ) * zcofw
-
-                  wslpj(ji,jj,jk) = (        zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
-                       &                +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
-                       &                + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
-                       &                +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
-                       &                + 4.*  zww(ji  ,jj  ,jk)                         ) * zcofw
-               END DO
-            END DO
-            !                                        !* decrease along coastal boundaries
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zck =   ( umask(ji,jj,jk) + umask(ji-1,jj,jk) )   &
-                     &  * ( vmask(ji,jj,jk) + vmask(ji,jj-1,jk) ) * 0.25
-                  wslpi(ji,jj,jk) = wslpi(ji,jj,jk) * zck * wmask(ji,jj,jk)
-                  wslpj(ji,jj,jk) = wslpj(ji,jj,jk) * zck * wmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-
-         ! III.  Specific grid points
-         ! ===========================
-         !
-         IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN     !  ORCA_R4 configuration: horizontal diffusion in specific area
-            !                                                    ! Gibraltar Strait
-            ij0 =  50   ;   ij1 =  53
-            ii0 =  69   ;   ii1 =  71   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            ij0 =  51   ;   ij1 =  53
-            ii0 =  68   ;   ii1 =  71   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            ii0 =  69   ;   ii1 =  71   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            ii0 =  69   ;   ii1 =  71   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            !
-            !                                                    ! Mediterrannean Sea
-            ij0 =  49   ;   ij1 =  56
-            ii0 =  71   ;   ii1 =  90   ;   uslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            ij0 =  50   ;   ij1 =  56
-            ii0 =  70   ;   ii1 =  90   ;   vslp ( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            ii0 =  71   ;   ii1 =  90   ;   wslpi( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-            ii0 =  71   ;   ii1 =  90   ;   wslpj( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) , : ) = 0._wp
-         ENDIF
-
-
-         ! IV. Lateral boundary conditions
-         ! ===============================
-         CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
-         CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
-
-
-         IF(ln_ctl) THEN
-            CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp  - u : ', tab3d_2=vslp,  clinfo2=' v : ', kdim=jpk)
-            CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp  - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk)
-         ENDIF
-         !
-
-      ELSEIF ( lk_vvl ) THEN 
- 
-         IF(lwp) THEN 
-            WRITE(numout,*) '          Horizontal mixing in s-coordinate: slope = slope of s-surfaces' 
-         ENDIF 
-
-         ! geopotential diffusion in s-coordinates on tracers and/or momentum 
-         ! The slopes of s-surfaces are computed at each time step due to vvl 
-         ! The slopes for momentum diffusion are i- or j- averaged of those on tracers 
-
-         ! set the slope of diffusion to the slope of s-surfaces 
-         !      ( c a u t i o n : minus sign as fsdep has positive value ) 
-         DO jj = 2, jpjm1 
-            DO ji = fs_2, fs_jpim1   ! vector opt. 
-               uslp(ji,jj,1) = -1./e1u(ji,jj) * ( fsdept_b(ji+1,jj,1) - fsdept_b(ji ,jj ,1) )  * umask(ji,jj,1) 
-               vslp(ji,jj,1) = -1./e2v(ji,jj) * ( fsdept_b(ji,jj+1,1) - fsdept_b(ji ,jj ,1) )  * vmask(ji,jj,1) 
-               wslpi(ji,jj,1) = -1./e1t(ji,jj) * ( fsdepw_b(ji+1,jj,1) - fsdepw_b(ji-1,jj,1) ) * tmask(ji,jj,1) * 0.5 
-               wslpj(ji,jj,1) = -1./e2t(ji,jj) * ( fsdepw_b(ji,jj+1,1) - fsdepw_b(ji,jj-1,1) ) * tmask(ji,jj,1) * 0.5 
-            END DO 
-         END DO 
-
-         DO jk = 2, jpk 
-            DO jj = 2, jpjm1 
-               DO ji = fs_2, fs_jpim1   ! vector opt. 
-                  uslp(ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept_b(ji+1,jj,jk) - fsdept_b(ji ,jj ,jk) ) * umask(ji,jj,jk) 
-                  vslp(ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept_b(ji,jj+1,jk) - fsdept_b(ji ,jj ,jk) ) * vmask(ji,jj,jk) 
-                  wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw_b(ji+1,jj,jk) - fsdepw_b(ji-1,jj,jk) ) &
-                    &                              * wmask(ji,jj,jk) * 0.5 
-                  wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw_b(ji,jj+1,jk) - fsdepw_b(ji,jj-1,jk) ) &
-                    &                              * wmask(ji,jj,jk) * 0.5 
-               END DO 
-            END DO 
-         END DO 
-
-         ! Lateral boundary conditions on the slopes 
-         CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. ) 
-         CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. ) 
-  
-         if( kt == nit000 ) then 
-            IF(lwp) WRITE(numout,*) ' max slop: u',SQRT( MAXVAL(uslp*uslp)), ' v ', SQRT(MAXVAL(vslp)),  & 
-               &                             ' wi', sqrt(MAXVAL(wslpi)), ' wj', sqrt(MAXVAL(wslpj)) 
-         endif 
-  
-         IF(ln_ctl) THEN 
-            CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp  - u : ', tab3d_2=vslp,  clinfo2=' v : ', kdim=jpk) 
-            CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp  - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk) 
-         ENDIF 
-
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zwz, 'T', -1. )   ;    CALL lbc_lnk( zww, 'T', -1. )      ! lateral boundary conditions
+      !
+      !                                           !* horizontal Shapiro filter
+      DO jk = 2, jpkm1
+         DO jj = 2, jpjm1, MAX(1, jpj-3)                        ! rows jj=2 and =jpjm1 only
+            DO ji = 2, jpim1
+               zcofw = wmask(ji,jj,jk) * z1_16
+               wslpi(ji,jj,jk) = (         zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
+                    &               +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
+                    &               + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
+                    &               +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
+                    &               + 4.*  zwz(ji  ,jj  ,jk)                         ) * zcofw
+
+               wslpj(ji,jj,jk) = (         zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
+                    &               +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
+                    &               + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
+                    &               +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
+                    &               + 4.*  zww(ji  ,jj  ,jk)                         ) * zcofw
+            END DO
+         END DO
+         DO jj = 3, jpj-2                               ! other rows
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zcofw = wmask(ji,jj,jk) * z1_16
+               wslpi(ji,jj,jk) = (         zwz(ji-1,jj-1,jk) + zwz(ji+1,jj-1,jk)     &
+                    &               +      zwz(ji-1,jj+1,jk) + zwz(ji+1,jj+1,jk)     &
+                    &               + 2.*( zwz(ji  ,jj-1,jk) + zwz(ji-1,jj  ,jk)     &
+                    &               +      zwz(ji+1,jj  ,jk) + zwz(ji  ,jj+1,jk) )   &
+                    &               + 4.*  zwz(ji  ,jj  ,jk)                         ) * zcofw
+
+               wslpj(ji,jj,jk) = (         zww(ji-1,jj-1,jk) + zww(ji+1,jj-1,jk)     &
+                    &               +      zww(ji-1,jj+1,jk) + zww(ji+1,jj+1,jk)     &
+                    &               + 2.*( zww(ji  ,jj-1,jk) + zww(ji-1,jj  ,jk)     &
+                    &               +      zww(ji+1,jj  ,jk) + zww(ji  ,jj+1,jk) )   &
+                    &               + 4.*  zww(ji  ,jj  ,jk)                         ) * zcofw
+            END DO
+         END DO
+         !                                        !* decrease in vicinity of topography
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zck =   ( umask(ji,jj,jk) + umask(ji-1,jj,jk) )   &
+                  &  * ( vmask(ji,jj,jk) + vmask(ji,jj-1,jk) ) * 0.25
+               wslpi(ji,jj,jk) = wslpi(ji,jj,jk) * zck
+               wslpj(ji,jj,jk) = wslpj(ji,jj,jk) * zck
+            END DO
+         END DO
+      END DO
+
+      ! IV. Lateral boundary conditions
+      ! ===============================
+      CALL lbc_lnk( uslp , 'U', -1. )      ;      CALL lbc_lnk( vslp , 'V', -1. )
+      CALL lbc_lnk( wslpi, 'W', -1. )      ;      CALL lbc_lnk( wslpj, 'W', -1. )
+
+
+      IF(ln_ctl) THEN
+         CALL prt_ctl(tab3d_1=uslp , clinfo1=' slp  - u : ', tab3d_2=vslp,  clinfo2=' v : ', kdim=jpk)
+         CALL prt_ctl(tab3d_1=wslpi, clinfo1=' slp  - wi: ', tab3d_2=wslpj, clinfo2=' wj: ', kdim=jpk)
       ENDIF
-      
+      !
       CALL wrk_dealloc( jpi,jpj,jpk, zwz, zww, zdzr, zgru, zgrv )
-      CALL wrk_dealloc( jpi,jpj,     zhmlpu, zhmlpv)
       !
       IF( nn_timing == 1 )  CALL timing_stop('ldf_slp')
@@ -470,10 +353,10 @@
 
 
-   SUBROUTINE ldf_slp_grif ( kt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE ldf_slp_grif  ***
+   SUBROUTINE ldf_slp_triad ( kt )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE ldf_slp_triad  ***
       !!
       !! ** Purpose :   Compute the squared slopes of neutral surfaces (slope
-      !!      of iso-pycnal surfaces referenced locally) (ln_traldf_grif=T)
+      !!      of iso-pycnal surfaces referenced locally) (ln_traldf_triad=T)
       !!      at W-points using the Griffies quarter-cells.
       !!
@@ -490,16 +373,20 @@
       REAL(wp) ::   zfacti, zfactj              ! local scalars
       REAL(wp) ::   znot_thru_surface           ! local scalars
-      REAL(wp) ::   zdit, zdis, zdjt, zdjs, zdkt, zdks, zbu, zbv, zbti, zbtj
+      REAL(wp) ::   zdit, zdis, zdkt, zbu, zbti, zisw
+      REAL(wp) ::   zdjt, zdjs, zdks, zbv, zbtj, zjsw
       REAL(wp) ::   zdxrho_raw, zti_coord, zti_raw, zti_lim, zti_g_raw, zti_g_lim
       REAL(wp) ::   zdyrho_raw, ztj_coord, ztj_raw, ztj_lim, ztj_g_raw, ztj_g_lim
       REAL(wp) ::   zdzrho_raw
+      REAL(wp) ::   zbeta0, ze3_e1, ze3_e2
       REAL(wp), POINTER, DIMENSION(:,:)     ::   z1_mlbw
+      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zalbet
       REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zdxrho , zdyrho, zdzrho     ! Horizontal and vertical density gradients
       REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   zti_mlb, ztj_mlb            ! for Griffies operator only
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('ldf_slp_grif')
+      IF( nn_timing == 1 )  CALL timing_start('ldf_slp_triad')
       !
       CALL wrk_alloc( jpi,jpj, z1_mlbw )
+      CALL wrk_alloc( jpi,jpj,jpk, zalbet )
       CALL wrk_alloc( jpi,jpj,jpk,2, zdxrho , zdyrho, zdzrho,              klstart = 0  )
       CALL wrk_alloc( jpi,jpj,  2,2, zti_mlb, ztj_mlb,        kkstart = 0, klstart = 0  )
@@ -519,8 +406,8 @@
                   zdjt = ( tsb(ji,jj+1,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )    ! j-gradient of T & S at v-point
                   zdjs = ( tsb(ji,jj+1,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
-                  zdxrho_raw = ( - rab_b(ji+ip,jj   ,jk,jp_tem) * zdit + rab_b(ji+ip,jj   ,jk,jp_sal) * zdis ) / e1u(ji,jj)
-                  zdyrho_raw = ( - rab_b(ji   ,jj+jp,jk,jp_tem) * zdjt + rab_b(ji   ,jj+jp,jk,jp_sal) * zdjs ) / e2v(ji,jj)
-                  zdxrho(ji+ip,jj   ,jk,1-ip) = SIGN( MAX( repsln, ABS( zdxrho_raw ) ), zdxrho_raw )   ! keep the sign
-                  zdyrho(ji   ,jj+jp,jk,1-jp) = SIGN( MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw )
+                  zdxrho_raw = ( - rab_b(ji+ip,jj   ,jk,jp_tem) * zdit + rab_b(ji+ip,jj   ,jk,jp_sal) * zdis ) * r1_e1u(ji,jj)
+                  zdyrho_raw = ( - rab_b(ji   ,jj+jp,jk,jp_tem) * zdjt + rab_b(ji   ,jj+jp,jk,jp_sal) * zdjs ) * r1_e2v(ji,jj)
+                  zdxrho(ji+ip,jj   ,jk,1-ip) = SIGN(  MAX( repsln, ABS( zdxrho_raw ) ), zdxrho_raw  )   ! keep the sign
+                  zdyrho(ji   ,jj+jp,jk,1-jp) = SIGN(  MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw  )
                END DO
             END DO
@@ -533,6 +420,6 @@
                   zdit = gtsu(ji,jj,jp_tem)   ;   zdjt = gtsv(ji,jj,jp_tem)      ! i- & j-gradient of Temperature
                   zdis = gtsu(ji,jj,jp_sal)   ;   zdjs = gtsv(ji,jj,jp_sal)      ! i- & j-gradient of Salinity
-                  zdxrho_raw = ( - rab_b(ji+ip,jj   ,iku,jp_tem) * zdit + rab_b(ji+ip,jj   ,iku,jp_sal) * zdis ) / e1u(ji,jj)
-                  zdyrho_raw = ( - rab_b(ji   ,jj+jp,ikv,jp_tem) * zdjt + rab_b(ji   ,jj+jp,ikv,jp_sal) * zdjs ) / e2v(ji,jj)
+                  zdxrho_raw = ( - rab_b(ji+ip,jj   ,iku,jp_tem) * zdit + rab_b(ji+ip,jj   ,iku,jp_sal) * zdis ) * r1_e1u(ji,jj)
+                  zdyrho_raw = ( - rab_b(ji   ,jj+jp,ikv,jp_tem) * zdjt + rab_b(ji   ,jj+jp,ikv,jp_sal) * zdjs ) * r1_e2v(ji,jj)
                   zdxrho(ji+ip,jj   ,iku,1-ip) = SIGN( MAX( repsln, ABS( zdxrho_raw ) ), zdxrho_raw )   ! keep the sign
                   zdyrho(ji   ,jj+jp,ikv,1-jp) = SIGN( MAX( repsln, ABS( zdyrho_raw ) ), zdyrho_raw )
@@ -554,6 +441,6 @@
                      zdks = 0._wp
                   ENDIF
-                  zdzrho_raw = ( - rab_b(ji,jj,jk,jp_tem) * zdkt + rab_b(ji,jj,jk,jp_sal) * zdks ) / fse3w(ji,jj,jk+kp)
-                  zdzrho(ji,jj,jk,kp) = - MIN( - repsln, zdzrho_raw )    ! force zdzrho >= repsln
+                  zdzrho_raw = ( - zalbet(ji,jj,jk) * zdkt + zbeta0*zdks ) / fse3w(ji,jj,jk+kp)
+                  zdzrho(ji,jj,jk,kp) = - MIN( - repsln , zdzrho_raw )    ! force zdzrho >= repsln
                  END DO
             END DO
@@ -588,20 +475,22 @@
                   !
                   jk = nmln(ji+ip,jj) + 1
-                  IF( jk .GT. mbkt(ji+ip,jj) ) THEN  !ML reaches bottom
-                    zti_mlb(ji+ip,jj   ,1-ip,kp) = 0.0_wp
-                  ELSE
-                    ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth)
-                    zti_g_raw = (  zdxrho(ji+ip,jj,jk-kp,1-ip) / zdzrho(ji+ip,jj,jk-kp,kp)      &
-                       &      - ( fsdept(ji+1,jj,jk-kp) - fsdept(ji,jj,jk-kp) ) / e1u(ji,jj)  ) * umask(ji,jj,jk)
-                    zti_mlb(ji+ip,jj   ,1-ip,kp) = SIGN( MIN( rn_slpmax, ABS( zti_g_raw ) ), zti_g_raw )
+                  IF( jk > mbkt(ji+ip,jj) ) THEN   ! ML reaches bottom
+                     zti_mlb(ji+ip,jj   ,1-ip,kp) = 0.0_wp
+                  ELSE                             
+                     ! Add s-coordinate slope at t-points (do this by *subtracting* gradient of depth)
+                     zti_g_raw = (  zdxrho(ji+ip,jj,jk-kp,1-ip) / zdzrho(ji+ip,jj,jk-kp,kp)      &
+                        &          - ( fsdept(ji+1,jj,jk-kp) - fsdept(ji,jj,jk-kp) ) * r1_e1u(ji,jj)  ) * umask(ji,jj,jk)
+                     ze3_e1    =  fse3w(ji+ip,jj,jk-kp) * r1_e1u(ji,jj) 
+                     zti_mlb(ji+ip,jj   ,1-ip,kp) = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e1  , ABS( zti_g_raw ) ), zti_g_raw )
                   ENDIF
                   !
                   jk = nmln(ji,jj+jp) + 1
                   IF( jk .GT. mbkt(ji,jj+jp) ) THEN  !ML reaches bottom
-                    ztj_mlb(ji   ,jj+jp,1-jp,kp) = 0.0_wp
+                     ztj_mlb(ji   ,jj+jp,1-jp,kp) = 0.0_wp
                   ELSE
-                    ztj_g_raw = (  zdyrho(ji,jj+jp,jk-kp,1-jp) / zdzrho(ji,jj+jp,jk-kp,kp)      &
-                       &      - ( fsdept(ji,jj+1,jk-kp) - fsdept(ji,jj,jk-kp) ) / e2v(ji,jj)  ) * vmask(ji,jj,jk)
-                    ztj_mlb(ji   ,jj+jp,1-jp,kp) = SIGN( MIN( rn_slpmax, ABS( ztj_g_raw ) ), ztj_g_raw )
+                     ztj_g_raw = (  zdyrho(ji,jj+jp,jk-kp,1-jp) / zdzrho(ji,jj+jp,jk-kp,kp)      &
+                        &      - ( fsdept(ji,jj+1,jk-kp) - fsdept(ji,jj,jk-kp) ) / e2v(ji,jj)  ) * vmask(ji,jj,jk)
+                     ze3_e2    =  fse3w(ji,jj+jp,jk-kp) / e2v(ji,jj)
+                     ztj_mlb(ji   ,jj+jp,1-jp,kp) = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e2  , ABS( ztj_g_raw ) ), ztj_g_raw )
                   ENDIF
                END DO
@@ -632,12 +521,16 @@
                      zti_raw   = zdxrho(ji+ip,jj   ,jk,1-ip) / zdzrho(ji+ip,jj   ,jk,kp)                   ! unmasked
                      ztj_raw   = zdyrho(ji   ,jj+jp,jk,1-jp) / zdzrho(ji   ,jj+jp,jk,kp)
-
+                     !
                      ! Must mask contribution to slope for triad jk=1,kp=0 that poke up though ocean surface
-                     zti_coord = znot_thru_surface * ( fsdept(ji+1,jj  ,jk) - fsdept(ji,jj,jk) ) / e1u(ji,jj)
-                     ztj_coord = znot_thru_surface * ( fsdept(ji  ,jj+1,jk) - fsdept(ji,jj,jk) ) / e2v(ji,jj)                  ! unmasked
+                     zti_coord = znot_thru_surface * ( fsdept(ji+1,jj  ,jk) - fsdept(ji,jj,jk) ) * r1_e1u(ji,jj)
+                     ztj_coord = znot_thru_surface * ( fsdept(ji  ,jj+1,jk) - fsdept(ji,jj,jk) ) * r1_e2v(ji,jj)     ! unmasked
                      zti_g_raw = zti_raw - zti_coord      ! ref to geopot surfaces
                      ztj_g_raw = ztj_raw - ztj_coord
-                     zti_g_lim = SIGN( MIN( rn_slpmax, ABS( zti_g_raw ) ), zti_g_raw )
-                     ztj_g_lim = SIGN( MIN( rn_slpmax, ABS( ztj_g_raw ) ), ztj_g_raw )
+                     ! additional limit required in bilaplacian case
+                     ze3_e1    = fse3w(ji+ip,jj   ,jk+kp) * r1_e1u(ji,jj)
+                     ze3_e2    = fse3w(ji   ,jj+jp,jk+kp) * r1_e2v(ji,jj)
+                     ! NB: hard coded factor 5 (can be a namelist parameter...)
+                     zti_g_lim = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e1, ABS( zti_g_raw ) ), zti_g_raw )
+                     ztj_g_lim = SIGN( MIN( rn_slpmax, 5.0_wp * ze3_e2, ABS( ztj_g_raw ) ), ztj_g_raw )
                      !
                      ! Below  ML use limited zti_g as is & mask
@@ -668,24 +561,27 @@
                      !
                      IF( ln_triad_iso ) THEN
-                        zti_raw = zti_lim**2 / zti_raw
-                        ztj_raw = ztj_lim**2 / ztj_raw
+                        zti_raw = zti_lim*zti_lim / zti_raw
+                        ztj_raw = ztj_lim*ztj_lim / ztj_raw
                         zti_raw = SIGN( MIN( ABS(zti_lim), ABS( zti_raw ) ), zti_raw )
                         ztj_raw = SIGN( MIN( ABS(ztj_lim), ABS( ztj_raw ) ), ztj_raw )
-                        zti_lim =           zfacti   * zti_lim                       &
-                        &      + ( 1._wp - zfacti ) * zti_raw
-                        ztj_lim =           zfactj   * ztj_lim                       &
-                        &      + ( 1._wp - zfactj ) * ztj_raw
+                        zti_lim = zfacti * zti_lim + ( 1._wp - zfacti ) * zti_raw
+                        ztj_lim = zfactj * ztj_lim + ( 1._wp - zfactj ) * ztj_raw
                      ENDIF
-                     triadi(ji+ip,jj   ,jk,1-ip,kp) = zti_lim
-                     triadj(ji   ,jj+jp,jk,1-jp,kp) = ztj_lim
-                    !
-                     zbu = e1u(ji    ,jj) * e2u(ji   ,jj) * fse3u(ji   ,jj,jk   )
-                     zbv = e1v(ji    ,jj) * e2v(ji   ,jj) * fse3v(ji   ,jj,jk   )
-                     zbti = e1t(ji+ip,jj) * e2t(ji+ip,jj) * fse3w(ji+ip,jj,jk+kp)
-                     zbtj = e1t(ji,jj+jp) * e2t(ji,jj+jp) * fse3w(ji,jj+jp,jk+kp)
-                     !
-                     !!gm this may inhibit vectorization on Vect Computers, and even on scalar computers....  ==> to be checked
-                     wslp2 (ji+ip,jj,jk+kp) = wslp2(ji+ip,jj,jk+kp) + 0.25_wp * zbu / zbti * zti_g_lim**2      ! masked
-                     wslp2 (ji,jj+jp,jk+kp) = wslp2(ji,jj+jp,jk+kp) + 0.25_wp * zbv / zbtj * ztj_g_lim**2
+                     !                                      ! switching triad scheme 
+                     zisw = (rn_sw_triad - 1._wp ) + rn_sw_triad    &
+                        &            * 2._wp * ABS( 0.5_wp - kp - ( 0.5_wp - ip ) * SIGN( 1._wp , zdxrho(ji+ip,jj,jk,1-ip) )  )
+                     zjsw = (rn_sw_triad - 1._wp ) + rn_sw_triad    &
+                        &            * 2._wp * ABS( 0.5_wp - kp - ( 0.5_wp - jp ) * SIGN( 1._wp , zdyrho(ji,jj+jp,jk,1-jp) )  )
+                     !
+                     triadi(ji+ip,jj   ,jk,1-ip,kp) = zti_lim * zisw
+                     triadj(ji   ,jj+jp,jk,1-jp,kp) = ztj_lim * zjsw
+                     !
+                     zbu  = e1e2u(ji   ,jj   ) * fse3u(ji   ,jj   ,jk   )
+                     zbv  = e1e2v(ji   ,jj   ) * fse3v(ji   ,jj   ,jk   )
+                     zbti = e1e2t(ji+ip,jj   ) * fse3w(ji+ip,jj   ,jk+kp)
+                     zbtj = e1e2t(ji   ,jj+jp) * fse3w(ji   ,jj+jp,jk+kp)
+                     !
+                     wslp2(ji+ip,jj,jk+kp) = wslp2(ji+ip,jj,jk+kp) + 0.25_wp * zbu / zbti * zti_g_lim*zti_g_lim      ! masked
+                     wslp2(ji,jj+jp,jk+kp) = wslp2(ji,jj+jp,jk+kp) + 0.25_wp * zbv / zbtj * ztj_g_lim*ztj_g_lim
                   END DO
                END DO
@@ -699,10 +595,11 @@
       !
       CALL wrk_dealloc( jpi,jpj, z1_mlbw )
+      CALL wrk_dealloc( jpi,jpj,jpk, zalbet )
       CALL wrk_dealloc( jpi,jpj,jpk,2, zdxrho , zdyrho, zdzrho,              klstart = 0  )
       CALL wrk_dealloc( jpi,jpj,  2,2, zti_mlb, ztj_mlb,        kkstart = 0, klstart = 0  )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('ldf_slp_grif')
-      !
-   END SUBROUTINE ldf_slp_grif
+      IF( nn_timing == 1 )  CALL timing_stop('ldf_slp_triad')
+      !
+   END SUBROUTINE ldf_slp_triad
 
 
@@ -730,5 +627,5 @@
       INTEGER  ::   ji , jj , jk                   ! dummy loop indices
       INTEGER  ::   iku, ikv, ik, ikm1             ! local integers
-      REAL(wp) ::   zeps, zm1_g, zm1_2g            ! local scalars
+      REAL(wp) ::   zeps, zm1_g, zm1_2g, z1_slpmax ! local scalars
       REAL(wp) ::   zci, zfi, zau, zbu, zai, zbi   !   -      -
       REAL(wp) ::   zcj, zfj, zav, zbv, zaj, zbj   !   -      -
@@ -741,4 +638,5 @@
       zm1_g  = -1.0_wp / grav
       zm1_2g = -0.5_wp / grav
+      z1_slpmax = 1._wp / rn_slpmax
       !
       uslpml (1,:) = 0._wp      ;      uslpml (jpi,:) = 0._wp
@@ -752,8 +650,6 @@
             DO ji = 1, jpi
                ik = nmln(ji,jj) - 1
-               IF( jk <= ik .AND. jk >= mikt(ji,jj) ) THEN
-                  omlmask(ji,jj,jk) = 1._wp
-               ELSE
-                  omlmask(ji,jj,jk) = 0._wp
+               IF( jk <= ik ) THEN   ;   omlmask(ji,jj,jk) = 1._wp
+               ELSE                  ;   omlmask(ji,jj,jk) = 0._wp
                ENDIF
             END DO
@@ -777,15 +673,15 @@
             !
             !                        !- vertical density gradient for u- and v-slopes (from dzr at T-point)
-            iku = MIN(  MAX( miku(ji,jj)+1, nmln(ji,jj) , nmln(ji+1,jj) ) , jpkm1  )   ! ML (MAX of T-pts, bound by jpkm1)
-            ikv = MIN(  MAX( mikv(ji,jj)+1, nmln(ji,jj) , nmln(ji,jj+1) ) , jpkm1  )   !
+            iku = MIN(  MAX( 1, nmln(ji,jj) , nmln(ji+1,jj) ) , jpkm1  )   ! ML (MAX of T-pts, bound by jpkm1)
+            ikv = MIN(  MAX( 1, nmln(ji,jj) , nmln(ji,jj+1) ) , jpkm1  )   !
             zbu = 0.5_wp * ( p_dzr(ji,jj,iku) + p_dzr(ji+1,jj  ,iku) )
             zbv = 0.5_wp * ( p_dzr(ji,jj,ikv) + p_dzr(ji  ,jj+1,ikv) )
             !                        !- horizontal density gradient at u- & v-points
-            zau = p_gru(ji,jj,iku) / e1u(ji,jj)
-            zav = p_grv(ji,jj,ikv) / e2v(ji,jj)
+            zau = p_gru(ji,jj,iku) * r1_e1u(ji,jj)
+            zav = p_grv(ji,jj,ikv) * r1_e2v(ji,jj)
             !                        !- bound the slopes: abs(zw.)<= 1/100 and zb..<0
             !                           kxz max= ah slope max =< e1 e3 /(pi**2 2 dt)
-            zbu = MIN(  zbu , -100._wp* ABS( zau ) , -7.e+3_wp/fse3u(ji,jj,iku)* ABS( zau )  )
-            zbv = MIN(  zbv , -100._wp* ABS( zav ) , -7.e+3_wp/fse3v(ji,jj,ikv)* ABS( zav )  )
+            zbu = MIN(  zbu , - z1_slpmax * ABS( zau ) , -7.e+3_wp/fse3u(ji,jj,iku)* ABS( zau )  )
+            zbv = MIN(  zbv , - z1_slpmax * ABS( zav ) , -7.e+3_wp/fse3v(ji,jj,ikv)* ABS( zav )  )
             !                        !- Slope at u- & v-points (uslpml, vslpml)
             uslpml(ji,jj) = zau / ( zbu - zeps ) * umask(ji,jj,iku)
@@ -812,6 +708,6 @@
             zbj = MIN(  zbw , -100._wp* ABS( zaj ) , -7.e+3_wp/fse3w(ji,jj,ik)* ABS( zaj )  )
             !                        !- i- & j-slope at w-points (wslpiml, wslpjml)
-            wslpiml(ji,jj) = zai / ( zbi - zeps ) * wmask (ji,jj,ik)
-            wslpjml(ji,jj) = zaj / ( zbj - zeps ) * wmask (ji,jj,ik)
+            wslpiml(ji,jj) = zai / ( zbi - zeps ) * tmask (ji,jj,ik)
+            wslpjml(ji,jj) = zaj / ( zbj - zeps ) * tmask (ji,jj,ik)
          END DO
       END DO
@@ -831,6 +727,5 @@
       !! ** Purpose :   Initialization for the isopycnal slopes computation
       !!
-      !! ** Method  :   read the nammbf namelist and check the parameter
-      !!      values called by tra_dmp at the first timestep (nit000)
+      !! ** Method  :   
       !!----------------------------------------------------------------------
       INTEGER ::   ji, jj, jk   ! dummy loop indices
@@ -845,15 +740,21 @@
          WRITE(numout,*) '~~~~~~~~~~~~'
       ENDIF
-
-      IF( ln_traldf_grif ) THEN        ! Griffies operator : triad of slopes
-         ALLOCATE( triadi_g(jpi,jpj,jpk,0:1,0:1) , triadj_g(jpi,jpj,jpk,0:1,0:1) , wslp2(jpi,jpj,jpk) , STAT=ierr )
-         ALLOCATE( triadi  (jpi,jpj,jpk,0:1,0:1) , triadj  (jpi,jpj,jpk,0:1,0:1)                      , STAT=ierr )
-         IF( ierr > 0             )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Griffies operator slope' )
-         !
+      !
+      ALLOCATE( ah_wslp2(jpi,jpj,jpk) , akz(jpi,jpj,jpk) , STAT=ierr )
+      IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate ah_slp2 or akz' )
+      !
+      IF( ln_traldf_triad ) THEN        ! Griffies operator : triad of slopes
+         IF(lwp) WRITE(numout,*) '              Griffies (triad) operator initialisation'
+         ALLOCATE( triadi_g(jpi,jpj,jpk,0:1,0:1) , triadj_g(jpi,jpj,jpk,0:1,0:1) ,     &
+            &      triadi  (jpi,jpj,jpk,0:1,0:1) , triadj  (jpi,jpj,jpk,0:1,0:1) ,     &
+            &      wslp2   (jpi,jpj,jpk)                                         , STAT=ierr )
+         IF( ierr > 0      )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Griffies operator slope' )
          IF( ln_dynldf_iso )   CALL ctl_stop( 'ldf_slp_init: Griffies operator on momentum not supported' )
          !
       ELSE                             ! Madec operator : slopes at u-, v-, and w-points
-         ALLOCATE( uslp(jpi,jpj,jpk) , vslp(jpi,jpj,jpk) , wslpi(jpi,jpj,jpk) , wslpj(jpi,jpj,jpk) ,                &
-            &   omlmask(jpi,jpj,jpk) , uslpml(jpi,jpj)   , vslpml(jpi,jpj)    , wslpiml(jpi,jpj)   , wslpjml(jpi,jpj) , STAT=ierr )
+         IF(lwp) WRITE(numout,*) '              Madec operator initialisation'
+         ALLOCATE( omlmask(jpi,jpj,jpk) ,                                                                        &
+            &      uslp(jpi,jpj,jpk) , uslpml(jpi,jpj) , wslpi(jpi,jpj,jpk) , wslpiml(jpi,jpj) ,     &
+            &      vslp(jpi,jpj,jpk) , vslpml(jpi,jpj) , wslpj(jpi,jpj,jpk) , wslpjml(jpi,jpj) , STAT=ierr )
          IF( ierr > 0 )   CALL ctl_stop( 'STOP', 'ldf_slp_init : unable to allocate Madec operator slope ' )
 
@@ -865,26 +766,27 @@
          wslpj(:,:,:) = 0._wp   ;   wslpjml(:,:) = 0._wp
 
-         IF(ln_sco .AND.  (ln_traldf_hor .OR. ln_dynldf_hor )) THEN
-            IF(lwp)   WRITE(numout,*) '          Horizontal mixing in s-coordinate: slope = slope of s-surfaces'
-
-            ! geopotential diffusion in s-coordinates on tracers and/or momentum
-            ! The slopes of s-surfaces are computed once (no call to ldfslp in step)
-            ! The slopes for momentum diffusion are i- or j- averaged of those on tracers
-
-            ! set the slope of diffusion to the slope of s-surfaces
-            !      ( c a u t i o n : minus sign as fsdep has positive value )
-            DO jk = 1, jpk
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
-                     uslp (ji,jj,jk) = -1./e1u(ji,jj) * ( fsdept_b(ji+1,jj,jk) - fsdept_b(ji ,jj ,jk) ) * umask(ji,jj,jk)
-                     vslp (ji,jj,jk) = -1./e2v(ji,jj) * ( fsdept_b(ji,jj+1,jk) - fsdept_b(ji ,jj ,jk) ) * vmask(ji,jj,jk)
-                     wslpi(ji,jj,jk) = -1./e1t(ji,jj) * ( fsdepw_b(ji+1,jj,jk) - fsdepw_b(ji-1,jj,jk) ) * tmask(ji,jj,jk) * 0.5
-                     wslpj(ji,jj,jk) = -1./e2t(ji,jj) * ( fsdepw_b(ji,jj+1,jk) - fsdepw_b(ji,jj-1,jk) ) * tmask(ji,jj,jk) * 0.5
-                  END DO
-               END DO
-            END DO
-            CALL lbc_lnk( uslp , 'U', -1. )   ;   CALL lbc_lnk( vslp , 'V', -1. )      ! Lateral boundary conditions
-            CALL lbc_lnk( wslpi, 'W', -1. )   ;   CALL lbc_lnk( wslpj, 'W', -1. )
-         ENDIF
+         !!gm I no longer understand this.....
+!!gm         IF( (ln_traldf_hor .OR. ln_dynldf_hor) .AND. .NOT. (lk_vvl .AND. ln_rstart) ) THEN
+!            IF(lwp)   WRITE(numout,*) '          Horizontal mixing in s-coordinate: slope = slope of s-surfaces'
+!
+!            ! geopotential diffusion in s-coordinates on tracers and/or momentum
+!            ! The slopes of s-surfaces are computed once (no call to ldfslp in step)
+!            ! The slopes for momentum diffusion are i- or j- averaged of those on tracers
+!
+!            ! set the slope of diffusion to the slope of s-surfaces
+!            !      ( c a u t i o n : minus sign as fsdep has positive value )
+!            DO jk = 1, jpk
+!               DO jj = 2, jpjm1
+!                  DO ji = fs_2, fs_jpim1   ! vector opt.
+!                     uslp (ji,jj,jk) = - ( fsdept(ji+1,jj,jk) - fsdept(ji ,jj ,jk) ) * r1_e1u(ji,jj) * umask(ji,jj,jk)
+!                     vslp (ji,jj,jk) = - ( fsdept(ji,jj+1,jk) - fsdept(ji ,jj ,jk) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk)
+!                     wslpi(ji,jj,jk) = - ( fsdepw(ji+1,jj,jk) - fsdepw(ji-1,jj,jk) ) * r1_e1t(ji,jj) * wmask(ji,jj,jk) * 0.5
+!                     wslpj(ji,jj,jk) = - ( fsdepw(ji,jj+1,jk) - fsdepw(ji,jj-1,jk) ) * r1_e2t(ji,jj) * wmask(ji,jj,jk) * 0.5
+!                  END DO
+!               END DO
+!            END DO
+!            CALL lbc_lnk( uslp , 'U', -1. )   ;   CALL lbc_lnk( vslp , 'V', -1. )      ! Lateral boundary conditions
+!            CALL lbc_lnk( wslpi, 'W', -1. )   ;   CALL lbc_lnk( wslpj, 'W', -1. )
+!!gm         ENDIF
       ENDIF
       !
@@ -892,23 +794,4 @@
       !
    END SUBROUTINE ldf_slp_init
-
-#else
-   !!------------------------------------------------------------------------
-   !!   Dummy module :                 NO Rotation of lateral mixing tensor
-   !!------------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER ::   lk_ldfslp = .FALSE.    !: slopes flag
-CONTAINS
-   SUBROUTINE ldf_slp( kt, prd, pn2 )   ! Dummy routine
-      INTEGER, INTENT(in) :: kt
-      REAL, DIMENSION(:,:,:), INTENT(in) :: prd, pn2
-      WRITE(*,*) 'ldf_slp: You should not have seen this print! error?', kt, prd(1,1,1), pn2(1,1,1)
-   END SUBROUTINE ldf_slp
-   SUBROUTINE ldf_slp_grif( kt )        ! Dummy routine
-      INTEGER, INTENT(in) :: kt
-      WRITE(*,*) 'ldf_slp_grif: You should not have seen this print! error?', kt
-   END SUBROUTINE ldf_slp_grif
-   SUBROUTINE ldf_slp_init              ! Dummy routine
-   END SUBROUTINE ldf_slp_init
-#endif
 
    !!======================================================================
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra.F90	(revision 6041)
@@ -2,31 +2,81 @@
    !!======================================================================
    !!                       ***  MODULE  ldftra  ***
-   !! Ocean physics:  lateral diffusivity coefficient 
+   !! Ocean physics:  lateral diffusivity coefficients 
    !!=====================================================================
-   !! History :        ! 1997-07  (G. Madec)  from inimix.F split in 2 routines
-   !!   NEMO      1.0  ! 2002-09  (G. Madec)  F90: Free form and module
-   !!             2.0  ! 2005-11  (G. Madec)  
+   !! History :       ! 1997-07  (G. Madec)  from inimix.F split in 2 routines
+   !!   NEMO     1.0  ! 2002-09  (G. Madec)  F90: Free form and module
+   !!            2.0  ! 2005-11  (G. Madec)  
+   !!            3.7  ! 2013-12  (F. Lemarie, G. Madec)  restructuration/simplification of aht/aeiv specification,
+   !!                 !                                  add velocity dependent coefficient and optional read in file
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
    !!   ldf_tra_init : initialization, namelist read, and parameters control
-   !!   ldf_tra_c3d   : 3D eddy viscosity coefficient initialization
-   !!   ldf_tra_c2d   : 2D eddy viscosity coefficient initialization
-   !!   ldf_tra_c1d   : 1D eddy viscosity coefficient initialization
+   !!   ldf_tra      : update lateral eddy diffusivity coefficients at each time step 
+   !!   ldf_eiv_init : initialization of the eiv coeff. from namelist choices 
+   !!   ldf_eiv      : time evolution of the eiv coefficients (function of the growth rate of baroclinic instability)
+   !!   ldf_eiv_trp  : add to the input ocean transport the contribution of the EIV parametrization
+   !!   ldf_eiv_dia  : diagnose the eddy induced velocity from the eiv streamfunction
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers
    USE dom_oce         ! ocean space and time domain
    USE phycst          ! physical constants
-   USE ldftra_oce      ! ocean tracer   lateral physics
-   USE ldfslp          ! ???
+   USE ldfslp          ! lateral diffusion: slope of iso-neutral surfaces
+   USE ldfc1d_c2d      ! lateral diffusion: 1D & 2D cases 
+   USE diaar5, ONLY:   lk_diaar5
+   !
+   USE trc_oce, ONLY: lk_offline ! offline flag
    USE in_out_manager  ! I/O manager
-   USE ioipsl
+   USE iom             ! I/O module for ehanced bottom friction file
    USE lib_mpp         ! distribued memory computing library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE wrk_nemo        ! work arrays
+   USE timing          ! timing
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   ldf_tra_init   ! called by opa.F90
+   PUBLIC   ldf_tra_init   ! called by nemogcm.F90
+   PUBLIC   ldf_tra        ! called by step.F90
+   PUBLIC   ldf_eiv_init   ! called by nemogcm.F90
+   PUBLIC   ldf_eiv        ! called by step.F90
+   PUBLIC   ldf_eiv_trp    ! called by traadv.F90
+   PUBLIC   ldf_eiv_dia    ! called by traldf_iso and traldf_iso_triad.F90
+   
+   !                                   !!* Namelist namtra_ldf : lateral mixing on tracers * 
+   !                                    != Operator type =!
+   LOGICAL , PUBLIC ::   ln_traldf_lap       !: laplacian operator
+   LOGICAL , PUBLIC ::   ln_traldf_blp       !: bilaplacian operator
+   !                                    != Direction of action =!
+   LOGICAL , PUBLIC ::   ln_traldf_lev       !: iso-level direction
+   LOGICAL , PUBLIC ::   ln_traldf_hor       !: horizontal (geopotential) direction
+!  LOGICAL , PUBLIC ::   ln_traldf_iso       !: iso-neutral direction                    (see ldfslp)
+!  LOGICAL , PUBLIC ::   ln_traldf_triad     !: griffies triad scheme                    (see ldfslp)
+   LOGICAL , PUBLIC ::   ln_traldf_msc       !: Method of Stabilizing Correction 
+!  LOGICAL , PUBLIC ::   ln_triad_iso        !: pure horizontal mixing in ML             (see ldfslp)
+!  LOGICAL , PUBLIC ::   ln_botmix_triad     !: mixing on bottom                         (see ldfslp)
+!  REAL(wp), PUBLIC ::   rn_sw_triad         !: =1/0 switching triad / all 4 triads used (see ldfslp)
+!  REAL(wp), PUBLIC ::   rn_slpmax           !: slope limit                              (see ldfslp)
+   !                                    !=  Coefficients =!
+   INTEGER , PUBLIC ::   nn_aht_ijk_t        !: choice of time & space variations of the lateral eddy diffusivity coef.
+   REAL(wp), PUBLIC ::   rn_aht_0            !:   laplacian lateral eddy diffusivity [m2/s]
+   REAL(wp), PUBLIC ::   rn_bht_0            !: bilaplacian lateral eddy diffusivity [m4/s]
+
+   !                                   !!* Namelist namtra_ldfeiv : eddy induced velocity param. *
+   !                                    != Use/diagnose eiv =!
+   LOGICAL , PUBLIC ::   ln_ldfeiv           !: eddy induced velocity flag
+   LOGICAL , PUBLIC ::   ln_ldfeiv_dia       !: diagnose & output eiv streamfunction and velocity (IOM)
+   !                                    != Coefficients =!
+   INTEGER , PUBLIC ::   nn_aei_ijk_t        !: choice of time/space variation of the eiv coeff.
+   REAL(wp), PUBLIC ::   rn_aeiv_0           !: eddy induced velocity coefficient [m2/s]
+   
+   LOGICAL , PUBLIC ::   l_ldftra_time = .FALSE.   !: flag for time variation of the lateral eddy diffusivity coef.
+   LOGICAL , PUBLIC ::   l_ldfeiv_time = .FALSE.   ! flag for time variation of the eiv coef.
+
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ahtu, ahtv   !: eddy diffusivity coef. at U- and V-points   [m2/s]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   aeiu, aeiv   !: eddy induced velocity coeff.                [m2/s]
+
+   REAL(wp) ::   r1_4  = 0.25_wp          ! =1/4
+   REAL(wp) ::   r1_12 = 1._wp / 12._wp   ! =1/12
 
    !! * Substitutions
@@ -34,5 +84,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -46,45 +96,49 @@
       !! ** Purpose :   initializations of the tracer lateral mixing coeff.
       !!
-      !! ** Method  :   the Eddy diffusivity and eddy induced velocity ceoff.
-      !!      are defined as follows:
-      !!         default option   : constant coef. aht0, aeiv0 (namelist)
-      !!        'key_traldf_c1d': depth dependent coef. defined in 
-      !!                            in ldf_tra_c1d routine
-      !!        'key_traldf_c2d': latitude and longitude dependent coef.
-      !!                            defined in ldf_tra_c2d routine
-      !!        'key_traldf_c3d': latitude, longitude, depth dependent coef.
-      !!                            defined in ldf_tra_c3d routine
-      !!
-      !!      N.B. User defined include files.  By default, 3d and 2d coef.
-      !!      are set to a constant value given in the namelist and the 1d
-      !!      coefficients are initialized to a hyperbolic tangent vertical
-      !!      profile.
-      !!----------------------------------------------------------------------
-      INTEGER ::   ioptio               ! temporary integer
-      INTEGER ::   ios                  ! temporary integer
-      LOGICAL ::   ll_print = .FALSE.   ! =T print eddy coef. in numout
-      !! 
-      NAMELIST/namtra_ldf/ ln_traldf_lap  , ln_traldf_bilap,                  &
-         &                 ln_traldf_level, ln_traldf_hor  , ln_traldf_iso,   &
-         &                 ln_traldf_grif , ln_traldf_gdia ,                  &
-         &                 ln_triad_iso   , ln_botmix_grif ,                  &
-         &                 rn_aht_0       , rn_ahtb_0      , rn_aeiv_0,       &
-         &                 rn_slpmax      , rn_chsmag      ,    rn_smsh,      &
-         &                 rn_aht_m
-      !!----------------------------------------------------------------------
-
-      !  Define the lateral tracer physics parameters
-      ! =============================================
-    
-
+      !! ** Method  : * the eddy diffusivity coef. specification depends on:
+      !!
+      !!    ln_traldf_lap = T     laplacian operator
+      !!    ln_traldf_blp = T   bilaplacian operator
+      !!
+      !!    nn_aht_ijk_t  =  0 => = constant
+      !!                  !
+      !!                  = 10 => = F(z) : constant with a reduction of 1/4 with depth 
+      !!                  !
+      !!                  =-20 => = F(i,j)   = shape read in 'eddy_diffusivity.nc' file
+      !!                  = 20    = F(i,j)   = F(e1,e2) or F(e1^3,e2^3) (lap or bilap case)
+      !!                  = 21    = F(i,j,t) = F(growth rate of baroclinic instability)
+      !!                  !
+      !!                  =-30 => = F(i,j,k)   = shape read in 'eddy_diffusivity.nc' file
+      !!                  = 30    = F(i,j,k)   = 2D (case 20) + decrease with depth (case 10)
+      !!                  = 31    = F(i,j,k,t) = F(local velocity) (  |u|e  /12   laplacian operator
+      !!                                                          or |u|e^3/12 bilaplacian operator )
+      !!              * initialisation of the eddy induced velocity coefficient by a call to ldf_eiv_init 
+      !!            
+      !! ** action  : ahtu, ahtv initialized once for all or l_ldftra_time set to true
+      !!              aeiu, aeiv initialized once for all or l_ldfeiv_time set to true
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk                ! dummy loop indices
+      INTEGER  ::   ierr, inum, ios   ! local integer
+      REAL(wp) ::   zah0              ! local scalar
+      !
+      NAMELIST/namtra_ldf/ ln_traldf_lap, ln_traldf_blp  ,                   &   ! type of operator
+         &                 ln_traldf_lev, ln_traldf_hor  , ln_traldf_triad,  &   ! acting direction of the operator
+         &                 ln_traldf_iso, ln_traldf_msc  ,  rn_slpmax     ,  &   ! option for iso-neutral operator
+         &                 ln_triad_iso , ln_botmix_triad, rn_sw_triad    ,  &   ! option for triad operator
+         &                 rn_aht_0     , rn_bht_0       , nn_aht_ijk_t          ! lateral eddy coefficient
+      !!----------------------------------------------------------------------
+      !
+      !  Choice of lateral tracer physics
+      ! =================================
+      !
       REWIND( numnam_ref )              ! Namelist namtra_ldf in reference namelist : Lateral physics on tracers
       READ  ( numnam_ref, namtra_ldf, IOSTAT = ios, ERR = 901)
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_ldf in reference namelist', lwp )
-
+      !
       REWIND( numnam_cfg )              ! Namelist namtra_ldf in configuration namelist : Lateral physics on tracers
       READ  ( numnam_cfg, namtra_ldf, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_ldf in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namtra_ldf )
-
+      !
       IF(lwp) THEN                      ! control print
          WRITE(numout,*)
@@ -92,98 +146,625 @@
          WRITE(numout,*) '~~~~~~~~~~~~ '
          WRITE(numout,*) '   Namelist namtra_ldf : lateral mixing parameters (type, direction, coefficients)'
-         WRITE(numout,*) '      laplacian operator            ln_traldf_lap   = ', ln_traldf_lap
-         WRITE(numout,*) '      bilaplacian operator          ln_traldf_bilap = ', ln_traldf_bilap
-         WRITE(numout,*) '      iso-level                     ln_traldf_level = ', ln_traldf_level
-         WRITE(numout,*) '      horizontal (geopotential)     ln_traldf_hor   = ', ln_traldf_hor
-         WRITE(numout,*) '      iso-neutral                   ln_traldf_iso   = ', ln_traldf_iso
-         WRITE(numout,*) '      iso-neutral (Griffies)        ln_traldf_grif  = ', ln_traldf_grif
-         WRITE(numout,*) '      Griffies strmfn diagnostics   ln_traldf_gdia  = ', ln_traldf_gdia
-         WRITE(numout,*) '      lateral eddy diffusivity      rn_aht_0        = ', rn_aht_0
-         WRITE(numout,*) '      background hor. diffusivity   rn_ahtb_0       = ', rn_ahtb_0
-         WRITE(numout,*) '      eddy induced velocity coef.   rn_aeiv_0       = ', rn_aeiv_0
-         WRITE(numout,*) '      maximum isoppycnal slope      rn_slpmax       = ', rn_slpmax
-         WRITE(numout,*) '      pure lateral mixing in ML     ln_triad_iso    = ', ln_triad_iso
-         WRITE(numout,*) '      lateral mixing on bottom      ln_botmix_grif  = ', ln_botmix_grif
+         !
+         WRITE(numout,*) '      type :'
+         WRITE(numout,*) '         laplacian operator                      ln_traldf_lap   = ', ln_traldf_lap
+         WRITE(numout,*) '         bilaplacian operator                    ln_traldf_blp   = ', ln_traldf_blp
+         !
+         WRITE(numout,*) '      direction of action :'
+         WRITE(numout,*) '         iso-level                               ln_traldf_lev   = ', ln_traldf_lev
+         WRITE(numout,*) '         horizontal (geopotential)               ln_traldf_hor   = ', ln_traldf_hor
+         WRITE(numout,*) '         iso-neutral Madec operator              ln_traldf_iso   = ', ln_traldf_iso
+         WRITE(numout,*) '         iso-neutral triad operator              ln_traldf_triad = ', ln_traldf_triad
+         WRITE(numout,*) '            iso-neutral (Method of Stab. Corr.)  ln_traldf_msc   = ', ln_traldf_msc
+         WRITE(numout,*) '            maximum isoppycnal slope             rn_slpmax       = ', rn_slpmax
+         WRITE(numout,*) '            pure lateral mixing in ML            ln_triad_iso    = ', ln_triad_iso
+         WRITE(numout,*) '            switching triad or not               rn_sw_triad     = ', rn_sw_triad
+         WRITE(numout,*) '            lateral mixing on bottom             ln_botmix_triad = ', ln_botmix_triad
+         !
+         WRITE(numout,*) '      coefficients :'
+         WRITE(numout,*) '         lateral eddy diffusivity   (lap case)   rn_aht_0        = ', rn_aht_0
+         WRITE(numout,*) '         lateral eddy diffusivity (bilap case)   rn_bht_0        = ', rn_bht_0
+         WRITE(numout,*) '         type of time-space variation            nn_aht_ijk_t    = ', nn_aht_ijk_t
+      ENDIF
+      !
+      !                                ! Parameter control
+      !
+      IF( .NOT.ln_traldf_lap .AND. .NOT.ln_traldf_blp ) THEN
+         IF(lwp) WRITE(numout,*) '   No diffusive operator selected. ahtu and ahtv are not allocated'
+         l_ldftra_time = .FALSE.
+         RETURN
+      ENDIF
+      !
+      IF( ln_traldf_blp .AND. ( ln_traldf_iso .OR. ln_traldf_triad) ) THEN     ! iso-neutral bilaplacian need MSC
+         IF( .NOT.ln_traldf_msc )   CALL ctl_stop( 'tra_ldf_init: iso-neutral bilaplacian requires ln_traldf_msc=.true.' )
+      ENDIF
+      !
+      !  Space/time variation of eddy coefficients 
+      ! ===========================================
+      !                                               ! allocate the aht arrays
+      ALLOCATE( ahtu(jpi,jpj,jpk) , ahtv(jpi,jpj,jpk) , STAT=ierr )
+      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'ldf_tra_init: failed to allocate arrays')
+      !
+      ahtu(:,:,jpk) = 0._wp                           ! last level always 0  
+      ahtv(:,:,jpk) = 0._wp
+      !
+      !                                               ! value of eddy mixing coef.
+      IF    ( ln_traldf_lap ) THEN   ;   zah0 =      rn_aht_0        !   laplacian operator
+      ELSEIF( ln_traldf_blp ) THEN   ;   zah0 = ABS( rn_bht_0 )      ! bilaplacian operator
+      ENDIF
+      !
+      l_ldftra_time = .FALSE.                         ! no time variation except in case defined below
+      !
+      IF( ln_traldf_lap .OR. ln_traldf_blp ) THEN     ! only if a lateral diffusion operator is used
+         !
+         SELECT CASE(  nn_aht_ijk_t  )                   ! Specification of space time variations of ehtu, ahtv
+         !
+         CASE(   0  )      !==  constant  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = constant = ', rn_aht_0
+            ahtu(:,:,:) = zah0 * umask(:,:,:)
+            ahtv(:,:,:) = zah0 * vmask(:,:,:)
+            !
+         CASE(  10  )      !==  fixed profile  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( depth )'
+            ahtu(:,:,1) = zah0 * umask(:,:,1)                      ! constant surface value
+            ahtv(:,:,1) = zah0 * vmask(:,:,1)
+            CALL ldf_c1d( 'TRA', r1_4, ahtu(:,:,1), ahtv(:,:,1), ahtu, ahtv )
+            !
+         CASE ( -20 )      !== fixed horizontal shape read in file  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F(i,j) read in eddy_diffusivity.nc file'
+            CALL iom_open( 'eddy_diffusivity_2D.nc', inum )
+            CALL iom_get ( inum, jpdom_data, 'ahtu_2D', ahtu(:,:,1) )
+            CALL iom_get ( inum, jpdom_data, 'ahtv_2D', ahtv(:,:,1) )
+            CALL iom_close( inum )
+            DO jk = 2, jpkm1
+               ahtu(:,:,jk) = ahtu(:,:,1) * umask(:,:,jk)
+               ahtv(:,:,jk) = ahtv(:,:,1) * vmask(:,:,jk)
+            END DO
+            !
+         CASE(  20  )      !== fixed horizontal shape  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( e1, e2 ) or F( e1^3, e2^3 ) (lap or blp case)'
+            IF( ln_traldf_lap )   CALL ldf_c2d( 'TRA', 'LAP', zah0, ahtu, ahtv )    ! surface value proportional to scale factor
+            IF( ln_traldf_blp )   CALL ldf_c2d( 'TRA', 'BLP', zah0, ahtu, ahtv )    ! surface value proportional to scale factor
+            !
+         CASE(  21  )      !==  time varying 2D field  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, time )'
+            IF(lwp) WRITE(numout,*) '                              = F( growth rate of baroclinic instability )'
+            IF(lwp) WRITE(numout,*) '                              min value = 0.1 * rn_aht_0'
+            IF(lwp) WRITE(numout,*) '                              max value = rn_aht_0 (rn_aeiv_0 if nn_aei_ijk_t=21)'
+            IF(lwp) WRITE(numout,*) '                              increased to rn_aht_0 within 20N-20S'
+            !
+            l_ldftra_time = .TRUE.     ! will be calculated by call to ldf_tra routine in step.F90
+            !
+            IF( ln_traldf_blp ) THEN
+               CALL ctl_stop( 'ldf_tra_init: aht=F(growth rate of baroc. insta.) incompatible with bilaplacian operator' )
+            ENDIF
+            !
+         CASE( -30  )      !== fixed 3D shape read in file  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F(i,j,k) read in eddy_diffusivity.nc file'
+            CALL iom_open( 'eddy_diffusivity_3D.nc', inum )
+            CALL iom_get ( inum, jpdom_data, 'ahtu_3D', ahtu )
+            CALL iom_get ( inum, jpdom_data, 'ahtv_3D', ahtv )
+            CALL iom_close( inum )
+            DO jk = 1, jpkm1
+               ahtu(:,:,jk) = ahtu(:,:,jk) * umask(:,:,jk)
+               ahtv(:,:,jk) = ahtv(:,:,jk) * vmask(:,:,jk)
+            END DO
+            !
+         CASE(  30  )      !==  fixed 3D shape  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, depth )'
+            IF( ln_traldf_lap )   CALL ldf_c2d( 'TRA', 'LAP', zah0, ahtu, ahtv )    ! surface value proportional to scale factor
+            IF( ln_traldf_blp )   CALL ldf_c2d( 'TRA', 'BLP', zah0, ahtu, ahtv )    ! surface value proportional to scale factor
+            !                                                    ! reduction with depth
+            CALL ldf_c1d( 'TRA', r1_4, ahtu(:,:,1), ahtv(:,:,1), ahtu, ahtv )
+            !
+         CASE(  31  )      !==  time varying 3D field  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, depth , time )'
+            IF(lwp) WRITE(numout,*) '                                proportional to the velocity : |u|e/12 or |u|e^3/12'
+            !
+            l_ldftra_time = .TRUE.     ! will be calculated by call to ldf_tra routine in step.F90
+            !
+         CASE DEFAULT
+            CALL ctl_stop('ldf_tra_init: wrong choice for nn_aht_ijk_t, the type of space-time variation of aht')
+         END SELECT
+         !
+         IF( ln_traldf_blp .AND. .NOT. l_ldftra_time ) THEN
+            ahtu(:,:,:) = SQRT( ahtu(:,:,:) )
+            ahtv(:,:,:) = SQRT( ahtv(:,:,:) )
+         ENDIF
+         !
+      ENDIF
+      !
+   END SUBROUTINE ldf_tra_init
+
+
+   SUBROUTINE ldf_tra( kt )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_tra  ***
+      !! 
+      !! ** Purpose :   update at kt the tracer lateral mixing coeff. (aht and aeiv)
+      !!
+      !! ** Method  :   time varying eddy diffusivity coefficients:
+      !!
+      !!    nn_aei_ijk_t = 21    aeiu, aeiv = F(i,j,  t) = F(growth rate of baroclinic instability)
+      !!                                                   with a reduction to 0 in vicinity of the Equator
+      !!    nn_aht_ijk_t = 21    ahtu, ahtv = F(i,j,  t) = F(growth rate of baroclinic instability)
+      !!
+      !!                 = 31    ahtu, ahtv = F(i,j,k,t) = F(local velocity) (  |u|e  /12   laplacian operator
+      !!                                                                     or |u|e^3/12 bilaplacian operator )
+      !!
+      !! ** action  :   ahtu, ahtv   update at each time step   
+      !!                aeiu, aeiv      -       -     -    -   (if ln_ldfeiv=T) 
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in) ::   kt   ! time step
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp) ::   zaht, zaht_min, z1_f20       ! local scalar
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_aei_ijk_t == 21 ) THEN       ! eddy induced velocity coefficients
+         !                                ! =F(growth rate of baroclinic instability)
+         !                                ! max value rn_aeiv_0 ; decreased to 0 within 20N-20S
+         CALL ldf_eiv( kt, rn_aeiv_0, aeiu, aeiv )
+         IF(lwp .AND. kt<=nit000+20 )   WRITE(numout,*) ' kt , ldf_eiv appel', kt
+      ENDIF
+      !
+      SELECT CASE(  nn_aht_ijk_t  )       ! Eddy diffusivity coefficients
+      !
+      CASE(  21  )       !==  time varying 2D field  ==!   = F( growth rate of baroclinic instability )
+         !                                             !   min value rn_aht_0 / 10 
+         !                                             !   max value rn_aht_0 (rn_aeiv_0 if nn_aei_ijk_t=21)
+         !                                             !   increase to rn_aht_0 within 20N-20S
+         IF( nn_aei_ijk_t /= 21 ) THEN
+            CALL ldf_eiv( kt, rn_aht_0, ahtu, ahtv )
+            IF(lwp .AND. kt<=nit000+20 )   WRITE(numout,*) ' kt , ldf_eiv appel  2', kt
+         ELSE
+            ahtu(:,:,1) = aeiu(:,:,1)
+            ahtv(:,:,1) = aeiv(:,:,1)
+            IF(lwp .AND. kt<=nit000+20 )   WRITE(numout,*) ' kt , ahtu=aeiu', kt
+         ENDIF
+         !
+         z1_f20   = 1._wp / (  2._wp * omega * SIN( rad * 20._wp )  )      ! 1 / ff(20 degrees)   
+         zaht_min = 0.2_wp * rn_aht_0                                      ! minimum value for aht
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zaht = ( 1._wp -  MIN( 1._wp , ABS( ff(ji,jj) * z1_f20 ) ) ) * ( rn_aht_0 - zaht_min )
+               ahtu(ji,jj,1) = (  MAX( zaht_min, ahtu(ji,jj,1) ) + zaht  ) * umask(ji,jj,1)     ! min value zaht_min
+               ahtv(ji,jj,1) = (  MAX( zaht_min, ahtv(ji,jj,1) ) + zaht  ) * vmask(ji,jj,1)     ! increase within 20S-20N
+            END DO
+         END DO
+         DO jk = 2, jpkm1                             ! deeper value = surface value
+            ahtu(:,:,jk) = ahtu(:,:,1) * umask(:,:,jk)
+            ahtv(:,:,jk) = ahtv(:,:,1) * vmask(:,:,jk)
+         END DO
+         !
+      CASE(  31  )       !==  time varying 3D field  ==!   = F( local velocity )
+         IF( ln_traldf_lap     ) THEN          !   laplacian operator |u| e /12
+            DO jk = 1, jpkm1
+               ahtu(:,:,jk) = ABS( ub(:,:,jk) ) * e1u(:,:) * r1_12
+               ahtv(:,:,jk) = ABS( vb(:,:,jk) ) * e2v(:,:) * r1_12
+            END DO
+         ELSEIF( ln_traldf_blp ) THEN      ! bilaplacian operator      sqrt( |u| e^3 /12 ) = sqrt( |u| e /12 ) * e
+            DO jk = 1, jpkm1
+               ahtu(:,:,jk) = SQRT(  ABS( ub(:,:,jk) ) * e1u(:,:) * r1_12  ) * e1u(:,:)
+               ahtv(:,:,jk) = SQRT(  ABS( vb(:,:,jk) ) * e2v(:,:) * r1_12  ) * e2v(:,:)
+            END DO
+         ENDIF
+         !
+      END SELECT
+      !
+      IF( .NOT.lk_offline ) THEN
+         CALL iom_put( "ahtu_2d", ahtu(:,:,1) )   ! surface u-eddy diffusivity coeff.
+         CALL iom_put( "ahtv_2d", ahtv(:,:,1) )   ! surface v-eddy diffusivity coeff.
+         CALL iom_put( "ahtu_3d", ahtu(:,:,:) )   ! 3D      u-eddy diffusivity coeff.
+         CALL iom_put( "ahtv_3d", ahtv(:,:,:) )   ! 3D      v-eddy diffusivity coeff.
+         !
+!!gm  : THE IF below is to be checked (comes from Seb)
+         IF( ln_ldfeiv ) THEN
+           CALL iom_put( "aeiu_2d", aeiu(:,:,1) )   ! surface u-EIV coeff.
+           CALL iom_put( "aeiv_2d", aeiv(:,:,1) )   ! surface v-EIV coeff.
+           CALL iom_put( "aeiu_3d", aeiu(:,:,:) )   ! 3D      u-EIV coeff.
+           CALL iom_put( "aeiv_3d", aeiv(:,:,:) )   ! 3D      v-EIV coeff.
+         ENDIF     
+      ENDIF
+      !
+   END SUBROUTINE ldf_tra
+
+
+   SUBROUTINE ldf_eiv_init
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_eiv_init  ***
+      !!
+      !! ** Purpose :   initialization of the eiv coeff. from namelist choices.
+      !!
+      !! ** Method :
+      !!
+      !! ** Action :   aeiu , aeiv   : EIV coeff. at u- & v-points
+      !!               l_ldfeiv_time : =T if EIV coefficients vary with time
+      !!----------------------------------------------------------------------
+      INTEGER  ::   jk                ! dummy loop indices
+      INTEGER  ::   ierr, inum, ios   ! local integer
+      !
+      NAMELIST/namtra_ldfeiv/ ln_ldfeiv   , ln_ldfeiv_dia,   &    ! eddy induced velocity (eiv)
+         &                    nn_aei_ijk_t, rn_aeiv_0             ! eiv  coefficient
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnam_ref )              ! Namelist namtra_ldfeiv in reference namelist : eddy induced velocity param.
+      READ  ( numnam_ref, namtra_ldfeiv, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_ldfeiv in reference namelist', lwp )
+      !
+      REWIND( numnam_cfg )              ! Namelist namtra_ldfeiv in configuration namelist : eddy induced velocity param.
+      READ  ( numnam_cfg, namtra_ldfeiv, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_ldfeiv in configuration namelist', lwp )
+      IF(lwm)  WRITE ( numond, namtra_ldfeiv )
+
+      IF(lwp) THEN                      ! control print
          WRITE(numout,*)
-      ENDIF
-
-      !                                ! convert DOCTOR namelist names into OLD names
-      aht0  = rn_aht_0
-      ahtb0 = rn_ahtb_0
-      aeiv0 = rn_aeiv_0
-
-      !                                ! Parameter control
-
-      ! ... Check consistency for type and direction :
-      !           ==> will be done in traldf module
-
-      ! ... Space variation of eddy coefficients
-      ioptio = 0
-#if defined key_traldf_c3d
-      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, depth)'
-      ioptio = ioptio + 1
-#endif
-#if defined key_traldf_c2d
-      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude)'
-      ioptio = ioptio + 1
-#endif
-#if defined key_traldf_c1d
-      IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( depth )'
-      ioptio = ioptio + 1
-      IF( .NOT. ln_zco )   CALL ctl_stop( 'key_traldf_c1d can only be used in z-coordinate - full step' )
-#endif
-      IF( ioptio == 0 ) THEN
-          IF(lwp) WRITE(numout,*) '          tracer mixing coef. = constant (default option)'
-        ELSEIF( ioptio > 1 ) THEN
-           CALL ctl_stop('          use only one of the following keys:',   &
-             &           ' key_traldf_c3d, key_traldf_c2d, key_traldf_c1d' )
-      ENDIF
-
-      IF( ln_traldf_bilap ) THEN
-         IF(lwp) WRITE(numout,*) '          biharmonic tracer diffusion'
-         IF( aht0 > 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal diffusivity coef. aht0 must be negative' )
+         WRITE(numout,*) 'ldf_eiv_init : eddy induced velocity parametrization'
+         WRITE(numout,*) '~~~~~~~~~~~~ '
+         WRITE(numout,*) '   Namelist namtra_ldfeiv : '
+         WRITE(numout,*) '      Eddy Induced Velocity (eiv) param.      ln_ldfeiv     = ', ln_ldfeiv
+         WRITE(numout,*) '      eiv streamfunction & velocity diag.     ln_ldfeiv_dia = ', ln_ldfeiv_dia
+         WRITE(numout,*) '      eddy induced velocity coef.             rn_aeiv_0     = ', rn_aeiv_0
+         WRITE(numout,*) '      type of time-space variation            nn_aei_ijk_t  = ', nn_aei_ijk_t
+         WRITE(numout,*)
+      ENDIF
+      !
+      IF( ln_ldfeiv .AND. ln_traldf_blp )   CALL ctl_stop( 'ldf_eiv_init: eddy induced velocity ONLY with laplacian diffusivity' )
+
+      !                                 ! Parameter control
+      l_ldfeiv_time = .FALSE.    
+      !
+      IF( ln_ldfeiv ) THEN                         ! allocate the aei arrays
+         ALLOCATE( aeiu(jpi,jpj,jpk), aeiv(jpi,jpj,jpk), STAT=ierr )
+         IF( ierr /= 0 )   CALL ctl_stop('STOP', 'ldf_eiv: failed to allocate arrays')
+         !
+         SELECT CASE( nn_aei_ijk_t )               ! Specification of space time variations of eaiu, aeiv
+         !
+         CASE(   0  )      !==  constant  ==!
+            IF(lwp) WRITE(numout,*) '          eddy induced velocity coef. = constant = ', rn_aeiv_0
+            aeiu(:,:,:) = rn_aeiv_0
+            aeiv(:,:,:) = rn_aeiv_0
+            !
+         CASE(  10  )      !==  fixed profile  ==!
+            IF(lwp) WRITE(numout,*) '          eddy induced velocity coef. = F( depth )'
+            aeiu(:,:,1) = rn_aeiv_0                                ! constant surface value
+            aeiv(:,:,1) = rn_aeiv_0
+            CALL ldf_c1d( 'TRA', r1_4, aeiu(:,:,1), aeiv(:,:,1), aeiu, aeiv )
+            !
+         CASE ( -20 )      !== fixed horizontal shape read in file  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F(i,j) read in eddy_diffusivity_2D.nc file'
+            CALL iom_open ( 'eddy_induced_velocity_2D.nc', inum )
+            CALL iom_get  ( inum, jpdom_data, 'aeiu', aeiu(:,:,1) )
+            CALL iom_get  ( inum, jpdom_data, 'aeiv', aeiv(:,:,1) )
+            CALL iom_close( inum )
+            DO jk = 2, jpk
+               aeiu(:,:,jk) = aeiu(:,:,1)
+               aeiv(:,:,jk) = aeiv(:,:,1)
+            END DO
+            !
+         CASE(  20  )      !== fixed horizontal shape  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( e1, e2 ) or F( e1^3, e2^3 ) (lap or bilap case)'
+            CALL ldf_c2d( 'TRA', 'LAP', rn_aeiv_0, aeiu, aeiv )    ! surface value proportional to scale factor
+            !
+         CASE(  21  )       !==  time varying 2D field  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, time )'
+            IF(lwp) WRITE(numout,*) '                              = F( growth rate of baroclinic instability )'
+            !
+            l_ldfeiv_time = .TRUE.     ! will be calculated by call to ldf_tra routine in step.F90
+            !
+         CASE( -30  )      !== fixed 3D shape read in file  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F(i,j,k) read in eddy_diffusivity_3D.nc file'
+            CALL iom_open ( 'eddy_induced_velocity_3D.nc', inum )
+            CALL iom_get  ( inum, jpdom_data, 'aeiu', aeiu )
+            CALL iom_get  ( inum, jpdom_data, 'aeiv', aeiv )
+            CALL iom_close( inum )
+            !
+         CASE(  30  )       !==  fixed 3D shape  ==!
+            IF(lwp) WRITE(numout,*) '          tracer mixing coef. = F( latitude, longitude, depth )'
+            CALL ldf_c2d( 'TRA', 'LAP', rn_aeiv_0, aeiu, aeiv )    ! surface value proportional to scale factor
+            !                                                 ! reduction with depth
+            CALL ldf_c1d( 'TRA', r1_4, aeiu(:,:,1), aeiv(:,:,1), aeiu, aeiv )
+            !
+         CASE DEFAULT
+            CALL ctl_stop('ldf_tra_init: wrong choice for nn_aei_ijk_t, the type of space-time variation of aei')
+         END SELECT
+         !
       ELSE
-         IF(lwp) WRITE(numout,*) '          harmonic tracer diffusion (default)'
-         IF( aht0 < 0 .AND. .NOT. lk_esopa )   CALL ctl_stop('The horizontal diffusivity coef. aht0 must be positive' )
-      ENDIF
-
-
-      !  Lateral eddy diffusivity and eddy induced velocity coefficients
-      ! ================================================================
-#if defined key_traldf_c3d
-      CALL ldf_tra_c3d( ll_print )      ! aht = 3D coef. = F( longitude, latitude, depth )
-#elif defined key_traldf_c2d
-      CALL ldf_tra_c2d( ll_print )      ! aht = 2D coef. = F( longitude, latitude )
-#elif defined key_traldf_c1d
-      CALL ldf_tra_c1d( ll_print )      ! aht = 1D coef. = F( depth )
-#else
-                                        ! Constant coefficients
-      IF(lwp)WRITE(numout,*)
-      IF(lwp)WRITE(numout,*) '      constant eddy diffusivity coef.   ahtu = ahtv = ahtw = aht0 = ', aht0
-      IF( lk_traldf_eiv ) THEN
-         IF(lwp)WRITE(numout,*) '      constant eddy induced velocity coef.   aeiu = aeiv = aeiw = aeiv0 = ', aeiv0
+          IF(lwp) WRITE(numout,*) '   eddy induced velocity param is NOT used neither diagnosed'
+          ln_ldfeiv_dia = .FALSE.
+      ENDIF
+      !                    
+   END SUBROUTINE ldf_eiv_init
+
+
+   SUBROUTINE ldf_eiv( kt, paei0, paeiu, paeiv )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_eiv  ***
+      !!
+      !! ** Purpose :   Compute the eddy induced velocity coefficient from the
+      !!              growth rate of baroclinic instability.
+      !!
+      !! ** Method  :   coefficient function of the growth rate of baroclinic instability
+      !!
+      !! Reference : Treguier et al. JPO 1997   ; Held and Larichev JAS 1996
+      !!----------------------------------------------------------------------
+      INTEGER                         , INTENT(in   ) ::   kt             ! ocean time-step index
+      REAL(wp)                        , INTENT(inout) ::   paei0          ! max value            [m2/s]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   paeiu, paeiv   ! eiv coefficient      [m2/s]
+      !
+      INTEGER  ::   ji, jj, jk    ! dummy loop indices
+      REAL(wp) ::   zfw, ze3w, zn2, z1_f20, zaht, zaht_min, zzaei   ! local scalars
+      REAL(wp), DIMENSION(:,:), POINTER ::   zn, zah, zhw, zross, zaeiw   ! 2D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('ldf_eiv')
+      !
+      CALL wrk_alloc( jpi,jpj,   zn, zah, zhw, zross, zaeiw )
+      !      
+      zn   (:,:) = 0._wp      ! Local initialization
+      zhw  (:,:) = 5._wp
+      zah  (:,:) = 0._wp
+      zross(:,:) = 0._wp
+      !                       ! Compute lateral diffusive coefficient at T-point
+      IF( ln_traldf_triad ) THEN
+         DO jk = 1, jpk
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1
+                  ! Take the max of N^2 and zero then take the vertical sum 
+                  ! of the square root of the resulting N^2 ( required to compute 
+                  ! internal Rossby radius Ro = .5 * sum_jpk(N) / f 
+                  zn2 = MAX( rn2b(ji,jj,jk), 0._wp )
+                  zn(ji,jj) = zn(ji,jj) + SQRT( zn2 ) * fse3w(ji,jj,jk)
+                  ! Compute elements required for the inverse time scale of baroclinic
+                  ! eddies using the isopycnal slopes calculated in ldfslp.F : 
+                  ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
+                  ze3w = fse3w(ji,jj,jk) * tmask(ji,jj,jk)
+                  zah(ji,jj) = zah(ji,jj) + zn2 * wslp2(ji,jj,jk) * ze3w
+                  zhw(ji,jj) = zhw(ji,jj) + ze3w
+               END DO
+            END DO
+         END DO
+      ELSE
+         DO jk = 1, jpk
+            DO jj = 2, jpjm1
+               DO ji = 2, jpim1
+                  ! Take the max of N^2 and zero then take the vertical sum 
+                  ! of the square root of the resulting N^2 ( required to compute 
+                  ! internal Rossby radius Ro = .5 * sum_jpk(N) / f 
+                  zn2 = MAX( rn2b(ji,jj,jk), 0._wp )
+                  zn(ji,jj) = zn(ji,jj) + SQRT( zn2 ) * fse3w(ji,jj,jk)
+                  ! Compute elements required for the inverse time scale of baroclinic
+                  ! eddies using the isopycnal slopes calculated in ldfslp.F : 
+                  ! T^-1 = sqrt(m_jpk(N^2*(r1^2+r2^2)*e3w))
+                  ze3w = fse3w(ji,jj,jk) * tmask(ji,jj,jk)
+                  zah(ji,jj) = zah(ji,jj) + zn2 * ( wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
+                     &                            + wslpj(ji,jj,jk) * wslpj(ji,jj,jk) ) * ze3w
+                  zhw(ji,jj) = zhw(ji,jj) + ze3w
+               END DO
+            END DO
+         END DO
+      END IF
+
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zfw = MAX( ABS( 2. * omega * SIN( rad * gphit(ji,jj) ) ) , 1.e-10 )
+            ! Rossby radius at w-point taken < 40km and  > 2km
+            zross(ji,jj) = MAX( MIN( .4 * zn(ji,jj) / zfw, 40.e3 ), 2.e3 )
+            ! Compute aeiw by multiplying Ro^2 and T^-1
+            zaeiw(ji,jj) = zross(ji,jj) * zross(ji,jj) * SQRT( zah(ji,jj) / zhw(ji,jj) ) * tmask(ji,jj,1)
+         END DO
+      END DO
+
+!!gm      IF( cp_cfg == "orca" .AND. jp_cfg == 2 ) THEN   ! ORCA R2
+!!gm         DO jj = 2, jpjm1
+!!gm            DO ji = fs_2, fs_jpim1   ! vector opt.
+!!gm               ! Take the minimum between aeiw and 1000 m2/s over shelves (depth shallower than 650 m)
+!!gm               IF( mbkt(ji,jj) <= 20 )   zaeiw(ji,jj) = MIN( zaeiw(ji,jj), 1000. )
+!!gm            END DO
+!!gm         END DO
+!!gm      ENDIF
+
+      !                                         !==  Bound on eiv coeff.  ==!
+      z1_f20 = 1._wp / (  2._wp * omega * sin( rad * 20._wp )  )
+      DO jj = 2, jpjm1
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            zzaei = MIN( 1._wp, ABS( ff(ji,jj) * z1_f20 ) ) * zaeiw(ji,jj)       ! tropical decrease
+            zaeiw(ji,jj) = MIN( zzaei , paei0 )                                  ! Max value = paei0
+         END DO
+      END DO
+      CALL lbc_lnk( zaeiw(:,:), 'W', 1. )       ! lateral boundary condition
+      !               
+      DO jj = 2, jpjm1                          !== aei at u- and v-points  ==!
+         DO ji = fs_2, fs_jpim1   ! vector opt.
+            paeiu(ji,jj,1) = 0.5_wp * ( zaeiw(ji,jj) + zaeiw(ji+1,jj  ) ) * umask(ji,jj,1)
+            paeiv(ji,jj,1) = 0.5_wp * ( zaeiw(ji,jj) + zaeiw(ji  ,jj+1) ) * vmask(ji,jj,1)
+         END DO 
+      END DO 
+      CALL lbc_lnk( paeiu(:,:,1), 'U', 1. )   ;   CALL lbc_lnk( paeiv(:,:,1), 'V', 1. )      ! lateral boundary condition
+
+      DO jk = 2, jpkm1                          !==  deeper values equal the surface one  ==!
+         paeiu(:,:,jk) = paeiu(:,:,1) * umask(:,:,jk)
+         paeiv(:,:,jk) = paeiv(:,:,1) * vmask(:,:,jk)
+      END DO
+      !  
+      CALL wrk_dealloc( jpi,jpj,   zn, zah, zhw, zross, zaeiw )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('ldf_eiv')
+      !
+   END SUBROUTINE ldf_eiv
+
+
+   SUBROUTINE ldf_eiv_trp( kt, kit000, pun, pvn, pwn, cdtype )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_eiv_trp  ***
+      !! 
+      !! ** Purpose :   add to the input ocean transport the contribution of 
+      !!              the eddy induced velocity parametrization.
+      !!
+      !! ** Method  :   The eddy induced transport is computed from a flux stream-
+      !!              function which depends on the slope of iso-neutral surfaces
+      !!              (see ldf_slp). For example, in the i-k plan : 
+      !!                   psi_uw = mk(aeiu) e2u mi(wslpi)   [in m3/s]
+      !!                   Utr_eiv = - dk[psi_uw]
+      !!                   Vtr_eiv = + di[psi_uw]
+      !!                ln_ldfeiv_dia = T : output the associated streamfunction,
+      !!                                    velocity and heat transport (call ldf_eiv_dia)
+      !!
+      !! ** Action  : pun, pvn increased by the eiv transport
+      !!----------------------------------------------------------------------
+      INTEGER                         , INTENT(in   ) ::   kt       ! ocean time-step index
+      INTEGER                         , INTENT(in   ) ::   kit000   ! first time step index
+      CHARACTER(len=3)                , INTENT(in   ) ::   cdtype   ! =TRA or TRC (tracer indicator)
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pun      ! in : 3 ocean transport components   [m3/s]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pvn      ! out: 3 ocean transport components   [m3/s]
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pwn      ! increased by the eiv                [m3/s]
+      !!
+      INTEGER  ::   ji, jj, jk                 ! dummy loop indices
+      REAL(wp) ::   zuwk, zuwk1, zuwi, zuwi1   ! local scalars
+      REAL(wp) ::   zvwk, zvwk1, zvwj, zvwj1   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zpsi_uw, zpsi_vw
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start( 'ldf_eiv_trp')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zpsi_uw, zpsi_vw )
+
+      IF( kt == kit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'ldf_eiv_trp : eddy induced advection on ', cdtype,' :'
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   add to velocity fields the eiv component'
+      ENDIF
+
       
-      ENDIF
-#endif
-
-#if defined key_traldf_smag && ! defined key_traldf_c3d
-        CALL ctl_stop( 'key_traldf_smag can only be used with key_traldf_c3d' )
-#endif
-#if defined key_traldf_smag
-        IF(lwp) WRITE(numout,*)' SMAGORINSKY DIFFUSION'
-        IF(lwp .AND. rn_smsh < 1)  WRITE(numout,*)' only  shear is used '
-        IF(lwp.and.ln_traldf_bilap) CALL ctl_stop(' SMAGORINSKY + BILAPLACIAN - UNSTABLE OR NON_CONSERVATIVE' )
-#endif
-
-      !
-   END SUBROUTINE ldf_tra_init
-
-#if defined key_traldf_c3d
-#   include "ldftra_c3d.h90"
-#elif defined key_traldf_c2d
-#   include "ldftra_c2d.h90"
-#elif defined key_traldf_c1d
-#   include "ldftra_c1d.h90"
-#endif
+      zpsi_uw(:,:, 1 ) = 0._wp   ;   zpsi_vw(:,:, 1 ) = 0._wp
+      zpsi_uw(:,:,jpk) = 0._wp   ;   zpsi_vw(:,:,jpk) = 0._wp
+      !
+      DO jk = 2, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zpsi_uw(ji,jj,jk) = - 0.25_wp * e2u(ji,jj) * ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj,jk) )   &
+                  &                                       * ( aeiu (ji,jj,jk-1) + aeiu (ji  ,jj,jk) ) * umask(ji,jj,jk)
+               zpsi_vw(ji,jj,jk) = - 0.25_wp * e1v(ji,jj) * ( wslpj(ji,jj,jk  ) + wslpj(ji,jj+1,jk) )   &
+                  &                                       * ( aeiv (ji,jj,jk-1) + aeiv (ji,jj  ,jk) ) * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.               
+               pun(ji,jj,jk) = pun(ji,jj,jk) - ( zpsi_uw(ji,jj,jk) - zpsi_uw(ji,jj,jk+1) )
+               pvn(ji,jj,jk) = pvn(ji,jj,jk) - ( zpsi_vw(ji,jj,jk) - zpsi_vw(ji,jj,jk+1) )
+            END DO
+         END DO
+      END DO
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               pwn(ji,jj,jk) = pwn(ji,jj,jk) + (  zpsi_uw(ji,jj,jk) - zpsi_uw(ji-1,jj  ,jk)   &
+                  &                             + zpsi_vw(ji,jj,jk) - zpsi_vw(ji  ,jj-1,jk) )
+            END DO
+         END DO
+      END DO
+      !
+      !                              ! diagnose the eddy induced velocity and associated heat transport
+      IF( ln_ldfeiv_dia .AND. cdtype == 'TRA' )   CALL ldf_eiv_dia( zpsi_uw, zpsi_vw )
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zpsi_uw, zpsi_vw )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop( 'ldf_eiv_trp')
+      !
+    END SUBROUTINE ldf_eiv_trp
+
+
+   SUBROUTINE ldf_eiv_dia( psi_uw, psi_vw )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE ldf_eiv_dia  ***
+      !!
+      !! ** Purpose :   diagnose the eddy induced velocity and its associated
+      !!              vertically integrated heat transport.
+      !!
+      !! ** Method :
+      !!
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   psi_uw, psi_vw   ! streamfunction   [m3/s]
+      !
+      INTEGER  ::   ji, jj, jk    ! dummy loop indices
+      REAL(wp) ::   zztmp   ! local scalar
+      REAL(wp), DIMENSION(:,:)  , POINTER ::   zw2d   ! 2D workspace
+      REAL(wp), DIMENSION(:,:,:), POINTER ::   zw3d   ! 3D workspace
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start( 'ldf_eiv_dia')
+      !
+      !                                                  !==  eiv stream function: output  ==!
+      CALL lbc_lnk( psi_uw, 'U', -1. )                         ! lateral boundary condition
+      CALL lbc_lnk( psi_vw, 'V', -1. )
+      !
+!!gm      CALL iom_put( "psi_eiv_uw", psi_uw )                 ! output
+!!gm      CALL iom_put( "psi_eiv_vw", psi_vw )
+      !
+      !                                                  !==  eiv velocities: calculate and output  ==!
+      CALL wrk_alloc( jpi,jpj,jpk,   zw3d )
+      !
+      zw3d(:,:,jpk) = 0._wp                                    ! bottom value always 0
+      !
+      DO jk = 1, jpkm1                                         ! e2u e3u u_eiv = -dk[psi_uw]
+         zw3d(:,:,jk) = ( psi_uw(:,:,jk+1) - psi_uw(:,:,jk) ) / ( e2u(:,:) * fse3u(:,:,jk) )
+      END DO
+      CALL iom_put( "uoce_eiv", zw3d )
+      !
+      DO jk = 1, jpkm1                                         ! e1v e3v v_eiv = -dk[psi_vw]
+         zw3d(:,:,jk) = ( psi_vw(:,:,jk+1) - psi_vw(:,:,jk) ) / ( e1v(:,:) * fse3v(:,:,jk) )
+      END DO
+      CALL iom_put( "voce_eiv", zw3d )
+      !
+      DO jk = 1, jpkm1                                         ! e1 e2 w_eiv = dk[psix] + dk[psix]
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1  ! vector opt.
+               zw3d(ji,jj,jk) = (  psi_vw(ji,jj,jk) - psi_vw(ji  ,jj-1,jk)    &
+                  &              + psi_uw(ji,jj,jk) - psi_uw(ji-1,jj  ,jk)  ) / e1e2t(ji,jj)
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zw3d, 'T', 1. )      ! lateral boundary condition
+      CALL iom_put( "woce_eiv", zw3d )
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zw3d )
+      !      
+      !
+      IF( lk_diaar5 ) THEN                               !==  eiv heat transport: calculate and output  ==!
+         CALL wrk_alloc( jpi,jpj,   zw2d )
+         !
+         zztmp = 0.5_wp * rau0 * rcp 
+         zw2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zw2d(ji,jj) = zw2d(ji,jj) + zztmp * ( psi_uw(ji,jj,jk+1)      - psi_uw(ji,jj,jk)          )   &
+                     &                              * ( tsn   (ji,jj,jk,jp_tem) + tsn   (ji+1,jj,jk,jp_tem) ) 
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( zw2d, 'U', -1. )
+         CALL iom_put( "ueiv_heattr", zw2d )                  ! heat transport in i-direction
+         zw2d(:,:) = 0._wp 
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zw2d(ji,jj) = zw2d(ji,jj) + zztmp * ( psi_vw(ji,jj,jk+1)      - psi_vw(ji,jj,jk)          )   &
+                     &                              * ( tsn   (ji,jj,jk,jp_tem) + tsn   (ji,jj+1,jk,jp_tem) ) 
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( zw2d, 'V', -1. )
+         CALL iom_put( "veiv_heattr", zw2d )                  !  heat transport in i-direction
+         !
+         CALL wrk_dealloc( jpi,jpj,   zw2d )
+      ENDIF
+      !
+      IF( nn_timing == 1 )  CALL timing_stop( 'ldf_eiv_dia')      
+      !
+   END SUBROUTINE ldf_eiv_dia
 
    !!======================================================================
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_c1d.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_c1d.h90	(revision 6040)
+++ 	(revision )
@@ -1,129 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                      ***  ldftra_c1d.h90  ***
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_tra_c1d( ld_print )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldftra_c1d  ***
-      !!              
-      !! ** Purpose :   1D eddy diffusivity coefficient
-      !!
-      !! ** Method  :   1D eddy diffusivity coefficients ( depth )
-      !!       biharmonic operator    : ahtt = defined at T-level
-      !!                                ahtu,ahtv,ahtw never used
-      !!
-      !!       harmonic operator      : ahtt never used
-      !!          -1-  iso-model level: ahtu = ahtv defined at T-level
-      !!                                ahtw never used
-      !!          -2-  isopycnal or   : ahtu = ahtv defined at T-level
-      !!               geopotential     ahtw defined at w-level
-      !!
-      !!       eddy induced velocity
-      !!         always harmonic      : aeiu = aeiv defined at T-level
-      !!				  aeiw defined at w-level
-      !!----------------------------------------------------------------------
-      LOGICAL, INTENT (in) ::   ld_print   ! If true, print arrays in numout
-      !
-      INTEGER  ::   jk   ! dummy loop indices
-      REAL(wp) ::   zkah, zahr, za00 , za01    ! local scalars
-      REAL(wp) ::   zahf, zahs, zahtf, zahts   !   -      -
-      !!----------------------------------------------------------------------
-
-      IF( lk_traldf_eiv ) THEN 
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' ldf_tra_c1d : 1D eddy diffusivity and eddy induced velocity coefficients'
-         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   -- ' 
-         IF(lwp) WRITE(numout,*)
-      ELSE
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' inildf : 1D eddy diffusivity coefficient '
-         IF(lwp) WRITE(numout,*) ' ~~~~~~   -- '
-         IF(lwp) WRITE(numout,*)
-      ENDIF
-
-      ! initialization of the profile
-
-      ! ahts, ahtf: surface and bottom values
-      zahts = aht0
-      zahtf = aht0/4. 
-      ! zkah, zahr: depth of the inflection pt and width of inflection
-      zkah =  -300.
-      zahr =   300.
-      ! computation coefficients
-      za00 = TANH( ( -fsdept(1,1,1  ) - zkah ) / zahr )
-      za01 = TANH( ( -fsdept(1,1,jpk) - zkah ) / zahr )
-      zahf = ( zahts-zahtf ) / ( za00 - za01 )
-      zahs = zahts - zahf * za00
-
-      ! biharmonic operator : (T-point)
-      ! ==================== 
-
-      ! set ahtt at T-level
-      DO jk = 1, jpk
-         ahtt(jk) = zahs + zahf * TANH( (-fsdept(1,1,jk)-zkah) / zahr )
-      END DO
-
-      ! control print
-      IF(lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '         aht profile at T-level : '
-         WRITE(numout,*)
-         WRITE(numout,*) ' level    aht          depth t-level '
-         DO jk = 1, jpk
-            WRITE(numout,'(i6,2f12.4)') jk, ahtt(jk), fsdept(1,1,jk)
-         END DO
-      ENDIF
-
-      ! harmonic operator : (U-, V-, W-points)
-      ! ================== 
-
-      ! set ahtu = ahtv at T-level, and ahtw at w-level
-      DO jk = 1, jpk
-         ahtu(jk) = zahs + zahf * TANH( ( -fsdept(1,1,jk) - zkah ) / zahr )
-         ahtv(jk) = ahtu(jk)
-         ahtw(jk) = zahs + zahf * TANH( ( -fsdepw(1,1,jk) - zkah ) / zahr )
-      END DO
-
-      ! control print
-      IF(lwp .AND. ld_print ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '         aht profile at T-level : '
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' level    aht          depth t-level '
-         DO jk = 1, jpk
-            IF(lwp) WRITE(numout,"(i6,2f12.4)") jk, ahtu(jk), fsdept(1,1,jk)
-         END DO
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '         aht profile at W-level : '
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '  jk      aht          depth w-level '
-         DO jk = 1, jpk
-            IF(lwp)WRITE(numout,"(i6,2f12.4)") jk, ahtw(jk), fsdepw(1,1,jk)
-         END DO
-      ENDIF
-
-# if defined key_traldf_eiv
-      ! set aeiu = aeiv and set aeiw (here same profile as on aht)
-      aeiu(:) = ahtu(:)
-      aeiv(:) = aeiu(:)
-      aeiw(:) = ahtw(:)
-      
-      ! Control print
-      IF(lwp .AND. ld_print ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '         aeiv profile at T-level : '
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) '  jk      aeiv           depth t-level '
-         DO jk = 1, jpk
-            IF(lwp) WRITE(numout,"(i6,2f12.4)") jk, aeiu(jk), fsdept(1,1,jk)
-         END DO
-      ENDIF
-#endif
-      !
-   END SUBROUTINE ldf_tra_c1d
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_c2d.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_c2d.h90	(revision 6040)
+++ 	(revision )
@@ -1,162 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                      ***  ldftra_c2d.h90  ***
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_tra_c2d( ld_print )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldftra_c2d  ***
-      !!              
-      !! ** Purpose :   initializations of horizontally non uniform eddy 
-      !!      diffusivity coefficients
-      !!
-      !! ** Method :
-      !!       biharmonic operator    : ahtt = defined at T-level
-      !!                                ahtu,ahtv,ahtw never used
-      !!       harmonic operator (ahtt never used)
-      !!           iso-model level   : ahtu, ahtv defined at u-, v-points
-      !!         isopycnal         : ahtu, ahtv, ahtw defined at u-, v-, w-pts
-      !!         or geopotential   
-      !!       eddy induced velocity
-      !!           always harmonic   : aeiu, aeiv, aeiw defined at u-, v-, w-pts
-      !!----------------------------------------------------------------------
-      LOGICAL, INTENT (in) ::   ld_print   ! If true, print arrays in numout
-      !
-      INTEGER ::   ji, jj   ! dummy loop indices
-      REAL(wp) ::   za00, zd_max, zeumax, zevmax, zetmax
-      !!----------------------------------------------------------------------
-
-      IF( lk_traldf_eiv ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' ldf_tra_c2d : 2D eddy diffusivity and eddy'
-         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --  induced velocity coefficients'
-      ELSE
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' ldf_tra2d : 2D eddy diffusivity coefficient'
-         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --'
-      ENDIF
-
-      zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
-      IF( lk_mpp ) CALL mpp_max( zd_max )   ! max over the global domain
-
-      ! harmonic operator : (U-, V-, W-points)
-      ! ==================
-      IF( ln_traldf_lap ) THEN
-         !
-         za00 = aht0 / zd_max
-         !
-         DO jj = 1, jpj 
-            DO ji = 1, jpi 
-               zeumax = MAX( e1u(ji,jj), e2u(ji,jj) ) 
-               zevmax = MAX( e1v(ji,jj), e2v(ji,jj) ) 
-               zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
-               ahtu(ji,jj) = za00 * zeumax ! set ahtu = ahtv at u- and v-points, 
-               ahtv(ji,jj) = za00 * zevmax ! and ahtw at w-point (idem T-point) 
-               ahtw(ji,jj) = za00 * zetmax ! 
-            END DO
-         END DO
-
-         CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
-         CALL lbc_lnk( ahtv, 'V', 1. )   ! (no change of sign)
-         CALL lbc_lnk( ahtw, 'W', 1. )
-
-         ! Special case for ORCA R2 and R4 configurations (overwrite the value of ahtu ahtv ahtw)
-         ! ==============================================
-         IF( cp_cfg == "orca" .AND. ( jp_cfg == 2 .OR. jp_cfg == 4 ) )   THEN
-            ahtu(:,:) = aht0              ! set ahtu = ahtv at u- and v-points,
-            ahtv(:,:) = aht0              ! and ahtw at w-point
-            ahtw(:,:) = aht0              ! (here : no space variation)
-            IF(lwp) WRITE(numout,*) '               ORCA R2 or R4 case'
-            IF(lwp) WRITE(numout,*) '               Constant values used for eddy diffusivity coefficients'
-            IF(lwp) WRITE(numout,*) '               Variation lat/lon only for eddy induced velocity coefficients'
-         ENDIF
-
-         ! Control print
-         IF( lwp .AND. ld_print ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahtu array'
-            CALL prihre( ahtu, jpi, jpj, 1, jpi, 1,   &
-               &                         1, jpj, 1, 1.e-3, numout )
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahtv array'
-            CALL prihre( ahtv, jpi, jpj, 1, jpi, 1,   &
-               &                         1, jpj, 1, 1.e-3, numout )
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: ahtw array'
-            CALL prihre( ahtw, jpi, jpj, 1, jpi, 1,   &
-               &                         1, jpj, 1, 1.e-3, numout )
-         ENDIF
-      ENDIF
-      
-      ! biharmonic operator : (T-point)
-      ! ====================
-      IF( ln_traldf_bilap ) THEN
-         ! (USER: modify ahtt following your desiderata)
-         ! Here: ahm is proportional to the cube of the maximum of the gridspacing
-         !       in the to horizontal direction
-
-         zd_max = MAX( MAXVAL( e1t(:,:) ), MAXVAL( e2t(:,:) ) )
-         IF( lk_mpp )   CALL mpp_max( zd_max )   ! max over the global domain
-
-         za00 = aht0 / ( zd_max * zd_max * zd_max )
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               zetmax = MAX( e1t(ji,jj), e2t(ji,jj) )
-               ahtt(ji,jj) = za00 * zetmax * zetmax * zetmax      ! set ahtt at T-point
-            END DO
-         END DO
-
-         CALL lbc_lnk( ahtt, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
-
-         ! Control print
-         IF( lwp .AND. ld_print ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) 'inildf: 2D ahtt array'
-            CALL prihre( ahtt, jpi, jpj, 1, jpi, 1,   &
-               &                         1, jpj, 1, 1.e-3, numout )
-         ENDIF
-      ENDIF
-
-# if defined key_traldf_eiv
-      ! set aeiu = aeiv at u- and v-points, and aeiw at w-point (idem T-point)
-      ! (here no space variation)
-      aeiu(:,:) = aeiv0
-      aeiv(:,:) = aeiv0
-      aeiw(:,:) = aeiv0
-      
-      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
-         !                                 ! Cancel eiv in Gibraltar strait
-         aeiu( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
-         aeiv( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
-         aeiw( mi0(68):mi1(71) , mj0(50):mj1(53) ) = 0.e0
-         !                                 ! Cancel eiv in Mediterrannean sea
-         aeiu( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
-         aeiv( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
-         aeiw( mi0(70):mi1(90) , mj0(49):mj1(56) ) = 0.e0
-      ENDIF
-
-      ! Lateral boundary conditions on ( aeiu, aeiv, aeiw )
-      CALL lbc_lnk( aeiu, 'U', 1. )
-      CALL lbc_lnk( aeiv, 'V', 1. )
-      CALL lbc_lnk( aeiw, 'W', 1. )
-
-      ! Control print
-      IF( lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: aeiu array'
-         CALL prihre(aeiu,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: aeiv array'
-         CALL prihre(aeiv,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: aeiw array'
-         CALL prihre(aeiw,jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-      ENDIF
-# endif
-      !
-   END SUBROUTINE ldf_tra_c2d
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_c3d.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_c3d.h90	(revision 6040)
+++ 	(revision )
@@ -1,123 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                        ***  ldftra_c3d.h90  ***
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_tra_c3d( ld_print )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE ldftra_c3d  ***
-      !!                
-      !! ** Purpose :
-      !!     initializations of non uniform horizontal eddy diffusivity coef.
-      !!
-      !! ** Method :
-      !!      3D eddy diffusivity coefficients ( longitude, latitude, depth )
-      !!
-      !!       biharmonic operator    : ahtt = defined at T-level
-      !!                                ahtu,ahtv,ahtw never used
-      !!
-      !!       harmonic operator (ahtt never used)
-      !!         iso-model level   : ahtu, ahtv defined at u-, v-points
-      !!         isopycnal         : ahtu, ahtv, ahtw defined at u-, v-, w-pts
-      !!         or geopotential
-      !!
-      !!       eddy induced velocity
-      !!         always harmonic   : aeiu, aeiv, aeiw defined at u-, v-, w-pts
-      !!----------------------------------------------------------------------
-      USE ioipsl
-      !
-      LOGICAL, INTENT (in) ::   ld_print   ! If true, output arrays on numout
-      !!----------------------------------------------------------------------
-
-      IF( lk_traldf_eiv ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' ldf_tra_c3d : 3D eddy diffusivity and eddy induced velocity coefficients'
-         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --  '
-         IF(lwp) WRITE(numout,*) '               Coefficients set to constant'
-      ELSE
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' ldf_tra_c3d : 3D eddy diffusivity coefficient'
-         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   -- '
-         IF(lwp) WRITE(numout,*) '               Coefficients set to constant'
-      ENDIF
-
-
-      ! biharmonic operator   (T-point)
-      ! -------------------
-
-      ahtt(:,:,:) = aht0              ! set ahtt at T-point (here no space variation)
-
-      CALL lbc_lnk( ahtt, 'T', 1. )   ! Lateral boundary conditions on ( ahtt )
-
-      IF(lwp .AND. ld_print ) THEN                    ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtt at k = 1'
-         CALL prihre( ahtt(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-3, numout )
-      ENDIF
-
-
-      ! harmonic operator   (U-, V-, W-points)
-      ! ----------------- 
-
-      ahtu(:,:,:) = aht0              ! set ahtu = ahtv at u- and v-points,
-      ahtv(:,:,:) = aht0              ! and ahtw at w-point
-      ahtw(:,:,:) = aht0              ! (here example: no space variation)
-      
-      CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
-      CALL lbc_lnk( ahtv, 'V', 1. )
-      CALL lbc_lnk( ahtw, 'W', 1. )
-
-      IF(lwp .AND. ld_print ) THEN                    ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtu at k = 1'
-         CALL prihre( ahtu(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-3, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtv at k = 1'
-         CALL prihre( ahtv(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-3, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtw at k = 1'
-         CALL prihre( ahtw(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-3, numout )
-      ENDIF
-
-# if defined key_traldf_eiv
-      aeiu(:,:,:) = aeiv0            ! set aeiu = aeiv at u- and v-points,
-      aeiv(:,:,:) = aeiv0            ! and aeiw at w-point
-      aeiw(:,:,:) = aeiv0            ! (here example: no space variation)
-
-      IF( cp_cfg == "orca" .AND. jp_cfg == 4 ) THEN
-         !                                 ! Cancel eiv in Gibraltar strait
-         aeiu( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
-         aeiv( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
-         aeiw( mi0(68):mi1(71) , mj0(50):mj1(53) , : ) = 0.e0
-         !                                 ! Cancel eiv in Mediterrannean sea
-         aeiu( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
-         aeiv( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
-         aeiw( mi0(70):mi1(90) , mj0(49):mj1(56) , : ) = 0.e0
-      ENDIF
-
-      CALL lbc_lnk( aeiu, 'U', 1. )   ! Lateral boundary conditions 
-      CALL lbc_lnk( aeiv, 'V', 1. )
-      CALL lbc_lnk( aeiw, 'W', 1. )
-      IF(lwp .AND. ld_print ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: aeiu at k = 1'
-         CALL prihre(aeiu(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: aeiv at k = 1'
-         CALL prihre(aeiv(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: aeiw at k = 1'
-         CALL prihre(aeiw(:,:,1),jpi,jpj,1,jpi,1,1,jpj,1,1.e-3,numout)
-      ENDIF
-
-# endif
-   END SUBROUTINE ldf_tra_c3d
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_oce.F90	(revision 6040)
+++ 	(revision )
@@ -1,124 +1,0 @@
-MODULE ldftra_oce
-   !!=====================================================================
-   !!                      ***  MODULE  ldftra_oce  ***
-   !! Ocean physics :  lateral tracer mixing coefficient defined in memory 
-   !!=====================================================================
-   !! History :  9.0  !  2002-11  (G. Madec)  Original code
-   !!----------------------------------------------------------------------
-   USE par_oce        ! ocean parameters
-   USE in_out_manager ! I/O manager
-   USE lib_mpp         ! MPP library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC ldftra_oce_alloc ! called by nemo_init->nemo_alloc, nemogcm.F90
-
-   !!----------------------------------------------------------------------
-   !! Lateral eddy diffusivity coefficients (tracers)
-   !!----------------------------------------------------------------------
-   !                                     !!* Namelist namtra_ldf : lateral mixing *
-   LOGICAL , PUBLIC ::   ln_traldf_lap    !: laplacian operator
-   LOGICAL , PUBLIC ::   ln_traldf_bilap  !: bilaplacian operator
-   LOGICAL , PUBLIC ::   ln_traldf_level  !: iso-level direction
-   LOGICAL , PUBLIC ::   ln_traldf_hor    !: horizontal (geopotential) direction
-   LOGICAL , PUBLIC ::   ln_traldf_iso    !: iso-neutral direction
-   LOGICAL , PUBLIC ::   ln_traldf_grif   !: griffies skew flux
-   LOGICAL , PUBLIC ::   ln_traldf_gdia   !: griffies skew flux streamfunction diagnostics
-   REAL(wp), PUBLIC ::   rn_aht_0         !: lateral eddy diffusivity (m2/s)
-   REAL(wp), PUBLIC ::   rn_ahtb_0        !: lateral background eddy diffusivity (m2/s)
-   REAL(wp), PUBLIC ::   rn_aeiv_0        !: eddy induced velocity coefficient (m2/s)
-   REAL(wp), PUBLIC ::   rn_slpmax        !: slope limit
-   REAL(wp), PUBLIC ::   rn_chsmag        !:  multiplicative factor in Smagorinsky diffusivity
-   REAL(wp), PUBLIC ::   rn_smsh          !:  Smagorinsky diffusivity: = 0 - use only sheer
-   REAL(wp), PUBLIC ::   rn_aht_m         !:  upper limit or stability criteria for lateral eddy diffusivity (m2/s)
-
-   REAL(wp), PUBLIC ::   aht0, ahtb0, aeiv0         !!: OLD namelist names
-
-   LOGICAL , PUBLIC ::   ln_triad_iso    !: calculate triads twice
-   LOGICAL , PUBLIC ::   ln_botmix_grif  !: mixing on bottom
-   LOGICAL , PUBLIC ::   l_grad_zps      = .FALSE.   !: special treatment for Horz Tgradients w partial steps 
-
-   REAL(wp), PUBLIC ::   rldf                        !: multiplicative factor of diffusive coefficient
-                                                     !: Needed to define the ratio between passive and active tracer diffusion coef. 
-
-#if defined key_traldf_c3d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ahtt, ahtu, ahtv, ahtw   !: ** 3D coefficients ** at T-,U-,V-,W-points
-#elif defined key_traldf_c2d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ahtt, ahtu, ahtv, ahtw   !: ** 2D coefficients ** at T-,U-,V-,W-points
-#elif defined key_traldf_c1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:)     ::   ahtt, ahtu, ahtv, ahtw   !: ** 1D coefficients ** at T-,U-,V-,W-points
-#else
-   REAL(wp), PUBLIC                                      ::   ahtt, ahtu, ahtv, ahtw   !: ** 0D coefficients ** at T-,U-,V-,W-points
-#endif
-
-#if defined key_traldf_eiv
-   !!----------------------------------------------------------------------
-   !!   'key_traldf_eiv'                              eddy induced velocity
-   !!----------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER               ::   lk_traldf_eiv   = .TRUE.   !: eddy induced velocity flag
-   
-   !                                                                              !!! eddy coefficients at U-, V-, W-points  [m2/s]
-# if defined key_traldf_c3d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   aeiu , aeiv , aeiw   !: ** 3D coefficients **
-# elif defined key_traldf_c2d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   aeiu , aeiv , aeiw   !: ** 2D coefficients **
-# elif defined key_traldf_c1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:)     ::   aeiu , aeiv , aeiw   !: ** 1D coefficients **
-# else
-   REAL(wp), PUBLIC                                      ::   aeiu , aeiv , aeiw   !: ** 0D coefficients **
-# endif
-# if defined key_diaeiv
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   u_eiv, v_eiv, w_eiv   !: eddy induced velocity [m/s]
-# endif
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option :                           NO eddy induced velocity
-   !!----------------------------------------------------------------------
-   LOGICAL , PUBLIC, PARAMETER ::   lk_traldf_eiv   = .FALSE.   !: eddy induced velocity flag
-   REAL(wp), PUBLIC            ::   aeiu, aeiv, aeiw            !: eddy induced coef. (not used)
-#endif
-
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION ldftra_oce_alloc()
-     !!----------------------------------------------------------------------
-      !!                 ***  FUNCTION ldftra_oce_alloc  ***
-     !!----------------------------------------------------------------------
-     INTEGER, DIMENSION(3) :: ierr
-     !!----------------------------------------------------------------------
-     ierr(:) = 0
-
-#if defined key_traldf_c3d
-      ALLOCATE( ahtt(jpi,jpj,jpk) , ahtu(jpi,jpj,jpk) , ahtv(jpi,jpj,jpk) , ahtw(jpi,jpj,jpk) , STAT=ierr(1) )
-#elif defined key_traldf_c2d
-      ALLOCATE( ahtt(jpi,jpj    ) , ahtu(jpi,jpj    ) , ahtv(jpi,jpj    ) , ahtw(jpi,jpj    ) , STAT=ierr(1) )
-#elif defined key_traldf_c1d
-      ALLOCATE( ahtt(        jpk) , ahtu(        jpk) , ahtv(        jpk) , ahtw(        jpk) , STAT=ierr(1) )
-#endif
-      !
-#if defined key_traldf_eiv
-# if defined key_traldf_c3d
-      ALLOCATE( aeiu(jpi,jpj,jpk) , aeiv(jpi,jpj,jpk) , aeiw(jpi,jpj,jpk) , STAT=ierr(2) )
-# elif defined key_traldf_c2d
-      ALLOCATE( aeiu(jpi,jpj    ) , aeiv(jpi,jpj    ) , aeiw(jpi,jpj    ) , STAT=ierr(2) )
-# elif defined key_traldf_c1d
-      ALLOCATE( aeiu(        jpk) , aeiv(        jpk) , aeiw(        jpk) , STAT=ierr(2) )
-# endif
-# if defined key_diaeiv
-      ALLOCATE( u_eiv(jpi,jpj,jpk), v_eiv(jpi,jpj,jpk), w_eiv(jpi,jpj,jpk), STAT=ierr(3))
-# endif
-#endif
-      ldftra_oce_alloc = MAXVAL( ierr )
-      IF( ldftra_oce_alloc /= 0 )   CALL ctl_warn('ldftra_oce_alloc: failed to allocate arrays')
-      !
-   END FUNCTION ldftra_oce_alloc
-
-   !!=====================================================================
-END MODULE ldftra_oce
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_smag.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_smag.F90	(revision 6040)
+++ 	(revision )
@@ -1,210 +1,0 @@
-MODULE ldftra_smag
-   !!======================================================================
-   !!                     ***  MODULE  ldftrasmag  ***
-   !! Ocean physics:  variable eddy induced velocity coefficients
-   !!======================================================================
-#if   defined key_traldf_smag   &&   defined key_traldf_c3d
-   !!----------------------------------------------------------------------
-   !!   'key_traldf_smag'      and           smagorinsky  diffusivity
-   !!   'key_traldf_c3d'                    3D tracer lateral  mixing coef.
-   !!----------------------------------------------------------------------
-   !!   ldf_eiv      : compute the eddy induced velocity coefficients
-   !!----------------------------------------------------------------------
-   !! * Modules used
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE sbc_oce         ! surface boundary condition: ocean
-   USE sbcrnf          ! river runoffs
-   USE ldftra_oce      ! ocean tracer   lateral physics
-   USE phycst          ! physical constants
-   USE ldfslp          ! iso-neutral slopes
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl          ! Print control
-   USE iom
-   USE wrk_nemo
-   IMPLICIT NONE
-   PRIVATE
-
-   !! * Routine accessibility
-   PUBLIC ldf_tra_smag               ! routine called by step.F90
-   !!----------------------------------------------------------------------
-   !!  OPA 9.0 , LOCEAN-IPSL (2005) 
-   !! $Id$
-   !! This software is governed by the CeCILL licence see modipsl/doc/NEMO_CeCILL.txt 
-   !!----------------------------------------------------------------------
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-
-CONTAINS
-
- 
-
-
-
-  !!----------------------------------------------------------------------
-  !!                        ***  ldf_tra_smag.F90  ***
-  !!----------------------------------------------------------------------
-
-
-   SUBROUTINE ldf_tra_smag( kt )
-      !!----------------------------------------------------------------------
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_tra_smag  ***
-      !!                   
-      !! ** Purpose :   initializations of the horizontal ocean physics
-      !!
-      !! ** Method  :   3D eddy viscosity coef. 
-      !!    M.Griffies, R.Hallberg AMS, 2000
-      !!  for laplacian:
-      !!   Asmag=(C/pi)^2*dx*dy sqrt(D^2), C=1 for tracers, C=3-4 for viscosity
-      !!   D^2= rm_smsh*(du/dx-dv/dy)^2+(dv/dx+du/dy)^2 for Cartesian coordinates
-      !!  IF rm_smsh = 0 , only shear is used, recommended for tidal flows
-      !!  in general case du/dx ==> e2 d(u/e2)/dx;  du/dy ==> e1 d(u/e1)/dy; 
-      !!                  dv/dx ==> e2 d(v/e2)/dx;  dv/dy ==> e1 d(v/e1)/dy
-      !!  for bilaplacian: now this option is deleted as unstable or non-conservative
-      !!   - delta{Bsmag (delta(T)} = -Bsmag* delta{delta(T)} - delta(Bsmag)*delta( T )
-      !!  second term is of arbitrary sign on the edge of fronts and can induce instability 
-      !!   Bsmag=Asmag*dx*dy/8
-      !!  
-      !!       laplacian operator   : ahm1, ahm2 defined at T- and F-points
-      !!                              ahm3, ahm4 never used
-      !!       bilaplacian operator : ahm1, ahm2 never used
-      !!                           :  ahm3, ahm4 defined at U- and V-points
-      !!       ??? explanation of the default is missing
-      !!  last modified : Maria Luneva, October 2012
-      !!----------------------------------------------------------------------
-      !!
-      !!----------------------------------------------------------------------
-      !! * Modules used
-      USE ioipsl
-      REAL ( wp), POINTER , DIMENSION (:,:) :: zux, zvx , zuy , zvy 
-      REAL ( wp), POINTER , DIMENSION (:,:) :: zue1, zue2 , zve1 , zve2 
-      INTEGER, INTENT( in )                 ::   kt                             ! ocean time-step inedx
-      !! * Arguments
-      INTEGER                               :: ji,jj,jk
-
-      REAL (wp)                             ::     zdeltau, zdeltav, zhsmag ,zsmsh    ! temporary scalars
-      
-      CALL wrk_alloc (jpi,jpj,zux, zvx , zuy , zvy )
-      CALL wrk_alloc (jpi,jpj,zue1, zue2 , zve1 , zve2 )
-      !!----------------------------------------------------------------------
-      IF(  kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) ' ldf_tra_smag : 3D eddy smagorinsky diffusivity '
-         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~   --  '
-         IF(lwp) WRITE(numout,*) '               Coefficients are computed'
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*)
-      ENDIF
-
-      zhsmag = rn_chsmag
-      zsmsh  = rn_smsh 
-      zux(:,:)=0._wp ; zuy(:,:)=0._wp ; zvx(:,:)=0._wp ; zvy(:,:)=0._wp
-
-      ! -------------------
-      ahtt(:,:,:) = rn_aht_0
-       IF( ln_traldf_bilap ) THEN
-        IF( lwp .AND. kt == nit000) WRITE(numout,* )'ldf_tra_smag :no bilaplacian Smagorinsky diffusivity'
-        IF( lwp .AND. kt == nit000) WRITE(numout,* )'ldf_tra_smag :bilaplacian diffusivity set to constant'  
-       ENDIF
-
-
-
-      ! harmonic operator   (U-, V-, W-points)
-      ! ----------------- 
-
-      ahtu(:,:,:) = rn_aht_0                  ! set ahtu , ahtv at u- and v-points,
-      ahtv(:,:,:) = rn_aht_0                  ! and ahtw at w-point
-      ahtw(:,:,:) = rn_aht_0                  ! (here example: no space variation)
-      
-      IF( ln_traldf_lap ) THEN
-
-         DO jk=1,jpk
-
-           zue2(:,:)=un(:,:,jk)/e2u(:,:)
-           zve1(:,:)=vn(:,:,jk)/e1v(:,:)
-           zue1(:,:)=un(:,:,jk)/e1u(:,:)
-           zve2(:,:)=vn(:,:,jk)/e2v(:,:)
-
-
-           DO jj=2,jpj
-            DO ji=2,jpi
-            zux(ji,jj)=(zue2(ji,jj)-zue2(ji-1,jj))/e1t(ji,jj)*e2t(ji,jj)*tmask(ji,jj,jk) * zsmsh 
-            zvy(ji,jj)=(zve1(ji,jj)-zve1(ji,jj-1))/e2t(ji,jj)*e1t(ji,jj)*tmask(ji,jj,jk) * zsmsh 
-            ENDDO
-           ENDDO
-
-           DO jj=1,jpjm1
-            DO ji=1,jpim1
-            zuy(ji,jj)=(zue1(ji,jj+1)-zue1(ji,jj))/e2f(ji,jj)*e1f(ji,jj)*fmask(ji,jj,jk)
-            zvx(ji,jj)=(zve2(ji+1,jj)-zve2(ji,jj))/e1f(ji,jj)*e2f(ji,jj)*fmask(ji,jj,jk)
-            ENDDO
-           ENDDO
-
-
-          DO jj=2,jpjm1
-           DO ji=2,jpim1
-           zdeltau=2._wp/( e1u(ji,jj)**(-2)+e2u(ji,jj)**(-2) )
-           zdeltav=2._wp/( e1v(ji,jj)**(-2)+e2v(ji,jj)**(-2) )
-
-           ahtu(ji,jj,jk)=MAX( rn_aht_0 , (zhsmag/rpi)**2*zdeltau*                                &
-                          SQRT(0.25_wp*( zux(ji,jj)+zux(ji+1,jj)-zvy(ji,jj)-zvy(ji+1,jj) )**2+    &
-                               0.25_wp*( zuy(ji,jj)+zuy(ji,jj-1)+zvx(ji,jj)+zvx(ji,jj-1)  )**2) )
-
-           ahtv(ji,jj,jk)=MAX( rn_aht_0 ,  (zhsmag/rpi)**2*zdeltav*                               &
-                          SQRT(0.25_wp*( zux(ji,jj)+zux(ji,jj+1)-zvy(ji,jj)-zvy(ji,jj+1) )**2+    &
-                               0.25_wp*( zuy(ji,jj)+zuy(ji-1,jj)+zvx(ji-1,jj)+zvx(ji,jj)  )**2) )
-
-
-         !!! stability criteria: aht<delta**2/(4*dt)   dt=2*rdt , positiveness require aht<delta**2/(8*dt)
-             ahtu(ji,jj,jk)=MIN(ahtu(ji,jj,jk),zdeltau/(16*rdt) ,rn_aht_m)
-             ahtv(ji,jj,jk)=MIN(ahtv(ji,jj,jk),zdeltav/(16*rdt) ,rn_aht_m)
-         ! so...
-
-
-            ENDDO
-           ENDDO
-         ENDDO
-        ENDIF
-            ahtu(:,:,jpk) = ahtu(:,:,jpkm1)
-            ahtv(:,:,jpk) = ahtv(:,:,jpkm1)
-        CALL lbc_lnk( ahtu, 'U', 1. )   ! Lateral boundary conditions
-        CALL lbc_lnk( ahtv, 'V', 1. )
-
-IF(  kt == nit000 ) THEN
-
-      IF(lwp ) THEN                    ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtu at k = 1'
-         CALL prihre( ahtu(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-1, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtv at k = 1'
-         CALL prihre( ahtv(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-1, numout )
-         WRITE(numout,*)
-         WRITE(numout,*) 'inildf: ahtw at k = 1'
-         CALL prihre( ahtw(:,:,1), jpi, jpj, 1, jpi, 1,   &
-            &                                1, jpj, 1, 1.e-1, numout )
-      ENDIF
-ENDIF
-
-      CALL wrk_dealloc ( jpi,jpj,zux, zvx , zuy , zvy     )
-      CALL wrk_dealloc ( jpi,jpj,zue1, zue2 , zve1 , zve2 )
-
-
-END SUBROUTINE ldf_tra_smag
-#else
-   !!----------------------------------------------------------------------
-   !!   Default option                                         Dummy module
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE ldf_tra_smag( kt )       ! Empty routine
-      WRITE(*,*) 'ldf_dyn_smag: You should not have seen this print! error? check keys ldf:c3d+smag', kt
-   END SUBROUTINE ldf_tra_smag
-#endif
-
-END MODULE ldftra_smag
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_substitute.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/LDF/ldftra_substitute.h90	(revision 6040)
+++ 	(revision )
@@ -1,36 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                    *** ldftra_substitute.h90  ***
-   !!----------------------------------------------------------------------
-   !! ** purpose :   substitute fsaht. the eddy diffusivity coeff.
-   !!      with a constant or 1D or 2D or 3D array, using CPP macro.
-   !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-#if defined key_traldf_c3d
-!   'key_traldf_c3d' :                 aht: 3D coefficient
-#       define   fsahtt(i,j,k)   rldf * ahtt(i,j,k)
-#       define   fsahtu(i,j,k)   rldf * ahtu(i,j,k)
-#       define   fsahtv(i,j,k)   rldf * ahtv(i,j,k)
-#       define   fsahtw(i,j,k)   rldf * ahtw(i,j,k)
-#elif defined key_traldf_c2d
-!   'key_traldf_c2d' :                 aht: 2D coefficient
-#       define   fsahtt(i,j,k)   rldf * ahtt(i,j)
-#       define   fsahtu(i,j,k)   rldf * ahtu(i,j)
-#       define   fsahtv(i,j,k)   rldf * ahtv(i,j)
-#       define   fsahtw(i,j,k)   rldf * ahtw(i,j)
-#elif defined key_traldf_c1d
-!   'key_traldf_c1d' :                aht: 1D coefficient
-#       define   fsahtt(i,j,k)   rldf * ahtt(k)
-#       define   fsahtu(i,j,k)   rldf * ahtu(k)
-#       define   fsahtv(i,j,k)   rldf * ahtv(k)
-#       define   fsahtw(i,j,k)   rldf * ahtw(k)
-#else
-!   Default option :             aht: Constant coefficient
-#      define   fsahtt(i,j,k)   rldf * aht0
-#      define   fsahtu(i,j,k)   rldf * aht0
-#      define   fsahtv(i,j,k)   rldf * aht0
-#      define   fsahtw(i,j,k)   rldf * aht0
-#endif
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/OBS/obs_readmdt.F90	(revision 6041)
@@ -24,5 +24,5 @@
    USE lib_mpp          ! MPP library
    USE dom_oce, ONLY : &                  ! Domain variables
-      &                    tmask, tmask_i, e1t, e2t, gphit, glamt
+      &                    tmask, tmask_i, e1e2t, gphit, glamt
    USE obs_const, ONLY :   obfillflt      ! Fillvalue
    USE oce      , ONLY :   sshn           ! Model variables
@@ -220,5 +220,5 @@
       DO jj = 1, jpj
          DO ji = 1, jpi
-          zdxdy = e1t(ji,jj) * e2t(ji,jj) * zpromsk(ji,jj)
+          zdxdy = e1e2t(ji,jj) * zpromsk(ji,jj)
           zarea = zarea + zdxdy
           zeta1 = zeta1 + mdt(ji,jj) * zdxdy
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/cpl_oasis3.F90	(revision 6041)
@@ -4,14 +4,15 @@
    !! Coupled O/A : coupled ocean-atmosphere case using OASIS3-MCT
    !!=====================================================================
-   !! History :   
-   !!   9.0  !  04-06  (R. Redler, NEC Laboratories Europe, Germany) Original code
-   !!   " "  !  04-11  (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Germany) revision
-   !!   " "  !  04-11  (V. Gayler, MPI M&D) Grid writing
-   !!   " "  !  05-08  (R. Redler, W. Park) frld initialization, paral(2) revision
-   !!   " "  !  05-09  (R. Redler) extended to allow for communication over root only
-   !!   " "  !  06-01  (W. Park) modification of physical part
-   !!   " "  !  06-02  (R. Redler, W. Park) buffer array fix for root exchange
-   !!   3.4  !  11-11  (C. Harris) Changes to allow mutiple category fields
-   !!----------------------------------------------------------------------
+   !! History :  1.0  !  2004-06  (R. Redler, NEC Laboratories Europe, Germany) Original code
+   !!             -   !  2004-11  (R. Redler, NEC Laboratories Europe; N. Keenlyside, W. Park, IFM-GEOMAR, Germany) revision
+   !!             -   !  2004-11  (V. Gayler, MPI M&D) Grid writing
+   !!            2.0  !  2005-08  (R. Redler, W. Park) frld initialization, paral(2) revision
+   !!             -   !  2005-09  (R. Redler) extended to allow for communication over root only
+   !!             -   !  2006-01  (W. Park) modification of physical part
+   !!             -   !  2006-02  (R. Redler, W. Park) buffer array fix for root exchange
+   !!            3.4  !  2011-11  (C. Harris) Changes to allow mutiple category fields
+   !!            3.6  !  2014-11  (S. Masson) OASIS3-MCT
+   !!----------------------------------------------------------------------
+   
    !!----------------------------------------------------------------------
    !!   'key_oasis3'                    coupled Ocean/Atmosphere via OASIS3-MCT
@@ -20,6 +21,6 @@
    !!   cpl_init     : initialization of coupled mode communication
    !!   cpl_define   : definition of grid and fields
-   !!   cpl_snd     : snd out fields in coupled mode
-   !!   cpl_rcv     : receive fields in coupled mode
+   !!   cpl_snd      : snd out fields in coupled mode
+   !!   cpl_rcv      : receive fields in coupled mode
    !!   cpl_finalize : finalize the coupled mode communication
    !!----------------------------------------------------------------------
@@ -99,6 +100,6 @@
       !! ** Method  :   OASIS3 MPI communication 
       !!--------------------------------------------------------------------
-      CHARACTER(len = *), INTENT(in) ::   cd_modname   ! model name as set in namcouple file
-      INTEGER          , INTENT(out) ::   kl_comm      ! local communicator of the model
+      CHARACTER(len = *), INTENT(in   ) ::   cd_modname   ! model name as set in namcouple file
+      INTEGER           , INTENT(  out) ::   kl_comm      ! local communicator of the model
       !!--------------------------------------------------------------------
 
@@ -163,5 +164,4 @@
          CALL oasis_abort ( ncomp_id, 'cpl_define', 'nsnd is larger than nmaxfld, increase nmaxfld')   ;   RETURN
       ENDIF
-
       !
       ! ... Define the shape for the area that excludes the halo
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/fldread.F90	(revision 6041)
@@ -285,5 +285,4 @@
                ztinta =  REAL( isecsbc - sd(jf)%nrec_b(2), wp ) / REAL( sd(jf)%nrec_a(2) - sd(jf)%nrec_b(2), wp )
                ztintb =  1. - ztinta
-!CDIR COLLAPSE
                sd(jf)%fnow(:,:,:) = ztintb * sd(jf)%fdta(:,:,:,1) + ztinta * sd(jf)%fdta(:,:,:,2)
             ELSE   ! nothing to do...
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/geo2ocean.F90	(revision 6041)
@@ -195,5 +195,4 @@
 
       DO jj = 2, jpjm1
-!CDIR NOVERRCHK
          DO ji = fs_2, jpi   ! vector opt.
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbc_oce.F90	(revision 6041)
@@ -80,5 +80,4 @@
    INTEGER , PUBLIC, PARAMETER ::   jp_mfs     = 6        !: MFS  bulk                     formulation
    INTEGER , PUBLIC, PARAMETER ::   jp_none    = 7        !: for OPA when doing coupling via SAS module
-   INTEGER , PUBLIC, PARAMETER ::   jp_esopa   = -1       !: esopa test, ALL formulations
    
    !!----------------------------------------------------------------------
@@ -200,7 +199,5 @@
       !!---------------------------------------------------------------------
       zcoef = 0.5 / ( zrhoa * zcdrag ) 
-!CDIR NOVERRCHK
       DO jj = 2, jpjm1
-!CDIR NOVERRCHK
          DO ji = fs_2, fs_jpim1   ! vect. opt.
             ztx = utau(ji-1,jj  ) + utau(ji,jj) 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcana.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcana.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcana.F90	(revision 6041)
@@ -279,7 +279,5 @@
       ! module of wind stress and wind speed at T-point
       zcoef = 1. / ( zrhoa * zcdrag ) 
-!CDIR NOVERRCHK
       DO jj = 2, jpjm1
-!CDIR NOVERRCHK
          DO ji = fs_2, fs_jpim1   ! vect. opt.
             ztx = utau(ji-1,jj  ) + utau(ji,jj) 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcapr.F90	(revision 6041)
@@ -12,5 +12,4 @@
    USE dom_oce         ! ocean space and time domain
    USE sbc_oce         ! surface boundary condition
-   USE dynspg_oce      ! surface pressure gradient variables
    USE phycst          ! physical constants
    USE fldread         ! read input fields
@@ -62,5 +61,5 @@
       !!---------------------------------------------------------------------
       INTEGER, INTENT(in)::   kt   ! ocean time step
-      !!
+      !
       INTEGER            ::   ierror  ! local integer 
       INTEGER            ::   ios     ! Local integer output status for namelist read
@@ -71,5 +70,4 @@
       NAMELIST/namsbc_apr/ cn_dir, sn_apr, ln_ref_apr, rn_pref, ln_apr_obc
       !!----------------------------------------------------------------------
-      !
       !
       !                                         ! -------------------- !
@@ -113,6 +111,5 @@
             IF(lwp) WRITE(numout,*) '         Inverse barometer added to OBC ssh data'
          ENDIF
-         IF( ( ln_apr_obc ) .AND. .NOT. lk_dynspg_ts )   &
-            CALL ctl_stop( 'sbc_apr: use inverse barometer ssh at open boundary ONLY possible with time-splitting' )
+!jc: stop below should rather be a warning 
          IF( ( ln_apr_obc ) .AND. .NOT. ln_apr_dyn   )   &
             CALL ctl_stop( 'sbc_apr: use inverse barometer ssh at open boundary ONLY requires ln_apr_dyn=T' )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_clio.F90	(revision 6041)
@@ -243,7 +243,5 @@
       !   momentum fluxes  (utau, vtau )   !
       !------------------------------------!
-!CDIR COLLAPSE
       utau(:,:) = sf(jp_utau)%fnow(:,:,1)
-!CDIR COLLAPSE
       vtau(:,:) = sf(jp_vtau)%fnow(:,:,1)
 
@@ -251,7 +249,5 @@
       !   wind stress module (taum )       !
       !------------------------------------!
-!CDIR NOVERRCHK
       DO jj = 2, jpjm1
-!CDIR NOVERRCHK
          DO ji = fs_2, fs_jpim1   ! vector opt.
             ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
@@ -268,5 +264,4 @@
       !   store the wind speed  (wndm )    !
       !------------------------------------!
-!CDIR COLLAPSE
       wndm(:,:) = sf(jp_wndm)%fnow(:,:,1)
       wndm(:,:) = wndm(:,:) * tmask(:,:,1)
@@ -281,8 +276,5 @@
       !   Other ocean fluxes   !
       !------------------------!
-!CDIR NOVERRCHK
-!CDIR COLLAPSE
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             !
@@ -375,9 +367,7 @@
       zcprec = rcp /  rday     ! convert prec ( mm/day ==> m/s)  ==> W/m2
 
-!CDIR COLLAPSE
       emp(:,:) = zqla(:,:) / cevap                                        &   ! freshwater flux
          &     - sf(jp_prec)%fnow(:,:,1) / rday * tmask(:,:,1)
       !
-!CDIR COLLAPSE
       qns(:,:) = zqlw(:,:) - zqsb(:,:) - zqla(:,:)                        &   ! Downward Non Solar flux
          &     - zqla(:,:)             * pst(:,:) * zcevap                &   ! remove evap.   heat content at SST in Celcius
@@ -415,4 +405,5 @@
 
 # if defined key_lim2 || defined key_lim3
+
    SUBROUTINE blk_ice_clio_tau
       !!---------------------------------------------------------------------------
@@ -429,15 +420,15 @@
       !
       IF( nn_timing == 1 )  CALL timing_start('blk_ice_clio_tau')
-
+      !
       SELECT CASE( cp_ice_msh )
-
+      !
       CASE( 'C' )                          ! C-grid ice dynamics
-
+         !
          zcoef  = cai / cao                         ! Change from air-sea stress to air-ice stress
          utau_ice(:,:) = zcoef * utau(:,:)
          vtau_ice(:,:) = zcoef * vtau(:,:)
-
+         !
       CASE( 'I' )                          ! I-grid ice dynamics:  I-point (i.e. F-point lower-left corner)
-
+         !
          zcoef  = 0.5_wp * cai / cao                ! Change from air-sea stress to air-ice stress
          DO jj = 2, jpj         ! stress from ocean U- and V-points to ice U,V point
@@ -447,19 +438,21 @@
             END DO
          END DO
-
+         !
          CALL lbc_lnk( utau_ice(:,:), 'I', -1. )   ;   CALL lbc_lnk( vtau_ice(:,:), 'I', -1. )   ! I-point
-
+         !
       END SELECT
-
+      !
       IF(ln_ctl) THEN
          CALL prt_ctl(tab2d_1=utau_ice , clinfo1=' blk_ice_clio: utau_ice : ', tab2d_2=vtau_ice , clinfo2=' vtau_ice : ')
       ENDIF
-
+      !
       IF( nn_timing == 1 )  CALL timing_stop('blk_ice_clio_tau')
-
+      !
    END SUBROUTINE blk_ice_clio_tau
+   
 #endif
 
 # if defined key_lim2 || defined key_lim3
+
    SUBROUTINE blk_ice_clio_flx(  ptsu , palb_cs, palb_os, palb )
       !!---------------------------------------------------------------------------
@@ -520,8 +513,5 @@
       !--------------------------------------------------------------------------------
 
-!CDIR NOVERRCHK
-!CDIR COLLAPSE
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             ztatm (ji,jj) = sf(jp_tair)%fnow(ji,jj,1)                ! air temperature in Kelvins 
@@ -573,10 +563,7 @@
 
       !                                     ! ========================== !
-      DO jl = 1, jpl                       !  Loop over ice categories  !
+      DO jl = 1, jpl                        !  Loop over ice categories  !
          !                                  ! ========================== !
-!CDIR NOVERRCHK
-!CDIR COLLAPSE
          DO jj = 1 , jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                !-------------------------------------------!
@@ -636,7 +623,5 @@
       ! ----------------------------------------------------------------------------- !
       !
-!CDIR COLLAPSE
       qns_ice(:,:,:) = z_qlw (:,:,:) - z_qsb (:,:,:) - qla_ice (:,:,:)      ! Downward Non Solar flux
-!CDIR COLLAPSE
       tprecip(:,:)   = sf(jp_prec)%fnow(:,:,1) / rday                     ! total precipitation [kg/m2/s]
       !
@@ -644,5 +629,4 @@
       !    Correct the OCEAN non solar flux with the existence of solid precipitation !
       ! ---------------=====--------------------------------------------------------- !
-!CDIR COLLAPSE
       qns(:,:) = qns(:,:)                                                           &   ! update the non-solar heat flux with:
          &     - sprecip(:,:) * lfus                                                  &   ! remove melting solid precip
@@ -782,8 +766,5 @@
       ! Saturated water vapour and vapour pressure
       ! ------------------------------------------
-!CDIR NOVERRCHK
-!CDIR COLLAPSE
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             ztamr = sf(jp_tair)%fnow(ji,jj,1) - rtt
@@ -814,7 +795,5 @@
       zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
 
-!CDIR NOVERRCHK
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             !  product of sine (cosine) of latitude and sine (cosine) of solar declination
@@ -837,11 +816,7 @@
 
       ! compute and sum ocean qsr over the daylight (i.e. between sunrise and sunset)
-!CDIR NOVERRCHK   
       DO jt = 1, jp24
          zcoef = FLOAT( jt ) - 0.5
-!CDIR NOVERRCHK     
-!CDIR COLLAPSE
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                zlha = COS(  zlsrise(ji,jj) - zcoef * zdlha(ji,jj)  )                  ! local hour angle
@@ -862,5 +837,4 @@
       ! Taking into account the ellipsity of the earth orbit, the clouds AND masked if sea-ice cover > 0%
       zcoef1 = srgamma * zdaycor / ( 2. * rpi )
-!CDIR COLLAPSE
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -920,8 +894,5 @@
       ! Saturated water vapour and vapour pressure
       ! ------------------------------------------
-!CDIR NOVERRCHK
-!CDIR COLLAPSE
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi           
             ztamr = sf(jp_tair)%fnow(ji,jj,1) - rtt           
@@ -952,7 +923,5 @@
       zdaycor  = 1.0 + 0.0013 * SIN( zdist ) + 0.0342 * COS( zdist )
 
-!CDIR NOVERRCHK
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             !  product of sine (cosine) of latitude and sine (cosine) of solar declination
@@ -979,11 +948,7 @@
       DO jl = 1, ijpl      !  loop over ice categories  !
          !                 !----------------------------! 
-!CDIR NOVERRCHK   
          DO jt = 1, jp24   
             zcoef = FLOAT( jt ) - 0.5
-!CDIR NOVERRCHK     
-!CDIR COLLAPSE
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   zlha = COS(  zlsrise(ji,jj) - zcoef * zdlha(ji,jj)  )                  ! local hour angle
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_mfs.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_mfs.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcblk_mfs.F90	(revision 6041)
@@ -251,7 +251,5 @@
          ! for basin budget and cooerence
          !--------------------------------------------------
-!CDIR COLLAPSE
-           emp (:,:) = evap(:,:) - sf(jp_prec)%fnow(:,:,1) * tmask(:,:,1)
-!CDIR COLLAPSE
+         emp(:,:) = evap(:,:) - sf(jp_prec)%fnow(:,:,1) * tmask(:,:,1)
 
          CALL iom_put( "qlw_oce",   qbw  )                 ! output downward longwave heat over the ocean
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbccpl.F90	(revision 6041)
@@ -931,7 +931,5 @@
          ! => need to be done only when otx1 was changed
          IF( llnewtx ) THEN
-!CDIR NOVERRCHK
             DO jj = 2, jpjm1
-!CDIR NOVERRCHK
                DO ji = fs_2, fs_jpim1   ! vect. opt.
                   zzx = frcv(jpr_otx1)%z3(ji-1,jj  ,1) + frcv(jpr_otx1)%z3(ji,jj,1)
@@ -961,7 +959,5 @@
          IF( llnewtau ) THEN 
             zcoef = 1. / ( zrhoa * zcdrag ) 
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi 
                   frcv(jpr_w10m)%z3(ji,jj,1) = SQRT( frcv(jpr_taum)%z3(ji,jj,1) * zcoef )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcflx.F90	(revision 6041)
@@ -131,5 +131,4 @@
          ELSE                  ;   qsr(:,:) =          sf(jp_qsr)%fnow(:,:,1)
          ENDIF
-!CDIR COLLAPSE
          DO jj = 1, jpj                                           ! set the ocean fluxes from read fields
             DO ji = 1, jpi
@@ -145,7 +144,5 @@
          !                                                        ! module of wind stress and wind speed at T-point
          zcoef = 1. / ( zrhoa * zcdrag )
-!CDIR NOVERRCHK
          DO jj = 2, jpjm1
-!CDIR NOVERRCHK
             DO ji = fs_2, fs_jpim1   ! vect. opt.
                ztx = utau(ji-1,jj  ) + utau(ji,jj) 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_cice.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_cice.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcice_cice.F90	(revision 6041)
@@ -67,5 +67,4 @@
    PRIVATE
 
-   !! * Routine accessibility
    PUBLIC cice_sbc_init   ! routine called by sbc_init
    PUBLIC cice_sbc_final  ! routine called by sbc_final
@@ -95,6 +94,9 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO-consortium (2015) 
    !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
 CONTAINS
 
@@ -154,9 +156,11 @@
    END SUBROUTINE sbc_ice_cice
 
-   SUBROUTINE cice_sbc_init (ksbc)
+
+   SUBROUTINE cice_sbc_init( ksbc )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE cice_sbc_init  ***
       !! ** Purpose: Initialise ice related fields for NEMO and coupling
       !!
+      !!---------------------------------------------------------------------
       INTEGER, INTENT( in  ) ::   ksbc                ! surface forcing type
       REAL(wp), DIMENSION(:,:), POINTER :: ztmp1, ztmp2
@@ -289,5 +293,5 @@
 
    
-   SUBROUTINE cice_sbc_in (kt, ksbc)
+   SUBROUTINE cice_sbc_in( kt, ksbc )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE cice_sbc_in  ***
@@ -296,5 +300,5 @@
       INTEGER, INTENT(in   ) ::   kt   ! ocean time step
       INTEGER, INTENT(in   ) ::   ksbc ! surface forcing type
-
+      !
       INTEGER  ::   ji, jj, jl                   ! dummy loop indices      
       REAL(wp), DIMENSION(:,:), POINTER :: ztmp, zpice
@@ -490,21 +494,19 @@
 ! x comp and y comp of sea surface slope (on F points)
 ! T point to F point
-      DO jj=1,jpjm1
-         DO ji=1,jpim1
-            ztmp(ji,jj)=0.5 * (  (zpice(ji+1,jj  )-zpice(ji,jj  ))/e1u(ji,jj  )   &
-                               + (zpice(ji+1,jj+1)-zpice(ji,jj+1))/e1u(ji,jj+1) ) & 
-                            *  fmask(ji,jj,1)
-         ENDDO
-      ENDDO
-      CALL nemo2cice(ztmp,ss_tltx,'F', -1. )
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            ztmp(ji,jj)=0.5 * (  (zpice(ji+1,jj  )-zpice(ji,jj  )) * r1_e1u(ji,jj  )    &
+               &               + (zpice(ji+1,jj+1)-zpice(ji,jj+1)) * r1_e1u(ji,jj+1)  ) * fmask(ji,jj,1)
+         END DO
+      END DO
+      CALL nemo2cice( ztmp,ss_tltx,'F', -1. )
 
 ! T point to F point
-      DO jj=1,jpjm1
-         DO ji=1,jpim1
-            ztmp(ji,jj)=0.5 * (  (zpice(ji  ,jj+1)-zpice(ji  ,jj))/e2v(ji  ,jj)   &
-                               + (zpice(ji+1,jj+1)-zpice(ji+1,jj))/e2v(ji+1,jj) ) &
-                            *  fmask(ji,jj,1)
-         ENDDO
-      ENDDO
+      DO jj = 1, jpjm1
+         DO ji = 1, jpim1
+            ztmp(ji,jj)=0.5 * (  (zpice(ji  ,jj+1)-zpice(ji  ,jj)) * r1_e2v(ji  ,jj)    &
+               &               + (zpice(ji+1,jj+1)-zpice(ji+1,jj)) * r1_e2v(ji+1,jj)  ) *  fmask(ji,jj,1)
+         END DO
+      END DO
       CALL nemo2cice(ztmp,ss_tlty,'F', -1. )
 
@@ -517,5 +519,5 @@
 
 
-   SUBROUTINE cice_sbc_out (kt,ksbc)
+   SUBROUTINE cice_sbc_out( kt, ksbc )
       !!---------------------------------------------------------------------
       !!                    ***  ROUTINE cice_sbc_out  ***
@@ -575,5 +577,5 @@
 ! Update taum with modulus of ice-ocean stress 
 ! strocnxT and strocnyT are not weighted by ice fraction in CICE so must be done here 
-taum(:,:)=(1.0-fr_i(:,:))*taum(:,:)+fr_i(:,:)*SQRT(ztmp1**2. + ztmp2**2.) 
+taum(:,:)=(1.0-fr_i(:,:))*taum(:,:)+fr_i(:,:)*SQRT(ztmp1*ztmp1 + ztmp2*ztmp2) 
 
 ! Freshwater fluxes 
@@ -888,5 +890,4 @@
 #endif
       !!---------------------------------------------------------------------
-
       CHARACTER(len=1), INTENT( in ) ::   &
           cd_type       ! nature of pn grid-point
@@ -908,4 +909,5 @@
 
       INTEGER  ::   ji, jj, jn                      ! dummy loop indices
+      !!---------------------------------------------------------------------
 
 !     A. Ensure all haloes are filled in NEMO field (pn)
@@ -1096,5 +1098,4 @@
    !!   Default option           Dummy module         NO CICE sea-ice model
    !!----------------------------------------------------------------------
-   !! $Id$
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90	(revision 6041)
@@ -18,19 +18,18 @@
    USE eosbn2          ! equation of state
    USE sbc_oce         ! surface boundary condition: ocean fields
+   USE zdfbfr          !
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O manager library
+   USE fldread         ! read input field at current time step
    USE lbclnk          !
-   USE iom             ! I/O manager library
-   USE in_out_manager  ! I/O manager
    USE wrk_nemo        ! Memory allocation
    USE timing          ! Timing
    USE lib_fortran     ! glob_sum
-   USE zdfbfr
-   USE fldread         ! read input field at current time step
-
-
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   sbc_isf, sbc_isf_div, sbc_isf_alloc  ! routine called in sbcmod and divcur
+   PUBLIC   sbc_isf, sbc_isf_div, sbc_isf_alloc  ! routine called in sbcmod and divhor
 
    ! public in order to be able to output then 
@@ -72,27 +71,29 @@
 #  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.0 , LOCEAN-IPSL (2008)
+   !! NEMO/OPA 3.7 , LOCEAN-IPSL (2015)
    !! $Id$
    !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
  
-  SUBROUTINE sbc_isf(kt)
-    INTEGER, INTENT(in)          ::   kt         ! ocean time step
-    INTEGER                      ::   ji, jj, jk, ijkmin, inum, ierror
-    INTEGER                      ::   ikt, ikb   ! top and bottom level of the isf boundary layer
-    REAL(wp)                     ::   rmin
-    REAL(wp)                     ::   zhk
-    REAL(wp)                     ::   zt_frz, zpress
-    CHARACTER(len=256)           ::   cfisf , cvarzisf, cvarhisf   ! name for isf file
-    CHARACTER(LEN=256)           :: cnameis                     ! name of iceshelf file
-    CHARACTER (LEN=32)           :: cvarLeff                    ! variable name for efficient Length scale
-    INTEGER           ::   ios           ! Local integer output status for namelist read
-      !
+   SUBROUTINE sbc_isf(kt)
       !!---------------------------------------------------------------------
+      !!                     ***  ROUTINE sbc_isf  ***
+      !!---------------------------------------------------------------------
+      INTEGER, INTENT(in)          ::   kt         ! ocean time step
+      !
+      INTEGER                      ::   ji, jj, jk, ijkmin, inum, ierror
+      INTEGER                      ::   ikt, ikb   ! top and bottom level of the isf boundary layer
+      REAL(wp)                     ::   rmin
+      REAL(wp)                     ::   zhk
+      REAL(wp)                     ::   zt_frz, zpress
+      CHARACTER(len=256)           ::   cfisf , cvarzisf, cvarhisf   ! name for isf file
+      CHARACTER(LEN=256)           :: cnameis                     ! name of iceshelf file
+      CHARACTER (LEN=32)           :: cvarLeff                    ! variable name for efficient Length scale
+      INTEGER           ::   ios           ! Local integer output status for namelist read
+      !!
       NAMELIST/namsbc_isf/ nn_isfblk, rn_hisf_tbl, ln_divisf, ln_conserve, rn_gammat0, rn_gammas0, nn_gammablk, &
-                         & sn_fwfisf, sn_qisf, sn_rnfisf, sn_depmax_isf, sn_depmin_isf, sn_Leff_isf
-      !
+         &                 sn_fwfisf, sn_qisf, sn_rnfisf, sn_depmax_isf, sn_depmin_isf, sn_Leff_isf
+      !!---------------------------------------------------------------------
       !
       !                                         ! ====================== !
@@ -107,5 +108,4 @@
 902      IF( ios /= 0 ) CALL ctl_nam ( ios , 'namsbc_isf in configuration namelist', lwp )
          IF(lwm) WRITE ( numond, namsbc_isf )
-
 
          IF ( lwp ) WRITE(numout,*)
@@ -210,5 +210,5 @@
             END DO
          END DO
-         
+         !
       END IF
 
@@ -298,6 +298,7 @@
          ! 
       END IF
-  
+      !  
   END SUBROUTINE sbc_isf
+
 
   INTEGER FUNCTION sbc_isf_alloc()
@@ -320,26 +321,26 @@
   END FUNCTION
 
-  SUBROUTINE sbc_isf_bg03(kt)
-   !!==========================================================================
-   !!                 *** SUBROUTINE sbcisf_bg03  ***
-   !! add net heat and fresh water flux from ice shelf melting
-   !! into the adjacent ocean using the parameterisation by
-   !! Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
-   !!     interaction for climate models", Ocean Modelling 5(2003) 157-170.
-   !!  (hereafter BG)
-   !!==========================================================================
-   !!----------------------------------------------------------------------
-   !!   sbc_isf_bg03      : routine called from sbcmod
-   !!----------------------------------------------------------------------
-   !!
-   !! ** Purpose   :   Add heat and fresh water fluxes due to ice shelf melting
-   !! ** Reference :   Beckmann et Goosse, 2003, Ocean Modelling
-   !!
-   !! History :
-   !!      !  06-02  (C. Wang) Original code
-   !!----------------------------------------------------------------------
-
-    INTEGER, INTENT ( in ) :: kt
-
+
+   SUBROUTINE sbc_isf_bg03(kt)
+      !!==========================================================================
+      !!                 *** SUBROUTINE sbcisf_bg03  ***
+      !! add net heat and fresh water flux from ice shelf melting
+      !! into the adjacent ocean using the parameterisation by
+      !! Beckmann and Goosse (2003), "A parameterization of ice shelf-ocean
+      !!     interaction for climate models", Ocean Modelling 5(2003) 157-170.
+      !!  (hereafter BG)
+      !!==========================================================================
+      !!----------------------------------------------------------------------
+      !!   sbc_isf_bg03      : routine called from sbcmod
+      !!----------------------------------------------------------------------
+      !!
+      !! ** Purpose   :   Add heat and fresh water fluxes due to ice shelf melting
+      !! ** Reference :   Beckmann et Goosse, 2003, Ocean Modelling
+      !!
+      !! History :
+      !!      !  06-02  (C. Wang) Original code
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT ( in ) :: kt
+      !
     INTEGER :: ji, jj, jk, jish  !temporary integer
     INTEGER :: ijkmin
@@ -385,9 +386,11 @@
              qisf(ji,jj) = 0._wp ; fwfisf(ji,jj) = 0._wp
           END IF
-       ENDDO
-    ENDDO
+       END DO
+    END DO
     !
     IF( nn_timing == 1 )  CALL timing_stop('sbc_isf_bg03')
+      !
   END SUBROUTINE sbc_isf_bg03
+
 
    SUBROUTINE sbc_isf_cav( kt )
@@ -438,5 +441,4 @@
       !
       !
-!CDIR COLLAPSE
       DO jj = 1, jpj
          DO ji = 1, jpi
@@ -492,5 +494,4 @@
 
 ! More complicated 3 equation thermodynamics as in MITgcm
-!CDIR COLLAPSE
          DO jj = 2, jpj
             DO ji = 2, jpi
@@ -561,6 +562,7 @@
       !
       IF( nn_timing == 1 )  CALL timing_stop('sbc_isf_cav')
-
+      !
    END SUBROUTINE sbc_isf_cav
+
 
    SUBROUTINE sbc_isf_gammats(gt, gs, zqhisf, zqwisf, ji, jj, lit )
@@ -689,6 +691,7 @@
                END IF
       END IF
-
+      !
    END SUBROUTINE
+
 
    SUBROUTINE sbc_isf_tbl( varin, varout, cptin )
@@ -752,5 +755,5 @@
       IF (cptin == 'T') CALL lbc_lnk(varout,'T',1.)
       IF (cptin == 'U' .OR. cptin == 'V') CALL lbc_lnk(varout,'T',-1.)
-
+      !
    END SUBROUTINE sbc_isf_tbl
       
@@ -819,5 +822,6 @@
       !
    END SUBROUTINE sbc_isf_div
-                        
+
+
    FUNCTION tinsitu( ptem, psal, ppress ) RESULT( pti )
       !!----------------------------------------------------------------------
@@ -870,5 +874,6 @@
       !
    END FUNCTION tinsitu
-   !
+
+
    FUNCTION fsatg( pfps, pfpt, pfphp )
       !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcmod.F90	(revision 6041)
@@ -28,5 +28,4 @@
    USE sbcdcy           ! surface boundary condition: diurnal cycle
    USE sbcssm           ! surface boundary condition: sea-surface mean variables
-   USE sbcapr           ! surface boundary condition: atmospheric pressure
    USE sbcana           ! surface boundary condition: analytical formulation
    USE sbcflx           ! surface boundary condition: flux formulation
@@ -133,5 +132,5 @@
          WRITE(numout,*) '              forced-coupled mixed formulation           ln_mixcpl   = ', ln_mixcpl
          WRITE(numout,*) '              OASIS coupling (with atm or sas)           lk_oasis    = ', lk_oasis
-         WRITE(numout,*) '              components of your executable              nn_components = ', nn_components
+         WRITE(numout,*) '              components of your executable            nn_components = ', nn_components
          WRITE(numout,*) '              Multicategory heat flux formulation (LIM3) nn_limflx   = ', nn_limflx
          WRITE(numout,*) '           Misc. options of sbc : '
@@ -176,9 +175,9 @@
 
       !                              ! allocate sbc arrays
-      IF( sbc_oce_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_oce arrays' )
+      IF( sbc_oce_alloc() /= 0 )   CALL ctl_stop( 'sbc_init : unable to allocate sbc_oce arrays' )
 
       !                          ! Checks:
       IF( nn_isf .EQ. 0 ) THEN                      ! variable initialisation if no ice shelf 
-         IF( sbc_isf_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_init : unable to allocate sbc_isf arrays' )
+         IF( sbc_isf_alloc() /= 0 )   CALL ctl_stop( 'sbc_init : unable to allocate sbc_isf arrays' )
          fwfisf  (:,:)   = 0.0_wp ; fwfisf_b  (:,:)   = 0.0_wp
          risf_tsc(:,:,:) = 0.0_wp ; risf_tsc_b(:,:,:) = 0.0_wp
@@ -224,7 +223,7 @@
          ENDIF
       ELSE
-      IF ( ln_cdgw .OR. ln_sdw  )                                         & 
-         &   CALL ctl_stop('Not Activated Wave Module (ln_wave=F) but     &
-         & asked coupling with drag coefficient (ln_cdgw =T) or Stokes drift (ln_sdw=T) ')
+      IF ( ln_cdgw .OR. ln_sdw  )                                                           & 
+         &   CALL ctl_stop( 'Not Activated Wave Module (ln_wave=F) but asked coupling ',    &
+         &                  'with drag coefficient (ln_cdgw =T) or Stokes drift (ln_sdw=T) ')
       ENDIF 
       !                          ! Choice of the Surface Boudary Condition (set nsbc)
@@ -241,16 +240,9 @@
       IF( nn_components == jp_iam_opa )   &
          &                  THEN   ;   nsbc = jp_none    ; icpt = icpt + 1   ;   ENDIF       ! opa coupling via SAS module
-      IF( lk_esopa        )            nsbc = jp_esopa                                       ! esopa test, ALL formulations
-      !
-      IF( icpt /= 1 .AND. .NOT.lk_esopa ) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '           E R R O R in setting the sbc, one and only one namelist/CPP key option '
-         WRITE(numout,*) '                     must be choosen. You choose ', icpt, ' option(s)'
-         WRITE(numout,*) '                     We stop'
-         nstop = nstop + 1
-      ENDIF
+      !
+      IF( icpt /= 1 )    CALL ctl_stop( 'sbc_init: choose ONE and only ONE sbc option' )
+      !
       IF(lwp) THEN
          WRITE(numout,*)
-         IF( nsbc == jp_esopa   )   WRITE(numout,*) '              ESOPA test All surface boundary conditions'
          IF( nsbc == jp_gyre    )   WRITE(numout,*) '              GYRE analytical formulation'
          IF( nsbc == jp_ana     )   WRITE(numout,*) '              analytical formulation'
@@ -267,10 +259,9 @@
       !
       IF( lk_oasis )   CALL sbc_cpl_init (nn_ice)   ! OASIS initialisation. must be done before: (1) first time step
-      !                                                     !                                            (2) the use of nn_fsbc
+      !                                             !                                            (2) the use of nn_fsbc
 
 !     nn_fsbc initialization if OPA-SAS coupling via OASIS
 !     sas model time step has to be declared in OASIS (mandatory) -> nn_fsbc has to be modified accordingly
       IF ( nn_components /= jp_iam_nemo ) THEN
-
          IF ( nn_components == jp_iam_opa ) nn_fsbc = cpl_freq('O_SFLX') / NINT(rdt)
          IF ( nn_components == jp_iam_sas ) nn_fsbc = cpl_freq('I_SFLX') / NINT(rdt)
@@ -344,9 +335,4 @@
       !                                            !        forcing field computation         !
       !                                            ! ---------------------------------------- !
-      !
-      IF ( .NOT. lk_bdy ) then
-         IF( ln_apr_dyn ) CALL sbc_apr( kt )                ! atmospheric pressure provided at kt+0.5*nn_fsbc
-      ENDIF
-                                                         ! (caution called before sbc_ssm)
       !
       IF( nn_components /= jp_iam_sas )   CALL sbc_ssm( kt )   ! ocean sea surface variables (sst_m, sss_m, ssu_m, ssv_m)
@@ -373,11 +359,4 @@
          IF( nn_components == jp_iam_opa ) &
                              CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   ! OPA-SAS coupling: OPA receiving fields from SAS
-      CASE( jp_esopa )                                
-                             CALL sbc_ana     ( kt )                    ! ESOPA, test ALL the formulations
-                             CALL sbc_gyre    ( kt )                    !
-                             CALL sbc_flx     ( kt )                    !
-                             CALL sbc_blk_clio( kt )                    !
-                             CALL sbc_blk_core( kt )                    !
-                             CALL sbc_cpl_rcv ( kt, nn_fsbc, nn_ice )   !
       END SELECT
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcrnf.F90	(revision 6041)
@@ -31,8 +31,9 @@
    PRIVATE
 
-   PUBLIC   sbc_rnf       ! routine call in sbcmod module
-   PUBLIC   sbc_rnf_div   ! routine called in divcurl module
-   PUBLIC   sbc_rnf_alloc ! routine call in sbcmod module
-   PUBLIC   sbc_rnf_init  ! (PUBLIC for TAM)
+   PUBLIC   sbc_rnf       ! routine called in sbcmod module
+   PUBLIC   sbc_rnf_div   ! routine called in divhor module
+   PUBLIC   sbc_rnf_alloc ! routine called in sbcmod module
+   PUBLIC   sbc_rnf_init  ! routine called in sbcmod module
+   
    !                                                     !!* namsbc_rnf namelist *
    CHARACTER(len=100)         ::   cn_dir          !: Root directory for location of rnf files
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssr.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssr.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcssr.F90	(revision 6041)
@@ -107,5 +107,4 @@
             IF( nn_sssr == 1 ) THEN                                   !* Salinity damping term (salt flux only (sfx))
                zsrp = rn_deds / rday                                  ! from [mm/day] to [kg/m2/s]
-!CDIR COLLAPSE
                DO jj = 1, jpj
                   DO ji = 1, jpi
@@ -121,5 +120,4 @@
                zsrp = rn_deds / rday                                  ! from [mm/day] to [kg/m2/s]
                zerp_bnd = rn_sssr_bnd / rday                          !       -              -    
-!CDIR COLLAPSE
                DO jj = 1, jpj
                   DO ji = 1, jpi                            
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbctide.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbctide.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbctide.F90	(revision 6041)
@@ -10,5 +10,4 @@
    USE phycst
    USE daymod
-   USE dynspg_oce
    USE tideini
    !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcwave.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcwave.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/sbcwave.F90	(revision 6041)
@@ -4,19 +4,21 @@
    !! Wave module 
    !!======================================================================
-   !! History :  3.3.1  !   2011-09  (Adani M)  Original code: Drag Coefficient 
-   !!         :  3.4    !   2012-10  (Adani M)                 Stokes Drift 
+   !! History :  3.3  !   2011-09  (Adani M)  Original code: Drag Coefficient 
+   !!         :  3.4  !   2012-10  (Adani M)                 Stokes Drift 
    !!----------------------------------------------------------------------
-   USE iom             ! I/O manager library
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! distribued memory computing library
+
+   !!----------------------------------------------------------------------
+   !!   sbc_wave      : read drag coefficient from wave model in netcdf files 
+   !!----------------------------------------------------------------------
+   USE oce            ! 
+   USE sbc_oce	       ! Surface boundary condition: ocean fields
+   USE bdy_oce        !
+   USE domvvl         !
+   !
+   USE iom            ! I/O manager library
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! distribued memory computing library
    USE fldread	       ! read input fields
-   USE oce
-   USE sbc_oce	       ! Surface boundary condition: ocean fields
-   USE domvvl
-
-   
-   !!----------------------------------------------------------------------
-   !!   sbc_wave       : read drag coefficient from wave model in netcdf files 
-   !!----------------------------------------------------------------------
+   USE wrk_nemo       !
 
    IMPLICIT NONE
@@ -25,18 +27,21 @@
    PUBLIC   sbc_wave    ! routine called in sbc_blk_core or sbc_blk_mfs
    
-   INTEGER , PARAMETER ::   jpfld  = 3           ! maximum number of files to read for srokes drift
-   INTEGER , PARAMETER ::   jp_usd = 1           ! index of stokes drift  (i-component) (m/s)    at T-point
-   INTEGER , PARAMETER ::   jp_vsd = 2           ! index of stokes drift  (j-component) (m/s)    at T-point
-   INTEGER , PARAMETER ::   jp_wn  = 3           ! index of wave number                 (1/m)    at T-point
+   INTEGER , PARAMETER ::   jpfld  = 3   ! maximum number of files to read for srokes drift
+   INTEGER , PARAMETER ::   jp_usd = 1   ! index of stokes drift  (i-component) (m/s)    at T-point
+   INTEGER , PARAMETER ::   jp_vsd = 2   ! index of stokes drift  (j-component) (m/s)    at T-point
+   INTEGER , PARAMETER ::   jp_wn  = 3   ! index of wave number                 (1/m)    at T-point
+
    TYPE(FLD), ALLOCATABLE, DIMENSION(:)  :: sf_cd	  ! structure of input fields (file informations, fields read) Drag Coefficient
    TYPE(FLD), ALLOCATABLE, DIMENSION(:)  :: sf_sd	  ! structure of input fields (file informations, fields read) Stokes Drift
-   REAL(wp),PUBLIC,ALLOCATABLE,DIMENSION (:,:)       :: cdn_wave 
-   REAL(wp),ALLOCATABLE,DIMENSION (:,:)              :: usd2d,vsd2d,uwavenum,vwavenum 
-   REAL(wp),PUBLIC,ALLOCATABLE,DIMENSION (:,:,:)     :: usd3d,vsd3d,wsd3d 
+
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION (:,:)   :: cdn_wave 
+   REAL(wp), PUBLIC, ALLOCATABLE, DIMENSION (:,:,:) :: usd3d, vsd3d, wsd3d 
+   REAL(wp),         ALLOCATABLE, DIMENSION (:,:)   :: usd2d, vsd2d, uwavenum, vwavenum 
 
    !! * Substitutions
 #  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011) 
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014) 
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -56,27 +61,17 @@
       !!              - Compute 3d stokes drift using monochromatic
       !! ** action  :   
-      !!               
       !!---------------------------------------------------------------------
-      USE oce,  ONLY : un,vn,hdivn,rotn
-      USE divcur
-      USE wrk_nemo
-#if defined key_bdy
-      USE bdy_oce, ONLY : bdytmask
-#endif
-      INTEGER, INTENT( in  ) ::  kt       ! ocean time step
-      INTEGER                ::  ierror   ! return error code
-      INTEGER                ::  ifpr, jj,ji,jk 
+      INTEGER, INTENT( in  ) ::   kt       ! ocean time step
+      !
+      INTEGER                ::   ierror   ! return error code
+      INTEGER                ::   ifpr, jj,ji,jk 
       INTEGER                ::   ios     ! Local integer output status for namelist read
-      REAL(wp),DIMENSION(:,:,:),POINTER             ::  udummy,vdummy,hdivdummy,rotdummy
-      REAL                                          ::  z2dt,z1_2dt
       TYPE(FLD_N), DIMENSION(jpfld) ::   slf_i     ! array of namelist informations on the fields to read
       CHARACTER(len=100)     ::  cn_dir                          ! Root directory for location of drag coefficient files
       TYPE(FLD_N)            ::  sn_cdg, sn_usd, sn_vsd, sn_wn   ! informations about the fields to be read
-      !!---------------------------------------------------------------------
+      REAL(wp), DIMENSION(:,:,:), POINTER ::   zusd_t, zvsd_t, ze3hdiv   ! 3D workspace
+      !!
       NAMELIST/namsbc_wave/  sn_cdg, cn_dir, sn_usd, sn_vsd, sn_wn
       !!---------------------------------------------------------------------
-
-      !!----------------------------------------------------------------------
-      !
       !
       !                                         ! -------------------- !
@@ -92,5 +87,4 @@
          IF(lwm) WRITE ( numond, namsbc_wave )
          !
-
          IF ( ln_cdgw ) THEN
             ALLOCATE( sf_cd(1), STAT=ierror )           !* allocate and fill sf_wave with sn_cdg
@@ -102,5 +96,5 @@
             ALLOCATE( cdn_wave(jpi,jpj) )
             cdn_wave(:,:) = 0.0
-        ENDIF
+         ENDIF
          IF ( ln_sdw ) THEN
             slf_i(jp_usd) = sn_usd ; slf_i(jp_vsd) = sn_vsd; slf_i(jp_wn) = sn_wn
@@ -113,80 +107,72 @@
             END DO
             CALL fld_fill( sf_sd, slf_i, cn_dir, 'sbc_wave', 'Wave module ', 'namsbc_wave' )
-            ALLOCATE( usd2d(jpi,jpj),vsd2d(jpi,jpj),uwavenum(jpi,jpj),vwavenum(jpi,jpj) )
+            ALLOCATE( usd2d(jpi,jpj) , vsd2d(jpi,jpj) , uwavenum(jpi,jpj) , vwavenum(jpi,jpj) )
             ALLOCATE( usd3d(jpi,jpj,jpk),vsd3d(jpi,jpj,jpk),wsd3d(jpi,jpj,jpk) )
-            usd2d(:,:) = 0.0 ;  vsd2d(:,:) = 0.0 ; uwavenum(:,:) = 0.0 ; vwavenum(:,:) = 0.0
-            usd3d(:,:,:) = 0.0 ;vsd3d(:,:,:) = 0.0 ; wsd3d(:,:,:) = 0.0
+            usd3d(:,:,:) = 0._wp   ;   usd2d(:,:) = 0._wp   ;    uwavenum(:,:) = 0._wp
+            vsd3d(:,:,:) = 0._wp   ;   vsd2d(:,:) = 0._wp   ;    vwavenum(:,:) = 0._wp
+            wsd3d(:,:,:) = 0._wp
          ENDIF
       ENDIF
+      !
+      IF ( ln_cdgw ) THEN              !==  Neutral drag coefficient  ==!
+         CALL fld_read( kt, nn_fsbc, sf_cd )      ! read from external forcing
+         cdn_wave(:,:) = sf_cd(1)%fnow(:,:,1)
+      ENDIF
+      !
+      IF ( ln_sdw )  THEN              !==  Computation of the 3d Stokes Drift  ==!
+         !
+         CALL fld_read( kt, nn_fsbc, sf_sd )    !* read drag coefficient from external forcing
          !
          !
-      IF ( ln_cdgw ) THEN
-         CALL fld_read( kt, nn_fsbc, sf_cd )      !* read drag coefficient from external forcing
-         cdn_wave(:,:) = sf_cd(1)%fnow(:,:,1)
-      ENDIF
-      IF ( ln_sdw )  THEN
-          CALL fld_read( kt, nn_fsbc, sf_sd )      !* read drag coefficient from external forcing
-
-         ! Interpolate wavenumber, stokes drift into the grid_V and grid_V
-         !-------------------------------------------------
-
-         DO jj = 1, jpjm1
-            DO ji = 1, jpim1
-               uwavenum(ji,jj)=0.5 * ( 2. - umask(ji,jj,1) ) * ( sf_sd(3)%fnow(ji,jj,1) * tmask(ji,jj,1) &
-               &                                + sf_sd(3)%fnow(ji+1,jj,1) * tmask(ji+1,jj,1) )
-
-               vwavenum(ji,jj)=0.5 * ( 2. - vmask(ji,jj,1) ) * ( sf_sd(3)%fnow(ji,jj,1) * tmask(ji,jj,1) &
-               &                                + sf_sd(3)%fnow(ji,jj+1,1) * tmask(ji,jj+1,1) )
-
-               usd2d(ji,jj) = 0.5 * ( 2. - umask(ji,jj,1) ) * ( sf_sd(1)%fnow(ji,jj,1) * tmask(ji,jj,1) &
-               &                                + sf_sd(1)%fnow(ji+1,jj,1) * tmask(ji+1,jj,1) )
-
-               vsd2d(ji,jj) = 0.5 * ( 2. - vmask(ji,jj,1) ) * ( sf_sd(2)%fnow(ji,jj,1) * tmask(ji,jj,1) &
-               &                                + sf_sd(2)%fnow(ji,jj+1,1) * tmask(ji,jj+1,1) )
+         CALL wrk_alloc( jpi,jpj,jpk,   zusd_t, zvsd_t, ze3hdiv )
+         !                                      !* distribute it on the vertical
+         DO jk = 1, jpkm1
+            zusd_t(:,:,jk) = sf_sd(jp_usd)%fnow(:,:,1) * EXP( -2._wp * sf_sd(jp_wn)%fnow(:,:,1) * fsdept_n(:,:,jk) )
+            zvsd_t(:,:,jk) = sf_sd(jp_vsd)%fnow(:,:,1) * EXP( -2._wp * sf_sd(jp_wn)%fnow(:,:,1) * fsdept_n(:,:,jk) )
+         END DO
+         !                                      !* interpolate the stokes drift from t-point to u- and v-points
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               DO ji = 1, jpim1
+                   usd3d(ji,jj,jk) = 0.5_wp * ( zusd_t(ji  ,jj,jk) + zusd_t(ji+1,jj,jk) ) * umask(ji,jj,jk)
+                   vsd3d(ji,jj,jk) = 0.5_wp * ( zvsd_t(ji  ,jj,jk) + zvsd_t(ji,jj+1,jk) ) * vmask(ji,jj,jk)
+               END DO
             END DO
          END DO
-
-          !Computation of the 3d Stokes Drift
-          DO jk = 1, jpk
-             DO jj = 1, jpj-1
-                DO ji = 1, jpi-1
-                   usd3d(ji,jj,jk) = usd2d(ji,jj)*exp(2.0*uwavenum(ji,jj)*(-MIN( gdept_0(ji,jj,jk) , gdept_0(ji+1,jj  ,jk))))
-                   vsd3d(ji,jj,jk) = vsd2d(ji,jj)*exp(2.0*vwavenum(ji,jj)*(-MIN( gdept_0(ji,jj,jk) , gdept_0(ji  ,jj+1,jk))))
-                END DO
-             END DO
-             usd3d(jpi,:,jk) = usd2d(jpi,:)*exp( 2.0*uwavenum(jpi,:)*(-gdept_0(jpi,:,jk)) )
-             vsd3d(:,jpj,jk) = vsd2d(:,jpj)*exp( 2.0*vwavenum(:,jpj)*(-gdept_0(:,jpj,jk)) )
-          END DO
-
-          CALL wrk_alloc( jpi,jpj,jpk,udummy,vdummy,hdivdummy,rotdummy)
-          
-          udummy(:,:,:)=un(:,:,:)
-          vdummy(:,:,:)=vn(:,:,:)
-          hdivdummy(:,:,:)=hdivn(:,:,:)
-          rotdummy(:,:,:)=rotn(:,:,:)
-          un(:,:,:)=usd3d(:,:,:)
-          vn(:,:,:)=vsd3d(:,:,:)
-          CALL div_cur(kt)
-      !                                           !------------------------------!
-      !                                           !     Now Vertical Velocity    !
-      !                                           !------------------------------!
-          z2dt = 2._wp * rdt                              ! set time step size (Euler/Leapfrog)
-
-          z1_2dt = 1.e0 / z2dt
-          DO jk = jpkm1, 1, -1                             ! integrate from the bottom the hor. divergence
-             ! - ML - need 3 lines here because replacement of fse3t by its expression yields too long lines otherwise
-             wsd3d(:,:,jk) = wsd3d(:,:,jk+1) -   fse3t_n(:,:,jk) * hdivn(:,:,jk)        &
-                &                      - ( fse3t_a(:,:,jk) - fse3t_b(:,:,jk) )    &
-                &                         * tmask(:,:,jk) * z1_2dt
+         CALL lbc_lnk( usd3d(:,:,:), 'U', -1. )
+         CALL lbc_lnk( vsd3d(:,:,:), 'V', -1. )
+         !
+         DO jk = 1, jpkm1                       !* e3t * Horizontal divergence  ==!
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ze3hdiv(ji,jj,jk) = (  e2u(ji  ,jj) * fse3u_n(ji  ,jj,jk) * usd3d(ji  ,jj,jk)     &
+                     &                 - e2u(ji-1,jj) * fse3u_n(ji-1,jj,jk) * usd3d(ji-1,jj,jk)     &
+                     &                 + e1v(ji,jj  ) * fse3v_n(ji,jj  ,jk) * vsd3d(ji,jj  ,jk)     &
+                     &                 - e1v(ji,jj-1) * fse3v_n(ji,jj-1,jk) * vsd3d(ji,jj-1,jk)   ) * r1_e1e2t(ji,jj)
+               END DO  
+            END DO  
+            IF( .NOT. AGRIF_Root() ) THEN
+               IF( nbondi ==  1 .OR. nbondi == 2 )   ze3hdiv(nlci-1,   :  ,jk) = 0._wp      ! east
+               IF( nbondi == -1 .OR. nbondi == 2 )   ze3hdiv(  2   ,   :  ,jk) = 0._wp      ! west
+               IF( nbondj ==  1 .OR. nbondj == 2 )   ze3hdiv(  :   ,nlcj-1,jk) = 0._wp      ! north
+               IF( nbondj == -1 .OR. nbondj == 2 )   ze3hdiv(  :   ,  2   ,jk) = 0._wp      ! south
+            ENDIF
+         END DO
+         CALL lbc_lnk( ze3hdiv, 'T', 1. ) 
+         !
+         DO jk = jpkm1, 1, -1                   !* integrate from the bottom the e3t * hor. divergence
+            wsd3d(:,:,jk) = wsd3d(:,:,jk+1) - ze3hdiv(:,:,jk)
+         END DO
 #if defined key_bdy
-             wsd3d(:,:,jk) = wsd3d(:,:,jk) * bdytmask(:,:)
+         IF( lk_bdy ) THEN
+            DO jk = 1, jpkm1
+               wsd3d(:,:,jk) = wsd3d(:,:,jk) * bdytmask(:,:)
+            END DO
+         ENDIF
 #endif
-          END DO
-          hdivn(:,:,:)=hdivdummy(:,:,:)
-          rotn(:,:,:)=rotdummy(:,:,:)
-          vn(:,:,:)=vdummy(:,:,:)
-          un(:,:,:)=udummy(:,:,:)
-          CALL wrk_dealloc( jpi,jpj,jpk,udummy,vdummy,hdivdummy,rotdummy)
+         CALL wrk_dealloc( jpi,jpj,jpk,   zusd_t, zvsd_t, ze3hdiv )
+         ! 
       ENDIF
+      !
    END SUBROUTINE sbc_wave
       
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/tideini.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/tideini.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/tideini.F90	(revision 6041)
@@ -10,5 +10,4 @@
    USE phycst
    USE daymod
-   USE dynspg_oce
    USE tide_mod
    !
@@ -96,5 +95,4 @@
           &   CALL ctl_stop('rdttideramp must be positive')
        !
-       IF( .NOT. lk_dynspg_ts )   CALL ctl_warn( 'sbc_tide : use of time splitting is recommended' )
        !
        ALLOCATE( ntide(nb_harmo) )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/updtide.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/updtide.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/SBC/updtide.F90	(revision 6041)
@@ -31,5 +31,5 @@
 CONTAINS
 
-   SUBROUTINE upd_tide( kt, kit, kbaro, koffset )
+   SUBROUTINE upd_tide( kt, kit, time_offset )
       !!----------------------------------------------------------------------
       !!                 ***  ROUTINE upd_tide  ***
@@ -42,8 +42,8 @@
       !!----------------------------------------------------------------------      
       INTEGER, INTENT(in)           ::   kt      ! ocean time-step index
-      INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T only)
-      INTEGER, INTENT(in), OPTIONAL ::   kbaro   ! number of sub-time-step           (lk_dynspg_ts=T only)
-      INTEGER, INTENT(in), OPTIONAL ::   koffset ! time offset in number 
-                                                 ! of sub-time-steps                 (lk_dynspg_ts=T only)
+      INTEGER, INTENT(in), OPTIONAL ::   kit     ! external mode sub-time-step index (lk_dynspg_ts=T)
+      INTEGER, INTENT(in), OPTIONAL ::   time_offset ! time offset in number 
+                                                     ! of internal steps             (lk_dynspg_ts=F)
+                                                     ! of external steps             (lk_dynspg_ts=T)
       !
       INTEGER  ::   joffset      ! local integer
@@ -57,8 +57,8 @@
       !
       joffset = 0
-      IF( PRESENT( koffset ) )   joffset = koffset
+      IF( PRESENT( time_offset ) )   joffset = time_offset
       !
-      IF( PRESENT( kit ) .AND. PRESENT( kbaro ) )   THEN
-         zt = zt + ( kit + 0.5_wp * ( joffset - 1 ) ) * rdt / REAL( kbaro, wp )
+      IF( PRESENT( kit ) )   THEN
+         zt = zt + ( kit +  joffset - 1 ) * rdt / REAL( nn_baro, wp )
       ELSE
          zt = zt + joffset * rdt
@@ -74,5 +74,5 @@
       IF( ln_tide_ramp ) THEN         ! linear increase if asked
          zt = ( kt - nit000 ) * rdt
-         IF( PRESENT( kit ) .AND. PRESENT( kbaro ) )   zt = zt + kit * rdt / REAL( kbaro, wp )
+         IF( PRESENT( kit ) )   zt = zt + ( kit + joffset -1) * rdt / REAL( nn_baro, wp )
          zramp = MIN(  MAX( zt / (rdttideramp*rday) , 0._wp ) , 1._wp  )
          pot_astro(:,:) = zramp * pot_astro(:,:)
@@ -86,9 +86,8 @@
   !!----------------------------------------------------------------------
 CONTAINS
-  SUBROUTINE upd_tide( kt, kit, kbaro, koffset )          ! Empty routine
+  SUBROUTINE upd_tide( kt, kit, time_offset )  ! Empty routine
     INTEGER, INTENT(in)           ::   kt      !  integer  arg, dummy routine
     INTEGER, INTENT(in), OPTIONAL ::   kit     !  optional arg, dummy routine
-    INTEGER, INTENT(in), OPTIONAL ::   kbaro   !  optional arg, dummy routine
-    INTEGER, INTENT(in), OPTIONAL ::   koffset !  optional arg, dummy routine
+    INTEGER, INTENT(in), OPTIONAL ::   time_offset !  optional arg, dummy routine
     WRITE(*,*) 'upd_tide: You should not have seen this print! error?', kt
   END SUBROUTINE upd_tide
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv.F90	(revision 6041)
@@ -6,34 +6,34 @@
    !! History :  2.0  !  2005-11  (G. Madec)  Original code
    !!            3.3  !  2010-09  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
-   !!            4.0  !  2011-06  (G. Madec)  Addition of Mixed Layer Eddy parameterisation
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_adv      : compute ocean tracer advection trend
-   !!   tra_adv_ctl  : control the different options of advection scheme
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and active tracers
-   USE dom_oce         ! ocean space and time domain
-   USE domvvl          ! variable vertical scale factors
-   USE traadv_cen2     ! 2nd order centered scheme (tra_adv_cen2   routine)
-   USE traadv_tvd      ! TVD      scheme           (tra_adv_tvd    routine)
-   USE traadv_muscl    ! MUSCL    scheme           (tra_adv_muscl  routine)
-   USE traadv_muscl2   ! MUSCL2   scheme           (tra_adv_muscl2 routine)
-   USE traadv_ubs      ! UBS      scheme           (tra_adv_ubs    routine)
-   USE traadv_qck      ! QUICKEST scheme           (tra_adv_qck    routine)
-   USE traadv_eiv      ! eddy induced velocity     (tra_adv_eiv    routine)
-   USE traadv_mle      ! ML eddy induced velocity  (tra_adv_mle    routine)
-   USE cla             ! cross land advection      (cla_traadv     routine)
-   USE ldftra_oce      ! lateral diffusion coefficient on tracers
+   !!            3.6  !  2011-06  (G. Madec)  Addition of Mixed Layer Eddy parameterisation
+   !!            3.7  !  2014-05  (G. Madec)  Add 2nd/4th order cases for CEN and FCT schemes 
+   !!             -   !  2014-12  (G. Madec) suppression of cross land advection option
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv       : compute ocean tracer advection trend
+   !!   tra_adv_ctl   : control the different options of advection scheme
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers
+   USE dom_oce        ! ocean space and time domain
+   USE domvvl         ! variable vertical scale factors
+   USE traadv_cen     ! centered scheme           (tra_adv_cen  routine)
+   USE traadv_fct     ! FCT      scheme           (tra_adv_fct  routine)
+   USE traadv_mus     ! MUSCL    scheme           (tra_adv_mus  routine)
+   USE traadv_ubs     ! UBS      scheme           (tra_adv_ubs  routine)
+   USE traadv_qck     ! QUICKEST scheme           (tra_adv_qck  routine)
+   USE traadv_mle     ! ML eddy induced velocity  (tra_adv_mle  routine)
+   USE ldftra         ! lateral diffusion: eddy diffusivity & EIV coeff.
+   USE ldfslp         ! Lateral diffusion: slopes of neutral surfaces
+   USE c1d            ! 1D vertical configuration
    !
-   USE in_out_manager  ! I/O manager
-   USE iom             ! I/O module
-   USE prtctl          ! Print control
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-   USE sbc_oce
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O module
+   USE prtctl         ! Print control
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
    USE diaptr          ! Poleward heat transport 
-
 
    IMPLICIT NONE
@@ -43,22 +43,32 @@
    PUBLIC   tra_adv_init   ! routine called by opa module
 
-   !                              !!* Namelist namtra_adv *
-   LOGICAL ::   ln_traadv_cen2     ! 2nd order centered scheme flag
-   LOGICAL ::   ln_traadv_tvd      ! TVD scheme flag
-   LOGICAL ::   ln_traadv_tvd_zts  ! TVD scheme flag with vertical sub time-stepping
-   LOGICAL ::   ln_traadv_muscl    ! MUSCL scheme flag
-   LOGICAL ::   ln_traadv_muscl2   ! MUSCL2 scheme flag
-   LOGICAL ::   ln_traadv_ubs      ! UBS scheme flag
-   LOGICAL ::   ln_traadv_qck      ! QUICKEST scheme flag
-   LOGICAL ::   ln_traadv_msc_ups  ! use upstream scheme within muscl
-
-
-   INTEGER ::   nadv   ! choice of the type of advection scheme
-
+   !                            !!* Namelist namtra_adv *
+   LOGICAL ::   ln_traadv_cen    ! centered scheme flag
+   INTEGER ::      nn_cen_h, nn_cen_v   ! =2/4 : horizontal and vertical choices of the order of CEN scheme
+   LOGICAL ::   ln_traadv_fct    ! FCT scheme flag
+   INTEGER ::      nn_fct_h, nn_fct_v   ! =2/4 : horizontal and vertical choices of the order of FCT scheme
+   INTEGER ::      nn_fct_zts           ! >=1 : 2nd order FCT with vertical sub-timestepping
+   LOGICAL ::   ln_traadv_mus    ! MUSCL scheme flag
+   LOGICAL ::      ln_mus_ups           ! use upstream scheme in vivcinity of river mouths
+   LOGICAL ::   ln_traadv_ubs    ! UBS scheme flag
+   INTEGER ::      nn_ubs_v             ! =2/4 : vertical choice of the order of UBS scheme
+   LOGICAL ::   ln_traadv_qck    ! QUICKEST scheme flag
+
+   INTEGER ::              nadv             ! choice of the type of advection scheme
+   !
+   !                                        ! associated indices:
+   INTEGER, PARAMETER ::   np_NO_adv  = 0   ! no T-S advection
+   INTEGER, PARAMETER ::   np_CEN     = 1   ! 2nd/4th order centered scheme
+   INTEGER, PARAMETER ::   np_FCT     = 2   ! 2nd/4th order Flux Corrected Transport scheme
+   INTEGER, PARAMETER ::   np_FCT_zts = 3   ! 2nd order FCT scheme with vertical sub-timestepping
+   INTEGER, PARAMETER ::   np_MUS     = 4   ! MUSCL scheme
+   INTEGER, PARAMETER ::   np_UBS     = 5   ! 3rd order Upstream Biased Scheme
+   INTEGER, PARAMETER ::   np_QCK     = 6   ! QUICK scheme
+   
    !! * Substitutions
 #  include "domzgr_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -74,5 +84,4 @@
       !! ** Method  : - Update (ua,va) with the advection term following nadv
       !!----------------------------------------------------------------------
-      !
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
       !
@@ -83,5 +92,6 @@
       IF( nn_timing == 1 )  CALL timing_start('tra_adv')
       !
-      CALL wrk_alloc( jpi, jpj, jpk, zun, zvn, zwn )
+      CALL wrk_alloc( jpi,jpj,jpk,   zun, zvn, zwn )
+      !
       !                                          ! set time step
       IF( neuler == 0 .AND. kt == nit000 ) THEN     ! at nit000
@@ -91,62 +101,48 @@
       ENDIF
       !
-      IF( nn_cla == 1 .AND. cp_cfg == 'orca' .AND. jp_cfg == 2 )   CALL cla_traadv( kt )       !==  Cross Land Advection  ==! (hor. advection)
-      !
-      !                                               !==  effective transport  ==!
+      !                                         !==  effective transport  ==!
       DO jk = 1, jpkm1
-         zun(:,:,jk) = e2u(:,:) * fse3u(:,:,jk) * un(:,:,jk)                  ! eulerian transport only
-         zvn(:,:,jk) = e1v(:,:) * fse3v(:,:,jk) * vn(:,:,jk)
-         zwn(:,:,jk) = e1t(:,:) * e2t(:,:)      * wn(:,:,jk)
+         zun(:,:,jk) = e2u  (:,:) * fse3u(:,:,jk) * un(:,:,jk)                  ! eulerian transport only
+         zvn(:,:,jk) = e1v  (:,:) * fse3v(:,:,jk) * vn(:,:,jk)
+         zwn(:,:,jk) = e1e2t(:,:)                 * wn(:,:,jk)
       END DO
       !
-      IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
+      IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN                                ! add z-tilde and/or vvl corrections
          zun(:,:,:) = zun(:,:,:) + un_td(:,:,:)
          zvn(:,:,:) = zvn(:,:,:) + vn_td(:,:,:)
       ENDIF
       !
-      zun(:,:,jpk) = 0._wp                                                     ! no transport trough the bottom
-      zvn(:,:,jpk) = 0._wp                                                     ! no transport trough the bottom
-      zwn(:,:,jpk) = 0._wp                                                     ! no transport trough the bottom
-      !
-      IF( lk_traldf_eiv .AND. .NOT. ln_traldf_grif )   &
-         &              CALL tra_adv_eiv( kt, nit000, zun, zvn, zwn, 'TRA' )    ! add the eiv transport (if necessary)
-      !
-      IF( ln_mle    )   CALL tra_adv_mle( kt, nit000, zun, zvn, zwn, 'TRA' )    ! add the mle transport (if necessary)
-      !
-      CALL iom_put( "uocetr_eff", zun )                                         ! output effective transport      
+      zun(:,:,jpk) = 0._wp                                                      ! no transport trough the bottom
+      zvn(:,:,jpk) = 0._wp
+      zwn(:,:,jpk) = 0._wp
+      !
+      IF( ln_ldfeiv .AND. .NOT. ln_traldf_triad )   &
+         &              CALL ldf_eiv_trp( kt, nit000, zun, zvn, zwn, 'TRA' )   ! add the eiv transport (if necessary)
+      !
+      IF( ln_mle    )   CALL tra_adv_mle( kt, nit000, zun, zvn, zwn, 'TRA' )   ! add the mle transport (if necessary)
+      !
+      CALL iom_put( "uocetr_eff", zun )                                        ! output effective transport      
       CALL iom_put( "vocetr_eff", zvn )
       CALL iom_put( "wocetr_eff", zwn )
       !
-      IF( ln_diaptr )   CALL dia_ptr( zvn )                                     ! diagnose the effective MSF 
-      !
-   
-      SELECT CASE ( nadv )                            !==  compute advection trend and add it to general trend  ==!
-      CASE ( 1 )   ;    CALL tra_adv_cen2   ( kt, nit000, 'TRA',         zun, zvn, zwn, tsb, tsn, tsa, jpts )   !  2nd order centered
-      CASE ( 2 )   ;    CALL tra_adv_tvd    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )   !  TVD 
-      CASE ( 3 )   ;    CALL tra_adv_muscl  ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb,      tsa, jpts, ln_traadv_msc_ups )   !  MUSCL 
-      CASE ( 4 )   ;    CALL tra_adv_muscl2 ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )   !  MUSCL2 
-      CASE ( 5 )   ;    CALL tra_adv_ubs    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )   !  UBS 
-      CASE ( 6 )   ;    CALL tra_adv_qck    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )   !  QUICKEST 
-      CASE ( 7 )   ;    CALL tra_adv_tvd_zts( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )   !  TVD ZTS
-      !
-      CASE (-1 )                                      !==  esopa: test all possibility with control print  ==!
-         CALL tra_adv_cen2  ( kt, nit000, 'TRA',         zun, zvn, zwn, tsb, tsn, tsa, jpts )          
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' adv0 - Ta: ', mask1=tmask,               &
-            &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_adv_tvd   ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )          
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' adv1 - Ta: ', mask1=tmask,               &
-            &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_adv_muscl ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb,      tsa, jpts, ln_traadv_msc_ups )          
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' adv3 - Ta: ', mask1=tmask,               &
-            &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_adv_muscl2( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )          
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' adv4 - Ta: ', mask1=tmask,               &
-            &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_adv_ubs   ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )          
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' adv5 - Ta: ', mask1=tmask,               &
-            &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_adv_qck   ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts )          
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' adv6 - Ta: ', mask1=tmask,               &
-            &          tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+!!gm ???
+      IF( ln_diaptr )   CALL dia_ptr( zvn )                                    ! diagnose the effective MSF 
+!!gm ???
+      !
+      SELECT CASE ( nadv )                      !==  compute advection trend and add it to general trend  ==!
+      !
+      CASE ( np_CEN )                                    ! Centered scheme : 2nd / 4th order
+         CALL tra_adv_cen    ( kt, nit000, 'TRA',         zun, zvn, zwn     , tsn, tsa, jpts, nn_cen_h, nn_cen_v )
+      CASE ( np_FCT )                                    ! FCT scheme      : 2nd / 4th order
+         CALL tra_adv_fct    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts, nn_fct_h, nn_fct_v )
+      CASE ( np_FCT_zts )                                ! 2nd order FCT with vertical time-splitting
+         CALL tra_adv_fct_zts( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts        , nn_fct_zts )
+      CASE ( np_MUS )                                    ! MUSCL
+         CALL tra_adv_mus    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb,      tsa, jpts        , ln_mus_ups ) 
+      CASE ( np_UBS )                                    ! UBS
+         CALL tra_adv_ubs    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts        , nn_ubs_v   )
+      CASE ( np_QCK )                                    ! QUICKEST
+         CALL tra_adv_qck    ( kt, nit000, 'TRA', r2dtra, zun, zvn, zwn, tsb, tsn, tsa, jpts                     )
+      !
       END SELECT
       !
@@ -157,5 +153,5 @@
       IF( nn_timing == 1 )  CALL timing_stop( 'tra_adv' )
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, zun, zvn, zwn )
+      CALL wrk_dealloc( jpi,jpj,jpk,   zun, zvn, zwn )
       !                                          
    END SUBROUTINE tra_adv
@@ -169,75 +165,109 @@
       !!              tracer advection schemes and set nadv
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio
-      INTEGER ::   ios                 ! Local integer output status for namelist read
-      !!
-      NAMELIST/namtra_adv/ ln_traadv_cen2 , ln_traadv_tvd,     &
-         &                 ln_traadv_muscl, ln_traadv_muscl2,  &
-         &                 ln_traadv_ubs  , ln_traadv_qck,     &
-         &                 ln_traadv_msc_ups, ln_traadv_tvd_zts
-      !!----------------------------------------------------------------------
-
-      REWIND( numnam_ref )              ! Namelist namtra_adv in reference namelist : Tracer advection scheme
+      INTEGER ::   ioptio, ios   ! Local integers
+      !
+      NAMELIST/namtra_adv/ ln_traadv_cen, nn_cen_h, nn_cen_v,               &   ! CEN
+         &                 ln_traadv_fct, nn_fct_h, nn_fct_v, nn_fct_zts,   &   ! FCT
+         &                 ln_traadv_mus,                     ln_mus_ups,   &   ! MUSCL
+         &                 ln_traadv_ubs,           nn_ubs_v,               &   ! UBS
+         &                 ln_traadv_qck                                        ! QCK
+      !!----------------------------------------------------------------------
+      !
+      !                                !==  Namelist  ==!
+      !
+      REWIND( numnam_ref )                   ! Namelist namtra_adv in reference namelist : Tracer advection scheme
       READ  ( numnam_ref, namtra_adv, IOSTAT = ios, ERR = 901)
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_adv in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namtra_adv in configuration namelist : Tracer advection scheme
+      !
+      REWIND( numnam_cfg )                   ! Namelist namtra_adv in configuration namelist : Tracer advection scheme
       READ  ( numnam_cfg, namtra_adv, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_adv in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namtra_adv )
 
-      IF(lwp) THEN                    ! Namelist print
+      IF(lwp) THEN                           ! Namelist print
          WRITE(numout,*)
          WRITE(numout,*) 'tra_adv_init : choice/control of the tracer advection scheme'
          WRITE(numout,*) '~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namtra_adv : chose a advection scheme for tracers'
-         WRITE(numout,*) '      2nd order advection scheme     ln_traadv_cen2    = ', ln_traadv_cen2
-         WRITE(numout,*) '      TVD advection scheme           ln_traadv_tvd     = ', ln_traadv_tvd
-         WRITE(numout,*) '      MUSCL  advection scheme        ln_traadv_muscl   = ', ln_traadv_muscl
-         WRITE(numout,*) '      MUSCL2 advection scheme        ln_traadv_muscl2  = ', ln_traadv_muscl2
-         WRITE(numout,*) '      UBS    advection scheme        ln_traadv_ubs     = ', ln_traadv_ubs
-         WRITE(numout,*) '      QUICKEST advection scheme      ln_traadv_qck     = ', ln_traadv_qck
-         WRITE(numout,*) '      upstream scheme within muscl   ln_traadv_msc_ups = ', ln_traadv_msc_ups
-         WRITE(numout,*) '      TVD advection scheme with zts  ln_traadv_tvd_zts = ', ln_traadv_tvd_zts
-      ENDIF
-
-      ioptio = 0                      ! Parameter control
-      IF( ln_traadv_cen2   )   ioptio = ioptio + 1
-      IF( ln_traadv_tvd    )   ioptio = ioptio + 1
-      IF( ln_traadv_muscl  )   ioptio = ioptio + 1
-      IF( ln_traadv_muscl2 )   ioptio = ioptio + 1
-      IF( ln_traadv_ubs    )   ioptio = ioptio + 1
-      IF( ln_traadv_qck    )   ioptio = ioptio + 1
-      IF( ln_traadv_tvd_zts)   ioptio = ioptio + 1
-      IF( lk_esopa         )   ioptio =          1
-
-      IF( ( ln_traadv_muscl .OR. ln_traadv_muscl2 .OR. ln_traadv_ubs .OR. ln_traadv_qck .OR. ln_traadv_tvd_zts )   &
-         .AND. ln_isfcav )   CALL ctl_stop( 'Only traadv_cen2 and traadv_tvd is compatible with ice shelf cavity')
-
-      IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE advection scheme in namelist namtra_adv' )
-
-      !                              ! Set nadv
-      IF( ln_traadv_cen2   )   nadv =  1
-      IF( ln_traadv_tvd    )   nadv =  2
-      IF( ln_traadv_muscl  )   nadv =  3
-      IF( ln_traadv_muscl2 )   nadv =  4
-      IF( ln_traadv_ubs    )   nadv =  5
-      IF( ln_traadv_qck    )   nadv =  6
-      IF( ln_traadv_tvd_zts)   nadv =  7
-      IF( lk_esopa         )   nadv = -1
-
-      IF(lwp) THEN                   ! Print the choice
+         WRITE(numout,*) '      centered scheme                           ln_traadv_cen = ', ln_traadv_cen
+         WRITE(numout,*) '            horizontal 2nd/4th order               nn_cen_h   = ', nn_fct_h
+         WRITE(numout,*) '            vertical   2nd/4th order               nn_cen_v   = ', nn_fct_v
+         WRITE(numout,*) '      Flux Corrected Transport scheme           ln_traadv_fct = ', ln_traadv_fct
+         WRITE(numout,*) '            horizontal 2nd/4th order               nn_fct_h   = ', nn_fct_h
+         WRITE(numout,*) '            vertical   2nd/4th order               nn_fct_v   = ', nn_fct_v
+         WRITE(numout,*) '            2nd order + vertical sub-timestepping  nn_fct_zts = ', nn_fct_zts
+         WRITE(numout,*) '      MUSCL scheme                              ln_traadv_mus = ', ln_traadv_mus
+         WRITE(numout,*) '            + upstream scheme near river mouths    ln_mus_ups = ', ln_mus_ups
+         WRITE(numout,*) '      UBS scheme                                ln_traadv_ubs = ', ln_traadv_ubs
+         WRITE(numout,*) '            vertical   2nd/4th order               nn_ubs_v   = ', nn_ubs_v
+         WRITE(numout,*) '      QUICKEST scheme                           ln_traadv_qck = ', ln_traadv_qck
+      ENDIF
+
+      ioptio = 0                       !==  Parameter control  ==!
+      IF( ln_traadv_cen )   ioptio = ioptio + 1
+      IF( ln_traadv_fct )   ioptio = ioptio + 1
+      IF( ln_traadv_mus )   ioptio = ioptio + 1
+      IF( ln_traadv_ubs )   ioptio = ioptio + 1
+      IF( ln_traadv_qck )   ioptio = ioptio + 1
+      !
+      IF( ioptio == 0 ) THEN
+         nadv = np_NO_adv
+         CALL ctl_warn( 'tra_adv_init: You are running without tracer advection.' )
+      ENDIF
+      IF( (ioptio /= 1).AND. (.NOT. lk_c1d ) ) & 
+        CALL ctl_stop( 'tra_adv_init: Choose ONE advection scheme in namelist namtra_adv' )
+      !
+      IF( ln_traadv_cen .AND. ( nn_cen_h /= 2 .AND. nn_cen_h /= 4 )   &          ! Centered
+                        .AND. ( nn_cen_v /= 2 .AND. nn_cen_v /= 4 )   ) THEN
+        CALL ctl_stop( 'tra_adv_init: CEN scheme, choose 2nd or 4th order' )
+      ENDIF
+      IF( ln_traadv_fct .AND. ( nn_fct_h /= 2 .AND. nn_fct_h /= 4 )   &          ! FCT
+                        .AND. ( nn_fct_v /= 2 .AND. nn_fct_v /= 4 )   ) THEN
+        CALL ctl_stop( 'tra_adv_init: FCT scheme, choose 2nd or 4th order' )
+      ENDIF
+      IF( ln_traadv_fct .AND. nn_fct_zts > 0 ) THEN
+         IF( nn_fct_h == 4 ) THEN
+            nn_fct_h = 2
+            CALL ctl_stop( 'tra_adv_init: force 2nd order FCT scheme, 4th order does not exist with sub-timestepping' )
+         ENDIF
+         IF( lk_vvl ) THEN
+            CALL ctl_stop( 'tra_adv_init: vertical sub-timestepping not allow in non-linear free surface' )
+         ENDIF
+         IF( nn_fct_zts == 1 )   CALL ctl_warn( 'tra_adv_init: FCT with ONE sub-timestep = FCT without sub-timestep' )
+      ENDIF
+      IF( ln_traadv_ubs .AND. ( nn_ubs_v /= 2 .AND. nn_ubs_v /= 4 )   ) THEN     ! UBS
+        CALL ctl_stop( 'tra_adv_init: UBS scheme, choose 2nd or 4th order' )
+      ENDIF
+      IF( ln_traadv_ubs .AND. nn_ubs_v == 4 ) THEN
+         CALL ctl_warn( 'tra_adv_init: UBS scheme, only 2nd FCT scheme available on the vertical. It will be used' )
+      ENDIF
+      IF( ln_isfcav ) THEN                                                       ! ice-shelf cavities
+         IF(  ln_traadv_cen .AND. nn_cen_v /= 4    .OR.   &                            ! NO 4th order with ISF
+            & ln_traadv_fct .AND. nn_fct_v /= 4   )   CALL ctl_stop( 'tra_adv_init: 4th order COMPACT scheme not allowed with ISF' )
+      ENDIF
+      !
+      !                                !==  used advection scheme  ==!  
+      !                                      ! set nadv
+      IF( ln_traadv_cen                      )   nadv = np_CEN
+      IF( ln_traadv_fct                      )   nadv = np_FCT
+      IF( ln_traadv_fct .AND. nn_fct_zts > 0 )   nadv = np_FCT_zts
+      IF( ln_traadv_mus                      )   nadv = np_MUS
+      IF( ln_traadv_ubs                      )   nadv = np_UBS
+      IF( ln_traadv_qck                      )   nadv = np_QCK
+
+      IF(lwp) THEN                           ! Print the choice
          WRITE(numout,*)
-         IF( nadv ==  1 )   WRITE(numout,*) '         2nd order scheme is used'
-         IF( nadv ==  2 )   WRITE(numout,*) '         TVD       scheme is used'
-         IF( nadv ==  3 )   WRITE(numout,*) '         MUSCL     scheme is used'
-         IF( nadv ==  4 )   WRITE(numout,*) '         MUSCL2    scheme is used'
-         IF( nadv ==  5 )   WRITE(numout,*) '         UBS       scheme is used'
-         IF( nadv ==  6 )   WRITE(numout,*) '         QUICKEST  scheme is used'
-         IF( nadv ==  7 )   WRITE(numout,*) '         TVD ZTS   scheme is used'
-         IF( nadv == -1 )   WRITE(numout,*) '         esopa test: use all advection scheme'
-      ENDIF
-      !
-      CALL tra_adv_mle_init          ! initialisation of the Mixed Layer Eddy parametrisation (MLE)
+         IF( nadv == np_NO_adv  )   WRITE(numout,*) '         NO T-S advection'
+         IF( nadv == np_CEN     )   WRITE(numout,*) '         CEN      scheme is used. Horizontal order: ', nn_cen_h,   &
+            &                                                                        ' Vertical   order: ', nn_cen_v
+         IF( nadv == np_FCT     )   WRITE(numout,*) '         FCT      scheme is used. Horizontal order: ', nn_fct_h,   &
+            &                                                                        ' Vertical   order: ', nn_fct_v
+         IF( nadv == np_FCT_zts )   WRITE(numout,*) '         use 2nd order FCT with ', nn_fct_zts,'vertical sub-timestepping'
+         IF( nadv == np_MUS     )   WRITE(numout,*) '         MUSCL    scheme is used'
+         IF( nadv == np_UBS     )   WRITE(numout,*) '         UBS      scheme is used'
+         IF( nadv == np_QCK     )   WRITE(numout,*) '         QUICKEST scheme is used'
+      ENDIF
+      !
+      CALL tra_adv_mle_init            !== initialisation of the Mixed Layer Eddy parametrisation (MLE)  ==!
       !
    END SUBROUTINE tra_adv_init
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen.F90	(revision 6041)
@@ -0,0 +1,210 @@
+MODULE traadv_cen
+   !!======================================================================
+   !!                     ***  MODULE  traadv_cen  ***
+   !! Ocean  tracers:  horizontal & vertical advective trend (2nd/4th order centered)
+   !!======================================================================
+   !! History :  3.7  ! 2014-05  (G. Madec)  original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_cen : update the tracer trend with the advection trends using a centered or scheme (2nd or 4th order)
+   !!                 NB: on the vertical it is actually a 4th order COMPACT scheme which is used
+   !!----------------------------------------------------------------------
+   USE oce, ONLY: tsn  ! now ocean temperature and salinity
+   USE dom_oce         ! ocean space and time domain
+   USE eosbn2          ! equation of state
+   USE traadv_fct      ! acces to routine interp_4th_cpt 
+   USE trd_oce         ! trends: ocean variables
+   USE trdtra          ! trends manager: tracers 
+   USE diaptr          ! poleward transport diagnostics
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! IOM library
+   USE trc_oce         ! share passive tracers/Ocean variables
+   USE lib_mpp         ! MPP library
+   USE wrk_nemo        ! Memory Allocation
+   USE timing          ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_cen       ! routine called by step.F90
+   
+   REAL(wp) ::   r1_6 = 1._wp / 6._wp   ! =1/6
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! $Id: traadv_cen2.F90 5737 2015-09-13 07:42:41Z gm $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tra_adv_cen( kt, kit000, cdtype, pun, pvn, pwn,     &
+      &                                             ptn, pta, kjpt, kn_cen_h, kn_cen_v ) 
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_cen  ***
+      !!                 
+      !! ** Purpose :   Compute the now trend due to the advection of tracers
+      !!      and add it to the general trend of passive tracer equations.
+      !!
+      !! ** Method  :   The advection is evaluated by a 2nd or 4th order scheme
+      !!               using now fields (leap-frog scheme). 
+      !!
+      !!       kn_cen_h = 2  ==>> 2nd order centered scheme on the horizontal
+      !!                = 4  ==>> 4th order    -        -       -      -
+      !!
+      !!       kn_cen_v = 2  ==>> 2nd order centered scheme on the vertical
+      !!                = 4  ==>> 4th order COMPACT  scheme     -      -
+      !!
+      !! ** Action :  - update pta  with the now advective tracer trends
+      !!              - send trends to trdtra module for further diagnostcs
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
+      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
+      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
+      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kn_cen_h        ! =2/4 (2nd or 4th order scheme)
+      INTEGER                              , INTENT(in   ) ::   kn_cen_v        ! =2/4 (2nd or 4th order scheme)
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptn             ! now tracer fields
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
+      !
+      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
+      INTEGER  ::   ierr             ! local integer
+      REAL(wp) ::   zC2t_u, zC4t_u   ! local scalars
+      REAL(wp) ::   zC2t_v, zC4t_v   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zwx, zwy, zwz, ztu, ztv, ztw
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('tra_adv_cen')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zwx, zwy, zwz, ztu, ztv, ztw )
+      !
+      IF( kt == kit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_cen : centered advection scheme on ', cdtype, ' order h/v =', kn_cen_h,'/', kn_cen_v
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~ '
+      ENDIF
+      !
+      !                          ! surface & bottom values 
+      IF( lk_vvl )   zwz(:,:, 1 ) = 0._wp             ! set to zero one for all
+                     zwz(:,:,jpk) = 0._wp             ! except at the surface in linear free surface
+      !
+      DO jn = 1, kjpt            !==  loop over the tracers  ==!
+         !
+         SELECT CASE( kn_cen_h )          !--  Horizontal fluxes  --!
+         !
+         CASE(  2  )                               ! 2nd order centered
+            DO jk = 1, jpkm1
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zwx(ji,jj,jk) = 0.5_wp * pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj  ,jk,jn) )
+                     zwy(ji,jj,jk) = 0.5_wp * pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji  ,jj+1,jk,jn) )
+                  END DO
+               END DO
+            END DO
+            !
+         CASE(  4  )                               ! 4th order centered
+            ztu(:,:,jpk) = 0._wp                            ! Bottom value : flux set to zero
+            ztv(:,:,jpk) = 0._wp
+            DO jk = 1, jpkm1                                 ! gradient
+               DO jj = 2, jpjm1                                   ! masked derivative
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ztu(ji,jj,jk) = ( ptn(ji+1,jj  ,jk,jn) - ptn(ji,jj,jk,jn) ) * umask(ji,jj,jk)
+                     ztv(ji,jj,jk) = ( ptn(ji  ,jj+1,jk,jn) - ptn(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( ztu, 'U', -1. )   ;    CALL lbc_lnk( ztv, 'V', -1. )   ! Lateral boundary cond. (unchanged sgn)
+            !
+            DO jk = 1, jpkm1                                 ! Horizontal advective fluxes
+               DO jj = 2, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zC2t_u = ptn(ji,jj,jk,jn) + ptn(ji+1,jj  ,jk,jn)   ! C2 interpolation of T at u- & v-points (x2)
+                     zC2t_v = ptn(ji,jj,jk,jn) + ptn(ji  ,jj+1,jk,jn)
+                     !                                                  ! C4 interpolation of T at u- & v-points (x2)
+                     zC4t_u =  zC2t_u + r1_6 * ( ztu(ji-1,jj,jk) - ztu(ji+1,jj,jk) )
+                     zC4t_v =  zC2t_v + r1_6 * ( ztv(ji,jj-1,jk) - ztv(ji,jj+1,jk) )
+                     !                                                  ! C4 fluxes
+                     zwx(ji,jj,jk) =  0.5_wp * pun(ji,jj,jk) * zC4t_u
+                     zwy(ji,jj,jk) =  0.5_wp * pvn(ji,jj,jk) * zC4t_v
+                  END DO
+               END DO
+            END DO         
+            !
+         CASE DEFAULT
+            CALL ctl_stop( 'traadv_fct: wrong value for nn_fct' )
+         END SELECT
+         !
+         !                             !==  Vertical fluxes  ==!
+         !
+         SELECT CASE( kn_cen_v )             !* interior fluxes
+         !
+         CASE(  2  )                               ! 2nd order centered
+            DO jk = 2, jpk
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zwz(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) ) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         CASE(  4  )                               ! 4th order centered
+            CALL interp_4th_cpt( ptn(:,:,:,jn) , ztw )         ! 4th order compact interpolation of T at w-point
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zwz(ji,jj,jk) = pwn(ji,jj,jk) * ztw(ji,jj,jk) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         END SELECT
+         !
+         IF(.NOT.lk_vvl ) THEN               !* top value   (only in linear free surf. as zwz is multiplied by wmask)
+            IF( ln_isfcav ) THEN                  ! ice-shelf cavities (top of the ocean)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptn(ji,jj,mikt(ji,jj),jn)   ! linear free surface 
+                  END DO
+               END DO   
+            ELSE                                   ! no ice-shelf cavities (only ocean surface)
+               zwz(:,:,1) = pwn(:,:,1) * ptn(:,:,1,jn)
+            ENDIF
+         ENDIF
+         !               
+         DO jk = 1, jpkm1              !--  Divergence of advective fluxes  --!
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn)    &
+                     &             - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )    &
+                     &                + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )    &
+                     &                + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1)  ) / ( e1e2t(ji,jj) *  fse3t_n(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         !                                 ! trend diagnostics
+         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) ) THEN
+            CALL trd_tra( kt, cdtype, jn, jptra_xad, zwx, pun, ptn(:,:,:,jn) )
+            CALL trd_tra( kt, cdtype, jn, jptra_yad, zwy, pvn, ptn(:,:,:,jn) )
+            CALL trd_tra( kt, cdtype, jn, jptra_zad, zwz, pwn, ptn(:,:,:,jn) )
+         END IF
+         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
+         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
+           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+         ENDIF
+         !
+      END DO
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zwx, zwy, zwz, ztu, ztv, ztw )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_cen')
+      !
+   END SUBROUTINE tra_adv_cen
+   
+   !!======================================================================
+END MODULE traadv_cen
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 6040)
+++ 	(revision )
@@ -1,368 +1,0 @@
-MODULE traadv_cen2
-   !!======================================================================
-   !!                     ***  MODULE  traadv_cen2  ***
-   !! Ocean  tracers:  horizontal & vertical advective trend
-   !!======================================================================
-   !! History :  OPA  ! 2001-08  (G. Madec, E. Durand) v8.2 trahad+trazad=traadv 
-   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module
-   !!             -   ! 2004-08  (C. Talandier) New trends organization
-   !!             -   ! 2005-11  (V. Garnier) Surface pressure gradient organization
-   !!            2.0  ! 2006-04  (R. Benshila, G. Madec) Step reorganization
-   !!             -   ! 2006-07  (G. madec)  add ups_orca_set routine
-   !!            3.2  ! 2009-07  (G. Madec) add avmb, avtb in restart for cen2 advection
-   !!            3.3  ! 2010-05  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_adv_cen2 : update the tracer trend with the advection trends using a 2nd order centered scheme
-   !!   ups_orca_set : allow mixed upstream/centered scheme in specific area (set for orca 2 and 4 only)
-   !!----------------------------------------------------------------------
-   USE oce, ONLY: tsn  ! now ocean temperature and salinity
-   USE dom_oce         ! ocean space and time domain
-   USE eosbn2          ! equation of state
-   USE trd_oce         ! trends: ocean variables
-   USE trdtra          ! trends manager: tracers 
-   USE closea          ! closed sea
-   USE sbcrnf          ! river runoffs
-   USE in_out_manager  ! I/O manager
-   USE iom             ! IOM library
-   USE diaptr          ! poleward transport diagnostics
-   USE zdf_oce         ! ocean vertical physics
-   USE trc_oce         ! share passive tracers/Ocean variables
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-   USE phycst
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_adv_cen2   ! routine called by traadv.F90
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) :: upsmsk !: mixed upstream/centered scheme near some straits 
-   !                                                             !  and in closed seas (orca 2 and 4 configurations)
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_adv_cen2( kt, kit000, cdtype, pun, pvn, pwn,     &
-      &                                         ptb, ptn, pta, kjpt   ) 
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_adv_cen2  ***
-      !!                 
-      !! ** Purpose :   Compute the now trend due to the advection of tracers
-      !!      and add it to the general trend of passive tracer equations.
-      !!
-      !! ** Method  :   The advection is evaluated by a second order centered
-      !!      scheme using now fields (leap-frog scheme). In specific areas
-      !!      (vicinity of major river mouths, some straits, or where tn is
-      !!      approaching the freezing point) it is mixed with an upstream
-      !!      scheme for stability reasons.
-      !!         Part 0 : compute the upstream / centered flag
-      !!                  (3D array, zind, defined at T-point (0<zind<1))
-      !!         Part I : horizontal advection
-      !!       * centered flux:
-      !!               zcenu = e2u*e3u  un  mi(ptn)
-      !!               zcenv = e1v*e3v  vn  mj(ptn)
-      !!       * upstream flux:
-      !!               zupsu = e2u*e3u  un  (ptb(i) or ptb(i-1) ) [un>0 or <0]
-      !!               zupsv = e1v*e3v  vn  (ptb(j) or ptb(j-1) ) [vn>0 or <0]
-      !!       * mixed upstream / centered horizontal advection scheme
-      !!               zcofi = max(zind(i+1), zind(i))
-      !!               zcofj = max(zind(j+1), zind(j))
-      !!               zwx = zcofi * zupsu + (1-zcofi) * zcenu
-      !!               zwy = zcofj * zupsv + (1-zcofj) * zcenv
-      !!       * horizontal advective trend (divergence of the fluxes)
-      !!               ztra = 1/(e1t*e2t*e3t) { di-1[zwx] + dj-1[zwy] }
-      !!       * Add this trend now to the general trend of tracer (ta,sa):
-      !!               pta = pta + ztra
-      !!       * trend diagnostic (l_trdtra=T or l_trctra=T): the trend is
-      !!      saved for diagnostics. The trends saved is expressed as
-      !!      Uh.gradh(T), i.e.  save trend = ztra + ptn divn
-      !!
-      !!         Part II : vertical advection
-      !!      For temperature (idem for salinity) the advective trend is com-
-      !!      puted as follows :
-      !!            ztra = 1/e3t dk+1[ zwz ]
-      !!      where the vertical advective flux, zwz, is given by :
-      !!            zwz = zcofk * zupst + (1-zcofk) * zcent
-      !!      with
-      !!        zupsv = upstream flux = wn * (ptb(k) or ptb(k-1) ) [wn>0 or <0]
-      !!        zcenu = centered flux = wn * mk(tn)
-      !!         The surface boundary condition is :
-      !!      variable volume (lk_vvl = T) : zero advective flux
-      !!      lin. free-surf  (lk_vvl = F) : wn(:,:,1) * ptn(:,:,1)
-      !!         Add this trend now to the general trend of tracer (ta,sa):
-      !!             pta = pta + ztra
-      !!         Trend diagnostic (l_trdtra=T or l_trctra=T): the trend is
-      !!      saved for diagnostics. The trends saved is expressed as :
-      !!             save trend =  w.gradz(T) = ztra - ptn divn.
-      !!
-      !! ** Action :  - update pta  with the now advective tracer trends
-      !!              - save trends if needed
-      !!----------------------------------------------------------------------
-      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb, ptn        ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
-      !
-      INTEGER  ::   ji, jj, jk, jn, ikt   ! dummy loop indices
-      INTEGER  ::   ierr                 ! local integer
-      REAL(wp) ::   zbtr, ztra                            ! local scalars
-      REAL(wp) ::   zfp_ui, zfp_vj, zfp_w, zcofi          !   -      -
-      REAL(wp) ::   zfm_ui, zfm_vj, zfm_w, zcofj, zcofk   !   -      -
-      REAL(wp) ::   zupsut, zcenut, zupst                 !   -      -
-      REAL(wp) ::   zupsvt, zcenvt, zcent, zice           !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:)   :: zfzp, zpres   ! 2D workspace
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwx, zwy     ! 3D     -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwz, zind    !  -     -
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_adv_cen2')
-      !
-      CALL wrk_alloc( jpi, jpj, zpres, zfzp )
-      CALL wrk_alloc( jpi, jpj, jpk, zwx, zwy, zwz, zind )
-      !
-
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_adv_cen2 : 2nd order centered advection scheme on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~ '
-         IF(lwp) WRITE(numout,*)
-         !
-         IF( .NOT. ALLOCATED( upsmsk ) )  THEN
-             ALLOCATE( upsmsk(jpi,jpj), STAT=ierr )
-             IF( ierr /= 0 )   CALL ctl_stop('STOP', 'tra_adv_cen2: unable to allocate array')
-         ENDIF
-
-         !
-         upsmsk(:,:) = 0._wp                             ! not upstream by default
-         ! 
-         IF( cp_cfg == "orca" )   CALL ups_orca_set      ! set mixed Upstream/centered scheme near some straits
-         !                                               ! and in closed seas (orca2 and orca4 only)
-         IF( jp_cfg == 2 .AND. .NOT. ln_rstart ) THEN    ! Increase the background in the surface layers
-            avmb(1) = 10.  * avmb(1)      ;      avtb(1) = 10.  * avtb(1)
-            avmb(2) = 10.  * avmb(2)      ;      avtb(2) = 10.  * avtb(2)
-            avmb(3) =  5.  * avmb(3)      ;      avtb(3) =  5.  * avtb(3)
-            avmb(4) =  2.5 * avmb(4)      ;      avtb(4) =  2.5 * avtb(4)
-         ENDIF
-      ENDIF
-      !
-      ! Upstream / centered scheme indicator
-      ! ------------------------------------
-!!gm  not strickly exact : the freezing point should be computed at each ocean levels...
-!!gm  not a big deal since cen2 is no more used in global ice-ocean simulations
-!!ch  changes for ice shelf to retain standard behaviour elsewhere, even if not optimal 
-      DO jj = 1, jpj 
-         DO ji = 1, jpi 
-            ikt = mikt(ji,jj) 
-            IF (ikt > 1 ) THEN 
-               zpres(ji,jj) = grav * rau0 * fsdept(ji,jj,ikt) * 1.e-04  
-            ELSE 
-               zpres(ji,jj) = 0.0 
-            ENDIF  
-         END DO 
-      END DO 
-      CALL eos_fzp( tsn(:,:,1,jp_sal), zfzp(:,:), zpres(:,:) )
-      DO jk = 1, jpk
-         DO jj = 1, jpj
-            DO ji = 1, jpi
-               !                                        ! below ice covered area (if tn < "freezing"+0.1 )
-               IF( tsn(ji,jj,jk,jp_tem) <= zfzp(ji,jj) + 0.1 ) THEN   ;   zice = 1._wp
-               ELSE                                                   ;   zice = 0._wp
-               ENDIF
-               zind(ji,jj,jk) = MAX (   &
-                  rnfmsk(ji,jj) * rnfmsk_z(jk),      &  ! near runoff mouths (& closed sea outflows)
-                  upsmsk(ji,jj)               ,      &  ! some of some straits
-                  zice                               &  ! below ice covered area (if tn < "freezing"+0.1 )
-                  &                  ) * tmask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-
-      DO jn = 1, kjpt
-         !
-         ! I. Horizontal advection
-         !    ====================
-         !
-         DO jk = 1, jpkm1
-            !                        ! Second order centered tracer flux at u- and v-points
-            DO jj = 1, jpjm1
-               !
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  ! upstream indicator
-                  zcofi = MAX( zind(ji+1,jj,jk), zind(ji,jj,jk) )
-                  zcofj = MAX( zind(ji,jj+1,jk), zind(ji,jj,jk) )
-                  !
-                  ! upstream scheme
-                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )
-                  zfm_ui = pun(ji,jj,jk) - ABS( pun(ji,jj,jk) )
-                  zfp_vj = pvn(ji,jj,jk) + ABS( pvn(ji,jj,jk) )
-                  zfm_vj = pvn(ji,jj,jk) - ABS( pvn(ji,jj,jk) )
-                  zupsut = zfp_ui * ptb(ji,jj,jk,jn) + zfm_ui * ptb(ji+1,jj  ,jk,jn)
-                  zupsvt = zfp_vj * ptb(ji,jj,jk,jn) + zfm_vj * ptb(ji  ,jj+1,jk,jn)
-                  ! centered scheme
-                  zcenut = pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj  ,jk,jn) )
-                  zcenvt = pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji  ,jj+1,jk,jn) )
-                  ! mixed centered / upstream scheme
-                  zwx(ji,jj,jk) = 0.5 * ( zcofi * zupsut + (1.-zcofi) * zcenut )
-                  zwy(ji,jj,jk) = 0.5 * ( zcofj * zupsvt + (1.-zcofj) * zcenvt )
-               END DO
-            END DO
-         END DO
-
-         ! II. Vertical advection
-         !     ==================
-         !
-         !                                                ! Vertical advective fluxes
-         zwz(:,:,jpk) = 0.e0                                   ! Bottom  value : flux set to zero
-         !                                                     ! Surface value : 
-         IF( lk_vvl ) THEN   ;   zwz(:,:, 1 ) = 0.e0                         ! volume variable
-         ELSE
-            DO jj = 1, jpj   ! vector opt.
-               DO ji = 1, jpi   ! vector opt.
-                  ikt = mikt(ji,jj)                
-                  zwz(ji,jj,ikt ) = pwn(ji,jj,ikt) * ptn(ji,jj,ikt,jn)   ! linear free surface 
-                  zwz(ji,jj,1:ikt-1) = 0.e0
-               END DO
-            END DO
-         ENDIF
-         !
-         DO jk = 2, jpk              ! Second order centered tracer flux at w-point
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ! upstream indicator
-                  zcofk = MAX( zind(ji,jj,jk-1), zind(ji,jj,jk) ) 
-                  ! mixed centered / upstream scheme
-                  zfp_w = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
-                  zfm_w = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
-                  zupst = zfp_w * ptb(ji,jj,jk,jn) + zfm_w * ptb(ji,jj,jk-1,jn)
-                  ! centered scheme
-                  zcent = pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) )
-                  ! mixed centered / upstream scheme
-                  zwz(ji,jj,jk) = 0.5 * ( zcofk * zupst + (1.-zcofk) * zcent )
-               END DO
-            END DO
-         END DO
-
-         ! II. Divergence of advective fluxes
-         ! ----------------------------------
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) *  fse3t(ji,jj,jk) )
-                  ! advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                  &                + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                  &                + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1)  )
-                  ! advective trends added to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-         END DO
-
-         !                                 ! trend diagnostics
-         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.    &
-            &( cdtype == 'TRC' .AND. l_trdtrc ) )   THEN
-            CALL trd_tra( kt, cdtype, jn, jptra_xad, zwx, pun, ptn(:,:,:,jn) )
-            CALL trd_tra( kt, cdtype, jn, jptra_yad, zwy, pvn, ptn(:,:,:,jn) )
-            CALL trd_tra( kt, cdtype, jn, jptra_zad, zwz, pwn, ptn(:,:,:,jn) )
-         END IF
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )   htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )   str_adv(:) = ptr_sj( zwy(:,:,:) )
-         ENDIF
-         !
-      END DO
-
-      ! ---------------------------  required in restart file to ensure restartability)
-      ! avmb, avtb will be read in zdfini in restart case as they are used in zdftke, kpp etc...
-      IF( lrst_oce .AND. cdtype == 'TRA' ) THEN
-         CALL iom_rstput( kt, nitrst, numrow, 'avmb', avmb )
-         CALL iom_rstput( kt, nitrst, numrow, 'avtb', avtb )
-      ENDIF
-      !
-      CALL wrk_dealloc( jpi, jpj, zpres, zfzp )
-      CALL wrk_dealloc( jpi, jpj, jpk, zwx, zwy, zwz, zind )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_cen2')
-      !
-   END SUBROUTINE tra_adv_cen2
-   
-   
-   SUBROUTINE ups_orca_set
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ups_orca_set  ***
-      !!       
-      !! ** Purpose :   add a portion of upstream scheme in area where the
-      !!                centered scheme generates too strong overshoot
-      !!
-      !! ** Method  :   orca (R4 and R2) confiiguration setting. Set upsmsk
-      !!                array to nozero value in some straith. 
-      !!
-      !! ** Action : - upsmsk set to 1 at some strait, 0 elsewhere for orca
-      !!----------------------------------------------------------------------
-      INTEGER  ::   ii0, ii1, ij0, ij1      ! temporary integers
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ups_orca_set')
-      !
-      ! mixed upstream/centered scheme near river mouths
-      ! ------------------------------------------------
-      SELECT CASE ( jp_cfg )
-      !                                        ! =======================
-      CASE ( 4 )                               !  ORCA_R4 configuration 
-         !                                     ! =======================
-         !                                          ! Gibraltar Strait
-         ii0 =  70   ;   ii1 =  71
-         ij0 =  52   ;   ij1 =  53   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
-         !
-         !                                     ! =======================
-      CASE ( 2 )                               !  ORCA_R2 configuration 
-         !                                     ! =======================
-         !                                          ! Gibraltar Strait
-         ij0 = 102   ;   ij1 = 102
-         ii0 = 138   ;   ii1 = 138   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.20
-         ii0 = 139   ;   ii1 = 139   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
-         ii0 = 140   ;   ii1 = 140   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
-         ij0 = 101   ;   ij1 = 102
-         ii0 = 141   ;   ii1 = 141   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
-         !                                          ! Bab el Mandeb Strait
-         ij0 =  87   ;   ij1 =  88
-         ii0 = 164   ;   ii1 = 164   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.10
-         ij0 =  88   ;   ij1 =  88
-         ii0 = 163   ;   ii1 = 163   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
-         ii0 = 162   ;   ii1 = 162   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.40
-         ii0 = 160   ;   ii1 = 161   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
-         ij0 =  89   ;   ij1 =  89
-         ii0 = 158   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
-         ij0 =  90   ;   ij1 =  90
-         ii0 = 160   ;   ii1 = 160   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
-         !                                          ! Sound Strait
-         ij0 = 116   ;   ij1 = 116
-         ii0 = 144   ;   ii1 = 144   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
-         ii0 = 145   ;   ii1 = 147   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.50
-         ii0 = 148   ;   ii1 = 148   ;   upsmsk( mi0(ii0):mi1(ii1) , mj0(ij0):mj1(ij1) ) = 0.25
-         !
-      END SELECT 
-      
-      ! mixed upstream/centered scheme over closed seas
-      ! -----------------------------------------------
-      CALL clo_ups( upsmsk(:,:) )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ups_orca_set')
-      !
-   END SUBROUTINE ups_orca_set
-
-   !!======================================================================
-END MODULE traadv_cen2
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_eiv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_eiv.F90	(revision 6040)
+++ 	(revision )
@@ -1,220 +1,0 @@
-MODULE traadv_eiv
-   !!======================================================================
-   !!                    ***  MODULE  traadv_eiv  ***
-   !! Ocean tracers:  advection trend - eddy induced velocity
-   !!======================================================================
-   !! History :  1.0  !  2005-11 (G. Madec)  Original code, from traldf and zdf _iso
-   !!            3.3  !  2010-05 (C. Ethe, G. Madec)  merge TRC-TRA 
-   !!----------------------------------------------------------------------
-#if defined key_traldf_eiv   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!   'key_traldf_eiv'                  rotation of the lateral mixing tensor
-   !!----------------------------------------------------------------------
-   !!   tra_ldf_iso : update the tracer trend with the horizontal component
-   !!                 of iso neutral laplacian operator or horizontal 
-   !!                 laplacian operator in s-coordinate
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldfslp          ! iso-neutral slopes
-   USE in_out_manager  ! I/O manager
-   USE iom
-   USE trc_oce         ! share passive tracers/Ocean variables
-# if defined key_diaeiv
-   USE phycst          ! physical constants
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-# endif  
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_adv_eiv   ! routine called by step.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
-#  include "ldfeiv_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_adv_eiv( kt, kit000, pun, pvn, pwn, cdtype )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_adv_eiv  ***
-      !! 
-      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive 
-      !!      trend and add it to the general trend of tracer equation.
-      !!
-      !! ** Method  :   The eddy induced advection is computed from the slope
-      !!      of iso-neutral surfaces computed in routine ldf_slp as follows:
-      !!         zu_eiv =  1/(e2u e3u)   dk[ aeiu e2u mi(wslpi) ]
-      !!         zv_eiv =  1/(e1v e3v)   dk[ aeiv e1v mj(wslpj)
-      !!         zw_eiv = -1/(e1t e2t) { di[ aeiu e2u mi(wslpi) ]
-      !!                               + dj[ aeiv e1v mj(wslpj) ] }
-      !!      add the eiv component to the model velocity:
-      !!         p.n = p.n + z._eiv
-      !!
-      !! ** Action  : - add to p.n the eiv component
-      !!----------------------------------------------------------------------
-      INTEGER                         , INTENT(in   ) ::   kt       ! ocean time-step index
-      INTEGER                         , INTENT(in   ) ::   kit000   ! first time step index
-      CHARACTER(len=3)                , INTENT(in   ) ::   cdtype   ! =TRA or TRC (tracer indicator)
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pun      ! in : 3 ocean velocity components 
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pvn      ! out: 3 ocean velocity components
-      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(inout) ::   pwn      ! increased by the eiv
-      !!
-      INTEGER  ::   ji, jj, jk                 ! dummy loop indices
-      REAL(wp) ::   zuwk, zuwk1, zuwi, zuwi1   ! local scalars
-      REAL(wp) ::   zvwk, zvwk1, zvwj, zvwj1   !   -      -
-# if defined key_diaeiv 
-      REAL(wp) ::   zztmp                      ! local scalar
-# endif  
-      REAL(wp), POINTER, DIMENSION(:,:) :: zu_eiv, zv_eiv, zw_eiv, z2d
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start( 'tra_adv_eiv')
-      !
-# if defined key_diaeiv 
-      CALL wrk_alloc( jpi, jpj, zu_eiv, zv_eiv, zw_eiv, z2d )
-# else
-      CALL wrk_alloc( jpi, jpj, zu_eiv, zv_eiv, zw_eiv )
-# endif
-
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_adv_eiv : eddy induced advection on ', cdtype,' :'
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~   add to velocity fields the eiv component'
-# if defined key_diaeiv 
-         IF( cdtype == 'TRA') THEN
-            u_eiv(:,:,:) = 0.e0
-            v_eiv(:,:,:) = 0.e0
-            w_eiv(:,:,:) = 0.e0
-         END IF
-# endif
-      ENDIF
-
-      zu_eiv(:,:) = 0.e0   ;   zv_eiv(:,:) = 0.e0   ;    zw_eiv(:,:) = 0.e0  
-      
-                                                    ! =================
-      DO jk = 1, jpkm1                              !  Horizontal slab
-         !                                          ! =================
-         DO jj = 1, jpjm1
-            DO ji = 1, fs_jpim1   ! vector opt.
-               zuwk = ( wslpi(ji,jj,jk  ) + wslpi(ji+1,jj,jk  ) ) * fsaeiu(ji,jj,jk  ) * umask(ji,jj,jk  )
-               zuwk1= ( wslpi(ji,jj,jk+1) + wslpi(ji+1,jj,jk+1) ) * fsaeiu(ji,jj,jk+1) * umask(ji,jj,jk+1)
-               zvwk = ( wslpj(ji,jj,jk  ) + wslpj(ji,jj+1,jk  ) ) * fsaeiv(ji,jj,jk  ) * vmask(ji,jj,jk  )
-               zvwk1= ( wslpj(ji,jj,jk+1) + wslpj(ji,jj+1,jk+1) ) * fsaeiv(ji,jj,jk+1) * vmask(ji,jj,jk+1)
-
-               zu_eiv(ji,jj) = 0.5 * umask(ji,jj,jk) * ( zuwk - zuwk1 ) 
-               zv_eiv(ji,jj) = 0.5 * vmask(ji,jj,jk) * ( zvwk - zvwk1 ) 
-   
-               pun(ji,jj,jk) = pun(ji,jj,jk) + e2u(ji,jj) * zu_eiv(ji,jj)
-               pvn(ji,jj,jk) = pvn(ji,jj,jk) + e1v(ji,jj) * zv_eiv(ji,jj)
-            END DO
-         END DO
-# if defined key_diaeiv 
-         IF( cdtype == 'TRA') THEN
-            u_eiv(:,:,jk) = zu_eiv(:,:) / fse3u(:,:,jk)
-            v_eiv(:,:,jk) = zv_eiv(:,:) / fse3v(:,:,jk)
-         END IF
-# endif
-         IF( jk >=2 ) THEN                             ! jk=1 zw_eiv=0, not computed
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-# if defined key_traldf_c2d || defined key_traldf_c3d
-                  zuwi  = ( wslpi(ji,jj,jk)+wslpi(ji-1,jj,jk) ) * fsaeiu(ji-1,jj,jk) * e2u(ji-1,jj) * umask(ji-1,jj,jk)
-                  zuwi1 = ( wslpi(ji,jj,jk)+wslpi(ji+1,jj,jk) ) * fsaeiu(ji  ,jj,jk) * e2u(ji  ,jj) * umask(ji  ,jj,jk)
-                  zvwj  = ( wslpj(ji,jj,jk)+wslpj(ji,jj-1,jk) ) * fsaeiv(ji,jj-1,jk) * e1v(ji,jj-1) * vmask(ji,jj-1,jk)
-                  zvwj1 = ( wslpj(ji,jj,jk)+wslpj(ji,jj+1,jk) ) * fsaeiv(ji,jj  ,jk) * e1v(ji  ,jj) * vmask(ji  ,jj,jk)
-  
-                  zw_eiv(ji,jj) = - 0.5 * tmask(ji,jj,jk) * ( zuwi1 - zuwi + zvwj1 - zvwj ) 
-# else
-                  zuwi  = ( wslpi(ji,jj,jk) + wslpi(ji-1,jj,jk) ) * e2u(ji-1,jj) * umask(ji-1,jj,jk)
-                  zuwi1 = ( wslpi(ji,jj,jk) + wslpi(ji+1,jj,jk) ) * e2u(ji  ,jj) * umask(ji  ,jj,jk)
-                  zvwj  = ( wslpj(ji,jj,jk) + wslpj(ji,jj-1,jk) ) * e1v(ji,jj-1) * vmask(ji,jj-1,jk)
-                  zvwj1 = ( wslpj(ji,jj,jk) + wslpj(ji,jj+1,jk) ) * e1v(ji  ,jj) * vmask(ji  ,jj,jk)
-
-                  zw_eiv(ji,jj) = - 0.5 * tmask(ji,jj,jk) * fsaeiw(ji,jj,jk) * ( zuwi1 - zuwi + zvwj1 - zvwj )
-# endif
-                  pwn(ji,jj,jk) = pwn(ji,jj,jk) + zw_eiv(ji,jj)
-               END DO
-            END DO
-# if defined key_diaeiv 
-            IF( cdtype == 'TRA')  w_eiv(:,:,jk) = zw_eiv(:,:) / ( e1t(:,:) * e2t(:,:) )
-# endif
-         ENDIF
-         !                                          ! =================
-      END DO                                        !    End of slab  
-      !                                             ! =================
-
-# if defined key_diaeiv 
-      IF( cdtype == 'TRA') THEN
-         CALL iom_put( "uoce_eiv", u_eiv )    ! i-eiv current
-         CALL iom_put( "voce_eiv", v_eiv )    ! j-eiv current
-         CALL iom_put( "woce_eiv", w_eiv )    ! vert. eiv current
-         IF( iom_use('ueiv_heattr') ) THEN
-            zztmp = 0.5 * rau0 * rcp 
-            z2d(:,:) = 0.e0 
-            DO jk = 1, jpkm1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
-                     z2d(ji,jj) = z2d(ji,jj) + u_eiv(ji,jj,jk) &
-                       &         * (tsn(ji,jj,jk,jp_tem)+tsn(ji+1,jj,jk,jp_tem)) * e2u(ji,jj) * fse3u(ji,jj,jk) 
-                  END DO
-               END DO
-            END DO
-            CALL lbc_lnk( z2d, 'U', -1. )
-            CALL iom_put( "ueiv_heattr", zztmp * z2d )                  ! heat transport in i-direction
-         ENDIF
-            
-         IF( iom_use('veiv_heattr') ) THEN
-            zztmp = 0.5 * rau0 * rcp 
-            z2d(:,:) = 0.e0 
-            DO jk = 1, jpkm1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1   ! vector opt.
-                     z2d(ji,jj) = z2d(ji,jj) + v_eiv(ji,jj,jk) &
-                     &           * (tsn(ji,jj,jk,jp_tem)+tsn(ji,jj+1,jk,jp_tem)) * e1v(ji,jj) * fse3v(ji,jj,jk) 
-                  END DO
-               END DO
-            END DO
-            CALL lbc_lnk( z2d, 'V', -1. )
-            CALL iom_put( "veiv_heattr", zztmp * z2d )                  !  heat transport in i-direction
-         ENDIF
-    END IF
-# endif  
-      ! 
-# if defined key_diaeiv 
-      CALL wrk_dealloc( jpi, jpj, zu_eiv, zv_eiv, zw_eiv, z2d )
-# else
-      CALL wrk_dealloc( jpi, jpj, zu_eiv, zv_eiv, zw_eiv )
-# endif
-      !
-      IF( nn_timing == 1 )  CALL timing_stop( 'tra_adv_eiv')
-      !
-    END SUBROUTINE tra_adv_eiv
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Dummy module :             No rotation of the lateral mixing tensor
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE tra_adv_eiv( kt, kit000, pun, pvn, pwn, cdtype )              ! Empty routine
-      INTEGER  ::   kt    
-      INTEGER  ::   kit000    
-      CHARACTER(len=3) ::   cdtype
-      REAL, DIMENSION(:,:,:) ::   pun, pvn, pwn
-      WRITE(*,*) 'tra_adv_eiv: You should not have seen this print! error?',   &
-         &    kt, cdtype, pun(1,1,1), pvn(1,1,1), pwn(1,1,1)
-   END SUBROUTINE tra_adv_eiv
-#endif
-
-   !!==============================================================================
-END MODULE traadv_eiv
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_fct.F90	(revision 6041)
@@ -0,0 +1,808 @@
+MODULE traadv_fct
+   !!==============================================================================
+   !!                       ***  MODULE  traadv_fct  ***
+   !! Ocean  tracers:  horizontal & vertical advective trend (2nd/4th order Flux Corrected Transport method)
+   !!==============================================================================
+   !! History :  3.7  !  2015-09  (L. Debreu, G. Madec)  original code (inspired from traadv_tvd.F90)
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!  tra_adv_fct    : update the tracer trend with a 3D advective trends using a 2nd or 4th order FCT scheme
+   !!  tra_adv_fct_zts: update the tracer trend with a 3D advective trends using a 2nd order FCT scheme 
+   !!                   with sub-time-stepping in the vertical direction
+   !!  nonosc         : compute monotonic tracer fluxes by a non-oscillatory algorithm 
+   !!  interp_4th_cpt : 4th order compact scheme for the vertical component of the advection
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers
+   USE dom_oce        ! ocean space and time domain
+   USE trc_oce        ! share passive tracers/Ocean variables
+   USE trd_oce        ! trends: ocean variables
+   USE trdtra         ! tracers trends
+   USE diaptr         ! poleward transport diagnostics
+   !
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! MPP library
+   USE lbclnk         ! ocean lateral boundary condition (or mpp link) 
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_fct        ! routine called by traadv.F90
+   PUBLIC   tra_adv_fct_zts    ! routine called by traadv.F90
+   PUBLIC   interp_4th_cpt     ! routine called by traadv_cen.F90
+
+   LOGICAL  ::   l_trd   ! flag to compute trends
+   REAL(wp) ::   r1_6 = 1._wp / 6._wp   ! =1/6
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tra_adv_fct( kt, kit000, cdtype, p2dt, pun, pvn, pwn,       &
+      &                                              ptb, ptn, pta, kjpt, kn_fct_h, kn_fct_v )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_fct  ***
+      !! 
+      !! **  Purpose :   Compute the now trend due to total advection of 
+      !!       tracers and add it to the general trend of tracer equations
+      !!
+      !! **  Method  : - 2nd or 4th FCT scheme on the horizontal direction
+      !!               (choice through the value of kn_fct)
+      !!               - 4th order compact scheme on the vertical 
+      !!               - corrected flux (monotonic correction) 
+      !!
+      !! ** Action : - update (pta) with the now advective tracer trends
+      !!             - send the trends for further diagnostics
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
+      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
+      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
+      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kn_fct_h        ! order of the FCT scheme (=2 or 4)
+      INTEGER                              , INTENT(in   ) ::   kn_fct_v        ! order of the FCT scheme (=2 or 4)
+      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb, ptn        ! before and now tracer fields
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
+      !
+      INTEGER  ::   ji, jj, jk, jn                           ! dummy loop indices  
+      REAL(wp) ::   z2dtt, ztra                              ! local scalar
+      REAL(wp) ::   zfp_ui, zfp_vj, zfp_wk, zC2t_u, zC4t_u   !   -      -
+      REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk, zC2t_v, zC4t_v   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zwi, zwx, zwy, zwz, ztu, ztv, zltu, zltv, ztw
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   ztrdx, ztrdy, ztrdz
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('tra_adv_fct')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zwi, zwx, zwy, zwz, ztu, ztv, zltu, zltv, ztw )
+      !
+      IF( kt == kit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_fct : FCT advection scheme on ', cdtype
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+      !
+      l_trd = .FALSE.
+      IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) )   l_trd = .TRUE.
+      !
+      IF( l_trd )  THEN
+         CALL wrk_alloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
+         ztrdx(:,:,:) = 0._wp   ;    ztrdy(:,:,:) = 0._wp   ;   ztrdz(:,:,:) = 0._wp
+      ENDIF
+      !
+      !                                         ! surface & bottom value : flux set to zero one for all
+      IF( lk_vvl )   zwz(:,:, 1 ) = 0._wp                ! except at the surface in linear free surface case
+      zwx(:,:,jpk) = 0._wp   ;   zwy(:,:,jpk) = 0._wp    ;    zwz(:,:,jpk) = 0._wp
+      !
+      zwi(:,:,:) = 0._wp        
+      !                                                          ! ===========
+      DO jn = 1, kjpt                                            ! tracer loop
+         !                                                       ! ===========
+         !
+         !        !==  upstream advection with initial mass fluxes & intermediate update  ==!
+         !                    !* upstream tracer flux in the i and j direction 
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ! upstream scheme
+                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )
+                  zfm_ui = pun(ji,jj,jk) - ABS( pun(ji,jj,jk) )
+                  zfp_vj = pvn(ji,jj,jk) + ABS( pvn(ji,jj,jk) )
+                  zfm_vj = pvn(ji,jj,jk) - ABS( pvn(ji,jj,jk) )
+                  zwx(ji,jj,jk) = 0.5 * ( zfp_ui * ptb(ji,jj,jk,jn) + zfm_ui * ptb(ji+1,jj  ,jk,jn) )
+                  zwy(ji,jj,jk) = 0.5 * ( zfp_vj * ptb(ji,jj,jk,jn) + zfm_vj * ptb(ji  ,jj+1,jk,jn) )
+               END DO
+            END DO
+         END DO
+         !                    !* upstream tracer flux in the k direction *!
+         DO jk = 2, jpkm1         ! Interior value ( multiplied by wmask)
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zfp_wk = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
+                  zfm_wk = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
+                  zwz(ji,jj,jk) = 0.5 * ( zfp_wk * ptb(ji,jj,jk,jn) + zfm_wk * ptb(ji,jj,jk-1,jn) ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !                    
+         IF(.NOT.lk_vvl ) THEN   ! top ocean value (only in linear free surface as zwz has been w-masked)
+            IF( ln_isfcav ) THEN             ! top of the ice-shelf cavities and at the ocean surface
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn)   ! linear free surface 
+                  END DO
+               END DO   
+            ELSE                             ! no cavities: only at the ocean surface
+               zwz(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)
+            ENDIF
+         ENDIF
+         !               
+         DO jk = 1, jpkm1     !* trend and after field with monotonic scheme
+            z2dtt = p2dt(jk)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! total intermediate advective trends
+                  ztra = - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                     &      + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
+                  ! update and guess with monotonic sheme
+!!gm why tmask added in the two following lines ???    the mask is done in tranxt !
+                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra   * tmask(ji,jj,jk)
+                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( zwi, 'T', 1. )  ! Lateral boundary conditions on zwi  (unchanged sign)
+         !                
+         IF( l_trd )  THEN             ! trend diagnostics (contribution of upstream fluxes)
+            ztrdx(:,:,:) = zwx(:,:,:)   ;    ztrdy(:,:,:) = zwy(:,:,:)  ;   ztrdz(:,:,:) = zwz(:,:,:)
+         END IF
+         !                             ! "Poleward" heat and salt transports (contribution of upstream fluxes)
+         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
+           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+         ENDIF
+         !
+         !
+         !        !==  anti-diffusive flux : high order minus low order  ==!
+         !
+         SELECT CASE( kn_fct_h )         !* horizontal anti-diffusive fluxes
+         !
+         CASE(  2  )                         ! 2nd order centered
+            DO jk = 1, jpkm1
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zwx(ji,jj,jk) = 0.5_wp * pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj,jk,jn) ) - zwx(ji,jj,jk)
+                     zwy(ji,jj,jk) = 0.5_wp * pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj+1,jk,jn) ) - zwy(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         CASE(  4  )                         ! 4th order centered
+            zltu(:,:,jpk) = 0._wp                            ! Bottom value : flux set to zero
+            zltv(:,:,jpk) = 0._wp
+            DO jk = 1, jpkm1                                 ! Laplacian
+               DO jj = 1, jpjm1                                   ! First derivative (gradient)
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     ztu(ji,jj,jk) = ( ptn(ji+1,jj  ,jk,jn) - ptn(ji,jj,jk,jn) ) * umask(ji,jj,jk)
+                     ztv(ji,jj,jk) = ( ptn(ji  ,jj+1,jk,jn) - ptn(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
+                  END DO
+               END DO
+               DO jj = 2, jpjm1                                   ! 
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     zltu(ji,jj,jk) = (  ztu(ji,jj,jk) + ztu(ji-1,jj,jk)  ) * r1_6
+                     zltv(ji,jj,jk) = (  ztv(ji,jj,jk) + ztv(ji,jj-1,jk)  ) * r1_6
+                  END DO
+               END DO
+            END DO
+            !
+            CALL lbc_lnk( zltu, 'T', 1. )   ;    CALL lbc_lnk( zltv, 'T', 1. )   ! Lateral boundary cond. (unchanged sgn)
+            !
+            DO jk = 1, jpkm1                                 ! Horizontal advective fluxes
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     zC2t_u = ptn(ji,jj,jk,jn) + ptn(ji+1,jj  ,jk,jn)   ! 2 x C2 interpolation of T at u- & v-points
+                     zC2t_v = ptn(ji,jj,jk,jn) + ptn(ji  ,jj+1,jk,jn)
+                     !                                                  ! C4 minus upstream advective fluxes 
+                     zwx(ji,jj,jk) =  0.5_wp * pun(ji,jj,jk) * ( zC2t_u + zltu(ji,jj,jk) - zltu(ji+1,jj,jk) ) - zwx(ji,jj,jk)
+                     zwy(ji,jj,jk) =  0.5_wp * pvn(ji,jj,jk) * ( zC2t_v + zltv(ji,jj,jk) - zltv(ji,jj+1,jk) ) - zwy(ji,jj,jk)
+                  END DO
+               END DO
+            END DO         
+            !
+         CASE(  41 )                         ! 4th order centered       ==>>   !!gm coding attempt   need to be tested
+            ztu(:,:,jpk) = 0._wp                             ! Bottom value : flux set to zero
+            ztv(:,:,jpk) = 0._wp
+            DO jk = 1, jpkm1                                 ! gradient
+               DO jj = 1, jpjm1                                   ! First derivative (gradient)
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     ztu(ji,jj,jk) = ( ptn(ji+1,jj  ,jk,jn) - ptn(ji,jj,jk,jn) ) * umask(ji,jj,jk)
+                     ztv(ji,jj,jk) = ( ptn(ji  ,jj+1,jk,jn) - ptn(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( ztu, 'U', -1. )   ;    CALL lbc_lnk( ztv, 'V', -1. )   ! Lateral boundary cond. (unchanged sgn)
+            !
+            DO jk = 1, jpkm1                                 ! Horizontal advective fluxes
+               DO jj = 2, jpjm1
+                  DO ji = 2, fs_jpim1   ! vector opt.
+                     zC2t_u = ptn(ji,jj,jk,jn) + ptn(ji+1,jj  ,jk,jn)   ! 2 x C2 interpolation of T at u- & v-points (x2)
+                     zC2t_v = ptn(ji,jj,jk,jn) + ptn(ji  ,jj+1,jk,jn)
+                     !                                                  ! C4 interpolation of T at u- & v-points (x2)
+                     zC4t_u =  zC2t_u + r1_6 * ( ztu(ji-1,jj  ,jk) - ztu(ji+1,jj  ,jk) )
+                     zC4t_v =  zC2t_v + r1_6 * ( ztv(ji  ,jj-1,jk) - ztv(ji  ,jj+1,jk) )
+                     !                                                  ! C4 minus upstream advective fluxes 
+                     zwx(ji,jj,jk) =  0.5_wp * pun(ji,jj,jk) * zC4t_u - zwx(ji,jj,jk)
+                     zwy(ji,jj,jk) =  0.5_wp * pvn(ji,jj,jk) * zC4t_v - zwy(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         END SELECT
+         !                                !* vertical anti-diffusive fluxes
+         SELECT CASE( kn_fct_v )                ! Interior values (w-masked)
+         !
+         CASE(  2  )                                  ! 2nd order centered
+            DO jk = 2, jpkm1    
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zwz(ji,jj,jk) =  ( 0.5_wp * pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) )   &
+                                       - zwz(ji,jj,jk) ) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         CASE(  4  )                                  ! 4th order COMPACT
+            !    
+            CALL interp_4th_cpt( ptn(:,:,:,jn) , ztw )         ! COMPACT interpolation of T at w-point
+            !
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zwz(ji,jj,jk) = ( pwn(ji,jj,jk) * ztw(ji,jj,jk) - zwz(ji,jj,jk) ) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !
+         END SELECT
+         !                                      ! top ocean value: high order = upstream  ==>>  zwz=0
+         zwz(:,:, 1 ) = 0._wp                   ! only ocean surface as interior zwz values have been w-masked
+         !
+         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )         ! Lateral bondary conditions
+         CALL lbc_lnk( zwz, 'W',  1. )
+
+         !        !==  monotonicity algorithm  ==!
+         !
+         CALL nonosc( ptb(:,:,:,jn), zwx, zwy, zwz, zwi, p2dt )
+
+
+         !        !==  final trend with corrected fluxes  ==!
+         !
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.  
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                     &                                   + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                     &                                   + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) &
+                     &                                / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         !
+         IF( l_trd ) THEN                 ! trend diagnostics (contribution of upstream fluxes)
+            ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:)  ! <<< Add to previously computed
+            ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:)  ! <<< Add to previously computed
+            ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:)  ! <<< Add to previously computed
+            !
+            CALL trd_tra( kt, cdtype, jn, jptra_xad, ztrdx, pun, ptn(:,:,:,jn) )
+            CALL trd_tra( kt, cdtype, jn, jptra_yad, ztrdy, pvn, ptn(:,:,:,jn) )
+            CALL trd_tra( kt, cdtype, jn, jptra_zad, ztrdz, pwn, ptn(:,:,:,jn) )
+            !
+            CALL wrk_dealloc( jpi,jpj,jpk,   ztrdx, ztrdy, ztrdz )
+         END IF
+         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
+         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) ) + htr_adv(:)
+           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) ) + str_adv(:)
+         ENDIF
+         !
+      END DO
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,    zwi, zwx, zwy, zwz, ztu, ztv, zltu, zltv, ztw )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_fct')
+      !
+   END SUBROUTINE tra_adv_fct
+
+
+   SUBROUTINE tra_adv_fct_zts( kt, kit000, cdtype, p2dt, pun, pvn, pwn,      &
+      &                                                  ptb, ptn, pta, kjpt, kn_fct_zts )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_adv_fct_zts  ***
+      !! 
+      !! **  Purpose :   Compute the now trend due to total advection of 
+      !!       tracers and add it to the general trend of tracer equations
+      !!
+      !! **  Method  :   TVD ZTS scheme, i.e. 2nd order centered scheme with
+      !!       corrected flux (monotonic correction). This version use sub-
+      !!       timestepping for the vertical advection which increases stability
+      !!       when vertical metrics are small.
+      !!       note: - this advection scheme needs a leap-frog time scheme
+      !!
+      !! ** Action : - update (pta) with the now advective tracer trends
+      !!             - save the trends 
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
+      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
+      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
+      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kn_fct_zts      ! number of number of vertical sub-timesteps
+      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb, ptn        ! before and now tracer fields
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
+      !
+      REAL(wp), DIMENSION( jpk )                           ::   zts             ! length of sub-timestep for vertical advection
+      REAL(wp), DIMENSION( jpk )                           ::   zr_p2dt         ! reciprocal of tracer timestep
+      INTEGER  ::   ji, jj, jk, jl, jn       ! dummy loop indices  
+      INTEGER  ::   jtb, jtn, jta   ! sub timestep pointers for leap-frog/euler forward steps
+      INTEGER  ::   jtaken          ! toggle for collecting appropriate fluxes from sub timesteps
+      REAL(wp) ::   z_rzts          ! Fractional length of Euler forward sub-timestep for vertical advection
+      REAL(wp) ::   z2dtt, ztra              ! local scalar
+      REAL(wp) ::   zfp_ui, zfp_vj, zfp_wk   !   -      -
+      REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk   !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:  )   ::   zwx_sav , zwy_sav
+      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zwi, zwx, zwy, zwz, zhdiv, zwzts, zwz_sav
+      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   ztrdx, ztrdy, ztrdz
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrs
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('tra_adv_fct_zts')
+      !
+      CALL wrk_alloc( jpi,jpj,             zwx_sav, zwy_sav )
+      CALL wrk_alloc( jpi,jpj, jpk,        zwx, zwy, zwz, zwi, zhdiv, zwzts, zwz_sav )
+      CALL wrk_alloc( jpi,jpj,jpk,kjpt+1,  ztrs )
+      !
+      IF( kt == kit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv_fct_zts : 2nd order FCT scheme with ', kn_fct_zts, ' vertical sub-timestep on ', cdtype
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+      !
+      l_trd = .FALSE.
+      IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) )   l_trd = .TRUE.
+      !
+      IF( l_trd )  THEN
+         CALL wrk_alloc( jpi,jpj,jpk,   ztrdx, ztrdy, ztrdz )
+         ztrdx(:,:,:) = 0._wp  ;    ztrdy(:,:,:) = 0._wp  ;   ztrdz(:,:,:) = 0._wp
+      ENDIF
+      !
+      zwi(:,:,:) = 0._wp
+      z_rzts = 1._wp / REAL( kn_fct_zts, wp )
+      zr_p2dt(:) = 1._wp / p2dt(:)
+      !
+      !                                                          ! ===========
+      DO jn = 1, kjpt                                            ! tracer loop
+         !                                                       ! ===========
+         ! 1. Bottom value : flux set to zero
+         ! ----------------------------------
+         zwx(:,:,jpk) = 0._wp   ;    zwz(:,:,jpk) = 0._wp
+         zwy(:,:,jpk) = 0._wp   ;    zwi(:,:,jpk) = 0._wp
+
+         ! 2. upstream advection with initial mass fluxes & intermediate update
+         ! --------------------------------------------------------------------
+         ! upstream tracer flux in the i and j direction
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  ! upstream scheme
+                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )
+                  zfm_ui = pun(ji,jj,jk) - ABS( pun(ji,jj,jk) )
+                  zfp_vj = pvn(ji,jj,jk) + ABS( pvn(ji,jj,jk) )
+                  zfm_vj = pvn(ji,jj,jk) - ABS( pvn(ji,jj,jk) )
+                  zwx(ji,jj,jk) = 0.5_wp * ( zfp_ui * ptb(ji,jj,jk,jn) + zfm_ui * ptb(ji+1,jj  ,jk,jn) )
+                  zwy(ji,jj,jk) = 0.5_wp * ( zfp_vj * ptb(ji,jj,jk,jn) + zfm_vj * ptb(ji  ,jj+1,jk,jn) )
+               END DO
+            END DO
+         END DO
+
+         ! upstream tracer flux in the k direction
+         DO jk = 2, jpkm1         ! Interior value
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zfp_wk = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
+                  zfm_wk = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
+                  zwz(ji,jj,jk) = 0.5_wp * ( zfp_wk * ptb(ji,jj,jk,jn) + zfm_wk * ptb(ji,jj,jk-1,jn) ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !                       ! top value
+         IF( lk_vvl ) THEN             ! variable volume: only k=1 as zwz is multiplied by wmask
+            zwz(:,:, 1 ) = 0._wp
+         ELSE                          ! linear free surface
+            IF( ln_isfcav ) THEN             ! ice-shelf cavities
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn) 
+                  END DO
+               END DO   
+            ELSE                             ! standard case
+               zwz(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)
+            ENDIF
+         ENDIF
+         !
+         DO jk = 1, jpkm1         ! total advective trend
+            z2dtt = p2dt(jk)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! total intermediate advective trends
+                  ztra = - (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
+                     &      + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
+                     &      + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) ) / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
+                  ! update and guess with monotonic sheme
+                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra
+                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !                           
+         CALL lbc_lnk( zwi, 'T', 1. )     ! Lateral boundary conditions on zwi  (unchanged sign)
+         !                
+         IF( l_trd )  THEN                ! trend diagnostics (contribution of upstream fluxes)
+            ztrdx(:,:,:) = zwx(:,:,:)   ;    ztrdy(:,:,:) = zwy(:,:,:)  ;   ztrdz(:,:,:) = zwz(:,:,:)
+         END IF
+         !                                ! "Poleward" heat and salt transports (contribution of upstream fluxes)
+         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
+           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+         ENDIF
+
+         ! 3. anti-diffusive flux : high order minus low order
+         ! ---------------------------------------------------
+
+         DO jk = 1, jpkm1                    !* horizontal anti-diffusive fluxes
+            !
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwx_sav(ji,jj) = zwx(ji,jj,jk)
+                  zwy_sav(ji,jj) = zwy(ji,jj,jk)
+                  !
+                  zwx(ji,jj,jk) = 0.5_wp * pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj,jk,jn) )
+                  zwy(ji,jj,jk) = 0.5_wp * pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj+1,jk,jn) )
+               END DO
+            END DO
+            !
+            DO jj = 2, jpjm1                    ! partial horizontal divergence
+               DO ji = fs_2, fs_jpim1
+                  zhdiv(ji,jj,jk) = (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk)   &
+                     &               + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk)  )
+               END DO
+            END DO
+            !
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwx(ji,jj,jk) = zwx(ji,jj,jk) - zwx_sav(ji,jj)
+                  zwy(ji,jj,jk) = zwy(ji,jj,jk) - zwy_sav(ji,jj)
+               END DO
+            END DO
+         END DO
+      
+         !                                !* vertical anti-diffusive flux
+         zwz_sav(:,:,:)   = zwz(:,:,:)
+         ztrs   (:,:,:,1) = ptb(:,:,:,jn)
+         zwzts  (:,:,:)   = 0._wp
+         IF( lk_vvl )   zwz(:,:, 1 ) = 0._wp    ! surface value set to zero in vvl case
+         !
+         DO jl = 1, kn_fct_zts                  ! Start of sub timestepping loop
+            !
+            IF( jl == 1 ) THEN                        ! Euler forward to kick things off
+               jtb = 1   ;   jtn = 1   ;   jta = 2
+               zts(:) = p2dt(:) * z_rzts
+               jtaken = MOD( kn_fct_zts + 1 , 2)            ! Toggle to collect every second flux
+               !                                            ! starting at jl =1 if kn_fct_zts is odd; 
+               !                                            ! starting at jl =2 otherwise
+            ELSEIF( jl == 2 ) THEN                    ! First leapfrog step
+               jtb = 1   ;   jtn = 2   ;   jta = 3
+               zts(:) = 2._wp * p2dt(:) * z_rzts
+            ELSE                                      ! Shuffle pointers for subsequent leapfrog steps
+               jtb = MOD(jtb,3) + 1
+               jtn = MOD(jtn,3) + 1
+               jta = MOD(jta,3) + 1
+            ENDIF
+            DO jk = 2, jpkm1                          ! interior value
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     zwz(ji,jj,jk) = 0.5_wp * pwn(ji,jj,jk) * ( ztrs(ji,jj,jk,jtn) + ztrs(ji,jj,jk-1,jtn) ) * wmask(ji,jj,jk)
+                     IF( jtaken == 0 )   zwzts(ji,jj,jk) = zwzts(ji,jj,jk) + zwz(ji,jj,jk) * zts(jk)    ! Accumulate time-weighted vertcal flux
+                  END DO
+               END DO
+            END DO
+            IF(.NOT.lk_vvl ) THEN                    ! top value (only in linear free surface case)
+               IF( ln_isfcav ) THEN                      ! ice-shelf cavities
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn)   ! linear free surface 
+                     END DO
+                  END DO   
+               ELSE                                      ! standard case
+                  zwz(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)
+               ENDIF
+            ENDIF
+            !
+            jtaken = MOD( jtaken + 1 , 2 )
+            !
+            DO jk = 2, jpkm1                             ! total advective trends
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ztrs(ji,jj,jk,jta) = ztrs(ji,jj,jk,jtb)                                                 &
+                        &               - zts(jk) * (  zhdiv(ji,jj,jk) + zwz(ji,jj,jk) - zwz(ji,jj,jk+1) )   &
+                        &                         / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  END DO
+               END DO
+            END DO
+            !
+         END DO
+
+         DO jk = 2, jpkm1          ! Anti-diffusive vertical flux using average flux from the sub-timestepping
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1
+                  zwz(ji,jj,jk) = ( zwzts(ji,jj,jk) * zr_p2dt(jk) - zwz_sav(ji,jj,jk) ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )         ! Lateral bondary conditions
+         CALL lbc_lnk( zwz, 'W',  1. )
+
+         ! 4. monotonicity algorithm
+         ! -------------------------
+         CALL nonosc( ptb(:,:,:,jn), zwx, zwy, zwz, zwi, p2dt )
+
+
+         ! 5. final trend with corrected fluxes
+         ! ------------------------------------
+         DO jk = 1, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.  
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + (   zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )       &
+                     &                                    + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1)   )   &
+                     &                                / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+
+         !                                 ! trend diagnostics (contribution of upstream fluxes)
+         IF( l_trd )  THEN 
+            ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:)  ! <<< Add to previously computed
+            ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:)  ! <<< Add to previously computed
+            ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:)  ! <<< Add to previously computed
+            !
+            CALL trd_tra( kt, cdtype, jn, jptra_xad, ztrdx, pun, ptn(:,:,:,jn) )   
+            CALL trd_tra( kt, cdtype, jn, jptra_yad, ztrdy, pvn, ptn(:,:,:,jn) )  
+            CALL trd_tra( kt, cdtype, jn, jptra_zad, ztrdz, pwn, ptn(:,:,:,jn) ) 
+            !
+            CALL wrk_dealloc( jpi,jpj,jpk,   ztrdx, ztrdy, ztrdz )
+         END IF
+         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
+         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) ) + htr_adv(:)
+           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) ) + str_adv(:)
+         ENDIF
+         !
+      END DO
+      !
+      CALL wrk_alloc( jpi,jpj,             zwx_sav, zwy_sav )
+      CALL wrk_alloc( jpi,jpj, jpk,        zwx, zwy, zwz, zwi, zhdiv, zwzts, zwz_sav )
+      CALL wrk_alloc( jpi,jpj,jpk,kjpt+1,  ztrs )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_fct_zts')
+      !
+   END SUBROUTINE tra_adv_fct_zts
+
+
+   SUBROUTINE nonosc( pbef, paa, pbb, pcc, paft, p2dt )
+      !!---------------------------------------------------------------------
+      !!                    ***  ROUTINE nonosc  ***
+      !!     
+      !! **  Purpose :   compute monotonic tracer fluxes from the upstream 
+      !!       scheme and the before field by a nonoscillatory algorithm 
+      !!
+      !! **  Method  :   ... ???
+      !!       warning : pbef and paft must be masked, but the boundaries
+      !!       conditions on the fluxes are not necessary zalezak (1979)
+      !!       drange (1995) multi-dimensional forward-in-time and upstream-
+      !!       in-space based differencing for fluid
+      !!----------------------------------------------------------------------
+      REAL(wp), DIMENSION(jpk)         , INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(in   ) ::   pbef, paft      ! before & after field
+      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(inout) ::   paa, pbb, pcc   ! monotonic fluxes in the 3 directions
+      !
+      INTEGER  ::   ji, jj, jk   ! dummy loop indices
+      INTEGER  ::   ikm1         ! local integer
+      REAL(wp) ::   zpos, zneg, zbt, za, zb, zc, zbig, zrtrn, z2dtt   ! local scalars
+      REAL(wp) ::   zau, zbu, zcu, zav, zbv, zcv, zup, zdo            !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zbetup, zbetdo, zbup, zbdo
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('nonosc')
+      !
+      CALL wrk_alloc( jpi, jpj, jpk, zbetup, zbetdo, zbup, zbdo )
+      !
+      zbig  = 1.e+40_wp
+      zrtrn = 1.e-15_wp
+      zbetup(:,:,:) = 0._wp   ;   zbetdo(:,:,:) = 0._wp
+
+      ! Search local extrema
+      ! --------------------
+      ! max/min of pbef & paft with large negative/positive value (-/+zbig) inside land
+      zbup = MAX( pbef * tmask - zbig * ( 1._wp - tmask ),   &
+         &        paft * tmask - zbig * ( 1._wp - tmask )  )
+      zbdo = MIN( pbef * tmask + zbig * ( 1._wp - tmask ),   &
+         &        paft * tmask + zbig * ( 1._wp - tmask )  )
+
+      DO jk = 1, jpkm1
+         ikm1 = MAX(jk-1,1)
+         z2dtt = p2dt(jk)
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+
+               ! search maximum in neighbourhood
+               zup = MAX(  zbup(ji  ,jj  ,jk  ),   &
+                  &        zbup(ji-1,jj  ,jk  ), zbup(ji+1,jj  ,jk  ),   &
+                  &        zbup(ji  ,jj-1,jk  ), zbup(ji  ,jj+1,jk  ),   &
+                  &        zbup(ji  ,jj  ,ikm1), zbup(ji  ,jj  ,jk+1)  )
+
+               ! search minimum in neighbourhood
+               zdo = MIN(  zbdo(ji  ,jj  ,jk  ),   &
+                  &        zbdo(ji-1,jj  ,jk  ), zbdo(ji+1,jj  ,jk  ),   &
+                  &        zbdo(ji  ,jj-1,jk  ), zbdo(ji  ,jj+1,jk  ),   &
+                  &        zbdo(ji  ,jj  ,ikm1), zbdo(ji  ,jj  ,jk+1)  )
+
+               ! positive part of the flux
+               zpos = MAX( 0., paa(ji-1,jj  ,jk  ) ) - MIN( 0., paa(ji  ,jj  ,jk  ) )   &
+                  & + MAX( 0., pbb(ji  ,jj-1,jk  ) ) - MIN( 0., pbb(ji  ,jj  ,jk  ) )   &
+                  & + MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
+
+               ! negative part of the flux
+               zneg = MAX( 0., paa(ji  ,jj  ,jk  ) ) - MIN( 0., paa(ji-1,jj  ,jk  ) )   &
+                  & + MAX( 0., pbb(ji  ,jj  ,jk  ) ) - MIN( 0., pbb(ji  ,jj-1,jk  ) )   &
+                  & + MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
+
+               ! up & down beta terms
+               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
+               zbetup(ji,jj,jk) = ( zup            - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt
+               zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo            ) / ( zneg + zrtrn ) * zbt
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( zbetup, 'T', 1. )   ;   CALL lbc_lnk( zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
+
+      ! 3. monotonic flux in the i & j direction (paa & pbb)
+      ! ----------------------------------------
+      DO jk = 1, jpkm1
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) )
+               zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
+               zcu =       ( 0.5  + SIGN( 0.5 , paa(ji,jj,jk) ) )
+               paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu )
+
+               zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
+               zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
+               zcv =       ( 0.5  + SIGN( 0.5 , pbb(ji,jj,jk) ) )
+               pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv )
+
+      ! monotonic flux in the k direction, i.e. pcc
+      ! -------------------------------------------
+               za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) )
+               zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) )
+               zc =       ( 0.5  + SIGN( 0.5 , pcc(ji,jj,jk+1) ) )
+               pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb )
+            END DO
+         END DO
+      END DO
+      CALL lbc_lnk( paa, 'U', -1. )   ;   CALL lbc_lnk( pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
+      !
+      CALL wrk_dealloc( jpi, jpj, jpk, zbetup, zbetdo, zbup, zbdo )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('nonosc')
+      !
+   END SUBROUTINE nonosc
+
+
+   SUBROUTINE interp_4th_cpt( pt_in, pt_out )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE interp_4th_cpt  ***
+      !! 
+      !! **  Purpose :   Compute the interpolation of tracer at w-point
+      !!
+      !! **  Method  :   4th order compact interpolation
+      !!----------------------------------------------------------------------
+      REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(in   ) ::   pt_in    ! now tracer fields
+      REAL(wp),DIMENSION(jpi,jpj,jpk), INTENT(  out) ::   pt_out   ! now tracer field interpolated at w-pts
+      !
+      INTEGER :: ji, jj, jk   ! dummy loop integers
+      REAL(wp),DIMENSION(jpi,jpj,jpk) :: zwd, zwi, zws, zwrm, zwt
+      !!----------------------------------------------------------------------
+      
+      DO jk = 3, jpkm1        !==  build the three diagonal matrix  ==!
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwd (ji,jj,jk) = 4._wp
+               zwi (ji,jj,jk) = 1._wp
+               zws (ji,jj,jk) = 1._wp
+               zwrm(ji,jj,jk) = 3._wp * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )
+               !
+               IF( tmask(ji,jj,jk+1) == 0._wp) THEN   ! Switch to second order centered at bottom
+                  zwd (ji,jj,jk) = 1._wp
+                  zwi (ji,jj,jk) = 0._wp
+                  zws (ji,jj,jk) = 0._wp
+                  zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )    
+               ENDIF
+            END DO
+         END DO
+      END DO
+      !
+      jk=2                                            ! Switch to second order centered at top
+      DO jj=1,jpj
+         DO ji=1,jpi
+            zwd (ji,jj,jk) = 1._wp
+            zwi (ji,jj,jk) = 0._wp
+            zws (ji,jj,jk) = 0._wp
+            zwrm(ji,jj,jk) = 0.5 * ( pt_in(ji,jj,jk-1) + pt_in(ji,jj,jk) )
+         END DO
+      END DO   
+      !
+      !                       !==  tridiagonal solve  ==!
+      DO jj = 1, jpj                ! first recurrence
+         DO ji = 1, jpi
+            zwt(ji,jj,2) = zwd(ji,jj,2)
+         END DO
+      END DO
+      DO jk = 3, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               zwt(ji,jj,jk) = zwd(ji,jj,jk) - zwi(ji,jj,jk) * zws(ji,jj,jk-1) /zwt(ji,jj,jk-1)
+            END DO
+         END DO
+      END DO
+      !
+      DO jj = 1, jpj                ! second recurrence:    Zk = Yk - Ik / Tk-1  Zk-1
+         DO ji = 1, jpi
+            pt_out(ji,jj,2) = zwrm(ji,jj,2)
+         END DO
+      END DO
+      DO jk = 3, jpkm1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               pt_out(ji,jj,jk) = zwrm(ji,jj,jk) - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) *pt_out(ji,jj,jk-1)             
+            END DO
+         END DO
+      END DO
+
+      DO jj = 1, jpj                ! third recurrence: Xk = (Zk - Sk Xk+1 ) / Tk
+         DO ji = 1, jpi
+            pt_out(ji,jj,jpkm1) = pt_out(ji,jj,jpkm1) / zwt(ji,jj,jpkm1)
+         END DO
+      END DO
+      DO jk = jpk-2, 2, -1
+         DO jj = 1, jpj
+            DO ji = 1, jpi
+               pt_out(ji,jj,jk) = ( pt_out(ji,jj,jk) - zws(ji,jj,jk) * pt_out(ji,jj,jk+1) ) / zwt(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !    
+   END SUBROUTINE interp_4th_cpt
+   
+   !!======================================================================
+END MODULE traadv_fct
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mle.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mle.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mle.F90	(revision 6041)
@@ -28,5 +28,5 @@
    PUBLIC   tra_adv_mle_init   ! routine called in traadv.F90
 
-   !                                               !!* namelist namtra_adv_mle *
+   !                                       !!* namelist namtra_adv_mle *
    LOGICAL, PUBLIC ::   ln_mle              ! flag to activate the Mixed Layer Eddy (MLE) parameterisation
    INTEGER         ::   nn_mle              ! MLE type: =0 standard Fox-Kemper ; =1 new formulation
@@ -34,10 +34,10 @@
    INTEGER         ::   nn_conv             ! =1 no MLE in case of convection ; =0 always MLE
    REAL(wp)        ::   rn_ce               ! MLE coefficient
-   !                                           ! parameters used in nn_mle = 0 case
+   !                                        ! parameters used in nn_mle = 0 case
    REAL(wp)        ::   rn_lf                  ! typical scale of mixed layer front
-   REAL(wp)        ::   rn_time             ! time scale for mixing momentum across the mixed layer
-   !                                             ! parameters used in nn_mle = 1 case
-   REAL(wp)        ::   rn_lat                   ! reference latitude for a 5 km scale of ML front
-   REAL(wp)        ::   rn_rho_c_mle         ! Density criterion for definition of MLD used by FK
+   REAL(wp)        ::   rn_time                ! time scale for mixing momentum across the mixed layer
+   !                                        ! parameters used in nn_mle = 1 case
+   REAL(wp)        ::   rn_lat                 ! reference latitude for a 5 km scale of ML front
+   REAL(wp)        ::   rn_rho_c_mle           ! Density criterion for definition of MLD used by FK
 
    REAL(wp) ::   r5_21 = 5.e0 / 21.e0   ! factor used in mle streamfunction computation
@@ -52,5 +52,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 4.0 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence (modipsl/doc/NEMO_CeCILL.txt)
@@ -80,5 +80,4 @@
       !!             Fox-Kemper and Ferrari, JPO, 38, 1166-1179, 2008
       !!----------------------------------------------------------------------
-      !
       INTEGER                         , INTENT(in   ) ::   kt         ! ocean time-step index
       INTEGER                         , INTENT(in   ) ::   kit000     ! first time step index
@@ -93,5 +92,5 @@
       REAL(wp) ::   zcvw, zmvw   !   -      -
       REAL(wp) ::   zc                                     !   -      -
-
+      !
       INTEGER  ::   ii, ij, ik              ! local integers
       INTEGER, DIMENSION(3) ::   ilocu      !
@@ -101,5 +100,5 @@
       INTEGER, POINTER, DIMENSION(:,:) :: inml_mle
       !!----------------------------------------------------------------------
-
+      !
       IF( nn_timing == 1 )  CALL timing_start('tra_adv_mle')
       CALL wrk_alloc( jpi, jpj, zpsim_u, zpsim_v, zmld, zbm, zhu, zhv, zn2, zLf_NH, zLf_MH)
@@ -171,11 +170,11 @@
          DO jj = 1, jpjm1
             DO ji = 1, fs_jpim1   ! vector opt.
-               zpsim_u(ji,jj) = rn_ce * zhu(ji,jj) * zhu(ji,jj)  * e2u(ji,jj)                                            &
-                  &           * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp          , e1u(ji,jj)                 )   &
-                  &           / (         e1u(ji,jj)          * MAX( rn_lf * rfu(ji,jj) , SQRT( rb_c * zhu(ji,jj) ) )   )
+               zpsim_u(ji,jj) = rn_ce * zhu(ji,jj) * zhu(ji,jj)  * e2_e1u(ji,jj)                                            &
+                  &           * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp , e1u(ji,jj) )   &
+                  &           / (  MAX( rn_lf * rfu(ji,jj) , SQRT( rb_c * zhu(ji,jj) ) )   )
                   !
-               zpsim_v(ji,jj) = rn_ce * zhv(ji,jj) * zhv(ji,jj)  * e1v(ji,jj)                                            &
-                  &           * ( zbm(ji,jj+1) - zbm(ji,jj) ) * MIN( 111.e3_wp          , e2v(ji,jj)                 )   &
-                  &           / (         e2v(ji,jj)          * MAX( rn_lf * rfv(ji,jj) , SQRT( rb_c * zhv(ji,jj) ) )   )
+               zpsim_v(ji,jj) = rn_ce * zhv(ji,jj) * zhv(ji,jj)  * e1_e2v(ji,jj)                                            &
+                  &           * ( zbm(ji,jj+1) - zbm(ji,jj) ) * MIN( 111.e3_wp , e2v(ji,jj) )   &
+                  &           / (  MAX( rn_lf * rfv(ji,jj) , SQRT( rb_c * zhv(ji,jj) ) )   )
             END DO
          END DO
@@ -184,8 +183,8 @@
          DO jj = 1, jpjm1
             DO ji = 1, fs_jpim1   ! vector opt.
-               zpsim_u(ji,jj) = rc_f *   zhu(ji,jj)   * zhu(ji,jj)   * e2u(ji,jj) / e1u(ji,jj)          &
+               zpsim_u(ji,jj) = rc_f *   zhu(ji,jj)   * zhu(ji,jj)   * e2_e1u(ji,jj)               &
                   &                  * ( zbm(ji+1,jj) - zbm(ji,jj) ) * MIN( 111.e3_wp , e1u(ji,jj) )
                   !
-               zpsim_v(ji,jj) = rc_f *   zhv(ji,jj)   * zhv(ji,jj)   * e1v(ji,jj) / e2v(ji,jj)          &
+               zpsim_v(ji,jj) = rc_f *   zhv(ji,jj)   * zhv(ji,jj)   * e1_e2v(ji,jj)               &
                   &                  * ( zbm(ji,jj+1) - zbm(ji,jj) ) * MIN( 111.e3_wp , e2v(ji,jj) )
             END DO
@@ -252,6 +251,6 @@
          ! divide by cross distance to give streamfunction with dimensions m^2/s
          DO jk = 1, ikmax+1
-            zpsi_uw(:,:,jk) = zpsi_uw(:,:,jk)/e2u(:,:)
-            zpsi_vw(:,:,jk) = zpsi_vw(:,:,jk)/e1v(:,:)
+            zpsi_uw(:,:,jk) = zpsi_uw(:,:,jk) * r1_e2u(:,:)
+            zpsi_vw(:,:,jk) = zpsi_vw(:,:,jk) * r1_e1v(:,:)
          END DO
          CALL iom_put( "psiu_mle", zpsi_uw )    ! i-mle streamfunction
@@ -281,5 +280,4 @@
       NAMELIST/namtra_adv_mle/ ln_mle , nn_mle, rn_ce, rn_lf, rn_time, rn_lat, nn_mld_uv, nn_conv, rn_rho_c_mle
       !!----------------------------------------------------------------------
-
 
       REWIND( numnam_ref )              ! Namelist namtra_adv_mle in reference namelist : Tracer advection scheme
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mus.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mus.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_mus.F90	(revision 6041)
@@ -0,0 +1,287 @@
+MODULE traadv_mus
+   !!======================================================================
+   !!                       ***  MODULE  traadv_mus  ***
+   !! Ocean  tracers:  horizontal & vertical advective trend
+   !!======================================================================
+   !! History :       !  2000-06  (A.Estublier)  for passive tracers
+   !!                 !  2001-08  (E.Durand, G.Madec)  adapted for T & S
+   !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
+   !!            3.2  !  2010-05  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
+   !!            3.4  !  2012-06  (P. Oddo, M. Vichi) include the upstream where needed
+   !!            3.7  !  2015-09  (G. Madec) add the ice-shelf cavities boundary condition
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_adv_mus   : update the tracer trend with the horizontal
+   !!                   and vertical advection trends using MUSCL scheme
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers
+   USE trc_oce        ! share passive tracers/Ocean variables
+   USE dom_oce        ! ocean space and time domain
+   USE trd_oce        ! trends: ocean variables
+   USE trdtra         ! tracers trends manager
+   USE sbcrnf         ! river runoffs
+   USE diaptr         ! poleward transport diagnostics
+   !
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! distribued memory computing
+   USE lbclnk         ! ocean lateral boundary condition (or mpp link) 
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_adv_mus   ! routine called by traadv.F90
+   
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   upsmsk   !: mixed upstream/centered scheme near some straits
+   !                                                           !  and in closed seas (orca 2 and 4 configurations)
+   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xind     !: mixed upstream/centered index
+   
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! $Id$ 
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tra_adv_mus( kt, kit000, cdtype, p2dt, pun, pvn, pwn,             &
+      &                                              ptb, pta, kjpt, ld_msc_ups )
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE tra_adv_mus  ***
+      !!
+      !! ** Purpose :   Compute the now trend due to total advection of tracers
+      !!              using a MUSCL scheme (Monotone Upstream-centered Scheme for
+      !!              Conservation Laws) and add it to the general tracer trend.
+      !!
+      !! ** Method  : MUSCL scheme plus centered scheme at ocean boundaries
+      !!              ld_msc_ups=T : 
+      !!
+      !! ** Action  : - update (ta,sa) with the now advective tracer trends
+      !!              - send trends to trdtra module for further diagnostcs
+      !!
+      !! References : Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
+      !!              IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
+      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
+      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
+      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
+      LOGICAL                              , INTENT(in   ) ::   ld_msc_ups      ! use upstream scheme within muscl
+      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb             ! before tracer field
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
+      !
+      INTEGER  ::   ji, jj, jk, jn       ! dummy loop indices
+      INTEGER  ::   ierr                 ! local integer
+      REAL(wp) ::   zu, z0u, zzwx, zw    ! local scalars
+      REAL(wp) ::   zv, z0v, zzwy, z0w   !   -      -
+      REAL(wp) ::   zdt, zalpha          !   -      -
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zslpx, zslpy   ! 3D workspace
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zwx  , zwy     ! -      - 
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('tra_adv_mus')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zslpx, zslpy, zwx, zwy )
+      !
+      IF( kt == kit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_adv : MUSCL advection scheme on ', cdtype
+         IF(lwp) WRITE(numout,*) '        : mixed up-stream           ', ld_msc_ups
+         IF(lwp) WRITE(numout,*) '~~~~~~~'
+         IF(lwp) WRITE(numout,*)
+         !
+         ! Upstream / MUSCL scheme indicator
+         !
+         ALLOCATE( xind(jpi,jpj,jpk), STAT=ierr )
+         xind(:,:,:) = 1._wp              ! set equal to 1 where up-stream is not needed
+         !
+         IF( ld_msc_ups ) THEN            ! define the upstream indicator (if asked)
+            ALLOCATE( upsmsk(jpi,jpj), STAT=ierr )
+            upsmsk(:,:) = 0._wp                             ! not upstream by default
+            !
+            DO jk = 1, jpkm1
+               xind(:,:,jk) = 1._wp                              &                 ! =>1 where up-stream is not needed
+                  &         - MAX ( rnfmsk(:,:) * rnfmsk_z(jk),  &                 ! =>0 near runoff mouths (& closed sea outflows)
+                  &                 upsmsk(:,:)                ) * tmask(:,:,jk)   ! =>0 in some user defined area
+            END DO
+         ENDIF 
+         !
+      ENDIF 
+      !      
+      !                                                     ! ===========
+      DO jn = 1, kjpt                                       ! tracer loop
+         !                                                  ! ===========
+         ! I. Horizontal advective fluxes
+         ! ------------------------------
+         ! first guess of the slopes
+         zwx(:,:,jpk) = 0.e0   ;   zwy(:,:,jpk) = 0.e0        ! bottom values
+         ! interior values
+         DO jk = 1, jpkm1
+            DO jj = 1, jpjm1      
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zwx(ji,jj,jk) = umask(ji,jj,jk) * ( ptb(ji+1,jj,jk,jn) - ptb(ji,jj,jk,jn) )
+                  zwy(ji,jj,jk) = vmask(ji,jj,jk) * ( ptb(ji,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
+               END DO
+           END DO
+         END DO
+         !
+         CALL lbc_lnk( zwx, 'U', -1. )                        ! lateral boundary conditions on zwx, zwy   (changed sign)
+         CALL lbc_lnk( zwy, 'V', -1. )
+         !                                             !-- Slopes of tracer
+         zslpx(:,:,jpk) = 0.e0   ;   zslpy(:,:,jpk) = 0.e0    ! bottom values
+         DO jk = 1, jpkm1                                     ! interior values
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  zslpx(ji,jj,jk) =                    ( zwx(ji,jj,jk) + zwx(ji-1,jj  ,jk) )   &
+                     &            * ( 0.25 + SIGN( 0.25, zwx(ji,jj,jk) * zwx(ji-1,jj  ,jk) ) )
+                  zslpy(ji,jj,jk) =                    ( zwy(ji,jj,jk) + zwy(ji  ,jj-1,jk) )   &
+                     &            * ( 0.25 + SIGN( 0.25, zwy(ji,jj,jk) * zwy(ji  ,jj-1,jk) ) )
+               END DO
+            END DO
+         END DO
+         !
+         DO jk = 1, jpkm1                                     ! Slopes limitation
+            DO jj = 2, jpj
+               DO ji = fs_2, jpi   ! vector opt.
+                  zslpx(ji,jj,jk) = SIGN( 1., zslpx(ji,jj,jk) ) * MIN(    ABS( zslpx(ji  ,jj,jk) ),   &
+                     &                                                 2.*ABS( zwx  (ji-1,jj,jk) ),   &
+                     &                                                 2.*ABS( zwx  (ji  ,jj,jk) ) )
+                  zslpy(ji,jj,jk) = SIGN( 1., zslpy(ji,jj,jk) ) * MIN(    ABS( zslpy(ji,jj  ,jk) ),   &
+                     &                                                 2.*ABS( zwy  (ji,jj-1,jk) ),   &
+                     &                                                 2.*ABS( zwy  (ji,jj  ,jk) ) )
+               END DO
+           END DO
+         END DO
+         !
+         !                                             !-- MUSCL horizontal advective fluxes
+         DO jk = 1, jpkm1                                     ! interior values
+            zdt  = p2dt(jk)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  ! MUSCL fluxes
+                  z0u = SIGN( 0.5, pun(ji,jj,jk) )
+                  zalpha = 0.5 - z0u
+                  zu  = z0u - 0.5 * pun(ji,jj,jk) * zdt / ( e1e2u(ji,jj) * fse3u(ji,jj,jk) )
+                  zzwx = ptb(ji+1,jj,jk,jn) + xind(ji,jj,jk) * zu * zslpx(ji+1,jj,jk)
+                  zzwy = ptb(ji  ,jj,jk,jn) + xind(ji,jj,jk) * zu * zslpx(ji  ,jj,jk)
+                  zwx(ji,jj,jk) = pun(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
+                  !
+                  z0v = SIGN( 0.5, pvn(ji,jj,jk) )
+                  zalpha = 0.5 - z0v
+                  zv  = z0v - 0.5 * pvn(ji,jj,jk) * zdt / ( e1e2v(ji,jj) * fse3v(ji,jj,jk) )
+                  zzwx = ptb(ji,jj+1,jk,jn) + xind(ji,jj,jk) * zv * zslpy(ji,jj+1,jk)
+                  zzwy = ptb(ji,jj  ,jk,jn) + xind(ji,jj,jk) * zv * zslpy(ji,jj  ,jk)
+                  zwy(ji,jj,jk) = pvn(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
+               END DO
+            END DO
+         END DO
+         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )   ! lateral boundary conditions   (changed sign)
+         !
+         DO jk = 1, jpkm1         ! Tracer flux divergence at t-point added to the general trend
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - ( zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )       &
+                  &                                     + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  ) )     &
+                  &                                   / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
+               END DO
+           END DO
+         END DO        
+         !                                 ! trend diagnostics (contribution of upstream fluxes)
+         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.   &
+            &( cdtype == 'TRC' .AND. l_trdtrc )      )  THEN
+            CALL trd_tra( kt, cdtype, jn, jptra_xad, zwx, pun, ptb(:,:,:,jn) )
+            CALL trd_tra( kt, cdtype, jn, jptra_yad, zwy, pvn, ptb(:,:,:,jn) )
+         END IF
+         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
+         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+            IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
+            IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+         ENDIF
+
+         ! II. Vertical advective fluxes
+         ! -----------------------------
+         !                                !-- first guess of the slopes
+         zwx(:,:, 1 ) = 0._wp                   ! surface & bottom boundary conditions
+         zwx(:,:,jpk) = 0._wp                   ! surface & bottom boundary conditions
+         DO jk = 2, jpkm1                                     ! interior values
+            zwx(:,:,jk) = tmask(:,:,jk) * ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) )
+         END DO
+
+         !                                !-- Slopes of tracer
+         zslpx(:,:,1) = 0._wp                   ! surface values
+         DO jk = 2, jpkm1                       ! interior value
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zslpx(ji,jj,jk) =                    ( zwx(ji,jj,jk) + zwx(ji,jj,jk+1) )   &
+                     &            * ( 0.25 + SIGN( 0.25, zwx(ji,jj,jk) * zwx(ji,jj,jk+1) ) )
+               END DO
+            END DO
+         END DO
+         !                                !-- Slopes limitation
+         DO jk = 2, jpkm1                       ! interior values
+            DO jj = 1, jpj
+               DO ji = 1, jpi
+                  zslpx(ji,jj,jk) = SIGN( 1., zslpx(ji,jj,jk) ) * MIN(    ABS( zslpx(ji,jj,jk  ) ),   &
+                     &                                                 2.*ABS( zwx  (ji,jj,jk+1) ),   &
+                     &                                                 2.*ABS( zwx  (ji,jj,jk  ) )  )
+               END DO
+            END DO
+         END DO
+         !                                !-- vertical advective flux
+         DO jk = 1, jpkm1                       ! interior values
+            zdt  = p2dt(jk)
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  z0w = SIGN( 0.5, pwn(ji,jj,jk+1) )
+                  zalpha = 0.5 + z0w
+                  zw  = z0w - 0.5 * pwn(ji,jj,jk+1) * zdt  / ( e1e2t(ji,jj) * fse3w(ji,jj,jk+1) )
+                  zzwx = ptb(ji,jj,jk+1,jn) + xind(ji,jj,jk) * zw * zslpx(ji,jj,jk+1)
+                  zzwy = ptb(ji,jj,jk  ,jn) + xind(ji,jj,jk) * zw * zslpx(ji,jj,jk  )
+                  zwx(ji,jj,jk+1) = pwn(ji,jj,jk+1) * ( zalpha * zzwx + (1.-zalpha) * zzwy ) * wmask(ji,jj,jk)
+               END DO 
+            END DO
+         END DO
+         !                                      ! top values  (bottom already set to zero)
+         IF( lk_vvl ) THEN                            !  variable volume
+            zwx(:,:, 1 ) = 0._wp                            ! k=1 only as zwx has been multiplied by wmask
+         ELSE                                         ! linear free surface 
+            IF( ln_isfcav ) THEN                            ! ice-shelf cavities (top of the ocean)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zwx(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn)
+                  END DO
+               END DO   
+            ELSE                                             ! no cavities: only at the ocean surface
+               zwx(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)
+            ENDIF
+         ENDIF
+         !
+         DO jk = 1, jpkm1                    ! Compute & add the vertical advective trend
+            DO jj = 2, jpjm1      
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  pta(ji,jj,jk,jn) =  pta(ji,jj,jk,jn) - ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) ) / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         !                                 ! Save the vertical advective trends for diagnostic
+         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.     &
+            &( cdtype == 'TRC' .AND. l_trdtrc )      )   &
+            CALL trd_tra( kt, cdtype, jn, jptra_zad, zwx, pwn, ptb(:,:,:,jn) )
+         !
+      END DO
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zslpx, zslpy, zwx, zwy )
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_mus')
+      !
+   END SUBROUTINE tra_adv_mus
+
+   !!======================================================================
+END MODULE traadv_mus
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl.F90	(revision 6040)
+++ 	(revision )
@@ -1,300 +1,0 @@
-MODULE traadv_muscl
-   !!======================================================================
-   !!                       ***  MODULE  traadv_muscl  ***
-   !! Ocean  tracers:  horizontal & vertical advective trend
-   !!======================================================================
-   !! History :       !  2000-06  (A.Estublier)  for passive tracers
-   !!                 !  2001-08  (E.Durand, G.Madec)  adapted for T & S
-   !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
-   !!            3.2  !  2010-05  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
-   !!            3.4  !  2012-06  (P. Oddo, M. Vichi) include the upstream where needed
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_adv_muscl : update the tracer trend with the horizontal
-   !!                   and vertical advection trends using MUSCL scheme
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and active tracers
-   USE trc_oce        ! share passive tracers/Ocean variables
-   USE dom_oce        ! ocean space and time domain
-   USE trd_oce        ! trends: ocean variables
-   USE trdtra         ! tracers trends manager
-   USE dynspg_oce     ! choice/control of key cpp for surface pressure gradient
-   USE sbcrnf         ! river runoffs
-   USE diaptr         ! poleward transport diagnostics
-   !
-   USE wrk_nemo       ! Memory Allocation
-   USE timing         ! Timing
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
-   USE in_out_manager ! I/O manager
-   USE lib_mpp        ! distribued memory computing
-   USE lbclnk         ! ocean lateral boundary condition (or mpp link) 
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_adv_muscl   ! routine called by traadv.F90
-   
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   upsmsk   !: mixed upstream/centered scheme near some straits
-   !                                                           !  and in closed seas (orca 2 and 4 configurations)
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   xind     !: mixed upstream/centered index
-   
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_adv_muscl( kt, kit000, cdtype, p2dt, pun, pvn, pwn,   &
-      &                                                ptb, pta, kjpt, ld_msc_ups )
-      !!----------------------------------------------------------------------
-      !!                    ***  ROUTINE tra_adv_muscl  ***
-      !!
-      !! ** Purpose :   Compute the now trend due to total advection of T and 
-      !!      S using a MUSCL scheme (Monotone Upstream-centered Scheme for
-      !!      Conservation Laws) and add it to the general tracer trend.
-      !!
-      !! ** Method  : MUSCL scheme plus centered scheme at ocean boundaries
-      !!
-      !! ** Action  : - update (ta,sa) with the now advective tracer trends
-      !!              - save trends 
-      !!
-      !! References : Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
-      !!              IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
-      !!----------------------------------------------------------------------
-      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
-      LOGICAL                              , INTENT(in   ) ::   ld_msc_ups      ! use upstream scheme within muscl
-      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb             ! before tracer field
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
-      !
-      INTEGER  ::   ji, jj, jk, jn            ! dummy loop indices
-      INTEGER  ::   ierr                      ! local integer
-      REAL(wp) ::   zu, z0u, zzwx, zw         ! local scalars
-      REAL(wp) ::   zv, z0v, zzwy, z0w        !   -      -
-      REAL(wp) ::   ztra, zbtr, zdt, zalpha   !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zslpx, zslpy   ! 3D workspace
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zwx  , zwy     ! -      - 
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_adv_muscl')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zslpx, zslpy, zwx, zwy )
-      !
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_adv : MUSCL advection scheme on ', cdtype
-         IF(lwp) WRITE(numout,*) '        : mixed up-stream           ', ld_msc_ups
-         IF(lwp) WRITE(numout,*) '~~~~~~~'
-         IF(lwp) WRITE(numout,*)
-         !
-         !
-         IF( ld_msc_ups ) THEN
-            IF( .NOT. ALLOCATED( upsmsk ) )  THEN
-                ALLOCATE( upsmsk(jpi,jpj), STAT=ierr )
-                IF( ierr /= 0 )   CALL ctl_stop('STOP', 'tra_adv_muscl: unable to allocate upsmsk array')
-            ENDIF
-            upsmsk(:,:) = 0._wp                             ! not upstream by default
-         ENDIF
-
-         IF( .NOT. ALLOCATED( xind ) ) THEN
-             ALLOCATE( xind(jpi,jpj,jpk), STAT=ierr )
-             IF( ierr /= 0 )   CALL ctl_stop('STOP', 'tra_adv_muscl: unable to allocate zind array')
-         ENDIF
-         !
-
-         !
-         ! Upstream / MUSCL scheme indicator
-         ! ------------------------------------
-!!gm  useless
-         xind(:,:,:) = 1._wp                             ! set equal to 1 where up-stream is not needed
-!!gm
-         !
-         IF( ld_msc_ups )  THEN
-            DO jk = 1, jpkm1
-               xind(:,:,jk) = 1._wp                              &                 ! =>1 where up-stream is not needed
-                  &         - MAX ( rnfmsk(:,:) * rnfmsk_z(jk),  &                 ! =>0 near runoff mouths (& closed sea outflows)
-                  &                 upsmsk(:,:)                ) * tmask(:,:,jk)   ! =>0 near some straits
-            END DO
-         ENDIF 
-         !
-      ENDIF 
-      !      
-      !                                                     ! ===========
-      DO jn = 1, kjpt                                       ! tracer loop
-         !                                                  ! ===========
-         ! I. Horizontal advective fluxes
-         ! ------------------------------
-         ! first guess of the slopes
-         zwx(:,:,jpk) = 0.e0   ;   zwy(:,:,jpk) = 0.e0        ! bottom values
-         ! interior values
-         DO jk = 1, jpkm1
-            DO jj = 1, jpjm1      
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwx(ji,jj,jk) = umask(ji,jj,jk) * ( ptb(ji+1,jj,jk,jn) - ptb(ji,jj,jk,jn) )
-                  zwy(ji,jj,jk) = vmask(ji,jj,jk) * ( ptb(ji,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
-               END DO
-           END DO
-         END DO
-         !
-         CALL lbc_lnk( zwx, 'U', -1. )                        ! lateral boundary conditions on zwx, zwy   (changed sign)
-         CALL lbc_lnk( zwy, 'V', -1. )
-         !                                             !-- Slopes of tracer
-         zslpx(:,:,jpk) = 0.e0   ;   zslpy(:,:,jpk) = 0.e0    ! bottom values
-         DO jk = 1, jpkm1                                     ! interior values
-            DO jj = 2, jpj
-               DO ji = fs_2, jpi   ! vector opt.
-                  zslpx(ji,jj,jk) =                    ( zwx(ji,jj,jk) + zwx(ji-1,jj  ,jk) )   &
-                     &            * ( 0.25 + SIGN( 0.25, zwx(ji,jj,jk) * zwx(ji-1,jj  ,jk) ) )
-                  zslpy(ji,jj,jk) =                    ( zwy(ji,jj,jk) + zwy(ji  ,jj-1,jk) )   &
-                     &            * ( 0.25 + SIGN( 0.25, zwy(ji,jj,jk) * zwy(ji  ,jj-1,jk) ) )
-               END DO
-            END DO
-         END DO
-         !
-         DO jk = 1, jpkm1                                     ! Slopes limitation
-            DO jj = 2, jpj
-               DO ji = fs_2, jpi   ! vector opt.
-                  zslpx(ji,jj,jk) = SIGN( 1., zslpx(ji,jj,jk) ) * MIN(    ABS( zslpx(ji  ,jj,jk) ),   &
-                     &                                                 2.*ABS( zwx  (ji-1,jj,jk) ),   &
-                     &                                                 2.*ABS( zwx  (ji  ,jj,jk) ) )
-                  zslpy(ji,jj,jk) = SIGN( 1., zslpy(ji,jj,jk) ) * MIN(    ABS( zslpy(ji,jj  ,jk) ),   &
-                     &                                                 2.*ABS( zwy  (ji,jj-1,jk) ),   &
-                     &                                                 2.*ABS( zwy  (ji,jj  ,jk) ) )
-               END DO
-           END DO
-         END DO             ! interior values
-
-         !                                             !-- MUSCL horizontal advective fluxes
-         DO jk = 1, jpkm1                                     ! interior values
-            zdt  = p2dt(jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ! MUSCL fluxes
-                  z0u = SIGN( 0.5, pun(ji,jj,jk) )
-                  zalpha = 0.5 - z0u
-                  zu  = z0u - 0.5 * pun(ji,jj,jk) * zdt / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
-                  zzwx = ptb(ji+1,jj,jk,jn) + xind(ji,jj,jk) * zu * zslpx(ji+1,jj,jk)
-                  zzwy = ptb(ji  ,jj,jk,jn) + xind(ji,jj,jk) * zu * zslpx(ji  ,jj,jk)
-                  zwx(ji,jj,jk) = pun(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
-                  !
-                  z0v = SIGN( 0.5, pvn(ji,jj,jk) )
-                  zalpha = 0.5 - z0v
-                  zv  = z0v - 0.5 * pvn(ji,jj,jk) * zdt / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
-                  zzwx = ptb(ji,jj+1,jk,jn) + xind(ji,jj,jk) * zv * zslpy(ji,jj+1,jk)
-                  zzwy = ptb(ji,jj  ,jk,jn) + xind(ji,jj,jk) * zv * zslpy(ji,jj  ,jk)
-                  zwy(ji,jj,jk) = pvn(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
-               END DO
-            END DO
-         END DO
-         !                                                    ! lateral boundary conditions on zwx, zwy   (changed sign)
-         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )
-         !
-         ! Tracer flux divergence at t-point added to the general trend
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1      
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! horizontal advective trends
-                  ztra = - zbtr * ( zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                  &               + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  ) )
-                  ! add it to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-           END DO
-         END DO        
-         !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.   &
-            &( cdtype == 'TRC' .AND. l_trdtrc )      )  THEN
-            CALL trd_tra( kt, cdtype, jn, jptra_xad, zwx, pun, ptb(:,:,:,jn) )
-            CALL trd_tra( kt, cdtype, jn, jptra_yad, zwy, pvn, ptb(:,:,:,jn) )
-         END IF
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-            IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-            IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
-         ENDIF
-
-         ! II. Vertical advective fluxes
-         ! -----------------------------
-         !                                             !-- first guess of the slopes
-         zwx (:,:, 1 ) = 0.e0    ;    zwx (:,:,jpk) = 0.e0    ! surface & bottom boundary conditions
-         DO jk = 2, jpkm1                                     ! interior values
-            zwx(:,:,jk) = tmask(:,:,jk) * ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) )
-         END DO
-
-         !                                             !-- Slopes of tracer
-         zslpx(:,:,1) = 0.e0                                  ! surface values
-         DO jk = 2, jpkm1                                     ! interior value
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zslpx(ji,jj,jk) =                    ( zwx(ji,jj,jk) + zwx(ji,jj,jk+1) )   &
-                     &            * ( 0.25 + SIGN( 0.25, zwx(ji,jj,jk) * zwx(ji,jj,jk+1) ) )
-               END DO
-            END DO
-         END DO
-         !                                             !-- Slopes limitation
-         DO jk = 2, jpkm1                                     ! interior values
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zslpx(ji,jj,jk) = SIGN( 1., zslpx(ji,jj,jk) ) * MIN(    ABS( zslpx(ji,jj,jk  ) ),   &
-                     &                                                 2.*ABS( zwx  (ji,jj,jk+1) ),   &
-                     &                                                 2.*ABS( zwx  (ji,jj,jk  ) )  )
-               END DO
-            END DO
-         END DO
-         !                                             !-- vertical advective flux
-         !                                                    ! surface values  (bottom already set to zero)
-         IF( lk_vvl ) THEN    ;   zwx(:,:, 1 ) = 0.e0                      !  variable volume
-         ELSE                 ;   zwx(:,:, 1 ) = pwn(:,:,1) * ptb(:,:,1,jn)   ! linear free surface
-         ENDIF 
-         !
-         DO jk = 1, jpkm1                                     ! interior values
-            zdt  = p2dt(jk)
-            DO jj = 2, jpjm1      
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3w(ji,jj,jk+1) )
-                  z0w = SIGN( 0.5, pwn(ji,jj,jk+1) )
-                  zalpha = 0.5 + z0w
-                  zw  = z0w - 0.5 * pwn(ji,jj,jk+1) * zdt * zbtr 
-                  zzwx = ptb(ji,jj,jk+1,jn) + xind(ji,jj,jk) * zw * zslpx(ji,jj,jk+1)
-                  zzwy = ptb(ji,jj,jk  ,jn) + xind(ji,jj,jk) * zw * zslpx(ji,jj,jk  )
-                  zwx(ji,jj,jk+1) = pwn(ji,jj,jk+1) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
-               END DO 
-            END DO
-         END DO
-
-         DO jk = 1, jpkm1                    ! Compute & add the vertical advective trend
-            DO jj = 2, jpjm1      
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! vertical advective trends 
-                  ztra = - zbtr * ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) )
-                  ! add it to the general tracer trends
-                  pta(ji,jj,jk,jn) =  pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-         END DO
-         !                                 ! Save the vertical advective trends for diagnostic
-         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.     &
-            &( cdtype == 'TRC' .AND. l_trdtrc )      )   &
-            CALL trd_tra( kt, cdtype, jn, jptra_zad, zwx, pwn, ptb(:,:,:,jn) )
-         !
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zslpx, zslpy, zwx, zwy )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_muscl')
-      !
-   END SUBROUTINE tra_adv_muscl
-
-   !!======================================================================
-END MODULE traadv_muscl
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl2.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl2.F90	(revision 6040)
+++ 	(revision )
@@ -1,293 +1,0 @@
-MODULE traadv_muscl2
-   !!======================================================================
-   !!                       ***  MODULE  traadv_muscl2  ***
-   !! Ocean  tracers:  horizontal & vertical advective trend
-   !!======================================================================
-   !! History :  1.0  !  2002-06  (G. Madec) from traadv_muscl
-   !!            3.2  !  2010-05  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_adv_muscl2 : update the tracer trend with the horizontal
-   !!                    and vertical advection trends using MUSCL2 scheme
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and active tracers
-   USE trc_oce         ! share passive tracers/Ocean variables
-   USE dom_oce         ! ocean space and time domain
-   USE trd_oce         ! trends: ocean variables
-   USE trdtra          ! trends manager: tracers 
-   USE in_out_manager  ! I/O manager
-   USE dynspg_oce      ! choice/control of key cpp for surface pressure gradient
-   USE diaptr          ! poleward transport diagnostics
-   !
-   USE lib_mpp         ! distribued memory computing
-   USE lbclnk          ! ocean lateral boundary condition (or mpp link) 
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-   USE lib_fortran     ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_adv_muscl2        ! routine called by step.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_adv_muscl2( kt, kit000, cdtype, p2dt, pun, pvn, pwn,      &
-      &                                         ptb, ptn, pta, kjpt )
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE tra_adv_muscl2  ***
-      !!
-      !! ** Purpose :   Compute the now trend due to total advection of T and 
-      !!      S using a MUSCL scheme (Monotone Upstream-centered Scheme for
-      !!      Conservation Laws) and add it to the general tracer trend.
-      !!
-      !! ** Method  : MUSCL scheme plus centered scheme at ocean boundaries
-      !!
-      !! ** Action  : - update (pta) with the now advective tracer trends
-      !!              - save trends 
-      !!
-      !! References : Estubier, A., and M. Levy, Notes Techn. Pole de Modelisation
-      !!              IPSL, Sept. 2000 (http://www.lodyc.jussieu.fr/opa)
-      !!----------------------------------------------------------------------
-      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
-      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb, ptn        ! before & now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
-      !!
-      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) ::   zu, z0u, zzwx, zw         ! local scalars
-      REAL(wp) ::   zv, z0v, zzwy, z0w        !   -      -
-      REAL(wp) ::   ztra, zbtr, zdt, zalpha   !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zslpx, zslpy , zwx, zwy
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_adv_muscl2')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zslpx, zslpy, zwx, zwy )
-      !
-
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_adv_muscl2 : MUSCL2 advection scheme on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~~'
-      ENDIF
-      !
-      !                                                          ! ===========
-      DO jn = 1, kjpt                                            ! tracer loop
-         !                                                       ! ===========
-         ! I. Horizontal advective fluxes
-         ! ------------------------------
-         ! first guess of the slopes
-         zwx(:,:,jpk) = 0.e0   ;   zwy(:,:,jpk) = 0.e0        ! bottom values
-         ! interior values
-         DO jk = 1, jpkm1
-            DO jj = 1, jpjm1      
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwx(ji,jj,jk) = umask(ji,jj,jk) * ( ptb(ji+1,jj,jk,jn) - ptb(ji,jj,jk,jn) )
-                  zwy(ji,jj,jk) = vmask(ji,jj,jk) * ( ptb(ji,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
-               END DO
-           END DO
-         END DO
-         !
-         CALL lbc_lnk( zwx, 'U', -1. )                        ! lateral boundary conditions on zwx, zwy   (changed sign)
-         CALL lbc_lnk( zwy, 'V', -1. )
-         !                                             !-- Slopes of tracer
-         zslpx(:,:,jpk) = 0.e0   ;   zslpy(:,:,jpk) = 0.e0    ! bottom values
-         DO jk = 1, jpkm1                                     ! interior values
-            DO jj = 2, jpj
-               DO ji = fs_2, jpi   ! vector opt.
-                  zslpx(ji,jj,jk) =                    ( zwx(ji,jj,jk) + zwx(ji-1,jj  ,jk) )   &
-                     &            * ( 0.25 + SIGN( 0.25, zwx(ji,jj,jk) * zwx(ji-1,jj  ,jk) ) )
-                  zslpy(ji,jj,jk) =                    ( zwy(ji,jj,jk) + zwy(ji  ,jj-1,jk) )   &
-                     &            * ( 0.25 + SIGN( 0.25, zwy(ji,jj,jk) * zwy(ji  ,jj-1,jk) ) )
-               END DO
-            END DO
-         END DO
-         !
-         DO jk = 1, jpkm1                                     ! Slopes limitation
-            DO jj = 2, jpj
-               DO ji = fs_2, jpi   ! vector opt.
-                  zslpx(ji,jj,jk) = SIGN( 1., zslpx(ji,jj,jk) ) * MIN(    ABS( zslpx(ji  ,jj,jk) ),   &
-                     &                                                 2.*ABS( zwx  (ji-1,jj,jk) ),   &
-                     &                                                 2.*ABS( zwx  (ji  ,jj,jk) ) )
-                  zslpy(ji,jj,jk) = SIGN( 1., zslpy(ji,jj,jk) ) * MIN(    ABS( zslpy(ji,jj  ,jk) ),   &
-                     &                                                 2.*ABS( zwy  (ji,jj-1,jk) ),   &
-                     &                                                 2.*ABS( zwy  (ji,jj  ,jk) ) )
-               END DO
-           END DO
-         END DO             ! interior values
-
-        !                                             !-- MUSCL horizontal advective fluxes
-         DO jk = 1, jpkm1                                     ! interior values
-            zdt  = p2dt(jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ! MUSCL fluxes
-                  z0u = SIGN( 0.5, pun(ji,jj,jk) )
-                  zalpha = 0.5 - z0u
-                  zu  = z0u - 0.5 * pun(ji,jj,jk) * zdt / ( e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk) )
-                  zzwx = ptb(ji+1,jj,jk,jn) + zu * zslpx(ji+1,jj,jk)
-                  zzwy = ptb(ji  ,jj,jk,jn) + zu * zslpx(ji  ,jj,jk)
-                  zwx(ji,jj,jk) = pun(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
-                  !
-                  z0v = SIGN( 0.5, pvn(ji,jj,jk) )
-                  zalpha = 0.5 - z0v
-                  zv  = z0v - 0.5 * pvn(ji,jj,jk) * zdt / ( e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk) )
-                  zzwx = ptb(ji,jj+1,jk,jn) + zv * zslpy(ji,jj+1,jk)
-                  zzwy = ptb(ji,jj  ,jk,jn) + zv * zslpy(ji,jj  ,jk)
-                  zwy(ji,jj,jk) = pvn(ji,jj,jk) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
-               END DO
-            END DO
-         END DO
-
-         !!  centered scheme at lateral b.C. if off-shore velocity
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( umask(ji,jj,jk) == 0. ) THEN
-                     IF( pun(ji+1,jj,jk) > 0. .AND. ji /= jpi ) THEN
-                        zwx(ji+1,jj,jk) = 0.5 * pun(ji+1,jj,jk) * ( ptn(ji+1,jj,jk,jn) + ptn(ji+2,jj,jk,jn) )
-                     ENDIF
-                     IF( pun(ji-1,jj,jk) < 0. ) THEN
-                        zwx(ji-1,jj,jk) = 0.5 * pun(ji-1,jj,jk) * ( ptn(ji-1,jj,jk,jn) + ptn(ji,jj,jk,jn) ) 
-                     ENDIF
-                  ENDIF
-                  IF( vmask(ji,jj,jk) == 0. ) THEN
-                     IF( pvn(ji,jj+1,jk) > 0. .AND. jj /= jpj ) THEN
-                        zwy(ji,jj+1,jk) = 0.5 * pvn(ji,jj+1,jk) * ( ptn(ji,jj+1,jk,jn) + ptn(ji,jj+2,jk,jn) )
-                     ENDIF
-                     IF( pvn(ji,jj-1,jk) < 0. ) THEN
-                        zwy(ji,jj-1,jk) = 0.5 * pvn(ji,jj-1,jk) * ( ptn(ji,jj-1,jk,jn) + ptn(ji,jj,jk,jn) ) 
-                     ENDIF
-                  ENDIF
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )   ! lateral boundary condition (changed sign)
-
-         ! Tracer flux divergence at t-point added to the general trend
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! horizontal advective trends 
-                  ztra = - zbtr * ( zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                  &               + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  ) )
-                  ! added to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-           END DO
-         END DO
-         !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.   &
-            &( cdtype == 'TRC' .AND. l_trdtrc )      ) THEN
-            CALL trd_tra( kt, cdtype, jn, jptra_xad, zwx, pun, ptb(:,:,:,jn) )
-            CALL trd_tra( kt, cdtype, jn, jptra_yad, zwy, pvn, ptb(:,:,:,jn) )
-         END IF
-
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-            IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
-         ENDIF
-
-         ! II. Vertical advective fluxes
-         ! -----------------------------
-         !                                             !-- first guess of the slopes
-         zwx (:,:, 1 ) = 0.e0    ;    zwx (:,:,jpk) = 0.e0    ! surface & bottom boundary conditions
-         DO jk = 2, jpkm1                                     ! interior values
-            zwx(:,:,jk) = tmask(:,:,jk) * ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) )
-         END DO
-
-         !                                             !-- Slopes of tracer
-         zslpx(:,:,1) = 0.e0                                  ! surface values
-         DO jk = 2, jpkm1                                     ! interior value
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zslpx(ji,jj,jk) =                    ( zwx(ji,jj,jk) + zwx(ji,jj,jk+1) )   &
-                     &            * ( 0.25 + SIGN( 0.25, zwx(ji,jj,jk) * zwx(ji,jj,jk+1) ) )
-               END DO
-            END DO
-         END DO
-         !                                             !-- Slopes limitation
-         DO jk = 2, jpkm1                                     ! interior values
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zslpx(ji,jj,jk) = SIGN( 1., zslpx(ji,jj,jk) ) * MIN(    ABS( zslpx(ji,jj,jk  ) ),   &
-                     &                                                 2.*ABS( zwx  (ji,jj,jk+1) ),   &
-                     &                                                 2.*ABS( zwx  (ji,jj,jk  ) )  )
-               END DO
-            END DO
-         END DO
-         !                                             !-- vertical advective flux
-         !                                                    ! surface values  (bottom already set to zero)
-         IF( lk_vvl ) THEN    ;   zwx(:,:, 1 ) = 0.e0                      !  variable volume
-         ELSE                 ;   zwx(:,:, 1 ) = pwn(:,:,1) * ptb(:,:,1,jn)   ! linear free surface
-         ENDIF
-         !
-         DO jk = 1, jpkm1                                     ! interior values
-            zdt  = p2dt(jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3w(ji,jj,jk+1) )
-                  z0w = SIGN( 0.5, pwn(ji,jj,jk+1) )
-                  zalpha = 0.5 + z0w
-                  zw  = z0w - 0.5 * pwn(ji,jj,jk+1) * zdt * zbtr
-                  zzwx = ptb(ji,jj,jk+1,jn) + zw * zslpx(ji,jj,jk+1)
-                  zzwy = ptb(ji,jj,jk  ,jn) + zw * zslpx(ji,jj,jk  )
-                  zwx(ji,jj,jk+1) = pwn(ji,jj,jk+1) * ( zalpha * zzwx + (1.-zalpha) * zzwy )
-               END DO
-            END DO
-         END DO
-         !
-         DO jk = 2, jpkm1        ! centered near the bottom
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  IF( tmask(ji,jj,jk+1) == 0. ) THEN
-                     IF( pwn(ji,jj,jk) > 0. ) THEN
-                        zwx(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk-1,jn) + ptn(ji,jj,jk,jn) ) 
-                     ENDIF
-                  ENDIF
-               END DO
-            END DO
-         END DO
-         !
-         DO jk = 1, jpkm1        ! Compute & add the vertical advective trend
-            DO jj = 2, jpjm1      
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! vertical advective trends 
-                  ztra = - zbtr * ( zwx(ji,jj,jk) - zwx(ji,jj,jk+1) )
-                  ! added to the general tracer trends
-                  pta(ji,jj,jk,jn) =  pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-         END DO
-         !                       ! trend diagnostics (contribution of upstream fluxes)
-         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR.     &
-            &( cdtype == 'TRC' .AND. l_trdtrc )      )   &
-            CALL trd_tra( kt, cdtype, jn, jptra_zad, zwx, pwn, ptb(:,:,:,jn) )
-         !
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zslpx, zslpy, zwx, zwy )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_muscl2')
-      !
-   END SUBROUTINE tra_adv_muscl2
-
-   !!======================================================================
-END MODULE traadv_muscl2
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_qck.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_qck.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_qck.F90	(revision 6041)
@@ -20,5 +20,4 @@
    USE trd_oce         ! trends: ocean variables
    USE trdtra          ! trends manager: tracers 
-   USE dynspg_oce      ! surface pressure gradient variables
    USE diaptr          ! poleward transport diagnostics
    !
@@ -102,4 +101,5 @@
          IF(lwp) WRITE(numout,*)
       ENDIF
+      !
       l_trd = .FALSE.
       IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) )   l_trd = .TRUE.
@@ -130,7 +130,7 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend 
       !!
-      INTEGER  :: ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) :: ztra, zbtr, zdir, zdx, zdt, zmsk   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwx, zfu, zfc, zfd
+      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
+      REAL(wp) ::   ztra, zbtr, zdir, zdx, zdt, zmsk   ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zwx, zfu, zfc, zfd
       !----------------------------------------------------------------------
       !
@@ -139,16 +139,13 @@
       DO jn = 1, kjpt                                            ! tracer loop
          !                                                       ! ===========
-         zfu(:,:,:) = 0.0     ;   zfc(:,:,:) = 0.0  
-         zfd(:,:,:) = 0.0     ;   zwx(:,:,:) = 0.0     
-         !                                                  
-         DO jk = 1, jpkm1                                
-            !                                             
-            !--- Computation of the ustream and downstream value of the tracer and the mask
+         zfu(:,:,:) = 0._wp     ;   zfc(:,:,:) = 0._wp 
+         zfd(:,:,:) = 0._wp     ;   zwx(:,:,:) = 0._wp   
+         !
+!!gm why not using a SHIFT instruction...
+         DO jk = 1, jpkm1     !--- Computation of the ustream and downstream value of the tracer and the mask
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ! Upstream in the x-direction for the tracer
-                  zfc(ji,jj,jk) = ptb(ji-1,jj,jk,jn)
-                  ! Downstream in the x-direction for the tracer
-                  zfd(ji,jj,jk) = ptb(ji+1,jj,jk,jn)
+                  zfc(ji,jj,jk) = ptb(ji-1,jj,jk,jn)        ! Upstream   in the x-direction for the tracer
+                  zfd(ji,jj,jk) = ptb(ji+1,jj,jk,jn)        ! Downstream in the x-direction for the tracer
                END DO
             END DO
@@ -159,5 +156,4 @@
          ! Horizontal advective fluxes
          ! ---------------------------
-         !
          DO jk = 1, jpkm1                             
             DO jj = 2, jpjm1
@@ -220,5 +216,5 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.  
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  zbtr = 1. / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
                   ! horizontal advective trends
                   ztra = - zbtr * ( zwx(ji,jj,jk) - zwx(ji-1,jj,jk) )
@@ -344,5 +340,5 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.  
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
+                  zbtr = 1. / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
                   ! horizontal advective trends
                   ztra = - zbtr * ( zwy(ji,jj,jk) - zwy(ji,jj-1,jk) )
@@ -380,36 +376,41 @@
       !
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) ::   zbtr , ztra      ! local scalars
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zwz
       !!----------------------------------------------------------------------
       !
-      CALL wrk_alloc( jpi, jpj, jpk, zwz )
+      CALL wrk_alloc( jpi,jpj,jpk,   zwz )
+      !
+      !                          ! surface & bottom values 
+      IF( lk_vvl )   zwz(:,:, 1 ) = 0._wp             ! set to zero one for all
+                     zwz(:,:,jpk) = 0._wp             ! except at the surface in linear free surface
+      !
       !                                                          ! ===========
       DO jn = 1, kjpt                                            ! tracer loop
          !                                                       ! ===========
-         ! 1. Bottom value : flux set to zero
-         zwz(:,:,jpk) = 0.e0             ! Bottom value : flux set to zero
-         !
-         !                                 ! Surface value
-         IF( lk_vvl ) THEN   ;   zwz(:,:, 1 ) = 0.e0                      ! Variable volume : flux set to zero
-         ELSE                ;   zwz(:,:, 1 ) = pwn(:,:,1) * ptn(:,:,1,jn)   ! Constant volume : advective flux through the surface
+         !
+         DO jk = 2, jpkm1                    !* Interior point   (w-masked 2nd order centered flux)
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  zwz(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk-1,jn) + ptn(ji,jj,jk,jn) ) * wmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         IF(.NOT.lk_vvl ) THEN               !* top value   (only in linear free surf. as zwz is multiplied by wmask)
+            IF( ln_isfcav ) THEN                  ! ice-shelf cavities (top of the ocean)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptn(ji,jj,mikt(ji,jj),jn)   ! linear free surface 
+                  END DO
+               END DO   
+            ELSE                                   ! no ice-shelf cavities (only ocean surface)
+               zwz(:,:,1) = pwn(:,:,1) * ptn(:,:,1,jn)
+            ENDIF
          ENDIF
          !
-         DO jk = 2, jpkm1                  ! Interior point: second order centered tracer flux at w-point
+         DO jk = 1, jpkm1          !==  Tracer flux divergence added to the general trend  ==!
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zwz(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk-1,jn) + ptn(ji,jj,jk,jn) )
-               END DO
-            END DO
-         END DO
-         !
-         DO jk = 1, jpkm1          !==  Tracer flux divergence added to the general trend  ==!
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! k- vertical advective trends 
-                  ztra = - zbtr * ( zwz(ji,jj,jk) - zwz(ji,jj,jk+1) ) 
-                  ! added to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - ( zwz(ji,jj,jk) - zwz(ji,jj,jk+1) )   &
+                     &                                / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
                END DO
             END DO
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 6040)
+++ 	(revision )
@@ -1,684 +1,0 @@
-MODULE traadv_tvd
-   !!==============================================================================
-   !!                       ***  MODULE  traadv_tvd  ***
-   !! Ocean  tracers:  horizontal & vertical advective trend
-   !!==============================================================================
-   !! History :  OPA  !  1995-12  (L. Mortier)  Original code
-   !!                 !  2000-01  (H. Loukos)  adapted to ORCA 
-   !!                 !  2000-10  (MA Foujols E.Kestenare)  include file not routine
-   !!                 !  2000-12  (E. Kestenare M. Levy)  fix bug in trtrd indexes
-   !!                 !  2001-07  (E. Durand G. Madec)  adaptation to ORCA config
-   !!            8.5  !  2002-06  (G. Madec)  F90: Free form and module
-   !!    NEMO    1.0  !  2004-01  (A. de Miranda, G. Madec, J.M. Molines ): advective bbl
-   !!            2.0  !  2008-04  (S. Cravatte) add the i-, j- & k- trends computation
-   !!             -   !  2009-11  (V. Garnier) Surface pressure gradient organization
-   !!            3.3  !  2010-05  (C. Ethe, G. Madec)  merge TRC-TRA + switch from velocity to transport
-   !!----------------------------------------------------------------------
-
-   !!----------------------------------------------------------------------
-   !!   tra_adv_tvd   : update the tracer trend with the 3D advection trends using a TVD scheme
-   !!   nonosc        : compute monotonic tracer fluxes by a non-oscillatory algorithm 
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and active tracers
-   USE dom_oce        ! ocean space and time domain
-   USE trc_oce        ! share passive tracers/Ocean variables
-   USE trd_oce        ! trends: ocean variables
-   USE trdtra         ! tracers trends
-   USE dynspg_oce     ! choice/control of key cpp for surface pressure gradient
-   USE diaptr         ! poleward transport diagnostics
-   !
-   USE lib_mpp        ! MPP library
-   USE lbclnk         ! ocean lateral boundary condition (or mpp link) 
-   USE in_out_manager ! I/O manager
-   USE wrk_nemo       ! Memory Allocation
-   USE timing         ! Timing
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_adv_tvd        ! routine called by traadv.F90
-   PUBLIC   tra_adv_tvd_zts    ! routine called by traadv.F90
-
-   LOGICAL ::   l_trd   ! flag to compute trends
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_adv_tvd ( kt, kit000, cdtype, p2dt, pun, pvn, pwn,      &
-      &                                       ptb, ptn, pta, kjpt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_adv_tvd  ***
-      !! 
-      !! **  Purpose :   Compute the now trend due to total advection of 
-      !!       tracers and add it to the general trend of tracer equations
-      !!
-      !! **  Method  :   TVD scheme, i.e. 2nd order centered scheme with
-      !!       corrected flux (monotonic correction)
-      !!       note: - this advection scheme needs a leap-frog time scheme
-      !!
-      !! ** Action : - update (pta) with the now advective tracer trends
-      !!             - save the trends 
-      !!----------------------------------------------------------------------
-      USE oce     , ONLY:   zwx => ua        , zwy => va          ! (ua,va) used as workspace
-      !
-      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
-      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb, ptn        ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
-      !
-      INTEGER  ::   ji, jj, jk, jn           ! dummy loop indices
-      INTEGER  ::   ik  
-      REAL(wp) ::   z2dtt, zbtr, ztra        ! local scalar
-      REAL(wp) ::   zfp_ui, zfp_vj, zfp_wk   !   -      -
-      REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk   !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwi, zwz
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdx, ztrdy, ztrdz
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_adv_tvd')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zwi, zwz )
-      !
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_adv_tvd : TVD advection scheme on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-         !
-         l_trd = .FALSE.
-         IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) ) l_trd = .TRUE.
-      ENDIF
-      !
-      IF( l_trd )  THEN
-         CALL wrk_alloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
-         ztrdx(:,:,:) = 0.e0   ;    ztrdy(:,:,:) = 0.e0   ;   ztrdz(:,:,:) = 0.e0
-      ENDIF
-      !
-      zwi(:,:,:) = 0.e0 ; 
-      !
-      !                                                          ! ===========
-      DO jn = 1, kjpt                                            ! tracer loop
-         !                                                       ! ===========
-         ! 1. Bottom and k=1 value : flux set to zero
-         ! ----------------------------------
-         zwx(:,:,jpk) = 0.e0    ;    zwz(:,:,jpk) = 0.e0
-         zwy(:,:,jpk) = 0.e0    ;    zwi(:,:,jpk) = 0.e0
-          
-         zwz(:,:,1  ) = 0._wp
-         ! 2. upstream advection with initial mass fluxes & intermediate update
-         ! --------------------------------------------------------------------
-         ! upstream tracer flux in the i and j direction
-         DO jk = 1, jpkm1
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  ! upstream scheme
-                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )
-                  zfm_ui = pun(ji,jj,jk) - ABS( pun(ji,jj,jk) )
-                  zfp_vj = pvn(ji,jj,jk) + ABS( pvn(ji,jj,jk) )
-                  zfm_vj = pvn(ji,jj,jk) - ABS( pvn(ji,jj,jk) )
-                  zwx(ji,jj,jk) = 0.5 * ( zfp_ui * ptb(ji,jj,jk,jn) + zfm_ui * ptb(ji+1,jj  ,jk,jn) )
-                  zwy(ji,jj,jk) = 0.5 * ( zfp_vj * ptb(ji,jj,jk,jn) + zfm_vj * ptb(ji  ,jj+1,jk,jn) )
-               END DO
-            END DO
-         END DO
-
-         ! upstream tracer flux in the k direction
-         ! Interior value
-         DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zfp_wk = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
-                  zfm_wk = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
-                  zwz(ji,jj,jk) = 0.5 * ( zfp_wk * ptb(ji,jj,jk,jn) + zfm_wk * ptb(ji,jj,jk-1,jn) ) * wmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         ! Surface value
-         IF( lk_vvl ) THEN   
-            IF ( ln_isfcav ) THEN
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     zwz(ji,jj, mikt(ji,jj) ) = 0.e0          ! volume variable
-                  END DO
-               END DO
-            ELSE
-               zwz(:,:,1) = 0.e0          ! volume variable
-            END IF
-         ELSE                
-            IF ( ln_isfcav ) THEN
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn)   ! linear free surface 
-                  END DO
-               END DO   
-            ELSE
-               zwz(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)   ! linear free surface
-            END IF
-         ENDIF
-
-         ! total advective trend
-         DO jk = 1, jpkm1
-            z2dtt = p2dt(jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! total intermediate advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &             + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
-                  ! update and guess with monotonic sheme
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra   * tmask(ji,jj,jk)
-                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         !                             ! Lateral boundary conditions on zwi  (unchanged sign)
-         CALL lbc_lnk( zwi, 'T', 1. )  
-
-         !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( l_trd )  THEN 
-            ! store intermediate advective trends
-            ztrdx(:,:,:) = zwx(:,:,:)   ;    ztrdy(:,:,:) = zwy(:,:,:)  ;   ztrdz(:,:,:) = zwz(:,:,:)
-         END IF
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
-         ENDIF
-
-         ! 3. antidiffusive flux : high order minus low order
-         ! --------------------------------------------------
-         ! antidiffusive flux on i and j
-         DO jk = 1, jpkm1
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwx(ji,jj,jk) = 0.5 * pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj,jk,jn) ) - zwx(ji,jj,jk)
-                  zwy(ji,jj,jk) = 0.5 * pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj+1,jk,jn) ) - zwy(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-      
-         ! antidiffusive flux on k
-         ! Interior value
-         DO jk = 2, jpkm1                    
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zwz(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) ) - zwz(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         ! surface value
-         IF ( ln_isfcav ) THEN
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zwz(ji,jj,mikt(ji,jj)) = 0.e0
-               END DO
-            END DO
-         ELSE
-            zwz(:,:,1) = 0.e0
-         END IF
-         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )         ! Lateral bondary conditions
-         CALL lbc_lnk( zwz, 'W',  1. )
-
-         ! 4. monotonicity algorithm
-         ! -------------------------
-         CALL nonosc( ptb(:,:,:,jn), zwx, zwy, zwz, zwi, p2dt )
-
-
-         ! 5. final trend with corrected fluxes
-         ! ------------------------------------
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.  
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! total advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &             + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
-                  ! add them to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra * tmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-
-         !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( l_trd )  THEN 
-            ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:)  ! <<< Add to previously computed
-            ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:)  ! <<< Add to previously computed
-            ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:)  ! <<< Add to previously computed
-            
-            CALL trd_tra( kt, cdtype, jn, jptra_xad, ztrdx, pun, ptn(:,:,:,jn) )   
-            CALL trd_tra( kt, cdtype, jn, jptra_yad, ztrdy, pvn, ptn(:,:,:,jn) )  
-            CALL trd_tra( kt, cdtype, jn, jptra_zad, ztrdz, pwn, ptn(:,:,:,jn) ) 
-         END IF
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) ) + htr_adv(:)
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) ) + str_adv(:)
-         ENDIF
-         !
-      END DO
-      !
-                   CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwz )
-      IF( l_trd )  CALL wrk_dealloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_tvd')
-      !
-   END SUBROUTINE tra_adv_tvd
-
-   SUBROUTINE tra_adv_tvd_zts ( kt, kit000, cdtype, p2dt, pun, pvn, pwn,      &
-      &                                       ptb, ptn, pta, kjpt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_adv_tvd_zts  ***
-      !! 
-      !! **  Purpose :   Compute the now trend due to total advection of 
-      !!       tracers and add it to the general trend of tracer equations
-      !!
-      !! **  Method  :   TVD ZTS scheme, i.e. 2nd order centered scheme with
-      !!       corrected flux (monotonic correction). This version use sub-
-      !!       timestepping for the vertical advection which increases stability
-      !!       when vertical metrics are small.
-      !!       note: - this advection scheme needs a leap-frog time scheme
-      !!
-      !! ** Action : - update (pta) with the now advective tracer trends
-      !!             - save the trends 
-      !!----------------------------------------------------------------------
-      USE oce     , ONLY:   zwx => ua        , zwy => va          ! (ua,va) used as workspace
-      !
-      INTEGER                              , INTENT(in   ) ::   kt              ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
-      REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean velocity components
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb, ptn        ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta             ! tracer trend 
-      !
-      REAL(wp), DIMENSION( jpk )                           ::   zts             ! length of sub-timestep for vertical advection
-      REAL(wp), DIMENSION( jpk )                           ::   zr_p2dt         ! reciprocal of tracer timestep
-      INTEGER  ::   ji, jj, jk, jl, jn       ! dummy loop indices  
-      INTEGER  ::   jnzts = 5       ! number of sub-timesteps for vertical advection
-      INTEGER  ::   jtb, jtn, jta   ! sub timestep pointers for leap-frog/euler forward steps
-      INTEGER  ::   jtaken          ! toggle for collecting appropriate fluxes from sub timesteps
-      REAL(wp) ::   z_rzts          ! Fractional length of Euler forward sub-timestep for vertical advection
-      REAL(wp) ::   z2dtt, zbtr, ztra        ! local scalar
-      REAL(wp) ::   zfp_ui, zfp_vj, zfp_wk   !   -      -
-      REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk   !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zwx_sav , zwy_sav
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zwi, zwz, zhdiv, zwz_sav, zwzts
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdx, ztrdy, ztrdz
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) :: ztrs
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_adv_tvd_zts')
-      !
-      CALL wrk_alloc( jpi, jpj, zwx_sav, zwy_sav )
-      CALL wrk_alloc( jpi, jpj, jpk, zwi, zwz , zhdiv, zwz_sav, zwzts )
-      CALL wrk_alloc( jpi, jpj, jpk, 3, ztrs )
-      !
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_adv_tvd_zts : TVD ZTS advection scheme on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-      ENDIF
-      !
-      l_trd = .FALSE.
-      IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) ) l_trd = .TRUE.
-      !
-      IF( l_trd )  THEN
-         CALL wrk_alloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
-         ztrdx(:,:,:) = 0._wp  ;    ztrdy(:,:,:) = 0._wp  ;   ztrdz(:,:,:) = 0._wp
-      ENDIF
-      !
-      zwi(:,:,:) = 0._wp
-      z_rzts = 1._wp / REAL( jnzts, wp )
-      zr_p2dt(:) = 1._wp / p2dt(:)
-      !
-      !                                                          ! ===========
-      DO jn = 1, kjpt                                            ! tracer loop
-         !                                                       ! ===========
-         ! 1. Bottom value : flux set to zero
-         ! ----------------------------------
-         zwx(:,:,jpk) = 0._wp   ;    zwz(:,:,jpk) = 0._wp
-         zwy(:,:,jpk) = 0._wp   ;    zwi(:,:,jpk) = 0._wp
-
-         ! 2. upstream advection with initial mass fluxes & intermediate update
-         ! --------------------------------------------------------------------
-         ! upstream tracer flux in the i and j direction
-         DO jk = 1, jpkm1
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  ! upstream scheme
-                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )
-                  zfm_ui = pun(ji,jj,jk) - ABS( pun(ji,jj,jk) )
-                  zfp_vj = pvn(ji,jj,jk) + ABS( pvn(ji,jj,jk) )
-                  zfm_vj = pvn(ji,jj,jk) - ABS( pvn(ji,jj,jk) )
-                  zwx(ji,jj,jk) = 0.5_wp * ( zfp_ui * ptb(ji,jj,jk,jn) + zfm_ui * ptb(ji+1,jj  ,jk,jn) )
-                  zwy(ji,jj,jk) = 0.5_wp * ( zfp_vj * ptb(ji,jj,jk,jn) + zfm_vj * ptb(ji  ,jj+1,jk,jn) )
-               END DO
-            END DO
-         END DO
-
-         ! upstream tracer flux in the k direction
-         ! Interior value
-         DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zfp_wk = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
-                  zfm_wk = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
-                  zwz(ji,jj,jk) = 0.5_wp * ( zfp_wk * ptb(ji,jj,jk,jn) + zfm_wk * ptb(ji,jj,jk-1,jn) )
-               END DO
-            END DO
-         END DO
-         ! Surface value
-         IF( lk_vvl ) THEN
-            IF ( ln_isfcav ) THEN
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     zwz(ji,jj, mikt(ji,jj) ) = 0.e0          ! volume variable +    isf
-                  END DO
-               END DO
-            ELSE
-               zwz(:,:,1) = 0.e0                              ! volume variable + no isf
-            END IF
-         ELSE
-            IF ( ln_isfcav ) THEN
-               DO jj = 1, jpj
-                  DO ji = 1, jpi
-                     zwz(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn)   ! linear free surface +    isf
-                  END DO
-               END DO
-            ELSE
-               zwz(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)                                               ! linear free surface + no isf
-            END IF
-         ENDIF
-
-         ! total advective trend
-         DO jk = 1, jpkm1
-            z2dtt = p2dt(jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1._wp / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! total intermediate advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &             + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
-                  ! update and guess with monotonic sheme
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn)         + ztra
-                  zwi(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ztra ) * tmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         !                             ! Lateral boundary conditions on zwi  (unchanged sign)
-         CALL lbc_lnk( zwi, 'T', 1. )  
-
-         !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( l_trd )  THEN 
-            ! store intermediate advective trends
-            ztrdx(:,:,:) = zwx(:,:,:)   ;    ztrdy(:,:,:) = zwy(:,:,:)  ;   ztrdz(:,:,:) = zwz(:,:,:)
-         END IF
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
-         ENDIF
-
-         ! 3. antidiffusive flux : high order minus low order
-         ! --------------------------------------------------
-         ! antidiffusive flux on i and j
-
-
-         DO jk = 1, jpkm1
-
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwx_sav(ji,jj) = zwx(ji,jj,jk)
-                  zwy_sav(ji,jj) = zwy(ji,jj,jk)
-
-                  zwx(ji,jj,jk) = 0.5_wp * pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj,jk,jn) )
-                  zwy(ji,jj,jk) = 0.5_wp * pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj+1,jk,jn) )
-               END DO
-            END DO
-
-            DO jj = 2, jpjm1         ! partial horizontal divergence
-               DO ji = fs_2, fs_jpim1
-                  zhdiv(ji,jj,jk) = (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk)   &
-                     &               + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk)  )
-               END DO
-            END DO
-
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zwx(ji,jj,jk) = zwx(ji,jj,jk)  - zwx_sav(ji,jj)
-                  zwy(ji,jj,jk) = zwy(ji,jj,jk)  - zwy_sav(ji,jj)
-               END DO
-            END DO
-         END DO
-      
-         ! antidiffusive flux on k
-         zwz(:,:,1) = 0._wp        ! Surface value
-         zwz_sav(:,:,:) = zwz(:,:,:)
-         !
-         ztrs(:,:,:,1) = ptb(:,:,:,jn)
-         zwzts(:,:,:) = 0._wp
-
-         DO jl = 1, jnzts                   ! Start of sub timestepping loop
-
-            IF( jl == 1 ) THEN              ! Euler forward to kick things off
-              jtb = 1   ;   jtn = 1   ;   jta = 2
-              zts(:) = p2dt(:) * z_rzts
-              jtaken = MOD( jnzts + 1 , 2)  ! Toggle to collect every second flux
-                                            ! starting at jl =1 if jnzts is odd; 
-                                            ! starting at jl =2 otherwise
-            ELSEIF( jl == 2 ) THEN          ! First leapfrog step
-              jtb = 1   ;   jtn = 2   ;   jta = 3
-              zts(:) = 2._wp * p2dt(:) * z_rzts
-            ELSE                            ! Shuffle pointers for subsequent leapfrog steps
-              jtb = MOD(jtb,3) + 1
-              jtn = MOD(jtn,3) + 1
-              jta = MOD(jta,3) + 1
-            ENDIF
-            DO jk = 2, jpkm1          ! Interior value
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1
-                     zwz(ji,jj,jk) = 0.5_wp * pwn(ji,jj,jk) * ( ztrs(ji,jj,jk,jtn) + ztrs(ji,jj,jk-1,jtn) )
-                     IF( jtaken == 0 ) zwzts(ji,jj,jk) = zwzts(ji,jj,jk) + zwz(ji,jj,jk)*zts(jk)           ! Accumulate time-weighted vertcal flux
-                  END DO
-               END DO
-            END DO
-
-            jtaken = MOD( jtaken + 1 , 2 )
-
-            DO jk = 2, jpkm1          ! Interior value
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1
-                     zbtr = 1._wp / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                     ! total advective trends
-                     ztra = - zbtr * (  zhdiv(ji,jj,jk) + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
-                     ztrs(ji,jj,jk,jta) = ztrs(ji,jj,jk,jtb) + zts(jk) * ztra
-                  END DO
-               END DO
-            END DO
-
-         END DO
-
-         DO jk = 2, jpkm1          ! Anti-diffusive vertical flux using average flux from the sub-timestepping
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1
-                  zwz(ji,jj,jk) = zwzts(ji,jj,jk) * zr_p2dt(jk) - zwz_sav(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         CALL lbc_lnk( zwx, 'U', -1. )   ;   CALL lbc_lnk( zwy, 'V', -1. )         ! Lateral bondary conditions
-         CALL lbc_lnk( zwz, 'W',  1. )
-
-         ! 4. monotonicity algorithm
-         ! -------------------------
-         CALL nonosc( ptb(:,:,:,jn), zwx, zwy, zwz, zwi, p2dt )
-
-
-         ! 5. final trend with corrected fluxes
-         ! ------------------------------------
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.  
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! total advective trends
-                  ztra = - zbtr * (  zwx(ji,jj,jk) - zwx(ji-1,jj  ,jk  )   &
-                     &             + zwy(ji,jj,jk) - zwy(ji  ,jj-1,jk  )   &
-                     &             + zwz(ji,jj,jk) - zwz(ji  ,jj  ,jk+1) )
-                  ! add them to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-         END DO
-
-         !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( l_trd )  THEN 
-            ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:)  ! <<< Add to previously computed
-            ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:)  ! <<< Add to previously computed
-            ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:)  ! <<< Add to previously computed
-            
-            CALL trd_tra( kt, cdtype, jn, jptra_xad, ztrdx, pun, ptn(:,:,:,jn) )   
-            CALL trd_tra( kt, cdtype, jn, jptra_yad, ztrdy, pvn, ptn(:,:,:,jn) )  
-            CALL trd_tra( kt, cdtype, jn, jptra_zad, ztrdz, pwn, ptn(:,:,:,jn) ) 
-         END IF
-         !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) ) + htr_adv(:)
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) ) + str_adv(:)
-         ENDIF
-         !
-      END DO
-      !
-                   CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwz, zhdiv, zwz_sav, zwzts )
-                   CALL wrk_dealloc( jpi, jpj, jpk, 3, ztrs )
-                   CALL wrk_dealloc( jpi, jpj, zwx_sav, zwy_sav )
-      IF( l_trd )  CALL wrk_dealloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_adv_tvd_zts')
-      !
-   END SUBROUTINE tra_adv_tvd_zts
-
-   SUBROUTINE nonosc( pbef, paa, pbb, pcc, paft, p2dt )
-      !!---------------------------------------------------------------------
-      !!                    ***  ROUTINE nonosc  ***
-      !!     
-      !! **  Purpose :   compute monotonic tracer fluxes from the upstream 
-      !!       scheme and the before field by a nonoscillatory algorithm 
-      !!
-      !! **  Method  :   ... ???
-      !!       warning : pbef and paft must be masked, but the boundaries
-      !!       conditions on the fluxes are not necessary zalezak (1979)
-      !!       drange (1995) multi-dimensional forward-in-time and upstream-
-      !!       in-space based differencing for fluid
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpk)         , INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
-      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(in   ) ::   pbef, paft      ! before & after field
-      REAL(wp), DIMENSION (jpi,jpj,jpk), INTENT(inout) ::   paa, pbb, pcc   ! monotonic fluxes in the 3 directions
-      !
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      INTEGER  ::   ikm1         ! local integer
-      REAL(wp) ::   zpos, zneg, zbt, za, zb, zc, zbig, zrtrn, z2dtt   ! local scalars
-      REAL(wp) ::   zau, zbu, zcu, zav, zbv, zcv, zup, zdo            !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zbetup, zbetdo, zbup, zbdo
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('nonosc')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zbetup, zbetdo, zbup, zbdo )
-      !
-      zbig  = 1.e+40_wp
-      zrtrn = 1.e-15_wp
-      zbetup(:,:,:) = 0._wp   ;   zbetdo(:,:,:) = 0._wp
-
-      ! Search local extrema
-      ! --------------------
-      ! max/min of pbef & paft with large negative/positive value (-/+zbig) inside land
-      zbup = MAX( pbef * tmask - zbig * ( 1._wp - tmask ),   &
-         &        paft * tmask - zbig * ( 1._wp - tmask )  )
-      zbdo = MIN( pbef * tmask + zbig * ( 1._wp - tmask ),   &
-         &        paft * tmask + zbig * ( 1._wp - tmask )  )
-
-      DO jk = 1, jpkm1
-         ikm1 = MAX(jk-1,1)
-         z2dtt = p2dt(jk)
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-
-               ! search maximum in neighbourhood
-               zup = MAX(  zbup(ji  ,jj  ,jk  ),   &
-                  &        zbup(ji-1,jj  ,jk  ), zbup(ji+1,jj  ,jk  ),   &
-                  &        zbup(ji  ,jj-1,jk  ), zbup(ji  ,jj+1,jk  ),   &
-                  &        zbup(ji  ,jj  ,ikm1), zbup(ji  ,jj  ,jk+1)  )
-
-               ! search minimum in neighbourhood
-               zdo = MIN(  zbdo(ji  ,jj  ,jk  ),   &
-                  &        zbdo(ji-1,jj  ,jk  ), zbdo(ji+1,jj  ,jk  ),   &
-                  &        zbdo(ji  ,jj-1,jk  ), zbdo(ji  ,jj+1,jk  ),   &
-                  &        zbdo(ji  ,jj  ,ikm1), zbdo(ji  ,jj  ,jk+1)  )
-
-               ! positive part of the flux
-               zpos = MAX( 0., paa(ji-1,jj  ,jk  ) ) - MIN( 0., paa(ji  ,jj  ,jk  ) )   &
-                  & + MAX( 0., pbb(ji  ,jj-1,jk  ) ) - MIN( 0., pbb(ji  ,jj  ,jk  ) )   &
-                  & + MAX( 0., pcc(ji  ,jj  ,jk+1) ) - MIN( 0., pcc(ji  ,jj  ,jk  ) )
-
-               ! negative part of the flux
-               zneg = MAX( 0., paa(ji  ,jj  ,jk  ) ) - MIN( 0., paa(ji-1,jj  ,jk  ) )   &
-                  & + MAX( 0., pbb(ji  ,jj  ,jk  ) ) - MIN( 0., pbb(ji  ,jj-1,jk  ) )   &
-                  & + MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
-
-               ! up & down beta terms
-               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
-               zbetup(ji,jj,jk) = ( zup            - paft(ji,jj,jk) ) / ( zpos + zrtrn ) * zbt
-               zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zdo            ) / ( zneg + zrtrn ) * zbt
-            END DO
-         END DO
-      END DO
-      CALL lbc_lnk( zbetup, 'T', 1. )   ;   CALL lbc_lnk( zbetdo, 'T', 1. )   ! lateral boundary cond. (unchanged sign)
-
-      ! 3. monotonic flux in the i & j direction (paa & pbb)
-      ! ----------------------------------------
-      DO jk = 1, jpkm1
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1   ! vector opt.
-               zau = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji+1,jj,jk) )
-               zbu = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji+1,jj,jk) )
-               zcu =       ( 0.5  + SIGN( 0.5 , paa(ji,jj,jk) ) )
-               paa(ji,jj,jk) = paa(ji,jj,jk) * ( zcu * zau + ( 1._wp - zcu) * zbu )
-
-               zav = MIN( 1._wp, zbetdo(ji,jj,jk), zbetup(ji,jj+1,jk) )
-               zbv = MIN( 1._wp, zbetup(ji,jj,jk), zbetdo(ji,jj+1,jk) )
-               zcv =       ( 0.5  + SIGN( 0.5 , pbb(ji,jj,jk) ) )
-               pbb(ji,jj,jk) = pbb(ji,jj,jk) * ( zcv * zav + ( 1._wp - zcv) * zbv )
-
-      ! monotonic flux in the k direction, i.e. pcc
-      ! -------------------------------------------
-               za = MIN( 1., zbetdo(ji,jj,jk+1), zbetup(ji,jj,jk) )
-               zb = MIN( 1., zbetup(ji,jj,jk+1), zbetdo(ji,jj,jk) )
-               zc =       ( 0.5  + SIGN( 0.5 , pcc(ji,jj,jk+1) ) )
-               pcc(ji,jj,jk+1) = pcc(ji,jj,jk+1) * ( zc * za + ( 1._wp - zc) * zb )
-            END DO
-         END DO
-      END DO
-      CALL lbc_lnk( paa, 'U', -1. )   ;   CALL lbc_lnk( pbb, 'V', -1. )   ! lateral boundary condition (changed sign)
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zbetup, zbetdo, zbup, zbdo )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('nonosc')
-      !
-   END SUBROUTINE nonosc
-
-   !!======================================================================
-END MODULE traadv_tvd
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_ubs.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_ubs.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_ubs.F90	(revision 6041)
@@ -16,6 +16,6 @@
    USE trc_oce        ! share passive tracers/Ocean variables
    USE trd_oce        ! trends: ocean variables
+   USE traadv_fct      ! acces to routine interp_4th_cpt 
    USE trdtra         ! trends manager: tracers 
-   USE dynspg_oce     ! choice/control of key cpp for surface pressure gradient
    USE diaptr         ! poleward transport diagnostics
    !
@@ -38,5 +38,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -44,6 +44,6 @@
 CONTAINS
 
-   SUBROUTINE tra_adv_ubs ( kt, kit000, cdtype, p2dt, pun, pvn, pwn,      &
-      &                                       ptb, ptn, pta, kjpt )
+   SUBROUTINE tra_adv_ubs( kt, kit000, cdtype, p2dt, pun, pvn, pwn,          &
+      &                                                ptb, ptn, pta, kjpt, kn_ubs_v )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE tra_adv_ubs  ***
@@ -52,5 +52,5 @@
       !!      and add it to the general trend of passive tracer equations.
       !!
-      !! ** Method  :   The upstream biased scheme (UBS) is based on a 3rd order
+      !! ** Method  :   The 3rd order Upstream Biased Scheme (UBS) is based on an
       !!      upstream-biased parabolic interpolation (Shchepetkin and McWilliams 2005)
       !!      It is only used in the horizontal direction.
@@ -61,14 +61,17 @@
       !!      where zltu is the second derivative of the before temperature field:
       !!          zltu = 1/e3t di[ e2u e3u / e1u di[Tb] ]
-      !!      This results in a dissipatively dominant (i.e. hyper-diffusive) 
+      !!        This results in a dissipatively dominant (i.e. hyper-diffusive) 
       !!      truncation error. The overall performance of the advection scheme 
       !!      is similar to that reported in (Farrow and Stevens, 1995). 
-      !!      For stability reasons, the first term of the fluxes which corresponds
+      !!        For stability reasons, the first term of the fluxes which corresponds
       !!      to a second order centered scheme is evaluated using the now velocity 
       !!      (centered in time) while the second term which is the diffusive part 
       !!      of the scheme, is evaluated using the before velocity (forward in time). 
       !!      Note that UBS is not positive. Do not use it on passive tracers.
-      !!                On the vertical, the advection is evaluated using a TVD scheme,
-      !!      as the UBS have been found to be too diffusive.
+      !!                On the vertical, the advection is evaluated using a FCT scheme,
+      !!      as the UBS have been found to be too diffusive. 
+!!gm  !!                kn_ubs_v argument (not coded for the moment)
+      !!      controles whether the FCT is based on a 2nd order centrered scheme (kn_ubs_v=2) 
+      !!      or on a 4th order compact scheme (kn_ubs_v=4).
       !!
       !! ** Action : - update (pta) with the now advective tracer trends
@@ -81,4 +84,5 @@
       CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype          ! =TRA or TRC (tracer indicator)
       INTEGER                              , INTENT(in   ) ::   kjpt            ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kn_ubs_v        ! number of tracers
       REAL(wp), DIMENSION(        jpk     ), INTENT(in   ) ::   p2dt            ! vertical profile of tracer time-step
       REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ) ::   pun, pvn, pwn   ! 3 ocean transport components
@@ -95,5 +99,5 @@
       IF( nn_timing == 1 )  CALL timing_start('tra_adv_ubs')
       !
-      CALL wrk_alloc( jpi, jpj, jpk, ztu, ztv, zltu, zltv, zti, ztw )
+      CALL wrk_alloc( jpi,jpj,jpk,   ztu, ztv, zltu, zltv, zti, ztw )
       !
       IF( kt == kit000 )  THEN
@@ -106,25 +110,24 @@
       IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) ) l_trd = .TRUE.
       !
+      zltu(:,:,jpk) = 0._wp   ;   zltv(:,:,jpk) = 0._wp     ! Bottom value : set to zero one for all
+      ztw (:,:,jpk) = 0._wp   ;   zti (:,:,jpk) = 0._wp
+      IF( lk_vvl )   ztw(:,:, 1 ) = 0._wp                   ! surface value: set to zero only in vvl case
+      !
       !                                                          ! ===========
       DO jn = 1, kjpt                                            ! tracer loop
          !                                                       ! ===========
-         ! 1. Bottom value : flux set to zero
-         ! ----------------------------------
-         zltu(:,:,jpk) = 0.e0       ;      zltv(:,:,jpk) = 0.e0
          !                                              
-         DO jk = 1, jpkm1                                 ! Horizontal slab
-            !                                   
-            !  Laplacian
-            DO jj = 1, jpjm1            ! First derivative (gradient)
+         DO jk = 1, jpkm1        !==  horizontal laplacian of before tracer ==!
+            DO jj = 1, jpjm1              ! First derivative (masked gradient)
                DO ji = 1, fs_jpim1   ! vector opt.
-                  zeeu = e2u(ji,jj) * fse3u(ji,jj,jk) / e1u(ji,jj) * umask(ji,jj,jk)
-                  zeev = e1v(ji,jj) * fse3v(ji,jj,jk) / e2v(ji,jj) * vmask(ji,jj,jk)
+                  zeeu = e2_e1u(ji,jj) * fse3u(ji,jj,jk) * umask(ji,jj,jk)
+                  zeev = e1_e2v(ji,jj) * fse3v(ji,jj,jk) * vmask(ji,jj,jk)
                   ztu(ji,jj,jk) = zeeu * ( ptb(ji+1,jj  ,jk,jn) - ptb(ji,jj,jk,jn) )
                   ztv(ji,jj,jk) = zeev * ( ptb(ji  ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
                END DO
             END DO
-            DO jj = 2, jpjm1            ! Second derivative (divergence)
+            DO jj = 2, jpjm1              ! Second derivative (divergence)
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zcoef = 1. / ( 6. * fse3t(ji,jj,jk) )
+                  zcoef = 1._wp / ( 6._wp * fse3t(ji,jj,jk) )
                   zltu(ji,jj,jk) = (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)  ) * zcoef
                   zltv(ji,jj,jk) = (  ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  ) * zcoef
@@ -132,30 +135,27 @@
             END DO
             !                                    
-         END DO                                           ! End of slab         
+         END DO         
          CALL lbc_lnk( zltu, 'T', 1. )   ;    CALL lbc_lnk( zltv, 'T', 1. )   ! Lateral boundary cond. (unchanged sgn)
-
          !    
-         !  Horizontal advective fluxes               
-         DO jk = 1, jpkm1                                 ! Horizontal slab
+         DO jk = 1, jpkm1        !==  Horizontal advective fluxes  ==!     (UBS)
             DO jj = 1, jpjm1
                DO ji = 1, fs_jpim1   ! vector opt.
-                  ! upstream transport (x2)
-                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )
+                  zfp_ui = pun(ji,jj,jk) + ABS( pun(ji,jj,jk) )      ! upstream transport (x2)
                   zfm_ui = pun(ji,jj,jk) - ABS( pun(ji,jj,jk) )
                   zfp_vj = pvn(ji,jj,jk) + ABS( pvn(ji,jj,jk) )
                   zfm_vj = pvn(ji,jj,jk) - ABS( pvn(ji,jj,jk) )
-                  ! 2nd order centered advective fluxes (x2)
+                  !                                                  ! 2nd order centered advective fluxes (x2)
                   zcenut = pun(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji+1,jj  ,jk,jn) )
                   zcenvt = pvn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji  ,jj+1,jk,jn) )
-                  ! UBS advective fluxes
+                  !                                                  ! UBS advective fluxes
                   ztu(ji,jj,jk) = 0.5 * ( zcenut - zfp_ui * zltu(ji,jj,jk) - zfm_ui * zltu(ji+1,jj,jk) )
                   ztv(ji,jj,jk) = 0.5 * ( zcenvt - zfp_vj * zltv(ji,jj,jk) - zfm_vj * zltv(ji,jj+1,jk) )
                END DO
             END DO
-         END DO                                           ! End of slab         
-
-         zltu(:,:,:) = pta(:,:,:,jn)      ! store pta trends
-
-         DO jk = 1, jpkm1                 ! Horizontal advective trends
+         END DO         
+         !
+         zltu(:,:,:) = pta(:,:,:,jn)      ! store the initial trends before its update
+         !
+         DO jk = 1, jpkm1        !==  add the horizontal advective trend  ==!
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
@@ -166,9 +166,8 @@
             END DO
             !                                             
-         END DO                                           !   End of slab
-
-         ! Horizontal trend used in tra_adv_ztvd subroutine
-         zltu(:,:,:) = pta(:,:,:,jn) - zltu(:,:,:)
-
+         END DO
+         !
+         zltu(:,:,:) = pta(:,:,:,jn) - zltu(:,:,:)    ! Horizontal advective trend used in vertical 2nd order FCT case
+         !                                            ! and/or in trend diagnostic (l_trd=T) 
          !                
          IF( l_trd ) THEN                  ! trend diagnostics
@@ -181,76 +180,89 @@
             IF( jn == jp_sal )  str_adv(:) = ptr_sj( ztv(:,:,:) )
          ENDIF
-         
-         ! TVD scheme for the vertical direction  
-         ! ----------------------
-         IF( l_trd )   zltv(:,:,:) = pta(:,:,:,jn)          ! store pta if trend diag.
-
-         !  Bottom value : flux set to zero
-         ztw(:,:,jpk) = 0.e0   ;   zti(:,:,jpk) = 0.e0
-
-         ! Surface value
-         IF( lk_vvl ) THEN   ;   ztw(:,:,1) = 0.e0                      ! variable volume : flux set to zero
-         ELSE                ;   ztw(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)   ! free constant surface 
-         ENDIF
-         !  upstream advection with initial mass fluxes & intermediate update
-         ! -------------------------------------------------------------------
-         ! Interior value
-         DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                   zfp_wk = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
-                   zfm_wk = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
-                   ztw(ji,jj,jk) = 0.5 * (  zfp_wk * ptb(ji,jj,jk,jn) + zfm_wk * ptb(ji,jj,jk-1,jn)  )
-               END DO
-            END DO
-         END DO 
-         ! update and guess with monotonic sheme
-         DO jk = 1, jpkm1
-            z2dtt = p2dt(jk)
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ztak = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) * zbtr
-                  pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn) +  ztak 
-                  zti(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ( ztak + zltu(ji,jj,jk) ) ) * tmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         !
-         CALL lbc_lnk( zti, 'T', 1. )      ! Lateral boundary conditions on zti, zsi   (unchanged sign)
-
-         !  antidiffusive flux : high order minus low order
-         ztw(:,:,1) = 0.e0       ! Surface value
-         DO jk = 2, jpkm1        ! Interior value
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  ztw(ji,jj,jk) = 0.5 * pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) ) - ztw(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         !
-         CALL nonosc_z( ptb(:,:,:,jn), ztw, zti, p2dt )      !  monotonicity algorithm
-
-         !  final trend with corrected fluxes
-         DO jk = 1, jpkm1
+         !
+         !                       !== vertical advective trend  ==!
+         !
+         SELECT CASE( kn_ubs_v )       ! select the vertical advection scheme
+         !
+         CASE(  2  )                   ! 2nd order FCT 
+            !         
+            IF( l_trd )   zltv(:,:,:) = pta(:,:,:,jn)          ! store pta if trend diag.
+            !
+            !                          !*  upstream advection with initial mass fluxes & intermediate update  ==!
+            DO jk = 2, jpkm1                 ! Interior value (w-masked)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     zfp_wk = pwn(ji,jj,jk) + ABS( pwn(ji,jj,jk) )
+                     zfm_wk = pwn(ji,jj,jk) - ABS( pwn(ji,jj,jk) )
+                     ztw(ji,jj,jk) = 0.5_wp * (  zfp_wk * ptb(ji,jj,jk,jn) + zfm_wk * ptb(ji,jj,jk-1,jn)  ) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO 
+            IF(.NOT.lk_vvl ) THEN            ! top ocean value (only in linear free surface as ztw has been w-masked)
+               IF( ln_isfcav ) THEN                ! top of the ice-shelf cavities and at the ocean surface
+                  DO jj = 1, jpj
+                     DO ji = 1, jpi
+                        ztw(ji,jj, mikt(ji,jj) ) = pwn(ji,jj,mikt(ji,jj)) * ptb(ji,jj,mikt(ji,jj),jn)   ! linear free surface 
+                     END DO
+                  END DO   
+               ELSE                                ! no cavities: only at the ocean surface
+                  ztw(:,:,1) = pwn(:,:,1) * ptb(:,:,1,jn)
+               ENDIF
+            ENDIF
+            !
+            DO jk = 1, jpkm1           !* trend and after field with monotonic scheme
+               z2dtt = p2dt(jk)
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     ztak = - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
+                     pta(ji,jj,jk,jn) =   pta(ji,jj,jk,jn) +  ztak 
+                     zti(ji,jj,jk)    = ( ptb(ji,jj,jk,jn) + z2dtt * ( ztak + zltu(ji,jj,jk) ) ) * tmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( zti, 'T', 1. )      ! Lateral boundary conditions on zti, zsi   (unchanged sign)
+            !
+            !                          !*  anti-diffusive flux : high order minus low order
+            DO jk = 2, jpkm1        ! Interior value  (w-masked)
+               DO jj = 1, jpj
+                  DO ji = 1, jpi
+                     ztw(ji,jj,jk) = (   0.5_wp * pwn(ji,jj,jk) * ( ptn(ji,jj,jk,jn) + ptn(ji,jj,jk-1,jn) )   &
+                        &              - ztw(ji,jj,jk)   ) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            !                                            ! top ocean value: high order == upstream  ==>>  zwz=0
+            IF(.NOT.lk_vvl )   ztw(:,:, 1 ) = 0._wp      ! only ocean surface as interior zwz values have been w-masked
+            !
+            CALL nonosc_z( ptb(:,:,:,jn), ztw, zti, p2dt )      !  monotonicity algorithm
+            !
+         CASE(  4  )                               ! 4th order COMPACT
+            CALL interp_4th_cpt( ptn(:,:,:,jn) , ztw )         ! 4th order compact interpolation of T at w-point
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ztw(ji,jj,jk) = pwn(ji,jj,jk) * ztw(ji,jj,jk) * wmask(ji,jj,jk)
+                  END DO
+               END DO
+            END DO
+            IF(.NOT.lk_vvl )   ztw(:,:, 1 ) = pwn(:,:,1) * ptn(:,:,1,jn)     !!gm ISF & 4th COMPACT doesn't work
+            !
+         END SELECT
+         !
+         DO jk = 1, jpkm1        !  final trend with corrected fluxes
             DO jj = 2, jpjm1 
                DO ji = fs_2, fs_jpim1   ! vector opt.   
-                  zbtr = 1. / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  ! k- vertical advective trends  
-                  ztra = - zbtr * ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) )
-                  ! added to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-         END DO
-
-         !  Save the final vertical advective trends
-         IF( l_trd )  THEN                        ! vertical advective trend diagnostics
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) - ( ztw(ji,jj,jk) - ztw(ji,jj,jk+1) ) / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         !
+         IF( l_trd )  THEN       ! vertical advective trend diagnostics
             DO jk = 1, jpkm1                       ! (compute -w.dk[ptn]= -dk[w.ptn] + ptn.dk[w])
                DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1   ! vector opt.
-                     zbtr = 1.e0 / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                     z_hdivn = (  pwn(ji,jj,jk) - pwn(ji,jj,jk+1)  ) * zbtr
-                     zltv(ji,jj,jk) = pta(ji,jj,jk,jn) - zltv(ji,jj,jk) + ptn(ji,jj,jk,jn) * z_hdivn
+                     zltv(ji,jj,jk) = pta(ji,jj,jk,jn) - zltv(ji,jj,jk)                          &
+                        &           + ptn(ji,jj,jk,jn) * (  pwn(ji,jj,jk) - pwn(ji,jj,jk+1)  )   &
+                        &                              / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
                   END DO
                END DO
@@ -261,5 +273,5 @@
       END DO
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, ztu, ztv, zltu, zltv, zti, ztw )
+      CALL wrk_dealloc( jpi,jpj,jpk,   ztu, ztv, zltu, zltv, zti, ztw )
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_adv_ubs')
@@ -294,17 +306,17 @@
       IF( nn_timing == 1 )  CALL timing_start('nonosc_z')
       !
-      CALL wrk_alloc( jpi, jpj, jpk, zbetup, zbetdo )
+      CALL wrk_alloc( jpi,jpj,jpk,   zbetup, zbetdo )
       !
       zbig  = 1.e+40_wp
       zrtrn = 1.e-15_wp
       zbetup(:,:,:) = 0._wp   ;   zbetdo(:,:,:) = 0._wp
-
+      !
       ! Search local extrema
       ! --------------------
-      ! large negative value (-zbig) inside land
+      !                    ! large negative value (-zbig) inside land
       pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:) - zbig * ( 1.e0 - tmask(:,:,:) )
       paft(:,:,:) = paft(:,:,:) * tmask(:,:,:) - zbig * ( 1.e0 - tmask(:,:,:) )
-      ! search maximum in neighbourhood
-      DO jk = 1, jpkm1
+      !
+      DO jk = 1, jpkm1     ! search maximum in neighbourhood
          ikm1 = MAX(jk-1,1)
          DO jj = 2, jpjm1
@@ -316,9 +328,9 @@
          END DO
       END DO
-      ! large positive value (+zbig) inside land
+      !                    ! large positive value (+zbig) inside land
       pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:) + zbig * ( 1.e0 - tmask(:,:,:) )
       paft(:,:,:) = paft(:,:,:) * tmask(:,:,:) + zbig * ( 1.e0 - tmask(:,:,:) )
-      ! search minimum in neighbourhood
-      DO jk = 1, jpkm1
+      !
+      DO jk = 1, jpkm1     ! search minimum in neighbourhood
          ikm1 = MAX(jk-1,1)
          DO jj = 2, jpjm1
@@ -330,13 +342,10 @@
          END DO
       END DO
-
-      ! restore masked values to zero
+      !                    ! restore masked values to zero
       pbef(:,:,:) = pbef(:,:,:) * tmask(:,:,:)
       paft(:,:,:) = paft(:,:,:) * tmask(:,:,:)
-
-
-      ! 2. Positive and negative part of fluxes and beta terms
-      ! ------------------------------------------------------
-
+      !
+      ! Positive and negative part of fluxes and beta terms
+      ! ---------------------------------------------------
       DO jk = 1, jpkm1
          z2dtt = p2dt(jk)
@@ -347,5 +356,5 @@
                zneg = MAX( 0., pcc(ji  ,jj  ,jk  ) ) - MIN( 0., pcc(ji  ,jj  ,jk+1) )
                ! up & down beta terms
-               zbt = e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
+               zbt = e1e2t(ji,jj) * fse3t(ji,jj,jk) / z2dtt
                zbetup(ji,jj,jk) = ( zbetup(ji,jj,jk) - paft(ji,jj,jk) ) / (zpos+zrtrn) * zbt
                zbetdo(ji,jj,jk) = ( paft(ji,jj,jk) - zbetdo(ji,jj,jk) ) / (zneg+zrtrn) * zbt
@@ -353,4 +362,5 @@
          END DO
       END DO
+      !
       ! monotonic flux in the k direction, i.e. pcc
       ! -------------------------------------------
@@ -366,5 +376,5 @@
       END DO
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, zbetup, zbetdo )
+      CALL wrk_dealloc( jpi,jpj,jpk,   zbetup, zbetdo )
       !
       IF( nn_timing == 1 )  CALL timing_stop('nonosc_z')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trabbl.F90	(revision 6041)
@@ -14,5 +14,5 @@
    !!             -   ! 2013-04  (F. Roquet, G. Madec)  use of eosbn2 instead of local hard coded alpha and beta
    !!----------------------------------------------------------------------
-#if   defined key_trabbl   ||   defined key_esopa
+#if   defined key_trabbl
    !!----------------------------------------------------------------------
    !!   'key_trabbl'   or                             bottom boundary layer
@@ -29,5 +29,5 @@
    USE phycst         ! physical constant
    USE eosbn2         ! equation of state
-   USE trd_oce     ! trends: ocean variables
+   USE trd_oce        ! trends: ocean variables
    USE trdtra         ! trends: active tracers
    !
@@ -198,6 +198,6 @@
          DO jj = 1, jpj
             DO ji = 1, jpi
-               ik = mbkt(ji,jj)                              ! bottom T-level index
-               zptb(ji,jj) = ptb(ji,jj,ik,jn)       ! bottom before T and S
+               ik = mbkt(ji,jj)                             ! bottom T-level index
+               zptb(ji,jj) = ptb(ji,jj,ik,jn)               ! bottom before T and S
             END DO
          END DO
@@ -205,11 +205,11 @@
          DO jj = 2, jpjm1                                    ! Compute the trend
             DO ji = 2, jpim1
-               ik = mbkt(ji,jj)                              ! bottom T-level index
-               zbtr = r1_e12t(ji,jj)  / fse3t(ji,jj,ik)
-               pta(ji,jj,ik,jn) = pta(ji,jj,ik,jn)                                                         &
-                  &               + (   ahu_bbl(ji  ,jj  ) * ( zptb(ji+1,jj  ) - zptb(ji  ,jj  ) )   &
-                  &                   - ahu_bbl(ji-1,jj  ) * ( zptb(ji  ,jj  ) - zptb(ji-1,jj  ) )   &
-                  &                   + ahv_bbl(ji  ,jj  ) * ( zptb(ji  ,jj+1) - zptb(ji  ,jj  ) )   &
-                  &                   - ahv_bbl(ji  ,jj-1) * ( zptb(ji  ,jj  ) - zptb(ji  ,jj-1) )   ) * zbtr
+               ik = mbkt(ji,jj)                            ! bottom T-level index
+               pta(ji,jj,ik,jn) = pta(ji,jj,ik,jn)                                                  &
+                  &             + (  ahu_bbl(ji  ,jj  ) * ( zptb(ji+1,jj  ) - zptb(ji  ,jj  ) )     &
+                  &                - ahu_bbl(ji-1,jj  ) * ( zptb(ji  ,jj  ) - zptb(ji-1,jj  ) )     &
+                  &                + ahv_bbl(ji  ,jj  ) * ( zptb(ji  ,jj+1) - zptb(ji  ,jj  ) )     &
+                  &                - ahv_bbl(ji  ,jj-1) * ( zptb(ji  ,jj  ) - zptb(ji  ,jj-1) )  )  &
+                  &             / ( e1e2t(ji,jj) * fse3t(ji,jj,ik) )
             END DO
          END DO
@@ -263,15 +263,15 @@
                   !
                   !                                               ! up  -slope T-point (shelf bottom point)
-                  zbtr = r1_e12t(iis,jj) / fse3t(iis,jj,ikus)
+                  zbtr = r1_e1e2t(iis,jj) / fse3t(iis,jj,ikus)
                   ztra = zu_bbl * ( ptb(iid,jj,ikus,jn) - ptb(iis,jj,ikus,jn) ) * zbtr
                   pta(iis,jj,ikus,jn) = pta(iis,jj,ikus,jn) + ztra
                   !
                   DO jk = ikus, ikud-1                            ! down-slope upper to down T-point (deep column)
-                     zbtr = r1_e12t(iid,jj) / fse3t(iid,jj,jk)
+                     zbtr = r1_e1e2t(iid,jj) / fse3t(iid,jj,jk)
                      ztra = zu_bbl * ( ptb(iid,jj,jk+1,jn) - ptb(iid,jj,jk,jn) ) * zbtr
                      pta(iid,jj,jk,jn) = pta(iid,jj,jk,jn) + ztra
                   END DO
                   !
-                  zbtr = r1_e12t(iid,jj) / fse3t(iid,jj,ikud)
+                  zbtr = r1_e1e2t(iid,jj) / fse3t(iid,jj,ikud)
                   ztra = zu_bbl * ( ptb(iis,jj,ikus,jn) - ptb(iid,jj,ikud,jn) ) * zbtr
                   pta(iid,jj,ikud,jn) = pta(iid,jj,ikud,jn) + ztra
@@ -285,15 +285,15 @@
                   !
                   ! up  -slope T-point (shelf bottom point)
-                  zbtr = r1_e12t(ji,ijs) / fse3t(ji,ijs,ikvs)
+                  zbtr = r1_e1e2t(ji,ijs) / fse3t(ji,ijs,ikvs)
                   ztra = zv_bbl * ( ptb(ji,ijd,ikvs,jn) - ptb(ji,ijs,ikvs,jn) ) * zbtr
                   pta(ji,ijs,ikvs,jn) = pta(ji,ijs,ikvs,jn) + ztra
                   !
                   DO jk = ikvs, ikvd-1                            ! down-slope upper to down T-point (deep column)
-                     zbtr = r1_e12t(ji,ijd) / fse3t(ji,ijd,jk)
+                     zbtr = r1_e1e2t(ji,ijd) / fse3t(ji,ijd,jk)
                      ztra = zv_bbl * ( ptb(ji,ijd,jk+1,jn) - ptb(ji,ijd,jk,jn) ) * zbtr
                      pta(ji,ijd,jk,jn) = pta(ji,ijd,jk,jn)  + ztra
                   END DO
                   !                                               ! down-slope T-point (deep bottom point)
-                  zbtr = r1_e12t(ji,ijd) / fse3t(ji,ijd,ikvd)
+                  zbtr = r1_e1e2t(ji,ijd) / fse3t(ji,ijd,ikvd)
                   ztra = zv_bbl * ( ptb(ji,ijs,ikvs,jn) - ptb(ji,ijd,ikvd,jn) ) * zbtr
                   pta(ji,ijd,ikvd,jn) = pta(ji,ijd,ikvd,jn) + ztra
@@ -566,6 +566,6 @@
 
       !                             !* masked diffusive flux coefficients
-      ahu_bbl_0(:,:) = rn_ahtbbl * e2u(:,:) * e3u_bbl_0(:,:) / e1u(:,:)  * umask(:,:,1)
-      ahv_bbl_0(:,:) = rn_ahtbbl * e1v(:,:) * e3v_bbl_0(:,:) / e2v(:,:)  * vmask(:,:,1)
+      ahu_bbl_0(:,:) = rn_ahtbbl * e2_e1u(:,:) * e3u_bbl_0(:,:) * umask(:,:,1)
+      ahv_bbl_0(:,:) = rn_ahtbbl * e1_e2v(:,:) * e3v_bbl_0(:,:) * vmask(:,:,1)
 
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/tradmp.F90	(revision 6041)
@@ -6,8 +6,6 @@
    !! History :  OPA  ! 1991-03  (O. Marti, G. Madec)  Original code
    !!                 ! 1992-06  (M. Imbard)  doctor norme
-   !!                 ! 1996-01  (G. Madec)  statement function for e3
-   !!                 ! 1997-05  (G. Madec)  macro-tasked on jk-slab
    !!                 ! 1998-07  (M. Imbard, G. Madec) ORCA version
-   !!            7.0  ! 2001-02  (M. Imbard)  cofdis, Original code
+   !!            7.0  ! 2001-02  (M. Imbard)  add distance to coast, Original code
    !!            8.1  ! 2001-02  (G. Madec, E. Durand)  cleaning
    !!  NEMO      1.0  ! 2002-08  (G. Madec, E. Durand)  free form + modules
@@ -15,4 +13,6 @@
    !!            3.3  ! 2010-06  (C. Ethe, G. Madec) merge TRA-TRC 
    !!            3.4  ! 2011-04  (G. Madec, C. Ethe) Merge of dtatem and dtasal + suppression of CPP keys
+   !!            3.6  ! 2015-06  (T. Graham)  read restoring coefficient in a file
+   !!            3.7  ! 2015-10  (G. Madec)  remove useless trends arrays
    !!----------------------------------------------------------------------
 
@@ -42,16 +42,11 @@
 
    PUBLIC   tra_dmp      ! routine called by step.F90
-   PUBLIC   tra_dmp_init ! routine called by opa.F90
-
-   !                               !!* Namelist namtra_dmp : T & S newtonian damping *
-   ! nn_zdmp and cn_resto are public as they are used by C1D/dyndmp.F90
-   LOGICAL , PUBLIC ::   ln_tradmp   !: internal damping flag
-   INTEGER , PUBLIC ::   nn_zdmp     ! = 0/1/2 flag for damping in the mixed layer
-   CHARACTER(LEN=200) , PUBLIC :: cn_resto      ! name of netcdf file containing restoration coefficient field
+   PUBLIC   tra_dmp_init ! routine called by nemogcm.F90
+
+   !                                           !!* Namelist namtra_dmp : T & S newtonian damping *
+   LOGICAL            , PUBLIC ::   ln_tradmp   !: internal damping flag
+   INTEGER            , PUBLIC ::   nn_zdmp     !: = 0/1/2 flag for damping in the mixed layer
+   CHARACTER(LEN=200) , PUBLIC ::   cn_resto    !: name of netcdf file containing restoration coefficient field
    !
-
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   strdmp   !: damping salinity trend (psu/s)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ttrdmp   !: damping temperature trend (Celcius/s)
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   resto    !: restoring coeff. on T and S (s-1)
 
@@ -70,5 +65,5 @@
       !!                ***  FUNCTION tra_dmp_alloc  ***
       !!----------------------------------------------------------------------
-      ALLOCATE( strdmp(jpi,jpj,jpk) , ttrdmp(jpi,jpj,jpk), resto(jpi,jpj,jpk), STAT= tra_dmp_alloc )
+      ALLOCATE( resto(jpi,jpj,jpk), STAT= tra_dmp_alloc )
       !
       IF( lk_mpp            )   CALL mpp_sum ( tra_dmp_alloc )
@@ -96,69 +91,58 @@
       !! ** Action  : - (ta,sa)   tracer trends updated with the damping trend
       !!----------------------------------------------------------------------
-      !
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !!
-      INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      REAL(wp) ::   zta, zsa             ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zts_dta 
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start( 'tra_dmp')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, jpts,  zts_dta )
-      !
-      !                           !==   input T-S data at kt   ==!
+      !
+      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) ::  zts_dta, ztrdts
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )   CALL timing_start('tra_dmp')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,jpts,   zts_dta )
+      !
+      IF( l_trdtra )   THEN                    !* Save ta and sa trends
+         CALL wrk_alloc( jpi,jpj,jpk,jpts,   ztrdts ) 
+         ztrdts(:,:,:,:) = tsa(:,:,:,:) 
+      ENDIF
+      !                           !==  input T-S data at kt  ==!
       CALL dta_tsd( kt, zts_dta )            ! read and interpolates T-S data at kt
       !
-      SELECT CASE ( nn_zdmp )     !==    type of damping   ==!
-      !
-      CASE( 0 )                   !==  newtonian damping throughout the water column  ==!
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zta = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
-                  zsa = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + zta
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + zsa
-                  strdmp(ji,jj,jk) = zsa           ! save the trend (used in asmtrj)
-                  ttrdmp(ji,jj,jk) = zta      
+      SELECT CASE ( nn_zdmp )     !==  type of damping  ==!
+      !
+      CASE( 0 )                        !*  newtonian damping throughout the water column  *!
+         DO jn = 1, jpts
+            DO jk = 1, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1   ! vector opt.
+                     tsa(ji,jj,jk,jn) = tsa(ji,jj,jk,jn) + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jn) - tsb(ji,jj,jk,jn) )
+                  END DO
                END DO
             END DO
          END DO
          !
-      CASE ( 1 )                  !==  no damping in the turbocline (avt > 5 cm2/s)  ==!
+      CASE ( 1 )                       !*  no damping in the turbocline (avt > 5 cm2/s)  *!
          DO jk = 1, jpkm1
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   IF( avt(ji,jj,jk) <= 5.e-4_wp ) THEN
-                     zta = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
-                     zsa = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
-                  ELSE
-                     zta = 0._wp
-                     zsa = 0._wp  
+                     tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
+                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
+                     tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal)   &
+                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
                   ENDIF
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + zta
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + zsa
-                  strdmp(ji,jj,jk) = zsa           ! save the salinity trend (used in asmtrj)
-                  ttrdmp(ji,jj,jk) = zta
                END DO
             END DO
          END DO
          !
-      CASE ( 2 )                  !==  no damping in the mixed layer   ==!
+      CASE ( 2 )                       !*  no damping in the mixed layer   *!
          DO jk = 1, jpkm1
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   IF( fsdept(ji,jj,jk) >= hmlp (ji,jj) ) THEN
-                     zta = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
-                     zsa = resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
-                  ELSE
-                     zta = 0._wp
-                     zsa = 0._wp  
+                     tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem)   &
+                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_tem) - tsb(ji,jj,jk,jp_tem) )
+                     tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal)   &
+                        &                 + resto(ji,jj,jk) * ( zts_dta(ji,jj,jk,jp_sal) - tsb(ji,jj,jk,jp_sal) )
                   ENDIF
-                  tsa(ji,jj,jk,jp_tem) = tsa(ji,jj,jk,jp_tem) + zta
-                  tsa(ji,jj,jk,jp_sal) = tsa(ji,jj,jk,jp_sal) + zsa
-                  strdmp(ji,jj,jk) = zsa           ! save the salinity trend (used in asmtrj)
-                  ttrdmp(ji,jj,jk) = zta
                END DO
             END DO
@@ -168,6 +152,8 @@
       !
       IF( l_trdtra )   THEN       ! trend diagnostic
-         CALL trd_tra( kt, 'TRA', jp_tem, jptra_dmp, ttrdmp )
-         CALL trd_tra( kt, 'TRA', jp_sal, jptra_dmp, strdmp )
+         ztrdts(:,:,:,:) = tsa(:,:,:,:) - ztrdts(:,:,:,:)
+         CALL trd_tra( kt, 'TRA', jp_tem, jptra_dmp, ztrdts(:,:,:,jp_tem) )
+         CALL trd_tra( kt, 'TRA', jp_sal, jptra_dmp, ztrdts(:,:,:,jp_sal) )
+         CALL wrk_dealloc( jpi,jpj,jpk,jpts,   ztrdts ) 
       ENDIF
       !                           ! Control print
@@ -175,7 +161,7 @@
          &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, jpts,  zts_dta )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop( 'tra_dmp')
+      CALL wrk_dealloc( jpi,jpj,jpk,jpts,   zts_dta )
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('tra_dmp')
       !
    END SUBROUTINE tra_dmp
@@ -190,8 +176,7 @@
       !! ** Method  :   read the namtra_dmp namelist and check the parameters
       !!----------------------------------------------------------------------
+      INTEGER ::   ios, imask   ! local integers 
+      !!
       NAMELIST/namtra_dmp/ ln_tradmp, nn_zdmp, cn_resto
-      INTEGER ::  ios         ! Local integer for output status of namelist read
-      INTEGER :: imask        ! File handle 
-      !!
       !!----------------------------------------------------------------------
       !
@@ -204,9 +189,9 @@
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtra_dmp in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namtra_dmp )
-
-      IF(lwp) THEN                 !Namelist print
+      !
+      IF(lwp) THEN                  ! Namelist print
          WRITE(numout,*)
          WRITE(numout,*) 'tra_dmp_init : T and S newtonian relaxation'
-         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '~~~~~~~~~~~'
          WRITE(numout,*) '   Namelist namtra_dmp : set relaxation parameters'
          WRITE(numout,*) '      Apply relaxation   or not       ln_tradmp = ', ln_tradmp
@@ -215,34 +200,31 @@
          WRITE(numout,*)
       ENDIF
-
+      !
       IF( ln_tradmp) THEN
-         !
-         !Allocate arrays
+         !                          ! Allocate arrays
          IF( tra_dmp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'tra_dmp_init: unable to allocate arrays' )
-
-         !Check values of nn_zdmp
-         SELECT CASE (nn_zdmp)
-         CASE ( 0 )  ; IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
-         CASE ( 1 )  ; IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline'
-         CASE ( 2 )  ; IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
+         !
+         SELECT CASE (nn_zdmp)      ! Check values of nn_zdmp
+         CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping as specified by mask'
+         CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixing layer (kz > 5 cm2/s)'
+         CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed  layer'
+         CASE DEFAULT
+            CALL ctl_stop('tra_dmp_init : wrong value of nn_zdmp')
          END SELECT
-
-         !TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
-         !so can damp to something other than intitial conditions files?
+         !
+         !!TG: Initialisation of dtatsd - Would it be better to have dmpdta routine
+         !    so can damp to something other than intitial conditions files?
+         !!gm: In principle yes. Nevertheless, we can't anticipate demands that have never been formulated.
          IF( .NOT.ln_tsd_tradmp ) THEN
-            CALL ctl_warn( 'tra_dmp_init: read T-S data not initialized, we force ln_tsd_tradmp=T' )
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout, *)  '   read T-S data not initialized, we force ln_tsd_tradmp=T'
             CALL dta_tsd_init( ld_tradmp=ln_tradmp )        ! forces the initialisation of T-S data
          ENDIF
-
-         !initialise arrays - Are these actually used anywhere else?
-         strdmp(:,:,:) = 0._wp
-         ttrdmp(:,:,:) = 0._wp
-
-         !Read in mask from file
+         !                          ! Read in mask from file
          CALL iom_open ( cn_resto, imask)
-         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto)
+         CALL iom_get  ( imask, jpdom_autoglo, 'resto', resto )
          CALL iom_close( imask )
-       ENDIF
-
+      ENDIF
+      !
    END SUBROUTINE tra_dmp_init
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf.F90	(revision 6041)
@@ -4,6 +4,9 @@
    !! Ocean Active tracers : lateral diffusive trends 
    !!=====================================================================
-   !! History :  9.0  ! 2005-11 (G. Madec)  Original code
-   !!       NEMO 3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA 
+   !! History :  9.0  ! 2005-11  (G. Madec)  Original code
+   !!  NEMO      3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA 
+   !!            3.7  ! 2013-12  (G. Madec) remove the optional computation from T & S anomaly profiles and traldf_bilapg
+   !!             -   ! 2013-12  (F. Lemarie, G. Madec)  triad operator (Griffies) + Method of Stabilizing Correction
+   !!             -   ! 2014-01  (G. Madec, S. Masson)  restructuration/simplification of lateral diffusive operators
    !!----------------------------------------------------------------------
 
@@ -11,25 +14,23 @@
    !!   tra_ldf      : update the tracer trend with the lateral diffusion
    !!   tra_ldf_init : initialization, namelist read, and parameters control
-   !!       ldf_ano  : compute lateral diffusion for constant T-S profiles
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers
-   USE dom_oce         ! ocean space and time domain
-   USE phycst          ! physical constants
-   USE ldftra_oce      ! ocean tracer   lateral physics
-   USE ldfslp          ! ???
-   USE traldf_bilapg   ! lateral mixing            (tra_ldf_bilapg routine)
-   USE traldf_bilap    ! lateral mixing             (tra_ldf_bilap routine)
-   USE traldf_iso      ! lateral mixing               (tra_ldf_iso routine)
-   USE traldf_iso_grif ! lateral mixing          (tra_ldf_iso_grif routine)
-   USE traldf_lap      ! lateral mixing               (tra_ldf_lap routine)
-   USE trd_oce         ! trends: ocean variables
-   USE trdtra          ! trends manager: tracers 
+   !!----------------------------------------------------------------------
+   USE oce           ! ocean dynamics and tracers
+   USE dom_oce       ! ocean space and time domain
+   USE phycst        ! physical constants
+   USE ldftra        ! lateral diffusion: eddy diffusivity & EIV coeff.
+   USE ldfslp        ! lateral diffusion: iso-neutral slope
+   USE traldf_lap    ! lateral diffusion: laplacian iso-level            operator  (tra_ldf_lap   routine)
+   USE traldf_iso    ! lateral diffusion: laplacian iso-neutral standard operator  (tra_ldf_iso   routine)
+   USE traldf_triad  ! lateral diffusion: laplacian iso-neutral triad    operator  (tra_ldf_triad routine)
+   USE traldf_blp    ! lateral diffusion (iso-level lap/blp)                       (tra_ldf_lap   routine)
+   USE trd_oce       ! trends: ocean variables
+   USE trdtra        ! ocean active tracers trends
    !
-   USE prtctl          ! Print control
-   USE in_out_manager  ! I/O manager
-   USE lib_mpp         ! distribued memory computing library
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE wrk_nemo        ! Memory allocation
-   USE timing          ! Timing
+   USE prtctl         ! Print control
+   USE in_out_manager ! I/O manager
+   USE lib_mpp        ! distribued memory computing library
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE wrk_nemo       ! Memory allocation
+   USE timing         ! Timing
 
    IMPLICIT NONE
@@ -37,16 +38,13 @@
 
    PUBLIC   tra_ldf        ! called by step.F90 
-   PUBLIC   tra_ldf_init   ! called by opa.F90 
+   PUBLIC   tra_ldf_init   ! called by nemogcm.F90 
    !
-   INTEGER ::   nldf = 0   ! type of lateral diffusion used defined from ln_traldf_... namlist logicals)
-
-   REAL, SAVE, ALLOCATABLE, DIMENSION(:,:,:) ::   t0_ldf, s0_ldf   !: lateral diffusion trends of T & S for a cst profile
-   !                                                               !  (key_traldf_ano only)
-
+   INTEGER ::   nldf = 0   ! type of lateral diffusion used defined from ln_traldf_... (namlist logicals)
+   
    !! * Substitutions
 #  include "domzgr_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$ 
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -65,67 +63,36 @@
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('tra_ldf')
-      !
-      rldf = 1     ! For active tracers the 
-
+      IF( nn_timing == 1 )   CALL timing_start('tra_ldf')
+      !
       IF( l_trdtra )   THEN                    !* Save ta and sa trends
-         CALL wrk_alloc( jpi, jpj, jpk, ztrdt, ztrds ) 
+         CALL wrk_alloc( jpi,jpj,jpk,   ztrdt, ztrds ) 
          ztrdt(:,:,:) = tsa(:,:,:,jp_tem) 
          ztrds(:,:,:) = tsa(:,:,:,jp_sal)
       ENDIF
-
-      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
-      CASE ( 0 )   ;   CALL tra_ldf_lap     ( kt, nit000, 'TRA', gtsu, gtsv, gtui, gtvi,        &
-                               &                                   tsb, tsa, jpts        )  ! iso-level laplacian
-      CASE ( 1 )                                                                              ! rotated laplacian
-         IF( ln_traldf_grif ) THEN                                                          
-                       CALL tra_ldf_iso_grif( kt, nit000,'TRA', gtsu, gtsv, tsb, tsa, jpts, ahtb0 )      ! Griffies operator
-         ELSE                                                                                
-                       CALL tra_ldf_iso     ( kt, nit000, 'TRA', gtsu, gtsv, gtui, gtvi,        &
-                               &                                  tsb, tsa, jpts, ahtb0 )      ! Madec operator
-         ENDIF
-      CASE ( 2 )   ;   CALL tra_ldf_bilap   ( kt, nit000, 'TRA', gtsu, gtsv, gtui, gtvi,        &
-                               &                                   tsb, tsa, jpts        )  ! iso-level bilaplacian
-      CASE ( 3 )   ;   CALL tra_ldf_bilapg  ( kt, nit000, 'TRA',             tsb, tsa, jpts        )  ! s-coord. geopot. bilap.
-         !
-      CASE ( -1 )                                ! esopa: test all possibility with control print
-         CALL tra_ldf_lap   ( kt, nit000, 'TRA', gtsu, gtsv, gtui, gtvi,        &
-         &                                       tsb, tsa, jpts        ) 
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' ldf0 - Ta: ', mask1=tmask,               &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         IF( ln_traldf_grif ) THEN
-            CALL tra_ldf_iso_grif( kt, nit000, 'TRA', gtsu, gtsv, tsb, tsa, jpts, ahtb0 )
-         ELSE
-            CALL tra_ldf_iso     ( kt, nit000, 'TRA', gtsu, gtsv, gtui, gtvi,        &
-            &                                               tsb, tsa, jpts, ahtb0 )  
-         ENDIF
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' ldf1 - Ta: ', mask1=tmask,               &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_ldf_bilap ( kt, nit000, 'TRA', gtsu, gtsv, gtui, gtvi,        &
-         &                                       tsb, tsa, jpts        ) 
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' ldf2 - Ta: ', mask1=tmask,               &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_ldf_bilapg( kt, nit000, 'TRA',             tsb, tsa, jpts        ) 
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' ldf3 - Ta: ', mask1=tmask,               &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+      !
+      SELECT CASE ( nldf )                     !* compute lateral mixing trend and add it to the general trend
+      !
+      CASE ( np_lap   )                                  ! laplacian: iso-level operator
+         CALL tra_ldf_lap  ( kt, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, tsb,      tsa, jpts,  1   )
+      CASE ( np_lap_i )                                  ! laplacian: standard iso-neutral operator (Madec)
+         CALL tra_ldf_iso  ( kt, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, tsb, tsb, tsa, jpts,  1   )
+      CASE ( np_lap_it )                                 ! laplacian: triad iso-neutral operator (griffies)
+         CALL tra_ldf_triad( kt, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, tsb, tsb, tsa, jpts,  1   )
+      CASE ( np_blp , np_blp_i , np_blp_it )             ! bilaplacian: iso-level & iso-neutral operators
+         CALL tra_ldf_blp  ( kt, nit000,'TRA', ahtu, ahtv, gtsu, gtsv, gtui, gtvi, tsb      , tsa, jpts, nldf )
       END SELECT
 
-#if defined key_traldf_ano
-      tsa(:,:,:,jp_tem) = tsa(:,:,:,jp_tem) - t0_ldf(:,:,:)      ! anomaly: substract the reference diffusivity
-      tsa(:,:,:,jp_sal) = tsa(:,:,:,jp_sal) - s0_ldf(:,:,:)
-#endif
-
-      IF( l_trdtra )   THEN                      ! save the horizontal diffusive trends for further diagnostics
+      IF( l_trdtra )   THEN                    !* save the horizontal diffusive trends for further diagnostics
          ztrdt(:,:,:) = tsa(:,:,:,jp_tem) - ztrdt(:,:,:)
          ztrds(:,:,:) = tsa(:,:,:,jp_sal) - ztrds(:,:,:)
          CALL trd_tra( kt, 'TRA', jp_tem, jptra_ldf, ztrdt )
          CALL trd_tra( kt, 'TRA', jp_sal, jptra_ldf, ztrds )
-         CALL wrk_dealloc( jpi, jpj, jpk, ztrdt, ztrds ) 
-      ENDIF
-      !                                          ! print mean trends (used for debugging)
+         CALL wrk_dealloc( jpi,jpj,jpk,   ztrdt, ztrds ) 
+      ENDIF
+      !                                        !* print mean trends (used for debugging)
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' ldf  - Ta: ', mask1=tmask,               &
          &                       tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
       !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_ldf')
+      IF( nn_timing == 1 )   CALL timing_stop('tra_ldf')
       !
    END SUBROUTINE tra_ldf
@@ -139,17 +106,9 @@
       !!
       !! ** Method  :   set nldf from the namtra_ldf logicals
-      !!      nldf == -1   ESOPA test: ALL operators are used
-      !!      nldf ==  0   laplacian operator
-      !!      nldf ==  1   Rotated laplacian operator
-      !!      nldf ==  2   bilaplacian operator
-      !!      nldf ==  3   Rotated bilaplacian
-      !!----------------------------------------------------------------------
-      INTEGER ::   ioptio, ierr         ! temporary integers 
-      !!----------------------------------------------------------------------
-
-      !  Define the lateral mixing oparator for tracers
-      ! ===============================================
-    
-      IF(lwp) THEN                    ! Namelist print
+      !!----------------------------------------------------------------------
+      INTEGER ::   ioptio, ierr   ! temporary integers 
+      !!----------------------------------------------------------------------
+      !
+      IF(lwp) THEN                     ! Namelist print
          WRITE(numout,*)
          WRITE(numout,*) 'tra_ldf_init : lateral tracer diffusive operator'
@@ -159,204 +118,83 @@
          WRITE(numout,*)
       ENDIF
-
-      !                               ! control the input
+      !                                   ! use of lateral operator or not
+      nldf   = np_ERROR
       ioptio = 0
-      IF( ln_traldf_lap   )   ioptio = ioptio + 1
-      IF( ln_traldf_bilap )   ioptio = ioptio + 1
-      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
-      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
-      ioptio = 0
-      IF( ln_traldf_level )   ioptio = ioptio + 1
-      IF( ln_traldf_hor   )   ioptio = ioptio + 1
-      IF( ln_traldf_iso   )   ioptio = ioptio + 1
-      IF( ioptio >  1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
-
-      ! defined the type of lateral diffusion from ln_traldf_... logicals
-      ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
-      ierr = 0
-      IF( ln_traldf_lap ) THEN       ! laplacian operator
-         IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
-            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
-            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+      IF( ln_traldf_lap )   ioptio = ioptio + 1
+      IF( ln_traldf_blp )   ioptio = ioptio + 1
+      IF( ioptio >  1   )   CALL ctl_stop( 'tra_ldf_init: use ONE or NONE of the 2 lap/bilap operator type on tracer' )
+      IF( ioptio == 0   )   nldf = np_no_ldf     ! No lateral diffusion
+      !
+      IF( nldf /= np_no_ldf ) THEN        ! direction ==>> type of operator  
+         ioptio = 0
+         IF( ln_traldf_lev )   ioptio = ioptio + 1
+         IF( ln_traldf_hor )   ioptio = ioptio + 1
+         IF( ln_traldf_iso )   ioptio = ioptio + 1
+         IF( ioptio >  1 )   CALL ctl_stop( 'tra_ldf_init: use only ONE direction (level/hor/iso)' )
+         !
+         !                                ! defined the type of lateral diffusion from ln_traldf_... logicals
+         ierr = 0
+         IF( ln_traldf_lap ) THEN         ! laplacian operator
+            IF ( ln_zco ) THEN               ! z-coordinate
+               IF ( ln_traldf_lev   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+               IF ( ln_traldf_hor   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+               IF ( ln_traldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard  (   rotation)
+               IF ( ln_traldf_triad )   nldf = np_lap_it  ! iso-neutral: triad     (   rotation)
+            ENDIF
+            IF ( ln_zps ) THEN               ! z-coordinate with partial step
+               IF ( ln_traldf_lev   )   ierr = 1          ! iso-level not allowed 
+               IF ( ln_traldf_hor   )   nldf = np_lap     ! horizontal             (no rotation)
+               IF ( ln_traldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard     (rotation)
+               IF ( ln_traldf_triad )   nldf = np_lap_it  ! iso-neutral: triad        (rotation)
+            ENDIF
+            IF ( ln_sco ) THEN               ! s-coordinate
+               IF ( ln_traldf_lev   )   nldf = np_lap     ! iso-level              (no rotation)
+               IF ( ln_traldf_hor   )   nldf = np_lap_i   ! horizontal             (   rotation)
+               IF ( ln_traldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard  (   rotation)
+               IF ( ln_traldf_triad )   nldf = np_lap_it  ! iso-neutral: triad     (   rotation)
+            ENDIF
          ENDIF
-         IF ( ln_zps ) THEN             ! zps-coordinate
-            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed
-            IF ( ln_traldf_hor   )   nldf = 0      ! horizontal (no rotation)
-            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
+         !
+         IF( ln_traldf_blp ) THEN         ! bilaplacian operator
+            IF ( ln_zco ) THEN               ! z-coordinate
+               IF ( ln_traldf_lev   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+               IF ( ln_traldf_hor   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+               IF ( ln_traldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard  (   rotation)
+               IF ( ln_traldf_triad )   nldf = np_blp_it  ! iso-neutral: triad     (   rotation)
+            ENDIF
+            IF ( ln_zps ) THEN               ! z-coordinate with partial step
+               IF ( ln_traldf_lev   )   ierr = 1          ! iso-level not allowed 
+               IF ( ln_traldf_hor   )   nldf = np_blp     ! horizontal             (no rotation)
+               IF ( ln_traldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard  (   rotation)
+               IF ( ln_traldf_triad )   nldf = np_blp_it  ! iso-neutral: triad     (   rotation)
+            ENDIF
+            IF ( ln_sco ) THEN               ! s-coordinate
+               IF ( ln_traldf_lev   )   nldf = np_blp     ! iso-level              (no rotation)
+               IF ( ln_traldf_hor   )   nldf = np_blp_it  ! horizontal             (   rotation)
+               IF ( ln_traldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard  (   rotation)
+               IF ( ln_traldf_triad )   nldf = np_blp_it  ! iso-neutral: triad     (   rotation)
+            ENDIF
          ENDIF
-         IF ( ln_sco ) THEN             ! s-coordinate
-            IF ( ln_traldf_level )   nldf = 0      ! iso-level  (no rotation)
-            IF ( ln_traldf_hor   )   nldf = 1      ! horizontal (   rotation)
-            IF ( ln_traldf_iso   )   nldf = 1      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-
-      IF( ln_traldf_bilap ) THEN      ! bilaplacian operator
-         IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
-            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
-            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_zps ) THEN             ! zps-coordinate
-            IF ( ln_traldf_level )   ierr = 1      ! iso-level not allowed 
-            IF ( ln_traldf_hor   )   nldf = 2      ! horizontal (no rotation)
-            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_sco ) THEN             ! s-coordinate
-            IF ( ln_traldf_level )   nldf = 2      ! iso-level  (no rotation)
-            IF ( ln_traldf_hor   )   nldf = 3      ! horizontal (   rotation)
-            IF ( ln_traldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-
-      IF( nldf == 3 )   CALL ctl_warn( 'geopotential bilaplacian tracer diffusion in s-coords not thoroughly tested' )
+      ENDIF
+      !
       IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
-      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
-      IF( lk_traldf_eiv .AND. .NOT.ln_traldf_iso )   &
-           CALL ctl_stop( '          eddy induced velocity on tracers',   &
-           &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
-      IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
-         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
-         l_traldf_rot = .TRUE.                 ! needed for trazdf_imp
-      ENDIF
-
-      IF( lk_esopa ) THEN
-         IF(lwp) WRITE(numout,*) '          esopa control: use all lateral physics options'
-         nldf = -1
-      ENDIF
-
+      IF( ln_ldfeiv .AND. .NOT.( ln_traldf_iso .OR. ln_traldf_triad ) )                                    &
+           &            CALL ctl_stop( '          eddy induced velocity on tracers requires isopycnal',    &
+           &                                                                    ' laplacian diffusion' )
+      IF(  nldf == np_lap_i .OR. nldf == np_lap_it .OR. &
+         & nldf == np_blp_i .OR. nldf == np_blp_it  )   l_ldfslp = .TRUE.    ! slope of neutral surfaces required 
+      !
       IF(lwp) THEN
          WRITE(numout,*)
-         IF( nldf == -2 )   WRITE(numout,*) '          NO lateral diffusion'
-         IF( nldf == -1 )   WRITE(numout,*) '          ESOPA test All scheme used'
-         IF( nldf ==  0 )   WRITE(numout,*) '          laplacian operator'
-         IF( nldf ==  1 )   WRITE(numout,*) '          Rotated laplacian operator'
-         IF( nldf ==  2 )   WRITE(numout,*) '          bilaplacian operator'
-         IF( nldf ==  3 )   WRITE(numout,*) '          Rotated bilaplacian'
-      ENDIF
-
-      ! Reference T & S diffusivity (if necessary)
-      ! ===========================
-      CALL ldf_ano
+         IF( nldf == np_no_ldf )   WRITE(numout,*) '          NO lateral diffusion'
+         IF( nldf == np_lap    )   WRITE(numout,*) '          laplacian iso-level operator'
+         IF( nldf == np_lap_i  )   WRITE(numout,*) '          Rotated laplacian operator (standard)'
+         IF( nldf == np_lap_it )   WRITE(numout,*) '          Rotated laplacian operator (triad)'
+         IF( nldf == np_blp    )   WRITE(numout,*) '          bilaplacian iso-level operator'
+         IF( nldf == np_blp_i  )   WRITE(numout,*) '          Rotated bilaplacian operator (standard)'
+         IF( nldf == np_blp_it )   WRITE(numout,*) '          Rotated bilaplacian operator (triad)'
+      ENDIF
       !
    END SUBROUTINE tra_ldf_init
-
-#if defined key_traldf_ano
-   !!----------------------------------------------------------------------
-   !!   'key_traldf_ano'               T & S lateral diffusion on anomalies
-   !!----------------------------------------------------------------------
-
-   SUBROUTINE ldf_ano
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldf_ano  ***
-      !!
-      !! ** Purpose :   initializations of 
-      !!----------------------------------------------------------------------
-      !
-      USE zdf_oce         ! vertical mixing
-      USE trazdf          ! vertical mixing: double diffusion
-      USE zdfddm          ! vertical mixing: double diffusion
-      !
-      INTEGER  ::   jk              ! Dummy loop indice
-      INTEGER  ::   ierr            ! local integer
-      LOGICAL  ::   llsave          ! local logical
-      REAL(wp) ::   zt0, zs0, z12   ! local scalar
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zt_ref, zs_ref, ztb, zsb, zavt     
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ldf_ano')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zt_ref, zs_ref, ztb, zsb, zavt ) 
-      !
-
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on anomalies'
-         WRITE(numout,*) '~~~~~~~~~~~'
-      ENDIF
-
-      !                              ! allocate trabbl arrays
-      ALLOCATE( t0_ldf(jpi,jpj,jpk) , s0_ldf(jpi,jpj,jpk) , STAT=ierr )
-      IF( lk_mpp    )   CALL mpp_sum( ierr )
-      IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'ldf_ano: unable to allocate arrays' )
-
-      ! defined the T & S reference profiles
-      ! ------------------------------------
-      zt0 =10.e0                               ! homogeneous ocean
-      zs0 =35.e0
-      zt_ref(:,:,:) = 10.0 * tmask(:,:,:)
-      zs_ref(:,:,:) = 35.0 * tmask(:,:,:)
-      IF(lwp) WRITE(numout,*) '              homogeneous ocean T = ', zt0, ' S = ',zs0
-
-      ! Initialisation of gtui/gtvi in case of no cavity
-      IF ( .NOT. ln_isfcav ) THEN
-         gtui(:,:,:) = 0.0_wp
-         gtvi(:,:,:) = 0.0_wp
-      END IF
-      !                                        ! T & S profile (to be coded +namelist parameter
-
-      ! prepare the ldf computation
-      ! ---------------------------
-      llsave = l_trdtra
-      l_trdtra = .false.      ! desactivate trend computation
-      t0_ldf(:,:,:) = 0.e0
-      s0_ldf(:,:,:) = 0.e0
-      ztb   (:,:,:) = tsb (:,:,:,jp_tem)
-      zsb   (:,:,:) = tsb (:,:,:,jp_sal)
-      ua    (:,:,:) = tsa (:,:,:,jp_tem)
-      va    (:,:,:) = tsa (:,:,:,jp_sal)
-      zavt  (:,:,:) = avt(:,:,:)
-      IF( lk_zdfddm ) THEN CALL ctl_stop( ' key_traldf_ano with key_zdfddm not implemented' )
-      ! set tb, sb to reference values and avr to zero
-      tsb (:,:,:,jp_tem) = zt_ref(:,:,:)
-      tsb (:,:,:,jp_sal) = zs_ref(:,:,:)
-      tsa (:,:,:,jp_tem) = 0.e0
-      tsa (:,:,:,jp_sal) = 0.e0
-      avt(:,:,:)         = 0.e0
-
-      ! Compute the ldf trends
-      ! ----------------------
-      CALL tra_ldf( nit000 + 1 )      ! horizontal components (+1: no more init)
-      CALL tra_zdf( nit000     )      ! vertical component (if necessary nit000 to performed the init)
-
-      ! finalise the computation and recover all arrays
-      ! -----------------------------------------------
-      l_trdtra = llsave
-      z12 = 2.e0
-      IF( neuler == 1)   z12 = 1.e0
-      IF( ln_zdfexp ) THEN      ! ta,sa are the trends
-         t0_ldf(:,:,:) = tsa(:,:,:,jp_tem)
-         s0_ldf(:,:,:) = tsa(:,:,:,jp_sal)
-      ELSE
-         DO jk = 1, jpkm1
-            t0_ldf(:,:,jk) = ( tsa(:,:,jk,jp_tem) - tsb(:,:,jk,jp_tem) ) / ( z12 *rdttra(jk) )
-            s0_ldf(:,:,jk) = ( tsa(:,:,jk,jp_sal) - tsb(:,:,jk,jp_sal) ) / ( z12 *rdttra(jk) )
-         END DO
-      ENDIF
-      tsb(:,:,:,jp_tem) = ztb (:,:,:)
-      tsb(:,:,:,jp_sal) = zsb (:,:,:)
-      tsa(:,:,:,jp_tem) = ua  (:,:,:)
-      tsa(:,:,:,jp_sal) = va  (:,:,:)
-      avt(:,:,:)        = zavt(:,:,:)
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, zt_ref, zs_ref, ztb, zsb, zavt ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ldf_ano')
-      !
-   END SUBROUTINE ldf_ano
-
-#else
-   !!----------------------------------------------------------------------
-   !!   default option :   Dummy code   NO T & S background profiles
-   !!----------------------------------------------------------------------
-   SUBROUTINE ldf_ano
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) 'tra:ldf_ano : lateral diffusion acting on the full fields'
-         WRITE(numout,*) '~~~~~~~~~~~'
-      ENDIF
-   END SUBROUTINE ldf_ano
-#endif
 
    !!======================================================================
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 6040)
+++ 	(revision )
@@ -1,189 +1,0 @@
-MODULE traldf_bilap
-   !!==============================================================================
-   !!                   ***  MODULE  traldf_bilap  ***
-   !! Ocean  tracers:  horizontal component of the lateral tracer mixing trend
-   !!==============================================================================
-   !! History :  OPA  !  1991-11  (G. Madec)  Original code
-   !!                 !  1993-03  (M. Guyon)  symetrical conditions
-   !!                 !  1995-11  (G. Madec)  suppress volumetric scale factors
-   !!                 !  1996-01  (G. Madec)  statement function for e3
-   !!                 !  1996-01  (M. Imbard)  mpp exchange
-   !!                 !  1997-07  (G. Madec)  optimization, and ahtt
-   !!            8.5  !  2002-08  (G. Madec)  F90: Free form and module
-   !!   NEMO     1.0  !  2004-08  (C. Talandier) New trends organization
-   !!             -   !  2005-11  (G. Madec)  zps or sco as default option
-   !!            3.3  !  2010-05  (C. Ethe, G. Madec)  merge TRC-TRA 
-   !!==============================================================================
-
-   !!----------------------------------------------------------------------
-   !!   tra_ldf_bilap : update the tracer trend with the horizontal diffusion
-   !!                   using a iso-level biharmonic operator
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and active tracers
-   USE dom_oce         ! ocean space and time domain
-   USE ldftra_oce      ! ocean tracer   lateral physics
-   USE in_out_manager  ! I/O manager
-   USE ldfslp          ! iso-neutral slopes 
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE diaptr          ! poleward transport diagnostics
-   USE trc_oce         ! share passive tracers/Ocean variables
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo       ! Memory Allocation
-   USE timing         ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_ldf_bilap   ! routine called by step.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
-#  include "ldfeiv_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
- 
-   SUBROUTINE tra_ldf_bilap( kt, kit000, cdtype, pgu, pgv,            &
-      &                                          pgui, pgvi,          &
-      &                                  ptb, pta, kjpt )  
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_ldf_bilap  ***
-      !!
-      !! ** Purpose :   Compute the before horizontal tracer diffusive 
-      !!      trend and add it to the general trend of tracer equation.
-      !!
-      !! ** Method  :   4th order diffusive operator along model level surfaces 
-      !!      evaluated using before fields (forward time scheme). The hor.
-      !!      diffusive trends  is given by:
-      !!      Laplacian of tb:
-      !!         zlt   = 1/(e1t*e2t*e3t) {  di-1[ e2u*e3u/e1u di(tb) ]
-      !!                                  + dj-1[ e1v*e3v/e2v dj(tb) ]  }
-      !!      Multiply by the eddy diffusivity coef. and insure lateral bc:
-      !!        zlt   = ahtt * zlt
-      !!        call to lbc_lnk
-      !!      Bilaplacian (laplacian of zlt):
-      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ e2u*e3u/e1u di(zlt) ]
-      !!                                  + dj-1[ e1v*e3v/e2v dj(zlt) ]  }
-      !!
-      !!      Add this trend to the general trend
-      !!         (pta) = (pta) + ( difft )
-      !!
-      !! ** Action : - Update pta arrays with the before iso-level
-      !!               biharmonic mixing trend.
-      !!----------------------------------------------------------------------
-      USE oce     , ONLY:   ztu  => ua       , ztv  => va                           ! (ua,va) used as workspace
-      !!
-      INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt       ! number of tracers
-      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgu , pgv  ! tracer gradient at pstep levels
-      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgui, pgvi ! tracer gradient at pstep levels
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend 
-      !!
-      INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp) ::  zbtr, ztra       ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:) ::  zeeu, zeev, zlt
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start( 'tra_ldf_bilap')
-      !
-      CALL wrk_alloc( jpi, jpj, zeeu, zeev, zlt ) 
-      !
-
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_ldf_bilap : iso-level biharmonic operator on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~'
-      ENDIF
-      !                                                          ! ===========
-      DO jn = 1, kjpt                                            ! tracer loop
-         !                                                       ! ===========
-         !                                               
-         DO jk = 1, jpkm1                                        ! Horizontal slab
-            !                                             
-            !                          !==  Initialization of metric arrays (for z- or s-coordinates)  ==!
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zeeu(ji,jj) = re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk) * umask(ji,jj,jk)
-                  zeev(ji,jj) = re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk) * vmask(ji,jj,jk)
-               END DO
-            END DO
-            !                          !==  Laplacian  ==!
-            !
-            DO jj = 1, jpjm1                 ! First derivative (gradient)
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  ztu(ji,jj,jk) = zeeu(ji,jj) * ( ptb(ji+1,jj  ,jk,jn) - ptb(ji,jj,jk,jn) )
-                  ztv(ji,jj,jk) = zeev(ji,jj) * ( ptb(ji  ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
-               END DO
-            END DO
-            !
-            IF( ln_zps ) THEN                ! set gradient at partial step level (last ocean level)
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     IF( mbku(ji,jj) == jk )  ztu(ji,jj,jk) = zeeu(ji,jj) * pgu(ji,jj,jn)
-                     IF( mbkv(ji,jj) == jk )  ztv(ji,jj,jk) = zeev(ji,jj) * pgv(ji,jj,jn)
-                  END DO
-               END DO
-            ENDIF
-            ! (ISH)
-            IF( ln_zps .AND. ln_isfcav ) THEN ! set gradient at partial step level (first ocean level in a cavity)
-               DO jj = 1, jpjm1
-                  DO ji = 1, jpim1
-                     IF( miku(ji,jj) == MAX(jk,2) )  ztu(ji,jj,jk) = zeeu(ji,jj) * pgui(ji,jj,jn)
-                     IF( mikv(ji,jj) == MAX(jk,2) )  ztu(ji,jj,jk) = zeev(ji,jj) * pgvi(ji,jj,jn)
-                  END DO
-               END DO
-            ENDIF
-            !
-            DO jj = 2, jpjm1                 ! Second derivative (divergence) time the eddy diffusivity coefficient
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                  zlt(ji,jj) = fsahtt(ji,jj,jk) * zbtr * (   ztu(ji,jj,jk) - ztu(ji-1,jj,jk)   &
-                     &                                     + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)   )
-               END DO
-            END DO
-            CALL lbc_lnk( zlt, 'T', 1. )     ! Lateral boundary conditions (unchanged sgn)
-
-            !                          !==  Bilaplacian  ==!
-            !
-            DO jj = 1, jpjm1                 ! third derivative (gradient)
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  ztu(ji,jj,jk) = zeeu(ji,jj) * ( zlt(ji+1,jj  ) - zlt(ji,jj) )
-                  ztv(ji,jj,jk) = zeev(ji,jj) * ( zlt(ji  ,jj+1) - zlt(ji,jj) )
-               END DO
-            END DO
-            DO jj = 2, jpjm1                 ! fourth derivative (divergence) and add to the general tracer trend
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  ! horizontal diffusive trends
-                  zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                  ztra = zbtr * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk) + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
-                  ! add it to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-            !                                             
-         END DO                                           ! Horizontal slab
-         !                                                
-         ! "zonal" mean lateral diffusive heat and salt transport
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_ldf(:) = ptr_sj( ztv(:,:,:) )
-           IF( jn == jp_sal )  str_ldf(:) = ptr_sj( ztv(:,:,:) )
-         ENDIF
-         !                                                ! ===========
-      END DO                                              ! tracer loop
-      !                                                   ! ===========
-      IF( nn_timing == 1 )  CALL timing_stop( 'tra_ldf_bilap')
-      !
-      CALL wrk_dealloc( jpi, jpj, zeeu, zeev, zlt ) 
-      !
-   END SUBROUTINE tra_ldf_bilap
-
-   !!==============================================================================
-END MODULE traldf_bilap
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 6040)
+++ 	(revision )
@@ -1,363 +1,0 @@
-MODULE traldf_bilapg
-   !!==============================================================================
-   !!                       ***  MODULE  traldf_bilapg  ***
-   !! Ocean  tracers:  horizontal component of the lateral tracer mixing trend
-   !!==============================================================================
-   !! History : 8.0   ! 1997-07  (G. Madec)  Original code
-   !!   NEMO    1.0   ! 2002-08  (G. Madec)  F90: Free form and module
-   !!           3.3   ! 2010-06  (C. Ethe, G. Madec) Merge TRA-TRC
-   !!==============================================================================
-#if defined key_ldfslp   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!   'key_ldfslp'                  rotation of the lateral mixing tensor
-   !!----------------------------------------------------------------------
-   !!   tra_ldf_bilapg : update the tracer trend with the horizontal diffusion
-   !!                    using an horizontal biharmonic operator in s-coordinate 
-   !!   ldfght         :  ???
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE in_out_manager  ! I/O manager
-   USE ldfslp          ! iso-neutral slopes available
-   USE lbclnk          ! ocean lateral boundary condition (or mpp link)
-   USE diaptr          ! poleward transport diagnostics 
-   USE trc_oce         ! share passive tracers/Ocean variables
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_ldf_bilapg   ! routine called by step.F90
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
-#  include "ldfeiv_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   SUBROUTINE tra_ldf_bilapg( kt, kit000, cdtype, ptb, pta, kjpt )
-      !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE tra_ldf_bilapg  ***
-      !!                    
-      !! ** Purpose :   Compute the before horizontal tracer diffusive 
-      !!      trend and add it to the general trend of tracer equation.
-      !!
-      !! ** Method  :   The lateral diffusive trends is provided by a 4th order
-      !!      operator rotated along geopotential surfaces. It is computed
-      !!      using before fields (forward in time) and geopotential slopes
-      !!      computed in routine inildf.
-      !!         -1- compute the geopotential harmonic operator applied to
-      !!        ptb and multiply it by the eddy diffusivity coefficient
-      !!       (done by a call to ldfght routine, result in wk1 arrays).
-      !!      Applied the domain lateral boundary conditions by call to lbc_lnk
-      !!         -2- compute the geopotential harmonic operator applied to
-      !!      wk1 by a second call to ldfght routine (result in wk2)
-      !!      arrays).
-      !!         -3- Add this trend to the general trend 
-      !!            pta = pta + wk2
-      !!
-      !! ** Action : - Update pta arrays with the before geopotential 
-      !!               biharmonic mixing trend.
-      !!----------------------------------------------------------------------
-      !
-      INTEGER         , INTENT(in   )                      ::   kt       ! ocean time-step index
-      INTEGER         , INTENT(in   )                      ::   kit000   ! first time step index
-      CHARACTER(len=3), INTENT(in   )                      ::   cdtype   ! =TRA or TRC (tracer indicator)
-      INTEGER         , INTENT(in   )                      ::   kjpt     ! number of tracers
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb      ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta      ! tracer trend 
-      !
-      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
-      REAL(wp), POINTER, DIMENSION(:,:,:,:) :: zwk1, zwk2 
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_ldf_bilapg')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, kjpt, zwk1, zwk2 ) 
-      !
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_ldf_bilapg : horizontal biharmonic operator in s-coordinate on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'
-      ENDIF
-
-      ! 1. Laplacian of ptb * aht
-      ! ----------------------------- 
-      CALL ldfght( kt, cdtype, ptb, zwk1, kjpt, 1 )      ! rotated harmonic operator applied to ptb and multiply by aht 
-      !                                                 ! output in wk1 
-      !
-      DO jn = 1, kjpt
-         CALL lbc_lnk( zwk1(:,:,:,jn) , 'T', 1. )        ! Lateral boundary conditions on wk1   (unchanged sign)
-      END DO
-
-      ! 2. Bilaplacian of ptb
-      ! -------------------------
-      CALL ldfght( kt, cdtype, zwk1, zwk2, kjpt, 2 )      ! rotated harmonic operator applied to wk1 ; output in wk2
-
-
-      ! 3. Update the tracer trends                    (j-slab :   2, jpj-1)
-      ! ---------------------------
-      DO jn = 1, kjpt
-         DO jj = 2, jpjm1
-            DO jk = 1, jpkm1
-               DO ji = 2, jpim1
-                  ! add it to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zwk2(ji,jj,jk,jn)
-               END DO
-            END DO
-         END DO
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj, jpk, kjpt, zwk1, zwk2 ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_bilapg')
-      !
-   END SUBROUTINE tra_ldf_bilapg
-
-
-   SUBROUTINE ldfght ( kt, cdtype, pt, plt, kjpt, kaht )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE ldfght  ***
-      !!          
-      !! ** Purpose :   Apply a geopotential harmonic operator to (pt) and 
-      !!      multiply it by the eddy diffusivity coefficient (if kaht=1).
-      !!      Routine only used in s-coordinates (l_sco=T) with bilaplacian
-      !!      operator (ln_traldf_bilap=T) acting along geopotential surfaces
-      !!      (ln_traldf_hor).
-      !!
-      !! ** Method  :   The harmonic operator rotated along geopotential 
-      !!      surfaces is applied to (pt) using the slopes of geopotential
-      !!      surfaces computed in inildf routine. The result is provided in
-      !!      (plt,pls) arrays. It is computed in 2 steps:
-      !!
-      !!      First step: horizontal part of the operator. It is computed on
-      !!      ==========  pt as follows (idem on ps)
-      !!      horizontal fluxes :
-      !!         zftu = e2u*e3u/e1u di[ pt ] - e2u*uslp dk[ mi(mk(pt)) ]
-      !!         zftv = e1v*e3v/e2v dj[ pt ] - e1v*vslp dk[ mj(mk(pt)) ]
-      !!      take the horizontal divergence of the fluxes (no divided by
-      !!      the volume element :
-      !!         plt  = di-1[ zftu ] +  dj-1[ zftv ]
-      !!
-      !!      Second step: vertical part of the operator. It is computed on
-      !!      ===========  pt as follows (idem on ps)
-      !!      vertical fluxes :
-      !!         zftw = e1t*e2t/e3w * (wslpi^2+wslpj^2)  dk-1[ pt ]
-      !!              -     e2t     *       wslpi        di[ mi(mk(pt)) ]
-      !!              -     e1t     *       wslpj        dj[ mj(mk(pt)) ]
-      !!      take the vertical divergence of the fluxes add it to the hori-
-      !!      zontal component, divide the result by the volume element and
-      !!      if kaht=1, multiply by the eddy diffusivity coefficient:
-      !!         plt  = aht / (e1t*e2t*e3t) { plt + dk[ zftw ] }
-      !!      else:
-      !!         plt  =  1  / (e1t*e2t*e3t) { plt + dk[ zftw ] }
-      !!
-      !!----------------------------------------------------------------------
-      USE oce     , ONLY:   zftv => ua       ! ua used as workspace
-      !
-      INTEGER         , INTENT(in )                              ::  kt      ! ocean time-step index
-      CHARACTER(len=3), INTENT(in )                              ::  cdtype  ! =TRA or TRC (tracer indicator) 
-      INTEGER         , INTENT(in )                              ::  kjpt    !: dimension of 
-      REAL(wp)        , INTENT(in ), DIMENSION(jpi,jpj,jpk,kjpt) ::  pt      ! tracer fields ( before for 1st call
-      !                                                         ! and laplacian of these fields for 2nd call. 
-      REAL(wp)        , INTENT(out), DIMENSION(jpi,jpj,jpk,kjpt) ::  plt     !: partial harmonic operator applied to  pt  components except
-      !                                                             !: second order vertical derivative term  
-      INTEGER         , INTENT(in )                              ::  kaht    !: =1 multiply the laplacian by the eddy diffusivity coeff.
-      !                                                             !: =2 no multiplication 
-      !!
-      INTEGER ::   ji, jj, jk,jn          ! dummy loop indices
-      !                                   ! temporary scalars
-      REAL(wp) ::  zabe1, zabe2, zmku, zmkv 
-      REAL(wp) ::  zbtr, ztah, ztav
-      REAL(wp) ::  zcof0, zcof1, zcof2, zcof3, zcof4
-      REAL(wp), POINTER, DIMENSION(:,:) ::  zftu, zdkt, zdk1t
-      REAL(wp), POINTER, DIMENSION(:,:) ::  zftw, zdit, zdjt, zdj1t
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('ldfght')
-      !
-      CALL wrk_alloc( jpi, jpj, zftu, zdkt, zdk1t ) 
-      CALL wrk_alloc( jpi, jpk, zftw, zdit, zdjt, zdj1t ) 
-      !
-      DO jn = 1, kjpt
-         !                               ! ********** !   ! ===============
-         DO jk = 1, jpkm1                ! First step !   ! Horizontal slab
-            !                            ! ********** !   ! ===============
-            
-            ! I.1 Vertical gradient of pt and ps at level jk and jk+1
-            ! -------------------------------------------------------
-            !     surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
-            
-            zdk1t(:,:) = ( pt(:,:,jk,jn) - pt(:,:,jk+1,jn) ) * tmask(:,:,jk+1)
-            IF( jk == 1 ) THEN
-               zdkt(:,:) = zdk1t(:,:)
-            ELSE
-               zdkt(:,:) = ( pt(:,:,jk-1,jn) - pt(:,:,jk,jn) ) * tmask(:,:,jk)
-            ENDIF
-
-
-            ! I.2 Horizontal fluxes
-            ! ---------------------
-            
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zabe1 = re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk)
-                  zabe2 = re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk)
-                  
-                  zmku = 1./MAX( tmask(ji+1,jj,jk  )+tmask(ji,jj,jk+1)   &
-                     &          +tmask(ji+1,jj,jk+1)+tmask(ji,jj,jk  ),1. )
-                  zmkv = 1./MAX( tmask(ji,jj+1,jk  )+tmask(ji,jj,jk+1)   &
-                     &          +tmask(ji,jj+1,jk+1)+tmask(ji,jj,jk  ),1. )
-                  
-                  zcof1 = -e2u(ji,jj) * uslp(ji,jj,jk) * zmku
-                  zcof2 = -e1v(ji,jj) * vslp(ji,jj,jk) * zmkv
-                  
-                  zftu(ji,jj)= umask(ji,jj,jk) *   &
-                     &         (  zabe1 *( pt   (ji+1,jj,jk,jn) - pt(ji,jj,jk,jn) )   &
-                     &          + zcof1 *( zdkt (ji+1,jj) + zdk1t(ji,jj)     &
-                     &                    +zdk1t(ji+1,jj) + zdkt (ji,jj) )  )
-                  
-                  zftv(ji,jj,jk)= vmask(ji,jj,jk) *   &
-                     &         (  zabe2 *( pt(ji,jj+1,jk,jn) - pt(ji,jj,jk,jn) )   &
-                     &          + zcof2 *( zdkt (ji,jj+1) + zdk1t(ji,jj)     &
-                     &                    +zdk1t(ji,jj+1) + zdkt (ji,jj) )  )                  
-               END DO
-            END DO
-
-
-            ! I.3 Second derivative (divergence) (not divided by the volume)
-            ! ---------------------
-            
-            DO jj = 2 , jpjm1
-               DO ji = 2 , jpim1
-                  ztah = zftu(ji,jj) - zftu(ji-1,jj) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)
-                  plt(ji,jj,jk,jn) = ztah
-               END DO
-            END DO
-            !                                             ! ===============
-         END DO                                           !   End of slab
-         !                                                ! ===============
-         ! "Poleward" diffusive heat or salt transport
-         IF( cdtype == 'TRA' .AND. ln_diaptr .AND. ( kaht == 2 ) ) THEN
-            ! note sign is reversed to give down-gradient diffusive transports (#1043)
-            IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( -zftv(:,:,:) )
-            IF( jn == jp_sal)   str_ldf(:) = ptr_sj( -zftv(:,:,:) )
-         ENDIF
-
-         !                             ! ************ !   ! ===============
-         DO jj = 2, jpjm1              !  Second step !   ! Horizontal slab
-            !                          ! ************ !   ! ===============
-            
-            ! II.1 horizontal tracer gradient
-            ! -------------------------------
-            
-            DO jk = 1, jpk
-               DO ji = 1, jpim1
-                  zdit (ji,jk) = ( pt(ji+1,jj  ,jk,jn) - pt(ji,jj  ,jk,jn) ) * umask(ji,jj  ,jk)
-                  zdjt (ji,jk) = ( pt(ji  ,jj+1,jk,jn) - pt(ji,jj  ,jk,jn) ) * vmask(ji,jj  ,jk)
-                  zdj1t(ji,jk) = ( pt(ji  ,jj  ,jk,jn) - pt(ji,jj-1,jk,jn) ) * vmask(ji,jj-1,jk)
-               END DO
-            END DO
-
-
-            ! II.2 Vertical fluxes
-            ! --------------------
-            
-            ! Surface and bottom vertical fluxes set to zero
-            zftw(:, 1 ) = 0.e0
-            zftw(:,jpk) = 0.e0
-            
-            ! interior (2=<jk=<jpk-1)
-            DO jk = 2, jpkm1
-               DO ji = 2, jpim1
-                  zcof0 = e12t(ji,jj) / fse3w_n(ji,jj,jk)   &
-                     &     * (  wslpi(ji,jj,jk) * wslpi(ji,jj,jk)        &
-                     &        + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)  )
-                  
-                  zmku = 1./MAX(  umask(ji  ,jj,jk-1)+umask(ji-1,jj,jk)   &
-                     &           +umask(ji-1,jj,jk-1)+umask(ji  ,jj,jk), 1. )
-                  
-                  zmkv = 1./MAX(  vmask(ji,jj  ,jk-1)+vmask(ji,jj-1,jk)   &
-                     &           +vmask(ji,jj-1,jk-1)+vmask(ji,jj  ,jk), 1. )
-                  
-                  zcof3 = - e2t(ji,jj) * wslpi (ji,jj,jk) * zmku
-                  zcof4 = - e1t(ji,jj) * wslpj (ji,jj,jk) * zmkv
-                  
-                  zftw(ji,jk) = tmask(ji,jj,jk) *   &
-                     &    (  zcof0 * ( pt   (ji,jj,jk-1,jn) - pt   (ji  ,jj,jk,jn) )   &
-                     &     + zcof3 * ( zdit (ji   ,jk-1   ) + zdit (ji-1,jk      )     &
-                     &                +zdit (ji-1 ,jk-1   ) + zdit (ji  ,jk      ) )   &
-                     &     + zcof4 * ( zdjt (ji   ,jk-1   ) + zdj1t(ji  ,jk)     &
-                     &                +zdj1t(ji   ,jk-1   ) + zdjt (ji  ,jk      ) )  )                 
-               END DO
-            END DO
-
-
-            ! II.3 Divergence of vertical fluxes added to the horizontal divergence
-            ! ---------------------------------------------------------------------
-            
-            IF( kaht == 1 ) THEN
-               ! multiply the laplacian by the eddy diffusivity coefficient
-               DO jk = 1, jpkm1
-                  DO ji = 2, jpim1
-                     ! eddy coef. divided by the volume element
-                     zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                     ! vertical divergence
-                     ztav = fsahtt(ji,jj,jk) * ( zftw(ji,jk) - zftw(ji,jk+1) )
-                     ! harmonic operator applied to (pt,ps) and multiply by aht
-                     plt(ji,jj,jk,jn) = ( plt(ji,jj,jk,jn) + ztav ) * zbtr
-                  END DO
-               END DO
-            ELSEIF( kaht == 2 ) THEN
-               ! second call, no multiplication
-               DO jk = 1, jpkm1
-                  DO ji = 2, jpim1
-                     ! inverse of the volume element
-                     zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                     ! vertical divergence
-                     ztav = zftw(ji,jk) - zftw(ji,jk+1)
-                     ! harmonic operator applied to (pt,ps) 
-                     plt(ji,jj,jk,jn) = ( plt(ji,jj,jk,jn) + ztav ) * zbtr
-                  END DO
-               END DO
-            ELSE
-               IF(lwp) WRITE(numout,*) ' ldfght: kaht= 1 or 2, here =', kaht
-               IF(lwp) WRITE(numout,*) '         We stop'
-               STOP 'ldfght'
-            ENDIF
-            !                                             ! ===============
-         END DO                                           !   End of slab
-         !                                                ! ===============
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj, zftu, zdkt, zdk1t ) 
-      CALL wrk_dealloc( jpi, jpk, zftw, zdit, zdjt, zdj1t ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('ldfght')
-      !
-   END SUBROUTINE ldfght
-
-#else  
-   !!----------------------------------------------------------------------
-   !!   Dummy module :             NO rotation of the lateral mixing tensor
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE tra_ldf_bilapg( kt, kit000, cdtype, ptb, pta, kjpt )      ! Empty routine
-      INTEGER :: kt, kit000
-      CHARACTER(len=3) ::   cdtype
-      REAL, DIMENSION(:,:,:,:) ::   ptb, pta
-      WRITE(*,*) 'tra_ldf_iso: You should not have seen this print! error?', &
-        &         kt, kit000, cdtype, ptb(1,1,1,1), pta(1,1,1,1), kjpt
-   END SUBROUTINE tra_ldf_bilapg
-#endif
-
-   !!==============================================================================
-END MODULE traldf_bilapg
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_blp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_blp.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_blp.F90	(revision 6041)
@@ -0,0 +1,148 @@
+MODULE traldf_blp
+   !!======================================================================
+   !!                   ***  MODULE  traldf_blp  ***
+   !! Ocean  tracers:  bilaplacian lateral mixing trend on tracers
+   !!======================================================================
+   !! History :  3.7  ! 2015-09  (G. Madec)  original code
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   traldf_blp    : update the tracer trend with the bilaplacian lateral mixing trend
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and active tracers
+   USE dom_oce        ! ocean space and time domain
+   USE phycst         ! physical constants
+   USE trc_oce        ! share passive tracers/Ocean variables
+   USE zdf_oce        ! ocean vertical physics
+   USE ldftra         ! lateral physics: eddy diffusivity
+   USE ldfslp         ! lateral physics: iso-neutral slopes
+   USE traldf_lap     ! lateral diffusion (Standard operator)         (tra_ldf_lap   routine)
+   USE traldf_iso     ! lateral diffusion (Standard operator)         (tra_ldf_iso   routine)
+   USE traldf_triad   ! lateral diffusion (Standard operator)         (tra_ldf_triad routine)
+   USE diaptr         ! poleward transport diagnostics
+   USE zpshde         ! partial step: hor. derivative     (zps_hde routine)
+   !
+   USE in_out_manager ! I/O manager
+   USE iom            ! I/O library
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_ldf_blp   ! routine called by traldf.F90
+
+   !                      ! Flag to control the type of lateral diffusive operator
+   INTEGER, PARAMETER, PUBLIC ::   np_ERROR  =-10   ! error in specification of lateral diffusion
+   INTEGER, PARAMETER, PUBLIC ::   np_no_ldf = 00   ! without operator (i.e. no lateral diffusive trend)
+   !                          !!      laplacian     !    bilaplacian    !
+   INTEGER, PARAMETER, PUBLIC ::   np_lap    = 10   ,   np_blp    = 20  ! iso-level operator
+   INTEGER, PARAMETER, PUBLIC ::   np_lap_i  = 11   ,   np_blp_i  = 21  ! standard iso-neutral or geopotential operator
+   INTEGER, PARAMETER, PUBLIC ::   np_lap_it = 12   ,   np_blp_it = 22  ! triad    iso-neutral or geopotential operator
+
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   zdkt3d   !: vertical tracer gradient at 2 levels
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id: traldf_iso_grif.F90 5147 2015-03-13 10:01:32Z cetlod $
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+   SUBROUTINE tra_ldf_blp( kt, kit000, cdtype, pahu, pahv, pgu , pgv ,   &
+      &                                                    pgui, pgvi,   &
+      &                                                    ptb , pta , kjpt, kldf )
+      !!----------------------------------------------------------------------
+      !!                 ***  ROUTINE tra_ldf_blp  ***
+      !!                    
+      !! ** Purpose :   Compute the before lateral tracer diffusive 
+      !!      trend and add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The lateral diffusive trends is provided by a bilaplacian
+      !!      operator applied to before field (forward in time).
+      !!      It is computed by two successive calls to laplacian routine
+      !!
+      !! ** Action :   pta   updated with the before rotated bilaplacian diffusion
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
+      INTEGER                              , INTENT(in   ) ::   kit000     ! first time step index
+      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
+      INTEGER                              , INTENT(in   ) ::   kjpt       ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kldf       ! type of operator used
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pahu, pahv ! eddy diffusivity at u- and v-points  [m2/s]
+      REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgu, pgv   ! tracer gradient at pstep levels
+      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgui, pgvi ! tracer gradient at top levels
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! before and now tracer fields
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend
+      !
+      INTEGER ::   ji, jj, jk, jn   ! dummy loop indices
+      REAL(wp), POINTER, DIMENSION(:,:,:,:) :: zlap         ! laplacian at t-point
+      REAL(wp), POINTER, DIMENSION(:,:,:)   :: zglu, zglv   ! bottom GRADh of the laplacian (u- and v-points)
+      REAL(wp), POINTER, DIMENSION(:,:,:)   :: zgui, zgvi   ! top    GRADh of the laplacian (u- and v-points)
+      !!---------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('tra_ldf_blp')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,kjpt,   zlap ) 
+      CALL wrk_alloc( jpi,jpj,    kjpt,   zglu, zglv, zgui, zgvi ) 
+      !
+      IF( kt == kit000 .AND. lwp )  THEN
+         WRITE(numout,*)
+         SELECT CASE ( kldf )
+         CASE ( np_blp    )   ;   WRITE(numout,*) 'tra_ldf_blp : iso-level   bilaplacian operator on ', cdtype
+         CASE ( np_blp_i  )   ;   WRITE(numout,*) 'tra_ldf_blp : iso-neutral bilaplacian operator on ', cdtype, ' (Standard)'
+         CASE ( np_blp_it )   ;   WRITE(numout,*) 'tra_ldf_blp : iso-neutral bilaplacian operator on ', cdtype, ' (triad)'
+         END SELECT
+         WRITE(numout,*) '~~~~~~~~~~~'
+      ENDIF
+
+      zlap(:,:,:,:) = 0._wp
+      !
+      SELECT CASE ( kldf )       !==  1st laplacian applied to ptb (output in zlap)  ==!
+      !
+      CASE ( np_blp    )               ! iso-level bilaplacian
+         CALL tra_ldf_lap  ( kt, kit000, cdtype, pahu, pahv, pgu, pgv, pgui, pgvi, ptb,      zlap, kjpt, 1 )
+         !
+      CASE ( np_blp_i  )               ! rotated   bilaplacian : standard operator (Madec)
+         CALL tra_ldf_iso  ( kt, kit000, cdtype, pahu, pahv, pgu, pgv, pgui, pgvi, ptb, ptb, zlap, kjpt, 1 )
+         !
+      CASE ( np_blp_it )               ! rotated  bilaplacian : triad operator (griffies)
+         CALL tra_ldf_triad( kt, kit000, cdtype, pahu, pahv, pgu, pgv, pgui, pgvi, ptb, ptb, zlap, kjpt, 1 )
+         !
+      END SELECT
+      !
+      DO jn = 1, kjpt
+         CALL lbc_lnk( zlap(:,:,:,jn) , 'T', 1. )     ! Lateral boundary conditions (unchanged sign)
+      END DO
+      !                                               ! Partial top/bottom cell: GRADh( zlap )  
+      IF( ln_isfcav .AND. ln_zps ) THEN   ;   CALL zps_hde_isf( kt, kjpt, zlap, zglu, zglv, zgui, zgvi )  ! both top & bottom
+      ELSEIF(             ln_zps ) THEN   ;   CALL zps_hde    ( kt, kjpt, zlap, zglu, zglv )              ! only bottom 
+      ENDIF
+      !
+      SELECT CASE ( kldf )       !==  2nd laplacian applied to zlap (output in pta)  ==!
+      !
+      CASE ( np_blp    )               ! iso-level bilaplacian
+         CALL tra_ldf_lap  ( kt, kit000, cdtype, pahu, pahv, zglu, zglv, zgui, zgvi, zlap, pta,      kjpt, 2 )
+         !
+      CASE ( np_blp_i  )               ! rotated   bilaplacian : standard operator (Madec)
+         CALL tra_ldf_iso  ( kt, kit000, cdtype, pahu, pahv, zglu, zglv, zgui, zgvi, zlap, ptb, pta, kjpt, 2 )
+         !
+      CASE ( np_blp_it )               ! rotated  bilaplacian : triad operator (griffies)
+         CALL tra_ldf_triad( kt, kit000, cdtype, pahu, pahv, zglu, zglv, zgui, zgvi, zlap, ptb, pta, kjpt, 2 )
+         !
+      END SELECT
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,kjpt,   zlap ) 
+      CALL wrk_dealloc( jpi,jpj    ,kjpt,   zglu, zglv, zgui, zgvi ) 
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_blp')
+      !
+   END SUBROUTINE tra_ldf_blp
+
+   !!==============================================================================
+END MODULE traldf_blp
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 6041)
@@ -4,18 +4,16 @@
    !! Ocean  tracers:  horizontal component of the lateral tracer mixing trend
    !!======================================================================
-   !! History :  OPA  !  1994-08  (G. Madec, M. Imbard)
-   !!            8.0  !  1997-05  (G. Madec)  split into traldf and trazdf
-   !!            NEMO !  2002-08  (G. Madec)  Free form, F90
-   !!            1.0  !  2005-11  (G. Madec)  merge traldf and trazdf :-)
-   !!            3.3  !  2010-09  (C. Ethe, G. Madec) Merge TRA-TRC
+   !! History :  OPA  ! 1994-08  (G. Madec, M. Imbard)
+   !!            8.0  ! 1997-05  (G. Madec)  split into traldf and trazdf
+   !!            NEMO ! 2002-08  (G. Madec)  Free form, F90
+   !!            1.0  ! 2005-11  (G. Madec)  merge traldf and trazdf :-)
+   !!            3.3  ! 2010-09  (C. Ethe, G. Madec) Merge TRA-TRC
+   !!            3.7  ! 2014-01  (G. Madec, S. Masson)  restructuration/simplification of aht/aeiv specification
+   !!             -   ! 2014-02  (F. Lemarie, G. Madec)  triad operator (Griffies) + Method of Stabilizing Correction
    !!----------------------------------------------------------------------
-#if   defined key_ldfslp   ||   defined key_esopa
+
    !!----------------------------------------------------------------------
-   !!   'key_ldfslp'               slope of the lateral diffusive direction
-   !!----------------------------------------------------------------------
-   !!   tra_ldf_iso  : update the tracer trend with the horizontal 
-   !!                  component of a iso-neutral laplacian operator
-   !!                  and with the vertical part of
-   !!                  the isopycnal or geopotential s-coord. operator 
+   !!   tra_ldf_iso  : update the tracer trend with the horizontal component of a iso-neutral laplacian operator
+   !!                  and with the vertical part of the isopycnal or geopotential s-coord. operator 
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and active tracers
@@ -23,7 +21,8 @@
    USE trc_oce         ! share passive tracers/Ocean variables
    USE zdf_oce         ! ocean vertical physics
-   USE ldftra_oce      ! ocean active tracers: lateral physics
+   USE ldftra          ! lateral diffusion: tracer eddy coefficients
    USE ldfslp          ! iso-neutral slopes
    USE diaptr          ! poleward transport diagnostics
+   !
    USE in_out_manager  ! I/O manager
    USE iom             ! I/O library
@@ -40,8 +39,7 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -49,7 +47,7 @@
 CONTAINS
 
-   SUBROUTINE tra_ldf_iso( kt, kit000, cdtype, pgu, pgv,              &
-      &                                pgui, pgvi,                    &
-      &                                ptb, pta, kjpt, pahtb0 )
+  SUBROUTINE tra_ldf_iso( kt, kit000, cdtype, pahu, pahv, pgu , pgv ,   &
+      &                                                   pgui, pgvi,   &
+      &                                       ptb , ptbb, pta , kjpt, kpass )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE tra_ldf_iso  ***
@@ -66,14 +64,15 @@
       !!
       !!      1st part :  masked horizontal derivative of T  ( di[ t ] )
-      !!      ========    with partial cell update if ln_zps=T.
+      !!      ========    with partial cell update if ln_zps=T
+      !!                  with top     cell update if ln_isfcav
       !!
       !!      2nd part :  horizontal fluxes of the lateral mixing operator
       !!      ========    
-      !!         zftu = (aht+ahtb0) e2u*e3u/e1u di[ tb ]
-      !!               - aht       e2u*uslp    dk[ mi(mk(tb)) ]
-      !!         zftv = (aht+ahtb0) e1v*e3v/e2v dj[ tb ]
-      !!               - aht       e2u*vslp    dk[ mj(mk(tb)) ]
+      !!         zftu =  pahu e2u*e3u/e1u di[ tb ]
+      !!               - pahu e2u*uslp    dk[ mi(mk(tb)) ]
+      !!         zftv =  pahv e1v*e3v/e2v dj[ tb ]
+      !!               - pahv e2u*vslp    dk[ mj(mk(tb)) ]
       !!      take the horizontal divergence of the fluxes:
-      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ zftu ] +  dj-1[ zftv ]  }
+      !!         difft = 1/(e1e2t*e3t) {  di-1[ zftu ] +  dj-1[ zftv ]  }
       !!      Add this trend to the general trend (ta,sa):
       !!         ta = ta + difft
@@ -82,8 +81,8 @@
       !!      ========  (excluding the vertical flux proportional to dk[t] )
       !!      vertical fluxes associated with the rotated lateral mixing:
-      !!         zftw =-aht {  e2t*wslpi di[ mi(mk(tb)) ]
-      !!                     + e1t*wslpj dj[ mj(mk(tb)) ]  }
+      !!         zftw = - {  mi(mk(pahu)) * e2t*wslpi di[ mi(mk(tb)) ]
+      !!                   + mj(mk(pahv)) * e1t*wslpj dj[ mj(mk(tb)) ]  }
       !!      take the horizontal divergence of the fluxes:
-      !!         difft = 1/(e1t*e2t*e3t) dk[ zftw ]
+      !!         difft = 1/(e1e2t*e3t) dk[ zftw ]
       !!      Add this trend to the general trend (ta,sa):
       !!         pta = pta + difft
@@ -91,35 +90,116 @@
       !! ** Action :   Update pta arrays with the before rotated diffusion
       !!----------------------------------------------------------------------
-      USE oce     , ONLY:   zftu => ua       , zftv  => va         ! (ua,va) used as workspace
-      !
       INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
+      INTEGER                              , INTENT(in   ) ::   kit000     ! first time step index
       CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
       INTEGER                              , INTENT(in   ) ::   kjpt       ! number of tracers
-      REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgu , pgv    ! tracer gradient at pstep levels
-      REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgui, pgvi   ! tracer gradient at pstep levels
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend 
-      REAL(wp)                             , INTENT(in   ) ::   pahtb0     ! background diffusion coef
+      INTEGER                              , INTENT(in   ) ::   kpass      ! =1/2 first or second passage
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pahu, pahv ! eddy diffusivity at u- and v-points  [m2/s]
+      REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgu, pgv   ! tracer gradient at pstep levels
+      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgui, pgvi ! tracer gradient at top   levels
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! tracer (kpass=1) or laplacian of tracer (kpass=2)
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptbb       ! tracer (only used in kpass=2)
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend
       !
       INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
-      INTEGER  ::  ikt
-      REAL(wp) ::  zmsku, zabe1, zcof1, zcoef3   ! local scalars
-      REAL(wp) ::  zmskv, zabe2, zcof2, zcoef4   !   -      -
-      REAL(wp) ::  zcoef0, zbtr, ztra            !   -      -
-      REAL(wp), POINTER, DIMENSION(:,:  ) ::  z2d
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zdkt, zdk1t, zdit, zdjt, ztfw 
+      INTEGER  ::  ierr             ! local integer
+      REAL(wp) ::  zmsku, zahu_w, zabe1, zcof1, zcoef3   ! local scalars
+      REAL(wp) ::  zmskv, zahv_w, zabe2, zcof2, zcoef4   !   -      -
+      REAL(wp) ::  zcoef0, ze3w_2, zsign, z2dt, z1_2dt   !   -      -
+#if defined key_diaar5
+      REAL(wp) ::   zztmp   ! local scalar
+#endif
+      REAL(wp), POINTER, DIMENSION(:,:)   ::   zdkt, zdk1t, z2d
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdit, zdjt, zftu, zftv, ztfw 
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('tra_ldf_iso')
       !
-      CALL wrk_alloc( jpi, jpj,      z2d ) 
-      CALL wrk_alloc( jpi, jpj, jpk, zdit, zdjt, ztfw, zdkt, zdk1t ) 
-      !
-
+      CALL wrk_alloc( jpi,jpj,       zdkt, zdk1t, z2d ) 
+      CALL wrk_alloc( jpi,jpj,jpk,   zdit, zdjt , zftu, zftv, ztfw  ) 
+      !
       IF( kt == kit000 )  THEN
          IF(lwp) WRITE(numout,*)
          IF(lwp) WRITE(numout,*) 'tra_ldf_iso : rotated laplacian diffusion operator on ', cdtype
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+         !
+         akz     (:,:,:) = 0._wp      
+         ah_wslp2(:,:,:) = 0._wp
+      ENDIF
+      !
+      !                                               ! set time step size (Euler/Leapfrog)
+      IF( neuler == 0 .AND. kt == nit000 ) THEN   ;   z2dt =     rdttra(1)      ! at nit000   (Euler)
+      ELSE                                        ;   z2dt = 2.* rdttra(1)      !             (Leapfrog)
+      ENDIF
+      z1_2dt = 1._wp / z2dt
+      !
+      IF( kpass == 1 ) THEN   ;   zsign =  1._wp      ! bilaplacian operator require a minus sign (eddy diffusivity >0)
+      ELSE                    ;   zsign = -1._wp
+      ENDIF
+         
+         
+      !!----------------------------------------------------------------------
+      !!   0 - calculate  ah_wslp2 and akz
+      !!----------------------------------------------------------------------
+      !
+      IF( kpass == 1 ) THEN                  !==  first pass only  ==!
+         !
+         DO jk = 2, jpkm1
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1   ! vector opt.
+                  !
+                  zmsku = tmask(ji,jj,jk) / MAX(   umask(ji  ,jj,jk-1) + umask(ji-1,jj,jk)          &
+                     &                           + umask(ji-1,jj,jk-1) + umask(ji  ,jj,jk) , 1._wp  )
+                  zmskv = tmask(ji,jj,jk) / MAX(   vmask(ji,jj  ,jk-1) + vmask(ji,jj-1,jk)          &
+                     &                           + vmask(ji,jj-1,jk-1) + vmask(ji,jj  ,jk) , 1._wp  )
+                     !
+                  zahu_w = (   pahu(ji  ,jj,jk-1) + pahu(ji-1,jj,jk)    &
+                     &       + pahu(ji-1,jj,jk-1) + pahu(ji  ,jj,jk)  ) * zmsku
+                  zahv_w = (   pahv(ji,jj  ,jk-1) + pahv(ji,jj-1,jk)    &
+                     &       + pahv(ji,jj-1,jk-1) + pahv(ji,jj  ,jk)  ) * zmskv
+                     !
+                  ah_wslp2(ji,jj,jk) = zahu_w * wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
+                     &               + zahv_w * wslpj(ji,jj,jk) * wslpj(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         !
+         IF( ln_traldf_msc ) THEN                ! stabilizing vertical diffusivity coefficient
+            DO jk = 2, jpkm1
+               DO jj = 2, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     akz(ji,jj,jk) = 0.25_wp * (                                                                     &
+                        &              ( pahu(ji  ,jj,jk) + pahu(ji  ,jj,jk-1) ) / ( e1u(ji  ,jj) * e1u(ji  ,jj) )   &
+                        &            + ( pahu(ji-1,jj,jk) + pahu(ji-1,jj,jk-1) ) / ( e1u(ji-1,jj) * e1u(ji-1,jj) )   &
+                        &            + ( pahv(ji,jj  ,jk) + pahv(ji,jj  ,jk-1) ) / ( e2v(ji,jj  ) * e2v(ji,jj  ) )   &
+                        &            + ( pahv(ji,jj-1,jk) + pahv(ji,jj-1,jk-1) ) / ( e2v(ji,jj-1) * e2v(ji,jj-1) )   )
+                  END DO
+               END DO
+            END DO
+            !
+            IF( ln_traldf_blp ) THEN                ! bilaplacian operator
+               DO jk = 2, jpkm1
+                  DO jj = 1, jpjm1
+                     DO ji = 1, fs_jpim1
+                        akz(ji,jj,jk) = 16._wp * ah_wslp2(ji,jj,jk)   &
+                           &          * (  akz(ji,jj,jk) + ah_wslp2(ji,jj,jk) / ( fse3w(ji,jj,jk) * fse3w(ji,jj,jk) )  )
+                     END DO
+                  END DO
+               END DO
+            ELSEIF( ln_traldf_lap ) THEN              ! laplacian operator
+               DO jk = 2, jpkm1
+                  DO jj = 1, jpjm1
+                     DO ji = 1, fs_jpim1
+                        ze3w_2 = fse3w(ji,jj,jk) * fse3w(ji,jj,jk)
+                        zcoef0 = z2dt * (  akz(ji,jj,jk) + ah_wslp2(ji,jj,jk) / ze3w_2  )
+                        akz(ji,jj,jk) = MAX( zcoef0 - 0.5_wp , 0._wp ) * ze3w_2 * z1_2dt
+                     END DO
+                  END DO
+               END DO
+           ENDIF
+           !
+         ELSE                                    ! 33 flux set to zero with akz=ah_wslp2 ==>> computed in full implicit
+            akz(:,:,:) = ah_wslp2(:,:,:)      
+         ENDIF
       ENDIF
       !
@@ -131,7 +211,7 @@
          !!   I - masked horizontal derivative 
          !!----------------------------------------------------------------------
-         !!bug ajout.... why?   ( 1,jpj,:) and (jpi,1,:) should be sufficient....
-         zdit (1,:,:) = 0.e0     ;     zdit (jpi,:,:) = 0.e0
-         zdjt (1,:,:) = 0.e0     ;     zdjt (jpi,:,:) = 0.e0
+!!gm : bug.... why (x,:,:)?   (1,jpj,:) and (jpi,1,:) should be sufficient....
+         zdit (1,:,:) = 0._wp     ;     zdit (jpi,:,:) = 0._wp
+         zdjt (1,:,:) = 0._wp     ;     zdjt (jpi,:,:) = 0._wp
          !!end
 
@@ -145,61 +225,50 @@
             END DO
          END DO
-
-         ! partial cell correction
-         IF( ln_zps ) THEN      ! partial steps correction at the last ocean level 
-            DO jj = 1, jpjm1
+         IF( ln_zps ) THEN      ! botton and surface ocean correction of the horizontal gradient
+            DO jj = 1, jpjm1              ! bottom correction (partial bottom cell)
                DO ji = 1, fs_jpim1   ! vector opt.
-! IF useless if zpshde defines pgu everywhere
+!!gm  the following anonymous remark is to considered: ! IF useless if zpshde defines pgu everywhere
                   zdit(ji,jj,mbku(ji,jj)) = pgu(ji,jj,jn)          
                   zdjt(ji,jj,mbkv(ji,jj)) = pgv(ji,jj,jn)
                END DO
             END DO
+            IF( ln_isfcav ) THEN      ! first wet level beneath a cavity
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     IF( miku(ji,jj) > 1 )   zdit(ji,jj,miku(ji,jj)) = pgui(ji,jj,jn)          
+                     IF( mikv(ji,jj) > 1 )   zdjt(ji,jj,mikv(ji,jj)) = pgvi(ji,jj,jn)     
+                  END DO
+               END DO
+            ENDIF
          ENDIF
-         IF( ln_zps .AND. ln_isfcav ) THEN      ! partial steps correction at the first wet level beneath a cavity
-            DO jj = 1, jpjm1
+
+         !!----------------------------------------------------------------------
+         !!   II - horizontal trend  (full)
+         !!----------------------------------------------------------------------
+         !
+         DO jk = 1, jpkm1                                 ! Horizontal slab
+            !
+            !                             !== Vertical tracer gradient
+            zdk1t(:,:) = ( ptb(:,:,jk,jn) - ptb(:,:,jk+1,jn) ) * wmask(:,:,jk+1)     ! level jk+1
+            !
+            IF( jk == 1 ) THEN   ;   zdkt(:,:) = zdk1t(:,:)                          ! surface: zdkt(jk=1)=zdkt(jk=2)
+            ELSE                 ;   zdkt(:,:) = ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) ) * wmask(:,:,jk)
+            ENDIF
+!!gm I don't understand why we should need this.... since wmask is used instead of tmask
+!         IF ( ln_isfcav ) THEN
+!            DO jj = 1, jpj
+!               DO ji = 1, jpi   ! vector opt.
+!                  ikt = mikt(ji,jj) ! surface level
+!                  zdk1t(ji,jj,ikt) = ( ptb(ji,jj,ikt,jn  ) - ptb(ji,jj,ikt+1,jn) ) * wmask(ji,jj,ikt+1)
+!                  zdkt (ji,jj,ikt) = zdk1t(ji,jj,ikt)
+!               END DO
+!            END DO
+!         END IF
+!!gm 
+
+            DO jj = 1 , jpjm1            !==  Horizontal fluxes
                DO ji = 1, fs_jpim1   ! vector opt.
-                  IF (miku(ji,jj) > 1) zdit(ji,jj,miku(ji,jj)) = pgui(ji,jj,jn)          
-                  IF (mikv(ji,jj) > 1) zdjt(ji,jj,mikv(ji,jj)) = pgvi(ji,jj,jn)     
-               END DO
-            END DO
-         END IF
-
-         !!----------------------------------------------------------------------
-         !!   II - horizontal trend  (full)
-         !!----------------------------------------------------------------------
-!!!!!!!!!!CDIR PARALLEL DO PRIVATE( zdk1t ) 
-            ! 1. Vertical tracer gradient at level jk and jk+1
-            ! ------------------------------------------------
-         ! 
-         ! interior value 
-         DO jk = 2, jpkm1               
-            DO jj = 1, jpj
-               DO ji = 1, jpi   ! vector opt.
-                  zdk1t(ji,jj,jk) = ( ptb(ji,jj,jk,jn  ) - ptb(ji,jj,jk+1,jn) ) * wmask(ji,jj,jk+1)
-                  !
-                  zdkt(ji,jj,jk)  = ( ptb(ji,jj,jk-1,jn) - ptb(ji,jj,jk,jn  ) ) * wmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         ! surface boundary condition: zdkt(jk=1)=zdkt(jk=2)
-         zdk1t(:,:,1) = ( ptb(:,:,1,jn  ) - ptb(:,:,2,jn) ) * wmask(:,:,2)
-         zdkt (:,:,1) = zdk1t(:,:,1)
-         IF ( ln_isfcav ) THEN
-            DO jj = 1, jpj
-               DO ji = 1, jpi   ! vector opt.
-                  ikt = mikt(ji,jj) ! surface level
-                  zdk1t(ji,jj,ikt) = ( ptb(ji,jj,ikt,jn  ) - ptb(ji,jj,ikt+1,jn) ) * wmask(ji,jj,ikt+1)
-                  zdkt (ji,jj,ikt) = zdk1t(ji,jj,ikt)
-               END DO
-            END DO
-         END IF
-
-         ! 2. Horizontal fluxes
-         ! --------------------   
-         DO jk = 1, jpkm1
-            DO jj = 1 , jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zabe1 = ( fsahtu(ji,jj,jk) + pahtb0 ) * re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk)
-                  zabe2 = ( fsahtv(ji,jj,jk) + pahtb0 ) * re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk)
+                  zabe1 = pahu(ji,jj,jk) * e2_e1u(ji,jj) * fse3u_n(ji,jj,jk)
+                  zabe2 = pahv(ji,jj,jk) * e1_e2v(ji,jj) * fse3v_n(ji,jj,jk)
                   !
                   zmsku = 1. / MAX(  tmask(ji+1,jj,jk  ) + tmask(ji,jj,jk+1)   &
@@ -209,73 +278,31 @@
                      &             + tmask(ji,jj+1,jk+1) + tmask(ji,jj,jk  ), 1. )
                   !
-                  zcof1 = - fsahtu(ji,jj,jk) * e2u(ji,jj) * uslp(ji,jj,jk) * zmsku
-                  zcof2 = - fsahtv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv
+                  zcof1 = - pahu(ji,jj,jk) * e2u(ji,jj) * uslp(ji,jj,jk) * zmsku
+                  zcof2 = - pahv(ji,jj,jk) * e1v(ji,jj) * vslp(ji,jj,jk) * zmskv
                   !
                   zftu(ji,jj,jk ) = (  zabe1 * zdit(ji,jj,jk)   &
-                     &              + zcof1 * (  zdkt (ji+1,jj,jk) + zdk1t(ji,jj,jk)      &
-                     &                         + zdk1t(ji+1,jj,jk) + zdkt (ji,jj,jk)  )  ) * umask(ji,jj,jk)
+                     &               + zcof1 * (  zdkt (ji+1,jj) + zdk1t(ji,jj)      &
+                     &                          + zdk1t(ji+1,jj) + zdkt (ji,jj)  )  ) * umask(ji,jj,jk)
                   zftv(ji,jj,jk) = (  zabe2 * zdjt(ji,jj,jk)   &
-                     &              + zcof2 * (  zdkt (ji,jj+1,jk) + zdk1t(ji,jj,jk)      &
-                     &                         + zdk1t(ji,jj+1,jk) + zdkt (ji,jj,jk)  )  ) * vmask(ji,jj,jk)                  
-               END DO
-            END DO
-
-            ! II.4 Second derivative (divergence) and add to the general trend
-            ! ----------------------------------------------------------------
-            DO jj = 2 , jpjm1
+                     &               + zcof2 * (  zdkt (ji,jj+1) + zdk1t(ji,jj)      &
+                     &                          + zdk1t(ji,jj+1) + zdkt (ji,jj)  )  ) * vmask(ji,jj,jk)                  
+               END DO
+            END DO
+            !
+            DO jj = 2 , jpjm1          !== horizontal divergence and add to pta
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                  ztra = zbtr * ( zftu(ji,jj,jk) - zftu(ji-1,jj,jk) + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)  )
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
-               END DO
-            END DO
-            !                                          ! ===============
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zsign * (  zftu(ji,jj,jk) - zftu(ji-1,jj,jk)      &
+                     &                                           + zftv(ji,jj,jk) - zftv(ji,jj-1,jk)  )   &
+                     &                                        / (  e1e2t(ji,jj) * fse3t(ji,jj,jk)  )
+               END DO
+            END DO
          END DO                                        !   End of slab  
-         !                                             ! ===============
-         !
-         ! "Poleward" diffusive heat or salt transports (T-S case only)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            ! note sign is reversed to give down-gradient diffusive transports (#1043)
-            IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( -zftv(:,:,:) )
-            IF( jn == jp_sal)   str_ldf(:) = ptr_sj( -zftv(:,:,:) )
-         ENDIF
- 
-         IF( iom_use("udiff_heattr") .OR. iom_use("vdiff_heattr") ) THEN
-           !
-           IF( cdtype == 'TRA' .AND. jn == jp_tem  ) THEN
-               z2d(:,:) = 0._wp 
-               DO jk = 1, jpkm1
-                  DO jj = 2, jpjm1
-                     DO ji = fs_2, fs_jpim1   ! vector opt.
-                        z2d(ji,jj) = z2d(ji,jj) + zftu(ji,jj,jk) 
-                     END DO
-                  END DO
-               END DO
-               z2d(:,:) = - rau0_rcp * z2d(:,:)     ! note sign is reversed to give down-gradient diffusive transports (#1043)
-               CALL lbc_lnk( z2d, 'U', -1. )
-               CALL iom_put( "udiff_heattr", z2d )                  ! heat transport in i-direction
-               !
-               z2d(:,:) = 0._wp 
-               DO jk = 1, jpkm1
-                  DO jj = 2, jpjm1
-                     DO ji = fs_2, fs_jpim1   ! vector opt.
-                        z2d(ji,jj) = z2d(ji,jj) + zftv(ji,jj,jk) 
-                     END DO
-                  END DO
-               END DO
-               z2d(:,:) = - rau0_rcp * z2d(:,:)     ! note sign is reversed to give down-gradient diffusive transports (#1043)
-               CALL lbc_lnk( z2d, 'V', -1. )
-               CALL iom_put( "vdiff_heattr", z2d )                  !  heat transport in i-direction
-            END IF
-            !
-         ENDIF
-
-         !!----------------------------------------------------------------------
-         !!   III - vertical trend of T & S (extra diagonal terms only)
-         !!----------------------------------------------------------------------
-         
-         ! Local constant initialization
-         ! -----------------------------
-         ztfw(1,:,:) = 0.e0     ;     ztfw(jpi,:,:) = 0.e0
+
+
+         !!----------------------------------------------------------------------
+         !!   III - vertical trend (full)
+         !!----------------------------------------------------------------------
+         
+         ztfw(1,:,:) = 0._wp     ;     ztfw(jpi,:,:) = 0._wp
          
          ! Vertical fluxes
@@ -283,5 +310,5 @@
          
          ! Surface and bottom vertical fluxes set to zero
-         ztfw(:,:, 1 ) = 0.e0      ;      ztfw(:,:,jpk) = 0.e0
+         ztfw(:,:, 1 ) = 0._wp      ;      ztfw(:,:,jpk) = 0._wp
          
          ! interior (2=<jk=<jpk-1)
@@ -289,13 +316,17 @@
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zcoef0 = - fsahtw(ji,jj,jk) * wmask(ji,jj,jk)
-                  !
-                  zmsku = 1./MAX(   umask(ji  ,jj,jk-1) + umask(ji-1,jj,jk)      &
-                     &            + umask(ji-1,jj,jk-1) + umask(ji  ,jj,jk), 1.  )
-                  zmskv = 1./MAX(   vmask(ji,jj  ,jk-1) + vmask(ji,jj-1,jk)      &
-                     &            + vmask(ji,jj-1,jk-1) + vmask(ji,jj  ,jk), 1.  )
-                  !
-                  zcoef3 = zcoef0 * e2t(ji,jj) * zmsku * wslpi (ji,jj,jk)
-                  zcoef4 = zcoef0 * e1t(ji,jj) * zmskv * wslpj (ji,jj,jk)
+                  !
+                  zmsku = tmask(ji,jj,jk) / MAX(   umask(ji  ,jj,jk-1) + umask(ji-1,jj,jk)          &
+                     &                           + umask(ji-1,jj,jk-1) + umask(ji  ,jj,jk) , 1._wp  )
+                  zmskv = tmask(ji,jj,jk) / MAX(   vmask(ji,jj  ,jk-1) + vmask(ji,jj-1,jk)          &
+                     &                           + vmask(ji,jj-1,jk-1) + vmask(ji,jj  ,jk) , 1._wp  )
+                     !
+                  zahu_w = (   pahu(ji  ,jj,jk-1) + pahu(ji-1,jj,jk)    &
+                     &       + pahu(ji-1,jj,jk-1) + pahu(ji  ,jj,jk)  ) * zmsku
+                  zahv_w = (   pahv(ji,jj  ,jk-1) + pahv(ji,jj-1,jk)    &
+                     &       + pahv(ji,jj-1,jk-1) + pahv(ji,jj  ,jk)  ) * zmskv
+                     !
+                  zcoef3 = - zahu_w * e2t(ji,jj) * zmsku * wslpi (ji,jj,jk)   !wslpi & j are already w-masked
+                  zcoef4 = - zahv_w * e1t(ji,jj) * zmskv * wslpj (ji,jj,jk)
                   !
                   ztfw(ji,jj,jk) = zcoef3 * (   zdit(ji  ,jj  ,jk-1) + zdit(ji-1,jj  ,jk)      &
@@ -306,41 +337,105 @@
             END DO
          END DO
-         
-         
-         ! I.5 Divergence of vertical fluxes added to the general tracer trend
-         ! -------------------------------------------------------------------
-         DO jk = 1, jpkm1
+         !
+         !                                !==  add the vertical 33 flux  ==!
+         IF( ln_traldf_lap ) THEN               ! laplacian case: eddy coef = ah_wslp2 - akz
+            DO jk = 2, jpkm1       
+               DO jj = 1, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ztfw(ji,jj,jk) = ztfw(ji,jj,jk) + e1e2t(ji,jj) / fse3w(ji,jj,jk) * tmask(ji,jj,jk)   &
+                        &                            * ( ah_wslp2(ji,jj,jk) - akz(ji,jj,jk) )             &
+                        &                            * ( ptb(ji,jj,jk-1,jn) - ptb(ji,jj,jk,jn) )
+                  END DO
+               END DO
+            END DO
+            !
+         ELSE                                   ! bilaplacian 
+            SELECT CASE( kpass )
+            CASE(  1  )                            ! 1st pass : eddy coef = ah_wslp2
+               DO jk = 2, jpkm1 
+                  DO jj = 1, jpjm1
+                     DO ji = fs_2, fs_jpim1
+                        ztfw(ji,jj,jk) = ztfw(ji,jj,jk)    &
+                           &           + ah_wslp2(ji,jj,jk) * e1e2t(ji,jj)   &
+                           &           * ( ptb(ji,jj,jk-1,jn) - ptb(ji,jj,jk,jn) ) * tmask(ji,jj,jk) / fse3w(ji,jj,jk)
+                     END DO
+                  END DO
+               END DO 
+            CASE(  2  )                         ! 2nd pass : eddy flux = ah_wslp2 and akz applied on ptb  and ptbb gradients, resp.
+               DO jk = 2, jpkm1 
+                  DO jj = 1, jpjm1
+                     DO ji = fs_2, fs_jpim1
+                        ztfw(ji,jj,jk) = ztfw(ji,jj,jk) + e1e2t(ji,jj) / fse3w(ji,jj,jk) * tmask(ji,jj,jk)                      &
+                           &                            * (  ah_wslp2(ji,jj,jk) * ( ptb (ji,jj,jk-1,jn) - ptb (ji,jj,jk,jn) )   &
+                           &                               + akz     (ji,jj,jk) * ( ptbb(ji,jj,jk-1,jn) - ptbb(ji,jj,jk,jn) )   )
+                     END DO
+                  END DO
+               END DO
+            END SELECT
+         ENDIF
+         !         
+         DO jk = 1, jpkm1                 !==  Divergence of vertical fluxes added to pta  ==!
             DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1.0 / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                  ztra = (  ztfw(ji,jj,jk) - ztfw(ji,jj,jk+1)  ) * zbtr
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + ztra
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zsign * (  ztfw (ji,jj,jk) - ztfw(ji,jj,jk+1)  )   &
+                     &                                        / (  e1e2t(ji,jj) * fse3t_n(ji,jj,jk)  )
                END DO
             END DO
          END DO
          !
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj, z2d ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, zdit, zdjt, ztfw, zdkt, zdk1t ) 
+         IF( ( kpass == 1 .AND. ln_traldf_lap ) .OR.  &     !==  first pass only (  laplacian)  ==!
+             ( kpass == 2 .AND. ln_traldf_blp ) ) THEN      !==  2nd   pass      (bilaplacian)  ==!
+            !
+            !                             ! "Poleward" diffusive heat or salt transports (T-S case only)
+            IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
+               ! note sign is reversed to give down-gradient diffusive transports (#1043)
+               IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( -zftv(:,:,:) )
+               IF( jn == jp_sal)   str_ldf(:) = ptr_sj( -zftv(:,:,:) )
+            ENDIF
+            !
+            IF( iom_use("udiff_heattr") .OR. iom_use("vdiff_heattr") ) THEN
+              !
+              IF( cdtype == 'TRA' .AND. jn == jp_tem  ) THEN
+                  z2d(:,:) = zftu(ji,jj,1) 
+                  DO jk = 2, jpkm1
+                     DO jj = 2, jpjm1
+                        DO ji = fs_2, fs_jpim1   ! vector opt.
+                           z2d(ji,jj) = z2d(ji,jj) + zftu(ji,jj,jk) 
+                        END DO
+                     END DO
+                  END DO
+!!gm CAUTION I think there is an error of sign when using BLP operator....
+!!gm         a multiplication by zsign is required (to be checked twice !)
+                  z2d(:,:) = - rau0_rcp * z2d(:,:)     ! note sign is reversed to give down-gradient diffusive transports (#1043)
+                  CALL lbc_lnk( z2d, 'U', -1. )
+                  CALL iom_put( "udiff_heattr", z2d )                  ! heat transport in i-direction
+                  !
+                  z2d(:,:) = zftv(ji,jj,1) 
+                  DO jk = 2, jpkm1
+                     DO jj = 2, jpjm1
+                        DO ji = fs_2, fs_jpim1   ! vector opt.
+                           z2d(ji,jj) = z2d(ji,jj) + zftv(ji,jj,jk) 
+                        END DO
+                     END DO
+                  END DO
+                  z2d(:,:) = - rau0_rcp * z2d(:,:)     ! note sign is reversed to give down-gradient diffusive transports (#1043)
+                  CALL lbc_lnk( z2d, 'V', -1. )
+                  CALL iom_put( "vdiff_heattr", z2d )                  !  heat transport in i-direction
+               END IF
+               !
+            ENDIF
+            !
+         ENDIF                                                    !== end pass selection  ==!
+         !
+         !                                                        ! ===============
+      END DO                                                      ! end tracer loop
+      !                                                           ! ===============
+      !
+      CALL wrk_dealloc( jpi, jpj,      zdkt, zdk1t, z2d ) 
+      CALL wrk_dealloc( jpi, jpj, jpk, zdit, zdjt , zftu, zftv, ztfw  ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_iso')
       !
    END SUBROUTINE tra_ldf_iso
-
-#else
-   !!----------------------------------------------------------------------
-   !!   default option :   Dummy code   NO rotation of the diffusive tensor
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE tra_ldf_iso( kt, kit000,cdtype, pgu, pgv, pgui, pgvi, ptb, pta, kjpt, pahtb0 )      ! Empty routine
-      INTEGER:: kt, kit000
-      CHARACTER(len=3) ::   cdtype
-      REAL, DIMENSION(:,:,:) ::   pgu, pgv, pgui, pgvi    ! tracer gradient at pstep levels
-      REAL, DIMENSION(:,:,:,:) ::   ptb, pta
-      WRITE(*,*) 'tra_ldf_iso: You should not have seen this print! error?', kt, kit000, cdtype,   &
-         &                       pgu(1,1,1), pgv(1,1,1), ptb(1,1,1,1), pta(1,1,1,1), kjpt, pahtb0
-   END SUBROUTINE tra_ldf_iso
-#endif
 
    !!==============================================================================
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90	(revision 6040)
+++ 	(revision )
@@ -1,450 +1,0 @@
-MODULE traldf_iso_grif
-   !!======================================================================
-   !!                   ***  MODULE  traldf_iso_grif  ***
-   !! Ocean  tracers:  horizontal component of the lateral tracer mixing trend
-   !!======================================================================
-   !! History : 3.3  ! 2010-10  (G. Nurser, C. Harris, G. Madec)
-   !!                !          Griffies operator version adapted from traldf_iso.F90
-   !!----------------------------------------------------------------------
-#if   defined key_ldfslp   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!   'key_ldfslp'               slope of the lateral diffusive direction
-   !!----------------------------------------------------------------------
-   !!   tra_ldf_iso_grif  : update the tracer trend with the horizontal component
-   !!                       of the Griffies iso-neutral laplacian operator
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and active tracers
-   USE dom_oce         ! ocean space and time domain
-   USE phycst          ! physical constants
-   USE trc_oce         ! share passive tracers/Ocean variables
-   USE zdf_oce         ! ocean vertical physics
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldfslp          ! iso-neutral slopes
-   USE diaptr          ! poleward transport diagnostics
-   USE in_out_manager  ! I/O manager
-   USE iom             ! I/O library
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
-
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   tra_ldf_iso_grif   ! routine called by traldf.F90
-
-   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   psix_eiv, psiy_eiv   !: eiv stream function (diag only)
-   REAL(wp), PUBLIC, DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   ah_wslp2             !: aeiv*w-slope^2
-   REAL(wp),         DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   zdkt3d               !: vertical tracer gradient at 2 levels
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-#  include "ldfeiv_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-  SUBROUTINE tra_ldf_iso_grif( kt, kit000, cdtype, pgu, pgv,              &
-       &                                   ptb, pta, kjpt, pahtb0 )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_ldf_iso_grif  ***
-      !!
-      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive
-      !!      trend for a laplacian tensor (ezxcept the dz[ dz[.] ] term) and
-      !!      add it to the general trend of tracer equation.
-      !!
-      !! ** Method  :   The horizontal component of the lateral diffusive trends
-      !!      is provided by a 2nd order operator rotated along neural or geopo-
-      !!      tential surfaces to which an eddy induced advection can be added
-      !!      It is computed using before fields (forward in time) and isopyc-
-      !!      nal or geopotential slopes computed in routine ldfslp.
-      !!
-      !!      1st part :  masked horizontal derivative of T  ( di[ t ] )
-      !!      ========    with partial cell update if ln_zps=T.
-      !!
-      !!      2nd part :  horizontal fluxes of the lateral mixing operator
-      !!      ========
-      !!         zftu = (aht+ahtb0) e2u*e3u/e1u di[ tb ]
-      !!               - aht       e2u*uslp    dk[ mi(mk(tb)) ]
-      !!         zftv = (aht+ahtb0) e1v*e3v/e2v dj[ tb ]
-      !!               - aht       e2u*vslp    dk[ mj(mk(tb)) ]
-      !!      take the horizontal divergence of the fluxes:
-      !!         difft = 1/(e1t*e2t*e3t) {  di-1[ zftu ] +  dj-1[ zftv ]  }
-      !!      Add this trend to the general trend (ta,sa):
-      !!         ta = ta + difft
-      !!
-      !!      3rd part: vertical trends of the lateral mixing operator
-      !!      ========  (excluding the vertical flux proportional to dk[t] )
-      !!      vertical fluxes associated with the rotated lateral mixing:
-      !!         zftw =-aht {  e2t*wslpi di[ mi(mk(tb)) ]
-      !!                     + e1t*wslpj dj[ mj(mk(tb)) ]  }
-      !!      take the horizontal divergence of the fluxes:
-      !!         difft = 1/(e1t*e2t*e3t) dk[ zftw ]
-      !!      Add this trend to the general trend (ta,sa):
-      !!         pta = pta + difft
-      !!
-      !! ** Action :   Update pta arrays with the before rotated diffusion
-      !!----------------------------------------------------------------------
-      USE oce     , ONLY:   zftu => ua       , zftv => va            ! (ua,va) used as 3D workspace
-      !
-      INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000     ! first time step index
-      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
-      INTEGER                              , INTENT(in   ) ::   kjpt       ! number of tracers
-      REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgu, pgv   ! tracer gradient at pstep levels
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! before and now tracer fields
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend
-      REAL(wp)                             , INTENT(in   ) ::   pahtb0     ! background diffusion coef
-      !
-      INTEGER  ::  ji, jj, jk,jn   ! dummy loop indices
-      INTEGER  ::  ip,jp,kp        ! dummy loop indices
-      INTEGER  ::  ierr            ! temporary integer
-      REAL(wp) ::  zmsku, zabe1, zcof1, zcoef3   ! local scalars
-      REAL(wp) ::  zmskv, zabe2, zcof2, zcoef4   !   -      -
-      REAL(wp) ::  zcoef0, zbtr                  !   -      -
-      !
-      REAL(wp) ::   zslope_skew, zslope_iso, zslope2, zbu, zbv
-      REAL(wp) ::   ze1ur, zdxt, ze2vr, ze3wr, zdyt, zdzt
-      REAL(wp) ::   zah, zah_slp, zaei_slp
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: z2d
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdit, zdjt, ztfw 
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zw3d       ! 3D workspace
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_ldf_iso_grif')
-      !
-      CALL wrk_alloc( jpi, jpj,      z2d ) 
-      CALL wrk_alloc( jpi, jpj, jpk, zdit, zdjt, ztfw  ) 
-      !
-
-      IF( kt == kit000 .AND. .NOT.ALLOCATED(ah_wslp2) )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_ldf_iso_grif : rotated laplacian diffusion operator on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-         ALLOCATE( ah_wslp2(jpi,jpj,jpk) , zdkt3d(jpi,jpj,0:1), STAT=ierr )
-         IF( lk_mpp   )   CALL mpp_sum ( ierr )
-         IF( ierr > 0 )   CALL ctl_stop('STOP', 'tra_ldf_iso_grif: unable to allocate arrays')
-         IF( ln_traldf_gdia ) THEN
-            IF (.NOT. ALLOCATED(psix_eiv))THEN
-                ALLOCATE( psix_eiv(jpi,jpj,jpk) , psiy_eiv(jpi,jpj,jpk) , STAT=ierr )
-                IF( lk_mpp   )   CALL mpp_sum ( ierr )
-                IF( ierr > 0 )   CALL ctl_stop('STOP', 'tra_ldf_iso_grif: unable to allocate diagnostics')
-            ENDIF
-         ENDIF
-      ENDIF
-
-      !!----------------------------------------------------------------------
-      !!   0 - calculate  ah_wslp2, psix_eiv, psiy_eiv
-      !!----------------------------------------------------------------------
-
-      !!gm Future development: consider using Ah defined at T-points and attached to the 4 t-point triads
-
-      ah_wslp2(:,:,:) = 0._wp
-      IF( ln_traldf_gdia ) THEN
-         psix_eiv(:,:,:) = 0._wp
-         psiy_eiv(:,:,:) = 0._wp
-      ENDIF
-
-      DO ip = 0, 1
-         DO kp = 0, 1
-            DO jk = 1, jpkm1
-               DO jj = 1, jpjm1
-                  DO ji = 1, fs_jpim1
-                     ze1ur = 1._wp / e1u(ji,jj)
-                     ze3wr = 1._wp / fse3w(ji+ip,jj,jk+kp)
-                     zbu   = 0.25_wp * e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-                     zah   = fsahtu(ji,jj,jk)                                  ! fsaht(ji+ip,jj,jk)
-                     zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp)
-                     ! Subtract s-coordinate slope at t-points to give slope rel to s surfaces
-                     ! (do this by *adding* gradient of depth)
-                     zslope2 = zslope_skew + ( fsdept(ji+1,jj,jk) - fsdept(ji ,jj ,jk) ) * ze1ur * umask(ji,jj,jk+kp)
-                     zslope2 = zslope2 *zslope2
-                     ah_wslp2(ji+ip,jj,jk+kp) = ah_wslp2(ji+ip,jj,jk+kp)    &
-                        &                     + zah * ( zbu * ze3wr / ( e1t(ji+ip,jj) * e2t(ji+ip,jj) ) ) * zslope2
-                     IF( ln_traldf_gdia ) THEN
-                        zaei_slp = fsaeiw(ji+ip,jj,jk) * zslope_skew           ! fsaeit(ji+ip,jj,jk)*zslope_skew
-                        psix_eiv(ji,jj,jk+kp) = psix_eiv(ji,jj,jk+kp) + 0.25_wp * zaei_slp
-                     ENDIF
-                  END DO
-               END DO
-            END DO
-         END DO
-      END DO
-      !
-      DO jp = 0, 1
-         DO kp = 0, 1
-            DO jk = 1, jpkm1
-               DO jj = 1, jpjm1
-                  DO ji=1,fs_jpim1
-                     ze2vr = 1._wp / e2v(ji,jj)
-                     ze3wr = 1.0_wp / fse3w(ji,jj+jp,jk+kp)
-                     zbv   = 0.25_wp * e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
-                     zah   = fsahtv(ji,jj,jk)                                  ! fsaht(ji,jj+jp,jk)
-                     zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp)
-                     ! Subtract s-coordinate slope at t-points to give slope rel to s surfaces
-                     !    (do this by *adding* gradient of depth)
-                     zslope2 = zslope_skew + ( fsdept(ji,jj+1,jk) - fsdept(ji,jj,jk) ) * ze2vr * vmask(ji,jj,jk+kp)
-                     zslope2 = zslope2 * zslope2
-                     ah_wslp2(ji,jj+jp,jk+kp) = ah_wslp2(ji,jj+jp,jk+kp)   &
-                        &                     + zah * ( zbv * ze3wr / ( e1t(ji,jj+jp) * e2t(ji,jj+jp) ) ) * zslope2
-                     IF( ln_traldf_gdia ) THEN
-                        zaei_slp = fsaeiw(ji,jj+jp,jk) * zslope_skew           ! fsaeit(ji,jj+jp,jk)*zslope_skew
-                        psiy_eiv(ji,jj,jk+kp) = psiy_eiv(ji,jj,jk+kp) + 0.25_wp * zaei_slp
-                     ENDIF
-                  END DO
-               END DO
-            END DO
-         END DO
-      END DO
-      !
-      IF( iom_use("uoce_eiv") .OR. iom_use("voce_eiv") .OR. iom_use("woce_eiv") )  THEN
-         !
-         IF( ln_traldf_gdia .AND. cdtype == 'TRA' ) THEN
-            CALL wrk_alloc( jpi , jpj , jpk  , zw3d )
-            DO jk=1,jpkm1
-               zw3d(:,:,jk) = (psix_eiv(:,:,jk+1) - psix_eiv(:,:,jk))/fse3u(:,:,jk)  ! u_eiv = -dpsix/dz
-            END DO
-            zw3d(:,:,jpk) = 0._wp
-            CALL iom_put( "uoce_eiv", zw3d )    ! i-eiv current
-
-            DO jk=1,jpk-1
-               zw3d(:,:,jk) = (psiy_eiv(:,:,jk+1) - psiy_eiv(:,:,jk))/fse3v(:,:,jk)  ! v_eiv = -dpsiy/dz
-            END DO
-            zw3d(:,:,jpk) = 0._wp
-            CALL iom_put( "voce_eiv", zw3d )    ! j-eiv current
-
-            DO jk=1,jpk-1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1  ! vector opt.
-                     zw3d(ji,jj,jk) = (psiy_eiv(ji,jj,jk) - psiy_eiv(ji,jj-1,jk))/e2t(ji,jj) + &
-                          &    (psix_eiv(ji,jj,jk) - psix_eiv(ji-1,jj,jk))/e1t(ji,jj) ! w_eiv = dpsiy/dy + dpsiy/dx
-                  END DO
-               END DO
-            END DO
-            zw3d(:,:,jpk) = 0._wp
-            CALL iom_put( "woce_eiv", zw3d )    ! vert. eiv current
-            CALL wrk_dealloc( jpi , jpj , jpk  , zw3d )
-         ENDIF
-         !
-      ENDIF
-      !                                                          ! ===========
-      DO jn = 1, kjpt                                            ! tracer loop
-         !                                                       ! ===========
-         ! Zero fluxes for each tracer
-         ztfw(:,:,:) = 0._wp
-         zftu(:,:,:) = 0._wp
-         zftv(:,:,:) = 0._wp
-         !
-         DO jk = 1, jpkm1                          !==  before lateral T & S gradients at T-level jk  ==!
-            DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zdit(ji,jj,jk) = ( ptb(ji+1,jj  ,jk,jn) - ptb(ji,jj,jk,jn) ) * umask(ji,jj,jk)
-                  zdjt(ji,jj,jk) = ( ptb(ji  ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
-               END DO
-            END DO
-         END DO
-         IF( ln_zps.and.l_grad_zps ) THEN              ! partial steps: correction at the last level
-            DO jj = 1, jpjm1
-               DO ji = 1, jpim1
-                  zdit(ji,jj,mbku(ji,jj)) = pgu(ji,jj,jn)
-                  zdjt(ji,jj,mbkv(ji,jj)) = pgv(ji,jj,jn)
-               END DO
-            END DO
-         ENDIF
-
-         !!----------------------------------------------------------------------
-         !!   II - horizontal trend  (full)
-         !!----------------------------------------------------------------------
-         !
-         DO jk = 1, jpkm1
-            !
-            !                    !==  Vertical tracer gradient at level jk and jk+1
-            zdkt3d(:,:,1) = ( ptb(:,:,jk,jn) - ptb(:,:,jk+1,jn) ) * tmask(:,:,jk+1)
-            !
-            !                    ! surface boundary condition: zdkt3d(jk=0)=zdkt3d(jk=1)
-            IF( jk == 1 ) THEN   ;   zdkt3d(:,:,0) = zdkt3d(:,:,1)
-            ELSE                 ;   zdkt3d(:,:,0) = ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) ) * tmask(:,:,jk)
-            ENDIF
-
-
-            IF (ln_botmix_grif) THEN
-               DO ip = 0, 1              !==  Horizontal & vertical fluxes
-                  DO kp = 0, 1
-                     DO jj = 1, jpjm1
-                        DO ji = 1, fs_jpim1
-                           ze1ur = 1._wp / e1u(ji,jj)
-                           zdxt  = zdit(ji,jj,jk) * ze1ur
-                           ze3wr = 1._wp / fse3w(ji+ip,jj,jk+kp)
-                           zdzt  = zdkt3d(ji+ip,jj,kp) * ze3wr
-                           zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp)
-                           zslope_iso  = triadi(ji+ip,jj,jk,1-ip,kp)
-
-                           zbu = 0.25_wp * e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-                           ! ln_botmix_grif is .T. don't mask zah for bottom half cells
-                           zah = fsahtu(ji,jj,jk)   !*umask(ji,jj,jk+kp)         !fsaht(ji+ip,jj,jk)           ===>>  ????
-                           zah_slp  = zah * zslope_iso
-                           zaei_slp = fsaeiw(ji+ip,jj,jk) * zslope_skew    !fsaeit(ji+ip,jj,jk)*zslope_skew
-                           zftu(ji,jj,jk) = zftu(ji,jj,jk) - ( zah * zdxt + (zah_slp - zaei_slp) * zdzt ) * zbu * ze1ur
-                           ztfw(ji+ip,jj,jk+kp) = ztfw(ji+ip,jj,jk+kp) - (zah_slp + zaei_slp) * zdxt * zbu * ze3wr
-                        END DO
-                     END DO
-                  END DO
-               END DO
-
-               DO jp = 0, 1
-                  DO kp = 0, 1
-                     DO jj = 1, jpjm1
-                        DO ji = 1, fs_jpim1
-                           ze2vr = 1._wp / e2v(ji,jj)
-                           zdyt  = zdjt(ji,jj,jk) * ze2vr
-                           ze3wr = 1._wp / fse3w(ji,jj+jp,jk+kp)
-                           zdzt  = zdkt3d(ji,jj+jp,kp) * ze3wr
-                           zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp)
-                           zslope_iso  = triadj(ji,jj+jp,jk,1-jp,kp)
-                           zbv = 0.25_wp * e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
-                           ! ln_botmix_grif is .T. don't mask zah for bottom half cells
-                           zah = fsahtv(ji,jj,jk)        !*vmask(ji,jj,jk+kp)  ! fsaht(ji,jj+jp,jk)
-                           zah_slp = zah * zslope_iso
-                           zaei_slp = fsaeiw(ji,jj+jp,jk) * zslope_skew        ! fsaeit(ji,jj+jp,jk)*zslope_skew
-                           zftv(ji,jj,jk) = zftv(ji,jj,jk) - ( zah * zdyt + (zah_slp - zaei_slp) * zdzt ) * zbv * ze2vr
-                           ztfw(ji,jj+jp,jk+kp) = ztfw(ji,jj+jp,jk+kp) - (zah_slp + zaei_slp) * zdyt * zbv * ze3wr
-                        END DO
-                     END DO
-                  END DO
-               END DO
-            ELSE
-               DO ip = 0, 1              !==  Horizontal & vertical fluxes
-                  DO kp = 0, 1
-                     DO jj = 1, jpjm1
-                        DO ji = 1, fs_jpim1
-                           ze1ur = 1._wp / e1u(ji,jj)
-                           zdxt  = zdit(ji,jj,jk) * ze1ur
-                           ze3wr = 1._wp / fse3w(ji+ip,jj,jk+kp)
-                           zdzt  = zdkt3d(ji+ip,jj,kp) * ze3wr
-                           zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp)
-                           zslope_iso  = triadi(ji+ip,jj,jk,1-ip,kp)
-
-                           zbu = 0.25_wp * e1u(ji,jj) * e2u(ji,jj) * fse3u(ji,jj,jk)
-                           ! ln_botmix_grif is .F. mask zah for bottom half cells
-                           zah = fsahtu(ji,jj,jk) * umask(ji,jj,jk+kp)         ! fsaht(ji+ip,jj,jk)   ===>>  ????
-                           zah_slp  = zah * zslope_iso
-                           zaei_slp = fsaeiw(ji+ip,jj,jk) * zslope_skew        ! fsaeit(ji+ip,jj,jk)*zslope_skew
-                           zftu(ji,jj,jk) = zftu(ji,jj,jk) - ( zah * zdxt + (zah_slp - zaei_slp) * zdzt ) * zbu * ze1ur
-                           ztfw(ji+ip,jj,jk+kp) = ztfw(ji+ip,jj,jk+kp) - (zah_slp + zaei_slp) * zdxt * zbu * ze3wr
-                        END DO
-                     END DO
-                  END DO
-               END DO
-
-               DO jp = 0, 1
-                  DO kp = 0, 1
-                     DO jj = 1, jpjm1
-                        DO ji = 1, fs_jpim1
-                           ze2vr = 1._wp / e2v(ji,jj)
-                           zdyt  = zdjt(ji,jj,jk) * ze2vr
-                           ze3wr = 1._wp / fse3w(ji,jj+jp,jk+kp)
-                           zdzt  = zdkt3d(ji,jj+jp,kp) * ze3wr
-                           zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp)
-                           zslope_iso  = triadj(ji,jj+jp,jk,1-jp,kp)
-                           zbv = 0.25_wp * e1v(ji,jj) * e2v(ji,jj) * fse3v(ji,jj,jk)
-                           ! ln_botmix_grif is .F. mask zah for bottom half cells
-                           zah = fsahtv(ji,jj,jk) * vmask(ji,jj,jk+kp)         ! fsaht(ji,jj+jp,jk)
-                           zah_slp = zah * zslope_iso
-                           zaei_slp = fsaeiw(ji,jj+jp,jk) * zslope_skew        ! fsaeit(ji,jj+jp,jk)*zslope_skew
-                           zftv(ji,jj,jk) = zftv(ji,jj,jk) - ( zah * zdyt + (zah_slp - zaei_slp) * zdzt ) * zbv * ze2vr
-                           ztfw(ji,jj+jp,jk+kp) = ztfw(ji,jj+jp,jk+kp) - (zah_slp + zaei_slp) * zdyt * zbv * ze3wr
-                        END DO
-                     END DO
-                  END DO
-               END DO
-            END IF
-            !                          !==  divergence and add to the general trend  ==!
-            DO jj = 2 , jpjm1
-               DO ji = fs_2, fs_jpim1  ! vector opt.
-                  zbtr = 1._wp / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zbtr * (   zftu(ji-1,jj,jk) - zftu(ji,jj,jk)   &
-                     &                                           + zftv(ji,jj-1,jk) - zftv(ji,jj,jk)   )
-               END DO
-            END DO
-            !
-         END DO
-         !
-         DO jk = 1, jpkm1              !== Divergence of vertical fluxes added to the general tracer trend
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1  ! vector opt.
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + (  ztfw(ji,jj,jk+1) - ztfw(ji,jj,jk)  )   &
-                     &                                / ( e1t(ji,jj) * e2t(ji,jj) * fse3t(ji,jj,jk) )
-               END DO
-            END DO
-         END DO
-         !
-         !                             ! "Poleward" diffusive heat or salt transports (T-S case only)
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( zftv(:,:,:) )        ! 3.3  names
-            IF( jn == jp_sal)   str_ldf(:) = ptr_sj( zftv(:,:,:) )
-         ENDIF
-
-         IF( iom_use("udiff_heattr") .OR. iom_use("vdiff_heattr") ) THEN
-           !
-           IF( cdtype == 'TRA' .AND. jn == jp_tem  ) THEN
-               z2d(:,:) = 0._wp 
-               DO jk = 1, jpkm1
-                  DO jj = 2, jpjm1
-                     DO ji = fs_2, fs_jpim1   ! vector opt.
-                        z2d(ji,jj) = z2d(ji,jj) + zftu(ji,jj,jk) 
-                     END DO
-                  END DO
-               END DO
-               z2d(:,:) = rau0_rcp * z2d(:,:) 
-               CALL lbc_lnk( z2d, 'U', -1. )
-               CALL iom_put( "udiff_heattr", z2d )                  ! heat transport in i-direction
-               !
-               z2d(:,:) = 0._wp 
-               DO jk = 1, jpkm1
-                  DO jj = 2, jpjm1
-                     DO ji = fs_2, fs_jpim1   ! vector opt.
-                        z2d(ji,jj) = z2d(ji,jj) + zftv(ji,jj,jk) 
-                     END DO
-                  END DO
-               END DO
-               z2d(:,:) = rau0_rcp * z2d(:,:)     
-               CALL lbc_lnk( z2d, 'V', -1. )
-               CALL iom_put( "vdiff_heattr", z2d )                  !  heat transport in i-direction
-            END IF
-            !
-         ENDIF
-         !
-      END DO
-      !
-      CALL wrk_dealloc( jpi, jpj,      z2d ) 
-      CALL wrk_dealloc( jpi, jpj, jpk, zdit, zdjt, ztfw  ) 
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_iso_grif')
-      !
-  END SUBROUTINE tra_ldf_iso_grif
-
-#else
-   !!----------------------------------------------------------------------
-   !!   default option :   Dummy code   NO rotation of the diffusive tensor
-   !!----------------------------------------------------------------------
-   REAL, PUBLIC, DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   psix_eiv, psiy_eiv   !: eiv stream function (diag only)
-CONTAINS
-   SUBROUTINE tra_ldf_iso_grif( kt, kit000, cdtype, pgu, pgv,              &
-       &                                   ptb, pta, kjpt, pahtb0 )
-      CHARACTER(len=3) ::   cdtype
-      INTEGER          ::   kit000     ! first time step index
-      REAL, DIMENSION(:,:,:) ::   pgu, pgv   ! tracer gradient at pstep levels
-      REAL, DIMENSION(:,:,:,:) ::   ptb, pta
-      WRITE(*,*) 'tra_ldf_iso_grif: You should not have seen this print! error?', kt, cdtype,    &
-         &                  pgu(1,1,1), pgv(1,1,1), ptb(1,1,1,1), pta(1,1,1,1), kjpt, pahtb0
-   END SUBROUTINE tra_ldf_iso_grif
-#endif
-
-   !!==============================================================================
-END MODULE traldf_iso_grif
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_lap.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_lap.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_lap.F90	(revision 6041)
@@ -2,40 +2,44 @@
    !!==============================================================================
    !!                       ***  MODULE  traldf_lap  ***
-   !! Ocean  tracers:  horizontal component of the lateral tracer mixing trend
+   !! Ocean tracers:  lateral diffusivity trend  (laplacian and bilaplacian)
    !!==============================================================================
-   !! History :  OPA  !  87-06  (P. Andrich, D. L Hostis)  Original code
-   !!                 !  91-11  (G. Madec)
-   !!                 !  95-11  (G. Madec)  suppress volumetric scale factors
-   !!                 !  96-01  (G. Madec)  statement function for e3
-   !!            NEMO !  02-06  (G. Madec)  F90: Free form and module
-   !!            1.0  !  04-08  (C. Talandier) New trends organization
-   !!                 !  05-11  (G. Madec)  add zps case
-   !!            3.0  !  10-06  (C. Ethe, G. Madec) Merge TRA-TRC
+   !! History :  OPA  ! 1987-06  (P. Andrich, D. L Hostis)  Original code
+   !!                 ! 1991-11  (G. Madec)
+   !!                 ! 1995-11  (G. Madec)  suppress volumetric scale factors
+   !!                 ! 1996-01  (G. Madec)  statement function for e3
+   !!            NEMO ! 2002-06  (G. Madec)  F90: Free form and module
+   !!            1.0  ! 2004-08  (C. Talandier) New trends organization
+   !!                 ! 2005-11  (G. Madec)  add zps case
+   !!            3.0  ! 2010-06  (C. Ethe, G. Madec) Merge TRA-TRC
+   !!            3.7  ! 2014-01  (G. Madec, S. Masson) re-entrant laplacian 
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   tra_ldf_lap  : update the tracer trend with the horizontal diffusion
-   !!                 using a iso-level harmonic (laplacien) operator.
+   !!   tra_ldf_lap : update the tracer trend with the lateral diffusion : iso-level laplacian operator
+   !!   tra_ldf_blp : update the tracer trend with the lateral diffusion : iso-level bilaplacian operator
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and active tracers
    USE dom_oce         ! ocean space and time domain
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE in_out_manager  ! I/O manager
+   USE ldftra          ! lateral physics: eddy diffusivity
    USE diaptr          ! poleward transport diagnostics
    USE trc_oce         ! share passive tracers/Ocean variables
-   USE lib_mpp         ! MPP library
+   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
+   !
+   USE in_out_manager  ! I/O manager
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! distribued memory computing library
    USE timing          ! Timing
+   USE wrk_nemo        ! Memory allocation
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   tra_ldf_lap   ! routine called by step.F90
+   PUBLIC   tra_ldf_lap   ! routine called by traldf.F90
 
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -43,7 +47,7 @@
 CONTAINS
 
-   SUBROUTINE tra_ldf_lap( kt, kit000, cdtype, pgu , pgv ,    &
-      &                                        pgui, pgvi,    &
-      &                                ptb, pta, kjpt ) 
+   SUBROUTINE tra_ldf_lap( kt, kit000, cdtype, pahu, pahv, pgu , pgv ,   &
+      &                                                    pgui, pgvi,   &
+      &                                        ptb , pta , kjpt, kpass ) 
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE tra_ldf_lap  ***
@@ -55,6 +59,6 @@
       !!      fields (forward time scheme). The horizontal diffusive trends of 
       !!      the tracer is given by:
-      !!          difft = 1/(e1t*e2t*e3t) {  di-1[ aht e2u*e3u/e1u di(tb) ]
-      !!                                   + dj-1[ aht e1v*e3v/e2v dj(tb) ] }
+      !!          difft = 1/(e1e2t*e3t) {  di-1[ pahu e2u*e3u/e1u di(tb) ]
+      !!                                 + dj-1[ pahv e1v*e3v/e2v dj(tb) ] }
       !!      Add this trend to the general tracer trend pta :
       !!          pta = pta + difft
@@ -63,106 +67,100 @@
       !!                harmonic mixing trend.
       !!----------------------------------------------------------------------
-      USE oce, ONLY:   ztu => ua , ztv => va  ! (ua,va) used as workspace
-      !
       INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
-      INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
+      INTEGER                              , INTENT(in   ) ::   kit000     ! first time step index
       CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
       INTEGER                              , INTENT(in   ) ::   kjpt       ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kpass      ! =1/2 first or second passage
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pahu, pahv ! eddy diffusivity at u- and v-points  [m2/s]
       REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgu, pgv   ! tracer gradient at pstep levels
-      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgui, pgvi ! tracer gradient at top levels
+      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgui, pgvi ! tracer gradient at top   levels
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! before and now tracer fields
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend 
       !
-      INTEGER  ::   ji, jj, jk, jn       ! dummy loop indices
-      INTEGER  ::   iku, ikv, ierr       ! local integers
-      REAL(wp) ::   zabe1, zabe2, zbtr   ! local scalars
+      INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
+      REAL(wp) ::   zsign            ! local scalars
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztu, ztv, zaheeu, zaheev
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 ) CALL timing_start('tra_ldf_lap')
+      IF( nn_timing == 1 )   CALL timing_start('tra_ldf_lap')
       !
-      IF( kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_ldf_lap : iso-level laplacian diffusion on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~ '
+      IF( kt == nit000 .AND. lwp )  THEN
+         WRITE(numout,*)
+         WRITE(numout,*) 'tra_ldf_lap : iso-level laplacian diffusion on ', cdtype, ', pass=', kpass
+         WRITE(numout,*) '~~~~~~~~~~~ '
       ENDIF
-
-      !                                                          ! =========== !
-      DO jn = 1, kjpt                                            ! tracer loop !
-         !                                                       ! =========== !    
-         DO jk = 1, jpkm1                                            ! slab loop
-            !                                           
-            ! 1. First derivative (gradient)
-            ! -------------------
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   ztu, ztv, zaheeu, zaheev ) 
+      !
+      !                                !==  Initialization of metric arrays used for all tracers  ==!
+      IF( kpass == 1 ) THEN   ;   zsign =  1._wp      ! bilaplacian operator require a minus sign (eddy diffusivity >0)
+      ELSE                    ;   zsign = -1._wp
+      ENDIF
+      DO jk = 1, jpkm1
+         DO jj = 1, jpjm1
+            DO ji = 1, fs_jpim1   ! vector opt.
+               zaheeu(ji,jj,jk) = zsign * pahu(ji,jj,jk) * e2_e1u(ji,jj) * fse3u_n(ji,jj,jk)   !!gm   * umask(ji,jj,jk) pah masked!
+               zaheev(ji,jj,jk) = zsign * pahv(ji,jj,jk) * e1_e2v(ji,jj) * fse3v_n(ji,jj,jk)   !!gm   * vmask(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      !                             ! =========== !
+      DO jn = 1, kjpt               ! tracer loop !
+         !                          ! =========== !    
+         !                               
+         DO jk = 1, jpkm1              !== First derivative (gradient)  ==!
             DO jj = 1, jpjm1
-               DO ji = 1, fs_jpim1   ! vector opt.
-                  zabe1 = fsahtu(ji,jj,jk) * umask(ji,jj,jk) * re2u_e1u(ji,jj) * fse3u_n(ji,jj,jk)
-                  zabe2 = fsahtv(ji,jj,jk) * vmask(ji,jj,jk) * re1v_e2v(ji,jj) * fse3v_n(ji,jj,jk)
-                  ztu(ji,jj,jk) = zabe1 * ( ptb(ji+1,jj  ,jk,jn) - ptb(ji,jj,jk,jn) )
-                  ztv(ji,jj,jk) = zabe2 * ( ptb(ji  ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
+               DO ji = 1, fs_jpim1
+                  ztu(ji,jj,jk) = zaheeu(ji,jj,jk) * ( ptb(ji+1,jj  ,jk,jn) - ptb(ji,jj,jk,jn) )
+                  ztv(ji,jj,jk) = zaheev(ji,jj,jk) * ( ptb(ji  ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) )
                END DO
             END DO
-            IF( ln_zps ) THEN      ! set gradient at partial step level for the last ocean cell
+         END DO  
+         IF( ln_zps ) THEN                ! set gradient at bottom/top ocean level
+            DO jj = 1, jpjm1                    ! bottom
+               DO ji = 1, fs_jpim1
+                  ztu(ji,jj,mbku(ji,jj)) = zaheeu(ji,jj,mbku(ji,jj)) * pgu(ji,jj,jn)
+                  ztv(ji,jj,mbkv(ji,jj)) = zaheev(ji,jj,mbkv(ji,jj)) * pgv(ji,jj,jn)
+               END DO
+            END DO  
+            IF( ln_isfcav ) THEN                ! top in ocean cavities only
                DO jj = 1, jpjm1
                   DO ji = 1, fs_jpim1   ! vector opt.
-                     ! last level
-                     iku = mbku(ji,jj)
-                     ikv = mbkv(ji,jj)
-                     IF( iku == jk ) THEN
-                        zabe1 = fsahtu(ji,jj,iku) * umask(ji,jj,iku) * re2u_e1u(ji,jj) * fse3u_n(ji,jj,iku)
-                        ztu(ji,jj,jk) = zabe1 * pgu(ji,jj,jn)
-                     ENDIF
-                     IF( ikv == jk ) THEN
-                        zabe2 = fsahtv(ji,jj,ikv) * vmask(ji,jj,ikv) * re1v_e2v(ji,jj) * fse3v_n(ji,jj,ikv)
-                        ztv(ji,jj,jk) = zabe2 * pgv(ji,jj,jn)
-                     ENDIF
+                     IF( miku(ji,jj) > 1 )   ztu(ji,jj,miku(ji,jj)) = zaheeu(ji,jj,miku(ji,jj)) * pgui(ji,jj,jn) 
+                     IF( mikv(ji,jj) > 1 )   ztv(ji,jj,mikv(ji,jj)) = zaheev(ji,jj,mikv(ji,jj)) * pgvi(ji,jj,jn) 
                   END DO
                END DO
             ENDIF
-            ! (ISH)
-            IF( ln_zps .AND. ln_isfcav ) THEN      ! set gradient at partial step level for the first ocean cell
-                                                   ! into a cavity
-               DO jj = 1, jpjm1
-                  DO ji = 1, fs_jpim1   ! vector opt.
-                     ! ice shelf level level MAX(2,jk) => only where ice shelf
-                     iku = miku(ji,jj) 
-                     ikv = mikv(ji,jj) 
-                     IF( iku == MAX(2,jk) ) THEN 
-                        zabe1 = fsahtu(ji,jj,iku) * umask(ji,jj,iku) * re2u_e1u(ji,jj) * fse3u_n(ji,jj,iku) 
-                        ztu(ji,jj,jk) = zabe1 * pgui(ji,jj,jn) 
-                     ENDIF 
-                     IF( ikv == MAX(2,jk) ) THEN 
-                        zabe2 = fsahtv(ji,jj,ikv) * vmask(ji,jj,ikv) * re1v_e2v(ji,jj) * fse3v_n(ji,jj,ikv) 
-                        ztv(ji,jj,jk) = zabe2 * pgvi(ji,jj,jn) 
-                     END IF 
-                  END DO
-               END DO
-            ENDIF
-         
-         
-            ! 2. Second derivative (divergence) added to the general tracer trends
-            ! ---------------------------------------------------------------------
+         ENDIF
+         !
+         DO jk = 1, jpkm1              !== Second derivative (divergence) added to the general tracer trends  ==!
             DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zbtr = 1._wp / ( e12t(ji,jj) * fse3t_n(ji,jj,jk) )
-                  ! horizontal diffusive trends added to the general tracer trends
-                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zbtr * (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)   &
-                     &                                          + ztv(ji,jj,jk) - ztv(ji,jj-1,jk)  )
+               DO ji = fs_2, fs_jpim1
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + (  ztu(ji,jj,jk) - ztu(ji-1,jj,jk)     &
+                     &                                   + ztv(ji,jj,jk) - ztv(ji,jj-1,jk) )   &
+                     &                                / ( e1e2t(ji,jj) * fse3t_n(ji,jj,jk) )
                END DO
             END DO
-            !
-         END DO                                             !  End of slab  
+         END DO  
          !
-         ! "Poleward" diffusive heat or salt transports
-         IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            IF( jn  == jp_tem)   htr_ldf(:) = ptr_sj( ztv(:,:,:) )
-            IF( jn  == jp_sal)   str_ldf(:) = ptr_sj( ztv(:,:,:) )
+         !                             !== "Poleward" diffusive heat or salt transports  ==!
+         IF( ( kpass == 1 .AND. .NOT.ln_traldf_blp ) .OR.  &     !==  first pass only (  laplacian)  ==!
+             ( kpass == 2 .AND.      ln_traldf_blp ) ) THEN      !==  2nd   pass only (bilaplacian)  ==!
+            IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
+               IF( jn  == jp_tem)   htr_ldf(:) = ptr_sj( -ztv(:,:,:) )
+               IF( jn  == jp_sal)   str_ldf(:) = ptr_sj( -ztv(:,:,:) )
+            ENDIF
          ENDIF
-         !                                                  ! ==================
-      END DO                                                ! end of tracer loop
-      !                                                     ! ==================
-      IF( nn_timing == 1 ) CALL timing_stop('tra_ldf_lap')
+         !                          ! ==================
+      END DO                        ! end of tracer loop
+      !                             ! ==================
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   ztu, ztv, zaheeu, zaheev ) 
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_lap')
       !
    END SUBROUTINE tra_ldf_lap
-
+   
    !!==============================================================================
 END MODULE traldf_lap
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_triad.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_triad.F90	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_triad.F90	(revision 6041)
@@ -0,0 +1,470 @@
+MODULE traldf_triad
+   !!======================================================================
+   !!                   ***  MODULE  traldf_triad  ***
+   !! Ocean  tracers:  horizontal component of the lateral tracer mixing trend
+   !!======================================================================
+   !! History :  3.3  ! 2010-10  (G. Nurser, C. Harris, G. Madec)  Griffies operator (original code)
+   !!            3.7  ! 2013-12  (F. Lemarie, G. Madec)  triad operator (Griffies) + Method of Stabilizing Correction
+   !!----------------------------------------------------------------------
+
+   !!----------------------------------------------------------------------
+   !!   tra_ldf_triad : update the tracer trend with the iso-neutral laplacian triad-operator
+   !!----------------------------------------------------------------------
+   USE oce             ! ocean dynamics and active tracers
+   USE dom_oce         ! ocean space and time domain
+   USE phycst          ! physical constants
+   USE trc_oce         ! share passive tracers/Ocean variables
+   USE zdf_oce         ! ocean vertical physics
+   USE ldftra          ! lateral physics: eddy diffusivity
+   USE ldfslp          ! lateral physics: iso-neutral slopes
+   USE traldf_iso      ! lateral diffusion (Madec operator)         (tra_ldf_iso routine)
+   USE diaptr          ! poleward transport diagnostics
+   USE zpshde          ! partial step: hor. derivative     (zps_hde routine)
+   !
+   USE in_out_manager  ! I/O manager
+   USE iom             ! I/O library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp         ! MPP library
+   USE wrk_nemo        ! Memory Allocation
+   USE timing          ! Timing
+
+   IMPLICIT NONE
+   PRIVATE
+
+   PUBLIC   tra_ldf_triad   ! routine called by traldf.F90
+
+   REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   zdkt3d   !: vertical tracer gradient at 2 levels
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
+   !!----------------------------------------------------------------------
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
+   !! $Id$
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
+   !!----------------------------------------------------------------------
+CONTAINS
+
+  SUBROUTINE tra_ldf_triad( kt, kit000, cdtype, pahu, pahv, pgu , pgv ,   &
+      &                                                     pgui, pgvi,   &
+      &                                         ptb , ptbb, pta , kjpt, kpass )
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE tra_ldf_triad  ***
+      !!
+      !! ** Purpose :   Compute the before horizontal tracer (t & s) diffusive
+      !!      trend for a laplacian tensor (ezxcept the dz[ dz[.] ] term) and
+      !!      add it to the general trend of tracer equation.
+      !!
+      !! ** Method  :   The horizontal component of the lateral diffusive trends
+      !!      is provided by a 2nd order operator rotated along neural or geopo-
+      !!      tential surfaces to which an eddy induced advection can be added
+      !!      It is computed using before fields (forward in time) and isopyc-
+      !!      nal or geopotential slopes computed in routine ldfslp.
+      !!
+      !!      see documentation for the desciption
+      !!
+      !! ** Action :   pta   updated with the before rotated diffusion
+      !!               ah_wslp2 ....
+      !!               akz   stabilizing vertical diffusivity coefficient (used in trazdf_imp)
+      !!----------------------------------------------------------------------
+      INTEGER                              , INTENT(in   ) ::   kt         ! ocean time-step index
+      INTEGER                              , INTENT(in   ) ::   kit000     ! first time step index
+      CHARACTER(len=3)                     , INTENT(in   ) ::   cdtype     ! =TRA or TRC (tracer indicator)
+      INTEGER                              , INTENT(in   ) ::   kjpt       ! number of tracers
+      INTEGER                              , INTENT(in   ) ::   kpass      ! =1/2 first or second passage
+      REAL(wp), DIMENSION(jpi,jpj,jpk)     , INTENT(in   ) ::   pahu, pahv ! eddy diffusivity at u- and v-points  [m2/s]
+      REAL(wp), DIMENSION(jpi,jpj    ,kjpt), INTENT(in   ) ::   pgu , pgv  ! tracer gradient at pstep levels
+      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(in   ) ::   pgui, pgvi ! tracer gradient at top   levels
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptb        ! tracer (kpass=1) or laplacian of tracer (kpass=2)
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   ) ::   ptbb       ! tracer (only used in kpass=2)
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pta        ! tracer trend
+      !
+      INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
+      INTEGER  ::  ip,jp,kp         ! dummy loop indices
+      INTEGER  ::  ierr            ! local integer
+      REAL(wp) ::  zmsku, zabe1, zcof1, zcoef3          ! local scalars
+      REAL(wp) ::  zmskv, zabe2, zcof2, zcoef4          !   -      -
+      REAL(wp) ::  zcoef0, ze3w_2, zsign, z2dt, z1_2dt  !   -      -
+      !
+      REAL(wp) ::   zslope_skew, zslope_iso, zslope2, zbu, zbv
+      REAL(wp) ::   ze1ur, ze2vr, ze3wr, zdxt, zdyt, zdzt
+      REAL(wp) ::   zah, zah_slp, zaei_slp
+#if defined key_diaar5
+      REAL(wp) ::   zztmp              ! local scalar
+#endif
+      REAL(wp), POINTER, DIMENSION(:,:  ) :: z2d                                            ! 2D workspace
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: zdit, zdjt, zftu, zftv, ztfw, zpsi_uw, zpsi_vw   ! 3D     -
+      !!----------------------------------------------------------------------
+      !
+      IF( nn_timing == 1 )  CALL timing_start('tra_ldf_triad')
+      !
+      CALL wrk_alloc( jpi,jpj,       z2d ) 
+      CALL wrk_alloc( jpi,jpj,jpk,   zdit, zdjt, zftu, zftv, ztfw, zpsi_uw, zpsi_vw  ) 
+      !
+      IF( .NOT.ALLOCATED(zdkt3d) )  THEN
+         ALLOCATE( zdkt3d(jpi,jpj,0:1) , STAT=ierr )
+         IF( lk_mpp   )   CALL mpp_sum ( ierr )
+         IF( ierr > 0 )   CALL ctl_stop('STOP', 'tra_ldf_triad: unable to allocate arrays')
+      ENDIF
+     !
+      IF( kpass == 1 .AND. kt == kit000 )  THEN
+         IF(lwp) WRITE(numout,*)
+         IF(lwp) WRITE(numout,*) 'tra_ldf_triad : rotated laplacian diffusion operator on ', cdtype
+         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~'
+      ENDIF
+      !
+      !                                               ! set time step size (Euler/Leapfrog)
+      IF( neuler == 0 .AND. kt == kit000 ) THEN   ;   z2dt =     rdttra(1)      ! at nit000   (Euler)
+      ELSE                                        ;   z2dt = 2.* rdttra(1)      !             (Leapfrog)
+      ENDIF
+      z1_2dt = 1._wp / z2dt
+      !
+      IF( kpass == 1 ) THEN   ;   zsign =  1._wp      ! bilaplacian operator require a minus sign (eddy diffusivity >0)
+      ELSE                    ;   zsign = -1._wp
+      ENDIF
+                  
+      !!----------------------------------------------------------------------
+      !!   0 - calculate  ah_wslp2, akz, and optionally zpsi_uw, zpsi_vw
+      !!----------------------------------------------------------------------
+      !
+      IF( kpass == 1 ) THEN         !==  first pass only  and whatever the tracer is  ==!
+         !
+         akz     (:,:,:) = 0._wp      
+         ah_wslp2(:,:,:) = 0._wp
+         IF( ln_ldfeiv_dia ) THEN
+            zpsi_uw(:,:,:) = 0._wp
+            zpsi_vw(:,:,:) = 0._wp
+         ENDIF
+         !
+         DO ip = 0, 1                            ! i-k triads
+            DO kp = 0, 1
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpjm1
+                     DO ji = 1, fs_jpim1
+                        ze3wr = 1._wp / fse3w(ji+ip,jj,jk+kp)
+                        zbu   = e1e2u(ji,jj) * fse3u(ji,jj,jk)
+                        zah   = 0.25_wp * pahu(ji,jj,jk)
+                        zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp)
+                        ! Subtract s-coordinate slope at t-points to give slope rel to s-surfaces (do this by *adding* gradient of depth)
+                        zslope2 = zslope_skew + ( fsdept(ji+1,jj,jk) - fsdept(ji,jj,jk) ) * r1_e1u(ji,jj) * umask(ji,jj,jk+kp)
+                        zslope2 = zslope2 *zslope2
+                        ah_wslp2(ji+ip,jj,jk+kp) = ah_wslp2(ji+ip,jj,jk+kp) + zah * zbu * ze3wr * r1_e1e2t(ji+ip,jj) * zslope2
+                        akz     (ji+ip,jj,jk+kp) = akz     (ji+ip,jj,jk+kp) + zah * r1_e1u(ji,jj)       &
+                           &                                                      * r1_e1u(ji,jj) * umask(ji,jj,jk+kp)
+                        !
+                       IF( ln_ldfeiv_dia )   zpsi_uw(ji,jj,jk+kp) = zpsi_uw(ji,jj,jk+kp)   &
+                           &                                       + 0.25_wp * aeiu(ji,jj,jk) * e2u(ji,jj) * zslope_skew
+                     END DO
+                  END DO
+               END DO
+            END DO
+         END DO
+         !
+         DO jp = 0, 1                            ! j-k triads 
+            DO kp = 0, 1
+               DO jk = 1, jpkm1
+                  DO jj = 1, jpjm1
+                     DO ji = 1, fs_jpim1
+                        ze3wr = 1.0_wp / fse3w(ji,jj+jp,jk+kp)
+                        zbv   = e1e2v(ji,jj) * fse3v(ji,jj,jk)
+                        zah   = 0.25_wp * pahv(ji,jj,jk)
+                        zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp)
+                        ! Subtract s-coordinate slope at t-points to give slope rel to s surfaces
+                        !    (do this by *adding* gradient of depth)
+                        zslope2 = zslope_skew + ( fsdept(ji,jj+1,jk) - fsdept(ji,jj,jk) ) * r1_e2v(ji,jj) * vmask(ji,jj,jk+kp)
+                        zslope2 = zslope2 * zslope2
+                        ah_wslp2(ji,jj+jp,jk+kp) = ah_wslp2(ji,jj+jp,jk+kp) + zah * zbv * ze3wr * r1_e1e2t(ji,jj+jp) * zslope2
+                        akz     (ji,jj+jp,jk+kp) = akz     (ji,jj+jp,jk+kp) + zah * r1_e2v(ji,jj)     &
+                           &                                                      * r1_e2v(ji,jj) * vmask(ji,jj,jk+kp)
+                        !
+                        IF( ln_ldfeiv_dia )   zpsi_vw(ji,jj,jk+kp) = zpsi_vw(ji,jj,jk+kp)   &
+                           &                                       + 0.25 * aeiv(ji,jj,jk) * e1v(ji,jj) * zslope_skew
+                     END DO
+                  END DO
+               END DO
+            END DO
+         END DO
+         !
+         IF( ln_traldf_msc ) THEN                ! stabilizing vertical diffusivity coefficient
+            !
+            IF( ln_traldf_blp ) THEN                ! bilaplacian operator
+               DO jk = 2, jpkm1
+                  DO jj = 1, jpjm1
+                     DO ji = 1, fs_jpim1
+                        akz(ji,jj,jk) = 16._wp * ah_wslp2(ji,jj,jk)   &
+                           &          * (  akz(ji,jj,jk) + ah_wslp2(ji,jj,jk) / ( fse3w(ji,jj,jk) * fse3w(ji,jj,jk) )  )
+                     END DO
+                  END DO
+               END DO
+            ELSEIF( ln_traldf_lap ) THEN              ! laplacian operator
+               DO jk = 2, jpkm1
+                  DO jj = 1, jpjm1
+                     DO ji = 1, fs_jpim1
+                        ze3w_2 = fse3w(ji,jj,jk) * fse3w(ji,jj,jk)
+                        zcoef0 = z2dt * (  akz(ji,jj,jk) + ah_wslp2(ji,jj,jk) / ze3w_2  )
+                        akz(ji,jj,jk) = MAX( zcoef0 - 0.5_wp , 0._wp ) * ze3w_2 * z1_2dt
+                     END DO
+                  END DO
+               END DO
+           ENDIF
+           !
+         ELSE                                    ! 33 flux set to zero with akz=ah_wslp2 ==>> computed in full implicit
+            akz(:,:,:) = ah_wslp2(:,:,:)      
+         ENDIF
+         !
+         IF( ln_ldfeiv_dia .AND. cdtype == 'TRA' )   CALL ldf_eiv_dia( zpsi_uw, zpsi_vw )
+         !
+      ENDIF                                  !==  end 1st pass only  ==!
+      !
+      !                                                           ! ===========
+      DO jn = 1, kjpt                                             ! tracer loop
+         !                                                        ! ===========
+         ! Zero fluxes for each tracer
+!!gm  this should probably be done outside the jn loop
+         ztfw(:,:,:) = 0._wp
+         zftu(:,:,:) = 0._wp
+         zftv(:,:,:) = 0._wp
+         !
+         DO jk = 1, jpkm1        !==  before lateral T & S gradients at T-level jk  ==!
+            DO jj = 1, jpjm1
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zdit(ji,jj,jk) = ( ptb(ji+1,jj  ,jk,jn) - ptb(ji,jj,jk,jn) ) * umask(ji,jj,jk)
+                  zdjt(ji,jj,jk) = ( ptb(ji  ,jj+1,jk,jn) - ptb(ji,jj,jk,jn) ) * vmask(ji,jj,jk)
+               END DO
+            END DO
+         END DO
+         IF( ln_zps .AND. l_grad_zps ) THEN    ! partial steps: correction at top/bottom ocean level
+            DO jj = 1, jpjm1                       ! bottom level
+               DO ji = 1, fs_jpim1   ! vector opt.
+                  zdit(ji,jj,mbku(ji,jj)) = pgu(ji,jj,jn)
+                  zdjt(ji,jj,mbkv(ji,jj)) = pgv(ji,jj,jn)
+               END DO
+            END DO
+            IF( ln_isfcav ) THEN                   ! top level (ocean cavities only)
+               DO jj = 1, jpjm1
+                  DO ji = 1, fs_jpim1   ! vector opt.
+                     IF( miku(ji,jj)  > 1 )   zdit(ji,jj,miku(ji,jj) ) = pgui(ji,jj,jn) 
+                     IF( mikv(ji,jj)  > 1 )   zdjt(ji,jj,mikv(ji,jj) ) = pgvi(ji,jj,jn) 
+                  END DO
+               END DO
+            ENDIF
+         ENDIF
+
+         !!----------------------------------------------------------------------
+         !!   II - horizontal trend  (full)
+         !!----------------------------------------------------------------------
+         !
+         DO jk = 1, jpkm1
+            !
+            !                    !==  Vertical tracer gradient at level jk and jk+1
+            zdkt3d(:,:,1) = ( ptb(:,:,jk,jn) - ptb(:,:,jk+1,jn) ) * tmask(:,:,jk+1)
+            !
+            !                    ! surface boundary condition: zdkt3d(jk=0)=zdkt3d(jk=1)
+            IF( jk == 1 ) THEN   ;   zdkt3d(:,:,0) = zdkt3d(:,:,1)
+            ELSE                 ;   zdkt3d(:,:,0) = ( ptb(:,:,jk-1,jn) - ptb(:,:,jk,jn) ) * tmask(:,:,jk)
+            ENDIF
+            !
+            zaei_slp = 0._wp
+            !
+            IF( ln_botmix_triad ) THEN
+               DO ip = 0, 1              !==  Horizontal & vertical fluxes
+                  DO kp = 0, 1
+                     DO jj = 1, jpjm1
+                        DO ji = 1, fs_jpim1
+                           ze1ur = r1_e1u(ji,jj)
+                           zdxt  = zdit(ji,jj,jk) * ze1ur
+                           ze3wr = 1._wp / fse3w(ji+ip,jj,jk+kp)
+                           zdzt  = zdkt3d(ji+ip,jj,kp) * ze3wr
+                           zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp)
+                           zslope_iso  = triadi  (ji+ip,jj,jk,1-ip,kp)
+
+                           zbu = 0.25_wp * e1e2u(ji,jj) * fse3u(ji,jj,jk)
+                           ! ln_botmix_triad is .T. don't mask zah for bottom half cells    !!gm ?????   ahu is masked....
+                           zah = pahu(ji,jj,jk)
+                           zah_slp  = zah * zslope_iso
+                           IF( ln_ldfeiv )   zaei_slp = aeiu(ji,jj,jk) * zslope_skew
+                           zftu(ji   ,jj,jk   ) = zftu(ji   ,jj,jk   ) - ( zah * zdxt + (zah_slp - zaei_slp) * zdzt ) * zbu * ze1ur
+                           ztfw(ji+ip,jj,jk+kp) = ztfw(ji+ip,jj,jk+kp) - ( zah_slp + zaei_slp) * zdxt                 * zbu * ze3wr
+                        END DO
+                     END DO
+                  END DO
+               END DO
+
+               DO jp = 0, 1
+                  DO kp = 0, 1
+                     DO jj = 1, jpjm1
+                        DO ji = 1, fs_jpim1
+                           ze2vr = r1_e2v(ji,jj)
+                           zdyt  = zdjt(ji,jj,jk) * ze2vr
+                           ze3wr = 1._wp / fse3w(ji,jj+jp,jk+kp)
+                           zdzt  = zdkt3d(ji,jj+jp,kp) * ze3wr
+                           zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp)
+                           zslope_iso  = triadj(ji,jj+jp,jk,1-jp,kp)
+                           zbv = 0.25_wp * e1e2v(ji,jj) * fse3v(ji,jj,jk)
+                           ! ln_botmix_triad is .T. don't mask zah for bottom half cells    !!gm ?????  ahv is masked...
+                           zah = pahv(ji,jj,jk)
+                           zah_slp = zah * zslope_iso
+                           IF( ln_ldfeiv )   zaei_slp = aeiv(ji,jj,jk) * zslope_skew
+                           zftv(ji,jj   ,jk   ) = zftv(ji,jj   ,jk   ) - ( zah * zdyt + (zah_slp - zaei_slp) * zdzt ) * zbv * ze2vr
+                           ztfw(ji,jj+jp,jk+kp) = ztfw(ji,jj+jp,jk+kp) - ( zah_slp + zaei_slp ) * zdyt                * zbv * ze3wr
+                        END DO
+                     END DO
+                  END DO
+               END DO
+
+            ELSE
+
+               DO ip = 0, 1               !==  Horizontal & vertical fluxes
+                  DO kp = 0, 1
+                     DO jj = 1, jpjm1
+                        DO ji = 1, fs_jpim1
+                           ze1ur = r1_e1u(ji,jj)
+                           zdxt  = zdit(ji,jj,jk) * ze1ur
+                           ze3wr = 1._wp / fse3w(ji+ip,jj,jk+kp)
+                           zdzt  = zdkt3d(ji+ip,jj,kp) * ze3wr
+                           zslope_skew = triadi_g(ji+ip,jj,jk,1-ip,kp)
+                           zslope_iso  = triadi(ji+ip,jj,jk,1-ip,kp)
+
+                           zbu = 0.25_wp * e1e2u(ji,jj) * fse3u(ji,jj,jk)
+                           ! ln_botmix_triad is .F. mask zah for bottom half cells
+                           zah = pahu(ji,jj,jk) * umask(ji,jj,jk+kp)         ! pahu(ji+ip,jj,jk)   ===>>  ????
+                           zah_slp  = zah * zslope_iso
+                           IF( ln_ldfeiv )   zaei_slp = aeiu(ji,jj,jk) * zslope_skew        ! fsaeit(ji+ip,jj,jk)*zslope_skew
+                           zftu(ji   ,jj,jk   ) = zftu(ji   ,jj,jk   ) - ( zah * zdxt + (zah_slp - zaei_slp) * zdzt ) * zbu * ze1ur
+                           ztfw(ji+ip,jj,jk+kp) = ztfw(ji+ip,jj,jk+kp) - (zah_slp + zaei_slp) * zdxt * zbu * ze3wr
+                        END DO
+                     END DO
+                  END DO
+               END DO
+
+               DO jp = 0, 1
+                  DO kp = 0, 1
+                     DO jj = 1, jpjm1
+                        DO ji = 1, fs_jpim1
+                           ze2vr = r1_e2v(ji,jj)
+                           zdyt  = zdjt(ji,jj,jk) * ze2vr
+                           ze3wr = 1._wp / fse3w(ji,jj+jp,jk+kp)
+                           zdzt  = zdkt3d(ji,jj+jp,kp) * ze3wr
+                           zslope_skew = triadj_g(ji,jj+jp,jk,1-jp,kp)
+                           zslope_iso  = triadj(ji,jj+jp,jk,1-jp,kp)
+                           zbv = 0.25_wp * e1e2v(ji,jj) * fse3v(ji,jj,jk)
+                           ! ln_botmix_triad is .F. mask zah for bottom half cells
+                           zah = pahv(ji,jj,jk) * vmask(ji,jj,jk+kp)         ! pahv(ji,jj+jp,jk)  ????
+                           zah_slp = zah * zslope_iso
+                           IF( ln_ldfeiv )   zaei_slp = aeiv(ji,jj,jk) * zslope_skew        ! fsaeit(ji,jj+jp,jk)*zslope_skew
+                           zftv(ji,jj,jk) = zftv(ji,jj,jk) - ( zah * zdyt + (zah_slp - zaei_slp) * zdzt ) * zbv * ze2vr
+                           ztfw(ji,jj+jp,jk+kp) = ztfw(ji,jj+jp,jk+kp) - (zah_slp + zaei_slp) * zdyt * zbv * ze3wr
+                        END DO
+                     END DO
+                  END DO
+               END DO
+            ENDIF
+            !                             !==  horizontal divergence and add to the general trend  ==!
+            DO jj = 2 , jpjm1
+               DO ji = fs_2, fs_jpim1  ! vector opt.
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zsign * (  zftu(ji-1,jj,jk) - zftu(ji,jj,jk)       &
+                     &                                           + zftv(ji,jj-1,jk) - zftv(ji,jj,jk)   )   &
+                     &                                        / (  e1e2t(ji,jj) * fse3t(ji,jj,jk)  )
+               END DO
+            END DO
+            !
+         END DO
+         !
+         !                                !==  add the vertical 33 flux  ==!
+         IF( ln_traldf_lap ) THEN               ! laplacian case: eddy coef = ah_wslp2 - akz
+            DO jk = 2, jpkm1       
+               DO jj = 1, jpjm1
+                  DO ji = fs_2, fs_jpim1
+                     ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / fse3w(ji,jj,jk) * tmask(ji,jj,jk)   &
+                        &                            * ( ah_wslp2(ji,jj,jk) - akz(ji,jj,jk) )             &
+                        &                            * ( ptb(ji,jj,jk-1,jn) - ptb(ji,jj,jk,jn) )
+                  END DO
+               END DO
+            END DO
+         ELSE                                   ! bilaplacian 
+            SELECT CASE( kpass )
+            CASE(  1  )                            ! 1st pass : eddy coef = ah_wslp2
+               DO jk = 2, jpkm1 
+                  DO jj = 1, jpjm1
+                     DO ji = fs_2, fs_jpim1
+                        ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / fse3w(ji,jj,jk) * tmask(ji,jj,jk)             &
+                           &                            * ah_wslp2(ji,jj,jk) * ( ptb(ji,jj,jk-1,jn) - ptb(ji,jj,jk,jn) )
+                     END DO
+                  END DO
+               END DO 
+            CASE(  2  )                            ! 2nd pass : eddy flux = ah_wslp2 and akz applied on ptb  and ptbb gradients, resp.
+               DO jk = 2, jpkm1 
+                  DO jj = 1, jpjm1
+                     DO ji = fs_2, fs_jpim1
+                        ztfw(ji,jj,jk) = ztfw(ji,jj,jk) - e1e2t(ji,jj) / fse3w(ji,jj,jk) * tmask(ji,jj,jk)                      &
+                           &                            * (  ah_wslp2(ji,jj,jk) * ( ptb (ji,jj,jk-1,jn) - ptb (ji,jj,jk,jn) )   &
+                           &                               + akz     (ji,jj,jk) * ( ptbb(ji,jj,jk-1,jn) - ptbb(ji,jj,jk,jn) )   )
+                     END DO
+                  END DO
+               END DO
+            END SELECT 
+         ENDIF
+         !
+         DO jk = 1, jpkm1                 !==  Divergence of vertical fluxes added to pta  ==!
+            DO jj = 2, jpjm1
+               DO ji = fs_2, fs_jpim1  ! vector opt.
+                  pta(ji,jj,jk,jn) = pta(ji,jj,jk,jn) + zsign * (  ztfw(ji,jj,jk+1) - ztfw(ji,jj,jk)  )   &
+                     &                                        / ( e1e2t(ji,jj) * fse3t(ji,jj,jk) )
+               END DO
+            END DO
+         END DO
+         !
+         IF( ( kpass == 1 .AND. ln_traldf_lap ) .OR.  &     !==  first pass only (  laplacian)  ==!
+             ( kpass == 2 .AND. ln_traldf_blp ) ) THEN      !==  2nd   pass      (bilaplacian)  ==!
+            !
+            !                          ! "Poleward" diffusive heat or salt transports (T-S case only)
+            IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
+               IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( zftv(:,:,:) )        ! 3.3  names
+               IF( jn == jp_sal)   str_ldf(:) = ptr_sj( zftv(:,:,:) )
+            ENDIF
+            !
+            IF( iom_use("udiff_heattr") .OR. iom_use("vdiff_heattr") ) THEN
+              !
+              IF( cdtype == 'TRA' .AND. jn == jp_tem  ) THEN
+                  z2d(:,:) = zftu(ji,jj,1) 
+                  DO jk = 2, jpkm1
+                     DO jj = 2, jpjm1
+                        DO ji = fs_2, fs_jpim1   ! vector opt.
+                           z2d(ji,jj) = z2d(ji,jj) + zftu(ji,jj,jk) 
+                        END DO
+                     END DO
+                  END DO
+                  z2d(:,:) = rau0_rcp * z2d(:,:) 
+                  CALL lbc_lnk( z2d, 'U', -1. )
+                  CALL iom_put( "udiff_heattr", z2d )                  ! heat i-transport
+                  !
+                  z2d(:,:) = zftv(ji,jj,1) 
+                  DO jk = 2, jpkm1
+                     DO jj = 2, jpjm1
+                        DO ji = fs_2, fs_jpim1   ! vector opt.
+                           z2d(ji,jj) = z2d(ji,jj) + zftv(ji,jj,jk) 
+                        END DO
+                     END DO
+                  END DO
+                  z2d(:,:) = rau0_rcp * z2d(:,:)     
+                  CALL lbc_lnk( z2d, 'V', -1. )
+                  CALL iom_put( "vdiff_heattr", z2d )                  !  heat j-transport
+               ENDIF
+               !
+            ENDIF
+            !
+         ENDIF                                                    !== end pass selection  ==!
+         !
+         !                                                        ! ===============
+      END DO                                                      ! end tracer loop
+      !                                                           ! ===============
+      !
+      CALL wrk_dealloc( jpi,jpj,       z2d ) 
+      CALL wrk_dealloc( jpi,jpj,jpk,   zdit, zdjt, zftu, zftv, ztfw, zpsi_uw, zpsi_vw  ) 
+      !
+      IF( nn_timing == 1 )  CALL timing_stop('tra_ldf_triad')
+      !
+   END SUBROUTINE tra_ldf_triad
+
+   !!==============================================================================
+END MODULE traldf_triad
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 6041)
@@ -31,11 +31,10 @@
    USE zdf_oce         ! ocean vertical mixing
    USE domvvl          ! variable volume
-   USE dynspg_oce      ! surface     pressure gradient variables
-   USE dynhpg          ! hydrostatic pressure gradient 
    USE trd_oce         ! trends: ocean variables
    USE trdtra          ! trends manager: tracers 
    USE traqsr          ! penetrative solar radiation (needed for nksr)
    USE phycst          ! physical constant
-   USE ldftra_oce      ! lateral physics on tracers
+   USE ldftra          ! lateral physics on tracers
+   USE ldfslp
    USE bdy_oce         ! BDY open boundary condition variables
    USE bdytra          ! open boundary condition (bdy_tra routine)
@@ -57,5 +56,4 @@
    PUBLIC   tra_nxt_vvl   ! to be used in trcnxt
 
-   REAL(wp) ::   rbcp   ! Brown & Campana parameters for semi-implicit hpg
 
    !! * Substitutions
@@ -89,5 +87,5 @@
       !!
       !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
-      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
+      !!
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in) ::   kt    ! ocean time-step index
@@ -104,10 +102,9 @@
          IF(lwp) WRITE(numout,*) 'tra_nxt : achieve the time stepping by Asselin filter and array swap'
          IF(lwp) WRITE(numout,*) '~~~~~~~'
-         !
-         rbcp = 0.25_wp * (1._wp + atfp) * (1._wp + atfp) * ( 1._wp - atfp)      ! Brown & Campana parameter for semi-implicit hpg
       ENDIF
 
       ! Update after tracer on domain lateral boundaries
       ! 
+      !
 #if defined key_agrif
       CALL Agrif_tra                     ! AGRIF zoom boundaries
@@ -180,18 +177,8 @@
       !! 
       !! ** Method  : - Apply a Asselin time filter on now fields.
-      !!              - save in (ta,sa) an average over the three time levels 
-      !!             which will be used to compute rdn and thus the semi-implicit
-      !!             hydrostatic pressure gradient (ln_dynhpg_imp = T)
       !!              - swap tracer fields to prepare the next time_step.
-      !!                This can be summurized for tempearture as:
-      !!             ztm = tn + rbcp * [ta -2 tn + tb ]       ln_dynhpg_imp = T
-      !!             ztm = 0                                   otherwise
-      !!                   with rbcp=1/4 * (1-atfp^4) / (1-atfp)
-      !!             tb  = tn + atfp*[ tb - 2 tn + ta ]
-      !!             tn  = ta  
-      !!             ta  = ztm       (NB: reset to 0 after eos_bn2 call)
       !!
       !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
-      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
+      !!              
       !!----------------------------------------------------------------------
       INTEGER         , INTENT(in   )                               ::   kt       ! ocean time-step index
@@ -204,5 +191,4 @@
       !
       INTEGER  ::   ji, jj, jk, jn   ! dummy loop indices
-      LOGICAL  ::   ll_tra_hpg       ! local logical
       REAL(wp) ::   ztn, ztd         ! local scalars
       !!----------------------------------------------------------------------
@@ -214,7 +200,4 @@
       ENDIF
       !
-      IF( cdtype == 'TRA' )  THEN   ;   ll_tra_hpg = ln_dynhpg_imp    ! active  tracers case  and  semi-implicit hpg    
-      ELSE                          ;   ll_tra_hpg = .FALSE.          ! passive tracers case or NO semi-implicit hpg
-      ENDIF
       !
       DO jn = 1, kjpt
@@ -229,5 +212,4 @@
                   ptn(ji,jj,jk,jn) = pta(ji,jj,jk,jn)                       ! ptn <-- pta
                   !
-                  IF( ll_tra_hpg )   pta(ji,jj,jk,jn) = ztn + rbcp * ztd    ! pta <-- Brown & Campana average
                END DO
            END DO
@@ -247,19 +229,9 @@
       !! 
       !! ** Method  : - Apply a thickness weighted Asselin time filter on now fields.
-      !!              - save in (ta,sa) a thickness weighted average over the three 
-      !!             time levels which will be used to compute rdn and thus the semi-
-      !!             implicit hydrostatic pressure gradient (ln_dynhpg_imp = T)
       !!              - swap tracer fields to prepare the next time_step.
       !!                This can be summurized for tempearture as:
-      !!             ztm = ( e3t_n*tn + rbcp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )   ln_dynhpg_imp = T
-      !!                  /( e3t_n    + rbcp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )   
-      !!             ztm = 0                                                       otherwise
-      !!             tb  = ( e3t_n*tn + atfp*[ e3t_b*tb - 2 e3t_n*tn + e3t_a*ta ] )
-      !!                  /( e3t_n    + atfp*[ e3t_b    - 2 e3t_n    + e3t_a    ] )
-      !!             tn  = ta 
-      !!             ta  = zt        (NB: reset to 0 after eos_bn2 call)
       !!
       !! ** Action  : - (tb,sb) and (tn,sn) ready for the next time step
-      !!              - (ta,sa) time averaged (t,s)   (ln_dynhpg_imp = T)
+      !!
       !!----------------------------------------------------------------------
       INTEGER         , INTENT(in   )                               ::  kt       ! ocean time-step index
@@ -275,5 +247,5 @@
 
       !!     
-      LOGICAL  ::   ll_tra_hpg, ll_traqsr, ll_rnf, ll_isf   ! local logical
+      LOGICAL  ::   ll_traqsr, ll_rnf, ll_isf   ! local logical
       INTEGER  ::   ji, jj, jk, jn              ! dummy loop indices
       REAL(wp) ::   zfact1, ztc_a , ztc_n , ztc_b , ztc_f , ztc_d    ! local scalar
@@ -288,5 +260,4 @@
       !
       IF( cdtype == 'TRA' )  THEN   
-         ll_tra_hpg = ln_dynhpg_imp    ! active  tracers case  and  semi-implicit hpg
          ll_traqsr  = ln_traqsr        ! active  tracers case  and  solar penetration
          ll_rnf     = ln_rnf           ! active  tracers case  and  river runoffs
@@ -297,5 +268,4 @@
          END IF
       ELSE                          
-         ll_tra_hpg = .FALSE.          ! passive tracers case or NO semi-implicit hpg
          ll_traqsr  = .FALSE.          ! active  tracers case and NO solar penetration
          ll_rnf     = .FALSE.          ! passive tracers or NO river runoffs
@@ -355,8 +325,4 @@
                   ptn(ji,jj,jk,jn) = pta(ji,jj,jk,jn)     ! ptn <-- pta
                   !
-                  IF( ll_tra_hpg ) THEN        ! semi-implicit hpg (T & S only)
-                     ze3t_d           = 1.e0   / ( ze3t_n + rbcp * ze3t_d )
-                     pta(ji,jj,jk,jn) = ze3t_d * ( ztc_n  + rbcp * ztc_d  )   ! ta <-- Brown & Campana average
-                  ENDIF
                END DO
             END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/traqsr.F90	(revision 6041)
@@ -189,8 +189,5 @@
                   CALL fld_read( kt, 1, sf_chl )                         ! Read Chl data and provides it at the current time step
                   !         
-!CDIR COLLAPSE
-!CDIR NOVERRCHK
                   DO jj = 1, jpj                                         ! Separation in R-G-B depending of the surface Chl
-!CDIR NOVERRCHK
                      DO ji = 1, jpi
                         zchl = MIN( 10. , MAX( 0.03, sf_chl(1)%fnow(ji,jj,1) ) )
@@ -217,7 +214,5 @@
                !
                DO jk = 2, nksr+1
-!CDIR NOVERRCHK
                   DO jj = 1, jpj
-!CDIR NOVERRCHK   
                      DO ji = 1, jpi
                         zc0 = ze0(ji,jj,jk-1) * EXP( - fse3t(ji,jj,jk-1) * xsi0r     )
@@ -495,7 +490,5 @@
                
                   DO jk = 2, nksr+1
-!CDIR NOVERRCHK
                      DO jj = 1, jpj
-!CDIR NOVERRCHK   
                         DO ji = 1, jpi
                            zc0 = ze0(ji,jj,jk-1) * EXP( - e3t_0(ji,jj,jk-1) * xsi0r     )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf.F90	(revision 6041)
@@ -18,8 +18,10 @@
    USE zdf_oce         ! ocean vertical physics variables
    USE sbc_oce         ! surface boundary condition: ocean
-   USE dynspg_oce
+   !
+   USE ldftra          ! lateral diffusion: eddy diffusivity
+   USE ldfslp          ! lateral diffusion: iso-neutral slope 
    USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
    USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
-   USE ldftra_oce      ! ocean active tracers: lateral physics
+   !
    USE trd_oce         ! trends: ocean variables
    USE trdtra          ! trends manager: tracers 
@@ -45,5 +47,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -80,16 +82,11 @@
       CASE ( 0 )    ;    CALL tra_zdf_exp( kt, nit000, 'TRA', r2dtra, nn_zdfexp, tsb, tsa, jpts )  !   explicit scheme 
       CASE ( 1 )    ;    CALL tra_zdf_imp( kt, nit000, 'TRA', r2dtra,            tsb, tsa, jpts )  !   implicit scheme 
-      CASE ( -1 )                                       ! esopa: test all possibility with control print
-         CALL tra_zdf_exp( kt, nit000, 'TRA', r2dtra, nn_zdfexp, tsb, tsa, jpts )
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf0 - Ta: ', mask1=tmask,               &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-         CALL tra_zdf_imp( kt, nit000, 'TRA', r2dtra,            tsb, tsa, jpts ) 
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' zdf1 - Ta: ', mask1=tmask,               &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
       END SELECT
+!!gm WHY here !   and I don't like that !
       ! DRAKKAR SSS control {
       ! JMM avoid negative salinities near river outlet ! Ugly fix
       ! JMM : restore negative salinities to small salinities:
       WHERE ( tsa(:,:,:,jp_sal) < 0._wp )   tsa(:,:,:,jp_sal) = 0.1_wp
+!!gm
 
       IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
@@ -98,6 +95,8 @@
             ztrds(:,:,jk) = ( ( tsa(:,:,jk,jp_sal) - tsb(:,:,jk,jp_sal) ) / r2dtra(jk) ) - ztrds(:,:,jk)
          END DO
+!!gm this should be moved in trdtra.F90 and done on all trends
          CALL lbc_lnk( ztrdt, 'T', 1. )
          CALL lbc_lnk( ztrds, 'T', 1. )
+!!gm
          CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
          CALL trd_tra( kt, 'TRA', jp_sal, jptra_zdf, ztrds )
@@ -123,10 +122,9 @@
       !!      nzdf = 0   explicit (time-splitting) scheme (ln_zdfexp=T)
       !!           = 1   implicit (euler backward) scheme (ln_zdfexp=F)
-      !!      NB: rotation of lateral mixing operator or TKE or KPP scheme,
-      !!      the implicit scheme is required.
+      !!      NB: rotation of lateral mixing operator or TKE & GLS schemes,
+      !!          an implicit scheme is required.
       !!----------------------------------------------------------------------
       USE zdftke
       USE zdfgls
-      USE zdfkpp
       !!----------------------------------------------------------------------
 
@@ -137,12 +135,9 @@
 
       ! Force implicit schemes
-      IF( lk_zdftke .OR. lk_zdfgls .OR. lk_zdfkpp )   nzdf = 1      ! TKE, GLS or KPP physics
-      IF( ln_traldf_iso                           )   nzdf = 1      ! iso-neutral lateral physics
-      IF( ln_traldf_hor .AND. ln_sco              )   nzdf = 1      ! horizontal lateral physics in s-coordinate
+      IF( lk_zdftke .OR. lk_zdfgls   )   nzdf = 1   ! TKE, or GLS physics
+      IF( ln_traldf_iso              )   nzdf = 1   ! iso-neutral lateral physics
+      IF( ln_traldf_hor .AND. ln_sco )   nzdf = 1   ! horizontal lateral physics in s-coordinate
       IF( ln_zdfexp .AND. nzdf == 1 )   CALL ctl_stop( 'tra_zdf : If using the rotation of lateral mixing operator',   &
-            &                         ' TKE or KPP scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
-
-      ! Test: esopa
-      IF( lk_esopa )    nzdf = -1                      ! All schemes used
+            &                         ' GLS or TKE scheme, the implicit scheme is required, set ln_zdfexp = .false.' )
 
       IF(lwp) THEN
@@ -150,5 +145,4 @@
          WRITE(numout,*) 'tra_zdf_init : vertical tracer physics scheme'
          WRITE(numout,*) '~~~~~~~~~~~'
-         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
          IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
          IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/trazdf_imp.F90	(revision 6041)
@@ -19,22 +19,21 @@
   
    !!----------------------------------------------------------------------
-   !!   tra_zdf_imp : Update the tracer trend with the diagonal vertical  
-   !!                 part of the mixing tensor.
-   !!----------------------------------------------------------------------
-   USE oce             ! ocean dynamics and tracers variables
-   USE dom_oce         ! ocean space and time domain variables 
-   USE zdf_oce         ! ocean vertical physics variables
-   USE trc_oce         ! share passive tracers/ocean variables
-   USE domvvl          ! variable volume
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldftra          ! lateral mixing type
-   USE ldfslp          ! lateral physics: slope of diffusion
-   USE zdfddm          ! ocean vertical physics: double diffusion
-   USE traldf_iso_grif ! active tracers: Griffies operator
-   USE in_out_manager  ! I/O manager
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
-   USE lib_mpp         ! MPP library
-   USE wrk_nemo        ! Memory Allocation
-   USE timing          ! Timing
+   !!   tra_zdf_imp   : Update the tracer trend with the diagonal vertical part of the mixing tensor.
+   !!----------------------------------------------------------------------
+   USE oce            ! ocean dynamics and tracers variables
+   USE dom_oce        ! ocean space and time domain variables 
+   USE zdf_oce        ! ocean vertical physics variables
+   USE trc_oce        ! share passive tracers/ocean variables
+   USE domvvl         ! variable volume
+   USE ldftra         ! lateral mixing type
+   USE ldfslp         ! lateral physics: slope of diffusion
+   USE zdfddm         ! ocean vertical physics: double diffusion
+   USE traldf_triad   ! active tracers: Method of Stabilizing Correction
+   !
+   USE in_out_manager ! I/O manager
+   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
+   USE lib_mpp        ! MPP library
+   USE wrk_nemo       ! Memory Allocation
+   USE timing         ! Timing
 
    IMPLICIT NONE
@@ -47,9 +46,8 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
 #  include "zdfddm_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -76,6 +74,4 @@
       !! ** Action  : - pta  becomes the after tracer
       !!---------------------------------------------------------------------
-      USE oce     , ONLY:   zwd => ua       , zws => va         ! (ua,va) used as 3D workspace
-      !
       INTEGER                              , INTENT(in   ) ::   kt       ! ocean time-step index
       INTEGER                              , INTENT(in   ) ::   kit000          ! first time step index
@@ -88,10 +84,10 @@
       INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
       REAL(wp) ::  zrhs, ze3tb, ze3tn, ze3ta   ! local scalars
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwt
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  zwi, zwt, zwd, zws
       !!---------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('tra_zdf_imp')
       !
-      CALL wrk_alloc( jpi, jpj, jpk, zwi, zwt ) 
+      CALL wrk_alloc( jpi,jpj,jpk,   zwi, zwt, zwd, zws ) 
       !
       IF( kt == kit000 )  THEN
@@ -120,32 +116,26 @@
             ELSE                                            ;   zwt(:,:,2:jpk) = fsavs(:,:,2:jpk)
             ENDIF
-            DO jj=1, jpj
-               DO ji=1, jpi
-                  zwt(ji,jj,1) = 0._wp
-               END DO
-            END DO
-!
-#if defined key_ldfslp
-            ! isoneutral diffusion: add the contribution 
-            IF( ln_traldf_grif    ) THEN     ! Griffies isoneutral diff
-               DO jk = 2, jpkm1
-                  DO jj = 2, jpjm1
-                     DO ji = fs_2, fs_jpim1   ! vector opt.
-                        zwt(ji,jj,jk) = zwt(ji,jj,jk) + ah_wslp2(ji,jj,jk)       
+            zwt(:,:,1) = 0._wp
+            !
+            IF( l_ldfslp ) THEN            ! isoneutral diffusion: add the contribution 
+               IF( ln_traldf_msc  ) THEN     ! MSC iso-neutral operator 
+                  DO jk = 2, jpkm1
+                     DO jj = 2, jpjm1
+                        DO ji = fs_2, fs_jpim1   ! vector opt.
+                           zwt(ji,jj,jk) = zwt(ji,jj,jk) + akz(ji,jj,jk)  
+                        END DO
                      END DO
                   END DO
-               END DO
-            ELSE IF( l_traldf_rot ) THEN     ! standard isoneutral diff
-               DO jk = 2, jpkm1
-                  DO jj = 2, jpjm1
-                     DO ji = fs_2, fs_jpim1   ! vector opt.
-                        zwt(ji,jj,jk) = zwt(ji,jj,jk) + fsahtw(ji,jj,jk)                       &
-                           &                          * (  wslpi(ji,jj,jk) * wslpi(ji,jj,jk)   &
-                           &                             + wslpj(ji,jj,jk) * wslpj(ji,jj,jk)  )
+               ELSE                          ! standard or triad iso-neutral operator
+                  DO jk = 2, jpkm1
+                     DO jj = 2, jpjm1
+                        DO ji = fs_2, fs_jpim1   ! vector opt.
+                           zwt(ji,jj,jk) = zwt(ji,jj,jk) + ah_wslp2(ji,jj,jk)
+                        END DO
                      END DO
                   END DO
-               END DO
+               ENDIF
             ENDIF
-#endif
+            !
             ! Diagonal, lower (i), upper (s)  (including the bottom boundary condition since avt is masked)
             DO jk = 1, jpkm1
@@ -202,6 +192,5 @@
                ze3tb = ( 1. - r_vvl ) + r_vvl * fse3t_b(ji,jj,1)
                ze3tn = ( 1. - r_vvl ) + r_vvl * fse3t(ji,jj,1)
-               pta(ji,jj,1,jn) = ze3tb * ptb(ji,jj,1,jn)                     &
-                  &                      + p2dt(1) * ze3tn * pta(ji,jj,1,jn)
+               pta(ji,jj,1,jn) = ze3tb * ptb(ji,jj,1,jn) + p2dt(1) * ze3tn * pta(ji,jj,1,jn)
             END DO
          END DO
@@ -235,5 +224,5 @@
       !                                               ! ================= !
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwt ) 
+      CALL wrk_dealloc( jpi,jpj,jpk,   zwi, zwt, zwd, zws ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_zdf_imp')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRA/zpshde.F90	(revision 6041)
@@ -93,16 +93,15 @@
       REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgru, pgrv  ! hor. grad of prd at u- & v-pts (bottom)
       !
-      INTEGER  ::   ji, jj, jn      ! Dummy loop indices
-      INTEGER  ::   iku, ikv, ikum1, ikvm1   ! partial step level (ocean bottom level) at u- and v-points
-      REAL(wp) ::  ze3wu, ze3wv, zmaxu, zmaxv  ! temporary scalars
-      REAL(wp), DIMENSION(jpi,jpj)      ::  zri, zrj, zhi, zhj   ! NB: 3rd dim=1 to use eos
-      REAL(wp), DIMENSION(jpi,jpj,kjpt) ::  zti, ztj             ! 
+      INTEGER  ::   ji, jj, jn                  ! Dummy loop indices
+      INTEGER  ::   iku, ikv, ikum1, ikvm1      ! partial step level (ocean bottom level) at u- and v-points
+      REAL(wp) ::   ze3wu, ze3wv, zmaxu, zmaxv  ! local scalars
+      REAL(wp), DIMENSION(jpi,jpj)      ::   zri, zrj, zhi, zhj   ! NB: 3rd dim=1 to use eos
+      REAL(wp), DIMENSION(jpi,jpj,kjpt) ::   zti, ztj             ! 
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start( 'zps_hde')
-      !
-      pgtu(:,:,:)=0.0_wp ; pgtv(:,:,:)=0.0_wp ;
-      zti (:,:,:)=0.0_wp ; ztj (:,:,:)=0.0_wp ;
-      zhi (:,:  )=0.0_wp ; zhj (:,:  )=0.0_wp ;
+      IF( nn_timing == 1 )   CALL timing_start( 'zps_hde')
+      !
+      pgtu(:,:,:)=0._wp   ;   zti (:,:,:)=0._wp   ;   zhi (:,:  )=0._wp
+      pgtv(:,:,:)=0._wp   ;   ztj (:,:,:)=0._wp   ;   zhj (:,:  )=0._wp
       !
       DO jn = 1, kjpt      !==   Interpolation of tracers at the last ocean level   ==!
@@ -149,8 +148,8 @@
          !
       END DO
-
-      ! horizontal derivative of density anomalies (rd)
-      IF( PRESENT( prd ) ) THEN         ! depth of the partial step level
-         pgru(:,:)=0.0_wp   ; pgrv(:,:)=0.0_wp ; 
+      !                
+      IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
+         pgru(:,:) = 0._wp
+         pgrv(:,:) = 0._wp                ! depth of the partial step level
          DO jj = 1, jpjm1
             DO ji = 1, jpim1
@@ -167,12 +166,9 @@
             END DO
          END DO
-
-         ! Compute interpolated rd from zti, ztj for the 2 cases at the depth of the partial
-         ! step and store it in  zri, zrj for each  case
-         CALL eos( zti, zhi, zri )  
-         CALL eos( ztj, zhj, zrj )
-
-         ! Gradient of density at the last level 
-         DO jj = 1, jpjm1
+         !
+         CALL eos( zti, zhi, zri )        ! interpolated density from zti, ztj 
+         CALL eos( ztj, zhj, zrj )        ! at the partial step depth output in  zri, zrj 
+         !
+         DO jj = 1, jpjm1                 ! Gradient of density at the last level 
             DO ji = 1, jpim1
                iku = mbku(ji,jj)
@@ -192,11 +188,12 @@
       END IF
       !
-      IF( nn_timing == 1 )  CALL timing_stop( 'zps_hde')
+      IF( nn_timing == 1 )   CALL timing_stop( 'zps_hde')
       !
    END SUBROUTINE zps_hde
-   !
-   SUBROUTINE zps_hde_isf( kt, kjpt, pta, pgtu, pgtv,   &
-      &                          prd, pgru, pgrv, pmru, pmrv, pgzu, pgzv, pge3ru, pge3rv,  &
-      &                   pgtui, pgtvi, pgrui, pgrvi, pmrui, pmrvi, pgzui, pgzvi, pge3rui, pge3rvi )
+
+
+   SUBROUTINE zps_hde_isf( kt, kjpt, pta, pgtu , pgtv , pgtui, pgtvi,                                   &
+      &                              prd, pgru , pgrv , pmru , pmrv , pgzu , pgzv , pge3ru , pge3rv ,   &
+      &                                   pgrui, pgrvi, pmrui, pmrvi, pgzui, pgzvi, pge3rui, pge3rvi )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE zps_hde  ***
@@ -245,18 +242,20 @@
       !!              - pge3ru, pge3rv, pge3rui, pge3rvi: horizontal gradient of rho weighted by local e3w at u- & v-points 
       !!----------------------------------------------------------------------
-      INTEGER                              , INTENT(in   )           ::  kt          ! ocean time-step index
-      INTEGER                              , INTENT(in   )           ::  kjpt        ! number of tracers
-      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   )           ::  pta         ! 4D tracers fields
-      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(  out)           ::  pgtu, pgtv  ! hor. grad. of ptra at u- & v-pts 
-      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(  out)           ::  pgtui, pgtvi  ! hor. grad. of stra at u- & v-pts (ISF)
-      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ), OPTIONAL ::  prd         ! 3D density anomaly fields
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgru, pgrv      ! hor. grad of prd at u- & v-pts (bottom)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pmru, pmrv      ! hor. sum  of prd at u- & v-pts (bottom)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgzu, pgzv      ! hor. grad of z   at u- & v-pts (bottom)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pge3ru, pge3rv  ! hor. grad of prd weighted by local e3w at u- & v-pts (bottom)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgrui, pgrvi      ! hor. grad of prd at u- & v-pts (top)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pmrui, pmrvi      ! hor. sum  of prd at u- & v-pts (top)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgzui, pgzvi      ! hor. grad of z   at u- & v-pts (top)
-      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pge3rui, pge3rvi  ! hor. grad of prd weighted by local e3w at u- & v-pts (top)
+      INTEGER                              , INTENT(in   )           ::  kt                ! ocean time-step index
+      INTEGER                              , INTENT(in   )           ::  kjpt              ! number of tracers
+      REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(in   )           ::  pta               ! 4D tracers fields
+      !                                                              !!  u-point ! v-point !
+      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(  out)           ::  pgtu    , pgtv    ! bottom GRADh( ptra )  
+      REAL(wp), DIMENSION(jpi,jpj,    kjpt), INTENT(  out)           ::  pgtui   , pgtvi   ! top    GRADh( ptra )
+      REAL(wp), DIMENSION(jpi,jpj,jpk     ), INTENT(in   ), OPTIONAL ::  prd               ! 3D density anomaly fields
+      !                                                              !!  u-point ! v-point !
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgru    , pgrv    ! bottom GRADh( prd  )
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pmru    , pmrv    ! bottom SUM  ( prd  )
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgzu    , pgzv    ! bottom GRADh( z    ) 
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pge3ru  , pge3rv  ! bottom GRADh( prd  ) weighted by e3w
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgrui   , pgrvi   ! top    GRADh( prd  ) 
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pmrui   , pmrvi   ! top    SUM  ( prd  ) 
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pgzui   , pgzvi   ! top    GRADh( z    ) 
+      REAL(wp), DIMENSION(jpi,jpj         ), INTENT(  out), OPTIONAL ::  pge3rui , pge3rvi ! top    GRADh( prd  ) weighted by e3w
       !
       INTEGER  ::   ji, jj, jn      ! Dummy loop indices
@@ -269,8 +268,8 @@
       IF( nn_timing == 1 )  CALL timing_start( 'zps_hde_isf')
       !
-      pgtu(:,:,:)=0.0_wp ; pgtv(:,:,:)=0.0_wp ;
-      pgtui(:,:,:)=0.0_wp ; pgtvi(:,:,:)=0.0_wp ;
-      zti (:,:,:)=0.0_wp ; ztj (:,:,:)=0.0_wp ;
-      zhi (:,:  )=0.0_wp ; zhj (:,:  )=0.0_wp ;
+      pgtu (:,:,:) = 0._wp   ;   pgtv (:,:,:) =0._wp
+      pgtui(:,:,:) = 0._wp   ;   pgtvi(:,:,:) =0._wp
+      zti  (:,:,:) = 0._wp   ;   ztj  (:,:,:) =0._wp
+      zhi  (:,:  ) = 0._wp   ;   zhj  (:,:  ) =0._wp
       !
       DO jn = 1, kjpt      !==   Interpolation of tracers at the last ocean level   ==!
@@ -322,11 +321,12 @@
       END DO
 
-      ! horizontal derivative of density anomalies (rd)
-      IF( PRESENT( prd ) ) THEN         ! depth of the partial step level
-         pgru(:,:)=0.0_wp   ; pgrv(:,:)=0.0_wp ; 
-         pgzu(:,:)=0.0_wp   ; pgzv(:,:)=0.0_wp ;
-         pmru(:,:)=0.0_wp   ; pmru(:,:)=0.0_wp ;
-         pge3ru(:,:)=0.0_wp ; pge3rv(:,:)=0.0_wp ;
-         DO jj = 1, jpjm1
+      IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
+         !
+         pgru  (:,:)=0._wp   ;   pgrv  (:,:) = 0._wp
+         pgzu  (:,:)=0._wp   ;   pgzv  (:,:) = 0._wp 
+         pmru  (:,:)=0._wp   ;   pmru  (:,:) = 0._wp 
+         pge3ru(:,:)=0._wp   ;   pge3rv(:,:) = 0._wp 
+         !
+         DO jj = 1, jpjm1                 ! depth of the partial step level
             DO ji = 1, jpim1
                iku = mbku(ji,jj)
@@ -334,5 +334,5 @@
                ze3wu  = (gdept_0(ji+1,jj,iku) - gdepw_0(ji+1,jj,iku)) - (gdept_0(ji,jj,iku) - gdepw_0(ji,jj,iku))
                ze3wv  = (gdept_0(ji,jj+1,ikv) - gdepw_0(ji,jj+1,ikv)) - (gdept_0(ji,jj,ikv) - gdepw_0(ji,jj,ikv))
-
+               !
                IF( ze3wu >= 0._wp ) THEN   ;   zhi(ji,jj) = fsdept(ji+1,jj,iku) - ze3wu     ! i-direction: case 1
                ELSE                        ;   zhi(ji,jj) = fsdept(ji  ,jj,iku) + ze3wu    ! -     -      case 2
@@ -343,12 +343,9 @@
             END DO
          END DO
-         
-         ! Compute interpolated rd from zti, ztj for the 2 cases at the depth of the partial
-         ! step and store it in  zri, zrj for each  case
-         CALL eos( zti, zhi, zri )  
-         CALL eos( ztj, zhj, zrj )
-
-         ! Gradient of density at the last level 
-         DO jj = 1, jpjm1
+         !
+         CALL eos( zti, zhi, zri )        ! interpolated density from zti, ztj 
+         CALL eos( ztj, zhj, zrj )        ! at the partial step depth output in  zri, zrj 
+
+         DO jj = 1, jpjm1                 ! Gradient of density at the last level 
             DO ji = 1, jpim1
                iku = mbku(ji,jj) ; ikum1 = MAX( iku - 1 , 1 )    ! last and before last ocean level at u- & v-points
@@ -394,5 +391,7 @@
          !
       END IF
-         ! (ISH)  compute grui and gruvi
+      !
+      !     !==  (ISH)  compute grui and gruvi  ==!
+      !
       DO jn = 1, kjpt      !==   Interpolation of tracers at the last ocean level   ==!            !
          DO jj = 1, jpjm1
@@ -442,12 +441,12 @@
       END DO
 
-      ! horizontal derivative of density anomalies (rd)
-      IF( PRESENT( prd ) ) THEN         ! depth of the partial step level
+      IF( PRESENT( prd ) ) THEN    !==  horizontal derivative of density anomalies (rd)  ==!    (optional part)
+         !
          pgrui(:,:)  =0.0_wp ; pgrvi(:,:)  =0.0_wp ;
          pgzui(:,:)  =0.0_wp ; pgzvi(:,:)  =0.0_wp ;
          pmrui(:,:)  =0.0_wp ; pmrui(:,:)  =0.0_wp ;
          pge3rui(:,:)=0.0_wp ; pge3rvi(:,:)=0.0_wp ;
-
-         DO jj = 1, jpjm1
+         !
+         DO jj = 1, jpjm1        ! depth of the partial step level
             DO ji = 1, jpim1
                iku = miku(ji,jj)
@@ -455,5 +454,5 @@
                ze3wu  = (gdepw_0(ji+1,jj,iku+1) - gdept_0(ji+1,jj,iku)) - (gdepw_0(ji,jj,iku+1) - gdept_0(ji,jj,iku))
                ze3wv  = (gdepw_0(ji,jj+1,ikv+1) - gdept_0(ji,jj+1,ikv)) - (gdepw_0(ji,jj,ikv+1) - gdept_0(ji,jj,ikv))
-
+               !
                IF( ze3wu >= 0._wp ) THEN   ;   zhi(ji,jj) = fsdept(ji+1,jj,iku) + ze3wu    ! i-direction: case 1
                ELSE                        ;   zhi(ji,jj) = fsdept(ji  ,jj,iku) - ze3wu    ! -     -      case 2
@@ -464,12 +463,9 @@
             END DO
          END DO
-
-         ! Compute interpolated rd from zti, ztj for the 2 cases at the depth of the partial
-         ! step and store it in  zri, zrj for each  case
-         CALL eos( zti, zhi, zri )  
-         CALL eos( ztj, zhj, zrj )
-
-         ! Gradient of density at the last level 
-         DO jj = 1, jpjm1
+         !
+         CALL eos( zti, zhi, zri )        ! interpolated density from zti, ztj 
+         CALL eos( ztj, zhj, zrj )        ! at the partial step depth output in  zri, zrj 
+         !
+         DO jj = 1, jpjm1                 ! Gradient of density at the last level 
             DO ji = 1, jpim1
                iku = miku(ji,jj) ; ikup1 = miku(ji,jj) + 1
@@ -482,6 +478,6 @@
                  pmrui  (ji,jj) = umask(ji,jj,iku)   * ( zri(ji,jj) + prd(ji,jj,iku) )          ! i: 1 
                  pge3rui(ji,jj) = umask(ji,jj,iku+1)                                                                  &
-                                * ( (fse3w(ji+1,jj,iku+1) - ze3wu) * (zri(ji,jj    ) + prd(ji+1,jj,iku+1) + 2._wp)   &
-                                   - fse3w(ji  ,jj,iku+1)          * (prd(ji,jj,iku) + prd(ji  ,jj,iku+1) + 2._wp)   ) ! i: 1
+                    &           * ( (fse3w(ji+1,jj,iku+1) - ze3wu) * (zri(ji,jj    ) + prd(ji+1,jj,iku+1) + 2._wp)   &
+                    &              - fse3w(ji  ,jj,iku+1)          * (prd(ji,jj,iku) + prd(ji  ,jj,iku+1) + 2._wp)   ) ! i: 1
                ELSE
                  pgzui  (ji,jj) = fsde3w(ji+1,jj,iku) - (fsde3w(ji,jj,iku) - ze3wu)
@@ -489,6 +485,6 @@
                  pmrui  (ji,jj) = umask(ji,jj,iku)   * ( prd(ji+1,jj,iku) + zri(ji,jj) )      ! i: 2
                  pge3rui(ji,jj) = umask(ji,jj,iku+1)                                                                   &
-                                * (  fse3w(ji+1,jj,iku+1)          * (prd(ji+1,jj,iku) + prd(ji+1,jj,iku+1) + 2._wp)  &
-                                   -(fse3w(ji  ,jj,iku+1) + ze3wu) * (zri(ji,jj      ) + prd(ji  ,jj,iku+1) + 2._wp)  )     ! i: 2
+                    &           * (  fse3w(ji+1,jj,iku+1)          * (prd(ji+1,jj,iku) + prd(ji+1,jj,iku+1) + 2._wp)  &
+                    &              -(fse3w(ji  ,jj,iku+1) + ze3wu) * (zri(ji,jj      ) + prd(ji  ,jj,iku+1) + 2._wp)  )     ! i: 2
                ENDIF
                IF( ze3wv >= 0._wp ) THEN
@@ -497,6 +493,6 @@
                  pmrvi  (ji,jj) = vmask(ji,jj,ikv)   * ( zrj(ji,jj  ) + prd(ji,jj,ikv) )        ! j: 1
                  pge3rvi(ji,jj) = vmask(ji,jj,ikv+1)                                                                  & 
-                                * ( (fse3w(ji,jj+1,ikv+1) - ze3wv) * ( zrj(ji,jj    ) + prd(ji,jj+1,ikv+1) + 2._wp)  &
-                                   - fse3w(ji,jj  ,ikv+1)          * ( prd(ji,jj,ikv) + prd(ji,jj  ,ikv+1) + 2._wp)  ) ! j: 1
+                     &           * ( (fse3w(ji,jj+1,ikv+1) - ze3wv) * ( zrj(ji,jj    ) + prd(ji,jj+1,ikv+1) + 2._wp)  &
+                     &                - fse3w(ji,jj  ,ikv+1)          * ( prd(ji,jj,ikv) + prd(ji,jj  ,ikv+1) + 2._wp)  ) ! j: 1
                                   ! + 2 due to the formulation in density and not in anomalie in hpg sco
                ELSE
@@ -505,6 +501,6 @@
                  pmrvi  (ji,jj) = vmask(ji,jj,ikv)   * ( prd(ji,jj+1,ikv) + zrj(ji,jj) )     ! j: 2
                  pge3rvi(ji,jj) = vmask(ji,jj,ikv+1)                                                                   &
-                                * (  fse3w(ji,jj+1,ikv+1)          * ( prd(ji,jj+1,ikv) + prd(ji,jj+1,ikv+1) + 2._wp) &
-                                   -(fse3w(ji,jj  ,ikv+1) + ze3wv) * ( zrj(ji,jj      ) + prd(ji,jj  ,ikv+1) + 2._wp) )  ! j: 2
+                    &           * (  fse3w(ji,jj+1,ikv+1)          * ( prd(ji,jj+1,ikv) + prd(ji,jj+1,ikv+1) + 2._wp) &
+                    &              -(fse3w(ji,jj  ,ikv+1) + ze3wv) * ( zrj(ji,jj      ) + prd(ji,jj  ,ikv+1) + 2._wp) )  ! j: 2
                ENDIF
             END DO
@@ -517,5 +513,5 @@
       END IF  
       !
-      IF( nn_timing == 1 )  CALL timing_stop( 'zps_hde_isf')
+      IF( nn_timing == 1 )   CALL timing_stop( 'zps_hde_isf')
       !
    END SUBROUTINE zps_hde_isf
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trd_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trd_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trd_oce.F90	(revision 6041)
@@ -71,6 +71,4 @@
    INTEGER, PUBLIC, PARAMETER ::   jpdyn_bfri = 12     !: implicit bottom friction (ln_bfrimp=.TRUE.)
    INTEGER, PUBLIC, PARAMETER ::   jpdyn_ken  = 13     !: use for calculation of KE
-   INTEGER, PUBLIC, PARAMETER ::   jpdyn_spgflt  = 14  !: filter contribution to surface pressure gradient (spg_flt)
-   INTEGER, PUBLIC, PARAMETER ::   jpdyn_spgexp  = 15  !: explicit contribution to surface pressure gradient (spg_flt)
    !
    !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trddyn.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trddyn.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trddyn.F90	(revision 6041)
@@ -113,8 +113,4 @@
       CASE( jpdyn_spg )   ;   CALL iom_put( "utrd_spg", putrd )    ! surface pressure gradient
                               CALL iom_put( "vtrd_spg", pvtrd )
-      CASE( jpdyn_spgexp );   CALL iom_put( "utrd_spgexp", putrd ) ! surface pressure gradient (explicit)
-                              CALL iom_put( "vtrd_spgexp", pvtrd )
-      CASE( jpdyn_spgflt );   CALL iom_put( "utrd_spgflt", putrd ) ! surface pressure gradient (filtered)
-                              CALL iom_put( "vtrd_spgflt", pvtrd )
       CASE( jpdyn_pvo )   ;   CALL iom_put( "utrd_pvo", putrd )    ! planetary vorticity
                               CALL iom_put( "vtrd_pvo", pvtrd )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdglo.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdglo.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdglo.F90	(revision 6041)
@@ -4,6 +4,6 @@
    !! Ocean diagnostics:  global domain averaged tracer and momentum trends
    !!=====================================================================
-   !! History :  1.0  !  2004-08 (C. Talandier) New trends organization
-   !!            3.5  !  2012-02 (G. Madec)  add 3D tracer zdf trend output using iom
+   !! History :  1.0  !  2004-08  (C. Talandier) New trends organization
+   !!            3.5  !  2012-02  (G. Madec)  add 3D tracer zdf trend output using iom
    !!----------------------------------------------------------------------
 
@@ -19,6 +19,6 @@
    USE trd_oce         ! trends: ocean variables
    USE phycst          ! physical constants
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldfdyn_oce      ! ocean dynamics: lateral physics
+   USE ldftra          ! lateral diffusion: eddy diffusivity & EIV coeff.
+   USE ldfdyn          ! ocean dynamics: lateral physics
    USE zdf_oce         ! ocean vertical physics
    USE zdfbfr          ! bottom friction
@@ -26,4 +26,5 @@
    USE eosbn2          ! equation of state
    USE phycst          ! physical constants
+   !
    USE lib_mpp         ! distibuted memory computing library
    USE in_out_manager  ! I/O manager
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdken.F90	(revision 6041)
@@ -13,14 +13,15 @@
    USE oce            ! ocean dynamics and tracers variables
    USE dom_oce        ! ocean space and time domain variables
+   USE sbc_oce        ! surface boundary condition: ocean
    USE zdf_oce        ! ocean vertical physics variables
    USE trd_oce        ! trends: ocean variables
 !!gm   USE dynhpg          ! hydrostatic pressure gradient   
    USE zdfbfr         ! bottom friction
-   USE ldftra_oce     ! ocean active tracers lateral physics
-   USE sbc_oce        ! surface boundary condition: ocean
+   USE ldftra         ! ocean active tracers lateral physics
    USE phycst         ! physical constants
    USE trdvor         ! ocean vorticity trends 
    USE trdglo         ! trends:global domain averaged
-   USE trdmxl         ! ocean active mixed layer tracers trends 
+   USE trdmxl         ! ocean active mixed layer tracers trends
+   !
    USE in_out_manager ! I/O manager
    USE iom            ! I/O manager library
@@ -96,6 +97,6 @@
          nkstp = kt
          DO jk = 1, jpkm1
-            bu   (:,:,jk) =  e1u(:,:) * e2u(:,:) * fse3u_n(:,:,jk)
-            bv   (:,:,jk) =  e1v(:,:) * e2v(:,:) * fse3v_n(:,:,jk)
+            bu   (:,:,jk) =           e1e2u(:,:) * fse3u_n(:,:,jk)
+            bv   (:,:,jk) =           e1e2v(:,:) * fse3v_n(:,:,jk)
             r1_bt(:,:,jk) = 1._wp / ( e1e2t(:,:) * fse3t_n(:,:,jk) ) * tmask(:,:,jk)
          END DO
@@ -119,6 +120,4 @@
          CASE( jpdyn_hpg )   ;   CALL iom_put( "ketrd_hpg", zke )    ! hydrostatic pressure gradient
          CASE( jpdyn_spg )   ;   CALL iom_put( "ketrd_spg", zke )    ! surface pressure gradient
-         CASE( jpdyn_spgexp );   CALL iom_put( "ketrd_spgexp", zke ) ! surface pressure gradient (explicit)
-         CASE( jpdyn_spgflt );   CALL iom_put( "ketrd_spgflt", zke ) ! surface pressure gradient (filter)
          CASE( jpdyn_pvo )   ;   CALL iom_put( "ketrd_pvo", zke )    ! planetary vorticity
          CASE( jpdyn_rvo )   ;   CALL iom_put( "ketrd_rvo", zke )    ! relative  vorticity     (or metric term)
@@ -263,13 +262,13 @@
       ENDIF
       !                           ! allocate box volume arrays
-      IF ( trd_ken_alloc() /= 0 )   CALL ctl_stop('trd_ken_alloc: failed to allocate arrays')
+      IF( trd_ken_alloc() /= 0 )   CALL ctl_stop('trd_ken_alloc: failed to allocate arrays')
       !
 !!gm      IF( .NOT. (ln_hpg_zco.OR.ln_hpg_zps) )   &
 !!gm         &   CALL ctl_stop('trd_ken_init : only full and partial cells are coded for conversion rate')
       !
-      IF ( .NOT.lk_vvl ) THEN     ! constant volume: bu, bv, 1/bt computed one for all
+      IF( .NOT.lk_vvl ) THEN      ! constant volume: bu, bv, 1/bt computed one for all
          DO jk = 1, jpkm1
-            bu   (:,:,jk) =  e1u(:,:) * e2u(:,:) * fse3u_n(:,:,jk)
-            bv   (:,:,jk) =  e1v(:,:) * e2v(:,:) * fse3v_n(:,:,jk)
+            bu   (:,:,jk) =           e1e2u(:,:) * fse3u_n(:,:,jk)
+            bv   (:,:,jk) =           e1e2v(:,:) * fse3v_n(:,:,jk)
             r1_bt(:,:,jk) = 1._wp / ( e1e2t(:,:) * fse3t_n(:,:,jk) )
          END DO
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdmxl.F90	(revision 6041)
@@ -22,7 +22,6 @@
    USE trd_oce         ! trends: ocean variables
    USE trdmxl_oce      ! ocean variables trends
-   USE ldftra_oce      ! ocean active tracers lateral physics
+   USE ldftra          ! lateral diffusion: eddy diffusivity & EIV coeff.
    USE zdf_oce         ! ocean vertical physics
-   USE in_out_manager  ! I/O manager
    USE phycst          ! Define parameters for the routines
    USE dianam          ! build the name of file (routine)
@@ -30,8 +29,10 @@
    USE zdfmxl          ! mixed layer depth
    USE zdfddm          ! ocean vertical physics: double diffusion
-   USE ioipsl          ! NetCDF library
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE diadimg         ! dimg direct access file format output
    USE trdmxl_rst      ! restart for diagnosing the ML trends
+   !
+   USE in_out_manager  ! I/O manager
+   USE ioipsl          ! NetCDF library
    USE prtctl          ! Print control
    USE restart         ! for lrst_oce
@@ -73,5 +74,4 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldftra_substitute.h90"
 #  include "zdfddm_substitute.h90"
    !!----------------------------------------------------------------------
@@ -801,7 +801,4 @@
       END IF
 
-      IF( nn_cla == 1 )   CALL ctl_warn( '      You set n_cla = 1. Note that the Mixed-Layer diagnostics  ',   &
-         &                               '      are not exact along the corresponding straits.            ')
-
       !                                   ! allocate trdmxl arrays
       IF( trd_mxl_alloc()    /= 0 )   CALL ctl_stop( 'STOP', 'trd_mxl_init : unable to allocate trdmxl     arrays' )
@@ -810,6 +807,5 @@
 
 
-
-       nkstp     = nit000 - 1              ! current time step indicator initialization
+      nkstp     = nit000 - 1              ! current time step indicator initialization
 
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdpen.F90	(revision 6041)
@@ -17,7 +17,8 @@
    USE trd_oce        ! trends: ocean variables
    USE eosbn2         ! equation of state and related derivatives
-   USE ldftra_oce     ! ocean active tracers lateral physics
+   USE ldftra         ! lateral diffusion: eddy diffusivity & EIV coeff.
    USE zdfddm         ! vertical physics: double diffusion
    USE phycst         ! physical constants
+   !
    USE in_out_manager ! I/O manager
    USE iom            ! I/O manager library
@@ -99,7 +100,7 @@
                                    CALL wrk_alloc( jpi, jpj, z2d )
                                    z2d(:,:) = wn(:,:,1) * ( &
-                                   &   - ( rab_n(:,:,1,jp_tem) + rab_pe(:,:,1,jp_tem) ) * tsn(:,:,1,jp_tem)    &
-                                   &   + ( rab_n(:,:,1,jp_sal) + rab_pe(:,:,1,jp_sal) ) * tsn(:,:,1,jp_sal)    &
-                                   &   ) / fse3t(:,:,1)
+                                     &   - ( rab_n(:,:,1,jp_tem) + rab_pe(:,:,1,jp_tem) ) * tsn(:,:,1,jp_tem)    &
+                                     &   + ( rab_n(:,:,1,jp_sal) + rab_pe(:,:,1,jp_sal) ) * tsn(:,:,1,jp_sal)    &
+                                     & ) / fse3t(:,:,1)
                                    CALL iom_put( "petrd_sad" , z2d )
                                    CALL wrk_dealloc( jpi, jpj, z2d )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdtra.F90	(revision 6041)
@@ -23,7 +23,9 @@
    USE trdpen         ! trends: Potential ENergy
    USE trdmxl         ! ocean active mixed layer tracers trends 
-   USE ldftra_oce     ! ocean active tracers lateral physics
+   USE ldftra         ! ocean active tracers lateral physics
+   USE ldfslp
    USE zdfddm         ! vertical physics: double diffusion
    USE phycst         ! physical constants
+   !
    USE in_out_manager ! I/O manager
    USE iom            ! I/O manager library
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdvor.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdvor.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/TRD/trdvor.F90	(revision 6041)
@@ -20,10 +20,11 @@
    USE sbc_oce         ! surface boundary condition: ocean
    USE phycst          ! Define parameters for the routines
-   USE ldfdyn_oce      ! ocean active tracers: lateral physics
+   USE ldfdyn          ! ocean active tracers: lateral physics
    USE dianam          ! build the name of file (routine)
    USE zdfmxl          ! mixed layer depth
-   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   !
    USE in_out_manager  ! I/O manager
    USE ioipsl          ! NetCDF library
+   USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp         ! MPP library
    USE wrk_nemo        ! Memory allocation
@@ -57,5 +58,4 @@
    !! * Substitutions
 #  include "domzgr_substitute.h90"
-#  include "ldfdyn_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdf_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdf_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdf_oce.F90	(revision 6041)
@@ -16,5 +16,5 @@
    PUBLIC  zdf_oce_alloc    ! Called in nemogcm.F90
 
-#if defined key_zdfcst   ||   defined key_esopa
+#if defined key_zdfcst
    LOGICAL, PARAMETER, PUBLIC ::   lk_zdfcst        = .TRUE.         !: constant vertical mixing flag
 #else
@@ -45,5 +45,5 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   avt_k , avm_k  ! not enhanced Kz
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   avmu_k, avmv_k ! not enhanced Kz
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   en             !: now turbulent kinetic energy   [m2/s2]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   en              !: now turbulent kinetic energy   [m2/s2]
 
    !!----------------------------------------------------------------------
@@ -62,8 +62,8 @@
          &     avtb(jpk) , bfrva(jpi,jpj) , avtb_2d(jpi,jpj) ,      &
          &     tfrua(jpi, jpj), tfrva(jpi, jpj)              ,      &
-         &     avmu  (jpi,jpj,jpk), avm   (jpi,jpj,jpk),            &
-         &     avmv  (jpi,jpj,jpk), avt   (jpi,jpj,jpk),            &
-         &     avt_k (jpi,jpj,jpk), avm_k (jpi,jpj,jpk),            & 
-         &     avmu_k(jpi,jpj,jpk), avmv_k(jpi,jpj,jpk),            & 
+         &     avmu  (jpi,jpj,jpk), avm   (jpi,jpj,jpk)      ,      &
+         &     avmv  (jpi,jpj,jpk), avt   (jpi,jpj,jpk)      ,      &
+         &     avt_k (jpi,jpj,jpk), avm_k (jpi,jpj,jpk)      ,      & 
+         &     avmu_k(jpi,jpj,jpk), avmv_k(jpi,jpj,jpk)      ,      &
          &     en    (jpi,jpj,jpk), STAT = zdf_oce_alloc )
          !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfddm.F90	(revision 6041)
@@ -9,5 +9,5 @@
    !!            3.6  ! 2013-04  (G. Madec, F. Roquet) zrau compute locally using interpolation of alpha & beta
    !!----------------------------------------------------------------------
-#if defined key_zdfddm   ||   defined key_esopa
+#if defined key_zdfddm
    !!----------------------------------------------------------------------
    !!   'key_zdfddm' :                                     double diffusion
@@ -162,7 +162,5 @@
          ! ------------------
          ! Constant eddy coefficient: reset to the background value
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                zinr = 1._wp / zrau(ji,jj)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfevd.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfevd.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfevd.F90	(revision 6041)
@@ -7,19 +7,19 @@
    !! History :  OPA  !  1997-06  (G. Madec, A. Lazar)  Original code
    !!   NEMO     1.0  !  2002-06  (G. Madec)  F90: Free form and module
-   !!             -   !  2005-06  (C. Ethe) KPP parameterization
    !!            3.2  !  2009-03  (M. Leclair, G. Madec, R. Benshila) test on both before & after
    !!----------------------------------------------------------------------
 
    !!----------------------------------------------------------------------
-   !!   zdf_evd      : increase the momentum and tracer Kz at the location of
-   !!                  statically unstable portion of the water column (ln_zdfevd=T)
+   !!   zdf_evd       : increase the momentum and tracer Kz at the location of
+   !!                   statically unstable portion of the water column (ln_zdfevd=T)
    !!----------------------------------------------------------------------
    USE oce             ! ocean dynamics and tracers variables
    USE dom_oce         ! ocean space and time domain variables
    USE zdf_oce         ! ocean vertical physics variables
-   USE zdfkpp          ! KPP vertical mixing
+   !
    USE in_out_manager  ! I/O manager
    USE iom             ! for iom_put
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
+   USE wrk_nemo        ! work arrays
    USE timing          ! Timing
 
@@ -53,9 +53,8 @@
       !! References :   Lazar, A., these de l'universite Paris VI, France, 1997
       !!----------------------------------------------------------------------
-      USE oce,   zavt_evd => ua , zavm_evd => va  ! (ua,va) used ua workspace
-      !
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step indexocean time step
       !
       INTEGER ::   ji, jj, jk   ! dummy loop indices
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zavt_evd, zavm_evd
       !!----------------------------------------------------------------------
       !
@@ -68,7 +67,9 @@
          IF(lwp) WRITE(numout,*)
       ENDIF
-
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zavt_evd, zavm_evd ) 
+      !
       zavt_evd(:,:,:) = avt(:,:,:)           ! set avt prior to evd application
-
+      !
       SELECT CASE ( nn_evdm )
       !
@@ -80,10 +81,5 @@
             DO jj = 2, jpj             ! no vector opt.
                DO ji = 2, jpi
-#if defined key_zdfkpp
-                  ! no evd mixing in the boundary layer with KPP
-                  IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12  .AND.  fsdepw(ji,jj,jk) > hkpp(ji,jj)  ) THEN
-#else
                   IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 ) THEN
-#endif
                      avt (ji  ,jj  ,jk) = rn_avevd * tmask(ji  ,jj  ,jk)
                      avm (ji  ,jj  ,jk) = rn_avevd * tmask(ji  ,jj  ,jk)
@@ -107,10 +103,5 @@
             DO jj = 1, jpj             ! loop over the whole domain (no lbc_lnk call)
                DO ji = 1, jpi
-#if defined key_zdfkpp
-                  ! no evd mixing in the boundary layer with KPP
-                  IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12  .AND.  fsdepw(ji,jj,jk) > hkpp(ji,jj)  )   &          
-#else
                   IF(  MIN( rn2(ji,jj,jk), rn2b(ji,jj,jk) ) <= -1.e-12 )   &
-#endif
                      avt(ji,jj,jk) = rn_avevd * tmask(ji,jj,jk)
                END DO
@@ -123,4 +114,6 @@
       CALL iom_put( "avt_evd", zavt_evd )              ! output this change
       !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zavt_evd, zavm_evd ) 
+      !
       IF( nn_timing == 1 )  CALL timing_stop('zdf_evd')
       !
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfgls.F90	(revision 6041)
@@ -8,5 +8,5 @@
    !!             3.3  !  2010-10  (C. Bricaud)  Add in the reference
    !!----------------------------------------------------------------------
-#if defined key_zdfgls   ||   defined key_esopa
+#if defined key_zdfgls
    !!----------------------------------------------------------------------
    !!   'key_zdfgls'                 Generic Length Scale vertical physics
@@ -116,5 +116,5 @@
       !!----------------------------------------------------------------------
       ALLOCATE( mxln(jpi,jpj,jpk), zwall(jpi,jpj,jpk) ,     &
-         &      ustars2(jpi,jpj), ustarb2(jpi,jpj)                      , STAT= zdf_gls_alloc )
+         &      ustars2(jpi,jpj) , ustarb2(jpi,jpj)   , STAT= zdf_gls_alloc )
          !
       IF( lk_mpp             )   CALL mpp_sum ( zdf_gls_alloc )
@@ -154,6 +154,6 @@
       IF( nn_timing == 1 )  CALL timing_start('zdf_gls')
       !
-      CALL wrk_alloc( jpi,jpj, zdep, zkar, zflxs, zhsro )
-      CALL wrk_alloc( jpi,jpj,jpk, eb, mxlb, shear, eps, zwall_psi, z_elem_a, z_elem_b, z_elem_c, psi  )
+      CALL wrk_alloc( jpi,jpj,       zdep, zkar, zflxs, zhsro )
+      CALL wrk_alloc( jpi,jpj,jpk,   eb, mxlb, shear, eps, zwall_psi, z_elem_a, z_elem_b, z_elem_c, psi  )
       
       ! Preliminary computing
@@ -169,7 +169,5 @@
 
       ! Compute surface and bottom friction at T-points
-!CDIR NOVERRCHK          
       DO jj = 2, jpjm1          
-!CDIR NOVERRCHK         
          DO ji = fs_2, fs_jpim1   ! vector opt.         
             !
@@ -360,7 +358,5 @@
          !                      ! en(ibot) = u*^2 / Co2 and mxln(ibot) = rn_lmin
          !                      ! Balance between the production and the dissipation terms
-!CDIR NOVERRCHK
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ibot   = mbkt(ji,jj) + 1      ! k   bottom level of w-point
@@ -383,7 +379,5 @@
       CASE ( 1 )             ! Neumman boundary condition
          !                      
-!CDIR NOVERRCHK
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ibot   = mbkt(ji,jj) + 1      ! k   bottom level of w-point
@@ -588,7 +582,5 @@
          !                      ! en(ibot) = u*^2 / Co2 and mxln(ibot) = vkarmn * rn_bfrz0
          !                      ! Balance between the production and the dissipation terms
-!CDIR NOVERRCHK
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ibot   = mbkt(ji,jj) + 1      ! k   bottom level of w-point
@@ -611,7 +603,5 @@
       CASE ( 1 )             ! Neumman boundary condition
          !                      
-!CDIR NOVERRCHK
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                ibot   = mbkt(ji,jj) + 1      ! k   bottom level of w-point
@@ -834,6 +824,6 @@
       avmv_k(:,:,:) = avmv(:,:,:)
       !
-      CALL wrk_dealloc( jpi,jpj, zdep, zkar, zflxs, zhsro )
-      CALL wrk_dealloc( jpi,jpj,jpk, eb, mxlb, shear, eps, zwall_psi, z_elem_a, z_elem_b, z_elem_c, psi )
+      CALL wrk_dealloc( jpi,jpj,       zdep, zkar, zflxs, zhsro )
+      CALL wrk_dealloc( jpi,jpj,jpk,   eb, mxlb, shear, eps, zwall_psi, z_elem_a, z_elem_b, z_elem_c, psi )
       !
       IF( nn_timing == 1 )  CALL timing_stop('zdf_gls')
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfini.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfini.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfini.F90	(revision 6041)
@@ -6,6 +6,7 @@
    !! History :  8.0  ! 1997-06  (G. Madec)  Original code from inimix
    !!            1.0  ! 2002-08  (G. Madec)  F90 : free form
-   !!             -   ! 2005-06  (C. Ethe) KPP parameterization
+   !!             -   ! 2005-06  (C. Ethe) KPP scheme
    !!             -   ! 2009-07  (G. Madec) add avmb, avtb in restart for cen2 advection
+   !!            3.7  ! 2014-12  (G. Madec) remove KPP scheme
    !!----------------------------------------------------------------------
 
@@ -14,19 +15,17 @@
    !!----------------------------------------------------------------------
    USE par_oce         ! mesh and scale factors
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldfdyn_oce      ! ocean dynamics lateral physics
    USE zdf_oce         ! TKE vertical mixing          
-   USE lib_mpp         ! distribued memory computing
+   USE sbc_oce         ! surface module (only for nn_isf in the option compatibility test)
    USE zdftke          ! TKE vertical mixing
    USE zdfgls          ! GLS vertical mixing
-   USE zdfkpp          ! KPP vertical mixing          
+   USE zdfric          ! Richardson vertical mixing   
    USE zdfddm          ! double diffusion mixing      
    USE zdfevd          ! enhanced vertical diffusion  
-   USE zdfric          ! Richardson vertical mixing   
    USE tranpc          ! convection: non penetrative adjustment
    USE ldfslp          ! iso-neutral slopes
-
+   !
    USE in_out_manager  ! I/O manager
    USE iom             ! IOM library
+   USE lib_mpp         ! distribued memory computing
 
    IMPLICIT NONE
@@ -50,6 +49,5 @@
       !! ** Method  :   Read namelist namzdf, control logicals 
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio       ! temporary scalar
-      INTEGER ::   ios
+      INTEGER ::   ioptio, ios       ! local integers
       !!
       NAMELIST/namzdf/ rn_avm0, rn_avt0, nn_avb, nn_havtb, ln_zdfexp, nn_zdfexp,   &
@@ -111,11 +109,7 @@
          ioptio = ioptio+1
       ENDIF
-      IF( lk_zdfkpp ) THEN
-         IF(lwp) WRITE(numout,*) '      KPP dependent eddy coefficients'
-         ioptio = ioptio+1
-      ENDIF
-      IF( ioptio == 0 .OR. ioptio > 1 .AND. .NOT. lk_esopa )   &
+      IF( ioptio == 0 .OR. ioptio > 1 )   &
          &   CALL ctl_stop( ' one and only one vertical diffusion option has to be defined ' )
-      IF( ( lk_zdfric .OR. lk_zdfgls .OR. lk_zdfkpp ) .AND. ln_isfcav )   &
+      IF( ( lk_zdfric .OR. lk_zdfgls ) .AND. ln_isfcav )   &
          &   CALL ctl_stop( ' only zdfcst and zdftke were tested with ice shelves cavities ' )
       !
@@ -143,14 +137,7 @@
          IF(lwp) WRITE(numout,*) '      use the GLS closure scheme'
       ENDIF
-      IF( lk_zdfkpp ) THEN
-         IF(lwp) WRITE(numout,*) '      use the KPP closure scheme'
-         IF(lk_mpp) THEN
-            IF(lwp) WRITE(numout,cform_err)
-            IF(lwp) WRITE(numout,*) 'The KPP scheme is not ready to run in MPI'
-         ENDIF
-      ENDIF
-      IF ( ioptio > 1 .AND. .NOT. lk_esopa )   CALL ctl_stop( ' chose between ln_zdfnpc and ln_zdfevd' )
-      IF( ioptio == 0 .AND. .NOT.( lk_zdftke .OR. lk_zdfgls .OR. lk_zdfkpp ) )           &
-         CALL ctl_stop( ' except for TKE, GLS or KPP physics, a convection scheme is',   &
+      IF ( ioptio > 1 )   CALL ctl_stop( ' chose between ln_zdfnpc and ln_zdfevd' )
+      IF( ioptio == 0 .AND. .NOT.( lk_zdftke .OR. lk_zdfgls ) )           &
+         CALL ctl_stop( ' except for TKE or GLS physics, a convection scheme is',   &
          &              ' required: ln_zdfevd or ln_zdfnpc logicals' )
 
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfkpp.F90	(revision 6040)
+++ 	(revision )
@@ -1,1592 +1,0 @@
-MODULE zdfkpp
-   !!======================================================================
-   !!                       ***  MODULE  zdfkpp  ***
-   !! Ocean physics:  vertical mixing coefficient compute from the KPP 
-   !!                 turbulent closure parameterization
-   !!=====================================================================
-   !! History :  OPA  ! 2000-03 (W.G. Large, J. Chanut) Original code
-   !!            8.1  ! 2002-06 (J.M. Molines) for real case CLIPPER  
-   !!            8.2  ! 2003-10 (Chanut J.) re-writting
-   !!   NEMO     1.0  ! 2005-01 (C. Ethe, G. Madec) Free form, F90 + creation of tra_kpp routine
-   !!            3.3  ! 2010-10 (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA
-   !!----------------------------------------------------------------------
-#if defined key_zdfkpp   ||   defined key_esopa
-   !!----------------------------------------------------------------------
-   !!   'key_zdfkpp'                                             KPP scheme
-   !!----------------------------------------------------------------------
-   !!   zdf_kpp       : update momentum and tracer Kz from a kpp scheme
-   !!   zdf_kpp_init  : initialization, namelist read, and parameters control
-   !!   tra_kpp       : compute and add to the T & S trend the non-local flux
-   !!   trc_kpp       : compute and add to the passive tracer trend the non-local flux (lk_top=T)
-   !!----------------------------------------------------------------------
-   USE oce            ! ocean dynamics and active tracers 
-   USE dom_oce        ! ocean space and time domain
-   USE zdf_oce        ! ocean vertical physics
-   USE sbc_oce        ! surface boundary condition: ocean
-   USE phycst         ! physical constants
-   USE eosbn2         ! equation of state
-   USE zdfddm         ! double diffusion mixing (avs array)
-   USE lib_mpp        ! MPP library
-   USE trd_oce        ! ocean trends definition
-   USE trdtra         ! tracers trends
-   !
-   USE in_out_manager ! I/O manager
-   USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
-   USE prtctl         ! Print control
-   USE wrk_nemo       ! work arrays
-   USE timing         ! Timing
-   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   zdf_kpp       ! routine called by step.F90
-   PUBLIC   zdf_kpp_init  ! routine called by opa.F90
-   PUBLIC   tra_kpp       ! routine called by step.F90
-   PUBLIC   trc_kpp       ! routine called by trcstp.F90
-
-   LOGICAL , PUBLIC, PARAMETER ::   lk_zdfkpp = .TRUE.    !: KPP vertical mixing flag
-
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ghats    !: non-local scalar mixing term (gamma/<ws>o)
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   wt0      !: surface temperature flux for non local flux
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ws0      !: surface salinity flux for non local flux
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   hkpp     !: boundary layer depth
-
-   !                          !!* Namelist namzdf_kpp *
-   REAL(wp) ::   rn_difmiw     ! constant internal wave viscosity (m2/s)
-   REAL(wp) ::   rn_difsiw     ! constant internal wave diffusivity (m2/s)
-   REAL(wp) ::   rn_riinfty    ! local Richardson Number limit for shear instability
-   REAL(wp) ::   rn_difri      ! maximum shear mixing at Rig = 0    (m2/s)
-   REAL(wp) ::   rn_bvsqcon    ! Brunt-Vaisala squared (1/s**2) for maximum convection
-   REAL(wp) ::   rn_difcon     ! maximum mixing in interior convection (m2/s)
-   INTEGER  ::   nn_ave        ! = 0/1 flag for horizontal average on avt, avmu, avmv
-
-#if defined key_zdfddm
-   !                                        !!! ** Double diffusion Mixing
-   REAL(wp) ::   difssf  = 1.e-03_wp         ! maximum salt fingering mixing 
-   REAL(wp) ::   Rrho0   = 1.9_wp            ! limit for salt  fingering mixing 
-   REAL(wp) ::   difsdc  = 1.5e-06_wp        ! maximum diffusive convection mixing
-#endif
-   LOGICAL  ::   ln_kpprimix       ! Shear instability mixing 
-
-   !                                        !!! ** General constants  **
-   REAL(wp) ::   epsln   = 1.0e-20_wp        ! a small positive number    
-   REAL(wp) ::   pthird  = 1._wp/3._wp       ! 1/3
-   REAL(wp) ::   pfourth = 1._wp/4._wp       ! 1/4
-
-   !                                        !!! ** Boundary Layer Turbulence Parameters  **
-   REAL(wp) ::   vonk     = 0.4_wp           ! von Karman's constant
-   REAL(wp) ::   epsilon  = 0.1_wp           ! nondimensional extent of the surface layer
-   REAL(wp) ::   rconc1   = 5.0_wp           ! standard flux profile function parmaeters
-   REAL(wp) ::   rconc2   = 16.0_wp          !         "        "
-   REAL(wp) ::   rconcm   = 8.38_wp          ! momentum flux profile fit
-   REAL(wp) ::   rconam   = 1.26_wp          !         "       "
-   REAL(wp) ::   rzetam   = -.20_wp          !         "       "       
-   REAL(wp) ::   rconcs   = 98.96_wp         !  scalar  flux profile fit
-   REAL(wp) ::   rconas   = -28.86_wp        !         "       "
-   REAL(wp) ::   rzetas   = -1.0_wp          !         "       "  
-   
-   !                                        !!! ** Boundary Layer Depth Diagnostic  **
-   REAL(wp) ::   Ricr     = 0.3_wp           ! critical bulk Richardson Number
-   REAL(wp) ::   rcekman  = 0.7_wp           ! coefficient for ekman depth  
-   REAL(wp) ::   rcmonob  = 1.0_wp           ! coefficient for Monin-Obukhov depth 
-   REAL(wp) ::   rconcv   = 1.7_wp           ! ratio of interior buoyancy frequency to its value at entrainment depth
-   REAL(wp) ::   hbf      = 1.0_wp           ! fraction of bound. layer depth to which absorbed solar 
-      !                                      ! rad. and contributes to surf. buo. forcing
-   REAL(wp) ::   Vtc                         ! function of rconcv,rconcs,epsilon,vonk,Ricr
-   
-   !                                        !!! ** Nonlocal Boundary Layer Mixing **
-   REAL(wp) ::   rcstar   = 5.0_wp           ! coefficient for convective nonlocal transport
-   REAL(wp) ::   rcs      = 1.0e-3_wp        ! conversion: mm/s ==> m/s   
-   REAL(wp) ::   rcg                         ! non-dimensional coefficient for nonlocal transport
-
-#if ! defined key_kppcustom
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:) ::   del     ! array for reference mean values of vertical integration 
-#endif
-
-#if defined key_kpplktb
-   !                                         !!! ** Parameters for lookup table for turbulent velocity scales ** 
-   INTEGER, PARAMETER ::   nilktb   = 892     ! number of values for zehat in KPP lookup table
-   INTEGER, PARAMETER ::   njlktb   = 482     ! number of values for ustar in KPP lookup table
-   INTEGER, PARAMETER ::   nilktbm1 = nilktb-1   !
-   INTEGER, PARAMETER ::   njlktbm1 = njlktb-1   !
-
-   REAL(wp), DIMENSION(nilktb,njlktb) ::   wmlktb   ! lookup table for the turbulent vertical velocity scale (momentum)
-   REAL(wp), DIMENSION(nilktb,njlktb) ::   wslktb   ! lookup table for the turbulent vertical velocity scale (tracers)
-
-   REAL(wp) ::   dehatmin = -4.e-7_wp    ! minimum limit for zhat in lookup table (m3/s3) 
-   REAL(wp) ::   dehatmax = 0._wp        ! maximum limit for zhat in lookup table (m3/s3)
-   REAL(wp) ::   ustmin   = 0._wp        ! minimum limit for ustar in lookup table (m/s)
-   REAL(wp) ::   ustmax   = 0.04_wp      ! maximum limit for ustar in lookup table (m/s)    
-   REAL(wp) ::   dezehat                 ! delta zhat in lookup table
-   REAL(wp) ::   deustar                 ! delta ustar in lookup table
-#endif
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   ratt   ! attenuation coef  (already defines in module traqsr, 
-   !                                    ! but only if the solar radiation penetration is considered)
-   
-   !                                    !!! * penetrative solar radiation coefficient *
-   REAL(wp) ::   rabs = 0.58_wp          ! fraction associated with xsi1
-   REAL(wp) ::   xsi1 = 0.35_wp          ! first depth of extinction 
-   REAL(wp) ::   xsi2 = 23.0_wp          ! second depth of extinction 
-      !                           ! (default values: water type Ib) 
-
-   REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   etmean, eumean, evmean   ! coeff. used for hor. smoothing at t-, u- & v-points
-        
-#if defined key_c1d
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   rig    !: gradient Richardson number
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   rib    !: bulk Richardson number
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   buof   !: buoyancy forcing
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   mols   !: moning-Obukhov length scale 
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)   ::   ekdp   !: Ekman depth
-#endif
-
-   INTEGER  ::   jip = 62 , jjp = 111
-
-   !! * Substitutions
-#  include "domzgr_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-#  include  "zdfddm_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
-   !! $Id$
-   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-CONTAINS
-
-   INTEGER FUNCTION zdf_kpp_alloc()
-      !!----------------------------------------------------------------------
-      !!                 ***  FUNCTION zdf_kpp_alloc  ***
-      !!----------------------------------------------------------------------
-      ALLOCATE( ghats(jpi,jpj,jpk), wt0(jpi,jpj), ws0(jpi,jpj), hkpp(jpi,jpj), &
-#if ! defined key_kpplktb
-         &      del(jpk,jpk),                                                  &
-#endif
-         &      ratt(jpk),                                                     &
-         &      etmean(jpi,jpj,jpk), eumean(jpi,jpj,jpk), evmean(jpi,jpj,jpk), &
-#if defined key_c1d
-         &      rig (jpi,jpj,jpk), rib(jpi,jpj,jpk), buof(jpi,jpj,jpk),        &
-         &      mols(jpi,jpj,jpk), ekdp(jpi,jpj),                              &
-#endif
-         &      STAT= zdf_kpp_alloc )
-         !
-      IF( lk_mpp             )   CALL mpp_sum ( zdf_kpp_alloc )
-      IF( zdf_kpp_alloc /= 0 )   CALL ctl_warn('zdf_kpp_alloc: failed to allocate arrays')
-   END FUNCTION zdf_kpp_alloc
-
-
-   SUBROUTINE zdf_kpp( kt )
-      !!----------------------------------------------------------------------
-      !!                   ***  ROUTINE zdf_kpp  ***
-      !!
-      !! ** Purpose :   Compute the vertical eddy viscosity and diffusivity
-      !!      coefficients and non local mixing using K-profile parameterization
-      !!
-      !! ** Method :   The boundary layer depth hkpp is diagnosed at tracer points
-      !!      from profiles of buoyancy, and shear, and the surface forcing.
-      !!      Above hbl (sigma=-z/hbl <1) the mixing coefficients are computed from 
-      !!
-      !!                      Kx =  hkpp  Wx(sigma) G(sigma)  
-      !!
-      !!             and the non local term ghat = Cs / Ws(sigma) / hkpp
-      !!      Below hkpp  the coefficients are the sum of mixing due to internal waves
-      !!      shear instability and double diffusion.
-      !!
-      !!      -1- Compute the now interior vertical mixing coefficients at all depths. 
-      !!      -2- Diagnose the boundary layer depth. 
-      !!      -3- Compute the now boundary layer vertical mixing coefficients. 
-      !!      -4- Compute the now vertical eddy vicosity and diffusivity.
-      !!      -5- Smoothing
-      !!
-      !!        N.B. The computation is done from jk=2 to jpkm1 
-      !!             Surface value of avt avmu avmv are set once a time to zero
-      !!             in routine zdf_kpp_init.
-      !!
-      !! ** Action  :   update the non-local terms ghats
-      !!                update avt, avmu, avmv (before vertical eddy coef.)
-      !!
-      !! References : Large W.G., Mc Williams J.C. and Doney S.C.              
-      !!         Reviews of Geophysics, 32, 4, November 1994
-      !!         Comments in the code refer to this paper, particularly 
-      !!         the equation number. (LMD94, here after)
-      !!----------------------------------------------------------------------
-      USE oce     , zviscos => ua   ! temp. array for viscosities use ua as workspace
-      USE oce     , zdiffut => va   ! temp. array for diffusivities use sa as workspace
-      !!
-      INTEGER, INTENT( in  ) ::   kt   ! ocean time step
-      !!
-      INTEGER ::   ji, jj, jk              ! dummy loop indices
-      INTEGER ::   ikbot, jkmax, jkm1, jkp2   !
-
-      REAL(wp) ::   ztx, zty, zflageos, zstabl, zbuofdep,zucube     !
-      REAL(wp) ::   zrhos, zalbet, zbeta, zthermal, zhalin, zatt1   !
-      REAL(wp) ::   zref, zt, zs, zh, zu, zv, zrh                   ! Bulk richardson number
-      REAL(wp) ::   zrib, zrinum, zdVsq, zVtsq                      !
-      REAL(wp) ::   zehat, zeta, zhrib, zsig, zscale, zwst, zws, zwm   ! Velocity scales
-#if defined key_kpplktb
-      INTEGER ::    il, jl                                          ! Lookup table or Analytical functions 
-      REAL(wp) ::   ud, zfrac, ufrac, zwam, zwbm, zwas, zwbs        !
-#else
-      REAL(wp) ::   zwsun, zwmun, zcons, zconm, zwcons, zwconm      !
-#endif
-      REAL(wp) ::   zsr, zbw, ze, zb, zd, zc, zaw, za, zb1, za1, zkw, zk0, zcomp , zrhd,zrhdr,zbvzed   ! In situ density
-#if ! defined key_kppcustom     
-      INTEGER  ::   jm                          ! dummy loop indices
-      REAL(wp) ::   zr1, zr2, zr3, zr4, zrhop   ! Compression terms
-#endif
-      REAL(wp) ::   zflag, ztemp, zrn2, zdep21, zdep32, zdep43
-      REAL(wp) ::   zdku2, zdkv2, ze3sqr, zsh2, zri, zfri          ! Interior richardson mixing
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zmoek                 ! Moning-Obukov limitation
-      REAL(wp), POINTER, DIMENSION(:)   ::   zmoa, zekman                
-      REAL(wp)                          ::   zmob, zek
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zdepw, zdift, zvisc   ! The pipe 
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zdept
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zriblk
-      REAL(wp), POINTER, DIMENSION(:)   ::   zhmax, zria, zhbl 
-      REAL(wp) ::   zflagri, zflagek, zflagmo, zflagh, zflagkb   !
-      REAL(wp), POINTER, DIMENSION(:)   ::   za2m, za3m, zkmpm, za2t, za3t, zkmpt   ! Shape function (G)
-      REAL(wp) ::   zdelta, zdelta2, zdzup, zdzdn, zdzh, zvath, zgat1, zdat1, zkm1m, zkm1t
-#if defined key_zdfddm
-      REAL(wp) ::   zrw, zkm1s                    ! local scalars
-      REAL(wp) ::   zrrau, zdt, zds, zavdds, zavddt, zinr   ! double diffusion mixing
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   zdifs
-      REAL(wp), POINTER, DIMENSION(:)     ::   za2s, za3s, zkmps
-      REAL(wp), POINTER, DIMENSION(:,:)   ::   zblcs
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zdiffus
-#endif
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zBo, zBosol, zustar         ! Surface buoyancy forcing, friction velocity
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zmask, zblcm, zblct
-      !!--------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('zdf_kpp')
-      !
-      CALL wrk_alloc( jpi, zmoa, zekman, zhmax, zria, zhbl )
-      CALL wrk_alloc( jpi, za2m, za3m, zkmpm, za2t, za3t, zkmpt )
-      CALL wrk_alloc( jpi,2, zriblk )
-      CALL wrk_alloc( jpi,3, zmoek, kjstart = 0 )
-      CALL wrk_alloc( jpi,3, zdept )
-      CALL wrk_alloc( jpi,4, zdepw, zdift, zvisc )
-      CALL wrk_alloc( jpi,jpj, zBo, zBosol, zustar )
-      CALL wrk_alloc( jpi,jpk, zmask, zblcm, zblct )
-#if defined key_zdfddm
-      CALL wrk_alloc( jpi,4, zdifs )
-      CALL wrk_alloc( jpi, zmoa, za2s, za3s, zkmps )
-      CALL wrk_alloc( jpi,jpk, zblcs )
-      CALL wrk_alloc( jpi,jpi,jpk, zdiffus )
-#endif
-
-      zviscos(:,:,:) = 0._wp
-      zblcm  (:,:  ) = 0._wp
-      zdiffut(:,:,:) = 0._wp
-      zblct  (:,:  ) = 0._wp 
-#if defined key_zdfddm
-      zdiffus(:,:,:) = 0._wp
-      zblcs  (:,:  ) = 0._wp 
-#endif
-      ghats  (:,:,:) = 0._wp
-      zBo    (:,:  ) = 0._wp
-      zBosol (:,:  ) = 0._wp
-      zustar (:,:  ) = 0._wp
-      !
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! I. Interior diffusivity and viscosity at w points ( T interfaces)
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
-      DO jk = 2, jpkm1
-         DO jj = 2, jpjm1
-            DO ji = fs_2, fs_jpim1 
-               ! Mixing due to internal waves breaking
-               ! -------------------------------------
-               avmu(ji,jj,jk)  = rn_difmiw 
-               avt (ji,jj,jk)  = rn_difsiw             
-               ! Mixing due to vertical shear instability
-               ! -------------------------------------               
-               IF( ln_kpprimix ) THEN          
-                  ! Compute the gradient Richardson  number at interfaces (zri):
-                  ! LMD94, eq. 27 (is vertical smoothing needed : Rig=N^2 / (dz(u))^2 + (dz(v))^2
-                  zdku2 =   ( un(ji - 1,jj,jk - 1) - un(ji - 1,jj,jk) ) &
-                     &    * ( un(ji - 1,jj,jk - 1) - un(ji - 1,jj,jk) ) &
-                     &    + ( un(ji    ,jj,jk - 1) - un(ji    ,jj,jk) ) &
-                     &    * ( un(ji    ,jj,jk - 1) - un(ji    ,jj,jk) )  
-                  
-                  zdkv2 =   ( vn(ji,jj - 1,jk - 1) - vn(ji,jj - 1,jk) ) &
-                     &    * ( vn(ji,jj - 1,jk - 1) - vn(ji,jj - 1,jk) ) &
-                     &    + ( vn(ji,    jj,jk - 1) - vn(ji,    jj,jk) ) &
-                     &    * ( vn(ji,    jj,jk - 1) - vn(ji,    jj,jk) )  
-
-                  ze3sqr = 1. / ( fse3w(ji,jj,jk) * fse3w(ji,jj,jk) )
-                  ! Square of vertical shear  at interfaces
-                  zsh2   = 0.5 * ( zdku2 + zdkv2 ) * ze3sqr
-                  zri    = MAX( rn2(ji,jj,jk), 0. ) / ( zsh2 + epsln ) 
-#if defined key_c1d
-                  ! save the gradient richardson number
-                  rig(ji,jj,jk) = zri * tmask(ji,jj,jk)
-#endif                  
-                  ! Evaluate f of Ri (zri) for shear instability store in zfri
-                  ! LMD94, eq. 28a,b,c, figure 3 ; Rem: p1 is 3, hard coded
-                  zfri  = MAX( zri , 0. )
-                  zfri  = MIN( zfri / rn_riinfty , 1.0 )
-                  zfri  = ( 1.0 - zfri * zfri )
-                  zfri  = zfri * zfri  * zfri
-                  ! add shear contribution to mixing coef. 
-                  avmu(ji,jj,jk) =  avmu(ji,jj,jk) + rn_difri * zfri   
-                  avt (ji,jj,jk) =  avt (ji,jj,jk) + rn_difri * zfri    
-               ENDIF
-               !
-#if defined key_zdfddm 
-               !
-               !  Double diffusion mixing ; NOT IN ROUTINE ZDFDDM.F90
-               ! -------------------------
-               avs (ji,jj,jk) =  avt (ji,jj,jk)   
-
-               ! R=zrau = (alpha / beta) (dk[t] / dk[s])
-               zrw =   ( fsdepw(ji,jj,jk  ) - fsdept(ji,jj,jk) )   &
-                  &  / ( fsdept(ji,jj,jk-1) - fsdept(ji,jj,jk) ) 
-               !
-               zaw = (  rab_n(ji,jj,jk,jp_tem) * (1. - zrw) + rab_n(ji,jj,jk-1,jp_tem) * zrw  ) * tmask(ji,jj,jk)
-               zbw = (  rab_n(ji,jj,jk,jp_sal) * (1. - zrw) + rab_n(ji,jj,jk-1,jp_sal) * zrw  ) * tmask(ji,jj,jk)
-               !
-               zdt = zaw * ( tsn(ji,jj,jk-1,jp_tem) - tsn(ji,jj,jk,jp_tem) )
-               zds = zbw * ( tsn(ji,jj,jk-1,jp_sal) - tsn(ji,jj,jk,jp_sal) ) 
-               IF( ABS( zds) <= 1.e-20_wp )   zds = 1.e-20_wp
-               zrrau = MAX(  epsln , zdt / zds  )    ! only retains positive value of zrau
-               !
-               IF( zrrau > 1. .AND. zds > 0.) THEN                        ! Salt fingering case.
-                  !                                                       !---------------------
-                  ! Compute interior diffusivity for double diffusive mixing of salinity. 
-                  ! Upper bound "zrrau" by "Rrho0"; (Rrho0=1.9, difcoefnuf=0.001).
-                  ! After that set interior diffusivity for double diffusive mixing of temperature
-                  zavdds = MIN( zrrau, Rrho0 )
-                  zavdds = ( zavdds - 1.0 ) / ( Rrho0 - 1.0 )
-                  zavdds = 1.0 - zavdds * zavdds 
-                  zavdds = zavdds * zavdds * zavdds 
-                  zavdds = difssf * zavdds 
-                  zavddt = 0.7 * zavdds
-                  !
-               ELSEIF( zrrau < 1. .AND. zrrau > 0. .AND. zds < 0.) THEN   ! Diffusive convection case.
-                  !                                                       !---------------------------
-                  ! Compute interior diffusivity for double diffusive mixing of temperature (Marmorino and Caldwell, 1976); 
-                  ! Compute interior diffusivity for double diffusive mixing of salinity 
-                  zinr   = 1. / zrrau
-                  zavddt = 0.909 * EXP( 4.6 * EXP( -0.54* ( zinr - 1. ) ) ) 
-                  zavddt = difsdc * zavddt
-                  IF( zrrau < 0.5) THEN   ;   zavdds = zavddt * 0.15 * zrrau
-                  ELSE                    ;   zavdds = zavddt * (1.85 * zrrau - 0.85 ) 
-                  ENDIF
-               ELSE
-                  zavddt = 0.
-                  zavdds = 0.
-               ENDIF 
-               ! Add double diffusion contribution to temperature and salinity  mixing coefficients.
-               avt (ji,jj,jk) =  avt (ji,jj,jk) +  zavddt 
-               avs (ji,jj,jk) =  avs (ji,jj,jk) +  zavdds         
-#endif                      
-            END DO
-         END DO
-      END DO
-
-
-      ! Radiative (zBosol) and non radiative (zBo) surface buoyancy
-      !JMM at the time zdfkpp is called, q still holds the sum q + qsr
-      !---------------------------------------------------------------------
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1           
-            zrhos    = rau0 * ( 1._wp + rhd(ji,jj,1) ) * tmask(ji,jj,1)
-            zthermal = rab_n(ji,jj,1,jp_tem) / ( rcp * zrhos + epsln )
-            zbeta    = rab_n(ji,jj,1,jp_sal)
-            zhalin   = zbeta * tsn(ji,jj,1,jp_sal) * rcs
-            !
-            ! Radiative surface buoyancy force
-            zBosol(ji,jj) = grav * zthermal * qsr(ji,jj)
-            ! Non radiative surface buoyancy force
-            zBo   (ji,jj) = grav * zthermal * qns(ji,jj) -  grav * zhalin * ( emp(ji,jj)-rnf(ji,jj) )  &
-               &                                         -  grav * zbeta * rcs * sfx(ji,jj)
-            ! Surface Temperature flux for non-local term
-            wt0(ji,jj) = - ( qsr(ji,jj) + qns(ji,jj) )* r1_rau0_rcp * tmask(ji,jj,1)
-            ! Surface salinity flux for non-local term
-            ws0(ji,jj) = - ( ( emp(ji,jj)-rnf(ji,jj) ) * tsn(ji,jj,1,jp_sal)                          &
-               &             + sfx(ji,jj)                                     ) * rcs * tmask(ji,jj,1) 
-         END DO
-      END DO
-
-      zflageos = 0.5 + SIGN( 0.5, nn_eos - 1. ) 
-      !  Compute surface buoyancy forcing, Monin Obukhov and Ekman depths  
-      !------------------------------------------------------------------    
-      DO jj = 2, jpjm1
-         DO ji = fs_2, fs_jpim1
-            !  Reference surface density = density at first T point level   
-            zrhos         = rhop(ji,jj,1) + zflageos * rau0 * ( 1. - tmask(ji,jj,1) )  
-            ! Friction velocity (zustar), at T-point : LMD94 eq. 2
-            zustar(ji,jj) = SQRT( taum(ji,jj) / ( zrhos +  epsln ) )
-         END DO
-      END DO
-
-!CDIR NOVERRCHK  
-      !                                               ! ===============
-      DO jj = 2, jpjm1                                 !  Vertical slab
-         !                                             ! ===============
-         
-         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-         ! II Compute Boundary layer mixing coef. and diagnose the new boundary layer depth
-         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-         
-         ! Initialization
-         jkmax       = 0
-         zdept (:,:) = 0.
-         zdepw (:,:) = 0.
-         zriblk(:,:) = 0.
-         zmoek (:,:) = 0.
-         zvisc (:,:) = 0.
-         zdift (:,:) = 0.
-#if defined key_zdfddm
-         zdifs (:,:) = 0.
-#endif
-         zmask (:,:) = 0.
-         DO ji = fs_2, fs_jpim1
-            zria(ji ) = 0.
-            ! Maximum boundary layer depth
-            ikbot     = mbkt(ji,jj)    ! ikbot is the last T point in the water
-            zhmax(ji) = fsdept(ji,jj,ikbot) - 0.001      
-            ! Compute Monin obukhov length scale at the surface and Ekman depth:
-            zbuofdep   = zBo(ji,jj) + zBosol(ji,jj) * ratt(1)
-            zekman(ji) = rcekman * zustar(ji,jj) / ( ABS( ff(ji,jj) ) + epsln )
-            zucube     = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj) 
-            zmoa(ji)   = zucube / ( vonk * ( zbuofdep + epsln ) )   
-#if defined key_c1d
-            ! store the surface buoyancy forcing
-            zstabl        = 0.5 + SIGN( 0.5, zbuofdep )
-            buof(ji,jj,1) = zbuofdep * tmask(ji,jj,1)
-            ! store the moning-oboukov length scale at surface
-            zmob          = zstabl * zmoa(ji) + ( 1.0 - zstabl ) * fsdept(ji,jj,1)
-            mols(ji,jj,1) = MIN( zmob , zhmax(ji) ) * tmask(ji,jj,1)
-            ! store Ekman depth
-            zek           = zstabl * zekman(ji) + ( 1.0 - zstabl ) * fsdept(ji,jj,1)  
-            ekdp(ji,jj )  = MIN( zek , zhmax(ji) ) * tmask(ji,jj,1)  
-#endif 
-         END DO     
-         ! Compute the pipe
-         ! ---------------------
-         DO jk = 2, jpkm1
-            DO ji = fs_2, fs_jpim1
-               ! Compute bfsfc = Bo + radiative contribution down to hbf*depht
-               zbuofdep = zBo(ji,jj) + zBosol(ji,jj) * ratt(jk)
-               ! Flag (zstabl  = 1) if positive forcing
-               zstabl   =  0.5 + SIGN(  0.5, zbuofdep)
-
-               !   Compute bulk richardson number zrib at depht 
-               !-------------------------------------------------------
-               !                           [Br - B(d)] * d         zrinum
-               !             Rib(z) = ----------------------- = -------------
-               !                       |Vr - V(d)|^2 + Vt(d)^2   zdVsq + zVtsq
-               !
-               ! First compute zt,zs,zu,zv = means in the surface layer < epsilon*depht  
-               ! Else surface values are taken at the first T level.
-               ! For stability, resolved vertical shear is computed with "before velocities".
-               zref = epsilon * fsdept(ji,jj,jk)
-#if defined key_kppcustom
-               ! zref = gdept(1)
-               zref = fsdept(ji,jj,1)
-               zt   = tsn(ji,jj,1,jp_tem)
-               zs   = tsn(ji,jj,1,jp_sal)
-               zrh  = rhop(ji,jj,1)
-               zu   = ( ub(ji,jj,1) + ub(ji - 1,jj    ,1) ) / MAX( 1. , umask(ji,jj,1) + umask(ji - 1,jj   ,1) )
-               zv   = ( vb(ji,jj,1) + vb(ji    ,jj - 1,1) ) / MAX( 1. , vmask(ji,jj,1) + vmask(ji   ,jj - 1,1) )
-#else
-               zt   = 0.
-               zs   = 0.
-               zu   = 0.
-               zv   = 0.
-               zrh  = 0.
-               ! vertically integration over the upper epsilon*gdept(jk) ; del () array is computed once in zdf_kpp_init
-               DO jm = 1, jpkm1
-                  zt   = zt  + del(jk,jm) * tsn(ji,jj,jm,jp_tem)
-                  zs   = zs  + del(jk,jm) * tsn(ji,jj,jm,jp_sal)
-                  zu   = zu  + 0.5 * del(jk,jm) &
-                     &            * ( ub(ji,jj,jm) + ub(ji - 1,jj,jm) ) &
-                     &            / MAX( 1. , umask(ji,jj,jm) + umask(ji - 1,jj,jm) )
-                  zv   = zv  + 0.5 * del(jk,jm) &
-                     &            * ( vb(ji,jj,jm) + vb(ji,jj - 1,jm) ) &
-                     &            / MAX( 1. , vmask(ji,jj,jm) + vmask(ji,jj - 1,jm) )
-                  zrh  = zrh + del(jk,jm) * rhop(ji,jj,jm)
-               END DO
-#endif
-               zsr = SQRT( ABS( tsn(ji,jj,jk,jp_sal) ) )
-               ! depth
-               zh = fsdept(ji,jj,jk)
-               ! compute compression terms on density
-               ze  = ( -3.508914e-8*zt-1.248266e-8 ) *zt-2.595994e-6
-               zbw = (  1.296821e-6*zt-5.782165e-9 ) *zt+1.045941e-4
-               zb  = zbw + ze * zs
-               
-               zd  = -2.042967e-2
-               zc  =   (-7.267926e-5*zt+2.598241e-3 ) *zt+0.1571896
-               zaw = ( ( 5.939910e-6*zt+2.512549e-3 ) *zt-0.1028859 ) *zt - 4.721788
-               za  = ( zd*zsr + zc ) *zs + zaw
-               
-               zb1 =   (-0.1909078*zt+7.390729 ) *zt-55.87545
-               za1 = ( ( 2.326469e-3*zt+1.553190)*zt-65.00517 ) *zt+1044.077
-               zkw = ( ( (-1.361629e-4*zt-1.852732e-2 ) *zt-30.41638 ) *zt + 2098.925 ) *zt+190925.6
-               zk0 = ( zb1*zsr + za1 )*zs + zkw
-               zcomp =   1.0 - zh / ( zk0 - zh * ( za - zh * zb ) )
-               
-#if defined key_kppcustom
-               ! potential density of water(zrh = zt,zs at level jk):
-               zrhdr = zrh / zcomp
-#else
-               ! potential density of water(ztref,zsref at level jk):
-               ! compute volumic mass pure water at atm pressure
-               IF ( nn_eos < 1 ) THEN
-                  zr1= ( ( ( ( 6.536332e-9*zt-1.120083e-6 )*zt+1.001685e-4)*zt   &
-                     &       -9.095290e-3 )*zt+6.793952e-2 )*zt+999.842594
-                  ! seawater volumic mass atm pressure
-                  zr2= ( ( ( 5.3875e-9*zt-8.2467e-7 ) *zt+7.6438e-5 ) *zt   &
-                     &   -4.0899e-3 ) *zt+0.824493
-                  zr3= ( -1.6546e-6*zt+1.0227e-4 ) *zt-5.72466e-3
-                  zr4= 4.8314e-4              
-                  ! potential volumic mass (reference to the surface)
-                  zrhop= ( zr4*zs + zr3*zsr + zr2 ) *zs + zr1                 
-                  zrhdr = zrhop / zcomp
-               ELSE
-                  zrhdr = zrh / zcomp
-               ENDIF
-#endif
-               
-               ! potential density of ambiant water at level jk :
-               zrhd   = ( rhd(ji,jj,jk) * rau0 + rau0 )  
-               
-               ! And now the Rib number numerator .
-               zrinum = grav * ( zrhd - zrhdr ) / rau0
-               zrinum = zrinum * ( fsdept(ji,jj,jk) - zref ) * tmask(ji,jj,jk)
-           
-               ! Resolved shear contribution to Rib at depth T-point (zdVsq)
-               ztx    =   ( ub( ji , jj ,jk)   +  ub(ji - 1, jj ,jk) ) &
-                  &     / MAX( 1. , umask( ji , jj ,jk) + umask(ji - 1, jj ,jk) )   
-               zty    =   ( vb( ji , jj ,jk)   +  vb(ji  ,jj - 1,jk) ) &
-                  &     / MAX( 1., vmask( ji , jj ,jk) + vmask(ji  ,jj - 1,jk) ) 
-               
-               zdVsq  = ( zu - ztx ) * ( zu - ztx ) + ( zv - zty ) * ( zv - zty )
-               
-               ! Scalar turbulent velocity scale zws for hbl=gdept
-               zscale = zstabl + ( 1.0 - zstabl ) * epsilon
-               zehat  = vonk * zscale * fsdept(ji,jj,jk) * zbuofdep
-               zucube = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj)              
-               zeta   = zehat / ( zucube + epsln )
-               
-               IF( zehat > 0. ) THEN
-                  ! Stable case
-                  zws  = vonk * zustar(ji,jj) / ( 1.0 + rconc1 * zeta )
-               ELSE
-                  ! Unstable case
-#if defined key_kpplktb
-                  ! use lookup table
-                  zd     = zehat - dehatmin
-                  il     = INT( zd / dezehat )
-                  il     = MIN( il, nilktbm1 )
-                  il     = MAX( il, 1 )
-                  
-                  ud     = zustar(ji,jj) - ustmin
-                  jl     = INT( ud / deustar )
-                  jl     = MIN( jl, njlktbm1 )
-                  jl     = MAX( jl, 1 )
-                  
-                  zfrac  = zd / dezehat - FLOAT( il )  
-                  ufrac  = ud / deustar - FLOAT( jl )
-                  zwas   = ( 1. - zfrac ) * wslktb(il,jl+1) + zfrac * wslktb(il+1,jl+1)
-                  zwbs   = ( 1. - zfrac ) * wslktb(il,jl  ) + zfrac * wslktb(il+1,jl  )
-                  !
-                  zws    = ( 1. - ufrac ) * zwbs + ufrac * zwas
-#else
-                  ! use analytical functions:
-                  zcons  = 0.5 + SIGN( 0.5 , ( rzetas - zeta ) )
-                  zwcons = vonk * zustar(ji,jj) * ( ( ABS( rconas - rconcs * zeta ) )**pthird ) 
-                  zwsun  = vonk * zustar(ji,jj) * SQRT( ABS ( 1.0 - rconc2 * zeta ) )
-                  !
-                  zws    = zcons * zwcons +  ( 1.0 - zcons) * zwsun
-#endif
-               ENDIF
-               
-               ! Turbulent shear contribution to Rib (zVtsq) bv frequency at levels  ( ie T-point jk)
-               zrn2   = 0.5 * ( rn2(ji,jj,jk) + rn2(ji,jj,jk+1) )   
-               zbvzed = SQRT( ABS( zrn2 ) ) 
-               zVtsq  = fsdept(ji,jj,jk) * zws * zbvzed  * Vtc
-               
-               ! Finally, the bulk Richardson number at depth fsdept(i,j,k) 
-               zrib  = zrinum   / ( zdVsq + zVtsq + epsln )
- 
-               ! Find subscripts around the boundary layer depth, build the pipe
-               ! ----------------------------------------------------------------
-
-               ! Flag (zflagri = 1) if zrib < Ricr  
-               zflagri = 0.5 + SIGN( 0.5, ( Ricr - zrib ) )
-               !  Flag (zflagh  = 1) if still within overall boundary layer
-               zflagh  = 0.5 + SIGN( 0.5, ( fsdept(ji,jj,1) - zdept(ji,2) ) )
-               
-               ! Ekman layer depth
-               zek     = zstabl * zekman(ji) + ( 1.0 - zstabl ) * zhmax(ji)
-               zflag   = 0.5 + SIGN( 0.5, ( zek - fsdept(ji,jj,jk-1) ) )
-               zek     = zflag * zek + ( 1.0 - zflag ) * zhmax(ji)
-               zflagek = 0.5 + SIGN( 0.5, ( zek - fsdept(ji,jj,jk) ) )
-               ! Flag (zflagmo = 1) if still within stable Monin-Obukhov and in water
-               zmob    = zucube / ( vonk * ( zbuofdep + epsln ) )  
-               ztemp   = zstabl * zmob + ( 1.0 - zstabl) * zhmax(ji)
-               ztemp   = MIN( ztemp , zhmax(ji) ) 
-               zflagmo = 0.5 + SIGN( 0.5, ( ztemp - fsdept(ji,jj,jk) ) )             
-
-               ! No limitation by Monin Obukhov or Ekman depths:
-!               zflagek = 1.0
-!               zflagmo = 0.5 + SIGN( 0.5, ( zhmax(ji) - fsdept(ji,jj,jk) ) )
-
-               ! Load  pipe via zflagkb  for later calculations
-               ! Flag (zflagkb = 1) if zflagh = 1 and (zflagri = 0 or zflagek = 0 or zflagmo = 0)
-               zflagkb = zflagh * ( 1.0 - ( zflagri * zflagek * zflagmo ) )
-
-               zmask(ji,jk) = zflagh
-               jkp2         = MIN( jk+2 , ikbot )
-               jkm1         = MAX( jk-1 , 2 )
-               jkmax        = MAX( jkmax, jk * INT( REAL( zflagh+epsln ) ) ) 
-
-               zdept(ji,1)  = zdept(ji,1) + zflagkb * fsdept(ji,jj,jk-1) 
-               zdept(ji,2)  = zdept(ji,2) + zflagkb * fsdept(ji,jj,jk  ) 
-               zdept(ji,3)  = zdept(ji,3) + zflagkb * fsdept(ji,jj,jk+1) 
-
-               zdepw(ji,1)  = zdepw(ji,1) + zflagkb * fsdepw(ji,jj,jk-1) 
-               zdepw(ji,2)  = zdepw(ji,2) + zflagkb * fsdepw(ji,jj,jk  ) 
-               zdepw(ji,3)  = zdepw(ji,3) + zflagkb * fsdepw(ji,jj,jk+1)
-               zdepw(ji,4)  = zdepw(ji,4) + zflagkb * fsdepw(ji,jj,jkp2)  
-
-               zriblk(ji,1) = zriblk(ji,1) + zflagkb * zria(ji)
-               zriblk(ji,2) = zriblk(ji,2) + zflagkb * zrib
-
-               zmoek (ji,0) = zmoek (ji,0) + zflagkb * zek
-               zmoek (ji,1) = zmoek (ji,1) + zflagkb * zmoa(ji)
-               zmoek (ji,2) = zmoek (ji,2) + zflagkb * ztemp  
-               ! Save Monin Obukhov depth
-               zmoa  (ji)   = zmob
-           
-               zvisc(ji,1) = zvisc(ji,1) + zflagkb * avmu(ji,jj,jkm1)
-               zvisc(ji,2) = zvisc(ji,2) + zflagkb * avmu(ji,jj,jk  )
-               zvisc(ji,3) = zvisc(ji,3) + zflagkb * avmu(ji,jj,jk+1)
-               zvisc(ji,4) = zvisc(ji,4) + zflagkb * avmu(ji,jj,jkp2)
-               
-               zdift(ji,1) = zdift(ji,1) + zflagkb * avt (ji,jj,jkm1)
-               zdift(ji,2) = zdift(ji,2) + zflagkb * avt (ji,jj,jk  )
-               zdift(ji,3) = zdift(ji,3) + zflagkb * avt (ji,jj,jk+1)
-               zdift(ji,4) = zdift(ji,4) + zflagkb * avt (ji,jj,jkp2)
-
-#if defined key_zdfddm
-               zdifs(ji,1) = zdifs(ji,1) + zflagkb * avs (ji,jj,jkm1)
-               zdifs(ji,2) = zdifs(ji,2) + zflagkb * avs (ji,jj,jk  )
-               zdifs(ji,3) = zdifs(ji,3) + zflagkb * avs (ji,jj,jk+1)
-               zdifs(ji,4) = zdifs(ji,4) + zflagkb * avs (ji,jj,jkp2)
-#endif               
-               ! Save the Richardson number 
-               zria  (ji)   = zrib  
-#if defined key_c1d
-               ! store buoyancy length scale
-               buof(ji,jj,jk) = zbuofdep * tmask(ji,jj,jk) 
-               ! store Monin Obukhov
-               zmob           = zstabl * zmob + ( 1.0 - zstabl) * fsdept(ji,jj,1)
-               mols(ji,jj,jk) = MIN( zmob , zhmax(ji) ) * tmask(ji,jj,jk) 
-               ! Bulk Richardson number
-               rib(ji,jj,jk)  = zrib * tmask(ji,jj,jk)             
-#endif               
-            END DO
-         END DO
-         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-         ! III PROCESS THE PIPE
-         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-         
-         DO ji = fs_2, fs_jpim1 
-            
-            ! Find the boundary layer depth zhbl
-            ! ----------------------------------------
-            
-            ! Interpolate monin Obukhov and critical Ri mumber depths   
-            ztemp = zdept(ji,2) - zdept(ji,1)
-            zflag = ( Ricr - zriblk(ji,1) ) / ( zriblk(ji,2) - zriblk(ji,1)  + epsln )
-            zhrib = zdept(ji,1) + zflag * ztemp      
-
-            IF( zriblk(ji,2) < Ricr ) zhrib = zhmax(ji) 
-         
-            IF( zmoek(ji,2) < zdept(ji,2) ) THEN
-               IF ( zmoek(ji,1) < 0. ) THEN
-                  zmob = zdept(ji,2) - epsln
-               ELSE
-                  zmob = ztemp + zmoek(ji,1) - zmoek(ji,2)
-                  zmob = ( zmoek(ji,1) * zdept(ji,2) - zmoek(ji,2) * zdept(ji,1) ) / zmob
-                  zmob = MAX( zmob , zdept(ji,1) + epsln )                
-               ENDIF
-            ELSE           
-               zmob = zhmax(ji) 
-            ENDIF
-            ztemp   = MIN( zmob , zmoek(ji,0) )
-                         
-            ! Finally, the boundary layer depth, zhbl 
-            zhbl(ji) = MAX( fsdept(ji,jj,1) + epsln, MIN( zhrib , ztemp ) )
-            
-            ! Save hkpp for further diagnostics (optional)
-            hkpp(ji,jj) = zhbl(ji) * tmask(ji,jj,1) 
-          
-            ! Correct mask if zhbl < fsdepw(ji,jj,2) for no viscosity/diffusivity enhancement at fsdepw(ji,jj,2)
-            !     zflag = 1 if zhbl(ji) > fsdepw(ji,jj,2)
-            IF( zhbl(ji) < fsdepw(ji,jj,2) ) zmask(ji,2) = 0.
-          
-            
-            !  Velocity scales at depth zhbl
-            ! -----------------------------------
-            
-            !  Compute bouyancy forcing down to zhbl
-            ztemp    = -hbf * zhbl(ji)
-            zatt1    = 1.0 - ( rabs * EXP( ztemp / xsi1 ) + ( 1.0 - rabs ) * EXP( ztemp / xsi2 ) )
-            zbuofdep = zBo(ji,jj) + zBosol(ji,jj) * zatt1
-            zstabl   = 0.5 + SIGN( 0.5 , zbuofdep ) 
-
-            zbuofdep = zbuofdep + zstabl * epsln
-
-            zscale = zstabl + ( 1.0 - zstabl ) * epsilon          
-            zehat  = vonk * zscale * zhbl(ji) * zbuofdep
-            zucube = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj)              
-            zeta   = zehat / ( zucube + epsln )
-            
-            IF( zehat > 0. ) THEN
-               ! Stable case
-               zws  = vonk * zustar(ji,jj) / ( 1.0 + rconc1 * zeta )
-               zwm  = zws
-            ELSE
-               ! Unstable case
-#if defined key_kpplktb
-               ! use lookup table
-               zd     = zehat - dehatmin
-               il     = INT( zd / dezehat )
-               il     = MIN( il, nilktbm1 )
-               il     = MAX( il, 1 )
-               
-               ud     = zustar(ji,jj) - ustmin
-               jl     = INT( ud / deustar )
-               jl     = MIN( jl, njlktbm1 )
-               jl     = MAX( jl, 1 )
-               
-               zfrac  = zd / dezehat - FLOAT( il )  
-               ufrac  = ud / deustar - FLOAT( jl )
-               zwas   = ( 1. - zfrac ) * wslktb(il,jl+1) + zfrac * wslktb(il+1,jl+1)
-               zwbs   = ( 1. - zfrac ) * wslktb(il,jl  ) + zfrac * wslktb(il+1,jl  )
-               zwam   = ( 1. - zfrac ) * wmlktb(il,jl+1) + zfrac * wmlktb(il+1,jl+1)
-               zwbm   = ( 1. - zfrac ) * wmlktb(il,jl  ) + zfrac * wmlktb(il+1,jl  )
-               !
-               zws    = ( 1. - ufrac ) * zwbs + ufrac * zwas
-               zwm    = ( 1. - ufrac ) * zwbm + ufrac * zwam
-#else
-               ! use analytical functions
-               zconm  = 0.5 + SIGN( 0.5, ( rzetam - zeta) )
-               zcons  = 0.5 + SIGN( 0.5, ( rzetas - zeta) )
-               
-               ! Momentum : zeta < rzetam (zconm = 1)
-               ! Scalars  : zeta < rzetas (zcons = 1) 
-               zwconm = zustar(ji,jj) * vonk * ( ( ABS( rconam - rconcm * zeta) )**pthird )
-               zwcons = zustar(ji,jj) * vonk * ( ( ABS( rconas - rconcs * zeta) )**pthird )
-               
-               ! Momentum : rzetam <= zeta < 0 (zconm = 0)
-               ! Scalars  : rzetas <= zeta < 0 (zcons = 0)	
-               zwmun  = SQRT( ABS( 1.0 - rconc2 * zeta ) )
-               zwsun  = vonk * zustar(ji,jj) * zwmun
-               zwmun  = vonk * zustar(ji,jj) * SQRT(zwmun)
-               !
-               zwm    = zconm * zwconm + ( 1.0 - zconm ) * zwmun
-               zws    = zcons * zwcons + ( 1.0 - zcons ) * zwsun
-               
-#endif
-            ENDIF
-            
-            
-            ! Viscosity, diffusivity values and derivatives at h
-            ! --------------------------------------------------------
-            
-            ! check between at which interfaces is located zhbl(ji)
-            ! ztemp = 1, zdepw(ji,2) < zhbl <  zdepw(ji,3)
-            ! ztemp = 0, zdepw(ji,1) < zhbl <  zdepw(ji,2)
-            ztemp  =  0.5 + SIGN( 0.5, ( zhbl(ji) - zdepw(ji,2) ) )  
-            zdep21 =   zdepw(ji,2) - zdepw(ji,1) + epsln
-            zdep32 =   zdepw(ji,3) - zdepw(ji,2) + epsln
-            zdep43 =   zdepw(ji,4) - zdepw(ji,3) + epsln  
-            
-            ! Compute R as in LMD94, eq D5b
-            zdelta =  ( zhbl(ji) - zdepw(ji,2) ) *         ztemp   / zdep32   &
-               &    + ( zhbl(ji) - zdepw(ji,1) ) * ( 1.0 - ztemp ) / zdep21 
-            
-            ! Compute the vertical derivative of viscosities (zdzh) at z=zhbl(ji)
-            zdzup  =  ( zvisc(ji,2) - zvisc(ji,3) ) *         ztemp   / zdep32 &
-               &    + ( zvisc(ji,1) - zvisc(ji,2) ) * ( 1.0 - ztemp ) / zdep21
-            
-            zdzdn  =  ( zvisc(ji,3) - zvisc(ji,4) ) *         ztemp   / zdep43 &
-               &    + ( zvisc(ji,2) - zvisc(ji,3) ) * ( 1.0 - ztemp ) / zdep32
-            
-            ! LMD94, eq D5b :          
-            zdzh   = ( 1.0 - zdelta ) * zdzup + zdelta * zdzdn
-            zdzh   = MAX( zdzh , 0. )
-            
-            ! Compute viscosities (zvath) at z=zhbl(ji), LMD94 eq D5a
-            zvath  =          ztemp   * ( zvisc(ji,3) + zdzh * ( zdepw(ji,3) - zhbl(ji) ) ) &
-               &    + ( 1.0 - ztemp ) * ( zvisc(ji,2) + zdzh * ( zdepw(ji,2) - zhbl(ji) ) )
-            
-            ! Compute G (zgat1) and its derivative (zdat1) at z=hbl(ji), LMD94 eq 18
-            
-            ! Vertical derivative of velocity scale divided by velocity scale squared at z=hbl(ji) 
-            ! (non zero only in stable conditions)
-            zflag  =  -zstabl * rconc1 * zbuofdep / ( zucube * zustar(ji,jj) + epsln )
-            
-            ! G at its derivative at z=hbl:
-            zgat1  = zvath  / ( zhbl(ji) * ( zwm + epsln )  )
-            zdat1  = -zdzh  / ( zwm + epsln ) -  zflag * zvath / zhbl(ji)
-            
-            ! G coefficients, LMD94 eq 17
-            za2m(ji) = -2.0 + 3.0 * zgat1 - zdat1
-            za3m(ji) =  1.0 - 2.0 * zgat1 + zdat1
-
-            
-            ! Compute the vertical derivative of temperature diffusivities (zdzh) at z=zhbl(ji)
-            zdzup  =  ( zdift(ji,2) - zdift(ji,3) ) *         ztemp   / zdep32 &
-               &    + ( zdift(ji,1) - zdift(ji,2) ) * ( 1.0 - ztemp ) / zdep21
-            
-            zdzdn  =  ( zdift(ji,3) - zdift(ji,4) ) *         ztemp   / zdep43 &
-               &    + ( zdift(ji,2) - zdift(ji,3) ) * ( 1.0 - ztemp ) / zdep32
-            
-            ! LMD94, eq D5b :          
-            zdzh   = ( 1.0 - zdelta ) * zdzup + zdelta * zdzdn
-            zdzh   = MAX( zdzh , 0. )
-            
-            
-            ! Compute diffusivities (zvath) at z=zhbl(ji), LMD94 eq D5a
-            zvath  =          ztemp   * ( zdift(ji,3) + zdzh * ( zdepw(ji,3) - zhbl(ji) ) ) &
-               &    + ( 1.0 - ztemp ) * ( zdift(ji,2) + zdzh * ( zdepw(ji,2) - zhbl(ji) ) )
-                        
-            ! G at its derivative at z=hbl:
-            zgat1  = zvath  / ( zhbl(ji) * ( zws + epsln )  )
-            zdat1  = -zdzh  / ( zws + epsln ) -  zflag * zvath / zhbl(ji)
-            
-            ! G coefficients, LMD94 eq 17
-            za2t(ji) = -2.0 + 3.0 * zgat1 - zdat1
-            za3t(ji) =  1.0 - 2.0 * zgat1 + zdat1
-
-#if defined key_zdfddm
-            ! Compute the vertical derivative of salinities diffusivities (zdzh) at z=zhbl(ji)
-            zdzup  =  ( zdifs(ji,2) - zdifs(ji,3) ) *         ztemp   / zdep32 &
-               &    + ( zdifs(ji,1) - zdifs(ji,2) ) * ( 1.0 - ztemp ) / zdep21
-            
-            zdzdn  =  ( zdifs(ji,3) - zdifs(ji,4) ) *         ztemp   / zdep43 &
-               &    + ( zdifs(ji,2) - zdifs(ji,3) ) * ( 1.0 - ztemp ) / zdep32
-            
-            ! LMD94, eq D5b :          
-            zdzh   = ( 1.0 - zdelta ) * zdzup + zdelta * zdzdn
-            zdzh   = MAX( zdzh , 0. )           
-            
-            ! Compute diffusivities (zvath) at z=zhbl(ji), LMD94 eq D5a
-            zvath  =          ztemp   * ( zdifs(ji,3) + zdzh * ( zdepw(ji,3) - zhbl(ji) ) ) &
-               &    + ( 1.0 - ztemp ) * ( zdifs(ji,2) + zdzh * ( zdepw(ji,2) - zhbl(ji) ) )
-                        
-            ! G at its derivative at z=hbl:
-            zgat1  = zvath  / ( zhbl(ji) * ( zws + epsln )  )
-            zdat1  = -zdzh  / ( zws + epsln ) -  zflag * zvath / zhbl(ji)
-            
-            ! G coefficients, LMD94 eq 17
-            za2s(ji) = -2.0 + 3.0 * zgat1 - zdat1
-            za3s(ji) =  1.0 - 2.0 * zgat1 + zdat1
-#endif
-
-            !-------------------turn off interior matching here------
-            !          za2(ji,1) = -2.0
-            !          za3(ji,1) =  1.0
-            !          za2(ji,2) = -2.0
-            !          za3(ji,2) =  1.0
-            !--------------------------------------------------------
-            
-            !  Compute Enhanced Mixing Coefficients (LMD94,eq D6)
-            ! ---------------------------------------------------------------
-            
-            ! Delta 
-            zdelta  = ( zhbl(ji)  - zdept(ji,1) ) / ( zdept(ji,2) - zdept(ji,1) + epsln )
-            zdelta2 = zdelta * zdelta
-            
-            !  Mixing coefficients at first level above h (zdept(ji,1)) 
-            ! and at first interface in the pipe (zdepw(ji,2))
-            
-            ! At first T level above h (zdept(ji,1)) (always in the boundary layer)
-            zsig    = zdept(ji,1) / zhbl(ji)
-            ztemp   = zstabl * zsig  + ( 1.0 - zstabl ) * MIN( zsig , epsilon )
-            zehat   = vonk * ztemp * zhbl(ji) * zbuofdep
-            zeta    = zehat / ( zucube + epsln)
-            zwst    = vonk * zustar(ji,jj) / ( ABS( 1.0 + rconc1 * zeta ) + epsln)
-            zwm     = zstabl * zwst + ( 1.0 - zstabl ) * zwm
-            zws     = zstabl * zwst + ( 1.0 - zstabl ) * zws
-
-            zkm1m  = zhbl(ji) * zwm * zsig * ( 1.0 + zsig * ( za2m(ji) + zsig * za3m(ji) ) )
-            zkm1t  = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2t(ji) + zsig * za3t(ji) ) )
-#if defined key_zdfddm
-            zkm1s  = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2s(ji) + zsig * za3s(ji) ) )
-#endif                        
-            ! At first W level in the pipe (zdepw(ji,2)) (not always in the boundary layer ):
-            zsig    = MIN( zdepw(ji,2) / zhbl(ji) , 1.0 )
-            ztemp   = zstabl * zsig + ( 1.0 - zstabl ) * MIN( zsig , epsilon )
-            zehat   = vonk * ztemp * zhbl(ji) * zbuofdep
-            zeta    = zehat / ( zucube + epsln )
-            zwst    = vonk * zustar(ji,jj) / ( ABS( 1.0 + rconc1 * zeta ) + epsln)
-            zws     = zstabl * zws + ( 1.0 - zstabl ) * zws
-            zwm     = zstabl * zws + ( 1.0 - zstabl ) * zwm
-
-            zkmpm(ji) = zhbl(ji) * zwm * zsig * ( 1.0 + zsig * ( za2m(ji) + zsig * za3m(ji) ) )
-            zkmpt(ji) = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2t(ji) + zsig * za3t(ji) ) )
-#if defined key_zdfddm
-            zkmps(ji) = zhbl(ji) * zws * zsig * ( 1.0 + zsig * ( za2s(ji) + zsig * za3s(ji) ) )
-#endif  
-      
-            ! check if this point is in the boundary layer,else take interior viscosity/diffusivity:
-            zflag       = 0.5 + SIGN( 0.5, ( zhbl(ji) - zdepw(ji,2) ) )
-            zkmpm(ji) = zkmpm(ji) * zflag + ( 1.0 - zflag ) * zvisc(ji,2)
-            zkmpt(ji) = zkmpt(ji) * zflag + ( 1.0 - zflag ) * zdift(ji,2)
-#if defined key_zdfddm
-            zkmps(ji) = zkmps(ji) * zflag + ( 1.0 - zflag ) * zdifs(ji,2)
-#endif
-
-            ! Enhanced viscosity/diffusivity at zdepw(ji,2)
-            ztemp     = ( 1.0 - 2.0 * zdelta + zdelta2 ) * zkm1m + zdelta2 * zkmpm(ji)
-            zkmpm(ji) = ( 1.0 - zdelta ) * zvisc(ji,2) + zdelta * ztemp
-            ztemp     = ( 1.0 - 2.0 * zdelta + zdelta2 ) * zkm1t + zdelta2 * zkmpt(ji)
-            zkmpt(ji) = ( 1.0 - zdelta ) * zdift(ji,2) + zdelta * ztemp
-#if defined key_zdfddm
-            ztemp     = ( 1.0 - 2.0 * zdelta + zdelta2 ) * zkm1s + zdelta2 * zkmps(ji)
-            zkmps(ji) = ( 1.0 - zdelta ) * zdifs(ji,2) + zdelta * ztemp
-#endif            
-
-         END DO
-         !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-         ! IV. Compute vertical eddy viscosity and diffusivity coefficients
-         !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-         
-         DO jk  = 2, jkmax
-            
-            ! Compute turbulent velocity scales on the interfaces
-            ! --------------------------------------------------------
-            DO  ji = fs_2, fs_jpim1
-               zbuofdep = zBo(ji,jj) + zBosol(ji,jj) * zatt1
-               zstabl   = 0.5 + SIGN( 0.5 , zbuofdep ) 
-               zbuofdep = zbuofdep + zstabl * epsln          
-               zsig    = fsdepw(ji,jj,jk) / zhbl(ji)
-               ztemp   = zstabl * zsig + ( 1. - zstabl ) * MIN( zsig , epsilon )
-               zehat   = vonk * ztemp * zhbl(ji) * zbuofdep
-               zucube  = zustar(ji,jj) * zustar(ji,jj) * zustar(ji,jj)
-               zeta    = zehat / ( zucube + epsln )
-
-               IF( zehat > 0. ) THEN
-                  ! Stable case
-                  zws  = vonk * zustar(ji,jj) / ( 1.0 + rconc1 * zeta )
-                  zwm  = zws
-               ELSE
-                  ! Unstable case
-#if defined key_kpplktb
-                  ! use lookup table
-                  zd     = zehat - dehatmin
-                  il     = INT( zd / dezehat )
-                  il     = MIN( il, nilktbm1 )
-                  il     = MAX( il, 1 )
-                  
-                  ud     = zustar(ji,jj) - ustmin
-                  jl     = INT( ud / deustar )
-                  jl     = MIN( jl, njlktbm1 )
-                  jl     = MAX( jl, 1 )
-                  
-                  zfrac  = zd / dezehat - FLOAT( il )  
-                  ufrac  = ud / deustar - FLOAT( jl )
-                  zwas   = ( 1. - zfrac ) * wslktb(il,jl+1) + zfrac * wslktb(il+1,jl+1)
-                  zwbs   = ( 1. - zfrac ) * wslktb(il,jl  ) + zfrac * wslktb(il+1,jl  )
-                  zwam   = ( 1. - zfrac ) * wmlktb(il,jl+1) + zfrac * wmlktb(il+1,jl+1)
-                  zwbm   = ( 1. - zfrac ) * wmlktb(il,jl  ) + zfrac * wmlktb(il+1,jl  )
-                  !
-                  zws    = ( 1. - ufrac ) * zwbs + ufrac * zwas
-                  zwm    = ( 1. - ufrac ) * zwbm + ufrac * zwam
-#else
-                  ! use analytical functions
-                  zconm  = 0.5 + SIGN( 0.5, ( rzetam - zeta) )
-                  zcons  = 0.5 + SIGN( 0.5, ( rzetas - zeta) )
-                  
-                  ! Momentum : zeta < rzetam (zconm = 1)
-                  ! Scalars  : zeta < rzetas (zcons = 1) 
-                  zwconm = zustar(ji,jj) * vonk * ( ( ABS( rconam - rconcm * zeta) )**pthird )
-                  zwcons = zustar(ji,jj) * vonk * ( ( ABS( rconas - rconcs * zeta) )**pthird )
-                  
-                  ! Momentum : rzetam <= zeta < 0 (zconm = 0)
-                  ! Scalars  : rzetas <= zeta < 0 (zcons = 0)	
-                  zwmun  = SQRT( ABS( 1.0 - rconc2 * zeta ) )
-                  zwsun  = vonk * zustar(ji,jj) * zwmun
-                  zwmun  = vonk * zustar(ji,jj) * SQRT(zwmun)
-                  !
-                  zwm    = zconm * zwconm + ( 1.0 - zconm ) * zwmun
-                  zws    = zcons * zwcons + ( 1.0 - zcons ) * zwsun
-                  
-#endif
-               ENDIF
-               
-               zblcm(ji,jk) = zhbl(ji) * zwm * zsig  * ( 1.0 + zsig * ( za2m(ji) + zsig * za3m(ji) ) )
-               zblct(ji,jk) = zhbl(ji) * zws * zsig  * ( 1.0 + zsig * ( za2t(ji) + zsig * za3t(ji) ) )
-#if defined key_zdfddm
-               zblcs(ji,jk) = zhbl(ji) * zws * zsig  * ( 1.0 + zsig * ( za2s(ji) + zsig * za3s(ji) ) )
-#endif              
-               !  Compute Nonlocal transport term = ghats * <ws>o
-               ! ----------------------------------------------------
-               ghats(ji,jj,jk-1) = ( 1. - zstabl ) * rcg / ( zws * zhbl(ji) + epsln ) * tmask(ji,jj,jk)
-
-            END DO
-         END DO     
-         !  Combine interior and boundary layer coefficients and nonlocal term
-         ! -----------------------------------------------------------------------
-         DO jk = 2, jpkm1   
-            DO ji = fs_2, fs_jpim1
-               zflag = zmask(ji,jk) * zmask(ji,jk+1)
-               zviscos(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )         * avmu (ji,jj,jk) & ! interior viscosities
-                  &              +                        zflag   * zblcm(ji,jk    ) & ! boundary layer viscosities
-                  &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmpm(ji       )   ! viscosity enhancement at W_level near zhbl
-               
-               zviscos(ji,jj,jk) = zviscos(ji,jj,jk) * tmask(ji,jj,jk)   
-
-            
-               zdiffut(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )          * avt (ji,jj,jk) & ! interior diffusivities 
-                  &              +                        zflag   * zblct(ji,jk   ) & ! boundary layer diffusivities
-                  &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmpt(ji      )   ! diffusivity enhancement at W_level near zhbl
-                       
-               zdiffut(ji,jj,jk) = zdiffut(ji,jj,jk) * tmask(ji,jj,jk) 
-#if defined key_zdfddm
-               zdiffus(ji,jj,jk) = ( 1.0 - zmask(ji,jk) )         * avs (ji,jj,jk) & ! interior diffusivities 
-                  &              +                        zflag   * zblcs(ji,jk   ) & ! boundary layer diffusivities
-                  &              + zmask(ji,jk) * ( 1.0 - zflag ) * zkmps(ji      )   ! diffusivity enhancement at W_level near zhbl
-               zdiffus(ji,jj,jk) = zdiffus(ji,jj,jk) * tmask(ji,jj,jk) 
-#endif               
-               ! Non local flux in the boundary layer only
-               ghats(ji,jj,jk-1) = zmask(ji,jk) * ghats(ji,jj,jk-1)
-
-            ENDDO
-         END DO
-         !                                             ! ===============
-      END DO                                           !   End of slab
-      !                                                ! ===============
-
-      ! Lateral boundary conditions on zvicos and zdiffus  (sign unchanged)
-      CALL lbc_lnk( zviscos(:,:,:), 'U', 1. )  ; CALL lbc_lnk( zdiffut(:,:,:), 'W', 1. )  
-#if defined key_zdfddm  
-      CALL lbc_lnk( zdiffus(:,:,:), 'W', 1. ) 
-#endif
-
-      SELECT CASE ( nn_ave )
-         !
-         CASE ( 0 )             ! no viscosity and diffusivity smoothing
-
-            DO jk = 2, jpkm1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1
-                     avmu(ji,jj,jk) = ( zviscos(ji,jj,jk) + zviscos(ji+1,jj,jk) ) &
-                        &  / MAX( 1., tmask(ji,jj,jk) + tmask (ji + 1,jj,jk) ) * umask(ji,jj,jk)
-                     
-                     avmv(ji,jj,jk) = ( zviscos(ji,jj,jk) + zviscos(ji,jj+1,jk) ) &
-                        &  / MAX( 1., tmask(ji,jj,jk) + tmask (ji,jj+1,jk) ) * vmask(ji,jj,jk)
-                     
-                     avt (ji,jj,jk) =  zdiffut(ji,jj,jk) * tmask(ji,jj,jk)  
-#if defined key_zdfddm     
-                     avs (ji,jj,jk) =  zdiffus(ji,jj,jk) * tmask(ji,jj,jk)  
-#endif
-                  END DO
-               END DO
-            END DO
-            
-         CASE ( 1 )                ! viscosity and diffusivity smoothing
-            !                      
-            !           ( 1/2  1  1/2 )              ( 1/2  1/2 )             ( 1/2  1  1/2 )
-            ! avt = 1/8 ( 1    2  1   )   avmu = 1/4 ( 1    1   )   avmv= 1/4 ( 1/2  1  1/2 )
-            !           ( 1/2  1  1/2 )              ( 1/2  1/2 )
-  
-            DO jk = 2, jpkm1
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1
-
-                     avmu(ji,jj,jk) = (      zviscos(ji  ,jj  ,jk) + zviscos(ji+1,jj  ,jk)   &
-                        &              +.5*( zviscos(ji  ,jj-1,jk) + zviscos(ji+1,jj-1,jk)   &
-                        &                   +zviscos(ji  ,jj+1,jk) + zviscos(ji+1,jj+1,jk) ) ) * eumean(ji,jj,jk)
-                     
-                     avmv(ji,jj,jk) = (      zviscos(ji  ,jj  ,jk) + zviscos(ji  ,jj+1,jk)   &
-                        &              +.5*( zviscos(ji-1,jj  ,jk) + zviscos(ji-1,jj+1,jk)   &
-                        &                   +zviscos(ji+1,jj  ,jk) + zviscos(ji+1,jj+1,jk) ) ) * evmean(ji,jj,jk)
- 
-                     avt (ji,jj,jk) = ( .5*( zdiffut(ji-1,jj+1,jk) + zdiffut(ji-1,jj-1,jk)    &
-                        &                   +zdiffut(ji+1,jj+1,jk) + zdiffut(ji+1,jj-1,jk) )  &
-                        &              +1.*( zdiffut(ji-1,jj  ,jk) + zdiffut(ji  ,jj+1,jk)    &
-                        &                   +zdiffut(ji  ,jj-1,jk) + zdiffut(ji+1,jj  ,jk) )  &
-                        &              +2.*  zdiffut(ji  ,jj  ,jk)                          ) * etmean(ji,jj,jk)
-#if defined key_zdfddm   
-                     avs (ji,jj,jk) = ( .5*( zdiffus(ji-1,jj+1,jk) + zdiffus(ji-1,jj-1,jk)    &
-                        &                   +zdiffus(ji+1,jj+1,jk) + zdiffus(ji+1,jj-1,jk) )  &
-                        &              +1.*( zdiffus(ji-1,jj  ,jk) + zdiffus(ji  ,jj+1,jk)    &
-                        &                   +zdiffus(ji  ,jj-1,jk) + zdiffus(ji+1,jj  ,jk) )  &
-                        &              +2.*  zdiffus(ji  ,jj  ,jk)                          ) * etmean(ji,jj,jk)  
-#endif                
-                  END DO
-               END DO
-            END DO
-         
-         END SELECT
-
-         DO jk = 2, jpkm1                       ! vertical slab
-            !
-            !  Minimum value on the eddy diffusivity
-            ! ----------------------------------------
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  avt(ji,jj,jk) = MAX( avt(ji,jj,jk), avtb(jk) ) * tmask(ji,jj,jk)
-#if defined key_zdfddm  
-                  avs(ji,jj,jk) = MAX( avs(ji,jj,jk), avtb(jk) ) * tmask(ji,jj,jk)
-#endif
-               END DO
-            END DO
-
-            !
-            ! Minimum value on the eddy viscosity
-            ! ----------------------------------------
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  avmu(ji,jj,jk) = MAX( avmu(ji,jj,jk), avmb(jk) ) * umask(ji,jj,jk)
-                  avmv(ji,jj,jk) = MAX( avmv(ji,jj,jk), avmb(jk) ) * vmask(ji,jj,jk)
-               END DO
-            END DO
-            !
-         END DO
-
-         ! Lateral boundary conditions on avt  (sign unchanged)
-         CALL lbc_lnk( hkpp(:,:), 'T', 1. )
-
-         ! Lateral boundary conditions on avt  (sign unchanged)
-         CALL lbc_lnk( avt(:,:,:), 'W', 1. )
-#if defined key_zdfddm  
-         CALL lbc_lnk( avs(:,:,:), 'W', 1. )  
-#endif
-         ! Lateral boundary conditions (avmu,avmv) (U- and V- points, sign unchanged)
-         CALL lbc_lnk( avmu(:,:,:), 'U', 1. )   ;    CALL lbc_lnk( avmv(:,:,:), 'V', 1. )  
- 
-         IF(ln_ctl) THEN
-#if defined key_zdfddm
-            CALL prt_ctl(tab3d_1=avt , clinfo1=' kpp - t: ', tab3d_2=avs , clinfo2=' s: ', ovlap=1, kdim=jpk)
-#else
-            CALL prt_ctl(tab3d_1=avt , clinfo1=' kpp - t: ', ovlap=1, kdim=jpk)
-#endif
-            CALL prt_ctl(tab3d_1=avmu, clinfo1=' kpp - u: ', mask1=umask,  &
-               &         tab3d_2=avmv, clinfo2=      ' v: ', mask2=vmask, ovlap=1, kdim=jpk)
-         ENDIF
-
-      CALL wrk_dealloc( jpi, zmoa, zekman, zhmax, zria, zhbl )
-      CALL wrk_dealloc( jpi, za2m, za3m, zkmpm, za2t, za3t, zkmpt )
-      CALL wrk_dealloc( jpi,2, zriblk )
-      CALL wrk_dealloc( jpi,3, zmoek, kjstart = 0 )
-      CALL wrk_dealloc( jpi,3, zdept )
-      CALL wrk_dealloc( jpi,4, zdepw, zdift, zvisc )
-      CALL wrk_dealloc( jpi,jpj, zBo, zBosol, zustar )
-      CALL wrk_dealloc( jpi,jpk, zmask, zblcm, zblct )
-#if defined key_zdfddm
-      CALL wrk_dealloc( jpi,4, zdifs )
-      CALL wrk_dealloc( jpi, zmoa, za2s, za3s, zkmps )
-      CALL wrk_dealloc( jpi,jpk, zblcs )
-      CALL wrk_dealloc( jpi,jpi,jpk, zdiffus )
-#endif
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('zdf_kpp')
-      !
-   END SUBROUTINE zdf_kpp
-
-
-   SUBROUTINE tra_kpp( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE tra_kpp  ***
-      !!
-      !! ** Purpose :   compute and add to the tracer trend the non-local tracer flux
-      !!
-      !! ** Method  :   ???
-      !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdt, ztrds   ! 3D workspace
-      !!----------------------------------------------------------------------
-      INTEGER, INTENT(in) :: kt
-      INTEGER :: ji, jj, jk
-      !
-      IF( nn_timing == 1 )  CALL timing_start('tra_kpp')
-      !
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*) 
-         IF(lwp) WRITE(numout,*) 'tra_kpp : KPP non-local tracer fluxes'
-         IF(lwp) WRITE(numout,*) '~~~~~~~   '
-      ENDIF
-
-      IF( l_trdtra )   THEN                    !* Save ta and sa trends
-         ALLOCATE( ztrdt(jpi,jpj,jpk) )   ;    ztrdt(:,:,:) = tsa(:,:,:,jp_tem)
-         ALLOCATE( ztrds(jpi,jpj,jpk) )   ;    ztrds(:,:,:) = tsa(:,:,:,jp_sal)
-      ENDIF
-
-      ! add non-local temperature and salinity flux ( in convective case only)
-      DO jk = 1, jpkm1
-         DO jj = 2, jpjm1 
-            DO ji = fs_2, fs_jpim1
-               tsa(ji,jj,jk,jp_tem) =  tsa(ji,jj,jk,jp_tem)                      &
-                  &                 - (  ghats(ji,jj,jk  ) * avt  (ji,jj,jk  )   & 
-                  &                    - ghats(ji,jj,jk+1) * avt  (ji,jj,jk+1) ) * wt0(ji,jj) / fse3t(ji,jj,jk)
-               tsa(ji,jj,jk,jp_sal) =  tsa(ji,jj,jk,jp_sal)                      &
-                  &                 - (  ghats(ji,jj,jk  ) * fsavs(ji,jj,jk  )   & 
-                  &                    - ghats(ji,jj,jk+1) * fsavs(ji,jj,jk+1) ) * ws0(ji,jj) / fse3t(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-
-      ! save the non-local tracer flux trends for diagnostic
-      IF( l_trdtra )   THEN
-         ztrdt(:,:,:) = tsa(:,:,:,jp_tem) - ztrdt(:,:,:)
-         ztrds(:,:,:) = tsa(:,:,:,jp_sal) - ztrds(:,:,:)
-!!bug gm jpttdzdf ==> jpttkpp
-         CALL trd_tra( kt, 'TRA', jp_tem, jptra_zdf, ztrdt )
-         CALL trd_tra( kt, 'TRA', jp_sal, jptra_zdf, ztrds )
-         DEALLOCATE( ztrdt )      ;     DEALLOCATE( ztrds )
-      ENDIF
-
-      IF(ln_ctl) THEN
-         CALL prt_ctl( tab3d_1=tsa(:,:,:,jp_tem), clinfo1=' kpp  - Ta: ', mask1=tmask,   &
-         &             tab3d_2=tsa(:,:,:,jp_sal), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-      ENDIF
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('tra_kpp')
-      !
-   END SUBROUTINE tra_kpp
-
-#if defined key_top
-   !!----------------------------------------------------------------------
-   !!   'key_top'                                                TOP models
-   !!----------------------------------------------------------------------
-   SUBROUTINE trc_kpp( kt )
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE trc_kpp  ***
-      !!
-      !! ** Purpose :   compute and add to the tracer trend the non-local
-      !!                tracer flux
-      !!
-      !! ** Method  :   ???
-      !!
-      !! history :
-      !!            9.0  ! 2005-11 (G. Madec)  Original code
-      !!       NEMO 3.3  ! 2010-06 (C. Ethe )  Adapted to passive tracers
-      !!----------------------------------------------------------------------
-      USE trc
-      USE prtctl_trc          ! Print control
-      !
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      !
-      INTEGER  ::   ji, jj, jk, jn      ! Dummy loop indices
-      CHARACTER (len=35) :: charout
-      REAL(wp) ::   ztra, zflx
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrtrd
-      !!----------------------------------------------------------------------
-
-      IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*) 
-         IF(lwp) WRITE(numout,*) 'trc_kpp : KPP non-local tracer fluxes'
-         IF(lwp) WRITE(numout,*) '~~~~~~~   '
-      ENDIF
-
-      IF( l_trdtrc )  ALLOCATE( ztrtrd(jpi,jpj,jpk) )
-      !
-      DO jn = 1, jptra
-         !
-         IF( l_trdtrc )  ztrtrd(:,:,:)  = tra(:,:,:,jn)
-         ! add non-local on passive tracer flux ( in convective case only)
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1 
-               DO ji = fs_2, fs_jpim1
-                  ! Surface tracer flux for non-local term 
-                  zflx = - ( sfx (ji,jj) * tra(ji,jj,1,jn) * rcs ) * tmask(ji,jj,1)
-                  ! compute the trend
-                  ztra = - ( ghats(ji,jj,jk  ) * fsavs(ji,jj,jk  )   &
-                  &        - ghats(ji,jj,jk+1) * fsavs(ji,jj,jk+1) ) * zflx / fse3t(ji,jj,jk)
-                  ! add the trend to the general trend
-                  tra(ji,jj,jk,jn) = tra(ji,jj,jk,jn)  + ztra
-               END DO
-            END DO
-         END DO
-         !
-         IF( l_trdtrc ) THEN         ! save the non-local tracer flux trends for diagnostic
-            ztrtrd(:,:,:) = tra(:,:,:,jn) - ztrtrd(:,:,:)
-            CALL trd_tra( kt, 'TRC', jn, jptra_zdf, ztrtrd(:,:,:) )
-         ENDIF
-         !
-      END DO
-      IF( l_trdtrc )  DEALLOCATE( ztrtrd )
-      IF( ln_ctl )   THEN
-         WRITE(charout, FMT="(' kpp')")  ;  CALL prt_ctl_trc_info(charout)
-         CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-      ENDIF
-      !
-   END SUBROUTINE trc_kpp
-
-#else
-   !!----------------------------------------------------------------------
-   !!   NO 'key_top'           DUMMY routine                  No TOP models
-   !!----------------------------------------------------------------------
-   SUBROUTINE trc_kpp( kt )         ! Dummy routine
-      INTEGER, INTENT(in) ::   kt   ! ocean time-step index
-      WRITE(*,*) 'tra_kpp: You should not have seen this print! error?', kt
-   END SUBROUTINE trc_kpp
-#endif
-
-   SUBROUTINE zdf_kpp_init
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE zdf_kpp_init  ***
-      !!                     
-      !! ** Purpose :   Initialization of the vertical eddy diffivity and 
-      !!      viscosity when using a kpp turbulent closure scheme
-      !!
-      !! ** Method  :   Read the namkpp namelist and check the parameters
-      !!      called at the first timestep (nit000)
-      !!
-      !! ** input   :   Namlist namkpp
-      !!----------------------------------------------------------------------
-      INTEGER  ::   ji, jj, jk     ! dummy loop indices
-      INTEGER  ::   ios            ! local integer
-#if ! defined key_kppcustom
-      INTEGER  ::   jm             ! dummy loop indices     
-      REAL(wp) ::   zref, zdist    ! tempory scalars
-#endif
-#if defined key_kpplktb
-      REAL(wp) ::   zustar, zucube, zustvk, zeta, zehat   ! tempory scalars
-#endif
-      REAL(wp) ::   zhbf           ! tempory scalars
-      LOGICAL  ::   ll_kppcustom   ! 1st ocean level taken as surface layer
-      LOGICAL  ::   ll_kpplktb     ! Lookup table for turbul. velocity scales 
-      !!
-      NAMELIST/namzdf_kpp/ ln_kpprimix, rn_difmiw, rn_difsiw, rn_riinfty, rn_difri, rn_bvsqcon, rn_difcon, nn_ave
-      !!----------------------------------------------------------------------
-      !
-      IF( nn_timing == 1 )  CALL timing_start('zdf_kpp_init')
-      !
-      REWIND( numnam_ref )              ! Namelist namzdf_kpp in reference namelist : Vertical eddy diffivity and viscosity using kpp turbulent closure scheme
-      READ  ( numnam_ref, namzdf_kpp, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_kpp in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namzdf_kpp in configuration namelist : Vertical eddy diffivity and viscosity using kpp turbulent closure scheme
-      READ  ( numnam_cfg, namzdf_kpp, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_kpp in configuration namelist', lwp )
-      IF(lwm) WRITE ( numond, namzdf_kpp )
-
-      IF(lwp) THEN                    ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) 'zdf_kpp_init : K-Profile Parameterisation'
-         WRITE(numout,*) '~~~~~~~~~~~~'
-         WRITE(numout,*) '   Namelist namzdf_kpp : set tke mixing parameters'
-         WRITE(numout,*) '     Shear instability mixing                      ln_kpprimix = ', ln_kpprimix
-         WRITE(numout,*) '     max. internal wave viscosity                  rn_difmiw   = ', rn_difmiw
-         WRITE(numout,*) '     max. internal wave diffusivity                rn_difsiw   = ', rn_difsiw
-         WRITE(numout,*) '     Richardson Number limit for shear instability rn_riinfty  = ', rn_riinfty
-         WRITE(numout,*) '     max. shear mixing at Rig = 0                  rn_difri    = ', rn_difri
-         WRITE(numout,*) '     Brunt-Vaisala squared for max. convection     rn_bvsqcon  = ', rn_bvsqcon
-         WRITE(numout,*) '     max. mix. in interior convec.                 rn_difcon   = ', rn_difcon
-         WRITE(numout,*) '     horizontal average flag                       nn_ave      = ', nn_ave
-      ENDIF
-
-      !                              ! allocate zdfkpp arrays
-      IF( zdf_kpp_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_kpp_init : unable to allocate arrays' )
-
-      ll_kppcustom = .FALSE.
-      ll_kpplktb   = .FALSE.
-
-#if defined key_kppcustom
-      ll_kppcustom = .TRUE.
-#endif
-#if defined key_kpplktb
-      ll_kpplktb   = .TRUE.
-#endif
-      IF(lwp) THEN
-         WRITE(numout,*) '     Lookup table for turbul. velocity scales ll_kpplktb   = ', ll_kpplktb
-         WRITE(numout,*) '     1st ocean level taken as surface layer   ll_kppcustom = ', ll_kppcustom
-      ENDIF
-      
-      IF( lk_zdfddm) THEN
-         IF(lwp) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) '    Double diffusion mixing on temperature and salinity '
-            WRITE(numout,*) '    CAUTION : done in routine zdfkpp, not in routine zdfddm '
-         ENDIF
-      ENDIF
-      
-
-      !set constants not in namelist
-      !-----------------------------
-      Vtc  = rconcv * SQRT( 0.2 / ( rconcs * epsilon ) ) / ( vonk * vonk * Ricr )
-      rcg  = rcstar * vonk * ( rconcs * vonk * epsilon )**pthird
-
-      IF(lwp) THEN
-         WRITE(numout,*)
-         WRITE(numout,*) '     Constant value for unreso. turbul. velocity shear Vtc = ', Vtc
-         WRITE(numout,*) '     Non-dimensional coef. for nonlocal transport      rcg = ', rcg
-       ENDIF
-
-      ! ratt is the attenuation coefficient for solar flux
-      ! Should be different is s_coordinate
-      DO jk = 1, jpk
-         zhbf     = - fsdept(1,1,jk) * hbf
-         ratt(jk) = 1.0 - ( rabs * EXP( zhbf / xsi1 ) + ( 1.0 - rabs ) * EXP( zhbf / xsi2 ) )        
-      ENDDO
-
-      ! Horizontal average : initialization of weighting arrays 
-      ! -------------------
-      
-      SELECT CASE ( nn_ave )
-
-      CASE ( 0 )                ! no horizontal average
-         IF(lwp) WRITE(numout,*) '          no horizontal average on avt, avmu, avmv'
-         IF(lwp) WRITE(numout,*) '          only in very high horizontal resolution !'
-         ! weighting mean arrays etmean, eumean and evmean
-         !           ( 1  1 )                                          ( 1 )
-         ! avt = 1/4 ( 1  1 )     avmu = 1/2 ( 1  1 )       avmv=  1/2 ( 1 )
-         !                          
-         etmean(:,:,:) = 0.e0
-         eumean(:,:,:) = 0.e0
-         evmean(:,:,:) = 0.e0
-         
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = 2, jpim1   ! vector opt.
-                  etmean(ji,jj,jk) = tmask(ji,jj,jk)                     &
-                  &  / MAX( 1.,  umask(ji-1,jj  ,jk) + umask(ji,jj,jk)   &
-                  &            + vmask(ji  ,jj-1,jk) + vmask(ji,jj,jk)  )
-                  
-                  eumean(ji,jj,jk) = umask(ji,jj,jk)                     &
-                  &  / MAX( 1.,  tmask(ji,jj,jk) + tmask(ji+1,jj  ,jk)  )
-
-                  evmean(ji,jj,jk) = vmask(ji,jj,jk)                     &
-                  &  / MAX( 1.,  tmask(ji,jj,jk) + tmask(ji  ,jj+1,jk)  )
-               END DO
-            END DO
-         END DO
-
-      CASE ( 1 )                ! horizontal average 
-         IF(lwp) WRITE(numout,*) '          horizontal average on avt, avmu, avmv'
-         ! weighting mean arrays etmean, eumean and evmean
-         !           ( 1/2  1  1/2 )              ( 1/2  1/2 )             ( 1/2  1  1/2 )
-         ! avt = 1/8 ( 1    2  1   )   avmu = 1/4 ( 1    1   )   avmv= 1/4 ( 1/2  1  1/2 )
-         !           ( 1/2  1  1/2 )              ( 1/2  1/2 )
-         etmean(:,:,:) = 0.e0
-         eumean(:,:,:) = 0.e0
-         evmean(:,:,:) = 0.e0
-         
-         DO jk = 1, jpkm1
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  etmean(ji,jj,jk) = tmask(ji, jj,jk)                           &
-                     & / MAX( 1., 2.* tmask(ji,jj,jk)                           &
-                     &      +.5 * ( tmask(ji-1,jj+1,jk) + tmask(ji-1,jj-1,jk)   &
-                     &             +tmask(ji+1,jj+1,jk) + tmask(ji+1,jj-1,jk) ) &
-                     &      +1. * ( tmask(ji-1,jj  ,jk) + tmask(ji  ,jj+1,jk)   &
-                     &             +tmask(ji  ,jj-1,jk) + tmask(ji+1,jj  ,jk) ) )
-                  
-                  eumean(ji,jj,jk) = umask(ji,jj,jk)                        &
-                     &  / MAX( 1.,   tmask(ji,jj  ,jk) + tmask(ji+1,jj  ,jk)   &
-                     &       +.5 * ( tmask(ji,jj-1,jk) + tmask(ji+1,jj-1,jk)   &
-                     &              +tmask(ji,jj+1,jk) + tmask(ji+1,jj+1,jk) )  )
-                  
-                  evmean(ji,jj,jk) = vmask(ji,jj,jk)                        &
-                     &  / MAX( 1.,   tmask(ji  ,jj,jk) + tmask(ji  ,jj+1,jk)   &
-                     &       +.5 * ( tmask(ji-1,jj,jk) + tmask(ji-1,jj+1,jk)   &
-                     &              +tmask(ji+1,jj,jk) + tmask(ji+1,jj+1,jk) )  )
-               END DO
-            END DO
-         END DO
-
-      CASE DEFAULT
-         WRITE(ctmp1,*) '          bad flag value for nn_ave = ', nn_ave
-         CALL ctl_stop( ctmp1 )
-
-      END SELECT
- 
-      ! Initialization of vertical eddy coef. to the background value
-      ! -------------------------------------------------------------
-      DO jk = 1, jpk
-         avt (:,:,jk) = avtb(jk) * tmask(:,:,jk)
-         avmu(:,:,jk) = avmb(jk) * umask(:,:,jk)
-         avmv(:,:,jk) = avmb(jk) * vmask(:,:,jk)
-      END DO
-
-      ! zero the surface flux for non local term and kpp mixed layer depth
-      ! ------------------------------------------------------------------
-      ghats(:,:,:) = 0.
-      wt0  (:,:  ) = 0.
-      ws0  (:,:  ) = 0.
-      hkpp (:,:  ) = 0. ! just a diagnostic (not essential)
-
-#if ! defined key_kppcustom
-      ! compute arrays (del, wz) for reference mean values 
-      ! (increase speed for vectorization key_kppcustom not defined)
-      del(1:jpk, 1:jpk) = 0.
-      DO jk = 1, jpk
-         zref = epsilon * fsdept(1,1,jk)    
-         DO jm = 1 , jpk
-            zdist = zref - fsdepw(1,1,jm)   
-            IF( zdist > 0.  ) THEN
-               del(jk,jm) = MIN( zdist, fse3t(1,1,jm) ) / zref   
-            ELSE
-               del(jk,jm) = 0.
-            ENDIF
-         ENDDO
-      ENDDO
-#endif
-
-#if defined key_kpplktb
-      ! build lookup table for turbulent velocity scales
-      dezehat = ( dehatmax - dehatmin ) / nilktbm1
-      deustar = ( ustmax   - ustmin   ) / njlktbm1
- 
-      DO jj = 1, njlktb
-         zustar = ( jj - 1) * deustar + ustmin
-         zustvk = vonk * zustar 
-         zucube = zustar * zustar * zustar 
-         DO ji = 1 , nilktb
-            zehat = ( ji - 1 ) * dezehat + dehatmin
-            zeta   = zehat / ( zucube + epsln )
-            IF( zehat >= 0 ) THEN             ! Stable case
-               wmlktb(ji,jj) = zustvk / ABS( 1.0 + rconc1 * zeta + epsln )                        
-               wslktb(ji,jj) = wmlktb(ji,jj)
-            ELSE                                ! Unstable case 
-               IF( zeta > rzetam ) THEN
-                  wmlktb(ji,jj) = zustvk * ABS( 1.0    - rconc2 * zeta )**pfourth
-               ELSE
-                  wmlktb(ji,jj) = zustvk * ABS( rconam - rconcm * zeta )**pthird
-               ENDIF
-               
-               IF( zeta > rzetas ) THEN
-                  wslktb(ji,jj) = zustvk * SQRT( ABS( 1.0 - rconc2 * zeta ) )
-               ELSE
-                  wslktb(ji,jj) = zustvk * ABS( rconas - rconcs * zeta )**pthird
-               ENDIF
-            ENDIF
-         END DO
-      END DO
-#endif
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('zdf_kpp_init')
-      !
-   END SUBROUTINE zdf_kpp_init
-
-#else
-   !!----------------------------------------------------------------------
-   !!   Dummy module :                                        NO KPP scheme
-   !!----------------------------------------------------------------------
-   LOGICAL, PUBLIC, PARAMETER ::   lk_zdfkpp = .FALSE.   !: KPP flag
-CONTAINS
-   SUBROUTINE zdf_kpp_init           ! Dummy routine
-      WRITE(*,*) 'zdf_kpp_init: You should not have seen this print! error?'
-   END SUBROUTINE zdf_kpp_init
-   SUBROUTINE zdf_kpp( kt )          ! Dummy routine
-      WRITE(*,*) 'zdf_kpp: You should not have seen this print! error?', kt
-   END SUBROUTINE zdf_kpp
-   SUBROUTINE tra_kpp( kt )          ! Dummy routine
-      WRITE(*,*) 'tra_kpp: You should not have seen this print! error?', kt
-   END SUBROUTINE tra_kpp
-   SUBROUTINE trc_kpp( kt )          ! Dummy routine
-      WRITE(*,*) 'trc_kpp: You should not have seen this print! error?', kt
-   END SUBROUTINE trc_kpp
-#endif
-
-   !!======================================================================
-END MODULE zdfkpp
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdfric.F90	(revision 6041)
@@ -13,5 +13,5 @@
    !!            3.3.1! 2011-09  (P. Oddo) Mixed layer depth parameterization
    !!----------------------------------------------------------------------
-#if defined key_zdfric   ||   defined key_esopa
+#if defined key_zdfric
    !!----------------------------------------------------------------------
    !!   'key_zdfric'                                             Kz = f(Ri)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftke.F90	(revision 6041)
@@ -28,5 +28,5 @@
    !!            3.6  !  2014-11  (P. Mathiot) add ice shelf capability
    !!----------------------------------------------------------------------
-#if defined key_zdftke   ||   defined key_esopa
+#if defined key_zdftke
    !!----------------------------------------------------------------------
    !!   'key_zdftke'                                   TKE vertical physics
@@ -102,5 +102,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -117,6 +117,6 @@
          &      e_pdl(jpi,jpj,jpk) , e_ric(jpi,jpj,jpk) ,                          &
 #endif
-         &      apdlr(jpi,jpj,jpk) , htau  (jpi,jpj)    , dissl(jpi,jpj,jpk) ,     & 
-         &      STAT= zdf_tke_alloc      )
+         &      htau  (jpi,jpj)    , dissl(jpi,jpj,jpk) ,     & 
+         &      apdlr(jpi,jpj,jpk) ,                                           STAT= zdf_tke_alloc      )
          !
       IF( lk_mpp             )   CALL mpp_sum ( zdf_tke_alloc )
@@ -232,7 +232,7 @@
       REAL(wp) ::   zzd_up, zzd_lw                  !    -         -
 !!bfr      REAL(wp) ::   zebot                           !    -         -
-      INTEGER , POINTER, DIMENSION(:,:  ) :: imlc
-      REAL(wp), POINTER, DIMENSION(:,:  ) :: zhlc
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zpelc, zdiag, zd_up, zd_lw, z3du, z3dv
+      INTEGER , POINTER, DIMENSION(:,:  ) ::   imlc
+      REAL(wp), POINTER, DIMENSION(:,:  ) ::   zhlc
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zpelc, zdiag, zd_up, zd_lw, z3du, z3dv
       REAL(wp)                            ::   zri  !   local Richardson number
       !!--------------------------------------------------------------------
@@ -240,7 +240,7 @@
       IF( nn_timing == 1 )  CALL timing_start('tke_tke')
       !
-      CALL wrk_alloc( jpi,jpj, imlc )    ! integer
-      CALL wrk_alloc( jpi,jpj, zhlc ) 
-      CALL wrk_alloc( jpi,jpj,jpk, zpelc, zdiag, zd_up, zd_lw, z3du, z3dv ) 
+      CALL wrk_alloc( jpi,jpj,       imlc )    ! integer
+      CALL wrk_alloc( jpi,jpj,       zhlc ) 
+      CALL wrk_alloc( jpi,jpj,jpk,   zpelc, zdiag, zd_up, zd_lw, z3du, z3dv ) 
       !
       zbbrau = rn_ebb / rau0       ! Local constant initialisation
@@ -256,5 +256,5 @@
          DO jj = 2, jpjm1            ! en(mikt(ji,jj))   = rn_emin
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               en(ji,jj,mikt(ji,jj))=rn_emin * tmask(ji,jj,1)
+               en(ji,jj,mikt(ji,jj)) = rn_emin * tmask(ji,jj,1)
             END DO
          END DO
@@ -277,7 +277,5 @@
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
       !                     en(bot)   = (rn_ebb0/rau0)*0.5*sqrt(u_botfr^2+v_botfr^2) (min value rn_emin)
-!CDIR NOVERRCHK
 !!    DO jj = 2, jpjm1
-!CDIR NOVERRCHK
 !!       DO ji = fs_2, fs_jpim1   ! vector opt.
 !!          ztx2 = bfrua(ji-1,jj) * ub(ji-1,jj,mbku(ji-1,jj)) + &
@@ -318,9 +316,6 @@
          END DO
          zcof = 0.016 / SQRT( zrhoa * zcdrag )
-!CDIR NOVERRCHK
          DO jk = 2, jpkm1         !* TKE Langmuir circulation source term added to en
-!CDIR NOVERRCHK
-            DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   zus  = zcof * SQRT( taum(ji,jj) )           ! Stokes drift
@@ -348,8 +343,10 @@
                z3du(ji,jj,jk) = 0.5 * ( avm(ji,jj,jk  ) + avm(ji+1,jj,jk) )   &
                   &                 * (  un(ji,jj,jk-1) -  un(ji  ,jj,jk) )   &
-                  &                 * (  ub(ji,jj,jk-1) -  ub(ji  ,jj,jk) ) / (  fse3uw_n(ji,jj,jk) * fse3uw_b(ji,jj,jk) )
+                  &                 * (  ub(ji,jj,jk-1) -  ub(ji  ,jj,jk) ) * wumask(ji,jj,jk) &
+                  &                 / (  fse3uw_n(ji,jj,jk) * fse3uw_b(ji,jj,jk) )
                z3dv(ji,jj,jk) = 0.5 * ( avm(ji,jj,jk  ) + avm(ji,jj+1,jk) )   &
                   &                 * (  vn(ji,jj,jk-1) -  vn(ji,jj  ,jk) )   &
-                  &                 * (  vb(ji,jj,jk-1) -  vb(ji,jj  ,jk) ) / (  fse3vw_n(ji,jj,jk) * fse3vw_b(ji,jj,jk) )
+                  &                 * (  vb(ji,jj,jk-1) -  vb(ji,jj  ,jk) ) * wvmask(ji,jj,jk) &
+                  &                 / (  fse3vw_n(ji,jj,jk) * fse3vw_b(ji,jj,jk) )
             END DO
          END DO
@@ -374,5 +371,5 @@
          !
       ENDIF
-         !         
+      !         
       DO jk = 2, jpkm1           !* Matrix and right hand side in en
          DO jj = 2, jpjm1
@@ -406,7 +403,5 @@
          END DO
       END DO
-      !
-      ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1
-      DO jj = 2, jpjm1
+      DO jj = 2, jpjm1                             ! Second recurrence : Lk = RHSk - Lk / Dk-1 * Lk-1
          DO ji = fs_2, fs_jpim1   ! vector opt.
             zd_lw(ji,jj,2) = en(ji,jj,2) - zd_lw(ji,jj,2) * en(ji,jj,1)    ! Surface boudary conditions on tke
@@ -420,7 +415,5 @@
          END DO
       END DO
-      !
-      ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk
-      DO jj = 2, jpjm1
+      DO jj = 2, jpjm1                             ! thrid recurrence : Ek = ( Lk - Uk * Ek+1 ) / Dk
          DO ji = fs_2, fs_jpim1   ! vector opt.
             en(ji,jj,jpkm1) = zd_lw(ji,jj,jpkm1) / zdiag(ji,jj,jpkm1)
@@ -463,9 +456,6 @@
          END DO
       ELSEIF( nn_etau == 3 ) THEN       !* penetration belox the mixed layer (HF variability)
-!CDIR NOVERRCHK
          DO jk = 2, jpkm1
-!CDIR NOVERRCHK
-            DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   ztx2 = utau(ji-1,jj  ) + utau(ji,jj)
@@ -482,7 +472,7 @@
       CALL lbc_lnk( en, 'W', 1. )      ! Lateral boundary conditions (sign unchanged)
       !
-      CALL wrk_dealloc( jpi,jpj, imlc )    ! integer
-      CALL wrk_dealloc( jpi,jpj, zhlc ) 
-      CALL wrk_dealloc( jpi,jpj,jpk, zpelc, zdiag, zd_up, zd_lw, z3du, z3dv ) 
+      CALL wrk_dealloc( jpi,jpj,       imlc )    ! integer
+      CALL wrk_dealloc( jpi,jpj,       zhlc ) 
+      CALL wrk_dealloc( jpi,jpj,jpk,   zpelc, zdiag, zd_up, zd_lw, z3du, z3dv ) 
       !
       IF( nn_timing == 1 )  CALL timing_stop('tke_tke')
@@ -528,5 +518,5 @@
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   zrn2, zraug, zcoef, zav     ! local scalars
-      REAL(wp) ::   zdku, zri, zsqen     !   -      -
+      REAL(wp) ::   zdku, zri, zsqen            !   -      -
       REAL(wp) ::   zdkv, zemxl, zemlm, zemlp   !   -      -
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zmpdl, zmxlm, zmxld
@@ -558,12 +548,9 @@
       ENDIF
       !
-!CDIR NOVERRCHK
       DO jk = 2, jpkm1              ! interior value : l=sqrt(2*e/n^2)
-!CDIR NOVERRCHK
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                zrn2 = MAX( rn2(ji,jj,jk), rsmall )
-               zmxlm(ji,jj,jk) = MAX(  rmxl_min,  SQRT( 2._wp * en(ji,jj,jk) / zrn2 ) )
+               zmxlm(ji,jj,jk) = MAX(  rmxl_min,  SQRT( 2._wp * en(ji,jj,jk) / zrn2 )  )
             END DO
          END DO
@@ -572,9 +559,10 @@
       !                     !* Physical limits for the mixing length
       !
-      zmxld(:,:,1  ) = zmxlm(:,:,1)   ! surface set to the minimum value 
+      zmxld(:,:, 1 ) = zmxlm(:,:,1)   ! surface set to the minimum value 
       zmxld(:,:,jpk) = rmxl_min       ! last level  set to the minimum value
       !
       SELECT CASE ( nn_mxl )
       !
+ !!gm Not sure of that coding for ISF....
       ! where wmask = 0 set zmxlm == fse3w
       CASE ( 0 )           ! bounded by the distance to surface and bottom
@@ -635,9 +623,6 @@
             END DO
          END DO
-!CDIR NOVERRCHK
          DO jk = 2, jpkm1
-!CDIR NOVERRCHK
-            DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+            DO jj = 2, jpjm1
                DO ji = fs_2, fs_jpim1   ! vector opt.
                   zemlm = MIN ( zmxld(ji,jj,jk),  zmxlm(ji,jj,jk) )
@@ -659,9 +644,6 @@
       !                     !  Vertical eddy viscosity and diffusivity  (avmu, avmv, avt)
       !                     !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-!CDIR NOVERRCHK
       DO jk = 1, jpkm1            !* vertical eddy viscosity & diffivity at w-points
-!CDIR NOVERRCHK
-         DO jj = 2, jpjm1
-!CDIR NOVERRCHK
+         DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1   ! vector opt.
                zsqen = SQRT( en(ji,jj,jk) )
@@ -692,4 +674,6 @@
 # if defined key_c1d
                   e_pdl(ji,jj,jk) = apdlr(ji,jj,jk) * wmask(ji,jj,jk)    ! c1d configuration : save masked Prandlt number
+!!gm bug NO zri here....
+!!gm remove the specific diag for c1d !
                   e_ric(ji,jj,jk) = zri * wmask(ji,jj,jk)                            ! c1d config. : save Ri
 # endif
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/ZDF/zdftmx.F90	(revision 6041)
@@ -8,5 +8,5 @@
    !!            3.3  !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
    !!----------------------------------------------------------------------
-#if defined key_zdftmx   ||   defined key_esopa
+#if defined key_zdftmx
    !!----------------------------------------------------------------------
    !!   'key_zdftmx'                                  Tidal vertical mixing
@@ -54,5 +54,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -105,17 +105,17 @@
       !!              Koch-Larrouy et al. 2007, GRL.
       !!----------------------------------------------------------------------
-      USE oce, zav_tide  =>   ua    ! use ua as workspace
-      !!
       INTEGER, INTENT(in) ::   kt   ! ocean time-step 
-      !!
+      !
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       REAL(wp) ::   ztpc         ! scalar workspace
-      REAL(wp), POINTER, DIMENSION(:,:) ::   zkz
+      REAL(wp), POINTER, DIMENSION(:,:)   ::   zkz
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::   zav_tide
       !!----------------------------------------------------------------------
       !
       IF( nn_timing == 1 )  CALL timing_start('zdf_tmx')
       !
-      CALL wrk_alloc( jpi,jpj, zkz )
-
+      CALL wrk_alloc( jpi,jpj,       zkz )
+      CALL wrk_alloc( jpi,jpj,jpk,   zav_tide )
+      !
       !                          ! ----------------------- !
       !                          !  Standard tidal mixing  !  (compute zav_tide)
@@ -136,22 +136,19 @@
 
       DO jk = 2, jpkm1     !* Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zav_tide bound by 300 cm2/s
-         DO jj = 1, jpj                !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
-            DO ji = 1, jpi
-               zav_tide(ji,jj,jk) = zav_tide(ji,jj,jk) * MIN( zkz(ji,jj), 30./6. ) * wmask(ji,jj,jk)  !kz max = 300 cm2/s
-            END DO
-         END DO
+         zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. ) * wmask(:,:,jk)  !kz max = 300 cm2/s
       END DO
 
       IF( kt == nit000 ) THEN       !* check at first time-step: diagnose the energy consumed by zav_tide
-         ztpc = 0.e0
+         ztpc = 0._wp
          DO jk= 1, jpk
             DO jj= 1, jpj
                DO ji= 1, jpi
-                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj)   &
-                     &         * MAX( 0.e0, rn2(ji,jj,jk) ) * zav_tide(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+                  ztpc = ztpc + fse3w(ji,jj,jk) * e1e2t(ji,jj)                  &
+                     &        * MAX( 0.e0, rn2(ji,jj,jk) ) * zav_tide(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
                END DO
             END DO
          END DO
          ztpc= rau0 / ( rn_tfe * rn_me ) * ztpc
+         IF( lk_mpp )   CALL mpp_sum( ztpc )
          IF(lwp) WRITE(numout,*) 
          IF(lwp) WRITE(numout,*) '          N Total power consumption by av_tide    : ztpc = ', ztpc * 1.e-12 ,'TW'
@@ -167,13 +164,6 @@
       !                          ! ----------------------- !
       DO jk = 2, jpkm1              !* update momentum & tracer diffusivity with tidal mixing
-         DO jj = 1, jpj                !* Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz to recover en_tmx
-            DO ji = 1, jpi
-               avt(ji,jj,jk) = avt(ji,jj,jk) + zav_tide(ji,jj,jk) * wmask(ji,jj,jk)
-               avm(ji,jj,jk) = avm(ji,jj,jk) + zav_tide(ji,jj,jk) * wmask(ji,jj,jk)
-            END DO
-         END DO
-      END DO
-      
-      DO jk = 2, jpkm1              !* update momentum & tracer diffusivity with tidal mixing
+         avt(:,:,jk) = avt(:,:,jk) + zav_tide(:,:,jk) * wmask(:,:,jk)
+         avm(:,:,jk) = avm(:,:,jk) + zav_tide(:,:,jk) * wmask(:,:,jk)
          DO jj = 2, jpjm1
             DO ji = fs_2, fs_jpim1  ! vector opt.
@@ -190,5 +180,6 @@
       IF(ln_ctl)   CALL prt_ctl(tab3d_1=zav_tide , clinfo1=' tmx - av_tide: ', tab3d_2=avt, clinfo2=' avt: ', ovlap=1, kdim=jpk)
       !
-      CALL wrk_dealloc( jpi,jpj, zkz )
+      CALL wrk_dealloc( jpi,jpj,       zkz )
+      CALL wrk_dealloc( jpi,jpj,jpk,   zav_tide )
       !
       IF( nn_timing == 1 )  CALL timing_stop('zdf_tmx')
@@ -239,5 +230,4 @@
       DO jk = 1, jpkm1             
          zdn2dz     (:,:,jk) = rn2(:,:,jk) - rn2(:,:,jk+1)           ! Vertical profile of dN2/dz
-!CDIR NOVERRCHK
          zempba_3d_1(:,:,jk) = SQRT(  MAX( 0.e0, rn2(:,:,jk) )  )    !    -        -    of N
          zempba_3d_2(:,:,jk) =        MAX( 0.e0, rn2(:,:,jk) )       !    -        -    of N^2
@@ -248,6 +238,6 @@
       zsum2(:,:) = 0.e0
       DO jk= 2, jpk
-         zsum1(:,:) = zsum1(:,:) + zempba_3d_1(:,:,jk) * fse3w(:,:,jk) * tmask(:,:,jk) * tmask(:,:,jk-1)
-         zsum2(:,:) = zsum2(:,:) + zempba_3d_2(:,:,jk) * fse3w(:,:,jk) * tmask(:,:,jk) * tmask(:,:,jk-1)               
+         zsum1(:,:) = zsum1(:,:) + zempba_3d_1(:,:,jk) * fse3w(:,:,jk) * wmask(:,:,jk)
+         zsum2(:,:) = zsum2(:,:) + zempba_3d_2(:,:,jk) * fse3w(:,:,jk) * wmask(:,:,jk)               
       END DO
       DO jj = 1, jpj
@@ -285,5 +275,5 @@
       zkz(:,:) = 0.e0               ! Associated potential energy consummed over the whole water column
       DO jk = 2, jpkm1
-         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zavt_itf(:,:,jk) * tmask(:,:,jk) * tmask(:,:,jk-1)
+         zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX( 0.e0, rn2(:,:,jk) ) * rau0 * zavt_itf(:,:,jk) * wmask(:,:,jk)
       END DO
 
@@ -295,5 +285,5 @@
 
       DO jk = 2, jpkm1              ! Mutiply by zkz to recover en_tmx, BUT bound by 30/6 ==> zavt_itf bound by 300 cm2/s
-         zavt_itf(:,:,jk) = zavt_itf(:,:,jk) * MIN( zkz(:,:), 120./10. ) * tmask(:,:,jk) * tmask(:,:,jk-1)   ! kz max = 120 cm2/s
+         zavt_itf(:,:,jk) = zavt_itf(:,:,jk) * MIN( zkz(:,:), 120./10. ) * wmask(:,:,jk)   ! kz max = 120 cm2/s
       END DO
 
@@ -303,9 +293,10 @@
             DO jj= 1, jpj
                DO ji= 1, jpi
-                  ztpc = ztpc + e1t(ji,jj) * e2t(ji,jj) * fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) )   &
-                     &                     * zavt_itf(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
+                  ztpc = ztpc + e1e2t(ji,jj) * fse3w(ji,jj,jk) * MAX( 0.e0, rn2(ji,jj,jk) )   &
+                     &                       * zavt_itf(ji,jj,jk) * tmask(ji,jj,jk) * tmask_i(ji,jj)
                END DO
             END DO
          END DO
+         IF( lk_mpp )   CALL mpp_sum( ztpc )
          ztpc= rau0 * ztpc / ( rn_me * rn_tfe_itf )
          IF(lwp) WRITE(numout,*) '          N Total power consumption by zavt_itf: ztpc = ', ztpc * 1.e-12 ,'TW'
@@ -361,15 +352,13 @@
       !!              Koch-Larrouy et al. 2007, GRL.
       !!----------------------------------------------------------------------
-      USE oce     ,         zav_tide =>  ua         ! ua used as workspace
-      !!
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
       INTEGER  ::   inum         ! local integer
       INTEGER  ::   ios
       REAL(wp) ::   ztpc, ze_z   ! local scalars
-      REAL(wp), DIMENSION(:,:)  , POINTER ::  zem2, zek1   ! read M2 and K1 tidal energy
-      REAL(wp), DIMENSION(:,:)  , POINTER ::  zkz          ! total M2, K1 and S2 tidal energy
-      REAL(wp), DIMENSION(:,:)  , POINTER ::  zfact        ! used for vertical structure function
-      REAL(wp), DIMENSION(:,:)  , POINTER ::  zhdep        ! Ocean depth 
-      REAL(wp), DIMENSION(:,:,:), POINTER ::  zpc      ! power consumption
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zem2, zek1     ! read M2 and K1 tidal energy
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zkz            ! total M2, K1 and S2 tidal energy
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zfact          ! used for vertical structure function
+      REAL(wp), DIMENSION(:,:)  , POINTER ::  zhdep          ! Ocean depth 
+      REAL(wp), DIMENSION(:,:,:), POINTER ::  zpc, zav_tide  ! power consumption
       !!
       NAMELIST/namzdf_tmx/ rn_htmx, rn_n2min, rn_tfe, rn_me, ln_tmx_itf, rn_tfe_itf
@@ -378,17 +367,17 @@
       IF( nn_timing == 1 )  CALL timing_start('zdf_tmx_init')
       !
-      CALL wrk_alloc( jpi,jpj, zem2, zek1, zkz, zfact, zhdep )
-      CALL wrk_alloc( jpi,jpj,jpk, zpc )
-      
-      REWIND( numnam_ref )              ! Namelist namzdf_tmx in reference namelist : Tidal Mixing
+      CALL wrk_alloc( jpi,jpj,       zem2, zek1, zkz, zfact, zhdep )
+      CALL wrk_alloc( jpi,jpj,jpk,   zpc, zav_tide )
+      !
+      REWIND( numnam_ref )             ! Namelist namzdf_tmx in reference namelist : Tidal Mixing
       READ  ( numnam_ref, namzdf_tmx, IOSTAT = ios, ERR = 901)
 901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tmx in reference namelist', lwp )
-
-      REWIND( numnam_cfg )              ! Namelist namzdf_tmx in configuration namelist : Tidal Mixing
+      !
+      REWIND( numnam_cfg )             ! Namelist namzdf_tmx in configuration namelist : Tidal Mixing
       READ  ( numnam_cfg, namzdf_tmx, IOSTAT = ios, ERR = 902 )
 902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namzdf_tmx in configuration namelist', lwp )
       IF(lwm) WRITE ( numond, namzdf_tmx )
-
-      IF(lwp) THEN                   ! Control print
+      !
+      IF(lwp) THEN                     ! Control print
          WRITE(numout,*)
          WRITE(numout,*) 'zdf_tmx_init : tidal mixing'
@@ -402,33 +391,31 @@
          WRITE(numout,*) '      ITF tidal dissipation efficiency      = ', rn_tfe_itf
       ENDIF
-
-      !                              ! allocate tmx arrays
+      !                                ! allocate tmx arrays
       IF( zdf_tmx_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'zdf_tmx_init : unable to allocate tmx arrays' )
 
-      IF( ln_tmx_itf ) THEN          ! read the Indonesian Through Flow mask
+      IF( ln_tmx_itf ) THEN            ! read the Indonesian Through Flow mask
          CALL iom_open('mask_itf',inum)
          CALL iom_get (inum, jpdom_data, 'tmaskitf',mask_itf,1) ! 
          CALL iom_close(inum)
       ENDIF
-
-      ! read M2 tidal energy flux : W/m2  ( zem2 < 0 )
+      !                                ! read M2 tidal energy flux : W/m2  ( zem2 < 0 )
       CALL iom_open('M2rowdrg',inum)
       CALL iom_get (inum, jpdom_data, 'field',zem2,1) ! 
       CALL iom_close(inum)
-
-      ! read K1 tidal energy flux : W/m2  ( zek1 < 0 )
+      !                                ! read K1 tidal energy flux : W/m2  ( zek1 < 0 )
       CALL iom_open('K1rowdrg',inum)
       CALL iom_get (inum, jpdom_data, 'field',zek1,1) ! 
       CALL iom_close(inum)
- 
-      ! Total tidal energy ( M2, S2 and K1  with S2=(1/2)^2 * M2 )
-      ! only the energy available for mixing is taken into account,
-      ! (mixing efficiency tidal dissipation efficiency)
+      !                                ! Total tidal energy ( M2, S2 and K1  with S2=(1/2)^2 * M2 )
+      !                                ! only the energy available for mixing is taken into account,
+      !                                ! (mixing efficiency tidal dissipation efficiency)
       en_tmx(:,:) = - rn_tfe * rn_me * ( zem2(:,:) * 1.25 + zek1(:,:) ) * ssmask(:,:)
 
 !============
 !TG: Bug for VVL? Should this section be moved out of _init and be updated at every timestep?
-      ! Vertical structure (az_tmx)
-      DO jj = 1, jpj                ! part independent of the level
+!!gm : you are right, but tidal mixing acts in deep ocean (H>500m) where e3 is O(100m)
+!!     the error is thus ~1% which I feel comfortable with, compared to uncertainties in tidal energy dissipation.
+      !                                ! Vertical structure (az_tmx)
+      DO jj = 1, jpj                         ! part independent of the level
          DO ji = 1, jpi
             zhdep(ji,jj) = gdepw_0(ji,jj,mbkt(ji,jj)+1)       ! depth of the ocean
@@ -437,5 +424,5 @@
          END DO
       END DO
-      DO jk= 1, jpk                 ! complete with the level-dependent part
+      DO jk= 1, jpk                          ! complete with the level-dependent part
          DO jj = 1, jpj
             DO ji = 1, jpi
@@ -445,5 +432,5 @@
       END DO
 !===========
-
+      !
       IF( nprint == 1 .AND. lwp ) THEN
          ! Control print
@@ -454,29 +441,25 @@
             zav_tide(:,:,jk) = az_tmx(:,:,jk) / MAX( rn_n2min, rn2(:,:,jk) )
          END DO
-
-         ztpc = 0.e0
+         !
+         ztpc = 0._wp
          zpc(:,:,:) = MAX(rn_n2min,rn2(:,:,:)) * zav_tide(:,:,:)
          DO jk= 2, jpkm1
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
+                  ztpc = ztpc + fse3w(ji,jj,jk) * e1e2t(ji,jj) * zpc(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
                END DO
             END DO
          END DO
+         IF( lk_mpp )   CALL mpp_sum( ztpc )
          ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
-
+         !
          WRITE(numout,*) 
          WRITE(numout,*) '          Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
-
-
+         !
          ! control print 2
          zav_tide(:,:,:) = MIN( zav_tide(:,:,:), 60.e-4 )   
-         zkz(:,:) = 0.e0
+         zkz(:,:) = 0._wp
          DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zkz(ji,jj) = zkz(ji,jj) + fse3w(ji,jj,jk) * MAX(0.e0, rn2(ji,jj,jk)) * rau0 * zav_tide(ji,jj,jk) * wmask(ji,jj,jk)
-               END DO
-            END DO
+               zkz(:,:) = zkz(:,:) + fse3w(:,:,jk) * MAX(0.e0, rn2(:,:,jk)) * rau0 * zav_tide(:,:,jk) * wmask(:,:,jk)
          END DO
          ! Here zkz should be equal to en_tmx ==> multiply by en_tmx/zkz
@@ -497,31 +480,28 @@
          END DO
          WRITE(numout,*) '          Min de zkz ', ztpc, ' Max = ', maxval(zkz(:,:) )
-
+         !
          DO jk = 2, jpkm1
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  zav_tide(ji,jj,jk) = zav_tide(ji,jj,jk) * MIN( zkz(ji,jj), 30./6. ) * wmask(ji,jj,jk)  !kz max = 300 cm2/s
-               END DO
-            END DO
-         END DO
-         ztpc = 0.e0
+            zav_tide(:,:,jk) = zav_tide(:,:,jk) * MIN( zkz(:,:), 30./6. ) * wmask(:,:,jk)  !kz max = 300 cm2/s
+         END DO
+         ztpc = 0._wp
          zpc(:,:,:) = Max(0.e0,rn2(:,:,:)) * zav_tide(:,:,:)
          DO jk= 1, jpk
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  ztpc = ztpc + fse3w(ji,jj,jk) * e1t(ji,jj) * e2t(ji,jj) * zpc(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
+                  ztpc = ztpc + fse3w(ji,jj,jk) * e1e2t(ji,jj) * zpc(ji,jj,jk) * wmask(ji,jj,jk) * tmask_i(ji,jj)
                END DO
             END DO
          END DO
+         IF( lk_mpp )   CALL mpp_sum( ztpc )
          ztpc= rau0 * 1/(rn_tfe * rn_me) * ztpc
          WRITE(numout,*) '          2 Total power consumption of the tidally driven part of Kz : ztpc = ', ztpc * 1.e-12 ,'TW'
-
+!!gm bug mpp  in these diagnostics
          DO jk = 1, jpk
-            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zav_tide(:,:,jk)     * tmask_i(:,:) )   &
-               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * wmask (:,:,jk) * tmask_i(:,:) ) )
-            ztpc = 1.E50
+            ze_z =                  SUM( e1e2t(:,:) * zav_tide(:,:,jk) * tmask_i(:,:) )   &
+               &     / MAX( 1.e-20, SUM( e1e2t(:,:) * wmask   (:,:,jk) * tmask_i(:,:) ) )
+            ztpc = 1.e50
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  IF( zav_tide(ji,jj,jk) /= 0.e0 )   ztpc =Min( ztpc, zav_tide(ji,jj,jk) )
+                  IF( zav_tide(ji,jj,jk) /= 0.e0 )   ztpc = MIN( ztpc, zav_tide(ji,jj,jk) )
                END DO
             END DO
@@ -530,5 +510,5 @@
          END DO
 
-         WRITE(numout,*) '          e_tide : ', SUM( e1t*e2t*en_tmx ) / ( rn_tfe * rn_me ) * 1.e-12, 'TW'
+         WRITE(numout,*) '          e_tide : ', SUM( e1e2t*en_tmx ) / ( rn_tfe * rn_me ) * 1.e-12, 'TW'
          WRITE(numout,*) 
          WRITE(numout,*) '          Initial profile of tidal vertical mixing'
@@ -539,16 +519,17 @@
                END DO
             END DO
-            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zkz(:,:)     * tmask_i(:,:) )   &
-               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * wmask (:,:,jk) * tmask_i(:,:) ) )
+            ze_z =                  SUM( e1e2t(:,:) * zkz  (:,:)    * tmask_i(:,:) )   &
+               &     / MAX( 1.e-20, SUM( e1e2t(:,:) * wmask(:,:,jk) * tmask_i(:,:) ) )
             WRITE(numout,*) '                jk= ', jk,'   ', ze_z * 1.e4,' cm2/s'
          END DO
          DO jk = 1, jpk
             zkz(:,:) = az_tmx(:,:,jk) /rn_n2min
-            ze_z =                  SUM( e1t(:,:) * e2t(:,:) * zkz(:,:)     * tmask_i(:,:) )   &
-               &     / MAX( 1.e-20, SUM( e1t(:,:) * e2t(:,:) * wmask (:,:,jk) * tmask_i(:,:) ) )
+            ze_z =                  SUM( e1e2t(:,:) * zkz  (:,:)    * tmask_i(:,:) )   &
+               &     / MAX( 1.e-20, SUM( e1e2t(:,:) * wmask(:,:,jk) * tmask_i(:,:) ) )
             WRITE(numout,*) 
             WRITE(numout,*) '          N2 min - jk= ', jk,'   ', ze_z * 1.e4,' cm2/s min= ',MINVAL(zkz)*1.e4,   &
                &       'max= ', MAXVAL(zkz)*1.e4, ' cm2/s'
          END DO
+!!gm  end bug mpp
          !
       ENDIF
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/nemogcm.F90	(revision 6041)
@@ -28,6 +28,9 @@
    !!             -   ! 2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase
    !!            3.3.1! 2011-01  (A. R. Porter, STFC Daresbury) dynamical allocation
-   !!            3.4  ! 2011-11  (C. Harris) decomposition changes for running with CICE
-   !!                 ! 2012-05  (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening 
+   !!            3.4  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE) add nemo_northcomms
+   !!             -   ! 2011-11  (C. Harris) decomposition changes for running with CICE
+   !!            3.6  ! 2012-05  (C. Calone, J. Simeon, G. Madec, C. Ethe) Add grid coarsening 
+   !!             -   ! 2013-06  (I. Epicoco, S. Mocavero, CMCC) nemo_northcomms: setup avoiding MPI communication 
+   !!             -   ! 2014-12  (G. Madec) remove KPP scheme and cross-land advection (cla)
    !!----------------------------------------------------------------------
 
@@ -41,6 +44,5 @@
    !!   factorise      : calculate the factors of the no. of MPI processes
    !!----------------------------------------------------------------------
-   USE step_oce        ! module used in the ocean time stepping module
-   USE cla             ! cross land advection               (tra_cla routine)
+   USE step_oce        ! module used in the ocean time stepping module (step.F90)
    USE domcfg          ! domain configuration               (dom_cfg routine)
    USE mppini          ! shared/distributed memory setting (mpp_init routine)
@@ -77,10 +79,10 @@
    USE lib_mpp         ! distributed memory computing
 #if defined key_iomput
-   USE xios
-#endif
-   USE sbctide, ONLY: lk_tide
+   USE xios            ! xIOserver
+#endif
+   USE sbctide, ONLY   : lk_tide
    USE crsini          ! initialise grid coarsening utility
-   USE lbcnfd, ONLY: isendto, nsndto, nfsloop, nfeloop ! Setup of north fold exchanges 
-   USE sbc_oce, ONLY: lk_oasis
+   USE lbcnfd , ONLY   : isendto, nsndto, nfsloop, nfeloop   ! Setup of north fold exchanges 
+   USE sbc_oce, ONLY   : lk_oasis
    USE stopar
    USE stopts
@@ -96,5 +98,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -191,9 +193,9 @@
       !
 #if defined key_agrif
-      IF( .NOT. Agrif_Root() ) THEN
-         CALL Agrif_ParentGrid_To_ChildGrid()
-         IF( lk_diaobs ) CALL dia_obs_wri
+      IF(.NOT.Agrif_Root() ) THEN
+                                CALL Agrif_ParentGrid_To_ChildGrid()
+         IF( lk_diaobs )        CALL dia_obs_wri
          IF( nn_timing == 1 )   CALL timing_finalize
-         CALL Agrif_ChildGrid_To_ParentGrid()
+                                CALL Agrif_ChildGrid_To_ParentGrid()
       ENDIF
 #endif
@@ -203,6 +205,6 @@
       !
 #if defined key_iomput
-      CALL xios_finalize                ! end mpp communications with xios
-      IF( lk_oasis ) CALL cpl_finalize    ! end coupling and mpp communications with OASIS
+      CALL xios_finalize                  ! end mpp communications with xios
+      IF( lk_oasis )   CALL cpl_finalize  ! end coupling and mpp communications with OASIS
 #else
       IF( lk_oasis ) THEN 
@@ -319,7 +321,7 @@
       ! If dimensions of processor grid weren't specified in the namelist file
       ! then we calculate them here now that we have our communicator size
-      IF( (jpni < 1) .OR. (jpnj < 1) )THEN
+      IF( jpni < 1 .OR. jpnj < 1 ) THEN
 #if   defined key_mpp_mpi
-         IF( Agrif_Root() ) CALL nemo_partition(mppsize)
+         IF( Agrif_Root() )   CALL nemo_partition( mppsize )
 #else
          jpni  = 1
@@ -327,26 +329,23 @@
          jpnij = jpni*jpnj
 #endif
-      END IF
+      ENDIF
 
       ! Calculate domain dimensions given calculated jpni and jpnj
-      ! This used to be done in par_oce.F90 when they were parameters rather
-      ! than variables
+      ! This used to be done in par_oce.F90 when they were parameters rather than variables
       IF( Agrif_Root() ) THEN
 #if defined key_nemocice_decomp
-         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci ! first  dim.
-         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj ! second dim. 
+         jpi = ( nx_global+2-2*jpreci + (jpni-1) ) / jpni + 2*jpreci    ! first  dim.
+         jpj = ( ny_global+2-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj    ! second dim. 
 #else
-         jpi = ( jpiglo-2*jpreci + (jpni-1) ) / jpni + 2*jpreci   ! first  dim.
-         jpj = ( jpjglo-2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj   ! second dim.
+         jpi = ( jpiglo     -2*jpreci + (jpni-1) ) / jpni + 2*jpreci    ! first  dim.
+         jpj = ( jpjglo     -2*jprecj + (jpnj-1) ) / jpnj + 2*jprecj    ! second dim.
 #endif
       ENDIF         
          jpk = jpkdta                                             ! third dim
 #if defined key_agrif
-         ! simple trick to use same vertical grid as parent
-         ! but different number of levels: 
-         ! Save maximum number of levels in jpkdta, then define all vertical grids
-         ! with this number.
+         ! simple trick to use same vertical grid as parent but different number of levels: 
+         ! Save maximum number of levels in jpkdta, then define all vertical grids with this number.
          ! Suppress once vertical online interpolation is ok
-         IF(.NOT.Agrif_Root()) jpkdta = Agrif_Parent(jpkdta)
+         IF(.NOT.Agrif_Root())   jpkdta = Agrif_Parent( jpkdta )
 #endif
          jpim1 = jpi-1                                            ! inner domain indices
@@ -363,5 +362,5 @@
          WRITE(numout,*) '                       NEMO team'
          WRITE(numout,*) '            Ocean General Circulation Model'
-         WRITE(numout,*) '                  version 3.6  (2015) '
+         WRITE(numout,*) '                  version 3.7  (2015) '
          WRITE(numout,*)
          WRITE(numout,*)
@@ -396,25 +395,20 @@
                             CALL     dom_cfg    ! Domain configuration
                             CALL     dom_init   ! Domain
-
-      IF( ln_nnogather )    CALL nemo_northcomms   ! Initialise the northfold neighbour lists (must be done after the masks are defined)
-
+      IF( ln_crs        )   CALL     crs_init   ! coarsened grid: domain initialization 
+      IF( ln_nnogather )    CALL nemo_northcomms! northfold neighbour lists (must be done after the masks are defined)
       IF( ln_ctl        )   CALL prt_ctl_init   ! Print control
-
                             CALL  istate_init   ! ocean initial state (Dynamics and tracers)
 
-      IF( lk_tide       )   CALL    tide_init( nit000 )    ! Initialisation of the tidal harmonics
-
-                            CALL     sbc_init   ! Forcings : surface module (clem: moved here for bdy purpose)
-
+      !                                      ! external forcing 
+!!gm to be added : creation and call of sbc_apr_init
+      IF( lk_tide       )   CALL    tide_init( nit000 )    ! tidal harmonics
+                            CALL     sbc_init   ! surface boundary conditions (including sea-ice)
+!!gm ==>> bdy_init should call bdy_dta_init and bdytide_init  NOT in nemogcm !!!
       IF( lk_bdy        )   CALL     bdy_init   ! Open boundaries initialisation
       IF( lk_bdy        )   CALL bdy_dta_init   ! Open boundaries initialisation of external data arrays
       IF( lk_bdy .AND. lk_tide )   &
          &                  CALL bdytide_init   ! Open boundaries initialisation of tidal harmonic forcing
-
-                            CALL dyn_nept_init  ! simplified form of Neptune effect
-      !     
-      IF( ln_crs        )   CALL     crs_init   ! Domain initialization of coarsened grid
-      !
-                                ! Ocean physics
+         
+      !                                      ! Ocean physics
       !                                         ! Vertical physics
                             CALL     zdf_init      ! namelist read
@@ -423,42 +417,44 @@
       IF( lk_zdftke     )   CALL zdf_tke_init      ! TKE closure scheme
       IF( lk_zdfgls     )   CALL zdf_gls_init      ! GLS closure scheme
-      IF( lk_zdfkpp     )   CALL zdf_kpp_init      ! KPP closure scheme
       IF( lk_zdftmx     )   CALL zdf_tmx_init      ! tidal vertical mixing
-      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
-         &                  CALL zdf_ddm_init      ! double diffusive mixing
+      IF( lk_zdfddm     )   CALL zdf_ddm_init      ! double diffusive mixing
+         
       !                                         ! Lateral physics
                             CALL ldf_tra_init      ! Lateral ocean tracer physics
+                            CALL ldf_eiv_init      ! eddy induced velocity param.
                             CALL ldf_dyn_init      ! Lateral ocean momentum physics
-      IF( lk_ldfslp     )   CALL ldf_slp_init      ! slope of lateral mixing
-
-      !                                     ! Active tracers
-                            CALL tra_qsr_init   ! penetrative solar radiation qsr
-                            CALL tra_bbc_init   ! bottom heat flux
-      IF( lk_trabbl     )   CALL tra_bbl_init   ! advective (and/or diffusive) bottom boundary layer scheme
-                            CALL tra_dmp_init   ! internal damping trends- tracers
-                            CALL tra_adv_init   ! horizontal & vertical advection
-                            CALL tra_ldf_init   ! lateral mixing
-                            CALL tra_zdf_init   ! vertical mixing and after tracer fields
-
-      !                                     ! Dynamics
-      IF( lk_c1d        )   CALL dyn_dmp_init   ! internal damping trends- momentum
-                            CALL dyn_adv_init   ! advection (vector or flux form)
-                            CALL dyn_vor_init   ! vorticity term including Coriolis
-                            CALL dyn_ldf_init   ! lateral mixing
-                            CALL dyn_hpg_init   ! horizontal gradient of Hydrostatic pressure
-                            CALL dyn_zdf_init   ! vertical diffusion
-                            CALL dyn_spg_init   ! surface pressure gradient
-
-      !                                     ! Misc. options
-      IF( nn_cla == 1 .AND. cp_cfg == 'orca' .AND. jp_cfg == 2 )   CALL cla_init       ! Cross Land Advection
+
+      !                                         ! Active tracers
+                            CALL tra_qsr_init      ! penetrative solar radiation qsr
+                            CALL tra_bbc_init      ! bottom heat flux
+      IF( lk_trabbl     )   CALL tra_bbl_init      ! advective (and/or diffusive) bottom boundary layer scheme
+                            CALL tra_dmp_init      ! internal tracer damping
+                            CALL tra_adv_init      ! horizontal & vertical advection
+                            CALL tra_ldf_init      ! lateral mixing
+                            CALL tra_zdf_init      ! vertical mixing and after tracer fields
+
+      !                                         ! Dynamics
+      IF( lk_c1d        )   CALL dyn_dmp_init      ! internal momentum damping
+                            CALL dyn_adv_init      ! advection (vector or flux form)
+                            CALL dyn_vor_init      ! vorticity term including Coriolis
+                            CALL dyn_ldf_init      ! lateral mixing
+                            CALL dyn_hpg_init      ! horizontal gradient of Hydrostatic pressure
+                            CALL dyn_zdf_init      ! vertical diffusion
+                            CALL dyn_spg_init      ! surface pressure gradient
+
+#if defined key_top
+      !                                      ! Passive tracers
+                            CALL     trc_init
+#endif
+      IF( l_ldfslp      )   CALL ldf_slp_init   ! slope of lateral mixing
+
+      !                                      ! Icebergs
                             CALL icb_init( rdt, nit000)   ! initialise icebergs instance
+
+      !                                      ! Misc. options
                             CALL sto_par_init   ! Stochastic parametrization
       IF( ln_sto_eos     )  CALL sto_pts_init   ! RRandom T/S fluctuations
      
-#if defined key_top
-      !                                     ! Passive tracers
-                            CALL     trc_init
-#endif
-      !                                     ! Diagnostics
+      !                                      ! Diagnostics
       IF( lk_floats     )   CALL     flo_init   ! drifting Floats
       IF( lk_diaar5     )   CALL dia_ar5_init   ! ar5 diag
@@ -471,6 +467,5 @@
                             CALL dia_obs( nit000 - 1 )   ! Observation operator for restart
       ENDIF
-
-      !                                     ! Assimilation increments
+      !                                      ! Assimilation increments
       IF( lk_asminc     )   CALL asm_inc_init   ! Initialize assimilation increments
       IF(lwp) WRITE(numout,*) 'Euler time step switch is ', neuler
@@ -519,15 +514,15 @@
          WRITE(numout,*) '~~~~~~~ '
          WRITE(numout,*) '   Namelist namcfg'
-         WRITE(numout,*) '      configuration name              cp_cfg      = ', TRIM(cp_cfg)
-         WRITE(numout,*) '      configuration zoom name         cp_cfz      = ', TRIM(cp_cfz)
-         WRITE(numout,*) '      configuration resolution        jp_cfg      = ', jp_cfg
-         WRITE(numout,*) '      1st lateral dimension ( >= jpi ) jpidta     = ', jpidta
-         WRITE(numout,*) '      2nd    "         "    ( >= jpj ) jpjdta     = ', jpjdta
-         WRITE(numout,*) '      3nd    "         "               jpkdta     = ', jpkdta
-         WRITE(numout,*) '      1st dimension of global domain in i jpiglo  = ', jpiglo
-         WRITE(numout,*) '      2nd    -                  -    in j jpjglo  = ', jpjglo
+         WRITE(numout,*) '      configuration name                               cp_cfg  = ', TRIM(cp_cfg)
+         WRITE(numout,*) '      configuration zoom name                          cp_cfz  = ', TRIM(cp_cfz)
+         WRITE(numout,*) '      configuration resolution                         jp_cfg  = ', jp_cfg
+         WRITE(numout,*) '      1st lateral dimension ( >= jpiglo )              jpidta  = ', jpidta
+         WRITE(numout,*) '      2nd    "         "    ( >= jpjglo )              jpjdta  = ', jpjdta
+         WRITE(numout,*) '      3nd    "         "                               jpkdta  = ', jpkdta
+         WRITE(numout,*) '      1st dimension of global domain in i              jpiglo  = ', jpiglo
+         WRITE(numout,*) '      2nd    -                  -    in j              jpjglo  = ', jpjglo
          WRITE(numout,*) '      left bottom i index of the zoom (in data domain) jpizoom = ', jpizoom
          WRITE(numout,*) '      left bottom j index of the zoom (in data domain) jpizoom = ', jpjzoom
-         WRITE(numout,*) '      lateral cond. type (between 0 and 6) jperio = ', jperio   
+         WRITE(numout,*) '      lateral cond. type (between 0 and 6)             jperio  = ', jperio   
          WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
       ENDIF
@@ -610,5 +605,4 @@
       IF( numdct_heat     /= -1 )   CLOSE( numdct_heat     )   ! heat transports
       IF( numdct_salt     /= -1 )   CLOSE( numdct_salt     )   ! salt transports
-
       !
       numout = 6                                     ! redefine numout in case it is used after this point...
@@ -627,6 +621,4 @@
       USE diawri    , ONLY: dia_wri_alloc
       USE dom_oce   , ONLY: dom_oce_alloc
-      USE ldfdyn_oce, ONLY: ldfdyn_oce_alloc
-      USE ldftra_oce, ONLY: ldftra_oce_alloc
       USE trc_oce   , ONLY: trc_oce_alloc
 #if defined key_diadct 
@@ -643,6 +635,4 @@
       ierr = ierr + dia_wri_alloc   ()
       ierr = ierr + dom_oce_alloc   ()          ! ocean domain
-      ierr = ierr + ldfdyn_oce_alloc()          ! ocean lateral  physics : dynamics
-      ierr = ierr + ldftra_oce_alloc()          ! ocean lateral  physics : tracers
       ierr = ierr + zdf_oce_alloc   ()          ! ocean vertical physics
       !
@@ -724,14 +714,15 @@
       INTEGER :: ifac, jl, inu
       INTEGER, PARAMETER :: ntest = 14
-      INTEGER, DIMENSION(ntest) :: ilfax
-      !!----------------------------------------------------------------------
+      INTEGER, DIMENSION(ntest) ::   ilfax
+      !!----------------------------------------------------------------------
+      !
       ! lfax contains the set of allowed factors.
       ilfax(:) = (/(2**jl,jl=ntest,1,-1)/)
-
+      !
       ! Clear the error flag and initialise output vars
-      kerr = 0
-      kfax = 1
+      kerr  = 0
+      kfax  = 1
       knfax = 0
-
+      !
       ! Find the factors of n.
       IF( kn == 1 )   GOTO 20
@@ -741,8 +732,8 @@
       ! l points to the allowed factor list.
       ! ifac holds the current factor.
-
+      !
       inu   = kn
       knfax = 0
-
+      !
       DO jl = ntest, 1, -1
          !
@@ -768,5 +759,5 @@
          !
       END DO
-
+      !
    20 CONTINUE      ! Label 20 is the exit point from the factor search loop.
       !
@@ -776,26 +767,24 @@
 
    SUBROUTINE nemo_northcomms
-      !!======================================================================
+      !!----------------------------------------------------------------------
       !!                     ***  ROUTINE  nemo_northcomms  ***
-      !! nemo_northcomms    :  Setup for north fold exchanges with explicit 
-      !!                       point-to-point messaging
-      !!=====================================================================
-      !!----------------------------------------------------------------------
-      !!
-      !! ** Purpose :   Initialization of the northern neighbours lists.
+      !! ** Purpose :   Setup for north fold exchanges with explicit 
+      !!                point-to-point messaging
+      !!
+      !! ** Method :   Initialization of the northern neighbours lists.
       !!----------------------------------------------------------------------
       !!    1.0  ! 2011-10  (A. C. Coward, NOCS & J. Donners, PRACE)
       !!    2.0  ! 2013-06 Setup avoiding MPI communication (I. Epicoco, S. Mocavero, CMCC) 
       !!----------------------------------------------------------------------
-
       INTEGER  ::   sxM, dxM, sxT, dxT, jn
       INTEGER  ::   njmppmax
-
+      !!----------------------------------------------------------------------
+      !
       njmppmax = MAXVAL( njmppt )
-    
+      !
       !initializes the north-fold communication variables
       isendto(:) = 0
-      nsndto = 0
-
+      nsndto     = 0
+      !
       !if I am a process in the north
       IF ( njmpp == njmppmax ) THEN
@@ -844,4 +833,5 @@
       l_north_nogather = .TRUE.
    END SUBROUTINE nemo_northcomms
+
 #else
    SUBROUTINE nemo_northcomms      ! Dummy routine
@@ -853,3 +843,2 @@
 END MODULE nemogcm
 
-
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/oce.F90	(revision 6041)
@@ -7,4 +7,5 @@
    !!            3.1  !  2009-02  (G. Madec, M. Leclair)  pure z* coordinate
    !!            3.3  !  2010-09  (C. Ethe) TRA-TRC merge: add ts, gtsu, gtsv 4D arrays
+   !!            3.7  !  2014-01  (G. Madec) suppression of curl and before hdiv from in-core memory
    !!----------------------------------------------------------------------
    USE par_oce        ! ocean parameters
@@ -16,14 +17,10 @@
    PUBLIC oce_alloc ! routine called by nemo_init in nemogcm.F90
 
-   LOGICAL, PUBLIC ::   l_traldf_rot = .FALSE.  !: rotated laplacian operator for lateral diffusion
-
    !! dynamics and tracer fields                            ! before ! now    ! after  ! the after trends becomes the fields
    !! --------------------------                            ! fields ! fields ! trends ! only after tra_zdf and dyn_spg
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   ub   ,  un    , ua     !: i-horizontal velocity          [m/s]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   vb   ,  vn    , va     !: j-horizontal velocity          [m/s]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   ua_sv,  va_sv          !: Saved trends (time spliting)   [m/s2]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::           wn             !: vertical velocity              [m/s]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   rotb ,  rotn           !: relative vorticity             [s-1]
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hdivb,  hdivn          !: horizontal divergence          [s-1]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   ub   ,  un    , ua     !: i-horizontal velocity        [m/s]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   vb   ,  vn    , va     !: j-horizontal velocity        [m/s]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::           wn             !: vertical velocity            [m/s]
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::           hdivn          !: horizontal divergence        [s-1]
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   tsb  ,  tsn   , tsa    !: 4D T-S fields                  [Celcius,psu] 
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   rab_b,  rab_n          !: thermal/haline expansion coef. [Celcius-1,psu-1]
@@ -40,4 +37,22 @@
    !
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   spgu, spgv               !: horizontal surface pressure gradient
+
+   !! Specific to split explicit free surface (allocated in dynspg_ts module):
+   !
+   !! Time filtered arrays at baroclinic time step:
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   un_adv, vn_adv    ! Advection vel. at "now" barocl. step
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ub2_b , vb2_b     ! Half step fluxes (ln_bt_fw=T)
+#if defined key_agrif
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ub2_i_b,  vb2_i_b ! Half step time integrated fluxes 
+#endif
+
+   !! Arrays at barotropic time step:                   ! bef before !   before   !    now     !   after    !
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ubb_e    ,    ub_e    ,    un_e    ,    ua_e 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   vbb_e    ,    vb_e    ,    vn_e    ,    va_e 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sshbb_e  ,    sshb_e  ,    sshn_e  ,    ssha_e 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::                              hu_e
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::                              hv_e                                                
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::                              hur_e
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::                              hvr_e 
 
    !! interpolated gradient (only used in zps case)
@@ -73,5 +88,5 @@
 
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 4.0 , NEMO Consortium (2011)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$ 
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -87,16 +102,12 @@
       !
       ALLOCATE( ub   (jpi,jpj,jpk)      , un   (jpi,jpj,jpk)      , ua(jpi,jpj,jpk)       ,     &
-         &      vb   (jpi,jpj,jpk)      , vn   (jpi,jpj,jpk)      , va(jpi,jpj,jpk)       ,     &      
-         &      ua_sv(jpi,jpj,jpk)      , va_sv(jpi,jpj,jpk)      ,                             &      
-         &      wn   (jpi,jpj,jpk)      ,                                                       &
-         &      rotb (jpi,jpj,jpk)      , rotn (jpi,jpj,jpk)      ,                             &   
-         &      hdivb(jpi,jpj,jpk)      , hdivn(jpi,jpj,jpk)      ,                             &
+         &      vb   (jpi,jpj,jpk)      , vn   (jpi,jpj,jpk)      , va(jpi,jpj,jpk)       ,     &          
+         &      wn   (jpi,jpj,jpk)      , hdivn(jpi,jpj,jpk)      ,                             &
          &      tsb  (jpi,jpj,jpk,jpts) , tsn  (jpi,jpj,jpk,jpts) , tsa(jpi,jpj,jpk,jpts) ,     &
          &      rab_b(jpi,jpj,jpk,jpts) , rab_n(jpi,jpj,jpk,jpts) ,                             &
-         &      rn2b (jpi,jpj,jpk)      , rn2  (jpi,jpj,jpk)                              , STAT=ierr(1) )
+         &      rn2b (jpi,jpj,jpk)      , rn2  (jpi,jpj,jpk)      ,                             &
+         &      rhd  (jpi,jpj,jpk)      , rhop (jpi,jpj,jpk)                              , STAT=ierr(1) )
          !
-      ALLOCATE(rhd (jpi,jpj,jpk) ,                                         &
-         &     rhop(jpi,jpj,jpk) ,                                         &
-         &     rke(jpi,jpj,jpk)  ,                                         &
+      ALLOCATE(rke(jpi,jpj,jpk)  ,                                         &
          &     sshb(jpi,jpj)     , sshn(jpi,jpj)   , ssha(jpi,jpj)   ,     &
          &     ub_b(jpi,jpj)     , un_b(jpi,jpj)   , ua_b(jpi,jpj)   ,     &
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/par_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/par_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/par_oce.F90	(revision 6041)
@@ -92,13 +92,4 @@
    INTEGER, PUBLIC  ::   jpij  ! = jpi*jpj                                          !:  jpi x jpj
 
-   !!---------------------------------------------------------------------
-   !! Optimization/control flags
-   !!---------------------------------------------------------------------
-#if defined key_esopa
-   LOGICAL, PUBLIC, PARAMETER ::   lk_esopa     = .TRUE.   !: flag to activate the all options
-#else
-   LOGICAL, PUBLIC, PARAMETER ::   lk_esopa     = .FALSE.  !: flag to activate the all options
-#endif
-
    !!----------------------------------------------------------------------
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/step.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/step.F90	(revision 6041)
@@ -24,6 +24,9 @@
    !!             -   !  2010-10  (C. Ethe, G. Madec) reorganisation of initialisation phase + merge TRC-TRA
    !!            3.4  !  2011-04  (G. Madec, C. Ethe) Merge of dtatem and dtasal
-   !!                 !  2012-07  (J. Simeon, G. Madec, C. Ethe) Online coarsening of outputs
-   !!            3.7  !  2014-04  (F. Roquet, G. Madec) New equations of state
+   !!            3.6  !  2012-07  (J. Simeon, G. Madec. C. Ethe)  Online coarsening of outputs
+   !!            3.6  !  2014-04  (F. Roquet, G. Madec) New equations of state
+   !!            3.7  !  2014-10  (G. Madec)  LDF simplication 
+   !!             -   !  2014-12  (G. Madec) remove KPP scheme
+   !!             -   !  2015-11  (J. Chanut) free surface simplification
    !!----------------------------------------------------------------------
 
@@ -37,5 +40,5 @@
    PRIVATE
 
-   PUBLIC   stp   ! called by opa.F90
+   PUBLIC   stp   ! called by nemogcm.F90
 
    !! * Substitutions
@@ -43,5 +46,5 @@
 !!gm   #  include "zdfddm_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2015)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -69,5 +72,5 @@
       !!              -5- Compute the momentum trends
       !!              -6- Update the horizontal velocity
-      !!              -7- Compute the diagnostics variables (rd,N2, div,cur,w)
+      !!              -7- Compute the diagnostics variables (rd,N2, hdiv,w)
       !!              -8- Outputs and diagnostics
       !!----------------------------------------------------------------------
@@ -76,43 +79,40 @@
       INTEGER ::   kcall    ! optional integer argument (dom_vvl_sf_nxt)
       !! ---------------------------------------------------------------------
-
 #if defined key_agrif
       kstp = nit000 + Agrif_Nb_Step()
-      IF ( lk_agrif_debug ) THEN
-         IF ( Agrif_Root() .and. lwp) Write(*,*) '---'
-         IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp, 'int tstep',Agrif_NbStepint()
-      ENDIF
-
-      IF ( kstp == (nit000 + 1) ) lk_agrif_fstep = .FALSE.
-
+      IF( lk_agrif_debug ) THEN
+         IF( Agrif_Root() .and. lwp)   WRITE(*,*) '---'
+         IF(lwp)   WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint()
+      ENDIF
+      IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE.
 # if defined key_iomput
       IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context )
 # endif
 #endif
-                             indic = 0           ! reset to no error condition
-      IF( kstp == nit000 ) THEN
-         ! must be done after nemo_init for AGRIF+XIOS+OASIS
-                      CALL iom_init(      cxios_context          )  ! iom_put initialization
-         IF( ln_crs ) CALL iom_init( TRIM(cxios_context)//"_crs" )  ! initialize context for coarse grid
-      ENDIF
-
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! update I/O and calendar 
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                             indic = 0                ! reset to no error condition
+                             
+      IF( kstp == nit000 ) THEN                       ! initialize IOM context (must be done after nemo_init for AGRIF+XIOS+OASIS)
+                             CALL iom_init(      cxios_context          )  ! for model grid (including passible AGRIF zoom)
+         IF( ln_crs      )   CALL iom_init( TRIM(cxios_context)//"_crs" )  ! for coarse grid
+      ENDIF
       IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init)
-                             CALL iom_setkt( kstp - nit000 + 1,      cxios_context          )   ! tell iom we are at time step kstp
-      IF( ln_crs     )       CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" )   ! tell iom we are at time step kstp
-
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! Update data, open boundaries, surface boundary condition (including sea-ice)
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( lk_tide    )   CALL sbc_tide( kstp )
-      IF( lk_bdy     )  THEN
-         IF( ln_apr_dyn) CALL sbc_apr( kstp )   ! bdy_dta needs ssh_ib 
-                         CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries
-      ENDIF
-                         CALL sbc    ( kstp )         ! Sea Boundary Condition (including sea-ice)
-                                                      ! clem: moved here for bdy ice purpose
+                             CALL iom_setkt( kstp - nit000 + 1,      cxios_context          )   ! tell IOM we are at time step kstp
+      IF( ln_crs         )   CALL iom_setkt( kstp - nit000 + 1, TRIM(cxios_context)//"_crs" )   ! tell IOM we are at time step kstp
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Update external forcing (tides, open boundaries, and surface boundary condition (including sea-ice)
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_tide    )   CALL sbc_tide( kstp )                   ! update tide potential
+      IF( ln_apr_dyn )   CALL sbc_apr ( kstp )                   ! atmospheric pressure (NB: call before bdy_dta which needs ssh_ib) 
+      IF( lk_bdy     )   CALL bdy_dta ( kstp, time_offset=+1 )   ! update dynamic & tracer data at open boundaries
+                         CALL sbc     ( kstp )                   ! Sea Boundary Condition (including sea-ice)
+
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Update stochastic parameters and random T/S fluctuations
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-                        CALL sto_par( kstp )          ! Stochastic parameters
+                         CALL sto_par( kstp )          ! Stochastic parameters
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
@@ -124,4 +124,5 @@
                          CALL bn2    ( tsb, rab_b, rn2b ) ! before Brunt-Vaisala frequency
                          CALL bn2    ( tsn, rab_n, rn2  ) ! now    Brunt-Vaisala frequency
+
       !
       !  VERTICAL PHYSICS
@@ -131,5 +132,4 @@
       IF( lk_zdftke  )   CALL zdf_tke( kstp )            ! TKE closure scheme for Kz
       IF( lk_zdfgls  )   CALL zdf_gls( kstp )            ! GLS closure scheme for Kz
-      IF( lk_zdfkpp  )   CALL zdf_kpp( kstp )            ! KPP closure scheme for Kz
       IF( lk_zdfcst  ) THEN                              ! Constant Kz (reset avt, avm[uv] to the background value)
          avt (:,:,:) = rn_avt0 * wmask (:,:,:)
@@ -137,6 +137,7 @@
          avmv(:,:,:) = rn_avm0 * wvmask(:,:,:)
       ENDIF
+
       IF( ln_rnf_mouth ) THEN                         ! increase diffusivity at rivers mouths
-         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2.e0 * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO
+         DO jk = 2, nkrnf   ;   avt(:,:,jk) = avt(:,:,jk) + 2._wp * rn_avt_rnf * rnfmsk(:,:) * tmask(:,:,jk)   ;   END DO
       ENDIF
       IF( ln_zdfevd  )   CALL zdf_evd( kstp )         ! enhanced vertical eddy diffusivity
@@ -144,6 +145,5 @@
       IF( lk_zdftmx  )   CALL zdf_tmx( kstp )         ! tidal vertical mixing
 
-      IF( lk_zdfddm .AND. .NOT. lk_zdfkpp )   &
-         &               CALL zdf_ddm( kstp )         ! double diffusive mixing
+      IF( lk_zdfddm  )   CALL zdf_ddm( kstp )         ! double diffusive mixing
 
                          CALL zdf_mxl( kstp )         ! mixed layer depth
@@ -155,87 +155,92 @@
       !  LATERAL  PHYSICS
       !
-      IF( lk_ldfslp ) THEN                            ! slope of lateral mixing
+      IF( l_ldfslp ) THEN                             ! slope of lateral mixing
+!!gm : why this here ????
          IF(ln_sto_eos ) CALL sto_pts( tsn )          ! Random T/S fluctuations
+!!gm
                          CALL eos( tsb, rhd, gdept_0(:,:,:) )               ! before in situ density
+
          IF( ln_zps .AND. .NOT. ln_isfcav)                               &
             &            CALL zps_hde    ( kstp, jpts, tsb, gtsu, gtsv,  &  ! Partial steps: before horizontal gradient
             &                                          rhd, gru , grv    )  ! of t, s, rd at the last ocean level
+
          IF( ln_zps .AND.       ln_isfcav)                               &
-            &            CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
+            &            CALL zps_hde_isf( kstp, jpts, tsb, gtsu, gtsv, gtui, gtvi,   &    ! Partial steps for top cell (ISF)
             &                                          rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-            &                                   gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the first ocean level
-         IF( ln_traldf_grif ) THEN                           ! before slope for Griffies operator
-                         CALL ldf_slp_grif( kstp )
-         ELSE
-                         CALL ldf_slp( kstp, rhd, rn2b )     ! before slope for Madec operator
+            &                                   grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the first ocean level
+
+         IF( ln_traldf_triad ) THEN 
+                         CALL ldf_slp_triad( kstp )                       ! before slope for triad operator
+         ELSE     
+                         CALL ldf_slp     ( kstp, rhd, rn2b )             ! before slope for standard operator
          ENDIF
       ENDIF
-#if defined key_traldf_c2d
-      IF( lk_traldf_eiv )   CALL ldf_eiv( kstp )      ! eddy induced velocity coefficient
-#endif
-#if defined key_traldf_c3d && defined key_traldf_smag
-                          CALL ldf_tra_smag( kstp )      ! eddy induced velocity coefficient
-#  endif
-#if defined key_dynldf_c3d && defined key_dynldf_smag
-                          CALL ldf_dyn_smag( kstp )      ! eddy induced velocity coefficient
-#  endif
-
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      !  Ocean dynamics : hdiv, rot, ssh, e3, wn
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL ssh_nxt       ( kstp )  ! after ssh (includes call to div_cur)
+      !                                               ! eddy diffusivity coeff. and/or eiv coeff.
+      IF( l_ldftra_time .OR. l_ldfeiv_time )   CALL ldf_tra( kstp ) 
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      !  Ocean dynamics : hdiv, ssh, e3, u, v, w
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+
+                         CALL ssh_nxt       ( kstp )  ! after ssh (includes call to div_hor)
       IF( lk_vvl     )   CALL dom_vvl_sf_nxt( kstp )  ! after vertical scale factors 
                          CALL wzv           ( kstp )  ! now cross-level velocity 
 
-      IF( lk_dynspg_ts ) THEN 
-          ! In case the time splitting case, update almost all momentum trends here:
-          ! Note that the computation of vertical velocity above, hence "after" sea level
-          ! is necessary to compute momentum advection for the rhs of barotropic loop:
-            IF(ln_sto_eos ) CALL sto_pts( tsn )                             ! Random T/S fluctuations
-                            CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation
-            IF( ln_zps .AND. .NOT. ln_isfcav)                               &
-               &            CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient
-               &                                          rhd, gru , grv    )  ! of t, s, rd at the last ocean level
-            IF( ln_zps .AND.       ln_isfcav)                               &
-               &            CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
+!!gm : why also here ????
+      IF(ln_sto_eos  )   CALL sto_pts( tsn )                             ! Random T/S fluctuations
+!!gm
+                         CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) ) ! now in situ density for hpg computation
+
+!!jc: fs simplification
+!!jc: lines below are useless if lk_vvl=T. Keep them here (which maintains a bug if lk_vvl=F and ln_zps=T, cf ticket #1636) 
+!!                                         but ensures reproductible results
+!!                                         with previous versions using split-explicit free surface          
+            IF( ln_zps .AND. .NOT. ln_isfcav)   &                           ! Partial steps: bottom before horizontal gradient
+               &            CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &  ! of t, s, rd at the last ocean level
+               &                                          rhd, gru , grv    )
+            IF( ln_zps .AND.       ln_isfcav)   &                           ! Partial steps: top & bottom before horizontal gradient
+               &            CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv, gtui, gtvi,   & 
                &                                          rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-               &                                   gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level
-
-                                  ua(:,:,:) = 0.e0             ! set dynamics trends to zero
-                                  va(:,:,:) = 0.e0
-          IF(  lk_asminc .AND. ln_asmiau .AND. &
-             & ln_dyninc       )  CALL dyn_asm_inc  ( kstp )   ! apply dynamics assimilation increment
-          IF( ln_neptsimp )       CALL dyn_nept_cor ( kstp )   ! subtract Neptune velocities (simplified)
-          IF( lk_bdy           )  CALL bdy_dyn3d_dmp( kstp )   ! bdy damping trends
-                                  CALL dyn_adv      ( kstp )   ! advection (vector or flux form)
-                                  CALL dyn_vor      ( kstp )   ! vorticity term including Coriolis
-                                  CALL dyn_ldf      ( kstp )   ! lateral mixing
-          IF( ln_neptsimp )       CALL dyn_nept_cor ( kstp )   ! add Neptune velocities (simplified)
-#if defined key_agrif
-          IF(.NOT. Agrif_Root())  CALL Agrif_Sponge_dyn        ! momentum sponge
-#endif
-                                  CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
-                                  CALL dyn_spg( kstp, indic )  ! surface pressure gradient
-
-                                  ua_sv(:,:,:) = ua(:,:,:)     ! Save trends (barotropic trend has been fully updated at this stage)
-                                  va_sv(:,:,:) = va(:,:,:)
-
-                                  CALL div_cur( kstp )         ! Horizontal divergence & Relative vorticity (2nd call in time-split case)
-          IF( lk_vvl     )        CALL dom_vvl_sf_nxt( kstp, kcall=2 )  ! after vertical scale factors (update depth average component)
-                                  CALL wzv           ( kstp )  ! now cross-level velocity 
-      ENDIF
-
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! diagnostics and outputs             (ua, va, tsa used as workspace)
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( lk_floats  )      CALL flo_stp( kstp )         ! drifting Floats
-      IF( lk_diahth  )      CALL dia_hth( kstp )         ! Thermocline depth (20 degres isotherm depth)
-      IF( .NOT. ln_cpl )    CALL dia_fwb( kstp )         ! Fresh water budget diagnostics
-      IF( lk_diadct  )      CALL dia_dct( kstp )         ! Transports
-      IF( lk_diaar5  )      CALL dia_ar5( kstp )         ! ar5 diag
-      IF( lk_diaharm )      CALL dia_harm( kstp )        ! Tidal harmonic analysis
-                            CALL dia_wri( kstp )         ! ocean model: outputs
-      !
-      IF( ln_crs     )      CALL crs_fld( kstp )         ! ocean model: online field coarsening & output
+               &                                               grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    )
+!!jc: fs simplification
+                            
+                         ua(:,:,:) = 0._wp            ! set dynamics trends to zero
+                         va(:,:,:) = 0._wp
+
+      IF(  lk_asminc .AND. ln_asmiau .AND. ln_dyninc )   &
+                         CALL dyn_asm_inc   ( kstp )  ! apply dynamics assimilation increment
+      IF( lk_bdy     )   CALL bdy_dyn3d_dmp ( kstp )  ! bdy damping trends
+#if defined key_agrif
+      IF(.NOT. Agrif_Root())  & 
+               &         CALL Agrif_Sponge_dyn        ! momentum sponge
+#endif
+                         CALL dyn_adv       ( kstp )  ! advection (vector or flux form)
+                         CALL dyn_vor       ( kstp )  ! vorticity term including Coriolis
+                         CALL dyn_ldf       ( kstp )  ! lateral mixing
+                         CALL dyn_hpg       ( kstp )  ! horizontal gradient of Hydrostatic pressure
+                         CALL dyn_spg       ( kstp )  ! surface pressure gradient
+
+                                                      ! With split-explicit free surface, since now transports have been updated and ssha as well
+      IF( ln_dynspg_ts ) THEN                         ! vertical scale factors and vertical velocity need to be updated
+                            CALL div_hor    ( kstp )              ! Horizontal divergence  (2nd call in time-split case)
+         IF( lk_vvl )       CALL dom_vvl_sf_nxt( kstp, kcall=2 )  ! after vertical scale factors (update depth average component)
+                            CALL wzv        ( kstp )              ! now cross-level velocity 
+      ENDIF
+
+                         CALL dyn_bfr       ( kstp )  ! bottom friction
+                         CALL dyn_zdf       ( kstp )  ! vertical diffusion
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! diagnostics and outputs             
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+      IF( lk_floats  )   CALL flo_stp       ( kstp )  ! drifting Floats
+      IF( lk_diahth  )   CALL dia_hth       ( kstp )  ! Thermocline depth (20 degres isotherm depth)
+      IF(.NOT.ln_cpl )   CALL dia_fwb       ( kstp )  ! Fresh water budget diagnostics
+      IF( lk_diadct  )   CALL dia_dct       ( kstp )  ! Transports
+      IF( lk_diaar5  )   CALL dia_ar5       ( kstp )  ! ar5 diag
+      IF( lk_diaharm )   CALL dia_harm      ( kstp )  ! Tidal harmonic analysis
+                         CALL dia_wri       ( kstp )  ! ocean model: outputs
+      !
+      IF( ln_crs     )   CALL crs_fld       ( kstp )  ! ocean model: online field coarsening & output
 
 #if defined key_top
@@ -243,102 +248,62 @@
       ! Passive Tracer Model
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                         CALL trc_stp( kstp )         ! time-stepping
-#endif
-
-
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! Active tracers                              (ua, va used as workspace)
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                             tsa(:,:,:,:) = 0.e0            ! set tracer trends to zero
+                         CALL trc_stp       ( kstp )  ! time-stepping
+#endif
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Active tracers                              
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+                         tsa(:,:,:,:) = 0._wp         ! set tracer trends to zero
 
       IF(  lk_asminc .AND. ln_asmiau .AND. &
-         & ln_trainc     )   CALL tra_asm_inc( kstp )       ! apply tracer assimilation increment
-                             CALL tra_sbc    ( kstp )       ! surface boundary condition
-      IF( ln_traqsr      )   CALL tra_qsr    ( kstp )       ! penetrative solar radiation qsr
-      IF( ln_trabbc      )   CALL tra_bbc    ( kstp )       ! bottom heat flux
-      IF( lk_trabbl      )   CALL tra_bbl    ( kstp )       ! advective (and/or diffusive) bottom boundary layer scheme
-      IF( ln_tradmp      )   CALL tra_dmp    ( kstp )       ! internal damping trends
-      IF( lk_bdy         )   CALL bdy_tra_dmp( kstp )       ! bdy damping trends
-                             CALL tra_adv    ( kstp )       ! horizontal & vertical advection
-      IF( lk_zdfkpp      )   CALL tra_kpp    ( kstp )       ! KPP non-local tracer fluxes
-                             CALL tra_ldf    ( kstp )       ! lateral mixing
-
-      IF( ln_diaptr      )   CALL dia_ptr                   ! Poleward adv/ldf TRansports diagnostics
-
-#if defined key_agrif
-      IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_tra          ! tracers sponge
-#endif
-                             CALL tra_zdf    ( kstp )       ! vertical mixing and after tracer fields
-
-      IF( ln_dynhpg_imp  ) THEN                             ! semi-implicit hpg (time stepping then eos)
-         IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
-                             CALL tra_nxt( kstp )                ! tracer fields at next time step
-            IF( ln_sto_eos ) CALL sto_pts( tsn )                 ! Random T/S fluctuations
-                             CALL eos    ( tsa, rhd, rhop, fsdept_n(:,:,:) )  ! Time-filtered in situ density for hpg computation
-            IF( ln_zps .AND. .NOT. ln_isfcav)                                &
-               &             CALL zps_hde    ( kstp, jpts, tsa, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient
-               &                                           rhd, gru , grv    )  ! of t, s, rd at the last ocean level
-            IF( ln_zps .AND.       ln_isfcav)                                &
-               &             CALL zps_hde_isf( kstp, jpts, tsa, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
-               &                                           rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-               &                                    gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level
-      ELSE                                                  ! centered hpg  (eos then time stepping)
-         IF ( .NOT. lk_dynspg_ts ) THEN                     ! eos already called in time-split case
-            IF( ln_sto_eos ) CALL sto_pts( tsn )    ! Random T/S fluctuations
-                             CALL eos    ( tsn, rhd, rhop, fsdept_n(:,:,:) )  ! now in situ density for hpg computation
-         IF( ln_zps .AND. .NOT. ln_isfcav)                                   &
-               &             CALL zps_hde    ( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps: before horizontal gradient
-               &                                           rhd, gru , grv    )  ! of t, s, rd at the last ocean level
-         IF( ln_zps .AND.       ln_isfcav)                                   & 
-               &             CALL zps_hde_isf( kstp, jpts, tsn, gtsu, gtsv,  &    ! Partial steps for top cell (ISF)
-               &                                           rhd, gru , grv , aru , arv , gzu , gzv , ge3ru , ge3rv ,   &
-               &                                    gtui, gtvi, grui, grvi, arui, arvi, gzui, gzvi, ge3rui, ge3rvi    ) ! of t, s, rd at the last ocean level
-         ENDIF
-         IF( ln_zdfnpc   )   CALL tra_npc( kstp )                ! update after fields by non-penetrative convection
-                             CALL tra_nxt( kstp )                ! tracer fields at next time step
-      ENDIF
-
-      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-      ! Dynamics                                    (tsa used as workspace)
-      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( lk_dynspg_ts   )  THEN
-                                                             ! revert to previously computed momentum tendencies
-                                                             ! (not using ua, va as temporary arrays during tracers' update could avoid that)
-                               ua(:,:,:) = ua_sv(:,:,:)
-                               va(:,:,:) = va_sv(:,:,:)
-                                                             ! Revert now divergence and rotational to previously computed ones 
-                                                             !(needed because of the time swap in div_cur, at the beginning of each time step)
-                               hdivn(:,:,:) = hdivb(:,:,:)
-                               rotn(:,:,:)  = rotb(:,:,:) 
-
-                               CALL dyn_bfr( kstp )         ! bottom friction
-                               CALL dyn_zdf( kstp )         ! vertical diffusion
-      ELSE
-                               ua(:,:,:) = 0.e0             ! set dynamics trends to zero
-                               va(:,:,:) = 0.e0
-
-        IF(  lk_asminc .AND. ln_asmiau .AND. &
-           & ln_dyninc      )  CALL dyn_asm_inc( kstp )     ! apply dynamics assimilation increment
-        IF( ln_bkgwri )        CALL asm_bkg_wri( kstp )     ! output background fields
-        IF( ln_neptsimp )      CALL dyn_nept_cor( kstp )    ! subtract Neptune velocities (simplified)
-        IF( lk_bdy          )  CALL bdy_dyn3d_dmp(kstp )    ! bdy damping trends
-                               CALL dyn_adv( kstp )         ! advection (vector or flux form)
-                               CALL dyn_vor( kstp )         ! vorticity term including Coriolis
-                               CALL dyn_ldf( kstp )         ! lateral mixing
-        IF( ln_neptsimp )      CALL dyn_nept_cor( kstp )    ! add Neptune velocities (simplified)
-#if defined key_agrif
-        IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_dyn        ! momemtum sponge
-#endif
-                               CALL dyn_hpg( kstp )         ! horizontal gradient of Hydrostatic pressure
-                               CALL dyn_bfr( kstp )         ! bottom friction
-                               CALL dyn_zdf( kstp )         ! vertical diffusion
-                               CALL dyn_spg( kstp, indic )  ! surface pressure gradient
-      ENDIF
-                               CALL dyn_nxt( kstp )         ! lateral velocity at next time step
-
-                               CALL ssh_swp( kstp )         ! swap of sea surface height
-      IF( lk_vvl           )   CALL dom_vvl_sf_swp( kstp )  ! swap of vertical scale factors
-      !
-      IF( lrst_oce         )   CALL rst_write( kstp )       ! write output ocean restart file
+         & ln_trainc )   CALL tra_asm_inc   ( kstp )  ! apply tracer assimilation increment
+                         CALL tra_sbc       ( kstp )  ! surface boundary condition
+      IF( ln_traqsr  )   CALL tra_qsr       ( kstp )  ! penetrative solar radiation qsr
+      IF( ln_trabbc  )   CALL tra_bbc       ( kstp )  ! bottom heat flux
+      IF( lk_trabbl  )   CALL tra_bbl       ( kstp )  ! advective (and/or diffusive) bottom boundary layer scheme
+      IF( ln_tradmp  )   CALL tra_dmp       ( kstp )  ! internal damping trends
+      IF( lk_bdy     )   CALL bdy_tra_dmp   ( kstp )  ! bdy damping trends
+#if defined key_agrif
+      IF(.NOT. Agrif_Root())  & 
+               &         CALL Agrif_Sponge_tra        ! tracers sponge
+#endif
+                         CALL tra_adv       ( kstp )  ! horizontal & vertical advection
+                         CALL tra_ldf       ( kstp )  ! lateral mixing
+
+!!gm : why CALL to dia_ptr has been moved here??? (use trends info?)
+      IF( ln_diaptr  )   CALL dia_ptr                 ! Poleward adv/ldf TRansports diagnostics
+!!gm
+                         CALL tra_zdf       ( kstp )  ! vertical mixing and after tracer fields
+      IF( ln_zdfnpc  )   CALL tra_npc       ( kstp )  ! update after fields by non-penetrative convection
+
+      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+      ! Set boundary conditions and Swap
+      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+!!jc1: For agrif, it would be much better to finalize tracers/momentum here (e.g. bdy conditions) and move the swap 
+!!    (and time filtering) after Agrif update. Then restart would be done after and would contain updated fields. 
+!!    If so: 
+!!    (i) no need to call agrif update at initialization time
+!!    (ii) no need to update "before" fields 
+!!
+!!    Apart from creating new tra_swp/dyn_swp routines, this however: 
+!!    (i) makes boundary conditions at initialization time computed from updated fields which is not the case between 
+!!    two restarts => restartability issue. One can circumvent this, maybe, by assuming "interface separation", 
+!!    e.g. a shift of the feedback interface inside child domain. 
+!!    (ii) requires that all restart outputs of updated variables by agrif (e.g. passive tracers/tke/barotropic arrays) are done at the same
+!!    place.
+!! 
+!!jc2: dynnxt must be the latest call. fse3t_b are indeed updated in that routine
+                         CALL tra_nxt       ( kstp )  ! finalize (bcs) tracer fields at next time step and swap
+                         CALL dyn_nxt       ( kstp )  ! finalize (bcs) velocities at next time step and swap
+                         CALL ssh_swp       ( kstp )  ! swap of sea surface height
+      IF( lk_vvl     )   CALL dom_vvl_sf_swp( kstp )  ! swap of vertical scale factors
+      !
+
+!!gm : This does not only concern the dynamics ==>>> add a new title
+!!gm2: why ouput restart before AGRIF update?
+!!
+!!jc: That would be better, but see comment above
+!!
+      IF( lrst_oce   )   CALL rst_write     ( kstp )  ! write output ocean restart file
 
 #if defined key_agrif
@@ -346,26 +311,28 @@
       ! AGRIF
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<      
-                               CALL Agrif_Integrate_ChildGrids( stp )  
-
-      IF ( Agrif_NbStepint().EQ.0 ) THEN
-                               CALL Agrif_Update_Tra()      ! Update active tracers
-                               CALL Agrif_Update_Dyn()      ! Update momentum
-      ENDIF
-#endif
-      IF( ln_diahsb        )   CALL dia_hsb( kstp )         ! - ML - global conservation diagnostics
-      IF( lk_diaobs  )         CALL dia_obs( kstp )         ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
+                         CALL Agrif_Integrate_ChildGrids( stp )  
+
+      IF ( Agrif_NbStepint().EQ.0 ) THEN              ! AGRIF Update 
+!!jc in fact update i useless at last time step, but do it for global diagnostics
+                         CALL Agrif_Update_Tra()      ! Update active tracers
+                         CALL Agrif_Update_Dyn()      ! Update momentum
+      ENDIF
+#endif
+      IF( ln_diahsb  )   CALL dia_hsb       ( kstp )  ! - ML - global conservation diagnostics
+      IF( lk_diaobs  )   CALL dia_obs       ( kstp )  ! obs-minus-model (assimilation) diagnostics (call after dynamics update)
 
       !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
       ! Control
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-                               CALL stp_ctl( kstp, indic )
-      IF( indic < 0        )   THEN
-                               CALL ctl_stop( 'step: indic < 0' )
-                               CALL dia_wri_state( 'output.abort', kstp )
-      ENDIF
-      IF( kstp == nit000   )   THEN
+                         CALL stp_ctl       ( kstp, indic )
+      IF( indic < 0  )   THEN
+                         CALL ctl_stop( 'step: indic < 0' )
+                         CALL dia_wri_state( 'output.abort', kstp )
+      ENDIF
+      IF( kstp == nit000 )   THEN
                  CALL iom_close( numror )     ! close input  ocean restart file
          IF(lwm) CALL FLUSH    ( numond )     ! flush output namelist oce
-         IF( lwm.AND.numoni /= -1 ) CALL FLUSH    ( numoni )     ! flush output namelist ice
+         IF(lwm.AND.numoni /= -1 )   &
+            &    CALL FLUSH    ( numoni )     ! flush output namelist ice (if exist)
       ENDIF
 
@@ -373,5 +340,6 @@
       ! Coupled mode
       !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-      IF( lk_oasis         )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
+!!gm why lk_oasis and not lk_cpl ????
+      IF( lk_oasis   )   CALL sbc_cpl_snd( kstp )     ! coupled mode : field exchanges
       !
 #if defined key_iomput
@@ -383,5 +351,4 @@
       !
       IF( nn_timing == 1 .AND.  kstp == nit000  )   CALL timing_reset
-      !     
       !
    END SUBROUTINE stp
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/step_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/step_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/step_oce.F90	(revision 6041)
@@ -4,28 +4,19 @@
    !! Ocean time-stepping : module used in both initialisation phase and time stepping
    !!======================================================================
-   !! History :   3.3  ! 2010-08  (C. Ethe)  Original code - reorganisation of the initial phase
+   !! History :   3.3  !  2010-08  (C. Ethe)  Original code - reorganisation of the initial phase
+   !!             3.7  !  2014-01  (G. Madec) LDF simplication 
    !!----------------------------------------------------------------------
    USE oce              ! ocean dynamics and tracers variables
    USE dom_oce          ! ocean space and time domain variables
    USE zdf_oce          ! ocean vertical physics variables
-   USE ldftra_oce       ! ocean tracer   - trends
-   USE ldfdyn_oce       ! ocean dynamics - trends
-   USE divcur           ! hor. divergence and curl      (div & cur routines)
-   USE in_out_manager   ! I/O manager
-   USE iom              !
-   USE lbclnk
-   USE restart          ! restart
-#if defined key_iomput
-   USE xios
-#endif
 
    USE daymod           ! calendar                         (day     routine)
 
+   USE sbc_oce          ! surface boundary condition: ocean
    USE sbcmod           ! surface boundary condition       (sbc     routine)
    USE sbcrnf           ! surface boundary condition: runoff variables
    USE sbccpl           ! surface boundary condition: coupled formulation (call send at end of step)
-   USE sbc_oce          ! surface boundary condition: ocean
+   USE sbcapr           ! surface boundary condition: atmospheric pressure
    USE sbctide          ! Tide initialisation
-   USE sbcapr           ! surface boundary condition: ssh_ib required by bdydta 
 
    USE traqsr           ! solar radiation penetration      (tra_qsr routine)
@@ -36,5 +27,4 @@
    USE traadv           ! advection scheme control     (tra_adv_ctl routine)
    USE traldf           ! lateral mixing                   (tra_ldf routine)
-   !   zdfkpp           ! KPP non-local tracer fluxes      (tra_kpp routine)
    USE trazdf           ! vertical mixing                  (tra_zdf routine)
    USE tranxt           ! time-stepping                    (tra_nxt routine)
@@ -43,4 +33,5 @@
    USE eosbn2           ! equation of state                (eos_bn2 routine)
 
+   USE divhor           ! horizontal divergence            (div_hor routine)
    USE dynadv           ! advection                        (dyn_adv routine)
    USE dynbfr           ! Bottom friction terms            (dyn_bfr routine)
@@ -49,7 +40,5 @@
    USE dynldf           ! lateral momentum diffusion       (dyn_ldf routine)
    USE dynzdf           ! vertical diffusion               (dyn_zdf routine)
-   USE dynspg_oce       ! surface pressure gradient        (dyn_spg routine)
    USE dynspg           ! surface pressure gradient        (dyn_spg routine)
-   USE dynnept          ! simp. form of Neptune effect(dyn_nept_cor routine)
 
    USE dynnxt           ! time-stepping                    (dyn_nxt routine)
@@ -71,7 +60,6 @@
 
    USE ldfslp           ! iso-neutral slopes               (ldf_slp routine)
-   USE ldfeiv           ! eddy induced velocity coef.      (ldf_eiv routine)
-   USE ldftra_smag      ! Smagirinsky diffusion            (ldftra_smag routine)
-   USE ldfdyn_smag      ! Smagorinsky viscosity            (ldfdyn_smag routine) 
+   USE ldfdyn           ! lateral eddy viscosity coef.     (ldf_dyn routine)
+   USE ldftra           ! lateral eddy diffusive coef.     (ldf_tra routine)
 
    USE zdftmx           ! tide-induced vertical mixing     (zdf_tmx routine)
@@ -79,5 +67,4 @@
    USE zdftke           ! TKE vertical mixing              (zdf_tke routine)
    USE zdfgls           ! GLS vertical mixing              (zdf_gls routine)
-   USE zdfkpp           ! KPP vertical mixing              (zdf_kpp routine)
    USE zdfddm           ! double diffusion mixing          (zdf_ddm routine)
    USE zdfevd           ! enhanced vertical diffusion      (zdf_evd routine)
@@ -104,10 +91,17 @@
    USE asmbkg
    USE stpctl           ! time stepping control            (stp_ctl routine)
+   USE restart          ! ocean restart                    (rst_wri routine)
    USE prtctl           ! Print control                    (prt_ctl routine)
 
    USE diaobs           ! Observation operator
 
+   USE in_out_manager   ! I/O manager
+   USE iom              !
+   USE lbclnk
    USE timing           ! Timing
 
+#if defined key_iomput
+   USE xios
+#endif
 #if defined key_agrif
    USE agrif_opa_sponge ! Momemtum and tracers sponges
@@ -118,5 +112,5 @@
 #endif
    !!----------------------------------------------------------------------
-   !! NEMO/OPA 3.3 , NEMO Consortium (2010)
+   !! NEMO/OPA 3.7 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/stpctl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 6041)
@@ -16,9 +16,7 @@
    USE oce             ! ocean dynamics and tracers variables
    USE dom_oce         ! ocean space and time domain variables 
-   USE sol_oce         ! ocean space and time domain variables 
    USE in_out_manager  ! I/O manager
    USE lbclnk          ! ocean lateral boundary conditions (or mpp link)
    USE lib_mpp         ! distributed memory computing
-   USE dynspg_oce      ! pressure gradient schemes 
    USE c1d             ! 1D vertical configuration
 
@@ -43,6 +41,5 @@
       !! ** Method  : - Save the time step in numstp
       !!              - Print it each 50 time steps
-      !!              - Print solver statistics in numsol 
-      !!              - Stop the run IF problem for the solver ( indec < 0 )
+      !!              - Stop the run IF problem ( indic < 0 )
       !!
       !! ** Actions :   'time.step' file containing the last ocean time-step
@@ -50,5 +47,5 @@
       !!----------------------------------------------------------------------
       INTEGER, INTENT( in ) ::   kt         ! ocean time-step index
-      INTEGER, INTENT( inout ) ::   kindic  ! indicator of solver convergence
+      INTEGER, INTENT( inout ) ::   kindic  ! error indicator
       !!
       INTEGER  ::   ji, jj, jk              ! dummy loop indices
@@ -143,32 +140,15 @@
       IF( lk_c1d )  RETURN          ! No log file in case of 1D vertical configuration
 
-      ! log file (solver or ssh statistics)
-      ! --------
-      IF( lk_dynspg_flt ) THEN      ! elliptic solver statistics (if required)
-         !
-         IF(lwp) WRITE(numsol,9200) kt, niter, res, SQRT(epsr)/eps       ! Solver
-         !
-         IF( kindic < 0 .AND. zsmin > 0.e0 .AND. zumax <= 20.e0 ) THEN   ! create a abort file if problem found 
-            IF(lwp) THEN
-               WRITE(numout,*) ' stpctl: the elliptic solver DO not converge or explode'
-               WRITE(numout,*) ' ====== '
-               WRITE(numout,9200) kt, niter, res, sqrt(epsr)/eps
-               WRITE(numout,*)
-               WRITE(numout,*) ' stpctl: output of last fields'
-               WRITE(numout,*) ' ======  '
-            ENDIF
-         ENDIF
-         !
-      ELSE                                   !* ssh statistics (and others...)
-         IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file)
-            CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
-         ENDIF
-         !
-         zssh2 = SUM( sshn(:,:) * sshn(:,:) * tmask_i(:,:) )
-         IF( lk_mpp )   CALL mpp_sum( zssh2 )      ! sum over the global domain
-         !
-         IF(lwp) WRITE(numsol,9300) kt, zssh2, zumax, zsmin      ! ssh statistics
-         !
+      ! log file (ssh statistics)
+      ! --------                                   !* ssh statistics (and others...)
+      IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file)
+         CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea )
       ENDIF
+      !
+      zssh2 = SUM( sshn(:,:) * sshn(:,:) * tmask_i(:,:) )
+      IF( lk_mpp )   CALL mpp_sum( zssh2 )      ! sum over the global domain
+      !
+      IF(lwp) WRITE(numsol,9300) kt, zssh2, zumax, zsmin      ! ssh statistics
+      !
 
 9200  FORMAT('it:', i8, ' iter:', i4, ' r: ',e16.10, ' b: ',e16.10 )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/SAS_SRC/diawri.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/SAS_SRC/diawri.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/SAS_SRC/diawri.F90	(revision 6041)
@@ -26,8 +26,4 @@
    USE dom_oce         ! ocean space and time domain
    USE zdf_oce         ! ocean vertical physics
-   USE ldftra_oce      ! ocean active tracers: lateral physics
-   USE ldfdyn_oce      ! ocean dynamics: lateral physics
-   USE traldf_iso_grif, ONLY : psix_eiv, psiy_eiv
-   USE sol_oce         ! solver variables
    USE sbc_oce         ! Surface boundary condition: ocean fields
    USE sbc_ice         ! Surface boundary condition: ice fields
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/C14b/trcsms_c14b.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/C14b/trcsms_c14b.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/C14b/trcsms_c14b.F90	(revision 6041)
@@ -50,6 +50,5 @@
 
    !! * Substitutions
-#  include "top_substitute.h90"
-
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/C14b/trcwri_c14b.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/C14b/trcwri_c14b.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/C14b/trcwri_c14b.F90	(revision 6041)
@@ -20,5 +20,4 @@
    PUBLIC trc_wri_c14b 
 
-#  include "top_substitute.h90"
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/CFC/trcsms_cfc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/CFC/trcsms_cfc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/CFC/trcsms_cfc.F90	(revision 6041)
@@ -51,5 +51,5 @@
 
    !! * Substitutions
-#  include "top_substitute.h90"
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/CFC/trcwri_cfc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/CFC/trcwri_cfc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/CFC/trcwri_cfc.F90	(revision 6041)
@@ -20,5 +20,4 @@
    PUBLIC trc_wri_cfc 
 
-#  include "top_substitute.h90"
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/MY_TRC/trcwri_my_trc.F90	(revision 6041)
@@ -20,5 +20,4 @@
    PUBLIC trc_wri_my_trc 
 
-#  include "top_substitute.h90"
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zbio.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zbio.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zbio.F90	(revision 6041)
@@ -59,6 +59,7 @@
    REAL(wp) ::   fdbod      ! zooplankton mortality fraction that goes to detritus
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zexp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zexp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zexp.F90	(revision 6041)
@@ -41,6 +41,7 @@
    REAL(wp)                                ::   areacot   !: surface coastal area
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zopt.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zopt.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zopt.F90	(revision 6041)
@@ -40,6 +40,6 @@
    REAL(wp), PUBLIC ::  reddom    ! redfield ratio (C:N) for DOM
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zsed.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zsed.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P2Z/p2zsed.F90	(revision 6041)
@@ -34,6 +34,6 @@
    REAL(wp), PUBLIC ::   xhr         ! coeff for martin''s remineralisation profile
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zbio.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zbio.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zbio.F90	(revision 6041)
@@ -34,6 +34,6 @@
    PUBLIC  p4z_bio    
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zche.F90	(revision 6041)
@@ -164,6 +164,6 @@
    REAL(wp) :: devk55  = 0.3692E-3      
 
-   !!* Substitution
-#include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -195,7 +195,5 @@
       ! CHEMICAL CONSTANTS - SURFACE LAYER
       ! ----------------------------------
-!CDIR NOVERRCHK
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             !                             ! SET ABSOLUTE TEMPERATURE
@@ -227,9 +225,6 @@
       ! OXYGEN SOLUBILITY - DEEP OCEAN
       ! -------------------------------
-!CDIR NOVERRCHK
       DO jk = 1, jpk
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
               ztkel = tsn(ji,jj,jk,jp_tem) + 273.16
@@ -252,9 +247,6 @@
       ! CHEMICAL CONSTANTS - DEEP OCEAN
       ! -------------------------------
-!CDIR NOVERRCHK
       DO jk = 1, jpk
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zfechem.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zfechem.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zfechem.F90	(revision 6041)
@@ -39,6 +39,6 @@
    REAL(wp) :: kl1, kl2, kb1, kb2, ks, kpr, spd, con, kth
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -113,9 +113,6 @@
          ! Chemistry is supposed to be fast enough to be at equilibrium
          ! ------------------------------------------------------------
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   ! Calculate ligand concentrations : assume 2/3rd of excess goes to
@@ -195,9 +192,6 @@
          ! Chemistry is supposed to be fast enough to be at equilibrium
          ! ------------------------------------------------------------
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   zTL1(ji,jj,jk) = ztotlig(ji,jj,jk)
@@ -216,11 +210,9 @@
          !
       ENDIF
-
+      !
       zdust = 0.         ! if no dust available
-!CDIR NOVERRCHK
+      !
       DO jk = 1, jpkm1
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                zstep = xstep
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zflx.F90	(revision 6041)
@@ -59,6 +59,6 @@
    REAL(wp) ::  xconv  = 0.01_wp / 3600._wp !: coefficients for conversion 
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -122,7 +122,5 @@
 
       DO jm = 1, 10
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
 
@@ -155,7 +153,5 @@
       ! -------------------------------------------
 
-!CDIR NOVERRCHK
       DO jj = 1, jpj
-!CDIR NOVERRCHK
          DO ji = 1, jpi
             ztc  = MIN( 35., tsn(ji,jj,1,jp_tem) )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlim.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlim.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlim.F90	(revision 6041)
@@ -52,6 +52,5 @@
    REAL(wp) ::  xcoef2   = 1.21E-5 * 14. / 55.85 / 7.625 * 0.5 * 1.5
    REAL(wp) ::  xcoef3   = 1.15E-4 * 14. / 55.85 / 7.625 * 0.5 
-   !!* Substitution
-#  include "top_substitute.h90"
+
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zlys.F90	(revision 6041)
@@ -80,9 +80,6 @@
       DO jn = 1, 5                               !  BEGIN OF ITERATION
          !
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   zfact = rhop(ji,jj,jk) / 1000. + rtrn
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmeso.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmeso.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmeso.F90	(revision 6041)
@@ -50,6 +50,4 @@
    REAL(wp), PUBLIC ::  grazflux     !: mesozoo flux feeding rate
 
-   !!* Substitution
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmicro.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmicro.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmicro.F90	(revision 6041)
@@ -49,6 +49,4 @@
 
 
-   !!* Substitution
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmort.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmort.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zmort.F90	(revision 6041)
@@ -35,6 +35,4 @@
 
 
-   !!* Substitution
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zopt.F90	(revision 6041)
@@ -51,6 +51,6 @@
    REAL(wp), DIMENSION(3,61), PUBLIC ::   xkrgb   !: tabulated attenuation coefficients for RGB absorption
    
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -95,7 +95,5 @@
       !                                        !* attenuation coef. function of Chlorophyll and wavelength (Red-Green-Blue)
       DO jk = 1, jpkm1                         !  --------------------------------------------------------
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                zchl = ( trb(ji,jj,jk,jpnch) + trb(ji,jj,jk,jpdch) + rtrn ) * 1.e6
@@ -179,7 +177,5 @@
 
       DO jk = 1, nksrp
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
@@ -198,7 +194,5 @@
       !
       DO jk = 1, nksrp
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
@@ -264,7 +258,5 @@
          !
          DO jk = 2, nksrp + 1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   pe0(ji,jj,jk) = pe0(ji,jj,jk-1) * EXP( -fse3t(ji,jj,jk-1) * xsi0r )
@@ -285,7 +277,5 @@
         !
         DO jk = 2, nksrp      
-!CDIR NOVERRCHK
            DO jj = 1, jpj
-!CDIR NOVERRCHK
               DO ji = 1, jpi
                  pe1(ji,jj,jk) = pe1(ji,jj,jk-1) * EXP( -0.5 * ( ekb(ji,jj,jk-1) + ekb(ji,jj,jk) ) )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zprod.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zprod.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zprod.F90	(revision 6041)
@@ -54,7 +54,6 @@
    REAL(wp) :: texcret2               !: 1 - excret2        
 
-
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -148,9 +147,6 @@
 
       IF( ln_newprod ) THEN
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   ! Computation of the P-I slope for nanos and diatoms
@@ -186,9 +182,6 @@
          END DO
       ELSE
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
 
@@ -231,9 +224,6 @@
       !  Computation of a proxy of the N/C ratio
       !  ---------------------------------------
-!CDIR NOVERRCHK
       DO jk = 1, jpkm1
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                 zval = MIN( xnanopo4(ji,jj,jk), ( xnanonh4(ji,jj,jk) + xnanono3(ji,jj,jk) ) )   &
@@ -296,9 +286,6 @@
 
       ! Computation of the various production terms 
-!CDIR NOVERRCHK
       DO jk = 1, jpkm1
-!CDIR NOVERRCHK
          DO jj = 1, jpj
-!CDIR NOVERRCHK
             DO ji = 1, jpi
                IF( etot_ndcy(ji,jj,jk) > 1.E-3 ) THEN
@@ -331,9 +318,6 @@
 
       IF( ln_newprod ) THEN
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   IF( fsdepw(ji,jj,jk+1) <= hmld(ji,jj) ) THEN
@@ -359,9 +343,6 @@
          END DO
       ELSE
-!CDIR NOVERRCHK
          DO jk = 1, jpkm1
-!CDIR NOVERRCHK
             DO jj = 1, jpj
-!CDIR NOVERRCHK
                DO ji = 1, jpi
                   IF( etot_ndcy(ji,jj,jk) > 1.E-3 ) THEN
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zrem.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zrem.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zrem.F90	(revision 6041)
@@ -50,6 +50,6 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   denitnh4   !: -    -    -    -   -
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsbc.F90	(revision 6041)
@@ -81,6 +81,7 @@
 
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsed.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsed.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsed.F90	(revision 6041)
@@ -38,6 +38,6 @@
    REAL(wp) :: r1_rday                  !: inverse of rday
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsink.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsink.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsink.F90	(revision 6041)
@@ -65,6 +65,6 @@
 #endif
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/P4Z/p4zsms.F90	(revision 6041)
@@ -45,6 +45,4 @@
 
 
-   !! * Substitutions
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/trcini_pisces.F90	(revision 6041)
@@ -27,6 +27,4 @@
    PUBLIC   trc_ini_pisces   ! called by trcini.F90 module
 
-
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/PISCES/trcwri_pisces.F90	(revision 6041)
@@ -21,5 +21,7 @@
    PUBLIC trc_wri_pisces 
 
-#  include "top_substitute.h90"
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
+
 CONTAINS
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcadv.F90	(revision 6041)
@@ -4,6 +4,7 @@
    !! Ocean passive tracers:  advection trend 
    !!==============================================================================
-   !! History :  2.0  !  05-11  (G. Madec)  Original code
-   !!            3.0  !  10-06  (C. Ethe)   Adapted to passive tracers
+   !! History :  2.0  !  2005-11  (G. Madec)  Original code
+   !!            3.0  !  2010-06  (C. Ethe)   Adapted to passive tracers
+   !!            3.7  !  2014-05  (G. Madec, C. Ethe)  Add 2nd/4th order cases for CEN and FCT schemes 
    !!----------------------------------------------------------------------
 #if defined key_top
@@ -11,28 +12,50 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-   !!   trc_adv      : compute ocean tracer advection trend
-   !!   trc_adv_ctl  : control the different options of advection scheme
-   !!----------------------------------------------------------------------
-   USE oce_trc         ! ocean dynamics and active tracers
-   USE trc             ! ocean passive tracers variables
-   USE trcnam_trp      ! passive tracers transport namelist variables
-   USE traadv_cen2     ! 2nd order centered scheme (tra_adv_cen2   routine)
-   USE traadv_tvd      ! TVD      scheme           (tra_adv_tvd    routine)
-   USE traadv_muscl    ! MUSCL    scheme           (tra_adv_muscl  routine)
-   USE traadv_muscl2   ! MUSCL2   scheme           (tra_adv_muscl2 routine)
-   USE traadv_ubs      ! UBS      scheme           (tra_adv_ubs    routine)
-   USE traadv_qck      ! QUICKEST scheme           (tra_adv_qck    routine)
-   USE traadv_eiv      ! eddy induced velocity     (tra_adv_eiv    routine)
-   USE traadv_mle      ! ML eddy induced velocity  (tra_adv_mle    routine)
-   USE ldftra_oce      ! lateral diffusion coefficient on tracers
-   USE prtctl_trc      ! Print control
+   !!   trc_adv       : compute ocean tracer advection trend
+   !!   trc_adv_ini   : control the different options of advection scheme
+   !!----------------------------------------------------------------------
+   USE oce_trc        ! ocean dynamics and active tracers
+   USE trc            ! ocean passive tracers variables
+   USE traadv_cen     ! centered scheme           (tra_adv_cen  routine)
+   USE traadv_fct     ! FCT      scheme           (tra_adv_fct  routine)
+   USE traadv_mus     ! MUSCL    scheme           (tra_adv_mus  routine)
+   USE traadv_ubs     ! UBS      scheme           (tra_adv_ubs  routine)
+   USE traadv_qck     ! QUICKEST scheme           (tra_adv_qck  routine)
+   USE traadv_mle     ! ML eddy induced velocity  (tra_adv_mle  routine)
+   USE ldftra         ! lateral diffusion coefficient on tracers
+   USE ldfslp         ! Lateral diffusion: slopes of neutral surfaces
+   !
+   USE prtctl_trc     ! Print control
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   trc_adv          ! routine called by step module
-   PUBLIC   trc_adv_alloc    ! routine called by nemogcm module
-
-   INTEGER ::   nadv   ! choice of the type of advection scheme
+   PUBLIC   trc_adv       
+   PUBLIC   trc_adv_alloc 
+   PUBLIC   trc_adv_ini  
+
+   !                            !!* Namelist namtrc_adv *
+   LOGICAL ::   ln_trcadv_cen    ! centered scheme flag
+   INTEGER ::      nn_cen_h, nn_cen_v   ! =2/4 : horizontal and vertical choices of the order of CEN scheme
+   LOGICAL ::   ln_trcadv_fct    ! FCT scheme flag
+   INTEGER ::      nn_fct_h, nn_fct_v   ! =2/4 : horizontal and vertical choices of the order of FCT scheme
+   INTEGER ::      nn_fct_zts           ! >=1 : 2nd order FCT with vertical sub-timestepping
+   LOGICAL ::   ln_trcadv_mus    ! MUSCL scheme flag
+   LOGICAL ::      ln_mus_ups           ! use upstream scheme in vivcinity of river mouths
+   LOGICAL ::   ln_trcadv_ubs    ! UBS scheme flag
+   INTEGER ::      nn_ubs_v             ! =2/4 : vertical choice of the order of UBS scheme
+   LOGICAL ::   ln_trcadv_qck    ! QUICKEST scheme flag
+
+   !                                        ! choices of advection scheme:
+   INTEGER, PARAMETER ::   np_NO_adv  = 0   ! no T-S advection
+   INTEGER, PARAMETER ::   np_CEN     = 1   ! 2nd/4th order centered scheme
+   INTEGER, PARAMETER ::   np_FCT     = 2   ! 2nd/4th order Flux Corrected Transport scheme
+   INTEGER, PARAMETER ::   np_FCT_zts = 3   ! 2nd order FCT scheme with vertical sub-timestepping
+   INTEGER, PARAMETER ::   np_MUS     = 4   ! MUSCL scheme
+   INTEGER, PARAMETER ::   np_UBS     = 5   ! 3rd order Upstream Biased Scheme
+   INTEGER, PARAMETER ::   np_QCK     = 6   ! QUICK scheme
+
+   INTEGER ::              nadv             ! chosen advection scheme
+   !
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:) ::   r2dt  ! vertical profile time-step, = 2 rdttra
    !                                                    ! except at nitrrc000 (=rdttra) if neuler=0
@@ -42,5 +65,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! NEMO/TOP 3.7 , NEMO Consortium (2015)
    !! $Id$ 
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
@@ -52,9 +75,9 @@
       !!                  ***  ROUTINE trc_adv_alloc  ***
       !!----------------------------------------------------------------------
-
+      !
       ALLOCATE( r2dt(jpk), STAT=trc_adv_alloc )
-
+      !
       IF( trc_adv_alloc /= 0 ) CALL ctl_warn('trc_adv_alloc : failed to allocate array.')
-
+      !
    END FUNCTION trc_adv_alloc
 
@@ -68,19 +91,15 @@
       !! ** Method  : - Update the tracer with the advection term following nadv
       !!----------------------------------------------------------------------
-      !!
       INTEGER, INTENT(in) ::   kt   ! ocean time-step index
       !
-      INTEGER ::   jk 
+      INTEGER ::   jk   ! dummy loop index
       CHARACTER (len=22) ::   charout
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zun, zvn, zwn  ! effective velocity
       !!----------------------------------------------------------------------
       !
-      IF( nn_timing == 1 )  CALL timing_start('trc_adv')
-      !
-      CALL wrk_alloc( jpi, jpj, jpk, zun, zvn, zwn )
-      !
-
-      IF( kt == nittrc000 )   CALL trc_adv_ctl          ! initialisation & control of options
-
+      IF( nn_timing == 1 )   CALL timing_start('trc_adv')
+      !
+      CALL wrk_alloc( jpi,jpj,jpk,   zun, zvn, zwn )
+      !
       IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
          r2dt(:) =  rdttrc(:)           ! = rdttrc (use or restarting with Euler time stepping)
@@ -88,64 +107,49 @@
          r2dt(:) = 2. * rdttrc(:)       ! = 2 rdttrc (leapfrog)
       ENDIF
-      !                                                   ! effective transport
+      !                                               !==  effective transport  ==!
       DO jk = 1, jpkm1
-         !                                                ! eulerian transport only
-         zun(:,:,jk) = e2u  (:,:) * fse3u(:,:,jk) * un(:,:,jk)
+         zun(:,:,jk) = e2u  (:,:) * fse3u(:,:,jk) * un(:,:,jk)                   ! eulerian transport
          zvn(:,:,jk) = e1v  (:,:) * fse3v(:,:,jk) * vn(:,:,jk)
          zwn(:,:,jk) = e1e2t(:,:)                 * wn(:,:,jk)
-         !
       END DO
       !
-      IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN
+      IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN                                 ! add z-tilde and/or vvl corrections
          zun(:,:,:) = zun(:,:,:) + un_td(:,:,:)
          zvn(:,:,:) = zvn(:,:,:) + vn_td(:,:,:)
       ENDIF
       !
-      zun(:,:,jpk) = 0._wp                                                     ! no transport trough the bottom
-      zvn(:,:,jpk) = 0._wp                                                     ! no transport trough the bottom
-      zwn(:,:,jpk) = 0._wp                                                     ! no transport trough the bottom
-
-      IF( lk_traldf_eiv .AND. .NOT. ln_traldf_grif )   &  ! add the eiv transport (if necessary)
-         &              CALL tra_adv_eiv( kt, nittrc000, zun, zvn, zwn, 'TRC' )
-      !
-      IF( ln_mle    )   CALL tra_adv_mle( kt, nittrc000, zun, zvn, zwn, 'TRC' )    ! add the mle transport (if necessary)
-      !
-      SELECT CASE ( nadv )                            !==  compute advection trend and add it to general trend  ==!
-      CASE ( 1 )   ;    CALL tra_adv_cen2  ( kt, nittrc000, 'TRC',       zun, zvn, zwn, trb, trn, tra, jptra )   !  2nd order centered
-      CASE ( 2 )   ;    CALL tra_adv_tvd   ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )   !  TVD 
-      CASE ( 3 )   ;    CALL tra_adv_muscl ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb,      tra, jptra, ln_trcadv_msc_ups )   !  MUSCL 
-      CASE ( 4 )   ;    CALL tra_adv_muscl2( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )   !  MUSCL2 
-      CASE ( 5 )   ;    CALL tra_adv_ubs   ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )   !  UBS 
-      CASE ( 6 )   ;    CALL tra_adv_qck   ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )   !  QUICKEST 
-      !
-      CASE (-1 )                                      !==  esopa: test all possibility with control print  ==!
-         CALL tra_adv_cen2  ( kt, nittrc000, 'TRC',       zun, zvn, zwn, trb, trn, tra, jptra )          
-         WRITE(charout, FMT="('adv1')")  ; CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
-         CALL tra_adv_tvd   ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )          
-         WRITE(charout, FMT="('adv2')")  ; CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
-         CALL tra_adv_muscl ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb,      tra, jptra, ln_trcadv_msc_ups  )          
-         WRITE(charout, FMT="('adv3')")  ; CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
-         CALL tra_adv_muscl2( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )          
-         WRITE(charout, FMT="('adv4')")  ; CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
-         CALL tra_adv_ubs   ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )          
-         WRITE(charout, FMT="('adv5')")  ; CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
-         CALL tra_adv_qck   ( kt, nittrc000, 'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra )          
-         WRITE(charout, FMT="('adv6')")  ; CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc(tab4d=tra, mask=tmask, clinfo=ctrcnm,clinfo2='trd')
-         !
+      IF( ln_ldfeiv .AND. .NOT. ln_traldf_triad )   & 
+         &              CALL ldf_eiv_trp( kt, nittrc000, zun, zvn, zwn, 'TRC' )  ! add the eiv transport
+      !
+      IF( ln_mle    )   CALL tra_adv_mle( kt, nittrc000, zun, zvn, zwn, 'TRC' )  ! add the mle transport
+      !
+      zun(:,:,jpk) = 0._wp                                                       ! no transport trough the bottom
+      zvn(:,:,jpk) = 0._wp
+      zwn(:,:,jpk) = 0._wp
+      !
+      !
+      SELECT CASE ( nadv )                      !==  compute advection trend and add it to general trend  ==!
+      !
+      CASE ( np_CEN )                                    ! Centered : 2nd / 4th order
+         CALL tra_adv_cen    ( kt, nittrc000,'TRC',       zun, zvn, zwn     , trn, tra, jptra, nn_cen_h, nn_cen_v )
+      CASE ( np_FCT )                                    ! FCT      : 2nd / 4th order
+         CALL tra_adv_fct    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra, nn_fct_h, nn_fct_v )
+      CASE ( np_FCT_zts )                                ! 2nd order FCT with vertical time-splitting
+         CALL tra_adv_fct_zts( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra        , nn_fct_zts )
+      CASE ( np_MUS )                                    ! MUSCL
+         CALL tra_adv_mus    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb,      tra, jptra        , ln_mus_ups ) 
+      CASE ( np_UBS )                                    ! UBS
+         CALL tra_adv_ubs    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra        , nn_ubs_v   )
+      CASE ( np_QCK )                                    ! QUICKEST
+         CALL tra_adv_qck    ( kt, nittrc000,'TRC', r2dt, zun, zvn, zwn, trb, trn, tra, jptra                     )
+      !
       END SELECT
-
-      !                                              ! print mean trends (used for debugging)
-      IF( ln_ctl )   THEN
+      !                  
+      IF( ln_ctl )   THEN                             !== print mean trends (used for debugging)
          WRITE(charout, FMT="('adv ')")  ;  CALL prt_ctl_trc_info(charout)
                                             CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
       END IF
       !
-      CALL wrk_dealloc( jpi, jpj, jpk, zun, zvn, zwn )
+      CALL wrk_dealloc( jpi,jpj,jpk,   zun, zvn, zwn )
       !
       IF( nn_timing == 1 )  CALL timing_stop('trc_adv')
@@ -154,7 +158,7 @@
 
 
-   SUBROUTINE trc_adv_ctl
+   SUBROUTINE trc_adv_ini
       !!---------------------------------------------------------------------
-      !!                  ***  ROUTINE trc_adv_ctl  ***
+      !!                  ***  ROUTINE trc_adv_ini  ***
       !!                
       !! ** Purpose : Control the consistency between namelist options for 
@@ -162,38 +166,108 @@
       !!----------------------------------------------------------------------
       INTEGER ::   ioptio
-      !!----------------------------------------------------------------------
-
-      ioptio = 0                      ! Parameter control
-      IF( ln_trcadv_cen2   )   ioptio = ioptio + 1
-      IF( ln_trcadv_tvd    )   ioptio = ioptio + 1
-      IF( ln_trcadv_muscl  )   ioptio = ioptio + 1
-      IF( ln_trcadv_muscl2 )   ioptio = ioptio + 1
-      IF( ln_trcadv_ubs    )   ioptio = ioptio + 1
-      IF( ln_trcadv_qck    )   ioptio = ioptio + 1
-      IF( lk_esopa         )   ioptio =          1
-
+      INTEGER ::  ios                 ! Local integer output status for namelist read
+      !!
+      NAMELIST/namtrc_adv/ ln_trcadv_cen, nn_cen_h, nn_cen_v,               &   ! CEN
+         &                 ln_trcadv_fct, nn_fct_h, nn_fct_v, nn_fct_zts,   &   ! FCT
+         &                 ln_trcadv_mus,                     ln_mus_ups,   &   ! MUSCL
+         &                 ln_trcadv_ubs,           nn_ubs_v,               &   ! UBS
+         &                 ln_trcadv_qck                                        ! QCK
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnat_ref )              !  namtrc_adv in reference namelist 
+      READ  ( numnat_ref, namtrc_adv, IOSTAT = ios, ERR = 901)
+901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_adv in reference namelist', lwp )
+
+      REWIND( numnat_cfg )              ! namtrc_adv in configuration namelist
+      READ  ( numnat_cfg, namtrc_adv, IOSTAT = ios, ERR = 902 )
+902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist', lwp )
+      IF(lwm) WRITE ( numont, namtrc_adv )
+
+      IF(lwp) THEN                    ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_adv_ini : choice/control of the tracer advection scheme'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namtrc_adv : chose a advection scheme for tracers'
+         WRITE(numout,*) '      centered scheme                           ln_trcadv_cen = ', ln_trcadv_cen
+         WRITE(numout,*) '            horizontal 2nd/4th order               nn_cen_h   = ', nn_fct_h
+         WRITE(numout,*) '            vertical   2nd/4th order               nn_cen_v   = ', nn_fct_v
+         WRITE(numout,*) '      Flux Corrected Transport scheme           ln_trcadv_fct = ', ln_trcadv_fct
+         WRITE(numout,*) '            horizontal 2nd/4th order               nn_fct_h   = ', nn_fct_h
+         WRITE(numout,*) '            vertical   2nd/4th order               nn_fct_v   = ', nn_fct_v
+         WRITE(numout,*) '            2nd order + vertical sub-timestepping  nn_fct_zts = ', nn_fct_zts
+         WRITE(numout,*) '      MUSCL scheme                              ln_trcadv_mus = ', ln_trcadv_mus
+         WRITE(numout,*) '            + upstream scheme near river mouths    ln_mus_ups = ', ln_mus_ups
+         WRITE(numout,*) '      UBS scheme                                ln_trcadv_ubs = ', ln_trcadv_ubs
+         WRITE(numout,*) '            vertical   2nd/4th order               nn_ubs_v   = ', nn_ubs_v
+         WRITE(numout,*) '      QUICKEST scheme                           ln_trcadv_qck = ', ln_trcadv_qck
+      ENDIF
+      !
+
+      ioptio = 0                       !==  Parameter control  ==!
+      IF( ln_trcadv_cen )   ioptio = ioptio + 1
+      IF( ln_trcadv_fct )   ioptio = ioptio + 1
+      IF( ln_trcadv_mus )   ioptio = ioptio + 1
+      IF( ln_trcadv_ubs )   ioptio = ioptio + 1
+      IF( ln_trcadv_qck )   ioptio = ioptio + 1
+
+      !
+      IF( ioptio == 0 ) THEN
+         nadv = np_NO_adv
+         CALL ctl_warn( 'trc_adv_init: You are running without tracer advection.' )
+      ENDIF
       IF( ioptio /= 1 )   CALL ctl_stop( 'Choose ONE advection scheme in namelist namtrc_adv' )
-
-      !                              ! Set nadv
-      IF( ln_trcadv_cen2   )   nadv =  1
-      IF( ln_trcadv_tvd    )   nadv =  2
-      IF( ln_trcadv_muscl  )   nadv =  3
-      IF( ln_trcadv_muscl2 )   nadv =  4
-      IF( ln_trcadv_ubs    )   nadv =  5
-      IF( ln_trcadv_qck    )   nadv =  6
-      IF( lk_esopa         )   nadv = -1
-
+      !
+      IF( ln_trcadv_cen .AND. ( nn_cen_h /= 2 .AND. nn_cen_h /= 4 )   &
+                        .AND. ( nn_cen_v /= 2 .AND. nn_cen_v /= 4 )   ) THEN
+        CALL ctl_stop( 'trc_adv_init: CEN scheme, choose 2nd or 4th order' )
+      ENDIF
+      IF( ln_trcadv_fct .AND. ( nn_fct_h /= 2 .AND. nn_fct_h /= 4 )   &
+                        .AND. ( nn_fct_v /= 2 .AND. nn_fct_v /= 4 )   ) THEN
+        CALL ctl_stop( 'trc_adv_init: FCT scheme, choose 2nd or 4th order' )
+      ENDIF
+      IF( ln_trcadv_fct .AND. nn_fct_zts > 0 ) THEN
+         IF( nn_fct_h == 4 ) THEN
+            nn_fct_h = 2
+            CALL ctl_stop( 'trc_adv_init: force 2nd order FCT scheme, 4th order does not exist with sub-timestepping' )
+         ENDIF
+         IF( lk_vvl ) THEN
+            CALL ctl_stop( 'trc_adv_init: vertical sub-timestepping not allow in non-linear free surface' )
+         ENDIF
+         IF( nn_fct_zts == 1 )   CALL ctl_warn( 'trc_adv_init: FCT with ONE sub-timestep = FCT without sub-timestep' )
+      ENDIF
+      IF( ln_trcadv_ubs .AND. ( nn_ubs_v /= 2 .AND. nn_ubs_v /= 4 )   ) THEN
+        CALL ctl_stop( 'trc_adv_init: UBS scheme, choose 2nd or 4th order' )
+      ENDIF
+      IF( ln_trcadv_ubs .AND. nn_ubs_v == 4 ) THEN
+         CALL ctl_warn( 'trc_adv_init: UBS scheme, only 2nd FCT scheme available on the vertical. It will be used' )
+      ENDIF
+      IF( ln_isfcav ) THEN                                                       ! ice-shelf cavities
+         IF(  ln_trcadv_cen .AND. nn_cen_v /= 4    .OR.   &                            ! NO 4th order with ISF
+            & ln_trcadv_fct .AND. nn_fct_v /= 4   )   CALL ctl_stop( 'tra_adv_init: 4th order COMPACT scheme not allowed with ISF' )
+      ENDIF
+      !
+      !                                !==  used advection scheme  ==!
+      !                                      ! set nadv
+      IF( ln_trcadv_cen                      )   nadv = np_CEN
+      IF( ln_trcadv_fct                      )   nadv = np_FCT
+      IF( ln_trcadv_fct .AND. nn_fct_zts > 0 )   nadv = np_FCT_zts
+      IF( ln_trcadv_mus                      )   nadv = np_MUS
+      IF( ln_trcadv_ubs                      )   nadv = np_UBS
+      IF( ln_trcadv_qck                      )   nadv = np_QCK
+      !
       IF(lwp) THEN                   ! Print the choice
          WRITE(numout,*)
-         IF( nadv ==  1 )   WRITE(numout,*) '         2nd order scheme is used'
-         IF( nadv ==  2 )   WRITE(numout,*) '         TVD       scheme is used'
-         IF( nadv ==  3 )   WRITE(numout,*) '         MUSCL     scheme is used'
-         IF( nadv ==  4 )   WRITE(numout,*) '         MUSCL2    scheme is used'
-         IF( nadv ==  5 )   WRITE(numout,*) '         UBS       scheme is used'
-         IF( nadv ==  6 )   WRITE(numout,*) '         QUICKEST  scheme is used'
-         IF( nadv == -1 )   WRITE(numout,*) '         esopa test: use all advection scheme'
-      ENDIF
-      !
-   END SUBROUTINE trc_adv_ctl
+         IF( nadv == np_NO_adv  )   WRITE(numout,*) '         NO passive tracer advection'
+         IF( nadv == np_CEN     )   WRITE(numout,*) '         CEN      scheme is used. Horizontal order: ', nn_cen_h,   &
+            &                                                                        ' Vertical   order: ', nn_cen_v
+         IF( nadv == np_FCT     )   WRITE(numout,*) '         FCT      scheme is used. Horizontal order: ', nn_fct_h,   &
+            &                                                                       ' Vertical   order: ', nn_fct_v
+         IF( nadv == np_FCT_zts )   WRITE(numout,*) '         use 2nd order FCT with ', nn_fct_zts,'vertical sub-timestepping'
+         IF( nadv == np_MUS     )   WRITE(numout,*) '         MUSCL    scheme is used'
+         IF( nadv == np_UBS     )   WRITE(numout,*) '         UBS      scheme is used'
+         IF( nadv == np_QCK     )   WRITE(numout,*) '         QUICKEST scheme is used'
+      ENDIF
+      !
+   END SUBROUTINE trc_adv_ini
    
 #else
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcbbl.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcbbl.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcbbl.F90	(revision 6041)
@@ -22,5 +22,4 @@
    USE oce_trc             ! ocean dynamics and active tracers variables
    USE trc                 ! ocean passive tracers variables
-   USE trcnam_trp      ! passive tracers transport namelist variables
    USE trabbl              ! 
    USE prtctl_trc          ! Print control for debbuging
@@ -30,7 +29,4 @@
    PUBLIC   trc_bbl       !  routine called by step.F90
 
-
-   !! * Substitutions
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcdmp.F90	(revision 6041)
@@ -18,5 +18,4 @@
    USE oce_trc         ! ocean dynamics and tracers variables
    USE trc             ! ocean passive tracers variables
-   USE trcnam_trp      ! passive tracers transport namelist variables
    USE trcdta
    USE tradmp
@@ -29,7 +28,11 @@
    PRIVATE
 
-   PUBLIC trc_dmp            ! routine called by step.F90
-   PUBLIC trc_dmp_clo        ! routine called by step.F90
-   PUBLIC trc_dmp_alloc      ! routine called by nemogcm.F90
+   PUBLIC trc_dmp      
+   PUBLIC trc_dmp_clo   
+   PUBLIC trc_dmp_alloc  
+   PUBLIC trc_dmp_ini    
+
+   INTEGER , PUBLIC ::   nn_zdmp_tr    ! = 0/1/2 flag for damping in the mixed layer
+   CHARACTER(LEN=200) , PUBLIC :: cn_resto_tr    !File containing restoration coefficient
 
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   restotr   ! restoring coeff. on tracers (s-1)
@@ -40,5 +43,6 @@
 
    !! * Substitutions
-#  include "top_substitute.h90"
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -90,8 +94,4 @@
       IF( nn_timing == 1 )  CALL timing_start('trc_dmp')
       !
-      ! 0. Initialization (first time-step only)
-      !    --------------
-      IF( kt == nittrc000 ) CALL trc_dmp_init
-
       IF( l_trdtrc )   CALL wrk_alloc( jpi, jpj, jpk, ztrtrd )   ! temporary save of trends
       !
@@ -171,4 +171,66 @@
    END SUBROUTINE trc_dmp
 
+   SUBROUTINE trc_dmp_ini
+      !!----------------------------------------------------------------------
+      !!                  ***  ROUTINE trc_dmp_ini  ***
+      !! 
+      !! ** Purpose :   Initialization for the newtonian damping 
+      !!
+      !! ** Method  :   read the nammbf namelist and check the parameters
+      !!              called by trc_dmp at the first timestep (nittrc000)
+      !!----------------------------------------------------------------------
+      !
+      INTEGER ::  ios                 ! Local integer output status for namelist read
+      INTEGER :: imask  !local file handle
+      !
+      NAMELIST/namtrc_dmp/ nn_zdmp_tr , cn_resto_tr
+      !!----------------------------------------------------------------------
+
+      IF( nn_timing == 1 )  CALL timing_start('trc_dmp_init')
+      !
+
+      REWIND( numnat_ref )              ! Namelist namtrc_dmp in reference namelist : Passive tracers newtonian damping
+      READ  ( numnat_ref, namtrc_dmp, IOSTAT = ios, ERR = 909)
+909   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist', lwp )
+
+      REWIND( numnat_cfg )              ! Namelist namtrc_dmp in configuration namelist : Passive tracers newtonian damping
+      READ  ( numnat_cfg, namtrc_dmp, IOSTAT = ios, ERR = 910)
+910   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist', lwp )
+      IF(lwm) WRITE ( numont, namtrc_dmp )
+
+      IF(lwp) THEN                       ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_dmp : Passive tracers newtonian damping'
+         WRITE(numout,*) '~~~~~~~'
+         WRITE(numout,*) '   Namelist namtrc_dmp : set damping parameter'
+         WRITE(numout,*) '      mixed layer damping option     nn_zdmp_tr = ', nn_zdmp_tr, '(zoom: forced to 0)'
+         WRITE(numout,*) '      Restoration coeff file    cn_resto_tr = ', cn_resto_tr
+      ENDIF
+      !
+      IF( lzoom .AND. .NOT.lk_c1d )   nn_zdmp_tr = 0           ! restoring to climatology at closed north or south boundaries
+      SELECT CASE ( nn_zdmp_tr )
+      CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping throughout the water column'
+      CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline (avt > 5 cm2/s)'
+      CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
+      CASE DEFAULT
+         WRITE(ctmp1,*) 'bad flag value for nn_zdmp_tr = ', nn_zdmp_tr
+         CALL ctl_stop(ctmp1)
+      END SELECT
+
+      IF( .NOT.lk_c1d ) THEN
+         IF( .NOT. ln_tradmp )   &
+            &   CALL ctl_stop( 'passive trace damping need ln_tradmp to compute damping coef.' )
+         !
+         !                          ! Read damping coefficients from file
+         !Read in mask from file
+         CALL iom_open ( cn_resto_tr, imask)
+         CALL iom_get  ( imask, jpdom_autoglo, 'resto', restotr)
+         CALL iom_close( imask )
+         !
+      ENDIF
+      IF( nn_timing == 1 )  CALL timing_stop('trc_dmp_init')
+      !
+   END SUBROUTINE trc_dmp_ini
+
    SUBROUTINE trc_dmp_clo( kt )
       !!---------------------------------------------------------------------
@@ -303,42 +365,4 @@
 
 
-   SUBROUTINE trc_dmp_init
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE trc_dmp_init  ***
-      !! 
-      !! ** Purpose :   Initialization for the newtonian damping 
-      !!
-      !! ** Method  :   read the nammbf namelist and check the parameters
-      !!              called by trc_dmp at the first timestep (nittrc000)
-      !!----------------------------------------------------------------------
-      !
-      INTEGER :: imask  !local file handle
-
-      IF( nn_timing == 1 )  CALL timing_start('trc_dmp_init')
-      !
-
-      IF( lzoom )   nn_zdmp_tr = 0           ! restoring to climatology at closed north or south boundaries
-      SELECT CASE ( nn_zdmp_tr )
-      CASE ( 0 )   ;   IF(lwp) WRITE(numout,*) '   tracer damping throughout the water column'
-      CASE ( 1 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the turbocline (avt > 5 cm2/s)'
-      CASE ( 2 )   ;   IF(lwp) WRITE(numout,*) '   no tracer damping in the mixed layer'
-      CASE DEFAULT
-         WRITE(ctmp1,*) 'bad flag value for nn_zdmp_tr = ', nn_zdmp_tr
-         CALL ctl_stop(ctmp1)
-      END SELECT
-
-      IF( .NOT. ln_tradmp )   &
-         &   CALL ctl_stop( 'passive trace damping need key_tradmp to compute damping coef.' )
-      !
-      !                          ! Read damping coefficients from file
-      !Read in mask from file
-      CALL iom_open ( cn_resto_tr, imask)
-      CALL iom_get  ( imask, jpdom_autoglo, 'resto', restotr)
-      CALL iom_close( imask )
-      !
-      IF( nn_timing == 1 )  CALL timing_stop('trc_dmp_init')
-      !
-   END SUBROUTINE trc_dmp_init
-
 #else
    !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcldf.F90	(revision 6041)
@@ -4,6 +4,7 @@
    !! Ocean Passive tracers : lateral diffusive trends
    !!=====================================================================
-   !! History :  9.0  ! 2005-11 (G. Madec)  Original code
-   !!       NEMO 3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
+   !! History :  1.0  ! 2005-11  (G. Madec)  Original code
+   !!            3.0  ! 2008-01  (C. Ethe, G. Madec)  merge TRC-TRA
+   !!            3.7  ! 2014-03  (G. Madec)  LDF simplification
    !!----------------------------------------------------------------------
 #if defined key_top
@@ -11,20 +12,17 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-   !!----------------------------------------------------------------------
-   !!   trc_ldf     : update the tracer trend with the lateral diffusion
-   !!       ldf_ctl : initialization, namelist read, and parameters control
-   !!----------------------------------------------------------------------
-   USE oce_trc         ! ocean dynamics and active tracers
-   USE trc             ! ocean passive tracers variables
-   USE trcnam_trp      ! passive tracers transport namelist variables
-   USE ldftra_oce      ! lateral diffusion coefficient on tracers
-   USE ldfslp          ! ???
-   USE traldf_bilapg   ! lateral mixing            (tra_ldf_bilapg routine)
-   USE traldf_bilap    ! lateral mixing            (tra_ldf_bilap routine)
-   USE traldf_iso      ! lateral mixing            (tra_ldf_iso routine)
-   USE traldf_iso_grif ! lateral mixing          (tra_ldf_iso_grif routine)
-   USE traldf_lap      ! lateral mixing            (tra_ldf_lap routine)
-   USE trd_oce
-   USE trdtra
+   !!   trc_ldf      : update the tracer trend with the lateral diffusion
+   !!   trc_ldf_ini  : initialization, namelist read, and parameters control
+   !!----------------------------------------------------------------------
+   USE trc           ! ocean passive tracers variables
+   USE oce_trc       ! ocean dynamics and active tracers
+   USE ldfslp        ! lateral diffusion: iso-neutral slope
+   USE traldf_lap    ! lateral diffusion: laplacian iso-level            operator  (tra_ldf_lap   routine)
+   USE traldf_iso    ! lateral diffusion: laplacian iso-neutral standard operator  (tra_ldf_iso   routine)
+   USE traldf_triad  ! lateral diffusion: laplacian iso-neutral triad    operator  (tra_ldf_triad routine)
+   USE traldf_blp    ! lateral diffusion (iso-level lap/blp)                       (tra_ldf_lap   routine)
+   USE trd_oce       ! trends: ocean variables
+   USE trdtra        ! trends manager: tracers 
+   !
    USE prtctl_trc      ! Print control
 
@@ -32,17 +30,28 @@
    PRIVATE
 
-   PUBLIC   trc_ldf    ! called by step.F90
-   !                                                 !!: ** lateral mixing namelist (nam_trcldf) **
-   REAL(wp) ::  rldf_rat    ! ratio between active and passive tracers diffusive coefficient
+   PUBLIC   trc_ldf    
+   PUBLIC   trc_ldf_ini   
+   !
+   LOGICAL , PUBLIC ::   ln_trcldf_lap       !:   laplacian operator
+   LOGICAL , PUBLIC ::   ln_trcldf_blp       !: bilaplacian operator
+   LOGICAL , PUBLIC ::   ln_trcldf_lev       !: iso-level   direction
+   LOGICAL , PUBLIC ::   ln_trcldf_hor       !: horizontal  direction (rotation to geopotential)
+   LOGICAL , PUBLIC ::   ln_trcldf_iso       !: iso-neutral direction (standard)
+   LOGICAL , PUBLIC ::   ln_trcldf_triad     !: iso-neutral direction (triad)
+   REAL(wp), PUBLIC ::   rn_ahtrc_0          !:   laplacian diffusivity coefficient for passive tracer [m2/s]
+   REAL(wp), PUBLIC ::   rn_bhtrc_0          !: bilaplacian      -          --     -       -   [m4/s]
+   !
+                                                 !!: ** lateral mixing namelist (nam_trcldf) **
+   REAL(wp) ::  rldf    ! ratio between active and passive tracers diffusive coefficient
    INTEGER  ::  nldf = 0   ! type of lateral diffusion used defined from ln_trcldf_... namlist logicals)
+   
    !! * Substitutions
 #  include "domzgr_substitute.h90"
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! NEMO/TOP 3.7 , NEMO Consortium (2014)
    !! $Id$
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
@@ -58,4 +67,5 @@
       INTEGER            :: jn
       CHARACTER (len=22) :: charout
+      REAL(wp), POINTER, DIMENSION(:,:,:)   ::   zahu, zahv
       REAL(wp), POINTER, DIMENSION(:,:,:,:) ::   ztrtrd
       !!----------------------------------------------------------------------
@@ -63,44 +73,31 @@
       IF( nn_timing == 1 )   CALL timing_start('trc_ldf')
       !
-      IF( kt == nittrc000 )   CALL ldf_ctl          ! initialisation & control of options
-
-      rldf = rldf_rat
-
       IF( l_trdtrc )  THEN
-         CALL wrk_alloc( jpi, jpj, jpk, jptra, ztrtrd )
+         CALL wrk_alloc( jpi,jpj,jpk,jptra,   ztrtrd )
          ztrtrd(:,:,:,:)  = tra(:,:,:,:)
       ENDIF
-
-      SELECT CASE ( nldf )                       ! compute lateral mixing trend and add it to the general trend
-      CASE ( 0 )   ;   CALL tra_ldf_lap   ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra        )  ! iso-level laplacian
-      CASE ( 1 )                                                                                            ! rotated laplacian
-                       IF( ln_traldf_grif ) THEN
-                          CALL tra_ldf_iso_grif( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
-                       ELSE
-                          CALL tra_ldf_iso     ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra, rn_ahtb_0 )
-                       ENDIF
-      CASE ( 2 )   ;   CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )  ! iso-level bilaplacian
-      CASE ( 3 )   ;   CALL tra_ldf_bilapg( kt, nittrc000, 'TRC',             trb, tra, jptra            )  ! s-coord. horizontal bilaplacian
-         !
-      CASE ( -1 )                                     ! esopa: test all possibility with control print
-         CALL tra_ldf_lap   ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )
-         WRITE(charout, FMT="('ldf0 ')") ;  CALL prt_ctl_trc_info(charout)
-                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-         IF( ln_traldf_grif ) THEN
-            CALL tra_ldf_iso_grif( kt, nittrc000, 'TRC', gtru, gtrv, trb, tra, jptra, rn_ahtb_0 )
-         ELSE
-            CALL tra_ldf_iso     ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra, rn_ahtb_0 )
-         ENDIF
-         WRITE(charout, FMT="('ldf1 ')") ;  CALL prt_ctl_trc_info(charout)
-                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-         CALL tra_ldf_bilap ( kt, nittrc000, 'TRC', gtru, gtrv, gtrui, gtrvi, trb, tra, jptra            )
-         WRITE(charout, FMT="('ldf2 ')") ;  CALL prt_ctl_trc_info(charout)
-                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-         CALL tra_ldf_bilapg( kt, nittrc000, 'TRC',             trb, tra, jptra            )
-         WRITE(charout, FMT="('ldf3 ')") ;  CALL prt_ctl_trc_info(charout)
-                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+      !
+      !                                        !* set the lateral diffusivity coef. for passive tracer      
+      CALL wrk_alloc( jpi,jpj,jpk,   zahu, zahv )
+      zahu(:,:,:) = rldf * ahtu(:,:,:)
+      zahv(:,:,:) = rldf * ahtv(:,:,:)
+
+      SELECT CASE ( nldf )                     !* compute lateral mixing trend and add it to the general trend
+      !
+      CASE ( np_lap   )                               ! iso-level laplacian
+         CALL tra_ldf_lap  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb,      tra, jptra,  1   )
+         !
+      CASE ( np_lap_i )                               ! laplacian : standard iso-neutral operator (Madec)
+         CALL tra_ldf_iso  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,  1   )
+         !
+      CASE ( np_lap_it )                              ! laplacian : triad iso-neutral operator (griffies)
+         CALL tra_ldf_triad( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb, trb, tra, jptra,  1   )
+         !
+      CASE ( np_blp , np_blp_i , np_blp_it )          ! bilaplacian: all operator (iso-level, -neutral)
+         CALL tra_ldf_blp  ( kt, nittrc000,'TRC', zahu, zahv, gtru, gtrv, gtrui, gtrvi, trb     , tra, jptra, nldf )
+         !
       END SELECT
       !
-      IF( l_trdtrc )   THEN                      ! save the horizontal diffusive trends for further diagnostics
+      IF( l_trdtrc )   THEN                    ! save the horizontal diffusive trends for further diagnostics
         DO jn = 1, jptra
            ztrtrd(:,:,:,jn) = tra(:,:,:,jn) - ztrtrd(:,:,:,jn)
@@ -109,9 +106,11 @@
         CALL wrk_dealloc( jpi, jpj, jpk, jptra, ztrtrd )
       ENDIF
-      !                                          ! print mean trends (used for debugging)
-      IF( ln_ctl )   THEN
-         WRITE(charout, FMT="('ldf ')") ;  CALL prt_ctl_trc_info(charout)
-                                           CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-      ENDIF
+      !                                        ! print mean trends (used for debugging)
+      IF( ln_ctl ) THEN
+         WRITE(charout, FMT="('ldf ')")   ;   CALL prt_ctl_trc_info(charout)
+                                              CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
+      ENDIF
+      !
+      CALL wrk_dealloc( jpi,jpj,jpk,   zahu, zahv )
       !
       IF( nn_timing == 1 )   CALL timing_stop('trc_ldf')
@@ -120,13 +119,11 @@
 
 
-   SUBROUTINE ldf_ctl
+   SUBROUTINE trc_ldf_ini
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE ldf_ctl  ***
       !!
-      !! ** Purpose :   Choice of the operator for the lateral tracer diffusion
+      !! ** Purpose :   Define the operator for the lateral diffusion
       !!
       !! ** Method  :   set nldf from the namtra_ldf logicals
-      !!      nldf == -2   No lateral diffusion
-      !!      nldf == -1   ESOPA test: ALL operators are used
       !!      nldf ==  0   laplacian operator
       !!      nldf ==  1   Rotated laplacian operator
@@ -134,124 +131,139 @@
       !!      nldf ==  3   Rotated bilaplacian
       !!----------------------------------------------------------------------
-      INTEGER ::   ioptio, ierr         ! temporary integers
-      !!----------------------------------------------------------------------
-
-      IF (ABS(rn_aht_0) < 2._wp*TINY(1.e0)) THEN
-         IF (ABS(rn_ahtrc_0) < 2._wp*TINY(1.e0)) THEN
-            rldf_rat = 1.0_wp
-         ELSE
-            CALL ctl_stop( 'STOP', 'ldf_ctl : cannot define rldf_rat, rn_aht_0==0, rn_ahtrc_0 /=0' )
-         END IF
-      ELSE
-         rldf_rat = rn_ahtrc_0 / rn_aht_0
-      END IF
-      !  Define the lateral mixing oparator for tracers
-      ! ===============================================
-
-      !                               ! control the input
+      INTEGER ::   ioptio, ierr   ! temporary integers
+      INTEGER ::   ios            ! Local integer output status for namelist read
+      !
+      NAMELIST/namtrc_ldf/ ln_trcldf_lap, ln_trcldf_blp,                                  &
+         &                 ln_trcldf_lev, ln_trcldf_hor, ln_trcldf_iso, ln_trcldf_triad,  &
+         &                 rn_ahtrc_0   , rn_bhtrc_0
+      !!----------------------------------------------------------------------
+      REWIND( numnat_ref )              !  namtrc_ldf in reference namelist 
+      READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903)
+903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist', lwp )
+
+      REWIND( numnat_cfg )              !  namtrc_ldf in configuration namelist 
+      READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 )
+904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist', lwp )
+      IF(lwm) WRITE ( numont, namtrc_ldf )
+
+      IF(lwp) THEN                    ! Namelist print
+         WRITE(numout,*)
+         WRITE(numout,*) 'trc_ldf_ini : lateral tracer diffusive operator'
+         WRITE(numout,*) '~~~~~~~~~~~'
+         WRITE(numout,*) '   Namelist namtrc_ldf : set lateral mixing parameters (type, direction, coefficients)'
+         WRITE(numout,*) '      operator'
+         WRITE(numout,*) '           laplacian                 ln_trcldf_lap   = ', ln_trcldf_lap
+         WRITE(numout,*) '         bilaplacian                 ln_trcldf_blp   = ', ln_trcldf_blp
+         WRITE(numout,*) '      direction of action'
+         WRITE(numout,*) '         iso-level                   ln_trcldf_lev   = ', ln_trcldf_lev
+         WRITE(numout,*) '         horizontal (geopotential)   ln_trcldf_hor   = ', ln_trcldf_hor
+         WRITE(numout,*) '         iso-neutral (standard)      ln_trcldf_iso   = ', ln_trcldf_iso
+         WRITE(numout,*) '         iso-neutral (triad)         ln_trcldf_triad = ', ln_trcldf_triad
+         WRITE(numout,*) '      diffusivity coefficient'
+         WRITE(numout,*) '           laplacian                 rn_ahtrc_0      = ', rn_ahtrc_0
+         WRITE(numout,*) '         bilaplacian                 rn_bhtrc_0      = ', rn_bhtrc_0
+      ENDIF
+      !      
+      !                                ! control the namelist parameters
       ioptio = 0
-      IF( ln_trcldf_lap   )   ioptio = ioptio + 1
-      IF( ln_trcldf_bilap )   ioptio = ioptio + 1
-      IF( ioptio >  1 )   CALL ctl_stop( '          use ONE or NONE of the 2 lap/bilap operator type on tracer' )
-      IF( ioptio == 0 )   nldf = -2   ! No lateral diffusion
+      IF( ln_trcldf_lap )   ioptio = ioptio + 1
+      IF( ln_trcldf_blp )   ioptio = ioptio + 1
+      IF( ioptio >  1   )   CALL ctl_stop( 'trc_ldf_ctl: use ONE or NONE of the 2 lap/bilap operator type on tracer' )
+      IF( ioptio == 0   )   nldf = np_no_ldf   ! No lateral diffusion
+      
+      IF( ln_trcldf_lap .AND. ln_trcldf_blp )   CALL ctl_stop( 'trc_ldf_ctl: bilaplacian should be used on both TRC and TRA' )
+      IF( ln_trcldf_blp .AND. ln_trcldf_lap )   CALL ctl_stop( 'trc_ldf_ctl:   laplacian should be used on both TRC and TRA' )
+      
       ioptio = 0
-      IF( ln_trcldf_level )   ioptio = ioptio + 1
-      IF( ln_trcldf_hor   )   ioptio = ioptio + 1
-      IF( ln_trcldf_iso   )   ioptio = ioptio + 1
-      IF( ioptio /= 1 )   CALL ctl_stop( '          use only ONE direction (level/hor/iso)' )
+      IF( ln_trcldf_lev )   ioptio = ioptio + 1
+      IF( ln_trcldf_hor )   ioptio = ioptio + 1
+      IF( ln_trcldf_iso )   ioptio = ioptio + 1
+      IF( ioptio /= 1   )   CALL ctl_stop( 'trc_ldf_ctl: use only ONE direction (level/hor/iso)' )
 
       ! defined the type of lateral diffusion from ln_trcldf_... logicals
       ! CAUTION : nldf = 1 is used in trazdf_imp, change it carefully
       ierr = 0
-      IF( ln_trcldf_lap ) THEN       ! laplacian operator
+      IF( ln_trcldf_lap ) THEN      !==  laplacian operator  ==!
          IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_trcldf_level )   nldf = 0      ! iso-level  (no rotation)
-            IF ( ln_trcldf_hor   )   nldf = 0      ! horizontal (no rotation)
-            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_zps ) THEN             ! z-coordinate
-            IF ( ln_trcldf_level )   ierr = 1      ! iso-level not allowed
-            IF ( ln_trcldf_hor   )   nldf = 0      ! horizontal (no rotation)
-            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_sco ) THEN             ! z-coordinate
-            IF ( ln_trcldf_level )   nldf = 0      ! iso-level  (no rotation)
-            IF ( ln_trcldf_hor   )   nldf = 1      ! horizontal (   rotation)
-            IF ( ln_trcldf_iso   )   nldf = 1      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-
-      IF( ln_trcldf_bilap ) THEN      ! bilaplacian operator
+            IF ( ln_trcldf_lev   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+            IF ( ln_trcldf_hor   )   nldf = np_lap     ! iso-level = horizontal (no rotation)
+            IF ( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard  (   rotation)
+            IF ( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad     (   rotation)
+         ENDIF
+         IF ( ln_zps ) THEN             ! z-coordinate with partial step
+            IF ( ln_trcldf_lev   )   ierr = 1         ! iso-level not allowed 
+            IF ( ln_trcldf_hor   )   nldf = np_lap     ! horizontal (no rotation)
+            IF ( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard (rotation)
+            IF ( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad    (rotation)
+         ENDIF
+         IF ( ln_sco ) THEN             ! s-coordinate
+            IF ( ln_trcldf_lev   )   nldf = np_lap     ! iso-level  (no rotation)
+            IF ( ln_trcldf_hor   )   nldf = np_lap_it  ! horizontal (   rotation)       !!gm   a checker....
+            IF ( ln_trcldf_iso   )   nldf = np_lap_i   ! iso-neutral: standard (rotation)
+            IF ( ln_trcldf_triad )   nldf = np_lap_it  ! iso-neutral: triad    (rotation)
+         ENDIF
+         !                                ! diffusivity ratio: passive / active tracers 
+         IF( ABS(rn_aht_0) < 2._wp*TINY(1.e0) ) THEN
+            IF( ABS(rn_ahtrc_0) < 2._wp*TINY(1.e0) ) THEN
+               rldf = 1.0_wp
+            ELSE
+               CALL ctl_stop( 'STOP', 'trc_ldf_ctl : cannot define rldf, rn_aht_0==0, rn_ahtrc_0 /=0' )
+            ENDIF
+         ELSE
+            rldf = rn_ahtrc_0 / rn_aht_0
+         ENDIF
+      ENDIF
+      !
+      IF( ln_trcldf_blp ) THEN      !==  bilaplacian operator  ==!
          IF ( ln_zco ) THEN                ! z-coordinate
-            IF ( ln_trcldf_level )   nldf = 2      ! iso-level  (no rotation)
-            IF ( ln_trcldf_hor   )   nldf = 2      ! horizontal (no rotation)
-            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_zps ) THEN             ! z-coordinate
-            IF ( ln_trcldf_level )   ierr = 1      ! iso-level not allowed
-            IF ( ln_trcldf_hor   )   nldf = 2      ! horizontal (no rotation)
-            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-         IF ( ln_sco ) THEN             ! z-coordinate
-            IF ( ln_trcldf_level )   nldf = 2      ! iso-level  (no rotation)
-            IF ( ln_trcldf_hor   )   nldf = 3      ! horizontal (   rotation)
-            IF ( ln_trcldf_iso   )   ierr = 2      ! isoneutral (   rotation)
-         ENDIF
-      ENDIF
-
+            IF ( ln_trcldf_lev   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+            IF ( ln_trcldf_hor   )   nldf = np_blp     ! iso-level = horizontal (no rotation)
+            IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
+            IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
+         ENDIF
+         IF ( ln_zps ) THEN             ! z-coordinate with partial step
+            IF ( ln_trcldf_lev   )   ierr = 1         ! iso-level not allowed 
+            IF ( ln_trcldf_hor   )   nldf = np_blp     ! horizontal (no rotation)
+            IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
+            IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
+         ENDIF
+         IF ( ln_sco ) THEN             ! s-coordinate
+            IF ( ln_trcldf_lev   )   nldf = np_blp     ! iso-level  (no rotation)
+            IF ( ln_trcldf_hor   )   nldf = np_blp_it  ! horizontal (   rotation)       !!gm   a checker....
+            IF ( ln_trcldf_iso   )   nldf = np_blp_i   ! iso-neutral: standard (rotation)
+            IF ( ln_trcldf_triad )   nldf = np_blp_it  ! iso-neutral: triad    (rotation)
+         ENDIF
+         !                                ! diffusivity ratio: passive / active tracers 
+         IF( ABS(rn_bht_0) < 2._wp*TINY(1.e0) ) THEN
+            IF( ABS(rn_bhtrc_0) < 2._wp*TINY(1.e0) ) THEN
+               rldf = 1.0_wp
+            ELSE
+               CALL ctl_stop( 'STOP', 'trc_ldf_ctl : cannot define rldf, rn_aht_0==0, rn_ahtrc_0 /=0' )
+            ENDIF
+         ELSE
+            rldf = SQRT(  ABS( rn_bhtrc_0 / rn_bht_0 )  )
+         ENDIF
+      ENDIF
+      !
       IF( ierr == 1 )   CALL ctl_stop( ' iso-level in z-coordinate - partial step, not allowed' )
-      IF( ierr == 2 )   CALL ctl_stop( ' isoneutral bilaplacian operator does not exist' )
-      IF( lk_traldf_eiv .AND. .NOT.ln_trcldf_iso )   &
+      IF( ln_ldfeiv .AND. .NOT.ln_trcldf_iso )   &
            CALL ctl_stop( '          eddy induced velocity on tracers',   &
            &              ' the eddy induced velocity on tracers requires isopycnal laplacian diffusion' )
       IF( nldf == 1 .OR. nldf == 3 ) THEN      ! rotation
-         IF( .NOT.lk_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require key_ldfslp' )
-#if defined key_offline
-         l_traldf_rot = .TRUE.                 ! needed for trazdf_imp
-#endif
-      ENDIF
-
-      IF( lk_esopa ) THEN
-         IF(lwp) WRITE(numout,*) '          esopa control: use all lateral physics options'
-         nldf = -1
-      ENDIF
-
+         IF( .NOT.l_ldfslp )   CALL ctl_stop( '          the rotation of the diffusive tensor require l_ldfslp' )
+      ENDIF
+      !
       IF(lwp) THEN
          WRITE(numout,*)
-         IF( nldf == -2 )   WRITE(numout,*) '          NO lateral diffusion'
-         IF( nldf == -1 )   WRITE(numout,*) '          ESOPA test All scheme used'
-         IF( nldf ==  0 )   WRITE(numout,*) '          laplacian operator'
-         IF( nldf ==  1 )   WRITE(numout,*) '          Rotated laplacian operator'
-         IF( nldf ==  2 )   WRITE(numout,*) '          bilaplacian operator'
-         IF( nldf ==  3 )   WRITE(numout,*) '          Rotated bilaplacian'
-      ENDIF
-
-      IF( ln_trcldf_bilap ) THEN
-         IF(lwp) WRITE(numout,*) '          biharmonic tracer diffusion'
-         IF( rn_ahtrc_0 > 0 .AND. .NOT. lk_esopa )   CALL ctl_stop( 'The horizontal diffusivity coef. rn_ahtrc_0 must be negative' )
-      ELSE
-         IF(lwp) WRITE(numout,*) '          harmonic tracer diffusion (default)'
-         IF( rn_ahtrc_0 < 0 .AND. .NOT. lk_esopa )   CALL ctl_stop('The horizontal diffusivity coef. rn_ahtrc_0 must be positive' )
-      ENDIF
-
-      ! ratio between active and passive tracers diffusive coef.
-      IF (ABS(rn_aht_0) < 2._wp*TINY(1.e0)) THEN
-         IF (ABS(rn_ahtrc_0) < 2._wp*TINY(1.e0)) THEN
-            rldf_rat = 1.0_wp
-         ELSE
-            CALL ctl_stop( 'STOP', 'ldf_ctl : cannot define rldf_rat, rn_aht_0==0, rn_ahtrc_0 /=0' )
-         END IF
-      ELSE
-         rldf_rat = rn_ahtrc_0 / rn_aht_0
-      END IF
-      IF( rldf_rat < 0 ) THEN
-         IF( .NOT.lk_offline ) THEN 
-            CALL ctl_stop( 'Choose the same type of diffusive scheme both for active & passive tracers' )
-         ELSE
-            CALL ctl_stop( 'Change the sign of rn_aht_0 in namelist to -/+1' )
-         ENDIF 
-      ENDIF
-      !
-   END SUBROUTINE ldf_ctl
+         IF( nldf == np_no_ldf )   WRITE(numout,*) '          NO lateral diffusion'
+         IF( nldf == np_lap    )   WRITE(numout,*) '          laplacian iso-level operator'
+         IF( nldf == np_lap_i  )   WRITE(numout,*) '          Rotated laplacian operator (standard)'
+         IF( nldf == np_lap_it )   WRITE(numout,*) '          Rotated laplacian operator (triad)'
+         IF( nldf == np_blp    )   WRITE(numout,*) '          bilaplacian iso-level operator'
+         IF( nldf == np_blp_i  )   WRITE(numout,*) '          Rotated bilaplacian operator (standard)'
+         IF( nldf == np_blp_it )   WRITE(numout,*) '          Rotated bilaplacian operator (triad)'
+      ENDIF
+      !
+   END SUBROUTINE trc_ldf_ini
 #else
    !!----------------------------------------------------------------------
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcnam_trp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcnam_trp.F90	(revision 6040)
+++ 	(revision )
@@ -1,195 +1,0 @@
-MODULE trcnam_trp
-   !!======================================================================
-   !!                       ***  MODULE  trcnam_trp  ***
-   !! TOP :   namelist read options for transport
-   !!======================================================================
-   !! History :   1.0  !  2004-03  (C. Ethe)  Original code
-   !!             2.0  !  2007-12  (C. Ethe, G. Madec)  revised architecture
-   !!----------------------------------------------------------------------
-#if defined key_top
-   !!----------------------------------------------------------------------
-   !!   'key_top'                                                TOP models
-   !!----------------------------------------------------------------------
-   !!   trc_nam_trp  : read the passive tracer namelist for transport
-   !!----------------------------------------------------------------------
-   USE trc                 ! passive tracers variables
-   USE in_out_manager      ! ocean dynamics and active tracers variables
-   USE lib_mpp           ! distributed memory computing library
-
-   IMPLICIT NONE
-   PRIVATE
-
-   PUBLIC   trc_nam_trp    ! routine called by step module
- 
-   !                                        !!: ** Advection (namtrc_adv) **
-   LOGICAL , PUBLIC ::   ln_trcadv_cen2      ! 2nd order centered scheme flag
-   LOGICAL , PUBLIC ::   ln_trcadv_tvd       ! TVD scheme flag
-   LOGICAL , PUBLIC ::   ln_trcadv_muscl     ! MUSCL scheme flag
-   LOGICAL , PUBLIC ::   ln_trcadv_muscl2    ! MUSCL2 scheme flag
-   LOGICAL , PUBLIC ::   ln_trcadv_ubs       ! UBS scheme flag
-   LOGICAL , PUBLIC ::   ln_trcadv_qck       ! QUICKEST scheme flag
-   LOGICAL , PUBLIC ::   ln_trcadv_msc_ups   ! use upstream scheme within muscl
-
-
-   !                                        !!: ** lateral mixing namelist (nam_trcldf) **
-   LOGICAL , PUBLIC ::   ln_trcldf_lap       !: laplacian operator
-   LOGICAL , PUBLIC ::   ln_trcldf_bilap     !: bilaplacian operator
-   LOGICAL , PUBLIC ::   ln_trcldf_level     !: iso-level direction
-   LOGICAL , PUBLIC ::   ln_trcldf_hor       !: horizontal (geopotential) direction
-   LOGICAL , PUBLIC ::   ln_trcldf_iso       !: iso-neutral direction
-   REAL(wp), PUBLIC ::   rn_ahtrc_0          !: diffusivity coefficient for passive tracer (m2/s)
-   REAL(wp), PUBLIC ::   rn_ahtrb_0          !: background diffusivity coefficient for passive tracer (m2/s)
-
-   !                                        !!: ** Treatment of Negative concentrations ( nam_trcrad )
-   LOGICAL , PUBLIC ::   ln_trcrad           !: flag to artificially correct negative concentrations
-
-   !                                        !!: ** Vertical diffusion (nam_trczdf) **
-   LOGICAL , PUBLIC ::   ln_trczdf_exp       !: explicit vertical diffusion scheme flag
-   INTEGER , PUBLIC ::   nn_trczdf_exp       !: number of sub-time step (explicit time stepping)
-
-   !                                                 !!: ** newtonian damping namelist (nam_trcdmp) **
-   !                          !!* Namelist namtrc_dmp : passive tracer newtonian damping *
-   INTEGER , PUBLIC ::   nn_zdmp_tr    ! = 0/1/2 flag for damping in the mixed layer
-   CHARACTER(LEN=200) , PUBLIC :: cn_resto_tr    !File containing restoration coefficient
-
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
-
-CONTAINS
-
-   SUBROUTINE trc_nam_trp
-      !!----------------------------------------------------------------------
-      !!                  ***  ROUTINE trc_nam_trp  ***
-      !!                
-      !! ** Purpose :   Read Namelist for tracer transport option
-      !!----------------------------------------------------------------------
-      INTEGER ::  ios                 ! Local integer output status for namelist read
-      NAMELIST/namtrc_adv/ ln_trcadv_cen2 , ln_trcadv_tvd   ,    &
-         &                 ln_trcadv_muscl, ln_trcadv_muscl2,    &
-         &                 ln_trcadv_ubs  , ln_trcadv_qck, ln_trcadv_msc_ups
-
-      NAMELIST/namtrc_ldf/ ln_trcldf_lap  ,     &
-         &                 ln_trcldf_bilap, ln_trcldf_level,     &
-         &                 ln_trcldf_hor  , ln_trcldf_iso  , rn_ahtrc_0, rn_ahtrb_0
-      NAMELIST/namtrc_zdf/ ln_trczdf_exp  , nn_trczdf_exp
-      NAMELIST/namtrc_rad/ ln_trcrad
-      NAMELIST/namtrc_dmp/ nn_zdmp_tr , cn_resto_tr
-      !!----------------------------------------------------------------------
-
-      IF(lwp) WRITE(numout,*)
-      IF(lwp) WRITE(numout,*) ' trc_nam_trp: read namelist for tracer transport'
-      IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~'
-
-      REWIND( numnat_ref )              ! Namelist namtrc_adv in reference namelist : Tracer advection scheme
-      READ  ( numnat_ref, namtrc_adv, IOSTAT = ios, ERR = 901)
-901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_adv in reference namelist', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_adv in configuration namelist : Tracer advection scheme
-      READ  ( numnat_cfg, namtrc_adv, IOSTAT = ios, ERR = 902 )
-902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_adv in configuration namelist', lwp )
-      IF(lwm) WRITE ( numont, namtrc_adv )
-
-      IF(lwp) THEN                    ! Namelist print
-         WRITE(numout,*)
-         WRITE(numout,*) 'trc_adv_ctl : choice/control of the tracer advection scheme'
-         WRITE(numout,*) '~~~~~~~~~~~'
-         WRITE(numout,*) '   Namelist namtrc_adv : chose a advection scheme for tracers'
-         WRITE(numout,*) '      2nd order advection scheme     ln_trcadv_cen2   = ', ln_trcadv_cen2
-         WRITE(numout,*) '      TVD advection scheme           ln_trcadv_tvd    = ', ln_trcadv_tvd
-         WRITE(numout,*) '      MUSCL  advection scheme        ln_trcadv_muscl  = ', ln_trcadv_muscl
-         WRITE(numout,*) '      MUSCL2 advection scheme        ln_trcadv_muscl2 = ', ln_trcadv_muscl2
-         WRITE(numout,*) '      UBS    advection scheme        ln_trcadv_ubs    = ', ln_trcadv_ubs
-         WRITE(numout,*) '      QUICKEST advection scheme      ln_trcadv_qck    = ', ln_trcadv_qck
-      ENDIF
-      !
-      REWIND( numnat_ref )              ! Namelist namtrc_ldf in reference namelist : Tracer lateral diffusive operator
-      READ  ( numnat_ref, namtrc_ldf, IOSTAT = ios, ERR = 903)
-903   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ldf in reference namelist', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_ldf in configuration namelist : Tracer lateral diffusive operator
-      READ  ( numnat_cfg, namtrc_ldf, IOSTAT = ios, ERR = 904 )
-904   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_ldf in configuration namelist', lwp )
-      IF(lwm) WRITE ( numont, namtrc_ldf )
-
-      IF(lwp) THEN                    ! Namelist print
-         WRITE(numout,*)
-         WRITE(numout,*) 'trc:ldf_ctl : lateral tracer diffusive operator'
-         WRITE(numout,*) '~~~~~~~~~~~'
-         WRITE(numout,*) '   Namelist namtrc_ldf : set lateral mixing parameters (type, direction, coefficients)'
-         WRITE(numout,*) '      laplacian operator                                 ln_trcldf_lap   = ', ln_trcldf_lap
-         WRITE(numout,*) '      bilaplacian operator                               ln_trcldf_bilap = ', ln_trcldf_bilap
-         WRITE(numout,*) '      iso-level                                          ln_trcldf_level = ', ln_trcldf_level
-         WRITE(numout,*) '      horizontal (geopotential)                          ln_trcldf_hor   = ', ln_trcldf_hor
-         WRITE(numout,*) '      iso-neutral                                        ln_trcldf_iso   = ', ln_trcldf_iso
-         WRITE(numout,*) '      diffusivity coefficient                                 rn_ahtrc_0 = ', rn_ahtrc_0
-         WRITE(numout,*) '      background hor. diffusivity                             rn_ahtrb_0 = ', rn_ahtrb_0
-      ENDIF
-
-      !                                ! Vertical mixing
-      REWIND( numnat_ref )              ! Namelist namtrc_zdf in reference namelist : Tracer vertical mixing
-      READ  ( numnat_ref, namtrc_zdf, IOSTAT = ios, ERR = 905)
-905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in reference namelist', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_zdf in configuration namelist : Tracer vertical mixing
-      READ  ( numnat_cfg, namtrc_zdf, IOSTAT = ios, ERR = 906 )
-906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in configuration namelist', lwp )
-      IF(lwm) WRITE ( numont, namtrc_zdf )
-
-      IF(lwp) THEN                     !   ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) '   Namelist namtrc_zdf : set vertical diffusion parameters'
-         WRITE(numout,*) '      time splitting / backward scheme ln_trczdf_exp = ', ln_trczdf_exp
-         WRITE(numout,*) '      number of time step              nn_trczdf_exp = ', nn_trczdf_exp
-      ENDIF
-
-      !
-      REWIND( numnat_ref )              ! Namelist namtrc_rad in reference namelist : Tracer negative concentrations
-      READ  ( numnat_ref, namtrc_rad, IOSTAT = ios, ERR = 907)
-907   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_rad in reference namelist', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_rad in configuration namelist : Tracer negative concentrations
-      READ  ( numnat_cfg, namtrc_rad, IOSTAT = ios, ERR = 908 )
-908   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_rad in configuration namelist', lwp )
-      IF(lwm) WRITE ( numont, namtrc_rad )
-
-      IF(lwp) THEN                     !   ! Control print
-         WRITE(numout,*)
-         WRITE(numout,*) '   Namelist namtrc_rad : treatment of negative concentrations'
-         WRITE(numout,*) '      correct artificially negative concen. or not ln_trcrad = ', ln_trcrad
-      ENDIF
-
-
-      REWIND( numnat_ref )              ! Namelist namtrc_dmp in reference namelist : Passive tracers newtonian damping
-      READ  ( numnat_ref, namtrc_dmp, IOSTAT = ios, ERR = 909)
-909   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dmp in reference namelist', lwp )
-
-      REWIND( numnat_cfg )              ! Namelist namtrc_dmp in configuration namelist : Passive tracers newtonian damping
-      READ  ( numnat_cfg, namtrc_dmp, IOSTAT = ios, ERR = 910)
-910   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_dmp in configuration namelist', lwp )
-      IF(lwm) WRITE ( numont, namtrc_dmp )
-
-      IF(lwp) THEN                       ! Namelist print
-         WRITE(numout,*)
-         WRITE(numout,*) 'trc_dmp : Passive tracers newtonian damping'
-         WRITE(numout,*) '~~~~~~~'
-         WRITE(numout,*) '   Namelist namtrc_dmp : set damping parameter'
-         WRITE(numout,*) '      mixed layer damping option     nn_zdmp_tr = ', nn_zdmp_tr, '(zoom: forced to 0)'
-         WRITE(numout,*) '      Restoration coeff file    cn_resto_tr = ', cn_resto_tr
-      ENDIF
-      !
-   END SUBROUTINE trc_nam_trp
-   
-#else
-   !!----------------------------------------------------------------------
-   !!   Dummy module :                                         No TOP model
-   !!----------------------------------------------------------------------
-CONTAINS
-   SUBROUTINE trc_nam_trp              ! Empty routine
-   END SUBROUTINE trc_nam_trp
-#endif
-
-  !!======================================================================
-END MODULE trcnam_trp
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcrad.F90	(revision 6041)
@@ -22,8 +22,9 @@
    PRIVATE
 
-   PUBLIC trc_rad         ! routine called by trcstp.F90
-
-   !! * Substitutions
-#  include "top_substitute.h90"
+   PUBLIC trc_rad     
+   PUBLIC trc_rad_ini  
+
+   LOGICAL , PUBLIC ::   ln_trcrad           !: flag to artificially correct negative concentrations
+
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -76,4 +77,32 @@
       !
    END SUBROUTINE trc_rad
+
+   SUBROUTINE trc_rad_ini
+      !!---------------------------------------------------------------------
+      !!                  ***  ROUTINE trc _rad_ini ***
+      !!
+      !! ** Purpose : read  namelist options 
+      !!----------------------------------------------------------------------
+      INTEGER ::  ios                 ! Local integer output status for namelist read
+      NAMELIST/namtrc_rad/ ln_trcrad
+      !!----------------------------------------------------------------------
+
+      !
+      REWIND( numnat_ref )              ! namtrc_rad in reference namelist 
+      READ  ( numnat_ref, namtrc_rad, IOSTAT = ios, ERR = 907)
+907   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_rad in reference namelist', lwp )
+
+      REWIND( numnat_cfg )              ! namtrc_rad in configuration namelist 
+      READ  ( numnat_cfg, namtrc_rad, IOSTAT = ios, ERR = 908 )
+908   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_rad in configuration namelist', lwp )
+      IF(lwm) WRITE ( numont, namtrc_rad )
+
+      IF(lwp) THEN                     !   ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtrc_rad : treatment of negative concentrations'
+         WRITE(numout,*) '      correct artificially negative concen. or not ln_trcrad = ', ln_trcrad
+      ENDIF
+      !
+   END SUBROUTINE trc_rad_ini
 
    SUBROUTINE trc_rad_sms( kt, ptrb, ptrn, jp_sms0, jp_sms1, cpreserv )
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trcsbc.F90	(revision 6041)
@@ -31,5 +31,6 @@
 
    !! * Substitutions
-#  include "top_substitute.h90"
+#  include "domzgr_substitute.h90"
+#  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -83,5 +84,5 @@
          CASE( 0    )   ;   zswitch = 1  ! (0) standard levitating sea-ice : salt exchange only
          CASE( 1, 2 )   ;   zswitch = 0  ! (1) levitating sea-ice: salt and volume exchange but no pressure effect                                
-                                         ! (2) embedded sea-ice : salt and volume fluxes and pressure
+      !                                  ! (2) embedded sea-ice : salt and volume fluxes and pressure
       END SELECT
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trctrp.F90	(revision 6041)
@@ -15,8 +15,6 @@
    USE oce_trc         ! ocean dynamics and active tracers variables
    USE trc             ! ocean passive tracers variables 
-   USE trcnam_trp      ! passive tracers transport namelist variables
    USE trabbl          ! bottom boundary layer               (trc_bbl routine)
    USE trcbbl          ! bottom boundary layer               (trc_bbl routine)
-   USE zdfkpp          ! KPP non-local tracer fluxes         (trc_kpp routine)
    USE trcdmp          ! internal damping                    (trc_dmp routine)
    USE trcldf          ! lateral mixing                      (trc_ldf routine)
@@ -38,6 +36,4 @@
    PUBLIC   trc_trp    ! called by trc_stp
 
-   !! * Substitutions
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -48,5 +44,5 @@
 CONTAINS
 
-   SUBROUTINE trc_trp( kstp )
+   SUBROUTINE trc_trp( kt )
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE trc_trp  ***
@@ -57,5 +53,5 @@
       !!              - Update the passive tracers
       !!----------------------------------------------------------------------
-      INTEGER, INTENT( in ) ::  kstp  ! ocean time-step index
+      INTEGER, INTENT( in ) ::  kt  ! ocean time-step index
       !! ---------------------------------------------------------------------
       !
@@ -64,36 +60,34 @@
       IF( .NOT. lk_c1d ) THEN
          !
-                                CALL trc_sbc( kstp )            ! surface boundary condition
-         IF( lk_trabbl )        CALL trc_bbl( kstp )            ! advective (and/or diffusive) bottom boundary layer scheme
-         IF( ln_trcdmp )        CALL trc_dmp( kstp )            ! internal damping trends
-         IF( ln_trcdmp_clo )    CALL trc_dmp_clo( kstp )        ! internal damping trends on closed seas only
-                                CALL trc_adv( kstp )            ! horizontal & vertical advection 
-                                CALL trc_ldf( kstp )            ! lateral mixing
-         IF( .NOT. lk_offline .AND. lk_zdfkpp )    &
-            &                   CALL trc_kpp( kstp )            ! KPP non-local tracer fluxes
+                                CALL trc_sbc    ( kt )      ! surface boundary condition
+         IF( lk_trabbl )        CALL trc_bbl    ( kt )      ! advective (and/or diffusive) bottom boundary layer scheme
+         IF( ln_trcdmp )        CALL trc_dmp    ( kt )      ! internal damping trends
+         IF( ln_trcdmp_clo )    CALL trc_dmp_clo( kt )      ! internal damping trends on closed seas only
+                                CALL trc_adv    ( kt )      ! horizontal & vertical advection 
+         !                                                         ! Partial top/bottom cell: GRADh( trb )  
+         IF( ln_zps ) THEN
+           IF( ln_isfcav ) THEN ; CALL zps_hde_isf( kt, jptra, trb, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )  ! both top & bottom
+           ELSE                 ; CALL zps_hde    ( kt, jptra, trb, gtru, gtrv )                                      !  only bottom
+           ENDIF
+         ENDIF
+         !                                                      
+                                CALL trc_ldf    ( kt )      ! lateral mixing
 #if defined key_agrif
-         IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_trc           ! tracers sponge
+         IF(.NOT. Agrif_Root()) CALL Agrif_Sponge_trc       ! tracers sponge
 #endif
-                                CALL trc_zdf( kstp )            ! vertical mixing and after tracer fields
-                                CALL trc_nxt( kstp )            ! tracer fields at next time step     
-         IF( ln_trcrad )        CALL trc_rad( kstp )            ! Correct artificial negative concentrations
+                                CALL trc_zdf    ( kt )      ! vertical mixing and after tracer fields
+                                CALL trc_nxt    ( kt )      ! tracer fields at next time step     
+         IF( ln_trcrad )        CALL trc_rad    ( kt )      ! Correct artificial negative concentrations
 
 #if defined key_agrif
-      IF( .NOT. Agrif_Root())   CALL Agrif_Update_Trc( kstp )   ! Update tracer at AGRIF zoom boundaries : children only
+         IF( .NOT.Agrif_Root()) CALL Agrif_Update_Trc( kt ) ! Update tracer at AGRIF zoom boundaries : children only
 #endif
-
-         IF( ln_zps  .AND. .NOT. ln_isfcav)        &
-            &            CALL zps_hde    ( kstp, jptra, trn, gtru, gtrv )   ! Partial steps: now horizontal gradient of passive
-         IF( ln_zps .AND.        ln_isfcav)        &
-            &            CALL zps_hde_isf( kstp, jptra, trn, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )  ! Partial steps: now horizontal gradient of passive
-                                                                ! tracers at the bottom ocean level
          !
       ELSE                                               ! 1D vertical configuration
-                                CALL trc_sbc( kstp )            ! surface boundary condition
-         IF( .NOT. lk_offline .AND. lk_zdfkpp )    &
-            &                   CALL trc_kpp( kstp )            ! KPP non-local tracer fluxes
-                                CALL trc_zdf( kstp )            ! vertical mixing and after tracer fields
-                                CALL trc_nxt( kstp )            ! tracer fields at next time step     
-          IF( ln_trcrad )       CALL trc_rad( kstp )            ! Correct artificial negative concentrations
+                                CALL trc_sbc( kt )            ! surface boundary condition
+         IF( ln_trcdmp )        CALL trc_dmp( kt )            ! internal damping trends
+                                CALL trc_zdf( kt )            ! vertical mixing and after tracer fields
+                                CALL trc_nxt( kt )            ! tracer fields at next time step     
+          IF( ln_trcrad )       CALL trc_rad( kt )            ! Correct artificial negative concentrations
          !
       END IF
@@ -108,7 +102,7 @@
    !!----------------------------------------------------------------------
 CONTAINS
-   SUBROUTINE trc_trp( kstp )              ! Empty routine
-      INTEGER, INTENT(in) ::   kstp
-      WRITE(*,*) 'trc_trp: You should not have seen this print! error?', kstp
+   SUBROUTINE trc_trp( kt )              ! Empty routine
+      INTEGER, INTENT(in) ::   kt
+      WRITE(*,*) 'trc_trp: You should not have seen this print! error?', kt
    END SUBROUTINE trc_trp
 #endif
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trczdf.F90	(revision 6041)
@@ -11,21 +11,26 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-   !!   trc_ldf     : update the tracer trend with the lateral diffusion
-   !!       ldf_ctl : initialization, namelist read, and parameters control
+   !!   trc_zdf      : update the tracer trend with the lateral diffusion
+   !!   trc_zdf_ini  : initialization, namelist read, and parameters control
    !!----------------------------------------------------------------------
-   USE oce_trc         ! ocean dynamics and active tracers
-   USE trc             ! ocean passive tracers variables
-   USE trcnam_trp      ! passive tracers transport namelist variables
-   USE trazdf_exp      ! vertical diffusion: explicit (tra_zdf_exp     routine)
-   USE trazdf_imp      ! vertical diffusion: implicit (tra_zdf_imp     routine)
-   USE trd_oce
-   USE trdtra
-   USE prtctl_trc      ! Print control
+   USE trc           ! ocean passive tracers variables
+   USE oce_trc       ! ocean dynamics and active tracers
+   USE trd_oce       ! trends: ocean variables
+   USE trazdf_exp    ! vertical diffusion: explicit (tra_zdf_exp     routine)
+   USE trazdf_imp    ! vertical diffusion: implicit (tra_zdf_imp     routine)
+   USE trcldf        ! passive tracers: lateral diffusion
+   USE trdtra        ! trends manager: tracers 
+   USE prtctl_trc    ! Print control
 
    IMPLICIT NONE
    PRIVATE
 
-   PUBLIC   trc_zdf          ! called by step.F90 
-   PUBLIC   trc_zdf_alloc    ! called by nemogcm.F90 
+   PUBLIC   trc_zdf         ! called by step.F90 
+   PUBLIC   trc_zdf_ini     ! called by nemogcm.F90 
+   PUBLIC   trc_zdf_alloc   ! called by nemogcm.F90 
+   
+   !                                        !!** Vertical diffusion (nam_trczdf) **
+   LOGICAL , PUBLIC ::   ln_trczdf_exp       !: explicit vertical diffusion scheme flag
+   INTEGER , PUBLIC ::   nn_trczdf_exp       !: number of sub-time step (explicit time stepping)
 
    INTEGER ::   nzdf = 0               ! type vertical diffusion algorithm used
@@ -39,5 +44,5 @@
 #  include "vectopt_loop_substitute.h90"
    !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
+   !! NEMO/TOP 3.7 , NEMO Consortium (2015)
    !! $Id$ 
    !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
@@ -71,6 +76,4 @@
       IF( nn_timing == 1 )  CALL timing_start('trc_zdf')
       !
-      IF( kt == nittrc000 )   CALL zdf_ctl          ! initialisation & control of options
-
       IF( ( neuler == 0 .AND. kt == nittrc000 ) .OR. ln_top_euler ) THEN     ! at nittrc000
          r2dt(:) =  rdttrc(:)           ! = rdttrc (use or restarting with Euler time stepping)
@@ -85,14 +88,6 @@
 
       SELECT CASE ( nzdf )                       ! compute lateral mixing trend and add it to the general trend
-      CASE ( -1 )                                       ! esopa: test all possibility with control print
-         CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra ) 
-         WRITE(charout, FMT="('zdf1 ')") ;  CALL prt_ctl_trc_info(charout)
-                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
-         CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra ) 
-         WRITE(charout, FMT="('zdf2 ')") ;  CALL prt_ctl_trc_info(charout)
-                                            CALL prt_ctl_trc( tab4d=tra, mask=tmask, clinfo=ctrcnm, clinfo2='trd' )
       CASE ( 0 ) ;  CALL tra_zdf_exp( kt, nittrc000, 'TRC', r2dt, nn_trczdf_exp, trb, tra, jptra )    !   explicit scheme 
       CASE ( 1 ) ;  CALL tra_zdf_imp( kt, nittrc000, 'TRC', r2dt,                trb, tra, jptra )    !   implicit scheme          
-
       END SELECT
 
@@ -117,7 +112,7 @@
 
 
-   SUBROUTINE zdf_ctl
+   SUBROUTINE trc_zdf_ini
       !!----------------------------------------------------------------------
-      !!                 ***  ROUTINE zdf_ctl  ***
+      !!                 ***  ROUTINE trc_zdf_ini  ***
       !!
       !! ** Purpose :   Choose the vertical mixing scheme
@@ -128,30 +123,41 @@
       !!      NB: The implicit scheme is required when using : 
       !!             - rotated lateral mixing operator
-      !!             - TKE, GLS or KPP vertical mixing scheme
+      !!             - TKE, GLS vertical mixing scheme
       !!----------------------------------------------------------------------
-
-      !  Define the vertical tracer physics scheme
-      ! ==========================================
-
-      ! Choice from ln_zdfexp already read in namelist in zdfini module
-      IF( ln_trczdf_exp ) THEN           ! use explicit scheme
-         nzdf = 0
-      ELSE                               ! use implicit scheme
-         nzdf = 1
+      INTEGER ::  ios                 ! Local integer output status for namelist read
+      !!
+      NAMELIST/namtrc_zdf/ ln_trczdf_exp  , nn_trczdf_exp
+      !!----------------------------------------------------------------------
+      !
+      REWIND( numnat_ref )             ! namtrc_zdf in reference namelist 
+      READ  ( numnat_ref, namtrc_zdf, IOSTAT = ios, ERR = 905)
+905   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in reference namelist', lwp )
+      !
+      REWIND( numnat_cfg )             ! namtrc_zdf in configuration namelist 
+      READ  ( numnat_cfg, namtrc_zdf, IOSTAT = ios, ERR = 906 )
+906   IF( ios /= 0 ) CALL ctl_nam ( ios , 'namtrc_zdf in configuration namelist', lwp )
+      IF(lwm) WRITE ( numont, namtrc_zdf )
+      !
+      IF(lwp) THEN                     ! Control print
+         WRITE(numout,*)
+         WRITE(numout,*) '   Namelist namtrc_zdf : set vertical diffusion  parameters'
+         WRITE(numout,*) '      time splitting / backward scheme ln_trczdf_exp = ', ln_trczdf_exp
+         WRITE(numout,*) '      number of time step              nn_trczdf_exp = ', nn_trczdf_exp
       ENDIF
 
-      ! Force implicit schemes
-      IF( ln_trcldf_iso                               )   nzdf = 1      ! iso-neutral lateral physics
-      IF( ln_trcldf_hor .AND. ln_sco                  )   nzdf = 1      ! horizontal lateral physics in s-coordinate
-#if defined key_zdftke || defined key_zdfgls || defined key_zdfkpp
-                                                          nzdf = 1      ! TKE, GLS or KPP physics       
-#endif
-      IF( ln_trczdf_exp .AND. nzdf == 1 )   THEN
-         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS or KPP vertical scheme ', &
-            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
+      !                                ! Define the vertical tracer physics scheme
+      IF( ln_trczdf_exp ) THEN   ;   nzdf = 0     ! explicit scheme
+      ELSE                       ;   nzdf = 1     ! implicit scheme
       ENDIF
 
-      ! Test: esopa
-      IF( lk_esopa )    nzdf = -1                      ! All schemes used
+      !                                ! Force implicit schemes
+      IF( ln_trcldf_iso              )   nzdf = 1      ! iso-neutral lateral physics
+      IF( ln_trcldf_hor .AND. ln_sco )   nzdf = 1      ! horizontal lateral physics in s-coordinate
+#if defined key_zdftke || defined key_zdfgls 
+                                         nzdf = 1      ! TKE or GLS physics       
+#endif
+      IF( ln_trczdf_exp .AND. nzdf == 1 )  & 
+         CALL ctl_stop( 'trc_zdf : If using the rotated lateral mixing operator or TKE, GLS vertical scheme ', &
+            &           '          the implicit scheme is required, set ln_trczdf_exp = .false.' )
 
       IF(lwp) THEN
@@ -159,10 +165,10 @@
          WRITE(numout,*) 'trc:zdf_ctl : vertical passive tracer physics scheme'
          WRITE(numout,*) '~~~~~~~~~~~'
-         IF( nzdf == -1 )   WRITE(numout,*) '              ESOPA test All scheme used'
          IF( nzdf ==  0 )   WRITE(numout,*) '              Explicit time-splitting scheme'
          IF( nzdf ==  1 )   WRITE(numout,*) '              Implicit (euler backward) scheme'
       ENDIF
-
-   END SUBROUTINE zdf_ctl
+      !
+   END SUBROUTINE trc_zdf_ini
+   
 #else
    !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdmxl_trc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdmxl_trc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdmxl_trc.F90	(revision 6041)
@@ -8,5 +8,5 @@
    !!                 !  07-06  (C. Deltel)  key_gyre : do not call lbc_lnk
    !!----------------------------------------------------------------------
-#if   defined key_top && ( defined key_trdmxl_trc   ||   defined key_esopa )
+#if   defined key_top   &&   defined key_trdmxl_trc
    !!----------------------------------------------------------------------
    !!   'key_trdmxl_trc'                      mixed layer trend diagnostics
@@ -24,5 +24,4 @@
    USE zdfddm  , ONLY : avs  ! salinity vertical diffusivity coeff. at w-point
 # endif
-   USE trcnam_trp        ! passive tracers transport namelist variables
    USE trdtrc_oce    ! definition of main arrays used for trends computations
    USE in_out_manager    ! I/O manager
@@ -67,5 +66,5 @@
 
    !! * Substitutions
-#  include "top_substitute.h90"
+#  include "domzgr_substitute.h90"
 #  include "zdfddm_substitute.h90"
    !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc.F90	(revision 6041)
@@ -14,5 +14,4 @@
    !!----------------------------------------------------------------------
    USE trc               ! tracer definitions (trn, trb, tra, etc.)
-   USE trcnam_trp
    USE trd_oce
    USE trdtrc_oce       ! definition of main arrays used for trends computations
@@ -29,6 +28,4 @@
    PUBLIC trd_trc
 
-   !! * Substitutions
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc_oce.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc_oce.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/TRP/trdtrc_oce.F90	(revision 6041)
@@ -4,5 +4,5 @@
    !! Ocean trends :   set tracer and momentum trend variables
    !!======================================================================
-#if defined key_top   ||   defined key_esopa
+#if defined key_top
    !!----------------------------------------------------------------------
    !!   'key_top'                                                TOP models
@@ -30,5 +30,5 @@
 # endif
 
-# if defined key_trdmxl_trc   ||   defined key_esopa
+# if defined key_trdmxl_trc
    !!----------------------------------------------------------------------
    !!   'key_trdmxl_trc'                     mixed layer trends diagnostics
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/oce_trc.F90	(revision 6041)
@@ -11,6 +11,6 @@
    !!   'key_top'                                                TOP models
    !!----------------------------------------------------------------------
-
-   !* Domain size *
+   !
+   !                                            !* Domain size *
    USE par_oce , ONLY :   jpi      =>   jpi        !: first  dimension of grid --> i 
    USE par_oce , ONLY :   jpj      =>   jpj        !: second dimension of grid --> j  
@@ -20,34 +20,16 @@
    USE par_oce , ONLY :   jpkm1    =>   jpkm1      !: jpk - 1  
    USE par_oce , ONLY :   jpij     =>   jpij       !: jpi x jpj
-   USE par_oce , ONLY :   lk_esopa =>   lk_esopa   !: flag to activate the all option
    USE par_oce , ONLY :   jp_tem   =>   jp_tem     !: indice for temperature
    USE par_oce , ONLY :   jp_sal   =>   jp_sal     !: indice for salinity
 
-   !* IO manager *
-   USE in_out_manager    
- 
-   !* Memory Allocation *
-   USE wrk_nemo      
- 
-   !* Timing *
-   USE timing    
- 
-   !* MPP library                         
-   USE lib_mpp 
-
-   !* Fortran utilities                         
-   USE lib_fortran
-
-   !* Lateral boundary conditions                         
-   USE lbclnk
-
-   !* physical constants *
-   USE phycst            
-
-   !* 1D configuration
-   USE c1d                                         
-
-   !* model domain *
-   USE dom_oce 
+   USE in_out_manager                           !* IO manager *
+   USE wrk_nemo                                 !* Memory Allocation *
+   USE timing                                   !* Timing * 
+   USE lib_mpp                                  !* MPP library                         
+   USE lib_fortran                              !* Fortran utilities                         
+   USE lbclnk                                   !* Lateral boundary conditions                         
+   USE phycst                                   !* physical constants *
+   USE c1d                                      !* 1D configuration
+   USE dom_oce                                  !* model domain *
 
    USE domvvl, ONLY : un_td, vn_td          !: thickness diffusion transport
@@ -56,6 +38,4 @@
 
    !* ocean fields: here now and after fields *
-   USE oce , ONLY :   ua      =>    ua      !: i-horizontal velocity (m s-1) 
-   USE oce , ONLY :   va      =>    va      !: j-horizontal velocity (m s-1)
    USE oce , ONLY :   un      =>    un      !: i-horizontal velocity (m s-1) 
    USE oce , ONLY :   vn      =>    vn      !: j-horizontal velocity (m s-1)
@@ -66,15 +46,11 @@
    USE oce , ONLY :   rhop    =>    rhop    !: potential volumic mass (kg m-3) 
    USE oce , ONLY :   rhd     =>    rhd     !: in situ density anomalie rhd=(rho-rau0)/rau0 (no units)
+   USE oce , ONLY :   hdivn   =>    hdivn   !: horizontal divergence (1/s)
+   USE oce , ONLY :   sshn    =>    sshn    !: sea surface height at t-point [m]   
+   USE oce , ONLY :   sshb    =>    sshb    !: sea surface height at t-point [m]   
+   USE oce , ONLY :   ssha    =>    ssha    !: sea surface height at t-point [m]   
 #if defined key_offline
    USE oce , ONLY :   rab_n   =>    rab_n   !: local thermal/haline expension ratio at T-points
 #endif
-   USE oce , ONLY :   hdivn   =>    hdivn   !: horizontal divergence (1/s)
-   USE oce , ONLY :   rotn    =>    rotn    !: relative vorticity    [s-1]
-   USE oce , ONLY :   hdivb   =>    hdivb   !: horizontal divergence (1/s)
-   USE oce , ONLY :   rotb    =>    rotb    !: relative vorticity    [s-1]
-   USE oce , ONLY :   sshn    =>    sshn    !: sea surface height at t-point [m]   
-   USE oce , ONLY :   sshb    =>    sshb    !: sea surface height at t-point [m]   
-   USE oce , ONLY :   ssha    =>    ssha    !: sea surface height at t-point [m]   
-   USE oce , ONLY :   l_traldf_rot => l_traldf_rot  !: rotated laplacian operator for lateral diffusion
 
    !* surface fluxes *
@@ -102,18 +78,27 @@
    USE trc_oce
 
+!!gm : I don't understand this as ldftra (where everything is defined) is used by TRC in all cases (ON/OFF-line)
+!!gm   so the following lines should be removed....   logical should be the one of TRC namelist
+!!gm   In case off coarsening....  the ( ahtu, ahtv, aeiu, aeiv) arrays are needed that's all.
    !* lateral diffusivity (tracers) *
-   USE ldftra_oce , ONLY :  rldf     =>   rldf        !: multiplicative coef. for lateral diffusivity
-   USE ldftra_oce , ONLY :  rn_aht_0 =>   rn_aht_0    !: horizontal eddy diffusivity for tracers (m2/s)
-   USE ldftra_oce , ONLY :  aht0     =>   aht0        !: horizontal eddy diffusivity for tracers (m2/s)
-   USE ldftra_oce , ONLY :  ahtb0    =>   ahtb0       !: background eddy diffusivity for isopycnal diff. (m2/s)
-   USE ldftra_oce , ONLY :  ahtu     =>   ahtu        !: lateral diffusivity coef. at u-points 
-   USE ldftra_oce , ONLY :  ahtv     =>   ahtv        !: lateral diffusivity coef. at v-points 
-   USE ldftra_oce , ONLY :  ahtw     =>   ahtw        !: lateral diffusivity coef. at w-points 
-   USE ldftra_oce , ONLY :  ahtt     =>   ahtt        !: lateral diffusivity coef. at t-points
-   USE ldftra_oce , ONLY :  aeiv0    =>   aeiv0       !: eddy induced velocity coefficient (m2/s) 
-   USE ldftra_oce , ONLY :  aeiu     =>   aeiu        !: eddy induced velocity coef. at u-points (m2/s)   
-   USE ldftra_oce , ONLY :  aeiv     =>   aeiv        !: eddy induced velocity coef. at v-points (m2/s) 
-   USE ldftra_oce , ONLY :  aeiw     =>   aeiw        !: eddy induced velocity coef. at w-points (m2/s) 
-   USE ldftra_oce , ONLY :  lk_traldf_eiv  =>  lk_traldf_eiv     !: eddy induced velocity flag
+   USE ldftra , ONLY :  rn_aht_0     =>   rn_aht_0     !:   laplacian lateral eddy diffusivity [m2/s]
+   USE ldftra , ONLY :  rn_bht_0     =>   rn_bht_0     !: bilaplacian lateral eddy diffusivity [m4/s]
+   USE ldftra , ONLY :  ahtu         =>   ahtu         !: lateral diffusivity coef. at u-points 
+   USE ldftra , ONLY :  ahtv         =>   ahtv         !: lateral diffusivity coef. at v-points 
+   USE ldftra , ONLY :  rn_aeiv_0    =>   rn_aeiv_0    !: eddy induced velocity coefficient (m2/s) 
+   USE ldftra , ONLY :  aeiu         =>   aeiu         !: eddy induced velocity coef. at u-points (m2/s)   
+   USE ldftra , ONLY :  aeiv         =>   aeiv         !: eddy induced velocity coef. at v-points (m2/s) 
+   USE ldftra , ONLY :  ln_ldfeiv    =>   ln_ldfeiv    !: eddy induced velocity flag
+     
+!!gm this should be : ln_trcldf_triad (TRC namelist)
+   USE ldfslp , ONLY :  ln_traldf_triad => ln_traldf_triad   !: triad scheme (Griffies et al.)
+
+   !* direction of lateral diffusion *
+   USE ldfslp , ONLY :   l_ldfslp  =>  l_ldfslp       !: slopes flag
+   USE ldfslp , ONLY :   uslp       =>   uslp         !: i-slope at u-point
+   USE ldfslp , ONLY :   vslp       =>   vslp         !: j-slope at v-point
+   USE ldfslp , ONLY :   wslpi      =>   wslpi        !: i-slope at w-point
+   USE ldfslp , ONLY :   wslpj      =>   wslpj        !: j-slope at w-point
+!!gm end 
 
    !* vertical diffusion *
@@ -128,13 +113,4 @@
    USE zdfmxl , ONLY :   hmlp        =>   hmlp        !: mixed layer depth  (rho=rho0+zdcrit) (m)
    USE zdfmxl , ONLY :   hmlpt       =>   hmlpt       !: mixed layer depth at t-points (m)
-
-   !* direction of lateral diffusion *
-   USE ldfslp , ONLY :   lk_ldfslp  =>  lk_ldfslp     !: slopes flag
-# if   defined key_ldfslp
-   USE ldfslp , ONLY :   uslp       =>   uslp         !: i-direction slope at u-, w-points
-   USE ldfslp , ONLY :   vslp       =>   vslp         !: j-direction slope at v-, w-points
-   USE ldfslp , ONLY :   wslpi      =>   wslpi        !: i-direction slope at u-, w-points
-   USE ldfslp , ONLY :   wslpj      =>   wslpj        !: j-direction slope at v-, w-points
-# endif
 
    USE diaar5 , ONLY :   lk_diaar5  =>   lk_diaar5
Index: anches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/top_substitute.h90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/top_substitute.h90	(revision 6040)
+++ 	(revision )
@@ -1,17 +1,0 @@
-   !!----------------------------------------------------------------------
-   !!                    ***  top_substitute.h90   ***
-   !!----------------------------------------------------------------------
-   !! ** purpose : Statement function file: to be include in all passive tracer modules
-   !!----------------------------------------------------------------------
-   !! History :   1.0  !  2004-03 (C. Ethe) Original code
-   !!             2.0  !  2007-12 (C. Ethe, G. Madec) new architecture
-   !!----------------------------------------------------------------------
-#  include "domzgr_substitute.h90"
-#  include "ldfeiv_substitute.h90"
-#  include "ldftra_substitute.h90"
-#  include "vectopt_loop_substitute.h90"
-   !!----------------------------------------------------------------------
-   !! NEMO/TOP 3.3 , NEMO Consortium (2010)
-   !! $Id$ 
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
-   !!----------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trc.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trc.F90	(revision 6041)
@@ -143,10 +143,4 @@
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  avs_tm      !: vertical double diffusivity coeff. at w-point   [m/s]
 # endif
-#if defined key_ldfslp
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  wslpi_tm    !: i-direction slope at u-, w-points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  wslpj_tm    !: j-direction slope at u-, w-points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  uslp_tm     !: j-direction slope at u-, w-points
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  vslp_tm     !: j-direction slope at u-, w-points
-#endif
 #if defined key_trabbl
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)     ::  ahu_bbl_tm  !: u-, w-points
@@ -183,8 +177,4 @@
 #endif
    !
-#if defined key_ldfslp
-   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  wslpi_temp, wslpj_temp, uslp_temp, vslp_temp    !: hold current values 
-#endif
-   ! 
 # if defined key_zdfddm
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  avs_temp      !: salinity vertical diffusivity coeff. at w-point   [m/s]
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcdia.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcdia.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcdia.F90	(revision 6041)
@@ -51,6 +51,4 @@
    INTEGER  ::   nhoritb   !:  id for horizontal mesh
 
-   !! * Substitutions
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcini.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcini.F90	(revision 6041)
@@ -18,15 +18,9 @@
    USE oce_trc         ! shared variables between ocean and passive tracers
    USE trc             ! passive tracers common variables
-   USE trcrst          ! passive tracers restart
    USE trcnam          ! Namelist read
-   USE trcini_cfc      ! CFC      initialisation
-   USE trcini_pisces   ! PISCES   initialisation
-   USE trcini_c14b     ! C14 bomb initialisation
-   USE trcini_my_trc   ! MY_TRC   initialisation
-   USE trcdta          ! initialisation from files
    USE daymod          ! calendar manager
-   USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
    USE prtctl_trc      ! Print control passive tracers (prt_ctl_trc_init routine)
    USE trcsub          ! variables to substep passive tracers
+   USE trcrst
    USE lib_mpp         ! distribued memory computing library
    USE sbc_oce
@@ -59,8 +53,4 @@
       !!                or read data or analytical formulation
       !!---------------------------------------------------------------------
-      INTEGER ::   jk, jn, jl    ! dummy loop indices
-      CHARACTER (len=25) :: charout
-      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 4D  workspace
-      !!---------------------------------------------------------------------
       !
       IF( nn_timing == 1 )   CALL timing_start('trc_init')
@@ -70,23 +60,61 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~'
 
-      CALL top_alloc()              ! allocate TOP arrays
-
+      !
+      CALL top_alloc()   ! allocate TOP arrays
+      !
+      CALL trc_ini_ctl   ! control 
+      !
+      CALL trc_nam       ! read passive tracers namelists
+      !
+      IF(lwp) WRITE(numout,*)
+      !
+      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
+      !
+      IF(lwp) WRITE(numout,*)
+      !
+      CALL trc_ini_sms   ! SMS
+      !
+      CALL trc_ini_trp   ! passive tracers transport
+      !
+      CALL trc_ice_ini   ! Tracers in sea ice
+      !
+      IF( lwp )  &
+         &  CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
+      !
+      CALL trc_ini_state  !  passive tracers initialisation : from a restart or from clim
+      !
+      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
+      !
+      CALL trc_ini_inv   ! Inventories
+      !
+      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
+      !
+   END SUBROUTINE trc_init
+
+
+   SUBROUTINE trc_ini_ctl
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ini_ctl  ***
+      !! ** Purpose :        Control  + ocean volume
+      !!----------------------------------------------------------------------
+      INTEGER ::   jk    ! dummy loop indices
+      !
+      ! Define logical parameter ton control dirunal cycle in TOP
       l_trcdm2dc = ln_dm2dc .OR. ( ln_cpl .AND. ncpl_qsr_freq /= 1 )
       l_trcdm2dc = l_trcdm2dc  .AND. .NOT. lk_offline
-      IF( l_trcdm2dc .AND. lwp ) &
-         &   CALL ctl_warn(' Coupling with passive tracers and used of diurnal cycle. &
-         & Computation of a daily mean shortwave for some biogeochemical models) ')
-
-      IF( nn_cla == 1 )   &
-         &  CALL ctl_stop( ' Cross Land Advection not yet implemented with passive tracer ; nn_cla must be 0' )
-
-      CALL trc_nam      ! read passive tracers namelists
-      !
-      IF(lwp) WRITE(numout,*)
-      !
-      IF( ln_rsttr .AND. .NOT. lk_offline ) CALL trc_rst_cal( nit000, 'READ' )   ! calendar
-      !
-      IF(lwp) WRITE(numout,*)
-                                                              ! masked grid volume
+      IF( l_trcdm2dc .AND. lwp )   CALL ctl_warn( 'Coupling with passive tracers and used of diurnal cycle.',   &
+         &                           'Computation of a daily mean shortwave for some biogeochemical models ' )
+      !
+   END SUBROUTINE trc_ini_ctl
+
+
+   SUBROUTINE trc_ini_inv
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ini_stat  ***
+      !! ** Purpose :      passive tracers inventories at initialsation phase
+      !!----------------------------------------------------------------------
+      INTEGER ::  jk, jn    ! dummy loop indices
+      CHARACTER (len=25) :: charout
+      !!----------------------------------------------------------------------
       !                                                              ! masked grid volume
       DO jk = 1, jpk
@@ -96,20 +124,89 @@
       !                                                              ! total volume of the ocean 
       areatot = glob_sum( cvol(:,:,:) )
-
+      !
+      trai(:) = 0._wp                                                   ! initial content of all tracers
+      DO jn = 1, jptra
+         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
+      END DO
+
+      IF(lwp) THEN               ! control print
+         WRITE(numout,*)
+         WRITE(numout,*)
+         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
+         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
+         WRITE(numout,*) '          *** Total inital content of all tracers '
+         WRITE(numout,*)
+         DO jn = 1, jptra
+            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
+         ENDDO
+         WRITE(numout,*)
+      ENDIF
+      IF(lwp) WRITE(numout,*)
+      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
+         CALL prt_ctl_trc_init
+         WRITE(charout, FMT="('ini ')")
+         CALL prt_ctl_trc_info( charout )
+         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
+      ENDIF
+9000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
+      !
+   END SUBROUTINE trc_ini_inv
+
+
+   SUBROUTINE trc_ini_sms
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ini_sms  ***
+      !! ** Purpose :   SMS initialisation
+      !!----------------------------------------------------------------------
+      USE trcini_cfc      ! CFC      initialisation
+      USE trcini_pisces   ! PISCES   initialisation
+      USE trcini_c14b     ! C14 bomb initialisation
+      USE trcini_my_trc   ! MY_TRC   initialisation
+      !!----------------------------------------------------------------------
       IF( lk_pisces  )       CALL trc_ini_pisces       ! PISCES  bio-model
       IF( lk_cfc     )       CALL trc_ini_cfc          ! CFC     tracers
       IF( lk_c14b    )       CALL trc_ini_c14b         ! C14 bomb  tracer
       IF( lk_my_trc  )       CALL trc_ini_my_trc       ! MY_TRC  tracers
-
-      CALL trc_ice_ini                                 ! Tracers in sea ice
-
-      IF( lwp ) THEN
-         !
-         CALL ctl_opn( numstr, 'tracer.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp , narea )
-         !
-      ENDIF
-
+      !
+   END SUBROUTINE trc_ini_sms
+
+   SUBROUTINE trc_ini_trp
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ini_trp  ***
+      !!
+      !! ** Purpose :   Allocate all the dynamic arrays of the OPA modules
+      !!----------------------------------------------------------------------
+      USE trcdmp , ONLY:  trc_dmp_ini
+      USE trcadv , ONLY:  trc_adv_ini
+      USE trcldf , ONLY:  trc_ldf_ini
+      USE trczdf , ONLY:  trc_zdf_ini
+      USE trcrad , ONLY:  trc_rad_ini
+      !
+      INTEGER :: ierr
+      !!----------------------------------------------------------------------
+      !
+      IF( ln_trcdmp )  CALL  trc_dmp_ini          ! damping
+                       CALL  trc_adv_ini          ! advection
+                       CALL  trc_ldf_ini          ! lateral diffusion
+                       CALL  trc_zdf_ini          ! vertical diffusion
+                       CALL  trc_rad_ini          ! positivity of passive tracers 
+      !
+   END SUBROUTINE trc_ini_trp
+
+
+   SUBROUTINE trc_ini_state
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE trc_ini_state ***
+      !! ** Purpose :          Initialisation of passive tracer concentration 
+      !!----------------------------------------------------------------------
+      USE zpshde          ! partial step: hor. derivative   (zps_hde routine)
+      USE trcrst          ! passive tracers restart
+      USE trcdta          ! initialisation from files
+      !
+      INTEGER ::   jk, jn, jl    ! dummy loop indices
+      REAL(wp), POINTER, DIMENSION(:,:,:) ::  ztrcdta   ! 4D  workspace
+      !!----------------------------------------------------------------------
+      !
       IF( ln_trcdta )      CALL trc_dta_init(jptra)
-
 
       IF( ln_rsttr ) THEN
@@ -146,43 +243,6 @@
  
       tra(:,:,:,:) = 0._wp
-      IF( ln_zps .AND. .NOT. lk_c1d .AND. .NOT. ln_isfcav )   &              ! Partial steps: before horizontal gradient of passive
-        &    CALL zps_hde    ( nit000, jptra, trn, gtru, gtrv  )  ! Partial steps: before horizontal gradient
-      IF( ln_zps .AND. .NOT. lk_c1d .AND.       ln_isfcav )   &
-        &    CALL zps_hde_isf( nit000, jptra, trn, pgtu=gtru, pgtv=gtrv, pgtui=gtrui, pgtvi=gtrvi )       ! tracers at the bottom ocean level
-
-
-      !
-      IF( nn_dttrc /= 1 )        CALL trc_sub_ini      ! Initialize variables for substepping passive tracers
-      !
-
-      trai(:) = 0._wp                                                   ! initial content of all tracers
-      DO jn = 1, jptra
-         trai(jn) = trai(jn) + glob_sum( trn(:,:,:,jn) * cvol(:,:,:)   )
-      END DO
-
-      IF(lwp) THEN               ! control print
-         WRITE(numout,*)
-         WRITE(numout,*)
-         WRITE(numout,*) '          *** Total number of passive tracer jptra = ', jptra
-         WRITE(numout,*) '          *** Total volume of ocean                = ', areatot
-         WRITE(numout,*) '          *** Total inital content of all tracers '
-         WRITE(numout,*)
-         DO jn = 1, jptra
-            WRITE(numout,9000) jn, TRIM( ctrcnm(jn) ), trai(jn)
-         ENDDO
-         WRITE(numout,*)
-      ENDIF
-      IF(lwp) WRITE(numout,*)
-      IF(ln_ctl) THEN            ! print mean trends (used for debugging)
-         CALL prt_ctl_trc_init
-         WRITE(charout, FMT="('ini ')")
-         CALL prt_ctl_trc_info( charout )
-         CALL prt_ctl_trc( tab4d=trn, mask=tmask, clinfo=ctrcnm )
-      ENDIF
-9000  FORMAT(' tracer nb : ',i2,'      name :',a10,'      initial content :',e18.10)
-      !
-      IF( nn_timing == 1 )   CALL timing_stop('trc_init')
-      !
-   END SUBROUTINE trc_init
+      !                                                         ! Partial top/bottom cell: GRADh(trn)
+   END SUBROUTINE trc_ini_state
 
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcnam.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcnam.F90	(revision 6041)
@@ -20,5 +20,4 @@
    USE oce_trc           ! shared variables between ocean and passive tracers
    USE trc               ! passive tracers common variables
-   USE trcnam_trp        ! Transport namelist
    USE trcnam_pisces     ! PISCES namelist
    USE trcnam_cfc        ! CFC SMS namelist
@@ -35,6 +34,4 @@
    PUBLIC trc_nam      ! called in trcini
 
-   !! * Substitutions
-#  include "top_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -42,7 +39,5 @@
    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
-
 
    SUBROUTINE trc_nam
@@ -57,26 +52,19 @@
       !!---------------------------------------------------------------------
       INTEGER  ::   jn                  ! dummy loop indice
-      !                                        !   Parameters of the run 
-      IF( .NOT. lk_offline ) CALL trc_nam_run
-      
-      !                                        !  passive tracer informations
-      CALL trc_nam_trc
-      
-      !                                        !   Parameters of additional diagnostics
-      CALL trc_nam_dia
-
-      !                                        !   namelist of transport
-      CALL trc_nam_trp
-
-
-      IF( ln_rsttr )                      ln_trcdta = .FALSE.   ! restart : no need of clim data
-      !
-      IF( ln_trcdmp .OR. ln_trcdmp_clo )  ln_trcdta = .TRUE.   ! damping : need to have clim data
-      !
-      IF( .NOT.ln_trcdta ) THEN
-         ln_trc_ini(:) = .FALSE.
-      ENDIF
-
-     IF(lwp) THEN                   ! control print
+      !                                  
+      IF( .NOT.lk_offline )   CALL trc_nam_run     ! Parameters of the run 
+      !               
+                              CALL trc_nam_trc     ! passive tracer informations
+      !                                        
+                              CALL trc_nam_dia     ! Parameters of additional diagnostics
+      !                                      
+      !
+      IF( ln_rsttr                     )   ln_trcdta     = .FALSE.   ! restart : no need of clim data
+      !
+      IF( ln_trcdmp .OR. ln_trcdmp_clo )   ln_trcdta     = .TRUE.   ! damping : need to have clim data
+      !
+      IF( .NOT.ln_trcdta               )   ln_trc_ini(:) = .FALSE.
+
+      IF(lwp) THEN                   ! control print
          WRITE(numout,*)
          WRITE(numout,*) ' Namelist : namtrc'
@@ -149,5 +137,5 @@
       ! Call the ice module for tracers
       ! -------------------------------
-      CALL trc_nam_ice
+                                  CALL trc_nam_ice
 
       ! namelist of SMS
@@ -171,4 +159,5 @@
    END SUBROUTINE trc_nam
 
+
    SUBROUTINE trc_nam_run
       !!---------------------------------------------------------------------
@@ -180,11 +169,8 @@
       NAMELIST/namtrc_run/ nn_dttrc, nn_writetrc, ln_rsttr, nn_rsttr, ln_top_euler, &
         &                  cn_trcrst_indir, cn_trcrst_outdir, cn_trcrst_in, cn_trcrst_out
-
-
+      !
       INTEGER  ::   ios                 ! Local integer output status for namelist read
-
-      !!---------------------------------------------------------------------
-
-
+      !!---------------------------------------------------------------------
+      !
       IF(lwp) WRITE(numout,*) 'trc_nam : read the passive tracer namelists'
       IF(lwp) WRITE(numout,*) '~~~~~~~'
@@ -220,4 +206,5 @@
     END SUBROUTINE trc_nam_run
 
+
    SUBROUTINE trc_nam_ice
       !!---------------------------------------------------------------------
@@ -229,12 +216,12 @@
       !!
       !!---------------------------------------------------------------------
-      ! --- Variable declarations --- !
       INTEGER :: jn      ! dummy loop indices
       INTEGER :: ios     ! Local integer output status for namelist read
-
-      ! --- Namelist declarations --- !
+      !
       TYPE(TRC_I_NML), DIMENSION(jptra) :: sn_tri_tracer
+      !!
       NAMELIST/namtrc_ice/ nn_ice_tr, sn_tri_tracer
-
+      !!---------------------------------------------------------------------
+      !
       IF(lwp) THEN
          WRITE(numout,*)
@@ -271,4 +258,5 @@
    END SUBROUTINE trc_nam_ice
 
+
    SUBROUTINE trc_nam_trc
       !!---------------------------------------------------------------------
@@ -278,15 +266,14 @@
       !!
       !!---------------------------------------------------------------------
-      TYPE(PTRACER), DIMENSION(jptra) :: sn_tracer  ! type of tracer for saving if not key_iomput
-      !!
-      NAMELIST/namtrc/ sn_tracer, ln_trcdta,ln_trcdmp, ln_trcdmp_clo
-  
       INTEGER  ::   ios                 ! Local integer output status for namelist read
       INTEGER  ::   jn                  ! dummy loop indice
+      !
+      TYPE(PTRACER), DIMENSION(jptra) :: sn_tracer  ! type of tracer for saving if not key_iomput
+      !!
+      NAMELIST/namtrc/ sn_tracer, ln_trcdta,ln_trcdmp, ln_trcdmp_clo
       !!---------------------------------------------------------------------
       IF(lwp) WRITE(numout,*)
       IF(lwp) WRITE(numout,*) 'trc_nam : read the passive tracer namelists'
       IF(lwp) WRITE(numout,*) '~~~~~~~'
-
 
       REWIND( numnat_ref )              ! Namelist namtrc in reference namelist : Passive tracer variables
@@ -306,6 +293,6 @@
          ln_trc_wri(jn) =       sn_tracer(jn)%llsave
       END DO
-      
-    END SUBROUTINE trc_nam_trc
+      !
+   END SUBROUTINE trc_nam_trc
 
 
@@ -320,5 +307,7 @@
       !!                ( (PISCES, CFC, MY_TRC )
       !!---------------------------------------------------------------------
+      INTEGER  ::   ios                 ! Local integer output status for namelist read
       INTEGER ::  ierr
+      !!
 #if defined key_trdmxl_trc  || defined key_trdtrc
       NAMELIST/namtrc_trd/ nn_trd_trc, nn_ctls_trc, rn_ucf_trc, &
@@ -327,6 +316,4 @@
 #endif
       NAMELIST/namtrc_dia/ ln_diatrc, ln_diabio, nn_writedia, nn_writebio
-
-      INTEGER  ::   ios                 ! Local integer output status for namelist read
       !!---------------------------------------------------------------------
 
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcrst.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcrst.F90	(revision 6041)
@@ -25,5 +25,4 @@
    USE oce_trc
    USE trc
-   USE trcnam_trp
    USE iom
    USE daymod
@@ -37,5 +36,5 @@
 
    !! * Substitutions
-#  include "top_substitute.h90"
+#  include "domzgr_substitute.h90"
    
 CONTAINS
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcsub.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcsub.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcsub.F90	(revision 6041)
@@ -25,5 +25,5 @@
    USE zdf_oce
    USE domvvl
-   USE divcur          ! hor. divergence and curl      (div & cur routines)
+   USE divhor          ! horizontal divergence            (div_hor routine)
    USE sbcrnf, ONLY: h_rnf, nk_rnf   ! River runoff 
    USE bdy_oce
@@ -44,6 +44,10 @@
    REAL(wp)  :: r1_ndttrcp1   !    1 / (nn_dttrc+1) 
 
-   !!* Substitution
-#  include "top_substitute.h90"
+   !                                                       !* iso-neutral slopes (if l_ldfslp=T)
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  uslp_temp, vslp_temp, wslpi_temp, wslpj_temp   !: hold current values 
+   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::  uslp_tm  , vslp_tm  , wslpi_tm  , wslpj_tm     !: time mean 
+
+   !! * Substitutions
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/TOP 3.3 , NEMO Consortium (2010)
@@ -93,10 +97,10 @@
           avs_tm  (:,:,:)        = avs_tm  (:,:,:)        + avs  (:,:,:)        * fse3w(:,:,:)  
 # endif
-#if defined key_ldfslp
-          wslpi_tm(:,:,:)        = wslpi_tm(:,:,:)        + wslpi(:,:,:)
-          wslpj_tm(:,:,:)        = wslpj_tm(:,:,:)        + wslpj(:,:,:)
-          uslp_tm (:,:,:)        = uslp_tm (:,:,:)        + uslp (:,:,:)
-          vslp_tm (:,:,:)        = vslp_tm (:,:,:)        + vslp (:,:,:)
-#endif
+         IF( l_ldfslp ) THEN
+            uslp_tm (:,:,:)      = uslp_tm (:,:,:)        + uslp (:,:,:)
+            vslp_tm (:,:,:)      = vslp_tm (:,:,:)        + vslp (:,:,:)
+            wslpi_tm(:,:,:)      = wslpi_tm(:,:,:)        + wslpi(:,:,:)
+            wslpj_tm(:,:,:)      = wslpj_tm(:,:,:)        + wslpj(:,:,:)
+         ENDIF
 # if defined key_trabbl
           IF( nn_bbl_ldf == 1 ) THEN
@@ -131,10 +135,8 @@
          avs_temp   (:,:,:)      = avs   (:,:,:)
 # endif
-#if defined key_ldfslp
-         wslpi_temp (:,:,:)      = wslpi (:,:,:)
-         wslpj_temp (:,:,:)      = wslpj (:,:,:)
-         uslp_temp  (:,:,:)      = uslp  (:,:,:)
-         vslp_temp  (:,:,:)      = vslp  (:,:,:)
-#endif
+         IF( l_ldfslp ) THEN
+            uslp_temp  (:,:,:)   = uslp  (:,:,:)   ;   wslpi_temp (:,:,:)   = wslpi (:,:,:)
+            vslp_temp  (:,:,:)   = vslp  (:,:,:)   ;   wslpj_temp (:,:,:)   = wslpj (:,:,:)
+         ENDIF
 # if defined key_trabbl
           IF( nn_bbl_ldf == 1 ) THEN
@@ -160,8 +162,5 @@
          wndm_temp  (:,:)        = wndm  (:,:)
          !                                    !  Variables reset in trc_sub_ssh
-         rotn_temp  (:,:,:)      = rotn  (:,:,:)
          hdivn_temp (:,:,:)      = hdivn (:,:,:)
-         rotb_temp  (:,:,:)      = rotb  (:,:,:)
-         hdivb_temp (:,:,:)      = hdivb (:,:,:)
          !
          ! 2. Create averages and reassign variables
@@ -175,10 +174,10 @@
          avs_tm   (:,:,:)        = avs_tm  (:,:,:)        + avs  (:,:,:)        * fse3w(:,:,:)  
 # endif
-#if defined key_ldfslp
-         wslpi_tm (:,:,:)        = wslpi_tm(:,:,:)        + wslpi(:,:,:) 
-         wslpj_tm (:,:,:)        = wslpj_tm(:,:,:)        + wslpj(:,:,:) 
-         uslp_tm  (:,:,:)        = uslp_tm (:,:,:)        + uslp (:,:,:) 
-         vslp_tm  (:,:,:)        = vslp_tm (:,:,:)        + vslp (:,:,:)
-#endif
+         IF( l_ldfslp ) THEN
+            uslp_tm  (:,:,:)     = uslp_tm (:,:,:)        + uslp (:,:,:) 
+            vslp_tm  (:,:,:)     = vslp_tm (:,:,:)        + vslp (:,:,:)
+            wslpi_tm (:,:,:)     = wslpi_tm(:,:,:)        + wslpi(:,:,:) 
+            wslpj_tm (:,:,:)     = wslpj_tm(:,:,:)        + wslpj(:,:,:) 
+         ENDIF
 # if defined key_trabbl
           IF( nn_bbl_ldf == 1 ) THEN
@@ -255,17 +254,18 @@
                   tsn  (ji,jj,jk,jp_sal) = tsn_tm  (ji,jj,jk,jp_sal) * z1_ne3t
                   rhop (ji,jj,jk)        = rhop_tm (ji,jj,jk)        * z1_ne3t
+!!gm : BUG? ==>> for avt & avs I don't understand the division by e3w
                   avt  (ji,jj,jk)        = avt_tm  (ji,jj,jk)        * z1_ne3w
 # if defined key_zdfddm
                   avs  (ji,jj,jk)        = avs_tm  (ji,jj,jk)        * z1_ne3w
 # endif
-#if defined key_ldfslp
-                  wslpi(ji,jj,jk)        = wslpi_tm(ji,jj,jk) 
-                  wslpj(ji,jj,jk)        = wslpj_tm(ji,jj,jk)
-                  uslp (ji,jj,jk)        = uslp_tm (ji,jj,jk)
-                  vslp (ji,jj,jk)        = vslp_tm (ji,jj,jk)
-#endif
-               ENDDO
-            ENDDO
-         ENDDO
+               END DO
+            END DO
+         END DO
+         IF( l_ldfslp ) THEN
+            wslpi(:,:,:)        = wslpi_tm(:,:,:) 
+            wslpj(:,:,:)        = wslpj_tm(:,:,:)
+            uslp (:,:,:)        = uslp_tm (:,:,:)
+            vslp (:,:,:)        = vslp_tm (:,:,:)
+         ENDIF
          !
          CALL trc_sub_ssh( kt )         ! after ssh & vertical velocity
@@ -276,4 +276,5 @@
       !
    END SUBROUTINE trc_sub_stp
+
 
    SUBROUTINE trc_sub_ini
@@ -304,14 +305,15 @@
       tsn_tm  (:,:,:,jp_sal) = tsn  (:,:,:,jp_sal) * fse3t(:,:,:)  
       rhop_tm (:,:,:)        = rhop (:,:,:)        * fse3t(:,:,:)  
+!!gm : BUG? ==>> for avt & avs I don't understand the division by e3w
       avt_tm  (:,:,:)        = avt  (:,:,:)        * fse3w(:,:,:)  
 # if defined key_zdfddm
       avs_tm  (:,:,:)        = avs  (:,:,:)        * fse3w(:,:,:)  
 # endif
-#if defined key_ldfslp
-      wslpi_tm(:,:,:)        = wslpi(:,:,:)
-      wslpj_tm(:,:,:)        = wslpj(:,:,:)
-      uslp_tm (:,:,:)        = uslp (:,:,:)
-      vslp_tm (:,:,:)        = vslp (:,:,:)
-#endif
+      IF( l_ldfslp ) THEN
+         wslpi_tm(:,:,:)     = wslpi(:,:,:)
+         wslpj_tm(:,:,:)     = wslpj(:,:,:)
+         uslp_tm (:,:,:)     = uslp (:,:,:)
+         vslp_tm (:,:,:)     = vslp (:,:,:)
+      ENDIF
       sshn_tm  (:,:) = sshn  (:,:) 
       rnf_tm   (:,:) = rnf   (:,:) 
@@ -365,10 +367,10 @@
       avs   (:,:,:)   =  avs_temp   (:,:,:)
 # endif
-#if defined key_ldfslp
-      wslpi (:,:,:)   =  wslpi_temp (:,:,:)
-      wslpj (:,:,:)   =  wslpj_temp (:,:,:)
-      uslp  (:,:,:)   =  uslp_temp  (:,:,:)
-      vslp  (:,:,:)   =  vslp_temp  (:,:,:)
-#endif
+      IF( l_ldfslp ) THEN
+         wslpi (:,:,:)=  wslpi_temp (:,:,:)
+         wslpj (:,:,:)=  wslpj_temp (:,:,:)
+         uslp  (:,:,:)=  uslp_temp  (:,:,:)
+         vslp  (:,:,:)=  vslp_temp  (:,:,:)
+      ENDIF
       sshn  (:,:)     =  sshn_temp  (:,:)
       sshb  (:,:)     =  sshb_temp  (:,:)
@@ -396,9 +398,5 @@
       !
       hdivn (:,:,:)   =  hdivn_temp (:,:,:)
-      rotn  (:,:,:)   =  rotn_temp  (:,:,:)
-      hdivb (:,:,:)   =  hdivb_temp (:,:,:)
-      rotb  (:,:,:)   =  rotb_temp  (:,:,:)
       !                                      
-
       ! Start new averages
          un_tm   (:,:,:)        = un   (:,:,:)        * fse3u(:,:,:) 
@@ -411,10 +409,10 @@
          avs_tm  (:,:,:)        = avs  (:,:,:)        * fse3w(:,:,:)  
 # endif
-#if defined key_ldfslp
+      IF( l_ldfslp ) THEN
+         uslp_tm (:,:,:)        = uslp (:,:,:)
+         vslp_tm (:,:,:)        = vslp (:,:,:)
          wslpi_tm(:,:,:)        = wslpi(:,:,:) 
          wslpj_tm(:,:,:)        = wslpj(:,:,:)
-         uslp_tm (:,:,:)        = uslp (:,:,:)
-         vslp_tm (:,:,:)        = vslp (:,:,:)
-#endif
+      ENDIF
       !
       sshb_hold  (:,:) = sshn  (:,:)
@@ -487,5 +485,5 @@
       ENDIF
       !
-      CALL div_cur( kt )                              ! Horizontal divergence & Relative vorticity
+      CALL div_hor( kt )                              ! Horizontal divergence & Relative vorticity
       !
       z2dt = 2._wp * rdt                              ! set time step size (Euler/Leapfrog)
@@ -504,5 +502,5 @@
       z1_rau0 = 0.5 / rau0
       ssha(:,:) = (  sshb(:,:) - z2dt * ( z1_rau0 * ( emp_b(:,:) + emp(:,:) ) + zhdiv(:,:) )  ) * tmask(:,:,1)
-#if ! defined key_dynspg_ts
+
       ! These lines are not necessary with time splitting since
       ! boundary condition on sea level is set during ts loop
@@ -514,6 +512,4 @@
       CALL lbc_lnk( ssha, 'T', 1. ) 
 #endif
-#endif
-
 
       !                                           !------------------------------!
@@ -551,8 +547,4 @@
          &      sshn_temp(jpi,jpj)          ,  sshb_temp(jpi,jpj) ,      &
          &      ssha_temp(jpi,jpj)          ,                           &
-#if defined key_ldfslp
-         &      wslpi_temp(jpi,jpj,jpk)     ,  wslpj_temp(jpi,jpj,jpk),  &
-         &      uslp_temp(jpi,jpj,jpk)      ,  vslp_temp(jpi,jpj,jpk),   &
-#endif
 #if defined key_trabbl
          &      ahu_bbl_temp(jpi,jpj)       ,  ahv_bbl_temp(jpi,jpj),    &
@@ -569,5 +561,4 @@
 # endif
          &      hdivn_temp(jpi,jpj,jpk)     ,  hdivb_temp(jpi,jpj,jpk),  &
-         &      rotn_temp(jpi,jpj,jpk)      ,  rotb_temp(jpi,jpj,jpk),   &
          &      un_tm(jpi,jpj,jpk)          ,  vn_tm(jpi,jpj,jpk)  ,     &
          &      avt_tm(jpi,jpj,jpk)                                ,     &
@@ -577,16 +568,20 @@
          &      emp_b_hold(jpi,jpj)         ,                            &
          &      hmld_tm(jpi,jpj)            ,  qsr_tm(jpi,jpj) ,         &
-#if defined key_ldfslp
-         &      wslpi_tm(jpi,jpj,jpk)       ,  wslpj_tm(jpi,jpj,jpk),    &
-         &      uslp_tm(jpi,jpj,jpk)        ,  vslp_tm(jpi,jpj,jpk),     &
-#endif
 #if defined key_trabbl
          &      ahu_bbl_tm(jpi,jpj)         ,  ahv_bbl_tm(jpi,jpj),      &
          &      utr_bbl_tm(jpi,jpj)         ,  vtr_bbl_tm(jpi,jpj),      &
 #endif
-         &      rnf_tm(jpi,jpj)             ,  h_rnf_tm(jpi,jpj) ,       &
-         &                                    STAT=trc_sub_alloc )  
+         &      rnf_tm(jpi,jpj)             ,  h_rnf_tm(jpi,jpj) , STAT=trc_sub_alloc )  
+      !
       IF( trc_sub_alloc /= 0 )   CALL ctl_warn('trc_sub_alloc: failed to allocate arrays')
-
+      !
+      IF( l_ldfslp ) THEN
+         ALLOCATE( uslp_temp(jpi,jpj,jpk)   ,  wslpi_temp(jpi,jpj,jpk),      &
+            &      vslp_temp(jpi,jpj,jpk)   ,  wslpj_temp(jpi,jpj,jpk),      &
+            &      uslp_tm  (jpi,jpj,jpk)   ,  wslpi_tm  (jpi,jpj,jpk),      &
+            &      vslp_tm  (jpi,jpj,jpk)   ,  wslpj_tm  (jpi,jpj,jpk),  STAT=trc_sub_alloc )
+      ENDIF
+      !
+      IF( trc_sub_alloc /= 0 )   CALL ctl_warn('trc_sub_alloc: failed to allocate ldf_slp arrays')
       !
    END FUNCTION trc_sub_alloc
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcwri.F90
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcwri.F90	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/NEMO/TOP_SRC/trcwri.F90	(revision 6041)
@@ -26,7 +26,4 @@
 
    PUBLIC trc_wri      
-
-   !! * Substitutions
-#  include "top_substitute.h90"
 
 CONTAINS
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/param.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/param.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/param.cfg	(revision 6041)
@@ -1,8 +1,8 @@
-#- forcing files storing 
+#- forcing files storing
 FORCING_DIR=~/FORCING
-#- input files storing 
+#- input files storing
 INPUT_DIR=${CONFIG_DIR}/${NEW_CONF}/EXP00
 #- only for IBM
 #TMPDIR=${CONFIG_DIR}/${NEW_CONF}/EXP00
-#- VALIDATION files storing 
+#- VALIDATION files storing
 NEMO_VALIDATION_DIR=~/NEMO_VALIDATION
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/sette.sh
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/sette.sh	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/sette.sh	(revision 6041)
@@ -143,4 +143,5 @@
 # ORCA2_AGRIF_LIM :16 & 17 
 #                  18 & 19 
+
 for config in  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
 
@@ -167,5 +168,4 @@
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg nn_fwb 0
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 2
     set_namelist namelist_cfg jpnj 2
@@ -191,5 +191,4 @@
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg nn_fwb 0
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 2
     set_namelist namelist_cfg jpnj 2
@@ -237,5 +236,4 @@
     set_namelist namelist_cfg ln_ctl .false.
     set_namelist namelist_cfg ln_clobber .true.
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 1
     set_namelist namelist_cfg jpnj 4
@@ -264,5 +262,4 @@
     set_namelist namelist_cfg ln_ctl .false.
     set_namelist namelist_cfg ln_clobber .true.
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 2
     set_namelist namelist_cfg jpnj 2
@@ -291,5 +288,5 @@
     . ./prepare_exe_dir.sh
     JOB_FILE=${EXE_DIR}/run_job.sh
-    NPROC=4
+    NPROC=8
     if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
@@ -301,7 +298,6 @@
     set_namelist namelist_cfg nn_fwb 0
     set_namelist namelist_cfg jpni 2
-    set_namelist namelist_cfg jpnj 2
-    set_namelist namelist_cfg jpnij 4
-    set_namelist namelist_cfg nn_solv 2
+    set_namelist namelist_cfg jpnj 4
+    set_namelist namelist_cfg jpnij 8
     set_namelist namelist_top_cfg ln_trcdta .false.
     set_namelist namelist_top_cfg ln_diatrc .false.
@@ -337,7 +333,6 @@
     set_namelist namelist_cfg nn_fwb 0
     set_namelist namelist_cfg jpni 2
-    set_namelist namelist_cfg jpnj 2
-    set_namelist namelist_cfg jpnij 4
-    set_namelist namelist_cfg nn_solv 2
+    set_namelist namelist_cfg jpnj 4
+    set_namelist namelist_cfg jpnij 8
     set_namelist namelist_top_cfg ln_diatrc .false.
     set_namelist namelist_top_cfg ln_rsttr .true.
@@ -397,5 +392,4 @@
     set_namelist namelist_cfg jpnj 4
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_top_cfg ln_trcdta .false.
     set_namelist namelist_top_cfg ln_diatrc .false.
@@ -436,5 +430,4 @@
     set_namelist namelist_cfg jpnj 8
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_top_cfg ln_trcdta .false.
     set_namelist namelist_top_cfg ln_diatrc .false.
@@ -473,5 +466,5 @@
     . ./prepare_exe_dir.sh
     JOB_FILE=${EXE_DIR}/run_job.sh
-    NPROC=4
+    NPROC=8
     if [ -f ${JOB_FILE} ] ; then \rm ${JOB_FILE} ; fi
     cd ${EXE_DIR}
@@ -482,6 +475,6 @@
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg jpni 2
-    set_namelist namelist_cfg jpnj 2
-    set_namelist namelist_cfg jpnij 4
+    set_namelist namelist_cfg jpnj 4
+    set_namelist namelist_cfg jpnij 8
     set_namelist namelist_top_cfg ln_trcdta .false.
     set_namelist namelist_top_cfg ln_diatrc .false.
@@ -516,6 +509,6 @@
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg jpni 2
-    set_namelist namelist_cfg jpnj 2
-    set_namelist namelist_cfg jpnij 4
+    set_namelist namelist_cfg jpnj 4
+    set_namelist namelist_cfg jpnij 8
     set_namelist namelist_top_cfg ln_diatrc .false.
     set_namelist namelist_top_cfg ln_rsttr .true.
@@ -657,5 +650,4 @@
     set_namelist namelist_cfg jpnj 2
     set_namelist namelist_cfg jpnij 4
-    set_namelist namelist_cfg nn_solv 2
     if [ ${USING_MPMD} == "yes" ] ; then
        set_xio_using_server iodef.xml true
@@ -681,5 +673,4 @@
     set_namelist namelist_cfg jpnj 2
     set_namelist namelist_cfg jpnij 4
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg cn_ocerst_in \"O2L3_LONG_00000075_restart\"
     set_namelist namelist_ice_cfg cn_icerst_in \"O2L3_LONG_00000075_restart_ice\"
@@ -722,5 +713,4 @@
     set_namelist namelist_cfg jpnj 4
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
     if [ ${USING_MPMD} == "yes" ] ; then
        set_xio_using_server iodef.xml true
@@ -747,5 +737,4 @@
     set_namelist namelist_cfg jpnj 8
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
     if [ ${USING_MPMD} == "yes" ] ; then
        set_xio_using_server iodef.xml true
@@ -1018,5 +1007,4 @@
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg nn_fwb 0
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 2
     set_namelist namelist_cfg jpnj 2
@@ -1042,5 +1030,4 @@
     set_namelist namelist_cfg ln_clobber .true.
     set_namelist namelist_cfg nn_fwb 0
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 2
     set_namelist namelist_cfg jpnj 2
@@ -1087,5 +1074,4 @@
     set_namelist namelist_cfg ln_ctl .false.
     set_namelist namelist_cfg ln_clobber .true.
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 1
     set_namelist namelist_cfg jpnj 4
@@ -1114,5 +1100,4 @@
     set_namelist namelist_cfg ln_ctl .false.
     set_namelist namelist_cfg ln_clobber .true.
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg jpni 2
     set_namelist namelist_cfg jpnj 2
@@ -1153,5 +1138,4 @@
     set_namelist namelist_cfg jpnj 4
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2   
     set_namelist namelist_cfg ln_t3d .true.
     set_namelist namelist_cfg ln_s3d .true.
@@ -1192,5 +1176,4 @@
     set_namelist namelist_cfg jpnj 8
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
     set_namelist namelist_cfg ln_t3d .true.
     set_namelist namelist_cfg ln_s3d .true.
@@ -1346,5 +1329,4 @@
     set_namelist namelist_cfg jpnj 2
     set_namelist namelist_cfg jpnij 4
-    set_namelist namelist_cfg nn_solv 2
 #
     set_namelist 1_namelist_cfg cn_exp \"O2LP_LONG\"
@@ -1379,5 +1361,4 @@
 
     set_namelist namelist_cfg jpnij 4
-    set_namelist namelist_cfg nn_solv 2
     set_namelist 1_namelist_cfg cn_exp \"O2LP_SHORT\"
     set_namelist 1_namelist_cfg nn_it000 151
@@ -1431,5 +1412,4 @@
     set_namelist namelist_cfg jpnj 4
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
 #
     set_namelist 1_namelist_cfg nn_it000 1
@@ -1463,5 +1443,4 @@
     set_namelist namelist_cfg jpnj 8
     set_namelist namelist_cfg jpnij 16
-    set_namelist namelist_cfg nn_solv 2
 #
     set_namelist 1_namelist_cfg nn_it000 1
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/sette_rpt
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/sette_rpt	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/SETTE/sette_rpt	(revision 6041)
@@ -393,4 +393,31 @@
 
 
+  if ( -d ./WORCA2_LIM_OBS ) then
+    set dorv = `ls -1rtd ./WORCA2_LIM_OBS/{$mach}/* | tail -1l `
+    set dorv = $dorv:t
+    set f1o = ./WORCA2_LIM_OBS/{$mach}/{$dorv}/REPRO_2_8/ocean.output
+    set f1s = ./WORCA2_LIM_OBS/{$mach}/{$dorv}/REPRO_2_8/solver.stat
+    set f2o = ./WORCA2_LIM_OBS/{$mach}/{$dorv}/REPRO_4_4/ocean.output
+    set f2s = ./WORCA2_LIM_OBS/{$mach}/{$dorv}/REPRO_4_4/solver.stat
+
+    cmp -s $f1s $f2s
+    if ( $status == 0 ) then
+      echo "ORCA2_LIM_OBS   reproducibility passed"
+    else
+      echo "ORCA2_LIM_OBS   reproducibility FAILED"
+      if ( $pass == 1 ) then
+        echo "<return> to view solver.stat differences"
+        set y = $<
+        sdiff $f1s $f2s
+        echo "<return> to view ocean.output differences"
+        set y = $<
+        sdiff $f1o $f2o | grep "|"
+        echo "<return> to continue"
+        set y = $<
+      endif
+    endif
+  endif
+
+
   if ( -d ./WSAS_32 ) then
     set dorv = `ls -1rtd ./WSAS_32/{$mach}/* | tail -1l `
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/batch/X64_ADA.sh
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/batch/X64_ADA.sh	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/batch/X64_ADA.sh	(revision 6041)
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# Nom de la requete
+# @ job_name = NEMO_CI
+# Type de travail
+# @ job_type = parallel
+# Fichier de sortie standard
+# @ output = $(job_name)_$(jobid)
+# Fichier de sortie erreur
+# @ error  = $(job_name)_$(jobid)
+# Nombre de processus demande
+# @ total_tasks = 32
+# Temps CPU max. par processus MPI hh:mm:ss
+# @ wall_clock_limit = 0:30:00
+# Fin de l entete
+# @ queue
+
+cd $LOADL_STEP_INITDIR
+
+# running the job in parallel mode
+poe ./opa
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/batch/X64_CURIE.sh
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/batch/X64_CURIE.sh	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/batch/X64_CURIE.sh	(revision 6041)
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+#Config ccc_msub
+#MSUB -A  gen7451
+#MSUB -r  NEMO_CI
+#MSUB -o  NEMO_CI_%I
+#MSUB -e  NEMO_CI_%I
+#MSUB -oe
+#MSUB -q  xlarge
+#MSUB -n  128
+#MSUB -N  1
+#MSUB -T  1800
+##MSUB -@  ntmlod@locean-ipsl.upmc.fr:begin,end
+ccc_mprun ./opa
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/X64_ADA.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/X64_ADA.cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/X64_ADA.cfg	(revision 6041)
@@ -0,0 +1,34 @@
+## Ada configuration
+##---------------------------------------------------
+
+
+## Default settings
+##---------------------------------------------------
+TRUS_ENVI=${TRUS_XIOS}/arch/arch-${TRUS_HPCC}
+
+TRUS_CDOD='cdo diffn'
+
+[ -z "${TRUS_NPRO}" ] && TRUS_NPRO='16'
+[ -z "${TRUS_TOUT}" ] && TRUS_TOUT='10800'
+
+
+## (Super)computer environment
+##---------------------------------------------------
+TRUS_JSPT=${TRUS_HPCC}.sh
+TRUS_JSUB="llsubmit ${TRUS_JSPT} | grep -oe '\<[0-9]*\>'"
+TRUS_JINF="llq -x \${TRUS_JIDN}"
+TRUS_JSTA="llq      | grep \${TRUS_JIDN}"
+TRUS_JKIL="llcancel        \${TRUS_JIDN}"
+
+TRUS_JTIM="grep IdrisMemMPI NEMO_CI_\${TRUS_JIDN} | cut -d, -f1 | awk '{print \$(NF-1),\$NF}'"
+TRUS_JPME="grep IdrisMemMPI NEMO_CI_\${TRUS_JIDN} | cut -d, -f3 | awk '{print \$3     ,\$4 }'"
+TRUS_JVME="grep IdrisMemMPI NEMO_CI_\${TRUS_JIDN} | cut -d, -f2 | awk '{print \$3     ,\$4 }'"
+
+TRUS_CMPV='ifort'
+TRUS_CDOR='cdo/'
+TRUS_MPIR='intel/impi/'
+TRUS_CDFR='netcdf/'
+
+PATH='/smplocal/pub/cdo/1.5.9/bin':$PATH
+## Not working with module delimiter ':'
+#WRAPPER_LDFLAGS='-L/smplocal/pub/IdrMemMPI/1.4/lib -lidrmem '${WRAPPER_LDFLAGS}
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/X64_CURIE.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/X64_CURIE.cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/X64_CURIE.cfg	(revision 6041)
@@ -0,0 +1,32 @@
+## Curie configuration
+##---------------------------------------------------
+
+
+## Default settings
+##---------------------------------------------------
+TRUS_ENVI=${TRUS_XIOS}/arch/arch-${TRUS_HPCC}
+
+TRUS_CDOD='cdo diffn'
+
+[ -z "${TRUS_NPRO}" ] && TRUS_NPRO='16'
+[ -z "${TRUS_TOUT}" ] && TRUS_TOUT='10800'
+
+
+## (Super)computer environment
+##---------------------------------------------------
+TRUS_JSPT=${TRUS_HPCC}.sh
+TRUS_JSUB="ccc_msub ${TRUS_JSPT} | grep -oe '\<[0-9]*\>'"
+TRUS_JINF="ccc_macct \${TRUS_JIDN}"
+TRUS_JSTA="ccc_mpp  | grep \${TRUS_JIDN}"
+TRUS_JKIL="ccc_mdel        \${TRUS_JIDN}"
+
+TRUS_JTIM="ccc_macct \${TRUS_JIDN} | grep     \"\${TRUS_JIDN}.0 *opa\" | awk '{print               \$9      }'"
+TRUS_JPME="ccc_macct \${TRUS_JIDN} | grep -m1 \"\${TRUS_JIDN}.0\"      | awk '{printf \"%d Mo\n\", \$2; exit}'"
+TRUS_JVME="ccc_macct \${TRUS_JIDN} | grep -m1 \"\${TRUS_JIDN}.0\"      | awk '{printf \"%d Go\n\", \$7; exit}'"
+
+TRUS_CMPV='ifort'
+TRUS_CDOR='netcdf-utils-'
+TRUS_MPIR='bullxmpi/'
+TRUS_CDFR='netcdf-'
+
+PATH='/usr/local/netcdf-utils-4.3.3.1_hdf5/bin':$PATH
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/arch_template.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/arch_template.cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/arch_template.cfg	(revision 6041)
@@ -0,0 +1,50 @@
+## (Super)Computer configuration template
+##---------------------------------------------------
+
+## Copy to root, rename it and then fill in according to your (super)computer environment
+## Rules for completion: undefined variables (=) are mandatory & void variables (='') are optional
+## Look into other configuration file for examples
+
+
+## Default settings
+##---------------------------------------------------
+# (Super)Computer environment (${TRUS_XIOS} is already defined in the user configuration file)
+TRUS_ENVI=${TRUS_XIOS}/arch/arch-${TRUS_HPCC}
+## If `module` is available, ${TRUS_ENVI}.env will be sourced
+## If not (scheduled jobs), it will be ${TRUS_ENVI}.path or finally ${TRUS_ENVI}
+
+## Comparison command with restart files as argument (think to append $PATH by any way)
+TRUS_CDOD='cdo diffn'
+
+[ -z "${TRUS_NPRO}" ] && TRUS_NPRO=     ## Number of compiling processes
+[ -z "${TRUS_TOUT}" ] && TRUS_TOUT=     ## Timeout for computation (s)
+
+
+## (Super)computer environment
+##---------------------------------------------------
+## Job commands will almost always be used with `eval ${TRUS_JXXX}` because
+## they will certainly need job ID number as argument for working
+TRUS_JSPT=       ## Submission script contained ./batch folder, will be copied to testing folder
+TRUS_JSUB=	 ## Submit a job and get his ID on the fly (assigned to ${TRUS_JIDN})
+        	   ## ex: `llsubmit ${TRUS_JSPT} | grep -oe '\<[0-9]*\>'`
+TRUS_JSTA=   	 ## Test state of the submitted job (true -> pending/running or false -> completed/crashed)
+                   ## ex: "llq | grep \${TRUS_JIDN}"
+TRUS_JKIL=   	 ## Kill the submitted job
+                   ## ex: "llcancel   \${TRUS_JIDN}"
+
+## Computational performances of job (respectively elapsed time, max physical & virtual memory)
+TRUS_JTIM=''       ## ex: "grep IdrisMemMPI NEMO_CI_\${TRUS_JIDN} | cut -d, -f1 | awk '{print \$(NF-1),\$NF}"
+TRUS_JPME=''       ## ex: "grep IdrisMemMPI NEMO_CI_\${TRUS_JIDN} | cut -d, -f3 | awk '{print \$3     ,\$4 }"
+TRUS_JVME=''       ## ex: "grep IdrisMemMPI NEMO_CI_\${TRUS_JIDN} | cut -d, -f2 | awk '{print \$3     ,\$4 }"
+
+TRUS_JINF=''   	 ## Get job informations to fill in a logfile during computation
+                   ## ex: "llq -x \${TRUS_JIDN}"
+
+## Compiler (use with `${TRUS_CMPV} --version`)
+TRUS_CMPV=''       ## ex: 'ifort'|'gfortran'|'pgfortran'|...
+
+## Software/libraries (string pattern to match just before the release number in $PATH)
+## Respectively CDO (Climate Data Operators) / MPI libraries / NetCDF libraries
+TRUS_CDOR=''       ## ex: 'cdo/'|'netcdf-utils-'
+TRUS_MPIR=''       ## ex: 'intel/impi/'|'bullxmpi/'
+TRUS_CDFR=''       ## ex: 'netcdf/'|'netcdf-'
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/martin.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/martin.cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/martin.cfg	(revision 6041)
@@ -0,0 +1,35 @@
+## Installation for trusting tests on Curie Supercomputer
+##---------------------------------------------------
+
+
+## Default settings
+##---------------------------------------------------
+[ -z "${TRUS_BRAN}" ] && TRUS_BRAN='trunk'
+TRUS_CKOT=( 'ARCH           CONFIG          NEMO               \
+             EXTERNAL/AGRIF EXTERNAL/fcm    EXTERNAL/IOIPSL    \
+             TOOLS/COMPILE  TOOLS/maketools TOOLS/REBUILD_NEMO  ' )
+
+[ -z "${TRUS_REFE}" ] && TRUS_REFE='ORCA2_LIM_PISCES'
+TRUS_CONF=${TRUS_REFE}'_trust'
+
+[ -z "${TRUS_TARF}" ] && TRUS_TARF='ORCA2_LIM_nemo_v3.6.tar'
+[ ${TRUS_REFE} == 'ORCA1_LIM3_PISCES' ] && TRUS_TARF='INPUTS_ORCA1_LIM3_PISCES_V6.tar'
+[ ${TRUS_REFE} == 'AMM12'             ] && TRUS_TARF='AMM12_v3.6.tar'
+
+TRUS_KEYA=''; TRUS_KEYD=''
+[ ${TRUS_REFE} == 'ORCA2_LIM' ] && TRUS_KEYA='key_add key_agrif' && TRUS_KEYD='key_del key_zdftmx'
+
+
+## User environment
+##---------------------------------------------------
+TRUS_WORK=$CCCWORKDIR/NEMO
+TRUS_SCRA=$SCRATCHDIR/NEMO/trusting/${TRUS_REFE}/${TRUS_BRAN}/${DATE}
+TRUS_STOR=$CCCSTOREDIR/NEMO/trusting_sav/${TRUS_REFE}/${TRUS_BRAN}
+TRUS_FORC=$CCCWORKDIR/NEMO/FORC
+TRUS_XIOS=$CCCWORKDIR/XIOS/xios-1.0
+
+[ ${TRUS_REFE} == 'ORCA2_LIM_PISCES'  ] && TRUS_CONF='O2LP_trust'
+[ ${TRUS_REFE} == 'ORCA1_LIM3_PISCES' ] && TRUS_CONF='O1L3P_trust'
+[ ${TRUS_REFE} == 'ORCA2_LIM'         ] && TRUS_CONF='O2LA_trust'
+
+[ -z "${TRUS_MAIL}" ] && TRUS_MAIL='ntmlod@locean-ipsl.upmc.fr'
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/romr005.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/romr005.cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/romr005.cfg	(revision 6041)
@@ -0,0 +1,35 @@
+## Installation for trusting tests on Ada Supercomputer
+##---------------------------------------------------
+
+
+## Default settings
+##---------------------------------------------------
+[ -z "${TRUS_BRAN}" ] && TRUS_BRAN='trunk'
+TRUS_CKOT=( 'ARCH           CONFIG          NEMO               \
+             EXTERNAL/AGRIF EXTERNAL/fcm    EXTERNAL/IOIPSL    \
+             TOOLS/COMPILE  TOOLS/maketools TOOLS/REBUILD_NEMO  ' )
+
+[ -z "${TRUS_REFE}" ] && TRUS_REFE='ORCA2_LIM_PISCES'
+TRUS_CONF=${TRUS_REFE}'_trust'
+
+[ -z "${TRUS_TARF}" ] && TRUS_TARF='ORCA2_LIM_nemo_v3.6.tar'
+[ ${TRUS_REFE} == 'ORCA1_LIM3_PISCES' ] && TRUS_TARF='INPUTS_ORCA1_LIM3_PISCES_V6.tar'
+[ ${TRUS_REFE} == 'AMM12'             ] && TRUS_TARF='AMM12_v3.6.tar'
+
+TRUS_KEYA=''; TRUS_KEYD=''
+[ ${TRUS_REFE} == 'ORCA2_LIM' ] && TRUS_KEYA='key_add key_agrif' && TRUS_KEYD='key_del key_zdftmx'
+
+
+## User environment
+##---------------------------------------------------
+TRUS_WORK=$WORKDIR/NEMO
+TRUS_SCRA=$WORKDIR/NEMO/trusting/${TRUS_REFE}/${TRUS_BRAN}/${DATE}
+TRUS_STOR=$WORKDIR/NEMO/trusting_sav/${TRUS_REFE}/${TRUS_BRAN}
+TRUS_FORC=$WORKDIR/NEMO/FORC
+TRUS_XIOS=$WORKDIR/XIOS/xios-1.0
+
+[ ${TRUS_REFE} == 'ORCA2_LIM_PISCES'  ] && TRUS_CONF='O2LP_trust'
+[ ${TRUS_REFE} == 'ORCA1_LIM3_PISCES' ] && TRUS_CONF='O1L3P_trust'
+[ ${TRUS_REFE} == 'ORCA2_LIM'         ] && TRUS_CONF='O2LA_trust'
+
+[ -z "${TRUS_MAIL}" ] && TRUS_MAIL='ntmlod@locean-ipsl.upmc.fr'
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/user_template.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/user_template.cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/config/user_template.cfg	(revision 6041)
@@ -0,0 +1,49 @@
+## User configuration template
+##---------------------------------------------------
+
+## Copy to root, rename it and then fill in according to your user environment
+## Rules for completion: undefined variables (=) are mandatory & void variables (='') are optional
+## Look into other configuration file for examples
+
+
+## Default settings
+##---------------------------------------------------
+## These settings can be changed directly from command line to reduce number of user configuration file
+## See `./trusting.sh [-h|--help]`
+
+## SVN branch name ('trunk', 'nemo_v3_6_STABLE', development branches)
+[ -z "${TRUS_BRAN}" ] && TRUS_BRAN='trunk'
+
+## Minimal content for code checkout/update
+TRUS_CKOT=( 'ARCH           CONFIG          NEMO               \
+             EXTERNAL/AGRIF EXTERNAL/fcm    EXTERNAL/IOIPSL    \
+             TOOLS/COMPILE  TOOLS/maketools TOOLS/REBUILD_NEMO  ' )
+
+[ -z "${TRUS_REFE}" ] && TRUS_REFE='ORCA2_LIM_PISCES'     ## Reference configuration to test
+TRUS_CONF=${TRUS_REFE}'_trust'                            ## Testing configuration name
+
+## Forcing archive, let void if just need to copy the files inside ${TRUS_FORC}
+[ -z "${TRUS_TARF}" ] && TRUS_TARF='ORCA2_LIM_nemo_v3.6.tar'
+[ ${TRUS_REFE} == 'ORCA1_LIM3_PISCES' ] && TRUS_TARF='INPUTS_ORCA1_LIM3_PISCES_V6.tar'
+[ ${TRUS_REFE} == 'AMM12'             ] && TRUS_TARF='AMM12_v3.6.tar'
+
+## CPP keys to add or remove from reference configuration
+TRUS_KEYA=''; TRUS_KEYD=''
+[ ${TRUS_REFE} == 'ORCA2_LIM' ] && TRUS_KEYA='key_add key_agrif' && TRUS_KEYD='key_del key_zdftmx'
+
+
+## User environment
+##---------------------------------------------------
+TRUS_WORK=     ## Testing folder for compilation (branches checkouts & configuration compilation)
+TRUS_SCRA=     ##   " "     ""   " " computation
+                 ## ...../${TRUS_REFE}/${TRUS_BRAN}/${DATE} recommended
+TRUS_STOR=     ## Benchmark folder where target files for comparison have been stored, ie:
+               ## Inputs  (all) : CPP_*, namelist_*, *.xml et inputs_list.txt (created by initial test)
+               ## Outputs (any) : *.stat, ocean.output, restarts
+                 ## ...../${TRUS_REFE}/${TRUS_BRAN} recommended (same layout as ${TRUS_SCRA})
+TRUS_FORC=     ## Path to the forcing archive to extract (usage combined with ${TRUS_TARF}) or
+               ##    ""   all inputs files who will be copied into ${TRUS_SCRA}
+TRUS_XIOS=     ## XIOS installation
+
+## Mailing list to notify on failure (-p|--prod option required)
+[ -z "${TRUS_MAIL}" ] && TRUS_MAIL=''
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/cron/ada.env
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/cron/ada.env	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/cron/ada.env	(revision 6041)
@@ -0,0 +1,53 @@
+## Set Ada environment for trusting scheduled job
+
+## Equivalent of source arch-X64_ADA.env with module commands
+PATH='/smplocal/intel/composer_xe_2013.1.117/bin/intel64:/smplocal/intel/composer_xe_2013.1.117/bin/intel64_mic:/smplocal/intel/composer_xe_2013.1.117/debugger/gui/intel64:/smplocal/intel/composer_xe_2013.1.117/bin/intel64:/smplocal/intel/composer_xe_2013.1.117/mpirt/bin/intel64:/smplocal/intel/impi/4.1.0.024/intel64/bin:/smplocal/pub/Modules/IDRIS/wrappers:/smplocal/pub/NetCDF/4.1.3/mpi/bin':$PATH
+LD_LIBRARY_PATH='/smplocal/intel/composer_xe_2013.1.117/compiler/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/mkl/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/compiler/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/mpirt/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/ipp/../compiler/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/ipp/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/tbb/lib/intel64:/smplocal/intel/impi/4.1.0.024/intel64/lib':${LD_LIBRARY_PATH}
+INCLUDE='/smplocal/intel/composer_xe_2013.1.117/mkl/include':$INCLUDE
+
+## Wrapper flags
+WRAPPER_CXXFLAGS='-I/smplocal/pub/NetCDF/4.1.3/mpi/include'
+WRAPPER_FFLAGS='-I/smplocal/pub/NetCDF/4.1.3/mpi/include'
+WRAPPER_LDFLAGS='-L/smplocal/pub/NetCDF/4.1.3/mpi/lib -Bstatic -lnetcdff -lnetcdf -lnetcdf_c++ -Bdynamic -L/smplocal/pub/HDF5/1.8.9/par/lib -Bstatic -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -Bdynamic -lz'
+
+## IDRIS files systems (no need with `at`)
+#WORKDIR=/workgpfs/rech/omr/$USER
+#COMMONDIR=/workgpfs/rech/omr/commun
+#TMPDIR=
+
+## Intel license
+INTEL_LICENSE_FILE='/smplocal/intel/composer_xe_2013.1.117/licenses:/smplocal/intel/licenses:/linkhome/rech/omr/romr005/intel/licenses'
+
+## Trusting
+TRUS_HPCC='X64_ADA'
+
+## Export to environment
+export PATH LD_LIBRARY_PATH INCLUDE
+export WRAPPER_CXXFLAGS WRAPPER_FFLAGS WRAPPER_LDFLAGS
+#export WORKDIR COMMONDIR TMPDIR
+export INTEL_LICENSE_FILE
+export TRUS_HPCC
+
+
+#-------------------------------------------------------------------
+#/smplocal/pub/Modules/IDRIS/modulefiles/environnement/intel/2013.0:
+#prepend-path	 PATH               /smplocal/intel/composer_xe_2013.1.117/bin/intel64:/smplocal/intel/composer_xe_2013.1.117/bin/intel64_mic:/smplocal/intel/composer_xe_2013.1.117/debugger/gui/intel64 
+#prepend-path	 PATH               /smplocal/intel/composer_xe_2013.1.117/bin/intel64:/smplocal/intel/composer_xe_2013.1.117/mpirt/bin/intel64 
+#prepend-path	 PATH               /smplocal/intel/impi/4.1.0.024/intel64/bin 
+#prepend-path	 PATH               /smplocal/pub/Modules/IDRIS/wrappers 
+#prepend-path	 LD_LIBRARY_PATH    /smplocal/intel/composer_xe_2013.1.117/tbb/lib/intel64 
+#prepend-path	 LD_LIBRARY_PATH    /smplocal/intel/composer_xe_2013.1.117/compiler/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/mkl/lib/intel64 
+#prepend-path	 LD_LIBRARY_PATH    /smplocal/intel/composer_xe_2013.1.117/ipp/../compiler/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/ipp/lib/intel64 
+#prepend-path	 LD_LIBRARY_PATH    /smplocal/intel/composer_xe_2013.1.117/compiler/lib/intel64:/smplocal/intel/composer_xe_2013.1.117/mpirt/lib/intel64 
+#prepend-path	 LD_LIBRARY_PATH    /smplocal/intel/impi/4.1.0.024/intel64/lib 
+#prepend-path	 INCLUDE            /smplocal/intel/composer_xe_2013.1.117/mkl/include 
+#append-path	 INTEL_LICENSE_FILE /smplocal/intel/composer_xe_2013.1.117/licenses:/smplocal/intel/licenses:/linkhome/rech/omr/romr005/intel/licenses 
+#-------------------------------------------------------------------
+#-------------------------------------------------------------------
+#/smplocal/pub/Modules/IDRIS/modulefiles/bibliotheques/netcdf/mpi/4.1.3:
+#prepend-path	 PATH               /smplocal/pub/NetCDF/4.1.3/mpi/bin 
+#prepend-path	 PATH               /smplocal/pub/Modules/IDRIS/wrappers 
+#prepend-path	 WRAPPER_FFLAGS     -I/smplocal/pub/NetCDF/4.1.3/mpi/include 
+#prepend-path	 WRAPPER_CXXFLAGS   -I/smplocal/pub/NetCDF/4.1.3/mpi/include 
+#prepend-path	 WRAPPER_LDFLAGS    -L/smplocal/pub/NetCDF/4.1.3/mpi/lib -Bstatic -lnetcdff -lnetcdf -lnetcdf_c++ -Bdynamic -L/smplocal/pub/HDF5/1.8.9/par/lib -Bstatic -lhdf5hl_fortran -lhdf5_hl -lhdf5_fortran -lhdf5 -Bdynamic -lz
+#-------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/cron/curie.env
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/cron/curie.env	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/cron/curie.env	(revision 6041)
@@ -0,0 +1,74 @@
+## Set Curie environment for trusting scheduled job
+
+## Equivalent of source arch-X64_CURIE.env with module commands
+PATH='/usr/local/ccc_users_env/bin:/opt/intel/14.0.3.174/bin/intel64:/opt/mpi/bullxmpi/1.2.8.2/bin:/usr/local/netcdf-4.3.3.1_hdf5_parallel/bin:/ccc/cont003/home/dsm/p86ipsl/bin':$PATH
+LD_LIBRARY_PATH='/lib64:/lib:/usr/lib64:/usr/lib:/opt/intel/14.0.3.174/compiler/lib/intel64:/usr/local/intel-14.0.3.174/14.0.3.174/mkl/lib/intel64:/opt/intel/14.0.3.174/debugger/lib/intel64:/opt/mpi/bullxmpi/1.2.8.2/lib:/usr/local/netcdf-4.3.3.1_hdf5_parallel/lib':${LD_LIBRARY_PATH}
+
+## NetCDF installation
+NETCDF_INCDIR='/usr/local/netcdf-4.3.3.1_hdf5_parallel/include'
+NETCDF_LDFLAGS='-L/usr/local/netcdf-4.3.3.1_hdf5_parallel/lib -lnetcdf'
+NETCDF_LIBDIR='/usr/local/netcdf-4.3.3.1_hdf5_parallel/lib'
+
+## TGCC files systems
+CCCWORKDIR=/ccc/work/cont003/gen7451/$USER
+SCRATCHDIR=/ccc/scratch/cont003/gen7451/$USER
+CCCSTOREDIR=/ccc/store/cont003/gen7451/$USER
+
+## Intel license
+LM_LICENSE_FILE='27000@licintel.ccc.cea.fr'
+
+## Trusting
+TRUS_HPCC='X64_CURIE'
+
+## Export to environment
+export PATH LD_LIBRARY_PATH
+export NETCDF_INCDIR NETCDF_LDFLAGS NETCDF_LIBDIR
+export CCCWORKDIR SCRATCHDIR CCCSTOREDIR
+export LM_LICENSE_FILE
+export TRUS_HPCC
+
+#-------------------------------------------------------------------
+#/opt/Modules/default/modulefiles/environment/ccc:
+#append-path	PATH    	/usr/local/ccc_users_env/bin
+#prepend-path	LD_LIBRARY_PATH	/lib64:/lib:/usr/lib64:/usr/lib
+#-------------------------------------------------------------------
+#-------------------------------------------------------------------
+#/opt/Modules/default/modulefiles/environment/dfldatadir/own:
+#setenv		CCCSTOREDIR	/ccc/store/cont003/gen7451/martin
+#setenv		CCCWORKDIR	/ccc/work/cont003/gen7451/martin
+#setenv		SCRATCHDIR	/ccc/scratch/cont003/gen7451/martin
+#-------------------------------------------------------------------
+#-------------------------------------------------------------------
+#/opt/Modules/default/modulefiles/environment/licsrv/intel:
+#append-path	LM_LICENSE_FILE	27000@licintel.ccc.cea.fr
+#-------------------------------------------------------------------
+#-------------------------------------------------------------------
+#/opt/Modules/default/modulefiles/compilers/intel/14.0.3.174:
+#module load	c/intel/14.0.3.174
+#prepend-path	PATH    	/opt/intel/14.0.3.174/bin/intel64
+#prepend-path	LD_LIBRARY_PATH	/opt/intel/14.0.3.174/compiler/lib/intel64
+#module load	c++/intel/14.0.3.174
+#prepend-path	PATH    	/opt/intel/14.0.3.174/bin/intel64
+#prepend-path	LD_LIBRARY_PATH	/opt/intel/14.0.3.174/compiler/lib/intel64
+#module load	fortran/intel/14.0.3.174
+#append-path	PATH    	/opt/intel/14.0.3.174/bin/intel64
+#prepend-path	LD_LIBRARY_PATH	/opt/intel/14.0.3.174/compiler/lib/intel64
+#module load	mkl/14.0.3.174
+#append-path	LD_LIBRARY_PATH	/usr/local/intel-14.0.3.174/14.0.3.174/mkl/lib/intel64
+#module load	idb/14.0.3.174
+#prepend-path	PATH    	/opt/intel/14.0.3.174/bin/intel64
+#append-path	LD_LIBRARY_PATH	/opt/intel/14.0.3.174/debugger/lib/intel64
+#-------------------------------------------------------------------
+#-------------------------------------------------------------------
+#/opt/Modules/default/modulefiles/parallel/bullxmpi/1.2.8.2:
+#prepend-path	PATH    	/opt/mpi/bullxmpi/1.2.8.2/bin
+#prepend-path	LD_LIBRARY_PATH	/opt/mpi/bullxmpi/1.2.8.2/lib
+#-------------------------------------------------------------------
+#-------------------------------------------------------------------
+#/opt/Modules/default/modulefiles/libraries/netcdf/4.3.3.1_hdf5_parallel:
+#prepend-path	PATH    	/usr/local/netcdf-4.3.3.1_hdf5_parallel/bin
+#prepend-path	LD_LIBRARY_PATH	/usr/local/netcdf-4.3.3.1_hdf5_parallel/lib
+#setenv		NETCDF_INCDIR	/usr/local/netcdf-4.3.3.1_hdf5_parallel/include
+#setenv		NETCDF_LIBDIR	/usr/local/netcdf-4.3.3.1_hdf5_parallel/lib
+#setenv		NETCDF_LDFLAGS	-L/usr/local/netcdf-4.3.3.1_hdf5_parallel/lib -lnetcdf
+#-------------------------------------------------------------------
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/banner.html
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/banner.html	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/banner.html	(revision 6041)
@@ -0,0 +1,33 @@
+<pre style="font: 2px/1px monospace;">
+@@@@@@O$$$$$$@@@@@@#$$$$$$&@#$$$$$$$$$$$$$$$&@O$$$$$$&@@@@@@@@@$$$$$$O@@@@@@@@@@@O$$%$O@@@@@@@@@@@@@
+@@@@@@?!!!!!!#@@@@@O!!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!?&@@@@@@@$!!!!!!?@@@@@@@@&O#&&&&%??$#@@@@@@@@@@
+@@@@@@?!!!!!!?@@@@@O!!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!!%@@@@@@O!!!!!!!?@@@@@@@O#@@&%??!!!!!$@@@@@@@@@
+@@@@@@?!!!!!!!O@@@@O!!!!!!#@$!!!!!!?????????&@%!!!!!!!!$@@@@#!!!!!!!!?@@@@@&O&@&&O$$?!!!!!!%&@@@@@@@
+@@@@@@?!!!!!!!!#@@@O!!!!!!#@$!!!!!!#&&&&&&&&@@%!!!!!!!!!$@@&?!!!!!!!!?@@@@@O&@&??&@@&O!!!!!!%@@@@@@@
+@@@@@@?!!!!!!!!?&@@O!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!!!!!O@%!!!!!!!!!?@@@@O&@@O!O@@@@&O!!!!!!$@@@@@@
+@@@@@@?!!!!!!!!!?#@O!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!!!!!!%!!!!!!!!!!?@@@&O@@$!!O&@@@@&O!!!!!!#@@@@@
+@@@@@@?!!!!!!!!!!!OO!!!!!!#@$!!!!!!$OOOOO@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@@O@&%!!!!!%#&&@&?!!!!!%@@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!!!!!!?@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@@O&!!!!!!%%eO&@$!!!!!!%&@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!!!!!!?@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@&&$!!!?$O$Oe$@@!!!!!!eO#@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!?%%%%$@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@O&!!!!$&$#%!#@@?!!!!!!$O@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@O&!!!!%?O@%&&&@$!!!!!!?O@@@@
+@@@@@@?!!!!!?#!!!!!!!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!#!!!!!!!!O?!!!!!?@@O#!!!!!!?@@@@@OO!!!!$e?O@@@@
+@@@@@@?!!!!!?@#?!!!!!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!&#!!!!!!%&?!!!!!?@@OOO?!!!%%@@@@@#?!%$#O%%$@@@@
+@@@@@@?!!!!!?@@&%!!!!!!!!!#@$!!!!!!?????????&@%!!!!!!&@O!!!!?&@?!!!!!?@@#&##%$&&&@@@@@@$%#&O!??O@@@@
+@@@@@@?!!!!!?@@@@#?!!!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!&@@$!!!&@@?!!!!!?@@&#$&@@@@@@@@@@@?O%%?!!!#@@@@
+@@@@@@?!!!!!?@@@@@@#%!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!&@@@$!O@@@?!!!!!?@@@O#&&@@@@@@@@@@O?!!!!!?&@@@@
+@@@@@@?!!!!!?@@@@@@@@&O$%%#@#O##&&&&&&&&##OO&@$!!!!!!&@@@@O@@@@?!!!!!?@@@O&&#&@@@@@@@@@$!!!!!!$@@@@@
+@@@@@@?!!!!!?@@@@@@@@@@@@@@&&#O$$$%%%%$$$OO#&@@&#O%?!&@@@@@@@@@?!!!!!?@@@@OOO@@@@@@@@@&!!!!!!!&@@@@@
+@@@@@@?!!!!!?@@@@@@@@@&#$%?!!!!!!!!!!!!!!!!!!!?%O#@@#@@@@@@@@@@?!!!!!?@@@@#!!%&@@@@@@@%!!!!!!O@@@@@@
+@@@@@@?!!!!!?@@@@@@#$?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%$&@@@@@@@@@?!!!!!?@@@@@#!!%@@@@@@@O!!$&$$@@@@@@@
+@@@@@@?!!!!!?@@@O%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!?$#@@@@@@?!!!!!?@@@@@@O!!?@@@@@@@&&@#O@@@@@@&&
+@@@@@@?!!!?O&#$?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!?$#@@@$?!!!!?@@@@@@@&%!?$#@@@@@&O#@@@@@#O&@
+@@@@@@?!?O&#%!!!!!!!!!??%%$$$OOOOOOOOOO$$%%??!!!!!!!!!!!!!!!?%O&&&O$%%@@@@@@@@@#%?%####O#@@@&#$$#@@@
+@@@@@@%O&#%!!!!!?%$O#&&@@@@@@@@@@@@@@@@@@@@@&&#O$%?!!!!!!!!!!!!!?$O&&&@@@@@@@@@@@&&&&&&&&#$%?%#@@@@@
+@@@@@@&#%!!!?$#&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&#O%?!!!!!!!!!!!!??%$OOO#######OO$%??!!?%#@@@@@@@
+@@@@@&$!?%O&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#O$%?!!!!!!!!!!!!!!!!!!!!!!!!!?$#&@@@@@@@@@
+@@@@O?%O&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#OO$%????!!!!!!!!??%%O#&@@@@@@@@@@@@@
+@@&$$&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&@@@@@@@@@@@@@@@@@@@@
+@#O&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+</pre>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/banner.txt
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/banner.txt	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/banner.txt	(revision 6041)
@@ -0,0 +1,31 @@
+@@@@@@O$$$$$$@@@@@@#$$$$$$&@#$$$$$$$$$$$$$$$&@O$$$$$$&@@@@@@@@@$$$$$$O@@@@@@@@@@@O$$%$O@@@@@@@@@@@@@
+@@@@@@?!!!!!!#@@@@@O!!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!?&@@@@@@@$!!!!!!?@@@@@@@@&O#&&&&%??$#@@@@@@@@@@
+@@@@@@?!!!!!!?@@@@@O!!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!!%@@@@@@O!!!!!!!?@@@@@@@O#@@&%??!!!!!$@@@@@@@@@
+@@@@@@?!!!!!!!O@@@@O!!!!!!#@$!!!!!!?????????&@%!!!!!!!!$@@@@#!!!!!!!!?@@@@@&O&@&&O$$?!!!!!!%&@@@@@@@
+@@@@@@?!!!!!!!!#@@@O!!!!!!#@$!!!!!!#&&&&&&&&@@%!!!!!!!!!$@@&?!!!!!!!!?@@@@@O&@&??&@@&O!!!!!!%@@@@@@@
+@@@@@@?!!!!!!!!?&@@O!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!!!!!O@%!!!!!!!!!?@@@@O&@@O!O@@@@&O!!!!!!$@@@@@@
+@@@@@@?!!!!!!!!!?#@O!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!!!!!!%!!!!!!!!!!?@@@&O@@$!!O&@@@@&O!!!!!!#@@@@@
+@@@@@@?!!!!!!!!!!!OO!!!!!!#@$!!!!!!$OOOOO@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@@O@&%!!!!!%#&&@&?!!!!!%@@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!!!!!!?@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@@O&!!!!!!%%eO&@$!!!!!!%&@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!!!!!!?@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@&&$!!!?$O$Oe$@@!!!!!!eO#@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!?%%%%$@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@O&!!!!$&$#%!#@@?!!!!!!$O@@@@
+@@@@@@?!!!!!!!!!!!!!!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!!!!!!!!!!!!!!!!!?@@O&!!!!%?O@%&&&@$!!!!!!?O@@@@
+@@@@@@?!!!!!?#!!!!!!!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!#!!!!!!!!O?!!!!!?@@O#!!!!!!?@@@@@OO!!!!$e?O@@@@
+@@@@@@?!!!!!?@#?!!!!!!!!!!#@$!!!!!!#@@@@@@@@@@%!!!!!!&#!!!!!!%&?!!!!!?@@OOO?!!!%%@@@@@#?!%$#O%%$@@@@
+@@@@@@?!!!!!?@@&%!!!!!!!!!#@$!!!!!!?????????&@%!!!!!!&@O!!!!?&@?!!!!!?@@#&##%$&&&@@@@@@$%#&O!??O@@@@
+@@@@@@?!!!!!?@@@@#?!!!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!&@@$!!!&@@?!!!!!?@@&#$&@@@@@@@@@@@?O%%?!!!#@@@@
+@@@@@@?!!!!!?@@@@@@#%!!!!!#@$!!!!!!!!!!!!!!!#@%!!!!!!&@@@$!O@@@?!!!!!?@@@O#&&@@@@@@@@@@O?!!!!!?&@@@@
+@@@@@@?!!!!!?@@@@@@@@&O$%%#@#O##&&&&&&&&##OO&@$!!!!!!&@@@@O@@@@?!!!!!?@@@O&&#&@@@@@@@@@$!!!!!!$@@@@@
+@@@@@@?!!!!!?@@@@@@@@@@@@@@&&#O$$$%%%%$$$OO#&@@&#O%?!&@@@@@@@@@?!!!!!?@@@@OOO@@@@@@@@@&!!!!!!!&@@@@@
+@@@@@@?!!!!!?@@@@@@@@@&#$%?!!!!!!!!!!!!!!!!!!!?%O#@@#@@@@@@@@@@?!!!!!?@@@@#!!%&@@@@@@@%!!!!!!O@@@@@@
+@@@@@@?!!!!!?@@@@@@#$?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!%$&@@@@@@@@@?!!!!!?@@@@@#!!%@@@@@@@O!!$&$$@@@@@@@
+@@@@@@?!!!!!?@@@O%!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!?$#@@@@@@?!!!!!?@@@@@@O!!?@@@@@@@&&@#O@@@@@@&&
+@@@@@@?!!!?O&#$?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!?$#@@@$?!!!!?@@@@@@@&%!?$#@@@@@&O#@@@@@#O&@
+@@@@@@?!?O&#%!!!!!!!!!??%%$$$OOOOOOOOOO$$%%??!!!!!!!!!!!!!!!?%O&&&O$%%@@@@@@@@@#%?%####O#@@@&#$$#@@@
+@@@@@@%O&#%!!!!!?%$O#&&@@@@@@@@@@@@@@@@@@@@@&&#O$%?!!!!!!!!!!!!!?$O&&&@@@@@@@@@@@&&&&&&&&#$%?%#@@@@@
+@@@@@@&#%!!!?$#&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&#O%?!!!!!!!!!!!!??%$OOO#######OO$%??!!?%#@@@@@@@
+@@@@@&$!?%O&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#O$%?!!!!!!!!!!!!!!!!!!!!!!!!!?$#&@@@@@@@@@
+@@@@O?%O&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#OO$%????!!!!!!!!??%%O#&@@@@@@@@@@@@@
+@@&$$&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&@@@@@@@@@@@@@@@@@@@@
+@#O&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/svn_abstract.awk
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/svn_abstract.awk	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/svn_abstract.awk	(revision 6041)
@@ -0,0 +1,34 @@
+#!/bin/awk
+
+BEGIN{}
+
+func relative_path() { sub(/.*NEMOGCM\/[[:upper:]]*\//,//); return substr($0,2) }
+
+func array_loop(action,nb,array) {
+    if ( nb != 0 ) {
+	printf("\n%-10s: %3d\n\t",action,nb)
+	j = 0
+	for (i in array) {
+	    j += 1
+	    printf("%-45s\t",array[i])
+	    if ( j % 3 == 0 && j != nb ) { printf"\n\t" }
+	}
+    }
+}
+
+/^A[[:upper:] ]/ { acount += 1; aroutines[acount] = relative_path() }
+/^C[[:upper:] ]/ { ccount += 1; croutines[ccount] = relative_path() }
+/^D[[:upper:] ]/ { dcount += 1; droutines[dcount] = relative_path() }
+/^E[[:upper:] ]/ { ecount += 1; eroutines[ecount] = relative_path() }
+/^G[[:upper:] ]/ { gcount += 1; groutines[gcount] = relative_path() }
+/^U[[:upper:] ]/ { ucount += 1; uroutines[ucount] = relative_path() }
+
+END{
+    array_loop("added",     acount,aroutines)
+    array_loop("conflicted",ccount,croutines)
+    array_loop("deleted",   dcount,droutines)
+    array_loop("edited",    ecount,eroutines)
+    array_loop("merged",    gcount,groutines)
+    array_loop("updated",   ucount,uroutines)
+    printf "\n"
+}
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting.env
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting.env	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting.env	(revision 6041)
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+
+## Global environment variables
+##--------------------------------------
+dat=$( date )
+export DATE=$( date -ud "$dat" +"%Y%m%d%Z%H%M" )
+export PATTERNAME=${TRUS_USER}'_'${TRUS_HPCC}
+export TRUS_SVNH='https://forge.ipsl.jussieu.fr/nemo/svn'
+
+
+## Source user configuration
+##---------------------------------------------------
+. ./config/${TRUS_USER}.cfg
+export TRUS_WORK TRUS_SCRA TRUS_STOR TRUS_XIOS TRUS_FORC
+export TRUS_BRAN TRUS_REFE
+export TRUS_CONF TRUS_TARF TRUS_KEYA TRUS_KEYD
+export TRUS_MAIL
+
+
+## Source (super)computer configuration
+##---------------------------------------------------
+. ./config/${TRUS_HPCC}.cfg
+export TRUS_ENVI TRUS_CDOD TRUS_NPRO TRUS_TOUT
+export TRUS_JSPT TRUS_JSUB TRUS_JSTA TRUS_JKIL
+export TRUS_JPME TRUS_JTIM TRUS_JVME TRUS_JINF
+export TRUS_CMPV TRUS_CDOR TRUS_MPIR TRUS_CDFR
+
+
+export TRUS_NGCM=${TRUS_WORK}/${TRUS_BRAN}/NEMOGCM
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting_func.sh
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting_func.sh	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting_func.sh	(revision 6041)
@@ -0,0 +1,427 @@
+#!/bin/bash
+
+
+## Messenger filenames
+FILE_DATE=mesg_01_date_$PATTERNAME.txt  ; FILE_RSLT=mesg_02_result_$PATTERNAME.txt
+FILE_STAT=mesg_03_state_$PATTERNAME.txt ; FILE_NEMO=mesg_04_nemo_$PATTERNAME.txt
+FILE_XIOS=mesg_05_xios_$PATTERNAME.txt  ; FILE_CMPF=mesg_06_compiler_$PATTERNAME.txt
+FILE_LMPI=mesg_07_mpi_$PATTERNAME.txt   ; FILE_NCDF=mesg_08_netcdf_$PATTERNAME.txt
+FILE_INPT=mesg_09_inputs_$PATTERNAME.txt; FILE_TIME=mesg_10_time_$PATTERNAME.txt
+FILE_MEMY=mesg_11_memory_$PATTERNAME.txt; FILE_NOTE=mesg_12_comments_$PATTERNAME.txt
+
+## Trusting timestamped logfile & archive
+TRUS_FILE=trusting_${DATE}_$PATTERNAME.txt; TRUS_ARCH=trusting_${DATE}_$PATTERNAME.tgz
+
+
+## Functions in order of use
+print_step() {
+    local char_nb=$( echo "$1" | wc -c )
+    local outline=$( printf "%${char_nb}s" )
+
+    printf "\nStep.....\n%s\n%s\n" "$1" ${outline// /-}
+}
+
+init_files() {
+    echo 'Date'        	      > ${FILE_DATE}; echo 'Result'           > ${FILE_RSLT}
+    echo 'State'      	      > ${FILE_STAT}; echo 'NEMOGCM rev.'     > ${FILE_NEMO}
+    echo 'XIOS rev.'   	      > ${FILE_XIOS}; echo 'Fortran compiler' > ${FILE_CMPF}
+    echo 'MPI libs'    	      > ${FILE_LMPI}; echo 'NetCDF libs'      > ${FILE_NCDF}
+    echo 'Input files' 	      > ${FILE_INPT}; echo 'Elapsed time'     > ${FILE_TIME}
+    echo 'Memory usage (P/V)' > ${FILE_MEMY}; echo 'Comments'         > ${FILE_NOTE}
+
+    ## 'Failed' status with 'Unknown error' by default
+    echo ${TRUS_RSLT}      \
+	>> ${FILE_RSLT}
+    echo 'Unknown error' \
+	>> ${FILE_STAT}
+}
+
+get_date() {
+    ## UTC time zone for timestamping
+    local dat=$( date -ud "${DATE}" +"%F %R %Z" )
+
+    echo $dat           \
+	>> ${FILE_DATE}
+}
+
+get_nemo_rev() {
+    local dir rev_loc
+    local rev=0
+
+    ## Loop on essential NEMO directories
+    for dir in ${TRUS_CKOT} ${TRUS_XIOS}; do
+
+	## For time being, just get revision from XIOS with no action on directory
+	if [ $dir == ${TRUS_XIOS} ]; then
+	    rev_loc=$( svn info $dir | awk '/Last Changed Rev/ {print $NF}' )
+	    echo 'XIOS '${rev_loc} \
+		>> model.log
+	    echo "<a href=\"https://forge.ipsl.jussieu.fr/ioserver/changeset/${rev_loc}\" target=\"_blank\">${rev_loc}</a>" \
+		>> ${FILE_XIOS}
+	    continue
+	fi
+
+	echo $dir && ${TRUS_SVNA} ${TRUS_NGCM}/$dir
+	rev_loc=$( svn info ${TRUS_NGCM}/$dir | awk '/Last Changed Rev/ {print $NF}' )
+
+	## Keep last rev. nb
+	[ ${rev_loc} -gt $rev ] && rev=${rev_loc}
+    done
+
+    echo 'NEMOGCM '$rev \
+	>> model.log
+    echo "<a href=\"https://forge.ipsl.jussieu.fr/nemo/changeset/$rev\" target=\"_blank\">$rev</a>" \
+	>> ${FILE_NEMO}
+}
+
+get_soft_rel() {
+    local soft_rel str
+
+    ## Sourcing environment
+    if [ -n "${TRUS_ENVI}" ]; then
+	if [[  -e ${TRUS_ENVI}.env && $( declare -F | grep ' module' ) ]]; then
+            ## .env file if module function is available
+	    . ${TRUS_ENVI}.env
+	else
+            ## .path file if existing, if not the given file
+	    [ -e ${TRUS_ENVI}.path ] && . ${TRUS_ENVI}.path || . ${TRUS_ENVI}
+	fi
+    fi
+
+    ## Problem with `prepend-path` of modulefile that use ':' instead of ' ' as delimiter
+    [ $TRUS_HPCC == 'X64_ADA' ] && WRAPPER_LDFLAGS='-L/smplocal/pub/IdrMemMPI/1.4/lib -lidrmem '${WRAPPER_LDFLAGS}
+
+    for str in ${TRUS_CMPV} ${TRUS_MPIR} ${TRUS_CDFR} ${TRUS_CDOR}; do
+	[ -z "$str" ] && continue
+	soft_rel=''
+
+	## Software release: next word after "$soft" in $PATH (case-insensitive)
+	soft_rel=$( echo $PATH | sed "s#.*$str\([0-9.a-z_]*\).*#\1#i" )
+
+	## option --version would work for main compilers (gfortran, intel, pgfortran, ...)
+	[ $str == ${TRUS_CMPV} ] && soft_rel=$( $str --version | grep -m1 -oe '\<[0-9. ]*\>' )
+
+	## Cleaning characters string to display proper soft name
+	str=$( echo $str | sed 's#\\##g; s#[/-]$##' )
+
+	echo $str ${soft_rel} \
+	    >> model.log
+    done
+
+    sed -n 3p model.log \
+	>> ${FILE_CMPF}
+    sed -n 4p model.log \
+	>> ${FILE_LMPI}
+    sed -n 5p model.log \
+	>> ${FILE_NCDF}
+}
+
+get_inputs() {
+    ## Extract archive or copy files in case of personal inputs
+    [ -z "${TRUS_TARF}" ] && get_io="cp ${TRUS_FORC}/* ." || get_io="tar -vxf ${TRUS_FORC}/${TRUS_TARF}"
+
+    ${get_io} > /dev/null
+    [ $? -ne 0 ] && get_out 3 || echo 'Success'
+    [ $( find -name '*.gz' -print -quit ) ] && gunzip *.gz
+
+    ls -lh > inputs_list.txt
+}
+
+diff_inputs() {
+    local dif file
+    local files_list='' mesg='Same' 
+
+    ## Simple diff
+    for file in 'inputs_list.txt' *namelist_* *.xml cpp_*; do
+	dif=''
+
+	## Continue even if input file is not in here (see after)
+	if [ -e ${TRUS_STOR}/$file ]; then dif=$( diff -q $file ${TRUS_STOR}/$file ); else dif=0; fi
+
+	## Pass over useless file omission in benckmark directory
+	[[ -n "$dif" && "$dif" != '0' ]] && { mesg='Different'; echo $dif; files_list+=$file' '; }
+    done
+
+    [ $mesg == 'Same' ] && echo $mesg
+    echo $mesg          \
+	>> ${FILE_INPT}
+
+    ## List different files for web comment
+    [ -n "${files_list}" ] && echo 'Inputs  : '${files_list}'differ<br>' \
+	>> temp_${FILE_NOTE}
+}
+
+job_pending() {
+    local outline=$( printf "%100s" ) time_elapsed=0 time_increment=30
+
+    sleep ${time_increment}
+
+    ## Append a log file while pending
+    while [[ $( eval ${TRUS_JSTA} ) && ${time_elapsed} -lt ${TRUS_TOUT} ]]; do
+	printf "\n%s\n" ${outline// /#}          \
+	    >> computation.log
+	[ -n "${TRUS_JINF}" ] && eval ${JOB_INFO} \
+	    >> computation.log
+	sleep ${time_increment}
+	time_elapsed=$(( ${time_elapsed} + ${time_increment} ))
+    done
+
+    sleep ${time_increment}
+
+    ## Kill remaining job & stop the test if it's too long
+    [ ${time_elapsed} -eq ${TRUS_TOUT} ] && { eval ${JOB_DELE} &> /dev/null; get_out 6; }
+}
+
+diff_results() {
+    local file
+    local files_list='' mesg='Same'
+
+    ## Simple diff
+    for file in 'ocean.output' *.stat; do
+	## Stop if no benchmark files (ocean.output, eventual stat files)
+	[ ! -e ${TRUS_STOR}/$file ] && { TRUS_RSLT='FAILED'; get_out 7; }
+
+	diff -q $file ${TRUS_STOR}/$file
+
+	## Continue even if it differs
+	[ $? -ne 0 ] && { TRUS_RSLT='FAILED'; mesg='Different'; files_list+=$file' '; }
+    done
+
+    [ $mesg == 'Same' ] && echo $mesg
+
+    ## List different files for web comment
+    [ -n "${files_list}" ] && echo 'Results : '${files_list}'differ<br>' \
+	>> temp_${FILE_NOTE}
+}
+
+diff_restart() {
+    local base_name comp dif file list_comp list_tmsp nb_dom time_step tmsp
+    local files_list='' dif_sum=0
+
+    ## Stop if no benchmark files (ie time.step)
+    [ ! -e ${TRUS_STOR}/time.step ] && { TRUS_RSLT='FAILED'; get_out 7; }
+    time_step=$( cat ${TRUS_STOR}/time.step | tr -d [:space:] )
+
+    ## Find all restart files to rebuild
+    if [ $( find -regex ".*_restart.*[0-9]\.nc" -print -quit ) ]; then
+	base_name=$( find -regex ".*_restart.*[0-9]\.nc"                       \
+	             | sed "s#^\./\(.*\)_[0-9]*_restart.*#\1#"       | sort -u   )
+	list_comp=$( find -regex ".*_restart.*[0-9]\.nc"                       \
+	             | sed "s#^.*\(restart[a-z_]*\)_[0-9].*\.nc#\1#" | sort -u   )
+	list_tmsp=$( find -regex ".*_restart.*[0-9]\.nc"                       \
+	             | sed "s#^.*\([0-9]\{8\}\)_restart.*#\1#"       | sort -u   )
+
+	## Loop on each time step
+	for tmsp in ${list_tmsp}; do
+
+	    for comp in ${list_comp}; do
+		file=${base_name}_${tmsp}_${comp}
+		nb_dom=$( find -name "${file}_[0-9]*.nc" | wc -l | awk '{ print $1 }' )
+
+		if   [ ${nb_dom} -gt 1 ]; then
+		    ${TRUS_NGCM}/TOOLS/REBUILD_NEMO/rebuild_nemo -t ${TRUS_NPRO} $file ${nb_dom} \
+			> /dev/null
+
+		     ## Possibility of remaining decomposed restarts (even after rebuild)
+		    [ $? -eq 0 ] && rm -f ${file}_[0-9]*.nc \
+                        > /dev/null
+
+		elif [ ${nb_dom} -eq 0 ]; then
+		    TRUS_RSLT='FAILED' && get_out 8
+		fi
+
+		## Compare restart files at same time step
+		if [ $tmsp -eq ${time_step} ]; then
+
+                    ## Stop if no benchmark files (restart file)
+		    if [ -e ${TRUS_STOR}/$file.nc ]; then
+
+	                ## UNIX `cmp` not suitable (timestamp in .nc file)
+			dif=$( $TRUS_CDOD $file.nc ${TRUS_STOR}/$file.nc 2> /dev/null          \
+			       | awk '/records/ {print $0}' | sed '2 s/^/,/' | tr -d '\n' )
+
+			## CDO can return void stdout with no difference
+			if [[ -n "$dif" && $( echo $dif | awk '{print $1}' ) -ne 0 ]]; then
+			    TRUS_RSLT='FAILED'
+			    files_list+=$comp' ' && let dif_sum+=$( echo $dif | awk '{print $1}' )
+			    echo $file.nc': '$dif
+			fi
+
+		    else
+			TRUS_RSLT='FAILED' && get_out 7
+		    fi
+
+		else
+		    continue
+		fi
+
+	    done
+
+	done
+
+        ## List different files for web comment with sum of different records
+	if [ ${dif_sum} -ne 0 ]; then
+	    echo 'Restarts: '${files_list}${dif_sum}' record(s) differ<br>' \
+		>> temp_${FILE_NOTE}
+	else
+	    echo 'Same'
+	fi
+
+    else
+	TRUS_RSLT='FAILED'
+    fi
+
+}
+
+get_time() {
+    [ -z "${TRUS_JTIM}" ] && return
+
+    ## Interest for checking unusual time computation
+    local time_cpu=$( eval ${TRUS_JTIM} )
+
+    printf "Elapsed time: "
+    echo ${time_cpu} | tee -a ${FILE_TIME}
+}
+
+get_memy() {
+    [[ -z "${TRUS_JPME}" && -z "${TRUS_JVME}" ]] && return
+
+    ## Interest for checking unusual memory usage
+    local memory_pmax=$( eval ${TRUS_JPME} ) memory_vmax=$( eval ${TRUS_JVME} )
+
+    printf "Memory max usage (physical/virtual): "
+    echo ${memory_pmax}' / '${memory_vmax} | tee -a ${FILE_MEMY}
+}
+
+comments() {
+    local opat
+    local line='' state=$1
+
+    if [ -e ocean.output ]; then
+        ## 'W A R N I N G' pattern by default
+	opat="-A2 \"^ $state\""
+	[ "$state" == 'E R R O R' ] && opat="-A4 \"$state\""
+
+        ## Select first occurence for web comment
+	line=$( eval grep -m1 $opat ocean.output | tr -d '\n' )
+    fi
+
+    [ -n "$line" ] && ( echo $line; printf "$line<br>" \
+	>> temp_${FILE_NOTE} )
+}
+
+log_make() {
+    ## Format comments for web
+    [ -e temp_${FILE_NOTE} ] && cat temp_${FILE_NOTE} | tr -d '\n' | sed 's/<br>$//' \
+	>> ${FILE_NOTE}
+
+    ## Construct txt file with all messenger files
+    paste -d ';' mesg_*.txt | tee ${TRUS_FILE}
+}
+
+prod_publish() {
+    local cmd
+    local rev=$( awk '/NEMOGCM/ {print $NF}' model.log )
+
+    ## Production mode (-p|--prod)
+    if [ ${TRUS_PROD} -eq 1 ]; then
+
+	## Create or append trusting logfile
+	if [ -f ${TRUS_STOR}/trusting_$PATTERNAME.txt ]; then cmd='tail -1'; else cmd='cat'; fi
+
+	$cmd ${TRUS_FILE}                            \
+	    >> ${TRUS_STOR}/trusting_$PATTERNAME.txt
+
+        ## Send mail only when FAILED
+	if [[ ! -z "${TRUS_MAIL}" && ${TRUS_RSLT} == 'FAILED' ]]; then
+
+	    ## Content
+	    cat <<END_MAIL      \
+		> trusting.mail
+Dear all,
+
+
+The trusting sequence has not completed successfully on new configuration ${TRUS_CONF} based on ${TRUS_REFE}.
+
+Here is the model summary:
+`cat model.log`
+
+First checking would be on the trusting environment files:
+${TRUS_USER}.cfg & ${TRUS_HPCC}.cfg
+
+For more details, look into the testing folder at:
+${TRUS_SCRA}
+
+An archive has been created to share the questionable configuration for further studies:
+${TRUS_STOR}/${TRUS_ARCH}
+
+END_MAIL
+
+	    ## Send with detailed subject
+	    mail -s "[NEMO Trusting][$rev][${TRUS_BRAN}][${TRUS_REFE}] ${TRUS_RSLT} ${TRUS_RORR}" ${TRUS_MAIL} \
+		<  trusting.mail
+	fi
+
+    fi
+}
+
+get_out() {
+    local time_step=0
+
+    TRUS_RORR=$1
+
+    printf "\n\nEnd of test\n"
+
+    ## In case of compilation error
+    cd ${TRUS_SCRA}
+
+    if [ ${TRUS_RSLT} == 'FAILED' ]; then
+	echo 'Failure'
+
+        ## Error identification
+	case ${TRUS_RORR} in
+            ## Compilation
+	    '1') TRUS_RORR='XIOS compilation failed' ;; '2') TRUS_RORR='NEMO compilation failed';;
+	    ## Submission
+	    '3') TRUS_RORR='Missing input files'     ;; '4') TRUS_RORR='Job submission error'   ;;
+	    ## Computation
+	    '5') TRUS_RORR='Crashed at time step'    ;; '6') TRUS_RORR='Exceeded time limit'    ;;
+	    ## Results
+	    '7') TRUS_RORR='Missing previous outputs';; '8') TRUS_RORR='New outputs differ'     ;;
+	    ## Other
+	    '*') TRUS_RORR='Unknown error'           ;;
+	esac
+
+    else
+	echo 'Success' && TRUS_RORR='Code is reliable'
+    fi
+
+    ## Eventual comments from ocean.output
+    if [ "${TRUS_RORR}" == 'Crashed at time step' ]; then
+	comments 'E R R O R'
+	[ -e time.step ] && time_step=$( grep -o [0-9]* time.step )
+	TRUS_RORR+=' '$time_step
+    else
+	comments 'W A R N I N G'
+	[ "${TRUS_RORR}" == 'Exceeded time limit' ] && TRUS_RORR+=' '$(( ${TRUS_TOUT}/3600 ))'h'
+    fi
+
+    ## Last messenger files
+    #export TRUS_RORR
+    sed -i "2 s/.*/$TRUS_RSLT/" ${FILE_RSLT}; sed -i "2 s/.*/$TRUS_RORR/" ${FILE_STAT}
+
+    ## Save tested configuration if trusting failed in production mode (-p|--prod)
+    if [[ ${TRUS_RSLT} == 'FAILED' && ${TRUS_PROD} -eq 1 ]]; then
+	echo 'Creating archive '${TRUS_ARCH}' under '${TRUS_STOR}
+	tar -czf ${TRUS_STOR}/${TRUS_ARCH}               *                    \
+	    -C   ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/MY_SRC .                    \
+	    -C   ${TRUS_NGCM}/CONFIG/${TRUS_CONF}        cpp_${TRUS_CONF}.fcm
+    fi
+
+    ## Logfile construct & eventual sending of notification email
+    printf "\nTrusting digest:\n----------------\n"
+    log_make
+    prod_publish
+
+    exit 0
+}
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting_help.txt
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting_help.txt	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inc/trusting_help.txt	(revision 6041)
@@ -0,0 +1,42 @@
+Usage: ./trusting.sh        -u $USER -m $ARCH [OPTIONS]
+       ./install_new_branch -u $USER -m $ARCH [OPTIONS]
+
+./trusting.sh            Launch trusting test on $ARCH machine from $USER installation
+./install_new_branch     Install new branch in $USER installation for trusting test on $ARCH machine
+
+Examples: `./trusting.sh        -u romr005 -m X64_CURIE -p -b nemo_v3_6_STABLE`
+          `./install_new_branch -u romr005 -m X64_ADA   -w $HOME/NEMO         `
+
+Mandatory
+    Default settings to source in ./config, templates (arch_template.cfg & user_template.cfg)
+    -m,--machine      Architecture environment (compilation & computation settings)
+    -u,--user         User             ""      (NEMO & XIOS installation)		   
+
+
+Options (modify default settings)
+SVN
+    -b,--branch	      Branch name in working directory ('trunk'|'nemo_v3_6_stable'|...)
+    -v,--version      Action on working copy ('status' by default)
+  		           '{'YYYY-MM-DD'}'  Update to revision available at this date
+		           [0-9]*	       ""   ""    ""    number
+		           HEAD|up|update      ""   "" last revision
+		           st|status	     Show differences with repository
+    -w,--workdir      Installation directory for testing branches
+
+Inputs
+    -a,--archive      Forcing input files archive to extract, if void it will copy all files from given folder (see next line)
+    -f,--forcdir      Path to your personal folder of forcing inputs
+
+Testing configuration
+    -n,--new_conf     Testing   configuration folder created in ./CONFIG
+    -r,--ref_conf     Reference      " "      for trusting test
+
+Compiling & computation
+    -j,--job          Number of processes for compiling
+    -t,--time         Timeout for computation (s)
+
+Trusting output
+    -d,--debug        Verbose output for debugging purpose (`set -vx`)
+    -e,--email        Email trusting digest report to following addresses only on failure
+    -h,--help         Print this help & exit
+    -p,--prod         Production mode (append trusting logfile)
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/AMM12/iodef.xml
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/AMM12/iodef.xml	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/AMM12/iodef.xml	(revision 6041)
@@ -0,0 +1,157 @@
+<?xml version="1.0"?>
+<simulation> 
+
+ <context id="nemo" time_origin="1950-01-01 00:00:00" >
+    
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    <field_definition src="./field_def.xml"/>
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+    
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="10d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->
+     
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."> <!-- 1d files -->
+
+	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="sst"          name="tos" />
+	  <field field_ref="sss"          name="sos" />
+	  <field field_ref="ssh"          name="zos" />
+	</file>
+
+	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="ssu"          name="uos" />
+	</file>
+	
+	<file id="file3" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="ssv"          name="vos" />
+	</file>
+	
+      </file_group>
+
+      <file_group id="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d files -->    
+
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   
+
+	<file id="file4" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="toce"         name="thetao" />
+	  <field field_ref="soce"         name="so"     />
+	  <field field_ref="sst"          name="tos"    />
+	  <field field_ref="sst2"         name="tossq"  />
+	  <field field_ref="sss"          name="sos"    />
+	  <field field_ref="ssh"          name="zos"    />
+	  <field field_ref="ssh2"         name="zossq"  />
+	  <field field_ref="empmr"        name="wfo"    />
+	  <field field_ref="qsr"          name="rsntds" />
+	  <field field_ref="qt"           name="tohfls" />
+	  <field field_ref="taum"     />
+	  <field field_ref="mldkz5"   />
+	  <field field_ref="mldr10_1" />
+	</file>
+	
+	<file id="file5" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="uoce"         name="uo"    />
+	  <field field_ref="ssu"          name="uos"   />
+	  <field field_ref="utau"         name="tauuo" />
+	</file>
+	
+	<file id="file6" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="voce"         name="vo"    />
+	  <field field_ref="ssv"          name="vos"   />
+	  <field field_ref="vtau"         name="tauvo" />
+	</file>
+	
+	<file id="file7" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="woce"         name="wo"     />
+	  <field field_ref="avt"          name="difvho" />
+	</file>
+	
+      </file_group>
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."/> <!-- real monthly files -->
+      <file_group id="2m" output_freq="2mo" output_level="10" enabled=".TRUE."/> <!-- real 2m files -->
+      <file_group id="3m" output_freq="3mo" output_level="10" enabled=".TRUE."/> <!-- real 3m files -->
+      <file_group id="4m" output_freq="4mo" output_level="10" enabled=".TRUE."/> <!-- real 4m files -->
+      <file_group id="6m" output_freq="6mo" output_level="10" enabled=".TRUE."/> <!-- real 6m files -->
+
+      <file_group id="1y"  output_freq="1y" output_level="10" enabled=".TRUE."/> <!-- real yearly files -->
+      <file_group id="2y"  output_freq="2y" output_level="10" enabled=".TRUE."/> <!-- real 2y files -->
+      <file_group id="5y"  output_freq="5y" output_level="10" enabled=".TRUE."/> <!-- real 5y files -->
+      <file_group id="10y" output_freq="10y" output_level="10" enabled=".TRUE."/> <!-- real 10y files -->
+
+   </file_definition>
+    
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+   <axis_definition>  
+      <axis id="deptht"  long_name="Vertical T levels"  unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels"  unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels"  unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels"  unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"       unit="1"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"       unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"              />
+   </axis_definition> 
+    
+   <domain_definition src="./domain_def.xml"/>
+   
+   <grid_definition>    
+     <grid id="grid_T_2D" domain_ref="grid_T"/>
+     <grid id="grid_T_3D" domain_ref="grid_T" axis_ref="deptht"/>
+     <grid id="grid_U_2D" domain_ref="grid_U"/>
+     <grid id="grid_U_3D" domain_ref="grid_U" axis_ref="depthu"/>
+     <grid id="grid_V_2D" domain_ref="grid_V"/>
+     <grid id="grid_V_3D" domain_ref="grid_V" axis_ref="depthv"/>
+     <grid id="grid_W_2D" domain_ref="grid_W"/>
+     <grid id="grid_W_3D" domain_ref="grid_W" axis_ref="depthw"/>
+     <grid id="gznl_T_2D" domain_ref="gznl"/>
+     <grid id="gznl_T_3D" domain_ref="gznl" axis_ref="deptht"/>
+     <grid id="gznl_W_3D" domain_ref="gznl" axis_ref="depthw"/>
+    </grid_definition>   
+  </context>
+  
+
+  <context id="xios">
+
+      <variable_definition>
+	
+     <!-- 
+        We must have buffer_size > jpi*jpj*jpk*8 (with jpi and jpj the subdomain size)
+-->
+	  <variable id="buffer_size"               type="integer">10000000</variable>
+	  <variable id="buffer_server_factor_size" type="integer">2</variable>
+	  <variable id="info_level"                type="integer">0</variable>
+	  <variable id="using_server"              type="boolean">false</variable>
+	  <variable id="using_oasis"               type="boolean">false</variable>
+	  <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+	
+      </variable_definition>
+               
+  </context>
+  
+</simulation>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/AMM12/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/AMM12/namelist_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/AMM12/namelist_cfg	(revision 6041)
@@ -0,0 +1,434 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  : AMM12 configuration namelist used to overwrite defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  "AMM12_trust"  	!  experience name
+   nn_it000    =       1   	 	!  first time step
+   nn_itend    =     576   	 	!  last  time step (std 1 day = 144)
+   nn_date0    =  20120102 	 	!  date at nit_0000 (format yyyymmdd) used if ln_rstart=F or (ln_rstart=T and nn_rstctl=0 or 1)
+   nn_leapy    =       1   	 	!  Leap year calendar (1) or not (0)
+   ln_rstart   =  .true.         	!  start from rest (F) or from a restart file (T)
+   nn_euler    =       1   	 	!  = 0 : start with forward time step if ln_rstart=.true.
+   cn_ocerst_in   = "amm12_restart_oce" !  suffix of ocean restart name (input)
+   cn_ocerst_out  = "restart_oce_out"   !  suffix of ocean restart name (input)
+   nn_stock    =    1296   	 	!  frequency of creation of a restart file (modulo referenced to 1)
+   nn_write    =     144   	 	!  frequency of write in the output file   (modulo referenced to nit000) 
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "amm"                !  name of the configuration
+   jp_cfg      =     011               !  resolution of the configuration
+   jpidta      =     198               !  1st lateral dimension ( >= jpi )
+   jpjdta      =     224               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      51               !  number of levels      ( >= jpk )
+   jpiglo      =     198               !  1st dimension of global domain --> i =jpidta
+   jpjglo      =     224               !  2nd    -                  -    --> j  =jpjdta
+   jpizoom     =       1               !  left bottom (i,j) indices of the zoom
+   jpjzoom     =       1               !  in data domain indices
+   jperio      =       0               !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zps      = .false.   !  z-coordinate - partial steps   (T/F)
+   ln_sco      = .true.    !  s- or hybrid z-s-coordinate    (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+   ln_s_sh94   = .false.   !  Song & Haidvogel 1994 hybrid S-sigma   (T)|
+   ln_s_sf12   = .true.    !  Siddorn & Furner 2012 hybrid S-z-sigma (T)| if both are false the NEMO tanh stretching is applied
+   ln_sigcrit  = .true.    !  use sigma coordinates below critical depth (T) or Z coordinates (F) for Siddorn & Furner stretch
+                           !  stretching coefficients for all functions
+   rn_hc       =   50.0    !  critical depth for transition to stretched coordinates
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_msh      =       0               !  create (=1) a mesh file or not (=0)
+   rn_rdt      =   600.    !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_rdtmin   =   600.          !  minimum time step on tracers (used if nn_acc=1)
+   rn_rdtmax   =   600.          !  maximum time step on tracers (used if nn_acc=1)
+   rn_rdth     =   600.          !  depth variation of tracer time step  (used if nn_acc=1)
+   ppglam0     =  999999.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =  999999.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0             !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0             !  meridional grid-spacing (degrees)
+   ppsur       =  999999.0             !  ORCA r4, r2 and r05 coefficients
+   ppa0        =  999999.0             ! (default coefficients)
+   ppa1        =  999999.0             !
+   ppkth       =      23.563           !
+   ppacr       =       9.0             !
+   ppdzmin     =       6.0             !  Minimum vertical spacing
+   pphmax      =    5720.              !  Maximum depth
+   ldbletanh   =  .FALSE.              !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.              !  Double tanh function parameters
+   ppkth2      =  999999.              !
+   ppacr2      =  999999.
+/
+!-----------------------------------------------------------------------
+&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
+!-----------------------------------------------------------------------
+   ln_bt_nn_auto =    .FALSE.          !  Set nn_baro automatically to be just below
+                                       !  a user defined maximum courant number (rn_bt_cmax)
+   nn_baro       =    30               !  Number of iterations of barotropic mode
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+   ln_tsd_init   = .false.   !  Initialisation of ocean T & S with T &S input data (T) or not (F)
+   ln_tsd_tradmp = .false.   !  damping of ocean T & S toward T &S input data (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation
+                           !     (also = the frequency of sea-ice model call)
+   ln_flx      = .true.    !  flux formulation       (T => fill namsbc_flx )
+   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core)
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+   ln_apr_dyn  = .false.    !  Patm gradient added in ocean & ice Eqs.   (T => fill namsbc_apr )
+
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_utau     = 'amm12_utau'     ,          1        ,  'utau'      , .false.      , .false. , 'daily'   ,  ''      ,  ''  , ''
+   sn_vtau     = 'amm12_vtau'     ,          1        ,  'vtau'      , .false.      , .false. , 'daily'   ,  ''      ,  ''  , ''
+   sn_qtot     = 'amm12_flx'      ,          3        ,  'sonsfldo'  ,  .true.      , .false. , 'daily'   ,  ''      ,  ''  , ''
+   sn_qsr      = 'amm12_flx'      ,          3        ,  'soshfldo'  ,  .true.      , .false. , 'daily'   ,  ''      ,  ''  , ''
+   sn_emp      = 'amm12_flx'      ,          3        ,  'sowafldo'  ,  .true.      , .false. , 'daily'   ,  ''      ,  ''  , ''
+   cn_dir      = './fluxes/'        !  root directory for the location of the flux files
+/
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_mfs   !   namsbc_mfs  MFS bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_traqsr   = .false.   !  Light penetration (T) or not (F)
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_rnf      = 'amm12_rivers'       ,        24         , 'rorunoff',   .false.    , .true. , 'yearly'  , ''       , ''  , ''
+   sn_cnf      = 'runoff_1m_nomask'   ,         0         , 'socoefr0',   .false.    , .true. , 'yearly'  , ''       , ''  , ''
+   sn_s_rnf    = 'amm12_rivers'       ,        24         , 'rosaline',   .false.    , .true. , 'yearly'  , ''       , ''  , ''
+   sn_t_rnf    = 'amm12_rivers'       ,        24         , 'rotemper',   .false.    , .true. , 'yearly'  , ''       , ''  , ''
+   sn_dep_rnf  = 'amm12_rivers'       ,        24         , 'rodepth' ,   .false.    , .true. , 'yearly'  , ''       , ''  , ''
+   ln_rnf_mouth = .false.   !  specific treatment at rivers mouths
+   ln_rnf_depth = .true.    !  read in depth information for runoff
+   ln_rnf_tem   = .true.    !  read in temperature information for runoff
+   ln_rnf_sal   = .true.    !  read in salinity information for runoff
+/
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_apr     = 'amm12_mslp'     ,          1        ,  'p_msl'      , .false.      , .false. , 'daily'   ,  ''      ,  ''  , ''
+
+   cn_dir      = './fluxes/' !  root directory for the location of the bulk files
+   rn_pref     = 101000.     !  reference atmospheric pressure   [N/m2]/
+   ln_ref_apr  = .false.    !  ref. pressure: global mean Patm (T) or a constant (F)
+   ln_apr_obc  = .true.    !  inverse barometer added to OBC ssh data
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_sst      = 'amm12_sstref'    ,        24         ,  'sst'     ,     .true.     , .false. , 'daily'   , .false. , ''       , '' , ''
+   sn_sss      = 'sss_data'        ,        -1         ,  'sss'     ,     .true.     , .true.  , 'yearly'  , .false. , ''       , '' , ''
+
+   cn_dir      = 'fluxes/' !  root directory for the location of the runoff files
+   nn_sstr     =     1     !  add a retroaction term in the surface heat       flux (=1) or not (=0)
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=2)
+                           !  or to SSS only (=1) or no damping term (=0)
+   rn_deds     =  -27.7    !  magnitude of the damping on salinity   [mm/day]
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =     0     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+                           !  free slip  !   partial slip  !   no slip   ! strong slip
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_tide      !   tide parameters (#ifdef key_tide)
+!-----------------------------------------------------------------------
+   clname(1)     =   'Q1'   !  name of constituent
+   clname(2)     =   'O1'
+   clname(3)     =   'P1'
+   clname(4)     =   'S1'
+   clname(5)     =   'K1'
+   clname(6)     =   '2N2'
+   clname(7)     =   'MU2'
+   clname(8)     =   'N2'
+   clname(9)     =   'NU2'
+   clname(10)    =   'M2'
+   clname(11)    =   'L2'
+   clname(12)    =   'T2'
+   clname(13)    =   'S2'
+   clname(14)    =   'K2'
+   clname(15)    =   'M4'
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+    nb_bdy         =  1
+    cn_dyn2d       = 'flather'
+    nn_dyn2d_dta   =  3
+    cn_tra         =  'frs'
+    nn_tra_dta    =   1 
+/
+!-----------------------------------------------------------------------
+&nambdy_dta      !  open boundaries - external data           ("key_bdy")
+!-----------------------------------------------------------------------
+!          !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!          !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   bn_ssh =     'amm12_bdyT_dyn2d' ,         24        , 'sossheig' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   bn_u2d =     'amm12_bdyU_dyn2d' ,         24        , 'vobtcrtx' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   bn_v2d =     'amm12_bdyV_dyn2d' ,         24        , 'vobtcrty' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   bn_u3d  =    'amm12_bdyU_dyn3d' ,         24        , 'vozocrtx' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   bn_v3d  =    'amm12_bdyV_dyn3d' ,         24        , 'vomecrty' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   bn_tem  =    'amm12_bdyT_tra'   ,         24        , 'votemper' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   bn_sal  =    'amm12_bdyT_tra'   ,         24        , 'vosaline' ,     .true.     , .false. ,  'daily'  ,    ''    ,   ''  , ''
+   cn_dir  =    './bdydta/'
+   ln_full_vel = .false.
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at open boundaries
+!-----------------------------------------------------------------------
+   filtide      = 'bdydta/amm12_bdytide_'         !  file name root of tidal forcing files
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+                           !                              = 2 : nonlinear friction
+   rn_bfri2    =    2.5e-3 !  bottom drag coefficient (non linear case)
+   rn_bfeb2    =    0.0e0  !  bottom turbulent kinetic energy background  (m2/s2)
+   ln_loglayer =    .true. !  loglayer bottom friction (only effect when nn_bfr = 2)
+   rn_bfrz0    =    0.003  !  bottom roughness (only effect when ln_loglayer = .true.)
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+   nn_bbl_ldf  =  0      !  diffusive bbl (=1)   or not (=0)
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+   ln_traldf_hor    =  .true.   !  horizontal (geopotential)   (needs "key_ldfslp" when ln_sco=T)
+   ln_traldf_iso    =  .false.  !  iso-neutral                 (needs "key_ldfslp")
+   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
+   rn_aht_0         =    50.    !  horizontal eddy diffusivity for tracers [m2/s]
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .false.  !  add a damping termn (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_prj  = .true.   !  s-coordinate (Pressure Jacobian scheme)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+!                          !  explicit free surface                     ("key_dynspg_exp")
+!                          !  filtered free surface                     ("key_dynspg_flt")
+!                          !  split-explicit free surface               ("key_dynspg_ts")
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+   !                       !  Type of the operator :
+   ln_dynldf_bilap  =  .true.   !  bilaplacian operator
+   ln_dynldf_lap    =  .false.  !  bilaplacian operator
+   !                       !  Direction of action  :
+   ln_dynldf_level  =  .true.   !  iso-level
+   ln_dynldf_hor    =  .false.  !  horizontal (geopotential)            (require "key_ldfslp" in s-coord.)
+                           !  Coefficient
+   rn_ahm_0_lap     = 60.0      !  horizontal laplacian eddy viscosity   [m2/s]
+   rn_ahm_0_blp     = -1.0e+10  !  horizontal bilaplacian eddy viscosity [m4/s]
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   rn_avm0     =   0.1e-6  !  vertical eddy viscosity   [m2/s]          (background Kz if not "key_zdfcst")
+   rn_avt0     =   0.1e-6  !  vertical eddy diffusivity [m2/s]          (background Kz if not "key_zdfcst")
+   ln_zdfevd   = .false.   !  enhanced vertical diffusion (evd) (T) or not (F)
+   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+/
+!-----------------------------------------------------------------------
+&namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
+!-----------------------------------------------------------------------
+   rn_charn =  100000.     !  Charnock constant for wb induced roughness length
+   nn_z0_met = 1           !  Method for surface roughness computation (0/1/2)
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   ln_tmx_itf  = .FALSE.   !  ITF specific parameterisation
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namnc4        !   netcdf4 chunking and compression settings            ("key_netcdf4")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ("key_trdmld" or     "key_trdvor")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_diaharm   !   Harmonic analysis of tidal constituents ('key_diaharm')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdct        ! transports through sections
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage switch                               ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsto       ! Stochastic parametrization of EOS
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_vvl    !   vertical coordinate options
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/GYRE/iodef.xml
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/GYRE/iodef.xml	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/GYRE/iodef.xml	(revision 6041)
@@ -0,0 +1,284 @@
+<?xml version="1.0"?>
+<simulation> 
+
+ <context id="nemo" time_origin="1900-01-01 00:00:00" >
+    
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    <field_definition src="./field_def.xml"/>
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+ 
+    
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="10d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->
+     
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."> <!-- 1d files -->
+
+	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="sst"          name="tos" />
+	  <field field_ref="sss"          name="sos" />
+	  <field field_ref="ssh"          name="zos" />
+	</file>
+
+	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="ssu"          name="uos" />
+	</file>
+	
+	<file id="file3" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="ssv"          name="vos" />
+	</file>
+
+        <file id="file4" 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="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d files -->    
+
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   
+
+	<file id="file5" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="toce"         name="thetao" />
+	  <field field_ref="soce"         name="so"     />
+	  <field field_ref="sst"          name="tos"    />
+	  <field field_ref="sst2"         name="tossq"  />
+	  <field field_ref="sss"          name="sos"    />
+	  <field field_ref="ssh"          name="zos"    />
+	  <field field_ref="ssh2"         name="zossq"  />
+	  <field field_ref="empmr"        name="wfo"    />
+	  <field field_ref="qsr"          name="rsntds" />
+	  <field field_ref="qt"           name="tohfls" />
+	  <field field_ref="taum"     />
+	  <field field_ref="mldkz5"   />
+	  <field field_ref="mldr10_1" />
+	</file>
+	
+	<file id="file6" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="uoce"         name="uo"     />
+	  <field field_ref="ssu"          name="uos"    />
+	  <field field_ref="utau"         name="tauuo"  />
+	</file>
+	
+	<file id="file7" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="voce"         name="vo"     />
+	  <field field_ref="ssv"          name="vos"    />
+	  <field field_ref="vtau"         name="tauvo"  />
+	</file>
+	
+	<file id="file8" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="woce"         name="wo"     />
+	  <field field_ref="avt"          name="difvho" />
+	</file>
+	
+	<file id="file9" name_suffix="_icemod" description="ice variables" >
+	  <field field_ref="ice_pres"   />
+	  <field field_ref="snowthic_cea" name="snd"    />
+	  <field field_ref="icethic_cea"  name="sit"    />
+	  <field field_ref="iceprod_cea"  name="sip"    />
+	  <field field_ref="ist_ipa"    />
+	  <field field_ref="uice_ipa"   />
+	  <field field_ref="vice_ipa"   />
+	  <field field_ref="utau_ice"   />
+	  <field field_ref="vtau_ice"   />
+	  <field field_ref="qsr_io_cea" />
+	  <field field_ref="qns_io_cea" />
+	  <field field_ref="snowpre"    />
+	</file>
+	
+      </file_group>
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+
+	<file id="file10" 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="file11" name_suffix="_diad_T" description="additional pisces diagnostics" >
+          <field field_ref="Cflx"     />
+          <field field_ref="Dpco2"    />
+	</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 id="file12" 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="file13" name_suffix="_diad_T" description="additional pisces diagnostics" >
+          <field field_ref="PH"       />
+          <field field_ref="CO3"      />
+          <field field_ref="CO3sat"   />
+          <field field_ref="PAR"      />
+          <field field_ref="PPPHY"    />
+          <field field_ref="PPPHY2"   />
+          <field field_ref="PPNEWN"   />
+          <field field_ref="PPNEWD"   />
+          <field field_ref="PBSi"     />
+          <field field_ref="PFeN"     />
+          <field field_ref="PFeD"     />
+          <field field_ref="xfracal"  />
+          <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="Oflx"     />
+          <field field_ref="Kg"       />
+          <field field_ref="Dpco2"    />
+          <field field_ref="Dpo2"     />
+          <field field_ref="Heup"     />
+          <field field_ref="Irondep"  />
+          <field field_ref="Ironsed"  />
+          <field field_ref="Ironice"  />
+          <field field_ref="Nfix"     />
+          <field field_ref="MuN"      />
+          <field field_ref="MuD"      />
+          <field field_ref="LNnut"    />
+          <field field_ref="LDnut"    />
+          <field field_ref="LNFe"     />
+          <field field_ref="LDFe"     />
+          <field field_ref="LNlight"  />
+          <field field_ref="LDlight"  />
+          <field field_ref="pdust"    />
+          <field field_ref="Fe2"      />
+          <field field_ref="Fe3"      />
+          <field field_ref="FeL1"     />
+          <field field_ref="FeL2"     />
+          <field field_ref="FeP"      />
+          <field field_ref="TL1"      />
+          <field field_ref="TL2"      />
+          <field field_ref="Sdenit"   />
+          <field field_ref="Totlig"   />
+	</file>
+
+      </file_group>
+
+      <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>
+
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+   <axis_definition>  
+      <axis id="deptht"  long_name="Vertical T levels"  unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels"  unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels"  unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels"  unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"       unit="1"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"       unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"              />
+   </axis_definition> 
+    
+   <domain_definition src="./domain_def.xml"/>
+   
+   <grid_definition>    
+     <grid id="grid_T_2D" domain_ref="grid_T"/>
+     <grid id="grid_T_3D" domain_ref="grid_T" axis_ref="deptht"/>
+     <grid id="grid_U_2D" domain_ref="grid_U"/>
+     <grid id="grid_U_3D" domain_ref="grid_U" axis_ref="depthu"/>
+     <grid id="grid_V_2D" domain_ref="grid_V"/>
+     <grid id="grid_V_3D" domain_ref="grid_V" axis_ref="depthv"/>
+     <grid id="grid_W_2D" domain_ref="grid_W"/>
+     <grid id="grid_W_3D" domain_ref="grid_W" axis_ref="depthw"/>
+    </grid_definition>  
+  
+  </context>
+  
+
+  <context id="xios">
+
+      <variable_definition>
+	
+     <!-- 
+        We must have buffer_size > jpi*jpj*jpk*8 (with jpi and jpj the subdomain size)
+-->
+	  <variable id="buffer_size"               type="integer">50000000</variable>
+	  <variable id="buffer_server_factor_size" type="integer">2</variable>
+	  <variable id="info_level"                type="integer">0</variable>
+	  <variable id="using_server"              type="boolean">false</variable>
+	  <variable id="using_oasis"               type="boolean">false</variable>
+	  <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+	
+      </variable_definition>
+               
+  </context>
+  
+</simulation>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/GYRE/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/GYRE/namelist_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/GYRE/namelist_cfg	(revision 6041)
@@ -0,0 +1,375 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  : GYRE_PISCES Configuration namelist to overwrite reference dynamical namelist
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  'GYRE_trust'		 !  experience name
+   nn_it000    =       1   		 !  first time step
+   nn_itend    =     120   		 !  last  time step
+   nn_stock    =      60   		 !  frequency of creation of a restart file (modulo referenced to 1)
+/
+!-----------------------------------------------------------------------
+&namcfg     !   parameters of the configuration   
+!-----------------------------------------------------------------------
+   cp_cfg      =  "gyre"                 !  name of the configuration
+   jp_cfg      =       1                 !  resolution of the configuration
+   jpidta      =      32                 !  1st lateral dimension ( >= jpi ) = 30*jp_cfg+2
+   jpjdta      =      22                 !  2nd    "         "    ( >= jpj ) = 20*jp_cfg+2 
+   jpkdta      =      31                 !  number of levels      ( >= jpk )
+   jpiglo      =      32                 !  1st dimension of global domain --> i  = jpidta
+   jpjglo      =      22                 !  2nd    -                  -    --> j  = jpjdta
+   jpizoom     =       1                 !  left bottom (i,j) indices of the zoom
+   jpjzoom     =       1                 !  in data domain indices
+   jperio      =       0                 !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+   ln_zco      = .true.    !  z-coordinate - full    steps   (T/F)      ("key_zco" may also be defined)
+   ln_zps      = .false.   !  z-coordinate - partial steps   (T/F)
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_bathy    =    0      !  compute (=0) or read (=1) the bathymetry file
+   rn_rdt      = 7200.     !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_rdtmin   = 7200.           !  minimum time step on tracers (used if nn_acc=1)
+   rn_rdtmax   = 7200.           !  maximum time step on tracers (used if nn_acc=1)
+   jphgr_msh   =       5                 !  type of horizontal mesh
+   ppglam0     =       0.0               !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =      29.0               ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0               !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0               !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0               !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0               !  meridional grid-spacing (degrees)
+   ppsur       =   -2033.194295283385    !  ORCA r4, r2 and r05 coefficients
+   ppa0        =     155.8325369664153   ! (default coefficients)
+   ppa1        =     146.3615918601890   !
+   ppkth       =      17.28520372419791  !
+   ppacr       =       5.0               !
+   ppdzmin     =  999999.0               !  Minimum vertical spacing
+   pphmax      =  999999.0               !  Maximum depth
+   ldbletanh   =  .FALSE.                !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.0               !  Double tanh function parameters
+   ppkth2      =  999999.0               !
+   ppacr2      =  999999.0               !
+/
+!-----------------------------------------------------------------------
+&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+   cn_dir        = './'      !  root directory for the location of the runoff files
+   ln_tsd_init   = .false.   !  Initialisation of ocean T & S with T &S input data (T) or not (F)
+   ln_tsd_tradmp = .false.   !  damping of ocean T & S toward T &S input data (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 1         !  frequency of surface boundary condition computation
+   !                       !     (also = the frequency of sea-ice model call)
+   ln_ana      = .true.    !  analytical formulation                    (T => fill namsbc_ana )
+   ln_blk_core = .false.   !  CORE bulk formulation                     (T => fill namsbc_core)
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+   ln_rnf      = .false.   !  runoffs                                   (T => fill namsbc_rnf)
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+/
+!-----------------------------------------------------------------------
+&namsbc_ana    !   analytical surface boundary condition
+!-----------------------------------------------------------------------
+   nn_tau000   =   100     !  gently increase the stress over the first ntau_rst time-steps
+   rn_utau0    =   0.1e0   !  uniform value for the i-stress
+/
+!-----------------------------------------------------------------------
+&namsbc_flx    !   surface boundary condition : flux formulation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_clio   !   namsbc_clio  CLIO bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_mfs   !   namsbc_mfs  MFS bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_cpl    !   coupled ocean/atmosphere model                       ("key_oasis3")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   ln_qsr_rgb  = .false.   !  RGB (Red-Green-Blue) light penetration
+   ln_qsr_2bd  = .true.    !  2 bands              light penetration
+   nn_chldta   =      0    !  RGB : Chl data (=1) or cst value (=0)
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+   ln_rnf_mouth = .false.   !  specific treatment at rivers mouths
+/
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+   nn_sssr     =     0     !  add a damping     term in the surface freshwater flux (=2)
+   rn_deds     =   -27.7   !  magnitude of the damping on salinity   [mm/day]
+   ln_sssr_bnd =   .false. !  flag to bound erp term (associated with nn_sssr=2)
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.     !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobc        !   open boundaries parameters                           ("key_obc")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_tide      !    tide parameters (#ifdef key_tide)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambdy        !  unstructured open boundaries                          ("key_bdy")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambdy_dta      !  open boundaries - external data           ("key_bdy")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambdy_tide     ! tidal forcing at open boundaries
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   ln_trabbc   = .false.   !  Apply a geothermal heating at the ocean bottom
+   nn_geoflx   =    0      !  geothermal heat flux: = 0 no flux
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+   nn_eos      =  0       !  type of equation of state and Brunt-Vaisala frequency
+                                 !  =-1, TEOS-10 
+                                 !  = 0, EOS-80 
+                                 !  = 1, S-EOS   (simplified eos)
+   ln_useCT    = .false.  ! use of Conservative Temp. ==> surface CT converted in Pot. Temp. in sbcssm
+   !                             !
+   !                      ! S-EOS coefficients :
+   !                             !  rd(T,S,Z)*rau0 = -a0*(1+.5*lambda*dT+mu*Z+nu*dS)*dT+b0*dS
+   rn_a0       =  1.6550e-1      !  thermal expension coefficient (nn_eos= 1)
+   rn_b0       =  7.6554e-1      !  saline  expension coefficient (nn_eos= 1)
+   rn_lambda1  =  5.9520e-2      !  cabbeling coeff in T^2  (=0 for linear eos)
+   rn_lambda2  =  7.4914e-4      !  cabbeling coeff in S^2  (=0 for linear eos)
+   rn_mu1      =  1.4970e-4      !  thermobaric coeff. in T (=0 for linear eos)
+   rn_mu2      =  1.1090e-5      !  thermobaric coeff. in S (=0 for linear eos)
+   rn_nu       =  2.4341e-3      !  cabbeling coeff in T*S  (=0 for linear eos)
+!!org GYRE   rn_alpha    =   2.0e-4  !  thermal expension coefficient (nn_eos= 1 or 2)
+!!org GYRE   rn_beta     =   7.7e-4  !  saline  expension coefficient (nn_eos= 2)
+!!org  caution  now a0 = alpha / rau0   with rau0 = 1026
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_cen2   =  .false.   !  2nd order centered scheme
+   ln_traadv_tvd    =  .true.    !  TVD scheme
+   ln_traadv_muscl  =  .false.   !  MUSCL scheme
+   ln_traadv_muscl2 =  .false.   !  MUSCL2 scheme + cen2 at boundaries
+   ln_traadv_ubs    =  .false.   !  UBS scheme
+   ln_traadv_qck    =  .false.   !  QUICKEST scheme
+   ln_traadv_msc_ups=  .false.   !  use upstream scheme within muscl
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]
+   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .false.  !  add a damping termn (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+   ln_dynvor_ene = .true.  !  energy    conserving scheme  
+   ln_dynvor_ens = .false. !  enstrophy conserving scheme    
+   ln_dynvor_een = .false. !  energy & enstrophy scheme
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zco  = .true.    !  z-coordinate - full steps
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+/
+!-----------------------------------------------------------------------
+!namdyn_spg    !   surface pressure gradient   (CPP key only)
+!-----------------------------------------------------------------------
+
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+   rn_ahm_0_lap     = 100000.   !  horizontal laplacian eddy viscosity   [m2/s]
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+   nn_evdm     =    1      !  evd apply on tracer (=0) or on tracer and momentum (=1)
+/
+!-----------------------------------------------------------------------
+&namzdf_ric    !   richardson number dependent vertical diffusion       ("key_zdfric" )
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+   nn_etau     =   0       !  penetration of tke below the mixed layer (ML) due to internal & intertial waves
+/
+!------------------------------------------------------------------------
+&namzdf_kpp    !   K-Profile Parameterization dependent vertical mixing  ("key_zdfkpp", and optionally:
+!------------------------------------------------------------------------ "key_kppcustom" or "key_kpplktb")
+/
+!-----------------------------------------------------------------------
+&namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   ln_tmx_itf  = .false.   !  ITF specific parameterisation
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
+!-----------------------------------------------------------------------
+   nn_solv     =      2    !  elliptic solver: =1 preconditioned conjugate gradient (pcg)
+   nn_nmin     =    210    !  minimum of iterations for the SOR solver
+   rn_sor      =  1.96     !  optimal coefficient for SOR solver (to be adjusted with the domain)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namnc4        !   netcdf4 chunking and compression settings            ("key_netcdf4")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends         ("key_trddyn" and/or "key_trdtra")
+!              !       or mixed-layer trends or barotropic vorticity    ("key_trdmld" or     "key_trdvor")
+!-----------------------------------------------------------------------
+   ln_glo_trd  = .false.   ! (T) global domain averaged diag for T, T^2, KE, and PE
+   ln_dyn_trd  = .false.   ! (T) 3D momentum trend output
+   ln_dyn_mxl  = .FALSE.   ! (T) 2D momentum trends averaged over the mixed layer (not coded yet)
+   ln_vor_trd  = .FALSE.   ! (T) 2D barotropic vorticity trends (not coded yet)
+   ln_KE_trd   = .false.   ! (T) 3D Kinetic   Energy     trends
+   ln_PE_trd   = .false.   ! (T) 3D Potential Energy     trends
+   ln_tra_trd  = .false.    ! (T) 3D tracer trend output
+   ln_tra_mxl  = .false.   ! (T) 2D tracer trends averaged over the mixed layer (not coded yet)
+   nn_trd      = 365       !  print frequency (ln_glo_trd=T) (unit=time step)
+/
+!!gm   nn_ctls     =   0       !  control surface type in mixed-layer trends (0,1 or n<jpk)
+!!gm   rn_ucf      =   1.      !  unit conversion factor (=1 -> /seconds ; =86400. -> /day)
+!!gm   cn_trdrst_in      = "restart_mld"   ! suffix of ocean restart name (input)
+!!gm   cn_trdrst_out     = "restart_mld"   ! suffix of ocean restart name (output)
+!!gm   ln_trdmld_restart = .false.         !  restart for ML diagnostics
+!!gm   ln_trdmld_instant = .false.         !  flag to diagnose trends of instantantaneous or mean ML T/S
+!!gm
+!-----------------------------------------------------------------------
+&namflo       !   float parameters                                      ("key_float")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdct        ! transports through sections
+!-----------------------------------------------------------------------
+    nn_dct      = 60       !  time step frequency for transports computing
+    nn_dctwri   = 60       !  time step frequency for transports writing
+    nn_secdebug = 0        !      0 : no section to debug
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage switch                               ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_wave   ! External fields from wave model
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+   ln_neptramp       = .false.  ! ramp down Neptune velocity in shallow water
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA1_LIM3_PISCES/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA1_LIM3_PISCES/namelist_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA1_LIM3_PISCES/namelist_cfg	(revision 6041)
@@ -0,0 +1,331 @@
+
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  "O1L3P_trust"        !  experience name
+   nn_itend    =     240               !  last  time step (std 5475)
+   nn_euler    =       0               !  = 0 : start with forward time step if ln_rstart=T
+   nn_stock    =     120               !  frequency of creation of a restart file (modulo referenced to 1)
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "orca"               !  name of the configuration
+   jp_cfg      =       1               !  resolution of the configuration
+   jpidta      =     362               !  1st lateral dimension ( >= jpi )
+!   jpjdta      =     292               !  2nd    "         "    ( >= jpj )
+   jpjdta      =     332               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      75               !  number of levels      ( >= jpk )
+   jpiglo      =     362               !  1st dimension of global domain --> i =jpidta
+!   jpjglo      =     292               !  2nd    -                  -    --> j  =jpjdta
+   jpjglo      =     332               !  2nd    -                  -    --> j  =jpjdta
+   jperio      =       6               !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzgr_sco    !   s-coordinate or hybrid z-s-coordinate
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   jphgr_msh   =       0               !  type of horizontal mesh
+   ppglam0     =  999999.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =  999999.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0             !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0             !  meridional grid-spacing (degrees)
+   ppsur       =   -3958.951371276829  !  ORCA r4, r2 and r05 coefficients
+   ppa0        =     103.9530096000000 ! (default coefficients)
+   ppa1        =       2.415951269000000   !
+   ppkth       =      15.35101370000000    !
+   ppacr       =       7.0             !
+   ppdzmin     =  999999.0             !  Minimum vertical spacing
+   pphmax      =  999999.0             !  Maximum depth
+   ppa2        =     100.7609285000000 !  Double tanh function parameters
+   ppkth2      =      48.02989372000000    !
+   ppacr2      =      13.00000000000   !
+   rn_rdt      =    3600.              !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_hmin     =   20. 
+   nn_msh      =       0               !  create (=1) a mesh file or not (=0)
+/
+!-----------------------------------------------------------------------
+&namsplit       
+!----------------------------------------------------------------------- 
+   ln_bt_fw      =    .TRUE.           !  Forward integration of barotropic equations
+   ln_bt_av      =    .TRUE.           !  Time filtering of barotropic variables
+   ln_bt_nn_auto =    .TRUE.           !  Set nn_baro automatically to be just below
+                                       !  a user defined maximum courant number (rn_bt_cmax)
+   nn_baro       =    30               !  Number of iterations of barotropic mode
+                                       !  during rn_rdt seconds. Only used if ln_bt_nn_auto=F
+   rn_bt_cmax    =    0.8              !  Maximum courant number allowed if ln_bt_nn_auto=T 
+   nn_bt_flt     =    1                !  Time filter choice
+                                       !  = 0 None
+                                       !  = 1 Boxcar over   nn_baro barotropic steps
+                                       !  = 2 Boxcar over 2*nn_baro     "        
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+   ln_tsd_tradmp = .false.  !  damping of ocean T & S toward T &S input data (T) or not (F)
+   sn_tem  = 'conservative_temperature_WOA13_decav_Reg1L75_clim', -1 ,'votemper' , .true. , .true. , 'yearly' , 'weights_3D_WOA13d1_2_eorca1_bilinear.nc'  ,   ''    ,    ''
+   sn_sal  = 'absolute_salinity_WOA13_decav_Reg1L75_clim'       , -1 ,'vosaline' , .true. , .true. , 'yearly' , 'weights_3D_WOA13d1_2_eorca1_bilinear.nc'  ,   ''    ,    ''
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fsbc     = 3         !  frequency of surface boundary condition computation
+   nn_ice_embd = 1         ! embedded sea-ice (full salt and mass exchanges and pressure)
+   ln_dm2dc    = .true.    !  Daily mean to diurnal cycle on short wave
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked
+   ln_rnf      = .true.    !  runoffs                                   (T   => fill namsbc_rnf)
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+!              !   file name                  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights              ! rotation !
+!              !                              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename             ! pairing  !
+   sn_wndi     = 'u_10.15JUNE2009_fill'       ,         6         , 'U_10_MOD',   .true.     ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bicubic.nc'  , 'U1'
+   sn_wndj     = 'v_10.15JUNE2009_fill'       ,         6         , 'V_10_MOD',   .true.     ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bicubic.nc'  , 'V1'
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'   ,        24         , 'SWDN_MOD',   .false.    ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bilinear.nc' , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'   ,        24         , 'LWDN_MOD',   .true.     ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bilinear.nc' , ''
+   sn_tair     = 't_10.15JUNE2009_fill'       ,         6         , 'T_10_MOD',   .false.    ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bilinear.nc' , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'       ,         6         , 'Q_10_MOD',   .false.    ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bilinear.nc' , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill',        -1         , 'PRC_MOD1',   .true.     ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bilinear.nc' , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill',        -1         , 'SNOW'    ,   .true.     ,  .true. , 'yearly'  , 'weights_coreII_2_eorca1_bilinear.nc' , ''
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+   sn_chl      ='merged_ESACCI_BIOMER4V1R1_CHL_REG05',  -1  , 'CHLA' , .true. , .true. , 'yearly' , 'weights_reg05_2_eorca1_bilinear.nc' , '' , ''
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+!              !  file name           ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !                      !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  ! filename      !
+   sn_rnf      = 'eORCA_R1_runoff_clim_v1.0_nomask',        -1         , 'sorunoff',   .true.     , .true. , 'yearly'  , ''       , ''       , ''
+   sn_cnf      = 'eORCA_R1_runoff_clim_v1.0_nomask',         0         , 'socoeff' ,   .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'  , ''       , ''       , ''
+
+   ln_rnf_mouth = .false.    !  specific treatment at rivers mouths
+   ln_rnf_depth = .false.    !  read in depth information for runoff
+   ln_rnf_tem   = .false.    !  read in temperature information for runoff
+   ln_rnf_sal   = .false.    !  read in salinity information for runoff
+   ln_rnf_depth_ini = .true. !  compute depth at initialisation from runoff file
+   rn_rnf_max   = 0.05       !  max value of the runoff climatology over global domain ( if ln_rnf_depth_ini = .true )
+   rn_dep_max = 150.         !  depth over which runoffs is spread ( ln_rnf_depth_ini = .true )
+   nn_rnf_depth_file = 1     ! create (=1) a runoff depth file or not (=0)
+/
+!-----------------------------------------------------------------------
+&namsbc_apr    !   Atmospheric pressure used as ocean forcing or in bulk
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+!              !   file name  ! frequency (hours) ! variable   ! time interpol. !  clim   ! 'yearly'/ ! weights  ! rotation !
+!              !              !  (if <0  months)  !   name     !    (logical)   !  (T/F)  ! 'monthly' ! filename ! pairing  !
+   sn_sss      = 'sss_absolute_salinity_WOA13_decav_Reg1L75_clim', -1. , 'sosaline', .true. , .true. , 'yearly' , 'weights_WOA13d1_2_eorca1_bilinear.nc' , ''
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters
+!-----------------------------------------------------------------------
+      ln_icebergs              = .false.
+      ln_bergdia               = .false.              ! Calculate budgets
+      nn_verbose_level         = 0                    ! Turn on more verbose output if level > 0
+      nn_verbose_write         = 120                  ! Timesteps between verbose messages
+      nn_sample_rate           = 1                    ! Timesteps between sampling for trajectory storage
+                                                      ! Initial mass required for an iceberg of each class
+      rn_initial_mass          = 8.8e7, 4.1e8, 3.3e9, 1.8e10, 3.8e10, 7.5e10, 1.2e11, 2.2e11, 3.9e11, 7.4e11
+                                                      ! Proportion of calving mass to apportion to each class  
+      rn_distribution          = 0.24, 0.12, 0.15, 0.18, 0.12, 0.07, 0.03, 0.03, 0.03, 0.02
+                                                      ! Ratio between effective and real iceberg mass (non-dim)
+                                                      ! i.e. number of icebergs represented at a point         
+      rn_mass_scaling          = 2000, 200, 50, 20, 10, 5, 2, 1, 1, 1
+                                                      ! thickness of newly calved bergs (m)
+      rn_initial_thickness     = 40., 67., 133., 175., 250., 250., 250., 250., 250., 250.
+      rn_rho_bergs             = 850.                 ! Density of icebergs
+      rn_LoW_ratio             = 1.5                  ! Initial ratio L/W for newly calved icebergs
+      ln_operator_splitting    = .true.               ! Use first order operator splitting for thermodynamics
+      rn_bits_erosion_fraction = 0.                   ! Fraction of erosion melt flux to divert to bergy bits
+      rn_sicn_shift            = 0.                   ! Shift of sea-ice concn in erosion flux (0<sicn_shift<1)
+      ln_passive_mode          = .false.              ! iceberg - ocean decoupling   
+      nn_test_icebergs         =   8                  ! Create test icebergs of this class (-1 = no)
+                                                      ! Put a test iceberg at each gridpoint in box (lon1,lon2,lat1,lat2)
+      !rn_test_box              = 108.0,  116.0, -66.0, -58.0
+      rn_test_box              = -180.0,  180.0,  70.0,  90.0     !
+      rn_speed_limit           = 0.                   ! CFL speed limit for a berg   
+
+!              ! file name ! frequency (hours) !   variable   ! time interp.   !  clim   ! 'yearly'/ ! weights  ! rotation ! land/sea mask !
+!              !           !  (if <0  months)  !     name     !   (logical)    !  (T/F ) ! 'monthly' ! filename ! pairing  ! filename      !
+      sn_icb =  'calving' ,       -1           , 'calvingmask',  .true.        , .true.  , 'yearly'  , ''       , ''       , ''
+   
+      cn_dir = './' 
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+   rn_shlat    =    0.0    !  shlat = 0  !  0 < shlat < 2  !  shlat = 2  !  2 < shlat
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+   nn_bfr      =    2      !  type of bottom friction :   = 0 : free slip,  = 1 : linear friction
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+   sn_qgh      ='Goutorbe_ghflux.nc',  -12.  , 'gh_flux'    ,   .false.     , .true. , 'yearly'  , 'weights_Goutorbe1_2_eorca1_bilinear.nc'       , ''       , ''
+   !
+   cn_dir      = './'      !  root directory for the location of the runoff files
+   nn_geoflx   =    2      !  geothermal heat flux: = 0 no flux
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+   ln_traadv_tvd    =  .true.   !  TVD scheme
+   ln_traadv_ubs    =  .false.  !  UBS scheme
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+   ln_traldf_grif   =  .false.   !  griffies skew flux formulation       (require "key_ldfslp")
+   ln_traldf_gdia   =  .false.   !  griffies operator strfn diagnostics  (require "key_ldfslp")
+   ln_botmix_grif   =  .false.   !  griffies operator with lateral mixing on bottom (require "key_ldfslp")
+   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+   rn_aeiv_0        =  1000.    !  eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .false.  !  add a damping termn (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+   ln_dynadv_vec = .true.  !  vector form (T) or flux form (F)
+   ln_dynadv_cen2= .false. !  flux form - 2nd order centered scheme
+   ln_dynadv_ubs = .false. !  flux form - 3rd order UBS      scheme
+   nn_dynkeg     = 1       !  scheme for grad(KE): =0  C2  ; =1  Hollingsworth correction
+/
+!-----------------------------------------------------------------------
+&nam_vvl    !   vertical coordinate options
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+   ln_hpg_zps  = .false.   !  z-coordinate - partial steps (interpolation)
+   ln_hpg_sco  = .true.    !  s-coordinate (standard jacobian formulation)
+   !ln_hpg_isf  = .true.    !  s-coordinate (sco ) adapted to isf
+   ln_dynhpg_imp = .false. !  time stepping: semi-implicit time scheme  (T)
+                           !           centered      time scheme  (F)
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+   rn_ahm_0_lap     = 20000.    !  horizontal laplacian eddy viscosity   [m2/s]
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
+!-----------------------------------------------------------------------
+   nn_solv     =       2               !  elliptic solver: =2 successive-over-relaxation (sor)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!----------------------------------------------------------------------- 
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+   ln_diahsb  = .true.  
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_vvl    !   vertical coordinate options
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_gls                !   GLS vertical diffusion                   ("key_zdfgls")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends
+!              !       and/or mixed-layer trends and/or barotropic vorticity
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsto       ! Stochastic parametrization of EOS
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA1_LIM3_PISCES/namelist_ice_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA1_LIM3_PISCES/namelist_ice_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA1_LIM3_PISCES/namelist_ice_cfg	(revision 6041)
@@ -0,0 +1,42 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/LIM-3 : Ice configuration namelist. Overwrites SHARED/namelist_ice_lim3_ref
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+
+!-----------------------------------------------------------------------
+&namicerun     !   Share parameters for dynamics/advection/thermo
+!-----------------------------------------------------------------------
+   ln_limdiahsb  = .false.         !  check the heat and salt budgets (T) or not (F)
+   ln_limdiaout  = .false.          !  output the heat and salt budgets (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namiceini     !   ice initialisation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namicedyn     !   ice dynamic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namicethd     !   ice thermodynamic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namicesal     !   ice salinity
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namiceitdme   !   parameters for mechanical redistribution of ice 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namicedia     !   ice diagnostics
+!-----------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namiceitd     !   Ice discretization
+!------------------------------------------------------------------------------
+/
+!------------------------------------------------------------------------------
+&namicehdf     !   Ice horizontal diffusion
+!------------------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM/1_namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM/1_namelist_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM/1_namelist_cfg	(revision 6041)
@@ -0,0 +1,228 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  :  Configuration namelist used to overwrite SHARED/1_namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =   "O2LA_trust"        !  experience name 
+   nn_itend    =     300  	       !  last  time step
+   nn_stock    =     150               !  frequency of creation of a restart file (modulo referenced to 1)
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "default"             !  name of the configuration
+   jp_cfg      =      -1               !  resolution of the configuration
+   jpidta      =     182               !  1st lateral dimension ( >= jpi )
+   jpjdta      =     149               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      31               !  number of levels      ( >= jpk )
+   jpiglo      =     182               !  1st dimension of global domain --> i =jpidta
+   jpjglo      =     149               !  2nd    -                  -    --> j  =jpjdta
+   jpizoom     =       1               !  left bottom (i,j) indices of the zoom
+   jpjzoom     =       1               !  in data domain indices
+   jperio      =       0               !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------  
+   nn_msh      =       0               !  create (=1) a mesh file or not (=0)
+   jphgr_msh   =       0               !  type of horizontal mesh
+   ppglam0     =  999999.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =  999999.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0             !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0             !  meridional grid-spacing (degrees)
+   ppsur       =   -4762.96143546300   !  ORCA r4, r2 and r05 coefficients
+   ppa0        =     255.58049070440   ! (default coefficients)
+   ppa1        =     245.58132232490   !
+   ppkth       =      21.43336197938   !
+   ppacr       =       3.0             !
+   ppdzmin     =  999999.              !  Minimum vertical spacing
+   pphmax      =  999999.              !  Maximum depth
+   ldbletanh   =  .FALSE.              !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.              !  Double tanh function parameters
+   ppkth2      =  999999.              !
+   ppacr2      =  999999.              !
+   rn_rdt      = 2880.     !  time step for the dynamics (and tracer if nn_acc=0)
+   rn_rdtmin   = 14400.          !  minimum time step on tracers (used if nn_acc=1)
+   rn_rdtmax   = 14400.          !  maximum time step on tracers (used if nn_acc=1)
+/
+!-----------------------------------------------------------------------
+&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_ice      = 0         !  =0 no ice boundary condition   ,
+                           !  =1 use observed ice-cover      ,
+                           !  =2 ice-model used                         ("key_lim3" or "key_lim2)
+   ln_rnf      = .false.   !  runoffs                                   (T => fill namsbc_rnf)
+   ln_ssr      = .false.   !  Sea Surface Restoring on T and/or S       (T => fill namsbc_ssr)
+   nn_fwb      = 0         !  FreshWater Budget: =0 unchecked 
+                           !     =1 global mean of e-p-r set to zero at each time step 
+                           !     =2 annual global mean of e-p-r set to zero
+                           !     =3 global emp set to zero and spread out over erp area
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+!              !  file name                    ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights                               ! rotation ! land/sea mask !
+!              !                               !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename                              ! pairing  ! filename      !
+   sn_wndi     = 'u_10.15JUNE2009_fill'        ,         6         , 'U_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bicubic.nc'      , 'Uwnd'   , ''
+   sn_wndj     = 'v_10.15JUNE2009_fill'        ,         6         , 'V_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bicubic.nc'      , 'Vwnd'   , ''
+   sn_qsr      = 'ncar_rad.15JUNE2009_fill'    ,        24         , 'SWDN_MOD',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+   sn_qlw      = 'ncar_rad.15JUNE2009_fill'    ,        24         , 'LWDN_MOD',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+   sn_tair     = 't_10.15JUNE2009_fill'        ,         6         , 'T_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+   sn_humi     = 'q_10.15JUNE2009_fill'        ,         6         , 'Q_10_MOD',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+   sn_prec     = 'ncar_precip.15JUNE2009_fill' ,        -1         , 'PRC_MOD1',   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+   sn_snow     = 'ncar_precip.15JUNE2009_fill' ,        -1         , 'SNOW'    ,   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+   sn_tdif     = 'taudif_core'                 ,        24         , 'taudif'  ,   .false.    , .true. , 'yearly'  , 'weights_core2_agrif_bilinear.nc'     , ''       , ''
+
+   cn_dir      = './'      !  root directory for the location of the bulk files
+   ln_taudif   = .false.   !  HF tau contribution: use "mean of stress module - module of the mean stress" data
+   rn_zqt      = 10.        !  Air temperature and humidity reference height (m)
+   rn_zu       = 10.        !  Wind vector reference height (m)
+   rn_pfac     = 1.        !  multiplicative factor for precipitation (total & snow)
+   rn_efac     = 1.        !  multiplicative factor for evaporation (0. or 1.)
+   rn_vfac     = 0.        !  multiplicative factor for ocean/ice velocity
+                           !  in the calculation of the wind stress (0.=absolute winds or 1.=relative winds)
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+!              !  file name  ! frequency (hours) ! variable  ! time interp. !  clim  ! 'yearly'/ ! weights  ! rotation !
+!              !             !  (if <0  months)  !   name    !   (logical)  !  (T/F) ! 'monthly' ! filename ! pairing  !
+   sn_chl      ='chlorophyll',        -1         , 'CHLA'    ,   .true.     , .true. , 'yearly'  , 'weights_bilin.nc'       , ''
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namagrif      !  AGRIF zoom                                            ("key_agrif")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+   ln_tradmp   =  .false.   !  add a damping termn (T) or not (F)
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers 
+!-----------------------------------------------------------------------
+
+   rn_aht_0         =  1000.    !  horizontal eddy diffusivity for tracers [m2/s]
+   rn_aeiv_0        =     0.    !  eddy induced velocity coefficient [m2/s]    (require "key_traldf_eiv")
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/  
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+   !                       !  Type of the operator : 
+   ln_dynldf_lap    =  .false.  !  laplacian operator         
+   ln_dynldf_bilap  =  .true.   !  bilaplacian operator    
+   rn_ahm_0_blp     = -8.5e+11  !  horizontal bilaplacian eddy viscosity [m4/s] 
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+   ln_tmx_itf  = .false.   !  ITF specific parameterisation
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nammpp_dyndist !   Massively Parallel Distribution for AGRIF zoom      ("key_agrif" && "key_mpp_dyndist")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage                                      ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM/namelist_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM/namelist_cfg	(revision 6041)
@@ -0,0 +1,203 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =   "O2LA_trust"        !  experience name 
+   nn_itend    =     150  	       !  last  time step
+   nn_stock    =      75               !  frequency of creation of a restart file (modulo referenced to 1)
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "orca"               !  name of the configuration
+   jp_cfg      =       2               !  resolution of the configuration
+   jpidta      =     182               !  1st lateral dimension ( >= jpi )
+   jpjdta      =     149               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      31               !  number of levels      ( >= jpk )
+   jpiglo      =     182               !  1st dimension of global domain --> i =jpidta
+   jpjglo      =     149               !  2nd    -                  -    --> j  =jpjdta
+   jpizoom     =       1               !  left bottom (i,j) indices of the zoom
+   jpjzoom     =       1               !  in data domain indices
+   jperio      =       4               !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_msh      =       0               !  create (=1) a mesh file or not (=0)
+   jphgr_msh   =       0               !  type of horizontal mesh
+   ppglam0     =  999999.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =  999999.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0             !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0             !  meridional grid-spacing (degrees)
+   ppsur       =   -4762.96143546300   !  ORCA r4, r2 and r05 coefficients
+   ppa0        =     255.58049070440   ! (default coefficients)
+   ppa1        =     245.58132232490   !
+   ppkth       =      21.43336197938   !
+   ppacr       =       3.0             !
+   ppdzmin     =  999999.              !  Minimum vertical spacing
+   pphmax      =  999999.              !  Maximum depth
+   ldbletanh   =  .FALSE.              !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.              !  Double tanh function parameters
+   ppkth2      =  999999.              !
+   ppacr2      =  999999.              !
+/
+!-----------------------------------------------------------------------
+&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fwb      =       0               !  FreshWater Budget: =0 unchecked
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
+!-----------------------------------------------------------------------
+   nn_solv     =      2    !  elliptic solver: =2 successive-over-relaxation (sor)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namobs       !  observation usage                                      ('key_diaobs')
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nam_asminc   !   assimilation increments                               ('key_asminc')
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/iodef.xml
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/iodef.xml	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/iodef.xml	(revision 6041)
@@ -0,0 +1,284 @@
+<?xml version="1.0"?>
+<simulation> 
+
+ <context id="nemo" time_origin="1900-01-01 00:00:00" >
+    
+    <!-- $id$ -->
+    
+    <!-- 
+============================================================================================================
+=                                  definition of all existing variables                                    =
+=                                            DO NOT CHANGE                                                 =
+============================================================================================================
+    -->
+    <field_definition src="./field_def.xml"/>
+    <!-- 
+============================================================================================================
+=                                           output files definition                                        =
+=                                            Define your own files                                         =
+=                                         put the variables you want...                                    =
+============================================================================================================
+    -->
+ 
+    
+    <file_definition type="one_file" name="@expname@_@freq@_@startdate@_@enddate@" sync_freq="10d" min_digits="4">
+    
+      <file_group id="1ts" output_freq="1ts"  output_level="10" enabled=".TRUE."/> <!-- 1 time step files -->
+      <file_group id="1h" output_freq="1h"  output_level="10" enabled=".TRUE."/> <!-- 1h files -->
+      <file_group id="2h" output_freq="2h"  output_level="10" enabled=".TRUE."/> <!-- 2h files -->
+      <file_group id="3h" output_freq="3h"  output_level="10" enabled=".TRUE."/> <!-- 3h files -->     
+      <file_group id="4h" output_freq="4h"  output_level="10" enabled=".TRUE."/> <!-- 4h files -->
+      <file_group id="6h" output_freq="6h"  output_level="10" enabled=".TRUE."/> <!-- 6h files -->
+     
+      <file_group id="1d" output_freq="1d"  output_level="10" enabled=".TRUE."> <!-- 1d files -->
+
+	<file id="file1" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="sst"          name="tos" />
+	  <field field_ref="sss"          name="sos" />
+	  <field field_ref="ssh"          name="zos" />
+	</file>
+
+	<file id="file2" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="ssu"          name="uos" />
+	</file>
+	
+	<file id="file3" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="ssv"          name="vos" />
+	</file>
+
+        <file id="file4" 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="3d" output_freq="3d"  output_level="10" enabled=".TRUE."/> <!-- 3d files -->    
+
+      <file_group id="5d" output_freq="5d"  output_level="10" enabled=".TRUE.">  <!-- 5d files -->   
+
+	<file id="file5" name_suffix="_grid_T" description="ocean T grid variables" >
+	  <field field_ref="toce"         name="thetao" />
+	  <field field_ref="soce"         name="so"     />
+	  <field field_ref="sst"          name="tos"    />
+	  <field field_ref="sst2"         name="tossq"  />
+	  <field field_ref="sss"          name="sos"    />
+	  <field field_ref="ssh"          name="zos"    />
+	  <field field_ref="ssh2"         name="zossq"  />
+	  <field field_ref="empmr"        name="wfo"    />
+	  <field field_ref="qsr"          name="rsntds" />
+	  <field field_ref="qt"           name="tohfls" />
+	  <field field_ref="taum"     />
+	  <field field_ref="mldkz5"   />
+	  <field field_ref="mldr10_1" />
+	</file>
+	
+	<file id="file6" name_suffix="_grid_U" description="ocean U grid variables" >
+	  <field field_ref="uoce"         name="uo"     />
+	  <field field_ref="ssu"          name="uos"    />
+	  <field field_ref="utau"         name="tauuo"  />
+	</file>
+	
+	<file id="file7" name_suffix="_grid_V" description="ocean V grid variables" >
+	  <field field_ref="voce"         name="vo"     />
+	  <field field_ref="ssv"          name="vos"    />
+	  <field field_ref="vtau"         name="tauvo"  />
+	</file>
+	
+	<file id="file8" name_suffix="_grid_W" description="ocean W grid variables" >
+	  <field field_ref="woce"         name="wo"     />
+	  <field field_ref="avt"          name="difvho" />
+	</file>
+	
+	<file id="file9" name_suffix="_icemod" description="ice variables" >
+	  <field field_ref="ice_pres"   />
+	  <field field_ref="snowthic_cea" name="snd"    />
+	  <field field_ref="icethic_cea"  name="sit"    />
+	  <field field_ref="iceprod_cea"  name="sip"    />
+	  <field field_ref="ist_ipa"    />
+	  <field field_ref="uice_ipa"   />
+	  <field field_ref="vice_ipa"   />
+	  <field field_ref="utau_ice"   />
+	  <field field_ref="vtau_ice"   />
+	  <field field_ref="qsr_io_cea" />
+	  <field field_ref="qns_io_cea" />
+	  <field field_ref="snowpre"    />
+	</file>
+	
+      </file_group>
+
+      <file_group id="1m" output_freq="1mo" output_level="10" enabled=".TRUE."> <!-- real monthly files -->
+
+	<file id="file10" 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="file11" name_suffix="_diad_T" description="additional pisces diagnostics" >
+          <field field_ref="Cflx"     />
+          <field field_ref="Dpco2"    />
+	</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 id="file12" 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="file13" name_suffix="_diad_T" description="additional pisces diagnostics" >
+          <field field_ref="PH"       />
+          <field field_ref="CO3"      />
+          <field field_ref="CO3sat"   />
+          <field field_ref="PAR"      />
+          <field field_ref="PPPHY"    />
+          <field field_ref="PPPHY2"   />
+          <field field_ref="PPNEWN"   />
+          <field field_ref="PPNEWD"   />
+          <field field_ref="PBSi"     />
+          <field field_ref="PFeN"     />
+          <field field_ref="PFeD"     />
+          <field field_ref="xfracal"  />
+          <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="Oflx"     />
+          <field field_ref="Kg"       />
+          <field field_ref="Dpco2"    />
+          <field field_ref="Dpo2"     />
+          <field field_ref="Heup"     />
+          <field field_ref="Irondep"  />
+          <field field_ref="Ironsed"  />
+          <field field_ref="Ironice"  />
+          <field field_ref="Nfix"     />
+          <field field_ref="MuN"      />
+          <field field_ref="MuD"      />
+          <field field_ref="LNnut"    />
+          <field field_ref="LDnut"    />
+          <field field_ref="LNFe"     />
+          <field field_ref="LDFe"     />
+          <field field_ref="LNlight"  />
+          <field field_ref="LDlight"  />
+          <field field_ref="pdust"    />
+          <field field_ref="Fe2"      />
+          <field field_ref="Fe3"      />
+          <field field_ref="FeL1"     />
+          <field field_ref="FeL2"     />
+          <field field_ref="FeP"      />
+          <field field_ref="TL1"      />
+          <field field_ref="TL2"      />
+          <field field_ref="Sdenit"   />
+          <field field_ref="Totlig"   />
+	</file>
+
+      </file_group>
+
+      <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>
+
+    <!-- 
+============================================================================================================
+= grid definition = = DO NOT CHANGE =
+============================================================================================================
+    -->
+    
+   <axis_definition>  
+      <axis id="deptht"  long_name="Vertical T levels"  unit="m" positive="down" />
+      <axis id="depthu"  long_name="Vertical U levels"  unit="m" positive="down" />
+      <axis id="depthv"  long_name="Vertical V levels"  unit="m" positive="down" />
+      <axis id="depthw"  long_name="Vertical W levels"  unit="m" positive="down" />
+      <axis id="nfloat"  long_name="Float number"       unit="1"                 />
+      <axis id="icbcla"  long_name="Iceberg class"      unit="1"                 />
+      <axis id="ncatice" long_name="Ice category"       unit="1"                 />
+      <axis id="iax_20C" long_name="20 degC isotherm"   unit="degC"              />
+      <axis id="iax_28C" long_name="28 degC isotherm"   unit="degC"              />
+   </axis_definition> 
+    
+   <domain_definition src="./domain_def.xml"/>
+   
+   <grid_definition>    
+     <grid id="grid_T_2D" domain_ref="grid_T"/>
+     <grid id="grid_T_3D" domain_ref="grid_T" axis_ref="deptht"/>
+     <grid id="grid_U_2D" domain_ref="grid_U"/>
+     <grid id="grid_U_3D" domain_ref="grid_U" axis_ref="depthu"/>
+     <grid id="grid_V_2D" domain_ref="grid_V"/>
+     <grid id="grid_V_3D" domain_ref="grid_V" axis_ref="depthv"/>
+     <grid id="grid_W_2D" domain_ref="grid_W"/>
+     <grid id="grid_W_3D" domain_ref="grid_W" axis_ref="depthw"/>
+    </grid_definition>  
+  
+  </context>
+  
+
+  <context id="xios">
+
+      <variable_definition>
+	
+     <!-- 
+        We must have buffer_size > jpi*jpj*jpk*8 (with jpi and jpj the subdomain size)
+-->
+	  <variable id="buffer_size"               type="integer">50000000</variable>
+	  <variable id="buffer_server_factor_size" type="integer">2</variable>
+	  <variable id="info_level"                type="integer">0</variable>
+	  <variable id="using_server"              type="boolean">false</variable>
+	  <variable id="using_oasis"               type="boolean">false</variable>
+	  <variable id="oasis_codes_id"            type="string" >oceanx</variable>
+	
+      </variable_definition>
+               
+  </context>
+  
+</simulation>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_cfg	(revision 6041)
@@ -0,0 +1,205 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/OPA  Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_ref
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!
+!-----------------------------------------------------------------------
+&namrun        !   parameters of the run
+!-----------------------------------------------------------------------
+   cn_exp      =  "O2LP_trust"         !  experience name
+   nn_itend    =     150               !  last  time step (std 5475)
+   nn_euler    =       0               !  = 0 : start with forward time step if ln_rstart=T
+   nn_stock    =      75               !  frequency of creation of a restart file (modulo referenced to 1)
+/
+!-----------------------------------------------------------------------
+&namcfg        !   parameters of the configuration
+!-----------------------------------------------------------------------
+   cp_cfg      =  "orca"               !  name of the configuration
+   jp_cfg      =       2               !  resolution of the configuration
+   jpidta      =     182               !  1st lateral dimension ( >= jpi )
+   jpjdta      =     149               !  2nd    "         "    ( >= jpj )
+   jpkdta      =      31               !  number of levels      ( >= jpk )
+   jpiglo      =     182               !  1st dimension of global domain --> i =jpidta
+   jpjglo      =     149               !  2nd    -                  -    --> j  =jpjdta
+   jpizoom     =       1               !  left bottom (i,j) indices of the zoom
+   jpjzoom     =       1               !  in data domain indices
+   jperio      =       4               !  lateral cond. type (between 0 and 6)
+/
+!-----------------------------------------------------------------------
+&namzgr        !   vertical coordinate
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdom        !   space and time domain (bathymetry, mesh, timestep)
+!-----------------------------------------------------------------------
+   nn_msh      =       0               !  create (=1) a mesh file or not (=0)
+   jphgr_msh   =       0               !  type of horizontal mesh
+   ppglam0     =  999999.0             !  longitude of first raw and column T-point (jphgr_msh = 1)
+   ppgphi0     =  999999.0             ! latitude  of first raw and column T-point (jphgr_msh = 1)
+   ppe1_deg    =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_deg    =  999999.0             !  meridional grid-spacing (degrees)
+   ppe1_m      =  999999.0             !  zonal      grid-spacing (degrees)
+   ppe2_m      =  999999.0             !  meridional grid-spacing (degrees)
+   ppsur       =   -4762.96143546300   !  ORCA r4, r2 and r05 coefficients
+   ppa0        =     255.58049070440   ! (default coefficients)
+   ppa1        =     245.58132232490   !
+   ppkth       =      21.43336197938   !
+   ppacr       =       3.0             !
+   ppdzmin     =  999999.              !  Minimum vertical spacing
+   pphmax      =  999999.              !  Maximum depth
+   ldbletanh   =  .FALSE.              !  Use/do not use double tanf function for vertical coordinates
+   ppa2        =  999999.              !  Double tanh function parameters
+   ppkth2      =  999999.              !
+   ppacr2      =  999999.              !
+/
+!-----------------------------------------------------------------------
+&namsplit      !   time splitting parameters                            ("key_dynspg_ts")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcrs        !   Grid coarsening for dynamics output and/or
+               !   passive tracer coarsened online simulations
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtsd    !   data : Temperature  & Salinity
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc        !   Surface Boundary Condition (surface module)
+!-----------------------------------------------------------------------
+   nn_fwb      =       0               !  FreshWater Budget: =0 unchecked
+/
+!-----------------------------------------------------------------------
+&namsbc_core   !   namsbc_core  CORE bulk formulae
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_qsr    !   penetrative solar radiation
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_rnf    !   runoffs namelist surface boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_ssr    !   surface boundary condition : sea surface restoring
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsbc_alb    !   albedo parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namberg       !   iceberg parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namlbc        !   lateral momentum boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namcla        !   cross land advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambfr        !   bottom friction
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambbc        !   bottom temperature boundary condition
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nambbl        !   bottom boundary layer scheme
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&nameos        !   ocean physical parameters
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv    !   advection scheme for tracer
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_adv_mle !  mixed layer eddy parametrisation (Fox-Kemper param)
+!-----------------------------------------------------------------------
+/
+!----------------------------------------------------------------------------------
+&namtra_ldf    !   lateral diffusion scheme for tracers
+!----------------------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtra_dmp    !   tracer: T & S newtonian damping
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_adv    !   formulation of the momentum advection
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_vor    !   option of physics/algorithm (not control by CPP keys)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_hpg    !   Hydrostatic pressure gradient option
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_ldf    !   lateral diffusion on momentum
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf        !   vertical physics
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tke    !   turbulent eddy kinetic dependent vertical diffusion  ("key_zdftke")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_ddm    !   double diffusive mixing parameterization             ("key_zdfddm")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namzdf_tmx    !   tidal mixing parameterization                        ("key_zdftmx")
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsol        !   elliptic solver / island / free surface
+!-----------------------------------------------------------------------
+   nn_solv     =       2               !  elliptic solver: =2 successive-over-relaxation (sor)
+/
+!-----------------------------------------------------------------------
+&nammpp        !   Massively Parallel Processing                        ("key_mpp_mpi)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namctl        !   Control prints & Benchmark
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namptr       !   Poleward Transport Diagnostic
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namhsb       !  Heat and salt budgets
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namdyn_nept  !   Neptune effect (simplified: lateral and vertical diffusions removed)
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namsto       ! Stochastic parametrization of EOS
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrd        !   diagnostics on dynamics and/or tracer trends
+!              !       and/or mixed-layer trends and/or barotropic vorticity
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_pisces_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_pisces_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_pisces_cfg	(revision 6041)
@@ -0,0 +1,72 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! PISCES  :   Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_pis_ref
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisext     !   air-sea exchange
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisatm     !  Atmospheric prrssure 
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_presatm  = .false.   ! constant atmopsheric pressure (F) or from a file (T)
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisbio     !   biological parameters
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampislim     !   parameters for nutrient limitations
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisopt     !   parameters for optics
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_varpar   =  .false.  ! boolean for PAR variable
+/ 
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisprod     !   parameters for phytoplankton growth
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismort     !   parameters for phytoplankton sinks
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismes     !   parameters for mesozooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiszoo     !   parameters for microzooplankton
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisfer     !   parameters for iron chemistry
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/  
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisrem     !   parameters for remineralization
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampiscal     !   parameters for Calcite chemistry
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampissbc     !   parameters for inputs deposition
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_dust     =  .false.  ! boolean for dust input from the atmosphere
+   ln_solub    =  .false.  ! boolean for variable solubility of atm. Iron
+   ln_river    =  .false.  ! boolean for river input of nutrients
+   ln_ndepo    =  .false.  ! boolean for atmospheric deposition of N
+   ln_ironsed  =  .false.  ! boolean for Fe input from sediments
+   ln_hydrofe  =  .false.  ! boolean for from hydrothermal vents
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampisdmp     !  Damping 
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+   ln_pisdmp   =  .false.  !  Relaxation fo some tracers to a mean value
+/
+!'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+&nampismass     !  Mass conservation
+!,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_top_cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_top_cfg	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/inputs/ORCA2_LIM_PISCES/namelist_top_cfg	(revision 6041)
@@ -0,0 +1,97 @@
+!!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!! NEMO/TOP1 :  Configuration namelist : used to overwrite defaults values defined in SHARED/namelist_top_ref
+!>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
+!-----------------------------------------------------------------------
+&namtrc_run     !   run information
+!-----------------------------------------------------------------------
+!   ln_top_euler  = .true.    !  use Euler time-stepping for TOP
+/
+!-----------------------------------------------------------------------
+&namtrc     !   tracers definition
+!-----------------------------------------------------------------------
+   ln_trcdta     =  .false.  !  Initialisation from data input file (T) or not (F)
+!                !    name   !           title of the field              ! initial data ! initial data ! save   !
+!                !           !                                           !  units       ! from file    ! or not ! 
+!                !           !                                           !              ! or not       !        !
+   sn_tracer(1)   = 'DIC     ' , 'Dissolved inorganic Concentration      ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(2)   = 'Alkalini' , 'Total Alkalinity Concentration         ',  'eq/L '   ,  .true.     ,  .true.
+   sn_tracer(3)   = 'O2      ' , 'Dissolved Oxygen Concentration         ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(4)   = 'CaCO3   ' , 'Calcite Concentration                  ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(5)   = 'PO4     ' , 'Phosphate Concentration                ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(6)   = 'POC     ' , 'Small organic carbon Concentration     ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(7)   = 'Si      ' , 'Silicate Concentration                 ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(8)   = 'PHY     ' , 'Nanophytoplankton Concentration        ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(9)   = 'ZOO     ' , 'Microzooplankton Concentration         ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(10)  = 'DOC     ' , 'Dissolved organic Concentration        ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(11)  = 'PHY2    ' , 'Diatoms Concentration                  ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(12)  = 'ZOO2    ' , 'Mesozooplankton Concentration          ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(13)  = 'DSi     ' , 'Diatoms Silicate Concentration         ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(14)  = 'Fer     ' , 'Dissolved Iron Concentration           ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(15)  = 'BFe     ' , 'Big iron particles Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(16)  = 'GOC     ' , 'Big organic carbon Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(17)  = 'SFe     ' , 'Small iron particles Concentration     ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(18)  = 'DFe     ' , 'Diatoms iron  Concentration            ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(19)  = 'GSi     ' , 'Sinking biogenic Silicate Concentration',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(20)  = 'NFe     ' , 'Nano iron Concentration                ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(21)  = 'NCHL    ' , 'Nano chlorophyl Concentration          ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(22)  = 'DCHL    ' , 'Diatoms chlorophyl Concentration       ',  'mol-C/L' ,  .false.    ,  .true.
+   sn_tracer(23)  = 'NO3     ' , 'Nitrates Concentration                 ',  'mol-C/L' ,  .true.     ,  .true.
+   sn_tracer(24)  = 'NH4     ' , 'Ammonium Concentration                 ',  'mol-C/L' ,  .false.    ,  .true.
+/
+!-----------------------------------------------------------------------
+&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 
+!-----------------------------------------------------------------------
+   ln_trcadv_tvd     =  .false.  !  TVD scheme
+   ln_trcadv_muscl   =  .true.   !  MUSCL scheme
+/
+!-----------------------------------------------------------------------
+&namtrc_ldf    !   lateral diffusion scheme for passive tracer 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_zdf        !   vertical physics
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_rad        !  treatment of negative concentrations 
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_dia       !   parameters for passive tracer additional diagnostics
+!----------------------------------------------------------------------
+   ln_diatrc     =  .false.   !  save additional diag. (T) or not (F)
+/
+!----------------------------------------------------------------------
+&namtrc_bc        !   data for boundary conditions
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_dmp    !   passive tracer newtonian damping   
+!-----------------------------------------------------------------------
+/
+!-----------------------------------------------------------------------
+&namtrc_ice       !    Representation of sea ice growth & melt effects
+!-----------------------------------------------------------------------
+/
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/install_new_branch.sh
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/install_new_branch.sh	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/install_new_branch.sh	(revision 6041)
@@ -0,0 +1,99 @@
+#!/bin/bash
+
+
+cd $( dirname $0 )
+
+## Set defaults
+##---------------------------------------------------
+TRUS_DBUG=0; TRUS_PROD=0; TRUS_HELP=0
+
+
+## Get options (for replacing initials settings)
+##---------------------------------------------------
+while [ $# -ne 0 ]; do
+    case $1 in
+	'-d'|'--debug'  ) TRUS_DBUG=1 ; shift  ;; '-j'|'--job' 	  ) TRUS_NPRO=$2; shift 2;;
+	'-m'|'--machine') TRUS_HPCC=$2; shift 2;; '-h'|'--help'	  ) TRUS_HELP=1 ; shift  ;;
+	'-u'|'--user'   ) TRUS_USER=$2; shift 2;; "*"             ) TRUS_HELP=1 ; shift  ;;
+    esac
+done
+
+
+## Initialization (HPC & user environment)
+##---------------------------------------------------
+if [[ ! -e config/${TRUS_USER}.cfg || ! -e config/${TRUS_HPCC}.cfg || ${TRUS_HELP} -eq 1 ]]; then
+    cat ./inc/trusting_help.txt
+
+    if [ ${TRUS_HELP} -eq 0 ]; then
+	printf "\n\n\033[0;33m"
+	printf "At least one configuration (arch or user) file is missing or misspelled:"
+	printf "\t'%s'.cfg\t'%s'.cfg" ${TRUS_USER} ${TRUS_HPCC}
+	printf "\033[0m"
+    fi
+
+    printf "\n\nContent of 'config' folder:\n"
+    find config -name *.cfg | cut -d/ -f2 \
+	| xargs -n 4 printf "\t- %-25s\t- %-25s\t- %-25s\t- %-25s\n"
+    exit 1
+else
+    . ./inc/trusting.env
+    [ ${TRUS_DBUG} -eq 1 ] && set -vx
+fi
+
+
+## List last branches from NEMO Forge
+##---------------------------------------------------
+printf "\nWhat branch do you want to install in "${TRUS_WORK}" for trusting test ? "
+echo 'Enter 0 to abort'
+select branch in 'trunk' $( svn ls ${TRUS_SVNH}/branches/2015 | tr -d / | sort -r ); do
+
+    if [ $REPLY -eq 0 ]; then exit 1; else export TRUS_BRAN=$branch; fi
+
+    printf "\nInstallation of a working copy of '%s' branch in '%s'? " ${TRUS_BRAN} ${TRUS_WORK}
+    printf "\nType [Y|y|yes] to confirm, if not back to branches list number\n"
+    read answer
+    [[ $answer == 'Y' || $answer == 'y' || $answer == 'yes' ]] && break
+
+done
+
+echo
+
+
+## First checkout of selected branch
+##---------------------------------------------------
+echo 'Initial checkout of '${TRUS_BRAN}' branch'
+mkdir -p ${TRUS_WORK}/${TRUS_BRAN}/NEMOGCM
+cd       ${TRUS_WORK}/${TRUS_BRAN}/NEMOGCM
+
+svn_bran=branches/2015/${TRUS_BRAN}
+[ ${TRUS_BRAN} == 'trunk' ] && svn_bran=${TRUS_BRAN}
+
+for elmt in ${TRUS_CKOT}; do
+    [ $elmt == '\' ] && continue
+    printf "%s " $elmt
+
+    if [ $elmt == 'TOOLS/maketools' ]; then
+	svn co -q ${TRUS_SVNH}/${svn_bran}/NEMOGCM/TOOLS --depth empty
+	svn up -q $elmt
+    else
+	svn co -q ${TRUS_SVNH}/${svn_bran}/NEMOGCM/$elmt $elmt
+    fi
+
+done
+
+printf "\n\n"
+
+
+## Compile rebuild_nemo.exe in anticipation
+##---------------------------------------------------
+if [ $( find ARCH -name arch-${TRUS_HPCC}.fcm ) ]; then
+    echo 'Compile NEMO rebuild tool'
+    cd TOOLS && ./maketools -n REBUILD_NEMO -m ${TRUS_HPCC} -j ${TRUS_NPRO} >& /dev/null
+    [ -e REBUILD_NEMO/rebuild_nemo.exe ] && printf "\033[0;32mOK\033[0m" || printf "\033[0;31mKO\033[0m"
+    printf "\n\n"
+else
+    printf "\033[0;31mNo arch file found to compile NEMO rebuild tool\033[0m\n\n"
+fi
+
+exit 0
+
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/trusting.sh
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/trusting.sh	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/trusting.sh	(revision 6041)
@@ -0,0 +1,181 @@
+#!/bin/bash
+
+
+cd $( dirname $0 )
+
+## Set defaults
+##---------------------------------------------------
+TRUS_DIRE=$PWD
+TRUS_DBUG=0; TRUS_PROD=0; TRUS_HELP=0
+## No update on SVN directories & 'FAILED' result for 'Unknown error' )
+TRUS_SVNA='svn status'; TRUS_RSLT='FAILED'; TRUS_RORR=0
+xios_mode='--full'; stdout_redir='>&'
+rev=$( svn info | awk '(NR == 9) {print $NF}' )
+
+
+## Get options (replacing initials settings)
+##---------------------------------------------------
+while [ $# -ne 0 ]; do
+    case $1 in
+	'-a'|'--archive') TRUS_TARF=$2; shift 2;; '-b'|'--branch' ) TRUS_BRAN=$2; shift 2;;
+	'-d'|'--debug'  ) TRUS_DBUG=1 ; shift  ;; '-e'|'--email'  ) TRUS_MAIL=$2; shift 2;;
+	'-f'|'--forcdir') TRUS_FORC=$2; shift 2;; '-j'|'--job'    ) TRUS_NPRO=$2; shift 2;;
+	'-h'|'--help'   ) TRUS_HELP=1 ; shift  ;; '-m'|'--machine') TRUS_HPCC=$2; shift 2;;
+	'-n'|'--newconf') TRUS_CONF=$2; shift 2;; '-r'|'--refconf') TRUS_REFE=$2; shift 2;;
+	'-t'|'--time'   ) TRUS_TOUT=$2; shift 2;; '-p'|'--prod'   ) TRUS_PROD=1 ; shift  ;;
+	'-u'|'--user'   ) TRUS_USER=$2; shift 2;; '-v'|'--version') TRUS_SVNV=$2; shift 2;;
+	'-w'|'--workdir') TRUS_WORK=$2; shift 2;; "*"             ) TRUS_HELP=1 ; shift  ;;
+    esac
+done
+
+
+## Initialization (HPC & user environment)
+##---------------------------------------------------
+if [[ ! -e config/${TRUS_USER}.cfg || ! -e config/${TRUS_HPCC}.cfg || ${TRUS_HELP} -eq 1 ]]; then
+    cat ./inc/trusting_help.txt
+
+    if [ ${TRUS_HELP} -eq 0 ]; then
+	printf "\n\n\033[0;33m"
+	printf "At least one configuration (arch or user) file is missing or misspelled:"
+	printf "\t'%s'.cfg\t'%s'.cfg" ${TRUS_USER} ${TRUS_HPCC}
+	printf "\033[0m"
+    fi
+
+    printf "\n\nContent of 'config' folder:"
+    find config -name *.cfg | cut -d/ -f2 \
+	| xargs -n 4 printf "%-25s\t%-25s\t%-25s\n"
+    exit 1
+else
+    . ./inc/trusting.env && . ./inc/trusting_func.sh
+
+    ## DEBUG option to speed up & expand verbosity of compilation
+    [ ${TRUS_DBUG} -eq 1 ] && { set -vx; xios_mode=''; stdout_redir='>'; }
+
+    ## If -v|--version option has been set, modify default SVN action on directories
+    if   [ $( echo ${TRUS_SVNV} | grep  "HEAD\|up\|update"                     ) ]; then
+	TRUS_SVNA='svn update -r HEAD'
+    elif [ $( echo ${TRUS_SVNV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' ) ]; then
+	TRUS_SVNA='svn update -r     '$( echo ${TRUS_SVNV} | grep -o '{[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}}' )
+    elif [ $( echo ${TRUS_SVNV} | grep -o '[0-9]*'                             ) ]; then
+	TRUS_SVNA='svn update -r     '$( echo ${TRUS_SVNV} | grep -o '[0-9]*' )
+    fi
+
+fi
+
+
+## Display contextual summary of trusting test
+##---------------------------------------------------
+echo
+if [ -t 0 ]; then cat ./inc/banner.txt; else cat ./inc/banner.html; fi
+echo
+echo '****************************************************************************************************'
+echo '*                                                                                                  *'
+echo '*                           NEMO Trusting (Continuous Integration Tool)                            *'
+echo "*                                             ver.$rev                                             *"
+echo '*                                                                                                  *'
+echo '****************************************************************************************************'
+echo
+printf "\t§ Testing configuration\t\t%s based on %s\n" ${TRUS_CONF} ${TRUS_REFE}
+printf "\t§ SVN working copy\t\t%s/%s\n"               ${TRUS_WORK} ${TRUS_BRAN}
+printf "\t§ Benchmark folder\t\t%s\n"       	       ${TRUS_STOR}
+printf "\t§ (Super)Computer\t\t%s\n" 		       ${TRUS_HPCC}
+printf "\t§ User installation\t\t%s\n\n" 	       ${TRUS_USER}
+
+
+## Make timestamped directory with messenger files
+##---------------------------------------------------
+print_step 'Timestamped testing directory'
+mkdir -p ${TRUS_SCRA} ${TRUS_STOR}
+cd       ${TRUS_SCRA}
+echo     ${TRUS_SCRA}
+init_files
+get_date
+
+
+## Get SVN revision on XIOS & NEMO essentials directories
+##---------------------------------------------------
+print_step "SVN action on NEMO directories: ${TRUS_SVNA}"
+get_nemo_rev
+
+
+## Check softwares versions (after sourced arch environment)
+##---------------------------------------------------
+print_step 'Get testing environement'
+get_soft_rel
+cat model.log | awk '{printf "%-20s %s %s\n", $1, $2, $3}'
+env | sort > env.log
+
+
+## XIOS compilation from scratch
+##---------------------------------------------------
+print_step 'Compile XIOS'
+cd ${TRUS_XIOS}
+eval ./make_xios ${xios_mode} --arch ${TRUS_HPCC} --job ${TRUS_NPRO} \
+    ${stdout_redir} /dev/null
+[ ! -e lib/libxios.a ] && get_out 1 || echo 'Success'
+
+
+## NEMO compilation from scratch
+##---------------------------------------------------
+print_step "Compile ${TRUS_REFE} configuration"
+cd ${TRUS_NGCM}/CONFIG
+[[ -d ${TRUS_CONF} && ${TRUS_DBUG} -eq 0 ]] && ./makenemo -n ${TRUS_CONF} clean_config \
+    > /dev/null <<EOF
+y
+EOF
+
+eval ./makenemo -n ${TRUS_CONF} -r ${TRUS_REFE} -m ${TRUS_HPCC} -j ${TRUS_NPRO} \
+                ${TRUS_KEYA} ${TRUS_KEYD}                                       \
+    ${stdout_redir} /dev/null
+[ ! -e ${TRUS_CONF}/BLD/bin/nemo.exe ] && get_out 2 || echo 'Success'
+
+
+## Get all inputs for running
+##---------------------------------------------------
+print_step 'Set job (copying or extracting inputs)'
+cd ${TRUS_SCRA}
+get_inputs
+cp   ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/cpp_* .
+find ${TRUS_NGCM}/CONFIG/${TRUS_CONF}/EXP00 -regex '.*\(_cfg\|.in\|opa\|_ref\|.xml\)' \
+                                            -exec  cp {} . \;
+
+
+## Check inputs
+##---------------------------------------------------
+print_step 'Compare inputs'
+diff_inputs
+
+
+## Job submission & computation
+##---------------------------------------------------
+print_step 'Submit job'
+cp ${TRUS_DIRE}/batch/${TRUS_JSPT} ${TRUS_SCRA} ## Copy the submitting script to testing folder
+TRUS_JIDN=$( eval ${TRUS_JSUB} )
+[ $? -ne 0 ] && get_out 4 || printf "Success (job ID %s)\n" ${TRUS_JIDN}
+print_step 'Pending job'
+job_pending
+print_step 'Job finished'
+
+
+## Check job state & get computation performances if succeeded
+##---------------------------------------------------
+print_step 'Test job state'
+[[ ! -e time.step || $( grep 'E R R O R' ocean.output ) ]] && get_out 5 || echo 'Success' ## Must be reviewed
+print_step 'Get job performances'
+get_time
+get_memy
+
+
+## Check outputs
+##---------------------------------------------------
+TRUS_RSLT='OK' ## 'OK' by default
+print_step 'Compare outputs'
+diff_results
+print_step 'Compare restarts'
+diff_restart
+[ $TRUS_RSLT == 'FAILED' ] && get_out 8
+
+
+## End, at least nothing has changed ;-)
+##---------------------------------------------------
+get_out 0
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/sortabletable.css
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/sortabletable.css	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/sortabletable.css	(revision 6041)
@@ -0,0 +1,50 @@
+.sort-table {
+	font:		Icon;
+	border:		1px Solid ThreeDShadow;
+	background:	Window;
+	color:		WindowText;
+}
+
+.sort-table thead {
+	background:	ButtonFace;
+}
+
+.sort-table td {
+	padding:	2px 5px;
+}
+
+.sort-table thead td {
+	border:			1px solid;
+	border-color:	ButtonHighlight ButtonShadow
+					ButtonShadow ButtonHighlight;
+	cursor:			default;
+}
+
+.sort-table thead td:active {
+	border-color:	ButtonShadow ButtonHighlight
+					ButtonHighlight ButtonShadow;
+	padding:		3px 4px 1px 6px;
+}
+
+.sort-table thead td[_sortType=None]:active {
+	border-color:	ButtonHighlight ButtonShadow
+					ButtonShadow ButtonHighlight;
+	padding:		2px 5px;
+}
+
+.sort-arrow {
+	width:					11px;
+	height:					11px;
+	background-position:	center center;
+	background-repeat:		no-repeat;
+	margin:					0 2px;
+}
+
+.sort-arrow.descending {
+	background-image:		url("images/downsimple.png");
+
+}
+
+.sort-arrow.ascending {
+	background-image:		url("images/upsimple.png");
+}
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/sortabletable.js
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/sortabletable.js	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/sortabletable.js	(revision 6041)
@@ -0,0 +1,438 @@
+/*----------------------------------------------------------------------------\
+|                            Sortable Table 1.12                              |
+|-----------------------------------------------------------------------------|
+|                         Created by Erik Arvidsson                           |
+|                  (http://webfx.eae.net/contact.html#erik)                   |
+|                      For WebFX (http://webfx.eae.net/)                      |
+|-----------------------------------------------------------------------------|
+| A DOM 1 based script that allows an ordinary HTML table to be sortable.     |
+|-----------------------------------------------------------------------------|
+|                  Copyright (c) 1998 - 2006 Erik Arvidsson                   |
+|-----------------------------------------------------------------------------|
+| Licensed under the Apache License, Version 2.0 (the "License"); you may not |
+| use this file except in compliance with the License.  You may obtain a copy |
+| of the License at http://www.apache.org/licenses/LICENSE-2.0                |
+| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
+| Unless  required  by  applicable law or  agreed  to  in  writing,  software |
+| distributed under the License is distributed on an  "AS IS" BASIS,  WITHOUT |
+| WARRANTIES OR  CONDITIONS OF ANY KIND,  either express or implied.  See the |
+| License  for the  specific language  governing permissions  and limitations |
+| under the License.                                                          |
+|-----------------------------------------------------------------------------|
+| 2003-01-10 | First version                                                  |
+| 2003-01-19 | Minor changes to the date parsing                              |
+| 2003-01-28 | JScript 5.0 fixes (no support for 'in' operator)               |
+| 2003-02-01 | Sloppy typo like error fixed in getInnerText                   |
+| 2003-07-04 | Added workaround for IE cellIndex bug.                         |
+| 2003-11-09 | The bDescending argument to sort was not correctly working     |
+|            | Using onclick DOM0 event if no support for addEventListener    |
+|            | or attachEvent                                                 |
+| 2004-01-13 | Adding addSortType and removeSortType which makes it a lot     |
+|            | easier to add new, custom sort types.                          |
+| 2004-01-27 | Switch to use descending = false as the default sort order.    |
+|            | Change defaultDescending to suit your needs.                   |
+| 2004-03-14 | Improved sort type None look and feel a bit                    |
+| 2004-08-26 | Made the handling of tBody and tHead more flexible. Now you    |
+|            | can use another tHead or no tHead, and you can chose some      |
+|            | other tBody.                                                   |
+| 2006-04-25 | Changed license to Apache Software License 2.0                 |  
+|-----------------------------------------------------------------------------|
+| Created 2003-01-10 | All changes are in the log above. | Updated 2006-04-25 |
+\----------------------------------------------------------------------------*/
+
+
+function SortableTable(oTable, oSortTypes) {
+
+	this.sortTypes = oSortTypes || [];
+
+	this.sortColumn = null;
+	this.descending = null;
+
+	var oThis = this;
+	this._headerOnclick = function (e) {
+		oThis.headerOnclick(e);
+	};
+
+	if (oTable) {
+		this.setTable( oTable );
+		this.document = oTable.ownerDocument || oTable.document;
+	}
+	else {
+		this.document = document;
+	}
+
+
+	// only IE needs this
+	var win = this.document.defaultView || this.document.parentWindow;
+	this._onunload = function () {
+		oThis.destroy();
+	};
+	if (win && typeof win.attachEvent != "undefined") {
+		win.attachEvent("onunload", this._onunload);
+	}
+}
+
+SortableTable.gecko = navigator.product == "Gecko";
+SortableTable.msie = /msie/i.test(navigator.userAgent);
+// Mozilla is faster when doing the DOM manipulations on
+// an orphaned element. MSIE is not
+SortableTable.removeBeforeSort = SortableTable.gecko;
+
+SortableTable.prototype.onsort = function () {};
+
+// default sort order. true -> descending, false -> ascending
+SortableTable.prototype.defaultDescending = false;
+
+// shared between all instances. This is intentional to allow external files
+// to modify the prototype
+SortableTable.prototype._sortTypeInfo = {};
+
+SortableTable.prototype.setTable = function (oTable) {
+	if ( this.tHead )
+		this.uninitHeader();
+	this.element = oTable;
+	this.setTHead( oTable.tHead );
+	this.setTBody( oTable.tBodies[0] );
+};
+
+SortableTable.prototype.setTHead = function (oTHead) {
+	if (this.tHead && this.tHead != oTHead )
+		this.uninitHeader();
+	this.tHead = oTHead;
+	this.initHeader( this.sortTypes );
+};
+
+SortableTable.prototype.setTBody = function (oTBody) {
+	this.tBody = oTBody;
+};
+
+SortableTable.prototype.setSortTypes = function ( oSortTypes ) {
+	if ( this.tHead )
+		this.uninitHeader();
+	this.sortTypes = oSortTypes || [];
+	if ( this.tHead )
+		this.initHeader( this.sortTypes );
+};
+
+// adds arrow containers and events
+// also binds sort type to the header cells so that reordering columns does
+// not break the sort types
+SortableTable.prototype.initHeader = function (oSortTypes) {
+	if (!this.tHead) return;
+	var cells = this.tHead.rows[0].cells;
+	var doc = this.tHead.ownerDocument || this.tHead.document;
+	this.sortTypes = oSortTypes || [];
+	var l = cells.length;
+	var img, c;
+	for (var i = 0; i < l; i++) {
+		c = cells[i];
+		if (this.sortTypes[i] != null && this.sortTypes[i] != "None") {
+			img = doc.createElement("IMG");
+			img.src = "html/images/blank.png";
+			c.appendChild(img);
+			if (this.sortTypes[i] != null)
+				c._sortType = this.sortTypes[i];
+			if (typeof c.addEventListener != "undefined")
+				c.addEventListener("click", this._headerOnclick, false);
+			else if (typeof c.attachEvent != "undefined")
+				c.attachEvent("onclick", this._headerOnclick);
+			else
+				c.onclick = this._headerOnclick;
+		}
+		else
+		{
+			c.setAttribute( "_sortType", oSortTypes[i] );
+			c._sortType = "None";
+		}
+	}
+	this.updateHeaderArrows();
+};
+
+// remove arrows and events
+SortableTable.prototype.uninitHeader = function () {
+	if (!this.tHead) return;
+	var cells = this.tHead.rows[0].cells;
+	var l = cells.length;
+	var c;
+	for (var i = 0; i < l; i++) {
+		c = cells[i];
+		if (c._sortType != null && c._sortType != "None") {
+			c.removeChild(c.lastChild);
+			if (typeof c.removeEventListener != "undefined")
+				c.removeEventListener("click", this._headerOnclick, false);
+			else if (typeof c.detachEvent != "undefined")
+				c.detachEvent("onclick", this._headerOnclick);
+			c._sortType = null;
+			c.removeAttribute( "_sortType" );
+		}
+	}
+};
+
+SortableTable.prototype.updateHeaderArrows = function () {
+	if (!this.tHead) return;
+	var cells = this.tHead.rows[0].cells;
+	var l = cells.length;
+	var img;
+	for (var i = 0; i < l; i++) {
+		if (cells[i]._sortType != null && cells[i]._sortType != "None") {
+			img = cells[i].lastChild;
+			if (i == this.sortColumn)
+				img.className = "sort-arrow " + (this.descending ? "descending" : "ascending");
+			else
+				img.className = "sort-arrow";
+		}
+	}
+};
+
+SortableTable.prototype.headerOnclick = function (e) {
+	// find TD element
+	var el = e.target || e.srcElement;
+	while (el.tagName != "TD")
+		el = el.parentNode;
+
+	this.sort(SortableTable.msie ? SortableTable.getCellIndex(el) : el.cellIndex);
+};
+
+// IE returns wrong cellIndex when columns are hidden
+SortableTable.getCellIndex = function (oTd) {
+	var cells = oTd.parentNode.childNodes
+	var l = cells.length;
+	var i;
+	for (i = 0; cells[i] != oTd && i < l; i++)
+		;
+	return i;
+};
+
+SortableTable.prototype.getSortType = function (nColumn) {
+	return this.sortTypes[nColumn] || "String";
+};
+
+// only nColumn is required
+// if bDescending is left out the old value is taken into account
+// if sSortType is left out the sort type is found from the sortTypes array
+
+SortableTable.prototype.sort = function (nColumn, bDescending, sSortType) {
+	if (!this.tBody) return;
+	if (sSortType == null)
+		sSortType = this.getSortType(nColumn);
+
+	// exit if None
+	if (sSortType == "None")
+		return;
+
+	if (bDescending == null) {
+		if (this.sortColumn != nColumn)
+			this.descending = this.defaultDescending;
+		else
+			this.descending = !this.descending;
+	}
+	else
+		this.descending = bDescending;
+
+	this.sortColumn = nColumn;
+
+	if (typeof this.onbeforesort == "function")
+		this.onbeforesort();
+
+	var f = this.getSortFunction(sSortType, nColumn);
+	var a = this.getCache(sSortType, nColumn);
+	var tBody = this.tBody;
+
+	a.sort(f);
+
+	if (this.descending)
+		a.reverse();
+
+	if (SortableTable.removeBeforeSort) {
+		// remove from doc
+		var nextSibling = tBody.nextSibling;
+		var p = tBody.parentNode;
+		p.removeChild(tBody);
+	}
+
+	// insert in the new order
+	var l = a.length;
+	for (var i = 0; i < l; i++)
+		tBody.appendChild(a[i].element);
+
+	if (SortableTable.removeBeforeSort) {
+		// insert into doc
+		p.insertBefore(tBody, nextSibling);
+	}
+
+	this.updateHeaderArrows();
+
+	this.destroyCache(a);
+
+	if (typeof this.onsort == "function")
+		this.onsort();
+};
+
+SortableTable.prototype.asyncSort = function (nColumn, bDescending, sSortType) {
+	var oThis = this;
+	this._asyncsort = function () {
+		oThis.sort(nColumn, bDescending, sSortType);
+	};
+	window.setTimeout(this._asyncsort, 1);
+};
+
+SortableTable.prototype.getCache = function (sType, nColumn) {
+	if (!this.tBody) return [];
+	var rows = this.tBody.rows;
+	var l = rows.length;
+	var a = new Array(l);
+	var r;
+	for (var i = 0; i < l; i++) {
+		r = rows[i];
+		a[i] = {
+			value:		this.getRowValue(r, sType, nColumn),
+			element:	r
+		};
+	};
+	return a;
+};
+
+SortableTable.prototype.destroyCache = function (oArray) {
+	var l = oArray.length;
+	for (var i = 0; i < l; i++) {
+		oArray[i].value = null;
+		oArray[i].element = null;
+		oArray[i] = null;
+	}
+};
+
+SortableTable.prototype.getRowValue = function (oRow, sType, nColumn) {
+	// if we have defined a custom getRowValue use that
+	if (this._sortTypeInfo[sType] && this._sortTypeInfo[sType].getRowValue)
+		return this._sortTypeInfo[sType].getRowValue(oRow, nColumn);
+
+	var s;
+	var c = oRow.cells[nColumn];
+	if (typeof c.innerText != "undefined")
+		s = c.innerText;
+	else
+		s = SortableTable.getInnerText(c);
+	return this.getValueFromString(s, sType);
+};
+
+SortableTable.getInnerText = function (oNode) {
+	var s = "";
+	var cs = oNode.childNodes;
+	var l = cs.length;
+	for (var i = 0; i < l; i++) {
+		switch (cs[i].nodeType) {
+			case 1: //ELEMENT_NODE
+				s += SortableTable.getInnerText(cs[i]);
+				break;
+			case 3:	//TEXT_NODE
+				s += cs[i].nodeValue;
+				break;
+		}
+	}
+	return s;
+};
+
+SortableTable.prototype.getValueFromString = function (sText, sType) {
+	if (this._sortTypeInfo[sType])
+		return this._sortTypeInfo[sType].getValueFromString( sText );
+	return sText;
+	/*
+	switch (sType) {
+		case "Number":
+			return Number(sText);
+		case "CaseInsensitiveString":
+			return sText.toUpperCase();
+		case "Date":
+			var parts = sText.split("-");
+			var d = new Date(0);
+			d.setFullYear(parts[0]);
+			d.setDate(parts[2]);
+			d.setMonth(parts[1] - 1);
+			return d.valueOf();
+	}
+	return sText;
+	*/
+	};
+
+SortableTable.prototype.getSortFunction = function (sType, nColumn) {
+	if (this._sortTypeInfo[sType])
+		return this._sortTypeInfo[sType].compare;
+	return SortableTable.basicCompare;
+};
+
+SortableTable.prototype.destroy = function () {
+	this.uninitHeader();
+	var win = this.document.parentWindow;
+	if (win && typeof win.detachEvent != "undefined") {	// only IE needs this
+		win.detachEvent("onunload", this._onunload);
+	}
+	this._onunload = null;
+	this.element = null;
+	this.tHead = null;
+	this.tBody = null;
+	this.document = null;
+	this._headerOnclick = null;
+	this.sortTypes = null;
+	this._asyncsort = null;
+	this.onsort = null;
+};
+
+// Adds a sort type to all instance of SortableTable
+// sType : String - the identifier of the sort type
+// fGetValueFromString : function ( s : string ) : T - A function that takes a
+//    string and casts it to a desired format. If left out the string is just
+//    returned
+// fCompareFunction : function ( n1 : T, n2 : T ) : Number - A normal JS sort
+//    compare function. Takes two values and compares them. If left out less than,
+//    <, compare is used
+// fGetRowValue : function( oRow : HTMLTRElement, nColumn : int ) : T - A function
+//    that takes the row and the column index and returns the value used to compare.
+//    If left out then the innerText is first taken for the cell and then the
+//    fGetValueFromString is used to convert that string the desired value and type
+
+SortableTable.prototype.addSortType = function (sType, fGetValueFromString, fCompareFunction, fGetRowValue) {
+	this._sortTypeInfo[sType] = {
+		type:				sType,
+		getValueFromString:	fGetValueFromString || SortableTable.idFunction,
+		compare:			fCompareFunction || SortableTable.basicCompare,
+		getRowValue:		fGetRowValue
+	};
+};
+
+// this removes the sort type from all instances of SortableTable
+SortableTable.prototype.removeSortType = function (sType) {
+	delete this._sortTypeInfo[sType];
+};
+
+SortableTable.basicCompare = function compare(n1, n2) {
+	if (n1.value < n2.value)
+		return -1;
+	if (n2.value < n1.value)
+		return 1;
+	return 0;
+};
+
+SortableTable.idFunction = function (x) {
+	return x;
+};
+
+SortableTable.toUpperCase = function (s) {
+	return s.toUpperCase();
+};
+
+SortableTable.toDate = function (s) {
+	var parts = s.split("-");
+	var d = new Date(0);
+	d.setFullYear(parts[0]);
+	d.setDate(parts[2]);
+	d.setMonth(parts[1] - 1);
+	return d.valueOf();
+};
+
+
+// add sort types
+SortableTable.prototype.addSortType("Number", Number);
+SortableTable.prototype.addSortType("CaseInsensitiveString", SortableTable.toUpperCase);
+SortableTable.prototype.addSortType("Date", SortableTable.toDate);
+SortableTable.prototype.addSortType("String");
+// None is a special case
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/tab-view.css
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/tab-view.css	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/tab-view.css	(revision 6041)
@@ -0,0 +1,60 @@
+	.dhtmlgoodies_tabPane{
+		height:21px;	/* Height of tabs */
+		border-bottom:1px solid #919b9c;
+	}
+	.dhtmlgoodies_aTab{
+		border-left:1px solid #919b9c;
+		border-right:1px solid #919b9c;
+		border-bottom:1px solid #919b9c;
+		font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;
+		padding:5px;		
+		
+	}
+	.dhtmlgoodies_tabPane DIV{
+		float:left;
+		height:100%;	/* Height of tabs */
+		padding-left:3px;
+		vertical-align:middle;
+		background-repeat:no-repeat;
+		background-position:bottom left;
+		cursor:pointer;
+		position:relative;
+		bottom:-1px;
+		margin-left:0px;
+		margin-right:0px;
+	}
+	.dhtmlgoodies_tabPane .tabActive{
+		background-image:url('../images/tab_left_active.gif');
+		margin-left:0px;
+		margin-right:0px;	
+		z-index:10;	
+	}
+	.dhtmlgoodies_tabPane .tabInactive{
+		background-image:url('../images/tab_left_inactive.gif');
+		margin-left:0px;
+		margin-right:0px;
+		z-index:1;
+	}
+
+	.dhtmlgoodies_tabPane .inactiveTabOver{
+		background-image:url('../images/tab_left_over.gif');
+		margin-left:0px;
+		margin-right:0px;
+	}
+	.dhtmlgoodies_tabPane span{
+		font-family:arial;
+		vertical-align:top;
+		font-size:11px;
+		padding-left:3px;
+		padding-right:3px;		
+		line-height:21px;
+		float:left;
+	}
+	.dhtmlgoodies_tabPane .tabActive span{
+		padding-bottom:1px;
+		line-height:20px;
+	}
+	
+	.dhtmlgoodies_tabPane img{
+		float:left;
+	}
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/tab-view.js
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/tab-view.js	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/html/tab-view.js	(revision 6041)
@@ -0,0 +1,375 @@
+	/************************************************************************************************************
+	(C) www.dhtmlgoodies.com, October 2005
+	
+	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
+	
+	Terms of use:
+	You are free to use this script as long as the copyright message is kept intact. However, you may not
+	redistribute, sell or repost it without our permission.
+	
+	Updated:
+		
+		March, 14th, 2006 - Create new tabs dynamically
+		March, 15th, 2006 - Dynamically delete a tab
+		
+	Thank you!
+	
+	www.dhtmlgoodies.com
+	Alf Magne Kalleland
+	
+	************************************************************************************************************/		
+	var textPadding = 3; // Padding at the left of tab text - bigger value gives you wider tabs
+	var strictDocType = true; 
+	var tabView_maxNumberOfTabs = 6;	// Maximum number of tabs
+	
+	/* Don't change anything below here */
+	var dhtmlgoodies_tabObj = new Array();
+	var activeTabIndex = new Array();
+	var MSIE = navigator.userAgent.indexOf('MSIE')>=0?true:false;
+	
+	var regExp = new RegExp(".*MSIE ([0-9]\.[0-9]).*","g");
+	var navigatorVersion = navigator.userAgent.replace(regExp,'$1');
+	
+	var ajaxObjects = new Array();
+	var tabView_countTabs = new Array();
+	var tabViewHeight = new Array();
+	var tabDivCounter = 0;
+	var closeImageHeight = 8;	// Pixel height of close buttons
+	var closeImageWidth = 8;	// Pixel height of close buttons
+	
+	
+	function setPadding(obj,padding){
+		var span = obj.getElementsByTagName('SPAN')[0];
+		span.style.paddingLeft = padding + 'px';	
+		span.style.paddingRight = padding + 'px';	
+	}
+	function showTab(parentId,tabIndex)
+	{
+		var parentId_div = parentId + "_";
+		if(!document.getElementById('tabView' + parentId_div + tabIndex)){
+			return;
+		}
+		if(activeTabIndex[parentId]>=0){
+			if(activeTabIndex[parentId]==tabIndex){
+				return;
+			}
+	
+			var obj = document.getElementById('tabTab'+parentId_div + activeTabIndex[parentId]);
+			
+			obj.className='tabInactive';
+			var img = obj.getElementsByTagName('IMG')[0];
+			if(img.src.indexOf('tab_')==-1)img = obj.getElementsByTagName('IMG')[1];
+			img.src = 'images/tab_right_inactive.gif';
+			document.getElementById('tabView' + parentId_div + activeTabIndex[parentId]).style.display='none';
+		}
+		
+		var thisObj = document.getElementById('tabTab'+ parentId_div +tabIndex);	
+			
+		thisObj.className='tabActive';
+		var img = thisObj.getElementsByTagName('IMG')[0];
+		if(img.src.indexOf('tab_')==-1)img = thisObj.getElementsByTagName('IMG')[1];
+		img.src = 'images/tab_right_active.gif';
+		
+		document.getElementById('tabView' + parentId_div + tabIndex).style.display='block';
+		activeTabIndex[parentId] = tabIndex;
+		
+
+		var parentObj = thisObj.parentNode;
+		var aTab = parentObj.getElementsByTagName('DIV')[0];
+		countObjects = 0;
+		var startPos = 2;
+		var previousObjectActive = false;
+		while(aTab){
+			if(aTab.tagName=='DIV'){
+				if(previousObjectActive){
+					previousObjectActive = false;
+					startPos-=2;
+				}
+				if(aTab==thisObj){
+					startPos-=2;
+					previousObjectActive=true;
+					setPadding(aTab,textPadding+1);
+				}else{
+					setPadding(aTab,textPadding);
+				}
+				
+				aTab.style.left = startPos + 'px';
+				countObjects++;
+				startPos+=2;
+			}			
+			aTab = aTab.nextSibling;
+		}
+		
+		return;
+	}
+	
+	function tabClick()
+	{
+		var idArray = this.id.split('_');		
+		showTab(this.parentNode.parentNode.id,idArray[idArray.length-1].replace(/[^0-9]/gi,''));
+		
+	}
+	
+	function rolloverTab()
+	{
+		if(this.className.indexOf('tabInactive')>=0){
+			this.className='inactiveTabOver';
+			var img = this.getElementsByTagName('IMG')[0];
+			if(img.src.indexOf('tab_')<=0)img = this.getElementsByTagName('IMG')[1];
+			img.src = 'images/tab_right_over.gif';
+		}
+		
+	}
+	function rolloutTab()
+	{
+		if(this.className ==  'inactiveTabOver'){
+			this.className='tabInactive';
+			var img = this.getElementsByTagName('IMG')[0];
+			if(img.src.indexOf('tab_')<=0)img = this.getElementsByTagName('IMG')[1];
+			img.src = 'images/tab_right_inactive.gif';
+		}
+		
+	}
+	
+	function hoverTabViewCloseButton()
+	{
+		this.src = this.src.replace('close.gif','close_over.gif');
+	}
+	
+	function stopHoverTabViewCloseButton()
+	{
+		this.src = this.src.replace('close_over.gif','close.gif');
+	}
+	
+	function initTabs(mainContainerID,tabTitles,activeTab,width,height,closeButtonArray,additionalTab)
+	{
+		if(!closeButtonArray)closeButtonArray = new Array();
+		
+		if(!additionalTab || additionalTab=='undefined'){			
+			dhtmlgoodies_tabObj[mainContainerID] = document.getElementById(mainContainerID);
+			width = width + '';
+			if(width.indexOf('%')<0)width= width + 'px';
+			dhtmlgoodies_tabObj[mainContainerID].style.width = width;
+						
+			height = height + '';
+			if(height.length>0){
+				if(height.indexOf('%')<0)height= height + 'px';
+				dhtmlgoodies_tabObj[mainContainerID].style.height = height;
+			}
+			
+
+			tabViewHeight[mainContainerID] = height;
+			
+			var tabDiv = document.createElement('DIV');		
+			var firstDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[0];	
+			
+			dhtmlgoodies_tabObj[mainContainerID].insertBefore(tabDiv,firstDiv);	
+			tabDiv.className = 'dhtmlgoodies_tabPane';			
+			tabView_countTabs[mainContainerID] = 0;
+
+		}else{
+			var tabDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[0];
+			var firstDiv = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV')[1];
+			height = tabViewHeight[mainContainerID];
+			activeTab = tabView_countTabs[mainContainerID];		
+	
+			
+		}
+		
+		
+		
+		for(var no=0;no<tabTitles.length;no++){
+			var aTab = document.createElement('DIV');
+			aTab.id = 'tabTab' + mainContainerID + "_" +  (no + tabView_countTabs[mainContainerID]);
+			aTab.onmouseover = rolloverTab;
+			aTab.onmouseout = rolloutTab;
+			aTab.onclick = tabClick;
+			aTab.className='tabInactive';
+			tabDiv.appendChild(aTab);
+			var span = document.createElement('SPAN');
+			span.innerHTML = tabTitles[no];
+			span.style.position = 'relative';
+			aTab.appendChild(span);
+			
+			if(closeButtonArray[no]){
+				var closeButton = document.createElement('IMG');
+				closeButton.src = 'images/close.gif';
+				closeButton.height = closeImageHeight + 'px';
+				closeButton.width = closeImageHeight + 'px';
+				closeButton.setAttribute('height',closeImageHeight);
+				closeButton.setAttribute('width',closeImageHeight);
+				closeButton.style.position='absolute';
+				closeButton.style.top = '6px';
+				closeButton.style.right = '0px';
+				closeButton.onmouseover = hoverTabViewCloseButton;
+				closeButton.onmouseout = stopHoverTabViewCloseButton;
+				
+				span.innerHTML = span.innerHTML + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';	
+				
+				var deleteTxt = span.innerHTML+'';
+
+				closeButton.onclick = function(){ deleteTab(this.parentNode.innerHTML) };
+				span.appendChild(closeButton);
+			}
+			
+			var img = document.createElement('IMG');
+			img.valign = 'bottom';
+			img.src = 'images/tab_right_inactive.gif';
+			// IE5.X FIX
+			if((navigatorVersion && navigatorVersion<6) || (MSIE && !strictDocType)){
+				img.style.styleFloat = 'none';
+				img.style.position = 'relative';	
+				img.style.top = '4px'
+				span.style.paddingTop = '4px';
+				aTab.style.cursor = 'hand';
+			}	// End IE5.x FIX
+			aTab.appendChild(img);
+		}
+
+		var tabs = dhtmlgoodies_tabObj[mainContainerID].getElementsByTagName('DIV');
+		var divCounter = 0;
+		for(var no=0;no<tabs.length;no++){
+			if(tabs[no].className=='dhtmlgoodies_aTab' && tabs[no].parentNode.id == mainContainerID){
+				if(height.length>0)tabs[no].style.height = height;
+				tabs[no].style.display='none';
+				tabs[no].id = 'tabView' + mainContainerID + "_" + divCounter;
+				divCounter++;
+			}			
+		}	
+		tabView_countTabs[mainContainerID] = tabView_countTabs[mainContainerID] + tabTitles.length;	
+		showTab(mainContainerID,activeTab);
+
+		return activeTab;
+	}	
+	
+	function showAjaxTabContent(ajaxIndex,parentId,tabId)
+	{
+		var obj = document.getElementById('tabView'+parentId + '_' + tabId);
+		obj.innerHTML = ajaxObjects[ajaxIndex].response;		
+	}
+	
+	function resetTabIds(parentId)
+	{
+		var tabTitleCounter = 0;
+		var tabContentCounter = 0;
+		
+		
+		var divs = dhtmlgoodies_tabObj[parentId].getElementsByTagName('DIV');
+
+		
+		for(var no=0;no<divs.length;no++){
+			if(divs[no].className=='dhtmlgoodies_aTab'){
+				divs[no].id = 'tabView' + parentId + '_' + tabTitleCounter;
+				tabTitleCounter++;
+			}
+			if(divs[no].id.indexOf('tabTab')>=0){
+				divs[no].id = 'tabTab' + parentId + '_' + tabContentCounter;	
+				tabContentCounter++;
+			}	
+			
+				
+		}
+	
+		tabView_countTabs[parentId] = tabContentCounter;
+	}
+	
+	
+	function createNewTab(parentId,tabTitle,tabContent,tabContentUrl,closeButton)
+	{
+		if(tabView_countTabs[parentId]>=tabView_maxNumberOfTabs)return;	// Maximum number of tabs reached - return
+		var div = document.createElement('DIV');
+		div.className = 'dhtmlgoodies_aTab';
+		dhtmlgoodies_tabObj[parentId].appendChild(div);		
+
+		var tabId = initTabs(parentId,Array(tabTitle),0,'','',Array(closeButton),true);
+		if(tabContent)div.innerHTML = tabContent;
+		if(tabContentUrl){		
+			var ajaxIndex = ajaxObjects.length;
+			ajaxObjects[ajaxIndex] = new sack();
+			ajaxObjects[ajaxIndex].requestFile = tabContentUrl;	// Specifying which file to get
+
+			ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxTabContent(ajaxIndex,parentId,tabId); };	// Specify function that will be executed after file has been found
+			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function	
+		
+		}
+				
+	}
+	
+	function getTabIndexByTitle(tabTitle)
+	{
+		var regExp = new RegExp("(.*?)&nbsp.*$","gi");
+		tabTitle = tabTitle.replace(regExp,'$1');
+		for(var prop in dhtmlgoodies_tabObj){
+			var divs = dhtmlgoodies_tabObj[prop].getElementsByTagName('DIV');
+			for(var no=0;no<divs.length;no++){
+				if(divs[no].id.indexOf('tabTab')>=0){
+					var span = divs[no].getElementsByTagName('SPAN')[0];
+					var regExp2 = new RegExp("(.*?)&nbsp.*$","gi");
+					var spanTitle = span.innerHTML.replace(regExp2,'$1');
+					
+					if(spanTitle == tabTitle){
+						
+						var tmpId = divs[no].id.split('_');						
+						return Array(prop,tmpId[tmpId.length-1].replace(/[^0-9]/g,'')/1);
+					}		
+				}
+			}
+		}
+		
+		return -1;
+		
+	}
+	
+	/* Call this function if you want to display some content from external file in one of the tabs 
+	Arguments: Title of tab and relative path to external file */
+	
+	function addAjaxContentToTab(tabTitle,tabContentUrl)
+	{
+		var index = getTabIndexByTitle(tabTitle);
+		if(index!=-1){
+			var ajaxIndex = ajaxObjects.length;
+			
+			tabId = index[1];
+			parentId = index[0];
+			
+			
+			ajaxObjects[ajaxIndex] = new sack();
+			ajaxObjects[ajaxIndex].requestFile = tabContentUrl;	// Specifying which file to get
+
+			ajaxObjects[ajaxIndex].onCompletion = function(){ showAjaxTabContent(ajaxIndex,parentId,tabId); };	// Specify function that will be executed after file has been found
+			ajaxObjects[ajaxIndex].runAJAX();		// Execute AJAX function				
+			
+		}	
+	}
+
+	
+	
+	function deleteTab(tabLabel,tabIndex,parentId)
+	{
+
+		if(tabLabel){
+			var index = getTabIndexByTitle(tabLabel);
+			if(index!=-1){
+				deleteTab(false,index[1],index[0]);
+			}
+			
+		}else if(tabIndex>=0){
+			if(document.getElementById('tabTab' + parentId + '_' + tabIndex)){
+				var obj = document.getElementById('tabTab' + parentId + '_' + tabIndex);
+				var id = obj.parentNode.parentNode.id;
+				obj.parentNode.removeChild(obj);
+				var obj2 = document.getElementById('tabView' + parentId + '_' + tabIndex);
+				obj2.parentNode.removeChild(obj2);
+				resetTabIds(parentId);
+				activeTabIndex[parentId]=-1;
+				showTab(parentId,'0');
+			}			
+		}
+		
+
+			
+		
+		
+	}
+	
+	
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/index.html
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/index.html	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/index.html	(revision 6041)
@@ -0,0 +1,354 @@
+<html>
+
+  <head>
+
+    <title>NEMO Trusting Dashboard</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <script type="text/javascript" src="html/sortabletable.js"></script>
+    <link type="text/css" rel="StyleSheet" href="html/sortabletable.css" />
+    <link rel="stylesheet" href="html/tab-view.css" type="text/css" media="screen">
+    <script type="text/javascript" src="html/tab-view.js"></script>
+    <style type="text/css">
+      body    { font-family:Helvetica, Arial, Sans-Serif;                      	    	      }
+      a1      { color:#000000; text-decoration:none;                           	    	      }
+      .title  { background:#AABBBB; font-weight:bold;                          	    	      }
+      .even   { background:#eee;                                               	    	      }
+      .odd    { background:#ddd;                                               	    	      }
+      td      { font-family:Arial    ; font-size:10pt; padding:1px 5px 1px 5px;	    	      }
+      .td1    { font-family:Monospace; font-size:10pt; padding:1px 5px 1px 5px;	    	      }
+      .table1 { background:#E6EEC9; border-collapse:collapse;                  	    	      }
+      .table2 { background:#E6EEC9; border-collapse:collapse;                  	    	      }
+      .myh3   { font-weight:bold; font-style:italic; font-family:Arial,Helvetica,sans-serif
+                background-color:#FFD700; border:2px outset #FFFFFF
+                padding: 1px 20px 1px 20px; width:120px; -moz-border-radius:6px 6px 6px 6px;  }
+    </style>
+
+  </head>
+
+  <body>
+
+    <?php
+       ini_set('display_errors', 'Off'); error_reporting(E_ALL);
+       include 'read_trusting.php';
+       $DODS_TGCC="http://dods.extra.cea.fr/store/martin/trusting"; $DODS_IDRIS="http://dodsp.idris.fr/romr005/trusting";
+       $file_headers=get_headers("${DODS_TGCC}/ORCA2_LIM_PISCES/nemo_v3_6_STABLE/trusting_info.html");
+       if ($file_headers[0] == '' ) { $LOCATION="./src/martin"; } else { $LOCATION="${DODS_TGCC}"; }
+    ?>
+
+       <!--$ctx=stream_context_create(array('http'=>array('timeout'=>1)));
+       $test=file_get_contents("${DODS_TGCC}/ORCA2_LIM_PISCES/nemo_v3_6_STABLE/trusting_info.html", 0, $ctx);
+       if ($test == FALSE ) { $LOCATION="./src/martin"; } else { $LOCATION="${DODS_TGCC}"; }-->
+
+    <!-----Begin NEMO trust----->
+    <div id="dhtmlgoodies_tabViewNEMO">
+
+      <!-----Begin v36 trust----->
+      <?php $BRANCH="nemo_v3_6_STABLE" ?>
+      <div class="dhtmlgoodies_aTab">
+	<div id="dhtmlgoodies_tabViewConf">
+
+	  <!-----Begin O2LP trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA2_LIM_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html"); ?>
+	    <div id="dhtmlgoodies_tabViewHPCC">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-1" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-1"),
+	                   [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-2" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-2"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O2LP trust----->
+
+	  <!-----Begin O1L3P trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA1_LIM3_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC2">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-3" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-3"),
+	                   [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-4" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-4"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O1L3P trust----->
+
+	  <!-----Begin AMM12 trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="AMM12"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC3">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-5" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-5"),
+	                   [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-6" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-6"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End AMM12 trust----->
+
+	</div>
+      </div>
+      <!-----End v36 trust----->
+
+
+      <!-----Begin trunk trust----->
+      <?php $BRANCH="trunk" ?>
+      <div class="dhtmlgoodies_aTab">
+	<div id="dhtmlgoodies_tabViewConf2">
+
+	  <!-----Begin O2LP trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA2_LIM_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC4">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-7" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-7"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End   Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-8" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-8"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O2LP trust----->
+
+	  <!-----Begin O1L3P trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA1_LIM3_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC5">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-9" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-9"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End   Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-10" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-10"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O1L3P trust----->
+
+	  <!-----Begin AMM12 trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="AMM12"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC6">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-11" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-11"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End   Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-12" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-12"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O1L3P trust----->
+
+	</div>
+      </div>
+      <!-----End trunk trust----->
+
+    </div>
+    <!-----End NEMO trust----->
+
+    <!-------------------------------------------------------------------------------------------->
+    <script type="text/javascript">
+      initTabs('dhtmlgoodies_tabViewNEMO'        ,
+               Array('<B>&nbsp;3.6&nbsp;  </B>',
+	             '<B>&nbsp;trunk&nbsp;</B>' 
+                                                ),
+               0,1820,15100                      ,
+               Array(false)                       )
+      initTabs('dhtmlgoodies_tabViewConf'                                        ,
+               Array('<B style="color: green">&nbsp;ORCA2_LIM_PISCES&nbsp;  </B>',
+	       	     '<B style="color: green">&nbsp;ORCA1_LIM3_PISCES&nbsp; </B>',
+	       	     '<B style="color: green">&nbsp;AMM12&nbsp;             </B>',
+	       	     '<B style="color: red  ">&nbsp;C1D_PAPA&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE&nbsp;              </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_BFM&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_PISCES&nbsp;       </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_XIOS&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM3&nbsp;        </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM_CFC_C14b&nbsp;</B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_OFF_PISCES&nbsp;  </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_SAS_LIM&nbsp;     </B>' 
+	                                                                          ),
+               0,1810,15050                                                        ,
+               Array(false)                                                         )
+      initTabs('dhtmlgoodies_tabViewConf2'                                       ,
+               Array('<B style="color: green">&nbsp;ORCA2_LIM_PISCES&nbsp;  </B>',
+	       	     '<B style="color: green">&nbsp;ORCA1_LIM3_PISCES&nbsp; </B>',
+	       	     '<B style="color: green">&nbsp;AMM12&nbsp;             </B>',
+	       	     '<B style="color: red  ">&nbsp;C1D_PAPA&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE&nbsp;              </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_BFM&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_PISCES&nbsp;       </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_XIOS&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM3&nbsp;        </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM_CFC_C14b&nbsp;</B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_OFF_PISCES&nbsp;  </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_SAS_LIM&nbsp;     </B>' 
+	                                                                          ),
+               0,1810,15050                                                        ,
+               Array(false)                                                         )
+      initTabs('dhtmlgoodies_tabViewHPCC'                         ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC2'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC3'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC4'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC5'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC6'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+    </script>
+    <!-------------------------------------------------------------------------------------------->
+
+  </body>
+
+</html>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/index.php
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/index.php	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/index.php	(revision 6041)
@@ -0,0 +1,354 @@
+<html>
+
+  <head>
+
+    <title>Trusting Dashboard</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <script type="text/javascript" src="html/sortabletable.js"></script>
+    <link type="text/css" rel="StyleSheet" href="html/sortabletable.css" />
+    <link rel="stylesheet" href="html/tab-view.css" type="text/css" media="screen">
+    <script type="text/javascript" src="html/tab-view.js"></script>
+    <style type="text/css">
+      body    { font-family:Helvetica, Arial, Sans-Serif;                      	    	      }
+      a1      { color:#000000; text-decoration:none;                           	    	      }
+      .title  { background:#AABBBB; font-weight:bold;                          	    	      }
+      .even   { background:#eee;                                               	    	      }
+      .odd    { background:#ddd;                                               	    	      }
+      td      { font-family:Arial    ; font-size:10pt; padding:1px 5px 1px 5px;	    	      }
+      .td1    { font-family:Monospace; font-size:10pt; padding:1px 5px 1px 5px;	    	      }
+      .table1 { background:#E6EEC9; border-collapse:collapse;                  	    	      }
+      .table2 { background:#E6EEC9; border-collapse:collapse;                  	    	      }
+      .myh3   { font-weight:bold; font-style:italic; font-family:Arial,Helvetica,sans-serif
+                background-color:#FFD700; border:2px outset #FFFFFF
+                padding: 1px 20px 1px 20px; width:120px; -moz-border-radius:6px 6px 6px 6px;  }
+    </style>
+
+  </head>
+
+  <body>
+
+    <?php
+       ini_set('display_errors', 'Off'); error_reporting(E_ALL);
+       include 'read_trusting.php';
+       $DODS_TGCC="http://dods.extra.cea.fr/store/martin/trusting"; $DODS_IDRIS="http://dodsp.idris.fr/romr005/trusting";
+       $ctx=stream_context_create(array('http'=>array('timeout'=>1)));
+       $test=file_get_contents("${DODS_TGCC}/ORCA2_LIM_PISCES/nemo_v3_6_STABLE/trusting_info.html", 0, $ctx);
+       if ($test == FALSE ) { $LOCATION="./src/martin"; } else { $LOCATION="${DODS_TGCC}"; }
+    ?>
+
+    <!--$file_headers=get_headers("${DODS_TGCC}/ORCA2_LIM_PISCES/nemo_v3_6_STABLE/trusting_info.html");
+       if ($file_headers[0] == '' ) { $LOCATION="./src/martin"; } else { $LOCATION="${DODS_TGCC}"; }-->
+
+    <!-----Begin NEMO trust----->
+    <div id="dhtmlgoodies_tabViewNEMO">
+
+      <!-----Begin v36 trust----->
+      <?php $BRANCH="nemo_v3_6_STABLE" ?>
+      <div class="dhtmlgoodies_aTab">
+	<div id="dhtmlgoodies_tabViewConf">
+
+	  <!-----Begin O2LP trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA2_LIM_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html"); ?>
+	    <div id="dhtmlgoodies_tabViewHPCC">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-1" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-1"),
+	                   [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-2" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-2"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O2LP trust----->
+
+	  <!-----Begin O1L3P trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA1_LIM3_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC2">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-3" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-3"),
+	                   [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-4" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-4"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O1L3P trust----->
+
+	  <!-----Begin AMM12 trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="AMM12"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC3">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-5" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-5"),
+	                   [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-6" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-6"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End AMM12 trust----->
+
+	</div>
+      </div>
+      <!-----End v36 trust----->
+
+
+      <!-----Begin trunk trust----->
+      <?php $BRANCH="trunk" ?>
+      <div class="dhtmlgoodies_aTab">
+	<div id="dhtmlgoodies_tabViewConf2">
+
+	  <!-----Begin O2LP trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA2_LIM_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC4">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-7" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-7"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End   Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-8" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-8"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O2LP trust----->
+
+	  <!-----Begin O1L3P trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="ORCA1_LIM3_PISCES"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC5">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-9" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-9"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End   Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-10" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-10"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O1L3P trust----->
+
+	  <!-----Begin AMM12 trust----->
+	  <div class="dhtmlgoodies_aTab">
+	    <?php $CONF="AMM12"; echo file_get_contents("$LOCATION/$CONF/$BRANCH/trusting_info.html") ?>
+	    <div id="dhtmlgoodies_tabViewHPCC6">
+
+	      <!-----Begin Curie trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-11" cellspacing="1">
+		  <?php read_trusting("$LOCATION/$CONF/$BRANCH/trusting_martin_X64_CURIE_cron.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-11"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End   Curie trust----->
+
+	      <!-----Begin Ada trust----->
+	      <div class="dhtmlgoodies_aTab">
+		<table class="sort-table" id="table-12" cellspacing="1">
+		  <?php read_trusting("${DODS_IDRIS}/$CONF/$BRANCH/trusting_romr005_X64_ADA_at.txt") ?>
+		</table>
+		<script type="text/javascript">
+		  var st = new SortableTable( document.getElementById("table-12"),
+		           [<?php print substr(str_repeat("\"String\",", $num),0,-1); ?>]);
+		  st.sort(0, true);
+		</script>
+	      </div>
+	      <!-----End Ada trust----->
+
+	    </div>
+	  </div>
+	  <!-----End O1L3P trust----->
+
+	</div>
+      </div>
+      <!-----End trunk trust----->
+
+    </div>
+    <!-----End NEMO trust----->
+
+    <!-------------------------------------------------------------------------------------------->
+    <script type="text/javascript">
+      initTabs('dhtmlgoodies_tabViewNEMO'        ,
+               Array('<B>&nbsp;3.6&nbsp;  </B>',
+	             '<B>&nbsp;trunk&nbsp;</B>' 
+                                                ),
+               0,1820,15100                      ,
+               Array(false)                       )
+      initTabs('dhtmlgoodies_tabViewConf'                                        ,
+               Array('<B style="color: green">&nbsp;ORCA2_LIM_PISCES&nbsp;  </B>',
+	       	     '<B style="color: green">&nbsp;ORCA1_LIM3_PISCES&nbsp; </B>',
+	       	     '<B style="color: green">&nbsp;AMM12&nbsp;             </B>',
+	       	     '<B style="color: red  ">&nbsp;C1D_PAPA&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE&nbsp;              </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_BFM&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_PISCES&nbsp;       </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_XIOS&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM3&nbsp;        </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM_CFC_C14b&nbsp;</B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_OFF_PISCES&nbsp;  </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_SAS_LIM&nbsp;     </B>' 
+	                                                                          ),
+               0,1810,15050                                                        ,
+               Array(false)                                                         )
+      initTabs('dhtmlgoodies_tabViewConf2'                                       ,
+               Array('<B style="color: green">&nbsp;ORCA2_LIM_PISCES&nbsp;  </B>',
+	       	     '<B style="color: green">&nbsp;ORCA1_LIM3_PISCES&nbsp; </B>',
+	       	     '<B style="color: green">&nbsp;AMM12&nbsp;             </B>',
+	       	     '<B style="color: red  ">&nbsp;C1D_PAPA&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE&nbsp;              </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_BFM&nbsp;          </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_PISCES&nbsp;       </B>',
+	       	     '<B style="color: red  ">&nbsp;GYRE_XIOS&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM&nbsp;         </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM3&nbsp;        </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_LIM_CFC_C14b&nbsp;</B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_OFF_PISCES&nbsp;  </B>',
+	       	     '<B style="color: red  ">&nbsp;ORCA2_SAS_LIM&nbsp;     </B>' 
+	                                                                          ),
+               0,1810,15050                                                        ,
+               Array(false)                                                         )
+      initTabs('dhtmlgoodies_tabViewHPCC'                         ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC2'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC3'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC4'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC5'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+      initTabs('dhtmlgoodies_tabViewHPCC6'                        ,
+               Array('<B>&nbsp;TGCC&nbsp;/&nbsp;curie&nbsp;</B>',
+	             '<B>&nbsp;IDRIS&nbsp;/&nbsp;ada&nbsp; </B>' ),
+               0,1800,15000                                       ,
+               Array(false)                                        )
+    </script>
+    <!-------------------------------------------------------------------------------------------->
+
+  </body>
+
+</html>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/read_trusting.php
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/read_trusting.php	(revision 6041)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/TRUST/web/read_trusting.php	(revision 6041)
@@ -0,0 +1,52 @@
+
+<?php
+
+$num=1;
+
+function read_trusting ($file) { 
+
+  global $num;
+  $row = 1;
+
+  if (($handle = fopen($file, "r")) !== FALSE) {
+
+    while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
+
+      switch ($row) {
+        case 1: 
+	  $num1 = count($data);
+	  print("<thead>\n\n"); print("<tr class=\"title\">\n");
+	  break;
+        default:	
+	  if   ( $row % 2 == 1 ) { print("<tr class=\"odd\">\n") ; }
+	  else                   { print("<tr class=\"even\">\n"); }
+      }
+
+      $num = count($data);
+      #echo "<p> $num champs ligne $row: <br /></p>\n";
+
+      for ($c=0; $c<$num1; $c++) {
+        #echo $data[$c] . "<br />\n";
+	if ($c > $num ) { $var=""; } else { $var=trim($data[$c]); }
+
+	switch ($var) { 
+	  case "FAILED"   : print("<td bgcolor=\"#FF6666\">".$var."</td>\n"); break;
+	  case "Different": print("<td bgcolor=\"#FFFF99\">".$var."</td>\n"); break;
+	  case "OK"       : print("<td bgcolor=\"#92CA89\">".$var."</td>\n"); break;
+	  default         : print("<td>".$var."</td>\n")                           ;
+	}
+
+      }
+
+      print("</tr>\n\n");
+      if ( $row == 1 ) { print("</thead>\n\n");	print("<tbody>\n\n"); }
+      $row++;
+    }
+
+    fclose($handle);
+  }
+
+  print("</tbody>\n");
+}
+
+?>
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-amm12.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-amm12.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-amm12.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_bdy key_tide key_dynspg_ts key_ldfslp key_zdfgls key_vvl key_diainstant key_mpp_mpi key_iomput
+  key_bdy key_tide key_ldfslp key_zdfgls key_vvl key_diainstant key_mpp_mpi key_iomput
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-gyre.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-gyre.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-gyre.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_dynspg_flt key_ldfslp key_zdftke key_iomput key_mpp_mpi key_nosignedzero
+  key_ldfslp key_zdftke key_iomput key_mpp_mpi key_nosignedzero
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-gyre_pisces.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-gyre_pisces.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-gyre_pisces.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_dynspg_flt key_ldfslp key_zdftke key_top key_pisces_reduced key_iomput key_mpp_mpi
+  key_ldfslp key_zdftke key_top key_pisces_reduced key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_asminc
+  key_trabbl key_lim2 key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_asminc
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim3.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim3.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim3.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_trabbl key_lim3 key_vvl key_dynspg_ts key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_asminc
+  key_trabbl key_lim3 key_vvl key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi key_diaobs key_asminc
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim_cfc.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim_cfc.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim_cfc.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_top key_cfc key_c14b key_iomput key_mpp_mpi
+  key_trabbl key_lim2 key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_top key_cfc key_c14b key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim_pisces.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim_pisces.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_lim_pisces.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_top key_pisces key_iomput key_mpp_mpi
+  key_trabbl key_lim2 key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_top key_pisces key_iomput key_mpp_mpi
Index: /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_sas_lim.cfg
===================================================================
--- /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_sas_lim.cfg	(revision 6040)
+++ /branches/2015/dev_r5776_UKMO2_OBS_efficiency_improvs/NEMOGCM/fcm-make/inc/keys-orca2_sas_lim.cfg	(revision 6041)
@@ -1,2 +1,2 @@
 preprocess.prop{fpp.defs} = \
-  key_trabbl key_lim2 key_dynspg_flt key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi
+  key_trabbl key_lim2 key_diaeiv key_ldfslp key_traldf_c2d key_traldf_eiv key_dynldf_c3d key_zdftke key_zdfddm key_zdftmx key_iomput key_mpp_mpi
