diff --git a/.gitignore b/.gitignore index c0823ccc76..b580da07fc 100644 --- a/.gitignore +++ b/.gitignore @@ -207,6 +207,7 @@ test_normal_dist test_beta_dist test_kde_dist test_window +test_force_bounds # Directories to NOT IGNORE ... same as executable names # as far as I know, these must be listed after the executables diff --git a/assimilation_code/modules/assimilation/algorithm_info_mod.f90 b/assimilation_code/modules/assimilation/algorithm_info_mod.f90 index 41887d4cad..e7c4a56ddd 100644 --- a/assimilation_code/modules/assimilation/algorithm_info_mod.f90 +++ b/assimilation_code/modules/assimilation/algorithm_info_mod.f90 @@ -217,9 +217,19 @@ subroutine read_qceff_table(qceff_table_filename) case ('BOUNDED_NORMAL_RH_DISTRIBUTION') qceff_table_data(row)%probit_inflation%dist_type = BOUNDED_NORMAL_RH_DISTRIBUTION case ('GAMMA_DISTRIBUTION') + ! Force standard Gamma distribution qceff_table_data(row)%probit_inflation%dist_type = GAMMA_DISTRIBUTION + qceff_table_data(row)%probit_inflation%bounded_above = .false. + qceff_table_data(row)%probit_inflation%bounded_below = .true. + qceff_table_data(row)%probit_inflation%upper_bound = MISSING_R8 + qceff_table_data(row)%probit_inflation%lower_bound = 0.0_r8 case ('BETA_DISTRIBUTION') + ! Force standard Beta distribution qceff_table_data(row)%probit_inflation%dist_type = BETA_DISTRIBUTION + qceff_table_data(row)%probit_inflation%bounded_above = .true. + qceff_table_data(row)%probit_inflation%bounded_below = .true. + qceff_table_data(row)%probit_inflation%upper_bound = 1.0_r8 + qceff_table_data(row)%probit_inflation%lower_bound = 0.0_r8 case ('LOG_NORMAL_DISTRIBUTION') qceff_table_data(row)%probit_inflation%dist_type = LOG_NORMAL_DISTRIBUTION case ('UNIFORM_DISTRIBUTION') @@ -242,9 +252,19 @@ subroutine read_qceff_table(qceff_table_filename) case ('BOUNDED_NORMAL_RH_DISTRIBUTION') qceff_table_data(row)%probit_state%dist_type = BOUNDED_NORMAL_RH_DISTRIBUTION case ('GAMMA_DISTRIBUTION') + ! Force standard Gamma distribution qceff_table_data(row)%probit_state%dist_type = GAMMA_DISTRIBUTION + qceff_table_data(row)%probit_state%bounded_above = .false. + qceff_table_data(row)%probit_state%bounded_below = .true. + qceff_table_data(row)%probit_state%upper_bound = MISSING_R8 + qceff_table_data(row)%probit_state%lower_bound = 0.0_r8 case ('BETA_DISTRIBUTION') + ! Force standard Beta distribution qceff_table_data(row)%probit_state%dist_type = BETA_DISTRIBUTION + qceff_table_data(row)%probit_state%bounded_above = .true. + qceff_table_data(row)%probit_state%bounded_below = .true. + qceff_table_data(row)%probit_state%upper_bound = 1.0_r8 + qceff_table_data(row)%probit_state%lower_bound = 0.0_r8 case ('LOG_NORMAL_DISTRIBUTION') qceff_table_data(row)%probit_state%dist_type = LOG_NORMAL_DISTRIBUTION case ('UNIFORM_DISTRIBUTION') @@ -266,9 +286,19 @@ subroutine read_qceff_table(qceff_table_filename) case ('BOUNDED_NORMAL_RH_DISTRIBUTION') qceff_table_data(row)%probit_extended_state%dist_type = BOUNDED_NORMAL_RH_DISTRIBUTION case ('GAMMA_DISTRIBUTION') + ! Force standard Gamma distribution qceff_table_data(row)%probit_extended_state%dist_type = GAMMA_DISTRIBUTION + qceff_table_data(row)%probit_extended_state%bounded_above = .false. + qceff_table_data(row)%probit_extended_state%bounded_below = .true. + qceff_table_data(row)%probit_extended_state%upper_bound = MISSING_R8 + qceff_table_data(row)%probit_extended_state%lower_bound = 0.0_r8 case ('BETA_DISTRIBUTION') + ! Force standard Beta distribution qceff_table_data(row)%probit_extended_state%dist_type = BETA_DISTRIBUTION + qceff_table_data(row)%probit_extended_state%bounded_above = .true. + qceff_table_data(row)%probit_extended_state%bounded_below = .true. + qceff_table_data(row)%probit_extended_state%upper_bound = 1.0_r8 + qceff_table_data(row)%probit_extended_state%lower_bound = 0.0_r8 case ('LOG_NORMAL_DISTRIBUTION') qceff_table_data(row)%probit_extended_state%dist_type = LOG_NORMAL_DISTRIBUTION case ('UNIFORM_DISTRIBUTION') diff --git a/developer_tests/qceff/test_force_bounds.f90 b/developer_tests/qceff/test_force_bounds.f90 new file mode 100644 index 0000000000..7e6dfc72ef --- /dev/null +++ b/developer_tests/qceff/test_force_bounds.f90 @@ -0,0 +1,95 @@ +! DART software - Copyright UCAR. This open source software is provided +! by UCAR, "as is", without charge, subject to all terms of use at +! http://www.image.ucar.edu/DAReS/DART/DART_download + +program test_force_bounds + +use algorithm_info_mod, only : init_algorithm_info_mod, end_algorithm_info_mod, probit_dist_info +use distribution_params_mod, only : GAMMA_DISTRIBUTION, BETA_DISTRIBUTION, NORMAL_DISTRIBUTION +use utilities_mod, only : initialize_utilities, finalize_utilities +use obs_kind_mod, only : QTY_AQUIFER_WATER, QTY_AMMONIUM_SULPHATE +use types_mod, only : r8, MISSING_R8 + +use test + +implicit none + +logical :: is_state, is_inflation +logical :: bounded_below, bounded_above +real(r8) :: lower_bound, upper_bound +integer :: dist_type + + +call initialize_utilities('test_table_read') + +call init_algorithm_info_mod() + +! QTY1 +! inflation GAMMA +call probit_dist_info(QTY_AQUIFER_WATER, .false., .true., dist_type, & + bounded_below, bounded_above, lower_bound, upper_bound) + +call ok(dist_type == GAMMA_DISTRIBUTION) +call ok(bounded_below) +call ok(.not. bounded_above) +call ok(lower_bound == 0.0_r8) +call ok(upper_bound == MISSING_R8) + +! state BETA +call probit_dist_info(QTY_AQUIFER_WATER, .true., .false., dist_type, & + bounded_below, bounded_above, lower_bound, upper_bound) + +call ok(dist_type == BETA_DISTRIBUTION) +call ok(bounded_below) +call ok(bounded_above) +call ok(lower_bound == 0.0_r8) +call ok(upper_bound == 1.0_r8) + +! extended state NORMAL +call probit_dist_info(QTY_AQUIFER_WATER, .false., .false., dist_type, & + bounded_below, bounded_above, lower_bound, upper_bound) + +call ok(dist_type == NORMAL_DISTRIBUTION) +call ok(.not. bounded_below) +call ok(.not. bounded_above) +call ok(lower_bound == MISSING_R8) +call ok(upper_bound == MISSING_R8) + + +! QTY2 +! inflation BETA +call probit_dist_info(QTY_AMMONIUM_SULPHATE , .false., .true., dist_type, & + bounded_below, bounded_above, lower_bound, upper_bound) + +call ok(dist_type == BETA_DISTRIBUTION) +call ok(bounded_below) +call ok(bounded_above) +call ok(lower_bound == 0.0_r8) +call ok(upper_bound == 1.0_r8) + +! state GAMMA +call probit_dist_info(QTY_AMMONIUM_SULPHATE , .true., .false., dist_type, & + bounded_below, bounded_above, lower_bound, upper_bound) + +call ok(dist_type == GAMMA_DISTRIBUTION) +call ok(bounded_below) +call ok(.not. bounded_above) +call ok(lower_bound == 0.0_r8) +call ok(upper_bound == MISSING_R8) + +! extended state BETA +call probit_dist_info(QTY_AMMONIUM_SULPHATE , .false., .false., dist_type, & + bounded_below, bounded_above, lower_bound, upper_bound) + +call ok(dist_type == BETA_DISTRIBUTION) +call ok(bounded_below) +call ok(bounded_above) +call ok(lower_bound == 0.0_r8) +call ok(upper_bound == 1.0_r8) + + +call end_algorithm_info_mod() + +call finalize_utilities() + +end program test_force_bounds diff --git a/developer_tests/qceff/work/input.nml b/developer_tests/qceff/work/input.nml index ffa7155436..d3109c405c 100644 --- a/developer_tests/qceff/work/input.nml +++ b/developer_tests/qceff/work/input.nml @@ -1,3 +1,7 @@ +&algorithm_info_nml + qceff_table_filename = 'qcf_force_beta_gamma.csv' +/ + &utilities_nml TERMLEVEL = 1, module_details = .false. diff --git a/developer_tests/qceff/work/input.nml.no_alg b/developer_tests/qceff/work/input.nml.no_alg new file mode 100644 index 0000000000..4b8b92d6b6 --- /dev/null +++ b/developer_tests/qceff/work/input.nml.no_alg @@ -0,0 +1,31 @@ +&utilities_nml + TERMLEVEL = 1, + module_details = .false. + logfilename = 'dart_log.out' + / + +# pick a random set of inputs +&preprocess_nml + overwrite_output = .true. + input_obs_qty_mod_file = '../../../assimilation_code/modules/observations/DEFAULT_obs_kind_mod.F90' + output_obs_qty_mod_file = '../../../assimilation_code/modules/observations/obs_kind_mod.f90' + input_obs_def_mod_file = '../../../observations/forward_operators/DEFAULT_obs_def_mod.F90' + output_obs_def_mod_file = '../../../observations/forward_operators/obs_def_mod.f90' + obs_type_files = '../../../observations/forward_operators/obs_def_reanalysis_bufr_mod.f90', + '../../../observations/forward_operators/obs_def_radar_mod.f90', + '../../../observations/forward_operators/obs_def_metar_mod.f90', + '../../../observations/forward_operators/obs_def_dew_point_mod.f90', + '../../../observations/forward_operators/obs_def_rel_humidity_mod.f90', + '../../../observations/forward_operators/obs_def_altimeter_mod.f90', + '../../../observations/forward_operators/obs_def_gps_mod.f90', + '../../../observations/forward_operators/obs_def_vortex_mod.f90', + '../../../observations/forward_operators/obs_def_gts_mod.f90', + '../../../observations/forward_operators/obs_def_QuikSCAT_mod.f90' + quantity_files = '../../../assimilation_code/modules/observations/default_quantities_mod.f90', + / + +&obs_kind_nml +/ + + + diff --git a/developer_tests/qceff/work/qcf_force_beta_gamma.csv b/developer_tests/qceff/work/qcf_force_beta_gamma.csv new file mode 100644 index 0000000000..31528d2db6 --- /dev/null +++ b/developer_tests/qceff/work/qcf_force_beta_gamma.csv @@ -0,0 +1,4 @@ +QCEFF table version: 1,obs_error_info,,,,probit_inflation,,,,,probit_state,,,,,probit_extended_state,,,,,obs_inc_info,,,, +QTY_NAME,bounded_below,bounded_above,lower_bound,upper_bound,dist_type,bounded_below,bounded_above,lower_bound,upper_bound,dist_type,bounded_below,bounded_above,lower_bound,upper_bound,dist_type,bounded_below,bounded_above,lower_bound,upper_bound,filter_kind,bounded_below,bounded_above,lower_bound,upper_bound +QTY_AQUIFER_WATER,.false.,.false.,-888888,-888888,GAMMA_DISTRIBUTION,.false.,.true.,-888888,1234,BETA_DISTRIBUTION,.false.,.false.,-888888,-888888,NORMAL_DISTRIBUTION,.false.,.false.,-888888,-888888,EAKF,.false.,.false.,-888888,-888888 +QTY_AMMONIUM_SULPHATE ,.false.,.false.,-888888,-888888,BETA_DISTRIBUTION,.false.,.true.,-888888,-145.6,GAMMA_DISTRIBUTION,.false.,.false.,45,44,BETA_DISTRIBUTION,.false.,.false.,-888888,-888888,EAKF,.false.,.false.,-888888,-888888 \ No newline at end of file diff --git a/developer_tests/qceff/work/quickbuild.sh b/developer_tests/qceff/work/quickbuild.sh index 81b1308494..24b053a36f 100755 --- a/developer_tests/qceff/work/quickbuild.sh +++ b/developer_tests/qceff/work/quickbuild.sh @@ -18,6 +18,7 @@ LOCATION="threed_sphere" serial_programs=( test_table_read +test_force_bounds ) # quickbuild arguments diff --git a/developer_tests/qceff/work/runall.sh b/developer_tests/qceff/work/runall.sh index 72597f775b..87cffcb0f5 100755 --- a/developer_tests/qceff/work/runall.sh +++ b/developer_tests/qceff/work/runall.sh @@ -41,6 +41,9 @@ else fi } +cp input.nml input.nml.bak +cp input.nml.no_alg input.nml + run_test ; should_pass "no table" run_test qcf_table.txt ; should_pass "correct v1 table" @@ -69,3 +72,4 @@ run_test all_bnrhf_qceff_table.csv ; should_pass "lower case QTY" run_test qcf_table_lower_case_dist.txt; should_pass "lower case dist_type" +cp input.nml.bak input.nml