MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
budgettermmodule Module Reference

Data Types

type  budgettermtype

Functions/Subroutines

subroutine initialize (this, flowtype, text1id1, text2id1, text1id2, text2id2, maxlist, olconv1, olconv2, naux, auxtxt, ordered_id1)
 Initialize the budget term.
subroutine allocate_arrays (this)
 Allocate budget term arrays.
subroutine deallocate_arrays (this)
 Deallocate budget term arrays.
subroutine reset (this, nlist)
 reset the budget term and counter so terms can be updated
subroutine update_term (this, id1, id2, flow, auxvar)
 replace the terms in position thisicounter for id1, id2, flow, and aux
subroutine accumulate_flow (this, ratin, ratout)
 Calculate ratin and ratout for all the flow terms.
subroutine save_flows (this, dis, ibinun, kstp, kper, delt, pertim, totim, iout)
 Write flows to a binary file.
integer(i4b) function get_nlist (this)
 Get the number of entries for the stress period.
character(len=lenbudtxt) function get_flowtype (this)
 Get the flowtype for the budget term.
integer(i4b) function get_id1 (this, icount)
 Get id1(icount) for the budget term.
integer(i4b) function get_id2 (this, icount)
 Get id2(icount) for the budget term.
real(dp) function get_flow (this, icount)
 Get flow(icount) for the budget term.
subroutine read_flows (this, dis, ibinun, kstp, kper, delt, pertim, totim)
 Read flows from a binary file.
subroutine fill_from_bfr (this, bfr, dis)
 Copy the flow from the binary file reader into this budterm.

Function/Subroutine Documentation

◆ accumulate_flow()

subroutine budgettermmodule::accumulate_flow ( class(budgettermtype) this,
real(dp), intent(inout) ratin,
real(dp), intent(inout) ratout )

Definition at line 153 of file BudgetTerm.f90.

154 ! -- dummy
155 class(BudgetTermType) :: this
156 real(DP), intent(inout) :: ratin
157 real(DP), intent(inout) :: ratout
158 ! -- local
159 integer(I4B) :: i
160 real(DP) :: q
161 !
162 ratin = dzero
163 ratout = dzero
164 do i = 1, this%nlist
165 q = this%flow(i)
166 if (q < dzero) then
167 ratout = ratout - q
168 else
169 ratin = ratin + q
170 end if
171 end do
172 !

◆ allocate_arrays()

subroutine budgettermmodule::allocate_arrays ( class(budgettermtype) this)

Definition at line 95 of file BudgetTerm.f90.

96 ! -- dummy
97 class(BudgetTermType) :: this
98 !
99 allocate (this%id1(this%maxlist))
100 allocate (this%id2(this%maxlist))
101 allocate (this%flow(this%maxlist))
102 allocate (this%auxvar(this%naux, this%maxlist))
103 allocate (this%auxtxt(this%naux))
104 !

◆ deallocate_arrays()

subroutine budgettermmodule::deallocate_arrays ( class(budgettermtype) this)

Definition at line 109 of file BudgetTerm.f90.

110 ! -- dummy
111 class(BudgetTermType) :: this
112 !
113 deallocate (this%id1)
114 deallocate (this%id2)
115 deallocate (this%flow)
116 deallocate (this%auxvar)
117 deallocate (this%auxtxt)

◆ fill_from_bfr()

subroutine budgettermmodule::fill_from_bfr ( class(budgettermtype) this,
type(budgetfilereadertype) bfr,
class(disbasetype), intent(in) dis )

Definition at line 364 of file BudgetTerm.f90.

