Index: /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90
===================================================================
--- /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 7900)
+++ /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/LBC/lib_mpp.F90	(revision 7901)
@@ -147,5 +147,5 @@
    ! variables used for zonal integration
    INTEGER, PUBLIC ::   ncomm_znl       !: communicator made by the processors on the same zonal average
-   LOGICAL, PUBLIC ::   l_znl_root      !  True on the 'left'most processor on the same row
+   LOGICAL, PUBLIC ::   l_znl_root      !: True on the 'left'most processor on the same row
    INTEGER         ::   ngrp_znl        !  group ID for the znl processors
    INTEGER         ::   ndim_rank_znl   !  number of processors on the same zonal average
@@ -163,7 +163,7 @@
 
    ! Type of send : standard, buffered, immediate
-   CHARACTER(len=1), PUBLIC ::   cn_mpi_send         !: type od mpi send/recieve (S=standard, B=bsend, I=isend)
-   LOGICAL         , PUBLIC ::   l_isend = .FALSE.   !: isend use indicator (T if cn_mpi_send='I')
-   INTEGER         , PUBLIC ::   nn_buffer           !: size of the buffer in case of mpi_bsend
+   CHARACTER(len=1), PUBLIC ::   cn_mpi_send        !: type od mpi send/recieve (S=standard, B=bsend, I=isend)
+   LOGICAL         , PUBLIC ::   l_isend = .FALSE.  !: isend use indicator (T if cn_mpi_send='I')
+   INTEGER         , PUBLIC ::   nn_buffer          !: size of the buffer in case of mpi_bsend
 
    REAL(wp), DIMENSION(:), ALLOCATABLE, SAVE ::   tampon   ! buffer in case of bsend
@@ -266,5 +266,5 @@
          END SELECT
          !
-      ELSE IF ( PRESENT(localComm) .AND. .NOT. mpi_was_called ) THEN
+      ELSEIF ( PRESENT(localComm) .AND. .NOT. mpi_was_called ) THEN
          WRITE(ldtxt(ii),*) ' lib_mpp: You cannot provide a local communicator '          ;   ii = ii + 1
          WRITE(ldtxt(ii),*) '          without calling MPI_Init before ! '                ;   ii = ii + 1
@@ -336,5 +336,5 @@
       !! ** Method  :   Use mppsend and mpprecv function for passing mask
       !!              between processors following neighboring subdomains.
-      !!            domain parameters
+      !!                domain parameters
       !!                    nlci   : first dimension of the local subdomain
       !!                    nlcj   : second dimension of the local subdomain
@@ -446,5 +446,5 @@
          CALL mppsend( 1, zt3ew(1,1,1,1), imigr, nowe, ml_req1 )
          CALL mpprecv( 2, zt3we(1,1,1,2), imigr, nowe )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
       END SELECT
       !
@@ -487,5 +487,5 @@
          CALL mppsend( 4, zt3sn(1,1,1,1), imigr, nono, ml_req1 )
          CALL mpprecv( 3, zt3ns(1,1,1,2), imigr, nono )
-         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err )
       CASE ( 0 )
          CALL mppsend( 3, zt3ns(1,1,1,1), imigr, noso, ml_req1 )
@@ -493,6 +493,6 @@
          CALL mpprecv( 3, zt3ns(1,1,1,2), imigr, nono )
          CALL mpprecv( 4, zt3sn(1,1,1,2), imigr, noso )
-         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         IF(l_isend)   CALL mpi_wait(ml_req2, ml_stat, ml_err)
+         IF(l_isend)   CALL mpi_wait(ml_req1, ml_stat, ml_err )
+         IF(l_isend)   CALL mpi_wait(ml_req2, ml_stat, ml_err )
       CASE ( 1 )
          CALL mppsend( 3, zt3ns(1,1,1,1), imigr, noso, ml_req1 )
@@ -759,5 +759,5 @@
       !!---------------------------------------------------------------------
       REAL(wp)        , DIMENSION(:,:), TARGET, INTENT(inout) ::   pt2d         ! 2D array on which the boundary condition is applied
-      CHARACTER(len=1)                        , INTENT(in   ) ::   cd_type      ! nature of ptab array grid-points
+      CHARACTER(len=1)                        , INTENT(in   ) ::   cd_type      ! nature of pt2d array grid-points
       REAL(wp)                                , INTENT(in   ) ::   psgn         ! sign used across the north fold boundary
       TYPE(arrayptr)  , DIMENSION(:)          , INTENT(inout) ::   pt2d_array   ! 
@@ -793,5 +793,5 @@
       INTEGER :: kfld
       TYPE(arrayptr)   , DIMENSION(9) ::   pt2d_array 
-      CHARACTER(len=1) , DIMENSION(9) ::   type_array    ! define the nature of ptab array grid-points
+      CHARACTER(len=1) , DIMENSION(9) ::   type_array    ! define the nature of pt2d array grid-points
       REAL(wp)         , DIMENSION(9) ::   psgn_array    ! sign used across the north fold boundary
       !!---------------------------------------------------------------------
