Index: /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/CONFIG/COMODO_IW/EXP00/namelist_cfg
===================================================================
--- /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/CONFIG/COMODO_IW/EXP00/namelist_cfg	(revision 9550)
+++ /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/CONFIG/COMODO_IW/EXP00/namelist_cfg	(revision 9551)
@@ -337,9 +337,9 @@
 !----------------------------------------------------------------------------------
    !                       !  Operator type:
-   ln_traldf_lap    =  .true.   !  laplacian operator
+   ln_traldf_lap    =  .false.  !  laplacian operator
    ln_traldf_bilap  =  .false.  !  bilaplacian operator
    !                       !  Direction of action:
    ln_traldf_level  =  .false.  !  iso-level
-   ln_traldf_hor    =  .true.  !  horizontal (geopotential)   (needs "key_ldfslp" when ln_sco=T)
+   ln_traldf_hor    =  .true.   !  horizontal (geopotential)   (needs "key_ldfslp" when ln_sco=T)
    ln_traldf_iso    =  .false.  !  iso-neutral                 (needs "key_ldfslp")
    ln_traldf_grif   =  .false.  !  use griffies triads
Index: /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/CONFIG/cfg.txt
===================================================================
--- /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/CONFIG/cfg.txt	(revision 9550)
+++ /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/CONFIG/cfg.txt	(revision 9551)
@@ -11,6 +11,3 @@
 GYRE OPA_SRC
 ORCA2_LIM OPA_SRC LIM_SRC_2 NST_SRC
-ORCA2LIM3_16 OPA_SRC LIM_SRC_3 NST_SRC
-RIDGE OPA_SRC
 COMODO_IW OPA_SRC
-ORCA2LIM3_LONG OPA_SRC LIM_SRC_3 NST_SRC
Index: /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 9550)
+++ /branches/2018/dev_r8864_nemo_v3_6_ZTILDE/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 9551)
@@ -462,8 +462,8 @@
                DO jj = 2, jpjm1
                   DO ji = fs_2, fs_jpim1   ! vector opt.
-                     tilde_e3t_a(ji,jj,jk) =   &
-                    -(  e2u(ji,jj)*fse3u(ji,jj,jk) * ztu(ji,jj,jk) - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * ztu(ji-1,jj  ,jk)       &
-                      + e1v(ji,jj)*fse3v(ji,jj,jk) * ztv(ji,jj,jk) - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * ztv(ji  ,jj-1,jk)  )    &
-                     / ( e1t(ji,jj) * e2t(ji,jj) )
+                     tilde_e3t_a(ji,jj,jk) =   tilde_e3t_a(ji,jj,jk) &
+                     & -(  e2u(ji,jj)*fse3u(ji,jj,jk) * ztu(ji,jj,jk) - e2u(ji-1,jj  )*fse3u(ji-1,jj  ,jk) * ztu(ji-1,jj  ,jk)       &
+                     &   + e1v(ji,jj)*fse3v(ji,jj,jk) * ztv(ji,jj,jk) - e1v(ji  ,jj-1)*fse3v(ji  ,jj-1,jk) * ztv(ji  ,jj-1,jk)  )    &
+                     & / ( e1t(ji,jj) * e2t(ji,jj) )
                   END DO
                END DO
@@ -677,5 +677,5 @@
       ENDIF
 
-      IF((ln_vvl_ztilde .OR. ln_vvl_layer).AND.(.NOT.ll_do_bclinic) ) THEN
+      IF(((ln_vvl_ztilde.AND.(.NOT.ln_vvl_ztilde_as_zstar)) .OR. ln_vvl_layer).AND.(.NOT.ll_do_bclinic) ) THEN
          zhdiv(:,:) = 0.
          DO jk = 1, jpkm1
@@ -691,9 +691,9 @@
 
          DO jk = 1, jpkm1
-            tilde_e3t_a(:,:,jk) = tilde_e3t_a(:,:,jk) - z2dt * fse3t_n(:,:,jk) * & 
+            tilde_e3t_a(:,:,jk) = tilde_e3t_a(:,:,jk) - tildemask(:,:) * z2dt * fse3t_n(:,:,jk) * & 
                                   & (hdivn(:,:,jk) - hdivb(:,:,jk) - zhdiv(:,:))
          END DO
          DO jk = 1, jpkm1
