62 character(len=LENFTYPE) ::
ftype =
'APT'
63 character(len=LENVARNAME) ::
text =
' APT'
67 character(len=LENPACKAGENAME) :: flowpackagename =
''
69 dimension(:),
pointer,
contiguous :: status => null()
70 character(len=LENAUXNAME) :: cauxfpconc =
''
71 integer(I4B),
pointer :: iauxfpconc => null()
72 integer(I4B),
pointer :: imatrows => null()
73 integer(I4B),
pointer :: iprconc => null()
74 integer(I4B),
pointer :: iconcout => null()
75 integer(I4B),
pointer :: ibudgetout => null()
76 integer(I4B),
pointer :: ibudcsv => null()
77 integer(I4B),
pointer :: ncv => null()
78 integer(I4B),
pointer :: igwfaptpak => null()
79 integer(I4B),
pointer :: idxprepak => null()
80 integer(I4B),
pointer :: idxlastpak => null()
81 real(dp),
dimension(:),
pointer,
contiguous :: strt => null()
82 real(dp),
dimension(:),
pointer,
contiguous :: ktf => null()
83 real(dp),
dimension(:),
pointer,
contiguous :: rfeatthk => null()
84 integer(I4B),
dimension(:),
pointer,
contiguous :: idxlocnode => null()
85 integer(I4B),
dimension(:),
pointer,
contiguous :: idxpakdiag => null()
86 integer(I4B),
dimension(:),
pointer,
contiguous :: idxdglo => null()
87 integer(I4B),
dimension(:),
pointer,
contiguous :: idxoffdglo => null()
88 integer(I4B),
dimension(:),
pointer,
contiguous :: idxsymdglo => null()
89 integer(I4B),
dimension(:),
pointer,
contiguous :: idxsymoffdglo => null()
90 integer(I4B),
dimension(:),
pointer,
contiguous :: idxfjfdglo => null()
91 integer(I4B),
dimension(:),
pointer,
contiguous :: idxfjfoffdglo => null()
92 integer(I4B),
dimension(:),
pointer,
contiguous :: iboundpak => null()
93 real(dp),
dimension(:),
pointer,
contiguous :: xnewpak => null()
94 real(dp),
dimension(:),
pointer,
contiguous :: xoldpak => null()
95 real(dp),
dimension(:),
pointer,
contiguous :: dbuff => null()
96 character(len=LENBOUNDNAME), &
97 dimension(:),
pointer,
contiguous :: featname => null()
98 real(dp),
dimension(:),
pointer,
contiguous :: concfeat => null()
99 real(dp),
dimension(:, :),
pointer,
contiguous :: lauxvar => null()
101 real(dp),
dimension(:),
pointer,
contiguous :: qsto => null()
102 real(dp),
dimension(:),
pointer,
contiguous :: ccterm => null()
103 integer(I4B),
pointer :: idxbudfjf => null()
104 integer(I4B),
pointer :: idxbudgwf => null()
105 integer(I4B),
pointer :: idxbudsto => null()
106 integer(I4B),
pointer :: idxbudtmvr => null()
107 integer(I4B),
pointer :: idxbudfmvr => null()
108 integer(I4B),
pointer :: idxbudaux => null()
109 integer(I4B),
dimension(:),
pointer,
contiguous :: idxbudssm => null()
110 integer(I4B),
pointer :: nconcbudssm => null()
111 real(dp),
dimension(:, :),
pointer,
contiguous :: concbudssm => null()
112 real(dp),
dimension(:),
pointer,
contiguous :: qmfrommvr => null()
113 real(dp),
pointer :: eqnsclfac => null()
114 character(len=LENVARNAME) :: depvartype =
''
115 character(len=LENVARNAME) :: depvarunit =
''
116 character(len=LENVARNAME) :: depvarunitabbrev =
''
119 type(
bndtype),
pointer :: flowpackagebnd => null()
199 integer(I4B),
intent(in) :: moffset
203 integer(I4B) :: jj, jglo
208 if (this%imatrows /= 0)
then
212 nglo = moffset + this%dis%nodes + this%ioffset + n
213 call sparse%addconnection(nglo, nglo, 1)
217 do i = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
218 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(i)
219 jj = this%flowbudptr%budterm(this%idxbudgwf)%id2(i)
220 nglo = moffset + this%dis%nodes + this%ioffset + n
222 call sparse%addconnection(nglo, jglo, 1)
223 call sparse%addconnection(jglo, nglo, 1)
227 if (this%idxbudfjf /= 0)
then
228 do i = 1, this%flowbudptr%budterm(this%idxbudfjf)%maxlist
229 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(i)
230 jj = this%flowbudptr%budterm(this%idxbudfjf)%id2(i)
231 nglo = moffset + this%dis%nodes + this%ioffset + n
232 jglo = moffset + this%dis%nodes + this%ioffset + jj
233 call sparse%addconnection(nglo, jglo, 1)
241 subroutine apt_mc(this, moffset, matrix_sln)
245 integer(I4B),
intent(in) :: moffset
248 integer(I4B) :: n, j, iglo, jglo
253 call this%apt_allocate_index_arrays()
256 if (this%imatrows /= 0)
then
263 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
264 iglo = moffset + this%dis%nodes + this%ioffset + n
265 this%idxpakdiag(n) = matrix_sln%get_position_diag(iglo)
267 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
268 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
269 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
270 iglo = moffset + this%dis%nodes + this%ioffset + n
272 this%idxdglo(ipos) = matrix_sln%get_position_diag(iglo)
273 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
277 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
278 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
279 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
281 jglo = moffset + this%dis%nodes + this%ioffset + n
282 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
283 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
287 if (this%idxbudfjf /= 0)
then
288 do ipos = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
289 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(ipos)
290 j = this%flowbudptr%budterm(this%idxbudfjf)%id2(ipos)
291 iglo = moffset + this%dis%nodes + this%ioffset + n
292 jglo = moffset + this%dis%nodes + this%ioffset + j
293 this%idxfjfdglo(ipos) = matrix_sln%get_position_diag(iglo)
294 this%idxfjfoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
310 character(len=*),
parameter :: fmtapt = &
311 "(1x,/1x,'APT -- ADVANCED PACKAGE TRANSPORT, VERSION 1, 3/5/2020', &
312 &' INPUT READ FROM UNIT ', i0, //)"
315 call this%obs%obs_ar()
318 write (this%iout, fmtapt) this%inunit
321 call this%apt_allocate_arrays()
324 call this%read_initial_attr()
328 call this%fmi%get_package_index(this%flowpackagename, this%igwfaptpak)
333 this%fmi%iatp(this%igwfaptpak) = 1
334 this%fmi%datp(this%igwfaptpak)%concpack => this%get_mvr_depvar()
335 this%fmi%datp(this%igwfaptpak)%qmfrommvr => this%qmfrommvr
340 if (
associated(this%flowpackagebnd))
then
341 if (this%cauxfpconc /=
'')
then
343 do j = 1, this%flowpackagebnd%naux
344 if (this%flowpackagebnd%auxname(j) == this%cauxfpconc)
then
350 if (this%iauxfpconc == 0)
then
351 errmsg =
'Could not find auxiliary variable '// &
352 trim(adjustl(this%cauxfpconc))//
' in flow package '// &
353 trim(adjustl(this%flowpackagename))
355 call this%parser%StoreErrorUnit()
358 this%flowpackagebnd%noupdateauxvar(this%iauxfpconc) = 1
359 call this%apt_copy2flowp()
376 logical :: isfound, endOfBlock
377 character(len=LINELENGTH) :: title
378 character(len=LINELENGTH) :: line
379 integer(I4B) :: itemno
380 integer(I4B) :: igwfnode
382 character(len=*),
parameter :: fmtblkerr = &
383 &
"('Error. Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
384 character(len=*),
parameter :: fmtlsp = &
385 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
388 this%nbound = this%maxbound
392 if (this%inunit == 0)
return
395 if (this%ionper <
kper)
then
398 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
399 supportopenclose=.true., &
400 blockrequired=.false.)
404 call this%read_check_ionper()
410 this%ionper =
nper + 1
413 call this%parser%GetCurrentLine(line)
414 write (
errmsg, fmtblkerr) adjustl(trim(line))
416 call this%parser%StoreErrorUnit()
422 if (this%ionper ==
kper)
then
425 if (this%iprpak /= 0)
then
428 title = trim(adjustl(this%text))//
' PACKAGE ('// &
429 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
430 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
431 call table_cr(this%inputtab, this%packName, title)
432 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
434 call this%inputtab%initialize_column(
text, 10, alignment=
tabcenter)
436 call this%inputtab%initialize_column(
text, 20, alignment=
tableft)
438 write (
text,
'(a,1x,i6)')
'VALUE', n
439 call this%inputtab%initialize_column(
text, 15, alignment=
tabcenter)
445 call this%parser%GetNextLine(endofblock)
449 itemno = this%parser%GetInteger()
452 call this%apt_set_stressperiod(itemno)
455 if (this%iprpak /= 0)
then
456 call this%parser%GetCurrentLine(line)
457 call this%inputtab%line_to_columns(line)
461 if (this%iprpak /= 0)
then
462 call this%inputtab%finalize_table()
467 write (this%iout, fmtlsp) trim(this%filtyp)
473 call this%parser%StoreErrorUnit()
477 do n = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
478 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
479 this%nodelist(n) = igwfnode
499 integer(I4B),
intent(in) :: itemno
501 character(len=LINELENGTH) :: text
502 character(len=LINELENGTH) :: caux
503 character(len=LINELENGTH) :: keyword
507 real(DP),
pointer :: bndElem => null()
518 call this%parser%GetStringCaps(keyword)
519 select case (keyword)
521 ierr = this%apt_check_valid(itemno)
525 call this%parser%GetStringCaps(text)
526 this%status(itemno) = text(1:8)
527 if (text ==
'CONSTANT')
then
528 this%iboundpak(itemno) = -1
529 else if (text ==
'INACTIVE')
then
530 this%iboundpak(itemno) = 0
531 else if (text ==
'ACTIVE')
then
532 this%iboundpak(itemno) = 1
535 'Unknown '//trim(this%text)//
' status keyword: ', text//
'.'
538 case (
'CONCENTRATION',
'TEMPERATURE')
539 ierr = this%apt_check_valid(itemno)
543 call this%parser%GetString(text)
545 bndelem => this%concfeat(itemno)
547 this%packName,
'BND', this%tsManager, &
548 this%iprpak, this%depvartype)
550 ierr = this%apt_check_valid(itemno)
554 call this%parser%GetStringCaps(caux)
556 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
557 call this%parser%GetString(text)
559 bndelem => this%lauxvar(jj, ii)
561 this%packName,
'AUX', &
562 this%tsManager, this%iprpak, &
569 call this%pak_set_stressperiod(itemno, keyword, found)
572 if (.not. found)
then
574 'Unknown '//trim(adjustl(this%text))//
' data keyword: ', &
582 call this%parser%StoreErrorUnit()
594 integer(I4B),
intent(in) :: itemno
595 character(len=*),
intent(in) :: keyword
596 logical,
intent(inout) :: found
603 call store_error(
'Program error: pak_set_stressperiod not implemented.', &
616 integer(I4B),
intent(in) :: itemno
619 if (itemno < 1 .or. itemno > this%ncv)
then
620 write (
errmsg,
'(a,1x,i6,1x,a,1x,i6)') &
621 'Featureno ', itemno,
'must be > 0 and <= ', this%ncv
651 integer(I4B) :: j, iaux
654 call this%TsManager%ad()
659 if (this%naux > 0)
then
660 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
661 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
662 do iaux = 1, this%naux
663 this%auxvar(iaux, j) = this%lauxvar(iaux, n)
672 this%xoldpak(n) = this%xnewpak(n)
673 if (this%iboundpak(n) < 0)
then
674 this%xnewpak(n) = this%concfeat(n)
679 this%xnewpak(n) = this%xoldpak(n)
680 if (this%iboundpak(n) < 0)
then
681 this%xnewpak(n) = this%concfeat(n)
694 call this%obs%obs_ad()
697 call this%apt_ad_chk()
706 do i = 1,
size(this%qmfrommvr)
707 this%qmfrommvr(i) =
dzero
711 subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
715 real(DP),
dimension(:),
intent(inout) :: rhs
716 integer(I4B),
dimension(:),
intent(in) :: ia
717 integer(I4B),
dimension(:),
intent(in) :: idxglo
722 if (this%imatrows == 0)
then
723 call this%apt_fc_nonexpanded(rhs, ia, idxglo, matrix_sln)
725 call this%apt_fc_expanded(rhs, ia, idxglo, matrix_sln)
738 real(DP),
dimension(:),
intent(inout) :: rhs
739 integer(I4B),
dimension(:),
intent(in) :: ia
740 integer(I4B),
dimension(:),
intent(in) :: idxglo
743 integer(I4B) :: j, igwfnode, idiag
746 call this%apt_solve()
749 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
750 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
751 if (this%ibound(igwfnode) < 1) cycle
752 idiag = idxglo(ia(igwfnode))
753 call matrix_sln%add_value_pos(idiag, this%hcof(j))
754 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
767 real(DP),
dimension(:),
intent(inout) :: rhs
768 integer(I4B),
dimension(:),
intent(in) :: ia
769 integer(I4B),
dimension(:),
intent(in) :: idxglo
772 integer(I4B) :: j, n, n1, n2
774 integer(I4B) :: iposd, iposoffd
775 integer(I4B) :: ipossymd, ipossymoffd
777 real(DP) :: qbnd, qbnd_scaled
788 call this%pak_fc_expanded(rhs, ia, idxglo, matrix_sln)
792 cold = this%xoldpak(n)
793 iloc = this%idxlocnode(n)
794 iposd = this%idxpakdiag(n)
795 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
796 call matrix_sln%add_value_pos(iposd, hcofval)
797 rhs(iloc) = rhs(iloc) + rhsval
801 if (this%idxbudtmvr /= 0)
then
802 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
803 call this%apt_tmvr_term(j, n1, n2, rrate, rhsval, hcofval)
804 iloc = this%idxlocnode(n1)
805 iposd = this%idxpakdiag(n1)
806 call matrix_sln%add_value_pos(iposd, hcofval)
807 rhs(iloc) = rhs(iloc) + rhsval
812 if (this%idxbudfmvr /= 0)
then
814 rhsval = this%qmfrommvr(n)
815 iloc = this%idxlocnode(n)
816 rhs(iloc) = rhs(iloc) - rhsval
821 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
824 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
825 if (this%iboundpak(n) /= 0)
then
828 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
831 qbnd_scaled = qbnd * this%eqnsclfac
834 iposd = this%idxdglo(j)
835 iposoffd = this%idxoffdglo(j)
836 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
837 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
840 ipossymd = this%idxsymdglo(j)
841 ipossymoffd = this%idxsymoffdglo(j)
842 call matrix_sln%add_value_pos(ipossymd, -(
done - omega) * qbnd_scaled)
843 call matrix_sln%add_value_pos(ipossymoffd, -omega * qbnd_scaled)
848 if (this%idxbudfjf /= 0)
then
849 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
850 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(j)
851 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(j)
852 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(j)
853 if (qbnd <=
dzero)
then
858 qbnd_scaled = qbnd * this%eqnsclfac
859 iposd = this%idxfjfdglo(j)
860 iposoffd = this%idxfjfoffdglo(j)
861 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
862 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
876 real(DP),
dimension(:),
intent(inout) :: rhs
877 integer(I4B),
dimension(:),
intent(in) :: ia
878 integer(I4B),
dimension(:),
intent(in) :: idxglo
883 call store_error(
'Program error: pak_fc_expanded not implemented.', &
904 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
905 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
908 if (this%iboundpak(n) /= 0)
then
909 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
912 this%hcof(j) = -(
done - omega) * qbnd * this%eqnsclfac
913 this%rhs(j) = omega * qbnd * this%xnewpak(n) * this%eqnsclfac
926 real(DP),
dimension(:),
intent(in) :: x
927 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
928 integer(I4B),
optional,
intent(in) :: iadv
930 integer(I4B) :: n, n1, n2
935 if (this%imatrows == 0)
then
936 call this%apt_solve()
938 call this%apt_cfupdate()
942 call this%BndType%bnd_cq(x, flowja)
947 if (this%iboundpak(n) > 0)
then
948 call this%apt_stor_term(n, n1, n2, rrate)
954 call this%apt_copy2flowp()
957 call this%apt_fill_budobj(x, flowja)
965 integer(I4B),
intent(in) :: icbcfl
966 integer(I4B),
intent(in) :: ibudfl
967 integer(I4B) :: ibinun
971 if (this%ibudgetout /= 0)
then
972 ibinun = this%ibudgetout
974 if (icbcfl == 0) ibinun = 0
976 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
981 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
982 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
994 integer(I4B),
intent(in) :: idvsave
995 integer(I4B),
intent(in) :: idvprint
997 integer(I4B) :: ibinun
1000 character(len=LENBUDTXT) :: text
1004 if (this%iconcout /= 0)
then
1005 ibinun = this%iconcout
1007 if (idvsave == 0) ibinun = 0
1010 if (ibinun > 0)
then
1013 if (this%iboundpak(n) == 0)
then
1018 write (text,
'(a)') str_pad_left(this%depvartype, lenvarname)
1020 this%ncv, 1, 1, ibinun)
1024 if (idvprint /= 0 .and. this%iprconc /= 0)
then
1027 call this%dvtab%set_kstpkper(
kstp,
kper)
1031 if (this%inamedbound == 1)
then
1032 call this%dvtab%add_term(this%featname(n))
1034 call this%dvtab%add_term(n)
1035 call this%dvtab%add_term(this%xnewpak(n))
1047 integer(I4B),
intent(in) :: kstp
1048 integer(I4B),
intent(in) :: kper
1049 integer(I4B),
intent(in) :: iout
1050 integer(I4B),
intent(in) :: ibudfl
1052 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
1067 call this%BndType%allocate_scalars()
1070 call mem_allocate(this%iauxfpconc,
'IAUXFPCONC', this%memoryPath)
1071 call mem_allocate(this%imatrows,
'IMATROWS', this%memoryPath)
1072 call mem_allocate(this%iprconc,
'IPRCONC', this%memoryPath)
1073 call mem_allocate(this%iconcout,
'ICONCOUT', this%memoryPath)
1074 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
1075 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
1076 call mem_allocate(this%igwfaptpak,
'IGWFAPTPAK', this%memoryPath)
1078 call mem_allocate(this%idxbudfjf,
'IDXBUDFJF', this%memoryPath)
1079 call mem_allocate(this%idxbudgwf,
'IDXBUDGWF', this%memoryPath)
1080 call mem_allocate(this%idxbudsto,
'IDXBUDSTO', this%memoryPath)
1081 call mem_allocate(this%idxbudtmvr,
'IDXBUDTMVR', this%memoryPath)
1082 call mem_allocate(this%idxbudfmvr,
'IDXBUDFMVR', this%memoryPath)
1083 call mem_allocate(this%idxbudaux,
'IDXBUDAUX', this%memoryPath)
1084 call mem_allocate(this%nconcbudssm,
'NCONCBUDSSM', this%memoryPath)
1085 call mem_allocate(this%idxprepak,
'IDXPREPAK', this%memoryPath)
1086 call mem_allocate(this%idxlastpak,
'IDXLASTPAK', this%memoryPath)
1103 this%nconcbudssm = 0
1123 if (this%imatrows /= 0)
then
1127 if (this%idxbudfjf /= 0)
then
1128 n = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1132 call mem_allocate(this%idxlocnode, this%ncv,
'IDXLOCNODE', &
1134 call mem_allocate(this%idxpakdiag, this%ncv,
'IDXPAKDIAG', &
1136 call mem_allocate(this%idxdglo, this%maxbound,
'IDXGLO', &
1138 call mem_allocate(this%idxoffdglo, this%maxbound,
'IDXOFFDGLO', &
1140 call mem_allocate(this%idxsymdglo, this%maxbound,
'IDXSYMDGLO', &
1142 call mem_allocate(this%idxsymoffdglo, this%maxbound,
'IDXSYMOFFDGLO', &
1146 call mem_allocate(this%idxfjfoffdglo, n,
'IDXFJFOFFDGLO', &
1159 call mem_allocate(this%idxsymoffdglo, 0,
'IDXSYMOFFDGLO', &
1163 call mem_allocate(this%idxfjfoffdglo, 0,
'IDXFJFOFFDGLO', &
1181 call this%BndType%allocate_arrays()
1186 if (this%iconcout > 0)
then
1187 call mem_allocate(this%dbuff, this%ncv,
'DBUFF', this%memoryPath)
1189 this%dbuff(n) =
dzero
1192 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
1196 allocate (this%status(this%ncv))
1199 call mem_allocate(this%concfeat, this%ncv,
'CONCFEAT', this%memoryPath)
1202 call mem_allocate(this%qsto, this%ncv,
'QSTO', this%memoryPath)
1203 call mem_allocate(this%ccterm, this%ncv,
'CCTERM', this%memoryPath)
1206 call mem_allocate(this%concbudssm, this%nconcbudssm, this%ncv, &
1207 'CONCBUDSSM', this%memoryPath)
1210 call mem_allocate(this%qmfrommvr, this%ncv,
'QMFROMMVR', this%memoryPath)
1214 this%status(n) =
'ACTIVE'
1215 this%qsto(n) =
dzero
1216 this%ccterm(n) =
dzero
1217 this%qmfrommvr(n) =
dzero
1218 this%concbudssm(:, n) =
dzero
1219 this%concfeat(n) =
dzero
1243 if (this%imatrows == 0)
then
1250 deallocate (this%status)
1251 deallocate (this%featname)
1254 call this%budobj%budgetobject_da()
1255 deallocate (this%budobj)
1256 nullify (this%budobj)
1259 if (this%iprconc > 0)
then
1260 call this%dvtab%table_da()
1261 deallocate (this%dvtab)
1262 nullify (this%dvtab)
1296 call this%BndType%bnd_da()
1309 call store_error(
'Program error: pak_solve not implemented.', &
1323 character(len=*),
intent(inout) :: option
1324 logical,
intent(inout) :: found
1326 character(len=MAXCHARLEN) :: fname, keyword
1328 character(len=*),
parameter :: fmtaptbin = &
1329 "(4x, a, 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, &
1330 &/4x, 'OPENED ON UNIT: ', I0)"
1333 select case (option)
1334 case (
'FLOW_PACKAGE_NAME')
1335 call this%parser%GetStringCaps(this%flowpackagename)
1336 write (this%iout,
'(4x,a)') &
1337 'THIS '//trim(adjustl(this%text))//
' PACKAGE CORRESPONDS TO A GWF &
1338 &PACKAGE WITH THE NAME '//trim(adjustl(this%flowpackagename))
1339 case (
'FLOW_PACKAGE_AUXILIARY_NAME')
1340 call this%parser%GetStringCaps(this%cauxfpconc)
1341 write (this%iout,
'(4x,a)') &
1342 'SIMULATED CONCENTRATIONS WILL BE COPIED INTO THE FLOW PACKAGE &
1343 &AUXILIARY VARIABLE WITH THE NAME '//trim(adjustl(this%cauxfpconc))
1344 case (
'DEV_NONEXPANDING_MATRIX')
1349 call this%parser%DevOpt()
1351 write (this%iout,
'(4x,a)') &
1352 trim(adjustl(this%text))// &
1353 ' WILL NOT ADD ADDITIONAL ROWS TO THE A MATRIX.'
1354 case (
'PRINT_CONCENTRATION',
'PRINT_TEMPERATURE')
1356 write (this%iout,
'(4x,a,1x,a,1x,a)') trim(adjustl(this%text))// &
1357 trim(adjustl(this%depvartype))//
'S WILL BE PRINTED TO LISTING &
1359 case (
'CONCENTRATION',
'TEMPERATURE')
1360 call this%parser%GetStringCaps(keyword)
1361 if (keyword ==
'FILEOUT')
then
1362 call this%parser%GetString(fname)
1364 call openfile(this%iconcout, this%iout, fname,
'DATA(BINARY)', &
1366 write (this%iout, fmtaptbin) &
1367 trim(adjustl(this%text)), trim(adjustl(this%depvartype)), &
1368 trim(fname), this%iconcout
1370 write (
errmsg,
"('Optional', 1x, a, 1X, 'keyword must &
1371 &be followed by FILEOUT')") this%depvartype
1375 call this%parser%GetStringCaps(keyword)
1376 if (keyword ==
'FILEOUT')
then
1377 call this%parser%GetString(fname)
1378 call assign_iounit(this%ibudgetout, this%inunit,
"BUDGET fileout")
1379 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
1381 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET', &
1382 trim(fname), this%ibudgetout
1384 call store_error(
'Optional BUDGET keyword must be followed by FILEOUT')
1387 call this%parser%GetStringCaps(keyword)
1388 if (keyword ==
'FILEOUT')
then
1389 call this%parser%GetString(fname)
1390 call assign_iounit(this%ibudcsv, this%inunit,
"BUDGETCSV fileout")
1391 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
1392 filstat_opt=
'REPLACE')
1393 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET CSV', &
1394 trim(fname), this%ibudcsv
1396 call store_error(
'Optional BUDGETCSV keyword must be followed by &
1412 integer(I4B) :: ierr
1416 if (this%flowpackagename ==
'')
then
1417 this%flowpackagename = this%packName
1418 write (this%iout,
'(4x,a)') &
1419 'THE FLOW PACKAGE NAME FOR '//trim(adjustl(this%text))//
' WAS NOT &
1420 &SPECIFIED. SETTING FLOW PACKAGE NAME TO '// &
1421 &trim(adjustl(this%flowpackagename))
1424 call this%find_apt_package()
1427 this%ncv = this%flowbudptr%ncv
1428 this%maxbound = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1429 this%nbound = this%maxbound
1430 write (this%iout,
'(a, a)')
'SETTING DIMENSIONS FOR PACKAGE ', this%packName
1431 write (this%iout,
'(2x,a,i0)')
'NUMBER OF CONTROL VOLUMES = ', this%ncv
1432 write (this%iout,
'(2x,a,i0)')
'MAXBOUND = ', this%maxbound
1433 write (this%iout,
'(2x,a,i0)')
'NBOUND = ', this%nbound
1434 if (this%imatrows /= 0)
then
1435 this%npakeq = this%ncv
1436 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1437 ' SOLVED AS PART OF GWT MATRIX EQUATIONS'
1439 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1440 ' SOLVED SEPARATELY FROM GWT MATRIX EQUATIONS '
1442 write (this%iout,
'(a, //)')
'DONE SETTING DIMENSIONS FOR '// &
1443 trim(adjustl(this%text))
1446 if (this%ncv < 0)
then
1448 'Number of control volumes could not be determined correctly.'
1459 call this%apt_read_cvs()
1463 call this%define_listlabel()
1466 call this%apt_setup_budobj()
1469 call this%apt_setup_tableobj()
1481 character(len=LINELENGTH) :: text
1482 character(len=LENBOUNDNAME) :: bndName, bndNameTemp
1483 character(len=9) :: cno
1484 character(len=50),
dimension(:),
allocatable :: caux
1485 integer(I4B) :: ierr
1486 logical :: isfound, endOfBlock
1488 integer(I4B) :: ii, jj
1489 integer(I4B) :: iaux
1490 integer(I4B) :: itmp
1491 integer(I4B) :: nlak
1492 integer(I4B) :: nconn
1493 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1494 real(DP),
pointer :: bndElem => null()
1500 call mem_allocate(this%strt, this%ncv,
'STRT', this%memoryPath)
1501 call mem_allocate(this%ktf, this%ncv,
'KTF', this%memoryPath)
1502 call mem_allocate(this%rfeatthk, this%ncv,
'RFEATTHK', this%memoryPath)
1503 call mem_allocate(this%lauxvar, this%naux, this%ncv,
'LAUXVAR', &
1507 if (this%imatrows == 0)
then
1508 call mem_allocate(this%iboundpak, this%ncv,
'IBOUND', this%memoryPath)
1509 call mem_allocate(this%xnewpak, this%ncv,
'XNEWPAK', this%memoryPath)
1511 call mem_allocate(this%xoldpak, this%ncv,
'XOLDPAK', this%memoryPath)
1514 allocate (this%featname(this%ncv))
1518 this%strt(n) =
dep20
1520 this%rfeatthk(n) =
dzero
1521 this%lauxvar(:, n) =
dzero
1522 this%xoldpak(n) =
dep20
1523 if (this%imatrows == 0)
then
1524 this%iboundpak(n) = 1
1525 this%xnewpak(n) =
dep20
1530 if (this%naux > 0)
then
1531 allocate (caux(this%naux))
1535 allocate (nboundchk(this%ncv))
1541 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
1542 supportopenclose=.true.)
1546 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1551 call this%parser%GetNextLine(endofblock)
1552 if (endofblock)
exit
1553 n = this%parser%GetInteger()
1555 if (n < 1 .or. n > this%ncv)
then
1556 write (
errmsg,
'(a,1x,i6)') &
1557 'Itemno must be > 0 and <= ', this%ncv
1563 nboundchk(n) = nboundchk(n) + 1
1566 this%strt(n) = this%parser%GetDouble()
1569 if (this%depvartype ==
'TEMPERATURE')
then
1571 if (trim(adjustl(this%text)) /=
'UZE')
then
1572 this%ktf(n) = this%parser%GetDouble()
1573 this%rfeatthk(n) = this%parser%GetDouble()
1574 if (this%rfeatthk(n) <=
dzero)
then
1575 write (
errmsg,
'(4x,a)') &
1576 '****ERROR. Specified thickness used for thermal &
1577 &conduction MUST BE > 0 else divide by zero error occurs'
1585 do iaux = 1, this%naux
1586 call this%parser%GetString(caux(iaux))
1590 write (cno,
'(i9.9)') n
1591 bndname =
'Feature'//cno
1594 if (this%inamedbound /= 0)
then
1595 call this%parser%GetStringCaps(bndnametemp)
1596 if (bndnametemp /=
'')
then
1597 bndname = bndnametemp
1600 this%featname(n) = bndname
1604 do jj = 1, this%naux
1607 bndelem => this%lauxvar(jj, ii)
1609 this%packName,
'AUX', &
1610 this%tsManager, this%iprpak, &
1619 if (nboundchk(n) == 0)
then
1620 write (
errmsg,
'(a,1x,i0)')
'No data specified for feature', n
1622 else if (nboundchk(n) > 1)
then
1623 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1624 'Data for feature', n,
'specified', nboundchk(n),
'times'
1629 write (this%iout,
'(1x,a)') &
1630 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1632 call store_error(
'Required packagedata block not found.')
1637 call this%parser%StoreErrorUnit()
1641 if (this%naux > 0)
then
1646 deallocate (nboundchk)
1658 integer(I4B) :: j, n
1664 this%xnewpak(n) = this%strt(n)
1673 if (this%status(n) ==
'CONSTANT')
then
1674 this%iboundpak(n) = -1
1675 else if (this%status(n) ==
'INACTIVE')
then
1676 this%iboundpak(n) = 0
1677 else if (this%status(n) ==
'ACTIVE ')
then
1678 this%iboundpak(n) = 1
1683 if (this%inamedbound /= 0)
then
1684 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1685 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1686 this%boundname(j) = this%featname(n)
1691 call this%copy_boundname()
1705 integer(I4B) :: n, j, igwfnode
1706 integer(I4B) :: n1, n2
1709 real(DP) :: c1, qbnd
1710 real(DP) :: hcofval, rhsval
1714 this%dbuff(n) = dzero
1719 call this%pak_solve()
1722 if (this%idxbudtmvr /= 0)
then
1723 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
1724 call this%apt_tmvr_term(j, n1, n2, rrate)
1725 this%dbuff(n1) = this%dbuff(n1) + rrate
1730 if (this%idxbudfmvr /= 0)
then
1731 do n1 = 1,
size(this%qmfrommvr)
1732 rrate = this%qmfrommvr(n1)
1733 this%dbuff(n1) = this%dbuff(n1) + rrate
1739 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1740 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1741 this%hcof(j) = dzero
1743 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
1744 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
1745 if (qbnd <= dzero)
then
1746 ctmp = this%xnewpak(n)
1747 this%rhs(j) = qbnd * ctmp * this%eqnsclfac
1749 ctmp = this%xnew(igwfnode)
1750 this%hcof(j) = -qbnd * this%eqnsclfac
1752 c1 = qbnd * ctmp * this%eqnsclfac
1753 this%dbuff(n) = this%dbuff(n) + c1
1758 if (this%idxbudfjf /= 0)
then
1759 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
1760 call this%apt_fjf_term(j, n1, n2, rrate)
1762 this%dbuff(n1) = this%dbuff(n1) + c1
1768 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
1772 this%dbuff(n) = this%dbuff(n) - rhsval
1775 c1 = -this%dbuff(n) / hcofval
1776 if (this%iboundpak(n) > 0)
then
1777 this%xnewpak(n) = c1
1793 call store_error(
'Program error: pak_solve not implemented.', &
1802 integer(I4B),
intent(in) :: ilak
1803 real(DP),
intent(in) :: rrate
1804 real(DP),
intent(inout) :: ccratin
1805 real(DP),
intent(inout) :: ccratout
1811 if (this%iboundpak(ilak) < 0)
then
1813 this%ccterm(ilak) = this%ccterm(ilak) + q
1819 ccratout = ccratout - q
1823 ccratin = ccratin + q
1835 this%listlabel = trim(this%filtyp)//
' NO.'
1836 if (this%dis%ndim == 3)
then
1837 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1838 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
1839 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
1840 elseif (this%dis%ndim == 2)
then
1841 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1842 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
1844 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
1846 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
1847 if (this%inamedbound == 1)
then
1848 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
1857 integer(I4B),
pointer :: neq
1858 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
1859 real(DP),
dimension(:),
pointer,
contiguous :: xnew
1860 real(DP),
dimension(:),
pointer,
contiguous :: xold
1861 real(DP),
dimension(:),
pointer,
contiguous :: flowja
1863 integer(I4B) :: istart, iend
1866 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
1871 if (this%imatrows /= 0)
then
1872 istart = this%dis%nodes + this%ioffset + 1
1873 iend = istart + this%ncv - 1
1874 this%iboundpak => this%ibound(istart:iend)
1875 this%xnewpak => this%xnew(istart:iend)
1885 integer(I4B),
intent(in) :: icv
1886 real(DP),
intent(inout) :: vnew, vold
1887 real(DP),
intent(in) :: delt
1894 if (this%idxbudsto /= 0)
then
1895 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1896 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1897 vold = vnew + qss * delt
1910 integer(I4B) :: nbudterms
1914 call store_error(
'Program error: pak_get_nbudterms not implemented.', &
1927 integer(I4B) :: nbudterm
1928 integer(I4B) :: nlen
1929 integer(I4B) :: n, n1, n2
1930 integer(I4B) :: maxlist, naux
1932 logical :: ordered_id1
1934 character(len=LENBUDTXT) :: bddim_opt
1935 character(len=LENBUDTXT) :: text, textt
1936 character(len=LENBUDTXT),
dimension(1) :: auxtxt
1943 if (this%idxbudfjf /= 0)
then
1944 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1951 if (this%idxbudfjf /= 0) nbudterm = nbudterm + 1
1954 nbudterm = nbudterm + 3
1957 nbudterm = nbudterm + this%pak_get_nbudterms()
1960 if (this%idxbudtmvr /= 0) nbudterm = nbudterm + 1
1961 if (this%idxbudfmvr /= 0) nbudterm = nbudterm + 1
1962 if (this%naux > 0) nbudterm = nbudterm + 1
1967 bddim_opt = this%depvarunitabbrev
1968 call this%budobj%budgetobject_df(this%ncv, nbudterm, 0, 0, &
1969 bddim_opt=bddim_opt, ibudcsv=this%ibudcsv)
1974 text =
' FLOW-JA-FACE'
1976 maxlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1978 ordered_id1 = this%flowbudptr%budterm(this%idxbudfjf)%ordered_id1
1979 call this%budobj%budterm(idx)%initialize(text, &
1984 maxlist, .false., .false., &
1985 naux, ordered_id1=ordered_id1)
1988 call this%budobj%budterm(idx)%reset(maxlist)
1991 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(n)
1992 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(n)
1993 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2000 maxlist = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
2002 call this%budobj%budterm(idx)%initialize(text, &
2007 maxlist, .false., .true., &
2009 call this%budobj%budterm(idx)%reset(maxlist)
2012 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(n)
2013 n2 = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
2014 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2018 this%idxprepak = idx
2019 call this%pak_setup_budobj(idx)
2020 this%idxlastpak = idx
2025 maxlist = this%flowbudptr%budterm(this%idxbudsto)%maxlist
2029 call this%budobj%budterm(idx)%initialize(text, &
2034 maxlist, .false., .false., &
2036 if (this%idxbudtmvr /= 0)
then
2041 maxlist = this%flowbudptr%budterm(this%idxbudtmvr)%maxlist
2043 ordered_id1 = this%flowbudptr%budterm(this%idxbudtmvr)%ordered_id1
2044 call this%budobj%budterm(idx)%initialize(text, &
2049 maxlist, .false., .false., &
2050 naux, ordered_id1=ordered_id1)
2052 if (this%idxbudfmvr /= 0)
then
2059 call this%budobj%budterm(idx)%initialize(text, &
2064 maxlist, .false., .false., &
2073 call this%budobj%budterm(idx)%initialize(text, &
2078 maxlist, .false., .false., &
2090 call this%budobj%budterm(idx)%initialize(text, &
2095 maxlist, .false., .false., &
2100 if (this%iprflow /= 0)
then
2101 call this%budobj%flowtable_df(this%iout)
2113 integer(I4B),
intent(inout) :: idx
2117 call store_error(
'Program error: pak_setup_budobj not implemented.', &
2128 real(DP),
dimension(:),
intent(in) :: x
2129 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2131 integer(I4B) :: naux
2132 real(DP),
dimension(:),
allocatable :: auxvartmp
2133 integer(I4B) :: i, j, n1, n2
2135 integer(I4B) :: nlen
2136 integer(I4B) :: nlist
2137 integer(I4B) :: igwfnode
2140 real(DP) :: ccratin, ccratout
2151 this%ccterm(n1) =
dzero
2156 if (this%idxbudfjf /= 0)
then
2157 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2161 nlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2162 call this%budobj%budterm(idx)%reset(nlist)
2165 call this%apt_fjf_term(j, n1, n2, q)
2166 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2167 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2173 call this%budobj%budterm(idx)%reset(this%maxbound)
2174 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2176 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2177 if (this%iboundpak(n1) /= 0)
then
2178 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
2179 q = this%hcof(j) * x(igwfnode) - this%rhs(j)
2182 call this%budobj%budterm(idx)%update_term(n1, igwfnode, q)
2183 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2188 idx = this%idxlastpak
2192 call this%budobj%budterm(idx)%reset(this%ncv)
2193 allocate (auxvartmp(1))
2195 call this%get_volumes(n1, v1, v0,
delt)
2196 auxvartmp(1) = v1 * this%xnewpak(n1)
2198 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2199 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2201 deallocate (auxvartmp)
2204 if (this%idxbudtmvr /= 0)
then
2206 nlist = this%flowbudptr%budterm(this%idxbudtmvr)%nlist
2207 call this%budobj%budterm(idx)%reset(nlist)
2209 call this%apt_tmvr_term(j, n1, n2, q)
2210 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2211 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2216 if (this%idxbudfmvr /= 0)
then
2219 call this%budobj%budterm(idx)%reset(nlist)
2221 call this%apt_fmvr_term(j, n1, n2, q)
2222 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2223 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2229 call this%budobj%budterm(idx)%reset(this%ncv)
2232 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2239 allocate (auxvartmp(naux))
2240 call this%budobj%budterm(idx)%reset(this%ncv)
2244 auxvartmp(i) = this%lauxvar(i, n1)
2246 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2248 deallocate (auxvartmp)
2252 idx = this%idxprepak
2253 call this%pak_fill_budobj(idx, x, flowja, ccratin, ccratout)
2256 call this%budobj%accumulate_terms()
2265 integer(I4B),
intent(inout) :: idx
2266 real(DP),
dimension(:),
intent(in) :: x
2267 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2268 real(DP),
intent(inout) :: ccratin
2269 real(DP),
intent(inout) :: ccratout
2274 call store_error(
'Program error: pak_fill_budobj not implemented.', &
2284 integer(I4B),
intent(in) :: ientry
2285 integer(I4B),
intent(inout) :: n1
2286 integer(I4B),
intent(inout) :: n2
2287 real(DP),
intent(inout),
optional :: rrate
2288 real(DP),
intent(inout),
optional :: rhsval
2289 real(DP),
intent(inout),
optional :: hcofval
2295 call this%get_volumes(n1, v1, v0,
delt)
2296 c0 = this%xoldpak(n1)
2297 c1 = this%xnewpak(n1)
2298 if (
present(rrate))
then
2299 rrate = (-c1 * v1 /
delt + c0 * v0 /
delt) * this%eqnsclfac
2301 if (
present(rhsval)) rhsval = -c0 * v0 * this%eqnsclfac /
delt
2302 if (
present(hcofval)) hcofval = -v1 * this%eqnsclfac /
delt
2312 integer(I4B),
intent(in) :: ientry
2313 integer(I4B),
intent(inout) :: n1
2314 integer(I4B),
intent(inout) :: n2
2315 real(DP),
intent(inout),
optional :: rrate
2316 real(DP),
intent(inout),
optional :: rhsval
2317 real(DP),
intent(inout),
optional :: hcofval
2323 n1 = this%flowbudptr%budterm(this%idxbudtmvr)%id1(ientry)
2324 n2 = this%flowbudptr%budterm(this%idxbudtmvr)%id2(ientry)
2325 qbnd = this%flowbudptr%budterm(this%idxbudtmvr)%flow(ientry)
2326 ctmp = this%xnewpak(n1)
2327 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2328 if (
present(rhsval)) rhsval =
dzero
2329 if (
present(hcofval)) hcofval = qbnd * this%eqnsclfac
2340 integer(I4B),
intent(in) :: ientry
2341 integer(I4B),
intent(inout) :: n1
2342 integer(I4B),
intent(inout) :: n2
2343 real(DP),
intent(inout),
optional :: rrate
2344 real(DP),
intent(inout),
optional :: rhsval
2345 real(DP),
intent(inout),
optional :: hcofval
2350 if (
present(rrate)) rrate = this%qmfrommvr(n1)
2351 if (
present(rhsval)) rhsval = this%qmfrommvr(n1)
2352 if (
present(hcofval)) hcofval =
dzero
2363 integer(I4B),
intent(in) :: ientry
2364 integer(I4B),
intent(inout) :: n1
2365 integer(I4B),
intent(inout) :: n2
2366 real(DP),
intent(inout),
optional :: rrate
2367 real(DP),
intent(inout),
optional :: rhsval
2368 real(DP),
intent(inout),
optional :: hcofval
2373 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(ientry)
2374 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(ientry)
2375 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(ientry)
2377 ctmp = this%xnewpak(n1)
2379 ctmp = this%xnewpak(n2)
2381 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2382 if (
present(rhsval)) rhsval = -rrate * this%eqnsclfac
2383 if (
present(hcofval)) hcofval =
dzero
2394 integer(I4B) :: n, j
2397 if (this%iauxfpconc /= 0)
then
2400 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2403 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2404 this%flowpackagebnd%auxvar(this%iauxfpconc, j) = this%xnewpak(n)
2437 call this%pak_df_obs()
2452 call store_error(
'Program error: pak_df_obs not implemented.', &
2464 logical,
intent(inout) :: found
2468 call store_error(
'Program error: pak_rp_obs not implemented.', &
2483 character(len=*),
parameter :: fmterr = &
2484 "('Boundary ', a, ' for observation ', a, &
2485 &' is invalid in package ', a)"
2486 nn1 = obsrv%NodeNumber
2490 if (this%featname(j) == obsrv%FeatureName)
then
2492 call obsrv%AddObsIndex(j)
2495 if (.not. jfound)
then
2496 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2503 if (nn1 < 0 .or. nn1 > this%ncv)
then
2504 write (
errmsg,
'(7a, i0, a, i0, a)') &
2505 'Observation ', trim(obsrv%Name),
' of type ', &
2506 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2507 trim(this%packName),
' was assigned ID = ', nn1, &
2508 '. ID must be >= 1 and <= ', this%ncv,
'.'
2511 call obsrv%AddObsIndex(nn1)
2525 integer(I4B) :: iconn
2530 character(len=*),
parameter :: fmterr = &
2531 "('Boundary ', a, ' for observation ', a, &
2532 &' is invalid in package ', a)"
2533 nn1 = obsrv%NodeNumber
2536 do j = 1, budterm%nlist
2537 icv = budterm%id1(j)
2538 if (this%featname(icv) == obsrv%FeatureName)
then
2540 call obsrv%AddObsIndex(j)
2543 if (.not. jfound)
then
2544 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2551 if (nn1 < 0 .or. nn1 > this%ncv)
then
2552 write (
errmsg,
'(7a, i0, a, i0, a)') &
2553 'Observation ', trim(obsrv%Name),
' of type ', &
2554 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2555 trim(this%packName),
' was assigned ID = ', nn1, &
2556 '. ID must be >= 1 and <= ', this%ncv,
'.'
2559 iconn = obsrv%NodeNumber2
2560 do j = 1, budterm%nlist
2561 if (budterm%id1(j) == nn1)
then
2565 call obsrv%AddObsIndex(idx)
2569 if (idx < 1 .or. idx > budterm%nlist)
then
2570 write (
errmsg,
'(7a, i0, a, i0, a)') &
2571 'Observation ', trim(obsrv%Name),
' of type ', &
2572 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2573 trim(this%packName),
' specifies iconn = ', iconn, &
2574 ', but this is not a valid connection for ID ', nn1,
'.'
2576 else if (budterm%id1(idx) /= nn1)
then
2577 write (
errmsg,
'(7a, i0, a, i0, a)') &
2578 'Observation ', trim(obsrv%Name),
' of type ', &
2579 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2580 trim(this%packName),
' specifies iconn = ', iconn, &
2581 ', but this is not a valid connection for ID ', nn1,
'.'
2601 character(len=*),
parameter :: fmterr = &
2602 "('Boundary ', a, ' for observation ', a, &
2603 &' is invalid in package ', a)"
2604 nn1 = obsrv%NodeNumber
2607 do j = 1, budterm%nlist
2608 icv = budterm%id1(j)
2609 if (this%featname(icv) == obsrv%FeatureName)
then
2611 call obsrv%AddObsIndex(j)
2614 if (.not. jfound)
then
2615 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2622 if (nn1 < 0 .or. nn1 > this%ncv)
then
2623 write (
errmsg,
'(7a, i0, a, i0, a)') &
2624 'Observation ', trim(obsrv%Name),
' of type ', &
2625 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2626 trim(this%packName),
' was assigned ID = ', nn1, &
2627 '. ID must be >= 1 and <= ', this%ncv,
'.'
2630 nn2 = obsrv%NodeNumber2
2633 if (nn2 < 0 .or. nn2 > this%ncv)
then
2634 write (
errmsg,
'(7a, i0, a, i0, a)') &
2635 'Observation ', trim(obsrv%Name),
' of type ', &
2636 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2637 trim(this%packName),
' was assigned ID2 = ', nn2, &
2638 '. ID must be >= 1 and <= ', this%ncv,
'.'
2643 do j = 1, budterm%nlist
2644 if (budterm%id1(j) == nn1 .and. budterm%id2(j) == nn2)
then
2645 call obsrv%AddObsIndex(j)
2649 if (.not. jfound)
then
2650 write (
errmsg,
'(7a, i0, a, i0, a)') &
2651 'Observation ', trim(obsrv%Name),
' of type ', &
2652 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2653 trim(this%packName), &
2654 ' specifies a connection between feature ', nn1, &
2655 ' feature ', nn2,
', but these features are not connected.'
2676 do i = 1, this%obs%npakobs
2677 obsrv => this%obs%pakobs(i)%obsrv
2678 select case (obsrv%ObsTypeId)
2679 case (
'CONCENTRATION',
'TEMPERATURE')
2680 call this%rp_obs_byfeature(obsrv)
2684 if (obsrv%indxbnds_count > 1)
then
2685 write (
errmsg,
'(a, a, a, a)') &
2686 trim(adjustl(this%depvartype))// &
2687 ' for observation', trim(adjustl(obsrv%Name)), &
2688 ' must be assigned to a feature with a unique boundname.'
2691 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2692 call this%rp_obs_budterm(obsrv, &
2693 this%flowbudptr%budterm(this%idxbudgwf))
2694 case (
'FLOW-JA-FACE')
2695 if (this%idxbudfjf > 0)
then
2696 call this%rp_obs_flowjaface(obsrv, &
2697 this%flowbudptr%budterm(this%idxbudfjf))
2700 'Observation ', trim(obsrv%Name),
' of type ', &
2701 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2702 trim(this%packName), &
2703 ' cannot be processed because there are no flow connections.'
2707 call this%rp_obs_byfeature(obsrv)
2709 call this%rp_obs_byfeature(obsrv)
2711 call this%rp_obs_byfeature(obsrv)
2716 call this%pak_rp_obs(obsrv, found)
2719 if (.not. found)
then
2720 errmsg =
'Unrecognized observation type "'// &
2721 trim(obsrv%ObsTypeId)//
'" for '// &
2722 trim(adjustl(this%text))//
' package '// &
2749 integer(I4B) :: igwfnode
2760 if (this%obs%npakobs > 0)
then
2761 call this%obs%obs_bd_clear()
2762 do i = 1, this%obs%npakobs
2763 obsrv => this%obs%pakobs(i)%obsrv
2764 do j = 1, obsrv%indxbnds_count
2766 jj = obsrv%indxbnds(j)
2767 select case (obsrv%ObsTypeId)
2768 case (
'CONCENTRATION',
'TEMPERATURE')
2769 if (this%iboundpak(jj) /= 0)
then
2770 v = this%xnewpak(jj)
2772 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2773 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(jj)
2774 if (this%iboundpak(n) /= 0)
then
2775 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(jj)
2776 v = this%hcof(jj) * this%xnew(igwfnode) - this%rhs(jj)
2779 case (
'FLOW-JA-FACE')
2780 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(jj)
2781 if (this%iboundpak(n) /= 0)
then
2782 call this%apt_fjf_term(jj, n1, n2, v)
2785 if (this%iboundpak(jj) /= 0)
then
2789 if (this%iboundpak(jj) /= 0)
then
2793 if (this%iboundpak(jj) /= 0 .and. this%idxbudfmvr > 0)
then
2794 call this%apt_fmvr_term(jj, n1, n2, v)
2797 if (this%idxbudtmvr > 0)
then
2798 n = this%flowbudptr%budterm(this%idxbudtmvr)%id1(jj)
2799 if (this%iboundpak(n) /= 0)
then
2800 call this%apt_tmvr_term(jj, n1, n2, v)
2807 call this%pak_bd_obs(obsrv%ObsTypeId, jj, v, found)
2810 if (.not. found)
then
2811 errmsg =
'Unrecognized observation type "'// &
2812 trim(obsrv%ObsTypeId)//
'" for '// &
2813 trim(adjustl(this%text))//
' package '// &
2818 call this%obs%SaveOneSimval(obsrv, v)
2834 character(len=*),
intent(in) :: obstypeid
2835 integer(I4B),
intent(in) :: jj
2836 real(DP),
intent(inout) :: v
2837 logical,
intent(inout) :: found
2854 integer(I4B),
intent(in) :: inunitobs
2855 integer(I4B),
intent(in) :: iout
2858 integer(I4B) :: icol
2859 integer(I4B) :: istart
2860 integer(I4B) :: istop
2861 character(len=LINELENGTH) :: string
2862 character(len=LENBOUNDNAME) :: bndname
2865 string = obsrv%IDstring
2875 obsrv%FeatureName = bndname
2879 obsrv%NodeNumber = nn1
2884 obsrv%NodeNumber2 = 1
2897 integer(I4B),
intent(in) :: inunitobs
2898 integer(I4B),
intent(in) :: iout
2901 integer(I4B) :: iconn
2902 integer(I4B) :: icol
2903 integer(I4B) :: istart
2904 integer(I4B) :: istop
2905 character(len=LINELENGTH) :: string
2906 character(len=LENBOUNDNAME) :: bndname
2909 string = obsrv%IDstring
2919 obsrv%FeatureName = bndname
2922 if (len_trim(bndname) < 1 .and. iconn < 0)
then
2923 write (
errmsg,
'(a,1x,a,a,1x,a,1x,a)') &
2924 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
2925 ', ID given as an integer and not as boundname,', &
2926 'but ID2 is missing. Either change ID to valid', &
2927 'boundname or supply valid entry for ID2.'
2930 obsrv%NodeNumber2 = iconn
2934 obsrv%NodeNumber = nn1
2949 integer(I4B) :: nterms
2950 character(len=LINELENGTH) :: title
2951 character(len=LINELENGTH) :: text_temp
2954 if (this%iprconc > 0)
then
2958 if (this%inamedbound == 1) nterms = nterms + 1
2961 title = trim(adjustl(this%text))//
' PACKAGE ('// &
2962 trim(adjustl(this%packName))// &
2963 ') '//trim(adjustl(this%depvartype))// &
2964 &
' FOR EACH CONTROL VOLUME'
2967 call table_cr(this%dvtab, this%packName, title)
2968 call this%dvtab%table_df(this%ncv, nterms, this%iout, &
2972 if (this%inamedbound == 1)
then
2974 call this%dvtab%initialize_column(text_temp, 20, alignment=tableft)
2978 text_temp =
'NUMBER'
2979 call this%dvtab%initialize_column(text_temp, 10, alignment=tabcenter)
2982 text_temp = this%depvartype(1:4)
2983 call this%dvtab%initialize_column(text_temp, 12, alignment=tabcenter)
This module contains the base boundary package.
This module contains the BudgetModule.
subroutine, public budget_cr(this, name_model)
@ brief Create a new budget object
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
@ 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 namedboundflag
named bound flag
real(dp), parameter dnodata
real no data constant
real(dp), parameter dhnoflo
real no flow constant
real(dp), parameter dep20
real constant 1e20
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenftype
maximum length of a package type (DIS, WEL, OC, etc.)
integer(i4b), parameter lenauxname
maximum length of a aux variable
integer(i4b), parameter lenboundname
maximum length of a bound name
real(dp), parameter dzero
real constant zero
integer(i4b), parameter maxcharlen
maximum length of char string
integer(i4b), parameter lenbudtxt
maximum length of a budget component names
real(dp), parameter done
real constant 1
This module defines variable data types.
This module contains the derived types ObserveType and ObsDataType.
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 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
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).
subroutine apt_ot_bdsummary(this, kstp, kper, iout, ibudfl)
Print advanced package transport dependent variables.
subroutine apt_cfupdate(this)
Advanced package transport routine.
subroutine pak_setup_budobj(this, idx)
Set up a budget object that stores an advanced package flows.
subroutine apt_ar(this)
Advanced package transport allocate and read (ar) routine.
subroutine pak_fill_budobj(this, idx, x, flowja, ccratin, ccratout)
Copy flow terms into thisbudobj, must be overridden.
subroutine rp_obs_flowjaface(this, obsrv, budterm)
Prepare observation.
subroutine pak_set_stressperiod(this, itemno, keyword, found)
Advanced package transport set stress period routine.
subroutine pak_bd_obs(this, obstypeid, jj, v, found)
Check if observation exists in an advanced package.
subroutine apt_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
subroutine pak_fc_expanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
subroutine apt_fjf_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Go through each "within apt-apt" connection (e.g., lkt-lkt, or sft-sft) and accumulate total mass (or...
subroutine rp_obs_budterm(this, obsrv, budterm)
Prepare observation.
subroutine allocate_scalars(this)
@ brief Allocate scalars
subroutine apt_read_initial_attr(this)
Read the initial parameters for an advanced package.
subroutine apt_setup_budobj(this)
Set up the budget object that stores advanced package flow terms.
subroutine apt_allocate_index_arrays(this)
@ brief Allocate index arrays
subroutine apt_rp_obs(this)
Read and prepare apt-related observations.
character(len=lenvarname) text
subroutine apt_ot_package_flows(this, icbcfl, ibudfl)
Save advanced package flows routine.
real(dp) function, dimension(:), pointer, contiguous get_mvr_depvar(this)
Advanced package transport utility function.
subroutine get_volumes(this, icv, vnew, vold, delt)
Return the feature new volume and old volume.
subroutine apt_allocate_arrays(this)
@ brief Allocate arrays
integer(i4b) function pak_get_nbudterms(this)
Function to return the number of budget terms just for this package.
subroutine apt_set_stressperiod(this, itemno)
Advanced package transport set stress period routine.
subroutine apt_df_obs(this)
Define observation type.
character(len=lenftype) ftype
subroutine apt_fmvr_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Account for mass or energy transferred to this package from the MVR package.
subroutine apt_da(this)
@ brief Deallocate memory
subroutine apt_read_dimensions(this)
Determine dimensions for this advanced package.
subroutine apt_mc(this, moffset, matrix_sln)
Advanced package transport map package connections to matrix.
subroutine apt_fill_budobj(this, x, flowja)
Copy flow terms into thisbudobj.
subroutine pak_rp_obs(this, obsrv, found)
Process package specific obs.
logical function apt_obs_supported(this)
Determine whether an obs type is supported.
subroutine apt_read_cvs(this)
Read feature information for this advanced package.
subroutine apt_bd_obs(this)
Calculate observation values.
subroutine apt_solve(this)
Add terms specific to advanced package transport to the explicit solve.
subroutine apt_tmvr_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Account for mass or energy transferred to the MVR package.
subroutine apt_set_pointers(this, neq, ibound, xnew, xold, flowja)
Set pointers to model arrays and variables so that a package has access to these items.
subroutine apt_accumulate_ccterm(this, ilak, rrate, ccratin, ccratout)
Accumulate constant concentration (or temperature) terms for budget.
subroutine apt_setup_tableobj(this)
Setup a table object an advanced package.
subroutine find_apt_package(this)
Find corresponding advanced package transport package.
subroutine apt_rp(this)
Advanced package transport read and prepare (rp) routine.
subroutine apt_stor_term(this, ientry, n1, n2, rrate, rhsval, hcofval)
Account for mass or energy storage in advanced package features.
subroutine apt_options(this, option, found)
Set options specific to the TspAptType.
subroutine rp_obs_byfeature(this, obsrv)
Prepare observation.
subroutine apt_copy2flowp(this)
Copy concentrations (or temperatures) into flow package aux variable.
subroutine apt_cq(this, x, flowja, iadv)
Advanced package transport calculate flows (cq) routine.
subroutine apt_ac(this, moffset, sparse)
Add package connection to matrix.
subroutine, public apt_process_obsid(obsrv, dis, inunitobs, iout)
Process observation IDs for an advanced package.
subroutine apt_ad(this)
Advanced package transport routine.
integer(i4b) function apt_check_valid(this, itemno)
Advanced package transport routine.
subroutine apt_ad_chk(this)
subroutine define_listlabel(this)
Define the list heading that is written to iout when PRINT_INPUT option is used.
subroutine pak_solve(this)
Add terms specific to advanced package transport features to the explicit solve routine.
subroutine apt_fc_nonexpanded(this, rhs, ia, idxglo, matrix_sln)
Advanced package transport fill coefficient (fc) method.
subroutine apt_reset(this)
Override bnd reset for custom mover logic.
subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
subroutine apt_ot_dv(this, idvsave, idvprint)
subroutine pak_df_obs(this)
Define apt observation type.
subroutine, public apt_process_obsid12(obsrv, dis, inunitobs, iout)
Process observation IDs for a package.