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

Remove standard topmodel output when running from ngen #41

Merged

Conversation

Ben-Choat
Copy link
Contributor

[Short description explaining the high-level reason for the pull request]

Additions

Removals

Changes

  • Added stand_alone to water_balance() and tread() so that standard topmodel outputs only written when stand_alone == 1
  • Added stand_alone == TRUE to conditional fprintf statements that are used to write standard topmodel outputs
  • Added #if TOPMODEL_DEBUG >= 1 statements in topmodel.c and bmi_topmodel.c so that information regarding calibratable parameters is only written to screen when in debug mode

Testing

  1. Executed both in NGEN and stand alone mode and compared to outputs from before any edits were made. All outputs were identical.
  2. Executed with and without calibratable parameters being provided in realization file and compared results from before edits were made. All outputs were identical.

Screenshots

Notes

  • All work done in Linux Ubuntu 22.04

Todos

  • When running in stand_alone mode, several warnings are thrown about unused or uninitialized variables. This should be addressed.

Checklist

  • [x ] PR has an informative and human-readable title
  • [ ~] 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)
  • [ x] Passes all existing automated tests
  • [x ] Any change in functionality is tested
  • [ x] New functions are documented (with a description, list of inputs, and expected output)
  • [x ] Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • [ x] Reviewers requested with the Reviewers tool ➡️

Testing checklist

Target Environment support

  • [ x] Windows
  • [x ] Linux
  • Browser

Accessibility

  • Keyboard friendly
  • Screen reader friendly

Other

  • Is useable without CSS
  • Is useable without JS
  • Flexible from small to large screens
  • No linting errors or warnings
  • JavaScript tests are passing

…xing accidental comment associated w/this file
…for printing out updates relevant to calibratable parameters.
hellkite500 and others added 20 commits September 20, 2023 07:32
…y+num_time_delay_histo_ords, instead of just num_time_dealy_histo_ords. Also edited a print statement, and an error to provide assistance to user about how to fix error.
…e Q differently depending on if stand alon emode or not. Seeing discrepancies between master stand_alone results and current stand_alone results. Differences exist before these edits.
@madMatchstick
Copy link
Contributor

tagging issue #32

Copy link
Member

@hellkite500 hellkite500 left a comment

Choose a reason for hiding this comment

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

I'm generally curious if it isn't possible to simply do something like

if( stand_alone ) model->yes_print_output = FALSE;

so that the existing state/variable can be used to disable the outputs without introducing a new flag/arg to several new functions that seems to be used in conjunction with yes_print_output.

@@ -527,7 +521,7 @@ static int Finalize (Bmi *self)
free(model->dist_from_outlet);

// Close output files only if opened in first place
if(model->yes_print_output == TRUE){
if(model->yes_print_output == TRUE && model->stand_alone == TRUE){ // && model->stand_alone == TRUE){
Copy link
Member

Choose a reason for hiding this comment

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

spurious comment

@@ -421,8 +421,7 @@ d_alloc(Qobs,(*nstep));
//NJF This is dangerous, there is no validation between nstep and
//number of historgram ordinates, which is used to iterate Q in later steps
//so this could easily overflow if nstep is smaller than historgram ords
d_alloc(Q,(*nstep)); //NJF TODO validate that this works correctly
//When used in "stand alone" mode
d_alloc(Q,(*nstep));
Copy link
Member

Choose a reason for hiding this comment

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

Was this ever validated? I don't believe I went through that code path in detail throughout the dyamic alloc refactoring. Might want to leave this comment until we are sure there isn't possible issues here in stand alone mode?

Copy link
Contributor Author

@Ben-Choat Ben-Choat Jan 17, 2024

Choose a reason for hiding this comment

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

I am able to run in stand alone mode and with NGEN. Output files topmod.out and hyd.out are produced and seem correct. Not sure if further validation is needed.

On a tangential note, to run in stand_alone I am using:

#!/bin/bash
# -lm links math library
gcc ./extern/topmodel/topmodel/src/main.c \
        ./extern/topmodel/topmodel/src/bmi_topmodel.c \
        ./extern/topmodel/topmodel/src/topmodel.c -o\
        run_topmodel_bmi -lm

./run_topmodel_bmi

When I view the info in docs/STAND_ALONE.md, I do not see these instructions anywhere. If this is the expected way to execute in stand_alone, it may be worth adding those instructions there.

If it is not the expected way to execute in stand_alone mode, feel free to let me know!

Copy link
Contributor

Choose a reason for hiding this comment

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

@Ben-Choat - The install doc gives instructions on standalone via cmake. It probably wouldn't be a bad idea to add a link in the STAND_ALONE.md. Thanks for pointing this out.

@PhilMiller
Copy link
Contributor

In terms of dynamic allocation validation, the unit tests are built with AddressSanitizer, but neither the standalone nor the ngen integration tests are.

Copy link
Contributor

@madMatchstick madMatchstick left a comment

Choose a reason for hiding this comment

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

This looks okay to me. Note that it addresses/closes issue #32.

@madMatchstick
Copy link
Contributor

@Ben-Choat - okay to merge?

@Ben-Choat
Copy link
Contributor Author

@madMatchstick , Yup, as far as I'm concerned it is good to merge. I'm not sure if it woud be better to squash or rebase, so I was hestitant to merge myself.

@madMatchstick madMatchstick merged commit b5ae9bb into NOAA-OWP:master Mar 29, 2024
4 checks passed
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.

4 participants