Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/DIA/diaptr.F90	(revision 6428)
@@ -40,6 +40,6 @@
 
    !                                  !!** namelist  namptr  **
-   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:) ::   htr_adv, htr_ldf   !: Heat TRansports (adv, diff, overturn.)
-   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:) ::   str_adv, str_ldf   !: Salt TRansports (adv, diff, overturn.)
+   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   htr_adv, htr_ldf   !: Heat TRansports (adv, diff, overturn.)
+   REAL(wp), ALLOCATABLE, SAVE, PUBLIC, DIMENSION(:,:) ::   str_adv, str_ldf   !: Salt TRansports (adv, diff, overturn.)
    
 
@@ -256,6 +256,6 @@
          ! Initialise arrays to zero because diatpr is called before they are first calculated
          ! Note that this means diagnostics will not be exactly correct when model run is restarted.
-         htr_adv(:) = 0._wp  ;  str_adv(:) =  0._wp  
-         htr_ldf(:) = 0._wp  ;  str_ldf(:) =  0._wp 
+         htr_adv(:,:) = 0._wp  ;  str_adv(:,:) =  0._wp  
+         htr_ldf(:,:) = 0._wp  ;  str_ldf(:,:) =  0._wp 
          !
       ENDIF 
@@ -263,4 +263,24 @@
    END SUBROUTINE dia_ptr_init
 
+   SUBROUTINE dia_ptr_ohst_components( pva, ptr ) 
+      !!----------------------------------------------------------------------
+      !!                    ***  ROUTINE dia_ptr_oht_components  ***
+      !!----------------------------------------------------------------------
+      !! Wrapper for heat and salt transport calculations to calculate them
+      !! for each basin
+      !! Called from all advection and/or diffusion routines
+      INTEGER                          :: jn
+      REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(IN) :: pva   ! 3D input array of advection/diffusion
+      REAL(wp), DIMENSION(jpi,nptr), INTENT(OUT)   :: ptr   ! zonal & vertical sum
+      
+      ptr(:, 1) = ptr_sj( pva(:,:,:) )
+      IF( ln_subbas ) THEN
+         DO jn=2,nptr
+            ptr(:,jn) = ptr_sj( pva(:,:,:), btmsk(:,:,jn) )
+         END DO
+      ENDIF
+
+   END SUBROUTINE
+
 
    FUNCTION dia_ptr_alloc()
@@ -274,6 +294,6 @@
       !
       ALLOCATE( btmsk(jpi,jpj,nptr) ,           &
-         &      htr_adv(jpj) , str_adv(jpj) ,   &
-         &      htr_ldf(jpj) , str_ldf(jpj) , STAT=ierr(1)  )
+         &      htr_adv(jpj,nptr) , str_adv(jpj,nptr) ,   &
+         &      htr_ldf(jpj,nptr) , str_ldf(jpj,nptr) , STAT=ierr(1)  )
          !
       ALLOCATE( p_fval1d(jpj), p_fval2d(jpj,jpk), Stat=ierr(2))
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_cen2.F90	(revision 6428)
@@ -280,6 +280,6 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )   htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )   str_adv(:) = ptr_sj( zwy(:,:,:) )
+           IF( jn == jp_tem )  CALL dia_ptr_ohst_components( zwy(:,:,:), htr_adv(:,:)  )
+           IF( jn == jp_sal )  CALL dia_ptr_ohst_components( zwy(:,:,:), str_adv(:,:)  )
          ENDIF
          !
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl.F90	(revision 6428)
@@ -220,6 +220,6 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-            IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-            IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+           IF( jn == jp_tem )  CALL dia_ptr_ohst_components( zwy(:,:,:), htr_adv(:,:)  )
+           IF( jn == jp_sal )  CALL dia_ptr_ohst_components( zwy(:,:,:), str_adv(:,:)  )
          ENDIF
 
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl2.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl2.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_muscl2.F90	(revision 6428)
@@ -201,6 +201,6 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-            IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+            IF( jn == jp_tem )  CALL dia_ptr_ohst_components( zwy(:,:,:), htr_adv(:,:)  )
+            IF( jn == jp_sal )  CALL dia_ptr_ohst_components( zwy(:,:,:), str_adv(:,:)  )
          ENDIF
 
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_qck.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_qck.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_qck.F90	(revision 6428)
@@ -356,6 +356,6 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+           IF( jn == jp_tem )  CALL dia_ptr_ohst_components( zwy(:,:,:), htr_adv(:,:)  )
+           IF( jn == jp_sal )  CALL dia_ptr_ohst_components( zwy(:,:,:), str_adv(:,:)  )
          ENDIF
          !
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 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_tvd.F90	(revision 6428)
@@ -86,4 +86,5 @@
       REAL(wp), POINTER, DIMENSION(:,:,:) :: zwi, zwz
       REAL(wp), POINTER, DIMENSION(:,:,:) :: ztrdx, ztrdy, ztrdz
