Skip to content

Commit

Permalink
stress package loaders allocated duplicate iper/ionper variables (#1732)
Browse files Browse the repository at this point in the history
Co-authored-by: mjreno <mjreno@IGSAAA071L01144.gs.doi.net>
  • Loading branch information
mjreno and mjreno authored Apr 18, 2024
1 parent dcb65f2 commit f7a2bd7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
15 changes: 0 additions & 15 deletions src/Utilities/Idm/InputLoadType.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ module InputLoadTypeModule
character(len=LINELENGTH) :: component_input_name !< component input name, e.g. model name file
character(len=LINELENGTH) :: input_name !< input name, e.g. package *.chd file
character(len=LINELENGTH), dimension(:), allocatable :: param_names !< dynamic param tagnames
integer(I4B), pointer :: iper => null() !< memory managed variable, loader iper
integer(I4B), pointer :: ionper => null() !< memory managed variable, next load period
logical(LGP) :: readasarrays !< is this array based input
integer(I4B) :: iperblock !< index of period block on block definition list
integer(I4B) :: iout !< inunit number for logging
Expand Down Expand Up @@ -166,7 +164,6 @@ end subroutine static_destroy
subroutine dynamic_init(this, mf6_input, component_name, component_input_name, &
input_name, iperblock, iout)
use SimVariablesModule, only: errmsg
use MemoryManagerModule, only: mem_allocate
use InputDefinitionModule, only: InputParamDefinitionType
! -- dummy
class(DynamicPkgLoadType), intent(inout) :: this
Expand All @@ -187,14 +184,6 @@ subroutine dynamic_init(this, mf6_input, component_name, component_input_name, &
this%iout = iout
nullify (idt)
!
! -- allocate scalars
call mem_allocate(this%iper, 'IPER', mf6_input%mempath)
call mem_allocate(this%ionper, 'IONPER', mf6_input%mempath)
!
! -- initialize
this%iper = 0
this%ionper = 0
!
! -- throw error and exit if not found
if (this%iperblock == 0) then
write (errmsg, '(a,a)') &
Expand Down Expand Up @@ -243,10 +232,6 @@ subroutine dynamic_destroy(this)
use SimVariablesModule, only: idm_context
class(DynamicPkgLoadType), intent(inout) :: this
!
! -- deallocate scalars
call mem_deallocate(this%iper)
call mem_deallocate(this%ionper)
!
! -- deallocate package static and dynamic input context
call memorylist_remove(this%mf6_input%component_name, &
this%mf6_input%subcomponent_name, &
Expand Down
19 changes: 16 additions & 3 deletions src/Utilities/Idm/mf6blockfile/IdmMf6File.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ module IdmMf6FileModule
!<
type, extends(DynamicPkgLoadBaseType) :: Mf6FileDynamicPkgLoadType
type(BlockParserType), pointer :: parser !< parser for MF6File period blocks
class(AsciiDynamicPkgLoadBaseType), pointer :: rp_loader
integer(I4B), pointer :: iper => null() !< memory managed variable, loader iper
integer(I4B), pointer :: ionper => null() !< memory managed variable, next load period
class(AsciiDynamicPkgLoadBaseType), pointer :: rp_loader => null()
contains
procedure :: init => dynamic_init
procedure :: df => dynamic_df
Expand Down Expand Up @@ -148,6 +150,7 @@ end subroutine static_destroy
!<
subroutine dynamic_init(this, mf6_input, component_name, component_input_name, &
input_name, iperblock, iout)
use MemoryManagerModule, only: mem_allocate
use InputDefinitionModule, only: InputParamDefinitionType
use DefinitionSelectModule, only: get_param_definition_type
class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
Expand All @@ -164,8 +167,13 @@ subroutine dynamic_init(this, mf6_input, component_name, component_input_name, &
component_input_name, input_name, &
iperblock, iout)
!
! -- initialize rp_loader
nullify (this%rp_loader)
! -- allocate scalars
call mem_allocate(this%iper, 'IPER', mf6_input%mempath)
call mem_allocate(this%ionper, 'IONPER', mf6_input%mempath)
!
! -- initialize
this%iper = 0
this%ionper = 0
!
! -- open input file
inunit = open_mf6file(mf6_input%pkgtype, input_name, &
Expand Down Expand Up @@ -324,8 +332,13 @@ end subroutine dynamic_create_loader
!> @brief dynamic loader destroy
!<
subroutine dynamic_destroy(this)
use MemoryManagerModule, only: mem_deallocate
class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
!
! -- deallocate scalars
call mem_deallocate(this%iper)
call mem_deallocate(this%ionper)
!
! -- deallocate loader
call this%rp_loader%destroy()
deallocate (this%rp_loader)
Expand Down

0 comments on commit f7a2bd7

Please sign in to comment.