MODFLOW 6  version 6.7.0.dev0
USGS Modular Hydrologic Model
mpimessagebuildermodule Module Reference

Data Types

type  vdcheadertype
 
type  vdcreceivermapstype
 
type  mpimessagebuildertype
 

Functions/Subroutines

subroutine create (this, map_sizes)
 
subroutine destroy (this)
 
subroutine init (this)
 
subroutine attach_data (this, vdc_models, vdc_exchanges)
 
subroutine release_data (this)
 
subroutine set_monitor (this, imon)
 
subroutine create_header_snd (this, rank, stage, hdrs_snd_type)
 Create the header data type to send to the remote process for this particular stage. From these data, the receiver can construct the. More...
 
subroutine create_header_rcv (this, hdr_rcv_type)
 
subroutine create_map_snd (this, rank, stage, map_snd_type)
 
subroutine create_map_rcv (this, rcv_map, nr_headers, map_rcv_type)
 
subroutine create_body_rcv (this, rank, stage, body_rcv_type)
 Create the body to receive based on the headers. More...
 
subroutine create_body_snd (this, rank, stage, headers, maps, body_snd_type)
 Create the body to send based on the received headers. More...
 
integer function create_vdc_snd_hdr (this, vdc, stage)
 Create send header for virtual data container, relative. More...
 
integer function create_vdc_snd_map (this, vdc, stage)
 Create a MPI datatype for sending the maps. More...
 
integer function create_vdc_rcv_body (this, vdc, rank, stage)
 
integer function create_vdc_snd_body (this, vdc, vdc_maps, rank, stage)
 
class(virtualdatacontainertype) function, pointer get_vdc_from_hdr (this, header)
 
subroutine get_mpi_datatype (this, virtual_data, el_displ, el_type, el_map_opt)
 Local routine to get elemental mpi data types representing the virtual data items. Types are automatically committed unless. More...
 
subroutine free_mpi_datatype (virtual_data, el_type)
 Local routine to free elemental mpi data types representing the virtual data items. This can't be done generally, because some. More...
 
subroutine get_mpitype_for_int (mem, el_displ, el_type)
 
subroutine get_mpitype_for_int1d (mem, el_displ, el_type, el_map)
 
subroutine get_mpitype_for_dbl (mem, el_displ, el_type)
 
subroutine get_mpitype_for_dbl1d (mem, el_displ, el_type, el_map)
 
subroutine get_mpitype_for_dbl2d (mem, el_displ, el_type, el_map)
 

Function/Subroutine Documentation

◆ attach_data()

