Index: NEMO/trunk/src/OCE/stpctl.F90
===================================================================
--- NEMO/trunk/src/OCE/stpctl.F90	(revision 9671)
+++ NEMO/trunk/src/OCE/stpctl.F90	(revision 9808)
@@ -32,5 +32,5 @@
    PUBLIC stp_ctl           ! routine called by step.F90
 
-   INTEGER  ::   idrun, idtime, idssh, idu, ids, istatus
+   INTEGER  ::   idrun, idtime, idssh, idu, ids1, ids2, istatus
    !!----------------------------------------------------------------------
    !! NEMO/OCE 4.0 , NEMO Consortium (2018)
@@ -63,9 +63,10 @@
       INTEGER  ::   iih, ijh               ! local integers
       INTEGER  ::   iiu, iju, iku          !   -       -
-      INTEGER  ::   iis, ijs, iks          !   -       -
+      INTEGER  ::   iis1, ijs1, iks1       !   -       -
+      INTEGER  ::   iis2, ijs2, iks2       !   -       -
       REAL(wp) ::   zzz                    ! local real 
-      INTEGER , DIMENSION(3) ::   ilocu, ilocs
+      INTEGER , DIMENSION(3) ::   ilocu, ilocs1, ilocs2
       INTEGER , DIMENSION(2) ::   iloch
-      REAL(wp), DIMENSION(4) ::   zmax
+      REAL(wp), DIMENSION(5) ::   zmax
       CHARACTER(len=20) :: clname
       !!----------------------------------------------------------------------
@@ -86,6 +87,7 @@
             istatus = NF90_DEF_DIM( idrun, 'time', NF90_UNLIMITED, idtime )
             istatus = NF90_DEF_VAR( idrun, 'abs_ssh_max', NF90_DOUBLE, (/ idtime /), idssh )
-            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu )
-            istatus = NF90_DEF_VAR( idrun,       's_min', NF90_DOUBLE, (/ idtime /), ids )
+            istatus = NF90_DEF_VAR( idrun,   'abs_u_max', NF90_DOUBLE, (/ idtime /), idu   )
+            istatus = NF90_DEF_VAR( idrun,       's_min', NF90_DOUBLE, (/ idtime /), ids1  )
+            istatus = NF90_DEF_VAR( idrun,       's_max', NF90_DOUBLE, (/ idtime /), ids2  )
             istatus = NF90_ENDDEF(idrun)
          ENDIF
@@ -106,40 +108,47 @@
       zmax(2) = MAXVAL(  ABS( un(:,:,:) )  )                                  ! velocity max (zonal only)
       zmax(3) = MAXVAL( -tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )   ! minus salinity max
-      zmax(4) = REAL( nstop , wp )                                            ! stop indicator
+      zmax(4) = MAXVAL(  tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )   !       salinity max
+      zmax(5) = REAL( nstop , wp )                                            ! stop indicator
       !
       IF( lk_mpp ) THEN
-         CALL mpp_max_multiple( zmax(:), 4 )    ! max over the global domain
+         CALL mpp_max_multiple( zmax(:), 5 )    ! max over the global domain
          !
-         nstop = INT( zmax(4) )                 ! nstop indicator sheared among all local domains
+         nstop = INT( zmax(5) )                 ! nstop indicator sheared among all local domains
       ENDIF
       !
       IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN
          WRITE(numout,*) ' ==>> time-step= ', kt, ' |ssh| max: ',   zmax(1), ' |U| max: ', zmax(2),   &
-            &                                     ' S min: '    , - zmax(3)
+            &                                     ' S min: '    , - zmax(3), ' S max: ', zmax(4)
       ENDIF
       !
