Index: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ISF/isfutils.F90
===================================================================
--- NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ISF/isfutils.F90	(revision 12270)
+++ NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/ISF/isfutils.F90	(revision 12271)
@@ -12,9 +12,9 @@
    !!----------------------------------------------------------------------
 
-   USE iom           , ONLY: iom_open, iom_get, iom_close, jpdom_data ! read input file
-   USE lib_fortran   , ONLY: glob_sum, glob_min, glob_max             ! compute global value
-   USE par_oce       , ONLY: jpi,jpj,jpk                              ! domain size
-   USE dom_oce       , ONLY: nldi, nlei, nldj, nlej                   ! local domain
-   USE in_out_manager, ONLY: i8, wp, lwp, numout                          ! miscelenious
+   USE iom           , ONLY: iom_open, iom_get, iom_close, jpdom_data        ! read input file
+   USE lib_fortran   , ONLY: glob_sum, glob_min, glob_max                    ! compute global value
+   USE par_oce       , ONLY: jpi,jpj,jpk, jpnij                              ! domain size
+   USE dom_oce       , ONLY: nldi, nlei, nldj, nlej, narea, tmask_h, tmask_i ! local domain
+   USE in_out_manager, ONLY: i8, wp, lwp, numout                             ! miscelenious
    USE lib_mpp
 
@@ -38,8 +38,8 @@
       !!
       !!-------------------------- OUT -------------------------------------
-      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) :: pvar          ! output variable
+      REAL(wp), DIMENSION(jpi,jpj), INTENT(  out) :: pvar     ! output variable
       !!-------------------------- IN  -------------------------------------
-      CHARACTER(len=256)          , INTENT(in   ) :: cdfile   ! input file name
-      CHARACTER(len=34)           , INTENT(in   ) :: cdvar    ! variable name
+      CHARACTER(len=*)            , INTENT(in   ) :: cdfile   ! input file name
+      CHARACTER(len=*)            , INTENT(in   ) :: cdvar    ! variable name
       !!--------------------------------------------------------------------
       INTEGER :: inum
@@ -64,5 +64,8 @@
       REAL(wp)    :: zmin, zmax, zsum
       INTEGER(i8) :: imodd, ip
-      INTEGER     :: itmps,imods, ji, jj, jk
+      INTEGER     :: imods
+      INTEGER     :: isums, idums
+      INTEGER     :: ji,jj,jk
+      INTEGER, DIMENSION(jpnij) :: itmps
       !!--------------------------------------------------------------------
       !
@@ -78,15 +81,23 @@
       imodd=65521 ! highest prime number < 2**16 with i8 type
       imods=65521 ! highest prime number < 2**16 with default integer for mpp_sum subroutine
-      itmps=0
+      isums=0 ; itmps(:)=0 ;
+      !
+      ! local MOD sum
       DO jj=nldj,nlej
          DO ji=nldi,nlei
-            itmps = MOD(itmps + MOD(TRANSFER(pvar(ji,jj), ip),imodd), imods)
+            idums = ABS(MOD(TRANSFER(pvar(ji,jj), ip),imodd))
+            itmps(narea) = MOD(itmps(narea) + idums, imods)
          END DO
       END DO
-      CALL mpp_sum('debug',itmps)
+      !
+      ! global MOD sum
+      CALL mpp_max('debug',itmps(:))
+      DO jk = 1,jpnij
+         isums = MOD(isums + itmps(jk),imods)
+      END DO
       !
       ! print out
       IF (lwp) THEN
-         WRITE(numout,*) TRIM(cdtxt),' (min, max, sum, tag) : ',zmin, zmax, zsum, itmps
+         WRITE(numout,*) TRIM(cdtxt),' (min, max, sum, tag) : ',zmin, zmax, zsum, isums
          CALL FLUSH(numout)
       END IF
@@ -104,7 +115,10 @@
       REAL(wp), DIMENSION(jpi,jpj,jpk), INTENT(in   ) :: pvar
       !!--------------------------------------------------------------------
-      REAL(wp) :: zmin, zmax, zsum
+      REAL(wp)    :: zmin, zmax, zsum
       INTEGER(i8) :: imodd, ip
-      INTEGER     :: itmps,imods, ji, jj, jk
+      INTEGER     :: imods
+      INTEGER     :: isums, idums
+      INTEGER     :: ji,jj,jk
+      INTEGER, DIMENSION(jpnij) :: itmps
       !!--------------------------------------------------------------------
       !
@@ -120,17 +134,25 @@
       imodd=65521 ! highest prime number < 2**16 with i8 type
       imods=65521 ! highest prime number < 2**16 with default integer for mpp_sum subroutine
-      itmps=0
+      itmps=0; isums=0
+      !
+      ! local MOD sum
       DO jk=1,jpk
          DO jj=nldj,nlej
             DO ji=nldi,nlei
-               itmps = MOD(itmps + MOD(TRANSFER(pvar(ji,jj,jk), ip),imodd), imods)
+               idums = ABS(MOD(TRANSFER(pvar(ji,jj,jk), ip),imodd))
+               itmps(narea) = MOD(itmps(narea) + idums, imods)
             END DO
          END DO
       END DO
-      CALL mpp_sum('debug',itmps)
+      !
+      ! global MOD sum
+      CALL mpp_max('debug',itmps)
+      DO jk = 1,jpnij
+         isums = MOD(isums+itmps(jk),imods)
+      END DO
       !
       ! print out
       IF (lwp) THEN
-         WRITE(numout,*) TRIM(cdtxt),' (min, max, sum, tag) : ',zmin, zmax, zsum, itmps
+         WRITE(numout,*) TRIM(cdtxt),' (min, max, sum, tag) : ',zmin, zmax, zsum, isums
          CALL FLUSH(numout)
       END IF
