MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
TspExchangeMover.f90
Go to the documentation of this file.
3
4 use kindmodule, only: i4b, dp, lgp
7 use tspfmimodule, only: tspfmitype
11 implicit none
12 private
13
14 public :: xmvt_cr
15
16 type, public, extends(tspmvttype) :: tspexchangemovertype
17 class(virtualmodeltype), pointer :: model1 => null() !< virtual model 1
18 class(virtualmodeltype), pointer :: model2 => null() !< virtual model 2
19 integer(I4B), pointer :: maxmvt => null() !< size of quantity arrays
20 real(dp), dimension(:), pointer, contiguous :: quantity_m1 => null() !< concentration, temp, ...
21 real(dp), dimension(:), pointer, contiguous :: quantity_m2 => null() !< concentration, temp, ...
22 contains
23 procedure :: mvt_rp => xmvt_rp
24 procedure :: xmvt_cf
25 procedure :: mvt_fc => xmvt_fc
26 procedure :: mvt_da => xmvt_da
28
29contains
30
31 subroutine xmvt_cr(mvt, name_exg, tsp_model1, tsp_model2, &
32 gwfmodelname1, gwfmodelname2, inunit, iout)
33 type(tspexchangemovertype), pointer :: mvt
34 character(len=*), intent(in) :: name_exg !< name of the exchange
35 class(transportmodeltype), pointer :: tsp_model1 !< gwt model 1, can be null()
36 class(transportmodeltype), pointer :: tsp_model2 !< gwt model 2, can be null()
37 character(len=*), intent(in) :: gwfmodelname1
38 character(len=*), intent(in) :: gwfmodelname2
39 integer(I4B), intent(in) :: inunit
40 integer(I4B), intent(in) :: iout
41 ! local
42 type(tspfmitype), pointer :: fmi1, fmi2
43 real(dp), pointer :: eqnsclfac !< governing equation scale factor
44 character(len=LENVARNAME) :: depvartype !< dependent variable type ('concentration' or 'temperature')
45
46 allocate (mvt)
47
48 fmi1 => null()
49 if (associated(tsp_model1)) then
50 fmi1 => tsp_model1%fmi
51 eqnsclfac => tsp_model1%eqnsclfac
52 depvartype = tsp_model1%depvartype
53 end if
54 fmi2 => null()
55 if (associated(tsp_model2)) then
56 fmi2 => tsp_model2%fmi
57 eqnsclfac => tsp_model2%eqnsclfac
58 depvartype = tsp_model2%depvartype
59 end if
60
61 mvt%model1 => get_virtual_model(gwfmodelname1)
62 mvt%model2 => get_virtual_model(gwfmodelname2)
63
64 call mvt%mvt_init(name_exg, inunit, iout, fmi1, &
65 eqnsclfac, depvartype, gwfmodelname1, &
66 gwfmodelname2, fmi2)
67
68 call mem_allocate(mvt%quantity_m1, 0, "QUANTITY_M1", mvt%memoryPath)
69 call mem_allocate(mvt%quantity_m2, 0, "QUANTITY_M2", mvt%memoryPath)
70 call mem_allocate(mvt%maxmvt, "MAXMVT", mvt%memoryPath)
71 mvt%maxmvt = 0
72
73 end subroutine xmvt_cr
74
75 !> @brief Read and prepare mover transport object
76 !<
77 subroutine xmvt_rp(this)
78 use tdismodule, only: kper, kstp
79 class(tspexchangemovertype) :: this
80 ! local
81 integer(I4B) :: i, max_array_size
82
83 call this%TspMvtType%mvt_rp()
84
85 ! only on first timestep
86 if (kstp * kper == 1) then
87 max_array_size = 0
88 do i = 1, this%mvrbudobj%nbudterm
89 max_array_size = max_array_size + this%mvrbudobj%budterm(i)%maxlist
90 end do
91
92 if (max_array_size > 0) then
93 call mem_reallocate(this%quantity_m1, max_array_size, &
94 "QUANTITY_M1", this%memoryPath)
95 call mem_reallocate(this%quantity_m2, max_array_size, &
96 "QUANTITY_M2", this%memoryPath)
97 this%maxmvt = max_array_size
98 end if
99 end if
100
101 this%quantity_m1 = dnodata
102 this%quantity_m2 = dnodata
103
104 end subroutine xmvt_rp
105
106 subroutine xmvt_cf(this, cnew1, cnew2)
107 class(tspexchangemovertype) :: this
108 real(DP), intent(in), dimension(:), contiguous, target :: cnew1
109 real(DP), intent(in), dimension(:), contiguous, target :: cnew2
110 ! local
111 integer(I4B) :: i, n, idx
112 real(DP), dimension(:), pointer, contiguous :: prov_array
113 logical(LGP) :: prov_is_local
114
115 call this%mvt_fill_mvrterm(cnew1, cnew2)
116
117 ! add mvrterm data into synchronization array
118 idx = 1
119 do i = 1, size(this%mvrterm)
120
121 ! point to provider array
122 prov_is_local = .false.
123 if (this%mvrterm(i)%prov_is_m1) then
124 prov_is_local = this%model1%is_local
125 prov_array => this%quantity_m1
126 else
127 prov_is_local = this%model2%is_local
128 prov_array => this%quantity_m2
129 end if
130
131 if (prov_is_local) then
132 do n = 1, size(this%mvrterm(i)%qty)
133 prov_array(idx) = this%mvrterm(i)%qty(n)
134 idx = idx + 1
135 end do
136 end if
137 end do
138
139 end subroutine xmvt_cf
140
141 subroutine xmvt_fc(this, cnew1, cnew2)
142 class(tspexchangemovertype) :: this
143 real(DP), intent(in), dimension(:), contiguous, target :: cnew1
144 real(DP), intent(in), dimension(:), contiguous, target :: cnew2
145 ! local
146 integer(I4B) :: i, n, idx
147 real(DP), dimension(:), pointer, contiguous :: prov_array ! after synchronization when parallel
148 logical(LGP) :: prov_is_remote
149
150 ! get mvrterm data from synchronization array
151 idx = 1
152 do i = 1, size(this%mvrterm)
153
154 ! point to provider array
155 if (this%mvrterm(i)%prov_is_m1) then
156 prov_is_remote = .not. this%model1%is_local
157 prov_array => this%quantity_m1
158 else
159 prov_is_remote = .not. this%model2%is_local
160 prov_array => this%quantity_m2
161 end if
162
163 if (prov_is_remote) then
164 ! remote provider, so we copy it in here after sync'ing
165 do n = 1, size(this%mvrterm(i)%qty)
166 this%mvrterm(i)%qty(n) = prov_array(idx)
167 idx = idx + 1
168 end do
169 end if
170 end do
171
172 call this%mvt_update_qmfrommvr()
173
174 end subroutine xmvt_fc
175
176 subroutine xmvt_da(this)
177 class(tspexchangemovertype) :: this
178
179 call this%TspMvtType%mvt_da()
180
181 call mem_deallocate(this%quantity_m1)
182 call mem_deallocate(this%quantity_m2)
183 call mem_deallocate(this%maxmvt)
184
185 end subroutine xmvt_da
186
187end module tspexchangemovermodule
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
integer(i4b), parameter lenvarname
maximum length of a variable name
Definition Constants.f90:17
This module defines variable data types.
Definition kind.f90:8
This module contains simulation variables.
integer(i4b) iout
file unit number for simulation output
integer(i4b) proc_id
integer(i4b), pointer, public kstp
current time step number
Definition tdis.f90:27
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
This module contains the base transport model type.
Definition tsp.f90:7
subroutine xmvt_fc(this, cnew1, cnew2)
subroutine xmvt_rp(this)
Read and prepare mover transport object.
subroutine xmvt_cf(this, cnew1, cnew2)
subroutine, public xmvt_cr(mvt, name_exg, tsp_model1, tsp_model2, gwfmodelname1, gwfmodelname2, inunit, iout)
subroutine mvt_rp(this)
Read and prepare mover transport object.
Definition tsp-mvt.f90:208
subroutine mvt_fc(this, cnew1, cnew2)
Calculate coefficients and fill amat and rhs.
Definition tsp-mvt.f90:241
subroutine mvt_da(this)
Deallocate memory.
Definition tsp-mvt.f90:515