Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/cfgs/SHARED/namelist_ref
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/cfgs/SHARED/namelist_ref	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/cfgs/SHARED/namelist_ref	(revision 12765)
@@ -94,4 +94,11 @@
    ln_use_jattr = .false.    !  use (T) the file attribute: open_ocean_jstart, if present
    !                         !  in netcdf input files, as the start j-row for reading
+/
+!-----------------------------------------------------------------------
+&namtile        !   parameters of the tiling
+!-----------------------------------------------------------------------
+   ln_tile = .false.     !  Use tiling (T) or not (F)
+   nn_tile_i = 10        !  Length of tiles in i
+   nn_tile_j = 10        !  Length of tiles in j
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/dom_oce.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/dom_oce.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/dom_oce.F90	(revision 12765)
@@ -72,4 +72,8 @@
    !                                !  = 7 bi-cyclic East-West AND North-South
    LOGICAL, PUBLIC ::   l_Iperio, l_Jperio   !   should we explicitely take care I/J periodicity 
+
+   ! Tiling namelist
+   LOGICAL, PUBLIC ::   ln_tile
+   INTEGER         ::   nn_tile_i, nn_tile_j
 
    !                                 !  domain MPP decomposition parameters
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/domain.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/domain.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/domain.F90	(revision 12765)
@@ -49,4 +49,5 @@
 
    PUBLIC   dom_init     ! called by nemogcm.F90
+   PUBLIC   dom_tile     ! called by step.F90
    PUBLIC   domain_cfg   ! called by nemogcm.F90
 
@@ -122,4 +123,8 @@
       CALL dom_glo                     ! global domain versus local domain
       CALL dom_nam                     ! read namelist ( namrun, namdom )
+
+      ! Initialise tile to full domain
+      CALL dom_tile(0)
+
       !
       IF( lwxios ) THEN
@@ -270,4 +275,47 @@
 
 
+   SUBROUTINE dom_tile(kntile)
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_tile  ***
+      !!
+      !! ** Purpose :   Set domain indices for specified tile
+      !!
+      !! ** Action  : - ntile          : current tile number
+      !!              - ntsi, ntsj     : start of internal part of domain
+      !!              - ntei, ntej     : end of internal part of domain
+      !!              - ntsim1, ntsjm1 : start of domain
+      !!              - nteip1, ntejp1 : end of domain
+      !!----------------------------------------------------------------------
+      INTEGER   , INTENT(in ) :: kntile               ! Tile number
+      INTEGER                 :: iitile, ijtile       ! Tile number in i and j
+      !!----------------------------------------------------------------------
+
+      IF( ln_tile .AND. kntile > 0 ) THEN          ! Tile domain
+         iitile = 1 + MOD( kntile - 1, jpnitile )
+         ijtile = 1 + (kntile - 1) / jpnitile
+
+         ntile = kntile
+         ntsi = 2 + (iitile - 1) * nn_tile_i
+         ntsj = 2 + (ijtile - 1) * nn_tile_j
+         ntei = MIN(ntsi + nn_tile_i - 1, jpim1)   ! Size of last tile limited by full domain
+         ntej = MIN(ntsj + nn_tile_j - 1, jpjm1)   !
+         ntsim1 = ntsi - 1
+         ntsjm1 = ntsj - 1
+         nteip1 = ntei + 1
+         ntejp1 = ntej + 1
+      ELSE                                         ! Full domain
+         ntile = 1
+         ntsi = 2
+         ntsj = 2
+         ntei = jpim1
+         ntej = jpjm1
+         ntsim1 = 1
+         ntsjm1 = 1
+         nteip1 = jpi
+         ntejp1 = jpj
+      ENDIF
+   END SUBROUTINE dom_tile
+
+
    SUBROUTINE dom_nam
       !!----------------------------------------------------------------------
@@ -278,4 +326,5 @@
       !! ** input   : - namrun namelist
       !!              - namdom namelist
+      !!              - namtile namelist
       !!              - namnc4 namelist   ! "key_netcdf4" only
       !!----------------------------------------------------------------------
