Skip to content

Commit

Permalink
feat(idm): update RCH package for IDM (MODFLOW-USGS#1380)
Browse files Browse the repository at this point in the history
* update RCH package for IDM

* rebuild makefiles

* some rch package cleanup

* add write_list call, additional cleanup

---------

Co-authored-by: mjreno <mreno@IGSAAA071L00066.gs.doi.net>
  • Loading branch information
mjreno and mjreno authored Oct 3, 2023
1 parent 275853a commit c223046
Show file tree
Hide file tree
Showing 16 changed files with 1,305 additions and 453 deletions.
4 changes: 2 additions & 2 deletions autotest/test_gwf_libmf6_rch01.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def api_func(exe, idx, model_ws=None):
max_iter = mf6.get_value(mxit_tag)

# get copy of recharge array
rch_tag = mf6.get_var_address("BOUND", name, rch_pname)
rch_tag = mf6.get_var_address("RECHARGE", name, rch_pname)
new_recharge = mf6.get_value(rch_tag)

# model time loop
Expand All @@ -193,7 +193,7 @@ def api_func(exe, idx, model_ws=None):
mf6.prepare_solve()

# update recharge
new_recharge[:, 0] = rch_spd[idx] * area
new_recharge[:] = rch_spd[idx]
mf6.set_value(rch_tag, new_recharge)

while kiter < max_iter:
Expand Down
4 changes: 2 additions & 2 deletions autotest/test_gwf_libmf6_rch02.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def run_perturbation(mf6, max_iter, recharge, tag, rch):
kiter = 0
while kiter < max_iter:
# update recharge
recharge[:, 0] = rch * area
recharge[:] = rch
mf6.set_value(tag, recharge)
# solve with updated well rate
has_converged = mf6.solve()
Expand Down Expand Up @@ -222,7 +222,7 @@ def api_func(exe, idx, model_ws=None):
max_iter = mf6.get_value(mxit_tag)

# get copy of recharge array
rch_tag = mf6.get_var_address("BOUND", name, rch_pname)
rch_tag = mf6.get_var_address("RECHARGE", name, rch_pname)
new_recharge = mf6.get_value(rch_tag).copy()

# determine initial recharge value
Expand Down
6 changes: 6 additions & 0 deletions doc/mf6io/mf6ivar/dfn/gwf-rch.dfn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# --------------------- gwf rch options ---------------------
# flopy multi-package
# modflow6 aux-sfac-param recharge

block options
name fixed_cell
Expand Down Expand Up @@ -44,6 +45,7 @@ reader urword
optional true
longname print input to listing file
description REPLACE print_input {'{#1}': 'recharge'}
mf6internal iprpak

block options
name print_flows
Expand All @@ -52,6 +54,7 @@ reader urword
optional true
longname print recharge rates to listing file
description REPLACE print_flows {'{#1}': 'recharge'}
mf6internal iprflow

block options
name save_flows
Expand All @@ -60,6 +63,7 @@ reader urword
optional true
longname save recharge to budget file
description REPLACE save_flows {'{#1}': 'recharge'}
mf6internal ipakcb

block options
name ts_filerecord
Expand Down Expand Up @@ -169,6 +173,7 @@ shape (maxbound)
reader urword
longname
description
mf6internal spd

block period
name cellid
Expand Down Expand Up @@ -202,6 +207,7 @@ optional true
time_series true
longname auxiliary variables
description REPLACE aux {'{#1}': 'recharge'}
mf6internal auxvar

block period
name boundname
Expand Down
7 changes: 7 additions & 0 deletions doc/mf6io/mf6ivar/dfn/gwf-rcha.dfn
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# --------------------- gwf rcha options ---------------------
# flopy multi-package
# modflow6 aux-sfac-param recharge

block options
name readasarrays
Expand Down Expand Up @@ -45,6 +46,7 @@ reader urword
optional true
longname print input to listing file
description REPLACE print_input {'{#1}': 'recharge'}
mf6internal iprpak

block options
name print_flows
Expand All @@ -53,6 +55,7 @@ reader urword
optional true
longname print recharge rates to listing file
description REPLACE print_flows {'{#1}': 'recharge'}
mf6internal iprflow

block options
name save_flows
Expand All @@ -61,6 +64,7 @@ reader urword
optional true
longname save CHD flows to budget file
description REPLACE save_flows {'{#1}': 'recharge'}
mf6internal ipakcb

block options
name tas_filerecord
Expand Down Expand Up @@ -168,6 +172,7 @@ name recharge
type double precision
shape (ncol*nrow; ncpl)
reader readarray
time_series true
longname recharge rate
description is the recharge flux rate ($LT^{-1}$). This rate is multiplied inside the program by the surface area of the cell to calculate the volumetric recharge rate. The recharge array may be defined by a time-array series (see the "Using Time-Array Series in a Package" section).
default_value 1.e-3
Expand All @@ -177,6 +182,8 @@ name aux
type double precision
shape (ncol*nrow; ncpl)
reader readarray
time_series true
optional true
longname auxiliary variable iaux
description is an array of values for auxiliary variable aux(iaux), where iaux is a value from 1 to naux, and aux(iaux) must be listed as part of the auxiliary variables. A separate array can be specified for each auxiliary variable. If an array is not specified for an auxiliary variable, then a value of zero is assigned. If the value specified here for the auxiliary variable is the same as auxmultname, then the recharge array will be multiplied by this array.
mf6internal auxvar
2 changes: 2 additions & 0 deletions make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ $(OBJDIR)/gwt1disu1idm.o \
$(OBJDIR)/gwt1dis1idm.o \
$(OBJDIR)/gwf3wel8idm.o \
$(OBJDIR)/gwf3riv8idm.o \
$(OBJDIR)/gwf3rch8idm.o \
$(OBJDIR)/gwf3rcha8idm.o \
$(OBJDIR)/gwf3npf8idm.o \
$(OBJDIR)/gwf3idm.o \
$(OBJDIR)/gwf3ghb8idm.o \
Expand Down
2 changes: 2 additions & 0 deletions msvs/mf6core.vfproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3obs8.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3oc8.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3rch8.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3rch8idm.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3rcha8idm.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3riv8.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3riv8idm.f90"/>
<File RelativePath="..\src\Model\GroundWaterFlow\gwf3sfr8.f90"/>
Expand Down
3 changes: 2 additions & 1 deletion src/Model/GroundWaterFlow/gwf3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,8 @@ subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, mempath, &
call ghb_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &
pakname, mempath)
case ('RCH6')
call rch_create(packobj, ipakid, ipaknum, inunit, iout, this%name, pakname)
call rch_create(packobj, ipakid, ipaknum, inunit, iout, this%name, &
pakname, mempath)
case ('EVT6')
call evt_create(packobj, ipakid, ipaknum, inunit, iout, this%name, pakname)
case ('MAW6')
Expand Down
88 changes: 88 additions & 0 deletions src/Model/GroundWaterFlow/gwf3dis8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module GwfDisModule
procedure, public :: read_layer_array
procedure, public :: record_srcdst_list_header
procedure, public :: nlarray_to_nodelist
procedure, public :: nlarray_to_nodelist2
! -- helper functions
procedure :: get_nodenumber_idx1
procedure :: get_nodenumber_idx3
Expand Down Expand Up @@ -1747,4 +1748,91 @@ subroutine nlarray_to_nodelist(this, nodelist, maxbnd, nbound, aname, &
! -- return
end subroutine nlarray_to_nodelist

subroutine nlarray_to_nodelist2(this, darray, nodelist, maxbnd, nbound, aname)
! ******************************************************************************
! nlarray_to_nodelist -- Read an integer array into nodelist. For structured
! model, integer array is layer number; for unstructured
! model, integer array is node number.
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use InputOutputModule, only: get_node
use ConstantsModule, only: LINELENGTH
! -- dummy
class(GwfDisType) :: this
integer(I4B), intent(in) :: maxbnd
integer(I4B), dimension(:), pointer, contiguous :: darray
integer(I4B), dimension(maxbnd), intent(inout) :: nodelist
integer(I4B), intent(inout) :: nbound
character(len=*), intent(in) :: aname
! -- local
integer(I4B) :: il, ir, ic, ncol, nrow, nlay, nval, nodeu, noder, ipos, ierr
! ------------------------------------------------------------------------------
!
! -- set variables
nlay = this%mshape(1)
nrow = this%mshape(2)
ncol = this%mshape(3)
!
if (this%ndim > 1) then
!
nval = ncol * nrow
!
! -- Copy array into nodelist
ipos = 1
ierr = 0
do ir = 1, nrow
do ic = 1, ncol
nodeu = get_node(1, ir, ic, nlay, nrow, ncol)
il = darray(nodeu)
if (il < 1 .or. il > nlay) then
write (errmsg, '(a,1x,i0)') 'Invalid layer number:', il
call store_error(errmsg, terminate=.TRUE.)
end if
nodeu = get_node(il, ir, ic, nlay, nrow, ncol)
noder = this%get_nodenumber(nodeu, 0)
if (ipos > maxbnd) then
ierr = ipos
else
nodelist(ipos) = noder
end if
ipos = ipos + 1
end do
end do
!
! -- Check for errors
nbound = ipos - 1
if (ierr > 0) then
write (errmsg, '(a,1x,i0)') &
'MAXBOUND dimension is too small.'// &
'INCREASE MAXBOUND TO:', ierr
call store_error(errmsg, terminate=.TRUE.)
end if
!
! -- If nbound < maxbnd, then initialize nodelist to zero in this range
if (nbound < maxbnd) then
do ipos = nbound + 1, maxbnd
nodelist(ipos) = 0
end do
end if
!
else
!
! -- For unstructured, read nodelist directly, then check node numbers
nodelist = darray
do noder = 1, maxbnd
if (noder < 1 .or. noder > this%nodes) then
write (errmsg, '(a,1x,i0)') 'Invalid node number:', noder
call store_error(errmsg, terminate=.TRUE.)
end if
end do
nbound = maxbnd
!
end if
!
! -- return
end subroutine nlarray_to_nodelist2

end module GwfDisModule
71 changes: 71 additions & 0 deletions src/Model/GroundWaterFlow/gwf3disv8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module GwfDisvModule
procedure, public :: read_layer_array
procedure, public :: record_srcdst_list_header
procedure, public :: nlarray_to_nodelist
procedure, public :: nlarray_to_nodelist2
! -- helper functions
procedure :: get_nodenumber_idx1
procedure :: get_nodenumber_idx2
Expand Down Expand Up @@ -1981,4 +1982,74 @@ subroutine nlarray_to_nodelist(this, nodelist, maxbnd, nbound, aname, &
! -- return
end subroutine nlarray_to_nodelist

subroutine nlarray_to_nodelist2(this, darray, nodelist, maxbnd, nbound, aname)
! ******************************************************************************
! nlarray_to_nodelist -- Read an integer array into nodelist. For structured
! model, integer array is layer number; for unstructured
! model, integer array is node number.
! ******************************************************************************
!
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use InputOutputModule, only: get_node
! -- dummy
class(GwfDisvType) :: this
integer(I4B), intent(in) :: maxbnd
integer(I4B), dimension(:), pointer, contiguous :: darray
integer(I4B), dimension(maxbnd), intent(inout) :: nodelist
integer(I4B), intent(inout) :: nbound
character(len=*), intent(in) :: aname
! -- local
integer(I4B) :: il, ir, ic, ncol, nrow, nlay, nval, nodeu, noder, ipos, ierr
! ------------------------------------------------------------------------------
!
! -- set variables
nlay = this%mshape(1)
nrow = 1
ncol = this%mshape(2)
!
nval = ncol * nrow
!
! -- Copy array into nodelist
ipos = 1
ierr = 0
do ir = 1, nrow
do ic = 1, ncol
nodeu = get_node(1, ir, ic, nlay, nrow, ncol)
il = darray(nodeu)
if (il < 1 .or. il > nlay) then
write (errmsg, '(a,i0,a)') &
'Invalid layer number (', il, ').'
call store_error(errmsg, terminate=.TRUE.)
end if
nodeu = get_node(il, ir, ic, nlay, nrow, ncol)
noder = this%get_nodenumber(nodeu, 0)
if (ipos > maxbnd) then
ierr = ipos
else
nodelist(ipos) = noder
end if
ipos = ipos + 1
end do
end do
!
! -- Check for errors
nbound = ipos - 1
if (ierr > 0) then
write (errmsg, '(a,i0,a)') &
'MAXBOUND dimension is too small. Increase MAXBOUND to ', ierr, '.'
call store_error(errmsg, terminate=.TRUE.)
end if
!
! -- If nbound < maxbnd, then initialize nodelist to zero in this range
if (nbound < maxbnd) then
do ipos = nbound + 1, maxbnd
nodelist(ipos) = 0
end do
end if
!
! -- return
end subroutine nlarray_to_nodelist2

end module GwfDisvModule
Loading

0 comments on commit c223046

Please sign in to comment.