43 character(len=LENFTYPE) ::
ftype =
'LAK'
44 character(len=LENPACKAGENAME) ::
text =
' LAK'
47 real(dp),
dimension(:),
pointer,
contiguous :: tabstage => null()
48 real(dp),
dimension(:),
pointer,
contiguous :: tabvolume => null()
49 real(dp),
dimension(:),
pointer,
contiguous :: tabsarea => null()
50 real(dp),
dimension(:),
pointer,
contiguous :: tabwarea => null()
56 character(len=16),
dimension(:),
pointer,
contiguous :: clakbudget => null()
57 character(len=16),
dimension(:),
pointer,
contiguous :: cauxcbc => null()
60 integer(I4B),
pointer :: iprhed => null()
61 integer(I4B),
pointer :: istageout => null()
62 integer(I4B),
pointer :: ibudgetout => null()
63 integer(I4B),
pointer :: ibudcsv => null()
64 integer(I4B),
pointer :: ipakcsv => null()
65 integer(I4B),
pointer :: cbcauxitems => null()
66 integer(I4B),
pointer :: nlakes => null()
67 integer(I4B),
pointer :: noutlets => null()
68 integer(I4B),
pointer :: ntables => null()
69 real(dp),
pointer :: convlength => null()
70 real(dp),
pointer :: convtime => null()
71 real(dp),
pointer :: outdmax => null()
72 integer(I4B),
pointer :: igwhcopt => null()
73 integer(I4B),
pointer :: iconvchk => null()
74 integer(I4B),
pointer :: iconvresidchk => null()
75 integer(I4B),
pointer :: maxlakit => null()
76 real(dp),
pointer :: surfdep => null()
77 real(dp),
pointer :: dmaxchg => null()
78 real(dp),
pointer :: delh => null()
79 real(dp),
pointer :: pdmax => null()
80 integer(I4B),
pointer :: check_attr => null()
82 integer(I4B),
pointer :: bditems => null()
85 integer(I4B),
dimension(:),
pointer,
contiguous :: nlakeconn => null()
86 integer(I4B),
dimension(:),
pointer,
contiguous :: idxlakeconn => null()
87 integer(I4B),
dimension(:),
pointer,
contiguous :: ntabrow => null()
88 real(dp),
dimension(:),
pointer,
contiguous :: strt => null()
89 real(dp),
dimension(:),
pointer,
contiguous :: laketop => null()
90 real(dp),
dimension(:),
pointer,
contiguous :: lakebot => null()
91 real(dp),
dimension(:),
pointer,
contiguous :: sareamax => null()
92 character(len=LENBOUNDNAME),
dimension(:),
pointer, &
93 contiguous :: lakename => null()
94 character(len=8),
dimension(:),
pointer,
contiguous :: status => null()
95 real(dp),
dimension(:),
pointer,
contiguous :: avail => null()
96 real(dp),
dimension(:),
pointer,
contiguous :: lkgwsink => null()
97 real(dp),
dimension(:),
pointer,
contiguous :: stage => null()
98 real(dp),
dimension(:),
pointer,
contiguous :: rainfall => null()
99 real(dp),
dimension(:),
pointer,
contiguous :: evaporation => null()
100 real(dp),
dimension(:),
pointer,
contiguous :: runoff => null()
101 real(dp),
dimension(:),
pointer,
contiguous :: inflow => null()
102 real(dp),
dimension(:),
pointer,
contiguous :: withdrawal => null()
103 real(dp),
dimension(:, :),
pointer,
contiguous :: lauxvar => null()
106 integer(I4B),
dimension(:),
pointer,
contiguous :: ialaktab => null()
107 real(dp),
dimension(:),
pointer,
contiguous :: tabstage => null()
108 real(dp),
dimension(:),
pointer,
contiguous :: tabvolume => null()
109 real(dp),
dimension(:),
pointer,
contiguous :: tabsarea => null()
110 real(dp),
dimension(:),
pointer,
contiguous :: tabwarea => null()
113 integer(I4B),
dimension(:),
pointer,
contiguous :: ncncvr => null()
114 real(dp),
dimension(:),
pointer,
contiguous :: surfin => null()
115 real(dp),
dimension(:),
pointer,
contiguous :: surfout => null()
116 real(dp),
dimension(:),
pointer,
contiguous :: surfout1 => null()
117 real(dp),
dimension(:),
pointer,
contiguous :: precip => null()
118 real(dp),
dimension(:),
pointer,
contiguous :: precip1 => null()
119 real(dp),
dimension(:),
pointer,
contiguous :: evap => null()
120 real(dp),
dimension(:),
pointer,
contiguous :: evap1 => null()
121 real(dp),
dimension(:),
pointer,
contiguous :: evapo => null()
122 real(dp),
dimension(:),
pointer,
contiguous :: withr => null()
123 real(dp),
dimension(:),
pointer,
contiguous :: withr1 => null()
124 real(dp),
dimension(:),
pointer,
contiguous :: flwin => null()
125 real(dp),
dimension(:),
pointer,
contiguous :: flwiter => null()
126 real(dp),
dimension(:),
pointer,
contiguous :: flwiter1 => null()
127 real(dp),
dimension(:),
pointer,
contiguous :: seep => null()
128 real(dp),
dimension(:),
pointer,
contiguous :: seep1 => null()
129 real(dp),
dimension(:),
pointer,
contiguous :: seep0 => null()
130 real(dp),
dimension(:),
pointer,
contiguous :: stageiter => null()
131 real(dp),
dimension(:),
pointer,
contiguous :: chterm => null()
134 integer(I4B),
dimension(:),
pointer,
contiguous :: iseepc => null()
135 integer(I4B),
dimension(:),
pointer,
contiguous :: idhc => null()
136 real(dp),
dimension(:),
pointer,
contiguous :: en1 => null()
137 real(dp),
dimension(:),
pointer,
contiguous :: en2 => null()
138 real(dp),
dimension(:),
pointer,
contiguous :: r1 => null()
139 real(dp),
dimension(:),
pointer,
contiguous :: r2 => null()
140 real(dp),
dimension(:),
pointer,
contiguous :: dh0 => null()
141 real(dp),
dimension(:),
pointer,
contiguous :: s0 => null()
142 real(dp),
dimension(:),
pointer,
contiguous :: qgwf0 => null()
145 integer(I4B),
dimension(:),
pointer,
contiguous :: imap => null()
146 integer(I4B),
dimension(:),
pointer,
contiguous :: cellid => null()
147 integer(I4B),
dimension(:),
pointer,
contiguous :: nodesontop => null()
148 integer(I4B),
dimension(:),
pointer,
contiguous :: ictype => null()
149 real(dp),
dimension(:),
pointer,
contiguous :: bedleak => null()
150 real(dp),
dimension(:),
pointer,
contiguous :: belev => null()
151 real(dp),
dimension(:),
pointer,
contiguous :: telev => null()
152 real(dp),
dimension(:),
pointer,
contiguous :: connlength => null()
153 real(dp),
dimension(:),
pointer,
contiguous :: connwidth => null()
154 real(dp),
dimension(:),
pointer,
contiguous :: sarea => null()
155 real(dp),
dimension(:),
pointer,
contiguous :: warea => null()
156 real(dp),
dimension(:),
pointer,
contiguous :: satcond => null()
157 real(dp),
dimension(:),
pointer,
contiguous :: simcond => null()
158 real(dp),
dimension(:),
pointer,
contiguous :: simlakgw => null()
161 integer(I4B),
dimension(:),
pointer,
contiguous :: lakein => null()
162 integer(I4B),
dimension(:),
pointer,
contiguous :: lakeout => null()
163 integer(I4B),
dimension(:),
pointer,
contiguous :: iouttype => null()
164 real(dp),
dimension(:),
pointer,
contiguous :: outrate => null()
165 real(dp),
dimension(:),
pointer,
contiguous :: outinvert => null()
166 real(dp),
dimension(:),
pointer,
contiguous :: outwidth => null()
167 real(dp),
dimension(:),
pointer,
contiguous :: outrough => null()
168 real(dp),
dimension(:),
pointer,
contiguous :: outslope => null()
169 real(dp),
dimension(:),
pointer,
contiguous :: simoutrate => null()
172 real(dp),
dimension(:),
pointer,
contiguous :: qauxcbc => null()
173 real(dp),
dimension(:),
pointer,
contiguous :: dbuff => null()
174 real(dp),
dimension(:),
pointer,
contiguous :: qleak => null()
175 real(dp),
dimension(:),
pointer,
contiguous :: qsto => null()
178 integer(I4B),
pointer :: gwfiss => null()
179 real(dp),
dimension(:),
pointer,
contiguous :: gwfk11 => null()
180 real(dp),
dimension(:),
pointer,
contiguous :: gwfk33 => null()
181 real(dp),
dimension(:),
pointer,
contiguous :: gwfsat => null()
182 integer(I4B),
pointer :: gwfik33 => null()
185 integer(I4B),
dimension(:),
pointer,
contiguous :: iboundpak => null()
186 real(dp),
dimension(:),
pointer,
contiguous :: xnewpak => null()
187 real(dp),
dimension(:),
pointer,
contiguous :: xoldpak => null()
197 integer(I4B),
pointer :: idense
198 real(dp),
dimension(:, :),
pointer,
contiguous :: denseterms => null()
201 real(dp),
dimension(:, :),
pointer,
contiguous :: viscratios => null()
290 subroutine lak_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
292 class(
bndtype),
pointer :: packobj
293 integer(I4B),
intent(in) :: id
294 integer(I4B),
intent(in) :: ibcnum
295 integer(I4B),
intent(in) :: inunit
296 integer(I4B),
intent(in) :: iout
297 character(len=*),
intent(in) :: namemodel
298 character(len=*),
intent(in) :: pakname
300 type(
laktype),
pointer :: lakobj
307 call packobj%set_names(ibcnum, namemodel, pakname,
ftype)
311 call lakobj%lak_allocate_scalars()
314 call packobj%pack_initialize()
316 packobj%inunit = inunit
319 packobj%ibcnum = ibcnum
333 class(
laktype),
intent(inout) :: this
336 call this%BndType%allocate_scalars()
339 call mem_allocate(this%iprhed,
'IPRHED', this%memoryPath)
340 call mem_allocate(this%istageout,
'ISTAGEOUT', this%memoryPath)
341 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
342 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
343 call mem_allocate(this%ipakcsv,
'IPAKCSV', this%memoryPath)
344 call mem_allocate(this%nlakes,
'NLAKES', this%memoryPath)
345 call mem_allocate(this%noutlets,
'NOUTLETS', this%memoryPath)
346 call mem_allocate(this%ntables,
'NTABLES', this%memoryPath)
347 call mem_allocate(this%convlength,
'CONVLENGTH', this%memoryPath)
348 call mem_allocate(this%convtime,
'CONVTIME', this%memoryPath)
349 call mem_allocate(this%outdmax,
'OUTDMAX', this%memoryPath)
350 call mem_allocate(this%igwhcopt,
'IGWHCOPT', this%memoryPath)
351 call mem_allocate(this%iconvchk,
'ICONVCHK', this%memoryPath)
352 call mem_allocate(this%iconvresidchk,
'ICONVRESIDCHK', this%memoryPath)
353 call mem_allocate(this%maxlakit,
'MAXLAKIT', this%memoryPath)
354 call mem_allocate(this%surfdep,
'SURFDEP', this%memoryPath)
355 call mem_allocate(this%dmaxchg,
'DMAXCHG', this%memoryPath)
358 call mem_allocate(this%check_attr,
'CHECK_ATTR', this%memoryPath)
359 call mem_allocate(this%bditems,
'BDITEMS', this%memoryPath)
360 call mem_allocate(this%cbcauxitems,
'CBCAUXITEMS', this%memoryPath)
361 call mem_allocate(this%idense,
'IDENSE', this%memoryPath)
372 this%convlength =
done
377 this%iconvresidchk = 1
381 this%delh =
dp999 * this%dmaxchg
397 class(
laktype),
intent(inout) :: this
402 call this%BndType%allocate_arrays()
405 allocate (this%clakbudget(this%bditems))
408 this%clakbudget(1) =
' GWF'
409 this%clakbudget(2) =
' RAINFALL'
410 this%clakbudget(3) =
' EVAPORATION'
411 this%clakbudget(4) =
' RUNOFF'
412 this%clakbudget(5) =
' EXT-INFLOW'
413 this%clakbudget(6) =
' WITHDRAWAL'
414 this%clakbudget(7) =
' EXT-OUTFLOW'
415 this%clakbudget(8) =
' STORAGE'
416 this%clakbudget(9) =
' CONSTANT'
417 this%clakbudget(10) =
' FROM-MVR'
418 this%clakbudget(11) =
' TO-MVR'
421 if (this%istageout > 0)
then
422 call mem_allocate(this%dbuff, this%nlakes,
'DBUFF', this%memoryPath)
423 do i = 1, this%nlakes
424 this%dbuff(i) =
dzero
427 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
431 allocate (this%cauxcbc(this%cbcauxitems))
434 call mem_allocate(this%qauxcbc, this%cbcauxitems,
'QAUXCBC', this%memoryPath)
435 do i = 1, this%cbcauxitems
436 this%qauxcbc(i) =
dzero
440 call mem_allocate(this%qleak, this%maxbound,
'QLEAK', this%memoryPath)
441 do i = 1, this%maxbound
442 this%qleak(i) =
dzero
444 call mem_allocate(this%qsto, this%nlakes,
'QSTO', this%memoryPath)
445 do i = 1, this%nlakes
450 call mem_allocate(this%denseterms, 3, 0,
'DENSETERMS', this%memoryPath)
453 call mem_allocate(this%viscratios, 2, 0,
'VISCRATIOS', this%memoryPath)
467 class(
laktype),
intent(inout) :: this
469 character(len=LINELENGTH) :: text
470 character(len=LENBOUNDNAME) :: bndName, bndNameTemp
471 character(len=9) :: cno
472 character(len=50),
dimension(:),
allocatable :: caux
473 integer(I4B) :: ierr, ival
474 logical(LGP) :: isfound, endOfBlock
476 integer(I4B) :: ii, jj
480 integer(I4B) :: nconn
481 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
482 real(DP),
pointer :: bndElem => null()
488 call mem_allocate(this%nlakeconn, this%nlakes,
'NLAKECONN', this%memoryPath)
489 call mem_allocate(this%idxlakeconn, this%nlakes + 1,
'IDXLAKECONN', &
491 call mem_allocate(this%ntabrow, this%nlakes,
'NTABROW', this%memoryPath)
492 call mem_allocate(this%strt, this%nlakes,
'STRT', this%memoryPath)
493 call mem_allocate(this%laketop, this%nlakes,
'LAKETOP', this%memoryPath)
494 call mem_allocate(this%lakebot, this%nlakes,
'LAKEBOT', this%memoryPath)
495 call mem_allocate(this%sareamax, this%nlakes,
'SAREAMAX', this%memoryPath)
496 call mem_allocate(this%stage, this%nlakes,
'STAGE', this%memoryPath)
497 call mem_allocate(this%rainfall, this%nlakes,
'RAINFALL', this%memoryPath)
498 call mem_allocate(this%evaporation, this%nlakes,
'EVAPORATION', &
500 call mem_allocate(this%runoff, this%nlakes,
'RUNOFF', this%memoryPath)
501 call mem_allocate(this%inflow, this%nlakes,
'INFLOW', this%memoryPath)
502 call mem_allocate(this%withdrawal, this%nlakes,
'WITHDRAWAL', this%memoryPath)
503 call mem_allocate(this%lauxvar, this%naux, this%nlakes,
'LAUXVAR', &
505 call mem_allocate(this%avail, this%nlakes,
'AVAIL', this%memoryPath)
506 call mem_allocate(this%lkgwsink, this%nlakes,
'LKGWSINK', this%memoryPath)
507 call mem_allocate(this%ncncvr, this%nlakes,
'NCNCVR', this%memoryPath)
508 call mem_allocate(this%surfin, this%nlakes,
'SURFIN', this%memoryPath)
509 call mem_allocate(this%surfout, this%nlakes,
'SURFOUT', this%memoryPath)
510 call mem_allocate(this%surfout1, this%nlakes,
'SURFOUT1', this%memoryPath)
511 call mem_allocate(this%precip, this%nlakes,
'PRECIP', this%memoryPath)
512 call mem_allocate(this%precip1, this%nlakes,
'PRECIP1', this%memoryPath)
513 call mem_allocate(this%evap, this%nlakes,
'EVAP', this%memoryPath)
514 call mem_allocate(this%evap1, this%nlakes,
'EVAP1', this%memoryPath)
515 call mem_allocate(this%evapo, this%nlakes,
'EVAPO', this%memoryPath)
516 call mem_allocate(this%withr, this%nlakes,
'WITHR', this%memoryPath)
517 call mem_allocate(this%withr1, this%nlakes,
'WITHR1', this%memoryPath)
518 call mem_allocate(this%flwin, this%nlakes,
'FLWIN', this%memoryPath)
519 call mem_allocate(this%flwiter, this%nlakes,
'FLWITER', this%memoryPath)
520 call mem_allocate(this%flwiter1, this%nlakes,
'FLWITER1', this%memoryPath)
521 call mem_allocate(this%seep, this%nlakes,
'SEEP', this%memoryPath)
522 call mem_allocate(this%seep1, this%nlakes,
'SEEP1', this%memoryPath)
523 call mem_allocate(this%seep0, this%nlakes,
'SEEP0', this%memoryPath)
524 call mem_allocate(this%stageiter, this%nlakes,
'STAGEITER', this%memoryPath)
525 call mem_allocate(this%chterm, this%nlakes,
'CHTERM', this%memoryPath)
528 call mem_allocate(this%iboundpak, this%nlakes,
'IBOUND', this%memoryPath)
529 call mem_allocate(this%xnewpak, this%nlakes,
'XNEWPAK', this%memoryPath)
530 call mem_allocate(this%xoldpak, this%nlakes,
'XOLDPAK', this%memoryPath)
533 call mem_allocate(this%iseepc, this%nlakes,
'ISEEPC', this%memoryPath)
534 call mem_allocate(this%idhc, this%nlakes,
'IDHC', this%memoryPath)
535 call mem_allocate(this%en1, this%nlakes,
'EN1', this%memoryPath)
536 call mem_allocate(this%en2, this%nlakes,
'EN2', this%memoryPath)
537 call mem_allocate(this%r1, this%nlakes,
'R1', this%memoryPath)
538 call mem_allocate(this%r2, this%nlakes,
'R2', this%memoryPath)
539 call mem_allocate(this%dh0, this%nlakes,
'DH0', this%memoryPath)
540 call mem_allocate(this%s0, this%nlakes,
'S0', this%memoryPath)
541 call mem_allocate(this%qgwf0, this%nlakes,
'QGWF0', this%memoryPath)
544 allocate (this%lakename(this%nlakes))
545 allocate (this%status(this%nlakes))
547 do n = 1, this%nlakes
549 this%status(n) =
'ACTIVE'
550 this%laketop(n) = -dep20
551 this%lakebot(n) = dep20
552 this%sareamax(n) = dzero
553 this%iboundpak(n) = 1
554 this%xnewpak(n) = dep20
555 this%xoldpak(n) = dep20
558 this%rainfall(n) = dzero
559 this%evaporation(n) = dzero
560 this%runoff(n) = dzero
561 this%inflow(n) = dzero
562 this%withdrawal(n) = dzero
566 if (this%naux > 0)
then
567 allocate (caux(this%naux))
571 allocate (nboundchk(this%nlakes))
572 do n = 1, this%nlakes
578 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
579 supportopenclose=.true.)
583 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
588 call this%parser%GetNextLine(endofblock)
590 n = this%parser%GetInteger()
592 if (n < 1 .or. n > this%nlakes)
then
593 write (
errmsg,
'(a,1x,i0)')
'lakeno MUST BE > 0 and <= ', this%nlakes
599 nboundchk(n) = nboundchk(n) + 1
602 this%strt(n) = this%parser%GetDouble()
605 ival = this%parser%GetInteger()
608 write (
errmsg,
'(a,1x,i0)')
'nlakeconn MUST BE >= 0 for lake ', n
613 this%nlakeconn(n) = ival
616 do iaux = 1, this%naux
617 call this%parser%GetString(caux(iaux))
621 write (cno,
'(i9.9)') n
622 bndname =
'Lake'//cno
625 if (this%inamedbound /= 0)
then
626 call this%parser%GetStringCaps(bndnametemp)
627 if (bndnametemp /=
'')
then
628 bndname = bndnametemp
631 this%lakename(n) = bndname
638 bndelem => this%lauxvar(jj, ii)
640 this%packName,
'AUX', &
641 this%tsManager, this%iprpak, &
649 do n = 1, this%nlakes
650 if (nboundchk(n) == 0)
then
651 write (
errmsg,
'(a,1x,i0)')
'NO DATA SPECIFIED FOR LAKE', n
653 else if (nboundchk(n) > 1)
then
654 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
655 'DATA FOR LAKE', n,
'SPECIFIED', nboundchk(n),
'TIMES'
660 write (this%iout,
'(1x,a)')
'END OF '//trim(adjustl(this%text))// &
663 call store_error(
'REQUIRED PACKAGEDATA BLOCK NOT FOUND.')
668 call this%parser%StoreErrorUnit()
672 this%MAXBOUND = nconn
673 write (this%iout,
'(//4x,a,i7)')
'MAXBOUND = ', this%maxbound
676 this%idxlakeconn(1) = 1
677 do n = 1, this%nlakes
678 this%idxlakeconn(n + 1) = this%idxlakeconn(n) + this%nlakeconn(n)
682 if (this%naux > 0)
then
687 deallocate (nboundchk)
699 class(
laktype),
intent(inout) :: this
701 character(len=LINELENGTH) :: keyword, cellid
702 integer(I4B) :: ierr, ival
703 logical(LGP) :: isfound, endOfBlock
704 logical(LGP) :: is_lake_bed
708 integer(I4B) :: ipos, ipos0
709 integer(I4B) :: icellid, icellid0
712 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
713 character(len=LENVARNAME) :: ctypenm
716 allocate (nboundchk(this%MAXBOUND))
717 do n = 1, this%MAXBOUND
722 call this%parser%GetBlock(
'CONNECTIONDATA', isfound, ierr, &
723 supportopenclose=.true.)
728 call mem_allocate(this%imap, this%MAXBOUND,
'IMAP', this%memoryPath)
729 call mem_allocate(this%cellid, this%MAXBOUND,
'CELLID', this%memoryPath)
730 call mem_allocate(this%nodesontop, this%MAXBOUND,
'NODESONTOP', &
732 call mem_allocate(this%ictype, this%MAXBOUND,
'ICTYPE', this%memoryPath)
733 call mem_allocate(this%bedleak, this%MAXBOUND,
'BEDLEAK', this%memoryPath)
734 call mem_allocate(this%belev, this%MAXBOUND,
'BELEV', this%memoryPath)
735 call mem_allocate(this%telev, this%MAXBOUND,
'TELEV', this%memoryPath)
736 call mem_allocate(this%connlength, this%MAXBOUND,
'CONNLENGTH', &
738 call mem_allocate(this%connwidth, this%MAXBOUND,
'CONNWIDTH', &
740 call mem_allocate(this%sarea, this%MAXBOUND,
'SAREA', this%memoryPath)
741 call mem_allocate(this%warea, this%MAXBOUND,
'WAREA', this%memoryPath)
742 call mem_allocate(this%satcond, this%MAXBOUND,
'SATCOND', this%memoryPath)
743 call mem_allocate(this%simcond, this%MAXBOUND,
'SIMCOND', this%memoryPath)
744 call mem_allocate(this%simlakgw, this%MAXBOUND,
'SIMLAKGW', this%memoryPath)
747 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
750 call this%parser%GetNextLine(endofblock)
752 n = this%parser%GetInteger()
754 if (n < 1 .or. n > this%nlakes)
then
755 write (
errmsg,
'(a,1x,i0)')
'lakeno MUST BE > 0 and <= ', this%nlakes
761 ival = this%parser%GetInteger()
762 if (ival < 1 .or. ival > this%nlakeconn(n))
then
763 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
764 'iconn FOR LAKE ', n,
'MUST BE > 1 and <= ', this%nlakeconn(n)
770 ipos = this%idxlakeconn(n) + ival - 1
777 nboundchk(ipos) = nboundchk(ipos) + 1
780 call this%parser%GetCellid(this%dis%ndim, cellid)
781 nn = this%dis%noder_from_cellid(cellid, &
782 this%parser%iuactive, this%iout)
786 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
787 'INVALID cellid FOR LAKE ', n,
'connection', j
792 this%cellid(ipos) = nn
793 this%nodesontop(ipos) = nn
796 call this%parser%GetStringCaps(keyword)
797 select case (keyword)
799 this%ictype(ipos) = 0
801 this%ictype(ipos) = 1
803 this%ictype(ipos) = 2
805 this%ictype(ipos) = 3
807 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,a,a)') &
808 'UNKNOWN ctype FOR LAKE ', n,
'connection', j, &
809 '(', trim(keyword),
')'
812 write (ctypenm,
'(a16)') keyword
816 call this%parser%GetStringCaps(keyword)
817 select case (keyword)
819 is_lake_bed = .false.
820 this%bedleak(ipos) = dnodata
823 write (
warnmsg,
'(2(a,1x,i0,1x),a,1pe8.1,a)') &
824 'BEDLEAK for connection', j,
'in lake', n,
'is specified to '// &
825 'be NONE. Lake connections where the lake-GWF connection '// &
826 'conductance is solely a function of aquifer properties '// &
827 'in the connected GWF cell should be specified with a '// &
828 'DNODATA (', dnodata,
') value.'
831 call deprecation_warning(
'CONNECTIONDATA',
'bedleak=NONE',
'6.4.3', &
832 warnmsg, this%parser%GetUnit())
834 read (keyword, *) rval
836 is_lake_bed = .false.
840 this%bedleak(ipos) = rval
843 if (is_lake_bed .and. this%bedleak(ipos) < dzero)
then
844 write (
errmsg,
'(a,1x,i0,1x,a)')
'bedleak FOR LAKE ', n,
'MUST BE >= 0'
849 this%belev(ipos) = this%parser%GetDouble()
852 this%telev(ipos) = this%parser%GetDouble()
855 rval = this%parser%GetDouble()
856 if (rval <= dzero)
then
857 if (this%ictype(ipos) == 1 .or. this%ictype(ipos) == 2 .or. &
858 this%ictype(ipos) == 3)
then
859 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,a,1x,a)') &
860 'connection length (connlen) FOR LAKE ', n, &
861 ', CONNECTION NO.', j,
', MUST BE > 0 FOR SPECIFIED ', &
862 'connection type (ctype)', ctypenm
868 this%connlength(ipos) = rval
871 rval = this%parser%GetDouble()
872 if (rval < dzero)
then
873 if (this%ictype(ipos) == 1)
then
874 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
875 'cell width (connwidth) FOR LAKE ', n, &
876 ' HORIZONTAL CONNECTION ', j,
'MUST BE >= 0'
882 this%connwidth(ipos) = rval
884 write (this%iout,
'(1x,a)') &
885 'END OF '//trim(adjustl(this%text))//
' CONNECTIONDATA'
887 call store_error(
'REQUIRED CONNECTIONDATA BLOCK NOT FOUND.')
892 call this%parser%StoreErrorUnit()
896 do n = 1, this%nlakes
898 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
899 if (this%ictype(ipos) /= 2 .and. this%ictype(ipos) /= 3) cycle
902 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
903 'nlakeconn FOR LAKE', n,
'EMBEDDED CONNECTION', j,
' EXCEEDS 1.'
910 do n = 1, this%nlakes
911 ipos0 = this%idxlakeconn(n)
912 icellid0 = this%cellid(ipos0)
913 if (this%ictype(ipos0) /= 2 .and. this%ictype(ipos0) /= 3) cycle
914 do nn = 1, this%nlakes
917 do ipos = this%idxlakeconn(nn), this%idxlakeconn(nn + 1) - 1
919 icellid = this%cellid(ipos)
920 if (icellid == icellid0)
then
921 if (this%ictype(ipos) == 0)
then
922 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
923 'EMBEDDED LAKE', n, &
924 'CANNOT COINCIDE WITH VERTICAL CONNECTION', j, &
934 do n = 1, this%nlakes
936 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
938 nn = this%cellid(ipos)
939 top = this%dis%top(nn)
940 bot = this%dis%bot(nn)
942 if (this%ictype(ipos) == 0)
then
943 this%telev(ipos) = top + this%surfdep
944 this%belev(ipos) = top
945 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
947 else if (this%ictype(ipos) == 1)
then
948 if (this%belev(ipos) == this%telev(ipos))
then
949 this%telev(ipos) = top
950 this%belev(ipos) = bot
952 if (this%belev(ipos) >= this%telev(ipos))
then
953 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
954 'telev FOR LAKE ', n,
' HORIZONTAL CONNECTION ', j, &
957 else if (this%belev(ipos) < bot)
then
958 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
959 'belev FOR LAKE ', n,
' HORIZONTAL CONNECTION ', j, &
960 'MUST BE >= cell bottom (', bot,
')'
962 else if (this%telev(ipos) > top)
then
963 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
964 'telev FOR LAKE ', n,
' HORIZONTAL CONNECTION ', j, &
965 'MUST BE <= cell top (', top,
')'
969 this%laketop(n) = max(this%telev(ipos), this%laketop(n))
970 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
972 else if (this%ictype(ipos) == 2 .or. this%ictype(ipos) == 3)
then
973 this%telev(ipos) = top
974 this%belev(ipos) = bot
975 this%lakebot(n) = bot
979 if (nboundchk(ipos) == 0)
then
980 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
981 'NO DATA SPECIFIED FOR LAKE', n,
'CONNECTION', j
983 else if (nboundchk(ipos) > 1)
then
984 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
985 'DATA FOR LAKE', n,
'CONNECTION', j, &
986 'SPECIFIED', nboundchk(ipos),
'TIMES'
992 if (this%laketop(n) == -dep20)
then
993 this%laketop(n) = this%lakebot(n) + 100.
998 deallocate (nboundchk)
1002 call this%parser%StoreErrorUnit()
1015 class(
laktype),
intent(inout) :: this
1017 type(
laktabtype),
dimension(:),
allocatable :: laketables
1018 character(len=LINELENGTH) :: line
1019 character(len=LINELENGTH) :: keyword
1020 integer(I4B) :: ierr
1021 logical(LGP) :: isfound, endOfBlock
1023 integer(I4B) :: iconn
1024 integer(I4B) :: ntabs
1025 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1028 if (this%ntables < 1)
return
1031 allocate (nboundchk(this%nlakes))
1032 do n = 1, this%nlakes
1037 allocate (laketables(this%nlakes))
1040 call this%parser%GetBlock(
'TABLES', isfound, ierr, &
1041 supportopenclose=.true.)
1047 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1050 call this%parser%GetNextLine(endofblock)
1051 if (endofblock)
exit
1052 n = this%parser%GetInteger()
1054 if (n < 1 .or. n > this%nlakes)
then
1055 write (
errmsg,
'(a,1x,i0)')
'lakeno MUST BE > 0 and <= ', this%nlakes
1062 nboundchk(n) = nboundchk(n) + 1
1065 call this%parser%GetStringCaps(keyword)
1066 select case (keyword)
1068 call this%parser%GetStringCaps(keyword)
1069 if (trim(adjustl(keyword)) /=
'FILEIN')
then
1070 errmsg =
'TAB6 keyword must be followed by "FILEIN" '// &
1075 call this%parser%GetString(line)
1076 call this%lak_read_table(n, line, laketables(n))
1078 write (
errmsg,
'(a,1x,i0,1x,a)') &
1079 'LAKE TABLE ENTRY for LAKE ', n,
'MUST INCLUDE TAB6 KEYWORD'
1085 write (this%iout,
'(1x,a)') &
1086 'END OF '//trim(adjustl(this%text))//
' LAKE_TABLES'
1089 if (ntabs < this%ntables)
then
1090 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1091 'TABLE DATA ARE SPECIFIED', ntabs, &
1092 'TIMES BUT NTABLES IS SET TO', this%ntables
1095 do n = 1, this%nlakes
1096 if (this%ntabrow(n) > 0 .and. nboundchk(n) > 1)
then
1097 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1098 'TABLE DATA FOR LAKE', n,
'SPECIFIED', nboundchk(n),
'TIMES'
1103 call store_error(
'REQUIRED TABLES BLOCK NOT FOUND.')
1107 deallocate (nboundchk)
1111 call this%parser%StoreErrorUnit()
1115 call this%laktables_to_vectors(laketables)
1118 do n = 1, this%nlakes
1119 if (this%ntabrow(n) > 0)
then
1120 deallocate (laketables(n)%tabstage)
1121 deallocate (laketables(n)%tabvolume)
1122 deallocate (laketables(n)%tabsarea)
1123 iconn = this%idxlakeconn(n)
1124 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1125 deallocate (laketables(n)%tabwarea)
1129 deallocate (laketables)
1139 class(
laktype),
intent(inout) :: this
1140 type(
laktabtype),
intent(in),
dimension(:),
contiguous :: laketables
1142 integer(I4B) :: ntabrows
1144 integer(I4B) :: ipos
1145 integer(I4B) :: iconn
1148 call mem_allocate(this%ialaktab, this%nlakes + 1,
'IALAKTAB', this%memoryPath)
1151 this%ialaktab(1) = 1
1152 do n = 1, this%nlakes
1154 this%ialaktab(n + 1) = this%ialaktab(n) + this%ntabrow(n)
1158 ntabrows = this%ialaktab(this%nlakes + 1) - 1
1159 call mem_allocate(this%tabstage, ntabrows,
'TABSTAGE', this%memoryPath)
1160 call mem_allocate(this%tabvolume, ntabrows,
'TABVOLUME', this%memoryPath)
1161 call mem_allocate(this%tabsarea, ntabrows,
'TABSAREA', this%memoryPath)
1162 call mem_allocate(this%tabwarea, ntabrows,
'TABWAREA', this%memoryPath)
1165 do n = 1, this%nlakes
1167 do ipos = this%ialaktab(n), this%ialaktab(n + 1) - 1
1168 this%tabstage(ipos) = laketables(n)%tabstage(j)
1169 this%tabvolume(ipos) = laketables(n)%tabvolume(j)
1170 this%tabsarea(ipos) = laketables(n)%tabsarea(j)
1171 iconn = this%idxlakeconn(n)
1172 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1175 this%tabwarea(ipos) = laketables(n)%tabwarea(j)
1177 this%tabwarea(ipos) =
dzero
1194 class(
laktype),
intent(inout) :: this
1195 integer(I4B),
intent(in) :: ilak
1196 character(len=*),
intent(in) :: filename
1199 character(len=LINELENGTH) :: keyword
1200 integer(I4B) :: ierr
1201 logical(LGP) :: isfound, endOfBlock
1204 integer(I4B) :: ipos
1206 integer(I4B) :: jmin
1207 integer(I4B) :: iconn
1215 character(len=*),
parameter :: fmttaberr = &
1216 &
'(a,1x,i0,1x,a,1x,g15.6,1x,a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.6,1x,a)'
1224 call openfile(iu, this%iout, filename,
'LAKE TABLE')
1225 call parser%Initialize(iu, this%iout)
1228 call parser%GetBlock(
'DIMENSIONS', isfound, ierr, supportopenclose=.true.)
1233 if (this%iprpak /= 0)
then
1234 write (this%iout,
'(/1x,a)') &
1235 'PROCESSING '//trim(adjustl(this%text))//
' DIMENSIONS'
1238 call parser%GetNextLine(endofblock)
1239 if (endofblock)
exit
1240 call parser%GetStringCaps(keyword)
1241 select case (keyword)
1243 n = parser%GetInteger()
1246 write (
errmsg,
'(a)')
'LAKE TABLE NROW MUST BE > 0'
1250 j = parser%GetInteger()
1252 if (this%ictype(ilak) == 2 .or. this%ictype(ilak) == 3)
then
1258 write (
errmsg,
'(a,1x,i0)')
'LAKE TABLE NCOL MUST BE >= ', jmin
1263 write (
errmsg,
'(a,a)') &
1264 'UNKNOWN '//trim(this%text)//
' DIMENSIONS KEYWORD: ', trim(keyword)
1268 if (this%iprpak /= 0)
then
1269 write (this%iout,
'(1x,a)') &
1270 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
1273 call store_error(
'REQUIRED DIMENSIONS BLOCK NOT FOUND.')
1279 'NROW NOT SPECIFIED IN THE LAKE TABLE DIMENSIONS BLOCK'
1284 'NCOL NOT SPECIFIED IN THE LAKE TABLE DIMENSIONS BLOCK'
1293 this%ntabrow(ilak) = n
1294 allocate (laketable%tabstage(n))
1295 allocate (laketable%tabvolume(n))
1296 allocate (laketable%tabsarea(n))
1297 ipos = this%idxlakeconn(ilak)
1298 if (this%ictype(ipos) == 2 .or. this%ictype(ipos) == 3)
then
1299 allocate (laketable%tabwarea(n))
1303 call parser%GetBlock(
'TABLE', isfound, ierr, supportopenclose=.true.)
1309 if (this%iprpak /= 0)
then
1310 write (this%iout,
'(/1x,a)') &
1311 'PROCESSING '//trim(adjustl(this%text))//
' TABLE'
1313 iconn = this%idxlakeconn(ilak)
1316 call parser%GetNextLine(endofblock)
1317 if (endofblock)
exit
1319 if (ipos > this%ntabrow(ilak))
then
1322 laketable%tabstage(ipos) = parser%GetDouble()
1323 laketable%tabvolume(ipos) = parser%GetDouble()
1324 laketable%tabsarea(ipos) = parser%GetDouble()
1325 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1326 laketable%tabwarea(ipos) = parser%GetDouble()
1328 end do readtabledata
1330 if (this%iprpak /= 0)
then
1331 write (this%iout,
'(1x,a)') &
1332 'END OF '//trim(adjustl(this%text))//
' TABLE'
1335 call store_error(
'REQUIRED TABLE BLOCK NOT FOUND.')
1339 if (ipos /= this%ntabrow(ilak))
then
1340 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1341 'NROW SET TO', this%ntabrow(ilak),
'BUT', ipos,
'ROWS WERE READ'
1346 iconn = this%idxlakeconn(ilak)
1347 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1348 do n = 1, this%ntabrow(ilak)
1349 vol = laketable%tabvolume(n)
1350 sa = laketable%tabsarea(n)
1351 wa = laketable%tabwarea(n)
1354 if (vol > dzero)
exit
1356 this%lakebot(ilak) = laketable%tabstage(n)
1357 this%belev(ilak) = laketable%tabstage(n)
1360 n = this%ntabrow(ilak)
1361 this%sareamax(ilak) = laketable%tabsarea(n)
1365 do n = 2, this%ntabrow(ilak)
1366 v = laketable%tabstage(n)
1367 v0 = laketable%tabstage(n - 1)
1369 write (
errmsg, fmttaberr) &
1370 'TABLE STAGE ENTRY', n,
'(', laketable%tabstage(n),
') FOR LAKE ', &
1371 ilak,
'MUST BE GREATER THAN THE PREVIOUS STAGE ENTRY', &
1372 n - 1,
'(', laketable%tabstage(n - 1),
')'
1375 v = laketable%tabvolume(n)
1376 v0 = laketable%tabvolume(n - 1)
1378 write (
errmsg, fmttaberr) &
1379 'TABLE VOLUME ENTRY', n,
'(', laketable%tabvolume(n), &
1381 ilak,
'MUST BE GREATER THAN THE PREVIOUS VOLUME ENTRY', &
1382 n - 1,
'(', laketable%tabvolume(n - 1),
')'
1385 v = laketable%tabsarea(n)
1386 v0 = laketable%tabsarea(n - 1)
1388 write (
errmsg, fmttaberr) &
1389 'TABLE SURFACE AREA ENTRY', n,
'(', &
1390 laketable%tabsarea(n),
') FOR LAKE ', ilak, &
1391 'MUST BE GREATER THAN OR EQUAL TO THE PREVIOUS SURFACE AREA ENTRY', &
1392 n - 1,
'(', laketable%tabsarea(n - 1),
')'
1395 iconn = this%idxlakeconn(ilak)
1396 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1397 v = laketable%tabwarea(n)
1398 v0 = laketable%tabwarea(n - 1)
1400 write (
errmsg, fmttaberr) &
1401 'TABLE EXCHANGE AREA ENTRY', n,
'(', &
1402 laketable%tabwarea(n),
') FOR LAKE ', ilak, &
1403 'MUST BE GREATER THAN OR EQUAL TO THE PREVIOUS EXCHANGE AREA '// &
1404 'ENTRY', n - 1,
'(', laketable%tabwarea(n - 1),
')'
1413 call parser%StoreErrorUnit()
1430 class(
laktype),
intent(inout) :: this
1432 character(len=LINELENGTH) :: text, keyword
1433 character(len=LENBOUNDNAME) :: bndName
1434 character(len=9) :: citem
1435 integer(I4B) :: ierr, ival
1436 logical(LGP) :: isfound, endOfBlock
1439 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1440 real(DP),
pointer :: bndElem => null()
1443 call this%parser%GetBlock(
'OUTLETS', isfound, ierr, &
1444 supportopenclose=.true., blockrequired=.false.)
1448 if (this%noutlets > 0)
then
1451 allocate (nboundchk(this%noutlets))
1452 do n = 1, this%noutlets
1457 call mem_allocate(this%lakein, this%NOUTLETS,
'LAKEIN', this%memoryPath)
1458 call mem_allocate(this%lakeout, this%NOUTLETS,
'LAKEOUT', this%memoryPath)
1459 call mem_allocate(this%iouttype, this%NOUTLETS,
'IOUTTYPE', &
1461 call mem_allocate(this%outrate, this%NOUTLETS,
'OUTRATE', this%memoryPath)
1462 call mem_allocate(this%outinvert, this%NOUTLETS,
'OUTINVERT', &
1464 call mem_allocate(this%outwidth, this%NOUTLETS,
'OUTWIDTH', &
1466 call mem_allocate(this%outrough, this%NOUTLETS,
'OUTROUGH', &
1468 call mem_allocate(this%outslope, this%NOUTLETS,
'OUTSLOPE', &
1470 call mem_allocate(this%simoutrate, this%NOUTLETS,
'SIMOUTRATE', &
1474 do n = 1, this%noutlets
1475 this%outrate(n) = dzero
1479 write (this%iout,
'(/1x,a)') &
1480 'PROCESSING '//trim(adjustl(this%text))//
' OUTLETS'
1482 call this%parser%GetNextLine(endofblock)
1483 if (endofblock)
exit
1484 n = this%parser%GetInteger()
1486 if (n < 1 .or. n > this%noutlets)
then
1487 write (
errmsg,
'(a,1x,i0)') &
1488 'outletno MUST BE > 0 and <= ', this%noutlets
1494 nboundchk(n) = nboundchk(n) + 1
1497 ival = this%parser%GetInteger()
1498 if (ival < 1 .or. ival > this%nlakes)
then
1499 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1500 'lakein FOR OUTLET ', n,
'MUST BE > 0 and <= ', this%nlakes
1504 this%lakein(n) = ival
1507 ival = this%parser%GetInteger()
1508 if (ival < 0 .or. ival > this%nlakes)
then
1509 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1510 'lakeout FOR OUTLET ', n,
'MUST BE >= 0 and <= ', this%nlakes
1514 this%lakeout(n) = ival
1517 call this%parser%GetStringCaps(keyword)
1518 select case (keyword)
1520 this%iouttype(n) = 0
1522 this%iouttype(n) = 1
1524 this%iouttype(n) = 2
1526 write (
errmsg,
'(a,1x,i0,1x,a,a,a)') &
1527 'UNKNOWN couttype FOR OUTLET ', n,
'(', trim(keyword),
')'
1533 write (citem,
'(i9.9)') n
1534 bndname =
'OUTLET'//citem
1540 call this%parser%GetString(text)
1541 bndelem => this%outinvert(n)
1543 this%packName,
'BND', &
1544 this%tsManager, this%iprpak, &
1548 call this%parser%GetString(text)
1549 bndelem => this%outwidth(n)
1551 this%packName,
'BND', &
1552 this%tsManager, this%iprpak,
'WIDTH')
1555 call this%parser%GetString(text)
1556 bndelem => this%outrough(n)
1558 this%packName,
'BND', &
1559 this%tsManager, this%iprpak,
'ROUGH')
1562 call this%parser%GetString(text)
1563 bndelem => this%outslope(n)
1565 this%packName,
'BND', &
1566 this%tsManager, this%iprpak,
'SLOPE')
1568 write (this%iout,
'(1x,a)')
'END OF '//trim(adjustl(this%text))// &
1572 do n = 1, this%noutlets
1573 if (nboundchk(n) == 0)
then
1574 write (
errmsg,
'(a,1x,i0)')
'NO DATA SPECIFIED FOR OUTLET', n
1576 else if (nboundchk(n) > 1)
then
1577 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1578 'DATA FOR OUTLET', n,
'SPECIFIED', nboundchk(n),
'TIMES'
1584 deallocate (nboundchk)
1586 write (
errmsg,
'(a,1x,a)') &
1587 'AN OUTLETS BLOCK SHOULD NOT BE SPECIFIED IF NOUTLETS IS NOT', &
1588 'SPECIFIED OR IS SPECIFIED TO BE 0.'
1593 if (this%noutlets > 0)
then
1594 call store_error(
'REQUIRED OUTLETS BLOCK NOT FOUND.')
1601 call this%parser%StoreErrorUnit()
1614 class(
laktype),
intent(inout) :: this
1616 character(len=LINELENGTH) :: keyword
1617 integer(I4B) :: ierr
1618 logical(LGP) :: isfound, endOfBlock
1625 call this%parser%GetBlock(
'DIMENSIONS', isfound, ierr, &
1626 supportopenclose=.true.)
1630 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1633 call this%parser%GetNextLine(endofblock)
1634 if (endofblock)
exit
1635 call this%parser%GetStringCaps(keyword)
1636 select case (keyword)
1638 this%nlakes = this%parser%GetInteger()
1639 write (this%iout,
'(4x,a,i7)')
'NLAKES = ', this%nlakes
1641 this%noutlets = this%parser%GetInteger()
1642 write (this%iout,
'(4x,a,i7)')
'NOUTLETS = ', this%noutlets
1644 this%ntables = this%parser%GetInteger()
1645 write (this%iout,
'(4x,a,i7)')
'NTABLES = ', this%ntables
1647 write (
errmsg,
'(a,a)') &
1648 'UNKNOWN '//trim(this%text)//
' DIMENSION: ', trim(keyword)
1652 write (this%iout,
'(1x,a)') &
1653 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
1655 call store_error(
'REQUIRED DIMENSIONS BLOCK NOT FOUND.')
1658 if (this%nlakes < 0)
then
1660 'NLAKES WAS NOT SPECIFIED OR WAS SPECIFIED INCORRECTLY.'
1666 call this%parser%StoreErrorUnit()
1670 call this%lak_read_lakes()
1673 call this%lak_read_lake_connections()
1676 call this%lak_read_tables()
1679 call this%lak_read_outlets()
1683 call this%define_listlabel()
1686 call this%lak_setup_budobj()
1689 call this%lak_setup_tableobj()
1703 class(
laktype),
intent(inout) :: this
1705 character(len=LINELENGTH) :: text
1706 integer(I4B) :: j, jj, n
1723 real(DP),
allocatable,
dimension(:) :: clb, caq
1724 character(len=14) :: cbedleak
1725 character(len=14) :: cbedcond
1726 character(len=10),
dimension(0:3) :: ctype
1727 character(len=15) :: nodestr
1728 real(DP),
pointer :: bndElem => null()
1730 data ctype(0)/
'VERTICAL '/
1731 data ctype(1)/
'HORIZONTAL'/
1732 data ctype(2)/
'EMBEDDEDH '/
1733 data ctype(3)/
'EMBEDDEDV '/
1736 do n = 1, this%nlakes
1737 this%xnewpak(n) = this%strt(n)
1738 write (text,
'(g15.7)') this%strt(n)
1740 bndelem => this%stage(n)
1742 'BND', this%tsManager, this%iprpak, &
1747 do n = 1, this%nlakes
1748 if (this%status(n) ==
'CONSTANT')
then
1749 this%iboundpak(n) = -1
1750 else if (this%status(n) ==
'INACTIVE')
then
1751 this%iboundpak(n) = 0
1752 else if (this%status(n) ==
'ACTIVE ')
then
1753 this%iboundpak(n) = 1
1758 if (this%inamedbound /= 0)
then
1759 do n = 1, this%nlakes
1760 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1761 this%boundname(j) = this%lakename(n)
1767 call this%copy_boundname()
1777 allocate (clb(this%MAXBOUND))
1778 allocate (caq(this%MAXBOUND))
1781 do n = 1, this%nlakes
1782 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1784 top = this%dis%top(nn)
1785 bot = this%dis%bot(nn)
1787 if (this%ictype(j) == 0)
then
1788 area = this%dis%area(nn)
1789 this%sarea(j) = area
1790 this%warea(j) = area
1791 this%sareamax(n) = this%sareamax(n) + area
1792 if (this%gwfik33 == 0)
then
1797 length = dhalf * (top - bot)
1799 else if (this%ictype(j) == 1)
then
1800 area = (this%telev(j) - this%belev(j)) * this%connwidth(j)
1803 if (top == this%telev(j) .and. bot == this%belev(j))
then
1804 if (this%icelltype(nn) == 0)
then
1805 area = this%gwfsat(nn) * (top - bot) * this%connwidth(j)
1808 this%sarea(j) = dzero
1809 this%warea(j) = area
1810 this%sareamax(n) = this%sareamax(n) + dzero
1812 length = this%connlength(j)
1814 else if (this%ictype(j) == 2)
then
1816 this%sarea(j) = dzero
1817 this%warea(j) = area
1818 this%sareamax(n) = this%sareamax(n) + dzero
1820 length = this%connlength(j)
1822 else if (this%ictype(j) == 3)
then
1824 this%sarea(j) = dzero
1825 this%warea(j) = area
1826 this%sareamax(n) = this%sareamax(n) + dzero
1827 if (this%gwfik33 == 0)
then
1832 length = this%connlength(j)
1834 if (
is_close(this%bedleak(j), dnodata))
then
1836 else if (this%bedleak(j) > dzero)
then
1837 clb(j) = done / this%bedleak(j)
1846 if (
is_close(this%bedleak(j), dnodata))
then
1847 this%satcond(j) = area / caq(j)
1848 else if (clb(j) * caq(j) > dzero)
then
1849 this%satcond(j) = area / (clb(j) + caq(j))
1851 this%satcond(j) = dzero
1857 if (this%iprpak > 0)
then
1858 write (this%iout,
'(//,29x,a,/)') &
1859 'INTERFACE CONDUCTANCE BETWEEN LAKE AND AQUIFER CELLS'
1860 write (this%iout,
'(1x,a)') &
1861 &
' LAKE CONNECTION CONNECTION LAKEBED'// &
1862 &
' C O N D U C T A N C E S '
1863 write (this%iout,
'(1x,a)') &
1864 &
' NUMBER NUMBER CELLID DIRECTION LEAKANCE'// &
1865 &
' LAKEBED AQUIFER COMBINED'
1866 write (this%iout,
"(1x,108('-'))")
1867 do n = 1, this%nlakes
1869 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1872 if (this%ictype(j) == 1)
then
1873 fact = this%telev(j) - this%belev(j)
1874 if (abs(fact) > dzero)
then
1879 area = this%warea(j)
1881 if (
is_close(clb(j), dnodata))
then
1884 else if (clb(j) > dzero)
then
1885 c1 = area * fact / clb(j)
1886 write (cbedleak,
'(g14.5)') this%bedleak(j)
1887 write (cbedcond,
'(g14.5)') c1
1889 write (cbedleak,
'(g14.5)') c1
1890 write (cbedcond,
'(g14.5)') c1
1893 if (caq(j) > dzero)
then
1894 c2 = area * fact / caq(j)
1896 call this%dis%noder_to_string(nn, nodestr)
1898 '(1x,i10,1x,i10,1x,a15,1x,a10,2(1x,a14),2(1x,g14.5))') &
1899 n, idx, nodestr, ctype(this%ictype(j)), cbedleak, &
1900 cbedcond, c2, this%satcond(j) * fact
1903 write (this%iout,
"(1x,108('-'))")
1904 write (this%iout,
'(1x,a)') &
1905 'IF VERTICAL CONNECTION, CONDUCTANCE (L^2/T) IS &
1906 &BETWEEN AQUIFER CELL AND OVERLYING LAKE CELL.'
1907 write (this%iout,
'(1x,a)') &
1908 'IF HORIZONTAL CONNECTION, CONDUCTANCES ARE PER &
1909 &UNIT SATURATED THICKNESS (L/T).'
1910 write (this%iout,
'(1x,a)') &
1911 'IF EMBEDDED CONNECTION, CONDUCTANCES ARE PER &
1912 &UNIT EXCHANGE AREA (1/T).'
1917 do n = 1, this%nlakes
1918 write (this%iout,
'(//1x,a,1x,i10)')
'STAGE/VOLUME RELATION FOR LAKE ', n
1919 write (this%iout,
'(/1x,5(a14))')
' STAGE',
' SURFACE AREA', &
1920 &
' WETTED AREA',
' CONDUCTANCE', &
1922 write (this%iout,
"(1x,70('-'))")
1923 dx = (this%laketop(n) - this%lakebot(n)) / 150.
1926 call this%lak_calculate_conductance(n, s, c)
1927 call this%lak_calculate_sarea(n, s, sa)
1928 call this%lak_calculate_warea(n, s, wa, s)
1929 call this%lak_calculate_vol(n, s, v)
1930 write (this%iout,
'(1x,5(E14.5))') s, sa, wa, c, v
1933 write (this%iout,
"(1x,70('-'))")
1935 write (this%iout,
'(//1x,a,1x,i10)')
'STAGE/VOLUME RELATION FOR LAKE ', n
1936 write (this%iout,
'(/1x,4(a14))')
' ',
' ', &
1937 &
' CALCULATED',
' STAGE'
1938 write (this%iout,
'(1x,4(a14))')
' STAGE',
' VOLUME', &
1939 &
' STAGE',
' DIFFERENCE'
1940 write (this%iout,
"(1x,56('-'))")
1941 s = this%lakebot(n) - dx
1943 call this%lak_calculate_vol(n, s, v)
1944 call this%lak_vol2stage(n, v, c)
1945 write (this%iout,
'(1x,4(E14.5))') s, v, c, s - c
1948 write (this%iout,
"(1x,56('-'))")
1953 this%gwfk11 => null()
1954 this%gwfk33 => null()
1955 this%gwfsat => null()
1956 this%gwfik33 => null()
1972 class(
laktype),
intent(inout) :: this
1973 integer(I4B),
intent(in) :: n
1974 real(DP),
dimension(n),
intent(in) :: x
1975 real(DP),
dimension(n),
intent(in) :: y
1976 real(DP),
intent(in) :: z
1977 real(DP),
intent(inout) :: v
1980 real(DP) :: dx, dydx
1988 else if (z > x(n))
then
1989 dx = x(n) - x(n - 1)
1991 if (abs(dx) >
dzero)
then
1992 dydx = (y(n) - y(n - 1)) / dx
1995 v = y(n) + dydx * dx
1999 dx = x(i) - x(i - 1)
2001 if (z >= x(i - 1) .and. z <= x(i))
then
2002 if (abs(dx) >
dzero)
then
2003 dydx = (y(i) - y(i - 1)) / dx
2006 v = y(i - 1) + dydx * dx
2020 class(
laktype),
intent(inout) :: this
2021 integer(I4B),
intent(in) :: ilak
2022 real(DP),
intent(in) :: stage
2023 real(DP),
intent(inout) :: sarea
2026 integer(I4B) :: ifirst
2027 integer(I4B) :: ilast
2034 i = this%ntabrow(ilak)
2036 ifirst = this%ialaktab(ilak)
2037 ilast = this%ialaktab(ilak + 1) - 1
2038 if (stage <= this%tabstage(ifirst))
then
2039 sarea = this%tabsarea(ifirst)
2040 else if (stage >= this%tabstage(ilast))
then
2041 sarea = this%tabsarea(ilast)
2043 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2044 this%tabsarea(ifirst:ilast), &
2048 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2049 topl = this%telev(i)
2050 botl = this%belev(i)
2052 sa = sat * this%sarea(i)
2065 class(
laktype),
intent(inout) :: this
2066 integer(I4B),
intent(in) :: ilak
2067 real(DP),
intent(in) :: stage
2068 real(DP),
intent(inout) :: warea
2069 real(DP),
optional,
intent(inout) :: hin
2072 integer(I4B) :: igwfnode
2077 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2078 if (
present(hin))
then
2081 igwfnode = this%cellid(i)
2082 head = this%xnew(igwfnode)
2084 call this%lak_calculate_conn_warea(ilak, i, stage, head, wa)
2096 class(
laktype),
intent(inout) :: this
2097 integer(I4B),
intent(in) :: ilak
2098 integer(I4B),
intent(in) :: iconn
2099 real(DP),
intent(in) :: stage
2100 real(DP),
intent(in) :: head
2101 real(DP),
intent(inout) :: wa
2104 integer(I4B) :: ifirst
2105 integer(I4B) :: ilast
2106 integer(I4B) :: node
2113 topl = this%telev(iconn)
2114 botl = this%belev(iconn)
2115 call this%lak_calculate_cond_head(iconn, stage, head, vv)
2116 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
2117 if (vv > topl) vv = topl
2118 i = this%ntabrow(ilak)
2119 ifirst = this%ialaktab(ilak)
2120 ilast = this%ialaktab(ilak + 1) - 1
2121 if (vv <= this%tabstage(ifirst))
then
2122 wa = this%tabwarea(ifirst)
2123 else if (vv >= this%tabstage(ilast))
then
2124 wa = this%tabwarea(ilast)
2126 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2127 this%tabwarea(ifirst:ilast), &
2131 node = this%cellid(iconn)
2133 if (this%icelltype(node) == 0)
then
2139 wa = sat * this%warea(iconn)
2150 class(
laktype),
intent(inout) :: this
2151 integer(I4B),
intent(in) :: ilak
2152 real(DP),
intent(in) :: stage
2153 real(DP),
intent(inout) :: volume
2156 integer(I4B) :: ifirst
2157 integer(I4B) :: ilast
2166 i = this%ntabrow(ilak)
2168 ifirst = this%ialaktab(ilak)
2169 ilast = this%ialaktab(ilak + 1) - 1
2170 if (stage <= this%tabstage(ifirst))
then
2171 volume = this%tabvolume(ifirst)
2172 else if (stage >= this%tabstage(ilast))
then
2173 ds = stage - this%tabstage(ilast)
2174 sa = this%tabsarea(ilast)
2175 volume = this%tabvolume(ilast) + ds * sa
2177 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2178 this%tabvolume(ifirst:ilast), &
2182 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2183 topl = this%telev(i)
2184 botl = this%belev(i)
2186 sa = sat * this%sarea(i)
2187 if (stage < botl)
then
2189 else if (stage > botl .and. stage < topl)
then
2190 v = sa * (stage - botl)
2192 v = sa * (topl - botl) + sa * (stage - topl)
2206 class(
laktype),
intent(inout) :: this
2207 integer(I4B),
intent(in) :: ilak
2208 real(DP),
intent(in) :: stage
2209 real(DP),
intent(inout) :: conductance
2215 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2216 call this%lak_calculate_conn_conductance(ilak, i, stage, stage, c)
2217 conductance = conductance + c
2230 class(
laktype),
intent(inout) :: this
2231 integer(I4B),
intent(in) :: iconn
2232 real(DP),
intent(in) :: stage
2233 real(DP),
intent(in) :: head
2234 real(DP),
intent(inout) :: vv
2241 topl = this%telev(iconn)
2242 botl = this%belev(iconn)
2243 ss = min(stage, topl)
2244 hh = min(head, topl)
2245 if (this%igwhcopt > 0)
then
2247 else if (this%inewton > 0)
then
2250 vv =
dhalf * (ss + hh)
2262 class(
laktype),
intent(inout) :: this
2263 integer(I4B),
intent(in) :: ilak
2264 integer(I4B),
intent(in) :: iconn
2265 real(DP),
intent(in) :: stage
2266 real(DP),
intent(in) :: head
2267 real(DP),
intent(inout) :: cond
2269 integer(I4B) :: node
2277 real(DP) :: vscratio
2281 topl = this%telev(iconn)
2282 botl = this%belev(iconn)
2283 call this%lak_calculate_cond_head(iconn, stage, head, vv)
2288 if (this%ictype(iconn) == 0)
then
2289 if (abs(topl - botl) <
dprec)
then
2294 else if (this%ictype(iconn) == 1)
then
2295 node = this%cellid(iconn)
2296 if (this%icelltype(node) == 0)
then
2300 else if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
2301 node = this%cellid(iconn)
2302 if (this%icelltype(node) == 0)
then
2303 vv = this%telev(iconn)
2304 call this%lak_calculate_conn_warea(ilak, iconn, vv, vv, wa)
2306 call this%lak_calculate_conn_warea(ilak, iconn, stage, head, wa)
2312 if (this%ivsc == 1)
then
2314 if (stage > head)
then
2315 vscratio = this%viscratios(1, iconn)
2318 vscratio = this%viscratios(2, iconn)
2321 cond = sat * this%satcond(iconn) * vscratio
2331 class(
laktype),
intent(inout) :: this
2332 integer(I4B),
intent(in) :: ilak
2333 real(DP),
intent(in) :: stage
2334 real(DP),
intent(inout) :: totflow
2337 integer(I4B) :: igwfnode
2342 do j = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2343 igwfnode = this%cellid(j)
2344 hgwf = this%xnew(igwfnode)
2345 call this%lak_calculate_conn_exchange(ilak, j, stage, hgwf, flow)
2346 totflow = totflow + flow
2359 class(
laktype),
intent(inout) :: this
2360 integer(I4B),
intent(in) :: ilak
2361 integer(I4B),
intent(in) :: iconn
2362 real(DP),
intent(in) :: stage
2363 real(DP),
intent(in) :: head
2364 real(DP),
intent(inout) :: flow
2365 real(DP),
intent(inout),
optional :: gwfhcof
2366 real(DP),
intent(inout),
optional :: gwfrhs
2372 real(DP) :: gwfhcof0
2376 call this%lak_calculate_conn_conductance(ilak, iconn, stage, head, cond)
2377 botl = this%belev(iconn)
2380 if (stage >= botl)
then
2387 if (head >= botl)
then
2394 flow = cond * (hh - ss)
2397 if (head >= botl)
then
2399 gwfrhs0 = -cond * ss
2406 if (this%idense /= 0)
then
2407 call this%lak_calculate_density_exchange(iconn, stage, head, cond, botl, &
2408 flow, gwfhcof0, gwfrhs0)
2412 if (
present(gwfhcof)) gwfhcof = gwfhcof0
2413 if (
present(gwfrhs)) gwfrhs = gwfrhs0
2423 head, flow, source, gwfhcof, gwfrhs)
2425 class(
laktype),
intent(inout) :: this
2426 integer(I4B),
intent(in) :: iflag
2427 integer(I4B),
intent(in) :: ilak
2428 integer(I4B),
intent(in) :: iconn
2429 integer(I4B),
intent(inout) :: idry
2430 real(DP),
intent(in) :: stage
2431 real(DP),
intent(in) :: head
2432 real(DP),
intent(inout) :: flow
2433 real(DP),
intent(inout) :: source
2434 real(DP),
intent(inout),
optional :: gwfhcof
2435 real(DP),
intent(inout),
optional :: gwfrhs
2437 real(DP) :: gwfhcof0, gwfrhs0
2441 call this%lak_calculate_conn_exchange(ilak, iconn, stage, head, flow, &
2443 if (iflag == 1)
then
2444 if (flow >
dzero)
then
2445 source = source + flow
2447 else if (iflag == 2)
then
2448 if (-flow > source)
then
2452 else if (flow <
dzero)
then
2453 source = source + flow
2458 if (
present(gwfhcof)) gwfhcof = gwfhcof0
2459 if (
present(gwfrhs)) gwfrhs = gwfrhs0
2470 class(
laktype),
intent(inout) :: this
2471 integer(I4B),
intent(in) :: ilak
2472 real(DP),
intent(in) :: stage
2473 real(DP),
intent(in) :: stage0
2474 real(DP),
intent(in) :: delt
2475 real(DP),
intent(inout) :: dvr
2481 if (this%gwfiss /= 1)
then
2482 call this%lak_calculate_vol(ilak, stage, v)
2483 call this%lak_calculate_vol(ilak, stage0, v0)
2484 dvr = (v0 - v) / delt
2495 class(
laktype),
intent(inout) :: this
2496 integer(I4B),
intent(in) :: ilak
2497 real(DP),
intent(in) :: stage
2498 real(DP),
intent(inout) :: ra
2500 integer(I4B) :: iconn
2504 iconn = this%idxlakeconn(ilak)
2505 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
2506 sa = this%sareamax(ilak)
2508 call this%lak_calculate_sarea(ilak, stage, sa)
2510 ra = this%rainfall(ilak) * sa
2520 class(
laktype),
intent(inout) :: this
2521 integer(I4B),
intent(in) :: ilak
2522 real(DP),
intent(inout) :: ro
2525 ro = this%runoff(ilak)
2535 class(
laktype),
intent(inout) :: this
2536 integer(I4B),
intent(in) :: ilak
2537 real(DP),
intent(inout) :: qin
2540 qin = this%inflow(ilak)
2550 class(
laktype),
intent(inout) :: this
2551 integer(I4B),
intent(in) :: ilak
2552 real(DP),
intent(inout) :: ex
2557 if (this%imover == 1)
then
2558 ex = this%pakmvrobj%get_qfrommvr(ilak)
2569 class(
laktype),
intent(inout) :: this
2570 integer(I4B),
intent(in) :: ilak
2571 real(DP),
intent(inout) :: avail
2572 real(DP),
intent(inout) :: wr
2575 wr = this%withdrawal(ilak)
2576 if (wr > avail)
then
2579 if (wr >
dzero)
then
2594 class(
laktype),
intent(inout) :: this
2595 integer(I4B),
intent(in) :: ilak
2596 real(DP),
intent(in) :: stage
2597 real(DP),
intent(inout) :: avail
2598 real(DP),
intent(inout) :: ev
2603 call this%lak_calculate_sarea(ilak, stage, sa)
2604 ev = sa * this%evaporation(ilak)
2605 if (ev > avail)
then
2624 class(
laktype),
intent(inout) :: this
2625 integer(I4B),
intent(in) :: ilak
2626 real(DP),
intent(inout) :: outinf
2631 do n = 1, this%noutlets
2632 if (this%lakeout(n) == ilak)
then
2633 outinf = outinf - this%simoutrate(n)
2634 if (this%imover == 1)
then
2635 outinf = outinf - this%pakmvrobj%get_qtomvr(n)
2648 class(
laktype),
intent(inout) :: this
2649 integer(I4B),
intent(in) :: ilak
2650 real(DP),
intent(in) :: stage
2651 real(DP),
intent(inout) :: avail
2652 real(DP),
intent(inout) :: outoutf
2662 do n = 1, this%noutlets
2663 if (this%lakein(n) == ilak)
then
2665 d = stage - this%outinvert(n)
2666 if (this%outdmax >
dzero)
then
2667 if (d > this%outdmax) d = this%outdmax
2669 g =
dgravity * this%convlength * this%convtime * this%convtime
2670 select case (this%iouttype(n))
2673 rate = this%outrate(n)
2674 if (-rate > avail)
then
2680 c = (this%convlength**
donethird) * this%convtime
2682 if (this%outrough(n) >
dzero)
then
2683 gsm =
done / this%outrough(n)
2685 rate = -c * gsm * this%outwidth(n) * (d**
dfivethirds) * &
2686 sqrt(this%outslope(n))
2695 this%simoutrate(n) = rate
2696 avail = avail + rate
2697 outoutf = outoutf + rate
2709 class(
laktype),
intent(inout) :: this
2710 integer(I4B),
intent(in) :: ilak
2711 real(DP),
intent(inout) :: outinf
2716 do n = 1, this%noutlets
2717 if (this%lakeout(n) == ilak)
then
2718 outinf = outinf - this%simoutrate(n)
2719 if (this%imover == 1)
then
2720 outinf = outinf - this%pakmvrobj%get_qtomvr(n)
2733 class(
laktype),
intent(inout) :: this
2734 integer(I4B),
intent(in) :: ilak
2735 real(DP),
intent(inout) :: outoutf
2740 do n = 1, this%noutlets
2741 if (this%lakein(n) == ilak)
then
2742 if (this%lakeout(n) < 1) cycle
2743 outoutf = outoutf + this%simoutrate(n)
2755 class(
laktype),
intent(inout) :: this
2756 integer(I4B),
intent(in) :: ilak
2757 real(DP),
intent(inout) :: outoutf
2762 do n = 1, this%noutlets
2763 if (this%lakein(n) == ilak)
then
2764 if (this%lakeout(n) > 0) cycle
2765 outoutf = outoutf + this%simoutrate(n)
2777 class(
laktype),
intent(inout) :: this
2778 integer(I4B),
intent(in) :: ilak
2779 real(DP),
intent(inout) :: outoutf
2784 if (this%imover == 1)
then
2785 do n = 1, this%noutlets
2786 if (this%lakein(n) == ilak)
then
2787 if (this%lakeout(n) > 0) cycle
2788 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2801 class(
laktype),
intent(inout) :: this
2802 integer(I4B),
intent(in) :: ilak
2803 real(DP),
intent(inout) :: outoutf
2808 if (this%imover == 1)
then
2809 do n = 1, this%noutlets
2810 if (this%lakein(n) == ilak)
then
2811 if (this%lakeout(n) < 1) cycle
2812 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2825 class(
laktype),
intent(inout) :: this
2826 integer(I4B),
intent(in) :: ilak
2827 real(DP),
intent(inout) :: outoutf
2832 if (this%imover == 1)
then
2833 do n = 1, this%noutlets
2834 if (this%lakein(n) == ilak)
then
2835 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2848 class(
laktype),
intent(inout) :: this
2849 integer(I4B),
intent(in) :: ilak
2850 real(DP),
intent(in) :: vol
2851 real(DP),
intent(inout) :: stage
2855 real(DP) :: s0, s1, sm
2856 real(DP) :: v0, v1, vm
2857 real(DP) :: f0, f1, fm
2859 real(DP) :: en0, en1
2863 s0 = this%lakebot(ilak)
2864 call this%lak_calculate_vol(ilak, s0, v0)
2865 s1 = this%laketop(ilak)
2866 call this%lak_calculate_vol(ilak, s1, v1)
2871 else if (vol >= v1)
then
2872 call this%lak_calculate_sarea(ilak, s1, sa)
2873 stage = s1 + (vol - v1) / sa
2884 secantbisection:
do i = 1, 150
2886 if (denom /=
dzero)
then
2887 ds = f1 * (s1 - s0) / denom
2895 if (sm < en0 .or. sm > en1) ibs = 13
2899 if (ds * ds0 <
dprec .or. abs(ds) > abs(ds0)) ibs = ibs + 1
2901 ds =
dhalf * (s1 - s0)
2905 if (abs(ds) <
dem6)
then
2906 exit secantbisection
2908 call this%lak_calculate_vol(ilak, sm, vm)
2915 end do secantbisection
2917 if (abs(ds) >=
dem6)
then
2918 write (this%iout,
'(1x,a,1x,i0,4(1x,a,1x,g15.6))') &
2919 &
'LAK_VOL2STAGE failed for lake', ilak,
'volume error =', fm, &
2920 &
'finding stage (', stage,
') for volume =', vol, &
2921 &
'final change in stage =', ds
2934 integer(I4B) :: ierr
2936 class(
laktype),
intent(inout) :: this
2937 integer(I4B),
intent(in) :: itemno
2939 integer(I4B) :: ival
2943 if (itemno > 0)
then
2944 if (ival < 1 .or. ival > this%nlakes)
then
2945 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,a)') &
2946 'LAKENO', itemno,
'must be greater than 0 and less than or equal to', &
2952 if (ival < 1 .or. ival > this%noutlets)
then
2953 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,a)') &
2954 'IOUTLET', itemno,
'must be greater than 0 and less than or equal to', &
2972 class(
laktype),
intent(inout) :: this
2973 integer(I4B),
intent(in) :: itemno
2975 character(len=LINELENGTH) :: text
2976 character(len=LINELENGTH) :: caux
2977 character(len=LINELENGTH) :: keyword
2978 integer(I4B) :: ierr
2981 real(DP),
pointer :: bndElem => null()
2984 call this%parser%GetStringCaps(keyword)
2985 select case (keyword)
2987 ierr = this%lak_check_valid(itemno)
2991 call this%parser%GetStringCaps(text)
2992 this%status(itemno) = text(1:8)
2993 if (text ==
'CONSTANT')
then
2994 this%iboundpak(itemno) = -1
2995 else if (text ==
'INACTIVE')
then
2996 this%iboundpak(itemno) = 0
2997 else if (text ==
'ACTIVE')
then
2998 this%iboundpak(itemno) = 1
3000 write (
errmsg,
'(a,a)') &
3001 'Unknown '//trim(this%text)//
' lak status keyword: ', text//
'.'
3005 ierr = this%lak_check_valid(itemno)
3009 call this%parser%GetString(text)
3011 bndelem => this%stage(itemno)
3013 this%packName,
'BND', this%tsManager, &
3014 this%iprpak,
'STAGE')
3016 ierr = this%lak_check_valid(itemno)
3020 call this%parser%GetString(text)
3022 bndelem => this%rainfall(itemno)
3024 this%packName,
'BND', this%tsManager, &
3025 this%iprpak,
'RAINFALL')
3026 if (this%rainfall(itemno) <
dzero)
then
3027 write (
errmsg,
'(a,i0,a,G0,a)') &
3028 'Lake ', itemno,
' was assigned a rainfall value of ', &
3029 this%rainfall(itemno),
'. Rainfall must be positive.'
3032 case (
'EVAPORATION')
3033 ierr = this%lak_check_valid(itemno)
3037 call this%parser%GetString(text)
3039 bndelem => this%evaporation(itemno)
3041 this%packName,
'BND', this%tsManager, &
3042 this%iprpak,
'EVAPORATION')
3043 if (this%evaporation(itemno) <
dzero)
then
3044 write (
errmsg,
'(a,i0,a,G0,a)') &
3045 'Lake ', itemno,
' was assigned an evaporation value of ', &
3046 this%evaporation(itemno),
'. Evaporation must be positive.'
3050 ierr = this%lak_check_valid(itemno)
3054 call this%parser%GetString(text)
3056 bndelem => this%runoff(itemno)
3058 this%packName,
'BND', this%tsManager, &
3059 this%iprpak,
'RUNOFF')
3060 if (this%runoff(itemno) <
dzero)
then
3061 write (
errmsg,
'(a,i0,a,G0,a)') &
3062 'Lake ', itemno,
' was assigned a runoff value of ', &
3063 this%runoff(itemno),
'. Runoff must be positive.'
3067 ierr = this%lak_check_valid(itemno)
3071 call this%parser%GetString(text)
3073 bndelem => this%inflow(itemno)
3075 this%packName,
'BND', this%tsManager, &
3076 this%iprpak,
'INFLOW')
3077 if (this%inflow(itemno) <
dzero)
then
3078 write (
errmsg,
'(a,i0,a,G0,a)') &
3079 'Lake ', itemno,
' was assigned an inflow value of ', &
3080 this%inflow(itemno),
'. Inflow must be positive.'
3084 ierr = this%lak_check_valid(itemno)
3088 call this%parser%GetString(text)
3090 bndelem => this%withdrawal(itemno)
3092 this%packName,
'BND', this%tsManager, &
3093 this%iprpak,
'WITHDRAWAL')
3094 if (this%withdrawal(itemno) <
dzero)
then
3095 write (
errmsg,
'(a,i0,a,G0,a)') &
3096 'Lake ', itemno,
' was assigned a withdrawal value of ', &
3097 this%withdrawal(itemno),
'. Withdrawal must be positive.'
3101 ierr = this%lak_check_valid(-itemno)
3105 call this%parser%GetString(text)
3107 bndelem => this%outrate(itemno)
3109 this%packName,
'BND', this%tsManager, &
3110 this%iprpak,
'RATE')
3112 ierr = this%lak_check_valid(-itemno)
3116 call this%parser%GetString(text)
3118 bndelem => this%outinvert(itemno)
3120 this%packName,
'BND', this%tsManager, &
3121 this%iprpak,
'INVERT')
3123 ierr = this%lak_check_valid(-itemno)
3127 call this%parser%GetString(text)
3129 bndelem => this%outwidth(itemno)
3131 this%packName,
'BND', this%tsManager, &
3132 this%iprpak,
'WIDTH')
3134 ierr = this%lak_check_valid(-itemno)
3138 call this%parser%GetString(text)
3140 bndelem => this%outrough(itemno)
3142 this%packName,
'BND', this%tsManager, &
3143 this%iprpak,
'ROUGH')
3145 ierr = this%lak_check_valid(-itemno)
3149 call this%parser%GetString(text)
3151 bndelem => this%outslope(itemno)
3153 this%packName,
'BND', this%tsManager, &
3154 this%iprpak,
'SLOPE')
3156 ierr = this%lak_check_valid(itemno)
3160 call this%parser%GetStringCaps(caux)
3161 do jj = 1, this%naux
3162 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
3163 call this%parser%GetString(text)
3165 bndelem => this%lauxvar(jj, ii)
3167 this%packName,
'AUX', &
3168 this%tsManager, this%iprpak, &
3174 'Unknown '//trim(this%text)//
' lak data keyword: ', &
3190 class(
laktype),
intent(inout) :: this
3191 integer(I4B),
intent(in) :: ilak
3192 character(len=*),
intent(in) :: keyword
3193 character(len=*),
intent(in) :: msg
3195 if (len(msg) == 0)
then
3196 write (
errmsg,
'(a,1x,a,1x,i0,1x,a)') &
3197 keyword,
' for LAKE', ilak,
'has already been set.'
3199 write (
errmsg,
'(a,1x,a,1x,i0,1x,a)') keyword,
' for LAKE', ilak, msg
3217 class(
laktype),
intent(inout) :: this
3218 character(len=*),
intent(inout) :: option
3219 logical(LGP),
intent(inout) :: found
3221 character(len=MAXCHARLEN) :: fname, keyword
3224 character(len=*),
parameter :: fmtlengthconv = &
3225 &
"(4x, 'LENGTH CONVERSION VALUE (',g15.7,') SPECIFIED.')"
3226 character(len=*),
parameter :: fmttimeconv = &
3227 &
"(4x, 'TIME CONVERSION VALUE (',g15.7,') SPECIFIED.')"
3228 character(len=*),
parameter :: fmtoutdmax = &
3229 &
"(4x, 'MAXIMUM OUTLET WATER DEPTH (',g15.7,') SPECIFIED.')"
3230 character(len=*),
parameter :: fmtlakeopt = &
3231 &
"(4x, 'LAKE ', a, ' VALUE (',g15.7,') SPECIFIED.')"
3232 character(len=*),
parameter :: fmtlakbin = &
3233 "(4x, 'LAK ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', &
3234 &a, /4x, 'OPENED ON UNIT: ', I0)"
3235 character(len=*),
parameter :: fmtiter = &
3236 &
"(4x, 'MAXIMUM LAK ITERATION VALUE (',i0,') SPECIFIED.')"
3237 character(len=*),
parameter :: fmtdmaxchg = &
3238 &
"(4x, 'MAXIMUM STAGE CHANGE VALUE (',g0,') SPECIFIED.')"
3241 select case (option)
3242 case (
'PRINT_STAGE')
3244 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
3245 ' STAGES WILL BE PRINTED TO LISTING FILE.'
3247 call this%parser%GetStringCaps(keyword)
3248 if (keyword ==
'FILEOUT')
then
3249 call this%parser%GetString(fname)
3251 call openfile(this%istageout, this%iout, fname,
'DATA(BINARY)', &
3253 write (this%iout, fmtlakbin)
'STAGE', trim(adjustl(fname)), &
3256 call store_error(
'OPTIONAL STAGE KEYWORD MUST BE FOLLOWED BY FILEOUT')
3259 call this%parser%GetStringCaps(keyword)
3260 if (keyword ==
'FILEOUT')
then
3261 call this%parser%GetString(fname)
3263 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
3265 write (this%iout, fmtlakbin)
'BUDGET', trim(adjustl(fname)), &
3268 call store_error(
'OPTIONAL BUDGET KEYWORD MUST BE FOLLOWED BY FILEOUT')
3271 call this%parser%GetStringCaps(keyword)
3272 if (keyword ==
'FILEOUT')
then
3273 call this%parser%GetString(fname)
3275 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
3276 filstat_opt=
'REPLACE')
3277 write (this%iout, fmtlakbin)
'BUDGET CSV', trim(adjustl(fname)), &
3280 call store_error(
'OPTIONAL BUDGETCSV KEYWORD MUST BE FOLLOWED BY &
3283 case (
'PACKAGE_CONVERGENCE')
3284 call this%parser%GetStringCaps(keyword)
3285 if (keyword ==
'FILEOUT')
then
3286 call this%parser%GetString(fname)
3288 call openfile(this%ipakcsv, this%iout, fname,
'CSV', &
3289 filstat_opt=
'REPLACE', mode_opt=
mnormal)
3290 write (this%iout, fmtlakbin)
'PACKAGE_CONVERGENCE', &
3291 trim(adjustl(fname)), this%ipakcsv
3293 call store_error(
'OPTIONAL PACKAGE_CONVERGENCE KEYWORD MUST BE '// &
3294 'FOLLOWED BY FILEOUT')
3298 write (this%iout,
'(4x,A)')
'MOVER OPTION ENABLED'
3299 case (
'LENGTH_CONVERSION')
3300 this%convlength = this%parser%GetDouble()
3301 write (this%iout, fmtlengthconv) this%convlength
3302 case (
'TIME_CONVERSION')
3303 this%convtime = this%parser%GetDouble()
3304 write (this%iout, fmttimeconv) this%convtime
3306 r = this%parser%GetDouble()
3311 write (this%iout, fmtlakeopt)
'SURFDEP', this%surfdep
3312 case (
'MAXIMUM_ITERATIONS')
3313 this%maxlakit = this%parser%GetInteger()
3314 write (this%iout, fmtiter) this%maxlakit
3315 case (
'MAXIMUM_STAGE_CHANGE')
3316 r = this%parser%GetDouble()
3318 this%delh = dp999 * r
3319 write (this%iout, fmtdmaxchg) this%dmaxchg
3325 case (
'DEV_GROUNDWATER_HEAD_CONDUCTANCE')
3326 call this%parser%DevOpt()
3328 write (this%iout,
'(4x,a)') &
3329 'CONDUCTANCE FOR HORIZONTAL CONNECTIONS WILL BE CALCULATED &
3330 &USING THE GROUNDWATER HEAD'
3331 case (
'DEV_MAXIMUM_OUTLET_DEPTH')
3332 call this%parser%DevOpt()
3333 this%outdmax = this%parser%GetDouble()
3334 write (this%iout, fmtoutdmax) this%outdmax
3335 case (
'DEV_NO_FINAL_CHECK')
3336 call this%parser%DevOpt()
3338 write (this%iout,
'(4x,a)') &
3339 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN LAKE STAGES &
3341 case (
'DEV_NO_FINAL_RESIDUAL_CHECK')
3342 call this%parser%DevOpt()
3343 this%iconvresidchk = 0
3344 write (this%iout,
'(4x,a)') &
3345 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN LAKE RESIDUALS &
3347 case (
'DEV_MAXIMUM_PERCENT_DIFFERENCE')
3348 call this%parser%DevOpt()
3349 r = this%parser%GetDouble()
3354 write (this%iout, fmtlakeopt)
'MAXIMUM_PERCENT_DIFFERENCE', this%pdmax
3371 class(
laktype),
intent(inout) :: this
3373 call this%obs%obs_ar()
3376 call this%lak_allocate_arrays()
3379 call this%read_initial_attr()
3382 if (this%imover /= 0)
then
3383 allocate (this%pakmvrobj)
3384 call this%pakmvrobj%ar(this%noutlets, this%nlakes, this%memoryPath)
3401 class(
laktype),
intent(inout) :: this
3403 character(len=LINELENGTH) :: title
3404 character(len=LINELENGTH) :: line
3405 character(len=LINELENGTH) :: text
3406 logical(LGP) :: isfound
3407 logical(LGP) :: endOfBlock
3408 integer(I4B) :: ierr
3409 integer(I4B) :: node
3411 integer(I4B) :: itemno
3414 character(len=*),
parameter :: fmtblkerr = &
3415 &
"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
3416 character(len=*),
parameter :: fmtlsp = &
3417 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
3420 this%nbound = this%maxbound
3424 if (this%inunit == 0)
return
3427 if (this%ionper <
kper)
then
3430 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
3431 supportopenclose=.true., &
3432 blockrequired=.false.)
3436 call this%read_check_ionper()
3442 this%ionper =
nper + 1
3445 call this%parser%GetCurrentLine(line)
3446 write (
errmsg, fmtblkerr) adjustl(trim(line))
3448 call this%parser%StoreErrorUnit()
3454 if (this%ionper ==
kper)
then
3457 if (this%iprpak /= 0)
then
3460 title = trim(adjustl(this%text))//
' PACKAGE ('// &
3461 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
3462 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
3463 call table_cr(this%inputtab, this%packName, title)
3464 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
3466 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
3468 call this%inputtab%initialize_column(text, 20, alignment=tableft)
3470 write (text,
'(a,1x,i6)')
'VALUE', n
3471 call this%inputtab%initialize_column(text, 15, alignment=tabcenter)
3478 call this%parser%GetNextLine(endofblock)
3479 if (endofblock)
exit
3482 itemno = this%parser%GetInteger()
3485 call this%lak_set_stressperiod(itemno)
3488 if (this%iprpak /= 0)
then
3489 call this%parser%GetCurrentLine(line)
3490 call this%inputtab%line_to_columns(line)
3494 if (this%iprpak /= 0)
then
3495 call this%inputtab%finalize_table()
3500 write (this%iout, fmtlsp) trim(this%filtyp)
3505 call this%parser%StoreErrorUnit()
3509 do n = 1, this%nlakes
3510 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3511 node = this%cellid(j)
3512 this%nodelist(j) = node
3513 this%bound(1, j) = this%xnewpak(n)
3514 this%bound(2, j) = this%satcond(j)
3515 this%bound(3, j) = this%belev(j)
3520 if (this%imover == 1)
then
3521 do n = 1, this%noutlets
3522 this%pakmvrobj%iprmap(n) = this%lakein(n)
3540 integer(I4B) :: iaux
3543 call this%TsManager%ad()
3548 if (this%naux > 0)
then
3549 do n = 1, this%nlakes
3550 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3551 do iaux = 1, this%naux
3552 if (this%noupdateauxvar(iaux) /= 0) cycle
3553 this%auxvar(iaux, j) = this%lauxvar(iaux, n)
3564 do n = 1, this%nlakes
3565 this%xoldpak(n) = this%xnewpak(n)
3566 this%stageiter(n) = this%xnewpak(n)
3567 if (this%iboundpak(n) < 0)
then
3568 this%xnewpak(n) = this%stage(n)
3570 this%seep0(n) =
dzero
3576 do n = 1, this%nlakes
3577 this%xnewpak(n) = this%xoldpak(n)
3578 this%stageiter(n) = this%xnewpak(n)
3579 if (this%iboundpak(n) < 0)
then
3580 this%xnewpak(n) = this%stage(n)
3582 this%seep0(n) =
dzero
3587 if (this%imover == 1)
then
3588 call this%pakmvrobj%ad()
3594 call this%obs%obs_ad()
3608 integer(I4B) :: j, n
3609 integer(I4B) :: igwfnode
3610 real(DP) :: hlak, bottom_lake
3613 do n = 1, this%nlakes
3614 this%seep0(n) = this%seep(n)
3618 do n = 1, this%nlakes
3619 this%s0(n) = this%xnewpak(n)
3620 call this%lak_calculate_exchange(n, this%s0(n), this%qgwf0(n))
3624 do n = 1, this%nlakes
3625 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3627 if (this%ictype(j) /= 0)
then
3630 igwfnode = this%nodesontop(j)
3631 if (this%ibound(igwfnode) == 0)
then
3632 call this%dis%highest_active(igwfnode, this%ibound)
3634 this%nodelist(j) = igwfnode
3635 this%cellid(j) = igwfnode
3642 do n = 1, this%nlakes
3644 hlak = this%xnewpak(n)
3647 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3650 igwfnode = this%cellid(j)
3653 if (this%ibound(igwfnode) < 1)
then
3658 if (this%ictype(j) /= 0)
then
3663 if (this%ictype(j) == 2 .or. this%ictype(j) == 3)
then
3668 bottom_lake = this%belev(j)
3669 if (hlak > bottom_lake .or. this%iboundpak(n) == 0)
then
3672 this%ibound(igwfnode) = 1
3680 call this%lak_bound_update()
3688 subroutine lak_fc(this, rhs, ia, idxglo, matrix_sln)
3691 real(DP),
dimension(:),
intent(inout) :: rhs
3692 integer(I4B),
dimension(:),
intent(in) :: ia
3693 integer(I4B),
dimension(:),
intent(in) :: idxglo
3696 integer(I4B) :: j, n
3697 integer(I4B) :: igwfnode
3698 integer(I4B) :: ipossymd
3701 if (this%imover == 1)
then
3702 call this%pakmvrobj%fc()
3706 call this%lak_solve()
3709 do n = 1, this%nlakes
3710 if (this%iboundpak(n) == 0) cycle
3711 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3712 igwfnode = this%cellid(j)
3713 if (this%ibound(igwfnode) < 1) cycle
3714 ipossymd = idxglo(ia(igwfnode))
3715 call matrix_sln%add_value_pos(ipossymd, this%hcof(j))
3716 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
3726 subroutine lak_fn(this, rhs, ia, idxglo, matrix_sln)
3729 real(DP),
dimension(:),
intent(inout) :: rhs
3730 integer(I4B),
dimension(:),
intent(in) :: ia
3731 integer(I4B),
dimension(:),
intent(in) :: idxglo
3734 integer(I4B) :: j, n
3735 integer(I4B) :: ipos
3736 integer(I4B) :: igwfnode
3737 integer(I4B) :: idry
3750 do n = 1, this%nlakes
3751 if (this%iboundpak(n) == 0) cycle
3752 hlak = this%xnewpak(n)
3753 call this%lak_calculate_available(n, hlak, avail, &
3754 ra, ro, qinf, ex, this%delh)
3755 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3756 igwfnode = this%cellid(j)
3758 head = this%xnew(igwfnode)
3759 if (-this%hcof(j) >
dzero)
then
3760 if (this%ibound(igwfnode) > 0)
then
3764 call this%lak_estimate_conn_exchange(2, n, j, idry, hlak, &
3765 head + this%delh, q1, avail)
3768 q = this%hcof(j) * head - this%rhs(j)
3770 rterm = this%hcof(j) * head
3772 drterm = (q1 - q) / this%delh
3775 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(j))
3776 rhs(igwfnode) = rhs(igwfnode) - rterm + drterm * head
3788 subroutine lak_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
3792 class(
laktype),
intent(inout) :: this
3793 integer(I4B),
intent(in) :: innertot
3794 integer(I4B),
intent(in) :: kiter
3795 integer(I4B),
intent(in) :: iend
3796 integer(I4B),
intent(in) :: icnvgmod
3797 character(len=LENPAKLOC),
intent(inout) :: cpak
3798 integer(I4B),
intent(inout) :: ipak
3799 real(DP),
intent(inout) :: dpak
3801 character(len=LENPAKLOC) :: cloc
3802 character(len=LINELENGTH) :: tag
3803 integer(I4B) :: icheck
3804 integer(I4B) :: ipakfail
3805 integer(I4B) :: locdhmax
3806 integer(I4B) :: locresidmax
3807 integer(I4B) :: locdgwfmax
3808 integer(I4B) :: locdqoutmax
3809 integer(I4B) :: locdqfrommvrmax
3810 integer(I4B) :: ntabrows
3811 integer(I4B) :: ntabcols
3815 real(DP) :: qtolfact
3833 real(DP) :: residmax
3835 real(DP) :: dqoutmax
3836 real(DP) :: dqfrommvr
3837 real(DP) :: dqfrommvrmax
3840 icheck = this%iconvchk
3851 dqfrommvrmax =
dzero
3855 if (this%ipakcsv == 0)
then
3856 if (icnvgmod == 0)
then
3864 if (.not.
associated(this%pakcsvtab))
then
3869 if (this%noutlets > 0)
then
3870 ntabcols = ntabcols + 2
3872 if (this%imover == 1)
then
3873 ntabcols = ntabcols + 2
3877 call table_cr(this%pakcsvtab, this%packName,
'')
3878 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
3879 lineseparator=.false., separator=
',', &
3883 tag =
'total_inner_iterations'
3884 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3886 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3888 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3890 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3892 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3894 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3896 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3898 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3899 tag =
'residmax_loc'
3900 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3902 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3904 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3905 if (this%noutlets > 0)
then
3907 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3908 tag =
'dqoutmax_loc'
3909 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3911 if (this%imover == 1)
then
3912 tag =
'dqfrommvrmax'
3913 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3914 tag =
'dqfrommvrmax_loc'
3915 call this%pakcsvtab%initialize_column(tag, 16, alignment=
tableft)
3921 if (icheck /= 0)
then
3922 final_check:
do n = 1, this%nlakes
3923 if (this%iboundpak(n) < 1) cycle
3927 hlak = this%xnewpak(n)
3933 call this%lak_calculate_sarea(n, hlak, area)
3936 if (area >
dzero)
then
3937 qtolfact =
delt / area
3943 call this%lak_calculate_residual(n, hlak, resid)
3944 resid = resid * qtolfact
3948 if (area >
dzero)
then
3949 gwf0 = this%qgwf0(n)
3950 call this%lak_calculate_exchange(n, hlak, gwf)
3951 dgwf = (gwf0 - gwf) * qtolfact
3956 if (this%noutlets > 0)
then
3957 if (area >
dzero)
then
3958 call this%lak_calculate_available(n, hlak0, inf, ra, ro, qinf, ex)
3959 call this%lak_calculate_outlet_outflow(n, hlak0, inf, qout0)
3960 call this%lak_calculate_available(n, hlak, inf, ra, ro, qinf, ex)
3961 call this%lak_calculate_outlet_outflow(n, hlak, inf, qout)
3962 dqout = (qout0 - qout) * qtolfact
3968 if (this%imover == 1)
then
3969 q = this%pakmvrobj%get_qfrommvr(n)
3970 q0 = this%pakmvrobj%get_qfrommvr0(n)
3971 dqfrommvr = qtolfact * (q0 - q)
3984 dqfrommvrmax = dqfrommvr
3987 if (abs(dh) > abs(dhmax))
then
3991 if (abs(resid) > abs(residmax))
then
3995 if (abs(dgwf) > abs(dgwfmax))
then
3999 if (abs(dqout) > abs(dqoutmax))
then
4003 if (abs(dqfrommvr) > abs(dqfrommvrmax))
then
4004 dqfrommvrmax = dqfrommvr
4011 if (abs(dhmax) > abs(dpak))
then
4014 write (cloc,
"(a,'-',a)") &
4015 trim(this%packName),
'stage'
4018 if (abs(residmax) > abs(dpak))
then
4021 write (cloc,
"(a,'-',a)") &
4022 trim(this%packName),
'residual'
4025 if (abs(dgwfmax) > abs(dpak))
then
4028 write (cloc,
"(a,'-',a)") &
4029 trim(this%packName),
'gwf'
4032 if (this%noutlets > 0)
then
4033 if (abs(dqoutmax) > abs(dpak))
then
4036 write (cloc,
"(a,'-',a)") &
4037 trim(this%packName),
'outlet'
4041 if (this%imover == 1)
then
4042 if (abs(dqfrommvrmax) > abs(dpak))
then
4043 ipak = locdqfrommvrmax
4045 write (cloc,
"(a,'-',a)") trim(this%packName),
'qfrommvr'
4051 if (this%ipakcsv /= 0)
then
4054 call this%pakcsvtab%add_term(innertot)
4055 call this%pakcsvtab%add_term(
totim)
4056 call this%pakcsvtab%add_term(
kper)
4057 call this%pakcsvtab%add_term(
kstp)
4058 call this%pakcsvtab%add_term(kiter)
4059 call this%pakcsvtab%add_term(dhmax)
4060 call this%pakcsvtab%add_term(locdhmax)
4061 call this%pakcsvtab%add_term(residmax)
4062 call this%pakcsvtab%add_term(locresidmax)
4063 call this%pakcsvtab%add_term(dgwfmax)
4064 call this%pakcsvtab%add_term(locdgwfmax)
4065 if (this%noutlets > 0)
then
4066 call this%pakcsvtab%add_term(dqoutmax)
4067 call this%pakcsvtab%add_term(locdqoutmax)
4069 if (this%imover == 1)
then
4070 call this%pakcsvtab%add_term(dqfrommvrmax)
4071 call this%pakcsvtab%add_term(locdqfrommvrmax)
4076 call this%pakcsvtab%finalize_table()
4091 class(
laktype),
intent(inout) :: this
4092 real(DP),
dimension(:),
intent(in) :: x
4093 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
4094 integer(I4B),
optional,
intent(in) :: iadv
4097 real(DP) :: chratin, chratout
4099 integer(I4B) :: j, n
4103 call this%lak_solve(update=.false.)
4107 call this%BndType%bnd_cq(x, flowja, iadv=1)
4112 do n = 1, this%nlakes
4113 this%chterm(n) =
dzero
4114 if (this%iboundpak(n) == 0) cycle
4115 hlak = this%xnewpak(n)
4116 call this%lak_calculate_vol(n, hlak, v1)
4119 if (this%iboundpak(n) /= 0)
then
4122 rrate = this%precip(n)
4123 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4126 rrate = this%evap(n)
4127 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4130 rrate = this%runoff(n)
4131 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4134 rrate = this%inflow(n)
4135 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4138 rrate = this%withr(n)
4139 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4143 if (this%iboundpak(n) > 0)
then
4144 if (this%gwfiss /= 1)
then
4145 call this%lak_calculate_vol(n, this%xoldpak(n), v0)
4146 rrate = -(v1 - v0) /
delt
4147 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4150 this%qsto(n) = rrate
4153 call this%lak_get_external_outlet(n, rrate)
4154 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4157 if (this%imover == 1)
then
4158 if (this%iboundpak(n) /= 0)
then
4159 rrate = this%pakmvrobj%get_qfrommvr(n)
4163 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4169 do n = 1, this%nlakes
4171 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4175 rrate = -this%simvals(j)
4176 this%qleak(j) = rrate
4177 if (this%iboundpak(n) /= 0)
then
4178 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4184 call this%lak_fill_budobj()
4195 integer(I4B),
intent(in) :: icbcfl
4196 integer(I4B),
intent(in) :: ibudfl
4197 integer(I4B) :: ibinun
4201 if (this%ibudgetout /= 0)
then
4202 ibinun = this%ibudgetout
4204 if (icbcfl == 0) ibinun = 0
4205 if (ibinun > 0)
then
4206 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
4211 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
4212 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
4223 integer(I4B),
intent(in) :: icbcfl
4224 integer(I4B),
intent(in) :: ibudfl
4225 integer(I4B),
intent(in) :: icbcun
4226 integer(I4B),
dimension(:),
optional,
intent(in) :: imap
4229 call this%BndType%bnd_ot_model_flows(icbcfl, ibudfl, icbcun, this%imap)
4242 integer(I4B),
intent(in) :: idvsave
4243 integer(I4B),
intent(in) :: idvprint
4244 integer(I4B) :: ibinun
4254 if (this%istageout /= 0)
then
4255 ibinun = this%istageout
4257 if (idvsave == 0) ibinun = 0
4260 if (ibinun > 0)
then
4261 do n = 1, this%nlakes
4263 d = v - this%lakebot(n)
4264 if (this%iboundpak(n) == 0)
then
4266 else if (d <= dzero)
then
4272 this%nlakes, 1, 1, ibinun)
4276 if (idvprint /= 0 .and. this%iprhed /= 0)
then
4279 call this%stagetab%set_kstpkper(
kstp,
kper)
4282 do n = 1, this%nlakes
4283 if (this%iboundpak(n) == 0)
then
4289 stage = this%xnewpak(n)
4290 call this%lak_calculate_sarea(n, stage, sa)
4291 call this%lak_calculate_warea(n, stage, wa)
4292 call this%lak_calculate_vol(n, stage, v)
4294 if (this%inamedbound == 1)
then
4295 call this%stagetab%add_term(this%lakename(n))
4297 call this%stagetab%add_term(n)
4298 call this%stagetab%add_term(stage)
4299 call this%stagetab%add_term(sa)
4300 call this%stagetab%add_term(wa)
4301 call this%stagetab%add_term(v)
4316 integer(I4B),
intent(in) :: kstp
4317 integer(I4B),
intent(in) :: kper
4318 integer(I4B),
intent(in) :: iout
4319 integer(I4B),
intent(in) :: ibudfl
4321 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
4336 deallocate (this%lakename)
4337 deallocate (this%status)
4338 deallocate (this%clakbudget)
4340 deallocate (this%cauxcbc)
4348 if (this%ntables > 0)
then
4357 call this%budobj%budgetobject_da()
4358 deallocate (this%budobj)
4359 nullify (this%budobj)
4362 if (this%noutlets > 0)
then
4375 if (this%iprhed > 0)
then
4376 call this%stagetab%table_da()
4377 deallocate (this%stagetab)
4378 nullify (this%stagetab)
4382 if (this%ipakcsv > 0)
then
4383 if (
associated(this%pakcsvtab))
then
4384 call this%pakcsvtab%table_da()
4385 deallocate (this%pakcsvtab)
4386 nullify (this%pakcsvtab)
4484 nullify (this%gwfiss)
4487 call this%BndType%bnd_da()
4498 class(
laktype),
intent(inout) :: this
4501 this%listlabel = trim(this%filtyp)//
' NO.'
4502 if (this%dis%ndim == 3)
then
4503 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
4504 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
4505 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
4506 elseif (this%dis%ndim == 2)
then
4507 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
4508 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
4510 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
4512 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
4513 if (this%inamedbound == 1)
then
4514 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
4527 integer(I4B),
pointer :: neq
4528 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
4529 real(DP),
dimension(:),
pointer,
contiguous :: xnew
4530 real(DP),
dimension(:),
pointer,
contiguous :: xold
4531 real(DP),
dimension(:),
pointer,
contiguous :: flowja
4534 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
4575 integer(I4B) :: indx
4579 call this%obs%StoreObsType(
'stage', .false., indx)
4584 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
4589 call this%obs%StoreObsType(
'outlet-inflow', .true., indx)
4594 call this%obs%StoreObsType(
'inflow', .true., indx)
4599 call this%obs%StoreObsType(
'from-mvr', .true., indx)
4604 call this%obs%StoreObsType(
'rainfall', .true., indx)
4609 call this%obs%StoreObsType(
'runoff', .true., indx)
4614 call this%obs%StoreObsType(
'lak', .true., indx)
4619 call this%obs%StoreObsType(
'evaporation', .true., indx)
4624 call this%obs%StoreObsType(
'withdrawal', .true., indx)
4629 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
4634 call this%obs%StoreObsType(
'to-mvr', .true., indx)
4639 call this%obs%StoreObsType(
'storage', .true., indx)
4644 call this%obs%StoreObsType(
'constant', .true., indx)
4649 call this%obs%StoreObsType(
'outlet', .true., indx)
4654 call this%obs%StoreObsType(
'volume', .true., indx)
4659 call this%obs%StoreObsType(
'surface-area', .true., indx)
4664 call this%obs%StoreObsType(
'wetted-area', .true., indx)
4669 call this%obs%StoreObsType(
'conductance', .true., indx)
4684 integer(I4B) :: igwfnode
4695 if (this%obs%npakobs > 0)
then
4696 call this%obs%obs_bd_clear()
4697 do i = 1, this%obs%npakobs
4698 obsrv => this%obs%pakobs(i)%obsrv
4699 do j = 1, obsrv%indxbnds_count
4701 jj = obsrv%indxbnds(j)
4702 select case (obsrv%ObsTypeId)
4704 if (this%iboundpak(jj) /= 0)
then
4705 v = this%xnewpak(jj)
4708 if (this%iboundpak(jj) /= 0)
then
4709 call this%lak_calculate_inflow(jj, v)
4711 case (
'OUTLET-INFLOW')
4712 if (this%iboundpak(jj) /= 0)
then
4713 call this%lak_calculate_outlet_inflow(jj, v)
4716 if (this%iboundpak(jj) /= 0)
then
4717 call this%lak_calculate_inflow(jj, v)
4718 call this%lak_calculate_outlet_inflow(jj, v2)
4722 if (this%iboundpak(jj) /= 0)
then
4723 if (this%imover == 1)
then
4724 v = this%pakmvrobj%get_qfrommvr(jj)
4728 if (this%iboundpak(jj) /= 0)
then
4732 if (this%iboundpak(jj) /= 0)
then
4737 if (this%iboundpak(n) /= 0)
then
4738 igwfnode = this%cellid(jj)
4739 hgwf = this%xnew(igwfnode)
4740 if (this%hcof(jj) /=
dzero)
then
4741 v = -(this%hcof(jj) * (this%xnewpak(n) - hgwf))
4746 case (
'EVAPORATION')
4747 if (this%iboundpak(jj) /= 0)
then
4751 if (this%iboundpak(jj) /= 0)
then
4754 case (
'EXT-OUTFLOW')
4756 if (this%iboundpak(n) /= 0)
then
4757 if (this%lakeout(jj) == 0)
then
4758 v = this%simoutrate(jj)
4760 if (this%imover == 1)
then
4761 v = v + this%pakmvrobj%get_qtomvr(jj)
4768 if (this%iboundpak(n) /= 0)
then
4769 if (this%imover == 1)
then
4770 v = this%pakmvrobj%get_qtomvr(jj)
4777 if (this%iboundpak(jj) /= 0)
then
4781 if (this%iboundpak(jj) /= 0)
then
4786 if (this%iboundpak(n) /= 0)
then
4787 v = this%simoutrate(jj)
4790 if (this%iboundpak(jj) /= 0)
then
4791 call this%lak_calculate_vol(jj, this%xnewpak(jj), v)
4793 case (
'SURFACE-AREA')
4794 if (this%iboundpak(jj) /= 0)
then
4795 hlak = this%xnewpak(jj)
4796 call this%lak_calculate_sarea(jj, hlak, v)
4798 case (
'WETTED-AREA')
4800 if (this%iboundpak(n) /= 0)
then
4801 hlak = this%xnewpak(n)
4802 igwfnode = this%cellid(jj)
4803 hgwf = this%xnew(igwfnode)
4804 call this%lak_calculate_conn_warea(n, jj, hlak, hgwf, v)
4806 case (
'CONDUCTANCE')
4808 if (this%iboundpak(n) /= 0)
then
4809 hlak = this%xnewpak(n)
4810 igwfnode = this%cellid(jj)
4811 hgwf = this%xnew(igwfnode)
4812 call this%lak_calculate_conn_conductance(n, jj, hlak, hgwf, v)
4815 errmsg =
'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
4818 call this%obs%SaveOneSimval(obsrv, v)
4840 class(
laktype),
intent(inout) :: this
4847 character(len=LENBOUNDNAME) :: bname
4848 logical(LGP) :: jfound
4851 10
format(
'Boundary "', a,
'" for observation "', a, &
4852 '" is invalid in package "', a,
'"')
4858 do i = 1, this%obs%npakobs
4859 obsrv => this%obs%pakobs(i)%obsrv
4862 nn1 = obsrv%NodeNumber
4864 bname = obsrv%FeatureName
4865 if (bname /=
'')
then
4870 if (obsrv%ObsTypeId ==
'LAK' .or. &
4871 obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4872 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4873 do j = 1, this%nlakes
4874 do jj = this%idxlakeconn(j), this%idxlakeconn(j + 1) - 1
4875 if (this%boundname(jj) == bname)
then
4877 call obsrv%AddObsIndex(jj)
4881 else if (obsrv%ObsTypeId ==
'EXT-OUTFLOW' .or. &
4882 obsrv%ObsTypeId ==
'TO-MVR' .or. &
4883 obsrv%ObsTypeId ==
'OUTLET')
then
4884 do j = 1, this%noutlets
4886 if (this%lakename(jj) == bname)
then
4888 call obsrv%AddObsIndex(j)
4892 do j = 1, this%nlakes
4893 if (this%lakename(j) == bname)
then
4895 call obsrv%AddObsIndex(j)
4899 if (.not. jfound)
then
4901 trim(bname), trim(obsrv%Name), trim(this%packName)
4906 if (obsrv%indxbnds_count == 0)
then
4907 if (obsrv%ObsTypeId ==
'LAK' .or. &
4908 obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4909 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4910 nn2 = obsrv%NodeNumber2
4911 j = this%idxlakeconn(nn1) + nn2 - 1
4912 call obsrv%AddObsIndex(j)
4914 call obsrv%AddObsIndex(nn1)
4917 errmsg =
'Programming error in lak_rp_obs'
4924 if (obsrv%ObsTypeId ==
'STAGE')
then
4925 if (obsrv%indxbnds_count > 1)
then
4926 write (
errmsg,
'(a,3(1x,a))') &
4927 trim(adjustl(obsrv%ObsTypeId)), &
4928 'for observation', trim(adjustl(obsrv%Name)), &
4929 ' must be assigned to a lake with a unique boundname.'
4935 if (obsrv%ObsTypeId ==
'TO-MVR' .or. &
4936 obsrv%ObsTypeId ==
'EXT-OUTFLOW' .or. &
4937 obsrv%ObsTypeId ==
'OUTLET')
then
4938 do j = 1, obsrv%indxbnds_count
4939 nn1 = obsrv%indxbnds(j)
4940 if (nn1 < 1 .or. nn1 > this%noutlets)
then
4941 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
4942 trim(adjustl(obsrv%ObsTypeId)), &
4943 ' outlet must be > 0 and <=', this%noutlets, &
4944 '(specified value is ', nn1,
')'
4948 else if (obsrv%ObsTypeId ==
'LAK' .or. &
4949 obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4950 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4951 do j = 1, obsrv%indxbnds_count
4952 nn1 = obsrv%indxbnds(j)
4953 if (nn1 < 1 .or. nn1 > this%maxbound)
then
4954 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
4955 trim(adjustl(obsrv%ObsTypeId)), &
4956 'lake connection number must be > 0 and <=', this%maxbound, &
4957 '(specified value is ', nn1,
')'
4962 do j = 1, obsrv%indxbnds_count
4963 nn1 = obsrv%indxbnds(j)
4964 if (nn1 < 1 .or. nn1 > this%nlakes)
then
4965 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
4966 trim(adjustl(obsrv%ObsTypeId)), &
4967 ' lake must be > 0 and <=', this%nlakes, &
4968 '(specified value is ', nn1,
')'
4996 integer(I4B),
intent(in) :: inunitobs
4997 integer(I4B),
intent(in) :: iout
4999 integer(I4B) :: nn1, nn2
5000 integer(I4B) :: icol, istart, istop
5001 character(len=LINELENGTH) :: string
5002 character(len=LENBOUNDNAME) :: bndname
5004 string = obsrv%IDstring
5012 obsrv%FeatureName = bndname
5014 if (obsrv%ObsTypeId ==
'LAK' .or. obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
5015 obsrv%ObsTypeId ==
'WETTED-AREA')
then
5017 if (len_trim(bndname) < 1 .and. nn2 < 0)
then
5018 write (
errmsg,
'(a,1x,a,a,1x,a,1x,a)') &
5019 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
5020 ', ID given as an integer and not as boundname,', &
5021 'but ID2 (iconn) is missing. Either change ID to valid', &
5022 'boundname or supply valid entry for ID2.'
5026 obsrv%FeatureName = bndname
5030 obsrv%NodeNumber2 = nn2
5035 obsrv%NodeNumber = nn1
5050 integer(I4B),
intent(in) :: ilak
5051 real(DP),
intent(in) :: rrate
5052 real(DP),
intent(inout) :: chratin
5053 real(DP),
intent(inout) :: chratout
5058 if (this%iboundpak(ilak) < 0)
then
5060 this%chterm(ilak) = this%chterm(ilak) + q
5066 chratout = chratout - q
5070 chratin = chratin + q
5082 class(
laktype),
intent(inout) :: this
5084 integer(I4B) :: j, n, node
5085 real(DP) :: hlak, head, clak
5088 if (this%nbound == 0)
return
5091 do n = 1, this%nlakes
5092 hlak = this%xnewpak(n)
5093 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5094 node = this%cellid(j)
5095 head = this%xnew(node)
5096 call this%lak_calculate_conn_conductance(n, j, hlak, head, clak)
5097 this%bound(1, j) = hlak
5098 this%bound(2, j) = clak
5112 class(
laktype),
intent(inout) :: this
5113 logical(LGP),
intent(in),
optional :: update
5115 logical(LGP) :: lupdate
5119 integer(I4B) :: iicnvg
5120 integer(I4B) :: iter
5121 integer(I4B) :: maxiter
5122 integer(I4B) :: ncnv
5123 integer(I4B) :: idry
5124 integer(I4B) :: idry1
5125 integer(I4B) :: igwfnode
5126 integer(I4B) :: ibflg
5127 integer(I4B) :: idhp
5155 real(DP) :: qtolfact
5158 if (
present(update))
then
5169 do n = 1, this%nlakes
5171 this%surfin(n) =
dzero
5172 this%surfout(n) =
dzero
5173 this%surfout1(n) =
dzero
5174 if (this%xnewpak(n) < this%lakebot(n))
then
5175 this%xnewpak(n) = this%lakebot(n)
5177 if (this%gwfiss /= 0)
then
5178 this%xoldpak(n) = this%xnewpak(n)
5183 this%en1(n) = this%lakebot(n)
5184 call this%lak_calculate_residual(n, this%en1(n), this%r1(n))
5185 this%en2(n) = this%laketop(n)
5186 call this%lak_calculate_residual(n, this%en2(n), this%r2(n))
5188 do n = 1, this%noutlets
5189 this%simoutrate(n) =
dzero
5193 do n = 1, this%nlakes
5194 call this%lak_calculate_outlet_inflow(n, this%surfin(n))
5199 do n = 1, this%nlakes
5200 hlak0 = this%xoldpak(n)
5201 hlak = this%xnewpak(n)
5202 call this%lak_calculate_runoff(n, ro)
5203 call this%lak_calculate_inflow(n, qinf)
5204 call this%lak_calculate_external(n, ex)
5205 call this%lak_calculate_vol(n, hlak0, v0)
5206 call this%lak_calculate_vol(n, hlak, v1)
5207 this%flwin(n) = this%surfin(n) + ro + qinf + ex + &
5212 do n = 1, this%nlakes
5213 call this%lak_calculate_outlet_inflow(n, outinf)
5214 this%flwin(n) = this%flwin(n) + outinf
5218 maxiter = this%maxlakit
5221 converge:
do iter = 1, maxiter
5223 do n = 1, this%nlakes
5224 if (this%ncncvr(n) == 0) ncnv = 1
5226 if (iter == maxiter) ncnv = 0
5227 if (ncnv == 0) iicnvg = 1
5230 do n = 1, this%nlakes
5231 this%evap(n) =
dzero
5232 this%precip(n) =
dzero
5233 this%precip1(n) =
dzero
5234 this%seep(n) =
dzero
5235 this%seep1(n) =
dzero
5236 this%evap(n) =
dzero
5237 this%evap1(n) =
dzero
5238 this%evapo(n) =
dzero
5239 this%withr(n) =
dzero
5240 this%withr1(n) =
dzero
5241 this%flwiter(n) = this%flwin(n)
5242 this%flwiter1(n) = this%flwin(n)
5243 if (this%gwfiss /= 0)
then
5244 this%flwiter(n) =
dep20
5245 this%flwiter1(n) =
dep20
5247 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5248 this%hcof(j) =
dzero
5253 estseep:
do i = 1, 2
5254 lakseep:
do n = 1, this%nlakes
5256 if (this%iboundpak(n) == 0)
then
5260 if (this%gwfiss /= 0)
then
5261 this%xoldpak(n) = this%xnewpak(n)
5263 hlak = this%xnewpak(n)
5264 calcconnseep:
do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5265 igwfnode = this%cellid(j)
5266 head = this%xnew(igwfnode)
5267 if (this%ncncvr(n) /= 2)
then
5268 if (this%ibound(igwfnode) > 0)
then
5269 call this%lak_estimate_conn_exchange(i, n, j, idry, hlak, &
5273 call this%lak_estimate_conn_exchange(i, n, j, idry1, &
5274 hlak + delh, head, qlakgw1, &
5278 if (ncnv == 0 .and. i == 2)
then
5279 if (j == this%maxbound)
then
5283 this%hcof(j) = gwfhcof
5284 this%rhs(j) = gwfrhs
5286 this%hcof(j) =
dzero
5287 this%rhs(j) = qlakgw
5291 this%seep(n) = this%seep(n) + qlakgw
5292 this%seep1(n) = this%seep1(n) + qlakgw1
5301 laklevel:
do n = 1, this%nlakes
5303 if (this%iboundpak(n) == 0)
then
5308 hlak = this%xnewpak(n)
5309 if (iter < maxiter)
then
5310 this%stageiter(n) = this%xnewpak(n)
5312 call this%lak_calculate_rainfall(n, hlak, ra)
5314 this%flwiter(n) = this%flwiter(n) + ra
5315 call this%lak_calculate_rainfall(n, hlak + delh, ra)
5316 this%precip1(n) = ra
5317 this%flwiter1(n) = this%flwiter1(n) + ra
5320 call this%lak_calculate_withdrawal(n, this%flwiter(n), wr)
5322 call this%lak_calculate_withdrawal(n, this%flwiter1(n), wr)
5326 call this%lak_calculate_evaporation(n, hlak, this%flwiter(n), ev)
5328 call this%lak_calculate_evaporation(n, hlak + delh, this%flwiter1(n), ev)
5332 call this%lak_calculate_outlet_outflow(n, hlak + delh, &
5335 call this%lak_calculate_outlet_outflow(n, hlak, this%flwiter(n), &
5339 call this%lak_calculate_outlet_inflow(n, this%surfin(n))
5343 if (this%iboundpak(n) > 0 .and. lupdate .eqv. .true.)
then
5346 hlak0 = this%xoldpak(n)
5347 hlak = this%xnewpak(n)
5348 call this%lak_calculate_vol(n, hlak0, v0)
5349 call this%lak_calculate_vol(n, hlak, v1)
5350 call this%lak_calculate_runoff(n, ro)
5351 call this%lak_calculate_inflow(n, qinf)
5352 call this%lak_calculate_external(n, ex)
5353 this%flwin(n) = this%surfin(n) + ro + qinf + ex + &
5357 resid = this%precip(n) + this%evap(n) + this%withr(n) + ro + &
5358 qinf + ex + this%surfin(n) + &
5359 this%surfout(n) + this%seep(n)
5360 resid1 = this%precip1(n) + this%evap1(n) + this%withr1(n) + ro + &
5361 qinf + ex + this%surfin(n) + &
5362 this%surfout1(n) + this%seep1(n)
5365 hlak = this%xnewpak(n)
5366 if (this%gwfiss /= 1)
then
5367 call this%lak_calculate_vol(n, hlak, v1)
5368 resid = resid + (v0 - v1) /
delt
5369 call this%lak_calculate_vol(n, hlak + delh, v1)
5370 resid1 = resid1 + (v0 - v1) /
delt
5374 if (abs(resid1 - resid) >
dzero)
then
5375 derv = (resid1 - resid) / delh
5377 if (abs(derv) >
dprec)
then
5381 if (resid <
dzero)
then
5384 call this%lak_vol2stage(n, resid, dh)
5391 if (iter == 1) this%dh0(n) = dh
5393 adh0 = abs(this%dh0(n))
5394 if ((ts >= this%en2(n)) .or. (ts < this%en1(n)))
then
5397 if ((adh > adh0) .or. (ts - this%lakebot(n)) <
dprec)
then
5399 call this%lak_bisection(n, ibflg, hlak, ts, dh, residb)
5405 this%seep0(n) = this%seep(n)
5409 if (this%seep(n) * this%seep0(n) <
dprec)
then
5410 this%iseepc(n) = this%iseepc(n) + 1
5416 if (dh * this%dh0(n) <
dprec) idhp = 1
5419 if (adh > adh0) idhp = 1
5422 this%idhc(n) = this%idhc(n) + 1
5427 if (ibflg == 1)
then
5428 if (this%iseepc(n) > 7 .or. this%idhc(n) > 12)
then
5429 call this%lak_bisection(n, ibflg, hlak, ts, dh, residb)
5438 if (hlak < this%lakebot(n))
then
5439 hlak = this%lakebot(n)
5443 call this%lak_calculate_sarea(n, hlak, area)
5446 if (area >
dzero)
then
5447 qtolfact =
delt / area
5453 call this%lak_calculate_residual(n, hlak, resid)
5457 if (abs(dh) < delh .and. abs(resid) * qtolfact < this%dmaxchg)
then
5460 this%xnewpak(n) = hlak
5463 this%seep0(n) = this%seep(n)
5468 if (iicnvg == 1)
exit converge
5475 if (this%imover == 1)
then
5476 do n = 1, this%noutlets
5477 call this%pakmvrobj%accumulate_qformvr(n, -this%simoutrate(n))
5491 class(
laktype),
intent(inout) :: this
5492 integer(I4B),
intent(in) :: n
5493 integer(I4B),
intent(inout) :: ibflg
5494 real(DP),
intent(in) :: hlak
5495 real(DP),
intent(inout) :: temporary_stage
5496 real(DP),
intent(inout) :: dh
5497 real(DP),
intent(inout) :: residual
5500 real(DP) :: temporary_stage0
5501 real(DP) :: residuala
5502 real(DP) :: endpoint1
5503 real(DP) :: endpoint2
5506 temporary_stage0 = hlak
5507 endpoint1 = this%en1(n)
5508 endpoint2 = this%en2(n)
5509 call this%lak_calculate_residual(n, temporary_stage, residuala)
5510 if (hlak > endpoint1 .and. hlak < endpoint2)
then
5513 do i = 1, this%maxlakit
5514 temporary_stage =
dhalf * (endpoint1 + endpoint2)
5515 call this%lak_calculate_residual(n, temporary_stage, residual)
5516 if (abs(residual) ==
dzero .or. &
5517 abs(temporary_stage0 - temporary_stage) < this%dmaxchg)
then
5520 call this%lak_calculate_residual(n, endpoint1, residuala)
5523 if (sign(
done, residuala) == sign(
done, residual))
then
5524 endpoint1 = temporary_stage
5527 endpoint2 = temporary_stage
5529 temporary_stage0 = temporary_stage
5531 dh = hlak - temporary_stage
5541 ra, ro, qinf, ex, headp)
5545 class(
laktype),
intent(inout) :: this
5546 integer(I4B),
intent(in) :: n
5547 real(DP),
intent(in) :: hlak
5548 real(DP),
intent(inout) :: avail
5549 real(DP),
intent(inout) :: ra
5550 real(DP),
intent(inout) :: ro
5551 real(DP),
intent(inout) :: qinf
5552 real(DP),
intent(inout) :: ex
5553 real(DP),
intent(in),
optional :: headp
5556 integer(I4B) :: idry
5557 integer(I4B) :: igwfnode
5564 if (
present(headp))
then
5574 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5575 igwfnode = this%cellid(j)
5576 if (this%ibound(igwfnode) == 0) cycle
5577 head = this%xnew(igwfnode) + hp
5578 call this%lak_estimate_conn_exchange(1, n, j, idry, hlak, head, qlakgw, &
5583 call this%lak_calculate_rainfall(n, hlak, ra)
5587 call this%lak_calculate_runoff(n, ro)
5591 call this%lak_calculate_inflow(n, qinf)
5592 avail = avail + qinf
5595 call this%lak_calculate_external(n, ex)
5599 call this%lak_calculate_vol(n, this%xoldpak(n), v0)
5600 avail = avail + v0 /
delt
5612 class(
laktype),
intent(inout) :: this
5613 integer(I4B),
intent(in) :: n
5614 real(DP),
intent(in) :: hlak
5615 real(DP),
intent(inout) :: resid
5616 real(DP),
intent(in),
optional :: headp
5619 integer(I4B) :: idry
5620 integer(I4B) :: igwfnode
5639 if (
present(headp))
then
5651 call this%lak_calculate_available(n, hlak, avail, &
5652 ra, ro, qinf, ex, hp)
5655 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5656 igwfnode = this%cellid(j)
5657 if (this%ibound(igwfnode) == 0) cycle
5658 head = this%xnew(igwfnode) + hp
5659 call this%lak_estimate_conn_exchange(2, n, j, idry, hlak, head, qlakgw, &
5661 seep = seep + qlakgw
5665 call this%lak_calculate_withdrawal(n, avail, wr)
5668 call this%lak_calculate_evaporation(n, hlak, avail, ev)
5671 call this%lak_calculate_outlet_outflow(n, hlak, avail, sout)
5674 call this%lak_calculate_outlet_inflow(n, sin)
5677 resid = ra + ev + wr + ro + qinf + ex + sin + sout + seep
5680 if (this%gwfiss /= 1)
then
5681 hlak0 = this%xoldpak(n)
5682 call this%lak_calculate_vol(n, hlak0, v0)
5683 call this%lak_calculate_vol(n, hlak, v1)
5684 resid = resid + (v0 - v1) /
delt
5699 integer(I4B) :: nbudterm
5700 integer(I4B) :: nlen
5701 integer(I4B) :: j, n, n1, n2
5702 integer(I4B) :: maxlist, naux
5705 character(len=LENBUDTXT) :: text
5706 character(len=LENBUDTXT),
dimension(1) :: auxtxt
5712 do n = 1, this%noutlets
5713 if (this%lakein(n) > 0 .and. this%lakeout(n) > 0)
then
5717 if (nlen > 0) nbudterm = nbudterm + 1
5718 if (this%imover == 1) nbudterm = nbudterm + 2
5719 if (this%naux > 0) nbudterm = nbudterm + 1
5723 call this%budobj%budgetobject_df(this%nlakes, nbudterm, 0, 0, &
5724 ibudcsv=this%ibudcsv)
5730 text =
' FLOW-JA-FACE'
5734 call this%budobj%budterm(idx)%initialize(text, &
5739 maxlist, .false., .false., &
5740 naux, ordered_id1=.false.)
5743 call this%budobj%budterm(idx)%reset(2 * nlen)
5745 do n = 1, this%noutlets
5747 n2 = this%lakeout(n)
5748 if (n1 > 0 .and. n2 > 0)
then
5749 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5750 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
5758 maxlist = this%maxbound
5760 auxtxt(1) =
' FLOW-AREA'
5761 call this%budobj%budterm(idx)%initialize(text, &
5766 maxlist, .false., .true., &
5768 call this%budobj%budterm(idx)%reset(this%maxbound)
5770 do n = 1, this%nlakes
5771 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5773 call this%budobj%budterm(idx)%update_term(n, n2, q)
5780 maxlist = this%nlakes
5782 call this%budobj%budterm(idx)%initialize(text, &
5787 maxlist, .false., .false., &
5791 text =
' EVAPORATION'
5793 maxlist = this%nlakes
5795 call this%budobj%budterm(idx)%initialize(text, &
5800 maxlist, .false., .false., &
5806 maxlist = this%nlakes
5808 call this%budobj%budterm(idx)%initialize(text, &
5813 maxlist, .false., .false., &
5817 text =
' EXT-INFLOW'
5819 maxlist = this%nlakes
5821 call this%budobj%budterm(idx)%initialize(text, &
5826 maxlist, .false., .false., &
5830 text =
' WITHDRAWAL'
5832 maxlist = this%nlakes
5834 call this%budobj%budterm(idx)%initialize(text, &
5839 maxlist, .false., .false., &
5843 text =
' EXT-OUTFLOW'
5845 maxlist = this%nlakes
5847 call this%budobj%budterm(idx)%initialize(text, &
5852 maxlist, .false., .false., &
5858 maxlist = this%nlakes
5860 auxtxt(1) =
' VOLUME'
5861 call this%budobj%budterm(idx)%initialize(text, &
5866 maxlist, .false., .false., &
5872 maxlist = this%nlakes
5874 call this%budobj%budterm(idx)%initialize(text, &
5879 maxlist, .false., .false., &
5883 if (this%imover == 1)
then
5888 maxlist = this%nlakes
5890 call this%budobj%budterm(idx)%initialize(text, &
5895 maxlist, .false., .false., &
5901 maxlist = this%noutlets
5903 call this%budobj%budterm(idx)%initialize(text, &
5908 maxlist, .false., .false., &
5909 naux, ordered_id1=.false.)
5912 call this%budobj%budterm(idx)%reset(this%noutlets)
5914 do n = 1, this%noutlets
5916 call this%budobj%budterm(idx)%update_term(n1, n1, q)
5927 maxlist = this%nlakes
5928 call this%budobj%budterm(idx)%initialize(text, &
5933 maxlist, .false., .false., &
5938 if (this%iprflow /= 0)
then
5939 call this%budobj%flowtable_df(this%iout)
5952 integer(I4B) :: naux
5953 real(DP),
dimension(:),
allocatable :: auxvartmp
5962 integer(I4B) :: nlen
5965 real(DP) :: lkstg, gwhead, wa
5972 do n = 1, this%noutlets
5973 if (this%lakein(n) > 0 .and. this%lakeout(n) > 0)
then
5979 call this%budobj%budterm(idx)%reset(2 * nlen)
5980 do n = 1, this%noutlets
5982 n2 = this%lakeout(n)
5983 if (n1 > 0 .and. n2 > 0)
then
5984 q = this%simoutrate(n)
5985 if (this%imover == 1)
then
5986 q = q + this%pakmvrobj%get_qtomvr(n)
5988 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5989 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
5996 call this%budobj%budterm(idx)%reset(this%maxbound)
5997 do n = 1, this%nlakes
5998 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
6001 lkstg = this%xnewpak(n)
6005 gwhead = this%xnew(n2)
6006 call this%lak_calculate_conn_warea(n, j, lkstg, gwhead, wa)
6010 if (this%belev(j) > lkstg) wa =
dzero
6011 this%qauxcbc(1) = wa
6012 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
6018 call this%budobj%budterm(idx)%reset(this%nlakes)
6019 do n = 1, this%nlakes
6021 call this%budobj%budterm(idx)%update_term(n, n, q)
6026 call this%budobj%budterm(idx)%reset(this%nlakes)
6027 do n = 1, this%nlakes
6029 call this%budobj%budterm(idx)%update_term(n, n, q)
6034 call this%budobj%budterm(idx)%reset(this%nlakes)
6035 do n = 1, this%nlakes
6037 call this%budobj%budterm(idx)%update_term(n, n, q)
6042 call this%budobj%budterm(idx)%reset(this%nlakes)
6043 do n = 1, this%nlakes
6045 call this%budobj%budterm(idx)%update_term(n, n, q)
6050 call this%budobj%budterm(idx)%reset(this%nlakes)
6051 do n = 1, this%nlakes
6053 call this%budobj%budterm(idx)%update_term(n, n, q)
6058 call this%budobj%budterm(idx)%reset(this%nlakes)
6059 do n = 1, this%nlakes
6060 call this%lak_get_external_outlet(n, q)
6062 call this%lak_get_external_mover(n, v)
6064 call this%budobj%budterm(idx)%update_term(n, n, q)
6069 call this%budobj%budterm(idx)%reset(this%nlakes)
6070 do n = 1, this%nlakes
6071 call this%lak_calculate_vol(n, this%xnewpak(n), v1)
6073 this%qauxcbc(1) = v1
6074 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
6079 call this%budobj%budterm(idx)%reset(this%nlakes)
6080 do n = 1, this%nlakes
6082 call this%budobj%budterm(idx)%update_term(n, n, q)
6086 if (this%imover == 1)
then
6090 call this%budobj%budterm(idx)%reset(this%nlakes)
6091 do n = 1, this%nlakes
6092 q = this%pakmvrobj%get_qfrommvr(n)
6093 call this%budobj%budterm(idx)%update_term(n, n, q)
6098 call this%budobj%budterm(idx)%reset(this%noutlets)
6099 do n = 1, this%noutlets
6101 q = this%pakmvrobj%get_qtomvr(n)
6105 call this%budobj%budterm(idx)%update_term(n1, n1, q)
6114 allocate (auxvartmp(naux))
6115 call this%budobj%budterm(idx)%reset(this%nlakes)
6116 do n = 1, this%nlakes
6120 auxvartmp(jj) = this%lauxvar(jj, ii)
6122 call this%budobj%budterm(idx)%update_term(n, n, q, auxvartmp)
6124 deallocate (auxvartmp)
6128 call this%budobj%accumulate_terms()
6145 integer(I4B) :: nterms
6146 character(len=LINELENGTH) :: title
6147 character(len=LINELENGTH) :: text
6150 if (this%iprhed > 0)
then
6157 if (this%inamedbound == 1)
then
6162 title = trim(adjustl(this%text))//
' PACKAGE ('// &
6163 trim(adjustl(this%packName))//
') STAGES FOR EACH CONTROL VOLUME'
6166 call table_cr(this%stagetab, this%packName, title)
6167 call this%stagetab%table_df(this%nlakes, nterms, this%iout, &
6171 if (this%inamedbound == 1)
then
6173 call this%stagetab%initialize_column(text, 20, alignment=tableft)
6178 call this%stagetab%initialize_column(text, 10, alignment=tabcenter)
6182 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6185 text =
'SURFACE AREA'
6186 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6189 text =
'WETTED AREA'
6190 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6194 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
6205 class(
laktype),
intent(inout) :: this
6207 integer(I4B) :: i, j
6211 call mem_reallocate(this%denseterms, 3, this%MAXBOUND,
'DENSETERMS', &
6213 do i = 1, this%maxbound
6215 this%denseterms(j, i) =
dzero
6218 write (this%iout,
'(/1x,a)')
'DENSITY TERMS HAVE BEEN ACTIVATED FOR LAKE &
6219 &PACKAGE: '//trim(adjustl(this%packName))
6233 class(
laktype),
intent(inout) :: this
6240 call mem_reallocate(this%viscratios, 2, this%MAXBOUND,
'VISCRATIOS', &
6242 do i = 1, this%maxbound
6244 this%viscratios(j, i) =
done
6247 write (this%iout,
'(/1x,a)')
'VISCOSITY HAS BEEN ACTIVATED FOR LAK &
6248 &PACKAGE: '//trim(adjustl(this%packName))
6273 botl, flow, gwfhcof, gwfrhs)
6275 class(
laktype),
intent(inout) :: this
6276 integer(I4B),
intent(in) :: iconn
6277 real(DP),
intent(in) :: stage
6278 real(DP),
intent(in) :: head
6279 real(DP),
intent(in) :: cond
6280 real(DP),
intent(in) :: botl
6281 real(DP),
intent(inout) :: flow
6282 real(DP),
intent(inout) :: gwfhcof
6283 real(DP),
intent(inout) :: gwfrhs
6288 real(DP) :: rdenselak
6289 real(DP) :: rdensegwf
6290 real(DP) :: rdenseavg
6296 logical(LGP) :: stage_below_bot
6297 logical(LGP) :: head_below_bot
6300 if (stage >= botl)
then
6302 stage_below_bot = .false.
6303 rdenselak = this%denseterms(1, iconn)
6306 stage_below_bot = .true.
6307 rdenselak = this%denseterms(2, iconn)
6311 if (head >= botl)
then
6313 head_below_bot = .false.
6314 rdensegwf = this%denseterms(2, iconn)
6317 head_below_bot = .true.
6318 rdensegwf = this%denseterms(1, iconn)
6322 if (rdensegwf ==
dzero)
return
6325 if (stage_below_bot .and. head_below_bot)
then
6332 rdenseavg =
dhalf * (rdenselak + rdensegwf)
6336 d1 = cond * (rdenseavg -
done)
6337 gwfhcof = gwfhcof - d1
6338 gwfrhs = gwfrhs - d1 * ss
6343 if (.not. stage_below_bot .and. .not. head_below_bot)
then
6347 elevgwf = this%denseterms(3, iconn)
6348 if (this%ictype(iconn) == 0 .or. this%ictype(iconn) == 3)
then
6355 elevavg =
dhalf * (elevlak + elevgwf)
6356 havg =
dhalf * (hh + ss)
6357 d2 = cond * (havg - elevavg) * (rdensegwf - rdenselak)
6358 gwfrhs = gwfrhs + d2
This module contains block parser methods.
This module contains the base boundary package.
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
@ tabucstring
upper case string table data
@ tabstring
string table data
@ tabinteger
integer table data
integer(i4b), parameter lenpackagename
maximum length of the package name
integer(i4b), parameter iwetlake
integer constant for a dry lake
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 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 dem1
real constant 1e-1
integer(i4b), parameter maxadpit
maximum advanced package Newton-Raphson iterations
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dhalf
real constant 1/2
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
real(dp), parameter dgravity
real constant gravitational acceleration (m/(s s))
real(dp), parameter dpi
real constant
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 dcd
real constant weir coefficient in SI units
real(dp), parameter dem5
real constant 1e-5
real(dp), parameter dten
real constant 10
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 dem9
real constant 1e-9
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 dthree
real constant 3
real(dp), parameter done
real constant 1
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
This module defines variable data types.
subroutine lak_activate_density(this)
Activate addition of density terms.
subroutine lak_cq(this, x, flowja, iadv)
Calculate flows.
subroutine lak_read_outlets(this)
Read the lake outlets for this package.
subroutine lak_vol2stage(this, ilak, vol, stage)
Determine the stage from a provided volume.
subroutine lak_calculate_outlet_outflow(this, ilak, stage, avail, outoutf)
Calculate the outlet outflow from a lake.
subroutine lak_read_lake_connections(this)
Read the lake connections for this package.
subroutine lak_calculate_sarea(this, ilak, stage, sarea)
Calculate the surface area of a lake at a given stage.
subroutine lak_fn(this, rhs, ia, idxglo, matrix_sln)
Fill newton terms.
subroutine lak_read_tables(this)
Read the lake tables for this package.
subroutine lak_set_stressperiod(this, itemno)
Set a stress period attribute for lakweslls(itemno) using keywords.
subroutine lak_ot_package_flows(this, icbcfl, ibudfl)
Output LAK package flow terms.
subroutine lak_accumulate_chterm(this, ilak, rrate, chratin, chratout)
Accumulate constant head terms for budget.
subroutine lak_process_obsid(obsrv, dis, inunitobs, iout)
This procedure is pointed to by ObsDataTypeProcesssIdPtr. It processes the ID string of an observatio...
subroutine lak_get_external_mover(this, ilak, outoutf)
Get the mover outflow from a lake to an external boundary.
subroutine lak_cf(this)
Formulate the HCOF and RHS terms.
subroutine lak_calculate_density_exchange(this, iconn, stage, head, cond, botl, flow, gwfhcof, gwfrhs)
Calculate the groundwater-lake density exchange terms.
subroutine lak_calculate_evaporation(this, ilak, stage, avail, ev)
Calculate the evaporation from a lake at a provided stage subject to an available volume.
subroutine lak_read_lakes(this)
Read the dimensions for this package.
subroutine lak_setup_budobj(this)
Set up the budget object that stores all the lake flows.
subroutine lak_calculate_external(this, ilak, ex)
Calculate the external flow terms to a lake.
subroutine lak_calculate_warea(this, ilak, stage, warea, hin)
Calculate the wetted area of a lake at a given stage.
subroutine lak_calculate_vol(this, ilak, stage, volume)
Calculate the volume of a lake at a given stage.
subroutine lak_da(this)
Deallocate objects.
subroutine lak_calculate_storagechange(this, ilak, stage, stage0, delt, dvr)
Calculate the storage change in a lake based on provided stages and a passed delt.
subroutine lak_get_internal_outlet(this, ilak, outoutf)
Get the outlet from a lake to another lake.
subroutine lak_calculate_conductance(this, ilak, stage, conductance)
Calculate the total conductance for a lake at a provided stage.
subroutine laktables_to_vectors(this, laketables)
Copy the laketables structure data into flattened vectors that are stored in the memory manager.
subroutine lak_calculate_residual(this, n, hlak, resid, headp)
Calculate the residual for a lake given a passed stage.
subroutine lak_get_outlet_tomover(this, ilak, outoutf)
Get the outlet to mover from a lake.
subroutine lak_allocate_arrays(this)
Allocate scalar members.
subroutine lak_calculate_available(this, n, hlak, avail, ra, ro, qinf, ex, headp)
Calculate the available volumetric rate for a lake given a passed stage.
logical function lak_obs_supported(this)
Procedures related to observations (type-bound)
subroutine lak_set_pointers(this, neq, ibound, xnew, xold, flowja)
Set pointers to model arrays and variables so that a package has access to these things.
subroutine lak_calculate_inflow(this, ilak, qin)
Calculate specified inflow to a lake.
character(len=lenpackagename) text
subroutine lak_ot_model_flows(this, icbcfl, ibudfl, icbcun, imap)
Write flows to binary file and/or print flows to budget.
subroutine lak_rp_obs(this)
Process each observation.
subroutine lak_calculate_conn_conductance(this, ilak, iconn, stage, head, cond)
Calculate the conductance for a lake connection at a provided stage and groundwater head.
subroutine lak_calculate_exchange(this, ilak, stage, totflow)
Calculate the total groundwater-lake flow at a provided stage.
subroutine lak_linear_interpolation(this, n, x, y, z, v)
Perform linear interpolation of two vectors.
subroutine lak_setup_tableobj(this)
Set up the table object that is used to write the lak stage data.
subroutine lak_ot_dv(this, idvsave, idvprint)
Save LAK-calculated values to binary file.
subroutine lak_options(this, option, found)
Set options specific to LakType.
subroutine lak_get_external_outlet(this, ilak, outoutf)
Get the outlet outflow from a lake to an external boundary.
subroutine lak_calculate_rainfall(this, ilak, stage, ra)
Calculate the rainfall for a lake.
subroutine lak_get_internal_inlet(this, ilak, outinf)
Get the outlet inflow to a lake from another lake.
subroutine lak_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
Final convergence check for package.
subroutine lak_rp(this)
Read and Prepare.
subroutine lak_read_dimensions(this)
Read the dimensions for this package.
subroutine lak_activate_viscosity(this)
Activate viscosity terms.
subroutine lak_read_initial_attr(this)
Read the initial parameters for this package.
integer(i4b) function lak_check_valid(this, itemno)
Determine if a valid lake or outlet number has been specified.
subroutine lak_bisection(this, n, ibflg, hlak, temporary_stage, dh, residual)
@ brief Lake package bisection method
subroutine lak_ad(this)
Add package connection to matrix.
subroutine lak_solve(this, update)
Solve for lake stage.
character(len=lenftype) ftype
subroutine lak_fc(this, rhs, ia, idxglo, matrix_sln)
Copy rhs and hcof into solution rhs and amat.
subroutine lak_set_attribute_error(this, ilak, keyword, msg)
Issue a parameter error for lakweslls(ilak)
subroutine lak_calculate_runoff(this, ilak, ro)
Calculate runoff to a lake.
subroutine define_listlabel(this)
Define the list heading that is written to iout when PRINT_INPUT option is used.
subroutine lak_read_table(this, ilak, filename, laketable)
Read the lake table for this package.
subroutine lak_calculate_withdrawal(this, ilak, avail, wr)
Calculate the withdrawal from a lake subject to an available volume.
subroutine lak_calculate_conn_warea(this, ilak, iconn, stage, head, wa)
Calculate the wetted area of a lake connection at a given stage.
subroutine lak_df_obs(this)
Store observation type supported by LAK package. Overrides BndTypebnd_df_obs.
subroutine lak_allocate_scalars(this)
Allocate scalar members.
subroutine lak_bound_update(this)
Store the lake head and connection conductance in the bound array.
subroutine lak_calculate_cond_head(this, iconn, stage, head, vv)
Calculate the controlling lake stage or groundwater head used to calculate the conductance for a lake...
subroutine lak_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Write LAK budget to listing file.
subroutine, public lak_create(packobj, id, ibcnum, inunit, iout, namemodel, pakname)
Create a new LAK Package and point bndobj to the new package.
subroutine lak_bd_obs(this)
Calculate observations this time step and call ObsTypeSaveOneSimval for each LakType observation.
subroutine lak_estimate_conn_exchange(this, iflag, ilak, iconn, idry, stage, head, flow, source, gwfhcof, gwfrhs)
Calculate the groundwater-lake flow at a provided stage and groundwater head.
subroutine lak_fill_budobj(this)
Copy flow terms into thisbudobj.
subroutine lak_get_internal_mover(this, ilak, outoutf)
Get the mover outflow from a lake to another lake.
subroutine lak_calculate_outlet_inflow(this, ilak, outinf)
Calculate the outlet inflow to a lake.
subroutine lak_calculate_conn_exchange(this, ilak, iconn, stage, head, flow, gwfhcof, gwfrhs)
Calculate the groundwater-lake flow at a provided stage and groundwater head.
subroutine lak_ar(this)
Allocate and Read.
pure logical function, public is_close(a, b, rtol, atol, symmetric)
Check if a real value is approximately equal to another.
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.
This module contains the derived type ObsType.
This module contains simulation methods.
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
integer(i4b) ifailedstepretry
current retry for this time step
character(len=maxcharlen) warnmsg
warning message string
real(dp) function squadraticsaturation(top, bot, x, eps)
@ brief sQuadraticSaturation
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
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).