diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index a670f53ae48456df279922fc0011b3f2a155407a..dee87a506c5cd7577de4cede8a2e1442ed83a11a 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -52,9 +52,10 @@ message("\nSelected Bulid Type: ${CMAKE_BUILD_TYPE}\n") if(CMAKE_BUILD_TYPE MATCHES Debug) message("\nSetting Debug Options\n") add_definitions(-DDEBUG) - set(SUMMA_NOAHMP_OPTIONS -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) - set(SUMMA_ALL_OPTIONS -g -O0 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) - set(CMAKE_CXX_FLAGS "-g -O0 -Wfatal-errors -std=c++17") + set(SUMMA_NOAHMP_OPTIONS -pg -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) + set(SUMMA_ALL_OPTIONS -pg -g -O0 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) + set(CMAKE_CXX_FLAGS "-pg -g -O0 -Wfatal-errors -std=c++17") + set(CMAKE_CXX_LINK_FLAGS "-pg -g -O0 -Wfatal-errors -std=c++17") else() message("\nSetting Release Options\n") set(SUMMA_NOAHMP_OPTIONS -O3 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) diff --git a/build/cmake/be.cmake b/build/cmake/be.cmake index aae6541b203b5c54b06d23327137f1f226d49def..98bc842acad0ee51e8706f85cd23838fdadbf808 100644 --- a/build/cmake/be.cmake +++ b/build/cmake/be.cmake @@ -45,7 +45,8 @@ function (compile_with_be PARENT_DIR) -lopenblas SUMMA_NOAHMP) - set(SUMMA_ACTORS_INCLUDES + set(SUMMA_ACTORS_INCLUDES + "/usr/local/actor-framework/debug/include" ${CAF_INCLUDES} ${LAPACK_INCLUDES} "${PARENT_DIR}/build/includes/global" @@ -55,6 +56,7 @@ function (compile_with_be PARENT_DIR) "${PARENT_DIR}/build/includes/file_access_actor" "${PARENT_DIR}/build/includes/hru_actor") + link_directories("/usr/local/actor-framework/debug/lib") set(SUMMA_ACTORS_LIBS -lopenblas -lcaf_core @@ -262,7 +264,7 @@ function (compile_with_be PARENT_DIR) set(JOB_ACTOR ${ACTORS_DIR}/job_actor/job_actor.cpp - ${ACTORS_DIR}/job_actor/GRUinfo.cpp) + ${ACTORS_DIR}/job_actor/GRU.cpp) set(MAIN ${ACTORS_DIR}/main.cpp) @@ -273,16 +275,19 @@ function (compile_with_be PARENT_DIR) ${NOAHMP} ${NRUTIL}) target_compile_options(SUMMA_NOAHMP PRIVATE ${SUMMA_NOAHMP_OPTIONS}) + target_link_options(SUMMA_NOAHMP PRIVATE ${SUMMA_NOAHMP_OPTIONS}) # Build SUMMA_COMM Object add_library(SUMMA_COMM OBJECT ${COMM_ALL}) target_compile_options(SUMMA_COMM PRIVATE ${SUMMA_ALL_OPTIONS}) + target_link_options(SUMMA_COMM PRIVATE ${SUMMA_ALL_OPTIONS}) target_include_directories(SUMMA_COMM PRIVATE ${SUMMA_INCLUDES}) target_link_libraries(SUMMA_COMM PUBLIC ${SUMMA_LIBS}) # Build SUMMA Shared Library add_library(summa SHARED ${SUMMA_ALL}) target_compile_options(summa PRIVATE ${SUMMA_ALL_OPTIONS}) + target_link_options(summa PRIVATE ${SUMMA_ALL_OPTIONS}) target_include_directories(summa PUBLIC ${SUMMA_INCLUDES}) target_link_libraries(summa PUBLIC ${SUMMA_LIBS} SUMMA_COMM) # Build SUMMA Executable diff --git a/build/cmake/ida.cmake b/build/cmake/ida.cmake index fd8747c889aac41b035d74ada907aff975f55b1b..248f1311408af165d903e3c9f6ec10cd1a9cd035 100644 --- a/build/cmake/ida.cmake +++ b/build/cmake/ida.cmake @@ -258,7 +258,7 @@ function(compile_with_ida PARENT_DIR, DIR_SUNDIALS) set(JOB_ACTOR ${ACTORS_DIR}/job_actor/job_actor.cpp - ${ACTORS_DIR}/job_actor/GRUinfo.cpp) + ${ACTORS_DIR}/job_actor/GRU.cpp) set(MAIN ${ACTORS_DIR}/main.cpp) diff --git a/build/cmake/kinsol.cmake b/build/cmake/kinsol.cmake index b19cc42d4dcb5a7ee7e4fd66babc8d672c697502..cd86d3ab7c699d2d6d19acc51e26327019822920 100644 --- a/build/cmake/kinsol.cmake +++ b/build/cmake/kinsol.cmake @@ -303,7 +303,7 @@ function(compile_with_kinsol PARENT_DIR, DIR_SUNDIALS) set(JOB_ACTOR ${ACTORS_DIR}/job_actor/job_actor.cpp - ${ACTORS_DIR}/job_actor/GRUinfo.cpp) + ${ACTORS_DIR}/job_actor/GRU.cpp) set(MAIN ${ACTORS_DIR}/main.cpp) diff --git a/build/includes/job_actor/GRUinfo.hpp b/build/includes/job_actor/GRU.hpp similarity index 57% rename from build/includes/job_actor/GRUinfo.hpp rename to build/includes/job_actor/GRU.hpp index 99eab9f9a6d3e67437a5936b4186ab8420d137e9..6f6589e458d194d32573627b9d613eec6615d7ef 100644 --- a/build/includes/job_actor/GRUinfo.hpp +++ b/build/includes/job_actor/GRU.hpp @@ -17,6 +17,10 @@ auto success = [](const gru_state& state) -> int { return(state == gru_state::succeeded) ? 1 : 0; }; +/** + * Class that holds information about the running GRUs. This class is held by the job actor + * The GRU/HRU actors that carry out the simulation are held by the GRU class +*/ class GRU { private: int global_gru_index; // The index of the GRU in the netcdf file @@ -73,70 +77,3 @@ class GRU { void decrementAttemptsLeft(); }; - - - -class GRUinfo { - private: - int refGRU; // This will be the same as the refGRU - int indxGRU; - caf::actor GRU; - - // Variable to update - int dt_init; - - // Completed Information - int currentAttempt; - int maxAttempts; - bool completed; - bool failed; - - // Timing information for the GRU - double runTime; - double initDuration; - double forcingDuration; - double runPhysicsDuration; - double writeOutputDuration; - - public: - - // Constructor - GRUinfo(int refGRU, int indxGRU, caf::actor gru, int dt_init, int maxAttempts); - - // Deconstructor - ~GRUinfo(); - - - int getRefGRU(); - - int getIndxGRU(); - - int getDt_init(); - - caf::actor getActor(); - - void updateGRU(caf::actor gru); - - void updateFailed(); - - void updateCompletedToTrue(); - - void updateDt_init(); - - void updateCurrentAttempt(); - - bool isMaxAttemptsReached(); - - bool isFailed(); - - bool isCompleted(); - - void doneRun(double runTime, double initDuration, double forcingDuration, - double runPhysicsDuration, double writeOutputDuration); - - void writeSuccess(std::string fileName, std::string hostname); - - void writeFail(std::string fileName); - - void printOutput(); -}; \ No newline at end of file diff --git a/build/includes/job_actor/job_actor.hpp b/build/includes/job_actor/job_actor.hpp index 2a3464b45ae0c9ec96d421fc66b2eed2402164cd..1bb27143d71d87eebf10e0a7d98c07e89b1e7dca 100644 --- a/build/includes/job_actor/job_actor.hpp +++ b/build/includes/job_actor/job_actor.hpp @@ -1,7 +1,7 @@ #pragma once #include "caf/all.hpp" #include "caf/io/all.hpp" -#include "GRUinfo.hpp" +#include "GRU.hpp" #include "timing_info.hpp" #include "settings_functions.hpp" #include <unistd.h> @@ -38,7 +38,6 @@ struct job_state { // Variables for GRU monitoring int dt_init_start_factor = 1; // Initial Factor for dt_init (coupled_em) - // std::vector<GRUinfo*> gru_list; // List of all GRUs under this job actor int num_gru_done = 0; // The number of GRUs that have completed int num_gru_failed = 0; // Number of GRUs that have failed diff --git a/build/source/actors/job_actor/GRU.cpp b/build/source/actors/job_actor/GRU.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3138692f3456e34c9d7b8cbcbd74073f003c6c86 --- /dev/null +++ b/build/source/actors/job_actor/GRU.cpp @@ -0,0 +1,86 @@ +#include "caf/all.hpp" +#include "GRU.hpp" +#include <iostream> +#include <fstream> + + + +GRU::GRU(int global_gru_index, int local_gru_index, caf::actor gru_actor, int dt_init_factor, int max_attempt) { + this->global_gru_index = global_gru_index; + this->local_gru_index = local_gru_index; + this->gru_actor = gru_actor; + this->dt_init_factor = dt_init_factor; + this->attempts_left = max_attempt; + this->state = gru_state::running; +} +GRU::~GRU() {}; + +// Getters +int GRU::getGlobalGRUIndex() { + return this->global_gru_index; +} + +int GRU::getLocalGRUIndex() { + return this->local_gru_index; +} + +caf::actor GRU::getGRUActor() { + return this->gru_actor; +} + +double GRU::getRunTime() { + return this->run_time; +} + +double GRU::getInitDuration() { + return this->init_duration; +} + +double GRU::getForcingDuration() { + return this->forcing_duration; +} + +double GRU::getRunPhysicsDuration() { + return this->run_physics_duration; +} + +double GRU::getWriteOutputDuration() { + return this->write_output_duration; +} + +double GRU::getAttemptsLeft() { + return this->attempts_left; +} + +gru_state GRU::getStatus() { + return this->state; +} + +// Setters +void GRU::setRunTime(double run_time) { + this->run_time = run_time; +} +void GRU::setInitDuration(double init_duration) { + this->init_duration = init_duration; +} +void GRU::setForcingDuration(double forcing_duration) { + this->forcing_duration = forcing_duration; +} +void GRU::setRunPhysicsDuration(double run_physics_duration) { + this->run_physics_duration = run_physics_duration; +} +void GRU::setWriteOutputDuration(double write_output_duration) { + this->write_output_duration = write_output_duration; +} + +void GRU::setSuccess() { + this->state = gru_state::succeeded; +} + +void GRU::setFailed() { + this->state = gru_state::failed; +} + +void GRU::decrementAttemptsLeft() { + this->attempts_left--; +} \ No newline at end of file diff --git a/build/source/actors/job_actor/GRUinfo.cpp b/build/source/actors/job_actor/GRUinfo.cpp deleted file mode 100644 index 9360e0de5e1619db3f837439874bb4907a3fb60b..0000000000000000000000000000000000000000 --- a/build/source/actors/job_actor/GRUinfo.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include "caf/all.hpp" -#include "GRUinfo.hpp" -#include <iostream> -#include <fstream> - - - -GRU::GRU(int global_gru_index, int local_gru_index, caf::actor gru_actor, int dt_init_factor, int max_attempt) { - this->global_gru_index = global_gru_index; - this->local_gru_index = local_gru_index; - this->gru_actor = gru_actor; - this->dt_init_factor = dt_init_factor; - this->attempts_left = max_attempt; - this->state = gru_state::running; -} -GRU::~GRU() {}; - -// Getters -int GRU::getGlobalGRUIndex() { - return this->global_gru_index; -} - -int GRU::getLocalGRUIndex() { - return this->local_gru_index; -} - -caf::actor GRU::getGRUActor() { - return this->gru_actor; -} - -double GRU::getRunTime() { - return this->run_time; -} - -double GRU::getInitDuration() { - return this->init_duration; -} - -double GRU::getForcingDuration() { - return this->forcing_duration; -} - -double GRU::getRunPhysicsDuration() { - return this->run_physics_duration; -} - -double GRU::getWriteOutputDuration() { - return this->write_output_duration; -} - -double GRU::getAttemptsLeft() { - return this->attempts_left; -} - -gru_state GRU::getStatus() { - return this->state; -} - -// Setters -void GRU::setRunTime(double run_time) { - this->run_time = run_time; -} -void GRU::setInitDuration(double init_duration) { - this->init_duration = init_duration; -} -void GRU::setForcingDuration(double forcing_duration) { - this->forcing_duration = forcing_duration; -} -void GRU::setRunPhysicsDuration(double run_physics_duration) { - this->run_physics_duration = run_physics_duration; -} -void GRU::setWriteOutputDuration(double write_output_duration) { - this->write_output_duration = write_output_duration; -} - -void GRU::setSuccess() { - this->state = gru_state::succeeded; -} - -void GRU::setFailed() { - this->state = gru_state::failed; -} - -void GRU::decrementAttemptsLeft() { - this->attempts_left--; -} - - - - -GRUinfo::GRUinfo(int refGRU, int indxGRU, caf::actor gru_actor, int dt_init_factor, int max_attempts) { - this->refGRU = refGRU; - this->indxGRU = indxGRU; - this->GRU = gru_actor; - this->dt_init = dt_init_factor; - this->currentAttempt = 1; - -} -GRUinfo::~GRUinfo(){}; - -// Getters -int GRUinfo::getRefGRU() { - return this->refGRU; -} - -int GRUinfo::getIndxGRU() { - return this->indxGRU; -} - -int GRUinfo::getDt_init() { - return this->dt_init; -} - -caf::actor GRUinfo::getActor() { - return GRU; -} -// Setters -void GRUinfo::updateGRU(caf::actor gru) { - this->GRU = gru; -} - -void GRUinfo::updateFailed() { - if (this->failed) { - this->failed = false; - } else { - this->failed = true; - } -} - -void GRUinfo::updateCompletedToTrue(){ - this->completed = true; -} - -void GRUinfo::updateDt_init() { - this->dt_init = this->dt_init * 2; -} - -void GRUinfo::updateCurrentAttempt() { - this->currentAttempt++; -} - -// Methods that return Booleans -bool GRUinfo::isMaxAttemptsReached() { - return this->maxAttempts <= this->currentAttempt; -} - -bool GRUinfo::isFailed() { - return this->failed; -} - -bool GRUinfo::isCompleted() { - return this->completed; -} - -void GRUinfo::doneRun(double runTime, double initDuration, double forcingDuration, - double runPhysicsDuration, double writeOutputDuration) { - this->runTime = runTime; - this->initDuration = initDuration; - this->forcingDuration = forcingDuration; - this->runPhysicsDuration = runPhysicsDuration; - this->writeOutputDuration = writeOutputDuration; -} - -// Methods for writing statistics to a file -void GRUinfo::writeSuccess(std::string fileName, std::string hostname) { - std::ofstream file; - file.open(fileName, std::ios_base::app); - file << hostname << "," - << this->refGRU << "," - << this->runTime << "," - << this->initDuration << "," - << this->forcingDuration << "," - << this->runPhysicsDuration << "," - << this->writeOutputDuration << "," - << this->dt_init << "," - << this->currentAttempt << "\n"; - file.close(); -} - -void GRUinfo::writeFail(std::string fileName) { - std::ofstream file; - file.open(fileName, std::ios_base::app); - file << this->refGRU << "," - << this->dt_init << "," - << this->currentAttempt << "\n"; - file.close(); -} - -void GRUinfo::printOutput() { - std::cout << "\nGRU = " << this->refGRU << "\n" << - "RunTime = " << this->runTime << "\n" << - "initDuration = " << this->initDuration << "\n" << - "forcingDuration = " << this->forcingDuration << "\n" << - "runPhysicsDuration = " << this->runPhysicsDuration << "\n" << - "writeOutputDuration = " << this->writeOutputDuration << "\n\n"; -} \ No newline at end of file