Index: branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_mpp.F90
===================================================================
--- branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_mpp.F90	(revision 2287)
+++ branches/nemo_v3_3_beta/NEMOGCM/NEMO/OPA_SRC/OBS/obs_mpp.F90	(revision 2335)
@@ -1,9 +1,2 @@
-#if defined key_mpp_mpi
-#if defined key_sp
-#define mpivar mpi_real
-#else
-#define mpivar mpi_double_precision
-#endif
-#endif
 MODULE obs_mpp
    !!======================================================================
@@ -11,35 +4,36 @@
    !! Observation diagnostics: Various MPP support routines
    !!======================================================================
-
+   !! History :  2.0  ! 2006-03  (K. Mogensen)  Original code
+   !!             -   ! 2006-05  (K. Mogensen)  Reformatted
+   !!             -   ! 2008-01  (K. Mogensen)  add mpp_global_max
    !!----------------------------------------------------------------------
-   !! obs_mpp_bcast_integer : Broadcast an integer array from a processor 
-   !!                         to all processors
-   !! obs_mpp_max_integer   : Find maximum on all processors of each
-   !!                         value in an integer on all processors
+#if defined key_mpp_mpi
+# if defined key_sp
+#  define mpivar mpi_real
+# else
+#  define mpivar mpi_double_precision
+# endif
+#endif
+   !!----------------------------------------------------------------------
+   !! obs_mpp_bcast_integer : Broadcast an integer array from a processor to all processors
+   !! obs_mpp_max_integer   : Find maximum on all processors of each value in an integer on all processors
    !! obs_mpp_find_obs_proc : Find processors which should hold the observations
    !! obs_mpp_sum_integers  : Sum an integer array from all processors
    !! obs_mpp_sum_integer   : Sum an integer from all processors
    !!----------------------------------------------------------------------
-   !! * Modules used   
-   USE dom_oce, ONLY : &    ! Ocean space and time domain variables
-      & nproc, &
-      & mig,mjg
-   USE mpp_map, ONLY : &
-      & mppmap
+   USE dom_oce, ONLY :   nproc, mig, mjg   ! Ocean space and time domain variables
+   USE mpp_map, ONLY :   mppmap
    USE in_out_manager
 #if defined key_mpp_mpi
-   USE lib_mpp, ONLY : &    ! MPP library
-      & mpi_comm_opa
+   USE lib_mpp, ONLY :   mpi_comm_opa      ! MPP library
 #endif
    IMPLICIT NONE
-
-   !! * Routine accessibility
    PRIVATE
 
-   PUBLIC obs_mpp_bcast_integer, & ! Broadcast an integer array from a proc to all procs
-      &   obs_mpp_max_integer,   & ! Find maximum across processors in an integer array
-      &   obs_mpp_find_obs_proc, & ! Find processors which should hold the observations
-      &   obs_mpp_sum_integers,  & ! Sum an integer array from all processors
-      &   obs_mpp_sum_integer,   & ! Sum an integer from all processors
+   PUBLIC obs_mpp_bcast_integer, & !: Broadcast an integer array from a proc to all procs
+      &   obs_mpp_max_integer,   & !: Find maximum across processors in an integer array
+      &   obs_mpp_find_obs_proc, & !: Find processors which should hold the observations
+      &   obs_mpp_sum_integers,  & !: Sum an integer array from all processors
+      &   obs_mpp_sum_integer,   & !: Sum an integer from all processors
       &   mpp_alltoall_int,      &
       &   mpp_alltoallv_int,     &
@@ -50,10 +44,9 @@
    !! NEMO/OPA 3.3 , NEMO Consortium (2010)
    !! $Id$
-   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt)
+   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt)
    !!----------------------------------------------------------------------
-
 CONTAINS
 
