-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update BMI specification to include calibratable parameters #29
Conversation
@hellkite500, how did you test the functionality in NOAA-OWP/cfe#44? |
@SnowHydrology I ran it through the ngen driver and the calibration scripts...though if you have a test setup, you can always call |
@madMatchstick made a really nice, reproducible unit testing script for the BMI implementation in C models. To get the number of input and output vars and their names, for example, it calls |
If you are implying adding them to |
What if I were to put them in https://github.com/NOAA-OWP/topmodel/blob/master/include/bmi_topmodel.h I'm just trying to think of ways to test the functions on the model side and on the ngen side. |
There are several ways to do it...you can add helper functions to bmi_topmodel like this bmi_topmodel.h char* get_param_names();
int get_param_count(); bmi_topmodel.c int get_param_cout(){
return PARAM_VAR_NAME_COUNT;
}
char* get_param_names()
{
return param_var_names;
} then in test/main_unit_test_bmi.c, around line 32, you can implement some param testing char* params = get_param_names();
int num_params = get_param_count();
int expected_num_params = 5;
static const char *expected_param_names[expected_num_params] = {"szm", "td", "srmax", "sr0", "xk0"};
assert(num_params == expected_num_params);
double test_set_value = 4.2;
double test_get_value = 0.0;
for( int i = 0; i < num_params; i++ ){
assert(strcmp(params[i], expected_param_names) == 0);
status = model->set_value(model, params[i], &test_set_value);
assert(status == BMI_SUCCESS);
status = model->get_value(model, params[i], & test_get_value);
assert(status == BMI_SUCCESS);
assert(test_set_value == test_get_value);
} You can also skip the helper functions and just define the assumptions in the test... int expected_num_params = 5;
static const char *expected_param_names[expected_num_params] = {"szm", "td", "srmax", "sr0", "xk0"};
double test_set_value = 4.2;
double test_get_value = 0.0;
for( int i = 0; i < expected_num_params; i++ ){
status = model->set_value(model, params[i], &test_set_value);
assert(status == BMI_SUCCESS);
status = model->get_value(model, params[i], & test_get_value);
assert(status == BMI_SUCCESS);
assert(test_set_value == test_get_value);
} This should still fail if the model isn't able to set values on the required params... |
@hellkite500, thanks for that! I'll work on putting together a test with helper functions that doesn't touch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added get/set values for new params in bmi unit testing sh as outlined in //TODO
Thanks @madMatchstick! |
This modification allows the Nextgen model engine to change parameter values by exposing them through BMI.
Additions
All in
bmi_topmodel.c
:PARAM_VAR_NAME_COUNT
param_var_names
param_var_types
Changes
Updated the following in
bmi_topmodel.c
:Get_var_type
Get_value_ptr
Testing
Todos
Checklist
Testing checklist
Target Environment support
Closes #28