@@ -290,4 +339,5 @@
          &             ln_cfmeta, ln_xios_read, nn_wxios
       NAMELIST/namdom/ ln_linssh, rn_Dt, rn_atfp, ln_crs, ln_meshmask
+      NAMELIST/namtile/ ln_tile, nn_tile_i, nn_tile_j
 #if defined key_netcdf4
       NAMELIST/namnc4/ nn_nchunks_i, nn_nchunks_j, nn_nchunks_k, ln_nc4zip
@@ -417,4 +467,36 @@
       r1_Dt = 1._wp / rDt
 
+      READ  ( numnam_ref, namtile, IOSTAT = ios, ERR = 905 )
+905   IF( ios /= 0 )   CALL ctl_nam ( ios , 'namtile in reference namelist' )
+      READ  ( numnam_cfg, namtile, IOSTAT = ios, ERR = 906 )
+906   IF( ios >  0 )   CALL ctl_nam ( ios , 'namtile in configuration namelist' )
+      IF(lwm) WRITE( numond, namtile )
+
+      ! Set tile decomposition
+      IF( ln_tile ) THEN
+         jpnitile = (jpi - 2) / nn_tile_i
+         jpnjtile = (jpj - 2) / nn_tile_j
+         IF( MOD( jpi - 2, nn_tile_i ) /= 0 ) jpnitile = jpnitile + 1
+         IF( MOD( jpj - 2, nn_tile_j ) /= 0 ) jpnjtile = jpnjtile + 1
+      ELSE
+         jpnitile = 1
+         jpnjtile = 1
+      ENDIF
+      jpnijtile = jpnitile * jpnjtile
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*)    '   Namelist : namtile   ---   tiling decomposition'
+         WRITE(numout,*)    '      Tiling (T) or not (F)                ln_tile   = ', ln_tile
+         WRITE(numout,*)    '      Length of tile in i                  nn_tile_i = ', nn_tile_i
+         WRITE(numout,*)    '      Length of tile in j                  nn_tile_j = ', nn_tile_j
+         WRITE(numout,*)
+         IF( ln_tile ) THEN
+            WRITE(numout,*) '      The domain will be decomposed into', jpnijtile, 'tiles of size', nn_tile_i, 'x', nn_tile_j
+         ELSE
+            WRITE(numout,*) '      Domain tiling will NOT be used'
+         ENDIF
+      ENDIF
+
       IF( TRIM(Agrif_CFixed()) == '0' ) THEN
          lrxios = ln_xios_read.AND.ln_rstart
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf.F90	(revision 12765)
@@ -45,5 +45,5 @@
 CONTAINS
 
-   SUBROUTINE tra_ldf( kt, Kbb, Kmm, pts, Krhs )
+   SUBROUTINE tra_ldf(kt, Kbb, Kmm, pts, Krhs )
       !!----------------------------------------------------------------------
       !!                  ***  ROUTINE tra_ldf  ***
@@ -58,10 +58,16 @@
       !!----------------------------------------------------------------------
       !
-      IF( ln_timing )   CALL timing_start('tra_ldf')
+      IF( ntile == 1 )  THEN                      ! Do only on the first tile
+         ! TODO: TO BE TILED
+         IF( ln_timing )   CALL timing_start('tra_ldf')
+      ENDIF
       !
-      IF( l_trdtra )   THEN                    !* Save ta and sa trends
-         ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) ) 
-         ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) 
-         ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs)
+      IF( ntile == jpnijtile )  THEN              ! Do only after all tiles finish
+         IF( l_trdtra )   THEN                    !* Save ta and sa trends
+            ! TODO: TO BE TILED
+            ALLOCATE( ztrdt(jpi,jpj,jpk) , ztrds(jpi,jpj,jpk) )
+            ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs)
+            ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs)
+         ENDIF
       ENDIF
       !
@@ -77,16 +83,23 @@
       END SELECT
       !
