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 9556 for branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/trcrst.F90 – NEMO

Ignore:
Timestamp:
2018-05-05T11:51:20+02:00 (6 years ago)
Author:
cetlod
Message:

Minor improvments to ensures PISCES restartability

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_merge_2017/NEMOGCM/NEMO/TOP_SRC/trcrst.F90

    r7753 r9556  
    186186      INTEGER  ::  jlibalt = jprstlib 
    187187      LOGICAL  ::  llok 
    188       REAL(wp) ::  zkt, zrdttrc1 
    189       REAL(wp) ::  zndastp 
     188      REAL(wp) ::  zrdttrc1, zkt, zndastp, zdayfrac, ksecs, ktime 
     189      INTEGER  ::   ihour, iminute 
    190190 
    191191      ! Time domain : restart 
     
    222222            !                                          ! set the date in offline mode 
    223223            IF( ln_rsttr .AND. nn_rsttr == 2 ) THEN 
    224                CALL iom_get( numrtr, 'ndastp', zndastp )  
     224               CALL iom_get( numrtr, 'ndastp', zndastp ) 
    225225               ndastp = NINT( zndastp ) 
    226226               CALL iom_get( numrtr, 'adatrj', adatrj  ) 
     227               CALL iom_get( numrtr, 'ntime' , ktime   ) 
     228               nn_time0=INT(ktime) 
     229               ! calculate start time in hours and minutes 
     230               zdayfrac=adatrj-INT(adatrj) 
     231               ksecs = NINT(zdayfrac*86400)            ! Nearest second to catch rounding errors in adatrj               
     232               ihour = INT(ksecs/3600) 
     233               iminute = ksecs/60-ihour*60 
     234                 
     235               ! Add to nn_time0 
     236               nhour   =   nn_time0 / 100 
     237               nminute = ( nn_time0 - nhour * 100 ) 
     238               nminute=nminute+iminute 
     239                
     240               IF( nminute >= 60 ) THEN 
     241                  nminute=nminute-60 
     242                  nhour=nhour+1 
     243               ENDIF 
     244               nhour=nhour+ihour 
     245               IF( nhour >= 24 ) THEN 
     246                  nhour=nhour-24 
     247                  adatrj=adatrj+1 
     248               ENDIF            
     249               nn_time0 = nhour * 100 + nminute 
     250               adatrj = INT(adatrj)                    ! adatrj set to integer as nn_time0 updated             
    227251             ELSE 
    228                ndastp = ndate0 - 1     ! ndate0 read in the namelist in dom_nam 
    229                adatrj = ( REAL( nittrc000-1, wp ) * rdt ) / rday 
     252               ! parameters corresponding to nit000 - 1 (as we start the step 
     253               ! loop with a call to day) 
     254               ndastp = ndate0        ! ndate0 read in the namelist in dom_nam 
     255               nhour   =   nn_time0 / 100 
     256               nminute = ( nn_time0 - nhour * 100 ) 
     257               IF( nhour*3600+nminute*60-ndt05 .lt. 0 )  ndastp=ndastp-1      ! Start hour is specified in the namelist (default 0) 
     258               adatrj = ( REAL( nit000-1, wp ) * rdt ) / rday 
    230259               ! note this is wrong if time step has changed during run 
    231260            ENDIF 
     261            IF( ABS(adatrj  - REAL(NINT(adatrj),wp)) < 0.1 / rday )   adatrj = REAL(NINT(adatrj),wp)   ! avoid truncation error 
    232262            ! 
    233263            IF(lwp) THEN 
     
    235265              WRITE(numout,*) '   date ndastp                                      : ', ndastp 
    236266              WRITE(numout,*) '   number of elapsed days since the begining of run : ', adatrj 
     267              WRITE(numout,*) '   nn_time0                                         : ', nn_time0 
    237268              WRITE(numout,*) 
    238269            ENDIF 
     
    257288         CALL iom_rstput( kt, nitrst, numrtw, 'adatrj' , adatrj            )   ! number of elapsed days since 
    258289         !                                                                     ! the begining of the run [s] 
     290         CALL iom_rstput( kt, nitrst, numrtw, 'ntime'  , REAL( nn_time0, wp)) ! time 
    259291      ENDIF 
    260292 
Note: See TracChangeset for help on using the changeset viewer.