365 ! -- modules
367 ! -- dummy
368 class(BudgetTermType) :: this
369 type(BudgetFileReaderType) :: bfr
370 class(DisBaseType), intent(in) :: dis
371 ! -- local
372 integer(I4B) :: i
373 integer(I4B) :: n1
374 integer(I4B) :: n2
375 real(DP) :: q
376 !
377 select type (h => bfr%header)
378 type is (budgetfileheadertype)
379 this%flowtype = h%budtxt
380 this%text1id1 = h%srcmodelname
381 this%text2id1 = h%srcpackagename
382 this%text1id2 = h%dstmodelname
383 this%text2id2 = h%dstpackagename
384 this%naux = h%naux
385 !
386 if (.not. associated(this%auxtxt)) then
387 allocate (this%auxtxt(this%naux))
388 else
389 if (size(this%auxtxt) /= this%naux) then
390 deallocate (this%auxtxt)
391 allocate (this%auxtxt(this%naux))
392 end if
393 end if
394 !
395 if (this%naux > 0) this%auxtxt(:) = h%auxtxt(:)
396 this%nlist = h%nlist
397 end select
398 if (.not. associated(this%id1)) then
399 this%maxlist = this%nlist
400 allocate (this%id1(this%maxlist))
401 allocate (this%id2(this%maxlist))
402 allocate (this%flow(this%maxlist))
403 allocate (this%auxvar(this%naux, this%maxlist))
404 else
405 if (this%nlist > this%maxlist) then
406 this%maxlist = this%nlist
407 deallocate (this%id1)
408 deallocate (this%id2)
409 deallocate (this%flow)
410 deallocate (this%auxvar)
411 allocate (this%id1(this%maxlist))
412 allocate (this%id2(this%maxlist))
413 allocate (this%flow(this%maxlist))
414 allocate (this%auxvar(this%naux, this%maxlist))
415 end if
416 end if
417 !
418 do i = 1, this%nlist
419 n1 = bfr%nodesrc(i)
420 n2 = bfr%nodedst(i)
421 q = bfr%flow(i)
422 this%auxvar(:, i) = bfr%auxvar(:, i)
423 if (this%olconv1) n1 = dis%get_nodenumber(n1, 0)
424 if (this%olconv2) n2 = dis%get_nodenumber(n2, 0)
425 this%id1(i) = n1
426 this%id2(i) = n2
427 this%flow(i) = q
428 end do
429 !

◆ get_flow()

real(dp) function budgettermmodule::get_flow ( class(budgettermtype) this,
integer(i4b), intent(in) icount )

Definition at line 279 of file BudgetTerm.f90.

280 ! -- return
281 real(DP) :: flow
282 ! -- dummy
283 class(BudgetTermType) :: this
284 integer(I4B), intent(in) :: icount
285 !
286 flow = this%flow(icount)
287 !

◆ get_flowtype()

character(len=lenbudtxt) function budgettermmodule::get_flowtype ( class(budgettermtype) this)

Definition at line 241 of file BudgetTerm.f90.

242 ! -- dummy
243 class(BudgetTermType) :: this
244 ! -- return
245 character(len=LENBUDTXT) :: flowtype
246 !
247 flowtype = this%flowtype
248 !

◆ get_id1()

integer(i4b) function budgettermmodule::get_id1 ( class(budgettermtype) this,
integer(i4b), intent(in) icount )

Definition at line 253 of file BudgetTerm.f90.

254 ! -- dummy
255 class(BudgetTermType) :: this
256 integer(I4B), intent(in) :: icount
257 ! -- return
258 integer(I4B) :: id1
259 !
260 id1 = this%id1(icount)
261 !

◆ get_id2()

integer(i4b) function budgettermmodule::get_id2 ( class(budgettermtype) this,
integer(i4b), intent(in) icount )

Definition at line 266 of file BudgetTerm.f90.

267 ! -- return
268 integer(I4B) :: id2
269 ! -- dummy
270 class(BudgetTermType) :: this
271 integer(I4B), intent(in) :: icount
272 !
273 id2 = this%id2(icount)
274 !

◆ get_nlist()

integer(i4b) function budgettermmodule::get_nlist ( class(budgettermtype) this)

Definition at line 229 of file BudgetTerm.f90.

230 ! -- dummy
231 class(BudgetTermType) :: this
232 ! -- return
233 integer(I4B) :: nlist
234 !
235 nlist = this%nlist
236 !

◆ initialize()

subroutine budgettermmodule::initialize ( class(budgettermtype) this,
character(len=lenbudtxt), intent(in) flowtype,
character(len=lenbudtxt), intent(in) text1id1,
character(len=lenbudtxt), intent(in) text2id1,
character(len=lenbudtxt), intent(in) text1id2,
character(len=lenbudtxt), intent(in) text2id2,
integer(i4b), intent(in) maxlist,
logical, intent(in) olconv1,
logical, intent(in) olconv2,
integer(i4b), intent(in) naux,
character(len=lenbudtxt), dimension(:), intent(in), optional auxtxt,
logical, intent(in), optional ordered_id1 )

