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 12685 – NEMO

Changeset 12685


Ignore:
Timestamp:
2020-04-06T11:52:15+02:00 (4 years ago)
Author:
smasson
Message:

r12581_ticket2418: end cleaning, see #2418

Location:
NEMO/branches/2020/r12581_ticket2418
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2020/r12581_ticket2418/src/OCE/stpctl.F90

    r12684 r12685  
    1919   USE dom_oce         ! ocean space and time domain variables  
    2020   USE c1d             ! 1D vertical configuration 
     21   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
     22   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
     23   !   
    2124   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
    22    ! 
    2325   USE in_out_manager  ! I/O manager 
    2426   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2527   USE lib_mpp         ! distributed memory computing 
    26    USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
    27    USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
    28  
     28   ! 
    2929   USE netcdf          ! NetCDF library 
    3030   IMPLICIT NONE 
     
    7474      ! 
    7575      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
    76       ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 
    77       ll_wrtruns = ll_colruns .AND. lwm 
     76      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1  
     77      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 
    7878      ! 
    7979      IF( kt == nit000 ) THEN 
     
    212212         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
    213213         ! 
    214          IF( ll_colruns ) THEN   ! all processes are synchronized -> use lwp to do the print in opened ocean.output files 
     214         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files 
    215215            IF(lwp)   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
    216216         ELSE   ! only mpi subdomains with errors are here -> STOP now 
  • NEMO/branches/2020/r12581_ticket2418/src/SAS/stpctl.F90

    r12684 r12685  
    2020   USE dom_oce         ! ocean space and time domain variables  
    2121   USE ice      , ONLY : vt_i, u_ice, tm_i 
     22   ! 
    2223   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
    23    ! 
    2424   USE in_out_manager  ! I/O manager 
    2525   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2626   USE lib_mpp         ! distributed memory computing 
    27  
     27   ! 
    2828   USE netcdf          ! NetCDF library 
    2929   IMPLICIT NONE 
     
    7373      ! 
    7474      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
    75       ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 
    76       ll_wrtruns = ll_colruns .AND. lwm 
     75      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1  
     76      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 
    7777      ! 
    7878      IF( kt == nit000 ) THEN 
     
    172172         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
    173173         ! 
    174          IF( ll_colruns ) THEN   ! all processes are synchronized -> use lwp to do the print in opened ocean.output files 
     174         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files 
    175175            IF(lwp)   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
    176176         ELSE   ! only mpi subdomains with errors are here -> STOP now 
  • NEMO/branches/2020/r12581_ticket2418/tests/CANAL/MY_SRC/stpctl.F90

    r12684 r12685  
    1919   USE dom_oce         ! ocean space and time domain variables  
    2020   USE c1d             ! 1D vertical configuration 
     21   USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
     22   USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
     23   !   
    2124   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
    22    ! 
    2325   USE in_out_manager  ! I/O manager 
    2426   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2527   USE lib_mpp         ! distributed memory computing 
    26    USE zdf_oce ,  ONLY : ln_zad_Aimp       ! ocean vertical physics variables 
    27    USE wet_dry,   ONLY : ll_wd, ssh_ref    ! reference depth for negative bathy 
    28  
     28   ! 
    2929   USE netcdf          ! NetCDF library 
    3030   IMPLICIT NONE 
     
    7474      ! 
    7575      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
    76       ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 
    77       ll_wrtruns = ll_colruns .AND. lwm 
     76      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1  
     77      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 
    7878      ! 
    7979      IF( kt == nit000 ) THEN 
     
    212212         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
    213213         ! 
    214          IF( ll_colruns ) THEN   ! all processes are synchronized -> use lwp to do the print in opened ocean.output files 
     214         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files 
    215215            IF(lwp)   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
    216216         ELSE   ! only mpi subdomains with errors are here -> STOP now 
  • NEMO/branches/2020/r12581_ticket2418/tests/STATION_ASF/MY_SRC/stpctl.F90

    r12593 r12685  
    1919   USE dom_oce         ! ocean space and time domain variables 
    2020   USE sbc_oce         ! surface fluxes and stuff 
     21   ! 
    2122   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
    22    ! 
    2323   USE in_out_manager  ! I/O manager 
    2424   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2525   USE lib_mpp         ! distributed memory computing 
    26  
     26   ! 
    2727   USE netcdf          ! NetCDF library 
    2828   IMPLICIT NONE 
     
    3131   PUBLIC stp_ctl           ! routine called by step.F90 
    3232 
    33    INTEGER  ::   nrunid, ntauid, nqnsid, nempid 
     33   INTEGER                ::   nrunid   ! netcdf file id 
     34   INTEGER, DIMENSION(3)  ::   nvarid   ! netcdf variable id 
    3435   !!---------------------------------------------------------------------- 
    3536   !! NEMO/SAS 4.0 , NEMO Consortium (2018) 
     
    3940CONTAINS 
    4041 
    41    SUBROUTINE stp_ctl( kt, Kbb, Kmm ) 
     42   SUBROUTINE stp_ctl( kt, Kmm ) 
    4243      !!---------------------------------------------------------------------- 
    4344      !!                    ***  ROUTINE stp_ctl  *** 
    44       !! 
     45      !!                      
    4546      !! ** Purpose :   Control the run 
    4647      !! 
    4748      !! ** Method  : - Save the time step in numstp 
    4849      !!              - Print it each 50 time steps 
    49       !!              - Stop the run IF problem encountered by setting indic=-3 
     50      !!              - Stop the run IF problem encountered by setting nstop > 0 
     51      !!                Problems checked: wind stress module  max larger than 5 N/m^2 
     52      !!                                  non-solar heat flux max larger than 2000 W/m^2 
     53      !!                                  Evaporation-Precip  max larger than 1.E-3 kg/m^2/s 
    5054      !! 
    5155      !! ** Actions :   "time.step" file = last ocean time-step 
    5256      !!                "run.stat"  file = run statistics 
    53       !!                nstop indicator sheared among all local domain (lk_mpp=T) 
     57      !!                 nstop indicator sheared among all local domain 
    5458      !!---------------------------------------------------------------------- 
    5559      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index 
    56       INTEGER, INTENT(in   ) ::   Kbb, Kmm      ! ocean time level index 
     60      INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index 
    5761      !! 
    58       INTEGER                ::   idtime, istatus 
    59       REAL(wp), DIMENSION(3) ::   zmax 
    60       LOGICAL                ::   ll_wrtstp, ll_colruns, ll_wrtruns 
    61       LOGICAL, DIMENSION(jpi,jpj) ::   llmsk 
    62       CHARACTER(len=20) :: clname 
     62      INTEGER                         ::   ji                                    ! dummy loop indices 
     63      INTEGER                         ::   idtime, istatus 
     64      INTEGER, DIMENSION(2,3)         ::   iloc                                  ! min/max loc indices 
     65      REAL(wp)                        ::   zzz                                   ! local real  
     66      REAL(wp), DIMENSION(4)          ::   zmax, zmaxlocal, zarea 
     67      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns 
     68      LOGICAL, DIMENSION(jpi,jpj)     ::   llmsk 
     69      CHARACTER(len=20)               ::   clname 
    6370      !!---------------------------------------------------------------------- 
     71      IF( nstop > 0 .AND. ngrdstop > -1 )   RETURN   !   stpctl was already called by a child grid 
    6472      ! 
    6573      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
    66       ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 
    67       ll_wrtruns = ll_colruns .AND. lwm 
     74      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat .AND. jpnij > 1  
     75      ll_wrtruns = ( ll_colruns .OR. jpnij == 1 ) .AND. lwm 
    6876      ! 
    6977      IF( kt == nit000 ) THEN 
     
    8593            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 
    8694            istatus = NF90_DEF_DIM( nrunid, 'time', NF90_UNLIMITED, idtime ) 
    87             istatus = NF90_DEF_VAR( nrunid, 'tau_max', NF90_DOUBLE, (/ idtime /), ntauid ) 
    88             istatus = NF90_DEF_VAR( nrunid, 'qns_max', NF90_DOUBLE, (/ idtime /), nqnsid  ) 
    89             istatus = NF90_DEF_VAR( nrunid, 'emp_max', NF90_DOUBLE, (/ idtime /), nempid  ) 
     95            istatus = NF90_DEF_VAR( nrunid, 'tau_max', NF90_DOUBLE, (/ idtime /), nvarid(1) ) 
     96            istatus = NF90_DEF_VAR( nrunid, 'qns_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 
     97            istatus = NF90_DEF_VAR( nrunid, 'emp_max', NF90_DOUBLE, (/ idtime /), nvarid(3) ) 
    9098            istatus = NF90_ENDDEF(nrunid) 
    9199         ENDIF 
     
    105113      zmax(2) = MAXVAL( ABS( qns(:,:) ) , mask = llmsk )   ! max non-solar heat flux 
    106114      zmax(3) = MAXVAL( ABS( emp(:,:) ) , mask = llmsk )   ! max E-P 
    107       ! 
     115      zmax(4) = REAL( nstop, wp )                                     ! stop indicator 
     116      !                                   !==               get global extrema             ==! 
     117      !                                   !==  done by all processes if writting run.stat  ==! 
    108118      IF( ll_colruns ) THEN 
     119         zmaxlocal(:) = zmax(:) 
    109120         CALL mpp_max( "stpctl", zmax )          ! max over the global domain 
    110          nstop = NINT( zmax(3) )                 ! nstop indicator sheared among all local domains 
     121         nstop = NINT( zmax(4) )                 ! update nstop indicator (now sheared among all local domains) 
    111122      ENDIF 
    112       !                                   !==  run statistics  ==!   ("run.stat" files) 
     123      !                                   !==              write "run.stat" files              ==! 
     124      !                                   !==  done only by 1st subdomain at writting timestep  ==! 
    113125      IF( ll_wrtruns ) THEN 
    114126         WRITE(numrun,9500) kt, zmax(1), zmax(2), zmax(3) 
    115          istatus = NF90_PUT_VAR( nrunid, ntauid, (/ zmax(1)/), (/kt/), (/1/) ) 
    116          istatus = NF90_PUT_VAR( nrunid, nqnsid, (/ zmax(2)/), (/kt/), (/1/) ) 
    117          istatus = NF90_PUT_VAR( nrunid, nempid, (/ zmax(3)/), (/kt/), (/1/) ) 
    118          IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(nrunid) 
    119          IF( kt == nitend         ) istatus = NF90_CLOSE(nrunid) 
     127         istatus = NF90_PUT_VAR( nrunid, nvarid(1), (/ zmax(1)/), (/kt/), (/1/) ) 
     128         istatus = NF90_PUT_VAR( nrunid, nvarid(2), (/ zmax(2)/), (/kt/), (/1/) ) 
     129         istatus = NF90_PUT_VAR( nrunid, nvarid(3), (/ zmax(3)/), (/kt/), (/1/) ) 
     130         IF( kt == nitend ) istatus = NF90_CLOSE(nrunid) 
    120131      END IF 
    121       !                                   !==  error handling  ==! 
    122       IF( ( sn_cfctl%l_glochk .OR. lsomeoce ) .AND. (   &  ! domain contains some ocean points, check for sensible ranges 
    123          &  zmax(1) >    5._wp .OR.   &             ! too large wind stress ( > 5 N/m^2 ) 
    124          &  zmax(2) > 2000._wp .OR.   &             ! too large non-solar heat flux ( > 2000 W/m^2) 
    125          &  zmax(3) > 1.E-3_wp .OR.   &             ! too large net freshwater flux ( kg/m^2/s) 
    126          &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) ) THEN   ! NaN encounter in the tests 
    127  
    128          !! We are 1D so no need to find a spatial location of the rogue point. 
    129  
     132      !                                   !==               error handling               ==! 
     133      !                                   !==  done by all processes at every time step  ==! 
     134      ! 
     135      IF(   zmax(1) >    5._wp .OR.   &                   ! too large wind stress         ( > 5 N/m^2 ) 
     136         &  zmax(2) > 2000._wp .OR.   &                   ! too large non-solar heat flux ( > 2000 W/m^2 ) 
     137         &  zmax(3) > 1.E-3_wp .OR.   &                   ! too large net freshwater flux ( > 1.E-3 kg/m^2/s ) 
     138         &  ISNAN( zmax(1) + zmax(2) + zmax(3) ) ) THEN   ! NaN encounter in the tests 
     139         ! 
     140         IF( ll_colruns ) THEN   ! zmax is global, so it is the same on all subdomains -> no dead lock with mpp_maxloc 
     141            ! first: close the netcdf file, so we can read it 
     142            IF( lwm .AND. kt /= nitend )   istatus = NF90_CLOSE(nrunid) 
     143            ! get global loc on the min/max 
     144            CALL mpp_maxloc( 'stpctl',      vt_i(:,:)            , tmask(:,:,1), zzz, iloc(1:2,1) )   ! mpp_maxloc ok if mask = F  
     145            CALL mpp_maxloc( 'stpctl',ABS( u_ice(:,:) )          , tmask(:,:,1), zzz, iloc(1:2,2) ) 
     146            CALL mpp_minloc( 'stpctl',      tm_i(:,:) - 273.15_wp, tmask(:,:,1), zzz, iloc(1:2,3) ) 
     147            ! find which subdomain has the max. 
     148            zarea(:) = 0._wp 
     149            DO ji = 1, 4 
     150               IF( zmaxlocal(ji) == zmax(ji) )   zarea(ji) = narea  
     151            END DO 
     152            CALL mpp_max( "stpctl", zarea )         ! max over the global domain 
     153         ELSE                    ! find local min and max locations: 
     154            ! if we are here, this means that the subdomain contains some oce points -> no need to test the mask used in maxloc 
     155            iloc(1:2,1) = MAXLOC(       vt_i(:,:)            , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 
     156            iloc(1:2,2) = MAXLOC( ABS( u_ice(:,:) )          , mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 
     157            iloc(1:2,3) = MINLOC(       tm_i(:,:) - 273.15_wp, mask = llmsk ) + (/ nimpp - 1, njmpp - 1/) 
     158            zarea(:) = narea     ! this is local information 
     159         ENDIF 
     160         ! 
    130161         WRITE(ctmp1,*) ' stp_ctl: |tau_mod| > 5 N/m2  or  |qns| > 2000 W/m2  or |emp| > 1.E-3 or  NaN encounter in the tests' 
    131          WRITE(ctmp2,9500) kt,   zmax(1), zmax(2), zmax(3) 
    132          WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort.nc file' 
    133  
     162         WRITE(ctmp2,9100) kt, ' |tau| max', zmax(1), iloc(1,1), iloc(2,1), NINT(zarea(1))-1 
     163         WRITE(ctmp3,9100) kt, ' |qns| max', zmax(2), iloc(1,2), iloc(2,3), NINT(zarea(2))-1 
     164         WRITE(ctmp4,9100) kt, '  emp  max', zmax(3), iloc(1,2), iloc(2,3), NINT(zarea(3))-1 
     165         IF( Agrif_Root() ) THEN 
     166            WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort* files' 
     167         ELSE 
     168            WRITE(ctmp6,*) '      ===> output of last computed fields in '//TRIM(Agrif_CFixed())//'_output.abort* files' 
     169         ENDIF 
     170         ! 
    134171         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
    135  
    136          IF( .NOT. sn_cfctl%l_glochk ) THEN 
    137             WRITE(ctmp8,*) 'E R R O R message from sub-domain: ', narea 
    138             CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) 
    139          ELSE 
    140             CALL ctl_stop( ctmp1, ' ', ctmp2, ' ', ctmp6, ' ' ) 
     172         ! 
     173         IF( ll_colruns .or. jpnij == 1 ) THEN   ! all processes synchronized -> use lwp to print in opened ocean.output files 
     174            IF(lwp)   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
     175         ELSE   ! only mpi subdomains with errors are here -> STOP now 
     176            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
    141177         ENDIF 
    142  
    143          kindic = -3 
     178         ! 
     179         IF( nstop == 0 )   nstop = 1  
     180         ngrdstop = Agrif_Fixed() 
    144181         ! 
    145182      ENDIF 
    146183      ! 
     1849100  FORMAT(' kt ',i8,a,1pg11.4,' at i j',2i6,' MPI rank',i6) 
    1471859500  FORMAT(' it :', i8, '    tau_max: ', D23.16, ' |qns|_max: ', D23.16,' |emp|_max: ', D23.16) 
    148186      ! 
Note: See TracChangeset for help on using the changeset viewer.