Skip to content
Snippets Groups Projects
Commit a8e9b719 authored by KyleKlenk's avatar KyleKlenk
Browse files

added file settings for hru

hooked up csv file functionality
parent cb67e9ed
No related branches found
No related tags found
No related merge requests found
...@@ -113,10 +113,12 @@ struct hru_state { ...@@ -113,10 +113,12 @@ struct hru_state {
* @param configPath Path to the directory that contains the settings file * @param configPath Path to the directory that contains the settings file
*/ */
void parseSettings(stateful_actor<hru_state>* self, std::string configPath); void parseSettings(stateful_actor<hru_state>* self, std::string configPath);
/** /**
Function to initalize the HRU for running Function to initalize the HRU for running
*/ */
void Initialize_HRU(stateful_actor<hru_state>* self); void Initialize_HRU(stateful_actor<hru_state>* self);
/** /**
Function runs all of the hru time_steps Function runs all of the hru time_steps
*/ */
...@@ -127,4 +129,6 @@ void initalizeTimeVars(stateful_actor<hru_state>* self); ...@@ -127,4 +129,6 @@ void initalizeTimeVars(stateful_actor<hru_state>* self);
void finalizeTimeVars(stateful_actor<hru_state>* self); void finalizeTimeVars(stateful_actor<hru_state>* self);
void deallocateHRUStructures(stateful_actor<hru_state>* self); void deallocateHRUStructures(stateful_actor<hru_state>* self);
void printOutput(stateful_actor<hru_state>* self);
#endif #endif
\ No newline at end of file
...@@ -38,6 +38,15 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, ...@@ -38,6 +38,15 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU,
self->state.timestep = 1; self->state.timestep = 1;
self->state.outputStep = 1; self->state.outputStep = 1;
// Get the settings for the HRU
parseSettings(self, configPath);
// We only want to print this once
if (indxGRU == 1) {
aout(self) << "\nSETTINGS FOR HRU_ACTOR\n";
aout(self) << "Print Output = " << self->state.printOutput << "\n";
aout(self) << "Print Output every " << self->state.outputFrequency << " timesteps\n\n";
}
Initialize_HRU(self); Initialize_HRU(self);
...@@ -176,7 +185,7 @@ void parseSettings(stateful_actor<hru_state>* self, std::string configPath) { ...@@ -176,7 +185,7 @@ void parseSettings(stateful_actor<hru_state>* self, std::string configPath) {
if (self->state.printOutput) { if (self->state.printOutput) {
// get the frequency in number of timesteps we want to print the output // get the frequency in number of timesteps we want to print the output
if(HRUActorConfig.find("outputFrequency") != settings.end()) { if(HRUActorConfig.find("outputFrequency") != HRUActorConfig.end()) {
self->state.outputFrequency = HRUActorConfig["outputFrequency"]; self->state.outputFrequency = HRUActorConfig["outputFrequency"];
} else { } else {
aout(self) << "Error finding outputFrequency in JSON File - Reverting to default value\n"; aout(self) << "Error finding outputFrequency in JSON File - Reverting to default value\n";
...@@ -273,9 +282,6 @@ void Initialize_HRU(stateful_actor<hru_state>* self) { ...@@ -273,9 +282,6 @@ void Initialize_HRU(stateful_actor<hru_state>* self) {
(self->state.initEnd - self->state.initStart).count(); (self->state.initEnd - self->state.initStart).count();
} }
/*
** RETURNS 0 on success and -1 on failure
*/
int Run_HRU(stateful_actor<hru_state>* self) { int Run_HRU(stateful_actor<hru_state>* self) {
// Housekeeping of the timing variables // Housekeeping of the timing variables
if(self->state.timestep == 1) { if(self->state.timestep == 1) {
...@@ -305,15 +311,12 @@ int Run_HRU(stateful_actor<hru_state>* self) { ...@@ -305,15 +311,12 @@ int Run_HRU(stateful_actor<hru_state>* self) {
self->state.forcingEnd = std::chrono::high_resolution_clock::now(); self->state.forcingEnd = std::chrono::high_resolution_clock::now();
self->state.forcingDuration += self->state.forcingEnd - self->state.forcingStart; self->state.forcingDuration += self->state.forcingEnd - self->state.forcingStart;
if (self->state.timestep % 50000 == 0) {
aout(self) << self->state.refGRU << ":Accumulated Forcing Time = " << if (self->state.printOutput &&
self->state.forcingDuration << std::endl; self->state.timestep % self->state.outputFrequency == 0) {
aout(self) << self->state.refGRU << " - Running Timestep = " << self->state.timestep << std::endl; printOutput(self);
aout(self) << self->state.refGRU << ":Accumulated Run Physics Time = " <<
self->state.runPhysicsDuration << std::endl;
aout(self) << self->state.refGRU << ":Accumulated WriteOutput = "
<< self->state.writeOutputDuration << std::endl;
} }
/********************************************************************** /**********************************************************************
** RUN_PHYSICS ** RUN_PHYSICS
...@@ -408,7 +411,6 @@ void initalizeTimeVars(stateful_actor<hru_state>* self) { ...@@ -408,7 +411,6 @@ void initalizeTimeVars(stateful_actor<hru_state>* self) {
self->state.writeOutputDuration = self->state.writeOutputEnd - self->state.writeOutputStart; self->state.writeOutputDuration = self->state.writeOutputEnd - self->state.writeOutputStart;
} }
void finalizeTimeVars(stateful_actor<hru_state>* self) { void finalizeTimeVars(stateful_actor<hru_state>* self) {
self->state.end = std::chrono::high_resolution_clock::now(); self->state.end = std::chrono::high_resolution_clock::now();
...@@ -449,5 +451,9 @@ void deallocateHRUStructures(stateful_actor<hru_state>* self) { ...@@ -449,5 +451,9 @@ void deallocateHRUStructures(stateful_actor<hru_state>* self) {
&self->state.err); &self->state.err);
} }
void printOutput(stateful_actor<hru_state>* self) {
aout(self) << self->state.refGRU << " - Timestep = " << self->state.timestep << std::endl;
aout(self) << self->state.refGRU << ":Accumulated Run Physics Time = " <<
self->state.runPhysicsDuration << std::endl;
}
#endif #endif
\ No newline at end of file
...@@ -48,7 +48,7 @@ struct job_state { ...@@ -48,7 +48,7 @@ struct job_state {
bool outputCSV; bool outputCSV;
std::string csvOut; std::string csvOut;
std::string csvPath; std::string csvPath;
std::string successOutputFile = "SuccessHRU"; std::string successOutputFile;
std::string failedOutputFile = "failedHRU"; std::string failedOutputFile = "failedHRU";
std::string fileAccessActorStats = "fileAccessActor.csv"; std::string fileAccessActorStats = "fileAccessActor.csv";
......
...@@ -26,7 +26,7 @@ behavior job_actor(stateful_actor<job_state>* self, int startGRU, int numGRU, ...@@ -26,7 +26,7 @@ behavior job_actor(stateful_actor<job_state>* self, int startGRU, int numGRU,
aout(self) << "ERROR WITH JSON SETTINGS FILE!!!\n"; aout(self) << "ERROR WITH JSON SETTINGS FILE!!!\n";
self->quit(); self->quit();
} else { } else {
aout(self) << "SETTINGS FOR JOB_ACTOR\n" << aout(self) << "\nSETTINGS FOR JOB_ACTOR\n" <<
"File Manager Path = " << self->state.fileManager << "\n" << "File Manager Path = " << self->state.fileManager << "\n" <<
"outputCSV = " << self->state.outputCSV << "\n"; "outputCSV = " << self->state.outputCSV << "\n";
if (self->state.outputCSV) { if (self->state.outputCSV) {
...@@ -178,10 +178,11 @@ int parseSettings(stateful_actor<job_state>* self, std::string configPath) { ...@@ -178,10 +178,11 @@ int parseSettings(stateful_actor<job_state>* self, std::string configPath) {
} }
void initJob(stateful_actor<job_state>* self) { void initJob(stateful_actor<job_state>* self) {
std::string success = "Success"; // allows us to build the string
if (self->state.outputCSV) { if (self->state.outputCSV) {
std::ofstream file; std::ofstream file;
self->state.successOutputFile += std::to_string(self->state.startGRU) += ".csv"; self->state.successOutputFile = self->state.csvPath += success +=
std::to_string(self->state.startGRU) += ".csv";
file.open(self->state.successOutputFile, std::ios_base::out); file.open(self->state.successOutputFile, std::ios_base::out);
file << "GRU" << "," << "totalDuration" << "," << "initDuration" << "," << file << "GRU" << "," << "totalDuration" << "," << "initDuration" << "," <<
"forcingDuration" << "," << "runPhysicsDuration" << "," << "writeOutputDuration" << "forcingDuration" << "," << "runPhysicsDuration" << "," << "writeOutputDuration" <<
......
...@@ -5,13 +5,13 @@ ...@@ -5,13 +5,13 @@
}, },
"JobActor": { "JobActor": {
"FileManagerPath": "/project/gwf/gwf_cmt/kck540/domain_NorthAmerica/settings/SUMMA/fileManager.txt", "FileManagerPath": ,
"outputCSV": false, "outputCSV": false,
"csvPath": "" "csvPath":
}, },
"HRUActor": { "HRUActor": {
"printOutput": true, "printOutput": true,
"outputFrequency": 25000 "outputFrequency": 1000
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment