Skip to content
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

Fix a bug in output variable name list, replacing (PR#577) #610

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

stcui007
Copy link
Contributor

This PR fixing variable name entry issue#535

Additions

Removals

Changes

include/realizations/catchment/Bmi_Multi_Formulation.hpp
src/realizations/catchment/Bmi_Multi_Formulation.cpp

Testing

Unit Tests
Run ngen tests

Screenshots

Notes

Todos

Checklist

  • [x ] PR has an informative and human-readable title
  • [x ] Changes are limited to a single goal (no scope creep)
  • [x ] Code can be automatically merged (no conflicts)
  • [x ] Code follows project standards (link if applicable)
  • Passes all existing automated tests
  • Any change in functionality is tested
  • [x ] New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist (automated report can be put here)

Target Environment support

  • [x ] Linux

Copy link
Contributor

@mattw-nws mattw-nws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed cleaner, but it goes back to only fixing the problem for Bmi_Multi_Formulation where the problem in #535 can occur in any BMI formulation. This should be possible to do up in Bmi_Formulation or at least with only a little duplicate code in Bmi_Multi_Formulation and Bmi_Module_Formulation

// take into account the unit test where both the original and remapped output var names are used in the test codes
for (const nested_module_ptr &module: modules) {
for (const std::string &out_var_name: module->get_bmi_output_variables()) {
if ((out_var_name == "OUTPUT_VAR_1") || (out_var_name == "OUTPUT_VAR_2") || (out_var_name == "OUTPUT_VAR_3")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's going on in the unit test (I'll try to take a closer look today), but putting these "magic strings" in the production code to account for behavior in the unit test isn't the right answer. Either the test is wrong, or the behavior needs to match the test.

Copy link
Contributor

@mattw-nws mattw-nws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is indeed cleaner, but it goes back to only fixing the problem for Bmi_Multi_Formulation where the problem in #535 can occur in any BMI formulation. This should be possible to do up in Bmi_Formulation or at least with only a little duplicate code in Bmi_Multi_Formulation and Bmi_Module_Formulation

@stcui007
Copy link
Contributor Author

stcui007 commented Aug 15, 2023 via email

@@ -292,6 +292,11 @@ string Bmi_Multi_Formulation::get_output_line_for_timestep(int timestep, std::st
throw std::invalid_argument("Only current time step valid when getting multi-module BMI formulation output");
}

// check if a requested output variable name is valid, if not, stop the execution
if (timestep == 0) {
check_output_var_names();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will work if this function is called at the end of create_multi_formulation instead of in the time loop... can you try it there instead?

@stcui007
Copy link
Contributor Author

stcui007 commented Aug 17, 2023 via email

@mattw-nws mattw-nws merged commit e872e8e into NOAA-OWP:master Aug 17, 2023
19 checks passed
@mattw-nws mattw-nws linked an issue Aug 17, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fail execution if output_variables has invalid entries
2 participants