Index: /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/cfgs/SHARED/namelist_ref
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/cfgs/SHARED/namelist_ref	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/cfgs/SHARED/namelist_ref	(revision 13514)
@@ -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_ltile_i = 10       !  Length of tiles in i
+   nn_ltile_j = 10       !  Length of tiles in j
 /
 !-----------------------------------------------------------------------
Index: /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/dom_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/dom_oce.F90	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/dom_oce.F90	(revision 13514)
@@ -73,4 +73,14 @@
    !                                !  = 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_ltile_i, nn_ltile_j
+
+   ! Domain tiling (all tiles)
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntsi_a       !: start of internal part of tile domain
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntsj_a       !
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntei_a       !: end of internal part of tile domain
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntej_a       !
 
    !                             !: domain MPP decomposition parameters
@@ -291,9 +301,9 @@
       ALLOCATE( e3t(jpi,jpj,jpk,jpt) , e3u (jpi,jpj,jpk,jpt) , e3v (jpi,jpj,jpk,jpt) , e3f(jpi,jpj,jpk) ,      &
          &      e3w(jpi,jpj,jpk,jpt) , e3uw(jpi,jpj,jpk,jpt) , e3vw(jpi,jpj,jpk,jpt)                    ,  STAT=ierr(ii) )
-#endif  
+#endif
          !
       ii = ii+1
       ALLOCATE( r3t  (jpi,jpj,jpt)   , r3u  (jpi,jpj,jpt)    , r3v  (jpi,jpj,jpt)    , r3f  (jpi,jpj) ,  &
-         &      r3t_f(jpi,jpj)       , r3u_f(jpi,jpj)        , r3v_f(jpi,jpj)                         ,  STAT=ierr(ii) )       
+         &      r3t_f(jpi,jpj)       , r3u_f(jpi,jpj)        , r3v_f(jpi,jpj)                         ,  STAT=ierr(ii) )
          !
       ii = ii+1
@@ -312,5 +322,5 @@
          !
       ii = ii+1
-      ALLOCATE( risfdep(jpi,jpj) , bathy(jpi,jpj) , STAT=ierr(ii)  ) 
+      ALLOCATE( risfdep(jpi,jpj) , bathy(jpi,jpj) , STAT=ierr(ii)  )
          !
       ii = ii+1
@@ -318,5 +328,5 @@
          !
       ii = ii+1
