Skip to content

Commit

Permalink
refactor(gwf): cleaning up call statements and arguments(#202)
Browse files Browse the repository at this point in the history
* refactor(gnc): removed mention of iasln as it was not used and named wrong

* refactor(gwf): cleaning up model%ia/ja confusion in gwf

* refactor(gwf): cleaning up call statements and arguments

* refactor(xt3d): minor comment cleanup

This is in preparation to be able to mask a primary connection between two model cells so that an interface model can be used to connect two models
  • Loading branch information
langevin-usgs authored Sep 30, 2019
1 parent ea90d47 commit 19ead5d
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 148 deletions.
8 changes: 3 additions & 5 deletions src/Exchange/GhostNode.f90
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ subroutine gnc_mc(this, iasln, jasln)
return
end subroutine gnc_mc

subroutine gnc_fmsav(this, kiter, iasln, amatsln)
subroutine gnc_fmsav(this, kiter, amatsln)
! ******************************************************************************
! gnc_fmsav -- Store the n-m Picard conductance in cond prior to the Newton
! terms being added.
Expand All @@ -320,7 +320,6 @@ subroutine gnc_fmsav(this, kiter, iasln, amatsln)
! -- dummy
class(GhostNodeType) :: this
integer(I4B), intent(in) :: kiter
integer(I4B), dimension(:), intent(in) :: iasln
real(DP), dimension(:), intent(inout) :: amatsln
! -- local
integer(I4B) :: ignc, ipos
Expand All @@ -343,7 +342,7 @@ subroutine gnc_fmsav(this, kiter, iasln, amatsln)
return
end subroutine gnc_fmsav

subroutine gnc_fc(this, kiter, iasln, amatsln)
subroutine gnc_fc(this, kiter, amatsln)
! ******************************************************************************
! gnc_fc -- Fill matrix terms
! Subroutine: (1) Add the GNC terms to the solution amat or model rhs depending
Expand All @@ -357,7 +356,6 @@ subroutine gnc_fc(this, kiter, iasln, amatsln)
! -- dummy
class(GhostNodeType) :: this
integer(I4B), intent(in) :: kiter
integer(I4B), dimension(:), intent(in) :: iasln
real(DP), dimension(:), intent(inout) :: amatsln
! -- local
integer(I4B) :: ignc, j, noden, nodem, ipos, jidx, iposjn, iposjm
Expand All @@ -366,7 +364,7 @@ subroutine gnc_fc(this, kiter, iasln, amatsln)
!
! -- If this is a single model gnc (not an exchange across models), then
! pull conductances out of amatsln and store them in this%cond
if(this%smgnc) call this%gnc_fmsav(kiter, iasln, amatsln)
if(this%smgnc) call this%gnc_fmsav(kiter, amatsln)
!
! -- Add gnc terms to rhs or to amat depending on whether gnc is implicit
! or explicit
Expand Down
2 changes: 1 addition & 1 deletion src/Exchange/GwfGwfExchange.f90
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ subroutine gwf_gwf_fc(this, kiter, iasln, amatsln, inwtflag)
!
! -- Fill the gnc terms in the solution matrix
if(this%ingnc > 0) then
call this%gnc%gnc_fc(kiter, iasln, amatsln)
call this%gnc%gnc_fc(kiter, amatsln)
endif
!
! -- Call mvr fc routine
Expand Down
51 changes: 22 additions & 29 deletions src/Model/GroundWaterFlow/gwf3.f90
Original file line number Diff line number Diff line change
Expand Up @@ -315,18 +315,19 @@ subroutine gwf_df(this)
!
! -- Define packages and utility objects
call this%dis%dis_df()
call this%npf%npf_df(this%xt3d, this%ingnc)
call this%npf%npf_df(this%dis, this%xt3d, this%ingnc)
call this%oc%oc_df()
call this%budget%budget_df(niunit, 'VOLUME', 'L**3')
if(this%ingnc > 0) call this%gnc%gnc_df(this)
!
! -- Assign or point model members to dis members
! this%neq will be incremented if packages add additional unknowns
this%neq = this%dis%nodes
this%nja = this%dis%nja
this%ia => this%dis%con%ia
this%ja => this%dis%con%ja
!
! -- Allocate model arrays, now that neq and nja are assigned
! -- Allocate model arrays, now that neq and nja are known
call this%allocate_arrays()
!
! -- Define packages and assign iout for time series managers
Expand Down Expand Up @@ -359,12 +360,11 @@ subroutine gwf_ac(this, sparse)
integer(I4B) :: ip
! ------------------------------------------------------------------------------
!
! -- Add the internal connections of this model to sparse
! -- Add the primary grid connections of this model to sparse
call this%dis%dis_ac(this%moffset, sparse)
!
! -- Add any additional connections that NPF may need
if(this%innpf > 0) call this%npf%npf_ac(this%moffset, sparse, &
this%dis%nodes, this%ia, this%ja)
if(this%innpf > 0) call this%npf%npf_ac(this%moffset, sparse)
!
! -- Add any package connections
do ip = 1, this%bndlist%Count()
Expand Down Expand Up @@ -401,8 +401,7 @@ subroutine gwf_mc(this, iasln, jasln)
call this%dis%dis_mc(this%moffset, this%idxglo, iasln, jasln)
!
! -- Map any additional connections that NPF may need
if(this%innpf > 0) call this%npf%npf_mc(this%moffset, this%dis%nodes, &
this%ia, this%ja, iasln, jasln)
if(this%innpf > 0) call this%npf%npf_mc(this%moffset, iasln, jasln)
!
! -- Map any package connections
do ip=1,this%bndlist%Count()
Expand Down Expand Up @@ -436,8 +435,7 @@ subroutine gwf_ar(this)
!
! -- Allocate and read modules attached to model
if(this%inic > 0) call this%ic%ic_ar(this%x)
if(this%innpf > 0) call this%npf%npf_ar(this%dis, this%ic, &
this%ibound, this%x)
if(this%innpf > 0) call this%npf%npf_ar(this%ic, this%ibound, this%x)
if(this%inhfb > 0) call this%hfb%hfb_ar(this%ibound, this%xt3d, this%dis)
if(this%insto > 0) call this%sto%sto_ar(this%dis, this%ibound)
if(this%inmvr > 0) call this%mvr%mvr_ar()
Expand Down Expand Up @@ -594,17 +592,14 @@ subroutine gwf_fc(this, kiter, amatsln, njasln, inwtflag)
endif
!
! -- Fill standard conductance terms
if(this%innpf > 0) call this%npf%npf_fc(kiter, this%dis%nodes, &
this%nja, njasln, amatsln, &
this%idxglo, this%rhs, this%x)
if(this%inhfb > 0) call this%hfb%hfb_fc(kiter, this%dis%nodes, &
this%nja, njasln, amatsln, &
this%idxglo, this%rhs, this%x)
if(this%ingnc > 0) call this%gnc%gnc_fc(kiter, this%ia, amatsln)
if(this%innpf > 0) call this%npf%npf_fc(kiter, njasln, amatsln, &
this%idxglo, this%rhs, this%x)
if(this%inhfb > 0) call this%hfb%hfb_fc(kiter, njasln, amatsln, &
this%idxglo, this%rhs, this%x)
if(this%ingnc > 0) call this%gnc%gnc_fc(kiter, amatsln)
if(this%insto > 0) then
call this%sto%sto_fc(kiter, this%dis%nodes, this%xold, &
this%x, this%nja, njasln, &
amatsln, this%idxglo, this%rhs)
call this%sto%sto_fc(kiter, this%xold, this%x, njasln, amatsln, &
this%idxglo, this%rhs)
end if
if(this%inmvr > 0) call this%mvr%mvr_fc()
do ip = 1, this%bndlist%Count()
Expand All @@ -615,8 +610,8 @@ subroutine gwf_fc(this, kiter, amatsln, njasln, inwtflag)
!--Fill newton terms
if(this%innpf > 0) then
if(inwt /= 0) then
call this%npf%npf_fn(kiter, this%dis%nodes, this%nja, njasln, &
amatsln, this%idxglo, this%rhs, this%x)
call this%npf%npf_fn(kiter, njasln, amatsln, this%idxglo, this%rhs, &
this%x)
endif
endif
!
Expand All @@ -633,8 +628,8 @@ subroutine gwf_fc(this, kiter, amatsln, njasln, inwtflag)
! -- Fill newton terms for storage
if(this%insto > 0) then
if (inwtsto /= 0) then
call this%sto%sto_fn(kiter, this%dis%nodes, this%xold, this%x, &
this%nja, njasln, amatsln, this%idxglo, this%rhs)
call this%sto%sto_fn(kiter, this%xold, this%x, njasln, amatsln, &
this%idxglo, this%rhs)
end if
end if
!
Expand Down Expand Up @@ -901,10 +896,8 @@ subroutine gwf_cq(this, icnvg, isuppress_output)
do i = 1, this%nja
this%flowja(i) = DZERO
enddo
if(this%innpf > 0) call this%npf%npf_flowja(this%neq, this%nja, this%x, &
this%flowja)
if(this%inhfb > 0) call this%hfb%hfb_flowja(this%neq, this%nja, this%x, &
this%flowja)
if(this%innpf > 0) call this%npf%npf_flowja(this%x, this%flowja)
if(this%inhfb > 0) call this%hfb%hfb_flowja(this%x, this%flowja)
if(this%ingnc > 0) call this%gnc%flowja(this%flowja)
!
! -- Return
Expand Down Expand Up @@ -963,7 +956,7 @@ subroutine gwf_bd(this, icnvg, isuppress_output)
!
! -- Node Property Flow
if(this%innpf > 0) then
call this%npf%npf_bdadj(this%nja, this%flowja, icbcfl, icbcun)
call this%npf%npf_bdadj(this%flowja, icbcfl, icbcun)
endif
!
! -- Clear obs
Expand Down Expand Up @@ -1028,7 +1021,7 @@ subroutine gwf_ot(this)
if(ibudfl /= 0) then
!
! -- NPF output
if(this%innpf > 0) call this%npf%npf_ot(this%neq, this%nja, this%flowja)
if(this%innpf > 0) call this%npf%npf_ot(this%flowja)
!
! -- GNC output
if(this%ingnc > 0) &
Expand Down
23 changes: 11 additions & 12 deletions src/Model/GroundWaterFlow/gwf3hfb8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ subroutine hfb_rp(this)
return
end subroutine hfb_rp

subroutine hfb_fc(this, kiter, nodes, nja, njasln, amat, idxglo, rhs, hnew)
subroutine hfb_fc(this, kiter, njasln, amat, idxglo, rhs, hnew)
! ******************************************************************************
! hfb_fc -- Fill amatsln for the following conditions:
! 1. Not Newton, and
Expand All @@ -212,14 +212,13 @@ subroutine hfb_fc(this, kiter, nodes, nja, njasln, amat, idxglo, rhs, hnew)
! -- dummy
class(GwfHfbType) :: this
integer(I4B) :: kiter
integer(I4B),intent(in) :: nodes
integer(I4B),intent(in) :: nja
integer(I4B),intent(in) :: njasln
real(DP),dimension(njasln),intent(inout) :: amat
integer(I4B),intent(in),dimension(nja) :: idxglo
real(DP),intent(inout),dimension(nodes) :: rhs
real(DP),intent(inout),dimension(nodes) :: hnew
integer(I4B),intent(in),dimension(:) :: idxglo
real(DP),intent(inout),dimension(:) :: rhs
real(DP),intent(inout),dimension(:) :: hnew
! -- local
integer(I4B) :: nodes, nja
integer(I4B) :: ihfb, n, m
integer(I4B) :: ipos
integer(I4B) :: idiag, isymcon
Expand All @@ -229,6 +228,8 @@ subroutine hfb_fc(this, kiter, nodes, nja, njasln, amat, idxglo, rhs, hnew)
real(DP) :: topn, topm, botn, botm
! ------------------------------------------------------------------------------
!
nodes = this%dis%nodes
nja = this%dis%con%nja
if (associated(this%xt3d%ixt3d)) then
ixt3d = this%xt3d%ixt3d
else
Expand Down Expand Up @@ -335,7 +336,7 @@ subroutine hfb_fc(this, kiter, nodes, nja, njasln, amat, idxglo, rhs, hnew)
return
end subroutine hfb_fc

subroutine hfb_flowja(this, nodes, nja, hnew, flowja)
subroutine hfb_flowja(this, hnew, flowja)
! ******************************************************************************
! hfb_flowja -- flowja will automatically include the effects of the hfb
! for confined and newton cases when xt3d is not used. This method
Expand All @@ -348,10 +349,8 @@ subroutine hfb_flowja(this, nodes, nja, hnew, flowja)
use ConstantsModule, only: DHALF, DZERO
! -- dummy
class(GwfHfbType) :: this
integer(I4B),intent(in) :: nodes
integer(I4B),intent(in) :: nja
real(DP),intent(inout),dimension(nodes) :: hnew
real(DP),intent(inout),dimension(nja) :: flowja
real(DP),intent(inout),dimension(:) :: hnew
real(DP),intent(inout),dimension(:) :: flowja
! -- local
integer(I4B) :: ihfb, n, m
integer(I4B) :: ipos
Expand Down Expand Up @@ -405,7 +404,7 @@ subroutine hfb_flowja(this, nodes, nja, hnew, flowja)
condhfb = this%hydchr(ihfb)
endif
! -- Make hfb corrections for xt3d
call this%xt3d%xt3d_flowjahfb(nodes, n, m, nja, hnew, flowja, condhfb)
call this%xt3d%xt3d_flowjahfb(n, m, hnew, flowja, condhfb)
end do
!
else
Expand Down
Loading

0 comments on commit 19ead5d

Please sign in to comment.