diff --git a/build/source/actors/HRU.h b/build/source/actors/HRU.h index 6a7ac6e0a54bbdf1e4593c48c192b2d53b772191..eb23f8ade60dc1710ce1022cbdaf363172cd3c55 100644 --- a/build/source/actors/HRU.h +++ b/build/source/actors/HRU.h @@ -113,10 +113,12 @@ struct hru_state { * @param configPath Path to the directory that contains the settings file */ void parseSettings(stateful_actor<hru_state>* self, std::string configPath); + /** Function to initalize the HRU for running */ void Initialize_HRU(stateful_actor<hru_state>* self); + /** Function runs all of the hru time_steps */ @@ -127,4 +129,6 @@ void initalizeTimeVars(stateful_actor<hru_state>* self); void finalizeTimeVars(stateful_actor<hru_state>* self); void deallocateHRUStructures(stateful_actor<hru_state>* self); + +void printOutput(stateful_actor<hru_state>* self); #endif \ No newline at end of file diff --git a/build/source/actors/HRUActor.h b/build/source/actors/HRUActor.h index 04f015a37fa380f17bf239207190c8528f95c8ea..4036bdf4ca0f26a395dd45a7bf4384670c30435a 100644 --- a/build/source/actors/HRUActor.h +++ b/build/source/actors/HRUActor.h @@ -38,6 +38,15 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, self->state.timestep = 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); @@ -176,7 +185,7 @@ void parseSettings(stateful_actor<hru_state>* self, std::string configPath) { if (self->state.printOutput) { // 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"]; } else { 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) { (self->state.initEnd - self->state.initStart).count(); } -/* -** RETURNS 0 on success and -1 on failure -*/ int Run_HRU(stateful_actor<hru_state>* self) { // Housekeeping of the timing variables if(self->state.timestep == 1) { @@ -305,15 +311,12 @@ int Run_HRU(stateful_actor<hru_state>* self) { self->state.forcingEnd = std::chrono::high_resolution_clock::now(); self->state.forcingDuration += self->state.forcingEnd - self->state.forcingStart; - if (self->state.timestep % 50000 == 0) { - aout(self) << self->state.refGRU << ":Accumulated Forcing Time = " << - self->state.forcingDuration << std::endl; - aout(self) << self->state.refGRU << " - Running Timestep = " << self->state.timestep << std::endl; - 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; + + if (self->state.printOutput && + self->state.timestep % self->state.outputFrequency == 0) { + printOutput(self); } + /********************************************************************** ** RUN_PHYSICS @@ -408,7 +411,6 @@ void initalizeTimeVars(stateful_actor<hru_state>* self) { self->state.writeOutputDuration = self->state.writeOutputEnd - self->state.writeOutputStart; } - void finalizeTimeVars(stateful_actor<hru_state>* self) { self->state.end = std::chrono::high_resolution_clock::now(); @@ -449,5 +451,9 @@ void deallocateHRUStructures(stateful_actor<hru_state>* self) { &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 \ No newline at end of file diff --git a/build/source/actors/Job.h b/build/source/actors/Job.h index 004b7c47e6abde8e76b752de756a69353822f806..9fa617c38cd81689e584f74b49dc84dcadab4cf7 100644 --- a/build/source/actors/Job.h +++ b/build/source/actors/Job.h @@ -48,7 +48,7 @@ struct job_state { bool outputCSV; std::string csvOut; std::string csvPath; - std::string successOutputFile = "SuccessHRU"; + std::string successOutputFile; std::string failedOutputFile = "failedHRU"; std::string fileAccessActorStats = "fileAccessActor.csv"; diff --git a/build/source/actors/JobActor.h b/build/source/actors/JobActor.h index d1583af44732d7e207fc153746a17f15ce1d15dd..352449fbac8c21fd7cb72dac007d0570b223d433 100644 --- a/build/source/actors/JobActor.h +++ b/build/source/actors/JobActor.h @@ -26,7 +26,7 @@ behavior job_actor(stateful_actor<job_state>* self, int startGRU, int numGRU, aout(self) << "ERROR WITH JSON SETTINGS FILE!!!\n"; self->quit(); } else { - aout(self) << "SETTINGS FOR JOB_ACTOR\n" << + aout(self) << "\nSETTINGS FOR JOB_ACTOR\n" << "File Manager Path = " << self->state.fileManager << "\n" << "outputCSV = " << self->state.outputCSV << "\n"; if (self->state.outputCSV) { @@ -178,10 +178,11 @@ int parseSettings(stateful_actor<job_state>* self, std::string configPath) { } void initJob(stateful_actor<job_state>* self) { - + std::string success = "Success"; // allows us to build the string if (self->state.outputCSV) { 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 << "GRU" << "," << "totalDuration" << "," << "initDuration" << "," << "forcingDuration" << "," << "runPhysicsDuration" << "," << "writeOutputDuration" << diff --git a/config/Summa_Actors_Settings.json b/config/Summa_Actors_Settings.json index 53358e70c7be469bfac5aa27ea658c3d0a1b2719..5acfcc6ad632c686cd7f167c6bd18c914c178b1e 100644 --- a/config/Summa_Actors_Settings.json +++ b/config/Summa_Actors_Settings.json @@ -5,13 +5,13 @@ }, "JobActor": { - "FileManagerPath": "/project/gwf/gwf_cmt/kck540/domain_NorthAmerica/settings/SUMMA/fileManager.txt", + "FileManagerPath": , "outputCSV": false, - "csvPath": "" + "csvPath": }, "HRUActor": { "printOutput": true, - "outputFrequency": 25000 + "outputFrequency": 1000 } } \ No newline at end of file