-            fse3t_a(:,:,jk) = fse3t_a(:,:,jk) - z2dt * fse3t_n(:,:,jk) * & 
+            fse3t_a(:,:,jk) = fse3t_a(:,:,jk) - tildemask(:,:) * z2dt * fse3t_n(:,:,jk) * & 
                                   & (hdivn(:,:,jk) - hdivb(:,:,jk) - zhdiv(:,:))
          END DO
@@ -1157,5 +1157,5 @@
       INTEGER ::   jkbot                                               ! bottom level
       LOGICAL ::   l_is_orca                                           ! local logical
-      REAL(wp) :: zmin, zdo, zup, ztap
+      REAL(wp) :: zmin, zdo, zup, ztap, zsmall
       REAL(wp), POINTER, DIMENSION(:,:)   :: zs                        ! Surface interface depth anomaly
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zw                        ! Interface depth anomaly
@@ -1167,9 +1167,12 @@
 
  
-      nmet=1 
 !      nmet=0 ! Original method (Surely wrong)
-!      nmet=1 ! Interface interpolation
-!      nmet=2 ! Internal interfaces interpolation only, spread barotropic increment
-      ztap = 0.1_wp ! Minimum fraction of T-point thickness at cell interfaces
+!      nmet= 1 ! Interface interpolation
+      nmet=2 ! Internal interfaces interpolation only, spread barotropic increment
+! Note that we kept surface weighted interpolation for barotropic increment to be compliant
+! with what is done in surface pressure module.
+
+      ztap = 0._wp ! Minimum fraction of T-point thickness at cell interfaces
+      zsmall = 1e-3_wp
 
       IF ( (nmet==1).OR.(nmet==2) ) THEN
@@ -1183,25 +1186,22 @@
             zw(:,:,:) =  0._wp    
             !
-            DO jj = 1, jpj
-               DO ji = 1, jpi
-                  jkbot = mbkt(ji,jj)
-                  DO jk=jkbot,1,-1
-                     zw(ji,jj,jk) = zw(ji,jj,jk+1) - pe3_in(ji,jj,jk) + e3t_0(ji,jj,jk)
-                  END DO
-               END DO
+            DO jk=2,jpk
+               zw(:,:,jk) = zw(:,:,jk-1) + pe3_in(:,:,jk-1)*tmask(:,:,jk-1)
             END DO 
-            !
+            ! Interface depth anomalies:
+            DO jk=1,jpkm1
+               zw(:,:,jk) = zw(:,:,jk) - zw(:,:,jpk) + ht_0(:,:)
+            END DO
+            zw(:,:,jpk) = ht_0(:,:)
             !
             IF (nmet==2) THEN        ! Consider "internal" interfaces only
                zs(:,:) = - zw(:,:,1) ! Save surface anomaly (ssh)
                !
-               zw(:,:,:) = 0._wp
                DO jj = 1, jpj
                   DO ji = 1, jpi
-                     jkbot = mbkt(ji,jj)
-                     DO jk=jkbot,1,-1
-                        zw(ji,jj,jk) = zw(ji,jj,jk+1) - ( pe3_in(ji,jj,jk)                     &
+                     DO jk=1,jpk
+                        zw(ji,jj,jk) = (zw(ji,jj,jk) + zs(ji,jj))                                          &
                                      & * ht_0(ji,jj) / (ht_0(ji,jj) + zs(ji,jj) + 1._wp - tmask(ji,jj,1))  &
-                                     & - e3t_0(ji,jj,jk)) * tmask(ji,jj,jk)
+                                     & * tmask(ji,jj,jk)
                      END DO
                   END DO
@@ -1236,28 +1236,22 @@
                   ! Correction at last level:
                   jkbot = mbku(ji,jj)