-      IF( l_trdtra )   THEN                    !* save the horizontal diffusive trends for further diagnostics
-         ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:)
-         ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) - ztrds(:,:,:)
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_ldf, ztrdt )
-         CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_ldf, ztrds )
-         DEALLOCATE( ztrdt, ztrds ) 
+      IF( ntile == jpnijtile )  THEN              ! Do only after all tiles finish
+         IF( l_trdtra )   THEN                    !* save the horizontal diffusive trends for further diagnostics
+            ! TODO: TO BE TILED
+            ztrdt(:,:,:) = pts(:,:,:,jp_tem,Krhs) - ztrdt(:,:,:)
+            ztrds(:,:,:) = pts(:,:,:,jp_sal,Krhs) - ztrds(:,:,:)
+            ! TODO: TO BE TILED
+            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_tem, jptra_ldf, ztrdt )
+            CALL trd_tra( kt, Kmm, Krhs, 'TRA', jp_sal, jptra_ldf, ztrds )
+            DEALLOCATE( ztrdt, ztrds )
+         ENDIF
+
+         !                                        !* print mean trends (used for debugging)
+         ! TODO: TO BE TILED
+         IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' ldf  - Ta: ', mask1=tmask,               &
+            &                                  tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
+         !
+         ! TODO: TO BE TILED
+         IF( ln_timing )   CALL timing_stop('tra_ldf')
       ENDIF
-      !                                        !* print mean trends (used for debugging)
-      IF(sn_cfctl%l_prtctl)   CALL prt_ctl( tab3d_1=pts(:,:,:,jp_tem,Krhs), clinfo1=' ldf  - Ta: ', mask1=tmask,               &
-         &                                  tab3d_2=pts(:,:,:,jp_sal,Krhs), clinfo2=       ' Sa: ', mask2=tmask, clinfo3='tra' )
-      !
-      IF( ln_timing )   CALL timing_stop('tra_ldf')
       !
    END SUBROUTINE tra_ldf
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf_iso.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf_iso.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf_iso.F90	(revision 12765)
@@ -36,7 +36,4 @@
    PUBLIC   tra_ldf_iso   ! routine called by step.F90
 
-   LOGICAL  ::   l_ptr   ! flag to compute poleward transport
-   LOGICAL  ::   l_hst   ! flag to compute heat transport
-
    !! * Substitutions
 #  include "do_loop_substitute.h90"
@@ -104,4 +101,6 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk,kjpt), INTENT(inout) ::   pt_rhs     ! tracer trend
       !
+      LOGICAL  ::  l_ptr                                 ! flag to compute poleward transport
+      LOGICAL  ::  l_hst                                 ! flag to compute heat transport
       INTEGER  ::  ji, jj, jk, jn   ! dummy loop indices
       INTEGER  ::  ikt
@@ -110,15 +109,20 @@
       REAL(wp) ::  zmskv, zahv_w, zabe2, zcof2, zcoef4   !   -      -
       REAL(wp) ::  zcoef0, ze3w_2, zsign                 !   -      -
-      REAL(wp), DIMENSION(jpi,jpj)     ::   zdkt, zdk1t, z2d
-      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zdit, zdjt, zftu, zftv, ztfw 
+      REAL(wp), DIMENSION(IND_2D)     ::   zdkt, zdk1t, z2d
+      REAL(wp), DIMENSION(IND_2D,jpk) ::   zdit, zdjt, zftu, zftv, ztfw
       !!----------------------------------------------------------------------
       !
       IF( kpass == 1 .AND. kt == kit000 )  THEN
-         IF(lwp) WRITE(numout,*)
-         IF(lwp) WRITE(numout,*) 'tra_ldf_iso : rotated laplacian diffusion operator on ', cdtype
-         IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
-         !
-         akz     (:,:,:) = 0._wp      
-         ah_wslp2(:,:,:) = 0._wp
+         IF( ntile == 1 )  THEN                       ! Do only on the first tile
+            ! TODO: TO BE TILED
+            IF(lwp) WRITE(numout,*)
+            IF(lwp) WRITE(numout,*) 'tra_ldf_iso : rotated laplacian diffusion operator on ', cdtype
+            IF(lwp) WRITE(numout,*) '~~~~~~~~~~~'
+         ENDIF
+         !
+         DO_3D_11_11( 1, jpk )
+            akz     (ji,jj,jk) = 0._wp
+            ah_wslp2(ji,jj,jk) = 0._wp
+         END_3D
       ENDIF
       !   
