MODFLOW 6  version 6.8.0.dev0
USGS Modular Hydrologic Model
swfzdgmodule Module Reference

This module contains the ZDG package methods. More...

Data Types

type  swfzdgtype
 

Functions/Subroutines

subroutine, public zdg_create (packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, dis, cxs, unitconv)
 @ brief Create a new package object More...
 
subroutine zdg_allocate_scalars (this)
 @ brief Allocate scalars More...
 
subroutine zdg_allocate_arrays (this, nodelist, auxvar)
 @ brief Allocate arrays More...
 
subroutine zdg_da (this)
 @ brief Deallocate package memory More...
 
subroutine zdg_options (this)
 @ brief Source additional options for package More...
 
subroutine log_zdg_options (this)
 @ brief Log SWF specific package options More...
 
subroutine zdg_cf (this)
 @ brief Formulate the package hcof and rhs terms. More...
 
real(dp) function qcalc (this, i, depth, unitconv)
 
subroutine zdg_fc (this, rhs, ia, idxglo, matrix_sln)
 @ brief Copy hcof and rhs terms into solution. More...
 
subroutine define_listlabel (this)
 @ brief Define the list label for the package More...
 
logical function zdg_obs_supported (this)
 Determine if observations are supported. More...
 
subroutine zdg_df_obs (this)
 Define the observation types available in the package. More...
 
subroutine zdg_bd_obs (this)
 Save observations for the package. More...
 
subroutine zdg_rp_ts (this)
 Assign time series links for the package. More...
 
real(dp) function zdg_bound_value (this, col, row)
 @ brief Return a bound value More...
 

Variables

character(len=lenftype) ftype = 'ZDG'
 package ftype More...
 
character(len=16) text = ' ZDG'
 package flow text string More...
 

Detailed Description

This module can be used to represent outflow from streams using a zero-depth-gradient boundary.

Function/Subroutine Documentation

◆ define_listlabel()

subroutine swfzdgmodule::define_listlabel ( class(swfzdgtype), intent(inout)  this)
private

Method defined the list label for the ZDG package. The list label is the heading that is written to iout when PRINT_INPUT option is used.

Parameters
[in,out]thisSwfZdgType object

Definition at line 379 of file swf-zdg.f90.

380  ! -- dummy variables
381  class(SwfZdgType), intent(inout) :: this !< SwfZdgType object
382  !
383  ! -- create the header list label
384  this%listlabel = trim(this%filtyp)//' NO.'
385  if (this%dis%ndim == 3) then
386  write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
387  write (this%listlabel, '(a, a7)') trim(this%listlabel), 'ROW'
388  write (this%listlabel, '(a, a7)') trim(this%listlabel), 'COL'
389  elseif (this%dis%ndim == 2) then
390  write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
391  write (this%listlabel, '(a, a7)') trim(this%listlabel), 'CELL2D'
392  else
393  write (this%listlabel, '(a, a7)') trim(this%listlabel), 'NODE'
394  end if
395  write (this%listlabel, '(a, a16)') trim(this%listlabel), 'FLOW RATE'
396  if (this%inamedbound == 1) then
397  write (this%listlabel, '(a, a16)') trim(this%listlabel), 'BOUNDARY NAME'
398  end if

◆ log_zdg_options()

subroutine swfzdgmodule::log_zdg_options ( class(swfzdgtype), intent(inout)  this)

Definition at line 229 of file swf-zdg.f90.

230  ! -- dummy variables
231  class(SwfZdgType), intent(inout) :: this
232  ! -- local variables
233  ! -- format
234  !
235  ! -- log found options
236  write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text)) &
237  //' OPTIONS'
238  !
239  ! -- close logging block
240  write (this%iout, '(1x,a)') &
241  'END OF '//trim(adjustl(this%text))//' OPTIONS'

◆ qcalc()

