PageRenderTime 62ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 1ms

/wrfv2_fire/share/mediation_integrate.F

http://github.com/jbeezley/wrf-fire
FORTRAN Legacy | 2716 lines | 1364 code | 476 blank | 876 comment | 25 complexity | cf69e657a5d46c322b123daf75124687 MD5 | raw file
Possible License(s): AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. !
  2. !WRF:MEDIATION_LAYER:IO
  3. !
  4. #if (DA_CORE != 1)
  5. SUBROUTINE med_calc_model_time ( grid , config_flags )
  6. ! Driver layer
  7. USE module_domain , ONLY : domain, domain_clock_get
  8. USE module_configure , ONLY : grid_config_rec_type
  9. ! Model layer
  10. USE module_date_time
  11. IMPLICIT NONE
  12. ! Arguments
  13. TYPE(domain) :: grid
  14. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  15. ! Local data
  16. REAL :: time
  17. ! this is now handled by with calls to time manager
  18. ! time = head_grid%dt * head_grid%total_time_steps
  19. ! CALL calc_current_date (grid%id, time)
  20. END SUBROUTINE med_calc_model_time
  21. SUBROUTINE med_before_solve_io ( grid , config_flags )
  22. ! Driver layer
  23. USE module_state_description
  24. USE module_domain , ONLY : domain, domain_clock_get
  25. USE module_configure , ONLY : grid_config_rec_type
  26. USE module_streams
  27. ! Model layer
  28. USE module_utility
  29. IMPLICIT NONE
  30. ! Arguments
  31. TYPE(domain) :: grid
  32. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  33. ! Local
  34. INTEGER :: ialarm
  35. INTEGER :: rc
  36. TYPE(WRFU_Time) :: currTime, startTime
  37. #ifdef HWRF
  38. !zhang's doing
  39. ! TYPE(WRFU_Time) :: CurrTime !zhang new
  40. INTEGER :: hr, min, sec, ms,julyr,julday
  41. REAL :: GMT
  42. !end of zhang's doing
  43. #endif
  44. CHARACTER*256 :: message
  45. ! #if (EM_CORE == 1)
  46. CALL WRFU_ClockGet( grid%domain_clock, CurrTime=currTime, StartTime=startTime )
  47. IF( WRFU_AlarmIsRinging( grid%alarms( HISTORY_ALARM ), rc=rc ) .AND. &
  48. (grid%dfi_write_dfi_history .OR. grid%dfi_stage == DFI_FST .OR. grid%dfi_opt == DFI_NODFI) ) THEN
  49. ! #else
  50. ! IF( WRFU_AlarmIsRinging( grid%alarms( HISTORY_ALARM ), rc=rc )) THEN
  51. ! #endif
  52. IF ( (config_flags%restart) .AND. ( currTime .EQ. startTime ) ) THEN
  53. ! output history at beginning of restart if alarm is ringing
  54. CALL med_hist_out ( grid , HISTORY_ALARM, config_flags )
  55. ELSE
  56. CALL med_hist_out ( grid , HISTORY_ALARM, config_flags )
  57. END IF
  58. CALL WRFU_AlarmRingerOff( grid%alarms( HISTORY_ALARM ), rc=rc )
  59. #if (EM_CORE == 1)
  60. ELSE IF ( (config_flags%restart) .AND. ( currTime .EQ. startTime ) .AND. &
  61. ( config_flags%write_hist_at_0h_rst ) ) THEN
  62. ! output history at beginning of restart even if alarm is not ringing
  63. CALL med_hist_out ( grid , HISTORY_ALARM, config_flags )
  64. CALL WRFU_AlarmRingerOff( grid%alarms( HISTORY_ALARM ), rc=rc )
  65. #endif
  66. ENDIF
  67. IF( WRFU_AlarmIsRinging( grid%alarms( INPUTOUT_ALARM ), rc=rc ) ) THEN
  68. CALL med_filter_out ( grid , config_flags )
  69. CALL WRFU_AlarmRingerOff( grid%alarms( INPUTOUT_ALARM ), rc=rc )
  70. ENDIF
  71. DO ialarm = first_auxhist, last_auxhist
  72. IF ( .FALSE.) THEN
  73. rc = 1 ! dummy statement
  74. ELSE IF( WRFU_AlarmIsRinging( grid%alarms( ialarm ), rc=rc ) ) THEN
  75. CALL med_hist_out ( grid , ialarm, config_flags )
  76. CALL WRFU_AlarmRingerOff( grid%alarms( ialarm ), rc=rc )
  77. ENDIF
  78. ENDDO
  79. DO ialarm = first_auxinput, last_auxinput
  80. IF ( .FALSE.) THEN
  81. rc = 1 ! dummy statement
  82. #ifdef WRF_CHEM
  83. ! - Get chemistry data
  84. ELSE IF( ialarm .EQ. AUXINPUT5_ALARM .AND. config_flags%chem_opt > 0 ) THEN
  85. IF( config_flags%emiss_inpt_opt /= 0 ) THEN
  86. IF( WRFU_AlarmIsRinging( grid%alarms( ialarm ), rc=rc ) ) THEN
  87. call wrf_debug(15,' CALL med_read_wrf_chem_emiss ')
  88. CALL med_read_wrf_chem_emiss ( grid , config_flags )
  89. CALL WRFU_AlarmRingerOff( grid%alarms( ialarm ), rc=rc )
  90. call wrf_debug(15,' Back from CALL med_read_wrf_chem_emiss ')
  91. ENDIF
  92. ELSE
  93. IF( WRFU_AlarmIsRinging( grid%alarms( ialarm ), rc=rc ) ) THEN
  94. CALL med_auxinput_in ( grid, ialarm, config_flags )
  95. CALL WRFU_AlarmRingerOff( grid%alarms( ialarm ), rc=rc )
  96. ENDIF
  97. ENDIF
  98. ELSE IF( ialarm .EQ. AUXINPUT13_ALARM .AND. config_flags%chem_opt > 0 ) THEN
  99. IF( config_flags%emiss_opt_vol /= 0 ) THEN
  100. IF( WRFU_AlarmIsRinging( grid%alarms( ialarm ), rc=rc ) ) THEN
  101. call wrf_debug(15,' CALL med_read_wrf_volc_emiss ')
  102. CALL med_read_wrf_volc_emiss ( grid , config_flags )
  103. CALL WRFU_AlarmRingerOff( grid%alarms( ialarm ), rc=rc )
  104. call wrf_debug(15,' Back from CALL med_read_wrf_volc_emiss ')
  105. ENDIF
  106. ELSE
  107. IF( WRFU_AlarmIsRinging( grid%alarms( ialarm ), rc=rc ) ) THEN
  108. CALL med_auxinput_in ( grid, ialarm, config_flags )
  109. CALL WRFU_AlarmRingerOff( grid%alarms( ialarm ), rc=rc )
  110. ENDIF
  111. ENDIF
  112. #endif
  113. #if ( EM_CORE == 1 )
  114. ELSE IF( ialarm .EQ. AUXINPUT11_ALARM ) THEN
  115. IF( config_flags%obs_nudge_opt .EQ. 1) THEN
  116. CALL med_fddaobs_in ( grid , config_flags )
  117. ENDIF
  118. #endif
  119. ELSE IF( WRFU_AlarmIsRinging( grid%alarms( ialarm ), rc=rc ) ) THEN
  120. CALL med_auxinput_in ( grid, ialarm, config_flags )
  121. WRITE ( message , FMT='(A,i3,A,i3)' ) 'Input data processed for aux input ' , &
  122. ialarm - first_auxinput + 1, ' for domain ',grid%id
  123. CALL wrf_debug ( 0 , message )
  124. CALL WRFU_AlarmRingerOff( grid%alarms( ialarm ), rc=rc )
  125. ENDIF
  126. ENDDO
  127. ! - RESTART OUTPUT
  128. CALL WRFU_ClockGet( grid%domain_clock, CurrTime=currTime, StartTime=startTime )
  129. IF ( ( WRFU_AlarmIsRinging( grid%alarms( RESTART_ALARM ), rc=rc ) ) .AND. &
  130. ( currTime .NE. startTime ) ) THEN
  131. #ifdef HWRF
  132. !zhang's doing
  133. CALL domain_clock_get( grid, current_time=CurrTime )
  134. CALL WRFU_TimeGet( CurrTime, YY=julyr, dayOfYear=julday, H=hr, M=min, S=sec, MS=ms, rc=rc)
  135. gmt=hr+real(min)/60.+real(sec)/3600.+real(ms)/(1000*3600)
  136. if (grid%id .eq. 2) call med_namelist_out ( grid , config_flags )
  137. !end of zhang's doing
  138. #endif
  139. IF ( grid%id .EQ. 1 ) THEN
  140. ! Only the parent initiates the restart writing. Otherwise, different
  141. ! domains may be written out at different times and with different
  142. ! time stamps in the file names.
  143. CALL med_restart_out ( grid , config_flags )
  144. ENDIF
  145. CALL WRFU_AlarmRingerOff( grid%alarms( RESTART_ALARM ), rc=rc )
  146. ELSE
  147. CALL WRFU_AlarmRingerOff( grid%alarms( RESTART_ALARM ), rc=rc )
  148. ENDIF
  149. ! - Look for boundary data after writing out history and restart files
  150. CALL med_latbound_in ( grid , config_flags )
  151. RETURN
  152. END SUBROUTINE med_before_solve_io
  153. SUBROUTINE med_after_solve_io ( grid , config_flags )
  154. ! Driver layer
  155. USE module_domain , ONLY : domain
  156. USE module_timing
  157. USE module_configure , ONLY : grid_config_rec_type
  158. ! Model layer
  159. IMPLICIT NONE
  160. ! Arguments
  161. TYPE(domain) :: grid
  162. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  163. ! Compute time series variables
  164. CALL calc_ts(grid)
  165. ! Compute track variables
  166. CALL track_driver(grid)
  167. RETURN
  168. END SUBROUTINE med_after_solve_io
  169. SUBROUTINE med_pre_nest_initial ( parent , newid , config_flags )
  170. ! Driver layer
  171. #ifdef MOVE_NESTS
  172. USE module_domain , ONLY : domain, domain_clock_get
  173. #else
  174. USE module_domain , ONLY : domain
  175. #endif
  176. #ifdef ESMFIO
  177. USE module_utility , ONLY : WRFU_Time
  178. #else
  179. USE module_utility , ONLY : WRFU_Time, WRFU_TimeEQ
  180. #endif
  181. USE module_timing
  182. USE module_io_domain
  183. USE module_configure , ONLY : grid_config_rec_type
  184. ! Model layer
  185. IMPLICIT NONE
  186. ! Arguments
  187. TYPE(domain) , POINTER :: parent
  188. INTEGER, INTENT(IN) :: newid
  189. TYPE (grid_config_rec_type) , INTENT(INOUT) :: config_flags
  190. TYPE (grid_config_rec_type) :: nest_config_flags
  191. ! Local
  192. INTEGER :: itmp, fid, ierr, icnt
  193. CHARACTER*256 :: rstname, message, timestr
  194. TYPE(WRFU_Time) :: strt_time, cur_time
  195. #ifdef MOVE_NESTS
  196. CALL domain_clock_get( parent, current_timestr=timestr, start_time=strt_time, current_time=cur_time )
  197. CALL construct_filename2a ( rstname , config_flags%rst_inname , newid , 2 , timestr )
  198. #ifdef ESMFIO
  199. IF ( config_flags%restart .AND. (cur_time .EQ. strt_time) ) THEN
  200. #else
  201. IF ( config_flags%restart .AND. WRFU_TimeEQ(cur_time,strt_time) ) THEN
  202. #endif
  203. WRITE(message,*)'RESTART: nest, opening ',TRIM(rstname),' for reading header information only'
  204. CALL wrf_message ( message )
  205. ! note that the parent pointer is not strictly correct, but nest is not allocated yet and
  206. ! only the i/o communicator fields are used from "parent" (and those are dummies in current
  207. ! implementation.
  208. CALL open_r_dataset ( fid , TRIM(rstname) , parent , config_flags , "DATASET=RESTART", ierr )
  209. IF ( ierr .NE. 0 ) THEN
  210. WRITE( message , '("program wrf: error opening ",A32," for reading")') TRIM(rstname)
  211. CALL WRF_ERROR_FATAL ( message )
  212. ENDIF
  213. ! update the values of parent_start that were read in from the namelist (nest may have moved)
  214. CALL wrf_get_dom_ti_integer ( fid , 'I_PARENT_START' , itmp , 1 , icnt, ierr )
  215. IF ( ierr .EQ. 0 ) THEN
  216. config_flags%i_parent_start = itmp
  217. CALL nl_set_i_parent_start ( newid , config_flags%i_parent_start )
  218. ENDIF
  219. CALL wrf_get_dom_ti_integer ( fid , 'J_PARENT_START' , itmp , 1 , icnt, ierr )
  220. IF ( ierr .EQ. 0 ) THEN
  221. config_flags%j_parent_start = itmp
  222. CALL nl_set_j_parent_start ( newid , config_flags%j_parent_start )
  223. ENDIF
  224. CALL close_dataset ( fid , config_flags , "DATASET=RESTART" )
  225. ENDIF
  226. #endif
  227. END SUBROUTINE med_pre_nest_initial
  228. SUBROUTINE med_nest_initial ( parent , nest , config_flags )
  229. ! Driver layer
  230. USE module_domain , ONLY : domain , domain_clock_get , get_ijk_from_grid
  231. USE module_timing
  232. USE module_io_domain
  233. USE module_configure , ONLY : grid_config_rec_type
  234. USE module_utility
  235. ! Model layer
  236. IMPLICIT NONE
  237. ! Arguments
  238. TYPE(domain) , POINTER :: parent, nest
  239. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  240. TYPE (grid_config_rec_type) :: nest_config_flags
  241. ! Local
  242. LOGICAL, EXTERNAL :: wrf_dm_on_monitor
  243. TYPE(WRFU_Time) :: strt_time, cur_time
  244. CHARACTER * 80 :: rstname , timestr
  245. CHARACTER * 256 :: message
  246. INTEGER :: fid
  247. INTEGER :: ierr
  248. INTEGER :: i , j, rc
  249. INTEGER :: ids , ide , jds , jde , kds , kde , &
  250. ims , ime , jms , jme , kms , kme , &
  251. ips , ipe , jps , jpe , kps , kpe
  252. #if (EM_CORE == 1)
  253. #ifdef MOVE_NESTS
  254. TYPE (WRFU_TimeInterval) :: interval, TimeSinceStart
  255. INTEGER :: vortex_interval , n
  256. #endif
  257. INTEGER :: save_itimestep ! This is a kludge, correct fix will
  258. ! involve integrating the time-step
  259. ! counting into the time manager.
  260. ! JM 20040604
  261. REAL, ALLOCATABLE, DIMENSION(:,:) :: save_acsnow &
  262. ,save_acsnom &
  263. ,save_cuppt &
  264. ,save_rainc &
  265. ,save_rainnc &
  266. ,save_sfcevp &
  267. ,save_sfcrunoff &
  268. ,save_udrunoff
  269. INTERFACE
  270. SUBROUTINE med_interp_domain ( parent , nest )
  271. USE module_domain , ONLY : domain
  272. TYPE(domain) , POINTER :: parent , nest
  273. END SUBROUTINE med_interp_domain
  274. SUBROUTINE med_initialdata_input_ptr( nest , config_flags )
  275. USE module_domain , ONLY : domain
  276. USE module_configure , ONLY : grid_config_rec_type
  277. TYPE (grid_config_rec_type), INTENT(IN) :: config_flags
  278. TYPE(domain) , POINTER :: nest
  279. END SUBROUTINE med_initialdata_input_ptr
  280. SUBROUTINE med_nest_feedback ( parent , nest , config_flags )
  281. USE module_domain , ONLY : domain
  282. USE module_configure , ONLY : grid_config_rec_type
  283. TYPE (domain), POINTER :: nest , parent
  284. TYPE (grid_config_rec_type), INTENT(IN) :: config_flags
  285. END SUBROUTINE med_nest_feedback
  286. SUBROUTINE start_domain ( grid , allowed_to_move )
  287. USE module_domain , ONLY : domain
  288. TYPE(domain) :: grid
  289. LOGICAL, INTENT(IN) :: allowed_to_move
  290. END SUBROUTINE start_domain
  291. SUBROUTINE blend_terrain ( ter_interpolated , ter_input , &
  292. ids , ide , jds , jde , kds , kde , &
  293. ims , ime , jms , jme , kms , kme , &
  294. ips , ipe , jps , jpe , kps , kpe )
  295. INTEGER :: ids , ide , jds , jde , kds , kde , &
  296. ims , ime , jms , jme , kms , kme , &
  297. ips , ipe , jps , jpe , kps , kpe
  298. REAL , DIMENSION(ims:ime,jms:jme) :: ter_interpolated
  299. REAL , DIMENSION(ims:ime,jms:jme) :: ter_input
  300. END SUBROUTINE blend_terrain
  301. SUBROUTINE copy_3d_field ( ter_interpolated , ter_input , &
  302. ids , ide , jds , jde , kds , kde , &
  303. ims , ime , jms , jme , kms , kme , &
  304. ips , ipe , jps , jpe , kps , kpe )
  305. INTEGER :: ids , ide , jds , jde , kds , kde , &
  306. ims , ime , jms , jme , kms , kme , &
  307. ips , ipe , jps , jpe , kps , kpe
  308. REAL , DIMENSION(ims:ime,jms:jme) :: ter_interpolated
  309. REAL , DIMENSION(ims:ime,jms:jme) :: ter_input
  310. END SUBROUTINE copy_3d_field
  311. SUBROUTINE input_terrain_rsmas ( grid , &
  312. ids , ide , jds , jde , kds , kde , &
  313. ims , ime , jms , jme , kms , kme , &
  314. ips , ipe , jps , jpe , kps , kpe )
  315. USE module_domain , ONLY : domain
  316. TYPE ( domain ) :: grid
  317. INTEGER :: ids , ide , jds , jde , kds , kde , &
  318. ims , ime , jms , jme , kms , kme , &
  319. ips , ipe , jps , jpe , kps , kpe
  320. END SUBROUTINE input_terrain_rsmas
  321. SUBROUTINE wrf_tsin ( grid , ierr )
  322. USE module_domain
  323. TYPE ( domain ), INTENT(INOUT) :: grid
  324. INTEGER, INTENT(INOUT) :: ierr
  325. END SUBROUTINE wrf_tsin
  326. END INTERFACE
  327. CALL domain_clock_get( parent, start_time=strt_time, current_time=cur_time )
  328. IF ( .not. ( config_flags%restart .AND. strt_time .EQ. cur_time ) ) THEN
  329. nest%first_force = .true.
  330. ! initialize nest with interpolated data from the parent
  331. nest%imask_nostag = 1
  332. nest%imask_xstag = 1
  333. nest%imask_ystag = 1
  334. nest%imask_xystag = 1
  335. #ifdef MOVE_NESTS
  336. parent%nest_pos = parent%ht
  337. where ( parent%nest_pos .gt. 0. ) parent%nest_pos = parent%nest_pos + 500. ! make a cliff
  338. #endif
  339. ! initialize some other constants (and 1d arrays in z)
  340. CALL init_domain_constants ( parent, nest )
  341. ! fill in entire fine grid domain with interpolated coarse grid data
  342. CALL med_interp_domain( parent, nest )
  343. ! De-reference dimension information stored in the grid data structure.
  344. CALL get_ijk_from_grid ( nest , &
  345. ids, ide, jds, jde, kds, kde, &
  346. ims, ime, jms, jme, kms, kme, &
  347. ips, ipe, jps, jpe, kps, kpe )
  348. ! get the nest config flags
  349. CALL model_to_grid_config_rec ( nest%id , model_config_rec , nest_config_flags )
  350. IF ( nest_config_flags%input_from_file .OR. nest_config_flags%input_from_hires ) THEN
  351. WRITE(message,FMT='(A,I2,A)') '*** Initializing nest domain #',nest%id,&
  352. ' from an input file. ***'
  353. CALL wrf_debug ( 0 , message )
  354. ! Store horizontally interpolated terrain-based fields in temp location if the input
  355. ! data is from a pristine, un-cycled model input file. For the original topo from
  356. ! the real program, we will need to adjust the terrain (and a couple of other base-
  357. ! state fields) so reflect the smoothing and matching between the parent and child
  358. ! domains.
  359. CALL copy_3d_field ( nest%ht_int , nest%ht , &
  360. ids , ide , jds , jde , 1 , 1 , &
  361. ims , ime , jms , jme , 1 , 1 , &
  362. ips , ipe , jps , jpe , 1 , 1 )
  363. CALL copy_3d_field ( nest%mub_fine , nest%mub , &
  364. ids , ide , jds , jde , 1 , 1 , &
  365. ims , ime , jms , jme , 1 , 1 , &
  366. ips , ipe , jps , jpe , 1 , 1 )
  367. CALL copy_3d_field ( nest%phb_fine , nest%phb , &
  368. ids , ide , jds , jde , kds , kde , &
  369. ims , ime , jms , jme , kms , kme , &
  370. ips , ipe , jps , jpe , kps , kpe )
  371. IF ( nest_config_flags%input_from_file ) THEN
  372. ! read input from dataset
  373. CALL med_initialdata_input_ptr( nest , nest_config_flags )
  374. ELSE IF ( nest_config_flags%input_from_hires ) THEN
  375. ! read in high res topography
  376. CALL input_terrain_rsmas ( nest, &
  377. ids , ide , jds , jde , 1 , 1 , &
  378. ims , ime , jms , jme , 1 , 1 , &
  379. ips , ipe , jps , jpe , 1 , 1 )
  380. ENDIF
  381. ! save elevation and mub for temp and qv adjustment
  382. CALL copy_3d_field ( nest%ht_fine , nest%ht , &
  383. ids , ide , jds , jde , 1 , 1 , &
  384. ims , ime , jms , jme , 1 , 1 , &
  385. ips , ipe , jps , jpe , 1 , 1 )
  386. CALL copy_3d_field ( nest%mub_save , nest%mub , &
  387. ids , ide , jds , jde , 1 , 1 , &
  388. ims , ime , jms , jme , 1 , 1 , &
  389. ips , ipe , jps , jpe , 1 , 1 )
  390. ! blend parent and nest fields: terrain, mub, and phb. The ht, mub and phb are used in start_domain.
  391. IF ( nest%save_topo_from_real == 1 ) THEN
  392. CALL blend_terrain ( nest%ht_int , nest%ht , &
  393. ids , ide , jds , jde , 1 , 1 , &
  394. ims , ime , jms , jme , 1 , 1 , &
  395. ips , ipe , jps , jpe , 1 , 1 )
  396. CALL blend_terrain ( nest%mub_fine , nest%mub , &
  397. ids , ide , jds , jde , 1 , 1 , &
  398. ims , ime , jms , jme , 1 , 1 , &
  399. ips , ipe , jps , jpe , 1 , 1 )
  400. CALL blend_terrain ( nest%phb_fine , nest%phb , &
  401. ids , ide , jds , jde , kds , kde , &
  402. ims , ime , jms , jme , kms , kme , &
  403. ips , ipe , jps , jpe , kps , kpe )
  404. ENDIF
  405. ! adjust temp and qv
  406. CALL adjust_tempqv ( nest%mub , nest%mub_save , &
  407. nest%znw , nest%p_top , &
  408. nest%t_2 , nest%p , nest%moist(ims,kms,jms,P_QV) , &
  409. ids , ide , jds , jde , kds , kde , &
  410. ims , ime , jms , jme , kms , kme , &
  411. ips , ipe , jps , jpe , kps , kpe )
  412. ELSE
  413. WRITE(message,FMT='(A,I2,A,I2,A)') '*** Initializing nest domain #',nest%id,&
  414. ' by horizontally interpolating parent domain #' ,parent%id, &
  415. '. ***'
  416. CALL wrf_debug ( 0 , message )
  417. #if (DA_CORE != 1)
  418. ! For nests without an input file, we still need to read time series locations
  419. ! from the tslist file
  420. CALL wrf_tsin( nest , ierr )
  421. #endif
  422. END IF
  423. ! feedback, mostly for this new terrain, but it is the safe thing to do
  424. parent%ht_coarse = parent%ht
  425. CALL med_nest_feedback ( parent , nest , config_flags )
  426. ! set some other initial fields, fill out halos, base fields; re-do parent due
  427. ! to new terrain elevation from feedback
  428. nest%imask_nostag = 1
  429. nest%imask_xstag = 1
  430. nest%imask_ystag = 1
  431. nest%imask_xystag = 1
  432. nest%press_adj = .TRUE.
  433. CALL start_domain ( nest , .TRUE. )
  434. ! kludge: 20040604
  435. CALL get_ijk_from_grid ( parent , &
  436. ids, ide, jds, jde, kds, kde, &
  437. ims, ime, jms, jme, kms, kme, &
  438. ips, ipe, jps, jpe, kps, kpe )
  439. ALLOCATE( save_acsnow(ims:ime,jms:jme) )
  440. ALLOCATE( save_acsnom(ims:ime,jms:jme) )
  441. ALLOCATE( save_cuppt(ims:ime,jms:jme) )
  442. ALLOCATE( save_rainc(ims:ime,jms:jme) )
  443. ALLOCATE( save_rainnc(ims:ime,jms:jme) )
  444. ALLOCATE( save_sfcevp(ims:ime,jms:jme) )
  445. ALLOCATE( save_sfcrunoff(ims:ime,jms:jme) )
  446. ALLOCATE( save_udrunoff(ims:ime,jms:jme) )
  447. save_acsnow = parent%acsnow
  448. save_acsnom = parent%acsnom
  449. save_cuppt = parent%cuppt
  450. save_rainc = parent%rainc
  451. save_rainnc = parent%rainnc
  452. save_sfcevp = parent%sfcevp
  453. save_sfcrunoff = parent%sfcrunoff
  454. save_udrunoff = parent%udrunoff
  455. save_itimestep = parent%itimestep
  456. parent%imask_nostag = 1
  457. parent%imask_xstag = 1
  458. parent%imask_ystag = 1
  459. parent%imask_xystag = 1
  460. parent%press_adj = .FALSE.
  461. CALL start_domain ( parent , .TRUE. )
  462. parent%acsnow = save_acsnow
  463. parent%acsnom = save_acsnom
  464. parent%cuppt = save_cuppt
  465. parent%rainc = save_rainc
  466. parent%rainnc = save_rainnc
  467. parent%sfcevp = save_sfcevp
  468. parent%sfcrunoff = save_sfcrunoff
  469. parent%udrunoff = save_udrunoff
  470. parent%itimestep = save_itimestep
  471. DEALLOCATE( save_acsnow )
  472. DEALLOCATE( save_acsnom )
  473. DEALLOCATE( save_cuppt )
  474. DEALLOCATE( save_rainc )
  475. DEALLOCATE( save_rainnc )
  476. DEALLOCATE( save_sfcevp )
  477. DEALLOCATE( save_sfcrunoff )
  478. DEALLOCATE( save_udrunoff )
  479. ! end of kludge: 20040604
  480. ELSE ! restart
  481. IF ( wrf_dm_on_monitor() ) CALL start_timing
  482. CALL domain_clock_get( nest, current_timestr=timestr )
  483. CALL construct_filename2a ( rstname , config_flags%rst_inname , nest%id , 2 , timestr )
  484. WRITE(message,*)'RESTART: nest, opening ',TRIM(rstname),' for reading'
  485. CALL wrf_message ( message )
  486. CALL model_to_grid_config_rec ( nest%id , model_config_rec , nest_config_flags )
  487. CALL open_r_dataset ( fid , TRIM(rstname) , nest , nest_config_flags , "DATASET=RESTART", ierr )
  488. IF ( ierr .NE. 0 ) THEN
  489. WRITE( message , '("program wrf: error opening ",A32," for reading")') TRIM(rstname)
  490. CALL WRF_ERROR_FATAL ( message )
  491. ENDIF
  492. CALL input_restart ( fid, nest , nest_config_flags , ierr )
  493. CALL close_dataset ( fid , nest_config_flags , "DATASET=RESTART" )
  494. IF ( wrf_dm_on_monitor() ) THEN
  495. WRITE ( message , FMT = '("processing restart file for domain ",I8)' ) nest%id
  496. CALL end_timing ( TRIM(message) )
  497. ENDIF
  498. nest%imask_nostag = 1
  499. nest%imask_xstag = 1
  500. nest%imask_ystag = 1
  501. nest%imask_xystag = 1
  502. nest%press_adj = .FALSE.
  503. CALL start_domain ( nest , .TRUE. )
  504. #ifndef MOVE_NESTS
  505. ! this doesn't need to be done for moving nests, since ht_coarse is part of the restart
  506. parent%ht_coarse = parent%ht
  507. #else
  508. # if 1
  509. ! In case of a restart, assume that the movement has already occurred in the previous
  510. ! run and turn off the alarm for the starting time. We must impose a requirement that the
  511. ! run be restarted on-interval. Test for that and print a warning if it isn't.
  512. ! Note, simulation_start, etc. should be available as metadata in the restart file, and
  513. ! these will have gotten, set, and retrievable as rconfig data been set in share/input_wrf.F
  514. ! using the nl_get routines below. JM 20060314
  515. CALL nl_get_vortex_interval ( nest%id , vortex_interval )
  516. CALL WRFU_TimeIntervalSet( interval, M=vortex_interval, rc=rc )
  517. CALL domain_clock_get( nest, timeSinceSimulationStart=TimeSinceStart )
  518. n = WRFU_TimeIntervalDIVQuot( TimeSinceStart , interval )
  519. IF ( ( interval * n ) .NE. TimeSinceStart ) THEN
  520. CALL wrf_message('WARNING: Restart is not on a vortex_interval time boundary.')
  521. CALL wrf_message('The code will work but results will not agree exactly with a ')
  522. CALL wrf_message('a run that was done straight-through, without a restart.')
  523. ENDIF
  524. !! In case of a restart, assume that the movement has already occurred in the previous
  525. !! run and turn off the alarm for the starting time. We must impose a requirement that the
  526. !! run be restarted on-interval. Test for that and print a warning if it isn't.
  527. !! Note, simulation_start, etc. should be available as metadata in the restart file, and
  528. !! these will have gotten, set, and retrievable as rconfig data been set in share/input_wrf.F
  529. !! using the nl_get routines below. JM 20060314
  530. ! CALL WRFU_AlarmRingerOff( nest%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  531. # else
  532. ! this code, currently commented out, is an attempt to have the
  533. ! vortex centering interval be set according to simulation start
  534. ! time (rather than run start time) in case of a restart. But
  535. ! there are other problems (the WRF clock is currently using
  536. ! run-start as it's start time) so the alarm still would not fire
  537. ! right if the model were started off-interval. Leave it here and
  538. ! enable when the clock is changed to use sim-start for start time.
  539. ! JM 20060314
  540. CALL nl_get_vortex_interval ( nest%id , vortex_interval )
  541. CALL WRFU_TimeIntervalSet( interval, M=vortex_interval, rc=rc )
  542. CALL domain_clock_get( nest, timeSinceSimulationStart=TimeSinceStart )
  543. CALL domain_alarm_create( nest, COMPUTE_VORTEX_CENTER_ALARM, interval )
  544. CALL WRFU_AlarmEnable( nest%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  545. n = WRFU_TimeIntervalDIVQuot( TimeSinceStart , interval )
  546. IF ( ( interval * n ) .EQ. TimeSinceStart ) THEN
  547. CALL WRFU_AlarmRingerOn( nest%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  548. ELSE
  549. CALL WRFU_AlarmRingerOff( nest%alarms( COMPUTE_VORTEX_CENTER_ALARM ), rc=rc )
  550. ENDIF
  551. # endif
  552. #endif
  553. ENDIF
  554. #endif
  555. #if (NMM_CORE == 1 && NMM_NEST == 1)
  556. !===================================================================================
  557. ! Added for the NMM core. This is gopal's doing.
  558. !===================================================================================
  559. INTERFACE
  560. SUBROUTINE med_nest_egrid_configure ( parent , nest )
  561. USE module_domain , ONLY : domain
  562. TYPE(domain) , POINTER :: parent , nest
  563. END SUBROUTINE med_nest_egrid_configure
  564. SUBROUTINE med_construct_egrid_weights ( parent , nest )
  565. USE module_domain , ONLY : domain
  566. TYPE(domain) , POINTER :: parent , nest
  567. END SUBROUTINE med_construct_egrid_weights
  568. SUBROUTINE BASE_STATE_PARENT ( Z3d,Q3d,T3d,PSTD, &
  569. PINT,T,Q,CWM, &
  570. FIS,QSH,PD,PDTOP,PTOP, &
  571. ETA1,ETA2, &
  572. DETA1,DETA2, &
  573. IDS,IDE,JDS,JDE,KDS,KDE, &
  574. IMS,IME,JMS,JME,KMS,KME, &
  575. IPS,IPE,JPS,JPE,KPS,KPE )
  576. !
  577. USE MODULE_MODEL_CONSTANTS
  578. IMPLICIT NONE
  579. INTEGER, INTENT(IN ) :: IDS,IDE,JDS,JDE,KDS,KDE
  580. INTEGER, INTENT(IN ) :: IMS,IME,JMS,JME,KMS,KME
  581. INTEGER, INTENT(IN ) :: IPS,IPE,JPS,JPE,KPS,KPE
  582. REAL, INTENT(IN ) :: PDTOP,PTOP
  583. REAL, DIMENSION(KMS:KME), INTENT(IN) :: ETA1,ETA2,DETA1,DETA2
  584. REAL, DIMENSION(IMS:IME,JMS:JME), INTENT(IN) :: FIS,PD,QSH
  585. REAL, DIMENSION(IMS:IME,JMS:JME,KMS:KME), INTENT(IN) :: PINT,T,Q,CWM
  586. REAL, DIMENSION(KMS:KME) , INTENT(OUT):: PSTD
  587. REAL, DIMENSION(IMS:IME,JMS:JME,KMS:KME), INTENT(OUT):: Z3d,Q3d,T3d
  588. END SUBROUTINE BASE_STATE_PARENT
  589. SUBROUTINE NEST_TERRAIN ( nest, config_flags )
  590. USE module_domain , ONLY : domain
  591. USE module_configure , ONLY : grid_config_rec_type
  592. TYPE(domain) , POINTER :: nest
  593. TYPE(grid_config_rec_type) , INTENT(IN) :: config_flags
  594. END SUBROUTINE NEST_TERRAIN
  595. SUBROUTINE med_interp_domain ( parent , nest )
  596. USE module_domain , ONLY : domain
  597. TYPE(domain) , POINTER :: parent , nest
  598. END SUBROUTINE med_interp_domain
  599. SUBROUTINE med_init_domain_constants_nmm ( parent, nest )
  600. USE module_domain , ONLY : domain
  601. TYPE(domain) , POINTER :: parent , nest
  602. END SUBROUTINE med_init_domain_constants_nmm
  603. SUBROUTINE start_domain ( grid , allowed_to_move )
  604. USE module_domain , ONLY : domain
  605. TYPE(domain) :: grid
  606. LOGICAL, INTENT(IN) :: allowed_to_move
  607. END SUBROUTINE start_domain
  608. END INTERFACE
  609. #ifdef HWRF
  610. !zhang's doing test
  611. if (config_flags%restart .or. nest%analysis) then
  612. nest%first_force = .true.
  613. else
  614. nest%first_force = .false.
  615. endif
  616. !end of zhang's doing
  617. !zhang's doing for analysis option
  618. IF(.not. nest%analysis .and. .not. config_flags%restart)THEN ! initialize for cold-start
  619. #endif
  620. !----------------------------------------------------------------------------
  621. ! initialize nested domain configurations including setting up wbd,sbd, etc
  622. !----------------------------------------------------------------------------
  623. CALL med_nest_egrid_configure ( parent , nest )
  624. !-------------------------------------------------------------------------
  625. ! initialize lat-lons and determine weights
  626. !-------------------------------------------------------------------------
  627. CALL med_construct_egrid_weights ( parent, nest )
  628. !
  629. !
  630. ! De-reference dimension information stored in the grid data structure.
  631. !
  632. ! From the hybrid, construct the GPMs on isobaric surfaces and then interpolate those
  633. ! values on to the nested domain. 23 standard prssure levels are assumed here. For
  634. ! levels below ground, lapse rate atmosphere is assumed before the use of vertical
  635. ! spline interpolation
  636. !
  637. IDS = parent%sd31
  638. IDE = parent%ed31
  639. JDS = parent%sd32
  640. JDE = parent%ed32
  641. KDS = parent%sd33
  642. KDE = parent%ed33
  643. IMS = parent%sm31
  644. IME = parent%em31
  645. JMS = parent%sm32
  646. JME = parent%em32
  647. KMS = parent%sm33
  648. KME = parent%em33
  649. IPS = parent%sp31
  650. IPE = parent%ep31
  651. JPS = parent%sp32
  652. JPE = parent%ep32
  653. KPS = parent%sp33
  654. KPE = parent%ep33
  655. CALL BASE_STATE_PARENT ( parent%Z3d,parent%Q3d,parent%T3d,parent%PSTD, &
  656. parent%PINT,parent%T,parent%Q,parent%CWM, &
  657. parent%FIS,parent%QSH,parent%PD,parent%pdtop,parent%pt, &
  658. parent%ETA1,parent%ETA2, &
  659. parent%DETA1,parent%DETA2, &
  660. IDS,IDE,JDS,JDE,KDS,KDE, &
  661. IMS,IME,JMS,JME,KMS,KME, &
  662. IPS,IPE,JPS,JPE,KPS,KPE )
  663. !
  664. ! Set new terrain. Since some terrain adjustment is done within the interpolation calls
  665. ! at the next step, the new terrain over the nested domain has to be called here.
  666. !
  667. IDS = nest%sd31
  668. IDE = nest%ed31
  669. JDS = nest%sd32
  670. JDE = nest%ed32
  671. KDS = nest%sd33
  672. KDE = nest%ed33
  673. IMS = nest%sm31
  674. IME = nest%em31
  675. JMS = nest%sm32
  676. JME = nest%em32
  677. KMS = nest%sm33
  678. KME = nest%em33
  679. IPS = nest%sp31
  680. IPE = nest%ep31
  681. JPS = nest%sp32
  682. JPE = nest%ep32
  683. KPS = nest%sp33
  684. KPE = nest%ep33
  685. CALL NEST_TERRAIN ( nest, config_flags )
  686. ! Initialize some more constants required especially for terrain adjustment processes
  687. nest%PSTD=parent%PSTD
  688. nest%KZMAX=KME
  689. parent%KZMAX=KME ! just for safety
  690. DO J = JPS, MIN(JPE,JDE-1)
  691. DO I = IPS, MIN(IPE,IDE-1)
  692. nest%fis(I,J)=nest%hres_fis(I,J)
  693. ENDDO
  694. ENDDO
  695. !--------------------------------------------------------------------------
  696. ! interpolation call
  697. !--------------------------------------------------------------------------
  698. ! initialize nest with interpolated data from the parent
  699. nest%imask_nostag = 0
  700. nest%imask_xstag = 0
  701. nest%imask_ystag = 0
  702. nest%imask_xystag = 0
  703. #ifdef HWRF
  704. CALL med_interp_domain( parent, nest )
  705. #else
  706. CALL domain_clock_get( parent, start_time=strt_time, current_time=cur_time )
  707. IF ( .not. ( config_flags%restart .AND. strt_time .EQ. cur_time ) ) THEN
  708. CALL med_interp_domain( parent, nest )
  709. ELSE
  710. CALL domain_clock_get( nest, current_timestr=timestr )
  711. CALL construct_filename2a ( rstname , config_flags%rst_inname , nest%id , 2 , timestr )
  712. WRITE(message,*)'RESTART: nest, opening ',TRIM(rstname),' for reading'
  713. CALL wrf_message ( message )
  714. CALL model_to_grid_config_rec ( nest%id , model_config_rec , nest_config_flags )
  715. CALL open_r_dataset ( fid , TRIM(rstname) , nest , nest_config_flags , "DATASET=RESTART", ierr )
  716. IF ( ierr .NE. 0 ) THEN
  717. WRITE( message , '("program wrf: error opening ",A32," for reading")') TRIM(rstname)
  718. CALL WRF_ERROR_FATAL ( message )
  719. ENDIF
  720. CALL input_restart ( fid, nest , nest_config_flags , ierr )
  721. CALL close_dataset ( fid , nest_config_flags , "DATASET=RESTART" )
  722. END IF
  723. #endif
  724. !------------------------------------------------------------------------------
  725. ! set up constants (module_initialize_real.F for nested nmm domain)
  726. !-----------------------------------------------------------------------------
  727. CALL med_init_domain_constants_nmm ( parent, nest )
  728. !--------------------------------------------------------------------------------------
  729. ! set some other initial fields, fill out halos, etc.
  730. !--------------------------------------------------------------------------------------
  731. CALL start_domain ( nest, .TRUE.)
  732. #ifdef HWRF
  733. !zhang's doing: else for analysis or restart option
  734. !zhang test
  735. CALL nl_set_isice ( nest%id , config_flags%isice )
  736. CALL nl_set_isoilwater ( nest%id , config_flags%isoilwater )
  737. CALL nl_set_isurban ( nest%id , config_flags%isurban )
  738. CALL nl_set_gmt ( nest%id , config_flags%gmt )
  739. CALL nl_set_julyr (nest%id, config_flags%julyr)
  740. CALL nl_set_julday ( nest%id , config_flags%julday )
  741. !zhang test ends
  742. CALL med_analysis_out ( nest, config_flags )
  743. ELSE
  744. !------------------------------------------------------------------------------------
  745. ! read in analysis (equivalent of restart for the nested domains)
  746. !------------------------------------------------------------------------------------
  747. !zhang's doing
  748. IF( nest%analysis .and. .not. config_flags%restart)THEN
  749. CALL med_analysis_in ( nest, config_flags )
  750. ELSE IF (config_flags%restart)THEN
  751. CALL med_restart_in ( nest, config_flags )
  752. ENDIF
  753. !end of zhang's doing
  754. !----------------------------------------------------------------------------
  755. ! initialize nested domain configurations including setting up wbd,sbd, etc
  756. !----------------------------------------------------------------------------
  757. CALL med_nest_egrid_configure ( parent , nest )
  758. !-------------------------------------------------------------------------
  759. ! initialize lat-lons and determine weights (overwrite for safety)
  760. !-------------------------------------------------------------------------
  761. CALL med_construct_egrid_weights ( parent, nest )
  762. nest%imask_nostag = 0
  763. nest%imask_xstag = 0
  764. nest%imask_ystag = 0
  765. nest%imask_xystag = 0
  766. !------------------------------------------------------------------------------
  767. ! set up constants (module_initialize_real.F for nested nmm domain)
  768. !-----------------------------------------------------------------------------
  769. CALL med_init_domain_constants_nmm ( parent, nest )
  770. !--------------------------------------------------------------------------------------
  771. ! set some other initial fields, fill out halos, etc. (again, safety sake only)
  772. ! Also, in order to accomodate some physics initialization after nest move, set
  773. ! analysis back to false for future use
  774. !--------------------------------------------------------------------------------------
  775. CALL start_domain ( nest, .TRUE.)
  776. nest%analysis=.FALSE.
  777. CALL nl_set_analysis( nest%id, nest%analysis)
  778. ENDIF
  779. #endif
  780. !===================================================================================
  781. ! Added for the NMM core. End of gopal's doing.
  782. !===================================================================================
  783. #endif
  784. RETURN
  785. END SUBROUTINE med_nest_initial
  786. SUBROUTINE init_domain_constants ( parent , nest )
  787. USE module_domain , ONLY : domain
  788. IMPLICIT NONE
  789. TYPE(domain) :: parent , nest
  790. #if (EM_CORE == 1)
  791. CALL init_domain_constants_em ( parent, nest )
  792. #endif
  793. END SUBROUTINE init_domain_constants
  794. SUBROUTINE med_nest_force ( parent , nest )
  795. ! Driver layer
  796. USE module_domain , ONLY : domain
  797. USE module_timing
  798. USE module_configure , ONLY : grid_config_rec_type
  799. ! Model layer
  800. ! External
  801. USE module_utility
  802. IMPLICIT NONE
  803. ! Arguments
  804. TYPE(domain) , POINTER :: parent, nest
  805. ! Local
  806. INTEGER :: idum1 , idum2 , fid, rc
  807. #if (NMM_CORE == 1 && NMM_NEST == 1)
  808. INTEGER :: IDS,IDE,JDS,JDE,KDS,KDE ! gopal
  809. INTEGER :: IMS,IME,JMS,JME,KMS,KME
  810. INTEGER :: ITS,ITE,JTS,JTE,KTS,KTE
  811. #endif
  812. INTERFACE
  813. SUBROUTINE med_force_domain ( parent , nest )
  814. USE module_domain , ONLY : domain
  815. TYPE(domain) , POINTER :: parent , nest
  816. END SUBROUTINE med_force_domain
  817. SUBROUTINE med_interp_domain ( parent , nest )
  818. USE module_domain , ONLY : domain
  819. TYPE(domain) , POINTER :: parent , nest
  820. END SUBROUTINE med_interp_domain
  821. #if (NMM_CORE == 1 && NMM_NEST == 1)
  822. !===================================================================================
  823. ! Added for the NMM core. This is gopal's doing.
  824. !===================================================================================
  825. SUBROUTINE BASE_STATE_PARENT ( Z3d,Q3d,T3d,PSTD, &
  826. PINT,T,Q,CWM, &
  827. FIS,QSH,PD,PDTOP,PTOP, &
  828. ETA1,ETA2, &
  829. DETA1,DETA2, &
  830. IDS,IDE,JDS,JDE,KDS,KDE, &
  831. IMS,IME,JMS,JME,KMS,KME, &
  832. ITS,ITE,JTS,JTE,KTS,KTE )
  833. !
  834. USE MODULE_MODEL_CONSTANTS
  835. IMPLICIT NONE
  836. INTEGER, INTENT(IN ) :: IDS,IDE,JDS,JDE,KDS,KDE
  837. INTEGER, INTENT(IN ) :: IMS,IME,JMS,JME,KMS,KME
  838. INTEGER, INTENT(IN ) :: ITS,ITE,JTS,JTE,KTS,KTE
  839. REAL, INTENT(IN ) :: PDTOP,PTOP
  840. REAL, DIMENSION(KMS:KME), INTENT(IN) :: ETA1,ETA2,DETA1,DETA2
  841. REAL, DIMENSION(IMS:IME,JMS:JME), INTENT(IN) :: FIS,PD,QSH
  842. REAL, DIMENSION(IMS:IME,JMS:JME,KMS:KME), INTENT(IN) :: PINT,T,Q,CWM
  843. REAL, DIMENSION(KMS:KME) , INTENT(OUT):: PSTD
  844. REAL, DIMENSION(IMS:IME,JMS:JME,KMS:KME), INTENT(OUT):: Z3d,Q3d,T3d
  845. END SUBROUTINE BASE_STATE_PARENT
  846. #endif
  847. END INTERFACE
  848. #if (NMM_CORE == 1 && NMM_NEST == 1)
  849. ! De-reference dimension information stored in the grid data structure.
  850. IDS = parent%sd31
  851. IDE = parent%ed31
  852. JDS = parent%sd32
  853. JDE = parent%ed32
  854. KDS = parent%sd33
  855. KDE = parent%ed33
  856. IMS = parent%sm31
  857. IME = parent%em31
  858. JMS = parent%sm32
  859. JME = parent%em32
  860. KMS = parent%sm33
  861. KME = parent%em33
  862. ITS = parent%sp31
  863. ITE = parent%ep31
  864. JTS = parent%sp32
  865. JTE = parent%ep32
  866. KTS = parent%sp33
  867. KTE = parent%ep33
  868. CALL BASE_STATE_PARENT ( parent%Z3d,parent%Q3d,parent%T3d,parent%PSTD, &
  869. parent%PINT,parent%T,parent%Q,parent%CWM, &
  870. parent%FIS,parent%QSH,parent%PD,parent%pdtop,parent%pt, &
  871. parent%ETA1,parent%ETA2, &
  872. parent%DETA1,parent%DETA2, &
  873. IDS,IDE,JDS,JDE,KDS,KDE, &
  874. IMS,IME,JMS,JME,KMS,KME, &
  875. ITS,ITE,JTS,JTE,KTS,KTE )
  876. #endif
  877. IF ( .NOT. WRFU_ClockIsStopTime(nest%domain_clock ,rc=rc) ) THEN
  878. ! initialize nest with interpolated data from the parent
  879. nest%imask_nostag = 1
  880. nest%imask_xstag = 1
  881. nest%imask_ystag = 1
  882. nest%imask_xystag = 1
  883. CALL med_force_domain( parent, nest )
  884. ENDIF
  885. ! might also have calls here to do input from a file into the nest
  886. RETURN
  887. END SUBROUTINE med_nest_force
  888. SUBROUTINE med_nest_feedback ( parent , nest , config_flags )
  889. ! Driver layer
  890. USE module_domain , ONLY : domain , get_ijk_from_grid
  891. USE module_timing
  892. USE module_configure , ONLY : grid_config_rec_type
  893. ! Model layer
  894. ! External
  895. USE module_utility
  896. IMPLICIT NONE
  897. ! Arguments
  898. TYPE(domain) , POINTER :: parent, nest
  899. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  900. ! Local
  901. INTEGER :: idum1 , idum2 , fid, rc
  902. INTEGER :: ids , ide , jds , jde , kds , kde , &
  903. ims , ime , jms , jme , kms , kme , &
  904. ips , ipe , jps , jpe , kps , kpe
  905. INTEGER i,j
  906. INTERFACE
  907. SUBROUTINE med_feedback_domain ( parent , nest )
  908. USE module_domain , ONLY : domain
  909. TYPE(domain) , POINTER :: parent , nest
  910. END SUBROUTINE med_feedback_domain
  911. END INTERFACE
  912. ! feedback nest to the parent
  913. IF ( config_flags%feedback .NE. 0 ) THEN
  914. CALL med_feedback_domain( parent, nest )
  915. #ifdef MOVE_NESTS
  916. CALL get_ijk_from_grid ( parent , &
  917. ids, ide, jds, jde, kds, kde, &
  918. ims, ime, jms, jme, kms, kme, &
  919. ips, ipe, jps, jpe, kps, kpe )
  920. ! gopal's change- added ifdef
  921. #if ( EM_CORE == 1 )
  922. DO j = jps, MIN(jpe,jde-1)
  923. DO i = ips, MIN(ipe,ide-1)
  924. IF ( parent%nest_pos(i,j) .EQ. 9021000. ) THEN
  925. parent%nest_pos(i,j) = parent%ht(i,j)*1.5 + 1000.
  926. ELSE IF ( parent%ht(i,j) .NE. 0. ) THEN
  927. parent%nest_pos(i,j) = parent%ht(i,j) + 500.
  928. ELSE
  929. parent%nest_pos(i,j) = 0.
  930. ENDIF
  931. ENDDO
  932. ENDDO
  933. #endif
  934. #endif
  935. END IF
  936. RETURN
  937. END SUBROUTINE med_nest_feedback
  938. SUBROUTINE med_last_solve_io ( grid , config_flags )
  939. ! Driver layer
  940. USE module_state_description
  941. USE module_domain , ONLY : domain, domain_clock_get
  942. USE module_configure , ONLY : grid_config_rec_type
  943. USE module_utility
  944. USE module_streams
  945. ! Model layer
  946. IMPLICIT NONE
  947. ! Arguments
  948. TYPE(domain) :: grid
  949. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  950. ! Local
  951. INTEGER :: rc
  952. #ifdef HWRF
  953. !zhang's doing
  954. TYPE(WRFU_Time) :: CurrTime !zhang new
  955. INTEGER :: hr, min, sec, ms,julyr,julday
  956. REAL :: GMT
  957. !end of zhang's doing
  958. #endif
  959. ! #if (EM_CORE == 1)
  960. IF( WRFU_AlarmIsRinging( grid%alarms( HISTORY_ALARM ), rc=rc ) .AND. &
  961. (grid%dfi_write_dfi_history .OR. grid%dfi_stage == DFI_FST .OR. grid%dfi_opt == DFI_NODFI) ) THEN
  962. ! #else
  963. ! IF( WRFU_AlarmIsRinging( grid%alarms( HISTORY_ALARM ), rc=rc )) THEN
  964. ! #endif
  965. CALL med_hist_out ( grid , HISTORY_ALARM , config_flags )
  966. ENDIF
  967. IF( WRFU_AlarmIsRinging( grid%alarms( INPUTOUT_ALARM ), rc=rc ) ) THEN
  968. CALL med_filter_out ( grid , config_flags )
  969. ENDIF
  970. ! registry-generated file of the following
  971. ! IF( WRFU_AlarmIsRinging( grid%alarms( AUXHIST1_ALARM ), rc=rc ) ) THEN
  972. ! CALL med_hist_out ( grid , AUXHIST1_ALARM , config_flags )
  973. ! ENDIF
  974. #include "med_last_solve_io.inc"
  975. ! - RESTART OUTPUT
  976. IF( WRFU_AlarmIsRinging( grid%alarms( RESTART_ALARM ), rc=rc ) ) THEN
  977. #ifdef HWRF
  978. !zhang's doing
  979. !zhang new CALL ESMF_TimeGet( grid%current_time, YY=julyr, dayOfYear=julday, H=hr, M=min, S=sec, MS=ms, rc=rc)
  980. CALL domain_clock_get( grid, current_time=CurrTime )
  981. CALL WRFU_TimeGet( CurrTime, YY=julyr, dayOfYear=julday, H=hr, M=min, S=sec, MS=ms, rc=rc)
  982. gmt=hr+real(min)/60.+real(sec)/3600.+real(ms)/(1000*3600)
  983. if (grid%id .eq. 2) call med_namelist_out ( grid , config_flags )
  984. !end of zhang's doing
  985. #endif
  986. IF ( grid%id .EQ. 1 ) THEN
  987. CALL med_restart_out ( grid , config_flags )
  988. ENDIF
  989. ENDIF
  990. ! Write out time series
  991. CALL write_ts( grid )
  992. RETURN
  993. END SUBROUTINE med_last_solve_io
  994. #endif
  995. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  996. #ifdef HWRF
  997. !==================================================================================
  998. ! Added for the NMM 3d var. This is simply an extension of med_restart_out.
  999. ! The file is simply called wrfanal***. This is gopal's doing
  1000. !===================================================================================
  1001. !
  1002. SUBROUTINE med_analysis_in ( grid , config_flags )
  1003. ! Driver layer
  1004. USE module_domain , ONLY : domain, domain_clock_get
  1005. USE module_io_domain
  1006. USE module_timing
  1007. ! Model layer
  1008. USE module_configure , ONLY : grid_config_rec_type
  1009. USE module_bc_time_utilities
  1010. !zhang USE WRF_ESMF_MOD
  1011. IMPLICIT NONE
  1012. ! Arguments
  1013. TYPE(domain) :: grid
  1014. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  1015. ! Local
  1016. LOGICAL, EXTERNAL :: wrf_dm_on_monitor
  1017. CHARACTER*80 :: rstname , outname
  1018. INTEGER :: fid , rid
  1019. CHARACTER (LEN=256) :: message
  1020. INTEGER :: ierr
  1021. INTEGER :: myproc
  1022. !zhang old TYPE(ESMF_Time) :: CurrTime
  1023. TYPE(WRFU_Time) :: CurrTime
  1024. CHARACTER*80 :: timestr
  1025. IF ( wrf_dm_on_monitor() ) THEN
  1026. CALL start_timing
  1027. END IF
  1028. rid=grid%id
  1029. !zhang's doing CALL ESMF_ClockGet( grid%domain_clock, CurrTime=CurrTime, rc=ierr )
  1030. !zhang's doing CALL wrf_timetoa ( CurrTime, timestr )
  1031. CALL domain_clock_get( grid, current_timestr=timestr )
  1032. CALL construct_filename2a ( rstname ,config_flags%anl_outname, grid%id , 2 , timestr )
  1033. WRITE( message , '("med_analysis_in: opening ",A," for reading")' ) TRIM ( rstname )
  1034. CALL wrf_debug( 1 , message )
  1035. CALL open_r_dataset ( rid, TRIM(rstname), grid , &
  1036. config_flags , "DATASET=RESTART", ierr )
  1037. IF ( ierr .NE. 0 ) THEN
  1038. ! Could not open the analysis file, so notify user.
  1039. write(message,'(A,I0,A,A,A)') 'WARNING: Domain ',grid%id,' analysis file ',trim(rstname),' is missing.'
  1040. call wrf_message(message)
  1041. write(message,'(A,I0,A)') '-------> Domain ',grid%id,' running as a cold start (interp from parent).'
  1042. call wrf_message(message)
  1043. IF ( wrf_dm_on_monitor() ) THEN
  1044. WRITE (message, '("Failing to read restart for domain ",I8)') grid%id
  1045. CALL end_timing ( TRIM(message) )
  1046. END IF
  1047. return
  1048. ELSE
  1049. ! Was able to open the analysis file. Read it as a restart file.
  1050. CALL input_restart ( rid, grid , config_flags , ierr )
  1051. IF ( wrf_dm_on_monitor() ) THEN
  1052. WRITE ( message , FMT = '("Reading restart for domain ",I8)' ) grid%id
  1053. CALL end_timing ( TRIM(message) )
  1054. END IF
  1055. CALL close_dataset ( rid , config_flags , "DATASET=RESTART" )
  1056. ENDIF
  1057. RETURN
  1058. END SUBROUTINE med_analysis_in
  1059. !=========================================================================================================
  1060. !=========================================================================================================
  1061. SUBROUTINE med_analysis_out ( grid , config_flags )
  1062. ! Driver layer
  1063. USE module_domain , ONLY : domain, domain_clock_get
  1064. USE module_io_domain
  1065. USE module_timing
  1066. ! Model layer
  1067. USE module_configure , ONLY : grid_config_rec_type
  1068. USE module_bc_time_utilities
  1069. !zhang USE WRF_ESMF_MOD
  1070. IMPLICIT NONE
  1071. ! Arguments
  1072. TYPE(domain) :: grid
  1073. TYPE (grid_config_rec_type) , INTENT(IN) :: config_flags
  1074. ! Local
  1075. LOGICAL, EXTERNAL :: wrf_dm_on_monitor
  1076. CHARACTER*80 :: rstname , outname
  1077. INTEGER :: fid , rid
  1078. CHARACTER (LEN=256) :: message
  1079. INTEGER

Large files files are truncated, but you can click here to view the full file