MODFLOW 6  version 6.7.0.dev3
USGS Modular Hydrologic Model
virtualexchangemodule Module Reference

Data Types

type  virtualexchangetype
 The Virtual Exchange is based on two Virtual Models and is therefore not always strictly local or remote. We have to consider three different cases: More...
 

Functions/Subroutines

subroutine vx_create (this, name, exg_id, m1_id, m2_id)
 Create the virtual exchange base. More...
 
subroutine init_virtual_data (this)
 
subroutine vx_prepare_stage (this, stage)
 
subroutine vx_get_recv_items (this, stg, rank, vi)
 
subroutine vx_get_send_items (this, stg, rank, vi)
 
subroutine add_vdi_for_stage (this, vdata_item, stage, virtual_items)
 Convenience routine to add virtual data item to a list. More...
 
logical(lgp) function vx_has_mover (this)
 Checks if there is an active mover in the exchange. More...
 
subroutine vx_destroy (this)
 
subroutine allocate_data (this)
 
subroutine deallocate_data (this)
 
class(virtualexchangetype) function, pointer, public get_virtual_exchange (exg_id)
 Returns a virtual exchange with the specified id. More...
 
class(virtualexchangetype) function, pointer, public get_virtual_exchange_from_list (list, idx)
 
class(virtualexchangetype) function, pointer, private cast_as_virtual_exchange (obj_ptr)
 

Function/Subroutine Documentation

◆ add_vdi_for_stage()

