Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/BDY/bdyice.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/BDY/bdyice.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/BDY/bdyice.F90	(revision 13741)
@@ -61,7 +61,5 @@
       !!----------------------------------------------------------------------
       ! controls
-      IF( ln_timing    )   CALL timing_start('bdy_ice_thd')                                                            ! timing
-      IF( ln_icediachk )   CALL ice_cons_hsm(0,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
-      IF( ln_icediachk )   CALL ice_cons2D  (0,'bdy_ice_thd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
+      IF( ln_timing )   CALL timing_start('bdy_ice_thd')   ! timing
       !
       CALL ice_var_glo2eqv
@@ -110,8 +108,6 @@
       !
       ! controls
-      IF( ln_icectl    )   CALL ice_prt     ( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )                        ! prints
-      IF( ln_icediachk )   CALL ice_cons_hsm(1,'bdy_ice_thd', rdiag_v, rdiag_s, rdiag_t, rdiag_fv, rdiag_fs, rdiag_ft) ! conservation
-      IF( ln_icediachk )   CALL ice_cons2D  (1,'bdy_ice_thd',  diag_v,  diag_s,  diag_t,  diag_fv,  diag_fs,  diag_ft) ! conservation
-      IF( ln_timing    )   CALL timing_stop ('bdy_ice_thd')                                                            ! timing
+      IF( ln_icectl )   CALL ice_prt     ( kt, iiceprt, jiceprt, 1, ' - ice thermo bdy - ' )   ! prints
+      IF( ln_timing )   CALL timing_stop ('bdy_ice_thd')                                       ! timing
       !
    END SUBROUTINE bdy_ice
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DIA/diaptr.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DIA/diaptr.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DIA/diaptr.F90	(revision 13741)
@@ -42,19 +42,14 @@
    END INTERFACE
 
-   PUBLIC   ptr_sj         ! call by tra_ldf & tra_adv routines
-   PUBLIC   ptr_sjk        ! 
-   PUBLIC   dia_ptr_init   ! call in memogcm
    PUBLIC   dia_ptr        ! call in step module
    PUBLIC   dia_ptr_hst    ! called from tra_ldf/tra_adv routines
 
-   !                                  !!** namelist  namptr  **
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hstr_adv, hstr_ldf, hstr_eiv   !: Heat/Salt TRansports(adv, diff, Bolus.)
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:)   ::   hstr_ove, hstr_btr, hstr_vtr   !: heat Salt TRansports(overturn, baro, merional)
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:,:) ::   pvtr_int, pzon_int             !: Other zonal integrals
 
-   LOGICAL , PUBLIC ::   l_diaptr        !: tracers  trend flag (set from namelist in trdini)
-   INTEGER, PARAMETER, PUBLIC ::   nptr = 5  ! (glo, atl, pac, ind, ipc)
-   INTEGER, PARAMETER         ::   jp_msk = 3
-   INTEGER, PARAMETER         ::   jp_vtr = 4
+   LOGICAL, PUBLIC    ::   l_diaptr       !: tracers  trend flag
+   INTEGER, PARAMETER ::   jp_msk = 3
+   INTEGER, PARAMETER ::   jp_vtr = 4
 
    REAL(wp) ::   rc_sv    = 1.e-6_wp   ! conversion from m3/s to Sverdrup
@@ -65,6 +60,6 @@
    REAL(wp), ALLOCATABLE, SAVE, DIMENSION(:,:,:) :: btmsk34 ! mask out Southern Ocean (=0 south of 34°S)
 
-   LOGICAL ::   ll_init = .TRUE.        !: tracers  trend flag (set from namelist in trdini)
-   
+   LOGICAL ::   ll_init = .TRUE.        !: tracers  trend flag
+
    !! * Substitutions
 #  include "do_loop_substitute.h90"
@@ -89,5 +84,5 @@
       IF( ln_timing )   CALL timing_start('dia_ptr')
 
-      IF( kt == nit000 .AND. ll_init )   CALL dia_ptr_init
+      IF( kt == nit000 .AND. ll_init )   CALL dia_ptr_init    ! -> will define l_diaptr and nbasin
       !
       IF( l_diaptr ) THEN
@@ -123,14 +118,18 @@
       !
       !overturning calculation
-      REAL(wp), DIMENSION(jpj,jpk,nptr) :: sjk, r1_sjk, v_msf  ! i-mean i-k-surface and its inverse
-      REAL(wp), DIMENSION(jpj,jpk,nptr) :: zt_jk, zs_jk ! i-mean T and S, j-Stream-Function
-
-      REAL(wp), DIMENSION(jpi,jpj,jpk,nptr)  :: z4d1, z4d2
-      REAL(wp), DIMENSION(jpi,jpj,nptr)      :: z3dtr ! i-mean T and S, j-Stream-Function
-      !!----------------------------------------------------------------------
-
+      REAL(wp), DIMENSION(:,:,:  ), ALLOCATABLE ::   sjk, r1_sjk, v_msf  ! i-mean i-k-surface and its inverse
+      REAL(wp), DIMENSION(:,:,:  ), ALLOCATABLE ::   zt_jk, zs_jk        ! i-mean T and S, j-Stream-Function
+
+      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE ::   z4d1, z4d2
+      REAL(wp), DIMENSION(:,:,:  ), ALLOCATABLE ::   z3dtr
+      !!----------------------------------------------------------------------
+      !
+      ALLOCATE( z3dtr(jpi,jpj,nbasin) )
+      !
       IF( PRESENT( pvtr ) ) THEN
          IF( iom_use( 'zomsf' ) ) THEN    ! effective MSF
-            DO jn = 1, nptr                                    ! by sub-basins
+            ALLOCATE( z4d1(jpi,jpj,jpk,nbasin) )
+            !
+            DO jn = 1, nbasin                                    ! by sub-basins
                z4d1(1,:,:,jn) =  pvtr_int(:,:,jp_vtr,jn)                  ! zonal cumulative effective transport excluding closed seas
                DO jk = jpkm1, 1, -1
@@ -142,7 +141,12 @@
             END DO
             CALL iom_put( 'zomsf', z4d1 * rc_sv )
+            !
+            DEALLOCATE( z4d1 )
          ENDIF
          IF( iom_use( 'sopstove' ) .OR. iom_use( 'sophtove' ) ) THEN
-            DO jn = 1, nptr
+            ALLOCATE( sjk(jpj,jpk,nbasin), r1_sjk(jpj,jpk,nbasin), v_msf(jpj,jpk,nbasin),   &
+               &      zt_jk(jpj,jpk,nbasin), zs_jk(jpj,jpk,nbasin) )
+            !
+            DO jn = 1, nbasin
                sjk(:,:,jn) = pvtr_int(:,:,jp_msk,jn)
                r1_sjk(:,:,jn) = 0._wp
@@ -156,5 +160,5 @@
                !
             ENDDO
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_ove(:,jp_tem,jn) * rc_pwatt  !  (conversion in PW)
                DO ji = 1, jpi
@@ -163,5 +167,5 @@
             ENDDO
             CALL iom_put( 'sophtove', z3dtr )
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_ove(:,jp_sal,jn) * rc_ggram !  (conversion in Gg)
                DO ji = 1, jpi
@@ -170,9 +174,13 @@
             ENDDO
             CALL iom_put( 'sopstove', z3dtr )
