From 84c3893ffa31fd7d19cf6d94d56d61858d5baeea Mon Sep 17 00:00:00 2001 From: mjreno Date: Mon, 26 Dec 2022 11:20:57 -0500 Subject: [PATCH] refactor(idm): consolidate package input context load in model create (#1127) * consolidate idm input_load calls upward into the model context * run build_makefiles.py * clean-up * place package input load in appropriate model scope * update pymake Co-authored-by: mjreno --- make/makefile | 72 +++++++++++----------- src/Model/GroundWaterFlow/gwf3.f90 | 41 ++++++++++++ src/Model/GroundWaterFlow/gwf3dis8.f90 | 18 ++---- src/Model/GroundWaterFlow/gwf3disu8.f90 | 13 +--- src/Model/GroundWaterFlow/gwf3disv8.f90 | 19 ++---- src/Model/GroundWaterFlow/gwf3npf8.f90 | 27 +++----- src/Model/GroundWaterTransport/gwt1.f90 | 42 ++++++++++++- src/Model/GroundWaterTransport/gwt1dsp.f90 | 8 --- src/Model/NumericalModel.f90 | 36 +++++++++++ src/Utilities/Idm/IdmMf6FileLoader.f90 | 42 ++++++++++++- utils/mf5to6/make/makefile | 6 +- 11 files changed, 219 insertions(+), 105 deletions(-) diff --git a/make/makefile b/make/makefile index 6791ed45b92..15e3c1c565d 100644 --- a/make/makefile +++ b/make/makefile @@ -7,28 +7,28 @@ include ./makedefaults SOURCEDIR1=../src SOURCEDIR2=../src/Exchange SOURCEDIR3=../src/Model -SOURCEDIR4=../src/Model/Geometry -SOURCEDIR5=../src/Model/ModelUtilities -SOURCEDIR6=../src/Model/Connection +SOURCEDIR4=../src/Model/Connection +SOURCEDIR5=../src/Model/Geometry +SOURCEDIR6=../src/Model/GroundWaterFlow SOURCEDIR7=../src/Model/GroundWaterTransport -SOURCEDIR8=../src/Model/GroundWaterFlow +SOURCEDIR8=../src/Model/ModelUtilities SOURCEDIR9=../src/Solution SOURCEDIR10=../src/Solution/LinearMethods SOURCEDIR11=../src/Timing SOURCEDIR12=../src/Utilities -SOURCEDIR13=../src/Utilities/TimeSeries -SOURCEDIR14=../src/Utilities/Libraries -SOURCEDIR15=../src/Utilities/Libraries/rcm -SOURCEDIR16=../src/Utilities/Libraries/sparsekit -SOURCEDIR17=../src/Utilities/Libraries/sparskit2 -SOURCEDIR18=../src/Utilities/Libraries/blas -SOURCEDIR19=../src/Utilities/Libraries/daglib -SOURCEDIR20=../src/Utilities/Idm +SOURCEDIR13=../src/Utilities/ArrayRead +SOURCEDIR14=../src/Utilities/Idm +SOURCEDIR15=../src/Utilities/Libraries +SOURCEDIR16=../src/Utilities/Libraries/blas +SOURCEDIR17=../src/Utilities/Libraries/daglib +SOURCEDIR18=../src/Utilities/Libraries/rcm +SOURCEDIR19=../src/Utilities/Libraries/sparsekit +SOURCEDIR20=../src/Utilities/Libraries/sparskit2 SOURCEDIR21=../src/Utilities/Matrix -SOURCEDIR22=../src/Utilities/Observation -SOURCEDIR23=../src/Utilities/OutputControl -SOURCEDIR24=../src/Utilities/Memory -SOURCEDIR25=../src/Utilities/ArrayRead +SOURCEDIR22=../src/Utilities/Memory +SOURCEDIR23=../src/Utilities/Observation +SOURCEDIR24=../src/Utilities/OutputControl +SOURCEDIR25=../src/Utilities/TimeSeries VPATH = \ ${SOURCEDIR1} \ @@ -96,17 +96,9 @@ $(OBJDIR)/SmoothingFunctions.o \ $(OBJDIR)/MatrixBase.o \ $(OBJDIR)/ListReader.o \ $(OBJDIR)/Connections.o \ -$(OBJDIR)/DiscretizationBase.o \ -$(OBJDIR)/TimeArray.o \ -$(OBJDIR)/ObsOutput.o \ -$(OBJDIR)/TimeArraySeries.o \ -$(OBJDIR)/ObsOutputList.o \ -$(OBJDIR)/Observe.o \ $(OBJDIR)/InputDefinition.o \ $(OBJDIR)/ArrayReaderBase.o \ -$(OBJDIR)/TimeArraySeriesLink.o \ -$(OBJDIR)/ObsUtility.o \ -$(OBJDIR)/ObsContainer.o \ +$(OBJDIR)/DiscretizationBase.o \ $(OBJDIR)/VectorInt.o \ $(OBJDIR)/gwt1dspidm.o \ $(OBJDIR)/gwf3npf8idm.o \ @@ -114,26 +106,36 @@ $(OBJDIR)/gwf3disv8idm.o \ $(OBJDIR)/gwf3disu8idm.o \ $(OBJDIR)/gwf3dis8idm.o \ $(OBJDIR)/Integer2dReader.o \ -$(OBJDIR)/BudgetFileReader.o \ -$(OBJDIR)/TimeArraySeriesManager.o \ -$(OBJDIR)/PackageMover.o \ -$(OBJDIR)/Obs3.o \ -$(OBJDIR)/NumericalPackage.o \ -$(OBJDIR)/Budget.o \ +$(OBJDIR)/TimeArray.o \ +$(OBJDIR)/ObsOutput.o \ $(OBJDIR)/StructVector.o \ $(OBJDIR)/IdmLogger.o \ $(OBJDIR)/InputDefinitionSelector.o \ $(OBJDIR)/Integer1dReader.o \ $(OBJDIR)/Double2dReader.o \ $(OBJDIR)/Double1dReader.o \ +$(OBJDIR)/TimeArraySeries.o \ +$(OBJDIR)/ObsOutputList.o \ +$(OBJDIR)/Observe.o \ +$(OBJDIR)/StructArray.o \ +$(OBJDIR)/ModflowInput.o \ +$(OBJDIR)/LayeredArrayReader.o \ +$(OBJDIR)/TimeArraySeriesLink.o \ +$(OBJDIR)/ObsUtility.o \ +$(OBJDIR)/ObsContainer.o \ +$(OBJDIR)/BudgetFileReader.o \ +$(OBJDIR)/LoadMf6FileType.o \ +$(OBJDIR)/TimeArraySeriesManager.o \ +$(OBJDIR)/PackageMover.o \ +$(OBJDIR)/Obs3.o \ +$(OBJDIR)/NumericalPackage.o \ +$(OBJDIR)/Budget.o \ $(OBJDIR)/sort.o \ $(OBJDIR)/SfrCrossSectionUtils.o \ $(OBJDIR)/BudgetTerm.o \ +$(OBJDIR)/IdmMf6FileLoader.o \ $(OBJDIR)/BoundaryPackage.o \ $(OBJDIR)/BaseModel.o \ -$(OBJDIR)/StructArray.o \ -$(OBJDIR)/ModflowInput.o \ -$(OBJDIR)/LayeredArrayReader.o \ $(OBJDIR)/SfrCrossSectionManager.o \ $(OBJDIR)/dag_module.o \ $(OBJDIR)/BudgetObject.o \ @@ -144,7 +146,6 @@ $(OBJDIR)/HeadFileReader.o \ $(OBJDIR)/PrintSaveManager.o \ $(OBJDIR)/Xt3dAlgorithm.o \ $(OBJDIR)/gwf3tvbase8.o \ -$(OBJDIR)/LoadMf6FileType.o \ $(OBJDIR)/gwf3sfr8.o \ $(OBJDIR)/gwf3riv8.o \ $(OBJDIR)/gwf3maw8.o \ @@ -161,7 +162,6 @@ $(OBJDIR)/gwf3ic8.o \ $(OBJDIR)/Xt3dInterface.o \ $(OBJDIR)/gwf3tvk8.o \ $(OBJDIR)/MemoryManagerExt.o \ -$(OBJDIR)/IdmMf6FileLoader.o \ $(OBJDIR)/gwf3vsc8.o \ $(OBJDIR)/GwfNpfOptions.o \ $(OBJDIR)/CellWithNbrs.o \ diff --git a/src/Model/GroundWaterFlow/gwf3.f90 b/src/Model/GroundWaterFlow/gwf3.f90 index 46dcab65d32..f6d7b52f10f 100644 --- a/src/Model/GroundWaterFlow/gwf3.f90 +++ b/src/Model/GroundWaterFlow/gwf3.f90 @@ -89,6 +89,7 @@ module GwfModule procedure :: gwf_ot_flow procedure :: gwf_ot_dv procedure :: gwf_ot_bdsummary + procedure :: load_input_context => gwf_load_input_context ! end type GwfModelType @@ -253,16 +254,22 @@ subroutine gwf_cr(filename, id, modelname) ! ! -- Create discretization object if (indis6 > 0) then + call this%load_input_context('DIS6', this%name, 'DIS', indis, this%iout) call dis_cr(this%dis, this%name, indis, this%iout) elseif (indisu6 > 0) then + call this%load_input_context('DISU6', this%name, 'DISU', indis, this%iout) call disu_cr(this%dis, this%name, indis, this%iout) elseif (indisv6 > 0) then + call this%load_input_context('DISV6', this%name, 'DISV', indis, this%iout) call disv_cr(this%dis, this%name, indis, this%iout) end if ! ! -- Create utility objects call budget_cr(this%budget, this%name) ! + ! -- Load input context for currently supported packages + call this%load_input_context('NPF6', this%name, 'NPF', this%innpf, this%iout) + ! ! -- Create packages that are tied directly to model call npf_cr(this%npf, this%name, this%innpf, this%iout) call xt3d_cr(this%xt3d, this%name, this%innpf, this%iout) @@ -1552,4 +1559,38 @@ function CastAsGwfModel(model) result(gwfModel) end function CastAsGwfModel + !> @brief Load input context for supported package + !< + subroutine gwf_load_input_context(this, filtyp, modelname, pkgname, inunit, & + iout, ipaknum) + ! -- modules + use IdmMf6FileLoaderModule, only: input_load + ! -- dummy + class(GwfModelType) :: this + character(len=*), intent(in) :: filtyp + character(len=*), intent(in) :: modelname + character(len=*), intent(in) :: pkgname + integer(I4B), intent(in) :: inunit + integer(I4B), intent(in) :: iout + integer(I4B), optional, intent(in) :: ipaknum + ! -- local +! ------------------------------------------------------------------------------ + ! + ! -- only load if there is a file to read + if (inunit <= 0) return + ! + ! -- Load model package input to input context + select case (filtyp) + case ('NPF6') + call input_load('NPF6', 'GWF', 'NPF', modelname, pkgname, inunit, iout) + case default + call this%NumericalModelType%load_input_context(filtyp, modelname, & + pkgname, inunit, iout, & + ipaknum) + end select + ! + ! -- return + return + end subroutine gwf_load_input_context + end module GwfModule diff --git a/src/Model/GroundWaterFlow/gwf3dis8.f90 b/src/Model/GroundWaterFlow/gwf3dis8.f90 index 886fab9af76..123ec841418 100644 --- a/src/Model/GroundWaterFlow/gwf3dis8.f90 +++ b/src/Model/GroundWaterFlow/gwf3dis8.f90 @@ -7,7 +7,6 @@ module GwfDisModule use InputOutputModule, only: get_node, URWORD, ulasav, ulaprufw, ubdsv1, & ubdsv06 use SimModule, only: count_errors, store_error, store_error_unit - use BlockParserModule, only: BlockParserType use MemoryManagerModule, only: mem_allocate use MemoryHelperModule, only: create_mem_path use TdisModule, only: kstp, kper, pertim, totim, delt @@ -100,13 +99,6 @@ subroutine dis_cr(dis, name_model, inunit, iout) if (iout > 0) then write (iout, fmtheader) inunit end if - ! - ! -- Initialize block parser - call dis%parser%Initialize(inunit, iout) - ! - ! -- Use the input data model routines to load the input data - ! into memory - call input_load(dis%parser, 'DIS6', 'GWF', 'DIS', name_model, 'DIS', iout) end if ! ! -- Return @@ -295,17 +287,17 @@ subroutine source_dimensions(this) if (this%nlay < 1) then call store_error( & 'NLAY was not specified or was specified incorrectly.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if if (this%nrow < 1) then call store_error( & 'NROW was not specified or was specified incorrectly.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if if (this%ncol < 1) then call store_error( & 'NCOL was not specified or was specified incorrectly.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- calculate nodesuser @@ -476,7 +468,7 @@ subroutine grid_finalize(this) call store_error('Model does not have any active nodes. & &Ensure IDOMAIN array has some values greater & &than zero.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Check cell thicknesses @@ -500,7 +492,7 @@ subroutine grid_finalize(this) end do end do if (count_errors() > 0) then - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Write message if reduced grid diff --git a/src/Model/GroundWaterFlow/gwf3disu8.f90 b/src/Model/GroundWaterFlow/gwf3disu8.f90 index 13c0bd84fcd..a9bb4eeca35 100644 --- a/src/Model/GroundWaterFlow/gwf3disu8.f90 +++ b/src/Model/GroundWaterFlow/gwf3disu8.f90 @@ -9,7 +9,6 @@ module GwfDisuModule use SimModule, only: count_errors, store_error, store_error_unit use SimVariablesModule, only: errmsg use BaseDisModule, only: DisBaseType - use BlockParserModule, only: BlockParserType use MemoryManagerModule, only: mem_allocate use TdisModule, only: kstp, kper, pertim, totim, delt @@ -121,14 +120,6 @@ subroutine disu_cr(dis, name_model, inunit, iout) write (iout, fmtheader) inunit end if ! - ! -- initialize parser and load the disu input file - call dis%parser%Initialize(inunit, iout) - ! - ! -- Use the input data model routines to load the input data - ! into memory - call input_load(dis%parser, 'DISU6', 'GWF', 'DISU', name_model, 'DISU', & - iout) - ! ! -- load disu call disnew%disu_load() end if @@ -228,7 +219,7 @@ subroutine grid_finalize(this) call store_error('Model does not have any active nodes. & &Ensure IDOMAIN array has some values greater & &than zero.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Write message if reduced grid @@ -709,7 +700,7 @@ subroutine source_dimensions(this) ! ! -- terminate if errors were detected if (count_errors() > 0) then - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- allocate vectors that are the size of nodesuser diff --git a/src/Model/GroundWaterFlow/gwf3disv8.f90 b/src/Model/GroundWaterFlow/gwf3disv8.f90 index 5db18e0a428..dcfc20a08e1 100644 --- a/src/Model/GroundWaterFlow/gwf3disv8.f90 +++ b/src/Model/GroundWaterFlow/gwf3disv8.f90 @@ -9,7 +9,6 @@ module GwfDisvModule ubdsv06 use SimModule, only: count_errors, store_error, store_error_unit use DisvGeom, only: DisvGeomType - use BlockParserModule, only: BlockParserType use MemoryManagerModule, only: mem_allocate use MemoryHelperModule, only: create_mem_path use TdisModule, only: kstp, kper, pertim, totim, delt @@ -105,14 +104,6 @@ subroutine disv_cr(dis, name_model, inunit, iout) write (iout, fmtheader) inunit end if ! - ! -- initialize parser and load the disv input file - call dis%parser%Initialize(dis%inunit, dis%iout) - ! - ! -- Use the input data model routines to load the input data - ! into memory - call input_load(dis%parser, 'DISV6', 'GWF', 'DISV', name_model, 'DISV', & - iout) - ! ! -- load disv call disnew%disv_load() end if @@ -324,17 +315,17 @@ subroutine source_dimensions(this) if (this%nlay < 1) then call store_error( & 'NLAY was not specified or was specified incorrectly.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if if (this%ncpl < 1) then call store_error( & 'NCPL was not specified or was specified incorrectly.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if if (this%nvert < 1) then call store_error( & 'NVERT was not specified or was specified incorrectly.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Calculate nodesuser @@ -487,7 +478,7 @@ subroutine grid_finalize(this) call store_error('Model does not have any active nodes. & &Ensure IDOMAIN array has some values greater & &than zero.') - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Check cell thicknesses @@ -509,7 +500,7 @@ subroutine grid_finalize(this) end do end do if (count_errors() > 0) then - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Write message if reduced grid diff --git a/src/Model/GroundWaterFlow/gwf3npf8.f90 b/src/Model/GroundWaterFlow/gwf3npf8.f90 index dc1999cf419..39458742db8 100644 --- a/src/Model/GroundWaterFlow/gwf3npf8.f90 +++ b/src/Model/GroundWaterFlow/gwf3npf8.f90 @@ -13,7 +13,6 @@ module GwfNpfModule use GwfIcModule, only: GwfIcType use GwfVscModule, only: GwfVscType use Xt3dModule, only: Xt3dType - use BlockParserModule, only: BlockParserType use InputOutputModule, only: GetUnit, openfile use TvkModule, only: TvkType, tvk_cr use MemoryManagerModule, only: mem_allocate, mem_reallocate, & @@ -188,14 +187,6 @@ subroutine npf_cr(npfobj, name_model, inunit, iout) ! ! -- Print a message identifying the node property flow package. write (iout, fmtheader) inunit - ! - ! -- Initialize block parser and read options - call npfobj%parser%Initialize(inunit, iout) - ! - ! -- Use the input data model routines to load the input data - ! into memory - call input_load(npfobj%parser, 'NPF6', 'GWF', 'NPF', npfobj%name_model, & - 'NPF', iout) end if ! ! -- Return @@ -1581,7 +1572,7 @@ subroutine check_options(this) ! SPECIFICATIONS: ! ------------------------------------------------------------------------------ ! -- modules - use SimModule, only: store_error, count_errors + use SimModule, only: store_error, count_errors, store_error_unit use ConstantsModule, only: LINELENGTH ! -- dummy class(GwfNpftype) :: this @@ -1678,7 +1669,7 @@ subroutine check_options(this) ! ! -- Terminate if errors if (count_errors() > 0) then - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Return @@ -1842,7 +1833,7 @@ subroutine prepcheck(this) ! SPECIFICATIONS: ! ------------------------------------------------------------------------------ use ConstantsModule, only: LINELENGTH, DPIO180 - use SimModule, only: store_error, count_errors + use SimModule, only: store_error, count_errors, store_error_unit ! -- dummy class(GwfNpfType) :: this ! -- local @@ -1987,7 +1978,7 @@ subroutine prepcheck(this) ! ! -- terminate if data errors if (count_errors() > 0) then - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if return @@ -2005,7 +1996,7 @@ end subroutine prepcheck !< subroutine preprocess_input(this) use ConstantsModule, only: LINELENGTH - use SimModule, only: store_error, count_errors + use SimModule, only: store_error, count_errors, store_error_unit class(GwfNpfType) :: this !< the instance of the NPF package ! local integer(I4B) :: n, m, ii, nn @@ -2131,7 +2122,7 @@ subroutine preprocess_input(this) end if end do if (count_errors() > 0) then - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Calculate condsat, but only if xt3d is not active. If xt3d is @@ -2320,7 +2311,7 @@ subroutine sgwf_npf_wetdry(this, kiter, hnew) ! ------------------------------------------------------------------------------ ! -- modules use TdisModule, only: kstp, kper - use SimModule, only: store_error + use SimModule, only: store_error, store_error_unit use ConstantsModule, only: LINELENGTH ! -- dummy class(GwfNpfType) :: this @@ -2380,7 +2371,7 @@ subroutine sgwf_npf_wetdry(this, kiter, hnew) call store_error(errmsg) write (errmsg, fmttopbot) ttop, bbot call store_error(errmsg) - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if ! ! -- Calculate saturated thickness @@ -2402,7 +2393,7 @@ subroutine sgwf_npf_wetdry(this, kiter, hnew) call this%dis%noder_to_string(n, nodestr) write (errmsg, fmtni) trim(adjustl(nodestr)), kiter, kstp, kper call store_error(errmsg) - call this%parser%StoreErrorUnit() + call store_error_unit(this%inunit) end if this%ibound(n) = 0 end if diff --git a/src/Model/GroundWaterTransport/gwt1.f90 b/src/Model/GroundWaterTransport/gwt1.f90 index 32d94f25f0f..aa06b49403d 100644 --- a/src/Model/GroundWaterTransport/gwt1.f90 +++ b/src/Model/GroundWaterTransport/gwt1.f90 @@ -82,7 +82,7 @@ module GwtModule procedure, private :: gwt_ot_dv procedure, private :: gwt_ot_bdsummary procedure, private :: gwt_ot_obs - + procedure :: load_input_context => gwt_load_input_context end type GwtModelType ! -- Module variables constant for simulation @@ -228,16 +228,22 @@ subroutine gwt_cr(filename, id, modelname) ! ! -- Create discretization object if (indis6 > 0) then + call this%load_input_context('DIS6', this%name, 'DIS', indis, this%iout) call dis_cr(this%dis, this%name, indis, this%iout) elseif (indisu6 > 0) then + call this%load_input_context('DISU6', this%name, 'DISU', indis, this%iout) call disu_cr(this%dis, this%name, indis, this%iout) elseif (indisv6 > 0) then + call this%load_input_context('DISV6', this%name, 'DISV', indis, this%iout) call disv_cr(this%dis, this%name, indis, this%iout) end if ! ! -- Create utility objects call budget_cr(this%budget, this%name) ! + ! -- Load input context for currently supported packages + call this%load_input_context('DSP6', this%name, 'DSP', this%indsp, this%iout) + ! ! -- Create packages that are tied directly to model call ic_cr(this%ic, this%name, this%inic, this%iout, this%dis) call fmi_cr(this%fmi, this%name, this%infmi, this%iout) @@ -1282,4 +1288,38 @@ function CastAsGwtModel(model) result(gwtmodel) end function CastAsGwtModel + !> @brief Load input context for supported package + !< + subroutine gwt_load_input_context(this, filtyp, modelname, pkgname, inunit, & + iout, ipaknum) + ! -- modules + use IdmMf6FileLoaderModule, only: input_load + ! -- dummy + class(GwtModelType) :: this + character(len=*), intent(in) :: filtyp + character(len=*), intent(in) :: modelname + character(len=*), intent(in) :: pkgname + integer(I4B), intent(in) :: inunit + integer(I4B), intent(in) :: iout + integer(I4B), optional, intent(in) :: ipaknum + ! -- local +! ------------------------------------------------------------------------------ + ! + ! -- only load if there is a file to read + if (inunit <= 0) return + ! + ! -- Load model package input to input context + select case (filtyp) + case ('DSP6') + call input_load('DSP6', 'GWT', 'DSP', modelname, pkgname, inunit, iout) + case default + call this%NumericalModelType%load_input_context(filtyp, modelname, & + pkgname, inunit, iout, & + ipaknum) + end select + ! + ! -- return + return + end subroutine gwt_load_input_context + end module GwtModule diff --git a/src/Model/GroundWaterTransport/gwt1dsp.f90 b/src/Model/GroundWaterTransport/gwt1dsp.f90 index c61c926267c..e052ffd4778 100644 --- a/src/Model/GroundWaterTransport/gwt1dsp.f90 +++ b/src/Model/GroundWaterTransport/gwt1dsp.f90 @@ -115,14 +115,6 @@ subroutine dsp_cr(dspobj, name_model, inunit, iout, fmi) if (dspobj%iout > 0) then write (dspobj%iout, fmtdsp) dspobj%inunit end if - ! - ! -- Initialize block parser - call dspobj%parser%Initialize(dspobj%inunit, dspobj%iout) - ! - ! -- Use the input data model routines to load the input data - ! into memory - call input_load(dspobj%parser, 'DSP6', 'GWT', 'DSP', dspobj%name_model, & - 'DSP', iout) end if ! ! -- Return diff --git a/src/Model/NumericalModel.f90 b/src/Model/NumericalModel.f90 index ea6d6dfa5f2..96b10b221aa 100644 --- a/src/Model/NumericalModel.f90 +++ b/src/Model/NumericalModel.f90 @@ -73,6 +73,7 @@ module NumericalModelModule procedure :: get_mcellid procedure :: get_mnodeu procedure :: get_iasym + procedure :: load_input_context end type NumericalModelType contains @@ -439,4 +440,39 @@ function GetNumericalModelFromList(list, idx) result(res) return end function GetNumericalModelFromList + !> @brief Load input context for supported package + !< + subroutine load_input_context(this, filtyp, modelname, pkgname, inunit, iout, & + ipaknum) + ! -- modules + use IdmMf6FileLoaderModule, only: input_load + ! -- dummy + class(NumericalModelType) :: this + character(len=*), intent(in) :: filtyp + character(len=*), intent(in) :: modelname + character(len=*), intent(in) :: pkgname + integer(I4B), intent(in) :: inunit + integer(I4B), intent(in) :: iout + integer(I4B), optional, intent(in) :: ipaknum + ! -- local +! ------------------------------------------------------------------------------ + ! + ! -- only load if there is a file to read + if (inunit <= 0) return + ! + ! -- Load model package input to input context + select case (filtyp) + case ('DIS6') + call input_load('DIS6', 'GWF', 'DIS', modelname, pkgname, inunit, iout) + case ('DISU6') + call input_load('DISU6', 'GWF', 'DISU', modelname, pkgname, inunit, iout) + case ('DISV6') + call input_load('DISV6', 'GWF', 'DISV', modelname, pkgname, inunit, iout) + case default + end select + ! + ! -- return + return + end subroutine load_input_context + end module NumericalModelModule diff --git a/src/Utilities/Idm/IdmMf6FileLoader.f90 b/src/Utilities/Idm/IdmMf6FileLoader.f90 index 5212b1a516f..57de69f32d7 100644 --- a/src/Utilities/Idm/IdmMf6FileLoader.f90 +++ b/src/Utilities/Idm/IdmMf6FileLoader.f90 @@ -16,7 +16,7 @@ module IdmMf6FileLoaderModule public :: input_load interface input_load - module procedure input_load_blockparser + module procedure input_load_blockparser, input_load_generic end interface input_load !> @brief derived type for storing package loader @@ -92,4 +92,44 @@ subroutine input_load_blockparser(parser, filetype, & return end subroutine input_load_blockparser + !> @brief main entry to mf6 input load + !< + subroutine input_load_generic(filetype, & + component_type, subcomponent_type, & + component_name, subcomponent_name, & + inunit, iout) + character(len=*), intent(in) :: filetype !< file type to load, such as DIS6, DISV6, NPF6 + character(len=*), intent(in) :: component_type !< component type, such as GWF or GWT + character(len=*), intent(in) :: subcomponent_type !< subcomponent type, such as DIS or NPF + character(len=*), intent(in) :: component_name !< component name, such as MYGWFMODEL + character(len=*), intent(in) :: subcomponent_name !< subcomponent name, such as MYWELLPACKAGE + integer(I4B), intent(in) :: inunit !< unit number for input + integer(I4B), intent(in) :: iout !< unit number for output + type(BlockParserType), allocatable :: parser !< block parser + type(ModflowInputType) :: mf6_input + type(PackageLoad) :: pkgloader + ! + ! -- create description of input + mf6_input = getModflowInput(filetype, component_type, & + subcomponent_type, component_name, & + subcomponent_name) + ! + ! -- set mf6 parser based package loader by file type + select case (filetype) + case default + allocate (parser) + call parser%Initialize(inunit, iout) + pkgloader%load_package => generic_mf6_load + end select + ! + ! -- invoke the selected load routine + call pkgloader%load_package(parser, mf6_input, iout) + ! + ! -- deallocate + if (allocated(parser)) deallocate (parser) + ! + ! -- return + return + end subroutine input_load_generic + end module IdmMf6FileLoaderModule diff --git a/utils/mf5to6/make/makefile b/utils/mf5to6/make/makefile index e286aaf1171..e1c0b88e1e3 100644 --- a/utils/mf5to6/make/makefile +++ b/utils/mf5to6/make/makefile @@ -6,9 +6,9 @@ include ./makedefaults # Define the source file directories SOURCEDIR1=../src SOURCEDIR2=../src/LGR -SOURCEDIR3=../src/Preproc -SOURCEDIR4=../src/MF2005 -SOURCEDIR5=../src/NWT +SOURCEDIR3=../src/MF2005 +SOURCEDIR4=../src/NWT +SOURCEDIR5=../src/Preproc SOURCEDIR6=../../../src/Utilities/Memory SOURCEDIR7=../../../src/Utilities/TimeSeries SOURCEDIR8=../../../src/Utilities