MODFLOW 6  version 6.7.0.dev1
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_clear (this)
 
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_clear()

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

Definition at line 111 of file MpiMessageCache.f90.

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

◆ mmc_destroy()

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

Definition at line 130 of file MpiMessageCache.f90.

131  class(MpiMessageCacheType) :: this !< the message cache
132  ! local
133  integer(I4B) :: i
134  class(*), pointer :: obj_ptr
135 
136  ! clear caches
137  do i = 1, this%cached_ids%size
138  obj_ptr => this%unit_caches%GetItem(i)
139  select type (obj_ptr)
140  class is (mpiunitcachetype)
141  call obj_ptr%destroy()
142  end select
143  end do
144  call this%unit_caches%Clear(destroy=.true.)
145 
146  call this%cached_ids%destroy()
147 
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 49 of file MpiMessageCache.f90.

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

◆ mmc_init()

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

Definition at line 39 of file MpiMessageCache.f90.

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

◆ 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 76 of file MpiMessageCache.f90.

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

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