29 logical(LGP) :: prov_is_m1
30 real(dp),
dimension(:),
pointer,
contiguous :: qty => null()
35 character(len=LENMODELNAME) :: gwfmodelname1 =
''
36 character(len=LENMODELNAME) :: gwfmodelname2 =
''
37 integer(I4B),
pointer :: maxpackages
38 integer(I4B),
pointer :: ibudgetout => null()
39 integer(I4B),
pointer :: ibudcsv => null()
40 real(dp),
pointer :: eqnsclfac => null()
46 character(len=LENPACKAGENAME), &
47 dimension(:),
pointer,
contiguous :: paknames => null()
48 character(len=LENVARNAME) :: depvartype =
''
54 type(
mvrtermtype),
dimension(:),
pointer,
contiguous :: mvrterm => null()
83 subroutine mvt_cr(mvt, name_model, inunit, iout, fmi1, eqnsclfac, &
84 depvartype, gwfmodelname1, gwfmodelname2, fmi2)
86 character(len=*),
intent(in) :: name_model
87 integer(I4B),
intent(in) :: inunit
88 integer(I4B),
intent(in) :: iout
90 real(dp),
intent(in),
pointer :: eqnsclfac
91 character(len=LENVARNAME),
intent(in) :: depvartype
92 character(len=*),
intent(in),
optional :: gwfmodelname1
93 character(len=*),
intent(in),
optional :: gwfmodelname2
94 type(
tspfmitype),
intent(in),
pointer,
optional :: fmi2
97 call mvt%mvt_init(name_model, inunit, iout, fmi1, eqnsclfac, &
98 depvartype, gwfmodelname1, gwfmodelname2, fmi2)
104 subroutine mvt_init(this, name_model, inunit, iout, fmi1, eqnsclfac, &
105 depvartype, gwfmodelname1, gwfmodelname2, fmi2)
108 character(len=*),
intent(in) :: name_model
109 integer(I4B),
intent(in) :: inunit
110 integer(I4B),
intent(in) :: iout
112 real(DP),
intent(in),
pointer :: eqnsclfac
113 character(len=LENVARNAME),
intent(in) :: depvartype
114 character(len=*),
intent(in),
optional :: gwfmodelname1
115 character(len=*),
intent(in),
optional :: gwfmodelname2
116 type(
tspfmitype),
intent(in),
pointer,
optional :: fmi2
119 call this%set_names(1, name_model,
'MVT',
'MVT')
122 call this%allocate_scalars()
132 if (
present(fmi2))
then
137 if (
present(gwfmodelname1))
then
138 this%gwfmodelname1 = gwfmodelname1
140 if (
present(gwfmodelname2))
then
141 this%gwfmodelname2 = gwfmodelname2
148 this%eqnsclfac => eqnsclfac
152 this%depvartype = depvartype
163 character(len=*),
parameter :: fmtmvt = &
164 "(1x,/1x,'MVT -- MOVER TRANSPORT PACKAGE, VERSION 1, 4/15/2020', &
165 &' INPUT READ FROM UNIT ', i0, //)"
171 write (this%iout, fmtmvt) this%inunit
174 call this%parser%Initialize(this%inunit, this%iout)
177 call budget_cr(this%budget, this%memoryPath)
180 call this%read_options()
192 this%mvrbudobj => mvrbudobj
202 call this%mvt_setup_outputtab()
218 if (
associated(this%fmi1, this%fmi2))
then
219 call this%set_pointer_mvrbudobj(this%fmi1%mvrbudobj)
223 call this%mvt_scan_mvrbudobj()
224 call this%mvt_setup_budobj()
227 call this%budget%budget_df(this%maxpackages,
'TRANSPORT MOVER', bddim=
'M')
228 call this%budget%set_ibudcsv(this%ibudcsv)
242 real(DP),
intent(in),
dimension(:),
contiguous,
target :: cnew1
243 real(DP),
intent(in),
dimension(:),
contiguous,
target :: cnew2
245 call this%mvt_fill_mvrterm(cnew1, cnew2)
246 call this%mvt_update_qmfrommvr()
254 real(DP),
intent(in),
dimension(:),
contiguous,
target :: cnew1
255 real(DP),
intent(in),
dimension(:),
contiguous,
target :: cnew2
258 integer(I4B) :: id1, nlist
260 integer(I4B) :: igwtnode
261 integer(I4B) :: nbudterm
263 real(DP),
dimension(:),
pointer :: concpak
264 real(DP),
dimension(:),
contiguous,
pointer :: cnew_pr
267 nbudterm = this%mvrbudobj%nbudterm
269 nlist = this%mvrbudobj%budterm(i)%nlist
270 if (nlist == 0) cycle
273 call this%set_fmi(i, fmi_pr, .true.)
274 if (.not.
associated(fmi_pr)) cycle
277 if (
associated(fmi_pr, this%fmi2))
then
281 call fmi_pr%get_package_index(this%mvrbudobj%budterm(i)%text2id1, ipr)
284 if (fmi_pr%iatp(ipr) /= 0)
then
285 concpak => fmi_pr%datp(ipr)%concpack
291 id1 = this%mvrbudobj%budterm(i)%id1(n)
293 if (fmi_pr%iatp(ipr) /= 0)
then
297 igwtnode = fmi_pr%gwfpackages(ipr)%nodelist(id1)
298 cp = cnew_pr(igwtnode)
301 this%mvrterm(i)%qty(n) = cp
312 integer(I4B) :: id2, nlist
314 integer(I4B) :: nbudterm
317 nbudterm = this%mvrbudobj%nbudterm
319 nlist = this%mvrbudobj%budterm(i)%nlist
320 if (nlist == 0) cycle
322 call this%set_fmi(i, fmi_rc, .false.)
323 if (.not.
associated(fmi_rc)) cycle
325 call fmi_rc%get_package_index(this%mvrbudobj%budterm(i)%text2id2, irc)
330 id2 = this%mvrbudobj%budterm(i)%id2(n)
334 if (fmi_rc%iatp(irc) /= 0)
then
335 fmi_rc%datp(irc)%qmfrommvr(id2) = fmi_rc%datp(irc)%qmfrommvr(id2) - &
336 this%mvrbudobj%budterm(i)%flow(n) * &
337 this%mvrterm(i)%qty(n) * &
344 subroutine set_fmi(this, ibudterm, fmi, set_provider)
346 integer(I4B),
intent(in) :: ibudterm
348 logical(LGP) :: set_provider
350 character(len=LENMODELNAME) :: model_name
353 if (this%gwfmodelname1 ==
'' .and. this%gwfmodelname2 ==
'')
then
359 if (set_provider)
then
360 model_name = this%mvrbudobj%budterm(ibudterm)%text1id1
362 model_name = this%mvrbudobj%budterm(ibudterm)%text1id2
365 if (model_name == this%gwfmodelname1)
then
368 else if (model_name == this%gwfmodelname2)
then
377 subroutine mvt_cc(this, kiter, iend, icnvgmod, cpak, dpak)
380 integer(I4B),
intent(in) :: kiter
381 integer(I4B),
intent(in) :: iend
382 integer(I4B),
intent(in) :: icnvgmod
383 character(len=LENPAKLOC),
intent(inout) :: cpak
384 real(DP),
intent(inout) :: dpak
386 character(len=*),
parameter :: fmtmvrcnvg = &
387 "(/,1x,'MOVER PACKAGE REQUIRES AT LEAST TWO OUTER ITERATIONS. CONVERGE &
388 &FLAG HAS BEEN RESET TO FALSE.')"
391 if (
associated(this%mvrbudobj))
then
392 if (icnvgmod == 1 .and. kiter == 1)
then
394 cpak = trim(this%packName)
395 write (this%iout, fmtmvrcnvg)
407 call this%mvt_fill_budobj()
417 integer(I4B),
intent(in) :: icbcfl
418 integer(I4B),
intent(in) :: ibudfl
420 integer(I4B) :: ibinun
424 if (this%ibudgetout /= 0)
then
425 ibinun = this%ibudgetout
427 if (icbcfl == 0) ibinun = 0
429 call this%budobj%save_flows(this%dis, ibinun,
kstp,
kper,
delt, &
439 integer(I4B),
intent(in) :: icbcfl
440 integer(I4B),
intent(in) :: ibudfl
443 if (ibudfl /= 0 .and. this%iprflow /= 0)
then
444 call this%mvt_print_outputtab()
455 integer(I4B),
intent(in) :: ibudfl
457 integer(I4B) :: i, j, n
458 real(DP),
allocatable,
dimension(:) :: ratin, ratout
461 allocate (ratin(this%maxpackages), ratout(this%maxpackages))
462 do j = 1, this%maxpackages
468 do i = 1, this%maxpackages
469 do j = 1, this%budobj%nbudterm
470 do n = 1, this%budobj%budterm(j)%nlist
473 if (this%paknames(i) == this%budobj%budterm(j)%text2id1)
then
474 ratin(i) = ratin(i) + this%budobj%budterm(j)%flow(n)
478 if (this%paknames(i) == this%budobj%budterm(j)%text2id2)
then
479 ratout(i) = ratout(i) + this%budobj%budterm(j)%flow(n)
486 call this%budget%reset()
487 do j = 1, this%maxpackages
488 call this%budget%addentry(ratin(j), ratout(j),
delt, this%paknames(j))
492 call this%budget%finalize_step(
delt)
493 if (ibudfl /= 0)
then
494 call this%budget%budget_ot(
kstp,
kper, this%iout)
498 call this%budget%writecsv(
totim)
501 deallocate (ratin, ratout)
523 if (this%inunit > 0)
then
526 if (
associated(this%mvrterm))
then
527 do i = 1,
size(this%mvrterm)
528 deallocate (this%mvrterm(i)%qty)
530 deallocate (this%mvrterm)
534 deallocate (this%paknames)
537 call this%budget%budget_da()
538 deallocate (this%budget)
541 call this%budobj%budgetobject_da()
542 deallocate (this%budobj)
543 nullify (this%budobj)
546 if (
associated(this%outputtab))
then
547 call this%outputtab%table_da()
548 deallocate (this%outputtab)
549 nullify (this%outputtab)
556 this%mvrbudobj => null()
562 call this%NumericalPackageType%da()
576 call this%NumericalPackageType%allocate_scalars()
579 call mem_allocate(this%maxpackages,
'MAXPACKAGES', this%memoryPath)
580 call mem_allocate(this%ibudgetout,
'IBUDGETOUT', this%memoryPath)
581 call mem_allocate(this%ibudcsv,
'IBUDCSV', this%memoryPath)
598 character(len=LINELENGTH) :: errmsg, keyword
599 character(len=MAXCHARLEN) :: fname
601 logical :: isfound, endOfBlock
603 character(len=*),
parameter :: fmtflow = &
604 "(4x, a, 1x, a, 1x, ' WILL BE SAVED TO FILE: ', a, &
605 &/4x, 'OPENED ON UNIT: ', I0)"
606 character(len=*),
parameter :: fmtflow2 = &
607 &
"(4x, 'FLOWS WILL BE SAVED TO BUDGET FILE')"
610 call this%parser%GetBlock(
'OPTIONS', isfound, ierr, blockrequired=.false., &
611 supportopenclose=.true.)
615 write (this%iout,
'(1x,a)')
'PROCESSING MVT OPTIONS'
617 call this%parser%GetNextLine(endofblock)
619 call this%parser%GetStringCaps(keyword)
620 select case (keyword)
623 write (this%iout, fmtflow2)
626 write (this%iout,
'(4x,a)')
'MVT INPUT WILL BE PRINTED.'
629 write (this%iout,
'(4x,a)') &
630 'MVT FLOWS WILL BE PRINTED TO LISTING FILE.'
632 call this%parser%GetStringCaps(keyword)
633 if (keyword ==
'FILEOUT')
then
634 call this%parser%GetString(fname)
635 call assign_iounit(this%ibudgetout, this%inunit,
"BUDGET fileout")
636 call openfile(this%ibudgetout, this%iout, fname,
'DATA(BINARY)', &
638 write (this%iout, fmtflow)
'MVT',
'BUDGET', trim(adjustl(fname)), &
642 &be followed by FILEOUT')
645 call this%parser%GetStringCaps(keyword)
646 if (keyword ==
'FILEOUT')
then
647 call this%parser%GetString(fname)
648 call assign_iounit(this%ibudcsv, this%inunit,
"BUDGETCSV fileout")
649 call openfile(this%ibudcsv, this%iout, fname,
'CSV', &
650 filstat_opt=
'REPLACE')
651 write (this%iout, fmtflow)
'MVT',
'BUDGET CSV', &
652 trim(adjustl(fname)), this%ibudcsv
654 call store_error(
'Optional BUDGETCSV keyword must be followed by &
658 write (errmsg,
'(a,a)')
'Unknown MVT option: ', &
661 call this%parser%StoreErrorUnit()
664 write (this%iout,
'(1x,a)')
'END OF MVT OPTIONS'
676 integer(I4B) :: nbudterm
678 integer(I4B) :: maxlist
681 character(len=LENMODELNAME) :: modelname1, modelname2
682 character(len=LENPACKAGENAME) :: packagename1, packagename2
683 character(len=LENBUDTXT) :: text
686 nbudterm = this%mvrbudobj%nbudterm
689 if (this%depvartype ==
'CONCENTRATION')
then
696 call this%budobj%budgetobject_df(ncv, nbudterm, 0, 0, bddim_opt=
'M')
699 allocate (this%mvrterm(nbudterm))
704 modelname1 = this%mvrbudobj%budterm(i)%text1id1
705 packagename1 = this%mvrbudobj%budterm(i)%text2id1
706 modelname2 = this%mvrbudobj%budterm(i)%text1id2
707 packagename2 = this%mvrbudobj%budterm(i)%text2id2
708 maxlist = this%mvrbudobj%budterm(i)%maxlist
709 call this%budobj%budterm(i)%initialize(text, &
714 maxlist, .false., .false., &
716 this%mvrterm(i)%prov_is_m1 = (this%gwfmodelname1 == modelname1)
717 allocate (this%mvrterm(i)%qty(maxlist))
718 this%mvrterm(i)%qty = dnodata
729 integer(I4B) :: nbudterm
730 integer(I4B) :: nlist
734 integer(I4B) :: n1, n2
741 nbudterm = this%mvrbudobj%nbudterm
743 nlist = this%mvrbudobj%budterm(i)%nlist
744 call this%set_fmi(i, fmi_rc, .false.)
745 if (.not.
associated(fmi_rc)) cycle
747 call fmi_rc%get_package_index(this%mvrbudobj%budterm(i)%text2id2, irc)
748 call this%budobj%budterm(i)%reset(nlist)
750 n1 = this%mvrbudobj%budterm(i)%id1(j)
751 n2 = this%mvrbudobj%budterm(i)%id2(j)
752 q = this%mvrbudobj%budterm(i)%flow(j)
753 cp = this%mvrterm(i)%qty(j)
757 if (fmi_rc%iatp(irc) /= 0)
then
758 rate = -q * cp * this%eqnsclfac
762 call this%budobj%budterm(i)%update_term(n1, n2, rate)
767 call this%budobj%accumulate_terms()
777 integer(I4B) :: nbudterm
778 integer(I4B) :: maxpackages
784 nbudterm = this%mvrbudobj%nbudterm
786 if (i * i == nbudterm)
then
791 this%maxpackages = maxpackages
794 if (
associated(this%paknames))
deallocate (this%paknames)
795 allocate (this%paknames(this%maxpackages))
796 do i = 1, this%maxpackages
797 this%paknames(i) =
''
805 if (this%mvrbudobj%budterm(i)%text2id1 == this%paknames(j))
then
810 if (.not. found)
then
811 this%paknames(ipos) = this%mvrbudobj%budterm(i)%text2id1
823 character(len=LINELENGTH) :: title
824 character(len=LINELENGTH) :: text
825 integer(I4B) :: ntabcol
826 integer(I4B) :: maxrow
830 if (this%iprflow /= 0)
then
837 title =
'TRANSPORT MOVER PACKAGE ('//trim(this%packName)// &
839 call table_cr(this%outputtab, this%packName, title)
840 call this%outputtab%table_df(maxrow, ntabcol, this%iout, &
843 call this%outputtab%initialize_column(text, 10, alignment=
tabcenter)
844 text =
'PROVIDER LOCATION'
846 call this%outputtab%initialize_column(text, ilen)
848 call this%outputtab%initialize_column(text, 10)
849 text =
'PROVIDER FLOW RATE'
850 call this%outputtab%initialize_column(text, 10)
851 text =
'PROVIDER TRANSPORT RATE'
852 call this%outputtab%initialize_column(text, 10)
853 text =
'RECEIVER LOCATION'
855 call this%outputtab%initialize_column(text, ilen)
857 call this%outputtab%initialize_column(text, 10)
870 character(len=LINELENGTH) :: title
871 character(len=LENMODELNAME + LENPACKAGENAME + 1) :: cloc1, cloc2
875 integer(I4B) :: ntabrows
876 integer(I4B) :: nlist
880 do i = 1, this%budobj%nbudterm
881 nlist = this%budobj%budterm(i)%nlist
882 ntabrows = ntabrows + nlist
886 call this%outputtab%set_kstpkper(
kstp,
kper)
889 title =
'TRANSPORT MOVER PACKAGE ('//trim(this%packName)// &
891 call this%outputtab%set_title(title)
892 call this%outputtab%set_maxbound(ntabrows)
896 do i = 1, this%budobj%nbudterm
897 nlist = this%budobj%budterm(i)%nlist
899 cloc1 = trim(adjustl(this%budobj%budterm(i)%text1id1))//
' '// &
900 trim(adjustl(this%budobj%budterm(i)%text2id1))
901 cloc2 = trim(adjustl(this%budobj%budterm(i)%text1id2))//
' '// &
902 trim(adjustl(this%budobj%budterm(i)%text2id2))
903 call this%outputtab%add_term(inum)
904 call this%outputtab%add_term(cloc1)
905 call this%outputtab%add_term(this%budobj%budterm(i)%id1(n))
906 call this%outputtab%add_term(-this%mvrbudobj%budterm(i)%flow(n))
907 call this%outputtab%add_term(this%budobj%budterm(i)%flow(n))
908 call this%outputtab%add_term(cloc2)
909 call this%outputtab%add_term(this%budobj%budterm(i)%id2(n))
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
@ tabcenter
centered table column
integer(i4b), parameter lenmodelname
maximum length of the model name
integer(i4b), parameter lenpackagename
maximum length of the package name
real(dp), parameter dnodata
real no data constant
integer(i4b), parameter lenpakloc
maximum length of a package location
integer(i4b), parameter lenvarname
maximum length of a variable 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
This module defines variable data types.
This module contains the base numerical package type.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
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
subroutine mvt_setup_outputtab(this)
Set up the mover-for-transport output table.
subroutine mvt_scan_mvrbudobj(this)
Determine max number of packages in use.
subroutine set_pointer_mvrbudobj(this, mvrbudobj)
@ brief Set pointer to mvrbudobj
subroutine, public mvt_cr(mvt, name_model, inunit, iout, fmi1, eqnsclfac, depvartype, gwfmodelname1, gwfmodelname2, fmi2)
subroutine mvt_bd(this)
Write mover terms to listing file.
subroutine mvt_fill_mvrterm(this, cnew1, cnew2)
Fill mvrterm with provider concentration and flow for each budget term.
subroutine mvt_fill_budobj(this)
Copy mover-for-transport flow terms into thisbudobj.
subroutine mvt_ot_saveflow(this, icbcfl, ibudfl)
Write mover budget terms.
subroutine mvt_ot_bdsummary(this, ibudfl)
Write mover budget to listing file.
subroutine mvt_rp(this)
Read and prepare mover transport object.
subroutine mvt_update_qmfrommvr(this)
Assign mover transport mass into each receiver's qmfrommvr.
subroutine mvt_cc(this, kiter, iend, icnvgmod, cpak, dpak)
Extra convergence check for mover.
subroutine read_options(this)
Read mover-for-transport options block.
subroutine mvt_setup_budobj(this)
Set up the budget object that stores all the mvr flows.
subroutine mvt_print_outputtab(this)
Set up mover-for-transport output table.
subroutine mvt_df(this, dis)
Define mover transport object.
subroutine mvt_ar(this)
Allocate and read mover-for-transport information.
subroutine mvt_fc(this, cnew1, cnew2)
Calculate coefficients and fill amat and rhs.
subroutine mvt_da(this)
@ brief Deallocate memory
subroutine mvt_ot_printflow(this, icbcfl, ibudfl)
Print mover flow table.
subroutine mvt_init(this, name_model, inunit, iout, fmi1, eqnsclfac, depvartype, gwfmodelname1, gwfmodelname2, fmi2)
Create a new mover transport object.
subroutine set_fmi(this, ibudterm, fmi, set_provider)
subroutine allocate_scalars(this)
@ brief Allocate scalar variables for package
Derived type for the Budget object.
Type to store mover-transport flow and concentration for one budget term.