26 character(len=LENBUDTXT) :: name
28 integer(I4B) :: nbudterm
31 real(dp),
dimension(:),
pointer :: xnew => null()
32 real(dp),
dimension(:),
pointer :: xold => null()
35 integer(I4B) :: iflowja
36 real(dp),
dimension(:),
pointer :: flowja => null()
40 real(dp),
dimension(:, :),
pointer :: qsto => null()
52 logical,
pointer :: add_cellids => null()
53 integer(I4B),
pointer :: icellid => null()
54 integer(I4B),
pointer :: nflowterms => null()
55 integer(I4B),
dimension(:),
pointer :: istart => null()
56 integer(I4B),
dimension(:),
pointer :: iflowterms => null()
85 character(len=*),
intent(in) :: name
105 bddim_opt, labeltitle_opt, bdzone_opt, &
109 integer(I4B),
intent(in) :: ncv
110 integer(I4B),
intent(in) :: nbudterm
111 integer(I4B),
intent(in) :: iflowja
112 integer(I4B),
intent(in) :: nsto
113 character(len=*),
optional :: bddim_opt
114 character(len=*),
optional :: labeltitle_opt
115 character(len=*),
optional :: bdzone_opt
116 integer(I4B),
intent(in),
optional :: ibudcsv
118 character(len=20) :: bdtype
119 character(len=5) :: bddim
120 character(len=16) :: labeltitle
121 character(len=20) :: bdzone
125 this%nbudterm = nbudterm
126 this%iflowja = iflowja
130 allocate (this%budterm(nbudterm))
136 if (
present(bddim_opt))
then
143 if (
present(bdzone_opt))
then
146 bdzone =
'ENTIRE MODEL'
150 if (
present(labeltitle_opt))
then
151 labeltitle = labeltitle_opt
153 labeltitle =
'PACKAGE NAME'
157 call this%budtable%budget_df(nbudterm, bdtype, bddim, labeltitle, bdzone)
160 if (
present(ibudcsv))
then
161 call this%budtable%set_ibudcsv(ibudcsv)
170 integer(I4B),
intent(in) :: iout
171 character(len=*),
intent(in),
optional :: cellids
173 character(len=LINELENGTH) :: title
174 character(len=LINELENGTH) :: text
175 character(len=LENBUDTXT) :: flowtype
176 character(len=LENBUDTXT) :: tag
177 character(len=LENBUDTXT) :: coupletype
179 logical :: add_cellids
180 integer(I4B) :: maxcol
186 if (
present(cellids))
then
190 add_cellids = .false.
194 allocate (this%add_cellids)
195 allocate (this%icellid)
196 allocate (this%nflowterms)
199 this%add_cellids = add_cellids
205 if (add_cellids)
then
208 do i = 1, this%nbudterm
210 flowtype = this%budterm(i)%get_flowtype()
211 if (trim(adjustl(flowtype)) ==
'FLOW-JA-FACE')
then
214 else if (trim(adjustl(flowtype)) /=
'AUXILIARY')
then
219 this%nflowterms = this%nflowterms + 1
220 if (add_cellids)
then
221 if (trim(adjustl(flowtype)) == trim(adjustl(coupletype)))
then
229 allocate (this%istart(this%nflowterms))
230 allocate (this%iflowterms(this%nflowterms))
233 title = trim(this%name)//
' PACKAGE - SUMMARY OF FLOWS FOR '// &
234 'EACH CONTROL VOLUME'
235 call table_cr(this%flowtab, this%name, title)
236 call this%flowtab%table_df(this%ncv, maxcol, iout, transient=.true.)
240 call this%flowtab%initialize_column(text, 10, alignment=
tabcenter)
241 if (add_cellids)
then
243 call this%flowtab%initialize_column(text, 20, alignment=
tableft)
246 do i = 1, this%nbudterm
248 flowtype = this%budterm(i)%get_flowtype()
249 tag = trim(adjustl(flowtype))
250 ipos = index(tag,
'-')
254 if (trim(adjustl(flowtype)) ==
'FLOW-JA-FACE')
then
257 call this%flowtab%initialize_column(text, 12, alignment=
tabcenter)
259 call this%flowtab%initialize_column(text, 12, alignment=
tabcenter)
260 else if (trim(adjustl(flowtype)) /=
'AUXILIARY')
then
262 call this%flowtab%initialize_column(tag, 12, alignment=
tabcenter)
265 this%iflowterms(idx) = i
270 call this%flowtab%initialize_column(text, 12, alignment=
tabcenter)
271 text =
'PERCENT DIFFERENCE'
272 call this%flowtab%initialize_column(text, 12, alignment=
tabcenter)
283 character(len=LENBUDTXT) :: flowtype
285 real(DP) :: ratin, ratout
288 call this%budtable%reset()
291 do i = 1, this%nbudterm
294 flowtype = this%budterm(i)%flowtype
295 select case (trim(adjustl(flowtype)))
296 case (
'FLOW-JA-FACE')
301 call this%budterm(i)%accumulate_flow(ratin, ratout)
304 call this%budtable%addentry(ratin, ratout,
delt, flowtype)
315 integer(I4B),
intent(in) :: kstp
316 integer(I4B),
intent(in) :: kper
317 character(len=20),
dimension(:),
optional :: cellidstr
319 character(len=LENBUDTXT) :: flowtype
320 character(len=20) :: cellid
321 integer(I4B) :: nlist
339 do j = 1, this%nflowterms
344 call this%flowtab%set_kstpkper(kstp, kper)
348 call this%flowtab%add_term(icv)
355 if (this%add_cellids)
then
356 if (
present(cellidstr))
then
362 cellid = cellidstr(icv)
368 idx = this%iflowterms(j)
370 id2 = this%budterm(idx)%get_id2(i)
372 call dis%noder_to_string(id2, cellid)
377 call this%flowtab%add_term(cellid)
381 do j = 1, this%nflowterms
390 idx = this%iflowterms(j)
391 flowtype = this%budterm(idx)%get_flowtype()
392 nlist = this%budterm(idx)%get_nlist()
396 colterm:
do i = this%istart(j), nlist
397 id1 = this%budterm(idx)%get_id1(i)
398 if (this%budterm(idx)%ordered_id1)
then
411 v = this%budterm(idx)%get_flow(i)
413 if (trim(adjustl(flowtype)) ==
'FLOW-JA-FACE')
then
415 qoutflow = qoutflow + v
417 qinflow = qinflow + v
431 if (trim(adjustl(flowtype)) ==
'FLOW-JA-FACE')
then
432 call this%flowtab%add_term(qinflow)
433 call this%flowtab%add_term(qoutflow)
435 call this%flowtab%add_term(q)
441 qavg =
dhalf * (qin - qout)
443 if (qavg >
dzero)
then
446 call this%flowtab%add_term(qerr)
447 call this%flowtab%add_term(qpd)
456 integer(I4B),
intent(in) :: kstp
457 integer(I4B),
intent(in) :: kper
458 integer(I4B),
intent(in) :: iout
459 integer(I4B),
intent(in) :: ibudfl
460 real(DP),
intent(in) :: totim
461 real(DP),
intent(in) :: delt
464 call this%budtable%finalize_step(delt)
465 if (ibudfl /= 0)
then
466 call this%budtable%budget_ot(kstp, kper, iout)
468 call this%budtable%writecsv(totim)
478 integer(I4B),
intent(in) :: ibinun
479 integer(I4B),
intent(in) :: kstp
480 integer(I4B),
intent(in) :: kper
481 real(DP),
intent(in) :: delt
482 real(DP),
intent(in) :: pertim
483 real(DP),
intent(in) :: totim
484 integer(I4B),
intent(in) :: iout
489 do i = 1, this%nbudterm
490 call this%budterm(i)%save_flows(dis, ibinun, kstp, kper, delt, &
501 integer(I4B),
intent(in) :: ibinun
511 do i = 1, this%nbudterm
512 call this%budterm(i)%read_flows(dis, ibinun, kstp, kper, delt, &
526 do i = 1, this%nbudterm
527 call this%budterm(i)%deallocate_arrays()
531 if (
associated(this%flowtab))
then
532 deallocate (this%add_cellids)
533 deallocate (this%icellid)
534 deallocate (this%nflowterms)
535 deallocate (this%istart)
536 deallocate (this%iflowterms)
537 call this%flowtab%table_da()
538 deallocate (this%flowtab)
539 nullify (this%flowtab)
543 if (
associated(this%budtable))
then
544 call this%budtable%budget_da()
545 deallocate (this%budtable)
546 nullify (this%budtable)
555 character(len=*),
intent(in) :: name
556 integer(I4B),
intent(in) :: ibinun
557 integer(I4B),
intent(in) :: iout
558 character(len=16),
dimension(:),
optional :: colconv1
559 character(len=16),
dimension(:),
optional :: colconv2
561 integer(I4B) :: ncv, nbudterm
562 integer(I4B) :: iflowja, nsto
569 call this%bfr_init(ibinun, ncv, nbudterm, iout)
575 call this%budgetobject_df(ncv, nbudterm, iflowja, nsto)
579 if (
present(colconv1))
then
581 do j = 1,
size(colconv1)
582 if (colconv1(j) == adjustl(this%bfr%budtxtarray(i)))
then
583 this%budterm(i)%olconv1 = .true.
589 if (
present(colconv2))
then
591 do j = 1,
size(colconv2)
592 if (colconv2(j) == adjustl(this%bfr%budtxtarray(i)))
then
593 this%budterm(i)%olconv2 = .true.
603 subroutine bfr_init(this, ibinun, ncv, nbudterm, iout)
606 integer(I4B),
intent(in) :: ibinun
607 integer(I4B),
intent(inout) :: ncv
608 integer(I4B),
intent(inout) :: nbudterm
609 integer(I4B),
intent(in) :: iout
613 call this%bfr%initialize(ibinun, iout, ncv)
614 nbudterm = this%bfr%nbudterms
626 integer(I4B),
intent(in) :: iout
630 character(len=*),
parameter :: fmtkstpkper = &
631 &
"(1x,/1x, a, ' READING BUDGET TERMS FOR KSTP ', i0, ' KPER ', i0)"
632 character(len=*),
parameter :: fmtbudkstpkper = &
633 "(1x,/1x, a, ' SETTING BUDGET TERMS FOR KSTP ', i0, ' AND KPER ', &
634 &i0, ' TO BUDGET FILE TERMS FROM KSTP ', i0, ' AND KPER ', i0)"
644 if (this%bfr%endoffile)
then
647 if (this%bfr%kpernext ==
kper + 1 .and. this%bfr%kstpnext == 1) &
657 write (iout, fmtkstpkper) this%name,
kstp,
kper
660 call this%fill_from_bfr(dis, iout)
663 write (iout, fmtbudkstpkper) trim(this%name),
kstp,
kper, &
664 this%bfr%kstp, this%bfr%kper
674 integer(I4B),
intent(in) :: iout
680 do i = 1, this%nbudterm
681 call this%bfr%read_record(success, iout)
682 call this%budterm(i)%fill_from_bfr(this%bfr, dis)
This module contains the BudgetModule.
subroutine, public budget_cr(this, name_model)
@ brief Create a new budget object
subroutine accumulate_terms(this)
Add up accumulators and submit to budget table.
subroutine, public budgetobject_cr(this, name)
Create a new budget object.
subroutine save_flows(this, dis, ibinun, kstp, kper, delt, pertim, totim, iout)
Write the budget table.
subroutine bfr_advance(this, dis, iout)
Advance the binary file readers for setting the budget terms of the next time step.
subroutine flowtable_df(this, iout, cellids)
Define the new flow table object.
subroutine write_budtable(this, kstp, kper, iout, ibudfl, totim, delt)
Write the budget table.
subroutine write_flowtable(this, dis, kstp, kper, cellidstr)
Write the flow table for each advanced package control volume.
subroutine budgetobject_df(this, ncv, nbudterm, iflowja, nsto, bddim_opt, labeltitle_opt, bdzone_opt, ibudcsv)
Define the new budget object.
subroutine bfr_init(this, ibinun, ncv, nbudterm, iout)
Initialize the budget file reader.
subroutine, public budgetobject_cr_bfr(this, name, ibinun, iout, colconv1, colconv2)
Create a new budget object from a binary flow file.
subroutine budgetobject_da(this)
Deallocate.
subroutine read_flows(this, dis, ibinun)
Read from a binary file into this BudgetObjectType.
subroutine fill_from_bfr(this, dis, iout)
Copy the information from the binary file into budterms.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
@ tabcenter
centered table column
@ tabright
right justified table column
@ tableft
left justified table column
@ tabucstring
upper case string table data
@ tabstring
string table data
@ tabinteger
integer table data
real(dp), parameter dhundred
real constant 100
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
This module defines variable data types.
subroutine, public table_cr(this, name, title)
integer(i4b), pointer, public kstp
current time step number
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.