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),
dimension(:),
pointer,
contiguous :: xsaus => null()
161 real(dp),
dimension(:),
pointer,
contiguous :: xsads => null()
162 real(dp),
dimension(:),
pointer,
contiguous :: xsausold => null()
163 real(dp),
dimension(:),
pointer,
contiguous :: xsadsold => null()
164 real(dp),
pointer :: ats_courant => null()
165 integer(I4B),
dimension(:),
pointer,
contiguous :: itvd_upstream => null()
166 real(dp),
dimension(:),
pointer,
contiguous :: crmin => null()
167 real(dp),
dimension(:),
pointer,
contiguous :: crmax => null()
168 real(dp),
dimension(:),
pointer,
contiguous :: crsum => null()
169 integer(I4B),
dimension(:),
pointer,
contiguous :: crcnt => null()
170 real(dp),
dimension(:),
pointer,
contiguous :: depth => null()
171 real(dp),
dimension(:),
pointer,
contiguous :: stage => null()
172 real(dp),
dimension(:),
pointer,
contiguous :: stageold => null()
173 real(dp),
dimension(:),
pointer,
contiguous :: gwflow => null()
174 real(dp),
dimension(:),
pointer,
contiguous :: simevap => null()
175 real(dp),
dimension(:),
pointer,
contiguous :: simrunoff => null()
176 real(dp),
dimension(:),
pointer,
contiguous :: stage0 => null()
177 real(dp),
dimension(:),
pointer,
contiguous :: usflow0 => null()
178 real(dp),
dimension(:),
pointer,
contiguous :: storage => null()
180 integer(I4B),
pointer :: ncrossptstot => null()
181 integer(I4B),
dimension(:),
pointer,
contiguous :: ncrosspts => null()
182 integer(I4B),
dimension(:),
pointer,
contiguous :: iacross => null()
183 real(dp),
dimension(:),
pointer,
contiguous :: station => null()
184 real(dp),
dimension(:),
pointer,
contiguous :: xsheight => null()
185 real(dp),
dimension(:),
pointer,
contiguous :: xsrough => null()
187 integer(I4B),
dimension(:),
pointer,
contiguous :: idir => null()
188 integer(I4B),
dimension(:),
pointer,
contiguous :: idiv => null()
189 real(dp),
dimension(:),
pointer,
contiguous :: qconn => null()
191 real(dp),
dimension(:),
pointer,
contiguous :: rough => null()
192 real(dp),
dimension(:),
pointer,
contiguous :: rain => null()
193 real(dp),
dimension(:),
pointer,
contiguous :: evap => null()
194 real(dp),
dimension(:),
pointer,
contiguous :: inflow => null()
195 real(dp),
dimension(:),
pointer,
contiguous :: runoff => null()
196 real(dp),
dimension(:),
pointer,
contiguous :: sstage => null()
198 integer(I4B),
dimension(:),
pointer,
contiguous :: iadiv => null()
199 integer(I4B),
dimension(:),
pointer,
contiguous :: divreach => null()
200 character(len=10),
dimension(:),
pointer,
contiguous :: divcprior => null()
201 real(dp),
dimension(:),
pointer,
contiguous :: divflow => null()
202 real(dp),
dimension(:),
pointer,
contiguous :: divq => null()
205 integer(I4B),
pointer :: idense
206 real(dp),
dimension(:, :),
pointer,
contiguous :: denseterms => null()
209 real(dp),
dimension(:, :),
pointer,
contiguous :: viscratios => null()
251 procedure,
private :: sfr_calc_constant
257 procedure,
private :: sfr_calc_transient
264 procedure,
private :: sfr_calc_tvd
271 procedure,
private :: sfr_calc_steady
319 module subroutine sfr_calc_steady(this, n, d1, hgwf, &
320 qu, qi, qfrommvr, qr, qe, qro, &
322 class(sfrtype) :: this
323 integer(I4B),
intent(in) :: n
324 real(dp),
intent(inout) :: d1
325 real(dp),
intent(in) :: hgwf
326 real(dp),
intent(in) :: qu
327 real(dp),
intent(in) :: qi
328 real(dp),
intent(in) :: qfrommvr
329 real(dp),
intent(in) :: qr
330 real(dp),
intent(in) :: qe
331 real(dp),
intent(in) :: qro
332 real(dp),
intent(inout) :: qgwf
333 real(dp),
intent(inout) :: qd
338 module subroutine sfr_calc_transient(this, n, d1, hgwf, &
339 qu, qi, qfrommvr, qr, qe, qro, &
341 class(sfrtype) :: this
342 integer(I4B),
intent(in) :: n
343 real(dp),
intent(inout) :: d1
344 real(dp),
intent(in) :: hgwf
345 real(dp),
intent(in) :: qu
346 real(dp),
intent(in) :: qi
347 real(dp),
intent(in) :: qfrommvr
348 real(dp),
intent(in) :: qr
349 real(dp),
intent(in) :: qe
350 real(dp),
intent(in) :: qro
351 real(dp),
intent(inout) :: qgwf
352 real(dp),
intent(inout) :: qd
357 module subroutine sfr_calc_tvd(this, n, d1, hgwf, &
358 qu, qi, qfrommvr, qr, qe, qro, &
360 class(sfrtype) :: this
361 integer(I4B),
intent(in) :: n
362 real(dp),
intent(inout) :: d1
363 real(dp),
intent(in) :: hgwf
364 real(dp),
intent(in) :: qu
365 real(dp),
intent(in) :: qi
366 real(dp),
intent(in) :: qfrommvr
367 real(dp),
intent(in) :: qr
368 real(dp),
intent(in) :: qe
369 real(dp),
intent(in) :: qro
370 real(dp),
intent(inout) :: qgwf
371 real(dp),
intent(inout) :: qd
376 module subroutine sfr_calc_constant(this, n, d1, hgwf, qgwf, qd)
377 class(sfrtype) :: this
378 integer(I4B),
intent(in) :: n
379 real(dp),
intent(inout) :: d1
380 real(dp),
intent(in) :: hgwf
381 real(dp),
intent(inout) :: qgwf
382 real(dp),
intent(inout) :: qd
392 subroutine sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, &
397 class(
bndtype),
pointer :: packobj
398 integer(I4B),
intent(in) :: id
399 integer(I4B),
intent(in) :: ibcnum
400 integer(I4B),
intent(in) :: inunit
401 integer(I4B),
intent(in) ::
iout
402 character(len=*),
intent(in) :: namemodel
403 character(len=*),
intent(in) :: pakname
404 character(len=*),
intent(in) :: mempath
406 type(sfrtype),
pointer :: sfrobj
413 call packobj%set_names(ibcnum, namemodel, pakname, ftype, mempath)
417 call sfrobj%sfr_allocate_scalars()
420 call packobj%pack_initialize()
422 packobj%inunit = inunit
425 packobj%ibcnum = ibcnum
430 end subroutine sfr_create
437 subroutine sfr_allocate_scalars(this)
442 class(sfrtype),
intent(inout) :: this
445 call this%BndExtType%allocate_scalars()
448 call mem_allocate(this%istorage,
'ISTORAGE', this%memoryPath)
449 call mem_allocate(this%iprhed,
'IPRHED', this%memoryPath)
450 call mem_allocate(this%istageout,
'ISTAGEOUT', this%memoryPath)
451 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
452 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
453 call mem_allocate(this%ipakcsv,
'IPAKCSV', this%memoryPath)
454 call mem_allocate(this%idiversions,
'IDIVERSIONS', this%memoryPath)
455 call mem_allocate(this%maxsfrpicard,
'MAXSFRPICARD', this%memoryPath)
456 call mem_allocate(this%maxsfrit,
'MAXSFRIT', this%memoryPath)
457 call mem_allocate(this%bditems,
'BDITEMS', this%memoryPath)
458 call mem_allocate(this%cbcauxitems,
'CBCAUXITEMS', this%memoryPath)
459 call mem_allocate(this%unitconv,
'UNITCONV', this%memoryPath)
460 call mem_allocate(this%lengthconv,
'LENGTHCONV', this%memoryPath)
461 call mem_allocate(this%timeconv,
'TIMECONV', this%memoryPath)
462 call mem_allocate(this%dmaxchg,
'DMAXCHG', this%memoryPath)
464 call mem_allocate(this%storage_weight,
'STORAGE_WEIGHT', this%memoryPath)
465 call mem_allocate(this%ats_courant,
'ATS_COURANT', this%memoryPath)
467 call mem_allocate(this%icheck,
'ICHECK', this%memoryPath)
468 call mem_allocate(this%iconvchk,
'ICONVCHK', this%memoryPath)
469 call mem_allocate(this%idense,
'IDENSE', this%memoryPath)
470 call mem_allocate(this%ianynone,
'IANYNONE', this%memoryPath)
471 call mem_allocate(this%ncrossptstot,
'NCROSSPTSTOT', this%memoryPath)
484 this%maxsfrpicard = 100
492 this%deps =
dp999 * this%dmaxchg
501 this%ncrossptstot = 0
502 end subroutine sfr_allocate_scalars
508 subroutine sfr_allocate_arrays(this)
512 class(sfrtype),
intent(inout) :: this
517 allocate (this%csfrbudget(this%bditems))
519 'SFRNAME', this%memoryPath)
522 call mem_allocate(this%iboundpak, this%maxbound,
'IBOUNDPAK', &
524 call mem_allocate(this%igwfnode, this%maxbound,
'IGWFNODE', this%memoryPath)
525 call mem_allocate(this%igwftopnode, this%maxbound,
'IGWFTOPNODE', &
527 call mem_allocate(this%length, this%maxbound,
'LENGTH', this%memoryPath)
528 call mem_allocate(this%width, this%maxbound,
'WIDTH', this%memoryPath)
529 call mem_allocate(this%strtop, this%maxbound,
'STRTOP', this%memoryPath)
530 call mem_allocate(this%bthick, this%maxbound,
'BTHICK', this%memoryPath)
531 call mem_allocate(this%slope, this%maxbound,
'SLOPE', this%memoryPath)
532 call mem_allocate(this%nconnreach, this%maxbound,
'NCONNREACH', &
534 call mem_allocate(this%bedk_set, this%maxbound,
'BEDK_SET', this%memoryPath)
535 call mem_allocate(this%manning_set, this%maxbound,
'MANNING_SET', &
537 call mem_allocate(this%ustrf_set, this%maxbound,
'USTRF_SET', &
539 this%bedk_set = .false.
540 this%manning_set = .false.
541 this%ustrf_set = .false.
542 call mem_allocate(this%ftotnd, this%maxbound,
'FTOTND', this%memoryPath)
543 call mem_allocate(this%ndiv, this%maxbound,
'NDIV', this%memoryPath)
544 call mem_allocate(this%usflow, this%maxbound,
'USFLOW', this%memoryPath)
545 call mem_allocate(this%dsflow, this%maxbound,
'DSFLOW', this%memoryPath)
546 call mem_allocate(this%depth, this%maxbound,
'DEPTH', this%memoryPath)
547 call mem_allocate(this%stage, this%maxbound,
'STAGE', this%memoryPath)
548 call mem_allocate(this%gwflow, this%maxbound,
'GWFLOW', this%memoryPath)
549 call mem_allocate(this%simevap, this%maxbound,
'SIMEVAP', this%memoryPath)
550 call mem_allocate(this%simrunoff, this%maxbound,
'SIMRUNOFF', &
552 call mem_allocate(this%stage0, this%maxbound,
'STAGE0', this%memoryPath)
553 call mem_allocate(this%usflow0, this%maxbound,
'USFLOW0', this%memoryPath)
556 if (this%istorage == 1)
then
557 call mem_allocate(this%stageold, this%maxbound,
'STAGEOLD', &
559 call mem_allocate(this%usinflow, this%maxbound,
'USINFLOW', &
561 call mem_allocate(this%usinflowold, this%maxbound,
'USINFLOWOLD', &
563 call mem_allocate(this%dsflowold, this%maxbound,
'DSFLOWOLD', &
565 call mem_allocate(this%xsaus, this%maxbound,
'XSAUS', this%memoryPath)
566 call mem_allocate(this%xsads, this%maxbound,
'XSADS', this%memoryPath)
567 call mem_allocate(this%xsausold, this%maxbound,
'XSAUSOLD', &
569 call mem_allocate(this%xsadsold, this%maxbound,
'XSADSOLD', &
571 call mem_allocate(this%storage, this%maxbound,
'STORAGE', &
573 call mem_allocate(this%crmin, this%maxbound,
'CRMIN', this%memoryPath)
574 call mem_allocate(this%crmax, this%maxbound,
'CRMAX', this%memoryPath)
575 call mem_allocate(this%crsum, this%maxbound,
'CRSUM', this%memoryPath)
576 call mem_allocate(this%crcnt, this%maxbound,
'CRCNT', this%memoryPath)
577 if (this%ats_courant /=
dnodata)
then
579 'ITVD_UPSTREAM', this%memoryPath)
581 call mem_allocate(this%itvd_upstream, 0,
'ITVD_UPSTREAM', this%memoryPath)
586 call mem_allocate(this%isfrorder, this%maxbound,
'ISFRORDER', &
588 call mem_allocate(this%ia, this%maxbound + 1,
'IA', this%memoryPath)
590 call mem_allocate(this%idir, 0,
'IDIR', this%memoryPath)
591 call mem_allocate(this%idiv, 0,
'IDIV', this%memoryPath)
592 call mem_allocate(this%qconn, 0,
'QCONN', this%memoryPath)
596 call mem_setptr(this%rain,
'RAINFALL', this%input_mempath)
597 call mem_setptr(this%evap,
'EVAPORATION', this%input_mempath)
598 call mem_setptr(this%inflow,
'INFLOW', this%input_mempath)
599 call mem_setptr(this%runoff,
'RUNOFF', this%input_mempath)
600 call mem_setptr(this%sstage,
'STAGE', this%input_mempath)
601 call mem_setptr(this%hk,
'BEDK', this%input_mempath)
602 call mem_setptr(this%rough,
'MANNING', this%input_mempath)
603 call mem_setptr(this%ustrf,
'UPSTREAM_FRAC', this%input_mempath)
607 call mem_allocate(this%iadiv, this%maxbound + 1,
'IADIV', this%memoryPath)
608 call mem_allocate(this%divreach, 0,
'DIVREACH', this%memoryPath)
609 call mem_allocate(this%divq, 0,
'DIVQ', this%memoryPath)
612 call mem_allocate(this%ncrosspts, this%maxbound,
'NCROSSPTS', &
614 call mem_allocate(this%iacross, this%maxbound + 1,
'IACROSS', &
616 call mem_allocate(this%station, this%ncrossptstot,
'STATION', &
618 call mem_allocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
620 call mem_allocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
625 do i = 1, this%maxbound
626 this%iboundpak(i) = 1
628 this%igwftopnode(i) = 0
629 this%length(i) =
dzero
630 this%width(i) =
dzero
631 this%strtop(i) =
dzero
632 this%bthick(i) =
dzero
634 this%slope(i) =
dzero
635 this%nconnreach(i) = 0
636 this%ustrf(i) =
dzero
637 this%ftotnd(i) =
dzero
639 this%usflow(i) =
dzero
640 this%dsflow(i) =
dzero
641 this%depth(i) =
dzero
642 this%stage(i) =
dzero
643 this%gwflow(i) =
dzero
644 this%simevap(i) =
dzero
645 this%simrunoff(i) =
dzero
646 this%stage0(i) =
dzero
647 this%usflow0(i) =
dzero
650 if (this%istorage == 1)
then
651 this%stageold(i) =
dzero
652 this%usinflow(i) =
dzero
653 this%usinflowold(i) =
dzero
654 this%dsflowold(i) =
dzero
655 this%xsaus(i) =
dzero
656 this%xsads(i) =
dzero
657 this%xsausold(i) =
dzero
658 this%xsadsold(i) =
dzero
659 this%storage(i) =
dzero
660 this%crmin(i) =
dep20
661 this%crmax(i) = -
dep20
662 this%crsum(i) =
dzero
664 if (this%ats_courant /=
dnodata)
then
665 this%itvd_upstream(i) = 0
670 this%rough(i) =
dzero
674 this%ncrosspts(i) = 0
675 this%iacross(i + 1) = 0
679 do i = 1, this%ncrossptstot
680 this%station(i) =
dzero
681 this%xsheight(i) =
dzero
682 this%xsrough(i) =
dzero
686 this%csfrbudget(1) =
' RAINFALL'
687 this%csfrbudget(2) =
' EVAPORATION'
688 this%csfrbudget(3) =
' RUNOFF'
689 this%csfrbudget(4) =
' EXT-INFLOW'
690 this%csfrbudget(5) =
' GWF'
691 this%csfrbudget(6) =
' EXT-OUTFLOW'
692 this%csfrbudget(7) =
' FROM-MVR'
693 this%csfrbudget(8) =
' TO-MVR'
696 call mem_allocate(this%qoutflow, this%maxbound,
'QOUTFLOW', this%memoryPath)
697 call mem_allocate(this%qextoutflow, this%maxbound,
'QEXTOUTFLOW', &
699 do i = 1, this%maxbound
700 this%qoutflow(i) =
dzero
701 this%qextoutflow(i) =
dzero
705 if (this%istageout > 0)
then
706 call mem_allocate(this%dbuff, this%maxbound,
'DBUFF', this%memoryPath)
707 do i = 1, this%maxbound
708 this%dbuff(i) =
dzero
711 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
715 allocate (this%cauxcbc(this%cbcauxitems))
718 call mem_allocate(this%qauxcbc, this%cbcauxitems,
'QAUXCBC', &
720 do i = 1, this%cbcauxitems
721 this%qauxcbc(i) =
dzero
725 this%cauxcbc(1) =
'FLOW-AREA '
728 call mem_allocate(this%denseterms, 3, 0,
'DENSETERMS', this%memoryPath)
731 call mem_allocate(this%viscratios, 2, 0,
'VISCRATIOS', this%memoryPath)
732 end subroutine sfr_allocate_arrays
743 subroutine sfr_checkin_deprecated_names(this)
748 class(sfrtype),
intent(inout) :: this
750 real(DP),
dimension(:, :),
pointer,
contiguous :: aux => null()
751 integer(I4B) :: isize
755 call get_isize(
'AUX', this%input_mempath, isize)
757 call mem_setptr(aux,
'AUX', this%input_mempath)
759 'AUX', this%input_mempath,
'6.8.2')
763 if (
associated(this%divflow))
then
765 'DIVFLOW', this%input_mempath,
'6.8.2')
767 call mem_allocate(this%divflow, 0,
'DIVFLOW', this%memoryPath)
771 'RAINFALL', this%input_mempath,
'6.8.2')
773 'EVAPORATION', this%input_mempath,
'6.8.2')
775 'INFLOW', this%input_mempath,
'6.8.2')
777 'RUNOFF', this%input_mempath,
'6.8.2')
779 'STAGE', this%input_mempath,
'6.8.2')
781 'BEDK', this%input_mempath,
'6.8.2')
783 'MANNING', this%input_mempath,
'6.8.2')
785 'UPSTREAM_FRAC', this%input_mempath,
'6.8.2')
786 end subroutine sfr_checkin_deprecated_names
790 subroutine sfr_source_options(this)
797 class(sfrtype),
intent(inout) :: this
799 character(len=LINELENGTH) :: fname
800 logical(LGP) :: found
802 character(len=*),
parameter :: fmtpicard = &
803 &
"(4x, 'MAXIMUM SFR PICARD ITERATION VALUE (',i0,') SPECIFIED.')"
804 character(len=*),
parameter :: fmtiter = &
805 &
"(4x, 'MAXIMUM SFR ITERATION VALUE (',i0,') SPECIFIED.')"
806 character(len=*),
parameter :: fmtdmaxchg = &
807 &
"(4x, 'MAXIMUM DEPTH CHANGE VALUE (',g0,') SPECIFIED.')"
808 character(len=*),
parameter :: fmtlengthconv = &
809 &
"(4x, 'LENGTH CONVERSION VALUE (',g0,') SPECIFIED.')"
810 character(len=*),
parameter :: fmttimeconv = &
811 &
"(4x, 'TIME CONVERSION VALUE (',g0,') SPECIFIED.')"
812 character(len=*),
parameter :: fmtstoweight = &
813 &
"(4x, 'KINEMATIC STORAGE WEIGHT (',g0,') SPECIFIED.')"
814 character(len=*),
parameter :: fmtsfrbin = &
815 "(4x, 'SFR ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, /4x, &
816 &'OPENED ON UNIT: ', I0)"
817 integer(I4B) :: isize
820 call this%BndExtType%source_options()
822 write (this%iout,
'(/1x,a)') &
823 'PROCESSING '//trim(adjustl(this%text))//
' OPTIONS'
826 call mem_set_value(this%istorage,
'STORAGE', this%input_mempath, found)
828 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
829 ' REACH STORAGE IS ACTIVE.'
834 this%input_mempath, found)
836 if (this%ats_courant <=
dzero)
then
837 write (
errmsg,
'(a,g0,a)') &
838 "ATS_COURANT SPECIFIED TO BE '", this%ats_courant, &
839 "' BUT MUST BE GREATER THAN ZERO"
843 write (this%iout,
'(4x,a,1pg15.6)') &
844 'TARGET COURANT NUMBER FOR ADAPTIVE TIME STEPS: ', &
850 call mem_set_value(this%iprhed,
'PRINT_STAGE', this%input_mempath, found)
852 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
853 ' STAGES WILL BE PRINTED TO LISTING FILE.'
857 call mem_set_value(fname,
'STAGEFILE', this%input_mempath, found)
860 call openfile(this%istageout, this%iout, fname,
'DATA(BINARY)', &
862 write (this%iout, fmtsfrbin)
'STAGE', trim(fname), this%istageout
866 call mem_set_value(fname,
'BUDGETFILE', this%input_mempath, found)
868 call assign_iounit(this%ibudgetout, this%inunit,
'BUDGET fileout')
869 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
871 write (this%iout, fmtsfrbin)
'BUDGET', trim(fname), this%ibudgetout
875 call mem_set_value(fname,
'BUDGETCSVFILE', this%input_mempath, found)
877 call assign_iounit(this%ibudcsv, this%inunit,
'BUDGETCSV fileout')
878 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
879 filstat_opt=
'REPLACE')
880 write (this%iout, fmtsfrbin)
'BUDGET CSV', trim(fname), this%ibudcsv
884 call mem_set_value(fname,
'PKGCONVFNAME', this%input_mempath, found)
887 call openfile(this%ipakcsv, this%iout, fname,
'CSV', &
888 filstat_opt=
'REPLACE', mode_opt=
mnormal)
889 write (this%iout, fmtsfrbin)
'PACKAGE_CONVERGENCE', trim(fname), &
894 call mem_set_value(this%imover,
'MOVER', this%input_mempath, found)
896 write (this%iout,
'(4x,A)')
'MOVER OPTION ENABLED'
901 this%input_mempath, found)
902 if (found)
write (this%iout, fmtpicard) this%maxsfrpicard
906 this%input_mempath, found)
907 if (found)
write (this%iout, fmtiter) this%maxsfrit
911 this%input_mempath, found)
913 this%deps =
dp999 * this%dmaxchg
914 write (this%iout, fmtdmaxchg) this%dmaxchg
919 this%input_mempath, found)
920 if (found)
write (this%iout, fmtlengthconv) this%lengthconv
924 this%input_mempath, found)
925 if (found)
write (this%iout, fmttimeconv) this%timeconv
929 this%input_mempath, found)
931 write (
warnmsg,
'(a)')
'SETTING UNIT_CONVERSION DIRECTLY'
938 this%input_mempath, found)
940 if (this%storage_weight <
dhalf .or. this%storage_weight >
done)
then
941 write (
errmsg,
'(a,g0,a)') &
942 "STORAGE_WEIGHT SPECIFIED TO BE '", this%storage_weight, &
943 "' BUT CANNOT BE LESS THAN 0.5 OR GREATER THAN 1.0"
947 write (this%iout, fmtstoweight) this%storage_weight
952 call get_isize(
'ICHECK', this%input_mempath, isize)
955 write (this%iout,
'(4x,a)') &
956 'REACH GEOMETRY AND PARAMETER CHECKS WILL NOT BE MADE'
960 call get_isize(
'ICONVCHK', this%input_mempath, isize)
963 write (this%iout,
'(4x,a)') &
964 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN STREAM FLOW ROUTING '// &
965 'STAGES AND FLOWS WILL NOT BE MADE'
968 write (this%iout,
'(1x,a)') &
969 'END OF '//trim(adjustl(this%text))//
' OPTIONS'
970 end subroutine sfr_source_options
974 subroutine sfr_source_dimensions(this)
978 class(sfrtype),
intent(inout) :: this
980 logical(LGP) :: found
985 write (this%iout,
'(/1x,a)') &
986 'PROCESSING '//trim(adjustl(this%text))//
' DIMENSIONS'
989 call mem_set_value(this%maxbound,
'MAXBOUND', this%input_mempath, found, &
992 write (this%iout,
'(4x,a,i0)')
'NREACHES = ', this%maxbound
995 write (this%iout,
'(1x,a)') &
996 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
998 if (this%maxbound < 1)
then
1000 'NREACHES was not specified or was specified incorrectly.'
1009 call this%define_listlabel()
1012 this%ncrossptstot = this%maxbound
1015 call this%sfr_allocate_arrays()
1018 call this%sfr_source_packagedata()
1021 call this%sfr_source_crosssections()
1024 call this%sfr_source_connectiondata()
1027 call this%sfr_source_diversions()
1030 call this%sfr_checkin_deprecated_names()
1033 call this%sfr_source_initialstages()
1036 call this%sfr_setup_budobj()
1039 call this%sfr_setup_tableobj()
1040 end subroutine sfr_source_dimensions
1044 subroutine sfr_source_packagedata(this)
1049 class(sfrtype),
intent(inout) :: this
1051 integer(I4B) :: i, n, nconzero
1052 integer(I4B) :: ipos
1053 character(len=10) :: cnum
1054 character(len=LENBOUNDNAME) :: bndName
1055 character(len=LINELENGTH) :: cellid_str
1056 integer(I4B),
allocatable :: nboundchk(:)
1057 integer(I4B),
dimension(:),
pointer,
contiguous :: ifno => null()
1058 integer(I4B),
dimension(:, :),
pointer,
contiguous :: cellid => null()
1059 real(DP),
dimension(:),
pointer,
contiguous :: rlen => null()
1060 real(DP),
dimension(:),
pointer,
contiguous :: rwid => null()
1061 real(DP),
dimension(:),
pointer,
contiguous :: rgrd => null()
1062 real(DP),
dimension(:),
pointer,
contiguous :: rtp => null()
1063 real(DP),
dimension(:),
pointer,
contiguous :: rbth => null()
1064 integer(I4B),
dimension(:),
pointer,
contiguous :: ncon => null()
1065 integer(I4B),
dimension(:),
pointer,
contiguous :: ndv => null()
1068 integer(I4B),
dimension(:, :),
pointer,
contiguous :: tslink => null()
1070 tslinkvars => null()
1072 write (this%iout,
'(/1x,a)') &
1073 'PROCESSING '//trim(adjustl(this%text))//
' PACKAGEDATA'
1076 call mem_setptr(ifno,
'PACKAGEDATA_IFNO', this%input_mempath)
1077 call mem_setptr(cellid,
'CELLID', this%input_mempath)
1078 call mem_setptr(rlen,
'RLEN', this%input_mempath)
1079 call mem_setptr(rwid,
'RWID', this%input_mempath)
1080 call mem_setptr(rgrd,
'RGRD', this%input_mempath)
1081 call mem_setptr(rtp,
'RTP', this%input_mempath)
1082 call mem_setptr(rbth,
'RBTH', this%input_mempath)
1083 call mem_setptr(this%input%rhk,
'RHK', this%input_mempath)
1084 call mem_setptr(this%input%man,
'MAN', this%input_mempath)
1085 call mem_setptr(ncon,
'NCON', this%input_mempath)
1086 call mem_setptr(this%input%ustrf,
'USTRF', this%input_mempath)
1087 call mem_setptr(tslink,
'TSLINK_PD', this%input_mempath)
1088 call mem_setptr(tslinkvars,
'TSLINKVARS_PD', this%input_mempath)
1089 do n = 1,
size(tslinkvars)
1090 if (tslinkvars(n) ==
'RHK') this%input%rhk_tslink => tslink(n, :)
1091 if (tslinkvars(n) ==
'MAN') this%input%man_tslink => tslink(n, :)
1092 if (tslinkvars(n) ==
'USTRF') this%input%ustrf_tslink => tslink(n, :)
1094 if (.not. (
associated(this%input%rhk_tslink) .and. &
1095 associated(this%input%man_tslink) .and. &
1096 associated(this%input%ustrf_tslink)))
then
1097 call store_error(
'Time series links for RHK, MAN and USTRF not found &
1101 call mem_setptr(ndv,
'NDV', this%input_mempath)
1102 if (this%inamedbound /= 0)
then
1103 call mem_setptr(boundname,
'BOUNDNAME', this%input_mempath)
1107 allocate (nboundchk(this%maxbound))
1112 do i = 1, this%maxbound
1115 n = this%validate_ifno(n, this%maxbound, nboundchk, &
1116 'rno',
'PACKAGEDATA')
1121 if (all(cellid(1:this%dis%ndim, i) <= 0))
then
1122 this%igwfnode(n) = 0
1124 write (cellid_str,
'(10(i0,1x))') cellid(1:this%dis%ndim, i)
1125 this%igwfnode(n) = this%dis%noder_from_cellid(cellid_str, &
1126 this%inunit, this%iout, &
1127 flag_string=.false., &
1130 this%igwftopnode(n) = this%igwfnode(n)
1131 if (this%igwfnode(n) < 1) this%ianynone = this%ianynone + 1
1134 this%length(n) = rlen(i)
1135 this%width(n) = rwid(i)
1136 this%slope(n) = rgrd(i)
1137 this%strtop(n) = rtp(i)
1138 this%bthick(n) = rbth(i)
1141 this%nconnreach(n) = ncon(i)
1142 this%nconn = this%nconn + ncon(i)
1143 if (ncon(i) < 0)
then
1144 write (
errmsg,
'(a,1x,i0,1x,a,i0,a)') &
1145 'NCON for reach', n, &
1146 'must be greater than or equal to 0 (', ncon(i),
').'
1148 else if (ncon(i) == 0)
then
1149 nconzero = nconzero + 1
1153 this%ndiv(n) = ndv(i)
1154 if (ndv(i) > 0) this%idiversions = 1
1157 write (cnum,
'(i10.10)') n
1158 bndname =
'Reach'//cnum
1159 if (this%inamedbound /= 0)
then
1160 bndname = boundname(i)
1162 this%sfrname(n) = bndname
1166 this%hk(n) = this%input%rhk(i)
1167 this%rough(n) = this%input%man(i)
1168 this%ustrf(n) = this%input%ustrf(i)
1171 this%sstage(n) = this%strtop(n)
1174 write (this%iout,
'(1x,a)') &
1175 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1178 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1180 deallocate (nboundchk)
1182 if (nconzero > 0)
then
1183 write (
warnmsg,
'(a,1x,a,1x,a,1x,i0,1x,a)') &
1184 'SFR Package', trim(this%packName), &
1185 'has', nconzero,
'reach(es) with zero connections.'
1195 this%iacross(1) = ipos
1196 do i = 1, this%maxbound
1197 this%ncrosspts(i) = 1
1198 this%station(ipos) = this%width(i)
1199 this%xsheight(ipos) =
dzero
1200 this%xsrough(ipos) =
done
1202 this%iacross(i + 1) = ipos
1207 call memorystore_release(
'CELLID', this%input_mempath)
1208 call memorystore_release(
'RLEN', this%input_mempath)
1209 call memorystore_release(
'RWID', this%input_mempath)
1210 call memorystore_release(
'RGRD', this%input_mempath)
1211 call memorystore_release(
'RTP', this%input_mempath)
1212 call memorystore_release(
'RBTH', this%input_mempath)
1213 call memorystore_release(
'NCON', this%input_mempath)
1214 call memorystore_release(
'NDV', this%input_mempath)
1215 call memorystore_release(
'BOUNDNAME', this%input_mempath)
1216 end subroutine sfr_source_packagedata
1220 subroutine sfr_source_crosssections(this)
1227 class(sfrtype),
intent(inout) :: this
1229 integer(I4B),
dimension(:),
pointer,
contiguous :: ifno => null()
1231 tab6_filename => null()
1233 sfrtab6_mempaths => null()
1235 integer(I4B) :: i, n, ncrossptstot
1236 integer(I4B),
allocatable :: nboundchk(:)
1237 integer(I4B) :: isize
1238 character(len=LINELENGTH) :: tabfname
1239 character(len=LENMEMPATH) :: mempath
1242 call get_isize(
'CROSSSECT_IFNO', this%input_mempath, isize)
1243 if (isize < 1)
return
1245 write (this%iout,
'(/1x,a)') &
1246 'PROCESSING '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1249 call mem_setptr(ifno,
'CROSSSECT_IFNO', this%input_mempath)
1250 call mem_setptr(tab6_filename,
'SFRTAB6_FILENAME', this%input_mempath)
1251 call mem_setptr(sfrtab6_mempaths,
'SFRTAB6_MEMPATH', this%input_mempath)
1255 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1256 this%iacross, this%station, this%xsheight, &
1259 allocate (nboundchk(this%maxbound))
1263 n = this%validate_ifno(ifno(i), this%maxbound, nboundchk, &
1264 'reach',
'CROSSSECTIONS')
1266 tabfname = tab6_filename(i)
1267 mempath = sfrtab6_mempaths(i)
1268 call cross_data%source_table(n, this%width(n), mempath, &
1269 trim(adjustl(tabfname)))
1272 write (this%iout,
'(1x,a)') &
1273 'END OF '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1276 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1277 'CROSSSECTIONS', check_missing=.false.)
1278 deallocate (nboundchk)
1285 ncrossptstot = cross_data%get_ncrossptstot()
1286 if (ncrossptstot /= this%ncrossptstot)
then
1287 this%ncrossptstot = ncrossptstot
1288 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
1290 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
1292 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
1296 call cross_data%output(this%width, this%rough)
1297 call cross_data%pack(this%ncrossptstot, this%ncrosspts, this%iacross, &
1298 this%station, this%xsheight, this%xsrough)
1299 call cross_data%destroy()
1300 deallocate (cross_data)
1301 nullify (cross_data)
1304 call memorystore_release(
'CROSSSECT_IFNO', this%input_mempath)
1305 call memorystore_release(
'SFRTAB6_FILENAME', this%input_mempath)
1306 end subroutine sfr_source_crosssections
1310 subroutine sfr_source_connectiondata(this)
1315 class(sfrtype),
intent(inout) :: this
1317 integer(I4B),
dimension(:),
pointer,
contiguous :: cd_ifno => null()
1318 integer(I4B),
dimension(:),
pointer,
contiguous :: ic_flat => null()
1319 integer(I4B),
dimension(:),
pointer,
contiguous :: cd_ia => null()
1321 integer(I4B),
dimension(:),
pointer,
contiguous :: rowmaxnnz => null()
1322 integer(I4B),
allocatable :: nboundchk(:)
1323 integer(I4B),
allocatable :: iconndata(:, :)
1324 integer(I4B),
allocatable :: iup(:)
1325 integer(I4B),
allocatable :: order(:)
1326 type(
dag) :: sfr_dag
1327 integer(I4B) :: i, n, j, jj, jcol, jcol2, nja, nconnmax
1328 integer(I4B) :: ival, idir, nup, ipos, istat, ierr, jlocal, nread
1330 write (this%iout,
'(/1x,a)') &
1331 'PROCESSING '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1334 call mem_setptr(cd_ifno,
'CONNDATA_IFNO', this%input_mempath)
1335 call mem_setptr(ic_flat,
'IC', this%input_mempath)
1336 call mem_setptr(cd_ia,
'IC_IA', this%input_mempath)
1339 allocate (nboundchk(this%maxbound))
1345 allocate (rowmaxnnz(this%maxbound))
1346 do n = 1, this%maxbound
1347 ival = this%nconnreach(n)
1348 if (ival < 0) ival = 0
1349 rowmaxnnz(n) = ival + 1
1350 nja = nja + ival + 1
1351 if (ival > nconnmax) nconnmax = ival
1364 allocate (iconndata(nconnmax, this%maxbound))
1368 call sparse%init(this%maxbound, this%maxbound, rowmaxnnz)
1371 do i = 1, this%maxbound
1372 n = this%validate_ifno(cd_ifno(i), this%maxbound, nboundchk, &
1373 'reach',
'CONNECTIONDATA')
1375 nread = cd_ia(i + 1) - cd_ia(i)
1376 if (nread /= this%nconnreach(n))
then
1377 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,a)') &
1378 'Reach', n,
'connectiondata specifies', nread, &
1379 'connections but NCON for this reach in packagedata is', &
1380 this%nconnreach(n),
'.'
1384 call sparse%addconnection(n, n, 1)
1386 do j = cd_ia(i), cd_ia(i + 1) - 1
1389 iconndata(jlocal, n) = ival
1393 else if (ival == 0)
then
1394 call store_error(
'Missing or zero connection reach in connectiondata.')
1399 if (ival > this%maxbound)
then
1400 call store_error(
'Reach number exceeds NREACHES in connectiondata.')
1403 call sparse%addconnection(n, ival, 1)
1407 write (this%iout,
'(1x,a)') &
1408 'END OF '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1410 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1418 call sparse%filliaja(this%ia, this%ja, ierr,
sort=.true.)
1420 write (
errmsg,
'(a,3(1x,a))') &
1421 'Could not fill', trim(this%packName), &
1422 'package IA and JA connection data.', &
1423 'Check connectivity data in connectiondata block.'
1428 do n = 1, this%maxbound
1429 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1431 do jj = 1, this%nconnreach(n)
1432 jcol2 = iconndata(jj, n)
1433 if (abs(jcol2) == jcol)
then
1435 if (jcol2 < 0) idir = -1
1444 deallocate (rowmaxnnz)
1445 deallocate (nboundchk)
1446 deallocate (iconndata)
1447 call sparse%destroy()
1451 call sfr_dag%set_vertices(this%maxbound)
1452 fill_dag:
do n = 1, this%maxbound
1454 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1455 if (this%idir(j) > 0) nup = nup + 1
1457 if (nup == 0) cycle fill_dag
1460 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1461 if (this%idir(j) > 0)
then
1462 iup(ipos) = this%ja(j)
1466 call sfr_dag%set_edges(n, iup)
1469 call sfr_dag%toposort(order, istat)
1470 if (istat == -1)
then
1472 trim(adjustl(this%text))//
' PACKAGE ('// &
1473 trim(adjustl(this%packName))//
') cannot calculate a '// &
1474 'Directed Asyclic Graph for reach connectivity because '// &
1475 'of circular dependency. Using the reach number for '// &
1476 'solution ordering.'
1479 do n = 1, this%maxbound
1480 if (istat == 0)
then
1481 this%isfrorder(n) = order(n)
1483 this%isfrorder(n) = n
1486 call sfr_dag%destroy()
1487 if (istat == 0)
deallocate (order)
1490 call memorystore_release(
'CONNDATA_IFNO', this%input_mempath)
1491 call memorystore_release(
'IC', this%input_mempath)
1492 call memorystore_release(
'IC_IA', this%input_mempath)
1493 end subroutine sfr_source_connectiondata
1497 subroutine sfr_source_diversions(this)
1502 class(sfrtype),
intent(inout) :: this
1504 integer(I4B),
dimension(:),
pointer,
contiguous :: d_ifno => null()
1505 integer(I4B),
dimension(:),
pointer,
contiguous :: d_idv => null()
1506 integer(I4B),
dimension(:),
pointer,
contiguous :: d_iconr => null()
1509 integer(I4B) :: i, n, idiv, ndiversions, i0, ipos, jpos
1510 integer(I4B) :: isize
1511 integer(I4B),
allocatable :: iachk(:), nboundchk(:)
1512 character(len=16) :: cval
1518 do n = 1, this%maxbound
1519 ndiversions = ndiversions + this%ndiv(n)
1520 i0 = i0 + this%ndiv(n)
1521 this%iadiv(n + 1) = i0
1525 if (ndiversions > 0)
then
1528 allocate (this%divcprior(ndiversions))
1529 call mem_setptr(this%divflow,
'DIVFLOW', this%input_mempath)
1530 call mem_reallocate(this%divq, ndiversions,
'DIVQ', this%memoryPath)
1535 call get_isize(
'DIVERSIONS_IFNO', this%input_mempath, isize)
1537 if (this%idiversions /= 0)
then
1538 call store_error(
'REQUIRED DIVERSIONS BLOCK NOT FOUND.')
1544 if (this%idiversions == 0)
then
1545 write (
errmsg,
'(a,1x,a)') &
1546 'A diversions block should not be', &
1547 'specified if diversions are not specified.'
1553 write (this%iout,
'(/1x,a)') &
1554 'PROCESSING '//trim(adjustl(this%text))//
' DIVERSIONS'
1557 call mem_setptr(d_ifno,
'DIVERSIONS_IFNO', this%input_mempath)
1558 call mem_setptr(d_idv,
'DIVERSIONS_IDV', this%input_mempath)
1559 call mem_setptr(d_iconr,
'ICONR', this%input_mempath)
1560 call mem_setptr(d_cprior,
'CPRIOR', this%input_mempath)
1563 allocate (iachk(this%maxbound + 1))
1564 allocate (nboundchk(ndiversions))
1567 do n = 1, this%maxbound
1568 iachk(n + 1) = iachk(n) + this%ndiv(n)
1573 if (n < 1 .or. n > this%maxbound)
then
1574 write (
errmsg,
'(a,i0,a)')
'Reach number should be between 1 and ', &
1579 if (this%ndiv(n) < 1)
then
1580 write (
errmsg,
'(a,i0)') &
1581 'Diversions cannot be specified for reach ', n
1586 if (idiv < 1 .or. idiv > this%ndiv(n))
then
1587 write (
errmsg,
'(a,i0,a,i0,a)') &
1588 'Reach ', n,
' diversion number should be between 1 and ', &
1593 ipos = iachk(n) + idiv - 1
1594 nboundchk(ipos) = nboundchk(ipos) + 1
1595 jpos = this%iadiv(n) + idiv - 1
1596 if (d_iconr(i) < 1 .or. d_iconr(i) > this%maxbound)
then
1597 write (
errmsg,
'(a,i0,a)') &
1598 'Diversion target reach number should be between 1 and ', &
1603 this%divreach(jpos) = d_iconr(i)
1605 select case (trim(cval))
1606 case (
'UPTO',
'THRESHOLD',
'FRACTION',
'EXCESS')
1608 errmsg =
'Invalid cprior type '//trim(cval)//
'.'
1611 this%divcprior(jpos) = trim(cval)
1614 write (this%iout,
'(1x,a)') &
1615 'END OF '//trim(adjustl(this%text))//
' DIVERSIONS'
1617 do n = 1, this%maxbound
1618 do idiv = 1, this%ndiv(n)
1619 ipos = iachk(n) + idiv - 1
1620 if (nboundchk(ipos) == 0)
then
1621 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1622 'No data specified for reach', n,
'diversion', idiv
1624 else if (nboundchk(ipos) > 1)
then
1625 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1626 'Data for reach', n,
'diversion', idiv, &
1627 'specified', nboundchk(ipos),
'times'
1633 deallocate (nboundchk)
1640 call memorystore_release(
'DIVERSIONS_IFNO', this%input_mempath)
1641 call memorystore_release(
'DIVERSIONS_IDV', this%input_mempath)
1642 call memorystore_release(
'ICONR', this%input_mempath)
1643 call memorystore_release(
'CPRIOR', this%input_mempath)
1644 end subroutine sfr_source_diversions
1648 subroutine sfr_source_initialstages(this)
1652 class(sfrtype),
intent(inout) :: this
1654 integer(I4B),
dimension(:),
pointer,
contiguous :: is_ifno => null()
1655 real(DP),
dimension(:),
pointer,
contiguous :: is_stage => null()
1656 integer(I4B) :: i, n
1657 integer(I4B) :: isize
1658 integer(I4B),
allocatable :: nboundchk(:)
1662 call get_isize(
'INITSTAGE_IFNO', this%input_mempath, isize)
1665 if (this%istorage == 1)
then
1666 do n = 1, this%maxbound
1667 this%stage(n) = this%strtop(n)
1673 write (this%iout,
'(/1x,a)') &
1674 'PROCESSING '//trim(adjustl(this%text))//
' INITIALSTAGES'
1676 call mem_setptr(is_ifno,
'INITSTAGE_IFNO', this%input_mempath)
1677 call mem_setptr(is_stage,
'INITIALSTAGE', this%input_mempath)
1679 allocate (nboundchk(this%maxbound))
1683 n = this%validate_ifno(is_ifno(i), this%maxbound, nboundchk, &
1684 'reach',
'INITIALSTAGES')
1687 this%stage(n) = rval
1688 this%depth(n) = rval - this%strtop(n)
1689 if (rval < this%strtop(n))
then
1690 write (
errmsg,
'(a,g0,a,1x,i0,1x,a,g0,a)') &
1691 'Initial stage (', rval,
') for reach', n, &
1692 'is less than the reach top (', this%strtop(n),
').'
1697 write (this%iout,
'(1x,a)') &
1698 'END OF '//trim(adjustl(this%text))//
' INITIALSTAGES'
1700 call this%report_ifno_coverage(nboundchk, this%maxbound,
'reach', &
1702 deallocate (nboundchk)
1709 call memorystore_release(
'INITSTAGE_IFNO', this%input_mempath)
1710 call memorystore_release(
'INITIALSTAGE', this%input_mempath)
1711 end subroutine sfr_source_initialstages
1717 subroutine sfr_ar(this)
1721 class(sfrtype),
intent(inout) :: this
1724 integer(I4B) :: ierr
1727 call this%obs%obs_ar()
1730 call this%BndExtType%allocate_arrays()
1734 call this%BndExtType%allocate_featureauxvar()
1738 call this%input%init(this%input_mempath, this%naux)
1741 if (this%inamedbound /= 0)
then
1742 do n = 1, this%maxbound
1743 this%boundname(n) = this%sfrname(n)
1748 call this%copy_boundname()
1751 do n = 1, this%maxbound
1752 this%nodelist(n) = this%igwfnode(n)
1756 call this%sfr_check_conversion()
1759 call this%sfr_check_storage_weight()
1762 if (this%ats_courant /= dnodata .and. this%istorage /= 1)
then
1764 'ATS_COURANT OPTION REQUIRES STORAGE OPTION TO BE ACTIVE'
1769 if (this%ats_courant /= dnodata .and.
inats == 0)
then
1771 'ATS_COURANT IS SPECIFIED IN THE SFR OPTIONS BLOCK BUT THE '// &
1772 'ATS PACKAGE IS NOT ACTIVE IN TDIS, SO THE TIME STEP IS NOT '// &
1773 'ADAPTED TO THE COURANT NUMBER. IF THE COURANT NUMBER EXCEEDS 1 '// &
1774 'THE EXPLICIT KINEMATIC-WAVE ROUTING MAY OSCILLATE WHILE STILL '// &
1775 'CLOSING THE BUDGET. ACTIVATE THE ATS PACKAGE OR USE A SMALLER '// &
1781 if (this%ats_courant /= dnodata .and. this%istorage == 1)
then
1782 call this%sfr_precompute_tvd()
1786 call this%sfr_check_reaches()
1789 call this%sfr_check_connections()
1792 if (this%idiversions /= 0)
then
1793 call this%sfr_check_diversions()
1797 if (this%istorage == 1)
then
1798 call this%sfr_check_initialstages()
1808 if (this%imover /= 0)
then
1809 allocate (this%pakmvrobj)
1810 call this%pakmvrobj%ar(this%maxbound, this%maxbound, this%memoryPath)
1812 end subroutine sfr_ar
1818 subroutine sfr_rp(this)
1825 class(sfrtype),
intent(inout) :: this
1827 character(len=LINELENGTH) :: crossfile
1828 character(len=LINELENGTH) :: str
1829 real(DP) :: auxvaldbl
1830 character(len=LINELENGTH) :: title
1831 character(len=LINELENGTH) :: text
1832 character(len=LENVARNAME) :: setting
1833 character(len=10) :: cnum
1834 character(len=10) :: cp
1839 integer(I4B) :: idiv
1840 integer(I4B) :: ichkustrm
1841 integer(I4B) :: ncrossptstot
1844 character(len=*),
parameter :: fmtlsp = &
1845 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
1854 this%nbound = this%maxbound
1857 if (this%iper ==
kper)
then
1861 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1863 this%station, this%xsheight, &
1867 if (this%iprpak /= 0)
then
1868 title = trim(adjustl(this%text))//
' PACKAGE ('// &
1869 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
1870 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
1871 call table_cr(this%inputtab, this%packName, title)
1872 call this%inputtab%table_df(1, 4, this%iout,
finalize=.false.)
1874 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
1876 call this%inputtab%initialize_column(text, 20, alignment=
tableft)
1878 write (text,
'(a,1x,i6)')
'VALUE', jj
1879 call this%inputtab%initialize_column(text, 15, alignment=
tabcenter)
1884 do i = 1, this%input%nbound
1885 n = this%input%ifno(i)
1886 if (n < 1 .or. n > this%maxbound)
then
1887 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
1888 'Reach number (RNO) must be greater than 0 and', &
1889 'less than or equal to', this%maxbound,
'.'
1895 setting = this%input%setting(i)
1898 if (trim(setting) ==
'STATUS')
then
1899 str = this%input%status(i)
1901 if (str ==
'INACTIVE')
then
1902 this%iboundpak(n) = 0
1903 else if (str ==
'ACTIVE')
then
1904 this%iboundpak(n) = 1
1905 else if (str ==
'SIMPLE')
then
1906 this%iboundpak(n) = -1
1909 'Unknown '//trim(this%text)//
' sfr status keyword: ', trim(str)
1916 call this%sfr_set_period_value(i, n, setting)
1917 if (trim(setting) ==
'UPSTREAM_FRAC') ichkustrm = 1
1920 if (trim(setting) ==
'DIVERSION')
then
1921 if (this%ndiv(n) < 1)
then
1922 write (cnum,
'(i0)') n
1923 errmsg =
'diversions cannot be specified for reach '//trim(cnum)
1926 idiv = this%input%idv(i)
1927 if (idiv < 1 .or. idiv > this%ndiv(n))
then
1928 write (cnum,
'(i0)') n
1929 errmsg =
'Reach '//trim(cnum)
1930 write (cnum,
'(i0)') this%ndiv(n)
1931 errmsg = trim(
errmsg)//
' diversion number should be between 1 '// &
1932 'and '//trim(cnum)//
'.'
1935 ii = this%iadiv(n) + idiv - 1
1937 cp = this%divcprior(ii)
1938 if (cp ==
'FRACTION' .and. &
1939 (this%divflow(ii) <
dzero .or. this%divflow(ii) >
done))
then
1940 write (
errmsg,
'(a,1x,i0,a)') &
1941 'cprior is type FRACTION for diversion no.', ii, &
1942 ', but divflow not within the range 0.0 to 1.0'
1950 if (trim(setting) ==
'CROSS_SECTION')
then
1951 crossfile = this%input%tab6_filename(i)
1952 call cross_data%read_table(n, this%width(n), trim(adjustl(crossfile)))
1957 if (this%naux > 0)
then
1958 if (trim(setting) ==
'PERIOD_AUXILIARY')
then
1959 str = this%input%auxname(i)
1960 auxvaldbl = this%input%auxval(i)
1965 if (this%iprpak /= 0)
then
1966 call this%inputtab%add_term(n)
1967 if (trim(setting) ==
'PERIOD_AUXILIARY')
then
1968 call this%inputtab%add_term(
'AUXILIARY')
1970 call this%inputtab%add_term(trim(setting))
1972 select case (trim(setting))
1974 call this%inputtab%add_term(trim(str))
1975 call this%inputtab%add_term(
' ')
1977 call this%inputtab%add_term(this%hk(n))
1978 call this%inputtab%add_term(
' ')
1980 call this%inputtab%add_term(this%rough(n))
1981 call this%inputtab%add_term(
' ')
1983 call this%inputtab%add_term(this%sstage(n))
1984 call this%inputtab%add_term(
' ')
1986 call this%inputtab%add_term(this%inflow(n))
1987 call this%inputtab%add_term(
' ')
1989 call this%inputtab%add_term(this%rain(n))
1990 call this%inputtab%add_term(
' ')
1991 case (
'EVAPORATION')
1992 call this%inputtab%add_term(this%evap(n))
1993 call this%inputtab%add_term(
' ')
1995 call this%inputtab%add_term(this%runoff(n))
1996 call this%inputtab%add_term(
' ')
1997 case (
'UPSTREAM_FRAC')
1998 call this%inputtab%add_term(this%ustrf(n))
1999 call this%inputtab%add_term(
' ')
2001 call this%inputtab%add_term(idiv)
2002 call this%inputtab%add_term(this%divflow(ii))
2003 case (
'CROSS_SECTION')
2004 call this%inputtab%add_term(trim(crossfile))
2005 call this%inputtab%add_term(
' ')
2006 case (
'PERIOD_AUXILIARY')
2007 call this%inputtab%add_term(trim(str))
2008 call this%inputtab%add_term(auxvaldbl)
2010 call this%inputtab%add_term(
' ')
2011 call this%inputtab%add_term(
' ')
2015 if (this%iprpak /= 0)
then
2016 call this%inputtab%finalize_table()
2020 ncrossptstot = cross_data%get_ncrossptstot()
2023 if (ncrossptstot /= this%ncrossptstot)
then
2024 this%ncrossptstot = ncrossptstot
2025 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
2027 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
2029 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
2034 call cross_data%output(this%width, this%rough,
kstp=1,
kper=
kper)
2037 call cross_data%pack(this%ncrossptstot, this%ncrosspts, &
2044 call cross_data%destroy()
2045 deallocate (cross_data)
2046 nullify (cross_data)
2048 write (this%iout, fmtlsp) trim(this%filtyp)
2053 if (ichkustrm /= 0)
then
2054 call this%sfr_check_ustrf()
2061 end subroutine sfr_rp
2068 subroutine sfr_ad(this)
2073 class(sfrtype) :: this
2078 integer(I4B) :: idiv
2079 integer(I4B) :: iaux
2080 character(len=LENVARNAME) :: setting
2084 call this%BndExtType%bnd_ad()
2089 do n = 1, this%maxbound
2090 this%stageold(n) = this%stage(n)
2091 this%usinflowold(n) = this%usinflow(n)
2092 this%dsflowold(n) = this%dsflow(n)
2093 this%xsausold(n) = this%xsaus(n)
2094 this%xsadsold(n) = this%xsads(n)
2101 if (this%ts_active)
then
2102 do i = 1, this%maxbound
2103 n = this%pkg_ifno(i)
2104 if (.not. this%bedk_set(n) .and. &
2105 this%input%rhk_tslink(i) /= 0) &
2106 this%hk(n) = this%input%rhk(i)
2107 if (.not. this%manning_set(n) .and. &
2108 this%input%man_tslink(i) /= 0) &
2109 this%rough(n) = this%input%man(i)
2110 if (.not. this%ustrf_set(n) .and. &
2111 this%input%ustrf_tslink(i) /= 0) &
2112 this%ustrf(n) = this%input%ustrf(i)
2115 if (this%input%nbound > 0)
then
2116 do i = 1, this%input%nbound
2117 n = this%input%ifno(i)
2118 if (n < 1 .or. n > this%maxbound) cycle
2120 setting = this%input%setting(i)
2121 call this%sfr_set_period_value(i, n, setting)
2123 if (trim(setting) ==
'DIVERSION')
then
2124 if (this%ndiv(n) >= 1)
then
2125 idiv = this%input%idv(i)
2126 if (idiv >= 1 .and. idiv <= this%ndiv(n))
then
2127 ii = this%iadiv(n) + idiv - 1
2137 if (this%ts_active)
call this%sfr_check_ustrf()
2142 if (this%naux > 0)
then
2143 do n = 1, this%maxbound
2144 do iaux = 1, this%naux
2145 if (this%noupdateauxvar(iaux) /= 0) cycle
2146 this%auxvar(iaux, n) = this%featureauxvar(iaux, n)
2152 do n = 1, this%maxbound
2153 this%usflow(n) =
dzero
2154 if (this%iboundpak(n) < 0)
then
2155 this%stage(n) = this%sstage(n)
2160 if (this%imover == 1)
then
2161 call this%pakmvrobj%ad()
2163 end subroutine sfr_ad
2170 subroutine sfr_cf(this)
2172 class(sfrtype) :: this
2175 integer(I4B) :: igwfnode
2178 if (this%nbound == 0)
return
2181 do n = 1, this%nbound
2182 igwfnode = this%igwftopnode(n)
2183 if (igwfnode > 0)
then
2184 if (this%ibound(igwfnode) == 0)
then
2185 call this%dis%highest_active(igwfnode, this%ibound)
2188 this%igwfnode(n) = igwfnode
2189 this%nodelist(n) = igwfnode
2191 end subroutine sfr_cf
2198 subroutine sfr_fc(this, rhs, ia, idxglo, matrix_sln)
2200 class(sfrtype) :: this
2201 real(DP),
dimension(:),
intent(inout) :: rhs
2202 integer(I4B),
dimension(:),
intent(in) :: ia
2203 integer(I4B),
dimension(:),
intent(in) :: idxglo
2209 integer(I4B) :: ipos
2210 integer(I4B) :: node
2221 sfrpicard:
do i = 1, this%maxsfrpicard
2227 if (this%imover == 1)
then
2228 call this%pakmvrobj%fc()
2232 reachsolve:
do j = 1, this%nbound
2233 n = this%isfrorder(j)
2234 node = this%igwfnode(n)
2236 hgwf = this%xnew(node)
2243 this%stage0(n) = this%stage(n)
2244 this%usflow0(n) = this%usflow(n)
2251 if (this%iboundpak(n) /= 0)
then
2252 call this%sfr_solve(n, hgwf, hhcof, rrhs)
2254 this%depth(n) = dzero
2255 this%stage(n) = this%strtop(n)
2257 call this%sfr_update_flows(n, v, v)
2258 if (this%istorage == 1)
then
2259 this%usinflow(n) = dzero
2260 this%storage(n) = dzero
2267 this%hcof(n) = hhcof
2271 ds = s0 - this%stage(n)
2274 if (abs(ds) > abs(dsmax))
then
2281 if (abs(dsmax) <= this%dmaxchg)
then
2288 do n = 1, this%nbound
2289 node = this%nodelist(n)
2291 rhs(node) = rhs(node) + this%rhs(n)
2293 call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(n))
2295 end subroutine sfr_fc
2302 subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
2304 class(sfrtype) :: this
2305 real(DP),
dimension(:),
intent(inout) :: rhs
2306 integer(I4B),
dimension(:),
intent(in) :: ia
2307 integer(I4B),
dimension(:),
intent(in) :: idxglo
2313 integer(I4B) :: ipos
2326 do j = 1, this%nbound
2327 i = this%isfrorder(j)
2329 if (this%iboundpak(i) < 1) cycle
2331 n = this%nodelist(i)
2334 rterm = this%hcof(i) * this%xnew(n)
2336 hgwf = this%xnew(n) + dem4
2338 if (this%istorage == 1) storage = this%storage(i)
2339 call this%sfr_solve(i, hgwf, hcof1, rhs1, update=.false.)
2340 if (this%istorage == 1) this%storage(i) = storage
2341 q1 = rhs1 - hcof1 * hgwf
2343 q2 = this%rhs(i) - this%hcof(i) * this%xnew(n)
2345 drterm = (q2 - q1) / dem4
2348 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(i))
2349 rhs(n) = rhs(n) - rterm + drterm * this%xnew(n)
2351 end subroutine sfr_fn
2358 subroutine sfr_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
2362 class(sfrtype),
intent(inout) :: this
2363 integer(I4B),
intent(in) :: innertot
2364 integer(I4B),
intent(in) :: kiter
2365 integer(I4B),
intent(in) :: iend
2366 integer(I4B),
intent(in) :: icnvgmod
2367 character(len=LENPAKLOC),
intent(inout) :: cpak
2368 integer(I4B),
intent(inout) :: ipak
2369 real(DP),
intent(inout) :: dpak
2371 character(len=LENPAKLOC) :: cloc
2372 character(len=LINELENGTH) :: tag
2373 integer(I4B) :: icheck
2374 integer(I4B) :: ipakfail
2375 integer(I4B) :: locdhmax
2376 integer(I4B) :: locrmax
2377 integer(I4B) :: locdqfrommvrmax
2378 integer(I4B) :: ntabrows
2379 integer(I4B) :: ntabcols
2383 real(DP) :: qtolfact
2388 real(DP) :: dqfrommvr
2389 real(DP) :: dqfrommvrmax
2392 icheck = this%iconvchk
2400 dqfrommvrmax = dzero
2404 if (this%ipakcsv == 0)
then
2405 if (icnvgmod == 0)
then
2413 if (.not.
associated(this%pakcsvtab))
then
2418 if (this%imover == 1)
then
2419 ntabcols = ntabcols + 2
2423 call table_cr(this%pakcsvtab, this%packName,
'')
2424 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
2425 lineseparator=.false., separator=
',', &
2429 tag =
'total_inner_iterations'
2430 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
2432 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
2434 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
2436 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
2438 call this%pakcsvtab%initialize_column(tag, 10, alignment=tableft)
2440 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
2442 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
2444 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
2445 tag =
'dinflowmax_loc'
2446 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
2447 if (this%imover == 1)
then
2448 tag =
'dqfrommvrmax'
2449 call this%pakcsvtab%initialize_column(tag, 15, alignment=tableft)
2450 tag =
'dqfrommvrmax_loc'
2451 call this%pakcsvtab%initialize_column(tag, 16, alignment=tableft)
2457 if (icheck /= 0)
then
2458 final_check:
do n = 1, this%maxbound
2459 if (this%iboundpak(n) == 0) cycle
2462 qtolfact =
delt / this%calc_surface_area(n)
2465 dh = this%stage0(n) - this%stage(n)
2468 if (this%gwfiss == 0)
then
2469 r = this%usflow0(n) - this%usflow(n)
2477 if (this%imover == 1)
then
2478 q = this%pakmvrobj%get_qfrommvr(n)
2479 q0 = this%pakmvrobj%get_qfrommvr0(n)
2480 dqfrommvr = qtolfact * (q0 - q)
2489 dqfrommvrmax = dqfrommvr
2492 if (abs(dh) > abs(dhmax))
then
2496 if (abs(r) > abs(rmax))
then
2500 if (abs(dqfrommvr) > abs(dqfrommvrmax))
then
2501 dqfrommvrmax = dqfrommvr
2508 if (abs(dhmax) > abs(dpak))
then
2511 write (cloc,
"(a,'-',a)") trim(this%packName),
'stage'
2514 if (abs(rmax) > abs(dpak))
then
2517 write (cloc,
"(a,'-',a)") trim(this%packName),
'inflow'
2520 if (this%imover == 1)
then
2521 if (abs(dqfrommvrmax) > abs(dpak))
then
2522 ipak = locdqfrommvrmax
2524 write (cloc,
"(a,'-',a)") trim(this%packName),
'qfrommvr'
2530 if (this%ipakcsv /= 0)
then
2533 call this%pakcsvtab%add_term(innertot)
2534 call this%pakcsvtab%add_term(
totim)
2535 call this%pakcsvtab%add_term(
kper)
2536 call this%pakcsvtab%add_term(
kstp)
2537 call this%pakcsvtab%add_term(kiter)
2538 call this%pakcsvtab%add_term(dhmax)
2539 call this%pakcsvtab%add_term(locdhmax)
2540 call this%pakcsvtab%add_term(rmax)
2541 call this%pakcsvtab%add_term(locrmax)
2542 if (this%imover == 1)
then
2543 call this%pakcsvtab%add_term(dqfrommvrmax)
2544 call this%pakcsvtab%add_term(locdqfrommvrmax)
2549 call this%pakcsvtab%finalize_table()
2553 end subroutine sfr_cc
2559 subroutine sfr_cq(this, x, flowja, iadv)
2563 class(sfrtype),
intent(inout) :: this
2564 real(DP),
dimension(:),
intent(in) :: x
2565 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2566 integer(I4B),
optional,
intent(in) :: iadv
2573 real(DP) :: qoutflow
2574 real(DP) :: qfrommvr
2580 call this%BndType%bnd_cq(x, flowja, iadv=1)
2585 if (this%istorage == 1)
then
2586 do n = 1, this%maxbound
2587 call this%sfr_calc_reach_depth(n, this%usinflow(n), d)
2588 this%xsaus(n) = this%calc_area_wet(n, d)
2589 call this%sfr_calc_reach_depth(n, this%dsflow(n), d)
2590 this%xsads(n) = this%calc_area_wet(n, d)
2595 do n = 1, this%maxbound
2600 if (this%imover == 1)
then
2601 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
2602 qtomvr = this%pakmvrobj%get_qtomvr(n)
2603 if (qtomvr > dzero)
then
2609 qext = this%dsflow(n)
2611 if (qext > dzero)
then
2614 do i = this%ia(n) + 1, this%ia(n + 1) - 1
2615 if (this%idir(i) > 0) cycle
2617 if (this%iboundpak(n2) == 0) cycle
2623 if (qext < dzero)
then
2624 if (qtomvr < dzero)
then
2625 qext = qext - qtomvr
2628 qoutflow = this%dsflow(n)
2629 if (qoutflow > dzero)
then
2630 qoutflow = -qoutflow
2636 this%qextoutflow(n) = qext
2637 this%qoutflow(n) = qoutflow
2642 call this%sfr_fill_budobj()
2643 end subroutine sfr_cq
2649 subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
2653 class(sfrtype) :: this
2654 integer(I4B),
intent(in) :: icbcfl
2655 integer(I4B),
intent(in) :: ibudfl
2657 integer(I4B) :: ibinun
2658 character(len=20),
dimension(:),
allocatable :: cellidstr
2660 integer(I4B) :: node
2664 if (this%ibudgetout /= 0)
then
2665 ibinun = this%ibudgetout
2667 if (icbcfl == 0) ibinun = 0
2668 if (ibinun > 0)
then
2669 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
2674 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
2680 if (this%ianynone > 0)
then
2681 allocate (cellidstr(this%maxbound))
2682 do n = 1, this%maxbound
2683 node = this%igwfnode(n)
2685 call this%dis%noder_to_string(node, cellidstr(n))
2687 cellidstr(n) =
'NONE'
2690 call this%budobj%write_flowtable(this%dis,
kstp,
kper, cellidstr)
2691 deallocate (cellidstr)
2693 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
2696 end subroutine sfr_ot_package_flows
2702 subroutine sfr_ot_dv(this, idvsave, idvprint)
2707 class(sfrtype) :: this
2708 integer(I4B),
intent(in) :: idvsave
2709 integer(I4B),
intent(in) :: idvprint
2711 character(len=20) :: cellid
2712 integer(I4B) :: ibinun
2714 integer(I4B) :: node
2727 if (this%istageout /= 0)
then
2728 ibinun = this%istageout
2730 if (idvsave == 0) ibinun = 0
2733 if (ibinun > 0)
then
2734 do n = 1, this%maxbound
2737 if (this%iboundpak(n) == 0)
then
2739 else if (d == dzero)
then
2745 this%maxbound, 1, 1, ibinun)
2749 if (idvprint /= 0 .and. this%iprhed /= 0)
then
2752 call this%stagetab%set_kstpkper(
kstp,
kper)
2755 do n = 1, this%maxbound
2756 node = this%igwfnode(n)
2758 call this%dis%noder_to_string(node, cellid)
2759 hgwf = this%xnew(node)
2763 if (this%inamedbound == 1)
then
2764 call this%stagetab%add_term(this%boundname(n))
2766 call this%stagetab%add_term(n)
2767 call this%stagetab%add_term(cellid)
2768 if (this%iboundpak(n) /= 0)
then
2769 depth = this%depth(n)
2770 stage = this%stage(n)
2771 w = this%calc_top_width_wet(n, depth)
2772 call this%sfr_calc_cond(n, depth, cond, stage, hgwf)
2779 if (depth == dzero)
then
2780 call this%stagetab%add_term(dhdry)
2782 call this%stagetab%add_term(stage)
2784 call this%stagetab%add_term(depth)
2785 call this%stagetab%add_term(w)
2787 if (this%iboundpak(n) /= 0)
then
2788 sbot = this%strtop(n) - this%bthick(n)
2789 if (hgwf < sbot)
then
2794 grad = grad / this%bthick(n)
2798 call this%stagetab%add_term(hgwf)
2799 call this%stagetab%add_term(cond)
2800 call this%stagetab%add_term(grad)
2802 call this%stagetab%add_term(
'--')
2803 call this%stagetab%add_term(
'--')
2804 call this%stagetab%add_term(
'--')
2808 end subroutine sfr_ot_dv
2814 subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
2818 class(sfrtype) :: this
2819 integer(I4B),
intent(in) :: kstp
2820 integer(I4B),
intent(in) :: kper
2821 integer(I4B),
intent(in) :: iout
2822 integer(I4B),
intent(in) :: ibudfl
2824 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
2825 end subroutine sfr_ot_bdsummary
2829 subroutine sfr_fp(this)
2831 class(sfrtype) :: this
2836 if (this%istorage == 1)
then
2837 do n = 1, this%maxbound
2838 if (this%inamedbound == 1)
then
2839 call this%couranttab%add_term(this%boundname(n))
2841 call this%couranttab%add_term(n)
2842 if (this%crmin(n) == dep20)
then
2843 call this%couranttab%add_term(
'--')
2845 call this%couranttab%add_term(this%crmin(n))
2847 if (this%crmax(n) < dzero)
then
2848 call this%couranttab%add_term(
'--')
2850 call this%couranttab%add_term(this%crmax(n))
2852 if (this%crcnt(n) > 0)
then
2853 crmean = this%crsum(n) / real(this%crcnt(n), dp)
2854 call this%couranttab%add_term(crmean)
2856 call this%couranttab%add_term(
'--')
2860 end subroutine sfr_fp
2864 subroutine sfr_dt(this)
2868 class(sfrtype) :: this
2871 integer(I4B) :: nrmin
2872 real(DP) :: celerity
2875 character(len=LINELENGTH) :: msg
2877 if (this%ats_courant == dnodata)
return
2878 if (this%istorage /= 1)
return
2883 do n = 1, this%maxbound
2884 call this%sfr_calc_celerity(n, this%dsflow(n), celerity)
2885 if (celerity > dzero)
then
2886 dt_n = this%ats_courant * this%length(n) / celerity
2887 if (dt_n < dtmin)
then
2895 write (msg,
'(a,i0)') trim(this%packName)//
'-REACH-', nrmin
2896 call ats%ats_submit_delt(
kstp,
kper, dtmin, trim(msg))
2898 end subroutine sfr_dt
2902 subroutine sfr_calc_celerity(this, n, q, celerity)
2904 class(sfrtype) :: this
2905 integer(I4B),
intent(in) :: n
2906 real(DP),
intent(in) :: q
2907 real(DP),
intent(out) :: celerity
2914 call this%sfr_calc_reach_depth(n, q, d)
2916 a = this%calc_area_wet(n, d)
2917 call this%sfr_calc_reach_depth(n, q + this%deps, d)
2918 a2 = this%calc_area_wet(n, d)
2920 celerity = this%deps / (a2 - a)
2923 end subroutine sfr_calc_celerity
2929 subroutine sfr_da(this)
2933 class(sfrtype) :: this
2938 deallocate (this%csfrbudget)
2941 deallocate (this%cauxcbc)
2969 if (this%istorage == 1)
then
2996 nullify (this%inflow)
2997 nullify (this%runoff)
2998 nullify (this%sstage)
3000 nullify (this%rough)
3001 nullify (this%ustrf)
3006 if (
associated(this%divcprior))
then
3007 deallocate (this%divcprior)
3011 if (
associated(this%divflow))
then
3012 if (
size(this%divflow) == 0)
then
3015 nullify (this%divflow)
3029 call this%budobj%budgetobject_da()
3030 deallocate (this%budobj)
3031 nullify (this%budobj)
3034 if (this%iprhed > 0)
then
3035 call this%stagetab%table_da()
3036 deallocate (this%stagetab)
3037 nullify (this%stagetab)
3041 if (
associated(this%couranttab))
then
3042 call this%couranttab%table_da()
3043 deallocate (this%couranttab)
3044 nullify (this%couranttab)
3048 if (this%ipakcsv > 0)
then
3049 if (
associated(this%pakcsvtab))
then
3050 call this%pakcsvtab%table_da()
3051 deallocate (this%pakcsvtab)
3052 nullify (this%pakcsvtab)
3081 nullify (this%gwfiss)
3084 call this%input%destroy()
3087 call this%BndExtType%bnd_da()
3088 end subroutine sfr_da
3094 subroutine sfr_precompute_tvd(this)
3096 class(sfrtype),
intent(inout) :: this
3100 integer(I4B) :: iup_count
3103 do n = 1, this%maxbound
3106 do j = this%ia(n) + 1, this%ia(n + 1) - 1
3107 if (this%idir(j) > 0)
then
3108 iup_count = iup_count + 1
3112 if (iup_count == 1)
then
3113 this%itvd_upstream(n) = m
3115 this%itvd_upstream(n) = 0
3118 end subroutine sfr_precompute_tvd
3127 class(sfrtype),
intent(inout) :: this
3130 this%listlabel = trim(this%filtyp)//
' NO.'
3131 if (this%dis%ndim == 3)
then
3132 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
3133 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
3134 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
3135 elseif (this%dis%ndim == 2)
then
3136 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
3137 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
3139 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
3141 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
3142 if (this%inamedbound == 1)
then
3143 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
3157 logical function sfr_obs_supported(this)
3159 class(sfrtype) :: this
3162 sfr_obs_supported = .true.
3163 end function sfr_obs_supported
3169 subroutine sfr_df_obs(this)
3171 class(sfrtype) :: this
3173 integer(I4B) :: indx
3177 call this%obs%StoreObsType(
'stage', .false., indx)
3178 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3182 call this%obs%StoreObsType(
'inflow', .true., indx)
3183 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3187 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
3188 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3192 call this%obs%StoreObsType(
'rainfall', .true., indx)
3193 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3197 call this%obs%StoreObsType(
'runoff', .true., indx)
3198 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3202 call this%obs%StoreObsType(
'evaporation', .true., indx)
3203 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3207 call this%obs%StoreObsType(
'outflow', .true., indx)
3208 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3212 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
3213 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3217 call this%obs%StoreObsType(
'to-mvr', .true., indx)
3218 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3222 call this%obs%StoreObsType(
'from-mvr', .true., indx)
3223 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3227 call this%obs%StoreObsType(
'sfr', .true., indx)
3228 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3232 call this%obs%StoreObsType(
'upstream-flow', .true., indx)
3233 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3237 call this%obs%StoreObsType(
'downstream-flow', .true., indx)
3238 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3242 call this%obs%StoreObsType(
'depth', .false., indx)
3243 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3247 call this%obs%StoreObsType(
'wet-perimeter', .false., indx)
3248 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3252 call this%obs%StoreObsType(
'wet-area', .false., indx)
3253 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3257 call this%obs%StoreObsType(
'wet-width', .false., indx)
3258 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3259 end subroutine sfr_df_obs
3265 subroutine sfr_bd_obs(this)
3267 class(sfrtype) :: this
3273 character(len=100) :: msg
3277 if (this%obs%npakobs > 0)
then
3278 call this%obs%obs_bd_clear()
3279 do i = 1, this%obs%npakobs
3280 obsrv => this%obs%pakobs(i)%obsrv
3281 do j = 1, obsrv%indxbnds_count
3282 n = obsrv%indxbnds(j)
3284 select case (obsrv%ObsTypeId)
3289 if (this%imover == 1)
then
3290 v = this%pakmvrobj%get_qtomvr(n)
3297 if (this%imover == 1)
then
3298 v = this%pakmvrobj%get_qfrommvr(n)
3305 v = this%qoutflow(n)
3306 case (
'EXT-OUTFLOW')
3307 v = this%qextoutflow(n)
3309 if (this%iboundpak(n) /= 0)
then
3315 v = this%simrunoff(n)
3316 case (
'EVAPORATION')
3320 case (
'UPSTREAM-FLOW')
3322 if (this%imover == 1)
then
3323 v = v + this%pakmvrobj%get_qfrommvr(n)
3325 case (
'DOWNSTREAM-FLOW')
3332 case (
'WET-PERIMETER')
3333 v = this%calc_perimeter_wet(n, this%depth(n))
3335 v = this%calc_area_wet(n, this%depth(n))
3337 v = this%calc_top_width_wet(n, this%depth(n))
3339 msg =
'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
3342 call this%obs%SaveOneSimval(obsrv, v)
3351 end subroutine sfr_bd_obs
3357 subroutine sfr_rp_obs(this)
3361 class(sfrtype),
intent(inout) :: this
3366 character(len=LENBOUNDNAME) :: bname
3367 logical(LGP) :: jfound
337010
format(
'Boundary "', a,
'" for observation "', a, &
3371 '" is invalid in package "', a,
'"')
337230
format(
'Boundary name not provided for observation "', a, &
3373 '" in package "', a,
'"')
3379 do i = 1, this%obs%npakobs
3380 obsrv => this%obs%pakobs(i)%obsrv
3383 nn1 = obsrv%NodeNumber
3384 if (nn1 == namedboundflag)
then
3385 bname = obsrv%FeatureName
3386 if (bname /=
'')
then
3391 if (this%inamedbound /= 0)
then
3392 do j = 1, this%maxbound
3393 if (this%boundname(j) == bname)
then
3395 call obsrv%AddObsIndex(j)
3399 if (.not. jfound)
then
3400 write (errmsg, 10) &
3401 trim(bname), trim(obsrv%name), trim(this%packName)
3405 write (errmsg, 30) trim(obsrv%name), trim(this%packName)
3408 else if (nn1 < 1 .or. nn1 > this%maxbound)
then
3409 write (errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3410 trim(adjustl(obsrv%ObsTypeId)), &
3411 'reach must be greater than 0 and less than or equal to', &
3412 this%maxbound,
'(specified value is ', nn1,
')'
3415 if (obsrv%indxbnds_count == 0)
then
3416 call obsrv%AddObsIndex(nn1)
3418 errmsg =
'Programming error in sfr_rp_obs'
3425 if (obsrv%ObsTypeId ==
'STAGE' .or. &
3426 obsrv%ObsTypeId ==
'DEPTH' .or. &
3427 obsrv%ObsTypeId ==
'WET-PERIMETER' .or. &
3428 obsrv%ObsTypeId ==
'WET-AREA' .or. &
3429 obsrv%ObsTypeId ==
'WET-WIDTH')
then
3430 nn1 = obsrv%NodeNumber
3431 if (nn1 == namedboundflag)
then
3432 if (obsrv%indxbnds_count > 1)
then
3433 write (errmsg,
'(a,3(1x,a))') &
3434 trim(adjustl(obsrv%ObsTypeId)), &
3435 'for observation', trim(adjustl(obsrv%Name)), &
3436 ' must be assigned to a reach with a unique boundname.'
3443 do j = 1, obsrv%indxbnds_count
3444 nn1 = obsrv%indxbnds(j)
3445 if (nn1 < 1 .or. nn1 > this%maxbound)
then
3446 write (errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3447 trim(adjustl(obsrv%ObsTypeId)), &
3448 'reach must be greater than 0 and less than or equal to', &
3449 this%maxbound,
'(specified value is ', nn1,
')'
3460 end subroutine sfr_rp_obs
3469 subroutine sfr_process_obsid(obsrv, dis, inunitobs, iout)
3473 integer(I4B),
intent(in) :: inunitobs
3474 integer(I4B),
intent(in) :: iout
3477 integer(I4B) :: icol
3478 integer(I4B) :: istart
3479 integer(I4B) :: istop
3480 character(len=LINELENGTH) :: string
3481 character(len=LENBOUNDNAME) :: bndname
3484 string = obsrv%IDstring
3492 call extract_idnum_or_bndname(string, icol, istart, istop, nn1, bndname)
3493 if (nn1 == namedboundflag)
then
3494 obsrv%FeatureName = bndname
3498 obsrv%NodeNumber = nn1
3499 end subroutine sfr_process_obsid
3505 subroutine sfr_solve(this, n, h, hcof, rhs, update)
3507 class(sfrtype) :: this
3508 integer(I4B),
intent(in) :: n
3509 real(DP),
intent(in) :: h
3510 real(DP),
intent(inout) :: hcof
3511 real(DP),
intent(inout) :: rhs
3512 logical(LGP),
intent(in),
optional :: update
3514 logical(LGP) :: lupdate
3527 real(DP) :: qfrommvr
3540 if (
present(update))
then
3550 if (this%iboundpak(n) == 0)
then
3551 this%depth(n) = dzero
3552 this%stage(n) = dhnoflo
3553 this%usflow(n) = dzero
3554 this%simevap(n) = dzero
3555 this%simrunoff(n) = dzero
3556 this%dsflow(n) = dzero
3557 this%gwflow(n) = dzero
3569 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3570 if (this%idir(i) < 0) cycle
3572 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
3573 if (this%idir(ii) > 0) cycle
3574 if (this%ja(ii) /= n) cycle
3575 qu = qu + this%qconn(ii)
3581 sa = this%calc_surface_area(n)
3582 sa_wet = this%calc_surface_area_wet(n, this%depth(n))
3584 qr = this%rain(n) * sa
3585 qe = this%evap(n) * sa_wet
3586 qro = this%runoff(n)
3590 if (this%imover == 1)
then
3591 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3595 qsrc = qu + qi + qr - qe + qro + qfrommvr
3598 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3601 this%simevap(n) = qe
3602 this%simrunoff(n) = qro
3606 if (this%istorage == 1)
then
3607 this%usinflow(n) = qu + qi + qfrommvr
3608 this%storage(n) = dzero
3612 if (this%iboundpak(n) < 0)
then
3613 call this%sfr_calc_constant(n, d1, hgwf, qgwf, qd)
3615 if (this%gwfiss == 0 .and. this%istorage == 1)
then
3616 if (this%ats_courant /= dnodata)
then
3617 call this%sfr_calc_tvd(n, d1, hgwf, qu, qi, &
3618 qfrommvr, qr, qe, qro, &
3621 call this%sfr_calc_transient(n, d1, hgwf, qu, qi, &
3622 qfrommvr, qr, qe, qro, &
3626 call this%sfr_calc_steady(n, d1, hgwf, qu, qi, &
3627 qfrommvr, qr, qe, qro, &
3634 bt = tp - this%bthick(n)
3641 this%stage(n) = hsfr
3643 call this%sfr_update_flows(n, qd, qgwf)
3649 if (this%gwfiss == 0)
then
3660 call this%sfr_calc_qgwf(n, d1, hgwf, qgwf, gwfhcof, gwfrhs)
3663 if (abs(sumleak) > dzero)
then
3668 else if ((sumleak - qsrc) < -dem30)
then
3669 if (this%gwfiss == 0)
then
3670 rhs = rhs + gwfrhs - sumrch
3677 if (this%gwfiss == 0)
then
3678 rhs = rhs - sumleak - sumrch
3685 else if (hgwf < bt)
then
3689 end subroutine sfr_solve
3696 subroutine sfr_update_flows(this, n, qd, qgwf)
3698 class(sfrtype),
intent(inout) :: this
3699 integer(I4B),
intent(in) :: n
3700 real(DP),
intent(inout) :: qd
3701 real(DP),
intent(in) :: qgwf
3705 integer(I4B) :: idiv
3706 integer(I4B) :: jpos
3716 this%gwflow(n) = qgwf
3719 if (qd > dzero)
then
3722 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3723 if (this%idir(i) > 0) cycle
3725 if (idiv == 0) cycle
3726 jpos = this%iadiv(n) + idiv - 1
3727 call this%sfr_calc_div(n, idiv, qd, qdiv)
3728 this%qconn(i) = qdiv
3729 this%divq(jpos) = qdiv
3735 if (this%imover == 1)
then
3736 call this%pakmvrobj%accumulate_qformvr(n, qd)
3737 qd = max(qd - this%pakmvrobj%get_qtomvr(n), dzero)
3741 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3742 if (this%idir(i) > 0) cycle
3743 if (this%idiv(i) > 0) cycle
3745 if (this%iboundpak(n2) == 0) cycle
3746 f = this%ustrf(n2) / this%ftotnd(n)
3747 this%qconn(i) = qd * f
3750 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3751 if (this%idir(i) > 0) cycle
3752 this%qconn(i) = dzero
3754 if (idiv == 0) cycle
3755 jpos = this%iadiv(n) + idiv - 1
3756 this%divq(jpos) = dzero
3759 end subroutine sfr_update_flows
3766 subroutine sfr_adjust_ro_ev(this, qc, qu, qi, qr, qro, qe, qfrommvr)
3768 class(sfrtype) :: this
3769 real(DP),
intent(inout) :: qc
3770 real(DP),
intent(in) :: qu
3771 real(DP),
intent(in) :: qi
3772 real(DP),
intent(in) :: qr
3773 real(DP),
intent(inout) :: qro
3774 real(DP),
intent(inout) :: qe
3775 real(DP),
intent(in) :: qfrommvr
3780 if (qc < dzero)
then
3783 qt = qu + qi + qr + qro + qfrommvr
3786 if (qt < dzero)
then
3787 if (qro < dzero)
then
3788 qro = -(qu + qi + qr + qfrommvr)
3794 if (qe > dzero)
then
3795 qe = qu + qi + qr + qro + qfrommvr
3798 qc = qu + qi + qr - qe + qro + qfrommvr
3800 end subroutine sfr_adjust_ro_ev
3806 subroutine sfr_calc_qd(this, n, depth, hgwf, qgwf, qd)
3808 class(sfrtype) :: this
3809 integer(I4B),
intent(in) :: n
3810 real(DP),
intent(in) :: depth
3811 real(DP),
intent(in) :: hgwf
3812 real(DP),
intent(inout) :: qgwf
3813 real(DP),
intent(inout) :: qd
3821 call this%sfr_calc_qsource(n, depth, qsrc)
3824 call this%sfr_calc_qgwf(n, depth, hgwf, qgwf)
3825 if (-qgwf > qsrc) qgwf = -qsrc
3831 if (qd < dem30) qd = dzero
3832 end subroutine sfr_calc_qd
3839 subroutine sfr_calc_qsource(this, n, depth, qsrc)
3841 class(sfrtype) :: this
3842 integer(I4B),
intent(in) :: n
3843 real(DP),
intent(in) :: depth
3844 real(DP),
intent(inout) :: qsrc
3851 real(DP) :: qfrommvr
3861 qro = this%runoff(n)
3864 a = this%calc_surface_area(n)
3865 ae = this%calc_surface_area_wet(n, depth)
3866 qr = this%rain(n) * a
3867 qe = this%evap(n) * ae
3871 if (this%imover == 1)
then
3872 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3876 qsrc = qu + qi + qr - qe + qro + qfrommvr
3879 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3880 end subroutine sfr_calc_qsource
3887 subroutine sfr_calc_qman(this, n, depth, qman)
3889 class(sfrtype) :: this
3890 integer(I4B),
intent(in) :: n
3891 real(DP),
intent(in) :: depth
3892 real(DP),
intent(inout) :: qman
3894 integer(I4B) :: npts
3909 if (depth > dzero)
then
3910 npts = this%ncrosspts(n)
3921 i0 = this%iacross(n)
3922 i1 = this%iacross(n + 1) - 1
3927 this%station(i0:i1), &
3928 this%xsheight(i0:i1), &
3929 this%xsrough(i0:i1), &
3936 aw = this%calc_area_wet(n, depth)
3937 wp = this%calc_perimeter_wet(n, depth)
3938 if (wp > dzero)
then
3943 qman = this%unitconv * aw * (rh**dtwothirds) * sqrt(s) / r
3949 end subroutine sfr_calc_qman
3957 subroutine sfr_calc_qgwf(this, n, depth, hgwf, qgwf, gwfhcof, gwfrhs)
3959 class(sfrtype) :: this
3960 integer(I4B),
intent(in) :: n
3961 real(DP),
intent(in) :: depth
3962 real(DP),
intent(in) :: hgwf
3963 real(DP),
intent(inout) :: qgwf
3964 real(DP),
intent(inout),
optional :: gwfhcof
3965 real(DP),
intent(inout),
optional :: gwfrhs
3967 integer(I4B) :: node
3975 real(DP) :: gwfhcof0
3982 node = this%igwfnode(n)
3983 if (node < 1)
return
3986 if (this%ibound(node) == 0)
return
3993 bt = tp - this%bthick(n)
3996 if (h_temp < bt)
then
4001 call this%sfr_calc_cond(n, depth, cond, hsfr, h_temp)
4004 qgwf = sat * cond * (h_temp - hsfr)
4005 gwfrhs0 = -sat * cond * hsfr
4006 gwfhcof0 = -sat * cond
4009 if (this%idense /= 0)
then
4010 call this%sfr_calculate_density_exchange(n, hsfr, hgwf, cond, tp, &
4011 qgwf, gwfhcof0, gwfrhs0)
4015 if (
present(gwfhcof)) gwfhcof = gwfhcof0
4016 if (
present(gwfrhs)) gwfrhs = gwfrhs0
4017 end subroutine sfr_calc_qgwf
4024 function sfr_gwf_conn(this, n)
4026 integer(I4B) :: sfr_gwf_conn
4028 class(sfrtype) :: this
4029 integer(I4B),
intent(in) :: n
4031 integer(I4B) :: node
4034 node = this%igwfnode(n)
4035 if (node > 0 .and. this%hk(n) > dzero)
then
4038 end function sfr_gwf_conn
4044 subroutine sfr_calc_cond(this, n, depth, cond, hsfr, h_temp)
4046 class(sfrtype) :: this
4047 integer(I4B),
intent(in) :: n
4048 real(DP),
intent(in) :: depth
4049 real(DP),
intent(inout) :: cond
4050 real(DP),
intent(in),
optional :: hsfr
4051 real(DP),
intent(in),
optional :: h_temp
4053 integer(I4B) :: node
4055 real(DP) :: vscratio
4065 node = this%igwfnode(n)
4067 if (this%ibound(node) > 0)
then
4070 if (this%ivsc == 1)
then
4071 if (hsfr > h_temp)
then
4073 vscratio = this%viscratios(1, n)
4075 vscratio = this%viscratios(2, n)
4078 wp = this%calc_perimeter_wet(n, depth)
4079 cond = this%hk(n) * vscratio * this%length(n) * wp / this%bthick(n)
4082 end subroutine sfr_calc_cond
4091 subroutine sfr_calc_div(this, n, i, qd, qdiv)
4093 class(sfrtype) :: this
4094 integer(I4B),
intent(in) :: n
4095 integer(I4B),
intent(in) :: i
4096 real(DP),
intent(inout) :: qd
4097 real(DP),
intent(inout) :: qdiv
4099 character(len=10) :: cp
4100 integer(I4B) :: jpos
4105 jpos = this%iadiv(n) + i - 1
4106 n2 = this%divreach(jpos)
4107 cp = this%divcprior(jpos)
4108 v = this%divflow(jpos)
4139 end subroutine sfr_calc_div
4145 subroutine sfr_calc_reach_depth(this, n, q1, d1)
4147 class(sfrtype) :: this
4148 integer(I4B),
intent(in) :: n
4149 real(DP),
intent(in) :: q1
4150 real(DP),
intent(inout) :: d1
4162 if (q1 > dzero)
then
4163 if (this%ncrosspts(n) > 1)
then
4164 call this%sfr_calc_xs_depth(n, q1, d1)
4166 w = this%station(this%iacross(n))
4167 qconst = this%unitconv * w * sqrt(s) / r
4168 d1 = (q1 / qconst)**dp6
4173 end subroutine sfr_calc_reach_depth
4180 subroutine sfr_calc_xs_depth(this, n, qrch, d)
4182 class(sfrtype) :: this
4183 integer(I4B),
intent(in) :: n
4184 real(DP),
intent(in) :: qrch
4185 real(DP),
intent(inout) :: d
4187 integer(I4B) :: iter
4188 real(DP) :: perturbation
4194 real(DP) :: residual
4197 perturbation = this%deps * dtwo
4200 residual = q0 - qrch
4203 nriter:
do iter = 1, this%maxsfrit
4204 call this%sfr_calc_qman(n, d + perturbation, q1)
4206 if (dq /= dzero)
then
4207 derv = perturbation / (q1 - q0)
4211 dd = derv * residual
4213 call this%sfr_calc_qman(n, d, q0)
4214 residual = q0 - qrch
4217 if (abs(dd) < this%dmaxchg)
then
4221 end subroutine sfr_calc_xs_depth
4228 subroutine sfr_check_conversion(this)
4230 class(sfrtype) :: this
4233 character(len=*),
parameter :: fmtunitconv_error = &
4234 &
"('SFR (',a,') UNIT_CONVERSION SPECIFIED VALUE (',g0,') AND', &
4235 &1x,'LENGTH_CONVERSION OR TIME_CONVERSION SPECIFIED.')"
4236 character(len=*),
parameter :: fmtunitconv = &
4237 &
"(1x,'SFR PACKAGE (',a,') CONVERSION DATA',&
4238 &/4x,'UNIT CONVERSION VALUE (',g0,').',/)"
4241 if (this%lengthconv /= dnodata .or. this%timeconv /= dnodata)
then
4242 if (this%unitconv /= done)
then
4243 write (errmsg, fmtunitconv_error) &
4244 trim(adjustl(this%packName)), this%unitconv
4247 if (this%lengthconv /= dnodata)
then
4248 this%unitconv = this%unitconv * this%lengthconv**donethird
4250 if (this%timeconv /= dnodata)
then
4251 this%unitconv = this%unitconv * this%timeconv
4253 write (this%iout, fmtunitconv) &
4254 trim(adjustl(this%packName)), this%unitconv
4257 end subroutine sfr_check_conversion
4265 subroutine sfr_check_storage_weight(this)
4267 class(sfrtype) :: this
4269 character(len=*),
parameter :: fmtweight = &
4270 &
"(1x,'SFR PACKAGE (',a,') SETTING DEFAULT',&
4271 &/4x,'STORAGE_WEIGHT VALUE (',g0,').',/)"
4274 if (this%istorage == 1)
then
4275 if (this%storage_weight == dnodata)
then
4276 this%storage_weight = done
4277 write (this%iout, fmtweight) &
4278 trim(adjustl(this%packName)), this%storage_weight
4281 end subroutine sfr_check_storage_weight
4289 subroutine sfr_check_reaches(this)
4291 class(sfrtype) :: this
4293 character(len=5) :: crch
4294 character(len=10) :: cval
4295 character(len=30) :: nodestr
4296 character(len=LINELENGTH) :: title
4297 character(len=LINELENGTH) :: text
4304 if (this%iprpak /= 0)
then
4305 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4306 trim(adjustl(this%packName))//
') STATIC REACH DATA'
4307 call table_cr(this%inputtab, this%packName, title)
4308 call this%inputtab%table_df(this%maxbound, 10, this%iout)
4310 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4312 call this%inputtab%initialize_column(text, 20, alignment=tableft)
4314 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4316 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4318 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4320 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4322 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4324 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4326 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4327 text =
'UPSTREAM FRACTION'
4328 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4332 do n = 1, this%maxbound
4333 write (crch,
'(i5)') n
4334 nn = this%igwfnode(n)
4336 btgwf = this%dis%bot(nn)
4337 call this%dis%noder_to_string(nn, nodestr)
4342 if (this%length(n) <= dzero)
then
4343 errmsg =
'Reach '//crch//
' length must be greater than 0.0.'
4347 if (this%width(n) <= dzero)
then
4348 errmsg =
'Reach '//crch//
' width must be greater than 0.0.'
4352 if (this%slope(n) <= dzero)
then
4353 errmsg =
'Reach '//crch//
' slope must be greater than 0.0.'
4358 bt = this%strtop(n) - this%bthick(n)
4359 if (bt <= btgwf .and. this%icheck /= 0)
then
4360 write (cval,
'(f10.4)') bt
4361 errmsg =
'Reach '//crch//
' bed bottom (rtp-rbth ='// &
4362 cval//
') must be greater than the bottom of cell ('// &
4364 write (cval,
'(f10.4)') btgwf
4365 errmsg = trim(adjustl(errmsg))//
'='//cval//
').'
4368 if (this%hk(n) < dzero)
then
4369 errmsg =
'Reach '//crch//
' hk must be greater than or equal to 0.0.'
4374 if (this%rough(n) <= dzero)
then
4375 errmsg =
'Reach '//crch//
" Manning's roughness "// &
4376 'coefficient must be greater than 0.0.'
4380 if (this%ustrf(n) < dzero)
then
4381 errmsg =
'Reach '//crch//
' upstream fraction must be greater '// &
4382 'than or equal to 0.0.'
4386 if (this%iprpak /= 0)
then
4387 call this%inputtab%add_term(n)
4388 call this%inputtab%add_term(nodestr)
4389 call this%inputtab%add_term(this%length(n))
4390 call this%inputtab%add_term(this%width(n))
4391 call this%inputtab%add_term(this%slope(n))
4392 call this%inputtab%add_term(this%strtop(n))
4393 call this%inputtab%add_term(this%bthick(n))
4394 call this%inputtab%add_term(this%hk(n))
4395 call this%inputtab%add_term(this%rough(n))
4396 call this%inputtab%add_term(this%ustrf(n))
4399 end subroutine sfr_check_reaches
4407 subroutine sfr_check_connections(this)
4409 class(sfrtype) :: this
4411 logical(LGP) :: lreorder
4412 character(len=5) :: crch
4413 character(len=5) :: crch2
4414 character(len=LINELENGTH) :: text
4415 character(len=LINELENGTH) :: title
4422 integer(I4B) :: ifound
4423 integer(I4B) :: ierr
4424 integer(I4B) :: maxconn
4425 integer(I4B) :: ntabcol
4429 do j = 1, this%MAXBOUND
4430 n = this%isfrorder(j)
4439 write (this%iout,
'(/,1x,a)') &
4440 trim(adjustl(this%text))//
' PACKAGE ('// &
4441 trim(adjustl(this%packName))//
') REACH SOLUTION HAS BEEN '// &
4442 'REORDERED USING A DAG'
4445 if (this%iprpak /= 0)
then
4449 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4450 trim(adjustl(this%packName))//
') REACH SOLUTION ORDER'
4451 call table_cr(this%inputtab, this%packName, title)
4452 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4454 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4456 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4459 do j = 1, this%maxbound
4460 n = this%isfrorder(j)
4461 call this%inputtab%add_term(j)
4462 call this%inputtab%add_term(n)
4468 if (this%iprpak /= 0)
then
4472 do n = 1, this%maxbound
4473 maxconn = max(maxconn, this%nconnreach(n))
4475 ntabcol = 1 + maxconn
4478 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4479 trim(adjustl(this%packName))//
') STATIC REACH CONNECTION DATA'
4480 call table_cr(this%inputtab, this%packName, title)
4481 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4483 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4485 write (text,
'(a,1x,i6)')
'CONN', n
4486 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4492 do n = 1, this%MAXBOUND
4493 write (crch,
'(i5)') n
4494 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4496 write (crch2,
'(i5)') nn
4498 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4505 if (ifound /= 1)
then
4506 errmsg =
'Reach '//crch//
' is connected to '// &
4507 'reach '//crch2//
' but reach '//crch2// &
4508 ' is not connected to reach '//crch//
'.'
4514 if (this%iprpak /= 0)
then
4515 call this%inputtab%add_term(n)
4516 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4517 call this%inputtab%add_term(this%ja(i))
4519 nn = maxconn - this%nconnreach(n)
4521 call this%inputtab%add_term(
' ')
4529 do n = 1, this%maxbound
4530 write (crch,
'(i5)') n
4531 eachconnv:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4534 if (this%idir(i) < 0) cycle eachconnv
4536 write (crch2,
'(i5)') nn
4537 connreachv:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4539 if (this%idir(ii) < 0) cycle connreachv
4546 errmsg =
'Reach '//crch//
' is connected to '// &
4547 'reach '//crch2//
' but streamflow from reach '// &
4548 crch//
' to reach '//crch2//
' is not permitted.'
4563 do n = 1, this%maxbound
4564 write (crch,
'(i5)') n
4565 eachconnds:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4567 if (this%idir(i) > 0) cycle eachconnds
4568 write (crch2,
'(i5)') nn
4570 connreachds:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4573 if (this%idir(i) /= this%idir(ii))
then
4579 if (ifound /= 1)
then
4580 errmsg =
'Reach '//crch//
' downstream connected reach '// &
4581 'is reach '//crch2//
' but reach '//crch//
' is not'// &
4582 ' the upstream connected reach for reach '//crch2//
'.'
4589 if (this%iprpak /= 0)
then
4593 do n = 1, this%maxbound
4595 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4596 if (this%idir(i) > 0)
then
4600 maxconn = max(maxconn, ii)
4602 ntabcol = 1 + maxconn
4605 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4606 trim(adjustl(this%packName))//
') STATIC UPSTREAM REACH '// &
4608 call table_cr(this%inputtab, this%packName, title)
4609 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4611 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4613 write (text,
'(a,1x,i6)')
'UPSTREAM CONN', n
4614 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4618 do n = 1, this%maxbound
4619 call this%inputtab%add_term(n)
4621 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4622 if (this%idir(i) > 0)
then
4623 call this%inputtab%add_term(this%ja(i))
4629 call this%inputtab%add_term(
' ')
4635 do n = 1, this%maxbound
4637 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4638 if (this%idir(i) < 0)
then
4642 maxconn = max(maxconn, ii)
4644 ntabcol = 1 + maxconn
4647 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4648 trim(adjustl(this%packName))//
') STATIC DOWNSTREAM '// &
4649 'REACH CONNECTION DATA'
4650 call table_cr(this%inputtab, this%packName, title)
4651 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4653 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4655 write (text,
'(a,1x,i6)')
'DOWNSTREAM CONN', n
4656 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4660 do n = 1, this%maxbound
4661 call this%inputtab%add_term(n)
4663 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4664 if (this%idir(i) < 0)
then
4665 call this%inputtab%add_term(this%ja(i))
4671 call this%inputtab%add_term(
' ')
4675 end subroutine sfr_check_connections
4683 subroutine sfr_check_diversions(this)
4685 class(sfrtype) :: this
4687 character(len=LINELENGTH) :: title
4688 character(len=LINELENGTH) :: text
4689 character(len=5) :: crch
4690 character(len=5) :: cdiv
4691 character(len=5) :: crch2
4692 character(len=10) :: cprior
4693 integer(I4B) :: maxdiv
4698 integer(I4B) :: idiv
4699 integer(I4B) :: ifound
4700 integer(I4B) :: jpos
470210
format(
'Diversion ', i0,
' of reach ', i0, &
4703 ' is invalid or has not been defined.')
4706 if (this%iprpak /= 0)
then
4710 do n = 1, this%maxbound
4711 maxdiv = maxdiv + this%ndiv(n)
4715 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4716 trim(adjustl(this%packName))//
') REACH DIVERSION DATA'
4717 call table_cr(this%inputtab, this%packName, title)
4718 call this%inputtab%table_df(maxdiv, 4, this%iout)
4720 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4722 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4724 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4726 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4730 do n = 1, this%maxbound
4731 if (this%ndiv(n) < 1) cycle
4732 write (crch,
'(i5)') n
4734 do idiv = 1, this%ndiv(n)
4737 jpos = this%iadiv(n) + idiv - 1
4740 write (cdiv,
'(i5)') idiv
4743 nn = this%divreach(jpos)
4744 write (crch2,
'(i5)') nn
4748 if (nn < 1 .or. nn > this%maxbound)
then
4749 write (errmsg, 10) idiv, n
4753 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4756 if (this%idir(ii) > 0)
then
4762 if (ifound /= 1)
then
4763 errmsg =
'Reach '//crch//
' is not a upstream reach for '// &
4764 'reach '//crch2//
' as a result diversion '//cdiv// &
4765 ' from reach '//crch//
' to reach '//crch2// &
4766 ' is not possible. Check reach connectivity.'
4770 cprior = this%divcprior(jpos)
4773 if (this%iprpak /= 0)
then
4774 call this%inputtab%add_term(n)
4775 call this%inputtab%add_term(idiv)
4776 call this%inputtab%add_term(nn)
4777 call this%inputtab%add_term(cprior)
4781 end subroutine sfr_check_diversions
4790 subroutine sfr_check_initialstages(this)
4791 class(sfrtype) :: this
4793 character(len=LINELENGTH) :: title
4794 character(len=LINELENGTH) :: text
4795 character(len=5) :: crch
4801 if (this%istorage == 0)
return
4804 if (this%iprpak /= 0)
then
4807 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4808 trim(adjustl(this%packName))//
') REACH INITIAL STAGE DATA'
4809 call table_cr(this%inputtab, this%packName, title)
4810 call this%inputtab%table_df(this%maxbound, 4, this%iout)
4812 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4813 text =
'INITIAL STAGE'
4814 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4815 text =
'INITIAL DEPTH'
4816 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4817 text =
'INITIAL FLOW'
4818 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4822 do n = 1, this%maxbound
4823 write (crch,
'(i5)') n
4826 call this%sfr_calc_qman(n, this%depth(n), qman)
4827 this%usinflow(n) = qman
4828 this%dsflow(n) = qman
4829 call this%sfr_calc_reach_depth(n, qman, d)
4830 this%xsaus(n) = this%calc_area_wet(n, d)
4831 this%xsads(n) = this%xsaus(n)
4834 if (this%iprpak /= 0)
then
4835 call this%inputtab%add_term(n)
4836 call this%inputtab%add_term(this%stage(n))
4837 call this%inputtab%add_term(this%depth(n))
4838 call this%inputtab%add_term(qman)
4841 end subroutine sfr_check_initialstages
4849 subroutine sfr_check_ustrf(this)
4851 class(sfrtype) :: this
4853 character(len=LINELENGTH) :: title
4854 character(len=LINELENGTH) :: text
4855 logical(LGP) :: lcycle
4856 logical(LGP) :: ladd
4857 character(len=5) :: crch
4858 character(len=5) :: crch2
4859 character(len=10) :: cval
4860 integer(I4B) :: maxcols
4861 integer(I4B) :: npairs
4862 integer(I4B) :: ipair
4866 integer(I4B) :: idiv
4869 integer(I4B) :: jpos
4875 if (this%iprpak /= 0)
then
4879 do n = 1, this%maxbound
4881 ec:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4884 if (this%idir(i) > 0) cycle ec
4888 if (this%iboundpak(n2) == 0) cycle ec
4892 npairs = max(npairs, ipair)
4895 maxcols = 1 + npairs * 2
4898 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4899 trim(adjustl(this%packName))//
') CONNECTED REACH UPSTREAM '// &
4901 call table_cr(this%inputtab, this%packName, title)
4902 call this%inputtab%table_df(this%maxbound, maxcols, this%iout)
4904 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4906 write (cval,
'(i10)') i
4907 text =
'DOWNSTREAM REACH '//trim(adjustl(cval))
4908 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
4909 text =
'FRACTION '//trim(adjustl(cval))
4910 call this%inputtab%initialize_column(text, 12, alignment=tabcenter)
4915 do n = 1, this%maxbound
4916 do idiv = 1, this%ndiv(n)
4918 i1 = this%iadiv(n + 1) - 1
4920 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4922 if (this%divreach(jpos) == n2)
then
4923 this%idiv(i) = jpos - i0 + 1
4933 do n = 1, this%maxbound
4937 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4938 if (this%idir(i) < 0)
then
4944 do idiv = 1, this%ndiv(n)
4945 jpos = this%iadiv(n) + idiv - 1
4946 n2 = this%divreach(jpos)
4948 if (f /= dzero)
then
4949 write (errmsg,
'(a,2(1x,i0,1x,a),1x,a,g0,a,2(1x,a))') &
4950 'Reach', n,
'is connected to reach', n2,
'by a diversion', &
4951 'but the upstream fraction is not equal to zero (', f,
'). Check', &
4952 trim(this%packName),
'package diversion and package data.'
4956 write (warnmsg,
'(a,3(1x,a))') &
4958 'A warning instead of an error is issued because', &
4959 'the reach is only connected to the diversion reach in the ', &
4960 'downstream direction.'
4970 do n = 1, this%maxbound
4974 write (crch,
'(i5)') n
4975 if (this%iprpak /= 0)
then
4976 call this%inputtab%add_term(n)
4979 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4983 this%qconn(i) = dzero
4986 if (this%idir(i) > 0)
then
4992 if (this%iboundpak(n2) == 0)
then
4999 write (crch2,
'(i5)') n2
5002 f = f + this%ustrf(n2)
5003 write (cval,
'(f10.4)') this%ustrf(n2)
5006 if (this%iprpak /= 0)
then
5007 call this%inputtab%add_term(n2)
5008 call this%inputtab%add_term(this%ustrf(n2))
5010 eachdiv:
do idiv = 1, this%ndiv(n)
5011 jpos = this%iadiv(n) + idiv - 1
5012 if (this%divreach(jpos) == n2)
then
5018 rval = rval + this%ustrf(n2)
5021 this%ftotnd(n) = rval
5024 if (this%iprpak /= 0)
then
5026 do i = ipair, npairs
5027 call this%inputtab%add_term(
' ')
5028 call this%inputtab%add_term(
' ')
5035 if (abs(f - done) > dem6)
then
5036 write (errmsg,
'(a,1x,i0,1x,a,g0,a,3(1x,a))') &
5037 'Upstream fractions for reach ', n,
'is not equal to one (', f, &
5038 '). Check', trim(this%packName),
'package reach connectivity and', &
5044 end subroutine sfr_check_ustrf
5051 subroutine sfr_set_period_value(this, i, n, setting)
5053 class(sfrtype),
intent(inout) :: this
5054 integer(I4B),
intent(in) :: i
5055 integer(I4B),
intent(in) :: n
5056 character(len=*),
intent(in) :: setting
5058 select case (trim(setting))
5060 this%bedk_set(n) = .true.
5062 this%manning_set(n) = .true.
5063 case (
'UPSTREAM_FRAC')
5064 this%ustrf_set(n) = .true.
5066 end subroutine sfr_set_period_value
5074 subroutine sfr_setup_budobj(this)
5076 class(sfrtype) :: this
5078 integer(I4B) :: nbudterm
5083 integer(I4B) :: maxlist
5084 integer(I4B) :: naux
5087 character(len=LENBUDTXT) :: text
5088 character(len=LENBUDTXT),
dimension(1) :: auxtxt
5095 if (this%imover == 1) nbudterm = nbudterm + 2
5096 if (this%naux > 0) nbudterm = nbudterm + 1
5100 call this%budobj%budgetobject_df(this%maxbound, nbudterm, 0, 0, &
5101 ibudcsv=this%ibudcsv)
5105 text =
' FLOW-JA-FACE'
5107 maxlist = this%nconn
5109 auxtxt(1) =
' FLOW-AREA'
5110 call this%budobj%budterm(idx)%initialize(text, &
5115 maxlist, .false., .false., &
5119 call this%budobj%budterm(idx)%reset(this%nconn)
5121 do n = 1, this%maxbound
5123 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5125 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5132 maxlist = this%maxbound - this%ianynone
5134 auxtxt(1) =
' FLOW-AREA'
5135 call this%budobj%budterm(idx)%initialize(text, &
5140 maxlist, .false., .true., &
5142 call this%budobj%budterm(idx)%reset(maxlist)
5144 do n = 1, this%maxbound
5145 n2 = this%igwfnode(n)
5147 call this%budobj%budterm(idx)%update_term(n, n2, q)
5154 maxlist = this%maxbound
5156 call this%budobj%budterm(idx)%initialize(text, &
5161 maxlist, .false., .false., &
5165 text =
' EVAPORATION'
5167 maxlist = this%maxbound
5169 call this%budobj%budterm(idx)%initialize(text, &
5174 maxlist, .false., .false., &
5180 maxlist = this%maxbound
5182 call this%budobj%budterm(idx)%initialize(text, &
5187 maxlist, .false., .false., &
5191 text =
' EXT-INFLOW'
5193 maxlist = this%maxbound
5195 call this%budobj%budterm(idx)%initialize(text, &
5200 maxlist, .false., .false., &
5204 text =
' EXT-OUTFLOW'
5206 maxlist = this%maxbound
5208 call this%budobj%budterm(idx)%initialize(text, &
5213 maxlist, .false., .false., &
5219 maxlist = this%maxbound
5221 auxtxt(1) =
' VOLUME'
5222 call this%budobj%budterm(idx)%initialize(text, &
5227 maxlist, .false., .false., &
5231 if (this%imover == 1)
then
5236 maxlist = this%maxbound
5238 call this%budobj%budterm(idx)%initialize(text, &
5243 maxlist, .false., .false., &
5249 maxlist = this%maxbound
5251 call this%budobj%budterm(idx)%initialize(text, &
5256 maxlist, .false., .false., &
5267 maxlist = this%maxbound
5268 call this%budobj%budterm(idx)%initialize(text, &
5273 maxlist, .false., .false., &
5278 if (this%iprflow /= 0)
then
5279 call this%budobj%flowtable_df(this%iout, cellids=
'GWF')
5281 end subroutine sfr_setup_budobj
5289 subroutine sfr_fill_budobj(this)
5291 class(sfrtype) :: this
5293 integer(I4B) :: naux
5300 integer(I4B) :: idiv
5301 integer(I4B) :: jpos
5315 call this%budobj%budterm(idx)%reset(this%nconn)
5316 do n = 1, this%maxbound
5320 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5322 if (this%iboundpak(n) /= 0)
then
5324 if (this%idir(i) < 0)
then
5330 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5331 if (this%idir(ii) > 0) cycle
5332 if (this%ja(ii) /= n) cycle
5338 call this%sfr_calc_reach_depth(n, qt, d)
5339 ca = this%calc_area_wet(n, d)
5344 this%qauxcbc(1) = ca
5345 call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5351 call this%budobj%budterm(idx)%reset(this%maxbound - this%ianynone)
5352 do n = 1, this%maxbound
5353 n2 = this%igwfnode(n)
5355 if (this%iboundpak(n) /= 0)
then
5357 if (this%depth(n) > dzero)
then
5358 wp = this%calc_perimeter_wet(n, this%depth(n))
5367 this%qauxcbc(1) = dzero
5370 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
5376 call this%budobj%budterm(idx)%reset(this%maxbound)
5377 do n = 1, this%maxbound
5378 if (this%iboundpak(n) /= 0)
then
5379 a = this%calc_surface_area(n)
5380 q = this%rain(n) * a
5384 call this%budobj%budterm(idx)%update_term(n, n, q)
5389 call this%budobj%budterm(idx)%reset(this%maxbound)
5390 do n = 1, this%maxbound
5391 if (this%iboundpak(n) /= 0)
then
5392 q = -this%simevap(n)
5396 call this%budobj%budterm(idx)%update_term(n, n, q)
5401 call this%budobj%budterm(idx)%reset(this%maxbound)
5402 do n = 1, this%maxbound
5403 if (this%iboundpak(n) /= 0)
then
5404 q = this%simrunoff(n)
5408 call this%budobj%budterm(idx)%update_term(n, n, q)
5413 call this%budobj%budterm(idx)%reset(this%maxbound)
5414 do n = 1, this%maxbound
5415 if (this%iboundpak(n) /= 0)
then
5420 call this%budobj%budterm(idx)%update_term(n, n, q)
5425 call this%budobj%budterm(idx)%reset(this%maxbound)
5426 do n = 1, this%maxbound
5428 if (this%iboundpak(n) /= 0)
then
5429 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5430 if (this%idir(i) > 0) cycle
5433 jpos = this%iadiv(n) + idiv - 1
5434 q = q + this%divq(jpos)
5436 q = q + this%qconn(i)
5439 q = q - this%dsflow(n)
5440 if (this%imover == 1)
then
5441 q = q + this%pakmvrobj%get_qtomvr(n)
5444 if (this%imover == 1)
then
5445 q = this%pakmvrobj%get_qfrommvr(n)
5448 call this%budobj%budterm(idx)%update_term(n, n, q)
5453 call this%budobj%budterm(idx)%reset(this%maxbound)
5454 do n = 1, this%maxbound
5456 if (this%iboundpak(n) /= 0)
then
5458 a = this%calc_surface_area_wet(n, d)
5459 this%qauxcbc(1) = a * d
5460 if (this%gwfiss == 0 .and. this%istorage == 1)
then
5465 this%qauxcbc(1) = dzero
5467 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
5471 if (this%imover == 1)
then
5475 call this%budobj%budterm(idx)%reset(this%maxbound)
5476 do n = 1, this%maxbound
5478 if (this%iboundpak(n) /= 0)
then
5479 q = this%pakmvrobj%get_qfrommvr(n)
5481 call this%budobj%budterm(idx)%update_term(n, n, q)
5486 call this%budobj%budterm(idx)%reset(this%maxbound)
5487 do n = 1, this%maxbound
5488 if (this%iboundpak(n) /= 0)
then
5489 q = this%pakmvrobj%get_qtomvr(n)
5496 call this%budobj%budterm(idx)%update_term(n, n, q)
5504 call this%budobj%budterm(idx)%reset(this%maxbound)
5505 do n = 1, this%maxbound
5507 call this%budobj%budterm(idx)%update_term(n, n, q, this%auxvar(:, n))
5512 call this%budobj%accumulate_terms()
5513 end subroutine sfr_fill_budobj
5521 subroutine sfr_setup_tableobj(this)
5523 class(sfrtype) :: this
5525 integer(I4B) :: nterms
5526 character(len=LINELENGTH) :: title
5527 character(len=LINELENGTH) :: text
5530 if (this%iprhed > 0)
then
5537 if (this%inamedbound == 1)
then
5542 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5543 trim(adjustl(this%packName))//
') STAGES FOR EACH CONTROL VOLUME'
5546 call table_cr(this%stagetab, this%packName, title)
5547 call this%stagetab%table_df(this%maxbound, nterms, this%iout, &
5551 if (this%inamedbound == 1)
then
5553 call this%stagetab%initialize_column(text, lenboundname, &
5559 call this%stagetab%initialize_column(text, 10, alignment=tabcenter)
5563 call this%stagetab%initialize_column(text, 20, alignment=tableft)
5567 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5571 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5575 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5579 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5582 text =
'STREAMBED CONDUCTANCE'
5583 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5586 text =
'STREAMBED GRADIENT'
5587 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5591 if (this%istorage == 1)
then
5593 if (this%inamedbound == 1)
then
5598 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5599 trim(adjustl(this%packName))//
') COURANT NUMBER FOR EACH REACH'
5602 call table_cr(this%couranttab, this%packName, title)
5603 call this%couranttab%table_df(this%maxbound, nterms, this%iout)
5605 if (this%inamedbound == 1)
then
5607 call this%couranttab%initialize_column(text, lenboundname, &
5613 call this%couranttab%initialize_column(text, 10, alignment=tabcenter)
5617 call this%couranttab%initialize_column(text, 16, alignment=tabcenter)
5621 call this%couranttab%initialize_column(text, 16, alignment=tabcenter)
5625 call this%couranttab%initialize_column(text, 16, alignment=tabcenter)
5627 end subroutine sfr_setup_tableobj
5635 function calc_area_wet(this, n, depth)
5637 real(dp) :: calc_area_wet
5639 class(sfrtype) :: this
5640 integer(I4B),
intent(in) :: n
5641 real(dp),
intent(in) :: depth
5643 integer(I4B) :: npts
5648 npts = this%ncrosspts(n)
5649 i0 = this%iacross(n)
5650 i1 = this%iacross(n + 1) - 1
5653 this%xsheight(i0:i1), depth)
5655 calc_area_wet = this%station(i0) * depth
5657 end function calc_area_wet
5663 function calc_perimeter_wet(this, n, depth)
5665 real(dp) :: calc_perimeter_wet
5667 class(sfrtype) :: this
5668 integer(I4B),
intent(in) :: n
5669 real(dp),
intent(in) :: depth
5671 integer(I4B) :: npts
5676 npts = this%ncrosspts(n)
5677 i0 = this%iacross(n)
5678 i1 = this%iacross(n + 1) - 1
5681 this%xsheight(i0:i1), depth)
5683 calc_perimeter_wet = this%station(i0)
5685 end function calc_perimeter_wet
5691 function calc_surface_area(this, n)
5693 real(dp) :: calc_surface_area
5695 class(sfrtype) :: this
5696 integer(I4B),
intent(in) :: n
5698 integer(I4B) :: npts
5701 real(dp) :: top_width
5704 npts = this%ncrosspts(n)
5705 i0 = this%iacross(n)
5706 i1 = this%iacross(n + 1) - 1
5710 top_width = this%station(i0)
5712 calc_surface_area = top_width * this%length(n)
5713 end function calc_surface_area
5719 function calc_surface_area_wet(this, n, depth)
5721 real(dp) :: calc_surface_area_wet
5723 class(sfrtype) :: this
5724 integer(I4B),
intent(in) :: n
5725 real(dp),
intent(in) :: depth
5727 real(dp) :: top_width
5730 top_width = this%calc_top_width_wet(n, depth)
5731 calc_surface_area_wet = top_width * this%length(n)
5732 end function calc_surface_area_wet
5738 function calc_top_width_wet(this, n, depth)
5740 real(dp) :: calc_top_width_wet
5742 class(sfrtype) :: this
5743 integer(I4B),
intent(in) :: n
5744 real(dp),
intent(in) :: depth
5746 integer(I4B) :: npts
5752 npts = this%ncrosspts(n)
5753 i0 = this%iacross(n)
5754 i1 = this%iacross(n + 1) - 1
5758 this%station(i0:i1), &
5759 this%xsheight(i0:i1), &
5762 calc_top_width_wet = sat * this%station(i0)
5764 end function calc_top_width_wet
5770 subroutine sfr_activate_density(this)
5774 class(sfrtype),
intent(inout) :: this
5781 call mem_reallocate(this%denseterms, 3, this%MAXBOUND,
'DENSETERMS', &
5783 do i = 1, this%maxbound
5785 this%denseterms(j, i) = dzero
5788 write (this%iout,
'(/1x,a)')
'DENSITY TERMS HAVE BEEN ACTIVATED FOR SFR &
5789 &PACKAGE: '//trim(adjustl(this%packName))
5790 end subroutine sfr_activate_density
5797 subroutine sfr_activate_viscosity(this)
5801 class(sfrtype),
intent(inout) :: this
5808 call mem_reallocate(this%viscratios, 2, this%MAXBOUND,
'VISCRATIOS', &
5810 do i = 1, this%maxbound
5812 this%viscratios(j, i) = done
5815 write (this%iout,
'(/1x,a)')
'VISCOSITY HAS BEEN ACTIVATED FOR SFR &
5816 &PACKAGE: '//trim(adjustl(this%packName))
5817 end subroutine sfr_activate_viscosity
5830 subroutine sfr_calculate_density_exchange(this, n, stage, head, cond, &
5831 tops, flow, gwfhcof, gwfrhs)
5833 class(sfrtype),
intent(inout) :: this
5834 integer(I4B),
intent(in) :: n
5835 real(DP),
intent(in) :: stage
5836 real(DP),
intent(in) :: head
5837 real(DP),
intent(in) :: cond
5838 real(DP),
intent(in) :: tops
5839 real(DP),
intent(inout) :: flow
5840 real(DP),
intent(inout) :: gwfhcof
5841 real(DP),
intent(inout) :: gwfrhs
5846 real(DP) :: rdensesfr
5847 real(DP) :: rdensegwf
5848 real(DP) :: rdenseavg
5854 logical(LGP) :: stage_below_bot
5855 logical(LGP) :: head_below_bot
5858 if (stage >= tops)
then
5860 stage_below_bot = .false.
5861 rdensesfr = this%denseterms(1, n)
5864 stage_below_bot = .true.
5865 rdensesfr = this%denseterms(2, n)
5869 if (head >= tops)
then
5871 head_below_bot = .false.
5872 rdensegwf = this%denseterms(2, n)
5875 head_below_bot = .true.
5876 rdensegwf = this%denseterms(1, n)
5880 if (rdensegwf == dzero)
return
5883 if (stage_below_bot .and. head_below_bot)
then
5890 rdenseavg = dhalf * (rdensesfr + rdensegwf)
5894 d1 = cond * (rdenseavg - done)
5895 gwfhcof = gwfhcof - d1
5896 gwfrhs = gwfrhs - d1 * ss
5901 if (.not. stage_below_bot .and. .not. head_below_bot)
then
5905 elevgwf = this%denseterms(3, n)
5907 elevavg = dhalf * (elevsfr + elevgwf)
5908 havg = dhalf * (hh + ss)
5909 d2 = cond * (havg - elevavg) * (rdensegwf - rdensesfr)
5910 gwfrhs = gwfrhs + d2
5914 end subroutine sfr_calculate_density_exchange
5921 subroutine sfr_input_init(this, mempath, naux)
5923 class(sfrinputtype),
intent(inout) :: this
5924 character(len=*),
intent(in) :: mempath
5925 integer(I4B),
intent(in) :: naux
5926 call mem_setptr(this%nbound,
'NBOUND', mempath)
5928 call mem_setptr(this%setting,
'SETTING', mempath)
5929 call mem_setptr(this%status,
'STATUS', mempath)
5931 call mem_setptr(this%tab6_filename,
'TAB6_FILENAME', mempath)
5933 call mem_setptr(this%auxname,
'AUXNAME', mempath)
5934 call mem_setptr(this%auxval,
'AUXVAL', mempath)
5936 end subroutine sfr_input_init
5940 subroutine sfr_input_destroy(this)
5941 class(sfrinputtype),
intent(inout) :: this
5944 nullify (this%ustrf)
5945 nullify (this%rhk_tslink)
5946 nullify (this%man_tslink)
5947 nullify (this%ustrf_tslink)
5948 nullify (this%nbound)
5950 nullify (this%status)
5951 nullify (this%setting)
5953 nullify (this%tab6_filename)
5954 nullify (this%auxname)
5955 nullify (this%auxval)
5956 end subroutine sfr_input_destroy
This module contains the extended boundary package.
subroutine source_dimensions(this)
Source package dimensions from input context.
subroutine source_options(this)
Source package options from input context.
This module contains the base boundary package.
logical(lgp) function bnd_obs_supported(this)
Determine if observations are supported.
subroutine bnd_ar(this)
Allocate and read method for boundary package.
subroutine bnd_rp(this)
Allocate and read method for package.
subroutine bnd_ot_dv(this, idvsave, idvprint)
Output advanced package dependent-variable terms.
subroutine bnd_ot_package_flows(this, icbcfl, ibudfl)
Output advanced package flow terms.
subroutine bnd_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
Convergence check for package.
subroutine bnd_bd_obs(this)
Save observations for the package.
subroutine bnd_da(this)
Deallocate package memory.
subroutine bnd_fc(this, rhs, ia, idxglo, matrix_sln)
Copy hcof and rhs terms into solution.
subroutine bnd_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Output advanced package budget summary.
subroutine bnd_fp(this)
Final processing at end of simulation (no-op by default).
subroutine bnd_df_obs(this)
Define the observation types available in the package.
subroutine bnd_rp_obs(this)
Read and prepare observations for a package.
subroutine bnd_cf(this)
Formulate the package hcof and rhs terms.
subroutine bnd_fn(this, rhs, ia, idxglo, matrix_sln)
Add Newton-Raphson terms for package into solution.
subroutine bnd_ad(this)
Advance the boundary package.
subroutine bnd_dt(this)
Submit an ATS time step request (no-op by default).
subroutine bnd_cq(this, x, flowja, iadv)
Calculate advanced package flows.
subroutine define_listlabel(this)
Define the list label for the 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)
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)
Convergence check for package.
subroutine sfr_cq(this, x, flowja, iadv)
Calculate package flows.
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
Output package flow terms.
subroutine sfr_activate_viscosity(this)
Activate viscosity terms.
subroutine sfr_da(this)
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)
Output package dependent-variable terms.
subroutine, public sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname, mempath)
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)
Copy hcof and rhs terms into solution.
subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
Add Newton-Raphson terms for package into solution.
subroutine define_listlabel(this)
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)
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)
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)
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)
Formulate the package hcof and rhs terms.
subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
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)
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)
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
integer(i4b) ifailedstepretry
current retry for this time step
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) iout
file unit number for simulation output
real(dp) function squadraticsaturation(top, bot, x, eps)
sQuadraticSaturation
real(dp) function scubicsaturation(top, bot, x, eps)
sCubicSaturation
real(dp) function squadraticsaturationderivative(top, bot, x, eps)
Derivative of the quadratic saturation function.
real(dp) function sqsaturationderivative(top, bot, x, c1, c2)
sQSaturationDerivative
subroutine schsmooth(d, smooth, dwdh)
sChSmooth
real(dp) function sqsaturation(top, bot, x, c1, c2)
sQSaturation
subroutine sort(this, with_csr)
subroutine finalize(this)
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 ...