subroutine mpimessagebuildermodule::attach_data ( class(mpimessagebuildertype this,
type(vdcptrtype), dimension(:), pointer  vdc_models,
type(vdcptrtype), dimension(:), pointer  vdc_exchanges 
)
private

Definition at line 82 of file MpiMessageBuilder.f90.

83  class(MpiMessageBuilderType) :: this
84  type(VdcPtrType), dimension(:), pointer :: vdc_models
85  type(VdcPtrType), dimension(:), pointer :: vdc_exchanges
86 
87  this%vdc_models => vdc_models
88  this%vdc_exchanges => vdc_exchanges
89 

◆ create()

subroutine mpimessagebuildermodule::create ( class(vdcreceivermapstype this,
integer(i4b), dimension(nr_vdc_element_maps)  map_sizes 
)

Definition at line 49 of file MpiMessageBuilder.f90.

50  class(VdcReceiverMapsType) :: this
51  integer(I4B), dimension(NR_VDC_ELEMENT_MAPS) :: map_sizes
52  ! local
53  integer(I4B) :: i
54 
55  do i = 1, nr_vdc_element_maps
56  this%el_maps(i)%nr_virt_elems = map_sizes(i)
57  allocate (this%el_maps(i)%remote_elem_shift(map_sizes(i)))
58  end do
59 

◆ create_body_rcv()

subroutine mpimessagebuildermodule::create_body_rcv ( class(mpimessagebuildertype this,
integer(i4b)  rank,
integer(i4b)  stage,
integer, intent(out)  body_rcv_type 
)
private

Definition at line 321 of file MpiMessageBuilder.f90.

322  class(MpiMessageBuilderType) :: this
323  integer(I4B) :: rank
324  integer(I4B) :: stage
325  integer, intent(out) :: body_rcv_type
326  ! local
327  integer(I4B) :: i, nr_types, offset
328  class(VirtualDataContainerType), pointer :: vdc
329  type(STLVecInt) :: model_idxs, exg_idxs
330  integer :: ierr
331  integer, dimension(:), allocatable :: types
332  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
333  integer, dimension(:), allocatable :: blk_cnts
334 
335  call model_idxs%init()
336  call exg_idxs%init()
337 
338  ! gather all containers from this rank
339  do i = 1, size(this%vdc_models)
340  vdc => this%vdc_models(i)%ptr
341  if (vdc%is_active .and. vdc%orig_rank == rank) then
342  if (this%imon > 0) then
343  write (this%imon, '(6x,a,i0)') "expecting model ", vdc%id
344  end if
345  call model_idxs%push_back(i)
346  end if
347  end do
348  do i = 1, size(this%vdc_exchanges)
349  vdc => this%vdc_exchanges(i)%ptr
350  if (vdc%is_active .and. vdc%orig_rank == rank) then
351  if (this%imon > 0) then
352  write (this%imon, '(6x,a,i0)') "expecting exchange ", vdc%id
353  end if
354  call exg_idxs%push_back(i)
355  end if
356  end do
357 
358  nr_types = model_idxs%size + exg_idxs%size
359  allocate (types(nr_types))
360  allocate (displs(nr_types))
361  allocate (blk_cnts(nr_types))
362 
363  ! loop over included containers
364  do i = 1, model_idxs%size
365  vdc => this%vdc_models(model_idxs%at(i))%ptr
366  call mpi_get_address(vdc%id, displs(i), ierr)
367  types(i) = this%create_vdc_rcv_body(vdc, rank, stage)
368  blk_cnts(i) = 1
369  end do
370  offset = model_idxs%size
371  do i = 1, exg_idxs%size
372  vdc => this%vdc_exchanges(exg_idxs%at(i))%ptr
373  call mpi_get_address(vdc%id, displs(i + offset), ierr)
374  blk_cnts(i + offset) = 1
375  types(i + offset) = this%create_vdc_rcv_body(vdc, rank, stage)
376  end do
377 
378  ! create a MPI data type for the virtual data containers to receive
379  call mpi_type_create_struct(nr_types, blk_cnts, displs, types, &
380  body_rcv_type, ierr)
381  call mpi_type_commit(body_rcv_type, ierr)
382  do i = 1, nr_types
383  call mpi_type_free(types(i), ierr)
384  end do
385 
386  call model_idxs%destroy()
387  call exg_idxs%destroy()
388  deallocate (types)
389  deallocate (displs)
390  deallocate (blk_cnts)
391 

◆ create_body_snd()

subroutine mpimessagebuildermodule::create_body_snd ( class(mpimessagebuildertype this,
integer(i4b)  rank,
integer(i4b)  stage,
type(vdcheadertype), dimension(:)  headers,
type(vdcreceivermapstype), dimension(:)  maps,
integer, intent(out)  body_snd_type 
)
private

Definition at line 396 of file MpiMessageBuilder.f90.

397  class(MpiMessageBuilderType) :: this
398  integer(I4B) :: rank
399  integer(I4B) :: stage
400  type(VdcHeaderType), dimension(:) :: headers
401  type(VdcReceiverMapsType), dimension(:) :: maps
402  integer, intent(out) :: body_snd_type
403  ! local
404  integer(I4B) :: i, nr_headers
405  class(VirtualDataContainerType), pointer :: vdc
406  integer :: ierr
407  integer, dimension(:), allocatable :: types
408  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
409  integer, dimension(:), allocatable :: blk_cnts
410 
411  nr_headers = size(headers)
412  allocate (types(nr_headers))
413  allocate (displs(nr_headers))
414  allocate (blk_cnts(nr_headers))
415 
416  do i = 1, nr_headers
417  vdc => this%get_vdc_from_hdr(headers(i))
418  call mpi_get_address(vdc%id, displs(i), ierr)
419  types(i) = this%create_vdc_snd_body(vdc, maps(i)%el_maps, rank, stage)
420  blk_cnts(i) = 1
421  end do
422 
423  ! create the list of virtual data containers to receive
424  call mpi_type_create_struct(nr_headers, blk_cnts, displs, &
425  types, body_snd_type, ierr)
426  call mpi_type_commit(body_snd_type, ierr)
427  do i = 1, nr_headers
428  call mpi_type_free(types(i), ierr)
429  end do
430 
431  deallocate (types)
432  deallocate (displs)
433  deallocate (blk_cnts)
434 

◆ create_header_rcv()

subroutine mpimessagebuildermodule::create_header_rcv ( class(mpimessagebuildertype this,
integer, intent(out)  hdr_rcv_type 
)
private

Definition at line 186 of file MpiMessageBuilder.f90.

187  class(MpiMessageBuilderType) :: this
188  integer, intent(out) :: hdr_rcv_type
189  ! local
190  integer :: ierr
191 
192  ! this will be for one data container, the mpi recv
193  ! call will accept an array of them, no need to create
194  ! an overarching contiguous type...
195  call mpi_type_contiguous(nr_vdc_element_maps + 2, mpi_integer, &
196  hdr_rcv_type, ierr)
197  call mpi_type_commit(hdr_rcv_type, ierr)
198 

◆ create_header_snd()

subroutine mpimessagebuildermodule::create_header_snd ( class(mpimessagebuildertype this,
integer(i4b)  rank,
integer(i4b)  stage,
integer, intent(out)  hdrs_snd_type 
)
private

Definition at line 112 of file MpiMessageBuilder.f90.

113  class(MpiMessageBuilderType) :: this
114  integer(I4B) :: rank
115  integer(I4B) :: stage
116  integer, intent(out) :: hdrs_snd_type
117  ! local
118  integer(I4B) :: i, offset, nr_types
119  class(VirtualDataContainerType), pointer :: vdc
120  integer :: ierr
121  type(STLVecInt) :: model_idxs, exg_idxs
122  integer, dimension(:), allocatable :: blk_cnts, types
123  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
124 
125  call model_idxs%init()
126  call exg_idxs%init()
127 
128  ! determine which containers to include
129  do i = 1, size(this%vdc_models)
130  vdc => this%vdc_models(i)%ptr
131  if (vdc%is_active .and. vdc%orig_rank == rank) then
132  call model_idxs%push_back(i)
133  end if
134  end do
135  do i = 1, size(this%vdc_exchanges)
136  vdc => this%vdc_exchanges(i)%ptr
137  if (vdc%is_active .and. vdc%orig_rank == rank) then
138  call exg_idxs%push_back(i)
139  end if
140  end do
141 
142  nr_types = model_idxs%size + exg_idxs%size
143  allocate (blk_cnts(nr_types))
144  allocate (types(nr_types))
145  allocate (displs(nr_types))
146 
147  if (this%imon > 0) then
148  write (this%imon, '(6x,a,*(i3))') "create headers for models: ", &
149  model_idxs%get_values()
150  write (this%imon, '(6x,a,*(i3))') "create headers for exchange: ", &
151  exg_idxs%get_values()
152  end if
153 
154  ! loop over containers
155  do i = 1, model_idxs%size
156  vdc => this%vdc_models(model_idxs%at(i))%ptr
157  call mpi_get_address(vdc%id, displs(i), ierr)
158  blk_cnts(i) = 1
159  types(i) = this%create_vdc_snd_hdr(vdc, stage)
160  end do
161  offset = model_idxs%size
162  do i = 1, exg_idxs%size
163  vdc => this%vdc_exchanges(exg_idxs%at(i))%ptr
164  call mpi_get_address(vdc%id, displs(i + offset), ierr)
165  blk_cnts(i + offset) = 1
166  types(i + offset) = this%create_vdc_snd_hdr(vdc, stage)
167  end do
168 
169  ! create a MPI data type for the headers to send
170  call mpi_type_create_struct(nr_types, blk_cnts, displs, types, &
171  hdrs_snd_type, ierr)
172  call mpi_type_commit(hdrs_snd_type, ierr)
173  do i = 1, nr_types
174  call mpi_type_free(types(i), ierr)
175  end do
176 
177  call model_idxs%destroy()
178  call exg_idxs%destroy()
179 
180  deallocate (blk_cnts)
181  deallocate (types)
182  deallocate (displs)
183 

◆ create_map_rcv()

subroutine mpimessagebuildermodule::create_map_rcv ( class(mpimessagebuildertype this,
type(vdcreceivermapstype), dimension(:)  rcv_map,
integer(i4b)  nr_headers,
integer, intent(out)  map_rcv_type 
)
private

Definition at line 278 of file MpiMessageBuilder.f90.

279  class(MpiMessageBuilderType) :: this
280  type(VdcReceiverMapsType), dimension(:) :: rcv_map
281  integer(I4B) :: nr_headers
282  integer, intent(out) :: map_rcv_type
283  ! local
284  integer(I4B) :: i, j, nr_elems, type_cnt
285  integer :: ierr, max_nr_maps
286  integer, dimension(:), allocatable :: types
287  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
288  integer, dimension(:), allocatable :: blk_cnts
289 
290  max_nr_maps = nr_headers * nr_vdc_element_maps
291  allocate (types(max_nr_maps))
292  allocate (displs(max_nr_maps))
293  allocate (blk_cnts(max_nr_maps))
294 
295  type_cnt = 0
296  do i = 1, nr_headers
297  do j = 1, nr_vdc_element_maps
298  nr_elems = rcv_map(i)%el_maps(j)%nr_virt_elems
299  if (nr_elems == 0) cycle
300 
301  type_cnt = type_cnt + 1
302  call mpi_get_address(rcv_map(i)%el_maps(j)%remote_elem_shift, &
303  displs(type_cnt), ierr)
304  call mpi_type_contiguous(nr_elems, mpi_integer, types(type_cnt), ierr)
305  blk_cnts(type_cnt) = 1
306  end do
307  end do
308 
309  call mpi_type_create_struct(type_cnt, blk_cnts, displs, types, &
310  map_rcv_type, ierr)
311  call mpi_type_commit(map_rcv_type, ierr)
312 
313  deallocate (types)
314  deallocate (displs)
315  deallocate (blk_cnts)
316 

◆ create_map_snd()

subroutine mpimessagebuildermodule::create_map_snd ( class(mpimessagebuildertype this,
integer(i4b)  rank,
integer(i4b)  stage,
integer, intent(out)  map_snd_type 
)
private

Definition at line 201 of file MpiMessageBuilder.f90.

202  class(MpiMessageBuilderType) :: this
203  integer(I4B) :: rank
204  integer(I4B) :: stage
205  integer, intent(out) :: map_snd_type
206  ! local
207  integer(I4B) :: i, offset, nr_types
208  class(VirtualDataContainerType), pointer :: vdc
209  integer :: ierr
210  type(STLVecInt) :: model_idxs, exg_idxs
211  integer, dimension(:), allocatable :: blk_cnts, types
212  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
213 
214  call model_idxs%init()
215  call exg_idxs%init()
216 
217  ! determine which containers to include,
218  ! currently models + exchanges
219  do i = 1, size(this%vdc_models)
220  vdc => this%vdc_models(i)%ptr
221  if (vdc%is_active .and. vdc%orig_rank == rank) then
222  call model_idxs%push_back(i)
223  end if
224  end do
225  do i = 1, size(this%vdc_exchanges)
226  vdc => this%vdc_exchanges(i)%ptr
227  if (vdc%is_active .and. vdc%orig_rank == rank) then
228  call exg_idxs%push_back(i)
229  end if
230  end do
231 
232  nr_types = model_idxs%size + exg_idxs%size
233  allocate (blk_cnts(nr_types))
234  allocate (types(nr_types))
235  allocate (displs(nr_types))
236 
237  if (this%imon > 0) then
238  write (this%imon, '(6x,a,*(i3))') "create maps for models: ", &
239  model_idxs%get_values()
240  write (this%imon, '(6x,a,*(i3))') "create maps for exchange: ", &
241  exg_idxs%get_values()
242  end if
243 
244  ! loop over containers
245  do i = 1, model_idxs%size
246  vdc => this%vdc_models(model_idxs%at(i))%ptr
247  call mpi_get_address(vdc%id, displs(i), ierr)
248  blk_cnts(i) = 1
249  types(i) = this%create_vdc_snd_map(vdc, stage)
250  end do
251  offset = model_idxs%size
252  do i = 1, exg_idxs%size
253  vdc => this%vdc_exchanges(exg_idxs%at(i))%ptr
254  call mpi_get_address(vdc%id, displs(i + offset), ierr)
255  blk_cnts(i + offset) = 1
256  types(i + offset) = this%create_vdc_snd_map(vdc, stage)
257  end do
258 
259  ! create a compound MPI data type for the maps
260  call mpi_type_create_struct(nr_types, blk_cnts, displs, types, &
261  map_snd_type, ierr)
262  call mpi_type_commit(map_snd_type, ierr)
263 
264  ! free the subtypes
265  do i = 1, nr_types
266  call mpi_type_free(types(i), ierr)
267  end do
268 
269  call model_idxs%destroy()
270  call exg_idxs%destroy()
271 
272  deallocate (blk_cnts)
273  deallocate (types)
274  deallocate (displs)
275 

◆ create_vdc_rcv_body()

integer function mpimessagebuildermodule::create_vdc_rcv_body ( class(mpimessagebuildertype this,
class(virtualdatacontainertype), pointer  vdc,
integer(i4b)  rank,
integer(i4b)  stage 
)
private

Definition at line 520 of file MpiMessageBuilder.f90.

521  class(MpiMessageBuilderType) :: this
522  class(VirtualDataContainerType), pointer :: vdc
523  integer(I4B) :: rank
524  integer(I4B) :: stage
525  integer :: new_type
526  ! local
527  type(STLVecInt) :: items
528  integer :: ierr
529  integer(kind=MPI_ADDRESS_KIND) :: offset
530  integer, dimension(:), allocatable :: types
531  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
532  integer, dimension(:), allocatable :: blk_cnts
533  integer(I4B) :: i
534  class(VirtualDataType), pointer :: vd
535 
536  call items%init()
537  call vdc%get_recv_items(stage, rank, items)
538  !if (this%imon > 0) call vdc%print_items(this%imon, items)
539 
540  allocate (types(items%size))
541  allocate (displs(items%size))
542  allocate (blk_cnts(items%size))
543 
544  call mpi_get_address(vdc%id, offset, ierr)
545 
546  do i = 1, items%size
547  vd => get_virtual_data_from_list(vdc%virtual_data_list, items%at(i))
548  call get_mpi_datatype(this, vd, displs(i), types(i))
549  blk_cnts(i) = 1
550  ! rebase w.r.t. id field
551  displs(i) = displs(i) - offset
552  end do
553 
554  call mpi_type_create_struct(items%size, blk_cnts, displs, &
555  types, new_type, ierr)
556  call mpi_type_commit(new_type, ierr)
557 
558  do i = 1, items%size
559  vd => get_virtual_data_from_list(vdc%virtual_data_list, items%at(i))
560  call free_mpi_datatype(vd, types(i))
561  end do
562 
563  deallocate (types)
564  deallocate (displs)
565  deallocate (blk_cnts)
566 
567  call items%destroy()
568 
Here is the call graph for this function:

◆ create_vdc_snd_body()

integer function mpimessagebuildermodule::create_vdc_snd_body ( class(mpimessagebuildertype this,
class(virtualdatacontainertype), pointer  vdc,
type(vdcelementmaptype), dimension(:)  vdc_maps,
integer(i4b)  rank,
integer(i4b)  stage 
)
private

Definition at line 571 of file MpiMessageBuilder.f90.

572  class(MpiMessageBuilderType) :: this
573  class(VirtualDataContainerType), pointer :: vdc
574  type(VdcElementMapType), dimension(:) :: vdc_maps
575  integer(I4B) :: rank
576  integer(I4B) :: stage
577  integer :: new_type
578  ! local
579  type(STLVecInt) :: items
580  integer :: ierr
581  integer(kind=MPI_ADDRESS_KIND) :: offset
582  integer, dimension(:), allocatable :: types
583  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
584  integer, dimension(:), allocatable :: blk_cnts
585  integer(I4B) :: i
586  class(VirtualDataType), pointer :: vd
587  integer(I4B), dimension(:), pointer, contiguous :: el_map
588 
589  call items%init()
590  call vdc%get_send_items(stage, rank, items)
591  !if (this%imon > 0) call vdc%print_items(this%imon, items)
592 
593  allocate (types(items%size))
594  allocate (displs(items%size))
595  allocate (blk_cnts(items%size))
596 
597  call mpi_get_address(vdc%id, offset, ierr)
598 
599  do i = 1, items%size
600  vd => get_virtual_data_from_list(vdc%virtual_data_list, items%at(i))
601  if (vd%map_type > 0) then
602  el_map => vdc_maps(vd%map_type)%remote_elem_shift
603  else
604  el_map => null()
605  end if
606  call get_mpi_datatype(this, vd, displs(i), types(i), el_map)
607  blk_cnts(i) = 1
608  ! rebase w.r.t. id field
609  displs(i) = displs(i) - offset
610  end do
611 
612  call mpi_type_create_struct(items%size, blk_cnts, displs, &
613  types, new_type, ierr)
614  call mpi_type_commit(new_type, ierr)
615 
616  do i = 1, items%size
617  vd => get_virtual_data_from_list(vdc%virtual_data_list, items%at(i))
618  call free_mpi_datatype(vd, types(i))
619  end do
620 
621  deallocate (types)
622  deallocate (displs)
623  deallocate (blk_cnts)
624 
625  call items%destroy()
626 
Here is the call graph for this function:

◆ create_vdc_snd_hdr()

integer function mpimessagebuildermodule::create_vdc_snd_hdr ( class(mpimessagebuildertype this,
class(virtualdatacontainertype vdc,
integer(i4b)  stage 
)
private

Definition at line 439 of file MpiMessageBuilder.f90.

440  class(MpiMessageBuilderType) :: this
441  class(VirtualDataContainerType) :: vdc
442  integer(I4B) :: stage
443  integer :: new_type ! the created MPI datatype, uncommitted
444  ! local
445  integer :: i, ierr
446  integer, dimension(NR_VDC_ELEMENT_MAPS + 2) :: blk_cnts
447  integer(kind=MPI_ADDRESS_KIND), dimension(NR_VDC_ELEMENT_MAPS + 2) :: displs
448  integer, dimension(NR_VDC_ELEMENT_MAPS + 2) :: types
449 
450  call mpi_get_address(vdc%id, displs(1), ierr)
451  types(1) = mpi_integer
452  blk_cnts(1) = 1
453  call mpi_get_address(vdc%container_type, displs(2), ierr)
454  types(2) = mpi_integer
455  blk_cnts(2) = 1
456  do i = 1, nr_vdc_element_maps
457  call mpi_get_address(vdc%element_maps(i)%nr_virt_elems, displs(i + 2), ierr)
458  types(i + 2) = mpi_integer
459  blk_cnts(i + 2) = 1
460  end do
461 
462  ! rebase to id field
463  displs = displs - displs(1)
464  call mpi_type_create_struct(nr_vdc_element_maps + 2, blk_cnts, &
465  displs, types, new_type, ierr)
466  call mpi_type_commit(new_type, ierr)
467 

◆ create_vdc_snd_map()

integer function mpimessagebuildermodule::create_vdc_snd_map ( class(mpimessagebuildertype this,
class(virtualdatacontainertype), pointer  vdc,
integer(i4b)  stage 
)
private

Definition at line 472 of file MpiMessageBuilder.f90.

473  class(MpiMessageBuilderType) :: this
474  class(VirtualDataContainerType), pointer :: vdc
475  integer(I4B) :: stage
476  integer :: new_type
477  ! local
478  integer(I4B) :: i, type_cnt
479  integer :: n_elems, ierr
480  integer(kind=MPI_ADDRESS_KIND) :: offset
481  integer, dimension(:), allocatable :: types
482  integer(kind=MPI_ADDRESS_KIND), dimension(:), allocatable :: displs
483  integer, dimension(:), allocatable :: blk_cnts
484 
485  allocate (types(nr_vdc_element_maps))
486  allocate (displs(nr_vdc_element_maps))
487  allocate (blk_cnts(nr_vdc_element_maps))
488 
489  ! displ relative to id field
490  call mpi_get_address(vdc%id, offset, ierr)
491 
492  type_cnt = 0
493  do i = 1, nr_vdc_element_maps
494  n_elems = vdc%element_maps(i)%nr_virt_elems
495  if (n_elems == 0) cycle ! only non-empty maps are sent
496 
497  type_cnt = type_cnt + 1
498  call mpi_get_address(vdc%element_maps(i)%remote_elem_shift, &
499  displs(type_cnt), ierr)
500  call mpi_type_contiguous(n_elems, mpi_integer, types(type_cnt), ierr)
501  call mpi_type_commit(types(type_cnt), ierr)
502  blk_cnts(type_cnt) = 1
503  displs(type_cnt) = displs(type_cnt) - offset
504  end do
505 
506  call mpi_type_create_struct(type_cnt, blk_cnts, displs, types, &
507  new_type, ierr)
508  call mpi_type_commit(new_type, ierr)
509 
510  do i = 1, type_cnt
511  call mpi_type_free(types(i), ierr)
512  end do
513 
514  deallocate (types)
515  deallocate (displs)
516  deallocate (blk_cnts)
517 

◆ destroy()

subroutine mpimessagebuildermodule::destroy ( class(vdcreceivermapstype this)
private

Definition at line 62 of file MpiMessageBuilder.f90.

63  class(VdcReceiverMapsType) :: this
64  ! local
65  integer(I4B) :: i
66 
67  do i = 1, nr_vdc_element_maps
68  if (associated(this%el_maps(i)%remote_elem_shift)) then
69  deallocate (this%el_maps(i)%remote_elem_shift)
70  end if
71  end do
72 

◆ free_mpi_datatype()

subroutine mpimessagebuildermodule::free_mpi_datatype ( class(virtualdatatype), pointer  virtual_data,
integer  el_type 
)

Definition at line 707 of file MpiMessageBuilder.f90.

708  class(VirtualDataType), pointer :: virtual_data
709  integer :: el_type
710  ! local
711  type(MemoryType), pointer :: mt
712  integer :: ierr
713 
714  mt => virtual_data%virtual_mt
715  if (associated(mt%intsclr)) then
716  ! type is MPI_INTEGER, don't free this!
717  return
718  else if (associated(mt%dblsclr)) then
719  ! type is MPI_DOUBLE_PRECISION, don't free this!
720  return
721  else if (associated(mt%logicalsclr)) then
722  ! type is MPI_LOGICAL, don't free this!
723  return
724  else
725  ! all other types are freed here
726  call mpi_type_free(el_type, ierr)
727  return
728  end if
729 
Here is the caller graph for this function:

◆ get_mpi_datatype()

subroutine mpimessagebuildermodule::get_mpi_datatype ( class(mpimessagebuildertype this,
class(virtualdatatype), pointer  virtual_data,
integer(kind=mpi_address_kind)  el_displ,
integer  el_type,
integer(i4b), dimension(:), optional, pointer, contiguous  el_map_opt 
)
private
Parameters
el_map_optoptional, and can be null

Definition at line 660 of file MpiMessageBuilder.f90.

661  use simmodule, only: ustop
662  class(MpiMessageBuilderType) :: this
663  class(VirtualDataType), pointer :: virtual_data
664  integer(kind=MPI_ADDRESS_KIND) :: el_displ
665  integer :: el_type
666  integer(I4B), dimension(:), pointer, contiguous, optional :: el_map_opt !< optional, and can be null
667  ! local
668  type(MemoryType), pointer :: mt
669  integer(I4B), dimension(:), pointer, contiguous :: el_map
670 
671  el_map => null()
672  if (present(el_map_opt)) el_map => el_map_opt
673 
674  if (this%imon > 0) then
675  if (.not. associated(el_map)) then
676  write (this%imon, '(8x,2a,i0)') virtual_data%var_name, ' all ', &
677  virtual_data%virtual_mt%isize
678  else
679  write (this%imon, '(8x,2a,i0)') virtual_data%var_name, &
680  ' with map size ', size(el_map)
681  end if
682  end if
683 
684  mt => virtual_data%virtual_mt
685 
686  if (associated(mt%intsclr)) then
687  call get_mpitype_for_int(mt, el_displ, el_type)
688  else if (associated(mt%aint1d)) then
689  call get_mpitype_for_int1d(mt, el_displ, el_type, el_map)
690  else if (associated(mt%dblsclr)) then
691  call get_mpitype_for_dbl(mt, el_displ, el_type)
692  else if (associated(mt%adbl1d)) then
693  call get_mpitype_for_dbl1d(mt, el_displ, el_type, el_map)
694  else if (associated(mt%adbl2d)) then
695  call get_mpitype_for_dbl2d(mt, el_displ, el_type, el_map)
696  else
697  write (*, *) 'unsupported datatype in MPI messaging for ', &
698  virtual_data%var_name, virtual_data%mem_path
699  call ustop()
700  end if
701 
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public ustop(stopmess, ioutlocal)
Stop the simulation.
Definition: Sim.f90:312
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_mpitype_for_dbl()

subroutine mpimessagebuildermodule::get_mpitype_for_dbl ( type(memorytype), pointer  mem,
integer(kind=mpi_address_kind)  el_displ,
integer  el_type 
)
private

Definition at line 764 of file MpiMessageBuilder.f90.

765  type(MemoryType), pointer :: mem
766  integer(kind=MPI_ADDRESS_KIND) :: el_displ
767  integer :: el_type
768  ! local
769  integer :: ierr
770 
771  call mpi_get_address(mem%dblsclr, el_displ, ierr)
772  el_type = mpi_double_precision
773  ! no need to commit primitive type
774 
Here is the caller graph for this function:

◆ get_mpitype_for_dbl1d()

subroutine mpimessagebuildermodule::get_mpitype_for_dbl1d ( type(memorytype), pointer  mem,
integer(kind=mpi_address_kind)  el_displ,
integer  el_type,
integer, dimension(:), pointer  el_map 
)
private

Definition at line 777 of file MpiMessageBuilder.f90.

778  type(MemoryType), pointer :: mem
779  integer(kind=MPI_ADDRESS_KIND) :: el_displ
780  integer :: el_type
781  integer, dimension(:), pointer :: el_map
782  ! local
783  integer :: ierr
784 
785  call mpi_get_address(mem%adbl1d, el_displ, ierr)
786  if (associated(el_map)) then
787  call mpi_type_create_indexed_block( &
788  size(el_map), 1, el_map, mpi_double_precision, el_type, ierr)
789  else
790  call mpi_type_contiguous(mem%isize, mpi_double_precision, el_type, ierr)
791  end if
792  call mpi_type_commit(el_type, ierr)
793 
Here is the caller graph for this function:

◆ get_mpitype_for_dbl2d()

subroutine mpimessagebuildermodule::get_mpitype_for_dbl2d ( type(memorytype), pointer  mem,
integer(kind=mpi_address_kind)  el_displ,
integer  el_type,
integer, dimension(:), pointer  el_map 
)
private

Definition at line 796 of file MpiMessageBuilder.f90.

797  type(MemoryType), pointer :: mem
798  integer(kind=MPI_ADDRESS_KIND) :: el_displ
799  integer :: el_type
800  integer, dimension(:), pointer :: el_map
801  ! local
802  integer :: ierr
803  integer :: entry_type
804 
805  call mpi_get_address(mem%adbl2d, el_displ, ierr)
806  if (associated(el_map)) then
807  call mpi_type_contiguous( &
808  size(mem%adbl2d, dim=1), mpi_double_precision, entry_type, ierr)
809  call mpi_type_create_indexed_block( &
810  size(el_map), 1, el_map, entry_type, el_type, ierr)
811  else
812  call mpi_type_contiguous(mem%isize, mpi_double_precision, el_type, ierr)
813  end if
814  call mpi_type_commit(el_type, ierr)
815 
Here is the caller graph for this function:

◆ get_mpitype_for_int()

subroutine mpimessagebuildermodule::get_mpitype_for_int ( type(memorytype), pointer  mem,
integer(kind=mpi_address_kind)  el_displ,
integer  el_type 
)
private

Definition at line 732 of file MpiMessageBuilder.f90.

733  type(MemoryType), pointer :: mem
734  integer(kind=MPI_ADDRESS_KIND) :: el_displ
735  integer :: el_type
736  ! local
737  integer :: ierr
738 
739  call mpi_get_address(mem%intsclr, el_displ, ierr)
740  el_type = mpi_integer
741  ! no need to commit primitive type
742 
Here is the caller graph for this function:

◆ get_mpitype_for_int1d()

subroutine mpimessagebuildermodule::get_mpitype_for_int1d ( type(memorytype), pointer  mem,
integer(kind=mpi_address_kind)  el_displ,
integer  el_type,
integer, dimension(:), pointer  el_map 
)
private

Definition at line 745 of file MpiMessageBuilder.f90.

746  type(MemoryType), pointer :: mem
747  integer(kind=MPI_ADDRESS_KIND) :: el_displ
748  integer :: el_type
749  integer, dimension(:), pointer :: el_map
750  ! local
751  integer :: ierr
752 
753  call mpi_get_address(mem%aint1d, el_displ, ierr)
754  if (associated(el_map)) then
755  call mpi_type_create_indexed_block( &
756  size(el_map), 1, el_map, mpi_integer, el_type, ierr)
757  else
758  call mpi_type_contiguous(mem%isize, mpi_integer, el_type, ierr)
759  end if
760  call mpi_type_commit(el_type, ierr)
761 
Here is the caller graph for this function:

◆ get_vdc_from_hdr()

class(virtualdatacontainertype) function, pointer mpimessagebuildermodule::get_vdc_from_hdr ( class(mpimessagebuildertype this,
type(vdcheadertype header 
)
private

Definition at line 629 of file MpiMessageBuilder.f90.

630  class(MpiMessageBuilderType) :: this
631  type(VdcHeaderType) :: header
632  class(VirtualDataContainerType), pointer :: vdc
633  ! local
634  integer(I4B) :: i
635 
636  vdc => null()
637  if (header%container_type == vdc_gwfmodel_type .or. &
638  header%container_type == vdc_gwtmodel_type .or. &
639  header%container_type == vdc_gwemodel_type) then
640  do i = 1, size(this%vdc_models)
641  vdc => this%vdc_models(i)%ptr
642  if (vdc%id == header%id) return
643  vdc => null()
644  end do
645  else if (header%container_type == vdc_gwfexg_type .or. &
646  header%container_type == vdc_gwtexg_type .or. &
647  header%container_type == vdc_gweexg_type) then
648  do i = 1, size(this%vdc_exchanges)
649  vdc => this%vdc_exchanges(i)%ptr
650  if (vdc%id == header%id) return
651  vdc => null()
652  end do
653  end if
654 

◆ init()

subroutine mpimessagebuildermodule::init ( class(mpimessagebuildertype this)
private

Definition at line 75 of file MpiMessageBuilder.f90.

76  class(MpiMessageBuilderType) :: this
77 
78  this%imon = -1
79 

◆ release_data()

subroutine mpimessagebuildermodule::release_data ( class(mpimessagebuildertype this)
private

Definition at line 92 of file MpiMessageBuilder.f90.

93  class(MpiMessageBuilderType) :: this
94 
95  this%vdc_models => null()
96  this%vdc_exchanges => null()
97 

◆ set_monitor()

subroutine mpimessagebuildermodule::set_monitor ( class(mpimessagebuildertype this,
integer(i4b)  imon 
)
private

Definition at line 100 of file MpiMessageBuilder.f90.

101  class(MpiMessageBuilderType) :: this
102  integer(I4B) :: imon
103 
104  this%imon = imon
105