-   SUBROUTINE obs_mpp_bcast_integer(kvals,kno,kroot)
+   SUBROUTINE obs_mpp_bcast_integer( kvals, kno, kroot )
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE obs_mpp_bcast_integer ***
@@ -64,36 +57,27 @@
       !!
       !! ** Action  : This does only work for MPI. 
-      !!              It does not work for SHMEM.
       !!              MPI_COMM_OPA needs to be replace for OASIS4.!
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-03  (K. Mogensen)  Original code
-      !!        !  06-05  (K. Mogensen)  Reformatted
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kno       ! Number of elements in array
-      INTEGER, INTENT(IN) :: kroot      ! Processor to send data
-      INTEGER, DIMENSION(kno), INTENT(INOUT) :: &
-         & kvals         ! Array to send on kroot, receive for non-kroot
+      !!----------------------------------------------------------------------
+      INTEGER                , INTENT(in   ) ::   kno     ! Number of elements in array
+      INTEGER                , INTENT(in   ) ::   kroot   ! Processor to send data
+      INTEGER, DIMENSION(kno), INTENT(inout) ::   kvals   ! Array to send on kroot, receive for non-kroot
+      !!
+#if defined key_mpp_mpi
+      INTEGER :: ierr
+INCLUDE 'mpif.h'
+      !!----------------------------------------------------------------------
+
+      ! Call the MPI library to broadcast data
+      CALL mpi_bcast( kvals, kno, mpi_integer,  &
+         &            kroot, mpi_comm_opa, ierr )
+#else
+      ! no MPI: empty routine
+#endif
+      !
+   END SUBROUTINE obs_mpp_bcast_integer
+
   
-#if defined key_mpp_mpi
-      !! * Local declarations
-      INTEGER :: ierr
-INCLUDE 'mpif.h'
-
-      !-----------------------------------------------------------------------
-      ! Call the MPI library to broadcast data
-      !-----------------------------------------------------------------------
-      CALL mpi_bcast( kvals, kno, mpi_integer, &
-         &            kroot, mpi_comm_opa, ierr )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
-#endif
-
-   END SUBROUTINE obs_mpp_bcast_integer
-    
    SUBROUTINE obs_mpp_max_integer( kvals, kno )
       !!----------------------------------------------------------------------
@@ -109,34 +93,25 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-03  (K. Mogensen)  Original code
-      !!        !  06-05  (K. Mogensen)  Reformatted
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) ::kno       ! Number of elements in array
-      INTEGER, DIMENSION(kno), INTENT(INOUT) :: &
-         & kvals     ! Array to send on kroot, receive for non-kroot  
-
-#if defined key_mpp_mpi
-      !! * Local declarations
-      INTEGER :: ierr
-      INTEGER, DIMENSION(kno) :: &
-         & ivals
-INCLUDE 'mpif.h'
-
-      !-----------------------------------------------------------------------
+      !!----------------------------------------------------------------------
+      INTEGER                , INTENT(in   ) ::   kno     ! Number of elements in array
+      INTEGER, DIMENSION(kno), INTENT(inout) ::   kvals   ! Array to send on kroot, receive for non-kroot  
+      !!
+#if defined key_mpp_mpi
+      INTEGER :: ierr
+      INTEGER, DIMENSION(kno) ::   ivals
+INCLUDE 'mpif.h'
+      !!----------------------------------------------------------------------
+
       ! Call the MPI library to find the maximum across processors
