1 | ! Create an initial data set for the WRF model based on real data. This |
---|
2 | ! program is specifically set up for the Eulerian, mass-based coordinate. |
---|
3 | PROGRAM real_data |
---|
4 | |
---|
5 | USE module_machine |
---|
6 | USE module_domain |
---|
7 | USE module_initialize |
---|
8 | USE module_io_domain |
---|
9 | USE module_driver_constants |
---|
10 | USE module_configure |
---|
11 | USE module_timing |
---|
12 | #ifdef WRF_CHEM |
---|
13 | USE module_input_chem_data |
---|
14 | USE module_input_chem_bioemiss |
---|
15 | #endif |
---|
16 | USE module_utility |
---|
17 | #ifdef DM_PARALLEL |
---|
18 | USE module_dm |
---|
19 | #endif |
---|
20 | |
---|
21 | IMPLICIT NONE |
---|
22 | |
---|
23 | #ifdef WRF_CHEM |
---|
24 | ! interface |
---|
25 | INTERFACE |
---|
26 | ! mediation-supplied |
---|
27 | SUBROUTINE med_read_wrf_chem_bioemiss ( grid , config_flags) |
---|
28 | USE module_domain |
---|
29 | TYPE (domain) grid |
---|
30 | TYPE (grid_config_rec_type) config_flags |
---|
31 | END SUBROUTINE med_read_wrf_chem_bioemiss |
---|
32 | END INTERFACE |
---|
33 | #endif |
---|
34 | |
---|
35 | REAL :: time , bdyfrq |
---|
36 | |
---|
37 | INTEGER :: loop , levels_to_process , debug_level |
---|
38 | |
---|
39 | |
---|
40 | TYPE(domain) , POINTER :: null_domain |
---|
41 | TYPE(domain) , POINTER :: grid , another_grid |
---|
42 | TYPE(domain) , POINTER :: grid_ptr , grid_ptr2 |
---|
43 | TYPE (grid_config_rec_type) :: config_flags |
---|
44 | INTEGER :: number_at_same_level |
---|
45 | |
---|
46 | INTEGER :: max_dom, domain_id , grid_id , parent_id , parent_id1 , id |
---|
47 | INTEGER :: e_we , e_sn , i_parent_start , j_parent_start |
---|
48 | INTEGER :: idum1, idum2 |
---|
49 | #ifdef DM_PARALLEL |
---|
50 | INTEGER :: nbytes |
---|
51 | INTEGER, PARAMETER :: configbuflen = 4* CONFIG_BUF_LEN |
---|
52 | INTEGER :: configbuf( configbuflen ) |
---|
53 | LOGICAL , EXTERNAL :: wrf_dm_on_monitor |
---|
54 | #endif |
---|
55 | LOGICAL found_the_id |
---|
56 | |
---|
57 | INTEGER :: ids , ide , jds , jde , kds , kde |
---|
58 | INTEGER :: ims , ime , jms , jme , kms , kme |
---|
59 | INTEGER :: ips , ipe , jps , jpe , kps , kpe |
---|
60 | INTEGER :: ijds , ijde , spec_bdy_width |
---|
61 | INTEGER :: i , j , k , idts, rc |
---|
62 | INTEGER :: sibling_count , parent_id_hold , dom_loop |
---|
63 | |
---|
64 | CHARACTER (LEN=80) :: message |
---|
65 | |
---|
66 | INTEGER :: start_year , start_month , start_day , start_hour , start_minute , start_second |
---|
67 | INTEGER :: end_year , end_month , end_day , end_hour , end_minute , end_second |
---|
68 | INTEGER :: interval_seconds , real_data_init_type |
---|
69 | INTEGER :: time_loop_max , time_loop |
---|
70 | real::t1,t2 |
---|
71 | INTERFACE |
---|
72 | SUBROUTINE Setup_Timekeeping( grid ) |
---|
73 | USE module_domain |
---|
74 | TYPE(domain), POINTER :: grid |
---|
75 | END SUBROUTINE Setup_Timekeeping |
---|
76 | END INTERFACE |
---|
77 | |
---|
78 | #include "version_decl" |
---|
79 | |
---|
80 | ! Define the name of this program (program_name defined in module_domain) |
---|
81 | |
---|
82 | ! NOTE: share/input_wrf.F tests first 7 chars of this name to decide |
---|
83 | ! whether to read P_TOP as metadata from the SI (yes, if .eq. REAL_EM) |
---|
84 | |
---|
85 | program_name = "REAL_EM " // TRIM(release_version) // " PREPROCESSOR" |
---|
86 | |
---|
87 | #ifdef DM_PARALLEL |
---|
88 | CALL disable_quilting |
---|
89 | #endif |
---|
90 | |
---|
91 | ! Initialize the modules used by the WRF system. Many of the CALLs made from the |
---|
92 | ! init_modules routine are NO-OPs. Typical initializations are: the size of a |
---|
93 | ! REAL, setting the file handles to a pre-use value, defining moisture and |
---|
94 | ! chemistry indices, etc. |
---|
95 | |
---|
96 | CALL wrf_debug ( 100 , 'real_em: calling init_modules ' ) |
---|
97 | CALL init_modules(1) ! Phase 1 returns after MPI_INIT() (if it is called) |
---|
98 | CALL WRFU_Initialize( defaultCalendar=WRFU_CAL_GREGORIAN, rc=rc ) |
---|
99 | CALL init_modules(2) ! Phase 2 resumes after MPI_INIT() (if it is called) |
---|
100 | |
---|
101 | ! The configuration switches mostly come from the NAMELIST input. |
---|
102 | |
---|
103 | #ifdef DM_PARALLEL |
---|
104 | IF ( wrf_dm_on_monitor() ) THEN |
---|
105 | CALL initial_config |
---|
106 | ENDIF |
---|
107 | CALL get_config_as_buffer( configbuf, configbuflen, nbytes ) |
---|
108 | CALL wrf_dm_bcast_bytes( configbuf, nbytes ) |
---|
109 | CALL set_config_as_buffer( configbuf, configbuflen ) |
---|
110 | CALL wrf_dm_initialize |
---|
111 | #else |
---|
112 | CALL initial_config |
---|
113 | #endif |
---|
114 | |
---|
115 | CALL nl_get_debug_level ( 1, debug_level ) |
---|
116 | CALL set_wrf_debug_level ( debug_level ) |
---|
117 | |
---|
118 | CALL wrf_message ( program_name ) |
---|
119 | |
---|
120 | ! Allocate the space for the mother of all domains. |
---|
121 | |
---|
122 | NULLIFY( null_domain ) |
---|
123 | CALL wrf_debug ( 100 , 'real_em: calling alloc_and_configure_domain ' ) |
---|
124 | CALL alloc_and_configure_domain ( domain_id = 1 , & |
---|
125 | grid = head_grid , & |
---|
126 | parent = null_domain , & |
---|
127 | kid = -1 ) |
---|
128 | |
---|
129 | grid => head_grid |
---|
130 | CALL nl_get_max_dom ( 1 , max_dom ) |
---|
131 | |
---|
132 | IF ( model_config_rec%interval_seconds .LE. 0 ) THEN |
---|
133 | CALL wrf_error_fatal( 'namelist value for interval_seconds must be > 0') |
---|
134 | ENDIF |
---|
135 | |
---|
136 | all_domains : DO domain_id = 1 , max_dom |
---|
137 | |
---|
138 | IF ( ( model_config_rec%input_from_file(domain_id) ) .OR. & |
---|
139 | ( domain_id .EQ. 1 ) ) THEN |
---|
140 | |
---|
141 | IF ( domain_id .GT. 1 ) THEN |
---|
142 | |
---|
143 | CALL nl_get_grid_id ( domain_id, grid_id ) |
---|
144 | CALL nl_get_parent_id ( domain_id, parent_id ) |
---|
145 | CALL nl_get_e_we ( domain_id, e_we ) |
---|
146 | CALL nl_get_e_sn ( domain_id, e_sn ) |
---|
147 | CALL nl_get_i_parent_start ( domain_id, i_parent_start ) |
---|
148 | CALL nl_get_j_parent_start ( domain_id, j_parent_start ) |
---|
149 | WRITE (message,FMT='(A,2I3,2I4,2I3)') & |
---|
150 | 'new allocated domain: id, par id, dims i/j, start i/j =', & |
---|
151 | grid_id, parent_id, e_we, e_sn, i_parent_start, j_parent_start |
---|
152 | |
---|
153 | CALL wrf_debug ( 100 , message ) |
---|
154 | CALL nl_get_grid_id ( parent_id, grid_id ) |
---|
155 | CALL nl_get_parent_id ( parent_id, parent_id1 ) |
---|
156 | CALL nl_get_e_we ( parent_id, e_we ) |
---|
157 | CALL nl_get_e_sn ( parent_id, e_sn ) |
---|
158 | CALL nl_get_i_parent_start ( parent_id, i_parent_start ) |
---|
159 | CALL nl_get_j_parent_start ( parent_id, j_parent_start ) |
---|
160 | WRITE (message,FMT='(A,2I3,2I4,2I3)') & |
---|
161 | 'parent domain: id, par id, dims i/j, start i/j =', & |
---|
162 | grid_id, parent_id1, e_we, e_sn, i_parent_start, j_parent_start |
---|
163 | CALL wrf_debug ( 100 , message ) |
---|
164 | |
---|
165 | CALL nl_get_grid_id ( domain_id, grid_id ) |
---|
166 | CALL nl_get_parent_id ( domain_id, parent_id ) |
---|
167 | CALL nl_get_e_we ( domain_id, e_we ) |
---|
168 | CALL nl_get_e_sn ( domain_id, e_sn ) |
---|
169 | CALL nl_get_i_parent_start ( domain_id, i_parent_start ) |
---|
170 | CALL nl_get_j_parent_start ( domain_id, j_parent_start ) |
---|
171 | grid_ptr2 => head_grid |
---|
172 | found_the_id = .FALSE. |
---|
173 | CALL find_my_parent ( grid_ptr2 , grid_ptr , domain_id , parent_id , found_the_id ) |
---|
174 | IF ( found_the_id ) THEN |
---|
175 | |
---|
176 | sibling_count = 0 |
---|
177 | DO dom_loop = 2 , domain_id |
---|
178 | CALL nl_get_parent_id ( dom_loop, parent_id_hold ) |
---|
179 | IF ( parent_id_hold .EQ. parent_id ) THEN |
---|
180 | sibling_count = sibling_count + 1 |
---|
181 | END IF |
---|
182 | END DO |
---|
183 | CALL alloc_and_configure_domain ( domain_id = domain_id , & |
---|
184 | grid = another_grid , & |
---|
185 | parent = grid_ptr , & |
---|
186 | kid = sibling_count ) |
---|
187 | grid => another_grid |
---|
188 | ELSE |
---|
189 | CALL wrf_error_fatal( 'real_em.F: Could not find the parent domain') |
---|
190 | END IF |
---|
191 | END IF |
---|
192 | |
---|
193 | CALL Setup_Timekeeping ( grid ) |
---|
194 | CALL set_current_grid_ptr( grid ) |
---|
195 | CALL domain_clockprint ( 150, grid, & |
---|
196 | 'DEBUG real: clock after Setup_Timekeeping,' ) |
---|
197 | CALL domain_clock_set( grid, & |
---|
198 | time_step_seconds=model_config_rec%interval_seconds ) |
---|
199 | CALL domain_clockprint ( 150, grid, & |
---|
200 | 'DEBUG real: clock after timeStep set,' ) |
---|
201 | |
---|
202 | |
---|
203 | CALL wrf_debug ( 100 , 'real_em: calling set_scalar_indices_from_config ' ) |
---|
204 | CALL set_scalar_indices_from_config ( grid%id , idum1, idum2 ) |
---|
205 | |
---|
206 | CALL wrf_debug ( 100 , 'real_em: calling model_to_grid_config_rec ' ) |
---|
207 | CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags ) |
---|
208 | |
---|
209 | ! Initialize the WRF IO: open files, init file handles, etc. |
---|
210 | |
---|
211 | CALL wrf_debug ( 100 , 'real_em: calling init_wrfio' ) |
---|
212 | CALL init_wrfio |
---|
213 | |
---|
214 | |
---|
215 | ! Some of the configuration values may have been modified from the initial READ |
---|
216 | ! of the NAMELIST, so we re-broadcast the configuration records. |
---|
217 | |
---|
218 | #ifdef DM_PARALLEL |
---|
219 | CALL wrf_debug ( 100 , 'real_em: re-broadcast the configuration records' ) |
---|
220 | CALL get_config_as_buffer( configbuf, configbuflen, nbytes ) |
---|
221 | CALL wrf_dm_bcast_bytes( configbuf, nbytes ) |
---|
222 | CALL set_config_as_buffer( configbuf, configbuflen ) |
---|
223 | #endif |
---|
224 | |
---|
225 | ! No looping in this layer. |
---|
226 | |
---|
227 | CALL wrf_debug ( 100 , 'calling med_sidata_input' ) |
---|
228 | CALL med_sidata_input ( grid , config_flags ) |
---|
229 | CALL wrf_debug ( 100 , 'backfrom med_sidata_input' ) |
---|
230 | |
---|
231 | ELSE |
---|
232 | CYCLE all_domains |
---|
233 | END IF |
---|
234 | |
---|
235 | END DO all_domains |
---|
236 | |
---|
237 | CALL set_current_grid_ptr( head_grid ) |
---|
238 | |
---|
239 | ! We are done. |
---|
240 | |
---|
241 | CALL wrf_debug ( 0 , 'real_em: SUCCESS COMPLETE REAL_EM INIT' ) |
---|
242 | |
---|
243 | CALL wrf_shutdown |
---|
244 | |
---|
245 | CALL WRFU_Finalize( rc=rc ) |
---|
246 | |
---|
247 | END PROGRAM real_data |
---|
248 | |
---|
249 | SUBROUTINE med_sidata_input ( grid , config_flags ) |
---|
250 | ! Driver layer |
---|
251 | USE module_domain |
---|
252 | USE module_io_domain |
---|
253 | ! Model layer |
---|
254 | USE module_configure |
---|
255 | USE module_bc_time_utilities |
---|
256 | USE module_initialize |
---|
257 | USE module_optional_si_input |
---|
258 | #ifdef WRF_CHEM |
---|
259 | USE module_input_chem_data |
---|
260 | USE module_input_chem_bioemiss |
---|
261 | #endif |
---|
262 | |
---|
263 | USE module_date_time |
---|
264 | USE module_utility |
---|
265 | |
---|
266 | IMPLICIT NONE |
---|
267 | |
---|
268 | |
---|
269 | ! Interface |
---|
270 | INTERFACE |
---|
271 | SUBROUTINE start_domain ( grid , allowed_to_read ) ! comes from module_start in appropriate dyn_ directory |
---|
272 | USE module_domain |
---|
273 | TYPE (domain) grid |
---|
274 | LOGICAL, INTENT(IN) :: allowed_to_read |
---|
275 | END SUBROUTINE start_domain |
---|
276 | END INTERFACE |
---|
277 | |
---|
278 | ! Arguments |
---|
279 | TYPE(domain) :: grid |
---|
280 | TYPE (grid_config_rec_type) :: config_flags |
---|
281 | ! Local |
---|
282 | INTEGER :: time_step_begin_restart |
---|
283 | INTEGER :: idsi , ierr , myproc |
---|
284 | CHARACTER (LEN=80) :: si_inpname |
---|
285 | CHARACTER (LEN=80) :: message |
---|
286 | |
---|
287 | CHARACTER(LEN=19) :: start_date_char , end_date_char , current_date_char , next_date_char |
---|
288 | |
---|
289 | INTEGER :: time_loop_max , loop, rc |
---|
290 | INTEGER :: julyr , julday |
---|
291 | REAL :: gmt |
---|
292 | real::t1,t2,t3,t4 |
---|
293 | |
---|
294 | grid%input_from_file = .true. |
---|
295 | grid%input_from_file = .false. |
---|
296 | |
---|
297 | CALL compute_si_start_and_end ( model_config_rec%start_year (grid%id) , & |
---|
298 | model_config_rec%start_month (grid%id) , & |
---|
299 | model_config_rec%start_day (grid%id) , & |
---|
300 | model_config_rec%start_hour (grid%id) , & |
---|
301 | model_config_rec%start_minute(grid%id) , & |
---|
302 | model_config_rec%start_second(grid%id) , & |
---|
303 | model_config_rec% end_year (grid%id) , & |
---|
304 | model_config_rec% end_month (grid%id) , & |
---|
305 | model_config_rec% end_day (grid%id) , & |
---|
306 | model_config_rec% end_hour (grid%id) , & |
---|
307 | model_config_rec% end_minute(grid%id) , & |
---|
308 | model_config_rec% end_second(grid%id) , & |
---|
309 | model_config_rec%interval_seconds , & |
---|
310 | model_config_rec%real_data_init_type , & |
---|
311 | start_date_char , end_date_char , time_loop_max ) |
---|
312 | |
---|
313 | ! Override stop time with value computed above. |
---|
314 | CALL domain_clock_set( grid, stop_timestr=end_date_char ) |
---|
315 | |
---|
316 | ! TBH: for now, turn off stop time and let it run data-driven |
---|
317 | CALL WRFU_ClockStopTimeDisable( grid%domain_clock, rc=rc ) |
---|
318 | CALL wrf_check_error( WRFU_SUCCESS, rc, & |
---|
319 | 'WRFU_ClockStopTimeDisable(grid%domain_clock) FAILED', & |
---|
320 | __FILE__ , & |
---|
321 | __LINE__ ) |
---|
322 | CALL domain_clockprint ( 150, grid, & |
---|
323 | 'DEBUG med_sidata_input: clock after stopTime set,' ) |
---|
324 | |
---|
325 | ! Here we define the initial time to process, for later use by the code. |
---|
326 | |
---|
327 | current_date_char = start_date_char |
---|
328 | start_date = start_date_char // '.0000' |
---|
329 | current_date = start_date |
---|
330 | |
---|
331 | CALL nl_set_bdyfrq ( grid%id , REAL(model_config_rec%interval_seconds) ) |
---|
332 | |
---|
333 | !!!!!!! Loop over each time period to process. |
---|
334 | |
---|
335 | CALL cpu_time ( t1 ) |
---|
336 | DO loop = 1 , time_loop_max |
---|
337 | |
---|
338 | internal_time_loop = loop |
---|
339 | IF ( ( grid%id .GT. 1 ) .AND. ( loop .GT. 1 ) .AND. (model_config_rec%grid_fdda(grid%id) .EQ. 0) ) EXIT |
---|
340 | |
---|
341 | print *,' ' |
---|
342 | print *,'-----------------------------------------------------------------------------' |
---|
343 | print *,' ' |
---|
344 | print '(A,I2,A,A,A,I2,A,I2)' , & |
---|
345 | ' Domain ',grid%id,': Current date being processed: ',current_date, ', which is loop #',loop,' out of ',time_loop_max |
---|
346 | |
---|
347 | ! After current_date has been set, fill in the julgmt stuff. |
---|
348 | |
---|
349 | CALL geth_julgmt ( config_flags%julyr , config_flags%julday , config_flags%gmt ) |
---|
350 | |
---|
351 | print *,'configflags%julyr, %julday, %gmt:',config_flags%julyr, config_flags%julday, config_flags%gmt |
---|
352 | ! Now that the specific Julian info is available, save these in the model config record. |
---|
353 | |
---|
354 | CALL nl_set_gmt (grid%id, config_flags%gmt) |
---|
355 | CALL nl_set_julyr (grid%id, config_flags%julyr) |
---|
356 | CALL nl_set_julday (grid%id, config_flags%julday) |
---|
357 | |
---|
358 | ! Open the input file for real. This is either the "new" one or the "old" one. The "new" one could have |
---|
359 | ! a suffix for the type of the data format. Check to see if either is around. |
---|
360 | |
---|
361 | CALL cpu_time ( t3 ) |
---|
362 | IF ( grid%dyn_opt .EQ. dyn_em ) THEN |
---|
363 | WRITE ( wrf_err_message , FMT='(A,A)' )'med_sidata_input: calling open_r_dataset for ', & |
---|
364 | TRIM(config_flags%auxinput1_inname) |
---|
365 | CALL wrf_debug ( 100 , wrf_err_message ) |
---|
366 | CALL construct_filename4a( si_inpname , config_flags%auxinput1_inname , grid%id , 2 , & |
---|
367 | current_date_char , config_flags%io_form_auxinput1 ) |
---|
368 | CALL open_r_dataset ( idsi, TRIM(si_inpname) , grid , config_flags , "DATASET=AUXINPUT1", ierr ) |
---|
369 | IF ( ierr .NE. 0 ) THEN |
---|
370 | CALL wrf_debug( 1 , 'error opening ' // TRIM(si_inpname) // & |
---|
371 | ' for input; bad date in namelist or file not in directory' ) |
---|
372 | CALL wrf_debug( 1 , 'will try again without the extension' ) |
---|
373 | CALL construct_filename2a( si_inpname , config_flags%auxinput1_inname , grid%id , 2 , current_date_char ) |
---|
374 | CALL open_r_dataset ( idsi, TRIM(si_inpname) , grid , config_flags , "DATASET=AUXINPUT1", ierr ) |
---|
375 | IF ( ierr .NE. 0 ) THEN |
---|
376 | CALL wrf_error_fatal( 'error opening ' // TRIM(si_inpname) // & |
---|
377 | ' for input; bad date in namelist or file not in directory' ) |
---|
378 | ENDIF |
---|
379 | ENDIF |
---|
380 | END IF |
---|
381 | |
---|
382 | ! Input data. |
---|
383 | |
---|
384 | CALL wrf_debug ( 100 , 'med_sidata_input: calling input_aux_model_input1' ) |
---|
385 | CALL input_aux_model_input1 ( idsi , grid , config_flags , ierr ) |
---|
386 | CALL cpu_time ( t4 ) |
---|
387 | WRITE ( wrf_err_message , FMT='(A,I10,A)' ) 'Timing for input ',NINT(t4-t3) ,' s.' |
---|
388 | CALL wrf_debug( 0, wrf_err_message ) |
---|
389 | |
---|
390 | ! Possible optional SI input. This sets flags used by init_domain. |
---|
391 | |
---|
392 | CALL cpu_time ( t3 ) |
---|
393 | IF ( loop .EQ. 1 ) THEN |
---|
394 | already_been_here = .FALSE. |
---|
395 | CALL wrf_debug ( 100 , 'med_sidata_input: calling init_module_optional_si_input' ) |
---|
396 | CALL init_module_optional_si_input ( grid , config_flags ) |
---|
397 | END IF |
---|
398 | CALL wrf_debug ( 100 , 'med_sidata_input: calling optional_si_input' ) |
---|
399 | CALL optional_si_input ( grid , idsi ) |
---|
400 | |
---|
401 | ! Initialize the mother domain for this time period with input data. |
---|
402 | |
---|
403 | CALL wrf_debug ( 100 , 'med_sidata_input: calling init_domain' ) |
---|
404 | grid%input_from_file = .true. |
---|
405 | CALL init_domain ( grid ) |
---|
406 | CALL cpu_time ( t4 ) |
---|
407 | WRITE ( wrf_err_message , FMT='(A,I10,A)' ) 'Timing for processing ',NINT(t4-t3) ,' s.' |
---|
408 | CALL wrf_debug( 0, wrf_err_message ) |
---|
409 | CALL model_to_grid_config_rec ( grid%id , model_config_rec , config_flags ) |
---|
410 | |
---|
411 | ! Close this file that is output from the SI and input to this pre-proc. |
---|
412 | |
---|
413 | CALL wrf_debug ( 100 , 'med_sidata_input: back from init_domain' ) |
---|
414 | CALL close_dataset ( idsi , config_flags , "DATASET=INPUT" ) |
---|
415 | |
---|
416 | ! CALL start_domain ( grid , .TRUE. ) |
---|
417 | |
---|
418 | #ifdef WRF_CHEM |
---|
419 | IF ( loop == 1 ) THEN |
---|
420 | IF( grid%chem_opt > 0 ) then |
---|
421 | ! Read the chemistry data from a previous wrf forecast (wrfout file) |
---|
422 | IF(grid%chem_in_opt == 1 ) THEN |
---|
423 | message = 'INITIALIZING CHEMISTRY WITH OLD SIMULATION' |
---|
424 | CALL wrf_message ( message ) |
---|
425 | |
---|
426 | CALL input_ext_chem_file( grid ) |
---|
427 | |
---|
428 | IF(grid%bio_emiss_opt == BEIS311 ) THEN |
---|
429 | message = 'READING BEIS3.11 EMISSIONS DATA' |
---|
430 | CALL wrf_message ( message ) |
---|
431 | CALL med_read_wrf_chem_bioemiss ( grid , config_flags) |
---|
432 | END IF |
---|
433 | |
---|
434 | ELSEIF(grid%chem_in_opt == 0)then |
---|
435 | ! Generate chemistry data from a idealized vertical profile |
---|
436 | message = 'STARTING WITH BACKGROUND CHEMISTRY ' |
---|
437 | CALL wrf_message ( message ) |
---|
438 | |
---|
439 | CALL input_chem_profile ( grid ) |
---|
440 | |
---|
441 | IF(grid%bio_emiss_opt == BEIS311 ) THEN |
---|
442 | message = 'READING BEIS3.11 EMISSIONS DATA' |
---|
443 | CALL wrf_message ( message ) |
---|
444 | CALL med_read_wrf_chem_bioemiss ( grid , config_flags) |
---|
445 | END IF |
---|
446 | |
---|
447 | ELSE |
---|
448 | message = 'RUNNING WITHOUT CHEMISTRY INITIALIZATION' |
---|
449 | CALL wrf_message ( message ) |
---|
450 | ENDIF |
---|
451 | ENDIF |
---|
452 | ENDIF |
---|
453 | #endif |
---|
454 | |
---|
455 | CALL cpu_time ( t3 ) |
---|
456 | CALL assemble_output ( grid , config_flags , loop , time_loop_max ) |
---|
457 | CALL cpu_time ( t4 ) |
---|
458 | WRITE ( wrf_err_message , FMT='(A,I10,A)' ) 'Timing for output ',NINT(t4-t3) ,' s.' |
---|
459 | CALL wrf_debug( 0, wrf_err_message ) |
---|
460 | CALL cpu_time ( t2 ) |
---|
461 | WRITE ( wrf_err_message , FMT='(A,I4,A,I10,A)' ) 'Timing for loop # ',loop,' = ',NINT(t2-t1) ,' s.' |
---|
462 | CALL wrf_debug( 0, wrf_err_message ) |
---|
463 | |
---|
464 | ! If this is not the last time, we define the next time that we are going to process. |
---|
465 | |
---|
466 | IF ( loop .NE. time_loop_max ) THEN |
---|
467 | CALL geth_newdate ( current_date_char , start_date_char , loop * model_config_rec%interval_seconds ) |
---|
468 | current_date = current_date_char // '.0000' |
---|
469 | CALL domain_clockprint ( 150, grid, & |
---|
470 | 'DEBUG med_sidata_input: clock before current_date set,' ) |
---|
471 | WRITE (wrf_err_message,*) & |
---|
472 | 'DEBUG med_sidata_input: before currTime set, current_date = ',TRIM(current_date) |
---|
473 | CALL wrf_debug ( 150 , wrf_err_message ) |
---|
474 | CALL domain_clock_set( grid, current_date(1:19) ) |
---|
475 | CALL domain_clockprint ( 150, grid, & |
---|
476 | 'DEBUG med_sidata_input: clock after current_date set,' ) |
---|
477 | END IF |
---|
478 | CALL cpu_time ( t1 ) |
---|
479 | END DO |
---|
480 | |
---|
481 | END SUBROUTINE med_sidata_input |
---|
482 | |
---|
483 | SUBROUTINE compute_si_start_and_end ( & |
---|
484 | start_year , start_month , start_day , start_hour , start_minute , start_second , & |
---|
485 | end_year , end_month , end_day , end_hour , end_minute , end_second , & |
---|
486 | interval_seconds , real_data_init_type , & |
---|
487 | start_date_char , end_date_char , time_loop_max ) |
---|
488 | |
---|
489 | USE module_date_time |
---|
490 | |
---|
491 | IMPLICIT NONE |
---|
492 | |
---|
493 | INTEGER :: start_year , start_month , start_day , start_hour , start_minute , start_second |
---|
494 | INTEGER :: end_year , end_month , end_day , end_hour , end_minute , end_second |
---|
495 | INTEGER :: interval_seconds , real_data_init_type |
---|
496 | INTEGER :: time_loop_max , time_loop |
---|
497 | |
---|
498 | CHARACTER(LEN=19) :: current_date_char , start_date_char , end_date_char , next_date_char |
---|
499 | |
---|
500 | WRITE ( start_date_char , FMT = '(I4.4,"-",I2.2,"-",I2.2,"_",I2.2,":",I2.2,":",I2.2)' ) & |
---|
501 | start_year,start_month,start_day,start_hour,start_minute,start_second |
---|
502 | WRITE ( end_date_char , FMT = '(I4.4,"-",I2.2,"-",I2.2,"_",I2.2,":",I2.2,":",I2.2)' ) & |
---|
503 | end_year, end_month, end_day, end_hour, end_minute, end_second |
---|
504 | |
---|
505 | IF ( end_date_char .LT. start_date_char ) THEN |
---|
506 | CALL wrf_error_fatal( 'Ending date in namelist ' // end_date_char // ' prior to beginning date ' // start_date_char ) |
---|
507 | END IF |
---|
508 | |
---|
509 | ! start_date = start_date_char // '.0000' |
---|
510 | |
---|
511 | ! Figure out our loop count for the processing times. |
---|
512 | |
---|
513 | time_loop = 1 |
---|
514 | PRINT '(A,I4,A,A,A)','Time period #',time_loop,' to process = ',start_date_char,'.' |
---|
515 | current_date_char = start_date_char |
---|
516 | loop_count : DO |
---|
517 | CALL geth_newdate ( next_date_char , current_date_char , interval_seconds ) |
---|
518 | IF ( next_date_char .LT. end_date_char ) THEN |
---|
519 | time_loop = time_loop + 1 |
---|
520 | PRINT '(A,I4,A,A,A)','Time period #',time_loop,' to process = ',next_date_char,'.' |
---|
521 | current_date_char = next_date_char |
---|
522 | ELSE IF ( next_date_char .EQ. end_date_char ) THEN |
---|
523 | time_loop = time_loop + 1 |
---|
524 | PRINT '(A,I4,A,A,A)','Time period #',time_loop,' to process = ',next_date_char,'.' |
---|
525 | PRINT '(A,I4,A)','Total analysis times to input = ',time_loop,'.' |
---|
526 | time_loop_max = time_loop |
---|
527 | EXIT loop_count |
---|
528 | ELSE IF ( next_date_char .GT. end_date_char ) THEN |
---|
529 | PRINT '(A,I4,A)','Total analysis times to input = ',time_loop,'.' |
---|
530 | time_loop_max = time_loop |
---|
531 | EXIT loop_count |
---|
532 | END IF |
---|
533 | END DO loop_count |
---|
534 | END SUBROUTINE compute_si_start_and_end |
---|
535 | |
---|
536 | SUBROUTINE assemble_output ( grid , config_flags , loop , time_loop_max ) |
---|
537 | |
---|
538 | USE module_big_step_utilities_em |
---|
539 | USE module_domain |
---|
540 | USE module_io_domain |
---|
541 | USE module_configure |
---|
542 | USE module_date_time |
---|
543 | USE module_bc |
---|
544 | IMPLICIT NONE |
---|
545 | |
---|
546 | TYPE(domain) :: grid |
---|
547 | TYPE (grid_config_rec_type) :: config_flags |
---|
548 | INTEGER , INTENT(IN) :: loop , time_loop_max |
---|
549 | |
---|
550 | INTEGER :: ids , ide , jds , jde , kds , kde |
---|
551 | INTEGER :: ims , ime , jms , jme , kms , kme |
---|
552 | INTEGER :: ips , ipe , jps , jpe , kps , kpe |
---|
553 | INTEGER :: ijds , ijde , spec_bdy_width |
---|
554 | INTEGER :: i , j , k , idts |
---|
555 | |
---|
556 | INTEGER :: id1 , interval_seconds , ierr, rc, sst_update, grid_fdda |
---|
557 | INTEGER , SAVE :: id, id2, id5 |
---|
558 | CHARACTER (LEN=80) :: inpname , bdyname |
---|
559 | CHARACTER(LEN= 4) :: loop_char |
---|
560 | character *19 :: temp19 |
---|
561 | character *24 :: temp24 , temp24b |
---|
562 | |
---|
563 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: ubdy3dtemp1 , vbdy3dtemp1 , tbdy3dtemp1 , pbdy3dtemp1 , qbdy3dtemp1 |
---|
564 | !!!!***MARS >> |
---|
565 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q2bdy3dtemp1 |
---|
566 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q3bdy3dtemp1 |
---|
567 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q4bdy3dtemp1 |
---|
568 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q5bdy3dtemp1 |
---|
569 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q6bdy3dtemp1 |
---|
570 | !!!!***MARS << |
---|
571 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: mbdy2dtemp1 |
---|
572 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: ubdy3dtemp2 , vbdy3dtemp2 , tbdy3dtemp2 , pbdy3dtemp2 , qbdy3dtemp2 |
---|
573 | !!!!***MARS >> |
---|
574 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q2bdy3dtemp2 |
---|
575 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q3bdy3dtemp2 |
---|
576 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q4bdy3dtemp2 |
---|
577 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q5bdy3dtemp2 |
---|
578 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: q6bdy3dtemp2 |
---|
579 | !!!!***MARS << |
---|
580 | REAL , DIMENSION(:,:,:) , ALLOCATABLE , SAVE :: mbdy2dtemp2 |
---|
581 | real::t1,t2 |
---|
582 | |
---|
583 | ! Various sizes that we need to be concerned about. |
---|
584 | |
---|
585 | ids = grid%sd31 |
---|
586 | ide = grid%ed31 |
---|
587 | kds = grid%sd32 |
---|
588 | kde = grid%ed32 |
---|
589 | jds = grid%sd33 |
---|
590 | jde = grid%ed33 |
---|
591 | |
---|
592 | ims = grid%sm31 |
---|
593 | ime = grid%em31 |
---|
594 | kms = grid%sm32 |
---|
595 | kme = grid%em32 |
---|
596 | jms = grid%sm33 |
---|
597 | jme = grid%em33 |
---|
598 | |
---|
599 | ips = grid%sp31 |
---|
600 | ipe = grid%ep31 |
---|
601 | kps = grid%sp32 |
---|
602 | kpe = grid%ep32 |
---|
603 | jps = grid%sp33 |
---|
604 | jpe = grid%ep33 |
---|
605 | |
---|
606 | ijds = MIN ( ids , jds ) |
---|
607 | ijde = MAX ( ide , jde ) |
---|
608 | |
---|
609 | ! Boundary width, scalar value. |
---|
610 | |
---|
611 | spec_bdy_width = model_config_rec%spec_bdy_width |
---|
612 | interval_seconds = model_config_rec%interval_seconds |
---|
613 | sst_update = model_config_rec%sst_update |
---|
614 | grid_fdda = model_config_rec%grid_fdda(grid%id) |
---|
615 | |
---|
616 | |
---|
617 | IF ( loop .EQ. 1 ) THEN |
---|
618 | |
---|
619 | ! This is the space needed to save the current 3d data for use in computing |
---|
620 | ! the lateral boundary tendencies. |
---|
621 | |
---|
622 | IF ( ALLOCATED ( ubdy3dtemp1 ) ) DEALLOCATE ( ubdy3dtemp1 ) |
---|
623 | IF ( ALLOCATED ( vbdy3dtemp1 ) ) DEALLOCATE ( vbdy3dtemp1 ) |
---|
624 | IF ( ALLOCATED ( tbdy3dtemp1 ) ) DEALLOCATE ( tbdy3dtemp1 ) |
---|
625 | IF ( ALLOCATED ( pbdy3dtemp1 ) ) DEALLOCATE ( pbdy3dtemp1 ) |
---|
626 | IF ( ALLOCATED ( qbdy3dtemp1 ) ) DEALLOCATE ( qbdy3dtemp1 ) |
---|
627 | !!!!***MARS >> |
---|
628 | IF ( ALLOCATED ( q2bdy3dtemp1 ) ) DEALLOCATE ( q2bdy3dtemp1 ) |
---|
629 | IF ( ALLOCATED ( q3bdy3dtemp1 ) ) DEALLOCATE ( q3bdy3dtemp1 ) |
---|
630 | IF ( ALLOCATED ( q4bdy3dtemp1 ) ) DEALLOCATE ( q4bdy3dtemp1 ) |
---|
631 | IF ( ALLOCATED ( q5bdy3dtemp1 ) ) DEALLOCATE ( q5bdy3dtemp1 ) |
---|
632 | IF ( ALLOCATED ( q6bdy3dtemp1 ) ) DEALLOCATE ( q6bdy3dtemp1 ) |
---|
633 | !!!!***MARS << |
---|
634 | IF ( ALLOCATED ( mbdy2dtemp1 ) ) DEALLOCATE ( mbdy2dtemp1 ) |
---|
635 | IF ( ALLOCATED ( ubdy3dtemp2 ) ) DEALLOCATE ( ubdy3dtemp2 ) |
---|
636 | IF ( ALLOCATED ( vbdy3dtemp2 ) ) DEALLOCATE ( vbdy3dtemp2 ) |
---|
637 | IF ( ALLOCATED ( tbdy3dtemp2 ) ) DEALLOCATE ( tbdy3dtemp2 ) |
---|
638 | IF ( ALLOCATED ( pbdy3dtemp2 ) ) DEALLOCATE ( pbdy3dtemp2 ) |
---|
639 | IF ( ALLOCATED ( qbdy3dtemp2 ) ) DEALLOCATE ( qbdy3dtemp2 ) |
---|
640 | !!!!***MARS >> |
---|
641 | IF ( ALLOCATED ( q2bdy3dtemp2 ) ) DEALLOCATE ( q2bdy3dtemp2 ) |
---|
642 | IF ( ALLOCATED ( q3bdy3dtemp2 ) ) DEALLOCATE ( q3bdy3dtemp2 ) |
---|
643 | IF ( ALLOCATED ( q4bdy3dtemp2 ) ) DEALLOCATE ( q4bdy3dtemp2 ) |
---|
644 | IF ( ALLOCATED ( q5bdy3dtemp2 ) ) DEALLOCATE ( q5bdy3dtemp2 ) |
---|
645 | IF ( ALLOCATED ( q6bdy3dtemp2 ) ) DEALLOCATE ( q6bdy3dtemp2 ) |
---|
646 | !!!!***MARS << |
---|
647 | IF ( ALLOCATED ( mbdy2dtemp2 ) ) DEALLOCATE ( mbdy2dtemp2 ) |
---|
648 | |
---|
649 | ALLOCATE ( ubdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
650 | ALLOCATE ( vbdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
651 | ALLOCATE ( tbdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
652 | ALLOCATE ( pbdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
653 | ALLOCATE ( qbdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
654 | !!!!***MARS >> |
---|
655 | ALLOCATE ( q2bdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
656 | ALLOCATE ( q3bdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
657 | ALLOCATE ( q4bdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
658 | ALLOCATE ( q5bdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
659 | ALLOCATE ( q6bdy3dtemp1(ims:ime,kms:kme,jms:jme) ) |
---|
660 | !!!!***MARS << |
---|
661 | ALLOCATE ( mbdy2dtemp1(ims:ime,1:1, jms:jme) ) |
---|
662 | ALLOCATE ( ubdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
663 | ALLOCATE ( vbdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
664 | ALLOCATE ( tbdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
665 | ALLOCATE ( pbdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
666 | ALLOCATE ( qbdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
667 | !!!!***MARS >> |
---|
668 | ALLOCATE ( q2bdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
669 | ALLOCATE ( q3bdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
670 | ALLOCATE ( q4bdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
671 | ALLOCATE ( q5bdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
672 | ALLOCATE ( q6bdy3dtemp2(ims:ime,kms:kme,jms:jme) ) |
---|
673 | !!!!***MARS << |
---|
674 | ALLOCATE ( mbdy2dtemp2(ims:ime,1:1, jms:jme) ) |
---|
675 | |
---|
676 | ! Open the wrfinput file. From this program, this is an *output* file. |
---|
677 | |
---|
678 | CALL construct_filename1( inpname , 'wrfinput' , grid%id , 2 ) |
---|
679 | CALL open_w_dataset ( id1, TRIM(inpname) , grid , config_flags , output_model_input , "DATASET=INPUT", ierr ) |
---|
680 | IF ( ierr .NE. 0 ) THEN |
---|
681 | CALL wrf_error_fatal( 'real: error opening wrfinput for writing' ) |
---|
682 | ENDIF |
---|
683 | IF(sst_update .EQ. 1)THEN |
---|
684 | CALL construct_filename1( inpname , 'wrflowinp' , grid%id , 2 ) |
---|
685 | CALL open_w_dataset ( id5, TRIM(inpname) , grid , config_flags , output_aux_model_input5 , "DATASET=AUXINPUT5", ierr ) |
---|
686 | IF ( ierr .NE. 0 ) THEN |
---|
687 | CALL wrf_error_fatal( 'real: error opening wrflowinp for writing' ) |
---|
688 | ENDIF |
---|
689 | ENDIF |
---|
690 | ! CALL calc_current_date ( grid%id , 0. ) |
---|
691 | CALL output_model_input ( id1, grid , config_flags , ierr ) |
---|
692 | CALL close_dataset ( id1 , config_flags , "DATASET=INPUT" ) |
---|
693 | IF(sst_update .EQ. 1)THEN |
---|
694 | CALL output_aux_model_input5 ( id5, grid , config_flags , ierr ) |
---|
695 | ENDIF |
---|
696 | |
---|
697 | ! We need to save the 3d data to compute a difference during the next loop. Couple the |
---|
698 | ! 3d fields with total mu (mub + mu_2) and the stagger-specific map scale factor. |
---|
699 | |
---|
700 | CALL couple ( grid%em_mu_2 , grid%em_mub , ubdy3dtemp1 , grid%em_u_2 , 'u' , grid%msfu , & |
---|
701 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
702 | CALL couple ( grid%em_mu_2 , grid%em_mub , vbdy3dtemp1 , grid%em_v_2 , 'v' , grid%msfv , & |
---|
703 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
704 | CALL couple ( grid%em_mu_2 , grid%em_mub , tbdy3dtemp1 , grid%em_t_2 , 't' , grid%msft , & |
---|
705 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
706 | CALL couple ( grid%em_mu_2 , grid%em_mub , pbdy3dtemp1 , grid%em_ph_2 , 'h' , grid%msft , & |
---|
707 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
708 | ! CALL couple ( grid%em_mu_2 , grid%em_mub , qbdy3dtemp1 , grid%moist(:,:,:,P_QV) , 't' , grid%msft , & |
---|
709 | ! ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
710 | |
---|
711 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
712 | !!!!!MARS: si config_flags%mars != 0 il y a au moins un autre traceur (indice 2 a cause du dummy tracer) |
---|
713 | !!!!!MARS: -- il faut donc definir ses conditions aux bornes |
---|
714 | !!!!!MARS: -- cas generique ici, les choix de flux ou non-flux sont dans solve_em |
---|
715 | !!!!!MARS: ensuite faire au cas par cas (ou un jour une boucle sur le nombre de traceurs ???) !!!q2bdy3dtemp1 |
---|
716 | !!!!!MARS: NB NB: si on ne veut pas passer un traceur aux bornes, tout ce qui suit n'est pas utile |
---|
717 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
718 | IF (config_flags%mars .gt. 0) THEN |
---|
719 | !! ceci suffit avec les modes 2 et 10 qui ne transportent qu'un seul traceur |
---|
720 | CALL couple ( grid%em_mu_2 , grid%em_mub , qbdy3dtemp1 , grid%scalar(:,:,:,2) , 't' , grid%msft , & |
---|
721 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
722 | ENDIF |
---|
723 | !!!!!MARS: autres possibilites. pour le moment seuls 4 traceurs aux bornes sont supportes. |
---|
724 | !!!!!MARS: ... mais il est facile d'en ajouter... ajouter simplement des tableaux type q2bdy3dtemp1 |
---|
725 | IF ( (config_flags%mars .eq. 1) .OR. & |
---|
726 | (config_flags%mars .eq. 3) .OR. & |
---|
727 | (config_flags%mars .eq. 11) .OR. & |
---|
728 | (config_flags%mars .eq. 12) ) THEN |
---|
729 | CALL couple ( grid%em_mu_2 , grid%em_mub , q2bdy3dtemp1 , grid%scalar(:,:,:,3) , 't' , grid%msft , & |
---|
730 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
731 | ENDIF |
---|
732 | IF ((config_flags%mars .eq. 11) .OR. (config_flags%mars .eq. 12)) THEN |
---|
733 | CALL couple ( grid%em_mu_2 , grid%em_mub , q3bdy3dtemp1 , grid%scalar(:,:,:,4) , 't' , grid%msft , & |
---|
734 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
735 | CALL couple ( grid%em_mu_2 , grid%em_mub , q4bdy3dtemp1 , grid%scalar(:,:,:,5) , 't' , grid%msft , & |
---|
736 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
737 | ENDIF |
---|
738 | IF ((config_flags%mars .eq. 12)) THEN |
---|
739 | CALL couple ( grid%em_mu_2 , grid%em_mub , q5bdy3dtemp1 , grid%scalar(:,:,:,6) , 't' , grid%msft , & |
---|
740 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
741 | CALL couple ( grid%em_mu_2 , grid%em_mub , q6bdy3dtemp1 , grid%scalar(:,:,:,7) , 't' , grid%msft , & |
---|
742 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
743 | ENDIF |
---|
744 | !!!!!MARS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
745 | |
---|
746 | |
---|
747 | |
---|
748 | DO j = jps , MIN(jde-1,jpe) |
---|
749 | DO i = ips , MIN(ide-1,ipe) |
---|
750 | mbdy2dtemp1(i,1,j) = grid%em_mu_2(i,j) |
---|
751 | END DO |
---|
752 | END DO |
---|
753 | |
---|
754 | IF(grid_fdda .EQ. 1)THEN |
---|
755 | ! for fdda |
---|
756 | DO j = jps , jpe |
---|
757 | DO k = kps , kpe |
---|
758 | DO i = ips , ipe |
---|
759 | grid%fdda3d(i,k,j,p_u_ndg_old) = grid%em_u_2(i,k,j) |
---|
760 | grid%fdda3d(i,k,j,p_v_ndg_old) = grid%em_v_2(i,k,j) |
---|
761 | grid%fdda3d(i,k,j,p_t_ndg_old) = grid%em_t_2(i,k,j) |
---|
762 | grid%fdda3d(i,k,j,p_q_ndg_old) = grid%moist(i,k,j,P_QV) |
---|
763 | grid%fdda3d(i,k,j,p_ph_ndg_old) = grid%em_ph_2(i,k,j) |
---|
764 | END DO |
---|
765 | END DO |
---|
766 | END DO |
---|
767 | |
---|
768 | DO j = jps , jpe |
---|
769 | DO i = ips , ipe |
---|
770 | grid%fdda2d(i,1,j,p_mu_ndg_old) = grid%em_mu_2(i,j) |
---|
771 | END DO |
---|
772 | END DO |
---|
773 | ENDIF |
---|
774 | |
---|
775 | |
---|
776 | ! There are 2 components to the lateral boundaries. First, there is the starting |
---|
777 | ! point of this time period - just the outer few rows and columns. |
---|
778 | |
---|
779 | CALL stuff_bdy ( ubdy3dtemp1 , grid%em_u_b , 'U' , ijds , ijde , spec_bdy_width , & |
---|
780 | ids , ide , jds , jde , kds , kde , & |
---|
781 | ims , ime , jms , jme , kms , kme , & |
---|
782 | ips , ipe , jps , jpe , kps , kpe ) |
---|
783 | CALL stuff_bdy ( vbdy3dtemp1 , grid%em_v_b , 'V' , ijds , ijde , spec_bdy_width , & |
---|
784 | ids , ide , jds , jde , kds , kde , & |
---|
785 | ims , ime , jms , jme , kms , kme , & |
---|
786 | ips , ipe , jps , jpe , kps , kpe ) |
---|
787 | CALL stuff_bdy ( tbdy3dtemp1 , grid%em_t_b , 'T' , ijds , ijde , spec_bdy_width , & |
---|
788 | ids , ide , jds , jde , kds , kde , & |
---|
789 | ims , ime , jms , jme , kms , kme , & |
---|
790 | ips , ipe , jps , jpe , kps , kpe ) |
---|
791 | CALL stuff_bdy ( pbdy3dtemp1 , grid%em_ph_b , 'W' , ijds , ijde , spec_bdy_width , & |
---|
792 | ids , ide , jds , jde , kds , kde , & |
---|
793 | ims , ime , jms , jme , kms , kme , & |
---|
794 | ips , ipe , jps , jpe , kps , kpe ) |
---|
795 | ! CALL stuff_bdy ( qbdy3dtemp1 , grid%moist_b(:,:,:,:,P_QV) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
796 | ! ids , ide , jds , jde , kds , kde , & |
---|
797 | ! ims , ime , jms , jme , kms , kme , & |
---|
798 | ! ips , ipe , jps , jpe , kps , kpe ) |
---|
799 | !!!!!MARS >> |
---|
800 | IF (config_flags%mars .gt. 0) THEN |
---|
801 | CALL stuff_bdy ( qbdy3dtemp1 , grid%scalar_b(:,:,:,:,2) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
802 | ids , ide , jds , jde , kds , kde , & |
---|
803 | ims , ime , jms , jme , kms , kme , & |
---|
804 | ips , ipe , jps , jpe , kps , kpe ) |
---|
805 | ENDIF |
---|
806 | IF ( (config_flags%mars .eq. 1) .OR. & |
---|
807 | (config_flags%mars .eq. 3) .OR. & |
---|
808 | (config_flags%mars .eq. 11) .OR. & |
---|
809 | (config_flags%mars .eq. 12) ) THEN |
---|
810 | CALL stuff_bdy ( q2bdy3dtemp1 , grid%scalar_b(:,:,:,:,3) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
811 | ids , ide , jds , jde , kds , kde , & |
---|
812 | ims , ime , jms , jme , kms , kme , & |
---|
813 | ips , ipe , jps , jpe , kps , kpe ) |
---|
814 | ENDIF |
---|
815 | IF ((config_flags%mars .eq. 11) .OR. (config_flags%mars .eq. 12)) THEN |
---|
816 | CALL stuff_bdy ( q3bdy3dtemp1 , grid%scalar_b(:,:,:,:,4) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
817 | ids , ide , jds , jde , kds , kde , & |
---|
818 | ims , ime , jms , jme , kms , kme , & |
---|
819 | ips , ipe , jps , jpe , kps , kpe ) |
---|
820 | CALL stuff_bdy ( q4bdy3dtemp1 , grid%scalar_b(:,:,:,:,5) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
821 | ids , ide , jds , jde , kds , kde , & |
---|
822 | ims , ime , jms , jme , kms , kme , & |
---|
823 | ips , ipe , jps , jpe , kps , kpe ) |
---|
824 | ENDIF |
---|
825 | IF ((config_flags%mars .eq. 12)) THEN |
---|
826 | CALL stuff_bdy ( q5bdy3dtemp1 , grid%scalar_b(:,:,:,:,6) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
827 | ids , ide , jds , jde , kds , kde , & |
---|
828 | ims , ime , jms , jme , kms , kme , & |
---|
829 | ips , ipe , jps , jpe , kps , kpe ) |
---|
830 | CALL stuff_bdy ( q6bdy3dtemp1 , grid%scalar_b(:,:,:,:,7) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
831 | ids , ide , jds , jde , kds , kde , & |
---|
832 | ims , ime , jms , jme , kms , kme , & |
---|
833 | ips , ipe , jps , jpe , kps , kpe ) |
---|
834 | ENDIF |
---|
835 | !!!!MARS << |
---|
836 | |
---|
837 | CALL stuff_bdy ( mbdy2dtemp1 , grid%em_mu_b , 'M' , ijds , ijde , spec_bdy_width , & |
---|
838 | ids , ide , jds , jde , 1 , 1 , & |
---|
839 | ims , ime , jms , jme , 1 , 1 , & |
---|
840 | ips , ipe , jps , jpe , 1 , 1 ) |
---|
841 | |
---|
842 | |
---|
843 | ELSE IF ( loop .GT. 1 ) THEN |
---|
844 | |
---|
845 | IF(sst_update .EQ. 1)THEN |
---|
846 | CALL output_aux_model_input5 ( id5, grid , config_flags , ierr ) |
---|
847 | ENDIF |
---|
848 | |
---|
849 | ! Open the boundary file. |
---|
850 | |
---|
851 | |
---|
852 | IF ( loop .eq. 2 ) THEN |
---|
853 | IF(grid%id .eq. 1)THEN |
---|
854 | CALL construct_filename1( bdyname , 'wrfbdy' , grid%id , 2 ) |
---|
855 | CALL open_w_dataset ( id, TRIM(bdyname) , grid , config_flags , output_boundary , "DATASET=BOUNDARY", ierr ) |
---|
856 | IF ( ierr .NE. 0 ) THEN |
---|
857 | CALL wrf_error_fatal( 'real: error opening wrfbdy for writing' ) |
---|
858 | ENDIF |
---|
859 | ENDIF |
---|
860 | IF(grid_fdda .EQ. 1)THEN |
---|
861 | ! for fdda |
---|
862 | CALL construct_filename1( inpname , 'wrffdda' , grid%id , 2 ) |
---|
863 | CALL open_w_dataset ( id2, TRIM(inpname) , grid , config_flags , output_aux_model_input10 , "DATASET=AUXINPUT10", ierr ) |
---|
864 | IF ( ierr .NE. 0 ) THEN |
---|
865 | CALL wrf_error_fatal( 'real: error opening wrffdda for writing' ) |
---|
866 | ENDIF |
---|
867 | ENDIF |
---|
868 | ELSE |
---|
869 | IF ( .NOT. domain_clockisstoptime(grid) ) THEN |
---|
870 | CALL domain_clockadvance( grid ) |
---|
871 | CALL domain_clockprint ( 150, grid, & |
---|
872 | 'DEBUG assemble_output: clock after ClockAdvance,' ) |
---|
873 | ENDIF |
---|
874 | END IF |
---|
875 | |
---|
876 | |
---|
877 | ! Couple this time period's data with total mu, and save it in the *bdy3dtemp2 arrays. |
---|
878 | |
---|
879 | CALL couple ( grid%em_mu_2 , grid%em_mub , ubdy3dtemp2 , grid%em_u_2 , 'u' , grid%msfu , & |
---|
880 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
881 | CALL couple ( grid%em_mu_2 , grid%em_mub , vbdy3dtemp2 , grid%em_v_2 , 'v' , grid%msfv , & |
---|
882 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
883 | CALL couple ( grid%em_mu_2 , grid%em_mub , tbdy3dtemp2 , grid%em_t_2 , 't' , grid%msft , & |
---|
884 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
885 | CALL couple ( grid%em_mu_2 , grid%em_mub , pbdy3dtemp2 , grid%em_ph_2 , 'h' , grid%msft , & |
---|
886 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
887 | ! CALL couple ( grid%em_mu_2 , grid%em_mub , qbdy3dtemp2 , grid%moist(:,:,:,P_QV) , 't' , grid%msft , & |
---|
888 | ! ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
889 | !!!!!MARS >> |
---|
890 | IF (config_flags%mars .gt. 0) THEN |
---|
891 | CALL couple ( grid%em_mu_2 , grid%em_mub , qbdy3dtemp2 , grid%scalar(:,:,:,2) , 't' , grid%msft , & |
---|
892 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
893 | ENDIF |
---|
894 | IF ( (config_flags%mars .eq. 1) .OR. & |
---|
895 | (config_flags%mars .eq. 3) .OR. & |
---|
896 | (config_flags%mars .eq. 11) .OR. & |
---|
897 | (config_flags%mars .eq. 12) ) THEN |
---|
898 | CALL couple ( grid%em_mu_2 , grid%em_mub , q2bdy3dtemp2 , grid%scalar(:,:,:,3) , 't' , grid%msft , & |
---|
899 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
900 | ENDIF |
---|
901 | IF ((config_flags%mars .eq. 11) .OR. (config_flags%mars .eq. 12)) THEN |
---|
902 | CALL couple ( grid%em_mu_2 , grid%em_mub , q3bdy3dtemp2 , grid%scalar(:,:,:,4) , 't' , grid%msft , & |
---|
903 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
904 | CALL couple ( grid%em_mu_2 , grid%em_mub , q4bdy3dtemp2 , grid%scalar(:,:,:,5) , 't' , grid%msft , & |
---|
905 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
906 | ENDIF |
---|
907 | IF ((config_flags%mars .eq. 12)) THEN |
---|
908 | CALL couple ( grid%em_mu_2 , grid%em_mub , q5bdy3dtemp2 , grid%scalar(:,:,:,6) , 't' , grid%msft , & |
---|
909 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
910 | CALL couple ( grid%em_mu_2 , grid%em_mub , q6bdy3dtemp2 , grid%scalar(:,:,:,7) , 't' , grid%msft , & |
---|
911 | ids, ide, jds, jde, kds, kde, ims, ime, jms, jme, kms, kme, ips, ipe, jps, jpe, kps, kpe ) |
---|
912 | ENDIF |
---|
913 | !!!!!MARS << |
---|
914 | |
---|
915 | DO j = jps , jpe |
---|
916 | DO i = ips , ipe |
---|
917 | mbdy2dtemp2(i,1,j) = grid%em_mu_2(i,j) |
---|
918 | END DO |
---|
919 | END DO |
---|
920 | |
---|
921 | IF(grid_fdda .EQ. 1)THEN |
---|
922 | ! for fdda |
---|
923 | DO j = jps , jpe |
---|
924 | DO k = kps , kpe |
---|
925 | DO i = ips , ipe |
---|
926 | grid%fdda3d(i,k,j,p_u_ndg_new) = grid%em_u_2(i,k,j) |
---|
927 | grid%fdda3d(i,k,j,p_v_ndg_new) = grid%em_v_2(i,k,j) |
---|
928 | grid%fdda3d(i,k,j,p_t_ndg_new) = grid%em_t_2(i,k,j) |
---|
929 | grid%fdda3d(i,k,j,p_q_ndg_new) = grid%moist(i,k,j,P_QV) |
---|
930 | grid%fdda3d(i,k,j,p_ph_ndg_new) = grid%em_ph_2(i,k,j) |
---|
931 | END DO |
---|
932 | END DO |
---|
933 | END DO |
---|
934 | |
---|
935 | DO j = jps , jpe |
---|
936 | DO i = ips , ipe |
---|
937 | grid%fdda2d(i,1,j,p_mu_ndg_new) = grid%em_mu_2(i,j) |
---|
938 | END DO |
---|
939 | END DO |
---|
940 | ENDIF |
---|
941 | |
---|
942 | ! During all of the loops after the first loop, we first compute the boundary |
---|
943 | ! tendencies with the current data values (*bdy3dtemp2 arrays) and the previously |
---|
944 | ! saved information stored in the *bdy3dtemp1 arrays. |
---|
945 | |
---|
946 | CALL stuff_bdytend ( ubdy3dtemp2 , ubdy3dtemp1 , REAL(interval_seconds) , grid%em_u_bt , 'U' , & |
---|
947 | ijds , ijde , spec_bdy_width , & |
---|
948 | ids , ide , jds , jde , kds , kde , & |
---|
949 | ims , ime , jms , jme , kms , kme , & |
---|
950 | ips , ipe , jps , jpe , kps , kpe ) |
---|
951 | CALL stuff_bdytend ( vbdy3dtemp2 , vbdy3dtemp1 , REAL(interval_seconds) , grid%em_v_bt , 'V' , & |
---|
952 | ijds , ijde , spec_bdy_width , & |
---|
953 | ids , ide , jds , jde , kds , kde , & |
---|
954 | ims , ime , jms , jme , kms , kme , & |
---|
955 | ips , ipe , jps , jpe , kps , kpe ) |
---|
956 | CALL stuff_bdytend ( tbdy3dtemp2 , tbdy3dtemp1 , REAL(interval_seconds) , grid%em_t_bt , 'T' , & |
---|
957 | ijds , ijde , spec_bdy_width , & |
---|
958 | ids , ide , jds , jde , kds , kde , & |
---|
959 | ims , ime , jms , jme , kms , kme , & |
---|
960 | ips , ipe , jps , jpe , kps , kpe ) |
---|
961 | CALL stuff_bdytend ( pbdy3dtemp2 , pbdy3dtemp1 , REAL(interval_seconds) , grid%em_ph_bt , 'W' , & |
---|
962 | ijds , ijde , spec_bdy_width , & |
---|
963 | ids , ide , jds , jde , kds , kde , & |
---|
964 | ims , ime , jms , jme , kms , kme , & |
---|
965 | ips , ipe , jps , jpe , kps , kpe ) |
---|
966 | ! CALL stuff_bdytend ( qbdy3dtemp2 , qbdy3dtemp1 , REAL(interval_seconds) , grid%moist_bt(:,:,:,:,P_QV) , 'T' , & |
---|
967 | ! ijds , ijde , spec_bdy_width , & |
---|
968 | ! ids , ide , jds , jde , kds , kde , & |
---|
969 | ! ims , ime , jms , jme , kms , kme , & |
---|
970 | ! ips , ipe , jps , jpe , kps , kpe ) |
---|
971 | !!!!!MARS >> |
---|
972 | IF (config_flags%mars .gt. 0) THEN |
---|
973 | CALL stuff_bdytend ( qbdy3dtemp2 , qbdy3dtemp1 , REAL(interval_seconds) , grid%scalar_bt(:,:,:,:,2) , 'T' , & |
---|
974 | ijds , ijde , spec_bdy_width , & |
---|
975 | ids , ide , jds , jde , kds , kde , & |
---|
976 | ims , ime , jms , jme , kms , kme , & |
---|
977 | ips , ipe , jps , jpe , kps , kpe ) |
---|
978 | ENDIF |
---|
979 | IF ( (config_flags%mars .eq. 1) .OR. & |
---|
980 | (config_flags%mars .eq. 3) .OR. & |
---|
981 | (config_flags%mars .eq. 11) .OR. & |
---|
982 | (config_flags%mars .eq. 12) ) THEN |
---|
983 | CALL stuff_bdytend ( q2bdy3dtemp2 , q2bdy3dtemp1 , REAL(interval_seconds) ,grid%scalar_bt(:,:,:,:,3) , 'T' , & |
---|
984 | ijds , ijde , spec_bdy_width , & |
---|
985 | ids , ide , jds , jde , kds , kde , & |
---|
986 | ims , ime , jms , jme , kms , kme , & |
---|
987 | ips , ipe , jps , jpe , kps , kpe ) |
---|
988 | ENDIF |
---|
989 | IF ((config_flags%mars .eq. 11) .OR. (config_flags%mars .eq. 12)) THEN |
---|
990 | CALL stuff_bdytend ( q3bdy3dtemp2 , q3bdy3dtemp1 , REAL(interval_seconds) , grid%scalar_bt(:,:,:,:,4) , 'T' , & |
---|
991 | ijds , ijde , spec_bdy_width , & |
---|
992 | ids , ide , jds , jde , kds , kde , & |
---|
993 | ims , ime , jms , jme , kms , kme , & |
---|
994 | ips , ipe , jps , jpe , kps , kpe ) |
---|
995 | CALL stuff_bdytend ( q4bdy3dtemp2 , q4bdy3dtemp1 , REAL(interval_seconds) ,grid%scalar_bt(:,:,:,:,5) , 'T' , & |
---|
996 | ijds , ijde , spec_bdy_width , & |
---|
997 | ids , ide , jds , jde , kds , kde , & |
---|
998 | ims , ime , jms , jme , kms , kme , & |
---|
999 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1000 | ENDIF |
---|
1001 | IF ((config_flags%mars .eq. 12)) THEN |
---|
1002 | CALL stuff_bdytend ( q5bdy3dtemp2 , q5bdy3dtemp1 , REAL(interval_seconds) , grid%scalar_bt(:,:,:,:,6) , 'T' , & |
---|
1003 | ijds , ijde , spec_bdy_width , & |
---|
1004 | ids , ide , jds , jde , kds , kde , & |
---|
1005 | ims , ime , jms , jme , kms , kme , & |
---|
1006 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1007 | CALL stuff_bdytend ( q6bdy3dtemp2 , q6bdy3dtemp1 , REAL(interval_seconds) ,grid%scalar_bt(:,:,:,:,7) , 'T' , & |
---|
1008 | ijds , ijde , spec_bdy_width , & |
---|
1009 | ids , ide , jds , jde , kds , kde , & |
---|
1010 | ims , ime , jms , jme , kms , kme , & |
---|
1011 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1012 | ENDIF |
---|
1013 | !!!!!MARS << |
---|
1014 | |
---|
1015 | CALL stuff_bdytend ( mbdy2dtemp2 , mbdy2dtemp1 , REAL(interval_seconds) , grid%em_mu_bt , 'M' , & |
---|
1016 | ijds , ijde , spec_bdy_width , & |
---|
1017 | ids , ide , jds , jde , 1 , 1 , & |
---|
1018 | ims , ime , jms , jme , 1 , 1 , & |
---|
1019 | ips , ipe , jps , jpe , 1 , 1 ) |
---|
1020 | |
---|
1021 | ! Both pieces of the boundary data are now available to be written (initial time and tendency). |
---|
1022 | ! This looks ugly, these date shifting things. What's it for? We want the "Times" variable |
---|
1023 | ! in the lateral BDY file to have the valid times of when the initial fields are written. |
---|
1024 | ! That's what the loop-2 thingy is for with the start date. We increment the start_date so |
---|
1025 | ! that the starting time in the attributes is the second time period. Why you may ask. I |
---|
1026 | ! agree, why indeed. |
---|
1027 | |
---|
1028 | CALL domain_clockprint ( 150, grid, & |
---|
1029 | 'DEBUG assemble_output: clock before 1st current_date set,' ) |
---|
1030 | WRITE (wrf_err_message,*) & |
---|
1031 | 'DEBUG assemble_output: before 1st currTime set, current_date = ',TRIM(current_date) |
---|
1032 | CALL wrf_debug ( 150 , wrf_err_message ) |
---|
1033 | CALL domain_clock_set( grid, current_date(1:19) ) |
---|
1034 | CALL domain_clockprint ( 150, grid, & |
---|
1035 | 'DEBUG assemble_output: clock after 1st current_date set,' ) |
---|
1036 | |
---|
1037 | temp24= current_date |
---|
1038 | temp24b=start_date |
---|
1039 | start_date = current_date |
---|
1040 | CALL geth_newdate ( temp19 , temp24b(1:19) , (loop-2) * model_config_rec%interval_seconds ) |
---|
1041 | current_date = temp19 // '.0000' |
---|
1042 | CALL domain_clockprint ( 150, grid, & |
---|
1043 | 'DEBUG assemble_output: clock before 2nd current_date set,' ) |
---|
1044 | WRITE (wrf_err_message,*) & |
---|
1045 | 'DEBUG assemble_output: before 2nd currTime set, current_date = ',TRIM(current_date) |
---|
1046 | CALL wrf_debug ( 150 , wrf_err_message ) |
---|
1047 | CALL domain_clock_set( grid, current_date(1:19) ) |
---|
1048 | CALL domain_clockprint ( 150, grid, & |
---|
1049 | 'DEBUG assemble_output: clock after 2nd current_date set,' ) |
---|
1050 | IF(grid%id .EQ. 1)THEN |
---|
1051 | print *,'LBC valid between these times ',current_date, ' ',start_date |
---|
1052 | CALL output_boundary ( id, grid , config_flags , ierr ) |
---|
1053 | ENDIF |
---|
1054 | ! for fdda |
---|
1055 | IF(grid_fdda .EQ. 1) THEN |
---|
1056 | CALL output_aux_model_input10 ( id2, grid , config_flags , ierr ) |
---|
1057 | END IF |
---|
1058 | current_date = temp24 |
---|
1059 | start_date = temp24b |
---|
1060 | CALL domain_clockprint ( 150, grid, & |
---|
1061 | 'DEBUG assemble_output: clock before 3rd current_date set,' ) |
---|
1062 | WRITE (wrf_err_message,*) & |
---|
1063 | 'DEBUG assemble_output: before 3rd currTime set, current_date = ',TRIM(current_date) |
---|
1064 | CALL wrf_debug ( 150 , wrf_err_message ) |
---|
1065 | CALL domain_clock_set( grid, current_date(1:19) ) |
---|
1066 | CALL domain_clockprint ( 150, grid, & |
---|
1067 | 'DEBUG assemble_output: clock after 3rd current_date set,' ) |
---|
1068 | |
---|
1069 | ! OK, for all of the loops, we output the initialzation data, which would allow us to |
---|
1070 | ! start the model at any of the available analysis time periods. |
---|
1071 | |
---|
1072 | ! WRITE ( loop_char , FMT = '(I4.4)' ) loop |
---|
1073 | ! CALL open_w_dataset ( id1, 'wrfinput'//loop_char , grid , config_flags , output_model_input , "DATASET=INPUT", ierr ) |
---|
1074 | ! IF ( ierr .NE. 0 ) THEN |
---|
1075 | ! CALL wrf_error_fatal( 'real: error opening wrfinput'//loop_char//' for writing' ) |
---|
1076 | ! ENDIF |
---|
1077 | |
---|
1078 | ! CALL calc_current_date ( grid%id , 0. ) |
---|
1079 | ! CALL output_model_input ( id1, grid , config_flags , ierr ) |
---|
1080 | ! CALL close_dataset ( id1 , config_flags , "DATASET=INPUT" ) |
---|
1081 | ! Is this or is this not the last time time? We can remove some unnecessary |
---|
1082 | ! stores if it is not. |
---|
1083 | IF ( loop .LT. time_loop_max ) THEN |
---|
1084 | |
---|
1085 | ! We need to save the 3d data to compute a difference during the next loop. Couple the |
---|
1086 | ! 3d fields with total mu (mub + mu_2) and the stagger-specific map scale factor. |
---|
1087 | ! We load up the boundary data again for use in the next loop. |
---|
1088 | |
---|
1089 | DO j = jps , jpe |
---|
1090 | DO k = kps , kpe |
---|
1091 | DO i = ips , ipe |
---|
1092 | ubdy3dtemp1(i,k,j) = ubdy3dtemp2(i,k,j) |
---|
1093 | vbdy3dtemp1(i,k,j) = vbdy3dtemp2(i,k,j) |
---|
1094 | tbdy3dtemp1(i,k,j) = tbdy3dtemp2(i,k,j) |
---|
1095 | pbdy3dtemp1(i,k,j) = pbdy3dtemp2(i,k,j) |
---|
1096 | qbdy3dtemp1(i,k,j) = qbdy3dtemp2(i,k,j) |
---|
1097 | !!!!MARS >> |
---|
1098 | q2bdy3dtemp1(i,k,j) = q2bdy3dtemp2(i,k,j) |
---|
1099 | q3bdy3dtemp1(i,k,j) = q3bdy3dtemp2(i,k,j) |
---|
1100 | q4bdy3dtemp1(i,k,j) = q4bdy3dtemp2(i,k,j) |
---|
1101 | q5bdy3dtemp1(i,k,j) = q5bdy3dtemp2(i,k,j) |
---|
1102 | q6bdy3dtemp1(i,k,j) = q6bdy3dtemp2(i,k,j) |
---|
1103 | !!!!MARS << |
---|
1104 | END DO |
---|
1105 | END DO |
---|
1106 | END DO |
---|
1107 | |
---|
1108 | DO j = jps , jpe |
---|
1109 | DO i = ips , ipe |
---|
1110 | mbdy2dtemp1(i,1,j) = mbdy2dtemp2(i,1,j) |
---|
1111 | END DO |
---|
1112 | END DO |
---|
1113 | |
---|
1114 | IF(grid_fdda .EQ. 1)THEN |
---|
1115 | ! for fdda |
---|
1116 | DO j = jps , jpe |
---|
1117 | DO k = kps , kpe |
---|
1118 | DO i = ips , ipe |
---|
1119 | grid%fdda3d(i,k,j,p_u_ndg_old) = grid%fdda3d(i,k,j,p_u_ndg_new) |
---|
1120 | grid%fdda3d(i,k,j,p_v_ndg_old) = grid%fdda3d(i,k,j,p_v_ndg_new) |
---|
1121 | grid%fdda3d(i,k,j,p_t_ndg_old) = grid%fdda3d(i,k,j,p_t_ndg_new) |
---|
1122 | grid%fdda3d(i,k,j,p_q_ndg_old) = grid%fdda3d(i,k,j,p_q_ndg_new) |
---|
1123 | grid%fdda3d(i,k,j,p_ph_ndg_old) = grid%fdda3d(i,k,j,p_ph_ndg_new) |
---|
1124 | END DO |
---|
1125 | END DO |
---|
1126 | END DO |
---|
1127 | |
---|
1128 | DO j = jps , jpe |
---|
1129 | DO i = ips , ipe |
---|
1130 | grid%fdda2d(i,1,j,p_mu_ndg_old) = grid%fdda2d(i,1,j,p_mu_ndg_new) |
---|
1131 | END DO |
---|
1132 | END DO |
---|
1133 | ENDIF |
---|
1134 | |
---|
1135 | ! There are 2 components to the lateral boundaries. First, there is the starting |
---|
1136 | ! point of this time period - just the outer few rows and columns. |
---|
1137 | |
---|
1138 | CALL stuff_bdy ( ubdy3dtemp1 , grid%em_u_b , 'U' , ijds , ijde , spec_bdy_width , & |
---|
1139 | ids , ide , jds , jde , kds , kde , & |
---|
1140 | ims , ime , jms , jme , kms , kme , & |
---|
1141 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1142 | CALL stuff_bdy ( vbdy3dtemp1 , grid%em_v_b , 'V' , ijds , ijde , spec_bdy_width , & |
---|
1143 | ids , ide , jds , jde , kds , kde , & |
---|
1144 | ims , ime , jms , jme , kms , kme , & |
---|
1145 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1146 | CALL stuff_bdy ( tbdy3dtemp1 , grid%em_t_b , 'T' , ijds , ijde , spec_bdy_width , & |
---|
1147 | ids , ide , jds , jde , kds , kde , & |
---|
1148 | ims , ime , jms , jme , kms , kme , & |
---|
1149 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1150 | CALL stuff_bdy ( pbdy3dtemp1 , grid%em_ph_b , 'W' , ijds , ijde , spec_bdy_width , & |
---|
1151 | ids , ide , jds , jde , kds , kde , & |
---|
1152 | ims , ime , jms , jme , kms , kme , & |
---|
1153 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1154 | ! CALL stuff_bdy ( qbdy3dtemp1 , grid%moist_b(:,:,:,:,P_QV) , 'T' , ijds , ijde , spec_bdy_width , & |
---|
1155 | ! ids , ide , jds , jde , kds , kde , & |
---|
1156 | ! ims , ime , jms , jme , kms , kme , & |
---|
1157 | ! ips , ipe , jps , jpe , kps , kpe ) |
---|
1158 | !!!!!MARS >> |
---|
1159 | IF (config_flags%mars .gt. 0) THEN |
---|
1160 | CALL stuff_bdy ( qbdy3dtemp1 , grid%scalar_b(:,:,:,:,2) , 'T', ijds , ijde , spec_bdy_width , & |
---|
1161 | ids , ide , jds , jde , kds , kde , & |
---|
1162 | ims , ime , jms , jme , kms , kme , & |
---|
1163 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1164 | ENDIF |
---|
1165 | IF ( (config_flags%mars .eq. 1) .OR. & |
---|
1166 | (config_flags%mars .eq. 3) .OR. & |
---|
1167 | (config_flags%mars .eq. 11) .OR. & |
---|
1168 | (config_flags%mars .eq. 12) ) THEN |
---|
1169 | CALL stuff_bdy ( q2bdy3dtemp1 , grid%scalar_b(:,:,:,:,3) , 'T', ijds , ijde , spec_bdy_width , & |
---|
1170 | ids , ide , jds , jde , kds , kde , & |
---|
1171 | ims , ime , jms , jme , kms , kme , & |
---|
1172 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1173 | ENDIF |
---|
1174 | IF ((config_flags%mars .eq. 11) .OR. (config_flags%mars .eq. 12)) THEN |
---|
1175 | CALL stuff_bdy ( q3bdy3dtemp1 , grid%scalar_b(:,:,:,:,4) , 'T', ijds , ijde , spec_bdy_width , & |
---|
1176 | ids , ide , jds , jde , kds , kde , & |
---|
1177 | ims , ime , jms , jme , kms , kme , & |
---|
1178 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1179 | CALL stuff_bdy ( q4bdy3dtemp1 , grid%scalar_b(:,:,:,:,5) , 'T', ijds , ijde , spec_bdy_width , & |
---|
1180 | ids , ide , jds , jde , kds , kde , & |
---|
1181 | ims , ime , jms , jme , kms , kme , & |
---|
1182 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1183 | ENDIF |
---|
1184 | IF ((config_flags%mars .eq. 12)) THEN |
---|
1185 | CALL stuff_bdy ( q5bdy3dtemp1 , grid%scalar_b(:,:,:,:,6) , 'T', ijds , ijde , spec_bdy_width , & |
---|
1186 | ids , ide , jds , jde , kds , kde , & |
---|
1187 | ims , ime , jms , jme , kms , kme , & |
---|
1188 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1189 | CALL stuff_bdy ( q6bdy3dtemp1 , grid%scalar_b(:,:,:,:,7) , 'T', ijds , ijde , spec_bdy_width , & |
---|
1190 | ids , ide , jds , jde , kds , kde , & |
---|
1191 | ims , ime , jms , jme , kms , kme , & |
---|
1192 | ips , ipe , jps , jpe , kps , kpe ) |
---|
1193 | ENDIF |
---|
1194 | !!!!MARS << |
---|
1195 | CALL stuff_bdy ( mbdy2dtemp1 , grid%em_mu_b , 'M' , ijds , ijde , spec_bdy_width , & |
---|
1196 | ids , ide , jds , jde , 1 , 1 , & |
---|
1197 | ims , ime , jms , jme , 1 , 1 , & |
---|
1198 | ips , ipe , jps , jpe , 1 , 1 ) |
---|
1199 | |
---|
1200 | ELSE IF ( loop .EQ. time_loop_max ) THEN |
---|
1201 | |
---|
1202 | ! If this is the last time through here, we need to close the files. |
---|
1203 | |
---|
1204 | IF(grid%id .EQ. 1)CALL close_dataset ( id , config_flags , "DATASET=BOUNDARY" ) |
---|
1205 | IF(grid_fdda .EQ. 1)CALL close_dataset ( id2 , config_flags , "DATASET=AUXINPUT10" ) |
---|
1206 | IF(sst_update .EQ. 1)THEN |
---|
1207 | CALL close_dataset ( id5 , config_flags , "DATASET=AUXINPUT5" ) |
---|
1208 | ENDIF |
---|
1209 | |
---|
1210 | END IF |
---|
1211 | |
---|
1212 | END IF |
---|
1213 | |
---|
1214 | END SUBROUTINE assemble_output |
---|