@@ -179,5 +183,7 @@
            !
          ELSE                                    ! 33 flux set to zero with akz=ah_wslp2 ==>> computed in full implicit
-            akz(:,:,:) = ah_wslp2(:,:,:)      
+            DO_3D_11_11( 1, jpk )
+               akz(ji,jj,jk) = ah_wslp2(ji,jj,jk)
+            END_3D
          ENDIF
       ENDIF
@@ -219,10 +225,13 @@
          DO jk = 1, jpkm1                                 ! Horizontal slab
             !
-            !                             !== Vertical tracer gradient
-            zdk1t(:,:) = ( pt(:,:,jk,jn) - pt(:,:,jk+1,jn) ) * wmask(:,:,jk+1)     ! level jk+1
-            !
-            IF( jk == 1 ) THEN   ;   zdkt(:,:) = zdk1t(:,:)                          ! surface: zdkt(jk=1)=zdkt(jk=2)
-            ELSE                 ;   zdkt(:,:) = ( pt(:,:,jk-1,jn) - pt(:,:,jk,jn) ) * wmask(:,:,jk)
-            ENDIF
+            DO_2D_11_11
+               !                             !== Vertical tracer gradient
+               zdk1t(ji,jj) = ( pt(ji,jj,jk,jn) - pt(ji,jj,jk+1,jn) ) * wmask(ji,jj,jk+1)     ! level jk+1
+               !
+               IF( jk == 1 ) THEN   ;   zdkt(ji,jj) = zdk1t(ji,jj)                          ! surface: zdkt(jk=1)=zdkt(jk=2)
+               ELSE                 ;   zdkt(ji,jj) = ( pt(ji,jj,jk-1,jn) - pt(ji,jj,jk,jn) ) * wmask(ji,jj,jk)
+               ENDIF
+            END_2D
+            !
             DO_2D_10_10
                zabe1 = pahu(ji,jj,jk) * e2_e1u(ji,jj) * e3u(ji,jj,jk,Kmm)
@@ -312,14 +321,18 @@
          END_3D
          !
-         IF( ( kpass == 1 .AND. ln_traldf_lap ) .OR.  &     !==  first pass only (  laplacian)  ==!
-             ( kpass == 2 .AND. ln_traldf_blp ) ) THEN      !==  2nd   pass      (bilaplacian)  ==!
-            !
-            !                             ! "Poleward" diffusive heat or salt transports (T-S case only)
-               ! note sign is reversed to give down-gradient diffusive transports )
-            IF( l_ptr )  CALL dia_ptr_hst( jn, 'ldf', -zftv(:,:,:)  )
-            !                          ! Diffusive heat transports
-            IF( l_hst )  CALL dia_ar5_hst( jn, 'ldf', -zftu(:,:,:), -zftv(:,:,:) )
-            !
-         ENDIF                                                    !== end pass selection  ==!
+         IF( ntile == jpnijtile )  THEN                        ! Do only after all tiles finish
+            IF( ( kpass == 1 .AND. ln_traldf_lap ) .OR.  &     !==  first pass only (  laplacian)  ==!
+                ( kpass == 2 .AND. ln_traldf_blp ) ) THEN      !==  2nd   pass      (bilaplacian)  ==!
+               !
+               !                             ! "Poleward" diffusive heat or salt transports (T-S case only)
+                  ! note sign is reversed to give down-gradient diffusive transports )
+               ! TODO: TO BE TILED
+               IF( l_ptr )  CALL dia_ptr_hst( jn, 'ldf', -zftv(:,:,:)  )
+               !                          ! Diffusive heat transports
+               ! TODO: TO BE TILED
+               IF( l_hst )  CALL dia_ar5_hst( jn, 'ldf', -zftu(:,:,:), -zftv(:,:,:) )
+               !
+            ENDIF                                                    !== end pass selection  ==!
+         ENDIF
          !
          !                                                        ! ===============
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/do_loop_substitute.h90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/do_loop_substitute.h90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/do_loop_substitute.h90	(revision 12765)
@@ -55,13 +55,15 @@
 !
 #endif
