From 53346df81036fc6e3ebed0d02e834b9200658a5c Mon Sep 17 00:00:00 2001 From: Kyle <kyle.c.klenk@gmail.com> Date: Wed, 2 Nov 2022 19:43:14 +0000 Subject: [PATCH] Updated with removal of output_struc_size --- .../file_access_actor/file_access_actor.hpp | 3 +- build/includes/gru_actor/gru_actor.hpp | 1 - build/includes/hru_actor/hru_actor.hpp | 3 +- build/includes/job_actor/job_actor.hpp | 1 - .../cpp_code/file_access_actor.cpp | 4 +-- build/source/actors/gru_actor/gru_actor.cpp | 4 +-- .../actors/hru_actor/cpp_code/hru_actor.cpp | 29 +------------------ build/source/actors/job_actor/job_actor.cpp | 7 ++--- 8 files changed, 9 insertions(+), 43 deletions(-) diff --git a/build/includes/file_access_actor/file_access_actor.hpp b/build/includes/file_access_actor/file_access_actor.hpp index 61a4497..9192455 100644 --- a/build/includes/file_access_actor/file_access_actor.hpp +++ b/build/includes/file_access_actor/file_access_actor.hpp @@ -19,7 +19,6 @@ struct file_access_state { OutputManager *output_manager; int num_vectors_in_output_manager; int num_steps; - int outputStrucSize; int stepsInCurrentFile; int numFiles; int filesLoaded; @@ -55,7 +54,7 @@ struct file_access_state { }; behavior file_access_actor(stateful_actor<file_access_state>* self, int startGRU, int numGRU, - int outputStrucSize, File_Access_Actor_Settings file_access_actor_settings, actor parent); + File_Access_Actor_Settings file_access_actor_settings, actor parent); void initalizeFileAccessActor(stateful_actor<file_access_state>* self); int writeOutput(stateful_actor<file_access_state>* self, int indxGRU, int indxHRU, int numStepsToWrite, int returnMessage, caf::actor actorRef); diff --git a/build/includes/gru_actor/gru_actor.hpp b/build/includes/gru_actor/gru_actor.hpp index a080475..8111d5b 100644 --- a/build/includes/gru_actor/gru_actor.hpp +++ b/build/includes/gru_actor/gru_actor.hpp @@ -47,6 +47,5 @@ behavior gru_actor(stateful_actor<gru_state>* self, int indx_gru, std::string config_path, caf::actor file_access_actor, - int output_struc_size, caf::actor parent); } \ No newline at end of file diff --git a/build/includes/hru_actor/hru_actor.hpp b/build/includes/hru_actor/hru_actor.hpp index 42fb3ff..ce634c5 100644 --- a/build/includes/hru_actor/hru_actor.hpp +++ b/build/includes/hru_actor/hru_actor.hpp @@ -24,7 +24,6 @@ struct hru_state { int refGRU; // The actual ID of the GRU we are // Variables for output/forcing structures - int outputStrucSize; int outputStep; int stepsInCurrentFFile; int forcingFileStep; @@ -98,7 +97,7 @@ struct hru_state { behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, HRU_Actor_Settings hru_actor_settings, caf::actor file_access_actor, - int outputStrucSize, caf::actor parent); + caf::actor parent); /** Function to initalize the HRU for running diff --git a/build/includes/job_actor/job_actor.hpp b/build/includes/job_actor/job_actor.hpp index b2724c9..92a8132 100644 --- a/build/includes/job_actor/job_actor.hpp +++ b/build/includes/job_actor/job_actor.hpp @@ -24,7 +24,6 @@ struct job_state { int gru_init = 0; // Number of GRUs initalized int err = 0; // Error Code int num_gru_failed = 0; // Number of GRUs that have failed - int output_struct_size; // Timing Variables TimingInfo job_timing; diff --git a/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp b/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp index 2e6d5ad..df36299 100644 --- a/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp +++ b/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp @@ -17,7 +17,7 @@ bool debug; namespace caf { behavior file_access_actor(stateful_actor<file_access_state>* self, int start_gru, int num_gru, - int output_structure_size, File_Access_Actor_Settings file_access_actor_settings, actor parent) { + File_Access_Actor_Settings file_access_actor_settings, actor parent) { aout(self) << "\n----------File_Access_Actor Started----------\n"; // Set Up timing Info we wish to track self->state.file_access_timing = TimingInfo(); @@ -29,7 +29,6 @@ behavior file_access_actor(stateful_actor<file_access_state>* self, int start_gr self->state.parent = parent; self->state.num_gru = num_gru; self->state.start_gru = start_gru; - self->state.outputStrucSize = output_structure_size; self->state.handle_forcing_file_info = new_handle_file_info(); self->state.handle_ncid = new_handle_var_i(); self->state.err = 0; @@ -127,6 +126,7 @@ behavior file_access_actor(stateful_actor<file_access_state>* self, int start_gr }, [=] (get_attributes_params, int ref_gru, caf::actor actor_to_respond) { + // Find the correct attribute file we loaded in void* handle_attr_struct = self->state.attr_structs_for_hrus[ref_gru-1]; std::vector<double> attr_struct_to_send = get_var_d(handle_attr_struct); diff --git a/build/source/actors/gru_actor/gru_actor.cpp b/build/source/actors/gru_actor/gru_actor.cpp index d9177c2..81720a6 100644 --- a/build/source/actors/gru_actor/gru_actor.cpp +++ b/build/source/actors/gru_actor/gru_actor.cpp @@ -9,8 +9,7 @@ namespace caf { behavior gru_actor(stateful_actor<gru_state>* self, - int ref_gru, int indx_gru, - std::string config_path, caf::actor file_access_actor, int output_struc_size, + int ref_gru, int indx_gru, std::string config_path, caf::actor file_access_actor, caf::actor parent) { aout(self) << "GRU Actor Has Started\n"; @@ -19,7 +18,6 @@ behavior gru_actor(stateful_actor<gru_state>* self, self->state.indx_gru = indx_gru; self->state.config_path = config_path; self->state.file_access_actor = file_access_actor; - self->state.output_struc_size = output_struc_size; self->state.parent = parent; self->state.num_hrus = getNumHRU(&self->state.indx_gru); diff --git a/build/source/actors/hru_actor/cpp_code/hru_actor.cpp b/build/source/actors/hru_actor/cpp_code/hru_actor.cpp index 16c29c0..b3a3992 100644 --- a/build/source/actors/hru_actor/cpp_code/hru_actor.cpp +++ b/build/source/actors/hru_actor/cpp_code/hru_actor.cpp @@ -9,7 +9,7 @@ namespace caf { behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, - HRU_Actor_Settings hru_actor_settings, caf::actor file_access_actor, int outputStrucSize, caf::actor parent) { + HRU_Actor_Settings hru_actor_settings, caf::actor file_access_actor, caf::actor parent) { // Timing Information self->state.hru_timing = TimingInfo(); @@ -30,9 +30,6 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, self->state.indxGRU = indxGRU; self->state.refGRU = refGRU; - // OutputStructure Size (how many timesteps we can compute before we need to write) - self->state.outputStrucSize = outputStrucSize; - // initialize counters self->state.timestep = 1; // Timestep of total simulation self->state.outputStep = 1; // Index of the output structure @@ -411,35 +408,11 @@ bool check_HRU(stateful_actor<hru_state>* self, int err) { } else if (self->state.timestep > self->state.num_steps) { // check if simulation is finished self->state.outputStep -= 1; // prevents segfault - - self->send(self->state.file_access_actor, write_output_v, - self->state.indxGRU, self->state.indxHRU, self->state.outputStep, self); self->state.hru_timing.updateEndPoint("total_duration"); - return false; - - } else if (self->state.outputStep > self->state.outputStrucSize && - self->state.forcingStep > self->state.stepsInCurrentFFile) { - // Special case where we need both reading and writing - self->state.outputStep -= 1; // prevents segfault - - self->send(self->state.file_access_actor, read_and_write_v, self->state.indxGRU, - self->state.indxHRU, self->state.outputStep, self->state.iFile + 1, self); - self->state.outputStep = 1; - return false; - } else if (self->state.outputStep > self->state.outputStrucSize) { - // check if we need to clear the output struc - self->state.outputStep -= 1; - - self->send(self->state.file_access_actor, write_output_v, - self->state.indxGRU, self->state.indxHRU, self->state.outputStep, self); - self->state.outputStep = 1; - - return false; - } else if (self->state.forcingStep > self->state.stepsInCurrentFFile) { // we need more forcing data self->send(self->state.file_access_actor, access_forcing_v, self->state.iFile + 1, self); diff --git a/build/source/actors/job_actor/job_actor.cpp b/build/source/actors/job_actor/job_actor.cpp index 1d5ef95..831c12c 100644 --- a/build/source/actors/job_actor/job_actor.cpp +++ b/build/source/actors/job_actor/job_actor.cpp @@ -70,7 +70,7 @@ behavior job_actor(stateful_actor<job_state>* self, int start_gru, int num_gru, // Spawn the file_access_actor. This will return the number of forcing files we are working with self->state.file_access_actor = self->spawn(file_access_actor, self->state.start_gru, self->state.num_gru, - self->state.job_actor_settings.output_structure_size, self->state.file_access_actor_settings, self); + self->state.file_access_actor_settings, self); aout(self) << "Job Actor Initalized \n"; @@ -190,7 +190,7 @@ behavior job_actor(stateful_actor<job_state>* self, int start_gru, int num_gru, aout(self) << "Error with the output file, will try creating it agian\n"; std::this_thread::sleep_for(std::chrono::seconds(5)); self->state.file_access_actor = self->spawn(file_access_actor, self->state.start_gru, self->state.num_gru, - self->state.job_actor_settings.output_structure_size, self->state.file_access_actor_settings, self); + self->state.file_access_actor_settings, self); } else { aout(self) << "Letting Parent Know we are quitting\n"; self->send(self->state.parent, err_v); @@ -232,7 +232,6 @@ void initalizeGRU(stateful_actor<job_state>* self) { index_gru, self->state.hru_actor_settings, self->state.file_access_actor, - self->state.output_struct_size, self); self->state.gru_list.push_back(new GRUinfo(start_gru, index_gru, gru, self->state.dt_init_start_factor, self->state.max_run_attempts)); @@ -262,7 +261,7 @@ void restartFailures(stateful_actor<job_state>* self) { gru->updateDt_init(); auto newGRU = self->spawn(hru_actor, gru->getRefGRU(), gru->getIndxGRU(), self->state.hru_actor_settings, self->state.file_access_actor, - self->state.output_struct_size, self); + self); gru->updateGRU(newGRU); gru->updateCurrentAttempt(); self->send(gru->getActor(), dt_init_factor_v, gru->getDt_init()); -- GitLab