Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/TRA/tranpc.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/TRA/tranpc.F90	(revision 13516)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/TRA/tranpc.F90	(revision 13517)
@@ -17,4 +17,6 @@
    USE oce            ! ocean dynamics and active tracers
    USE dom_oce        ! ocean space and time domain
+   ! TEMP: This change not necessary after trd_tra is tiled and extra haloes development (lbc_lnk removed)
+   USE domain, ONLY : dom_tile
    USE phycst         ! physical constants
    USE zdf_oce        ! ocean vertical physics
@@ -32,4 +34,6 @@
 
    PUBLIC   tra_npc    ! routine called by step.F90
+
+   INTEGER  ::   nnpcc        ! number of statically instable water column
 
    !! * Substitutions
@@ -64,5 +68,4 @@
       !
       INTEGER  ::   ji, jj, jk   ! dummy loop indices
-      INTEGER  ::   inpcc        ! number of statically instable water column
       INTEGER  ::   jiter, ikbot, ikp, ikup, ikdown, ilayer, ik_low   ! local integers
       LOGICAL  ::   l_bottom_reached, l_column_treated
@@ -70,9 +73,10 @@
       REAL(wp) ::   zsa, zbeta, zsum_sali, zsum_beta, zbw, zrw, z1_rDt
       REAL(wp), PARAMETER ::   zn2_zero = 1.e-14_wp             ! acceptance criteria for neutrality (N2==0)
-      REAL(wp), DIMENSION(        jpk     )   ::   zvn2         ! vertical profile of N2 at 1 given point...
-      REAL(wp), DIMENSION(        jpk,jpts)   ::   zvts, zvab   ! vertical profile of T & S , and  alpha & betaat 1 given point
-      REAL(wp), DIMENSION(jpi,jpj,jpk     )   ::   zn2          ! N^2 
-      REAL(wp), DIMENSION(jpi,jpj,jpk,jpts)   ::   zab          ! alpha and beta
-      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:) ::   ztrdt, ztrds ! 3D workspace
+      REAL(wp), DIMENSION(    jpk     )   ::   zvn2             ! vertical profile of N2 at 1 given point...
+      REAL(wp), DIMENSION(    jpk,jpts)   ::   zvts, zvab       ! vertical profile of T & S , and  alpha & betaat 1 given point
+      REAL(wp), DIMENSION(ST_2D(nn_hls),jpk     )   ::   zn2              ! N^2
+      REAL(wp), DIMENSION(ST_2D(nn_hls),jpk,jpts)   ::   zab              ! alpha and beta
+      ! TEMP: This change not necessary after trd_tra is tiled
+      REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::   ztrdt, ztrds ! 3D workspace
       !
       LOGICAL, PARAMETER :: l_LB_debug = .FALSE. ! set to true if you want to follow what is
@@ -82,13 +86,22 @@
       !
       IF( ln_timing )   CALL timing_start('tra_npc')
+
+      IF( l_trdtra )   THEN
+         IF( ntile == 0 .OR. ntile == 1 )  THEN                       ! Do only on the first tile
+            ! TEMP: This can be ST_2D(nn_hls) after trd_tra is tiled
+            ALLOCATE( ztrdt(jpi,jpj,jpk), ztrds(jpi,jpj,jpk) )
+         ENDIF
+      ENDIF
       !
       IF( MOD( kt, nn_npc ) == 0 ) THEN
          !
          IF( l_trdtra )   THEN                    !* Save initial after fields
-            ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) )
-            ztrdt(:,:,:) = pts(:,:,:,jp_tem,Kaa) 
-            ztrds(:,:,:) = pts(:,:,:,jp_sal,Kaa)
-         ENDIF
-         !
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               ztrdt(ji,jj,jk) = pts(ji,jj,jk,jp_tem,Kaa)
+               ztrds(ji,jj,jk) = pts(ji,jj,jk,jp_sal,Kaa)
+            END_3D
+         ENDIF
+         !
+         ! TODO: NOT TESTED- requires ORCA2
          IF( l_LB_debug ) THEN
             ! Location of 1 known convection site to follow what's happening in the water column
@@ -101,5 +114,5 @@
          CALL bn2    ( pts(:,:,:,:,Kaa), zab, zn2, Kmm )    ! after Brunt-Vaisala  (given on W-points)
          !
-         inpcc = 0
+         IF( ntile == 0 .OR. ntile == 1 ) nnpcc = 0         ! Do only on the first tile
          !
          DO_2D( 0, 0, 0, 0 )
@@ -160,5 +173,5 @@
                         ENDIF
                         !
-                        IF( jiter == 1 )   inpcc = inpcc + 1 
+                        IF( jiter == 1 )   nnpcc = nnpcc + 1
                         !
                         IF( lp_monitor_point )   WRITE(numout, *) 'Negative N2 at ikp =',ikp,' for layer #', ilayer
