Index: branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90
===================================================================
--- branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 5866)
+++ branches/2015/dev_r5836_NOC3_vvl_by_default/NEMOGCM/NEMO/OPA_SRC/DYN/dynadv_ubs.F90	(revision 5883)
@@ -100,10 +100,9 @@
       zlu_uv(:,:,:,:) = 0._wp 
       zlv_vu(:,:,:,:) = 0._wp 
-
-      IF( l_trddyn ) THEN           ! Save ua and va trends
+      !
+      IF( l_trddyn ) THEN           ! trends: store the input trends
          zfu_uw(:,:,:) = ua(:,:,:)
          zfv_vw(:,:,:) = va(:,:,:)
       ENDIF
-
       !                                      ! =========================== !
       DO jk = 1, jpkm1                       !  Laplacian of the velocity  !
@@ -115,5 +114,4 @@
          DO jj = 2, jpjm1                          ! laplacian
             DO ji = fs_2, fs_jpim1   ! vector opt.
-               !
                zlu_uu(ji,jj,jk,1) = ( ub (ji+1,jj  ,jk) - 2.*ub (ji,jj,jk) + ub (ji-1,jj  ,jk) ) * umask(ji,jj,jk)
                zlv_vv(ji,jj,jk,1) = ( vb (ji  ,jj+1,jk) - 2.*vb (ji,jj,jk) + vb (ji  ,jj-1,jk) ) * vmask(ji,jj,jk)
@@ -136,5 +134,5 @@
       CALL lbc_lnk( zlv_vv(:,:,:,1), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,1), 'V', 1. )
       CALL lbc_lnk( zlv_vv(:,:,:,2), 'V', 1. )   ;   CALL lbc_lnk( zlv_vu(:,:,:,2), 'V', 1. ) 
-      
+      !
       !                                      ! ====================== !
       !                                      !  Horizontal advection  !
@@ -149,9 +147,9 @@
                zvj = ( vn(ji,jj,jk) + vn(ji  ,jj+1,jk) )
                !
-               IF (zui > 0) THEN   ;   zl_u = zlu_uu(ji  ,jj,jk,1)
-               ELSE                ;   zl_u = zlu_uu(ji+1,jj,jk,1)
-               ENDIF
-               IF (zvj > 0) THEN   ;   zl_v = zlv_vv(ji,jj  ,jk,1)
-               ELSE                ;   zl_v = zlv_vv(ji,jj+1,jk,1)
+               IF( zui > 0 ) THEN   ;   zl_u = zlu_uu(ji  ,jj,jk,1)
+               ELSE                 ;   zl_u = zlu_uu(ji+1,jj,jk,1)
+               ENDIF
+               IF( zvj > 0 ) THEN   ;   zl_v = zlv_vv(ji,jj  ,jk,1)
+               ELSE                 ;   zl_v = zlv_vv(ji,jj+1,jk,1)
                ENDIF
                !
@@ -165,9 +163,9 @@
                zfuj = ( zfu(ji,jj,jk) + zfu(ji  ,jj+1,jk) )
                zfvi = ( zfv(ji,jj,jk) + zfv(ji+1,jj  ,jk) )
-               IF (zfuj > 0) THEN   ;    zl_v = zlv_vu( ji  ,jj  ,jk,1)
-               ELSE                 ;    zl_v = zlv_vu( ji+1,jj,jk,1)
-               ENDIF
-               IF (zfvi > 0) THEN   ;    zl_u = zlu_uv( ji,jj  ,jk,1)
-               ELSE                 ;    zl_u = zlu_uv( ji,jj+1,jk,1)
+               IF( zfuj > 0 ) THEN   ;    zl_v = zlv_vu( ji  ,jj  ,jk,1)
+               ELSE                  ;    zl_v = zlv_vu( ji+1,jj,jk,1)
+               ENDIF
+               IF( zfvi > 0 ) THEN   ;    zl_u = zlu_uv( ji,jj  ,jk,1)
+               ELSE                  ;    zl_u = zlu_uv( ji,jj+1,jk,1)
                ENDIF
                !
@@ -190,5 +188,5 @@
          END DO
       END DO
-      IF( l_trddyn ) THEN                          ! save the horizontal advection trend for diagnostic
+      IF( l_trddyn ) THEN                          ! trends: send trends to trddyn for diagnostic
          zfu_uw(:,:,:) = ua(:,:,:) - zfu_uw(:,:,:)
          zfv_vw(:,:,:) = va(:,:,:) - zfv_vw(:,:,:)
@@ -197,52 +195,51 @@
          zfv_t(:,:,:) = va(:,:,:)
       ENDIF
-
       !                                      ! ==================== !
       !                                      !  Vertical advection  !