+            !
+            DEALLOCATE( sjk, r1_sjk, v_msf, zt_jk, zs_jk )
          ENDIF
 
          IF( iom_use( 'sopstbtr' ) .OR. iom_use( 'sophtbtr' ) ) THEN
             ! Calculate barotropic heat and salt transport here 
-            DO jn = 1, nptr
+            ALLOCATE( sjk(jpj,1,nbasin), r1_sjk(jpj,1,nbasin) )
+            !
+            DO jn = 1, nbasin
                sjk(:,1,jn) = SUM( pvtr_int(:,:,jp_msk,jn), 2 )
                r1_sjk(:,1,jn) = 0._wp
@@ -186,6 +194,7 @@
                !
             ENDDO
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_btr(:,jp_tem,jn) * rc_pwatt  !  (conversion in PW)
+               ! TODO: Change these loop indices in the next commit
                DO ji = 1, jpi
                   z3dtr(ji,:,jn) = z3dtr(1,:,jn)
@@ -193,5 +202,5 @@
             ENDDO
             CALL iom_put( 'sophtbtr', z3dtr )
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_btr(:,jp_sal,jn) * rc_ggram !  (conversion in Gg)
                DO ji = 1, jpi
@@ -200,5 +209,7 @@
             ENDDO
             CALL iom_put( 'sopstbtr', z3dtr )
-         ENDIF 
+            !
+            DEALLOCATE( sjk, r1_sjk )
+         ENDIF
          !
          hstr_ove(:,:,:) = 0._wp       ! Zero before next timestep
@@ -207,6 +218,7 @@
       ELSE
          IF( iom_use( 'zotem' ) .OR. iom_use( 'zosal' ) .OR. iom_use( 'zosrf' )  ) THEN    ! i-mean i-k-surface
-            !
-            DO jn = 1, nptr
+            ALLOCATE( z4d1(jpi,jpj,jpk,nbasin), z4d2(jpi,jpj,jpk,nbasin) )
+            !
+            DO jn = 1, nbasin
                z4d1(1,:,:,jn) = pzon_int(:,:,jp_msk,jn)
                DO ji = 2, jpi
@@ -216,5 +228,5 @@
             CALL iom_put( 'zosrf', z4d1 )
             !
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z4d2(1,:,:,jn) = pzon_int(:,:,jp_tem,jn) / MAX( z4d1(1,:,:,jn), 10.e-15 )
                DO ji = 2, jpi
@@ -224,5 +236,5 @@
             CALL iom_put( 'zotem', z4d2 )
             !
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z4d2(1,:,:,jn) = pzon_int(:,:,jp_sal,jn) / MAX( z4d1(1,:,:,jn), 10.e-15 )
                DO ji = 2, jpi
@@ -232,4 +244,5 @@
             CALL iom_put( 'zosal', z4d2 )
             !
+            DEALLOCATE( z4d1, z4d2 )
          ENDIF
          !
@@ -237,5 +250,5 @@
          IF( iom_use( 'sophtadv' ) .OR. iom_use( 'sopstadv' ) ) THEN  
             ! 
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_adv(:,jp_tem,jn) * rc_pwatt  !  (conversion in PW)
                DO ji = 1, jpi
@@ -244,5 +257,5 @@
             ENDDO
             CALL iom_put( 'sophtadv', z3dtr )
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_adv(:,jp_sal,jn) * rc_ggram !  (conversion in Gg)
                DO ji = 1, jpi
@@ -255,5 +268,5 @@
          IF( iom_use( 'sophtldf' ) .OR. iom_use( 'sopstldf' ) ) THEN  
             ! 
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_ldf(:,jp_tem,jn) * rc_pwatt  !  (conversion in PW)
                DO ji = 1, jpi
@@ -262,5 +275,5 @@
             ENDDO
             CALL iom_put( 'sophtldf', z3dtr )
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_ldf(:,jp_sal,jn) * rc_ggram !  (conversion in Gg)
                DO ji = 1, jpi
@@ -273,5 +286,5 @@
          IF( iom_use( 'sophteiv' ) .OR. iom_use( 'sopsteiv' ) ) THEN  
             ! 
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_eiv(:,jp_tem,jn) * rc_pwatt  !  (conversion in PW)
                DO ji = 1, jpi
@@ -280,5 +293,5 @@
             ENDDO
             CALL iom_put( 'sophteiv', z3dtr )
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_eiv(:,jp_sal,jn) * rc_ggram !  (conversion in Gg)
                DO ji = 1, jpi
@@ -290,5 +303,5 @@
          !
          IF( iom_use( 'sopstvtr' ) .OR. iom_use( 'sophtvtr' ) ) THEN
-             DO jn = 1, nptr
+             DO jn = 1, nbasin
                 z3dtr(1,:,jn) = hstr_vtr(:,jp_tem,jn) * rc_pwatt  !  (conversion in PW)
                 DO ji = 1, jpi
@@ -297,5 +310,5 @@
              ENDDO
              CALL iom_put( 'sophtvtr', z3dtr )
-             DO jn = 1, nptr
+             DO jn = 1, nbasin
                z3dtr(1,:,jn) = hstr_vtr(:,jp_sal,jn) * rc_ggram !  (conversion in Gg)
                DO ji = 1, jpi
@@ -322,4 +335,7 @@
          pzon_int(:,:,:,:) = 0._wp
       ENDIF
+      !
+      DEALLOCATE( z3dtr )
+      !
    END SUBROUTINE dia_ptr_iom
 
@@ -339,8 +355,8 @@
       INTEGER                     , INTENT(in)           :: Kmm          ! time level index
       REAL(wp), DIMENSION(ST_2D(nn_hls),jpk), INTENT(in), OPTIONAL :: pvtr         ! j-effective transport
-      REAL(wp), DIMENSION(ST_2D(nn_hls),jpk)                       :: zmask        ! 3D workspace
-      REAL(wp), DIMENSION(ST_2D(nn_hls),jpk,jpts)                  :: zts          ! 4D workspace
-      REAL(wp), DIMENSION(ST_1Dj(nn_hls),jpk,nptr)                 :: sjk, v_msf   ! Zonal sum: i-k surface area, j-effective transport
-      REAL(wp), DIMENSION(ST_1Dj(nn_hls),jpk,nptr)                 :: zt_jk, zs_jk ! Zonal sum: i-k surface area * (T, S)
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE            :: zmask        ! 3D workspace
+      REAL(wp), DIMENSION(:,:,:,:), ALLOCATABLE          :: zts          ! 4D workspace
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE            :: sjk, v_msf   ! Zonal sum: i-k surface area, j-effective transport
+      REAL(wp), DIMENSION(:,:,:), ALLOCATABLE            :: zt_jk, zs_jk ! Zonal sum: i-k surface area * (T, S)
       REAL(wp)                                           :: zsfc, zvfc   ! i-k surface area
       INTEGER  ::   ji, jj, jk, jn                                       ! dummy loop indices
@@ -350,9 +366,13 @@
          ! i sum of effective j transport excluding closed seas
          IF( iom_use( 'zomsf' ) .OR. iom_use( 'sopstove' ) .OR. iom_use( 'sophtove' ) ) THEN
-            DO jn = 1, nptr
+            ALLOCATE( v_msf(ST_1Dj(nn_hls),jpk,nbasin) )
+
+            DO jn = 1, nbasin
                v_msf(:,:,jn) = ptr_sjk( pvtr(:,:,:), btmsk34(:,:,jn) )
             ENDDO
 
             CALL ptr_sum( pvtr_int(:,:,jp_vtr,:), v_msf(:,:,:) )