@@ -301,18 +314,32 @@
          END_2D
          !
-         IF( l_trdtra ) THEN         ! send the Non penetrative mixing trends for diagnostic
+         ! TEMP: These changes not necessary after trd_tra is tiled and extra haloes development (lbc_lnk removed)
+         IF( l_trdtra ) THEN
             z1_rDt = 1._wp / (2._wp * rn_Dt)
-            ztrdt(:,:,:) = ( pts(:,:,:,jp_tem,Kaa) - ztrdt(:,:,:) ) * z1_rDt
-            ztrds(:,:,:) = ( pts(:,:,:,jp_sal,Kaa) - ztrds(:,:,:) ) * z1_rDt
-            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_npc, ztrdt )
-            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_npc, ztrds )
-            DEALLOCATE( ztrdt, ztrds )
-         ENDIF
-         !
-         CALL lbc_lnk_multi( 'tranpc', pts(:,:,:,jp_tem,Kaa), 'T', 1.0_wp, pts(:,:,:,jp_sal,Kaa), 'T', 1.0_wp )
-         !
-         IF( lwp .AND. l_LB_debug ) THEN
-            WRITE(numout,*) 'Exiting tra_npc , kt = ',kt,', => numb. of statically instable water-columns: ', inpcc
-            WRITE(numout,*)
+
+            DO_3D( 0, 0, 0, 0, 1, jpk )
+               ztrdt(ji,jj,jk) = ( pts(ji,jj,jk,jp_tem,Kaa) - ztrdt(ji,jj,jk) ) * z1_rDt
+               ztrds(ji,jj,jk) = ( pts(ji,jj,jk,jp_sal,Kaa) - ztrds(ji,jj,jk) ) * z1_rDt
+            END_3D
+         ENDIF
+
+         IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only for the full domain
+            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )         ! Use full domain
+
+            IF( l_trdtra ) THEN         ! send the Non penetrative mixing trends for diagnostic
+               ! TODO: TO BE TILED- trd_tra
+               CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_npc, ztrdt )
+               CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_npc, ztrds )
+               DEALLOCATE( ztrdt, ztrds )
+            ENDIF
+
+            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = nijtile )   ! Revert to tile domain
+            !
+            CALL lbc_lnk_multi( 'tranpc', pts(:,:,:,jp_tem,Kaa), 'T', 1.0_wp, pts(:,:,:,jp_sal,Kaa), 'T', 1.0_wp )
+            !
+            IF( lwp .AND. l_LB_debug ) THEN
+               WRITE(numout,*) 'Exiting tra_npc , kt = ',kt,', => numb. of statically instable water-columns: ', nnpcc
+               WRITE(numout,*)
+            ENDIF
          ENDIF
          !
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/TRA/trazdf.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/TRA/trazdf.F90	(revision 13516)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/TRA/trazdf.F90	(revision 13517)
@@ -14,4 +14,6 @@
    USE oce            ! ocean dynamics and tracers variables
    USE dom_oce        ! ocean space and time domain variables 
+   ! TEMP: This change not necessary after trd_tra is tiled
+   USE domain, ONLY : dom_tile
    USE domvvl         ! variable volume
    USE phycst         ! physical constant
@@ -55,6 +57,7 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk,jpts,jpt), INTENT(inout) :: pts                 ! active tracers and RHS of tracer equation
       !
-      INTEGER  ::   jk   ! Dummy loop indices
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdt, ztrds   ! 3D workspace
+      INTEGER  ::   ji, jj, jk   ! Dummy loop indices
+      ! TEMP: This change not necessary after trd_tra is tiled
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   ztrdt, ztrds   ! 3D workspace
       !!---------------------------------------------------------------------
       !
@@ -62,13 +65,21 @@
       !
       IF( kt == nit000 )  THEN
-         IF(lwp)WRITE(numout,*)
-         IF(lwp)WRITE(numout,*) 'tra_zdf : implicit vertical mixing on T & S'
-         IF(lwp)WRITE(numout,*) '~~~~~~~ '
+         IF( ntile == 0 .OR. ntile == 1 )  THEN                   ! Do only on the first tile
+            IF(lwp)WRITE(numout,*)
+            IF(lwp)WRITE(numout,*) 'tra_zdf : implicit vertical mixing on T & S'
+            IF(lwp)WRITE(numout,*) '~~~~~~~ '
+         ENDIF
       ENDIF
       !
       IF( l_trdtra )   THEN                  !* Save ta and sa trends
