MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
swfcdbmodule Module Reference

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

Data Types

type  swfcdbtype

Functions/Subroutines

subroutine, public cdb_create (packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, dis, cxs, lengthconv, timeconv)
 Create a new package object.
subroutine cdb_allocate_scalars (this)
 Allocate scalars.
subroutine cdb_allocate_arrays (this, nodelist, auxvar)
 Allocate arrays.
subroutine cdb_da (this)
 Deallocate package memory.
subroutine cdb_options (this)
 Source additional options for package.
subroutine log_cdb_options (this)
 Log SWF specific package options.
subroutine cdb_cf (this)
 Formulate the package hcof and rhs terms.
real(dp) function qcalc (this, i, depth)
 Calculate critical depth boundary flow.
subroutine cdb_fc (this, rhs, ia, idxglo, matrix_sln)
 Copy hcof and rhs terms into solution.
subroutine define_listlabel (this)
 Define the list label for the package.
logical function cdb_obs_supported (this)
 Determine if observations are supported.
subroutine cdb_df_obs (this)
 Define the observation types available in the package.
subroutine cdb_bd_obs (this)
 Save observations for the package.
subroutine cdb_rp_ts (this)
 Assign time series links for the package.
real(dp) function cdb_bound_value (this, col, row)
 Return a bound value.

Variables

character(len=lenftype) ftype = 'CDB'
 package ftype
character(len=16) text = ' CDB'
 package flow text string

Detailed Description

This module can be used to represent outflow from streams using a critical depth boundary.

Function/Subroutine Documentation

◆ cdb_allocate_arrays()

subroutine swfcdbmodule::cdb_allocate_arrays ( class(swfcdbtype) this,
integer(i4b), dimension(:), optional, pointer, contiguous nodelist,
real(dp), dimension(:, :), optional, pointer, contiguous auxvar )
private

Allocate and initialize arrays for the SWF package

Definition at line 146 of file swf-cdb.f90.

147 ! -- modules
149 ! -- dummy
150 class(SwfCdbType) :: this
151 integer(I4B), dimension(:), pointer, contiguous, optional :: nodelist
152 real(DP), dimension(:, :), pointer, contiguous, optional :: auxvar
153 ! -- local
154 !
155 ! -- call BndExtType allocate scalars
156 call this%BndExtType%allocate_arrays(nodelist, auxvar)
157 !
158 ! -- set array input context pointer
159 call mem_setptr(this%idcxs, 'IDCXS', this%input_mempath)
160 call mem_setptr(this%width, 'WIDTH', this%input_mempath)
161 !
162 ! -- checkin array input context pointer
163 call mem_checkin(this%idcxs, 'IDCXS', this%memoryPath, &
164 'IDCXS', this%input_mempath)
165 call mem_checkin(this%width, 'WIDTH', this%memoryPath, &
166 'WIDTH', this%input_mempath)

◆ cdb_allocate_scalars()

subroutine swfcdbmodule::cdb_allocate_scalars ( class(swfcdbtype) this)
private

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

Parameters
thisSwfcdbType object

Definition at line 125 of file swf-cdb.f90.

126 ! -- modules
128 ! -- dummy variables
129 class(SwfCdbType) :: this !< SwfcdbType object
130 !
131 ! -- call base type allocate scalars
132 call this%BndExtType%allocate_scalars()
133 !
134 ! -- allocate the object and assign values to object variables
135 call mem_allocate(this%gravconv, 'GRAVCONV', this%memoryPath)
136 !
137 ! -- Set values
138 this%gravconv = dzero

◆ cdb_bd_obs()

subroutine swfcdbmodule::cdb_bd_obs ( class(swfcdbtype) this)
private

Method to save simulated values for the CDB package.

Parameters
thisSwfCdbType object

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