+
+            DEALLOCATE( v_msf )
          ENDIF
 
@@ -360,4 +380,8 @@
          IF(  iom_use( 'sopstove' ) .OR. iom_use( 'sophtove' ) .OR.   &
             & iom_use( 'sopstbtr' ) .OR. iom_use( 'sophtbtr' ) ) THEN
+            ALLOCATE( zmask(ST_2D(nn_hls),jpk), zts(ST_2D(nn_hls),jpk,jpts), &
+               &      sjk(ST_1Dj(nn_hls),jpk,nbasin), &
+               &      zt_jk(ST_1Dj(nn_hls),jpk,nbasin), zs_jk(ST_1Dj(nn_hls),jpk,nbasin) )
+
             zmask(:,:,:) = 0._wp
             zts(:,:,:,:) = 0._wp
@@ -370,5 +394,5 @@
             END_3D
 
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                sjk(:,:,jn)   = ptr_sjk( zmask(:,:,:)     , btmsk(:,:,jn) )
                zt_jk(:,:,jn) = ptr_sjk( zts(:,:,:,jp_tem), btmsk(:,:,jn) )
@@ -379,8 +403,14 @@
             CALL ptr_sum( pvtr_int(:,:,jp_tem,:), zt_jk(:,:,:) )
             CALL ptr_sum( pvtr_int(:,:,jp_sal,:), zs_jk(:,:,:) )
+
+            DEALLOCATE( zmask, zts, sjk, zt_jk, zs_jk )
          ENDIF
       ELSE
          ! i sum of j surface area - temperature/salinity product on T grid
          IF( iom_use( 'zotem' ) .OR. iom_use( 'zosal' ) .OR. iom_use( 'zosrf' )  ) THEN
+            ALLOCATE( zmask(ST_2D(nn_hls),jpk), zts(ST_2D(nn_hls),jpk,jpts), &
+               &      sjk(ST_1Dj(nn_hls),jpk,nbasin), &
+               &      zt_jk(ST_1Dj(nn_hls),jpk,nbasin), zs_jk(ST_1Dj(nn_hls),jpk,nbasin) )
+
             zmask(:,:,:) = 0._wp
             zts(:,:,:,:) = 0._wp
@@ -393,5 +423,5 @@
             END_3D
 
-            DO jn = 1, nptr
+            DO jn = 1, nbasin
                sjk(:,:,jn)   = ptr_sjk( zmask(:,:,:)     , btmsk(:,:,jn) )
                zt_jk(:,:,jn) = ptr_sjk( zts(:,:,:,jp_tem), btmsk(:,:,jn) )
@@ -402,8 +432,12 @@
             CALL ptr_sum( pzon_int(:,:,jp_tem,:), zt_jk(:,:,:) )
             CALL ptr_sum( pzon_int(:,:,jp_sal,:), zs_jk(:,:,:) )
+
+            DEALLOCATE( zmask, zts, sjk, zt_jk, zs_jk )
          ENDIF
 
          ! i-k sum of j surface area - temperature/salinity product on V grid
          IF( iom_use( 'sopstvtr' ) .OR. iom_use( 'sophtvtr' ) ) THEN
+            ALLOCATE( zts(ST_2D(nn_hls),jpk,jpts) )
+
             zts(:,:,:,:) = 0._wp
 
@@ -416,4 +450,6 @@
             CALL dia_ptr_hst( jp_tem, 'vtr', zts(:,:,:,jp_tem) )
             CALL dia_ptr_hst( jp_sal, 'vtr', zts(:,:,:,jp_sal) )
+
+            DEALLOCATE( zts )
          ENDIF
       ENDIF
@@ -425,5 +461,5 @@
       !!                  ***  ROUTINE dia_ptr_init  ***
       !!                   
-      !! ** Purpose :   Initialization, namelist read
+      !! ** Purpose :   Initialization
       !!----------------------------------------------------------------------
       INTEGER ::  inum, jn           ! local integers
@@ -432,12 +468,13 @@
       !!----------------------------------------------------------------------
 
-      l_diaptr = .FALSE.
-      IF(   iom_use( 'zomsf'    ) .OR. iom_use( 'zotem'    ) .OR. iom_use( 'zosal'    ) .OR.  &
-         &  iom_use( 'zosrf'    ) .OR. iom_use( 'sopstove' ) .OR. iom_use( 'sophtove' ) .OR.  &
-         &  iom_use( 'sopstbtr' ) .OR. iom_use( 'sophtbtr' ) .OR. iom_use( 'sophtadv' ) .OR.  &
-         &  iom_use( 'sopstadv' ) .OR. iom_use( 'sophtldf' ) .OR. iom_use( 'sopstldf' ) .OR.  & 
-         &  iom_use( 'sophteiv' ) .OR. iom_use( 'sopsteiv' ) .OR. iom_use( 'sopstvtr' ) .OR.  &
-         &  iom_use( 'sophtvtr' ) .OR. iom_use( 'uocetr_vsum_cumul' ) )  l_diaptr  = .TRUE.
-
+      ! l_diaptr is defined with iom_use
+      !   --> dia_ptr_init must be done after the call to iom_init
+      !   --> cannot be .TRUE. without cpp key: key_iom -->  nbasin define by iom_init is initialized
+      l_diaptr = iom_use( 'zomsf'    ) .OR. iom_use( 'zotem'    ) .OR. iom_use( 'zosal'    ) .OR.  &
+         &       iom_use( 'zosrf'    ) .OR. iom_use( 'sopstove' ) .OR. iom_use( 'sophtove' ) .OR.  &
+         &       iom_use( 'sopstbtr' ) .OR. iom_use( 'sophtbtr' ) .OR. iom_use( 'sophtadv' ) .OR.  &
+         &       iom_use( 'sopstadv' ) .OR. iom_use( 'sophtldf' ) .OR. iom_use( 'sopstldf' ) .OR.  &
+         &       iom_use( 'sophteiv' ) .OR. iom_use( 'sopsteiv' ) .OR. iom_use( 'sopstvtr' ) .OR.  &
+         &       iom_use( 'sophtvtr' ) .OR. iom_use( 'uocetr_vsum_cumul' )
  
       IF(lwp) THEN                     ! Control print
@@ -445,5 +482,4 @@
          WRITE(numout,*) 'dia_ptr_init : poleward transport and msf initialization'
          WRITE(numout,*) '~~~~~~~~~~~~'
-         WRITE(numout,*) '   Namelist namptr : set ptr parameters'
          WRITE(numout,*) '      Poleward heat & salt transport (T) or not (F)      l_diaptr  = ', l_diaptr
       ENDIF
@@ -452,5 +488,5 @@
          !
          IF( dia_ptr_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'dia_ptr_init : unable to allocate arrays' )
-
+         !
          rc_pwatt = rc_pwatt * rho0_rcp          ! conversion from K.s-1 to PetaWatt
          rc_ggram = rc_ggram * rho0              ! conversion from m3/s to Gg/s
@@ -458,14 +494,15 @@
          IF( lk_mpp )   CALL mpp_ini_znl( numout )     ! Define MPI communicator for zonal sum
 
