Skip to content

Commit

Permalink
Lots of post-rebase clean up after the merge of MODFLOW-USGS#1332 in …
Browse files Browse the repository at this point in the history
…the main code base
  • Loading branch information
emorway-usgs committed Sep 14, 2023
1 parent bf4ccdd commit 3fc86f1
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/Model/Connection/GwtInterfaceModel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module GwtInterfaceModelModule
real(DP), dimension(:), pointer, contiguous :: porosity => null() !< to be filled with MST porosity

contains

procedure, pass(this) :: gwtifmod_cr
procedure :: model_df => gwtifmod_df
procedure :: model_ar => gwtifmod_ar
Expand Down Expand Up @@ -97,6 +98,7 @@ subroutine allocate_scalars(this, modelname)
class(GwtInterfaceModelType) :: this !< the GWT interface model
character(len=*), intent(in) :: modelname !< the model name

call this%GwtModelType%allocate_tsp_scalars(modelname)
call this%GwtModelType%allocate_scalars(modelname)

call mem_allocate(this%iAdvScheme, 'ADVSCHEME', this%memoryPath)
Expand Down
17 changes: 15 additions & 2 deletions src/Model/ModelUtilities/FlowModelInterface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module FlowModelInterfaceModule

use KindModule, only: DP, I4B, LGP
use ConstantsModule, only: DONE, DZERO, DHALF, LINELENGTH, LENBUDTXT, &
LENPACKAGENAME
LENPACKAGENAME, LENVARNAME
use SimModule, only: store_error, store_error_unit
use SimVariablesModule, only: errmsg
use NumericalPackageModule, only: NumericalPackageType
Expand All @@ -29,6 +29,7 @@ module FlowModelInterfaceModule
real(DP), dimension(:), pointer, contiguous :: gwfhead => null() !< pointer to the GWF head array
real(DP), dimension(:), pointer, contiguous :: gwfsat => null() !< pointer to the GWF saturation array
integer(I4B), dimension(:), pointer, contiguous :: ibdgwfsat0 => null() !< mark cells with saturation = 0 to exclude from dispersion
integer(I4B), pointer :: idryinactive => null() !< mark cells with an additional flag to exclude from deactivation (gwe will simulate conduction through dry cells)
real(DP), dimension(:), pointer, contiguous :: gwfstrgss => null() !< pointer to flow model QSTOSS
real(DP), dimension(:), pointer, contiguous :: gwfstrgsy => null() !< pointer to flow model QSTOSY
integer(I4B), pointer :: igwfstrgss => null() !< indicates if gwfstrgss is available
Expand All @@ -43,6 +44,8 @@ module FlowModelInterfaceModule
type(PackageBudgetType), dimension(:), allocatable :: gwfpackages !< used to get flows between a package and gwf
type(BudgetObjectType), pointer :: mvrbudobj => null() !< pointer to the mover budget budget object
character(len=16), dimension(:), allocatable :: flowpacknamearray !< array of boundary package names (e.g. LAK-1, SFR-3, etc.)
character(len=LENVARNAME) :: depvartype = ''

contains

procedure :: advance_bfr
Expand All @@ -69,12 +72,13 @@ module FlowModelInterfaceModule
contains

!> @brief Define the flow model interface
subroutine fmi_df(this, dis)
subroutine fmi_df(this, dis, idryinactive)
! -- modules
use SimModule, only: store_error
! -- dummy
class(FlowModelInterfaceType) :: this
class(DisBaseType), pointer, intent(in) :: dis
integer(I4B), intent(in) :: idryinactive
! -- formats
character(len=*), parameter :: fmtfmi = &
"(1x,/1x,'FMI -- FLOW MODEL INTERFACE, VERSION 2, 8/17/2023', &
Expand Down Expand Up @@ -115,6 +119,11 @@ subroutine fmi_df(this, dis)
call this%initialize_gwfterms_from_gwfbndlist()
end if
!
! -- Set flag that stops dry flows from being deactivated in a GWE
! transport model since conduction will still be simulated.
! 0: GWE (skip deactivation step); 1: GWT (default: use existing code)
this%idryinactive = idryinactive
!
! -- Return
return
end subroutine fmi_df
Expand All @@ -138,6 +147,7 @@ subroutine fmi_ar(this, ibound)
end subroutine fmi_ar

