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()
198 integer(I4B),
intent(in) :: moffset
202 integer(I4B) :: jj, jglo
207 if (this%imatrows /= 0)
then
211 nglo = moffset + this%dis%nodes + this%ioffset + n
212 call sparse%addconnection(nglo, nglo, 1)
216 do i = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
217 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(i)
218 jj = this%flowbudptr%budterm(this%idxbudgwf)%id2(i)
219 nglo = moffset + this%dis%nodes + this%ioffset + n
221 call sparse%addconnection(nglo, jglo, 1)
222 call sparse%addconnection(jglo, nglo, 1)
226 if (this%idxbudfjf /= 0)
then
227 do i = 1, this%flowbudptr%budterm(this%idxbudfjf)%maxlist
228 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(i)
229 jj = this%flowbudptr%budterm(this%idxbudfjf)%id2(i)
230 nglo = moffset + this%dis%nodes + this%ioffset + n
231 jglo = moffset + this%dis%nodes + this%ioffset + jj
232 call sparse%addconnection(nglo, jglo, 1)
243 subroutine apt_mc(this, moffset, matrix_sln)
247 integer(I4B),
intent(in) :: moffset
250 integer(I4B) :: n, j, iglo, jglo
255 call this%apt_allocate_index_arrays()
258 if (this%imatrows /= 0)
then
265 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
266 iglo = moffset + this%dis%nodes + this%ioffset + n
267 this%idxpakdiag(n) = matrix_sln%get_position_diag(iglo)
269 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
270 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
271 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
272 iglo = moffset + this%dis%nodes + this%ioffset + n
274 this%idxdglo(ipos) = matrix_sln%get_position_diag(iglo)
275 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
279 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
280 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
281 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
283 jglo = moffset + this%dis%nodes + this%ioffset + n
284 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
285 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
289 if (this%idxbudfjf /= 0)
then
290 do ipos = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
291 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(ipos)
292 j = this%flowbudptr%budterm(this%idxbudfjf)%id2(ipos)
293 iglo = moffset + this%dis%nodes + this%ioffset + n
294 jglo = moffset + this%dis%nodes + this%ioffset + j
295 this%idxfjfdglo(ipos) = matrix_sln%get_position_diag(iglo)
296 this%idxfjfoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
315 character(len=*),
parameter :: fmtapt = &
316 "(1x,/1x,'APT -- ADVANCED PACKAGE TRANSPORT, VERSION 1, 3/5/2020', &
317 &' INPUT READ FROM UNIT ', i0, //)"
320 call this%obs%obs_ar()
323 write (this%iout, fmtapt) this%inunit
326 call this%apt_allocate_arrays()
329 call this%read_initial_attr()
333 call this%fmi%get_package_index(this%flowpackagename, this%igwfaptpak)
338 this%fmi%iatp(this%igwfaptpak) = 1
339 this%fmi%datp(this%igwfaptpak)%concpack => this%get_mvr_depvar()
340 this%fmi%datp(this%igwfaptpak)%qmfrommvr => this%qmfrommvr
345 if (
associated(this%flowpackagebnd))
then
346 if (this%cauxfpconc /=
'')
then
348 do j = 1, this%flowpackagebnd%naux
349 if (this%flowpackagebnd%auxname(j) == this%cauxfpconc)
then
355 if (this%iauxfpconc == 0)
then
356 errmsg =
'Could not find auxiliary variable '// &
357 trim(adjustl(this%cauxfpconc))//
' in flow package '// &
358 trim(adjustl(this%flowpackagename))
360 call this%parser%StoreErrorUnit()
363 this%flowpackagebnd%noupdateauxvar(this%iauxfpconc) = 1
364 call this%apt_copy2flowp()
384 logical :: isfound, endOfBlock
385 character(len=LINELENGTH) :: title
386 character(len=LINELENGTH) :: line
387 integer(I4B) :: itemno
388 integer(I4B) :: igwfnode
390 character(len=*),
parameter :: fmtblkerr = &
391 &
"('Error. Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
392 character(len=*),
parameter :: fmtlsp = &
393 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
396 this%nbound = this%maxbound
400 if (this%inunit == 0)
return
403 if (this%ionper <
kper)
then
406 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
407 supportopenclose=.true., &
408 blockrequired=.false.)
412 call this%read_check_ionper()
418 this%ionper =
nper + 1
421 call this%parser%GetCurrentLine(line)
422 write (
errmsg, fmtblkerr) adjustl(trim(line))
424 call this%parser%StoreErrorUnit()
430 if (this%ionper ==
kper)
then
433 if (this%iprpak /= 0)
then
436 title = trim(adjustl(this%text))//
' PACKAGE ('// &
437 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
438 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
439 call table_cr(this%inputtab, this%packName, title)
440 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
442 call this%inputtab%initialize_column(
text, 10, alignment=
tabcenter)
444 call this%inputtab%initialize_column(
text, 20, alignment=
tableft)
446 write (
text,
'(a,1x,i6)')
'VALUE', n
447 call this%inputtab%initialize_column(
text, 15, alignment=
tabcenter)
453 call this%parser%GetNextLine(endofblock)
457 itemno = this%parser%GetInteger()
460 call this%apt_set_stressperiod(itemno)
463 if (this%iprpak /= 0)
then
464 call this%parser%GetCurrentLine(line)
465 call this%inputtab%line_to_columns(line)
469 if (this%iprpak /= 0)
then
470 call this%inputtab%finalize_table()
475 write (this%iout, fmtlsp) trim(this%filtyp)
481 call this%parser%StoreErrorUnit()
485 do n = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
486 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
487 this%nodelist(n) = igwfnode
504 integer(I4B),
intent(in) :: itemno
506 character(len=LINELENGTH) :: text
507 character(len=LINELENGTH) :: caux
508 character(len=LINELENGTH) :: keyword
512 real(DP),
pointer :: bndElem => null()
523 call this%parser%GetStringCaps(keyword)
524 select case (keyword)
526 ierr = this%apt_check_valid(itemno)
530 call this%parser%GetStringCaps(text)
531 this%status(itemno) = text(1:8)
532 if (text ==
'CONSTANT')
then
533 this%iboundpak(itemno) = -1
534 else if (text ==
'INACTIVE')
then
535 this%iboundpak(itemno) = 0
536 else if (text ==
'ACTIVE')
then
537 this%iboundpak(itemno) = 1
540 'Unknown '//trim(this%text)//
' status keyword: ', text//
'.'
543 case (
'CONCENTRATION',
'TEMPERATURE')
544 ierr = this%apt_check_valid(itemno)
548 call this%parser%GetString(text)
550 bndelem => this%concfeat(itemno)
552 this%packName,
'BND', this%tsManager, &
553 this%iprpak, this%depvartype)
555 ierr = this%apt_check_valid(itemno)
559 call this%parser%GetStringCaps(caux)
561 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
562 call this%parser%GetString(text)
564 bndelem => this%lauxvar(jj, ii)
566 this%packName,
'AUX', &
567 this%tsManager, this%iprpak, &
574 call this%pak_set_stressperiod(itemno, keyword, found)
577 if (.not. found)
then
579 'Unknown '//trim(adjustl(this%text))//
' data keyword: ', &
587 call this%parser%StoreErrorUnit()
602 integer(I4B),
intent(in) :: itemno
603 character(len=*),
intent(in) :: keyword
604 logical,
intent(inout) :: found
611 call store_error(
'Program error: pak_set_stressperiod not implemented.', &
627 integer(I4B),
intent(in) :: itemno
630 if (itemno < 1 .or. itemno > this%ncv)
then
631 write (
errmsg,
'(a,1x,i6,1x,a,1x,i6)') &
632 'Featureno ', itemno,
'must be > 0 and <= ', this%ncv
662 integer(I4B) :: j, iaux
665 call this%TsManager%ad()
670 if (this%naux > 0)
then
671 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
672 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
673 do iaux = 1, this%naux
674 this%auxvar(iaux, j) = this%lauxvar(iaux, n)
683 this%xoldpak(n) = this%xnewpak(n)
684 if (this%iboundpak(n) < 0)
then
685 this%xnewpak(n) = this%concfeat(n)
690 this%xnewpak(n) = this%xoldpak(n)
691 if (this%iboundpak(n) < 0)
then
692 this%xnewpak(n) = this%concfeat(n)
705 call this%obs%obs_ad()
717 do i = 1,
size(this%qmfrommvr)
718 this%qmfrommvr(i) =
dzero
725 subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
729 real(DP),
dimension(:),
intent(inout) :: rhs
730 integer(I4B),
dimension(:),
intent(in) :: ia
731 integer(I4B),
dimension(:),
intent(in) :: idxglo
736 if (this%imatrows == 0)
then
737 call this%apt_fc_nonexpanded(rhs, ia, idxglo, matrix_sln)
739 call this%apt_fc_expanded(rhs, ia, idxglo, matrix_sln)
755 real(DP),
dimension(:),
intent(inout) :: rhs
756 integer(I4B),
dimension(:),
intent(in) :: ia
757 integer(I4B),
dimension(:),
intent(in) :: idxglo
760 integer(I4B) :: j, igwfnode, idiag
763 call this%apt_solve()
766 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
767 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
768 if (this%ibound(igwfnode) < 1) cycle
769 idiag = idxglo(ia(igwfnode))
770 call matrix_sln%add_value_pos(idiag, this%hcof(j))
771 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
787 real(DP),
dimension(:),
intent(inout) :: rhs
788 integer(I4B),
dimension(:),
intent(in) :: ia
789 integer(I4B),
dimension(:),
intent(in) :: idxglo
792 integer(I4B) :: j, n, n1, n2
794 integer(I4B) :: iposd, iposoffd
795 integer(I4B) :: ipossymd, ipossymoffd
797 real(DP) :: qbnd, qbnd_scaled
808 call this%pak_fc_expanded(rhs, ia, idxglo, matrix_sln)
812 cold = this%xoldpak(n)
813 iloc = this%idxlocnode(n)
814 iposd = this%idxpakdiag(n)
815 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
816 call matrix_sln%add_value_pos(iposd, hcofval)
817 rhs(iloc) = rhs(iloc) + rhsval
821 if (this%idxbudtmvr /= 0)
then
822 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
823 call this%apt_tmvr_term(j, n1, n2, rrate, rhsval, hcofval)
824 iloc = this%idxlocnode(n1)
825 iposd = this%idxpakdiag(n1)
826 call matrix_sln%add_value_pos(iposd, hcofval)
827 rhs(iloc) = rhs(iloc) + rhsval
832 if (this%idxbudfmvr /= 0)
then
834 rhsval = this%qmfrommvr(n)
835 iloc = this%idxlocnode(n)
836 rhs(iloc) = rhs(iloc) - rhsval
841 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
844 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
845 if (this%iboundpak(n) /= 0)
then
848 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
851 qbnd_scaled = qbnd * this%eqnsclfac
854 iposd = this%idxdglo(j)
855 iposoffd = this%idxoffdglo(j)
856 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
857 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
860 ipossymd = this%idxsymdglo(j)
861 ipossymoffd = this%idxsymoffdglo(j)
862 call matrix_sln%add_value_pos(ipossymd, -(
done - omega) * qbnd_scaled)
863 call matrix_sln%add_value_pos(ipossymoffd, -omega * qbnd_scaled)
868 if (this%idxbudfjf /= 0)
then
869 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
870 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(j)
871 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(j)
872 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(j)
873 if (qbnd <=
dzero)
then
878 qbnd_scaled = qbnd * this%eqnsclfac
879 iposd = this%idxfjfdglo(j)
880 iposoffd = this%idxfjfoffdglo(j)
881 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
882 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
899 real(DP),
dimension(:),
intent(inout) :: rhs
900 integer(I4B),
dimension(:),
intent(in) :: ia
901 integer(I4B),
dimension(:),
intent(in) :: idxglo
906 call store_error(
'Program error: pak_fc_expanded not implemented.', &
930 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
931 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
934 if (this%iboundpak(n) /= 0)
then
935 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
938 this%hcof(j) = -(
done - omega) * qbnd * this%eqnsclfac
939 this%rhs(j) = omega * qbnd * this%xnewpak(n) * this%eqnsclfac
955 real(DP),
dimension(:),
intent(in) :: x
956 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
957 integer(I4B),
optional,
intent(in) :: iadv
959 integer(I4B) :: n, n1, n2
964 if (this%imatrows == 0)
then
965 call this%apt_solve()
967 call this%apt_cfupdate()
971 call this%BndType%bnd_cq(x, flowja)
976 if (this%iboundpak(n) > 0)
then
977 call this%apt_stor_term(n, n1, n2, rrate)
983 call this%apt_copy2flowp()
986 call this%apt_fill_budobj(x, flowja)
997 integer(I4B),
intent(in) :: icbcfl
998 integer(I4B),
intent(in) :: ibudfl
999 integer(I4B) :: ibinun
1003 if (this%ibudgetout /= 0)
then
1004 ibinun = this%ibudgetout
1006 if (icbcfl == 0) ibinun = 0
1007 if (ibinun > 0)
then
1008 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
1013 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
1014 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
1029 integer(I4B),
intent(in) :: idvsave
1030 integer(I4B),
intent(in) :: idvprint
1032 integer(I4B) :: ibinun
1035 character(len=LENBUDTXT) :: text
1039 if (this%iconcout /= 0)
then
1040 ibinun = this%iconcout
1042 if (idvsave == 0) ibinun = 0
1045 if (ibinun > 0)
then
1048 if (this%iboundpak(n) == 0)
then
1053 write (text,
'(a)') str_pad_left(this%depvartype, lenvarname)
1055 this%ncv, 1, 1, ibinun)
1059 if (idvprint /= 0 .and. this%iprconc /= 0)
then
1062 call this%dvtab%set_kstpkper(
kstp,
kper)
1066 if (this%inamedbound == 1)
then
1067 call this%dvtab%add_term(this%featname(n))
1069 call this%dvtab%add_term(n)
1070 call this%dvtab%add_term(this%xnewpak(n))
1085 integer(I4B),
intent(in) :: kstp
1086 integer(I4B),
intent(in) :: kper
1087 integer(I4B),
intent(in) :: iout
1088 integer(I4B),
intent(in) :: ibudfl
1090 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
1108 call this%BndType%allocate_scalars()
1111 call mem_allocate(this%iauxfpconc,
'IAUXFPCONC', this%memoryPath)
1112 call mem_allocate(this%imatrows,
'IMATROWS', this%memoryPath)
1113 call mem_allocate(this%iprconc,
'IPRCONC', this%memoryPath)
1114 call mem_allocate(this%iconcout,
'ICONCOUT', this%memoryPath)
1115 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
1116 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
1117 call mem_allocate(this%igwfaptpak,
'IGWFAPTPAK', this%memoryPath)
1119 call mem_allocate(this%idxbudfjf,
'IDXBUDFJF', this%memoryPath)
1120 call mem_allocate(this%idxbudgwf,
'IDXBUDGWF', this%memoryPath)
1121 call mem_allocate(this%idxbudsto,
'IDXBUDSTO', this%memoryPath)
1122 call mem_allocate(this%idxbudtmvr,
'IDXBUDTMVR', this%memoryPath)
1123 call mem_allocate(this%idxbudfmvr,
'IDXBUDFMVR', this%memoryPath)
1124 call mem_allocate(this%idxbudaux,
'IDXBUDAUX', this%memoryPath)
1125 call mem_allocate(this%nconcbudssm,
'NCONCBUDSSM', this%memoryPath)
1126 call mem_allocate(this%idxprepak,
'IDXPREPAK', this%memoryPath)
1127 call mem_allocate(this%idxlastpak,
'IDXLASTPAK', this%memoryPath)
1144 this%nconcbudssm = 0
1167 if (this%imatrows /= 0)
then
1171 if (this%idxbudfjf /= 0)
then
1172 n = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1176 call mem_allocate(this%idxlocnode, this%ncv,
'IDXLOCNODE', &
1178 call mem_allocate(this%idxpakdiag, this%ncv,
'IDXPAKDIAG', &
1180 call mem_allocate(this%idxdglo, this%maxbound,
'IDXGLO', &
1182 call mem_allocate(this%idxoffdglo, this%maxbound,
'IDXOFFDGLO', &
1184 call mem_allocate(this%idxsymdglo, this%maxbound,
'IDXSYMDGLO', &
1186 call mem_allocate(this%idxsymoffdglo, this%maxbound,
'IDXSYMOFFDGLO', &
1190 call mem_allocate(this%idxfjfoffdglo, n,
'IDXFJFOFFDGLO', &
1203 call mem_allocate(this%idxsymoffdglo, 0,
'IDXSYMOFFDGLO', &
1207 call mem_allocate(this%idxfjfoffdglo, 0,
'IDXFJFOFFDGLO', &
1228 call this%BndType%allocate_arrays()
1233 if (this%iconcout > 0)
then
1234 call mem_allocate(this%dbuff, this%ncv,
'DBUFF', this%memoryPath)
1236 this%dbuff(n) =
dzero
1239 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
1243 allocate (this%status(this%ncv))
1246 call mem_allocate(this%concfeat, this%ncv,
'CONCFEAT', this%memoryPath)
1249 call mem_allocate(this%qsto, this%ncv,
'QSTO', this%memoryPath)
1250 call mem_allocate(this%ccterm, this%ncv,
'CCTERM', this%memoryPath)
1253 call mem_allocate(this%concbudssm, this%nconcbudssm, this%ncv, &
1254 'CONCBUDSSM', this%memoryPath)
1257 call mem_allocate(this%qmfrommvr, this%ncv,
'QMFROMMVR', this%memoryPath)
1261 this%status(n) =
'ACTIVE'
1262 this%qsto(n) =
dzero
1263 this%ccterm(n) =
dzero
1264 this%qmfrommvr(n) =
dzero
1265 this%concbudssm(:, n) =
dzero
1266 this%concfeat(n) =
dzero
1293 if (this%imatrows == 0)
then
1300 deallocate (this%status)
1301 deallocate (this%featname)
1304 call this%budobj%budgetobject_da()
1305 deallocate (this%budobj)
1306 nullify (this%budobj)
1309 if (this%iprconc > 0)
then
1310 call this%dvtab%table_da()
1311 deallocate (this%dvtab)
1312 nullify (this%dvtab)
1346 call this%BndType%bnd_da()
1362 call store_error(
'Program error: pak_solve not implemented.', &
1379 character(len=*),
intent(inout) :: option
1380 logical,
intent(inout) :: found
1382 character(len=MAXCHARLEN) :: fname, keyword
1384 character(len=*),
parameter :: fmtaptbin = &
1385 "(4x, a, 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, &
1386 &/4x, 'OPENED ON UNIT: ', I0)"
1389 select case (option)
1390 case (
'FLOW_PACKAGE_NAME')
1391 call this%parser%GetStringCaps(this%flowpackagename)
1392 write (this%iout,
'(4x,a)') &
1393 'THIS '//trim(adjustl(this%text))//
' PACKAGE CORRESPONDS TO A GWF &
1394 &PACKAGE WITH THE NAME '//trim(adjustl(this%flowpackagename))
1395 case (
'FLOW_PACKAGE_AUXILIARY_NAME')
1396 call this%parser%GetStringCaps(this%cauxfpconc)
1397 write (this%iout,
'(4x,a)') &
1398 'SIMULATED CONCENTRATIONS WILL BE COPIED INTO THE FLOW PACKAGE &
1399 &AUXILIARY VARIABLE WITH THE NAME '//trim(adjustl(this%cauxfpconc))
1400 case (
'DEV_NONEXPANDING_MATRIX')
1405 call this%parser%DevOpt()
1407 write (this%iout,
'(4x,a)') &
1408 trim(adjustl(this%text))// &
1409 ' WILL NOT ADD ADDITIONAL ROWS TO THE A MATRIX.'
1410 case (
'PRINT_CONCENTRATION',
'PRINT_TEMPERATURE')
1412 write (this%iout,
'(4x,a,1x,a,1x,a)') trim(adjustl(this%text))// &
1413 trim(adjustl(this%depvartype))//
'S WILL BE PRINTED TO LISTING &
1415 case (
'CONCENTRATION',
'TEMPERATURE')
1416 call this%parser%GetStringCaps(keyword)
1417 if (keyword ==
'FILEOUT')
then
1418 call this%parser%GetString(fname)
1420 call openfile(this%iconcout, this%iout, fname,
'DATA(BINARY)', &
1422 write (this%iout, fmtaptbin) &
1423 trim(adjustl(this%text)), trim(adjustl(this%depvartype)), &
1424 trim(fname), this%iconcout
1426 write (
errmsg,
"('Optional', 1x, a, 1X, 'keyword must &
1427 &be followed by FILEOUT')") this%depvartype
1431 call this%parser%GetStringCaps(keyword)
1432 if (keyword ==
'FILEOUT')
then
1433 call this%parser%GetString(fname)
1435 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
1437 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET', &
1438 trim(fname), this%ibudgetout
1440 call store_error(
'Optional BUDGET keyword must be followed by FILEOUT')
1443 call this%parser%GetStringCaps(keyword)
1444 if (keyword ==
'FILEOUT')
then
1445 call this%parser%GetString(fname)
1447 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
1448 filstat_opt=
'REPLACE')
1449 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET CSV', &
1450 trim(fname), this%ibudcsv
1452 call store_error(
'Optional BUDGETCSV keyword must be followed by &
1471 integer(I4B) :: ierr
1475 if (this%flowpackagename ==
'')
then
1476 this%flowpackagename = this%packName
1477 write (this%iout,
'(4x,a)') &
1478 'THE FLOW PACKAGE NAME FOR '//trim(adjustl(this%text))//
' WAS NOT &
1479 &SPECIFIED. SETTING FLOW PACKAGE NAME TO '// &
1480 &trim(adjustl(this%flowpackagename))
1483 call this%find_apt_package()
1486 this%ncv = this%flowbudptr%ncv
1487 this%maxbound = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1488 this%nbound = this%maxbound
1489 write (this%iout,
'(a, a)')
'SETTING DIMENSIONS FOR PACKAGE ', this%packName
1490 write (this%iout,
'(2x,a,i0)')
'NUMBER OF CONTROL VOLUMES = ', this%ncv
1491 write (this%iout,
'(2x,a,i0)')
'MAXBOUND = ', this%maxbound
1492 write (this%iout,
'(2x,a,i0)')
'NBOUND = ', this%nbound
1493 if (this%imatrows /= 0)
then
1494 this%npakeq = this%ncv
1495 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1496 ' SOLVED AS PART OF GWT MATRIX EQUATIONS'
1498 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1499 ' SOLVED SEPARATELY FROM GWT MATRIX EQUATIONS '
1501 write (this%iout,
'(a, //)')
'DONE SETTING DIMENSIONS FOR '// &
1502 trim(adjustl(this%text))
1505 if (this%ncv < 0)
then
1507 'Number of control volumes could not be determined correctly.'
1518 call this%apt_read_cvs()
1522 call this%define_listlabel()
1525 call this%apt_setup_budobj()
1528 call this%apt_setup_tableobj()
1543 character(len=LINELENGTH) :: text
1544 character(len=LENBOUNDNAME) :: bndName, bndNameTemp
1545 character(len=9) :: cno
1546 character(len=50),
dimension(:),
allocatable :: caux
1547 integer(I4B) :: ierr
1548 logical :: isfound, endOfBlock
1550 integer(I4B) :: ii, jj
1551 integer(I4B) :: iaux
1552 integer(I4B) :: itmp
1553 integer(I4B) :: nlak
1554 integer(I4B) :: nconn
1555 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1556 real(DP),
pointer :: bndElem => null()
1562 call mem_allocate(this%strt, this%ncv,
'STRT', this%memoryPath)
1563 call mem_allocate(this%ktf, this%ncv,
'KTF', this%memoryPath)
1564 call mem_allocate(this%rfeatthk, this%ncv,
'RFEATTHK', this%memoryPath)
1565 call mem_allocate(this%lauxvar, this%naux, this%ncv,
'LAUXVAR', &
1569 if (this%imatrows == 0)
then
1570 call mem_allocate(this%iboundpak, this%ncv,
'IBOUND', this%memoryPath)
1571 call mem_allocate(this%xnewpak, this%ncv,
'XNEWPAK', this%memoryPath)
1573 call mem_allocate(this%xoldpak, this%ncv,
'XOLDPAK', this%memoryPath)
1576 allocate (this%featname(this%ncv))
1580 this%strt(n) =
dep20
1582 this%rfeatthk(n) =
dzero
1583 this%lauxvar(:, n) =
dzero
1584 this%xoldpak(n) =
dep20
1585 if (this%imatrows == 0)
then
1586 this%iboundpak(n) = 1
1587 this%xnewpak(n) =
dep20
1592 if (this%naux > 0)
then
1593 allocate (caux(this%naux))
1597 allocate (nboundchk(this%ncv))
1603 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
1604 supportopenclose=.true.)
1608 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1613 call this%parser%GetNextLine(endofblock)
1614 if (endofblock)
exit
1615 n = this%parser%GetInteger()
1617 if (n < 1 .or. n > this%ncv)
then
1618 write (
errmsg,
'(a,1x,i6)') &
1619 'Itemno must be > 0 and <= ', this%ncv
1625 nboundchk(n) = nboundchk(n) + 1
1628 this%strt(n) = this%parser%GetDouble()
1631 if (this%depvartype ==
'TEMPERATURE')
then
1633 if (trim(adjustl(this%text)) /=
'UZE')
then
1634 this%ktf(n) = this%parser%GetDouble()
1635 this%rfeatthk(n) = this%parser%GetDouble()
1636 if (this%rfeatthk(n) <=
dzero)
then
1637 write (
errmsg,
'(4x,a)') &
1638 '****ERROR. Specified thickness used for thermal &
1639 &conduction MUST BE > 0 else divide by zero error occurs'
1647 do iaux = 1, this%naux
1648 call this%parser%GetString(caux(iaux))
1652 write (cno,
'(i9.9)') n
1653 bndname =
'Feature'//cno
1656 if (this%inamedbound /= 0)
then
1657 call this%parser%GetStringCaps(bndnametemp)
1658 if (bndnametemp /=
'')
then
1659 bndname = bndnametemp
1662 this%featname(n) = bndname
1666 do jj = 1, this%naux
1669 bndelem => this%lauxvar(jj, ii)
1671 this%packName,
'AUX', &
1672 this%tsManager, this%iprpak, &
1681 if (nboundchk(n) == 0)
then
1682 write (
errmsg,
'(a,1x,i0)')
'No data specified for feature', n
1684 else if (nboundchk(n) > 1)
then
1685 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1686 'Data for feature', n,
'specified', nboundchk(n),
'times'
1691 write (this%iout,
'(1x,a)') &
1692 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1694 call store_error(
'Required packagedata block not found.')
1699 call this%parser%StoreErrorUnit()
1703 if (this%naux > 0)
then
1708 deallocate (nboundchk)
1723 integer(I4B) :: j, n
1729 this%xnewpak(n) = this%strt(n)
1738 if (this%status(n) ==
'CONSTANT')
then
1739 this%iboundpak(n) = -1
1740 else if (this%status(n) ==
'INACTIVE')
then
1741 this%iboundpak(n) = 0
1742 else if (this%status(n) ==
'ACTIVE ')
then
1743 this%iboundpak(n) = 1
1748 if (this%inamedbound /= 0)
then
1749 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1750 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1751 this%boundname(j) = this%featname(n)
1756 call this%copy_boundname()
1773 integer(I4B) :: n, j, igwfnode
1774 integer(I4B) :: n1, n2
1777 real(DP) :: c1, qbnd
1778 real(DP) :: hcofval, rhsval
1782 this%dbuff(n) = dzero
1787 call this%pak_solve()
1790 if (this%idxbudtmvr /= 0)
then
1791 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
1792 call this%apt_tmvr_term(j, n1, n2, rrate)
1793 this%dbuff(n1) = this%dbuff(n1) + rrate
1798 if (this%idxbudfmvr /= 0)
then
1799 do n1 = 1,
size(this%qmfrommvr)
1800 rrate = this%qmfrommvr(n1)
1801 this%dbuff(n1) = this%dbuff(n1) + rrate
1807 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1808 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1809 this%hcof(j) = dzero
1811 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
1812 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
1813 if (qbnd <= dzero)
then
1814 ctmp = this%xnewpak(n)
1815 this%rhs(j) = qbnd * ctmp * this%eqnsclfac
1817 ctmp = this%xnew(igwfnode)
1818 this%hcof(j) = -qbnd * this%eqnsclfac
1820 c1 = qbnd * ctmp * this%eqnsclfac
1821 this%dbuff(n) = this%dbuff(n) + c1
1826 if (this%idxbudfjf /= 0)
then
1827 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
1828 call this%apt_fjf_term(j, n1, n2, rrate)
1830 this%dbuff(n1) = this%dbuff(n1) + c1
1836 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
1840 this%dbuff(n) = this%dbuff(n) - rhsval
1843 c1 = -this%dbuff(n) / hcofval
1844 if (this%iboundpak(n) > 0)
then
1845 this%xnewpak(n) = c1
1864 call store_error(
'Program error: pak_solve not implemented.', &
1876 integer(I4B),
intent(in) :: ilak
1877 real(DP),
intent(in) :: rrate
1878 real(DP),
intent(inout) :: ccratin
1879 real(DP),
intent(inout) :: ccratout
1885 if (this%iboundpak(ilak) < 0)
then
1887 this%ccterm(ilak) = this%ccterm(ilak) + q
1893 ccratout = ccratout - q
1897 ccratin = ccratin + q
1912 this%listlabel = trim(this%filtyp)//
' NO.'
1913 if (this%dis%ndim == 3)
then
1914 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1915 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
1916 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
1917 elseif (this%dis%ndim == 2)
then
1918 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1919 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
1921 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
1923 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
1924 if (this%inamedbound == 1)
then
1925 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
1937 integer(I4B),
pointer :: neq
1938 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
1939 real(DP),
dimension(:),
pointer,
contiguous :: xnew
1940 real(DP),
dimension(:),
pointer,
contiguous :: xold
1941 real(DP),
dimension(:),
pointer,
contiguous :: flowja
1943 integer(I4B) :: istart, iend
1946 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
1951 if (this%imatrows /= 0)
then
1952 istart = this%dis%nodes + this%ioffset + 1
1953 iend = istart + this%ncv - 1
1954 this%iboundpak => this%ibound(istart:iend)
1955 this%xnewpak => this%xnew(istart:iend)
1968 integer(I4B),
intent(in) :: icv
1969 real(DP),
intent(inout) :: vnew, vold
1970 real(DP),
intent(in) :: delt
1977 if (this%idxbudsto /= 0)
then
1978 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1979 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1980 vold = vnew + qss * delt
1996 integer(I4B) :: nbudterms
2000 call store_error(
'Program error: pak_get_nbudterms not implemented.', &
2016 integer(I4B) :: nbudterm
2017 integer(I4B) :: nlen
2018 integer(I4B) :: n, n1, n2
2019 integer(I4B) :: maxlist, naux
2021 logical :: ordered_id1
2023 character(len=LENBUDTXT) :: bddim_opt
2024 character(len=LENBUDTXT) :: text, textt
2025 character(len=LENBUDTXT),
dimension(1) :: auxtxt
2032 if (this%idxbudfjf /= 0)
then
2033 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2040 if (this%idxbudfjf /= 0) nbudterm = nbudterm + 1
2043 nbudterm = nbudterm + 3
2046 nbudterm = nbudterm + this%pak_get_nbudterms()
2049 if (this%idxbudtmvr /= 0) nbudterm = nbudterm + 1
2050 if (this%idxbudfmvr /= 0) nbudterm = nbudterm + 1
2051 if (this%naux > 0) nbudterm = nbudterm + 1
2056 bddim_opt = this%depvarunitabbrev
2057 call this%budobj%budgetobject_df(this%ncv, nbudterm, 0, 0, &
2058 bddim_opt=bddim_opt, ibudcsv=this%ibudcsv)
2063 text =
' FLOW-JA-FACE'
2065 maxlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2067 ordered_id1 = this%flowbudptr%budterm(this%idxbudfjf)%ordered_id1
2068 call this%budobj%budterm(idx)%initialize(text, &
2073 maxlist, .false., .false., &
2074 naux, ordered_id1=ordered_id1)
2077 call this%budobj%budterm(idx)%reset(maxlist)
2080 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(n)
2081 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(n)
2082 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2089 maxlist = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
2091 call this%budobj%budterm(idx)%initialize(text, &
2096 maxlist, .false., .true., &
2098 call this%budobj%budterm(idx)%reset(maxlist)
2101 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(n)
2102 n2 = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
2103 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2107 this%idxprepak = idx
2108 call this%pak_setup_budobj(idx)
2109 this%idxlastpak = idx
2114 maxlist = this%flowbudptr%budterm(this%idxbudsto)%maxlist
2118 call this%budobj%budterm(idx)%initialize(text, &
2123 maxlist, .false., .false., &
2125 if (this%idxbudtmvr /= 0)
then
2130 maxlist = this%flowbudptr%budterm(this%idxbudtmvr)%maxlist
2132 ordered_id1 = this%flowbudptr%budterm(this%idxbudtmvr)%ordered_id1
2133 call this%budobj%budterm(idx)%initialize(text, &
2138 maxlist, .false., .false., &
2139 naux, ordered_id1=ordered_id1)
2141 if (this%idxbudfmvr /= 0)
then
2148 call this%budobj%budterm(idx)%initialize(text, &
2153 maxlist, .false., .false., &
2162 call this%budobj%budterm(idx)%initialize(text, &
2167 maxlist, .false., .false., &
2179 call this%budobj%budterm(idx)%initialize(text, &
2184 maxlist, .false., .false., &
2189 if (this%iprflow /= 0)
then
2190 call this%budobj%flowtable_df(this%iout)
2205 integer(I4B),
intent(inout) :: idx
2209 call store_error(
'Program error: pak_setup_budobj not implemented.', &
2223 real(DP),
dimension(:),
intent(in) :: x
2224 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2226 integer(I4B) :: naux
2227 real(DP),
dimension(:),
allocatable :: auxvartmp
2228 integer(I4B) :: i, j, n1, n2
2230 integer(I4B) :: nlen
2231 integer(I4B) :: nlist
2232 integer(I4B) :: igwfnode
2235 real(DP) :: ccratin, ccratout
2246 this%ccterm(n1) =
dzero
2251 if (this%idxbudfjf /= 0)
then
2252 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2256 nlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2257 call this%budobj%budterm(idx)%reset(nlist)
2260 call this%apt_fjf_term(j, n1, n2, q)
2261 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2262 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2268 call this%budobj%budterm(idx)%reset(this%maxbound)
2269 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2271 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2272 if (this%iboundpak(n1) /= 0)
then
2273 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
2274 q = this%hcof(j) * x(igwfnode) - this%rhs(j)
2277 call this%budobj%budterm(idx)%update_term(n1, igwfnode, q)
2278 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2283 idx = this%idxlastpak
2287 call this%budobj%budterm(idx)%reset(this%ncv)
2288 allocate (auxvartmp(1))
2290 call this%get_volumes(n1, v1, v0,
delt)
2291 auxvartmp(1) = v1 * this%xnewpak(n1)
2293 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2294 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2296 deallocate (auxvartmp)
2299 if (this%idxbudtmvr /= 0)
then
2301 nlist = this%flowbudptr%budterm(this%idxbudtmvr)%nlist
2302 call this%budobj%budterm(idx)%reset(nlist)
2304 call this%apt_tmvr_term(j, n1, n2, q)
2305 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2306 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2311 if (this%idxbudfmvr /= 0)
then
2314 call this%budobj%budterm(idx)%reset(nlist)
2316 call this%apt_fmvr_term(j, n1, n2, q)
2317 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2318 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2324 call this%budobj%budterm(idx)%reset(this%ncv)
2327 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2334 allocate (auxvartmp(naux))
2335 call this%budobj%budterm(idx)%reset(this%ncv)
2339 auxvartmp(i) = this%lauxvar(i, n1)
2341 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2343 deallocate (auxvartmp)
2347 idx = this%idxprepak
2348 call this%pak_fill_budobj(idx, x, flowja, ccratin, ccratout)
2351 call this%budobj%accumulate_terms()
2363 integer(I4B),
intent(inout) :: idx
2364 real(DP),
dimension(:),
intent(in) :: x
2365 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2366 real(DP),
intent(inout) :: ccratin
2367 real(DP),
intent(inout) :: ccratout
2372 call store_error(
'Program error: pak_fill_budobj not implemented.', &
2385 integer(I4B),
intent(in) :: ientry
2386 integer(I4B),
intent(inout) :: n1
2387 integer(I4B),
intent(inout) :: n2
2388 real(DP),
intent(inout),
optional :: rrate
2389 real(DP),
intent(inout),
optional :: rhsval
2390 real(DP),
intent(inout),
optional :: hcofval
2396 call this%get_volumes(n1, v1, v0,
delt)
2397 c0 = this%xoldpak(n1)
2398 c1 = this%xnewpak(n1)
2399 if (
present(rrate))
then
2400 rrate = (-c1 * v1 /
delt + c0 * v0 /
delt) * this%eqnsclfac
2402 if (
present(rhsval)) rhsval = -c0 * v0 * this%eqnsclfac /
delt
2403 if (
present(hcofval)) hcofval = -v1 * this%eqnsclfac /
delt
2416 integer(I4B),
intent(in) :: ientry
2417 integer(I4B),
intent(inout) :: n1
2418 integer(I4B),
intent(inout) :: n2
2419 real(DP),
intent(inout),
optional :: rrate
2420 real(DP),
intent(inout),
optional :: rhsval
2421 real(DP),
intent(inout),
optional :: hcofval
2427 n1 = this%flowbudptr%budterm(this%idxbudtmvr)%id1(ientry)
2428 n2 = this%flowbudptr%budterm(this%idxbudtmvr)%id2(ientry)
2429 qbnd = this%flowbudptr%budterm(this%idxbudtmvr)%flow(ientry)
2430 ctmp = this%xnewpak(n1)
2431 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2432 if (
present(rhsval)) rhsval =
dzero
2433 if (
present(hcofval)) hcofval = qbnd * this%eqnsclfac
2447 integer(I4B),
intent(in) :: ientry
2448 integer(I4B),
intent(inout) :: n1
2449 integer(I4B),
intent(inout) :: n2
2450 real(DP),
intent(inout),
optional :: rrate
2451 real(DP),
intent(inout),
optional :: rhsval
2452 real(DP),
intent(inout),
optional :: hcofval
2457 if (
present(rrate)) rrate = this%qmfrommvr(n1)
2458 if (
present(rhsval)) rhsval = this%qmfrommvr(n1)
2459 if (
present(hcofval)) hcofval =
dzero
2473 integer(I4B),
intent(in) :: ientry
2474 integer(I4B),
intent(inout) :: n1
2475 integer(I4B),
intent(inout) :: n2
2476 real(DP),
intent(inout),
optional :: rrate
2477 real(DP),
intent(inout),
optional :: rhsval
2478 real(DP),
intent(inout),
optional :: hcofval
2483 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(ientry)
2484 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(ientry)
2485 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(ientry)
2487 ctmp = this%xnewpak(n1)
2489 ctmp = this%xnewpak(n2)
2491 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2492 if (
present(rhsval)) rhsval = -rrate * this%eqnsclfac
2493 if (
present(hcofval)) hcofval =
dzero
2507 integer(I4B) :: n, j
2510 if (this%iauxfpconc /= 0)
then
2513 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2516 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2517 this%flowpackagebnd%auxvar(this%iauxfpconc, j) = this%xnewpak(n)
2556 call this%pak_df_obs()
2574 call store_error(
'Program error: pak_df_obs not implemented.', &
2589 logical,
intent(inout) :: found
2593 call store_error(
'Program error: pak_rp_obs not implemented.', &
2611 character(len=*),
parameter :: fmterr = &
2612 "('Boundary ', a, ' for observation ', a, &
2613 &' is invalid in package ', a)"
2614 nn1 = obsrv%NodeNumber
2618 if (this%featname(j) == obsrv%FeatureName)
then
2620 call obsrv%AddObsIndex(j)
2623 if (.not. jfound)
then
2624 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2631 if (nn1 < 0 .or. nn1 > this%ncv)
then
2632 write (
errmsg,
'(7a, i0, a, i0, a)') &
2633 'Observation ', trim(obsrv%Name),
' of type ', &
2634 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2635 trim(this%packName),
' was assigned ID = ', nn1, &
2636 '. ID must be >= 1 and <= ', this%ncv,
'.'
2639 call obsrv%AddObsIndex(nn1)
2656 integer(I4B) :: iconn
2661 character(len=*),
parameter :: fmterr = &
2662 "('Boundary ', a, ' for observation ', a, &
2663 &' is invalid in package ', a)"
2664 nn1 = obsrv%NodeNumber
2667 do j = 1, budterm%nlist
2668 icv = budterm%id1(j)
2669 if (this%featname(icv) == obsrv%FeatureName)
then
2671 call obsrv%AddObsIndex(j)
2674 if (.not. jfound)
then
2675 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2682 if (nn1 < 0 .or. nn1 > this%ncv)
then
2683 write (
errmsg,
'(7a, i0, a, i0, a)') &
2684 'Observation ', trim(obsrv%Name),
' of type ', &
2685 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2686 trim(this%packName),
' was assigned ID = ', nn1, &
2687 '. ID must be >= 1 and <= ', this%ncv,
'.'
2690 iconn = obsrv%NodeNumber2
2691 do j = 1, budterm%nlist
2692 if (budterm%id1(j) == nn1)
then
2696 call obsrv%AddObsIndex(idx)
2700 if (idx < 1 .or. idx > budterm%nlist)
then
2701 write (
errmsg,
'(7a, i0, a, i0, a)') &
2702 'Observation ', trim(obsrv%Name),
' of type ', &
2703 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2704 trim(this%packName),
' specifies iconn = ', iconn, &
2705 ', but this is not a valid connection for ID ', nn1,
'.'
2707 else if (budterm%id1(idx) /= nn1)
then
2708 write (
errmsg,
'(7a, i0, a, i0, a)') &
2709 'Observation ', trim(obsrv%Name),
' of type ', &
2710 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2711 trim(this%packName),
' specifies iconn = ', iconn, &
2712 ', but this is not a valid connection for ID ', nn1,
'.'
2735 character(len=*),
parameter :: fmterr = &
2736 "('Boundary ', a, ' for observation ', a, &
2737 &' is invalid in package ', a)"
2738 nn1 = obsrv%NodeNumber
2741 do j = 1, budterm%nlist
2742 icv = budterm%id1(j)
2743 if (this%featname(icv) == obsrv%FeatureName)
then
2745 call obsrv%AddObsIndex(j)
2748 if (.not. jfound)
then
2749 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2756 if (nn1 < 0 .or. nn1 > this%ncv)
then
2757 write (
errmsg,
'(7a, i0, a, i0, a)') &
2758 'Observation ', trim(obsrv%Name),
' of type ', &
2759 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2760 trim(this%packName),
' was assigned ID = ', nn1, &
2761 '. ID must be >= 1 and <= ', this%ncv,
'.'
2764 nn2 = obsrv%NodeNumber2
2767 if (nn2 < 0 .or. nn2 > this%ncv)
then
2768 write (
errmsg,
'(7a, i0, a, i0, a)') &
2769 'Observation ', trim(obsrv%Name),
' of type ', &
2770 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2771 trim(this%packName),
' was assigned ID2 = ', nn2, &
2772 '. ID must be >= 1 and <= ', this%ncv,
'.'
2777 do j = 1, budterm%nlist
2778 if (budterm%id1(j) == nn1 .and. budterm%id2(j) == nn2)
then
2779 call obsrv%AddObsIndex(j)
2783 if (.not. jfound)
then
2784 write (
errmsg,
'(7a, i0, a, i0, a)') &
2785 'Observation ', trim(obsrv%Name),
' of type ', &
2786 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2787 trim(this%packName), &
2788 ' specifies a connection between feature ', nn1, &
2789 ' feature ', nn2,
', but these features are not connected.'
2813 do i = 1, this%obs%npakobs
2814 obsrv => this%obs%pakobs(i)%obsrv
2815 select case (obsrv%ObsTypeId)
2816 case (
'CONCENTRATION',
'TEMPERATURE')
2817 call this%rp_obs_byfeature(obsrv)
2821 if (obsrv%indxbnds_count > 1)
then
2822 write (
errmsg,
'(a, a, a, a)') &
2823 trim(adjustl(this%depvartype))// &
2824 ' for observation', trim(adjustl(obsrv%Name)), &
2825 ' must be assigned to a feature with a unique boundname.'
2828 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2829 call this%rp_obs_budterm(obsrv, &
2830 this%flowbudptr%budterm(this%idxbudgwf))
2831 case (
'FLOW-JA-FACE')
2832 if (this%idxbudfjf > 0)
then
2833 call this%rp_obs_flowjaface(obsrv, &
2834 this%flowbudptr%budterm(this%idxbudfjf))
2837 'Observation ', trim(obsrv%Name),
' of type ', &
2838 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2839 trim(this%packName), &
2840 ' cannot be processed because there are no flow connections.'
2844 call this%rp_obs_byfeature(obsrv)
2846 call this%rp_obs_byfeature(obsrv)
2848 call this%rp_obs_byfeature(obsrv)
2853 call this%pak_rp_obs(obsrv, found)
2856 if (.not. found)
then
2857 errmsg =
'Unrecognized observation type "'// &
2858 trim(obsrv%ObsTypeId)//
'" for '// &
2859 trim(adjustl(this%text))//
' package '// &
2889 integer(I4B) :: igwfnode
2901 if (this%obs%npakobs > 0)
then
2902 call this%obs%obs_bd_clear()
2903 do i = 1, this%obs%npakobs
2904 obsrv => this%obs%pakobs(i)%obsrv
2905 do j = 1, obsrv%indxbnds_count
2907 jj = obsrv%indxbnds(j)
2908 select case (obsrv%ObsTypeId)
2909 case (
'CONCENTRATION',
'TEMPERATURE')
2910 if (this%iboundpak(jj) /= 0)
then
2911 v = this%xnewpak(jj)
2913 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2914 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(jj)
2915 if (this%iboundpak(n) /= 0)
then
2916 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(jj)
2917 v = this%hcof(jj) * this%xnew(igwfnode) - this%rhs(jj)
2920 case (
'FLOW-JA-FACE')
2921 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(jj)
2922 if (this%iboundpak(n) /= 0)
then
2923 call this%apt_fjf_term(jj, n1, n2, v)
2926 if (this%iboundpak(jj) /= 0)
then
2930 if (this%iboundpak(jj) /= 0)
then
2934 if (this%iboundpak(jj) /= 0 .and. this%idxbudfmvr > 0)
then
2935 call this%apt_fmvr_term(jj, n1, n2, v)
2938 if (this%idxbudtmvr > 0)
then
2939 n = this%flowbudptr%budterm(this%idxbudtmvr)%id1(jj)
2940 if (this%iboundpak(n) /= 0)
then
2941 call this%apt_tmvr_term(jj, n1, n2, v)
2948 call this%pak_bd_obs(obsrv%ObsTypeId, jj, v, found)
2951 if (.not. found)
then
2952 errmsg =
'Unrecognized observation type "'// &
2953 trim(obsrv%ObsTypeId)//
'" for '// &
2954 trim(adjustl(this%text))//
' package '// &
2959 call this%obs%SaveOneSimval(obsrv, v)
2978 character(len=*),
intent(in) :: obstypeid
2979 integer(I4B),
intent(in) :: jj
2980 real(DP),
intent(inout) :: v
2981 logical,
intent(inout) :: found
3001 integer(I4B),
intent(in) :: inunitobs
3002 integer(I4B),
intent(in) :: iout
3005 integer(I4B) :: icol
3006 integer(I4B) :: istart
3007 integer(I4B) :: istop
3008 character(len=LINELENGTH) :: string
3009 character(len=LENBOUNDNAME) :: bndname
3012 string = obsrv%IDstring
3022 obsrv%FeatureName = bndname
3026 obsrv%NodeNumber = nn1
3031 obsrv%NodeNumber2 = 1
3047 integer(I4B),
intent(in) :: inunitobs
3048 integer(I4B),
intent(in) :: iout
3051 integer(I4B) :: iconn
3052 integer(I4B) :: icol
3053 integer(I4B) :: istart
3054 integer(I4B) :: istop
3055 character(len=LINELENGTH) :: string
3056 character(len=LENBOUNDNAME) :: bndname
3059 string = obsrv%IDstring
3069 obsrv%FeatureName = bndname
3072 if (len_trim(bndname) < 1 .and. iconn < 0)
then
3073 write (
errmsg,
'(a,1x,a,a,1x,a,1x,a)') &
3074 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
3075 ', ID given as an integer and not as boundname,', &
3076 'but ID2 is missing. Either change ID to valid', &
3077 'boundname or supply valid entry for ID2.'
3080 obsrv%NodeNumber2 = iconn
3084 obsrv%NodeNumber = nn1
3102 integer(I4B) :: nterms
3103 character(len=LINELENGTH) :: title
3104 character(len=LINELENGTH) :: text_temp
3107 if (this%iprconc > 0)
then
3111 if (this%inamedbound == 1) nterms = nterms + 1
3114 title = trim(adjustl(this%text))//
' PACKAGE ('// &
3115 trim(adjustl(this%packName))// &
3116 ') '//trim(adjustl(this%depvartype))// &
3117 &
' FOR EACH CONTROL VOLUME'
3120 call table_cr(this%dvtab, this%packName, title)
3121 call this%dvtab%table_df(this%ncv, nterms, this%iout, &
3125 if (this%inamedbound == 1)
then
3127 call this%dvtab%initialize_column(text_temp, 20, alignment=tableft)
3131 text_temp =
'NUMBER'
3132 call this%dvtab%initialize_column(text_temp, 10, alignment=tabcenter)
3135 text_temp = this%depvartype(1:4)
3136 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 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.