32 type(mpi_grp_t) :: mpi_grp
35 logical :: double_sided_comms
53 class(ring_pattern_t),
intent(inout) :: this
54 type(mpi_grp_t),
intent(in) :: mpi_grp
55 logical,
intent(in) :: double_sided_comms
59 this%double_sided_comms = double_sided_comms
60 this%mpi_grp = mpi_grp
62 if (this%mpi_grp%size <= 0)
then
68 if (double_sided_comms)
then
69 this%nsteps = int((mpi_grp%size+2)/2)-1
71 this%nsteps = mpi_grp%size-1
74 write(
message(1),
'(a,i6,a)')
"Debug: The ring pattern will perform ", this%nsteps,
" steps."
81 integer pure function ring_pattern_get_nsteps(this)
82 class(ring_pattern_t),
intent(in) :: this
84 ring_pattern_get_nsteps = this%nsteps
106 integer pure function ring_pattern_get_rank_to(this, istep) result(rank_to)
107 class(ring_pattern_t),
intent(in) :: this
108 integer,
intent(in) :: istep
110 logical :: last_step, even_number_tasks, rank_to_first_half
112 rank_to = mod(this%mpi_grp%rank + istep, this%mpi_grp%size)
114 if (this%double_sided_comms)
then
115 last_step = istep == this%nsteps
116 even_number_tasks = mod(this%mpi_grp%size, 2) == 0
117 rank_to_first_half = rank_to < this%mpi_grp%size/2
119 if (last_step .and. even_number_tasks .and. rank_to_first_half)
then
128 integer,
intent(in) :: istep
130 logical :: last_step, even_number_tasks, rank_first_half
132 rank_fr = modulo(this%mpi_grp%rank - istep, this%mpi_grp%size)
134 if (this%double_sided_comms)
then
135 last_step = istep == this%nsteps
136 even_number_tasks = mod(this%mpi_grp%size, 2) == 0
137 rank_first_half = this%mpi_grp%rank < this%mpi_grp%size/2
138 if (last_step .and. even_number_tasks .and. rank_first_half)
then
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_info(no_lines, iunit, debug_only, stress, all_nodes, namespace)
This module is an helper to perform ring-pattern communications among all states.
integer pure function ring_pattern_get_nsteps(this)
Returns the total number of steps in the ring.
subroutine ring_pattern_start(this, mpi_grp, double_sided_comms)
Starts the ring pattern scheme.
integer pure function ring_pattern_get_rank_from(this, istep)
Returns the rank from which we receive the information.
integer pure function ring_pattern_get_rank_to(this, istep)
Returns the rank where to send the information.