New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 9019 for branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/stpctl.F90 – NEMO

Ignore:
Timestamp:
2017-12-13T15:58:53+01:00 (6 years ago)
Author:
timgraham
Message:

Merge of dev_CNRS_2017 into branch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_merge_2017/NEMOGCM/NEMO/OPA_SRC/stpctl.F90

    r7852 r9019  
    99   !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module 
    1010   !!            2.0  ! 2009-07  (G. Madec)  Add statistic for time-spliting 
     11   !!            3.7  ! 2016-09  (G. Madec)  Remove solver 
     12   !!            4.0  ! 2017-04  (G. Madec)  regroup global communications 
    1113   !!---------------------------------------------------------------------- 
    1214 
     
    2123   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2224   USE lib_mpp         ! distributed memory computing 
    23    USE lib_fortran     ! Fortran routines library  
    2425 
    2526   IMPLICIT NONE 
     
    2829   PUBLIC stp_ctl           ! routine called by step.F90 
    2930   !!---------------------------------------------------------------------- 
    30    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     31   !! NEMO/OPA 4.0 , NEMO Consortium (2017) 
    3132   !! $Id$ 
    3233   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
     
    4243      !! ** Method  : - Save the time step in numstp 
    4344      !!              - Print it each 50 time steps 
    44       !!              - Stop the run IF problem ( indic < 0 ) 
     45      !!              - Stop the run IF problem encountered by setting indic=-3 
     46      !!                Problems checked: |ssh| maximum larger than 10 m 
     47      !!                                  |U|   maximum larger than 10 m/s  
     48      !!                                  negative sea surface salinity 
    4549      !! 
    46       !! ** Actions :   'time.step' file containing the last ocean time-step 
    47       !!                 
     50      !! ** Actions :   "time.step" file = last ocean time-step 
     51      !!                "run.stat"  file = run statistics 
    4852      !!---------------------------------------------------------------------- 
    4953      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index 
     
    5155      !! 
    5256      INTEGER  ::   ji, jj, jk             ! dummy loop indices 
    53       INTEGER  ::   ii, ij, ik             ! local integers 
    54       REAL(wp) ::   zumax, zsmin, zssh2, zsshmax    ! local scalars 
    55       INTEGER, DIMENSION(3) ::   ilocu     !  
    56       INTEGER, DIMENSION(2) ::   ilocs     !  
     57      INTEGER  ::   iih, ijh               ! local integers 
     58      INTEGER  ::   iiu, iju, iku          !   -       - 
     59      INTEGER  ::   iis, ijs, iks          !   -       - 
     60      REAL(wp) ::   zzz                    ! local real  
     61      INTEGER , DIMENSION(3) ::   ilocu, ilocs 
     62      INTEGER , DIMENSION(2) ::   iloch 
     63      REAL(wp), DIMENSION(3) ::   zmax 
    5764      !!---------------------------------------------------------------------- 
    5865      ! 
     
    6168         WRITE(numout,*) 'stp_ctl : time-stepping control' 
    6269         WRITE(numout,*) '~~~~~~~' 
    63          ! open time.step file 
     70         !                                ! open time.step file 
    6471         CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
     72         !                                ! open run.stat file 
     73         CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
    6574      ENDIF 
    6675      ! 
    67       IF(lwp) WRITE ( numstp, '(1x, i8)' )   kt      !* save the current time step in numstp 
    68       IF(lwp) REWIND( numstp )                       !  -------------------------- 
     76      IF(lwp) THEN                        !==  current time step  ==!   ("time.step" file) 
     77         WRITE ( numstp, '(1x, i8)' )   kt 
     78         REWIND( numstp ) 
     79      ENDIF 
    6980      ! 
    70       !                                              !* Test maximum of velocity (zonal only) 
    71       !                                              !  ------------------------ 
    72       !! zumax = MAXVAL( ABS( un(:,:,:) ) )                ! slower than the following loop on NEC SX5 
    73       zumax = 0.e0 
    74       DO jk = 1, jpk 
    75          DO jj = 1, jpj 
    76             DO ji = 1, jpi 
    77                zumax = MAX(zumax,ABS(un(ji,jj,jk))) 
    78           END DO  
    79         END DO  
    80       END DO         
    81       IF( lk_mpp )   CALL mpp_max( zumax )                 ! max over the global domain 
     81      !                                   !==  test of extrema  ==! 
     82      zmax(1) = MAXVAL(  ABS( sshn(:,:) )  )                                  ! ssh max 
     83      zmax(2) = MAXVAL(  ABS( un(:,:,:) )  )                                  ! velocity max (zonal only) 
     84      zmax(3) = MAXVAL( -tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp )   ! minus salinity max 
    8285      ! 
    83       IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' abs(U) max: ', zumax 
     86      IF( lk_mpp )   CALL mpp_max_multiple( zmax(:), 3 ) ! max over the global domain 
    8487      ! 
    85       IF( zumax > 20.e0 ) THEN 
     88      IF( MOD( kt, nwrite ) == 1 .AND. lwp ) THEN 
     89         WRITE(numout,*) ' ==>> time-step= ', kt, ' |ssh| max: ',   zmax(1), ' |U| max: ', zmax(2),   & 
     90            &                                     ' S min: '    , - zmax(3) 
     91      ENDIF 
     92      ! 
     93      IF (  zmax(1) >  10._wp .OR.   &                     ! too large sea surface height ( > 10 m) 
     94         &  zmax(2) >  10._wp .OR.   &                     ! too large velocity ( > 10 m/s) 
     95         &  zmax(3) >=  0._wp .OR.   &                     ! negative or zero sea surface salinity 
     96         &  ISNAN( zmax(1) + zmax(2) + zmax(3) )  ) THEN   ! NaN encounter in the tests 
    8697         IF( lk_mpp ) THEN 
    87             CALL mpp_maxloc(ABS(un),umask,zumax,ii,ij,ik) 
     98            CALL mpp_maxloc( ABS(sshn)        , ssmask(:,:)  , zzz, iih, ijh ) 
     99            CALL mpp_maxloc( ABS(un)          , umask (:,:,:), zzz, iiu, iju, iku ) 
     100            CALL mpp_minloc( tsn(:,:,:,jp_sal), tmask (:,:,:), zzz, iis, ijs, iks ) 
    88101         ELSE 
    89             ilocu = MAXLOC( ABS( un(:,:,:) ) ) 
    90             ii = ilocu(1) + nimpp - 1 
    91             ij = ilocu(2) + njmpp - 1 
    92             ik = ilocu(3) 
     102            iloch = MINLOC( ABS( sshn(:,:)   )                               ) 
     103            ilocu = MAXLOC( ABS( un  (:,:,:) )                               ) 
     104            ilocs = MINLOC( tsn(:,:,:,jp_sal) , mask = tmask(:,:,:) == 1._wp ) 
     105            iih = iloch(1) + nimpp - 1   ;   ijh = iloch(2) + njmpp - 1 
     106            iiu = ilocu(1) + nimpp - 1   ;   iju = ilocu(2) + njmpp - 1   ;   iku = ilocu(3) 
     107            iis = ilocs(1) + nimpp - 1   ;   ijs = ilocs(2) + njmpp - 1   ;   iks = ilocu(3) 
    93108         ENDIF 
    94109         IF(lwp) THEN 
    95110            WRITE(numout,cform_err) 
    96             WRITE(numout,*) ' stpctl: the zonal velocity is larger than 20 m/s' 
     111            WRITE(numout,*) ' stpctl: |ssh| > 10 m   or   |U| > 10 m/s   or   S < 0   or   NaN encounter in the tests' 
    97112            WRITE(numout,*) ' ====== ' 
    98             WRITE(numout,9400) kt, zumax, ii, ij, ik 
     113            WRITE(numout,9100) kt,   zmax(1), iih, ijh 
     114            WRITE(numout,9200) kt,   zmax(2), iiu, iju, iku 
     115            WRITE(numout,9300) kt, - zmax(3), iis, ijs, iks 
    99116            WRITE(numout,*) 
    100             WRITE(numout,*) '          output of last fields in numwso' 
     117            WRITE(numout,*) '          output of last computed fields in output.abort.nc file' 
    101118         ENDIF 
    102119         kindic = -3 
    103120      ENDIF 
    104 9400  FORMAT (' kt=',i6,' max abs(U): ',1pg11.4,', i j k: ',3i5) 
     1219100  FORMAT (' kt=',i8,'   |ssh| max: ',1pg11.4,', at  i j  : ',2i5) 
     1229200  FORMAT (' kt=',i8,'   |U|   max: ',1pg11.4,', at  i j k: ',3i5) 
     1239300  FORMAT (' kt=',i8,'   S     min: ',1pg11.4,', at  i j  : ',2i5) 
    105124      ! 
    106       !                                              !* Test minimum of salinity 
    107       !                                              !  ------------------------ 
    108       !! zsmin = MINVAL( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 )  slower than the following loop on NEC SX5 
    109       zsmin = 100._wp 
    110       DO jj = 2, jpjm1 
    111          DO ji = 1, jpi 
    112             IF( tmask(ji,jj,1) == 1) zsmin = MIN(zsmin,tsn(ji,jj,1,jp_sal)) 
    113          END DO 
    114       END DO 
    115       IF( lk_mpp )   CALL mpp_min( zsmin )                ! min over the global domain 
     125      !                                            !==  run statistics  ==!   ("run.stat" file) 
     126      IF(lwp) WRITE(numrun,9400) kt, zmax(1), zmax(2), - zmax(3) 
    116127      ! 
    117       IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' SSS min:', zsmin 
    118       ! 
    119       IF( zsmin < 0.) THEN  
    120          IF (lk_mpp) THEN 
    121             CALL mpp_minloc ( tsn(:,:,1,jp_sal),tmask(:,:,1), zsmin, ii,ij ) 
    122          ELSE 
    123             ilocs = MINLOC( tsn(:,:,1,jp_sal), mask = tmask(:,:,1) == 1.e0 ) 
    124             ii = ilocs(1) + nimpp - 1 
    125             ij = ilocs(2) + njmpp - 1 
    126          ENDIF 
    127          ! 
    128          IF(lwp) THEN 
    129             WRITE(numout,cform_err) 
    130             WRITE(numout,*) 'stp_ctl : NEGATIVE sea surface salinity' 
    131             WRITE(numout,*) '======= ' 
    132             WRITE(numout,9500) kt, zsmin, ii, ij 
    133             WRITE(numout,*) 
    134             WRITE(numout,*) '          output of last fields in numwso' 
    135          ENDIF 
    136          kindic = -3 
    137       ENDIF 
    138 9500  FORMAT (' kt=',i6,' min SSS: ',1pg11.4,', i j: ',2i5) 
    139       ! 
    140       ! 
    141       IF( lk_c1d )  RETURN          ! No log file in case of 1D vertical configuration 
    142  
    143       ! log file (ssh statistics) 
    144       ! --------                                   !* ssh statistics (and others...) 
    145       IF( kt == nit000 .AND. lwp ) THEN   ! open ssh statistics file (put in solver.stat file) 
    146          CALL ctl_opn( numsol, 'solver.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
    147       ENDIF 
    148       ! 
    149       zsshmax = 0.e0 
    150       DO jj = 1, jpj 
    151          DO ji = 1, jpi 
    152             IF( tmask(ji,jj,1) == 1) zsshmax = MAX( zsshmax, ABS(sshn(ji,jj)) ) 
    153          END DO 
    154       END DO 
    155       IF( lk_mpp )   CALL mpp_max( zsshmax )                ! min over the global domain 
    156       ! 
    157       IF( MOD( kt, nwrite ) == 1 .AND. lwp )   WRITE(numout,*) ' ==>> time-step= ',kt,' ssh max:', zsshmax 
    158       ! 
    159       IF( zsshmax > 10.e0 ) THEN  
    160          IF (lk_mpp) THEN 
    161             CALL mpp_maxloc( ABS(sshn(:,:)),tmask(:,:,1),zsshmax,ii,ij) 
    162          ELSE 
    163             ilocs = MAXLOC( ABS(sshn(:,:)) ) 
    164             ii = ilocs(1) + nimpp - 1 
    165             ij = ilocs(2) + njmpp - 1 
    166          ENDIF 
    167          ! 
    168          IF(lwp) THEN 
    169             WRITE(numout,cform_err) 
    170             WRITE(numout,*) 'stp_ctl : the ssh is larger than 10m' 
    171             WRITE(numout,*) '======= ' 
    172             WRITE(numout,9600) kt, zsshmax, ii, ij 
    173             WRITE(numout,*) 
    174             WRITE(numout,*) '          output of last fields in numwso' 
    175          ENDIF 
    176          kindic = -3 
    177       ENDIF 
    178 9600  FORMAT (' kt=',i6,' max ssh: ',1pg11.4,', i j: ',2i5) 
    179       ! 
    180       zssh2 = glob_sum( sshn(:,:) * sshn(:,:) ) 
    181       ! 
    182       IF(lwp) WRITE(numsol,9700) kt, zssh2, zumax, zsmin      ! ssh statistics 
    183       ! 
    184 9700  FORMAT(' it :', i8, ' ssh2: ', d23.16, ' Umax: ',d23.16,' Smin: ',d23.16) 
     1289400  FORMAT(' it :', i8, '    |ssh|_max: ', e16.10, ' |U|_max: ',e16.10,' S_min: ',e16.10) 
    185129      ! 
    186130   END SUBROUTINE stp_ctl 
Note: See TracChangeset for help on using the changeset viewer.