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

Change GRUinfo to GRU

Changed the GRUinfo class to be just the GRU class.
This class now better reflects that it is the object that
the job actor holds. It will also contain the GRU actor that runs the simulation
portion of the program.
parent 73feb946
No related branches found
No related tags found
No related merge requests found
...@@ -52,9 +52,10 @@ message("\nSelected Bulid Type: ${CMAKE_BUILD_TYPE}\n") ...@@ -52,9 +52,10 @@ message("\nSelected Bulid Type: ${CMAKE_BUILD_TYPE}\n")
if(CMAKE_BUILD_TYPE MATCHES Debug) if(CMAKE_BUILD_TYPE MATCHES Debug)
message("\nSetting Debug Options\n") message("\nSetting Debug Options\n")
add_definitions(-DDEBUG) add_definitions(-DDEBUG)
set(SUMMA_NOAHMP_OPTIONS -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) set(SUMMA_NOAHMP_OPTIONS -pg -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(SUMMA_ALL_OPTIONS -pg -g -O0 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors)
set(CMAKE_CXX_FLAGS "-g -O0 -Wfatal-errors -std=c++17") 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() else()
message("\nSetting Release Options\n") message("\nSetting Release Options\n")
set(SUMMA_NOAHMP_OPTIONS -O3 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) set(SUMMA_NOAHMP_OPTIONS -O3 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors)
......
...@@ -45,7 +45,8 @@ function (compile_with_be PARENT_DIR) ...@@ -45,7 +45,8 @@ function (compile_with_be PARENT_DIR)
-lopenblas -lopenblas
SUMMA_NOAHMP) SUMMA_NOAHMP)
set(SUMMA_ACTORS_INCLUDES set(SUMMA_ACTORS_INCLUDES
"/usr/local/actor-framework/debug/include"
${CAF_INCLUDES} ${CAF_INCLUDES}
${LAPACK_INCLUDES} ${LAPACK_INCLUDES}
"${PARENT_DIR}/build/includes/global" "${PARENT_DIR}/build/includes/global"
...@@ -55,6 +56,7 @@ function (compile_with_be PARENT_DIR) ...@@ -55,6 +56,7 @@ function (compile_with_be PARENT_DIR)
"${PARENT_DIR}/build/includes/file_access_actor" "${PARENT_DIR}/build/includes/file_access_actor"
"${PARENT_DIR}/build/includes/hru_actor") "${PARENT_DIR}/build/includes/hru_actor")
link_directories("/usr/local/actor-framework/debug/lib")
set(SUMMA_ACTORS_LIBS set(SUMMA_ACTORS_LIBS
-lopenblas -lopenblas
-lcaf_core -lcaf_core
...@@ -262,7 +264,7 @@ function (compile_with_be PARENT_DIR) ...@@ -262,7 +264,7 @@ function (compile_with_be PARENT_DIR)
set(JOB_ACTOR set(JOB_ACTOR
${ACTORS_DIR}/job_actor/job_actor.cpp ${ACTORS_DIR}/job_actor/job_actor.cpp
${ACTORS_DIR}/job_actor/GRUinfo.cpp) ${ACTORS_DIR}/job_actor/GRU.cpp)
set(MAIN set(MAIN
${ACTORS_DIR}/main.cpp) ${ACTORS_DIR}/main.cpp)
...@@ -273,16 +275,19 @@ function (compile_with_be PARENT_DIR) ...@@ -273,16 +275,19 @@ function (compile_with_be PARENT_DIR)
${NOAHMP} ${NOAHMP}
${NRUTIL}) ${NRUTIL})
target_compile_options(SUMMA_NOAHMP PRIVATE ${SUMMA_NOAHMP_OPTIONS}) target_compile_options(SUMMA_NOAHMP PRIVATE ${SUMMA_NOAHMP_OPTIONS})
target_link_options(SUMMA_NOAHMP PRIVATE ${SUMMA_NOAHMP_OPTIONS})
# Build SUMMA_COMM Object # Build SUMMA_COMM Object
add_library(SUMMA_COMM OBJECT add_library(SUMMA_COMM OBJECT
${COMM_ALL}) ${COMM_ALL})
target_compile_options(SUMMA_COMM PRIVATE ${SUMMA_ALL_OPTIONS}) 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_include_directories(SUMMA_COMM PRIVATE ${SUMMA_INCLUDES})
target_link_libraries(SUMMA_COMM PUBLIC ${SUMMA_LIBS}) target_link_libraries(SUMMA_COMM PUBLIC ${SUMMA_LIBS})
# Build SUMMA Shared Library # Build SUMMA Shared Library
add_library(summa SHARED add_library(summa SHARED
${SUMMA_ALL}) ${SUMMA_ALL})
target_compile_options(summa PRIVATE ${SUMMA_ALL_OPTIONS}) target_compile_options(summa PRIVATE ${SUMMA_ALL_OPTIONS})
target_link_options(summa PRIVATE ${SUMMA_ALL_OPTIONS})
target_include_directories(summa PUBLIC ${SUMMA_INCLUDES}) target_include_directories(summa PUBLIC ${SUMMA_INCLUDES})
target_link_libraries(summa PUBLIC ${SUMMA_LIBS} SUMMA_COMM) target_link_libraries(summa PUBLIC ${SUMMA_LIBS} SUMMA_COMM)
# Build SUMMA Executable # Build SUMMA Executable
......
...@@ -258,7 +258,7 @@ function(compile_with_ida PARENT_DIR, DIR_SUNDIALS) ...@@ -258,7 +258,7 @@ function(compile_with_ida PARENT_DIR, DIR_SUNDIALS)
set(JOB_ACTOR set(JOB_ACTOR
${ACTORS_DIR}/job_actor/job_actor.cpp ${ACTORS_DIR}/job_actor/job_actor.cpp
${ACTORS_DIR}/job_actor/GRUinfo.cpp) ${ACTORS_DIR}/job_actor/GRU.cpp)
set(MAIN set(MAIN
${ACTORS_DIR}/main.cpp) ${ACTORS_DIR}/main.cpp)
......
...@@ -303,7 +303,7 @@ function(compile_with_kinsol PARENT_DIR, DIR_SUNDIALS) ...@@ -303,7 +303,7 @@ function(compile_with_kinsol PARENT_DIR, DIR_SUNDIALS)
set(JOB_ACTOR set(JOB_ACTOR
${ACTORS_DIR}/job_actor/job_actor.cpp ${ACTORS_DIR}/job_actor/job_actor.cpp
${ACTORS_DIR}/job_actor/GRUinfo.cpp) ${ACTORS_DIR}/job_actor/GRU.cpp)
set(MAIN set(MAIN
${ACTORS_DIR}/main.cpp) ${ACTORS_DIR}/main.cpp)
......
...@@ -17,6 +17,10 @@ auto success = [](const gru_state& state) -> int { ...@@ -17,6 +17,10 @@ auto success = [](const gru_state& state) -> int {
return(state == gru_state::succeeded) ? 1 : 0; 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 { class GRU {
private: private:
int global_gru_index; // The index of the GRU in the netcdf file int global_gru_index; // The index of the GRU in the netcdf file
...@@ -73,70 +77,3 @@ class GRU { ...@@ -73,70 +77,3 @@ class GRU {
void decrementAttemptsLeft(); 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
#pragma once #pragma once
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
#include "GRUinfo.hpp" #include "GRU.hpp"
#include "timing_info.hpp" #include "timing_info.hpp"
#include "settings_functions.hpp" #include "settings_functions.hpp"
#include <unistd.h> #include <unistd.h>
...@@ -38,7 +38,6 @@ struct job_state { ...@@ -38,7 +38,6 @@ struct job_state {
// Variables for GRU monitoring // Variables for GRU monitoring
int dt_init_start_factor = 1; // Initial Factor for dt_init (coupled_em) 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_done = 0; // The number of GRUs that have completed
int num_gru_failed = 0; // Number of GRUs that have failed int num_gru_failed = 0; // Number of GRUs that have failed
......
#include "caf/all.hpp" #include "caf/all.hpp"
#include "GRUinfo.hpp" #include "GRU.hpp"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
...@@ -83,114 +83,4 @@ void GRU::setFailed() { ...@@ -83,114 +83,4 @@ void GRU::setFailed() {
void GRU::decrementAttemptsLeft() { void GRU::decrementAttemptsLeft() {
this->attempts_left--; 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
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