Skip to content

Commit ac0a39e

Browse files
adding PRODUCT DEFINITION TEMPLATE 4.49 (#136)
* starting to add 4.49 * starting to add 4.49 * starting to add 4.49 * working on 4.49
1 parent 5e46d04 commit ac0a39e

File tree

2 files changed

+139
-3
lines changed

2 files changed

+139
-3
lines changed

src/grib2_all_tables_module.F90

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ subroutine g2sec4_temp46(icatg, iparm, aer_type, typ_intvl_size,
23902390
ipdstmpl46(35) = time_inc_betwn_succ_fld ! value = 0
23912391
!
23922392
end subroutine g2sec4_temp46
2393-
!>
2393+
23942394
!> This subroutine returns the Grib2 Section 4 Template 4.0 list for given keys
23952395
!> PDT 4.48 - Analysis or forecast at a horizontal level or in a
23962396
!> horizontal layer at a point in time for aerosol.
@@ -2500,8 +2500,131 @@ subroutine g2sec4_temp48(icatg, iparm, aer_type, typ_intvl_size,
25002500
ipdstmpl48(26) = scaled_val2
25012501
!
25022502
end subroutine g2sec4_temp48
2503-
!
2504-
!
2503+
2504+
!> This subroutine returns the Grib2 Section 4 Template 4.0 list for
2505+
!> given keys PDT 4.49 - Individual Ensemble Forecast, Control and
2506+
!> Perturbed, at a horizontal level or in a horizontal layer at a
2507+
!> point in time for Optical Properties of Aerosol for Optical
2508+
!> Properties of Aerosol.
2509+
!>
2510+
!> @param[in] icatg - Parameter category (see Code table 4.1)
2511+
!> @param[in] iparm - Parameter number (see Code table 4.2)
2512+
!> @param[in] aer_type - Aetosol type (see Code table 4.233)
2513+
!> @param[in] typ_intvl_size - Type of interval for first and second size (see Code table 4.91)
2514+
!> @param[in] scale_fac1_size - Scale factor of first size
2515+
!> @param[in] scale_val1_size - Scale value of first size in meters
2516+
!> @param[in] scale_fac2_size - Scale factor of second size
2517+
!> @param[in] scale_val2_size - Scale value of second size in meters
2518+
!> @param[in] typ_intvl_wavelength - Type of interval for first and second wavelength (see Code table 4.91)
2519+
!> @param[in] scale_fac1_wavelength - Scale factor of first wavelength
2520+
!> @param[in] scale_val1_wavelength - Scale value of first wavelength in meters
2521+
!> @param[in] scale_fac2_wavelength - Scale factor of second wavelength
2522+
!> @param[in] scale_val2_wavelength - Scale value of second wavelength in meters
2523+
!> @param[in] typ_gen_proc_key - Type of generating process (see Code table 4.3)
2524+
!> @param[in] gen_proc_or_mod_key - Analysis or forecast generating process identified (see Code ON388 Table A)
2525+
!> @param[in] hrs_obs_cutoff - Hours of observational data cutoff after reference time (see Note)
2526+
!> @param[in] min_obs_cutoff - Minutes of observational data cutoff after reference time (see Note)
2527+
!> @param[in] unit_of_time_key - Indicator of unit of time range (see Code table 4.4)
2528+
!> @param[in] fcst_time - Forecast time in units defined by octet 18
2529+
!> @param[in] lvl_type1 - Type of first fixed surface (see Code table 4.5)
2530+
!> @param[in] scale_fac1 - Scale factor of first fixed surface
2531+
!> @param[in] scaled_val1 - Scaled value of first fixed surface
2532+
!> @param[in] lvl_type2 - Type of second fixed surfaced (see Code table 4.5)
2533+
!> @param[in] scale_fac2 - Scale factor of second fixed surface
2534+
!> @param[in] scaled_val2 - Scaled value of second fixed surfaces
2535+
!> @param[in] type_ens_fcst_key Type of ensemble forecast (see Code table 4.6)
2536+
!> @param[in] perturb_num Perturbation ensemble number
2537+
!> @param[in] num_fcst_ens number of forecasts in ensemble
2538+
!> @param[out] ipdstmpl49 - GRIB2 PDS Template 4.49 listing
2539+
!>
2540+
!> @author Edward Hartnett @date 2024-07-02
2541+
subroutine g2sec4_temp49(icatg, iparm, aer_type, typ_intvl_size, &
2542+
scale_fac1_size, scale_val1_size, scale_fac2_size, &
2543+
scale_val2_size, typ_intvl_wavelength, &
2544+
scale_fac1_wavelength, scale_val1_wavelength, &
2545+
scale_fac2_wavelength, scale_val2_wavelength, &
2546+
typ_gen_proc_key, gen_proc_or_mod_key, &
2547+
hrs_obs_cutoff, min_obs_cutoff, &
2548+
unit_of_time_key, fcst_time, lvl_type1, scale_fac1, &
2549+
scaled_val1, lvl_type2, scale_fac2, scaled_val2, &
2550+
type_ens_fcst_key, perturb_num, num_fcst_ens, &
2551+
ipdstmpl49)
2552+
2553+
integer(4), intent(in) :: icatg, iparm, hrs_obs_cutoff, min_obs_cutoff, &
2554+
scale_fac1_size, scale_fac2_size, scale_fac1_wavelength, &
2555+
scale_fac2_wavelength, &
2556+
fcst_time, scale_fac1, scaled_val1, &
2557+
scale_fac2, scaled_val2
2558+
integer(4),intent(in) :: perturb_num, num_fcst_ens
2559+
real, intent(in) :: scale_val1_size, scale_val2_size, scale_val1_wavelength, &
2560+
scale_val2_wavelength
2561+
2562+
character(len=*), intent(in) :: aer_type, typ_intvl_size, &
2563+
typ_intvl_wavelength, typ_gen_proc_key, &
2564+
gen_proc_or_mod_key, unit_of_time_key, lvl_type1, lvl_type2, &
2565+
type_ens_fcst_key
2566+
2567+
integer(4), intent(inout) :: ipdstmpl49(29)
2568+
2569+
!local vars
2570+
integer(4) :: value, ierr
2571+
integer(4) :: bckgnd_gen_proc_id ! defined by the center
2572+
2573+
bckgnd_gen_proc_id=0 ! defined by the center
2574+
2575+
ipdstmpl49(1) = icatg
2576+
ipdstmpl49(2) = iparm
2577+
2578+
call get_g2_typeofaerosol(aer_type, value, ierr)
2579+
ipdstmpl49(3) = value
2580+
2581+
call get_g2_typeofintervals(typ_intvl_size, value, ierr)
2582+
ipdstmpl49(4) = value
2583+
ipdstmpl49(5) = scale_fac1_size
2584+
ipdstmpl49(6) = nint(scale_val1_size)
2585+
ipdstmpl49(7) = scale_fac2_size
2586+
ipdstmpl49(8) = nint(scale_val2_size)
2587+
2588+
call get_g2_typeofintervals(typ_intvl_wavelength, value, ierr)
2589+
ipdstmpl49(9) = value
2590+
ipdstmpl49(10) = scale_fac1_wavelength
2591+
ipdstmpl49(11) = nint(scale_val1_wavelength)
2592+
ipdstmpl49(12) = scale_fac2_wavelength
2593+
ipdstmpl49(13) = nint(scale_val2_wavelength)
2594+
2595+
call get_g2_typeofgenproc(typ_gen_proc_key, value, ierr)
2596+
ipdstmpl49(14) = value
2597+
2598+
ipdstmpl49(15) = bckgnd_gen_proc_id
2599+
2600+
call get_g2_on388genproc(gen_proc_or_mod_key, value, ierr)
2601+
ipdstmpl49(16) = value
2602+
2603+
ipdstmpl49(17) = hrs_obs_cutoff
2604+
ipdstmpl49(18) = min_obs_cutoff
2605+
2606+
call get_g2_unitoftimerange(unit_of_time_key, value, ierr)
2607+
ipdstmpl49(19) = value
2608+
ipdstmpl49(20) = fcst_time
2609+
2610+
call get_g2_fixedsurfacetypes(lvl_type1, value, ierr)
2611+
ipdstmpl49(21) = value
2612+
ipdstmpl49(22) = scale_fac1
2613+
ipdstmpl49(23) = scaled_val1
2614+
2615+
call get_g2_fixedsurfacetypes(lvl_type2, value, ierr)
2616+
ipdstmpl49(24) = value
2617+
2618+
ipdstmpl49(25) = scale_fac2
2619+
ipdstmpl49(26) = scaled_val2
2620+
2621+
call get_g2_typeofensfcst(type_ens_fcst_key, value, ierr)
2622+
ipdstmpl49(27) = value
2623+
ipdstmpl49(28) = perturb_num
2624+
ipdstmpl49(29) = num_fcst_ens
2625+
2626+
end subroutine g2sec4_temp49
2627+
25052628
!> This subroutine returns the corresponding GRIB2 type of
25062629
!> ensemble forecast value for a given short key name based on Table 4.6
25072630
!>

tests/test_all_table_other.F90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ program test_all_table_other
2121
integer :: ipdstmpl48(26)
2222
integer :: ipdstmpl48_expected(26) = (/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 0, &
2323
12, 15, 16, 13, 18, 20, 20, 21, 100, 22, 23 /)
24+
integer :: ipdstmpl49(29)
25+
integer :: ipdstmpl49_expected(29) = (/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 0, &
26+
12, 15, 16, 13, 18, 20, 20, 21, 100, 22, 23, 0, 0, 0 /)
2427
integer :: ifield5(16)
2528
integer :: ifield5_expected(16) = (/ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /)
2629
integer :: ifield5_0(5)
@@ -78,6 +81,16 @@ program test_all_table_other
7881
if (ipdstmpl48(i) .ne. ipdstmpl48_expected(i)) stop 6
7982
end do
8083

84+
print *, 'testing g2sec4_temp49'
85+
call g2sec4_temp49(0, 1, 'methane', 'greater_than_first_limit', 4, 5.0, 6, 7.0, &
86+
'greater_or_equal_first_limit', 9, 10., 11, 12., 'prob_wt_fcst', 'prob_st_surg', 15, 16, &
87+
'second', 18, 'isothermal', 20, 21, 'isobaric_sfc', 22, 23, &
88+
'unpert_hi_res_ctrl_fcst', 0, 0, ipdstmpl49)
89+
do i = 1, 29
90+
print *, ipdstmpl49(i)
91+
if (ipdstmpl49(i) .ne. ipdstmpl49_expected(i)) stop 65
92+
end do
93+
8194
print *, 'testing g2sec5_temp0'
8295
call g2sec5_temp0(0, 1, 2, ifield5_0)
8396
do i = 1, 5

0 commit comments

Comments
 (0)