15 character(len=500),
public :: varmap_file =
"NULL"
16 character(len=500),
public :: atm_files_input_grid(6) =
"NULL"
20 character(len=500),
public :: atm_core_files_input_grid(7) =
"NULL"
21 character(len=500),
public :: atm_tracer_files_input_grid(6) =
"NULL"
22 character(len=500),
public :: data_dir_input_grid =
"NULL"
23 character(len=500),
public :: fix_dir_target_grid =
"NULL"
24 character(len=500),
public :: mosaic_file_input_grid =
"NULL"
25 character(len=500),
public :: mosaic_file_target_grid =
"NULL"
26 character(len=500),
public :: nst_files_input_grid =
"NULL"
27 character(len=500),
public :: grib2_file_input_grid =
"NULL"
28 character(len=500),
public :: geogrid_file_input_grid =
"NULL"
31 character(len=500),
public :: orog_dir_input_grid =
"NULL"
32 character(len=500),
public :: orog_files_input_grid(6) =
"NULL"
33 character(len=500),
public :: orog_dir_target_grid =
"NULL"
34 character(len=500),
public :: orog_files_target_grid(6) =
"NULL"
35 character(len=500),
public :: sfc_files_input_grid(6) =
"NULL"
36 character(len=500),
public :: vcoord_file_target_grid =
"NULL"
37 character(len=500),
public :: thomp_mp_climo_file=
"NULL"
38 character(len=6),
public :: cres_target_grid =
"NULL"
39 character(len=500),
public :: atm_weight_file=
"NULL"
40 character(len=25),
public :: input_type=
"restart"
54 character(len=20),
public :: external_model=
"GFS"
56 character(len=500),
public :: fix_dir_input_grid =
"NULL"
60 integer,
parameter,
public :: max_tracers=100
61 integer,
public :: num_tracers
62 integer,
public :: num_tracers_input
64 logical,
allocatable,
public :: read_from_input(:)
67 character(len=20),
public :: tracers(max_tracers)=
"NULL"
73 character(len=20),
public :: tracers_input(max_tracers)=
"NULL"
78 character(len=20),
allocatable,
public :: missing_var_methods(:)
80 character(len=20),
allocatable,
public :: chgres_var_names(:)
82 character(len=20),
allocatable,
public :: field_var_names(:)
85 integer,
public :: cycle_mon = -999
86 integer,
public :: cycle_day = -999
87 integer,
public :: cycle_hour = -999
88 integer,
public :: regional = 0
90 integer,
public :: halo_bndy = 0
91 integer,
public :: halo_blend = 0
92 integer,
public :: nsoill_out = 4
94 logical,
public :: convert_atm = .false.
95 logical,
public :: convert_nst = .false.
96 logical,
public :: convert_sfc = .false.
100 logical,
public :: vgtyp_from_climo = .true.
104 logical,
public :: sotyp_from_climo = .true.
109 logical,
public :: vgfrc_from_climo = .true.
114 logical,
public :: minmax_vgfrc_from_climo = .true.
118 logical,
public :: lai_from_climo = .true.
121 logical,
public :: tg3_from_soil = .false.
124 logical,
public :: use_thomp_mp_climo=.false.
126 real,
allocatable,
public :: drysmc_input(:)
127 real,
allocatable,
public :: drysmc_target(:)
128 real,
allocatable,
public :: maxsmc_input(:)
129 real,
allocatable,
public :: maxsmc_target(:)
130 real,
allocatable,
public :: refsmc_input(:)
131 real,
allocatable,
public :: refsmc_target(:)
132 real,
allocatable,
public :: wltsmc_input(:)
133 real,
allocatable,
public :: wltsmc_target(:)
134 real,
allocatable,
public :: bb_target(:)
135 real,
allocatable,
public :: satpsi_target(:)
136 real,
allocatable,
public :: missing_var_values(:)
155 character(len=*),
intent(in),
optional :: filename
156 character(:),
allocatable :: filename_to_use
159 integer :: is, ie, ierr
162 namelist /config/ varmap_file, &
163 mosaic_file_target_grid, &
164 fix_dir_target_grid, &
165 orog_dir_target_grid, &
166 orog_files_target_grid, &
167 mosaic_file_input_grid, &
168 orog_dir_input_grid, &
169 orog_files_input_grid, &
170 nst_files_input_grid, &
171 sfc_files_input_grid, &
172 atm_files_input_grid, &
173 atm_core_files_input_grid, &
174 atm_tracer_files_input_grid, &
175 grib2_file_input_grid, &
176 geogrid_file_input_grid, &
177 data_dir_input_grid, &
178 vcoord_file_target_grid, &
179 cycle_mon, cycle_day, &
180 cycle_hour, convert_atm, &
181 convert_nst, convert_sfc, &
185 minmax_vgfrc_from_climo, &
186 lai_from_climo, tg3_from_soil, &
187 regional, input_type, &
189 atm_weight_file, tracers, &
193 fix_dir_input_grid, &
197 print*,
"- READ SETUP NAMELIST"
199 if (present(filename))
then
200 filename_to_use = filename
202 filename_to_use =
"./fort.41"
205 open(41, file=filename_to_use, iostat=ierr)
206 if (ierr /= 0) call
error_handler(
"OPENING SETUP NAMELIST.", ierr)
207 read(41, nml=config, iostat=ierr)
208 if (ierr /= 0) call
error_handler(
"READING SETUP NAMELIST.", ierr)
213 orog_dir_target_grid = trim(orog_dir_target_grid) //
'/'
214 orog_dir_input_grid = trim(orog_dir_input_grid) //
'/'
220 is = index(mosaic_file_target_grid,
"/", .true.)
221 ie = index(mosaic_file_target_grid,
"mosaic") - 1
223 if (is == 0 .or. ie == 0)
then
224 call
error_handler(
"CANT DETERMINE CRES FROM MOSAIC FILE.", 1)
227 cres_target_grid = mosaic_file_target_grid(is+1:ie-1)
229 if (.not. convert_sfc .and. .not. convert_atm)
then
230 call
error_handler(
"MUST CONVERT EITHER AN ATM OR SFC FILE.", 1)
241 if (regional > 0)
then
242 print*,
"- PROCESSING A REGIONAL NEST WITH A BOUNDARY HALO OF ",halo_bndy
243 print*,
"- PROCESSING A REGIONAL NEST WITH A BLENDING HALO OF ",halo_blend
250 do is = 1, max_tracers
251 if (trim(tracers(is)) ==
"NULL")
exit
252 num_tracers = num_tracers + 1
253 print*,
"- WILL PROCESS TRACER ", trim(tracers(is))
256 num_tracers_input = 0
257 do is = 1, max_tracers
258 if (trim(tracers_input(is)) ==
"NULL")
exit
259 num_tracers_input = num_tracers_input + 1
260 print*,
"- WILL PROCESS INPUT TRACER ", trim(tracers_input(is))
267 select case (trim(input_type))
269 print*,
'- INPUT DATA FROM FV3 TILED RESTART FILES.'
271 print*,
'- INPUT DATA FROM FV3 TILED HISTORY FILES.'
272 case (
"gaussian_nemsio")
273 print*,
'- INPUT DATA FROM FV3 GAUSSIAN NEMSIO FILE.'
274 case (
"gfs_gaussian_nemsio")
275 print*,
'- INPUT DATA FROM SPECTRAL GFS GAUSSIAN NEMSIO FILE.'
277 print*,
'- INPUT DATA FROM SPECTRAL GFS SIGIO/SFCIO FILE.'
278 case (
"gaussian_netcdf")
279 print*,
'- INPUT DATA FROM FV3 GAUSSIAN NETCDF FILE.'
281 print*,
'- INPUT DATA FROM A GRIB2 FILE'
290 if (trim(input_type) ==
"grib2")
then
291 if (trim(grib2_file_input_grid) ==
"NULL" .or. trim(grib2_file_input_grid) ==
"")
then
292 call
error_handler(
"FOR GRIB2 DATA, PLEASE PROVIDE GRIB2_FILE_INPUT_GRID", 1)
300 if (trim(input_type) ==
"grib2")
then
301 if (.not. any((/
character(4)::
"GFS",
"NAM",
"RAP",
"HRRR"/)==trim(external_model))) then
302 call
error_handler(
"KNOWN SUPPORTED external_model INPUTS ARE GFS, NAM, RAP, AND HRRR. " // &
303 "IF YOU WISH TO PROCESS GRIB2 DATA FROM ANOTHER MODEL, YOU MAY ATTEMPT TO DO SO AT YOUR OWN RISK. " // &
304 "ONE WAY TO DO THIS IS PROVIDE NAM FOR external_model AS IT IS A RELATIVELY STRAIGHT-" // &
305 "FORWARD REGIONAL GRIB2 FILE. YOU MAY ALSO COMMENT OUT THIS ERROR MESSAGE IN " // &
306 "program_setup.f90 LINE 389. NO GUARANTEE IS PROVIDED THAT THE CODE WILL WORK OR "// &
307 "THAT THE RESULTING DATA WILL BE CORRECT OR WORK WITH THE ATMOSPHERIC MODEL.", 1)
316 if (trim(input_type) ==
"grib2" .and. trim(external_model)==
"HRRR")
then
317 if (trim(geogrid_file_input_grid) ==
"NULL" .or. trim(grib2_file_input_grid) ==
"")
then
318 print*,
"HRRR DATA DOES NOT CONTAIN SOIL TYPE INFORMATION. WITHOUT &
319 GEOGRID_FILE_INPUT_GRID SPECIFIED, SOIL MOISTURE INTERPOLATION MAY BE LESS &
324 if (trim(thomp_mp_climo_file) /=
"NULL")
then
325 use_thomp_mp_climo=.true.
326 print*,
"- WILL PROCESS CLIMO THOMPSON MP TRACERS FROM FILE: ", trim(thomp_mp_climo_file)
342 integer :: istat, k, nvars
343 character(len=500) :: line
344 character(len=20),
allocatable :: var_type(:)
346 if (trim(input_type) ==
"grib2")
then
348 print*,
"OPEN VARIABLE MAPPING FILE: ", trim(varmap_file)
349 open(14, file=trim(varmap_file), form=
'formatted', iostat=istat)
359 read(14,
'(A)', iostat=istat) line
362 if ( trim(line) .eq.
'' ) cycle
365 if ( nvars == 0) call
error_handler(
"VARMAP FILE IS EMPTY.", -1)
367 allocate(chgres_var_names(nvars))
368 allocate(field_var_names(nvars))
369 allocate(missing_var_methods(nvars))
370 allocate(missing_var_values(nvars))
371 allocate(read_from_input(nvars))
372 allocate(var_type(nvars))
374 read_from_input(:) = .true.
377 read(14, *, iostat=istat) chgres_var_names(k), field_var_names(k) , &
378 missing_var_methods(k), missing_var_values(k), var_type(k)
379 if (istat /= 0) call
error_handler(
"READING VARIABLE MAPPING FILE", istat)
380 if(trim(var_type(k))==
'T')
then
381 num_tracers = num_tracers + 1
382 tracers_input(num_tracers)=chgres_var_names(k)
383 if ((trim(chgres_var_names(k)) ==
"ice_aero" .or. trim(chgres_var_names(k)) ==
"liq_aero") .and. &
384 trim(thomp_mp_climo_file) .ne.
"NULL" .and. trim(input_type) ==
"grib2")
then
385 call
error_handler(
"VARMAP TABLE CONTAINS TRACER ENTRIES FOR THOMPSON AEROSOLS liq_aero or "// &
386 "ice_aero. REMOVE THESE ENTRIES OR REMOVE THE NAMELIST ENTRY FOR "// &
387 "thomp_mp_climo_file AND TRY AGAIN.",1)
407 subroutine get_var_cond(var_name,this_miss_var_method,this_miss_var_value, &
408 this_field_var_name, loc)
412 character(len=20),
intent(in) :: var_name
414 character(len=20),
optional,
intent(out) :: this_miss_var_method, &
416 real(esmf_kind_r4),
optional,
intent(out):: this_miss_var_value
418 integer,
optional,
intent(out) :: loc
420 integer :: i, tmp(size(missing_var_methods))
425 where(chgres_var_names==var_name) tmp=1
427 i = maxloc(merge(1.,0.,chgres_var_names == var_name),dim=1)
429 if (maxval(tmp).eq.0)
then
430 print*,
"WARNING: NO ENTRY FOR ", trim(var_name),
" IN VARMAP TABLE. WILL SKIP " // &
431 "VARIABLE IF NOT FOUND IN EXTERNAL MODEL FILE"
433 if(present(this_miss_var_method)) this_miss_var_method =
"skip"
434 if(present(this_miss_var_value)) this_miss_var_value = -9999.9_esmf_kind_r4
435 if(present(this_field_var_name)) this_field_var_name =
"NULL"
436 if(present(loc)) loc = 9999
438 if(present(this_miss_var_method)) this_miss_var_method = missing_var_methods(i)
439 if(present(this_miss_var_value)) this_miss_var_value = missing_var_values(i)
440 if(present(this_field_var_name)) this_field_var_name = field_var_names(i)
441 if(present(loc)) loc = i
483 integer,
intent(in) :: localpet
485 integer,
parameter :: num_statsgo = 16
486 real,
parameter :: smlow_statsgo = 0.5
487 real,
parameter :: smhigh_statsgo = 6.0
490 integer,
parameter :: num_zobler = 9
491 real,
parameter :: smlow_zobler = 0.5
492 real,
parameter :: smhigh_zobler = 6.0
494 integer :: num_soil_cats
496 real :: bb_statsgo(num_statsgo)
497 real :: maxsmc_statsgo(num_statsgo)
498 real :: satdk_statsgo(num_statsgo)
499 real :: satpsi_statsgo(num_statsgo)
501 real :: bb_zobler(num_zobler)
502 real :: maxsmc_zobler(num_zobler)
503 real :: satdk_zobler(num_zobler)
504 real :: satpsi_zobler(num_zobler)
506 real,
allocatable :: bb(:)
507 real :: smlow, smhigh
508 real,
allocatable :: satdk(:)
509 real,
allocatable :: satpsi(:)
510 real,
allocatable :: satdw(:)
513 data bb_statsgo /4.05, 4.26, 4.74, 5.33, 5.33, 5.25, &
514 6.77, 8.72, 8.17, 10.73, 10.39, 11.55, &
515 5.25, -9.99, 4.05, 4.26/
517 data maxsmc_statsgo /0.395, 0.421, 0.434, 0.476, 0.476, 0.439, &
518 0.404, 0.464, 0.465, 0.406, 0.468, 0.457, &
519 0.464, -9.99, 0.200, 0.421/
521 data satdk_statsgo /1.7600e-4, 1.4078e-5, 5.2304e-6, 2.8089e-6, 2.8089e-6, &
522 3.3770e-6, 4.4518e-6, 2.0348e-6, 2.4464e-6, 7.2199e-6, &
523 1.3444e-6, 9.7384e-7, 3.3770e-6, -9.99, 1.4078e-5, &
526 data satpsi_statsgo /0.0350, 0.0363, 0.1413, 0.7586, 0.7586, 0.3548, &
527 0.1349, 0.6166, 0.2630, 0.0977, 0.3236, 0.4677, &
528 0.3548, -9.99, 0.0350, 0.0363/
530 data bb_zobler /4.26, 8.72, 11.55, 4.74, 10.73, 8.17, &
533 data maxsmc_zobler /0.421, 0.464, 0.468, 0.434, 0.406, 0.465, &
536 data satdk_zobler /1.41e-5, 0.20e-5, 0.10e-5, 0.52e-5, 0.72e-5, &
537 0.25e-5, 0.45e-5, 0.34e-5, 1.41e-5/
539 data satpsi_zobler /0.040, 0.620, 0.470, 0.140, 0.100, 0.260, &
546 select case (trim(input_type))
548 print*,
'- INPUT GRID USED ZOBLER SOIL TYPES.'
549 num_soil_cats = num_zobler
551 print*,
'- INPUT GRID USED STATSGO SOIL TYPES.'
552 num_soil_cats = num_statsgo
555 allocate(maxsmc_input(num_soil_cats))
556 allocate(wltsmc_input(num_soil_cats))
557 allocate(drysmc_input(num_soil_cats))
558 allocate(refsmc_input(num_soil_cats))
559 allocate(bb(num_soil_cats))
560 allocate(satdk(num_soil_cats))
561 allocate(satpsi(num_soil_cats))
562 allocate(satdw(num_soil_cats))
564 select case (trim(input_type))
567 smhigh = smhigh_zobler
568 maxsmc_input = maxsmc_zobler
571 satpsi = satpsi_zobler
573 smlow = smlow_statsgo
574 smhigh = smhigh_statsgo
575 maxsmc_input = maxsmc_statsgo
577 satdk = satdk_statsgo
578 satpsi = satpsi_statsgo
582 bb, satpsi, satdw, refsmc_input, drysmc_input, wltsmc_input)
584 deallocate(bb, satdk, satpsi, satdw)
586 if (localpet == 0) print*,
'maxsmc input grid ',maxsmc_input
587 if (localpet == 0) print*,
'wltsmc input grid ',wltsmc_input
593 print*,
'- TARGET GRID USEING STATSGO SOIL TYPES.'
595 num_soil_cats = num_statsgo
597 allocate(maxsmc_target(num_soil_cats))
598 allocate(wltsmc_target(num_soil_cats))
599 allocate(drysmc_target(num_soil_cats))
600 allocate(refsmc_target(num_soil_cats))
601 allocate(bb_target(num_soil_cats))
602 allocate(satpsi_target(num_soil_cats))
603 allocate(satdk(num_soil_cats))
604 allocate(satdw(num_soil_cats))
606 smlow = smlow_statsgo
607 smhigh = smhigh_statsgo
608 maxsmc_target = maxsmc_statsgo
609 bb_target = bb_statsgo
610 satdk = satdk_statsgo
611 satpsi_target = satpsi_statsgo
614 bb_target, satpsi_target, satdw, refsmc_target, drysmc_target, wltsmc_target)
616 deallocate(satdk, satdw)
618 if (localpet == 0) print*,
'maxsmc target grid ',maxsmc_target
619 if (localpet == 0) print*,
'wltsmc input grid ',wltsmc_target
640 maxsmc, bb, satpsi, satdw, refsmc, drysmc, wltsmc)
644 integer,
intent(in) :: num_soil_cats
646 real,
intent(in) :: smlow, smhigh
647 real,
intent(in) :: bb(num_soil_cats)
648 real,
intent(in) :: maxsmc(num_soil_cats)
649 real,
intent(in) :: satdk(num_soil_cats)
650 real,
intent(in) :: satpsi(num_soil_cats)
652 real,
intent(out) :: satdw(num_soil_cats)
653 real,
intent(out) :: refsmc(num_soil_cats)
654 real,
intent(out) :: drysmc(num_soil_cats)
655 real,
intent(out) :: wltsmc(num_soil_cats)
667 do i = 1, num_soil_cats
669 if (maxsmc(i) > 0.0)
then
671 satdw(i) = bb(i)*satdk(i)*(satpsi(i)/maxsmc(i))
672 refsmc1 = maxsmc(i)*(5.79e-9/satdk(i)) **(1.0/(2.0*bb(i)+3.0))
673 refsmc(i) = refsmc1 + (maxsmc(i)-refsmc1) / smhigh
674 wltsmc1 = maxsmc(i) * (200.0/satpsi(i))**(-1.0/bb(i))
675 wltsmc(i) = wltsmc1 - smlow * wltsmc1
682 drysmc(i) = wltsmc(i)
subroutine, public calc_soil_params_driver(localpet)
Driver routine to compute soil parameters for each soil type.
subroutine to_lower(strIn)
Convert from upper to lowercase.
subroutine, public read_setup_namelist(filename)
Reads program configuration namelist.
subroutine error_handler(string, rc)
General error handler.
This module contains code to read the setup namelist file, handle the varmap file for GRIB2 data...
subroutine, public read_varmap
Reads the variable mapping table, which is required for initializing with GRIB2 data.
subroutine, public get_var_cond(var_name, this_miss_var_method, this_miss_var_value, this_field_var_name, loc)
Search the variable mapping table to find conditions for handling missing variables.
subroutine calc_soil_params(num_soil_cats, smlow, smhigh, satdk, maxsmc, bb, satpsi, satdw, refsmc, drysmc, wltsmc)
Compute soil parameters.