-         ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) )
-         ztrdt(:,:,:) = pts(:,:,:,jp_tem,Kaa)
-         ztrds(:,:,:) = pts(:,:,:,jp_sal,Kaa)
+         IF( ntile == 0 .OR. ntile == 1 )  THEN                       ! Do only on the first tile
+            ! TEMP: This can be ST_2D(nn_hls) after trd_tra is tiled
+            ALLOCATE( ztrdt(jpi,jpj,jpk), ztrds(jpi,jpj,jpk) )
+         ENDIF
+
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            ztrdt(ji,jj,jk) = pts(ji,jj,jk,jp_tem,Kaa)
+            ztrds(ji,jj,jk) = pts(ji,jj,jk,jp_sal,Kaa)
+         END_3D
       ENDIF
       !
@@ -80,24 +91,26 @@
       ! JMM avoid negative salinities near river outlet ! Ugly fix
       ! JMM : restore negative salinities to small salinities:
-      WHERE( pts(:,:,:,jp_sal,Kaa) < 0._wp )   pts(:,:,:,jp_sal,Kaa) = 0.1_wp
+      WHERE( pts(ST_2D(0),:,jp_sal,Kaa) < 0._wp )   pts(ST_2D(0),:,jp_sal,Kaa) = 0.1_wp
 !!gm
 
+      ! TEMP: These changes not necessary after trd_tra is tiled
       IF( l_trdtra )   THEN                      ! save the vertical diffusive trends for further diagnostics
-         DO jk = 1, jpkm1
-            ztrdt(:,:,jk) = (   (  pts(:,:,jk,jp_tem,Kaa)*e3t(:,:,jk,Kaa)     &
-               &                 - pts(:,:,jk,jp_tem,Kbb)*e3t(:,:,jk,Kbb)  )  &
-               &              / (  e3t(:,:,jk,Kmm)*rDt  )   )                 &
-               &          - ztrdt(:,:,jk)
-            ztrds(:,:,jk) = (   (  pts(:,:,jk,jp_sal,Kaa)*e3t(:,:,jk,Kaa)     &
-               &                 - pts(:,:,jk,jp_sal,Kbb)*e3t(:,:,jk,Kbb)  )  &
-               &             / (   e3t(:,:,jk,Kmm)*rDt  )   )                 &
-               &          - ztrds(:,:,jk)
-         END DO
-!!gm this should be moved in trdtra.F90 and done on all trends
-         CALL lbc_lnk_multi( 'trazdf', ztrdt, 'T', 1.0_wp , ztrds, 'T', 1.0_wp )
-!!gm
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_zdf, ztrds )
-         DEALLOCATE( ztrdt , ztrds )
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            ztrdt(ji,jj,jk) = ( ( pts(ji,jj,jk,jp_tem,Kaa)*e3t(ji,jj,jk,Kaa) - pts(ji,jj,jk,jp_tem,Kbb)*e3t(ji,jj,jk,Kbb) ) &
+               &          / (e3t(ji,jj,jk,Kmm)*rDt) ) - ztrdt(ji,jj,jk)
+            ztrds(ji,jj,jk) = ( ( pts(ji,jj,jk,jp_sal,Kaa)*e3t(ji,jj,jk,Kaa) - pts(ji,jj,jk,jp_sal,Kbb)*e3t(ji,jj,jk,Kbb) ) &
+              &           / (e3t(ji,jj,jk,Kmm)*rDt) ) - ztrds(ji,jj,jk)
+         END_3D
+
+         IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only for the full domain
+            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )         ! Use full domain
+
+            ! TODO: TO BE TILED- trd_tra
+            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
+            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_zdf, ztrds )
+            DEALLOCATE( ztrdt , ztrds )
+
+            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = nijtile )   ! Revert to tile domain
+         ENDIF
       ENDIF
       !                                          ! print mean trends (used for debugging)
@@ -140,5 +153,5 @@
       INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
       REAL(wp) ::  zrhs, zzwi, zzws ! local scalars
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::  zwi, zwt, zwd, zws
+      REAL(wp), DIMENSION(ST_2D(nn_hls),jpk) ::  zwi, zwt, zwd, zws
       !!---------------------------------------------------------------------
       !
@@ -154,6 +167,12 @@
             !
             ! vertical mixing coef.: avt for temperature, avs for salinity and passive tracers
-            IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN   ;   zwt(:,:,2:jpk) = avt(:,:,2:jpk)
-            ELSE                                            ;   zwt(:,:,2:jpk) = avs(:,:,2:jpk)
+            IF( cdtype == 'TRA' .AND. jn == jp_tem ) THEN
+               DO_3D( 1, 1, 1, 1, 2, jpk )
+                  zwt(ji,jj,jk) = avt(ji,jj,jk)
+               END_3D
+            ELSE
+               DO_3D( 1, 1, 1, 1, 2, jpk )
+                  zwt(ji,jj,jk) = avs(ji,jj,jk)
+               END_3D
             ENDIF
             zwt(:,:,1) = 0._wp