425 ! -- dummy variables
426 class(SwfCdbType) :: this !< SwfCdbType object
427 ! -- local variables
428 integer(I4B) :: i
429 integer(I4B) :: n
430 integer(I4B) :: jj
431 real(DP) :: v
432 type(ObserveType), pointer :: obsrv => null()
433 !
434 ! -- clear the observations
435 call this%obs%obs_bd_clear()
436 !
437 ! -- Save simulated values for all of package's observations.
438 do i = 1, this%obs%npakobs
439 obsrv => this%obs%pakobs(i)%obsrv
440 if (obsrv%BndFound) then
441 do n = 1, obsrv%indxbnds_count
442 v = dnodata
443 jj = obsrv%indxbnds(n)
444 select case (obsrv%ObsTypeId)
445 case ('TO-MVR')
446 if (this%imover == 1) then
447 v = this%pakmvrobj%get_qtomvr(jj)
448 if (v > dzero) then
449 v = -v
450 end if
451 end if
452 case ('CDB')
453 v = this%simvals(jj)
454 case default
455 errmsg = 'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
456 call store_error(errmsg)
457 end select
458 call this%obs%SaveOneSimval(obsrv, v)
459 end do
460 else
461 call this%obs%SaveOneSimval(obsrv, dnodata)
462 end if
463 end do
Here is the call graph for this function:

◆ cdb_bound_value()

real(dp) function swfcdbmodule::cdb_bound_value ( class(swfcdbtype), 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 499 of file swf-cdb.f90.

500 ! -- modules
501 use constantsmodule, only: dzero
502 ! -- dummy variables
503 class(SwfCdbType), intent(inout) :: this
504 integer(I4B), intent(in) :: col
505 integer(I4B), intent(in) :: row
506 ! -- result
507 real(DP) :: bndval
508 !
509 select case (col)
510 case (1)
511 bndval = this%idcxs(row)
512 case (2)
513 bndval = this%width(row)
514 case default
515 errmsg = 'Programming error. CDB bound value requested column '&
516 &'outside range of ncolbnd (1).'
517 call store_error(errmsg)
518 call store_error_filename(this%input_fname)
519 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:

◆ cdb_cf()

subroutine swfcdbmodule::cdb_cf ( class(swfcdbtype) this)
private

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

Parameters
thisSwfCdbType object

Definition at line 237 of file swf-cdb.f90.

238 ! modules
240 ! -- dummy variables
241 class(SwfCdbType) :: this !< SwfCdbType object
242 ! -- local variables
243 integer(I4B) :: i, node
244 real(DP) :: q
245 real(DP) :: qeps
246 real(DP) :: depth
247 real(DP) :: derv
248 real(DP) :: eps
249 !
250 ! -- Return if no inflows
251 if (this%nbound == 0) return
252 !
253 ! -- Calculate hcof and rhs for each cdb entry
254 do i = 1, this%nbound
255
256 node = this%nodelist(i)
257 if (this%ibound(node) <= 0) then
258 this%hcof(i) = dzero
259 this%rhs(i) = dzero
260 cycle
261 end if
262
263 ! -- calculate terms and add to hcof and rhs
264 depth = this%xnew(node) - this%dis%bot(node)
265
266 ! -- calculate unperturbed q
267 q = this%qcalc(i, depth)
268
269 ! -- calculate perturbed q
270 eps = get_perturbation(depth)
271 qeps = this%qcalc(i, depth + eps)
272
273 ! -- calculate derivative
274 derv = (qeps - q) / eps
275
276 ! -- add terms to hcof and rhs
277 this%hcof(i) = derv
278 this%rhs(i) = -q + derv * this%xnew(node)
279
280 end do
real(dp) function, public get_perturbation(x)
Calculate a numerical perturbation given the value of x.
Definition MathUtil.f90:372
Here is the call graph for this function:

◆ cdb_create()

subroutine, public swfcdbmodule::cdb_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) lengthconv,
real(dp), intent(in) timeconv )

Create a new CDB Package object

Parameters
packobjpointer to default package type
[in]idpackage id
[in]ibcnumboundary condition number
[in]inunitunit number of CDB 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]lengthconvconversion factor from model length to meters
[in]timeconvconversion factor from model time units to seconds

Definition at line 69 of file swf-cdb.f90.

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

◆ cdb_da()

