diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt index b683b909dd3cb24d9a6ed354d32c5234659a6ab2..19a479fe14e88c5298775efa142b9bdf89877547 100644 --- a/build/cmake/CMakeLists.txt +++ b/build/cmake/CMakeLists.txt @@ -27,11 +27,11 @@ set(CMAKE_CONFIGURATION_TYPES Debug Release Cluster Cluster_Debug) # Set compiler flags if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES Cluster_Debug) - message("Debug build.") - add_definitions(-DDEBUG) - set(SUMMA_NOAHMP_OPTIONS -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) - set(SUMMA_ALL_OPTIONS -g -O0 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) - set(CMAKE_CXX_FLAGS "-g -O0 -Wfatal-errors -std=c++17") + message("Debug build.") + add_definitions(-DDEBUG) + set(SUMMA_NOAHMP_OPTIONS -g -O0 -ffree-form -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) + set(SUMMA_ALL_OPTIONS -g -O0 -ffree-line-length-none -fmax-errors=0 -fPIC -Wfatal-errors) + set(CMAKE_CXX_FLAGS "-g -O0 -Wfatal-errors -std=c++17") else() message("Release build.") add_definitions(-DNDEBUG) @@ -327,9 +327,9 @@ if (SUNDIALS) ${JOB_ACTOR_DIR}/job_actor.f90) set(HRU_INTERFACE - ${HRU_ACTOR_DIR}/fortran_code/cppwrap_hru.f90 ${HRU_ACTOR_DIR}/fortran_code/model_run.f90 ${HRU_ACTOR_DIR}/fortran_code/setup_hru.f90 + ${HRU_ACTOR_DIR}/fortran_code/restart.f90 ${HRU_ACTOR_DIR}/fortran_code/hru_actor.f90 ${HRU_ACTOR_DIR}/fortran_code/init_hru_actor.f90 ${HRU_ACTOR_DIR}/fortran_code/outputStrucWrite.f90 @@ -383,7 +383,6 @@ if (SUNDIALS) ${DRIVER_DIR}/summaActors_type.f90 ${DRIVER_DIR}/summaActors_util.f90 ${DRIVER_DIR}/summaActors_globalData.f90 - ${DRIVER_DIR}/summaActors_restart.f90 ${DRIVER_DIR}/summaActors_alarms.f90) set(COMM_ALL @@ -454,12 +453,7 @@ if (SUNDIALS) target_include_directories(summa PUBLIC ${SUMMA_INCLUDES}) target_link_libraries(summa PUBLIC ${SUMMA_LIBS} SUMMA_COMM) - - - - - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXEC_DIR}) - + # Build Summa-Actors executable add_executable(${EXEC_NAME} ${ACTORS_GLOBAL} ${HRU_ACTOR} @@ -563,9 +557,9 @@ else() ${JOB_ACTOR_DIR}/job_actor.f90) set(HRU_INTERFACE - ${HRU_ACTOR_DIR}/fortran_code/cppwrap_hru.f90 ${HRU_ACTOR_DIR}/fortran_code/model_run.f90 ${HRU_ACTOR_DIR}/fortran_code/setup_hru.f90 + ${HRU_ACTOR_DIR}/fortran_code/restart.f90 ${HRU_ACTOR_DIR}/fortran_code/hru_actor.f90 ${HRU_ACTOR_DIR}/fortran_code/init_hru_actor.f90 ${HRU_ACTOR_DIR}/fortran_code/outputStrucWrite.f90 @@ -621,7 +615,6 @@ else() ${DRIVER_DIR}/summaActors_type.f90 ${DRIVER_DIR}/summaActors_util.f90 ${DRIVER_DIR}/summaActors_globalData.f90 - ${DRIVER_DIR}/summaActors_restart.f90 ${DRIVER_DIR}/summaActors_alarms.f90) set(COMM_ALL @@ -696,8 +689,7 @@ else() target_compile_options(summa PRIVATE ${SUMMA_ALL_OPTIONS}) target_include_directories(summa PUBLIC ${SUMMA_INCLUDES}) target_link_libraries(summa PUBLIC ${SUMMA_LIBS} SUMMA_COMM) - - + # Build SUMMA Executable add_executable(${EXEC_NAME} ${ACTORS_GLOBAL} ${HRU_ACTOR} diff --git a/build/source/actors/hru_actor/fortran_code/cppwrap_hru.f90 b/build/source/actors/hru_actor/fortran_code/cppwrap_hru.f90 deleted file mode 100644 index 7ad811f38c85ade923c2ddcccfb2155641c7e310..0000000000000000000000000000000000000000 --- a/build/source/actors/hru_actor/fortran_code/cppwrap_hru.f90 +++ /dev/null @@ -1,215 +0,0 @@ -module cppwrap_hru - -USE,intrinsic :: iso_c_binding -USE nrtype -USE data_types -USE globalData - -implicit none -public::Restart -! public::RunPhysics - -contains - - - -! ********************************************************************************************************** -! public subroutine Restart: -! ********************************************************************************************************** -subroutine Restart(& - indxGRU, & ! index of GRU in gru_struc - indxHRU, & ! index of HRU in gru_struc - ! 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_bvarStruct, & ! basin-average variables - dt_init, & - err) bind(C,name='Restart') - - use summa_restart,only:summa_readRestart - - implicit none - ! calling variables - integer(c_int), intent(in) :: indxGRU ! index of GRU in gru_struc - integer(c_int), intent(in) :: indxHRU ! index of HRU in gru_struc - ! 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_bvarStruct ! basin-average variables - real(c_double), intent(inout) :: dt_init - integer(c_int), intent(inout) :: err - !--------------------------------------------------------------------------------------------------- - ! local variables - - ! define the 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 - ! define the basin-average structures - type(var_dlength),pointer :: bvarStruct ! basin-average variables - character(len=256) :: message - - - ! getting data - 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_bvarStruct, bvarStruct) - - ! define global data (parameters, metadata) - call summa_readRestart(& - indxGRU, & ! index of GRU in gru_struc - indxHRU, & ! index of HRU in gru_struc - ! primary data structures (variable length vectors) - indxStruct, & ! x%var(:)%dat -- model indices - mparStruct, & ! x%var(:)%dat -- model parameters - progStruct, & ! x%var(:)%dat -- model prognostic (state) variables - diagStruct, & ! x%var(:)%dat -- model diagnostic variables - fluxStruct, & ! x%var(:)%dat -- model fluxes - ! basin-average structures - bvarStruct, & ! x%var(:)%dat -- basin-average variables - dt_init, & ! used to initialize the length of the sub-step for each HRU - err, message) - - if(err/=0)then - message=trim(message) - print*, message - endif - -end subroutine Restart - -! ********************************************************************************************************** -! public subroutine RunPhysics: solving coupled energy-mass equations for one timestep -! ********************************************************************************************************** -! subroutine RunPhysics(& -! indxHRU, & -! step_index, & -! ! primary data structures (scalars) -! handle_timeStruct, & ! x%var(:) -- model time data -! handle_forcStruct, & ! x%var(:) -- model forcing data -! handle_attrStruct, & ! x%var(:) -- local attributes for each HRU -! handle_typeStruct, & ! x%var(:) -- local classification of soil veg etc. for each HRU -! ! primary data structures (variable length vectors) -! handle_indxStruct, & ! x%var(:)%dat -- model indices -! handle_mparStruct, & ! x%var(:)%dat -- model parameters -! handle_progStruct, & ! x%var(:)%dat -- model prognostic (state) variables -! handle_diagStruct, & ! x%var(:)%dat -- model diagnostic variables -! handle_fluxStruct, & ! x%var(:)%dat -- model fluxes -! ! basin-average structures -! handle_bvarStruct, & ! x%var(:)%dat -- basin-average variables -! handle_lookupStruct, & -! fracJulDay, & -! tmZoneOffsetFracDay, & -! yearLength, & -! ! run time variables -! computeVegFlux, & ! flag to indicate if we are computing fluxes over vegetation -! dt_init, & ! used to initialize the length of the sub-step for each HRU -! dt_init_factor, & ! Used to adjust the length of the timestep in the event of a failure -! err) bind(C, name='RunPhysics') - -! USE SummaActors_modelRun,only:SummaActors_runPhysics - -! !======= Declarations ========= -! implicit none -! ! calling variables -! integer(c_int), intent(in) :: indxHRU -! integer(c_int), intent(in) :: step_index -! ! 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 -! ! 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_bvarStruct ! basin-average variables -! type(c_ptr), intent(in), value :: handle_lookupStruct ! lookup tables -! real(c_double),intent(inout) :: fracJulDay -! real(c_double),intent(inout) :: tmZoneOffsetFracDay -! integer(c_int),intent(inout) :: yearLength -! integer(c_int),intent(inout) :: computeVegFlux ! flag to indicate if we are computing fluxes over vegetation -! real(c_double),intent(inout) :: dt_init -! integer(c_int),intent(in) :: dt_init_factor ! Used to adjust the length of the timestep in the event of a failure -! integer(c_int), intent(out) :: err - -! ! local variables -! ! 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 -! ! 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_dlength),pointer :: bvarStruct ! basin-average variables -! type(zLookup), pointer :: lookupStruct ! lookup tables -! character(len=256) :: message - -! 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_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_bvarStruct, bvarStruct) -! call c_f_pointer(handle_lookupStruct, lookupStruct) - - -! call SummaActors_runPhysics(& -! indxHRU, & -! step_index, & -! ! primary data structures (scalars) -! timeStruct, & ! x%var(:) -- model time data -! forcStruct, & ! x%var(:) -- model forcing data -! attrStruct, & ! x%var(:) -- local attributes for each HRU -! typeStruct, & ! x%var(:) -- local classification of soil veg etc. for each HRU -! ! primary data structures (variable length vectors) -! indxStruct, & ! x%var(:)%dat -- model indices -! mparStruct, & ! x%var(:)%dat -- model parameters -! progStruct, & ! x%var(:)%dat -- model prognostic (state) variables -! diagStruct, & ! x%var(:)%dat -- model diagnostic variables -! fluxStruct, & ! x%var(:)%dat -- model fluxes -! ! basin-average structures -! bvarStruct, & ! x%var(:)%dat -- basin-average variables -! lookupStruct, & -! fracJulDay, & -! tmZoneOffsetFracDay, & -! yearLength, & -! ! run time variables -! computeVegFlux, & ! flag to indicate if we are computing fluxes over vegetation -! dt_init, & ! used to initialize the length of the sub-step for each HRU -! dt_init_factor, & ! Used to adjust the length of the timestep in the event of a failure -! err, message) - -! if(err/=0)then -! message=trim(message) -! print*, message -! endif - -! end subroutine RunPhysics - - -end module cppwrap_hru \ No newline at end of file diff --git a/build/source/actors/hru_actor/fortran_code/restart.f90 b/build/source/actors/hru_actor/fortran_code/restart.f90 new file mode 100644 index 0000000000000000000000000000000000000000..44324a5a4f3ef4cd8cc3b59cfdf6cac2e9b633f5 --- /dev/null +++ b/build/source/actors/hru_actor/fortran_code/restart.f90 @@ -0,0 +1,249 @@ +! SUMMA - Structure for Unifying Multiple Modeling Alternatives +! Copyright (C) 2014-2020 NCAR/RAL; University of Saskatchewan; University of Washington +! +! This file is part of SUMMA +! +! For more information see: http://www.ral.ucar.edu/projects/summa +! +! This program is free software: you can redistribute it and/or modify +! it under the terms of the GNU General Public License as published by +! the Free Software Foundation, either version 3 of the License, or +! (at your option) any later version. +! +! This program is distributed in the hope that it will be useful, +! but WITHOUT ANY WARRANTY; without even the implied warranty of +! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +! GNU General Public License for more details. +! +! You should have received a copy of the GNU General Public License +! along with this program. If not, see <http://www.gnu.org/licenses/>. + +module summa_restart +! read restart data and reset the model state +USE,intrinsic :: iso_c_binding + + +USE data_types,only:& + ! no spatial dimension + var_i, & ! x%var(:) (i4b) + var_i8, & ! x%var(:) (i8b) + var_d, & ! x%var(:) (dp) + var_ilength, & ! x%var(:)%dat (i4b) + var_dlength ! x%var(:)%dat (dp) + +! access missing values +USE globalData,only:integerMissing ! missing integer +USE globalData,only:realMissing ! missing double precision number + +! named variables +USE var_lookup,only:iLookPROG ! look-up values for local column model prognostic (state) variables +USE var_lookup,only:iLookDIAG ! look-up values for local column model diagnostic variables +USE var_lookup,only:iLookFLUX ! look-up values for local column model fluxes +USE var_lookup,only:iLookBVAR ! look-up values for basin-average model variables +USE var_lookup,only:iLookDECISIONS ! look-up values for model decisions + +! safety: set private unless specified otherwise +implicit none +private +public::Restart +contains + +! read restart data and reset the model state +subroutine Restart(& + indxGRU, & ! index of GRU in gru_struc + indxHRU, & ! index of HRU in gru_struc + ! primary data structures (variable length vectors) + handle_indxStruct, & ! c_ptr to -- model indices + handle_mparStruct, & ! c_ptr to -- model parameters + handle_progStruct, & ! c_ptr to -- model prognostic (state) variables + handle_diagStruct, & ! c_ptr to -- model diagnostic variables + handle_fluxStruct, & ! c_ptr to -- model fluxes + ! basin-average structures + handle_bvarStruct, & ! x%var(:)%dat -- basin-average variables + dt_init, & ! used to initialize the length of the sub-step for each HRU + err) bind(C,name='Restart') + ! --------------------------------------------------------------------------------------- + ! * desired modules + ! --------------------------------------------------------------------------------------- + ! data types + USE nrtype ! variable types, etc. + ! functions and subroutines + USE time_utils_module,only:elapsedSec ! calculate the elapsed time + USE read_icond_gru_hru_module,only:read_icond ! module to read initial conditions + USE check_icond4chm_module,only:check_icond4chm ! module to check initial conditions + USE var_derive_module,only:calcHeight ! module to calculate height at layer interfaces and layer mid-point + USE var_derive_module,only:v_shortcut ! module to calculate "short-cut" variables + USE var_derive_module,only:rootDensty ! module to calculate the vertical distribution of roots + USE var_derive_module,only:satHydCond ! module to calculate the saturated hydraulic conductivity in each soil layer + ! global data structures + USE globalData,only:model_decisions ! model decision structure + ! timing variables + USE globalData,only:startRestart,endRestart ! date/time for the start and end of reading model restart files + USE globalData,only:elapsedRestart ! elapsed time to read model restart files + ! model decisions + USE mDecisions_module,only:& ! look-up values for the choice of method for the spatial representation of groundwater + localColumn, & ! separate groundwater representation in each local soil column + singleBasin ! single groundwater store over the entire basin + implicit none + ! --------------------------------------------------------------------------------------- + ! Dummy variables + ! --------------------------------------------------------------------------------------- + integer(c_int),intent(in) :: indxGRU ! index of GRU in gru_struc + integer(c_int),intent(in) :: indxHRU ! index of HRU in gru_struc + ! 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 + ! define the basin-average structures + type(c_ptr), intent(in), value :: handle_bvarStruct ! basin-average variables + real(c_double), intent(inout) :: dt_init + integer(c_int), intent(inout) :: err + ! --------------------------------------------------------------------------------------- + ! Fortran Pointers + ! --------------------------------------------------------------------------------------- + ! 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 + ! define the basin-average structures + type(var_dlength),pointer :: bvarStruct ! basin-average variables + ! --------------------------------------------------------------------------------------- + ! local variables + ! --------------------------------------------------------------------------------------- + character(len=256) :: message ! error message + character(LEN=256) :: cmessage ! error message of downwind routine + character(LEN=256) :: restartFile ! restart file name + integer(i4b) :: nGRU + ! --------------------------------------------------------------------------------------- + + ! ############################################################################# + 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_bvarStruct, bvarStruct) + ! ############################################################################# + + ! initialize error control + err=0; message='hru_actor_readRestart/' + nGRU = 1 + + ! ***************************************************************************** + ! *** read/check initial conditions + ! ***************************************************************************** + ! read initial conditions + call read_icond(& + indxGRU, & ! intent(in): index of GRU in gru_struc + indxHRU, & ! intent(in): index of HRU in gru_struc + mparStruct, & ! intent(in): model parameters + progStruct, & ! intent(inout): model prognostic variables + bvarStruct, & ! intent(inout): model basin (GRU) variables + indxStruct, & ! intent(inout): model indices + err,cmessage) ! intent(out): error control + if(err/=0)then; message=trim(message)//trim(cmessage); return; endif + + ! check initial conditions + call check_icond4chm(& + indxGRU, & ! intent(in): index of GRU in gru_struc + indxHRU, & ! intent(in): index of HRU in gru_struc + progStruct, & ! intent(in): model prognostic (state) variables + mparStruct, & ! intent(in): model parameters + indxStruct, & ! intent(in): layer indexes + err,cmessage) ! intent(out): error control + if(err/=0)then; message=trim(message)//trim(cmessage); return; endif + + + ! ***************************************************************************** + ! *** compute ancillary variables + ! ***************************************************************************** + + ! re-calculate height of each layer + call calcHeight(indxStruct, & ! layer type + progStruct, & ! model prognostic (state) variables for a local HRU + err,cmessage) ! error control + if(err/=0)then; message=trim(message)//trim(cmessage); return; endif + + ! calculate vertical distribution of root density + call rootDensty(mparStruct, & ! vector of model parameters + indxStruct, & ! data structure of model indices + progStruct, & ! data structure of model prognostic (state) variables + diagStruct, & ! data structure of model diagnostic variables + err,cmessage) ! error control + if(err/=0)then; message=trim(message)//trim(cmessage); return; endif + + ! calculate saturated hydraulic conductivity in each soil layer + call satHydCond(mparStruct, & ! vector of model parameters + indxStruct, & ! data structure of model indices + progStruct, & ! data structure of model prognostic (state) variables + fluxStruct, & ! data structure of model fluxes + err,cmessage) ! error control + if(err/=0)then; message=trim(message)//trim(cmessage); return; endif + + ! calculate "short-cut" variables such as volumetric heat capacity + call v_shortcut(mparStruct, & ! vector of model parameters + diagStruct, & ! data structure of model diagnostic variables + err,cmessage) ! error control + if(err/=0)then; message=trim(message)//trim(cmessage); return; endif + + ! initialize canopy drip + ! NOTE: canopy drip from the previous time step is used to compute throughfall for the current time step + fluxStruct%var(iLookFLUX%scalarCanopyLiqDrainage)%dat(1) = 0._dp ! not used + + ! ***************************************************************************** + ! *** initialize aquifer storage + ! ***************************************************************************** + + ! initialize aquifer storage + ! NOTE: this is ugly: need to add capabilities to initialize basin-wide state variables + + ! There are two options for groundwater: + ! (1) where groundwater is included in the local column (i.e., the HRUs); and + ! (2) where groundwater is included for the single basin (i.e., the GRUS, where multiple HRUS drain into a GRU). + + ! For water balance calculations it is important to ensure that the local aquifer storage is zero if groundwater is treated as a basin-average state variable (singleBasin); + ! and ensure that basin-average aquifer storage is zero when groundwater is included in the local columns (localColumn). + + ! select groundwater option + select case(model_decisions(iLookDECISIONS%spatial_gw)%iDecision) + + ! the basin-average aquifer storage is not used if the groundwater is included in the local column + case(localColumn) + bvarStruct%var(iLookBVAR%basin__AquiferStorage)%dat(1) = 0._dp ! set to zero to be clear that there is no basin-average aquifer storage in this configuration + + ! the local column aquifer storage is not used if the groundwater is basin-average + ! (i.e., where multiple HRUs drain to a basin-average aquifer) + case(singleBasin) + bvarStruct%var(iLookBVAR%basin__AquiferStorage)%dat(1) = 1._dp + progStruct%var(iLookPROG%scalarAquiferStorage)%dat(1) = 0._dp ! set to zero to be clear that there is no local aquifer storage in this configuration + + ! error check + case default + message=trim(message)//'unable to identify decision for regional representation of groundwater' + return + + end select ! groundwater option + + ! ***************************************************************************** + ! *** initialize time step + ! ***************************************************************************** + + ! initialize time step length + dt_init = progStruct%var(iLookPROG%dt_init)%dat(1) ! seconds + + + ! ***************************************************************************** + ! *** finalize + ! ***************************************************************************** + +end subroutine Restart + +end module summa_restart + + + + diff --git a/build/unneeded/cppwrap_hru.f90 b/build/unneeded/cppwrap_hru.f90 new file mode 100644 index 0000000000000000000000000000000000000000..0cca5e1abd83c28084b87e8f9220213c1a1f2d2b --- /dev/null +++ b/build/unneeded/cppwrap_hru.f90 @@ -0,0 +1,92 @@ +module cppwrap_hru + +USE,intrinsic :: iso_c_binding +USE nrtype +USE data_types +USE globalData + +implicit none +public::Restart + +contains + + + +! ********************************************************************************************************** +! public subroutine Restart: +! ********************************************************************************************************** +subroutine Restart(& + indxGRU, & ! index of GRU in gru_struc + indxHRU, & ! index of HRU in gru_struc + ! 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_bvarStruct, & ! basin-average variables + dt_init, & + err) bind(C,name='Restart') + + use summa_restart,only:summa_readRestart + + implicit none + ! calling variables + integer(c_int), intent(in) :: indxGRU ! index of GRU in gru_struc + integer(c_int), intent(in) :: indxHRU ! index of HRU in gru_struc + ! 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_bvarStruct ! basin-average variables + real(c_double), intent(inout) :: dt_init + integer(c_int), intent(inout) :: err + !--------------------------------------------------------------------------------------------------- + ! local variables + + ! define the 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 + ! define the basin-average structures + type(var_dlength),pointer :: bvarStruct ! basin-average variables + character(len=256) :: message + + + ! getting data + 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_bvarStruct, bvarStruct) + + ! define global data (parameters, metadata) + call summa_readRestart(& + indxGRU, & ! index of GRU in gru_struc + indxHRU, & ! index of HRU in gru_struc + ! primary data structures (variable length vectors) + indxStruct, & ! x%var(:)%dat -- model indices + mparStruct, & ! x%var(:)%dat -- model parameters + progStruct, & ! x%var(:)%dat -- model prognostic (state) variables + diagStruct, & ! x%var(:)%dat -- model diagnostic variables + fluxStruct, & ! x%var(:)%dat -- model fluxes + ! basin-average structures + bvarStruct, & ! x%var(:)%dat -- basin-average variables + dt_init, & ! used to initialize the length of the sub-step for each HRU + err, message) + + if(err/=0)then + message=trim(message) + print*, message + endif + +end subroutine Restart + +end module cppwrap_hru \ No newline at end of file diff --git a/build/source/driver/summaActors_restart.f90 b/build/unneeded/summaActors_restart.f90 similarity index 100% rename from build/source/driver/summaActors_restart.f90 rename to build/unneeded/summaActors_restart.f90