Index: /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90
===================================================================
--- /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 2969)
+++ /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/DIA/diawri.F90	(revision 2970)
@@ -33,4 +33,5 @@
    USE sbcssr          ! restoring term toward SST/SSS climatology
    USE phycst          ! physical constants
+   USE dynadv          ! dynamics: vector invariant versus flux form
    USE zdfmxl          ! mixed layer
    USE dianam          ! build name of file (routine)
@@ -126,5 +127,5 @@
       !!----------------------------------------------------------------------
       ! 
-      IF( wrk_in_use(2, 1))THEN
+      IF( wrk_in_use(2, 1) )THEN
          CALL ctl_stop('dia_wri: ERROR - requested 2D workspace unavailable.')
          RETURN
@@ -137,17 +138,32 @@
       ENDIF
 
-      CALL iom_put( "toce"   , tn                    )    ! temperature
-      CALL iom_put( "soce"   , sn                    )    ! salinity
-      CALL iom_put( "sst"    , tn(:,:,1)             )    ! sea surface temperature
-      CALL iom_put( "sst2"   , tn(:,:,1) * tn(:,:,1) )    ! square of sea surface temperature
-      CALL iom_put( "sss"    , sn(:,:,1)             )    ! sea surface salinity
-      CALL iom_put( "sss2"   , sn(:,:,1) * sn(:,:,1) )    ! square of sea surface salinity
-      CALL iom_put( "uoce"   , un                    )    ! i-current      
-      CALL iom_put( "voce"   , vn                    )    ! j-current
-      
-      CALL iom_put( "avt"    , avt                   )    ! T vert. eddy diff. coef.
-      CALL iom_put( "avm"    , avmu                  )    ! T vert. eddy visc. coef.
+      IF( lk_vvl ) THEN
+         z3d(:,:,:) = tn(:,:,:) * fse3t_n(:,:,:)
+         CALL iom_put( "toce" , z3d                        )   ! heat content
+         CALL iom_put( "sst"  , z3d(:,:,1)                 )   ! sea surface heat content
+         CALL iom_put( "sst2" , z3d(:,:,1) * tn(:,:,1)     )   ! sea surface content of squared temperature
+         z3d(:,:,:) = sn(:,:,:) * fse3t_n(:,:,:)            
+         CALL iom_put( "soce" , z3d                        )   ! salinity content
+         CALL iom_put( "sss"  , z3d(:,:,1)                 )   ! sea surface salinity content
+         CALL iom_put( "sss2" , z3d(:,:,1) * sn(:,:,1)     )   ! sea surface content of squared salinity
+      ELSE
+         CALL iom_put( "toce" , tn                         )   ! temperature
+         CALL iom_put( "sst"  , tn(:,:,1)                  )   ! sea surface temperature
+         CALL iom_put( "sst2" , tn(:,:,1) * tn(:,:,1)      )   ! square of sea surface temperature
+         CALL iom_put( "soce" , sn                         )   ! salinity
+         CALL iom_put( "sss"  , sn(:,:,1)                  )   ! sea surface salinity
+         CALL iom_put( "sss2" , sn(:,:,1) * sn(:,:,1)      )   ! square of sea surface salinity
+      END IF
+      IF( lk_vvl .AND. (.NOT. ln_dynadv_vec) ) THEN
+         CALL iom_put( "uoce" , un(:,:,:) * fse3u_n(:,:,:) )    ! i-transport
+         CALL iom_put( "voce" , vn(:,:,:) * fse3v_n(:,:,:) )    ! j-transport
+      ELSE
+         CALL iom_put( "uoce" , un                         )    ! i-current
+         CALL iom_put( "voce" , vn                         )    ! j-current
+      END IF
+      CALL iom_put(    "avt"  , avt                        )    ! T vert. eddy diff. coef.
+      CALL iom_put(    "avm"  , avmu                       )    ! T vert. eddy visc. coef.
       IF( lk_zdfddm ) THEN
-         CALL iom_put( "avs" , fsavs(:,:,:)          )    ! S vert. eddy diff. coef.
+         CALL iom_put( "avs"  , fsavs(:,:,:)               )    ! S vert. eddy diff. coef.
       ENDIF
 
@@ -170,5 +186,5 @@
          z3d(:,:,jpk) = 0.e0
          DO jk = 1, jpkm1
-            z3d(:,:,jk) = rau0 * un(:,:,jk) * e1u(:,:) * fse3u(:,:,jk)
+            z3d(:,:,jk) = rau0 * un(:,:,jk) * e1u(:,:) * fse3u_n(:,:,jk)
          END DO
          CALL iom_put( "u_masstr", z3d )                  ! mass transport in i-direction
