25 character(len=LENBUDTXT),
dimension(1) ::
budtxt = & !< text labels for budget terms
29 integer(I4B),
pointer :: iss => null()
30 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound => null()
31 real(dp),
dimension(:),
pointer,
contiguous :: qsto => null()
34 integer(I4B),
dimension(:),
pointer,
contiguous :: idcxs => null()
40 integer(I4B),
pointer :: iper => null()
41 character(len=:),
pointer :: storage
72 subroutine sto_cr(stoobj, name_model, mempath, inunit, iout, cxs)
75 character(len=*),
intent(in) :: name_model
76 character(len=*),
intent(in) :: mempath
77 integer(I4B),
intent(in) :: inunit
78 integer(I4B),
intent(in) :: iout
85 call stoobj%set_names(1, name_model,
'STO',
'STO', mempath)
88 call stoobj%allocate_scalars()
91 stoobj%inunit = inunit
111 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
114 character(len=*),
parameter :: fmtsto = &
115 "(1x,/1x,'STO -- STORAGE PACKAGE, VERSION 1, 10/27/2023', &
116 &' INPUT READ FROM UNIT ', i0, //)"
119 write (this%iout, fmtsto) this%inunit
122 call this%set_dfw_pointers()
127 this%ibound => ibound
133 call this%allocate_arrays(dis%nodes)
136 call this%source_options()
155 character(len=16) :: css(0:1)
157 data css(0)/
' TRANSIENT'/
158 data css(1)/
' STEADY-STATE'/
161 if (this%inunit <= 0)
return
164 if (this%iper /=
kper)
return
166 write (this%iout,
'(//,1x,a)')
'PROCESSING STORAGE PERIOD DATA'
169 if (this%storage ==
'STEADY-STATE')
then
171 else if (this%storage ==
'TRANSIENT')
then
174 write (
errmsg,
'(a,a)')
'Unknown STORAGE data tag: ', &
180 write (this%iout,
'(1x,a)')
'END PROCESSING STORAGE PERIOD DATA'
182 write (this%iout,
'(//1X,A,I0,A,A,/)') &
183 'STRESS PERIOD ',
kper,
' IS ', trim(adjustl(css(this%iss)))
202 subroutine sto_fc(this, kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
207 integer(I4B) :: kiter
208 real(DP),
intent(inout),
dimension(:) :: stage_old
209 real(DP),
intent(inout),
dimension(:) :: stage_new
211 integer(I4B),
intent(in),
dimension(:) :: idxglo
212 real(DP),
intent(inout),
dimension(:) :: rhs
214 character(len=LINELENGTH) :: distype =
''
216 character(len=*),
parameter :: fmtsperror = &
217 &
"('Detected time step length of zero. SWF Storage Package cannot be ', &
218 &'used unless delt is non-zero.')"
221 if (this%iss /= 0)
return
225 write (
errmsg, fmtsperror)
229 call this%dis%get_dis_type(distype)
230 if (distype ==
'DISV1D')
then
231 call this%sto_fc_dis1d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
233 call this%sto_fc_dis2d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
243 subroutine sto_fc_dis1d(this, kiter, stage_old, stage_new, matrix_sln, &
248 integer(I4B) :: kiter
249 real(DP),
intent(inout),
dimension(:) :: stage_old
250 real(DP),
intent(inout),
dimension(:) :: stage_new
252 integer(I4B),
intent(in),
dimension(:) :: idxglo
253 real(DP),
intent(inout),
dimension(:) :: rhs
255 integer(I4B) :: n, idiag
258 real(DP),
dimension(:),
pointer :: reach_length
261 reach_length => this%reach_length_pointer()
264 do n = 1, this%dis%nodes
267 if (this%ibound(n) < 0) cycle
269 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), &
270 reach_length(n), qsto, derv)
273 idiag = this%dis%con%ia(n)
274 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
275 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
285 subroutine sto_fc_dis2d(this, kiter, stage_old, stage_new, matrix_sln, &
290 integer(I4B) :: kiter
291 real(DP),
intent(inout),
dimension(:) :: stage_old
292 real(DP),
intent(inout),
dimension(:) :: stage_new
294 integer(I4B),
intent(in),
dimension(:) :: idxglo
295 real(DP),
intent(inout),
dimension(:) :: rhs
297 integer(I4B) :: n, idiag
302 do n = 1, this%dis%nodes
305 if (this%ibound(n) < 0) cycle
308 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), &
312 idiag = this%dis%con%ia(n)
313 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
314 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
322 subroutine sto_cq(this, flowja, stage_new, stage_old)
325 real(DP),
intent(inout),
dimension(:) :: flowja
326 real(DP),
intent(inout),
dimension(:) :: stage_new
327 real(DP),
intent(inout),
dimension(:) :: stage_old
329 real(DP),
dimension(:),
pointer :: reach_length
331 integer(I4B) :: idiag
336 if (this%iss /= 0)
return
339 reach_length => this%reach_length_pointer()
342 do n = 1, this%dis%nodes
345 if (this%ibound(n) < 0) cycle
349 if (
associated(reach_length))
then
351 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), dx, q)
353 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), q)
356 idiag = this%dis%con%ia(n)
357 flowja(idiag) = flowja(idiag) + this%qsto(n)
368 integer(I4B),
intent(in) :: n
369 real(DP),
intent(in) :: stage_new
370 real(DP),
intent(in) :: stage_old
371 real(DP),
intent(in) :: dx
372 real(DP),
intent(inout) :: qsto
373 real(DP),
intent(inout),
optional :: derv
375 real(DP) :: depth_new
376 real(DP) :: depth_old
379 real(DP) :: cxs_area_new
380 real(DP) :: cxs_area_old
381 real(DP) :: cxs_area_eps
384 call this%dis%get_flow_width(n, n, 0, width_n, width_m)
385 depth_new = stage_new - this%dis%bot(n)
386 depth_old = stage_old - this%dis%bot(n)
387 cxs_area_new = this%cxs%get_area(this%idcxs(n), width_n, depth_new)
388 cxs_area_old = this%cxs%get_area(this%idcxs(n), width_n, depth_old)
389 qsto = (cxs_area_new - cxs_area_old) * dx /
delt
390 if (
present(derv))
then
392 cxs_area_eps = this%cxs%get_area(this%idcxs(n), width_n, depth_new + eps)
393 derv = (cxs_area_eps - cxs_area_new) * dx /
delt / eps
404 integer(I4B),
intent(in) :: n
405 real(DP),
intent(in) :: stage_new
406 real(DP),
intent(in) :: stage_old
407 real(DP),
intent(inout) :: qsto
408 real(DP),
intent(inout),
optional :: derv
411 real(DP) :: depth_new
412 real(DP) :: depth_old
413 real(DP) :: depth_eps
414 real(DP) :: volume_new
415 real(DP) :: volume_old
418 area = this%dis%get_area(n)
419 depth_new = stage_new - this%dis%bot(n)
420 depth_old = stage_old - this%dis%bot(n)
421 volume_new = area * depth_new
422 volume_old = area * depth_old
423 qsto = (volume_new - volume_old) /
delt
425 if (
present(derv))
then
427 depth_eps = depth_new + eps
428 derv = (depth_eps - depth_new) * area /
delt / eps
439 subroutine sto_bd(this, isuppress_output, model_budget)
445 integer(I4B),
intent(in) :: isuppress_output
446 type(
budgettype),
intent(inout) :: model_budget
453 call model_budget%addentry(rin, rout,
delt,
' STO', &
454 isuppress_output,
' STORAGE')
465 integer(I4B),
intent(in) :: icbcfl
466 integer(I4B),
intent(in) :: icbcun
468 integer(I4B) :: ibinun
469 integer(I4B) :: iprint, nvaluesp, nwidthp
470 character(len=1) :: cdatafmp =
' ', editdesc =
' '
474 if (this%ipakcb < 0)
then
476 elseif (this%ipakcb == 0)
then
481 if (icbcfl == 0) ibinun = 0
484 if (ibinun /= 0)
then
489 call this%dis%record_array(this%qsto, this%iout, iprint, -ibinun, &
490 budtxt(1), cdatafmp, nvaluesp, &
491 nwidthp, editdesc, dinact)
507 if (this%inunit > 0)
then
511 nullify (this%storage)
517 call this%NumericalPackageType%da()
533 call this%NumericalPackageType%allocate_scalars()
552 integer(I4B),
intent(in) :: nodes
557 call mem_allocate(this%qsto, nodes,
'STRGSS', this%memoryPath)
560 if (this%inunit > 0)
then
561 call mem_setptr(this%iper,
'IPER', this%input_mempath)
562 call mem_setptr(this%storage,
'STORAGE', this%input_mempath)
589 call mem_set_value(this%ipakcb,
'IPAKCB', this%input_mempath, found%ipakcb)
591 if (found%ipakcb)
then
596 call this%log_options(found)
613 character(len=*),
parameter :: fmtisvflow = &
614 "(4x,'CELL-BY-CELL FLOW INFORMATION WILL BE SAVED TO BINARY FILE &
615 &WHENEVER ICBCFL IS NOT ZERO.')"
617 write (this%iout,
'(1x,a)')
'PROCESSING STORAGE OPTIONS'
619 if (found%ipakcb)
then
620 write (this%iout, fmtisvflow)
623 write (this%iout,
'(1x,a)')
'END OF STORAGE OPTIONS'
638 character(len=24),
dimension(1) :: aname
639 integer(I4B),
dimension(:),
pointer,
contiguous :: map
643 data aname(1)/
' XXX'/
647 if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
650 write (this%iout,
'(1x,a)')
'PROCESSING GRIDDATA'
651 write (this%iout,
'(1x,a)')
'END PROCESSING GRIDDATA'
662 character(len=LENMEMPATH) :: dfw_mem_path
665 call mem_setptr(this%idcxs,
'IDCXS', dfw_mem_path)
673 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 dhalf
real constant 1/2
real(dp), parameter dem4
real constant 1e-4
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dzero
real constant zero
real(dp), parameter dtwo
real constant 2
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
integer(i4b), parameter lenmempath
maximum length of the memory path
real(dp), parameter done
real constant 1
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.
integer(i4b) function, public count_errors()
Return number of errors.
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.