Changeset 6140 for trunk/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
- Timestamp:
- 2015-12-21T12:35:23+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMOGCM/NEMO/OPA_SRC/DOM/daymod.F90
r5563 r6140 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 … … 20 21 !! 21 22 !! we suppose that the time step is deviding the number of second of in a day 22 !! ---> MOD( rday, rdt tra(1)) == 023 !! ---> MOD( rday, rdt ) == 0 23 24 !! 24 25 !! ----------- WARNING ----------- … … 26 27 !! 27 28 !!---------------------------------------------------------------------- 28 USE dom_oce 29 USE phycst 30 USE in_out_manager 31 USE iom 32 USE ioipsl , ONLY : ymds2ju ! for calendar33 USE prtctl 34 USE trc_oce , ONLY : lk_offline ! offline flag35 USE timing 36 USE restart 29 USE dom_oce ! ocean space and time domain 30 USE phycst ! physical constants 31 USE in_out_manager ! I/O manager 32 USE iom ! 33 USE ioipsl , ONLY : ymds2ju ! for calendar 34 USE prtctl ! Print control 35 USE trc_oce , ONLY : lk_offline ! offline flag 36 USE timing ! Timing 37 USE restart ! restart 37 38 38 39 IMPLICIT NONE … … 43 44 PUBLIC day_mth ! Needed by TAM 44 45 45 INTEGER, PUBLIC :: nsecd, nsecd05, ndt, ndt05 !(PUBLIC for TAM)46 INTEGER, PUBLIC :: nsecd, nsecd05, ndt, ndt05 !: (PUBLIC for TAM) 46 47 47 48 !!---------------------------------------------------------------------- … … 78 79 & 'You must do a restart at higher frequency (or remove this stop and recompile the code in I8)' ) 79 80 ENDIF 80 ! all calendar staff is based on the fact that MOD( rday, rdt tra(1)) == 081 IF( MOD( rday , rdt tra(1)) /= 0. ) CALL ctl_stop( 'the time step must devide the number of second of in a day' )82 IF( MOD( rday , 2. 83 IF( MOD( rdt tra(1), 2.) /= 0. ) CALL ctl_stop( 'the time step (in second) must be an even number' )84 nsecd = NINT(rday 85 nsecd05 = NINT(0.5 * rday 86 ndt = NINT( rdt tra(1))87 ndt05 = NINT(0.5 * rdt tra(1))81 ! all calendar staff is based on the fact that MOD( rday, rdt ) == 0 82 IF( MOD( rday , rdt ) /= 0. ) CALL ctl_stop( 'the time step must devide the number of second of in a day' ) 83 IF( MOD( rday , 2. ) /= 0. ) CALL ctl_stop( 'the number of second of in a day must be an even number' ) 84 IF( MOD( rdt , 2. ) /= 0. ) CALL ctl_stop( 'the time step (in second) must be an even number' ) 85 nsecd = NINT(rday ) 86 nsecd05 = NINT(0.5 * rday ) 87 ndt = NINT( rdt ) 88 ndt05 = NINT(0.5 * rdt ) 88 89 89 90 IF( .NOT. lk_offline ) CALL day_rst( nit000, 'READ' ) … … 95 96 nday = ndastp - (nyear * 10000) - ( nmonth * 100 ) 96 97 97 CALL ymds2ju( nyear, nmonth, nday, 0.0, fjulday ) ! we assume that we start run at 00:00 98 nhour = nn_time0 / 100 99 nminute = ( nn_time0 - nhour * 100 ) 100 101 CALL ymds2ju( nyear, nmonth, nday, nhour*3600._wp+nminute*60._wp, fjulday ) 98 102 IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < 0.1 / rday ) fjulday = REAL(NINT(fjulday),wp) ! avoid truncation error 99 fjulday = fjulday + 1.! move back to the day at nit000 (and not at nit000 - 1)103 IF( nn_time0*3600 - ndt05 .lt. 0 ) fjulday = fjulday + 1. ! move back to the day at nit000 (and not at nit000 - 1) 100 104 101 105 nsec1jan000 = 0 … … 118 122 !compute number of days between last monday and today 119 123 CALL ymds2ju( 1900, 01, 01, 0.0, zjul ) ! compute julian day value of 01.01.1900 (our reference that was a Monday) 120 inbday = NINT(fjulday - zjul) ! compute nb day between 01.01.1900 andcurrent day124 inbday = FLOOR(fjulday - zjul) ! compute nb day between 01.01.1900 and start of current day 121 125 idweek = MOD(inbday, 7) ! compute nb day between last monday and current day 126 IF (idweek .lt. 0) idweek=idweek+7 ! Avoid negative values for dates before 01.01.1900 122 127 123 128 ! number of seconds since the beginning of current year/month/week/day at the middle of the time-step 124 nsec_year = nday_year * nsecd - ndt05 ! 1 time step before the middle of the first time step 125 nsec_month = nday * nsecd - ndt05 ! because day will be called at the beginning of step 126 nsec_week = idweek * nsecd - ndt05 127 nsec_day = nsecd - ndt05 129 IF (nhour*3600+nminute*60-ndt05 .gt. 0) THEN 130 ! 1 timestep before current middle of first time step is still the same day 131 nsec_year = (nday_year-1) * nsecd + nhour*3600+nminute*60 - ndt05 132 nsec_month = (nday-1) * nsecd + nhour*3600+nminute*60 - ndt05 133 ELSE 134 ! 1 time step before the middle of the first time step is the previous day 135 nsec_year = nday_year * nsecd + nhour*3600+nminute*60 - ndt05 136 nsec_month = nday * nsecd + nhour*3600+nminute*60 - ndt05 137 ENDIF 138 nsec_week = idweek * nsecd + nhour*3600+nminute*60 - ndt05 139 nsec_day = nhour*3600+nminute*60 - ndt05 140 IF( nsec_day .lt. 0 ) nsec_day = nsec_day + nsecd 141 IF( nsec_week .lt. 0 ) nsec_week = nsec_week + nsecd*7 128 142 129 143 ! control print 130 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 = ', & 131 & nyear, '/', nmonth, '/', nday, ' nsec_day:', nsec_day, ' nsec_week:', nsec_week 144 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 = ', & 145 & nyear, '/', nmonth, '/', nday, ' nsec_day:', nsec_day, ' nsec_week:', nsec_week, ' & 146 & nsec_month:', nsec_month , ' nsec_year:' , nsec_year 132 147 133 148 ! Up to now, calendar parameters are related to the end of previous run (nit000-1) … … 223 238 nsec_week = nsec_week + ndt 224 239 nsec_day = nsec_day + ndt 225 adatrj = adatrj + rdt tra(1)/ rday226 fjulday = fjulday + rdt tra(1)/ rday240 adatrj = adatrj + rdt / rday 241 fjulday = fjulday + rdt / rday 227 242 IF( ABS(fjulday - REAL(NINT(fjulday),wp)) < zprec ) fjulday = REAL(NINT(fjulday),wp) ! avoid truncation error 228 243 IF( ABS(adatrj - REAL(NINT(adatrj ),wp)) < zprec ) adatrj = REAL(NINT(adatrj ),wp) ! avoid truncation error … … 302 317 CHARACTER(len=*), INTENT(in) :: cdrw ! "READ"/"WRITE" flag 303 318 ! 304 REAL(wp) :: zkt, zndastp 319 REAL(wp) :: zkt, zndastp, zdayfrac, ksecs, ktime 320 INTEGER :: ihour, iminute 305 321 !!---------------------------------------------------------------------- 306 322 … … 327 343 ! define ndastp and adatrj 328 344 IF ( nrstdt == 2 ) THEN 329 ! read the parameters correspond ting to nit000 - 1 (last time step of previous run)345 ! read the parameters corresponding to nit000 - 1 (last time step of previous run) 330 346 CALL iom_get( numror, 'ndastp', zndastp ) 331 347 ndastp = NINT( zndastp ) 332 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 333 373 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 336 adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 374 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 375 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam 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) 379 adatrj = ( REAL( nit000-1, wp ) * rdt ) / rday 337 380 ! note this is wrong if time step has changed during run 338 381 ENDIF 339 382 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 342 adatrj = ( REAL( nit000-1, wp ) * rdttra(1) ) / rday 383 ! parameters corresponding to nit000 - 1 (as we start the step loop with a call to day) 384 ndastp = ndate0 ! ndate0 read in the namelist in dom_nam 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) 388 adatrj = ( REAL( nit000-1, wp ) * rdt ) / rday 343 389 ENDIF 344 390 IF( ABS(adatrj - REAL(NINT(adatrj),wp)) < 0.1 / rday ) adatrj = REAL(NINT(adatrj),wp) ! avoid truncation error … … 348 394 WRITE(numout,*) ' date ndastp : ', ndastp 349 395 WRITE(numout,*) ' number of elapsed days since the begining of run : ', adatrj 396 WRITE(numout,*) ' nn_time0 : ',nn_time0 350 397 WRITE(numout,*) 351 398 ENDIF … … 363 410 CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj ) ! number of elapsed days since 364 411 ! ! the begining of the run [s] 412 CALL iom_rstput( kt, nitrst, numrow, 'ntime' , REAL( nn_time0, wp) ) ! time 365 413 ENDIF 366 414 !
Note: See TracChangeset
for help on using the changeset viewer.