-#define __kIs_     2
-#define __kJs_     2
-#define __kIsm1_   1
-#define __kJsm1_   1
+#define __kIs_     ntsi
+#define __kJs_     ntsj
+#define __kIsm1_   ntsim1
+#define __kJsm1_   ntsjm1
 
-#define __kIe_     jpim1
-#define __kJe_     jpjm1
-#define __kIep1_   jpi
-#define __kJep1_   jpj
+#define __kIe_     ntei
+#define __kJe_     ntej
+#define __kIep1_   nteip1
+#define __kJep1_   ntejp1
+
+#define IND_2D     __kIsm1_:__kIep1_,__kJsm1_:__kJep1_
 
 #define DO_2D_00_00   DO jj = __kJs_, __kJe_   ;   DO ji = __kIs_, __kIe_
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/par_oce.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/par_oce.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/par_oce.F90	(revision 12765)
@@ -62,4 +62,20 @@
    INTEGER, PUBLIC ::   jpjmax! = ( jpjglo-2*nn_hls + (jpnj-1) ) / jpnj + 2*nn_hls !: maximum jpj
 
+   ! Tiling decomposition
+   INTEGER, PUBLIC ::   jpnitile                !: number of tiles following i
+   INTEGER, PUBLIC ::   jpnjtile                !: number of tiles following j
+   INTEGER, PUBLIC ::   jpnijtile               !: number of tiles in total (jpnitile x jpnjtile)
+
+   ! Tile indices
+   INTEGER, PUBLIC ::   ntsi                    !: start of internal part of tile domain
+   INTEGER, PUBLIC ::   ntsj                    !
+   INTEGER, PUBLIC ::   ntei                    !: end of internal part of tile domain
+   INTEGER, PUBLIC ::   ntej                    !
+   INTEGER, PUBLIC ::   ntsim1                  !: start of tile domain
+   INTEGER, PUBLIC ::   ntsjm1                  !
+   INTEGER, PUBLIC ::   nteip1                  !: end of tile domain
+   INTEGER, PUBLIC ::   ntejp1                  !
+   INTEGER, PUBLIC ::   ntile                   !: current tile number
+
    !!---------------------------------------------------------------------
    !! Active tracer parameters
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step.F90	(revision 12765)
@@ -81,5 +81,5 @@
       !!              -8- Outputs and diagnostics
       !!----------------------------------------------------------------------
-      INTEGER ::   ji, jj, jk   ! dummy loop indice
+      INTEGER ::   ji, jj, jk, jtile   ! dummy loop indice
       INTEGER ::   indic        ! error indicator if < 0
 !!gm kcall can be removed, I guess
@@ -264,5 +264,11 @@
       IF( lrst_oce .AND. ln_zdfosm ) &
            &             CALL osm_rst    ( kstp,      Nnn, 'WRITE'  )  ! write OSMOSIS outputs + ww (so must do here) to restarts
+
+      ! Loop over tile domains
+      DO jtile = 1, jpnijtile
+         IF( ln_tile )   CALL dom_tile( jtile )
                          CALL tra_ldf    ( kstp, Nbb, Nnn, ts, Nrhs )  ! lateral mixing
+      END DO
+      IF( ln_tile )      CALL dom_tile( 0 )                            ! Revert to tile over full domain
 
                          CALL tra_zdf    ( kstp, Nbb, Nnn, Nrhs, ts, Naa  )  ! vertical mixing and after tracer fields
Index: /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step_oce.F90
===================================================================
--- /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step_oce.F90	(revision 12764)
+++ /NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step_oce.F90	(revision 12765)
@@ -62,4 +62,5 @@
    USE domvvl          ! variable vertical scale factors  (dom_vvl_sf_nxt routine)
    !                                                       (dom_vvl_sf_swp routine)
+   USE domain   , ONLY : dom_tile
 
    USE ldfslp          ! iso-neutral slopes               (ldf_slp routine)
