Index: NEMO/branches/2020/r12377_ticket2386/src/OCE/SBC/sbcrnf.F90
===================================================================
--- NEMO/branches/2020/r12377_ticket2386/src/OCE/SBC/sbcrnf.F90	(revision 12511)
+++ NEMO/branches/2020/r12377_ticket2386/src/OCE/SBC/sbcrnf.F90	(revision 13540)
@@ -72,4 +72,5 @@
    !! * Substitutions
 #  include "do_loop_substitute.h90"
+#  include "domzgr_substitute.h90"
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -159,7 +160,7 @@
             & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields red in the restart file', lrxios
-            CALL iom_get( numror, jpdom_autoglo, 'rnf_b', rnf_b, ldxios = lrxios )     ! before runoff
-            CALL iom_get( numror, jpdom_autoglo, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before heat content of runoff
-            CALL iom_get( numror, jpdom_autoglo, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salinity content of runoff
+            CALL iom_get( numror, jpdom_auto, 'rnf_b', rnf_b, ldxios = lrxios )     ! before runoff
+            CALL iom_get( numror, jpdom_auto, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before heat content of runoff
+            CALL iom_get( numror, jpdom_auto, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salinity content of runoff
          ELSE                                                   !* no restart: set from nit000 values
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000'
@@ -208,5 +209,5 @@
       IF( ln_rnf_depth .OR. ln_rnf_depth_ini ) THEN      !==   runoff distributed over several levels   ==!
          IF( ln_linssh ) THEN    !* constant volume case : just apply the runoff input flow
-            DO_2D_11_11
+            DO_2D( 1, 1, 1, 1 )
                DO jk = 1, nk_rnf(ji,jj)
                   phdivn(ji,jj,jk) = phdivn(ji,jj,jk) - ( rnf(ji,jj) + rnf_b(ji,jj) ) * zfact * r1_rho0 / h_rnf(ji,jj)
@@ -214,7 +215,7 @@
             END_2D
          ELSE                    !* variable volume case
-            DO_2D_11_11
+            DO_2D( 1, 1, 1, 1 )              ! update the depth over which runoffs are distributed
                h_rnf(ji,jj) = 0._wp
-               DO jk = 1, nk_rnf(ji,jj)                           ! recalculates h_rnf to be the depth in metres
+               DO jk = 1, nk_rnf(ji,jj)                             ! recalculates h_rnf to be the depth in metres
                   h_rnf(ji,jj) = h_rnf(ji,jj) + e3t(ji,jj,jk,Kmm)   ! to the bottom of the relevant grid box
                END DO
@@ -353,12 +354,12 @@
          rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname )
          IF( .NOT. sn_dep_rnf%ln_clim ) THEN   ;   WRITE(rn_dep_file, '(a,"_y",i4)' ) TRIM( rn_dep_file ), nyear    ! add year 
-            IF( sn_dep_rnf%cltype == 'monthly' )   WRITE(rn_dep_file, '(a,"m",i2)'  ) TRIM( rn_dep_file ), nmonth   ! add month 
-         ENDIF
-         CALL iom_open ( rn_dep_file, inum )                           ! open file
-         CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array
-         CALL iom_close( inum )                                        ! close file
+            IF( sn_dep_rnf%clftyp == 'monthly' )   WRITE(rn_dep_file, '(a,"m",i2)'  ) TRIM( rn_dep_file ), nmonth   ! add month 
+         ENDIF
+         CALL iom_open ( rn_dep_file, inum )                             ! open file
+         CALL iom_get  ( inum, jpdom_global, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array
+         CALL iom_close( inum )                                          ! close file
          !
          nk_rnf(:,:) = 0                               ! set the number of level over which river runoffs are applied
-         DO_2D_11_11
+         DO_2D( 1, 1, 1, 1 )
             IF( h_rnf(ji,jj) > 0._wp ) THEN
                jk = 2
@@ -373,5 +374,5 @@
             ENDIF
          END_2D
-         DO_2D_11_11
+         DO_2D( 1, 1, 1, 1 )                           ! set the associated depth
             h_rnf(ji,jj) = 0._wp
             DO jk = 1, nk_rnf(ji,jj)
@@ -390,8 +391,8 @@
          CALL iom_open( TRIM( sn_rnf%clname ), inum )    !  open runoff file
          nbrec = iom_getszuld( inum )
-         zrnfcl(:,:,1) = 0._wp                                                          ! init the max to 0. in 1
+         zrnfcl(:,:,1) = 0._wp                                                            ! init the max to 0. in 1
          DO jm = 1, nbrec
-            CALL iom_get( inum, jpdom_data, TRIM( sn_rnf%clvar ), zrnfcl(:,:,2), jm )   ! read the value in 2
-            zrnfcl(:,:,1) = MAXVAL( zrnfcl(:,:,:), DIM=3 )                              ! store the maximum value in time in 1
+            CALL iom_get( inum, jpdom_global, TRIM( sn_rnf%clvar ), zrnfcl(:,:,2), jm )   ! read the value in 2
+            zrnfcl(:,:,1) = MAXVAL( zrnfcl(:,:,:), DIM=3 )                                ! store the maximum value in time in 1
          END DO
          CALL iom_close( inum )
@@ -403,5 +404,5 @@
          WHERE( zrnfcl(:,:,1) > 0._wp )  h_rnf(:,:) = zacoef * zrnfcl(:,:,1)   ! compute depth for all runoffs
          !
-         DO_2D_11_11
+         DO_2D( 1, 1, 1, 1 )                ! take in account min depth of ocean rn_hmin
             IF( zrnfcl(ji,jj,1) > 0._wp ) THEN
                jk = mbkt(ji,jj)
@@ -411,5 +412,5 @@
          !
          nk_rnf(:,:) = 0                       ! number of levels on which runoffs are distributed
-         DO_2D_11_11
+         DO_2D( 1, 1, 1, 1 )
             IF( zrnfcl(ji,jj,1) > 0._wp ) THEN
                jk = 2
@@ -422,5 +423,5 @@
          END_2D
          !
-         DO_2D_11_11
+         DO_2D( 1, 1, 1, 1 )                          ! set the associated depth
             h_rnf(ji,jj) = 0._wp
             DO jk = 1, nk_rnf(ji,jj)
@@ -518,11 +519,11 @@
       cl_rnfile = TRIM( cn_dir )//TRIM( sn_cnf%clname )
       IF( .NOT. sn_cnf%ln_clim ) THEN   ;   WRITE(cl_rnfile, '(a,"_y",i4)' ) TRIM( cl_rnfile ), nyear    ! add year
-         IF( sn_cnf%cltype == 'monthly' )   WRITE(cl_rnfile, '(a,"m",i2)'  ) TRIM( cl_rnfile ), nmonth   ! add month
+         IF( sn_cnf%clftyp == 'monthly' )   WRITE(cl_rnfile, '(a,"m",i2)'  ) TRIM( cl_rnfile ), nmonth   ! add month
       ENDIF
       !
       ! horizontal mask (read in NetCDF file)
-      CALL iom_open ( cl_rnfile, inum )                           ! open file
-      CALL iom_get  ( inum, jpdom_data, sn_cnf%clvar, rnfmsk )    ! read the river mouth array
-      CALL iom_close( inum )                                      ! close file
+      CALL iom_open ( cl_rnfile, inum )                             ! open file
+      CALL iom_get  ( inum, jpdom_global, sn_cnf%clvar, rnfmsk )    ! read the river mouth array
+      CALL iom_close( inum )                                        ! close file
       !
       IF( l_clo_rnf )   CALL clo_rnf( rnfmsk )   ! closed sea inflow set as river mouth
