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 12593 for NEMO/branches/2020/r12581_ticket2418/src/SAS – NEMO

Ignore:
Timestamp:
2020-03-24T16:52:17+01:00 (4 years ago)
Author:
smasson
Message:

r12581_ticket2418, first commit see #2418

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

Legend:

Unmodified
Added
Removed
  • NEMO/branches/2020/r12581_ticket2418/src/SAS/diawri.F90

    r12489 r12593  
    9999      ! Output the initial state and forcings 
    100100      IF( ninist == 1 ) THEN 
    101          CALL dia_wri_state( 'output.init', Kmm ) 
     101         CALL dia_wri_state( Kmm, 'output.init' ) 
    102102         ninist = 0 
    103103      ENDIF 
     
    126126   END FUNCTION dia_wri_alloc_abl 
    127127   
    128    SUBROUTINE dia_wri( kt ) 
     128   SUBROUTINE dia_wri( kt, Kmm ) 
    129129      !!--------------------------------------------------------------------- 
    130130      !!                  ***  ROUTINE dia_wri  *** 
     
    140140      !! 
    141141      INTEGER, INTENT( in ) ::   kt      ! ocean time-step index 
     142      INTEGER, INTENT( in ) ::   Kmm     ! ocean time levelindex 
    142143      !! 
    143144      LOGICAL ::   ll_print = .FALSE.                        ! =T print and flush numout 
     
    154155      ! Output the initial state and forcings 
    155156      IF( ninist == 1 ) THEN                        
    156          CALL dia_wri_state( 'output.init' ) 
     157         CALL dia_wri_state( Kmm, 'output.init' ) 
    157158         ninist = 0 
    158159      ENDIF 
     
    414415#endif 
    415416 
    416    SUBROUTINE dia_wri_state( cdfile_name, Kmm ) 
     417   SUBROUTINE dia_wri_state( Kmm, cdfile_name ) 
    417418      !!--------------------------------------------------------------------- 
    418419      !!                 ***  ROUTINE dia_wri_state  *** 
     
    427428      !!      File 'output.abort.nc' is created in case of abnormal job end 
    428429      !!---------------------------------------------------------------------- 
     430      INTEGER           , INTENT( in ) ::   Kmm              ! ocean time levelindex 
    429431      CHARACTER (len=* ), INTENT( in ) ::   cdfile_name      ! name of the file created 
    430       INTEGER           , INTENT( in ) ::   Kmm              ! ocean time levelindex 
    431432      !! 
    432433      INTEGER :: inum 
  • NEMO/branches/2020/r12581_ticket2418/src/SAS/nemogcm.F90

    r12489 r12593  
    401401         WRITE(numout,*) '~~~~~~~~' 
    402402         WRITE(numout,*) '   Namelist namctl' 
    403          WRITE(numout,*) '                              sn_cfctl%l_glochk  = ', sn_cfctl%l_glochk 
    404403         WRITE(numout,*) '                              sn_cfctl%l_allon   = ', sn_cfctl%l_allon 
    405404         WRITE(numout,*) '       finer control over o/p sn_cfctl%l_config  = ', sn_cfctl%l_config 
  • NEMO/branches/2020/r12581_ticket2418/src/SAS/step.F90

    r12377 r12593  
    7474      !!              -2- Outputs and diagnostics 
    7575      !!---------------------------------------------------------------------- 
    76       INTEGER ::   indic    ! error indicator if < 0 
    77       !! --------------------------------------------------------------------- 
    7876 
    7977#if defined key_agrif 
    8078      kstp = nit000 + Agrif_Nb_Step() 
    8179      Kbb_a = Nbb; Kmm_a = Nnn; Krhs_a = Nrhs   ! agrif_oce module copies of time level indices 
    82       IF ( lk_agrif_debug ) THEN 
    83          IF ( Agrif_Root() .and. lwp) Write(*,*) '---' 
    84          IF (lwp) Write(*,*) 'Grid Number',Agrif_Fixed(),' time step ',kstp, 'int tstep',Agrif_NbStepint() 
     80      IF( lk_agrif_debug ) THEN 
     81         IF( Agrif_Root() .and. lwp)   WRITE(*,*) '---' 
     82         IF(lwp)   WRITE(*,*) 'Grid Number', Agrif_Fixed(),' time step ', kstp, 'int tstep', Agrif_NbStepint() 
    8583      ENDIF 
    86  
    87       IF ( kstp == (nit000 + 1) ) lk_agrif_fstep = .FALSE. 
    88  
     84      IF( kstp == nit000 + 1 )   lk_agrif_fstep = .FALSE. 
    8985# if defined key_iomput 
    9086      IF( Agrif_Nbstepint() == 0 )   CALL iom_swap( cxios_context ) 
    9187# endif    
    9288#endif    
    93                              indic = 0                    ! although indic is not changed in stp_ctl 
    94                                                           ! need to keep the same interface  
    9589      IF( kstp == nit000 )   CALL iom_init( cxios_context ) ! iom_put initialization (must be done after nemo_init for AGRIF+XIOS+OASIS) 
    9690      IF( kstp /= nit000 )   CALL day( kstp )             ! Calendar (day was already called at nit000 in day_init) 
     
    123117      ! Control 
    124118      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    125                              CALL stp_ctl( kstp, indic ) 
    126       IF( indic < 0  )  THEN 
    127                              CALL ctl_stop( 'step: indic < 0' ) 
    128                              CALL dia_wri_state( 'output.abort', Nnn ) 
    129       ENDIF 
    130       IF( kstp == nit000   ) CALL iom_close( numror )           ! close input  ocean restart file 
     119                             CALL stp_ctl( kstp, Nnn ) 
     120       
     121      IF( kstp == nit000   ) CALL iom_close( numror )               ! close input  ocean restart file 
    131122       
    132123      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
    133124      ! Coupled mode 
    134125      !<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 
    135       IF( lk_oasis    ) CALL sbc_cpl_snd( kstp, Nbb, Nnn )     ! coupled mode : field exchanges if OASIS-coupled ice 
     126      IF( lk_oasis         ) CALL sbc_cpl_snd( kstp, Nbb, Nnn )     ! coupled mode : field exchanges if OASIS-coupled ice 
    136127 
    137128#if defined key_iomput 
     
    144135         lrst_oce = .FALSE. 
    145136      ENDIF 
    146       IF( kstp == nitend .OR. indic < 0 ) THEN 
     137      IF( kstp == nitend .OR. nstop > 0 ) THEN 
    147138                             CALL iom_context_finalize( cxios_context ) ! needed for XIOS+AGRIF 
    148139      ENDIF 
  • NEMO/branches/2020/r12581_ticket2418/src/SAS/stpctl.F90

    r12377 r12593  
    2020   USE dom_oce         ! ocean space and time domain variables  
    2121   USE ice      , ONLY : vt_i, u_ice, tm_i 
     22   USE diawri          ! Standard run outputs       (dia_wri_state routine) 
    2223   ! 
    2324   USE in_out_manager  ! I/O manager 
     
    3132   PUBLIC stp_ctl           ! routine called by step.F90 
    3233 
    33    INTEGER  ::   idrun, idtime, idssh, idu, ids, istatus 
    34    LOGICAL  ::   lsomeoce 
     34   INTEGER                ::   nrunid   ! netcdf file id 
     35   INTEGER, DIMENSION(3)  ::   nvarid   ! netcdf variable id 
    3536   !!---------------------------------------------------------------------- 
    3637   !! NEMO/SAS 4.0 , NEMO Consortium (2018) 
     
    3839   !! Software governed by the CeCILL license (see ./LICENSE) 
    3940   !!---------------------------------------------------------------------- 
    40  
    4141CONTAINS 
    4242 
    43    SUBROUTINE stp_ctl( kt, kindic ) 
     43   SUBROUTINE stp_ctl( kt, Kmm ) 
    4444      !!---------------------------------------------------------------------- 
    4545      !!                    ***  ROUTINE stp_ctl  *** 
     
    4949      !! ** Method  : - Save the time step in numstp 
    5050      !!              - Print it each 50 time steps 
     51      !!              - Stop the run IF problem encountered by setting nstop > 0 
     52      !!                Problems checked: ice thickness maximum > 100 m 
     53      !!                                  ice velocity  maximum > 10 m/s  
     54      !!                                  min ice temperature   < -100 degC 
    5155      !! 
    5256      !! ** Actions :   "time.step" file = last ocean time-step 
    5357      !!                "run.stat"  file = run statistics 
    54       !!                 
     58      !!                 nstop indicator sheared among all local domain 
    5559      !!---------------------------------------------------------------------- 
    56       INTEGER, INTENT( in    ) ::   kt       ! ocean time-step index 
    57       INTEGER, INTENT( inout ) ::   kindic   ! indicator of solver convergence 
     60      INTEGER, INTENT(in   ) ::   kt       ! ocean time-step index 
     61      INTEGER, INTENT(in   ) ::   Kmm      ! ocean time level index 
    5862      !! 
    59       REAL(wp), DIMENSION(3) ::   zmax 
    60       LOGICAL                ::   ll_wrtstp, ll_colruns, ll_wrtruns 
    61       CHARACTER(len=20) :: clname 
     63      INTEGER                         ::   ji                                    ! dummy loop indices 
     64      INTEGER                         ::   idtime, istatus 
     65      INTEGER, DIMENSION(2,3)         ::   iloc                                  ! min/max loc indices 
     66      REAL(wp)                        ::   zzz                                   ! local real  
     67      REAL(wp), DIMENSION(4)          ::   zmax, zmaxlocal, zarea 
     68      LOGICAL                         ::   ll_wrtstp, ll_colruns, ll_wrtruns 
     69      LOGICAL, DIMENSION(jpi,jpj)     ::   llmsk 
     70      CHARACTER(len=20)               ::   clname 
    6271      !!---------------------------------------------------------------------- 
    6372      ! 
    64       ll_wrtstp  = ( MOD( kt, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
    65       ll_colruns = ll_wrtstp .AND. ( sn_cfctl%l_runstat ) 
     73      ll_wrtstp  = ( MOD( kt-nit000, sn_cfctl%ptimincr ) == 0 ) .OR. ( kt == nitend ) 
     74      ll_colruns = ll_wrtstp .AND. sn_cfctl%l_runstat 
    6675      ll_wrtruns = ll_colruns .AND. lwm 
    67       IF( kt == nit000 .AND. lwp ) THEN 
    68          WRITE(numout,*) 
    69          WRITE(numout,*) 'stp_ctl : time-stepping control' 
    70          WRITE(numout,*) '~~~~~~~' 
    71          !                                ! open time.step file 
    72          IF( lwm ) CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
    73          !                                ! open run.stat file(s) at start whatever 
    74          !                                ! the value of sn_cfctl%ptimincr 
    75          IF( lwm .AND. ( sn_cfctl%l_runstat ) ) THEN 
     76      ! 
     77      IF( kt == nit000 ) THEN 
     78         ! 
     79         IF( lwp ) THEN 
     80            WRITE(numout,*) 
     81            WRITE(numout,*) 'stp_ctl : time-stepping control' 
     82            WRITE(numout,*) '~~~~~~~' 
     83         ENDIF 
     84         !                                ! open time.step    ascii file, done only by 1st subdomain 
     85         IF( lwm )   CALL ctl_opn( numstp, 'time.step', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
     86         ! 
     87         IF( ll_wrtruns ) THEN 
     88            !                             ! open run.stat     ascii file, done only by 1st subdomain 
    7689            CALL ctl_opn( numrun, 'run.stat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, lwp, narea ) 
     90            !                             ! open run.stat.nc netcdf file, done only by 1st subdomain 
    7791            clname = 'run.stat.nc' 
    7892            IF( .NOT. Agrif_Root() )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 
    79             istatus = NF90_CREATE( 'run.stat.nc', NF90_CLOBBER, idrun ) 
    80             istatus = NF90_DEF_DIM( idrun, 'time'     , NF90_UNLIMITED, idtime ) 
    81             istatus = NF90_DEF_VAR( idrun, 'vt_i_max' , NF90_DOUBLE, (/ idtime /), idssh ) 
    82             istatus = NF90_DEF_VAR( idrun, 'abs_u_max', NF90_DOUBLE, (/ idtime /), idu ) 
    83             istatus = NF90_DEF_VAR( idrun, 'tm_i_min' , NF90_DOUBLE, (/ idtime /), ids ) 
    84             istatus = NF90_ENDDEF(idrun) 
     93            istatus = NF90_CREATE( TRIM(clname), NF90_CLOBBER, nrunid ) 
     94            istatus = NF90_DEF_DIM( nrunid, 'time'     , NF90_UNLIMITED, idtime ) 
     95            istatus = NF90_DEF_VAR( nrunid, 'vt_i_max' , NF90_DOUBLE, (/ idtime /), nvarid(1) ) 
     96            istatus = NF90_DEF_VAR( nrunid, 'abs_u_max', NF90_DOUBLE, (/ idtime /), nvarid(2) ) 
     97            istatus = NF90_DEF_VAR( nrunid, 'tm_i_min' , NF90_DOUBLE, (/ idtime /), nvarid(3) ) 
     98            istatus = NF90_ENDDEF(nrunid) 
    8599         ENDIF 
     100         !     
    86101      ENDIF 
    87       IF( kt == nit000 )   lsomeoce = COUNT( ssmask(:,:) == 1._wp ) > 0 
    88102      ! 
    89       IF(lwm .AND. ll_wrtstp) THEN        !==  current time step  ==!   ("time.step" file) 
     103      !                                   !==              write current time step              ==! 
     104      !                                   !==  done only by 1st subdomain at writting timestep  ==! 
     105      IF( lwm .AND. ll_wrtstp ) THEN 
    90106         WRITE ( numstp, '(1x, i8)' )   kt 
    91107         REWIND( numstp ) 
    92108      ENDIF 
    93       !                                   !==  test of extrema  ==! 
     109      !                                   !==            test of local extrema           ==! 
     110      !                                   !==  done by all processes at every time step  ==! 
     111      llmsk(:,:) = tmask(:,:,1) == 1._wp 
     112      zmax(1) = MAXVAL(      vt_i (:,:)            , mask = llmsk )   ! max ice thickness 
     113      zmax(2) = MAXVAL( ABS( u_ice(:,:) )          , mask = llmsk )   ! max ice velocity (zonal only) 
     114      zmax(3) = MAXVAL(     -tm_i (:,:) + 273.15_wp, mask = llmsk )   ! min ice temperature 
     115      zmax(4) = REAL( nstop, wp )                                     ! stop indicator 
     116      !                                   !==               get global extrema             ==! 
     117      !                                   !==  done by all processes if writting run.stat  ==! 
    94118      IF( ll_colruns ) THEN 
    95          zmax(1) = MAXVAL(      vt_i (:,:) )                                           ! max ice thickness 
    96          zmax(2) = MAXVAL( ABS( u_ice(:,:) ) )                                         ! max ice velocity (zonal only) 
    97          zmax(3) = MAXVAL(     -tm_i (:,:)+273.15_wp , mask = ssmask(:,:) == 1._wp )   ! min ice temperature 
    98          CALL mpp_max( "stpctl", zmax )                                   ! max over the global domain 
     119         zmaxlocal(:) = zmax(:) 
     120         CALL mpp_max( "stpctl", zmax )          ! max over the global domain 
     121         nstop = NINT( zmax(9) )                 ! update nstop indicator (now sheared among all local domains) 
     122      ENDIF 
     123      !                                   !==              write "run.stat" files              ==! 
     124      !                                   !==  done only by 1st subdomain at writting timestep  ==! 
     125      IF( ll_wrtruns ) THEN 
     126         WRITE(numrun,9500) kt, zmax(1), zmax(2), -zmax(3) 
     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) 
    99131      END IF 
    100       !                                            !==  run statistics  ==!   ("run.stat" file) 
    101       IF( ll_wrtruns ) THEN 
    102          WRITE(numrun,9500) kt, zmax(1), zmax(2), - zmax(3) 
    103          istatus = NF90_PUT_VAR( idrun, idssh, (/ zmax(1)/), (/kt/), (/1/) ) 
    104          istatus = NF90_PUT_VAR( idrun,   idu, (/ zmax(2)/), (/kt/), (/1/) ) 
    105          istatus = NF90_PUT_VAR( idrun,   ids, (/-zmax(3)/), (/kt/), (/1/) ) 
    106          IF( MOD( kt , 100 ) == 0 ) istatus = NF90_SYNC(idrun) 
    107          IF( kt == nitend         ) istatus = NF90_CLOSE(idrun) 
    108       END IF 
     132      !                                   !==               error handling               ==! 
     133      !                                   !==  done by all processes at every time step  ==! 
    109134      ! 
     135      IF(   zmax(1) >  100._wp .OR.   &                   ! too large ice thickness maximum ( > 100 m) 
     136         &  zmax(2) >   10._wp .OR.   &                   ! too large ice velocity ( > 10 m/s) 
     137         &  zmax(3) >  101._wp .OR.   &                   ! too cold ice temperature ( < -100 degC) 
     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         ! 
     161         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' 
     162         WRITE(ctmp2,9100) kt, ' ice_thick max',  zmax(1), iloc(1,1), iloc(2,1), NINT(zarea(1))-1 
     163         WRITE(ctmp3,9100) kt, ' |ice_vel| max',  zmax(2), iloc(1,2), iloc(2,3), NINT(zarea(2))-1 
     164         WRITE(ctmp4,9100) kt, ' ice_temp  min', -zmax(3), iloc(1,2), iloc(2,3), NINT(zarea(3))-1 
     165         WRITE(ctmp6,*) '      ===> output of last computed fields in output.abort.nc file' 
     166         ! 
     167         CALL dia_wri_state( Kmm, 'output.abort' )     ! create an output.abort file 
     168         ! 
     169         IF( ll_colruns ) THEN   ! all processes are synchronized -> use lwp to do the print in opened ocean.output files 
     170            IF(lwp)   CALL ctl_stop( ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
     171         ELSE   ! only mpi subdomains with errors are here -> STOP now 
     172            CALL ctl_stop( 'STOP', ctmp1, ' ', ctmp2, ctmp3, ctmp4, ctmp5, ' ', ctmp6 ) 
     173         ENDIF 
     174         ! 
     175         IF( nstop == 0 )   nstop = 1  
     176         ! 
     177      ENDIF 
     178      ! 
     1799100  FORMAT(' kt ',i8,a,1pg11.4,' at i j',2i6,' MPI rank',i6) 
    1101809500  FORMAT(' it :', i8, '    vt_i_max: ', D23.16, ' |u|_max: ', D23.16,' tm_i_min: ', D23.16) 
    111181      ! 
Note: See TracChangeset for help on using the changeset viewer.