46 character(len=LENFTYPE) ::
ftype =
'SFR'
47 character(len=LENPACKAGENAME) ::
text =
' SFR'
57 character(len=16),
dimension(:),
pointer,
contiguous :: csfrbudget => null()
58 character(len=16),
dimension(:),
pointer,
contiguous :: cauxcbc => null()
59 character(len=LENBOUNDNAME),
dimension(:),
pointer, &
60 contiguous :: sfrname => null()
62 integer(I4B),
pointer :: istorage => null()
63 integer(I4B),
pointer :: iprhed => null()
64 integer(I4B),
pointer :: istageout => null()
65 integer(I4B),
pointer :: ibudgetout => null()
66 integer(I4B),
pointer :: ibudcsv => null()
67 integer(I4B),
pointer :: ipakcsv => null()
68 integer(I4B),
pointer :: idiversions => null()
69 integer(I4B),
pointer :: nconn => null()
70 integer(I4B),
pointer :: maxsfrpicard => null()
71 integer(I4B),
pointer :: maxsfrit => null()
72 integer(I4B),
pointer :: bditems => null()
73 integer(I4B),
pointer :: cbcauxitems => null()
74 integer(I4B),
pointer :: icheck => null()
75 integer(I4B),
pointer :: iconvchk => null()
76 integer(I4B),
pointer :: gwfiss => null()
77 integer(I4B),
pointer :: ianynone => null()
79 real(dp),
pointer :: unitconv => null()
80 real(dp),
pointer :: lengthconv => null()
81 real(dp),
pointer :: timeconv => null()
82 real(dp),
pointer :: dmaxchg => null()
83 real(dp),
pointer :: deps => null()
84 real(dp),
pointer :: storage_weight => null()
86 integer(I4B),
dimension(:),
pointer,
contiguous :: isfrorder => null()
87 integer(I4B),
dimension(:),
pointer,
contiguous :: ia => null()
88 integer(I4B),
dimension(:),
pointer,
contiguous :: ja => null()
90 real(dp),
dimension(:),
pointer,
contiguous :: qoutflow => null()
91 real(dp),
dimension(:),
pointer,
contiguous :: qextoutflow => null()
92 real(dp),
dimension(:),
pointer,
contiguous :: qauxcbc => null()
93 real(dp),
dimension(:),
pointer,
contiguous :: dbuff => null()
103 integer(I4B),
dimension(:),
pointer,
contiguous :: iboundpak => null()
104 integer(I4B),
dimension(:),
pointer,
contiguous :: igwfnode => null()
105 integer(I4B),
dimension(:),
pointer,
contiguous :: igwftopnode => null()
106 real(dp),
dimension(:),
pointer,
contiguous :: length => null()
107 real(dp),
dimension(:),
pointer,
contiguous :: width => null()
108 real(dp),
dimension(:),
pointer,
contiguous :: strtop => null()
109 real(dp),
dimension(:),
pointer,
contiguous :: bthick => null()
110 real(dp),
dimension(:),
pointer,
contiguous :: hk => null()
111 real(dp),
dimension(:),
pointer,
contiguous :: slope => null()
112 integer(I4B),
dimension(:),
pointer,
contiguous :: nconnreach => null()
113 real(dp),
dimension(:),
pointer,
contiguous :: ustrf => null()
114 real(dp),
dimension(:),
pointer,
contiguous :: ftotnd => null()
115 integer(I4B),
dimension(:),
pointer,
contiguous :: ndiv => null()
116 real(dp),
dimension(:),
pointer,
contiguous :: usflow => null()
117 real(dp),
dimension(:),
pointer,
contiguous :: dsflow => null()
118 real(dp),
dimension(:),
pointer,
contiguous :: dsflowold => null()
119 real(dp),
dimension(:),
pointer,
contiguous :: usinflow => null()
120 real(dp),
dimension(:),
pointer,
contiguous :: usinflowold => null()
121 real(dp),
dimension(:),
pointer,
contiguous :: depth => null()
122 real(dp),
dimension(:),
pointer,
contiguous :: stage => null()
123 real(dp),
dimension(:),
pointer,
contiguous :: stageold => null()
124 real(dp),
dimension(:),
pointer,
contiguous :: gwflow => null()
125 real(dp),
dimension(:),
pointer,
contiguous :: simevap => null()
126 real(dp),
dimension(:),
pointer,
contiguous :: simrunoff => null()
127 real(dp),
dimension(:),
pointer,
contiguous :: stage0 => null()
128 real(dp),
dimension(:),
pointer,
contiguous :: usflow0 => null()
129 real(dp),
dimension(:),
pointer,
contiguous :: storage => null()
131 integer(I4B),
pointer :: ncrossptstot => null()
132 integer(I4B),
dimension(:),
pointer,
contiguous :: ncrosspts => null()
133 integer(I4B),
dimension(:),
pointer,
contiguous :: iacross => null()
134 real(dp),
dimension(:),
pointer,
contiguous :: station => null()
135 real(dp),
dimension(:),
pointer,
contiguous :: xsheight => null()
136 real(dp),
dimension(:),
pointer,
contiguous :: xsrough => null()
138 integer(I4B),
dimension(:),
pointer,
contiguous :: idir => null()
139 integer(I4B),
dimension(:),
pointer,
contiguous :: idiv => null()
140 real(dp),
dimension(:),
pointer,
contiguous :: qconn => null()
142 real(dp),
dimension(:),
pointer,
contiguous :: rough => null()
143 real(dp),
dimension(:),
pointer,
contiguous :: rain => null()
144 real(dp),
dimension(:),
pointer,
contiguous :: evap => null()
145 real(dp),
dimension(:),
pointer,
contiguous :: inflow => null()
146 real(dp),
dimension(:),
pointer,
contiguous :: runoff => null()
147 real(dp),
dimension(:),
pointer,
contiguous :: sstage => null()
149 real(dp),
dimension(:, :),
pointer,
contiguous :: rauxvar => null()
151 integer(I4B),
dimension(:),
pointer,
contiguous :: iadiv => null()
152 integer(I4B),
dimension(:),
pointer,
contiguous :: divreach => null()
153 character(len=10),
dimension(:),
pointer,
contiguous :: divcprior => null()
154 real(dp),
dimension(:),
pointer,
contiguous :: divflow => null()
155 real(dp),
dimension(:),
pointer,
contiguous :: divq => null()
158 integer(I4B),
pointer :: idense
159 real(dp),
dimension(:, :),
pointer,
contiguous :: denseterms => null()
162 real(dp),
dimension(:, :),
pointer,
contiguous :: viscratios => null()
192 procedure,
private :: sfr_calc_constant
193 procedure,
private :: sfr_calc_transient
194 procedure,
private :: sfr_calc_steady
240 module subroutine sfr_calc_steady(this, n, d1, hgwf, &
241 qu, qi, qfrommvr, qr, qe, qro, &
243 class(sfrtype) :: this
244 integer(I4B),
intent(in) :: n
245 real(dp),
intent(inout) :: d1
246 real(dp),
intent(in) :: hgwf
247 real(dp),
intent(in) :: qu
248 real(dp),
intent(in) :: qi
249 real(dp),
intent(in) :: qfrommvr
250 real(dp),
intent(in) :: qr
251 real(dp),
intent(in) :: qe
252 real(dp),
intent(in) :: qro
253 real(dp),
intent(inout) :: qgwf
254 real(dp),
intent(inout) :: qd
259 module subroutine sfr_calc_transient(this, n, d1, hgwf, &
260 qu, qi, qfrommvr, qr, qe, qro, &
262 class(sfrtype) :: this
263 integer(I4B),
intent(in) :: n
264 real(dp),
intent(inout) :: d1
265 real(dp),
intent(in) :: hgwf
266 real(dp),
intent(in) :: qu
267 real(dp),
intent(in) :: qi
268 real(dp),
intent(in) :: qfrommvr
269 real(dp),
intent(in) :: qr
270 real(dp),
intent(in) :: qe
271 real(dp),
intent(in) :: qro
272 real(dp),
intent(inout) :: qgwf
273 real(dp),
intent(inout) :: qd
278 module subroutine sfr_calc_constant(this, n, d1, hgwf, qgwf, qd)
279 class(sfrtype) :: this
280 integer(I4B),
intent(in) :: n
281 real(dp),
intent(inout) :: d1
282 real(dp),
intent(in) :: hgwf
283 real(dp),
intent(inout) :: qgwf
284 real(dp),
intent(inout) :: qd
295 subroutine sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
299 class(
bndtype),
pointer :: packobj
300 integer(I4B),
intent(in) :: id
301 integer(I4B),
intent(in) :: ibcnum
302 integer(I4B),
intent(in) :: inunit
303 integer(I4B),
intent(in) :: iout
304 character(len=*),
intent(in) :: namemodel
305 character(len=*),
intent(in) :: pakname
307 type(sfrtype),
pointer :: sfrobj
314 call packobj%set_names(ibcnum, namemodel, pakname, ftype)
318 call sfrobj%sfr_allocate_scalars()
321 call packobj%pack_initialize()
323 packobj%inunit = inunit
326 packobj%ibcnum = ibcnum
331 end subroutine sfr_create
339 subroutine sfr_allocate_scalars(this)
344 class(sfrtype),
intent(inout) :: this
347 call this%BndType%allocate_scalars()
350 call mem_allocate(this%istorage,
'ISTORAGE', this%memoryPath)
351 call mem_allocate(this%iprhed,
'IPRHED', this%memoryPath)
352 call mem_allocate(this%istageout,
'ISTAGEOUT', this%memoryPath)
353 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
354 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
355 call mem_allocate(this%ipakcsv,
'IPAKCSV', this%memoryPath)
356 call mem_allocate(this%idiversions,
'IDIVERSIONS', this%memoryPath)
357 call mem_allocate(this%maxsfrpicard,
'MAXSFRPICARD', this%memoryPath)
358 call mem_allocate(this%maxsfrit,
'MAXSFRIT', this%memoryPath)
359 call mem_allocate(this%bditems,
'BDITEMS', this%memoryPath)
360 call mem_allocate(this%cbcauxitems,
'CBCAUXITEMS', this%memoryPath)
361 call mem_allocate(this%unitconv,
'UNITCONV', this%memoryPath)
362 call mem_allocate(this%lengthconv,
'LENGTHCONV', this%memoryPath)
363 call mem_allocate(this%timeconv,
'TIMECONV', this%memoryPath)
364 call mem_allocate(this%dmaxchg,
'DMAXCHG', this%memoryPath)
366 call mem_allocate(this%storage_weight,
'STORAGE_WEIGHT', this%memoryPath)
368 call mem_allocate(this%icheck,
'ICHECK', this%memoryPath)
369 call mem_allocate(this%iconvchk,
'ICONVCHK', this%memoryPath)
370 call mem_allocate(this%idense,
'IDENSE', this%memoryPath)
371 call mem_allocate(this%ianynone,
'IANYNONE', this%memoryPath)
372 call mem_allocate(this%ncrossptstot,
'NCROSSPTSTOT', this%memoryPath)
385 this%maxsfrpicard = 100
393 this%deps =
dp999 * this%dmaxchg
401 this%ncrossptstot = 0
402 end subroutine sfr_allocate_scalars
409 subroutine sfr_allocate_arrays(this)
413 class(sfrtype),
intent(inout) :: this
419 allocate (this%csfrbudget(this%bditems))
421 'SFRNAME', this%memoryPath)
424 call mem_allocate(this%iboundpak, this%maxbound,
'IBOUNDPAK', &
426 call mem_allocate(this%igwfnode, this%maxbound,
'IGWFNODE', this%memoryPath)
427 call mem_allocate(this%igwftopnode, this%maxbound,
'IGWFTOPNODE', &
429 call mem_allocate(this%length, this%maxbound,
'LENGTH', this%memoryPath)
430 call mem_allocate(this%width, this%maxbound,
'WIDTH', this%memoryPath)
431 call mem_allocate(this%strtop, this%maxbound,
'STRTOP', this%memoryPath)
432 call mem_allocate(this%bthick, this%maxbound,
'BTHICK', this%memoryPath)
433 call mem_allocate(this%hk, this%maxbound,
'HK', this%memoryPath)
434 call mem_allocate(this%slope, this%maxbound,
'SLOPE', this%memoryPath)
435 call mem_allocate(this%nconnreach, this%maxbound,
'NCONNREACH', &
437 call mem_allocate(this%ustrf, this%maxbound,
'USTRF', this%memoryPath)
438 call mem_allocate(this%ftotnd, this%maxbound,
'FTOTND', this%memoryPath)
439 call mem_allocate(this%ndiv, this%maxbound,
'NDIV', this%memoryPath)
440 call mem_allocate(this%usflow, this%maxbound,
'USFLOW', this%memoryPath)
441 call mem_allocate(this%dsflow, this%maxbound,
'DSFLOW', this%memoryPath)
442 call mem_allocate(this%depth, this%maxbound,
'DEPTH', this%memoryPath)
443 call mem_allocate(this%stage, this%maxbound,
'STAGE', this%memoryPath)
444 call mem_allocate(this%gwflow, this%maxbound,
'GWFLOW', this%memoryPath)
445 call mem_allocate(this%simevap, this%maxbound,
'SIMEVAP', this%memoryPath)
446 call mem_allocate(this%simrunoff, this%maxbound,
'SIMRUNOFF', &
448 call mem_allocate(this%stage0, this%maxbound,
'STAGE0', this%memoryPath)
449 call mem_allocate(this%usflow0, this%maxbound,
'USFLOW0', this%memoryPath)
452 if (this%istorage == 1)
then
453 call mem_allocate(this%stageold, this%maxbound,
'STAGEOLD', &
455 call mem_allocate(this%usinflow, this%maxbound,
'USINFLOW', &
457 call mem_allocate(this%usinflowold, this%maxbound,
'USINFLOWOLD', &
459 call mem_allocate(this%dsflowold, this%maxbound,
'DSFLOWOLD', &
461 call mem_allocate(this%storage, this%maxbound,
'STORAGE', &
466 call mem_allocate(this%isfrorder, this%maxbound,
'ISFRORDER', &
468 call mem_allocate(this%ia, this%maxbound + 1,
'IA', this%memoryPath)
470 call mem_allocate(this%idir, 0,
'IDIR', this%memoryPath)
471 call mem_allocate(this%idiv, 0,
'IDIV', this%memoryPath)
472 call mem_allocate(this%qconn, 0,
'QCONN', this%memoryPath)
475 call mem_allocate(this%rough, this%maxbound,
'ROUGH', this%memoryPath)
476 call mem_allocate(this%rain, this%maxbound,
'RAIN', this%memoryPath)
477 call mem_allocate(this%evap, this%maxbound,
'EVAP', this%memoryPath)
478 call mem_allocate(this%inflow, this%maxbound,
'INFLOW', this%memoryPath)
479 call mem_allocate(this%runoff, this%maxbound,
'RUNOFF', this%memoryPath)
480 call mem_allocate(this%sstage, this%maxbound,
'SSTAGE', this%memoryPath)
483 call mem_allocate(this%rauxvar, this%naux, this%maxbound, &
484 'RAUXVAR', this%memoryPath)
487 call mem_allocate(this%iadiv, this%maxbound + 1,
'IADIV', this%memoryPath)
488 call mem_allocate(this%divreach, 0,
'DIVREACH', this%memoryPath)
489 call mem_allocate(this%divflow, 0,
'DIVFLOW', this%memoryPath)
490 call mem_allocate(this%divq, 0,
'DIVQ', this%memoryPath)
493 call mem_allocate(this%ncrosspts, this%maxbound,
'NCROSSPTS', &
495 call mem_allocate(this%iacross, this%maxbound + 1,
'IACROSS', &
497 call mem_allocate(this%station, this%ncrossptstot,
'STATION', &
499 call mem_allocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
501 call mem_allocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
506 do i = 1, this%maxbound
507 this%iboundpak(i) = 1
509 this%igwftopnode(i) = 0
510 this%length(i) =
dzero
511 this%width(i) =
dzero
512 this%strtop(i) =
dzero
513 this%bthick(i) =
dzero
515 this%slope(i) =
dzero
516 this%nconnreach(i) = 0
517 this%ustrf(i) =
dzero
518 this%ftotnd(i) =
dzero
520 this%usflow(i) =
dzero
521 this%dsflow(i) =
dzero
522 this%depth(i) =
dzero
523 this%stage(i) =
dzero
524 this%gwflow(i) =
dzero
525 this%simevap(i) =
dzero
526 this%simrunoff(i) =
dzero
527 this%stage0(i) =
dzero
528 this%usflow0(i) =
dzero
531 if (this%istorage == 1)
then
532 this%stageold(i) =
dzero
533 this%usinflow(i) =
dzero
534 this%usinflowold(i) =
dzero
535 this%dsflowold(i) =
dzero
536 this%storage(i) =
dzero
540 this%rough(i) =
dzero
543 this%inflow(i) =
dzero
544 this%runoff(i) =
dzero
545 this%sstage(i) =
dzero
549 this%rauxvar(j, i) =
dzero
553 this%ncrosspts(i) = 0
554 this%iacross(i + 1) = 0
558 do i = 1, this%ncrossptstot
559 this%station(i) =
dzero
560 this%xsheight(i) =
dzero
561 this%xsrough(i) =
dzero
565 this%csfrbudget(1) =
' RAINFALL'
566 this%csfrbudget(2) =
' EVAPORATION'
567 this%csfrbudget(3) =
' RUNOFF'
568 this%csfrbudget(4) =
' EXT-INFLOW'
569 this%csfrbudget(5) =
' GWF'
570 this%csfrbudget(6) =
' EXT-OUTFLOW'
571 this%csfrbudget(7) =
' FROM-MVR'
572 this%csfrbudget(8) =
' TO-MVR'
575 call mem_allocate(this%qoutflow, this%maxbound,
'QOUTFLOW', this%memoryPath)
576 call mem_allocate(this%qextoutflow, this%maxbound,
'QEXTOUTFLOW', &
578 do i = 1, this%maxbound
579 this%qoutflow(i) =
dzero
580 this%qextoutflow(i) =
dzero
584 if (this%istageout > 0)
then
585 call mem_allocate(this%dbuff, this%maxbound,
'DBUFF', this%memoryPath)
586 do i = 1, this%maxbound
587 this%dbuff(i) =
dzero
590 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
594 allocate (this%cauxcbc(this%cbcauxitems))
597 call mem_allocate(this%qauxcbc, this%cbcauxitems,
'QAUXCBC', &
599 do i = 1, this%cbcauxitems
600 this%qauxcbc(i) =
dzero
604 this%cauxcbc(1) =
'FLOW-AREA '
607 call mem_allocate(this%denseterms, 3, 0,
'DENSETERMS', this%memoryPath)
610 call mem_allocate(this%viscratios, 2, 0,
'VISCRATIOS', this%memoryPath)
611 end subroutine sfr_allocate_arrays
618 subroutine sfr_read_dimensions(this)
620 class(sfrtype),
intent(inout) :: this
622 character(len=LINELENGTH) :: keyword
624 logical(LGP) :: isfound
625 logical(LGP) :: endOfBlock
631 call this%parser%GetBlock(
'DIMENSIONS', isfound, ierr, &
632 supportopenclose=.true.)
636 write (this%iout,
'(/1x,a)') &
637 'PROCESSING '//trim(adjustl(this%text))//
' DIMENSIONS'
639 call this%parser%GetNextLine(endofblock)
641 call this%parser%GetStringCaps(keyword)
642 select case (keyword)
644 this%maxbound = this%parser%GetInteger()
645 write (this%iout,
'(4x,a,i0)')
'NREACHES = ', this%maxbound
648 'Unknown '//trim(this%text)//
' dimension: ', trim(keyword)
652 write (this%iout,
'(1x,a)') &
653 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
655 call store_error(
'Required dimensions block not found.')
659 if (this%maxbound < 1)
then
661 'NREACHES was not specified or was specified incorrectly.'
667 call this%parser%StoreErrorUnit()
672 call this%define_listlabel()
675 this%ncrossptstot = this%maxbound
678 call this%sfr_allocate_arrays()
681 call this%sfr_read_packagedata()
684 call this%sfr_read_crossection()
687 call this%sfr_read_connectiondata()
690 call this%sfr_read_diversions()
693 call this%sfr_read_initial_stages()
696 call this%sfr_setup_budobj()
699 call this%sfr_setup_tableobj()
700 end subroutine sfr_read_dimensions
707 subroutine sfr_options(this, option, found)
712 class(sfrtype),
intent(inout) :: this
713 character(len=*),
intent(inout) :: option
714 logical(LGP),
intent(inout) :: found
717 character(len=MAXCHARLEN) :: fname
718 character(len=MAXCHARLEN) :: keyword
720 character(len=*),
parameter :: fmttimeconv = &
721 &
"(4x, 'TIME CONVERSION VALUE (',g0,') SPECIFIED.')"
722 character(len=*),
parameter :: fmtlengthconv = &
723 &
"(4x, 'LENGTH CONVERSION VALUE (',g0,') SPECIFIED.')"
724 character(len=*),
parameter :: fmtpicard = &
725 &
"(4x, 'MAXIMUM SFR PICARD ITERATION VALUE (',i0,') SPECIFIED.')"
726 character(len=*),
parameter :: fmtiter = &
727 &
"(4x, 'MAXIMUM SFR ITERATION VALUE (',i0,') SPECIFIED.')"
728 character(len=*),
parameter :: fmtdmaxchg = &
729 &
"(4x, 'MAXIMUM DEPTH CHANGE VALUE (',g0,') SPECIFIED.')"
730 character(len=*),
parameter :: fmtsfrbin = &
731 "(4x, 'SFR ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, /4x, &
732 &'OPENED ON UNIT: ', I0)"
733 character(len=*),
parameter :: fmtstoweight = &
734 &
"(4x, 'KINEMATIC STORAGE WEIGHT (',g0,') SPECIFIED.')"
741 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
742 ' REACH STORAGE IS ACTIVE.'
745 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
746 ' STAGES WILL BE PRINTED TO LISTING FILE.'
748 call this%parser%GetStringCaps(keyword)
749 if (keyword ==
'FILEOUT')
then
750 call this%parser%GetString(fname)
752 call openfile(this%istageout, this%iout, fname,
'DATA(BINARY)', &
754 write (this%iout, fmtsfrbin) &
755 'STAGE', trim(adjustl(fname)), this%istageout
758 &be followed by fileout.')
761 call this%parser%GetStringCaps(keyword)
762 if (keyword ==
'FILEOUT')
then
763 call this%parser%GetString(fname)
765 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
767 write (this%iout, fmtsfrbin) &
768 'BUDGET', trim(adjustl(fname)), this%ibudgetout
770 call store_error(
'Optional budget keyword must be '// &
771 'followed by fileout.')
774 call this%parser%GetStringCaps(keyword)
775 if (keyword ==
'FILEOUT')
then
776 call this%parser%GetString(fname)
778 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
779 filstat_opt=
'REPLACE')
780 write (this%iout, fmtsfrbin) &
781 'BUDGET CSV', trim(adjustl(fname)), this%ibudcsv
783 call store_error(
'OPTIONAL BUDGETCSV KEYWORD MUST BE FOLLOWED BY &
786 case (
'PACKAGE_CONVERGENCE')
787 call this%parser%GetStringCaps(keyword)
788 if (keyword ==
'FILEOUT')
then
789 call this%parser%GetString(fname)
791 call openfile(this%ipakcsv, this%iout, fname,
'CSV', &
792 filstat_opt=
'REPLACE', mode_opt=
mnormal)
793 write (this%iout, fmtsfrbin) &
794 'PACKAGE_CONVERGENCE', trim(adjustl(fname)), this%ipakcsv
796 call store_error(
'Optional package_convergence keyword must be '// &
797 'followed by fileout.')
799 case (
'UNIT_CONVERSION')
800 this%unitconv = this%parser%GetDouble()
804 'SETTING UNIT_CONVERSION DIRECTLY'
808 warnmsg, this%parser%GetUnit())
809 case (
'LENGTH_CONVERSION')
810 this%lengthconv = this%parser%GetDouble()
811 write (this%iout, fmtlengthconv) this%lengthconv
812 case (
'TIME_CONVERSION')
813 this%timeconv = this%parser%GetDouble()
814 write (this%iout, fmttimeconv) this%timeconv
815 case (
'MAXIMUM_PICARD_ITERATIONS')
816 this%maxsfrpicard = this%parser%GetInteger()
817 write (this%iout, fmtpicard) this%maxsfrpicard
818 case (
'MAXIMUM_ITERATIONS')
819 this%maxsfrit = this%parser%GetInteger()
820 write (this%iout, fmtiter) this%maxsfrit
821 case (
'MAXIMUM_DEPTH_CHANGE')
822 r = this%parser%GetDouble()
824 this%deps =
dp999 * r
825 write (this%iout, fmtdmaxchg) this%dmaxchg
828 write (this%iout,
'(4x,A)')
'MOVER OPTION ENABLED'
834 case (
'DEV_NO_CHECK')
835 call this%parser%DevOpt()
837 write (this%iout,
'(4x,A)')
'SFR CHECKS OF REACH GEOMETRY '// &
838 'RELATIVE TO MODEL GRID AND '// &
839 'REASONABLE PARAMETERS WILL NOT '// &
841 case (
'DEV_NO_FINAL_CHECK')
842 call this%parser%DevOpt()
844 write (this%iout,
'(4x,a)') &
845 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN STREAM FLOW ROUTING &
846 &STAGES AND FLOWS WILL NOT BE MADE'
847 case (
'DEV_STORAGE_WEIGHT')
848 r = this%parser%GetDouble()
850 write (
errmsg,
'(a,g0,a)') &
851 "STORAGE_WEIGHT SPECIFIED TO BE '", r, &
852 "' BUT CANNOT BE LESS THAN 0.5 OR GREATER THAN 1.0"
855 this%storage_weight = r
856 write (this%iout, fmtstoweight) this%storage_weight
865 end subroutine sfr_options
872 subroutine sfr_ar(this)
874 class(sfrtype),
intent(inout) :: this
880 call this%obs%obs_ar()
883 call this%BndType%allocate_arrays()
886 if (this%inamedbound /= 0)
then
887 do n = 1, this%maxbound
888 this%boundname(n) = this%sfrname(n)
893 call this%copy_boundname()
896 do n = 1, this%maxbound
897 this%nodelist(n) = this%igwfnode(n)
901 call this%sfr_check_conversion()
904 call this%sfr_check_storage_weight()
907 call this%sfr_check_reaches()
910 call this%sfr_check_connections()
913 if (this%idiversions /= 0)
then
914 call this%sfr_check_diversions()
918 if (this%istorage == 1)
then
919 call this%sfr_check_initialstages()
925 call this%parser%StoreErrorUnit()
929 if (this%imover /= 0)
then
930 allocate (this%pakmvrobj)
931 call this%pakmvrobj%ar(this%maxbound, this%maxbound, this%memoryPath)
933 end subroutine sfr_ar
940 subroutine sfr_read_packagedata(this)
944 class(sfrtype),
intent(inout) :: this
946 character(len=LINELENGTH) :: text
947 character(len=LINELENGTH) :: cellid
948 character(len=10) :: cnum
949 character(len=LENBOUNDNAME) :: bndName
950 character(len=LENBOUNDNAME) :: bndNameTemp
951 character(len=LENBOUNDNAME) :: hkname
952 character(len=LENBOUNDNAME) :: manningname
953 character(len=LENBOUNDNAME) :: ustrfname
954 character(len=50),
dimension(:),
allocatable :: caux
955 integer(I4B) :: n, ierr, ival
956 logical(LGP) :: isfound
957 logical(LGP) :: endOfBlock
962 integer(I4B) :: nconzero
964 integer,
allocatable,
dimension(:) :: nboundchk
965 real(DP),
pointer :: bndElem => null()
968 allocate (nboundchk(this%maxbound))
969 do i = 1, this%maxbound
975 if (this%naux > 0)
then
976 allocate (caux(this%naux))
980 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
981 supportopenclose=.true.)
985 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
988 call this%parser%GetNextLine(endofblock)
991 n = this%parser%GetInteger()
993 if (n < 1 .or. n > this%maxbound)
then
994 write (
errmsg,
'(a,1x,a,1x,i0)') &
995 'Reach number (rno) must be greater than 0 and less', &
996 'than or equal to', this%maxbound
1002 nboundchk(n) = nboundchk(n) + 1
1005 call this%parser%GetCellid(this%dis%ndim, cellid, flag_string=.true.)
1006 this%igwfnode(n) = this%dis%noder_from_cellid(cellid, this%inunit, &
1008 flag_string=.true., &
1010 this%igwftopnode(n) = this%igwfnode(n)
1013 if (this%igwfnode(n) < 1)
then
1014 this%ianynone = this%ianynone + 1
1016 if (cellid ==
'NONE')
then
1017 call this%parser%GetStringCaps(cellid)
1020 write (cnum,
'(i0)') n
1021 warnmsg =
'CELLID for unconnected reach '//trim(cnum)// &
1022 ' specified to be NONE. Unconnected reaches '// &
1023 'should be specified with a zero for each grid '// &
1024 'dimension. For example, for a DIS grid a CELLID '// &
1025 'of 0 0 0 should be specified for unconnected reaches'
1029 warnmsg, this%parser%GetUnit())
1035 this%length(n) = this%parser%GetDouble()
1037 this%width(n) = this%parser%GetDouble()
1039 this%slope(n) = this%parser%GetDouble()
1041 this%strtop(n) = this%parser%GetDouble()
1043 this%bthick(n) = this%parser%GetDouble()
1045 call this%parser%GetStringCaps(hkname)
1047 call this%parser%GetStringCaps(manningname)
1049 ival = this%parser%GetInteger()
1050 this%nconnreach(n) = ival
1051 this%nconn = this%nconn + ival
1053 write (
errmsg,
'(a,1x,i0,1x,a,i0,a)') &
1054 'NCON for reach', n, &
1055 'must be greater than or equal to 0 (', ival,
').'
1057 else if (ival == 0)
then
1058 nconzero = nconzero + 1
1061 call this%parser%GetString(ustrfname)
1063 ival = this%parser%GetInteger()
1066 this%idiversions = 1
1067 else if (ival < 0)
then
1072 do iaux = 1, this%naux
1073 call this%parser%GetString(caux(iaux))
1077 write (cnum,
'(i10.10)') n
1078 bndname =
'Reach'//cnum
1081 if (this%inamedbound /= 0)
then
1082 call this%parser%GetStringCaps(bndnametemp)
1083 if (bndnametemp /=
'')
then
1084 bndname = bndnametemp
1088 this%sfrname(n) = bndname
1093 bndelem => this%hk(n)
1095 this%packName,
'BND', &
1096 this%tsManager, this%iprpak, &
1102 bndelem => this%rough(n)
1104 this%packName,
'BND', &
1105 this%tsManager, this%iprpak, &
1111 bndelem => this%ustrf(n)
1113 this%packName,
'BND', &
1114 this%tsManager, this%iprpak,
'USTRF')
1117 do jj = 1, this%naux
1120 bndelem => this%rauxvar(jj, ii)
1122 this%packName,
'AUX', &
1123 this%tsManager, this%iprpak, &
1131 this%sstage(n) = this%strtop(n)
1134 write (this%iout,
'(1x,a)') &
1135 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1137 call store_error(
'REQUIRED PACKAGEDATA BLOCK NOT FOUND.')
1142 do i = 1, this%maxbound
1143 if (nboundchk(i) == 0)
then
1144 write (
errmsg,
'(a,i0,1x,a)') &
1145 'Information for reach ', i,
'not specified in packagedata block.'
1147 else if (nboundchk(i) > 1)
then
1148 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1149 'Reach information specified', nboundchk(i),
'times for reach', i
1153 deallocate (nboundchk)
1156 if (nconzero > 0)
then
1157 write (
warnmsg,
'(a,1x,a,1x,a,1x,i0,1x, a)') &
1158 'SFR Package', trim(this%packName), &
1159 'has', nconzero,
'reach(es) with zero connections.'
1165 call this%parser%StoreErrorUnit()
1170 this%iacross(1) = ipos
1171 do i = 1, this%maxbound
1172 this%ncrosspts(i) = 1
1173 this%station(ipos) = this%width(i)
1174 this%xsheight(ipos) =
dzero
1175 this%xsrough(ipos) =
done
1177 this%iacross(i + 1) = ipos
1181 if (this%naux > 0)
then
1184 end subroutine sfr_read_packagedata
1191 subroutine sfr_read_crossection(this)
1196 class(sfrtype),
intent(inout) :: this
1198 character(len=LINELENGTH) :: keyword
1199 character(len=LINELENGTH) :: line
1200 logical(LGP) :: isfound
1201 logical(LGP) :: endOfBlock
1203 integer(I4B) :: ierr
1204 integer(I4B) :: ncrossptstot
1205 integer,
allocatable,
dimension(:) :: nboundchk
1209 call this%parser%GetBlock(
'CROSSSECTIONS', isfound, ierr, &
1210 supportopenclose=.true., &
1211 blockrequired=.false.)
1215 write (this%iout,
'(/1x,a)') &
1216 'PROCESSING '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1219 allocate (nboundchk(this%maxbound))
1220 do n = 1, this%maxbound
1226 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1228 this%station, this%xsheight, &
1233 call this%parser%GetNextLine(endofblock)
1234 if (endofblock)
exit
1237 n = this%parser%GetInteger()
1240 if (n < 1 .or. n > this%maxbound)
then
1241 write (
errmsg,
'(a,1x,a,1x,i0)') &
1242 'SFR reach in crosssections block is less than one or greater', &
1249 nboundchk(n) = nboundchk(n) + 1
1252 call this%parser%GetStringCaps(keyword)
1253 select case (keyword)
1255 call this%parser%GetStringCaps(keyword)
1256 if (trim(adjustl(keyword)) /=
'FILEIN')
then
1257 errmsg =
'TAB6 keyword must be followed by "FILEIN" '// &
1262 call this%parser%GetString(line)
1263 call cross_data%read_table(n, this%width(n), &
1264 trim(adjustl(line)))
1266 write (
errmsg,
'(a,1x,i4,1x,a)') &
1267 'CROSS-SECTION TABLE ENTRY for REACH ', n, &
1268 'MUST INCLUDE TAB6 KEYWORD'
1274 write (this%iout,
'(1x,a)') &
1275 'END OF '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1279 do n = 1, this%maxbound
1280 if (nboundchk(n) > 1)
then
1281 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1282 'Cross-section data for reach', n, &
1283 'specified', nboundchk(n),
'times.'
1290 call this%parser%StoreErrorUnit()
1294 ncrossptstot = cross_data%get_ncrossptstot()
1297 if (ncrossptstot /= this%ncrossptstot)
then
1298 this%ncrossptstot = ncrossptstot
1299 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
1301 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
1303 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
1308 call cross_data%output(this%width, this%rough)
1311 call cross_data%pack(this%ncrossptstot, this%ncrosspts, &
1318 deallocate (nboundchk)
1319 call cross_data%destroy()
1320 deallocate (cross_data)
1321 nullify (cross_data)
1323 end subroutine sfr_read_crossection
1330 subroutine sfr_read_connectiondata(this)
1335 class(sfrtype),
intent(inout) :: this
1337 character(len=LINELENGTH) :: line
1338 logical(LGP) :: isfound
1339 logical(LGP) :: endOfBlock
1344 integer(I4B) :: jcol
1345 integer(I4B) :: jcol2
1347 integer(I4B) :: ival
1348 integer(I4B) :: idir
1349 integer(I4B) :: ierr
1350 integer(I4B) :: nconnmax
1352 integer(I4B) :: ipos
1353 integer(I4B) :: istat
1354 integer(I4B),
dimension(:),
pointer,
contiguous :: rowmaxnnz => null()
1355 integer,
allocatable,
dimension(:) :: nboundchk
1356 integer,
allocatable,
dimension(:, :) :: iconndata
1358 integer(I4B),
dimension(:),
allocatable :: iup
1359 integer(I4B),
dimension(:),
allocatable :: order
1360 type(
dag) :: sfr_dag
1363 allocate (nboundchk(this%maxbound))
1364 do n = 1, this%maxbound
1371 allocate (rowmaxnnz(this%maxbound))
1372 do n = 1, this%maxbound
1373 ival = this%nconnreach(n)
1374 if (ival < 0) ival = 0
1375 rowmaxnnz(n) = ival + 1
1376 nja = nja + ival + 1
1377 if (ival > nconnmax)
then
1392 this%qconn(n) =
dzero
1396 allocate (iconndata(nconnmax, this%maxbound))
1399 do n = 1, this%maxbound
1409 call sparse%init(this%maxbound, this%maxbound, rowmaxnnz)
1412 call this%parser%GetBlock(
'CONNECTIONDATA', isfound, ierr, &
1413 supportopenclose=.true.)
1417 write (this%iout,
'(/1x,a)') &
1418 'PROCESSING '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1420 call this%parser%GetNextLine(endofblock)
1421 if (endofblock)
exit
1424 n = this%parser%GetInteger()
1427 if (n < 1 .or. n > this%maxbound)
then
1428 write (
errmsg,
'(a,1x,a,1x,i0)') &
1429 'SFR reach in connectiondata block is less than one or greater', &
1436 nboundchk(n) = nboundchk(n) + 1
1439 call sparse%addconnection(n, n, 1)
1442 do i = 1, this%nconnreach(n)
1445 ival = this%parser%GetInteger()
1448 iconndata(i, n) = ival
1454 elseif (ival == 0)
then
1455 call store_error(
'Missing or zero connection reach in line:')
1460 if (ival > this%maxbound)
then
1461 call store_error(
'Reach number exceeds NREACHES in line:')
1466 call sparse%addconnection(n, ival, 1)
1470 write (this%iout,
'(1x,a)') &
1471 'END OF '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1473 do n = 1, this%maxbound
1476 if (nboundchk(n) == 0)
then
1477 write (
errmsg,
'(a,1x,i0)') &
1478 'No connection data specified for reach', n
1480 else if (nboundchk(n) > 1)
then
1481 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1482 'Connection data for reach', n, &
1483 'specified', nboundchk(n),
'times.'
1488 call store_error(
'Required connectiondata block not found.')
1493 call this%parser%StoreErrorUnit()
1497 call sparse%filliaja(this%ia, this%ja, ierr, sort=.true.)
1501 write (
errmsg,
'(a,3(1x,a))') &
1502 'Could not fill', trim(this%packName), &
1503 'package IA and JA connection data.', &
1504 'Check connectivity data in connectiondata block.'
1509 do n = 1, this%maxbound
1510 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1512 do jj = 1, this%nconnreach(n)
1513 jcol2 = iconndata(jj, n)
1514 if (abs(jcol2) == jcol)
then
1527 deallocate (rowmaxnnz)
1528 deallocate (nboundchk)
1529 deallocate (iconndata)
1532 call sparse%destroy()
1538 call sfr_dag%set_vertices(this%maxbound)
1541 fill_dag:
do n = 1, this%maxbound
1545 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1546 if (this%idir(j) > 0)
then
1552 if (nup == 0) cycle fill_dag
1559 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1560 if (this%idir(j) > 0)
then
1561 iup(ipos) = this%ja(j)
1567 call sfr_dag%set_edges(n, iup)
1574 call sfr_dag%toposort(order, istat)
1577 if (istat == -1)
then
1579 trim(adjustl(this%text))//
' PACKAGE ('// &
1580 trim(adjustl(this%packName))//
') cannot calculate a '// &
1581 'Directed Asyclic Graph for reach connectivity because '// &
1582 'of circular dependency. Using the reach number for '// &
1583 'solution ordering.'
1588 do n = 1, this%maxbound
1589 if (istat == 0)
then
1590 this%isfrorder(n) = order(n)
1592 this%isfrorder(n) = n
1597 call sfr_dag%destroy()
1598 if (istat == 0)
then
1601 end subroutine sfr_read_connectiondata
1608 subroutine sfr_read_diversions(this)
1612 class(sfrtype),
intent(inout) :: this
1614 character(len=10) :: cnum
1615 character(len=10) :: cval
1618 integer(I4B) :: ierr
1619 integer(I4B) :: ival
1621 integer(I4B) :: ipos
1622 integer(I4B) :: jpos
1623 integer(I4B) :: ndiv
1624 integer(I4B) :: ndiversions
1625 integer(I4B) :: idivreach
1626 logical(LGP) :: isfound
1627 logical(LGP) :: endOfBlock
1628 integer(I4B) :: idiv
1629 integer,
allocatable,
dimension(:) :: iachk
1630 integer,
allocatable,
dimension(:) :: nboundchk
1636 do n = 1, this%maxbound
1637 ndiversions = ndiversions + this%ndiv(n)
1638 i0 = i0 + this%ndiv(n)
1639 this%iadiv(n + 1) = i0
1643 if (ndiversions > 0)
then
1646 allocate (this%divcprior(ndiversions))
1647 call mem_reallocate(this%divflow, ndiversions,
'DIVFLOW', this%memoryPath)
1648 call mem_reallocate(this%divq, ndiversions,
'DIVQ', this%memoryPath)
1652 do n = 1, ndiversions
1653 this%divflow(n) =
dzero
1654 this%divq(n) =
dzero
1658 call this%parser%GetBlock(
'DIVERSIONS', isfound, ierr, &
1659 supportopenclose=.true., &
1660 blockrequired=.false.)
1664 if (this%idiversions /= 0)
then
1665 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1670 do n = 1, this%maxbound
1671 ndiv = ndiv + this%ndiv(n)
1673 allocate (iachk(this%maxbound + 1))
1674 allocate (nboundchk(ndiv))
1676 do n = 1, this%maxbound
1677 iachk(n + 1) = iachk(n) + this%ndiv(n)
1685 call this%parser%GetNextLine(endofblock)
1686 if (endofblock)
exit
1689 n = this%parser%GetInteger()
1690 if (n < 1 .or. n > this%maxbound)
then
1691 write (cnum,
'(i0)') n
1692 errmsg =
'Reach number should be between 1 and '// &
1699 if (this%ndiv(n) < 1)
then
1700 write (cnum,
'(i0)') n
1701 errmsg =
'Diversions cannot be specified '// &
1702 'for reach '//trim(cnum)
1708 ival = this%parser%GetInteger()
1709 if (ival < 1 .or. ival > this%ndiv(n))
then
1710 write (cnum,
'(i0)') n
1711 errmsg =
'Reach '//trim(cnum)
1712 write (cnum,
'(i0)') this%ndiv(n)
1713 errmsg = trim(
errmsg)//
' diversion number should be between '// &
1714 '1 and '//trim(cnum)//
'.'
1720 ipos = iachk(n) + ival - 1
1721 nboundchk(ipos) = nboundchk(ipos) + 1
1726 ival = this%parser%GetInteger()
1727 if (ival < 1 .or. ival > this%maxbound)
then
1728 write (cnum,
'(i0)') ival
1729 errmsg =
'Diversion target reach number should be '// &
1730 'between 1 and '//trim(cnum)//
'.'
1735 jpos = this%iadiv(n) + idiv - 1
1736 this%divreach(jpos) = idivreach
1739 call this%parser%GetStringCaps(cval)
1751 errmsg =
'Invalid cprior type '//trim(cval)//
'.'
1756 this%divcprior(jpos) = cval
1759 write (this%iout,
'(1x,a)')
'END OF '//trim(adjustl(this%text))// &
1762 do n = 1, this%maxbound
1763 do j = 1, this%ndiv(n)
1764 ipos = iachk(n) + j - 1
1767 if (nboundchk(ipos) == 0)
then
1768 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1769 'No data specified for reach', n,
'diversion', j
1771 else if (nboundchk(ipos) > 1)
then
1772 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1773 'Data for reach', n,
'diversion', j, &
1774 'specified', nboundchk(ipos),
'times'
1782 deallocate (nboundchk)
1786 write (
errmsg,
'(a,1x,a)') &
1787 'A diversions block should not be', &
1788 'specified if diversions are not specified.'
1792 if (this%idiversions /= 0)
then
1793 call store_error(
'REQUIRED DIVERSIONS BLOCK NOT FOUND.')
1799 call this%parser%StoreErrorUnit()
1801 end subroutine sfr_read_diversions
1808 subroutine sfr_read_initial_stages(this)
1812 class(sfrtype),
intent(inout) :: this
1815 integer(I4B) :: ierr
1816 logical(LGP) :: isfound
1817 logical(LGP) :: endOfBlock
1820 integer,
allocatable,
dimension(:) :: nboundchk
1823 call this%parser%GetBlock(
'INITIALSTAGES', isfound, ierr, &
1824 supportopenclose=.true., &
1825 blockrequired=.false.)
1829 write (this%iout,
'(/1x,a)') &
1830 'PROCESSING '//trim(adjustl(this%text))//
' INITIALSTAGES'
1832 allocate (nboundchk(this%maxbound))
1833 do n = 1, this%maxbound
1838 call this%parser%GetNextLine(endofblock)
1839 if (endofblock)
exit
1842 n = this%parser%GetInteger()
1844 if (n < 1 .or. n > this%maxbound)
then
1845 write (
errmsg,
'(a,i0,a,1x,i0,a)') &
1846 'Reach number (', n,
') must be greater than 0 and less &
1847 &than or equal to', this%maxbound,
'.'
1853 nboundchk(n) = nboundchk(n) + 1
1855 rval = this%parser%GetDouble()
1856 this%stage(n) = rval
1857 this%depth(n) = rval - this%strtop(n)
1859 if (rval < this%strtop(n))
then
1860 write (
errmsg,
'(a,g0,a,1x,i0,1x,a,g0,a)') &
1861 'Initial stage (', rval,
') for reach', n, &
1862 'is less than the reach top (', this%strtop(n),
').'
1867 write (this%iout,
'(1x,a)') &
1868 'END OF '//trim(adjustl(this%text))//
' INITIALSTAGES'
1873 do i = 1, this%maxbound
1874 if (nboundchk(i) == 0)
then
1875 write (
errmsg,
'(a,i0,1x,a)') &
1876 'Information for reach ', i,
'not specified in initialstages block.'
1878 else if (nboundchk(i) > 1)
then
1879 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1880 'Initial stage information specified', &
1881 nboundchk(i),
'times for reach', i
1885 deallocate (nboundchk)
1888 if (this%istorage == 1)
then
1889 do n = 1, this%maxbound
1890 rval = this%strtop(n)
1891 this%stage(n) = rval
1898 call this%parser%StoreErrorUnit()
1900 end subroutine sfr_read_initial_stages
1907 subroutine sfr_rp(this)
1913 class(sfrtype),
intent(inout) :: this
1915 character(len=LINELENGTH) :: title
1916 character(len=LINELENGTH) :: line
1917 character(len=LINELENGTH) :: crossfile
1918 integer(I4B) :: ierr
1920 integer(I4B) :: ichkustrm
1921 integer(I4B) :: ichkcross
1922 integer(I4B) :: ncrossptstot
1923 logical(LGP) :: isfound
1924 logical(LGP) :: endOfBlock
1927 character(len=*),
parameter :: fmtblkerr = &
1928 &
"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
1929 character(len=*),
parameter :: fmtlsp = &
1930 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
1931 character(len=*),
parameter :: fmtnbd = &
1932 "(1X,/1X,'The number of active ',A,'S (',I6, &
1933 &') is greater than maximum (',I6,')')"
1943 this%nbound = this%maxbound
1947 if (this%ionper <
kper)
then
1950 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
1951 supportopenclose=.true., &
1952 blockrequired=.false.)
1956 call this%read_check_ionper()
1962 this%ionper =
nper + 1
1965 call this%parser%GetCurrentLine(line)
1966 write (
errmsg, fmtblkerr) adjustl(trim(line))
1968 call this%parser%StoreErrorUnit()
1974 if (this%ionper ==
kper)
then
1978 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1980 this%station, this%xsheight, &
1984 if (this%iprpak /= 0)
then
1987 title = trim(adjustl(this%text))//
' PACKAGE ('// &
1988 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
1989 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
1990 call table_cr(this%inputtab, this%packName, title)
1991 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
1993 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
1995 call this%inputtab%initialize_column(text, 20, alignment=
tableft)
1997 write (text,
'(a,1x,i6)')
'VALUE', n
1998 call this%inputtab%initialize_column(text, 15, alignment=
tabcenter)
2004 call this%parser%GetNextLine(endofblock)
2005 if (endofblock)
exit
2006 n = this%parser%GetInteger()
2007 if (n < 1 .or. n > this%maxbound)
then
2008 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
2009 'Reach number (RNO) must be greater than 0 and', &
2010 'less than or equal to', this%maxbound,
'.'
2016 call this%sfr_set_stressperiod(n, ichkustrm, crossfile)
2019 if (this%iprpak /= 0)
then
2020 call this%parser%GetCurrentLine(line)
2021 call this%inputtab%line_to_columns(line)
2025 if (trim(adjustl(crossfile)) /=
'NONE')
then
2026 call cross_data%read_table(n, this%width(n), &
2027 trim(adjustl(crossfile)))
2032 if (this%iprpak /= 0)
then
2033 call this%inputtab%finalize_table()
2040 ncrossptstot = cross_data%get_ncrossptstot()
2043 if (ncrossptstot /= this%ncrossptstot)
then
2044 this%ncrossptstot = ncrossptstot
2045 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
2047 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
2049 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
2054 call cross_data%output(this%width, this%rough, kstp=1,
kper=
kper)
2057 call cross_data%pack(this%ncrossptstot, this%ncrosspts, &
2064 call cross_data%destroy()
2065 deallocate (cross_data)
2066 nullify (cross_data)
2070 write (this%iout, fmtlsp) trim(this%filtyp)
2074 if (ichkustrm /= 0)
then
2075 call this%sfr_check_ustrf()
2080 call this%parser%StoreErrorUnit()
2082 end subroutine sfr_rp
2090 subroutine sfr_ad(this)
2094 class(sfrtype) :: this
2097 integer(I4B) :: iaux
2100 if (this%istorage == 1)
then
2101 do n = 1, this%maxbound
2102 this%stageold(n) = this%stage(n)
2103 this%usinflowold(n) = this%usinflow(n)
2104 this%dsflowold(n) = this%dsflow(n)
2114 call this%TsManager%ad()
2119 call this%sfr_check_ustrf()
2125 if (this%naux > 0)
then
2126 do n = 1, this%maxbound
2127 do iaux = 1, this%naux
2128 if (this%noupdateauxvar(iaux) /= 0) cycle
2129 this%auxvar(iaux, n) = this%rauxvar(iaux, n)
2135 do n = 1, this%maxbound
2136 this%usflow(n) =
dzero
2137 if (this%iboundpak(n) < 0)
then
2138 this%stage(n) = this%sstage(n)
2143 if (this%imover == 1)
then
2144 call this%pakmvrobj%ad()
2150 call this%obs%obs_ad()
2151 end subroutine sfr_ad
2159 subroutine sfr_cf(this)
2161 class(sfrtype) :: this
2164 integer(I4B) :: igwfnode
2167 if (this%nbound == 0)
return
2170 do n = 1, this%nbound
2171 igwfnode = this%igwftopnode(n)
2172 if (igwfnode > 0)
then
2173 if (this%ibound(igwfnode) == 0)
then
2174 call this%dis%highest_active(igwfnode, this%ibound)
2177 this%igwfnode(n) = igwfnode
2178 this%nodelist(n) = igwfnode
2180 end subroutine sfr_cf
2188 subroutine sfr_fc(this, rhs, ia, idxglo, matrix_sln)
2190 class(sfrtype) :: this
2191 real(DP),
dimension(:),
intent(inout) :: rhs
2192 integer(I4B),
dimension(:),
intent(in) :: ia
2193 integer(I4B),
dimension(:),
intent(in) :: idxglo
2199 integer(I4B) :: ipos
2200 integer(I4B) :: node
2211 sfrpicard:
do i = 1, this%maxsfrpicard
2217 if (this%imover == 1)
then
2218 call this%pakmvrobj%fc()
2222 reachsolve:
do j = 1, this%nbound
2223 n = this%isfrorder(j)
2224 node = this%igwfnode(n)
2226 hgwf = this%xnew(node)
2233 this%stage0(n) = this%stage(n)
2234 this%usflow0(n) = this%usflow(n)
2241 if (this%iboundpak(n) /= 0)
then
2242 call this%sfr_solve(n, hgwf, hhcof, rrhs)
2244 this%depth(n) =
dzero
2245 this%stage(n) = this%strtop(n)
2247 call this%sfr_update_flows(n, v, v)
2253 this%hcof(n) = hhcof
2257 ds = s0 - this%stage(n)
2260 if (abs(ds) > abs(dsmax))
then
2267 if (abs(dsmax) <= this%dmaxchg)
then
2274 do n = 1, this%nbound
2275 node = this%nodelist(n)
2277 rhs(node) = rhs(node) + this%rhs(n)
2279 call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(n))
2281 end subroutine sfr_fc
2289 subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
2291 class(sfrtype) :: this
2292 real(DP),
dimension(:),
intent(inout) :: rhs
2293 integer(I4B),
dimension(:),
intent(in) :: ia
2294 integer(I4B),
dimension(:),
intent(in) :: idxglo
2300 integer(I4B) :: ipos
2310 do j = 1, this%nbound
2311 i = this%isfrorder(j)
2313 if (this%iboundpak(i) < 1) cycle
2315 n = this%nodelist(i)
2318 rterm = this%hcof(i) * this%xnew(n)
2320 hgwf = this%xnew(n) +
dem4
2321 call this%sfr_solve(i, hgwf, hcof1, rhs1, update=.false.)
2322 q1 = rhs1 - hcof1 * hgwf
2324 q2 = this%rhs(i) - this%hcof(i) * this%xnew(n)
2326 drterm = (q2 - q1) /
dem4
2329 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(i))
2330 rhs(n) = rhs(n) - rterm + drterm * this%xnew(n)
2332 end subroutine sfr_fn
2340 subroutine sfr_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
2344 class(sfrtype),
intent(inout) :: this
2345 integer(I4B),
intent(in) :: innertot
2346 integer(I4B),
intent(in) :: kiter
2347 integer(I4B),
intent(in) :: iend
2348 integer(I4B),
intent(in) :: icnvgmod
2349 character(len=LENPAKLOC),
intent(inout) :: cpak
2350 integer(I4B),
intent(inout) :: ipak
2351 real(DP),
intent(inout) :: dpak
2353 character(len=LENPAKLOC) :: cloc
2354 character(len=LINELENGTH) :: tag
2355 integer(I4B) :: icheck
2356 integer(I4B) :: ipakfail
2357 integer(I4B) :: locdhmax
2358 integer(I4B) :: locrmax
2359 integer(I4B) :: locdqfrommvrmax
2360 integer(I4B) :: ntabrows
2361 integer(I4B) :: ntabcols
2365 real(DP) :: qtolfact
2370 real(DP) :: dqfrommvr
2371 real(DP) :: dqfrommvrmax
2374 icheck = this%iconvchk
2382 dqfrommvrmax =
dzero
2386 if (this%ipakcsv == 0)
then
2387 if (icnvgmod == 0)
then
2395 if (.not.
associated(this%pakcsvtab))
then
2400 if (this%imover == 1)
then
2401 ntabcols = ntabcols + 2
2405 call table_cr(this%pakcsvtab, this%packName,
'')
2406 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
2407 lineseparator=.false., separator=
',', &
2411 tag =
'total_inner_iterations'
2412 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2414 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2416 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2418 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2420 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2422 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2424 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2426 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2427 tag =
'dinflowmax_loc'
2428 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2429 if (this%imover == 1)
then
2430 tag =
'dqfrommvrmax'
2431 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2432 tag =
'dqfrommvrmax_loc'
2433 call this%pakcsvtab%initialize_column(tag, 16, alignment=
tableft)
2439 if (icheck /= 0)
then
2440 final_check:
do n = 1, this%maxbound
2441 if (this%iboundpak(n) == 0) cycle
2444 qtolfact =
delt / this%calc_surface_area(n)
2447 dh = this%stage0(n) - this%stage(n)
2450 if (this%gwfiss == 0)
then
2451 r = this%usflow0(n) - this%usflow(n)
2459 if (this%imover == 1)
then
2460 q = this%pakmvrobj%get_qfrommvr(n)
2461 q0 = this%pakmvrobj%get_qfrommvr0(n)
2462 dqfrommvr = qtolfact * (q0 - q)
2471 dqfrommvrmax = dqfrommvr
2474 if (abs(dh) > abs(dhmax))
then
2478 if (abs(r) > abs(rmax))
then
2482 if (abs(dqfrommvr) > abs(dqfrommvrmax))
then
2483 dqfrommvrmax = dqfrommvr
2490 if (abs(dhmax) > abs(dpak))
then
2493 write (cloc,
"(a,'-',a)") trim(this%packName),
'stage'
2496 if (abs(rmax) > abs(dpak))
then
2499 write (cloc,
"(a,'-',a)") trim(this%packName),
'inflow'
2502 if (this%imover == 1)
then
2503 if (abs(dqfrommvrmax) > abs(dpak))
then
2504 ipak = locdqfrommvrmax
2506 write (cloc,
"(a,'-',a)") trim(this%packName),
'qfrommvr'
2512 if (this%ipakcsv /= 0)
then
2515 call this%pakcsvtab%add_term(innertot)
2516 call this%pakcsvtab%add_term(
totim)
2517 call this%pakcsvtab%add_term(
kper)
2518 call this%pakcsvtab%add_term(
kstp)
2519 call this%pakcsvtab%add_term(kiter)
2520 call this%pakcsvtab%add_term(dhmax)
2521 call this%pakcsvtab%add_term(locdhmax)
2522 call this%pakcsvtab%add_term(rmax)
2523 call this%pakcsvtab%add_term(locrmax)
2524 if (this%imover == 1)
then
2525 call this%pakcsvtab%add_term(dqfrommvrmax)
2526 call this%pakcsvtab%add_term(locdqfrommvrmax)
2531 call this%pakcsvtab%finalize_table()
2535 end subroutine sfr_cc
2542 subroutine sfr_cq(this, x, flowja, iadv)
2546 class(sfrtype),
intent(inout) :: this
2547 real(DP),
dimension(:),
intent(in) :: x
2548 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2549 integer(I4B),
optional,
intent(in) :: iadv
2556 real(DP) :: qoutflow
2557 real(DP) :: qfrommvr
2562 call this%BndType%bnd_cq(x, flowja, iadv=1)
2565 do n = 1, this%maxbound
2570 if (this%imover == 1)
then
2571 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
2572 qtomvr = this%pakmvrobj%get_qtomvr(n)
2573 if (qtomvr >
dzero)
then
2579 qext = this%dsflow(n)
2581 if (qext >
dzero)
then
2584 do i = this%ia(n) + 1, this%ia(n + 1) - 1
2585 if (this%idir(i) > 0) cycle
2587 if (this%iboundpak(n2) == 0) cycle
2593 if (qext <
dzero)
then
2594 if (qtomvr <
dzero)
then
2595 qext = qext - qtomvr
2598 qoutflow = this%dsflow(n)
2599 if (qoutflow >
dzero)
then
2600 qoutflow = -qoutflow
2606 this%qextoutflow(n) = qext
2607 this%qoutflow(n) = qoutflow
2612 call this%sfr_fill_budobj()
2613 end subroutine sfr_cq
2620 subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
2624 class(sfrtype) :: this
2625 integer(I4B),
intent(in) :: icbcfl
2626 integer(I4B),
intent(in) :: ibudfl
2628 integer(I4B) :: ibinun
2629 character(len=20),
dimension(:),
allocatable :: cellidstr
2631 integer(I4B) :: node
2635 if (this%ibudgetout /= 0)
then
2636 ibinun = this%ibudgetout
2638 if (icbcfl == 0) ibinun = 0
2639 if (ibinun > 0)
then
2640 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
2645 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
2651 if (this%ianynone > 0)
then
2652 allocate (cellidstr(this%maxbound))
2653 do n = 1, this%maxbound
2654 node = this%igwfnode(n)
2656 call this%dis%noder_to_string(node, cellidstr(n))
2658 cellidstr(n) =
'NONE'
2661 call this%budobj%write_flowtable(this%dis,
kstp,
kper, cellidstr)
2662 deallocate (cellidstr)
2664 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
2667 end subroutine sfr_ot_package_flows
2674 subroutine sfr_ot_dv(this, idvsave, idvprint)
2679 class(sfrtype) :: this
2680 integer(I4B),
intent(in) :: idvsave
2681 integer(I4B),
intent(in) :: idvprint
2683 character(len=20) :: cellid
2684 integer(I4B) :: ibinun
2686 integer(I4B) :: node
2699 if (this%istageout /= 0)
then
2700 ibinun = this%istageout
2702 if (idvsave == 0) ibinun = 0
2705 if (ibinun > 0)
then
2706 do n = 1, this%maxbound
2709 if (this%iboundpak(n) == 0)
then
2711 else if (d ==
dzero)
then
2717 this%maxbound, 1, 1, ibinun)
2721 if (idvprint /= 0 .and. this%iprhed /= 0)
then
2724 call this%stagetab%set_kstpkper(
kstp,
kper)
2727 do n = 1, this%maxbound
2728 node = this%igwfnode(n)
2730 call this%dis%noder_to_string(node, cellid)
2731 hgwf = this%xnew(node)
2735 if (this%inamedbound == 1)
then
2736 call this%stagetab%add_term(this%boundname(n))
2738 call this%stagetab%add_term(n)
2739 call this%stagetab%add_term(cellid)
2740 if (this%iboundpak(n) /= 0)
then
2741 depth = this%depth(n)
2742 stage = this%stage(n)
2743 w = this%calc_top_width_wet(n, depth)
2744 call this%sfr_calc_cond(n, depth, cond, stage, hgwf)
2751 if (depth ==
dzero)
then
2752 call this%stagetab%add_term(
dhdry)
2754 call this%stagetab%add_term(stage)
2756 call this%stagetab%add_term(depth)
2757 call this%stagetab%add_term(w)
2759 if (this%iboundpak(n) /= 0)
then
2760 sbot = this%strtop(n) - this%bthick(n)
2761 if (hgwf < sbot)
then
2766 grad = grad / this%bthick(n)
2770 call this%stagetab%add_term(hgwf)
2771 call this%stagetab%add_term(cond)
2772 call this%stagetab%add_term(grad)
2774 call this%stagetab%add_term(
'--')
2775 call this%stagetab%add_term(
'--')
2776 call this%stagetab%add_term(
'--')
2780 end subroutine sfr_ot_dv
2787 subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
2791 class(sfrtype) :: this
2792 integer(I4B),
intent(in) :: kstp
2793 integer(I4B),
intent(in) :: kper
2794 integer(I4B),
intent(in) :: iout
2795 integer(I4B),
intent(in) :: ibudfl
2797 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
2798 end subroutine sfr_ot_bdsummary
2805 subroutine sfr_da(this)
2809 class(sfrtype) :: this
2814 deallocate (this%csfrbudget)
2817 deallocate (this%cauxcbc)
2844 if (this%istorage == 1)
then
2874 if (
associated(this%divcprior))
then
2875 deallocate (this%divcprior)
2889 call this%budobj%budgetobject_da()
2890 deallocate (this%budobj)
2891 nullify (this%budobj)
2894 if (this%iprhed > 0)
then
2895 call this%stagetab%table_da()
2896 deallocate (this%stagetab)
2897 nullify (this%stagetab)
2901 if (this%ipakcsv > 0)
then
2902 if (
associated(this%pakcsvtab))
then
2903 call this%pakcsvtab%table_da()
2904 deallocate (this%pakcsvtab)
2905 nullify (this%pakcsvtab)
2933 nullify (this%gwfiss)
2936 call this%BndType%bnd_da()
2937 end subroutine sfr_da
2945 subroutine define_listlabel(this)
2947 class(sfrtype),
intent(inout) :: this
2950 this%listlabel = trim(this%filtyp)//
' NO.'
2951 if (this%dis%ndim == 3)
then
2952 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
2953 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
2954 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
2955 elseif (this%dis%ndim == 2)
then
2956 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
2957 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
2959 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
2961 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
2962 if (this%inamedbound == 1)
then
2963 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
2965 end subroutine define_listlabel
2978 logical function sfr_obs_supported(this)
2980 class(sfrtype) :: this
2983 sfr_obs_supported = .true.
2984 end function sfr_obs_supported
2991 subroutine sfr_df_obs(this)
2993 class(sfrtype) :: this
2995 integer(I4B) :: indx
2999 call this%obs%StoreObsType(
'stage', .false., indx)
3000 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3004 call this%obs%StoreObsType(
'inflow', .true., indx)
3005 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3009 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
3010 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3014 call this%obs%StoreObsType(
'rainfall', .true., indx)
3015 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3019 call this%obs%StoreObsType(
'runoff', .true., indx)
3020 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3024 call this%obs%StoreObsType(
'evaporation', .true., indx)
3025 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3029 call this%obs%StoreObsType(
'outflow', .true., indx)
3030 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3034 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
3035 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3039 call this%obs%StoreObsType(
'to-mvr', .true., indx)
3040 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3044 call this%obs%StoreObsType(
'from-mvr', .true., indx)
3045 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3049 call this%obs%StoreObsType(
'sfr', .true., indx)
3050 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3054 call this%obs%StoreObsType(
'upstream-flow', .true., indx)
3055 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3059 call this%obs%StoreObsType(
'downstream-flow', .true., indx)
3060 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3064 call this%obs%StoreObsType(
'depth', .false., indx)
3065 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3069 call this%obs%StoreObsType(
'wet-perimeter', .false., indx)
3070 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3074 call this%obs%StoreObsType(
'wet-area', .false., indx)
3075 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3079 call this%obs%StoreObsType(
'wet-width', .false., indx)
3080 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3081 end subroutine sfr_df_obs
3088 subroutine sfr_bd_obs(this)
3090 class(sfrtype) :: this
3096 character(len=100) :: msg
3100 if (this%obs%npakobs > 0)
then
3101 call this%obs%obs_bd_clear()
3102 do i = 1, this%obs%npakobs
3103 obsrv => this%obs%pakobs(i)%obsrv
3104 do j = 1, obsrv%indxbnds_count
3105 n = obsrv%indxbnds(j)
3107 select case (obsrv%ObsTypeId)
3112 if (this%imover == 1)
then
3113 v = this%pakmvrobj%get_qtomvr(n)
3120 if (this%imover == 1)
then
3121 v = this%pakmvrobj%get_qfrommvr(n)
3128 v = this%qoutflow(n)
3129 case (
'EXT-OUTFLOW')
3130 v = this%qextoutflow(n)
3132 if (this%iboundpak(n) /= 0)
then
3138 v = this%simrunoff(n)
3139 case (
'EVAPORATION')
3143 case (
'UPSTREAM-FLOW')
3145 if (this%imover == 1)
then
3146 v = v + this%pakmvrobj%get_qfrommvr(n)
3148 case (
'DOWNSTREAM-FLOW')
3155 case (
'WET-PERIMETER')
3156 v = this%calc_perimeter_wet(n, this%depth(n))
3158 v = this%calc_area_wet(n, this%depth(n))
3160 v = this%calc_top_width_wet(n, this%depth(n))
3162 msg =
'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
3165 call this%obs%SaveOneSimval(obsrv, v)
3171 call this%parser%StoreErrorUnit()
3174 end subroutine sfr_bd_obs
3181 subroutine sfr_rp_obs(this)
3185 class(sfrtype),
intent(inout) :: this
3190 character(len=LENBOUNDNAME) :: bname
3191 logical(LGP) :: jfound
3194 10
format(
'Boundary "', a,
'" for observation "', a, &
3195 '" is invalid in package "', a,
'"')
3196 30
format(
'Boundary name not provided for observation "', a, &
3197 '" in package "', a,
'"')
3203 do i = 1, this%obs%npakobs
3204 obsrv => this%obs%pakobs(i)%obsrv
3207 nn1 = obsrv%NodeNumber
3209 bname = obsrv%FeatureName
3210 if (bname /=
'')
then
3215 do j = 1, this%maxbound
3216 if (this%boundname(j) == bname)
then
3218 call obsrv%AddObsIndex(j)
3221 if (.not. jfound)
then
3223 trim(bname), trim(obsrv%name), trim(this%packName)
3227 write (
errmsg, 30) trim(obsrv%name), trim(this%packName)
3230 else if (nn1 < 1 .or. nn1 > this%maxbound)
then
3231 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3232 trim(adjustl(obsrv%ObsTypeId)), &
3233 'reach must be greater than 0 and less than or equal to', &
3234 this%maxbound,
'(specified value is ', nn1,
')'
3237 if (obsrv%indxbnds_count == 0)
then
3238 call obsrv%AddObsIndex(nn1)
3240 errmsg =
'Programming error in sfr_rp_obs'
3247 if (obsrv%ObsTypeId ==
'STAGE' .or. &
3248 obsrv%ObsTypeId ==
'DEPTH' .or. &
3249 obsrv%ObsTypeId ==
'WET-PERIMETER' .or. &
3250 obsrv%ObsTypeId ==
'WET-AREA' .or. &
3251 obsrv%ObsTypeId ==
'WET-WIDTH')
then
3252 nn1 = obsrv%NodeNumber
3254 if (obsrv%indxbnds_count > 1)
then
3255 write (
errmsg,
'(a,3(1x,a))') &
3256 trim(adjustl(obsrv%ObsTypeId)), &
3257 'for observation', trim(adjustl(obsrv%Name)), &
3258 ' must be assigned to a reach with a unique boundname.'
3265 do j = 1, obsrv%indxbnds_count
3266 nn1 = obsrv%indxbnds(j)
3267 if (nn1 < 1 .or. nn1 > this%maxbound)
then
3268 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3269 trim(adjustl(obsrv%ObsTypeId)), &
3270 'reach must be greater than 0 and less than or equal to', &
3271 this%maxbound,
'(specified value is ', nn1,
')'
3279 call this%parser%StoreErrorUnit()
3282 end subroutine sfr_rp_obs
3292 subroutine sfr_process_obsid(obsrv, dis, inunitobs, iout)
3296 integer(I4B),
intent(in) :: inunitobs
3297 integer(I4B),
intent(in) :: iout
3300 integer(I4B) :: icol
3301 integer(I4B) :: istart
3302 integer(I4B) :: istop
3303 character(len=LINELENGTH) :: string
3304 character(len=LENBOUNDNAME) :: bndname
3307 string = obsrv%IDstring
3317 obsrv%FeatureName = bndname
3321 obsrv%NodeNumber = nn1
3322 end subroutine sfr_process_obsid
3333 subroutine sfr_set_stressperiod(this, n, ichkustrm, crossfile)
3337 class(sfrtype),
intent(inout) :: this
3338 integer(I4B),
intent(in) :: n
3339 integer(I4B),
intent(inout) :: ichkustrm
3340 character(len=LINELENGTH),
intent(inout) :: crossfile
3342 character(len=10) :: cnum
3343 character(len=LINELENGTH) :: text
3344 character(len=LINELENGTH) :: caux
3345 character(len=LINELENGTH) :: keyword
3346 integer(I4B) :: ival
3349 integer(I4B) :: idiv
3350 integer(I4B) :: ixserror
3351 character(len=10) :: cp
3353 real(DP),
pointer :: bndElem => null()
3359 call this%parser%GetStringCaps(keyword)
3360 select case (keyword)
3363 call this%parser%GetStringCaps(text)
3364 if (text ==
'INACTIVE')
then
3365 this%iboundpak(n) = 0
3366 else if (text ==
'ACTIVE')
then
3367 this%iboundpak(n) = 1
3368 else if (text ==
'SIMPLE')
then
3369 this%iboundpak(n) = -1
3372 'Unknown '//trim(this%text)//
' sfr status keyword: ', trim(text)
3376 call this%parser%GetString(text)
3378 bndelem => this%hk(n)
3380 this%packName,
'BND', &
3381 this%tsManager, this%iprpak, &
3384 call this%parser%GetString(text)
3386 bndelem => this%rough(n)
3388 this%packName,
'BND', &
3389 this%tsManager, this%iprpak, &
3392 call this%parser%GetString(text)
3394 bndelem => this%sstage(n)
3396 this%packName,
'BND', &
3397 this%tsManager, this%iprpak,
'STAGE')
3399 call this%parser%GetString(text)
3401 bndelem => this%rain(n)
3403 this%packName,
'BND', &
3404 this%tsManager, this%iprpak,
'RAIN')
3405 case (
'EVAPORATION')
3406 call this%parser%GetString(text)
3408 bndelem => this%evap(n)
3410 this%packName,
'BND', &
3411 this%tsManager, this%iprpak, &
3414 call this%parser%GetString(text)
3416 bndelem => this%runoff(n)
3418 this%packName,
'BND', &
3419 this%tsManager, this%iprpak, &
3422 call this%parser%GetString(text)
3424 bndelem => this%inflow(n)
3426 this%packName,
'BND', &
3427 this%tsManager, this%iprpak, &
3432 if (this%ndiv(n) < 1)
then
3433 write (cnum,
'(i0)') n
3434 errmsg =
'diversions cannot be specified for reach '//trim(cnum)
3439 ival = this%parser%GetInteger()
3440 if (ival < 1 .or. ival > this%ndiv(n))
then
3441 write (cnum,
'(i0)') n
3442 errmsg =
'Reach '//trim(cnum)
3443 write (cnum,
'(i0)') this%ndiv(n)
3444 errmsg = trim(
errmsg)//
' diversion number should be between 1 '// &
3445 'and '//trim(cnum)//
'.'
3451 call this%parser%GetString(text)
3452 ii = this%iadiv(n) + idiv - 1
3454 bndelem => this%divflow(ii)
3456 this%packName,
'BND', &
3457 this%tsManager, this%iprpak, &
3461 cp = this%divcprior(ii)
3462 divq = this%divflow(ii)
3463 if (cp ==
'FRACTION' .and. (divq <
dzero .or. divq >
done))
then
3464 write (
errmsg,
'(a,1x,i0,a)') &
3465 'cprior is type FRACTION for diversion no.', ii, &
3466 ', but divflow not within the range 0.0 to 1.0'
3469 case (
'UPSTREAM_FRACTION')
3471 call this%parser%GetString(text)
3473 bndelem => this%ustrf(n)
3475 this%packName,
'BND', &
3476 this%tsManager, this%iprpak,
'USTRF')
3478 case (
'CROSS_SECTION')
3482 call this%parser%GetStringCaps(keyword)
3483 select case (keyword)
3485 call this%parser%GetStringCaps(keyword)
3486 if (trim(adjustl(keyword)) /=
'FILEIN')
then
3487 errmsg =
'TAB6 keyword must be followed by "FILEIN" '// &
3492 if (ixserror == 0)
then
3493 call this%parser%GetString(crossfile)
3496 write (
errmsg,
'(a,1x,i4,1x,a)') &
3497 'CROSS-SECTION TABLE ENTRY for REACH ', n, &
3498 'MUST INCLUDE TAB6 KEYWORD'
3503 call this%parser%GetStringCaps(caux)
3504 do jj = 1, this%naux
3505 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
3506 call this%parser%GetString(text)
3508 bndelem => this%rauxvar(jj, ii)
3510 this%packName,
'AUX', &
3511 this%tsManager, this%iprpak, &
3517 write (
errmsg,
'(a,a)') &
3518 'Unknown '//trim(this%text)//
' sfr data keyword: ', &
3522 end subroutine sfr_set_stressperiod
3529 subroutine sfr_solve(this, n, h, hcof, rhs, update)
3531 class(sfrtype) :: this
3532 integer(I4B),
intent(in) :: n
3533 real(DP),
intent(in) :: h
3534 real(DP),
intent(inout) :: hcof
3535 real(DP),
intent(inout) :: rhs
3536 logical(LGP),
intent(in),
optional :: update
3538 logical(LGP) :: lupdate
3551 real(DP) :: qfrommvr
3564 if (
present(update))
then
3574 if (this%iboundpak(n) == 0)
then
3575 this%depth(n) =
dzero
3577 this%usflow(n) =
dzero
3578 this%simevap(n) =
dzero
3579 this%simrunoff(n) =
dzero
3580 this%dsflow(n) =
dzero
3581 this%gwflow(n) =
dzero
3593 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3594 if (this%idir(i) < 0) cycle
3596 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
3597 if (this%idir(ii) > 0) cycle
3598 if (this%ja(ii) /= n) cycle
3599 qu = qu + this%qconn(ii)
3605 sa = this%calc_surface_area(n)
3606 sa_wet = this%calc_surface_area_wet(n, this%depth(n))
3608 qr = this%rain(n) * sa
3609 qe = this%evap(n) * sa_wet
3610 qro = this%runoff(n)
3614 if (this%imover == 1)
then
3615 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3619 qsrc = qu + qi + qr - qe + qro + qfrommvr
3622 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3625 this%simevap(n) = qe
3626 this%simrunoff(n) = qro
3629 if (this%iboundpak(n) < 0)
then
3630 call this%sfr_calc_constant(n, d1, hgwf, qgwf, qd)
3632 if (this%gwfiss == 0 .and. this%istorage == 1)
then
3633 call this%sfr_calc_transient(n, d1, hgwf, qu, qi, &
3634 qfrommvr, qr, qe, qro, &
3637 call this%sfr_calc_steady(n, d1, hgwf, qu, qi, &
3638 qfrommvr, qr, qe, qro, &
3645 bt = tp - this%bthick(n)
3652 this%stage(n) = hsfr
3654 call this%sfr_update_flows(n, qd, qgwf)
3660 if (this%gwfiss == 0)
then
3671 call this%sfr_calc_qgwf(n, d1, hgwf, qgwf, gwfhcof, gwfrhs)
3674 if (abs(sumleak) >
dzero)
then
3679 else if ((sumleak - qsrc) < -
dem30)
then
3680 if (this%gwfiss == 0)
then
3681 rhs = rhs + gwfrhs - sumrch
3688 if (this%gwfiss == 0)
then
3689 rhs = rhs - sumleak - sumrch
3696 else if (hgwf < bt)
then
3700 end subroutine sfr_solve
3708 subroutine sfr_update_flows(this, n, qd, qgwf)
3710 class(sfrtype),
intent(inout) :: this
3711 integer(I4B),
intent(in) :: n
3712 real(DP),
intent(inout) :: qd
3713 real(DP),
intent(in) :: qgwf
3717 integer(I4B) :: idiv
3718 integer(I4B) :: jpos
3728 this%gwflow(n) = qgwf
3731 if (qd >
dzero)
then
3734 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3735 if (this%idir(i) > 0) cycle
3737 if (idiv == 0) cycle
3738 jpos = this%iadiv(n) + idiv - 1
3739 call this%sfr_calc_div(n, idiv, qd, qdiv)
3740 this%qconn(i) = qdiv
3741 this%divq(jpos) = qdiv
3747 if (this%imover == 1)
then
3748 call this%pakmvrobj%accumulate_qformvr(n, qd)
3749 qd = max(qd - this%pakmvrobj%get_qtomvr(n),
dzero)
3753 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3754 if (this%idir(i) > 0) cycle
3755 if (this%idiv(i) > 0) cycle
3757 if (this%iboundpak(n2) == 0) cycle
3758 f = this%ustrf(n2) / this%ftotnd(n)
3759 this%qconn(i) = qd * f
3762 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3763 if (this%idir(i) > 0) cycle
3764 this%qconn(i) =
dzero
3766 if (idiv == 0) cycle
3767 jpos = this%iadiv(n) + idiv - 1
3768 this%divq(jpos) =
dzero
3771 end subroutine sfr_update_flows
3779 subroutine sfr_adjust_ro_ev(this, qc, qu, qi, qr, qro, qe, qfrommvr)
3781 class(sfrtype) :: this
3782 real(DP),
intent(inout) :: qc
3783 real(DP),
intent(in) :: qu
3784 real(DP),
intent(in) :: qi
3785 real(DP),
intent(in) :: qr
3786 real(DP),
intent(inout) :: qro
3787 real(DP),
intent(inout) :: qe
3788 real(DP),
intent(in) :: qfrommvr
3793 if (qc <
dzero)
then
3796 qt = qu + qi + qr + qro + qfrommvr
3799 if (qt <
dzero)
then
3800 if (qro <
dzero)
then
3801 qro = -(qu + qi + qr + qfrommvr)
3807 if (qe >
dzero)
then
3808 qe = qu + qi + qr + qro + qfrommvr
3811 qc = qu + qi + qr - qe + qro + qfrommvr
3813 end subroutine sfr_adjust_ro_ev
3820 subroutine sfr_calc_qd(this, n, depth, hgwf, qgwf, qd)
3822 class(sfrtype) :: this
3823 integer(I4B),
intent(in) :: n
3824 real(DP),
intent(in) :: depth
3825 real(DP),
intent(in) :: hgwf
3826 real(DP),
intent(inout) :: qgwf
3827 real(DP),
intent(inout) :: qd
3835 call this%sfr_calc_qsource(n, depth, qsrc)
3838 call this%sfr_calc_qgwf(n, depth, hgwf, qgwf)
3839 if (-qgwf > qsrc) qgwf = -qsrc
3846 end subroutine sfr_calc_qd
3854 subroutine sfr_calc_qsource(this, n, depth, qsrc)
3856 class(sfrtype) :: this
3857 integer(I4B),
intent(in) :: n
3858 real(DP),
intent(in) :: depth
3859 real(DP),
intent(inout) :: qsrc
3866 real(DP) :: qfrommvr
3876 qro = this%runoff(n)
3879 a = this%calc_surface_area(n)
3880 ae = this%calc_surface_area_wet(n, depth)
3881 qr = this%rain(n) * a
3882 qe = this%evap(n) * ae
3886 if (this%imover == 1)
then
3887 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3891 qsrc = qu + qi + qr - qe + qro + qfrommvr
3894 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3895 end subroutine sfr_calc_qsource
3903 subroutine sfr_calc_qman(this, n, depth, qman)
3905 class(sfrtype) :: this
3906 integer(I4B),
intent(in) :: n
3907 real(DP),
intent(in) :: depth
3908 real(DP),
intent(inout) :: qman
3910 integer(I4B) :: npts
3925 if (depth >
dzero)
then
3926 npts = this%ncrosspts(n)
3937 i0 = this%iacross(n)
3938 i1 = this%iacross(n + 1) - 1
3943 this%station(i0:i1), &
3944 this%xsheight(i0:i1), &
3945 this%xsrough(i0:i1), &
3952 aw = this%calc_area_wet(n, depth)
3953 wp = this%calc_perimeter_wet(n, depth)
3954 if (wp >
dzero)
then
3959 qman = this%unitconv * aw * (rh**
dtwothirds) * sqrt(s) / r
3965 end subroutine sfr_calc_qman
3974 subroutine sfr_calc_qgwf(this, n, depth, hgwf, qgwf, gwfhcof, gwfrhs)
3976 class(sfrtype) :: this
3977 integer(I4B),
intent(in) :: n
3978 real(DP),
intent(in) :: depth
3979 real(DP),
intent(in) :: hgwf
3980 real(DP),
intent(inout) :: qgwf
3981 real(DP),
intent(inout),
optional :: gwfhcof
3982 real(DP),
intent(inout),
optional :: gwfrhs
3984 integer(I4B) :: node
3992 real(DP) :: gwfhcof0
3999 node = this%igwfnode(n)
4000 if (node < 1)
return
4003 if (this%ibound(node) == 0)
return
4010 bt = tp - this%bthick(n)
4013 if (h_temp < bt)
then
4018 call this%sfr_calc_cond(n, depth, cond, hsfr, h_temp)
4021 qgwf = sat * cond * (h_temp - hsfr)
4022 gwfrhs0 = -sat * cond * hsfr
4023 gwfhcof0 = -sat * cond
4026 if (this%idense /= 0)
then
4027 call this%sfr_calculate_density_exchange(n, hsfr, hgwf, cond, tp, &
4028 qgwf, gwfhcof0, gwfrhs0)
4032 if (
present(gwfhcof)) gwfhcof = gwfhcof0
4033 if (
present(gwfrhs)) gwfrhs = gwfrhs0
4034 end subroutine sfr_calc_qgwf
4042 function sfr_gwf_conn(this, n)
4044 integer(I4B) :: sfr_gwf_conn
4046 class(sfrtype) :: this
4047 integer(I4B),
intent(in) :: n
4049 integer(I4B) :: node
4052 node = this%igwfnode(n)
4053 if (node > 0 .and. this%hk(n) >
dzero)
then
4056 end function sfr_gwf_conn
4063 subroutine sfr_calc_cond(this, n, depth, cond, hsfr, h_temp)
4065 class(sfrtype) :: this
4066 integer(I4B),
intent(in) :: n
4067 real(DP),
intent(in) :: depth
4068 real(DP),
intent(inout) :: cond
4069 real(DP),
intent(in),
optional :: hsfr
4070 real(DP),
intent(in),
optional :: h_temp
4072 integer(I4B) :: node
4074 real(DP) :: vscratio
4084 node = this%igwfnode(n)
4086 if (this%ibound(node) > 0)
then
4089 if (this%ivsc == 1)
then
4090 if (hsfr > h_temp)
then
4092 vscratio = this%viscratios(1, n)
4094 vscratio = this%viscratios(2, n)
4097 wp = this%calc_perimeter_wet(n, depth)
4098 cond = this%hk(n) * vscratio * this%length(n) * wp / this%bthick(n)
4101 end subroutine sfr_calc_cond
4111 subroutine sfr_calc_div(this, n, i, qd, qdiv)
4113 class(sfrtype) :: this
4114 integer(I4B),
intent(in) :: n
4115 integer(I4B),
intent(in) :: i
4116 real(DP),
intent(inout) :: qd
4117 real(DP),
intent(inout) :: qdiv
4119 character(len=10) :: cp
4120 integer(I4B) :: jpos
4125 jpos = this%iadiv(n) + i - 1
4126 n2 = this%divreach(jpos)
4127 cp = this%divcprior(jpos)
4128 v = this%divflow(jpos)
4159 end subroutine sfr_calc_div
4166 subroutine sfr_calc_reach_depth(this, n, q1, d1)
4168 class(sfrtype) :: this
4169 integer(I4B),
intent(in) :: n
4170 real(DP),
intent(in) :: q1
4171 real(DP),
intent(inout) :: d1
4183 if (q1 >
dzero)
then
4184 if (this%ncrosspts(n) > 1)
then
4185 call this%sfr_calc_xs_depth(n, q1, d1)
4187 w = this%station(this%iacross(n))
4188 qconst = this%unitconv * w * sqrt(s) / r
4189 d1 = (q1 / qconst)**
dp6
4194 end subroutine sfr_calc_reach_depth
4202 subroutine sfr_calc_xs_depth(this, n, qrch, d)
4204 class(sfrtype) :: this
4205 integer(I4B),
intent(in) :: n
4206 real(DP),
intent(in) :: qrch
4207 real(DP),
intent(inout) :: d
4209 integer(I4B) :: iter
4210 real(DP) :: perturbation
4216 real(DP) :: residual
4219 perturbation = this%deps *
dtwo
4222 residual = q0 - qrch
4225 nriter:
do iter = 1, this%maxsfrit
4226 call this%sfr_calc_qman(n, d + perturbation, q1)
4228 if (dq /=
dzero)
then
4229 derv = perturbation / (q1 - q0)
4233 dd = derv * residual
4235 call this%sfr_calc_qman(n, d, q0)
4236 residual = q0 - qrch
4239 if (abs(dd) < this%dmaxchg)
then
4243 end subroutine sfr_calc_xs_depth
4251 subroutine sfr_check_conversion(this)
4253 class(sfrtype) :: this
4256 character(len=*),
parameter :: fmtunitconv_error = &
4257 &
"('SFR (',a,') UNIT_CONVERSION SPECIFIED VALUE (',g0,') AND', &
4258 &1x,'LENGTH_CONVERSION OR TIME_CONVERSION SPECIFIED.')"
4259 character(len=*),
parameter :: fmtunitconv = &
4260 &
"(1x,'SFR PACKAGE (',a,') CONVERSION DATA',&
4261 &/4x,'UNIT CONVERSION VALUE (',g0,').',/)"
4264 if (this%lengthconv /=
dnodata .or. this%timeconv /=
dnodata)
then
4265 if (this%unitconv /=
done)
then
4266 write (
errmsg, fmtunitconv_error) &
4267 trim(adjustl(this%packName)), this%unitconv
4270 if (this%lengthconv /=
dnodata)
then
4271 this%unitconv = this%unitconv * this%lengthconv**
donethird
4273 if (this%timeconv /=
dnodata)
then
4274 this%unitconv = this%unitconv * this%timeconv
4276 write (this%iout, fmtunitconv) &
4277 trim(adjustl(this%packName)), this%unitconv
4280 end subroutine sfr_check_conversion
4289 subroutine sfr_check_storage_weight(this)
4291 class(sfrtype) :: this
4293 character(len=*),
parameter :: fmtweight = &
4294 &
"(1x,'SFR PACKAGE (',a,') SETTING DEFAULT',&
4295 &/4x,'STORAGE_WEIGHT VALUE (',g0,').',/)"
4298 if (this%istorage == 1)
then
4299 if (this%storage_weight ==
dnodata)
then
4300 this%storage_weight =
done
4301 write (this%iout, fmtweight) &
4302 trim(adjustl(this%packName)), this%storage_weight
4305 end subroutine sfr_check_storage_weight
4314 subroutine sfr_check_reaches(this)
4316 class(sfrtype) :: this
4318 character(len=5) :: crch
4319 character(len=10) :: cval
4320 character(len=30) :: nodestr
4321 character(len=LINELENGTH) :: title
4322 character(len=LINELENGTH) :: text
4329 if (this%iprpak /= 0)
then
4330 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4331 trim(adjustl(this%packName))//
') STATIC REACH DATA'
4332 call table_cr(this%inputtab, this%packName, title)
4333 call this%inputtab%table_df(this%maxbound, 10, this%iout)
4335 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4337 call this%inputtab%initialize_column(text, 20, alignment=
tableft)
4339 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4341 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4343 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4345 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4347 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4349 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4351 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4352 text =
'UPSTREAM FRACTION'
4353 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4357 do n = 1, this%maxbound
4358 write (crch,
'(i5)') n
4359 nn = this%igwfnode(n)
4361 btgwf = this%dis%bot(nn)
4362 call this%dis%noder_to_string(nn, nodestr)
4367 if (this%length(n) <=
dzero)
then
4368 errmsg =
'Reach '//crch//
' length must be greater than 0.0.'
4372 if (this%width(n) <=
dzero)
then
4373 errmsg =
'Reach '//crch//
' width must be greater than 0.0.'
4377 if (this%slope(n) <=
dzero)
then
4378 errmsg =
'Reach '//crch//
' slope must be greater than 0.0.'
4383 bt = this%strtop(n) - this%bthick(n)
4384 if (bt <= btgwf .and. this%icheck /= 0)
then
4385 write (cval,
'(f10.4)') bt
4386 errmsg =
'Reach '//crch//
' bed bottom (rtp-rbth ='// &
4387 cval//
') must be greater than the bottom of cell ('// &
4389 write (cval,
'(f10.4)') btgwf
4393 if (this%hk(n) <
dzero)
then
4394 errmsg =
'Reach '//crch//
' hk must be greater than or equal to 0.0.'
4399 if (this%rough(n) <=
dzero)
then
4400 errmsg =
'Reach '//crch//
" Manning's roughness "// &
4401 'coefficient must be greater than 0.0.'
4405 if (this%ustrf(n) <
dzero)
then
4406 errmsg =
'Reach '//crch//
' upstream fraction must be greater '// &
4407 'than or equal to 0.0.'
4411 if (this%iprpak /= 0)
then
4412 call this%inputtab%add_term(n)
4413 call this%inputtab%add_term(nodestr)
4414 call this%inputtab%add_term(this%length(n))
4415 call this%inputtab%add_term(this%width(n))
4416 call this%inputtab%add_term(this%slope(n))
4417 call this%inputtab%add_term(this%strtop(n))
4418 call this%inputtab%add_term(this%bthick(n))
4419 call this%inputtab%add_term(this%hk(n))
4420 call this%inputtab%add_term(this%rough(n))
4421 call this%inputtab%add_term(this%ustrf(n))
4424 end subroutine sfr_check_reaches
4433 subroutine sfr_check_connections(this)
4435 class(sfrtype) :: this
4437 logical(LGP) :: lreorder
4438 character(len=5) :: crch
4439 character(len=5) :: crch2
4440 character(len=LINELENGTH) :: text
4441 character(len=LINELENGTH) :: title
4448 integer(I4B) :: ifound
4449 integer(I4B) :: ierr
4450 integer(I4B) :: maxconn
4451 integer(I4B) :: ntabcol
4455 do j = 1, this%MAXBOUND
4456 n = this%isfrorder(j)
4465 write (this%iout,
'(/,1x,a)') &
4466 trim(adjustl(this%text))//
' PACKAGE ('// &
4467 trim(adjustl(this%packName))//
') REACH SOLUTION HAS BEEN '// &
4468 'REORDERED USING A DAG'
4471 if (this%iprpak /= 0)
then
4475 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4476 trim(adjustl(this%packName))//
') REACH SOLUTION ORDER'
4477 call table_cr(this%inputtab, this%packName, title)
4478 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4480 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4482 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4485 do j = 1, this%maxbound
4486 n = this%isfrorder(j)
4487 call this%inputtab%add_term(j)
4488 call this%inputtab%add_term(n)
4494 if (this%iprpak /= 0)
then
4498 do n = 1, this%maxbound
4499 maxconn = max(maxconn, this%nconnreach(n))
4501 ntabcol = 1 + maxconn
4504 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4505 trim(adjustl(this%packName))//
') STATIC REACH CONNECTION DATA'
4506 call table_cr(this%inputtab, this%packName, title)
4507 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4509 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4511 write (text,
'(a,1x,i6)')
'CONN', n
4512 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4518 do n = 1, this%MAXBOUND
4519 write (crch,
'(i5)') n
4520 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4522 write (crch2,
'(i5)') nn
4524 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4531 if (ifound /= 1)
then
4532 errmsg =
'Reach '//crch//
' is connected to '// &
4533 'reach '//crch2//
' but reach '//crch2// &
4534 ' is not connected to reach '//crch//
'.'
4540 if (this%iprpak /= 0)
then
4541 call this%inputtab%add_term(n)
4542 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4543 call this%inputtab%add_term(this%ja(i))
4545 nn = maxconn - this%nconnreach(n)
4547 call this%inputtab%add_term(
' ')
4556 do n = 1, this%maxbound
4557 write (crch,
'(i5)') n
4558 eachconnv:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4561 if (this%idir(i) < 0) cycle eachconnv
4563 write (crch2,
'(i5)') nn
4564 connreachv:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4566 if (this%idir(ii) < 0) cycle connreachv
4573 errmsg =
'Reach '//crch//
' is connected to '// &
4574 'reach '//crch2//
' but streamflow from reach '// &
4575 crch//
' to reach '//crch2//
' is not permitted.'
4585 call this%parser%StoreErrorUnit()
4590 do n = 1, this%maxbound
4591 write (crch,
'(i5)') n
4592 eachconnds:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4594 if (this%idir(i) > 0) cycle eachconnds
4595 write (crch2,
'(i5)') nn
4597 connreachds:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4600 if (this%idir(i) /= this%idir(ii))
then
4606 if (ifound /= 1)
then
4607 errmsg =
'Reach '//crch//
' downstream connected reach '// &
4608 'is reach '//crch2//
' but reach '//crch//
' is not'// &
4609 ' the upstream connected reach for reach '//crch2//
'.'
4616 if (this%iprpak /= 0)
then
4620 do n = 1, this%maxbound
4622 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4623 if (this%idir(i) > 0)
then
4627 maxconn = max(maxconn, ii)
4629 ntabcol = 1 + maxconn
4632 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4633 trim(adjustl(this%packName))//
') STATIC UPSTREAM REACH '// &
4635 call table_cr(this%inputtab, this%packName, title)
4636 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4638 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4640 write (text,
'(a,1x,i6)')
'UPSTREAM CONN', n
4641 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4645 do n = 1, this%maxbound
4646 call this%inputtab%add_term(n)
4648 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4649 if (this%idir(i) > 0)
then
4650 call this%inputtab%add_term(this%ja(i))
4656 call this%inputtab%add_term(
' ')
4662 do n = 1, this%maxbound
4664 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4665 if (this%idir(i) < 0)
then
4669 maxconn = max(maxconn, ii)
4671 ntabcol = 1 + maxconn
4674 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4675 trim(adjustl(this%packName))//
') STATIC DOWNSTREAM '// &
4676 'REACH CONNECTION DATA'
4677 call table_cr(this%inputtab, this%packName, title)
4678 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4680 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4682 write (text,
'(a,1x,i6)')
'DOWNSTREAM CONN', n
4683 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4687 do n = 1, this%maxbound
4688 call this%inputtab%add_term(n)
4690 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4691 if (this%idir(i) < 0)
then
4692 call this%inputtab%add_term(this%ja(i))
4698 call this%inputtab%add_term(
' ')
4702 end subroutine sfr_check_connections
4711 subroutine sfr_check_diversions(this)
4713 class(sfrtype) :: this
4715 character(len=LINELENGTH) :: title
4716 character(len=LINELENGTH) :: text
4717 character(len=5) :: crch
4718 character(len=5) :: cdiv
4719 character(len=5) :: crch2
4720 character(len=10) :: cprior
4721 integer(I4B) :: maxdiv
4726 integer(I4B) :: idiv
4727 integer(I4B) :: ifound
4728 integer(I4B) :: jpos
4730 10
format(
'Diversion ', i0,
' of reach ', i0, &
4731 ' is invalid or has not been defined.')
4734 if (this%iprpak /= 0)
then
4738 do n = 1, this%maxbound
4739 maxdiv = maxdiv + this%ndiv(n)
4743 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4744 trim(adjustl(this%packName))//
') REACH DIVERSION DATA'
4745 call table_cr(this%inputtab, this%packName, title)
4746 call this%inputtab%table_df(maxdiv, 4, this%iout)
4748 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4750 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4752 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4754 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4758 do n = 1, this%maxbound
4759 if (this%ndiv(n) < 1) cycle
4760 write (crch,
'(i5)') n
4762 do idiv = 1, this%ndiv(n)
4765 jpos = this%iadiv(n) + idiv - 1
4768 write (cdiv,
'(i5)') idiv
4771 nn = this%divreach(jpos)
4772 write (crch2,
'(i5)') nn
4776 if (nn < 1 .or. nn > this%maxbound)
then
4777 write (
errmsg, 10) idiv, n
4781 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4784 if (this%idir(ii) > 0)
then
4790 if (ifound /= 1)
then
4791 errmsg =
'Reach '//crch//
' is not a upstream reach for '// &
4792 'reach '//crch2//
' as a result diversion '//cdiv// &
4793 ' from reach '//crch//
' to reach '//crch2// &
4794 ' is not possible. Check reach connectivity.'
4798 cprior = this%divcprior(jpos)
4801 if (this%iprpak /= 0)
then
4802 call this%inputtab%add_term(n)
4803 call this%inputtab%add_term(idiv)
4804 call this%inputtab%add_term(nn)
4805 call this%inputtab%add_term(cprior)
4809 end subroutine sfr_check_diversions
4819 subroutine sfr_check_initialstages(this)
4820 class(sfrtype) :: this
4822 character(len=LINELENGTH) :: title
4823 character(len=LINELENGTH) :: text
4824 character(len=5) :: crch
4829 if (this%istorage == 0)
return
4832 if (this%iprpak /= 0)
then
4835 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4836 trim(adjustl(this%packName))//
') REACH INITIAL STAGE DATA'
4837 call table_cr(this%inputtab, this%packName, title)
4838 call this%inputtab%table_df(this%maxbound, 4, this%iout)
4840 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4841 text =
'INITIAL STAGE'
4842 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4843 text =
'INITIAL DEPTH'
4844 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4845 text =
'INITIAL FLOW'
4846 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4850 do n = 1, this%maxbound
4851 write (crch,
'(i5)') n
4854 call this%sfr_calc_qman(n, this%depth(n), qman)
4855 this%usinflow(n) = qman
4856 this%dsflow(n) = qman
4859 if (this%iprpak /= 0)
then
4860 call this%inputtab%add_term(n)
4861 call this%inputtab%add_term(this%stage(n))
4862 call this%inputtab%add_term(this%depth(n))
4863 call this%inputtab%add_term(qman)
4866 end subroutine sfr_check_initialstages
4875 subroutine sfr_check_ustrf(this)
4877 class(sfrtype) :: this
4879 character(len=LINELENGTH) :: title
4880 character(len=LINELENGTH) :: text
4881 logical(LGP) :: lcycle
4882 logical(LGP) :: ladd
4883 character(len=5) :: crch
4884 character(len=5) :: crch2
4885 character(len=10) :: cval
4886 integer(I4B) :: maxcols
4887 integer(I4B) :: npairs
4888 integer(I4B) :: ipair
4892 integer(I4B) :: idiv
4895 integer(I4B) :: jpos
4901 if (this%iprpak /= 0)
then
4905 do n = 1, this%maxbound
4907 ec:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4910 if (this%idir(i) > 0) cycle ec
4914 if (this%iboundpak(n2) == 0) cycle ec
4918 npairs = max(npairs, ipair)
4921 maxcols = 1 + npairs * 2
4924 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4925 trim(adjustl(this%packName))//
') CONNECTED REACH UPSTREAM '// &
4927 call table_cr(this%inputtab, this%packName, title)
4928 call this%inputtab%table_df(this%maxbound, maxcols, this%iout)
4930 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4932 write (cval,
'(i10)') i
4933 text =
'DOWNSTREAM REACH '//trim(adjustl(cval))
4934 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4935 text =
'FRACTION '//trim(adjustl(cval))
4936 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4941 do n = 1, this%maxbound
4942 do idiv = 1, this%ndiv(n)
4944 i1 = this%iadiv(n + 1) - 1
4946 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4948 if (this%divreach(jpos) == n2)
then
4949 this%idiv(i) = jpos - i0 + 1
4959 do n = 1, this%maxbound
4963 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4964 if (this%idir(i) < 0)
then
4970 do idiv = 1, this%ndiv(n)
4971 jpos = this%iadiv(n) + idiv - 1
4972 n2 = this%divreach(jpos)
4974 if (f /=
dzero)
then
4975 write (
errmsg,
'(a,2(1x,i0,1x,a),1x,a,g0,a,2(1x,a))') &
4976 'Reach', n,
'is connected to reach', n2,
'by a diversion', &
4977 'but the upstream fraction is not equal to zero (', f,
'). Check', &
4978 trim(this%packName),
'package diversion and package data.'
4982 write (
warnmsg,
'(a,3(1x,a))') &
4984 'A warning instead of an error is issued because', &
4985 'the reach is only connected to the diversion reach in the ', &
4986 'downstream direction.'
4996 do n = 1, this%maxbound
5000 write (crch,
'(i5)') n
5001 if (this%iprpak /= 0)
then
5002 call this%inputtab%add_term(n)
5005 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5009 this%qconn(i) =
dzero
5012 if (this%idir(i) > 0)
then
5018 if (this%iboundpak(n2) == 0)
then
5025 write (crch2,
'(i5)') n2
5028 f = f + this%ustrf(n2)
5029 write (cval,
'(f10.4)') this%ustrf(n2)
5032 if (this%iprpak /= 0)
then
5033 call this%inputtab%add_term(n2)
5034 call this%inputtab%add_term(this%ustrf(n2))
5036 eachdiv:
do idiv = 1, this%ndiv(n)
5037 jpos = this%iadiv(n) + idiv - 1
5038 if (this%divreach(jpos) == n2)
then
5044 rval = rval + this%ustrf(n2)
5047 this%ftotnd(n) = rval
5050 if (this%iprpak /= 0)
then
5052 do i = ipair, npairs
5053 call this%inputtab%add_term(
' ')
5054 call this%inputtab%add_term(
' ')
5062 write (
errmsg,
'(a,1x,i0,1x,a,g0,a,3(1x,a))') &
5063 'Upstream fractions for reach ', n,
'is not equal to one (', f, &
5064 '). Check', trim(this%packName),
'package reach connectivity and', &
5070 end subroutine sfr_check_ustrf
5079 subroutine sfr_setup_budobj(this)
5081 class(sfrtype) :: this
5083 integer(I4B) :: nbudterm
5088 integer(I4B) :: maxlist
5089 integer(I4B) :: naux
5092 character(len=LENBUDTXT) :: text
5093 character(len=LENBUDTXT),
dimension(1) :: auxtxt
5100 if (this%imover == 1) nbudterm = nbudterm + 2
5101 if (this%naux > 0) nbudterm = nbudterm + 1
5105 call this%budobj%budgetobject_df(this%maxbound, nbudterm, 0, 0, &
5106 ibudcsv=this%ibudcsv)
5110 text =
' FLOW-JA-FACE'
5112 maxlist = this%nconn
5114 auxtxt(1) =
' FLOW-AREA'
5115 call this%budobj%budterm(idx)%initialize(text, &
5120 maxlist, .false., .false., &
5124 call this%budobj%budterm(idx)%reset(this%nconn)
5126 do n = 1, this%maxbound
5128 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5130 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5137 maxlist = this%maxbound - this%ianynone
5139 auxtxt(1) =
' FLOW-AREA'
5140 call this%budobj%budterm(idx)%initialize(text, &
5145 maxlist, .false., .true., &
5147 call this%budobj%budterm(idx)%reset(maxlist)
5149 do n = 1, this%maxbound
5150 n2 = this%igwfnode(n)
5152 call this%budobj%budterm(idx)%update_term(n, n2, q)
5159 maxlist = this%maxbound
5161 call this%budobj%budterm(idx)%initialize(text, &
5166 maxlist, .false., .false., &
5170 text =
' EVAPORATION'
5172 maxlist = this%maxbound
5174 call this%budobj%budterm(idx)%initialize(text, &
5179 maxlist, .false., .false., &
5185 maxlist = this%maxbound
5187 call this%budobj%budterm(idx)%initialize(text, &
5192 maxlist, .false., .false., &
5196 text =
' EXT-INFLOW'
5198 maxlist = this%maxbound
5200 call this%budobj%budterm(idx)%initialize(text, &
5205 maxlist, .false., .false., &
5209 text =
' EXT-OUTFLOW'
5211 maxlist = this%maxbound
5213 call this%budobj%budterm(idx)%initialize(text, &
5218 maxlist, .false., .false., &
5224 maxlist = this%maxbound
5226 auxtxt(1) =
' VOLUME'
5227 call this%budobj%budterm(idx)%initialize(text, &
5232 maxlist, .false., .false., &
5236 if (this%imover == 1)
then
5241 maxlist = this%maxbound
5243 call this%budobj%budterm(idx)%initialize(text, &
5248 maxlist, .false., .false., &
5254 maxlist = this%maxbound
5256 call this%budobj%budterm(idx)%initialize(text, &
5261 maxlist, .false., .false., &
5272 maxlist = this%maxbound
5273 call this%budobj%budterm(idx)%initialize(text, &
5278 maxlist, .false., .false., &
5283 if (this%iprflow /= 0)
then
5284 call this%budobj%flowtable_df(this%iout, cellids=
'GWF')
5286 end subroutine sfr_setup_budobj
5295 subroutine sfr_fill_budobj(this)
5297 class(sfrtype) :: this
5299 integer(I4B) :: naux
5306 integer(I4B) :: idiv
5307 integer(I4B) :: jpos
5321 call this%budobj%budterm(idx)%reset(this%nconn)
5322 do n = 1, this%maxbound
5326 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5328 if (this%iboundpak(n) /= 0)
then
5330 if (this%idir(i) < 0)
then
5336 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5337 if (this%idir(ii) > 0) cycle
5338 if (this%ja(ii) /= n) cycle
5344 call this%sfr_calc_reach_depth(n, qt, d)
5345 ca = this%calc_area_wet(n, d)
5350 this%qauxcbc(1) = ca
5351 call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5357 call this%budobj%budterm(idx)%reset(this%maxbound - this%ianynone)
5358 do n = 1, this%maxbound
5359 n2 = this%igwfnode(n)
5361 if (this%iboundpak(n) /= 0)
then
5363 if (this%depth(n) >
dzero)
then
5364 wp = this%calc_perimeter_wet(n, this%depth(n))
5373 this%qauxcbc(1) =
dzero
5376 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
5382 call this%budobj%budterm(idx)%reset(this%maxbound)
5383 do n = 1, this%maxbound
5384 if (this%iboundpak(n) /= 0)
then
5385 a = this%calc_surface_area(n)
5386 q = this%rain(n) * a
5390 call this%budobj%budterm(idx)%update_term(n, n, q)
5395 call this%budobj%budterm(idx)%reset(this%maxbound)
5396 do n = 1, this%maxbound
5397 if (this%iboundpak(n) /= 0)
then
5398 q = -this%simevap(n)
5402 call this%budobj%budterm(idx)%update_term(n, n, q)
5407 call this%budobj%budterm(idx)%reset(this%maxbound)
5408 do n = 1, this%maxbound
5409 if (this%iboundpak(n) /= 0)
then
5410 q = this%simrunoff(n)
5414 call this%budobj%budterm(idx)%update_term(n, n, q)
5419 call this%budobj%budterm(idx)%reset(this%maxbound)
5420 do n = 1, this%maxbound
5421 if (this%iboundpak(n) /= 0)
then
5426 call this%budobj%budterm(idx)%update_term(n, n, q)
5431 call this%budobj%budterm(idx)%reset(this%maxbound)
5432 do n = 1, this%maxbound
5434 if (this%iboundpak(n) /= 0)
then
5435 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5436 if (this%idir(i) > 0) cycle
5439 jpos = this%iadiv(n) + idiv - 1
5440 q = q + this%divq(jpos)
5442 q = q + this%qconn(i)
5445 q = q - this%dsflow(n)
5446 if (this%imover == 1)
then
5447 q = q + this%pakmvrobj%get_qtomvr(n)
5450 if (this%imover == 1)
then
5451 q = this%pakmvrobj%get_qfrommvr(n)
5454 call this%budobj%budterm(idx)%update_term(n, n, q)
5459 call this%budobj%budterm(idx)%reset(this%maxbound)
5460 do n = 1, this%maxbound
5462 if (this%iboundpak(n) /= 0)
then
5464 a = this%calc_surface_area_wet(n, d)
5465 this%qauxcbc(1) = a * d
5466 if (this%gwfiss == 0 .and. this%istorage == 1)
then
5471 this%qauxcbc(1) =
dzero
5473 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
5477 if (this%imover == 1)
then
5481 call this%budobj%budterm(idx)%reset(this%maxbound)
5482 do n = 1, this%maxbound
5484 if (this%iboundpak(n) /= 0)
then
5485 q = this%pakmvrobj%get_qfrommvr(n)
5487 call this%budobj%budterm(idx)%update_term(n, n, q)
5492 call this%budobj%budterm(idx)%reset(this%maxbound)
5493 do n = 1, this%maxbound
5494 if (this%iboundpak(n) /= 0)
then
5495 q = this%pakmvrobj%get_qtomvr(n)
5502 call this%budobj%budterm(idx)%update_term(n, n, q)
5510 call this%budobj%budterm(idx)%reset(this%maxbound)
5511 do n = 1, this%maxbound
5513 call this%budobj%budterm(idx)%update_term(n, n, q, this%auxvar(:, n))
5518 call this%budobj%accumulate_terms()
5519 end subroutine sfr_fill_budobj
5528 subroutine sfr_setup_tableobj(this)
5530 class(sfrtype) :: this
5532 integer(I4B) :: nterms
5533 character(len=LINELENGTH) :: title
5534 character(len=LINELENGTH) :: text
5537 if (this%iprhed > 0)
then
5544 if (this%inamedbound == 1)
then
5549 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5550 trim(adjustl(this%packName))//
') STAGES FOR EACH CONTROL VOLUME'
5553 call table_cr(this%stagetab, this%packName, title)
5554 call this%stagetab%table_df(this%maxbound, nterms, this%iout, &
5558 if (this%inamedbound == 1)
then
5560 call this%stagetab%initialize_column(text,
lenboundname, &
5566 call this%stagetab%initialize_column(text, 10, alignment=
tabcenter)
5570 call this%stagetab%initialize_column(text, 20, alignment=
tableft)
5574 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5578 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5582 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5586 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5589 text =
'STREAMBED CONDUCTANCE'
5590 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5593 text =
'STREAMBED GRADIENT'
5594 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5596 end subroutine sfr_setup_tableobj
5605 function calc_area_wet(this, n, depth)
5607 real(dp) :: calc_area_wet
5609 class(sfrtype) :: this
5610 integer(I4B),
intent(in) :: n
5611 real(dp),
intent(in) :: depth
5613 integer(I4B) :: npts
5618 npts = this%ncrosspts(n)
5619 i0 = this%iacross(n)
5620 i1 = this%iacross(n + 1) - 1
5623 this%xsheight(i0:i1), depth)
5625 calc_area_wet = this%station(i0) * depth
5627 end function calc_area_wet
5634 function calc_perimeter_wet(this, n, depth)
5636 real(dp) :: calc_perimeter_wet
5638 class(sfrtype) :: this
5639 integer(I4B),
intent(in) :: n
5640 real(dp),
intent(in) :: depth
5642 integer(I4B) :: npts
5647 npts = this%ncrosspts(n)
5648 i0 = this%iacross(n)
5649 i1 = this%iacross(n + 1) - 1
5652 this%xsheight(i0:i1), depth)
5654 calc_perimeter_wet = this%station(i0)
5656 end function calc_perimeter_wet
5663 function calc_surface_area(this, n)
5665 real(dp) :: calc_surface_area
5667 class(sfrtype) :: this
5668 integer(I4B),
intent(in) :: n
5670 integer(I4B) :: npts
5673 real(dp) :: top_width
5676 npts = this%ncrosspts(n)
5677 i0 = this%iacross(n)
5678 i1 = this%iacross(n + 1) - 1
5682 top_width = this%station(i0)
5684 calc_surface_area = top_width * this%length(n)
5685 end function calc_surface_area
5692 function calc_surface_area_wet(this, n, depth)
5694 real(dp) :: calc_surface_area_wet
5696 class(sfrtype) :: this
5697 integer(I4B),
intent(in) :: n
5698 real(dp),
intent(in) :: depth
5700 real(dp) :: top_width
5703 top_width = this%calc_top_width_wet(n, depth)
5704 calc_surface_area_wet = top_width * this%length(n)
5705 end function calc_surface_area_wet
5712 function calc_top_width_wet(this, n, depth)
5714 real(dp) :: calc_top_width_wet
5716 class(sfrtype) :: this
5717 integer(I4B),
intent(in) :: n
5718 real(dp),
intent(in) :: depth
5720 integer(I4B) :: npts
5726 npts = this%ncrosspts(n)
5727 i0 = this%iacross(n)
5728 i1 = this%iacross(n + 1) - 1
5732 this%station(i0:i1), &
5733 this%xsheight(i0:i1), &
5736 calc_top_width_wet = sat * this%station(i0)
5738 end function calc_top_width_wet
5745 subroutine sfr_activate_density(this)
5749 class(sfrtype),
intent(inout) :: this
5756 call mem_reallocate(this%denseterms, 3, this%MAXBOUND,
'DENSETERMS', &
5758 do i = 1, this%maxbound
5760 this%denseterms(j, i) =
dzero
5763 write (this%iout,
'(/1x,a)')
'DENSITY TERMS HAVE BEEN ACTIVATED FOR SFR &
5764 &PACKAGE: '//trim(adjustl(this%packName))
5765 end subroutine sfr_activate_density
5773 subroutine sfr_activate_viscosity(this)
5777 class(sfrtype),
intent(inout) :: this
5784 call mem_reallocate(this%viscratios, 2, this%MAXBOUND,
'VISCRATIOS', &
5786 do i = 1, this%maxbound
5788 this%viscratios(j, i) =
done
5791 write (this%iout,
'(/1x,a)')
'VISCOSITY HAS BEEN ACTIVATED FOR SFR &
5792 &PACKAGE: '//trim(adjustl(this%packName))
5793 end subroutine sfr_activate_viscosity
5807 subroutine sfr_calculate_density_exchange(this, n, stage, head, cond, &
5808 bots, flow, gwfhcof, gwfrhs)
5810 class(sfrtype),
intent(inout) :: this
5811 integer(I4B),
intent(in) :: n
5812 real(DP),
intent(in) :: stage
5813 real(DP),
intent(in) :: head
5814 real(DP),
intent(in) :: cond
5815 real(DP),
intent(in) :: bots
5816 real(DP),
intent(inout) :: flow
5817 real(DP),
intent(inout) :: gwfhcof
5818 real(DP),
intent(inout) :: gwfrhs
5823 real(DP) :: rdensesfr
5824 real(DP) :: rdensegwf
5825 real(DP) :: rdenseavg
5831 logical(LGP) :: stage_below_bot
5832 logical(LGP) :: head_below_bot
5835 if (stage >= bots)
then
5837 stage_below_bot = .false.
5838 rdensesfr = this%denseterms(1, n)
5841 stage_below_bot = .true.
5842 rdensesfr = this%denseterms(2, n)
5846 if (head >= bots)
then
5848 head_below_bot = .false.
5849 rdensegwf = this%denseterms(2, n)
5852 head_below_bot = .true.
5853 rdensegwf = this%denseterms(1, n)
5857 if (rdensegwf ==
dzero)
return
5860 if (stage_below_bot .and. head_below_bot)
then
5867 rdenseavg =
dhalf * (rdensesfr + rdensegwf)
5871 d1 = cond * (rdenseavg -
done)
5872 gwfhcof = gwfhcof - d1
5873 gwfrhs = gwfrhs - d1 * ss
5878 if (.not. stage_below_bot .and. .not. head_below_bot)
then
5882 elevgwf = this%denseterms(3, n)
5884 elevavg =
dhalf * (elevsfr + elevgwf)
5885 havg =
dhalf * (hh + ss)
5886 d2 = cond * (havg - elevavg) * (rdensegwf - rdensesfr)
5887 gwfrhs = gwfrhs + d2
5891 end subroutine sfr_calculate_density_exchange
This module contains the base boundary package.
This module contains the BudgetModule.
subroutine, public budgetobject_cr(this, name)
Create a new budget object.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
real(dp), parameter dhdry
real dry cell constant
@ tabcenter
centered table column
@ tabright
right justified table column
@ tableft
left justified table column
@ mnormal
normal output mode
real(dp), parameter dtwothirds
real constant 2/3
integer(i4b), parameter lenpackagename
maximum length of the package name
real(dp), parameter dp9
real constant 9/10
real(dp), parameter deight
real constant 8
real(dp), parameter dfivethirds
real constant 5/3
real(dp), parameter dp999
real constant 999/1000
integer(i4b), parameter namedboundflag
named bound flag
real(dp), parameter donethird
real constant 1/3
real(dp), parameter dnodata
real no data constant
real(dp), parameter d1p1
real constant 1.1
real(dp), parameter dhnoflo
real no flow constant
real(dp), parameter dhundred
real constant 100
integer(i4b), parameter lenpakloc
maximum length of a package location
integer(i4b), parameter lentimeseriesname
maximum length of a time series name
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
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
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.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
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.
real(dp) function calc_top_width_wet(this, n, depth)
Calculate wetted top width.
subroutine sfr_setup_tableobj(this)
Setup stage table object for package.
subroutine sfr_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
@ brief Convergence check for package.
subroutine sfr_cq(this, x, flowja, iadv)
@ brief Calculate package flows.
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
@ brief Output package flow terms.
subroutine sfr_activate_viscosity(this)
Activate viscosity terms.
subroutine sfr_da(this)
@ brief Deallocate package memory
subroutine sfr_read_diversions(this)
@ brief Read diversions for the package
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_read_connectiondata(this)
@ brief Read connectiondata for the package
subroutine sfr_calc_xs_depth(this, n, qrch, d)
Calculate the depth at the midpoint of a irregular cross-section.
subroutine sfr_set_stressperiod(this, n, ichkustrm, crossfile)
Set period data.
subroutine sfr_check_diversions(this)
Check diversions data.
subroutine sfr_ot_dv(this, idvsave, idvprint)
@ brief Output package dependent-variable terms.
subroutine sfr_calculate_density_exchange(this, n, stage, head, cond, bots, flow, gwfhcof, gwfrhs)
Calculate density terms.
subroutine sfr_fc(this, rhs, ia, idxglo, matrix_sln)
@ brief Copy hcof and rhs terms into solution.
subroutine, public sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
@ brief Create a new package object
subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
@ brief Add Newton-Raphson terms for package into solution.
subroutine define_listlabel(this)
@ brief Define the list label for the package
subroutine sfr_df_obs(this)
Define the observation types available in the package.
subroutine sfr_options(this, option, found)
@ brief Read additional options for 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_allocate_arrays(this)
@ brief Allocate arrays
subroutine sfr_bd_obs(this)
Save observations for the package.
subroutine sfr_setup_budobj(this)
Setup budget object for package.
subroutine sfr_check_initialstages(this)
Check initial stage data.
subroutine sfr_rp(this)
@ brief Read and prepare period data for package
subroutine sfr_ar(this)
@ brief Allocate and read method for package
subroutine sfr_calc_qman(this, n, depth, qman)
Calculate streamflow.
subroutine sfr_check_reaches(this)
Check reach data.
real(dp) function calc_perimeter_wet(this, n, depth)
Calculate wetted perimeter.
subroutine sfr_read_packagedata(this)
@ brief Read packagedata for the package
subroutine sfr_read_initial_stages(this)
@ brief Read initialstages data for the package
subroutine sfr_update_flows(this, n, qd, qgwf)
Update flow terms.
subroutine sfr_calc_qd(this, n, depth, hgwf, qgwf, qd)
Calculate downstream flow term.
subroutine sfr_fill_budobj(this)
Copy flow terms into budget object for package.
subroutine sfr_cf(this)
@ brief Formulate the package hcof and rhs terms.
subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
@ brief Output advanced package budget summary.
subroutine sfr_calc_div(this, n, i, qd, qdiv)
Calculate diversion flow.
subroutine sfr_calc_qgwf(this, n, depth, hgwf, qgwf, gwfhcof, gwfrhs)
Calculate reach-aquifer exchange.
character(len=lenftype) ftype
package ftype string
character(len=lenpackagename) text
package budget string
subroutine sfr_calc_qsource(this, n, depth, qsrc)
Calculate sum of sources.
subroutine sfr_allocate_scalars(this)
@ brief Allocate scalars
logical function sfr_obs_supported(this)
Determine if observations are supported.
subroutine sfr_check_storage_weight(this)
Check storage weight.
subroutine sfr_solve(this, n, h, hcof, rhs, update)
Solve reach continuity equation.
subroutine sfr_read_dimensions(this)
@ brief Read dimensions for package
real(dp) function calc_area_wet(this, n, depth)
Calculate wetted area.
subroutine sfr_read_crossection(this)
@ brief Read crosssection block for the package
subroutine sfr_rp_obs(this)
Read and prepare observations for a package.
subroutine sfr_activate_density(this)
Activate density terms.
subroutine sfr_adjust_ro_ev(this, qc, qu, qi, qr, qro, qe, qfrommvr)
Adjust runoff and evaporation.
subroutine sfr_check_conversion(this)
Check unit conversion data.
real(dp) function calc_surface_area_wet(this, n, depth)
Calculate wetted surface area.
integer(i4b) function sfr_gwf_conn(this, n)
Determine if a reach is connected to a gwf cell.
subroutine sfr_ad(this)
@ brief Advance the package
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public deprecation_warning(cblock, cvar, cver, endmsg, iunit)
Store deprecation warning message.
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=maxcharlen) warnmsg
warning message string
real(dp) function squadraticsaturation(top, bot, x, eps)
@ brief sQuadraticSaturation
real(dp) function scubicsaturation(top, bot, x, eps)
@ brief sCubicSaturation
real(dp) function squadraticsaturationderivative(top, bot, x, eps)
@ brief Derivative of the quadratic saturation function
real(dp) function sqsaturationderivative(top, bot, x, c1, c2)
@ brief sQSaturationDerivative
subroutine schsmooth(d, smooth, dwdh)
@ brief sChSmooth
real(dp) function sqsaturation(top, bot, x, c1, c2)
@ brief sQSaturation
subroutine, public table_cr(this, name, title)
real(dp), pointer, public pertim
time relative to start of stress period
real(dp), pointer, public totim
time relative to start of simulation
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
integer(i4b), pointer, public nper
number of stress period
subroutine, public read_value_or_time_series_adv(textInput, ii, jj, bndElem, pkgName, auxOrBnd, tsManager, iprpak, varName)
Call this subroutine from advanced packages to define timeseries link for a variable (varName).
logical function, public var_timeseries(tsManager, pkgName, varName, auxOrBnd)
Determine if a timeseries link with varName is defined.
Derived type for the Budget object.