-      IF (  zmax(1) >  15._wp .OR.   &                     ! too large sea surface height ( > 10 m)
-         &  zmax(2) >  10._wp .OR.   &                     ! too large velocity ( > 10 m/s)
-         &  zmax(3) >=  0._wp .OR.   &                     ! negative or zero sea surface salinity
+      IF (  zmax(1) >   15._wp .OR.   &                    ! too large sea surface height ( > 15 m )
+         &  zmax(2) >   10._wp .OR.   &                    ! too large velocity ( > 10 m/s)
+         &  zmax(3) >=   0._wp .OR.   &                    ! negative or zero sea surface salinity
+         &  zmax(4) >= 100._wp .OR.   &                    ! too large sea surface salinity ( > 100 )
+         &  zmax(4) <    0._wp .OR.   &                    ! too large sea surface salinity (keep this line for sea-ice)
          &  ISNAN( zmax(1) + zmax(2) + zmax(3) )  ) THEN   ! NaN encounter in the tests
          IF( lk_mpp ) THEN
-            CALL mpp_maxloc( ABS(sshn)        , ssmask(:,:)  , zzz, iih, ijh )
-            CALL mpp_maxloc( ABS(un)          , umask (:,:,:), zzz, iiu, iju, iku )
-            CALL mpp_minloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis, ijs, iks )
+            CALL mpp_maxloc( ABS(sshn)        , ssmask(:,:)  , zzz, iih , ijh        )
+            CALL mpp_maxloc( ABS(un)          , umask (:,:,:), zzz, iiu , iju , iku  )
+            CALL mpp_minloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis1, ijs1, iks1 )
+            CALL mpp_maxloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis2, ijs2, iks2 )
          ELSE
-            iloch = MINLOC( ABS( sshn(:,:)   )                               )
-            ilocu = MAXLOC( ABS( un  (:,:,:) )                               )
-            ilocs = MINLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 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   ;   iks = ilocu(3)
+            iloch  = MINLOC( ABS( sshn(:,:)   )                               )
+            ilocu  = MAXLOC( ABS( un  (:,:,:) )                               )
+            ilocs1 = MINLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )
+            ilocs2 = MAXLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 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)
+            iis1 = ilocs1(1) + nimpp - 1   ;   ijs1 = ilocs1(2) + njmpp - 1   ;   iks1 = ilocs1(3)
+            iis2 = ilocs2(1) + nimpp - 1   ;   ijs2 = ilocs2(2) + njmpp - 1   ;   iks2 = ilocs2(3)
          ENDIF
          IF(lwp) THEN
             WRITE(numout,cform_err)
-            WRITE(numout,*) ' stp_ctl: |ssh| > 10 m   or   |U| > 10 m/s   or   S <= 0   or   NaN encounter in the tests'
+            WRITE(numout,*) ' stp_ctl: |ssh| > 10 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests'
             WRITE(numout,*) ' ======= '
-            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, iks
+            WRITE(numout,9100) kt,   zmax(1), iih , ijh
+            WRITE(numout,9200) kt,   zmax(2), iiu , iju , iku
+            WRITE(numout,9300) kt, - zmax(3), iis1, ijs1, iks1
+            WRITE(numout,9400) kt,   zmax(4), iis2, ijs2, iks2
             WRITE(numout,*)
             WRITE(numout,*) '          output of last computed fields in output.abort.nc file'
@@ -153,17 +162,19 @@
 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,'   S     min: ',1pg11.4,', at  i j  : ',3i5)
+9300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j k: ',3i5)
+9400  FORMAT (' kt=',i8,'   S     max: ',1pg11.4,', at  i j k: ',3i5)
       !
       !                                            !==  run statistics  ==!   ("run.stat" file)
-      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3)
+      IF(lwp) WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4)
       IF( lwm ) THEN
          istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) )
          istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) )
-         istatus = NF90_PUT_VAR( idrun,   ids, (/-zmax(3)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,  ids1, (/-zmax(3)/), (/kt/), (/1/) )
+         istatus = NF90_PUT_VAR( idrun,  ids2, (/ zmax(4)/), (/kt/), (/1/) )
          IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun)
          IF( kt == nitend         ) istatus = NF90_CLOSE(idrun)
       END IF
       !
-9400  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16)
+9500  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16)
       !
    END SUBROUTINE stp_ctl
