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)
240 subroutine apt_mc(this, moffset, matrix_sln)
244 integer(I4B),
intent(in) :: moffset
247 integer(I4B) :: n, j, iglo, jglo
252 call this%apt_allocate_index_arrays()
255 if (this%imatrows /= 0)
then
262 this%idxlocnode(n) = this%dis%nodes + this%ioffset + n
263 iglo = moffset + this%dis%nodes + this%ioffset + n
264 this%idxpakdiag(n) = matrix_sln%get_position_diag(iglo)
266 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
267 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
268 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
269 iglo = moffset + this%dis%nodes + this%ioffset + n
271 this%idxdglo(ipos) = matrix_sln%get_position_diag(iglo)
272 this%idxoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
276 do ipos = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
277 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(ipos)
278 j = this%flowbudptr%budterm(this%idxbudgwf)%id2(ipos)
280 jglo = moffset + this%dis%nodes + this%ioffset + n
281 this%idxsymdglo(ipos) = matrix_sln%get_position_diag(iglo)
282 this%idxsymoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
286 if (this%idxbudfjf /= 0)
then
287 do ipos = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
288 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(ipos)
289 j = this%flowbudptr%budterm(this%idxbudfjf)%id2(ipos)
290 iglo = moffset + this%dis%nodes + this%ioffset + n
291 jglo = moffset + this%dis%nodes + this%ioffset + j
292 this%idxfjfdglo(ipos) = matrix_sln%get_position_diag(iglo)
293 this%idxfjfoffdglo(ipos) = matrix_sln%get_position(iglo, jglo)
309 character(len=*),
parameter :: fmtapt = &
310 "(1x,/1x,'APT -- ADVANCED PACKAGE TRANSPORT, VERSION 1, 3/5/2020', &
311 &' INPUT READ FROM UNIT ', i0, //)"
314 call this%obs%obs_ar()
317 write (this%iout, fmtapt) this%inunit
320 call this%apt_allocate_arrays()
323 call this%read_initial_attr()
327 call this%fmi%get_package_index(this%flowpackagename, this%igwfaptpak)
332 this%fmi%iatp(this%igwfaptpak) = 1
333 this%fmi%datp(this%igwfaptpak)%concpack => this%get_mvr_depvar()
334 this%fmi%datp(this%igwfaptpak)%qmfrommvr => this%qmfrommvr
339 if (
associated(this%flowpackagebnd))
then
340 if (this%cauxfpconc /=
'')
then
342 do j = 1, this%flowpackagebnd%naux
343 if (this%flowpackagebnd%auxname(j) == this%cauxfpconc)
then
349 if (this%iauxfpconc == 0)
then
350 errmsg =
'Could not find auxiliary variable '// &
351 trim(adjustl(this%cauxfpconc))//
' in flow package '// &
352 trim(adjustl(this%flowpackagename))
354 call this%parser%StoreErrorUnit()
357 this%flowpackagebnd%noupdateauxvar(this%iauxfpconc) = 1
358 call this%apt_copy2flowp()
375 logical :: isfound, endOfBlock
376 character(len=LINELENGTH) :: title
377 character(len=LINELENGTH) :: line
378 integer(I4B) :: itemno
379 integer(I4B) :: igwfnode
381 character(len=*),
parameter :: fmtblkerr = &
382 &
"('Error. Looking for BEGIN PERIOD iper. Found ', a, ' instead.')"
383 character(len=*),
parameter :: fmtlsp = &
384 &
"(1X,/1X,'REUSING ',A,'S FROM LAST STRESS PERIOD')"
387 this%nbound = this%maxbound
391 if (this%inunit == 0)
return
394 if (this%ionper <
kper)
then
397 call this%parser%GetBlock(
'PERIOD', isfound, ierr, &
398 supportopenclose=.true., &
399 blockrequired=.false.)
403 call this%read_check_ionper()
409 this%ionper =
nper + 1
412 call this%parser%GetCurrentLine(line)
413 write (
errmsg, fmtblkerr) adjustl(trim(line))
415 call this%parser%StoreErrorUnit()
421 if (this%ionper ==
kper)
then
424 if (this%iprpak /= 0)
then
427 title = trim(adjustl(this%text))//
' PACKAGE ('// &
428 trim(adjustl(this%packName))//
') DATA FOR PERIOD'
429 write (title,
'(a,1x,i6)') trim(adjustl(title)),
kper
430 call table_cr(this%inputtab, this%packName, title)
431 call this%inputtab%table_df(1, 4, this%iout, finalize=.false.)
433 call this%inputtab%initialize_column(
text, 10, alignment=
tabcenter)
435 call this%inputtab%initialize_column(
text, 20, alignment=
tableft)
437 write (
text,
'(a,1x,i6)')
'VALUE', n
438 call this%inputtab%initialize_column(
text, 15, alignment=
tabcenter)
444 call this%parser%GetNextLine(endofblock)
448 itemno = this%parser%GetInteger()
451 call this%apt_set_stressperiod(itemno)
454 if (this%iprpak /= 0)
then
455 call this%parser%GetCurrentLine(line)
456 call this%inputtab%line_to_columns(line)
460 if (this%iprpak /= 0)
then
461 call this%inputtab%finalize_table()
466 write (this%iout, fmtlsp) trim(this%filtyp)
472 call this%parser%StoreErrorUnit()
476 do n = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
477 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
478 this%nodelist(n) = igwfnode
492 integer(I4B),
intent(in) :: itemno
494 character(len=LINELENGTH) :: text
495 character(len=LINELENGTH) :: caux
496 character(len=LINELENGTH) :: keyword
500 real(DP),
pointer :: bndElem => null()
511 call this%parser%GetStringCaps(keyword)
512 select case (keyword)
514 ierr = this%apt_check_valid(itemno)
518 call this%parser%GetStringCaps(text)
519 this%status(itemno) = text(1:8)
520 if (text ==
'CONSTANT')
then
521 this%iboundpak(itemno) = -1
522 else if (text ==
'INACTIVE')
then
523 this%iboundpak(itemno) = 0
524 else if (text ==
'ACTIVE')
then
525 this%iboundpak(itemno) = 1
528 'Unknown '//trim(this%text)//
' status keyword: ', text//
'.'
531 case (
'CONCENTRATION',
'TEMPERATURE')
532 ierr = this%apt_check_valid(itemno)
536 call this%parser%GetString(text)
538 bndelem => this%concfeat(itemno)
540 this%packName,
'BND', this%tsManager, &
541 this%iprpak, this%depvartype)
543 ierr = this%apt_check_valid(itemno)
547 call this%parser%GetStringCaps(caux)
549 if (trim(adjustl(caux)) /= trim(adjustl(this%auxname(jj)))) cycle
550 call this%parser%GetString(text)
552 bndelem => this%lauxvar(jj, ii)
554 this%packName,
'AUX', &
555 this%tsManager, this%iprpak, &
562 call this%pak_set_stressperiod(itemno, keyword, found)
565 if (.not. found)
then
567 'Unknown '//trim(adjustl(this%text))//
' data keyword: ', &
575 call this%parser%StoreErrorUnit()
587 integer(I4B),
intent(in) :: itemno
588 character(len=*),
intent(in) :: keyword
589 logical,
intent(inout) :: found
596 call store_error(
'Program error: pak_set_stressperiod not implemented.', &
609 integer(I4B),
intent(in) :: itemno
612 if (itemno < 1 .or. itemno > this%ncv)
then
613 write (
errmsg,
'(a,1x,i6,1x,a,1x,i6)') &
614 'Featureno ', itemno,
'must be > 0 and <= ', this%ncv
644 integer(I4B) :: j, iaux
647 call this%TsManager%ad()
652 if (this%naux > 0)
then
653 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
654 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
655 do iaux = 1, this%naux
656 this%auxvar(iaux, j) = this%lauxvar(iaux, n)
665 this%xoldpak(n) = this%xnewpak(n)
666 if (this%iboundpak(n) < 0)
then
667 this%xnewpak(n) = this%concfeat(n)
672 this%xnewpak(n) = this%xoldpak(n)
673 if (this%iboundpak(n) < 0)
then
674 this%xnewpak(n) = this%concfeat(n)
687 call this%obs%obs_ad()
696 do i = 1,
size(this%qmfrommvr)
697 this%qmfrommvr(i) =
dzero
701 subroutine apt_fc(this, rhs, ia, idxglo, matrix_sln)
705 real(DP),
dimension(:),
intent(inout) :: rhs
706 integer(I4B),
dimension(:),
intent(in) :: ia
707 integer(I4B),
dimension(:),
intent(in) :: idxglo
712 if (this%imatrows == 0)
then
713 call this%apt_fc_nonexpanded(rhs, ia, idxglo, matrix_sln)
715 call this%apt_fc_expanded(rhs, ia, idxglo, matrix_sln)
728 real(DP),
dimension(:),
intent(inout) :: rhs
729 integer(I4B),
dimension(:),
intent(in) :: ia
730 integer(I4B),
dimension(:),
intent(in) :: idxglo
733 integer(I4B) :: j, igwfnode, idiag
736 call this%apt_solve()
739 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
740 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
741 if (this%ibound(igwfnode) < 1) cycle
742 idiag = idxglo(ia(igwfnode))
743 call matrix_sln%add_value_pos(idiag, this%hcof(j))
744 rhs(igwfnode) = rhs(igwfnode) + this%rhs(j)
757 real(DP),
dimension(:),
intent(inout) :: rhs
758 integer(I4B),
dimension(:),
intent(in) :: ia
759 integer(I4B),
dimension(:),
intent(in) :: idxglo
762 integer(I4B) :: j, n, n1, n2
764 integer(I4B) :: iposd, iposoffd
765 integer(I4B) :: ipossymd, ipossymoffd
767 real(DP) :: qbnd, qbnd_scaled
778 call this%pak_fc_expanded(rhs, ia, idxglo, matrix_sln)
782 cold = this%xoldpak(n)
783 iloc = this%idxlocnode(n)
784 iposd = this%idxpakdiag(n)
785 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
786 call matrix_sln%add_value_pos(iposd, hcofval)
787 rhs(iloc) = rhs(iloc) + rhsval
791 if (this%idxbudtmvr /= 0)
then
792 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
793 call this%apt_tmvr_term(j, n1, n2, rrate, rhsval, hcofval)
794 iloc = this%idxlocnode(n1)
795 iposd = this%idxpakdiag(n1)
796 call matrix_sln%add_value_pos(iposd, hcofval)
797 rhs(iloc) = rhs(iloc) + rhsval
802 if (this%idxbudfmvr /= 0)
then
804 rhsval = this%qmfrommvr(n)
805 iloc = this%idxlocnode(n)
806 rhs(iloc) = rhs(iloc) - rhsval
811 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
814 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
815 if (this%iboundpak(n) /= 0)
then
818 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
821 qbnd_scaled = qbnd * this%eqnsclfac
824 iposd = this%idxdglo(j)
825 iposoffd = this%idxoffdglo(j)
826 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
827 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
830 ipossymd = this%idxsymdglo(j)
831 ipossymoffd = this%idxsymoffdglo(j)
832 call matrix_sln%add_value_pos(ipossymd, -(
done - omega) * qbnd_scaled)
833 call matrix_sln%add_value_pos(ipossymoffd, -omega * qbnd_scaled)
838 if (this%idxbudfjf /= 0)
then
839 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
840 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(j)
841 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(j)
842 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(j)
843 if (qbnd <=
dzero)
then
848 qbnd_scaled = qbnd * this%eqnsclfac
849 iposd = this%idxfjfdglo(j)
850 iposoffd = this%idxfjfoffdglo(j)
851 call matrix_sln%add_value_pos(iposd, omega * qbnd_scaled)
852 call matrix_sln%add_value_pos(iposoffd, (
done - omega) * qbnd_scaled)
866 real(DP),
dimension(:),
intent(inout) :: rhs
867 integer(I4B),
dimension(:),
intent(in) :: ia
868 integer(I4B),
dimension(:),
intent(in) :: idxglo
873 call store_error(
'Program error: pak_fc_expanded not implemented.', &
894 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
895 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
898 if (this%iboundpak(n) /= 0)
then
899 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
902 this%hcof(j) = -(
done - omega) * qbnd * this%eqnsclfac
903 this%rhs(j) = omega * qbnd * this%xnewpak(n) * this%eqnsclfac
916 real(DP),
dimension(:),
intent(in) :: x
917 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
918 integer(I4B),
optional,
intent(in) :: iadv
920 integer(I4B) :: n, n1, n2
925 if (this%imatrows == 0)
then
926 call this%apt_solve()
928 call this%apt_cfupdate()
932 call this%BndType%bnd_cq(x, flowja)
937 if (this%iboundpak(n) > 0)
then
938 call this%apt_stor_term(n, n1, n2, rrate)
944 call this%apt_copy2flowp()
947 call this%apt_fill_budobj(x, flowja)
955 integer(I4B),
intent(in) :: icbcfl
956 integer(I4B),
intent(in) :: ibudfl
957 integer(I4B) :: ibinun
961 if (this%ibudgetout /= 0)
then
962 ibinun = this%ibudgetout
964 if (icbcfl == 0) ibinun = 0
966 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
971 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
972 call this%budobj%write_flowtable(this%dis,
kstp,
kper)
984 integer(I4B),
intent(in) :: idvsave
985 integer(I4B),
intent(in) :: idvprint
987 integer(I4B) :: ibinun
990 character(len=LENBUDTXT) :: text
994 if (this%iconcout /= 0)
then
995 ibinun = this%iconcout
997 if (idvsave == 0) ibinun = 0
1000 if (ibinun > 0)
then
1003 if (this%iboundpak(n) == 0)
then
1008 write (text,
'(a)') str_pad_left(this%depvartype, lenvarname)
1010 this%ncv, 1, 1, ibinun)
1014 if (idvprint /= 0 .and. this%iprconc /= 0)
then
1017 call this%dvtab%set_kstpkper(
kstp,
kper)
1021 if (this%inamedbound == 1)
then
1022 call this%dvtab%add_term(this%featname(n))
1024 call this%dvtab%add_term(n)
1025 call this%dvtab%add_term(this%xnewpak(n))
1037 integer(I4B),
intent(in) :: kstp
1038 integer(I4B),
intent(in) :: kper
1039 integer(I4B),
intent(in) :: iout
1040 integer(I4B),
intent(in) :: ibudfl
1042 call this%budobj%write_budtable(kstp, kper, iout, ibudfl,
totim,
delt)
1057 call this%BndType%allocate_scalars()
1060 call mem_allocate(this%iauxfpconc,
'IAUXFPCONC', this%memoryPath)
1061 call mem_allocate(this%imatrows,
'IMATROWS', this%memoryPath)
1062 call mem_allocate(this%iprconc,
'IPRCONC', this%memoryPath)
1063 call mem_allocate(this%iconcout,
'ICONCOUT', this%memoryPath)
1064 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
1065 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
1066 call mem_allocate(this%igwfaptpak,
'IGWFAPTPAK', this%memoryPath)
1068 call mem_allocate(this%idxbudfjf,
'IDXBUDFJF', this%memoryPath)
1069 call mem_allocate(this%idxbudgwf,
'IDXBUDGWF', this%memoryPath)
1070 call mem_allocate(this%idxbudsto,
'IDXBUDSTO', this%memoryPath)
1071 call mem_allocate(this%idxbudtmvr,
'IDXBUDTMVR', this%memoryPath)
1072 call mem_allocate(this%idxbudfmvr,
'IDXBUDFMVR', this%memoryPath)
1073 call mem_allocate(this%idxbudaux,
'IDXBUDAUX', this%memoryPath)
1074 call mem_allocate(this%nconcbudssm,
'NCONCBUDSSM', this%memoryPath)
1075 call mem_allocate(this%idxprepak,
'IDXPREPAK', this%memoryPath)
1076 call mem_allocate(this%idxlastpak,
'IDXLASTPAK', this%memoryPath)
1093 this%nconcbudssm = 0
1113 if (this%imatrows /= 0)
then
1117 if (this%idxbudfjf /= 0)
then
1118 n = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1122 call mem_allocate(this%idxlocnode, this%ncv,
'IDXLOCNODE', &
1124 call mem_allocate(this%idxpakdiag, this%ncv,
'IDXPAKDIAG', &
1126 call mem_allocate(this%idxdglo, this%maxbound,
'IDXGLO', &
1128 call mem_allocate(this%idxoffdglo, this%maxbound,
'IDXOFFDGLO', &
1130 call mem_allocate(this%idxsymdglo, this%maxbound,
'IDXSYMDGLO', &
1132 call mem_allocate(this%idxsymoffdglo, this%maxbound,
'IDXSYMOFFDGLO', &
1136 call mem_allocate(this%idxfjfoffdglo, n,
'IDXFJFOFFDGLO', &
1149 call mem_allocate(this%idxsymoffdglo, 0,
'IDXSYMOFFDGLO', &
1153 call mem_allocate(this%idxfjfoffdglo, 0,
'IDXFJFOFFDGLO', &
1171 call this%BndType%allocate_arrays()
1176 if (this%iconcout > 0)
then
1177 call mem_allocate(this%dbuff, this%ncv,
'DBUFF', this%memoryPath)
1179 this%dbuff(n) =
dzero
1182 call mem_allocate(this%dbuff, 0,
'DBUFF', this%memoryPath)
1186 allocate (this%status(this%ncv))
1189 call mem_allocate(this%concfeat, this%ncv,
'CONCFEAT', this%memoryPath)
1192 call mem_allocate(this%qsto, this%ncv,
'QSTO', this%memoryPath)
1193 call mem_allocate(this%ccterm, this%ncv,
'CCTERM', this%memoryPath)
1196 call mem_allocate(this%concbudssm, this%nconcbudssm, this%ncv, &
1197 'CONCBUDSSM', this%memoryPath)
1200 call mem_allocate(this%qmfrommvr, this%ncv,
'QMFROMMVR', this%memoryPath)
1204 this%status(n) =
'ACTIVE'
1205 this%qsto(n) =
dzero
1206 this%ccterm(n) =
dzero
1207 this%qmfrommvr(n) =
dzero
1208 this%concbudssm(:, n) =
dzero
1209 this%concfeat(n) =
dzero
1233 if (this%imatrows == 0)
then
1240 deallocate (this%status)
1241 deallocate (this%featname)
1244 call this%budobj%budgetobject_da()
1245 deallocate (this%budobj)
1246 nullify (this%budobj)
1249 if (this%iprconc > 0)
then
1250 call this%dvtab%table_da()
1251 deallocate (this%dvtab)
1252 nullify (this%dvtab)
1286 call this%BndType%bnd_da()
1299 call store_error(
'Program error: pak_solve not implemented.', &
1313 character(len=*),
intent(inout) :: option
1314 logical,
intent(inout) :: found
1316 character(len=MAXCHARLEN) :: fname, keyword
1318 character(len=*),
parameter :: fmtaptbin = &
1319 "(4x, a, 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, &
1320 &/4x, 'OPENED ON UNIT: ', I0)"
1323 select case (option)
1324 case (
'FLOW_PACKAGE_NAME')
1325 call this%parser%GetStringCaps(this%flowpackagename)
1326 write (this%iout,
'(4x,a)') &
1327 'THIS '//trim(adjustl(this%text))//
' PACKAGE CORRESPONDS TO A GWF &
1328 &PACKAGE WITH THE NAME '//trim(adjustl(this%flowpackagename))
1329 case (
'FLOW_PACKAGE_AUXILIARY_NAME')
1330 call this%parser%GetStringCaps(this%cauxfpconc)
1331 write (this%iout,
'(4x,a)') &
1332 'SIMULATED CONCENTRATIONS WILL BE COPIED INTO THE FLOW PACKAGE &
1333 &AUXILIARY VARIABLE WITH THE NAME '//trim(adjustl(this%cauxfpconc))
1334 case (
'DEV_NONEXPANDING_MATRIX')
1339 call this%parser%DevOpt()
1341 write (this%iout,
'(4x,a)') &
1342 trim(adjustl(this%text))// &
1343 ' WILL NOT ADD ADDITIONAL ROWS TO THE A MATRIX.'
1344 case (
'PRINT_CONCENTRATION',
'PRINT_TEMPERATURE')
1346 write (this%iout,
'(4x,a,1x,a,1x,a)') trim(adjustl(this%text))// &
1347 trim(adjustl(this%depvartype))//
'S WILL BE PRINTED TO LISTING &
1349 case (
'CONCENTRATION',
'TEMPERATURE')
1350 call this%parser%GetStringCaps(keyword)
1351 if (keyword ==
'FILEOUT')
then
1352 call this%parser%GetString(fname)
1354 call openfile(this%iconcout, this%iout, fname,
'DATA(BINARY)', &
1356 write (this%iout, fmtaptbin) &
1357 trim(adjustl(this%text)), trim(adjustl(this%depvartype)), &
1358 trim(fname), this%iconcout
1360 write (
errmsg,
"('Optional', 1x, a, 1X, 'keyword must &
1361 &be followed by FILEOUT')") this%depvartype
1365 call this%parser%GetStringCaps(keyword)
1366 if (keyword ==
'FILEOUT')
then
1367 call this%parser%GetString(fname)
1369 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
1371 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET', &
1372 trim(fname), this%ibudgetout
1374 call store_error(
'Optional BUDGET keyword must be followed by FILEOUT')
1377 call this%parser%GetStringCaps(keyword)
1378 if (keyword ==
'FILEOUT')
then
1379 call this%parser%GetString(fname)
1381 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
1382 filstat_opt=
'REPLACE')
1383 write (this%iout, fmtaptbin) trim(adjustl(this%text)),
'BUDGET CSV', &
1384 trim(fname), this%ibudcsv
1386 call store_error(
'Optional BUDGETCSV keyword must be followed by &
1402 integer(I4B) :: ierr
1406 if (this%flowpackagename ==
'')
then
1407 this%flowpackagename = this%packName
1408 write (this%iout,
'(4x,a)') &
1409 'THE FLOW PACKAGE NAME FOR '//trim(adjustl(this%text))//
' WAS NOT &
1410 &SPECIFIED. SETTING FLOW PACKAGE NAME TO '// &
1411 &trim(adjustl(this%flowpackagename))
1414 call this%find_apt_package()
1417 this%ncv = this%flowbudptr%ncv
1418 this%maxbound = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1419 this%nbound = this%maxbound
1420 write (this%iout,
'(a, a)')
'SETTING DIMENSIONS FOR PACKAGE ', this%packName
1421 write (this%iout,
'(2x,a,i0)')
'NUMBER OF CONTROL VOLUMES = ', this%ncv
1422 write (this%iout,
'(2x,a,i0)')
'MAXBOUND = ', this%maxbound
1423 write (this%iout,
'(2x,a,i0)')
'NBOUND = ', this%nbound
1424 if (this%imatrows /= 0)
then
1425 this%npakeq = this%ncv
1426 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1427 ' SOLVED AS PART OF GWT MATRIX EQUATIONS'
1429 write (this%iout,
'(2x,a)') trim(adjustl(this%text))// &
1430 ' SOLVED SEPARATELY FROM GWT MATRIX EQUATIONS '
1432 write (this%iout,
'(a, //)')
'DONE SETTING DIMENSIONS FOR '// &
1433 trim(adjustl(this%text))
1436 if (this%ncv < 0)
then
1438 'Number of control volumes could not be determined correctly.'
1449 call this%apt_read_cvs()
1453 call this%define_listlabel()
1456 call this%apt_setup_budobj()
1459 call this%apt_setup_tableobj()
1471 character(len=LINELENGTH) :: text
1472 character(len=LENBOUNDNAME) :: bndName, bndNameTemp
1473 character(len=9) :: cno
1474 character(len=50),
dimension(:),
allocatable :: caux
1475 integer(I4B) :: ierr
1476 logical :: isfound, endOfBlock
1478 integer(I4B) :: ii, jj
1479 integer(I4B) :: iaux
1480 integer(I4B) :: itmp
1481 integer(I4B) :: nlak
1482 integer(I4B) :: nconn
1483 integer(I4B),
dimension(:),
pointer,
contiguous :: nboundchk
1484 real(DP),
pointer :: bndElem => null()
1490 call mem_allocate(this%strt, this%ncv,
'STRT', this%memoryPath)
1491 call mem_allocate(this%ktf, this%ncv,
'KTF', this%memoryPath)
1492 call mem_allocate(this%rfeatthk, this%ncv,
'RFEATTHK', this%memoryPath)
1493 call mem_allocate(this%lauxvar, this%naux, this%ncv,
'LAUXVAR', &
1497 if (this%imatrows == 0)
then
1498 call mem_allocate(this%iboundpak, this%ncv,
'IBOUND', this%memoryPath)
1499 call mem_allocate(this%xnewpak, this%ncv,
'XNEWPAK', this%memoryPath)
1501 call mem_allocate(this%xoldpak, this%ncv,
'XOLDPAK', this%memoryPath)
1504 allocate (this%featname(this%ncv))
1508 this%strt(n) =
dep20
1510 this%rfeatthk(n) =
dzero
1511 this%lauxvar(:, n) =
dzero
1512 this%xoldpak(n) =
dep20
1513 if (this%imatrows == 0)
then
1514 this%iboundpak(n) = 1
1515 this%xnewpak(n) =
dep20
1520 if (this%naux > 0)
then
1521 allocate (caux(this%naux))
1525 allocate (nboundchk(this%ncv))
1531 call this%parser%GetBlock(
'PACKAGEDATA', isfound, ierr, &
1532 supportopenclose=.true.)
1536 write (this%iout,
'(/1x,a)')
'PROCESSING '//trim(adjustl(this%text))// &
1541 call this%parser%GetNextLine(endofblock)
1542 if (endofblock)
exit
1543 n = this%parser%GetInteger()
1545 if (n < 1 .or. n > this%ncv)
then
1546 write (
errmsg,
'(a,1x,i6)') &
1547 'Itemno must be > 0 and <= ', this%ncv
1553 nboundchk(n) = nboundchk(n) + 1
1556 this%strt(n) = this%parser%GetDouble()
1559 if (this%depvartype ==
'TEMPERATURE')
then
1561 if (trim(adjustl(this%text)) /=
'UZE')
then
1562 this%ktf(n) = this%parser%GetDouble()
1563 this%rfeatthk(n) = this%parser%GetDouble()
1564 if (this%rfeatthk(n) <=
dzero)
then
1565 write (
errmsg,
'(4x,a)') &
1566 '****ERROR. Specified thickness used for thermal &
1567 &conduction MUST BE > 0 else divide by zero error occurs'
1575 do iaux = 1, this%naux
1576 call this%parser%GetString(caux(iaux))
1580 write (cno,
'(i9.9)') n
1581 bndname =
'Feature'//cno
1584 if (this%inamedbound /= 0)
then
1585 call this%parser%GetStringCaps(bndnametemp)
1586 if (bndnametemp /=
'')
then
1587 bndname = bndnametemp
1590 this%featname(n) = bndname
1594 do jj = 1, this%naux
1597 bndelem => this%lauxvar(jj, ii)
1599 this%packName,
'AUX', &
1600 this%tsManager, this%iprpak, &
1609 if (nboundchk(n) == 0)
then
1610 write (
errmsg,
'(a,1x,i0)')
'No data specified for feature', n
1612 else if (nboundchk(n) > 1)
then
1613 write (
errmsg,
'(a,1x,i0,1x,a,1x,i0,1x,a)') &
1614 'Data for feature', n,
'specified', nboundchk(n),
'times'
1619 write (this%iout,
'(1x,a)') &
1620 'END OF '//trim(adjustl(this%text))//
' PACKAGEDATA'
1622 call store_error(
'Required packagedata block not found.')
1627 call this%parser%StoreErrorUnit()
1631 if (this%naux > 0)
then
1636 deallocate (nboundchk)
1648 integer(I4B) :: j, n
1654 this%xnewpak(n) = this%strt(n)
1663 if (this%status(n) ==
'CONSTANT')
then
1664 this%iboundpak(n) = -1
1665 else if (this%status(n) ==
'INACTIVE')
then
1666 this%iboundpak(n) = 0
1667 else if (this%status(n) ==
'ACTIVE ')
then
1668 this%iboundpak(n) = 1
1673 if (this%inamedbound /= 0)
then
1674 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1675 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1676 this%boundname(j) = this%featname(n)
1681 call this%copy_boundname()
1695 integer(I4B) :: n, j, igwfnode
1696 integer(I4B) :: n1, n2
1699 real(DP) :: c1, qbnd
1700 real(DP) :: hcofval, rhsval
1704 this%dbuff(n) = dzero
1709 call this%pak_solve()
1712 if (this%idxbudtmvr /= 0)
then
1713 do j = 1, this%flowbudptr%budterm(this%idxbudtmvr)%nlist
1714 call this%apt_tmvr_term(j, n1, n2, rrate)
1715 this%dbuff(n1) = this%dbuff(n1) + rrate
1720 if (this%idxbudfmvr /= 0)
then
1721 do n1 = 1,
size(this%qmfrommvr)
1722 rrate = this%qmfrommvr(n1)
1723 this%dbuff(n1) = this%dbuff(n1) + rrate
1729 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
1730 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
1731 this%hcof(j) = dzero
1733 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
1734 qbnd = this%flowbudptr%budterm(this%idxbudgwf)%flow(j)
1735 if (qbnd <= dzero)
then
1736 ctmp = this%xnewpak(n)
1737 this%rhs(j) = qbnd * ctmp * this%eqnsclfac
1739 ctmp = this%xnew(igwfnode)
1740 this%hcof(j) = -qbnd * this%eqnsclfac
1742 c1 = qbnd * ctmp * this%eqnsclfac
1743 this%dbuff(n) = this%dbuff(n) + c1
1748 if (this%idxbudfjf /= 0)
then
1749 do j = 1, this%flowbudptr%budterm(this%idxbudfjf)%nlist
1750 call this%apt_fjf_term(j, n1, n2, rrate)
1752 this%dbuff(n1) = this%dbuff(n1) + c1
1758 call this%apt_stor_term(n, n1, n2, rrate, rhsval, hcofval)
1762 this%dbuff(n) = this%dbuff(n) - rhsval
1765 c1 = -this%dbuff(n) / hcofval
1766 if (this%iboundpak(n) > 0)
then
1767 this%xnewpak(n) = c1
1783 call store_error(
'Program error: pak_solve not implemented.', &
1792 integer(I4B),
intent(in) :: ilak
1793 real(DP),
intent(in) :: rrate
1794 real(DP),
intent(inout) :: ccratin
1795 real(DP),
intent(inout) :: ccratout
1801 if (this%iboundpak(ilak) < 0)
then
1803 this%ccterm(ilak) = this%ccterm(ilak) + q
1809 ccratout = ccratout - q
1813 ccratin = ccratin + q
1825 this%listlabel = trim(this%filtyp)//
' NO.'
1826 if (this%dis%ndim == 3)
then
1827 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1828 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'ROW'
1829 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'COL'
1830 elseif (this%dis%ndim == 2)
then
1831 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'LAYER'
1832 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'CELL2D'
1834 write (this%listlabel,
'(a, a7)') trim(this%listlabel),
'NODE'
1836 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'STRESS RATE'
1837 if (this%inamedbound == 1)
then
1838 write (this%listlabel,
'(a, a16)') trim(this%listlabel),
'BOUNDARY NAME'
1847 integer(I4B),
pointer :: neq
1848 integer(I4B),
dimension(:),
pointer,
contiguous :: ibound
1849 real(DP),
dimension(:),
pointer,
contiguous :: xnew
1850 real(DP),
dimension(:),
pointer,
contiguous :: xold
1851 real(DP),
dimension(:),
pointer,
contiguous :: flowja
1853 integer(I4B) :: istart, iend
1856 call this%BndType%set_pointers(neq, ibound, xnew, xold, flowja)
1861 if (this%imatrows /= 0)
then
1862 istart = this%dis%nodes + this%ioffset + 1
1863 iend = istart + this%ncv - 1
1864 this%iboundpak => this%ibound(istart:iend)
1865 this%xnewpak => this%xnew(istart:iend)
1875 integer(I4B),
intent(in) :: icv
1876 real(DP),
intent(inout) :: vnew, vold
1877 real(DP),
intent(in) :: delt
1884 if (this%idxbudsto /= 0)
then
1885 qss = this%flowbudptr%budterm(this%idxbudsto)%flow(icv)
1886 vnew = this%flowbudptr%budterm(this%idxbudsto)%auxvar(1, icv)
1887 vold = vnew + qss * delt
1900 integer(I4B) :: nbudterms
1904 call store_error(
'Program error: pak_get_nbudterms not implemented.', &
1917 integer(I4B) :: nbudterm
1918 integer(I4B) :: nlen
1919 integer(I4B) :: n, n1, n2
1920 integer(I4B) :: maxlist, naux
1922 logical :: ordered_id1
1924 character(len=LENBUDTXT) :: bddim_opt
1925 character(len=LENBUDTXT) :: text, textt
1926 character(len=LENBUDTXT),
dimension(1) :: auxtxt
1933 if (this%idxbudfjf /= 0)
then
1934 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1941 if (this%idxbudfjf /= 0) nbudterm = nbudterm + 1
1944 nbudterm = nbudterm + 3
1947 nbudterm = nbudterm + this%pak_get_nbudterms()
1950 if (this%idxbudtmvr /= 0) nbudterm = nbudterm + 1
1951 if (this%idxbudfmvr /= 0) nbudterm = nbudterm + 1
1952 if (this%naux > 0) nbudterm = nbudterm + 1
1957 bddim_opt = this%depvarunitabbrev
1958 call this%budobj%budgetobject_df(this%ncv, nbudterm, 0, 0, &
1959 bddim_opt=bddim_opt, ibudcsv=this%ibudcsv)
1964 text =
' FLOW-JA-FACE'
1966 maxlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
1968 ordered_id1 = this%flowbudptr%budterm(this%idxbudfjf)%ordered_id1
1969 call this%budobj%budterm(idx)%initialize(text, &
1974 maxlist, .false., .false., &
1975 naux, ordered_id1=ordered_id1)
1978 call this%budobj%budterm(idx)%reset(maxlist)
1981 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(n)
1982 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(n)
1983 call this%budobj%budterm(idx)%update_term(n1, n2, q)
1990 maxlist = this%flowbudptr%budterm(this%idxbudgwf)%maxlist
1992 call this%budobj%budterm(idx)%initialize(text, &
1997 maxlist, .false., .true., &
1999 call this%budobj%budterm(idx)%reset(maxlist)
2002 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(n)
2003 n2 = this%flowbudptr%budterm(this%idxbudgwf)%id2(n)
2004 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2008 this%idxprepak = idx
2009 call this%pak_setup_budobj(idx)
2010 this%idxlastpak = idx
2015 maxlist = this%flowbudptr%budterm(this%idxbudsto)%maxlist
2019 call this%budobj%budterm(idx)%initialize(text, &
2024 maxlist, .false., .false., &
2026 if (this%idxbudtmvr /= 0)
then
2031 maxlist = this%flowbudptr%budterm(this%idxbudtmvr)%maxlist
2033 ordered_id1 = this%flowbudptr%budterm(this%idxbudtmvr)%ordered_id1
2034 call this%budobj%budterm(idx)%initialize(text, &
2039 maxlist, .false., .false., &
2040 naux, ordered_id1=ordered_id1)
2042 if (this%idxbudfmvr /= 0)
then
2049 call this%budobj%budterm(idx)%initialize(text, &
2054 maxlist, .false., .false., &
2063 call this%budobj%budterm(idx)%initialize(text, &
2068 maxlist, .false., .false., &
2080 call this%budobj%budterm(idx)%initialize(text, &
2085 maxlist, .false., .false., &
2090 if (this%iprflow /= 0)
then
2091 call this%budobj%flowtable_df(this%iout)
2103 integer(I4B),
intent(inout) :: idx
2107 call store_error(
'Program error: pak_setup_budobj not implemented.', &
2118 real(DP),
dimension(:),
intent(in) :: x
2119 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2121 integer(I4B) :: naux
2122 real(DP),
dimension(:),
allocatable :: auxvartmp
2123 integer(I4B) :: i, j, n1, n2
2125 integer(I4B) :: nlen
2126 integer(I4B) :: nlist
2127 integer(I4B) :: igwfnode
2130 real(DP) :: ccratin, ccratout
2141 this%ccterm(n1) =
dzero
2146 if (this%idxbudfjf /= 0)
then
2147 nlen = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2151 nlist = this%flowbudptr%budterm(this%idxbudfjf)%maxlist
2152 call this%budobj%budterm(idx)%reset(nlist)
2155 call this%apt_fjf_term(j, n1, n2, q)
2156 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2157 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2163 call this%budobj%budterm(idx)%reset(this%maxbound)
2164 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2166 n1 = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2167 if (this%iboundpak(n1) /= 0)
then
2168 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(j)
2169 q = this%hcof(j) * x(igwfnode) - this%rhs(j)
2172 call this%budobj%budterm(idx)%update_term(n1, igwfnode, q)
2173 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2178 idx = this%idxlastpak
2182 call this%budobj%budterm(idx)%reset(this%ncv)
2183 allocate (auxvartmp(1))
2185 call this%get_volumes(n1, v1, v0,
delt)
2186 auxvartmp(1) = v1 * this%xnewpak(n1)
2188 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2189 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2191 deallocate (auxvartmp)
2194 if (this%idxbudtmvr /= 0)
then
2196 nlist = this%flowbudptr%budterm(this%idxbudtmvr)%nlist
2197 call this%budobj%budterm(idx)%reset(nlist)
2199 call this%apt_tmvr_term(j, n1, n2, q)
2200 call this%budobj%budterm(idx)%update_term(n1, n2, q)
2201 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2206 if (this%idxbudfmvr /= 0)
then
2209 call this%budobj%budterm(idx)%reset(nlist)
2211 call this%apt_fmvr_term(j, n1, n2, q)
2212 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2213 call this%apt_accumulate_ccterm(n1, q, ccratin, ccratout)
2219 call this%budobj%budterm(idx)%reset(this%ncv)
2222 call this%budobj%budterm(idx)%update_term(n1, n1, q)
2229 allocate (auxvartmp(naux))
2230 call this%budobj%budterm(idx)%reset(this%ncv)
2234 auxvartmp(i) = this%lauxvar(i, n1)
2236 call this%budobj%budterm(idx)%update_term(n1, n1, q, auxvartmp)
2238 deallocate (auxvartmp)
2242 idx = this%idxprepak
2243 call this%pak_fill_budobj(idx, x, flowja, ccratin, ccratout)
2246 call this%budobj%accumulate_terms()
2255 integer(I4B),
intent(inout) :: idx
2256 real(DP),
dimension(:),
intent(in) :: x
2257 real(DP),
dimension(:),
contiguous,
intent(inout) :: flowja
2258 real(DP),
intent(inout) :: ccratin
2259 real(DP),
intent(inout) :: ccratout
2264 call store_error(
'Program error: pak_fill_budobj not implemented.', &
2274 integer(I4B),
intent(in) :: ientry
2275 integer(I4B),
intent(inout) :: n1
2276 integer(I4B),
intent(inout) :: n2
2277 real(DP),
intent(inout),
optional :: rrate
2278 real(DP),
intent(inout),
optional :: rhsval
2279 real(DP),
intent(inout),
optional :: hcofval
2285 call this%get_volumes(n1, v1, v0,
delt)
2286 c0 = this%xoldpak(n1)
2287 c1 = this%xnewpak(n1)
2288 if (
present(rrate))
then
2289 rrate = (-c1 * v1 /
delt + c0 * v0 /
delt) * this%eqnsclfac
2291 if (
present(rhsval)) rhsval = -c0 * v0 * this%eqnsclfac /
delt
2292 if (
present(hcofval)) hcofval = -v1 * this%eqnsclfac /
delt
2302 integer(I4B),
intent(in) :: ientry
2303 integer(I4B),
intent(inout) :: n1
2304 integer(I4B),
intent(inout) :: n2
2305 real(DP),
intent(inout),
optional :: rrate
2306 real(DP),
intent(inout),
optional :: rhsval
2307 real(DP),
intent(inout),
optional :: hcofval
2313 n1 = this%flowbudptr%budterm(this%idxbudtmvr)%id1(ientry)
2314 n2 = this%flowbudptr%budterm(this%idxbudtmvr)%id2(ientry)
2315 qbnd = this%flowbudptr%budterm(this%idxbudtmvr)%flow(ientry)
2316 ctmp = this%xnewpak(n1)
2317 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2318 if (
present(rhsval)) rhsval =
dzero
2319 if (
present(hcofval)) hcofval = qbnd * this%eqnsclfac
2330 integer(I4B),
intent(in) :: ientry
2331 integer(I4B),
intent(inout) :: n1
2332 integer(I4B),
intent(inout) :: n2
2333 real(DP),
intent(inout),
optional :: rrate
2334 real(DP),
intent(inout),
optional :: rhsval
2335 real(DP),
intent(inout),
optional :: hcofval
2340 if (
present(rrate)) rrate = this%qmfrommvr(n1)
2341 if (
present(rhsval)) rhsval = this%qmfrommvr(n1)
2342 if (
present(hcofval)) hcofval =
dzero
2353 integer(I4B),
intent(in) :: ientry
2354 integer(I4B),
intent(inout) :: n1
2355 integer(I4B),
intent(inout) :: n2
2356 real(DP),
intent(inout),
optional :: rrate
2357 real(DP),
intent(inout),
optional :: rhsval
2358 real(DP),
intent(inout),
optional :: hcofval
2363 n1 = this%flowbudptr%budterm(this%idxbudfjf)%id1(ientry)
2364 n2 = this%flowbudptr%budterm(this%idxbudfjf)%id2(ientry)
2365 qbnd = this%flowbudptr%budterm(this%idxbudfjf)%flow(ientry)
2367 ctmp = this%xnewpak(n1)
2369 ctmp = this%xnewpak(n2)
2371 if (
present(rrate)) rrate = ctmp * qbnd * this%eqnsclfac
2372 if (
present(rhsval)) rhsval = -rrate * this%eqnsclfac
2373 if (
present(hcofval)) hcofval =
dzero
2384 integer(I4B) :: n, j
2387 if (this%iauxfpconc /= 0)
then
2390 do j = 1, this%flowbudptr%budterm(this%idxbudgwf)%nlist
2393 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(j)
2394 this%flowpackagebnd%auxvar(this%iauxfpconc, j) = this%xnewpak(n)
2427 call this%pak_df_obs()
2442 call store_error(
'Program error: pak_df_obs not implemented.', &
2454 logical,
intent(inout) :: found
2458 call store_error(
'Program error: pak_rp_obs not implemented.', &
2473 character(len=*),
parameter :: fmterr = &
2474 "('Boundary ', a, ' for observation ', a, &
2475 &' is invalid in package ', a)"
2476 nn1 = obsrv%NodeNumber
2480 if (this%featname(j) == obsrv%FeatureName)
then
2482 call obsrv%AddObsIndex(j)
2485 if (.not. jfound)
then
2486 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2493 if (nn1 < 0 .or. nn1 > this%ncv)
then
2494 write (
errmsg,
'(7a, i0, a, i0, a)') &
2495 'Observation ', trim(obsrv%Name),
' of type ', &
2496 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2497 trim(this%packName),
' was assigned ID = ', nn1, &
2498 '. ID must be >= 1 and <= ', this%ncv,
'.'
2501 call obsrv%AddObsIndex(nn1)
2515 integer(I4B) :: iconn
2520 character(len=*),
parameter :: fmterr = &
2521 "('Boundary ', a, ' for observation ', a, &
2522 &' is invalid in package ', a)"
2523 nn1 = obsrv%NodeNumber
2526 do j = 1, budterm%nlist
2527 icv = budterm%id1(j)
2528 if (this%featname(icv) == obsrv%FeatureName)
then
2530 call obsrv%AddObsIndex(j)
2533 if (.not. jfound)
then
2534 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2541 if (nn1 < 0 .or. nn1 > this%ncv)
then
2542 write (
errmsg,
'(7a, i0, a, i0, a)') &
2543 'Observation ', trim(obsrv%Name),
' of type ', &
2544 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2545 trim(this%packName),
' was assigned ID = ', nn1, &
2546 '. ID must be >= 1 and <= ', this%ncv,
'.'
2549 iconn = obsrv%NodeNumber2
2550 do j = 1, budterm%nlist
2551 if (budterm%id1(j) == nn1)
then
2555 call obsrv%AddObsIndex(idx)
2559 if (idx < 1 .or. idx > budterm%nlist)
then
2560 write (
errmsg,
'(7a, i0, a, i0, a)') &
2561 'Observation ', trim(obsrv%Name),
' of type ', &
2562 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2563 trim(this%packName),
' specifies iconn = ', iconn, &
2564 ', but this is not a valid connection for ID ', nn1,
'.'
2566 else if (budterm%id1(idx) /= nn1)
then
2567 write (
errmsg,
'(7a, i0, a, i0, a)') &
2568 'Observation ', trim(obsrv%Name),
' of type ', &
2569 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2570 trim(this%packName),
' specifies iconn = ', iconn, &
2571 ', but this is not a valid connection for ID ', nn1,
'.'
2591 character(len=*),
parameter :: fmterr = &
2592 "('Boundary ', a, ' for observation ', a, &
2593 &' is invalid in package ', a)"
2594 nn1 = obsrv%NodeNumber
2597 do j = 1, budterm%nlist
2598 icv = budterm%id1(j)
2599 if (this%featname(icv) == obsrv%FeatureName)
then
2601 call obsrv%AddObsIndex(j)
2604 if (.not. jfound)
then
2605 write (
errmsg, fmterr) trim(obsrv%FeatureName), trim(obsrv%Name), &
2612 if (nn1 < 0 .or. nn1 > this%ncv)
then
2613 write (
errmsg,
'(7a, i0, a, i0, a)') &
2614 'Observation ', trim(obsrv%Name),
' of type ', &
2615 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2616 trim(this%packName),
' was assigned ID = ', nn1, &
2617 '. ID must be >= 1 and <= ', this%ncv,
'.'
2620 nn2 = obsrv%NodeNumber2
2623 if (nn2 < 0 .or. nn2 > this%ncv)
then
2624 write (
errmsg,
'(7a, i0, a, i0, a)') &
2625 'Observation ', trim(obsrv%Name),
' of type ', &
2626 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2627 trim(this%packName),
' was assigned ID2 = ', nn2, &
2628 '. ID must be >= 1 and <= ', this%ncv,
'.'
2633 do j = 1, budterm%nlist
2634 if (budterm%id1(j) == nn1 .and. budterm%id2(j) == nn2)
then
2635 call obsrv%AddObsIndex(j)
2639 if (.not. jfound)
then
2640 write (
errmsg,
'(7a, i0, a, i0, a)') &
2641 'Observation ', trim(obsrv%Name),
' of type ', &
2642 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2643 trim(this%packName), &
2644 ' specifies a connection between feature ', nn1, &
2645 ' feature ', nn2,
', but these features are not connected.'
2666 do i = 1, this%obs%npakobs
2667 obsrv => this%obs%pakobs(i)%obsrv
2668 select case (obsrv%ObsTypeId)
2669 case (
'CONCENTRATION',
'TEMPERATURE')
2670 call this%rp_obs_byfeature(obsrv)
2674 if (obsrv%indxbnds_count > 1)
then
2675 write (
errmsg,
'(a, a, a, a)') &
2676 trim(adjustl(this%depvartype))// &
2677 ' for observation', trim(adjustl(obsrv%Name)), &
2678 ' must be assigned to a feature with a unique boundname.'
2681 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2682 call this%rp_obs_budterm(obsrv, &
2683 this%flowbudptr%budterm(this%idxbudgwf))
2684 case (
'FLOW-JA-FACE')
2685 if (this%idxbudfjf > 0)
then
2686 call this%rp_obs_flowjaface(obsrv, &
2687 this%flowbudptr%budterm(this%idxbudfjf))
2690 'Observation ', trim(obsrv%Name),
' of type ', &
2691 trim(adjustl(obsrv%ObsTypeId)),
' in package ', &
2692 trim(this%packName), &
2693 ' cannot be processed because there are no flow connections.'
2697 call this%rp_obs_byfeature(obsrv)
2699 call this%rp_obs_byfeature(obsrv)
2701 call this%rp_obs_byfeature(obsrv)
2706 call this%pak_rp_obs(obsrv, found)
2709 if (.not. found)
then
2710 errmsg =
'Unrecognized observation type "'// &
2711 trim(obsrv%ObsTypeId)//
'" for '// &
2712 trim(adjustl(this%text))//
' package '// &
2739 integer(I4B) :: igwfnode
2750 if (this%obs%npakobs > 0)
then
2751 call this%obs%obs_bd_clear()
2752 do i = 1, this%obs%npakobs
2753 obsrv => this%obs%pakobs(i)%obsrv
2754 do j = 1, obsrv%indxbnds_count
2756 jj = obsrv%indxbnds(j)
2757 select case (obsrv%ObsTypeId)
2758 case (
'CONCENTRATION',
'TEMPERATURE')
2759 if (this%iboundpak(jj) /= 0)
then
2760 v = this%xnewpak(jj)
2762 case (
'LKT',
'SFT',
'MWT',
'UZT',
'LKE',
'SFE',
'MWE',
'UZE')
2763 n = this%flowbudptr%budterm(this%idxbudgwf)%id1(jj)
2764 if (this%iboundpak(n) /= 0)
then
2765 igwfnode = this%flowbudptr%budterm(this%idxbudgwf)%id2(jj)
2766 v = this%hcof(jj) * this%xnew(igwfnode) - this%rhs(jj)
2769 case (
'FLOW-JA-FACE')
2770 n = this%flowbudptr%budterm(this%idxbudfjf)%id1(jj)
2771 if (this%iboundpak(n) /= 0)
then
2772 call this%apt_fjf_term(jj, n1, n2, v)
2775 if (this%iboundpak(jj) /= 0)
then
2779 if (this%iboundpak(jj) /= 0)
then
2783 if (this%iboundpak(jj) /= 0 .and. this%idxbudfmvr > 0)
then
2784 call this%apt_fmvr_term(jj, n1, n2, v)
2787 if (this%idxbudtmvr > 0)
then
2788 n = this%flowbudptr%budterm(this%idxbudtmvr)%id1(jj)
2789 if (this%iboundpak(n) /= 0)
then
2790 call this%apt_tmvr_term(jj, n1, n2, v)
2797 call this%pak_bd_obs(obsrv%ObsTypeId, jj, v, found)
2800 if (.not. found)
then
2801 errmsg =
'Unrecognized observation type "'// &
2802 trim(obsrv%ObsTypeId)//
'" for '// &
2803 trim(adjustl(this%text))//
' package '// &
2808 call this%obs%SaveOneSimval(obsrv, v)
2824 character(len=*),
intent(in) :: obstypeid
2825 integer(I4B),
intent(in) :: jj
2826 real(DP),
intent(inout) :: v
2827 logical,
intent(inout) :: found
2844 integer(I4B),
intent(in) :: inunitobs
2845 integer(I4B),
intent(in) :: iout
2848 integer(I4B) :: icol
2849 integer(I4B) :: istart
2850 integer(I4B) :: istop
2851 character(len=LINELENGTH) :: string
2852 character(len=LENBOUNDNAME) :: bndname
2855 string = obsrv%IDstring
2865 obsrv%FeatureName = bndname
2869 obsrv%NodeNumber = nn1
2874 obsrv%NodeNumber2 = 1
2887 integer(I4B),
intent(in) :: inunitobs
2888 integer(I4B),
intent(in) :: iout
2891 integer(I4B) :: iconn
2892 integer(I4B) :: icol
2893 integer(I4B) :: istart
2894 integer(I4B) :: istop
2895 character(len=LINELENGTH) :: string
2896 character(len=LENBOUNDNAME) :: bndname
2899 string = obsrv%IDstring
2909 obsrv%FeatureName = bndname
2912 if (len_trim(bndname) < 1 .and. iconn < 0)
then
2913 write (
errmsg,
'(a,1x,a,a,1x,a,1x,a)') &
2914 'For observation type', trim(adjustl(obsrv%ObsTypeId)), &
2915 ', ID given as an integer and not as boundname,', &
2916 'but ID2 is missing. Either change ID to valid', &
2917 'boundname or supply valid entry for ID2.'
2920 obsrv%NodeNumber2 = iconn
2924 obsrv%NodeNumber = nn1
2939 integer(I4B) :: nterms
2940 character(len=LINELENGTH) :: title
2941 character(len=LINELENGTH) :: text_temp
2944 if (this%iprconc > 0)
then
2948 if (this%inamedbound == 1) nterms = nterms + 1
2951 title = trim(adjustl(this%text))//
' PACKAGE ('// &
2952 trim(adjustl(this%packName))// &
2953 ') '//trim(adjustl(this%depvartype))// &
2954 &
' FOR EACH CONTROL VOLUME'
2957 call table_cr(this%dvtab, this%packName, title)
2958 call this%dvtab%table_df(this%ncv, nterms, this%iout, &
2962 if (this%inamedbound == 1)
then
2964 call this%dvtab%initialize_column(text_temp, 20, alignment=tableft)
2968 text_temp =
'NUMBER'
2969 call this%dvtab%initialize_column(text_temp, 10, alignment=tabcenter)
2972 text_temp = this%depvartype(1:4)
2973 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.