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
330 class(
laktype),
intent(inout) :: this
333 call this%BndType%allocate_scalars()
336 call mem_allocate(this%iprhed,
'IPRHED', this%memoryPath)
337 call mem_allocate(this%istageout,
'ISTAGEOUT', this%memoryPath)
338 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
339 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
340 call mem_allocate(this%ipakcsv,
'IPAKCSV', this%memoryPath)
341 call mem_allocate(this%nlakes,
'NLAKES', this%memoryPath)
342 call mem_allocate(this%noutlets,
'NOUTLETS', this%memoryPath)
343 call mem_allocate(this%ntables,
'NTABLES', this%memoryPath)
344 call mem_allocate(this%convlength,
'CONVLENGTH', this%memoryPath)
345 call mem_allocate(this%convtime,
'CONVTIME', this%memoryPath)
346 call mem_allocate(this%outdmax,
'OUTDMAX', this%memoryPath)
347 call mem_allocate(this%igwhcopt,
'IGWHCOPT', this%memoryPath)
348 call mem_allocate(this%iconvchk,
'ICONVCHK', this%memoryPath)
349 call mem_allocate(this%iconvresidchk,
'ICONVRESIDCHK', this%memoryPath)
350 call mem_allocate(this%maxlakit,
'MAXLAKIT', this%memoryPath)
351 call mem_allocate(this%surfdep,
'SURFDEP', this%memoryPath)
352 call mem_allocate(this%dmaxchg,
'DMAXCHG', this%memoryPath)
355 call mem_allocate(this%check_attr,
'CHECK_ATTR', this%memoryPath)
356 call mem_allocate(this%bditems,
'BDITEMS', this%memoryPath)
357 call mem_allocate(this%cbcauxitems,
'CBCAUXITEMS', this%memoryPath)
358 call mem_allocate(this%idense,
'IDENSE', this%memoryPath)
369 this%convlength =
done
374 this%iconvresidchk = 1
378 this%delh =
dp999 * this%dmaxchg
391 class(
laktype),
intent(inout) :: this
396 call this%BndType%allocate_arrays()
399 allocate (this%clakbudget(this%bditems))
402 this%clakbudget(1) =
' GWF'
403 this%clakbudget(2) =
' RAINFALL'
404 this%clakbudget(3) =
' EVAPORATION'
405 this%clakbudget(4) =
' RUNOFF'
406 this%clakbudget(5) =
' EXT-INFLOW'
407 this%clakbudget(6) =
' WITHDRAWAL'
408 this%clakbudget(7) =
' EXT-OUTFLOW'
409 this%clakbudget(8) =
' STORAGE'
410 this%clakbudget(9) =
' CONSTANT'
411 this%clakbudget(10) =
' FROM-MVR'
412 this%clakbudget(11) =
' TO-MVR'
415 if (this%istageout > 0)
then
416 call mem_allocate(this%dbuff, this%nlakes,
'DBUFF', this%memoryPath)
417 do i = 1, this%nlakes
418 this%dbuff(i) =
dzero
421 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
425 allocate (this%cauxcbc(this%cbcauxitems))
428 call mem_allocate(this%qauxcbc, this%cbcauxitems,
'QAUXCBC', this%memoryPath)
429 do i = 1, this%cbcauxitems
430 this%qauxcbc(i) =
dzero
434 call mem_allocate(this%qleak, this%maxbound,
'QLEAK', this%memoryPath)
435 do i = 1, this%maxbound
436 this%qleak(i) =
dzero
438 call mem_allocate(this%qsto, this%nlakes,
'QSTO', this%memoryPath)
439 do i = 1, this%nlakes
444 call mem_allocate(this%denseterms, 3, 0,
'DENSETERMS', this%memoryPath)
447 call mem_allocate(this%viscratios, 2, 0,
'VISCRATIOS', this%memoryPath)
458 class(
laktype),
intent(inout) :: this
460 character(len=LINELENGTH) :: text
461 character(len=LENBOUNDNAME) :: bndName, bndNameTemp
462 character(len=9) :: cno
463 character(len=50),
dimension(:),
allocatable :: caux
464 integer(I4B) :: ierr, ival
465 logical(LGP) :: isfound, endOfBlock
467 integer(I4B) :: ii, jj
471 integer(I4B) :: nconn
472 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
473 real(DP),
pointer :: bndElem => null()
479 call mem_allocate(this%nlakeconn, this%nlakes,
'NLAKECONN', this%memoryPath)
480 call mem_allocate(this%idxlakeconn, this%nlakes + 1,
'IDXLAKECONN', &
482 call mem_allocate(this%ntabrow, this%nlakes,
'NTABROW', this%memoryPath)
483 call mem_allocate(this%strt, this%nlakes,
'STRT', this%memoryPath)
484 call mem_allocate(this%laketop, this%nlakes,
'LAKETOP', this%memoryPath)
485 call mem_allocate(this%lakebot, this%nlakes,
'LAKEBOT', this%memoryPath)
486 call mem_allocate(this%sareamax, this%nlakes,
'SAREAMAX', this%memoryPath)
487 call mem_allocate(this%stage, this%nlakes,
'STAGE', this%memoryPath)
488 call mem_allocate(this%rainfall, this%nlakes,
'RAINFALL', this%memoryPath)
489 call mem_allocate(this%evaporation, this%nlakes,
'EVAPORATION', &
491 call mem_allocate(this%runoff, this%nlakes,
'RUNOFF', this%memoryPath)
492 call mem_allocate(this%inflow, this%nlakes,
'INFLOW', this%memoryPath)
493 call mem_allocate(this%withdrawal, this%nlakes,
'WITHDRAWAL', this%memoryPath)
494 call mem_allocate(this%lauxvar, this%naux, this%nlakes,
'LAUXVAR', &
496 call mem_allocate(this%avail, this%nlakes,
'AVAIL', this%memoryPath)
497 call mem_allocate(this%lkgwsink, this%nlakes,
'LKGWSINK', this%memoryPath)
498 call mem_allocate(this%ncncvr, this%nlakes,
'NCNCVR', this%memoryPath)
499 call mem_allocate(this%surfin, this%nlakes,
'SURFIN', this%memoryPath)
500 call mem_allocate(this%surfout, this%nlakes,
'SURFOUT', this%memoryPath)
501 call mem_allocate(this%surfout1, this%nlakes,
'SURFOUT1', this%memoryPath)
502 call mem_allocate(this%precip, this%nlakes,
'PRECIP', this%memoryPath)
503 call mem_allocate(this%precip1, this%nlakes,
'PRECIP1', this%memoryPath)
504 call mem_allocate(this%evap, this%nlakes,
'EVAP', this%memoryPath)
505 call mem_allocate(this%evap1, this%nlakes,
'EVAP1', this%memoryPath)
506 call mem_allocate(this%evapo, this%nlakes,
'EVAPO', this%memoryPath)
507 call mem_allocate(this%withr, this%nlakes,
'WITHR', this%memoryPath)
508 call mem_allocate(this%withr1, this%nlakes,
'WITHR1', this%memoryPath)
509 call mem_allocate(this%flwin, this%nlakes,
'FLWIN', this%memoryPath)
510 call mem_allocate(this%flwiter, this%nlakes,
'FLWITER', this%memoryPath)
511 call mem_allocate(this%flwiter1, this%nlakes,
'FLWITER1', this%memoryPath)
512 call mem_allocate(this%seep, this%nlakes,
'SEEP', this%memoryPath)
513 call mem_allocate(this%seep1, this%nlakes,
'SEEP1', this%memoryPath)
514 call mem_allocate(this%seep0, this%nlakes,
'SEEP0', this%memoryPath)
515 call mem_allocate(this%stageiter, this%nlakes,
'STAGEITER', this%memoryPath)
516 call mem_allocate(this%chterm, this%nlakes,
'CHTERM', this%memoryPath)
519 call mem_allocate(this%iboundpak, this%nlakes,
'IBOUND', this%memoryPath)
520 call mem_allocate(this%xnewpak, this%nlakes,
'XNEWPAK', this%memoryPath)
521 call mem_allocate(this%xoldpak, this%nlakes,
'XOLDPAK', this%memoryPath)
524 call mem_allocate(this%iseepc, this%nlakes,
'ISEEPC', this%memoryPath)
525 call mem_allocate(this%idhc, this%nlakes,
'IDHC', this%memoryPath)
526 call mem_allocate(this%en1, this%nlakes,
'EN1', this%memoryPath)
527 call mem_allocate(this%en2, this%nlakes,
'EN2', this%memoryPath)
528 call mem_allocate(this%r1, this%nlakes,
'R1', this%memoryPath)
529 call mem_allocate(this%r2, this%nlakes,
'R2', this%memoryPath)
530 call mem_allocate(this%dh0, this%nlakes,
'DH0', this%memoryPath)
531 call mem_allocate(this%s0, this%nlakes,
'S0', this%memoryPath)
532 call mem_allocate(this%qgwf0, this%nlakes,
'QGWF0', this%memoryPath)
535 allocate (this%lakename(this%nlakes))
536 allocate (this%status(this%nlakes))
538 do n = 1, this%nlakes
540 this%status(n) =
'ACTIVE'
541 this%laketop(n) = -dep20
542 this%lakebot(n) = dep20
543 this%sareamax(n) = dzero
544 this%iboundpak(n) = 1
545 this%xnewpak(n) = dep20
546 this%xoldpak(n) = dep20
549 this%rainfall(n) = dzero
550 this%evaporation(n) = dzero
551 this%runoff(n) = dzero
552 this%inflow(n) = dzero
553 this%withdrawal(n) = dzero
557 if (this%naux > 0)
then
558 allocate (caux(this%naux))
562 allocate (nboundchk(this%nlakes))
563 do n = 1, this%nlakes
569 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
570 supportopenclose=.true.)
574 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
579 call this%parser%GetNextLine(endofblock)
581 n = this%parser%GetInteger()
583 if (n < 1 .or. n > this%nlakes)
then
584 write (
errmsg,
'(a,1x,i0)')
'lakeno MUST BE > 0 and <= ', this%nlakes
590 nboundchk(n) = nboundchk(n) + 1
593 this%strt(n) = this%parser%GetDouble()
596 ival = this%parser%GetInteger()
599 write (
errmsg,
'(a,1x,i0)')
'nlakeconn MUST BE >= 0 for lake ', n
604 this%nlakeconn(n) = ival
607 do iaux = 1, this%naux
608 call this%parser%GetString(caux(iaux))
612 write (cno,
'(i9.9)') n
613 bndname =
'Lake'//cno
616 if (this%inamedbound /= 0)
then
617 call this%parser%GetStringCaps(bndnametemp)
618 if (bndnametemp /=
'')
then
619 bndname = bndnametemp
622 this%lakename(n) = bndname
629 bndelem => this%lauxvar(jj, ii)
631 this%packName,
'AUX', &
632 this%tsManager, this%iprpak, &
640 do n = 1, this%nlakes
641 if (nboundchk(n) == 0)
then
642 write (
errmsg,
'(a,1x,i0)')
'NO DATA SPECIFIED FOR LAKE', n
644 else if (nboundchk(n) > 1)
then
645 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
646 'DATA FOR LAKE', n,
'SPECIFIED', nboundchk(n),
'TIMES'
651 write (this%iout,
'(1x,a)')
'END OF '//trim(adjustl(this%text))// &
654 call store_error(
'REQUIRED PACKAGEDATA BLOCK NOT FOUND.')
659 call this%parser%StoreErrorUnit()
663 this%MAXBOUND = nconn
664 write (this%iout,
'(//4x,a,i7)')
'MAXBOUND = ', this%maxbound
667 this%idxlakeconn(1) = 1
668 do n = 1, this%nlakes
669 this%idxlakeconn(n + 1) = this%idxlakeconn(n) + this%nlakeconn(n)
673 if (this%naux > 0)
then
678 deallocate (nboundchk)
687 class(
laktype),
intent(inout) :: this
689 character(len=LINELENGTH) :: keyword, cellid
690 integer(I4B) :: ierr, ival
691 logical(LGP) :: isfound, endOfBlock
692 logical(LGP) :: is_lake_bed
696 integer(I4B) :: ipos, ipos0
697 integer(I4B) :: icellid, icellid0
700 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
701 character(len=LENVARNAME) :: ctypenm
704 allocate (nboundchk(this%MAXBOUND))
705 do n = 1, this%MAXBOUND
710 call this%parser%GetBlock(
'CONNECTIONDATA', isfound, ierr, &
711 supportopenclose=.true.)
716 call mem_allocate(this%imap, this%MAXBOUND,
'IMAP', this%memoryPath)
717 call mem_allocate(this%cellid, this%MAXBOUND,
'CELLID', this%memoryPath)
718 call mem_allocate(this%nodesontop, this%MAXBOUND,
'NODESONTOP', &
720 call mem_allocate(this%ictype, this%MAXBOUND,
'ICTYPE', this%memoryPath)
721 call mem_allocate(this%bedleak, this%MAXBOUND,
'BEDLEAK', this%memoryPath)
722 call mem_allocate(this%belev, this%MAXBOUND,
'BELEV', this%memoryPath)
723 call mem_allocate(this%telev, this%MAXBOUND,
'TELEV', this%memoryPath)
724 call mem_allocate(this%connlength, this%MAXBOUND,
'CONNLENGTH', &
726 call mem_allocate(this%connwidth, this%MAXBOUND,
'CONNWIDTH', &
728 call mem_allocate(this%sarea, this%MAXBOUND,
'SAREA', this%memoryPath)
729 call mem_allocate(this%warea, this%MAXBOUND,
'WAREA', this%memoryPath)
730 call mem_allocate(this%satcond, this%MAXBOUND,
'SATCOND', this%memoryPath)
731 call mem_allocate(this%simcond, this%MAXBOUND,
'SIMCOND', this%memoryPath)
732 call mem_allocate(this%simlakgw, this%MAXBOUND,
'SIMLAKGW', this%memoryPath)
735 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
738 call this%parser%GetNextLine(endofblock)
740 n = this%parser%GetInteger()
742 if (n < 1 .or. n > this%nlakes)
then
743 write (
errmsg,
'(a,1x,i0)')
'lakeno MUST BE > 0 and <= ', this%nlakes
749 ival = this%parser%GetInteger()
750 if (ival < 1 .or. ival > this%nlakeconn(n))
then
751 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
752 'iconn FOR LAKE ', n,
'MUST BE > 1 and <= ', this%nlakeconn(n)
758 ipos = this%idxlakeconn(n) + ival - 1
765 nboundchk(ipos) = nboundchk(ipos) + 1
768 call this%parser%GetCellid(this%dis%ndim, cellid)
769 nn = this%dis%noder_from_cellid(cellid, &
770 this%parser%iuactive, this%iout)
774 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
775 'INVALID cellid FOR LAKE ', n,
'connection', j
780 this%cellid(ipos) = nn
781 this%nodesontop(ipos) = nn
784 call this%parser%GetStringCaps(keyword)
785 select case (keyword)
787 this%ictype(ipos) = 0
789 this%ictype(ipos) = 1
791 this%ictype(ipos) = 2
793 this%ictype(ipos) = 3
795 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,a,a)') &
796 'UNKNOWN ctype FOR LAKE ', n,
'connection', j, &
797 '(', trim(keyword),
')'
800 write (ctypenm,
'(a16)') keyword
804 call this%parser%GetStringCaps(keyword)
805 select case (keyword)
807 is_lake_bed = .false.
808 this%bedleak(ipos) = dnodata
811 write (
warnmsg,
'(2(a,1x,i0,1x),a,1pe8.1,a)') &
812 'BEDLEAK for connection', j,
'in lake', n,
'is specified to '// &
813 'be NONE. Lake connections where the lake-GWF connection '// &
814 'conductance is solely a function of aquifer properties '// &
815 'in the connected GWF cell should be specified with a '// &
816 'DNODATA (', dnodata,
') value.'
819 call deprecation_warning(
'CONNECTIONDATA',
'bedleak=NONE',
'6.4.3', &
820 warnmsg, this%parser%GetUnit())
822 read (keyword, *) rval
824 is_lake_bed = .false.
828 this%bedleak(ipos) = rval
831 if (is_lake_bed .and. this%bedleak(ipos) < dzero)
then
832 write (
errmsg,
'(a,1x,i0,1x,a)')
'bedleak FOR LAKE ', n,
'MUST BE >= 0'
837 this%belev(ipos) = this%parser%GetDouble()
840 this%telev(ipos) = this%parser%GetDouble()
843 rval = this%parser%GetDouble()
844 if (rval <= dzero)
then
845 if (this%ictype(ipos) == 1 .or. this%ictype(ipos) == 2 .or. &
846 this%ictype(ipos) == 3)
then
847 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,a,1x,a)') &
848 'connection length (connlen) FOR LAKE ', n, &
849 ', CONNECTION NO.', j,
', MUST BE > 0 FOR SPECIFIED ', &
850 'connection type (ctype)', ctypenm
856 this%connlength(ipos) = rval
859 rval = this%parser%GetDouble()
860 if (rval < dzero)
then
861 if (this%ictype(ipos) == 1)
then
862 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
863 'cell width (connwidth) FOR LAKE ', n, &
864 ' HORIZONTAL CONNECTION ', j,
'MUST BE >= 0'
870 this%connwidth(ipos) = rval
872 write (this%iout,
'(1x,a)') &
873 'END OF '//trim(adjustl(this%text))//
' CONNECTIONDATA'
875 call store_error(
'REQUIRED CONNECTIONDATA BLOCK NOT FOUND.')
880 call this%parser%StoreErrorUnit()
884 do n = 1, this%nlakes
886 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
887 if (this%ictype(ipos) /= 2 .and. this%ictype(ipos) /= 3) cycle
890 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
891 'nlakeconn FOR LAKE', n,
'EMBEDDED CONNECTION', j,
' EXCEEDS 1.'
898 do n = 1, this%nlakes
899 ipos0 = this%idxlakeconn(n)
900 icellid0 = this%cellid(ipos0)
901 if (this%ictype(ipos0) /= 2 .and. this%ictype(ipos0) /= 3) cycle
902 do nn = 1, this%nlakes
905 do ipos = this%idxlakeconn(nn), this%idxlakeconn(nn + 1) - 1
907 icellid = this%cellid(ipos)
908 if (icellid == icellid0)
then
909 if (this%ictype(ipos) == 0)
then
910 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
911 'EMBEDDED LAKE', n, &
912 'CANNOT COINCIDE WITH VERTICAL CONNECTION', j, &
922 do n = 1, this%nlakes
924 do ipos = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
926 nn = this%cellid(ipos)
927 top = this%dis%top(nn)
928 bot = this%dis%bot(nn)
930 if (this%ictype(ipos) == 0)
then
931 this%telev(ipos) = top + this%surfdep
932 this%belev(ipos) = top
933 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
935 else if (this%ictype(ipos) == 1)
then
936 if (this%belev(ipos) == this%telev(ipos))
then
937 this%telev(ipos) = top
938 this%belev(ipos) = bot
940 if (this%belev(ipos) >= this%telev(ipos))
then
941 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
942 'telev FOR LAKE ', n,
' HORIZONTAL CONNECTION ', j, &
945 else if (this%belev(ipos) < bot)
then
946 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
947 'belev FOR LAKE ', n,
' HORIZONTAL CONNECTION ', j, &
948 'MUST BE >= cell bottom (', bot,
')'
950 else if (this%telev(ipos) > top)
then
951 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.7,1x,a)') &
952 'telev FOR LAKE ', n,
' HORIZONTAL CONNECTION ', j, &
953 'MUST BE <= cell top (', top,
')'
957 this%laketop(n) = max(this%telev(ipos), this%laketop(n))
958 this%lakebot(n) = min(this%belev(ipos), this%lakebot(n))
960 else if (this%ictype(ipos) == 2 .or. this%ictype(ipos) == 3)
then
961 this%telev(ipos) = top
962 this%belev(ipos) = bot
963 this%lakebot(n) = bot
967 if (nboundchk(ipos) == 0)
then
968 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
969 'NO DATA SPECIFIED FOR LAKE', n,
'CONNECTION', j
971 else if (nboundchk(ipos) > 1)
then
972 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a,1x,i0,1x,a)') &
973 'DATA FOR LAKE', n,
'CONNECTION', j, &
974 'SPECIFIED', nboundchk(ipos),
'TIMES'
980 if (this%laketop(n) == -dep20)
then
981 this%laketop(n) = this%lakebot(n) + 100.
986 deallocate (nboundchk)
990 call this%parser%StoreErrorUnit()
1000 class(
laktype),
intent(inout) :: this
1002 type(
laktabtype),
dimension(:),
allocatable :: laketables
1003 character(len=LINELENGTH) :: line
1004 character(len=LINELENGTH) :: keyword
1005 integer(I4B) :: ierr
1006 logical(LGP) :: isfound, endOfBlock
1008 integer(I4B) :: iconn
1009 integer(I4B) :: ntabs
1010 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1013 if (this%ntables < 1)
return
1016 allocate (nboundchk(this%nlakes))
1017 do n = 1, this%nlakes
1022 allocate (laketables(this%nlakes))
1025 call this%parser%GetBlock(
'TABLES', isfound, ierr, &
1026 supportopenclose=.true.)
1032 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1035 call this%parser%GetNextLine(endofblock)
1036 if (endofblock)
exit
1037 n = this%parser%GetInteger()
1039 if (n < 1 .or. n > this%nlakes)
then
1040 write (
errmsg,
'(a,1x,i0)')
'lakeno MUST BE > 0 and <= ', this%nlakes
1047 nboundchk(n) = nboundchk(n) + 1
1050 call this%parser%GetStringCaps(keyword)
1051 select case (keyword)
1053 call this%parser%GetStringCaps(keyword)
1054 if (trim(adjustl(keyword)) /=
'FILEIN')
then
1055 errmsg =
'TAB6 keyword must be followed by "FILEIN" '// &
1060 call this%parser%GetString(line)
1061 call this%lak_read_table(n, line, laketables(n))
1063 write (
errmsg,
'(a,1x,i0,1x,a)') &
1064 'LAKE TABLE ENTRY for LAKE ', n,
'MUST INCLUDE TAB6 KEYWORD'
1070 write (this%iout,
'(1x,a)') &
1071 'END OF '//trim(adjustl(this%text))//
' LAKE_TABLES'
1074 if (ntabs < this%ntables)
then
1075 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1076 'TABLE DATA ARE SPECIFIED', ntabs, &
1077 'TIMES BUT NTABLES IS SET TO', this%ntables
1080 do n = 1, this%nlakes
1081 if (this%ntabrow(n) > 0 .and. nboundchk(n) > 1)
then
1082 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1083 'TABLE DATA FOR LAKE', n,
'SPECIFIED', nboundchk(n),
'TIMES'
1088 call store_error(
'REQUIRED TABLES BLOCK NOT FOUND.')
1092 deallocate (nboundchk)
1096 call this%parser%StoreErrorUnit()
1100 call this%laktables_to_vectors(laketables)
1103 do n = 1, this%nlakes
1104 if (this%ntabrow(n) > 0)
then
1105 deallocate (laketables(n)%tabstage)
1106 deallocate (laketables(n)%tabvolume)
1107 deallocate (laketables(n)%tabsarea)
1108 iconn = this%idxlakeconn(n)
1109 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1110 deallocate (laketables(n)%tabwarea)
1114 deallocate (laketables)
1121 class(
laktype),
intent(inout) :: this
1122 type(
laktabtype),
intent(in),
dimension(:),
contiguous :: laketables
1124 integer(I4B) :: ntabrows
1126 integer(I4B) :: ipos
1127 integer(I4B) :: iconn
1130 call mem_allocate(this%ialaktab, this%nlakes + 1,
'IALAKTAB', this%memoryPath)
1133 this%ialaktab(1) = 1
1134 do n = 1, this%nlakes
1136 this%ialaktab(n + 1) = this%ialaktab(n) + this%ntabrow(n)
1140 ntabrows = this%ialaktab(this%nlakes + 1) - 1
1141 call mem_allocate(this%tabstage, ntabrows,
'TABSTAGE', this%memoryPath)
1142 call mem_allocate(this%tabvolume, ntabrows,
'TABVOLUME', this%memoryPath)
1143 call mem_allocate(this%tabsarea, ntabrows,
'TABSAREA', this%memoryPath)
1144 call mem_allocate(this%tabwarea, ntabrows,
'TABWAREA', this%memoryPath)
1147 do n = 1, this%nlakes
1149 do ipos = this%ialaktab(n), this%ialaktab(n + 1) - 1
1150 this%tabstage(ipos) = laketables(n)%tabstage(j)
1151 this%tabvolume(ipos) = laketables(n)%tabvolume(j)
1152 this%tabsarea(ipos) = laketables(n)%tabsarea(j)
1153 iconn = this%idxlakeconn(n)
1154 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1157 this%tabwarea(ipos) = laketables(n)%tabwarea(j)
1159 this%tabwarea(ipos) =
dzero
1173 class(
laktype),
intent(inout) :: this
1174 integer(I4B),
intent(in) :: ilak
1175 character(len=*),
intent(in) :: filename
1178 character(len=LINELENGTH) :: keyword
1179 integer(I4B) :: ierr
1180 logical(LGP) :: isfound, endOfBlock
1183 integer(I4B) :: ipos
1185 integer(I4B) :: jmin
1186 integer(I4B) :: iconn
1194 character(len=*),
parameter :: fmttaberr = &
1195 &
'(a,1x,i0,1x,a,1x,g15.6,1x,a,1x,i0,1x,a,1x,i0,1x,a,1x,g15.6,1x,a)'
1203 call openfile(iu, this%iout, filename,
'LAKE TABLE')
1204 call parser%Initialize(iu, this%iout)
1207 call parser%GetBlock(
'DIMENSIONS', isfound, ierr, supportopenclose=.true.)
1212 if (this%iprpak /= 0)
then
1213 write (this%iout,
'(/1x,a)') &
1214 'PROCESSING '//trim(adjustl(this%text))//
' DIMENSIONS'
1217 call parser%GetNextLine(endofblock)
1218 if (endofblock)
exit
1219 call parser%GetStringCaps(keyword)
1220 select case (keyword)
1222 n = parser%GetInteger()
1225 write (
errmsg,
'(a)')
'LAKE TABLE NROW MUST BE > 0'
1229 j = parser%GetInteger()
1231 if (this%ictype(ilak) == 2 .or. this%ictype(ilak) == 3)
then
1237 write (
errmsg,
'(a,1x,i0)')
'LAKE TABLE NCOL MUST BE >= ', jmin
1242 write (
errmsg,
'(a,a)') &
1243 'UNKNOWN '//trim(this%text)//
' DIMENSIONS KEYWORD: ', trim(keyword)
1247 if (this%iprpak /= 0)
then
1248 write (this%iout,
'(1x,a)') &
1249 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
1252 call store_error(
'REQUIRED DIMENSIONS BLOCK NOT FOUND.')
1258 'NROW NOT SPECIFIED IN THE LAKE TABLE DIMENSIONS BLOCK'
1263 'NCOL NOT SPECIFIED IN THE LAKE TABLE DIMENSIONS BLOCK'
1272 this%ntabrow(ilak) = n
1273 allocate (laketable%tabstage(n))
1274 allocate (laketable%tabvolume(n))
1275 allocate (laketable%tabsarea(n))
1276 ipos = this%idxlakeconn(ilak)
1277 if (this%ictype(ipos) == 2 .or. this%ictype(ipos) == 3)
then
1278 allocate (laketable%tabwarea(n))
1282 call parser%GetBlock(
'TABLE', isfound, ierr, supportopenclose=.true.)
1288 if (this%iprpak /= 0)
then
1289 write (this%iout,
'(/1x,a)') &
1290 'PROCESSING '//trim(adjustl(this%text))//
' TABLE'
1292 iconn = this%idxlakeconn(ilak)
1295 call parser%GetNextLine(endofblock)
1296 if (endofblock)
exit
1298 if (ipos > this%ntabrow(ilak))
then
1301 laketable%tabstage(ipos) = parser%GetDouble()
1302 laketable%tabvolume(ipos) = parser%GetDouble()
1303 laketable%tabsarea(ipos) = parser%GetDouble()
1304 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1305 laketable%tabwarea(ipos) = parser%GetDouble()
1307 end do readtabledata
1309 if (this%iprpak /= 0)
then
1310 write (this%iout,
'(1x,a)') &
1311 'END OF '//trim(adjustl(this%text))//
' TABLE'
1314 call store_error(
'REQUIRED TABLE BLOCK NOT FOUND.')
1318 if (ipos /= this%ntabrow(ilak))
then
1319 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1320 'NROW SET TO', this%ntabrow(ilak),
'BUT', ipos,
'ROWS WERE READ'
1325 iconn = this%idxlakeconn(ilak)
1326 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1327 do n = 1, this%ntabrow(ilak)
1328 vol = laketable%tabvolume(n)
1329 sa = laketable%tabsarea(n)
1330 wa = laketable%tabwarea(n)
1333 if (vol > dzero)
exit
1335 this%lakebot(ilak) = laketable%tabstage(n)
1336 this%belev(ilak) = laketable%tabstage(n)
1339 n = this%ntabrow(ilak)
1340 this%sareamax(ilak) = laketable%tabsarea(n)
1344 do n = 2, this%ntabrow(ilak)
1345 v = laketable%tabstage(n)
1346 v0 = laketable%tabstage(n - 1)
1348 write (
errmsg, fmttaberr) &
1349 'TABLE STAGE ENTRY', n,
'(', laketable%tabstage(n),
') FOR LAKE ', &
1350 ilak,
'MUST BE GREATER THAN THE PREVIOUS STAGE ENTRY', &
1351 n - 1,
'(', laketable%tabstage(n - 1),
')'
1354 v = laketable%tabvolume(n)
1355 v0 = laketable%tabvolume(n - 1)
1357 write (
errmsg, fmttaberr) &
1358 'TABLE VOLUME ENTRY', n,
'(', laketable%tabvolume(n), &
1360 ilak,
'MUST BE GREATER THAN THE PREVIOUS VOLUME ENTRY', &
1361 n - 1,
'(', laketable%tabvolume(n - 1),
')'
1364 v = laketable%tabsarea(n)
1365 v0 = laketable%tabsarea(n - 1)
1367 write (
errmsg, fmttaberr) &
1368 'TABLE SURFACE AREA ENTRY', n,
'(', &
1369 laketable%tabsarea(n),
') FOR LAKE ', ilak, &
1370 'MUST BE GREATER THAN OR EQUAL TO THE PREVIOUS SURFACE AREA ENTRY', &
1371 n - 1,
'(', laketable%tabsarea(n - 1),
')'
1374 iconn = this%idxlakeconn(ilak)
1375 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
1376 v = laketable%tabwarea(n)
1377 v0 = laketable%tabwarea(n - 1)
1379 write (
errmsg, fmttaberr) &
1380 'TABLE EXCHANGE AREA ENTRY', n,
'(', &
1381 laketable%tabwarea(n),
') FOR LAKE ', ilak, &
1382 'MUST BE GREATER THAN OR EQUAL TO THE PREVIOUS EXCHANGE AREA '// &
1383 'ENTRY', n - 1,
'(', laketable%tabwarea(n - 1),
')'
1392 call parser%StoreErrorUnit()
1406 class(
laktype),
intent(inout) :: this
1408 character(len=LINELENGTH) :: text, keyword
1409 character(len=LENBOUNDNAME) :: bndName
1410 character(len=9) :: citem
1411 integer(I4B) :: ierr, ival
1412 logical(LGP) :: isfound, endOfBlock
1415 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1416 real(DP),
pointer :: bndElem => null()
1419 call this%parser%GetBlock(
'OUTLETS', isfound, ierr, &
1420 supportopenclose=.true., blockrequired=.false.)
1424 if (this%noutlets > 0)
then
1427 allocate (nboundchk(this%noutlets))
1428 do n = 1, this%noutlets
1433 call mem_allocate(this%lakein, this%NOUTLETS,
'LAKEIN', this%memoryPath)
1434 call mem_allocate(this%lakeout, this%NOUTLETS,
'LAKEOUT', this%memoryPath)
1435 call mem_allocate(this%iouttype, this%NOUTLETS,
'IOUTTYPE', &
1437 call mem_allocate(this%outrate, this%NOUTLETS,
'OUTRATE', this%memoryPath)
1438 call mem_allocate(this%outinvert, this%NOUTLETS,
'OUTINVERT', &
1440 call mem_allocate(this%outwidth, this%NOUTLETS,
'OUTWIDTH', &
1442 call mem_allocate(this%outrough, this%NOUTLETS,
'OUTROUGH', &
1444 call mem_allocate(this%outslope, this%NOUTLETS,
'OUTSLOPE', &
1446 call mem_allocate(this%simoutrate, this%NOUTLETS,
'SIMOUTRATE', &
1450 do n = 1, this%noutlets
1451 this%outrate(n) = dzero
1455 write (this%iout,
'(/1x,a)') &
1456 'PROCESSING '//trim(adjustl(this%text))//
' OUTLETS'
1458 call this%parser%GetNextLine(endofblock)
1459 if (endofblock)
exit
1460 n = this%parser%GetInteger()
1462 if (n < 1 .or. n > this%noutlets)
then
1463 write (
errmsg,
'(a,1x,i0)') &
1464 'outletno MUST BE > 0 and <= ', this%noutlets
1470 nboundchk(n) = nboundchk(n) + 1
1473 ival = this%parser%GetInteger()
1474 if (ival < 1 .or. ival > this%nlakes)
then
1475 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1476 'lakein FOR OUTLET ', n,
'MUST BE > 0 and <= ', this%nlakes
1480 this%lakein(n) = ival
1483 ival = this%parser%GetInteger()
1484 if (ival < 0 .or. ival > this%nlakes)
then
1485 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0)') &
1486 'lakeout FOR OUTLET ', n,
'MUST BE >= 0 and <= ', this%nlakes
1490 this%lakeout(n) = ival
1493 call this%parser%GetStringCaps(keyword)
1494 select case (keyword)
1496 this%iouttype(n) = 0
1498 this%iouttype(n) = 1
1500 this%iouttype(n) = 2
1502 write (
errmsg,
'(a,1x,i0,1x,a,a,a)') &
1503 'UNKNOWN couttype FOR OUTLET ', n,
'(', trim(keyword),
')'
1509 write (citem,
'(i9.9)') n
1510 bndname =
'OUTLET'//citem
1516 call this%parser%GetString(text)
1517 bndelem => this%outinvert(n)
1519 this%packName,
'BND', &
1520 this%tsManager, this%iprpak, &
1524 call this%parser%GetString(text)
1525 bndelem => this%outwidth(n)
1527 this%packName,
'BND', &
1528 this%tsManager, this%iprpak,
'WIDTH')
1531 call this%parser%GetString(text)
1532 bndelem => this%outrough(n)
1534 this%packName,
'BND', &
1535 this%tsManager, this%iprpak,
'ROUGH')
1538 call this%parser%GetString(text)
1539 bndelem => this%outslope(n)
1541 this%packName,
'BND', &
1542 this%tsManager, this%iprpak,
'SLOPE')
1544 write (this%iout,
'(1x,a)')
'END OF '//trim(adjustl(this%text))// &
1548 do n = 1, this%noutlets
1549 if (nboundchk(n) == 0)
then
1550 write (
errmsg,
'(a,1x,i0)')
'NO DATA SPECIFIED FOR OUTLET', n
1552 else if (nboundchk(n) > 1)
then
1553 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1554 'DATA FOR OUTLET', n,
'SPECIFIED', nboundchk(n),
'TIMES'
1560 deallocate (nboundchk)
1562 write (
errmsg,
'(a,1x,a)') &
1563 'AN OUTLETS BLOCK SHOULD NOT BE SPECIFIED IF NOUTLETS IS NOT', &
1564 'SPECIFIED OR IS SPECIFIED TO BE 0.'
1569 if (this%noutlets > 0)
then
1570 call store_error(
'REQUIRED OUTLETS BLOCK NOT FOUND.')
1577 call this%parser%StoreErrorUnit()
1587 class(
laktype),
intent(inout) :: this
1589 character(len=LINELENGTH) :: keyword
1590 integer(I4B) :: ierr
1591 logical(LGP) :: isfound, endOfBlock
1598 call this%parser%GetBlock(
'DIMENSIONS', isfound, ierr, &
1599 supportopenclose=.true.)
1603 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1606 call this%parser%GetNextLine(endofblock)
1607 if (endofblock)
exit
1608 call this%parser%GetStringCaps(keyword)
1609 select case (keyword)
1611 this%nlakes = this%parser%GetInteger()
1612 write (this%iout,
'(4x,a,i7)')
'NLAKES = ', this%nlakes
1614 this%noutlets = this%parser%GetInteger()
1615 write (this%iout,
'(4x,a,i7)')
'NOUTLETS = ', this%noutlets
1617 this%ntables = this%parser%GetInteger()
1618 write (this%iout,
'(4x,a,i7)')
'NTABLES = ', this%ntables
1620 write (
errmsg,
'(a,a)') &
1621 'UNKNOWN '//trim(this%text)//
' DIMENSION: ', trim(keyword)
1625 write (this%iout,
'(1x,a)') &
1626 'END OF '//trim(adjustl(this%text))//
' DIMENSIONS'
1628 call store_error(
'REQUIRED DIMENSIONS BLOCK NOT FOUND.')
1631 if (this%nlakes < 0)
then
1633 'NLAKES WAS NOT SPECIFIED OR WAS SPECIFIED INCORRECTLY.'
1639 call this%parser%StoreErrorUnit()
1643 call this%lak_read_lakes()
1646 call this%lak_read_lake_connections()
1649 call this%lak_read_tables()
1652 call this%lak_read_outlets()
1656 call this%define_listlabel()
1659 call this%lak_setup_budobj()
1662 call this%lak_setup_tableobj()
1673 class(
laktype),
intent(inout) :: this
1675 character(len=LINELENGTH) :: text
1676 integer(I4B) :: j, jj, n
1693 real(DP),
allocatable,
dimension(:) :: clb, caq
1694 character(len=14) :: cbedleak
1695 character(len=14) :: cbedcond
1696 character(len=10),
dimension(0:3) :: ctype
1697 character(len=15) :: nodestr
1698 real(DP),
pointer :: bndElem => null()
1700 data ctype(0)/
'VERTICAL '/
1701 data ctype(1)/
'HORIZONTAL'/
1702 data ctype(2)/
'EMBEDDEDH '/
1703 data ctype(3)/
'EMBEDDEDV '/
1706 do n = 1, this%nlakes
1707 this%xnewpak(n) = this%strt(n)
1708 write (text,
'(g15.7)') this%strt(n)
1710 bndelem => this%stage(n)
1712 'BND', this%tsManager, this%iprpak, &
1717 do n = 1, this%nlakes
1718 if (this%status(n) ==
'CONSTANT')
then
1719 this%iboundpak(n) = -1
1720 else if (this%status(n) ==
'INACTIVE')
then
1721 this%iboundpak(n) = 0
1722 else if (this%status(n) ==
'ACTIVE ')
then
1723 this%iboundpak(n) = 1
1728 if (this%inamedbound /= 0)
then
1729 do n = 1, this%nlakes
1730 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1731 this%boundname(j) = this%lakename(n)
1737 call this%copy_boundname()
1747 allocate (clb(this%MAXBOUND))
1748 allocate (caq(this%MAXBOUND))
1751 do n = 1, this%nlakes
1752 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1754 top = this%dis%top(nn)
1755 bot = this%dis%bot(nn)
1757 if (this%ictype(j) == 0)
then
1758 area = this%dis%area(nn)
1759 this%sarea(j) = area
1760 this%warea(j) = area
1761 this%sareamax(n) = this%sareamax(n) + area
1762 if (this%gwfik33 == 0)
then
1767 length = dhalf * (top - bot)
1769 else if (this%ictype(j) == 1)
then
1770 area = (this%telev(j) - this%belev(j)) * this%connwidth(j)
1773 if (top == this%telev(j) .and. bot == this%belev(j))
then
1774 if (this%icelltype(nn) == 0)
then
1775 area = this%gwfsat(nn) * (top - bot) * this%connwidth(j)
1778 this%sarea(j) = dzero
1779 this%warea(j) = area
1780 this%sareamax(n) = this%sareamax(n) + dzero
1782 length = this%connlength(j)
1784 else if (this%ictype(j) == 2)
then
1786 this%sarea(j) = dzero
1787 this%warea(j) = area
1788 this%sareamax(n) = this%sareamax(n) + dzero
1790 length = this%connlength(j)
1792 else if (this%ictype(j) == 3)
then
1794 this%sarea(j) = dzero
1795 this%warea(j) = area
1796 this%sareamax(n) = this%sareamax(n) + dzero
1797 if (this%gwfik33 == 0)
then
1802 length = this%connlength(j)
1804 if (
is_close(this%bedleak(j), dnodata))
then
1806 else if (this%bedleak(j) > dzero)
then
1807 clb(j) = done / this%bedleak(j)
1816 if (
is_close(this%bedleak(j), dnodata))
then
1817 this%satcond(j) = area / caq(j)
1818 else if (clb(j) * caq(j) > dzero)
then
1819 this%satcond(j) = area / (clb(j) + caq(j))
1821 this%satcond(j) = dzero
1827 if (this%iprpak > 0)
then
1828 write (this%iout,
'(//,29x,a,/)') &
1829 'INTERFACE CONDUCTANCE BETWEEN LAKE AND AQUIFER CELLS'
1830 write (this%iout,
'(1x,a)') &
1831 &
' LAKE CONNECTION CONNECTION LAKEBED'// &
1832 &
' C O N D U C T A N C E S '
1833 write (this%iout,
'(1x,a)') &
1834 &
' NUMBER NUMBER CELLID DIRECTION LEAKANCE'// &
1835 &
' LAKEBED AQUIFER COMBINED'
1836 write (this%iout,
"(1x,108('-'))")
1837 do n = 1, this%nlakes
1839 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
1842 if (this%ictype(j) == 1)
then
1843 fact = this%telev(j) - this%belev(j)
1844 if (abs(fact) > dzero)
then
1849 area = this%warea(j)
1851 if (
is_close(clb(j), dnodata))
then
1854 else if (clb(j) > dzero)
then
1855 c1 = area * fact / clb(j)
1856 write (cbedleak,
'(g14.5)') this%bedleak(j)
1857 write (cbedcond,
'(g14.5)') c1
1859 write (cbedleak,
'(g14.5)') c1
1860 write (cbedcond,
'(g14.5)') c1
1863 if (caq(j) > dzero)
then
1864 c2 = area * fact / caq(j)
1866 call this%dis%noder_to_string(nn, nodestr)
1868 '(1x,i10,1x,i10,1x,a15,1x,a10,2(1x,a14),2(1x,g14.5))') &
1869 n, idx, nodestr, ctype(this%ictype(j)), cbedleak, &
1870 cbedcond, c2, this%satcond(j) * fact
1873 write (this%iout,
"(1x,108('-'))")
1874 write (this%iout,
'(1x,a)') &
1875 'IF VERTICAL CONNECTION, CONDUCTANCE (L^2/T) IS &
1876 &BETWEEN AQUIFER CELL AND OVERLYING LAKE CELL.'
1877 write (this%iout,
'(1x,a)') &
1878 'IF HORIZONTAL CONNECTION, CONDUCTANCES ARE PER &
1879 &UNIT SATURATED THICKNESS (L/T).'
1880 write (this%iout,
'(1x,a)') &
1881 'IF EMBEDDED CONNECTION, CONDUCTANCES ARE PER &
1882 &UNIT EXCHANGE AREA (1/T).'
1887 do n = 1, this%nlakes
1888 write (this%iout,
'(//1x,a,1x,i10)')
'STAGE/VOLUME RELATION FOR LAKE ', n
1889 write (this%iout,
'(/1x,5(a14))')
' STAGE',
' SURFACE AREA', &
1890 &
' WETTED AREA',
' CONDUCTANCE', &
1892 write (this%iout,
"(1x,70('-'))")
1893 dx = (this%laketop(n) - this%lakebot(n)) / 150.
1896 call this%lak_calculate_conductance(n, s, c)
1897 call this%lak_calculate_sarea(n, s, sa)
1898 call this%lak_calculate_warea(n, s, wa, s)
1899 call this%lak_calculate_vol(n, s, v)
1900 write (this%iout,
'(1x,5(E14.5))') s, sa, wa, c, v
1903 write (this%iout,
"(1x,70('-'))")
1905 write (this%iout,
'(//1x,a,1x,i10)')
'STAGE/VOLUME RELATION FOR LAKE ', n
1906 write (this%iout,
'(/1x,4(a14))')
' ',
' ', &
1907 &
' CALCULATED',
' STAGE'
1908 write (this%iout,
'(1x,4(a14))')
' STAGE',
' VOLUME', &
1909 &
' STAGE',
' DIFFERENCE'
1910 write (this%iout,
"(1x,56('-'))")
1911 s = this%lakebot(n) - dx
1913 call this%lak_calculate_vol(n, s, v)
1914 call this%lak_vol2stage(n, v, c)
1915 write (this%iout,
'(1x,4(E14.5))') s, v, c, s - c
1918 write (this%iout,
"(1x,56('-'))")
1923 this%gwfk11 => null()
1924 this%gwfk33 => null()
1925 this%gwfsat => null()
1926 this%gwfik33 => null()
1939 class(
laktype),
intent(inout) :: this
1940 integer(I4B),
intent(in) :: n
1941 real(DP),
dimension(n),
intent(in) :: x
1942 real(DP),
dimension(n),
intent(in) :: y
1943 real(DP),
intent(in) :: z
1944 real(DP),
intent(inout) :: v
1947 real(DP) :: dx, dydx
1955 else if (z > x(n))
then
1956 dx = x(n) - x(n - 1)
1958 if (abs(dx) >
dzero)
then
1959 dydx = (y(n) - y(n - 1)) / dx
1962 v = y(n) + dydx * dx
1966 dx = x(i) - x(i - 1)
1968 if (z >= x(i - 1) .and. z <= x(i))
then
1969 if (abs(dx) >
dzero)
then
1970 dydx = (y(i) - y(i - 1)) / dx
1973 v = y(i - 1) + dydx * dx
1984 class(
laktype),
intent(inout) :: this
1985 integer(I4B),
intent(in) :: ilak
1986 real(DP),
intent(in) :: stage
1987 real(DP),
intent(inout) :: sarea
1990 integer(I4B) :: ifirst
1991 integer(I4B) :: ilast
1998 i = this%ntabrow(ilak)
2000 ifirst = this%ialaktab(ilak)
2001 ilast = this%ialaktab(ilak + 1) - 1
2002 if (stage <= this%tabstage(ifirst))
then
2003 sarea = this%tabsarea(ifirst)
2004 else if (stage >= this%tabstage(ilast))
then
2005 sarea = this%tabsarea(ilast)
2007 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2008 this%tabsarea(ifirst:ilast), &
2012 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2013 topl = this%telev(i)
2014 botl = this%belev(i)
2016 sa = sat * this%sarea(i)
2026 class(
laktype),
intent(inout) :: this
2027 integer(I4B),
intent(in) :: ilak
2028 real(DP),
intent(in) :: stage
2029 real(DP),
intent(inout) :: warea
2030 real(DP),
optional,
intent(inout) :: hin
2033 integer(I4B) :: igwfnode
2038 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2039 if (
present(hin))
then
2042 igwfnode = this%cellid(i)
2043 head = this%xnew(igwfnode)
2045 call this%lak_calculate_conn_warea(ilak, i, stage, head, wa)
2054 class(
laktype),
intent(inout) :: this
2055 integer(I4B),
intent(in) :: ilak
2056 integer(I4B),
intent(in) :: iconn
2057 real(DP),
intent(in) :: stage
2058 real(DP),
intent(in) :: head
2059 real(DP),
intent(inout) :: wa
2062 integer(I4B) :: ifirst
2063 integer(I4B) :: ilast
2064 integer(I4B) :: node
2071 topl = this%telev(iconn)
2072 botl = this%belev(iconn)
2073 call this%lak_calculate_cond_head(iconn, stage, head, vv)
2074 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
2075 if (vv > topl) vv = topl
2076 i = this%ntabrow(ilak)
2077 ifirst = this%ialaktab(ilak)
2078 ilast = this%ialaktab(ilak + 1) - 1
2079 if (vv <= this%tabstage(ifirst))
then
2080 wa = this%tabwarea(ifirst)
2081 else if (vv >= this%tabstage(ilast))
then
2082 wa = this%tabwarea(ilast)
2084 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2085 this%tabwarea(ifirst:ilast), &
2089 node = this%cellid(iconn)
2091 if (this%icelltype(node) == 0)
then
2097 wa = sat * this%warea(iconn)
2105 class(
laktype),
intent(inout) :: this
2106 integer(I4B),
intent(in) :: ilak
2107 real(DP),
intent(in) :: stage
2108 real(DP),
intent(inout) :: volume
2111 integer(I4B) :: ifirst
2112 integer(I4B) :: ilast
2121 i = this%ntabrow(ilak)
2123 ifirst = this%ialaktab(ilak)
2124 ilast = this%ialaktab(ilak + 1) - 1
2125 if (stage <= this%tabstage(ifirst))
then
2126 volume = this%tabvolume(ifirst)
2127 else if (stage >= this%tabstage(ilast))
then
2128 ds = stage - this%tabstage(ilast)
2129 sa = this%tabsarea(ilast)
2130 volume = this%tabvolume(ilast) + ds * sa
2132 call this%lak_linear_interpolation(i, this%tabstage(ifirst:ilast), &
2133 this%tabvolume(ifirst:ilast), &
2137 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2138 topl = this%telev(i)
2139 botl = this%belev(i)
2141 sa = sat * this%sarea(i)
2142 if (stage < botl)
then
2144 else if (stage > botl .and. stage < topl)
then
2145 v = sa * (stage - botl)
2147 v = sa * (topl - botl) + sa * (stage - topl)
2158 class(
laktype),
intent(inout) :: this
2159 integer(I4B),
intent(in) :: ilak
2160 real(DP),
intent(in) :: stage
2161 real(DP),
intent(inout) :: conductance
2167 do i = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2168 call this%lak_calculate_conn_conductance(ilak, i, stage, stage, c)
2169 conductance = conductance + c
2179 class(
laktype),
intent(inout) :: this
2180 integer(I4B),
intent(in) :: iconn
2181 real(DP),
intent(in) :: stage
2182 real(DP),
intent(in) :: head
2183 real(DP),
intent(inout) :: vv
2190 topl = this%telev(iconn)
2191 botl = this%belev(iconn)
2192 ss = min(stage, topl)
2193 hh = min(head, topl)
2194 if (this%igwhcopt > 0)
then
2196 else if (this%inewton > 0)
then
2199 vv =
dhalf * (ss + hh)
2208 class(
laktype),
intent(inout) :: this
2209 integer(I4B),
intent(in) :: ilak
2210 integer(I4B),
intent(in) :: iconn
2211 real(DP),
intent(in) :: stage
2212 real(DP),
intent(in) :: head
2213 real(DP),
intent(inout) :: cond
2215 integer(I4B) :: node
2223 real(DP) :: vscratio
2227 topl = this%telev(iconn)
2228 botl = this%belev(iconn)
2229 call this%lak_calculate_cond_head(iconn, stage, head, vv)
2234 if (this%ictype(iconn) == 0)
then
2235 if (abs(topl - botl) <
dprec)
then
2240 else if (this%ictype(iconn) == 1)
then
2241 node = this%cellid(iconn)
2242 if (this%icelltype(node) == 0)
then
2246 else if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
2247 node = this%cellid(iconn)
2248 if (this%icelltype(node) == 0)
then
2249 vv = this%telev(iconn)
2250 call this%lak_calculate_conn_warea(ilak, iconn, vv, vv, wa)
2252 call this%lak_calculate_conn_warea(ilak, iconn, stage, head, wa)
2258 if (this%ivsc == 1)
then
2260 if (stage > head)
then
2261 vscratio = this%viscratios(1, iconn)
2264 vscratio = this%viscratios(2, iconn)
2267 cond = sat * this%satcond(iconn) * vscratio
2274 class(
laktype),
intent(inout) :: this
2275 integer(I4B),
intent(in) :: ilak
2276 real(DP),
intent(in) :: stage
2277 real(DP),
intent(inout) :: totflow
2280 integer(I4B) :: igwfnode
2285 do j = this%idxlakeconn(ilak), this%idxlakeconn(ilak + 1) - 1
2286 igwfnode = this%cellid(j)
2287 hgwf = this%xnew(igwfnode)
2288 call this%lak_calculate_conn_exchange(ilak, j, stage, hgwf, flow)
2289 totflow = totflow + flow
2299 class(
laktype),
intent(inout) :: this
2300 integer(I4B),
intent(in) :: ilak
2301 integer(I4B),
intent(in) :: iconn
2302 real(DP),
intent(in) :: stage
2303 real(DP),
intent(in) :: head
2304 real(DP),
intent(inout) :: flow
2305 real(DP),
intent(inout),
optional :: gwfhcof
2306 real(DP),
intent(inout),
optional :: gwfrhs
2312 real(DP) :: gwfhcof0
2316 call this%lak_calculate_conn_conductance(ilak, iconn, stage, head, cond)
2317 botl = this%belev(iconn)
2320 if (stage >= botl)
then
2327 if (head >= botl)
then
2334 flow = cond * (hh - ss)
2337 if (head >= botl)
then
2339 gwfrhs0 = -cond * ss
2346 if (this%idense /= 0)
then
2347 call this%lak_calculate_density_exchange(iconn, stage, head, cond, botl, &
2348 flow, gwfhcof0, gwfrhs0)
2352 if (
present(gwfhcof)) gwfhcof = gwfhcof0
2353 if (
present(gwfrhs)) gwfrhs = gwfrhs0
2360 head, flow, source, gwfhcof, gwfrhs)
2362 class(
laktype),
intent(inout) :: this
2363 integer(I4B),
intent(in) :: iflag
2364 integer(I4B),
intent(in) :: ilak
2365 integer(I4B),
intent(in) :: iconn
2366 integer(I4B),
intent(inout) :: idry
2367 real(DP),
intent(in) :: stage
2368 real(DP),
intent(in) :: head
2369 real(DP),
intent(inout) :: flow
2370 real(DP),
intent(inout) :: source
2371 real(DP),
intent(inout),
optional :: gwfhcof
2372 real(DP),
intent(inout),
optional :: gwfrhs
2374 real(DP) :: gwfhcof0, gwfrhs0
2378 call this%lak_calculate_conn_exchange(ilak, iconn, stage, head, flow, &
2380 if (iflag == 1)
then
2381 if (flow >
dzero)
then
2382 source = source + flow
2384 else if (iflag == 2)
then
2385 if (-flow > source)
then
2389 else if (flow <
dzero)
then
2390 source = source + flow
2395 if (
present(gwfhcof)) gwfhcof = gwfhcof0
2396 if (
present(gwfrhs)) gwfrhs = gwfrhs0
2404 class(
laktype),
intent(inout) :: this
2405 integer(I4B),
intent(in) :: ilak
2406 real(DP),
intent(in) :: stage
2407 real(DP),
intent(in) :: stage0
2408 real(DP),
intent(in) :: delt
2409 real(DP),
intent(inout) :: dvr
2415 if (this%gwfiss /= 1)
then
2416 call this%lak_calculate_vol(ilak, stage, v)
2417 call this%lak_calculate_vol(ilak, stage0, v0)
2418 dvr = (v0 - v) / delt
2426 class(
laktype),
intent(inout) :: this
2427 integer(I4B),
intent(in) :: ilak
2428 real(DP),
intent(in) :: stage
2429 real(DP),
intent(inout) :: ra
2431 integer(I4B) :: iconn
2435 iconn = this%idxlakeconn(ilak)
2436 if (this%ictype(iconn) == 2 .or. this%ictype(iconn) == 3)
then
2437 sa = this%sareamax(ilak)
2439 call this%lak_calculate_sarea(ilak, stage, sa)
2441 ra = this%rainfall(ilak) * sa
2448 class(
laktype),
intent(inout) :: this
2449 integer(I4B),
intent(in) :: ilak
2450 real(DP),
intent(inout) :: ro
2453 ro = this%runoff(ilak)
2460 class(
laktype),
intent(inout) :: this
2461 integer(I4B),
intent(in) :: ilak
2462 real(DP),
intent(inout) :: qin
2465 qin = this%inflow(ilak)
2472 class(
laktype),
intent(inout) :: this
2473 integer(I4B),
intent(in) :: ilak
2474 real(DP),
intent(inout) :: ex
2479 if (this%imover == 1)
then
2480 ex = this%pakmvrobj%get_qfrommvr(ilak)
2488 class(
laktype),
intent(inout) :: this
2489 integer(I4B),
intent(in) :: ilak
2490 real(DP),
intent(inout) :: avail
2491 real(DP),
intent(inout) :: wr
2494 wr = this%withdrawal(ilak)
2495 if (wr > avail)
then
2498 if (wr >
dzero)
then
2510 class(
laktype),
intent(inout) :: this
2511 integer(I4B),
intent(in) :: ilak
2512 real(DP),
intent(in) :: stage
2513 real(DP),
intent(inout) :: avail
2514 real(DP),
intent(inout) :: ev
2519 call this%lak_calculate_sarea(ilak, stage, sa)
2520 ev = sa * this%evaporation(ilak)
2521 if (ev > avail)
then
2537 class(
laktype),
intent(inout) :: this
2538 integer(I4B),
intent(in) :: ilak
2539 real(DP),
intent(inout) :: outinf
2544 do n = 1, this%noutlets
2545 if (this%lakeout(n) == ilak)
then
2546 outinf = outinf - this%simoutrate(n)
2547 if (this%imover == 1)
then
2548 outinf = outinf - this%pakmvrobj%get_qtomvr(n)
2558 class(
laktype),
intent(inout) :: this
2559 integer(I4B),
intent(in) :: ilak
2560 real(DP),
intent(in) :: stage
2561 real(DP),
intent(inout) :: avail
2562 real(DP),
intent(inout) :: outoutf
2572 do n = 1, this%noutlets
2573 if (this%lakein(n) == ilak)
then
2575 d = stage - this%outinvert(n)
2576 if (this%outdmax >
dzero)
then
2577 if (d > this%outdmax) d = this%outdmax
2579 g =
dgravity * this%convlength * this%convtime * this%convtime
2580 select case (this%iouttype(n))
2583 rate = this%outrate(n)
2584 if (-rate > avail)
then
2590 c = (this%convlength**
donethird) * this%convtime
2592 if (this%outrough(n) >
dzero)
then
2593 gsm =
done / this%outrough(n)
2595 rate = -c * gsm * this%outwidth(n) * (d**
dfivethirds) * &
2596 sqrt(this%outslope(n))
2605 this%simoutrate(n) = rate
2606 avail = avail + rate
2607 outoutf = outoutf + rate
2616 class(
laktype),
intent(inout) :: this
2617 integer(I4B),
intent(in) :: ilak
2618 real(DP),
intent(inout) :: outinf
2623 do n = 1, this%noutlets
2624 if (this%lakeout(n) == ilak)
then
2625 outinf = outinf - this%simoutrate(n)
2626 if (this%imover == 1)
then
2627 outinf = outinf - this%pakmvrobj%get_qtomvr(n)
2637 class(
laktype),
intent(inout) :: this
2638 integer(I4B),
intent(in) :: ilak
2639 real(DP),
intent(inout) :: outoutf
2644 do n = 1, this%noutlets
2645 if (this%lakein(n) == ilak)
then
2646 if (this%lakeout(n) < 1) cycle
2647 outoutf = outoutf + this%simoutrate(n)
2656 class(
laktype),
intent(inout) :: this
2657 integer(I4B),
intent(in) :: ilak
2658 real(DP),
intent(inout) :: outoutf
2663 do n = 1, this%noutlets
2664 if (this%lakein(n) == ilak)
then
2665 if (this%lakeout(n) > 0) cycle
2666 outoutf = outoutf + this%simoutrate(n)
2675 class(
laktype),
intent(inout) :: this
2676 integer(I4B),
intent(in) :: ilak
2677 real(DP),
intent(inout) :: outoutf
2682 if (this%imover == 1)
then
2683 do n = 1, this%noutlets
2684 if (this%lakein(n) == ilak)
then
2685 if (this%lakeout(n) > 0) cycle
2686 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2696 class(
laktype),
intent(inout) :: this
2697 integer(I4B),
intent(in) :: ilak
2698 real(DP),
intent(inout) :: outoutf
2703 if (this%imover == 1)
then
2704 do n = 1, this%noutlets
2705 if (this%lakein(n) == ilak)
then
2706 if (this%lakeout(n) < 1) cycle
2707 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2717 class(
laktype),
intent(inout) :: this
2718 integer(I4B),
intent(in) :: ilak
2719 real(DP),
intent(inout) :: outoutf
2724 if (this%imover == 1)
then
2725 do n = 1, this%noutlets
2726 if (this%lakein(n) == ilak)
then
2727 outoutf = outoutf + this%pakmvrobj%get_qtomvr(n)
2737 class(
laktype),
intent(inout) :: this
2738 integer(I4B),
intent(in) :: ilak
2739 real(DP),
intent(in) :: vol
2740 real(DP),
intent(inout) :: stage
2744 real(DP) :: s0, s1, sm
2745 real(DP) :: v0, v1, vm
2746 real(DP) :: f0, f1, fm
2748 real(DP) :: en0, en1
2752 s0 = this%lakebot(ilak)
2753 call this%lak_calculate_vol(ilak, s0, v0)
2754 s1 = this%laketop(ilak)
2755 call this%lak_calculate_vol(ilak, s1, v1)
2760 else if (vol >= v1)
then
2761 call this%lak_calculate_sarea(ilak, s1, sa)
2762 stage = s1 + (vol - v1) / sa
2773 secantbisection:
do i = 1, 150
2775 if (denom /=
dzero)
then
2776 ds = f1 * (s1 - s0) / denom
2784 if (sm < en0 .or. sm > en1) ibs = 13
2788 if (ds * ds0 <
dprec .or. abs(ds) > abs(ds0)) ibs = ibs + 1
2790 ds =
dhalf * (s1 - s0)
2794 if (abs(ds) <
dem6)
then
2795 exit secantbisection
2797 call this%lak_calculate_vol(ilak, sm, vm)
2804 end do secantbisection
2806 if (abs(ds) >=
dem6)
then
2807 write (this%iout,
'(1x,a,1x,i0,4(1x,a,1x,g15.6))') &
2808 &
'LAK_VOL2STAGE failed for lake', ilak,
'volume error =', fm, &
2809 &
'finding stage (', stage,
') for volume =', vol, &
2810 &
'final change in stage =', ds
2820 integer(I4B) :: ierr
2822 class(
laktype),
intent(inout) :: this
2823 integer(I4B),
intent(in) :: itemno
2825 integer(I4B) :: ival
2829 if (itemno > 0)
then
2830 if (ival < 1 .or. ival > this%nlakes)
then
2831 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,a)') &
2832 'LAKENO', itemno,
'must be greater than 0 and less than or equal to', &
2838 if (ival < 1 .or. ival > this%noutlets)
then
2839 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,a)') &
2840 'IOUTLET', itemno,
'must be greater than 0 and less than or equal to', &
2855 class(
laktype),
intent(inout) :: this
2856 integer(I4B),
intent(in) :: itemno
2858 character(len=LINELENGTH) :: text
2859 character(len=LINELENGTH) :: caux
2860 character(len=LINELENGTH) :: keyword
2861 integer(I4B) :: ierr
2864 real(DP),
pointer :: bndElem => null()
2867 call this%parser%GetStringCaps(keyword)
2868 select case (keyword)
2870 ierr = this%lak_check_valid(itemno)
2874 call this%parser%GetStringCaps(text)
2875 this%status(itemno) = text(1:8)
2876 if (text ==
'CONSTANT')
then
2877 this%iboundpak(itemno) = -1
2878 else if (text ==
'INACTIVE')
then
2879 this%iboundpak(itemno) = 0
2880 else if (text ==
'ACTIVE')
then
2881 this%iboundpak(itemno) = 1
2883 write (
errmsg,
'(a,a)') &
2884 'Unknown '//trim(this%text)//
' lak status keyword: ', text//
'.'
2888 ierr = this%lak_check_valid(itemno)
2892 call this%parser%GetString(text)
2894 bndelem => this%stage(itemno)
2896 this%packName,
'BND', this%tsManager, &
2897 this%iprpak,
'STAGE')
2899 ierr = this%lak_check_valid(itemno)
2903 call this%parser%GetString(text)
2905 bndelem => this%rainfall(itemno)
2907 this%packName,
'BND', this%tsManager, &
2908 this%iprpak,
'RAINFALL')
2909 if (this%rainfall(itemno) <
dzero)
then
2910 write (
errmsg,
'(a,i0,a,G0,a)') &
2911 'Lake ', itemno,
' was assigned a rainfall value of ', &
2912 this%rainfall(itemno),
'. Rainfall must be positive.'
2915 case (
'EVAPORATION')
2916 ierr = this%lak_check_valid(itemno)
2920 call this%parser%GetString(text)
2922 bndelem => this%evaporation(itemno)
2924 this%packName,
'BND', this%tsManager, &
2925 this%iprpak,
'EVAPORATION')
2926 if (this%evaporation(itemno) <
dzero)
then
2927 write (
errmsg,
'(a,i0,a,G0,a)') &
2928 'Lake ', itemno,
' was assigned an evaporation value of ', &
2929 this%evaporation(itemno),
'. Evaporation must be positive.'
2933 ierr = this%lak_check_valid(itemno)
2937 call this%parser%GetString(text)
2939 bndelem => this%runoff(itemno)
2941 this%packName,
'BND', this%tsManager, &
2942 this%iprpak,
'RUNOFF')
2943 if (this%runoff(itemno) <
dzero)
then
2944 write (
errmsg,
'(a,i0,a,G0,a)') &
2945 'Lake ', itemno,
' was assigned a runoff value of ', &
2946 this%runoff(itemno),
'. Runoff must be positive.'
2950 ierr = this%lak_check_valid(itemno)
2954 call this%parser%GetString(text)
2956 bndelem => this%inflow(itemno)
2958 this%packName,
'BND', this%tsManager, &
2959 this%iprpak,
'INFLOW')
2960 if (this%inflow(itemno) <
dzero)
then
2961 write (
errmsg,
'(a,i0,a,G0,a)') &
2962 'Lake ', itemno,
' was assigned an inflow value of ', &
2963 this%inflow(itemno),
'. Inflow must be positive.'
2967 ierr = this%lak_check_valid(itemno)
2971 call this%parser%GetString(text)
2973 bndelem => this%withdrawal(itemno)
2975 this%packName,
'BND', this%tsManager, &
2976 this%iprpak,
'WITHDRAWAL')
2977 if (this%withdrawal(itemno) <
dzero)
then
2978 write (
errmsg,
'(a,i0,a,G0,a)') &
2979 'Lake ', itemno,
' was assigned a withdrawal value of ', &
2980 this%withdrawal(itemno),
'. Withdrawal must be positive.'
2984 ierr = this%lak_check_valid(-itemno)
2988 call this%parser%GetString(text)
2990 bndelem => this%outrate(itemno)
2992 this%packName,
'BND', this%tsManager, &
2993 this%iprpak,
'RATE')
2995 ierr = this%lak_check_valid(-itemno)
2999 call this%parser%GetString(text)
3001 bndelem => this%outinvert(itemno)
3003 this%packName,
'BND', this%tsManager, &
3004 this%iprpak,
'INVERT')
3006 ierr = this%lak_check_valid(-itemno)
3010 call this%parser%GetString(text)
3012 bndelem => this%outwidth(itemno)
3014 this%packName,
'BND', this%tsManager, &
3015 this%iprpak,
'WIDTH')
3017 ierr = this%lak_check_valid(-itemno)
3021 call this%parser%GetString(text)
3023 bndelem => this%outrough(itemno)
3025 this%packName,
'BND', this%tsManager, &
3026 this%iprpak,
'ROUGH')
3028 ierr = this%lak_check_valid(-itemno)
3032 call this%parser%GetString(text)
3034 bndelem => this%outslope(itemno)
3036 this%packName,
'BND', this%tsManager, &
3037 this%iprpak,
'SLOPE')
3039 ierr = this%lak_check_valid(itemno)
3043 call this%parser%GetStringCaps(caux)
3044 do jj = 1, this%naux
3045 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
3046 call this%parser%GetString(text)
3048 bndelem => this%lauxvar(jj, ii)
3050 this%packName,
'AUX', &
3051 this%tsManager, this%iprpak, &
3057 'Unknown '//trim(this%text)//
' lak data keyword: ', &
3073 class(
laktype),
intent(inout) :: this
3074 integer(I4B),
intent(in) :: ilak
3075 character(len=*),
intent(in) :: keyword
3076 character(len=*),
intent(in) :: msg
3078 if (len(msg) == 0)
then
3079 write (
errmsg,
'(a,1x,a,1x,i0,1x,a)') &
3080 keyword,
' for LAKE', ilak,
'has already been set.'
3082 write (
errmsg,
'(a,1x,a,1x,i0,1x,a)') keyword,
' for LAKE', ilak, msg
3098 class(
laktype),
intent(inout) :: this
3099 character(len=*),
intent(inout) :: option
3100 logical(LGP),
intent(inout) :: found
3102 character(len=MAXCHARLEN) :: fname, keyword
3105 character(len=*),
parameter :: fmtlengthconv = &
3106 &
"(4x, 'LENGTH CONVERSION VALUE (',g15.7,') SPECIFIED.')"
3107 character(len=*),
parameter :: fmttimeconv = &
3108 &
"(4x, 'TIME CONVERSION VALUE (',g15.7,') SPECIFIED.')"
3109 character(len=*),
parameter :: fmtoutdmax = &
3110 &
"(4x, 'MAXIMUM OUTLET WATER DEPTH (',g15.7,') SPECIFIED.')"
3111 character(len=*),
parameter :: fmtlakeopt = &
3112 &
"(4x, 'LAKE ', a, ' VALUE (',g15.7,') SPECIFIED.')"
3113 character(len=*),
parameter :: fmtlakbin = &
3114 "(4x, 'LAK ', 1x, a, 1x, ' WILL BE SAVED TO FILE: ', &
3115 &a, /4x, 'OPENED ON UNIT: ', I0)"
3116 character(len=*),
parameter :: fmtiter = &
3117 &
"(4x, 'MAXIMUM LAK ITERATION VALUE (',i0,') SPECIFIED.')"
3118 character(len=*),
parameter :: fmtdmaxchg = &
3119 &
"(4x, 'MAXIMUM STAGE CHANGE VALUE (',g0,') SPECIFIED.')"
3122 select case (option)
3123 case (
'PRINT_STAGE')
3125 write (this%iout,
'(4x,a)') trim(adjustl(this%text))// &
3126 ' STAGES WILL BE PRINTED TO LISTING FILE.'
3128 call this%parser%GetStringCaps(keyword)
3129 if (keyword ==
'FILEOUT')
then
3130 call this%parser%GetString(fname)
3132 call openfile(this%istageout, this%iout, fname,
'DATA(BINARY)', &
3134 write (this%iout, fmtlakbin)
'STAGE', trim(adjustl(fname)), &
3137 call store_error(
'OPTIONAL STAGE KEYWORD MUST BE FOLLOWED BY FILEOUT')
3140 call this%parser%GetStringCaps(keyword)
3141 if (keyword ==
'FILEOUT')
then
3142 call this%parser%GetString(fname)
3144 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
3146 write (this%iout, fmtlakbin)
'BUDGET', trim(adjustl(fname)), &
3149 call store_error(
'OPTIONAL BUDGET KEYWORD MUST BE FOLLOWED BY FILEOUT')
3152 call this%parser%GetStringCaps(keyword)
3153 if (keyword ==
'FILEOUT')
then
3154 call this%parser%GetString(fname)
3156 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
3157 filstat_opt=
'REPLACE')
3158 write (this%iout, fmtlakbin)
'BUDGET CSV', trim(adjustl(fname)), &
3161 call store_error(
'OPTIONAL BUDGETCSV KEYWORD MUST BE FOLLOWED BY &
3164 case (
'PACKAGE_CONVERGENCE')
3165 call this%parser%GetStringCaps(keyword)
3166 if (keyword ==
'FILEOUT')
then
3167 call this%parser%GetString(fname)
3169 call openfile(this%ipakcsv, this%iout, fname,
'CSV', &
3170 filstat_opt=
'REPLACE', mode_opt=
mnormal)
3171 write (this%iout, fmtlakbin)
'PACKAGE_CONVERGENCE', &
3172 trim(adjustl(fname)), this%ipakcsv
3174 call store_error(
'OPTIONAL PACKAGE_CONVERGENCE KEYWORD MUST BE '// &
3175 'FOLLOWED BY FILEOUT')
3179 write (this%iout,
'(4x,A)')
'MOVER OPTION ENABLED'
3180 case (
'LENGTH_CONVERSION')
3181 this%convlength = this%parser%GetDouble()
3182 write (this%iout, fmtlengthconv) this%convlength
3183 case (
'TIME_CONVERSION')
3184 this%convtime = this%parser%GetDouble()
3185 write (this%iout, fmttimeconv) this%convtime
3187 r = this%parser%GetDouble()
3192 write (this%iout, fmtlakeopt)
'SURFDEP', this%surfdep
3193 case (
'MAXIMUM_ITERATIONS')
3194 this%maxlakit = this%parser%GetInteger()
3195 write (this%iout, fmtiter) this%maxlakit
3196 case (
'MAXIMUM_STAGE_CHANGE')
3197 r = this%parser%GetDouble()
3199 this%delh = dp999 * r
3200 write (this%iout, fmtdmaxchg) this%dmaxchg
3206 case (
'DEV_GROUNDWATER_HEAD_CONDUCTANCE')
3207 call this%parser%DevOpt()
3209 write (this%iout,
'(4x,a)') &
3210 'CONDUCTANCE FOR HORIZONTAL CONNECTIONS WILL BE CALCULATED &
3211 &USING THE GROUNDWATER HEAD'
3212 case (
'DEV_MAXIMUM_OUTLET_DEPTH')
3213 call this%parser%DevOpt()
3214 this%outdmax = this%parser%GetDouble()
3215 write (this%iout, fmtoutdmax) this%outdmax
3216 case (
'DEV_NO_FINAL_CHECK')
3217 call this%parser%DevOpt()
3219 write (this%iout,
'(4x,a)') &
3220 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN LAKE STAGES &
3222 case (
'DEV_NO_FINAL_RESIDUAL_CHECK')
3223 call this%parser%DevOpt()
3224 this%iconvresidchk = 0
3225 write (this%iout,
'(4x,a)') &
3226 'A FINAL CONVERGENCE CHECK OF THE CHANGE IN LAKE RESIDUALS &
3228 case (
'DEV_MAXIMUM_PERCENT_DIFFERENCE')
3229 call this%parser%DevOpt()
3230 r = this%parser%GetDouble()
3235 write (this%iout, fmtlakeopt)
'MAXIMUM_PERCENT_DIFFERENCE', this%pdmax
3249 class(
laktype),
intent(inout) :: this
3251 call this%obs%obs_ar()
3254 call this%lak_allocate_arrays()
3257 call this%read_initial_attr()
3260 if (this%imover /= 0)
then
3261 allocate (this%pakmvrobj)
3262 call this%pakmvrobj%ar(this%noutlets, this%nlakes, this%memoryPath)
3276 class(
laktype),
intent(inout) :: this
3278 character(len=LINELENGTH) :: title
3279 character(len=LINELENGTH) :: line
3280 character(len=LINELENGTH) :: text
3281 logical(LGP) :: isfound
3282 logical(LGP) :: endOfBlock
3283 integer(I4B) :: ierr
3284 integer(I4B) :: node
3286 integer(I4B) :: itemno
3289 character(len=*),
parameter :: fmtblkerr = &
3290 &
"('Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
3291 character(len=*),
parameter :: fmtlsp = &
3292 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
3295 this%nbound = this%maxbound
3299 if (this%inunit == 0)
return
3302 if (this%ionper <
kper)
then
3305 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
3306 supportopenclose=.true., &
3307 blockrequired=.false.)
3311 call this%read_check_ionper()
3317 this%ionper =
nper + 1
3320 call this%parser%GetCurrentLine(line)
3321 write (
errmsg, fmtblkerr) adjustl(trim(line))
3323 call this%parser%StoreErrorUnit()
3329 if (this%ionper ==
kper)
then
3332 if (this%iprpak /= 0)
then
3335 title = trim(adjustl(this%text))//
' PACKAGE ('// &
3336 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
3337 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
3338 call table_cr(this%inputtab, this%packName, title)
3339 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
3341 call this%inputtab%initialize_column(text, 10, alignment=tabcenter)
3343 call this%inputtab%initialize_column(text, 20, alignment=tableft)
3345 write (text,
'(a,1x,i6)')
'VALUE', n
3346 call this%inputtab%initialize_column(text, 15, alignment=tabcenter)
3353 call this%parser%GetNextLine(endofblock)
3354 if (endofblock)
exit
3357 itemno = this%parser%GetInteger()
3360 call this%lak_set_stressperiod(itemno)
3363 if (this%iprpak /= 0)
then
3364 call this%parser%GetCurrentLine(line)
3365 call this%inputtab%line_to_columns(line)
3369 if (this%iprpak /= 0)
then
3370 call this%inputtab%finalize_table()
3375 write (this%iout, fmtlsp) trim(this%filtyp)
3380 call this%parser%StoreErrorUnit()
3384 do n = 1, this%nlakes
3385 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3386 node = this%cellid(j)
3387 this%nodelist(j) = node
3388 this%bound(1, j) = this%xnewpak(n)
3389 this%bound(2, j) = this%satcond(j)
3390 this%bound(3, j) = this%belev(j)
3395 if (this%imover == 1)
then
3396 do n = 1, this%noutlets
3397 this%pakmvrobj%iprmap(n) = this%lakein(n)
3412 integer(I4B) :: iaux
3415 call this%TsManager%ad()
3420 if (this%naux > 0)
then
3421 do n = 1, this%nlakes
3422 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3423 do iaux = 1, this%naux
3424 if (this%noupdateauxvar(iaux) /= 0) cycle
3425 this%auxvar(iaux, j) = this%lauxvar(iaux, n)
3436 do n = 1, this%nlakes
3437 this%xoldpak(n) = this%xnewpak(n)
3438 this%stageiter(n) = this%xnewpak(n)
3439 if (this%iboundpak(n) < 0)
then
3440 this%xnewpak(n) = this%stage(n)
3442 this%seep0(n) =
dzero
3448 do n = 1, this%nlakes
3449 this%xnewpak(n) = this%xoldpak(n)
3450 this%stageiter(n) = this%xnewpak(n)
3451 if (this%iboundpak(n) < 0)
then
3452 this%xnewpak(n) = this%stage(n)
3454 this%seep0(n) =
dzero
3459 if (this%imover == 1)
then
3460 call this%pakmvrobj%ad()
3466 call this%obs%obs_ad()
3477 integer(I4B) :: j, n
3478 integer(I4B) :: igwfnode
3479 real(DP) :: hlak, bottom_lake
3482 do n = 1, this%nlakes
3483 this%seep0(n) = this%seep(n)
3487 do n = 1, this%nlakes
3488 this%s0(n) = this%xnewpak(n)
3489 call this%lak_calculate_exchange(n, this%s0(n), this%qgwf0(n))
3493 do n = 1, this%nlakes
3494 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3496 if (this%ictype(j) /= 0)
then
3499 igwfnode = this%nodesontop(j)
3500 if (this%ibound(igwfnode) == 0)
then
3501 call this%dis%highest_active(igwfnode, this%ibound)
3503 this%nodelist(j) = igwfnode
3504 this%cellid(j) = igwfnode
3511 do n = 1, this%nlakes
3513 hlak = this%xnewpak(n)
3516 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3519 igwfnode = this%cellid(j)
3522 if (this%ibound(igwfnode) < 1)
then
3527 if (this%ictype(j) /= 0)
then
3532 if (this%ictype(j) == 2 .or. this%ictype(j) == 3)
then
3537 bottom_lake = this%belev(j)
3538 if (hlak > bottom_lake .or. this%iboundpak(n) == 0)
then
3541 this%ibound(igwfnode) = 1
3549 call this%lak_bound_update()
3554 subroutine lak_fc(this, rhs, ia, idxglo, matrix_sln)
3557 real(DP),
dimension(:),
intent(inout) :: rhs
3558 integer(I4B),
dimension(:),
intent(in) :: ia
3559 integer(I4B),
dimension(:),
intent(in) :: idxglo
3562 integer(I4B) :: j, n
3563 integer(I4B) :: igwfnode
3564 integer(I4B) :: ipossymd
3567 if (this%imover == 1)
then
3568 call this%pakmvrobj%fc()
3572 call this%lak_solve()
3575 do n = 1, this%nlakes
3576 if (this%iboundpak(n) == 0) cycle
3577 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3578 igwfnode = this%cellid(j)
3579 if (this%ibound(igwfnode) < 1) cycle
3580 ipossymd = idxglo(ia(igwfnode))
3581 call matrix_sln%add_value_pos(ipossymd, this%hcof(j))
3582 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
3589 subroutine lak_fn(this, rhs, ia, idxglo, matrix_sln)
3592 real(DP),
dimension(:),
intent(inout) :: rhs
3593 integer(I4B),
dimension(:),
intent(in) :: ia
3594 integer(I4B),
dimension(:),
intent(in) :: idxglo
3597 integer(I4B) :: j, n
3598 integer(I4B) :: ipos
3599 integer(I4B) :: igwfnode
3600 integer(I4B) :: idry
3613 do n = 1, this%nlakes
3614 if (this%iboundpak(n) == 0) cycle
3615 hlak = this%xnewpak(n)
3616 call this%lak_calculate_available(n, hlak, avail, &
3617 ra, ro, qinf, ex, this%delh)
3618 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
3619 igwfnode = this%cellid(j)
3621 head = this%xnew(igwfnode)
3622 if (-this%hcof(j) >
dzero)
then
3623 if (this%ibound(igwfnode) > 0)
then
3627 call this%lak_estimate_conn_exchange(2, n, j, idry, hlak, &
3628 head + this%delh, q1, avail)
3631 q = this%hcof(j) * head - this%rhs(j)
3633 rterm = this%hcof(j) * head
3635 drterm = (q1 - q) / this%delh
3638 call matrix_sln%add_value_pos(idxglo(ipos), drterm - this%hcof(j))
3639 rhs(igwfnode) = rhs(igwfnode) - rterm + drterm * head
3648 subroutine lak_cc(this, innertot, kiter, iend, icnvgmod, cpak, ipak, dpak)
3652 class(
laktype),
intent(inout) :: this
3653 integer(I4B),
intent(in) :: innertot
3654 integer(I4B),
intent(in) :: kiter
3655 integer(I4B),
intent(in) :: iend
3656 integer(I4B),
intent(in) :: icnvgmod
3657 character(len=LENPAKLOC),
intent(inout) :: cpak
3658 integer(I4B),
intent(inout) :: ipak
3659 real(DP),
intent(inout) :: dpak
3661 character(len=LENPAKLOC) :: cloc
3662 character(len=LINELENGTH) :: tag
3663 integer(I4B) :: icheck
3664 integer(I4B) :: ipakfail
3665 integer(I4B) :: locdhmax
3666 integer(I4B) :: locresidmax
3667 integer(I4B) :: locdgwfmax
3668 integer(I4B) :: locdqoutmax
3669 integer(I4B) :: locdqfrommvrmax
3670 integer(I4B) :: ntabrows
3671 integer(I4B) :: ntabcols
3675 real(DP) :: qtolfact
3693 real(DP) :: residmax
3695 real(DP) :: dqoutmax
3696 real(DP) :: dqfrommvr
3697 real(DP) :: dqfrommvrmax
3700 icheck = this%iconvchk
3711 dqfrommvrmax =
dzero
3715 if (this%ipakcsv == 0)
then
3716 if (icnvgmod == 0)
then
3724 if (.not.
associated(this%pakcsvtab))
then
3729 if (this%noutlets > 0)
then
3730 ntabcols = ntabcols + 2
3732 if (this%imover == 1)
then
3733 ntabcols = ntabcols + 2
3737 call table_cr(this%pakcsvtab, this%packName,
'')
3738 call this%pakcsvtab%table_df(ntabrows, ntabcols, this%ipakcsv, &
3739 lineseparator=.false., separator=
',', &
3743 tag =
'total_inner_iterations'
3744 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3746 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3748 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3750 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3752 call this%pakcsvtab%initialize_column(tag, 10, alignment=
tableft)
3754 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3756 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3758 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3759 tag =
'residmax_loc'
3760 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3762 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3764 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3765 if (this%noutlets > 0)
then
3767 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3768 tag =
'dqoutmax_loc'
3769 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3771 if (this%imover == 1)
then
3772 tag =
'dqfrommvrmax'
3773 call this%pakcsvtab%initialize_column(tag, 15, alignment=
tableft)
3774 tag =
'dqfrommvrmax_loc'
3775 call this%pakcsvtab%initialize_column(tag, 16, alignment=
tableft)
3781 if (icheck /= 0)
then
3782 final_check:
do n = 1, this%nlakes
3783 if (this%iboundpak(n) < 1) cycle
3787 hlak = this%xnewpak(n)
3793 call this%lak_calculate_sarea(n, hlak, area)
3796 if (area >
dzero)
then
3797 qtolfact =
delt / area
3803 call this%lak_calculate_residual(n, hlak, resid)
3804 resid = resid * qtolfact
3808 if (area >
dzero)
then
3809 gwf0 = this%qgwf0(n)
3810 call this%lak_calculate_exchange(n, hlak, gwf)
3811 dgwf = (gwf0 - gwf) * qtolfact
3816 if (this%noutlets > 0)
then
3817 if (area >
dzero)
then
3818 call this%lak_calculate_available(n, hlak0, inf, ra, ro, qinf, ex)
3819 call this%lak_calculate_outlet_outflow(n, hlak0, inf, qout0)
3820 call this%lak_calculate_available(n, hlak, inf, ra, ro, qinf, ex)
3821 call this%lak_calculate_outlet_outflow(n, hlak, inf, qout)
3822 dqout = (qout0 - qout) * qtolfact
3828 if (this%imover == 1)
then
3829 q = this%pakmvrobj%get_qfrommvr(n)
3830 q0 = this%pakmvrobj%get_qfrommvr0(n)
3831 dqfrommvr = qtolfact * (q0 - q)
3844 dqfrommvrmax = dqfrommvr
3847 if (abs(dh) > abs(dhmax))
then
3851 if (abs(resid) > abs(residmax))
then
3855 if (abs(dgwf) > abs(dgwfmax))
then
3859 if (abs(dqout) > abs(dqoutmax))
then
3863 if (abs(dqfrommvr) > abs(dqfrommvrmax))
then
3864 dqfrommvrmax = dqfrommvr
3871 if (abs(dhmax) > abs(dpak))
then
3874 write (cloc,
"(a,'-',a)") &
3875 trim(this%packName),
'stage'
3878 if (abs(residmax) > abs(dpak))
then
3881 write (cloc,
"(a,'-',a)") &
3882 trim(this%packName),
'residual'
3885 if (abs(dgwfmax) > abs(dpak))
then
3888 write (cloc,
"(a,'-',a)") &
3889 trim(this%packName),
'gwf'
3892 if (this%noutlets > 0)
then
3893 if (abs(dqoutmax) > abs(dpak))
then
3896 write (cloc,
"(a,'-',a)") &
3897 trim(this%packName),
'outlet'
3901 if (this%imover == 1)
then
3902 if (abs(dqfrommvrmax) > abs(dpak))
then
3903 ipak = locdqfrommvrmax
3905 write (cloc,
"(a,'-',a)") trim(this%packName),
'qfrommvr'
3911 if (this%ipakcsv /= 0)
then
3914 call this%pakcsvtab%add_term(innertot)
3915 call this%pakcsvtab%add_term(
totim)
3916 call this%pakcsvtab%add_term(
kper)
3917 call this%pakcsvtab%add_term(
kstp)
3918 call this%pakcsvtab%add_term(kiter)
3919 call this%pakcsvtab%add_term(dhmax)
3920 call this%pakcsvtab%add_term(locdhmax)
3921 call this%pakcsvtab%add_term(residmax)
3922 call this%pakcsvtab%add_term(locresidmax)
3923 call this%pakcsvtab%add_term(dgwfmax)
3924 call this%pakcsvtab%add_term(locdgwfmax)
3925 if (this%noutlets > 0)
then
3926 call this%pakcsvtab%add_term(dqoutmax)
3927 call this%pakcsvtab%add_term(locdqoutmax)
3929 if (this%imover == 1)
then
3930 call this%pakcsvtab%add_term(dqfrommvrmax)
3931 call this%pakcsvtab%add_term(locdqfrommvrmax)
3936 call this%pakcsvtab%finalize_table()
3948 class(
laktype),
intent(inout) :: this
3949 real(DP),
dimension(:),
intent(in) :: x
3950 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
3951 integer(I4B),
optional,
intent(in) :: iadv
3954 real(DP) :: chratin, chratout
3956 integer(I4B) :: j, n
3960 call this%lak_solve(update=.false.)
3964 call this%BndType%bnd_cq(x, flowja, iadv=1)
3969 do n = 1, this%nlakes
3970 this%chterm(n) =
dzero
3971 if (this%iboundpak(n) == 0) cycle
3972 hlak = this%xnewpak(n)
3973 call this%lak_calculate_vol(n, hlak, v1)
3976 if (this%iboundpak(n) /= 0)
then
3979 rrate = this%precip(n)
3980 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
3983 rrate = this%evap(n)
3984 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
3987 rrate = this%runoff(n)
3988 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
3991 rrate = this%inflow(n)
3992 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
3995 rrate = this%withr(n)
3996 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4000 if (this%iboundpak(n) > 0)
then
4001 if (this%gwfiss /= 1)
then
4002 call this%lak_calculate_vol(n, this%xoldpak(n), v0)
4003 rrate = -(v1 - v0) /
delt
4004 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4007 this%qsto(n) = rrate
4010 call this%lak_get_external_outlet(n, rrate)
4011 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4014 if (this%imover == 1)
then
4015 if (this%iboundpak(n) /= 0)
then
4016 rrate = this%pakmvrobj%get_qfrommvr(n)
4020 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4026 do n = 1, this%nlakes
4028 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4032 rrate = -this%simvals(j)
4033 this%qleak(j) = rrate
4034 if (this%iboundpak(n) /= 0)
then
4035 call this%lak_accumulate_chterm(n, rrate, chratin, chratout)
4041 call this%lak_fill_budobj()
4049 integer(I4B),
intent(in) :: icbcfl
4050 integer(I4B),
intent(in) :: ibudfl
4051 integer(I4B) :: ibinun
4055 if (this%ibudgetout /= 0)
then
4056 ibinun = this%ibudgetout
4058 if (icbcfl == 0) ibinun = 0
4059 if (ibinun > 0)
then
4060 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
4065 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
4066 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
4074 integer(I4B),
intent(in) :: icbcfl
4075 integer(I4B),
intent(in) :: ibudfl
4076 integer(I4B),
intent(in) :: icbcun
4077 integer(I4B),
dimension(:),
optional,
intent(in) :: imap
4080 call this%BndType%bnd_ot_model_flows(icbcfl, ibudfl, icbcun, this%imap)
4090 integer(I4B),
intent(in) :: idvsave
4091 integer(I4B),
intent(in) :: idvprint
4092 integer(I4B) :: ibinun
4102 if (this%istageout /= 0)
then
4103 ibinun = this%istageout
4105 if (idvsave == 0) ibinun = 0
4108 if (ibinun > 0)
then
4109 do n = 1, this%nlakes
4111 d = v - this%lakebot(n)
4112 if (this%iboundpak(n) == 0)
then
4114 else if (d <= dzero)
then
4120 this%nlakes, 1, 1, ibinun)
4124 if (idvprint /= 0 .and. this%iprhed /= 0)
then
4127 call this%stagetab%set_kstpkper(
kstp,
kper)
4130 do n = 1, this%nlakes
4131 if (this%iboundpak(n) == 0)
then
4137 stage = this%xnewpak(n)
4138 call this%lak_calculate_sarea(n, stage, sa)
4139 call this%lak_calculate_warea(n, stage, wa)
4140 call this%lak_calculate_vol(n, stage, v)
4142 if (this%inamedbound == 1)
then
4143 call this%stagetab%add_term(this%lakename(n))
4145 call this%stagetab%add_term(n)
4146 call this%stagetab%add_term(stage)
4147 call this%stagetab%add_term(sa)
4148 call this%stagetab%add_term(wa)
4149 call this%stagetab%add_term(v)
4161 integer(I4B),
intent(in) :: kstp
4162 integer(I4B),
intent(in) :: kper
4163 integer(I4B),
intent(in) :: iout
4164 integer(I4B),
intent(in) :: ibudfl
4166 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
4178 deallocate (this%lakename)
4179 deallocate (this%status)
4180 deallocate (this%clakbudget)
4182 deallocate (this%cauxcbc)
4190 if (this%ntables > 0)
then
4199 call this%budobj%budgetobject_da()
4200 deallocate (this%budobj)
4201 nullify (this%budobj)
4204 if (this%noutlets > 0)
then
4217 if (this%iprhed > 0)
then
4218 call this%stagetab%table_da()
4219 deallocate (this%stagetab)
4220 nullify (this%stagetab)
4224 if (this%ipakcsv > 0)
then
4225 if (
associated(this%pakcsvtab))
then
4226 call this%pakcsvtab%table_da()
4227 deallocate (this%pakcsvtab)
4228 nullify (this%pakcsvtab)
4326 nullify (this%gwfiss)
4329 call this%BndType%bnd_da()
4337 class(
laktype),
intent(inout) :: this
4340 this%listlabel = trim(this%filtyp)//
' NO.'
4341 if (this%dis%ndim == 3)
then
4342 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
4343 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
4344 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
4345 elseif (this%dis%ndim == 2)
then
4346 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
4347 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
4349 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
4351 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
4352 if (this%inamedbound == 1)
then
4353 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
4363 integer(I4B),
pointer :: neq
4364 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
4365 real(DP),
dimension(:),
pointer,
contiguous :: xnew
4366 real(DP),
dimension(:),
pointer,
contiguous :: xold
4367 real(DP),
dimension(:),
pointer,
contiguous :: flowja
4370 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
4405 integer(I4B) :: indx
4409 call this%obs%StoreObsType(
'stage', .false., indx)
4414 call this%obs%StoreObsType(
'ext-inflow', .true., indx)
4419 call this%obs%StoreObsType(
'outlet-inflow', .true., indx)
4424 call this%obs%StoreObsType(
'inflow', .true., indx)
4429 call this%obs%StoreObsType(
'from-mvr', .true., indx)
4434 call this%obs%StoreObsType(
'rainfall', .true., indx)
4439 call this%obs%StoreObsType(
'runoff', .true., indx)
4444 call this%obs%StoreObsType(
'lak', .true., indx)
4449 call this%obs%StoreObsType(
'evaporation', .true., indx)
4454 call this%obs%StoreObsType(
'withdrawal', .true., indx)
4459 call this%obs%StoreObsType(
'ext-outflow', .true., indx)
4464 call this%obs%StoreObsType(
'to-mvr', .true., indx)
4469 call this%obs%StoreObsType(
'storage', .true., indx)
4474 call this%obs%StoreObsType(
'constant', .true., indx)
4479 call this%obs%StoreObsType(
'outlet', .true., indx)
4484 call this%obs%StoreObsType(
'volume', .true., indx)
4489 call this%obs%StoreObsType(
'surface-area', .true., indx)
4494 call this%obs%StoreObsType(
'wetted-area', .true., indx)
4499 call this%obs%StoreObsType(
'conductance', .true., indx)
4511 integer(I4B) :: igwfnode
4522 if (this%obs%npakobs > 0)
then
4523 call this%obs%obs_bd_clear()
4524 do i = 1, this%obs%npakobs
4525 obsrv => this%obs%pakobs(i)%obsrv
4526 do j = 1, obsrv%indxbnds_count
4528 jj = obsrv%indxbnds(j)
4529 select case (obsrv%ObsTypeId)
4531 if (this%iboundpak(jj) /= 0)
then
4532 v = this%xnewpak(jj)
4535 if (this%iboundpak(jj) /= 0)
then
4536 call this%lak_calculate_inflow(jj, v)
4538 case (
'OUTLET-INFLOW')
4539 if (this%iboundpak(jj) /= 0)
then
4540 call this%lak_calculate_outlet_inflow(jj, v)
4543 if (this%iboundpak(jj) /= 0)
then
4544 call this%lak_calculate_inflow(jj, v)
4545 call this%lak_calculate_outlet_inflow(jj, v2)
4549 if (this%iboundpak(jj) /= 0)
then
4550 if (this%imover == 1)
then
4551 v = this%pakmvrobj%get_qfrommvr(jj)
4555 if (this%iboundpak(jj) /= 0)
then
4559 if (this%iboundpak(jj) /= 0)
then
4564 if (this%iboundpak(n) /= 0)
then
4565 igwfnode = this%cellid(jj)
4566 hgwf = this%xnew(igwfnode)
4567 if (this%hcof(jj) /=
dzero)
then
4568 v = -(this%hcof(jj) * (this%xnewpak(n) - hgwf))
4573 case (
'EVAPORATION')
4574 if (this%iboundpak(jj) /= 0)
then
4578 if (this%iboundpak(jj) /= 0)
then
4581 case (
'EXT-OUTFLOW')
4583 if (this%iboundpak(n) /= 0)
then
4584 if (this%lakeout(jj) == 0)
then
4585 v = this%simoutrate(jj)
4587 if (this%imover == 1)
then
4588 v = v + this%pakmvrobj%get_qtomvr(jj)
4595 if (this%iboundpak(n) /= 0)
then
4596 if (this%imover == 1)
then
4597 v = this%pakmvrobj%get_qtomvr(jj)
4604 if (this%iboundpak(jj) /= 0)
then
4608 if (this%iboundpak(jj) /= 0)
then
4613 if (this%iboundpak(n) /= 0)
then
4614 v = this%simoutrate(jj)
4617 if (this%iboundpak(jj) /= 0)
then
4618 call this%lak_calculate_vol(jj, this%xnewpak(jj), v)
4620 case (
'SURFACE-AREA')
4621 if (this%iboundpak(jj) /= 0)
then
4622 hlak = this%xnewpak(jj)
4623 call this%lak_calculate_sarea(jj, hlak, v)
4625 case (
'WETTED-AREA')
4627 if (this%iboundpak(n) /= 0)
then
4628 hlak = this%xnewpak(n)
4629 igwfnode = this%cellid(jj)
4630 hgwf = this%xnew(igwfnode)
4631 call this%lak_calculate_conn_warea(n, jj, hlak, hgwf, v)
4633 case (
'CONDUCTANCE')
4635 if (this%iboundpak(n) /= 0)
then
4636 hlak = this%xnewpak(n)
4637 igwfnode = this%cellid(jj)
4638 hgwf = this%xnew(igwfnode)
4639 call this%lak_calculate_conn_conductance(n, jj, hlak, hgwf, v)
4642 errmsg =
'Unrecognized observation type: '//trim(obsrv%ObsTypeId)
4645 call this%obs%SaveOneSimval(obsrv, v)
4664 class(
laktype),
intent(inout) :: this
4671 character(len=LENBOUNDNAME) :: bname
4672 logical(LGP) :: jfound
4675 10
format(
'Boundary "', a,
'" for observation "', a, &
4676 '" is invalid in package "', a,
'"')
4682 do i = 1, this%obs%npakobs
4683 obsrv => this%obs%pakobs(i)%obsrv
4686 nn1 = obsrv%NodeNumber
4688 bname = obsrv%FeatureName
4689 if (bname /=
'')
then
4694 if (obsrv%ObsTypeId ==
'LAK' .or. &
4695 obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4696 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4697 do j = 1, this%nlakes
4698 do jj = this%idxlakeconn(j), this%idxlakeconn(j + 1) - 1
4699 if (this%boundname(jj) == bname)
then
4701 call obsrv%AddObsIndex(jj)
4705 else if (obsrv%ObsTypeId ==
'EXT-OUTFLOW' .or. &
4706 obsrv%ObsTypeId ==
'TO-MVR' .or. &
4707 obsrv%ObsTypeId ==
'OUTLET')
then
4708 do j = 1, this%noutlets
4710 if (this%lakename(jj) == bname)
then
4712 call obsrv%AddObsIndex(j)
4716 do j = 1, this%nlakes
4717 if (this%lakename(j) == bname)
then
4719 call obsrv%AddObsIndex(j)
4723 if (.not. jfound)
then
4725 trim(bname), trim(obsrv%Name), trim(this%packName)
4730 if (obsrv%indxbnds_count == 0)
then
4731 if (obsrv%ObsTypeId ==
'LAK' .or. &
4732 obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4733 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4734 nn2 = obsrv%NodeNumber2
4735 j = this%idxlakeconn(nn1) + nn2 - 1
4736 call obsrv%AddObsIndex(j)
4738 call obsrv%AddObsIndex(nn1)
4741 errmsg =
'Programming error in lak_rp_obs'
4748 if (obsrv%ObsTypeId ==
'STAGE')
then
4749 if (obsrv%indxbnds_count > 1)
then
4750 write (
errmsg,
'(a,3(1x,a))') &
4751 trim(adjustl(obsrv%ObsTypeId)), &
4752 'for observation', trim(adjustl(obsrv%Name)), &
4753 ' must be assigned to a lake with a unique boundname.'
4759 if (obsrv%ObsTypeId ==
'TO-MVR' .or. &
4760 obsrv%ObsTypeId ==
'EXT-OUTFLOW' .or. &
4761 obsrv%ObsTypeId ==
'OUTLET')
then
4762 do j = 1, obsrv%indxbnds_count
4763 nn1 = obsrv%indxbnds(j)
4764 if (nn1 < 1 .or. nn1 > this%noutlets)
then
4765 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
4766 trim(adjustl(obsrv%ObsTypeId)), &
4767 ' outlet must be > 0 and <=', this%noutlets, &
4768 '(specified value is ', nn1,
')'
4772 else if (obsrv%ObsTypeId ==
'LAK' .or. &
4773 obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4774 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4775 do j = 1, obsrv%indxbnds_count
4776 nn1 = obsrv%indxbnds(j)
4777 if (nn1 < 1 .or. nn1 > this%maxbound)
then
4778 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
4779 trim(adjustl(obsrv%ObsTypeId)), &
4780 'lake connection number must be > 0 and <=', this%maxbound, &
4781 '(specified value is ', nn1,
')'
4786 do j = 1, obsrv%indxbnds_count
4787 nn1 = obsrv%indxbnds(j)
4788 if (nn1 < 1 .or. nn1 > this%nlakes)
then
4789 write (
errmsg,
'(a,1x,a,1x,i0,1x,a,1x,i0,a)') &
4790 trim(adjustl(obsrv%ObsTypeId)), &
4791 ' lake must be > 0 and <=', this%nlakes, &
4792 '(specified value is ', nn1,
')'
4817 integer(I4B),
intent(in) :: inunitobs
4818 integer(I4B),
intent(in) :: iout
4820 integer(I4B) :: nn1, nn2
4821 integer(I4B) :: icol, istart, istop
4822 character(len=LINELENGTH) :: string
4823 character(len=LENBOUNDNAME) :: bndname
4825 string = obsrv%IDstring
4833 obsrv%FeatureName = bndname
4835 if (obsrv%ObsTypeId ==
'LAK' .or. obsrv%ObsTypeId ==
'CONDUCTANCE' .or. &
4836 obsrv%ObsTypeId ==
'WETTED-AREA')
then
4838 if (len_trim(bndname) < 1 .and. nn2 < 0)
then
4839 write (
errmsg,
'(a,1x,a,a,1x,a,1x,a)') &
4840 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
4841 ', ID given as an integer and not as boundname,', &
4842 'but ID2 (iconn) is missing. Either change ID to valid', &
4843 'boundname or supply valid entry for ID2.'
4847 obsrv%FeatureName = bndname
4851 obsrv%NodeNumber2 = nn2
4856 obsrv%NodeNumber = nn1
4868 integer(I4B),
intent(in) :: ilak
4869 real(DP),
intent(in) :: rrate
4870 real(DP),
intent(inout) :: chratin
4871 real(DP),
intent(inout) :: chratout
4876 if (this%iboundpak(ilak) < 0)
then
4878 this%chterm(ilak) = this%chterm(ilak) + q
4884 chratout = chratout - q
4888 chratin = chratin + q
4897 class(
laktype),
intent(inout) :: this
4899 integer(I4B) :: j, n, node
4900 real(DP) :: hlak, head, clak
4903 if (this%nbound == 0)
return
4906 do n = 1, this%nlakes
4907 hlak = this%xnewpak(n)
4908 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
4909 node = this%cellid(j)
4910 head = this%xnew(node)
4911 call this%lak_calculate_conn_conductance(n, j, hlak, head, clak)
4912 this%bound(1, j) = hlak
4913 this%bound(2, j) = clak
4924 class(
laktype),
intent(inout) :: this
4925 logical(LGP),
intent(in),
optional :: update
4927 logical(LGP) :: lupdate
4931 integer(I4B) :: iicnvg
4932 integer(I4B) :: iter
4933 integer(I4B) :: maxiter
4934 integer(I4B) :: ncnv
4935 integer(I4B) :: idry
4936 integer(I4B) :: idry1
4937 integer(I4B) :: igwfnode
4938 integer(I4B) :: ibflg
4939 integer(I4B) :: idhp
4967 real(DP) :: qtolfact
4970 if (
present(update))
then
4981 do n = 1, this%nlakes
4983 this%surfin(n) =
dzero
4984 this%surfout(n) =
dzero
4985 this%surfout1(n) =
dzero
4986 if (this%xnewpak(n) < this%lakebot(n))
then
4987 this%xnewpak(n) = this%lakebot(n)
4989 if (this%gwfiss /= 0)
then
4990 this%xoldpak(n) = this%xnewpak(n)
4995 this%en1(n) = this%lakebot(n)
4996 call this%lak_calculate_residual(n, this%en1(n), this%r1(n))
4997 this%en2(n) = this%laketop(n)
4998 call this%lak_calculate_residual(n, this%en2(n), this%r2(n))
5000 do n = 1, this%noutlets
5001 this%simoutrate(n) =
dzero
5005 do n = 1, this%nlakes
5006 call this%lak_calculate_outlet_inflow(n, this%surfin(n))
5011 do n = 1, this%nlakes
5012 hlak0 = this%xoldpak(n)
5013 hlak = this%xnewpak(n)
5014 call this%lak_calculate_runoff(n, ro)
5015 call this%lak_calculate_inflow(n, qinf)
5016 call this%lak_calculate_external(n, ex)
5017 call this%lak_calculate_vol(n, hlak0, v0)
5018 call this%lak_calculate_vol(n, hlak, v1)
5019 this%flwin(n) = this%surfin(n) + ro + qinf + ex + &
5024 do n = 1, this%nlakes
5025 call this%lak_calculate_outlet_inflow(n, outinf)
5026 this%flwin(n) = this%flwin(n) + outinf
5030 maxiter = this%maxlakit
5033 converge:
do iter = 1, maxiter
5035 do n = 1, this%nlakes
5036 if (this%ncncvr(n) == 0) ncnv = 1
5038 if (iter == maxiter) ncnv = 0
5039 if (ncnv == 0) iicnvg = 1
5042 do n = 1, this%nlakes
5043 this%evap(n) =
dzero
5044 this%precip(n) =
dzero
5045 this%precip1(n) =
dzero
5046 this%seep(n) =
dzero
5047 this%seep1(n) =
dzero
5048 this%evap(n) =
dzero
5049 this%evap1(n) =
dzero
5050 this%evapo(n) =
dzero
5051 this%withr(n) =
dzero
5052 this%withr1(n) =
dzero
5053 this%flwiter(n) = this%flwin(n)
5054 this%flwiter1(n) = this%flwin(n)
5055 if (this%gwfiss /= 0)
then
5056 this%flwiter(n) =
dep20
5057 this%flwiter1(n) =
dep20
5059 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5060 this%hcof(j) =
dzero
5065 estseep:
do i = 1, 2
5066 lakseep:
do n = 1, this%nlakes
5068 if (this%iboundpak(n) == 0)
then
5072 if (this%gwfiss /= 0)
then
5073 this%xoldpak(n) = this%xnewpak(n)
5075 hlak = this%xnewpak(n)
5076 calcconnseep:
do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5077 igwfnode = this%cellid(j)
5078 head = this%xnew(igwfnode)
5079 if (this%ncncvr(n) /= 2)
then
5080 if (this%ibound(igwfnode) > 0)
then
5081 call this%lak_estimate_conn_exchange(i, n, j, idry, hlak, &
5085 call this%lak_estimate_conn_exchange(i, n, j, idry1, &
5086 hlak + delh, head, qlakgw1, &
5090 if (ncnv == 0 .and. i == 2)
then
5091 if (j == this%maxbound)
then
5095 this%hcof(j) = gwfhcof
5096 this%rhs(j) = gwfrhs
5098 this%hcof(j) =
dzero
5099 this%rhs(j) = qlakgw
5103 this%seep(n) = this%seep(n) + qlakgw
5104 this%seep1(n) = this%seep1(n) + qlakgw1
5113 laklevel:
do n = 1, this%nlakes
5115 if (this%iboundpak(n) == 0)
then
5120 hlak = this%xnewpak(n)
5121 if (iter < maxiter)
then
5122 this%stageiter(n) = this%xnewpak(n)
5124 call this%lak_calculate_rainfall(n, hlak, ra)
5126 this%flwiter(n) = this%flwiter(n) + ra
5127 call this%lak_calculate_rainfall(n, hlak + delh, ra)
5128 this%precip1(n) = ra
5129 this%flwiter1(n) = this%flwiter1(n) + ra
5132 call this%lak_calculate_withdrawal(n, this%flwiter(n), wr)
5134 call this%lak_calculate_withdrawal(n, this%flwiter1(n), wr)
5138 call this%lak_calculate_evaporation(n, hlak, this%flwiter(n), ev)
5140 call this%lak_calculate_evaporation(n, hlak + delh, this%flwiter1(n), ev)
5144 call this%lak_calculate_outlet_outflow(n, hlak + delh, &
5147 call this%lak_calculate_outlet_outflow(n, hlak, this%flwiter(n), &
5151 call this%lak_calculate_outlet_inflow(n, this%surfin(n))
5155 if (this%iboundpak(n) > 0 .and. lupdate .eqv. .true.)
then
5158 hlak0 = this%xoldpak(n)
5159 hlak = this%xnewpak(n)
5160 call this%lak_calculate_vol(n, hlak0, v0)
5161 call this%lak_calculate_vol(n, hlak, v1)
5162 call this%lak_calculate_runoff(n, ro)
5163 call this%lak_calculate_inflow(n, qinf)
5164 call this%lak_calculate_external(n, ex)
5165 this%flwin(n) = this%surfin(n) + ro + qinf + ex + &
5169 resid = this%precip(n) + this%evap(n) + this%withr(n) + ro + &
5170 qinf + ex + this%surfin(n) + &
5171 this%surfout(n) + this%seep(n)
5172 resid1 = this%precip1(n) + this%evap1(n) + this%withr1(n) + ro + &
5173 qinf + ex + this%surfin(n) + &
5174 this%surfout1(n) + this%seep1(n)
5177 hlak = this%xnewpak(n)
5178 if (this%gwfiss /= 1)
then
5179 call this%lak_calculate_vol(n, hlak, v1)
5180 resid = resid + (v0 - v1) /
delt
5181 call this%lak_calculate_vol(n, hlak + delh, v1)
5182 resid1 = resid1 + (v0 - v1) /
delt
5186 if (abs(resid1 - resid) >
dzero)
then
5187 derv = (resid1 - resid) / delh
5189 if (abs(derv) >
dprec)
then
5193 if (resid <
dzero)
then
5196 call this%lak_vol2stage(n, resid, dh)
5203 if (iter == 1) this%dh0(n) = dh
5205 adh0 = abs(this%dh0(n))
5206 if ((ts >= this%en2(n)) .or. (ts < this%en1(n)))
then
5209 if ((adh > adh0) .or. (ts - this%lakebot(n)) <
dprec)
then
5211 call this%lak_bisection(n, ibflg, hlak, ts, dh, residb)
5217 this%seep0(n) = this%seep(n)
5221 if (this%seep(n) * this%seep0(n) <
dprec)
then
5222 this%iseepc(n) = this%iseepc(n) + 1
5228 if (dh * this%dh0(n) <
dprec) idhp = 1
5231 if (adh > adh0) idhp = 1
5234 this%idhc(n) = this%idhc(n) + 1
5239 if (ibflg == 1)
then
5240 if (this%iseepc(n) > 7 .or. this%idhc(n) > 12)
then
5241 call this%lak_bisection(n, ibflg, hlak, ts, dh, residb)
5250 if (hlak < this%lakebot(n))
then
5251 hlak = this%lakebot(n)
5255 call this%lak_calculate_sarea(n, hlak, area)
5258 if (area >
dzero)
then
5259 qtolfact =
delt / area
5265 call this%lak_calculate_residual(n, hlak, resid)
5269 if (abs(dh) < delh .and. abs(resid) * qtolfact < this%dmaxchg)
then
5272 this%xnewpak(n) = hlak
5275 this%seep0(n) = this%seep(n)
5280 if (iicnvg == 1)
exit converge
5287 if (this%imover == 1)
then
5288 do n = 1, this%noutlets
5289 call this%pakmvrobj%accumulate_qformvr(n, -this%simoutrate(n))
5300 class(
laktype),
intent(inout) :: this
5301 integer(I4B),
intent(in) :: n
5302 integer(I4B),
intent(inout) :: ibflg
5303 real(DP),
intent(in) :: hlak
5304 real(DP),
intent(inout) :: temporary_stage
5305 real(DP),
intent(inout) :: dh
5306 real(DP),
intent(inout) :: residual
5309 real(DP) :: temporary_stage0
5310 real(DP) :: residuala
5311 real(DP) :: endpoint1
5312 real(DP) :: endpoint2
5315 temporary_stage0 = hlak
5316 endpoint1 = this%en1(n)
5317 endpoint2 = this%en2(n)
5318 call this%lak_calculate_residual(n, temporary_stage, residuala)
5319 if (hlak > endpoint1 .and. hlak < endpoint2)
then
5322 do i = 1, this%maxlakit
5323 temporary_stage =
dhalf * (endpoint1 + endpoint2)
5324 call this%lak_calculate_residual(n, temporary_stage, residual)
5325 if (abs(residual) ==
dzero .or. &
5326 abs(temporary_stage0 - temporary_stage) < this%dmaxchg)
then
5329 call this%lak_calculate_residual(n, endpoint1, residuala)
5332 if (sign(
done, residuala) == sign(
done, residual))
then
5333 endpoint1 = temporary_stage
5336 endpoint2 = temporary_stage
5338 temporary_stage0 = temporary_stage
5340 dh = hlak - temporary_stage
5347 ra, ro, qinf, ex, headp)
5351 class(
laktype),
intent(inout) :: this
5352 integer(I4B),
intent(in) :: n
5353 real(DP),
intent(in) :: hlak
5354 real(DP),
intent(inout) :: avail
5355 real(DP),
intent(inout) :: ra
5356 real(DP),
intent(inout) :: ro
5357 real(DP),
intent(inout) :: qinf
5358 real(DP),
intent(inout) :: ex
5359 real(DP),
intent(in),
optional :: headp
5362 integer(I4B) :: idry
5363 integer(I4B) :: igwfnode
5370 if (
present(headp))
then
5380 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5381 igwfnode = this%cellid(j)
5382 if (this%ibound(igwfnode) == 0) cycle
5383 head = this%xnew(igwfnode) + hp
5384 call this%lak_estimate_conn_exchange(1, n, j, idry, hlak, head, qlakgw, &
5389 call this%lak_calculate_rainfall(n, hlak, ra)
5393 call this%lak_calculate_runoff(n, ro)
5397 call this%lak_calculate_inflow(n, qinf)
5398 avail = avail + qinf
5401 call this%lak_calculate_external(n, ex)
5405 call this%lak_calculate_vol(n, this%xoldpak(n), v0)
5406 avail = avail + v0 /
delt
5415 class(
laktype),
intent(inout) :: this
5416 integer(I4B),
intent(in) :: n
5417 real(DP),
intent(in) :: hlak
5418 real(DP),
intent(inout) :: resid
5419 real(DP),
intent(in),
optional :: headp
5422 integer(I4B) :: idry
5423 integer(I4B) :: igwfnode
5442 if (
present(headp))
then
5454 call this%lak_calculate_available(n, hlak, avail, &
5455 ra, ro, qinf, ex, hp)
5458 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5459 igwfnode = this%cellid(j)
5460 if (this%ibound(igwfnode) == 0) cycle
5461 head = this%xnew(igwfnode) + hp
5462 call this%lak_estimate_conn_exchange(2, n, j, idry, hlak, head, qlakgw, &
5464 seep = seep + qlakgw
5468 call this%lak_calculate_withdrawal(n, avail, wr)
5471 call this%lak_calculate_evaporation(n, hlak, avail, ev)
5474 call this%lak_calculate_outlet_outflow(n, hlak, avail, sout)
5477 call this%lak_calculate_outlet_inflow(n, sin)
5480 resid = ra + ev + wr + ro + qinf + ex + sin + sout + seep
5483 if (this%gwfiss /= 1)
then
5484 hlak0 = this%xoldpak(n)
5485 call this%lak_calculate_vol(n, hlak0, v0)
5486 call this%lak_calculate_vol(n, hlak, v1)
5487 resid = resid + (v0 - v1) /
delt
5499 integer(I4B) :: nbudterm
5500 integer(I4B) :: nlen
5501 integer(I4B) :: j, n, n1, n2
5502 integer(I4B) :: maxlist, naux
5505 character(len=LENBUDTXT) :: text
5506 character(len=LENBUDTXT),
dimension(1) :: auxtxt
5512 do n = 1, this%noutlets
5513 if (this%lakein(n) > 0 .and. this%lakeout(n) > 0)
then
5517 if (nlen > 0) nbudterm = nbudterm + 1
5518 if (this%imover == 1) nbudterm = nbudterm + 2
5519 if (this%naux > 0) nbudterm = nbudterm + 1
5523 call this%budobj%budgetobject_df(this%nlakes, nbudterm, 0, 0, &
5524 ibudcsv=this%ibudcsv)
5530 text =
' FLOW-JA-FACE'
5534 call this%budobj%budterm(idx)%initialize(text, &
5539 maxlist, .false., .false., &
5540 naux, ordered_id1=.false.)
5543 call this%budobj%budterm(idx)%reset(2 * nlen)
5545 do n = 1, this%noutlets
5547 n2 = this%lakeout(n)
5548 if (n1 > 0 .and. n2 > 0)
then
5549 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5550 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
5558 maxlist = this%maxbound
5560 auxtxt(1) =
' FLOW-AREA'
5561 call this%budobj%budterm(idx)%initialize(text, &
5566 maxlist, .false., .true., &
5568 call this%budobj%budterm(idx)%reset(this%maxbound)
5570 do n = 1, this%nlakes
5571 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5573 call this%budobj%budterm(idx)%update_term(n, n2, q)
5580 maxlist = this%nlakes
5582 call this%budobj%budterm(idx)%initialize(text, &
5587 maxlist, .false., .false., &
5591 text =
' EVAPORATION'
5593 maxlist = this%nlakes
5595 call this%budobj%budterm(idx)%initialize(text, &
5600 maxlist, .false., .false., &
5606 maxlist = this%nlakes
5608 call this%budobj%budterm(idx)%initialize(text, &
5613 maxlist, .false., .false., &
5617 text =
' EXT-INFLOW'
5619 maxlist = this%nlakes
5621 call this%budobj%budterm(idx)%initialize(text, &
5626 maxlist, .false., .false., &
5630 text =
' WITHDRAWAL'
5632 maxlist = this%nlakes
5634 call this%budobj%budterm(idx)%initialize(text, &
5639 maxlist, .false., .false., &
5643 text =
' EXT-OUTFLOW'
5645 maxlist = this%nlakes
5647 call this%budobj%budterm(idx)%initialize(text, &
5652 maxlist, .false., .false., &
5658 maxlist = this%nlakes
5660 auxtxt(1) =
' VOLUME'
5661 call this%budobj%budterm(idx)%initialize(text, &
5666 maxlist, .false., .false., &
5672 maxlist = this%nlakes
5674 call this%budobj%budterm(idx)%initialize(text, &
5679 maxlist, .false., .false., &
5683 if (this%imover == 1)
then
5688 maxlist = this%nlakes
5690 call this%budobj%budterm(idx)%initialize(text, &
5695 maxlist, .false., .false., &
5701 maxlist = this%noutlets
5703 call this%budobj%budterm(idx)%initialize(text, &
5708 maxlist, .false., .false., &
5709 naux, ordered_id1=.false.)
5712 call this%budobj%budterm(idx)%reset(this%noutlets)
5714 do n = 1, this%noutlets
5716 call this%budobj%budterm(idx)%update_term(n1, n1, q)
5727 maxlist = this%nlakes
5728 call this%budobj%budterm(idx)%initialize(text, &
5733 maxlist, .false., .false., &
5738 if (this%iprflow /= 0)
then
5739 call this%budobj%flowtable_df(this%iout)
5749 integer(I4B) :: naux
5750 real(DP),
dimension(:),
allocatable :: auxvartmp
5759 integer(I4B) :: nlen
5762 real(DP) :: lkstg, gwhead, wa
5769 do n = 1, this%noutlets
5770 if (this%lakein(n) > 0 .and. this%lakeout(n) > 0)
then
5776 call this%budobj%budterm(idx)%reset(2 * nlen)
5777 do n = 1, this%noutlets
5779 n2 = this%lakeout(n)
5780 if (n1 > 0 .and. n2 > 0)
then
5781 q = this%simoutrate(n)
5782 if (this%imover == 1)
then
5783 q = q + this%pakmvrobj%get_qtomvr(n)
5785 call this%budobj%budterm(idx)%update_term(n1, n2, q)
5786 call this%budobj%budterm(idx)%update_term(n2, n1, -q)
5793 call this%budobj%budterm(idx)%reset(this%maxbound)
5794 do n = 1, this%nlakes
5795 do j = this%idxlakeconn(n), this%idxlakeconn(n + 1) - 1
5798 lkstg = this%xnewpak(n)
5802 gwhead = this%xnew(n2)
5803 call this%lak_calculate_conn_warea(n, j, lkstg, gwhead, wa)
5807 if (this%belev(j) > lkstg) wa =
dzero
5808 this%qauxcbc(1) = wa
5809 call this%budobj%budterm(idx)%update_term(n, n2, q, this%qauxcbc)
5815 call this%budobj%budterm(idx)%reset(this%nlakes)
5816 do n = 1, this%nlakes
5818 call this%budobj%budterm(idx)%update_term(n, n, q)
5823 call this%budobj%budterm(idx)%reset(this%nlakes)
5824 do n = 1, this%nlakes
5826 call this%budobj%budterm(idx)%update_term(n, n, q)
5831 call this%budobj%budterm(idx)%reset(this%nlakes)
5832 do n = 1, this%nlakes
5834 call this%budobj%budterm(idx)%update_term(n, n, q)
5839 call this%budobj%budterm(idx)%reset(this%nlakes)
5840 do n = 1, this%nlakes
5842 call this%budobj%budterm(idx)%update_term(n, n, q)
5847 call this%budobj%budterm(idx)%reset(this%nlakes)
5848 do n = 1, this%nlakes
5850 call this%budobj%budterm(idx)%update_term(n, n, q)
5855 call this%budobj%budterm(idx)%reset(this%nlakes)
5856 do n = 1, this%nlakes
5857 call this%lak_get_external_outlet(n, q)
5859 call this%lak_get_external_mover(n, v)
5861 call this%budobj%budterm(idx)%update_term(n, n, q)
5866 call this%budobj%budterm(idx)%reset(this%nlakes)
5867 do n = 1, this%nlakes
5868 call this%lak_calculate_vol(n, this%xnewpak(n), v1)
5870 this%qauxcbc(1) = v1
5871 call this%budobj%budterm(idx)%update_term(n, n, q, this%qauxcbc)
5876 call this%budobj%budterm(idx)%reset(this%nlakes)
5877 do n = 1, this%nlakes
5879 call this%budobj%budterm(idx)%update_term(n, n, q)
5883 if (this%imover == 1)
then
5887 call this%budobj%budterm(idx)%reset(this%nlakes)
5888 do n = 1, this%nlakes
5889 q = this%pakmvrobj%get_qfrommvr(n)
5890 call this%budobj%budterm(idx)%update_term(n, n, q)
5895 call this%budobj%budterm(idx)%reset(this%noutlets)
5896 do n = 1, this%noutlets
5898 q = this%pakmvrobj%get_qtomvr(n)
5902 call this%budobj%budterm(idx)%update_term(n1, n1, q)
5911 allocate (auxvartmp(naux))
5912 call this%budobj%budterm(idx)%reset(this%nlakes)
5913 do n = 1, this%nlakes
5917 auxvartmp(jj) = this%lauxvar(jj, ii)
5919 call this%budobj%budterm(idx)%update_term(n, n, q, auxvartmp)
5921 deallocate (auxvartmp)
5925 call this%budobj%accumulate_terms()
5939 integer(I4B) :: nterms
5940 character(len=LINELENGTH) :: title
5941 character(len=LINELENGTH) :: text
5944 if (this%iprhed > 0)
then
5951 if (this%inamedbound == 1)
then
5956 title = trim(adjustl(this%text))//
' PACKAGE ('// &
5957 trim(adjustl(this%packName))//
') STAGES FOR EACH CONTROL VOLUME'
5960 call table_cr(this%stagetab, this%packName, title)
5961 call this%stagetab%table_df(this%nlakes, nterms, this%iout, &
5965 if (this%inamedbound == 1)
then
5967 call this%stagetab%initialize_column(text, 20, alignment=tableft)
5972 call this%stagetab%initialize_column(text, 10, alignment=tabcenter)
5976 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5979 text =
'SURFACE AREA'
5980 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5983 text =
'WETTED AREA'
5984 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5988 call this%stagetab%initialize_column(text, 12, alignment=tabcenter)
5996 class(
laktype),
intent(inout) :: this
5998 integer(I4B) :: i, j
6002 call mem_reallocate(this%denseterms, 3, this%MAXBOUND,
'DENSETERMS', &
6004 do i = 1, this%maxbound
6006 this%denseterms(j, i) =
dzero
6009 write (this%iout,
'(/1x,a)')
'DENSITY TERMS HAVE BEEN ACTIVATED FOR LAKE &
6010 &PACKAGE: '//trim(adjustl(this%packName))
6021 class(
laktype),
intent(inout) :: this
6028 call mem_reallocate(this%viscratios, 2, this%MAXBOUND,
'VISCRATIOS', &
6030 do i = 1, this%maxbound
6032 this%viscratios(j, i) =
done
6035 write (this%iout,
'(/1x,a)')
'VISCOSITY HAS BEEN ACTIVATED FOR LAK &
6036 &PACKAGE: '//trim(adjustl(this%packName))
6058 botl, flow, gwfhcof, gwfrhs)
6060 class(
laktype),
intent(inout) :: this
6061 integer(I4B),
intent(in) :: iconn
6062 real(DP),
intent(in) :: stage
6063 real(DP),
intent(in) :: head
6064 real(DP),
intent(in) :: cond
6065 real(DP),
intent(in) :: botl
6066 real(DP),
intent(inout) :: flow
6067 real(DP),
intent(inout) :: gwfhcof
6068 real(DP),
intent(inout) :: gwfrhs
6073 real(DP) :: rdenselak
6074 real(DP) :: rdensegwf
6075 real(DP) :: rdenseavg
6081 logical(LGP) :: stage_below_bot
6082 logical(LGP) :: head_below_bot
6085 if (stage >= botl)
then
6087 stage_below_bot = .false.
6088 rdenselak = this%denseterms(1, iconn)
6091 stage_below_bot = .true.
6092 rdenselak = this%denseterms(2, iconn)
6096 if (head >= botl)
then
6098 head_below_bot = .false.
6099 rdensegwf = this%denseterms(2, iconn)
6102 head_below_bot = .true.
6103 rdensegwf = this%denseterms(1, iconn)
6107 if (rdensegwf ==
dzero)
return
6110 if (stage_below_bot .and. head_below_bot)
then
6117 rdenseavg =
dhalf * (rdenselak + rdensegwf)
6121 d1 = cond * (rdenseavg -
done)
6122 gwfhcof = gwfhcof - d1
6123 gwfrhs = gwfrhs - d1 * ss
6128 if (.not. stage_below_bot .and. .not. head_below_bot)
then
6132 elevgwf = this%denseterms(3, iconn)
6133 if (this%ictype(iconn) == 0 .or. this%ictype(iconn) == 3)
then
6140 elevavg =
dhalf * (elevlak + elevgwf)
6141 havg =
dhalf * (hh + ss)
6142 d2 = cond * (havg - elevavg) * (rdensegwf - rdenselak)
6143 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).