-      !-----------------------------------------------------------------------
-      CALL mpi_allreduce( kvals, ivals, kno, mpi_integer, &
+      CALL mpi_allreduce( kvals, ivals, kno, mpi_integer,   &
          &                mpi_max, mpi_comm_opa, ierr )
       kvals(:) = ivals(:)
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
+#else
+      ! no MPI: empty routine
 #endif
    END SUBROUTINE obs_mpp_max_integer
 
-   SUBROUTINE obs_mpp_find_obs_proc(kobsp,kobsi,kobsj,kno)
+
+   SUBROUTINE obs_mpp_find_obs_proc( kobsp, kobsi, kobsj, kno )
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE obs_mpp_find_obs_proc ***
@@ -155,19 +130,10 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-07  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kno
-      INTEGER, DIMENSION(kno), INTENT(IN) :: &
-         & kobsi, &
-         & kobsj
-      INTEGER, DIMENSION(kno), INTENT(INOUT) :: &
-         & kobsp
-
-#if defined key_mpp_mpi
-      !! * Local declarations
+      !!----------------------------------------------------------------------
+      INTEGER                , INTENT(in   ) ::   kno
+      INTEGER, DIMENSION(kno), INTENT(in   ) ::   kobsi, kobsj
+      INTEGER, DIMENSION(kno), INTENT(inout) ::   kobsp
+      !!
+#if defined key_mpp_mpi
       INTEGER :: ji
       INTEGER :: jj
@@ -177,11 +143,9 @@
       INTEGER :: iobsjp
       INTEGER :: num_sus_obs
-      INTEGER, DIMENSION(kno) :: &
-         & iobsig, &
-         & iobsjg
-      INTEGER, ALLOCATABLE, DIMENSION(:,:) :: &
-         & iobsp, iobsi, iobsj
-
-INCLUDE 'mpif.h'
+      INTEGER, DIMENSION(kno) ::   iobsig, iobsjg
+      INTEGER, ALLOCATABLE, DIMENSION(:,:) ::   iobsp, iobsi, iobsj
+      !!
+INCLUDE 'mpif.h'
+      !!----------------------------------------------------------------------
 
       !-----------------------------------------------------------------------
@@ -258,10 +222,11 @@
       DEALLOCATE( iobsi )
       DEALLOCATE( iobsp )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
-#endif
-
+#else
+      ! no MPI: empty routine
+#endif
+      !
    END SUBROUTINE obs_mpp_find_obs_proc
 
+
    SUBROUTINE obs_mpp_sum_integers( kvalsin, kvalsout, kno )
       !!----------------------------------------------------------------------
@@ -276,21 +241,15 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-07  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kno
-      INTEGER, DIMENSION(kno), INTENT(IN) :: &
-         & kvalsin
-      INTEGER, DIMENSION(kno), INTENT(OUT) :: &
-         & kvalsout
-
-#if defined key_mpp_mpi
-      !! * Local declarations
-      INTEGER :: ierr
-INCLUDE 'mpif.h'
- 
+      !!----------------------------------------------------------------------
+      INTEGER                , INTENT(in   ) :: kno
+      INTEGER, DIMENSION(kno), INTENT(in   ) ::   kvalsin
+      INTEGER, DIMENSION(kno), INTENT(  out) ::   kvalsout
+      !!
+#if defined key_mpp_mpi
+      INTEGER :: ierr
+      !!
+INCLUDE 'mpif.h'
+      !!----------------------------------------------------------------------
+      !
       !-----------------------------------------------------------------------
       ! Call the MPI library to find the sum across processors
@@ -298,8 +257,5 @@
       CALL mpi_allreduce( kvalsin, kvalsout, kno, mpi_integer, &
          &                mpi_sum, mpi_comm_opa, ierr )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
-#else
-
+#else
       !-----------------------------------------------------------------------
       ! For no-MPP just return input values
@@ -307,7 +263,8 @@
       kvalsout(:) = kvalsin(:)
 #endif
-
+      !
    END SUBROUTINE obs_mpp_sum_integers
 
+
    SUBROUTINE obs_mpp_sum_integer( kvalin, kvalout )
       !!----------------------------------------------------------------------
@@ -322,27 +279,20 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-07  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kvalin
-      INTEGER, INTENT(OUT) :: kvalout
-
-#if defined key_mpp_mpi
-      !! * Local declarations
-      INTEGER :: ierr
-INCLUDE 'mpif.h'
-
+      !!----------------------------------------------------------------------
+      INTEGER, INTENT(in   ) ::   kvalin
+      INTEGER, INTENT(  out) ::   kvalout
+      !!
+#if defined key_mpp_mpi
+      INTEGER :: ierr
+      !!
+INCLUDE 'mpif.h'
+      !!----------------------------------------------------------------------
+      !
       !-----------------------------------------------------------------------
       ! Call the MPI library to find the sum across processors
       !-----------------------------------------------------------------------
-      CALL mpi_allreduce( kvalin, kvalout, 1, mpi_integer, &
+      CALL mpi_allreduce( kvalin, kvalout, 1, mpi_integer,   &
          &                mpi_sum, mpi_comm_opa, ierr )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
-#else
-
+#else
       !-----------------------------------------------------------------------
       ! For no-MPP just return input values
@@ -350,5 +300,7 @@
       kvalout = kvalin
 #endif
+      !
    END SUBROUTINE obs_mpp_sum_integer
+
 
    SUBROUTINE mpp_global_max( pval )
@@ -365,18 +317,12 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  08-01  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      REAL(KIND=wp), DIMENSION(jpiglo,jpjglo), INTENT(INOUT) :: &
-         & pval
-      !! * Local declarations
-      INTEGER :: ierr
-#if defined key_mpp_mpi
-INCLUDE 'mpif.h'
-      REAL(KIND=wp), DIMENSION(:,:), ALLOCATABLE :: &
-         & zcp
+      !!----------------------------------------------------------------------
+      REAL(KIND=wp), DIMENSION(jpiglo,jpjglo), INTENT(inout) ::   pval
+      !!
+      INTEGER :: ierr
+#if defined key_mpp_mpi
+INCLUDE 'mpif.h'
+      REAL(KIND=wp), DIMENSION(:,:), ALLOCATABLE ::   zcp
+      !!----------------------------------------------------------------------
 
       ! Copy data for input to MPI
@@ -396,10 +342,11 @@
          & )
 
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
-#endif
-      
+#else
+      ! no MPI: empty routine
+#endif
+      !
    END SUBROUTINE mpp_global_max
 
+
    SUBROUTINE mpp_alltoall_int( kno, kvalsin, kvalsout )
       !!----------------------------------------------------------------------
@@ -414,16 +361,9 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-09  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: kno
-      INTEGER, DIMENSION(kno*jpnij), INTENT(IN) :: &
-         & kvalsin
-      INTEGER, DIMENSION(kno*jpnij), INTENT(OUT) :: &
-         & kvalsout
-      !! * Local declarations
+      !!----------------------------------------------------------------------
+      INTEGER                      , INTENT(in   ) ::   kno
+      INTEGER, DIMENSION(kno*jpnij), INTENT(in   ) ::   kvalsin
+      INTEGER, DIMENSION(kno*jpnij), INTENT(  out) ::   kvalsout
+      !!
       INTEGER :: ierr
 #if defined key_mpp_mpi
@@ -435,6 +375,4 @@
          &               kvalsout, kno, mpi_integer, &
          &               mpi_comm_opa, ierr )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
 #else
       !-----------------------------------------------------------------------