@@ -837,5 +837,5 @@
       !!----------------------------------------------------------------------
       REAL(wp), DIMENSION(jpi,jpj), INTENT(inout) ::   pt2d     ! 2D array on which the boundary condition is applied
-      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type  ! nature of ptab array grid-points
+      CHARACTER(len=1)            , INTENT(in   ) ::   cd_type  ! nature of pt2d array grid-points
       REAL(wp)                    , INTENT(in   ) ::   psgn     ! sign used across the north fold boundary
       CHARACTER(len=3), OPTIONAL  , INTENT(in   ) ::   cd_mpp   ! fill the overlap area only
@@ -1989,7 +1989,7 @@
       !!
       !!----------------------------------------------------------------------
-      INTEGER , INTENT(in   )                  ::   kdim
-      REAL(wp), INTENT(inout), DIMENSION(kdim) ::   ptab
-      INTEGER , INTENT(in   ), OPTIONAL        ::   kcom
+      REAL(wp), DIMENSION(kdim), INTENT(inout) ::   ptab
+      INTEGER                  , INTENT(in   ) ::   kdim
+      INTEGER , OPTIONAL       , INTENT(in   ) ::   kcom
       !
       INTEGER :: ierror, localcomm
@@ -2041,4 +2041,5 @@
       !!
       INTEGER  ::   ierror, localcomm
+      REAL(wp), DIMENSION(kdim) ::  zwork
       !!----------------------------------------------------------------------
       !
@@ -2046,6 +2047,6 @@
       IF( PRESENT(kcom) )   localcomm = kcom
       !
-      CALL mpi_allreduce( ptab, zwork, kdim, mpi_double_precision, mpi_max, localcomm, ierror )
-      ptab(:) = zwork(:)
+      CALL mpi_allreduce( pt1d, zwork, kdim, mpi_double_precision, mpi_max, localcomm, ierror )
+      pt1d(:) = zwork(:)
       !
    END SUBROUTINE mppmax_real_multiple
@@ -2212,5 +2213,5 @@
       REAL(wp), DIMENSION (jpi,jpj), INTENT(in   ) ::   pmask   ! Local mask
       REAL(wp)                     , INTENT(  out) ::   pmin    ! Global minimum of ptab
-      INTEGER                      , INTENT(  out) ::   ki, kj   ! index of minimum in global frame
+      INTEGER                      , INTENT(  out) ::   ki, kj  ! index of minimum in global frame
       !
       INTEGER :: ierror
@@ -2716,5 +2717,5 @@
 
          DO jr = 1,nsndto
-            IF ((nfipproc(isendto(jr),jpnj) /= (narea-1)) .and. (nfipproc(isendto(jr),jpnj) /= -1)) THEN
+            IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
               CALL mppsend( 5, znorthloc, itaille, nfipproc(isendto(jr),jpnj), ml_req_nf(jr) )
             ENDIF
@@ -2727,5 +2728,5 @@
                iilb = nfiimpp(isendto(jr),jpnj) - nfiimpp(isendto(1),jpnj)
             ENDIF
-            IF((iproc /= (narea-1)) .and. (iproc /= -1)) THEN
+            IF( iproc /= narea-1 .AND. iproc /= -1 ) THEN
               CALL mpprecv(5, zfoldwk, itaille, iproc)
               DO jk = 1, ipk
@@ -2748,6 +2749,6 @@
          IF (l_isend) THEN
             DO jr = 1,nsndto
-               IF ((nfipproc(isendto(jr),jpnj) /= (narea-1)) .and. (nfipproc(isendto(jr),jpnj) /= -1)) THEN
-                  CALL mpi_wait(ml_req_nf(jr), ml_stat, ml_err)
+               IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
+                  CALL mpi_wait( ml_req_nf(jr), ml_stat, ml_err )
                ENDIF    
             END DO
@@ -2870,11 +2871,11 @@
 
          DO jr = 1,nsndto
-            IF ((nfipproc(isendto(jr),jpnj) /= (narea-1)) .and. (nfipproc(isendto(jr),jpnj) /= -1)) THEN
-               CALL mppsend(5, znorthloc, itaille, nfipproc(isendto(jr),jpnj), ml_req_nf(jr))
+            IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
+               CALL mppsend( 5, znorthloc, itaille, nfipproc(isendto(jr),jpnj), ml_req_nf(jr) )
             ENDIF
          END DO
          DO jr = 1,nsndto
             iproc = nfipproc(isendto(jr),jpnj)
-            IF(iproc /= -1) THEN
+            IF( iproc /= -1 ) THEN
                ilei = nleit (iproc+1)
                ildi = nldit (iproc+1)
@@ -2888,5 +2889,5 @@
                  END DO
               END DO
-            ELSE IF( iproc == narea-1 ) THEN
+            ELSEIF( iproc == narea-1 ) THEN
               DO jj = 1, ijpj
                  DO ji = ildi, ilei
@@ -2896,7 +2897,7 @@
             ENDIF
          END DO
-         IF (l_isend) THEN
+         IF(l_isend) THEN
             DO jr = 1,nsndto
