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 14053 for NEMO/trunk/src/SWE/stpctl.F90 – NEMO

Ignore:
Timestamp:
2020-12-03T14:48:38+01:00 (3 years ago)
Author:
techene
Message:

#2385 added to the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/src/SWE/stpctl.F90

    r13458 r14053  
    33   !!                       ***  MODULE  stpctl  *** 
    44   !! Ocean run control :  gross check of the ocean time stepping 
     5   !!              *** Shallow Water Equation (SWE) case *** 
     6   !!               ( No test on temperature and salinity ) 
    57   !!====================================================================== 
    6    !! History :  OPA  ! 1991-03  (G. Madec) Original code 
    7    !!            6.0  ! 1992-06  (M. Imbard) 
    8    !!            8.0  ! 1997-06  (A.M. Treguier) 
    9    !!   NEMO     1.0  ! 2002-06  (G. Madec)  F90: Free form and module 
    10    !!            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 
     8   !! History :  SWE  ! 2020-09  (A. Nasser, S. Techene ) OCE/stpctl adaptated to SWE 
    139   !!---------------------------------------------------------------------- 
    1410 
     
    2117   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
    2218   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
    23    !   
     19   ! 
    2420   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
    2521   USE in_out_manager  ! I/O manager 
    2622   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2723   USE lib_mpp         ! distributed memory computing 
    28    ! 
    2924   USE netcdf          ! NetCDF library 
     25 
    3026   IMPLICIT NONE 
    3127   PRIVATE 
     
    3531   INTEGER                ::   nrunid   ! netcdf file id 
    3632   INTEGER, DIMENSION(2)  ::   nvarid   ! netcdf variable id 
     33 
     34#  include "domzgr_substitute.h90" 
    3735   !!---------------------------------------------------------------------- 
    3836   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
     
    4947      !! 
    5048      !! ** Method  : - Save the time step in numstp 
     49      !!              - Print it each 50 time steps 
    5150      !!              - Stop the run IF problem encountered by setting nstop > 0 
    52       !!                Problems checked: negative sea surface height  
     51      !!                Problems checked: e3t0+ssh minimum smaller that 0 
    5352      !!                                  |U|   maximum larger than 10 m/s  
     53      !!                                  ( not for SWE : negative sea surface salinity ) 
    5454      !! 
    5555      !! ** Actions :   "time.step" file = last ocean time-step 
     
    6363      INTEGER                         ::   idtime, istatus 
    6464      INTEGER , DIMENSION(3)          ::   iareasum, iareamin, iareamax 
    65       INTEGER , DIMENSION(3,2)        ::   iloc                                  ! min/max loc indices 
     65      INTEGER , DIMENSION(3,4)        ::   iloc                                  ! min/max loc indices 
    6666      REAL(wp)                        ::   zzz                                   ! local real  
    6767      REAL(wp), DIMENSION(3)          ::   zmax, zmaxlocal 
     
    7070      CHARACTER(len=20)               ::   clname 
    7171      !!---------------------------------------------------------------------- 
     72      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid 
     73      ! 
    7274      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid 
    7375      ! 
     
    109111      !                                   !==            test of local extrema           ==! 
    110112      !                                   !==  done by all processes at every time step  ==! 
    111       ! 
    112       llmsk(   1:Nis1,:,:) = .FALSE.                                              ! exclude halos from the checked region 
    113       llmsk(Nie1: jpi,:,:) = .FALSE. 
    114       llmsk(:,   1:Njs1,:) = .FALSE. 
    115       llmsk(:,Nje1: jpj,:) = .FALSE. 
    116       ! 
     113      zmax(1) = MINVAL( e3t_0(:,:,1)+ssh(:,:,Kmm)  )                              ! e3t_Kmm min 
     114      llmsk(:,:,:) = umask(:,:,:) == 1._wp 
     115      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) ), mask = llmsk )                     ! velocity max (zonal only) 
     116      zmax(3) = REAL( nstop , wp )                                            ! stop indicator 
     117      !                                   !==               get global extrema             ==! 
     118      !                                   !==  done by all processes if writting run.stat  ==! 
    117119      llmsk(Nis0:Nie0,Njs0:Nje0,1) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp         ! define only the inner domain 
    118120      zmax(1) = MAXVAL(     -e3t(:,:,1,Kmm) ), mask = llmsk(:,:,1) )      ! ssh max 
     
    131133      IF( ll_wrtruns ) THEN 
    132134         WRITE(numrun,9500) kt, zmax(1), zmax(2) 
    133          istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ -zmax(1)/), (/kt/), (/1/) ) 
    134          istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/  zmax(2)/), (/kt/), (/1/) ) 
     135         istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 
     136         istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 
    135137         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid) 
    136       END IF 
     138      ENDIF 
    137139      !                                   !==               error handling               ==! 
    138140      !                                   !==  done by all processes at every time step  ==! 
    139141      ! 
    140       IF(   zmax(1) >  0._wp           .OR.   &               ! negative sea surface height  
    141          &  zmax(2) > 10._wp           .OR.   &               ! too large velocity ( > 10 m/s) 
     142!!SWE specific : start 
     143      IF(   zmax(1) <=   0._wp .OR.           &               ! negative e3t_Kmm 
     144         &  zmax(2) >   10._wp .OR.           &               ! too large velocity ( > 10 m/s) 
    142145         &  ISNAN( zmax(1) + zmax(2) ) .OR.   &               ! NaN encounter in the tests 
    143146         &  ABS(   zmax(1) + zmax(2) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests 
     
    148151            IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid) 
    149152            ! get global loc on the min/max 
    150             llmsk(Nis0:Nie0,Njs0:Nje0,1) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp         ! define only the inner domain 
    151             CALL mpp_maxloc( 'stpctl',   -e3t(:,:,1,Kmm) , llmsk(:,:,1), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F  
    152             llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
    153             CALL mpp_maxloc( 'stpctl', ABS(uu(:,:,:,Kmm)), llmsk(:,:,:), zzz, iloc(1:3,2) ) 
     153            CALL mpp_minloc( 'stpctl', e3t_0(:,:,1) + ssh(:,:,Kmm), ssmask(:,:  ), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F  
     154            CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,Kmm))        ,  umask(:,:,:), zzz, iloc(1:3,2) ) 
    154155            ! find which subdomain has the max. 
    155156            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0 
     
    164165         ELSE                    ! find local min and max locations: 
    165166            ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 
    166             llmsk(Nis0:Nie0,Njs0:Nje0,1) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp         ! define only the inner domain 
    167             iloc(1:2,1) = MAXLOC(   -e3t(:,:,1,Kmm) , mask = llmsk(:,:,1) ) 
    168             llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
    169             iloc(1:3,2) = MAXLOC( ABS(uu(:,:,:,Kmm)), mask = llmsk(:,:,:) ) 
    170             DO ji = 1, 2   ! local domain indices ==> global domain indices, excluding halos 
    171                iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /) 
    172             END DO 
     167            iloc(1:2,1) = MINLOC( e3t_0(:,:,1) + ssh(:,:,Kmm), mask = ssmask(:,:  ) == 1._wp ) + (/ nimpp - 1, njmpp - 1    /) 
     168            iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask =  umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
    173169            iareamin(:) = narea   ;   iareamax(:) = narea   ;   iareasum(:) = 1         ! this is local information 
    174170         ENDIF 
    175171         ! 
    176          WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests' 
    177          CALL wrt_line( ctmp2, kt, '|e3t| min', -zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
    178          CALL wrt_line( ctmp3, kt, '|U|   max',  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
     172         WRITE(ctmp1,*) ' stp_ctl:  e3t0+ssh < 0 m  or  |U| > 10 m/s  or  NaN encounter in the tests' 
     173         CALL wrt_line( ctmp2, kt, 'e3t0+ssh min',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
     174         CALL wrt_line( ctmp3, kt, '|U|   max'   ,  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
    179175         IF( Agrif_Root() ) THEN 
    180176            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files' 
     
    194190         ! 
    195191      ENDIF 
     192!!SWE specific : end 
    196193      ! 
    197194      IF( nstop > 0 ) THEN                                                  ! an error was detected and we did not abort yet... 
     
    200197      ENDIF 
    201198      ! 
    202 9500  FORMAT(' it :', i8, '    |ssh|_max: ', D23.16, ' |U|_max: ', D23.16,' S_min: ', D23.16,' S_max: ', D23.16) 
     1999500  FORMAT(' it :', i8, '      e3t_min: ', D23.16, ' |U|_max: ', D23.16) 
    203200      ! 
    204201   END SUBROUTINE stp_ctl 
Note: See TracChangeset for help on using the changeset viewer.