Skip to content

Commit

Permalink
adjustments for consistency with source loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
mjreno authored and mjreno committed Nov 16, 2023
1 parent 47c29cb commit 20d9df3
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 207 deletions.
15 changes: 11 additions & 4 deletions src/Utilities/Idm/SourceContext.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module InputModelContextModule

!> @brief type for storing model context
!!
!! This type is used to store a list of context objects
!! This type is used to store a set of context objects
!! associated with a model. Add additional context types as
!! appropriate.
!!
!<
type :: ModelContextType
character(len=LENMODELNAME) :: modelname !< name of model
character(len=LINELENGTH) :: modelfname !< name of model input file
type(NC4ModelInputsType), pointer :: nc4_context
type(NC4ModelInputsType), pointer :: nc4_context !< model netcdf context
contains
procedure :: init => modelctx_init
procedure :: destroy => modelctx_destroy
Expand Down Expand Up @@ -148,7 +148,11 @@ subroutine ModelContextDestroy()
return
end subroutine ModelContextDestroy

!> @brief get model context object from list
!> @brief add netcdf context to model context object
!!
!! Add netcdf context to a model on the model context list.
!! If model context object does not exist, create and add
!! to the model context list.
!!
!<
subroutine AddModelNC4Context(modelname, modelfname, nc4_context)
Expand Down Expand Up @@ -177,7 +181,10 @@ subroutine AddModelNC4Context(modelname, modelfname, nc4_context)
return
end subroutine AddModelNC4Context

!> @brief get model context object from list
!> @brief get netcdf context associated with model
!!
!! Retrieve and return netcdf context associated with a model
!! context object on the model context list.
!!
!<
function GetModelNC4Context(modelname) result(nc4_context)
Expand Down
6 changes: 6 additions & 0 deletions src/Utilities/Idm/mf6blockfile/AsciiInputLoadType.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
module AsciiInputLoadTypeModule

use KindModule, only: DP, I4B, LGP
use ConstantsModule, only: LENVARNAME
use InputLoadTypeModule, only: DynamicPkgLoadType
use BlockParserModule, only: BlockParserType
use BoundInputContextModule, only: BoundInputContextType

implicit none
private
Expand All @@ -19,6 +21,10 @@ module AsciiInputLoadTypeModule
!!
!<
type, abstract, extends(DynamicPkgLoadType) :: AsciiDynamicPkgLoadBaseType
integer(I4B) :: nparam
character(len=LENVARNAME), dimension(:), &
allocatable :: param_names !< dynamic param names
type(BoundInputContextType) :: bndctx
contains
procedure(ascii_period_load_if), deferred :: rp
end type AsciiDynamicPkgLoadBaseType
Expand Down
54 changes: 30 additions & 24 deletions src/Utilities/Idm/mf6blockfile/IdmMf6File.f90
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module IdmMf6FileModule
!!
!<
type :: PackageLoad
procedure(IPackageLoad), nopass, pointer, public :: load_package => null() !< procedure pointer to the load routine
procedure(IPackageLoad), nopass, pointer, public :: load_package !< procedure pointer to the load routine
end type PackageLoad

