- Timestamp:
- 2021-09-14T13:37:21+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UKMO/dev_r5518_obs_oper_update/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
r7960 r15254 73 73 !!---------------------------------------------------------------------- 74 74 ! 75 ! max number of seconds between each restart 76 IF( REAL( nitend - nit000 + 1 ) * rdt > REAL( HUGE( nsec1jan000 ) ) ) THEN 77 CALL ctl_stop( 'The number of seconds between each restart exceeds the integer 4 max value: 2^31-1. ', & 78 & 'You must do a restart at higher frequency (or remove this stop and recompile the code in I8)' ) 79 ENDIF 75 80 ! all calendar staff is based on the fact that MOD( rday, rdttra(1) ) == 0 76 81 IF( MOD( rday , rdttra(1) ) /= 0. ) CALL ctl_stop( 'the time step must devide the number of second of in a day' ) … … 90 95 nday = ndastp - (nyear * 10000) - ( nmonth * 100 ) 91 96 92 CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday ) ! we assume that we start run at 00:00 97 nhour = nn_time0 / 100 98 nminute = ( nn_time0 - nhour * 100 ) 99 100 CALL ymds2ju( nyear, nmonth, nday, nhour*3600._wp+nminute*60._wp, fjulday ) 93 101 IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday ) fjulday = REAL(NINT(fjulday),wp) ! avoid truncation error 94 fjulday = fjulday + 1.! move back to the day at nit000 (and not at nit000 - 1)102 IF(nhour*3600 + nminute*60 - ndt05 .lt. 0) fjulday = fjulday + 1. ! move back to the day at nit000 (and not at nit000 - 1) 95 103 96 104 nsec1jan000 = 0 … … 113 121 !compute number of days between last monday and today 114 122 CALL ymds2ju( 1900, 01, 01, 0.0, zjul ) ! compute julian day value of 01.01.1900 (our reference that was a Monday) 115 inbday = NINT(fjulday - zjul) ! compute nb day between 01.01.1900 andcurrent day123 inbday = FLOOR(fjulday - zjul) ! compute nb day between 01.01.1900 and start of current day 116 124 idweek = MOD(inbday, 7) ! compute nb day between last monday and current day 125 IF (idweek .lt. 0) idweek=idweek+7 ! Avoid negative values for dates before 01.01.1900 117 126 118 127 ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step 119 nsec_year = nday_year * nsecd - ndt05 ! 1 time step before the middle of the first time step 120 nsec_month = nday * nsecd - ndt05 ! because day will be called at the beginning of step 121 nsec_week = idweek * nsecd - ndt05 122 nsec_day = nsecd - ndt05 128 IF (nhour*3600+nminute*60-ndt05 .gt. 0) THEN 129 ! 1 timestep before current middle of first time step is still the same day 130 nsec_year = (nday_year-1) * nsecd + nhour*3600+nminute*60 - ndt05 131 nsec_month = (nday-1) * nsecd + nhour*3600+nminute*60 - ndt05 132 ELSE 133 ! 1 time step before the middle of the first time step is the previous day 134 nsec_year = nday_year * nsecd + nhour*3600+nminute*60 - ndt05 135 nsec_month = nday * nsecd + nhour*3600+nminute*60 - ndt05 136 ENDIF 137 nsec_week = idweek * nsecd + nhour*3600+nminute*60 - ndt05 138 nsec_day = nhour*3600+nminute*60 - ndt05 139 IF( nsec_day .lt. 0 ) nsec_day = nsec_day + nsecd 140 IF( nsec_week .lt. 0 ) nsec_week = nsec_week + nsecd*7 123 141 124 142 ! control print 125 IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i8,a,i8)')' =======>> 1/2 time step before the start of the run DATE Y/M/D = ', & 126 & nyear, '/', nmonth, '/', nday, ' nsec_day:', nsec_day, ' nsec_week:', nsec_week 143 IF(lwp) WRITE(numout,'(a,i6,a,i2,a,i2,a,i8,a,i8,a,i8,a,i8)')' =======>> 1/2 time step before the start of the run DATE Y/M/D = ', & 144 & nyear, '/', nmonth, '/', nday, ' nsec_day:', nsec_day, ' nsec_week:', nsec_week, ' & 145 & nsec_month:', nsec_month , ' nsec_year:' , nsec_year 127 146 128 147 ! Up to now, calendar parameters are related to the end of previous run (nit000-1) … … 238 257 nday_year = 1 239 258 nsec_year = ndt05 240 IF( nsec1jan000 >= 2 * (2**30 - nsecd * nyear_len(1) / 2 ) ) THEN ! test integer 4 max value241 CALL ctl_stop( 'The number of seconds between Jan. 1st 00h of nit000 year and Jan. 1st 00h ', &242 & 'of the current year is exceeding the INTEGER 4 max VALUE: 2^31-1 -> 68.09 years in seconds', &243 & 'You must do a restart at higher frequency (or remove this STOP and recompile everything in I8)' )244 ENDIF245 259 nsec1jan000 = nsec1jan000 + nsecd * nyear_len(1) 246 260 IF( nleapy == 1 ) CALL day_mth … … 302 316 CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag 303 317 ! 304 REAL(wp) :: zkt, zndastp 318 REAL(wp) :: zkt, zndastp, zdayfrac, ksecs, ktime 319 INTEGER :: ihour, iminute 305 320 !!---------------------------------------------------------------------- 306 321 … … 309 324 IF( iom_varid( numror, 'kt', ldstop = .FALSE. ) > 0 ) THEN 310 325 ! Get Calendar informations 326 IF(nn_timing == 2) CALL timing_start('iom_rstget') 311 327 CALL iom_get( numror, 'kt', zkt ) ! last time-step of previous run 328 IF(nn_timing == 2) CALL timing_stop('iom_rstget') 312 329 IF(lwp) THEN 313 330 WRITE(numout,*) ' *** Info read in restart : ' … … 327 344 ! define ndastp and adatrj 328 345 IF ( nrstdt == 2 ) THEN 346 IF(nn_timing == 2) CALL timing_start('iom_rstget') 329 347 ! read the parameters correspondting to nit000 - 1 (last time step of previous run) 330 348 CALL iom_get( numror, 'ndastp', zndastp ) 331 349 ndastp = NINT( zndastp ) 332 350 CALL iom_get( numror, 'adatrj', adatrj ) 351 CALL iom_get( numror, 'ntime', ktime ) 352 IF(nn_timing == 2) CALL timing_stop('iom_rstget') 353 nn_time0=INT(ktime) 354 ! calculate start time in hours and minutes 355 zdayfrac=adatrj-INT(adatrj) 356 ksecs = NINT(zdayfrac*86400) ! Nearest second to catch rounding errors in adatrj 357 ihour = INT(ksecs/3600) 358 iminute = ksecs/60-ihour*60 359 360 ! Add to nn_time0 361 nhour = nn_time0 / 100 362 nminute = ( nn_time0 - nhour * 100 ) 363 nminute=nminute+iminute 364 365 IF( nminute >= 60 ) THEN 366 nminute=nminute-60 367 nhour=nhour+1 368 ENDIF 369 nhour=nhour+ihour 370 IF( nhour >= 24 ) THEN 371 nhour=nhour-24 372 adatrj=adatrj+1 373 ENDIF 374 nn_time0 = nhour * 100 + nminute 375 adatrj = INT(adatrj) ! adatrj set to integer as nn_time0 updated 333 376 ELSE 334 ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day) 335 ndastp = ndate0 - 1 ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00 377 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 378 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam 379 nhour = nn_time0 / 100 380 nminute = ( nn_time0 - nhour * 100 ) 381 IF( nhour*3600+nminute*60-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0) 336 382 adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 337 383 ! note this is wrong if time step has changed during run 338 384 ENDIF 339 385 ELSE 340 ! parameters correspondting to nit000 - 1 (as we start the step loop with a call to day) 341 ndastp = ndate0 - 1 ! ndate0 read in the namelist in dom_nam, we assume that we start run at 00:00 386 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 387 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam 388 nhour = nn_time0 / 100 389 nminute = ( nn_time0 - nhour * 100 ) 390 IF( nhour*3600+nminute*60-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0) 342 391 adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 343 392 ENDIF … … 348 397 WRITE(numout,*) ' date ndastp : ', ndastp 349 398 WRITE(numout,*) ' number of elapsed days since the begining of run : ', adatrj 399 WRITE(numout,*) ' nn_time0 : ',nn_time0 350 400 WRITE(numout,*) 351 401 ENDIF … … 359 409 ENDIF 360 410 ! calendar control 411 IF(nn_timing == 2) CALL timing_start('iom_rstput') 361 412 CALL iom_rstput( kt, nitrst, numrow, 'kt' , REAL( kt , wp) ) ! time-step 362 413 CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp) ) ! date 363 414 CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj ) ! number of elapsed days since 364 415 ! ! the begining of the run [s] 416 CALL iom_rstput( kt, nitrst, numrow, 'ntime' , REAL( nn_time0, wp) ) ! time 417 IF(nn_timing == 2) CALL timing_stop('iom_rstput') 365 418 ENDIF 366 419 !
Note: See TracChangeset
for help on using the changeset viewer.