MODFLOW 6  version 6.6.0.dev0
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, stage, rank, virtual_items)
 
subroutine vx_get_send_items (this, stage, rank, virtual_items)
 
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

◆ allocate_data()

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

Definition at line 263 of file VirtualExchange.f90.

264  class(VirtualExchangeType) :: this
265 
266  allocate (this%nexg)
267  allocate (this%naux)
268  allocate (this%ianglex)
269  allocate (this%nodem1)
270  allocate (this%nodem2)
271  allocate (this%ihc)
272  allocate (this%cl1)
273  allocate (this%cl2)
274  allocate (this%hwva)
275  allocate (this%auxvar)
276 

◆ cast_as_virtual_exchange()

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

Definition at line 331 of file VirtualExchange.f90.

332  class(*), pointer :: obj_ptr
333  class(VirtualExchangeType), pointer :: virtual_exg
334 
335  virtual_exg => null()
336  select type (obj_ptr)
337  class is (virtualexchangetype)
338  virtual_exg => obj_ptr
339  end select
340 
Here is the caller graph for this function:

◆ deallocate_data()

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

Definition at line 279 of file VirtualExchange.f90.

280  class(VirtualExchangeType) :: this
281 
282  deallocate (this%nexg)
283  deallocate (this%naux)
284  deallocate (this%ianglex)
285  deallocate (this%nodem1)
286  deallocate (this%nodem2)
287  deallocate (this%ihc)
288  deallocate (this%cl1)
289  deallocate (this%cl2)
290  deallocate (this%hwva)
291  deallocate (this%auxvar)
292 

◆ get_virtual_exchange()

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

Definition at line 297 of file VirtualExchange.f90.

299  integer(I4B) :: exg_id
300  class(VirtualExchangeType), pointer :: virtual_exg
301  ! local
302  integer(I4B) :: i
303  class(*), pointer :: ve
304 
305  virtual_exg => null()
306  do i = 1, virtual_exchange_list%Count()
307  ve => virtual_exchange_list%GetItem(i)
308  select type (ve)
309  class is (virtualexchangetype)
310  if (ve%id == exg_id) then
311  virtual_exg => ve
312  return
313  end if
314  end select
315  end do
316 
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 319 of file VirtualExchange.f90.

320  type(ListType) :: list
321  integer(I4B) :: idx
322  class(VirtualExchangeType), pointer :: virtual_exg
323  ! local
324  class(*), pointer :: obj_ptr
325 
326  obj_ptr => list%GetItem(idx)
327  virtual_exg => cast_as_virtual_exchange(obj_ptr)
328 
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 120 of file VirtualExchange.f90.

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

◆ 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 97 of file VirtualExchange.f90.

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

◆ vx_destroy()

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

Definition at line 255 of file VirtualExchange.f90.

256  class(VirtualExchangeType) :: this
257 
258  call this%VirtualDataContainerType%destroy()
259  call this%deallocate_data()
260 

◆ vx_get_recv_items()

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

Definition at line 176 of file VirtualExchange.f90.

177  class(VirtualExchangeType) :: this
178  integer(I4B) :: stage
179  integer(I4B) :: rank
180  type(STLVecInt) :: virtual_items
181  ! local
182  integer(I4B) :: nodem1_idx, nodem2_idx
183  class(*), pointer :: vdi
184 
185  vdi => this%nodem1
186  nodem1_idx = this%virtual_data_list%GetIndex(vdi)
187  vdi => this%nodem2
188  nodem2_idx = this%virtual_data_list%GetIndex(vdi)
189 
190  if (this%v_model1%is_local .and. &
191  this%v_model2%orig_rank == rank) then
192  ! this is our dual exchange on the other rank,
193  ! only receive nodem2
194  if (this%nodem2%check_stage(stage)) then
195  call virtual_items%push_back(nodem2_idx)
196  end if
197  else if (this%v_model2%is_local .and. &
198  this%v_model1%orig_rank == rank) then
199  ! the reverse case...
200  if (this%nodem1%check_stage(stage)) then
201  call virtual_items%push_back(nodem1_idx)
202  end if
203  else
204  ! receive all using base
205  call this%VirtualDataContainerType%get_recv_items(stage, rank, &
206  virtual_items)
207  end if
208 

◆ vx_get_send_items()

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

Definition at line 211 of file VirtualExchange.f90.

212  class(VirtualExchangeType) :: this
213  integer(I4B) :: stage
214  integer(I4B) :: rank
215  type(STLVecInt) :: virtual_items
216  ! local
217  integer(I4B) :: nodem1_idx, nodem2_idx
218  class(*), pointer :: vdi
219 
220  vdi => this%nodem1
221  nodem1_idx = this%virtual_data_list%GetIndex(vdi)
222  vdi => this%nodem2
223  nodem2_idx = this%virtual_data_list%GetIndex(vdi)
224  if (this%v_model1%is_local .and. &
225  this%v_model2%orig_rank == rank) then
226  ! this is our dual exchange on the other rank,
227  ! only send nodem1
228  if (this%nodem1%check_stage(stage)) then
229  call virtual_items%push_back(nodem1_idx)
230  end if
231  else if (this%v_model2%is_local .and. &
232  this%v_model1%orig_rank == rank) then
233  ! the reverse case...
234  if (this%nodem2%check_stage(stage)) then
235  call virtual_items%push_back(nodem2_idx)
236  end if
237  else
238  ! send all of it
239  call this%VirtualDataContainerType%get_send_items(stage, rank, &
240  virtual_items)
241  end if
242 

◆ vx_has_mover()

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

Definition at line 247 of file VirtualExchange.f90.

248  class(VirtualExchangeType) :: this
249  logical(LGP) :: has_mover
250 
251  has_mover = .false.
252 

◆ vx_prepare_stage()

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

Definition at line 146 of file VirtualExchange.f90.

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