Index: /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90
===================================================================
--- /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 6670)
+++ /branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 6671)
@@ -34,4 +34,5 @@
    USE timing         ! Timing
    USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined)  
+   USE iom
 
    IMPLICIT NONE
@@ -42,4 +43,5 @@
 
    LOGICAL ::   l_trd   ! flag to compute trends
+   LOGICAL ::   l_trans   ! flag to output vertically integrated transports
 
    !! * Substitutions
@@ -85,6 +87,6 @@
       REAL(wp) ::   zfm_ui, zfm_vj, zfm_wk   !   -      -
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zwi, zwz
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdx, ztrdy, ztrdz
-      REAL(wp), POINTER, DIMENSION(:,:,:) :: zptry
+      REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdx, ztrdy, ztrdz, z2d, zptry
+      REAL(wp), POINTER, DIMENSION(:,:)   :: z2d
       !!----------------------------------------------------------------------
       !
@@ -99,10 +101,13 @@
          !
          l_trd = .FALSE.
+         l_trans = .FALSE.
          IF( ( cdtype == 'TRA' .AND. l_trdtra ) .OR. ( cdtype == 'TRC' .AND. l_trdtrc ) ) l_trd = .TRUE.
+         IF( cdtype == 'TRA' .AND. (iom_use("uadv_heattr") .OR. iom_use("vadv_heattr") ) ) l_trans = .TRUE.
       ENDIF
       !
-      IF( l_trd )  THEN
+      IF( l_trd .OR. l_trans )  THEN
          CALL wrk_alloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
          ztrdx(:,:,:) = 0.e0   ;    ztrdy(:,:,:) = 0.e0   ;   ztrdz(:,:,:) = 0.e0
+         CALL wrk_alloc( jpi, jpj, z2d )
       ENDIF
       !
@@ -194,5 +199,5 @@
 
          !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( l_trd )  THEN 
+         IF( l_trd .OR. l_trans )  THEN 
             ! store intermediate advective trends
             ztrdx(:,:,:) = zwx(:,:,:)   ;    ztrdy(:,:,:) = zwy(:,:,:)  ;   ztrdz(:,:,:) = zwz(:,:,:)
@@ -257,14 +262,40 @@
 
          !                                 ! trend diagnostics (contribution of upstream fluxes)
-         IF( l_trd )  THEN 
+         IF( l_trd .OR. l_trans )  THEN 
             ztrdx(:,:,:) = ztrdx(:,:,:) + zwx(:,:,:)  ! <<< Add to previously computed
             ztrdy(:,:,:) = ztrdy(:,:,:) + zwy(:,:,:)  ! <<< Add to previously computed
             ztrdz(:,:,:) = ztrdz(:,:,:) + zwz(:,:,:)  ! <<< Add to previously computed
-            
+         ENDIF
+         
+         IF( l_trd ) THEN 
             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( l_trans .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) + ztrdx(ji,jj,jk) 
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( z2d, 'U', -1. )
+            CALL iom_put( "uadv_heattr", rau0_rcp * 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) + ztrdy(ji,jj,jk) 
+                  END DO
+               END DO
+            END DO
+            CALL lbc_lnk( z2d, 'V', -1. )
+            CALL iom_put( "vadv_heattr", rau0_rcp * z2d )       ! heat transport in j-direction
+         ENDIF
+         ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
             zptry(:,:,:) = zptry(:,:,:) + zwy(:,:,:)  ! <<< Add to previously computed
@@ -274,6 +305,9 @@
       END DO
       !
-                   CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwz )
-      IF( l_trd )  CALL wrk_dealloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
+      CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwz )
+      IF( l_trd .OR. l_trans )  THEN 
+         CALL wrk_dealloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
+         CALL wrk_dealloc( jpi, jpj, z2d )
+      ENDIF
       IF( cdtype == 'TRA' .AND. ln_diaptr ) CALL wrk_dealloc( jpi, jpj, jpk, zptry )
       !