-                  pe3_out(ji,jj,jkbot) = -0.5_wp * umask(ji,jj,jkbot) * r1_e12u(ji,jj) &
-                        &                    * (   e12t(ji  ,jj) * zw(ji  ,jj,jkbot)   &
-                        &                        + e12t(ji+1,jj) * zw(ji+1,jj,jkbot)   )
-                  !
-                  ! If there is a step, taper bottom interface:
-                  IF (hu_0(ji,jj) < 0.5_wp * ( ht_0(ji,jj) + ht_0(ji+1,jj) ) ) THEN
-                     IF ( ht_0(ji+1,jj) < ht_0(ji,jj) ) THEN
-!                        zmin = ztap * pe3_in(ji+1,jj,jkbot)
-                        zmin = ztap * (-zw(ji+1,jj,jkbot)+e3t_0(ji+1,jj,jkbot))
-                     ELSE
-!                        zmin = ztap * pe3_in(ji  ,jj,jkbot)
-                        zmin = ztap * (-zw(ji,jj,jkbot)+e3t_0(ji,jj,jkbot))
+                  zdo   = hu_0(ji,jj)
+                  DO jk=jkbot,1,-1
+                     zup = 0.5_wp * ( zw(ji  ,jj,jk) + zw(ji+1,jj,jk) ) 
+                     !
+                     ! If there is a step, taper bottom interface:
+                     IF ((hu_0(ji,jj) < 0.5_wp * ( ht_0(ji,jj) + ht_0(ji+1,jj) ) ).AND.(zup>zdo)) THEN
+                        IF ( ht_0(ji+1,jj) < ht_0(ji,jj) ) THEN
+!                           zmin = ztap * pe3_in(ji+1,jj,jk)
+                           zmin = ztap * (zw(ji+1,jj,jk+1)-zw(ji+1,jj,jk))
+                        ELSE
+!                           zmin = ztap * pe3_in(ji  ,jj,jk)
+                           zmin = ztap * (zw(ji  ,jj,jk+1)-zw(ji  ,jj,jk))
+                        ENDIF
+                        zup = MIN(zup, zdo-zmin)
                      ENDIF
-                     zmin = -e3u_0(ji,jj,jkbot) + zmin
-                     pe3_out(ji,jj,jkbot) = MAX(pe3_out(ji,jj,jkbot), zmin)
-                  ENDIF
-                  !
-                  zdo =  -pe3_out(ji,jj,jkbot)
-                  DO jk=jkbot-1,1,-1
-                     zup = 0.5_wp * umask(ji,jj,jk) * r1_e12u(ji  ,jj) &
-                              &                     *(   e12t(ji  ,jj) * zw(ji  ,jj,jk)  &
-                              &                         +e12t(ji+1,jj) * zw(ji+1,jj,jk)  )
-                     pe3_out(ji,jj,jk) = zdo - zup  
-                     zdo =  zdo - pe3_out(ji,jj,jk)
+                     zup = MIN(zup, zdo-zsmall)
+                     pe3_out(ji,jj,jk) = zdo - zup - e3u_0(ji,jj,jk)
+                     zdo = zup
                   END DO
                END DO
@@ -1309,29 +1303,22 @@
                   ! Correction at last level:
                   jkbot = mbkv(ji,jj)
-                  pe3_out(ji,jj,jkbot) = -0.5_wp * vmask(ji,jj,jkbot) * r1_e12v(ji,jj) &
-                        &                    * (   e12t(ji,jj  ) * zw(ji,jj  ,jkbot)   &
-                        &                        + e12t(ji,jj+1) * zw(ji,jj+1,jkbot)   )
-                  !
-                  ! If there is a step, taper bottom interface:
-                  IF (hv_0(ji,jj) < 0.5_wp * ( ht_0(ji,jj) + ht_0(ji,jj+1) ) ) THEN
-                     IF ( ht_0(ji,jj+1) < ht_0(ji,jj) ) THEN
-!                        zmin = ztap * pe3_in(ji,jj+1,jkbot)
-                        zmin = ztap * (-zw(ji,jj+1,jkbot)+e3t_0(ji,jj+1,jkbot))
-                     ELSE
-!                        zmin = ztap * pe3_in(ji,jj  ,jkbot)
-                        zmin = ztap * (-zw(ji,jj,jkbot)+e3t_0(ji,jj,jkbot))
+                  zdo   = hv_0(ji,jj)
+                  DO jk=jkbot,1,-1
+                     zup = 0.5_wp * ( zw(ji,jj  ,jk) + zw(ji,jj+1,jk) )
+                     !
+                     ! If there is a step, taper bottom interface:
+                     IF ((hv_0(ji,jj) < 0.5_wp * ( ht_0(ji,jj) + ht_0(ji,jj+1) ) ).AND.(zup>zdo)) THEN
+                        IF ( ht_0(ji,jj+1) < ht_0(ji,jj) ) THEN
+!                           zmin = ztap * pe3_in(ji,jj+1,jk)
+                           zmin = ztap * (zw(ji,jj+1,jk+1)-zw(ji,jj+1,jk))
+                        ELSE
+!                           zmin = ztap * pe3_in(ji  ,jj,jk)
+                           zmin = ztap * (zw(ji,jj  ,jk+1)-zw(ji,jj  ,jk))
+                        ENDIF
+                        zup = MIN(zup, zdo-zmin)                        
                      ENDIF