@@ -185,5 +201,5 @@
          CALL iom_put( "u_heattr", z2d )                  ! heat transport in i-direction
          DO jk = 1, jpkm1
-            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e2v(:,:) * fse3v(:,:,jk)
+            z3d(:,:,jk) = rau0 * vn(:,:,jk) * e2v(:,:) * fse3v_n(:,:,jk)
          END DO
          CALL iom_put( "v_masstr", z3d )                  ! mass transport in j-direction
@@ -197,8 +213,8 @@
          END DO
          CALL lbc_lnk( z2d, 'V', -1. )
-         CALL iom_put( "v_heattr", z2d )                  !  heat transport in i-direction
-      ENDIF
-      !
-      IF( wrk_not_released(2, 1))THEN
+         CALL iom_put( "v_heattr", z2d )                  !  heat transport in j-direction
+      ENDIF
+      !
+      IF( wrk_not_released(2, 1) ) THEN
          CALL ctl_stop('dia_wri: ERROR - failed to release 2D workspace.')
          RETURN
@@ -224,4 +240,5 @@
       !!      Each nwrite time step, output the instantaneous or mean fields
       !!----------------------------------------------------------------------
+      USE oce, ONLY :   z3d => ta   ! use ta as 3D workspace
       USE wrk_nemo, ONLY: wrk_in_use, wrk_not_released
       USE wrk_nemo, ONLY: zw2d => wrk_2d_1
