Skip to content

Commit

Permalink
updated unittest, realization file, and changed K_infiltration to Kin…
Browse files Browse the repository at this point in the history
…f_nash_surface for consistency.
  • Loading branch information
ajkhattak committed Jun 24, 2024
1 parent 78d9156 commit 2587df9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -76,7 +76,7 @@
"soil_moisture_profile" : "sloth_smp"
},
"model_params": {
"K_infiltration": 0.04
"Kinf_nash_surface": 0.04
},
"uses_forcing_file": false
}
Expand Down
6 changes: 3 additions & 3 deletions src/bmi_cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions test/main_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,24 +401,24 @@ 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);
assert(status == BMI_SUCCESS);
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);
Expand Down

0 comments on commit 2587df9

Please sign in to comment.