Definition at line 59 of file BudgetTerm.f90.

62 ! -- dummy
63 class(BudgetTermType) :: this
64 character(len=LENBUDTXT), intent(in) :: flowtype
65 character(len=LENBUDTXT), intent(in) :: text1id1
66 character(len=LENBUDTXT), intent(in) :: text2id1
67 character(len=LENBUDTXT), intent(in) :: text1id2
68 character(len=LENBUDTXT), intent(in) :: text2id2
69 integer(I4B), intent(in) :: maxlist
70 logical, intent(in) :: olconv1
71 logical, intent(in) :: olconv2
72 integer(I4B), intent(in) :: naux
73 character(len=LENBUDTXT), dimension(:), intent(in), optional :: auxtxt
74 logical, intent(in), optional :: ordered_id1
75 !
76 this%flowtype = flowtype
77 this%text1id1 = text1id1
78 this%text2id1 = text2id1
79 this%text1id2 = text1id2
80 this%text2id2 = text2id2
81 this%maxlist = maxlist
82 this%olconv1 = olconv1
83 this%olconv2 = olconv2
84 this%naux = naux
85 this%nlist = 0
86 call this%allocate_arrays()
87 if (present(auxtxt)) this%auxtxt(:) = auxtxt(1:naux)
88 this%ordered_id1 = .true.
89 if (present(ordered_id1)) this%ordered_id1 = ordered_id1
90 !

◆ read_flows()

subroutine budgettermmodule::read_flows ( class(budgettermtype) this,
class(disbasetype), intent(in) dis,
integer(i4b), intent(in) ibinun,
integer(i4b), intent(inout) kstp,
integer(i4b), intent(inout) kper,
real(dp), intent(inout) delt,
real(dp), intent(inout) pertim,
real(dp), intent(inout) totim )

Definition at line 292 of file BudgetTerm.f90.

293 ! -- dummy
294 class(BudgetTermType) :: this
295 class(DisBaseType), intent(in) :: dis
296 integer(I4B), intent(in) :: ibinun
297 integer(I4B), intent(inout) :: kstp
298 integer(I4B), intent(inout) :: kper
299 real(DP), intent(inout) :: delt
300 real(DP), intent(inout) :: pertim
301 real(DP), intent(inout) :: totim
302 ! -- local
303 integer(I4B) :: idum1, idum2, imeth
304 integer(I4B) :: i, j
305 integer(I4B) :: n1
306 integer(I4B) :: n2
307 real(DP) :: q
308 !
309 read (ibinun) kstp, kper, this%flowtype, this%nlist, idum1, idum2
310 read (ibinun) imeth, delt, pertim, totim
311 read (ibinun) this%text1id1
312 read (ibinun) this%text2id1
313 read (ibinun) this%text1id2
314 read (ibinun) this%text2id2
315 read (ibinun) this%naux
316 this%naux = this%naux - 1
317 if (.not. associated(this%auxtxt)) then
318 allocate (this%auxtxt(this%naux))
319 else
320 if (size(this%auxtxt) /= this%naux) then
321 deallocate (this%auxtxt)
322 allocate (this%auxtxt(this%naux))
323 end if
324 end if
325 !
326 if (this%naux > 0) read (ibinun) (this%auxtxt(j), j=1, this%naux)
327 read (ibinun) this%nlist
328 if (.not. associated(this%id1)) then
329 this%maxlist = this%nlist
330 allocate (this%id1(this%maxlist))
331 allocate (this%id2(this%maxlist))
332 allocate (this%flow(this%maxlist))
333 allocate (this%auxvar(this%naux, this%maxlist))
334 else
335 if (this%nlist > this%maxlist) then
336 this%maxlist = this%nlist
337 deallocate (this%id1)
338 deallocate (this%id2)
339 deallocate (this%flow)
340 deallocate (this%auxvar)
341 allocate (this%id1(this%maxlist))
342 allocate (this%id2(this%maxlist))
343 allocate (this%flow(this%maxlist))
344 allocate (this%auxvar(this%naux, this%maxlist))
345 end if
346 end if
347 !
348 do i = 1, this%nlist
349 read (ibinun) n1
350 read (ibinun) n2
351 read (ibinun) q
352 read (ibinun) (this%auxvar(j, i), j=1, this%naux)
353 if (this%olconv1) n1 = dis%get_nodenumber(n1, 0)
354 if (this%olconv2) n2 = dis%get_nodenumber(n2, 0)
355 this%id1(i) = n1
356 this%id2(i) = n2
357 this%flow(i) = q
358 end do
359 !