!> @brief Deallocate variables
!<
subroutine fmi_da(this)
! -- modules
use MemoryManagerModule, only: mem_deallocate
Expand All @@ -153,6 +163,7 @@ subroutine fmi_da(this)
deallocate (this%flowpacknamearray)
call mem_deallocate(this%igwfmvrterm)
call mem_deallocate(this%ibdgwfsat0)
call mem_deallocate(this%idryinactive)
!
if (this%flows_from_file) then
call mem_deallocate(this%gwfstrgss)
Expand Down Expand Up @@ -202,6 +213,7 @@ subroutine allocate_scalars(this)
call mem_allocate(this%iuhds, 'IUHDS', this%memoryPath)
call mem_allocate(this%iumvr, 'IUMVR', this%memoryPath)
call mem_allocate(this%nflowpack, 'NFLOWPACK', this%memoryPath)
call mem_allocate(this%idryinactive, "IDRYINACTIVE", this%memoryPath)
!
! !
! -- Initialize
Expand All @@ -213,6 +225,7 @@ subroutine allocate_scalars(this)
this%iuhds = 0
this%iumvr = 0
this%nflowpack = 0
this%idryinactive = 1
!
! -- Return
return
Expand Down
15 changes: 13 additions & 2 deletions src/Model/TransportModel/tsp1adv1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ module TspAdvModule
integer(I4B), pointer :: iadvwt => null() !< advection scheme (0 up, 1 central, 2 tvd)
integer(I4B), dimension(:), pointer, contiguous :: ibound => null() !< pointer to model ibound
type(TspFmiType), pointer :: fmi => null() !< pointer to fmi object
real(DP), pointer :: eqnsclfac => null() !< governing equation scale factor; =1.0 for solute; =rhow*cpw for energy
real(DP), dimension(:), pointer, contiguous :: cpw => null() ! pointer to GWE heat capacity of water
real(DP), dimension(:), pointer, contiguous :: rhow => null() ! fixed density of water
real(DP), pointer :: eqnsclfac => null() !< governing equation scale factor; =1. for solute; =rhow*cpw for energy

contains

Expand Down Expand Up @@ -112,12 +114,14 @@ end subroutine adv_df
!!
!! Method to allocate and read static data for the ADV package.
!<
subroutine adv_ar(this, dis, ibound)
subroutine adv_ar(this, dis, ibound, cpw, rhow)
! -- modules
! -- dummy
class(TspAdvType) :: this
class(DisBaseType), pointer, intent(in) :: dis
integer(I4B), dimension(:), pointer, contiguous, intent(in) :: ibound
real(DP), dimension(:), pointer, contiguous, optional, intent(in) :: cpw
real(DP), dimension(:), pointer, contiguous, optional, intent(in) :: rhow
! -- local
! -- formats
! ------------------------------------------------------------------------------
Expand All @@ -126,6 +130,10 @@ subroutine adv_ar(this, dis, ibound)
this%dis => dis
this%ibound => ibound
!
! -- if part of a GWE simulation, need heat capacity(cpw) and density (rhow)
if (present(cpw)) this%cpw => cpw
if (present(rhow)) this%rhow => rhow
!
! -- Return
return
end subroutine adv_ar
Expand Down Expand Up @@ -157,6 +165,7 @@ subroutine adv_fc(this, nodes, matrix_sln, idxglo, cnew, rhs)
if (this%dis%con%mask(ipos) == 0) cycle
m = this%dis%con%ja(ipos)
if (this%ibound(m) == 0) cycle
!! qnm = this%fmi%gwfflowja(ipos)
qnm = this%fmi%gwfflowja(ipos) * this%eqnsclfac
omega = this%adv_weight(this%iadvwt, ipos, n, m, qnm)
call matrix_sln%add_value_pos(idxglo(ipos), qnm * (DONE - omega))
Expand Down Expand Up @@ -361,6 +370,8 @@ subroutine adv_da(this)
!
! -- nullify pointers
this%ibound => null()
nullify (this%cpw)
nullify (this%rhow)
!
! -- Scalars
call mem_deallocate(this%iadvwt)
Expand Down
2 changes: 1 addition & 1 deletion src/Model/TransportModel/tsp1apt1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module TspAptModule
real(DP), pointer :: eqnsclfac => null() !< governing equation scale factor; =1. for solute; =rhow*cpw for energy
character(len=LENVARNAME) :: depvartype = '' !< stores string identifying dependent variable type, depending on model type
character(len=LENVARNAME) :: depvarunit = '' !< "mass" or "energy"
character(len=LENVARNAME) :: depvarunitabbrev = '' !< "M" or "J"
character(len=LENVARNAME) :: depvarunitabbrev = '' !< "M" or "E"
!
! -- pointer to flow package boundary
type(BndType), pointer :: flowpackagebnd => null()
Expand Down
21 changes: 9 additions & 12 deletions src/Model/TransportModel/tsp1mvt1.f90
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ subroutine mvt_fc(this, cnew1, cnew2)
! -- Set pointers to the fmi packages for the provider and the receiver
call this%set_fmi_pr_rc(i, fmi_pr, fmi_rc)
!
! -- Set a pointer to the transport model's dependent variable
! (concentration or temperature) associated with the provider
! -- Set a pointer to the GWT model concentration associated with the provider
cnew => cnew1
if (associated(fmi_pr, this%fmi2)) then
cnew => cnew2
Expand All @@ -262,8 +261,7 @@ subroutine mvt_fc(this, cnew1, cnew2)
! -- Get the package index for the receiver
call fmi_rc%get_package_index(this%mvrbudobj%budterm(i)%text2id2, irc)
!
! -- If provider is an advanced package, then set a pointer to its
! simulated dependent variable (concentration or temperature)
! -- If provider is an advanced package, then set a pointer to its simulated concentration
if (fmi_pr%iatp(ipr) /= 0) then
concpak => fmi_pr%datp(ipr)%concpack
end if
Expand All @@ -278,27 +276,26 @@ subroutine mvt_fc(this, cnew1, cnew2)
! -- Obtain mover flow rate from the mover flow budget object
q = this%mvrbudobj%budterm(i)%flow(n)
!
! -- Assign the concentration (or temperature) of the provider
! -- Assign concentration of the provider
cp = DZERO
if (fmi_pr%iatp(ipr) /= 0) then
!
! -- Provider package is being represented by an APT (SFT, LKT, MWT, UZT)
! so set the concentration (or temperature) to the simulated
! concentation (or temperature) of APT
! so set the concentration to the simulated concentation of APT
cp = concpak(id1)
else
!
! -- Provider is a regular stress package (WEL, DRN, RIV, etc.) or the
! provider is an advanced stress package but is not represented with
! SFT, LKT, MWT, or UZT, so use the cell concentration (GWT) or
! temperature (GWE)
! SFT, LKT, MWT, or UZT, so use the GWT cell concentration
igwtnode = fmi_pr%gwfpackages(ipr)%nodelist(id1)
cp = cnew(igwtnode)

