23 character(len=LENBUDTXT),
dimension(1) ::
budtxt = & !< text labels for budget terms
27 integer(I4B),
pointer :: iss => null()
28 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound => null()
29 real(dp),
dimension(:),
pointer,
contiguous :: qsto => null()
32 integer(I4B),
dimension(:),
pointer,
contiguous :: idcxs => null()
38 integer(I4B),
pointer :: iper => null()
39 character(len=:),
pointer :: storage
70 subroutine sto_cr(stoobj, name_model, mempath, inunit, iout, cxs)
73 character(len=*),
intent(in) :: name_model
74 character(len=*),
intent(in) :: mempath
75 integer(I4B),
intent(in) :: inunit
76 integer(I4B),
intent(in) :: iout
83 call stoobj%set_names(1, name_model,
'STO',
'STO', mempath)
86 call stoobj%allocate_scalars()
89 stoobj%inunit = inunit
109 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
112 character(len=*),
parameter :: fmtsto = &
113 "(1x,/1x,'STO -- STORAGE PACKAGE, VERSION 1, 10/27/2023', &
114 &' INPUT READ FROM UNIT ', i0, //)"
117 write (this%iout, fmtsto) this%inunit
120 call this%set_dfw_pointers()
125 this%ibound => ibound
131 call this%allocate_arrays(dis%nodes)
134 call this%source_options()
153 character(len=16) :: css(0:1)
155 data css(0)/
' TRANSIENT'/
156 data css(1)/
' STEADY-STATE'/
159 if (this%inunit <= 0)
return
162 if (this%iper /=
kper)
return
164 write (this%iout,
'(//,1x,a)')
'PROCESSING STORAGE PERIOD DATA'
167 if (this%storage ==
'STEADY-STATE')
then
169 else if (this%storage ==
'TRANSIENT')
then
172 write (
errmsg,
'(a,a)')
'Unknown STORAGE data tag: ', &
178 write (this%iout,
'(1x,a)')
'END PROCESSING STORAGE PERIOD DATA'
180 write (this%iout,
'(//1X,A,I0,A,A,/)') &
181 'STRESS PERIOD ',
kper,
' IS ', trim(adjustl(css(this%iss)))
200 subroutine sto_fc(this, kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
205 integer(I4B) :: kiter
206 real(DP),
intent(inout),
dimension(:) :: stage_old
207 real(DP),
intent(inout),
dimension(:) :: stage_new
209 integer(I4B),
intent(in),
dimension(:) :: idxglo
210 real(DP),
intent(inout),
dimension(:) :: rhs
212 character(len=LINELENGTH) :: distype =
''
214 character(len=*),
parameter :: fmtsperror = &
215 &
"('Detected time step length of zero. SWF Storage Package cannot be ', &
216 &'used unless delt is non-zero.')"
219 if (this%iss /= 0)
return
223 write (
errmsg, fmtsperror)
227 call this%dis%get_dis_type(distype)
228 if (distype ==
'DISV1D')
then
229 call this%sto_fc_dis1d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
231 call this%sto_fc_dis2d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
241 subroutine sto_fc_dis1d(this, kiter, stage_old, stage_new, matrix_sln, &
246 integer(I4B) :: kiter
247 real(DP),
intent(inout),
dimension(:) :: stage_old
248 real(DP),
intent(inout),
dimension(:) :: stage_new
250 integer(I4B),
intent(in),
dimension(:) :: idxglo
251 real(DP),
intent(inout),
dimension(:) :: rhs
253 integer(I4B) :: n, idiag
256 real(DP),
dimension(:),
pointer :: reach_length
259 reach_length => this%reach_length_pointer()
262 do n = 1, this%dis%nodes
265 if (this%ibound(n) < 0) cycle
267 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), &
268 reach_length(n), qsto, derv)
271 idiag = this%dis%con%ia(n)
272 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
273 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
283 subroutine sto_fc_dis2d(this, kiter, stage_old, stage_new, matrix_sln, &
288 integer(I4B) :: kiter
289 real(DP),
intent(inout),
dimension(:) :: stage_old
290 real(DP),
intent(inout),
dimension(:) :: stage_new
292 integer(I4B),
intent(in),
dimension(:) :: idxglo
293 real(DP),
intent(inout),
dimension(:) :: rhs
295 integer(I4B) :: n, idiag
300 do n = 1, this%dis%nodes
303 if (this%ibound(n) < 0) cycle
306 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), &
310 idiag = this%dis%con%ia(n)
311 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
312 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
320 subroutine sto_cq(this, flowja, stage_new, stage_old)
323 real(DP),
intent(inout),
dimension(:) :: flowja
324 real(DP),
intent(inout),
dimension(:) :: stage_new
325 real(DP),
intent(inout),
dimension(:) :: stage_old
327 real(DP),
dimension(:),
pointer :: reach_length
329 integer(I4B) :: idiag
334 if (this%iss /= 0)
return
337 reach_length => this%reach_length_pointer()
340 do n = 1, this%dis%nodes
343 if (this%ibound(n) < 0) cycle
347 if (
associated(reach_length))
then
349 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), dx, q)
351 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), q)
354 idiag = this%dis%con%ia(n)
355 flowja(idiag) = flowja(idiag) + this%qsto(n)
366 integer(I4B),
intent(in) :: n
367 real(DP),
intent(in) :: stage_new
368 real(DP),
intent(in) :: stage_old
369 real(DP),
intent(in) :: dx
370 real(DP),
intent(inout) :: qsto
371 real(DP),
intent(inout),
optional :: derv
373 real(DP) :: depth_new
374 real(DP) :: depth_old
377 real(DP) :: cxs_area_new
378 real(DP) :: cxs_area_old
379 real(DP) :: cxs_area_eps
382 call this%dis%get_flow_width(n, n, 0, width_n, width_m)
383 depth_new = stage_new - this%dis%bot(n)
384 depth_old = stage_old - this%dis%bot(n)
385 cxs_area_new = this%cxs%get_area(this%idcxs(n), width_n, depth_new)
386 cxs_area_old = this%cxs%get_area(this%idcxs(n), width_n, depth_old)
387 qsto = (cxs_area_new - cxs_area_old) * dx /
delt
388 if (
present(derv))
then
390 cxs_area_eps = this%cxs%get_area(this%idcxs(n), width_n, depth_new + eps)
391 derv = (cxs_area_eps - cxs_area_new) * dx /
delt / eps
402 integer(I4B),
intent(in) :: n
403 real(DP),
intent(in) :: stage_new
404 real(DP),
intent(in) :: stage_old
405 real(DP),
intent(inout) :: qsto
406 real(DP),
intent(inout),
optional :: derv
409 real(DP) :: depth_new
410 real(DP) :: depth_old
411 real(DP) :: depth_eps
412 real(DP) :: volume_new
413 real(DP) :: volume_old
416 area = this%dis%get_area(n)
417 depth_new = stage_new - this%dis%bot(n)
418 depth_old = stage_old - this%dis%bot(n)
419 volume_new = area * depth_new
420 volume_old = area * depth_old
421 qsto = (volume_new - volume_old) /
delt
423 if (
present(derv))
then
425 depth_eps = depth_new + eps
426 derv = (depth_eps - depth_new) * area /
delt / eps
437 subroutine sto_bd(this, isuppress_output, model_budget)
443 integer(I4B),
intent(in) :: isuppress_output
444 type(
budgettype),
intent(inout) :: model_budget
451 call model_budget%addentry(rin, rout,
delt,
' STO', &
452 isuppress_output,
' STORAGE')
463 integer(I4B),
intent(in) :: icbcfl
464 integer(I4B),
intent(in) :: icbcun
466 integer(I4B) :: ibinun
467 integer(I4B) :: iprint, nvaluesp, nwidthp
468 character(len=1) :: cdatafmp =
' ', editdesc =
' '
472 if (this%ipakcb < 0)
then
474 elseif (this%ipakcb == 0)
then
479 if (icbcfl == 0) ibinun = 0
482 if (ibinun /= 0)
then
487 call this%dis%record_array(this%qsto, this%iout, iprint, -ibinun, &
488 budtxt(1), cdatafmp, nvaluesp, &
489 nwidthp, editdesc, dinact)
505 if (this%inunit > 0)
then
509 nullify (this%storage)
515 call this%NumericalPackageType%da()
531 call this%NumericalPackageType%allocate_scalars()
550 integer(I4B),
intent(in) :: nodes
555 call mem_allocate(this%qsto, nodes,
'STRGSS', this%memoryPath)
558 if (this%inunit > 0)
then
559 call mem_setptr(this%iper,
'IPER', this%input_mempath)
560 call mem_setptr(this%storage,
'STORAGE', this%input_mempath)
586 call mem_set_value(this%ipakcb,
'IPAKCB', this%input_mempath, found%ipakcb)
588 if (found%ipakcb)
then
593 call this%log_options(found)
610 character(len=*),
parameter :: fmtisvflow = &
611 "(4x,'CELL-BY-CELL FLOW INFORMATION WILL BE SAVED TO BINARY FILE &
612 &WHENEVER ICBCFL IS NOT ZERO.')"
614 write (this%iout,
'(1x,a)')
'PROCESSING STORAGE OPTIONS'
616 if (found%ipakcb)
then
617 write (this%iout, fmtisvflow)
620 write (this%iout,
'(1x,a)')
'END OF STORAGE OPTIONS'
635 character(len=24),
dimension(1) :: aname
636 integer(I4B),
dimension(:),
pointer,
contiguous :: map
640 data aname(1)/
' XXX'/
644 if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
647 write (this%iout,
'(1x,a)')
'PROCESSING GRIDDATA'
648 write (this%iout,
'(1x,a)')
'END PROCESSING GRIDDATA'
659 character(len=LENMEMPATH) :: dfw_mem_path
662 call mem_setptr(this%idcxs,
'IDCXS', dfw_mem_path)
670 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.