50 character(len=LENFTYPE) ::
ftype =
'SFR'
51 character(len=LENPACKAGENAME) ::
text =
' SFR'
64 real(dp),
dimension(:),
pointer,
contiguous :: rhk => null()
65 real(dp),
dimension(:),
pointer,
contiguous :: man => null()
66 real(dp),
dimension(:),
pointer,
contiguous :: ustrf => null()
67 integer(I4B),
dimension(:),
pointer :: rhk_tslink => null()
68 integer(I4B),
dimension(:),
pointer :: man_tslink => null()
69 integer(I4B),
dimension(:),
pointer :: ustrf_tslink => null()
71 integer(I4B),
pointer :: nbound => null()
72 integer(I4B),
dimension(:),
pointer,
contiguous :: ifno => null()
74 contiguous :: status => null()
76 contiguous :: setting => null()
77 integer(I4B),
dimension(:),
pointer,
contiguous :: idv => null()
79 contiguous :: tab6_filename => null()
81 contiguous :: auxname => null()
82 real(dp),
dimension(:),
pointer,
contiguous :: auxval => null()
92 character(len=16),
dimension(:),
pointer,
contiguous :: csfrbudget => null()
93 character(len=16),
dimension(:),
pointer,
contiguous :: cauxcbc => null()
94 character(len=LENBOUNDNAME),
dimension(:),
pointer, &
95 contiguous :: sfrname => null()
97 integer(I4B),
pointer :: istorage => null()
98 integer(I4B),
pointer :: iprhed => null()
99 integer(I4B),
pointer :: istageout => null()
100 integer(I4B),
pointer :: ibudgetout => null()
101 integer(I4B),
pointer :: ibudcsv => null()
102 integer(I4B),
pointer :: ipakcsv => null()
103 integer(I4B),
pointer :: idiversions => null()
104 integer(I4B),
pointer :: nconn => null()
105 integer(I4B),
pointer :: maxsfrpicard => null()
106 integer(I4B),
pointer :: maxsfrit => null()
107 integer(I4B),
pointer :: bditems => null()
108 integer(I4B),
pointer :: cbcauxitems => null()
109 integer(I4B),
pointer :: icheck => null()
110 integer(I4B),
pointer :: iconvchk => null()
111 integer(I4B),
pointer :: gwfiss => null()
112 integer(I4B),
pointer :: ianynone => null()
114 real(dp),
pointer :: unitconv => null()
115 real(dp),
pointer :: lengthconv => null()
116 real(dp),
pointer :: timeconv => null()
117 real(dp),
pointer :: dmaxchg => null()
118 real(dp),
pointer :: deps => null()
119 real(dp),
pointer :: storage_weight => null()
121 integer(I4B),
dimension(:),
pointer,
contiguous :: isfrorder => null()
122 integer(I4B),
dimension(:),
pointer,
contiguous :: ia => null()
123 integer(I4B),
dimension(:),
pointer,
contiguous :: ja => null()
125 real(dp),
dimension(:),
pointer,
contiguous :: qoutflow => null()
126 real(dp),
dimension(:),
pointer,
contiguous :: qextoutflow => null()
127 real(dp),
dimension(:),
pointer,
contiguous :: qauxcbc => null()
128 real(dp),
dimension(:),
pointer,
contiguous :: dbuff => null()
139 integer(I4B),
dimension(:),
pointer,
contiguous :: iboundpak => null()
140 integer(I4B),
dimension(:),
pointer,
contiguous :: igwfnode => null()
141 integer(I4B),
dimension(:),
pointer,
contiguous :: igwftopnode => null()
142 real(dp),
dimension(:),
pointer,
contiguous :: length => null()
143 real(dp),
dimension(:),
pointer,
contiguous :: width => null()
144 real(dp),
dimension(:),
pointer,
contiguous :: strtop => null()
145 real(dp),
dimension(:),
pointer,
contiguous :: bthick => null()
146 real(dp),
dimension(:),
pointer,
contiguous :: hk => null()
147 real(dp),
dimension(:),
pointer,
contiguous :: slope => null()
148 integer(I4B),
dimension(:),
pointer,
contiguous :: nconnreach => null()
149 real(dp),
dimension(:),
pointer,
contiguous :: ustrf => null()
150 logical(LGP),
dimension(:),
pointer,
contiguous :: bedk_set => null()
151 logical(LGP),
dimension(:),
pointer,
contiguous :: manning_set => null()
152 logical(LGP),
dimension(:),
pointer,
contiguous :: ustrf_set => null()
153 real(dp),
dimension(:),
pointer,
contiguous :: ftotnd => null()
154 integer(I4B),
dimension(:),
pointer,
contiguous :: ndiv => null()
155 real(dp),
dimension(:),
pointer,
contiguous :: usflow => null()
156 real(dp),
dimension(:),
pointer,
contiguous :: dsflow => null()
157 real(dp),
dimension(:),
pointer,
contiguous :: dsflowold => null()
158 real(dp),
dimension(:),
pointer,
contiguous :: usinflow => null()
159 real(dp),
dimension(:),
pointer,
contiguous :: usinflowold => null()
160 real(dp),
pointer :: ats_courant => null()
161 integer(I4B),
dimension(:),
pointer,
contiguous :: itvd_upstream => null()
162 real(dp),
dimension(:),
pointer,
contiguous :: crmin => null()
163 real(dp),
dimension(:),
pointer,
contiguous :: crmax => null()
164 real(dp),
dimension(:),
pointer,
contiguous :: crsum => null()
165 integer(I4B),
dimension(:),
pointer,
contiguous :: crcnt => null()
166 real(dp),
dimension(:),
pointer,
contiguous :: depth => null()
167 real(dp),
dimension(:),
pointer,
contiguous :: stage => null()
168 real(dp),
dimension(:),
pointer,
contiguous :: stageold => null()
169 real(dp),
dimension(:),
pointer,
contiguous :: gwflow => null()
170 real(dp),
dimension(:),
pointer,
contiguous :: simevap => null()
171 real(dp),
dimension(:),
pointer,
contiguous :: simrunoff => null()
172 real(dp),
dimension(:),
pointer,
contiguous :: stage0 => null()
173 real(dp),
dimension(:),
pointer,
contiguous :: usflow0 => null()
174 real(dp),
dimension(:),
pointer,
contiguous :: storage => null()
176 integer(I4B),
pointer :: ncrossptstot => null()
177 integer(I4B),
dimension(:),
pointer,
contiguous :: ncrosspts => null()
178 integer(I4B),
dimension(:),
pointer,
contiguous :: iacross => null()
179 real(dp),
dimension(:),
pointer,
contiguous :: station => null()
180 real(dp),
dimension(:),
pointer,
contiguous :: xsheight => null()
181 real(dp),
dimension(:),
pointer,
contiguous :: xsrough => null()
183 integer(I4B),
dimension(:),
pointer,
contiguous :: idir => null()
184 integer(I4B),
dimension(:),
pointer,
contiguous :: idiv => null()
185 real(dp),
dimension(:),
pointer,
contiguous :: qconn => null()
187 real(dp),
dimension(:),
pointer,
contiguous :: rough => null()
188 real(dp),
dimension(:),
pointer,
contiguous :: rain => null()
189 real(dp),
dimension(:),
pointer,
contiguous :: evap => null()
190 real(dp),
dimension(:),
pointer,
contiguous :: inflow => null()
191 real(dp),
dimension(:),
pointer,
contiguous :: runoff => null()
192 real(dp),
dimension(:),
pointer,
contiguous :: sstage => null()
194 integer(I4B),
dimension(:),
pointer,
contiguous :: iadiv => null()
195 integer(I4B),
dimension(:),
pointer,
contiguous :: divreach => null()
196 character(len=10),
dimension(:),
pointer,
contiguous :: divcprior => null()
197 real(dp),
dimension(:),
pointer,
contiguous :: divflow => null()
198 real(dp),
dimension(:),
pointer,
contiguous :: divq => null()
201 integer(I4B),
pointer :: idense
202 real(dp),
dimension(:, :),
pointer,
contiguous :: denseterms => null()
205 real(dp),
dimension(:, :),
pointer,
contiguous :: viscratios => null()
242 procedure,
private :: sfr_calc_constant
243 procedure,
private :: sfr_calc_transient
244 procedure,
private :: sfr_calc_tvd
246 procedure,
private :: sfr_calc_steady
294 module subroutine sfr_calc_steady(this, n, d1, hgwf, &
295 qu, qi, qfrommvr, qr, qe, qro, &
297 class(sfrtype) :: this
298 integer(I4B),
intent(in) :: n
299 real(dp),
intent(inout) :: d1
300 real(dp),
intent(in) :: hgwf
301 real(dp),
intent(in) :: qu
302 real(dp),
intent(in) :: qi
303 real(dp),
intent(in) :: qfrommvr
304 real(dp),
intent(in) :: qr
305 real(dp),
intent(in) :: qe
306 real(dp),
intent(in) :: qro
307 real(dp),
intent(inout) :: qgwf
308 real(dp),
intent(inout) :: qd
313 module subroutine sfr_calc_transient(this, n, d1, hgwf, &
314 qu, qi, qfrommvr, qr, qe, qro, &
316 class(sfrtype) :: this
317 integer(I4B),
intent(in) :: n
318 real(dp),
intent(inout) :: d1
319 real(dp),
intent(in) :: hgwf
320 real(dp),
intent(in) :: qu
321 real(dp),
intent(in) :: qi
322 real(dp),
intent(in) :: qfrommvr
323 real(dp),
intent(in) :: qr
324 real(dp),
intent(in) :: qe
325 real(dp),
intent(in) :: qro
326 real(dp),
intent(inout) :: qgwf
327 real(dp),
intent(inout) :: qd
332 module subroutine sfr_calc_tvd(this, n, d1, hgwf, &
333 qu, qi, qfrommvr, qr, qe, qro, &
335 class(sfrtype) :: this
336 integer(I4B),
intent(in) :: n
337 real(dp),
intent(inout) :: d1
338 real(dp),
intent(in) :: hgwf
339 real(dp),
intent(in) :: qu
340 real(dp),
intent(in) :: qi
341 real(dp),
intent(in) :: qfrommvr
342 real(dp),
intent(in) :: qr
343 real(dp),
intent(in) :: qe
344 real(dp),
intent(in) :: qro
345 real(dp),
intent(inout) :: qgwf
346 real(dp),
intent(inout) :: qd
351 module subroutine sfr_calc_constant(this, n, d1, hgwf, qgwf, qd)
352 class(sfrtype) :: this
353 integer(I4B),
intent(in) :: n
354 real(dp),
intent(inout) :: d1
355 real(dp),
intent(in) :: hgwf
356 real(dp),
intent(inout) :: qgwf
357 real(dp),
intent(inout) :: qd
367 subroutine sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
372 class(
bndtype),
pointer :: packobj
373 integer(I4B),
intent(in) :: id
374 integer(I4B),
intent(in) :: ibcnum
375 integer(I4B),
intent(in) :: inunit
376 integer(I4B),
intent(in) :: iout
377 character(len=*),
intent(in) :: namemodel
378 character(len=*),
intent(in) :: pakname
379 character(len=*),
intent(in) :: mempath
381 type(sfrtype),
pointer :: sfrobj
388 call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
392 call sfrobj%sfr_allocate_scalars()
395 call packobj%pack_initialize()
397 packobj%inunit = inunit
400 packobj%ibcnum = ibcnum
405 end subroutine sfr_create
412 subroutine sfr_allocate_scalars(this)
417 class(sfrtype),
intent(inout) :: this
420 call this%BndExtType%allocate_scalars()
423 call mem_allocate(this%istorage,
'ISTORAGE', this%memoryPath)
424 call mem_allocate(this%iprhed,
'IPRHED', this%memoryPath)
425 call mem_allocate(this%istageout,
'ISTAGEOUT', this%memoryPath)
426 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
427 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
428 call mem_allocate(this%ipakcsv,
'IPAKCSV', this%memoryPath)
429 call mem_allocate(this%idiversions,
'IDIVERSIONS', this%memoryPath)
430 call mem_allocate(this%maxsfrpicard,
'MAXSFRPICARD', this%memoryPath)
431 call mem_allocate(this%maxsfrit,
'MAXSFRIT', this%memoryPath)
432 call mem_allocate(this%bditems,
'BDITEMS', this%memoryPath)
433 call mem_allocate(this%cbcauxitems,
'CBCAUXITEMS', this%memoryPath)
434 call mem_allocate(this%unitconv,
'UNITCONV', this%memoryPath)
435 call mem_allocate(this%lengthconv,
'LENGTHCONV', this%memoryPath)
436 call mem_allocate(this%timeconv,
'TIMECONV', this%memoryPath)
437 call mem_allocate(this%dmaxchg,
'DMAXCHG', this%memoryPath)
439 call mem_allocate(this%storage_weight,
'STORAGE_WEIGHT', this%memoryPath)
440 call mem_allocate(this%ats_courant,
'ATS_COURANT', this%memoryPath)
442 call mem_allocate(this%icheck,
'ICHECK', this%memoryPath)
443 call mem_allocate(this%iconvchk,
'ICONVCHK', this%memoryPath)
444 call mem_allocate(this%idense,
'IDENSE', this%memoryPath)
445 call mem_allocate(this%ianynone,
'IANYNONE', this%memoryPath)
446 call mem_allocate(this%ncrossptstot,
'NCROSSPTSTOT', this%memoryPath)
459 this%maxsfrpicard = 100
467 this%deps =
dp999 * this%dmaxchg
476 this%ncrossptstot = 0
477 end subroutine sfr_allocate_scalars
483 subroutine sfr_allocate_arrays(this)
487 class(sfrtype),
intent(inout) :: this
492 allocate (this%csfrbudget(this%bditems))
494 'SFRNAME', this%memoryPath)
497 call mem_allocate(this%iboundpak, this%maxbound,
'IBOUNDPAK', &
499 call mem_allocate(this%igwfnode, this%maxbound,
'IGWFNODE', this%memoryPath)
500 call mem_allocate(this%igwftopnode, this%maxbound,
'IGWFTOPNODE', &
502 call mem_allocate(this%length, this%maxbound,
'LENGTH', this%memoryPath)
503 call mem_allocate(this%width, this%maxbound,
'WIDTH', this%memoryPath)
504 call mem_allocate(this%strtop, this%maxbound,
'STRTOP', this%memoryPath)
505 call mem_allocate(this%bthick, this%maxbound,
'BTHICK', this%memoryPath)
506 call mem_allocate(this%slope, this%maxbound,
'SLOPE', this%memoryPath)
507 call mem_allocate(this%nconnreach, this%maxbound,
'NCONNREACH', &
509 call mem_allocate(this%bedk_set, this%maxbound,
'BEDK_SET', this%memoryPath)
510 call mem_allocate(this%manning_set, this%maxbound,
'MANNING_SET', &
512 call mem_allocate(this%ustrf_set, this%maxbound,
'USTRF_SET', &
514 this%bedk_set = .false.
515 this%manning_set = .false.
516 this%ustrf_set = .false.
517 call mem_allocate(this%ftotnd, this%maxbound,
'FTOTND', this%memoryPath)
518 call mem_allocate(this%ndiv, this%maxbound,
'NDIV', this%memoryPath)
519 call mem_allocate(this%usflow, this%maxbound,
'USFLOW', this%memoryPath)
520 call mem_allocate(this%dsflow, this%maxbound,
'DSFLOW', this%memoryPath)
521 call mem_allocate(this%depth, this%maxbound,
'DEPTH', this%memoryPath)
522 call mem_allocate(this%stage, this%maxbound,
'STAGE', this%memoryPath)
523 call mem_allocate(this%gwflow, this%maxbound,
'GWFLOW', this%memoryPath)
524 call mem_allocate(this%simevap, this%maxbound,
'SIMEVAP', this%memoryPath)
525 call mem_allocate(this%simrunoff, this%maxbound,
'SIMRUNOFF', &
527 call mem_allocate(this%stage0, this%maxbound,
'STAGE0', this%memoryPath)
528 call mem_allocate(this%usflow0, this%maxbound,
'USFLOW0', this%memoryPath)
531 if (this%istorage == 1)
then
532 call mem_allocate(this%stageold, this%maxbound,
'STAGEOLD', &
534 call mem_allocate(this%usinflow, this%maxbound,
'USINFLOW', &
536 call mem_allocate(this%usinflowold, this%maxbound,
'USINFLOWOLD', &
538 call mem_allocate(this%dsflowold, this%maxbound,
'DSFLOWOLD', &
540 call mem_allocate(this%storage, this%maxbound,
'STORAGE', &
542 call mem_allocate(this%crmin, this%maxbound,
'CRMIN', this%memoryPath)
543 call mem_allocate(this%crmax, this%maxbound,
'CRMAX', this%memoryPath)
544 call mem_allocate(this%crsum, this%maxbound,
'CRSUM', this%memoryPath)
545 call mem_allocate(this%crcnt, this%maxbound,
'CRCNT', this%memoryPath)
546 if (this%ats_courant /=
dnodata)
then
548 'ITVD_UPSTREAM', this%memoryPath)
550 call mem_allocate(this%itvd_upstream, 0,
'ITVD_UPSTREAM', this%memoryPath)
555 call mem_allocate(this%isfrorder, this%maxbound,
'ISFRORDER', &
557 call mem_allocate(this%ia, this%maxbound + 1,
'IA', this%memoryPath)
559 call mem_allocate(this%idir, 0,
'IDIR', this%memoryPath)
560 call mem_allocate(this%idiv, 0,
'IDIV', this%memoryPath)
561 call mem_allocate(this%qconn, 0,
'QCONN', this%memoryPath)
565 call mem_setptr(this%rain,
'RAINFALL', this%input_mempath)
566 call mem_setptr(this%evap,
'EVAPORATION', this%input_mempath)
567 call mem_setptr(this%inflow,
'INFLOW', this%input_mempath)
568 call mem_setptr(this%runoff,
'RUNOFF', this%input_mempath)
569 call mem_setptr(this%sstage,
'STAGE', this%input_mempath)
570 call mem_setptr(this%hk,
'BEDK', this%input_mempath)
571 call mem_setptr(this%rough,
'MANNING', this%input_mempath)
572 call mem_setptr(this%ustrf,
'UPSTREAM_FRAC', this%input_mempath)
576 call mem_allocate(this%iadiv, this%maxbound + 1,
'IADIV', this%memoryPath)
577 call mem_allocate(this%divreach, 0,
'DIVREACH', this%memoryPath)
578 call mem_allocate(this%divq, 0,
'DIVQ', this%memoryPath)
581 call mem_allocate(this%ncrosspts, this%maxbound,
'NCROSSPTS', &
583 call mem_allocate(this%iacross, this%maxbound + 1,
'IACROSS', &
585 call mem_allocate(this%station, this%ncrossptstot,
'STATION', &
587 call mem_allocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
589 call mem_allocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
594 do i = 1, this%maxbound
595 this%iboundpak(i) = 1
597 this%igwftopnode(i) = 0
598 this%length(i) =
dzero
599 this%width(i) =
dzero
600 this%strtop(i) =
dzero
601 this%bthick(i) =
dzero
603 this%slope(i) =
dzero
604 this%nconnreach(i) = 0
605 this%ustrf(i) =
dzero
606 this%ftotnd(i) =
dzero
608 this%usflow(i) =
dzero
609 this%dsflow(i) =
dzero
610 this%depth(i) =
dzero
611 this%stage(i) =
dzero
612 this%gwflow(i) =
dzero
613 this%simevap(i) =
dzero
614 this%simrunoff(i) =
dzero
615 this%stage0(i) =
dzero
616 this%usflow0(i) =
dzero
619 if (this%istorage == 1)
then
620 this%stageold(i) =
dzero
621 this%usinflow(i) =
dzero
622 this%usinflowold(i) =
dzero
623 this%dsflowold(i) =
dzero
624 this%storage(i) =
dzero
625 this%crmin(i) =
dep20
626 this%crmax(i) = -
dep20
627 this%crsum(i) =
dzero
629 if (this%ats_courant /=
dnodata)
then
630 this%itvd_upstream(i) = 0
635 this%rough(i) =
dzero
639 this%ncrosspts(i) = 0
640 this%iacross(i + 1) = 0
644 do i = 1, this%ncrossptstot
645 this%station(i) =
dzero
646 this%xsheight(i) =
dzero
647 this%xsrough(i) =
dzero
651 this%csfrbudget(1) =
' RAINFALL'
652 this%csfrbudget(2) =
' EVAPORATION'
653 this%csfrbudget(3) =
' RUNOFF'
654 this%csfrbudget(4) =
' EXT-INFLOW'
655 this%csfrbudget(5) =
' GWF'
656 this%csfrbudget(6) =
' EXT-OUTFLOW'
657 this%csfrbudget(7) =
' FROM-MVR'
658 this%csfrbudget(8) =
' TO-MVR'
661 call mem_allocate(this%qoutflow, this%maxbound,
'QOUTFLOW', this%memoryPath)
662 call mem_allocate(this%qextoutflow, this%maxbound,
'QEXTOUTFLOW', &
664 do i = 1, this%maxbound
665 this%qoutflow(i) =
dzero
666 this%qextoutflow(i) =
dzero
670 if (this%istageout > 0)
then
671 call mem_allocate(this%dbuff, this%maxbound,
'DBUFF', this%memoryPath)
672 do i = 1, this%maxbound
673 this%dbuff(i) =
dzero
676 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
680 allocate (this%cauxcbc(this%cbcauxitems))
683 call mem_allocate(this%qauxcbc, this%cbcauxitems,
'QAUXCBC', &
685 do i = 1, this%cbcauxitems
686 this%qauxcbc(i) =
dzero
690 this%cauxcbc(1) =
'FLOW-AREA '
693 call mem_allocate(this%denseterms, 3, 0,
'DENSETERMS', this%memoryPath)
696 call mem_allocate(this%viscratios, 2, 0,
'VISCRATIOS', this%memoryPath)
697 end subroutine sfr_allocate_arrays
708 subroutine sfr_checkin_deprecated_names(this)
713 class(sfrtype),
intent(inout) :: this
715 real(DP),
dimension(:, :),
pointer,
contiguous :: aux => null()
716 integer(I4B) :: isize
720 call get_isize(
'AUX', this%input_mempath, isize)
722 call mem_setptr(aux,
'AUX', this%input_mempath)
724 'AUX', this%input_mempath,
'6.8.2')
728 if (
associated(this%divflow))
then
730 'DIVFLOW', this%input_mempath,
'6.8.2')
732 call mem_allocate(this%divflow, 0,
'DIVFLOW', this%memoryPath)
736 'RAINFALL', this%input_mempath,
'6.8.2')
738 'EVAPORATION', this%input_mempath,
'6.8.2')
740 'INFLOW', this%input_mempath,
'6.8.2')
742 'RUNOFF', this%input_mempath,
'6.8.2')
744 'STAGE', this%input_mempath,
'6.8.2')
746 'BEDK', this%input_mempath,
'6.8.2')
748 'MANNING', this%input_mempath,
'6.8.2')
750 'UPSTREAM_FRAC', this%input_mempath,
'6.8.2')
751 end subroutine sfr_checkin_deprecated_names
755 subroutine sfr_source_options(this)
762 class(sfrtype),
intent(inout) :: this
764 character(len=LINELENGTH) :: fname
765 logical(LGP) :: found
767 character(len=*),
parameter :: fmtpicard = &
768 &
"(4x, 'MAXIMUM SFR PICARD ITERATION VALUE (',i0,') SPECIFIED.')"
769 character(len=*),
parameter :: fmtiter = &
770 &
"(4x, 'MAXIMUM SFR ITERATION VALUE (',i0,') SPECIFIED.')"
771 character(len=*),
parameter :: fmtdmaxchg = &
772 &
"(4x, 'MAXIMUM DEPTH CHANGE VALUE (',g0,') SPECIFIED.')"
773 character(len=*),
parameter :: fmtlengthconv = &
774 &
"(4x, 'LENGTH CONVERSION VALUE (',g0,') SPECIFIED.')"
775 character(len=*),
parameter :: fmttimeconv = &
776 &
"(4x, 'TIME CONVERSION VALUE (',g0,') SPECIFIED.')"
777 character(len=*),
parameter :: fmtstoweight = &
778 &
"(4x, 'KINEMATIC STORAGE WEIGHT (',g0,') SPECIFIED.')"
779 character(len=*),
parameter :: fmtsfrbin = &
780 "(4x, 'SFR ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, /4x, &
781 &'OPENED ON UNIT: ', I0)"
782 integer(I4B) :: isize
785 call this%BndExtType%source_options()
787 write (this%iout,
'(/1x,a)') &
788 'PROCESSING '//trim(adjustl(this%text))//
' OPTIONS'
791 call mem_set_value(this%istorage,
'STORAGE', this%input_mempath, found)
793 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
794 ' REACH STORAGE IS ACTIVE.'
799 this%input_mempath, found)
801 if (this%ats_courant <=
dzero)
then
802 write (
errmsg,
'(a,g0,a)') &
803 "ATS_COURANT SPECIFIED TO BE '", this%ats_courant, &
804 "' BUT MUST BE GREATER THAN ZERO"
808 write (this%iout,
'(4x,a,1pg15.6)') &
809 'TARGET COURANT NUMBER FOR ADAPTIVE TIME STEPS: ', &
815 call mem_set_value(this%iprhed,
'PRINT_STAGE', this%input_mempath, found)
817 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
818 ' STAGES WILL BE PRINTED TO LISTING FILE.'
822 call mem_set_value(fname,
'STAGEFILE', this%input_mempath, found)
825 call openfile(this%istageout, this%iout, fname,
'DATA(BINARY)', &
827 write (this%iout, fmtsfrbin)
'STAGE', trim(fname), this%istageout
831 call mem_set_value(fname,
'BUDGETFILE', this%input_mempath, found)
833 call assign_iounit(this%ibudgetout, this%inunit,
'BUDGET fileout')
834 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
836 write (this%iout, fmtsfrbin)
'BUDGET', trim(fname), this%ibudgetout
840 call mem_set_value(fname,
'BUDGETCSVFILE', this%input_mempath, found)
842 call assign_iounit(this%ibudcsv, this%inunit,
'BUDGETCSV fileout')
843 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
844 filstat_opt=
'REPLACE')
845 write (this%iout, fmtsfrbin)
'BUDGET CSV', trim(fname), this%ibudcsv
849 call mem_set_value(fname,
'PKGCONVFNAME', this%input_mempath, found)
852 call openfile(this%ipakcsv, this%iout, fname,
'CSV', &
853 filstat_opt=
'REPLACE', mode_opt=
mnormal)
854 write (this%iout, fmtsfrbin)
'PACKAGE_CONVERGENCE', trim(fname), &
859 call mem_set_value(this%imover,
'MOVER', this%input_mempath, found)
861 write (this%iout,
'(4x,A)')
'MOVER OPTION ENABLED'
866 this%input_mempath, found)
867 if (found)
write (this%iout, fmtpicard) this%maxsfrpicard
871 this%input_mempath, found)
872 if (found)
write (this%iout, fmtiter) this%maxsfrit
876 this%input_mempath, found)
878 this%deps =
dp999 * this%dmaxchg
879 write (this%iout, fmtdmaxchg) this%dmaxchg
884 this%input_mempath, found)
885 if (found)
write (this%iout, fmtlengthconv) this%lengthconv
889 this%input_mempath, found)
890 if (found)
write (this%iout, fmttimeconv) this%timeconv
894 this%input_mempath, found)
896 write (
warnmsg,
'(a)')
'SETTING UNIT_CONVERSION DIRECTLY'
903 this%input_mempath, found)
905 if (this%storage_weight <
dhalf .or. this%storage_weight >
done)
then
906 write (
errmsg,
'(a,g0,a)') &
907 "STORAGE_WEIGHT SPECIFIED TO BE '", this%storage_weight, &
908 "' BUT CANNOT BE LESS THAN 0.5 OR GREATER THAN 1.0"
912 write (this%iout, fmtstoweight) this%storage_weight
917 call get_isize(
'ICHECK', this%input_mempath, isize)
920 write (this%iout,
'(4x,a)') &
921 'REACH GEOMETRY AND PARAMETER CHECKS WILL NOT BE MADE'
925 call get_isize(
'ICONVCHK', this%input_mempath, isize)
928 write (this%iout,
'(4x,a)') &
929 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN STREAM FLOW ROUTING '// &
930 'STAGES AND FLOWS WILL NOT BE MADE'
933 write (this%iout,
'(1x,a)') &
934 'END OF '//trim(adjustl(this%text))//
' OPTIONS'
935 end subroutine sfr_source_options
939 subroutine sfr_source_dimensions(this)
943 class(sfrtype),
intent(inout) :: this
945 logical(LGP) :: found
950 write (this%iout,
'(/1x,a)') &
951 'PROCESSING '//trim(adjustl(this%text))//
' DIMENSIONS'
954 call mem_set_value(this%maxbound,
'MAXBOUND', this%input_mempath, found, &
957 write (this%iout,
'(4x,a,i0)')
'NREACHES = ', this%maxbound
960 write (this%iout,
'(1x,a)') &
961 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
963 if (this%maxbound < 1)
then
965 'NREACHES was not specified or was specified incorrectly.'
974 call this%define_listlabel()
977 this%ncrossptstot = this%maxbound
980 call this%sfr_allocate_arrays()
983 call this%sfr_source_packagedata()
986 call this%sfr_source_crosssections()
989 call this%sfr_source_connectiondata()
992 call this%sfr_source_diversions()
995 call this%sfr_checkin_deprecated_names()
998 call this%sfr_source_initialstages()
1001 call this%sfr_setup_budobj()
1004 call this%sfr_setup_tableobj()
1005 end subroutine sfr_source_dimensions
1009 subroutine sfr_source_packagedata(this)
1014 class(sfrtype),
intent(inout) :: this
1016 integer(I4B) :: i, n, nconzero
1017 integer(I4B) :: ipos
1018 character(len=10) :: cnum
1019 character(len=LENBOUNDNAME) :: bndName
1020 character(len=LINELENGTH) :: cellid_str
1021 integer(I4B),
allocatable :: nboundchk(:)
1022 integer(I4B),
dimension(:),
pointer,
contiguous :: ifno => null()
1023 integer(I4B),
dimension(:, :),
pointer,
contiguous :: cellid => null()
1024 real(DP),
dimension(:),
pointer,
contiguous :: rlen => null()
1025 real(DP),
dimension(:),
pointer,
contiguous :: rwid => null()
1026 real(DP),
dimension(:),
pointer,
contiguous :: rgrd => null()
1027 real(DP),
dimension(:),
pointer,
contiguous :: rtp => null()
1028 real(DP),
dimension(:),
pointer,
contiguous :: rbth => null()
1029 integer(I4B),
dimension(:),
pointer,
contiguous :: ncon => null()
1030 integer(I4B),
dimension(:),
pointer,
contiguous :: ndv => null()
1033 integer(I4B),
dimension(:, :),
pointer,
contiguous :: tslink => null()
1035 tslinkvars => null()
1037 write (this%iout,
'(/1x,a)') &
1038 'PROCESSING '//trim(adjustl(this%text))//
' PACKAGEDATA'
1041 call mem_setptr(ifno,
'PACKAGEDATA_IFNO', this%input_mempath)
1042 call mem_setptr(cellid,
'CELLID', this%input_mempath)
1043 call mem_setptr(rlen,
'RLEN', this%input_mempath)
1044 call mem_setptr(rwid,
'RWID', this%input_mempath)
1045 call mem_setptr(rgrd,
'RGRD', this%input_mempath)
1046 call mem_setptr(rtp,
'RTP', this%input_mempath)
1047 call mem_setptr(rbth,
'RBTH', this%input_mempath)
1048 call mem_setptr(this%input%rhk,
'RHK', this%input_mempath)
1049 call mem_setptr(this%input%man,
'MAN', this%input_mempath)
1050 call mem_setptr(ncon,
'NCON', this%input_mempath)
1051 call mem_setptr(this%input%ustrf,
'USTRF', this%input_mempath)
1052 call mem_setptr(tslink,
'TSLINK_PD', this%input_mempath)
1053 call mem_setptr(tslinkvars,
'TSLINKVARS_PD', this%input_mempath)
1054 do n = 1,
size(tslinkvars)
1055 if (tslinkvars(n) ==
'RHK') this%input%rhk_tslink => tslink(n, :)
1056 if (tslinkvars(n) ==
'MAN') this%input%man_tslink => tslink(n, :)
1057 if (tslinkvars(n) ==
'USTRF') this%input%ustrf_tslink => tslink(n, :)
1059 if (.not. (
associated(this%input%rhk_tslink) .and. &
1060 associated(this%input%man_tslink) .and. &
1061 associated(this%input%ustrf_tslink)))
then
1062 call store_error(
'Time series links for RHK, MAN and USTRF not found &
1066 call mem_setptr(ndv,
'NDV', this%input_mempath)
1067 if (this%inamedbound /= 0)
then
1068 call mem_setptr(boundname,
'BOUNDNAME', this%input_mempath)
1072 allocate (nboundchk(this%maxbound))
1077 do i = 1, this%maxbound
1080 n = this%validate_ifno(n, this%maxbound, nboundchk, &
1081 'rno',
'PACKAGEDATA')
1086 if (all(cellid(1:this%dis%ndim, i) <= 0))
then
1087 this%igwfnode(n) = 0
1089 write (cellid_str,
'(10(i0,1x))') cellid(1:this%dis%ndim, i)
1090 this%igwfnode(n) = this%dis%noder_from_cellid(cellid_str, &
1091 this%inunit, this%iout, &
1092 flag_string=.false., &
1095 this%igwftopnode(n) = this%igwfnode(n)
1096 if (this%igwfnode(n) < 1) this%ianynone = this%ianynone + 1
1099 this%length(n) = rlen(i)
1100 this%width(n) = rwid(i)
1101 this%slope(n) = rgrd(i)
1102 this%strtop(n) = rtp(i)
1103 this%bthick(n) = rbth(i)
1106 this%nconnreach(n) = ncon(i)
1107 this%nconn = this%nconn + ncon(i)
1108 if (ncon(i) < 0)
then
1109 write (
errmsg,
'(a,1x,i0,1x,a,i0,a)') &
1110 'NCON for reach', n, &
1111 'must be greater than or equal to 0 (', ncon(i),
').'
1113 else if (ncon(i) == 0)
then
1114 nconzero = nconzero + 1
1118 this%ndiv(n) = ndv(i)
1119 if (ndv(i) > 0) this%idiversions = 1
1122 write (cnum,
'(i10.10)') n
1123 bndname =
'Reach'//cnum
1124 if (this%inamedbound /= 0)
then
1125 bndname = boundname(i)
1127 this%sfrname(n) = bndname
1131 this%hk(n) = this%input%rhk(i)
1132 this%rough(n) = this%input%man(i)
1133 this%ustrf(n) = this%input%ustrf(i)
1136 this%sstage(n) = this%strtop(n)
1139 write (this%iout,
'(1x,a)') &
1140 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1143 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1145 deallocate (nboundchk)
1147 if (nconzero > 0)
then
1148 write (
warnmsg,
'(a,1x,a,1x,a,1x,i0,1x,a)') &
1149 'SFR Package', trim(this%packName), &
1150 'has', nconzero,
'reach(es) with zero connections.'
1160 this%iacross(1) = ipos
1161 do i = 1, this%maxbound
1162 this%ncrosspts(i) = 1
1163 this%station(ipos) = this%width(i)
1164 this%xsheight(ipos) =
dzero
1165 this%xsrough(ipos) =
done
1167 this%iacross(i + 1) = ipos
1181 end subroutine sfr_source_packagedata
1185 subroutine sfr_source_crosssections(this)
1192 class(sfrtype),
intent(inout) :: this
1194 integer(I4B),
dimension(:),
pointer,
contiguous :: ifno => null()
1196 tab6_filename => null()
1198 sfrtab6_mempaths => null()
1200 integer(I4B) :: i, n, ncrossptstot
1201 integer(I4B),
allocatable :: nboundchk(:)
1202 integer(I4B) :: isize
1203 character(len=LINELENGTH) :: tabfname
1204 character(len=LENMEMPATH) :: mempath
1207 call get_isize(
'CROSSSECT_IFNO', this%input_mempath, isize)
1208 if (isize < 1)
return
1210 write (this%iout,
'(/1x,a)') &
1211 'PROCESSING '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1214 call mem_setptr(ifno,
'CROSSSECT_IFNO', this%input_mempath)
1215 call mem_setptr(tab6_filename,
'SFRTAB6_FILENAME', this%input_mempath)
1216 call mem_setptr(sfrtab6_mempaths,
'SFRTAB6_MEMPATH', this%input_mempath)
1220 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1221 this%iacross, this%station, this%xsheight, &
1224 allocate (nboundchk(this%maxbound))
1228 n = this%validate_ifno(ifno(i), this%maxbound, nboundchk, &
1229 'reach',
'CROSSSECTIONS')
1231 tabfname = tab6_filename(i)
1232 mempath = sfrtab6_mempaths(i)
1233 call cross_data%source_table(n, this%width(n), mempath, &
1234 trim(adjustl(tabfname)))
1237 write (this%iout,
'(1x,a)') &
1238 'END OF '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1241 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1242 'CROSSSECTIONS', check_missing=.false.)
1243 deallocate (nboundchk)
1250 ncrossptstot = cross_data%get_ncrossptstot()
1251 if (ncrossptstot /= this%ncrossptstot)
then
1252 this%ncrossptstot = ncrossptstot
1253 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
1255 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
1257 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
1261 call cross_data%output(this%width, this%rough)
1262 call cross_data%pack(this%ncrossptstot, this%ncrosspts, this%iacross, &
1263 this%station, this%xsheight, this%xsrough)
1264 call cross_data%destroy()
1265 deallocate (cross_data)
1266 nullify (cross_data)
1271 end subroutine sfr_source_crosssections
1275 subroutine sfr_source_connectiondata(this)
1280 class(sfrtype),
intent(inout) :: this
1282 integer(I4B),
dimension(:),
pointer,
contiguous :: cd_ifno => null()
1283 integer(I4B),
dimension(:),
pointer,
contiguous :: ic_flat => null()
1284 integer(I4B),
dimension(:),
pointer,
contiguous :: cd_ia => null()
1286 integer(I4B),
dimension(:),
pointer,
contiguous :: rowmaxnnz => null()
1287 integer(I4B),
allocatable :: nboundchk(:)
1288 integer(I4B),
allocatable :: iconndata(:, :)
1289 integer(I4B),
allocatable :: iup(:)
1290 integer(I4B),
allocatable :: order(:)
1291 type(
dag) :: sfr_dag
1292 integer(I4B) :: i, n, j, jj, jcol, jcol2, nja, nconnmax
1293 integer(I4B) :: ival, idir, nup, ipos, istat, ierr, jlocal, nread
1295 write (this%iout,
'(/1x,a)') &
1296 'PROCESSING '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1299 call mem_setptr(cd_ifno,
'CONNDATA_IFNO', this%input_mempath)
1300 call mem_setptr(ic_flat,
'IC', this%input_mempath)
1301 call mem_setptr(cd_ia,
'IC_IA', this%input_mempath)
1304 allocate (nboundchk(this%maxbound))
1310 allocate (rowmaxnnz(this%maxbound))
1311 do n = 1, this%maxbound
1312 ival = this%nconnreach(n)
1313 if (ival < 0) ival = 0
1314 rowmaxnnz(n) = ival + 1
1315 nja = nja + ival + 1
1316 if (ival > nconnmax) nconnmax = ival
1329 allocate (iconndata(nconnmax, this%maxbound))
1333 call sparse%init(this%maxbound, this%maxbound, rowmaxnnz)
1336 do i = 1, this%maxbound
1337 n = this%validate_ifno(cd_ifno(i), this%maxbound, nboundchk, &
1338 'reach',
'CONNECTIONDATA')
1340 nread = cd_ia(i + 1) - cd_ia(i)
1341 if (nread /= this%nconnreach(n))
then
1342 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,a)') &
1343 'Reach', n,
'connectiondata specifies', nread, &
1344 'connections but NCON for this reach in packagedata is', &
1345 this%nconnreach(n),
'.'
1349 call sparse%addconnection(n, n, 1)
1351 do j = cd_ia(i), cd_ia(i + 1) - 1
1354 iconndata(jlocal, n) = ival
1358 else if (ival == 0)
then
1359 call store_error(
'Missing or zero connection reach in connectiondata.')
1364 if (ival > this%maxbound)
then
1365 call store_error(
'Reach number exceeds NREACHES in connectiondata.')
1368 call sparse%addconnection(n, ival, 1)
1372 write (this%iout,
'(1x,a)') &
1373 'END OF '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1375 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1383 call sparse%filliaja(this%ia, this%ja, ierr, sort=.true.)
1385 write (
errmsg,
'(a,3(1x,a))') &
1386 'Could not fill', trim(this%packName), &
1387 'package IA and JA connection data.', &
1388 'Check connectivity data in connectiondata block.'
1393 do n = 1, this%maxbound
1394 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1396 do jj = 1, this%nconnreach(n)
1397 jcol2 = iconndata(jj, n)
1398 if (abs(jcol2) == jcol)
then
1400 if (jcol2 < 0) idir = -1
1409 deallocate (rowmaxnnz)
1410 deallocate (nboundchk)
1411 deallocate (iconndata)
1412 call sparse%destroy()
1416 call sfr_dag%set_vertices(this%maxbound)
1417 fill_dag:
do n = 1, this%maxbound
1419 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1420 if (this%idir(j) > 0) nup = nup + 1
1422 if (nup == 0) cycle fill_dag
1425 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1426 if (this%idir(j) > 0)
then
1427 iup(ipos) = this%ja(j)
1431 call sfr_dag%set_edges(n, iup)
1434 call sfr_dag%toposort(order, istat)
1435 if (istat == -1)
then
1437 trim(adjustl(this%text))//
' PACKAGE ('// &
1438 trim(adjustl(this%packName))//
') cannot calculate a '// &
1439 'Directed Asyclic Graph for reach connectivity because '// &
1440 'of circular dependency. Using the reach number for '// &
1441 'solution ordering.'
1444 do n = 1, this%maxbound
1445 if (istat == 0)
then
1446 this%isfrorder(n) = order(n)
1448 this%isfrorder(n) = n
1451 call sfr_dag%destroy()
1452 if (istat == 0)
deallocate (order)
1458 end subroutine sfr_source_connectiondata
1462 subroutine sfr_source_diversions(this)
1467 class(sfrtype),
intent(inout) :: this
1469 integer(I4B),
dimension(:),
pointer,
contiguous :: d_ifno => null()
1470 integer(I4B),
dimension(:),
pointer,
contiguous :: d_idv => null()
1471 integer(I4B),
dimension(:),
pointer,
contiguous :: d_iconr => null()
1474 integer(I4B) :: i, n, idiv, ndiversions, i0, ipos, jpos
1475 integer(I4B) :: isize
1476 integer(I4B),
allocatable :: iachk(:), nboundchk(:)
1477 character(len=16) :: cval
1483 do n = 1, this%maxbound
1484 ndiversions = ndiversions + this%ndiv(n)
1485 i0 = i0 + this%ndiv(n)
1486 this%iadiv(n + 1) = i0
1490 if (ndiversions > 0)
then
1493 allocate (this%divcprior(ndiversions))
1494 call mem_setptr(this%divflow,
'DIVFLOW', this%input_mempath)
1495 call mem_reallocate(this%divq, ndiversions,
'DIVQ', this%memoryPath)
1500 call get_isize(
'DIVERSIONS_IFNO', this%input_mempath, isize)
1502 if (this%idiversions /= 0)
then
1503 call store_error(
'REQUIRED DIVERSIONS BLOCK NOT FOUND.')
1509 if (this%idiversions == 0)
then
1510 write (
errmsg,
'(a,1x,a)') &
1511 'A diversions block should not be', &
1512 'specified if diversions are not specified.'
1518 write (this%iout,
'(/1x,a)') &
1519 'PROCESSING '//trim(adjustl(this%text))//
' DIVERSIONS'
1522 call mem_setptr(d_ifno,
'DIVERSIONS_IFNO', this%input_mempath)
1523 call mem_setptr(d_idv,
'DIVERSIONS_IDV', this%input_mempath)
1524 call mem_setptr(d_iconr,
'ICONR', this%input_mempath)
1525 call mem_setptr(d_cprior,
'CPRIOR', this%input_mempath)
1528 allocate (iachk(this%maxbound + 1))
1529 allocate (nboundchk(ndiversions))
1532 do n = 1, this%maxbound
1533 iachk(n + 1) = iachk(n) + this%ndiv(n)
1538 if (n < 1 .or. n > this%maxbound)
then
1539 write (
errmsg,
'(a,i0,a)')
'Reach number should be between 1 and ', &
1544 if (this%ndiv(n) < 1)
then
1545 write (
errmsg,
'(a,i0)') &
1546 'Diversions cannot be specified for reach ', n
1551 if (idiv < 1 .or. idiv > this%ndiv(n))
then
1552 write (
errmsg,
'(a,i0,a,i0,a)') &
1553 'Reach ', n,
' diversion number should be between 1 and ', &
1558 ipos = iachk(n) + idiv - 1
1559 nboundchk(ipos) = nboundchk(ipos) + 1
1560 jpos = this%iadiv(n) + idiv - 1
1561 if (d_iconr(i) < 1 .or. d_iconr(i) > this%maxbound)
then
1562 write (
errmsg,
'(a,i0,a)') &
1563 'Diversion target reach number should be between 1 and ', &
1568 this%divreach(jpos) = d_iconr(i)
1570 select case (trim(cval))
1571 case (
'UPTO',
'THRESHOLD',
'FRACTION',
'EXCESS')
1573 errmsg =
'Invalid cprior type '//trim(cval)//
'.'
1576 this%divcprior(jpos) = trim(cval)
1579 write (this%iout,
'(1x,a)') &
1580 'END OF '//trim(adjustl(this%text))//
' DIVERSIONS'
1582 do n = 1, this%maxbound
1583 do idiv = 1, this%ndiv(n)
1584 ipos = iachk(n) + idiv - 1
1585 if (nboundchk(ipos) == 0)
then
1586 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1587 'No data specified for reach', n,
'diversion', idiv
1589 else if (nboundchk(ipos) > 1)
then
1590 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1591 'Data for reach', n,
'diversion', idiv, &
1592 'specified', nboundchk(ipos),
'times'
1598 deallocate (nboundchk)
1609 end subroutine sfr_source_diversions
1613 subroutine sfr_source_initialstages(this)
1617 class(sfrtype),
intent(inout) :: this
1619 integer(I4B),
dimension(:),
pointer,
contiguous :: is_ifno => null()
1620 real(DP),
dimension(:),
pointer,
contiguous :: is_stage => null()
1621 integer(I4B) :: i, n
1622 integer(I4B) :: isize
1623 integer(I4B),
allocatable :: nboundchk(:)
1627 call get_isize(
'INITSTAGE_IFNO', this%input_mempath, isize)
1630 if (this%istorage == 1)
then
1631 do n = 1, this%maxbound
1632 this%stage(n) = this%strtop(n)
1638 write (this%iout,
'(/1x,a)') &
1639 'PROCESSING '//trim(adjustl(this%text))//
' INITIALSTAGES'
1641 call mem_setptr(is_ifno,
'INITSTAGE_IFNO', this%input_mempath)
1642 call mem_setptr(is_stage,
'INITIALSTAGE', this%input_mempath)
1644 allocate (nboundchk(this%maxbound))
1648 n = this%validate_ifno(is_ifno(i), this%maxbound, nboundchk, &
1649 'reach',
'INITIALSTAGES')
1652 this%stage(n) = rval
1653 this%depth(n) = rval - this%strtop(n)
1654 if (rval < this%strtop(n))
then
1655 write (
errmsg,
'(a,g0,a,1x,i0,1x,a,g0,a)') &
1656 'Initial stage (', rval,
') for reach', n, &
1657 'is less than the reach top (', this%strtop(n),
').'
1662 write (this%iout,
'(1x,a)') &
1663 'END OF '//trim(adjustl(this%text))//
' INITIALSTAGES'
1665 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1667 deallocate (nboundchk)
1676 end subroutine sfr_source_initialstages
1682 subroutine sfr_ar(this)
1686 class(sfrtype),
intent(inout) :: this
1689 integer(I4B) :: ierr
1692 call this%obs%obs_ar()
1695 call this%BndExtType%allocate_arrays()
1699 call this%BndExtType%allocate_featureauxvar()
1703 call this%input%init(this%input_mempath, this%naux)
1706 if (this%inamedbound /= 0)
then
1707 do n = 1, this%maxbound
1708 this%boundname(n) = this%sfrname(n)
1713 call this%copy_boundname()
1716 do n = 1, this%maxbound
1717 this%nodelist(n) = this%igwfnode(n)
1721 call this%sfr_check_conversion()
1724 call this%sfr_check_storage_weight()
1727 if (this%ats_courant /=
dnodata .and. this%istorage /= 1)
then
1729 'ATS_COURANT OPTION REQUIRES STORAGE OPTION TO BE ACTIVE'
1736 'ATS_COURANT IS SPECIFIED IN THE SFR OPTIONS BLOCK BUT THE '// &
1737 'ATS PACKAGE IS NOT ACTIVE IN TDIS, SO THE TIME STEP IS NOT '// &
1738 'ADAPTED TO THE COURANT NUMBER. IF THE COURANT NUMBER EXCEEDS 1 '// &
1739 'THE EXPLICIT KINEMATIC-WAVE ROUTING MAY OSCILLATE WHILE STILL '// &
1740 'CLOSING THE BUDGET. ACTIVATE THE ATS PACKAGE OR USE A SMALLER '// &
1746 if (this%ats_courant /=
dnodata .and. this%istorage == 1)
then
1747 call this%sfr_precompute_tvd()
1751 call this%sfr_check_reaches()
1754 call this%sfr_check_connections()
1757 if (this%idiversions /= 0)
then
1758 call this%sfr_check_diversions()
1762 if (this%istorage == 1)
then
1763 call this%sfr_check_initialstages()
1773 if (this%imover /= 0)
then
1774 allocate (this%pakmvrobj)
1775 call this%pakmvrobj%ar(this%maxbound, this%maxbound, this%memoryPath)
1777 end subroutine sfr_ar
1783 subroutine sfr_rp(this)
1790 class(sfrtype),
intent(inout) :: this
1792 character(len=LINELENGTH) :: crossfile
1793 character(len=LINELENGTH) :: str
1794 real(DP) :: auxvaldbl
1795 character(len=LINELENGTH) :: title
1796 character(len=LINELENGTH) :: text
1797 character(len=LENVARNAME) :: setting
1798 character(len=10) :: cnum
1799 character(len=10) :: cp
1804 integer(I4B) :: idiv
1805 integer(I4B) :: ichkustrm
1806 integer(I4B) :: ncrossptstot
1809 character(len=*),
parameter :: fmtlsp = &
1810 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
1819 this%nbound = this%maxbound
1822 if (this%iper ==
kper)
then
1826 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1828 this%station, this%xsheight, &
1832 if (this%iprpak /= 0)
then
1833 title = trim(adjustl(this%text))//
' PACKAGE ('// &
1834 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
1835 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
1836 call table_cr(this%inputtab, this%packName, title)
1837 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
1839 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
1841 call this%inputtab%initialize_column(text, 20, alignment=tableft)
1843 write (text,
'(a,1x,i6)')
'VALUE', jj
1844 call this%inputtab%initialize_column(text, 15, alignment=tabcenter)
1849 do i = 1, this%input%nbound
1850 n = this%input%ifno(i)
1851 if (n < 1 .or. n > this%maxbound)
then
1852 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
1853 'Reach number (RNO) must be greater than 0 and', &
1854 'less than or equal to', this%maxbound,
'.'
1860 setting = this%input%setting(i)
1863 if (trim(setting) ==
'STATUS')
then
1864 str = this%input%status(i)
1866 if (str ==
'INACTIVE')
then
1867 this%iboundpak(n) = 0
1868 else if (str ==
'ACTIVE')
then
1869 this%iboundpak(n) = 1
1870 else if (str ==
'SIMPLE')
then
1871 this%iboundpak(n) = -1
1874 'Unknown '//trim(this%text)//
' sfr status keyword: ', trim(str)
1881 call this%sfr_set_period_value(i, n, setting)
1882 if (trim(setting) ==
'UPSTREAM_FRAC') ichkustrm = 1
1885 if (trim(setting) ==
'DIVERSION')
then
1886 if (this%ndiv(n) < 1)
then
1887 write (cnum,
'(i0)') n
1888 errmsg =
'diversions cannot be specified for reach '//trim(cnum)
1891 idiv = this%input%idv(i)
1892 if (idiv < 1 .or. idiv > this%ndiv(n))
then
1893 write (cnum,
'(i0)') n
1894 errmsg =
'Reach '//trim(cnum)
1895 write (cnum,
'(i0)') this%ndiv(n)
1896 errmsg = trim(
errmsg)//
' diversion number should be between 1 '// &
1897 'and '//trim(cnum)//
'.'
1900 ii = this%iadiv(n) + idiv - 1
1902 cp = this%divcprior(ii)
1903 if (cp ==
'FRACTION' .and. &
1904 (this%divflow(ii) < dzero .or. this%divflow(ii) > done))
then
1905 write (
errmsg,
'(a,1x,i0,a)') &
1906 'cprior is type FRACTION for diversion no.', ii, &
1907 ', but divflow not within the range 0.0 to 1.0'
1915 if (trim(setting) ==
'CROSS_SECTION')
then
1916 crossfile = this%input%tab6_filename(i)
1917 call cross_data%read_table(n, this%width(n), trim(adjustl(crossfile)))
1922 if (this%naux > 0)
then
1923 if (trim(setting) ==
'PERIOD_AUXILIARY')
then
1924 str = this%input%auxname(i)
1925 auxvaldbl = this%input%auxval(i)
1930 if (this%iprpak /= 0)
then
1931 call this%inputtab%add_term(n)
1932 if (trim(setting) ==
'PERIOD_AUXILIARY')
then
1933 call this%inputtab%add_term(
'AUXILIARY')
1935 call this%inputtab%add_term(trim(setting))
1937 select case (trim(setting))
1939 call this%inputtab%add_term(trim(str))
1940 call this%inputtab%add_term(
' ')
1942 call this%inputtab%add_term(this%hk(n))
1943 call this%inputtab%add_term(
' ')
1945 call this%inputtab%add_term(this%rough(n))
1946 call this%inputtab%add_term(
' ')
1948 call this%inputtab%add_term(this%sstage(n))
1949 call this%inputtab%add_term(
' ')
1951 call this%inputtab%add_term(this%inflow(n))
1952 call this%inputtab%add_term(
' ')
1954 call this%inputtab%add_term(this%rain(n))
1955 call this%inputtab%add_term(
' ')
1956 case (
'EVAPORATION')
1957 call this%inputtab%add_term(this%evap(n))
1958 call this%inputtab%add_term(
' ')
1960 call this%inputtab%add_term(this%runoff(n))
1961 call this%inputtab%add_term(
' ')
1962 case (
'UPSTREAM_FRAC')
1963 call this%inputtab%add_term(this%ustrf(n))
1964 call this%inputtab%add_term(
' ')
1966 call this%inputtab%add_term(idiv)
1967 call this%inputtab%add_term(this%divflow(ii))
1968 case (
'CROSS_SECTION')
1969 call this%inputtab%add_term(trim(crossfile))
1970 call this%inputtab%add_term(
' ')
1971 case (
'PERIOD_AUXILIARY')
1972 call this%inputtab%add_term(trim(str))
1973 call this%inputtab%add_term(auxvaldbl)
1975 call this%inputtab%add_term(
' ')
1976 call this%inputtab%add_term(
' ')
1980 if (this%iprpak /= 0)
then
1981 call this%inputtab%finalize_table()
1985 ncrossptstot = cross_data%get_ncrossptstot()
1988 if (ncrossptstot /= this%ncrossptstot)
then
1989 this%ncrossptstot = ncrossptstot
1990 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
1992 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
1994 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
1999 call cross_data%output(this%width, this%rough, kstp=1,
kper=
kper)
2002 call cross_data%pack(this%ncrossptstot, this%ncrosspts, &
2009 call cross_data%destroy()
2010 deallocate (cross_data)
2011 nullify (cross_data)
2013 write (this%iout, fmtlsp) trim(this%filtyp)
2018 if (ichkustrm /= 0)
then
2019 call this%sfr_check_ustrf()
2026 end subroutine sfr_rp
2033 subroutine sfr_ad(this)
2037 class(sfrtype) :: this
2042 integer(I4B) :: idiv
2043 integer(I4B) :: iaux
2044 character(len=LENVARNAME) :: setting
2048 call this%BndExtType%bnd_ad()
2051 if (this%istorage == 1)
then
2052 do n = 1, this%maxbound
2053 this%stageold(n) = this%stage(n)
2054 this%usinflowold(n) = this%usinflow(n)
2055 this%dsflowold(n) = this%dsflow(n)
2062 if (this%ts_active)
then
2063 do i = 1, this%maxbound
2064 n = this%pkg_ifno(i)
2065 if (.not. this%bedk_set(n) .and. &
2066 this%input%rhk_tslink(i) /= 0) &
2067 this%hk(n) = this%input%rhk(i)
2068 if (.not. this%manning_set(n) .and. &
2069 this%input%man_tslink(i) /= 0) &
2070 this%rough(n) = this%input%man(i)
2071 if (.not. this%ustrf_set(n) .and. &
2072 this%input%ustrf_tslink(i) /= 0) &
2073 this%ustrf(n) = this%input%ustrf(i)
2076 if (this%input%nbound > 0)
then
2077 do i = 1, this%input%nbound
2078 n = this%input%ifno(i)
2079 if (n < 1 .or. n > this%maxbound) cycle
2081 setting = this%input%setting(i)
2082 call this%sfr_set_period_value(i, n, setting)
2084 if (trim(setting) ==
'DIVERSION')
then
2085 if (this%ndiv(n) >= 1)
then
2086 idiv = this%input%idv(i)
2087 if (idiv >= 1 .and. idiv <= this%ndiv(n))
then
2088 ii = this%iadiv(n) + idiv - 1
2098 if (this%ts_active)
call this%sfr_check_ustrf()
2103 if (this%naux > 0)
then
2104 do n = 1, this%maxbound
2105 do iaux = 1, this%naux
2106 if (this%noupdateauxvar(iaux) /= 0) cycle
2107 this%auxvar(iaux, n) = this%featureauxvar(iaux, n)
2113 do n = 1, this%maxbound
2114 this%usflow(n) = dzero
2115 if (this%iboundpak(n) < 0)
then
2116 this%stage(n) = this%sstage(n)
2121 if (this%imover == 1)
then
2122 call this%pakmvrobj%ad()
2124 end subroutine sfr_ad
2131 subroutine sfr_cf(this)
2133 class(sfrtype) :: this
2136 integer(I4B) :: igwfnode
2139 if (this%nbound == 0)
return
2142 do n = 1, this%nbound
2143 igwfnode = this%igwftopnode(n)
2144 if (igwfnode > 0)
then
2145 if (this%ibound(igwfnode) == 0)
then
2146 call this%dis%highest_active(igwfnode, this%ibound)
2149 this%igwfnode(n) = igwfnode
2150 this%nodelist(n) = igwfnode
2152 end subroutine sfr_cf
2159 subroutine sfr_fc(this, rhs, ia, idxglo, matrix_sln)
2161 class(sfrtype) :: this
2162 real(DP),
dimension(:),
intent(inout) :: rhs
2163 integer(I4B),
dimension(:),
intent(in) :: ia
2164 integer(I4B),
dimension(:),
intent(in) :: idxglo
2170 integer(I4B) :: ipos
2171 integer(I4B) :: node
2182 sfrpicard:
do i = 1, this%maxsfrpicard
2188 if (this%imover == 1)
then
2189 call this%pakmvrobj%fc()
2193 reachsolve:
do j = 1, this%nbound
2194 n = this%isfrorder(j)
2195 node = this%igwfnode(n)
2197 hgwf = this%xnew(node)
2204 this%stage0(n) = this%stage(n)
2205 this%usflow0(n) = this%usflow(n)
2212 if (this%iboundpak(n) /= 0)
then
2213 call this%sfr_solve(n, hgwf, hhcof, rrhs)
2215 this%depth(n) =
dzero
2216 this%stage(n) = this%strtop(n)
2218 call this%sfr_update_flows(n, v, v)
2224 this%hcof(n) = hhcof
2228 ds = s0 - this%stage(n)
2231 if (abs(ds) > abs(dsmax))
then
2238 if (abs(dsmax) <= this%dmaxchg)
then
2245 do n = 1, this%nbound
2246 node = this%nodelist(n)
2248 rhs(node) = rhs(node) + this%rhs(n)
2250 call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(n))
2252 end subroutine sfr_fc
2259 subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
2261 class(sfrtype) :: this
2262 real(DP),
dimension(:),
intent(inout) :: rhs
2263 integer(I4B),
dimension(:),
intent(in) :: ia
2264 integer(I4B),
dimension(:),
intent(in) :: idxglo
2270 integer(I4B) :: ipos
2280 do j = 1, this%nbound
2281 i = this%isfrorder(j)
2283 if (this%iboundpak(i) < 1) cycle
2285 n = this%nodelist(i)
2288 rterm = this%hcof(i) * this%xnew(n)
2290 hgwf = this%xnew(n) +
dem4
2291 call this%sfr_solve(i, hgwf, hcof1, rhs1, update=.false.)
2292 q1 = rhs1 - hcof1 * hgwf
2294 q2 = this%rhs(i) - this%hcof(i) * this%xnew(n)
2296 drterm = (q2 - q1) /
dem4
2299 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(i))
2300 rhs(n) = rhs(n) - rterm + drterm * this%xnew(n)
2302 end subroutine sfr_fn
2309 subroutine sfr_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
2313 class(sfrtype),
intent(inout) :: this
2314 integer(I4B),
intent(in) :: innertot
2315 integer(I4B),
intent(in) :: kiter
2316 integer(I4B),
intent(in) :: iend
2317 integer(I4B),
intent(in) :: icnvgmod
2318 character(len=LENPAKLOC),
intent(inout) :: cpak
2319 integer(I4B),
intent(inout) :: ipak
2320 real(DP),
intent(inout) :: dpak
2322 character(len=LENPAKLOC) :: cloc
2323 character(len=LINELENGTH) :: tag
2324 integer(I4B) :: icheck
2325 integer(I4B) :: ipakfail
2326 integer(I4B) :: locdhmax
2327 integer(I4B) :: locrmax
2328 integer(I4B) :: locdqfrommvrmax
2329 integer(I4B) :: ntabrows
2330 integer(I4B) :: ntabcols
2334 real(DP) :: qtolfact
2339 real(DP) :: dqfrommvr
2340 real(DP) :: dqfrommvrmax
2343 icheck = this%iconvchk
2351 dqfrommvrmax =
dzero
2355 if (this%ipakcsv == 0)
then
2356 if (icnvgmod == 0)
then
2364 if (.not.
associated(this%pakcsvtab))
then
2369 if (this%imover == 1)
then
2370 ntabcols = ntabcols + 2
2374 call table_cr(this%pakcsvtab, this%packName,
'')
2375 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
2376 lineseparator=.false., separator=
',', &
2380 tag =
'total_inner_iterations'
2381 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2383 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2385 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2387 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2389 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2391 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2393 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2395 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2396 tag =
'dinflowmax_loc'
2397 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2398 if (this%imover == 1)
then
2399 tag =
'dqfrommvrmax'
2400 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2401 tag =
'dqfrommvrmax_loc'
2402 call this%pakcsvtab%initialize_column(tag, 16, alignment=
tableft)
2408 if (icheck /= 0)
then
2409 final_check:
do n = 1, this%maxbound
2410 if (this%iboundpak(n) == 0) cycle
2413 qtolfact =
delt / this%calc_surface_area(n)
2416 dh = this%stage0(n) - this%stage(n)
2419 if (this%gwfiss == 0)
then
2420 r = this%usflow0(n) - this%usflow(n)
2428 if (this%imover == 1)
then
2429 q = this%pakmvrobj%get_qfrommvr(n)
2430 q0 = this%pakmvrobj%get_qfrommvr0(n)
2431 dqfrommvr = qtolfact * (q0 - q)
2440 dqfrommvrmax = dqfrommvr
2443 if (abs(dh) > abs(dhmax))
then
2447 if (abs(r) > abs(rmax))
then
2451 if (abs(dqfrommvr) > abs(dqfrommvrmax))
then
2452 dqfrommvrmax = dqfrommvr
2459 if (abs(dhmax) > abs(dpak))
then
2462 write (cloc,
"(a,'-',a)") trim(this%packName),
'stage'
2465 if (abs(rmax) > abs(dpak))
then
2468 write (cloc,
"(a,'-',a)") trim(this%packName),
'inflow'
2471 if (this%imover == 1)
then
2472 if (abs(dqfrommvrmax) > abs(dpak))
then
2473 ipak = locdqfrommvrmax
2475 write (cloc,
"(a,'-',a)") trim(this%packName),
'qfrommvr'
2481 if (this%ipakcsv /= 0)
then
2484 call this%pakcsvtab%add_term(innertot)
2485 call this%pakcsvtab%add_term(
totim)
2486 call this%pakcsvtab%add_term(
kper)
2487 call this%pakcsvtab%add_term(
kstp)
2488 call this%pakcsvtab%add_term(kiter)
2489 call this%pakcsvtab%add_term(dhmax)
2490 call this%pakcsvtab%add_term(locdhmax)
2491 call this%pakcsvtab%add_term(rmax)
2492 call this%pakcsvtab%add_term(locrmax)
2493 if (this%imover == 1)
then
2494 call this%pakcsvtab%add_term(dqfrommvrmax)
2495 call this%pakcsvtab%add_term(locdqfrommvrmax)
2500 call this%pakcsvtab%finalize_table()
2504 end subroutine sfr_cc
2510 subroutine sfr_cq(this, x, flowja, iadv)
2514 class(sfrtype),
intent(inout) :: this
2515 real(DP),
dimension(:),
intent(in) :: x
2516 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2517 integer(I4B),
optional,
intent(in) :: iadv
2524 real(DP) :: qoutflow
2525 real(DP) :: qfrommvr
2530 call this%BndType%bnd_cq(x, flowja, iadv=1)
2533 do n = 1, this%maxbound
2538 if (this%imover == 1)
then
2539 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
2540 qtomvr = this%pakmvrobj%get_qtomvr(n)
2541 if (qtomvr >
dzero)
then
2547 qext = this%dsflow(n)
2549 if (qext >
dzero)
then
2552 do i = this%ia(n) + 1, this%ia(n + 1) - 1
2553 if (this%idir(i) > 0) cycle
2555 if (this%iboundpak(n2) == 0) cycle
2561 if (qext <
dzero)
then
2562 if (qtomvr <
dzero)
then
2563 qext = qext - qtomvr
2566 qoutflow = this%dsflow(n)
2567 if (qoutflow >
dzero)
then
2568 qoutflow = -qoutflow
2574 this%qextoutflow(n) = qext
2575 this%qoutflow(n) = qoutflow
2580 call this%sfr_fill_budobj()
2581 end subroutine sfr_cq
2587 subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
2591 class(sfrtype) :: this
2592 integer(I4B),
intent(in) :: icbcfl
2593 integer(I4B),
intent(in) :: ibudfl
2595 integer(I4B) :: ibinun
2596 character(len=20),
dimension(:),
allocatable :: cellidstr
2598 integer(I4B) :: node
2602 if (this%ibudgetout /= 0)
then
2603 ibinun = this%ibudgetout
2605 if (icbcfl == 0) ibinun = 0
2606 if (ibinun > 0)
then
2607 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
2612 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
2618 if (this%ianynone > 0)
then
2619 allocate (cellidstr(this%maxbound))
2620 do n = 1, this%maxbound
2621 node = this%igwfnode(n)
2623 call this%dis%noder_to_string(node, cellidstr(n))
2625 cellidstr(n) =
'NONE'
2628 call this%budobj%write_flowtable(this%dis,
kstp,
kper, cellidstr)
2629 deallocate (cellidstr)
2631 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
2634 end subroutine sfr_ot_package_flows
2640 subroutine sfr_ot_dv(this, idvsave, idvprint)
2645 class(sfrtype) :: this
2646 integer(I4B),
intent(in) :: idvsave
2647 integer(I4B),
intent(in) :: idvprint
2649 character(len=20) :: cellid
2650 integer(I4B) :: ibinun
2652 integer(I4B) :: node
2665 if (this%istageout /= 0)
then
2666 ibinun = this%istageout
2668 if (idvsave == 0) ibinun = 0
2671 if (ibinun > 0)
then
2672 do n = 1, this%maxbound
2675 if (this%iboundpak(n) == 0)
then
2677 else if (d ==
dzero)
then
2683 this%maxbound, 1, 1, ibinun)
2687 if (idvprint /= 0 .and. this%iprhed /= 0)
then
2690 call this%stagetab%set_kstpkper(
kstp,
kper)
2693 do n = 1, this%maxbound
2694 node = this%igwfnode(n)
2696 call this%dis%noder_to_string(node, cellid)
2697 hgwf = this%xnew(node)
2701 if (this%inamedbound == 1)
then
2702 call this%stagetab%add_term(this%boundname(n))
2704 call this%stagetab%add_term(n)
2705 call this%stagetab%add_term(cellid)
2706 if (this%iboundpak(n) /= 0)
then
2707 depth = this%depth(n)
2708 stage = this%stage(n)
2709 w = this%calc_top_width_wet(n, depth)
2710 call this%sfr_calc_cond(n, depth, cond, stage, hgwf)
2717 if (depth ==
dzero)
then
2718 call this%stagetab%add_term(
dhdry)
2720 call this%stagetab%add_term(stage)
2722 call this%stagetab%add_term(depth)
2723 call this%stagetab%add_term(w)
2725 if (this%iboundpak(n) /= 0)
then
2726 sbot = this%strtop(n) - this%bthick(n)
2727 if (hgwf < sbot)
then
2732 grad = grad / this%bthick(n)
2736 call this%stagetab%add_term(hgwf)
2737 call this%stagetab%add_term(cond)
2738 call this%stagetab%add_term(grad)
2740 call this%stagetab%add_term(
'--')
2741 call this%stagetab%add_term(
'--')
2742 call this%stagetab%add_term(
'--')
2746 end subroutine sfr_ot_dv
2752 subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
2756 class(sfrtype) :: this
2757 integer(I4B),
intent(in) :: kstp
2758 integer(I4B),
intent(in) :: kper
2759 integer(I4B),
intent(in) :: iout
2760 integer(I4B),
intent(in) :: ibudfl
2762 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
2763 end subroutine sfr_ot_bdsummary
2767 subroutine sfr_fp(this)
2769 class(sfrtype) :: this
2774 if (this%istorage == 1)
then
2775 do n = 1, this%maxbound
2776 if (this%inamedbound == 1)
then
2777 call this%couranttab%add_term(this%boundname(n))
2779 call this%couranttab%add_term(n)
2780 if (this%crmin(n) ==
dep20)
then
2781 call this%couranttab%add_term(
'--')
2783 call this%couranttab%add_term(this%crmin(n))
2785 if (this%crmax(n) <
dzero)
then
2786 call this%couranttab%add_term(
'--')
2788 call this%couranttab%add_term(this%crmax(n))
2790 if (this%crcnt(n) > 0)
then
2791 crmean = this%crsum(n) / real(this%crcnt(n), dp)
2792 call this%couranttab%add_term(crmean)
2794 call this%couranttab%add_term(
'--')
2798 end subroutine sfr_fp
2802 subroutine sfr_dt(this)
2806 class(sfrtype) :: this
2809 integer(I4B) :: nrmin
2810 real(DP) :: celerity
2813 character(len=LINELENGTH) :: msg
2815 if (this%ats_courant ==
dnodata)
return
2816 if (this%istorage /= 1)
return
2821 do n = 1, this%maxbound
2822 call this%sfr_calc_celerity(n, this%dsflow(n), celerity)
2823 if (celerity >
dzero)
then
2824 dt_n = this%ats_courant * this%length(n) / celerity
2825 if (dt_n < dtmin)
then
2833 write (msg,
'(a,i0)') trim(this%packName)//
'-REACH-', nrmin
2834 call ats%ats_submit_delt(
kstp,
kper, dtmin, trim(msg))
2836 end subroutine sfr_dt
2840 subroutine sfr_calc_celerity(this, n, q, celerity)
2842 class(sfrtype) :: this
2843 integer(I4B),
intent(in) :: n
2844 real(DP),
intent(in) :: q
2845 real(DP),
intent(out) :: celerity
2852 call this%sfr_calc_reach_depth(n, q, d)
2854 a = this%calc_area_wet(n, d)
2855 call this%sfr_calc_reach_depth(n, q + this%deps, d)
2856 a2 = this%calc_area_wet(n, d)
2858 celerity = this%deps / (a2 - a)
2861 end subroutine sfr_calc_celerity
2867 subroutine sfr_da(this)
2871 class(sfrtype) :: this
2876 deallocate (this%csfrbudget)
2879 deallocate (this%cauxcbc)
2907 if (this%istorage == 1)
then
2930 nullify (this%inflow)
2931 nullify (this%runoff)
2932 nullify (this%sstage)
2934 nullify (this%rough)
2935 nullify (this%ustrf)
2940 if (
associated(this%divcprior))
then
2941 deallocate (this%divcprior)
2945 if (
associated(this%divflow))
then
2946 if (
size(this%divflow) == 0)
then
2949 nullify (this%divflow)
2963 call this%budobj%budgetobject_da()
2964 deallocate (this%budobj)
2965 nullify (this%budobj)
2968 if (this%iprhed > 0)
then
2969 call this%stagetab%table_da()
2970 deallocate (this%stagetab)
2971 nullify (this%stagetab)
2975 if (
associated(this%couranttab))
then
2976 call this%couranttab%table_da()
2977 deallocate (this%couranttab)
2978 nullify (this%couranttab)
2982 if (this%ipakcsv > 0)
then
2983 if (
associated(this%pakcsvtab))
then
2984 call this%pakcsvtab%table_da()
2985 deallocate (this%pakcsvtab)
2986 nullify (this%pakcsvtab)
3015 nullify (this%gwfiss)
3018 call this%input%destroy()
3021 call this%BndExtType%bnd_da()
3022 end subroutine sfr_da
3028 subroutine sfr_precompute_tvd(this)
3030 class(sfrtype),
intent(inout) :: this
3034 integer(I4B) :: iup_count
3037 do n = 1, this%maxbound
3040 do j = this%ia(n) + 1, this%ia(n + 1) - 1
3041 if (this%idir(j) > 0)
then
3042 iup_count = iup_count + 1
3046 if (iup_count == 1)
then
3047 this%itvd_upstream(n) = m
3049 this%itvd_upstream(n) = 0
3052 end subroutine sfr_precompute_tvd
3059 subroutine define_listlabel(this)
3061 class(sfrtype),
intent(inout) :: this
3064 this%listlabel = trim(this%filtyp)//
' NO.'
3065 if (this%dis%ndim == 3)
then
3066 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
3067 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
3068 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
3069 elseif (this%dis%ndim == 2)
then
3070 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
3071 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
3073 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
3075 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
3076 if (this%inamedbound == 1)
then
3077 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
3079 end subroutine define_listlabel
3091 logical function sfr_obs_supported(this)
3093 class(sfrtype) :: this
3096 sfr_obs_supported = .true.
3097 end function sfr_obs_supported
3103 subroutine sfr_df_obs(this)
3105 class(sfrtype) :: this
3107 integer(I4B) :: indx
3111 call this%obs%StoreObsType(
'stage', .false., indx)
3112 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3116 call this%obs%StoreObsType(
'inflow', .true., indx)
3117 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3121 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
3122 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3126 call this%obs%StoreObsType(
'rainfall', .true., indx)
3127 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3131 call this%obs%StoreObsType(
'runoff', .true., indx)
3132 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3136 call this%obs%StoreObsType(
'evaporation', .true., indx)
3137 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3141 call this%obs%StoreObsType(
'outflow', .true., indx)
3142 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3146 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
3147 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3151 call this%obs%StoreObsType(
'to-mvr', .true., indx)
3152 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3156 call this%obs%StoreObsType(
'from-mvr', .true., indx)
3157 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3161 call this%obs%StoreObsType(
'sfr', .true., indx)
3162 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3166 call this%obs%StoreObsType(
'upstream-flow', .true., indx)
3167 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3171 call this%obs%StoreObsType(
'downstream-flow', .true., indx)
3172 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3176 call this%obs%StoreObsType(
'depth', .false., indx)
3177 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3181 call this%obs%StoreObsType(
'wet-perimeter', .false., indx)
3182 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3186 call this%obs%StoreObsType(
'wet-area', .false., indx)
3187 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3191 call this%obs%StoreObsType(
'wet-width', .false., indx)
3192 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3193 end subroutine sfr_df_obs
3199 subroutine sfr_bd_obs(this)
3201 class(sfrtype) :: this
3207 character(len=100) :: msg
3211 if (this%obs%npakobs > 0)
then
3212 call this%obs%obs_bd_clear()
3213 do i = 1, this%obs%npakobs
3214 obsrv => this%obs%pakobs(i)%obsrv
3215 do j = 1, obsrv%indxbnds_count
3216 n = obsrv%indxbnds(j)
3218 select case (obsrv%ObsTypeId)
3223 if (this%imover == 1)
then
3224 v = this%pakmvrobj%get_qtomvr(n)
3231 if (this%imover == 1)
then
3232 v = this%pakmvrobj%get_qfrommvr(n)
3239 v = this%qoutflow(n)
3240 case (
'EXT-OUTFLOW')
3241 v = this%qextoutflow(n)
3243 if (this%iboundpak(n) /= 0)
then
3249 v = this%simrunoff(n)
3250 case (
'EVAPORATION')
3254 case (
'UPSTREAM-FLOW')
3256 if (this%imover == 1)
then
3257 v = v + this%pakmvrobj%get_qfrommvr(n)
3259 case (
'DOWNSTREAM-FLOW')
3266 case (
'WET-PERIMETER')
3267 v = this%calc_perimeter_wet(n, this%depth(n))
3269 v = this%calc_area_wet(n, this%depth(n))
3271 v = this%calc_top_width_wet(n, this%depth(n))
3273 msg =
'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
3276 call this%obs%SaveOneSimval(obsrv, v)
3285 end subroutine sfr_bd_obs
3291 subroutine sfr_rp_obs(this)
3295 class(sfrtype),
intent(inout) :: this
3300 character(len=LENBOUNDNAME) :: bname
3301 logical(LGP) :: jfound
3304 10
format(
'Boundary "', a,
'" for observation "', a, &
3305 '" is invalid in package "', a,
'"')
3306 30
format(
'Boundary name not provided for observation "', a, &
3307 '" in package "', a,
'"')
3313 do i = 1, this%obs%npakobs
3314 obsrv => this%obs%pakobs(i)%obsrv
3317 nn1 = obsrv%NodeNumber
3319 bname = obsrv%FeatureName
3320 if (bname /=
'')
then
3325 if (this%inamedbound /= 0)
then
3326 do j = 1, this%maxbound
3327 if (this%boundname(j) == bname)
then
3329 call obsrv%AddObsIndex(j)
3333 if (.not. jfound)
then
3335 trim(bname), trim(obsrv%name), trim(this%packName)
3339 write (
errmsg, 30) trim(obsrv%name), trim(this%packName)
3342 else if (nn1 < 1 .or. nn1 > this%maxbound)
then
3343 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3344 trim(adjustl(obsrv%ObsTypeId)), &
3345 'reach must be greater than 0 and less than or equal to', &
3346 this%maxbound,
'(specified value is ', nn1,
')'
3349 if (obsrv%indxbnds_count == 0)
then
3350 call obsrv%AddObsIndex(nn1)
3352 errmsg =
'Programming error in sfr_rp_obs'
3359 if (obsrv%ObsTypeId ==
'STAGE' .or. &
3360 obsrv%ObsTypeId ==
'DEPTH' .or. &
3361 obsrv%ObsTypeId ==
'WET-PERIMETER' .or. &
3362 obsrv%ObsTypeId ==
'WET-AREA' .or. &
3363 obsrv%ObsTypeId ==
'WET-WIDTH')
then
3364 nn1 = obsrv%NodeNumber
3366 if (obsrv%indxbnds_count > 1)
then
3367 write (
errmsg,
'(a,3(1x,a))') &
3368 trim(adjustl(obsrv%ObsTypeId)), &
3369 'for observation', trim(adjustl(obsrv%Name)), &
3370 ' must be assigned to a reach with a unique boundname.'
3377 do j = 1, obsrv%indxbnds_count
3378 nn1 = obsrv%indxbnds(j)
3379 if (nn1 < 1 .or. nn1 > this%maxbound)
then
3380 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3381 trim(adjustl(obsrv%ObsTypeId)), &
3382 'reach must be greater than 0 and less than or equal to', &
3383 this%maxbound,
'(specified value is ', nn1,
')'
3394 end subroutine sfr_rp_obs
3403 subroutine sfr_process_obsid(obsrv, dis, inunitobs, iout)
3407 integer(I4B),
intent(in) :: inunitobs
3408 integer(I4B),
intent(in) :: iout
3411 integer(I4B) :: icol
3412 integer(I4B) :: istart
3413 integer(I4B) :: istop
3414 character(len=LINELENGTH) :: string
3415 character(len=LENBOUNDNAME) :: bndname
3418 string = obsrv%IDstring
3428 obsrv%FeatureName = bndname
3432 obsrv%NodeNumber = nn1
3433 end subroutine sfr_process_obsid
3439 subroutine sfr_solve(this, n, h, hcof, rhs, update)
3441 class(sfrtype) :: this
3442 integer(I4B),
intent(in) :: n
3443 real(DP),
intent(in) :: h
3444 real(DP),
intent(inout) :: hcof
3445 real(DP),
intent(inout) :: rhs
3446 logical(LGP),
intent(in),
optional :: update
3448 logical(LGP) :: lupdate
3461 real(DP) :: qfrommvr
3474 if (
present(update))
then
3484 if (this%iboundpak(n) == 0)
then
3485 this%depth(n) =
dzero
3487 this%usflow(n) =
dzero
3488 this%simevap(n) =
dzero
3489 this%simrunoff(n) =
dzero
3490 this%dsflow(n) =
dzero
3491 this%gwflow(n) =
dzero
3503 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3504 if (this%idir(i) < 0) cycle
3506 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
3507 if (this%idir(ii) > 0) cycle
3508 if (this%ja(ii) /= n) cycle
3509 qu = qu + this%qconn(ii)
3515 sa = this%calc_surface_area(n)
3516 sa_wet = this%calc_surface_area_wet(n, this%depth(n))
3518 qr = this%rain(n) * sa
3519 qe = this%evap(n) * sa_wet
3520 qro = this%runoff(n)
3524 if (this%imover == 1)
then
3525 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3529 qsrc = qu + qi + qr - qe + qro + qfrommvr
3532 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3535 this%simevap(n) = qe
3536 this%simrunoff(n) = qro
3539 if (this%iboundpak(n) < 0)
then
3540 call this%sfr_calc_constant(n, d1, hgwf, qgwf, qd)
3542 if (this%gwfiss == 0 .and. this%istorage == 1)
then
3543 if (this%ats_courant /=
dnodata)
then
3544 call this%sfr_calc_tvd(n, d1, hgwf, qu, qi, &
3545 qfrommvr, qr, qe, qro, &
3548 call this%sfr_calc_transient(n, d1, hgwf, qu, qi, &
3549 qfrommvr, qr, qe, qro, &
3553 call this%sfr_calc_steady(n, d1, hgwf, qu, qi, &
3554 qfrommvr, qr, qe, qro, &
3561 bt = tp - this%bthick(n)
3568 this%stage(n) = hsfr
3570 call this%sfr_update_flows(n, qd, qgwf)
3576 if (this%gwfiss == 0)
then
3587 call this%sfr_calc_qgwf(n, d1, hgwf, qgwf, gwfhcof, gwfrhs)
3590 if (abs(sumleak) >
dzero)
then
3595 else if ((sumleak - qsrc) < -
dem30)
then
3596 if (this%gwfiss == 0)
then
3597 rhs = rhs + gwfrhs - sumrch
3604 if (this%gwfiss == 0)
then
3605 rhs = rhs - sumleak - sumrch
3612 else if (hgwf < bt)
then
3616 end subroutine sfr_solve
3623 subroutine sfr_update_flows(this, n, qd, qgwf)
3625 class(sfrtype),
intent(inout) :: this
3626 integer(I4B),
intent(in) :: n
3627 real(DP),
intent(inout) :: qd
3628 real(DP),
intent(in) :: qgwf
3632 integer(I4B) :: idiv
3633 integer(I4B) :: jpos
3643 this%gwflow(n) = qgwf
3646 if (qd >
dzero)
then
3649 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3650 if (this%idir(i) > 0) cycle
3652 if (idiv == 0) cycle
3653 jpos = this%iadiv(n) + idiv - 1
3654 call this%sfr_calc_div(n, idiv, qd, qdiv)
3655 this%qconn(i) = qdiv
3656 this%divq(jpos) = qdiv
3662 if (this%imover == 1)
then
3663 call this%pakmvrobj%accumulate_qformvr(n, qd)
3664 qd = max(qd - this%pakmvrobj%get_qtomvr(n),
dzero)
3668 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3669 if (this%idir(i) > 0) cycle
3670 if (this%idiv(i) > 0) cycle
3672 if (this%iboundpak(n2) == 0) cycle
3673 f = this%ustrf(n2) / this%ftotnd(n)
3674 this%qconn(i) = qd * f
3677 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3678 if (this%idir(i) > 0) cycle
3679 this%qconn(i) =
dzero
3681 if (idiv == 0) cycle
3682 jpos = this%iadiv(n) + idiv - 1
3683 this%divq(jpos) =
dzero
3686 end subroutine sfr_update_flows
3693 subroutine sfr_adjust_ro_ev(this, qc, qu, qi, qr, qro, qe, qfrommvr)
3695 class(sfrtype) :: this
3696 real(DP),
intent(inout) :: qc
3697 real(DP),
intent(in) :: qu
3698 real(DP),
intent(in) :: qi
3699 real(DP),
intent(in) :: qr
3700 real(DP),
intent(inout) :: qro
3701 real(DP),
intent(inout) :: qe
3702 real(DP),
intent(in) :: qfrommvr
3707 if (qc <
dzero)
then
3710 qt = qu + qi + qr + qro + qfrommvr
3713 if (qt <
dzero)
then
3714 if (qro <
dzero)
then
3715 qro = -(qu + qi + qr + qfrommvr)
3721 if (qe >
dzero)
then
3722 qe = qu + qi + qr + qro + qfrommvr
3725 qc = qu + qi + qr - qe + qro + qfrommvr
3727 end subroutine sfr_adjust_ro_ev
3733 subroutine sfr_calc_qd(this, n, depth, hgwf, qgwf, qd)
3735 class(sfrtype) :: this
3736 integer(I4B),
intent(in) :: n
3737 real(DP),
intent(in) :: depth
3738 real(DP),
intent(in) :: hgwf
3739 real(DP),
intent(inout) :: qgwf
3740 real(DP),
intent(inout) :: qd
3748 call this%sfr_calc_qsource(n, depth, qsrc)
3751 call this%sfr_calc_qgwf(n, depth, hgwf, qgwf)
3752 if (-qgwf > qsrc) qgwf = -qsrc
3759 end subroutine sfr_calc_qd
3766 subroutine sfr_calc_qsource(this, n, depth, qsrc)
3768 class(sfrtype) :: this
3769 integer(I4B),
intent(in) :: n
3770 real(DP),
intent(in) :: depth
3771 real(DP),
intent(inout) :: qsrc
3778 real(DP) :: qfrommvr
3788 qro = this%runoff(n)
3791 a = this%calc_surface_area(n)
3792 ae = this%calc_surface_area_wet(n, depth)
3793 qr = this%rain(n) * a
3794 qe = this%evap(n) * ae
3798 if (this%imover == 1)
then
3799 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3803 qsrc = qu + qi + qr - qe + qro + qfrommvr
3806 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3807 end subroutine sfr_calc_qsource
3814 subroutine sfr_calc_qman(this, n, depth, qman)
3816 class(sfrtype) :: this
3817 integer(I4B),
intent(in) :: n
3818 real(DP),
intent(in) :: depth
3819 real(DP),
intent(inout) :: qman
3821 integer(I4B) :: npts
3836 if (depth >
dzero)
then
3837 npts = this%ncrosspts(n)
3848 i0 = this%iacross(n)
3849 i1 = this%iacross(n + 1) - 1
3854 this%station(i0:i1), &
3855 this%xsheight(i0:i1), &
3856 this%xsrough(i0:i1), &
3863 aw = this%calc_area_wet(n, depth)
3864 wp = this%calc_perimeter_wet(n, depth)
3865 if (wp >
dzero)
then
3870 qman = this%unitconv * aw * (rh**
dtwothirds) * sqrt(s) / r
3876 end subroutine sfr_calc_qman
3884 subroutine sfr_calc_qgwf(this, n, depth, hgwf, qgwf, gwfhcof, gwfrhs)
3886 class(sfrtype) :: this
3887 integer(I4B),
intent(in) :: n
3888 real(DP),
intent(in) :: depth
3889 real(DP),
intent(in) :: hgwf
3890 real(DP),
intent(inout) :: qgwf
3891 real(DP),
intent(inout),
optional :: gwfhcof
3892 real(DP),
intent(inout),
optional :: gwfrhs
3894 integer(I4B) :: node
3902 real(DP) :: gwfhcof0
3909 node = this%igwfnode(n)
3910 if (node < 1)
return
3913 if (this%ibound(node) == 0)
return
3920 bt = tp - this%bthick(n)
3923 if (h_temp < bt)
then
3928 call this%sfr_calc_cond(n, depth, cond, hsfr, h_temp)
3931 qgwf = sat * cond * (h_temp - hsfr)
3932 gwfrhs0 = -sat * cond * hsfr
3933 gwfhcof0 = -sat * cond
3936 if (this%idense /= 0)
then
3937 call this%sfr_calculate_density_exchange(n, hsfr, hgwf, cond, tp, &
3938 qgwf, gwfhcof0, gwfrhs0)
3942 if (
present(gwfhcof)) gwfhcof = gwfhcof0
3943 if (
present(gwfrhs)) gwfrhs = gwfrhs0
3944 end subroutine sfr_calc_qgwf
3951 function sfr_gwf_conn(this, n)
3953 integer(I4B) :: sfr_gwf_conn
3955 class(sfrtype) :: this
3956 integer(I4B),
intent(in) :: n
3958 integer(I4B) :: node
3961 node = this%igwfnode(n)
3962 if (node > 0 .and. this%hk(n) >
dzero)
then
3965 end function sfr_gwf_conn
3971 subroutine sfr_calc_cond(this, n, depth, cond, hsfr, h_temp)
3973 class(sfrtype) :: this
3974 integer(I4B),
intent(in) :: n
3975 real(DP),
intent(in) :: depth
3976 real(DP),
intent(inout) :: cond
3977 real(DP),
intent(in),
optional :: hsfr
3978 real(DP),
intent(in),
optional :: h_temp
3980 integer(I4B) :: node
3982 real(DP) :: vscratio
3992 node = this%igwfnode(n)
3994 if (this%ibound(node) > 0)
then
3997 if (this%ivsc == 1)
then
3998 if (hsfr > h_temp)
then
4000 vscratio = this%viscratios(1, n)
4002 vscratio = this%viscratios(2, n)
4005 wp = this%calc_perimeter_wet(n, depth)
4006 cond = this%hk(n) * vscratio * this%length(n) * wp / this%bthick(n)
4009 end subroutine sfr_calc_cond
4018 subroutine sfr_calc_div(this, n, i, qd, qdiv)
4020 class(sfrtype) :: this
4021 integer(I4B),
intent(in) :: n
4022 integer(I4B),
intent(in) :: i
4023 real(DP),
intent(inout) :: qd
4024 real(DP),
intent(inout) :: qdiv
4026 character(len=10) :: cp
4027 integer(I4B) :: jpos
4032 jpos = this%iadiv(n) + i - 1
4033 n2 = this%divreach(jpos)
4034 cp = this%divcprior(jpos)
4035 v = this%divflow(jpos)
4066 end subroutine sfr_calc_div
4072 subroutine sfr_calc_reach_depth(this, n, q1, d1)
4074 class(sfrtype) :: this
4075 integer(I4B),
intent(in) :: n
4076 real(DP),
intent(in) :: q1
4077 real(DP),
intent(inout) :: d1
4089 if (q1 >
dzero)
then
4090 if (this%ncrosspts(n) > 1)
then
4091 call this%sfr_calc_xs_depth(n, q1, d1)
4093 w = this%station(this%iacross(n))
4094 qconst = this%unitconv * w * sqrt(s) / r
4095 d1 = (q1 / qconst)**
dp6
4100 end subroutine sfr_calc_reach_depth
4107 subroutine sfr_calc_xs_depth(this, n, qrch, d)
4109 class(sfrtype) :: this
4110 integer(I4B),
intent(in) :: n
4111 real(DP),
intent(in) :: qrch
4112 real(DP),
intent(inout) :: d
4114 integer(I4B) :: iter
4115 real(DP) :: perturbation
4121 real(DP) :: residual
4124 perturbation = this%deps *
dtwo
4127 residual = q0 - qrch
4130 nriter:
do iter = 1, this%maxsfrit
4131 call this%sfr_calc_qman(n, d + perturbation, q1)
4133 if (dq /=
dzero)
then
4134 derv = perturbation / (q1 - q0)
4138 dd = derv * residual
4140 call this%sfr_calc_qman(n, d, q0)
4141 residual = q0 - qrch
4144 if (abs(dd) < this%dmaxchg)
then
4148 end subroutine sfr_calc_xs_depth
4155 subroutine sfr_check_conversion(this)
4157 class(sfrtype) :: this
4160 character(len=*),
parameter :: fmtunitconv_error = &
4161 &
"('SFR (',a,') UNIT_CONVERSION SPECIFIED VALUE (',g0,') AND', &
4162 &1x,'LENGTH_CONVERSION OR TIME_CONVERSION SPECIFIED.')"
4163 character(len=*),
parameter :: fmtunitconv = &
4164 &
"(1x,'SFR PACKAGE (',a,') CONVERSION DATA',&
4165 &/4x,'UNIT CONVERSION VALUE (',g0,').',/)"
4168 if (this%lengthconv /=
dnodata .or. this%timeconv /=
dnodata)
then
4169 if (this%unitconv /=
done)
then
4170 write (
errmsg, fmtunitconv_error) &
4171 trim(adjustl(this%packName)), this%unitconv
4174 if (this%lengthconv /=
dnodata)
then
4175 this%unitconv = this%unitconv * this%lengthconv**
donethird
4177 if (this%timeconv /=
dnodata)
then
4178 this%unitconv = this%unitconv * this%timeconv
4180 write (this%iout, fmtunitconv) &
4181 trim(adjustl(this%packName)), this%unitconv
4184 end subroutine sfr_check_conversion
4192 subroutine sfr_check_storage_weight(this)
4194 class(sfrtype) :: this
4196 character(len=*),
parameter :: fmtweight = &
4197 &
"(1x,'SFR PACKAGE (',a,') SETTING DEFAULT',&
4198 &/4x,'STORAGE_WEIGHT VALUE (',g0,').',/)"
4201 if (this%istorage == 1)
then
4202 if (this%storage_weight ==
dnodata)
then
4203 this%storage_weight =
done
4204 write (this%iout, fmtweight) &
4205 trim(adjustl(this%packName)), this%storage_weight
4208 end subroutine sfr_check_storage_weight
4216 subroutine sfr_check_reaches(this)
4218 class(sfrtype) :: this
4220 character(len=5) :: crch
4221 character(len=10) :: cval
4222 character(len=30) :: nodestr
4223 character(len=LINELENGTH) :: title
4224 character(len=LINELENGTH) :: text
4231 if (this%iprpak /= 0)
then
4232 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4233 trim(adjustl(this%packName))//
') STATIC REACH DATA'
4234 call table_cr(this%inputtab, this%packName, title)
4235 call this%inputtab%table_df(this%maxbound, 10, this%iout)
4237 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4239 call this%inputtab%initialize_column(text, 20, alignment=
tableft)
4241 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4243 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4245 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4247 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4249 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4251 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4253 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4254 text =
'UPSTREAM FRACTION'
4255 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4259 do n = 1, this%maxbound
4260 write (crch,
'(i5)') n
4261 nn = this%igwfnode(n)
4263 btgwf = this%dis%bot(nn)
4264 call this%dis%noder_to_string(nn, nodestr)
4269 if (this%length(n) <=
dzero)
then
4270 errmsg =
'Reach '//crch//
' length must be greater than 0.0.'
4274 if (this%width(n) <=
dzero)
then
4275 errmsg =
'Reach '//crch//
' width must be greater than 0.0.'
4279 if (this%slope(n) <=
dzero)
then
4280 errmsg =
'Reach '//crch//
' slope must be greater than 0.0.'
4285 bt = this%strtop(n) - this%bthick(n)
4286 if (bt <= btgwf .and. this%icheck /= 0)
then
4287 write (cval,
'(f10.4)') bt
4288 errmsg =
'Reach '//crch//
' bed bottom (rtp-rbth ='// &
4289 cval//
') must be greater than the bottom of cell ('// &
4291 write (cval,
'(f10.4)') btgwf
4295 if (this%hk(n) <
dzero)
then
4296 errmsg =
'Reach '//crch//
' hk must be greater than or equal to 0.0.'
4301 if (this%rough(n) <=
dzero)
then
4302 errmsg =
'Reach '//crch//
" Manning's roughness "// &
4303 'coefficient must be greater than 0.0.'
4307 if (this%ustrf(n) <
dzero)
then
4308 errmsg =
'Reach '//crch//
' upstream fraction must be greater '// &
4309 'than or equal to 0.0.'
4313 if (this%iprpak /= 0)
then
4314 call this%inputtab%add_term(n)
4315 call this%inputtab%add_term(nodestr)
4316 call this%inputtab%add_term(this%length(n))
4317 call this%inputtab%add_term(this%width(n))
4318 call this%inputtab%add_term(this%slope(n))
4319 call this%inputtab%add_term(this%strtop(n))
4320 call this%inputtab%add_term(this%bthick(n))
4321 call this%inputtab%add_term(this%hk(n))
4322 call this%inputtab%add_term(this%rough(n))
4323 call this%inputtab%add_term(this%ustrf(n))
4326 end subroutine sfr_check_reaches
4334 subroutine sfr_check_connections(this)
4336 class(sfrtype) :: this
4338 logical(LGP) :: lreorder
4339 character(len=5) :: crch
4340 character(len=5) :: crch2
4341 character(len=LINELENGTH) :: text
4342 character(len=LINELENGTH) :: title
4349 integer(I4B) :: ifound
4350 integer(I4B) :: ierr
4351 integer(I4B) :: maxconn
4352 integer(I4B) :: ntabcol
4356 do j = 1, this%MAXBOUND
4357 n = this%isfrorder(j)
4366 write (this%iout,
'(/,1x,a)') &
4367 trim(adjustl(this%text))//
' PACKAGE ('// &
4368 trim(adjustl(this%packName))//
') REACH SOLUTION HAS BEEN '// &
4369 'REORDERED USING A DAG'
4372 if (this%iprpak /= 0)
then
4376 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4377 trim(adjustl(this%packName))//
') REACH SOLUTION ORDER'
4378 call table_cr(this%inputtab, this%packName, title)
4379 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4381 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4383 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4386 do j = 1, this%maxbound
4387 n = this%isfrorder(j)
4388 call this%inputtab%add_term(j)
4389 call this%inputtab%add_term(n)
4395 if (this%iprpak /= 0)
then
4399 do n = 1, this%maxbound
4400 maxconn = max(maxconn, this%nconnreach(n))
4402 ntabcol = 1 + maxconn
4405 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4406 trim(adjustl(this%packName))//
') STATIC REACH CONNECTION DATA'
4407 call table_cr(this%inputtab, this%packName, title)
4408 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4410 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4412 write (text,
'(a,1x,i6)')
'CONN', n
4413 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4419 do n = 1, this%MAXBOUND
4420 write (crch,
'(i5)') n
4421 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4423 write (crch2,
'(i5)') nn
4425 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4432 if (ifound /= 1)
then
4433 errmsg =
'Reach '//crch//
' is connected to '// &
4434 'reach '//crch2//
' but reach '//crch2// &
4435 ' is not connected to reach '//crch//
'.'
4441 if (this%iprpak /= 0)
then
4442 call this%inputtab%add_term(n)
4443 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4444 call this%inputtab%add_term(this%ja(i))
4446 nn = maxconn - this%nconnreach(n)
4448 call this%inputtab%add_term(
' ')
4456 do n = 1, this%maxbound
4457 write (crch,
'(i5)') n
4458 eachconnv:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4461 if (this%idir(i) < 0) cycle eachconnv
4463 write (crch2,
'(i5)') nn
4464 connreachv:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4466 if (this%idir(ii) < 0) cycle connreachv
4473 errmsg =
'Reach '//crch//
' is connected to '// &
4474 'reach '//crch2//
' but streamflow from reach '// &
4475 crch//
' to reach '//crch2//
' is not permitted.'
4490 do n = 1, this%maxbound
4491 write (crch,
'(i5)') n
4492 eachconnds:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4494 if (this%idir(i) > 0) cycle eachconnds
4495 write (crch2,
'(i5)') nn
4497 connreachds:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4500 if (this%idir(i) /= this%idir(ii))
then
4506 if (ifound /= 1)
then
4507 errmsg =
'Reach '//crch//
' downstream connected reach '// &
4508 'is reach '//crch2//
' but reach '//crch//
' is not'// &
4509 ' the upstream connected reach for reach '//crch2//
'.'
4516 if (this%iprpak /= 0)
then
4520 do n = 1, this%maxbound
4522 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4523 if (this%idir(i) > 0)
then
4527 maxconn = max(maxconn, ii)
4529 ntabcol = 1 + maxconn
4532 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4533 trim(adjustl(this%packName))//
') STATIC UPSTREAM REACH '// &
4535 call table_cr(this%inputtab, this%packName, title)
4536 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4538 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4540 write (text,
'(a,1x,i6)')
'UPSTREAM CONN', n
4541 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4545 do n = 1, this%maxbound
4546 call this%inputtab%add_term(n)
4548 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4549 if (this%idir(i) > 0)
then
4550 call this%inputtab%add_term(this%ja(i))
4556 call this%inputtab%add_term(
' ')
4562 do n = 1, this%maxbound
4564 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4565 if (this%idir(i) < 0)
then
4569 maxconn = max(maxconn, ii)
4571 ntabcol = 1 + maxconn
4574 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4575 trim(adjustl(this%packName))//
') STATIC DOWNSTREAM '// &
4576 'REACH CONNECTION DATA'
4577 call table_cr(this%inputtab, this%packName, title)
4578 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4580 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4582 write (text,
'(a,1x,i6)')
'DOWNSTREAM CONN', n
4583 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4587 do n = 1, this%maxbound
4588 call this%inputtab%add_term(n)
4590 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4591 if (this%idir(i) < 0)
then
4592 call this%inputtab%add_term(this%ja(i))
4598 call this%inputtab%add_term(
' ')
4602 end subroutine sfr_check_connections
4610 subroutine sfr_check_diversions(this)
4612 class(sfrtype) :: this
4614 character(len=LINELENGTH) :: title
4615 character(len=LINELENGTH) :: text
4616 character(len=5) :: crch
4617 character(len=5) :: cdiv
4618 character(len=5) :: crch2
4619 character(len=10) :: cprior
4620 integer(I4B) :: maxdiv
4625 integer(I4B) :: idiv
4626 integer(I4B) :: ifound
4627 integer(I4B) :: jpos
4629 10
format(
'Diversion ', i0,
' of reach ', i0, &
4630 ' is invalid or has not been defined.')
4633 if (this%iprpak /= 0)
then
4637 do n = 1, this%maxbound
4638 maxdiv = maxdiv + this%ndiv(n)
4642 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4643 trim(adjustl(this%packName))//
') REACH DIVERSION DATA'
4644 call table_cr(this%inputtab, this%packName, title)
4645 call this%inputtab%table_df(maxdiv, 4, this%iout)
4647 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4649 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4651 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4653 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4657 do n = 1, this%maxbound
4658 if (this%ndiv(n) < 1) cycle
4659 write (crch,
'(i5)') n
4661 do idiv = 1, this%ndiv(n)
4664 jpos = this%iadiv(n) + idiv - 1
4667 write (cdiv,
'(i5)') idiv
4670 nn = this%divreach(jpos)
4671 write (crch2,
'(i5)') nn
4675 if (nn < 1 .or. nn > this%maxbound)
then
4676 write (
errmsg, 10) idiv, n
4680 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4683 if (this%idir(ii) > 0)
then
4689 if (ifound /= 1)
then
4690 errmsg =
'Reach '//crch//
' is not a upstream reach for '// &
4691 'reach '//crch2//
' as a result diversion '//cdiv// &
4692 ' from reach '//crch//
' to reach '//crch2// &
4693 ' is not possible. Check reach connectivity.'
4697 cprior = this%divcprior(jpos)
4700 if (this%iprpak /= 0)
then
4701 call this%inputtab%add_term(n)
4702 call this%inputtab%add_term(idiv)
4703 call this%inputtab%add_term(nn)
4704 call this%inputtab%add_term(cprior)
4708 end subroutine sfr_check_diversions
4717 subroutine sfr_check_initialstages(this)
4718 class(sfrtype) :: this
4720 character(len=LINELENGTH) :: title
4721 character(len=LINELENGTH) :: text
4722 character(len=5) :: crch
4727 if (this%istorage == 0)
return
4730 if (this%iprpak /= 0)
then
4733 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4734 trim(adjustl(this%packName))//
') REACH INITIAL STAGE DATA'
4735 call table_cr(this%inputtab, this%packName, title)
4736 call this%inputtab%table_df(this%maxbound, 4, this%iout)
4738 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4739 text =
'INITIAL STAGE'
4740 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4741 text =
'INITIAL DEPTH'
4742 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4743 text =
'INITIAL FLOW'
4744 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4748 do n = 1, this%maxbound
4749 write (crch,
'(i5)') n
4752 call this%sfr_calc_qman(n, this%depth(n), qman)
4753 this%usinflow(n) = qman
4754 this%dsflow(n) = qman
4757 if (this%iprpak /= 0)
then
4758 call this%inputtab%add_term(n)
4759 call this%inputtab%add_term(this%stage(n))
4760 call this%inputtab%add_term(this%depth(n))
4761 call this%inputtab%add_term(qman)
4764 end subroutine sfr_check_initialstages
4772 subroutine sfr_check_ustrf(this)
4774 class(sfrtype) :: this
4776 character(len=LINELENGTH) :: title
4777 character(len=LINELENGTH) :: text
4778 logical(LGP) :: lcycle
4779 logical(LGP) :: ladd
4780 character(len=5) :: crch
4781 character(len=5) :: crch2
4782 character(len=10) :: cval
4783 integer(I4B) :: maxcols
4784 integer(I4B) :: npairs
4785 integer(I4B) :: ipair
4789 integer(I4B) :: idiv
4792 integer(I4B) :: jpos
4798 if (this%iprpak /= 0)
then
4802 do n = 1, this%maxbound
4804 ec:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4807 if (this%idir(i) > 0) cycle ec
4811 if (this%iboundpak(n2) == 0) cycle ec
4815 npairs = max(npairs, ipair)
4818 maxcols = 1 + npairs * 2
4821 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4822 trim(adjustl(this%packName))//
') CONNECTED REACH UPSTREAM '// &
4824 call table_cr(this%inputtab, this%packName, title)
4825 call this%inputtab%table_df(this%maxbound, maxcols, this%iout)
4827 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4829 write (cval,
'(i10)') i
4830 text =
'DOWNSTREAM REACH '//trim(adjustl(cval))
4831 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4832 text =
'FRACTION '//trim(adjustl(cval))
4833 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4838 do n = 1, this%maxbound
4839 do idiv = 1, this%ndiv(n)
4841 i1 = this%iadiv(n + 1) - 1
4843 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4845 if (this%divreach(jpos) == n2)
then
4846 this%idiv(i) = jpos - i0 + 1
4856 do n = 1, this%maxbound
4860 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4861 if (this%idir(i) < 0)
then
4867 do idiv = 1, this%ndiv(n)
4868 jpos = this%iadiv(n) + idiv - 1
4869 n2 = this%divreach(jpos)
4871 if (f /=
dzero)
then
4872 write (
errmsg,
'(a,2(1x,i0,1x,a),1x,a,g0,a,2(1x,a))') &
4873 'Reach', n,
'is connected to reach', n2,
'by a diversion', &
4874 'but the upstream fraction is not equal to zero (', f,
'). Check', &
4875 trim(this%packName),
'package diversion and package data.'
4879 write (
warnmsg,
'(a,3(1x,a))') &
4881 'A warning instead of an error is issued because', &
4882 'the reach is only connected to the diversion reach in the ', &
4883 'downstream direction.'
4893 do n = 1, this%maxbound
4897 write (crch,
'(i5)') n
4898 if (this%iprpak /= 0)
then
4899 call this%inputtab%add_term(n)
4902 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4906 this%qconn(i) =
dzero
4909 if (this%idir(i) > 0)
then
4915 if (this%iboundpak(n2) == 0)
then
4922 write (crch2,
'(i5)') n2
4925 f = f + this%ustrf(n2)
4926 write (cval,
'(f10.4)') this%ustrf(n2)
4929 if (this%iprpak /= 0)
then
4930 call this%inputtab%add_term(n2)
4931 call this%inputtab%add_term(this%ustrf(n2))
4933 eachdiv:
do idiv = 1, this%ndiv(n)
4934 jpos = this%iadiv(n) + idiv - 1
4935 if (this%divreach(jpos) == n2)
then
4941 rval = rval + this%ustrf(n2)
4944 this%ftotnd(n) = rval
4947 if (this%iprpak /= 0)
then
4949 do i = ipair, npairs
4950 call this%inputtab%add_term(
' ')
4951 call this%inputtab%add_term(
' ')
4959 write (
errmsg,
'(a,1x,i0,1x,a,g0,a,3(1x,a))') &
4960 'Upstream fractions for reach ', n,
'is not equal to one (', f, &
4961 '). Check', trim(this%packName),
'package reach connectivity and', &
4967 end subroutine sfr_check_ustrf
4974 subroutine sfr_set_period_value(this, i, n, setting)
4976 class(sfrtype),
intent(inout) :: this
4977 integer(I4B),
intent(in) :: i
4978 integer(I4B),
intent(in) :: n
4979 character(len=*),
intent(in) :: setting
4981 select case (trim(setting))
4983 this%bedk_set(n) = .true.
4985 this%manning_set(n) = .true.
4986 case (
'UPSTREAM_FRAC')
4987 this%ustrf_set(n) = .true.
4989 end subroutine sfr_set_period_value
4997 subroutine sfr_setup_budobj(this)
4999 class(sfrtype) :: this
5001 integer(I4B) :: nbudterm
5006 integer(I4B) :: maxlist
5007 integer(I4B) :: naux
5010 character(len=LENBUDTXT) :: text
5011 character(len=LENBUDTXT),
dimension(1) :: auxtxt
5018 if (this%imover == 1) nbudterm = nbudterm + 2
5019 if (this%naux > 0) nbudterm = nbudterm + 1
5023 call this%budobj%budgetobject_df(this%maxbound, nbudterm, 0, 0, &
5024 ibudcsv=this%ibudcsv)
5028 text =
' FLOW-JA-FACE'
5030 maxlist = this%nconn
5032 auxtxt(1) =
' FLOW-AREA'
5033 call this%budobj%budterm(idx)%initialize(text, &
5038 maxlist, .false., .false., &
5042 call this%budobj%budterm(idx)%reset(this%nconn)
5044 do n = 1, this%maxbound
5046 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5048 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5055 maxlist = this%maxbound - this%ianynone
5057 auxtxt(1) =
' FLOW-AREA'
5058 call this%budobj%budterm(idx)%initialize(text, &
5063 maxlist, .false., .true., &
5065 call this%budobj%budterm(idx)%reset(maxlist)
5067 do n = 1, this%maxbound
5068 n2 = this%igwfnode(n)
5070 call this%budobj%budterm(idx)%update_term(n, n2, q)
5077 maxlist = this%maxbound
5079 call this%budobj%budterm(idx)%initialize(text, &
5084 maxlist, .false., .false., &
5088 text =
' EVAPORATION'
5090 maxlist = this%maxbound
5092 call this%budobj%budterm(idx)%initialize(text, &
5097 maxlist, .false., .false., &
5103 maxlist = this%maxbound
5105 call this%budobj%budterm(idx)%initialize(text, &
5110 maxlist, .false., .false., &
5114 text =
' EXT-INFLOW'
5116 maxlist = this%maxbound
5118 call this%budobj%budterm(idx)%initialize(text, &
5123 maxlist, .false., .false., &
5127 text =
' EXT-OUTFLOW'
5129 maxlist = this%maxbound
5131 call this%budobj%budterm(idx)%initialize(text, &
5136 maxlist, .false., .false., &
5142 maxlist = this%maxbound
5144 auxtxt(1) =
' VOLUME'
5145 call this%budobj%budterm(idx)%initialize(text, &
5150 maxlist, .false., .false., &
5154 if (this%imover == 1)
then
5159 maxlist = this%maxbound
5161 call this%budobj%budterm(idx)%initialize(text, &
5166 maxlist, .false., .false., &
5172 maxlist = this%maxbound
5174 call this%budobj%budterm(idx)%initialize(text, &
5179 maxlist, .false., .false., &
5190 maxlist = this%maxbound
5191 call this%budobj%budterm(idx)%initialize(text, &
5196 maxlist, .false., .false., &
5201 if (this%iprflow /= 0)
then
5202 call this%budobj%flowtable_df(this%iout, cellids=
'GWF')
5204 end subroutine sfr_setup_budobj
5212 subroutine sfr_fill_budobj(this)
5214 class(sfrtype) :: this
5216 integer(I4B) :: naux
5223 integer(I4B) :: idiv
5224 integer(I4B) :: jpos
5238 call this%budobj%budterm(idx)%reset(this%nconn)
5239 do n = 1, this%maxbound
5243 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5245 if (this%iboundpak(n) /= 0)
then
5247 if (this%idir(i) < 0)
then
5253 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5254 if (this%idir(ii) > 0) cycle
5255 if (this%ja(ii) /= n) cycle
5261 call this%sfr_calc_reach_depth(n, qt, d)
5262 ca = this%calc_area_wet(n, d)
5267 this%qauxcbc(1) = ca
5268 call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5274 call this%budobj%budterm(idx)%reset(this%maxbound - this%ianynone)
5275 do n = 1, this%maxbound
5276 n2 = this%igwfnode(n)
5278 if (this%iboundpak(n) /= 0)
then
5280 if (this%depth(n) >
dzero)
then
5281 wp = this%calc_perimeter_wet(n, this%depth(n))
5290 this%qauxcbc(1) =
dzero
5293 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
5299 call this%budobj%budterm(idx)%reset(this%maxbound)
5300 do n = 1, this%maxbound
5301 if (this%iboundpak(n) /= 0)
then
5302 a = this%calc_surface_area(n)
5303 q = this%rain(n) * a
5307 call this%budobj%budterm(idx)%update_term(n, n, q)
5312 call this%budobj%budterm(idx)%reset(this%maxbound)
5313 do n = 1, this%maxbound
5314 if (this%iboundpak(n) /= 0)
then
5315 q = -this%simevap(n)
5319 call this%budobj%budterm(idx)%update_term(n, n, q)
5324 call this%budobj%budterm(idx)%reset(this%maxbound)
5325 do n = 1, this%maxbound
5326 if (this%iboundpak(n) /= 0)
then
5327 q = this%simrunoff(n)
5331 call this%budobj%budterm(idx)%update_term(n, n, q)
5336 call this%budobj%budterm(idx)%reset(this%maxbound)
5337 do n = 1, this%maxbound
5338 if (this%iboundpak(n) /= 0)
then
5343 call this%budobj%budterm(idx)%update_term(n, n, q)
5348 call this%budobj%budterm(idx)%reset(this%maxbound)
5349 do n = 1, this%maxbound
5351 if (this%iboundpak(n) /= 0)
then
5352 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5353 if (this%idir(i) > 0) cycle
5356 jpos = this%iadiv(n) + idiv - 1
5357 q = q + this%divq(jpos)
5359 q = q + this%qconn(i)
5362 q = q - this%dsflow(n)
5363 if (this%imover == 1)
then
5364 q = q + this%pakmvrobj%get_qtomvr(n)
5367 if (this%imover == 1)
then
5368 q = this%pakmvrobj%get_qfrommvr(n)
5371 call this%budobj%budterm(idx)%update_term(n, n, q)
5376 call this%budobj%budterm(idx)%reset(this%maxbound)
5377 do n = 1, this%maxbound
5379 if (this%iboundpak(n) /= 0)
then
5381 a = this%calc_surface_area_wet(n, d)
5382 this%qauxcbc(1) = a * d
5383 if (this%gwfiss == 0 .and. this%istorage == 1)
then
5388 this%qauxcbc(1) =
dzero
5390 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
5394 if (this%imover == 1)
then
5398 call this%budobj%budterm(idx)%reset(this%maxbound)
5399 do n = 1, this%maxbound
5401 if (this%iboundpak(n) /= 0)
then
5402 q = this%pakmvrobj%get_qfrommvr(n)
5404 call this%budobj%budterm(idx)%update_term(n, n, q)
5409 call this%budobj%budterm(idx)%reset(this%maxbound)
5410 do n = 1, this%maxbound
5411 if (this%iboundpak(n) /= 0)
then
5412 q = this%pakmvrobj%get_qtomvr(n)
5419 call this%budobj%budterm(idx)%update_term(n, n, q)
5427 call this%budobj%budterm(idx)%reset(this%maxbound)
5428 do n = 1, this%maxbound
5430 call this%budobj%budterm(idx)%update_term(n, n, q, this%auxvar(:, n))
5435 call this%budobj%accumulate_terms()
5436 end subroutine sfr_fill_budobj
5444 subroutine sfr_setup_tableobj(this)
5446 class(sfrtype) :: this
5448 integer(I4B) :: nterms
5449 character(len=LINELENGTH) :: title
5450 character(len=LINELENGTH) :: text
5453 if (this%iprhed > 0)
then
5460 if (this%inamedbound == 1)
then
5465 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5466 trim(adjustl(this%packName))//
') STAGES FOR EACH CONTROL VOLUME'
5469 call table_cr(this%stagetab, this%packName, title)
5470 call this%stagetab%table_df(this%maxbound, nterms, this%iout, &
5474 if (this%inamedbound == 1)
then
5476 call this%stagetab%initialize_column(text,
lenboundname, &
5482 call this%stagetab%initialize_column(text, 10, alignment=
tabcenter)
5486 call this%stagetab%initialize_column(text, 20, alignment=
tableft)
5490 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5494 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5498 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5502 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5505 text =
'STREAMBED CONDUCTANCE'
5506 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5509 text =
'STREAMBED GRADIENT'
5510 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5514 if (this%istorage == 1)
then
5516 if (this%inamedbound == 1)
then
5521 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5522 trim(adjustl(this%packName))//
') COURANT NUMBER FOR EACH REACH'
5525 call table_cr(this%couranttab, this%packName, title)
5526 call this%couranttab%table_df(this%maxbound, nterms, this%iout)
5528 if (this%inamedbound == 1)
then
5530 call this%couranttab%initialize_column(text,
lenboundname, &
5536 call this%couranttab%initialize_column(text, 10, alignment=
tabcenter)
5540 call this%couranttab%initialize_column(text, 16, alignment=
tabcenter)
5544 call this%couranttab%initialize_column(text, 16, alignment=
tabcenter)
5548 call this%couranttab%initialize_column(text, 16, alignment=
tabcenter)
5550 end subroutine sfr_setup_tableobj
5558 function calc_area_wet(this, n, depth)
5560 real(dp) :: calc_area_wet
5562 class(sfrtype) :: this
5563 integer(I4B),
intent(in) :: n
5564 real(dp),
intent(in) :: depth
5566 integer(I4B) :: npts
5571 npts = this%ncrosspts(n)
5572 i0 = this%iacross(n)
5573 i1 = this%iacross(n + 1) - 1
5576 this%xsheight(i0:i1), depth)
5578 calc_area_wet = this%station(i0) * depth
5580 end function calc_area_wet
5586 function calc_perimeter_wet(this, n, depth)
5588 real(dp) :: calc_perimeter_wet
5590 class(sfrtype) :: this
5591 integer(I4B),
intent(in) :: n
5592 real(dp),
intent(in) :: depth
5594 integer(I4B) :: npts
5599 npts = this%ncrosspts(n)
5600 i0 = this%iacross(n)
5601 i1 = this%iacross(n + 1) - 1
5604 this%xsheight(i0:i1), depth)
5606 calc_perimeter_wet = this%station(i0)
5608 end function calc_perimeter_wet
5614 function calc_surface_area(this, n)
5616 real(dp) :: calc_surface_area
5618 class(sfrtype) :: this
5619 integer(I4B),
intent(in) :: n
5621 integer(I4B) :: npts
5624 real(dp) :: top_width
5627 npts = this%ncrosspts(n)
5628 i0 = this%iacross(n)
5629 i1 = this%iacross(n + 1) - 1
5633 top_width = this%station(i0)
5635 calc_surface_area = top_width * this%length(n)
5636 end function calc_surface_area
5642 function calc_surface_area_wet(this, n, depth)
5644 real(dp) :: calc_surface_area_wet
5646 class(sfrtype) :: this
5647 integer(I4B),
intent(in) :: n
5648 real(dp),
intent(in) :: depth
5650 real(dp) :: top_width
5653 top_width = this%calc_top_width_wet(n, depth)
5654 calc_surface_area_wet = top_width * this%length(n)
5655 end function calc_surface_area_wet
5661 function calc_top_width_wet(this, n, depth)
5663 real(dp) :: calc_top_width_wet
5665 class(sfrtype) :: this
5666 integer(I4B),
intent(in) :: n
5667 real(dp),
intent(in) :: depth
5669 integer(I4B) :: npts
5675 npts = this%ncrosspts(n)
5676 i0 = this%iacross(n)
5677 i1 = this%iacross(n + 1) - 1
5681 this%station(i0:i1), &
5682 this%xsheight(i0:i1), &
5685 calc_top_width_wet = sat * this%station(i0)
5687 end function calc_top_width_wet
5693 subroutine sfr_activate_density(this)
5697 class(sfrtype),
intent(inout) :: this
5704 call mem_reallocate(this%denseterms, 3, this%MAXBOUND,
'DENSETERMS', &
5706 do i = 1, this%maxbound
5708 this%denseterms(j, i) =
dzero
5711 write (this%iout,
'(/1x,a)')
'DENSITY TERMS HAVE BEEN ACTIVATED FOR SFR &
5712 &PACKAGE: '//trim(adjustl(this%packName))
5713 end subroutine sfr_activate_density
5720 subroutine sfr_activate_viscosity(this)
5724 class(sfrtype),
intent(inout) :: this
5731 call mem_reallocate(this%viscratios, 2, this%MAXBOUND,
'VISCRATIOS', &
5733 do i = 1, this%maxbound
5735 this%viscratios(j, i) =
done
5738 write (this%iout,
'(/1x,a)')
'VISCOSITY HAS BEEN ACTIVATED FOR SFR &
5739 &PACKAGE: '//trim(adjustl(this%packName))
5740 end subroutine sfr_activate_viscosity
5753 subroutine sfr_calculate_density_exchange(this, n, stage, head, cond, &
5754 tops, flow, gwfhcof, gwfrhs)
5756 class(sfrtype),
intent(inout) :: this
5757 integer(I4B),
intent(in) :: n
5758 real(DP),
intent(in) :: stage
5759 real(DP),
intent(in) :: head
5760 real(DP),
intent(in) :: cond
5761 real(DP),
intent(in) :: tops
5762 real(DP),
intent(inout) :: flow
5763 real(DP),
intent(inout) :: gwfhcof
5764 real(DP),
intent(inout) :: gwfrhs
5769 real(DP) :: rdensesfr
5770 real(DP) :: rdensegwf
5771 real(DP) :: rdenseavg
5777 logical(LGP) :: stage_below_bot
5778 logical(LGP) :: head_below_bot
5781 if (stage >= tops)
then
5783 stage_below_bot = .false.
5784 rdensesfr = this%denseterms(1, n)
5787 stage_below_bot = .true.
5788 rdensesfr = this%denseterms(2, n)
5792 if (head >= tops)
then
5794 head_below_bot = .false.
5795 rdensegwf = this%denseterms(2, n)
5798 head_below_bot = .true.
5799 rdensegwf = this%denseterms(1, n)
5803 if (rdensegwf ==
dzero)
return
5806 if (stage_below_bot .and. head_below_bot)
then
5813 rdenseavg =
dhalf * (rdensesfr + rdensegwf)
5817 d1 = cond * (rdenseavg -
done)
5818 gwfhcof = gwfhcof - d1
5819 gwfrhs = gwfrhs - d1 * ss
5824 if (.not. stage_below_bot .and. .not. head_below_bot)
then
5828 elevgwf = this%denseterms(3, n)
5830 elevavg =
dhalf * (elevsfr + elevgwf)
5831 havg =
dhalf * (hh + ss)
5832 d2 = cond * (havg - elevavg) * (rdensegwf - rdensesfr)
5833 gwfrhs = gwfrhs + d2
5837 end subroutine sfr_calculate_density_exchange
5844 subroutine sfr_input_init(this, mempath, naux)
5846 class(sfrinputtype),
intent(inout) :: this
5847 character(len=*),
intent(in) :: mempath
5848 integer(I4B),
intent(in) :: naux
5849 call mem_setptr(this%nbound,
'NBOUND', mempath)
5851 call mem_setptr(this%setting,
'SETTING', mempath)
5852 call mem_setptr(this%status,
'STATUS', mempath)
5854 call mem_setptr(this%tab6_filename,
'TAB6_FILENAME', mempath)
5856 call mem_setptr(this%auxname,
'AUXNAME', mempath)
5857 call mem_setptr(this%auxval,
'AUXVAL', mempath)
5859 end subroutine sfr_input_init
5863 subroutine sfr_input_destroy(this)
5864 class(sfrinputtype),
intent(inout) :: this
5867 nullify (this%ustrf)
5868 nullify (this%rhk_tslink)
5869 nullify (this%man_tslink)
5870 nullify (this%ustrf_tslink)
5871 nullify (this%nbound)
5873 nullify (this%status)
5874 nullify (this%setting)
5876 nullify (this%tab6_filename)
5877 nullify (this%auxname)
5878 nullify (this%auxval)
5879 end subroutine sfr_input_destroy
This module contains the extended boundary package.
This module contains the base boundary package.
This module contains the BudgetModule.
subroutine, public budgetobject_cr(this, name)
Create a new budget object.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dhdry
real dry cell constant
@ tabcenter
centered table column
@ tabright
right justified table column
@ tableft
left justified table column
@ mnormal
normal output mode
real(dp), parameter dtwothirds
real constant 2/3
integer(i4b), parameter lenpackagename
maximum length of the package name
real(dp), parameter dp9
real constant 9/10
real(dp), parameter deight
real constant 8
real(dp), parameter dfivethirds
real constant 5/3
real(dp), parameter dp999
real constant 999/1000
integer(i4b), parameter namedboundflag
named bound flag
real(dp), parameter donethird
real constant 1/3
real(dp), parameter dnodata
real no data constant
real(dp), parameter d1p1
real constant 1.1
real(dp), parameter dhnoflo
real no flow constant
real(dp), parameter dhundred
real constant 100
integer(i4b), parameter lenpakloc
maximum length of a package location
real(dp), parameter dep20
real constant 1e20
real(dp), parameter dp6
real constant 3/5
integer(i4b), parameter maxadpit
maximum advanced package Newton-Raphson iterations
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dhalf
real constant 1/2
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
real(dp), parameter dpi
real constant
real(dp), parameter dp99
real constant 99/100
integer(i4b), parameter lenboundname
maximum length of a bound name
real(dp), parameter dem4
real constant 1e-4
real(dp), parameter dem30
real constant 1e-30
real(dp), parameter dem6
real constant 1e-6
real(dp), parameter dzero
real constant zero
real(dp), parameter dem5
real constant 1e-5
real(dp), parameter dprec
real constant machine precision
integer(i4b), parameter maxcharlen
maximum length of char string
real(dp), parameter dp7
real constant 7/10
real(dp), parameter dem2
real constant 1e-2
real(dp), parameter dtwo
real constant 2
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
integer(i4b), parameter lenmempath
maximum length of the memory path
real(dp), parameter done
real constant 1
This module contains stateless sfr subroutines and functions.
real(dp) function, public get_wetted_topwidth(npts, stations, heights, d)
Calculate the wetted top width for a reach.
real(dp) function, public get_wetted_perimeter(npts, stations, heights, d)
Calculate the wetted perimeter for a reach.
real(dp) function, public get_cross_section_area(npts, stations, heights, d)
Calculate the cross-sectional area for a reach.
real(dp) function, public get_saturated_topwidth(npts, stations)
Calculate the saturated top width for a reach.
real(dp) function, public get_mannings_section(npts, stations, heights, roughfracs, roughness, conv_fact, slope, d)
Calculate the manning's discharge for a reach.
This module defines variable data types.
Previous variable names checked in as deprecated aliases.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the derived types ObserveType and ObsDataType.
subroutine, public cross_section_cr(this, iout, iprpak, nreaches)
Create a cross-section object.
This module contains the SFR package methods.
subroutine sfr_source_connectiondata(this)
Source CONNECTIONDATA block from input context.
subroutine sfr_source_initialstages(this)
Source INITIALSTAGES block from input context.
subroutine sfr_calc_celerity(this, n, q, celerity)
Kinematic-wave celerity from a flow perturbation (0 if dry)
real(dp) function calc_top_width_wet(this, n, depth)
Calculate wetted top width.
subroutine sfr_precompute_tvd(this)
Pre-compute the single upstream reach index for the TVD limiter.
subroutine sfr_setup_tableobj(this)
Setup stage table object for package.
subroutine sfr_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
@ brief Convergence check for package.
subroutine sfr_cq(this, x, flowja, iadv)
@ brief Calculate package flows.
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
@ brief Output package flow terms.
subroutine sfr_activate_viscosity(this)
Activate viscosity terms.
subroutine sfr_da(this)
@ brief Deallocate package memory
subroutine sfr_calc_reach_depth(this, n, q1, d1)
Calculate the depth at the midpoint.
real(dp) function calc_surface_area(this, n)
Calculate maximum surface area.
subroutine sfr_check_ustrf(this)
Check upstream fraction data.
subroutine sfr_source_packagedata(this)
Source PACKAGEDATA block from input context.
subroutine sfr_calc_xs_depth(this, n, qrch, d)
Calculate the depth at the midpoint of a irregular cross-section.
subroutine sfr_check_diversions(this)
Check diversions data.
subroutine sfr_ot_dv(this, idvsave, idvprint)
@ brief Output package dependent-variable terms.
subroutine, public sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
@ brief Create a new package object
subroutine sfr_dt(this)
Submit the ATS time step for the most Courant-constraining reach.
subroutine sfr_fc(this, rhs, ia, idxglo, matrix_sln)
@ brief Copy hcof and rhs terms into solution.
subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
@ brief Add Newton-Raphson terms for package into solution.
subroutine define_listlabel(this)
@ brief Define the list label for the package
subroutine sfr_df_obs(this)
Define the observation types available in the package.
subroutine sfr_calc_cond(this, n, depth, cond, hsfr, h_temp)
Calculate reach-aquifer conductance.
subroutine sfr_check_connections(this)
Check connection data.
subroutine sfr_source_options(this)
Source OPTIONS from input context.
subroutine sfr_input_destroy(this)
Nullify all SfrInputType pointers.
subroutine sfr_allocate_arrays(this)
@ brief Allocate arrays
subroutine sfr_bd_obs(this)
Save observations for the package.
subroutine sfr_source_crosssections(this)
Source CROSSSECTIONS block from input context.
subroutine sfr_setup_budobj(this)
Setup budget object for package.
subroutine sfr_check_initialstages(this)
Check initial stage data.
subroutine sfr_rp(this)
@ brief Read and prepare period data for package
subroutine sfr_input_init(this, mempath, naux)
Bind SfrInputType PERIOD pointers to input context arrays.
subroutine sfr_ar(this)
@ brief Allocate and read method for package
subroutine sfr_calc_qman(this, n, depth, qman)
Calculate streamflow.
subroutine sfr_fp(this)
Write the Courant-number summary table to the listing file.
subroutine sfr_check_reaches(this)
Check reach data.
real(dp) function calc_perimeter_wet(this, n, depth)
Calculate wetted perimeter.
subroutine sfr_update_flows(this, n, qd, qgwf)
Update flow terms.
subroutine sfr_calc_qd(this, n, depth, hgwf, qgwf, qd)
Calculate downstream flow term.
subroutine sfr_fill_budobj(this)
Copy flow terms into budget object for package.
subroutine sfr_cf(this)
@ brief Formulate the package hcof and rhs terms.
subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
@ brief Output advanced package budget summary.
subroutine sfr_calc_div(this, n, i, qd, qdiv)
Calculate diversion flow.
subroutine sfr_calc_qgwf(this, n, depth, hgwf, qgwf, gwfhcof, gwfrhs)
Calculate reach-aquifer exchange.
character(len=lenftype) ftype
package ftype string
subroutine sfr_calculate_density_exchange(this, n, stage, head, cond, tops, flow, gwfhcof, gwfrhs)
Calculate density terms.
subroutine sfr_source_dimensions(this)
Source DIMENSIONS block from input context and load static data.
character(len=lenpackagename) text
package budget string
subroutine sfr_set_period_value(this, i, n, setting)
Apply a PERIOD setting value to reach n.
subroutine sfr_calc_qsource(this, n, depth, qsrc)
Calculate sum of sources.
subroutine sfr_checkin_deprecated_names(this)
Alias deprecated SFR variable names to their current storage.
subroutine sfr_allocate_scalars(this)
@ brief Allocate scalars
logical function sfr_obs_supported(this)
Determine if observations are supported.
subroutine sfr_source_diversions(this)
Source DIVERSIONS block from input context.
subroutine sfr_check_storage_weight(this)
Check storage weight.
subroutine sfr_solve(this, n, h, hcof, rhs, update)
Solve reach continuity equation.
real(dp) function calc_area_wet(this, n, depth)
Calculate wetted area.
subroutine sfr_rp_obs(this)
Read and prepare observations for a package.
subroutine sfr_activate_density(this)
Activate density terms.
subroutine sfr_adjust_ro_ev(this, qc, qu, qi, qr, qro, qe, qfrommvr)
Adjust runoff and evaporation.
subroutine sfr_check_conversion(this)
Check unit conversion data.
real(dp) function calc_surface_area_wet(this, n, depth)
Calculate wetted surface area.
integer(i4b) function sfr_gwf_conn(this, n)
Determine if a reach is connected to a gwf cell.
subroutine sfr_ad(this)
@ brief Advance the package
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public deprecation_warning(cblock, cvar, cver, endmsg, iunit)
Store deprecation warning 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
character(len=maxcharlen) warnmsg
warning message string
real(dp) function squadraticsaturation(top, bot, x, eps)
@ brief sQuadraticSaturation
real(dp) function scubicsaturation(top, bot, x, eps)
@ brief sCubicSaturation
real(dp) function squadraticsaturationderivative(top, bot, x, eps)
@ brief Derivative of the quadratic saturation function
real(dp) function sqsaturationderivative(top, bot, x, c1, c2)
@ brief sQSaturationDerivative
subroutine schsmooth(d, smooth, dwdh)
@ brief sChSmooth
real(dp) function sqsaturation(top, bot, x, c1, c2)
@ brief sQSaturation
subroutine, public table_cr(this, name, title)
real(dp), pointer, public pertim
time relative to start of stress period
real(dp), pointer, public totim
time relative to start of simulation
class(atstype), pointer, public ats
integer(i4b), pointer, public inats
flag indicating ats active for simulation
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.
This class is used to store a single deferred-length character string. It was designed to work in an ...