MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
packagebudgetmodule Module Reference

This module contains the PackageBudgetModule Module. More...

Data Types

type  packagebudgettype
 Derived type for storing flows. More...
 

Functions/Subroutines

subroutine initialize (this, mempath)
 @ brief Initialize a PackageBudgetType object More...
 
subroutine set_name (this, name, budtxt)
 @ brief Set names for this PackageBudgetType object More...
 
subroutine set_auxname (this, naux, auxname)
 @ brief Set aux names for this PackageBudgetType object More...
 
subroutine set_pointers (this, flowvarname, mem_path_target, input_mempath)
 @ brief Point members of this class to data stored in GWF packages More...
 
subroutine copy_values (this, nbound, nodelist, flow, auxvar)
 @ brief Copy data read from a budget file into this object More...
 
real(dp) function get_flow (this, i)
 @ brief Get flow rate for specified entry More...
 
subroutine da (this)
 @ brief Deallocate More...
 

Detailed Description

The PackageBudgetType object defined here provides flows to the GWT model. The PackageBudgetType can be filled with flows from a budget object that was written from a previous GWF simulation, or its individual members can be pointed to flows that are being calculated by a GWF model that is running as part of this simulation.

Function/Subroutine Documentation

◆ copy_values()

subroutine packagebudgetmodule::copy_values ( class(packagebudgettype this,
integer(i4b), intent(in)  nbound,
integer(i4b), dimension(:), intent(in), contiguous  nodelist,
real(dp), dimension(:), intent(in), contiguous  flow,
real(dp), dimension(:, :), intent(in), contiguous  auxvar 
)

The routine is called when GWF flows are read from a budget file created from a previous GWF simulation. Arrays here must be dynamically resized because maxbound is not known unless the entire budget file was read first.

Parameters
thisPackageBudgetType object
[in]nboundnumber of entries
[in]nodelistarray of GWT node numbers
[in]flowarray of flow rates
[in]auxvararray of auxiliary variables

Definition at line 158 of file PackageBudget.f90.

159  class(PackageBudgetType) :: this !< PackageBudgetType object
160  integer(I4B), intent(in) :: nbound !< number of entries
161  integer(I4B), dimension(:), contiguous, intent(in) :: nodelist !< array of GWT node numbers
162  real(DP), dimension(:), contiguous, intent(in) :: flow !< array of flow rates
163  real(DP), dimension(:, :), contiguous, intent(in) :: auxvar !< array of auxiliary variables
164  integer(I4B) :: i
165  !
166  ! -- Assign variables
167  this%nbound = nbound
168  !
169  ! -- Lists are not large enough (maxbound is not known), so need to
170  ! reallocate based on size in binary budget file.
171  if (size(this%nodelist) < nbound) then
172  call mem_reallocate(this%nodelist, nbound, 'NODELIST', this%memoryPath)
173  call mem_reallocate(this%flow, nbound, 'FLOW', this%memoryPath)
174  call mem_reallocate(this%auxvar, this%naux, nbound, 'AUXVAR', &
175  this%memoryPath)
176  end if
177  !
178  ! -- Copy values into member variables
179  do i = 1, nbound
180  this%nodelist(i) = nodelist(i)
181  this%flow(i) = flow(i)
182  this%auxvar(:, i) = auxvar(:, i)
183  end do

◆ da()

subroutine packagebudgetmodule::da ( class(packagebudgettype this)
private

Free any memory associated with this object

Definition at line 204 of file PackageBudget.f90.

205  class(PackageBudgetType) :: this
206  call mem_deallocate(this%name, 'NAME', this%memoryPath)
207  call mem_deallocate(this%budtxt, 'BUDTXT', this%memoryPath)
208  call mem_deallocate(this%naux)
209  call mem_deallocate(this%auxname, 'AUXNAME', this%memoryPath)
210  call mem_deallocate(this%nbound)
211  call mem_deallocate(this%nodelist, 'NODELIST', this%memoryPath)
212  call mem_deallocate(this%flow, 'FLOW', this%memoryPath)
213  call mem_deallocate(this%auxvar, 'AUXVAR', this%memoryPath)
214  return

◆ get_flow()

real(dp) function packagebudgetmodule::get_flow ( class(packagebudgettype this,
integer(i4b), intent(in)  i 
)
private

Return the flow rate for the specified entry

Parameters
thisPackageBudgetType object
[in]ientry number

Definition at line 191 of file PackageBudget.f90.

192  class(PackageBudgetType) :: this !< PackageBudgetType object
193  integer(I4B), intent(in) :: i !< entry number
194  real(DP) :: flow
195  flow = this%flow(i)
196  return

◆ initialize()

subroutine packagebudgetmodule::initialize ( class(packagebudgettype this,
character(len=*), intent(in)  mempath 
)
private

Establish the memory path and allocate and initialize member variables.

Parameters
thisPackageBudgetType object
[in]mempathmemory path in memory manager

Definition at line 59 of file PackageBudget.f90.

60  class(PackageBudgetType) :: this !< PackageBudgetType object
61  character(len=*), intent(in) :: mempath !< memory path in memory manager
62  this%memoryPath = mempath
63  !
64  ! -- allocate member variables in memory manager
65  call mem_allocate(this%name, lenpackagename, 'NAME', mempath)
66  call mem_allocate(this%budtxt, lenpackagename, 'BUDTXT', mempath)
67  call mem_allocate(this%naux, 'NAUX', mempath)
68  call mem_allocate(this%auxname, lenauxname, 0, 'AUXNAME', this%memoryPath)
69  call mem_allocate(this%nbound, 'NBOUND', mempath)
70  call mem_allocate(this%nodelist, 0, 'NODELIST', mempath)
71  call mem_allocate(this%flow, 0, 'FLOW', mempath)
72  call mem_allocate(this%auxvar, 0, 0, 'AUXVAR', mempath)
73  !
74  ! -- initialize
75  this%name = ''
76  this%budtxt = ''
77  this%naux = 0
78  this%nbound = 0
79  return

◆ set_auxname()

subroutine packagebudgetmodule::set_auxname ( class(packagebudgettype this,
integer(i4b), intent(in)  naux,
character(len=lenauxname), dimension(:), intent(in), contiguous  auxname 
)
private

Set the number of auxiliary variables and the names of the auxiliary variables

Parameters
thisPackageBudgetType object
[in]nauxnumber of auxiliary variables
[in]auxnamearray of names for auxiliary variables

Definition at line 102 of file PackageBudget.f90.

103  class(PackageBudgetType) :: this !< PackageBudgetType object
104  integer(I4B), intent(in) :: naux !< number of auxiliary variables
105  character(len=LENAUXNAME), contiguous, &
106  dimension(:), intent(in) :: auxname !< array of names for auxiliary variables
107  this%naux = naux
108  call mem_reallocate(this%auxname, lenauxname, naux, 'AUXNAME', &
109  this%memoryPath)
110  this%auxname(:) = auxname(:)
111  return

◆ set_name()

subroutine packagebudgetmodule::set_name ( class(packagebudgettype this,
character(len=lenpackagename)  name,
character(len=lenpackagename)  budtxt 
)
private

Set the name of the package and the name of the of budget text

Parameters
thisPackageBudgetType object
namename of the package (WEL-1, DRN-4, etc.)
budtxtname of budget term (CHD, RCH, EVT, DRN-TO-MVR, etc.)

Definition at line 87 of file PackageBudget.f90.

88  class(PackageBudgetType) :: this !< PackageBudgetType object
89  character(len=LENPACKAGENAME) :: name !< name of the package (WEL-1, DRN-4, etc.)
90  character(len=LENPACKAGENAME) :: budtxt !< name of budget term (CHD, RCH, EVT, DRN-TO-MVR, etc.)
91  this%name = name
92  this%budtxt = budtxt
93  return

◆ set_pointers()

subroutine packagebudgetmodule::set_pointers ( class(packagebudgettype this,
character(len=*), intent(in)  flowvarname,
character(len=*), intent(in)  mem_path_target,
character(len=*), intent(in)  input_mempath 
)
private

The routine is called when a GWF model is being run concurrently with a GWT model. In this situation, the member variables NBOUND, NODELIST, FLOW, and AUXVAR are pointed into member variables of the individual GWF Package members stored in BndType.

Parameters
thisPackageBudgetType object
[in]flowvarnamename of variable storing flow (SIMVALS, SIMTOMVR)
[in]mem_path_targetpath where target variable is stored

Definition at line 122 of file PackageBudget.f90.

123  use constantsmodule, only: lenvarname
124  class(PackageBudgetType) :: this !< PackageBudgetType object
125  character(len=*), intent(in) :: flowvarname !< name of variable storing flow (SIMVALS, SIMTOMVR)
126  character(len=*), intent(in) :: mem_path_target !< path where target variable is stored
127  character(len=*), intent(in) :: input_mempath
128  character(len=LENVARNAME) :: auxvarname
129  !
130  ! -- set memory manager aux varname
131  if (input_mempath /= '') then
132  auxvarname = 'AUXVAR_IDM'
133  else
134  auxvarname = 'AUXVAR'
135  end if
136  !
137  ! -- Reassign pointers to variables in the flow model
138  call mem_reassignptr(this%nbound, 'NBOUND', this%memoryPath, &
139  'NBOUND', mem_path_target)
140  call mem_reassignptr(this%nodelist, 'NODELIST', this%memoryPath, &
141  'NODELIST', mem_path_target)
142  call mem_reassignptr(this%flow, 'FLOW', this%memoryPath, &
143  flowvarname, mem_path_target)
144  call mem_reassignptr(this%auxvar, 'AUXVAR', this%memoryPath, &
145  auxvarname, mem_path_target)
146  !
147  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition: Constants.f90:17