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 7901)
+++ branches/2017/dev_r7832_HPC08_lbclnk_3rd_dim/NEMOGCM/NEMO/OPA_SRC/stpctl.F90	(revision 7902)
@@ -44,9 +44,9 @@
       !!              - Print it each 50 time steps
       !!              - Stop the run IF problem encountered by setting indic=-3
-      !!                Problems checked: |U| and |ssh| maximum larger than 10 m/s 
-      !!                                  sea surface salinity (SSS) minimum < 0
+      !!                Problems checked: |U| maximum larger than 10 m/s 
+      !!                                  negative sea surface salinity
       !!
-      !! ** Actions :   'time.step' file containing the last ocean time-step
-      !!                
+      !! ** Actions :   "time.step" file = last ocean time-step
+      !!                "run.stat"  file = run statistics
       !!----------------------------------------------------------------------
       INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index
@@ -54,9 +54,11 @@
       !!
       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    ! 
-      REAL(wp), DIMENSION(3) ::   zmax     !  
+      INTEGER  ::   iih, ijh               ! local integers
+      INTEGER  ::   iiu, iju, iku          !   -       -
+      INTEGER  ::   iis, ijs               !   -       -
+      REAL(wp) ::   zzz                    ! local real 
+      INTEGER , DIMENSION(3) ::   ilocu
+      INTEGER , DIMENSION(2) ::   ilocs, iloch
+      REAL(wp), DIMENSION(3) ::   zmax
       !!----------------------------------------------------------------------
       !
@@ -76,10 +78,10 @@
       ENDIF
       !
-      !                                            !==  test of extrema  ==!
-      zmax(1) = MAXVAL(  ABS( un(:,:,:) )  )                                  ! velocity max (zonal only)
-      zmax(2) = MAXVAL( -tsn(:,:,1,jp_sal) , mask = tmask(:,:,1) == 1._wp )   ! minus surface salinity max
-      zmax(3) = MAXVAL( sshn(:,:)*sshn(:,:), mask = tmask(:,:,1) == 1._wp )   ! ssh^2 max
+      !                                   !==  test of extrema  ==!
+      zmax(1) = MAXVAL(  ABS( sshn(:,:) )  )                                  ! ssh max
+      zmax(2) = MAXVAL(  ABS( un(:,:,:) )  )                                  ! velocity max (zonal only)
+      zmax(3) = MAXVAL( -tsn(:,:,1,jp_sal) , mask = tmask(:,:,1) == 1._wp )   ! minus surface salinity max
       !
-      IF( lk_mpp )   CALL mpp_max_multiple( zmax(:), 3 )          ! max over the global domain
+      IF( lk_mpp )   CALL mpp_max_multiple( zmax(:), 3 ) ! max over the global domain
       !
       IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
@@ -87,18 +89,26 @@
       ENDIF
       !
-      IF( zmax(1) > 10._wp ) THEN                     !* too large velocity ( > 10 m/s)
+      IF ( zmax(2) > 10._wp .OR.   &                     ! too large sea surface height ( > 10 m)
+         & zmax(2) > 10._wp .OR.   &                     ! too large velocity ( > 10 m/s)
+         & zmax(3) >  0._wp ) THEN                       ! negative sea surface salinity
          IF( lk_mpp ) THEN
-            CALL mpp_maxloc( ABS(un), umask, zmax(1), ii, ij, ik )
+            CALL mpp_maxloc( ABS(sshn)        , tmask(:,:,1), zzz, iih, ijh )
+            CALL mpp_maxloc( ABS(un)          , umask       , zzz, iiu, iju, iku )
+            CALL mpp_minloc( tsn(:,:,1,jp_sal), tmask(:,:,1), zzz, iis, ijs )
          ELSE
+            iloch = MINLOC( ABS( sshn(:,:) ) )
             ilocu = MAXLOC( ABS( un(:,:,:) ) )
-            ii = ilocu(1) + nimpp - 1
-            ij = ilocu(2) + njmpp - 1
-            ik = ilocu(3)
+            ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1._wp )
+            iih = iloch(1) + nimpp - 1   ;   ijh = iloch(2) + njmpp - 1
+            iiu = ilocu(1) + nimpp - 1   ;   iju = ilocu(2) + njmpp - 1   ;   iku = ilocu(3)
+            iis = ilocs(1) + nimpp - 1   ;   ijs = ilocs(2) + njmpp - 1
          ENDIF
          IF(lwp) THEN
             WRITE(numout,cform_err)
-            WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s'
+            WRITE(numout,*) ' stpctl: |ssh| > 10 m   or   |U| > 10 m/s   or   SSS < 0'
             WRITE(numout,*) ' ====== '
-            WRITE(numout,9400) kt, zmax(1), ii, ij, ik
+            WRITE(numout,9100) kt,   zmax(1), iih, ijh
+            WRITE(numout,9200) kt,   zmax(2), iiu, iju, iku
+            WRITE(numout,9300) kt, - zmax(3), iis, ijs
             WRITE(numout,*)
             WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
@@ -106,31 +116,12 @@
          kindic = -3
       ENDIF
-9400  FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5)
-      !
-      IF( -zmax(2) < 0._wp ) THEN                     !* negative salinity
-         IF( lk_mpp ) THEN
-            CALL mpp_minloc( tsn(:,:,1,jp_sal),tmask(:,:,1), zzt, ii, ij )
-         ELSE
-            ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1._wp )
-            ii = ilocs(1) + nimpp - 1
-            ij = ilocs(2) + njmpp - 1
-         ENDIF
-         !
-         IF(lwp) THEN
-            WRITE(numout,cform_err)
-            WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity'
-            WRITE(numout,*) '======= '
-            WRITE(numout,9500) kt, -zmax(2), ii, ij
-            WRITE(numout,*)
-            WRITE(numout,*) '          output of last fields in numwso'
-         ENDIF
-         kindic = -3
-      ENDIF
-9500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5)
+9100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5)
+9200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5)
+9300  FORMAT (' kt=',i8,'   SSS   min: ',1pg11.4,', at  i j  : ',2i5)
       !
       !                                            !==  run statistics  ==!   ("run.stat" file)
-      IF(lwp) WRITE(numrun,9200) kt, zmax(3), zmax(1), - zmax(2)      !  formerly called "solver.stat" file
+      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3)
       !
-9200  FORMAT(' it :', i8, ' ssh2: ', e16.10, ' Umax: ',e16.10,' Smin: ',e16.10)
+9400  FORMAT(' it :', i8, '    |ssh|max: ', e16.10, ' |U|max: ',e16.10,' SSS min: ',e16.10)
       !
    END SUBROUTINE stp_ctl