+      REAL(wp), POINTER, DIMENSION(:,:) :: ptr_adv_tmp
       !!----------------------------------------------------------------------
       !
@@ -104,4 +105,9 @@
          CALL wrk_alloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
          ztrdx(:,:,:) = 0.e0   ;    ztrdy(:,:,:) = 0.e0   ;   ztrdz(:,:,:) = 0.e0
+      ENDIF
+      !
+      IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+         CALL wrk_alloc( jpi, nptr, ptr_adv_tmp )
+         ptr_adv_tmp(:,:) = 0._wp
       ENDIF
       !
@@ -194,6 +200,5 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+           CALL dia_ptr_ohst_components( zwy(:,:,:), ptr_adv_tmp(:,:)  )
          ENDIF
 
@@ -265,6 +270,13 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) ) + htr_adv(:)
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) ) + str_adv(:)
+           IF( jn == jp_tem ) THEN 
+              CALL dia_ptr_ohst_components( zwy(:,:,:), htr_adv(:,:)  )
+              htr_adv(:,:) = htr_adv(:,:) + ptr_adv_tmp(:,:)
+           ENDIF
+           IF( jn == jp_sal )  THEN
+              CALL dia_ptr_ohst_components( zwy(:,:,:), str_adv(:,:)  )
+              htr_adv(:,:) = htr_adv(:,:) + ptr_adv_tmp(:,:)
+           ENDIF
+           ptr_adv_tmp(:,:) = 0._wp
          ENDIF
          !
@@ -273,4 +285,5 @@
                    CALL wrk_dealloc( jpi, jpj, jpk, zwi, zwz )
       IF( l_trd )  CALL wrk_dealloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
+      IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN wrk_dealloc( jpi, nptr, ptr_adv_tmp )
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_adv_tvd')
@@ -342,4 +355,9 @@
       ENDIF
       !
+      IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
+         CALL wrk_alloc( jpi, nptr, ptr_adv_tmp )
+         ptr_adv_tmp(:,:) = 0._wp
+      ENDIF
+      !
       zwi(:,:,:) = 0._wp
       z_rzts = 1._wp / REAL( jnzts, wp )
@@ -431,6 +449,5 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) )
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) )
+           CALL dia_ptr_ohst_components( zwy(:,:,:), ptr_adv_tmp(:,:)  )
          ENDIF
 
@@ -557,6 +574,13 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_adv(:) = ptr_sj( zwy(:,:,:) ) + htr_adv(:)
-           IF( jn == jp_sal )  str_adv(:) = ptr_sj( zwy(:,:,:) ) + str_adv(:)
+           IF( jn == jp_tem ) THEN 
+              CALL dia_ptr_ohst_components( zwy(:,:,:), htr_adv(:,:)  )
+              htr_adv(:,:) = htr_adv(:,:) + ptr_adv_tmp(:,:)
+           ENDIF
+           IF( jn == jp_sal )  THEN
+              CALL dia_ptr_ohst_components( zwy(:,:,:), str_adv(:,:)  )
+              htr_adv(:,:) = htr_adv(:,:) + ptr_adv_tmp(:,:)
+           ENDIF
+           ptr_adv_tmp(:,:) = 0._wp
          ENDIF
          !
@@ -567,4 +591,5 @@
                    CALL wrk_dealloc( jpi, jpj, zwx_sav, zwy_sav )
       IF( l_trd )  CALL wrk_dealloc( jpi, jpj, jpk, ztrdx, ztrdy, ztrdz )
+      IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN wrk_dealloc( jpi, nptr, ptr_adv_tmp )
       !
       IF( nn_timing == 1 )  CALL timing_stop('tra_adv_tvd_zts')
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_ubs.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_ubs.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traadv_ubs.F90	(revision 6428)
@@ -178,6 +178,6 @@
          !                                 ! "Poleward" heat and salt transports (contribution of upstream fluxes)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-            IF( jn == jp_tem )  htr_adv(:) = ptr_sj( ztv(:,:,:) )
