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

Model output includes startDate #604

Merged
merged 6 commits into from
Apr 18, 2022
Merged

Model output includes startDate #604

merged 6 commits into from
Apr 18, 2022

Conversation

bpbond
Copy link
Member

@bpbond bpbond commented Apr 3, 2022

Changes model output so that the csvOutputStream as well as hector::fetchvars data now start with 1745, or whatever startDate is.

Closes #177

@bpbond bpbond requested a review from kdorheim April 3, 2022 11:20
@bpbond bpbond linked an issue Apr 3, 2022 that may be closed by this pull request
@@ -40,6 +40,10 @@ test_that("Basic hcore functionality works", {
expect_silent(run(hc, 2100))
expect_silent(run(hc))

# All years should appear in the output
out <- fetchvars(hc, dates = 1745:2300)
expect_equivalent(sort(unique(out$year)), 1745:2300)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are there two expect_silent(run) in a row after each other? Is the second run(hc) call just to run the date out to the year 2300 for all years should appear in the output? test?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is older code, not something I added. The model is at 2100 at that point, and those lines test that it will run to 2100 (no change) and then continue to 2300, all without error.

// Initialize surface flux tracking variables
annualflux_sum.set( 0.0, U_PGC );
annualflux_sumHL.set( 0.0, U_PGC );
annualflux_sumLL.set( 0.0, U_PGC );
Copy link
Contributor

Choose a reason for hiding this comment

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

The annualflux_sum is also set in the run component around line 360 does it really need to be set twice? Or could we remove that code block?

Copy link
Member Author

@bpbond bpbond Apr 8, 2022

Choose a reason for hiding this comment

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

It needs to be zeroed here as well, so that the initial output visitor pass — which now occurs before the component has ever run — can correctly report model state.

// visitors that spinup is 'true' (which it's not). This is necessary because the ocean
// component hasn't had a chance to initialize its active chemistry yet, and without that
// calc_revelle() will throw an error. Kind of hacky; but the only alternative I see is
// to create a whole new done_with_spinup() signal to the components--a lot of work.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I fully understand what is going on here. Is the initial output 1745? Or is it any start year?

So this is just a hack that is letting the visitor output access the initial year values even though the ocean is not at equlibrium? Would it make sense to open an issue :( outlining what done_with_spinup() would look like, where, and why it would be used?

Copy link
Member Author

@bpbond bpbond Apr 8, 2022

Choose a reason for hiding this comment

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

It's a bit hacky, yes, but allows the visitor to collect model state even though the ocean chemistry has not yet been turned on. That last bit is the issue—ocean chemistry is turned on the first time the ocean is run(). Now, however, the visitor needs to output things and, because we're no longer in spinup, it tries to collect info on chemistry (and fails). So instead, we tell the visitor, one last time, that we're still in spinup.

Copy link
Contributor

@kdorheim kdorheim left a comment

Choose a reason for hiding this comment

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

Some questions

@bpbond bpbond merged commit 17506df into land_tracking Apr 18, 2022
@bpbond bpbond deleted the output-fixes branch April 18, 2022 16:04
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.

startDate non-inclusive?
2 participants