Index: branches/2014/dev_r4650_UKMO3_masked_damping/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90
===================================================================
--- branches/2014/dev_r4650_UKMO3_masked_damping/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 4668)
+++ branches/2014/dev_r4650_UKMO3_masked_damping/NEMOGCM/NEMO/OPA_SRC/DYN/dynvor.F90	(revision 5086)
@@ -15,4 +15,5 @@
    !!            3.2  ! 2009-04  (R. Benshila)  vvl: correction of een scheme
    !!            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 
    !!----------------------------------------------------------------------
 
@@ -29,6 +30,6 @@
    USE dommsk         ! ocean mask
    USE dynadv         ! momentum advection (use ln_dynadv_vec value)
-   USE trdmod         ! ocean dynamics trends 
-   USE trdmod_oce     ! ocean variables trends
+   USE trd_oce        ! trends: ocean variables
+   USE trddyn         ! trend manager: dynamics
    USE lbclnk         ! ocean lateral boundary conditions (or mpp link)
    USE prtctl         ! Print control
@@ -50,4 +51,5 @@
    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
@@ -73,5 +75,6 @@
       !! ** Action : - Update (ua,va) with the now vorticity term trend
       !!             - save the trends in (ztrdu,ztrdv) in 2 parts (relative
-      !!               and planetary vorticity trends) ('key_trddyn')
+      !!               and planetary vorticity trends) and send them to trd_dyn 
+      !!               for futher diagnostics (l_trddyn=T)
       !!----------------------------------------------------------------------
       INTEGER, INTENT( in ) ::   kt   ! ocean time-step index
@@ -108,5 +111,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
@@ -114,6 +117,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
             CALL vor_ene( kt, ntot, ua, va )                ! total vorticity
@@ -127,5 +129,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
@@ -133,6 +135,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
             CALL vor_ens( kt, ntot, ua, va )                ! total vorticity
@@ -146,5 +147,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
@@ -152,6 +153,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
             CALL vor_mix( kt )                               ! total vorticity (mix=ens-ene)
@@ -165,5 +165,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_rvo, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_rvo, kt )
             ztrdu(:,:,:) = ua(:,:,:)
             ztrdv(:,:,:) = va(:,:,:)
@@ -171,6 +171,5 @@
             ztrdu(:,:,:) = ua(:,:,:) - ztrdu(:,:,:)
             ztrdv(:,:,:) = va(:,:,:) - ztrdv(:,:,:)
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_pvo, 'DYN', kt )
-            CALL trd_mod( ztrdu, ztrdv, jpdyn_trd_dat, 'DYN', kt )
+            CALL trd_dyn( ztrdu, ztrdv, jpdyn_pvo, kt )
          ELSE
             CALL vor_een( kt, ntot, ua, va )                ! total vorticity
@@ -211,6 +210,4 @@
       !!
       !! ** Action : - Update (ua,va) with the now vorticity term trend
-      !!             - save the trends in (ztrdu,ztrdv) in 2 parts (relative
-      !!               and planetary vorticity trends) ('key_trddyn')
       !!
       !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
@@ -328,6 +325,4 @@
       !!
       !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
-      !!             - Save the trends in (ztrdu,ztrdv) in 2 parts (relative
-      !!               and planetary vorticity trends) ('key_trddyn')
       !!
       !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
@@ -444,6 +439,4 @@
       !!
       !! ** Action : - Update (ua,va) arrays with the now vorticity term trend
-      !!             - Save the trends in (ztrdu,ztrdv) in 2 parts (relative 
-      !!               and planetary vorticity trends) ('key_trddyn')
       !!
       !! References : Sadourny, r., 1975, j. atmos. sciences, 32, 680-689.
@@ -557,6 +550,4 @@
       !!
       !! ** Action : - Update (ua,va) with the now vorticity term trend
-      !!             - save the trends in (ztrdu,ztrdv) in 2 parts (relative
-      !!               and planetary vorticity trends) ('key_trddyn')
       !!
       !! References : Arakawa and Lamb 1980, Mon. Wea. Rev., 109, 18-36
@@ -601,20 +592,34 @@
             IF( ierr /= 0 )   CALL ctl_stop( 'STOP', 'dyn:vor_een : unable to allocate arrays' )
          ENDIF
-         ze3f(:,:,:) = 0.d0
+         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)
-         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
+
+         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
@@ -715,5 +720,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
+      NAMELIST/namdyn_vor/ ln_dynvor_ens, ln_dynvor_ene, ln_dynvor_mix, ln_dynvor_een, ln_dynvor_een_old
       !!----------------------------------------------------------------------
 
@@ -736,4 +741,5 @@
          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
       ENDIF
 
@@ -759,4 +765,5 @@
       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
 
@@ -767,5 +774,5 @@
       IF( ln_dynvor_ens )   nvor =  1
       IF( ln_dynvor_mix )   nvor =  2
-      IF( ln_dynvor_een )   nvor =  3
+      IF( ln_dynvor_een .or. ln_dynvor_een_old )   nvor =  3
       IF( lk_esopa      )   nvor = -1
       