@@ -443,9 +381,10 @@
       kvalsout = kvalsin
 #endif
-      
+      !
    END SUBROUTINE mpp_alltoall_int
 
-   SUBROUTINE mpp_alltoallv_int( kvalsin, knoin, kinv, kvalsout, &
-      &                              knoout, koutv )
+
+   SUBROUTINE mpp_alltoallv_int( kvalsin, knoin , kinv , kvalsout,   &
+      &                                   knoout, koutv )
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE mpp_alltoallv_int ***
@@ -459,27 +398,16 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-09  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: knoin
-      INTEGER, INTENT(IN) :: knoout
-      INTEGER, DIMENSION(jpnij) :: &
-         & kinv, &
-         & koutv
-      INTEGER, DIMENSION(knoin), INTENT(IN) :: &
-         & kvalsin
-      INTEGER, DIMENSION(knoout), INTENT(OUT) :: &
-         & kvalsout
-      !! * Local declarations
+      !!----------------------------------------------------------------------
+      INTEGER                   , INTENT(in) :: knoin
+      INTEGER                   , INTENT(in) :: knoout
+      INTEGER, DIMENSION(jpnij)                 ::   kinv, koutv
+      INTEGER, DIMENSION(knoin) , INTENT(in   ) ::   kvalsin
+      INTEGER, DIMENSION(knoout), INTENT(  out) ::   kvalsout
+      !!
       INTEGER :: ierr
       INTEGER :: jproc
 #if defined key_mpp_mpi
 INCLUDE 'mpif.h'