@@ -361,4 +378,12 @@
          CALL histdef( nid_T, "vosaline", "Salinity"                           , "PSU"    ,   &  ! sn
             &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#if defined key_vvl
+         CALL histdef( nid_T, "vovvle3t", "Level thickness"                    , "m"      ,   &  ! e3t_n
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vovvldep", "T point depth"                      , "m"      ,   &  ! e3t_n
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+         CALL histdef( nid_T, "vovvldef", "Squared level deformation"          , "%^2"    ,   &  ! e3t_n
+            &          jpi, jpj, nh_T, ipk, 1, ipk, nz_T, 32, clop, zsto, zout )
+#endif
          !                                                                                      !!! nid_T : 2D
          CALL histdef( nid_T, "sosstsst", "Sea Surface temperature"            , "C"      ,   &  ! sst
@@ -439,5 +464,5 @@
             &          jpi, jpj, nh_T, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
 # endif 
-#endif 
+#endif
 
          CALL histend( nid_T, snc4chunks=snc4set )
@@ -516,8 +541,22 @@
 
       ! Write fields on T grid
-      CALL histwrite( nid_T, "votemper", it, tn            , ndim_T , ndex_T  )   ! temperature
-      CALL histwrite( nid_T, "vosaline", it, sn            , ndim_T , ndex_T  )   ! salinity
-      CALL histwrite( nid_T, "sosstsst", it, tn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface temperature
-      CALL histwrite( nid_T, "sosaline", it, sn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface salinity
+      IF( lk_vvl ) THEN
+         CALL histwrite( nid_T, "votemper", it, tn(:,:,:) * fse3t_n(:,:,:) , ndim_T , ndex_T  )   ! heat content
+         CALL histwrite( nid_T, "vosaline", it, sn(:,:,:) * fse3t_n(:,:,:) , ndim_T , ndex_T  )   ! salt content
+         CALL histwrite( nid_T, "sosstsst", it, tn(:,:,1) * fse3t_n(:,:,1) , ndim_hT, ndex_hT )   ! sea surface heat content
+         CALL histwrite( nid_T, "sosaline", it, sn(:,:,1) * fse3t_n(:,:,1) , ndim_hT, ndex_hT )   ! sea surface salinity content
+      ELSE
+         CALL histwrite( nid_T, "votemper", it, tn            , ndim_T , ndex_T  )   ! temperature
+         CALL histwrite( nid_T, "vosaline", it, sn            , ndim_T , ndex_T  )   ! salinity
+         CALL histwrite( nid_T, "sosstsst", it, tn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface temperature
+         CALL histwrite( nid_T, "sosaline", it, sn(:,:,1)     , ndim_hT, ndex_hT )   ! sea surface salinity
+
+      ENDIF
+      IF( lk_vvl ) THEN
+         z3d(:,:,:) = ( ( fse3t_n(:,:,:) - fse3t_0(:,:,:) ) / fse3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2
+         CALL histwrite( nid_T, "vovvle3t", it, fse3t_n (:,:,:) , ndim_T , ndex_T  )   ! level thickness
+         CALL histwrite( nid_T, "vovvldep", it, fsdept_n(:,:,:) , ndim_T , ndex_T  )   ! t-point depth
+         CALL histwrite( nid_T, "vovvldef", it, z3d             , ndim_T , ndex_T  )   ! level thickness deformation
+      ENDIF
       CALL histwrite( nid_T, "sossheig", it, sshn          , ndim_hT, ndex_hT )   ! sea surface height
 !!$#if  defined key_lim3 || defined key_lim2 
@@ -569,5 +608,9 @@
 #endif
          ! Write fields on U grid
-      CALL histwrite( nid_U, "vozocrtx", it, un            , ndim_U , ndex_U )    ! i-current
+      IF( lk_vvl .AND. (.NOT. ln_dynadv_vec) ) THEN
+         CALL histwrite( nid_U, "vozocrtx", it, un(:,:,:) * fse3u_n(:,:,:), ndim_U , ndex_U )    ! i-transport
+      ELSE
+         CALL histwrite( nid_U, "vozocrtx", it, un            , ndim_U , ndex_U )    ! i-current
+      ENDIF
 #if defined key_diaeiv
       CALL histwrite( nid_U, "vozoeivu", it, u_eiv         , ndim_U , ndex_U )    ! i-eiv current
@@ -576,5 +619,9 @@
 
          ! Write fields on V grid
-      CALL histwrite( nid_V, "vomecrty", it, vn            , ndim_V , ndex_V  )   ! j-current
+      IF( lk_vvl .AND. (.NOT. ln_dynadv_vec) ) THEN
+         CALL histwrite( nid_V, "vomecrty", it, vn(:,:,:) * fse3v_n(:,:,:), ndim_V , ndex_V  )   ! j-transport
+      ELSE
+         CALL histwrite( nid_V, "vomecrty", it, vn            , ndim_V , ndex_V  )   ! j-current
+      END IF
 #if defined key_diaeiv
       CALL histwrite( nid_V, "vomeeivv", it, v_eiv         , ndim_V , ndex_V  )   ! j-eiv current
@@ -676,5 +723,5 @@
       CALL histdef( id_i, "votemper", "Temperature"           , "C"      ,   &   ! temperature
          &          jpi, jpj, nh_i, jpk, 1, jpk, nz_i, 32, clop, zsto, zout )
-      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &  ! ssh
+      CALL histdef( id_i, "sossheig", "Sea Surface Height"    , "m"      ,   &   ! ssh
          &          jpi, jpj, nh_i, 1  , 1, 1  , nz_i, 32, clop, zsto, zout )
       CALL histdef( id_i, "vozocrtx", "Zonal Current"         , "m/s"    ,   &   ! zonal current
@@ -696,4 +743,8 @@
       CALL histdef( id_i, "sometauy", "Meridional Wind Stress", "N/m2"   ,   &   ! j-wind stress
          &          jpi, jpj, nh_i, 1  , 1, 1  , -99 , 32, clop, zsto, zout )
+      IF( lk_vvl ) THEN
+         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
 
 #if defined key_lim2
@@ -711,6 +762,6 @@
 
       ! Write all fields on T grid
-      CALL histwrite( id_i, "votemper", kt, tn      , jpi*jpj*jpk, idex )    ! now temperature
-      CALL histwrite( id_i, "vosaline", kt, sn      , jpi*jpj*jpk, idex )    ! now salinity
+      CALL histwrite( id_i, "votemper", kt, tn       , jpi*jpj*jpk, idex )    ! now temperature
+      CALL histwrite( id_i, "vosaline", kt, sn       , jpi*jpj*jpk, idex )    ! now salinity
       CALL histwrite( id_i, "sossheig", kt, sshn     , jpi*jpj    , idex )    ! sea surface height
       CALL histwrite( id_i, "vozocrtx", kt, un       , jpi*jpj*jpk, idex )    ! now i-velocity
@@ -723,4 +774,7 @@
       CALL histwrite( id_i, "sozotaux", kt, utau     , jpi*jpj    , idex )    ! i-wind stress
       CALL histwrite( id_i, "sometauy", kt, vtau     , jpi*jpj    , idex )    ! j-wind stress
+      IF( lk_vvl ) THEN
+         CALL histwrite( id_i, "vovvldep", kt, fsdept_n(:,:,:), jpi*jpj*jpk, idex )    ! t-point depth
+      END IF
 
       ! 3. Close the file
Index: /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90
===================================================================
--- /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 2969)
+++ /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/DOM/domvvl.F90	(revision 2970)
@@ -209,5 +209,5 @@
       !! Reference  : Leclair, M., and G. Madec, 2011, Ocean Modelling.
       !!----------------------------------------------------------------------
-      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released, iwrk_in_use, iwrk_not_released
+      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released
       USE oce     , ONLY:   ze3t    => ta         ! ua used as workspace
       USE wrk_nemo, ONLY:   zht     => wrk_2d_1   ! 2D REAL workspace
@@ -521,5 +521,5 @@
       z_e3t_def(:,:,:) = ( ( fse3t_n(:,:,:) - fse3t_0(:,:,:) ) / fse3t_0(:,:,:) * 100 * tmask(:,:,:) ) ** 2
       CALL iom_put( "e3t_n"  , fse3t_n  (:,:,:) )
-      CALL iom_put( "dept"   , fsdept_n (:,:,:) )
+      CALL iom_put( "dept_n" , fsdept_n (:,:,:) )
       CALL iom_put( "e3tdef" , z_e3t_def(:,:,:) )
 
Index: /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90
===================================================================
--- /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 2969)
+++ /branches/2011/dev_r2739_LOCEAN8_ZTC/NEMOGCM/NEMO/OPA_SRC/TRA/tranxt.F90	(revision 2970)
@@ -278,6 +278,6 @@
       LOGICAL  ::   ll_tra, ll_tra_hpg, ll_traqsr   ! 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
-      REAL(wp) ::   zfact2, ze3t_b, ze3t_n, ze3t_a, ze3t_f, ze3t_d   !   -      -
+      REAL(wp) ::   zfact1, ztc_a, ztc_n, ztc_b, ztc_f , ztc_d    ! local scalar
+      REAL(wp) ::   zfact2,                      ze3t_f, ze3t_d   !   -      -
       !!----------------------------------------------------------------------
 
@@ -304,21 +304,18 @@
             DO jj = 1, jpj
                DO ji = 1, jpi
-                  ze3t_b = fse3t_b(ji,jj,jk)
-                  ze3t_n = fse3t_n(ji,jj,jk)
-                  ze3t_a = fse3t_a(ji,jj,jk)
-                  !                                         ! tracer content at Before, now and after
-                  ztc_b  = ptb(ji,jj,jk,jn) * ze3t_b
-                  ztc_n  = ptn(ji,jj,jk,jn) * ze3t_n
-                  ztc_a  = pta(ji,jj,jk,jn) * ze3t_a
-                  !
-                  ze3t_d = ze3t_a - 2. * ze3t_n + ze3t_b
+                  !                                         ! tracer content at before, now and after
+                  ztc_b  = ptb(ji,jj,jk,jn) * fse3t_b(ji,jj,jk)
+                  ztc_n  = ptn(ji,jj,jk,jn) * fse3t_n(ji,jj,jk)
+                  ztc_a  = pta(ji,jj,jk,jn) * fse3t_a(ji,jj,jk)
+                  !
+                  ze3t_d = fse3t_a(ji,jj,jk) - 2. * fse3t_n(ji,jj,jk) + fse3t_b(ji,jj,jk)
                   ztc_d  = ztc_a  - 2. * ztc_n  + ztc_b
                   !
-                  ze3t_f = ze3t_n + atfp * ze3t_d
+                  ze3t_f = fse3t_n(ji,jj,jk) + atfp * ze3t_d
                   ztc_f  = ztc_n  + atfp * ztc_d
                   !
-                  IF( ll_tra .AND. jk == 1 ) THEN           ! first level only for T & S
-                      ze3t_f = ze3t_f - zfact2 * ( emp_b(ji,jj) - emp(ji,jj) )
-                      ztc_f  = ztc_f  - zfact1 * ( sbc_tsc(ji,jj,jn) - sbc_tsc_b(ji,jj,jn) )
+                  IF( jk == 1 ) THEN           ! first level
+                     ze3t_f = ze3t_f - zfact2 * ( emp_b(ji,jj) - emp(ji,jj) )
+                     IF( ll_tra ) ztc_f  = ztc_f  - zfact1 * ( sbc_tsc(ji,jj,jn) - sbc_tsc_b(ji,jj,jn) )   ! only T and S
                   ENDIF
                   IF( ll_traqsr .AND. jn == jp_tem .AND. jk <= nksr )   &     ! solar penetration (temperature only)
@@ -330,5 +327,5 @@
                    !
                    IF( ll_tra_hpg ) THEN        ! semi-implicit hpg (T & S only)
-                      ze3t_d           = 1.e0   / ( ze3t_n + rbcp * ze3t_d )
+                      ze3t_d           = 1.e0   / ( fse3t_n(ji,jj,jk) + rbcp * ze3t_d )
                       pta(ji,jj,jk,jn) = ze3t_d * ( ztc_n  + rbcp * ztc_d  )   ! ta <-- Brown & Campana average
                    ENDIF