-         btmsk(:,:,:) = 0._wp
-         btmsk(:,:,1) = tmask_i(:,:)
-         CALL iom_open( 'subbasins', inum,  ldstop = .FALSE.  )
-         CALL iom_get( inum, jpdom_global, 'atlmsk', btmsk(:,:,2) )   ! Atlantic basin
-         CALL iom_get( inum, jpdom_global, 'pacmsk', btmsk(:,:,3) )   ! Pacific  basin
-         CALL iom_get( inum, jpdom_global, 'indmsk', btmsk(:,:,4) )   ! Indian   basin
-         CALL iom_close( inum )
-         btmsk(:,:,5) = MAX ( btmsk(:,:,3), btmsk(:,:,4) )          ! Indo-Pacific basin
-         DO jn = 2, nptr
-            btmsk(:,:,jn) = btmsk(:,:,jn) * tmask_i(:,:)               ! interior domain only
+         btmsk(:,:,1) = tmask_i(:,:)                 
+         IF( nbasin == 5 ) THEN   ! nbasin has been initialized in iom_init to define the axis "basin"
+            CALL iom_open( 'subbasins', inum )
+            CALL iom_get( inum, jpdom_global, 'atlmsk', btmsk(:,:,2) )   ! Atlantic basin
+            CALL iom_get( inum, jpdom_global, 'pacmsk', btmsk(:,:,3) )   ! Pacific  basin
+            CALL iom_get( inum, jpdom_global, 'indmsk', btmsk(:,:,4) )   ! Indian   basin
+            CALL iom_close( inum )
+            btmsk(:,:,5) = MAX ( btmsk(:,:,3), btmsk(:,:,4) )            ! Indo-Pacific basin
+         ENDIF
+         DO jn = 2, nbasin
+            btmsk(:,:,jn) = btmsk(:,:,jn) * tmask_i(:,:)                 ! interior domain only
          END DO
          ! JD : modification so that overturning streamfunction is available in Atlantic at 34S to compare with observations
@@ -476,6 +513,6 @@
          END WHERE
          btmsk34(:,:,1) = btmsk(:,:,1)                 
-         DO jn = 2, nptr
-            btmsk34(:,:,jn) = btmsk(:,:,jn) * zmsk(:,:)               ! interior domain only
+         DO jn = 2, nbasin
+            btmsk34(:,:,jn) = btmsk(:,:,jn) * zmsk(:,:)                  ! interior domain only
          ENDDO
 
@@ -508,8 +545,8 @@
       CHARACTER(len=3)                , INTENT(in)   :: cptr  ! transport type  'adv'/'ldf'/'eiv'
       REAL(wp), DIMENSION(ST_2D(nn_hls),jpk)    , INTENT(in)   :: pvflx ! 3D input array of advection/diffusion
-      REAL(wp), DIMENSION(ST_1Dj(nn_hls),nptr)                 :: zsj   !
+      REAL(wp), DIMENSION(ST_1Dj(nn_hls),nbasin)                 :: zsj   !
       INTEGER                                        :: jn    !
 
-      DO jn = 1, nptr
+      DO jn = 1, nbasin
          zsj(:,jn) = ptr_sj( pvflx(:,:,:), btmsk(:,:,jn) )
       ENDDO
@@ -536,5 +573,5 @@
       !!                    ***  ROUTINE ptr_sum_2d ***
       !!----------------------------------------------------------------------
-      !! ** Purpose : Add two 2D arrays with (j,nptr) dimensions
+      !! ** Purpose : Add two 2D arrays with (j,nbasin) dimensions
       !!
       !! ** Method  : - phstr = phstr + pva
@@ -543,11 +580,11 @@
       !! ** Action  : phstr
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpj,nptr) , INTENT(inout)         ::  phstr  !
-      REAL(wp), DIMENSION(ST_1Dj(nn_hls),nptr), INTENT(in)            ::  pva    !
+      REAL(wp), DIMENSION(jpj,nbasin) , INTENT(inout)         ::  phstr  !
+      REAL(wp), DIMENSION(ST_1Dj(nn_hls),nbasin), INTENT(in)            ::  pva    !
       INTEGER                                               ::  jj
 #if defined key_mpp_mpi
-      INTEGER, DIMENSION(1)          ::  ish1d
-      INTEGER, DIMENSION(2)          ::  ish2d
-      REAL(wp), DIMENSION(jpj*nptr)  ::  zwork
+      INTEGER, DIMENSION(1)           ::  ish1d
+      INTEGER, DIMENSION(2)           ::  ish2d
+      REAL(wp), DIMENSION(jpj*nbasin) ::  zwork
 #endif
 
@@ -558,6 +595,6 @@
 #if defined key_mpp_mpi
       IF( ntile == 0 .OR. ntile == nijtile ) THEN
-         ish1d(1) = jpj*nptr
-         ish2d(1) = jpj ; ish2d(2) = nptr
+         ish1d(1) = jpj*nbasin
+         ish2d(1) = jpj ; ish2d(2) = nbasin
          zwork(:) = RESHAPE( phstr(:,:), ish1d )
          CALL mpp_sum( 'diaptr', zwork, ish1d(1), ncomm_znl )
@@ -572,5 +609,5 @@
       !!                    ***  ROUTINE ptr_sum_3d ***
       !!----------------------------------------------------------------------
-      !! ** Purpose : Add two 3D arrays with (j,k,nptr) dimensions
+      !! ** Purpose : Add two 3D arrays with (j,k,nbasin) dimensions
       !!
       !! ** Method  : - phstr = phstr + pva
@@ -579,11 +616,11 @@
       !! ** Action  : phstr
       !!----------------------------------------------------------------------
-      REAL(wp), DIMENSION(jpj,jpk,nptr) , INTENT(inout)     ::  phstr  !
-      REAL(wp), DIMENSION(ST_1Dj(nn_hls),jpk,nptr), INTENT(in)        ::  pva    !
+      REAL(wp), DIMENSION(jpj,jpk,nbasin) , INTENT(inout)     ::  phstr  !
+      REAL(wp), DIMENSION(ST_1Dj(nn_hls),jpk,nbasin), INTENT(in)        ::  pva    !
       INTEGER                                               ::  jj, jk
 #if defined key_mpp_mpi
       INTEGER, DIMENSION(1)              ::  ish1d
       INTEGER, DIMENSION(3)              ::  ish3d
-      REAL(wp), DIMENSION(jpj*jpk*nptr)  ::  zwork
+      REAL(wp), DIMENSION(jpj*jpk*nbasin)  ::  zwork
 #endif
 
@@ -596,6 +633,6 @@
 #if defined key_mpp_mpi
       IF( ntile == 0 .OR. ntile == nijtile ) THEN
-         ish1d(1) = jpj*jpk*nptr
-         ish3d(1) = jpj ; ish3d(2) = jpk ; ish3d(3) = nptr
+         ish1d(1) = jpj*jpk*nbasin
+         ish3d(1) = jpj ; ish3d(2) = jpk ; ish3d(3) = nbasin
          zwork(:) = RESHAPE( phstr(:,:,:), ish1d )
          CALL mpp_sum( 'diaptr', zwork, ish1d(1), ncomm_znl )
@@ -615,12 +652,14 @@
       ierr(:) = 0
       !
+      ! nbasin has been initialized in iom_init to define the axis "basin"
+      !
       IF( .NOT. ALLOCATED( btmsk ) ) THEN