-      INTEGER, DIMENSION(jpnij) :: &
-         & irdsp, &
-         & isdsp
+      INTEGER, DIMENSION(jpnij) ::   irdsp, isdsp
       !-----------------------------------------------------------------------
       ! Compute displacements
@@ -497,6 +425,4 @@
          &                kvalsout, koutv, irdsp, mpi_integer, &
          &                mpi_comm_opa, ierr )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
 #else
       !-----------------------------------------------------------------------
@@ -505,9 +431,10 @@
       kvalsout = kvalsin
 #endif
-      
+      !
    END SUBROUTINE mpp_alltoallv_int
 
-   SUBROUTINE mpp_alltoallv_real( pvalsin, knoin, kinv, pvalsout, &
-      &                               knoout, koutv )
+
+   SUBROUTINE mpp_alltoallv_real( pvalsin, knoin , kinv , pvalsout,   &
+      &                                    knoout, koutv )
       !!----------------------------------------------------------------------
       !!               ***  ROUTINE mpp_alltoallv_real ***
@@ -521,27 +448,18 @@
       !!
       !! References : http://www.mpi-forum.org
-      !!
-      !! History :
-      !!        !  06-09  (K. Mogensen)  Original code
-      !!----------------------------------------------------------------------
-
-      !! * Arguments
-      INTEGER, INTENT(IN) :: knoin
-      INTEGER, INTENT(IN) :: knoout
-      INTEGER, DIMENSION(jpnij) :: &
-         & kinv, &
-         & koutv
-      REAL(KIND=wp), DIMENSION(knoin), INTENT(IN) :: &
-         & pvalsin
-      REAL(KIND=wp), DIMENSION(knoout), INTENT(OUT) :: &
-         & pvalsout
-      !! * Local declarations
+      !!----------------------------------------------------------------------
+      INTEGER                    , INTENT(in   ) :: knoin
+      INTEGER                    , INTENT(in   ) :: knoout
+      INTEGER , DIMENSION(jpnij)                 ::   kinv, koutv
+      REAL(wp), DIMENSION(knoin) , INTENT(in   ) ::   pvalsin
+      REAL(wp), DIMENSION(knoout), INTENT(  out) ::   pvalsout
+      !!
       INTEGER :: ierr
       INTEGER :: jproc
 #if defined key_mpp_mpi
 INCLUDE 'mpif.h'
-      INTEGER, DIMENSION(jpnij) :: &
-         & irdsp, &
-         & isdsp
+      INTEGER, DIMENSION(jpnij) ::   irdsp, isdsp
+      !!----------------------------------------------------------------------
+      !
       !-----------------------------------------------------------------------
       ! Compute displacements
@@ -559,6 +477,4 @@
          &                pvalsout, koutv, irdsp, mpivar, &
          &                mpi_comm_opa, ierr )
-#elif defined key_mpp_shmem
-error "Only MPI support for MPP in NEMOVAR"
 #else
       !-----------------------------------------------------------------------
@@ -567,6 +483,7 @@
       pvalsout = pvalsin
 #endif
-      
+      !
    END SUBROUTINE mpp_alltoallv_real
 
+   !!======================================================================
 END MODULE obs_mpp