-                     zmin = -e3v_0(ji,jj,jkbot) + zmin
-                     pe3_out(ji,jj,jkbot) = MAX(pe3_out(ji,jj,jkbot), zmin)
-                  ENDIF
-                  !
-                  zdo =  -pe3_out(ji,jj,jkbot)
-                  DO jk=jkbot-1,1,-1
-                     zup = 0.5_wp * vmask(ji,jj,jk) * r1_e12v(ji,jj  ) &
-                              &                     *  ( e12t(ji,jj  ) * zw(ji,jj  ,jk) &
-                              &                         +e12t(ji,jj+1) * zw(ji,jj+1,jk) )
-                     !
-                     pe3_out(ji,jj,jk) = zdo - zup 
-                     zdo =  zdo - pe3_out(ji,jj,jk)
+                     zup = MIN(zup, zdo-zsmall)
+                     pe3_out(ji,jj,jk) = zdo - zup - e3v_0(ji,jj,jk)
+                     zdo = zup
                   END DO
                END DO
@@ -1386,47 +1373,39 @@
                   ! bottom correction:
                   jkbot = MIN(mbku(ji,jj), mbku(ji,jj+1)) 
-                  pe3_out(ji,jj,jkbot) = -0.25_wp * umask(ji,jj,jkbot) * umask(ji,jj+1,jkbot) * r1_e12f(ji,jj) &
-                        &                         * (  e12t(ji  ,jj  ) * zw(ji  ,jj  ,jkbot)   &
-                        &                            + e12t(ji+1,jj  ) * zw(ji+1,jj  ,jkbot)   &
-                        &                            + e12t(ji  ,jj+1) * zw(ji  ,jj+1,jkbot)   &
-                        &                            + e12t(ji+1,jj+1) * zw(ji+1,jj+1,jkbot)   )
-                  !
-                  ! If there is a step, taper bottom interface:
-                  IF (hf_0(ji,jj) < 0.5_wp * ( hu_0(ji,jj  ) + hu_0(ji,jj+1) ) ) THEN
-                     IF ( hu_0(ji,jj+1) < hu_0(ji,jj) ) THEN
-                        IF ( ht_0(ji+1,jj+1) < ht_0(ji  ,jj+1) ) THEN
-!                           zmin = ztap * pe3_in(ji+1,jj+1,jkbot)
-                           zmin = ztap * (-zw(ji+1,jj+1,jkbot)+e3t_0(ji+1,jj+1,jkbot))
+                  zdo = hf_0(ji,jj)
+                  DO jk=jkbot,1,-1
+                     zup =  0.25_wp * (  zw(ji  ,jj  ,jk)  & 
+                           &           + zw(ji+1,jj  ,jk)  & 
+                           &           + zw(ji  ,jj+1,jk)  & 
+                           &           + zw(ji+1,jj+1,jk)  )
+                     !
+                     ! If there is a step, taper bottom interface:
+                     IF ((hf_0(ji,jj) < 0.5_wp * ( hu_0(ji,jj  ) + hu_0(ji,jj+1) ) ).AND.(zup>zdo)) THEN
+                        IF ( hu_0(ji,jj+1) < hu_0(ji,jj) ) THEN
+                           IF ( ht_0(ji+1,jj+1) < ht_0(ji  ,jj+1) ) THEN
+!                              zmin = ztap * pe3_in(ji+1,jj+1,jk)
+                              zmin = ztap * (zw(ji+1,jj+1,jk+1)-zw(ji+1,jj+1,jk))
+                           ELSE
+!                              zmin = ztap * pe3_in(ji  ,jj+1,jk)
+                              zmin = ztap * (zw(ji  ,jj+1,jk+1)-zw(ji  ,jj+1,jk))
+                           ENDIF
                         ELSE