subroutine virtualexchangemodule::add_vdi_for_stage ( class(virtualexchangetype this,
class(virtualdatatype), pointer  vdata_item,
integer(i4b)  stage,
type(stlvecint virtual_items 
)
private

Definition at line 249 of file VirtualExchange.f90.

250  class(VirtualExchangeType) :: this
251  class(VirtualDataType), pointer :: vdata_item
252  integer(I4B) :: stage
253  type(STLVecInt) :: virtual_items
254  ! local
255  class(*), pointer :: vdi
256  integer(I4B) :: idx
257 
258  vdi => vdata_item
259  idx = this%virtual_data_list%GetIndex(vdi)
260  if (vdata_item%check_stage(stage)) then
261  call virtual_items%push_back(idx)
262  end if
263 

◆ allocate_data()

subroutine virtualexchangemodule::allocate_data ( class(virtualexchangetype this)
private

Definition at line 284 of file VirtualExchange.f90.

285  class(VirtualExchangeType) :: this
286 
287  allocate (this%nexg)
288  allocate (this%naux)
289  allocate (this%ianglex)
290  allocate (this%nodem1)
291  allocate (this%nodem2)
292  allocate (this%ihc)
293  allocate (this%cl1)
294  allocate (this%cl2)
295  allocate (this%hwva)
296  allocate (this%auxvar)
297 

◆ cast_as_virtual_exchange()

class(virtualexchangetype) function, pointer, private virtualexchangemodule::cast_as_virtual_exchange ( class(*), pointer  obj_ptr)
private

Definition at line 352 of file VirtualExchange.f90.

353  class(*), pointer :: obj_ptr
354  class(VirtualExchangeType), pointer :: virtual_exg
355 
356  virtual_exg => null()
357  select type (obj_ptr)
358  class is (virtualexchangetype)
359  virtual_exg => obj_ptr
360  end select
361 
Here is the caller graph for this function:

◆ deallocate_data()

subroutine virtualexchangemodule::deallocate_data ( class(virtualexchangetype this)
private

Definition at line 300 of file VirtualExchange.f90.

301  class(VirtualExchangeType) :: this
302 
303  deallocate (this%nexg)
304  deallocate (this%naux)
305  deallocate (this%ianglex)
306  deallocate (this%nodem1)
307  deallocate (this%nodem2)
308  deallocate (this%ihc)
309  deallocate (this%cl1)
310  deallocate (this%cl2)
311  deallocate (this%hwva)
312  deallocate (this%auxvar)
313 

◆ get_virtual_exchange()

class(virtualexchangetype) function, pointer, public virtualexchangemodule::get_virtual_exchange ( integer(i4b)  exg_id)

Definition at line 318 of file VirtualExchange.f90.

320  integer(I4B) :: exg_id
321  class(VirtualExchangeType), pointer :: virtual_exg
322  ! local
323  integer(I4B) :: i
324  class(*), pointer :: ve
325 
326  virtual_exg => null()
327  do i = 1, virtual_exchange_list%Count()
328  ve => virtual_exchange_list%GetItem(i)
329  select type (ve)
330  class is (virtualexchangetype)
331  if (ve%id == exg_id) then
332  virtual_exg => ve
333  return
334  end if
335  end select
336  end do
337 
type(listtype), public virtual_exchange_list
Here is the caller graph for this function:

◆ get_virtual_exchange_from_list()

class(virtualexchangetype) function, pointer, public virtualexchangemodule::get_virtual_exchange_from_list ( type(listtype list,
integer(i4b)  idx 
)

Definition at line 340 of file VirtualExchange.f90.

341  type(ListType) :: list
342  integer(I4B) :: idx
343  class(VirtualExchangeType), pointer :: virtual_exg
344  ! local
345  class(*), pointer :: obj_ptr
346 
347  obj_ptr => list%GetItem(idx)
348  virtual_exg => cast_as_virtual_exchange(obj_ptr)
349 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_virtual_data()

subroutine virtualexchangemodule::init_virtual_data ( class(virtualexchangetype this)
private

Definition at line 125 of file VirtualExchange.f90.

126  class(VirtualExchangeType) :: this
127  ! local
128  logical(LGP) :: is_nodem1_local
129  logical(LGP) :: is_nodem2_local
130 
131  ! exchanges can be hybrid with both local and remote
132  ! fields, nodem1/2 array only local when corresponding
133  ! model sits on the same process
134  is_nodem1_local = this%v_model1%is_local
135  is_nodem2_local = this%v_model2%is_local
136  call this%set(this%nexg%base(), 'NEXG', '', map_all_type)
137  call this%set(this%naux%base(), 'NAUX', '', map_all_type)
138  call this%set(this%ianglex%base(), 'IANGLEX', '', map_all_type)
139  call this%set(this%nodem1%base(), 'NODEM1', '', &
140  map_all_type, is_nodem1_local)
141  call this%set(this%nodem2%base(), 'NODEM2', '', &
142  map_all_type, is_nodem2_local)
143  call this%set(this%ihc%base(), 'IHC', '', map_all_type)
144  call this%set(this%cl1%base(), 'CL1', '', map_all_type)
145  call this%set(this%cl2%base(), 'CL2', '', map_all_type)
146  call this%set(this%hwva%base(), 'HWVA', '', map_all_type)
147  call this%set(this%auxvar%base(), 'AUXVAR', '', map_all_type)
148 

◆ vx_create()

subroutine virtualexchangemodule::vx_create ( class(virtualexchangetype this,
character(len=*)  name,
integer(i4b)  exg_id,
integer(i4b)  m1_id,
integer(i4b)  m2_id 
)

Definition at line 102 of file VirtualExchange.f90.

103  class(VirtualExchangeType) :: this
104  character(len=*) :: name
105  integer(I4B) :: exg_id
106  integer(I4B) :: m1_id
107  integer(I4B) :: m2_id
108  ! local
109  logical(LGP) :: is_local
110 
111  this%v_model1 => get_virtual_model(m1_id)
112  this%v_model2 => get_virtual_model(m2_id)
113 
114  ! 1) both models local: is_local = true
115  ! 2) only one of them: is_local = true
116  ! 3) both models remote: is_local = false
117  is_local = this%v_model1%is_local .or. this%v_model2%is_local
118  call this%VirtualDataContainerType%vdc_create(name, exg_id, is_local)
119 
120  call this%allocate_data()
121  call this%init_virtual_data()
122 

◆ vx_destroy()

subroutine virtualexchangemodule::vx_destroy ( class(virtualexchangetype this)
private

Definition at line 276 of file VirtualExchange.f90.

277  class(VirtualExchangeType) :: this
278 
279  call this%VirtualDataContainerType%destroy()
280  call this%deallocate_data()
281 

◆ vx_get_recv_items()

subroutine virtualexchangemodule::vx_get_recv_items ( class(virtualexchangetype this,
integer(i4b)  stg,
integer(i4b)  rank,
type(stlvecint vi 
)
private

Definition at line 181 of file VirtualExchange.f90.

182  class(VirtualExchangeType) :: this
183  integer(I4B) :: stg
184  integer(I4B) :: rank
185  type(STLVecInt) :: vi
186 
187  if (this%is_local .and. rank == this%orig_rank) then
188  ! treat the primary exchange case independently, we
189  ! have all data available except for nodem1 or nodem2
190  if (stg < stg_bfr_con_df) then
191  if (this%nodem1%is_remote) then
192  call this%add_vdi_for_stage(this%nodem1%base(), stg, vi)
193  end if
194  if (this%nodem2%is_remote) then
195  call this%add_vdi_for_stage(this%nodem2%base(), stg, vi)
196  end if
197  end if
198  else
199  ! send/receive all
200  call this%add_vdi_for_stage(this%nexg%base(), stg, vi)
201  call this%add_vdi_for_stage(this%naux%base(), stg, vi)
202  call this%add_vdi_for_stage(this%ianglex%base(), stg, vi)
203  call this%add_vdi_for_stage(this%nodem1%base(), stg, vi)
204  call this%add_vdi_for_stage(this%nodem2%base(), stg, vi)
205  call this%add_vdi_for_stage(this%ihc%base(), stg, vi)
206  call this%add_vdi_for_stage(this%cl1%base(), stg, vi)
207  call this%add_vdi_for_stage(this%cl2%base(), stg, vi)
208  call this%add_vdi_for_stage(this%hwva%base(), stg, vi)
209  call this%add_vdi_for_stage(this%auxvar%base(), stg, vi)
210  end if
211 

◆ vx_get_send_items()

subroutine virtualexchangemodule::vx_get_send_items ( class(virtualexchangetype this,
integer(i4b)  stg,
integer(i4b)  rank,
type(stlvecint vi 
)
private

Definition at line 214 of file VirtualExchange.f90.

215  class(VirtualExchangeType) :: this
216  integer(I4B) :: stg
217  integer(I4B) :: rank
218  type(STLVecInt) :: vi
219 
220  if (this%is_local .and. rank == this%orig_rank) then
221  ! this is a primary exchange, all we need to send are
222  ! the node numbers nodem1 or nodem2
223  if (stg < stg_bfr_con_df) then
224  if (.not. this%nodem1%is_remote) then
225  call this%add_vdi_for_stage(this%nodem1%base(), stg, vi)
226  end if
227  if (.not. this%nodem2%is_remote) then
228  call this%add_vdi_for_stage(this%nodem2%base(), stg, vi)
229  end if
230  end if
231  else
232  ! send/receive all
233  call this%add_vdi_for_stage(this%nexg%base(), stg, vi)
234  call this%add_vdi_for_stage(this%naux%base(), stg, vi)
235  call this%add_vdi_for_stage(this%ianglex%base(), stg, vi)
236  call this%add_vdi_for_stage(this%nodem1%base(), stg, vi)
237  call this%add_vdi_for_stage(this%nodem2%base(), stg, vi)
238  call this%add_vdi_for_stage(this%ihc%base(), stg, vi)
239  call this%add_vdi_for_stage(this%cl1%base(), stg, vi)
240  call this%add_vdi_for_stage(this%cl2%base(), stg, vi)
241  call this%add_vdi_for_stage(this%hwva%base(), stg, vi)
242  call this%add_vdi_for_stage(this%auxvar%base(), stg, vi)
243  end if
244 

◆ vx_has_mover()

logical(lgp) function virtualexchangemodule::vx_has_mover ( class(virtualexchangetype this)
private

Definition at line 268 of file VirtualExchange.f90.

269  class(VirtualExchangeType) :: this
270  logical(LGP) :: has_mover
271 
272  has_mover = .false.
273 

◆ vx_prepare_stage()

subroutine virtualexchangemodule::vx_prepare_stage ( class(virtualexchangetype this,
integer(i4b)  stage 
)
private

Definition at line 151 of file VirtualExchange.f90.

152  class(VirtualExchangeType) :: this
153  integer(I4B) :: stage
154  ! local
155  integer(I4B) :: nexg, naux
156 
157  if (stage == stg_aft_exg_df) then
158 
159  call this%map(this%nexg%base(), (/stg_aft_exg_df/))
160  call this%map(this%naux%base(), (/stg_aft_exg_df/))
161  call this%map(this%ianglex%base(), (/stg_aft_exg_df/))
162 
163  else if (stage == stg_aft_con_cr) then
164 
165  nexg = this%nexg%get()
166  naux = this%naux%get()
167  call this%map(this%nodem1%base(), nexg, (/stg_aft_con_cr, &
168  stg_bfr_con_df/))
169  call this%map(this%nodem2%base(), nexg, (/stg_aft_con_cr, &
170  stg_bfr_con_df/))
171  call this%map(this%ihc%base(), nexg, (/stg_aft_con_cr/))
172  call this%map(this%cl1%base(), nexg, (/stg_aft_con_cr/))
173  call this%map(this%cl2%base(), nexg, (/stg_aft_con_cr/))
174  call this%map(this%hwva%base(), nexg, (/stg_aft_con_cr/))
175  call this%map(this%auxvar%base(), naux, nexg, (/stg_aft_con_cr/))
176 
177  end if
178