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

ORG78 Finish event wiring in SIPNET #25

Merged
merged 12 commits into from
Feb 6, 2025
Merged

Conversation

Alomir
Copy link
Contributor

@Alomir Alomir commented Jan 31, 2025

This PR augments event handling in SIPNET by fetching events at the relevant place, and has a stubbed method for implementing the actual processing of events for later work.

Note that this is only for runModelOutput(), not runModelNoOut(); we can update the latter as well if desired later.


// calculate all fluxes and update state for this time step
// we calculate all fluxes before updating state in case flux calculations depend on the old state
void updateState() {
double npp; // net primary productivity, g C * m^-2 ground area * day^-1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything in this function above the #if EVENT_HANDLER is just indent formatting changes

Copy link
Member

@dlebauer dlebauer left a comment

Choose a reason for hiding this comment

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

Changes look great, looking forward to seeing how these events flesh out!

sipnet.c Outdated
break;
default:
printf("Unknown event type (%d) in processEvents()\n", locEvent->type);
exit(1);
Copy link
Member

Choose a reason for hiding this comment

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

do we really want to exit and not just print error message, and continue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great question, I was going with what seems to be the standard for SIPNET - that is, exit on errors that look like mistakes in inputs. Any thoughts on this @dlebauer @infotroph ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Decided via discussion: using different error codes, starting here

sipnet.c Outdated
@@ -2485,7 +2534,9 @@ void setupModel(SpatialParams *spatialParams, int loc) {

// Setup events at given location
void setupEvents(int currLoc) {
// Implementation TBD
#if EVENT_HANDLER
locEvent = events[currLoc];
Copy link
Member

Choose a reason for hiding this comment

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

indenting looks off here

Copy link
Member

Choose a reason for hiding this comment

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

Formatting looks inconsistent throughout - what about applying a formatter in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I cannot get CLion on Mac to listen to its own format settings, thus some wonky things sneak in. I def. vote for adding a formatter on checkin/push/merge or some such, but I'll fix this one here for now. Thanks for pointing that out!

sipnet.c Outdated
@@ -2554,6 +2605,12 @@ void runModelNoOut(double **outArray, int numDataTypes, int dataTypeIndices[], S

setupModel(spatialParams, loc);

#if EVENT_HANDLER
// Implementation TBD
Copy link
Member

Choose a reason for hiding this comment

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

indenting looks off here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto

exitCodes.h Outdated
// Note for future: these codes typically have other meanings and should not be
// used here (except for 0 and 1, for which our meaning is the special meaning)
// 0-2, 126-165, and 255
// See, e.g., https://tldp.org/LDP/abs/html/exitcodes.html
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I like that one better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or, in addition, looking at that more closely.

@@ -2485,7 +2535,9 @@ void setupModel(SpatialParams *spatialParams, int loc) {

// Setup events at given location
void setupEvents(int currLoc) {
// Implementation TBD
#if EVENT_HANDLER
Copy link
Member

Choose a reason for hiding this comment

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

probably should be consistent and have the EVENT_HANDLER around the function as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Member

@robkooper robkooper left a comment

Choose a reason for hiding this comment

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

one other thing to think about is to start a changelog, see pecan and https://keepachangelog.com/

@Alomir Alomir merged commit 8ff893e into master Feb 6, 2025
6 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.

3 participants