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

Adding a passthrough option to the statistic action #61

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/multio/action/statistics/Statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ using message::glossary;
Statistics::Statistics(const ComponentConfiguration& compConf) :
ChainedAction{compConf},
needRestart_{false},
initialDataAlreadyPassedThrough_{false},
lastDateTime_{""},
opt_{compConf},
operations_{compConf.parsedConfig().getStringVector("operations")},
Expand Down Expand Up @@ -332,6 +333,16 @@ void Statistics::executeImpl(message::Message msg) {
stat = fieldStats_.find(key);
}

// If the action sets the option that initial data is supposed to be passed to the next action in case of several statistic actions,
// AND the model sends initial data AND the internal tracker if any message has been directly passed through is still false the message is passed through to the next action
// TODO check if this is a good position for this check. It looks like the next chekc would filter this message out anyway.
//std::cout<<"STEBA opt_.solver_send_initial_condition() " << opt_.solver_send_initial_condition() << " opt_.initialDataPassThrough() " << opt_.initialDataPassThrough() <<" !initialDataAlreadyPassedThrough_ " << !initialDataAlreadyPassedThrough_ << std::endl;
if(opt_.solver_send_initial_condition() && opt_.initialDataPassThrough() && !initialDataAlreadyPassedThrough_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So this assumes - without checking the metadata - that the
user properly configured the action to what the model is sending.

Is it possible to assert some things? I.e. a pass through message has step=0 ?

initialDataAlreadyPassedThrough_ = true;
executeNext(msg);
return;
}

// Exit if the current time is the same as the current point in the
// window and the solver does not send the initial condition.
// This can happen when the solver is sending the initial condition
Expand Down
1 change: 1 addition & 0 deletions src/multio/action/statistics/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Statistics : public ChainedAction {
private:
bool needRestart_;
std::string lastDateTime_;
bool initialDataAlreadyPassedThrough_;
void TryDumpRestart(const message::Message& msg);
std::string generateRestartNameFromFlush(const message::Message& msg) const;
void DeleteLatestSymLink();
Expand Down
13 changes: 13 additions & 0 deletions src/multio/action/statistics/cfg/StatisticsOptions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ StatisticsOptions::StatisticsOptions(const config::ComponentConfiguration& compC
parseStepFrequency(options);
parseTimeStep(options);
parseInitialConditionPresent(options);
parseInitialDataPassThrough(options);
parseWriteRestart(options);
parseDebugRestart(options);
parseClientSideStatistics(options);
Expand Down Expand Up @@ -84,6 +85,14 @@ void StatisticsOptions::parseInitialConditionPresent(const eckit::LocalConfigura
return;
};

void StatisticsOptions::parseInitialDataPassThrough(const eckit::LocalConfiguration& cfg) {
//This option needs to be set if we have two statistic actions in a plan. Then the second statistic action also needs the initial data to create the statistic window correctly.
//Therefore the first action needs to have this option set to true.
initDataPassTrough_ = cfg.getBool("initial-data-passed-through", false);
Copy link
Contributor

Choose a reason for hiding this comment

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

should the option really be named ...-passed-through or ...-pass-through

return;
}


void StatisticsOptions::parseWriteRestart(const eckit::LocalConfiguration& cfg) {
// Used to determine if the simulation need to save/load
// restart files.
Expand Down Expand Up @@ -306,6 +315,10 @@ const std::string& StatisticsOptions::solverResetAccumulatedFields() const {
return accumulatedFieldsResetFreqency_;
};

bool StatisticsOptions::initialDataPassThrough() const {
return initDataPassTrough_;
};


std::optional<long> StatisticsOptions::valueCountThreshold() const {
return valueCountThreshold_;
Expand Down
3 changes: 3 additions & 0 deletions src/multio/action/statistics/cfg/StatisticsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class StatisticsOptions {
long stepFreq_;
long timeStep_;
bool solverSendInitStep_;
bool initDataPassTrough_;
bool readRestart_;
bool writeRestart_;
bool debugRestart_;
Expand All @@ -41,6 +42,7 @@ class StatisticsOptions {
void parseStepFrequency(const eckit::LocalConfiguration& cfg);
void parseTimeStep(const eckit::LocalConfiguration& cfg);
void parseInitialConditionPresent(const eckit::LocalConfiguration& cfg);
void parseInitialDataPassThrough(const eckit::LocalConfiguration& cfg);
void parseWriteRestart(const eckit::LocalConfiguration& cfg);
void parseDebugRestart(const eckit::LocalConfiguration& cfg);
void parseClientSideStatistics(const eckit::LocalConfiguration& cfg);
Expand Down Expand Up @@ -77,6 +79,7 @@ class StatisticsOptions {
bool writeRestart() const;
bool debugRestart() const;
bool clientSideStatistics() const;
bool initialDataPassThrough() const;

const std::string& restartTime() const;
const std::string& restartPath() const;
Expand Down
Loading