From be86bf4f30a2d798b394a4355f07cc6c235d4f0e Mon Sep 17 00:00:00 2001
From: Kyle <kyle.c.klenk@gmail.com>
Date: Tue, 22 Nov 2022 15:22:47 +0000
Subject: [PATCH] fixed some memory leaks and got all laugh tests to complete

---
 .../file_access_actor/fortran_code/cppwrap_fileAccess.f90       | 2 ++
 .../actors/file_access_actor/fortran_code/read_attribute.f90    | 2 --
 build/source/dshare/get_ixname.f90                              | 1 -
 build/source/dshare/popMetadat.f90                              | 1 -
 build/source/dshare/var_lookup_sundials.f90                     | 1 -
 5 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/build/source/actors/file_access_actor/fortran_code/cppwrap_fileAccess.f90 b/build/source/actors/file_access_actor/fortran_code/cppwrap_fileAccess.f90
index 1a1cad0..3ae3d72 100644
--- a/build/source/actors/file_access_actor/fortran_code/cppwrap_fileAccess.f90
+++ b/build/source/actors/file_access_actor/fortran_code/cppwrap_fileAccess.f90
@@ -107,6 +107,7 @@ subroutine FileAccessActor_DeallocateStructures(handle_forcFileInfo, handle_ncid
   USE netcdf_util_module,only:nc_file_close 
   USE globalData,only:structInfo                              ! information on the data structures
   USE globalData,only:failedHRUs
+  USE globalData,only:forcingDataStruct
   implicit none
   type(c_ptr),intent(in), value        :: handle_forcFileInfo
   type(c_ptr),intent(in), value        :: handle_ncid
@@ -133,6 +134,7 @@ subroutine FileAccessActor_DeallocateStructures(handle_forcFileInfo, handle_ncid
   deallocate(forcFileInfo)
   deallocate(ncid)
   deallocate(failedHRUs)
+  deallocate(forcingDataStruct)
 end subroutine FileAccessActor_DeallocateStructures
 
 
diff --git a/build/source/actors/file_access_actor/fortran_code/read_attribute.f90 b/build/source/actors/file_access_actor/fortran_code/read_attribute.f90
index ff82536..2351c3a 100644
--- a/build/source/actors/file_access_actor/fortran_code/read_attribute.f90
+++ b/build/source/actors/file_access_actor/fortran_code/read_attribute.f90
@@ -309,8 +309,6 @@ subroutine readAttributeFromNetCDF(ncid, index_gru, index_hru, num_var, &
       checkAttr(varIndx) = .true.
   endif
 
-  varIndx = get_ixTYPE('downkHRU')
-  checkType(varIndx) = .true.
   ! **********************************************************************************************
   ! (4) check that we have all the desired varaibles
   ! **********************************************************************************************
diff --git a/build/source/dshare/get_ixname.f90 b/build/source/dshare/get_ixname.f90
index 966b413..933a77c 100755
--- a/build/source/dshare/get_ixname.f90
+++ b/build/source/dshare/get_ixname.f90
@@ -196,7 +196,6 @@ contains
   case('soilTypeIndex'  ); get_ixType = iLookTYPE%soilTypeIndex      ! index defining soil type
   case('slopeTypeIndex' ); get_ixType = iLookTYPE%slopeTypeIndex     ! index defining slope
   case('downHRUindex'   ); get_ixType = iLookTYPE%downHRUindex       ! index of downslope HRU (0 = basin outlet)
-  case('downkHRU');        get_ixType = iLookTYPE%downkHRU 
     ! get to here if cannot find the variable
   case default
    get_ixType = integerMissing
diff --git a/build/source/dshare/popMetadat.f90 b/build/source/dshare/popMetadat.f90
index 814bcd1..dd8f1ab 100755
--- a/build/source/dshare/popMetadat.f90
+++ b/build/source/dshare/popMetadat.f90
@@ -92,7 +92,6 @@ subroutine popMetadat(err,message)
   type_meta(iLookTYPE%soilTypeIndex)          = var_info('soilTypeIndex' , 'index defining soil type'                   , '-', get_ixVarType('scalarv'), iMissVec, iMissVec, .false.)
   type_meta(iLookTYPE%slopeTypeIndex)         = var_info('slopeTypeIndex', 'index defining slope'                       , '-', get_ixVarType('scalarv'), iMissVec, iMissVec, .false.)
   type_meta(iLookTYPE%downHRUindex)           = var_info('downHRUindex'  , 'index of downslope HRU (0 = basin outlet)'  , '-', get_ixVarType('scalarv'), iMissVec, iMissVec, .false.)
-  type_meta(iLookTYPE%downkHRU)               = var_info('downkHRU'      , 'real index of downslope HRU'                , '-', get_ixVarType('scalarv'), iMissVec, iMissVec, .false.)
   ! -----
   ! * hru and gru ID data...
   ! ---------------------
diff --git a/build/source/dshare/var_lookup_sundials.f90 b/build/source/dshare/var_lookup_sundials.f90
index f47a3f1..4ffc157 100755
--- a/build/source/dshare/var_lookup_sundials.f90
+++ b/build/source/dshare/var_lookup_sundials.f90
@@ -124,7 +124,6 @@ MODULE var_lookup
   integer(i4b)    :: soilTypeIndex = integerMissing  ! index defining soil type (-)
   integer(i4b)    :: slopeTypeIndex= integerMissing  ! index defining slope (-)
   integer(i4b)    :: downHRUindex  = integerMissing  ! index of downslope HRU (0 = basin outlet)
-  integer(i4b)    :: downkHRU      = integerMissing  ! reza index of downslope HRU (0 = basin outlet)
  end type iLook_type
 
  type, public  ::  iLook_id
-- 
GitLab