PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/wrfv2_fire/share/set_timekeeping.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 622 lines | 275 code | 44 blank | 303 comment | 0 complexity | f65d7b8391b971af6329c5999ce46dd6 MD5 | raw file
Possible License(s): AGPL-1.0
  1. SUBROUTINE Setup_Timekeeping ( grid )
  2. USE module_domain
  3. USE module_configure
  4. USE module_utility
  5. IMPLICIT NONE
  6. TYPE(domain), POINTER :: grid
  7. ! Local
  8. TYPE(WRFU_TimeInterval) :: begin_time, end_time, zero_time, one_minute, one_hour, forever, padding_interval
  9. TYPE(WRFU_TimeInterval) :: interval, run_length, dfl_length
  10. TYPE(WRFU_Time) :: startTime, stopTime, initialTime
  11. TYPE(WRFU_TimeInterval) :: stepTime
  12. TYPE(WRFU_TimeInterval) :: tmp_step
  13. INTEGER :: start_year,start_month,start_day,start_hour,start_minute,start_second
  14. INTEGER :: end_year,end_month,end_day,end_hour,end_minute,end_second
  15. INTEGER :: vortex_interval
  16. #ifdef HWRF
  17. !zhang's doing
  18. real (kind=8) :: day_in_sec
  19. REAL :: tstart
  20. !end of zhang's doing
  21. #endif
  22. ! #if (EM_CORE == 1)
  23. INTEGER :: dfi_fwdstop_year,dfi_fwdstop_month,dfi_fwdstop_day,dfi_fwdstop_hour,dfi_fwdstop_minute,dfi_fwdstop_second
  24. INTEGER :: dfi_bckstop_year,dfi_bckstop_month,dfi_bckstop_day,dfi_bckstop_hour,dfi_bckstop_minute,dfi_bckstop_second
  25. ! #endif
  26. INTEGER :: restart_interval_d
  27. INTEGER :: inputout_interval_d
  28. INTEGER :: inputout_begin_y
  29. INTEGER :: inputout_end_y
  30. INTEGER :: inputout_begin_m
  31. INTEGER :: inputout_begin_s
  32. INTEGER :: inputout_begin_d
  33. INTEGER :: inputout_begin_h
  34. INTEGER :: inputout_end_m
  35. INTEGER :: inputout_end_s
  36. INTEGER :: inputout_end_d
  37. INTEGER :: inputout_end_h
  38. INTEGER :: restart_interval_m
  39. INTEGER :: restart_interval_s
  40. INTEGER :: restart_interval
  41. INTEGER :: restart_interval_h
  42. INTEGER :: inputout_interval_m
  43. INTEGER :: inputout_interval_s
  44. INTEGER :: inputout_interval
  45. INTEGER :: inputout_interval_h
  46. # include "set_timekeeping_defs.inc"
  47. INTEGER :: grid_fdda, grid_sfdda
  48. INTEGER :: run_days, run_hours, run_minutes, run_seconds
  49. INTEGER :: time_step, time_step_fract_num, time_step_fract_den
  50. INTEGER :: rc
  51. REAL :: dt
  52. CALL WRFU_TimeIntervalSet ( zero_time, rc=rc )
  53. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  54. 'WRFU_TimeIntervalSet(zero_time) FAILED', &
  55. __FILE__ , &
  56. __LINE__ )
  57. CALL WRFU_TimeIntervalSet ( one_minute, M=1, rc=rc )
  58. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  59. 'WRFU_TimeIntervalSet(one_minute) FAILED', &
  60. __FILE__ , &
  61. __LINE__ )
  62. CALL WRFU_TimeIntervalSet ( one_hour, H=1, rc=rc )
  63. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  64. 'WRFU_TimeIntervalSet(one_hour) FAILED', &
  65. __FILE__ , &
  66. __LINE__ )
  67. CALL WRFU_TimeIntervalSet ( forever, S=1700000000, rc=rc ) ! magic number; indicats an interval that is forever
  68. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  69. 'WRFU_TimeIntervalSet(forever) FAILED', &
  70. __FILE__ , &
  71. __LINE__ )
  72. ! #if (EM_CORE == 1)
  73. IF ( (grid%dfi_opt .EQ. DFI_NODFI) .OR. (grid%dfi_stage .EQ. DFI_SETUP) ) THEN
  74. ! #endif
  75. CALL nl_get_start_year(grid%id,start_year)
  76. CALL nl_get_start_month(grid%id,start_month)
  77. CALL nl_get_start_day(grid%id,start_day)
  78. CALL nl_get_start_hour(grid%id,start_hour)
  79. CALL nl_get_start_minute(grid%id,start_minute)
  80. CALL nl_get_start_second(grid%id,start_second)
  81. #ifdef HWRF
  82. !zhang's doing - check with zhan before adding this bit
  83. ! CALL nl_get_tstart ( grid%id , tstart )
  84. ! CALL jdn_sec(day_in_sec,start_year,start_month,start_day,start_hour,start_minute,start_second)
  85. ! day_in_sec = day_in_sec + tstart*3600.
  86. ! CALL jdn_ymd_hms(day_in_sec,start_year,start_month,start_day,start_hour,start_minute,start_second)
  87. !end of zhang's doing
  88. #endif
  89. CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, &
  90. H=start_hour, M=start_minute, S=start_second,&
  91. rc=rc)
  92. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  93. 'WRFU_TimeSet(startTime) FAILED', &
  94. __FILE__ , &
  95. __LINE__ )
  96. ! #if (EM_CORE == 1)
  97. ELSE
  98. IF ( grid%dfi_opt .EQ. DFI_DFL ) THEN
  99. IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN
  100. CALL nl_get_start_year(grid%id,start_year)
  101. CALL nl_get_start_month(grid%id,start_month)
  102. CALL nl_get_start_day(grid%id,start_day)
  103. CALL nl_get_start_hour(grid%id,start_hour)
  104. CALL nl_get_start_minute(grid%id,start_minute)
  105. CALL nl_get_start_second(grid%id,start_second)
  106. ELSE IF ( grid%dfi_stage .EQ. DFI_FST ) THEN
  107. CALL nl_get_start_year(grid%id,start_year)
  108. CALL nl_get_start_month(grid%id,start_month)
  109. CALL nl_get_start_day(grid%id,start_day)
  110. CALL nl_get_start_hour(grid%id,start_hour)
  111. CALL nl_get_start_minute(grid%id,start_minute)
  112. CALL nl_get_start_second(grid%id,start_second)
  113. run_length = grid%stop_subtime - grid%start_subtime
  114. CALL WRFU_TimeIntervalGet( run_length, S=run_seconds, rc=rc )
  115. ! What about fractional seconds?
  116. run_seconds = run_seconds / 2
  117. CALL WRFU_TimeIntervalSet ( run_length, S=run_seconds, rc=rc )
  118. CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, &
  119. H=start_hour, M=start_minute, S=start_second,&
  120. rc=rc)
  121. startTime = startTime + run_length
  122. CALL WRFU_TimeGet(startTime, YY=start_year, MM=start_month, DD=start_day, &
  123. H=start_hour, M=start_minute, S=start_second,&
  124. rc=rc)
  125. END IF
  126. ELSE IF ( grid%dfi_opt .EQ. DFI_DDFI ) THEN
  127. IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN
  128. CALL nl_get_dfi_bckstop_year(grid%id,start_year)
  129. CALL nl_get_dfi_bckstop_month(grid%id,start_month)
  130. CALL nl_get_dfi_bckstop_day(grid%id,start_day)
  131. CALL nl_get_dfi_bckstop_hour(grid%id,start_hour)
  132. CALL nl_get_dfi_bckstop_minute(grid%id,start_minute)
  133. CALL nl_get_dfi_bckstop_second(grid%id,start_second)
  134. ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN
  135. CALL nl_get_start_year(grid%id,start_year)
  136. CALL nl_get_start_month(grid%id,start_month)
  137. CALL nl_get_start_day(grid%id,start_day)
  138. CALL nl_get_start_hour(grid%id,start_hour)
  139. CALL nl_get_start_minute(grid%id,start_minute)
  140. CALL nl_get_start_second(grid%id,start_second)
  141. ELSE IF ( grid%dfi_stage .EQ. DFI_FST ) THEN
  142. CALL nl_get_start_year(grid%id,start_year)
  143. CALL nl_get_start_month(grid%id,start_month)
  144. CALL nl_get_start_day(grid%id,start_day)
  145. CALL nl_get_start_hour(grid%id,start_hour)
  146. CALL nl_get_start_minute(grid%id,start_minute)
  147. CALL nl_get_start_second(grid%id,start_second)
  148. END IF
  149. ELSE IF ( grid%dfi_opt .EQ. DFI_TDFI ) THEN
  150. IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN
  151. CALL nl_get_dfi_bckstop_year(grid%id,start_year)
  152. CALL nl_get_dfi_bckstop_month(grid%id,start_month)
  153. CALL nl_get_dfi_bckstop_day(grid%id,start_day)
  154. CALL nl_get_dfi_bckstop_hour(grid%id,start_hour)
  155. CALL nl_get_dfi_bckstop_minute(grid%id,start_minute)
  156. CALL nl_get_dfi_bckstop_second(grid%id,start_second)
  157. ! Here, we look at head_grid to determine run_length.
  158. ! Since start_subtime and stop_subtime were
  159. ! updated for nesting, they no longer bound the dfi
  160. ! time window, so, start_subtime and stop_subtime from
  161. ! from the grid structure won't work. However, we can use
  162. ! head_grid since the dfi time window is the same for all
  163. ! domains.
  164. run_length = head_grid%start_subtime - head_grid%stop_subtime
  165. CALL WRFU_TimeIntervalGet( run_length, S=run_seconds, rc=rc )
  166. ! What about fractional seconds?
  167. run_seconds = run_seconds / 2
  168. CALL WRFU_TimeIntervalSet ( run_length, S=run_seconds, rc=rc )
  169. CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, &
  170. H=start_hour, M=start_minute, S=start_second,&
  171. rc=rc)
  172. startTime = startTime + run_length
  173. CALL WRFU_TimeGet(startTime, YY=start_year, MM=start_month, DD=start_day, &
  174. H=start_hour, M=start_minute, S=start_second,&
  175. rc=rc)
  176. ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN
  177. CALL nl_get_start_year(grid%id,start_year)
  178. CALL nl_get_start_month(grid%id,start_month)
  179. CALL nl_get_start_day(grid%id,start_day)
  180. CALL nl_get_start_hour(grid%id,start_hour)
  181. CALL nl_get_start_minute(grid%id,start_minute)
  182. CALL nl_get_start_second(grid%id,start_second)
  183. ELSE IF ( grid%dfi_stage .EQ. DFI_FST ) THEN
  184. CALL nl_get_start_year(grid%id,start_year)
  185. CALL nl_get_start_month(grid%id,start_month)
  186. CALL nl_get_start_day(grid%id,start_day)
  187. CALL nl_get_start_hour(grid%id,start_hour)
  188. CALL nl_get_start_minute(grid%id,start_minute)
  189. CALL nl_get_start_second(grid%id,start_second)
  190. ELSE IF ( grid%dfi_stage .EQ. DFI_STARTFWD ) THEN
  191. CALL nl_get_start_year(grid%id,start_year)
  192. CALL nl_get_start_month(grid%id,start_month)
  193. CALL nl_get_start_day(grid%id,start_day)
  194. CALL nl_get_start_hour(grid%id,start_hour)
  195. CALL nl_get_start_minute(grid%id,start_minute)
  196. CALL nl_get_start_second(grid%id,start_second)
  197. END IF
  198. END IF
  199. IF ( grid%dfi_stage .EQ. DFI_STARTBCK ) THEN
  200. CALL WRFU_ClockGet( grid%domain_clock, CurrTime=startTime, rc=rc)
  201. ELSE
  202. CALL WRFU_TimeSet(startTime, YY=start_year, MM=start_month, DD=start_day, &
  203. H=start_hour, M=start_minute, S=start_second,&
  204. rc=rc)
  205. ENDIF
  206. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  207. 'WRFU_TimeSet(startTime) FAILED', &
  208. __FILE__ , &
  209. __LINE__ )
  210. END IF
  211. ! #endif
  212. CALL nl_get_run_days(1,run_days)
  213. CALL nl_get_run_hours(1,run_hours)
  214. CALL nl_get_run_minutes(1,run_minutes)
  215. CALL nl_get_run_seconds(1,run_seconds)
  216. ! #if (EM_CORE == 1)
  217. IF ( (grid%dfi_opt .EQ. DFI_NODFI) .OR. (grid%dfi_stage .EQ. DFI_SETUP) .OR. (grid%dfi_stage .EQ. DFI_FST)) THEN
  218. ! #endif
  219. IF ( grid%id .EQ. head_grid%id .AND. &
  220. ( run_days .gt. 0 .or. run_hours .gt. 0 .or. run_minutes .gt. 0 .or. run_seconds .gt. 0 )) THEN
  221. CALL WRFU_TimeIntervalSet ( run_length , D=run_days, H=run_hours, M=run_minutes, S=run_seconds, rc=rc )
  222. ! #if (EM_CORE == 1)
  223. IF ( grid%dfi_stage .EQ. DFI_FST .AND. grid%dfi_opt .EQ. DFI_DFL ) THEN
  224. CALL nl_get_start_year(grid%id,start_year)
  225. CALL nl_get_start_month(grid%id,start_month)
  226. CALL nl_get_start_day(grid%id,start_day)
  227. CALL nl_get_start_hour(grid%id,start_hour)
  228. CALL nl_get_start_minute(grid%id,start_minute)
  229. CALL nl_get_start_second(grid%id,start_second)
  230. CALL WRFU_TimeSet(initialTime, YY=start_year, MM=start_month, DD=start_day, &
  231. H=start_hour, M=start_minute, S=start_second,&
  232. rc=rc)
  233. dfl_length = startTime - initialTime
  234. run_length = run_length - dfl_length
  235. END IF
  236. ! #endif
  237. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  238. 'WRFU_TimeIntervalSet(run_length) FAILED', &
  239. __FILE__ , &
  240. __LINE__ )
  241. stopTime = startTime + run_length
  242. ELSE
  243. CALL nl_get_end_year(grid%id,end_year)
  244. CALL nl_get_end_month(grid%id,end_month)
  245. CALL nl_get_end_day(grid%id,end_day)
  246. CALL nl_get_end_hour(grid%id,end_hour)
  247. CALL nl_get_end_minute(grid%id,end_minute)
  248. CALL nl_get_end_second(grid%id,end_second)
  249. CALL WRFU_TimeSet(stopTime, YY=end_year, MM=end_month, DD=end_day, &
  250. H=end_hour, M=end_minute, S=end_second,&
  251. rc=rc )
  252. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  253. 'WRFU_TimeSet(stopTime) FAILED', &
  254. __FILE__ , &
  255. __LINE__ )
  256. run_length = stopTime - startTime
  257. ENDIF
  258. ! #if (EM_CORE == 1)
  259. ELSE IF ( grid%dfi_stage .EQ. DFI_STARTFWD ) THEN
  260. CALL nl_get_time_step ( 1, time_step )
  261. CALL nl_get_time_step_fract_num( 1, time_step_fract_num )
  262. CALL nl_get_time_step_fract_den( 1, time_step_fract_den )
  263. CALL WRFU_TimeIntervalSet( run_length, S=time_step, Sn=time_step_fract_num, Sd=time_step_fract_den, rc=rc)
  264. stopTime = startTime + run_length
  265. ELSE IF ( grid%dfi_stage .EQ. DFI_STARTBCK ) THEN
  266. CALL nl_get_time_step ( 1, time_step )
  267. CALL nl_get_time_step_fract_num( 1, time_step_fract_num )
  268. CALL nl_get_time_step_fract_den( 1, time_step_fract_den )
  269. CALL WRFU_TimeIntervalSet( run_length, S=time_step, Sn=time_step_fract_num, Sd=time_step_fract_den, rc=rc)
  270. stopTime = startTime + run_length
  271. ELSE
  272. IF ( grid%dfi_opt .EQ. DFI_DFL ) THEN
  273. IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN
  274. CALL nl_get_dfi_fwdstop_year(grid%id,end_year)
  275. CALL nl_get_dfi_fwdstop_month(grid%id,end_month)
  276. CALL nl_get_dfi_fwdstop_day(grid%id,end_day)
  277. CALL nl_get_dfi_fwdstop_hour(grid%id,end_hour)
  278. CALL nl_get_dfi_fwdstop_minute(grid%id,end_minute)
  279. CALL nl_get_dfi_fwdstop_second(grid%id,end_second)
  280. END IF
  281. ELSE IF ( grid%dfi_opt .EQ. DFI_DDFI ) THEN
  282. IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN
  283. CALL nl_get_dfi_fwdstop_year(grid%id,end_year)
  284. CALL nl_get_dfi_fwdstop_month(grid%id,end_month)
  285. CALL nl_get_dfi_fwdstop_day(grid%id,end_day)
  286. CALL nl_get_dfi_fwdstop_hour(grid%id,end_hour)
  287. CALL nl_get_dfi_fwdstop_minute(grid%id,end_minute)
  288. CALL nl_get_dfi_fwdstop_second(grid%id,end_second)
  289. ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN
  290. CALL nl_get_dfi_bckstop_year(grid%id,end_year)
  291. CALL nl_get_dfi_bckstop_month(grid%id,end_month)
  292. CALL nl_get_dfi_bckstop_day(grid%id,end_day)
  293. CALL nl_get_dfi_bckstop_hour(grid%id,end_hour)
  294. CALL nl_get_dfi_bckstop_minute(grid%id,end_minute)
  295. CALL nl_get_dfi_bckstop_second(grid%id,end_second)
  296. END IF
  297. ELSE IF ( grid%dfi_opt .EQ. DFI_TDFI ) THEN
  298. IF ( grid%dfi_stage .EQ. DFI_FWD ) THEN
  299. CALL nl_get_dfi_fwdstop_year(grid%id,end_year)
  300. CALL nl_get_dfi_fwdstop_month(grid%id,end_month)
  301. CALL nl_get_dfi_fwdstop_day(grid%id,end_day)
  302. CALL nl_get_dfi_fwdstop_hour(grid%id,end_hour)
  303. CALL nl_get_dfi_fwdstop_minute(grid%id,end_minute)
  304. CALL nl_get_dfi_fwdstop_second(grid%id,end_second)
  305. ELSE IF ( grid%dfi_stage .EQ. DFI_BCK ) THEN
  306. CALL nl_get_dfi_bckstop_year(grid%id,end_year)
  307. CALL nl_get_dfi_bckstop_month(grid%id,end_month)
  308. CALL nl_get_dfi_bckstop_day(grid%id,end_day)
  309. CALL nl_get_dfi_bckstop_hour(grid%id,end_hour)
  310. CALL nl_get_dfi_bckstop_minute(grid%id,end_minute)
  311. CALL nl_get_dfi_bckstop_second(grid%id,end_second)
  312. END IF
  313. END IF
  314. CALL WRFU_TimeSet(stopTime, YY=end_year, MM=end_month, DD=end_day, &
  315. H=end_hour, M=end_minute, S=end_second,&
  316. rc=rc)
  317. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  318. 'WRFU_TimeSet(dfistopfwdTime) FAILED', &
  319. __FILE__ , &
  320. __LINE__ )
  321. run_length = stopTime - startTime
  322. END IF
  323. ! #endif
  324. IF ( run_length .GT. zero_time ) THEN
  325. padding_interval = forever
  326. ELSE
  327. padding_interval = zero_time - forever
  328. ENDIF
  329. IF ( grid%id .EQ. head_grid%id ) THEN
  330. CALL nl_get_time_step ( 1, time_step )
  331. CALL nl_get_time_step_fract_num( 1, time_step_fract_num )
  332. CALL nl_get_time_step_fract_den( 1, time_step_fract_den )
  333. dt = real(time_step) + real(time_step_fract_num) / real(time_step_fract_den)
  334. #ifdef PLANET
  335. ! 2004-12-08 ADT notes:
  336. ! We have gotten the timestep from integers in the namelist, and they have just
  337. ! been converted to the timestep, "dt", used by the physics code just above.
  338. ! After this point, the integers are only used to update the clock used for,
  339. ! and we want to leave that on a "24-hour" type schedule, so we don't need to
  340. ! modify those integers. Theoretically they refer to a portion of the planet's
  341. ! solar day. The only thing we have to do is convert the *real* timestep, dt,
  342. ! to useful SI units. This is easily accomplished by multiplying it by the
  343. ! variable P2SI, which was designed for just this purpose. After multiplication,
  344. ! make sure every subsequent part of the model knows what the value is.
  345. dt = dt * P2SI
  346. #endif
  347. CALL nl_set_dt( grid%id, dt )
  348. grid%dt = dt
  349. CALL WRFU_TimeIntervalSet(stepTime, S=time_step, Sn=time_step_fract_num, Sd=time_step_fract_den, rc=rc)
  350. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  351. 'WRFU_TimeIntervalSet(stepTime) FAILED', &
  352. __FILE__ , &
  353. __LINE__ )
  354. ELSE
  355. tmp_step = domain_get_time_step( grid%parents(1)%ptr )
  356. stepTime = domain_get_time_step( grid%parents(1)%ptr ) / &
  357. grid%parent_time_step_ratio
  358. grid%dt = grid%parents(1)%ptr%dt / grid%parent_time_step_ratio
  359. CALL nl_set_dt( grid%id, grid%dt )
  360. ENDIF
  361. ! create grid%domain_clock and associated state
  362. CALL domain_clock_create( grid, TimeStep= stepTime, &
  363. StartTime=startTime, &
  364. StopTime= stopTime )
  365. CALL domain_clockprint ( 150, grid, &
  366. 'DEBUG setup_timekeeping(): clock after creation,' )
  367. ! Set default value for SIMULATION_START_DATE.
  368. ! This is overwritten later in input_wrf(), if needed.
  369. IF ( grid%id .EQ. head_grid%id ) THEN
  370. CALL nl_set_simulation_start_year ( 1 , start_year )
  371. CALL nl_set_simulation_start_month ( 1 , start_month )
  372. CALL nl_set_simulation_start_day ( 1 , start_day )
  373. CALL nl_set_simulation_start_hour ( 1 , start_hour )
  374. CALL nl_set_simulation_start_minute ( 1 , start_minute )
  375. CALL nl_set_simulation_start_second ( 1 , start_second )
  376. ENDIF
  377. #include "set_timekeeping_alarms.inc"
  378. ! RESTART INTERVAL
  379. ! restart_interval is left there (and means minutes) for consistency, but
  380. ! restart_interval_m will take precedence if specified
  381. CALL nl_get_restart_interval( 1, restart_interval ) ! same as minutes
  382. CALL nl_get_restart_interval_d( 1, restart_interval_d )
  383. CALL nl_get_restart_interval_h( 1, restart_interval_h )
  384. CALL nl_get_restart_interval_m( 1, restart_interval_m )
  385. CALL nl_get_restart_interval_s( 1, restart_interval_s )
  386. IF ( restart_interval_m .EQ. 0 ) restart_interval_m = restart_interval
  387. IF ( MAX( restart_interval_d, &
  388. restart_interval_h, restart_interval_m , restart_interval_s ) .GT. 0 ) THEN
  389. CALL WRFU_TimeIntervalSet( interval, D=restart_interval_d, &
  390. H=restart_interval_h, M=restart_interval_m, S=restart_interval_s, rc=rc )
  391. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  392. 'WRFU_TimeIntervalSet(restart_interval) FAILED', &
  393. __FILE__ , &
  394. __LINE__ )
  395. ELSE
  396. interval = padding_interval
  397. ENDIF
  398. CALL domain_alarm_create( grid, RESTART_ALARM, interval )
  399. ! INPUTOUT INTERVAL
  400. CALL nl_get_inputout_interval( grid%id, inputout_interval ) ! same as minutes
  401. CALL nl_get_inputout_interval_d( grid%id, inputout_interval_d )
  402. CALL nl_get_inputout_interval_h( grid%id, inputout_interval_h )
  403. CALL nl_get_inputout_interval_m( grid%id, inputout_interval_m )
  404. CALL nl_get_inputout_interval_s( grid%id, inputout_interval_s )
  405. IF ( inputout_interval_m .EQ. 0 ) inputout_interval_m = inputout_interval
  406. IF ( MAX( inputout_interval_d, &
  407. inputout_interval_h, inputout_interval_m , inputout_interval_s ) .GT. 0 ) THEN
  408. CALL WRFU_TimeIntervalSet( interval, D=inputout_interval_d, &
  409. H=inputout_interval_h, M=inputout_interval_m, S=inputout_interval_s, rc=rc )
  410. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  411. 'WRFU_TimeIntervalSet(inputout_interval) FAILED', &
  412. __FILE__ , &
  413. __LINE__ )
  414. ELSE
  415. interval = padding_interval
  416. ENDIF
  417. CALL nl_get_inputout_begin_y( grid%id, inputout_begin_y )
  418. CALL nl_get_inputout_begin_d( grid%id, inputout_begin_d )
  419. CALL nl_get_inputout_begin_h( grid%id, inputout_begin_h )
  420. CALL nl_get_inputout_begin_m( grid%id, inputout_begin_m )
  421. CALL nl_get_inputout_begin_s( grid%id, inputout_begin_s )
  422. IF ( MAX( inputout_begin_y, inputout_begin_d, &
  423. inputout_begin_h, inputout_begin_m , inputout_begin_s ) .GT. 0 ) THEN
  424. CALL WRFU_TimeIntervalSet( begin_time , D=inputout_begin_d, &
  425. H=inputout_begin_h, M=inputout_begin_m, S=inputout_begin_s, rc=rc )
  426. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  427. 'WRFU_TimeIntervalSet(inputout_begin) FAILED', &
  428. __FILE__ , &
  429. __LINE__ )
  430. ELSE
  431. begin_time = zero_time
  432. ENDIF
  433. CALL nl_get_inputout_end_y( grid%id, inputout_end_y )
  434. CALL nl_get_inputout_end_d( grid%id, inputout_end_d )
  435. CALL nl_get_inputout_end_h( grid%id, inputout_end_h )
  436. CALL nl_get_inputout_end_m( grid%id, inputout_end_m )
  437. CALL nl_get_inputout_end_s( grid%id, inputout_end_s )
  438. IF ( MAX( inputout_end_y, inputout_end_d, &
  439. inputout_end_h, inputout_end_m , inputout_end_s ) .GT. 0 ) THEN
  440. CALL WRFU_TimeIntervalSet( end_time , D=inputout_end_d, &
  441. H=inputout_end_h, M=inputout_end_m, S=inputout_end_s, rc=rc )
  442. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  443. 'WRFU_TimeIntervalSet(inputout_end) FAILED', &
  444. __FILE__ , &
  445. __LINE__ )
  446. ELSE
  447. end_time = padding_interval
  448. ENDIF
  449. CALL domain_alarm_create( grid, INPUTOUT_ALARM, interval, begin_time, end_time )
  450. #ifdef WRF_CHEM
  451. ! AUXINPUT5_ INTERVAL
  452. ! auxinput5_interval is left there (and means minutes) for consistency, but
  453. ! auxinput5_interval_m will take precedence if specified
  454. CALL nl_get_auxinput5_interval( grid%id, auxinput5_interval ) ! same as minutes
  455. CALL nl_get_auxinput5_interval_d( grid%id, auxinput5_interval_d )
  456. CALL nl_get_auxinput5_interval_h( grid%id, auxinput5_interval_h )
  457. CALL nl_get_auxinput5_interval_m( grid%id, auxinput5_interval_m )
  458. CALL nl_get_auxinput5_interval_s( grid%id, auxinput5_interval_s )
  459. IF ( auxinput5_interval_m .EQ. 0 ) auxinput5_interval_m = auxinput5_interval
  460. IF ( MAX( auxinput5_interval_d, &
  461. auxinput5_interval_h, auxinput5_interval_m , auxinput5_interval_s ) .GT. 0 ) THEN
  462. CALL WRFU_TimeIntervalSet( interval, D=auxinput5_interval_d, &
  463. H=auxinput5_interval_h, M=auxinput5_interval_m, S=auxinput5_interval_s, rc=rc )
  464. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  465. 'WRFU_TimeIntervalSet(auxinput5_interval) FAILED', &
  466. __FILE__ , &
  467. __LINE__ )
  468. ELSE
  469. interval = padding_interval
  470. ENDIF
  471. CALL nl_get_auxinput5_begin_y( grid%id, auxinput5_begin_y )
  472. CALL nl_get_auxinput5_begin_d( grid%id, auxinput5_begin_d )
  473. CALL nl_get_auxinput5_begin_h( grid%id, auxinput5_begin_h )
  474. CALL nl_get_auxinput5_begin_m( grid%id, auxinput5_begin_m )
  475. CALL nl_get_auxinput5_begin_s( grid%id, auxinput5_begin_s )
  476. IF ( MAX( auxinput5_begin_y, auxinput5_begin_d, &
  477. auxinput5_begin_h, auxinput5_begin_m , auxinput5_begin_s ) .GT. 0 ) THEN
  478. CALL WRFU_TimeIntervalSet( begin_time , D=auxinput5_begin_d, &
  479. H=auxinput5_begin_h, M=auxinput5_begin_m, S=auxinput5_begin_s, rc=rc )
  480. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  481. 'WRFU_TimeIntervalSet(auxinput5_begin) FAILED', &
  482. __FILE__ , &
  483. __LINE__ )
  484. ELSE
  485. begin_time = zero_time
  486. ENDIF
  487. CALL nl_get_auxinput5_end_y( grid%id, auxinput5_end_y )
  488. CALL nl_get_auxinput5_end_d( grid%id, auxinput5_end_d )
  489. CALL nl_get_auxinput5_end_h( grid%id, auxinput5_end_h )
  490. CALL nl_get_auxinput5_end_m( grid%id, auxinput5_end_m )
  491. CALL nl_get_auxinput5_end_s( grid%id, auxinput5_end_s )
  492. IF ( MAX( auxinput5_end_y, auxinput5_end_d, &
  493. auxinput5_end_h, auxinput5_end_m , auxinput5_end_s ) .GT. 0 ) THEN
  494. CALL WRFU_TimeIntervalSet( end_time , D=auxinput5_end_d, &
  495. H=auxinput5_end_h, M=auxinput5_end_m, S=auxinput5_end_s, rc=rc )
  496. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  497. 'WRFU_TimeIntervalSet(auxinput5_end) FAILED', &
  498. __FILE__ , &
  499. __LINE__ )
  500. ELSE
  501. end_time = padding_interval
  502. ENDIF
  503. CALL domain_alarm_create( grid, AUXINPUT5_ALARM, interval, begin_time, end_time )
  504. !TBH: Should be OK to remove the "#else" section and the code it contains
  505. !TBH: because later code overwrites grid%alarms( AUXINPUT5_ALARM )...
  506. !TBH: In fact, by setting namelist values for auxinput5 correctly, it ought
  507. !TBH: to be possible to get rid of all "#ifdef WRF_CHEM" bits in this file...
  508. CALL WRFU_AlarmEnable( grid%alarms( AUXINPUT5_ALARM ), rc=rc )
  509. CALL WRFU_AlarmRingerOn( grid%alarms( AUXINPUT5_ALARM ), rc=rc )
  510. ! TBH: NOTE: Proper setting of namelist variables for auxinput5 ought to
  511. ! TBH: make this hard-coded bit unnecessary.
  512. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  513. ! add for wrf_chem emiss input
  514. CALL WRFU_AlarmEnable( grid%alarms( AUXINPUT5_ALARM ), rc=rc )
  515. CALL WRFU_AlarmRingerOn( grid%alarms( AUXINPUT5_ALARM ), rc=rc )
  516. ! end for wrf chem emiss input
  517. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  518. #endif
  519. ! without this test, it's possible for the value of the WRF_ALARM_SECS_TIL_NEXT_RING
  520. ! that is written as metadata to a restart file to be garbage for BOUNDARY_ALARM for
  521. ! the nests. Parallel NetCDF does a header check on all the metadata being written
  522. ! from multiple processors and if it differs, it throws up an error. This avoids that.
  523. IF ( grid%id .EQ. 1 ) THEN ! only moad can have specified boundaries
  524. CALL domain_alarm_create( grid, BOUNDARY_ALARM )
  525. CALL WRFU_AlarmEnable( grid%alarms( BOUNDARY_ALARM ), rc=rc )
  526. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  527. 'WRFU_AlarmEnable(BOUNDARY_ALARM) FAILED', &
  528. __FILE__ , &
  529. __LINE__ )
  530. CALL WRFU_AlarmRingerOn( grid%alarms( BOUNDARY_ALARM ), rc=rc )
  531. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  532. 'WRFU_AlarmRingerOn(BOUNDARY_ALARM) FAILED', &
  533. __FILE__ , &
  534. __LINE__ )
  535. ENDIF
  536. ! This is the interval at which the code in time_for_move in share/mediation_integrate.F
  537. ! will recompute the center of the Vortex. Other times, it will use the last position.
  538. !
  539. vortex_interval = 0
  540. #ifdef MOVE_NESTS
  541. CALL nl_get_vortex_interval ( grid%id , vortex_interval )
  542. #endif
  543. CALL WRFU_TimeIntervalSet( interval, M=vortex_interval, rc=rc )
  544. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  545. 'WRFU_TimeIntervalSet(interval) for computing vortex center FAILED', &
  546. __FILE__ , &
  547. __LINE__ )
  548. CALL domain_alarm_create( grid, COMPUTE_VORTEX_CENTER_ALARM, interval )
  549. #ifdef MOVE_NESTS
  550. CALL WRFU_AlarmEnable( grid%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  551. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  552. 'WRFU_AlarmEnable(COMPUTE_VORTEX_CENTER_ALARM) FAILED', &
  553. __FILE__ , &
  554. __LINE__ )
  555. CALL WRFU_AlarmRingerOn( grid%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  556. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  557. 'WRFU_AlarmRingerOn(COMPUTE_VORTEX_CENTER_ALARM) FAILED', &
  558. __FILE__ , &
  559. __LINE__ )
  560. #else
  561. ! Go ahead and let the alarm be defined, but disable it, since we are not using moving nests here.
  562. CALL WRFU_AlarmDisable( grid%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  563. CALL wrf_check_error( WRFU_SUCCESS, rc, &
  564. 'WRFU_AlarmDisable(COMPUTE_VORTEX_CENTER_ALARM) FAILED', &
  565. __FILE__ , &
  566. __LINE__ )
  567. #endif
  568. grid%time_set = .TRUE.
  569. ! Initialize derived time quantities in grid state.
  570. ! These are updated in domain_clockadvance().
  571. CALL domain_clock_get( grid, minutesSinceSimulationStart=grid%xtime )
  572. CALL domain_clock_get( grid, currentDayOfYearReal=grid%julian )
  573. WRITE(wrf_err_message,*) 'setup_timekeeping: set xtime to ',grid%xtime
  574. CALL wrf_debug ( 100, TRIM(wrf_err_message) )
  575. WRITE(wrf_err_message,*) 'setup_timekeeping: set julian to ',grid%julian
  576. CALL wrf_debug ( 100, TRIM(wrf_err_message) )
  577. CALL wrf_debug ( 100 , 'setup_timekeeping: returning...' )
  578. END SUBROUTINE Setup_Timekeeping