Skip to content

Commit

Permalink
refactor(BndType): Generalized BndType pointer to NPF ICELLTYPE to be…
Browse files Browse the repository at this point in the history
… model agnostic (#93)

ICELLTYPE is a member of BndType, which is supposed to be a general package class for GWF and other models.  But ICELLTYPE is an NPF thing.  This PR generalizes the ICELLTYPE member by allowing packages to set the origin of this variable.  For the GWF Boundary packages, the ictorigin value is set to "NPF".  If ictorigin is not set, then BndType will not try to set ICELLTYPE, and it will remain null().

Closes #67
  • Loading branch information
langevin-usgs committed Feb 15, 2019
1 parent 1c7309f commit 737ca3b
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 19 deletions.
24 changes: 11 additions & 13 deletions src/Model/GroundWaterFlow/gwf3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,6 @@ subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, inunit, &
integer(I4B) :: ip
! ------------------------------------------------------------------------------
!
! -- Now supporting new-style WEL and GHB packages.
! -- This part creates the package object
select case(filtyp)
case('CHD6')
Expand Down Expand Up @@ -1363,18 +1362,17 @@ subroutine package_create(this, filtyp, ipakid, ipaknum, pakname, inunit, &
call ustop()
end select
!
! -- Packages is the bndlist that is associated with the parent model
! -- The following statement puts a pointer to this package in the ipakid
! -- position of packages.
do ip = 1, this%bndlist%Count()
packobj2 => GetBndFromList(this%bndlist, ip)
if(packobj2%name == pakname) then
write(errmsg, '(a,a)') 'Cannot create package. Package name ' // &
'already exists: ', trim(pakname)
call store_error(errmsg)
call ustop()
endif
enddo
! -- Check to make sure that the package name is unique, then store a
! pointer to the package in the model bndlist
do ip = 1, this%bndlist%Count()
packobj2 => GetBndFromList(this%bndlist, ip)
if(packobj2%name == pakname) then
write(errmsg, '(a,a)') 'Cannot create package. Package name ' // &
'already exists: ', trim(pakname)
call store_error(errmsg)
call ustop()
endif
enddo
call AddBndToList(this%bndlist, packobj)
!
! -- return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3chd8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ subroutine chd_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 1
packobj%iscloc = 1
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3drn8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ subroutine drn_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd=2 ! drnelev, conductance
packobj%iscloc=2 !sfac applies to conductance
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3evt8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ subroutine evt_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 3 ! Assumes NSEG = 1
packobj%iscloc = 2 ! sfac applies to max. ET rate
packobj%ictorigin = 'NPF'
! indxconvertflux is Column index of bound that will be multiplied by
! cell area to convert flux rates to flow rates
packobj%indxconvertflux = 2
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3ghb8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ subroutine ghb_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd=2
packobj%iscloc=2
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3lak8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ subroutine lak_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 3
packobj%iscloc = 0 ! not supported
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3maw8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ subroutine maw_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 4
packobj%iscloc = 0 ! not supported
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3rch8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ subroutine rch_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 1
packobj%iscloc = 1 ! sfac applies to recharge rate
packobj%ictorigin = 'NPF'
! indxconvertflux is Column index of bound that will be multiplied by
! cell area to convert flux rates to flow rates
packobj%indxconvertflux = 1
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3riv8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ subroutine riv_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd=3 ! stage, conductance, rbot
packobj%iscloc=2 !sfac applies to conductance
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3sfr8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ subroutine sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 4
packobj%iscloc = 0 ! not supported
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3uzf8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ subroutine uzf_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd = 1
packobj%iscloc = 0 ! not supported
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
1 change: 1 addition & 0 deletions src/Model/GroundWaterFlow/gwf3wel8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ subroutine wel_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
packobj%ibcnum = ibcnum
packobj%ncolbnd=1
packobj%iscloc=1
packobj%ictorigin = 'NPF'
!
! -- return
return
Expand Down
13 changes: 8 additions & 5 deletions src/Model/ModelUtilities/BoundaryPackage.f90
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module BndModule
real(DP), dimension(:), pointer, contiguous :: xold => null() !dependent variable for last time step
real(DP), dimension(:), pointer, contiguous :: flowja => null() !intercell flows
integer(I4B), dimension(:), pointer, contiguous :: icelltype => null() !pointer to icelltype array in NPF

character(len=10) :: ictorigin = '' !package name for icelltype (NPF for GWF)
contains
procedure :: bnd_df
procedure :: bnd_ac
Expand Down Expand Up @@ -992,17 +992,20 @@ subroutine allocate_arrays(this, nodelist, auxvar)
allocate(this%boundname(1))
endif
!
! -- Set pointer to ICELLTYPE
call mem_setptr(this%icelltype, 'ICELLTYPE', &
trim(adjustl(this%name_model))//' NPF')
! -- Set pointer to ICELLTYPE. For GWF boundary packages,
! this%ictorigin will be 'NPF'. If boundary packages do not set
! this%ictorigin, then icelltype will remain as null()
if (this%ictorigin /= '') &
call mem_setptr(this%icelltype, 'ICELLTYPE', &
trim(adjustl(this%name_model)) // ' ' // &
trim(adjustl(this%ictorigin)))
!
! -- Initialize values
do j = 1, this%maxbound
do i = 1, this%ncolbnd
this%bound(i, j) = DZERO
end do
end do

do i = 1, this%maxbound
this%hcof(i) = DZERO
this%rhs(i) = DZERO
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# MODFLOW 6 version file automatically created using...pre-commit.py
# created on...February 15, 2019 11:17:03
# created on...February 15, 2019 13:36:06

# add some comments on how this version file
# should be manually updated and used
Expand Down

0 comments on commit 737ca3b

Please sign in to comment.