-               IF ((nfipproc(isendto(jr),jpnj) /= (narea-1)) .and. (nfipproc(isendto(jr),jpnj) /= -1)) THEN
+               IF( nfipproc(isendto(jr),jpnj) /= narea-1 .AND. nfipproc(isendto(jr),jpnj) /= -1 ) THEN
                   CALL mpi_wait(ml_req_nf(jr), ml_stat, ml_err)
                ENDIF
@@ -3019,5 +3020,5 @@
          DO jr = 1, nsndto
             iproc = nfipproc(isendto(jr),jpnj)
-            IF(iproc /= -1) THEN
+            IF( iproc /= -1 ) THEN
                ilei = nleit (iproc+1)
                ildi = nldit (iproc+1)
@@ -3562,10 +3563,10 @@
       SELECT CASE ( nbondj_bdy(ib_bdy) )
       CASE ( -1 )
-         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-      CASE ( 0 )
-         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
-         IF(l_isend) CALL mpi_wait(ml_req2, ml_stat, ml_err)
-      CASE ( 1 )
-         IF(l_isend) CALL mpi_wait(ml_req1, ml_stat, ml_err)
+         IF(l_isend) CALL mpi_wait( ml_req1, ml_stat, ml_err )
+      CASE ( 0 )
+         IF(l_isend) CALL mpi_wait (ml_req1, ml_stat, ml_err )
+         IF(l_isend) CALL mpi_wait( ml_req2, ml_stat, ml_err )
+      CASE ( 1 )
+         IF(l_isend) CALL mpi_wait( ml_req1, ml_stat, ml_err )
       END SELECT
       !
Index: /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/SBC/sbcwave.F90
===================================================================
--- /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/SBC/sbcwave.F90	(revision 7900)
+++ /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/SBC/sbcwave.F90	(revision 7901)
@@ -132,6 +132,6 @@
                zda_v = EXP( -2.0_wp*zkh_v ) / ( 1.0_wp + 8.0_wp*zkh_v )
                !
-               usd(ji,jj,jk) = zda_u * zk_u(ji,jj) * umask(ji,jj,jk)
-               vsd(ji,jj,jk) = zda_v * zk_v(ji,jj) * vmask(ji,jj,jk)
+               usd(ji,jj,jk) = zda_u * zu0_sd(ji,jj) * umask(ji,jj,jk)
+               vsd(ji,jj,jk) = zda_v * zv0_sd(ji,jj) * vmask(ji,jj,jk)
             END DO
          END DO
Index: /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/stpctl.F90
===================================================================
--- /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 7900)
+++ /branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 7901)
@@ -10,5 +10,5 @@
    !!            2.0  ! 2009-07  (G. Madec)  Add statistic for time-spliting
    !!            3.7  ! 2016-09  (G. Madec)  Remove solver
-   !!            4.0  ! 2017-04  (G. Madec)  regroup 
+   !!            4.0  ! 2017-04  (G. Madec)  regroup global communications
    !!----------------------------------------------------------------------
 
@@ -44,5 +44,6 @@
       !!              - Print it each 50 time steps
       !!              - Stop the run IF problem encountered by setting indic=-3
-      !!                Problems checked: U max>10 m/s and SSS min < 0
+      !!                Problems checked: |U| and |ssh| maximum larger than 10 m/s 
+      !!                                  sea surface salinity (SSS) minimum < 0
       !!
       !! ** Actions :   'time.step' file containing the last ocean time-step
@@ -54,4 +55,5 @@
       INTEGER  ::   ji, jj, jk             ! dummy loop indices
       INTEGER  ::   ii, ij, ik             ! local integers
+      REAL(wp) ::   zzt                    ! local real 
       INTEGER , DIMENSION(3) ::   ilocu    ! 
       INTEGER , DIMENSION(2) ::   ilocs    ! 
@@ -69,6 +71,8 @@
       ENDIF
       !
-      IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt    !==  current time step  ==!   ("time.step" file)
-      IF(lwp) REWIND( numstp )
+      IF(lwp) THEN                        !==  current time step  ==!   ("time.step" file)
+         WRITE ( numstp, '(1x, i8)' )   kt
+         REWIND( numstp )
+      ENDIF
       !
       !                                            !==  test of extrema  ==!
@@ -80,5 +84,5 @@
       !
       IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
-         WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zmax(1), ' SSS min:', - zmax(2)
+         WRITE(numout,*) ' ==>> time-step= ',kt,' |U| max: ', zmax(1), ' SSS min:', - zmax(2)
       ENDIF
       !
@@ -106,5 +110,5 @@
       IF( -zmax(2) < 0._wp ) THEN                     !* negative salinity
          IF( lk_mpp ) THEN
-            CALL mpp_minloc( tsn(:,:,1,jp_sal),tmask(:,:,1), - zmax(2), ii, ij )
+            CALL mpp_minloc( tsn(:,:,1,jp_sal),tmask(:,:,1), zzt, ii, ij )
          ELSE
             ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1._wp )