-         ALLOCATE( btmsk(jpi,jpj,nptr)    , btmsk34(jpi,jpj,nptr),   &
-            &      hstr_adv(jpj,jpts,nptr), hstr_eiv(jpj,jpts,nptr), &
-            &      hstr_ove(jpj,jpts,nptr), hstr_btr(jpj,jpts,nptr), &
-            &      hstr_ldf(jpj,jpts,nptr), hstr_vtr(jpj,jpts,nptr), STAT=ierr(1)  )
-            !
-         ALLOCATE( pvtr_int(jpj,jpk,jpts+2,nptr), &
-            &      pzon_int(jpj,jpk,jpts+1,nptr), STAT=ierr(2) )
+         ALLOCATE( btmsk(jpi,jpj,nbasin)    , btmsk34(jpi,jpj,nbasin),   &
+            &      hstr_adv(jpj,jpts,nbasin), hstr_eiv(jpj,jpts,nbasin), &
+            &      hstr_ove(jpj,jpts,nbasin), hstr_btr(jpj,jpts,nbasin), &
+            &      hstr_ldf(jpj,jpts,nbasin), hstr_vtr(jpj,jpts,nbasin), STAT=ierr(1)  )
+            !
+         ALLOCATE( pvtr_int(jpj,jpk,jpts+2,nbasin), &
+            &      pzon_int(jpj,jpk,jpts+1,nbasin), STAT=ierr(2) )
          !
          dia_ptr_alloc = MAXVAL( ierr )
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DIU/diu_bulk.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DIU/diu_bulk.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DIU/diu_bulk.F90	(revision 13741)
@@ -22,6 +22,6 @@
    
    ! Namelist parameters
-   LOGICAL, PUBLIC :: ln_diurnal
-   LOGICAL, PUBLIC :: ln_diurnal_only
+   LOGICAL, PUBLIC :: ln_diurnal      = .false.   ! force definition if diurnal_sst_bulk_init is not called
+   LOGICAL, PUBLIC :: ln_diurnal_only = .false.   ! force definition if diurnal_sst_bulk_init is not called
 
    ! Parameters
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/closea.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/closea.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/closea.F90	(revision 13741)
@@ -38,10 +38,11 @@
    LOGICAL, PUBLIC :: ln_clo_rnf       !: closed sea treated as runoff (update rnf mask)
 
-   LOGICAL, PUBLIC :: l_sbc_clo  !: T => net evap/precip over closed seas spread outover the globe/river mouth
-   LOGICAL, PUBLIC :: l_clo_rnf  !: T => Some closed seas output freshwater (RNF) to specified runoff points.
-
-   INTEGER, PUBLIC :: ncsg      !: number of closed seas global mappings (inferred from closea_mask_glo field)
-   INTEGER, PUBLIC :: ncsr      !: number of closed seas rnf    mappings (inferred from closea_mask_rnf field)
-   INTEGER, PUBLIC :: ncse      !: number of closed seas empmr  mappings (inferred from closea_mask_emp field)
+   ! WARNING: keep default definitions in the following lines as dom_clo is called only if ln_closea = .true.
+   LOGICAL, PUBLIC :: l_sbc_clo = .FALSE.   !: T => net evap/precip over closed seas spread outover the globe/river mouth
+   LOGICAL, PUBLIC :: l_clo_rnf = .FALSE.   !: T => Some closed seas output freshwater (RNF) to specified runoff points.
+
+   INTEGER, PUBLIC :: ncsg = 0   !: number of closed seas global mappings (inferred from closea_mask_glo field)
+   INTEGER, PUBLIC :: ncsr = 0   !: number of closed seas rnf    mappings (inferred from closea_mask_rnf field)
+   INTEGER, PUBLIC :: ncse = 0   !: number of closed seas empmr  mappings (inferred from closea_mask_emp field)
 
    INTEGER, PUBLIC, SAVE, ALLOCATABLE, DIMENSION(:,:) :: mask_opnsea, mask_csundef  !: mask defining the open sea and the undefined closed sea
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/daymod.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/daymod.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/daymod.F90	(revision 13741)
@@ -82,6 +82,7 @@
       ndt05   = NINT( 0.5 * rn_Dt  )
 
-      IF( .NOT. l_offline )   CALL day_rst( nit000, 'READ' )
-
+      lrst_oce = .NOT. l_offline   ! force definition of offline
+      IF( lrst_oce )   CALL day_rst( nit000, 'READ' )
+      
       ! set the calandar from ndastp (read in restart file and namelist)
       nyear   =   ndastp / 10000
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 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/dom_oce.F90	(revision 13741)
@@ -230,4 +230,9 @@
 
    !!----------------------------------------------------------------------
+   !! variable defined here to avoid circular dependencies...
+   !! ---------------------------------------------------------------------
+   INTEGER, PUBLIC ::   nbasin         ! number of basin to be considered in diaprt (glo, atl, pac, ind, ipc)
+
+   !!----------------------------------------------------------------------
    !! agrif domain
    !!----------------------------------------------------------------------
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 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DOM/domain.F90	(revision 13741)
@@ -121,6 +121,4 @@
          WRITE(numout,*)     '         cn_cfg = ', TRIM( cn_cfg ), '   nn_cfg = ', nn_cfg
       ENDIF
-      nn_wxios = 0
-      ln_xios_read = .FALSE.
       !
       !           !==  Reference coordinate system  ==!
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DYN/divhor.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DYN/divhor.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DYN/divhor.F90	(revision 13741)
@@ -78,5 +78,5 @@
       !
       DO_3D( 0, 0, 0, 0, 1, jpkm1 )                                    !==  Horizontal divergence  ==!
-         hdiv(ji,jj,jk) = (  e2u(ji  ,jj) * e3u(ji  ,jj,jk,Kmm) * uu(ji  ,jj,jk,Kmm)      &
+         hdiv(ji,jj,jk) = (   e2u(ji  ,jj) * e3u(ji  ,jj,jk,Kmm) * uu(ji  ,jj,jk,Kmm)      &
             &               - e2u(ji-1,jj) * e3u(ji-1,jj,jk,Kmm) * uu(ji-1,jj,jk,Kmm)      &
             &               + e1v(ji,jj  ) * e3v(ji,jj  ,jk,Kmm) * vv(ji,jj  ,jk,Kmm)      &
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DYN/wet_dry.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DYN/wet_dry.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/DYN/wet_dry.F90	(revision 13741)
@@ -57,5 +57,5 @@
    REAL(wp), PUBLIC  ::   ssh_ref     !: height of z=0 with respect to the geoid; 
 
-   LOGICAL,  PUBLIC  ::   ll_wd       !: Wetting/drying activation switch if either ln_wd_il or ln_wd_dl
+   LOGICAL,  PUBLIC  ::   ll_wd = .FALSE. !: Wetting/drying activation switch (ln_wd_il or ln_wd_dl) <- default def if wad_init not called
 
    PUBLIC   wad_init                  ! initialisation routine called by step.F90
@@ -111,5 +111,4 @@
 
       r_rn_wdmin1 = 1 / rn_wdmin1
-      ll_wd = .FALSE.
       IF( ln_wd_il .OR. ln_wd_dl ) THEN
          ll_wd = .TRUE.
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/FLO/flo_oce.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/FLO/flo_oce.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/FLO/flo_oce.F90	(revision 13741)
@@ -19,5 +19,5 @@
    !! ----------------
    LOGICAL, PUBLIC ::   ln_floats   !: Activate floats or not
-   INTEGER, PUBLIC ::   jpnfl       !: total number of floats during the run
+   INTEGER, PUBLIC ::   jpnfl = 0   !: total number of floats during the run
    INTEGER, PUBLIC ::   jpnnewflo   !: number of floats added in a new run
    INTEGER, PUBLIC ::   jpnrstflo   !: number of floats for the restart
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ICB/icbtrj.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ICB/icbtrj.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ICB/icbtrj.F90	(revision 13741)
@@ -35,5 +35,5 @@
    PUBLIC   icb_trj_end     ! routine called in icbstp.F90 module
 
-   INTEGER ::   num_traj
+   INTEGER ::   num_traj = 0
    INTEGER ::   n_dim, m_dim
    INTEGER ::   ntrajid
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/IOM/iom.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/IOM/iom.F90	(revision 13741)
@@ -123,4 +123,5 @@
       REAL(wp), DIMENSION(2,jpkam1)         :: za_bnds   ! ABL vertical boundaries
       LOGICAL ::   ll_closedef = .TRUE.
+      LOGICAL ::   ll_exist
       !!----------------------------------------------------------------------
       !
@@ -230,5 +231,5 @@
           CALL iom_set_axis_attr( "ghw_abl", bounds=za_bnds )
 
-          CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,jpnfl) /) )
+          CALL iom_set_axis_attr(  "nfloat", (/ (REAL(ji,wp), ji=1,jpnfl) /) )
 # if defined key_si3
           CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) )
