- Timestamp:
- 2015-11-09T19:20:54+01:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2014/dev_r4650_UKMO7_STARTHOUR/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
r5164 r5872 11 11 !! ! 2004-01 (A.M. Treguier) new calculation based on adatrj 12 12 !! ! 2006-08 (G. Madec) surface module major update 13 !! ! 2015-11 (D. Lea) Allow non-zero initial time of day 13 14 !!---------------------------------------------------------------------- 14 15 … … 90 91 nday = ndastp - (nyear * 10000) - ( nmonth * 100 ) 91 92 92 CALL ymds2ju( nyear, nmonth, nday, nn_time0*3600._wp, fjulday ) 93 nhour = nn_time0 / 100 94 nminute = ( nn_time0 - nhour * 100 ) 95 96 CALL ymds2ju( nyear, nmonth, nday, nhour*3600._wp+nminute*60._wp, fjulday ) 93 97 IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday ) fjulday = REAL(NINT(fjulday),wp) ! avoid truncation error 94 98 IF( nn_time0*3600 - ndt05 .lt. 0 ) fjulday = fjulday + 1. ! move back to the day at nit000 (and not at nit000 - 1) … … 118 122 119 123 ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step 120 IF (n n_time0*3600-ndt05 .gt. 0) THEN124 IF (nhour*3600+nminute*60-ndt05 .gt. 0) THEN 121 125 ! 1 timestep before current middle of first time step is still the same day 122 nsec_year = (nday_year-1) * nsecd + n n_time0*3600._wp- ndt05123 nsec_month = (nday-1) * nsecd + n n_time0*3600._wp- ndt05126 nsec_year = (nday_year-1) * nsecd + nhour*3600+nminute*60 - ndt05 127 nsec_month = (nday-1) * nsecd + nhour*3600+nminute*60 - ndt05 124 128 ELSE 125 129 ! 1 time step before the middle of the first time step is the previous day 126 nsec_year = nday_year * nsecd + n n_time0*3600._wp- ndt05127 nsec_month = nday * nsecd + n n_time0*3600._wp- ndt05128 ENDIF 129 nsec_week = idweek * nsecd + n n_time0*3600._wp- ndt05130 nsec_day = n n_time0*3600._wp- ndt05130 nsec_year = nday_year * nsecd + nhour*3600+nminute*60 - ndt05 131 nsec_month = nday * nsecd + nhour*3600+nminute*60 - ndt05 132 ENDIF 133 nsec_week = idweek * nsecd + nhour*3600+nminute*60 - ndt05 134 nsec_day = nhour*3600+nminute*60 - ndt05 131 135 IF( nsec_day .lt. 0 ) nsec_day = nsec_day + nsecd 132 136 IF( nsec_week .lt. 0 ) nsec_week = nsec_week + nsecd*7 … … 313 317 CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag 314 318 ! 315 REAL(wp) :: zkt, zndastp 319 REAL(wp) :: zkt, zndastp, zdayfrac, ksecs, ktime 320 INTEGER :: ihour, iminute 316 321 !!---------------------------------------------------------------------- 317 322 … … 342 347 ndastp = NINT( zndastp ) 343 348 CALL iom_get( numror, 'adatrj', adatrj ) 349 CALL iom_get( numror, 'ntime', ktime ) 350 nn_time0=INT(ktime) 351 ! calculate start time in hours and minutes 352 zdayfrac=adatrj-INT(adatrj) 353 ksecs = NINT(zdayfrac*86400) ! Nearest second to catch rounding errors in adatrj 354 ihour = INT(ksecs/3600) 355 iminute = ksecs/60-ihour*60 356 357 ! Add to nn_time0 358 nhour = nn_time0 / 100 359 nminute = ( nn_time0 - nhour * 100 ) 360 nminute=nminute+iminute 361 362 IF( nminute >= 60 ) THEN 363 nminute=nminute-60 364 nhour=nhour+1 365 ENDIF 366 nhour=nhour+ihour 367 IF( nhour >= 24 ) THEN 368 nhour=nhour-24 369 adatrj=adatrj+1 370 ENDIF 371 nn_time0 = nhour * 100 + nminute 372 adatrj = INT(adatrj) ! adatrj set to integer as nn_time0 updated 344 373 ELSE 345 374 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 346 375 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam 347 IF( nn_time0*3600-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0) 376 nhour = nn_time0 / 100 377 nminute = ( nn_time0 - nhour * 100 ) 378 IF( nhour*3600+nminute*60-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0) 348 379 adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 349 380 ! note this is wrong if time step has changed during run … … 352 383 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 353 384 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam 354 IF( nn_time0*3600-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0) 385 nhour = nn_time0 / 100 386 nminute = ( nn_time0 - nhour * 100 ) 387 IF( nhour*3600+nminute*60-ndt05 .lt. 0 ) ndastp=ndastp-1 ! Start hour is specified in the namelist (default 0) 355 388 adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 356 389 ENDIF … … 361 394 WRITE(numout,*) ' date ndastp : ', ndastp 362 395 WRITE(numout,*) ' number of elapsed days since the begining of run : ', adatrj 396 WRITE(numout,*) ' nn_time0 : ',nn_time0 363 397 WRITE(numout,*) 364 398 ENDIF … … 376 410 CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj ) ! number of elapsed days since 377 411 ! ! the begining of the run [s] 412 CALL iom_rstput( kt, nitrst, numrow, 'ntime' , REAL( nn_time0, wp) ) ! time 378 413 ENDIF 379 414 !
Note: See TracChangeset
for help on using the changeset viewer.