real(dp) function swfzdgmodule::qcalc ( class(swfzdgtype this,
integer(i4b), intent(in)  i,
real(dp), intent(in)  depth,
real(dp), intent(in)  unitconv 
)
Parameters
[in]iboundary number
[in]depthsimulated depth (stage - elevation) in reach n for this iteration
[in]unitconvconversion factor for roughness to length and time units of meters and seconds

Definition at line 311 of file swf-zdg.f90.

312  ! dummy
313  class(SwfZdgType) :: this
314  integer(I4B), intent(in) :: i !< boundary number
315  real(DP), intent(in) :: depth !< simulated depth (stage - elevation) in reach n for this iteration
316  real(DP), intent(in) :: unitconv !< conversion factor for roughness to length and time units of meters and seconds
317  ! return
318  real(DP) :: q
319  ! local
320  integer(I4B) :: idcxs
321  real(DP) :: width
322  real(DP) :: rough
323  real(DP) :: slope
324  real(DP) :: conveyance
325 
326  idcxs = this%idcxs(i)
327  width = this%width(i)
328  rough = this%rough(i)
329  slope = this%slope(i)
330  conveyance = this%cxs%get_conveyance(idcxs, width, depth, rough)
331  q = conveyance * slope**dhalf * unitconv
332 

◆ zdg_allocate_arrays()

subroutine swfzdgmodule::zdg_allocate_arrays ( class(swfzdgtype this,
integer(i4b), dimension(:), optional, pointer, contiguous  nodelist,
real(dp), dimension(:, :), optional, pointer, contiguous  auxvar 
)

Allocate and initialize arrays for the SWF package

Definition at line 151 of file swf-zdg.f90.

152  ! -- modules
154  ! -- dummy
155  class(SwfZdgType) :: this
156  integer(I4B), dimension(:), pointer, contiguous, optional :: nodelist
157  real(DP), dimension(:, :), pointer, contiguous, optional :: auxvar
158  ! -- local
159  !
160  ! -- call BndExtType allocate scalars
161  call this%BndExtType%allocate_arrays(nodelist, auxvar)
162  !
163  ! -- set array input context pointer
164  call mem_setptr(this%idcxs, 'IDCXS', this%input_mempath)
165  call mem_setptr(this%width, 'WIDTH', this%input_mempath)
166  call mem_setptr(this%slope, 'SLOPE', this%input_mempath)
167  call mem_setptr(this%rough, 'ROUGH', this%input_mempath)
168  !
169  ! -- checkin array input context pointer
170  call mem_checkin(this%idcxs, 'IDCXS', this%memoryPath, &
171  'IDCXS', this%input_mempath)
172  call mem_checkin(this%width, 'WIDTH', this%memoryPath, &
173  'WIDTH', this%input_mempath)
174  call mem_checkin(this%slope, 'SLOPE', this%memoryPath, &
175  'SLOPE', this%input_mempath)
176  call mem_checkin(this%rough, 'ROUGH', this%memoryPath, &
177  'ROUGH', this%input_mempath)

◆ zdg_allocate_scalars()

subroutine swfzdgmodule::zdg_allocate_scalars ( class(swfzdgtype this)
private

Allocate and initialize scalars for the ZDG package. The base model allocate scalars method is also called.

Parameters
thisSwfZdgType object

Definition at line 130 of file swf-zdg.f90.

131  ! -- modules
133  ! -- dummy variables
134  class(SwfZdgType) :: this !< SwfZdgType object
135  !
136  ! -- call base type allocate scalars
137  call this%BndExtType%allocate_scalars()
138  !
139  ! -- allocate the object and assign values to object variables
140  call mem_allocate(this%unitconv, 'UNITCONV', this%memoryPath)
141  !
142  ! -- Set values
143  this%unitconv = dzero

◆ zdg_bd_obs()

subroutine swfzdgmodule::zdg_bd_obs ( class(swfzdgtype this)
private

Method to save simulated values for the ZDG package.

Parameters
thisSwfZdgType object

Definition at line 445 of file swf-zdg.f90.

446  ! -- dummy variables
447  class(SwfZdgType) :: this !< SwfZdgType object
448  ! -- local variables
449  integer(I4B) :: i
450  integer(I4B) :: n
451  integer(I4B) :: jj
452  real(DP) :: v
453  type(ObserveType), pointer :: obsrv => null()
454  !
455  ! -- clear the observations
456  call this%obs%obs_bd_clear()
457  !
458  ! -- Save simulated values for all of package's observations.
459  do i = 1, this%obs%npakobs
460  obsrv => this%obs%pakobs(i)%obsrv
461  if (obsrv%BndFound) then
462  do n = 1, obsrv%indxbnds_count
463  v = dnodata
464  jj = obsrv%indxbnds(n)
465  select case (obsrv%ObsTypeId)
466  case ('TO-MVR')
467  if (this%imover == 1) then
468  v = this%pakmvrobj%get_qtomvr(jj)
469  if (v > dzero) then
470  v = -v
471  end if
472  end if
473  case ('ZDG')
474  v = this%simvals(jj)
475  case default
476  errmsg = 'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
477  call store_error(errmsg)
478  end select
479  call this%obs%SaveOneSimval(obsrv, v)
480  end do
481  else
482  call this%obs%SaveOneSimval(obsrv, dnodata)
483  end if
484  end do
Here is the call graph for this function:

◆ zdg_bound_value()

real(dp) function swfzdgmodule::zdg_bound_value ( class(swfzdgtype), intent(inout)  this,
integer(i4b), intent(in)  col,
integer(i4b), intent(in)  row 
)
private

Return a bound value associated with an ncolbnd index and row.

Definition at line 520 of file swf-zdg.f90.

521  ! -- modules
522  use constantsmodule, only: dzero
523  ! -- dummy variables
524  class(SwfZdgType), intent(inout) :: this
525  integer(I4B), intent(in) :: col
526  integer(I4B), intent(in) :: row
527  ! -- result
528  real(DP) :: bndval
529  !
530  select case (col)
531  case (1)
532  bndval = this%idcxs(row)
533  case (2)
534  bndval = this%width(row)
535  case (3)
536  bndval = this%slope(row)
537  case (4)
538  bndval = this%rough(row)
539  case default
540  errmsg = 'Programming error. ZDG bound value requested column '&
541  &'outside range of ncolbnd (1).'
542  call store_error(errmsg)
543  call store_error_filename(this%input_fname)
544  end select
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
Here is the call graph for this function:

◆ zdg_cf()

subroutine swfzdgmodule::zdg_cf ( class(swfzdgtype this)
private

Formulate the hcof and rhs terms for the ZDG package that will be added to the coefficient matrix and right-hand side vector.

Parameters
thisSwfZdgType object

Definition at line 250 of file swf-zdg.f90.

251  ! modules
253  use smoothingmodule, only: squadratic
254  ! dummy variables
255  class(SwfZdgType) :: this !< SwfZdgType object
256  ! local variables
257  integer(I4B) :: i, node
258  real(DP) :: q
259  real(DP) :: qeps
260  real(DP) :: absdhdxsq
261  real(DP) :: depth
262  real(DP) :: derv
263  real(DP) :: eps
264  real(DP) :: range = 1.d-6
265  real(DP) :: dydx
266  real(DP) :: smooth_factor
267  !
268  ! -- Return if no inflows
269  if (this%nbound == 0) return
270  !
271  ! -- Calculate hcof and rhs for each zdg entry
272  do i = 1, this%nbound
273 
274  node = this%nodelist(i)
275  if (this%ibound(node) <= 0) then
276  this%hcof(i) = dzero
277  this%rhs(i) = dzero
278  cycle
279  end if
280 
281  ! -- calculate terms and add to hcof and rhs
282  absdhdxsq = this%slope(i)**dhalf
283  depth = this%xnew(node) - this%dis%bot(node)
284 
285  ! smooth the depth
286  call squadratic(depth, range, dydx, smooth_factor)
287  depth = depth * smooth_factor
288 
289  ! -- calculate unperturbed q
290  q = -this%qcalc(i, depth, this%unitconv)
291 
292  ! -- calculate perturbed q
293  eps = get_perturbation(depth)
294  qeps = -this%qcalc(i, depth + eps, this%unitconv)
295 
296  ! -- calculate derivative
297  derv = (qeps - q) / eps
298 
299  ! -- add terms to hcof and rhs
300  this%hcof(i) = derv
301  this%rhs(i) = -q + derv * this%xnew(node)
302 
303  end do
real(dp) function, public get_perturbation(x)
Calculate a numerical perturbation given the value of x.
Definition: MathUtil.f90:372
subroutine squadratic(x, range, dydx, y)
@ brief sQuadratic
Here is the call graph for this function:

◆ zdg_create()

subroutine, public swfzdgmodule::zdg_create ( class(bndtype), pointer  packobj,
integer(i4b), intent(in)  id,
integer(i4b), intent(in)  ibcnum,
integer(i4b), intent(in)  inunit,
integer(i4b), intent(in)  iout,
character(len=*), intent(in)  namemodel,
character(len=*), intent(in)  pakname,
character(len=*), intent(in)  mempath,
class(disbasetype), intent(inout), pointer  dis,
type(swfcxstype), intent(in), pointer  cxs,
real(dp), intent(in)  unitconv 
)

Create a new ZDG Package object

Parameters
packobjpointer to default package type
[in]idpackage id
[in]ibcnumboundary condition number
[in]inunitunit number of ZDG package input file
[in]ioutunit number of model listing file
[in]namemodelmodel name
[in]paknamepackage name
[in]mempathinput mempath
[in,out]disthe pointer to the discretization
[in]cxsthe pointer to the cxs package
[in]unitconvunit conversion for roughness

Definition at line 72 of file swf-zdg.f90.

74  ! -- dummy variables
75  class(BndType), pointer :: packobj !< pointer to default package type
76  integer(I4B), intent(in) :: id !< package id
77  integer(I4B), intent(in) :: ibcnum !< boundary condition number
78  integer(I4B), intent(in) :: inunit !< unit number of ZDG package input file
79  integer(I4B), intent(in) :: iout !< unit number of model listing file
80  character(len=*), intent(in) :: namemodel !< model name
81  character(len=*), intent(in) :: pakname !< package name
82  character(len=*), intent(in) :: mempath !< input mempath
83  class(DisBaseType), pointer, intent(inout) :: dis !< the pointer to the discretization
84  type(SwfCxsType), pointer, intent(in) :: cxs !< the pointer to the cxs package
85  real(DP), intent(in) :: unitconv !< unit conversion for roughness
86  ! -- local variables
87  type(SwfZdgType), pointer :: zdgobj
88  !
89  ! -- allocate the object and assign values to object variables
90  allocate (zdgobj)
91  packobj => zdgobj
92  !
93  ! -- create name and memory path
94  call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
95  packobj%text = text
96  !
97  ! -- allocate scalars
98  call zdgobj%allocate_scalars()
99  !
100  ! -- initialize package
101  call packobj%pack_initialize()
102 
103  packobj%inunit = inunit
104  packobj%iout = iout
105  packobj%id = id
106  packobj%ibcnum = ibcnum
107  packobj%ncolbnd = 1
108  packobj%iscloc = 1
109  packobj%ictMemPath = create_mem_path(namemodel, 'DFW')
110  !
111  ! -- store pointer to disv1d
112  select type (dis)
113  type is (disv1dtype)
114  zdgobj%disv1d => dis
115  end select
116  !
117  ! -- store pointer to cxs
118  zdgobj%cxs => cxs
119  !
120  ! -- store unit conversion
121  zdgobj%unitconv = unitconv
Here is the call graph for this function:
Here is the caller graph for this function:

◆ zdg_da()

subroutine swfzdgmodule::zdg_da ( class(swfzdgtype this)

Deallocate SWF package scalars and arrays.

Parameters
thisSwfZdgType object

Definition at line 185 of file swf-zdg.f90.

186  ! -- modules
188  ! -- dummy variables
189  class(SwfZdgType) :: this !< SwfZdgType object
190  !
191  ! -- Deallocate parent package
192  call this%BndExtType%bnd_da()
193  !
194  ! -- arrays
195  call mem_deallocate(this%idcxs, 'IDCXS', this%memoryPath)
196  call mem_deallocate(this%width, 'WIDTH', this%memoryPath)
197  call mem_deallocate(this%slope, 'SLOPE', this%memoryPath)
198  call mem_deallocate(this%rough, 'ROUGH', this%memoryPath)
199  !
200  ! -- scalars
201  call mem_deallocate(this%unitconv)

◆ zdg_df_obs()

subroutine swfzdgmodule::zdg_df_obs ( class(swfzdgtype this)
private

Method to define the observation types available in the ZDG package.

Parameters
thisSwfZdgType object

Definition at line 424 of file swf-zdg.f90.

425  ! -- dummy variables
426  class(SwfZdgType) :: this !< SwfZdgType object
427  ! -- local variables
428  integer(I4B) :: indx
429  !
430  ! -- initialize observations
431  call this%obs%StoreObsType('zdg', .true., indx)
432  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
433  !
434  ! -- Store obs type and assign procedure pointer
435  ! for to-mvr observation type.
436  call this%obs%StoreObsType('to-mvr', .true., indx)
437  this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
Here is the call graph for this function:

◆ zdg_fc()

subroutine swfzdgmodule::zdg_fc ( class(swfzdgtype this,
real(dp), dimension(:), intent(inout)  rhs,
integer(i4b), dimension(:), intent(in)  ia,
integer(i4b), dimension(:), intent(in)  idxglo,
class(matrixbasetype), pointer  matrix_sln 
)
private

Add the hcof and rhs terms for the ZDG package to the coefficient matrix and right-hand side vector.

Parameters
thisSwfZdgType object
[in,out]rhsright-hand side vector for model
[in]iasolution CRS row pointers
[in]idxglomapping vector for model (local) to solution (global)
matrix_slnsolution coefficient matrix

Definition at line 341 of file swf-zdg.f90.

342  ! -- dummy variables
343  class(SwfZdgType) :: this !< SwfZdgType object
344  real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector for model
345  integer(I4B), dimension(:), intent(in) :: ia !< solution CRS row pointers
346  integer(I4B), dimension(:), intent(in) :: idxglo !< mapping vector for model (local) to solution (global)
347  class(MatrixBaseType), pointer :: matrix_sln !< solution coefficient matrix
348  ! -- local variables
349  integer(I4B) :: i
350  integer(I4B) :: n
351  integer(I4B) :: ipos
352  !
353  ! -- pakmvrobj fc
354  if (this%imover == 1) then
355  call this%pakmvrobj%fc()
356  end if
357  !
358  ! -- Copy package rhs and hcof into solution rhs and amat
359  do i = 1, this%nbound
360  n = this%nodelist(i)
361  rhs(n) = rhs(n) + this%rhs(i)
362  ipos = ia(n)
363  call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(i))
364  !
365  ! -- If mover is active and this zdg item is discharging,
366  ! store available water (as positive value).
367  if (this%imover == 1 .and. this%rhs(i) > dzero) then
368  call this%pakmvrobj%accumulate_qformvr(i, this%rhs(i))
369  end if
370  end do

◆ zdg_obs_supported()

logical function swfzdgmodule::zdg_obs_supported ( class(swfzdgtype this)
private

Function to determine if observations are supported by the ZDG package. Observations are supported by the ZDG package.

Returns
zdg_obs_supported boolean indicating if observations are supported
Parameters
thisSwfZdgType object

Definition at line 411 of file swf-zdg.f90.

412  ! -- dummy variables
413  class(SwfZdgType) :: this !< SwfZdgType object
414  !
415  ! -- set boolean
416  zdg_obs_supported = .true.

◆ zdg_options()

subroutine swfzdgmodule::zdg_options ( class(swfzdgtype), intent(inout)  this)

Source additional options for SWF package.

Parameters
[in,out]thisSwfZdgType object

Definition at line 209 of file swf-zdg.f90.

210  ! -- modules
211  use inputoutputmodule, only: urword
213  ! -- dummy variables
214  class(SwfZdgType), intent(inout) :: this !< SwfZdgType object
215  ! -- formats
216  !
217  ! -- source base BndExtType options
218  call this%BndExtType%source_options()
219  !
220  ! -- source options from input context
221  ! none
222  !
223  ! -- log SWF specific options
224  call this%log_zdg_options()
subroutine, public urword(line, icol, istart, istop, ncode, n, r, iout, in)
Extract a word from a string.
Here is the call graph for this function:

◆ zdg_rp_ts()

subroutine swfzdgmodule::zdg_rp_ts ( class(swfzdgtype), intent(inout)  this)
private

Assign the time series links for the ZDG package. Only the Q variable can be defined with time series.

Parameters
[in,out]thisSwfZdgType object

Definition at line 495 of file swf-zdg.f90.

496  ! -- dummy variables
497  class(SwfZdgType), intent(inout) :: this !< SwfZdgType object
498  ! -- local variables
499  integer(I4B) :: i, nlinks
500  type(TimeSeriesLinkType), pointer :: tslink => null()
501  !
502  ! -- set up the time series links
503  nlinks = this%TsManager%boundtslinks%Count()
504  do i = 1, nlinks
505  tslink => gettimeserieslinkfromlist(this%TsManager%boundtslinks, i)
506  if (associated(tslink)) then
507  if (tslink%JCol == 1) then
508  tslink%Text = 'Q'
509  end if
510  end if
511  end do
Here is the call graph for this function:

Variable Documentation

◆ ftype

character(len=lenftype) swfzdgmodule::ftype = 'ZDG'
private

Definition at line 30 of file swf-zdg.f90.

30  character(len=LENFTYPE) :: ftype = 'ZDG' !< package ftype

◆ text

character(len=16) swfzdgmodule::text = ' ZDG'
private

Definition at line 31 of file swf-zdg.f90.

31  character(len=16) :: text = ' ZDG' !< package flow text string