@@ -243,5 +244,8 @@
           CALL iom_set_axis_attr( "iax_26C", (/ REAL(26,wp) /) )   ! strange syntaxe and idea...
           CALL iom_set_axis_attr( "iax_28C", (/ REAL(28,wp) /) )   ! strange syntaxe and idea...
-          CALL iom_set_axis_attr( "basin"  , (/ (REAL(ji,wp), ji=1,5) /) )
+          ! for diaprt, we need to define an axis which size can be 1 (default) or 5 (if the file subbasins.nc exists)
+          INQUIRE( FILE = 'subbasins.nc', EXIST = ll_exist )
+          nbasin = 1 + 4 * COUNT( (/ll_exist/) )
+          CALL iom_set_axis_attr( "basin"  , (/ (REAL(ji,wp), ji=1,nbasin) /) )
       ENDIF
       !
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/IOM/iom_def.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/IOM/iom_def.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/IOM/iom_def.F90	(revision 13741)
@@ -33,8 +33,8 @@
    INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
 !XIOS write restart   
-   LOGICAL, PUBLIC            ::   lwxios          !: write single file restart using XIOS
-   INTEGER, PUBLIC            ::   nxioso          !: type of restart file when writing using XIOS 1 - single, 2 - multiple
+   LOGICAL, PUBLIC            ::   lwxios = .FALSE.    !: write single file restart using XIOS
+   INTEGER, PUBLIC            ::   nxioso = 0          !: type of restart file when writing using XIOS 1 - single, 2 - multiple
 !XIOS read restart   
-   LOGICAL, PUBLIC            ::   lrxios          !: read single file restart using XIOS
+   LOGICAL, PUBLIC            ::   lrxios = .FALSE.     !: read single file restart using XIOS
    LOGICAL, PUBLIC            ::   lxios_sini = .FALSE. ! is restart in a single file
    LOGICAL, PUBLIC            ::   lxios_set  = .FALSE. 
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ISF/isf_oce.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ISF/isf_oce.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ISF/isf_oce.F90	(revision 13741)
@@ -74,5 +74,5 @@
    !
    ! 2.1 -------- ice shelf cavity parameter --------------
-   LOGICAL , PUBLIC            :: l_isfoasis
+   LOGICAL , PUBLIC            :: l_isfoasis = .FALSE.
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)    ::   risfload                    !: ice shelf load
    REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:)    ::   fwfisf_oasis
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/LBC/lib_mpp.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/LBC/lib_mpp.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/LBC/lib_mpp.F90	(revision 13741)
@@ -511,4 +511,5 @@
             ALLOCATE(todelay(idvar)%y1d(isz))
             todelay(idvar)%y1d(:) = CMPLX(todelay(idvar)%z1d(:), 0., wp)   ! create %y1d, complex variable needed by mpi_sumdd
+            ndelayid(idvar) = MPI_REQUEST_NULL                             ! initialised request to a valid value
          END IF
       ENDIF
@@ -518,8 +519,8 @@
          ALLOCATE(todelay(idvar)%z1d(isz), todelay(idvar)%y1d(isz))   ! allocate also %z1d as used for the restart
          CALL mpi_allreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ierr )   ! get %y1d
-         todelay(idvar)%z1d(:) = REAL(todelay(idvar)%y1d(:), wp)      ! define %z1d from %y1d
-      ENDIF
-
-      IF( ndelayid(idvar) > 0 )   CALL mpp_delay_rcv( idvar )         ! make sure %z1d is received
+         ndelayid(idvar) = MPI_REQUEST_NULL
+      ENDIF
+
+      CALL mpp_delay_rcv( idvar )         ! make sure %z1d is received
 
       ! send back pout from todelay(idvar)%z1d defined at previous call
@@ -530,5 +531,5 @@
       IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
       CALL  mpi_allreduce( y_in(:), todelay(idvar)%y1d(:), isz, MPI_DOUBLE_COMPLEX, mpi_sumdd, ilocalcomm, ierr )
-      ndelayid(idvar) = 1
+      ndelayid(idvar) = MPI_REQUEST_NULL
       IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
 # else
@@ -591,4 +592,6 @@
             DEALLOCATE(todelay(idvar)%z1d)
             ndelayid(idvar) = -1                                      ! do as if we had no restart
+         ELSE
+            ndelayid(idvar) = MPI_REQUEST_NULL
          END IF
       ENDIF
@@ -598,7 +601,8 @@
          ALLOCATE(todelay(idvar)%z1d(isz))
          CALL mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_DOUBLE_PRECISION, mpi_max, ilocalcomm, ierr )   ! get %z1d
-      ENDIF
-
-      IF( ndelayid(idvar) > 0 )   CALL mpp_delay_rcv( idvar )         ! make sure %z1d is received
+         ndelayid(idvar) = MPI_REQUEST_NULL
+      ENDIF
+
+      CALL mpp_delay_rcv( idvar )         ! make sure %z1d is received
 
       ! send back pout from todelay(idvar)%z1d defined at previous call
@@ -606,7 +610,8 @@
 
       ! send p_in into todelay(idvar)%z1d with a non-blocking communication
+      ! (PM) Should we get rid of MPI2 option ? MPI3 was release in 2013. Who is still using MPI2 ?
 # if defined key_mpi2
       IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
-      CALL  mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_TYPE, mpi_max, ilocalcomm, ndelayid(idvar), ierr )
+      CALL  mpi_allreduce( p_in(:), todelay(idvar)%z1d(:), isz, MPI_TYPE, mpi_max, ilocalcomm, ierr )
       IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
 # else
@@ -631,13 +636,9 @@
       !!----------------------------------------------------------------------
 #if defined key_mpp_mpi
