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
213 character(len=*),
parameter :: fmtsperror = &
214 &
"('Detected time step length of zero. SWF Storage Package cannot be ', &
215 &'used unless delt is non-zero.')"
218 if (this%iss /= 0)
return
222 write (
errmsg, fmtsperror)
226 if (this%dis%is_1d())
then
227 call this%sto_fc_dis1d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
229 call this%sto_fc_dis2d(kiter, stage_old, stage_new, matrix_sln, idxglo, rhs)
239 subroutine sto_fc_dis1d(this, kiter, stage_old, stage_new, matrix_sln, &
244 integer(I4B) :: kiter
245 real(DP),
intent(inout),
dimension(:) :: stage_old
246 real(DP),
intent(inout),
dimension(:) :: stage_new
248 integer(I4B),
intent(in),
dimension(:) :: idxglo
249 real(DP),
intent(inout),
dimension(:) :: rhs
251 integer(I4B) :: n, idiag
254 real(DP),
dimension(:),
pointer :: reach_length
257 reach_length => this%reach_length_pointer()
260 do n = 1, this%dis%nodes
263 if (this%ibound(n) < 0) cycle
265 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), &
266 reach_length(n), qsto, derv)
269 idiag = this%dis%con%ia(n)
270 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
271 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
281 subroutine sto_fc_dis2d(this, kiter, stage_old, stage_new, matrix_sln, &
286 integer(I4B) :: kiter
287 real(DP),
intent(inout),
dimension(:) :: stage_old
288 real(DP),
intent(inout),
dimension(:) :: stage_new
290 integer(I4B),
intent(in),
dimension(:) :: idxglo
291 real(DP),
intent(inout),
dimension(:) :: rhs
293 integer(I4B) :: n, idiag
298 do n = 1, this%dis%nodes
301 if (this%ibound(n) < 0) cycle
304 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), &
308 idiag = this%dis%con%ia(n)
309 call matrix_sln%add_value_pos(idxglo(idiag), -derv)
310 rhs(n) = rhs(n) + qsto - derv * stage_new(n)
318 subroutine sto_cq(this, flowja, stage_new, stage_old)
321 real(DP),
intent(inout),
dimension(:) :: flowja
322 real(DP),
intent(inout),
dimension(:) :: stage_new
323 real(DP),
intent(inout),
dimension(:) :: stage_old
325 real(DP),
dimension(:),
pointer :: reach_length
327 integer(I4B) :: idiag
332 if (this%iss /= 0)
return
335 reach_length => this%reach_length_pointer()
338 do n = 1, this%dis%nodes
341 if (this%ibound(n) < 0) cycle
345 if (
associated(reach_length))
then
347 call this%calc_storage_dis1d(n, stage_new(n), stage_old(n), dx, q)
349 call this%calc_storage_dis2d(n, stage_new(n), stage_old(n), q)
352 idiag = this%dis%con%ia(n)
353 flowja(idiag) = flowja(idiag) + this%qsto(n)
364 integer(I4B),
intent(in) :: n
365 real(DP),
intent(in) :: stage_new
366 real(DP),
intent(in) :: stage_old
367 real(DP),
intent(in) :: dx
368 real(DP),
intent(inout) :: qsto
369 real(DP),
intent(inout),
optional :: derv
371 real(DP) :: depth_new
372 real(DP) :: depth_old
375 real(DP) :: cxs_area_new
376 real(DP) :: cxs_area_old
377 real(DP) :: cxs_area_eps
380 call this%dis%get_flow_width(n, n, 0, width_n, width_m)
381 depth_new = stage_new - this%dis%bot(n)
382 depth_old = stage_old - this%dis%bot(n)
383 cxs_area_new = this%cxs%get_area(this%idcxs(n), width_n, depth_new)
384 cxs_area_old = this%cxs%get_area(this%idcxs(n), width_n, depth_old)
385 qsto = (cxs_area_new - cxs_area_old) * dx /
delt
386 if (
present(derv))
then
388 cxs_area_eps = this%cxs%get_area(this%idcxs(n), width_n, depth_new + eps)
389 derv = (cxs_area_eps - cxs_area_new) * dx /
delt / eps
400 integer(I4B),
intent(in) :: n
401 real(DP),
intent(in) :: stage_new
402 real(DP),
intent(in) :: stage_old
403 real(DP),
intent(inout) :: qsto
404 real(DP),
intent(inout),
optional :: derv
407 real(DP) :: depth_new
408 real(DP) :: depth_old
409 real(DP) :: depth_eps
410 real(DP) :: volume_new
411 real(DP) :: volume_old
414 area = this%dis%get_area(n)
415 depth_new = stage_new - this%dis%bot(n)
416 depth_old = stage_old - this%dis%bot(n)
417 volume_new = area * depth_new
418 volume_old = area * depth_old
419 qsto = (volume_new - volume_old) /
delt
421 if (
present(derv))
then
423 depth_eps = depth_new + eps
424 derv = (depth_eps - depth_new) * area /
delt / eps
435 subroutine sto_bd(this, isuppress_output, model_budget)
441 integer(I4B),
intent(in) :: isuppress_output
442 type(
budgettype),
intent(inout) :: model_budget
449 call model_budget%addentry(rin, rout,
delt,
' STO', &
450 isuppress_output,
' STORAGE')
461 integer(I4B),
intent(in) :: icbcfl
462 integer(I4B),
intent(in) :: icbcun
464 integer(I4B) :: ibinun
465 integer(I4B) :: iprint, nvaluesp, nwidthp
466 character(len=1) :: cdatafmp =
' ', editdesc =
' '
470 if (this%ipakcb < 0)
then
472 elseif (this%ipakcb == 0)
then
477 if (icbcfl == 0) ibinun = 0
480 if (ibinun /= 0)
then
485 call this%dis%record_array(this%qsto, this%iout, iprint, -ibinun, &
486 budtxt(1), cdatafmp, nvaluesp, &
487 nwidthp, editdesc, dinact)
503 if (this%inunit > 0)
then
507 nullify (this%storage)
513 call this%NumericalPackageType%da()
529 call this%NumericalPackageType%allocate_scalars()
548 integer(I4B),
intent(in) :: nodes
553 call mem_allocate(this%qsto, nodes,
'STRGSS', this%memoryPath)
556 if (this%inunit > 0)
then
557 call mem_setptr(this%iper,
'IPER', this%input_mempath)
558 call mem_setptr(this%storage,
'STORAGE', this%input_mempath)
584 call mem_set_value(this%ipakcb,
'IPAKCB', this%input_mempath, found%ipakcb)
586 if (found%ipakcb)
then
591 call this%log_options(found)
608 character(len=*),
parameter :: fmtisvflow = &
609 "(4x,'CELL-BY-CELL FLOW INFORMATION WILL BE SAVED TO BINARY FILE &
610 &WHENEVER ICBCFL IS NOT ZERO.')"
612 write (this%iout,
'(1x,a)')
'PROCESSING STORAGE OPTIONS'
614 if (found%ipakcb)
then
615 write (this%iout, fmtisvflow)
618 write (this%iout,
'(1x,a)')
'END OF STORAGE OPTIONS'
633 character(len=24),
dimension(1) :: aname
634 integer(I4B),
dimension(:),
pointer,
contiguous :: map
638 data aname(1)/
' XXX'/
642 if (this%dis%nodes < this%dis%nodesuser) map => this%dis%nodeuser
645 write (this%iout,
'(1x,a)')
'PROCESSING GRIDDATA'
646 write (this%iout,
'(1x,a)')
'END PROCESSING GRIDDATA'
657 character(len=LENMEMPATH) :: dfw_mem_path
660 call mem_setptr(this%idcxs,
'IDCXS', dfw_mem_path)
668 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.