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 13616 for NEMO/trunk/src/SAS – NEMO

Changeset 13616 for NEMO/trunk/src/SAS


Ignore:
Timestamp:
2020-10-15T17:58:33+02:00 (4 years ago)
Author:
smasson
Message:

trunk: bugfix in stpctl for land inner-domains, see #2549

File:
1 edited

Legend:

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

    r13546 r13616  
    6868      REAL(wp)                        ::   zzz                                   ! local real  
    6969      REAL(wp), DIMENSION(4)          ::   zmax, zmaxlocal 
    70       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns 
     70      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce 
    7171      LOGICAL, DIMENSION(jpi,jpj)     ::   llmsk 
    7272      CHARACTER(len=20)               ::   clname 
     
    124124      llmsk(:,Nje1: jpj) = .FALSE. 
    125125      ! 
    126       llmsk(Nis0:Nie0,Njs0:Nje0) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp   ! test only the inner domain 
    127       IF( COUNT( llmsk(:,:) ) > 0 ) THEN   ! avoid huge values sent back for land processors... 
    128          zmax(1) = MAXVAL(      vt_i (:,:)      , mask = llmsk )   ! max ice thickness 
    129          zmax(2) = MAXVAL( ABS( u_ice(:,:) )    , mask = llmsk )   ! max ice velocity (zonal only) 
    130          zmax(3) = MAXVAL(     -tm_i (:,:) + rt0, mask = llmsk )   ! min ice temperature (in degC) 
    131       ELSE 
    132          IF( ll_colruns ) THEN    ! default value: must not be kept when calling mpp_max -> must be as small as possible 
    133             zmax(1:3) = -HUGE(1._wp) 
    134          ELSE                     ! default value: must not give true for any of the tests bellow (-> avoid manipulating HUGE...) 
    135             zmax(1:3) = 0._wp 
    136          ENDIF 
    137       ENDIF 
    138       zmax(4) = REAL( nstop, wp )                                     ! stop indicator 
     126      llmsk(Nis0:Nie0,Njs0:Nje0) = tmask(Nis0:Nie0,Njs0:Nje0,1) == 1._wp        ! test only the inner domain 
     127      ! 
     128      ll_0oce = .NOT. ANY( llmsk(:,:) )                                         ! no ocean point in the inner domain? 
     129      ! 
     130      zmax(1) = MAXVAL(      vt_i (:,:)      , mask = llmsk )                   ! max ice thickness 
     131      zmax(2) = MAXVAL( ABS( u_ice(:,:) )    , mask = llmsk )                   ! max ice velocity (zonal only) 
     132      zmax(3) = MAXVAL(     -tm_i (:,:) + rt0, mask = llmsk )                   ! min ice temperature (in degC) 
     133      zmax(4) = REAL( nstop, wp )                                               ! stop indicator 
     134      ! 
    139135      !                                   !==               get global extrema             ==! 
    140136      !                                   !==  done by all processes if writting run.stat  ==! 
    141137      IF( ll_colruns ) THEN 
    142138         zmaxlocal(:) = zmax(:) 
    143          CALL mpp_max( "stpctl", zmax )          ! max over the global domain 
     139         CALL mpp_max( "stpctl", zmax )          ! max over the global domain: ok even of ll_0oce = .true. 
    144140         nstop = NINT( zmax(4) )                 ! update nstop indicator (now sheared among all local domains) 
    145       ENDIF 
     141      ELSE 
     142         ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow. 
     143         IF( ll_0oce )   zmax(1:3) = 0._wp       ! default "valid" values... 
     144      ENDIF 
     145      ! 
     146      zmax(3) = -zmax(3)                              ! move back from max(-zz) to min(zz) : easier to manage! 
     147      IF( ll_colruns ) zmaxlocal(3) = -zmaxlocal(3)   ! move back from max(-zz) to min(zz) : easier to manage! 
     148      ! 
    146149      !                                   !==              write "run.stat" files              ==! 
    147150      !                                   !==  done only by 1st subdomain at writting timestep  ==! 
    148151      IF( ll_wrtruns ) THEN 
    149          WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3) 
    150          istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 
    151          istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 
    152          istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) ) 
     152         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3) 
     153         DO ji = 1, 3 
     154            istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) ) 
     155         END DO 
    153156         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid) 
    154157      END IF 
     
    158161      IF(   zmax(1) >  100._wp .OR.   &                   ! too large ice thickness maximum ( > 100 m) 
    159162         &  zmax(2) >   10._wp .OR.   &                   ! too large ice velocity ( > 10 m/s) 
    160          &  zmax(3) 101._wp .OR.   &                   ! too cold ice temperature ( < -100 degC) 
     163         &  zmax(3) < -101._wp .OR.   &                   ! too cold ice temperature ( < -100 degC) 
    161164         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests 
    162165         &  ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests 
     
    192195         ! 
    193196         WRITE(ctmp1,*) ' stp_ctl: ice_thick > 100 m or |ice_vel| > 10 m/s or ice_temp < -100 degC or NaN encounter in the tests' 
    194          CALL wrt_line( ctmp2, kt, 'ice_thick max',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
    195          CALL wrt_line( ctmp3, kt, '|ice_vel| max',  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
    196          CALL wrt_line( ctmp4, kt, 'ice_temp  min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 
     197         CALL wrt_line( ctmp2, kt, 'ice_thick max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
     198         CALL wrt_line( ctmp3, kt, '|ice_vel| max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
     199         CALL wrt_line( ctmp4, kt, 'ice_temp  min', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 
    197200         IF( Agrif_Root() ) THEN 
    198201            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files' 
Note: See TracChangeset for help on using the changeset viewer.