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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/cfgs/SHARED/namelist_ref	(revision 12879)
@@ -99,6 +99,6 @@
 !-----------------------------------------------------------------------
    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
+   nn_ltile_i = 10       !  Length of tiles in i
+   nn_ltile_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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/dom_oce.F90	(revision 12879)
@@ -75,5 +75,5 @@
    ! Tiling namelist
    LOGICAL, PUBLIC ::   ln_tile
-   INTEGER         ::   nn_tile_i, nn_tile_j
+   INTEGER         ::   nn_ltile_i, nn_ltile_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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/DOM/domain.F90	(revision 12879)
@@ -49,5 +49,4 @@
 
    PUBLIC   dom_init     ! called by nemogcm.F90
-   PUBLIC   dom_tile     ! called by step.F90
    PUBLIC   domain_cfg   ! called by nemogcm.F90
 
@@ -123,7 +122,5 @@
       CALL dom_glo                     ! global domain versus local domain
       CALL dom_nam                     ! read namelist ( namrun, namdom )
-
-      ! Initialise tile to full domain
-      CALL dom_tile(0)
+      CALL dom_tile                    ! Tile domains
 
       !
@@ -275,43 +272,66 @@
 
 
-   SUBROUTINE dom_tile(kntile)
+   SUBROUTINE dom_tile
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE dom_tile  ***
       !!
-      !! ** Purpose :   Set domain indices for specified tile
-      !!
-      !! ** Action  : - ntile          : current tile number
-      !!              - ntsi, ntsj     : start of internal part of domain
+      !! ** Purpose :   Set tile domain variables
+      !!
+      !! ** Action  : - 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
+      !!              - nijtile        : total number of tiles
+      !!----------------------------------------------------------------------
+      INTEGER ::   jt               ! dummy loop argument
+      INTEGER ::   iitile, ijtile   ! Local integers
+      !!----------------------------------------------------------------------
+      ntile = 0                     ! Initialise to full domain indices
+
+      IF( ln_tile ) THEN            ! Set tile decomposition
+         iitile = (jpi - 2 * nn_hls) / nn_ltile_i
+         ijtile = (jpj - 2 * nn_hls) / nn_ltile_j
+         IF( MOD( jpi - 2 * nn_hls, nn_ltile_i ) /= 0 ) iitile = iitile + 1
+         IF( MOD( jpj - 2 * nn_hls, nn_ltile_j ) /= 0 ) ijtile = ijtile + 1
+
+         nijtile = iitile * ijtile
+         ALLOCATE( ntsi(0:nijtile), ntsj(0:nijtile), ntei(0:nijtile), ntej(0:nijtile) )
+      ELSE
+         nijtile = 1
+         ALLOCATE( ntsi(0:0), ntsj(0:0), ntei(0:0), ntej(0:0) )
+      ENDIF
+
+      ntsi(0) = 1 + nn_hls          ! Full domain
+      ntsj(0) = 1 + nn_hls
+      ntei(0) = jpi - nn_hls
+      ntej(0) = jpj - nn_hls
+
+      IF( ln_tile ) THEN            ! Tile domains
+         DO jt = 1, nijtile
+            ntsi(jt) = ntsi(0) + nn_ltile_i * MOD(jt - 1, iitile)
+            ntsj(jt) = ntsj(0) + nn_ltile_j * ((jt - 1) / iitile)
+            ntei(jt) = MIN(ntsi(jt) + nn_ltile_i - 1, ntei(0))
+            ntej(jt) = MIN(ntsj(jt) + nn_ltile_j - 1, ntej(0))
+         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(jt), jt=1, iitile)
+            WRITE(numout,*) '    Ending indices'
+            WRITE(numout,*) '        ', (ntei(jt), jt=1, iitile)
+            WRITE(numout,*) ijtile, 'tiles in j'
+            WRITE(numout,*) '    Starting indices'
+            WRITE(numout,*) '        ', (ntsj(jt), jt=1, nijtile, iitile)
+            WRITE(numout,*) '    Ending indices'
+            WRITE(numout,*) '        ', (ntej(jt), jt=1, nijtile, iitile)
+         ELSE
+            WRITE(numout,*) 'No domain tiling'
+            WRITE(numout,*) '    i indices =', ntsi(0), ':', ntei(0)
+            WRITE(numout,*) '    j indices =', ntsj(0), ':', ntej(0)
+         ENDIF
       ENDIF
    END SUBROUTINE dom_tile
