diff --git a/src/Utilities/Idm/BoundInputContext.f90 b/src/Utilities/Idm/BoundInputContext.f90 index c4fc8089c64..26da823cb5e 100644 --- a/src/Utilities/Idm/BoundInputContext.f90 +++ b/src/Utilities/Idm/BoundInputContext.f90 @@ -1,4 +1,9 @@ -! -- Generic List Reader Module +!> @brief This module contains the BoundInputContextModule +!! +!! This module contains a type that stores and creates context +!! relevant to stress package inputs. +!! +!< module BoundInputContextModule use KindModule, only: DP, I4B, LGP @@ -12,7 +17,7 @@ module BoundInputContextModule !> @brief derived type for boundary package input context !! - !! This derived type is input context used by dynamic package loaders. + !! This derived type defines input context used by dynamic package loaders. !! Some variables (e.g. iprpak) in the type may have already been created !! by a static loader whereas others (e.g. nboound) are created by this !! type, updated by to dynamic loader, and accessed from the model package. @@ -143,7 +148,7 @@ end subroutine create_context !! !! This routine should be invoked after the loader allocates dynamic !! input params. This routine will assign pointers to arrays if they - !! have been allocoated or allocate the arrays if they have not been. + !! have been allocated and allocate the arrays if not. !! !< subroutine enable(this) diff --git a/src/Utilities/Idm/IdmLoad.f90 b/src/Utilities/Idm/IdmLoad.f90 index 00084b744af..63690c9863b 100644 --- a/src/Utilities/Idm/IdmLoad.f90 +++ b/src/Utilities/Idm/IdmLoad.f90 @@ -441,7 +441,7 @@ subroutine allocate_simnam_param(input_mempath, idt) end if case default write (errmsg, '(a,a)') & - 'Programming error. Idm Load unhandled datatype: ', & + 'Programming error. IdmLoad unhandled datatype: ', & trim(idt%datatype) call store_error(errmsg) call store_error_filename(simfile) diff --git a/src/Utilities/Idm/InputLoadType.f90 b/src/Utilities/Idm/InputLoadType.f90 index 6ff2ecfc7bd..556e492ccb3 100644 --- a/src/Utilities/Idm/InputLoadType.f90 +++ b/src/Utilities/Idm/InputLoadType.f90 @@ -31,6 +31,7 @@ module InputLoadTypeModule character(len=LENMODELNAME) :: modelname !< name of model character(len=LINELENGTH) :: modelfname !< name of model input file character(len=LINELENGTH) :: sourcename !< source name, e.g. name of file + integer(I4B) :: iperblock contains procedure :: init => static_init procedure :: destroy => static_destroy @@ -89,7 +90,6 @@ end function load_if subroutine period_load_if(this) import DynamicPkgLoadBaseType, I4B class(DynamicPkgLoadBaseType), intent(inout) :: this - !integer(I4B), intent(in) :: iout end subroutine end interface @@ -125,11 +125,22 @@ subroutine static_init(this, mf6_input, modelname, modelfname, source) character(len=*), intent(in) :: modelname character(len=*), intent(in) :: modelfname character(len=*), intent(in) :: source + integer(I4B) :: iblock ! this%mf6_input = mf6_input this%modelname = modelname this%modelfname = modelfname this%sourcename = source + this%iperblock = 0 + ! + ! -- identify period block definition + do iblock = 1, size(mf6_input%block_dfns) + ! + if (mf6_input%block_dfns(iblock)%blockname == 'PERIOD') then + this%iperblock = iblock + exit + end if + end do ! return end subroutine static_init @@ -146,7 +157,8 @@ end subroutine static_destroy !! must be allocated when derived dynamic loader is initialized. !! !< - subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, iout) + subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, & + iperblock, iout) use SimVariablesModule, only: errmsg use SimModule, only: store_error, store_error_filename class(DynamicPkgLoadType), intent(inout) :: this @@ -154,26 +166,16 @@ subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, iout) character(len=*), intent(in) :: modelname character(len=*), intent(in) :: modelfname character(len=*), intent(in) :: source + integer(I4B), intent(in) :: iperblock integer(I4B), intent(in) :: iout - integer(I4B) :: iblock ! this%mf6_input = mf6_input this%modelname = modelname this%modelfname = modelfname this%sourcename = source - this%iperblock = 0 + this%iperblock = iperblock this%iout = iout ! - ! -- identify period block definition - do iblock = 1, size(mf6_input%block_dfns) - ! - if (mf6_input%block_dfns(iblock)%blockname == 'PERIOD') then - this%iperblock = iblock - this%readasarrays = .not. mf6_input%block_dfns(iblock)%aggregate - exit - end if - end do - ! ! -- throw error and exit if not found if (this%iperblock == 0) then write (errmsg, '(a,a)') & @@ -182,6 +184,9 @@ subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, iout) trim(mf6_input%subcomponent_name) call store_error(errmsg) call store_error_filename(this%sourcename) + else + ! + this%readasarrays = (.not. mf6_input%block_dfns(iperblock)%aggregate) end if ! ! -- return diff --git a/src/Utilities/Idm/SourceLoad.F90 b/src/Utilities/Idm/SourceLoad.F90 index ae93d6813a0..236607806c7 100644 --- a/src/Utilities/Idm/SourceLoad.F90 +++ b/src/Utilities/Idm/SourceLoad.F90 @@ -1,7 +1,7 @@ !> @brief This module contains the SourceLoadModule !! !! This module contains the routines needed to generate -!! a loading object for an input source and routines +!! a loader object for an input source and routines !! that distribute processing to a particular source. !! !< diff --git a/src/Utilities/Idm/mf6blockfile/AsciiInputLoadType.f90 b/src/Utilities/Idm/mf6blockfile/AsciiInputLoadType.f90 index 3f10dd482c8..081f31f1579 100644 --- a/src/Utilities/Idm/mf6blockfile/AsciiInputLoadType.f90 +++ b/src/Utilities/Idm/mf6blockfile/AsciiInputLoadType.f90 @@ -1,3 +1,10 @@ +!> @brief This module contains the AsciiInputLoadTypeModule +!! +!! This module defines an abstract type that support generic +!! IDP dynamic input loading for traditional MODFLOW 6 ascii +!! files. +!! +!< module AsciiInputLoadTypeModule use KindModule, only: DP, I4B, LGP diff --git a/src/Utilities/Idm/mf6blockfile/IdmMf6File.f90 b/src/Utilities/Idm/mf6blockfile/IdmMf6File.f90 index 82fe8e61eaf..cdef4bda732 100644 --- a/src/Utilities/Idm/mf6blockfile/IdmMf6File.f90 +++ b/src/Utilities/Idm/mf6blockfile/IdmMf6File.f90 @@ -91,38 +91,6 @@ subroutine generic_mf6_load(parser, mf6_input, iout) end subroutine generic_mf6_load - !> @brief allocate dynamic load parser if expecting dynamic input - !< - function create_dynamic_parser(mf6_input, mf6_parser, static_parser) & - result(created) - type(ModflowInputType), intent(in) :: mf6_input - type(BlockParserType), pointer, intent(inout) :: mf6_parser - type(BlockParserType), allocatable, target, intent(inout) :: static_parser - logical(LGP) :: created - integer(I4B) :: iblock - ! - ! -- initialize - nullify (mf6_parser) - created = .false. - ! - ! -- check if package has dynamic input - do iblock = 1, size(mf6_input%block_dfns) - ! - if (mf6_input%block_dfns(iblock)%blockname == 'PERIOD') then - ! - ! -- dynamic package, allocate parser - allocate (mf6_parser, source=static_parser) - created = .true. - ! - exit - ! - end if - end do - ! - ! -- return - return - end function - !> @brief input load for traditional mf6 simulation input file !< subroutine input_load(filename, mf6_input, component_filename, iout, & @@ -135,10 +103,6 @@ subroutine input_load(filename, mf6_input, component_filename, iout, & type(BlockParserType), allocatable, target :: parser !< block parser type(PackageLoad) :: pkgloader integer(I4B) :: inunit - logical(LGP) :: created - ! - ! -- initialize - created = .false. ! ! -- set parser based package loader by file type select case (mf6_input%pkgtype) @@ -163,17 +127,16 @@ subroutine input_load(filename, mf6_input, component_filename, iout, & if (present(mf6_parser)) then ! ! -- create dynamic parser - created = create_dynamic_parser(mf6_input, mf6_parser, parser) - end if - ! - ! -- deallocate static load parser - if (allocated(parser)) then - ! - if (.not. created) call parser%clear() - deallocate (parser) + allocate (mf6_parser, source=parser) + else ! + ! -- clear parser file handles + call parser%clear() end if ! + ! -- cleanup + deallocate (parser) + ! ! -- return return end subroutine input_load @@ -197,35 +160,42 @@ function static_load(this, iout) result(period_loader) class(Mf6FileStaticPkgLoadType), intent(inout) :: this integer(I4B), intent(in) :: iout class(DynamicPkgLoadBaseType), pointer :: period_loader - class(Mf6FileDynamicPkgLoadType), pointer :: mf6file_period_loader => null() + class(Mf6FileDynamicPkgLoadType), pointer :: mf6_loader => null() type(BlockParserType), pointer :: parser => null() ! ! -- initialize nullify (period_loader) ! ! -- load model package to input context - call input_load(this%sourcename, this%mf6_input, & - this%modelfname, iout, parser) - ! - ! - if (associated(parser)) then + if (this%iperblock > 0) then ! ! -- package is dynamic, allocate loader - allocate (mf6file_period_loader) + allocate (mf6_loader) + ! + ! -- load static input + call input_load(this%sourcename, this%mf6_input, & + this%modelfname, iout, parser) ! ! -- initialize dynamic loader - call mf6file_period_loader%init(this%mf6_input, this%modelname, & - this%modelfname, this%sourcename, & - iout) + call mf6_loader%init(this%mf6_input, this%modelname, & + this%modelfname, this%sourcename, & + this%iperblock, iout) ! ! -- set parser - call mf6file_period_loader%set(parser) + call mf6_loader%set(parser) ! ! -- set return pointer to base dynamic loader - period_loader => mf6file_period_loader + period_loader => mf6_loader + ! + else ! + ! -- load static input + call input_load(this%sourcename, this%mf6_input, & + this%modelfname, iout) end if ! + ! -- return + return end function static_load !> @brief static loader destroy @@ -239,7 +209,8 @@ end subroutine static_destroy !> @brief dynamic loader init !< - subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, iout) + subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, & + iperblock, iout) use InputDefinitionModule, only: InputParamDefinitionType use DefinitionSelectModule, only: get_param_definition_type use MemoryManagerModule, only: mem_allocate @@ -248,10 +219,11 @@ subroutine dynamic_init(this, mf6_input, modelname, modelfname, source, iout) character(len=*), intent(in) :: modelname character(len=*), intent(in) :: modelfname character(len=*), intent(in) :: source + integer(I4B), intent(in) :: iperblock integer(I4B), intent(in) :: iout ! call this%DynamicPkgLoadType%init(mf6_input, modelname, modelfname, & - source, iout) + source, iperblock, iout) ! call mem_allocate(this%iper, 'IPER', this%mf6_input%mempath) call mem_allocate(this%ionper, 'IONPER', this%mf6_input%mempath) @@ -413,6 +385,7 @@ subroutine dynamic_create_loader(this) this%modelname, & this%modelfname, & this%sourcename, & + this%iperblock, & this%iout) ! ! -- return diff --git a/src/Utilities/Idm/mf6blockfile/StressGridInput.f90 b/src/Utilities/Idm/mf6blockfile/StressGridInput.f90 index 460f515f304..c70dd7624c9 100644 --- a/src/Utilities/Idm/mf6blockfile/StressGridInput.f90 +++ b/src/Utilities/Idm/mf6blockfile/StressGridInput.f90 @@ -1,7 +1,7 @@ !> @brief This module contains the StressGridInputModule !! -!! This module contains the routines for reading -!! period block array based input +!! This module contains the routines for reading period block +!! array based input. !! !< module StressGridInputModule @@ -63,23 +63,22 @@ module StressGridInputModule contains subroutine ingrid_init(this, mf6_input, modelname, modelfname, & - source, iout) + source, iperblock, iout) use MemoryManagerModule, only: get_isize class(StressGridInputType), intent(inout) :: this type(ModflowInputType), intent(in) :: mf6_input character(len=*), intent(in) :: modelname character(len=*), intent(in) :: modelfname character(len=*), intent(in) :: source + integer(I4B), intent(in) :: iperblock integer(I4B), intent(in) :: iout type(CharacterStringType), dimension(:), pointer, & contiguous :: tas_fnames character(len=LINELENGTH) :: fname integer(I4B) :: tas6_size, n - ! call this%DynamicPkgLoadType%init(mf6_input, modelname, modelfname, & - source, iout) - ! + source, iperblock, iout) ! -- initialize this%tas_active = 0 this%nparam = 0 @@ -92,7 +91,7 @@ subroutine ingrid_init(this, mf6_input, modelname, modelfname, & ! ! -- determine if TAS6 files were provided in OPTIONS block call get_isize('TAS6_FILENAME', this%mf6_input%mempath, tas6_size) - + ! if (tas6_size > 0) then ! this%tas_active = 1 @@ -190,8 +189,10 @@ subroutine ingrid_rp(this, parser) ! -- look for TAS keyword if tas is active if (this%tas_active /= 0) then call parser%GetStringCaps(keyword) + ! if (keyword == 'TIMEARRAYSERIES') then call parser%GetStringCaps(tas_name) + ! if (param_tag == 'AUX') then this%aux_tasnames(iaux) = tas_name else @@ -203,6 +204,7 @@ subroutine ingrid_rp(this, parser) ! -- cycle to next input param cycle end if + ! end if ! ! -- read and load the parameter diff --git a/src/Utilities/Idm/mf6blockfile/StressListInput.f90 b/src/Utilities/Idm/mf6blockfile/StressListInput.f90 index 7b44042c85b..67c6ac5177d 100644 --- a/src/Utilities/Idm/mf6blockfile/StressListInput.f90 +++ b/src/Utilities/Idm/mf6blockfile/StressListInput.f90 @@ -1,8 +1,7 @@ !> @brief This module contains the StressListInputModule !! -!! This module contains the routines for reading a -!! structured list, which consists of a separate vector -!! for each column in the list. +!! This module contains the routines for reading period block +!! list based input. !! !< module StressListInputModule @@ -55,13 +54,14 @@ module StressListInputModule contains subroutine inlist_init(this, mf6_input, modelname, modelfname, & - source, iout) + source, iperblock, iout) use MemoryManagerModule, only: get_isize class(StressListInputType), intent(inout) :: this type(ModflowInputType), intent(in) :: mf6_input character(len=*), intent(in) :: modelname character(len=*), intent(in) :: modelfname character(len=*), intent(in) :: source + integer(I4B), intent(in) :: iperblock integer(I4B), intent(in) :: iout type(CharacterStringType), dimension(:), pointer, & contiguous :: ts_fnames @@ -69,7 +69,7 @@ subroutine inlist_init(this, mf6_input, modelname, modelfname, & integer(I4B) :: ts6_size, n ! call this%DynamicPkgLoadType%init(mf6_input, modelname, modelfname, & - source, iout) + source, iperblock, iout) ! ! -- initialize this%ts_active = 0 @@ -194,9 +194,7 @@ subroutine inlist_reset(this) class(StressListInputType), intent(inout) :: this !< StressListInputType ! ! -- reset tsmanager - if (this%ts_active /= 0) then - call this%tsmanager%reset(this%mf6_input%subcomponent_name) - end if + call this%tsmanager%reset(this%mf6_input%subcomponent_name) ! ! -- return return @@ -276,6 +274,7 @@ subroutine inlist_ts_link(this, structvector, ts_strloc) boundname = sv_bound%charstr1d(ts_strloc%row) tsLinkAux%BndName = boundname end if + ! end if ! case default diff --git a/src/Utilities/Idm/mf6blockfile/StructArray.f90 b/src/Utilities/Idm/mf6blockfile/StructArray.f90 index 4760860d85f..5b5528af0a0 100644 --- a/src/Utilities/Idm/mf6blockfile/StructArray.f90 +++ b/src/Utilities/Idm/mf6blockfile/StructArray.f90 @@ -838,8 +838,8 @@ function read_from_binary(this, inunit, iout) result(irow) integer(I4B) :: intval, numval character(len=LINELENGTH) :: fname character(len=*), parameter :: fmtlsterronly = & - "('Error Reading LIST from file: ',& - &1x,a,1x,' On UNIT: ',I0)" + "('Error reading LIST from file: ',& + &1x,a,1x,' on UNIT: ',I0)" ! ! -- set error and exit if deferred shape if (this%deferred_shape) then @@ -910,7 +910,7 @@ function read_from_binary(this, inunit, iout) result(irow) ! no error case (:-1) ! - ! -- End of record was encountered + ! -- End of block was encountered irow = irow - 1 exit readloop ! diff --git a/src/Utilities/Idm/mf6blockfile/StructVector.f90 b/src/Utilities/Idm/mf6blockfile/StructVector.f90 index f1f190ce239..d9618d4fba9 100644 --- a/src/Utilities/Idm/mf6blockfile/StructVector.f90 +++ b/src/Utilities/Idm/mf6blockfile/StructVector.f90 @@ -55,7 +55,6 @@ module StructVectorModule ! TimeSeries strings type(ListType) :: ts_strlocs contains - !procedure :: init => sv_init procedure :: clear => sv_clear procedure :: read_token => sv_read_token procedure :: add_ts_strloc => sv_add_ts_strloc