-      ALLOCATE( tmask_i(jpi,jpj) , tmask_h(jpi,jpj) ,                        & 
+      ALLOCATE( tmask_i(jpi,jpj) , tmask_h(jpi,jpj) ,                        &
          &      ssmask (jpi,jpj) , ssumask(jpi,jpj) , ssvmask(jpi,jpj) , ssfmask(jpi,jpj) ,     &
          &      mbkt   (jpi,jpj) , mbku   (jpi,jpj) , mbkv   (jpi,jpj) ,                    STAT=ierr(ii) )
@@ -326,5 +336,5 @@
          !
       ii = ii+1
-      ALLOCATE( tmask(jpi,jpj,jpk) , umask(jpi,jpj,jpk) ,     & 
+      ALLOCATE( tmask(jpi,jpj,jpk) , umask(jpi,jpj,jpk) ,     &
          &      vmask(jpi,jpj,jpk) , fmask(jpi,jpj,jpk) , STAT=ierr(ii) )
          !
Index: /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domain.F90
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domain.F90	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domain.F90	(revision 13514)
@@ -55,4 +55,5 @@
    PUBLIC   dom_init     ! called by nemogcm.F90
    PUBLIC   domain_cfg   ! called by nemogcm.F90
+   PUBLIC   dom_tile     ! called by step.F90
 
    !!-------------------------------------------------------------------------
@@ -125,6 +126,8 @@
       !           !==  Reference coordinate system  ==!
       !
-      CALL dom_glo                     ! global domain versus local domain
-      CALL dom_nam                     ! read namelist ( namrun, namdom )
+      CALL dom_glo                            ! global domain versus local domain
+      CALL dom_nam                            ! read namelist ( namrun, namdom )
+      CALL dom_tile( ntsi, ntsj, ntei, ntej ) ! Tile domain
+
       !
       IF( lwxios ) THEN
@@ -287,4 +290,81 @@
 
 
+   SUBROUTINE dom_tile( ktsi, ktsj, ktei, ktej, ktile )
+      !!----------------------------------------------------------------------
+      !!                     ***  ROUTINE dom_tile  ***
+      !!
+      !! ** Purpose :   Set tile domain variables
+      !!
+      !! ** Action  : - ktsi, ktsj     : start of internal part of domain
+      !!              - ktei, ktej     : end of internal part of domain
+      !!              - ntile          : current tile number
+      !!              - nijtile        : total number of tiles
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(out) :: ktsi, ktsj, ktei, ktej      ! Tile domain indices
+      INTEGER, INTENT(in), OPTIONAL :: ktile              ! Tile number
+      INTEGER ::   jt                                     ! dummy loop argument
+      INTEGER ::   iitile, ijtile                         ! Local integers
+      !!----------------------------------------------------------------------
+      IF( PRESENT(ktile) .AND. ln_tile ) THEN
+         ntile = ktile                 ! Set domain indices for tile
+         ktsi = ntsi_a(ktile)
+         ktsj = ntsj_a(ktile)
+         ktei = ntei_a(ktile)
+         ktej = ntej_a(ktile)
+      ELSE
+         ntile = 0                     ! Initialise to full domain
+         nijtile = 1
+         ktsi = Nis0
+         ktsj = Njs0
+         ktei = Nie0
+         ktej = Nje0
+
+         IF( ln_tile ) THEN            ! Calculate tile domain indices
+            iitile = Ni_0 / nn_ltile_i       ! Number of tiles
+            ijtile = Nj_0 / nn_ltile_j
+            IF( MOD( Ni_0, nn_ltile_i ) /= 0 ) iitile = iitile + 1
+            IF( MOD( Nj_0, nn_ltile_j ) /= 0 ) ijtile = ijtile + 1
+
+            nijtile = iitile * ijtile
+            ALLOCATE( ntsi_a(0:nijtile), ntsj_a(0:nijtile), ntei_a(0:nijtile), ntej_a(0:nijtile) )
+
+            ntsi_a(0) = ktsi                 ! Full domain
+            ntsj_a(0) = ktsj
+            ntei_a(0) = ktei
+            ntej_a(0) = ktej
+
+            DO jt = 1, nijtile               ! Tile domains
+               ntsi_a(jt) = Nis0 + nn_ltile_i * MOD(jt - 1, iitile)
+               ntsj_a(jt) = Njs0 + nn_ltile_j * ((jt - 1) / iitile)
+               ntei_a(jt) = MIN(ntsi_a(jt) + nn_ltile_i - 1, Nie0)
+               ntej_a(jt) = MIN(ntsj_a(jt) + nn_ltile_j - 1, Nje0)
+            ENDDO
+         ENDIF
+
+         IF(lwp) THEN                  ! control print
+            WRITE(numout,*)
+            WRITE(numout,*) 'dom_tile : Domain tiling decomposition'
+            WRITE(numout,*) '~~~~~~~~'
+            IF( ln_tile ) THEN
+               WRITE(numout,*) iitile, 'tiles in i'
+               WRITE(numout,*) '    Starting indices'
+               WRITE(numout,*) '        ', (ntsi_a(jt), jt=1, iitile)
+               WRITE(numout,*) '    Ending indices'
+               WRITE(numout,*) '        ', (ntei_a(jt), jt=1, iitile)
+               WRITE(numout,*) ijtile, 'tiles in j'
+               WRITE(numout,*) '    Starting indices'
+               WRITE(numout,*) '        ', (ntsj_a(jt), jt=1, nijtile, iitile)
+               WRITE(numout,*) '    Ending indices'
+               WRITE(numout,*) '        ', (ntej_a(jt), jt=1, nijtile, iitile)
+            ELSE
+               WRITE(numout,*) 'No domain tiling'
+               WRITE(numout,*) '    i indices =', ktsi, ':', ktei
+               WRITE(numout,*) '    j indices =', ktsj, ':', ktej
+            ENDIF
+         ENDIF
+      ENDIF
+   END SUBROUTINE dom_tile
+
+
    SUBROUTINE dom_nam
       !!----------------------------------------------------------------------
@@ -295,4 +375,5 @@
       !! ** input   : - namrun namelist
       !!              - namdom namelist
+      !!              - namtile namelist
       !!              - namnc4 namelist   ! "key_netcdf4" only
       !!----------------------------------------------------------------------
@@ -307,4 +388,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_ltile_i, nn_ltile_j
 #if defined key_netcdf4
       NAMELIST/namnc4/ nn_nchunks_i, nn_nchunks_j, nn_nchunks_k, ln_nc4zip
@@ -443,4 +525,24 @@
       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 )
+
+      IF(lwp) THEN
+         WRITE(numout,*)
+         WRITE(numout,*)    '   Namelist : namtile   ---   Domain tiling decomposition'
+         WRITE(numout,*)    '      Tiling (T) or not (F)                ln_tile    = ', ln_tile
+         WRITE(numout,*)    '      Length of tile in i                  nn_ltile_i = ', nn_ltile_i
+         WRITE(numout,*)    '      Length of tile in j                  nn_ltile_j = ', nn_ltile_j
+         WRITE(numout,*)
+         IF( ln_tile ) THEN
+            WRITE(numout,*) '      The domain will be decomposed into tiles of size', nn_ltile_i, 'x', nn_ltile_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/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domutl.F90
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domutl.F90	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domutl.F90	(revision 13514)
@@ -21,6 +21,11 @@
    PRIVATE
 
+   INTERFACE is_tile
+      MODULE PROCEDURE is_tile_2d, is_tile_3d, is_tile_4d
+   END INTERFACE is_tile
+
    PUBLIC dom_ngb    ! routine called in iom.F90 module
    PUBLIC dom_uniq   ! Called by dommsk and domwri
+   PUBLIC is_tile
 
    !!----------------------------------------------------------------------
@@ -115,5 +120,44 @@
       !
    END SUBROUTINE dom_uniq
-   
+
+
+   PURE FUNCTION is_tile_2d( pt )
+      !!
+      REAL(wp), DIMENSION(:,:), INTENT(in) ::   pt
+      INTEGER :: is_tile_2d
+      !!
+      IF( ln_tile .AND. SIZE(pt, 1) < jpi ) THEN
+         is_tile_2d = 1
+      ELSE
+         is_tile_2d = 0
+      ENDIF
+   END FUNCTION is_tile_2d
+
+
+   PURE FUNCTION is_tile_3d( pt )
+      !!
+      REAL(wp), DIMENSION(:,:,:), INTENT(in) ::   pt
+      INTEGER :: is_tile_3d
+      !!
+      IF( ln_tile .AND. SIZE(pt, 1) < jpi ) THEN
+         is_tile_3d = 1
+      ELSE
+         is_tile_3d = 0
+      ENDIF
+   END FUNCTION is_tile_3d
+
+
+   PURE FUNCTION is_tile_4d( pt )
+      !!
+      REAL(wp), DIMENSION(:,:,:,:), INTENT(in) ::   pt
+      INTEGER :: is_tile_4d
+      !!
+      IF( ln_tile .AND. SIZE(pt, 1) < jpi ) THEN
+         is_tile_4d = 1
+      ELSE
+         is_tile_4d = 0
+      ENDIF
+   END FUNCTION is_tile_4d
+
    !!======================================================================
 END MODULE domutl
Index: /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/do_loop_substitute.h90
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/do_loop_substitute.h90	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/do_loop_substitute.h90	(revision 13514)
@@ -59,5 +59,11 @@
 #endif
 
-#define DO_2D(B, T, L, R) DO jj = Njs0-(B), Nje0+(T)   ;   DO ji = Nis0-(L), Nie0+(R)
+#define DO_2D(B, T, L, R) DO jj = ntsj-(B), ntej+(T)   ;   DO ji = ntsi-(L), ntei+(R)
+#define ST_1Di(H) ntsi-H:ntei+H
+#define ST_1Dj(H) ntsj-H:ntej+H
+#define ST_2D(H) ST_1Di(H),ST_1Dj(H)
+#define ST_1DTi(T) (ntsi-nn_hls-1)*T+1:(ntei+nn_hls-jpi)*T+jpi
+#define ST_1DTj(T) (ntsj-nn_hls-1)*T+1:(ntej+nn_hls-jpj)*T+jpj
+#define ST_2DT(T) ST_1DTi(T),ST_1DTj(T)
 
 #define DO_3D(B, T, L, R, ks, ke) DO jk = ks, ke   ;   DO_2D(B, T, L, R)
Index: /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/par_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/par_oce.F90	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/par_oce.F90	(revision 13514)
@@ -65,4 +65,12 @@
    INTEGER, PUBLIC ::   jpjmax! = ( Nj0glo + jpnj-1 ) / jpnj + 2*nn_hls            !: maximum jpj
 
+   ! Domain tiling
+   INTEGER, PUBLIC ::   nijtile    !: number of tiles in total
+   INTEGER, PUBLIC ::   ntile      !: current tile number
+   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       !
+
    !!---------------------------------------------------------------------
    !! Active tracer parameters
Index: /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/step_oce.F90
===================================================================
--- /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/step_oce.F90	(revision 13513)
+++ /NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/step_oce.F90	(revision 13514)
@@ -9,4 +9,5 @@
    USE oce             ! ocean dynamics and tracers variables
    USE dom_oce         ! ocean space and time domain variables
+   USE domain, ONLY : dom_tile
    USE zdf_oce         ! ocean vertical physics variables
    USE zdfdrg  ,  ONLY : ln_drgimp   ! implicit top/bottom friction
