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 13952 for NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/tests/DOME/MY_SRC/stpctl.F90 – NEMO

Ignore:
Timestamp:
2020-12-01T19:19:12+01:00 (3 years ago)
Author:
jchanut
Message:

#2222, make new tests namelists compliant with trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2020/dev_r13312_AGRIF-03-04_jchanut_vinterp_tstep/tests/DOME/MY_SRC/stpctl.F90

    r13930 r13952  
    3838   !!---------------------------------------------------------------------- 
    3939   !! NEMO/OCE 4.0 , NEMO Consortium (2018) 
    40    !! $Id: stpctl.F90 13216 2020-07-02 09:25:49Z rblod $ 
     40   !! $Id: stpctl.F90 13942 2020-12-01 16:14:18Z jchanut $ 
    4141   !! Software governed by the CeCILL license (see ./LICENSE) 
    4242   !!---------------------------------------------------------------------- 
     
    5050      !! 
    5151      !! ** Method  : - Save the time step in numstp 
    52       !!              - Print it each 50 time steps 
    5352      !!              - Stop the run IF problem encountered by setting nstop > 0 
    5453      !!                Problems checked: |ssh| maximum larger than 10 m 
     
    6968      REAL(wp)                        ::   zzz                                   ! local real  
    7069      REAL(wp), DIMENSION(9)          ::   zmax, zmaxlocal 
    71       LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns 
     70      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns, ll_0oce 
    7271      LOGICAL, DIMENSION(jpi,jpj,jpk) ::   llmsk 
    7372      CHARACTER(len=20)               ::   clname 
     
    120119      !                                   !==            test of local extrema           ==! 
    121120      !                                   !==  done by all processes at every time step  ==! 
    122       llmsk(:,:,1) = ssmask(:,:) == 1._wp 
     121      ! 
     122      llmsk(   1:Nis1,:,:) = .FALSE.                                              ! exclude halos from the checked region 
     123      llmsk(Nie1: jpi,:,:) = .FALSE. 
     124      llmsk(:,   1:Njs1,:) = .FALSE. 
     125      llmsk(:,Nje1: jpj,:) = .FALSE. 
     126      ! 
     127      llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0) == 1._wp         ! define only the inner domain 
     128      ! 
     129      ll_0oce = .NOT. ANY( llmsk(:,:,1) )                                         ! no ocean point in the inner domain? 
     130      ! 
    123131      IF( ll_wd ) THEN 
    124132         zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm) + ssh_ref ), mask = llmsk(:,:,1) )   ! ssh max 
     
    126134         zmax(1) = MAXVAL( ABS( ssh(:,:,Kmm)           ), mask = llmsk(:,:,1) )   ! ssh max 
    127135      ENDIF 
    128       llmsk(:,:,:) = umask(:,:,:) == 1._wp 
     136      llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
    129137      zmax(2) = MAXVAL(  ABS( uu(:,:,:,Kmm) ), mask = llmsk )                     ! velocity max (zonal only) 
    130       llmsk(:,:,:) = tmask(:,:,:) == 1._wp 
     138      llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
    131139      IF ( ln_seos.AND.(rn_lambda2==0._wp) ) THEN ! Discard checks on salinity 
    132140         zmax(3) = -99._wp 
    133141         zmax(4) = 99._wp 
    134       ELSE  
     142      ELSE 
    135143         zmax(3) = MAXVAL( -ts(:,:,:,jp_sal,Kmm), mask = llmsk )                  ! minus salinity max 
    136144         zmax(4) = MAXVAL(  ts(:,:,:,jp_sal,Kmm), mask = llmsk )                  !       salinity max 
     
    149157         zmax(5:8) = 0._wp 
    150158      ENDIF 
    151       zmax(9) = REAL( nstop, wp )                                              ! stop indicator 
     159      zmax(9) = REAL( nstop, wp )                                                 ! stop indicator 
     160      ! 
    152161      !                                   !==               get global extrema             ==! 
    153162      !                                   !==  done by all processes if writting run.stat  ==! 
    154163      IF( ll_colruns ) THEN 
    155164         zmaxlocal(:) = zmax(:) 
    156          CALL mpp_max( "stpctl", zmax )          ! max over the global domain 
     165         CALL mpp_max( "stpctl", zmax )          ! max over the global domain: ok even of ll_0oce = .true.  
    157166         nstop = NINT( zmax(9) )                 ! update nstop indicator (now sheared among all local domains) 
    158       ENDIF 
     167      ELSE 
     168         ! if no ocean point: MAXVAL returns -HUGE => we must overwrite this value to avoid error handling bellow. 
     169         IF( ll_0oce )   zmax(1:4) = (/ 0._wp, 0._wp, -1._wp, 1._wp /)   ! default "valid" values... 
     170      ENDIF 
     171      ! 
     172      zmax(3) = -zmax(3)                         ! move back from max(-zz) to min(zz) : easier to manage!  
     173      zmax(5) = -zmax(5)                         ! move back from max(-zz) to min(zz) : easier to manage! 
     174      IF( ll_colruns ) THEN 
     175         zmaxlocal(3) = -zmaxlocal(3)            ! move back from max(-zz) to min(zz) : easier to manage!  
     176         zmaxlocal(5) = -zmaxlocal(5)            ! move back from max(-zz) to min(zz) : easier to manage! 
     177      ENDIF 
     178      ! 
    159179      !                                   !==              write "run.stat" files              ==! 
    160180      !                                   !==  done only by 1st subdomain at writting timestep  ==! 
    161181      IF( ll_wrtruns ) THEN 
    162          WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3), zmax(4) 
    163          istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 
    164          istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 
    165          istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/-zmax(3)/), (/kt/), (/1/) ) 
    166          istatus = NF90_PUT_VAR( nrunid, nvarid(4), (/ zmax(4)/), (/kt/), (/1/) ) 
    167          istatus = NF90_PUT_VAR( nrunid, nvarid(5), (/-zmax(5)/), (/kt/), (/1/) ) 
    168          istatus = NF90_PUT_VAR( nrunid, nvarid(6), (/ zmax(6)/), (/kt/), (/1/) ) 
    169          IF( ln_zad_Aimp ) THEN 
    170             istatus = NF90_PUT_VAR( nrunid, nvarid(7), (/ zmax(7)/), (/kt/), (/1/) ) 
    171             istatus = NF90_PUT_VAR( nrunid, nvarid(8), (/ zmax(8)/), (/kt/), (/1/) ) 
    172          ENDIF 
     182         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3), zmax(4) 
     183         DO ji = 1, 6 + 2 * COUNT( (/ln_zad_Aimp/) ) 
     184            istatus = NF90_PUT_VAR( nrunid, nvarid(ji), (/zmax(ji)/), (/kt/), (/1/) ) 
     185         END DO 
    173186         IF( kt == nitend )   istatus = NF90_CLOSE(nrunid) 
    174187      END IF 
     
    176189      !                                   !==  done by all processes at every time step  ==! 
    177190      ! 
    178       IF(   zmax(1) >   20._wp .OR.   &                   ! too large sea surface height ( > 20 m ) 
    179          &  zmax(2) >   10._wp .OR.   &                   ! too large velocity ( > 10 m/s) 
    180          &  zmax(3) >=   0._wp .OR.   &                   ! negative or zero sea surface salinity 
    181          &  zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 ) 
    182          &  zmax(4) <    0._wp .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice) 
    183          &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests 
    184          &  ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests 
     191      IF(  zmax(1) >   20._wp .OR.   &                   ! too large sea surface height ( > 20 m ) 
     192         & zmax(2) >   10._wp .OR.   &                   ! too large velocity ( > 10 m/s) 
     193         & zmax(3) <=   0._wp .OR.   &                   ! negative or zero sea surface salinity 
     194         & zmax(4) >= 100._wp .OR.   &                   ! too large sea surface salinity ( > 100 ) 
     195         & zmax(4) <    0._wp .OR.   &                   ! too large sea surface salinity (keep this line for sea-ice) 
     196         & ISNAN( zmax(1) + zmax(2) + zmax(3) ) .OR.   &               ! NaN encounter in the tests 
     197         & ABS(   zmax(1) + zmax(2) + zmax(3) ) > HUGE(1._wp) ) THEN   ! Infinity encounter in the tests 
    185198         ! 
    186199         iloc(:,:) = 0 
     
    189202            IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid) 
    190203            ! get global loc on the min/max 
    191             CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,         Kmm)), ssmask(:,:  ), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F  
    192             CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,       Kmm)),  umask(:,:,:), zzz, iloc(1:3,2) ) 
    193             CALL mpp_minloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) ,  tmask(:,:,:), zzz, iloc(1:3,3) ) 
    194             CALL mpp_maxloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) ,  tmask(:,:,:), zzz, iloc(1:3,4) ) 
     204            llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp         ! define only the inner domain 
     205            CALL mpp_maxloc( 'stpctl', ABS(ssh(:,:,         Kmm)), llmsk(:,:,1), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F  
     206            llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
     207            CALL mpp_maxloc( 'stpctl', ABS( uu(:,:,:,       Kmm)), llmsk(:,:,:), zzz, iloc(1:3,2) ) 
     208            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
     209            CALL mpp_minloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,3) ) 
     210            CALL mpp_maxloc( 'stpctl',      ts(:,:,:,jp_sal,Kmm) , llmsk(:,:,:), zzz, iloc(1:3,4) ) 
    195211            ! find which subdomain has the max. 
    196212            iareamin(:) = jpnij+1   ;   iareamax(:) = 0   ;   iareasum(:) = 0 
     
    205221         ELSE                    ! find local min and max locations: 
    206222            ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 
    207             iloc(1:2,1) = MAXLOC( ABS( ssh(:,:,         Kmm)), mask = ssmask(:,:  ) == 1._wp ) + (/ nimpp - 1, njmpp - 1    /) 
    208             iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask =  umask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
    209             iloc(1:3,3) = MINLOC(       ts(:,:,:,jp_sal,Kmm) , mask =  tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
    210             iloc(1:3,4) = MAXLOC(       ts(:,:,:,jp_sal,Kmm) , mask =  tmask(:,:,:) == 1._wp ) + (/ nimpp - 1, njmpp - 1, 0 /) 
     223            llmsk(Nis0:Nie0,Njs0:Nje0,1) = ssmask(Nis0:Nie0,Njs0:Nje0 ) == 1._wp        ! define only the inner domain 
     224            iloc(1:2,1) = MAXLOC( ABS( ssh(:,:,         Kmm)), mask = llmsk(:,:,1) ) 
     225            llmsk(Nis0:Nie0,Njs0:Nje0,:) = umask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
     226            iloc(1:3,2) = MAXLOC( ABS(  uu(:,:,:,       Kmm)), mask = llmsk(:,:,:) ) 
     227            llmsk(Nis0:Nie0,Njs0:Nje0,:) = tmask(Nis0:Nie0,Njs0:Nje0,:) == 1._wp        ! define only the inner domain 
     228            iloc(1:3,3) = MINLOC(       ts(:,:,:,jp_sal,Kmm) , mask = llmsk(:,:,:) ) 
     229            iloc(1:3,4) = MAXLOC(       ts(:,:,:,jp_sal,Kmm) , mask = llmsk(:,:,:) ) 
     230            DO ji = 1, 4   ! local domain indices ==> global domain indices, excluding halos 
     231               iloc(1:2,ji) = (/ mig0(iloc(1,ji)), mjg0(iloc(2,ji)) /) 
     232            END DO 
    211233            iareamin(:) = narea   ;   iareamax(:) = narea   ;   iareasum(:) = 1         ! this is local information 
    212234         ENDIF 
    213235         ! 
    214236         WRITE(ctmp1,*) ' stp_ctl: |ssh| > 20 m  or  |U| > 10 m/s  or  S <= 0  or  S >= 100  or  NaN encounter in the tests' 
    215          CALL wrt_line( ctmp2, kt, '|ssh| max',  zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
    216          CALL wrt_line( ctmp3, kt, '|U|   max',  zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
    217          CALL wrt_line( ctmp4, kt, 'Sal   min', -zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 
    218          CALL wrt_line( ctmp5, kt, 'Sal   max',  zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) ) 
     237         CALL wrt_line( ctmp2, kt, '|ssh| max', zmax(1), iloc(:,1), iareasum(1), iareamin(1), iareamax(1) ) 
     238         CALL wrt_line( ctmp3, kt, '|U|   max', zmax(2), iloc(:,2), iareasum(2), iareamin(2), iareamax(2) ) 
     239         CALL wrt_line( ctmp4, kt, 'Sal   min', zmax(3), iloc(:,3), iareasum(3), iareamin(3), iareamax(3) ) 
     240         CALL wrt_line( ctmp5, kt, 'Sal   max', zmax(4), iloc(:,4), iareasum(4), iareamin(4), iareamax(4) ) 
    219241         IF( Agrif_Root() ) THEN 
    220242            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files' 
Note: See TracChangeset for help on using the changeset viewer.