Skip to content

Commit

Permalink
refactor(idm): consolidate package input context load in model create (
Browse files Browse the repository at this point in the history
…#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 <[email protected]>
  • Loading branch information
mjreno and mjreno authored Dec 26, 2022
1 parent 8758486 commit 84c3893
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 105 deletions.
72 changes: 36 additions & 36 deletions make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand Down Expand Up @@ -96,44 +96,46 @@ $(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 \
$(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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down
41 changes: 41 additions & 0 deletions src/Model/GroundWaterFlow/gwf3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
18 changes: 5 additions & 13 deletions src/Model/GroundWaterFlow/gwf3dis8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 2 additions & 11 deletions src/Model/GroundWaterFlow/gwf3disu8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 5 additions & 14 deletions src/Model/GroundWaterFlow/gwf3disv8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 84c3893

Please sign in to comment.