diff --git a/build/includes/gru_actor/gru_actor.hpp b/build/includes/gru_actor/gru_actor.hpp index 95c257c1a1c0ab1b7680c282e5fa3f5878cc3e9b..fd9a7a6075e8a88267ba49f3d322f933fbc2e45e 100644 --- a/build/includes/gru_actor/gru_actor.hpp +++ b/build/includes/gru_actor/gru_actor.hpp @@ -3,6 +3,7 @@ #include "caf/all.hpp" #include "fortran_data_types.hpp" #include "timing_info.hpp" +#include "global.hpp" #include <vector> #include <array> #include <chrono> @@ -19,11 +20,18 @@ struct gru_state { int ref_gru; // The actual ID of the GRU we are int num_hrus; - int num_bpar_vars; // number of variables in the fortran structure for bpar_struct - int num_bvar_vars; // number of variables in the fortran structure for bvar_struct - int n_time_delay = 2000; // number of timesteps in the time delay historgram. - std::vector<double> bpar_struct; - std::vector<std::vector<double>> bvar_struct; + + + int num_bpar_vars; // number of variables in the fortran structure for bpar_struct + std::vector<double> bpar_struct; + std::vector<int> bpar_struct_var_type_list; // The types to the variable at each element in bpar_struct + + int num_bvar_vars; // number of variables in the fortran structure for bvar_struct + std::vector<std::vector<double>> bvar_struct; + std::vector<int> bvar_struct_var_type_list; + + int num_var_types; + std::vector<int> i_look_var_type_list; // The types to the variable at each element in bvar_struct }; behavior gru_actor(stateful_actor<gru_state>* self, int refGRU, int indxGRU, diff --git a/build/includes/gru_actor/gru_actor_subroutine_wrappers.hpp b/build/includes/gru_actor/gru_actor_subroutine_wrappers.hpp index 61fd5aa29d5fb3ba02cadfe9e248d91bd6fe5bf2..5e103fac8eee002f8b4b9b7e3fa7aa3d32f3c657 100644 --- a/build/includes/gru_actor/gru_actor_subroutine_wrappers.hpp +++ b/build/includes/gru_actor/gru_actor_subroutine_wrappers.hpp @@ -2,6 +2,9 @@ extern "C" { - void getVarSizes(int* num_bpar_vars, int* num_bvar_vars); + void getVarSizes(int* num_var_types, int* num_bpar_vars, int* num_bvar_vars); + + void fillVarTypeLists(int* num_var_types, int* num_bpar_vars, int* num_bvar_vars, void* i_look_var_type_list, + void* bpar_struct_var_type_list, void* bvar_struct_var_type_list); } \ No newline at end of file diff --git a/build/makefile b/build/makefile index 1154336f25231682e01e1b161facb039b64252cc..826cb4b493d0d5d39714bc11e23721a8dd216e34 100644 --- a/build/makefile +++ b/build/makefile @@ -14,16 +14,16 @@ ACTORS_LIBRARIES = -L/usr/lib -L/usr/local/lib -L/Summa-Actors/bin -lcaf_core -l # Production runs -FLAGS_NOAH = -O3 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors -FLAGS_COMM = -O3 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors -FLAGS_SUMMA = -O3 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors -FLAGS_ACTORS = -O3 -Wfatal-errors -std=c++17 +# FLAGS_NOAH = -O3 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors +# FLAGS_COMM = -O3 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors +# FLAGS_SUMMA = -O3 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors +# FLAGS_ACTORS = -O3 -Wfatal-errors -std=c++17 # Debug runs -# FLAGS_NOAH = -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument -fPIC -# FLAGS_COMM = -g -O0 -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds -fPIC -# FLAGS_SUMMA = -g -O0 -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds -fPIC -# FLAGS_ACTORS = -g -O0 -Wall -std=c++17 +FLAGS_NOAH = -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fbacktrace -Wno-unused -Wno-unused-dummy-argument -fPIC +FLAGS_COMM = -g -O0 -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds -fPIC +FLAGS_SUMMA = -g -O0 -Wall -ffree-line-length-none -fmax-errors=0 -fbacktrace -fcheck=bounds -fPIC +FLAGS_ACTORS = -g -O0 -Wall -std=c++17 diff --git a/build/source/actors/global/global.cpp b/build/source/actors/global/global.cpp index dff7bf4d1fb978d6d7b4e9eb15c59f3f2accdbc4..c906fd559dcfc90ea91d391b1e3c2ffe7f6852f3 100644 --- a/build/source/actors/global/global.cpp +++ b/build/source/actors/global/global.cpp @@ -1,6 +1,25 @@ #include "global.hpp" #include <chrono> +struct iLookVarType { + // These values should be one index less than the Fortran structure + // This is so they align with C++ vectors that start at 0 + int scalarv = -9999; + int wLength = -9999; + int midSnow = -9999; + int midSoil = -9999; + int midToto = -9999; + int ifcSnow = -9999; + int ifcSoil = -9999; + int ifcToto = -9999; + int parSoil = -9999; + int routing = -9999; + int outstat = -9999; + int unknown = -9999; +}; + + + double calculateTime(std::chrono::time_point<std::chrono::system_clock> start, std::chrono::time_point<std::chrono::system_clock> end) { diff --git a/build/source/actors/gru_actor/gru_actor.cpp b/build/source/actors/gru_actor/gru_actor.cpp index 19d7c6a8d904be4a6b1c4dbc909a3ab5098f2ae4..23449a18f0eb833ce9e3a8bb5e98fbb6da7d40c7 100644 --- a/build/source/actors/gru_actor/gru_actor.cpp +++ b/build/source/actors/gru_actor/gru_actor.cpp @@ -2,6 +2,7 @@ #include "gru_actor.hpp" #include "global.hpp" #include "message_atoms.hpp" +#include <vector> #include "gru_actor_subroutine_wrappers.hpp" namespace caf { @@ -18,14 +19,38 @@ behavior gru_actor(stateful_actor<gru_state>* self, int refGRU, int indxGRU, // [=](init_gru) { // Get the variable data length, we also need the type information - aout(self) << "init GRU"; + aout(self) << "init GRU \n"; + int integer_missing_value = -9999; - getVarSizes(&self->state.num_bpar_vars, + // Get the sizes we need for the lists from Fortran + getVarSizes(&self->state.num_var_types, + &self->state.num_bpar_vars, &self->state.num_bvar_vars); - + + aout(self) << "GRU: GOT VAR SIZES\n"; + aout(self) << "NUM VAR Type = " << self->state.num_var_types << "\n"; aout(self) << "NUM BPAR = " << self->state.num_bpar_vars << "\n"; aout(self) << "NUM BVAR = " << self->state.num_bvar_vars << "\n"; + for (int i = 0; i < self->state.num_var_types; i++) { + self->state.i_look_var_type_list.push_back(integer_missing_value); + } + for (int i = 0; i < self->state.num_bpar_vars; i++) { + self->state.bpar_struct_var_type_list.push_back(integer_missing_value); + } + for (int i = 0; i < self->state.num_bvar_vars; i++) { + self->state.bvar_struct_var_type_list.push_back(integer_missing_value); + } + + // Fill The lists with the values from the fortran lists + fillVarTypeLists(&self->state.num_var_types, + &self->state.num_bpar_vars, + &self->state.num_bvar_vars, + &self->state.i_look_var_type_list[0], + &self->state.bpar_struct_var_type_list[0], + &self->state.bvar_struct_var_type_list[0]); + + } diff --git a/build/source/actors/gru_actor/gru_actor.f90 b/build/source/actors/gru_actor/gru_actor.f90 index 791cdaa4ae141ed9fc1b9056f3550b51443def48..fe4c0b461f06573c8a439cef9d2ba4542929daf8 100644 --- a/build/source/actors/gru_actor/gru_actor.f90 +++ b/build/source/actors/gru_actor/gru_actor.f90 @@ -2,29 +2,104 @@ !!! If lateral flows exits use the code module gru_actor USE,intrinsic :: iso_c_binding +USE nrtype implicit none ! public::run_gru public::getVarSizes -! public::run_gru_for_timestep() +public::fillvarTypeLists contains -subroutine getVarSizes(num_bpar_vars, & +subroutine getVarSizes(num_var_types, & + num_bpar_vars, & num_bvar_vars) bind(C,name="getVarSizes") - USE var_lookup,only:maxvarBpar, maxvarBvar + USE var_lookup,only:maxvarBpar, maxvarBvar, maxvarVarType implicit none + + integer(c_int), intent(out) :: num_var_types + integer(c_int), intent(out) :: num_bpar_vars + integer(c_int), intent(out) :: num_bvar_vars - integer(c_int), intent(out) :: num_bpar_vars - integer(c_int), intent(out) :: num_bvar_vars - - + num_var_types = maxvarVarType num_bpar_vars = maxvarBpar num_bvar_vars = maxvarBvar end subroutine getVarSizes +subroutine initVarType(num_var_types, & + i_look_var_type_list) bind(C, name="initVarType") + USE var_lookup,only:iLookVarType + implicit none + integer(c_int), intent(in) :: num_var_types + integer(c_int), intent(out), dimension(num_var_types) :: i_look_var_type_list + + i_look_var_type_list(1) = iLookVarType%scalarv + i_look_var_type_list(2) = iLookVarType%wLength + i_look_var_type_list(3) = iLookVarType%midSnow + i_look_var_type_list(4) = iLookVarType%midSoil + i_look_var_type_list(5) = iLookVarType%midToto + i_look_var_type_list(6) = iLookVarType%ifcSnow + i_look_var_type_list(7) = iLookVarType%ifcSoil + i_look_var_type_list(8) = iLookVarType%ifcToto + i_look_var_type_list(9) = iLookVarType%parSoil + i_look_var_type_list(10) = iLookVarType%routing + i_look_var_type_list(11) = iLookVarType%outstat + i_look_var_type_list(12) = iLookVarType%unknown + +end subroutine +subroutine fillVarTypeLists(num_var_types, & + num_bpar_vars, & + num_bvar_vars, & + i_look_var_type_list, & + bpar_struct_var_type_list, & + bvar_struct_var_type_list) bind(C, name="fillVarTypeLists") + + USE globalData,only:type_meta,bpar_meta,bvar_meta + USE var_lookup,only:iLookBVAR,iLookBPAR,iLookVarType + implicit none + integer(c_int), intent(in) :: num_var_types + integer(c_int), intent(in) :: num_bpar_vars + integer(c_int), intent(in) :: num_bvar_vars + integer(c_int), intent(out), dimension(num_var_types) :: i_look_var_type_list + integer(c_int), intent(out), dimension(num_bpar_vars) :: bpar_struct_var_type_list + integer(c_int), intent(out), dimension(num_bvar_vars) :: bvar_struct_var_type_list + + integer(i4b) :: i + + i_look_var_type_list(1) = iLookVarType%scalarv + i_look_var_type_list(2) = iLookVarType%wLength + i_look_var_type_list(3) = iLookVarType%midSnow + i_look_var_type_list(4) = iLookVarType%midSoil + i_look_var_type_list(5) = iLookVarType%midToto + i_look_var_type_list(6) = iLookVarType%ifcSnow + i_look_var_type_list(7) = iLookVarType%ifcSoil + i_look_var_type_list(8) = iLookVarType%ifcToto + i_look_var_type_list(9) = iLookVarType%parSoil + i_look_var_type_list(10) = iLookVarType%routing + i_look_var_type_list(11) = iLookVarType%outstat + i_look_var_type_list(12) = iLookVarType%unknown + + do i = 1, num_var_types + print*, "iLookVarType = ", i_look_var_type_list(i) + end do + + do i = 1, num_bpar_vars + bpar_struct_var_type_list(i) = bpar_meta(i)%varType + end do + + do i = 1, num_bvar_vars + bvar_struct_var_type_list(i) = bvar_meta(i)%varType + end do + + + + + + +end subroutine fillVarTypeLists + ! subroutine run_gru_for_timestep() diff --git a/build/source/actors/job_actor/job_actor.cpp b/build/source/actors/job_actor/job_actor.cpp index 8cbb5a93959e4d746f126073a7f80cfabe29dee7..4d17d170e85e6fc8297ae626ffdf8f0b1cd63e47 100644 --- a/build/source/actors/job_actor/job_actor.cpp +++ b/build/source/actors/job_actor/job_actor.cpp @@ -49,8 +49,8 @@ behavior job_actor(stateful_actor<job_state>* self, int startGRU, int numGRU, // Print Settings aout(self) << "\nSETTINGS FOR JOB_ACTOR\n" << - "File Manager Path = " << self->state.fileManager << "\n" << - "outputCSV = " << self->state.outputCSV << "\n"; + "File Manager Path = " << self->state.fileManager << "\n" << + "outputCSV = " << self->state.outputCSV << "\n"; if (self->state.outputCSV) { aout(self) << "csvPath = " << self->state.csvPath << "\n"; } diff --git a/build/source/actors/job_actor/job_actor.f90 b/build/source/actors/job_actor/job_actor.f90 index 6f30c1a257b675574a58c1eb969ba65cedd69e83..6aad13f1c5f94594d1836cbc268512f106f3d58c 100644 --- a/build/source/actors/job_actor/job_actor.f90 +++ b/build/source/actors/job_actor/job_actor.f90 @@ -1,3 +1,6 @@ module job_actor implicit none -public::init_veg_ \ No newline at end of file + + + +end module \ No newline at end of file diff --git a/build/source/actors/job_actor/job_actor.mod b/build/source/actors/job_actor/job_actor.mod new file mode 100644 index 0000000000000000000000000000000000000000..b366c2ffbdafde27829cd595569503d7d44a7a84 Binary files /dev/null and b/build/source/actors/job_actor/job_actor.mod differ diff --git a/utils/laugh_tests/celia1990/output/runinfo.txt b/utils/laugh_tests/celia1990/output/runinfo.txt index 345b15be47ef3c522e858c498dd07179b80b0e64..0b31f04567175e7e99cbf5ae5b9e8f327807b70f 100644 --- a/utils/laugh_tests/celia1990/output/runinfo.txt +++ b/utils/laugh_tests/celia1990/output/runinfo.txt @@ -1 +1 @@ - Run start time on system: ccyy=2022 - mm=08 - dd=17 - hh=22 - mi=54 - ss=02.427 + Run start time on system: ccyy=2022 - mm=08 - dd=18 - hh=16 - mi=51 - ss=11.619