-      IF( ndelayid(kid) /= -2 ) THEN  
-#if ! defined key_mpi2
-         IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
-         CALL mpi_wait( ndelayid(kid), MPI_STATUS_IGNORE, ierr )                        ! make sure todelay(kid) is received
-         IF( ln_timing ) CALL tic_tac(.FALSE., ld_global = .TRUE.)
-#endif
-         IF( ASSOCIATED(todelay(kid)%y1d) )   todelay(kid)%z1d(:) = REAL(todelay(kid)%y1d(:), wp)  ! define %z1d from %y1d
-         ndelayid(kid) = -2   ! add flag to know that mpi_wait was already called on kid
-      ENDIF
+      IF( ln_timing ) CALL tic_tac( .TRUE., ld_global = .TRUE.)
+      ! test on ndelayid(kid) useless as mpi_wait return immediatly if the request handle is MPI_REQUEST_NULL
+      CALL mpi_wait( ndelayid(kid), MPI_STATUS_IGNORE, ierr ) ! after this ndelayid(kid) = MPI_REQUEST_NULL
+      IF( ln_timing ) CALL tic_tac( .FALSE., ld_global = .TRUE.)
+      IF( ASSOCIATED(todelay(kid)%y1d) )   todelay(kid)%z1d(:) = REAL(todelay(kid)%y1d(:), wp)  ! define %z1d from %y1d
 #endif
    END SUBROUTINE mpp_delay_rcv
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/LDF/ldftra.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/LDF/ldftra.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/LDF/ldftra.F90	(revision 13741)
@@ -246,8 +246,5 @@
       ENDIF
       !
-      IF( ln_ldfeiv .AND. .NOT.( ln_traldf_iso .OR. ln_traldf_triad ) )                &
-           &            CALL ctl_stop( 'ln_ldfeiv=T requires iso-neutral laplacian diffusion' )
-      IF( ln_isfcav .AND. ln_traldf_triad ) &
-           &            CALL ctl_stop( ' ice shelf cavity and traldf_triad not tested' )
+      IF( ln_isfcav .AND. ln_traldf_triad )   CALL ctl_stop( ' ice shelf cavity and traldf_triad not tested' )
            !
       IF(  nldf_tra == np_lap_i .OR. nldf_tra == np_lap_it .OR. &
@@ -541,4 +538,6 @@
          IF( ln_traldf_blp )   CALL ctl_stop( 'ldf_eiv_init: eddy induced velocity ONLY with laplacian diffusivity' )
          !
+         IF( .NOT.( ln_traldf_iso .OR. ln_traldf_triad ) )   &
+           &                  CALL ctl_stop( 'ln_ldfeiv=T requires iso-neutral laplacian diffusion' )
          !                                != allocate the aei arrays
          ALLOCATE( aeiu(jpi,jpj,jpk), aeiv(jpi,jpj,jpk), STAT=ierr )
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/SBC/sbcfwb.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/SBC/sbcfwb.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/SBC/sbcfwb.F90	(revision 13741)
@@ -94,4 +94,5 @@
          snwice_mass_b(:,:) = 0.e0               ! no sea-ice model is being used : no snow+ice mass
          snwice_mass  (:,:) = 0.e0
+         snwice_fmass (:,:) = 0.e0
 #endif
          !
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfdrg.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfdrg.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfdrg.F90	(revision 13741)
@@ -383,4 +383,5 @@
       IF(ll_bot)   zmsk_boost(:,:) = zmsk_boost(:,:) * ssmask(:,:)                         ! x seafloor mask
       !
+      l_log_not_linssh = .FALSE.    ! default definition
       !
       SELECT CASE( ndrg )
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfgls.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfgls.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfgls.F90	(revision 13741)
@@ -815,8 +815,4 @@
          WRITE(numout,*) '      Ice-ocean roughness (used if nn_z0_ice/=0)    rn_hsri        = ', rn_hsri
          WRITE(numout,*)
-         WRITE(numout,*) '   Namelist namdrg_top/_bot:   used values:'
-         WRITE(numout,*) '      top    ocean cavity roughness (m)             rn_z0(_top)   = ', r_z0_top
-         WRITE(numout,*) '      Bottom seafloor     roughness (m)             rn_z0(_bot)   = ', r_z0_bot
-         WRITE(numout,*)
       ENDIF
 
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfphy.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfphy.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdfphy.F90	(revision 13741)
@@ -337,4 +337,6 @@
       !
    END SUBROUTINE zdf_phy
+
+
    INTEGER FUNCTION zdf_phy_alloc()
       !!----------------------------------------------------------------------
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdftke.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdftke.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/ZDF/zdftke.F90	(revision 13741)
@@ -678,10 +678,4 @@
             CALL ctl_stop( 'zdf_tke_init: wrong value for nn_eice, should be 0,1,2, or 3')
          END SELECT      
-         IF( .NOT.ln_drg_OFF ) THEN
-            WRITE(numout,*)
-            WRITE(numout,*) '   Namelist namdrg_top/_bot:   used values:'
-            WRITE(numout,*) '      top    ocean cavity roughness (m)          rn_z0(_top)= ', r_z0_top
-            WRITE(numout,*) '      Bottom seafloor     roughness (m)          rn_z0(_bot)= ', r_z0_bot
-         ENDIF
          WRITE(numout,*)
          WRITE(numout,*) '   ==>>>   critical Richardson nb with your parameters  ri_cri = ', ri_cri
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/nemogcm.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/nemogcm.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/nemogcm.F90	(revision 13741)
@@ -54,5 +54,4 @@
    USE asminc         ! assimilation increments     
    USE asmbkg         ! writing out state trajectory
-   USE diaptr         ! poleward transports           (dia_ptr_init routine)
    USE diadct         ! sections transports           (dia_dct_init routine)
    USE diaobs         ! Observation diagnostics       (dia_obs_init routine)
@@ -472,5 +471,5 @@
       !                                         ! Lateral physics
                            CALL ldf_tra_init      ! Lateral ocean tracer physics
-                           CALL ldf_eiv_init      ! eddy induced velocity param.
+                           CALL ldf_eiv_init      ! eddy induced velocity param. must be done after ldf_tra_init
                            CALL ldf_dyn_init      ! Lateral ocean momentum physics
 
@@ -510,5 +509,4 @@
                            CALL     flo_init( Nnn )    ! drifting Floats
       IF( ln_diacfl    )   CALL dia_cfl_init    ! Initialise CFL diagnostics
-!                           CALL dia_ptr_init    ! Poleward TRansports initialization
                            CALL dia_dct_init    ! Sections tranports
                            CALL dia_hsb_init( Nnn )    ! heat content, salt content and volume budgets
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/stpctl.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/stpctl.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/stpctl.F90	(revision 13741)
@@ -67,5 +67,5 @@
       REAL(wp)                        ::   zzz                                   ! local real 
       REAL(wp), DIMENSION(9)          ::   zmax, zmaxlocal
-      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns
+      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce
       LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk
       CHARACTER(len=20)               ::   clname
@@ -125,4 +125,7 @@
       !
       llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0) == 1._wp         ! define only the inner domain
+      !
+      ll_0oce = .NOT. ANY( llmsk(:,:,1) )                                         ! no ocean point in the inner domain?
+      !
       IF( ll_wd ) THEN
          zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max
@@ -149,25 +152,30 @@
       ENDIF
       zmax(9) = REAL( nstop, wp )                                                 ! stop indicator
+      !
       !                                   !==               get global extrema             ==!
       !                                   !==  done by all processes if writting run.stat  ==!
       IF( ll_colruns ) THEN
          zmaxlocal(:) = zmax(:)
-         CALL mpp_max( "stpctl", zmax )          ! max over the global domain
+         CALL mpp_max( "stpctl", zmax )          ! max over the global domain: ok even of ll_0oce = .true. 
          nstop = NINT( zmax(9) )                 ! update nstop indicator (now sheared among all local domains)
