23 character(len=LENBUDTXT),
dimension(1) ::
budtxt = & !< text labels for budget terms
28 logical(LGP) :: ipakcb = .false.
32 integer(I4B),
pointer :: iss => null()
33 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound => null()
34 real(dp),
dimension(:),
pointer,
contiguous :: qsto => null()
37 integer(I4B),
dimension(:),
pointer,
contiguous :: idcxs => null()
43 integer(I4B),
pointer :: iper => null()
44 character(len=:),
pointer :: storage
75 subroutine sto_cr(stoobj, name_model, mempath, inunit, iout, cxs)
78 character(len=*),
intent(in) :: name_model
79 character(len=*),
intent(in) :: mempath
80 integer(I4B),
intent(in) :: inunit
81 integer(I4B),
intent(in) :: iout
88 call stoobj%set_names(1, name_model,
'STO',
'STO', mempath)
91 call stoobj%allocate_scalars()
94 stoobj%inunit = inunit
114 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
117 character(len=*),
parameter :: fmtsto = &
118 "(1x,/1x,'STO -- STORAGE PACKAGE, VERSION 1, 10/27/2023', &
119 &' INPUT READ FROM UNIT ', i0, //)"
122 write (this%iout, fmtsto) this%inunit
125 call this%set_dfw_pointers()
130 this%ibound => ibound
136 call this%allocate_arrays(dis%nodes)
139 call this%source_options()
158 character(len=16) :: css(0:1)
160 data css(0)/
' TRANSIENT'/
161 data css(1)/
' STEADY-STATE'/
164 if (this%inunit <= 0)
return
167 if (this%iper /=
kper)
return
169 write (this%iout,
'(//,1x,a)')
'PROCESSING STORAGE PERIOD DATA'
172 if (this%storage ==
'STEADY-STATE')
then
174 else if (this%storage ==
'TRANSIENT')
then
177 write (
errmsg,
'(a,a)')
'Unknown STORAGE data tag: ', &
183 write (this%iout,
'(1x,a)')
'END PROCESSING STORAGE PERIOD DATA'
185 write (this%iout,
'(//1X,A,I0,A,A,/)') &
186 'STRESS PERIOD ',
kper,
' IS ', trim(adjustl(css(this%iss)))
205 subroutine sto_fc(this, kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
210 integer(I4B) :: kiter
211 real(DP),
intent(inout),
dimension(:) :: stage_old
212 real(DP),
intent(inout),
dimension(:) :: stage_new
214 integer(I4B),
intent(in),
dimension(:) :: idxglo
215 real(DP),
intent(inout),
dimension(:) :: rhs
218 character(len=*),
parameter :: fmtsperror = &
219 &
"('Detected time step length of zero. SWF Storage Package cannot be ', &
220 &'used unless delt is non-zero.')"
223 if (this%iss /= 0)
return
227 write (
errmsg, fmtsperror)
231 if (this%dis%is_1d())
then
232 call this%sto_fc_dis1d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
234 call this%sto_fc_dis2d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
244 subroutine sto_fc_dis1d(this, kiter, stage_old, stage_new, matrix_sln, &
249 integer(I4B) :: kiter
250 real(DP),
intent(inout),
dimension(:) :: stage_old
251 real(DP),
intent(inout),
dimension(:) :: stage_new
253 integer(I4B),
intent(in),
dimension(:) :: idxglo
254 real(DP),
intent(inout),
dimension(:) :: rhs
256 integer(I4B) :: n, idiag
259 real(DP),
dimension(:),
pointer :: reach_length
262 reach_length => this%reach_length_pointer()
265 do n = 1, this%dis%nodes
268 if (this%ibound(n) < 0) cycle
270 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), &
271 reach_length(n), qsto, derv)
274 idiag = this%dis%con%ia(n)
275 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
276 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
286 subroutine sto_fc_dis2d(this, kiter, stage_old, stage_new, matrix_sln, &
291 integer(I4B) :: kiter
292 real(DP),
intent(inout),
dimension(:) :: stage_old
293 real(DP),
intent(inout),
dimension(:) :: stage_new
295 integer(I4B),
intent(in),
dimension(:) :: idxglo
296 real(DP),
intent(inout),
dimension(:) :: rhs
298 integer(I4B) :: n, idiag
303 do n = 1, this%dis%nodes
306 if (this%ibound(n) < 0) cycle
309 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), &
313 idiag = this%dis%con%ia(n)
314 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
315 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
323 subroutine sto_cq(this, flowja, stage_new, stage_old)
326 real(DP),
intent(inout),
dimension(:) :: flowja
327 real(DP),
intent(inout),
dimension(:) :: stage_new
328 real(DP),
intent(inout),
dimension(:) :: stage_old
330 real(DP),
dimension(:),
pointer :: reach_length
332 integer(I4B) :: idiag
337 if (this%iss /= 0)
return
340 reach_length => this%reach_length_pointer()
343 do n = 1, this%dis%nodes
346 if (this%ibound(n) < 0) cycle
350 if (
associated(reach_length))
then
352 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), dx, q)
354 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), q)
357 idiag = this%dis%con%ia(n)
358 flowja(idiag) = flowja(idiag) + this%qsto(n)
369 integer(I4B),
intent(in) :: n
370 real(DP),
intent(in) :: stage_new
371 real(DP),
intent(in) :: stage_old
372 real(DP),
intent(in) :: dx
373 real(DP),
intent(inout) :: qsto
374 real(DP),
intent(inout),
optional :: derv
376 real(DP) :: depth_new
377 real(DP) :: depth_old
380 real(DP) :: cxs_area_new
381 real(DP) :: cxs_area_old
382 real(DP) :: cxs_area_eps
385 call this%dis%get_flow_width(n, n, 0, width_n, width_m)
386 depth_new = stage_new - this%dis%bot(n)
387 depth_old = stage_old - this%dis%bot(n)
388 cxs_area_new = this%cxs%get_area(this%idcxs(n), width_n, depth_new)
389 cxs_area_old = this%cxs%get_area(this%idcxs(n), width_n, depth_old)
390 qsto = (cxs_area_new - cxs_area_old) * dx /
delt
391 if (
present(derv))
then
393 cxs_area_eps = this%cxs%get_area(this%idcxs(n), width_n, depth_new + eps)
394 derv = (cxs_area_eps - cxs_area_new) * dx /
delt / eps
405 integer(I4B),
intent(in) :: n
406 real(DP),
intent(in) :: stage_new
407 real(DP),
intent(in) :: stage_old
408 real(DP),
intent(inout) :: qsto
409 real(DP),
intent(inout),
optional :: derv
412 real(DP) :: depth_new
413 real(DP) :: depth_old
414 real(DP) :: depth_eps
415 real(DP) :: volume_new
416 real(DP) :: volume_old
419 area = this%dis%get_area(n)
420 depth_new = stage_new - this%dis%bot(n)
421 depth_old = stage_old - this%dis%bot(n)
422 volume_new = area * depth_new
423 volume_old = area * depth_old
424 qsto = (volume_new - volume_old) /
delt
426 if (
present(derv))
then
428 depth_eps = depth_new + eps
429 derv = (depth_eps - depth_new) * area /
delt / eps
440 subroutine sto_bd(this, isuppress_output, model_budget)
446 integer(I4B),
intent(in) :: isuppress_output
447 type(
budgettype),
intent(inout) :: model_budget
454 call model_budget%addentry(rin, rout,
delt,
' STO', &
455 isuppress_output,
' STORAGE')
466 integer(I4B),
intent(in) :: icbcfl
467 integer(I4B),
intent(in) :: icbcun
469 integer(I4B) :: ibinun
470 integer(I4B) :: iprint, nvaluesp, nwidthp
471 character(len=1) :: cdatafmp =
' ', editdesc =
' '
475 if (this%ipakcb < 0)
then
477 elseif (this%ipakcb == 0)
then
482 if (icbcfl == 0) ibinun = 0
485 if (ibinun /= 0)
then
490 call this%dis%record_array(this%qsto, this%iout, iprint, -ibinun, &
491 budtxt(1), cdatafmp, nvaluesp, &
492 nwidthp, editdesc, dinact)
508 if (this%inunit > 0)
then
512 nullify (this%storage)
518 call this%NumericalPackageType%da()
534 call this%NumericalPackageType%allocate_scalars()
553 integer(I4B),
intent(in) :: nodes
558 call mem_allocate(this%qsto, nodes,
'STRGSS', this%memoryPath)
561 if (this%inunit > 0)
then
562 call mem_setptr(this%iper,
'IPER', this%input_mempath)
563 call mem_setptr(this%storage,
'STORAGE', this%input_mempath)
588 call mem_set_value(this%ipakcb,
'IPAKCB', this%input_mempath, found%ipakcb)
590 if (found%ipakcb)
then
595 call this%log_options(found)
611 character(len=*),
parameter :: fmtisvflow = &
612 "(4x,'CELL-BY-CELL FLOW INFORMATION WILL BE SAVED TO BINARY FILE &
613 &WHENEVER ICBCFL IS NOT ZERO.')"
615 write (this%iout,
'(1x,a)')
'PROCESSING STORAGE OPTIONS'
617 if (found%ipakcb)
then
618 write (this%iout, fmtisvflow)
621 write (this%iout,
'(1x,a)')
'END OF STORAGE OPTIONS'
635 character(len=24),
dimension(1) :: aname
636 integer(I4B),
dimension(:),
pointer,
contiguous :: map
639 data aname(1)/
' XXX'/
643 if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
646 write (this%iout,
'(1x,a)')
'PROCESSING GRIDDATA'
647 write (this%iout,
'(1x,a)')
'END PROCESSING GRIDDATA'
658 character(len=LENMEMPATH) :: dfw_mem_path
661 call mem_setptr(this%idcxs,
'IDCXS', dfw_mem_path)
669 real(dp),
dimension(:),
pointer :: ptr
This module contains the BudgetModule.
subroutine, public rate_accumulator(flow, rin, rout)
@ brief Rate accumulator subroutine
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
integer(i4b), parameter lenmempath
maximum length of the memory path
This module defines variable data types.
real(dp) function, public get_perturbation(x)
Calculate a numerical perturbation given the value of x.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains the base numerical package type.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
This module contains the SourceCommonModule.
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
This module contains the storage package methods.
subroutine sto_fc_dis2d(this, kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
@ brief Fill A and right-hand side for the package
subroutine calc_storage_dis2d(this, n, stage_new, stage_old, qsto, derv)
subroutine sto_save_model_flows(this, icbcfl, icbcun)
@ brief Save model flows for package
subroutine source_data(this)
@ brief Source input data for package
subroutine log_options(this, found)
@ brief Log found options for package
subroutine sto_fc(this, kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
@ brief Fill A and right-hand side for the package
subroutine sto_bd(this, isuppress_output, model_budget)
@ brief Model budget calculation for package
subroutine sto_cq(this, flowja, stage_new, stage_old)
@ brief Calculate flows for package
subroutine sto_rp(this)
@ brief Read and prepare method for package
subroutine sto_ad(this)
@ brief Advance the package
subroutine sto_ar(this, dis, ibound)
@ brief Allocate and read method for package
subroutine sto_da(this)
@ brief Deallocate package memory
subroutine sto_fc_dis1d(this, kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
@ brief Fill A and right-hand side for the package
real(dp) function, dimension(:), pointer reach_length_pointer(this)
subroutine allocate_arrays(this, nodes)
@ brief Allocate package arrays
subroutine calc_storage_dis1d(this, n, stage_new, stage_old, dx, qsto, derv)
subroutine set_dfw_pointers(this)
Set pointers to channel properties in DFW Package.
subroutine, public sto_cr(stoobj, name_model, mempath, inunit, iout, cxs)
@ brief Create a new package object
subroutine allocate_scalars(this)
@ brief Allocate scalars
subroutine source_options(this)
@ brief Source input options for package
character(len=lenbudtxt), dimension(1) budtxt
integer(i4b), pointer, public kper
current stress period number
real(dp), pointer, public delt
length of the current time step
Derived type for the Budget object.
flags indicating which STO options were found in the input