From 2587df95273dd34479097b596583e58838758884 Mon Sep 17 00:00:00 2001 From: Ahmad Jan Date: Mon, 24 Jun 2024 16:06:14 -0400 Subject: [PATCH] updated unittest, realization file, and changed K_infiltration to Kinf_nash_surface for consistency. --- ...sh_calib.json => realization_cfe_pet_surfnash.json} | 4 ++-- src/bmi_cfe.c | 6 +++--- test/main_unit_test.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) rename realizations/{realization_cfe_pet_surfnash_calib.json => realization_cfe_pet_surfnash.json} (98%) diff --git a/realizations/realization_cfe_pet_surfnash_calib.json b/realizations/realization_cfe_pet_surfnash.json similarity index 98% rename from realizations/realization_cfe_pet_surfnash_calib.json rename to realizations/realization_cfe_pet_surfnash.json index 37b2ac4..a263e07 100644 --- a/realizations/realization_cfe_pet_surfnash_calib.json +++ b/realizations/realization_cfe_pet_surfnash.json @@ -57,7 +57,7 @@ "model_type_name": "bmi_c_cfe", "library_file": "./extern/cfe/cfe/cmake_build/libcfebmi", "forcing_file": "", - "init_config": "./extern/cfe/cfe/configs/cfe_config_cat_87_pass_surfnash.txt", + "init_config": "./extern/cfe/cfe/configs/cfe_config_cat_87_pass.txt", "allow_exceed_end_time": true, "main_output_variable": "Q_OUT", "registration_function": "register_bmi_cfe", @@ -76,7 +76,7 @@ "soil_moisture_profile" : "sloth_smp" }, "model_params": { - "K_infiltration": 0.04 + "Kinf_nash_surface": 0.04 }, "uses_forcing_file": false } diff --git a/src/bmi_cfe.c b/src/bmi_cfe.c index 5554319..72b65c4 100644 --- a/src/bmi_cfe.c +++ b/src/bmi_cfe.c @@ -32,7 +32,7 @@ static const char *param_var_names[PARAM_VAR_NAME_COUNT] = { "Kn", "Cgw", "expon", "max_gw_storage", "satpsi","wltsmc","alpha_fc","refkdt", "a_Xinanjiang_inflection_point_parameter","b_Xinanjiang_shape_parameter","x_Xinanjiang_shape_parameter", - "K_infiltration", + "Kinf_nash_surface", "N_nash_subsurface" }; @@ -723,7 +723,7 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model) model->N_nash_subsurface = strtol(param_value, NULL, 10); continue; } - if (strcmp(param_key, "K_nash_subsurface") == 0) { + if (strcmp(param_key, "K_nash_subsurface") == 0 || strcmp(param_key, "K_nash") == 0) { model->K_nash_subsurface = strtod(param_value, NULL); is_K_nash_subsurface_set = TRUE; continue; @@ -1922,7 +1922,7 @@ static int Get_value_ptr (Bmi *self, const char *name, void **dest) return BMI_SUCCESS; } - if (strcmp (name, "K_infiltration") == 0) { + if (strcmp (name, "Kinf_nash_surface") == 0) { cfe_state_struct *cfe_ptr; cfe_ptr = (cfe_state_struct *) self->data; *dest = (void*)&cfe_ptr->nash_surface_params.K_infiltration; diff --git a/test/main_unit_test.c b/test/main_unit_test.c index fbda063..8182a6f 100644 --- a/test/main_unit_test.c +++ b/test/main_unit_test.c @@ -401,16 +401,16 @@ main(int argc, const char *argv[]){ "Kn", "Cgw", "expon", "max_gw_storage", "satpsi","wltsmc","alpha_fc","refkdt", "a_Xinanjiang_inflection_point_parameter","b_Xinanjiang_shape_parameter","x_Xinanjiang_shape_parameter", - "K_infiltration", - "N_nash"}; + "Kinf_nash_surface", + "N_nash_subsurface"}; double test_set_value = 4.2; double test_get_value = 0.0; int test_set_value_int = 5; int test_get_value_int = 0; // Loop through params to test get and set - for( int i = 0; i < PARAM_COUNT; i++ ){ - if(strcmp(expected_param_names[i], "N_nash") == 0){ + for( int i = 0; i < PARAM_COUNT; i++ ) { + if(strcmp(expected_param_names[i], "N_nash_subsurface") == 0){ status = model->set_value(model, expected_param_names[i], &test_set_value_int); assert(status == BMI_SUCCESS); status = model->get_value(model, expected_param_names[i], &test_get_value_int); @@ -418,7 +418,7 @@ main(int argc, const char *argv[]){ assert(test_set_value_int == test_get_value_int); printf(" get & set values match for parameter: %s \n", expected_param_names[i]); } - else{ + else { status = model->set_value(model, expected_param_names[i], &test_set_value); //if (status == BMI_FAILURE)return BMI_FAILURE; assert(status == BMI_SUCCESS);