diff --git a/build/includes/global/auxilary.hpp b/build/includes/global/auxilary.hpp new file mode 100644 index 0000000000000000000000000000000000000000..294940087d54722ff9b9f7953c4ac167d6ec7486 --- /dev/null +++ b/build/includes/global/auxilary.hpp @@ -0,0 +1,14 @@ +#pragma once + + +std::vector<int> get_flagVec(void* handle); +std::vector<int> get_var_i(void* handle); +std::vector<double> get_var_d(void* handle); +std::vector<long int> get_var_i8(void* handle); +std::vector<long int> get_i8length(void* handle); +std::vector<int> get_ilength(void* handle); +std::vector<double> get_dlength(void* handle); +std::vector<std::vector<int> > get_var_flagVec(void* handle); +std::vector<std::vector<int> > get_var_ilength(void* handle); +std::vector<std::vector<long int> > get_var_i8length(void* handle); +std::vector<std::vector<double> > get_var_dlength(void* handle); \ No newline at end of file diff --git a/build/includes/global/message_atoms.hpp b/build/includes/global/message_atoms.hpp index 93f1b8f2e40b472a40095155c3e568ed805e3c86..b82b7faf42ef5afa01c0be58066bcc549f17e50b 100644 --- a/build/includes/global/message_atoms.hpp +++ b/build/includes/global/message_atoms.hpp @@ -42,6 +42,7 @@ CAF_BEGIN_TYPE_ID_BLOCK(summa, first_custom_type_id) CAF_ADD_ATOM(summa, start_hru) CAF_ADD_ATOM(summa, file_information) CAF_ADD_ATOM(summa, dt_init_factor) + CAF_ADD_ATOM(summa, serialize_data) // Client Actor CAF_ADD_ATOM(summa, connect_to_server) CAF_ADD_ATOM(summa, batch) diff --git a/build/includes/hru_actor/hru_actor.hpp b/build/includes/hru_actor/hru_actor.hpp index cb0b7257ebc1748af3cc530fffbc9f2a2fa058bb..f1dc48fbcda8c417f7dc2ad309f640f5b5bcf69a 100644 --- a/build/includes/hru_actor/hru_actor.hpp +++ b/build/includes/hru_actor/hru_actor.hpp @@ -3,6 +3,8 @@ #include "caf/all.hpp" #include "fortran_data_types.hpp" #include "timing_info.hpp" +#include "fortran_data_types.hpp" +#include "auxilary.hpp" #include <chrono> #include <string> diff --git a/build/includes/hru_actor/serialize_data_structure.hpp b/build/includes/hru_actor/serialize_data_structure.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c150069a2c7ef550484c4e77edbe0ceb3bdba840 --- /dev/null +++ b/build/includes/hru_actor/serialize_data_structure.hpp @@ -0,0 +1,32 @@ +#pragma once + +template<typename T> +struct Summa_Variable { + std::vector<T> dat; // needs to be general as each array can have its own type + int var_type; // maps to varType() in Fortran-Side + int var_fortran_index; // maps to the index of the var portion of the summa_variable +}; + +extern "C" { + void getSummaVariableInfo(int* var_type, int* var_fortran_index, void* data_struct); +} + + + + +template <typename T> +std::vector<Summa_Variable<T>> init_summa_variable_vector(int num_variables) { + std::vector<Summa_Variable<T>> summa_variables(num_variables); + + int variable_index = 1; // value to index into the fortran structure of the array + for (Summa_Variable var : summa_variables) { + var.var_fortran_index = variable_index; + getSummaVariableInfo(var.var_type, var.var_fortran_index); + variable_index++; + } + + return summa_variables; +} + + + diff --git a/build/makefile_sundials b/build/makefile_sundials index 206d44bcb33986a529614c4b6553b94f55d1a74e..15a8c726b56692c9e6e67f7e86b0b3fde4b0c7b3 100644 --- a/build/makefile_sundials +++ b/build/makefile_sundials @@ -175,7 +175,8 @@ SUMMA_JOB_INTERFACE = \ JOB_INTERFACE = $(patsubst %, $(JOB_ACTOR_DIR)/%, $(SUMMA_JOB_INTERFACE)) SUMMA_HRU_INTERFACE = \ - cppwrap_hru.f90 + cppwrap_hru.f90 \ + hru_actor.f90 HRU_INTERFACE = $(patsubst %, $(HRU_ACTOR_DIR)/%, $(SUMMA_HRU_INTERFACE)) @@ -183,6 +184,7 @@ SUMMA_GRU_INTERFACE = \ gru_actor.f90 \ GRU_INTERFACE = $(patsubst %, $(GRU_ACTOR_DIR)/%, $(SUMMA_GRU_INTERFACE)) + # Define routines for SUMMA preliminaries @@ -283,6 +285,7 @@ SOURCE_DIR = /Summa-Actors/build/source/actors GLOBAL_INCLUDES = -I$(INCLUDE_DIR)/global GLOBAL = $(SOURCE_DIR)/global/global.cpp TIMEINFO = $(SOURCE_DIR)/global/timing_info.cpp +AUXILARY = $(SOURCE_DIR)/global/auxiliary.cpp SUMMA_ACTOR_INCLUDES = -I$(INCLUDE_DIR)/summa_actor SUMMA_ACTOR = $(SOURCE_DIR)/summa_actor/summa_actor.cpp @@ -358,7 +361,7 @@ clean_fortran: ################################################ COMPILE SUMMA-C++ ################################################ ################################################################################################################### compile_globals: - $(CC) $(FLAGS_ACTORS) -c $(GLOBAL) $(TIMEINFO) $(GLOBAL_INCLUDES) + $(CC) $(FLAGS_ACTORS) -c $(GLOBAL) $(TIMEINFO) $(AUXILARY) $(GLOBAL_INCLUDES) compile_gru_actor: $(CC) $(FLAGS_ACTORS) -c $(GRU_ACTOR) $(HRU_ACTOR_INCLUDES) $(GRU_ACTOR_INCLUDES) $(GLOBAL_INCLUDES) $(ACTORS_INCLUDES) diff --git a/build/source/actors/global/auxiliary.cpp b/build/source/actors/global/auxiliary.cpp new file mode 100644 index 0000000000000000000000000000000000000000..745f156b8fa556e1b45a61d3945abde9d7231dce --- /dev/null +++ b/build/source/actors/global/auxiliary.cpp @@ -0,0 +1,303 @@ +#include <iostream> +#include <stdio.h> +#include <vector> +#include <string.h> +#include "fortran_data_types.hpp" +#include "auxilary.hpp" + +/***** + * These are all of the functions to get the Fortran data types into C + * / +/*************** SET DATA **************/ +void set_flagVec(const std::vector<int>& arr_i, void* handle) { + set_data_flagVec(handle, &arr_i[0], arr_i.size()); +} + +void set_var_i(const std::vector<int>& arr_i, void* handle) { + set_data_var_i(handle, &arr_i[0], arr_i.size()); +} + +void set_var_d(const std::vector<double> &arr_d, void* handle) { + set_data_var_d(handle, &arr_d[0], arr_d.size()); +} + +void set_var_i8(const std::vector<long int>& arr_i, void* handle) { + ::set_data_var_i8(handle, &arr_i[0], arr_i.size()); +} + +void set_i8length(const std::vector<long int> &arr_i8length, void* handle) { + set_data_i8length(handle, &arr_i8length[0], arr_i8length.size()); +} + +void set_ilength(const std::vector<int> &arr_ilength, void* handle) { + set_data_ilength(handle, &arr_ilength[0], arr_ilength.size()); +} + +void set_dlength(const std::vector<double> &arr_dlength, void* handle) { + set_data_dlength(handle, &arr_dlength[0], arr_dlength.size()); +} + +void set_var_flagVec(const std::vector<std::vector<int> > &mat, void* handle) { + + size_t num_row = mat.size(); + std::vector<int> num_col( num_row ); + std::vector<int> array; + + int num_elements = 0; + for(size_t i=0; i<num_row; i++) { + num_col[i] = mat[i].size(); + for(size_t j=0; j<num_col[i]; j++) + array.push_back(mat[i][j]); + num_elements += num_col[i]; + } + + set_data_var_flagVec(handle, &array[0], num_row, &num_col[0], num_elements); +} + +void set_var_ilength(const std::vector<std::vector<int> > &mat, void* handle) { + + size_t num_row = mat.size(); + std::vector<int> num_col( num_row ); + std::vector<int> array; + + int num_elements = 0; + for(size_t i=0; i<num_row; i++) { + num_col[i] = mat[i].size(); + for(size_t j=0; j<num_col[i]; j++) + array.push_back(mat[i][j]); + num_elements += num_col[i]; + } + + set_data_var_ilength(handle, &array[0], num_row, &num_col[0], num_elements); +} + +void set_var_i8length(const std::vector<std::vector<long int> > &mat, void* handle) { + + size_t num_row = mat.size(); + std::vector<int> num_col( num_row ); + std::vector<long int> array; + + int num_elements = 0; + for(size_t i=0; i<num_row; i++) { + num_col[i] = mat[i].size(); + for(size_t j=0; j<num_col[i]; j++) + array.push_back(mat[i][j]); + num_elements += num_col[i]; + } + + set_data_var_i8length(handle, &array[0], num_row, &num_col[0], num_elements); +} + +void set_var_dlength(const std::vector<std::vector<double> > &mat, void *handle) { + + size_t num_row = mat.size(); + std::vector<int> num_col( num_row ); + std::vector<double> array; + + int num_elements = 0; + for(size_t i=0; i<num_row; i++) { + num_col[i] = mat[i].size(); + for(size_t j=0; j<num_col[i]; j++) + array.push_back(mat[i][j]); + num_elements += num_col[i]; + } + + set_data_var_dlength(handle, &array[0], num_row, &num_col[0], num_elements); +} + +// void set_var_info(VarInfo v, void* handle) { +// set_data_var_info(handle, v.varname, v.vardesc, v.varunit, v.vartype, +// &v.ncVarID[0], v.ncVarID.size(), &v.statIndex[0], v.statIndex.size(), v.varDesire); +// } + +/*************** GET DATA **************/ + +std::vector<int> get_flagVec(void* handle) { +int size; +get_size_data_flagVec(handle, &size); +if (size == 0) return std::vector<int>(); + +std::vector<int> array(size); +get_data_flagVec(handle, &array[0]); +return array; +} + +std::vector<int> get_var_i(void* handle) { +int size; +get_size_data_var_i(handle, &size); +if (size == 0) return std::vector<int>(); + +std::vector<int> array(size); +get_data_var_i(handle, &array[0]); +return array; +} + + +std::vector<double> get_var_d(void* handle) { +int size; +get_size_data_var_d(handle, &size); +if (size == 0) return std::vector<double>(); + +std::vector<double> array(size); +get_data_var_d(handle, &array[0]); +return array; +} + +std::vector<long int> get_var_i8(void* handle) { +int size; +get_size_data_var_i8(handle, &size); +if (size == 0) return std::vector<long int>(); + +std::vector<long int> array(size); +get_data_var_i8(handle, &array[0]); +return array; +} + +std::vector<long int> get_i8length(void* handle) { +int size; +get_size_data_i8length(handle, &size); +if (size == 0) return std::vector<long int>(); + +std::vector<long int> array(size); +get_data_i8length(handle, &array[0]); +return array; +} + +std::vector<int> get_ilength(void* handle) { +int size; +get_size_data_ilength(handle, &size); +if (size == 0) return std::vector<int>(); + +std::vector<int> array(size); +get_data_ilength(handle, &array[0]); +return array; +} + +std::vector<double> get_dlength(void* handle) { +int size; +get_size_data_dlength(handle, &size); +if (size == 0) return std::vector<double>(); + +std::vector<double> array(size); +get_data_dlength(handle, &array[0]); +return array; +} + +std::vector<std::vector<int> > get_var_flagVec(void* handle) { +int num_row; +get_size_var_flagVec(handle, &num_row); +if (num_row == 0) return std::vector<std::vector<int> >(); + +std::vector<int> num_col(num_row); +get_size_data_var_flagVec(handle, &num_row, &num_col[0]); + +int num_elem = 0; +for(int i=0; i<num_row; i++) + num_elem += num_col[i]; + +std::vector<int> array(num_elem); + +get_data_var_flagVec(handle, &array[0]); + +std::vector<std::vector<int> > mat(num_row); +for(size_t i=0; i<num_row; i++) + mat[i] = std::vector<int>(num_col[i]); + +num_elem = 0; +for(size_t i=0; i<num_row; i++){ + for(size_t j=0; j<num_col[i]; j++) + mat[i][j] = array[num_elem + j]; + num_elem += num_col[i]; +} + + +return mat; +} + +std::vector<std::vector<int> > get_var_ilength(void* handle) { +int num_row; +get_size_var_ilength(handle, &num_row); +if (num_row == 0) return std::vector<std::vector<int> >(); + +std::vector<int> num_col(num_row); +get_size_data_var_ilength(handle, &num_row, &num_col[0]); + +int num_elem = 0; +for(int i=0; i<num_row; i++) + num_elem += num_col[i]; + +std::vector<int> array(num_elem); + +get_data_var_ilength(handle, &array[0]); + +std::vector<std::vector<int> > mat(num_row); +for(size_t i=0; i<num_row; i++) + mat[i] = std::vector<int>(num_col[i]); + +num_elem = 0; +for(size_t i=0; i<num_row; i++){ + for(size_t j=0; j<num_col[i]; j++) + mat[i][j] = array[num_elem + j]; + num_elem += num_col[i]; +} +return mat; +} + +std::vector<std::vector<long int> > get_var_i8length(void* handle) { +int num_row; +get_size_var_i8length(handle, &num_row); +if (num_row == 0) return std::vector<std::vector<long int> >(); + +std::vector<int> num_col(num_row); +get_size_data_var_i8length(handle, &num_row, &num_col[0]); + +int num_elem = 0; +for(int i=0; i<num_row; i++) + num_elem += num_col[i]; + +std::vector<long int> array(num_elem); + +get_data_var_i8length(handle, &array[0]); + +std::vector<std::vector<long int> > mat(num_row); +for(size_t i=0; i<num_row; i++) + mat[i] = std::vector<long int>(num_col[i]); + +num_elem = 0; +for(size_t i=0; i<num_row; i++){ + for(size_t j=0; j<num_col[i]; j++) + mat[i][j] = array[num_elem + j]; + num_elem += num_col[i]; +} +return mat; +} + +std::vector<std::vector<double> > get_var_dlength(void* handle) { +int num_row; +get_size_var_dlength(handle, &num_row); +if (num_row == 0) return std::vector<std::vector<double> >(); + +std::vector<int> num_col(num_row); +get_size_data_var_dlength(handle, &num_row, &num_col[0]); + +int num_elem = 0; +for(int i=0; i<num_row; i++) + num_elem += num_col[i]; + +std::vector<double> array(num_elem); + +get_data_var_dlength(handle, &array[0]); + +std::vector<std::vector<double> > mat(num_row); +for(size_t i=0; i<num_row; i++) + mat[i] = std::vector<double>(num_col[i]); + +num_elem = 0; +for(size_t i=0; i<num_row; i++){ + for(size_t j=0; j<num_col[i]; j++) + mat[i][j] = array[num_elem + j]; + num_elem += num_col[i]; +} + +return mat; +} \ No newline at end of file diff --git a/build/source/actors/hru_actor/hru_actor.cpp b/build/source/actors/hru_actor/hru_actor.cpp index a4016ae028e2479b48be0ad7e6bd540ccab5ef25..7fc381780569c58f0c720446b731fb2bd702c22a 100644 --- a/build/source/actors/hru_actor/hru_actor.cpp +++ b/build/source/actors/hru_actor/hru_actor.cpp @@ -3,6 +3,7 @@ #include "global.hpp" #include "message_atoms.hpp" #include "hru_actor_subroutine_wrappers.hpp" +#include "serialize_data_structure.hpp" namespace caf { @@ -132,11 +133,46 @@ behavior hru_actor(stateful_actor<hru_state>* self, int refGRU, int indxGRU, keepRunning = check_HRU(self, err); // check if we are done, need to write } + + self->send(self, serialize_data_v); self->state.hru_timing.updateEndPoint("total_duration"); }, + [=](serialize_data) { + + aout(self) << "We are here in Serialize Data\n"; + // Statistic Structures + std::vector<std::vector<double>> forc_stat_array = get_var_dlength(self->state.handle_forcStat); + std::vector<std::vector<double>> prog_stat_array = get_var_dlength(self->state.handle_progStat); + std::vector<std::vector<double>> diag_stat_array = get_var_dlength(self->state.handle_diagStat); + std::vector<std::vector<double>> flux_stat_array = get_var_dlength(self->state.handle_fluxStat); + std::vector<std::vector<double>> indx_stat_array = get_var_dlength(self->state.handle_indxStat); + std::vector<std::vector<double>> bvar_stat_array = get_var_dlength(self->state.handle_bvarStat); + + // primary data structures (scalars) + std::vector<int> time_struct_array = get_var_i(self->state.handle_timeStruct); + std::vector<double> forc_struct_array = get_var_d(self->state.handle_forcStruct); + std::vector<double> attr_struct_array = get_var_d(self->state.handle_attrStruct); + std::vector<int> type_struct_array = get_var_i(self->state.handle_typeStruct); + std::vector<long int> id_struct_array = get_var_i8(self->state.handle_idStruct); + + // primary data structures (variable length vectors) + std::vector<std::vector<int>> indx_struct_array = get_var_ilength(self->state.handle_indxStruct); + std::vector<std::vector<double>> mpar_struct_array = get_var_dlength(self->state.handle_mparStruct); + std::vector<std::vector<double>> prog_struc_array = get_var_dlength(self->state.handle_progStruct); + std::vector<std::vector<double>> diag_struct_array = get_var_dlength(self->state.handle_diagStruct); + std::vector<std::vector<double>> flux_struct_array = get_var_dlength(self->state.handle_fluxStruct); + + // basin-average structures + std::vector<double> bpar_struct_array = get_var_d(self->state.handle_bparStruct); + std::vector<std::vector<double>> bvar_struct_array = get_var_dlength(self->state.handle_bvarStruct); + + // ancillary data structures + std::vector<double> dpar_struct_array = get_var_d(self->state.handle_dparStruct); + }, + [=](dt_init_factor, int dt_init_factor) { aout(self) << "Recieved New dt_init_factor to attempt on next run \n"; self->state.dt_init_factor = dt_init_factor; diff --git a/build/source/actors/hru_actor/hru_actor.f90 b/build/source/actors/hru_actor/hru_actor.f90 index 2ae7bab059d99f8c4f479b7e0202578c2456e613..8cf60bf3f1a52744edafcf40995c7168f8b51eac 100644 --- a/build/source/actors/hru_actor/hru_actor.f90 +++ b/build/source/actors/hru_actor/hru_actor.f90 @@ -1,151 +1,22 @@ module hru_actor - implicit none +USE,intrinsic :: iso_c_binding +USE nrtype +implicit none - public::run_hru_for_timestep() +public::getSummaVariableInfo - contains - subroutine run_hru_for_timestep() +contains +subroutine getSummaVariableInfo(var_type, var_fortran_index, data_struct) bind(C, name="getSummaVariableInfo") + integer(c_int) :: var_type + integer(c_int) :: var_fortran_index + type(c_ptr) :: data_struct - - ! local variables: - integer(i4b) :: nSnow - integer(i4b) :: nSoil - integer(i4b) :: nLayers - ! ******************************************************************************************* - ! *** initialize computeVegFlux (flag to indicate if we are computing fluxes over vegetation) - ! ******************************************************************************************* - - ! if computeVegFlux changes, then the number of state variables changes, and we need to reoranize the data structures - if(modelTimeStep==1)then - ! get vegetation phenology - ! (compute the exposed LAI and SAI and whether veg is buried by snow) - call vegPhenlgy(& - ! input/output: data structures - model_decisions, & ! intent(in): model decisions - typeStruct, & ! intent(in): type of vegetation and soil - attrStruct, & ! intent(in): spatial attributes - mparStruct, & ! intent(in): model parameters - progStruct, & ! intent(in): model prognostic variables for a local HRU - diagStruct, & ! intent(inout): model diagnostic variables for a local HRU - ! output - computeVegFluxFlag, & ! intent(out): flag to indicate if we are computing fluxes over vegetation (.false. means veg is buried with snow) - notUsed_canopyDepth, & ! intent(out): NOT USED: canopy depth (m) - notUsed_exposedVAI, & ! intent(out): NOT USED: exposed vegetation area index (m2 m-2) - fracJulDay, & - yearLength, & - err,cmessage) ! intent(out): error control - if(err/=0)then; message=trim(message)//trim(cmessage); return; endif - ! save the flag for computing the vegetation fluxes - if(computeVegFluxFlag) computeVegFlux = yes - if(.not.computeVegFluxFlag) computeVegFlux = no - ! define the green vegetation fraction of the grid box (used to compute LAI) - diagStruct%var(iLookDIAG%scalarGreenVegFraction)%dat(1) = greenVegFrac_monthly(timeStruct%var(iLookTIME%im)) - end if ! if first timestep - - ! initialize total inflow for each layer in a soil column - fluxStruct%var(iLookFLUX%mLayerColumnInflow)%dat(:) = 0._dp - - ! convienence variables - nSnow = indxStruct%var(iLookINDEX%nSnow)%dat(1) ! number of snow layers - nSoil = indxStruct%var(iLookINDEX%nSoil)%dat(1) ! number of soil layers - nLayers = indxStruct%var(iLookINDEX%nLayers)%dat(1) ! total number of layers - - computeVegFluxFlag = (ComputeVegFlux == yes) - - ! water pixel: do nothing - if (typeStruct%var(iLookTYPE%vegTypeIndex) == isWater) return - - ! get height at bottom of each soil layer, negative downwards (used in Noah MP) - allocate(zSoilReverseSign(nSoil),stat=err) - if(err/=0)then - message=trim(message)//'problem allocating space for zSoilReverseSign' - err=20; return - endif - zSoilReverseSign(:) = -progStruct%var(iLookPROG%iLayerHeight)%dat(nSnow+1:nLayers) - - ! populate parameters in Noah-MP modules - ! Passing a maxSoilLayer in order to pass the check for NROOT, that is done to avoid making any changes to Noah-MP code. - ! --> NROOT from Noah-MP veg tables (as read here) is not used in SUMMA - call REDPRM(typeStruct%var(iLookTYPE%vegTypeIndex), & ! vegetation type index - typeStruct%var(iLookTYPE%soilTypeIndex), & ! soil type - typeStruct%var(iLookTYPE%slopeTypeIndex), & ! slope type index - zSoilReverseSign, & ! * not used: height at bottom of each layer [NOTE: negative] (m) - maxSoilLayers, & ! number of soil layers - urbanVegCategory) ! vegetation category for urban areas - - ! deallocate height at bottom of each soil layer(used in Noah MP) - deallocate(zSoilReverseSign,stat=err) - if(err/=0)then - message=trim(message)//'problem deallocating space for zSoilReverseSign' - err=20; return - endif - - ! overwrite the minimum resistance - if(overwriteRSMIN) RSMIN = mparStruct%var(iLookPARAM%minStomatalResistance)%dat(1) - - ! overwrite the vegetation height - HVT(typeStruct%var(iLookTYPE%vegTypeIndex)) = mparStruct%var(iLookPARAM%heightCanopyTop)%dat(1) - HVB(typeStruct%var(iLookTYPE%vegTypeIndex)) = mparStruct%var(iLookPARAM%heightCanopyBottom)%dat(1) - - ! overwrite the tables for LAI and SAI - if(model_decisions(iLookDECISIONS%LAI_method)%iDecision == specified)then - SAIM(typeStruct%var(iLookTYPE%vegTypeIndex),:) = mparStruct%var(iLookPARAM%winterSAI)%dat(1) - LAIM(typeStruct%var(iLookTYPE%vegTypeIndex),:) = mparStruct%var(iLookPARAM%summerLAI)%dat(1)*greenVegFrac_monthly - end if - - ! compute derived forcing variables - call derivforce(& - timeStruct%var, & ! vector of time information - forcStruct%var, & ! vector of model forcing data - attrStruct%var, & ! vector of model attributes - mparStruct, & ! data structure of model parameters - progStruct, & ! data structure of model prognostic variables - diagStruct, & ! data structure of model diagnostic variables - fluxStruct, & ! data structure of model fluxes - tmZoneOffsetFracDay,& - err,cmessage) ! error control - if(err/=0)then; err=20; message=trim(message)//trim(cmessage); return; endif - - ! initialize the number of flux calls - diagStruct%var(iLookDIAG%numFluxCalls)%dat(1) = 0._dp - - ! run the model for a single HRU - call coupled_em(& - ! model control - indxHRU, & ! intent(in): hruID - dt_init, & ! intent(inout): initial time step - dt_init_factor, & ! Used to adjust the length of the timestep in the event of a failure - computeVegFluxFlag, & ! intent(inout): flag to indicate if we are computing fluxes over vegetation - ! data structures (input) - typeStruct, & ! intent(in): local classification of soil veg etc. for each HRU - attrStruct, & ! intent(in): local attributes for each HRU - forcStruct, & ! intent(in): model forcing data - mparStruct, & ! intent(in): model parameters - bvarStruct, & ! intent(in): basin-average model variables - ! data structures (input-output) - indxStruct, & ! intent(inout): model indices - progStruct, & ! intent(inout): model prognostic variables for a local HRU - diagStruct, & ! intent(inout): model diagnostic variables for a local HRU - fluxStruct, & ! intent(inout): model fluxes for a local HRU - fracJulDay, & - yearLength, & - ! error control - err,cmessage) ! intent(out): error control - if(err/=0)then; err=20; message=trim(message)//trim(cmessage); return; endif + - ! save the flag for computing the vegetation fluxes - if(computeVegFluxFlag) ComputeVegFlux = yes - if(.not.computeVegFluxFlag) ComputeVegFlux = no - ! The gru_actor will need the following information - fracHRU = attrStruct%var(iLookATTR%HRUarea) / bvarStruct%var(iLookBVAR%basin__totalArea)%dat(1) - fluxStruct%var(iLookFLUX%scalarSurfaceRunoff)%dat(1) - fluxStruct%var(iLookFLUX%scalarSoilDrainage)%dat(1) - fluxStruct%var(iLookFLUX%scalarAquiferTranspire)%dat(1) - fluxStruct%var(iLookFLUX%scalarAquiferBaseflow)%dat(1) - end subroutine +end subroutine getSummaVariableInfo end module hru_actor \ No newline at end of file diff --git a/build/source/actors/hru_actor/serialize_data_structure.cpp b/build/source/actors/hru_actor/serialize_data_structure.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a1d432361a41b4787d11bd495153a4d4e6bc54b --- /dev/null +++ b/build/source/actors/hru_actor/serialize_data_structure.cpp @@ -0,0 +1,2 @@ +#include "serialize_data_structure.hpp" + diff --git a/build/source/driver/summaActors_wOutputStruc.f90 b/build/source/driver/summaActors_wOutputStruc.f90 index c81bb5a2a2e4be4ec5560a21afebee9eb0541c9a..e5f96b819a4e7d2c28088bf03fa3c9a73743139e 100644 --- a/build/source/driver/summaActors_wOutputStruc.f90 +++ b/build/source/driver/summaActors_wOutputStruc.f90 @@ -168,10 +168,14 @@ subroutine summaActors_writeToOutputStruc(& integer(i4b) :: nHRU integer(i4b) :: iFreq ! index of the output frequency integer(i4b) :: iGRU ! Temporary index for GRU + integer(i4b) :: i + integer(i4b) :: j + nGRU = 1 nHRU = 1 iGRU = 1 + err=0; message='summa_manageOutputFiles/' ! identify the start of the writing call date_and_time(values=startWrite)