@@ -339,5 +359,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
+      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
@@ -473,25 +493,13 @@
       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,*)    '   Namelist : namtile   ---   Domain 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,*)    '      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', jpnijtile, 'tiles of size', nn_tile_i, 'x', nn_tile_j
+            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'
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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf.F90	(revision 12879)
@@ -63,5 +63,5 @@
       ENDIF
       !
-      IF( ntile == jpnijtile )  THEN              ! Do only after all tiles finish
+      IF( ntile == nijtile )  THEN                ! Do only after all tiles finish
          IF( l_trdtra )   THEN                    !* Save ta and sa trends
             ! TODO: TO BE TILED
@@ -83,5 +83,5 @@
       END SELECT
       !
-      IF( ntile == jpnijtile )  THEN              ! Do only after all tiles finish
+      IF( ntile == nijtile )  THEN                ! Do only after all tiles finish
          IF( l_trdtra )   THEN                    !* save the horizontal diffusive trends for further diagnostics
             ! TODO: TO BE TILED
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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/TRA/traldf_iso.F90	(revision 12879)
@@ -109,6 +109,6 @@
       REAL(wp) ::  zmskv, zahv_w, zabe2, zcof2, zcoef4   !   -      -
       REAL(wp) ::  zcoef0, ze3w_2, zsign                 !   -      -
-      REAL(wp), DIMENSION(IND_2D)     ::   zdkt, zdk1t, z2d
-      REAL(wp), DIMENSION(IND_2D,jpk) ::   zdit, zdjt, zftu, zftv, ztfw
+      REAL(wp), DIMENSION(A2D)     ::   zdkt, zdk1t, z2d
+      REAL(wp), DIMENSION(A2D,jpk) ::   zdit, zdjt, zftu, zftv, ztfw
       !!----------------------------------------------------------------------
       !
@@ -321,5 +321,5 @@
          END_3D
          !
-         IF( ntile == jpnijtile )  THEN                        ! Do only after all tiles finish
+         IF( ntile == nijtile )  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)  ==!
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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/do_loop_substitute.h90	(revision 12879)
@@ -55,15 +55,15 @@
 !
 #endif
-#define __kIs_     ntsi
-#define __kJs_     ntsj
-#define __kIsm1_   ntsim1
-#define __kJsm1_   ntsjm1
+#define __kIs_     ntsi(ntile)
+#define __kJs_     ntsj(ntile)
+#define __kIsm1_   __kIs_ - nn_hls
+#define __kJsm1_   __kJs_ - nn_hls
 
-#define __kIe_     ntei
-#define __kJe_     ntej
-#define __kIep1_   nteip1
-#define __kJep1_   ntejp1
+#define __kIe_     ntei(ntile)
+#define __kJe_     ntej(ntile)
+#define __kIep1_   __kIe_ + nn_hls
+#define __kJep1_   __kJe_ + nn_hls
 
-#define IND_2D     __kIsm1_:__kIep1_,__kJsm1_:__kJep1_
+#define A2D        __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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/par_oce.F90	(revision 12879)
@@ -62,19 +62,11 @@
    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
+   ! Domain tiling
+   INTEGER, PUBLIC                                  ::   nijtile    !: number of tiles in total
+   INTEGER, PUBLIC                                  ::   ntile      !: current tile number
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntsi       !: start of internal part of tile domain
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntsj       !
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntei       !: end of internal part of tile domain
+   INTEGER, PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:) ::   ntej       !
 
    !!---------------------------------------------------------------------
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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step.F90	(revision 12879)
@@ -266,10 +266,9 @@
 
       ! Loop over tile domains
-      DO jtile = 1, jpnijtile
-         IF( ln_tile )   CALL dom_tile( jtile )
+      DO jtile = 1, nijtile
+         IF( ln_tile ) ntile = 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
-
+      IF( ln_tile ) ntile = 0                                          ! Revert to tile over full domain
                          CALL tra_zdf    ( kstp, Nbb, Nnn, Nrhs, ts, Naa  )  ! vertical mixing and after tracer fields
       IF( ln_zdfnpc  )   CALL tra_npc    ( kstp,      Nnn, Nrhs, ts, Naa  )  ! update after fields by non-penetrative convection
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 12765)
+++ NEMO/branches/UKMO/dev_r12745_HPC-02_Daley_Tiling_trial_public/src/OCE/step_oce.F90	(revision 12879)
@@ -62,5 +62,4 @@
    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)