-!                           zmin = ztap * pe3_in(ji  ,jj+1,jkbot)
-                           zmin = ztap * (-zw(ji,jj+1,jkbot)+e3t_0(ji,jj+1,jkbot))
+                           IF ( ht_0(ji+1,jj  ) < ht_0(ji  ,jj  ) ) THEN
+!                              zmin = ztap * pe3_in(ji+1,jj  ,jk)
+                              zmin = ztap * (zw(ji+1,jj  ,jk+1)-zw(ji+1,jj  ,jk))
+                           ELSE
+!                              zmin = ztap * pe3_in(ji  ,jj  ,jk)
+                              zmin = ztap * (zw(ji  ,jj  ,jk+1)-zw(ji  ,jj  ,jk))
+                           ENDIF
                         ENDIF
-                     ELSE
-                        IF ( ht_0(ji+1,jj  ) < ht_0(ji  ,jj  ) ) THEN
-!                           zmin = ztap * pe3_in(ji+1,jj  ,jkbot)
-                           zmin = ztap * (-zw(ji+1,jj,jkbot)+e3t_0(ji+1,jj,jkbot))
-                        ELSE
-!                           zmin = ztap * pe3_in(ji  ,jj  ,jkbot)
-                           zmin = ztap * (-zw(ji,jj,jkbot)+e3t_0(ji,jj,jkbot))
-                        ENDIF
+                        zup = MIN(zup, zdo-zmin)
                      ENDIF
-                     zmin = -e3f_0(ji,jj,jkbot) + zmin
-                     pe3_out(ji,jj,jkbot) = MAX(pe3_out(ji,jj,jkbot), zmin)
-                  ENDIF
-                  !
-                  zdo =  -pe3_out(ji,jj,jkbot)
-                  DO jk=jkbot-1,1,-1
-                     zup =  0.25_wp * umask(ji,jj,jk) * umask(ji,jj+1,jk) * r1_e12f(ji,jj) &
-                           &        * (  e12t(ji  ,jj  ) * zw(ji  ,jj  ,jk)  & 
-                           &           + e12t(ji+1,jj  ) * zw(ji+1,jj  ,jk)  & 
-                           &           + e12t(ji  ,jj+1) * zw(ji  ,jj+1,jk)  & 
-                           &           + e12t(ji+1,jj+1) * zw(ji+1,jj+1,jk)  )
-                     pe3_out(ji,jj,jk) = zdo - zup 
+                     zup = MIN(zup, zdo-zsmall)
                      !
-                     zdo =  zdo - pe3_out(ji,jj,jk)                                    
+                     pe3_out(ji,jj,jk) = zdo - zup - e3f_0(ji,jj,jk)
+                     zdo = zup
                   END DO
-                  !
-               END DO
-            END DO 
+               END DO
+            END DO
          ENDIF
          !
@@ -1491,4 +1470,5 @@
 
    END SUBROUTINE dom_vvl_interpol
+
 
 
@@ -2669,4 +2649,5 @@
                   ztmpd = dsm(ji,jj)
                   zh2   = ztmph * exp(-(gdepw_0(ji,jj,jk)-gdepw_0(ji,jj,i_int_bot(ji,jj)+1))/ztmpd)
+                  zh2 = MAX(zh2,0.001_wp) ! Extend tolerance a bit for stability reasons (to be explored)
                   zdiff = cush_max(gdepw_0(ji,jj,jk)-zwdw(ji,jj,jk), zh2 )
                   zwdw(ji,jj,jk) = MAX(zwdw(ji,jj,jk), gdepw_0(ji,jj,jk) - zdiff)
