diff --git a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp index 577b3f2ebc15385db58f588f47a2b5e89de10fcd..9ffdece737faab27373735d56346926a8be30a15 100644 --- a/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp +++ b/build/includes/hru_actor/hru_actor_subroutine_wrappers.hpp @@ -18,8 +18,18 @@ extern "C" { void* startTime, void* finshTime, void* refTime, void* oldTime, int* err); // SetupParam for HRU - void SetupParam( - int* indxGRU, int* indxHRU, + // void SetupParam( + // int* indxGRU, int* indxHRU, + // // primary data structures (scalars) + // void* attrStruct, void* typeStruct, void* idStruct, + // // primary data structures (variable length vectors) + // void* mparStruct, void* bparStruct, void* bvarStruct, void* dparStruct, + // // local HRU data + // void* startTime, void* oldTime, + // // miscellaneous + // double* upArea, int* err); + + void setupHRUParam( int* indxGRU, int* indxHRU, // primary data structures (scalars) void* attrStruct, void* typeStruct, void* idStruct, // primary data structures (variable length vectors) diff --git a/build/source/actors/hru_actor/cppwrap_hru.f90 b/build/source/actors/hru_actor/cppwrap_hru.f90 index 11b27e42a0427b2f57d6d7aa5cccdd225395d9d2..cf2ff5491f9066f66bd35a7eeca58f77c46da69e 100644 --- a/build/source/actors/hru_actor/cppwrap_hru.f90 +++ b/build/source/actors/hru_actor/cppwrap_hru.f90 @@ -39,7 +39,7 @@ subroutine SetupParam(& upArea, & ! area upslope of each HRU, err) bind(C,name='SetupParam') - USE SummaActors_setup,only:SummaActors_paramSetup + ! USE SummaActors_setup,only:SummaActors_paramSetup implicit none ! calling variables @@ -81,28 +81,28 @@ subroutine SetupParam(& call c_f_pointer(handle_startTime, startTime) call c_f_pointer(handle_oldTime, oldTime) - call SummaActors_paramSetup(& - indxHRU, & ! ID of hru to obtain from netcdf file - indxGRU, & ! Index of the parent GRU of the HRU - ! primary data structures (scalars) - attrStruct, & ! local attributes for each HRU - typeStruct, & ! local classification of soil veg etc. for each HRU - idStruct, & ! local classification of soil veg etc. for each HRU - ! primary data structures (variable length vectors) - mparStruct, & ! model parameters - bparStruct, & ! basin-average parameters - bvarStruct, & ! basin-average variables - dparStruct, & ! default model parameters - ! local HRU data - startTime, & ! start time for the model simulation - oldTime, & ! time for the previous model time step - ! miscellaneous variables - upArea, & ! area upslope of each HRU, - err, message) - if(err/=0)then - message=trim(message) - print*, message - endif + ! call SummaActors_paramSetup(& + ! indxHRU, & ! ID of hru to obtain from netcdf file + ! indxGRU, & ! Index of the parent GRU of the HRU + ! ! primary data structures (scalars) + ! attrStruct, & ! local attributes for each HRU + ! typeStruct, & ! local classification of soil veg etc. for each HRU + ! idStruct, & ! local classification of soil veg etc. for each HRU + ! ! primary data structures (variable length vectors) + ! mparStruct, & ! model parameters + ! bparStruct, & ! basin-average parameters + ! bvarStruct, & ! basin-average variables + ! dparStruct, & ! default model parameters + ! ! local HRU data + ! startTime, & ! start time for the model simulation + ! oldTime, & ! time for the previous model time step + ! ! miscellaneous variables + ! upArea, & ! area upslope of each HRU, + ! err, message) + ! if(err/=0)then + ! message=trim(message) + ! print*, message + ! endif end subroutine SetupParam diff --git a/build/source/actors/hru_actor/hru_actor.cpp b/build/source/actors/hru_actor/hru_actor.cpp index 90b60db61a71e33454bc90879e4f4324e14342ae..5ffd04c58aace16b74586a90466d2d206ac7a096 100644 --- a/build/source/actors/hru_actor/hru_actor.cpp +++ b/build/source/actors/hru_actor/hru_actor.cpp @@ -188,7 +188,7 @@ void Initialize_HRU(stateful_actor<hru_state>* self) { return; } - SetupParam(&self->state.indxGRU, + setupHRUParam(&self->state.indxGRU, &self->state.indxHRU, self->state.handle_attrStruct, self->state.handle_typeStruct, diff --git a/build/source/driver/SummaActors_setup.f90 b/build/source/driver/SummaActors_setup.f90 index 3917cf0c8815fd9b6ce95458c41fd0dafef03e55..03a5d916dd334198179ccc6910f81e81b9bae8cc 100755 --- a/build/source/driver/SummaActors_setup.f90 +++ b/build/source/driver/SummaActors_setup.f90 @@ -19,6 +19,8 @@ ! along with this program. If not, see <http://www.gnu.org/licenses/>. module SummaActors_setup +USE,intrinsic :: iso_c_binding + ! initializes parameter data structures (e.g. vegetation and soil parameters). USE data_types,only:& @@ -58,29 +60,29 @@ USE mDecisions_module,only:& ! safety: set private unless specified otherwise implicit none private -public::SummaActors_paramSetup +public::setupHRUParam public::SOIL_VEG_GEN_PARM contains ! initializes parameter data structures (e.g. vegetation and soil parameters). - subroutine SummaActors_paramSetup(& + subroutine setupHRUParam(& indxHRU, & ! ID of hru indxGRU, & ! Index of the parent GRU of the HRU ! primary data structures (scalars) - attrStruct, & ! local attributes for each HRU - typeStruct, & ! local classification of soil veg etc. for each HRU - idStruct, & ! local classification of soil veg etc. for each HRU + handle_attrStruct, & ! local attributes for each HRU + handle_typeStruct, & ! local classification of soil veg etc. for each HRU + handle_idStruct, & ! local classification of soil veg etc. for each HRU ! primary data structures (variable length vectors) - mparStruct, & ! model parameters - bparStruct, & ! basin-average parameters - bvarStruct, & ! basin-average variables - dparStruct, & ! default model parameters + handle_mparStruct, & ! model parameters + handle_bparStruct, & ! basin-average parameters + handle_bvarStruct, & ! basin-average variables + handle_dparStruct, & ! default model parameters ! local HRU data - startTime, & ! start time for the model simulation - oldTime, & ! time for the previous model time step + handle_startTime, & ! start time for the model simulation + handle_oldTime, & ! time for the previous model time step ! miscellaneous variables upArea, & ! area upslope of each HRU, - err, message) + err) bind(C, name='setupHRUParam') ! --------------------------------------------------------------------------------------- ! * desired modules ! --------------------------------------------------------------------------------------- @@ -126,29 +128,53 @@ contains ! --------------------------------------------------------------------------------------- implicit none ! dummy variables - integer(i4b),intent(in) :: indxHRU ! ID of HRU - integer(i4b),intent(in) :: indxGRU ! Index of the parent GRU of the HRU - 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(var_dlength),intent(inout) :: mparStruct ! model parameters - type(var_d),intent(inout) :: bparStruct ! basin-average parameters - type(var_dlength),intent(inout) :: bvarStruct ! basin-average variables - type(var_d),intent(inout) :: dparStruct ! default model parameter - type(var_i),intent(inout) :: startTime ! start time for the model simulation - type(var_i),intent(inout) :: oldTime ! time for the previous model time step - real(dp),intent(inout) :: upArea ! area upslope of each HRU - integer(i4b),intent(out) :: err ! error code - character(*),intent(out) :: message ! error message + ! calling variables + integer(c_int),intent(in) :: indxGRU ! Index of the parent GRU of the HRU + integer(c_int),intent(in) :: indxHRU ! ID to locate correct HRU from netcdf file + 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 ! + type(c_ptr), intent(in), value :: handle_mparStruct ! model parameters + type(c_ptr), intent(in), value :: handle_bparStruct ! basin-average parameters + type(c_ptr), intent(in), value :: handle_bvarStruct ! basin-average variables + type(c_ptr), intent(in), value :: handle_dparStruct ! default model parameters + type(c_ptr), intent(in), value :: handle_startTime ! start time for the model simulation + type(c_ptr), intent(in), value :: handle_oldTime ! time for the previous model time step + real(c_double),intent(inout) :: upArea + integer(c_int),intent(inout) :: err + ! local variables + 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 ! + type(var_dlength),pointer :: mparStruct ! model parameters + type(var_d),pointer :: bparStruct ! basin-average parameters + type(var_dlength),pointer :: bvarStruct ! basin-average variables + type(var_d),pointer :: dparStruct ! default model parameters + type(var_i),pointer :: startTime ! start time for the model simulation + type(var_i),pointer :: oldTime ! time for the previous model time step + character(len=256) :: message ! error message character(len=256) :: cmessage ! error message of downwind routine character(len=256) :: attrFile ! attributes file name integer(i4b) :: iVar ! looping variables ! --------------------------------------------------------------------------------------- ! initialize error control - err=0; message='hru_paramSetup/' + err=0; message='setupHRUParam/' ! initialize the start of the initialization call date_and_time(values=startSetup) + + ! convert to fortran pointer from C++ pointer + 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_mparStruct, mparStruct) + 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_oldTime, oldTime) + + ! ffile_info and mDecisions moved to their own seperate subroutine call @@ -268,7 +294,7 @@ contains ! aggregate the elapsed time for the initialization elapsedSetup = elapsedSec(startSetup, endSetup) - end subroutine SummaActors_paramSetup + end subroutine setupHRUParam ! =================================================================================================