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
294 subroutine sfr_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
298 class(
bndtype),
pointer :: packobj
299 integer(I4B),
intent(in) :: id
300 integer(I4B),
intent(in) :: ibcnum
301 integer(I4B),
intent(in) :: inunit
302 integer(I4B),
intent(in) :: iout
303 character(len=*),
intent(in) :: namemodel
304 character(len=*),
intent(in) :: pakname
306 type(sfrtype),
pointer :: sfrobj
313 call packobj%set_names(ibcnum, namemodel, pakname, ftype)
317 call sfrobj%sfr_allocate_scalars()
320 call packobj%pack_initialize()
322 packobj%inunit = inunit
325 packobj%ibcnum = ibcnum
330 end subroutine sfr_create
337 subroutine sfr_allocate_scalars(this)
342 class(sfrtype),
intent(inout) :: this
345 call this%BndType%allocate_scalars()
348 call mem_allocate(this%istorage,
'ISTORAGE', this%memoryPath)
349 call mem_allocate(this%iprhed,
'IPRHED', this%memoryPath)
350 call mem_allocate(this%istageout,
'ISTAGEOUT', this%memoryPath)
351 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
352 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
353 call mem_allocate(this%ipakcsv,
'IPAKCSV', this%memoryPath)
354 call mem_allocate(this%idiversions,
'IDIVERSIONS', this%memoryPath)
355 call mem_allocate(this%maxsfrpicard,
'MAXSFRPICARD', this%memoryPath)
356 call mem_allocate(this%maxsfrit,
'MAXSFRIT', this%memoryPath)
357 call mem_allocate(this%bditems,
'BDITEMS', this%memoryPath)
358 call mem_allocate(this%cbcauxitems,
'CBCAUXITEMS', this%memoryPath)
359 call mem_allocate(this%unitconv,
'UNITCONV', this%memoryPath)
360 call mem_allocate(this%lengthconv,
'LENGTHCONV', this%memoryPath)
361 call mem_allocate(this%timeconv,
'TIMECONV', this%memoryPath)
362 call mem_allocate(this%dmaxchg,
'DMAXCHG', this%memoryPath)
364 call mem_allocate(this%storage_weight,
'STORAGE_WEIGHT', this%memoryPath)
366 call mem_allocate(this%icheck,
'ICHECK', this%memoryPath)
367 call mem_allocate(this%iconvchk,
'ICONVCHK', this%memoryPath)
368 call mem_allocate(this%idense,
'IDENSE', this%memoryPath)
369 call mem_allocate(this%ianynone,
'IANYNONE', this%memoryPath)
370 call mem_allocate(this%ncrossptstot,
'NCROSSPTSTOT', this%memoryPath)
383 this%maxsfrpicard = 100
391 this%deps =
dp999 * this%dmaxchg
399 this%ncrossptstot = 0
400 end subroutine sfr_allocate_scalars
406 subroutine sfr_allocate_arrays(this)
410 class(sfrtype),
intent(inout) :: this
416 allocate (this%csfrbudget(this%bditems))
418 'SFRNAME', this%memoryPath)
421 call mem_allocate(this%iboundpak, this%maxbound,
'IBOUNDPAK', &
423 call mem_allocate(this%igwfnode, this%maxbound,
'IGWFNODE', this%memoryPath)
424 call mem_allocate(this%igwftopnode, this%maxbound,
'IGWFTOPNODE', &
426 call mem_allocate(this%length, this%maxbound,
'LENGTH', this%memoryPath)
427 call mem_allocate(this%width, this%maxbound,
'WIDTH', this%memoryPath)
428 call mem_allocate(this%strtop, this%maxbound,
'STRTOP', this%memoryPath)
429 call mem_allocate(this%bthick, this%maxbound,
'BTHICK', this%memoryPath)
430 call mem_allocate(this%hk, this%maxbound,
'HK', this%memoryPath)
431 call mem_allocate(this%slope, this%maxbound,
'SLOPE', this%memoryPath)
432 call mem_allocate(this%nconnreach, this%maxbound,
'NCONNREACH', &
434 call mem_allocate(this%ustrf, this%maxbound,
'USTRF', this%memoryPath)
435 call mem_allocate(this%ftotnd, this%maxbound,
'FTOTND', this%memoryPath)
436 call mem_allocate(this%ndiv, this%maxbound,
'NDIV', this%memoryPath)
437 call mem_allocate(this%usflow, this%maxbound,
'USFLOW', this%memoryPath)
438 call mem_allocate(this%dsflow, this%maxbound,
'DSFLOW', this%memoryPath)
439 call mem_allocate(this%depth, this%maxbound,
'DEPTH', this%memoryPath)
440 call mem_allocate(this%stage, this%maxbound,
'STAGE', this%memoryPath)
441 call mem_allocate(this%gwflow, this%maxbound,
'GWFLOW', this%memoryPath)
442 call mem_allocate(this%simevap, this%maxbound,
'SIMEVAP', this%memoryPath)
443 call mem_allocate(this%simrunoff, this%maxbound,
'SIMRUNOFF', &
445 call mem_allocate(this%stage0, this%maxbound,
'STAGE0', this%memoryPath)
446 call mem_allocate(this%usflow0, this%maxbound,
'USFLOW0', this%memoryPath)
449 if (this%istorage == 1)
then
450 call mem_allocate(this%stageold, this%maxbound,
'STAGEOLD', &
452 call mem_allocate(this%usinflow, this%maxbound,
'USINFLOW', &
454 call mem_allocate(this%usinflowold, this%maxbound,
'USINFLOWOLD', &
456 call mem_allocate(this%dsflowold, this%maxbound,
'DSFLOWOLD', &
458 call mem_allocate(this%storage, this%maxbound,
'STORAGE', &
463 call mem_allocate(this%isfrorder, this%maxbound,
'ISFRORDER', &
465 call mem_allocate(this%ia, this%maxbound + 1,
'IA', this%memoryPath)
467 call mem_allocate(this%idir, 0,
'IDIR', this%memoryPath)
468 call mem_allocate(this%idiv, 0,
'IDIV', this%memoryPath)
469 call mem_allocate(this%qconn, 0,
'QCONN', this%memoryPath)
472 call mem_allocate(this%rough, this%maxbound,
'ROUGH', this%memoryPath)
473 call mem_allocate(this%rain, this%maxbound,
'RAIN', this%memoryPath)
474 call mem_allocate(this%evap, this%maxbound,
'EVAP', this%memoryPath)
475 call mem_allocate(this%inflow, this%maxbound,
'INFLOW', this%memoryPath)
476 call mem_allocate(this%runoff, this%maxbound,
'RUNOFF', this%memoryPath)
477 call mem_allocate(this%sstage, this%maxbound,
'SSTAGE', this%memoryPath)
480 call mem_allocate(this%rauxvar, this%naux, this%maxbound, &
481 'RAUXVAR', this%memoryPath)
484 call mem_allocate(this%iadiv, this%maxbound + 1,
'IADIV', this%memoryPath)
485 call mem_allocate(this%divreach, 0,
'DIVREACH', this%memoryPath)
486 call mem_allocate(this%divflow, 0,
'DIVFLOW', this%memoryPath)
487 call mem_allocate(this%divq, 0,
'DIVQ', this%memoryPath)
490 call mem_allocate(this%ncrosspts, this%maxbound,
'NCROSSPTS', &
492 call mem_allocate(this%iacross, this%maxbound + 1,
'IACROSS', &
494 call mem_allocate(this%station, this%ncrossptstot,
'STATION', &
496 call mem_allocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
498 call mem_allocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
503 do i = 1, this%maxbound
504 this%iboundpak(i) = 1
506 this%igwftopnode(i) = 0
507 this%length(i) =
dzero
508 this%width(i) =
dzero
509 this%strtop(i) =
dzero
510 this%bthick(i) =
dzero
512 this%slope(i) =
dzero
513 this%nconnreach(i) = 0
514 this%ustrf(i) =
dzero
515 this%ftotnd(i) =
dzero
517 this%usflow(i) =
dzero
518 this%dsflow(i) =
dzero
519 this%depth(i) =
dzero
520 this%stage(i) =
dzero
521 this%gwflow(i) =
dzero
522 this%simevap(i) =
dzero
523 this%simrunoff(i) =
dzero
524 this%stage0(i) =
dzero
525 this%usflow0(i) =
dzero
528 if (this%istorage == 1)
then
529 this%stageold(i) =
dzero
530 this%usinflow(i) =
dzero
531 this%usinflowold(i) =
dzero
532 this%dsflowold(i) =
dzero
533 this%storage(i) =
dzero
537 this%rough(i) =
dzero
540 this%inflow(i) =
dzero
541 this%runoff(i) =
dzero
542 this%sstage(i) =
dzero
546 this%rauxvar(j, i) =
dzero
550 this%ncrosspts(i) = 0
551 this%iacross(i + 1) = 0
555 do i = 1, this%ncrossptstot
556 this%station(i) =
dzero
557 this%xsheight(i) =
dzero
558 this%xsrough(i) =
dzero
562 this%csfrbudget(1) =
' RAINFALL'
563 this%csfrbudget(2) =
' EVAPORATION'
564 this%csfrbudget(3) =
' RUNOFF'
565 this%csfrbudget(4) =
' EXT-INFLOW'
566 this%csfrbudget(5) =
' GWF'
567 this%csfrbudget(6) =
' EXT-OUTFLOW'
568 this%csfrbudget(7) =
' FROM-MVR'
569 this%csfrbudget(8) =
' TO-MVR'
572 call mem_allocate(this%qoutflow, this%maxbound,
'QOUTFLOW', this%memoryPath)
573 call mem_allocate(this%qextoutflow, this%maxbound,
'QEXTOUTFLOW', &
575 do i = 1, this%maxbound
576 this%qoutflow(i) =
dzero
577 this%qextoutflow(i) =
dzero
581 if (this%istageout > 0)
then
582 call mem_allocate(this%dbuff, this%maxbound,
'DBUFF', this%memoryPath)
583 do i = 1, this%maxbound
584 this%dbuff(i) =
dzero
587 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
591 allocate (this%cauxcbc(this%cbcauxitems))
594 call mem_allocate(this%qauxcbc, this%cbcauxitems,
'QAUXCBC', &
596 do i = 1, this%cbcauxitems
597 this%qauxcbc(i) =
dzero
601 this%cauxcbc(1) =
'FLOW-AREA '
604 call mem_allocate(this%denseterms, 3, 0,
'DENSETERMS', this%memoryPath)
607 call mem_allocate(this%viscratios, 2, 0,
'VISCRATIOS', this%memoryPath)
608 end subroutine sfr_allocate_arrays
614 subroutine sfr_read_dimensions(this)
616 class(sfrtype),
intent(inout) :: this
618 character(len=LINELENGTH) :: keyword
620 logical(LGP) :: isfound
621 logical(LGP) :: endOfBlock
627 call this%parser%GetBlock(
'DIMENSIONS', isfound, ierr, &
628 supportopenclose=.true.)
632 write (this%iout,
'(/1x,a)') &
633 'PROCESSING '//trim(adjustl(this%text))//
' DIMENSIONS'
635 call this%parser%GetNextLine(endofblock)
637 call this%parser%GetStringCaps(keyword)
638 select case (keyword)
640 this%maxbound = this%parser%GetInteger()
641 write (this%iout,
'(4x,a,i0)')
'NREACHES = ', this%maxbound
644 'Unknown '//trim(this%text)//
' dimension: ', trim(keyword)
648 write (this%iout,
'(1x,a)') &
649 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
651 call store_error(
'Required dimensions block not found.')
655 if (this%maxbound < 1)
then
657 'NREACHES was not specified or was specified incorrectly.'
663 call this%parser%StoreErrorUnit()
668 call this%define_listlabel()
671 this%ncrossptstot = this%maxbound
674 call this%sfr_allocate_arrays()
677 call this%sfr_read_packagedata()
680 call this%sfr_read_crossection()
683 call this%sfr_read_connectiondata()
686 call this%sfr_read_diversions()
689 call this%sfr_read_initial_stages()
692 call this%sfr_setup_budobj()
695 call this%sfr_setup_tableobj()
696 end subroutine sfr_read_dimensions
702 subroutine sfr_options(this, option, found)
707 class(sfrtype),
intent(inout) :: this
708 character(len=*),
intent(inout) :: option
709 logical(LGP),
intent(inout) :: found
712 character(len=MAXCHARLEN) :: fname
713 character(len=MAXCHARLEN) :: keyword
715 character(len=*),
parameter :: fmttimeconv = &
716 &
"(4x, 'TIME CONVERSION VALUE (',g0,') SPECIFIED.')"
717 character(len=*),
parameter :: fmtlengthconv = &
718 &
"(4x, 'LENGTH CONVERSION VALUE (',g0,') SPECIFIED.')"
719 character(len=*),
parameter :: fmtpicard = &
720 &
"(4x, 'MAXIMUM SFR PICARD ITERATION VALUE (',i0,') SPECIFIED.')"
721 character(len=*),
parameter :: fmtiter = &
722 &
"(4x, 'MAXIMUM SFR ITERATION VALUE (',i0,') SPECIFIED.')"
723 character(len=*),
parameter :: fmtdmaxchg = &
724 &
"(4x, 'MAXIMUM DEPTH CHANGE VALUE (',g0,') SPECIFIED.')"
725 character(len=*),
parameter :: fmtsfrbin = &
726 "(4x, 'SFR ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, /4x, &
727 &'OPENED ON UNIT: ', I0)"
728 character(len=*),
parameter :: fmtstoweight = &
729 &
"(4x, 'KINEMATIC STORAGE WEIGHT (',g0,') SPECIFIED.')"
736 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
737 ' REACH STORAGE IS ACTIVE.'
740 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
741 ' STAGES WILL BE PRINTED TO LISTING FILE.'
743 call this%parser%GetStringCaps(keyword)
744 if (keyword ==
'FILEOUT')
then
745 call this%parser%GetString(fname)
747 call openfile(this%istageout, this%iout, fname,
'DATA(BINARY)', &
749 write (this%iout, fmtsfrbin) &
750 'STAGE', trim(adjustl(fname)), this%istageout
753 &be followed by fileout.')
756 call this%parser%GetStringCaps(keyword)
757 if (keyword ==
'FILEOUT')
then
758 call this%parser%GetString(fname)
759 call assign_iounit(this%ibudgetout, this%inunit,
"BUDGET fileout")
760 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
762 write (this%iout, fmtsfrbin) &
763 'BUDGET', trim(adjustl(fname)), this%ibudgetout
765 call store_error(
'Optional budget keyword must be '// &
766 'followed by fileout.')
769 call this%parser%GetStringCaps(keyword)
770 if (keyword ==
'FILEOUT')
then
771 call this%parser%GetString(fname)
772 call assign_iounit(this%ibudcsv, this%inunit,
"BUDGETCSV fileout")
773 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
774 filstat_opt=
'REPLACE')
775 write (this%iout, fmtsfrbin) &
776 'BUDGET CSV', trim(adjustl(fname)), this%ibudcsv
778 call store_error(
'OPTIONAL BUDGETCSV KEYWORD MUST BE FOLLOWED BY &
781 case (
'PACKAGE_CONVERGENCE')
782 call this%parser%GetStringCaps(keyword)
783 if (keyword ==
'FILEOUT')
then
784 call this%parser%GetString(fname)
786 call openfile(this%ipakcsv, this%iout, fname,
'CSV', &
787 filstat_opt=
'REPLACE', mode_opt=
mnormal)
788 write (this%iout, fmtsfrbin) &
789 'PACKAGE_CONVERGENCE', trim(adjustl(fname)), this%ipakcsv
791 call store_error(
'Optional package_convergence keyword must be '// &
792 'followed by fileout.')
794 case (
'UNIT_CONVERSION')
795 this%unitconv = this%parser%GetDouble()
799 'SETTING UNIT_CONVERSION DIRECTLY'
803 warnmsg, this%parser%GetUnit())
804 case (
'LENGTH_CONVERSION')
805 this%lengthconv = this%parser%GetDouble()
806 write (this%iout, fmtlengthconv) this%lengthconv
807 case (
'TIME_CONVERSION')
808 this%timeconv = this%parser%GetDouble()
809 write (this%iout, fmttimeconv) this%timeconv
810 case (
'MAXIMUM_PICARD_ITERATIONS')
811 this%maxsfrpicard = this%parser%GetInteger()
812 write (this%iout, fmtpicard) this%maxsfrpicard
813 case (
'MAXIMUM_ITERATIONS')
814 this%maxsfrit = this%parser%GetInteger()
815 write (this%iout, fmtiter) this%maxsfrit
816 case (
'MAXIMUM_DEPTH_CHANGE')
817 r = this%parser%GetDouble()
819 this%deps =
dp999 * r
820 write (this%iout, fmtdmaxchg) this%dmaxchg
823 write (this%iout,
'(4x,A)')
'MOVER OPTION ENABLED'
829 case (
'DEV_NO_CHECK')
830 call this%parser%DevOpt()
832 write (this%iout,
'(4x,A)')
'SFR CHECKS OF REACH GEOMETRY '// &
833 'RELATIVE TO MODEL GRID AND '// &
834 'REASONABLE PARAMETERS WILL NOT '// &
836 case (
'DEV_NO_FINAL_CHECK')
837 call this%parser%DevOpt()
839 write (this%iout,
'(4x,a)') &
840 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN STREAM FLOW ROUTING &
841 &STAGES AND FLOWS WILL NOT BE MADE'
842 case (
'DEV_STORAGE_WEIGHT')
843 r = this%parser%GetDouble()
845 write (
errmsg,
'(a,g0,a)') &
846 "STORAGE_WEIGHT SPECIFIED TO BE '", r, &
847 "' BUT CANNOT BE LESS THAN 0.5 OR GREATER THAN 1.0"
850 this%storage_weight = r
851 write (this%iout, fmtstoweight) this%storage_weight
860 end subroutine sfr_options
866 subroutine sfr_ar(this)
868 class(sfrtype),
intent(inout) :: this
874 call this%obs%obs_ar()
877 call this%BndType%allocate_arrays()
880 if (this%inamedbound /= 0)
then
881 do n = 1, this%maxbound
882 this%boundname(n) = this%sfrname(n)
887 call this%copy_boundname()
890 do n = 1, this%maxbound
891 this%nodelist(n) = this%igwfnode(n)
895 call this%sfr_check_conversion()
898 call this%sfr_check_storage_weight()
901 call this%sfr_check_reaches()
904 call this%sfr_check_connections()
907 if (this%idiversions /= 0)
then
908 call this%sfr_check_diversions()
912 if (this%istorage == 1)
then
913 call this%sfr_check_initialstages()
919 call this%parser%StoreErrorUnit()
923 if (this%imover /= 0)
then
924 allocate (this%pakmvrobj)
925 call this%pakmvrobj%ar(this%maxbound, this%maxbound, this%memoryPath)
927 end subroutine sfr_ar
933 subroutine sfr_read_packagedata(this)
937 class(sfrtype),
intent(inout) :: this
939 character(len=LINELENGTH) :: text
940 character(len=LINELENGTH) :: cellid
941 character(len=10) :: cnum
942 character(len=LENBOUNDNAME) :: bndName
943 character(len=LENBOUNDNAME) :: bndNameTemp
944 character(len=LENBOUNDNAME) :: hkname
945 character(len=LENBOUNDNAME) :: manningname
946 character(len=LENBOUNDNAME) :: ustrfname
947 character(len=50),
dimension(:),
allocatable :: caux
948 integer(I4B) :: n, ierr, ival
949 logical(LGP) :: isfound
950 logical(LGP) :: endOfBlock
955 integer(I4B) :: nconzero
957 integer,
allocatable,
dimension(:) :: nboundchk
958 real(DP),
pointer :: bndElem => null()
961 allocate (nboundchk(this%maxbound))
962 do i = 1, this%maxbound
968 if (this%naux > 0)
then
969 allocate (caux(this%naux))
973 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
974 supportopenclose=.true.)
978 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
981 call this%parser%GetNextLine(endofblock)
984 n = this%parser%GetInteger()
986 if (n < 1 .or. n > this%maxbound)
then
987 write (
errmsg,
'(a,1x,a,1x,i0)') &
988 'Reach number (rno) must be greater than 0 and less', &
989 'than or equal to', this%maxbound
995 nboundchk(n) = nboundchk(n) + 1
998 call this%parser%GetCellid(this%dis%ndim, cellid, flag_string=.true.)
999 this%igwfnode(n) = this%dis%noder_from_cellid(cellid, this%inunit, &
1001 flag_string=.true., &
1003 this%igwftopnode(n) = this%igwfnode(n)
1006 if (this%igwfnode(n) < 1)
then
1007 this%ianynone = this%ianynone + 1
1009 if (cellid ==
'NONE')
then
1010 call this%parser%GetStringCaps(cellid)
1013 write (cnum,
'(i0)') n
1014 warnmsg =
'CELLID for unconnected reach '//trim(cnum)// &
1015 ' specified to be NONE. Unconnected reaches '// &
1016 'should be specified with a zero for each grid '// &
1017 'dimension. For example, for a DIS grid a CELLID '// &
1018 'of 0 0 0 should be specified for unconnected reaches'
1022 warnmsg, this%parser%GetUnit())
1028 this%length(n) = this%parser%GetDouble()
1030 this%width(n) = this%parser%GetDouble()
1032 this%slope(n) = this%parser%GetDouble()
1034 this%strtop(n) = this%parser%GetDouble()
1036 this%bthick(n) = this%parser%GetDouble()
1038 call this%parser%GetStringCaps(hkname)
1040 call this%parser%GetStringCaps(manningname)
1042 ival = this%parser%GetInteger()
1043 this%nconnreach(n) = ival
1044 this%nconn = this%nconn + ival
1046 write (
errmsg,
'(a,1x,i0,1x,a,i0,a)') &
1047 'NCON for reach', n, &
1048 'must be greater than or equal to 0 (', ival,
').'
1050 else if (ival == 0)
then
1051 nconzero = nconzero + 1
1054 call this%parser%GetString(ustrfname)
1056 ival = this%parser%GetInteger()
1059 this%idiversions = 1
1060 else if (ival < 0)
then
1065 do iaux = 1, this%naux
1066 call this%parser%GetString(caux(iaux))
1070 write (cnum,
'(i10.10)') n
1071 bndname =
'Reach'//cnum
1074 if (this%inamedbound /= 0)
then
1075 call this%parser%GetStringCaps(bndnametemp)
1076 if (bndnametemp /=
'')
then
1077 bndname = bndnametemp
1081 this%sfrname(n) = bndname
1086 bndelem => this%hk(n)
1088 this%packName,
'BND', &
1089 this%tsManager, this%iprpak, &
1095 bndelem => this%rough(n)
1097 this%packName,
'BND', &
1098 this%tsManager, this%iprpak, &
1104 bndelem => this%ustrf(n)
1106 this%packName,
'BND', &
1107 this%tsManager, this%iprpak,
'USTRF')
1110 do jj = 1, this%naux
1113 bndelem => this%rauxvar(jj, ii)
1115 this%packName,
'AUX', &
1116 this%tsManager, this%iprpak, &
1124 this%sstage(n) = this%strtop(n)
1127 write (this%iout,
'(1x,a)') &
1128 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1130 call store_error(
'REQUIRED PACKAGEDATA BLOCK NOT FOUND.')
1135 do i = 1, this%maxbound
1136 if (nboundchk(i) == 0)
then
1137 write (
errmsg,
'(a,i0,1x,a)') &
1138 'Information for reach ', i,
'not specified in packagedata block.'
1140 else if (nboundchk(i) > 1)
then
1141 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1142 'Reach information specified', nboundchk(i),
'times for reach', i
1146 deallocate (nboundchk)
1149 if (nconzero > 0)
then
1150 write (
warnmsg,
'(a,1x,a,1x,a,1x,i0,1x, a)') &
1151 'SFR Package', trim(this%packName), &
1152 'has', nconzero,
'reach(es) with zero connections.'
1158 call this%parser%StoreErrorUnit()
1163 this%iacross(1) = ipos
1164 do i = 1, this%maxbound
1165 this%ncrosspts(i) = 1
1166 this%station(ipos) = this%width(i)
1167 this%xsheight(ipos) =
dzero
1168 this%xsrough(ipos) =
done
1170 this%iacross(i + 1) = ipos
1174 if (this%naux > 0)
then
1177 end subroutine sfr_read_packagedata
1183 subroutine sfr_read_crossection(this)
1188 class(sfrtype),
intent(inout) :: this
1190 character(len=LINELENGTH) :: keyword
1191 character(len=LINELENGTH) :: line
1192 logical(LGP) :: isfound
1193 logical(LGP) :: endOfBlock
1195 integer(I4B) :: ierr
1196 integer(I4B) :: ncrossptstot
1197 integer,
allocatable,
dimension(:) :: nboundchk
1201 call this%parser%GetBlock(
'CROSSSECTIONS', isfound, ierr, &
1202 supportopenclose=.true., &
1203 blockrequired=.false.)
1207 write (this%iout,
'(/1x,a)') &
1208 'PROCESSING '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1211 allocate (nboundchk(this%maxbound))
1212 do n = 1, this%maxbound
1218 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1220 this%station, this%xsheight, &
1225 call this%parser%GetNextLine(endofblock)
1226 if (endofblock)
exit
1229 n = this%parser%GetInteger()
1232 if (n < 1 .or. n > this%maxbound)
then
1233 write (
errmsg,
'(a,1x,a,1x,i0)') &
1234 'SFR reach in crosssections block is less than one or greater', &
1241 nboundchk(n) = nboundchk(n) + 1
1244 call this%parser%GetStringCaps(keyword)
1245 select case (keyword)
1247 call this%parser%GetStringCaps(keyword)
1248 if (trim(adjustl(keyword)) /=
'FILEIN')
then
1249 errmsg =
'TAB6 keyword must be followed by "FILEIN" '// &
1254 call this%parser%GetString(line)
1255 call cross_data%read_table(n, this%width(n), &
1256 trim(adjustl(line)))
1258 write (
errmsg,
'(a,1x,i4,1x,a)') &
1259 'CROSS-SECTION TABLE ENTRY for REACH ', n, &
1260 'MUST INCLUDE TAB6 KEYWORD'
1266 write (this%iout,
'(1x,a)') &
1267 'END OF '//trim(adjustl(this%text))//
' CROSSSECTIONS'
1271 do n = 1, this%maxbound
1272 if (nboundchk(n) > 1)
then
1273 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1274 'Cross-section data for reach', n, &
1275 'specified', nboundchk(n),
'times.'
1282 call this%parser%StoreErrorUnit()
1286 ncrossptstot = cross_data%get_ncrossptstot()
1289 if (ncrossptstot /= this%ncrossptstot)
then
1290 this%ncrossptstot = ncrossptstot
1291 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
1293 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
1295 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
1300 call cross_data%output(this%width, this%rough)
1303 call cross_data%pack(this%ncrossptstot, this%ncrosspts, &
1310 deallocate (nboundchk)
1311 call cross_data%destroy()
1312 deallocate (cross_data)
1313 nullify (cross_data)
1315 end subroutine sfr_read_crossection
1321 subroutine sfr_read_connectiondata(this)
1326 class(sfrtype),
intent(inout) :: this
1328 character(len=LINELENGTH) :: line
1329 logical(LGP) :: isfound
1330 logical(LGP) :: endOfBlock
1335 integer(I4B) :: jcol
1336 integer(I4B) :: jcol2
1338 integer(I4B) :: ival
1339 integer(I4B) :: idir
1340 integer(I4B) :: ierr
1341 integer(I4B) :: nconnmax
1343 integer(I4B) :: ipos
1344 integer(I4B) :: istat
1345 integer(I4B),
dimension(:),
pointer,
contiguous :: rowmaxnnz => null()
1346 integer,
allocatable,
dimension(:) :: nboundchk
1347 integer,
allocatable,
dimension(:, :) :: iconndata
1349 integer(I4B),
dimension(:),
allocatable :: iup
1350 integer(I4B),
dimension(:),
allocatable :: order
1351 type(
dag) :: sfr_dag
1354 allocate (nboundchk(this%maxbound))
1355 do n = 1, this%maxbound
1362 allocate (rowmaxnnz(this%maxbound))
1363 do n = 1, this%maxbound
1364 ival = this%nconnreach(n)
1365 if (ival < 0) ival = 0
1366 rowmaxnnz(n) = ival + 1
1367 nja = nja + ival + 1
1368 if (ival > nconnmax)
then
1383 this%qconn(n) =
dzero
1387 allocate (iconndata(nconnmax, this%maxbound))
1390 do n = 1, this%maxbound
1400 call sparse%init(this%maxbound, this%maxbound, rowmaxnnz)
1403 call this%parser%GetBlock(
'CONNECTIONDATA', isfound, ierr, &
1404 supportopenclose=.true.)
1408 write (this%iout,
'(/1x,a)') &
1409 'PROCESSING '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1411 call this%parser%GetNextLine(endofblock)
1412 if (endofblock)
exit
1415 n = this%parser%GetInteger()
1418 if (n < 1 .or. n > this%maxbound)
then
1419 write (
errmsg,
'(a,1x,a,1x,i0)') &
1420 'SFR reach in connectiondata block is less than one or greater', &
1427 nboundchk(n) = nboundchk(n) + 1
1430 call sparse%addconnection(n, n, 1)
1433 do i = 1, this%nconnreach(n)
1436 ival = this%parser%GetInteger()
1439 iconndata(i, n) = ival
1445 elseif (ival == 0)
then
1446 call store_error(
'Missing or zero connection reach in line:')
1451 if (ival > this%maxbound)
then
1452 call store_error(
'Reach number exceeds NREACHES in line:')
1457 call sparse%addconnection(n, ival, 1)
1461 write (this%iout,
'(1x,a)') &
1462 'END OF '//trim(adjustl(this%text))//
' CONNECTIONDATA'
1464 do n = 1, this%maxbound
1467 if (nboundchk(n) == 0)
then
1468 write (
errmsg,
'(a,1x,i0)') &
1469 'No connection data specified for reach', n
1471 else if (nboundchk(n) > 1)
then
1472 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1473 'Connection data for reach', n, &
1474 'specified', nboundchk(n),
'times.'
1479 call store_error(
'Required connectiondata block not found.')
1484 call this%parser%StoreErrorUnit()
1488 call sparse%filliaja(this%ia, this%ja, ierr, sort=.true.)
1492 write (
errmsg,
'(a,3(1x,a))') &
1493 'Could not fill', trim(this%packName), &
1494 'package IA and JA connection data.', &
1495 'Check connectivity data in connectiondata block.'
1500 do n = 1, this%maxbound
1501 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1503 do jj = 1, this%nconnreach(n)
1504 jcol2 = iconndata(jj, n)
1505 if (abs(jcol2) == jcol)
then
1518 deallocate (rowmaxnnz)
1519 deallocate (nboundchk)
1520 deallocate (iconndata)
1523 call sparse%destroy()
1529 call sfr_dag%set_vertices(this%maxbound)
1532 fill_dag:
do n = 1, this%maxbound
1536 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1537 if (this%idir(j) > 0)
then
1543 if (nup == 0) cycle fill_dag
1550 do j = this%ia(n) + 1, this%ia(n + 1) - 1
1551 if (this%idir(j) > 0)
then
1552 iup(ipos) = this%ja(j)
1558 call sfr_dag%set_edges(n, iup)
1565 call sfr_dag%toposort(order, istat)
1568 if (istat == -1)
then
1570 trim(adjustl(this%text))//
' PACKAGE ('// &
1571 trim(adjustl(this%packName))//
') cannot calculate a '// &
1572 'Directed Asyclic Graph for reach connectivity because '// &
1573 'of circular dependency. Using the reach number for '// &
1574 'solution ordering.'
1579 do n = 1, this%maxbound
1580 if (istat == 0)
then
1581 this%isfrorder(n) = order(n)
1583 this%isfrorder(n) = n
1588 call sfr_dag%destroy()
1589 if (istat == 0)
then
1592 end subroutine sfr_read_connectiondata
1598 subroutine sfr_read_diversions(this)
1602 class(sfrtype),
intent(inout) :: this
1604 character(len=10) :: cnum
1605 character(len=10) :: cval
1608 integer(I4B) :: ierr
1609 integer(I4B) :: ival
1611 integer(I4B) :: ipos
1612 integer(I4B) :: jpos
1613 integer(I4B) :: ndiv
1614 integer(I4B) :: ndiversions
1615 integer(I4B) :: idivreach
1616 logical(LGP) :: isfound
1617 logical(LGP) :: endOfBlock
1618 integer(I4B) :: idiv
1619 integer,
allocatable,
dimension(:) :: iachk
1620 integer,
allocatable,
dimension(:) :: nboundchk
1626 do n = 1, this%maxbound
1627 ndiversions = ndiversions + this%ndiv(n)
1628 i0 = i0 + this%ndiv(n)
1629 this%iadiv(n + 1) = i0
1633 if (ndiversions > 0)
then
1636 allocate (this%divcprior(ndiversions))
1637 call mem_reallocate(this%divflow, ndiversions,
'DIVFLOW', this%memoryPath)
1638 call mem_reallocate(this%divq, ndiversions,
'DIVQ', this%memoryPath)
1642 do n = 1, ndiversions
1643 this%divflow(n) =
dzero
1644 this%divq(n) =
dzero
1648 call this%parser%GetBlock(
'DIVERSIONS', isfound, ierr, &
1649 supportopenclose=.true., &
1650 blockrequired=.false.)
1654 if (this%idiversions /= 0)
then
1655 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1660 do n = 1, this%maxbound
1661 ndiv = ndiv + this%ndiv(n)
1663 allocate (iachk(this%maxbound + 1))
1664 allocate (nboundchk(ndiv))
1666 do n = 1, this%maxbound
1667 iachk(n + 1) = iachk(n) + this%ndiv(n)
1675 call this%parser%GetNextLine(endofblock)
1676 if (endofblock)
exit
1679 n = this%parser%GetInteger()
1680 if (n < 1 .or. n > this%maxbound)
then
1681 write (cnum,
'(i0)') n
1682 errmsg =
'Reach number should be between 1 and '// &
1689 if (this%ndiv(n) < 1)
then
1690 write (cnum,
'(i0)') n
1691 errmsg =
'Diversions cannot be specified '// &
1692 'for reach '//trim(cnum)
1698 ival = this%parser%GetInteger()
1699 if (ival < 1 .or. ival > this%ndiv(n))
then
1700 write (cnum,
'(i0)') n
1701 errmsg =
'Reach '//trim(cnum)
1702 write (cnum,
'(i0)') this%ndiv(n)
1703 errmsg = trim(
errmsg)//
' diversion number should be between '// &
1704 '1 and '//trim(cnum)//
'.'
1710 ipos = iachk(n) + ival - 1
1711 nboundchk(ipos) = nboundchk(ipos) + 1
1716 ival = this%parser%GetInteger()
1717 if (ival < 1 .or. ival > this%maxbound)
then
1718 write (cnum,
'(i0)') ival
1719 errmsg =
'Diversion target reach number should be '// &
1720 'between 1 and '//trim(cnum)//
'.'
1725 jpos = this%iadiv(n) + idiv - 1
1726 this%divreach(jpos) = idivreach
1729 call this%parser%GetStringCaps(cval)
1741 errmsg =
'Invalid cprior type '//trim(cval)//
'.'
1746 this%divcprior(jpos) = cval
1749 write (this%iout,
'(1x,a)')
'END OF '//trim(adjustl(this%text))// &
1752 do n = 1, this%maxbound
1753 do j = 1, this%ndiv(n)
1754 ipos = iachk(n) + j - 1
1757 if (nboundchk(ipos) == 0)
then
1758 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1759 'No data specified for reach', n,
'diversion', j
1761 else if (nboundchk(ipos) > 1)
then
1762 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
1763 'Data for reach', n,
'diversion', j, &
1764 'specified', nboundchk(ipos),
'times'
1772 deallocate (nboundchk)
1776 write (
errmsg,
'(a,1x,a)') &
1777 'A diversions block should not be', &
1778 'specified if diversions are not specified.'
1782 if (this%idiversions /= 0)
then
1783 call store_error(
'REQUIRED DIVERSIONS BLOCK NOT FOUND.')
1789 call this%parser%StoreErrorUnit()
1791 end subroutine sfr_read_diversions
1797 subroutine sfr_read_initial_stages(this)
1801 class(sfrtype),
intent(inout) :: this
1804 integer(I4B) :: ierr
1805 logical(LGP) :: isfound
1806 logical(LGP) :: endOfBlock
1809 integer,
allocatable,
dimension(:) :: nboundchk
1812 call this%parser%GetBlock(
'INITIALSTAGES', isfound, ierr, &
1813 supportopenclose=.true., &
1814 blockrequired=.false.)
1818 write (this%iout,
'(/1x,a)') &
1819 'PROCESSING '//trim(adjustl(this%text))//
' INITIALSTAGES'
1821 allocate (nboundchk(this%maxbound))
1822 do n = 1, this%maxbound
1827 call this%parser%GetNextLine(endofblock)
1828 if (endofblock)
exit
1831 n = this%parser%GetInteger()
1833 if (n < 1 .or. n > this%maxbound)
then
1834 write (
errmsg,
'(a,i0,a,1x,i0,a)') &
1835 'Reach number (', n,
') must be greater than 0 and less &
1836 &than or equal to', this%maxbound,
'.'
1842 nboundchk(n) = nboundchk(n) + 1
1844 rval = this%parser%GetDouble()
1845 this%stage(n) = rval
1846 this%depth(n) = rval - this%strtop(n)
1848 if (rval < this%strtop(n))
then
1849 write (
errmsg,
'(a,g0,a,1x,i0,1x,a,g0,a)') &
1850 'Initial stage (', rval,
') for reach', n, &
1851 'is less than the reach top (', this%strtop(n),
').'
1856 write (this%iout,
'(1x,a)') &
1857 'END OF '//trim(adjustl(this%text))//
' INITIALSTAGES'
1862 do i = 1, this%maxbound
1863 if (nboundchk(i) == 0)
then
1864 write (
errmsg,
'(a,i0,1x,a)') &
1865 'Information for reach ', i,
'not specified in initialstages block.'
1867 else if (nboundchk(i) > 1)
then
1868 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1869 'Initial stage information specified', &
1870 nboundchk(i),
'times for reach', i
1874 deallocate (nboundchk)
1877 if (this%istorage == 1)
then
1878 do n = 1, this%maxbound
1879 rval = this%strtop(n)
1880 this%stage(n) = rval
1887 call this%parser%StoreErrorUnit()
1889 end subroutine sfr_read_initial_stages
1895 subroutine sfr_rp(this)
1901 class(sfrtype),
intent(inout) :: this
1903 character(len=LINELENGTH) :: title
1904 character(len=LINELENGTH) :: line
1905 character(len=LINELENGTH) :: crossfile
1906 integer(I4B) :: ierr
1908 integer(I4B) :: ichkustrm
1909 integer(I4B) :: ichkcross
1910 integer(I4B) :: ncrossptstot
1911 logical(LGP) :: isfound
1912 logical(LGP) :: endOfBlock
1915 character(len=*),
parameter :: fmtblkerr = &
1916 &
"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
1917 character(len=*),
parameter :: fmtlsp = &
1918 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
1919 character(len=*),
parameter :: fmtnbd = &
1920 "(1X,/1X,'The number of active ',A,'S (',I6, &
1921 &') is greater than maximum (',I6,')')"
1931 this%nbound = this%maxbound
1935 if (this%ionper <
kper)
then
1938 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
1939 supportopenclose=.true., &
1940 blockrequired=.false.)
1944 call this%read_check_ionper()
1950 this%ionper =
nper + 1
1953 call this%parser%GetCurrentLine(line)
1954 write (
errmsg, fmtblkerr) adjustl(trim(line))
1956 call this%parser%StoreErrorUnit()
1962 if (this%ionper ==
kper)
then
1966 call cross_data%initialize(this%ncrossptstot, this%ncrosspts, &
1968 this%station, this%xsheight, &
1972 if (this%iprpak /= 0)
then
1975 title = trim(adjustl(this%text))//
' PACKAGE ('// &
1976 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
1977 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
1978 call table_cr(this%inputtab, this%packName, title)
1979 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
1981 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
1983 call this%inputtab%initialize_column(text, 20, alignment=
tableft)
1985 write (text,
'(a,1x,i6)')
'VALUE', n
1986 call this%inputtab%initialize_column(text, 15, alignment=
tabcenter)
1992 call this%parser%GetNextLine(endofblock)
1993 if (endofblock)
exit
1994 n = this%parser%GetInteger()
1995 if (n < 1 .or. n > this%maxbound)
then
1996 write (
errmsg,
'(a,1x,a,1x,i0,a)') &
1997 'Reach number (RNO) must be greater than 0 and', &
1998 'less than or equal to', this%maxbound,
'.'
2004 call this%sfr_set_stressperiod(n, ichkustrm, crossfile)
2007 if (this%iprpak /= 0)
then
2008 call this%parser%GetCurrentLine(line)
2009 call this%inputtab%line_to_columns(line)
2013 if (trim(adjustl(crossfile)) /=
'NONE')
then
2014 call cross_data%read_table(n, this%width(n), &
2015 trim(adjustl(crossfile)))
2020 if (this%iprpak /= 0)
then
2021 call this%inputtab%finalize_table()
2028 ncrossptstot = cross_data%get_ncrossptstot()
2031 if (ncrossptstot /= this%ncrossptstot)
then
2032 this%ncrossptstot = ncrossptstot
2033 call mem_reallocate(this%station, this%ncrossptstot,
'STATION', &
2035 call mem_reallocate(this%xsheight, this%ncrossptstot,
'XSHEIGHT', &
2037 call mem_reallocate(this%xsrough, this%ncrossptstot,
'XSROUGH', &
2042 call cross_data%output(this%width, this%rough, kstp=1,
kper=
kper)
2045 call cross_data%pack(this%ncrossptstot, this%ncrosspts, &
2052 call cross_data%destroy()
2053 deallocate (cross_data)
2054 nullify (cross_data)
2058 write (this%iout, fmtlsp) trim(this%filtyp)
2062 if (ichkustrm /= 0)
then
2063 call this%sfr_check_ustrf()
2068 call this%parser%StoreErrorUnit()
2070 end subroutine sfr_rp
2077 subroutine sfr_ad(this)
2081 class(sfrtype) :: this
2084 integer(I4B) :: iaux
2087 if (this%istorage == 1)
then
2088 do n = 1, this%maxbound
2089 this%stageold(n) = this%stage(n)
2090 this%usinflowold(n) = this%usinflow(n)
2091 this%dsflowold(n) = this%dsflow(n)
2101 call this%TsManager%ad()
2106 call this%sfr_check_ustrf()
2112 if (this%naux > 0)
then
2113 do n = 1, this%maxbound
2114 do iaux = 1, this%naux
2115 if (this%noupdateauxvar(iaux) /= 0) cycle
2116 this%auxvar(iaux, n) = this%rauxvar(iaux, n)
2122 do n = 1, this%maxbound
2123 this%usflow(n) =
dzero
2124 if (this%iboundpak(n) < 0)
then
2125 this%stage(n) = this%sstage(n)
2130 if (this%imover == 1)
then
2131 call this%pakmvrobj%ad()
2137 call this%obs%obs_ad()
2138 end subroutine sfr_ad
2145 subroutine sfr_cf(this)
2147 class(sfrtype) :: this
2150 integer(I4B) :: igwfnode
2153 if (this%nbound == 0)
return
2156 do n = 1, this%nbound
2157 igwfnode = this%igwftopnode(n)
2158 if (igwfnode > 0)
then
2159 if (this%ibound(igwfnode) == 0)
then
2160 call this%dis%highest_active(igwfnode, this%ibound)
2163 this%igwfnode(n) = igwfnode
2164 this%nodelist(n) = igwfnode
2166 end subroutine sfr_cf
2173 subroutine sfr_fc(this, rhs, ia, idxglo, matrix_sln)
2175 class(sfrtype) :: this
2176 real(DP),
dimension(:),
intent(inout) :: rhs
2177 integer(I4B),
dimension(:),
intent(in) :: ia
2178 integer(I4B),
dimension(:),
intent(in) :: idxglo
2184 integer(I4B) :: ipos
2185 integer(I4B) :: node
2196 sfrpicard:
do i = 1, this%maxsfrpicard
2202 if (this%imover == 1)
then
2203 call this%pakmvrobj%fc()
2207 reachsolve:
do j = 1, this%nbound
2208 n = this%isfrorder(j)
2209 node = this%igwfnode(n)
2211 hgwf = this%xnew(node)
2218 this%stage0(n) = this%stage(n)
2219 this%usflow0(n) = this%usflow(n)
2226 if (this%iboundpak(n) /= 0)
then
2227 call this%sfr_solve(n, hgwf, hhcof, rrhs)
2229 this%depth(n) =
dzero
2230 this%stage(n) = this%strtop(n)
2232 call this%sfr_update_flows(n, v, v)
2238 this%hcof(n) = hhcof
2242 ds = s0 - this%stage(n)
2245 if (abs(ds) > abs(dsmax))
then
2252 if (abs(dsmax) <= this%dmaxchg)
then
2259 do n = 1, this%nbound
2260 node = this%nodelist(n)
2262 rhs(node) = rhs(node) + this%rhs(n)
2264 call matrix_sln%add_value_pos(idxglo(ipos), this%hcof(n))
2266 end subroutine sfr_fc
2273 subroutine sfr_fn(this, rhs, ia, idxglo, matrix_sln)
2275 class(sfrtype) :: this
2276 real(DP),
dimension(:),
intent(inout) :: rhs
2277 integer(I4B),
dimension(:),
intent(in) :: ia
2278 integer(I4B),
dimension(:),
intent(in) :: idxglo
2284 integer(I4B) :: ipos
2294 do j = 1, this%nbound
2295 i = this%isfrorder(j)
2297 if (this%iboundpak(i) < 1) cycle
2299 n = this%nodelist(i)
2302 rterm = this%hcof(i) * this%xnew(n)
2304 hgwf = this%xnew(n) +
dem4
2305 call this%sfr_solve(i, hgwf, hcof1, rhs1, update=.false.)
2306 q1 = rhs1 - hcof1 * hgwf
2308 q2 = this%rhs(i) - this%hcof(i) * this%xnew(n)
2310 drterm = (q2 - q1) /
dem4
2313 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(i))
2314 rhs(n) = rhs(n) - rterm + drterm * this%xnew(n)
2316 end subroutine sfr_fn
2323 subroutine sfr_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
2327 class(sfrtype),
intent(inout) :: this
2328 integer(I4B),
intent(in) :: innertot
2329 integer(I4B),
intent(in) :: kiter
2330 integer(I4B),
intent(in) :: iend
2331 integer(I4B),
intent(in) :: icnvgmod
2332 character(len=LENPAKLOC),
intent(inout) :: cpak
2333 integer(I4B),
intent(inout) :: ipak
2334 real(DP),
intent(inout) :: dpak
2336 character(len=LENPAKLOC) :: cloc
2337 character(len=LINELENGTH) :: tag
2338 integer(I4B) :: icheck
2339 integer(I4B) :: ipakfail
2340 integer(I4B) :: locdhmax
2341 integer(I4B) :: locrmax
2342 integer(I4B) :: locdqfrommvrmax
2343 integer(I4B) :: ntabrows
2344 integer(I4B) :: ntabcols
2348 real(DP) :: qtolfact
2353 real(DP) :: dqfrommvr
2354 real(DP) :: dqfrommvrmax
2357 icheck = this%iconvchk
2365 dqfrommvrmax =
dzero
2369 if (this%ipakcsv == 0)
then
2370 if (icnvgmod == 0)
then
2378 if (.not.
associated(this%pakcsvtab))
then
2383 if (this%imover == 1)
then
2384 ntabcols = ntabcols + 2
2388 call table_cr(this%pakcsvtab, this%packName,
'')
2389 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
2390 lineseparator=.false., separator=
',', &
2394 tag =
'total_inner_iterations'
2395 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2397 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2399 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2401 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2403 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
2405 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2407 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2409 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2410 tag =
'dinflowmax_loc'
2411 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2412 if (this%imover == 1)
then
2413 tag =
'dqfrommvrmax'
2414 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
2415 tag =
'dqfrommvrmax_loc'
2416 call this%pakcsvtab%initialize_column(tag, 16, alignment=
tableft)
2422 if (icheck /= 0)
then
2423 final_check:
do n = 1, this%maxbound
2424 if (this%iboundpak(n) == 0) cycle
2427 qtolfact =
delt / this%calc_surface_area(n)
2430 dh = this%stage0(n) - this%stage(n)
2433 if (this%gwfiss == 0)
then
2434 r = this%usflow0(n) - this%usflow(n)
2442 if (this%imover == 1)
then
2443 q = this%pakmvrobj%get_qfrommvr(n)
2444 q0 = this%pakmvrobj%get_qfrommvr0(n)
2445 dqfrommvr = qtolfact * (q0 - q)
2454 dqfrommvrmax = dqfrommvr
2457 if (abs(dh) > abs(dhmax))
then
2461 if (abs(r) > abs(rmax))
then
2465 if (abs(dqfrommvr) > abs(dqfrommvrmax))
then
2466 dqfrommvrmax = dqfrommvr
2473 if (abs(dhmax) > abs(dpak))
then
2476 write (cloc,
"(a,'-',a)") trim(this%packName),
'stage'
2479 if (abs(rmax) > abs(dpak))
then
2482 write (cloc,
"(a,'-',a)") trim(this%packName),
'inflow'
2485 if (this%imover == 1)
then
2486 if (abs(dqfrommvrmax) > abs(dpak))
then
2487 ipak = locdqfrommvrmax
2489 write (cloc,
"(a,'-',a)") trim(this%packName),
'qfrommvr'
2495 if (this%ipakcsv /= 0)
then
2498 call this%pakcsvtab%add_term(innertot)
2499 call this%pakcsvtab%add_term(
totim)
2500 call this%pakcsvtab%add_term(
kper)
2501 call this%pakcsvtab%add_term(
kstp)
2502 call this%pakcsvtab%add_term(kiter)
2503 call this%pakcsvtab%add_term(dhmax)
2504 call this%pakcsvtab%add_term(locdhmax)
2505 call this%pakcsvtab%add_term(rmax)
2506 call this%pakcsvtab%add_term(locrmax)
2507 if (this%imover == 1)
then
2508 call this%pakcsvtab%add_term(dqfrommvrmax)
2509 call this%pakcsvtab%add_term(locdqfrommvrmax)
2514 call this%pakcsvtab%finalize_table()
2518 end subroutine sfr_cc
2524 subroutine sfr_cq(this, x, flowja, iadv)
2528 class(sfrtype),
intent(inout) :: this
2529 real(DP),
dimension(:),
intent(in) :: x
2530 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2531 integer(I4B),
optional,
intent(in) :: iadv
2538 real(DP) :: qoutflow
2539 real(DP) :: qfrommvr
2544 call this%BndType%bnd_cq(x, flowja, iadv=1)
2547 do n = 1, this%maxbound
2552 if (this%imover == 1)
then
2553 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
2554 qtomvr = this%pakmvrobj%get_qtomvr(n)
2555 if (qtomvr >
dzero)
then
2561 qext = this%dsflow(n)
2563 if (qext >
dzero)
then
2566 do i = this%ia(n) + 1, this%ia(n + 1) - 1
2567 if (this%idir(i) > 0) cycle
2569 if (this%iboundpak(n2) == 0) cycle
2575 if (qext <
dzero)
then
2576 if (qtomvr <
dzero)
then
2577 qext = qext - qtomvr
2580 qoutflow = this%dsflow(n)
2581 if (qoutflow >
dzero)
then
2582 qoutflow = -qoutflow
2588 this%qextoutflow(n) = qext
2589 this%qoutflow(n) = qoutflow
2594 call this%sfr_fill_budobj()
2595 end subroutine sfr_cq
2601 subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
2605 class(sfrtype) :: this
2606 integer(I4B),
intent(in) :: icbcfl
2607 integer(I4B),
intent(in) :: ibudfl
2609 integer(I4B) :: ibinun
2610 character(len=20),
dimension(:),
allocatable :: cellidstr
2612 integer(I4B) :: node
2616 if (this%ibudgetout /= 0)
then
2617 ibinun = this%ibudgetout
2619 if (icbcfl == 0) ibinun = 0
2620 if (ibinun > 0)
then
2621 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
2626 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
2632 if (this%ianynone > 0)
then
2633 allocate (cellidstr(this%maxbound))
2634 do n = 1, this%maxbound
2635 node = this%igwfnode(n)
2637 call this%dis%noder_to_string(node, cellidstr(n))
2639 cellidstr(n) =
'NONE'
2642 call this%budobj%write_flowtable(this%dis,
kstp,
kper, cellidstr)
2643 deallocate (cellidstr)
2645 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
2648 end subroutine sfr_ot_package_flows
2654 subroutine sfr_ot_dv(this, idvsave, idvprint)
2659 class(sfrtype) :: this
2660 integer(I4B),
intent(in) :: idvsave
2661 integer(I4B),
intent(in) :: idvprint
2663 character(len=20) :: cellid
2664 integer(I4B) :: ibinun
2666 integer(I4B) :: node
2679 if (this%istageout /= 0)
then
2680 ibinun = this%istageout
2682 if (idvsave == 0) ibinun = 0
2685 if (ibinun > 0)
then
2686 do n = 1, this%maxbound
2689 if (this%iboundpak(n) == 0)
then
2691 else if (d ==
dzero)
then
2697 this%maxbound, 1, 1, ibinun)
2701 if (idvprint /= 0 .and. this%iprhed /= 0)
then
2704 call this%stagetab%set_kstpkper(
kstp,
kper)
2707 do n = 1, this%maxbound
2708 node = this%igwfnode(n)
2710 call this%dis%noder_to_string(node, cellid)
2711 hgwf = this%xnew(node)
2715 if (this%inamedbound == 1)
then
2716 call this%stagetab%add_term(this%boundname(n))
2718 call this%stagetab%add_term(n)
2719 call this%stagetab%add_term(cellid)
2720 if (this%iboundpak(n) /= 0)
then
2721 depth = this%depth(n)
2722 stage = this%stage(n)
2723 w = this%calc_top_width_wet(n, depth)
2724 call this%sfr_calc_cond(n, depth, cond, stage, hgwf)
2731 if (depth ==
dzero)
then
2732 call this%stagetab%add_term(
dhdry)
2734 call this%stagetab%add_term(stage)
2736 call this%stagetab%add_term(depth)
2737 call this%stagetab%add_term(w)
2739 if (this%iboundpak(n) /= 0)
then
2740 sbot = this%strtop(n) - this%bthick(n)
2741 if (hgwf < sbot)
then
2746 grad = grad / this%bthick(n)
2750 call this%stagetab%add_term(hgwf)
2751 call this%stagetab%add_term(cond)
2752 call this%stagetab%add_term(grad)
2754 call this%stagetab%add_term(
'--')
2755 call this%stagetab%add_term(
'--')
2756 call this%stagetab%add_term(
'--')
2760 end subroutine sfr_ot_dv
2766 subroutine sfr_ot_bdsummary(this, kstp, kper, iout, ibudfl)
2770 class(sfrtype) :: this
2771 integer(I4B),
intent(in) :: kstp
2772 integer(I4B),
intent(in) :: kper
2773 integer(I4B),
intent(in) :: iout
2774 integer(I4B),
intent(in) :: ibudfl
2776 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
2777 end subroutine sfr_ot_bdsummary
2783 subroutine sfr_da(this)
2787 class(sfrtype) :: this
2792 deallocate (this%csfrbudget)
2795 deallocate (this%cauxcbc)
2822 if (this%istorage == 1)
then
2852 if (
associated(this%divcprior))
then
2853 deallocate (this%divcprior)
2867 call this%budobj%budgetobject_da()
2868 deallocate (this%budobj)
2869 nullify (this%budobj)
2872 if (this%iprhed > 0)
then
2873 call this%stagetab%table_da()
2874 deallocate (this%stagetab)
2875 nullify (this%stagetab)
2879 if (this%ipakcsv > 0)
then
2880 if (
associated(this%pakcsvtab))
then
2881 call this%pakcsvtab%table_da()
2882 deallocate (this%pakcsvtab)
2883 nullify (this%pakcsvtab)
2911 nullify (this%gwfiss)
2914 call this%BndType%bnd_da()
2915 end subroutine sfr_da
2922 subroutine define_listlabel(this)
2924 class(sfrtype),
intent(inout) :: this
2927 this%listlabel = trim(this%filtyp)//
' NO.'
2928 if (this%dis%ndim == 3)
then
2929 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
2930 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
2931 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
2932 elseif (this%dis%ndim == 2)
then
2933 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
2934 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
2936 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
2938 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
2939 if (this%inamedbound == 1)
then
2940 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
2942 end subroutine define_listlabel
2954 logical function sfr_obs_supported(this)
2956 class(sfrtype) :: this
2959 sfr_obs_supported = .true.
2960 end function sfr_obs_supported
2966 subroutine sfr_df_obs(this)
2968 class(sfrtype) :: this
2970 integer(I4B) :: indx
2974 call this%obs%StoreObsType(
'stage', .false., indx)
2975 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
2979 call this%obs%StoreObsType(
'inflow', .true., indx)
2980 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
2984 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
2985 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
2989 call this%obs%StoreObsType(
'rainfall', .true., indx)
2990 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
2994 call this%obs%StoreObsType(
'runoff', .true., indx)
2995 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
2999 call this%obs%StoreObsType(
'evaporation', .true., indx)
3000 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3004 call this%obs%StoreObsType(
'outflow', .true., indx)
3005 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3009 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
3010 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3014 call this%obs%StoreObsType(
'to-mvr', .true., indx)
3015 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3019 call this%obs%StoreObsType(
'from-mvr', .true., indx)
3020 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3024 call this%obs%StoreObsType(
'sfr', .true., indx)
3025 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3029 call this%obs%StoreObsType(
'upstream-flow', .true., indx)
3030 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3034 call this%obs%StoreObsType(
'downstream-flow', .true., indx)
3035 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3039 call this%obs%StoreObsType(
'depth', .false., indx)
3040 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3044 call this%obs%StoreObsType(
'wet-perimeter', .false., indx)
3045 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3049 call this%obs%StoreObsType(
'wet-area', .false., indx)
3050 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3054 call this%obs%StoreObsType(
'wet-width', .false., indx)
3055 this%obs%obsData(indx)%ProcessIdPtr => sfr_process_obsid
3056 end subroutine sfr_df_obs
3062 subroutine sfr_bd_obs(this)
3064 class(sfrtype) :: this
3070 character(len=100) :: msg
3074 if (this%obs%npakobs > 0)
then
3075 call this%obs%obs_bd_clear()
3076 do i = 1, this%obs%npakobs
3077 obsrv => this%obs%pakobs(i)%obsrv
3078 do j = 1, obsrv%indxbnds_count
3079 n = obsrv%indxbnds(j)
3081 select case (obsrv%ObsTypeId)
3086 if (this%imover == 1)
then
3087 v = this%pakmvrobj%get_qtomvr(n)
3094 if (this%imover == 1)
then
3095 v = this%pakmvrobj%get_qfrommvr(n)
3102 v = this%qoutflow(n)
3103 case (
'EXT-OUTFLOW')
3104 v = this%qextoutflow(n)
3106 if (this%iboundpak(n) /= 0)
then
3112 v = this%simrunoff(n)
3113 case (
'EVAPORATION')
3117 case (
'UPSTREAM-FLOW')
3119 if (this%imover == 1)
then
3120 v = v + this%pakmvrobj%get_qfrommvr(n)
3122 case (
'DOWNSTREAM-FLOW')
3129 case (
'WET-PERIMETER')
3130 v = this%calc_perimeter_wet(n, this%depth(n))
3132 v = this%calc_area_wet(n, this%depth(n))
3134 v = this%calc_top_width_wet(n, this%depth(n))
3136 msg =
'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
3139 call this%obs%SaveOneSimval(obsrv, v)
3145 call this%parser%StoreErrorUnit()
3148 end subroutine sfr_bd_obs
3154 subroutine sfr_rp_obs(this)
3158 class(sfrtype),
intent(inout) :: this
3163 character(len=LENBOUNDNAME) :: bname
3164 logical(LGP) :: jfound
3167 10
format(
'Boundary "', a,
'" for observation "', a, &
3168 '" is invalid in package "', a,
'"')
3169 30
format(
'Boundary name not provided for observation "', a, &
3170 '" in package "', a,
'"')
3176 do i = 1, this%obs%npakobs
3177 obsrv => this%obs%pakobs(i)%obsrv
3180 nn1 = obsrv%NodeNumber
3182 bname = obsrv%FeatureName
3183 if (bname /=
'')
then
3188 do j = 1, this%maxbound
3189 if (this%boundname(j) == bname)
then
3191 call obsrv%AddObsIndex(j)
3194 if (.not. jfound)
then
3196 trim(bname), trim(obsrv%name), trim(this%packName)
3200 write (
errmsg, 30) trim(obsrv%name), trim(this%packName)
3203 else if (nn1 < 1 .or. nn1 > this%maxbound)
then
3204 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3205 trim(adjustl(obsrv%ObsTypeId)), &
3206 'reach must be greater than 0 and less than or equal to', &
3207 this%maxbound,
'(specified value is ', nn1,
')'
3210 if (obsrv%indxbnds_count == 0)
then
3211 call obsrv%AddObsIndex(nn1)
3213 errmsg =
'Programming error in sfr_rp_obs'
3220 if (obsrv%ObsTypeId ==
'STAGE' .or. &
3221 obsrv%ObsTypeId ==
'DEPTH' .or. &
3222 obsrv%ObsTypeId ==
'WET-PERIMETER' .or. &
3223 obsrv%ObsTypeId ==
'WET-AREA' .or. &
3224 obsrv%ObsTypeId ==
'WET-WIDTH')
then
3225 nn1 = obsrv%NodeNumber
3227 if (obsrv%indxbnds_count > 1)
then
3228 write (
errmsg,
'(a,3(1x,a))') &
3229 trim(adjustl(obsrv%ObsTypeId)), &
3230 'for observation', trim(adjustl(obsrv%Name)), &
3231 ' must be assigned to a reach with a unique boundname.'
3238 do j = 1, obsrv%indxbnds_count
3239 nn1 = obsrv%indxbnds(j)
3240 if (nn1 < 1 .or. nn1 > this%maxbound)
then
3241 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
3242 trim(adjustl(obsrv%ObsTypeId)), &
3243 'reach must be greater than 0 and less than or equal to', &
3244 this%maxbound,
'(specified value is ', nn1,
')'
3252 call this%parser%StoreErrorUnit()
3255 end subroutine sfr_rp_obs
3264 subroutine sfr_process_obsid(obsrv, dis, inunitobs, iout)
3268 integer(I4B),
intent(in) :: inunitobs
3269 integer(I4B),
intent(in) :: iout
3272 integer(I4B) :: icol
3273 integer(I4B) :: istart
3274 integer(I4B) :: istop
3275 character(len=LINELENGTH) :: string
3276 character(len=LENBOUNDNAME) :: bndname
3279 string = obsrv%IDstring
3289 obsrv%FeatureName = bndname
3293 obsrv%NodeNumber = nn1
3294 end subroutine sfr_process_obsid
3304 subroutine sfr_set_stressperiod(this, n, ichkustrm, crossfile)
3308 class(sfrtype),
intent(inout) :: this
3309 integer(I4B),
intent(in) :: n
3310 integer(I4B),
intent(inout) :: ichkustrm
3311 character(len=LINELENGTH),
intent(inout) :: crossfile
3313 character(len=10) :: cnum
3314 character(len=LINELENGTH) :: text
3315 character(len=LINELENGTH) :: caux
3316 character(len=LINELENGTH) :: keyword
3317 integer(I4B) :: ival
3320 integer(I4B) :: idiv
3321 integer(I4B) :: ixserror
3322 character(len=10) :: cp
3324 real(DP),
pointer :: bndElem => null()
3330 call this%parser%GetStringCaps(keyword)
3331 select case (keyword)
3334 call this%parser%GetStringCaps(text)
3335 if (text ==
'INACTIVE')
then
3336 this%iboundpak(n) = 0
3337 else if (text ==
'ACTIVE')
then
3338 this%iboundpak(n) = 1
3339 else if (text ==
'SIMPLE')
then
3340 this%iboundpak(n) = -1
3343 'Unknown '//trim(this%text)//
' sfr status keyword: ', trim(text)
3347 call this%parser%GetString(text)
3349 bndelem => this%hk(n)
3351 this%packName,
'BND', &
3352 this%tsManager, this%iprpak, &
3355 call this%parser%GetString(text)
3357 bndelem => this%rough(n)
3359 this%packName,
'BND', &
3360 this%tsManager, this%iprpak, &
3363 call this%parser%GetString(text)
3365 bndelem => this%sstage(n)
3367 this%packName,
'BND', &
3368 this%tsManager, this%iprpak,
'STAGE')
3370 call this%parser%GetString(text)
3372 bndelem => this%rain(n)
3374 this%packName,
'BND', &
3375 this%tsManager, this%iprpak,
'RAIN')
3376 case (
'EVAPORATION')
3377 call this%parser%GetString(text)
3379 bndelem => this%evap(n)
3381 this%packName,
'BND', &
3382 this%tsManager, this%iprpak, &
3385 call this%parser%GetString(text)
3387 bndelem => this%runoff(n)
3389 this%packName,
'BND', &
3390 this%tsManager, this%iprpak, &
3393 call this%parser%GetString(text)
3395 bndelem => this%inflow(n)
3397 this%packName,
'BND', &
3398 this%tsManager, this%iprpak, &
3403 if (this%ndiv(n) < 1)
then
3404 write (cnum,
'(i0)') n
3405 errmsg =
'diversions cannot be specified for reach '//trim(cnum)
3410 ival = this%parser%GetInteger()
3411 if (ival < 1 .or. ival > this%ndiv(n))
then
3412 write (cnum,
'(i0)') n
3413 errmsg =
'Reach '//trim(cnum)
3414 write (cnum,
'(i0)') this%ndiv(n)
3415 errmsg = trim(
errmsg)//
' diversion number should be between 1 '// &
3416 'and '//trim(cnum)//
'.'
3422 call this%parser%GetString(text)
3423 ii = this%iadiv(n) + idiv - 1
3425 bndelem => this%divflow(ii)
3427 this%packName,
'BND', &
3428 this%tsManager, this%iprpak, &
3432 cp = this%divcprior(ii)
3433 divq = this%divflow(ii)
3434 if (cp ==
'FRACTION' .and. (divq <
dzero .or. divq >
done))
then
3435 write (
errmsg,
'(a,1x,i0,a)') &
3436 'cprior is type FRACTION for diversion no.', ii, &
3437 ', but divflow not within the range 0.0 to 1.0'
3440 case (
'UPSTREAM_FRACTION')
3442 call this%parser%GetString(text)
3444 bndelem => this%ustrf(n)
3446 this%packName,
'BND', &
3447 this%tsManager, this%iprpak,
'USTRF')
3449 case (
'CROSS_SECTION')
3453 call this%parser%GetStringCaps(keyword)
3454 select case (keyword)
3456 call this%parser%GetStringCaps(keyword)
3457 if (trim(adjustl(keyword)) /=
'FILEIN')
then
3458 errmsg =
'TAB6 keyword must be followed by "FILEIN" '// &
3463 if (ixserror == 0)
then
3464 call this%parser%GetString(crossfile)
3467 write (
errmsg,
'(a,1x,i4,1x,a)') &
3468 'CROSS-SECTION TABLE ENTRY for REACH ', n, &
3469 'MUST INCLUDE TAB6 KEYWORD'
3474 call this%parser%GetStringCaps(caux)
3475 do jj = 1, this%naux
3476 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
3477 call this%parser%GetString(text)
3479 bndelem => this%rauxvar(jj, ii)
3481 this%packName,
'AUX', &
3482 this%tsManager, this%iprpak, &
3488 write (
errmsg,
'(a,a)') &
3489 'Unknown '//trim(this%text)//
' sfr data keyword: ', &
3493 end subroutine sfr_set_stressperiod
3499 subroutine sfr_solve(this, n, h, hcof, rhs, update)
3501 class(sfrtype) :: this
3502 integer(I4B),
intent(in) :: n
3503 real(DP),
intent(in) :: h
3504 real(DP),
intent(inout) :: hcof
3505 real(DP),
intent(inout) :: rhs
3506 logical(LGP),
intent(in),
optional :: update
3508 logical(LGP) :: lupdate
3521 real(DP) :: qfrommvr
3534 if (
present(update))
then
3544 if (this%iboundpak(n) == 0)
then
3545 this%depth(n) =
dzero
3547 this%usflow(n) =
dzero
3548 this%simevap(n) =
dzero
3549 this%simrunoff(n) =
dzero
3550 this%dsflow(n) =
dzero
3551 this%gwflow(n) =
dzero
3563 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3564 if (this%idir(i) < 0) cycle
3566 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
3567 if (this%idir(ii) > 0) cycle
3568 if (this%ja(ii) /= n) cycle
3569 qu = qu + this%qconn(ii)
3575 sa = this%calc_surface_area(n)
3576 sa_wet = this%calc_surface_area_wet(n, this%depth(n))
3578 qr = this%rain(n) * sa
3579 qe = this%evap(n) * sa_wet
3580 qro = this%runoff(n)
3584 if (this%imover == 1)
then
3585 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3589 qsrc = qu + qi + qr - qe + qro + qfrommvr
3592 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3595 this%simevap(n) = qe
3596 this%simrunoff(n) = qro
3599 if (this%iboundpak(n) < 0)
then
3600 call this%sfr_calc_constant(n, d1, hgwf, qgwf, qd)
3602 if (this%gwfiss == 0 .and. this%istorage == 1)
then
3603 call this%sfr_calc_transient(n, d1, hgwf, qu, qi, &
3604 qfrommvr, qr, qe, qro, &
3607 call this%sfr_calc_steady(n, d1, hgwf, qu, qi, &
3608 qfrommvr, qr, qe, qro, &
3615 bt = tp - this%bthick(n)
3622 this%stage(n) = hsfr
3624 call this%sfr_update_flows(n, qd, qgwf)
3630 if (this%gwfiss == 0)
then
3641 call this%sfr_calc_qgwf(n, d1, hgwf, qgwf, gwfhcof, gwfrhs)
3644 if (abs(sumleak) >
dzero)
then
3649 else if ((sumleak - qsrc) < -
dem30)
then
3650 if (this%gwfiss == 0)
then
3651 rhs = rhs + gwfrhs - sumrch
3658 if (this%gwfiss == 0)
then
3659 rhs = rhs - sumleak - sumrch
3666 else if (hgwf < bt)
then
3670 end subroutine sfr_solve
3677 subroutine sfr_update_flows(this, n, qd, qgwf)
3679 class(sfrtype),
intent(inout) :: this
3680 integer(I4B),
intent(in) :: n
3681 real(DP),
intent(inout) :: qd
3682 real(DP),
intent(in) :: qgwf
3686 integer(I4B) :: idiv
3687 integer(I4B) :: jpos
3697 this%gwflow(n) = qgwf
3700 if (qd >
dzero)
then
3703 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3704 if (this%idir(i) > 0) cycle
3706 if (idiv == 0) cycle
3707 jpos = this%iadiv(n) + idiv - 1
3708 call this%sfr_calc_div(n, idiv, qd, qdiv)
3709 this%qconn(i) = qdiv
3710 this%divq(jpos) = qdiv
3716 if (this%imover == 1)
then
3717 call this%pakmvrobj%accumulate_qformvr(n, qd)
3718 qd = max(qd - this%pakmvrobj%get_qtomvr(n),
dzero)
3722 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3723 if (this%idir(i) > 0) cycle
3724 if (this%idiv(i) > 0) cycle
3726 if (this%iboundpak(n2) == 0) cycle
3727 f = this%ustrf(n2) / this%ftotnd(n)
3728 this%qconn(i) = qd * f
3731 do i = this%ia(n) + 1, this%ia(n + 1) - 1
3732 if (this%idir(i) > 0) cycle
3733 this%qconn(i) =
dzero
3735 if (idiv == 0) cycle
3736 jpos = this%iadiv(n) + idiv - 1
3737 this%divq(jpos) =
dzero
3740 end subroutine sfr_update_flows
3747 subroutine sfr_adjust_ro_ev(this, qc, qu, qi, qr, qro, qe, qfrommvr)
3749 class(sfrtype) :: this
3750 real(DP),
intent(inout) :: qc
3751 real(DP),
intent(in) :: qu
3752 real(DP),
intent(in) :: qi
3753 real(DP),
intent(in) :: qr
3754 real(DP),
intent(inout) :: qro
3755 real(DP),
intent(inout) :: qe
3756 real(DP),
intent(in) :: qfrommvr
3761 if (qc <
dzero)
then
3764 qt = qu + qi + qr + qro + qfrommvr
3767 if (qt <
dzero)
then
3768 if (qro <
dzero)
then
3769 qro = -(qu + qi + qr + qfrommvr)
3775 if (qe >
dzero)
then
3776 qe = qu + qi + qr + qro + qfrommvr
3779 qc = qu + qi + qr - qe + qro + qfrommvr
3781 end subroutine sfr_adjust_ro_ev
3787 subroutine sfr_calc_qd(this, n, depth, hgwf, qgwf, qd)
3789 class(sfrtype) :: this
3790 integer(I4B),
intent(in) :: n
3791 real(DP),
intent(in) :: depth
3792 real(DP),
intent(in) :: hgwf
3793 real(DP),
intent(inout) :: qgwf
3794 real(DP),
intent(inout) :: qd
3802 call this%sfr_calc_qsource(n, depth, qsrc)
3805 call this%sfr_calc_qgwf(n, depth, hgwf, qgwf)
3806 if (-qgwf > qsrc) qgwf = -qsrc
3813 end subroutine sfr_calc_qd
3820 subroutine sfr_calc_qsource(this, n, depth, qsrc)
3822 class(sfrtype) :: this
3823 integer(I4B),
intent(in) :: n
3824 real(DP),
intent(in) :: depth
3825 real(DP),
intent(inout) :: qsrc
3832 real(DP) :: qfrommvr
3842 qro = this%runoff(n)
3845 a = this%calc_surface_area(n)
3846 ae = this%calc_surface_area_wet(n, depth)
3847 qr = this%rain(n) * a
3848 qe = this%evap(n) * ae
3852 if (this%imover == 1)
then
3853 qfrommvr = this%pakmvrobj%get_qfrommvr(n)
3857 qsrc = qu + qi + qr - qe + qro + qfrommvr
3860 call this%sfr_adjust_ro_ev(qsrc, qu, qi, qr, qro, qe, qfrommvr)
3861 end subroutine sfr_calc_qsource
3868 subroutine sfr_calc_qman(this, n, depth, qman)
3870 class(sfrtype) :: this
3871 integer(I4B),
intent(in) :: n
3872 real(DP),
intent(in) :: depth
3873 real(DP),
intent(inout) :: qman
3875 integer(I4B) :: npts
3890 if (depth >
dzero)
then
3891 npts = this%ncrosspts(n)
3902 i0 = this%iacross(n)
3903 i1 = this%iacross(n + 1) - 1
3908 this%station(i0:i1), &
3909 this%xsheight(i0:i1), &
3910 this%xsrough(i0:i1), &
3917 aw = this%calc_area_wet(n, depth)
3918 wp = this%calc_perimeter_wet(n, depth)
3919 if (wp >
dzero)
then
3924 qman = this%unitconv * aw * (rh**
dtwothirds) * sqrt(s) / r
3930 end subroutine sfr_calc_qman
3938 subroutine sfr_calc_qgwf(this, n, depth, hgwf, qgwf, gwfhcof, gwfrhs)
3940 class(sfrtype) :: this
3941 integer(I4B),
intent(in) :: n
3942 real(DP),
intent(in) :: depth
3943 real(DP),
intent(in) :: hgwf
3944 real(DP),
intent(inout) :: qgwf
3945 real(DP),
intent(inout),
optional :: gwfhcof
3946 real(DP),
intent(inout),
optional :: gwfrhs
3948 integer(I4B) :: node
3956 real(DP) :: gwfhcof0
3963 node = this%igwfnode(n)
3964 if (node < 1)
return
3967 if (this%ibound(node) == 0)
return
3974 bt = tp - this%bthick(n)
3977 if (h_temp < bt)
then
3982 call this%sfr_calc_cond(n, depth, cond, hsfr, h_temp)
3985 qgwf = sat * cond * (h_temp - hsfr)
3986 gwfrhs0 = -sat * cond * hsfr
3987 gwfhcof0 = -sat * cond
3990 if (this%idense /= 0)
then
3991 call this%sfr_calculate_density_exchange(n, hsfr, hgwf, cond, tp, &
3992 qgwf, gwfhcof0, gwfrhs0)
3996 if (
present(gwfhcof)) gwfhcof = gwfhcof0
3997 if (
present(gwfrhs)) gwfrhs = gwfrhs0
3998 end subroutine sfr_calc_qgwf
4005 function sfr_gwf_conn(this, n)
4007 integer(I4B) :: sfr_gwf_conn
4009 class(sfrtype) :: this
4010 integer(I4B),
intent(in) :: n
4012 integer(I4B) :: node
4015 node = this%igwfnode(n)
4016 if (node > 0 .and. this%hk(n) >
dzero)
then
4019 end function sfr_gwf_conn
4025 subroutine sfr_calc_cond(this, n, depth, cond, hsfr, h_temp)
4027 class(sfrtype) :: this
4028 integer(I4B),
intent(in) :: n
4029 real(DP),
intent(in) :: depth
4030 real(DP),
intent(inout) :: cond
4031 real(DP),
intent(in),
optional :: hsfr
4032 real(DP),
intent(in),
optional :: h_temp
4034 integer(I4B) :: node
4036 real(DP) :: vscratio
4046 node = this%igwfnode(n)
4048 if (this%ibound(node) > 0)
then
4051 if (this%ivsc == 1)
then
4052 if (hsfr > h_temp)
then
4054 vscratio = this%viscratios(1, n)
4056 vscratio = this%viscratios(2, n)
4059 wp = this%calc_perimeter_wet(n, depth)
4060 cond = this%hk(n) * vscratio * this%length(n) * wp / this%bthick(n)
4063 end subroutine sfr_calc_cond
4072 subroutine sfr_calc_div(this, n, i, qd, qdiv)
4074 class(sfrtype) :: this
4075 integer(I4B),
intent(in) :: n
4076 integer(I4B),
intent(in) :: i
4077 real(DP),
intent(inout) :: qd
4078 real(DP),
intent(inout) :: qdiv
4080 character(len=10) :: cp
4081 integer(I4B) :: jpos
4086 jpos = this%iadiv(n) + i - 1
4087 n2 = this%divreach(jpos)
4088 cp = this%divcprior(jpos)
4089 v = this%divflow(jpos)
4120 end subroutine sfr_calc_div
4126 subroutine sfr_calc_reach_depth(this, n, q1, d1)
4128 class(sfrtype) :: this
4129 integer(I4B),
intent(in) :: n
4130 real(DP),
intent(in) :: q1
4131 real(DP),
intent(inout) :: d1
4143 if (q1 >
dzero)
then
4144 if (this%ncrosspts(n) > 1)
then
4145 call this%sfr_calc_xs_depth(n, q1, d1)
4147 w = this%station(this%iacross(n))
4148 qconst = this%unitconv * w * sqrt(s) / r
4149 d1 = (q1 / qconst)**
dp6
4154 end subroutine sfr_calc_reach_depth
4161 subroutine sfr_calc_xs_depth(this, n, qrch, d)
4163 class(sfrtype) :: this
4164 integer(I4B),
intent(in) :: n
4165 real(DP),
intent(in) :: qrch
4166 real(DP),
intent(inout) :: d
4168 integer(I4B) :: iter
4169 real(DP) :: perturbation
4175 real(DP) :: residual
4178 perturbation = this%deps *
dtwo
4181 residual = q0 - qrch
4184 nriter:
do iter = 1, this%maxsfrit
4185 call this%sfr_calc_qman(n, d + perturbation, q1)
4187 if (dq /=
dzero)
then
4188 derv = perturbation / (q1 - q0)
4192 dd = derv * residual
4194 call this%sfr_calc_qman(n, d, q0)
4195 residual = q0 - qrch
4198 if (abs(dd) < this%dmaxchg)
then
4202 end subroutine sfr_calc_xs_depth
4209 subroutine sfr_check_conversion(this)
4211 class(sfrtype) :: this
4214 character(len=*),
parameter :: fmtunitconv_error = &
4215 &
"('SFR (',a,') UNIT_CONVERSION SPECIFIED VALUE (',g0,') AND', &
4216 &1x,'LENGTH_CONVERSION OR TIME_CONVERSION SPECIFIED.')"
4217 character(len=*),
parameter :: fmtunitconv = &
4218 &
"(1x,'SFR PACKAGE (',a,') CONVERSION DATA',&
4219 &/4x,'UNIT CONVERSION VALUE (',g0,').',/)"
4222 if (this%lengthconv /=
dnodata .or. this%timeconv /=
dnodata)
then
4223 if (this%unitconv /=
done)
then
4224 write (
errmsg, fmtunitconv_error) &
4225 trim(adjustl(this%packName)), this%unitconv
4228 if (this%lengthconv /=
dnodata)
then
4229 this%unitconv = this%unitconv * this%lengthconv**
donethird
4231 if (this%timeconv /=
dnodata)
then
4232 this%unitconv = this%unitconv * this%timeconv
4234 write (this%iout, fmtunitconv) &
4235 trim(adjustl(this%packName)), this%unitconv
4238 end subroutine sfr_check_conversion
4246 subroutine sfr_check_storage_weight(this)
4248 class(sfrtype) :: this
4250 character(len=*),
parameter :: fmtweight = &
4251 &
"(1x,'SFR PACKAGE (',a,') SETTING DEFAULT',&
4252 &/4x,'STORAGE_WEIGHT VALUE (',g0,').',/)"
4255 if (this%istorage == 1)
then
4256 if (this%storage_weight ==
dnodata)
then
4257 this%storage_weight =
done
4258 write (this%iout, fmtweight) &
4259 trim(adjustl(this%packName)), this%storage_weight
4262 end subroutine sfr_check_storage_weight
4270 subroutine sfr_check_reaches(this)
4272 class(sfrtype) :: this
4274 character(len=5) :: crch
4275 character(len=10) :: cval
4276 character(len=30) :: nodestr
4277 character(len=LINELENGTH) :: title
4278 character(len=LINELENGTH) :: text
4285 if (this%iprpak /= 0)
then
4286 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4287 trim(adjustl(this%packName))//
') STATIC REACH DATA'
4288 call table_cr(this%inputtab, this%packName, title)
4289 call this%inputtab%table_df(this%maxbound, 10, this%iout)
4291 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4293 call this%inputtab%initialize_column(text, 20, alignment=
tableft)
4295 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4297 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4299 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4301 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4303 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4305 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4307 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4308 text =
'UPSTREAM FRACTION'
4309 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4313 do n = 1, this%maxbound
4314 write (crch,
'(i5)') n
4315 nn = this%igwfnode(n)
4317 btgwf = this%dis%bot(nn)
4318 call this%dis%noder_to_string(nn, nodestr)
4323 if (this%length(n) <=
dzero)
then
4324 errmsg =
'Reach '//crch//
' length must be greater than 0.0.'
4328 if (this%width(n) <=
dzero)
then
4329 errmsg =
'Reach '//crch//
' width must be greater than 0.0.'
4333 if (this%slope(n) <=
dzero)
then
4334 errmsg =
'Reach '//crch//
' slope must be greater than 0.0.'
4339 bt = this%strtop(n) - this%bthick(n)
4340 if (bt <= btgwf .and. this%icheck /= 0)
then
4341 write (cval,
'(f10.4)') bt
4342 errmsg =
'Reach '//crch//
' bed bottom (rtp-rbth ='// &
4343 cval//
') must be greater than the bottom of cell ('// &
4345 write (cval,
'(f10.4)') btgwf
4349 if (this%hk(n) <
dzero)
then
4350 errmsg =
'Reach '//crch//
' hk must be greater than or equal to 0.0.'
4355 if (this%rough(n) <=
dzero)
then
4356 errmsg =
'Reach '//crch//
" Manning's roughness "// &
4357 'coefficient must be greater than 0.0.'
4361 if (this%ustrf(n) <
dzero)
then
4362 errmsg =
'Reach '//crch//
' upstream fraction must be greater '// &
4363 'than or equal to 0.0.'
4367 if (this%iprpak /= 0)
then
4368 call this%inputtab%add_term(n)
4369 call this%inputtab%add_term(nodestr)
4370 call this%inputtab%add_term(this%length(n))
4371 call this%inputtab%add_term(this%width(n))
4372 call this%inputtab%add_term(this%slope(n))
4373 call this%inputtab%add_term(this%strtop(n))
4374 call this%inputtab%add_term(this%bthick(n))
4375 call this%inputtab%add_term(this%hk(n))
4376 call this%inputtab%add_term(this%rough(n))
4377 call this%inputtab%add_term(this%ustrf(n))
4380 end subroutine sfr_check_reaches
4388 subroutine sfr_check_connections(this)
4390 class(sfrtype) :: this
4392 logical(LGP) :: lreorder
4393 character(len=5) :: crch
4394 character(len=5) :: crch2
4395 character(len=LINELENGTH) :: text
4396 character(len=LINELENGTH) :: title
4403 integer(I4B) :: ifound
4404 integer(I4B) :: ierr
4405 integer(I4B) :: maxconn
4406 integer(I4B) :: ntabcol
4410 do j = 1, this%MAXBOUND
4411 n = this%isfrorder(j)
4420 write (this%iout,
'(/,1x,a)') &
4421 trim(adjustl(this%text))//
' PACKAGE ('// &
4422 trim(adjustl(this%packName))//
') REACH SOLUTION HAS BEEN '// &
4423 'REORDERED USING A DAG'
4426 if (this%iprpak /= 0)
then
4430 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4431 trim(adjustl(this%packName))//
') REACH SOLUTION ORDER'
4432 call table_cr(this%inputtab, this%packName, title)
4433 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4435 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4437 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4440 do j = 1, this%maxbound
4441 n = this%isfrorder(j)
4442 call this%inputtab%add_term(j)
4443 call this%inputtab%add_term(n)
4449 if (this%iprpak /= 0)
then
4453 do n = 1, this%maxbound
4454 maxconn = max(maxconn, this%nconnreach(n))
4456 ntabcol = 1 + maxconn
4459 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4460 trim(adjustl(this%packName))//
') STATIC REACH CONNECTION DATA'
4461 call table_cr(this%inputtab, this%packName, title)
4462 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4464 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4466 write (text,
'(a,1x,i6)')
'CONN', n
4467 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4473 do n = 1, this%MAXBOUND
4474 write (crch,
'(i5)') n
4475 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4477 write (crch2,
'(i5)') nn
4479 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4486 if (ifound /= 1)
then
4487 errmsg =
'Reach '//crch//
' is connected to '// &
4488 'reach '//crch2//
' but reach '//crch2// &
4489 ' is not connected to reach '//crch//
'.'
4495 if (this%iprpak /= 0)
then
4496 call this%inputtab%add_term(n)
4497 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4498 call this%inputtab%add_term(this%ja(i))
4500 nn = maxconn - this%nconnreach(n)
4502 call this%inputtab%add_term(
' ')
4511 do n = 1, this%maxbound
4512 write (crch,
'(i5)') n
4513 eachconnv:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4516 if (this%idir(i) < 0) cycle eachconnv
4518 write (crch2,
'(i5)') nn
4519 connreachv:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4521 if (this%idir(ii) < 0) cycle connreachv
4528 errmsg =
'Reach '//crch//
' is connected to '// &
4529 'reach '//crch2//
' but streamflow from reach '// &
4530 crch//
' to reach '//crch2//
' is not permitted.'
4540 call this%parser%StoreErrorUnit()
4545 do n = 1, this%maxbound
4546 write (crch,
'(i5)') n
4547 eachconnds:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4549 if (this%idir(i) > 0) cycle eachconnds
4550 write (crch2,
'(i5)') nn
4552 connreachds:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4555 if (this%idir(i) /= this%idir(ii))
then
4561 if (ifound /= 1)
then
4562 errmsg =
'Reach '//crch//
' downstream connected reach '// &
4563 'is reach '//crch2//
' but reach '//crch//
' is not'// &
4564 ' the upstream connected reach for reach '//crch2//
'.'
4571 if (this%iprpak /= 0)
then
4575 do n = 1, this%maxbound
4577 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4578 if (this%idir(i) > 0)
then
4582 maxconn = max(maxconn, ii)
4584 ntabcol = 1 + maxconn
4587 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4588 trim(adjustl(this%packName))//
') STATIC UPSTREAM REACH '// &
4590 call table_cr(this%inputtab, this%packName, title)
4591 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4593 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4595 write (text,
'(a,1x,i6)')
'UPSTREAM CONN', n
4596 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4600 do n = 1, this%maxbound
4601 call this%inputtab%add_term(n)
4603 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4604 if (this%idir(i) > 0)
then
4605 call this%inputtab%add_term(this%ja(i))
4611 call this%inputtab%add_term(
' ')
4617 do n = 1, this%maxbound
4619 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4620 if (this%idir(i) < 0)
then
4624 maxconn = max(maxconn, ii)
4626 ntabcol = 1 + maxconn
4629 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4630 trim(adjustl(this%packName))//
') STATIC DOWNSTREAM '// &
4631 'REACH CONNECTION DATA'
4632 call table_cr(this%inputtab, this%packName, title)
4633 call this%inputtab%table_df(this%maxbound, ntabcol, this%iout)
4635 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4637 write (text,
'(a,1x,i6)')
'DOWNSTREAM CONN', n
4638 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4642 do n = 1, this%maxbound
4643 call this%inputtab%add_term(n)
4645 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4646 if (this%idir(i) < 0)
then
4647 call this%inputtab%add_term(this%ja(i))
4653 call this%inputtab%add_term(
' ')
4657 end subroutine sfr_check_connections
4665 subroutine sfr_check_diversions(this)
4667 class(sfrtype) :: this
4669 character(len=LINELENGTH) :: title
4670 character(len=LINELENGTH) :: text
4671 character(len=5) :: crch
4672 character(len=5) :: cdiv
4673 character(len=5) :: crch2
4674 character(len=10) :: cprior
4675 integer(I4B) :: maxdiv
4680 integer(I4B) :: idiv
4681 integer(I4B) :: ifound
4682 integer(I4B) :: jpos
4684 10
format(
'Diversion ', i0,
' of reach ', i0, &
4685 ' is invalid or has not been defined.')
4688 if (this%iprpak /= 0)
then
4692 do n = 1, this%maxbound
4693 maxdiv = maxdiv + this%ndiv(n)
4697 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4698 trim(adjustl(this%packName))//
') REACH DIVERSION DATA'
4699 call table_cr(this%inputtab, this%packName, title)
4700 call this%inputtab%table_df(maxdiv, 4, this%iout)
4702 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4704 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4706 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4708 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4712 do n = 1, this%maxbound
4713 if (this%ndiv(n) < 1) cycle
4714 write (crch,
'(i5)') n
4716 do idiv = 1, this%ndiv(n)
4719 jpos = this%iadiv(n) + idiv - 1
4722 write (cdiv,
'(i5)') idiv
4725 nn = this%divreach(jpos)
4726 write (crch2,
'(i5)') nn
4730 if (nn < 1 .or. nn > this%maxbound)
then
4731 write (
errmsg, 10) idiv, n
4735 connreach:
do ii = this%ia(nn) + 1, this%ia(nn + 1) - 1
4738 if (this%idir(ii) > 0)
then
4744 if (ifound /= 1)
then
4745 errmsg =
'Reach '//crch//
' is not a upstream reach for '// &
4746 'reach '//crch2//
' as a result diversion '//cdiv// &
4747 ' from reach '//crch//
' to reach '//crch2// &
4748 ' is not possible. Check reach connectivity.'
4752 cprior = this%divcprior(jpos)
4755 if (this%iprpak /= 0)
then
4756 call this%inputtab%add_term(n)
4757 call this%inputtab%add_term(idiv)
4758 call this%inputtab%add_term(nn)
4759 call this%inputtab%add_term(cprior)
4763 end subroutine sfr_check_diversions
4772 subroutine sfr_check_initialstages(this)
4773 class(sfrtype) :: this
4775 character(len=LINELENGTH) :: title
4776 character(len=LINELENGTH) :: text
4777 character(len=5) :: crch
4782 if (this%istorage == 0)
return
4785 if (this%iprpak /= 0)
then
4788 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4789 trim(adjustl(this%packName))//
') REACH INITIAL STAGE DATA'
4790 call table_cr(this%inputtab, this%packName, title)
4791 call this%inputtab%table_df(this%maxbound, 4, this%iout)
4793 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4794 text =
'INITIAL STAGE'
4795 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4796 text =
'INITIAL DEPTH'
4797 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4798 text =
'INITIAL FLOW'
4799 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4803 do n = 1, this%maxbound
4804 write (crch,
'(i5)') n
4807 call this%sfr_calc_qman(n, this%depth(n), qman)
4808 this%usinflow(n) = qman
4809 this%dsflow(n) = qman
4812 if (this%iprpak /= 0)
then
4813 call this%inputtab%add_term(n)
4814 call this%inputtab%add_term(this%stage(n))
4815 call this%inputtab%add_term(this%depth(n))
4816 call this%inputtab%add_term(qman)
4819 end subroutine sfr_check_initialstages
4827 subroutine sfr_check_ustrf(this)
4829 class(sfrtype) :: this
4831 character(len=LINELENGTH) :: title
4832 character(len=LINELENGTH) :: text
4833 logical(LGP) :: lcycle
4834 logical(LGP) :: ladd
4835 character(len=5) :: crch
4836 character(len=5) :: crch2
4837 character(len=10) :: cval
4838 integer(I4B) :: maxcols
4839 integer(I4B) :: npairs
4840 integer(I4B) :: ipair
4844 integer(I4B) :: idiv
4847 integer(I4B) :: jpos
4853 if (this%iprpak /= 0)
then
4857 do n = 1, this%maxbound
4859 ec:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4862 if (this%idir(i) > 0) cycle ec
4866 if (this%iboundpak(n2) == 0) cycle ec
4870 npairs = max(npairs, ipair)
4873 maxcols = 1 + npairs * 2
4876 title = trim(adjustl(this%text))//
' PACKAGE ('// &
4877 trim(adjustl(this%packName))//
') CONNECTED REACH UPSTREAM '// &
4879 call table_cr(this%inputtab, this%packName, title)
4880 call this%inputtab%table_df(this%maxbound, maxcols, this%iout)
4882 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4884 write (cval,
'(i10)') i
4885 text =
'DOWNSTREAM REACH '//trim(adjustl(cval))
4886 call this%inputtab%initialize_column(text, 10, alignment=
tabcenter)
4887 text =
'FRACTION '//trim(adjustl(cval))
4888 call this%inputtab%initialize_column(text, 12, alignment=
tabcenter)
4893 do n = 1, this%maxbound
4894 do idiv = 1, this%ndiv(n)
4896 i1 = this%iadiv(n + 1) - 1
4898 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4900 if (this%divreach(jpos) == n2)
then
4901 this%idiv(i) = jpos - i0 + 1
4911 do n = 1, this%maxbound
4915 do i = this%ia(n) + 1, this%ia(n + 1) - 1
4916 if (this%idir(i) < 0)
then
4922 do idiv = 1, this%ndiv(n)
4923 jpos = this%iadiv(n) + idiv - 1
4924 n2 = this%divreach(jpos)
4926 if (f /=
dzero)
then
4927 write (
errmsg,
'(a,2(1x,i0,1x,a),1x,a,g0,a,2(1x,a))') &
4928 'Reach', n,
'is connected to reach', n2,
'by a diversion', &
4929 'but the upstream fraction is not equal to zero (', f,
'). Check', &
4930 trim(this%packName),
'package diversion and package data.'
4934 write (
warnmsg,
'(a,3(1x,a))') &
4936 'A warning instead of an error is issued because', &
4937 'the reach is only connected to the diversion reach in the ', &
4938 'downstream direction.'
4948 do n = 1, this%maxbound
4952 write (crch,
'(i5)') n
4953 if (this%iprpak /= 0)
then
4954 call this%inputtab%add_term(n)
4957 eachconn:
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4961 this%qconn(i) =
dzero
4964 if (this%idir(i) > 0)
then
4970 if (this%iboundpak(n2) == 0)
then
4977 write (crch2,
'(i5)') n2
4980 f = f + this%ustrf(n2)
4981 write (cval,
'(f10.4)') this%ustrf(n2)
4984 if (this%iprpak /= 0)
then
4985 call this%inputtab%add_term(n2)
4986 call this%inputtab%add_term(this%ustrf(n2))
4988 eachdiv:
do idiv = 1, this%ndiv(n)
4989 jpos = this%iadiv(n) + idiv - 1
4990 if (this%divreach(jpos) == n2)
then
4996 rval = rval + this%ustrf(n2)
4999 this%ftotnd(n) = rval
5002 if (this%iprpak /= 0)
then
5004 do i = ipair, npairs
5005 call this%inputtab%add_term(
' ')
5006 call this%inputtab%add_term(
' ')
5014 write (
errmsg,
'(a,1x,i0,1x,a,g0,a,3(1x,a))') &
5015 'Upstream fractions for reach ', n,
'is not equal to one (', f, &
5016 '). Check', trim(this%packName),
'package reach connectivity and', &
5022 end subroutine sfr_check_ustrf
5030 subroutine sfr_setup_budobj(this)
5032 class(sfrtype) :: this
5034 integer(I4B) :: nbudterm
5039 integer(I4B) :: maxlist
5040 integer(I4B) :: naux
5043 character(len=LENBUDTXT) :: text
5044 character(len=LENBUDTXT),
dimension(1) :: auxtxt
5051 if (this%imover == 1) nbudterm = nbudterm + 2
5052 if (this%naux > 0) nbudterm = nbudterm + 1
5056 call this%budobj%budgetobject_df(this%maxbound, nbudterm, 0, 0, &
5057 ibudcsv=this%ibudcsv)
5061 text =
' FLOW-JA-FACE'
5063 maxlist = this%nconn
5065 auxtxt(1) =
' FLOW-AREA'
5066 call this%budobj%budterm(idx)%initialize(text, &
5071 maxlist, .false., .false., &
5075 call this%budobj%budterm(idx)%reset(this%nconn)
5077 do n = 1, this%maxbound
5079 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5081 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5088 maxlist = this%maxbound - this%ianynone
5090 auxtxt(1) =
' FLOW-AREA'
5091 call this%budobj%budterm(idx)%initialize(text, &
5096 maxlist, .false., .true., &
5098 call this%budobj%budterm(idx)%reset(maxlist)
5100 do n = 1, this%maxbound
5101 n2 = this%igwfnode(n)
5103 call this%budobj%budterm(idx)%update_term(n, n2, q)
5110 maxlist = this%maxbound
5112 call this%budobj%budterm(idx)%initialize(text, &
5117 maxlist, .false., .false., &
5121 text =
' EVAPORATION'
5123 maxlist = this%maxbound
5125 call this%budobj%budterm(idx)%initialize(text, &
5130 maxlist, .false., .false., &
5136 maxlist = this%maxbound
5138 call this%budobj%budterm(idx)%initialize(text, &
5143 maxlist, .false., .false., &
5147 text =
' EXT-INFLOW'
5149 maxlist = this%maxbound
5151 call this%budobj%budterm(idx)%initialize(text, &
5156 maxlist, .false., .false., &
5160 text =
' EXT-OUTFLOW'
5162 maxlist = this%maxbound
5164 call this%budobj%budterm(idx)%initialize(text, &
5169 maxlist, .false., .false., &
5175 maxlist = this%maxbound
5177 auxtxt(1) =
' VOLUME'
5178 call this%budobj%budterm(idx)%initialize(text, &
5183 maxlist, .false., .false., &
5187 if (this%imover == 1)
then
5192 maxlist = this%maxbound
5194 call this%budobj%budterm(idx)%initialize(text, &
5199 maxlist, .false., .false., &
5205 maxlist = this%maxbound
5207 call this%budobj%budterm(idx)%initialize(text, &
5212 maxlist, .false., .false., &
5223 maxlist = this%maxbound
5224 call this%budobj%budterm(idx)%initialize(text, &
5229 maxlist, .false., .false., &
5234 if (this%iprflow /= 0)
then
5235 call this%budobj%flowtable_df(this%iout, cellids=
'GWF')
5237 end subroutine sfr_setup_budobj
5245 subroutine sfr_fill_budobj(this)
5247 class(sfrtype) :: this
5249 integer(I4B) :: naux
5256 integer(I4B) :: idiv
5257 integer(I4B) :: jpos
5271 call this%budobj%budterm(idx)%reset(this%nconn)
5272 do n = 1, this%maxbound
5276 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5278 if (this%iboundpak(n) /= 0)
then
5280 if (this%idir(i) < 0)
then
5286 do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5287 if (this%idir(ii) > 0) cycle
5288 if (this%ja(ii) /= n) cycle
5294 call this%sfr_calc_reach_depth(n, qt, d)
5295 ca = this%calc_area_wet(n, d)
5300 this%qauxcbc(1) = ca
5301 call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5307 call this%budobj%budterm(idx)%reset(this%maxbound - this%ianynone)
5308 do n = 1, this%maxbound
5309 n2 = this%igwfnode(n)
5311 if (this%iboundpak(n) /= 0)
then
5313 if (this%depth(n) >
dzero)
then
5314 wp = this%calc_perimeter_wet(n, this%depth(n))
5323 this%qauxcbc(1) =
dzero
5326 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
5332 call this%budobj%budterm(idx)%reset(this%maxbound)
5333 do n = 1, this%maxbound
5334 if (this%iboundpak(n) /= 0)
then
5335 a = this%calc_surface_area(n)
5336 q = this%rain(n) * a
5340 call this%budobj%budterm(idx)%update_term(n, n, q)
5345 call this%budobj%budterm(idx)%reset(this%maxbound)
5346 do n = 1, this%maxbound
5347 if (this%iboundpak(n) /= 0)
then
5348 q = -this%simevap(n)
5352 call this%budobj%budterm(idx)%update_term(n, n, q)
5357 call this%budobj%budterm(idx)%reset(this%maxbound)
5358 do n = 1, this%maxbound
5359 if (this%iboundpak(n) /= 0)
then
5360 q = this%simrunoff(n)
5364 call this%budobj%budterm(idx)%update_term(n, n, q)
5369 call this%budobj%budterm(idx)%reset(this%maxbound)
5370 do n = 1, this%maxbound
5371 if (this%iboundpak(n) /= 0)
then
5376 call this%budobj%budterm(idx)%update_term(n, n, q)
5381 call this%budobj%budterm(idx)%reset(this%maxbound)
5382 do n = 1, this%maxbound
5384 if (this%iboundpak(n) /= 0)
then
5385 do i = this%ia(n) + 1, this%ia(n + 1) - 1
5386 if (this%idir(i) > 0) cycle
5389 jpos = this%iadiv(n) + idiv - 1
5390 q = q + this%divq(jpos)
5392 q = q + this%qconn(i)
5395 q = q - this%dsflow(n)
5396 if (this%imover == 1)
then
5397 q = q + this%pakmvrobj%get_qtomvr(n)
5400 if (this%imover == 1)
then
5401 q = this%pakmvrobj%get_qfrommvr(n)
5404 call this%budobj%budterm(idx)%update_term(n, n, q)
5409 call this%budobj%budterm(idx)%reset(this%maxbound)
5410 do n = 1, this%maxbound
5412 if (this%iboundpak(n) /= 0)
then
5414 a = this%calc_surface_area_wet(n, d)
5415 this%qauxcbc(1) = a * d
5416 if (this%gwfiss == 0 .and. this%istorage == 1)
then
5421 this%qauxcbc(1) =
dzero
5423 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
5427 if (this%imover == 1)
then
5431 call this%budobj%budterm(idx)%reset(this%maxbound)
5432 do n = 1, this%maxbound
5434 if (this%iboundpak(n) /= 0)
then
5435 q = this%pakmvrobj%get_qfrommvr(n)
5437 call this%budobj%budterm(idx)%update_term(n, n, q)
5442 call this%budobj%budterm(idx)%reset(this%maxbound)
5443 do n = 1, this%maxbound
5444 if (this%iboundpak(n) /= 0)
then
5445 q = this%pakmvrobj%get_qtomvr(n)
5452 call this%budobj%budterm(idx)%update_term(n, n, q)
5460 call this%budobj%budterm(idx)%reset(this%maxbound)
5461 do n = 1, this%maxbound
5463 call this%budobj%budterm(idx)%update_term(n, n, q, this%auxvar(:, n))
5468 call this%budobj%accumulate_terms()
5469 end subroutine sfr_fill_budobj
5477 subroutine sfr_setup_tableobj(this)
5479 class(sfrtype) :: this
5481 integer(I4B) :: nterms
5482 character(len=LINELENGTH) :: title
5483 character(len=LINELENGTH) :: text
5486 if (this%iprhed > 0)
then
5493 if (this%inamedbound == 1)
then
5498 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5499 trim(adjustl(this%packName))//
') STAGES FOR EACH CONTROL VOLUME'
5502 call table_cr(this%stagetab, this%packName, title)
5503 call this%stagetab%table_df(this%maxbound, nterms, this%iout, &
5507 if (this%inamedbound == 1)
then
5509 call this%stagetab%initialize_column(text,
lenboundname, &
5515 call this%stagetab%initialize_column(text, 10, alignment=
tabcenter)
5519 call this%stagetab%initialize_column(text, 20, alignment=
tableft)
5523 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5527 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5531 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5535 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5538 text =
'STREAMBED CONDUCTANCE'
5539 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5542 text =
'STREAMBED GRADIENT'
5543 call this%stagetab%initialize_column(text, 12, alignment=
tabcenter)
5545 end subroutine sfr_setup_tableobj
5553 function calc_area_wet(this, n, depth)
5555 real(dp) :: calc_area_wet
5557 class(sfrtype) :: this
5558 integer(I4B),
intent(in) :: n
5559 real(dp),
intent(in) :: depth
5561 integer(I4B) :: npts
5566 npts = this%ncrosspts(n)
5567 i0 = this%iacross(n)
5568 i1 = this%iacross(n + 1) - 1
5571 this%xsheight(i0:i1), depth)
5573 calc_area_wet = this%station(i0) * depth
5575 end function calc_area_wet
5581 function calc_perimeter_wet(this, n, depth)
5583 real(dp) :: calc_perimeter_wet
5585 class(sfrtype) :: this
5586 integer(I4B),
intent(in) :: n
5587 real(dp),
intent(in) :: depth
5589 integer(I4B) :: npts
5594 npts = this%ncrosspts(n)
5595 i0 = this%iacross(n)
5596 i1 = this%iacross(n + 1) - 1
5599 this%xsheight(i0:i1), depth)
5601 calc_perimeter_wet = this%station(i0)
5603 end function calc_perimeter_wet
5609 function calc_surface_area(this, n)
5611 real(dp) :: calc_surface_area
5613 class(sfrtype) :: this
5614 integer(I4B),
intent(in) :: n
5616 integer(I4B) :: npts
5619 real(dp) :: top_width
5622 npts = this%ncrosspts(n)
5623 i0 = this%iacross(n)
5624 i1 = this%iacross(n + 1) - 1
5628 top_width = this%station(i0)
5630 calc_surface_area = top_width * this%length(n)
5631 end function calc_surface_area
5637 function calc_surface_area_wet(this, n, depth)
5639 real(dp) :: calc_surface_area_wet
5641 class(sfrtype) :: this
5642 integer(I4B),
intent(in) :: n
5643 real(dp),
intent(in) :: depth
5645 real(dp) :: top_width
5648 top_width = this%calc_top_width_wet(n, depth)
5649 calc_surface_area_wet = top_width * this%length(n)
5650 end function calc_surface_area_wet
5656 function calc_top_width_wet(this, n, depth)
5658 real(dp) :: calc_top_width_wet
5660 class(sfrtype) :: this
5661 integer(I4B),
intent(in) :: n
5662 real(dp),
intent(in) :: depth
5664 integer(I4B) :: npts
5670 npts = this%ncrosspts(n)
5671 i0 = this%iacross(n)
5672 i1 = this%iacross(n + 1) - 1
5676 this%station(i0:i1), &
5677 this%xsheight(i0:i1), &
5680 calc_top_width_wet = sat * this%station(i0)
5682 end function calc_top_width_wet
5688 subroutine sfr_activate_density(this)
5692 class(sfrtype),
intent(inout) :: this
5699 call mem_reallocate(this%denseterms, 3, this%MAXBOUND,
'DENSETERMS', &
5701 do i = 1, this%maxbound
5703 this%denseterms(j, i) =
dzero
5706 write (this%iout,
'(/1x,a)')
'DENSITY TERMS HAVE BEEN ACTIVATED FOR SFR &
5707 &PACKAGE: '//trim(adjustl(this%packName))
5708 end subroutine sfr_activate_density
5715 subroutine sfr_activate_viscosity(this)
5719 class(sfrtype),
intent(inout) :: this
5726 call mem_reallocate(this%viscratios, 2, this%MAXBOUND,
'VISCRATIOS', &
5728 do i = 1, this%maxbound
5730 this%viscratios(j, i) =
done
5733 write (this%iout,
'(/1x,a)')
'VISCOSITY HAS BEEN ACTIVATED FOR SFR &
5734 &PACKAGE: '//trim(adjustl(this%packName))
5735 end subroutine sfr_activate_viscosity
5748 subroutine sfr_calculate_density_exchange(this, n, stage, head, cond, &
5749 bots, flow, gwfhcof, gwfrhs)
5751 class(sfrtype),
intent(inout) :: this
5752 integer(I4B),
intent(in) :: n
5753 real(DP),
intent(in) :: stage
5754 real(DP),
intent(in) :: head
5755 real(DP),
intent(in) :: cond
5756 real(DP),
intent(in) :: bots
5757 real(DP),
intent(inout) :: flow
5758 real(DP),
intent(inout) :: gwfhcof
5759 real(DP),
intent(inout) :: gwfrhs
5764 real(DP) :: rdensesfr
5765 real(DP) :: rdensegwf
5766 real(DP) :: rdenseavg
5772 logical(LGP) :: stage_below_bot
5773 logical(LGP) :: head_below_bot
5776 if (stage >= bots)
then
5778 stage_below_bot = .false.
5779 rdensesfr = this%denseterms(1, n)
5782 stage_below_bot = .true.
5783 rdensesfr = this%denseterms(2, n)
5787 if (head >= bots)
then
5789 head_below_bot = .false.
5790 rdensegwf = this%denseterms(2, n)
5793 head_below_bot = .true.
5794 rdensegwf = this%denseterms(1, n)
5798 if (rdensegwf ==
dzero)
return
5801 if (stage_below_bot .and. head_below_bot)
then
5808 rdenseavg =
dhalf * (rdensesfr + rdensegwf)
5812 d1 = cond * (rdenseavg -
done)
5813 gwfhcof = gwfhcof - d1
5814 gwfrhs = gwfrhs - d1 * ss
5819 if (.not. stage_below_bot .and. .not. head_below_bot)
then
5823 elevgwf = this%denseterms(3, n)
5825 elevavg =
dhalf * (elevsfr + elevgwf)
5826 havg =
dhalf * (hh + ss)
5827 d2 = cond * (havg - elevavg) * (rdensegwf - rdensesfr)
5828 gwfrhs = gwfrhs + d2
5832 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.