MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
gwt-sft.f90
Go to the documentation of this file.
1! -- Stream Transport Module
2! -- todo: what to do about reactions in stream? Decay?
3! -- todo: save the sft concentration into the sfr aux variable?
4! -- todo: calculate the sfr DENSE aux variable using concentration?
5!
6! SFR flows (sfrbudptr) index var SFT term Transport Type
7!---------------------------------------------------------------------------------
8
9! -- terms from SFR that will be handled by parent APT Package
10! FLOW-JA-FACE idxbudfjf FLOW-JA-FACE cv2cv
11! GWF (aux FLOW-AREA) idxbudgwf GWF cv2gwf
12! STORAGE (aux VOLUME) idxbudsto none used for cv volumes
13! FROM-MVR idxbudfmvr FROM-MVR q * cext = this%qfrommvr(:)
14! TO-MVR idxbudtmvr TO-MVR q * cfeat
15
16! -- SFR terms
17! RAINFALL idxbudrain RAINFALL q * crain
18! EVAPORATION idxbudevap EVAPORATION cfeat<cevap: q*cfeat, else: q*cevap
19! RUNOFF idxbudroff RUNOFF q * croff
20! EXT-INFLOW idxbudiflw EXT-INFLOW q * ciflw
21! EXT-OUTFLOW idxbudoutf EXT-OUTFLOW q * cfeat
22
23! -- terms from a flow file that should be skipped
24! CONSTANT none none none
25! AUXILIARY none none none
26
27! -- terms that are written to the transport budget file
28! none none STORAGE (aux MASS) dM/dt
29! none none AUXILIARY none
30! none none CONSTANT accumulate
31!
32!
34
35 use kindmodule, only: dp, i4b
41 use tspfmimodule, only: tspfmitype
42 use sfrmodule, only: sfrtype
43 use observemodule, only: observetype
47
48 implicit none
49
50 public sft_create
51
52 character(len=*), parameter :: ftype = 'SFT'
53 character(len=*), parameter :: flowtype = 'SFR'
54 character(len=16) :: text = ' SFT'
55
56 type, extends(tspapttype) :: gwtsfttype
57
58 integer(I4B), pointer :: idxbudrain => null() !< index of rainfall terms in flowbudptr
59 integer(I4B), pointer :: idxbudevap => null() !< index of evaporation terms in flowbudptr
60 integer(I4B), pointer :: idxbudroff => null() !< index of runoff terms in flowbudptr
61 integer(I4B), pointer :: idxbudiflw => null() !< index of inflow terms in flowbudptr
62 integer(I4B), pointer :: idxbudoutf => null() !< index of outflow terms in flowbudptr
63
64 real(dp), dimension(:), pointer, contiguous :: concrain => null() !< rainfall concentration
65 real(dp), dimension(:), pointer, contiguous :: concevap => null() !< evaporation concentration
66 real(dp), dimension(:), pointer, contiguous :: concroff => null() !< runoff concentration
67 real(dp), dimension(:), pointer, contiguous :: conciflw => null() !< inflow concentration
68
69 real(dp), dimension(:), pointer, contiguous :: vnew => null() !< current reach volume
70 real(dp), dimension(:), pointer, contiguous :: vold => null() !< previous reach volume
71
72 contains
73
74 procedure :: bnd_ad => sft_ad
75 procedure :: bnd_da => sft_da
76 procedure :: allocate_scalars
82 procedure :: pak_solve => sft_solve
86 procedure :: sft_rain_term
87 procedure :: sft_evap_term
88 procedure :: sft_roff_term
89 procedure :: sft_iflw_term
90 procedure :: sft_outf_term
91 procedure :: pak_df_obs => sft_df_obs
92 procedure :: pak_rp_obs => sft_rp_obs
93 procedure :: pak_bd_obs => sft_bd_obs
95
96 end type gwtsfttype
97
98contains
99
100 !> @brief Create a new sft package
101 !<
102 subroutine sft_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
103 mempath, fmi, eqnsclfac, dvt, dvu, dvua)
104 ! -- dummy
105 class(bndtype), pointer :: packobj
106 integer(I4B), intent(in) :: id
107 integer(I4B), intent(in) :: ibcnum
108 integer(I4B), intent(in) :: inunit
109 integer(I4B), intent(in) :: iout
110 character(len=*), intent(in) :: namemodel
111 character(len=*), intent(in) :: pakname
112 character(len=*), intent(in) :: mempath !< input memory path
113 type(tspfmitype), pointer :: fmi
114 real(dp), intent(in), pointer :: eqnsclfac !< governing equation scale factor
115 character(len=*), intent(in) :: dvt !< For GWT, set to "CONCENTRATION" in TspAptType
116 character(len=*), intent(in) :: dvu !< For GWT, set to "mass" in TspAptType
117 character(len=*), intent(in) :: dvua !< For GWT, set to "M" in TspAptType
118 ! -- local
119 type(gwtsfttype), pointer :: sftobj
120 !
121 ! -- allocate the object and assign values to object variables
122 allocate (sftobj)
123 packobj => sftobj
124 !
125 ! -- create name and memory path
126 call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
127 packobj%text = text
128 !
129 ! -- allocate scalars
130 call sftobj%allocate_scalars()
131 !
132 ! -- initialize package
133 call packobj%pack_initialize()
134 !
135 packobj%inunit = inunit
136 packobj%iout = iout
137 packobj%id = id
138 packobj%ibcnum = ibcnum
139 packobj%ncolbnd = 1
140 packobj%iscloc = 1
141 packobj%isadvpak = 1
142 !
143 ! -- Store pointer to flow model interface. When the GwfGwt exchange is
144 ! created, it sets fmi%bndlist so that the GWT model has access to all
145 ! the flow packages
146 sftobj%fmi => fmi
147 !
148 ! -- Store pointer to governing equation scale factor
149 sftobj%eqnsclfac => eqnsclfac
150 !
151 ! -- Set labels that will be used in generalized APT class
152 sftobj%depvartype = dvt
153 sftobj%depvarunit = dvu
154 sftobj%depvarunitabbrev = dvua
155 end subroutine sft_create
156
157 !> @brief Find corresponding sft package
158 !<
159 subroutine find_sft_package(this)
160 ! -- modules
162 ! -- dummy
163 class(gwtsfttype) :: this
164 ! -- local
165 character(len=LINELENGTH) :: errmsg
166 class(bndtype), pointer :: packobj
167 integer(I4B) :: ip, icount
168 integer(I4B) :: nbudterm
169 logical :: found
170 !
171 ! -- Initialize found to false, and error later if flow package cannot
172 ! be found
173 found = .false.
174 !
175 ! -- If user is specifying flows in a binary budget file, then set up
176 ! the budget file reader, otherwise set a pointer to the flow package
177 ! budobj
178 if (this%fmi%flows_from_file) then
179 call this%fmi%set_aptbudobj_pointer(this%flowpackagename, this%flowbudptr)
180 if (associated(this%flowbudptr)) found = .true.
181 !
182 else
183 if (associated(this%fmi%gwfbndlist)) then
184 ! -- Look through gwfbndlist for a flow package with the same name as
185 ! this transport package name
186 do ip = 1, this%fmi%gwfbndlist%Count()
187 packobj => getbndfromlist(this%fmi%gwfbndlist, ip)
188 if (packobj%packName == this%flowpackagename) then
189 found = .true.
190 !
191 ! -- store BndType pointer to packobj, and then
192 ! use the select type to point to the budobj in flow package
193 this%flowpackagebnd => packobj
194 select type (packobj)
195 type is (sfrtype)
196 this%flowbudptr => packobj%budobj
197 end select
198 end if
199 if (found) exit
200 end do
201 end if
202 end if
203 !
204 ! -- error if flow package not found
205 if (.not. found) then
206 write (errmsg, '(a)') 'Could not find flow package with name '&
207 &//trim(adjustl(this%flowpackagename))//'.'
208 call store_error(errmsg)
209 call store_error_filename(this%input_fname)
210 end if
211 !
212 ! -- allocate space for idxbudssm, which indicates whether this is a
213 ! special budget term or one that is a general source and sink
214 nbudterm = this%flowbudptr%nbudterm
215 call mem_allocate(this%idxbudssm, nbudterm, 'IDXBUDSSM', this%memoryPath)
216 !
217 ! -- Process budget terms and identify special budget terms
218 write (this%iout, '(/, a, a)') &
219 'PROCESSING '//ftype//' INFORMATION FOR ', this%packName
220 write (this%iout, '(a)') ' IDENTIFYING FLOW TERMS IN '//flowtype//' PACKAGE'
221 write (this%iout, '(a, i0)') &
222 ' NUMBER OF '//flowtype//' = ', this%flowbudptr%ncv
223 icount = 1
224 do ip = 1, this%flowbudptr%nbudterm
225 select case (trim(adjustl(this%flowbudptr%budterm(ip)%flowtype)))
226 case ('FLOW-JA-FACE')
227 this%idxbudfjf = ip
228 this%idxbudssm(ip) = 0
229 case ('GWF')
230 this%idxbudgwf = ip
231 this%idxbudssm(ip) = 0
232 case ('STORAGE')
233 this%idxbudsto = ip
234 this%idxbudssm(ip) = 0
235 case ('RAINFALL')
236 this%idxbudrain = ip
237 this%idxbudssm(ip) = 0
238 case ('EVAPORATION')
239 this%idxbudevap = ip
240 this%idxbudssm(ip) = 0
241 case ('RUNOFF')
242 this%idxbudroff = ip
243 this%idxbudssm(ip) = 0
244 case ('EXT-INFLOW')
245 this%idxbudiflw = ip
246 this%idxbudssm(ip) = 0
247 case ('EXT-OUTFLOW')
248 this%idxbudoutf = ip
249 this%idxbudssm(ip) = 0
250 case ('TO-MVR')
251 this%idxbudtmvr = ip
252 this%idxbudssm(ip) = 0
253 case ('FROM-MVR')
254 this%idxbudfmvr = ip
255 this%idxbudssm(ip) = 0
256 case ('AUXILIARY')
257 this%idxbudaux = ip
258 this%idxbudssm(ip) = 0
259 case default
260 !
261 ! -- set idxbudssm equal to a column index for where the concentrations
262 ! are stored in the concbud(nbudssm, ncv) array
263 this%idxbudssm(ip) = icount
264 icount = icount + 1
265 end select
266 write (this%iout, '(a, i0, " = ", a,/, a, i0)') &
267 ' TERM ', ip, trim(adjustl(this%flowbudptr%budterm(ip)%flowtype)), &
268 ' MAX NO. OF ENTRIES = ', this%flowbudptr%budterm(ip)%maxlist
269 end do
270 write (this%iout, '(a, //)') 'DONE PROCESSING '//ftype//' INFORMATION'
271 end subroutine find_sft_package
272
273 !> @brief Value for a package-specific PERIOD setting
274 !!
275 !! Already resolved by the input context; this only supplies it for
276 !! the shared apt_rp table echo.
277 !<
278 function sft_setting_value(this, itemno, key) result(val)
279 ! -- dummy
280 class(gwtsfttype), intent(inout) :: this
281 integer(I4B), intent(in) :: itemno
282 character(len=*), intent(in) :: key
283 real(dp) :: val
284 !
285 val = dzero
286 select case (trim(key))
287 case ('RAINFALL')
288 val = this%concrain(itemno)
289 case ('EVAPORATION')
290 val = this%concevap(itemno)
291 case ('RUNOFF')
292 val = this%concroff(itemno)
293 case ('INFLOW')
294 val = this%conciflw(itemno)
295 end select
296 end function sft_setting_value
297
298 !> @brief Add matrix terms related to SFT
299 !!
300 !! This will be called from TspAptType%apt_fc_expanded()
301 !! in order to add matrix terms specifically for SFT
302 !<
303 subroutine sft_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
304 ! -- modules
305 ! -- dummy
306 class(gwtsfttype) :: this
307 real(DP), dimension(:), intent(inout) :: rhs
308 integer(I4B), dimension(:), intent(in) :: ia
309 integer(I4B), dimension(:), intent(in) :: idxglo
310 class(matrixbasetype), pointer :: matrix_sln
311 ! -- local
312 integer(I4B) :: j, n1, n2
313 integer(I4B) :: iloc
314 integer(I4B) :: iposd
315 real(DP) :: rrate
316 real(DP) :: rhsval
317 real(DP) :: hcofval
318 !
319 ! -- add rainfall contribution
320 if (this%idxbudrain /= 0) then
321 do j = 1, this%flowbudptr%budterm(this%idxbudrain)%nlist
322 call this%sft_rain_term(j, n1, n2, rrate, rhsval, hcofval)
323 iloc = this%idxlocnode(n1)
324 iposd = this%idxpakdiag(n1)
325 call matrix_sln%add_value_pos(iposd, hcofval)
326 rhs(iloc) = rhs(iloc) + rhsval
327 end do
328 end if
329 !
330 ! -- add evaporation contribution
331 if (this%idxbudevap /= 0) then
332 do j = 1, this%flowbudptr%budterm(this%idxbudevap)%nlist
333 call this%sft_evap_term(j, n1, n2, rrate, rhsval, hcofval)
334 iloc = this%idxlocnode(n1)
335 iposd = this%idxpakdiag(n1)
336 call matrix_sln%add_value_pos(iposd, hcofval)
337 rhs(iloc) = rhs(iloc) + rhsval
338 end do
339 end if
340 !
341 ! -- add runoff contribution
342 if (this%idxbudroff /= 0) then
343 do j = 1, this%flowbudptr%budterm(this%idxbudroff)%nlist
344 call this%sft_roff_term(j, n1, n2, rrate, rhsval, hcofval)
345 iloc = this%idxlocnode(n1)
346 iposd = this%idxpakdiag(n1)
347 call matrix_sln%add_value_pos(iposd, hcofval)
348 rhs(iloc) = rhs(iloc) + rhsval
349 end do
350 end if
351 !
352 ! -- add inflow contribution
353 if (this%idxbudiflw /= 0) then
354 do j = 1, this%flowbudptr%budterm(this%idxbudiflw)%nlist
355 call this%sft_iflw_term(j, n1, n2, rrate, rhsval, hcofval)
356 iloc = this%idxlocnode(n1)
357 iposd = this%idxpakdiag(n1)
358 call matrix_sln%add_value_pos(iposd, hcofval)
359 rhs(iloc) = rhs(iloc) + rhsval
360 end do
361 end if
362 !
363 ! -- add outflow contribution
364 if (this%idxbudoutf /= 0) then
365 do j = 1, this%flowbudptr%budterm(this%idxbudoutf)%nlist
366 call this%sft_outf_term(j, n1, n2, rrate, rhsval, hcofval)
367 iloc = this%idxlocnode(n1)
368 iposd = this%idxpakdiag(n1)
369 call matrix_sln%add_value_pos(iposd, hcofval)
370 rhs(iloc) = rhs(iloc) + rhsval
371 end do
372 end if
373 end subroutine sft_fc_expanded
374
375 !> @brief Add terms specific to sft to the explicit sft solve
376 !<
377 subroutine sft_solve(this)
378 ! -- dummy
379 class(gwtsfttype) :: this
380 ! -- local
381 integer(I4B) :: j
382 integer(I4B) :: n1, n2
383 real(DP) :: rrate
384 !
385 ! -- add rainfall contribution
386 if (this%idxbudrain /= 0) then
387 do j = 1, this%flowbudptr%budterm(this%idxbudrain)%nlist
388 call this%sft_rain_term(j, n1, n2, rrate)
389 this%dbuff(n1) = this%dbuff(n1) + rrate
390 end do
391 end if
392 !
393 ! -- add evaporation contribution
394 if (this%idxbudevap /= 0) then
395 do j = 1, this%flowbudptr%budterm(this%idxbudevap)%nlist
396 call this%sft_evap_term(j, n1, n2, rrate)
397 this%dbuff(n1) = this%dbuff(n1) + rrate
398 end do
399 end if
400 !
401 ! -- add runoff contribution
402 if (this%idxbudroff /= 0) then
403 do j = 1, this%flowbudptr%budterm(this%idxbudroff)%nlist
404 call this%sft_roff_term(j, n1, n2, rrate)
405 this%dbuff(n1) = this%dbuff(n1) + rrate
406 end do
407 end if
408 !
409 ! -- add inflow contribution
410 if (this%idxbudiflw /= 0) then
411 do j = 1, this%flowbudptr%budterm(this%idxbudiflw)%nlist
412 call this%sft_iflw_term(j, n1, n2, rrate)
413 this%dbuff(n1) = this%dbuff(n1) + rrate
414 end do
415 end if
416 !
417 ! -- add outflow contribution
418 if (this%idxbudoutf /= 0) then
419 do j = 1, this%flowbudptr%budterm(this%idxbudoutf)%nlist
420 call this%sft_outf_term(j, n1, n2, rrate)
421 this%dbuff(n1) = this%dbuff(n1) + rrate
422 end do
423 end if
424 end subroutine sft_solve
425
426 !> @brief Function to return the number of budget terms just for this package.
427 !!
428 !! This overrides a function in the parent class.
429 !<
430 function sft_get_nbudterms(this) result(nbudterms)
431 ! -- modules
432 ! -- dummy
433 class(gwtsfttype) :: this
434 ! -- return
435 integer(I4B) :: nbudterms
436 ! -- local
437 !
438 ! -- Number of budget terms is 5
439 nbudterms = 5
440 end function sft_get_nbudterms
441
442 !> @brief Set up the budget object that stores all the sft flows
443 !<
444 subroutine sft_setup_budobj(this, idx)
445 ! -- modules
446 use constantsmodule, only: lenbudtxt
447 ! -- dummy
448 class(gwtsfttype) :: this
449 integer(I4B), intent(inout) :: idx
450 ! -- local
451 integer(I4B) :: maxlist, naux
452 character(len=LENBUDTXT) :: text
453 !
454 ! --
455 text = ' RAINFALL'
456 idx = idx + 1
457 maxlist = this%flowbudptr%budterm(this%idxbudrain)%maxlist
458 naux = 0
459 call this%budobj%budterm(idx)%initialize(text, &
460 this%name_model, &
461 this%packName, &
462 this%name_model, &
463 this%packName, &
464 maxlist, .false., .false., &
465 naux)
466 !
467 ! --
468 text = ' EVAPORATION'
469 idx = idx + 1
470 maxlist = this%flowbudptr%budterm(this%idxbudevap)%maxlist
471 naux = 0
472 call this%budobj%budterm(idx)%initialize(text, &
473 this%name_model, &
474 this%packName, &
475 this%name_model, &
476 this%packName, &
477 maxlist, .false., .false., &
478 naux)
479 !
480 ! --
481 text = ' RUNOFF'
482 idx = idx + 1
483 maxlist = this%flowbudptr%budterm(this%idxbudroff)%maxlist
484 naux = 0
485 call this%budobj%budterm(idx)%initialize(text, &
486 this%name_model, &
487 this%packName, &
488 this%name_model, &
489 this%packName, &
490 maxlist, .false., .false., &
491 naux)
492 !
493 ! --
494 text = ' EXT-INFLOW'
495 idx = idx + 1
496 maxlist = this%flowbudptr%budterm(this%idxbudiflw)%maxlist
497 naux = 0
498 call this%budobj%budterm(idx)%initialize(text, &
499 this%name_model, &
500 this%packName, &
501 this%name_model, &
502 this%packName, &
503 maxlist, .false., .false., &
504 naux)
505 !
506 ! --
507 text = ' EXT-OUTFLOW'
508 idx = idx + 1
509 maxlist = this%flowbudptr%budterm(this%idxbudoutf)%maxlist
510 naux = 0
511 call this%budobj%budterm(idx)%initialize(text, &
512 this%name_model, &
513 this%packName, &
514 this%name_model, &
515 this%packName, &
516 maxlist, .false., .false., &
517 naux)
518 end subroutine sft_setup_budobj
519
520 !> @brief Copy flow terms into this%budobj
521 !<
522 subroutine sft_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
523 ! -- modules
524 ! -- dummy
525 class(gwtsfttype) :: this
526 integer(I4B), intent(inout) :: idx
527 real(DP), dimension(:), intent(in) :: x
528 real(DP), dimension(:), contiguous, intent(inout) :: flowja
529 real(DP), intent(inout) :: ccratin
530 real(DP), intent(inout) :: ccratout
531 ! -- local
532 integer(I4B) :: j, n1, n2
533 integer(I4B) :: nlist
534 real(DP) :: q
535 ! -- formats
536 !
537 ! -- RAIN
538 idx = idx + 1
539 nlist = this%flowbudptr%budterm(this%idxbudrain)%nlist
540 call this%budobj%budterm(idx)%reset(nlist)
541 do j = 1, nlist
542 call this%sft_rain_term(j, n1, n2, q)
543 call this%budobj%budterm(idx)%update_term(n1, n2, q)
544 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
545 end do
546 !
547 ! -- EVAPORATION
548 idx = idx + 1
549 nlist = this%flowbudptr%budterm(this%idxbudevap)%nlist
550 call this%budobj%budterm(idx)%reset(nlist)
551 do j = 1, nlist
552 call this%sft_evap_term(j, n1, n2, q)
553 call this%budobj%budterm(idx)%update_term(n1, n2, q)
554 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
555 end do
556 !
557 ! -- RUNOFF
558 idx = idx + 1
559 nlist = this%flowbudptr%budterm(this%idxbudroff)%nlist
560 call this%budobj%budterm(idx)%reset(nlist)
561 do j = 1, nlist
562 call this%sft_roff_term(j, n1, n2, q)
563 call this%budobj%budterm(idx)%update_term(n1, n2, q)
564 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
565 end do
566 !
567 ! -- EXT-INFLOW
568 idx = idx + 1
569 nlist = this%flowbudptr%budterm(this%idxbudiflw)%nlist
570 call this%budobj%budterm(idx)%reset(nlist)
571 do j = 1, nlist
572 call this%sft_iflw_term(j, n1, n2, q)
573 call this%budobj%budterm(idx)%update_term(n1, n2, q)
574 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
575 end do
576 !
577 ! -- EXT-OUTFLOW
578 idx = idx + 1
579 nlist = this%flowbudptr%budterm(this%idxbudoutf)%nlist
580 call this%budobj%budterm(idx)%reset(nlist)
581 do j = 1, nlist
582 call this%sft_outf_term(j, n1, n2, q)
583 call this%budobj%budterm(idx)%update_term(n1, n2, q)
584 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
585 end do
586 end subroutine sft_fill_budobj
587
588 !> @brief Allocate scalars specific to the streamflow energy transport (SFE)
589 !! package.
590 !<
591 subroutine allocate_scalars(this)
592 ! -- modules
594 ! -- dummy
595 class(gwtsfttype) :: this
596 ! -- local
597 !
598 ! -- allocate scalars in TspAptType
599 call this%TspAptType%allocate_scalars()
600 !
601 ! -- Allocate
602 call mem_allocate(this%idxbudrain, 'IDXBUDRAIN', this%memoryPath)
603 call mem_allocate(this%idxbudevap, 'IDXBUDEVAP', this%memoryPath)
604 call mem_allocate(this%idxbudroff, 'IDXBUDROFF', this%memoryPath)
605 call mem_allocate(this%idxbudiflw, 'IDXBUDIFLW', this%memoryPath)
606 call mem_allocate(this%idxbudoutf, 'IDXBUDOUTF', this%memoryPath)
607 !
608 ! -- Initialize
609 this%idxbudrain = 0
610 this%idxbudevap = 0
611 this%idxbudroff = 0
612 this%idxbudiflw = 0
613 this%idxbudoutf = 0
614 end subroutine allocate_scalars
615
616 !> @brief Allocate arrays specific to the streamflow energy transport (SFE)
617 !! package.
618 !<
619 subroutine sft_allocate_arrays(this)
620 ! -- modules
622 ! -- dummy
623 class(gwtsfttype), intent(inout) :: this
624 ! -- local
625 integer(I4B) :: n
626 !
627 ! -- alias into the input context's permanent, feature-indexed arrays
628 ! (allocated and DZERO-initialized by the input context)
629 call mem_setptr(this%concrain, 'RAINFALL', this%input_mempath)
630 call mem_setptr(this%concevap, 'EVAPORATION', this%input_mempath)
631 call mem_setptr(this%concroff, 'RUNOFF', this%input_mempath)
632 call mem_setptr(this%conciflw, 'INFLOW', this%input_mempath)
633
634 call mem_allocate(this%vnew, this%ncv, 'VNEW', this%memoryPath)
635 call mem_allocate(this%vold, this%ncv, 'VOLD', this%memoryPath)
636
637 !
638 ! -- call standard TspAptType allocate arrays
639 call this%TspAptType%apt_allocate_arrays()
640 !
641 ! -- Initialize
642 do n = 1, this%ncv
643 this%vnew(n) = dzero
644 this%vold(n) = dzero
645 end do
646 end subroutine sft_allocate_arrays
647
648 !> @brief Alias deprecated SFT variable names to their current storage
649 !<
651 ! -- modules
653 ! -- dummy
654 class(gwtsfttype), intent(inout) :: this
655 ! -- code
656 !
657 ! -- names common to all advanced transport packages
658 call this%TspAptType%apt_checkin_deprecated_names()
659 !
660 call mem_alias_deprecated(this%concrain, 'CONCRAIN', this%memoryPath, &
661 'RAINFALL', this%input_mempath, '6.8.2')
662 call mem_alias_deprecated(this%concevap, 'CONCEVAP', this%memoryPath, &
663 'EVAPORATION', this%input_mempath, '6.8.2')
664 call mem_alias_deprecated(this%concroff, 'CONCROFF', this%memoryPath, &
665 'RUNOFF', this%input_mempath, '6.8.2')
666 call mem_alias_deprecated(this%conciflw, 'CONCIFLW', this%memoryPath, &
667 'INFLOW', this%input_mempath, '6.8.2')
668 end subroutine sft_checkin_deprecated_names
669
670 !> @brief Advance sft package routine
671 !<
672 subroutine sft_ad(this)
673 ! modules
675 ! dummy
676 class(gwtsfttype) :: this
677 ! local
678 integer(I4B) :: n
679
680 ! call base bnd_ad and run the per-timestep resync directly
681 ! (see apt_ad_resync)
682 call this%BndExtType%bnd_ad()
683 call this%apt_ad_resync()
684
685 ! update vold, unless this time step is repeated, when vnew is the
686 ! volume the failed attempt ended with
687 if (ifailedstepretry == 0) then
688 do n = 1, this%ncv
689 this%vold(n) = this%vnew(n)
690 end do
691 end if
692
693 end subroutine sft_ad
694
695 !> @brief Deallocate memory
696 !<
697 subroutine sft_da(this)
698 ! -- modules
700 ! -- dummy
701 class(gwtsfttype) :: this
702 ! -- local
703 !
704 ! -- deallocate scalars
705 call mem_deallocate(this%idxbudrain)
706 call mem_deallocate(this%idxbudevap)
707 call mem_deallocate(this%idxbudroff)
708 call mem_deallocate(this%idxbudiflw)
709 call mem_deallocate(this%idxbudoutf)
710 !
711 ! -- input-context-owned aliases, not package-allocated
712 nullify (this%concrain)
713 nullify (this%concevap)
714 nullify (this%concroff)
715 nullify (this%conciflw)
716
717 call mem_deallocate(this%vnew)
718 call mem_deallocate(this%vold)
719 !
720 ! -- deallocate scalars in TspAptType
721 call this%TspAptType%bnd_da()
722 end subroutine sft_da
723
724 !> @brief Rain term
725 !<
726 subroutine sft_rain_term(this, ientry, n1, n2, rrate, &
727 rhsval, hcofval)
728 ! -- dummy
729 class(gwtsfttype) :: this
730 integer(I4B), intent(in) :: ientry
731 integer(I4B), intent(inout) :: n1
732 integer(I4B), intent(inout) :: n2
733 real(DP), intent(inout), optional :: rrate
734 real(DP), intent(inout), optional :: rhsval
735 real(DP), intent(inout), optional :: hcofval
736 ! -- local
737 real(DP) :: qbnd
738 real(DP) :: ctmp
739 !
740 n1 = this%flowbudptr%budterm(this%idxbudrain)%id1(ientry)
741 n2 = this%flowbudptr%budterm(this%idxbudrain)%id2(ientry)
742 qbnd = this%flowbudptr%budterm(this%idxbudrain)%flow(ientry)
743 ctmp = this%concrain(n1)
744 if (present(rrate)) rrate = ctmp * qbnd
745 if (present(rhsval)) rhsval = -rrate
746 if (present(hcofval)) hcofval = dzero
747 end subroutine sft_rain_term
748
749 !> @brief Evaporative term
750 !<
751 subroutine sft_evap_term(this, ientry, n1, n2, rrate, &
752 rhsval, hcofval)
753 ! -- dummy
754 class(gwtsfttype) :: this
755 integer(I4B), intent(in) :: ientry
756 integer(I4B), intent(inout) :: n1
757 integer(I4B), intent(inout) :: n2
758 real(DP), intent(inout), optional :: rrate
759 real(DP), intent(inout), optional :: rhsval
760 real(DP), intent(inout), optional :: hcofval
761 ! -- local
762 real(DP) :: qbnd
763 real(DP) :: ctmp
764 real(DP) :: omega
765 !
766 n1 = this%flowbudptr%budterm(this%idxbudevap)%id1(ientry)
767 n2 = this%flowbudptr%budterm(this%idxbudevap)%id2(ientry)
768 ! -- note that qbnd is negative for evap
769 qbnd = this%flowbudptr%budterm(this%idxbudevap)%flow(ientry)
770 ctmp = this%concevap(n1)
771 if (this%xnewpak(n1) < ctmp) then
772 omega = done
773 else
774 omega = dzero
775 end if
776 if (present(rrate)) &
777 rrate = omega * qbnd * this%xnewpak(n1) + &
778 (done - omega) * qbnd * ctmp
779 if (present(rhsval)) rhsval = -(done - omega) * qbnd * ctmp
780 if (present(hcofval)) hcofval = omega * qbnd
781 end subroutine sft_evap_term
782
783 !> @brief Runoff term
784 !<
785 subroutine sft_roff_term(this, ientry, n1, n2, rrate, &
786 rhsval, hcofval)
787 ! -- dummy
788 class(gwtsfttype) :: this
789 integer(I4B), intent(in) :: ientry
790 integer(I4B), intent(inout) :: n1
791 integer(I4B), intent(inout) :: n2
792 real(DP), intent(inout), optional :: rrate
793 real(DP), intent(inout), optional :: rhsval
794 real(DP), intent(inout), optional :: hcofval
795 ! -- local
796 real(DP) :: qbnd
797 real(DP) :: ctmp
798 !
799 n1 = this%flowbudptr%budterm(this%idxbudroff)%id1(ientry)
800 n2 = this%flowbudptr%budterm(this%idxbudroff)%id2(ientry)
801 qbnd = this%flowbudptr%budterm(this%idxbudroff)%flow(ientry)
802 ctmp = this%concroff(n1)
803 if (present(rrate)) rrate = ctmp * qbnd
804 if (present(rhsval)) rhsval = -rrate
805 if (present(hcofval)) hcofval = dzero
806 end subroutine sft_roff_term
807
808 !> @brief Inflow Term
809 !!
810 !! Accounts for mass added via streamflow entering into a stream channel;
811 !! for example, energy entering the model domain via a specified flow in a
812 !! stream channel.
813 !<
814 subroutine sft_iflw_term(this, ientry, n1, n2, rrate, &
815 rhsval, hcofval)
816 ! -- dummy
817 class(gwtsfttype) :: this
818 integer(I4B), intent(in) :: ientry
819 integer(I4B), intent(inout) :: n1
820 integer(I4B), intent(inout) :: n2
821 real(DP), intent(inout), optional :: rrate
822 real(DP), intent(inout), optional :: rhsval
823 real(DP), intent(inout), optional :: hcofval
824 ! -- local
825 real(DP) :: qbnd
826 real(DP) :: ctmp
827 !
828 n1 = this%flowbudptr%budterm(this%idxbudiflw)%id1(ientry)
829 n2 = this%flowbudptr%budterm(this%idxbudiflw)%id2(ientry)
830 qbnd = this%flowbudptr%budterm(this%idxbudiflw)%flow(ientry)
831 ctmp = this%conciflw(n1)
832 if (present(rrate)) rrate = ctmp * qbnd
833 if (present(rhsval)) rhsval = -rrate
834 if (present(hcofval)) hcofval = dzero
835 end subroutine sft_iflw_term
836
837 !> @brief Outflow term
838 !!
839 !! Accounts for the mass leaving a stream channel; for example, mass exiting the
840 !! model domain via a flow in a stream channel flowing out of the active domain.
841 !<
842 subroutine sft_outf_term(this, ientry, n1, n2, rrate, &
843 rhsval, hcofval)
844 ! -- dummy
845 class(gwtsfttype) :: this
846 integer(I4B), intent(in) :: ientry
847 integer(I4B), intent(inout) :: n1
848 integer(I4B), intent(inout) :: n2
849 real(DP), intent(inout), optional :: rrate
850 real(DP), intent(inout), optional :: rhsval
851 real(DP), intent(inout), optional :: hcofval
852 ! -- local
853 real(DP) :: qbnd
854 real(DP) :: ctmp
855 !
856 n1 = this%flowbudptr%budterm(this%idxbudoutf)%id1(ientry)
857 n2 = this%flowbudptr%budterm(this%idxbudoutf)%id2(ientry)
858 qbnd = this%flowbudptr%budterm(this%idxbudoutf)%flow(ientry)
859 ctmp = this%xnewpak(n1)
860 if (present(rrate)) rrate = ctmp * qbnd
861 if (present(rhsval)) rhsval = dzero
862 if (present(hcofval)) hcofval = qbnd
863 end subroutine sft_outf_term
864
865 !> @brief Observations
866 !!
867 !! Store the observation type supported by the APT package and override
868 !! BndType%bnd_df_obs
869 !<
870 subroutine sft_df_obs(this)
871 ! -- modules
872 ! -- dummy
873 class(gwtsfttype) :: this
874 ! -- local
875 integer(I4B) :: indx
876 !
877 ! -- Store obs type and assign procedure pointer
878 ! for concentration observation type.
879 call this%obs%StoreObsType('concentration', .false., indx)
880 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
881 !
882 ! -- Store obs type and assign procedure pointer
883 ! for flow between reaches.
884 call this%obs%StoreObsType('flow-ja-face', .true., indx)
885 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid12
886 !
887 ! -- Store obs type and assign procedure pointer
888 ! for from-mvr observation type.
889 call this%obs%StoreObsType('from-mvr', .true., indx)
890 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
891 !
892 ! -- Store obs type and assign procedure pointer
893 ! for to-mvr observation type.
894 call this%obs%StoreObsType('to-mvr', .true., indx)
895 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
896 !
897 ! -- Store obs type and assign procedure pointer
898 ! for storage observation type.
899 call this%obs%StoreObsType('storage', .true., indx)
900 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
901 !
902 ! -- Store obs type and assign procedure pointer
903 ! for constant observation type.
904 call this%obs%StoreObsType('constant', .true., indx)
905 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
906 !
907 ! -- Store obs type and assign procedure pointer
908 ! for observation type: sft
909 call this%obs%StoreObsType('sft', .true., indx)
910 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
911 !
912 ! -- Store obs type and assign procedure pointer
913 ! for rainfall observation type.
914 call this%obs%StoreObsType('rainfall', .true., indx)
915 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
916 !
917 ! -- Store obs type and assign procedure pointer
918 ! for evaporation observation type.
919 call this%obs%StoreObsType('evaporation', .true., indx)
920 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
921 !
922 ! -- Store obs type and assign procedure pointer
923 ! for runoff observation type.
924 call this%obs%StoreObsType('runoff', .true., indx)
925 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
926 !
927 ! -- Store obs type and assign procedure pointer
928 ! for inflow observation type.
929 call this%obs%StoreObsType('ext-inflow', .true., indx)
930 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
931 !
932 ! -- Store obs type and assign procedure pointer
933 ! for ext-outflow observation type.
934 call this%obs%StoreObsType('ext-outflow', .true., indx)
935 this%obs%obsData(indx)%ProcessIdPtr => apt_process_obsid
936 end subroutine sft_df_obs
937
938 !> @brief Process package specific obs
939 !!
940 !! Method to process specific observations for this package.
941 !<
942 subroutine sft_rp_obs(this, obsrv, found)
943 ! -- dummy
944 class(gwtsfttype), intent(inout) :: this !< package class
945 type(observetype), intent(inout) :: obsrv !< observation object
946 logical, intent(inout) :: found !< indicate whether observation was found
947 ! -- local
948 !
949 found = .true.
950 select case (obsrv%ObsTypeId)
951 case ('RAINFALL')
952 call this%rp_obs_byfeature(obsrv)
953 case ('EVAPORATION')
954 call this%rp_obs_byfeature(obsrv)
955 case ('RUNOFF')
956 call this%rp_obs_byfeature(obsrv)
957 case ('EXT-INFLOW')
958 call this%rp_obs_byfeature(obsrv)
959 case ('EXT-OUTFLOW')
960 call this%rp_obs_byfeature(obsrv)
961 case ('TO-MVR')
962 call this%rp_obs_byfeature(obsrv)
963 case default
964 found = .false.
965 end select
966 end subroutine sft_rp_obs
967
968 !> @brief Calculate observation value and pass it back to APT
969 !<
970 subroutine sft_bd_obs(this, obstypeid, jj, v, found)
971 ! -- dummy
972 class(gwtsfttype), intent(inout) :: this
973 character(len=*), intent(in) :: obstypeid
974 real(DP), intent(inout) :: v
975 integer(I4B), intent(in) :: jj
976 logical, intent(inout) :: found
977 ! -- local
978 integer(I4B) :: n1, n2
979 !
980 found = .true.
981 select case (obstypeid)
982 case ('RAINFALL')
983 if (this%iboundpak(jj) /= 0) then
984 call this%sft_rain_term(jj, n1, n2, v)
985 end if
986 case ('EVAPORATION')
987 if (this%iboundpak(jj) /= 0) then
988 call this%sft_evap_term(jj, n1, n2, v)
989 end if
990 case ('RUNOFF')
991 if (this%iboundpak(jj) /= 0) then
992 call this%sft_roff_term(jj, n1, n2, v)
993 end if
994 case ('EXT-INFLOW')
995 if (this%iboundpak(jj) /= 0) then
996 call this%sft_iflw_term(jj, n1, n2, v)
997 end if
998 case ('EXT-OUTFLOW')
999 if (this%iboundpak(jj) /= 0) then
1000 call this%sft_outf_term(jj, n1, n2, v)
1001 end if
1002 case default
1003 found = .false.
1004 end select
1005 end subroutine sft_bd_obs
1006
1007 !> @brief Return the sfr new volume and old volume
1008 !<
1009 subroutine sft_get_volumes(this, icv, vnew, vold, delt)
1010 ! modules
1011 ! dummy
1012 class(gwtsfttype) :: this
1013 integer(I4B), intent(in) :: icv
1014 real(DP), intent(inout) :: vnew, vold
1015 real(DP), intent(in) :: delt
1016 ! local
1017 real(DP) :: qss
1018 !
1019 ! -- get volumes
1020 vold = dzero
1021 vnew = vold
1022 if (this%idxbudsto /= 0) then
1023 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1024 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1025 this%vnew(icv) = vnew
1026 if (qss /= dzero) then
1027 vold = vnew + qss * delt
1028 else
1029 if (vnew == dzero) then
1030 vold = dzero
1031 else
1032 vold = this%vold(icv)
1033 end if
1034 end if
1035 end if
1036 end subroutine sft_get_volumes
1037
1038end module gwtsftmodule
This module contains the base boundary package.
subroutine bnd_da(this)
Deallocate package memory.
class(bndtype) function, pointer, public getbndfromlist(list, idx)
Get boundary from package list.
subroutine bnd_ad(this)
Advance the boundary package.
This module contains simulation constants.
Definition Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition Constants.f90:45
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
real(dp), parameter dzero
real constant zero
Definition Constants.f90:65
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
Definition Constants.f90:37
real(dp), parameter done
real constant 1
Definition Constants.f90:76
subroutine sft_solve(this)
Add terms specific to sft to the explicit sft solve.
Definition gwt-sft.f90:378
subroutine sft_iflw_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Inflow Term.
Definition gwt-sft.f90:816
subroutine allocate_scalars(this)
Allocate scalars specific to the streamflow energy transport (SFE) package.
Definition gwt-sft.f90:592
character(len= *), parameter flowtype
Definition gwt-sft.f90:53
subroutine sft_outf_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Outflow term.
Definition gwt-sft.f90:844
real(dp) function sft_setting_value(this, itemno, key)
Value for a package-specific PERIOD setting.
Definition gwt-sft.f90:279
subroutine sft_roff_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Runoff term.
Definition gwt-sft.f90:787
subroutine find_sft_package(this)
Find corresponding sft package.
Definition gwt-sft.f90:160
subroutine sft_bd_obs(this, obstypeid, jj, v, found)
Calculate observation value and pass it back to APT.
Definition gwt-sft.f90:971
subroutine sft_rp_obs(this, obsrv, found)
Process package specific obs.
Definition gwt-sft.f90:943
subroutine sft_ad(this)
Advance sft package routine.
Definition gwt-sft.f90:673
subroutine sft_da(this)
Deallocate memory.
Definition gwt-sft.f90:698
subroutine sft_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
Copy flow terms into thisbudobj.
Definition gwt-sft.f90:523
subroutine sft_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Add matrix terms related to SFT.
Definition gwt-sft.f90:304
subroutine sft_get_volumes(this, icv, vnew, vold, delt)
Return the sfr new volume and old volume.
Definition gwt-sft.f90:1010
subroutine, public sft_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath, fmi, eqnsclfac, dvt, dvu, dvua)
Create a new sft package.
Definition gwt-sft.f90:104
subroutine sft_setup_budobj(this, idx)
Set up the budget object that stores all the sft flows.
Definition gwt-sft.f90:445
integer(i4b) function sft_get_nbudterms(this)
Function to return the number of budget terms just for this package.
Definition gwt-sft.f90:431
subroutine sft_checkin_deprecated_names(this)
Alias deprecated SFT variable names to their current storage.
Definition gwt-sft.f90:651
subroutine sft_evap_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Evaporative term.
Definition gwt-sft.f90:753
subroutine sft_allocate_arrays(this)
Allocate arrays specific to the streamflow energy transport (SFE) package.
Definition gwt-sft.f90:620
subroutine sft_df_obs(this)
Observations.
Definition gwt-sft.f90:871
subroutine sft_rain_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Rain term.
Definition gwt-sft.f90:728
This module defines variable data types.
Definition kind.f90:8
Previous variable names checked in as deprecated aliases.
This module contains the derived types ObserveType and ObsDataType.
Definition Observe.f90:15
This module contains the SFR package methods.
Definition gwf-sfr.f90:7
character(len=lenftype) ftype
package ftype string
Definition gwf-sfr.f90:50
character(len=lenpackagename) text
package budget string
Definition gwf-sfr.f90:51
This module contains simulation methods.
Definition Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition Sim.f90:94
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
Definition Sim.f90:208
This module contains simulation variables.
integer(i4b) ifailedstepretry
current retry for this time step
subroutine apt_checkin_deprecated_names(this)
Alias deprecated advanced transport variable names.
Definition tsp-apt.f90:1192
subroutine pak_setup_budobj(this, idx)
Set up a budget object that stores an advanced package flows.
Definition tsp-apt.f90:1987
subroutine pak_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
Copy flow terms into thisbudobj, must be overridden.
Definition tsp-apt.f90:2139
subroutine pak_bd_obs(this, obstypeid, jj, v, found)
Check if observation exists in an advanced package.
Definition tsp-apt.f90:2712
subroutine pak_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
Definition tsp-apt.f90:830
subroutine apt_allocate_arrays(this)
Allocate arrays.
Definition tsp-apt.f90:1130
integer(i4b) function pak_get_nbudterms(this)
Function to return the number of budget terms just for this package.
Definition tsp-apt.f90:1783
real(dp) function apt_setting_value(this, itemno, key)
Virtual hook: value for a package-specific PERIOD setting. Override in individual packages to supply ...
Definition tsp-apt.f90:649
subroutine pak_rp_obs(this, obsrv, found)
Process package specific obs.
Definition tsp-apt.f90:2339
subroutine apt_get_volumes(this, icv, vnew, vold, delt)
Return the feature new volume and old volume.
Definition tsp-apt.f90:1759
subroutine find_apt_package(this)
Find corresponding advanced package transport package.
Definition tsp-apt.f90:1292
subroutine, public apt_process_obsid(obsrv, dis, inunitobs, iout)
Process observation IDs for an advanced package.
Definition tsp-apt.f90:2731
subroutine pak_solve(this)
Add terms specific to advanced package transport features to the explicit solve routine.
Definition tsp-apt.f90:1665
subroutine pak_df_obs(this)
Define apt observation type.
Definition tsp-apt.f90:2324
subroutine, public apt_process_obsid12(obsrv, dis, inunitobs, iout)
Process observation IDs for a package.
Definition tsp-apt.f90:2774
This class is used to store a single deferred-length character string. It was designed to work in an ...