-      ENDIF
+      ELSE
+         ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow.
+         IF( ll_0oce )   zmax(1:4) = (/ 0._wp, 0._wp, -1._wp, 1._wp /)   ! default "valid" values...
+      ENDIF
+      !
+      zmax(3) = -zmax(3)                         ! move back from max(-zz) to min(zz) : easier to manage! 
+      zmax(5) = -zmax(5)                         ! move back from max(-zz) to min(zz) : easier to manage!
+      IF( ll_colruns ) THEN
+         zmaxlocal(3) = -zmaxlocal(3)            ! move back from max(-zz) to min(zz) : easier to manage! 
+         zmaxlocal(5) = -zmaxlocal(5)            ! move back from max(-zz) to min(zz) : easier to manage!
+      ENDIF
+      !
       !                                   !==              write "run.stat" files              ==!
       !                                   !==  done only by 1st subdomain at writting timestep  ==!
       IF( ll_wrtruns ) THEN
-         WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4)
-         istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(4), (/ zmax(4)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(5), (/-zmax(5)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( nrunid, nvarid(6), (/ zmax(6)/), (/kt/), (/1/) )
-         IF( ln_zad_Aimp ) THEN
-            istatus = NF90_PUT_VAR( nrunid, nvarid(7), (/ zmax(7)/), (/kt/), (/1/) )
-            istatus = NF90_PUT_VAR( nrunid, nvarid(8), (/ zmax(8)/), (/kt/), (/1/) )
-         ENDIF
+         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3), zmax(4)
+         DO ji = 1, 6 + 2 * COUNT( (/ln_zad_Aimp/) )
+            istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) )
+         END DO
          IF( kt == nitend )   istatus = NF90_CLOSE(nrunid)
       END IF
@@ -175,11 +183,11 @@
       !                                   !==  done by all processes at every time step  ==!
       !
-      IF(   zmax(1) >   20._wp .OR.   &                   ! too large sea surface height ( > 20 m )
-         &  zmax(2) >   10._wp .OR.   &                   ! too large velocity ( > 10 m/s)
-         &  zmax(3) >=   0._wp .OR.   &                   ! negative or zero sea surface salinity
-         &  zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 )
-         &  zmax(4) <    0._wp .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice)
-         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests
-         &  ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
+      IF(  zmax(1) >   20._wp .OR.   &                   ! too large sea surface height ( > 20 m )
+         & zmax(2) >   10._wp .OR.   &                   ! too large velocity ( > 10 m/s)
+         & zmax(3) <=   0._wp .OR.   &                   ! negative or zero sea surface salinity
+         & zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 )
+         & zmax(4) <    0._wp .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice)
+         & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests
+         & ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests
          !
          iloc(:,:) = 0
@@ -221,8 +229,8 @@
          !
          WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
-         CALL wrt_line( ctmp2, kt, '|ssh| max',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) )
-         CALL wrt_line( ctmp3, kt, '|U|   max',  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) )
-         CALL wrt_line( ctmp4, kt, 'Sal   min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) )
-         CALL wrt_line( ctmp5, kt, 'Sal   max',  zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) )
+         CALL wrt_line( ctmp2, kt, '|ssh| max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) )
+         CALL wrt_line( ctmp3, kt, '|U|   max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) )
+         CALL wrt_line( ctmp4, kt, 'Sal   min', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) )
+         CALL wrt_line( ctmp5, kt, 'Sal   max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) )
          IF( Agrif_Root() ) THEN
             WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files'
Index: NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/timing.F90
===================================================================
--- NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/timing.F90	(revision 13563)
+++ NEMO/branches/2020/dev_r13383_HPC-02_Daley_Tiling/src/OCE/timing.F90	(revision 13741)
@@ -424,5 +424,5 @@
          s_timer => s_timer_root
          DO WHILE ( ASSOCIATED( s_timer%next ) )
-         IF (.NOT. ASSOCIATED(s_timer%next)) EXIT
+            IF (.NOT. ASSOCIATED(s_timer%next)) EXIT
             IF ( s_timer%tsum_clock < s_timer%next%tsum_clock ) THEN 
                ALLOCATE(s_wrk)
@@ -432,7 +432,7 @@
                ll_ord = .FALSE.
                CYCLE            
-            ENDIF           
-         IF( ASSOCIATED(s_timer%next) ) s_timer => s_timer%next
-         END DO         
+            ENDIF
+            IF( ASSOCIATED(s_timer%next) ) s_timer => s_timer%next
+         END DO
          IF( ll_ord ) EXIT
       END DO
@@ -447,8 +447,9 @@
       clfmt = '(1x,a,4x,f12.3,6x,f12.3,x,f12.3,2x,f12.3,6x,f7.3,2x,i9)'
       DO WHILE ( ASSOCIATED(s_timer) )
-         WRITE(numtime,TRIM(clfmt))   s_timer%cname,   &
-         &   s_timer%tsum_clock,s_timer%tsum_clock*100./t_elaps(2),            &
-         &   s_timer%tsum_cpu  ,s_timer%tsum_cpu*100./t_cpu(2)    ,            &
-         &   s_timer%tsum_cpu/s_timer%tsum_clock, s_timer%niter
+         IF( s_timer%tsum_clock > 0._wp )                                &
+            WRITE(numtime,TRIM(clfmt))   s_timer%cname,                  &
+            &   s_timer%tsum_clock,s_timer%tsum_clock*100./t_elaps(2),   &
+            &   s_timer%tsum_cpu  ,s_timer%tsum_cpu*100./t_cpu(2)    ,   &
+            &   s_timer%tsum_cpu/s_timer%tsum_clock, s_timer%niter
          s_timer => s_timer%next
       END DO
@@ -613,11 +614,12 @@
          clfmt = '((A),E15.7,2x,f6.2,5x,f12.2,5x,f6.2,5x,f7.2,2x,f12.2,4x,f6.2,2x,f9.2)'
          DO WHILE ( ASSOCIATED(sl_timer_ave) )
-            WRITE(numtime,TRIM(clfmt))   sl_timer_ave%cname(1:18),                            &
-            &   sl_timer_ave%tsum_clock,sl_timer_ave%tsum_clock*100.*jpnij/tot_etime,   &
-            &   sl_timer_ave%tsum_cpu  ,sl_timer_ave%tsum_cpu*100.*jpnij/tot_ctime  ,   &
-            &   sl_timer_ave%tsum_cpu/sl_timer_ave%tsum_clock,                          &
-            &   sl_timer_ave%tmax_clock*100.*jpnij/tot_etime,                           &
-            &   sl_timer_ave%tmin_clock*100.*jpnij/tot_etime,                           &                                               
-            &   sl_timer_ave%niter/REAL(jpnij)
+            IF( sl_timer_ave%tsum_clock > 0. )                                             & 
+               WRITE(numtime,TRIM(clfmt))   sl_timer_ave%cname(1:18),                      &
+               &   sl_timer_ave%tsum_clock,sl_timer_ave%tsum_clock*100.*jpnij/tot_etime,   &
+               &   sl_timer_ave%tsum_cpu  ,sl_timer_ave%tsum_cpu*100.*jpnij/tot_ctime  ,   &
+               &   sl_timer_ave%tsum_cpu/sl_timer_ave%tsum_clock,                          &
+               &   sl_timer_ave%tmax_clock*100.*jpnij/tot_etime,                           &
+               &   sl_timer_ave%tmin_clock*100.*jpnij/tot_etime,                           &
+               &   sl_timer_ave%niter/REAL(jpnij)
             sl_timer_ave => sl_timer_ave%next
          END DO
