1 MODULE module_optional_input
3 INTEGER :: flag_metgrid , flag_tavgsfc , flag_psfc , flag_soilhgt , flag_mf_xy , flag_slp , &
4 flag_snow , flag_snowh , flag_tsk , flag_pinterp , flag_prho
6 INTEGER :: flag_qv , flag_qc , flag_qr , flag_qi , flag_qs , &
8 flag_qni , flag_qnc , flag_qnr , &
9 flag_qns , flag_qng , flag_qnh , &
10 flag_qnwfa2d , flag_qnifa2d , flag_qnbca2d , flag_qnocbb2d , flag_qnbcbb2d , &
11 flag_qnwfa , flag_qnifa , flag_qnbca , &
12 flag_qnwfa_cl , flag_qnifa_cl , flag_qnbca_cl , &
14 flag_sh , flag_speccldl , flag_speccldf
16 INTEGER :: flag_soil_levels, flag_soil_layers
18 INTEGER :: flag_st000010 , flag_st010040 , flag_st040100 , flag_st100200 , flag_st010200 , &
19 flag_sm000010 , flag_sm010040 , flag_sm040100 , flag_sm100200 , flag_sm010200 , &
20 flag_sw000010 , flag_sw010040 , flag_sw040100 , flag_sw100200 , flag_sw010200
22 INTEGER :: flag_st000007 , flag_st007028 , flag_st028100 , flag_st100255 , &
23 flag_sm000007 , flag_sm007028 , flag_sm028100 , flag_sm100255
25 INTEGER :: flag_soilt000 , flag_soilt005 , flag_soilt020 , flag_soilt040 , flag_soilt160 , flag_soilt300 , &
26 flag_soilm000 , flag_soilm005 , flag_soilm020 , flag_soilm040 , flag_soilm160 , flag_soilm300 , &
27 flag_soilw000 , flag_soilw005 , flag_soilw020 , flag_soilw040 , flag_soilw160 , flag_soilw300
29 INTEGER :: flag_sst , flag_toposoil
31 INTEGER :: flag_icedepth , flag_icefrac , flag_albsi , flag_snowsi
33 INTEGER :: flag_ptheta
35 INTEGER :: flag_excluded_middle
37 INTEGER :: flag_um_soil
38 INTEGER :: flag_icepct
40 INTEGER :: flag_hgtmaxw , flag_pmaxw , flag_tmaxw , flag_umaxw , flag_vmaxw , &
41 flag_hgttrop , flag_ptrop , flag_ttrop , flag_utrop , flag_vtrop
42 INTEGER :: flag_pmaxwnn , flag_ptropnn
43 INTEGER :: flag_extra_levels
45 INTEGER :: flag_canfra , flag_clayfrac , flag_erod , flag_frc_urb2d , flag_imperv , &
46 flag_lai12m , flag_lake_depth , flag_sandfrac , flag_urb_param , flag_var_sso, &
49 integer :: flag_cldmask, flag_cldbasez, flag_cldtopz, flag_brtemp
51 INTEGER :: num_soil_levels_input
52 INTEGER :: num_st_levels_input , num_sm_levels_input , num_sw_levels_input
53 INTEGER :: num_st_levels_alloc , num_sm_levels_alloc , num_sw_levels_alloc
54 INTEGER , DIMENSION(100) :: st_levels_input , sm_levels_input , sw_levels_input
55 REAL , ALLOCATABLE , DIMENSION(:,:,:) :: st_input , sm_input , sw_input
57 CHARACTER (LEN=80) , PRIVATE :: flag_name
59 LOGICAL :: already_been_here
63 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
65 SUBROUTINE init_module_optional_input ( grid , config_flags )
67 USE module_domain , ONLY : domain
68 USE module_configure , ONLY : grid_config_rec_type
72 TYPE ( domain ) :: grid
73 TYPE (grid_config_rec_type) :: config_flags
75 INTEGER :: ids, ide, jds, jde, kds, kde, &
76 ims, ime, jms, jme, kms, kme, &
77 its, ite, jts, jte, kts, kte
79 ! Get the various indices, assume XYZ & XZY ordering.
81 ids = grid%sd31 ; ide = grid%ed31 ;
82 kds = grid%sd32 ; kde = grid%ed32 ;
83 jds = grid%sd33 ; jde = grid%ed33 ;
85 ims = grid%sm31 ; ime = grid%em31 ;
86 kms = grid%sm32 ; kme = grid%em32 ;
87 jms = grid%sm33 ; jme = grid%em33 ;
89 its = grid%sp31 ; ite = grid%ep31 ; ! note that tile is entire patch
90 kts = grid%sp32 ; kte = grid%ep32 ; ! note that tile is entire patch
91 jts = grid%sp33 ; jte = grid%ep33 ; ! note that tile is entire patch
93 IF ( .NOT. already_been_here ) THEN
95 num_st_levels_alloc = config_flags%num_soil_layers * 3 ! used to be 2
96 num_sm_levels_alloc = config_flags%num_soil_layers * 3
97 num_sw_levels_alloc = config_flags%num_soil_layers * 3
99 IF ( ALLOCATED ( st_input ) ) DEALLOCATE ( st_input )
100 IF ( ALLOCATED ( sm_input ) ) DEALLOCATE ( sm_input )
101 IF ( ALLOCATED ( sw_input ) ) DEALLOCATE ( sw_input )
103 ALLOCATE ( st_input(ims:ime,num_st_levels_alloc,jms:jme) )
104 ALLOCATE ( sm_input(ims:ime,num_sm_levels_alloc,jms:jme) )
105 ALLOCATE ( sw_input(ims:ime,num_sw_levels_alloc,jms:jme) )
109 already_been_here = .TRUE.
111 END SUBROUTINE init_module_optional_input
114 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
116 SUBROUTINE optional_input ( grid , fid, config_flags )
119 USE module_configure , ONLY : grid_config_rec_type
120 USE module_domain , ONLY : domain
124 TYPE ( domain ) :: grid
125 TYPE (grid_config_rec_type) :: config_flags
126 INTEGER , INTENT(IN) :: fid
128 INTEGER :: ids, ide, jds, jde, kds, kde, &
129 ims, ime, jms, jme, kms, kme, &
130 its, ite, jts, jte, kts, kte
132 INTEGER :: itmp , icnt , ierr, num_layers
133 CHARACTER (LEN=132) :: message
135 ! Get the various indices, assume XYZ & XZY ordering.
137 ids = grid%sd31 ; ide = grid%ed31 ;
138 kds = grid%sd32 ; kde = grid%ed32 ;
139 jds = grid%sd33 ; jde = grid%ed33 ;
141 ims = grid%sm31 ; ime = grid%em31 ;
142 kms = grid%sm32 ; kme = grid%em32 ;
143 jms = grid%sm33 ; jme = grid%em33 ;
145 its = grid%sp31 ; ite = grid%ep31 ; ! note that tile is entire patch
146 kts = grid%sp32 ; kte = grid%ep32 ; ! note that tile is entire patch
147 jts = grid%sp33 ; jte = grid%ep33 ; ! note that tile is entire patch
150 CALL optional_tsk ( grid , fid , &
151 ids, ide, jds, jde, kds, kde, &
152 ims, ime, jms, jme, kms, kme, &
153 its, ite, jts, jte, kts, kte )
155 CALL optional_tavgsfc ( grid , fid , &
156 ids, ide, jds, jde, kds, kde, &
157 ims, ime, jms, jme, kms, kme, &
158 its, ite, jts, jte, kts, kte )
160 CALL optional_moist ( grid , fid , &
161 ids, ide, jds, jde, kds, kde, &
162 ims, ime, jms, jme, kms, kme, &
163 its, ite, jts, jte, kts, kte )
165 CALL optional_metgrid ( grid , fid , &
166 ids, ide, jds, jde, kds, kde, &
167 ims, ime, jms, jme, kms, kme, &
168 its, ite, jts, jte, kts, kte )
170 CALL optional_sst ( grid , fid , &
171 ids, ide, jds, jde, kds, kde, &
172 ims, ime, jms, jme, kms, kme, &
173 its, ite, jts, jte, kts, kte )
175 CALL optional_snowh ( grid , fid , &
176 ids, ide, jds, jde, kds, kde, &
177 ims, ime, jms, jme, kms, kme, &
178 its, ite, jts, jte, kts, kte )
181 CALL optional_sfc ( grid , fid , &
182 ids, ide, jds, jde, kds, kde, &
183 ims, ime, jms, jme, kms, kme, &
184 its, ite, jts, jte, kts, kte )
186 CALL optional_ice ( grid , fid , &
187 config_flags%seaice_albedo_opt , &
188 config_flags%seaice_snowdepth_opt , &
189 config_flags%seaice_thickness_opt , &
190 ids, ide, jds, jde, kds, kde, &
191 ims, ime, jms, jme, kms, kme, &
192 its, ite, jts, jte, kts, kte )
194 CALL optional_geogrid ( grid , fid , &
195 ids, ide, jds, jde, kds, kde, &
196 ims, ime, jms, jme, kms, kme, &
197 its, ite, jts, jte, kts, kte )
199 CALL optional_ptheta ( grid , fid , &
200 ids, ide, jds, jde, kds, kde, &
201 ims, ime, jms, jme, kms, kme, &
202 its, ite, jts, jte, kts, kte )
204 CALL optional_excl_middle( grid , fid , &
205 ids, ide, jds, jde, kds, kde, &
206 ims, ime, jms, jme, kms, kme, &
207 its, ite, jts, jte, kts, kte )
209 CALL optional_levels ( grid , fid , &
210 ids, ide, jds, jde, kds, kde, &
211 ims, ime, jms, jme, kms, kme, &
212 its, ite, jts, jte, kts, kte )
217 ! How many soil levels have we found? Well, right now, none.
219 num_st_levels_input = 0
220 num_sm_levels_input = 0
221 num_sw_levels_input = 0
223 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_SOIL_LEVELS', itmp, 1, icnt, ierr )
225 IF ( ierr .EQ. 0 ) THEN
226 flag_soil_levels = itmp
227 write (message,'(A50,I3)') 'flag_soil_levels read from met_em file is',flag_soil_levels
228 CALL wrf_debug(0,message)
231 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_SOIL_LAYERS', itmp, 1, icnt, ierr )
233 IF ( ierr .EQ. 0 ) THEN
234 flag_soil_layers = itmp
235 write (message,'(A50,I3)') 'flag_soil_layers read from met_em file is',flag_soil_layers
236 CALL wrf_debug(0,message)
240 IF ( ( flag_soil_levels == 1 ) .OR. ( flag_soil_layers == 1 ) ) THEN
242 num_st_levels_input = config_flags%num_metgrid_soil_levels
243 num_sm_levels_input = config_flags%num_metgrid_soil_levels
244 num_sw_levels_input = config_flags%num_metgrid_soil_levels
245 num_soil_levels_input = config_flags%num_metgrid_soil_levels
250 IF ( ( model_config_rec%sf_surface_physics(grid%id) .EQ. 1 ) .OR. &
251 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 2 ) .OR. &
252 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 3 ) .OR. &
253 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 4 ) .OR. &
254 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 5 ) .OR. &
255 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 7 ) .OR. &
256 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 8 ) .OR. & !fds
257 ( model_config_rec%sf_surface_physics(grid%id) .EQ. 88 ) ) THEN
259 CALL optional_lsm_levels ( grid , fid , &
260 ids, ide, jds, jde, kds, kde, &
261 ims, ime, jms, jme, kms, kme, &
262 its, ite, jts, jte, kts, kte )
265 END SUBROUTINE optional_input
267 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
269 SUBROUTINE optional_moist ( grid , fid , &
270 ids, ide, jds, jde, kds, kde, &
271 ims, ime, jms, jme, kms, kme, &
272 its, ite, jts, jte, kts, kte )
275 USE module_domain , ONLY : domain
277 USE module_configure , ONLY : grid_config_rec_type
282 TYPE ( domain ) :: grid
283 INTEGER , INTENT(IN) :: fid
285 INTEGER :: ids, ide, jds, jde, kds, kde, &
286 ims, ime, jms, jme, kms, kme, &
287 its, ite, jts, jte, kts, kte
289 INTEGER :: itmp , icnt , ierr
326 flag_name(1:8) = 'QV '
327 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
328 IF ( ierr .EQ. 0 ) THEN
331 flag_name(1:8) = 'QC '
332 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
333 IF ( ierr .EQ. 0 ) THEN
336 flag_name(1:8) = 'QR '
337 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
338 IF ( ierr .EQ. 0 ) THEN
341 flag_name(1:8) = 'QI '
342 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
343 IF ( ierr .EQ. 0 ) THEN
346 flag_name(1:8) = 'QS '
347 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
348 IF ( ierr .EQ. 0 ) THEN
351 flag_name(1:8) = 'QG '
352 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
353 IF ( ierr .EQ. 0 ) THEN
356 flag_name(1:8) = 'QH '
357 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
358 IF ( ierr .EQ. 0 ) THEN
361 flag_name(1:8) = 'QNI '
362 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
363 IF ( ierr .EQ. 0 ) THEN
366 flag_name(1:8) = 'QNC '
367 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
368 IF ( ierr .EQ. 0 ) THEN
371 flag_name(1:8) = 'QNR '
372 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
373 IF ( ierr .EQ. 0 ) THEN
376 flag_name(1:8) = 'QNS '
377 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
378 IF ( ierr .EQ. 0 ) THEN
381 flag_name(1:8) = 'QNG '
382 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
383 IF ( ierr .EQ. 0 ) THEN
386 flag_name(1:8) = 'QNH '
387 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
388 IF ( ierr .EQ. 0 ) THEN
391 flag_name(1:8) = 'QNWFA2D '
392 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
393 IF ( ierr .EQ. 0 ) THEN
396 flag_name(1:8) = 'QNIFA2D '
397 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
398 IF ( ierr .EQ. 0 ) THEN
401 flag_name(1:8) = 'QNBCA2D '
402 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
403 IF ( ierr .EQ. 0 ) THEN
406 flag_name(1:8) = 'QNOCBB2D'
407 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
408 IF ( ierr .EQ. 0 ) THEN
411 flag_name(1:8) = 'QNBCBB2D'
412 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
413 IF ( ierr .EQ. 0 ) THEN
416 flag_name(1:8) = 'QNWFA '
417 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
418 IF ( ierr .EQ. 0 ) THEN
421 flag_name(1:8) = 'QNIFA '
422 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
423 IF ( ierr .EQ. 0 ) THEN
426 flag_name(1:8) = 'QNBCA '
427 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
428 IF ( ierr .EQ. 0 ) THEN
431 flag_name(1:8) = 'QNWFA_CL'
432 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
433 IF ( ierr .EQ. 0 ) THEN
436 flag_name(1:8) = 'QNIFA_CL'
437 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
438 IF ( ierr .EQ. 0 ) THEN
441 flag_name(1:8) = 'QNBCA_CL'
442 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
443 IF ( ierr .EQ. 0 ) THEN
446 flag_name(1:8) = 'P_WIF '
447 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
448 IF ( ierr .EQ. 0 ) THEN
451 flag_name(1:8) = 'SH '
452 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
453 IF ( ierr .EQ. 0 ) THEN
456 flag_name(1:8) = 'SPECCLDL'
457 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
458 IF ( ierr .EQ. 0 ) THEN
461 flag_name(1:8) = 'SPECCLDF'
462 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
463 IF ( ierr .EQ. 0 ) THEN
466 flag_name(1:8) = 'CLDMASK '
467 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
468 IF ( ierr .EQ. 0 ) THEN
471 flag_name(1:8) = 'CLDBASEZ'
472 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
473 IF ( ierr .EQ. 0 ) THEN
476 flag_name(1:8) = 'CLDTOPZ '
477 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
478 IF ( ierr .EQ. 0 ) THEN
481 flag_name(1:8) = 'BRTEMP '
482 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
483 IF ( ierr .EQ. 0 ) THEN
487 END SUBROUTINE optional_moist
489 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
491 SUBROUTINE optional_metgrid ( grid , fid , &
492 ids, ide, jds, jde, kds, kde, &
493 ims, ime, jms, jme, kms, kme, &
494 its, ite, jts, jte, kts, kte )
497 USE module_domain , ONLY : domain
498 USE module_configure , ONLY : grid_config_rec_type
503 TYPE ( domain ) :: grid
504 INTEGER , INTENT(IN) :: fid
506 INTEGER :: ids, ide, jds, jde, kds, kde, &
507 ims, ime, jms, jme, kms, kme, &
508 its, ite, jts, jte, kts, kte
510 INTEGER :: itmp , icnt , ierr
516 flag_name(1:8) = 'METGRID '
517 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
518 IF ( ierr .EQ. 0 ) THEN
524 flag_name(1:8) = 'P_INTERP'
525 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
526 IF ( ierr .EQ. 0 ) THEN
532 flag_name(1:8) = 'MF_XY '
533 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
534 IF ( ierr .EQ. 0 ) THEN
538 grid%flag_metgrid = flag_metgrid
539 grid%flag_mf_xy = flag_mf_xy
540 END SUBROUTINE optional_metgrid
542 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
544 SUBROUTINE optional_sst ( grid , fid , &
545 ids, ide, jds, jde, kds, kde, &
546 ims, ime, jms, jme, kms, kme, &
547 its, ite, jts, jte, kts, kte )
550 USE module_domain , ONLY : domain
551 USE module_configure , ONLY : grid_config_rec_type
556 TYPE ( domain ) :: grid
557 INTEGER , INTENT(IN) :: fid
559 INTEGER :: ids, ide, jds, jde, kds, kde, &
560 ims, ime, jms, jme, kms, kme, &
561 its, ite, jts, jte, kts, kte
563 INTEGER :: itmp , icnt , ierr
569 flag_name(1:8) = 'SST '
570 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
571 IF ( ierr .EQ. 0 ) THEN
575 END SUBROUTINE optional_sst
577 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
579 SUBROUTINE optional_levels ( grid , fid , &
580 ids, ide, jds, jde, kds, kde, &
581 ims, ime, jms, jme, kms, kme, &
582 its, ite, jts, jte, kts, kte )
585 USE module_domain , ONLY : domain
586 USE module_configure , ONLY : grid_config_rec_type
591 TYPE ( domain ) :: grid
592 INTEGER , INTENT(IN) :: fid
594 INTEGER :: ids, ide, jds, jde, kds, kde, &
595 ims, ime, jms, jme, kms, kme, &
596 its, ite, jts, jte, kts, kte
598 INTEGER :: itmp , icnt , ierr
614 flag_extra_levels = 0
616 flag_name(1:8) = 'HGTMAXW '
617 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
618 IF ( ierr .EQ. 0 ) THEN
621 flag_name(1:8) = 'PMAXW '
622 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
623 IF ( ierr .EQ. 0 ) THEN
626 flag_name(1:8) = 'PMAXWNN '
627 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
628 IF ( ierr .EQ. 0 ) THEN
631 flag_name(1:8) = 'TMAXW '
632 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
633 IF ( ierr .EQ. 0 ) THEN
636 flag_name(1:8) = 'UMAXW '
637 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
638 IF ( ierr .EQ. 0 ) THEN
641 flag_name(1:8) = 'VMAXW '
642 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
643 IF ( ierr .EQ. 0 ) THEN
646 flag_name(1:8) = 'HGTTROP '
647 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
648 IF ( ierr .EQ. 0 ) THEN
651 flag_name(1:8) = 'PTROP '
652 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
653 IF ( ierr .EQ. 0 ) THEN
656 flag_name(1:8) = 'PTROPNN '
657 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
658 IF ( ierr .EQ. 0 ) THEN
661 flag_name(1:8) = 'TTROP '
662 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
663 IF ( ierr .EQ. 0 ) THEN
666 flag_name(1:8) = 'UTROP '
667 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
668 IF ( ierr .EQ. 0 ) THEN
671 flag_name(1:8) = 'VTROP '
672 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
673 IF ( ierr .EQ. 0 ) THEN
677 ! Newer versions of WPS supply a nearest-neighbor version of pressure and a
678 ! pressure that is suitable for interpolation. If the nearest neighbor is
679 ! missing, all fields are set to unavailable.
681 IF ( flag_pmaxwnn .EQ. 0 ) THEN
689 IF ( flag_ptropnn .EQ. 0 ) THEN
697 flag_extra_levels = flag_hgtmaxw*flag_pmaxw*flag_tmaxw*flag_umaxw*flag_vmaxw* &
698 flag_hgttrop*flag_ptrop*flag_ttrop*flag_utrop*flag_vtrop
700 END SUBROUTINE optional_levels
702 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
705 SUBROUTINE optional_geogrid ( grid , fid , &
706 ids, ide, jds, jde, kds, kde, &
707 ims, ime, jms, jme, kms, kme, &
708 its, ite, jts, jte, kts, kte )
711 USE module_domain , ONLY : domain
712 USE module_configure , ONLY : grid_config_rec_type
717 TYPE ( domain ) :: grid
718 INTEGER , INTENT(IN) :: fid
720 INTEGER :: ids, ide, jds, jde, kds, kde, &
721 ims, ime, jms, jme, kms, kme, &
722 its, ite, jts, jte, kts, kte
724 INTEGER :: itmp , icnt , ierr
730 flag_name(1:6) = 'CANFRA'
731 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
732 IF ( ierr .EQ. 0 ) THEN
741 flag_name(1:8) = 'CLAYFRAC'
742 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
743 IF ( ierr .EQ. 0 ) THEN
752 flag_name(1:4) = 'EROD'
753 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
754 IF ( ierr .EQ. 0 ) THEN
763 flag_name(1:9) = 'FRC_URB2D'
764 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
765 IF ( ierr .EQ. 0 ) THEN
766 flag_frc_urb2d = itmp
774 flag_name(1:6) = 'IMPERV'
775 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
776 IF ( ierr .EQ. 0 ) THEN
785 flag_name(1:6) = 'LAI12M'
786 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
787 IF ( ierr .EQ. 0 ) THEN
796 flag_name(1:10) = 'LAKE_DEPTH'
797 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
798 IF ( ierr .EQ. 0 ) THEN
799 flag_lake_depth = itmp
806 flag_name(1:10) = 'BATHYMETRY'
807 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
808 IF ( ierr .EQ. 0 ) THEN
809 flag_bathymetry = itmp
817 flag_name(1:8) = 'SANDFRAC'
818 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
819 IF ( ierr .EQ. 0 ) THEN
828 flag_name(1:9) = 'URB_PARAM'
829 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
830 IF ( ierr .EQ. 0 ) THEN
831 flag_urb_param = itmp
839 flag_name(1:7) = 'VAR_SSO'
840 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
841 IF ( ierr .EQ. 0 ) THEN
845 END SUBROUTINE optional_geogrid
847 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
849 SUBROUTINE optional_tsk ( grid , fid , &
850 ids, ide, jds, jde, kds, kde, &
851 ims, ime, jms, jme, kms, kme, &
852 its, ite, jts, jte, kts, kte )
855 USE module_domain , ONLY : domain
856 USE module_configure , ONLY : grid_config_rec_type
861 TYPE ( domain ) :: grid
862 INTEGER , INTENT(IN) :: fid
864 INTEGER :: ids, ide, jds, jde, kds, kde, &
865 ims, ime, jms, jme, kms, kme, &
866 its, ite, jts, jte, kts, kte
868 INTEGER :: itmp , icnt , ierr
874 flag_name(1:8) = 'TSK '
875 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
876 IF ( ierr .EQ. 0 ) THEN
880 END SUBROUTINE optional_tsk
882 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
884 SUBROUTINE optional_tavgsfc ( grid , fid , &
885 ids, ide, jds, jde, kds, kde, &
886 ims, ime, jms, jme, kms, kme, &
887 its, ite, jts, jte, kts, kte )
890 USE module_domain , ONLY : domain
891 USE module_configure , ONLY : grid_config_rec_type
896 TYPE ( domain ) :: grid
897 INTEGER , INTENT(IN) :: fid
899 INTEGER :: ids, ide, jds, jde, kds, kde, &
900 ims, ime, jms, jme, kms, kme, &
901 its, ite, jts, jte, kts, kte
903 INTEGER :: itmp , icnt , ierr
909 flag_name(1:8) = 'TAVGSFC '
910 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
911 IF ( ierr .EQ. 0 ) THEN
915 END SUBROUTINE optional_tavgsfc
917 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
919 SUBROUTINE optional_snowh ( grid , fid , &
920 ids, ide, jds, jde, kds, kde, &
921 ims, ime, jms, jme, kms, kme, &
922 its, ite, jts, jte, kts, kte )
925 USE module_domain , ONLY : domain
926 USE module_configure , ONLY : grid_config_rec_type
931 TYPE ( domain ) :: grid
932 INTEGER , INTENT(IN) :: fid
934 INTEGER :: ids, ide, jds, jde, kds, kde, &
935 ims, ime, jms, jme, kms, kme, &
936 its, ite, jts, jte, kts, kte
938 INTEGER :: itmp , icnt , ierr
944 flag_name(1:8) = 'SNOWH '
945 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
946 IF ( ierr .EQ. 0 ) THEN
952 flag_name(1:8) = 'SNOW '
953 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
954 IF ( ierr .EQ. 0 ) THEN
957 grid%flag_snow = flag_snow
959 END SUBROUTINE optional_snowh
961 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
963 SUBROUTINE optional_sfc ( grid , fid , &
964 ids, ide, jds, jde, kds, kde, &
965 ims, ime, jms, jme, kms, kme, &
966 its, ite, jts, jte, kts, kte )
969 USE module_domain , ONLY : domain
970 USE module_configure , ONLY : grid_config_rec_type
975 TYPE ( domain ) :: grid
976 INTEGER , INTENT(IN) :: fid
978 INTEGER :: ids, ide, jds, jde, kds, kde, &
979 ims, ime, jms, jme, kms, kme, &
980 its, ite, jts, jte, kts, kte
982 INTEGER :: itmp , icnt , ierr
991 flag_name(1:8) = 'TOPOSOIL'
992 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
993 IF ( ierr .EQ. 0 ) THEN
997 flag_name(1:8) = 'PSFC '
998 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
999 IF ( ierr .EQ. 0 ) THEN
1003 flag_name(1:8) = 'SOILHGT '
1004 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1005 IF ( ierr .EQ. 0 ) THEN
1009 flag_name(1:8) = 'SLP '
1010 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1011 IF ( ierr .EQ. 0 ) THEN
1015 flag_name(1:8) = 'UM_SOIL '
1016 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1017 IF ( ierr .EQ. 0 ) THEN
1021 grid%flag_soilhgt = flag_soilhgt
1022 grid%flag_slp = flag_slp
1023 grid%flag_psfc = flag_psfc
1024 END SUBROUTINE optional_sfc
1026 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1028 SUBROUTINE optional_ice ( grid , fid , &
1029 seaice_albedo_opt , &
1030 seaice_snowdepth_opt , &
1031 seaice_thickness_opt , &
1032 ids, ide, jds, jde, kds, kde, &
1033 ims, ime, jms, jme, kms, kme, &
1034 its, ite, jts, jte, kts, kte )
1037 USE module_domain , ONLY : domain
1038 USE module_configure , ONLY : grid_config_rec_type
1039 USE module_io_domain
1043 TYPE ( domain ) :: grid
1044 INTEGER , INTENT(IN) :: fid
1045 INTEGER , INTENT(IN) :: seaice_albedo_opt
1046 INTEGER , INTENT(IN) :: seaice_snowdepth_opt
1047 INTEGER , INTENT(IN) :: seaice_thickness_opt
1049 INTEGER :: ids, ide, jds, jde, kds, kde, &
1050 ims, ime, jms, jme, kms, kme, &
1051 its, ite, jts, jte, kts, kte
1053 INTEGER :: itmp , icnt , ierr, i, j
1062 flag_name(1:8) = 'ICEFRAC '
1063 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1064 IF ( ierr .EQ. 0 ) THEN
1068 flag_name(1:8) = 'ICEPCT '
1069 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1070 IF ( ierr .EQ. 0 ) THEN
1074 flag_name(1:8) = 'ICEDEPTH'
1075 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1076 IF ( ierr .EQ. 0 ) THEN
1077 flag_icedepth = itmp
1080 flag_name(1:8) = 'ALBSI '
1081 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1082 IF ( ierr .EQ. 0 ) THEN
1086 flag_name(1:8) = 'SNOWSI '
1087 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1088 IF ( ierr .EQ. 0 ) THEN
1093 ! Check that ICEDEPTH field is available for SEAICE_THICKNESS_OPT == 1
1095 IF ( flag_icedepth == 0 ) THEN
1096 IF ( seaice_thickness_opt == 1 ) THEN
1097 call wrf_error_fatal("Field ICEDEPTH not found in input. Field ICEDEPTH is required if SEAICE_THICKNESS_OPT=1")
1098 ! DO j = jts , MIN(jde-1,jte)
1099 ! DO i = its , MIN(ide-1,ite)
1100 ! grid%icedepth(i,j) = -1.E8
1107 ! Check that ALBSI field is available for SEAICE_ALBEDO_OPT == 2
1109 IF ( flag_albsi == 0 ) THEN
1110 IF ( seaice_albedo_opt == 2 ) THEN
1111 call wrf_error_fatal("Field ALBSI not found in input. Field ALBSI is required if SEAICE_ALBEDO_OPT=2")
1112 ! DO j = jts , MIN(jde-1,jte)
1113 ! DO i = its , MIN(ide-1,ite)
1114 ! grid%albsi(i,j) = -1.E8
1121 ! Check that SNOWSI field is available for SEAICE_SNOWDEPTH_OPT == 1
1123 IF ( flag_snowsi == 0 ) THEN
1124 IF ( seaice_snowdepth_opt == 1 ) THEN
1125 call wrf_error_fatal("Field SNOWSI not found in input. Field SNOWSI is required if SEAICE_SNOWDEPTH_OPT=1")
1126 ! DO j = jts , MIN(jde-1,jte)
1127 ! DO i = its , MIN(ide-1,ite)
1128 ! grid%snowsi(i,j) = -1.E8
1134 END SUBROUTINE optional_ice
1136 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1138 SUBROUTINE optional_ptheta ( grid , fid , &
1139 ids, ide, jds, jde, kds, kde, &
1140 ims, ime, jms, jme, kms, kme, &
1141 its, ite, jts, jte, kts, kte )
1144 USE module_domain , ONLY : domain
1145 USE module_configure , ONLY : grid_config_rec_type
1146 USE module_io_domain
1150 TYPE ( domain ) :: grid
1151 INTEGER , INTENT(IN) :: fid
1153 INTEGER :: ids, ide, jds, jde, kds, kde, &
1154 ims, ime, jms, jme, kms, kme, &
1155 its, ite, jts, jte, kts, kte
1157 INTEGER :: itmp , icnt , ierr
1163 flag_name(1:8) = 'PTHETA '
1164 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1165 IF ( ierr .EQ. 0 ) THEN
1173 flag_name(1:8) = 'PRHO '
1174 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1175 IF ( ierr .EQ. 0 ) THEN
1179 END SUBROUTINE optional_ptheta
1181 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1183 SUBROUTINE optional_excl_middle ( grid , fid , &
1184 ids, ide, jds, jde, kds, kde, &
1185 ims, ime, jms, jme, kms, kme, &
1186 its, ite, jts, jte, kts, kte )
1189 USE module_domain , ONLY : domain
1190 USE module_configure , ONLY : grid_config_rec_type
1191 USE module_io_domain
1195 TYPE ( domain ) :: grid
1196 INTEGER , INTENT(IN) :: fid
1198 INTEGER :: ids, ide, jds, jde, kds, kde, &
1199 ims, ime, jms, jme, kms, kme, &
1200 its, ite, jts, jte, kts, kte
1202 INTEGER :: itmp , icnt , ierr
1206 flag_excluded_middle = 0
1208 flag_name(1:16) = 'EXCLUDED_MIDDLE '
1209 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1210 IF ( ierr .EQ. 0 ) THEN
1211 flag_excluded_middle = itmp
1214 END SUBROUTINE optional_excl_middle
1216 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1218 SUBROUTINE optional_lsm_levels ( grid , fid , &
1219 ids, ide, jds, jde, kds, kde, &
1220 ims, ime, jms, jme, kms, kme, &
1221 its, ite, jts, jte, kts, kte )
1224 USE module_domain , ONLY : domain
1225 !USE module_configure , ONLY : grid_config_rec_type
1226 USE module_io_domain
1230 TYPE ( domain ) :: grid
1231 INTEGER , INTENT(IN) :: fid
1233 INTEGER :: ids, ide, jds, jde, kds, kde, &
1234 ims, ime, jms, jme, kms, kme, &
1235 its, ite, jts, jte, kts, kte
1237 INTEGER :: itmp , icnt , ierr , i , j , k
1238 INTEGER :: level_above
1239 CHARACTER (LEN=132) :: message
1241 ! Initialize the soil temp and moisture flags to "field not found".
1294 st_levels_input = -1
1295 sm_levels_input = -1
1296 sw_levels_input = -1
1299 !-------------------------------------------------------------------------
1300 ! NOTE: We are assuming that soil_layers are the same for each grid point
1301 !-------------------------------------------------------------------------
1302 IF ( flag_soil_levels == 1 ) THEN
1304 DO k = 1, num_st_levels_input
1305 st_levels_input(k) = grid%soil_levels(its,num_st_levels_input + 1 - k,jts)
1306 sm_levels_input(k) = grid%soil_levels(its,num_st_levels_input + 1 - k,jts)
1307 sw_levels_input(k) = grid%soil_levels(its,num_st_levels_input + 1 - k,jts)
1310 !----------------------------------------------------------------
1311 ! Flip the input soil temperature/moisture/water
1312 ! profiles upside down to make k=1 closest to the sfc
1313 !----------------------------------------------------------------
1314 DO j = jts , MIN(jde-1,jte)
1315 DO k = 1, num_st_levels_input
1316 DO i = its , MIN(ide-1,ite)
1317 st_input(i,k,j) = grid%soilt(i,num_st_levels_input + 1 - k,j)
1318 sm_input(i,k,j) = grid%soilm(i,num_st_levels_input + 1 - k,j)
1319 !-------------------------------------------------------------------------
1320 ! Initialize sw_input to 0. For 3D RUC soil moisture, there is no sw,
1321 ! but num_sw_levels_input is set to num_metgrid_soil_levels from the
1322 ! namelist causing sw_input to be used in init_soil_#_real subroutines
1323 !-------------------------------------------------------------------------
1324 sw_input(i,k,j) = 0.0
1329 END IF ! flag_soil_levels == 1
1331 IF ( flag_soil_layers == 1 ) THEN
1333 DO k = 1, num_st_levels_input
1334 !-------------------------------------------------------------
1335 ! Calculate mid-point of each layer and set to st_levels_input
1336 ! Flip the input soil depths upside down to make k=1 closest to the sfc
1337 !-------------------------------------------------------------
1338 !st_levels_input(k) = (level_above + grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1339 !sm_levels_input(k) = (level_above + grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1340 !sw_levels_input(k) = (level_above + grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1341 !level_above = grid%soil_layers(its,num_st_levels_input + 1 - k,jts)
1342 !-------------------------------------------------------------
1343 ! If UM soil input, levels are cumulative (0-10cm, 0-25cm,
1344 ! etc.) so we simply take the midpoint of each level - GAC
1345 !-------------------------------------------------------------
1346 IF ( flag_um_soil == 1 ) THEN
1347 st_levels_input(k) = (grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1348 sm_levels_input(k) = (grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1349 sw_levels_input(k) = (grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1351 st_levels_input(k) = (level_above + grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1352 sm_levels_input(k) = (level_above + grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1353 sw_levels_input(k) = (level_above + grid%soil_layers(its,num_st_levels_input + 1 - k,jts))/2
1354 level_above = grid%soil_layers(its,num_st_levels_input + 1 - k,jts)
1359 !----------------------------------------------------------------
1360 ! Flip the input soil temperature/moisture/water
1361 ! profiles upside down to make k=1 closest to the sfc
1362 !----------------------------------------------------------------
1363 DO j = jts , MIN(jde-1,jte)
1364 DO k = 1, num_st_levels_input
1365 DO i = its , MIN(ide-1,ite)
1366 st_input(i,k+1,j) = grid%st(i,num_st_levels_input + 1 - k,j)
1367 sm_input(i,k+1,j) = grid%sm(i,num_st_levels_input + 1 - k,j)
1368 sw_input(i,k+1,j) = grid%sw(i,num_st_levels_input + 1 - k,j)
1373 !----------------------------------------------------------------
1374 ! UM input is in kg/m2, convert to volumetric soil moisture here
1375 !----------------------------------------------------------------
1376 IF ( flag_um_soil == 1 ) THEN
1377 DO j = jts, MIN(jde-1,jte)
1378 DO k = 1, num_sm_levels_input
1379 DO i = its, MIN(ide-1,ite)
1380 sm_input(i,k+1,j)=100.*sm_input(i,k+1,j)/(2*sm_levels_input(k)*1000.)
1386 END IF ! flag_soil_layers == 1
1389 IF ( ( flag_soil_levels == 0 ) .AND. ( flag_soil_layers == 0 ) ) THEN ! Legacy code
1391 flag_name(1:8) = 'ST000010'
1392 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1393 IF ( ierr .EQ. 0 ) THEN
1394 flag_st000010 = itmp
1395 num_st_levels_input = num_st_levels_input + 1
1396 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1397 DO j = jts , MIN(jde-1,jte)
1398 DO i = its , MIN(ide-1,ite)
1399 st_input(i,num_st_levels_input + 1,j) = grid%st000010(i,j)
1403 flag_name(1:8) = 'ST010040'
1404 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1405 IF ( ierr .EQ. 0 ) THEN
1406 flag_st010040 = itmp
1407 num_st_levels_input = num_st_levels_input + 1
1408 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1409 DO j = jts , MIN(jde-1,jte)
1410 DO i = its , MIN(ide-1,ite)
1411 st_input(i,num_st_levels_input + 1,j) = grid%st010040(i,j)
1415 flag_name(1:8) = 'ST040100'
1416 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1417 IF ( ierr .EQ. 0 ) THEN
1418 flag_st040100 = itmp
1419 num_st_levels_input = num_st_levels_input + 1
1420 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1421 DO j = jts , MIN(jde-1,jte)
1422 DO i = its , MIN(ide-1,ite)
1423 st_input(i,num_st_levels_input + 1,j) = grid%st040100(i,j)
1427 flag_name(1:8) = 'ST100200'
1428 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1429 IF ( ierr .EQ. 0 ) THEN
1430 flag_st100200 = itmp
1431 num_st_levels_input = num_st_levels_input + 1
1432 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1433 DO j = jts , MIN(jde-1,jte)
1434 DO i = its , MIN(ide-1,ite)
1435 st_input(i,num_st_levels_input + 1,j) = grid%st100200(i,j)
1439 flag_name(1:8) = 'ST010200'
1440 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1441 IF ( ierr .EQ. 0 ) THEN
1442 flag_st010200 = itmp
1443 num_st_levels_input = num_st_levels_input + 1
1444 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1445 DO j = jts , MIN(jde-1,jte)
1446 DO i = its , MIN(ide-1,ite)
1447 st_input(i,num_st_levels_input + 1,j) = grid%st010200(i,j)
1451 flag_name(1:8) = 'ST000007'
1452 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1453 IF ( ierr .EQ. 0 ) THEN
1454 flag_st000007 = itmp
1455 num_st_levels_input = num_st_levels_input + 1
1456 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1457 DO j = jts , MIN(jde-1,jte)
1458 DO i = its , MIN(ide-1,ite)
1459 st_input(i,num_st_levels_input + 1,j) = grid%st000007(i,j)
1463 flag_name(1:8) = 'ST007028'
1464 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1465 IF ( ierr .EQ. 0 ) THEN
1466 flag_st007028 = itmp
1467 num_st_levels_input = num_st_levels_input + 1
1468 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1469 DO j = jts , MIN(jde-1,jte)
1470 DO i = its , MIN(ide-1,ite)
1471 st_input(i,num_st_levels_input + 1,j) = grid%st007028(i,j)
1475 flag_name(1:8) = 'ST028100'
1476 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1477 IF ( ierr .EQ. 0 ) THEN
1478 flag_st028100 = itmp
1479 num_st_levels_input = num_st_levels_input + 1
1480 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1481 DO j = jts , MIN(jde-1,jte)
1482 DO i = its , MIN(ide-1,ite)
1483 st_input(i,num_st_levels_input + 1,j) = grid%st028100(i,j)
1487 flag_name(1:8) = 'ST100255'
1488 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1489 IF ( ierr .EQ. 0 ) THEN
1490 flag_st100255 = itmp
1491 num_st_levels_input = num_st_levels_input + 1
1492 st_levels_input(num_st_levels_input) = char2int2(flag_name(3:8))
1493 DO j = jts , MIN(jde-1,jte)
1494 DO i = its , MIN(ide-1,ite)
1495 st_input(i,num_st_levels_input + 1,j) = grid%st100255(i,j)
1499 flag_name(1:8) = 'SOILT000'
1500 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1501 IF ( ierr .EQ. 0 ) THEN
1502 flag_soilt000 = itmp
1503 num_st_levels_input = num_st_levels_input + 1
1504 st_levels_input(num_st_levels_input) = char2int1(flag_name(6:8))
1505 DO j = jts , MIN(jde-1,jte)
1506 DO i = its , MIN(ide-1,ite)
1507 st_input(i,num_st_levels_input ,j) = grid%soilt000(i,j)
1511 flag_name(1:8) = 'SOILT005'
1512 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1513 IF ( ierr .EQ. 0 ) THEN
1514 flag_soilt005 = itmp
1515 num_st_levels_input = num_st_levels_input + 1
1516 st_levels_input(num_st_levels_input) = char2int1(flag_name(6:8))
1517 DO j = jts , MIN(jde-1,jte)
1518 DO i = its , MIN(ide-1,ite)
1519 st_input(i,num_st_levels_input ,j) = grid%soilt005(i,j)
1523 flag_name(1:8) = 'SOILT020'
1524 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1525 IF ( ierr .EQ. 0 ) THEN
1526 flag_soilt020 = itmp
1527 num_st_levels_input = num_st_levels_input + 1
1528 st_levels_input(num_st_levels_input) = char2int1(flag_name(6:8))
1529 DO j = jts , MIN(jde-1,jte)
1530 DO i = its , MIN(ide-1,ite)
1531 st_input(i,num_st_levels_input ,j) = grid%soilt020(i,j)
1535 flag_name(1:8) = 'SOILT040'
1536 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1537 IF ( ierr .EQ. 0 ) THEN
1538 flag_soilt040 = itmp
1539 num_st_levels_input = num_st_levels_input + 1
1540 st_levels_input(num_st_levels_input) = char2int1(flag_name(6:8))
1541 DO j = jts , MIN(jde-1,jte)
1542 DO i = its , MIN(ide-1,ite)
1543 st_input(i,num_st_levels_input ,j) = grid%soilt040(i,j)
1547 flag_name(1:8) = 'SOILT160'
1548 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1549 IF ( ierr .EQ. 0 ) THEN
1550 flag_soilt160 = itmp
1551 num_st_levels_input = num_st_levels_input + 1
1552 st_levels_input(num_st_levels_input) = char2int1(flag_name(6:8))
1553 DO j = jts , MIN(jde-1,jte)
1554 DO i = its , MIN(ide-1,ite)
1555 st_input(i,num_st_levels_input ,j) = grid%soilt160(i,j)
1559 flag_name(1:8) = 'SOILT300'
1560 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1561 IF ( ierr .EQ. 0 ) THEN
1562 flag_soilt300 = itmp
1563 num_st_levels_input = num_st_levels_input + 1
1564 st_levels_input(num_st_levels_input) = char2int1(flag_name(6:8))
1565 DO j = jts , MIN(jde-1,jte)
1566 DO i = its , MIN(ide-1,ite)
1567 st_input(i,num_st_levels_input ,j) = grid%soilt300(i,j)
1572 flag_name(1:8) = 'SM000010'
1573 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1574 IF ( ierr .EQ. 0 ) THEN
1575 flag_sm000010 = itmp
1576 num_sm_levels_input = num_sm_levels_input + 1
1577 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1578 DO j = jts , MIN(jde-1,jte)
1579 DO i = its , MIN(ide-1,ite)
1580 sm_input(i,num_sm_levels_input + 1,j) = grid%sm000010(i,j)
1584 flag_name(1:8) = 'SM010040'
1585 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1586 IF ( ierr .EQ. 0 ) THEN
1587 flag_sm010040 = itmp
1588 num_sm_levels_input = num_sm_levels_input + 1
1589 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1590 DO j = jts , MIN(jde-1,jte)
1591 DO i = its , MIN(ide-1,ite)
1592 sm_input(i,num_sm_levels_input + 1,j) = grid%sm010040(i,j)
1596 flag_name(1:8) = 'SM040100'
1597 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1598 IF ( ierr .EQ. 0 ) THEN
1599 flag_sm040100 = itmp
1600 num_sm_levels_input = num_sm_levels_input + 1
1601 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1602 DO j = jts , MIN(jde-1,jte)
1603 DO i = its , MIN(ide-1,ite)
1604 sm_input(i,num_sm_levels_input + 1,j) = grid%sm040100(i,j)
1608 flag_name(1:8) = 'SM100200'
1609 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1610 IF ( ierr .EQ. 0 ) THEN
1611 flag_sm100200 = itmp
1612 num_sm_levels_input = num_sm_levels_input + 1
1613 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1614 DO j = jts , MIN(jde-1,jte)
1615 DO i = its , MIN(ide-1,ite)
1616 sm_input(i,num_sm_levels_input + 1,j) = grid%sm100200(i,j)
1620 flag_name(1:8) = 'SM010200'
1621 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1622 IF ( ierr .EQ. 0 ) THEN
1623 flag_sm010200 = itmp
1624 num_sm_levels_input = num_sm_levels_input + 1
1625 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1626 DO j = jts , MIN(jde-1,jte)
1627 DO i = its , MIN(ide-1,ite)
1628 sm_input(i,num_sm_levels_input + 1,j) = grid%sm010200(i,j)
1632 flag_name(1:8) = 'SM000007'
1633 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1634 IF ( ierr .EQ. 0 ) THEN
1635 flag_sm000007 = itmp
1636 num_sm_levels_input = num_sm_levels_input + 1
1637 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1638 DO j = jts , MIN(jde-1,jte)
1639 DO i = its , MIN(ide-1,ite)
1640 sm_input(i,num_sm_levels_input + 1,j) = grid%sm000007(i,j)
1644 flag_name(1:8) = 'SM007028'
1645 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1646 IF ( ierr .EQ. 0 ) THEN
1647 flag_sm007028 = itmp
1648 num_sm_levels_input = num_sm_levels_input + 1
1649 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1650 DO j = jts , MIN(jde-1,jte)
1651 DO i = its , MIN(ide-1,ite)
1652 sm_input(i,num_sm_levels_input + 1,j) = grid%sm007028(i,j)
1656 flag_name(1:8) = 'SM028100'
1657 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1658 IF ( ierr .EQ. 0 ) THEN
1659 flag_sm028100 = itmp
1660 num_sm_levels_input = num_sm_levels_input + 1
1661 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1662 DO j = jts , MIN(jde-1,jte)
1663 DO i = its , MIN(ide-1,ite)
1664 sm_input(i,num_sm_levels_input + 1,j) = grid%sm028100(i,j)
1668 flag_name(1:8) = 'SM100255'
1669 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1670 IF ( ierr .EQ. 0 ) THEN
1671 flag_sm100255 = itmp
1672 num_sm_levels_input = num_sm_levels_input + 1
1673 sm_levels_input(num_sm_levels_input) = char2int2(flag_name(3:8))
1674 DO j = jts , MIN(jde-1,jte)
1675 DO i = its , MIN(ide-1,ite)
1676 sm_input(i,num_sm_levels_input + 1,j) = grid%sm100255(i,j)
1680 flag_name(1:8) = 'SOILM000'
1681 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1682 IF ( ierr .EQ. 0 ) THEN
1683 flag_soilm000 = itmp
1684 num_sm_levels_input = num_sm_levels_input + 1
1685 sm_levels_input(num_sm_levels_input) = char2int1(flag_name(6:8))
1686 DO j = jts , MIN(jde-1,jte)
1687 DO i = its , MIN(ide-1,ite)
1688 sm_input(i,num_sm_levels_input ,j) = grid%soilm000(i,j)
1692 flag_name(1:8) = 'SOILM005'
1693 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1694 IF ( ierr .EQ. 0 ) THEN
1695 flag_soilm005 = itmp
1696 num_sm_levels_input = num_sm_levels_input + 1
1697 sm_levels_input(num_sm_levels_input) = char2int1(flag_name(6:8))
1698 DO j = jts , MIN(jde-1,jte)
1699 DO i = its , MIN(ide-1,ite)
1700 sm_input(i,num_sm_levels_input ,j) = grid%soilm005(i,j)
1704 flag_name(1:8) = 'SOILM020'
1705 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1706 IF ( ierr .EQ. 0 ) THEN
1707 flag_soilm020 = itmp
1708 num_sm_levels_input = num_sm_levels_input + 1
1709 sm_levels_input(num_sm_levels_input) = char2int1(flag_name(6:8))
1710 DO j = jts , MIN(jde-1,jte)
1711 DO i = its , MIN(ide-1,ite)
1712 sm_input(i,num_sm_levels_input ,j) = grid%soilm020(i,j)
1716 flag_name(1:8) = 'SOILM040'
1717 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1718 IF ( ierr .EQ. 0 ) THEN
1719 flag_soilm040 = itmp
1720 num_sm_levels_input = num_sm_levels_input + 1
1721 sm_levels_input(num_sm_levels_input) = char2int1(flag_name(6:8))
1722 DO j = jts , MIN(jde-1,jte)
1723 DO i = its , MIN(ide-1,ite)
1724 sm_input(i,num_sm_levels_input ,j) = grid%soilm040(i,j)
1728 flag_name(1:8) = 'SOILM160'
1729 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1730 IF ( ierr .EQ. 0 ) THEN
1731 flag_soilm160 = itmp
1732 num_sm_levels_input = num_sm_levels_input + 1
1733 sm_levels_input(num_sm_levels_input) = char2int1(flag_name(6:8))
1734 DO j = jts , MIN(jde-1,jte)
1735 DO i = its , MIN(ide-1,ite)
1736 sm_input(i,num_sm_levels_input ,j) = grid%soilm160(i,j)
1740 flag_name(1:8) = 'SOILM300'
1741 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1742 IF ( ierr .EQ. 0 ) THEN
1743 flag_soilm300 = itmp
1744 num_sm_levels_input = num_sm_levels_input + 1
1745 sm_levels_input(num_sm_levels_input) = char2int1(flag_name(6:8))
1746 DO j = jts , MIN(jde-1,jte)
1747 DO i = its , MIN(ide-1,ite)
1748 sm_input(i,num_sm_levels_input ,j) = grid%soilm300(i,j)
1753 flag_name(1:8) = 'SW000010'
1754 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1755 IF ( ierr .EQ. 0 ) THEN
1756 flag_sw000010 = itmp
1757 num_sw_levels_input = num_sw_levels_input + 1
1758 sw_levels_input(num_sw_levels_input) = char2int2(flag_name(3:8))
1759 DO j = jts , MIN(jde-1,jte)
1760 DO i = its , MIN(ide-1,ite)
1761 sw_input(i,num_sw_levels_input + 1,j) = grid%sw000010(i,j)
1765 flag_name(1:8) = 'SW010040'
1766 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1767 IF ( ierr .EQ. 0 ) THEN
1768 flag_sw010040 = itmp
1769 num_sw_levels_input = num_sw_levels_input + 1
1770 sw_levels_input(num_sw_levels_input) = char2int2(flag_name(3:8))
1771 DO j = jts , MIN(jde-1,jte)
1772 DO i = its , MIN(ide-1,ite)
1773 sw_input(i,num_sw_levels_input + 1,j) = grid%sw010040(i,j)
1777 flag_name(1:8) = 'SW040100'
1778 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1779 IF ( ierr .EQ. 0 ) THEN
1780 flag_sw040100 = itmp
1781 num_sw_levels_input = num_sw_levels_input + 1
1782 sw_levels_input(num_sw_levels_input) = char2int2(flag_name(3:8))
1783 DO j = jts , MIN(jde-1,jte)
1784 DO i = its , MIN(ide-1,ite)
1785 sw_input(i,num_sw_levels_input + 1,j) = grid%sw040100(i,j)
1789 flag_name(1:8) = 'SW100200'
1790 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1791 IF ( ierr .EQ. 0 ) THEN
1792 flag_sw100200 = itmp
1793 num_sw_levels_input = num_sw_levels_input + 1
1794 sw_levels_input(num_sw_levels_input) = char2int2(flag_name(3:8))
1795 DO j = jts , MIN(jde-1,jte)
1796 DO i = its , MIN(ide-1,ite)
1797 sw_input(i,num_sw_levels_input + 1,j) = grid%sw100200(i,j)
1801 flag_name(1:8) = 'SW010200'
1802 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1803 IF ( ierr .EQ. 0 ) THEN
1804 flag_sw010200 = itmp
1805 num_sw_levels_input = num_sw_levels_input + 1
1806 sw_levels_input(num_sw_levels_input) = char2int2(flag_name(3:8))
1807 DO j = jts , MIN(jde-1,jte)
1808 DO i = its , MIN(ide-1,ite)
1809 sw_input(i,num_sw_levels_input + 1,j) = grid%sw010200(i,j)
1813 flag_name(1:8) = 'SOILW000'
1814 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1815 IF ( ierr .EQ. 0 ) THEN
1816 flag_soilw000 = itmp
1817 num_sw_levels_input = num_sw_levels_input + 1
1818 sw_levels_input(num_sw_levels_input) = char2int1(flag_name(6:8))
1819 DO j = jts , MIN(jde-1,jte)
1820 DO i = its , MIN(ide-1,ite)
1821 sw_input(i,num_sw_levels_input ,j) = grid%soilw000(i,j)
1825 flag_name(1:8) = 'SOILW005'
1826 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1827 IF ( ierr .EQ. 0 ) THEN
1828 flag_soilw005 = itmp
1829 num_sw_levels_input = num_sw_levels_input + 1
1830 sw_levels_input(num_sw_levels_input) = char2int1(flag_name(6:8))
1831 DO j = jts , MIN(jde-1,jte)
1832 DO i = its , MIN(ide-1,ite)
1833 sw_input(i,num_sw_levels_input ,j) = grid%soilw005(i,j)
1837 flag_name(1:8) = 'SOILW020'
1838 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1839 IF ( ierr .EQ. 0 ) THEN
1840 flag_soilw020 = itmp
1841 num_sw_levels_input = num_sw_levels_input + 1
1842 sw_levels_input(num_sw_levels_input) = char2int1(flag_name(6:8))
1843 DO j = jts , MIN(jde-1,jte)
1844 DO i = its , MIN(ide-1,ite)
1845 sw_input(i,num_sw_levels_input ,j) = grid%soilw020(i,j)
1849 flag_name(1:8) = 'SOILW040'
1850 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1851 IF ( ierr .EQ. 0 ) THEN
1852 flag_soilw040 = itmp
1853 num_sw_levels_input = num_sw_levels_input + 1
1854 sw_levels_input(num_sw_levels_input) = char2int1(flag_name(6:8))
1855 DO j = jts , MIN(jde-1,jte)
1856 DO i = its , MIN(ide-1,ite)
1857 sw_input(i,num_sw_levels_input ,j) = grid%soilw040(i,j)
1861 flag_name(1:8) = 'SOILW160'
1862 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1863 IF ( ierr .EQ. 0 ) THEN
1864 flag_soilw160 = itmp
1865 num_sw_levels_input = num_sw_levels_input + 1
1866 sw_levels_input(num_sw_levels_input) = char2int1(flag_name(6:8))
1867 DO j = jts , MIN(jde-1,jte)
1868 DO i = its , MIN(ide-1,ite)
1869 sw_input(i,num_sw_levels_input ,j) = grid%soilw160(i,j)
1873 flag_name(1:8) = 'SOILW300'
1874 CALL wrf_get_dom_ti_integer ( fid, 'FLAG_' // flag_name, itmp, 1, icnt, ierr )
1875 IF ( ierr .EQ. 0 ) THEN
1876 flag_soilw300 = itmp
1877 num_sw_levels_input = num_sw_levels_input + 1
1878 sw_levels_input(num_sw_levels_input) = char2int1(flag_name(6:8))
1879 DO j = jts , MIN(jde-1,jte)
1880 DO i = its , MIN(ide-1,ite)
1881 sw_input(i,num_sw_levels_input ,j) = grid%soilw300(i,j)
1886 END IF ! End of legacy code for temperature and moisture
1888 ! The flags flag_st*, flag_sm*, flag_sw*, flag_soilt*, flag_soilm*, flag_soilw* are no longer used.
1889 ! If the new flags flag_soil_layers or flag_soil_levels are not set in met_em, and some legacy
1890 ! flags are, reset the new flags
1892 IF ( ( flag_soil_levels == 0 ) .AND. ( flag_soil_layers == 0 ) ) THEN
1893 IF ( flag_st000010 == 1 .OR. flag_st010040 == 1 .OR. flag_st040100 == 1 .OR. &
1894 flag_st100200 == 1 .OR. flag_st010200 == 1 .OR. &
1895 flag_sm000010 == 1 .OR. flag_sm010040 == 1 .OR. flag_sm040100 == 1 .OR. &
1896 flag_sm100200 == 1 .OR. flag_sm010200 == 1 .OR. &
1897 flag_sw000010 == 1 .OR. flag_sw010040 == 1 .OR. flag_sw040100 == 1 .OR. &
1898 flag_sw100200 == 1 .OR. flag_sw010200 == 1 .OR. &
1899 flag_st000007 == 1 .OR. flag_st007028 == 1 .OR. flag_st028100 == 1 .OR. &
1900 flag_st100255 == 1 .OR. &
1901 flag_sm000007 == 1 .OR. flag_sm007028 == 1 .OR. flag_sm028100 == 1 .OR. &
1902 flag_sm100255 == 1 ) THEN
1905 IF ( flag_soilt000 == 1 .OR. flag_soilt005 == 1 .OR. flag_soilt020 == 1 .OR. &
1906 flag_soilt040 == 1 .OR. flag_soilt160 == 1 .OR. flag_soilt300 == 1 .OR. &
1907 flag_soilm000 == 1 .OR. flag_soilm005 == 1 .OR. flag_soilm020 == 1 .OR. &
1908 flag_soilm040 == 1 .OR. flag_soilm160 == 1 .OR. flag_soilm300 == 1 .OR. &
1909 flag_soilw000 == 1 .OR. flag_soilw005 == 1 .OR. flag_soilw020 == 1 .OR. &
1910 flag_soilw040 == 1 .OR. flag_soilw160 == 1 .OR. flag_soilw300 == 1 ) THEN
1915 write (message,'(A,I3)') 'flag_soil_layers at end of optional_lsm_levels is',flag_soil_layers
1916 CALL wrf_debug(1,message)
1917 write (message,'(A,I3)') 'flag_soil_levels at end of optional_lsm_levels is',flag_soil_levels
1918 CALL wrf_debug(1,message)
1920 write (message,'(A,10(i3,1x))') 'st_levels_input = ', (st_levels_input(k), k=1,num_st_levels_input)
1921 CALL wrf_debug(1,message)
1922 write (message,'(A,10(i3,1x))') 'sm_levels_input = ', (sm_levels_input(k), k=1,num_sm_levels_input)
1923 CALL wrf_debug(1,message)
1924 write (message,'(A,10(i3,1x))') 'sw_levels_input = ', (sw_levels_input(k), k=1,num_sw_levels_input)
1925 CALL wrf_debug(1,message)
1927 ! OK, let's do a quick sanity check.
1929 IF ( ( num_st_levels_input .GT. num_st_levels_alloc ) .OR. &
1930 ( num_sm_levels_input .GT. num_sm_levels_alloc ) .OR. &
1931 ( num_sw_levels_input .GT. num_sw_levels_alloc ) ) THEN
1932 print *,'pain and woe, the soil level allocation is too small'
1933 CALL wrf_error_fatal ( 'soil_levels_too_few' )
1936 END SUBROUTINE optional_lsm_levels
1938 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1940 FUNCTION char2int1( string3 ) RESULT ( int1 )
1941 CHARACTER (LEN=3) , INTENT(IN) :: string3
1942 INTEGER :: i1 , int1
1943 READ(string3,fmt='(I3)') i1
1945 END FUNCTION char2int1
1947 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1949 FUNCTION char2int2( string6 ) RESULT ( int1 )
1950 CHARACTER (LEN=6) , INTENT(IN) :: string6
1951 INTEGER :: i2 , i1 , int1
1952 READ(string6,fmt='(I3,I3)') i1,i2
1953 int1 = ( i2 + i1 ) / 2
1954 END FUNCTION char2int2
1956 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1958 END MODULE module_optional_input