Skip to content

Commit

Permalink
Output initial post-spinup model state
Browse files Browse the repository at this point in the history
Addresses #177
  • Loading branch information
bpbond committed Apr 3, 2022
1 parent 3977f8b commit 38ae453
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ void Core::prepareToRun(void)
// 4. Tell model components we are finished sending data and about to start running.
H_LOG( glog, Logger::NOTICE) << "Preparing to run..." << endl;
for( NameComponentIterator it = modelComponents.begin(); it != modelComponents.end(); ++it ) {
// H_LOG( glog, Logger::DEBUG) << "Preparing " << (*it).second->getComponentName() << " to run" << endl;
( *it ).second->prepareToRun();
}

Expand Down Expand Up @@ -460,8 +459,24 @@ void Core::run(double runtodate) {
// ------------------------------------
// 6. Run all model dates.
H_LOG( glog, Logger::NOTICE) << "Running..." << endl;


// Let visitors record initial model state
// Note that just for this initial output, in calling shouldVisit below, we're telling
// 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.
for( VisitorIterator visitorIt = modelVisitors.begin(); visitorIt != modelVisitors.end(); ++visitorIt ) {
if( ( *visitorIt )->shouldVisit( true, lastDate ) ) {
accept( *visitorIt );
}
}

// Main model run loop
for(double currDate = lastDate+1.0; currDate <= runtodate; currDate += 1.0 ) {
H_LOG( glog, Logger::NOTICE) << currDate << endl;

// If we've hit the tracking start year, note this in the log
if(currDate == trackingDate) {
H_LOG(glog, Logger::NOTICE) << "Starting tracking in " << currDate << endl;
Expand All @@ -471,7 +486,7 @@ void Core::run(double runtodate) {
for( NameComponentIterator it = modelComponents.begin(); it != modelComponents.end(); ++it ) {
( *it ).second->run( currDate );
}

// Let visitors attempt to collect data if necessary
for( VisitorIterator visitorIt = modelVisitors.begin(); visitorIt != modelVisitors.end(); ++visitorIt ) {
if( ( *visitorIt )->shouldVisit( in_spinup, currDate ) ) {
Expand All @@ -480,7 +495,7 @@ void Core::run(double runtodate) {
}
}

// Record the last finished date. We will resume here the next time run is called
// Record the last finished date; we will resume here the next time run is called
lastDate = runtodate;
}

Expand Down

1 comment on commit 38ae453

@github-actions
Copy link

Choose a reason for hiding this comment

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

Differences in Hector outputs

Hello, this is leeyabot! 🤖

The current pull request's outputs do not differ from 3.0.0 (0f2664f).

CML watermark

Please sign in to comment.