Skip to content

Commit d171425

Browse files
committed
mpi common
1 parent 6413886 commit d171425

File tree

3 files changed

+32
-65
lines changed

3 files changed

+32
-65
lines changed

src/common/m_mpi_common.fpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,38 @@ contains
217217
218218
end subroutine s_initialize_mpi_data
219219
220+
subroutine s_mpi_gather_data(my_vector, counts, gathered_vector, root)
221+
222+
implicit none
223+
integer, intent(in) :: counts ! Array of vector lengths for each process
224+
real(kind(0d0)), intent(in), dimension(counts) :: my_vector ! Input vector on each process
225+
integer, intent(in) :: root ! Rank of the root process
226+
real(kind(0d0)), allocatable, intent(out) :: gathered_vector(:) ! Gathered vector on the root process
227+
228+
integer :: i, offset, ierr
229+
integer, allocatable :: recounts(:), displs(:)
230+
231+
#ifdef MFC_MPI
232+
233+
allocate (recounts(num_procs))
234+
235+
call MPI_GATHER(counts, 1, MPI_INTEGER, recounts, 1, MPI_INTEGER, root, &
236+
MPI_COMM_WORLD, ierr)
237+
238+
allocate (displs(size(recounts)))
239+
240+
displs(1) = 0
241+
242+
do i = 2, size(recounts)
243+
displs(i) = displs(i - 1) + recounts(i - 1)
244+
end do
245+
246+
allocate (gathered_vector(sum(recounts)))
247+
call MPI_GATHERV(my_vector, counts, MPI_DOUBLE_PRECISION, gathered_vector, recounts, displs, MPI_DOUBLE_PRECISION, &
248+
root, MPI_COMM_WORLD, ierr)
249+
#endif
250+
end subroutine s_mpi_gather_data
251+
220252
subroutine mpi_bcast_time_step_values(proc_time, time_avg)
221253
222254
real(kind(0d0)), dimension(0:num_procs - 1), intent(inout) :: proc_time

src/post_process/m_mpi_proxy.fpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -141,38 +141,6 @@ contains
141141
142142
end subroutine s_initialize_mpi_proxy_module
143143
144-
subroutine s_mpi_gather_data(my_vector, counts, gathered_vector, root)
145-
146-
#ifdef MFC_MPI
147-
148-
implicit none
149-
integer, intent(in) :: counts ! Array of vector lengths for each process
150-
real(kind(0d0)), intent(in), dimension(counts) :: my_vector ! Input vector on each process
151-
integer, intent(in) :: root ! Rank of the root process
152-
real(kind(0d0)), allocatable, intent(out) :: gathered_vector(:) ! Gathered vector on the root process
153-
154-
integer :: i, offset, ierr
155-
integer, allocatable :: recounts(:), displs(:)
156-
157-
allocate (recounts(num_procs))
158-
159-
call MPI_GATHER(counts, 1, MPI_INTEGER, recounts, 1, MPI_INTEGER, root, &
160-
MPI_COMM_WORLD, ierr)
161-
162-
allocate (displs(size(recounts)))
163-
164-
displs(1) = 0
165-
166-
do i = 2, size(recounts)
167-
displs(i) = displs(i - 1) + recounts(i - 1)
168-
end do
169-
170-
allocate (gathered_vector(sum(recounts)))
171-
call MPI_GATHERV(my_vector, counts, MPI_DOUBLE_PRECISION, gathered_vector, recounts, displs, MPI_DOUBLE_PRECISION, &
172-
root, MPI_COMM_WORLD, ierr)
173-
#endif
174-
end subroutine s_mpi_gather_data
175-
176144
!> Since only processor with rank 0 is in charge of reading
177145
!! and checking the consistency of the user provided inputs,
178146
!! these are not available to the remaining processors. This

src/simulation/m_mpi_proxy.fpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -164,39 +164,6 @@ contains
164164
!! available to the other processors. Then, the purpose of
165165
!! this subroutine is to distribute the user inputs to the
166166
!! remaining processors in the communicator.
167-
168-
subroutine s_mpi_gather_data(my_vector, counts, gathered_vector, root)
169-
170-
implicit none
171-
integer, intent(in) :: counts ! Array of vector lengths for each process
172-
real(kind(0d0)), intent(in), dimension(counts) :: my_vector ! Input vector on each process
173-
integer, intent(in) :: root ! Rank of the root process
174-
real(kind(0d0)), allocatable, intent(out) :: gathered_vector(:) ! Gathered vector on the root process
175-
176-
integer :: i, offset, ierr
177-
integer, allocatable :: recounts(:), displs(:)
178-
179-
#ifdef MFC_MPI
180-
181-
allocate (recounts(num_procs))
182-
183-
call MPI_GATHER(counts, 1, MPI_INTEGER, recounts, 1, MPI_INTEGER, root, &
184-
MPI_COMM_WORLD, ierr)
185-
186-
allocate (displs(size(recounts)))
187-
188-
displs(1) = 0
189-
190-
do i = 2, size(recounts)
191-
displs(i) = displs(i - 1) + recounts(i - 1)
192-
end do
193-
194-
allocate (gathered_vector(sum(recounts)))
195-
call MPI_GATHERV(my_vector, counts, MPI_DOUBLE_PRECISION, gathered_vector, recounts, displs, MPI_DOUBLE_PRECISION, &
196-
root, MPI_COMM_WORLD, ierr)
197-
#endif
198-
end subroutine s_mpi_gather_data
199-
200167
subroutine s_mpi_bcast_user_inputs() ! ---------------------------------
201168
202169
#ifdef MFC_MPI

0 commit comments

Comments
 (0)