subroutine swfcdbmodule::cdb_da ( class(swfcdbtype) this)
private

Deallocate SWF package scalars and arrays.

Parameters
thisSwfcdbType object

Definition at line 174 of file swf-cdb.f90.

175 ! -- modules
177 ! -- dummy variables
178 class(SwfCdbType) :: this !< SwfcdbType object
179 !
180 ! -- Deallocate parent package
181 call this%BndExtType%bnd_da()
182 !
183 ! -- arrays
184 call mem_deallocate(this%idcxs, 'IDCXS', this%memoryPath)
185 call mem_deallocate(this%width, 'WIDTH', this%memoryPath)
186 !
187 ! -- scalars
188 call mem_deallocate(this%gravconv)

◆ cdb_df_obs()

subroutine swfcdbmodule::cdb_df_obs ( class(swfcdbtype) this)
private

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

Parameters
thisSwfCdbType object

Definition at line 403 of file swf-cdb.f90.

404 ! -- dummy variables
405 class(SwfCdbType) :: this !< SwfCdbType object
406 ! -- local variables
407 integer(I4B) :: indx
408 !
409 ! -- initialize observations
410 call this%obs%StoreObsType('cdb', .true., indx)
411 this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
412 !
413 ! -- Store obs type and assign procedure pointer
414 ! for to-mvr observation type.
415 call this%obs%StoreObsType('to-mvr', .true., indx)
416 this%obs%obsData(indx)%ProcessIdPtr => defaultobsidprocessor
Here is the call graph for this function:

◆ cdb_fc()

subroutine swfcdbmodule::cdb_fc ( class(swfcdbtype) 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 CDB package to the coefficient matrix and right-hand side vector.

Parameters
thisSwfCdbType 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 320 of file swf-cdb.f90.

321 ! -- dummy variables
322 class(SwfCdbType) :: this !< SwfCdbType object
323 real(DP), dimension(:), intent(inout) :: rhs !< right-hand side vector for model
324 integer(I4B), dimension(:), intent(in) :: ia !< solution CRS row pointers
325 integer(I4B), dimension(:), intent(in) :: idxglo !< mapping vector for model (local) to solution (global)
326 class(MatrixBaseType), pointer :: matrix_sln !< solution coefficient matrix
327 ! -- local variables
328 integer(I4B) :: i
329 integer(I4B) :: n
330 integer(I4B) :: ipos
331 !
332 ! -- pakmvrobj fc
333 if (this%imover == 1) then
334 call this%pakmvrobj%fc()
335 end if
336 !
337 ! -- Copy package rhs and hcof into solution rhs and amat
338 do i = 1, this%nbound
339 n = this%nodelist(i)
340 rhs(n) = rhs(n) + this%rhs(i)
341 ipos = ia(n)
342 call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(i))
343 !
344 ! -- If mover is active and this cdb item is discharging,
345 ! store available water (as positive value).
346 if (this%imover == 1 .and. this%rhs(i) > dzero) then
347 call this%pakmvrobj%accumulate_qformvr(i, this%rhs(i))
348 end if
349 end do

◆ cdb_obs_supported()

logical function swfcdbmodule::cdb_obs_supported ( class(swfcdbtype) this)
private

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

Returns
cdb_obs_supported boolean indicating if observations are supported
Parameters
thisSwfCdbType object

Definition at line 390 of file swf-cdb.f90.

391 ! -- dummy variables
392 class(SwfCdbType) :: this !< SwfCdbType object
393 !
394 ! -- set boolean
395 cdb_obs_supported = .true.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cdb_options()

subroutine swfcdbmodule::cdb_options ( class(swfcdbtype), intent(inout) this)
private

Source additional options for SWF package.

Parameters
[in,out]thisSwfCdbType object

Definition at line 196 of file swf-cdb.f90.

197 ! -- modules
198 use inputoutputmodule, only: urword
200 ! -- dummy variables
201 class(SwfCdbType), intent(inout) :: this !< SwfCdbType object
202 ! -- formats
203 !
204 ! -- source base BndExtType options
205 call this%BndExtType%source_options()
206 !
207 ! -- source options from input context
208 ! none
209 !
210 ! -- log SWF specific options
211 call this%log_cdb_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:

