Index: trunk/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90
===================================================================
--- trunk/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 4528)
+++ trunk/NEMOGCM/NEMO/OPA_SRC/lib_fortran.F90	(revision 6140)
@@ -24,6 +24,7 @@
    PRIVATE
 
-   PUBLIC   glob_sum   ! used in many places
-   PUBLIC   DDPDD      ! also used in closea module
+   PUBLIC   glob_sum      ! used in many places (masked with tmask_i)
+   PUBLIC   glob_sum_full ! used in many places (masked with tmask_h, ie omly over the halos)
+   PUBLIC   DDPDD         ! also used in closea module
    PUBLIC   glob_min, glob_max
 #if defined key_nosignedzero
@@ -34,4 +35,7 @@
       MODULE PROCEDURE glob_sum_1d, glob_sum_2d, glob_sum_3d, &
          &             glob_sum_2d_a, glob_sum_3d_a
+   END INTERFACE
+   INTERFACE glob_sum_full
+      MODULE PROCEDURE glob_sum_full_2d, glob_sum_full_3d
    END INTERFACE
    INTERFACE glob_min
@@ -156,4 +160,44 @@
       !
    END FUNCTION glob_sum_3d_a
+
+   FUNCTION glob_sum_full_2d( ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  glob_sum_full_2d ***
+      !!
+      !! ** Purpose : perform a sum in calling DDPDD routine (nomask)
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab
+      REAL(wp)                             ::   glob_sum_full_2d   ! global sum
+      !!
+      !!-----------------------------------------------------------------------
+      !
+      glob_sum_full_2d = SUM( ptab(:,:) * tmask_h(:,:) )
+      IF( lk_mpp )   CALL mpp_sum( glob_sum_full_2d )
+      !
+   END FUNCTION glob_sum_full_2d
+
+   FUNCTION glob_sum_full_3d( ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  glob_sum_full_3d ***
+      !!
+      !! ** Purpose : perform a sum on a 3D array in calling DDPDD routine (nomask)
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab
+      REAL(wp)                               ::   glob_sum_full_3d   ! global sum
+      !!
+      INTEGER    ::   ji, jj, jk   ! dummy loop indices
+      INTEGER    ::   ijpk ! local variables: size of ptab
+      !!-----------------------------------------------------------------------
+      !
+      ijpk = SIZE(ptab,3)
+      !
+      glob_sum_full_3d = 0.e0
+      DO jk = 1, ijpk
+         glob_sum_full_3d = glob_sum_full_3d + SUM( ptab(:,:,jk) * tmask_h(:,:) )
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( glob_sum_full_3d )
+      !
+   END FUNCTION glob_sum_full_3d
+
 
 #else  
@@ -314,4 +358,65 @@
    END FUNCTION glob_sum_3d_a   
 
+   FUNCTION glob_sum_full_2d( ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  glob_sum_full_2d ***
+      !!
+      !! ** Purpose : perform a sum in calling DDPDD routine
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in), DIMENSION(:,:) ::   ptab
+      REAL(wp)                             ::   glob_sum_full_2d   ! global sum (nomask)
+      !!
+      COMPLEX(wp)::   ctmp
+      REAL(wp)   ::   ztmp
+      INTEGER    ::   ji, jj   ! dummy loop indices
+      !!-----------------------------------------------------------------------
+      !
+      ztmp = 0.e0
+      ctmp = CMPLX( 0.e0, 0.e0, wp )
+      DO jj = 1, jpj
+         DO ji =1, jpi
+         ztmp =  ptab(ji,jj) * tmask_h(ji,jj) 
+         CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
+      glob_sum_full_2d = REAL(ctmp,wp)
+      !
+   END FUNCTION glob_sum_full_2d
+
+   FUNCTION glob_sum_full_3d( ptab )
+      !!----------------------------------------------------------------------
+      !!                  ***  FUNCTION  glob_sum_full_3d ***
+      !!
+      !! ** Purpose : perform a sum on a 3D array in calling DDPDD routine
+      !!----------------------------------------------------------------------
+      REAL(wp), INTENT(in), DIMENSION(:,:,:) ::   ptab
+      REAL(wp)                               ::   glob_sum_full_3d   ! global sum (nomask)
+      !!
+      COMPLEX(wp)::   ctmp
+      REAL(wp)   ::   ztmp
+      INTEGER    ::   ji, jj, jk   ! dummy loop indices
+      INTEGER    ::   ijpk ! local variables: size of ptab
+      !!-----------------------------------------------------------------------
+      !
+      ijpk = SIZE(ptab,3)
+      !
+      ztmp = 0.e0
+      ctmp = CMPLX( 0.e0, 0.e0, wp )
+      DO jk = 1, ijpk
+         DO jj = 1, jpj
+            DO ji =1, jpi
+            ztmp =  ptab(ji,jj,jk) * tmask_h(ji,jj)
+            CALL DDPDD( CMPLX( ztmp, 0.e0, wp ), ctmp )
+            END DO
+         END DO
+      END DO
+      IF( lk_mpp )   CALL mpp_sum( ctmp )   ! sum over the global domain
+      glob_sum_full_3d = REAL(ctmp,wp)
+      !
+   END FUNCTION glob_sum_full_3d
+
+
+
 #endif
 
