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

Data Types

type  mpimessagecachetype
 Facility to cache the constructed MPI datatypes. This will avoid having to construct them over and over again for the communication inside the timestep loop. This class deals with separate caches for different units (solutions or global) and for different types of. More...
 

Functions/Subroutines

subroutine mmc_init (this)
 
integer function mmc_get (this, unit, rank, stage, msg_id)
 
subroutine mmc_put (this, unit, rank, stage, msg_id, mpi_type)
 Put the mpi datatype for this particular unit, rank, and stage in cache. The datatype should be. More...
 
subroutine mmc_destroy (this)
 

Variables

integer(i4b), parameter, public mpi_bdy_rcv = 1
 receiving data (body) from ranks More...
 
integer(i4b), parameter, public mpi_bdy_snd = 2
 sending data (body) to ranks More...
 
integer(i4b), parameter, public nr_msg_types = 2
 the total number of message types to be cached More...
 

Function/Subroutine Documentation

◆ mmc_destroy()

subroutine mpimessagecachemodule::mmc_destroy ( class(mpimessagecachetype this)
private
Parameters
thisthe message cache

Definition at line 110 of file MpiMessageCache.f90.

111  class(MpiMessageCacheType) :: this !< the message cache
112  ! local
113  integer(I4B) :: i
114  class(*), pointer :: obj_ptr
115 
116  ! clear caches
117  do i = 1, this%cached_ids%size
118  obj_ptr => this%unit_caches%GetItem(i)
119  select type (obj_ptr)
120  class is (mpiunitcachetype)
121  call obj_ptr%destroy()
122  end select
123  end do
124  call this%unit_caches%Clear(destroy=.true.)
125 
126  call this%cached_ids%destroy()
127 
Here is the call graph for this function:

◆ mmc_get()

integer function mpimessagecachemodule::mmc_get ( class(mpimessagecachetype this,
integer(i4b)  unit,
integer(i4b)  rank,
integer(i4b)  stage,
integer(i4b)  msg_id 
)
private
Parameters
thisthe message cache
unitthe unit (solution or global)
rankthe rank of the MPI process to communicate with
stagethe simulation stage at which the message is sent
msg_idthe message type as an integer between 1 and NR_MSG_TYPES (see above for predefined values)
Returns
the resulting mpi datatype

Definition at line 48 of file MpiMessageCache.f90.

49  class(MpiMessageCacheType) :: this !< the message cache
50  integer(I4B) :: unit !< the unit (solution or global)
51  integer(I4B) :: rank !< the rank of the MPI process to communicate with
52  integer(I4B) :: stage !< the simulation stage at which the message is sent
53  integer(I4B) :: msg_id !< the message type as an integer between 1 and NR_MSG_TYPES (see above for predefined values)
54  integer :: mpi_type !< the resulting mpi datatype
55  ! local
56  integer(I4B) :: unit_idx
57  class(*), pointer :: obj_ptr
58 
59  mpi_type = no_cached_value
60 
61  unit_idx = this%cached_ids%get_index(unit)
62  if (unit_idx == -1) return ! not cached
63 
64  obj_ptr => this%unit_caches%GetItem(unit_idx)
65  select type (obj_ptr)
66  class is (mpiunitcachetype)
67  mpi_type = obj_ptr%get_cached(rank, stage, msg_id)
68  end select
69 

◆ mmc_init()

subroutine mpimessagecachemodule::mmc_init ( class(mpimessagecachetype this)
Parameters
thisthe message cache

Definition at line 38 of file MpiMessageCache.f90.

39  class(MpiMessageCacheType) :: this !< the message cache
40 
41  call this%cached_ids%init()
42 

◆ mmc_put()

subroutine mpimessagecachemodule::mmc_put ( class(mpimessagecachetype this,
integer(i4b)  unit,
integer(i4b)  rank,
integer(i4b)  stage,
integer(i4b)  msg_id,
integer  mpi_type 
)
private
Parameters
thisthe message cache
unitthe unit (solution or global)
rankthe rank of the MPI process to communicate with
stagethe simulation stage at which the message is sent
msg_idthe message type as an integer between 1 and NR_MSG_TYPES (see above for predefined values)
mpi_typethe mpi datatype to cache

Definition at line 75 of file MpiMessageCache.f90.

76  class(MpiMessageCacheType) :: this !< the message cache
77  integer(I4B) :: unit !< the unit (solution or global)
78  integer(I4B) :: rank !< the rank of the MPI process to communicate with
79  integer(I4B) :: stage !< the simulation stage at which the message is sent
80  integer(I4B) :: msg_id !< the message type as an integer between 1 and NR_MSG_TYPES (see above for predefined values)
81  integer :: mpi_type !< the mpi datatype to cache
82  ! local
83  integer(I4B) :: unit_idx
84  type(MpiUnitCacheType), pointer :: new_cache
85  class(*), pointer :: obj_ptr
86 
87  unit_idx = this%cached_ids%get_index(unit)
88  if (unit_idx == -1) then
89  ! add to vector with cached unit ids
90  call this%cached_ids%push_back(unit)
91  ! create and add unit cache
92  allocate (new_cache)
93  call new_cache%init(nr_sim_stages, nr_msg_types)
94  obj_ptr => new_cache
95  call this%unit_caches%Add(obj_ptr)
96  unit_idx = this%cached_ids%size
97  end if
98 
99  ! get the cache for this unit
100  obj_ptr => this%unit_caches%GetItem(unit_idx)
101  select type (obj_ptr)
102  class is (mpiunitcachetype)
103  call obj_ptr%cache(rank, stage, msg_id, mpi_type)
104  end select
105 

Variable Documentation

◆ mpi_bdy_rcv

integer(i4b), parameter, public mpimessagecachemodule::mpi_bdy_rcv = 1

Definition at line 11 of file MpiMessageCache.f90.

11  integer(I4B), public, parameter :: MPI_BDY_RCV = 1 !< receiving data (body) from ranks

◆ mpi_bdy_snd

integer(i4b), parameter, public mpimessagecachemodule::mpi_bdy_snd = 2

Definition at line 12 of file MpiMessageCache.f90.

12  integer(I4B), public, parameter :: MPI_BDY_SND = 2 !< sending data (body) to ranks

◆ nr_msg_types

integer(i4b), parameter, public mpimessagecachemodule::nr_msg_types = 2

Definition at line 13 of file MpiMessageCache.f90.

13  integer(I4B), public, parameter :: NR_MSG_TYPES = 2 !< the total number of message types to be cached