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 integer(I4B),
dimension(:),
pointer,
contiguous :: idxlocnode => null()
83 integer(I4B),
dimension(:),
pointer,
contiguous :: idxpakdiag => null()
84 integer(I4B),
dimension(:),
pointer,
contiguous :: idxdglo => null()
85 integer(I4B),
dimension(:),
pointer,
contiguous :: idxoffdglo => null()
86 integer(I4B),
dimension(:),
pointer,
contiguous :: idxsymdglo => null()
87 integer(I4B),
dimension(:),
pointer,
contiguous :: idxsymoffdglo => null()
88 integer(I4B),
dimension(:),
pointer,
contiguous :: idxfjfdglo => null()
89 integer(I4B),
dimension(:),
pointer,
contiguous :: idxfjfoffdglo => null()
90 integer(I4B),
dimension(:),
pointer,
contiguous :: iboundpak => null()
91 real(dp),
dimension(:),
pointer,
contiguous :: xnewpak => null()
92 real(dp),
dimension(:),
pointer,
contiguous :: xoldpak => null()
93 real(dp),
dimension(:),
pointer,
contiguous :: dbuff => null()
94 character(len=LENBOUNDNAME), &
95 dimension(:),
pointer,
contiguous :: featname => null()
96 real(dp),
dimension(:),
pointer,
contiguous :: concfeat => null()
97 real(dp),
dimension(:, :),
pointer,
contiguous :: lauxvar => null()
99 real(dp),
dimension(:),
pointer,
contiguous :: qsto => null()
100 real(dp),
dimension(:),
pointer,
contiguous :: ccterm => null()
101 integer(I4B),
pointer :: idxbudfjf => null()
102 integer(I4B),
pointer :: idxbudgwf => null()
103 integer(I4B),
pointer :: idxbudsto => null()
104 integer(I4B),
pointer :: idxbudtmvr => null()
105 integer(I4B),
pointer :: idxbudfmvr => null()
106 integer(I4B),
pointer :: idxbudaux => null()
107 integer(I4B),
dimension(:),
pointer,
contiguous :: idxbudssm => null()
108 integer(I4B),
pointer :: nconcbudssm => null()
109 real(dp),
dimension(:, :),
pointer,
contiguous :: concbudssm => null()
110 real(dp),
dimension(:),
pointer,
contiguous :: qmfrommvr => null()
111 real(dp),
pointer :: eqnsclfac => null()
112 character(len=LENVARNAME) :: depvartype =
''
113 character(len=LENVARNAME) :: depvarunit =
''
114 character(len=LENVARNAME) :: depvarunitabbrev =
''
117 type(
bndtype),
pointer :: flowpackagebnd => null()
197 integer(I4B),
intent(in) :: moffset
201 integer(I4B) :: jj, jglo
206 if (this%imatrows /= 0)
then
210 nglo = moffset + this%dis%nodes + this%ioffset + n
211 call sparse%addconnection(nglo, nglo, 1)
215 do i = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
216 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(i)
217 jj = this%flowbudptr%budterm(this%idxbudgwf)%id2(i)
218 nglo = moffset + this%dis%nodes + this%ioffset + n
220 call sparse%addconnection(nglo, jglo, 1)
221 call sparse%addconnection(jglo, nglo, 1)
225 if (this%idxbudfjf /= 0)
then
226 do i = 1, this%flowbudptr%budterm(this%idxbudfjf)%maxlist
227 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(i)
228 jj = this%flowbudptr%budterm(this%idxbudfjf)%id2(i)
229 nglo = moffset + this%dis%nodes + this%ioffset + n
230 jglo = moffset + this%dis%nodes + this%ioffset + jj
231 call sparse%addconnection(nglo, jglo, 1)
239 subroutine apt_mc(this, moffset, matrix_sln)
243 integer(I4B),
intent(in) :: moffset
246 integer(I4B) :: n, j, iglo, jglo
251 call this%apt_allocate_index_arrays()
254 if (this%imatrows /= 0)
then
261 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
262 iglo = moffset + this%dis%nodes + this%ioffset + n
263 this%idxpakdiag(n) = matrix_sln%get_position_diag(iglo)
265 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
266 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
267 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
268 iglo = moffset + this%dis%nodes + this%ioffset + n
270 this%idxdglo(ipos) = matrix_sln%get_position_diag(iglo)
271 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
275 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
276 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
277 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
279 jglo = moffset + this%dis%nodes + this%ioffset + n
280 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
281 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
285 if (this%idxbudfjf /= 0)
then
286 do ipos = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
287 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(ipos)
288 j = this%flowbudptr%budterm(this%idxbudfjf)%id2(ipos)
289 iglo = moffset + this%dis%nodes + this%ioffset + n
290 jglo = moffset + this%dis%nodes + this%ioffset + j
291 this%idxfjfdglo(ipos) = matrix_sln%get_position_diag(iglo)
292 this%idxfjfoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
308 character(len=*),
parameter :: fmtapt = &
309 "(1x,/1x,'APT -- ADVANCED PACKAGE TRANSPORT, VERSION 1, 3/5/2020', &
310 &' INPUT READ FROM UNIT ', i0, //)"
313 call this%obs%obs_ar()
316 write (this%iout, fmtapt) this%inunit
319 call this%apt_allocate_arrays()
322 call this%read_initial_attr()
326 call this%fmi%get_package_index(this%flowpackagename, this%igwfaptpak)
331 this%fmi%iatp(this%igwfaptpak) = 1
332 this%fmi%datp(this%igwfaptpak)%concpack => this%get_mvr_depvar()
333 this%fmi%datp(this%igwfaptpak)%qmfrommvr => this%qmfrommvr
338 if (
associated(this%flowpackagebnd))
then
339 if (this%cauxfpconc /=
'')
then
341 do j = 1, this%flowpackagebnd%naux
342 if (this%flowpackagebnd%auxname(j) == this%cauxfpconc)
then
348 if (this%iauxfpconc == 0)
then
349 errmsg =
'Could not find auxiliary variable '// &
350 trim(adjustl(this%cauxfpconc))//
' in flow package '// &
351 trim(adjustl(this%flowpackagename))
353 call this%parser%StoreErrorUnit()
356 this%flowpackagebnd%noupdateauxvar(this%iauxfpconc) = 1
357 call this%apt_copy2flowp()
374 logical :: isfound, endOfBlock
375 character(len=LINELENGTH) :: title
376 character(len=LINELENGTH) :: line
377 integer(I4B) :: itemno
378 integer(I4B) :: igwfnode
380 character(len=*),
parameter :: fmtblkerr = &
381 &
"('Error. Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
382 character(len=*),
parameter :: fmtlsp = &
383 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
386 this%nbound = this%maxbound
390 if (this%inunit == 0)
return
393 if (this%ionper <
kper)
then
396 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
397 supportopenclose=.true., &
398 blockrequired=.false.)
402 call this%read_check_ionper()
408 this%ionper =
nper + 1
411 call this%parser%GetCurrentLine(line)
412 write (
errmsg, fmtblkerr) adjustl(trim(line))
414 call this%parser%StoreErrorUnit()
420 if (this%ionper ==
kper)
then
423 if (this%iprpak /= 0)
then
426 title = trim(adjustl(this%text))//
' PACKAGE ('// &
427 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
428 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
429 call table_cr(this%inputtab, this%packName, title)
430 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
432 call this%inputtab%initialize_column(
text, 10, alignment=
tabcenter)
434 call this%inputtab%initialize_column(
text, 20, alignment=
tableft)
436 write (
text,
'(a,1x,i6)')
'VALUE', n
437 call this%inputtab%initialize_column(
text, 15, alignment=
tabcenter)
443 call this%parser%GetNextLine(endofblock)
447 itemno = this%parser%GetInteger()
450 call this%apt_set_stressperiod(itemno)
453 if (this%iprpak /= 0)
then
454 call this%parser%GetCurrentLine(line)
455 call this%inputtab%line_to_columns(line)
459 if (this%iprpak /= 0)
then
460 call this%inputtab%finalize_table()
465 write (this%iout, fmtlsp) trim(this%filtyp)
471 call this%parser%StoreErrorUnit()
475 do n = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
476 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
477 this%nodelist(n) = igwfnode
497 integer(I4B),
intent(in) :: itemno
499 character(len=LINELENGTH) :: text
500 character(len=LINELENGTH) :: caux
501 character(len=LINELENGTH) :: keyword
505 real(DP),
pointer :: bndElem => null()
516 call this%parser%GetStringCaps(keyword)
517 select case (keyword)
519 ierr = this%apt_check_valid(itemno)
523 call this%parser%GetStringCaps(text)
524 this%status(itemno) = text(1:8)
525 if (text ==
'CONSTANT')
then
526 this%iboundpak(itemno) = -1
527 else if (text ==
'INACTIVE')
then
528 this%iboundpak(itemno) = 0
529 else if (text ==
'ACTIVE')
then
530 this%iboundpak(itemno) = 1
533 'Unknown '//trim(this%text)//
' status keyword: ', text//
'.'
536 case (
'CONCENTRATION',
'TEMPERATURE')
537 ierr = this%apt_check_valid(itemno)
541 call this%parser%GetString(text)
543 bndelem => this%concfeat(itemno)
545 this%packName,
'BND', this%tsManager, &
546 this%iprpak, this%depvartype)
548 ierr = this%apt_check_valid(itemno)
552 call this%parser%GetStringCaps(caux)
554 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
555 call this%parser%GetString(text)
557 bndelem => this%lauxvar(jj, ii)
559 this%packName,
'AUX', &
560 this%tsManager, this%iprpak, &
567 call this%pak_set_stressperiod(itemno, keyword, found)
570 if (.not. found)
then
572 'Unknown '//trim(adjustl(this%text))//
' data keyword: ', &
580 call this%parser%StoreErrorUnit()
592 integer(I4B),
intent(in) :: itemno
593 character(len=*),
intent(in) :: keyword
594 logical,
intent(inout) :: found
601 call store_error(
'Program error: pak_set_stressperiod not implemented.', &
614 integer(I4B),
intent(in) :: itemno
617 if (itemno < 1 .or. itemno > this%ncv)
then
618 write (
errmsg,
'(a,1x,i6,1x,a,1x,i6)') &
619 'Featureno ', itemno,
'must be > 0 and <= ', this%ncv
649 integer(I4B) :: j, iaux
652 call this%TsManager%ad()
657 if (this%naux > 0)
then
658 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
659 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
660 do iaux = 1, this%naux
661 this%auxvar(iaux, j) = this%lauxvar(iaux, n)
670 this%xoldpak(n) = this%xnewpak(n)
671 if (this%iboundpak(n) < 0)
then
672 this%xnewpak(n) = this%concfeat(n)
677 this%xnewpak(n) = this%xoldpak(n)
678 if (this%iboundpak(n) < 0)
then
679 this%xnewpak(n) = this%concfeat(n)
692 call this%obs%obs_ad()
695 call this%apt_ad_chk()
704 do i = 1,
size(this%qmfrommvr)
705 this%qmfrommvr(i) =
dzero
709 subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
713 real(DP),
dimension(:),
intent(inout) :: rhs
714 integer(I4B),
dimension(:),
intent(in) :: ia
715 integer(I4B),
dimension(:),
intent(in) :: idxglo
720 if (this%imatrows == 0)
then
721 call this%apt_fc_nonexpanded(rhs, ia, idxglo, matrix_sln)
723 call this%apt_fc_expanded(rhs, ia, idxglo, matrix_sln)
736 real(DP),
dimension(:),
intent(inout) :: rhs
737 integer(I4B),
dimension(:),
intent(in) :: ia
738 integer(I4B),
dimension(:),
intent(in) :: idxglo
741 integer(I4B) :: j, igwfnode, idiag
744 call this%apt_solve()
747 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
748 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
749 if (this%ibound(igwfnode) < 1) cycle
750 idiag = idxglo(ia(igwfnode))
751 call matrix_sln%add_value_pos(idiag, this%hcof(j))
752 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
765 real(DP),
dimension(:),
intent(inout) :: rhs
766 integer(I4B),
dimension(:),
intent(in) :: ia
767 integer(I4B),
dimension(:),
intent(in) :: idxglo
770 integer(I4B) :: j, n, n1, n2
772 integer(I4B) :: iposd, iposoffd
773 integer(I4B) :: ipossymd, ipossymoffd
775 real(DP) :: qbnd, qbnd_scaled
786 call this%pak_fc_expanded(rhs, ia, idxglo, matrix_sln)
790 cold = this%xoldpak(n)
791 iloc = this%idxlocnode(n)
792 iposd = this%idxpakdiag(n)
793 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
794 call matrix_sln%add_value_pos(iposd, hcofval)
795 rhs(iloc) = rhs(iloc) + rhsval
799 if (this%idxbudtmvr /= 0)
then
800 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
801 call this%apt_tmvr_term(j, n1, n2, rrate, rhsval, hcofval)
802 iloc = this%idxlocnode(n1)
803 iposd = this%idxpakdiag(n1)
804 call matrix_sln%add_value_pos(iposd, hcofval)
805 rhs(iloc) = rhs(iloc) + rhsval
810 if (this%idxbudfmvr /= 0)
then
812 rhsval = this%qmfrommvr(n)
813 iloc = this%idxlocnode(n)
814 rhs(iloc) = rhs(iloc) - rhsval
819 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
822 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
823 if (this%iboundpak(n) /= 0)
then
826 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
829 qbnd_scaled = qbnd * this%eqnsclfac
832 iposd = this%idxdglo(j)
833 iposoffd = this%idxoffdglo(j)
834 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
835 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
838 ipossymd = this%idxsymdglo(j)
839 ipossymoffd = this%idxsymoffdglo(j)
840 call matrix_sln%add_value_pos(ipossymd, -(
done - omega) * qbnd_scaled)
841 call matrix_sln%add_value_pos(ipossymoffd, -omega * qbnd_scaled)
846 if (this%idxbudfjf /= 0)
then
847 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
848 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(j)
849 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(j)
850 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(j)
851 if (qbnd <=
dzero)
then
856 qbnd_scaled = qbnd * this%eqnsclfac
857 iposd = this%idxfjfdglo(j)
858 iposoffd = this%idxfjfoffdglo(j)
859 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
860 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
874 real(DP),
dimension(:),
intent(inout) :: rhs
875 integer(I4B),
dimension(:),
intent(in) :: ia
876 integer(I4B),
dimension(:),
intent(in) :: idxglo
881 call store_error(
'Program error: pak_fc_expanded not implemented.', &
902 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
903 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
906 if (this%iboundpak(n) /= 0)
then
907 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
910 this%hcof(j) = -(
done - omega) * qbnd * this%eqnsclfac
911 this%rhs(j) = omega * qbnd * this%xnewpak(n) * this%eqnsclfac
924 real(DP),
dimension(:),
intent(in) :: x
925 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
926 integer(I4B),
optional,
intent(in) :: iadv
928 integer(I4B) :: n, n1, n2
933 if (this%imatrows == 0)
then
934 call this%apt_solve()
936 call this%apt_cfupdate()
940 call this%BndType%bnd_cq(x, flowja)
945 if (this%iboundpak(n) > 0)
then
946 call this%apt_stor_term(n, n1, n2, rrate)
952 call this%apt_copy2flowp()
955 call this%apt_fill_budobj(x, flowja)
963 integer(I4B),
intent(in) :: icbcfl
964 integer(I4B),
intent(in) :: ibudfl
965 integer(I4B) :: ibinun
969 if (this%ibudgetout /= 0)
then
970 ibinun = this%ibudgetout
972 if (icbcfl == 0) ibinun = 0
974 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
979 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
980 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
992 integer(I4B),
intent(in) :: idvsave
993 integer(I4B),
intent(in) :: idvprint
995 integer(I4B) :: ibinun
998 character(len=LENBUDTXT) :: text
1002 if (this%iconcout /= 0)
then
1003 ibinun = this%iconcout
1005 if (idvsave == 0) ibinun = 0
1008 if (ibinun > 0)
then
1011 if (this%iboundpak(n) == 0)
then
1016 write (text,
'(a)') str_pad_left(this%depvartype, lenvarname)
1018 this%ncv, 1, 1, ibinun)
1022 if (idvprint /= 0 .and. this%iprconc /= 0)
then
1025 call this%dvtab%set_kstpkper(
kstp,
kper)
1029 if (this%inamedbound == 1)
then
1030 call this%dvtab%add_term(this%featname(n))
1032 call this%dvtab%add_term(n)
1033 call this%dvtab%add_term(this%xnewpak(n))
1045 integer(I4B),
intent(in) :: kstp
1046 integer(I4B),
intent(in) :: kper
1047 integer(I4B),
intent(in) :: iout
1048 integer(I4B),
intent(in) :: ibudfl
1050 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
1065 call this%BndType%allocate_scalars()
1068 call mem_allocate(this%iauxfpconc,
'IAUXFPCONC', this%memoryPath)
1069 call mem_allocate(this%imatrows,
'IMATROWS', this%memoryPath)
1070 call mem_allocate(this%iprconc,
'IPRCONC', this%memoryPath)
1071 call mem_allocate(this%iconcout,
'ICONCOUT', this%memoryPath)
1072 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
1073 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
1074 call mem_allocate(this%igwfaptpak,
'IGWFAPTPAK', this%memoryPath)
1076 call mem_allocate(this%idxbudfjf,
'IDXBUDFJF', this%memoryPath)
1077 call mem_allocate(this%idxbudgwf,
'IDXBUDGWF', this%memoryPath)
1078 call mem_allocate(this%idxbudsto,
'IDXBUDSTO', this%memoryPath)
1079 call mem_allocate(this%idxbudtmvr,
'IDXBUDTMVR', this%memoryPath)
1080 call mem_allocate(this%idxbudfmvr,
'IDXBUDFMVR', this%memoryPath)
1081 call mem_allocate(this%idxbudaux,
'IDXBUDAUX', this%memoryPath)
1082 call mem_allocate(this%nconcbudssm,
'NCONCBUDSSM', this%memoryPath)
1083 call mem_allocate(this%idxprepak,
'IDXPREPAK', this%memoryPath)
1084 call mem_allocate(this%idxlastpak,
'IDXLASTPAK', this%memoryPath)
1101 this%nconcbudssm = 0
1121 if (this%imatrows /= 0)
then
1125 if (this%idxbudfjf /= 0)
then
1126 n = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1130 call mem_allocate(this%idxlocnode, this%ncv,
'IDXLOCNODE', &
1132 call mem_allocate(this%idxpakdiag, this%ncv,
'IDXPAKDIAG', &
1134 call mem_allocate(this%idxdglo, this%maxbound,
'IDXGLO', &
1136 call mem_allocate(this%idxoffdglo, this%maxbound,
'IDXOFFDGLO', &
1138 call mem_allocate(this%idxsymdglo, this%maxbound,
'IDXSYMDGLO', &
1140 call mem_allocate(this%idxsymoffdglo, this%maxbound,
'IDXSYMOFFDGLO', &
1144 call mem_allocate(this%idxfjfoffdglo, n,
'IDXFJFOFFDGLO', &
1157 call mem_allocate(this%idxsymoffdglo, 0,
'IDXSYMOFFDGLO', &
1161 call mem_allocate(this%idxfjfoffdglo, 0,
'IDXFJFOFFDGLO', &
1179 call this%BndType%allocate_arrays()
1184 if (this%iconcout > 0)
then
1185 call mem_allocate(this%dbuff, this%ncv,
'DBUFF', this%memoryPath)
1187 this%dbuff(n) =
dzero
1190 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
1194 allocate (this%status(this%ncv))
1197 call mem_allocate(this%concfeat, this%ncv,
'CONCFEAT', this%memoryPath)
1200 call mem_allocate(this%qsto, this%ncv,
'QSTO', this%memoryPath)
1201 call mem_allocate(this%ccterm, this%ncv,
'CCTERM', this%memoryPath)
1204 call mem_allocate(this%concbudssm, this%nconcbudssm, this%ncv, &
1205 'CONCBUDSSM', this%memoryPath)
1208 call mem_allocate(this%qmfrommvr, this%ncv,
'QMFROMMVR', this%memoryPath)
1212 this%status(n) =
'ACTIVE'
1213 this%qsto(n) =
dzero
1214 this%ccterm(n) =
dzero
1215 this%qmfrommvr(n) =
dzero
1216 this%concbudssm(:, n) =
dzero
1217 this%concfeat(n) =
dzero
1239 if (this%imatrows == 0)
then
1246 deallocate (this%status)
1247 deallocate (this%featname)
1250 call this%budobj%budgetobject_da()
1251 deallocate (this%budobj)
1252 nullify (this%budobj)
1255 if (this%iprconc > 0)
then
1256 call this%dvtab%table_da()
1257 deallocate (this%dvtab)
1258 nullify (this%dvtab)
1292 call this%BndType%bnd_da()
1305 call store_error(
'Program error: pak_solve not implemented.', &
1319 character(len=*),
intent(inout) :: option
1320 logical,
intent(inout) :: found
1322 character(len=MAXCHARLEN) :: fname, keyword
1324 character(len=*),
parameter :: fmtaptbin = &
1325 "(4x, a, 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, &
1326 &/4x, 'OPENED ON UNIT: ', I0)"
1329 select case (option)
1330 case (
'FLOW_PACKAGE_NAME')
1331 call this%parser%GetStringCaps(this%flowpackagename)
1332 write (this%iout,
'(4x,a)') &
1333 'THIS '//trim(adjustl(this%text))//
' PACKAGE CORRESPONDS TO A GWF &
1334 &PACKAGE WITH THE NAME '//trim(adjustl(this%flowpackagename))
1335 case (
'FLOW_PACKAGE_AUXILIARY_NAME')
1336 call this%parser%GetStringCaps(this%cauxfpconc)
1337 write (this%iout,
'(4x,a)') &
1338 'SIMULATED CONCENTRATIONS WILL BE COPIED INTO THE FLOW PACKAGE &
1339 &AUXILIARY VARIABLE WITH THE NAME '//trim(adjustl(this%cauxfpconc))
1340 case (
'DEV_NONEXPANDING_MATRIX')
1345 call this%parser%DevOpt()
1347 write (this%iout,
'(4x,a)') &
1348 trim(adjustl(this%text))// &
1349 ' WILL NOT ADD ADDITIONAL ROWS TO THE A MATRIX.'
1350 case (
'PRINT_CONCENTRATION',
'PRINT_TEMPERATURE')
1352 write (this%iout,
'(4x,a,1x,a,1x,a)') trim(adjustl(this%text))// &
1353 trim(adjustl(this%depvartype))//
'S WILL BE PRINTED TO LISTING &
1355 case (
'CONCENTRATION',
'TEMPERATURE')
1356 call this%parser%GetStringCaps(keyword)
1357 if (keyword ==
'FILEOUT')
then
1358 call this%parser%GetString(fname)
1360 call openfile(this%iconcout, this%iout, fname,
'DATA(BINARY)', &
1362 write (this%iout, fmtaptbin) &
1363 trim(adjustl(this%text)), trim(adjustl(this%depvartype)), &
1364 trim(fname), this%iconcout
1366 write (
errmsg,
"('Optional', 1x, a, 1X, 'keyword must &
1367 &be followed by FILEOUT')") this%depvartype
1371 call this%parser%GetStringCaps(keyword)
1372 if (keyword ==
'FILEOUT')
then
1373 call this%parser%GetString(fname)
1374 call assign_iounit(this%ibudgetout, this%inunit,
"BUDGET fileout")
1375 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
1377 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET', &
1378 trim(fname), this%ibudgetout
1380 call store_error(
'Optional BUDGET keyword must be followed by FILEOUT')
1383 call this%parser%GetStringCaps(keyword)
1384 if (keyword ==
'FILEOUT')
then
1385 call this%parser%GetString(fname)
1386 call assign_iounit(this%ibudcsv, this%inunit,
"BUDGETCSV fileout")
1387 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
1388 filstat_opt=
'REPLACE')
1389 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET CSV', &
1390 trim(fname), this%ibudcsv
1392 call store_error(
'Optional BUDGETCSV keyword must be followed by &
1408 integer(I4B) :: ierr
1412 if (this%flowpackagename ==
'')
then
1413 this%flowpackagename = this%packName
1414 write (this%iout,
'(4x,a)') &
1415 'THE FLOW PACKAGE NAME FOR '//trim(adjustl(this%text))//
' WAS NOT &
1416 &SPECIFIED. SETTING FLOW PACKAGE NAME TO '// &
1417 &trim(adjustl(this%flowpackagename))
1420 call this%find_apt_package()
1423 this%ncv = this%flowbudptr%ncv
1424 this%maxbound = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1425 this%nbound = this%maxbound
1426 write (this%iout,
'(a, a)')
'SETTING DIMENSIONS FOR PACKAGE ', this%packName
1427 write (this%iout,
'(2x,a,i0)')
'NUMBER OF CONTROL VOLUMES = ', this%ncv
1428 write (this%iout,
'(2x,a,i0)')
'MAXBOUND = ', this%maxbound
1429 write (this%iout,
'(2x,a,i0)')
'NBOUND = ', this%nbound
1430 if (this%imatrows /= 0)
then
1431 this%npakeq = this%ncv
1432 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1433 ' SOLVED AS PART OF GWT MATRIX EQUATIONS'
1435 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1436 ' SOLVED SEPARATELY FROM GWT MATRIX EQUATIONS '
1438 write (this%iout,
'(a, //)')
'DONE SETTING DIMENSIONS FOR '// &
1439 trim(adjustl(this%text))
1442 if (this%ncv < 0)
then
1444 'Number of control volumes could not be determined correctly.'
1455 call this%apt_read_cvs()
1459 call this%define_listlabel()
1462 call this%apt_setup_budobj()
1465 call this%apt_setup_tableobj()
1477 character(len=LINELENGTH) :: text
1478 character(len=LENBOUNDNAME) :: bndName, bndNameTemp
1479 character(len=9) :: cno
1480 character(len=50),
dimension(:),
allocatable :: caux
1481 integer(I4B) :: ierr
1482 logical :: isfound, endOfBlock
1484 integer(I4B) :: ii, jj
1485 integer(I4B) :: iaux
1486 integer(I4B) :: itmp
1487 integer(I4B) :: nlak
1488 integer(I4B) :: nconn
1489 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1490 real(DP),
pointer :: bndElem => null()
1496 call mem_allocate(this%strt, this%ncv,
'STRT', this%memoryPath)
1497 call mem_allocate(this%lauxvar, this%naux, this%ncv,
'LAUXVAR', &
1501 if (this%imatrows == 0)
then
1502 call mem_allocate(this%iboundpak, this%ncv,
'IBOUND', this%memoryPath)
1503 call mem_allocate(this%xnewpak, this%ncv,
'XNEWPAK', this%memoryPath)
1505 call mem_allocate(this%xoldpak, this%ncv,
'XOLDPAK', this%memoryPath)
1508 allocate (this%featname(this%ncv))
1512 this%strt(n) =
dep20
1513 this%lauxvar(:, n) =
dzero
1514 this%xoldpak(n) =
dep20
1515 if (this%imatrows == 0)
then
1516 this%iboundpak(n) = 1
1517 this%xnewpak(n) =
dep20
1522 if (this%naux > 0)
then
1523 allocate (caux(this%naux))
1527 allocate (nboundchk(this%ncv))
1533 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
1534 supportopenclose=.true.)
1538 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1543 call this%parser%GetNextLine(endofblock)
1544 if (endofblock)
exit
1545 n = this%parser%GetInteger()
1547 if (n < 1 .or. n > this%ncv)
then
1548 write (
errmsg,
'(a,1x,i6)') &
1549 'Itemno must be > 0 and <= ', this%ncv
1555 nboundchk(n) = nboundchk(n) + 1
1558 this%strt(n) = this%parser%GetDouble()
1561 do iaux = 1, this%naux
1562 call this%parser%GetString(caux(iaux))
1566 write (cno,
'(i9.9)') n
1567 bndname =
'Feature'//cno
1570 if (this%inamedbound /= 0)
then
1571 call this%parser%GetStringCaps(bndnametemp)
1572 if (bndnametemp /=
'')
then
1573 bndname = bndnametemp
1576 this%featname(n) = bndname
1580 do jj = 1, this%naux
1583 bndelem => this%lauxvar(jj, ii)
1585 this%packName,
'AUX', &
1586 this%tsManager, this%iprpak, &
1595 if (nboundchk(n) == 0)
then
1596 write (
errmsg,
'(a,1x,i0)')
'No data specified for feature', n
1598 else if (nboundchk(n) > 1)
then
1599 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1600 'Data for feature', n,
'specified', nboundchk(n),
'times'
1605 write (this%iout,
'(1x,a)') &
1606 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1608 call store_error(
'Required packagedata block not found.')
1613 call this%parser%StoreErrorUnit()
1617 if (this%naux > 0)
then
1622 deallocate (nboundchk)
1634 integer(I4B) :: j, n
1640 this%xnewpak(n) = this%strt(n)
1649 if (this%status(n) ==
'CONSTANT')
then
1650 this%iboundpak(n) = -1
1651 else if (this%status(n) ==
'INACTIVE')
then
1652 this%iboundpak(n) = 0
1653 else if (this%status(n) ==
'ACTIVE ')
then
1654 this%iboundpak(n) = 1
1659 if (this%inamedbound /= 0)
then
1660 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1661 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1662 this%boundname(j) = this%featname(n)
1667 call this%copy_boundname()
1681 integer(I4B) :: n, j, igwfnode
1682 integer(I4B) :: n1, n2
1685 real(DP) :: c1, qbnd
1686 real(DP) :: hcofval, rhsval
1690 this%dbuff(n) = dzero
1695 call this%pak_solve()
1698 if (this%idxbudtmvr /= 0)
then
1699 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
1700 call this%apt_tmvr_term(j, n1, n2, rrate)
1701 this%dbuff(n1) = this%dbuff(n1) + rrate
1706 if (this%idxbudfmvr /= 0)
then
1707 do n1 = 1,
size(this%qmfrommvr)
1708 rrate = this%qmfrommvr(n1)
1709 this%dbuff(n1) = this%dbuff(n1) + rrate
1715 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1716 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1717 this%hcof(j) = dzero
1719 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
1720 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
1721 if (qbnd <= dzero)
then
1722 ctmp = this%xnewpak(n)
1723 this%rhs(j) = qbnd * ctmp * this%eqnsclfac
1725 ctmp = this%xnew(igwfnode)
1726 this%hcof(j) = -qbnd * this%eqnsclfac
1728 c1 = qbnd * ctmp * this%eqnsclfac
1729 this%dbuff(n) = this%dbuff(n) + c1
1734 if (this%idxbudfjf /= 0)
then
1735 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
1736 call this%apt_fjf_term(j, n1, n2, rrate)
1738 this%dbuff(n1) = this%dbuff(n1) + c1
1744 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
1748 this%dbuff(n) = this%dbuff(n) - rhsval
1751 c1 = -this%dbuff(n) / hcofval
1752 if (this%iboundpak(n) > 0)
then
1753 this%xnewpak(n) = c1
1769 call store_error(
'Program error: pak_solve not implemented.', &
1778 integer(I4B),
intent(in) :: ilak
1779 real(DP),
intent(in) :: rrate
1780 real(DP),
intent(inout) :: ccratin
1781 real(DP),
intent(inout) :: ccratout
1787 if (this%iboundpak(ilak) < 0)
then
1789 this%ccterm(ilak) = this%ccterm(ilak) + q
1795 ccratout = ccratout - q
1799 ccratin = ccratin + q
1811 this%listlabel = trim(this%filtyp)//
' NO.'
1812 if (this%dis%ndim == 3)
then
1813 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1814 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
1815 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
1816 elseif (this%dis%ndim == 2)
then
1817 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1818 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
1820 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
1822 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
1823 if (this%inamedbound == 1)
then
1824 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
1833 integer(I4B),
pointer :: neq
1834 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
1835 real(DP),
dimension(:),
pointer,
contiguous :: xnew
1836 real(DP),
dimension(:),
pointer,
contiguous :: xold
1837 real(DP),
dimension(:),
pointer,
contiguous :: flowja
1839 integer(I4B) :: istart, iend
1842 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
1847 if (this%imatrows /= 0)
then
1848 istart = this%dis%nodes + this%ioffset + 1
1849 iend = istart + this%ncv - 1
1850 this%iboundpak => this%ibound(istart:iend)
1851 this%xnewpak => this%xnew(istart:iend)
1861 integer(I4B),
intent(in) :: icv
1862 real(DP),
intent(inout) :: vnew, vold
1863 real(DP),
intent(in) :: delt
1870 if (this%idxbudsto /= 0)
then
1871 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1872 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1873 vold = vnew + qss * delt
1886 integer(I4B) :: nbudterms
1890 call store_error(
'Program error: pak_get_nbudterms not implemented.', &
1903 integer(I4B) :: nbudterm
1904 integer(I4B) :: nlen
1905 integer(I4B) :: n, n1, n2
1906 integer(I4B) :: maxlist, naux
1908 logical :: ordered_id1
1910 character(len=LENBUDTXT) :: bddim_opt
1911 character(len=LENBUDTXT) :: text, textt
1912 character(len=LENBUDTXT),
dimension(1) :: auxtxt
1919 if (this%idxbudfjf /= 0)
then
1920 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1927 if (this%idxbudfjf /= 0) nbudterm = nbudterm + 1
1930 nbudterm = nbudterm + 3
1933 nbudterm = nbudterm + this%pak_get_nbudterms()
1936 if (this%idxbudtmvr /= 0) nbudterm = nbudterm + 1
1937 if (this%idxbudfmvr /= 0) nbudterm = nbudterm + 1
1938 if (this%naux > 0) nbudterm = nbudterm + 1
1943 bddim_opt = this%depvarunitabbrev
1944 call this%budobj%budgetobject_df(this%ncv, nbudterm, 0, 0, &
1945 bddim_opt=bddim_opt, ibudcsv=this%ibudcsv)
1950 text =
' FLOW-JA-FACE'
1952 maxlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1954 ordered_id1 = this%flowbudptr%budterm(this%idxbudfjf)%ordered_id1
1955 call this%budobj%budterm(idx)%initialize(text, &
1960 maxlist, .false., .false., &
1961 naux, ordered_id1=ordered_id1)
1964 call this%budobj%budterm(idx)%reset(maxlist)
1967 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(n)
1968 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(n)
1969 call this%budobj%budterm(idx)%update_term(n1, n2, q)
1976 maxlist = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1978 call this%budobj%budterm(idx)%initialize(text, &
1983 maxlist, .false., .true., &
1985 call this%budobj%budterm(idx)%reset(maxlist)
1988 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(n)
1989 n2 = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
1990 call this%budobj%budterm(idx)%update_term(n1, n2, q)
1994 this%idxprepak = idx
1995 call this%pak_setup_budobj(idx)
1996 this%idxlastpak = idx
2001 maxlist = this%flowbudptr%budterm(this%idxbudsto)%maxlist
2005 call this%budobj%budterm(idx)%initialize(text, &
2010 maxlist, .false., .false., &
2012 if (this%idxbudtmvr /= 0)
then
2017 maxlist = this%flowbudptr%budterm(this%idxbudtmvr)%maxlist
2019 ordered_id1 = this%flowbudptr%budterm(this%idxbudtmvr)%ordered_id1
2020 call this%budobj%budterm(idx)%initialize(text, &
2025 maxlist, .false., .false., &
2026 naux, ordered_id1=ordered_id1)
2028 if (this%idxbudfmvr /= 0)
then
2035 call this%budobj%budterm(idx)%initialize(text, &
2040 maxlist, .false., .false., &
2049 call this%budobj%budterm(idx)%initialize(text, &
2054 maxlist, .false., .false., &
2066 call this%budobj%budterm(idx)%initialize(text, &
2071 maxlist, .false., .false., &
2076 if (this%iprflow /= 0)
then
2077 call this%budobj%flowtable_df(this%iout)
2089 integer(I4B),
intent(inout) :: idx
2093 call store_error(
'Program error: pak_setup_budobj not implemented.', &
2104 real(DP),
dimension(:),
intent(in) :: x
2105 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2107 integer(I4B) :: naux
2108 real(DP),
dimension(:),
allocatable :: auxvartmp
2109 integer(I4B) :: i, j, n1, n2
2111 integer(I4B) :: nlen
2112 integer(I4B) :: nlist
2113 integer(I4B) :: igwfnode
2116 real(DP) :: ccratin, ccratout
2127 this%ccterm(n1) =
dzero
2132 if (this%idxbudfjf /= 0)
then
2133 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2137 nlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2138 call this%budobj%budterm(idx)%reset(nlist)
2141 call this%apt_fjf_term(j, n1, n2, q)
2142 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2143 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2149 call this%budobj%budterm(idx)%reset(this%maxbound)
2150 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2152 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2153 if (this%iboundpak(n1) /= 0)
then
2154 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
2155 q = this%hcof(j) * x(igwfnode) - this%rhs(j)
2158 call this%budobj%budterm(idx)%update_term(n1, igwfnode, q)
2159 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2164 idx = this%idxlastpak
2168 call this%budobj%budterm(idx)%reset(this%ncv)
2169 allocate (auxvartmp(1))
2171 call this%get_volumes(n1, v1, v0,
delt)
2172 auxvartmp(1) = v1 * this%xnewpak(n1)
2174 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2175 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2177 deallocate (auxvartmp)
2180 if (this%idxbudtmvr /= 0)
then
2182 nlist = this%flowbudptr%budterm(this%idxbudtmvr)%nlist
2183 call this%budobj%budterm(idx)%reset(nlist)
2185 call this%apt_tmvr_term(j, n1, n2, q)
2186 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2187 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2192 if (this%idxbudfmvr /= 0)
then
2195 call this%budobj%budterm(idx)%reset(nlist)
2197 call this%apt_fmvr_term(j, n1, n2, q)
2198 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2199 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2205 call this%budobj%budterm(idx)%reset(this%ncv)
2208 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2215 allocate (auxvartmp(naux))
2216 call this%budobj%budterm(idx)%reset(this%ncv)
2220 auxvartmp(i) = this%lauxvar(i, n1)
2222 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2224 deallocate (auxvartmp)
2228 idx = this%idxprepak
2229 call this%pak_fill_budobj(idx, x, flowja, ccratin, ccratout)
2232 call this%budobj%accumulate_terms()
2241 integer(I4B),
intent(inout) :: idx
2242 real(DP),
dimension(:),
intent(in) :: x
2243 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2244 real(DP),
intent(inout) :: ccratin
2245 real(DP),
intent(inout) :: ccratout
2250 call store_error(
'Program error: pak_fill_budobj not implemented.', &
2260 integer(I4B),
intent(in) :: ientry
2261 integer(I4B),
intent(inout) :: n1
2262 integer(I4B),
intent(inout) :: n2
2263 real(DP),
intent(inout),
optional :: rrate
2264 real(DP),
intent(inout),
optional :: rhsval
2265 real(DP),
intent(inout),
optional :: hcofval
2271 call this%get_volumes(n1, v1, v0,
delt)
2272 c0 = this%xoldpak(n1)
2273 c1 = this%xnewpak(n1)
2274 if (
present(rrate))
then
2275 rrate = (-c1 * v1 /
delt + c0 * v0 /
delt) * this%eqnsclfac
2277 if (
present(rhsval)) rhsval = -c0 * v0 * this%eqnsclfac /
delt
2278 if (
present(hcofval)) hcofval = -v1 * this%eqnsclfac /
delt
2288 integer(I4B),
intent(in) :: ientry
2289 integer(I4B),
intent(inout) :: n1
2290 integer(I4B),
intent(inout) :: n2
2291 real(DP),
intent(inout),
optional :: rrate
2292 real(DP),
intent(inout),
optional :: rhsval
2293 real(DP),
intent(inout),
optional :: hcofval
2299 n1 = this%flowbudptr%budterm(this%idxbudtmvr)%id1(ientry)
2300 n2 = this%flowbudptr%budterm(this%idxbudtmvr)%id2(ientry)
2301 qbnd = this%flowbudptr%budterm(this%idxbudtmvr)%flow(ientry)
2302 ctmp = this%xnewpak(n1)
2303 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2304 if (
present(rhsval)) rhsval =
dzero
2305 if (
present(hcofval)) hcofval = qbnd * this%eqnsclfac
2316 integer(I4B),
intent(in) :: ientry
2317 integer(I4B),
intent(inout) :: n1
2318 integer(I4B),
intent(inout) :: n2
2319 real(DP),
intent(inout),
optional :: rrate
2320 real(DP),
intent(inout),
optional :: rhsval
2321 real(DP),
intent(inout),
optional :: hcofval
2326 if (
present(rrate)) rrate = this%qmfrommvr(n1)
2327 if (
present(rhsval)) rhsval = this%qmfrommvr(n1)
2328 if (
present(hcofval)) hcofval =
dzero
2339 integer(I4B),
intent(in) :: ientry
2340 integer(I4B),
intent(inout) :: n1
2341 integer(I4B),
intent(inout) :: n2
2342 real(DP),
intent(inout),
optional :: rrate
2343 real(DP),
intent(inout),
optional :: rhsval
2344 real(DP),
intent(inout),
optional :: hcofval
2349 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(ientry)
2350 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(ientry)
2351 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(ientry)
2353 ctmp = this%xnewpak(n1)
2355 ctmp = this%xnewpak(n2)
2357 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2358 if (
present(rhsval)) rhsval = -rrate * this%eqnsclfac
2359 if (
present(hcofval)) hcofval =
dzero
2370 integer(I4B) :: n, j
2373 if (this%iauxfpconc /= 0)
then
2376 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2379 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2380 this%flowpackagebnd%auxvar(this%iauxfpconc, j) = this%xnewpak(n)
2413 call this%pak_df_obs()
2428 call store_error(
'Program error: pak_df_obs not implemented.', &
2440 logical,
intent(inout) :: found
2444 call store_error(
'Program error: pak_rp_obs not implemented.', &
2459 character(len=*),
parameter :: fmterr = &
2460 "('Boundary ', a, ' for observation ', a, &
2461 &' is invalid in package ', a)"
2462 nn1 = obsrv%NodeNumber
2466 if (this%featname(j) == obsrv%FeatureName)
then
2468 call obsrv%AddObsIndex(j)
2471 if (.not. jfound)
then
2472 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2479 if (nn1 < 0 .or. nn1 > this%ncv)
then
2480 write (
errmsg,
'(7a, i0, a, i0, a)') &
2481 'Observation ', trim(obsrv%Name),
' of type ', &
2482 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2483 trim(this%packName),
' was assigned ID = ', nn1, &
2484 '. ID must be >= 1 and <= ', this%ncv,
'.'
2487 call obsrv%AddObsIndex(nn1)
2501 integer(I4B) :: iconn
2506 character(len=*),
parameter :: fmterr = &
2507 "('Boundary ', a, ' for observation ', a, &
2508 &' is invalid in package ', a)"
2509 nn1 = obsrv%NodeNumber
2512 do j = 1, budterm%nlist
2513 icv = budterm%id1(j)
2514 if (this%featname(icv) == obsrv%FeatureName)
then
2516 call obsrv%AddObsIndex(j)
2519 if (.not. jfound)
then
2520 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2527 if (nn1 < 0 .or. nn1 > this%ncv)
then
2528 write (
errmsg,
'(7a, i0, a, i0, a)') &
2529 'Observation ', trim(obsrv%Name),
' of type ', &
2530 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2531 trim(this%packName),
' was assigned ID = ', nn1, &
2532 '. ID must be >= 1 and <= ', this%ncv,
'.'
2535 iconn = obsrv%NodeNumber2
2536 do j = 1, budterm%nlist
2537 if (budterm%id1(j) == nn1)
then
2541 call obsrv%AddObsIndex(idx)
2545 if (idx < 1 .or. idx > budterm%nlist)
then
2546 write (
errmsg,
'(7a, i0, a, i0, a)') &
2547 'Observation ', trim(obsrv%Name),
' of type ', &
2548 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2549 trim(this%packName),
' specifies iconn = ', iconn, &
2550 ', but this is not a valid connection for ID ', nn1,
'.'
2552 else if (budterm%id1(idx) /= nn1)
then
2553 write (
errmsg,
'(7a, i0, a, i0, a)') &
2554 'Observation ', trim(obsrv%Name),
' of type ', &
2555 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2556 trim(this%packName),
' specifies iconn = ', iconn, &
2557 ', but this is not a valid connection for ID ', nn1,
'.'
2577 character(len=*),
parameter :: fmterr = &
2578 "('Boundary ', a, ' for observation ', a, &
2579 &' is invalid in package ', a)"
2580 nn1 = obsrv%NodeNumber
2583 do j = 1, budterm%nlist
2584 icv = budterm%id1(j)
2585 if (this%featname(icv) == obsrv%FeatureName)
then
2587 call obsrv%AddObsIndex(j)
2590 if (.not. jfound)
then
2591 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2598 if (nn1 < 0 .or. nn1 > this%ncv)
then
2599 write (
errmsg,
'(7a, i0, a, i0, a)') &
2600 'Observation ', trim(obsrv%Name),
' of type ', &
2601 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2602 trim(this%packName),
' was assigned ID = ', nn1, &
2603 '. ID must be >= 1 and <= ', this%ncv,
'.'
2606 nn2 = obsrv%NodeNumber2
2609 if (nn2 < 0 .or. nn2 > this%ncv)
then
2610 write (
errmsg,
'(7a, i0, a, i0, a)') &
2611 'Observation ', trim(obsrv%Name),
' of type ', &
2612 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2613 trim(this%packName),
' was assigned ID2 = ', nn2, &
2614 '. ID must be >= 1 and <= ', this%ncv,
'.'
2619 do j = 1, budterm%nlist
2620 if (budterm%id1(j) == nn1 .and. budterm%id2(j) == nn2)
then
2621 call obsrv%AddObsIndex(j)
2625 if (.not. jfound)
then
2626 write (
errmsg,
'(7a, i0, a, i0, a)') &
2627 'Observation ', trim(obsrv%Name),
' of type ', &
2628 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2629 trim(this%packName), &
2630 ' specifies a connection between feature ', nn1, &
2631 ' feature ', nn2,
', but these features are not connected.'
2652 do i = 1, this%obs%npakobs
2653 obsrv => this%obs%pakobs(i)%obsrv
2654 select case (obsrv%ObsTypeId)
2655 case (
'CONCENTRATION',
'TEMPERATURE')
2656 call this%rp_obs_byfeature(obsrv)
2660 if (obsrv%indxbnds_count > 1)
then
2661 write (
errmsg,
'(a, a, a, a)') &
2662 trim(adjustl(this%depvartype))// &
2663 ' for observation', trim(adjustl(obsrv%Name)), &
2664 ' must be assigned to a feature with a unique boundname.'
2667 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2668 call this%rp_obs_budterm(obsrv, &
2669 this%flowbudptr%budterm(this%idxbudgwf))
2670 case (
'FLOW-JA-FACE')
2671 if (this%idxbudfjf > 0)
then
2672 call this%rp_obs_flowjaface(obsrv, &
2673 this%flowbudptr%budterm(this%idxbudfjf))
2676 'Observation ', trim(obsrv%Name),
' of type ', &
2677 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2678 trim(this%packName), &
2679 ' cannot be processed because there are no flow connections.'
2683 call this%rp_obs_byfeature(obsrv)
2685 call this%rp_obs_byfeature(obsrv)
2687 call this%rp_obs_byfeature(obsrv)
2692 call this%pak_rp_obs(obsrv, found)
2695 if (.not. found)
then
2696 errmsg =
'Unrecognized observation type "'// &
2697 trim(obsrv%ObsTypeId)//
'" for '// &
2698 trim(adjustl(this%text))//
' package '// &
2725 integer(I4B) :: igwfnode
2736 if (this%obs%npakobs > 0)
then
2737 call this%obs%obs_bd_clear()
2738 do i = 1, this%obs%npakobs
2739 obsrv => this%obs%pakobs(i)%obsrv
2740 do j = 1, obsrv%indxbnds_count
2742 jj = obsrv%indxbnds(j)
2743 select case (obsrv%ObsTypeId)
2744 case (
'CONCENTRATION',
'TEMPERATURE')
2745 if (this%iboundpak(jj) /= 0)
then
2746 v = this%xnewpak(jj)
2748 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2749 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(jj)
2750 if (this%iboundpak(n) /= 0)
then
2751 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(jj)
2752 v = this%hcof(jj) * this%xnew(igwfnode) - this%rhs(jj)
2755 case (
'FLOW-JA-FACE')
2756 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(jj)
2757 if (this%iboundpak(n) /= 0)
then
2758 call this%apt_fjf_term(jj, n1, n2, v)
2761 if (this%iboundpak(jj) /= 0)
then
2765 if (this%iboundpak(jj) /= 0)
then
2769 if (this%iboundpak(jj) /= 0 .and. this%idxbudfmvr > 0)
then
2770 call this%apt_fmvr_term(jj, n1, n2, v)
2773 if (this%idxbudtmvr > 0)
then
2774 n = this%flowbudptr%budterm(this%idxbudtmvr)%id1(jj)
2775 if (this%iboundpak(n) /= 0)
then
2776 call this%apt_tmvr_term(jj, n1, n2, v)
2783 call this%pak_bd_obs(obsrv%ObsTypeId, jj, v, found)
2786 if (.not. found)
then
2787 errmsg =
'Unrecognized observation type "'// &
2788 trim(obsrv%ObsTypeId)//
'" for '// &
2789 trim(adjustl(this%text))//
' package '// &
2794 call this%obs%SaveOneSimval(obsrv, v)
2810 character(len=*),
intent(in) :: obstypeid
2811 integer(I4B),
intent(in) :: jj
2812 real(DP),
intent(inout) :: v
2813 logical,
intent(inout) :: found
2830 integer(I4B),
intent(in) :: inunitobs
2831 integer(I4B),
intent(in) :: iout
2834 integer(I4B) :: icol
2835 integer(I4B) :: istart
2836 integer(I4B) :: istop
2837 character(len=LINELENGTH) :: string
2838 character(len=LENBOUNDNAME) :: bndname
2841 string = obsrv%IDstring
2851 obsrv%FeatureName = bndname
2855 obsrv%NodeNumber = nn1
2860 obsrv%NodeNumber2 = 1
2873 integer(I4B),
intent(in) :: inunitobs
2874 integer(I4B),
intent(in) :: iout
2877 integer(I4B) :: iconn
2878 integer(I4B) :: icol
2879 integer(I4B) :: istart
2880 integer(I4B) :: istop
2881 character(len=LINELENGTH) :: string
2882 character(len=LENBOUNDNAME) :: bndname
2885 string = obsrv%IDstring
2895 obsrv%FeatureName = bndname
2898 if (len_trim(bndname) < 1 .and. iconn < 0)
then
2899 write (
errmsg,
'(a,1x,a,a,1x,a,1x,a)') &
2900 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
2901 ', ID given as an integer and not as boundname,', &
2902 'but ID2 is missing. Either change ID to valid', &
2903 'boundname or supply valid entry for ID2.'
2906 obsrv%NodeNumber2 = iconn
2910 obsrv%NodeNumber = nn1
2925 integer(I4B) :: nterms
2926 character(len=LINELENGTH) :: title
2927 character(len=LINELENGTH) :: text_temp
2930 if (this%iprconc > 0)
then
2934 if (this%inamedbound == 1) nterms = nterms + 1
2937 title = trim(adjustl(this%text))//
' PACKAGE ('// &
2938 trim(adjustl(this%packName))// &
2939 ') '//trim(adjustl(this%depvartype))// &
2940 &
' FOR EACH CONTROL VOLUME'
2943 call table_cr(this%dvtab, this%packName, title)
2944 call this%dvtab%table_df(this%ncv, nterms, this%iout, &
2948 if (this%inamedbound == 1)
then
2950 call this%dvtab%initialize_column(text_temp, 20, alignment=tableft)
2954 text_temp =
'NUMBER'
2955 call this%dvtab%initialize_column(text_temp, 10, alignment=tabcenter)
2958 text_temp = this%depvartype(1:4)
2959 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.