◆ reset()

subroutine budgettermmodule::reset ( class(budgettermtype) this,
integer(i4b), intent(in) nlist )

Definition at line 122 of file BudgetTerm.f90.

123 ! -- dummy
124 class(BudgetTermType) :: this
125 integer(I4B), intent(in) :: nlist
126 !
127 this%nlist = nlist
128 this%icounter = 1
129 !

◆ save_flows()

subroutine budgettermmodule::save_flows ( class(budgettermtype) this,
class(disbasetype), intent(in) dis,
integer(i4b), intent(in) ibinun,
integer(i4b), intent(in) kstp,
integer(i4b), intent(in) kper,
real(dp), intent(in) delt,
real(dp), intent(in) pertim,
real(dp), intent(in) totim,
integer(i4b), intent(in) iout )

Definition at line 177 of file BudgetTerm.f90.

179 ! -- dummy
180 class(BudgetTermType) :: this
181 class(DisBaseType), intent(in) :: dis
182 integer(I4B), intent(in) :: ibinun
183 integer(I4B), intent(in) :: kstp
184 integer(I4B), intent(in) :: kper
185 real(DP), intent(in) :: delt
186 real(DP), intent(in) :: pertim
187 real(DP), intent(in) :: totim
188 integer(I4B), intent(in) :: iout
189 ! -- local
190 integer(I4B) :: nlist
191 integer(I4B) :: i
192 integer(I4B) :: n1
193 integer(I4B) :: n2
194 real(DP) :: q
195 !
196 ! -- Count the size of the list and exclude ids less than or equal to zero
197 nlist = 0
198 do i = 1, this%nlist
199 n1 = this%id1(i)
200 n2 = this%id2(i)
201 if (n1 <= 0 .or. n2 <= 0) cycle
202 nlist = nlist + 1
203 end do
204 !
205 ! -- Write the header
206 call ubdsv06(kstp, kper, this%flowtype, &
207 this%text1id1, this%text2id1, &
208 this%text1id2, this%text2id2, &
209 ibinun, this%naux, this%auxtxt, &
210 nlist, 1, 1, nlist, &
211 iout, delt, pertim, totim)
212 !
213 ! -- Write each entry
214 do i = 1, this%nlist
215 q = this%flow(i)
216 n1 = this%id1(i)
217 n2 = this%id2(i)
218 if (n1 <= 0 .or. n2 <= 0) cycle
219 call dis%record_mf6_list_entry(ibinun, n1, n2, q, &
220 this%naux, this%auxvar(:, i), &
221 olconv=this%olconv1, &
222 olconv2=this%olconv2)
223 end do
224 !
Here is the call graph for this function:

◆ update_term()

subroutine budgettermmodule::update_term ( class(budgettermtype) this,
integer(i4b), intent(in) id1,
integer(i4b), intent(in) id2,
real(dp), intent(in) flow,
real(dp), dimension(:), intent(in), optional auxvar )

Definition at line 135 of file BudgetTerm.f90.

136 ! -- dummy
137 class(BudgetTermType) :: this
138 integer(I4B), intent(in) :: id1
139 integer(I4B), intent(in) :: id2
140 real(DP), intent(in) :: flow
141 real(DP), dimension(:), intent(in), optional :: auxvar
142 !
143 this%id1(this%icounter) = id1
144 this%id2(this%icounter) = id2
145 this%flow(this%icounter) = flow
146 if (present(auxvar)) this%auxvar(:, this%icounter) = auxvar(1:this%naux)
147 this%icounter = this%icounter + 1
148 !