From 9d4af9f0313fa1e2dbe9efaee5d3b216e95e4749 Mon Sep 17 00:00:00 2001 From: KyleKlenk <kyle.c.klenk@gmail.com> Date: Wed, 29 Jun 2022 13:50:56 -0600 Subject: [PATCH] HRU now calls its initalize routine directly --- .../hru_actor_subroutine_wrappers.hpp | 2 +- build/launch_apptainer.sh | 6 + build/makefile-container | 10 +- build/source/actors/hru_actor/cppwrap_hru.f90 | 346 +++++++++--------- build/source/actors/hru_actor/hru_actor.cpp | 6 +- build/source/driver/summaActors_init.f90 | 187 ++++++---- build/source/netcdf/writeOutput.f90 | 3 - utils/Summa_Actors_Settings_backup.json | 32 ++ 8 files changed, 345 insertions(+), 247 deletions(-) create mode 100755 build/launch_apptainer.sh create mode 100644 utils/Summa_Actors_Settings_backup.json diff --git a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp index 6c14753..577b3f2 100644 --- a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp +++ b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp @@ -2,7 +2,7 @@ extern "C" { // Initialize HRU data_structures - void Initialize( + void summaActors_initialize( int* indxGRU, int* num_steps, // Statistics Structures void* forcStat, void* progStat, void* diagStat, void* fluxStat, void* indxStat, void* bvarStat, diff --git a/build/launch_apptainer.sh b/build/launch_apptainer.sh new file mode 100755 index 0000000..94269c9 --- /dev/null +++ b/build/launch_apptainer.sh @@ -0,0 +1,6 @@ +#!/bin/bash +singularity shell --bind /globalhome/kck540/HPC/SummaProjects/Summa-Actors:/Summa-Actors \ + --bind /scratch/gwf/gwf_cmt/kck540/SummaOutput/SummaActors:/output \ + --bind /project/gwf/gwf_cmt/kck540/domain_NorthAmerica/settings/SUMMA:/SUMMA \ + --bind /project/gwf/gwf_cmt/kck540/domain_NorthAmerica/forcing/SummaChunkedData/:/forcing \ + summa-actors.sif diff --git a/build/makefile-container b/build/makefile-container index 8766bde..e7f087d 100644 --- a/build/makefile-container +++ b/build/makefile-container @@ -1,5 +1,5 @@ #### parent directory of the 'build' directory #### -ROOT_DIR = /globalhome/kck540/HPC/SummaProjects/Summa-Actors +ROOT_DIR = /Summa-Actors #### Compilers #### FC = gfortran # Fortran @@ -241,8 +241,8 @@ DRIVER = $(patsubst %, $(DRIVER_DIR)/%, $(SUMMA_DRIVER)) ######################################## Assemble C++ Files ######################################## #################################################################################################### -INCLUDE_DIR = /globalhome/kck540/HPC/SummaProjects/Summa-Actors/build/includes -SOURCE_DIR = /globalhome/kck540/HPC/SummaProjects/Summa-Actors/build/source/actors +INCLUDE_DIR = $(ROOT_DIR)/build/includes +SOURCE_DIR = $(ROOT_DIR)/build/source/actors GLOBAL_INCLUDES = -I$(INCLUDE_DIR)/global @@ -296,11 +296,11 @@ compile_noah: # compile common routines compile_comm: - $(FC) $(FLAGS_COMM) -c $(COMM_ALL) $(INCLUDES) + $(FC) $(FLAGS_COMM) -c $(COMM_ALL) $(INTERFACE) $(INCLUDES) # compile SUMMA routines compile_summa: - $(FC) $(FLAGS_SUMMA) -c $(SUMMA_ALL) $(DRIVER) $(INTERFACE) $(JOB_INTERFACE) $(FILEACCESS_INTERFACE) $(HRU_INTERFACE) $(INCLUDES) + $(FC) $(FLAGS_SUMMA) -c $(SUMMA_ALL) $(DRIVER) $(JOB_INTERFACE) $(FILEACCESS_INTERFACE) $(HRU_INTERFACE) $(INCLUDES) # generate library link: diff --git a/build/source/actors/hru_actor/cppwrap_hru.f90 b/build/source/actors/hru_actor/cppwrap_hru.f90 index 87587d0..e4f48be 100644 --- a/build/source/actors/hru_actor/cppwrap_hru.f90 +++ b/build/source/actors/hru_actor/cppwrap_hru.f90 @@ -6,7 +6,7 @@ USE data_types USE globalData implicit none -public::Initialize +! public::Initialize public::SetupParam public::Restart public::Forcing @@ -19,178 +19,178 @@ contains !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! *************** Initalize Structures For HRU ************************ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -subroutine Initialize(& - indxGRU, & - num_steps, & - ! statistics structures - handle_forcStat, & ! model forcing data - handle_progStat, & ! model prognostic (state) variables - handle_diagStat, & ! model diagnostic variables - handle_fluxStat, & ! model fluxes - handle_indxStat, & ! model indices - handle_bvarStat, & ! basin-average variables - ! primary data structures (scalars) - handle_timeStruct, & ! model time data - handle_forcStruct, & ! model forcing data - handle_attrStruct, & ! local attributes for each HRU - handle_typeStruct, & ! local classification of soil veg etc. for each HRU - handle_idStruct, & ! - ! primary data structures (variable length vectors) - handle_indxStruct, & ! model indices - handle_mparStruct, & ! model parameters - handle_progStruct, & ! model prognostic (state) variables - handle_diagStruct, & ! model diagnostic variables - handle_fluxStruct, & ! model fluxes - ! basin-average structures - handle_bparStruct, & ! basin-average parameters - handle_bvarStruct, & ! basin-average variables - ! ancillary data structures - handle_dparStruct, & ! default model parameters - ! local HRU data - handle_startTime, & ! start time for the model simulation - handle_finshTime, & ! end time for the model simulation - handle_refTime, & ! reference time for the model simulation - handle_oldTime, & ! time for the previous model time step - ! miscellaneous variables - err) bind(C,name='Initialize') - - use summa4chm_init,only:summa4chm_initialize - - implicit none - ! calling variables - integer(c_int),intent(in) :: indxGRU - integer(c_int),intent(out) :: num_steps - ! statistics structures - type(c_ptr), intent(in), value :: handle_forcStat ! model forcing data - type(c_ptr), intent(in), value :: handle_progStat ! model prognostic (state) variables - type(c_ptr), intent(in), value :: handle_diagStat ! model diagnostic variables - type(c_ptr), intent(in), value :: handle_fluxStat ! model fluxes - type(c_ptr), intent(in), value :: handle_indxStat ! model indices - type(c_ptr), intent(in), value :: handle_bvarStat ! basin-average variables - ! primary data structures (scalars) - type(c_ptr), intent(in), value :: handle_timeStruct ! model time data - type(c_ptr), intent(in), value :: handle_forcStruct ! model forcing data - type(c_ptr), intent(in), value :: handle_attrStruct ! local attributes for each HRU - type(c_ptr), intent(in), value :: handle_typeStruct ! local classification of soil veg etc. for each HRU - type(c_ptr), intent(in), value :: handle_idStruct ! - ! primary data structures (variable length vectors) - type(c_ptr), intent(in), value :: handle_indxStruct ! model indices - type(c_ptr), intent(in), value :: handle_mparStruct ! model parameters - type(c_ptr), intent(in), value :: handle_progStruct ! model prognostic (state) variables - type(c_ptr), intent(in), value :: handle_diagStruct ! model diagnostic variables - type(c_ptr), intent(in), value :: handle_fluxStruct ! model fluxes - ! basin-average structures - type(c_ptr), intent(in), value :: handle_bparStruct ! basin-average parameters - type(c_ptr), intent(in), value :: handle_bvarStruct ! basin-average variables - ! ancillary data structures - type(c_ptr), intent(in), value :: handle_dparStruct ! default model parameters - ! local hru data structures - type(c_ptr), intent(in), value :: handle_startTime ! start time for the model simulation - type(c_ptr), intent(in), value :: handle_finshTime ! end time for the model simulation - type(c_ptr), intent(in), value :: handle_refTime ! reference time for the model simulation - type(c_ptr), intent(in), value :: handle_oldTime ! time for the previous model time step - integer(c_int),intent(inout) :: err - !--------------------------------------------------------------------------------------------------- - ! local variables - - ! statistics structures - type(var_dlength),pointer :: forcStat ! model forcing data - type(var_dlength),pointer :: progStat ! model prognostic (state) variables - type(var_dlength),pointer :: diagStat ! model diagnostic variables - type(var_dlength),pointer :: fluxStat ! model fluxes - type(var_dlength),pointer :: indxStat ! model indices - type(var_dlength),pointer :: bvarStat ! basin-average variabl - ! primary data structures (scalars) - type(var_i),pointer :: timeStruct ! model time data - type(var_d),pointer :: forcStruct ! model forcing data - type(var_d),pointer :: attrStruct ! local attributes for each HRU - type(var_i),pointer :: typeStruct ! local classification of soil veg etc. for each HRU - type(var_i8),pointer :: idStruct ! - ! primary data structures (variable length vectors) - type(var_ilength),pointer :: indxStruct ! model indices - type(var_dlength),pointer :: mparStruct ! model parameters - type(var_dlength),pointer :: progStruct ! model prognostic (state) variables - type(var_dlength),pointer :: diagStruct ! model diagnostic variables - type(var_dlength),pointer :: fluxStruct ! model fluxes - ! basin-average structures - type(var_d),pointer :: bparStruct ! basin-average parameters - type(var_dlength),pointer :: bvarStruct ! basin-average variables - ! ancillary data structures - type(var_d),pointer :: dparStruct ! default model parameters - ! local HRU data structures - type(var_i),pointer :: startTime ! start time for the model simulation - type(var_i),pointer :: finshTime ! end time for the model simulation - type(var_i),pointer :: refTime ! reference time for the model simulation - type(var_i),pointer :: oldTime ! time for the previous model time step - character(len=256) :: message - - - ! getting data - call c_f_pointer(handle_forcStat, forcStat) - call c_f_pointer(handle_progStat, progStat) - call c_f_pointer(handle_diagStat, diagStat) - call c_f_pointer(handle_fluxStat, fluxStat) - call c_f_pointer(handle_indxStat, indxStat) - call c_f_pointer(handle_bvarStat, bvarStat) - call c_f_pointer(handle_timeStruct, timeStruct) - call c_f_pointer(handle_forcStruct, forcStruct) - call c_f_pointer(handle_attrStruct, attrStruct) - call c_f_pointer(handle_typeStruct, typeStruct) - call c_f_pointer(handle_idStruct, idStruct) - call c_f_pointer(handle_indxStruct, indxStruct) - call c_f_pointer(handle_mparStruct, mparStruct) - call c_f_pointer(handle_progStruct, progStruct) - call c_f_pointer(handle_diagStruct, diagStruct) - call c_f_pointer(handle_fluxStruct, fluxStruct) - call c_f_pointer(handle_bparStruct, bparStruct) - call c_f_pointer(handle_bvarStruct, bvarStruct) - call c_f_pointer(handle_dparStruct, dparStruct) - call c_f_pointer(handle_startTime, startTime) - call c_f_pointer(handle_finshTime, finshTime) - call c_f_pointer(handle_refTime, refTime) - call c_f_pointer(handle_oldTime, oldTime) - - - call summa4chm_initialize(& - indxGRU, & ! index of the parent GRU - num_steps, & - ! statistics structures - forcStat, & ! model forcing data - progStat, & ! model prognostic (state) variables - diagStat, & ! model diagnostic variables - fluxStat, & ! model fluxes - indxStat, & ! model indices - bvarStat, & ! basin-average variables - ! primary data structures (scalars) - timeStruct, & ! model time data - forcStruct, & ! model forcing data - attrStruct, & ! local attributes for each HRU - typeStruct, & ! local classification of soil veg etc. for each HRU - idStruct, & ! - ! primary data structures (variable length vectors) - indxStruct, & ! model indices - mparStruct, & ! model parameters - progStruct, & ! model prognostic (state) variables - diagStruct, & ! model diagnostic variables - fluxStruct, & ! model fluxes - ! basin-average structures - bparStruct, & ! basin-average parameters - bvarStruct, & ! basin-average variables - ! ancillary data structures - dparStruct, & ! default model parameters - startTime, & ! start time for the model simulation - finshTime, & ! end time for the model simulation - refTime, & ! reference time for the model simulation - oldTime, & ! time for the previous model time step - ! miscellaneous variables - err, message) - - if(err/=0)then - message=trim(message) - print*, message - endif - -end subroutine Initialize +! subroutine Initialize(& +! indxGRU, & +! num_steps, & +! ! statistics structures +! handle_forcStat, & ! model forcing data +! handle_progStat, & ! model prognostic (state) variables +! handle_diagStat, & ! model diagnostic variables +! handle_fluxStat, & ! model fluxes +! handle_indxStat, & ! model indices +! handle_bvarStat, & ! basin-average variables +! ! primary data structures (scalars) +! handle_timeStruct, & ! model time data +! handle_forcStruct, & ! model forcing data +! handle_attrStruct, & ! local attributes for each HRU +! handle_typeStruct, & ! local classification of soil veg etc. for each HRU +! handle_idStruct, & ! +! ! primary data structures (variable length vectors) +! handle_indxStruct, & ! model indices +! handle_mparStruct, & ! model parameters +! handle_progStruct, & ! model prognostic (state) variables +! handle_diagStruct, & ! model diagnostic variables +! handle_fluxStruct, & ! model fluxes +! ! basin-average structures +! handle_bparStruct, & ! basin-average parameters +! handle_bvarStruct, & ! basin-average variables +! ! ancillary data structures +! handle_dparStruct, & ! default model parameters +! ! local HRU data +! handle_startTime, & ! start time for the model simulation +! handle_finshTime, & ! end time for the model simulation +! handle_refTime, & ! reference time for the model simulation +! handle_oldTime, & ! time for the previous model time step +! ! miscellaneous variables +! err) bind(C,name='Initialize') + +! use summa4chm_init,only:summa4chm_initialize + +! implicit none +! ! calling variables +! integer(c_int),intent(in) :: indxGRU +! integer(c_int),intent(out) :: num_steps +! ! statistics structures +! type(c_ptr), intent(in), value :: handle_forcStat ! model forcing data +! type(c_ptr), intent(in), value :: handle_progStat ! model prognostic (state) variables +! type(c_ptr), intent(in), value :: handle_diagStat ! model diagnostic variables +! type(c_ptr), intent(in), value :: handle_fluxStat ! model fluxes +! type(c_ptr), intent(in), value :: handle_indxStat ! model indices +! type(c_ptr), intent(in), value :: handle_bvarStat ! basin-average variables +! ! primary data structures (scalars) +! type(c_ptr), intent(in), value :: handle_timeStruct ! model time data +! type(c_ptr), intent(in), value :: handle_forcStruct ! model forcing data +! type(c_ptr), intent(in), value :: handle_attrStruct ! local attributes for each HRU +! type(c_ptr), intent(in), value :: handle_typeStruct ! local classification of soil veg etc. for each HRU +! type(c_ptr), intent(in), value :: handle_idStruct ! +! ! primary data structures (variable length vectors) +! type(c_ptr), intent(in), value :: handle_indxStruct ! model indices +! type(c_ptr), intent(in), value :: handle_mparStruct ! model parameters +! type(c_ptr), intent(in), value :: handle_progStruct ! model prognostic (state) variables +! type(c_ptr), intent(in), value :: handle_diagStruct ! model diagnostic variables +! type(c_ptr), intent(in), value :: handle_fluxStruct ! model fluxes +! ! basin-average structures +! type(c_ptr), intent(in), value :: handle_bparStruct ! basin-average parameters +! type(c_ptr), intent(in), value :: handle_bvarStruct ! basin-average variables +! ! ancillary data structures +! type(c_ptr), intent(in), value :: handle_dparStruct ! default model parameters +! ! local hru data structures +! type(c_ptr), intent(in), value :: handle_startTime ! start time for the model simulation +! type(c_ptr), intent(in), value :: handle_finshTime ! end time for the model simulation +! type(c_ptr), intent(in), value :: handle_refTime ! reference time for the model simulation +! type(c_ptr), intent(in), value :: handle_oldTime ! time for the previous model time step +! integer(c_int),intent(inout) :: err +! !--------------------------------------------------------------------------------------------------- +! ! local variables + +! ! statistics structures +! type(var_dlength),pointer :: forcStat ! model forcing data +! type(var_dlength),pointer :: progStat ! model prognostic (state) variables +! type(var_dlength),pointer :: diagStat ! model diagnostic variables +! type(var_dlength),pointer :: fluxStat ! model fluxes +! type(var_dlength),pointer :: indxStat ! model indices +! type(var_dlength),pointer :: bvarStat ! basin-average variabl +! ! primary data structures (scalars) +! type(var_i),pointer :: timeStruct ! model time data +! type(var_d),pointer :: forcStruct ! model forcing data +! type(var_d),pointer :: attrStruct ! local attributes for each HRU +! type(var_i),pointer :: typeStruct ! local classification of soil veg etc. for each HRU +! type(var_i8),pointer :: idStruct ! +! ! primary data structures (variable length vectors) +! type(var_ilength),pointer :: indxStruct ! model indices +! type(var_dlength),pointer :: mparStruct ! model parameters +! type(var_dlength),pointer :: progStruct ! model prognostic (state) variables +! type(var_dlength),pointer :: diagStruct ! model diagnostic variables +! type(var_dlength),pointer :: fluxStruct ! model fluxes +! ! basin-average structures +! type(var_d),pointer :: bparStruct ! basin-average parameters +! type(var_dlength),pointer :: bvarStruct ! basin-average variables +! ! ancillary data structures +! type(var_d),pointer :: dparStruct ! default model parameters +! ! local HRU data structures +! type(var_i),pointer :: startTime ! start time for the model simulation +! type(var_i),pointer :: finshTime ! end time for the model simulation +! type(var_i),pointer :: refTime ! reference time for the model simulation +! type(var_i),pointer :: oldTime ! time for the previous model time step +! character(len=256) :: message + + +! ! getting data +! call c_f_pointer(handle_forcStat, forcStat) +! call c_f_pointer(handle_progStat, progStat) +! call c_f_pointer(handle_diagStat, diagStat) +! call c_f_pointer(handle_fluxStat, fluxStat) +! call c_f_pointer(handle_indxStat, indxStat) +! call c_f_pointer(handle_bvarStat, bvarStat) +! call c_f_pointer(handle_timeStruct, timeStruct) +! call c_f_pointer(handle_forcStruct, forcStruct) +! call c_f_pointer(handle_attrStruct, attrStruct) +! call c_f_pointer(handle_typeStruct, typeStruct) +! call c_f_pointer(handle_idStruct, idStruct) +! call c_f_pointer(handle_indxStruct, indxStruct) +! call c_f_pointer(handle_mparStruct, mparStruct) +! call c_f_pointer(handle_progStruct, progStruct) +! call c_f_pointer(handle_diagStruct, diagStruct) +! call c_f_pointer(handle_fluxStruct, fluxStruct) +! call c_f_pointer(handle_bparStruct, bparStruct) +! call c_f_pointer(handle_bvarStruct, bvarStruct) +! call c_f_pointer(handle_dparStruct, dparStruct) +! call c_f_pointer(handle_startTime, startTime) +! call c_f_pointer(handle_finshTime, finshTime) +! call c_f_pointer(handle_refTime, refTime) +! call c_f_pointer(handle_oldTime, oldTime) + + +! call summa4chm_initialize(& +! indxGRU, & ! index of the parent GRU +! num_steps, & +! ! statistics structures +! forcStat, & ! model forcing data +! progStat, & ! model prognostic (state) variables +! diagStat, & ! model diagnostic variables +! fluxStat, & ! model fluxes +! indxStat, & ! model indices +! bvarStat, & ! basin-average variables +! ! primary data structures (scalars) +! timeStruct, & ! model time data +! forcStruct, & ! model forcing data +! attrStruct, & ! local attributes for each HRU +! typeStruct, & ! local classification of soil veg etc. for each HRU +! idStruct, & ! +! ! primary data structures (variable length vectors) +! indxStruct, & ! model indices +! mparStruct, & ! model parameters +! progStruct, & ! model prognostic (state) variables +! diagStruct, & ! model diagnostic variables +! fluxStruct, & ! model fluxes +! ! basin-average structures +! bparStruct, & ! basin-average parameters +! bvarStruct, & ! basin-average variables +! ! ancillary data structures +! dparStruct, & ! default model parameters +! startTime, & ! start time for the model simulation +! finshTime, & ! end time for the model simulation +! refTime, & ! reference time for the model simulation +! oldTime, & ! time for the previous model time step +! ! miscellaneous variables +! err, message) + +! if(err/=0)then +! message=trim(message) +! print*, message +! endif + +! end subroutine Initialize ! ********************************************************************************************************** ! public subroutine SetupParam: initializes parameter data structures (e.g. vegetation and soil parameters). diff --git a/build/source/actors/hru_actor/hru_actor.cpp b/build/source/actors/hru_actor/hru_actor.cpp index 300c978..50605b7 100644 --- a/build/source/actors/hru_actor/hru_actor.cpp +++ b/build/source/actors/hru_actor/hru_actor.cpp @@ -190,7 +190,7 @@ 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, + summaActors_initialize(&self->state.indxGRU, &self->state.num_steps, self->state.handle_forcStat, self->state.handle_progStat, @@ -214,7 +214,9 @@ void Initialize_HRU(stateful_actor<hru_state>* self) { self->state.handle_startTime, self->state.handle_finshTime, self->state.handle_refTime, - self->state.handle_oldTime, &self->state.err); + self->state.handle_oldTime, + &self->state.err); + if (self->state.err != 0) { aout(self) << "Error: Initialize - HRU = " << self->state.indxHRU << diff --git a/build/source/driver/summaActors_init.f90 b/build/source/driver/summaActors_init.f90 index 99b6872..c95de9d 100755 --- a/build/source/driver/summaActors_init.f90 +++ b/build/source/driver/summaActors_init.f90 @@ -1,5 +1,6 @@ -module summa4chm_init +module summaActors_init ! used to declare and allocate summa data structures and initialize model state to known values +USE,intrinsic :: iso_c_binding USE nrtype ! variable types, etc. USE data_types,only:& ! no spatial dimension @@ -33,44 +34,44 @@ USE var_lookup,only:maxVarFreq ! # of available ou ! safety: set private unless specified otherwise implicit none private -public::summa4chm_initialize +public::summaActors_initialize contains ! used to declare and allocate summa data structures and initialize model state to known values - subroutine summa4chm_initialize(& + subroutine summaActors_initialize(& indxGRU, & ! Index of HRU's GRU parent num_steps, & ! statistics structures - forcStat, & ! model forcing data - progStat, & ! model prognostic (state) variables - diagStat, & ! model diagnostic variables - fluxStat, & ! model fluxes - indxStat, & ! model indices - bvarStat, & ! basin-average variables + handle_forcStat, & ! model forcing data + handle_progStat, & ! model prognostic (state) variables + handle_diagStat, & ! model diagnostic variables + handle_fluxStat, & ! model fluxes + handle_indxStat, & ! model indices + handle_bvarStat, & ! basin-average variables ! primary data structures (scalars) - timeStruct, & ! model time data - forcStruct, & ! model forcing data - attrStruct, & ! local attributes for each HRU - typeStruct, & ! local classification of soil veg etc. for each HRU - idStruct, & ! + handle_timeStruct, & ! model time data + handle_forcStruct, & ! model forcing data + handle_attrStruct, & ! local attributes for each HRU + handle_typeStruct, & ! local classification of soil veg etc. for each HRU + handle_idStruct, & ! ! primary data structures (variable length vectors) - indxStruct, & ! model indices - mparStruct, & ! model parameters - progStruct, & ! model prognostic (state) variables - diagStruct, & ! model diagnostic variables - fluxStruct, & ! model fluxes + handle_indxStruct, & ! model indices + handle_mparStruct, & ! model parameters + handle_progStruct, & ! model prognostic (state) variables + handle_diagStruct, & ! model diagnostic variables + handle_fluxStruct, & ! model fluxes ! basin-average structures - bparStruct, & ! basin-average parameters - bvarStruct, & ! basin-average variables + handle_bparStruct, & ! basin-average parameters + handle_bvarStruct, & ! basin-average variables ! ancillary data structures - dparStruct, & ! default model parameters + handle_dparStruct, & ! default model parameters ! local HRU data structures - startTime_hru, & ! start time for the model simulation - finishTime_hru, & ! end time for the model simulation - refTime_hru, & ! reference time for the model simulation - oldTime_hru, & ! time from previous step + handle_startTime, & ! start time for the model simulation + handle_finshTime, & ! end time for the model simulation + handle_refTime, & ! reference time for the model simulation + handle_oldTime, & ! time for the previous model time step ! miscellaneous variables - err, message) + err) bind(C,name='summaActors_initialize') ! --------------------------------------------------------------------------------------- ! * desired modules ! --------------------------------------------------------------------------------------- @@ -91,51 +92,111 @@ contains USE globalData,only:numtim USE var_lookup,only:maxvarFreq ! maximum number of output files USE globalData,only:startTime,finshTime,refTime,oldTime + + implicit none + ! --------------------------------------------------------------------------------------- - ! * variables + ! * variables from C++ ! --------------------------------------------------------------------------------------- - implicit none - ! dummy variables - integer(i4b),intent(in) :: indxGRU ! indx of the parent GRU - integer(i4b),intent(out) :: num_steps ! number of steps in model, local to the HRU - ! statistics structures - type(var_dlength),intent(inout) :: forcStat ! model forcing data - type(var_dlength),intent(inout) :: progStat ! model prognostic (state) variables - type(var_dlength),intent(inout) :: diagStat ! model diagnostic variables - type(var_dlength),intent(inout) :: fluxStat ! model fluxes - type(var_dlength),intent(inout) :: indxStat ! model indices - type(var_dlength),intent(inout) :: bvarStat ! basin-average variabl + integer(c_int),intent(in) :: indxGRU ! indx of the parent GRU + integer(c_int),intent(out) :: num_steps ! number of steps in model, local to the HRU + ! statistics structures + type(c_ptr), intent(in), value :: handle_forcStat ! model forcing data + type(c_ptr), intent(in), value :: handle_progStat ! model prognostic (state) variables + type(c_ptr), intent(in), value :: handle_diagStat ! model diagnostic variables + type(c_ptr), intent(in), value :: handle_fluxStat ! model fluxes + type(c_ptr), intent(in), value :: handle_indxStat ! model indices + type(c_ptr), intent(in), value :: handle_bvarStat ! basin-average variables ! primary data structures (scalars) - type(var_i),intent(inout) :: timeStruct ! model time data - type(var_d),intent(inout) :: forcStruct ! model forcing data - type(var_d),intent(inout) :: attrStruct ! local attributes for each HRU - type(var_i),intent(inout) :: typeStruct ! local classification of soil veg etc. for each HRU - type(var_i8),intent(inout) :: idStruct ! + type(c_ptr), intent(in), value :: handle_timeStruct ! model time data + type(c_ptr), intent(in), value :: handle_forcStruct ! model forcing data + type(c_ptr), intent(in), value :: handle_attrStruct ! local attributes for each HRU + type(c_ptr), intent(in), value :: handle_typeStruct ! local classification of soil veg etc. for each HRU + type(c_ptr), intent(in), value :: handle_idStruct ! ! primary data structures (variable length vectors) - type(var_ilength),intent(inout) :: indxStruct ! model indices - type(var_dlength),intent(inout) :: mparStruct ! model parameters - type(var_dlength),intent(inout) :: progStruct ! model prognostic (state) variables - type(var_dlength),intent(inout) :: diagStruct ! model diagnostic variables - type(var_dlength),intent(inout) :: fluxStruct ! model fluxes + type(c_ptr), intent(in), value :: handle_indxStruct ! model indices + type(c_ptr), intent(in), value :: handle_mparStruct ! model parameters + type(c_ptr), intent(in), value :: handle_progStruct ! model prognostic (state) variables + type(c_ptr), intent(in), value :: handle_diagStruct ! model diagnostic variables + type(c_ptr), intent(in), value :: handle_fluxStruct ! model fluxes ! basin-average structures - type(var_d),intent(inout) :: bparStruct ! basin-average parameters - type(var_dlength),intent(inout) :: bvarStruct ! basin-average variables + type(c_ptr), intent(in), value :: handle_bparStruct ! basin-average parameters + type(c_ptr), intent(in), value :: handle_bvarStruct ! basin-average variables ! ancillary data structures - type(var_d),intent(inout) :: dparStruct ! default model parameters + type(c_ptr), intent(in), value :: handle_dparStruct ! default model parameters + ! local hru data structures + type(c_ptr), intent(in), value :: handle_startTime ! start time for the model simulation + type(c_ptr), intent(in), value :: handle_finshTime ! end time for the model simulation + type(c_ptr), intent(in), value :: handle_refTime ! reference time for the model simulation + type(c_ptr), intent(in), value :: handle_oldTime ! time for the previous model time step + integer(c_int),intent(inout) :: err + ! --------------------------------------------------------------------------------------- + ! * Fortran Variables For Conversion + ! --------------------------------------------------------------------------------------- + type(var_dlength),pointer :: forcStat ! model forcing data + type(var_dlength),pointer :: progStat ! model prognostic (state) variables + type(var_dlength),pointer :: diagStat ! model diagnostic variables + type(var_dlength),pointer :: fluxStat ! model fluxes + type(var_dlength),pointer :: indxStat ! model indices + type(var_dlength),pointer :: bvarStat ! basin-average variabl + ! primary data structures (scalars) + type(var_i),pointer :: timeStruct ! model time data + type(var_d),pointer :: forcStruct ! model forcing data + type(var_d),pointer :: attrStruct ! local attributes for each HRU + type(var_i),pointer :: typeStruct ! local classification of soil veg etc. for each HRU + type(var_i8),pointer :: idStruct ! + ! primary data structures (variable length vectors) + type(var_ilength),pointer :: indxStruct ! model indices + type(var_dlength),pointer :: mparStruct ! model parameters + type(var_dlength),pointer :: progStruct ! model prognostic (state) variables + type(var_dlength),pointer :: diagStruct ! model diagnostic variables + type(var_dlength),pointer :: fluxStruct ! model fluxes + ! basin-average structures + type(var_d),pointer :: bparStruct ! basin-average parameters + type(var_dlength),pointer :: bvarStruct ! basin-average variables + ! ancillary data structures + type(var_d),pointer :: dparStruct ! default model parameters ! local HRU data structures - type(var_i),intent(inout) :: startTime_hru ! start time for the model simulation - type(var_i),intent(inout) :: finishTime_hru ! end time for the model simulation - type(var_i),intent(inout) :: refTime_hru ! reference time for the model simulation - type(var_i),intent(inout) :: oldTime_hru ! time from previous step - ! misc variables - integer(i4b),intent(out) :: err ! error code - character(*),intent(out) :: message ! error message - ! local variables + type(var_i),pointer :: startTime_hru ! start time for the model simulation + type(var_i),pointer :: finishTime_hru ! end time for the model simulation + type(var_i),pointer :: refTime_hru ! reference time for the model simulation + type(var_i),pointer :: oldTime_hru ! time from previous step + ! --------------------------------------------------------------------------------------- + ! * Local Subroutine Variables + ! --------------------------------------------------------------------------------------- + character(LEN=256) :: message ! error message character(LEN=256) :: cmessage ! error message of downwind routine integer(i4b) :: iStruct ! looping variables + ! --------------------------------------------------------------------------------------- + ! * Convert From C++ to Fortran + ! --------------------------------------------------------------------------------------- + call c_f_pointer(handle_forcStat, forcStat) + call c_f_pointer(handle_progStat, progStat) + call c_f_pointer(handle_diagStat, diagStat) + call c_f_pointer(handle_fluxStat, fluxStat) + call c_f_pointer(handle_indxStat, indxStat) + call c_f_pointer(handle_bvarStat, bvarStat) + call c_f_pointer(handle_timeStruct, timeStruct) + call c_f_pointer(handle_forcStruct, forcStruct) + call c_f_pointer(handle_attrStruct, attrStruct) + call c_f_pointer(handle_typeStruct, typeStruct) + call c_f_pointer(handle_idStruct, idStruct) + call c_f_pointer(handle_indxStruct, indxStruct) + call c_f_pointer(handle_mparStruct, mparStruct) + call c_f_pointer(handle_progStruct, progStruct) + call c_f_pointer(handle_diagStruct, diagStruct) + call c_f_pointer(handle_fluxStruct, fluxStruct) + call c_f_pointer(handle_bparStruct, bparStruct) + call c_f_pointer(handle_bvarStruct, bvarStruct) + call c_f_pointer(handle_dparStruct, dparStruct) + call c_f_pointer(handle_startTime, startTime_hru) + call c_f_pointer(handle_finshTime, finishTime_hru) + call c_f_pointer(handle_refTime, refTime_hru) + call c_f_pointer(handle_oldTime, oldTime_hru) + ! --------------------------------------------------------------------------------------- ! initialize error control - err=0; message='summa4chm_initialize/' + err=0; message='summaActors_initialize/' ! initialize the start of the initialization call date_and_time(values=startInit) @@ -237,6 +298,6 @@ contains ! end association to info in data structures end associate - end subroutine summa4chm_initialize + end subroutine summaActors_initialize -end module summa4chm_init +end module summaActors_init diff --git a/build/source/netcdf/writeOutput.f90 b/build/source/netcdf/writeOutput.f90 index 7ce8d7d..f37dfa0 100644 --- a/build/source/netcdf/writeOutput.f90 +++ b/build/source/netcdf/writeOutput.f90 @@ -160,7 +160,6 @@ subroutine writeData(ncid,outputTimestep,outputTimestepUpdate,maxLayers,indxGRU, USE var_lookup,only:iLookStat ! index into stat structure USE globalData,only:outFreq ! output file information USE globalData,only:outputStructure - USE globalData,only:gru_struc USE globalData,only:failedHRUs USE get_ixName_module,only:get_varTypeName ! to access type strings for error messages USE get_ixName_module,only:get_statName ! to access type strings for error messages @@ -185,7 +184,6 @@ subroutine writeData(ncid,outputTimestep,outputTimestepUpdate,maxLayers,indxGRU, integer(i4b) ,intent(out) :: err ! error code character(*) ,intent(out) :: message ! error message ! local variables - integer(i4b) :: iHRU integer(i4b) :: iVar ! variable index integer(i4b) :: iStat ! statistics index integer(i4b) :: iFreq ! frequency index @@ -208,7 +206,6 @@ subroutine writeData(ncid,outputTimestep,outputTimestepUpdate,maxLayers,indxGRU, integer(i4b) :: iStep integer(i4b) :: iGRU integer(i4b) :: verifiedGRUIndex ! index of HRU verified to not have failed - integer(i4b) :: verifiedStepCounter ! numStepsForStepCounter from HRU that did not fail ! initialize error control err=0;message="writeData/" ! loop through output frequencies diff --git a/utils/Summa_Actors_Settings_backup.json b/utils/Summa_Actors_Settings_backup.json new file mode 100644 index 0000000..b6f659b --- /dev/null +++ b/utils/Summa_Actors_Settings_backup.json @@ -0,0 +1,32 @@ +{ + "DistributedSettings": { + "distributed-mode": true, + "host": "simlab03", + "port": 4444 + }, + + "SimulationSettings": { + "total_hru_count": 100, + "num_hru_per_batch": 20 + }, + + "SummaActor": { + "OuputStructureSize": 250, + "maxGRUPerJob": 20 + }, + + "FileAccessActor": { + "num_vectors_in_output_manager": 1 + }, + + "JobActor": { + "FileManagerPath": "/gladwell/SummaActorsSettings/fileManager.txt", + "outputCSV": false, + "csvPath": "" + }, + + "HRUActor": { + "printOutput": true, + "outputFrequency": 500 + } + } \ No newline at end of file -- GitLab