diff --git a/build/includes/file_access_actor/file_access_actor_subroutine_wrappers.hpp b/build/includes/file_access_actor/file_access_actor_subroutine_wrappers.hpp index 9a75628b64726713bffd31c4282913de1dbb4858..6ad69e8c43376abee91d60ae0e9028ae2c473780 100644 --- a/build/includes/file_access_actor/file_access_actor_subroutine_wrappers.hpp +++ b/build/includes/file_access_actor/file_access_actor_subroutine_wrappers.hpp @@ -10,7 +10,7 @@ extern "C" { void def_output(void* handle_ncid, int* startGRU, int* numGRU, int* numHRU, int* err); void initOutputStructure(void* handle_forcFileInfo, int* max_steps, int* numGRU, int* err); - + void deallocateOutputStructure(int* err); // Attributes Files- called inside initalizeFileAccessActor void allocateAttributeStructures(int* index_gru, int* index_hru, void* handle_attr_struct, @@ -39,7 +39,6 @@ extern "C" { void closeInitCondFile(int* init_cond_ncid, int* err); void readInitCond_prog(int* init_cond_ncid, int* start_gru, int* num_gru, int* err); void readInitCond_bvar(int* init_cond_ncid, int* start_gru, int* num_gru, int* err); - // void readInitCond_Fortran(int* start_gru, int* num_gru, int* err); void updateFailed(int* indxHRU); diff --git a/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp b/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp index 382f0337083d5efe6233e4693d9a93c576fe1044..a48f259dfc0ba7b11621ebbd110acef256110cd4 100644 --- a/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp +++ b/build/source/actors/file_access_actor/cpp_code/file_access_actor.cpp @@ -280,6 +280,7 @@ behavior file_access_actor(stateful_actor<file_access_state>* self, int start_gr [=](deallocate_structures) { aout(self) << "Deallocating Structure" << std::endl; FileAccessActor_DeallocateStructures(self->state.handle_forcing_file_info, self->state.handle_ncid); + deallocateOutputStructure(&self->state.err); aout(self) << "\n________________FILE_ACCESS_ACTOR TIMING INFO RESULTS________________\n"; aout(self) << "Total Read Duration = " << self->state.file_access_timing.getDuration("read_duration").value_or(-1.0) << " Seconds\n"; aout(self) << "Total Write Duration = " << self->state.file_access_timing.getDuration("write_duration").value_or(-1.0) << " Seconds\n"; diff --git a/build/source/actors/file_access_actor/fortran_code/output_structure.f90 b/build/source/actors/file_access_actor/fortran_code/output_structure.f90 index 9e0ba7737f93ce31cb21358734fa3c48d005c244..75bd7805849bb1becc12e1bebe17188fccb73877 100644 --- a/build/source/actors/file_access_actor/fortran_code/output_structure.f90 +++ b/build/source/actors/file_access_actor/fortran_code/output_structure.f90 @@ -4,6 +4,8 @@ module output_structure_module USE, intrinsic :: iso_c_binding implicit none public::initOutputStructure + public::deallocateOutputStructure + public::deallocateData_output type(summa_output_type),allocatable,save,public :: outputStructure(:) ! summa_OutputStructure(iFile)%struc%var(:)%dat(nTimeSteps) @@ -49,7 +51,7 @@ subroutine initOutputStructure(handle_forcFileInfo, maxSteps, num_gru, err) bind integer(i4b) :: iStruct character(len=256) :: message integer(i4b) :: num_hru - + call c_f_pointer(handle_forcFileInfo, forcFileInfo) ! Allocate structure to hold output files @@ -243,4 +245,171 @@ subroutine initOutputStructure(handle_forcFileInfo, maxSteps, num_gru, err) bind end subroutine initOutputStructure +subroutine deallocateOutputStructure(err) bind(C, name="deallocateOutputStructure") + implicit none + integer(i4b), intent(inout) :: err + + err = 0 + ! Time + call deallocateData_output(outputStructure(1)%timeStruct(1)); deallocate(outputStructure(1)%timeStruct) + ! Forc + call deallocateData_output(outputStructure(1)%forcStat(1)); deallocate(outputStructure(1)%forcStat) + call deallocateData_output(outputStructure(1)%forcStruct(1)); deallocate(outputStructure(1)%forcStruct) + ! prog + call deallocateData_output(outputStructure(1)%progStat(1)); deallocate(outputStructure(1)%progStat) + call deallocateData_output(outputStructure(1)%progStruct(1)); deallocate(outputStructure(1)%progStruct) + ! diag + call deallocateData_output(outputStructure(1)%diagStat(1)); deallocate(outputStructure(1)%diagStat) + call deallocateData_output(outputStructure(1)%diagStruct(1)); deallocate(outputStructure(1)%diagStruct) + ! flux + call deallocateData_output(outputStructure(1)%fluxStat(1)); deallocate(outputStructure(1)%fluxStat) + call deallocateData_output(outputStructure(1)%fluxStruct(1)); deallocate(outputStructure(1)%fluxStruct) + ! indx + call deallocateData_output(outputStructure(1)%indxStat(1)); deallocate(outputStructure(1)%indxStat) + call deallocateData_output(outputStructure(1)%indxStruct(1)); deallocate(outputStructure(1)%indxStruct) + ! bvar + call deallocateData_output(outputStructure(1)%bvarStat(1)); deallocate(outputStructure(1)%bvarStat) + call deallocateData_output(outputStructure(1)%bvarStruct(1)); deallocate(outputStructure(1)%bvarStruct) + ! id + call deallocateData_output(outputStructure(1)%idStruct(1)); deallocate(outputStructure(1)%idStruct) + ! attr + call deallocateData_output(outputStructure(1)%attrStruct(1)); deallocate(outputStructure(1)%attrStruct) + ! type + call deallocateData_output(outputStructure(1)%typeStruct(1)); deallocate(outputStructure(1)%typeStruct) + ! mpar + call deallocateData_output(outputStructure(1)%mparStruct(1)); deallocate(outputStructure(1)%mparStruct) + ! bpar + call deallocateData_output(outputStructure(1)%bparStruct(1)); deallocate(outputStructure(1)%bparStruct) + ! finalize stats + call deallocateData_output(outputStructure(1)%finalizeStats(1)); deallocate(outputStructure(1)%finalizeStats) + +end subroutine deallocateOutputStructure + +subroutine deallocateData_output(dataStruct) + USE data_types,only:gru_hru_time_doubleVec, & + gru_hru_time_intVec, & + gru_hru_time_flagVec, & + gru_hru_time_int, & + gru_hru_int, & + gru_hru_time_int8, & + gru_hru_time_double, & + gru_hru_double, & + gru_double + implicit none + class(*),intent(inout) :: dataStruct + ! local variables + integer(i4b) :: iGRU + integer(i4b) :: iHRU + integer(i4b) :: iVar + integer(i4b) :: iTim + + select type(dataStruct) + class is (gru_hru_time_doubleVec) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + do iVar = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(:)) + do iTim = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim(iTim)%dat) + end do ! Time + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim) + end do ! var + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_time_intVec) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + do iVar = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(:)) + do iTim = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim(iTim)%dat) + end do ! Time + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim) + end do ! var + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_time_flagVec) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + do iTim = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%tim(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%tim(iTim)%dat) + end do ! Time + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%tim) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_time_int) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + do iVar = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim) + end do ! var + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_int) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_time_int8) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + do iVar = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim) + end do ! var + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_time_double) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + do iVar = 1, size(dataStruct%gru(iGRU)%hru(iHRU)%var(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var(iVar)%tim) + end do ! var + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_hru_double) + do iGRU = 1, size(dataStruct%gru(:)) + do iHRU = 1, size(dataStruct%gru(iGRU)%hru(:)) + deallocate(dataStruct%gru(iGRU)%hru(iHRU)%var) + end do ! hru + deallocate(dataStruct%gru(iGRU)%hru) + end do ! gru + deallocate(dataStruct%gru) + + class is (gru_double) + do iGRU = 1, size(dataStruct%gru(:)) + deallocate(dataStruct%gru(iGRU)%var) + end do ! gru + deallocate(dataStruct%gru) + + + end select + +end subroutine + + end module output_structure_module \ No newline at end of file diff --git a/build/summa b/build/summa new file mode 160000 index 0000000000000000000000000000000000000000..fa9adf808229a45085defdc2bb8ef05836b9b3aa --- /dev/null +++ b/build/summa @@ -0,0 +1 @@ +Subproject commit fa9adf808229a45085defdc2bb8ef05836b9b3aa diff --git a/laugh_tests b/laugh_tests new file mode 160000 index 0000000000000000000000000000000000000000..0712a5e534811683bee120de3b76c3a0f27ba309 --- /dev/null +++ b/laugh_tests @@ -0,0 +1 @@ +Subproject commit 0712a5e534811683bee120de3b76c3a0f27ba309