-      DO jk = 1, jpkm1                       ! ==================== !
-         !                                         ! Vertical volume fluxesÊ
-         zfw(:,:,jk) = 0.25 * e1e2t(:,:) * wn(:,:,jk)
-         !
-         IF( jk == 1 ) THEN                        ! surface/bottom advective fluxes                   
-            zfu_uw(:,:,jpk) = 0.e0                      ! Bottom  value : flux set to zero
-            zfv_vw(:,:,jpk) = 0.e0
-            !                                           ! Surface value :
-            IF( .NOT.ln_linssh ) THEN                        ! variable volume : flux set to zero
-               zfu_uw(:,:, 1 ) = 0._wp
-               zfv_vw(:,:, 1 ) = 0._wp
-            ELSE                                             ! constant volume : advection through the surface
-               DO jj = 2, jpjm1
-                  DO ji = fs_2, fs_jpim1
-                     zfu_uw(ji,jj, 1 ) = 2._wp * ( zfw(ji,jj,1) + zfw(ji+1,jj  ,1) ) * un(ji,jj,1)
-                     zfv_vw(ji,jj, 1 ) = 2._wp * ( zfw(ji,jj,1) + zfw(ji  ,jj+1,1) ) * vn(ji,jj,1)
-                  END DO
-               END DO
-            ENDIF
-         ELSE                                      ! interior fluxes
-            DO jj = 2, jpjm1
-               DO ji = fs_2, fs_jpim1   ! vector opt.
-                  zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji+1,jj  ,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) )
-                  zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji  ,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) )
-               END DO
-            END DO
-         ENDIF
-      END DO
-      DO jk = 1, jpkm1                             ! divergence of vertical momentum flux divergence
-         DO jj = 2, jpjm1 
-            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) )    &
-                  &  / ( e1e2u(ji,jj) * e3u_n(ji,jj,jk) )
-               va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) )    &
-                  &  / ( e1e2v(ji,jj) * e3v_n(ji,jj,jk) )
-            END DO
-         END DO
-      END DO
-      !
-      IF( l_trddyn ) THEN                          ! save the vertical advection trend for diagnostic
+      !                                      ! ==================== !
+      DO jj = 2, jpjm1                             ! surface/bottom advective fluxes set to zero                  
+         DO ji = fs_2, fs_jpim1
+            zfu_uw(ji,jj,jpk) = 0._wp
+            zfv_vw(ji,jj,jpk) = 0._wp
+            zfu_uw(ji,jj, 1 ) = 0._wp
+            zfv_vw(ji,jj, 1 ) = 0._wp
+         END DO
+      END DO
+      IF( ln_linssh ) THEN                         ! constant volume : advection through the surface
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zfu_uw(ji,jj,1) = 0.5_wp * ( e1e2t(ji,jj) * wn(ji,jj,1) + e1e2t(ji+1,jj) * wn(ji+1,jj,1) ) * un(ji,jj,1)
+               zfv_vw(ji,jj,1) = 0.5_wp * ( e1e2t(ji,jj) * wn(ji,jj,1) + e1e2t(ji,jj+1) * wn(ji,jj+1,1) ) * vn(ji,jj,1)
+            END DO
+         END DO
+      ENDIF
+      DO jk = 2, jpkm1                          ! interior fluxes
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1
+               zfw(ji,jj,jk) = 0.25 * e1e2t(ji,jj) * wn(ji,jj,jk)
+            END DO
+         END DO
+         DO jj = 2, jpjm1
+            DO ji = fs_2, fs_jpim1   ! vector opt.
+               zfu_uw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji+1,jj,jk) ) * ( un(ji,jj,jk) + un(ji,jj,jk-1) )
+               zfv_vw(ji,jj,jk) = ( zfw(ji,jj,jk)+ zfw(ji,jj+1,jk) ) * ( vn(ji,jj,jk) + vn(ji,jj,jk-1) )
+            END DO
+         END DO
+      END DO
+      DO jk = 1, jpkm1                          ! divergence of vertical momentum flux divergence
+         DO jj = 2, jpjm1
+            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) ) * r1_e1e2u(ji,jj) / e3u_n(ji,jj,jk)
+               va(ji,jj,jk) =  va(ji,jj,jk) - ( zfv_vw(ji,jj,jk) - zfv_vw(ji,jj,jk+1) ) * r1_e1e2v(ji,jj) / e3v_n(ji,jj,jk)
+            END DO
+         END DO
+      END DO
+      !
+      IF( l_trddyn ) THEN                       ! save the vertical advection trend for diagnostic
          zfu_t(:,:,:) = ua(:,:,:) - zfu_t(:,:,:)
          zfv_t(:,:,:) = va(:,:,:) - zfv_t(:,:,:)
          CALL trd_dyn( zfu_t, zfv_t, jpdyn_zad, kt )
       ENDIF
-      !                                            ! Control print
+      !                                         ! Control print
       IF(ln_ctl)   CALL prt_ctl( tab3d_1=ua, clinfo1=' ubs2 adv - Ua: ', mask1=umask,   &
          &                       tab3d_2=va, clinfo2=           ' Va: ', mask2=vmask, clinfo3='dyn' )
