From 737ca3bb83519d4724afe8354aba81535ba42a73 Mon Sep 17 00:00:00 2001 From: langevin-usgs Date: Fri, 15 Feb 2019 14:14:14 -0500 Subject: [PATCH] refactor(BndType): Generalized BndType pointer to NPF ICELLTYPE to be 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 --- src/Model/GroundWaterFlow/gwf3.f90 | 24 +++++++++----------- src/Model/GroundWaterFlow/gwf3chd8.f90 | 1 + src/Model/GroundWaterFlow/gwf3drn8.f90 | 1 + src/Model/GroundWaterFlow/gwf3evt8.f90 | 1 + src/Model/GroundWaterFlow/gwf3ghb8.f90 | 1 + src/Model/GroundWaterFlow/gwf3lak8.f90 | 1 + src/Model/GroundWaterFlow/gwf3maw8.f90 | 1 + src/Model/GroundWaterFlow/gwf3rch8.f90 | 1 + src/Model/GroundWaterFlow/gwf3riv8.f90 | 1 + src/Model/GroundWaterFlow/gwf3sfr8.f90 | 1 + src/Model/GroundWaterFlow/gwf3uzf8.f90 | 1 + src/Model/GroundWaterFlow/gwf3wel8.f90 | 1 + src/Model/ModelUtilities/BoundaryPackage.f90 | 13 +++++++---- version.txt | 2 +- 14 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/Model/GroundWaterFlow/gwf3.f90 b/src/Model/GroundWaterFlow/gwf3.f90 index f78a3716ef3..6c86e95698b 100644 --- a/src/Model/GroundWaterFlow/gwf3.f90 +++ b/src/Model/GroundWaterFlow/gwf3.f90 @@ -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') @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3chd8.f90 b/src/Model/GroundWaterFlow/gwf3chd8.f90 index 3e51d621289..cab648f055e 100644 --- a/src/Model/GroundWaterFlow/gwf3chd8.f90 +++ b/src/Model/GroundWaterFlow/gwf3chd8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3drn8.f90 b/src/Model/GroundWaterFlow/gwf3drn8.f90 index 2fe3278a25b..cae4d87c712 100644 --- a/src/Model/GroundWaterFlow/gwf3drn8.f90 +++ b/src/Model/GroundWaterFlow/gwf3drn8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3evt8.f90 b/src/Model/GroundWaterFlow/gwf3evt8.f90 index af3cdc3d021..75af19a6a6d 100644 --- a/src/Model/GroundWaterFlow/gwf3evt8.f90 +++ b/src/Model/GroundWaterFlow/gwf3evt8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3ghb8.f90 b/src/Model/GroundWaterFlow/gwf3ghb8.f90 index b8648921a42..54b304925f0 100644 --- a/src/Model/GroundWaterFlow/gwf3ghb8.f90 +++ b/src/Model/GroundWaterFlow/gwf3ghb8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3lak8.f90 b/src/Model/GroundWaterFlow/gwf3lak8.f90 index 4493b532e49..800df1b5798 100644 --- a/src/Model/GroundWaterFlow/gwf3lak8.f90 +++ b/src/Model/GroundWaterFlow/gwf3lak8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3maw8.f90 b/src/Model/GroundWaterFlow/gwf3maw8.f90 index d066584b9e2..a71edfe94b8 100644 --- a/src/Model/GroundWaterFlow/gwf3maw8.f90 +++ b/src/Model/GroundWaterFlow/gwf3maw8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3rch8.f90 b/src/Model/GroundWaterFlow/gwf3rch8.f90 index 1cc834577b9..45e7edb3b40 100644 --- a/src/Model/GroundWaterFlow/gwf3rch8.f90 +++ b/src/Model/GroundWaterFlow/gwf3rch8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3riv8.f90 b/src/Model/GroundWaterFlow/gwf3riv8.f90 index 8fa84840063..269585d75c2 100644 --- a/src/Model/GroundWaterFlow/gwf3riv8.f90 +++ b/src/Model/GroundWaterFlow/gwf3riv8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3sfr8.f90 b/src/Model/GroundWaterFlow/gwf3sfr8.f90 index 84af275f4fe..3ea77ff53e2 100644 --- a/src/Model/GroundWaterFlow/gwf3sfr8.f90 +++ b/src/Model/GroundWaterFlow/gwf3sfr8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3uzf8.f90 b/src/Model/GroundWaterFlow/gwf3uzf8.f90 index 9b1d241a1bd..2d61d4283e6 100644 --- a/src/Model/GroundWaterFlow/gwf3uzf8.f90 +++ b/src/Model/GroundWaterFlow/gwf3uzf8.f90 @@ -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 diff --git a/src/Model/GroundWaterFlow/gwf3wel8.f90 b/src/Model/GroundWaterFlow/gwf3wel8.f90 index 1fbb929e55d..0ea454139c6 100644 --- a/src/Model/GroundWaterFlow/gwf3wel8.f90 +++ b/src/Model/GroundWaterFlow/gwf3wel8.f90 @@ -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 diff --git a/src/Model/ModelUtilities/BoundaryPackage.f90 b/src/Model/ModelUtilities/BoundaryPackage.f90 index f030b9f8f2e..5d306b7625d 100644 --- a/src/Model/ModelUtilities/BoundaryPackage.f90 +++ b/src/Model/ModelUtilities/BoundaryPackage.f90 @@ -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 @@ -992,9 +992,13 @@ 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 @@ -1002,7 +1006,6 @@ subroutine allocate_arrays(this, nodelist, auxvar) this%bound(i, j) = DZERO end do end do - do i = 1, this%maxbound this%hcof(i) = DZERO this%rhs(i) = DZERO diff --git a/version.txt b/version.txt index d132683c139..1f222b85173 100644 --- a/version.txt +++ b/version.txt @@ -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