abstract interface
Expand All @@ -63,9 +63,9 @@ end subroutine IPackageLoad
!<
type, extends(DynamicPkgLoadBaseType) :: Mf6FileDynamicPkgLoadType
type(BlockParserType), pointer :: parser !< parser for MF6File period blocks
integer(I4B), pointer :: iper => null()
integer(I4B), pointer :: ionper => null()
class(AsciiDynamicPkgLoadBaseType), pointer :: block_loader => null()
integer(I4B), pointer :: iper
integer(I4B), pointer :: ionper
class(AsciiDynamicPkgLoadBaseType), pointer :: rp_loader
contains
procedure :: init => dynamic_init
procedure :: df => dynamic_df
Expand Down Expand Up @@ -104,6 +104,9 @@ subroutine input_load(filename, mf6_input, component_filename, iout, &
type(PackageLoad) :: pkgloader
integer(I4B) :: inunit
!
! -- initialize
nullify (pkgloader%load_package)
!
! -- set parser based package loader by file type
select case (mf6_input%pkgtype)
case default
Expand Down Expand Up @@ -156,15 +159,17 @@ end subroutine static_init

!> @brief load routine for static loader
!<
function static_load(this, iout) result(period_loader)
function static_load(this, iout) result(rp_loader)
class(Mf6FileStaticPkgLoadType), intent(inout) :: this
integer(I4B), intent(in) :: iout
class(DynamicPkgLoadBaseType), pointer :: period_loader
class(Mf6FileDynamicPkgLoadType), pointer :: mf6_loader => null()
type(BlockParserType), pointer :: parser => null()
class(DynamicPkgLoadBaseType), pointer :: rp_loader
class(Mf6FileDynamicPkgLoadType), pointer :: mf6_loader
type(BlockParserType), pointer :: parser
!
! -- initialize
nullify (period_loader)
nullify (rp_loader)
nullify (mf6_loader)
nullify (parser)
!
! -- load model package to input context
if (this%iperblock > 0) then
Expand All @@ -185,7 +190,7 @@ function static_load(this, iout) result(period_loader)
call mf6_loader%set(parser)
!
! -- set return pointer to base dynamic loader
period_loader => mf6_loader
rp_loader => mf6_loader
!
else
!
Expand Down Expand Up @@ -228,6 +233,8 @@ subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, &
call mem_allocate(this%iper, 'IPER', this%mf6_input%mempath)
call mem_allocate(this%ionper, 'IONPER', this%mf6_input%mempath)
!
! -- initialize package
nullify (this%rp_loader)
this%iper = 0
this%ionper = 0
!
Expand Down Expand Up @@ -261,7 +268,7 @@ subroutine dynamic_df(this)
! -- read first iper
call this%read_ionper()
!
call this%block_loader%df()
call this%rp_loader%df()
!
! -- return
return
Expand All @@ -272,7 +279,7 @@ end subroutine dynamic_df
subroutine dynamic_ad(this)
class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
!
call this%block_loader%ad()
call this%rp_loader%ad()
!
! -- return
return
Expand All @@ -283,7 +290,6 @@ end subroutine dynamic_ad
subroutine dynamic_rp(this)
! -- modules
use TdisModule, only: kper, nper
use MemoryManagerModule, only: mem_setptr
! -- dummy
class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
! -- locals
Expand All @@ -292,7 +298,7 @@ subroutine dynamic_rp(this)
if (this%ionper /= kper) return
!
! -- dynamic load
call this%block_loader%rp(this%parser)
call this%rp_loader%rp(this%parser)
!
! -- update loaded iper
this%iper = kper
Expand Down Expand Up @@ -372,19 +378,19 @@ subroutine dynamic_create_loader(this)
! -- allocate and set loader
if (this%readasarrays) then
allocate (grid_loader)
this%block_loader => grid_loader
this%rp_loader => grid_loader
else
allocate (list_loader)
this%block_loader => list_loader
this%rp_loader => list_loader
end if
!
! -- initialize loader
call this%block_loader%init(this%mf6_input, &
this%modelname, &
this%modelfname, &
this%sourcename, &
this%iperblock, &
this%iout)
call this%rp_loader%init(this%mf6_input, &
this%modelname, &
this%modelfname, &
this%sourcename, &
this%iperblock, &
this%iout)
!
! -- return
return
Expand All @@ -396,8 +402,8 @@ subroutine dynamic_destroy(this)
class(Mf6FileDynamicPkgLoadType), intent(inout) :: this
!
! -- deallocate loader
call this%block_loader%destroy()
deallocate (this%block_loader)
call this%rp_loader%destroy()
deallocate (this%rp_loader)
!
! -- deallocate parser
call this%parser%clear()
Expand Down
12 changes: 5 additions & 7 deletions src/Utilities/Idm/mf6blockfile/StressGridInput.f90
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ module StressGridInputModule
!<
type, extends(AsciiDynamicPkgLoadBaseType) :: StressGridInputType
integer(I4B) :: tas_active !< Are TAS6 inputs defined
integer(I4B) :: nparam !< number of dynamic parameters other than AUX
type(CharacterStringType), dimension(:), contiguous, &
pointer :: aux_tasnames => null() !< array of AUXVAR TAS names
pointer :: aux_tasnames !< array of AUXVAR TAS names
type(CharacterStringType), dimension(:), contiguous, &
pointer :: param_tasnames => null() !< array of dynamic param TAS names
character(len=LENVARNAME), dimension(:), &
allocatable :: param_names !< dynamic param names
pointer :: param_tasnames !< array of dynamic param TAS names
type(ReadStateVarType), dimension(:), allocatable :: param_reads !< read states for current load
type(TimeArraySeriesManagerType), pointer :: tasmanager => null() !< TAS manager object
type(BoundInputContextType) :: bndctx !< boundary package input context
type(TimeArraySeriesManagerType), pointer :: tasmanager !< TAS manager
contains
procedure :: init => ingrid_init
procedure :: df => ingrid_df
Expand Down Expand Up @@ -73,6 +69,8 @@ subroutine ingrid_init(this, mf6_input, modelname, modelfname, &
call this%DynamicPkgLoadType%init(mf6_input, modelname, modelfname, &
source, iperblock, iout)
! -- initialize
nullify (this%aux_tasnames)
nullify (this%param_tasnames)
this%tas_active = 0
this%nparam = 0
this%iout = iout
Expand Down
25 changes: 11 additions & 14 deletions src/Utilities/Idm/mf6blockfile/StressListInput.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ module StressListInputModule
integer(I4B) :: ts_active
integer(I4B) :: ibinary
integer(I4B) :: oc_inunit
integer(I4B) :: ncol
integer(I4B) :: iboundname
character(len=LENVARNAME), dimension(:), allocatable :: cols
type(TimeSeriesManagerType), pointer :: tsmanager => null()
type(TimeSeriesManagerType), pointer :: tsmanager
type(StructArrayType), pointer :: structarray
type(BoundInputContextType) :: bndctx
contains
procedure :: init => inlist_init
procedure :: df => inlist_df
Expand Down Expand Up @@ -99,7 +96,7 @@ subroutine inlist_init(this, mf6_input, modelname, modelfname, &
call this%bndctx%init(mf6_input, .false.)
!
! -- set SA cols in scope for list input
call this%bndctx%filtered_params(this%cols, this%ncol)
call this%bndctx%filtered_params(this%param_names, this%nparam)
!
! -- construct and set up the struct array object
call this%create_structarray()
Expand Down Expand Up @@ -180,7 +177,7 @@ subroutine inlist_destroy(this)
! -- modules
class(StressListInputType), intent(inout) :: this !< StressListInputType
!
deallocate (this%cols)
deallocate (this%param_names)
deallocate (this%tsmanager)
call destructStructArray(this%structarray)
call this%bndctx%destroy()
Expand Down Expand Up @@ -211,16 +208,16 @@ subroutine inlist_ts_link(this, structvector, ts_strloc)
type(StructVectorType), pointer, intent(in) :: structvector
type(TSStringLocType), pointer, intent(in) :: ts_strloc
! -- locals
real(DP), pointer :: bndElem => null()
type(TimeSeriesLinkType), pointer :: tsLinkBnd => null()
type(TimeSeriesLinkType), pointer :: tsLinkAux => null()
real(DP), pointer :: bndElem
type(TimeSeriesLinkType), pointer :: tsLinkBnd
type(TimeSeriesLinkType), pointer :: tsLinkAux
type(StructVectorType), pointer :: sv_bound
character(len=LENBOUNDNAME) :: boundname
!
select case (structvector%memtype)
case (2)
!
tsLinkBnd => NULL()
nullify (tsLinkBnd)
!
! -- set bound element
bndElem => structvector%dbl1d(ts_strloc%row)
Expand Down Expand Up @@ -250,7 +247,7 @@ subroutine inlist_ts_link(this, structvector, ts_strloc)
!
case (6)
!
tsLinkAux => NULL()
nullify (tsLinkAux)
!
! -- set bound element
bndElem => structvector%dbl2d(ts_strloc%col, ts_strloc%row)
Expand Down Expand Up @@ -325,18 +322,18 @@ subroutine create_structarray(this)
integer(I4B) :: icol
!
! -- construct and set up the struct array object
this%structarray => constructStructArray(this%ncol, this%bndctx%maxbound, &
this%structarray => constructStructArray(this%nparam, this%bndctx%maxbound, &
0, this%mf6_input%mempath, &
this%mf6_input%component_mempath)
!
! -- set up struct array
do icol = 1, this%ncol
do icol = 1, this%nparam
!
idt => get_param_definition_type(this%mf6_input%param_dfns, &
this%mf6_input%component_type, &
this%mf6_input%subcomponent_type, &
'PERIOD', &
this%cols(icol), this%sourcename)
this%param_names(icol), this%sourcename)
!
! -- allocate variable in memory manager
call this%structarray%mem_create_vector(icol, idt)
Expand Down
Loading

0 comments on commit 20d9df3

Please sign in to comment.