-            IF( jn == jp_sal )  str_adv(:) = ptr_sj( ztv(:,:,:) )
+           IF( jn == jp_tem )  CALL dia_ptr_ohst_components( ztv(:,:,:), htr_adv(:,:)  )
+           IF( jn == jp_sal )  CALL dia_ptr_ohst_components( ztv(:,:,:), str_adv(:,:)  )
          ENDIF
          
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilap.F90	(revision 6428)
@@ -174,6 +174,6 @@
          ! "zonal" mean lateral diffusive heat and salt transport
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN  
-           IF( jn == jp_tem )  htr_ldf(:) = ptr_sj( ztv(:,:,:) )
-           IF( jn == jp_sal )  str_ldf(:) = ptr_sj( ztv(:,:,:) )
+           IF( jn == jp_tem )  CALL dia_ptr_ohst_components( ztv(:,:,:),htr_ldf(:,:) )
+           IF( jn == jp_sal )  CALL dia_ptr_ohst_components( ztv(:,:,:),str_ldf(:,:) )
          ENDIF
          !                                                ! ===========
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_bilapg.F90	(revision 6428)
@@ -249,6 +249,6 @@
          IF( cdtype == 'TRA' .AND. ln_diaptr .AND. ( kaht == 2 ) ) THEN
             ! note sign is reversed to give down-gradient diffusive transports (#1043)
-            IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( -zftv(:,:,:) )
-            IF( jn == jp_sal)   str_ldf(:) = ptr_sj( -zftv(:,:,:) )
+            IF( jn == jp_tem )  CALL dia_ptr_ohst_components( -zftv(:,:,:),htr_ldf(:,:) )
+            IF( jn == jp_sal )  CALL dia_ptr_ohst_components( -zftv(:,:,:),str_ldf(:,:) )
          ENDIF
 
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso.F90	(revision 6428)
@@ -237,6 +237,6 @@
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
             ! note sign is reversed to give down-gradient diffusive transports (#1043)
-            IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( -zftv(:,:,:) )
-            IF( jn == jp_sal)   str_ldf(:) = ptr_sj( -zftv(:,:,:) )
+            IF( jn == jp_tem )  CALL dia_ptr_ohst_components( -zftv(:,:,:),htr_ldf(:,:) )
+            IF( jn == jp_sal )  CALL dia_ptr_ohst_components( -zftv(:,:,:),str_ldf(:,:) )
          ENDIF
  
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_iso_grif.F90	(revision 6428)
@@ -387,6 +387,6 @@
          !                             ! "Poleward" diffusive heat or salt transports (T-S case only)
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            IF( jn == jp_tem)   htr_ldf(:) = ptr_sj( zftv(:,:,:) )        ! 3.3  names
-            IF( jn == jp_sal)   str_ldf(:) = ptr_sj( zftv(:,:,:) )
+            IF( jn == jp_tem )  CALL dia_ptr_ohst_components( zftv(:,:,:),htr_ldf(:,:) )
+            IF( jn == jp_sal )  CALL dia_ptr_ohst_components( zftv(:,:,:),str_ldf(:,:) )
          ENDIF
 
Index: branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_lap.F90
===================================================================
--- branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_lap.F90	(revision 6427)
+++ branches/UKMO/v3_6_extra_CMIP6_diagnostics/NEMOGCM/NEMO/OPA_SRC/TRA/traldf_lap.F90	(revision 6428)
@@ -155,6 +155,6 @@
          ! "Poleward" diffusive heat or salt transports
          IF( cdtype == 'TRA' .AND. ln_diaptr ) THEN
-            IF( jn  == jp_tem)   htr_ldf(:) = ptr_sj( ztv(:,:,:) )
-            IF( jn  == jp_sal)   str_ldf(:) = ptr_sj( ztv(:,:,:) )
+           IF( jn == jp_tem )  CALL dia_ptr_ohst_components( ztv(:,:,:),htr_ldf(:,:) )
+           IF( jn == jp_sal )  CALL dia_ptr_ohst_components( ztv(:,:,:),str_ldf(:,:) )
          ENDIF
          !                                                  ! ==================