end if
!
! -- add the mover rate times the provider concentration (or
! temperature) into the receiver make sure these are accumulated
! since multiple providers can move water into the same receiver
! -- add the mover rate times the provider concentration into the receiver
! make sure these are accumulated since multiple providers can move
! water into the same receiver
if (fmi_rc%iatp(irc) /= 0) then
fmi_rc%datp(irc)%qmfrommvr(id2) = fmi_rc%datp(irc)%qmfrommvr(id2) - &
q * cp * this%eqnsclfac
Expand Down
14 changes: 11 additions & 3 deletions src/Utilities/Budget.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module BudgetModule
use SimModule, only: store_error, count_errors
use ConstantsModule, only: LINELENGTH, LENBUDTXT, LENBUDROWLABEL, DZERO, &
DTWO, DHUNDRED
use TspLabelsModule, only: TspLabelsType

implicit none

Expand Down Expand Up @@ -56,9 +57,11 @@ module BudgetModule
! -- csv output
integer(I4B), pointer :: ibudcsv => null()
integer(I4B), pointer :: icsvheader => null()
!
! -- labels
type(TspLabelsType), pointer :: tsplab => null()

contains

procedure :: budget_df
procedure :: budget_ot
procedure :: budget_da
Expand All @@ -73,7 +76,6 @@ module BudgetModule
procedure, private :: allocate_arrays
procedure, private :: resize
procedure, private :: write_csv_header

end type BudgetType

contains
Expand All @@ -83,11 +85,12 @@ module BudgetModule
!! Create a new budget object.
!!
!<
subroutine budget_cr(this, name_model)
subroutine budget_cr(this, name_model, tsplab)
! -- modules
! -- dummy
type(BudgetType), pointer :: this !< BudgetType object
character(len=*), intent(in) :: name_model !< name of the model
type(TspLabelsType), pointer, intent(in), optional :: tsplab !< TspLabelsType object
! ------------------------------------------------------------------------------
!
! -- Create the object
Expand All @@ -96,6 +99,11 @@ subroutine budget_cr(this, name_model)
! -- Allocate scalars
call this%allocate_scalars(name_model)
!
! -- Store pointer to labels associated with the current model in order
! assign the correct transport-related labels - only necessary for
! transport model type (i.e., GWT or GWE)
if (present(tsplab)) this%tsplab => tsplab
!
! -- Return
return
end subroutine budget_cr
Expand Down

0 comments on commit 3fc86f1

Please sign in to comment.