@@ -222,5 +241,5 @@
          END_2D
          DO_3D( 0, 0, 0, 0, 2, jpkm1 )
-            zrhs =        e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb)    & 
+            zrhs =        e3t(ji,jj,jk,Kbb) * pt(ji,jj,jk,jn,Kbb)    &
                & + p2dt * e3t(ji,jj,jk,Kmm) * pt(ji,jj,jk,jn,Krhs)   ! zrhs=right hand side
             pt(ji,jj,jk,jn,Kaa) = zrhs - zwi(ji,jj,jk) / zwt(ji,jj,jk-1) * pt(ji,jj,jk-1,jn,Kaa)
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfosm.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfosm.F90	(revision 13516)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfosm.F90	(revision 13517)
@@ -44,4 +44,6 @@
                       ! uses ww from previous time step (which is now wb) to calculate hbl
    USE dom_oce        ! ocean space and time domain
+   ! TEMP: This change not necessary after trd_tra is tiled
+   USE domain, ONLY : dom_tile
    USE zdf_oce        ! ocean vertical physics
    USE sbc_oce        ! surface boundary condition: ocean
@@ -1496,4 +1498,6 @@
      !!-----------------------------------------------------------------------------
      IF( TRIM(cdrw) == 'WRITE') THEN     !* Write hbli into the restart file, then return
+        IF( ntile /= 0 .AND. ntile /= nijtile ) RETURN        ! Do only on the last tile
+
         IF(lwp) WRITE(numout,*) '---- osm-rst ----'
          CALL iom_rstput( kt, nitrst, numrow, 'wn'     , ww  , ldxios = lwxios )
@@ -1541,5 +1545,6 @@
       !! ** Method  :   ???
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE ::   ztrdt, ztrds   ! 3D workspace
+      ! TEMP: This change not necessary after trd_tra is tiled
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE, SAVE ::   ztrdt, ztrds   ! 3D workspace
       !!----------------------------------------------------------------------
       INTEGER                                  , INTENT(in)    :: kt        ! time step index
@@ -1550,12 +1555,21 @@
       !
       IF( kt == nit000 ) THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_osm : OSM non-local tracer fluxes'
-         IF(lwp) WRITE(numout,*) '~~~~~~~   '
+         IF( ntile == 0 .OR. ntile == 1 ) THEN                    ! Do only on the first tile
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'tra_osm : OSM non-local tracer fluxes'
+            IF(lwp) WRITE(numout,*) '~~~~~~~   '
+         ENDIF
       ENDIF
 
       IF( l_trdtra )   THEN                    !* Save ta and sa trends
-         ALLOCATE( ztrdt(jpi,jpj,jpk) )   ;    ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs)
-         ALLOCATE( ztrds(jpi,jpj,jpk) )   ;    ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs)
+         IF( ntile == 0 .OR. ntile == 1 )  THEN                       ! Do only on the first tile
+            ! TEMP: This can be ST_2D(nn_hls) after trd_tra is tiled
+            ALLOCATE( ztrdt(jpi,jpj,jpk), ztrds(jpi,jpj,jpk) )
+         ENDIF
+
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            ztrdt(ji,jj,jk) = pts(ji,jj,jk,jp_tem,Krhs)
+            ztrds(ji,jj,jk) = pts(ji,jj,jk,jp_sal,Krhs)
+         END_3D
       ENDIF
 
@@ -1570,13 +1584,23 @@
       END_3D
 
-
+      ! TEMP: These changes not necessary after trd_tra is tiled
       ! save the non-local tracer flux trends for diagnostic
       IF( l_trdtra )   THEN
-         ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:)
-         ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) - ztrds(:,:,:)
+         DO_3D( 0, 0, 0, 0, 1, jpk )
+            ztrdt(ji,jj,jk) = pts(ji,jj,jk,jp_tem,Krhs) - ztrdt(ji,jj,jk)
+            ztrds(ji,jj,jk) = pts(ji,jj,jk,jp_sal,Krhs) - ztrds(ji,jj,jk)
+         END_3D
+
+         IF( ntile == 0 .OR. ntile == nijtile )  THEN                ! Do only for the full domain
+            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = 0 )         ! Use full domain
+
 !!bug gm jpttdzdf ==> jpttosm
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_zdf, ztrds )
-         DEALLOCATE( ztrdt )      ;     DEALLOCATE( ztrds )
+            ! TODO: TO BE TILED- trd_tra
+            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_zdf, ztrdt )
+            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_zdf, ztrds )
+            DEALLOCATE( ztrdt )      ;     DEALLOCATE( ztrds )
+
+            IF( ln_tile ) CALL dom_tile( ntsi, ntsj, ntei, ntej, ktile = nijtile )   ! Revert to tile domain
+         ENDIF
       ENDIF
 
