From e847c41d2a4125a66dc488b59998e1bf03869301 Mon Sep 17 00:00:00 2001 From: KyleKlenk <kyle.c.klenk@gmail.com> Date: Wed, 9 Nov 2022 14:23:59 -0600 Subject: [PATCH] got the backup server to publish when the original server goes down --- build/includes/global/message_atoms.hpp | 4 + .../summa_actor/summa_backup_server.hpp | 5 +- build/includes/summa_actor/summa_server.hpp | 5 +- .../summa_actor/summa_backup_server.cpp | 36 ++- .../actors/summa_actor/summa_server.cpp | 35 +-- build/source/testing/Extras/Client.h | 28 -- build/source/testing/Extras/ClientActor.h | 80 ----- build/source/testing/Extras/HRUMonitor.h | 49 --- build/source/testing/Extras/JobActorConnect.h | 9 - build/source/testing/Extras/globalFunctions.h | 65 ---- .../testing/Extras/server/ClientManager.h | 43 --- .../testing/Extras/server/ClientReference.h | 66 ---- build/source/testing/Extras/server/GRUInfo.h | 71 ----- build/source/testing/Extras/server/GRUStruc.h | 52 ---- .../testing/Extras/server/SummaCoordinator.h | 51 ---- .../Extras/server/SummaCoordinatorActor.h | 221 -------------- build/source/testing/Test/HRUTest.h | 257 ---------------- build/source/testing/Test/JobTest.h | 117 -------- build/source/testing/Test/makefile | 281 ------------------ build/source/testing/Test/messageAtoms.h | 7 - build/source/testing/Test/testing_main.cc | 20 -- 21 files changed, 61 insertions(+), 1441 deletions(-) delete mode 100644 build/source/testing/Extras/Client.h delete mode 100644 build/source/testing/Extras/ClientActor.h delete mode 100644 build/source/testing/Extras/HRUMonitor.h delete mode 100644 build/source/testing/Extras/JobActorConnect.h delete mode 100644 build/source/testing/Extras/globalFunctions.h delete mode 100644 build/source/testing/Extras/server/ClientManager.h delete mode 100644 build/source/testing/Extras/server/ClientReference.h delete mode 100644 build/source/testing/Extras/server/GRUInfo.h delete mode 100644 build/source/testing/Extras/server/GRUStruc.h delete mode 100644 build/source/testing/Extras/server/SummaCoordinator.h delete mode 100644 build/source/testing/Extras/server/SummaCoordinatorActor.h delete mode 100644 build/source/testing/Test/HRUTest.h delete mode 100644 build/source/testing/Test/JobTest.h delete mode 100644 build/source/testing/Test/makefile delete mode 100644 build/source/testing/Test/messageAtoms.h delete mode 100644 build/source/testing/Test/testing_main.cc diff --git a/build/includes/global/message_atoms.hpp b/build/includes/global/message_atoms.hpp index e60f5f7..bc1f341 100644 --- a/build/includes/global/message_atoms.hpp +++ b/build/includes/global/message_atoms.hpp @@ -99,6 +99,10 @@ CAF_BEGIN_TYPE_ID_BLOCK(summa, first_custom_type_id) CAF_ADD_ATOM(summa, connect_to_server) // Sender: // Reciever: + // Summary: + CAF_ADD_ATOM(summa, connect_as_backup) + // Sender: + // Reciever: // Summary: CAF_ADD_ATOM(summa, compute_batch) // Sender: diff --git a/build/includes/summa_actor/summa_backup_server.hpp b/build/includes/summa_actor/summa_backup_server.hpp index 3f0ff0c..08033dd 100644 --- a/build/includes/summa_actor/summa_backup_server.hpp +++ b/build/includes/summa_actor/summa_backup_server.hpp @@ -2,16 +2,17 @@ #include "caf/all.hpp" #include "caf/io/all.hpp" - +#include <string> namespace caf { struct summa_backup_state { strong_actor_ptr current_server; - + std::string hostname; }; behavior summa_backup_server(stateful_actor<summa_backup_state>* self); behavior unconnected(stateful_actor<summa_backup_state>* self); void connecting(stateful_actor<summa_backup_state>* self, const std::string& host, uint16_t port); behavior running(stateful_actor<summa_backup_state>* self, const actor& server_actor); +behavior backup_server(stateful_actor<summa_backup_state>* self); } \ No newline at end of file diff --git a/build/includes/summa_actor/summa_server.hpp b/build/includes/summa_actor/summa_server.hpp index 921cb45..324b8f9 100644 --- a/build/includes/summa_actor/summa_server.hpp +++ b/build/includes/summa_actor/summa_server.hpp @@ -12,9 +12,12 @@ namespace caf { struct summa_server_state { + actor backup_server; + int num_clients; int batches_remaining = 0; int batches_solved = 0; + std::string config_path; std::vector<Batch> batch_list; std::vector<Batch> solved_batches; @@ -41,7 +44,7 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett void sendClientsHeartbeat(stateful_actor<summa_server_state>* self); -behavior cleint_health_check_reminder(event_based_actor* self); +behavior client_health_check_reminder(event_based_actor* self); int assembleBatches(stateful_actor<summa_server_state>* self); diff --git a/build/source/actors/summa_actor/summa_backup_server.cpp b/build/source/actors/summa_actor/summa_backup_server.cpp index 57b69c8..00bfa1d 100644 --- a/build/source/actors/summa_actor/summa_backup_server.cpp +++ b/build/source/actors/summa_actor/summa_backup_server.cpp @@ -3,7 +3,8 @@ #include "message_atoms.hpp" #include "summa_backup_server.hpp" #include "global.hpp" - +#include <chrono> +#include <thread> namespace caf { behavior summa_backup_server(stateful_actor<summa_backup_state>* self) { @@ -11,8 +12,20 @@ behavior summa_backup_server(stateful_actor<summa_backup_state>* self) { self->set_down_handler([=](const down_msg& dm){ if(dm.source == self->state.current_server) { aout(self) << "*** Lost Connection to Server" << std::endl; - self->state.current_server = nullptr; - self->become(unconnected(self)); + + auto new_server = self->spawn(backup_server); + + int port = 4444; + aout(self) << "Attempting to publish backup server on port - " << port << std::endl; + auto is_port = io::publish(new_server, port); + if (!is_port) { + std::cerr << "********PUBLISH FAILED*******" << to_string(is_port.error()) << "\n"; + return; + } + aout(self) << "Successfully Published summa_server_actor on port " << *is_port << "\n"; + + // self->state.current_server = nullptr; + // self->become(unconnected(self)); } }); return unconnected(self); @@ -62,8 +75,23 @@ void connecting(stateful_actor<summa_backup_state>* self, const std::string& hos behavior running(stateful_actor<summa_backup_state>* self, const actor& server_actor) { aout(self) << "Backup Server is now Running\n"; + self->send(server_actor, connect_as_backup_v, self); + return { + [=](connect_as_backup) { + aout(self) << "Successfully connected to current server\n"; + } + - return {}; + }; +} + +behavior backup_server(stateful_actor<summa_backup_state>* self) { + aout(self) << "Published\n"; + return { + [=] (connect_as_backup) { + + } + }; } diff --git a/build/source/actors/summa_actor/summa_server.cpp b/build/source/actors/summa_actor/summa_server.cpp index 63cf2fb..def4f9e 100644 --- a/build/source/actors/summa_actor/summa_server.cpp +++ b/build/source/actors/summa_actor/summa_server.cpp @@ -16,8 +16,15 @@ namespace caf { behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Settings distributed_settings, Summa_Actor_Settings summa_actor_settings, File_Access_Actor_Settings file_access_actor_settings, Job_Actor_Settings job_actor_settings, HRU_Actor_Settings hru_actor_settings) { - + aout(self) << "Summa Server has Started \n"; + + self->set_down_handler([=](const down_msg& dm) { + aout(self) << "Lost A Client\n"; + }); + + + self->state.distributed_settings = distributed_settings; self->state.summa_actor_settings = summa_actor_settings; self->state.file_access_actor_settings = file_access_actor_settings; @@ -34,18 +41,12 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett initializeCSVOutput(self->state.job_actor_settings.csv_path, self->state.csv_output_name); // Start the heartbeat actor after a client has connected - self->state.health_check_reminder_actor = self->spawn(cleint_health_check_reminder); + self->state.health_check_reminder_actor = self->spawn(client_health_check_reminder); self->send(self->state.health_check_reminder_actor, start_health_check_v, self, self->state.distributed_settings.heartbeat_interval); return { - /** - * @brief A message from a client requesting to connect - * - * @param client the actor_ref of the client_actor - * (used to send messages to the client_actor) - * @param hostname human readable hostname of the machine that the actor is running on - */ + // A message from a client requesting to connect [=](connect_to_server, actor client_actor, std::string hostname) { aout(self) << "Actor trying to connect with hostname " << hostname << "\n"; @@ -69,13 +70,13 @@ behavior summa_server(stateful_actor<summa_server_state>* self, Distributed_Sett }, - /** - * @brief Construct a new [=] object - * - * @param client_actor - * @param client_id - * @param batch - */ + [=](connect_as_backup, actor backup_server) { + aout(self) << "Received Connection Request From a backup server\n"; + self->state.backup_server = backup_server; + self->monitor(backup_server); + self->send(self->state.backup_server, connect_as_backup_v); // confirm connection + }, + [=](done_batch, actor client_actor, int client_id, Batch& batch) { aout(self) << "Received Completed Batch From Client\n"; @@ -176,7 +177,7 @@ void initializeCSVOutput(std::string csv_output_path, std::string csv_output_nam -behavior cleint_health_check_reminder(event_based_actor* self) { +behavior client_health_check_reminder(event_based_actor* self) { return { [=](start_health_check, caf::actor summa_server, int sleep_duration) { diff --git a/build/source/testing/Extras/Client.h b/build/source/testing/Extras/Client.h deleted file mode 100644 index 0937b70..0000000 --- a/build/source/testing/Extras/Client.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef SUMMACLIENT_H_ -#define SUMMACLIENT_H_ - -#include "caf/all.hpp" -#include "caf/io/all.hpp" -#include "string.h" -#include <unistd.h> - -#include "../messageAtoms.h" - -struct summa_client_state{ - int ID; // ID for array access by coordinator actor - strong_actor_ptr coordinator_actor; // This is the Actor Coordinating jobs, it talks to jobs through a Jobs Client Actor - strong_actor_ptr job_actor; // This actors direct parent, reponsible for creating, and running GRU/HRU actors - std::string fileManager; - - const int numRetryAttempts = 2; // number of attempts for an HRU to try and compute - int currentAttempt; // the current attempt we are on -}; - -// ******************************************************************************** -// ** Funciton Prototypes -// ******************************************************************************** -behavior unconnected(stateful_actor<summa_client_state>*); -void connecting(stateful_actor<summa_client_state>*, const std::string& host, uint16_t port); -behavior running(stateful_actor<summa_client_state>*, const actor& summa_coordinator); - -#endif diff --git a/build/source/testing/Extras/ClientActor.h b/build/source/testing/Extras/ClientActor.h deleted file mode 100644 index 7a03ee9..0000000 --- a/build/source/testing/Extras/ClientActor.h +++ /dev/null @@ -1,80 +0,0 @@ -#ifndef SUMMACLIENTACTOR_H_ -#define SUMMACLIENTACTOR_H_ - -#include "Client.h" - -using namespace caf; -behavior client_actor(stateful_actor<client_state>* self, std::string fileManager, int jobID) { - self->state.fileManager = fileManager; - self->state.ID = jobID; - - self->set_down_handler([=](const down_msg& dm){ - if(dm.source == self->state.current_server) { - aout(self) << "!!!! LOST CONNECTION TO Summa_Coordinator_Actor !!!!" << std::endl; - self->state.current_server = nullptr; - self->become(unconnected(self)); - - } - }); - return unconnected(self); -} - - -behavior unconnected(stateful_actor<client_state>* self) { - return { - [=] (connect_atom, const std::string& host, uint16_t port) { - connecting(self, host, port); - }, - }; -} - -void connecting(stateful_actor<client_state>* self, const std::string& host, uint16_t port) { - self->state.current_server = nullptr; - - auto mm = self->system().middleman().actor_handle(); - self->request(mm, infinite, connect_atom_v, host, port) - .await( - [=](const node_id&, strong_actor_ptr serv, - const std::set<std::string>& ifs) { - if (!serv) { - aout(self) << R"(*** no server found at ")" << host << R"(":)" << port << std::endl; - return; - } - if (!ifs.empty()) { - aout(self) << R"(*** typed actor found at ")" << host << R"(":)" - << port << ", but expected an untyped actor " << std::endl; - return; - } - aout(self) << "*** successfully connected to server" << std::endl; - self->state.current_server = serv; - auto hdl = actor_cast<actor>(serv); - self->monitor(hdl); - self->become(running(self, hdl)); - }, - [=](const error& err) { - aout(self) << R"(*** cannot connect to ")" << host << R"(":)" << port - << " => " << to_string(err) << std::endl; - self->become(unconnected(self)); - }); -} - -behavior running(stateful_actor<summa_client_state>* self, const actor& summa_coordinator) { - /********************************************************************************************************* - ******************************** ACTOR INITIALIZATION *************************************************** - *********************************************************************************************************/ - aout(self) << "Client is Connected and about to send a message" << std::endl; - self->state.server = summa_coordinator; - self->send(self->state.server, connect_to_coordinator_v, self, self->state.ID); - /********************************************************************************************************* - ************************************ END ACTOR INITIALIZATION ******************************************* - *********************************************************************************************************/ - - - /********************************************************************************************************* - *********************************** ACTOR MESSAGE HANDLERS ********************************************** - *********************************************************************************************************/ - return { - }; -} - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/HRUMonitor.h b/build/source/testing/Extras/HRUMonitor.h deleted file mode 100644 index e5bb783..0000000 --- a/build/source/testing/Extras/HRUMonitor.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef HRUMonitor_H_ -#define HRUMonitor_H_ - -#include "HRUinfo.h" -#include "../HRUActor.h" -#include "Job.h" -#include "JobActor.h" -#include "caf/all.hpp" -#include <vector> - -// class HRUMonitor { -// private: -// std::vector<HRUinfo> hruList; -// int numHRU; -// int numCompleted; -// int numFailed; -// int startHRU; - -// public: -// HRUMonitor() {}; -// ~HRUMonitor() {}; - -// /** -// * @brief Initalize HRU and add it to the hruList -// * -// * @param self The parent HRU initalizing the HRU -// * @param fileManager The location of the file with the SUMMA settings -// * @param dt_init_start_factor The factor for the timestep length -// * @param maxRunAttempts The max number of run attempts before we consider the hru failed -// */ -// void initalizeHRU(caf::actor* self, std::string fileManager, int dt_init_start_factor, int maxRunAttempts) { -// int startHRU = this->hruList.size() + this->startHRU; -// int indexHRU = this->hruList.size() + 1; // Fortran reference starts at 1 -// auto hru = self->spawn(hru_actor, startHRU, indexHRU, fileManager, self); -// HRUinfo infoHRU = HRUinfo(startHRU, indexHRU, hru, dt_init_start_factor, maxRunAttempts); -// this->hruList.push_back(infoHRU); -// } - -// int getNewStartHRU() - -// bool isAllHRUInitialized() { -// return this->hruList.size() == this->numHRU; -// } - - -// }; - - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/JobActorConnect.h b/build/source/testing/Extras/JobActorConnect.h deleted file mode 100644 index 2710383..0000000 --- a/build/source/testing/Extras/JobActorConnect.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef JOBACTORCONNECT_H_ -#define JOBACTORCONNECT_H_ - - - - - - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/globalFunctions.h b/build/source/testing/Extras/globalFunctions.h deleted file mode 100644 index bde760a..0000000 --- a/build/source/testing/Extras/globalFunctions.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef GLOBALFUNCTIONS_H_ -#define GLOBALFUNCTIONS_H_ - - -#include <chrono> -#include <unistd.h> -#include <ios> -#include <iostream> -#include <fstream> -#include <string> - - -/* This is a function that checks if this actor -* should send a message to its parent letting it know it -* is still running. -* timeSinceCheckIn = the last time that we sent a message to our parent -* maxCheckInDuration = The max amount of time in minutes we can go without -* checking in with our parent -*/ -bool isCheckInTime(std::chrono::time_point<std::chrono::system_clock> timeSinceCheckIn, - int maxCheckInDuration) { - - return (std::chrono::duration_cast<std::chrono::minutes> - (std::chrono::high_resolution_clock::now() - timeSinceCheckIn).count() > maxCheckInDuration); - -} - -void process_mem_usage(double& vm_usage, double& resident_set) -{ - using std::ios_base; - using std::ifstream; - using std::string; - - vm_usage = 0.0; - resident_set = 0.0; - - // 'file' stat seems to give the most reliable results - // - ifstream stat_stream("/proc/self/stat",ios_base::in); - - // dummy vars for leading entries in stat that we don't care about - // - string pid, comm, state, ppid, pgrp, session, tty_nr; - string tpgid, flags, minflt, cminflt, majflt, cmajflt; - string utime, stime, cutime, cstime, priority, nice; - string O, itrealvalue, starttime; - - // the two fields we want - // - unsigned long vsize; - long rss; - - stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr - >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt - >> utime >> stime >> cutime >> cstime >> priority >> nice - >> O >> itrealvalue >> starttime >> vsize >> rss; // don't care about the rest - - stat_stream.close(); - - long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages - vm_usage = vsize / 1024.0; - resident_set = rss * page_size_kb; -} - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/server/ClientManager.h b/build/source/testing/Extras/server/ClientManager.h deleted file mode 100644 index c5e0ae8..0000000 --- a/build/source/testing/Extras/server/ClientManager.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef ClientManager_H_ -#define ClientManager_H_ - -// #include "caf/all.h" -#include <vector> -#include "ClientReference.h" - - -class ClientManager { - private: - - int id_counter; // value just increases when new client connects - int num_clients; - - public: - ClientManager(caf::actor server) { - // First value in client list is always the server - // The server will always be value 0 - this->id_counter = 0; - this->num_clients = 0; - ClientReference *serverReference = new ClientReference(id_counter, server); - this->clientList.push_back(serverReference); - this->id_counter++; - } - - void addClient(caf::actor client) { - ClientReference *ref = new ClientReference(id_counter, client); - this->clientList.push_back(ref); - this->id_counter++; - this->num_clients++; - } - - - - - - - // ~ClientManager() { - // delete[] clientList; - // } -}; - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/server/ClientReference.h b/build/source/testing/Extras/server/ClientReference.h deleted file mode 100644 index 8d4e5c9..0000000 --- a/build/source/testing/Extras/server/ClientReference.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef ClientReference_H_ -#define ClientReference_H_ - -// #include "caf/all.h" -#include <chrono> -#include <vector> - -class ClientReference { - private: - int ID; // Will be the same as index in array - caf::actor client; - int currentGRU; - std::chrono::time_point<std::chrono::system_clock> lastSeen; - std::vector<int> GRUsCompleted; - bool isConnected; - - public: - ClientReference(int ID, caf::actor client) { - this->ID = ID; - this->client = client; - this->lastSeen = std::chrono::high_resolution_clock::now(); - this->isConnected = true; - this->currentGRU = 0; - } - - void gruCompleted() { - this->GRUsCompleted.push_back(this->currentGRU); - this->currentGRU = 0; - } - - void updateCurrentGRU(int newCurrentGRU) { - this->currentGRU = newCurrentGRU; - } - - bool isClientConnected() { - return this->isConnected; - } - - void disconnectClient() { - this->isConnected = false; - } - - void updateLastSeen() { - this->lastSeen = std::chrono::high_resolution_clock::now(); - } - - std::chrono::time_point<std::chrono::system_clock> getLastSeen() { - return this->lastSeen; - } - - int getCurrentGRU() { - return this->currentGRU; - } - - - - - - // ~ClientReference() { - // delete[] GRUsCompleted; - // } - - -}; - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/server/GRUInfo.h b/build/source/testing/Extras/server/GRUInfo.h deleted file mode 100644 index b1cc3f1..0000000 --- a/build/source/testing/Extras/server/GRUInfo.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef GRUInfo_H_ -#define GRUInfo_H_ - - -#include "caf/all.hpp" -#include "../messageAtoms.h" - -#define max_failures 3 - - -enum State {Ready, Running, Done, Fail}; -/** -* Information about the GRU and its status {Ready, Running, Done, Fail}, as well as other useful information -* that may be needed -**/ -class GRUInfo { - private: - int refGRU; // The GRUID of the Gru being solved - State state; // State this HRU is currently in - caf::actor client; // Client Actor in Charge of GRU solvers - int duration; // in seconds - int initDuration; // in seconds - int forcingDuration; // in seconds - int runPhysicsDuration; // in seconds - int writeOutputDuration; // in seconds - int numFailures; - - - public: - GRUInfo(int refGRU) { - this->refGRU = refGRU; - this->state = Ready; - this->numFailures = 0; - }; - - /** - * Method Called when GRU is finished - **/ - void GRU_Done(int duration, int initDuration, int forcingDuration, - int runPhysicsDuration, int writeOutputDuration) { - - // Update Timing Information for GRU - this->duration = duration; - this->initDuration = forcingDuration; - this->forcingDuration = forcingDuration; - this->runPhysicsDuration = runPhysicsDuration; - this->writeOutputDuration = writeOutputDuration; - // Update the state of the GRU - this->state = Done; - }; - - // Checks to see if we hit the failure threshold - int GRU_Start(caf::actor client) { - this->client = client; - if(this->numFailures == max_failures) { - return -1; - } - return 0; - }; - - void GRU_Fail() { - this->numFailures++; - }; - - int getRefGRU() { - return this->refGRU; - }; - -}; - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/server/GRUStruc.h b/build/source/testing/Extras/server/GRUStruc.h deleted file mode 100644 index 3c4e4d9..0000000 --- a/build/source/testing/Extras/server/GRUStruc.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef GRUStruc_H_ -#define GRUStruc_H_ - -#include "caf/all.hpp" -#include "vector" -#include "GRUInfo.h" - - -/** -* GRUStruc is an object that helps the coordinator keep track -* of which GRUs need to run, have been completed, and or have -* failed. -**/ -class GRUStruc { - private: - std::vector<GRUInfo> GRUs_to_compute; - std::vector<GRUInfo> GRUs_completed; - std::vector<GRUInfo> GRUs_failed; - int passed; - int failed; - int Left_to_compute; - - public: - GRUStruc(int startGRU, int numGRUs) { - for(int i = 0; i <= numGRUs; i++) { - // put a start object in so refGRU = index in vector - if (i == 0) { - auto gru = GRUInfo(i); - GRUs_to_compute.push_back(gru); - } else { - auto gru = GRUInfo(startGRU + i -1); - GRUs_to_compute.push_back(gru); - } - } - } - - void print_struc(int numGRUs) { - for (int i = 0; i <= numGRUs; i++) { - std::cout << "GRUInfo::" << GRUs_to_compute[i].getRefGRU() << std::endl; - } - } - - void addGRU(GRUInfo gru) { - this->GRUs_to_compute.push_back(gru); - } - - void GRUComplete(int refGRU) { - - } - -}; -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/server/SummaCoordinator.h b/build/source/testing/Extras/server/SummaCoordinator.h deleted file mode 100644 index e7286c3..0000000 --- a/build/source/testing/Extras/server/SummaCoordinator.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef SUMMACOORDINATOR_H_ -#define SUMMACOORDINATOR_H_ - -#include "caf/all.hpp" -#include "caf/io/all.hpp" -#include "GRUInfo.h" -#include "GRUStruc.h" -#include "ClientReference.h" -#include "string.h" -#include <unistd.h> -#include <iostream> -#include <fstream> -#include <list> -#include <chrono> -#include <vector> - -using namespace caf; -void checkIfDisconnected(std::vector<ClientReference*> &clientList, std::vector<int*> &GRUsToRepeat, -std::chrono::time_point<std::chrono::system_clock> lastConnectedCheck); - - -struct summa_coordinator_state { - int indxCounter; - int numGRUs; - int numGRUsLeftToCompute; - int startGRU; - int counter; - int numClientsConnected; - - int numSuccess; - int numFailed; - - // ClientManager *clientManager; - std::vector<ClientReference*> clientList; - int clientIdCounter; - - std::list<caf::actor> clients; - std::list<int> passed; - std::vector<int> failed; - std::vector<int> GRUsToRepeat; - std::chrono::time_point<std::chrono::system_clock> start; - std::chrono::time_point<std::chrono::system_clock> end; - double duration; - GRUStruc *gru_struc; - - std::chrono::time_point<std::chrono::system_clock> lastConnectedCheck; - -}; - - -#endif \ No newline at end of file diff --git a/build/source/testing/Extras/server/SummaCoordinatorActor.h b/build/source/testing/Extras/server/SummaCoordinatorActor.h deleted file mode 100644 index 92cb812..0000000 --- a/build/source/testing/Extras/server/SummaCoordinatorActor.h +++ /dev/null @@ -1,221 +0,0 @@ - -#ifndef SUMMACOORDINATORACTOR_H_ -#define SUMMACOORDINATORACTOR_H_ - -#include "SummaCoordinator.h" -#include "GRUInfo.h" -#include "../globalFunctions.h" -#include "../messageAtoms.h" -#include <iostream> -#include <fstream> -#include <algorithm> -#include <chrono> - -using namespace caf; - -#define maxCheckInTimeCoordinator 30 // 30 minutes - - -/* -* Function to check if client has not checked in for a while -* If not assume the client has unexpectedly disconnected -* ClientList = List of clients to check if they are connected -*/ -void checkIfDisconnected(std::vector<ClientReference*> &clientList, std::vector<int> &GRUsToRepeat, - std::chrono::time_point<std::chrono::system_clock> &lastConnectedCheck) { - // Check to see if any clients can be assumed to be disconnected - if (isCheckInTime(lastConnectedCheck, maxCheckInTimeCoordinator)) { - std::cout << "Checking if any clients are disconnected \n"; - // TRUE: We check to see if we have any nodes we have not - // heard from in a while - // for (int i = 1; i < clientList.size(); i++) { - //for (auto iterator = clientList->begin(); iterator != clientList->end(); ++iterator) { - // if (clientList[i]->isClientConnected()) { - // std::chrono::time_point<std::chrono::system_clock> lastSeen = clientList[i]->getLastSeen(); - - // if (std::chrono::duration_cast<std::chrono::minutes> - // (std::chrono::high_resolution_clock::now() - lastSeen).count() > maxCheckInTimeCoordinator) { - // // We Assume this client has been lost - // clientList[i]->disconnectClient(); - // int gru = clientList[i]->getCurrentGRU(); - // GRUsToRepeat.push_back(gru); - // std::cout << "Client with ID = " << i << " Has Unexpectedly Disconnected \n"; - // std::cout << "GRU:" << gru << " Getting moved to the retry list \n"; - // std::cout << GRUsToRepeat.size() << "\n"; - // lastConnectedCheck = std::chrono::high_resolution_clock::now(); - - // } - // } - // } - } -} - -behavior summa_coordinator_actor(stateful_actor<summa_coordinator_state>* self, int indxStartGRU, int numGRUs) { - /********************************************************************************************************* - ******************************** ACTOR INITIALIZATION *************************************************** - *********************************************************************************************************/ - self->state.indxCounter = indxStartGRU; - self->state.startGRU = indxStartGRU; - self->state.numGRUs = numGRUs; - self->state.numGRUsLeftToCompute = numGRUs; // A counter of the number of remaining GRUs left - aout(self) << self->state.numGRUsLeftToCompute << std::endl; - self->state.numClientsConnected = 0; - self->state.numSuccess = 0; - self->state.numFailed = 0; - self->state.start = std::chrono::high_resolution_clock::now(); - self->state.lastConnectedCheck = std::chrono::high_resolution_clock::now(); - - // add ourselves to be at reference 0 - self->state.clientIdCounter = 0; - ClientReference *serverReference = new ClientReference(self->state.clientIdCounter, self); - self->state.clientList.push_back(serverReference); - self->state.clientIdCounter++; - - /********************************************************************************************************* - ************************************ END ACTOR INITIALIZATION ******************************************* - *********************************************************************************************************/ - - - - /********************************************************************************************************* - *********************************** ACTOR MESSAGE HANDLERS ********************************************** - *********************************************************************************************************/ - return { - /* - * Client Initialization - * client = client actor attempting to connect - */ - [=](connect_to_coordinator, actor client, int id) { - if (self->state.numGRUsLeftToCompute <= 0) { - aout(self) << "No GRUs left to compute. Telling Client to exit" << "\n"; - self->send(client, time_to_exit_v); - } else { - // This is the first time we are seing this client - // Add client to our list - ClientReference *ref = new ClientReference(self->state.clientIdCounter, client); - self->state.clientList.push_back(ref); - - aout(self) << "New Client Connected, This is client ID =" << self->state.clientIdCounter << "\n"; - ref->updateCurrentGRU(self->state.indxCounter); - // Send the Client the GRU - self->send(client, self->state.indxCounter); - - self->state.clientIdCounter++; - self->state.indxCounter++; - self->state.numClientsConnected++; - } - }, - /* - * A Client has Requested a GRU to Compute - * request_gru = message atom - * client = the actor address of the client requesting the GRU - * id = id of the client (faster array lookup) - */ - [=](request_gru, actor client, int clientID) { - self->state.clientList[clientID]->updateLastSeen(); - - checkIfDisconnected(self->state.clientList, self->state.GRUsToRepeat, - self->state.lastConnectedCheck); - aout(self) << self->state.lastConnectedCheck << "\n"; - - - // Check if we have any more GRUs to compute - if (self->state.numGRUsLeftToCompute <= 0 && self->state.GRUsToRepeat.empty()) { - /* - * If No GRUs left to Compute: Set Client status to unconnected - */ - if(self->state.clientList[clientID]->isClientConnected()) { - self->state.clientList[clientID]->disconnectClient(); - aout(self) << "Telling Client To Exit" << std::endl; - self->send(client, time_to_exit_v); - self->state.numClientsConnected--; - } - - /* - * If there are no clients left to disconnect. We can disconnect - */ - if (self->state.numClientsConnected == 0) { - aout(self) << "EXITING" << std::endl; - self->state.end = std::chrono::high_resolution_clock::now(); - self->state.duration = std::chrono::duration_cast<std::chrono::seconds> - (self->state.end - self->state.start).count(); - - aout(self) << "TIME RAN: " << self->state.duration << std::endl; - self->quit(); - return; - } - } else { - /* - * Else: There are still GRUs left to compute. - */ - // check that this client is connected - if (self->state.clientList[clientID]->isClientConnected()) { - aout(self) << "Size of GRUsToRepeat = " << self->state.GRUsToRepeat.size() << "\n"; - // First check if we have any GRUs to repeat - if (self->state.GRUsToRepeat.empty()) { - aout(self) << "Sending " << self->state.indxCounter << std::endl; - self->state.clientList[clientID]->updateCurrentGRU(self->state.indxCounter); - self->send(client, self->state.indxCounter); - self->state.indxCounter++; - } else { - int gru = self->state.GRUsToRepeat.back(); - aout(self) << "Sending an Uncompleted GRU:" << gru << "\n"; - self->state.clientList[clientID]->updateCurrentGRU(gru); - self->send(client, gru); - self->state.GRUsToRepeat.pop_back(); - } - } else { - aout(self) << "ERROR: Client with ID = " << clientID << "is disconnected for an unknown reason" << "\n"; - } - } - - }, - - [=](check_in, int clientID) { - self->state.clientList[clientID]->updateLastSeen(); - aout(self) << "Client with ID = " << clientID << "Just chekced in \n"; - }, - - [=](done_hru, int clientID, int refGRU, double totalDuration, double initDuration, - double forcingDuration, double runPhysicsDuration, double writeOutputDuration) { - - aout(self) << "HRU DONE:" << refGRU << std::endl; - self->state.numSuccess++; - self->state.clientList[clientID]->gruCompleted(); - self->state.clientList[clientID]->updateLastSeen(); - - checkIfDisconnected(self->state.clientList, self->state.GRUsToRepeat, - self->state.lastConnectedCheck); - //TODO: Add Gaurd that checks to see if the file exists, Ideally it should be moved after completion of a run - // Write the output to a file - std::ofstream timingInfo; - timingInfo.open("Successful.csv", std::ios_base::app); - timingInfo << refGRU << "," << totalDuration << "," << initDuration << "," << - forcingDuration << "," << runPhysicsDuration << "," << writeOutputDuration << "\n"; - timingInfo.close(); - self->state.numGRUsLeftToCompute--; - aout(self) << "Passed = " << self->state.numSuccess << "\n"; - aout(self) << "Failed = " << self->state.numFailed << "\n"; - aout(self) << self->state.numGRUsLeftToCompute << " hrus left" << std::endl; - }, - - [=](run_failure, int refGRU, int timestep) { - self->state.numFailed++; - std::ofstream timingInfo; - timingInfo.open("Failures.csv", std::ios_base::app); - timingInfo << refGRU << "," << timestep << "\n"; - aout(self) << "Passed = " << self->state.numSuccess << "\n"; - aout(self) << "Failed = " << self->state.numFailed << "\n"; - aout(self) << self->state.numGRUsLeftToCompute << " hrus left" << std::endl; - self->state.numGRUsLeftToCompute--; - }, - }; -} - - - - - - - -#endif \ No newline at end of file diff --git a/build/source/testing/Test/HRUTest.h b/build/source/testing/Test/HRUTest.h deleted file mode 100644 index e30de4e..0000000 --- a/build/source/testing/Test/HRUTest.h +++ /dev/null @@ -1,257 +0,0 @@ -#ifndef HRUTEST_H_ -#define HRUTEST_H_ - -#include "caf/all.hpp" -#include "/home/k13nk/SummaProject/Summa-Actors/build/source/interface/fortran_dataTypes.h" -#include "/home/k13nk/SummaProject/Summa-Actors/build/source/interface/hru_actor/hru_subroutine_wrappers.h" -#include "messageAtoms.h" -#include <fstream> -#include <string> -#include <typeinfo> -#include <stdio.h> -#include <sys/time.h> -#include <sys/resource.h> -#include <chrono> -#include <iostream> -#include "/home/k13nk/SummaProject/Summa-Actors/build/source/actors/global.h" - -using namespace caf; - -struct hru_state { - // Actor References - caf::actor file_access_actor; - caf::actor parent; - - // Info about which HRU we are and our indexes - // into global structures in Fortran - int indxHRU; // index for hru part of derived types in FORTRAN - int indxGRU; // index for gru part of derived types in FORTRAN - int refGRU; // The actual ID of the GRU we are - - // Variables for output/forcing structures - int outputStrucSize; - int outputStep; - int stepsInCurrentFFile; - int forcingFileStep; - int currentForcingFile = 1; - - - // statistics structures - void *handle_forcStat = new_handle_var_dlength(); // model forcing data - void *handle_progStat = new_handle_var_dlength(); // model prognostic (state) variables - void *handle_diagStat = new_handle_var_dlength(); // model diagnostic variables - void *handle_fluxStat = new_handle_var_dlength(); // model fluxes - void *handle_indxStat = new_handle_var_dlength(); // model indices - void *handle_bvarStat = new_handle_var_dlength(); // basin-average variables - // primary data structures (scalars) - void *handle_timeStruct = new_handle_var_i(); // model time data - void *handle_forcStruct = new_handle_var_d(); // model forcing data - void *handle_attrStruct = new_handle_var_d(); // local attributes for each HRU - void *handle_typeStruct = new_handle_var_i(); // local classification of soil veg etc. for each HRU - void *handle_idStruct = new_handle_var_i8(); - // primary data structures (variable length vectors) - void *handle_indxStruct = new_handle_var_ilength(); // model indices - void *handle_mparStruct = new_handle_var_dlength(); // model parameters - void *handle_progStruct = new_handle_var_dlength(); // model prognostic (state) variables - void *handle_diagStruct = new_handle_var_dlength(); // model diagnostic variables - void *handle_fluxStruct = new_handle_var_dlength(); // model fluxes - // basin-average structures - void *handle_bparStruct = new_handle_var_d(); // basin-average parameters - void *handle_bvarStruct = new_handle_var_dlength(); // basin-average variables - // ancillary data structures - void *handle_dparStruct = new_handle_var_d(); // default model parameters - // Local hru data - void *handle_ncid = new_handle_var_i(); // output file ids - void *handle_statCounter = new_handle_var_i(); - void *handle_outputTimeStep = new_handle_var_i(); - void *handle_resetStats = new_handle_flagVec(); - void *handle_finalizeStats = new_handle_flagVec(); - void *handle_oldTime = new_handle_var_i(); - void *handle_refTime = new_handle_var_i(); - void *handle_finshTime = new_handle_var_i(); - void *handle_startTime = new_handle_var_i(); - // Misc Variables - int timestep = 1; // Current Timestep of HRU simulation - int computeVegFlux; // flag to indicate if we are computing fluxes over vegetation - double dt_init; // used to initialize the length of the sub-step for each HRU - double upArea; // area upslope of each HRU - int num_steps = 0; // number of time steps - int forcingStep; // index of current time step in current forcing file - int iFile; // index of current forcing file from forcing file list - int dt_init_factor = 1; // factor of dt_init (coupled_em) - bool printOutput; - int outputFrequency; - - - // Julian Day variables - double fracJulDay; - double tmZoneOffsetFracDay; - int yearLength; - int err = 0; // error conotrol - - std::chrono::time_point<std::chrono::system_clock> start; - std::chrono::time_point<std::chrono::system_clock> end; - double duration = 0.0; - std::chrono::time_point<std::chrono::system_clock> initStart; - std::chrono::time_point<std::chrono::system_clock> initEnd; - double initDuration = 0.0; - std::chrono::time_point<std::chrono::system_clock> forcingStart; - std::chrono::time_point<std::chrono::system_clock> forcingEnd; - double forcingDuration = 0.0; - std::chrono::time_point<std::chrono::system_clock> runPhysicsStart; - std::chrono::time_point<std::chrono::system_clock> runPhysicsEnd; - double runPhysicsDuration = 0.0; - std::chrono::time_point<std::chrono::system_clock> writeOutputStart; - std::chrono::time_point<std::chrono::system_clock> writeOutputEnd; - double writeOutputDuration = 0.0; - -}; - -/** - * @brief Get the settings from the settings JSON file - * - * @param self Actor 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 - */ -int Run_HRU(stateful_actor<hru_state>* self); - -bool check_HRU(stateful_actor<hru_state>* self, int err); - -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); - - - -/** - * @brief HRU Actor is reponsible for carrying out the computation component of SUMMA - * - * @param self The Actor Ref - * @param refGRU The GRU we are computing in reference to the forcingFile - * @param indxGRU The GRU we are computing's index in gru_struc - * @param parent - * @return behavior - */ -behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, - std::string configPath, - int outputStrucSize, caf::actor parent) { - // Timing Information - self->state.start = std::chrono::high_resolution_clock::now(); - self->state.duration = 0.0; - self->state.initDuration = 0.0; - - // Actor References - self->state.parent = parent; - - // Indexes into global structures - self->state.indxHRU = 1; - 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 - self->state.forcingStep = 1; // Index into the forcing file - self->state.iFile = 1; - - Initialize_HRU(self); - - DeallocateStructures(self->state.handle_forcStat, - self->state.handle_progStat, - self->state.handle_diagStat, - self->state.handle_fluxStat, - self->state.handle_indxStat, - self->state.handle_bvarStat, - self->state.handle_timeStruct, - self->state.handle_forcStruct, - self->state.handle_attrStruct, - self->state.handle_typeStruct, - self->state.handle_idStruct, - self->state.handle_indxStruct, - self->state.handle_mparStruct, - self->state.handle_progStruct, - self->state.handle_diagStruct, - self->state.handle_fluxStruct, - self->state.handle_bparStruct, - self->state.handle_bvarStruct, - self->state.handle_dparStruct, - self->state.handle_startTime, - self->state.handle_finshTime, - self->state.handle_refTime, - self->state.handle_oldTime, - self->state.handle_ncid, - self->state.handle_statCounter, - self->state.handle_outputTimeStep, - self->state.handle_resetStats, - self->state.handle_finalizeStats, - &self->state.err); - - self->state.end = std::chrono::high_resolution_clock::now(); - self->state.duration += calculateTime(self->state.start, self->state.end); - - self->send(self->state.parent, done_init_hru_v); - - return { - }; - /********************************************************************************************************* - *********************************** END ACTOR MESSAGE HANDLERS ****************************************** - *********************************************************************************************************/ -} - -void Initialize_HRU(stateful_actor<hru_state>* self) { - self->state.initStart = std::chrono::high_resolution_clock::now(); - // aout(self) << "Initalizing HRU" << std::endl; - aout(self) << "Entering Initalize \n"; - Initialize(&self->state.indxGRU, - &self->state.num_steps, - self->state.handle_forcStat, - self->state.handle_progStat, - self->state.handle_diagStat, - self->state.handle_fluxStat, - self->state.handle_indxStat, - self->state.handle_bvarStat, - self->state.handle_timeStruct, - self->state.handle_forcStruct, - self->state.handle_attrStruct, - self->state.handle_typeStruct, - self->state.handle_idStruct, - self->state.handle_indxStruct, - self->state.handle_mparStruct, - self->state.handle_progStruct, - self->state.handle_diagStruct, - self->state.handle_fluxStruct, - self->state.handle_bparStruct, - self->state.handle_bvarStruct, - self->state.handle_dparStruct, - self->state.handle_startTime, - self->state.handle_finshTime, - self->state.handle_refTime, - self->state.handle_oldTime, &self->state.err); - - if (self->state.err != 0) { - aout(self) << "Error: Initialize - HRU = " << self->state.indxHRU << - " - indxGRU = " << self->state.indxGRU << " - refGRU = "<< self->state.refGRU << std::endl; - aout(self) << "Error = " << self->state.err << "\n"; - self->quit(); - return; - } - -} -#endif \ No newline at end of file diff --git a/build/source/testing/Test/JobTest.h b/build/source/testing/Test/JobTest.h deleted file mode 100644 index 2630777..0000000 --- a/build/source/testing/Test/JobTest.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef JOBTEST_H_ -#define JOBTEST_H_ - -#include "caf/all.hpp" -#include "caf/io/all.hpp" -#include "string.h" -#include <unistd.h> -#include <vector> -#include "/home/k13nk/SummaProject/Summa-Actors/build/source/interface/job_actor/job_subroutine_wrappers.h" -#include "HRUTest.h" -#include <chrono> -#include "messageAtoms.h" -#include <iostream> -#include <fstream> -#include <sys/stat.h> -#include "/home/k13nk/SummaProject/Summa-Actors/build/source/actors/global.h" - -struct job_state { - // Actor References - caf::actor parent; // actor reference to the top-level SummaActor - - // Job Parameters - int startGRU; // Starting GRU for this job - int numGRU; // Number of GRUs for this job - std::string configPath; - - std::string fileManager; // Path of the fileManager.txt file - - // Variables for GRU monitoring - int dt_init_start_factor = 1; // Initial Factor for dt_init (coupled_em) - int maxRunAttempts = 3; // Max number of attemtps to solve a GRU - int numGRUDone = 0; // The number of GRUs that have completed - int GRUInit = 0; // Number of GRUs initalized - int err = 0; // Error Code - int numGRUFailed = 0; // Number of GRUs that have failed - int outputStrucSize; - - // Timing Variables - std::chrono::time_point<std::chrono::system_clock> start; - std::chrono::time_point<std::chrono::system_clock> end; - double duration; - - // Output File Names for Timings - bool outputCSV; - std::string csvOut; - std::string csvPath; - std::string successOutputFile; - std::string failedOutputFile = "failedHRU"; - std::string fileAccessActorStats = "fileAccessActor.csv"; - -}; - -int parseSettings(stateful_actor<job_state>* self, std::string configPath); - -void initJob(stateful_actor<job_state>* self); - -void initalizeGRU(stateful_actor<job_state>* self); - -void runGRUs(stateful_actor<job_state>* self); - -void restartFailures(stateful_actor<job_state>* self); - -behavior job_actor(stateful_actor<job_state>* self) { - self->state.start = std::chrono::high_resolution_clock::now(); - // Set Job Variables - self->state.startGRU = 1; - self->state.numGRU = 500; - self->state.configPath = "/home/k13nk/SummaProject/Summa-Actors/config"; - self->state.outputStrucSize = 100; - self->state.fileManager = "/home/k13nk/SummaProject/SummaActorsSettings/fileManager.txt"; - - // Initalize global variables - initJob(self); - - // // spawn HRU test actor - auto gru = self->spawn(hru_actor, 1, 1, - self->state.configPath, - self->state.outputStrucSize, self); - - - return { - - [=](done_init_hru) { - // Dealocate the structure - aout(self) << "Received done from HRU\n"; - int err = 0; - cleanUpJobActor(&err); - } - }; - -} - -void initJob(stateful_actor<job_state>* self) { - std::string success = "Success"; // allows us to build the string - - int totalGRUs = 0; - int totalHRUs = 0; - int numHRUs = 0; - int err = 0; - - // aout(self) << "Initalizing Globals \n"; - initGlobals(self->state.fileManager.c_str(), - &totalGRUs, - &totalHRUs, - &self->state.numGRU, - &numHRUs, - &self->state.startGRU, - &err); - if (err != 0) { - aout(self) << "Error: initGlobals" << std::endl; - self->quit(); - } -} - - - -#endif \ No newline at end of file diff --git a/build/source/testing/Test/makefile b/build/source/testing/Test/makefile deleted file mode 100644 index e5a7eab..0000000 --- a/build/source/testing/Test/makefile +++ /dev/null @@ -1,281 +0,0 @@ -F_MASTER = /home/k13nk/SummaProject/Summa-Actors - -FC = gfortran -CC = g++ - -INCLUDES = -I/usr/include -LIBRARIES = -lnetcdff -lnetcdf -lopenblas - -ACTORS_INCLUDES = -I/home/k13nk/actorLib/include -ACTORS_LIBRARIES = -L/home/k13nk/actorLib/lib \ --L/home/k13nk/SummaProject/Summa-Actors/build/source/testing/Test/ \ --lcaf_core -lcaf_io -lsumma -lnetcdff -lopenblas - -# # Debug runs -FLAGS_NOAH = -p -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument -fPIC -FLAGS_COMM = -p -g -O0 -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds -fPIC -FLAGS_SUMMA = -p -g -O0 -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds -fPIC -FLAGS_ACTORS = -g -O0 -Wall - -#======================================================================== -# PART 1: Define directory paths -#======================================================================== - -# Core directory that contains source code -F_KORE_DIR = $(F_MASTER)/build/source - -# Location of the compiled modules -MOD_PATH = $(F_MASTER)/build - -# Define the directory for the executables -EXE_PATH = $(F_MASTER)/bin - -# Define directories -DRIVER_DIR = $(F_KORE_DIR)/driver -HOOKUP_DIR = $(F_KORE_DIR)/hookup -NETCDF_DIR = $(F_KORE_DIR)/netcdf -DSHARE_DIR = $(F_KORE_DIR)/dshare -NUMREC_DIR = $(F_KORE_DIR)/numrec -NOAHMP_DIR = $(F_KORE_DIR)/noah-mp -ENGINE_DIR = $(F_KORE_DIR)/engine -INTERFACE_DIR = $(F_KORE_DIR)/interface -JOB_ACTOR_DIR = $(INTERFACE_DIR)/job_actor -FILE_ACCESS_DIR = $(INTERFACE_DIR)/file_access_actor -HRU_ACTOR_DIR = $(INTERFACE_DIR)/hru_actor - -# utilities -SUMMA_NRUTIL= \ - nrtype.f90 \ - f2008funcs.f90 \ - nr_utility.f90 -NRUTIL = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_NRUTIL)) - -# Numerical recipes procedures -# NOTE: all numerical recipes procedures are now replaced with free versions -SUMMA_NRPROC= \ - expIntegral.f90 \ - spline_int.f90 -NRPROC = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_NRPROC)) - -# Hook-up modules (set files and directory paths) -SUMMA_HOOKUP= \ - ascii_util.f90 \ - summaActors_FileManager.f90 -HOOKUP = $(patsubst %, $(HOOKUP_DIR)/%, $(SUMMA_HOOKUP)) - -# Data modules -SUMMA_DATAMS= \ - multiconst.f90 \ - var_lookup.f90 \ - data_types.f90 \ - globalData.f90 \ - flxMapping.f90 \ - get_ixname.f90 \ - popMetadat.f90 \ - outpt_stat.f90 -DATAMS = $(patsubst %, $(DSHARE_DIR)/%, $(SUMMA_DATAMS)) - -# utility modules -SUMMA_UTILMS= \ - time_utils.f90 \ - mDecisions.f90 \ - snow_utils.f90 \ - soil_utils.f90 \ - updatState.f90 \ - matrixOper.f90 -UTILMS = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_UTILMS)) - -# Model guts -SUMMA_MODGUT= \ - MODGUT = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_MODGUT)) - -# Solver -SUMMA_SOLVER= \ - vegPhenlgy.f90 \ - diagn_evar.f90 \ - stomResist.f90 \ - groundwatr.f90 \ - vegSWavRad.f90 \ - vegNrgFlux.f90 \ - ssdNrgFlux.f90 \ - vegLiqFlux.f90 \ - snowLiqFlx.f90 \ - soilLiqFlx.f90 \ - bigAquifer.f90 \ - computFlux.f90 \ - computResid.f90 \ - computJacob.f90 \ - eval8summa.f90 \ - summaSolve.f90 \ - systemSolv.f90 \ - varSubstep.f90 \ - opSplittin.f90 \ - coupled_em.f90 - -SOLVER = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_SOLVER)) - -# Interface code for Fortran-C++ -SUMMA_INTERFACE= \ - cppwrap_datatypes.f90 \ - cppwrap_auxiliary.f90 \ - cppwrap_metadata.f90 \ - -INTERFACE = $(patsubst %, $(INTERFACE_DIR)/%, $(SUMMA_INTERFACE)) - -SUMMA_FILEACCESS_INTERFACE = \ - initOutputStruc.f90 \ - deallocateOutputStruc.f90 \ - cppwrap_fileAccess.f90 - -FILEACCESS_INTERFACE = $(patsubst %, $(FILE_ACCESS_DIR)/%, $(SUMMA_FILEACCESS_INTERFACE)) - -SUMMA_JOB_INTERFACE = \ - cppwrap_job.f90 - -JOB_INTERFACE = $(patsubst %, $(JOB_ACTOR_DIR)/%, $(SUMMA_JOB_INTERFACE)) - -SUMMA_HRU_INTERFACE = \ - cppwrap_hru.f90 - -HRU_INTERFACE = $(patsubst %, $(HRU_ACTOR_DIR)/%, $(SUMMA_HRU_INTERFACE)) - - -# Define routines for SUMMA preliminaries -SUMMA_PRELIM= \ - conv_funcs.f90 \ - sunGeomtry.f90 \ - convE2Temp.f90 \ - allocspaceActors.f90 \ - alloc_file_access.f90\ - checkStruc.f90 \ - childStruc.f90 \ - ffile_info.f90 \ - read_attribute.f90 \ - read_pinit.f90 \ - pOverwrite.f90 \ - read_paramActors.f90 \ - paramCheck.f90 \ - check_icondActors.f90 \ - # allocspace.f90 -PRELIM = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_PRELIM)) - -SUMMA_NOAHMP= \ - module_model_constants.F \ - module_sf_noahutl.F \ - module_sf_noahlsm.F \ - module_sf_noahmplsm.F - -NOAHMP = $(patsubst %, $(NOAHMP_DIR)/%, $(SUMMA_NOAHMP)) - -# Define routines for the SUMMA model runs -SUMMA_MODRUN = \ - indexState.f90 \ - getVectorz.f90 \ - updateVars.f90 \ - var_derive.f90 \ - read_forcingActors.f90 \ - access_forcing.f90\ - access_write.f90 \ - derivforce.f90 \ - snowAlbedo.f90 \ - canopySnow.f90 \ - tempAdjust.f90 \ - snwCompact.f90 \ - layerMerge.f90 \ - layerDivide.f90 \ - volicePack.f90 \ - qTimeDelay.f90 -MODRUN = $(patsubst %, $(ENGINE_DIR)/%, $(SUMMA_MODRUN)) - -# Define NetCDF routines -# OutputStrucWrite is not a netcdf subroutine and should be -# moved -SUMMA_NETCDF = \ - netcdf_util.f90 \ - def_output.f90 \ - outputStrucWrite.f90 \ - writeOutput.f90 \ - read_icondActors.f90 -NETCDF = $(patsubst %, $(NETCDF_DIR)/%, $(SUMMA_NETCDF)) - -# ... stitch together common programs -COMM_ALL = $(NRUTIL) $(NRPROC) $(HOOKUP) $(DATAMS) $(UTILMS) - -# ... stitch together SUMMA programs -SUMMA_ALL = $(NETCDF) $(PRELIM) $(MODRUN) $(SOLVER) - -# Define the driver routine -SUMMA_DRIVER= \ - summaActors_type.f90 \ - summaActors_util.f90 \ - summaActors_globalData.f90 \ - summaActors_init.f90 \ - SummaActors_setup.f90 \ - summaActors_restart.f90 \ - summaActors_forcing.f90 \ - SummaActors_modelRun.f90 \ - summaActors_alarms.f90 \ - summaActors_wOutputStruc.f90 - - -DRIVER = $(patsubst %, $(DRIVER_DIR)/%, $(SUMMA_DRIVER)) - -ACTORC = $(F_KORE_DIR)/testing/Test/testing_main.cc - -ACTOR_TEST = $(F_KORE_DIR)/testing/testing_main.cc - - -#======================================================================== -# PART 3: compilation -#====================================================================== - -# Compile -all: lib main - -lib: compile_noah compile_comm compile_summa link clean - -main: actors actorsLink actorsClean - -test: actors_test actors_testLink actorsClean - -# compile Noah-MP routines -compile_noah: - $(FC) $(FLAGS_NOAH) -c $(NRUTIL) $(NOAHMP) - -# compile common routines -compile_comm: - $(FC) $(FLAGS_COMM) -c $(COMM_ALL) $(INCLUDES) - -# compile SUMMA routines -compile_summa: - $(FC) $(FLAGS_SUMMA) -c $(SUMMA_ALL) $(DRIVER) $(INTERFACE) $(JOB_INTERFACE) $(FILEACCESS_INTERFACE) $(HRU_INTERFACE) $(INCLUDES) - -# generate library -link: - $(FC) -shared *.o -o libsumma.so - -# compile the c++ portion of SummaActors -actors: - $(CC) $(FLAGS_ACTORS) -c $(ACTORC) -std=c++17 $(ACTORS_INCLUDES) - -actorsLink: - $(CC) -o summaMain *.o $(ACTORS_LIBRARIES) - -actors_test: - $(CC) $(FLAGS_ACTORS) -c $(ACTOR_TEST) -std=c++17 $(ACTORS_INCLUDES) - -actors_testLink: - $(CC) -o summaTest *.o $(ACTORS_LIBRARIES) - -actorsClean: - rm *.o -# Remove object files -clean: - rm -f *.o *.mod soil_veg_gen_parm__genmod.f90 - -clean_lib: - rm *.so - - - - diff --git a/build/source/testing/Test/messageAtoms.h b/build/source/testing/Test/messageAtoms.h deleted file mode 100644 index f72dcc9..0000000 --- a/build/source/testing/Test/messageAtoms.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef MESSAGEATOMS_H_ -#define MESSAGEATOMS_H_ - -CAF_BEGIN_TYPE_ID_BLOCK(summaTest, first_custom_type_id) - CAF_ADD_ATOM(summaTest, done_init_hru) -CAF_END_TYPE_ID_BLOCK(summaTest) -#endif diff --git a/build/source/testing/Test/testing_main.cc b/build/source/testing/Test/testing_main.cc deleted file mode 100644 index 81ff3f0..0000000 --- a/build/source/testing/Test/testing_main.cc +++ /dev/null @@ -1,20 +0,0 @@ -#include "caf/all.hpp" -#include "caf/io/all.hpp" -#include "/home/k13nk/SummaProject/Summa-Actors/build/source/testing/Test/JobTest.h" -#include <string> -#include "messageAtoms.h" -#include <bits/stdc++.h> -#include <unistd.h> -#include <iostream> - -using namespace caf; - - -void caf_main(actor_system& sys) { - scoped_actor self{sys}; - - // start SUMMA - auto job = self->spawn(job_actor); -} - -CAF_MAIN(id_block::summaTest) \ No newline at end of file -- GitLab