◆ cdb_rp_ts()

subroutine swfcdbmodule::cdb_rp_ts ( class(swfcdbtype), intent(inout) this)
private

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

Parameters
[in,out]thisSwfCdbType object

Definition at line 474 of file swf-cdb.f90.

475 ! -- dummy variables
476 class(SwfCdbType), intent(inout) :: this !< SwfCdbType object
477 ! -- local variables
478 integer(I4B) :: i, nlinks
479 type(TimeSeriesLinkType), pointer :: tslink => null()
480 !
481 ! -- set up the time series links
482 nlinks = this%TsManager%boundtslinks%Count()
483 do i = 1, nlinks
484 tslink => gettimeserieslinkfromlist(this%TsManager%boundtslinks, i)
485 if (associated(tslink)) then
486 if (tslink%JCol == 1) then
487 tslink%Text = 'Q'
488 end if
489 end if
490 end do
Here is the call graph for this function:

◆ define_listlabel()

subroutine swfcdbmodule::define_listlabel ( class(swfcdbtype), intent(inout) this)
private

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

Parameters
[in,out]thisSwfCdbType object

Definition at line 358 of file swf-cdb.f90.

359 ! -- dummy variables
360 class(SwfCdbType), intent(inout) :: this !< SwfCdbType object
361 !
362 ! -- create the header list label
363 this%listlabel = trim(this%filtyp)//' NO.'
364 if (this%dis%ndim == 3) then
365 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
366 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'ROW'
367 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'COL'
368 elseif (this%dis%ndim == 2) then
369 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'LAYER'
370 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'CELL2D'
371 else
372 write (this%listlabel, '(a, a7)') trim(this%listlabel), 'NODE'
373 end if
374 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'FLOW RATE'
375 if (this%inamedbound == 1) then
376 write (this%listlabel, '(a, a16)') trim(this%listlabel), 'BOUNDARY NAME'
377 end if

◆ log_cdb_options()

subroutine swfcdbmodule::log_cdb_options ( class(swfcdbtype), intent(inout) this)
private

Definition at line 216 of file swf-cdb.f90.

217 ! -- dummy variables
218 class(SwfCdbType), intent(inout) :: this
219 ! -- local variables
220 ! -- format
221 !
222 ! -- log found options
223 write (this%iout, '(/1x,a)') 'PROCESSING '//trim(adjustl(this%text)) &
224 //' OPTIONS'
225 !
226 ! -- close logging block
227 write (this%iout, '(1x,a)') &
228 'END OF '//trim(adjustl(this%text))//' OPTIONS'

◆ qcalc()

real(dp) function swfcdbmodule::qcalc ( class(swfcdbtype) this,
integer(i4b), intent(in) i,
real(dp), intent(in) depth )
private
Parameters
[in]iboundary number
[in]depthsimulated depth (stage - elevation) in reach n for this iteration

Definition at line 285 of file swf-cdb.f90.

286 ! modules
287 ! dummy
288 class(SwfCdbType) :: this
289 integer(I4B), intent(in) :: i !< boundary number
290 real(DP), intent(in) :: depth !< simulated depth (stage - elevation) in reach n for this iteration
291 ! return
292 real(DP) :: q
293 ! local
294 integer(I4B) :: idcxs
295 real(DP) :: width
296 real(DP) :: a
297 real(DP) :: r
298
299 idcxs = this%idcxs(i)
300 width = this%width(i)
301 a = this%cxs%get_area(idcxs, width, depth)
302 r = this%cxs%get_hydraulic_radius(idcxs, width, depth, area=a)
303
304 q = this%gravconv * a**dtwo * r
305 if (q > dprec) then
306 q = q**dhalf
307 else
308 q = dzero
309 end if
310 q = -q
311

Variable Documentation

◆ ftype

character(len=lenftype) swfcdbmodule::ftype = 'CDB'
private

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

◆ text

character(len=16) swfcdbmodule::text = ' CDB'
private

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