Line data Source code
1 : #!-------------------------------------------------------------------------------------------------!
2 : #! CP2K: A general program to perform molecular dynamics simulations !
3 : #! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4 : #! !
5 : #! SPDX-License-Identifier: GPL-2.0-or-later !
6 : #!-------------------------------------------------------------------------------------------------!
7 : #:mute
8 : #:set nametype1 = ['i', 'l', 'd', 'r', 'z', 'c']
9 : #:set type1 = ['INTEGER(KIND=int_4)', 'INTEGER(KIND=int_8)', 'REAL(kind=real_8)', 'REAL(kind=real_4)', 'COMPLEX(kind=real_8)', 'COMPLEX(kind=real_4)']
10 : #:set mpi_type1 = ['MPI_INTEGER', 'MPI_INTEGER8', 'MPI_DOUBLE_PRECISION', 'MPI_REAL', 'MPI_DOUBLE_COMPLEX', 'MPI_COMPLEX']
11 : #:set mpi_2type1 = ['MPI_2INTEGER', 'MPI_INTEGER8', 'MPI_2DOUBLE_PRECISION', 'MPI_2REAL', 'MPI_2DOUBLE_COMPLEX', 'MPI_2COMPLEX']
12 : #:set kind1 = ['int_4', 'int_8', 'real_8', 'real_4', 'real_8', 'real_4']
13 : #:set bytes1 = ['int_4_size','int_8_size','real_8_size','real_4_size','(2*real_8_size)','(2*real_4_size)']
14 : #:set handle1 = ['17', '19', '3', '1', '7', '5']
15 : #:set zero1 = ['0_int_4', '0_int_8', '0.0_real_8', '0.0_real_4', 'CMPLX(0.0, 0.0, real_8)', 'CMPLX(0.0, 0.0, real_4)']
16 : #:set one1 = ['1_int_4', '1_int_8', '1.0_real_8', '1.0_real_4', 'CMPLX(1.0, 0.0, real_8)', 'CMPLX(1.0, 0.0, real_4)']
17 : #:set inst_params = list(zip(nametype1, type1, mpi_type1, mpi_2type1, kind1, bytes1, handle1, zero1, one1))
18 : #:endmute
19 : #:for nametype1, type1, mpi_type1, mpi_2type1, kind1, bytes1, handle1, zero1, one1 in inst_params
20 : ! **************************************************************************************************
21 : !> \brief Shift around the data in msg
22 : !> \param[in,out] msg Rank-2 data to shift
23 : !> \param[in] comm message passing environment identifier
24 : !> \param[in] displ_in displacements (?)
25 : !> \par Example
26 : !> msg will be moved from rank to rank+displ_in (in a circular way)
27 : !> \par Limitations
28 : !> * displ_in will be 1 by default (others not tested)
29 : !> * the message array needs to be the same size on all processes
30 : ! **************************************************************************************************
31 4248 : SUBROUTINE mp_shift_${nametype1}$m(msg, comm, displ_in)
32 :
33 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
34 : CLASS(mp_comm_type), INTENT(IN) :: comm
35 : INTEGER, INTENT(IN), OPTIONAL :: displ_in
36 :
37 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_shift_${nametype1}$m'
38 :
39 : INTEGER :: handle, ierror
40 : #if defined(__parallel)
41 : INTEGER :: displ, left, &
42 : msglen, myrank, nprocs, &
43 : right, tag
44 : #endif
45 :
46 : ierror = 0
47 1416 : CALL mp_timeset(routineN, handle)
48 :
49 : #if defined(__parallel)
50 1416 : CALL mpi_comm_rank(comm%handle, myrank, ierror)
51 1416 : IF (ierror /= 0) CALL mp_stop(ierror, "mpi_comm_rank @ "//routineN)
52 1416 : CALL mpi_comm_size(comm%handle, nprocs, ierror)
53 1416 : IF (ierror /= 0) CALL mp_stop(ierror, "mpi_comm_size @ "//routineN)
54 1416 : IF (PRESENT(displ_in)) THEN
55 0 : displ = displ_in
56 : ELSE
57 : displ = 1
58 : END IF
59 1416 : right = MODULO(myrank + displ, nprocs)
60 1416 : left = MODULO(myrank - displ, nprocs)
61 1416 : tag = 17
62 4248 : msglen = SIZE(msg)
63 : CALL mpi_sendrecv_replace(msg, msglen, ${mpi_type1}$, right, tag, left, tag, &
64 1416 : comm%handle, MPI_STATUS_IGNORE, ierror)
65 1416 : IF (ierror /= 0) CALL mp_stop(ierror, "mpi_sendrecv_replace @ "//routineN)
66 1416 : CALL add_perf(perf_id=7, count=1, msg_size=msglen*${bytes1}$)
67 : #else
68 : MARK_USED(msg)
69 : MARK_USED(comm)
70 : MARK_USED(displ_in)
71 : #endif
72 1416 : CALL mp_timestop(handle)
73 :
74 1416 : END SUBROUTINE mp_shift_${nametype1}$m
75 :
76 : ! **************************************************************************************************
77 : !> \brief Shift around the data in msg
78 : !> \param[in,out] msg Data to shift
79 : !> \param[in] comm message passing environment identifier
80 : !> \param[in] displ_in displacements (?)
81 : !> \par Example
82 : !> msg will be moved from rank to rank+displ_in (in a circular way)
83 : !> \par Limitations
84 : !> * displ_in will be 1 by default (others not tested)
85 : !> * the message array needs to be the same size on all processes
86 : ! **************************************************************************************************
87 12690 : SUBROUTINE mp_shift_${nametype1}$ (msg, comm, displ_in)
88 :
89 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
90 : CLASS(mp_comm_type), INTENT(IN) :: comm
91 : INTEGER, INTENT(IN), OPTIONAL :: displ_in
92 :
93 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_shift_${nametype1}$'
94 :
95 : INTEGER :: handle, ierror
96 : #if defined(__parallel)
97 : INTEGER :: displ, left, &
98 : msglen, myrank, nprocs, &
99 : right, tag
100 : #endif
101 :
102 : ierror = 0
103 4230 : CALL mp_timeset(routineN, handle)
104 :
105 : #if defined(__parallel)
106 4230 : CALL mpi_comm_rank(comm%handle, myrank, ierror)
107 4230 : IF (ierror /= 0) CALL mp_stop(ierror, "mpi_comm_rank @ "//routineN)
108 4230 : CALL mpi_comm_size(comm%handle, nprocs, ierror)
109 4230 : IF (ierror /= 0) CALL mp_stop(ierror, "mpi_comm_size @ "//routineN)
110 4230 : IF (PRESENT(displ_in)) THEN
111 6 : displ = displ_in
112 : ELSE
113 : displ = 1
114 : END IF
115 4230 : right = MODULO(myrank + displ, nprocs)
116 4230 : left = MODULO(myrank - displ, nprocs)
117 4230 : tag = 19
118 4230 : msglen = SIZE(msg)
119 : CALL mpi_sendrecv_replace(msg, msglen, ${mpi_type1}$, right, tag, left, &
120 4230 : tag, comm%handle, MPI_STATUS_IGNORE, ierror)
121 4230 : IF (ierror /= 0) CALL mp_stop(ierror, "mpi_sendrecv_replace @ "//routineN)
122 4230 : CALL add_perf(perf_id=7, count=1, msg_size=msglen*${bytes1}$)
123 : #else
124 : MARK_USED(msg)
125 : MARK_USED(comm)
126 : MARK_USED(displ_in)
127 : #endif
128 4230 : CALL mp_timestop(handle)
129 :
130 4230 : END SUBROUTINE mp_shift_${nametype1}$
131 :
132 : ! **************************************************************************************************
133 : !> \brief All-to-all data exchange, rank-1 data of different sizes
134 : !> \param[in] sb Data to send
135 : !> \param[in] scount Data counts for data sent to other processes
136 : !> \param[in] sdispl Respective data offsets for data sent to process
137 : !> \param[in,out] rb Buffer into which to receive data
138 : !> \param[in] rcount Data counts for data received from other
139 : !> processes
140 : !> \param[in] rdispl Respective data offsets for data received from
141 : !> other processes
142 : !> \param[in] comm Message passing environment identifier
143 : !> \par MPI mapping
144 : !> mpi_alltoallv
145 : !> \par Array sizes
146 : !> The scount, rcount, and the sdispl and rdispl arrays have a
147 : !> size equal to the number of processes.
148 : !> \par Offsets
149 : !> Values in sdispl and rdispl start with 0.
150 : ! **************************************************************************************************
151 1033746 : SUBROUTINE mp_alltoall_${nametype1}$11v(sb, scount, sdispl, rb, rcount, rdispl, comm)
152 :
153 : ${type1}$, DIMENSION(:), INTENT(IN), CONTIGUOUS :: sb
154 : INTEGER, DIMENSION(:), INTENT(IN), CONTIGUOUS :: scount, sdispl
155 : ${type1}$, DIMENSION(:), INTENT(INOUT), CONTIGUOUS :: rb
156 : INTEGER, DIMENSION(:), INTENT(IN), CONTIGUOUS :: rcount, rdispl
157 : CLASS(mp_comm_type), INTENT(IN) :: comm
158 :
159 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$11v'
160 :
161 : INTEGER :: handle
162 : #if defined(__parallel)
163 : INTEGER :: ierr, msglen
164 : #else
165 : INTEGER :: i
166 : #endif
167 :
168 1033746 : CALL mp_timeset(routineN, handle)
169 :
170 : #if defined(__parallel)
171 : CALL mpi_alltoallv(sb, scount, sdispl, ${mpi_type1}$, &
172 1033746 : rb, rcount, rdispl, ${mpi_type1}$, comm%handle, ierr)
173 1033746 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoallv @ "//routineN)
174 6089448 : msglen = SUM(scount) + SUM(rcount)
175 1033746 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
176 : #else
177 : MARK_USED(comm)
178 : MARK_USED(scount)
179 : MARK_USED(sdispl)
180 : !$OMP PARALLEL DO DEFAULT(NONE) PRIVATE(i) SHARED(rcount,rdispl,sdispl,rb,sb)
181 : DO i = 1, rcount(1)
182 : rb(rdispl(1) + i) = sb(sdispl(1) + i)
183 : END DO
184 : #endif
185 1033746 : CALL mp_timestop(handle)
186 :
187 1033746 : END SUBROUTINE mp_alltoall_${nametype1}$11v
188 :
189 : ! **************************************************************************************************
190 : !> \brief All-to-all data exchange, rank-2 data of different sizes
191 : !> \param sb ...
192 : !> \param scount ...
193 : !> \param sdispl ...
194 : !> \param rb ...
195 : !> \param rcount ...
196 : !> \param rdispl ...
197 : !> \param comm ...
198 : !> \par MPI mapping
199 : !> mpi_alltoallv
200 : !> \note see mp_alltoall_${nametype1}$11v
201 : ! **************************************************************************************************
202 3941175 : SUBROUTINE mp_alltoall_${nametype1}$22v(sb, scount, sdispl, rb, rcount, rdispl, comm)
203 :
204 : ${type1}$, DIMENSION(:, :), &
205 : INTENT(IN), CONTIGUOUS :: sb
206 : INTEGER, DIMENSION(:), INTENT(IN), CONTIGUOUS :: scount, sdispl
207 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, &
208 : INTENT(INOUT) :: rb
209 : INTEGER, DIMENSION(:), INTENT(IN), CONTIGUOUS :: rcount, rdispl
210 : CLASS(mp_comm_type), INTENT(IN) :: comm
211 :
212 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$22v'
213 :
214 : INTEGER :: handle
215 : #if defined(__parallel)
216 : INTEGER :: ierr, msglen
217 : #endif
218 :
219 3941175 : CALL mp_timeset(routineN, handle)
220 :
221 : #if defined(__parallel)
222 : CALL mpi_alltoallv(sb, scount, sdispl, ${mpi_type1}$, &
223 3941175 : rb, rcount, rdispl, ${mpi_type1}$, comm%handle, ierr)
224 3941175 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoallv @ "//routineN)
225 23645120 : msglen = SUM(scount) + SUM(rcount)
226 3941175 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*2*${bytes1}$)
227 : #else
228 : MARK_USED(comm)
229 : MARK_USED(scount)
230 : MARK_USED(sdispl)
231 : MARK_USED(rcount)
232 : MARK_USED(rdispl)
233 : rb = sb
234 : #endif
235 3941175 : CALL mp_timestop(handle)
236 :
237 3941175 : END SUBROUTINE mp_alltoall_${nametype1}$22v
238 :
239 : ! **************************************************************************************************
240 : !> \brief All-to-all data exchange, rank 1 arrays, equal sizes
241 : !> \param[in] sb array with data to send
242 : !> \param[out] rb array into which data is received
243 : !> \param[in] count number of elements to send/receive (product of the
244 : !> extents of the first two dimensions)
245 : !> \param[in] comm Message passing environment identifier
246 : !> \par Index meaning
247 : !> \par The first two indices specify the data while the last index counts
248 : !> the processes
249 : !> \par Sizes of ranks
250 : !> All processes have the same data size.
251 : !> \par MPI mapping
252 : !> mpi_alltoall
253 : ! **************************************************************************************************
254 1838534 : SUBROUTINE mp_alltoall_${nametype1}$ (sb, rb, count, comm)
255 :
256 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: sb
257 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(OUT) :: rb
258 : INTEGER, INTENT(IN) :: count
259 : CLASS(mp_comm_type), INTENT(IN) :: comm
260 :
261 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$'
262 :
263 : INTEGER :: handle
264 : #if defined(__parallel)
265 : INTEGER :: ierr, msglen, np
266 : #endif
267 :
268 919267 : CALL mp_timeset(routineN, handle)
269 :
270 : #if defined(__parallel)
271 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
272 919267 : rb, count, ${mpi_type1}$, comm%handle, ierr)
273 919267 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
274 919267 : CALL mpi_comm_size(comm%handle, np, ierr)
275 919267 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
276 919267 : msglen = 2*count*np
277 919267 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
278 : #else
279 : MARK_USED(count)
280 : MARK_USED(comm)
281 : rb = sb
282 : #endif
283 919267 : CALL mp_timestop(handle)
284 :
285 919267 : END SUBROUTINE mp_alltoall_${nametype1}$
286 :
287 : ! **************************************************************************************************
288 : !> \brief All-to-all data exchange, rank-2 arrays, equal sizes
289 : !> \param sb ...
290 : !> \param rb ...
291 : !> \param count ...
292 : !> \param commp ...
293 : !> \note see mp_alltoall_${nametype1}$
294 : ! **************************************************************************************************
295 823708 : SUBROUTINE mp_alltoall_${nametype1}$22(sb, rb, count, comm)
296 :
297 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, INTENT(IN) :: sb
298 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, INTENT(OUT) :: rb
299 : INTEGER, INTENT(IN) :: count
300 : CLASS(mp_comm_type), INTENT(IN) :: comm
301 :
302 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$22'
303 :
304 : INTEGER :: handle
305 : #if defined(__parallel)
306 : INTEGER :: ierr, msglen, np
307 : #endif
308 :
309 411854 : CALL mp_timeset(routineN, handle)
310 :
311 : #if defined(__parallel)
312 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
313 411854 : rb, count, ${mpi_type1}$, comm%handle, ierr)
314 411854 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
315 411854 : CALL mpi_comm_size(comm%handle, np, ierr)
316 411854 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
317 1235562 : msglen = 2*SIZE(sb)*np
318 411854 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
319 : #else
320 : MARK_USED(count)
321 : MARK_USED(comm)
322 : rb = sb
323 : #endif
324 411854 : CALL mp_timestop(handle)
325 :
326 411854 : END SUBROUTINE mp_alltoall_${nametype1}$22
327 :
328 : ! **************************************************************************************************
329 : !> \brief All-to-all data exchange, rank-3 data with equal sizes
330 : !> \param sb ...
331 : !> \param rb ...
332 : !> \param count ...
333 : !> \param comm ...
334 : !> \note see mp_alltoall_${nametype1}$
335 : ! **************************************************************************************************
336 0 : SUBROUTINE mp_alltoall_${nametype1}$33(sb, rb, count, comm)
337 :
338 : ${type1}$, DIMENSION(:, :, :), CONTIGUOUS, INTENT(IN) :: sb
339 : ${type1}$, DIMENSION(:, :, :), CONTIGUOUS, INTENT(OUT) :: rb
340 : INTEGER, INTENT(IN) :: count
341 : CLASS(mp_comm_type), INTENT(IN) :: comm
342 :
343 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$33'
344 :
345 : INTEGER :: handle
346 : #if defined(__parallel)
347 : INTEGER :: ierr, msglen, np
348 : #endif
349 :
350 0 : CALL mp_timeset(routineN, handle)
351 :
352 : #if defined(__parallel)
353 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
354 0 : rb, count, ${mpi_type1}$, comm%handle, ierr)
355 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
356 0 : CALL mpi_comm_size(comm%handle, np, ierr)
357 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
358 0 : msglen = 2*count*np
359 0 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
360 : #else
361 : MARK_USED(count)
362 : MARK_USED(comm)
363 : rb = sb
364 : #endif
365 0 : CALL mp_timestop(handle)
366 :
367 0 : END SUBROUTINE mp_alltoall_${nametype1}$33
368 :
369 : ! **************************************************************************************************
370 : !> \brief All-to-all data exchange, rank 4 data, equal sizes
371 : !> \param sb ...
372 : !> \param rb ...
373 : !> \param count ...
374 : !> \param comm ...
375 : !> \note see mp_alltoall_${nametype1}$
376 : ! **************************************************************************************************
377 0 : SUBROUTINE mp_alltoall_${nametype1}$44(sb, rb, count, comm)
378 :
379 : ${type1}$, DIMENSION(:, :, :, :), CONTIGUOUS, &
380 : INTENT(IN) :: sb
381 : ${type1}$, DIMENSION(:, :, :, :), CONTIGUOUS, &
382 : INTENT(OUT) :: rb
383 : INTEGER, INTENT(IN) :: count
384 : CLASS(mp_comm_type), INTENT(IN) :: comm
385 :
386 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$44'
387 :
388 : INTEGER :: handle
389 : #if defined(__parallel)
390 : INTEGER :: ierr, msglen, np
391 : #endif
392 :
393 0 : CALL mp_timeset(routineN, handle)
394 :
395 : #if defined(__parallel)
396 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
397 0 : rb, count, ${mpi_type1}$, comm%handle, ierr)
398 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
399 0 : CALL mpi_comm_size(comm%handle, np, ierr)
400 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
401 0 : msglen = 2*count*np
402 0 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
403 : #else
404 : MARK_USED(count)
405 : MARK_USED(comm)
406 : rb = sb
407 : #endif
408 0 : CALL mp_timestop(handle)
409 :
410 0 : END SUBROUTINE mp_alltoall_${nametype1}$44
411 :
412 : ! **************************************************************************************************
413 : !> \brief All-to-all data exchange, rank 5 data, equal sizes
414 : !> \param sb ...
415 : !> \param rb ...
416 : !> \param count ...
417 : !> \param comm ...
418 : !> \note see mp_alltoall_${nametype1}$
419 : ! **************************************************************************************************
420 0 : SUBROUTINE mp_alltoall_${nametype1}$55(sb, rb, count, comm)
421 :
422 : ${type1}$, DIMENSION(:, :, :, :, :), CONTIGUOUS, &
423 : INTENT(IN) :: sb
424 : ${type1}$, DIMENSION(:, :, :, :, :), CONTIGUOUS, &
425 : INTENT(OUT) :: rb
426 : INTEGER, INTENT(IN) :: count
427 : CLASS(mp_comm_type), INTENT(IN) :: comm
428 :
429 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$55'
430 :
431 : INTEGER :: handle
432 : #if defined(__parallel)
433 : INTEGER :: ierr, msglen, np
434 : #endif
435 :
436 0 : CALL mp_timeset(routineN, handle)
437 :
438 : #if defined(__parallel)
439 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
440 0 : rb, count, ${mpi_type1}$, comm%handle, ierr)
441 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
442 0 : CALL mpi_comm_size(comm%handle, np, ierr)
443 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
444 0 : msglen = 2*count*np
445 0 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
446 : #else
447 : MARK_USED(count)
448 : MARK_USED(comm)
449 : rb = sb
450 : #endif
451 0 : CALL mp_timestop(handle)
452 :
453 0 : END SUBROUTINE mp_alltoall_${nametype1}$55
454 :
455 : ! **************************************************************************************************
456 : !> \brief All-to-all data exchange, rank-4 data to rank-5 data
457 : !> \param sb ...
458 : !> \param rb ...
459 : !> \param count ...
460 : !> \param comm ...
461 : !> \note see mp_alltoall_${nametype1}$
462 : !> \note User must ensure size consistency.
463 : ! **************************************************************************************************
464 0 : SUBROUTINE mp_alltoall_${nametype1}$45(sb, rb, count, comm)
465 :
466 : ${type1}$, DIMENSION(:, :, :, :), CONTIGUOUS, &
467 : INTENT(IN) :: sb
468 : ${type1}$, &
469 : DIMENSION(:, :, :, :, :), INTENT(OUT), CONTIGUOUS :: rb
470 : INTEGER, INTENT(IN) :: count
471 : CLASS(mp_comm_type), INTENT(IN) :: comm
472 :
473 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$45'
474 :
475 : INTEGER :: handle
476 : #if defined(__parallel)
477 : INTEGER :: ierr, msglen, np
478 : #endif
479 :
480 0 : CALL mp_timeset(routineN, handle)
481 :
482 : #if defined(__parallel)
483 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
484 0 : rb, count, ${mpi_type1}$, comm%handle, ierr)
485 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
486 0 : CALL mpi_comm_size(comm%handle, np, ierr)
487 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
488 0 : msglen = 2*count*np
489 0 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
490 : #else
491 : MARK_USED(count)
492 : MARK_USED(comm)
493 : rb = RESHAPE(sb, SHAPE(rb))
494 : #endif
495 0 : CALL mp_timestop(handle)
496 :
497 0 : END SUBROUTINE mp_alltoall_${nametype1}$45
498 :
499 : ! **************************************************************************************************
500 : !> \brief All-to-all data exchange, rank-3 data to rank-4 data
501 : !> \param sb ...
502 : !> \param rb ...
503 : !> \param count ...
504 : !> \param comm ...
505 : !> \note see mp_alltoall_${nametype1}$
506 : !> \note User must ensure size consistency.
507 : ! **************************************************************************************************
508 30296 : SUBROUTINE mp_alltoall_${nametype1}$34(sb, rb, count, comm)
509 :
510 : ${type1}$, DIMENSION(:, :, :), CONTIGUOUS, &
511 : INTENT(IN) :: sb
512 : ${type1}$, DIMENSION(:, :, :, :), CONTIGUOUS, &
513 : INTENT(OUT) :: rb
514 : INTEGER, INTENT(IN) :: count
515 : CLASS(mp_comm_type), INTENT(IN) :: comm
516 :
517 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$34'
518 :
519 : INTEGER :: handle
520 : #if defined(__parallel)
521 : INTEGER :: ierr, msglen, np
522 : #endif
523 :
524 15148 : CALL mp_timeset(routineN, handle)
525 :
526 : #if defined(__parallel)
527 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
528 15148 : rb, count, ${mpi_type1}$, comm%handle, ierr)
529 15148 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
530 15148 : CALL mpi_comm_size(comm%handle, np, ierr)
531 15148 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
532 15148 : msglen = 2*count*np
533 15148 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
534 : #else
535 : MARK_USED(count)
536 : MARK_USED(comm)
537 : rb = RESHAPE(sb, SHAPE(rb))
538 : #endif
539 15148 : CALL mp_timestop(handle)
540 :
541 15148 : END SUBROUTINE mp_alltoall_${nametype1}$34
542 :
543 : ! **************************************************************************************************
544 : !> \brief All-to-all data exchange, rank-5 data to rank-4 data
545 : !> \param sb ...
546 : !> \param rb ...
547 : !> \param count ...
548 : !> \param comm ...
549 : !> \note see mp_alltoall_${nametype1}$
550 : !> \note User must ensure size consistency.
551 : ! **************************************************************************************************
552 0 : SUBROUTINE mp_alltoall_${nametype1}$54(sb, rb, count, comm)
553 :
554 : ${type1}$, &
555 : DIMENSION(:, :, :, :, :), CONTIGUOUS, INTENT(IN) :: sb
556 : ${type1}$, DIMENSION(:, :, :, :), CONTIGUOUS, &
557 : INTENT(OUT) :: rb
558 : INTEGER, INTENT(IN) :: count
559 : CLASS(mp_comm_type), INTENT(IN) :: comm
560 :
561 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$54'
562 :
563 : INTEGER :: handle
564 : #if defined(__parallel)
565 : INTEGER :: ierr, msglen, np
566 : #endif
567 :
568 0 : CALL mp_timeset(routineN, handle)
569 :
570 : #if defined(__parallel)
571 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
572 0 : rb, count, ${mpi_type1}$, comm%handle, ierr)
573 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
574 0 : CALL mpi_comm_size(comm%handle, np, ierr)
575 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
576 0 : msglen = 2*count*np
577 0 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
578 : #else
579 : MARK_USED(count)
580 : MARK_USED(comm)
581 : rb = RESHAPE(sb, SHAPE(rb))
582 : #endif
583 0 : CALL mp_timestop(handle)
584 :
585 0 : END SUBROUTINE mp_alltoall_${nametype1}$54
586 :
587 : ! **************************************************************************************************
588 : !> \brief All-to-all data exchange, rank-4 data to rank-3 data
589 : !> \param sb ...
590 : !> \param rb ...
591 : !> \param count ...
592 : !> \param comm ...
593 : !> \note see mp_alltoall_${nametype1}$
594 : !> \note User must ensure size consistency.
595 : ! **************************************************************************************************
596 29364 : SUBROUTINE mp_alltoall_${nametype1}$43(sb, rb, count, comm)
597 :
598 : ${type1}$, &
599 : DIMENSION(:, :, :, :), CONTIGUOUS, INTENT(IN) :: sb
600 : ${type1}$, DIMENSION(:, :, :), CONTIGUOUS, &
601 : INTENT(OUT) :: rb
602 : INTEGER, INTENT(IN) :: count
603 : CLASS(mp_comm_type), INTENT(IN) :: comm
604 :
605 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_alltoall_${nametype1}$54'
606 :
607 : INTEGER :: handle
608 : #if defined(__parallel)
609 : INTEGER :: ierr, msglen, np
610 : #endif
611 :
612 14682 : CALL mp_timeset(routineN, handle)
613 :
614 : #if defined(__parallel)
615 : CALL mpi_alltoall(sb, count, ${mpi_type1}$, &
616 14682 : rb, count, ${mpi_type1}$, comm%handle, ierr)
617 14682 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_alltoall @ "//routineN)
618 14682 : CALL mpi_comm_size(comm%handle, np, ierr)
619 14682 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_size @ "//routineN)
620 14682 : msglen = 2*count*np
621 14682 : CALL add_perf(perf_id=6, count=1, msg_size=msglen*${bytes1}$)
622 : #else
623 : MARK_USED(count)
624 : MARK_USED(comm)
625 : rb = RESHAPE(sb, SHAPE(rb))
626 : #endif
627 14682 : CALL mp_timestop(handle)
628 :
629 14682 : END SUBROUTINE mp_alltoall_${nametype1}$43
630 :
631 : ! **************************************************************************************************
632 : !> \brief Send one datum to another process
633 : !> \param[in] msg Scalar to send
634 : !> \param[in] dest Destination process
635 : !> \param[in] tag Transfer identifier
636 : !> \param[in] comm Message passing environment identifier
637 : !> \par MPI mapping
638 : !> mpi_send
639 : ! **************************************************************************************************
640 374 : SUBROUTINE mp_send_${nametype1}$ (msg, dest, tag, comm)
641 : ${type1}$, INTENT(IN) :: msg
642 : INTEGER, INTENT(IN) :: dest, tag
643 : CLASS(mp_comm_type), INTENT(IN) :: comm
644 :
645 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_send_${nametype1}$'
646 :
647 : INTEGER :: handle
648 : #if defined(__parallel)
649 : INTEGER :: ierr, msglen
650 : #endif
651 :
652 374 : CALL mp_timeset(routineN, handle)
653 :
654 : #if defined(__parallel)
655 374 : msglen = 1
656 374 : CALL mpi_send(msg, msglen, ${mpi_type1}$, dest, tag, comm%handle, ierr)
657 374 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_send @ "//routineN)
658 374 : CALL add_perf(perf_id=13, count=1, msg_size=msglen*${bytes1}$)
659 : #else
660 : MARK_USED(msg)
661 : MARK_USED(dest)
662 : MARK_USED(tag)
663 : MARK_USED(comm)
664 : ! only defined in parallel
665 : CPABORT("not in parallel mode")
666 : #endif
667 374 : CALL mp_timestop(handle)
668 374 : END SUBROUTINE mp_send_${nametype1}$
669 :
670 : ! **************************************************************************************************
671 : !> \brief Send rank-1 data to another process
672 : !> \param[in] msg Rank-1 data to send
673 : !> \param dest ...
674 : !> \param tag ...
675 : !> \param comm ...
676 : !> \note see mp_send_${nametype1}$
677 : ! **************************************************************************************************
678 155907 : SUBROUTINE mp_send_${nametype1}$v(msg, dest, tag, comm)
679 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:)
680 : INTEGER, INTENT(IN) :: dest, tag
681 : CLASS(mp_comm_type), INTENT(IN) :: comm
682 :
683 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_send_${nametype1}$v'
684 :
685 : INTEGER :: handle
686 : #if defined(__parallel)
687 : INTEGER :: ierr, msglen
688 : #endif
689 :
690 155907 : CALL mp_timeset(routineN, handle)
691 :
692 : #if defined(__parallel)
693 155907 : msglen = SIZE(msg)
694 155907 : CALL mpi_send(msg, msglen, ${mpi_type1}$, dest, tag, comm%handle, ierr)
695 155907 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_send @ "//routineN)
696 155907 : CALL add_perf(perf_id=13, count=1, msg_size=msglen*${bytes1}$)
697 : #else
698 : MARK_USED(msg)
699 : MARK_USED(dest)
700 : MARK_USED(tag)
701 : MARK_USED(comm)
702 : ! only defined in parallel
703 : CPABORT("not in parallel mode")
704 : #endif
705 155907 : CALL mp_timestop(handle)
706 155907 : END SUBROUTINE mp_send_${nametype1}$v
707 :
708 : ! **************************************************************************************************
709 : !> \brief Send rank-2 data to another process
710 : !> \param[in] msg Rank-2 data to send
711 : !> \param dest ...
712 : !> \param tag ...
713 : !> \param comm ...
714 : !> \note see mp_send_${nametype1}$
715 : ! **************************************************************************************************
716 436 : SUBROUTINE mp_send_${nametype1}$m2(msg, dest, tag, comm)
717 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:, :)
718 : INTEGER, INTENT(IN) :: dest, tag
719 : CLASS(mp_comm_type), INTENT(IN) :: comm
720 :
721 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_send_${nametype1}$m2'
722 :
723 : INTEGER :: handle
724 : #if defined(__parallel)
725 : INTEGER :: ierr, msglen
726 : #endif
727 :
728 436 : CALL mp_timeset(routineN, handle)
729 :
730 : #if defined(__parallel)
731 1308 : msglen = SIZE(msg)
732 436 : CALL mpi_send(msg, msglen, ${mpi_type1}$, dest, tag, comm%handle, ierr)
733 436 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_send @ "//routineN)
734 436 : CALL add_perf(perf_id=13, count=1, msg_size=msglen*${bytes1}$)
735 : #else
736 : MARK_USED(msg)
737 : MARK_USED(dest)
738 : MARK_USED(tag)
739 : MARK_USED(comm)
740 : ! only defined in parallel
741 : CPABORT("not in parallel mode")
742 : #endif
743 436 : CALL mp_timestop(handle)
744 436 : END SUBROUTINE mp_send_${nametype1}$m2
745 :
746 : ! **************************************************************************************************
747 : !> \brief Send rank-3 data to another process
748 : !> \param[in] msg Rank-3 data to send
749 : !> \param dest ...
750 : !> \param tag ...
751 : !> \param comm ...
752 : !> \note see mp_send_${nametype1}$
753 : ! **************************************************************************************************
754 258 : SUBROUTINE mp_send_${nametype1}$m3(msg, dest, tag, comm)
755 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:, :, :)
756 : INTEGER, INTENT(IN) :: dest, tag
757 : CLASS(mp_comm_type), INTENT(IN) :: comm
758 :
759 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_send_${nametype1}m3'
760 :
761 : INTEGER :: handle
762 : #if defined(__parallel)
763 : INTEGER :: ierr, msglen
764 : #endif
765 :
766 258 : CALL mp_timeset(routineN, handle)
767 :
768 : #if defined(__parallel)
769 1032 : msglen = SIZE(msg)
770 258 : CALL mpi_send(msg, msglen, ${mpi_type1}$, dest, tag, comm%handle, ierr)
771 258 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_send @ "//routineN)
772 258 : CALL add_perf(perf_id=13, count=1, msg_size=msglen*${bytes1}$)
773 : #else
774 : MARK_USED(msg)
775 : MARK_USED(dest)
776 : MARK_USED(tag)
777 : MARK_USED(comm)
778 : ! only defined in parallel
779 : CPABORT("not in parallel mode")
780 : #endif
781 258 : CALL mp_timestop(handle)
782 258 : END SUBROUTINE mp_send_${nametype1}$m3
783 :
784 : ! **************************************************************************************************
785 : !> \brief Receive one datum from another process
786 : !> \param[in,out] msg Place received data into this variable
787 : !> \param[in,out] source Process to receive from
788 : !> \param[in,out] tag Transfer identifier
789 : !> \param[in] comm Message passing environment identifier
790 : !> \par MPI mapping
791 : !> mpi_send
792 : ! **************************************************************************************************
793 374 : SUBROUTINE mp_recv_${nametype1}$ (msg, source, tag, comm)
794 : ${type1}$, INTENT(INOUT) :: msg
795 : INTEGER, INTENT(INOUT) :: source, tag
796 : CLASS(mp_comm_type), INTENT(IN) :: comm
797 :
798 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_recv_${nametype1}$'
799 :
800 : INTEGER :: handle
801 : #if defined(__parallel)
802 : INTEGER :: ierr, msglen
803 : MPI_STATUS_TYPE :: status
804 : #endif
805 :
806 374 : CALL mp_timeset(routineN, handle)
807 :
808 : #if defined(__parallel)
809 374 : msglen = 1
810 374 : IF (source /= mp_any_source .AND. tag /= mp_any_tag) THEN
811 338 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, MPI_STATUS_IGNORE, ierr)
812 338 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
813 : ELSE
814 36 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, status, ierr)
815 36 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
816 36 : CALL add_perf(perf_id=14, count=1, msg_size=msglen*${bytes1}$)
817 36 : source = status MPI_STATUS_EXTRACT(MPI_SOURCE)
818 36 : tag = status MPI_STATUS_EXTRACT(MPI_TAG)
819 : END IF
820 : #else
821 : MARK_USED(msg)
822 : MARK_USED(source)
823 : MARK_USED(tag)
824 : MARK_USED(comm)
825 : ! only defined in parallel
826 : CPABORT("not in parallel mode")
827 : #endif
828 374 : CALL mp_timestop(handle)
829 374 : END SUBROUTINE mp_recv_${nametype1}$
830 :
831 : ! **************************************************************************************************
832 : !> \brief Receive rank-1 data from another process
833 : !> \param[in,out] msg Place received data into this rank-1 array
834 : !> \param source ...
835 : !> \param tag ...
836 : !> \param comm ...
837 : !> \note see mp_recv_${nametype1}$
838 : ! **************************************************************************************************
839 155735 : SUBROUTINE mp_recv_${nametype1}$v(msg, source, tag, comm)
840 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
841 : INTEGER, INTENT(INOUT) :: source, tag
842 : CLASS(mp_comm_type), INTENT(IN) :: comm
843 :
844 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_recv_${nametype1}$v'
845 :
846 : INTEGER :: handle
847 : #if defined(__parallel)
848 : INTEGER :: ierr, msglen
849 : MPI_STATUS_TYPE :: status
850 : #endif
851 :
852 155735 : CALL mp_timeset(routineN, handle)
853 :
854 : #if defined(__parallel)
855 155735 : msglen = SIZE(msg)
856 155735 : IF (source /= mp_any_source .AND. tag /= mp_any_tag) THEN
857 147305 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, MPI_STATUS_IGNORE, ierr)
858 147305 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
859 : ELSE
860 8430 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, status, ierr)
861 8430 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
862 8430 : CALL add_perf(perf_id=14, count=1, msg_size=msglen*${bytes1}$)
863 8430 : source = status MPI_STATUS_EXTRACT(MPI_SOURCE)
864 8430 : tag = status MPI_STATUS_EXTRACT(MPI_TAG)
865 : END IF
866 : #else
867 : MARK_USED(msg)
868 : MARK_USED(source)
869 : MARK_USED(tag)
870 : MARK_USED(comm)
871 : ! only defined in parallel
872 : CPABORT("not in parallel mode")
873 : #endif
874 155735 : CALL mp_timestop(handle)
875 155735 : END SUBROUTINE mp_recv_${nametype1}$v
876 :
877 : ! **************************************************************************************************
878 : !> \brief Receive rank-2 data from another process
879 : !> \param[in,out] msg Place received data into this rank-2 array
880 : !> \param source ...
881 : !> \param tag ...
882 : !> \param comm ...
883 : !> \note see mp_recv_${nametype1}$
884 : ! **************************************************************************************************
885 436 : SUBROUTINE mp_recv_${nametype1}$m2(msg, source, tag, comm)
886 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
887 : INTEGER, INTENT(INOUT) :: source, tag
888 : CLASS(mp_comm_type), INTENT(IN) :: comm
889 :
890 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_recv_${nametype1}$m2'
891 :
892 : INTEGER :: handle
893 : #if defined(__parallel)
894 : INTEGER :: ierr, msglen
895 : MPI_STATUS_TYPE :: status
896 : #endif
897 :
898 436 : CALL mp_timeset(routineN, handle)
899 :
900 : #if defined(__parallel)
901 1308 : msglen = SIZE(msg)
902 436 : IF (source /= mp_any_source .AND. tag /= mp_any_tag) THEN
903 436 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, MPI_STATUS_IGNORE, ierr)
904 436 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
905 : ELSE
906 0 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, status, ierr)
907 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
908 0 : CALL add_perf(perf_id=14, count=1, msg_size=msglen*${bytes1}$)
909 0 : source = status MPI_STATUS_EXTRACT(MPI_SOURCE)
910 0 : tag = status MPI_STATUS_EXTRACT(MPI_TAG)
911 : END IF
912 : #else
913 : MARK_USED(msg)
914 : MARK_USED(source)
915 : MARK_USED(tag)
916 : MARK_USED(comm)
917 : ! only defined in parallel
918 : CPABORT("not in parallel mode")
919 : #endif
920 436 : CALL mp_timestop(handle)
921 436 : END SUBROUTINE mp_recv_${nametype1}$m2
922 :
923 : ! **************************************************************************************************
924 : !> \brief Receive rank-3 data from another process
925 : !> \param[in,out] msg Place received data into this rank-3 array
926 : !> \param source ...
927 : !> \param tag ...
928 : !> \param comm ...
929 : !> \note see mp_recv_${nametype1}$
930 : ! **************************************************************************************************
931 258 : SUBROUTINE mp_recv_${nametype1}$m3(msg, source, tag, comm)
932 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :, :)
933 : INTEGER, INTENT(INOUT) :: source, tag
934 : CLASS(mp_comm_type), INTENT(IN) :: comm
935 :
936 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_recv_${nametype1}$m3'
937 :
938 : INTEGER :: handle
939 : #if defined(__parallel)
940 : INTEGER :: ierr, msglen
941 : MPI_STATUS_TYPE :: status
942 : #endif
943 :
944 258 : CALL mp_timeset(routineN, handle)
945 :
946 : #if defined(__parallel)
947 1032 : msglen = SIZE(msg)
948 258 : IF (source /= mp_any_source .AND. tag /= mp_any_tag) THEN
949 258 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, MPI_STATUS_IGNORE, ierr)
950 258 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
951 : ELSE
952 0 : CALL mpi_recv(msg, msglen, ${mpi_type1}$, source, tag, comm%handle, status, ierr)
953 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_recv @ "//routineN)
954 0 : CALL add_perf(perf_id=14, count=1, msg_size=msglen*${bytes1}$)
955 0 : source = status MPI_STATUS_EXTRACT(MPI_SOURCE)
956 0 : tag = status MPI_STATUS_EXTRACT(MPI_TAG)
957 : END IF
958 : #else
959 : MARK_USED(msg)
960 : MARK_USED(source)
961 : MARK_USED(tag)
962 : MARK_USED(comm)
963 : ! only defined in parallel
964 : CPABORT("not in parallel mode")
965 : #endif
966 258 : CALL mp_timestop(handle)
967 258 : END SUBROUTINE mp_recv_${nametype1}$m3
968 :
969 : ! **************************************************************************************************
970 : !> \brief Broadcasts a datum to all processes.
971 : !> \param[in] msg Datum to broadcast
972 : !> \param[in] source Processes which broadcasts
973 : !> \param[in] comm Message passing environment identifier
974 : !> \par MPI mapping
975 : !> mpi_bcast
976 : ! **************************************************************************************************
977 1264469 : SUBROUTINE mp_bcast_${nametype1}$ (msg, source, comm)
978 : ${type1}$, INTENT(INOUT) :: msg
979 : INTEGER, INTENT(IN) :: source
980 : CLASS(mp_comm_type), INTENT(IN) :: comm
981 :
982 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$'
983 :
984 : INTEGER :: handle
985 : #if defined(__parallel)
986 : INTEGER :: ierr, msglen
987 : #endif
988 :
989 1264469 : CALL mp_timeset(routineN, handle)
990 :
991 : #if defined(__parallel)
992 1264469 : msglen = 1
993 1264469 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, source, comm%handle, ierr)
994 1264469 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
995 1264469 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
996 : #else
997 : MARK_USED(msg)
998 : MARK_USED(source)
999 : MARK_USED(comm)
1000 : #endif
1001 1264469 : CALL mp_timestop(handle)
1002 1264469 : END SUBROUTINE mp_bcast_${nametype1}$
1003 :
1004 : ! **************************************************************************************************
1005 : !> \brief Broadcasts a datum to all processes. Convenience function using the source of the communicator
1006 : !> \param[in] msg Datum to broadcast
1007 : !> \param[in] comm Message passing environment identifier
1008 : !> \par MPI mapping
1009 : !> mpi_bcast
1010 : ! **************************************************************************************************
1011 405029 : SUBROUTINE mp_bcast_${nametype1}$_src(msg, comm)
1012 : ${type1}$, INTENT(INOUT) :: msg
1013 : CLASS(mp_comm_type), INTENT(IN) :: comm
1014 :
1015 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$_src'
1016 :
1017 : INTEGER :: handle
1018 : #if defined(__parallel)
1019 : INTEGER :: ierr, msglen
1020 : #endif
1021 :
1022 405029 : CALL mp_timeset(routineN, handle)
1023 :
1024 : #if defined(__parallel)
1025 405029 : msglen = 1
1026 405029 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
1027 405029 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1028 405029 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1029 : #else
1030 : MARK_USED(msg)
1031 : MARK_USED(comm)
1032 : #endif
1033 405029 : CALL mp_timestop(handle)
1034 405029 : END SUBROUTINE mp_bcast_${nametype1}$_src
1035 :
1036 : ! **************************************************************************************************
1037 : !> \brief Broadcasts a datum to all processes.
1038 : !> \param[in] msg Datum to broadcast
1039 : !> \param[in] source Processes which broadcasts
1040 : !> \param[in] comm Message passing environment identifier
1041 : !> \par MPI mapping
1042 : !> mpi_bcast
1043 : ! **************************************************************************************************
1044 0 : SUBROUTINE mp_ibcast_${nametype1}$ (msg, source, comm, request)
1045 : ${type1}$, INTENT(INOUT) :: msg
1046 : INTEGER, INTENT(IN) :: source
1047 : CLASS(mp_comm_type), INTENT(IN) :: comm
1048 : TYPE(mp_request_type), INTENT(OUT) :: request
1049 :
1050 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_ibcast_${nametype1}$'
1051 :
1052 : INTEGER :: handle
1053 : #if defined(__parallel)
1054 : INTEGER :: ierr, msglen
1055 : #endif
1056 :
1057 0 : CALL mp_timeset(routineN, handle)
1058 :
1059 : #if defined(__parallel)
1060 0 : msglen = 1
1061 0 : CALL mpi_ibcast(msg, msglen, ${mpi_type1}$, source, comm%handle, request%handle, ierr)
1062 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_ibcast @ "//routineN)
1063 0 : CALL add_perf(perf_id=22, count=1, msg_size=msglen*${bytes1}$)
1064 : #else
1065 : MARK_USED(msg)
1066 : MARK_USED(source)
1067 : MARK_USED(comm)
1068 : request = mp_request_null
1069 : #endif
1070 0 : CALL mp_timestop(handle)
1071 0 : END SUBROUTINE mp_ibcast_${nametype1}$
1072 :
1073 : ! **************************************************************************************************
1074 : !> \brief Broadcasts rank-1 data to all processes
1075 : !> \param[in] msg Data to broadcast
1076 : !> \param source ...
1077 : !> \param comm ...
1078 : !> \note see mp_bcast_${nametype1}$1
1079 : ! **************************************************************************************************
1080 1019300 : SUBROUTINE mp_bcast_${nametype1}$v(msg, source, comm)
1081 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
1082 : INTEGER, INTENT(IN) :: source
1083 : CLASS(mp_comm_type), INTENT(IN) :: comm
1084 :
1085 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$v'
1086 :
1087 : INTEGER :: handle
1088 : #if defined(__parallel)
1089 : INTEGER :: ierr, msglen
1090 : #endif
1091 :
1092 1019300 : CALL mp_timeset(routineN, handle)
1093 :
1094 : #if defined(__parallel)
1095 1019300 : msglen = SIZE(msg)
1096 1019300 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, source, comm%handle, ierr)
1097 1019300 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1098 1019300 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1099 : #else
1100 : MARK_USED(msg)
1101 : MARK_USED(source)
1102 : MARK_USED(comm)
1103 : #endif
1104 1019300 : CALL mp_timestop(handle)
1105 1019300 : END SUBROUTINE mp_bcast_${nametype1}$v
1106 :
1107 : ! **************************************************************************************************
1108 : !> \brief Broadcasts rank-1 data to all processes, uses the source of the communicator, convenience function
1109 : !> \param[in] msg Data to broadcast
1110 : !> \param comm ...
1111 : !> \note see mp_bcast_${nametype1}$1
1112 : ! **************************************************************************************************
1113 110940 : SUBROUTINE mp_bcast_${nametype1}$v_src(msg, comm)
1114 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
1115 : CLASS(mp_comm_type), INTENT(IN) :: comm
1116 :
1117 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$v_src'
1118 :
1119 : INTEGER :: handle
1120 : #if defined(__parallel)
1121 : INTEGER :: ierr, msglen
1122 : #endif
1123 :
1124 110940 : CALL mp_timeset(routineN, handle)
1125 :
1126 : #if defined(__parallel)
1127 110940 : msglen = SIZE(msg)
1128 110940 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
1129 110940 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1130 110940 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1131 : #else
1132 : MARK_USED(msg)
1133 : MARK_USED(comm)
1134 : #endif
1135 110940 : CALL mp_timestop(handle)
1136 110940 : END SUBROUTINE mp_bcast_${nametype1}$v_src
1137 :
1138 : ! **************************************************************************************************
1139 : !> \brief Broadcasts rank-1 data to all processes
1140 : !> \param[in] msg Data to broadcast
1141 : !> \param source ...
1142 : !> \param comm ...
1143 : !> \note see mp_bcast_${nametype1}$1
1144 : ! **************************************************************************************************
1145 0 : SUBROUTINE mp_ibcast_${nametype1}$v(msg, source, comm, request)
1146 : ${type1}$, INTENT(INOUT) :: msg(:)
1147 : INTEGER, INTENT(IN) :: source
1148 : CLASS(mp_comm_type), INTENT(IN) :: comm
1149 : TYPE(mp_request_type) :: request
1150 :
1151 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_ibcast_${nametype1}$v'
1152 :
1153 : INTEGER :: handle
1154 : #if defined(__parallel)
1155 : INTEGER :: ierr, msglen
1156 : #endif
1157 :
1158 0 : CALL mp_timeset(routineN, handle)
1159 :
1160 : #if defined(__parallel)
1161 0 : CPASSERT(IS_CONTIGUOUS(msg) .OR. SIZE(msg) == 0)
1162 0 : msglen = SIZE(msg)
1163 0 : CALL mpi_ibcast(msg, msglen, ${mpi_type1}$, source, comm%handle, request%handle, ierr)
1164 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_ibcast @ "//routineN)
1165 0 : CALL add_perf(perf_id=22, count=1, msg_size=msglen*${bytes1}$)
1166 : #else
1167 : MARK_USED(msg)
1168 : MARK_USED(source)
1169 : MARK_USED(comm)
1170 : request = mp_request_null
1171 : #endif
1172 0 : CALL mp_timestop(handle)
1173 0 : END SUBROUTINE mp_ibcast_${nametype1}$v
1174 :
1175 : ! **************************************************************************************************
1176 : !> \brief Broadcasts rank-2 data to all processes
1177 : !> \param[in] msg Data to broadcast
1178 : !> \param source ...
1179 : !> \param comm ...
1180 : !> \note see mp_bcast_${nametype1}$1
1181 : ! **************************************************************************************************
1182 701217 : SUBROUTINE mp_bcast_${nametype1}$m(msg, source, comm)
1183 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1184 : INTEGER, INTENT(IN) :: source
1185 : CLASS(mp_comm_type), INTENT(IN) :: comm
1186 :
1187 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$m'
1188 :
1189 : INTEGER :: handle
1190 : #if defined(__parallel)
1191 : INTEGER :: ierr, msglen
1192 : #endif
1193 :
1194 701217 : CALL mp_timeset(routineN, handle)
1195 :
1196 : #if defined(__parallel)
1197 2103651 : msglen = SIZE(msg)
1198 701217 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, source, comm%handle, ierr)
1199 701217 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1200 701217 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1201 : #else
1202 : MARK_USED(msg)
1203 : MARK_USED(source)
1204 : MARK_USED(comm)
1205 : #endif
1206 701217 : CALL mp_timestop(handle)
1207 701217 : END SUBROUTINE mp_bcast_${nametype1}$m
1208 :
1209 : ! **************************************************************************************************
1210 : !> \brief Broadcasts rank-2 data to all processes
1211 : !> \param[in] msg Data to broadcast
1212 : !> \param source ...
1213 : !> \param comm ...
1214 : !> \note see mp_bcast_${nametype1}$1
1215 : ! **************************************************************************************************
1216 11165 : SUBROUTINE mp_bcast_${nametype1}$m_src(msg, comm)
1217 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1218 : CLASS(mp_comm_type), INTENT(IN) :: comm
1219 :
1220 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$m_src'
1221 :
1222 : INTEGER :: handle
1223 : #if defined(__parallel)
1224 : INTEGER :: ierr, msglen
1225 : #endif
1226 :
1227 11165 : CALL mp_timeset(routineN, handle)
1228 :
1229 : #if defined(__parallel)
1230 33495 : msglen = SIZE(msg)
1231 11165 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
1232 11165 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1233 11165 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1234 : #else
1235 : MARK_USED(msg)
1236 : MARK_USED(comm)
1237 : #endif
1238 11165 : CALL mp_timestop(handle)
1239 11165 : END SUBROUTINE mp_bcast_${nametype1}$m_src
1240 :
1241 : ! **************************************************************************************************
1242 : !> \brief Broadcasts rank-3 data to all processes
1243 : !> \param[in] msg Data to broadcast
1244 : !> \param source ...
1245 : !> \param comm ...
1246 : !> \note see mp_bcast_${nametype1}$1
1247 : ! **************************************************************************************************
1248 248 : SUBROUTINE mp_bcast_${nametype1}$3(msg, source, comm)
1249 : ${type1}$, CONTIGUOUS :: msg(:, :, :)
1250 : INTEGER, INTENT(IN) :: source
1251 : CLASS(mp_comm_type), INTENT(IN) :: comm
1252 :
1253 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$3'
1254 :
1255 : INTEGER :: handle
1256 : #if defined(__parallel)
1257 : INTEGER :: ierr, msglen
1258 : #endif
1259 :
1260 248 : CALL mp_timeset(routineN, handle)
1261 :
1262 : #if defined(__parallel)
1263 992 : msglen = SIZE(msg)
1264 248 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, source, comm%handle, ierr)
1265 248 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1266 248 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1267 : #else
1268 : MARK_USED(msg)
1269 : MARK_USED(source)
1270 : MARK_USED(comm)
1271 : #endif
1272 248 : CALL mp_timestop(handle)
1273 248 : END SUBROUTINE mp_bcast_${nametype1}$3
1274 :
1275 : ! **************************************************************************************************
1276 : !> \brief Broadcasts rank-3 data to all processes. Uses the source of the communicator for convenience
1277 : !> \param[in] msg Data to broadcast
1278 : !> \param source ...
1279 : !> \param comm ...
1280 : !> \note see mp_bcast_${nametype1}$1
1281 : ! **************************************************************************************************
1282 96 : SUBROUTINE mp_bcast_${nametype1}$3_src(msg, comm)
1283 : ${type1}$, CONTIGUOUS :: msg(:, :, :)
1284 : CLASS(mp_comm_type), INTENT(IN) :: comm
1285 :
1286 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_bcast_${nametype1}$3_src'
1287 :
1288 : INTEGER :: handle
1289 : #if defined(__parallel)
1290 : INTEGER :: ierr, msglen
1291 : #endif
1292 :
1293 96 : CALL mp_timeset(routineN, handle)
1294 :
1295 : #if defined(__parallel)
1296 384 : msglen = SIZE(msg)
1297 96 : CALL mpi_bcast(msg, msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
1298 96 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_bcast @ "//routineN)
1299 96 : CALL add_perf(perf_id=2, count=1, msg_size=msglen*${bytes1}$)
1300 : #else
1301 : MARK_USED(msg)
1302 : MARK_USED(comm)
1303 : #endif
1304 96 : CALL mp_timestop(handle)
1305 96 : END SUBROUTINE mp_bcast_${nametype1}$3_src
1306 :
1307 : ! **************************************************************************************************
1308 : !> \brief Sums a datum from all processes with result left on all processes.
1309 : !> \param[in,out] msg Datum to sum (input) and result (output)
1310 : !> \param[in] comm Message passing environment identifier
1311 : !> \par MPI mapping
1312 : !> mpi_allreduce
1313 : ! **************************************************************************************************
1314 30850595 : SUBROUTINE mp_sum_${nametype1}$ (msg, comm)
1315 : ${type1}$, INTENT(INOUT) :: msg
1316 : CLASS(mp_comm_type), INTENT(IN) :: comm
1317 :
1318 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_${nametype1}$'
1319 :
1320 : INTEGER :: handle
1321 : #if defined(__parallel)
1322 : INTEGER :: ierr, msglen
1323 : ${type1}$ :: res
1324 : #endif
1325 :
1326 30850595 : CALL mp_timeset(routineN, handle)
1327 :
1328 : #if defined(__parallel)
1329 30850595 : msglen = 1
1330 30850595 : IF (comm%num_pe > 1) THEN
1331 29095660 : CALL mpi_allreduce(msg, res, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, ierr)
1332 29095660 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1333 29095660 : msg = res
1334 : END IF
1335 30850595 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1336 : #else
1337 : MARK_USED(msg)
1338 : MARK_USED(comm)
1339 : #endif
1340 30850595 : CALL mp_timestop(handle)
1341 30850595 : END SUBROUTINE mp_sum_${nametype1}$
1342 :
1343 : ! **************************************************************************************************
1344 : !> \brief Element-wise sum of a rank-1 array on all processes.
1345 : !> \param[in,out] msg Vector to sum and result
1346 : !> \param comm ...
1347 : !> \note see mp_sum_${nametype1}$
1348 : ! **************************************************************************************************
1349 6037982 : SUBROUTINE mp_sum_${nametype1}$v(msg, comm)
1350 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
1351 : CLASS(mp_comm_type), INTENT(IN) :: comm
1352 :
1353 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_${nametype1}$v'
1354 :
1355 : INTEGER :: handle
1356 : #if defined(__parallel)
1357 : INTEGER :: ierr, msglen
1358 6037982 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1359 : #endif
1360 :
1361 6037982 : CALL mp_timeset(routineN, handle)
1362 :
1363 : #if defined(__parallel)
1364 6037982 : msglen = SIZE(msg)
1365 6037982 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1366 15084348 : ALLOCATE (msgbuf(msglen))
1367 5028116 : CALL mpi_allreduce(msg, msgbuf, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, ierr)
1368 5028116 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1369 257330208 : msg = msgbuf
1370 : END IF
1371 6037982 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1372 : #else
1373 : MARK_USED(msg)
1374 : MARK_USED(comm)
1375 : #endif
1376 6037982 : CALL mp_timestop(handle)
1377 6037982 : END SUBROUTINE mp_sum_${nametype1}$v
1378 :
1379 : ! **************************************************************************************************
1380 : !> \brief Element-wise sum of a rank-1 array on all processes.
1381 : !> \param[in,out] msg Vector to sum and result
1382 : !> \param comm ...
1383 : !> \note see mp_sum_${nametype1}$
1384 : ! **************************************************************************************************
1385 0 : SUBROUTINE mp_isum_${nametype1}$v(msg, comm, request)
1386 : ${type1}$, INTENT(INOUT) :: msg(:)
1387 : CLASS(mp_comm_type), INTENT(IN) :: comm
1388 : TYPE(mp_request_type), INTENT(OUT) :: request
1389 :
1390 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isum_${nametype1}$v'
1391 :
1392 : INTEGER :: handle
1393 : #if defined(__parallel)
1394 : INTEGER :: ierr, msglen
1395 : #endif
1396 :
1397 0 : CALL mp_timeset(routineN, handle)
1398 :
1399 : #if defined(__parallel)
1400 0 : CPASSERT(IS_CONTIGUOUS(msg) .OR. SIZE(msg) == 0)
1401 0 : msglen = SIZE(msg)
1402 0 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1403 0 : CALL mpi_iallreduce(MPI_IN_PLACE, msg, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, request%handle, ierr)
1404 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallreduce @ "//routineN)
1405 : ELSE
1406 0 : request = mp_request_null
1407 : END IF
1408 0 : CALL add_perf(perf_id=23, count=1, msg_size=msglen*${bytes1}$)
1409 : #else
1410 : MARK_USED(msg)
1411 : MARK_USED(comm)
1412 : request = mp_request_null
1413 : #endif
1414 0 : CALL mp_timestop(handle)
1415 0 : END SUBROUTINE mp_isum_${nametype1}$v
1416 :
1417 : ! **************************************************************************************************
1418 : !> \brief Element-wise sum of a rank-2 array on all processes.
1419 : !> \param[in] msg Matrix to sum and result
1420 : !> \param comm ...
1421 : !> \note see mp_sum_${nametype1}$
1422 : ! **************************************************************************************************
1423 2641315 : SUBROUTINE mp_sum_${nametype1}$m(msg, comm)
1424 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1425 : CLASS(mp_comm_type), INTENT(IN) :: comm
1426 :
1427 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_${nametype1}$m'
1428 :
1429 : INTEGER :: handle
1430 : #if defined(__parallel)
1431 : INTEGER, PARAMETER :: max_msg = 2**25
1432 : INTEGER :: ierr, m1, msglen, ncols, step, msglensum
1433 2641315 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1434 : #endif
1435 :
1436 2641315 : CALL mp_timeset(routineN, handle)
1437 :
1438 : #if defined(__parallel)
1439 : ! chunk up the call so that message sizes are limited, to avoid overflows in mpich triggered in large rpa calcs
1440 7923945 : step = MAX(1, SIZE(msg, 2)/MAX(1, SIZE(msg)/max_msg))
1441 2641315 : msglensum = 0
1442 7923845 : DO m1 = LBOUND(msg, 2), UBOUND(msg, 2), step
1443 2641265 : msglen = SIZE(msg, 1)*(MIN(UBOUND(msg, 2), m1 + step - 1) - m1 + 1)
1444 2641265 : msglensum = msglensum + msglen
1445 5282580 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1446 2567250 : ncols = MIN(UBOUND(msg, 2), m1 + step - 1) - m1 + 1
1447 7701750 : ALLOCATE (msgbuf(msglen))
1448 2567250 : CALL mpi_allreduce(msg(LBOUND(msg, 1), m1), msgbuf, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, ierr)
1449 2567250 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1450 7701750 : msg(:, m1:m1 + ncols - 1) = RESHAPE(msgbuf, [SIZE(msg, 1), ncols])
1451 2567250 : DEALLOCATE (msgbuf)
1452 : END IF
1453 : END DO
1454 2641315 : CALL add_perf(perf_id=3, count=1, msg_size=msglensum*${bytes1}$)
1455 : #else
1456 : MARK_USED(msg)
1457 : MARK_USED(comm)
1458 : #endif
1459 2641315 : CALL mp_timestop(handle)
1460 2641315 : END SUBROUTINE mp_sum_${nametype1}$m
1461 :
1462 : ! **************************************************************************************************
1463 : !> \brief Element-wise sum of a rank-3 array on all processes.
1464 : !> \param[in] msg Array to sum and result
1465 : !> \param comm ...
1466 : !> \note see mp_sum_${nametype1}$
1467 : ! **************************************************************************************************
1468 404865 : SUBROUTINE mp_sum_${nametype1}$m3(msg, comm)
1469 : ${type1}$, INTENT(INOUT), CONTIGUOUS :: msg(:, :, :)
1470 : CLASS(mp_comm_type), INTENT(IN) :: comm
1471 :
1472 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_${nametype1}$m3'
1473 :
1474 : INTEGER :: handle
1475 : #if defined(__parallel)
1476 : INTEGER :: ierr, msglen
1477 404865 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1478 : #endif
1479 :
1480 404865 : CALL mp_timeset(routineN, handle)
1481 :
1482 : #if defined(__parallel)
1483 1619460 : msglen = SIZE(msg)
1484 404865 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1485 1158012 : ALLOCATE (msgbuf(msglen))
1486 386004 : CALL mpi_allreduce(msg, msgbuf, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, ierr)
1487 386004 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1488 1544016 : msg = RESHAPE(msgbuf, SHAPE(msg))
1489 : END IF
1490 404865 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1491 : #else
1492 : MARK_USED(msg)
1493 : MARK_USED(comm)
1494 : #endif
1495 404865 : CALL mp_timestop(handle)
1496 404865 : END SUBROUTINE mp_sum_${nametype1}$m3
1497 :
1498 : ! **************************************************************************************************
1499 : !> \brief Element-wise sum of a rank-4 array on all processes.
1500 : !> \param[in] msg Array to sum and result
1501 : !> \param comm ...
1502 : !> \note see mp_sum_${nametype1}$
1503 : ! **************************************************************************************************
1504 962 : SUBROUTINE mp_sum_${nametype1}$m4(msg, comm)
1505 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :, :, :)
1506 : CLASS(mp_comm_type), INTENT(IN) :: comm
1507 :
1508 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_${nametype1}$m4'
1509 :
1510 : INTEGER :: handle
1511 : #if defined(__parallel)
1512 : INTEGER :: ierr, msglen
1513 962 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1514 : #endif
1515 :
1516 962 : CALL mp_timeset(routineN, handle)
1517 :
1518 : #if defined(__parallel)
1519 4810 : msglen = SIZE(msg)
1520 962 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1521 2886 : ALLOCATE (msgbuf(msglen))
1522 962 : CALL mpi_allreduce(msg, msgbuf, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, ierr)
1523 962 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1524 4810 : msg = RESHAPE(msgbuf, SHAPE(msg))
1525 : END IF
1526 962 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1527 : #else
1528 : MARK_USED(msg)
1529 : MARK_USED(comm)
1530 : #endif
1531 962 : CALL mp_timestop(handle)
1532 962 : END SUBROUTINE mp_sum_${nametype1}$m4
1533 :
1534 : ! **************************************************************************************************
1535 : !> \brief Element-wise sum of data from all processes with result left only on
1536 : !> one.
1537 : !> \param[in,out] msg Vector to sum (input) and (only on process root)
1538 : !> result (output)
1539 : !> \param root ...
1540 : !> \param[in] comm Message passing environment identifier
1541 : !> \par MPI mapping
1542 : !> mpi_reduce
1543 : ! **************************************************************************************************
1544 152412 : SUBROUTINE mp_sum_root_${nametype1}$v(msg, root, comm)
1545 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
1546 : INTEGER, INTENT(IN) :: root
1547 : CLASS(mp_comm_type), INTENT(IN) :: comm
1548 :
1549 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_root_${nametype1}$v'
1550 :
1551 : INTEGER :: handle
1552 : #if defined(__parallel)
1553 : INTEGER :: ierr, m1, msglen, taskid
1554 152412 : ${type1}$, ALLOCATABLE :: res(:)
1555 : #endif
1556 :
1557 152412 : CALL mp_timeset(routineN, handle)
1558 :
1559 : #if defined(__parallel)
1560 152412 : msglen = SIZE(msg)
1561 152412 : CALL mpi_comm_rank(comm%handle, taskid, ierr)
1562 152412 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_rank @ "//routineN)
1563 152412 : IF (msglen > 0) THEN
1564 152412 : m1 = SIZE(msg, 1)
1565 457236 : ALLOCATE (res(m1))
1566 : CALL mpi_reduce(msg, res, msglen, ${mpi_type1}$, MPI_SUM, &
1567 152412 : root, comm%handle, ierr)
1568 152412 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_reduce @ "//routineN)
1569 152412 : IF (taskid == root) THEN
1570 610582423 : msg = res
1571 : END IF
1572 152412 : DEALLOCATE (res)
1573 : END IF
1574 152412 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1575 : #else
1576 : MARK_USED(msg)
1577 : MARK_USED(root)
1578 : MARK_USED(comm)
1579 : #endif
1580 152412 : CALL mp_timestop(handle)
1581 152412 : END SUBROUTINE mp_sum_root_${nametype1}$v
1582 :
1583 : ! **************************************************************************************************
1584 : !> \brief Element-wise sum of data from all processes with result left only on
1585 : !> one.
1586 : !> \param[in,out] msg Matrix to sum (input) and (only on process root)
1587 : !> result (output)
1588 : !> \param root ...
1589 : !> \param comm ...
1590 : !> \note see mp_sum_root_${nametype1}$v
1591 : ! **************************************************************************************************
1592 12 : SUBROUTINE mp_sum_root_${nametype1}$m(msg, root, comm)
1593 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1594 : INTEGER, INTENT(IN) :: root
1595 : CLASS(mp_comm_type), INTENT(IN) :: comm
1596 :
1597 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_root_rm'
1598 :
1599 : INTEGER :: handle
1600 : #if defined(__parallel)
1601 : INTEGER :: ierr, m1, m2, msglen, taskid
1602 12 : ${type1}$, ALLOCATABLE :: res(:, :)
1603 : #endif
1604 :
1605 12 : CALL mp_timeset(routineN, handle)
1606 :
1607 : #if defined(__parallel)
1608 36 : msglen = SIZE(msg)
1609 12 : CALL mpi_comm_rank(comm%handle, taskid, ierr)
1610 12 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_rank @ "//routineN)
1611 12 : IF (msglen > 0) THEN
1612 12 : m1 = SIZE(msg, 1)
1613 12 : m2 = SIZE(msg, 2)
1614 48 : ALLOCATE (res(m1, m2))
1615 12 : CALL mpi_reduce(msg, res, msglen, ${mpi_type1}$, MPI_SUM, root, comm%handle, ierr)
1616 12 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_reduce @ "//routineN)
1617 12 : IF (taskid == root) THEN
1618 146 : msg = res
1619 : END IF
1620 12 : DEALLOCATE (res)
1621 : END IF
1622 12 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1623 : #else
1624 : MARK_USED(root)
1625 : MARK_USED(msg)
1626 : MARK_USED(comm)
1627 : #endif
1628 12 : CALL mp_timestop(handle)
1629 12 : END SUBROUTINE mp_sum_root_${nametype1}$m
1630 :
1631 : ! **************************************************************************************************
1632 : !> \brief Element-wise sum of data from all processes with result left only on
1633 : !> one.
1634 : !> \param[in,out] msg Rank-3 tensor to sum (input) and (only on process root)
1635 : !> result (output)
1636 : !> \param root ...
1637 : !> \param comm ...
1638 : !> \note see mp_sum_root_${nametype1}$v
1639 : ! **************************************************************************************************
1640 32 : SUBROUTINE mp_sum_root_${nametype1}$m3(msg, root, comm)
1641 : ${type1}$, CONTIGUOUS, TARGET, INTENT(INOUT) :: msg(:, :, :)
1642 : INTEGER, INTENT(IN) :: root
1643 : CLASS(mp_comm_type), INTENT(IN) :: comm
1644 :
1645 32 : ${type1}$, CONTIGUOUS, POINTER :: msg_flat(:)
1646 :
1647 : ! Remap the contiguous tensor without allocating or copying its elements.
1648 128 : msg_flat(1:SIZE(msg)) => msg
1649 32 : CALL mp_sum_root_${nametype1}$v(msg_flat, root, comm)
1650 32 : END SUBROUTINE mp_sum_root_${nametype1}$m3
1651 :
1652 : ! **************************************************************************************************
1653 : !> \brief Partial sum of data from all processes with result on each process.
1654 : !> \param[in] msg Matrix to sum (input)
1655 : !> \param[out] res Matrix containing result (output)
1656 : !> \param[in] comm Message passing environment identifier
1657 : ! **************************************************************************************************
1658 112 : SUBROUTINE mp_sum_partial_${nametype1}$m(msg, res, comm)
1659 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:, :)
1660 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: res(:, :)
1661 : CLASS(mp_comm_type), INTENT(IN) :: comm
1662 :
1663 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_partial_${nametype1}$m'
1664 :
1665 : INTEGER :: handle
1666 : #if defined(__parallel)
1667 : INTEGER :: ierr, msglen, taskid
1668 : #endif
1669 :
1670 56 : CALL mp_timeset(routineN, handle)
1671 :
1672 : #if defined(__parallel)
1673 168 : msglen = SIZE(msg)
1674 56 : CALL mpi_comm_rank(comm%handle, taskid, ierr)
1675 56 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_comm_rank @ "//routineN)
1676 56 : IF (msglen > 0) THEN
1677 56 : CALL mpi_scan(msg, res, msglen, ${mpi_type1}$, MPI_SUM, comm%handle, ierr)
1678 56 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_scan @ "//routineN)
1679 : END IF
1680 56 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1681 : ! perf_id is same as for other summation routines
1682 : #else
1683 : res = msg
1684 : MARK_USED(comm)
1685 : #endif
1686 56 : CALL mp_timestop(handle)
1687 56 : END SUBROUTINE mp_sum_partial_${nametype1}$m
1688 :
1689 : ! **************************************************************************************************
1690 : !> \brief Finds the maximum of a datum with the result left on all processes.
1691 : !> \param[in,out] msg Find maximum among these data (input) and
1692 : !> maximum (output)
1693 : !> \param[in] comm Message passing environment identifier
1694 : !> \par MPI mapping
1695 : !> mpi_allreduce
1696 : ! **************************************************************************************************
1697 17454290 : SUBROUTINE mp_max_${nametype1}$ (msg, comm)
1698 : ${type1}$, INTENT(INOUT) :: msg
1699 : CLASS(mp_comm_type), INTENT(IN) :: comm
1700 :
1701 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_max_${nametype1}$'
1702 :
1703 : INTEGER :: handle
1704 : #if defined(__parallel)
1705 : INTEGER :: ierr, msglen
1706 : ${type1}$ :: res
1707 : #endif
1708 :
1709 17454290 : CALL mp_timeset(routineN, handle)
1710 :
1711 : #if defined(__parallel)
1712 17454290 : msglen = 1
1713 17454290 : IF (comm%num_pe > 1) THEN
1714 17208834 : CALL mpi_allreduce(msg, res, msglen, ${mpi_type1}$, MPI_MAX, comm%handle, ierr)
1715 17208834 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1716 17208834 : msg = res
1717 : END IF
1718 17454290 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1719 : #else
1720 : MARK_USED(msg)
1721 : MARK_USED(comm)
1722 : #endif
1723 17454290 : CALL mp_timestop(handle)
1724 17454290 : END SUBROUTINE mp_max_${nametype1}$
1725 :
1726 : ! **************************************************************************************************
1727 : !> \brief Finds the maximum of a datum with the result left on all processes.
1728 : !> \param[in,out] msg Find maximum among these data (input) and
1729 : !> maximum (output)
1730 : !> \param[in] comm Message passing environment identifier
1731 : !> \par MPI mapping
1732 : !> mpi_allreduce
1733 : ! **************************************************************************************************
1734 56 : SUBROUTINE mp_max_root_${nametype1}$ (msg, root, comm)
1735 : ${type1}$, INTENT(INOUT) :: msg
1736 : INTEGER, INTENT(IN) :: root
1737 : CLASS(mp_comm_type), INTENT(IN) :: comm
1738 :
1739 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_max_root_${nametype1}$'
1740 :
1741 : INTEGER :: handle
1742 : #if defined(__parallel)
1743 : INTEGER :: ierr, msglen
1744 : ${type1}$ :: res
1745 : #endif
1746 :
1747 56 : CALL mp_timeset(routineN, handle)
1748 :
1749 : #if defined(__parallel)
1750 56 : msglen = 1
1751 56 : CALL mpi_reduce(msg, res, msglen, ${mpi_type1}$, MPI_MAX, root, comm%handle, ierr)
1752 56 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_reduce @ "//routineN)
1753 56 : IF (root == comm%mepos) msg = res
1754 56 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1755 : #else
1756 : MARK_USED(msg)
1757 : MARK_USED(comm)
1758 : MARK_USED(root)
1759 : #endif
1760 56 : CALL mp_timestop(handle)
1761 56 : END SUBROUTINE mp_max_root_${nametype1}$
1762 :
1763 : ! **************************************************************************************************
1764 : !> \brief Finds the element-wise maximum of a vector with the result left on
1765 : !> all processes.
1766 : !> \param[in,out] msg Find maximum among these data (input) and
1767 : !> maximum (output)
1768 : !> \param comm ...
1769 : !> \note see mp_max_${nametype1}$
1770 : ! **************************************************************************************************
1771 1262600 : SUBROUTINE mp_max_${nametype1}$v(msg, comm)
1772 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:)
1773 : CLASS(mp_comm_type), INTENT(IN) :: comm
1774 :
1775 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_max_${nametype1}$v'
1776 :
1777 : INTEGER :: handle
1778 : #if defined(__parallel)
1779 : INTEGER :: ierr, msglen
1780 1262600 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1781 : #endif
1782 :
1783 1262600 : CALL mp_timeset(routineN, handle)
1784 :
1785 : #if defined(__parallel)
1786 1262600 : msglen = SIZE(msg)
1787 1262600 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1788 3108594 : ALLOCATE (msgbuf(msglen))
1789 1036198 : CALL mpi_allreduce(msg, msgbuf, msglen, ${mpi_type1}$, MPI_MAX, comm%handle, ierr)
1790 1036198 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1791 3119466 : msg = msgbuf
1792 : END IF
1793 1262600 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1794 : #else
1795 : MARK_USED(msg)
1796 : MARK_USED(comm)
1797 : #endif
1798 1262600 : CALL mp_timestop(handle)
1799 1262600 : END SUBROUTINE mp_max_${nametype1}$v
1800 :
1801 : ! **************************************************************************************************
1802 : !> \brief Finds the element-wise maximum of a rank2-array with the result left on
1803 : !> all processes.
1804 : !> \param[in] msg Matrix - Find maximum among these data (input) and
1805 : !> maximum (output)
1806 : !> \param comm ...
1807 : !> \note see mp_max_${nametype1}$
1808 : ! **************************************************************************************************
1809 300 : SUBROUTINE mp_max_${nametype1}$m(msg, comm)
1810 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1811 : CLASS(mp_comm_type), INTENT(IN) :: comm
1812 :
1813 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_max_${nametype1}$m'
1814 :
1815 : INTEGER :: handle
1816 : #if defined(__parallel)
1817 : INTEGER, PARAMETER :: max_msg = 2**25
1818 : INTEGER :: ierr, m1, msglen, ncols, step, msglensum
1819 300 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1820 : #endif
1821 :
1822 300 : CALL mp_timeset(routineN, handle)
1823 :
1824 : #if defined(__parallel)
1825 : ! chunk up the call so that message sizes are limited, to avoid overflows in mpich triggered in large rpa calcs
1826 900 : step = MAX(1, SIZE(msg, 2)/MAX(1, SIZE(msg)/max_msg))
1827 300 : msglensum = 0
1828 900 : DO m1 = LBOUND(msg, 2), UBOUND(msg, 2), step
1829 300 : msglen = SIZE(msg, 1)*(MIN(UBOUND(msg, 2), m1 + step - 1) - m1 + 1)
1830 300 : msglensum = msglensum + msglen
1831 600 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1832 300 : ncols = MIN(UBOUND(msg, 2), m1 + step - 1) - m1 + 1
1833 900 : ALLOCATE (msgbuf(msglen))
1834 300 : CALL mpi_allreduce(msg(LBOUND(msg, 1), m1), msgbuf, msglen, ${mpi_type1}$, MPI_MAX, comm%handle, ierr)
1835 300 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1836 900 : msg(:, m1:m1 + ncols - 1) = RESHAPE(msgbuf, [SIZE(msg, 1), ncols])
1837 300 : DEALLOCATE (msgbuf)
1838 : END IF
1839 : END DO
1840 300 : CALL add_perf(perf_id=3, count=1, msg_size=msglensum*${bytes1}$)
1841 : #else
1842 : MARK_USED(msg)
1843 : MARK_USED(comm)
1844 : #endif
1845 300 : CALL mp_timestop(handle)
1846 300 : END SUBROUTINE mp_max_${nametype1}$m
1847 :
1848 : ! **************************************************************************************************
1849 : !> \brief Finds the element-wise maximum of a vector with the result left on
1850 : !> all processes.
1851 : !> \param[in,out] msg Find maximum among these data (input) and
1852 : !> maximum (output)
1853 : !> \param comm ...
1854 : !> \note see mp_max_${nametype1}$
1855 : ! **************************************************************************************************
1856 2 : SUBROUTINE mp_max_root_${nametype1}$m(msg, root, comm)
1857 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1858 : INTEGER :: root
1859 : CLASS(mp_comm_type), INTENT(IN) :: comm
1860 :
1861 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_max_root_${nametype1}$m'
1862 :
1863 : INTEGER :: handle
1864 : #if defined(__parallel)
1865 : INTEGER :: ierr, msglen
1866 4 : ${type1}$ :: res(SIZE(msg, 1), SIZE(msg, 2))
1867 : #endif
1868 :
1869 2 : CALL mp_timeset(routineN, handle)
1870 :
1871 : #if defined(__parallel)
1872 6 : msglen = SIZE(msg)
1873 2 : CALL mpi_reduce(msg, res, msglen, ${mpi_type1}$, MPI_MAX, root, comm%handle, ierr)
1874 2 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1875 9 : IF (root == comm%mepos) msg = res
1876 2 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1877 : #else
1878 : MARK_USED(msg)
1879 : MARK_USED(comm)
1880 : MARK_USED(root)
1881 : #endif
1882 2 : CALL mp_timestop(handle)
1883 2 : END SUBROUTINE mp_max_root_${nametype1}$m
1884 :
1885 : ! **************************************************************************************************
1886 : !> \brief Finds the minimum of a datum with the result left on all processes.
1887 : !> \param[in,out] msg Find minimum among these data (input) and
1888 : !> maximum (output)
1889 : !> \param[in] comm Message passing environment identifier
1890 : !> \par MPI mapping
1891 : !> mpi_allreduce
1892 : ! **************************************************************************************************
1893 149048 : SUBROUTINE mp_min_${nametype1}$ (msg, comm)
1894 : ${type1}$, INTENT(INOUT) :: msg
1895 : CLASS(mp_comm_type), INTENT(IN) :: comm
1896 :
1897 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_min_${nametype1}$'
1898 :
1899 : INTEGER :: handle
1900 : #if defined(__parallel)
1901 : INTEGER :: ierr, msglen
1902 : ${type1}$ :: res
1903 : #endif
1904 :
1905 149048 : CALL mp_timeset(routineN, handle)
1906 :
1907 : #if defined(__parallel)
1908 149048 : msglen = 1
1909 149048 : IF (comm%num_pe > 1) THEN
1910 148184 : CALL mpi_allreduce(msg, res, msglen, ${mpi_type1}$, MPI_MIN, comm%handle, ierr)
1911 148184 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1912 148184 : msg = res
1913 : END IF
1914 149048 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1915 : #else
1916 : MARK_USED(msg)
1917 : MARK_USED(comm)
1918 : #endif
1919 149048 : CALL mp_timestop(handle)
1920 149048 : END SUBROUTINE mp_min_${nametype1}$
1921 :
1922 : ! **************************************************************************************************
1923 : !> \brief Finds the element-wise minimum of vector with the result left on
1924 : !> all processes.
1925 : !> \param[in,out] msg Find minimum among these data (input) and
1926 : !> maximum (output)
1927 : !> \param comm ...
1928 : !> \par MPI mapping
1929 : !> mpi_allreduce
1930 : !> \note see mp_min_${nametype1}$
1931 : ! **************************************************************************************************
1932 50077 : SUBROUTINE mp_min_${nametype1}$v(msg, comm)
1933 : ${type1}$, INTENT(INOUT), CONTIGUOUS :: msg(:)
1934 : CLASS(mp_comm_type), INTENT(IN) :: comm
1935 :
1936 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_min_${nametype1}$v'
1937 :
1938 : INTEGER :: handle
1939 : #if defined(__parallel)
1940 : INTEGER :: ierr, msglen
1941 50077 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1942 : #endif
1943 :
1944 50077 : CALL mp_timeset(routineN, handle)
1945 :
1946 : #if defined(__parallel)
1947 50077 : msglen = SIZE(msg)
1948 50077 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1949 149076 : ALLOCATE (msgbuf(msglen))
1950 49692 : CALL mpi_allreduce(msg, msgbuf, msglen, ${mpi_type1}$, MPI_MIN, comm%handle, ierr)
1951 49692 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1952 169554 : msg = msgbuf
1953 : END IF
1954 50077 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
1955 : #else
1956 : MARK_USED(msg)
1957 : MARK_USED(comm)
1958 : #endif
1959 50077 : CALL mp_timestop(handle)
1960 50077 : END SUBROUTINE mp_min_${nametype1}$v
1961 :
1962 : ! **************************************************************************************************
1963 : !> \brief Finds the element-wise minimum of a rank2-array with the result left on
1964 : !> all processes.
1965 : !> \param[in] msg Matrix - Find maximum among these data (input) and
1966 : !> minimum (output)
1967 : !> \param comm ...
1968 : !> \note see mp_min_${nametype1}$
1969 : ! **************************************************************************************************
1970 164 : SUBROUTINE mp_min_${nametype1}$m(msg, comm)
1971 : ${type1}$, CONTIGUOUS, INTENT(INOUT) :: msg(:, :)
1972 : CLASS(mp_comm_type), INTENT(IN) :: comm
1973 :
1974 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_min_${nametype1}$m'
1975 :
1976 : INTEGER :: handle
1977 : #if defined(__parallel)
1978 : INTEGER, PARAMETER :: max_msg = 2**25
1979 : INTEGER :: ierr, m1, msglen, ncols, step, msglensum
1980 164 : ${type1}$, ALLOCATABLE :: msgbuf(:)
1981 : #endif
1982 :
1983 164 : CALL mp_timeset(routineN, handle)
1984 :
1985 : #if defined(__parallel)
1986 : ! chunk up the call so that message sizes are limited, to avoid overflows in mpich triggered in large rpa calcs
1987 492 : step = MAX(1, SIZE(msg, 2)/MAX(1, SIZE(msg)/max_msg))
1988 164 : msglensum = 0
1989 492 : DO m1 = LBOUND(msg, 2), UBOUND(msg, 2), step
1990 164 : msglen = SIZE(msg, 1)*(MIN(UBOUND(msg, 2), m1 + step - 1) - m1 + 1)
1991 164 : msglensum = msglensum + msglen
1992 328 : IF (msglen > 0 .AND. comm%num_pe > 1) THEN
1993 164 : ncols = MIN(UBOUND(msg, 2), m1 + step - 1) - m1 + 1
1994 492 : ALLOCATE (msgbuf(msglen))
1995 164 : CALL mpi_allreduce(msg(LBOUND(msg, 1), m1), msgbuf, msglen, ${mpi_type1}$, MPI_MIN, comm%handle, ierr)
1996 164 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
1997 492 : msg(:, m1:m1 + ncols - 1) = RESHAPE(msgbuf, [SIZE(msg, 1), ncols])
1998 164 : DEALLOCATE (msgbuf)
1999 : END IF
2000 : END DO
2001 164 : CALL add_perf(perf_id=3, count=1, msg_size=msglensum*${bytes1}$)
2002 : #else
2003 : MARK_USED(msg)
2004 : MARK_USED(comm)
2005 : #endif
2006 164 : CALL mp_timestop(handle)
2007 164 : END SUBROUTINE mp_min_${nametype1}$m
2008 :
2009 : ! **************************************************************************************************
2010 : !> \brief Multiplies a set of numbers scattered across a number of processes,
2011 : !> then replicates the result.
2012 : !> \param[in,out] msg a number to multiply (input) and result (output)
2013 : !> \param[in] comm message passing environment identifier
2014 : !> \par MPI mapping
2015 : !> mpi_allreduce
2016 : ! **************************************************************************************************
2017 6416 : SUBROUTINE mp_prod_${nametype1}$ (msg, comm)
2018 : ${type1}$, INTENT(INOUT) :: msg
2019 : CLASS(mp_comm_type), INTENT(IN) :: comm
2020 :
2021 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_prod_${nametype1}$'
2022 :
2023 : INTEGER :: handle
2024 : #if defined(__parallel)
2025 : INTEGER :: ierr, msglen
2026 : ${type1}$ :: res
2027 : #endif
2028 :
2029 6416 : CALL mp_timeset(routineN, handle)
2030 :
2031 : #if defined(__parallel)
2032 6416 : msglen = 1
2033 6416 : IF (comm%num_pe > 1) THEN
2034 6416 : CALL mpi_allreduce(msg, res, msglen, ${mpi_type1}$, MPI_PROD, comm%handle, ierr)
2035 6416 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allreduce @ "//routineN)
2036 6416 : msg = res
2037 : END IF
2038 6416 : CALL add_perf(perf_id=3, count=1, msg_size=msglen*${bytes1}$)
2039 : #else
2040 : MARK_USED(msg)
2041 : MARK_USED(comm)
2042 : #endif
2043 6416 : CALL mp_timestop(handle)
2044 6416 : END SUBROUTINE mp_prod_${nametype1}$
2045 :
2046 : ! **************************************************************************************************
2047 : !> \brief Scatters data from one processes to all others
2048 : !> \param[in] msg_scatter Data to scatter (for root process)
2049 : !> \param[out] msg Received data
2050 : !> \param[in] root Process which scatters data
2051 : !> \param[in] comm Message passing environment identifier
2052 : !> \par MPI mapping
2053 : !> mpi_scatter
2054 : ! **************************************************************************************************
2055 0 : SUBROUTINE mp_scatter_${nametype1}$v(msg_scatter, msg, root, comm)
2056 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg_scatter(:)
2057 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg(:)
2058 : INTEGER, INTENT(IN) :: root
2059 : CLASS(mp_comm_type), INTENT(IN) :: comm
2060 :
2061 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_scatter_${nametype1}$v'
2062 :
2063 : INTEGER :: handle
2064 : #if defined(__parallel)
2065 : INTEGER :: ierr, msglen
2066 : #endif
2067 :
2068 0 : CALL mp_timeset(routineN, handle)
2069 :
2070 : #if defined(__parallel)
2071 0 : msglen = SIZE(msg)
2072 : CALL mpi_scatter(msg_scatter, msglen, ${mpi_type1}$, msg, &
2073 0 : msglen, ${mpi_type1}$, root, comm%handle, ierr)
2074 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_scatter @ "//routineN)
2075 0 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2076 : #else
2077 : MARK_USED(root)
2078 : MARK_USED(comm)
2079 : msg = msg_scatter
2080 : #endif
2081 0 : CALL mp_timestop(handle)
2082 0 : END SUBROUTINE mp_scatter_${nametype1}$v
2083 :
2084 : ! **************************************************************************************************
2085 : !> \brief Scatters data from one processes to all others
2086 : !> \param[in] msg_scatter Data to scatter (for root process)
2087 : !> \param[in] root Process which scatters data
2088 : !> \param[in] comm Message passing environment identifier
2089 : !> \par MPI mapping
2090 : !> mpi_scatter
2091 : ! **************************************************************************************************
2092 0 : SUBROUTINE mp_iscatter_${nametype1}$ (msg_scatter, msg, root, comm, request)
2093 : ${type1}$, INTENT(IN) :: msg_scatter(:)
2094 : ${type1}$, INTENT(INOUT) :: msg
2095 : INTEGER, INTENT(IN) :: root
2096 : CLASS(mp_comm_type), INTENT(IN) :: comm
2097 : TYPE(mp_request_type), INTENT(OUT) :: request
2098 :
2099 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iscatter_${nametype1}$'
2100 :
2101 : INTEGER :: handle
2102 : #if defined(__parallel)
2103 : INTEGER :: ierr, msglen
2104 : #endif
2105 :
2106 0 : CALL mp_timeset(routineN, handle)
2107 :
2108 : #if defined(__parallel)
2109 0 : CPASSERT(IS_CONTIGUOUS(msg_scatter) .OR. SIZE(msg_scatter) == 0)
2110 0 : msglen = 1
2111 : CALL mpi_iscatter(msg_scatter, msglen, ${mpi_type1}$, msg, &
2112 0 : msglen, ${mpi_type1}$, root, comm%handle, request%handle, ierr)
2113 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iscatter @ "//routineN)
2114 0 : CALL add_perf(perf_id=24, count=1, msg_size=1*${bytes1}$)
2115 : #else
2116 : MARK_USED(root)
2117 : MARK_USED(comm)
2118 : msg = msg_scatter(1)
2119 : request = mp_request_null
2120 : #endif
2121 0 : CALL mp_timestop(handle)
2122 0 : END SUBROUTINE mp_iscatter_${nametype1}$
2123 :
2124 : ! **************************************************************************************************
2125 : !> \brief Scatters data from one processes to all others
2126 : !> \param[in] msg_scatter Data to scatter (for root process)
2127 : !> \param[in] root Process which scatters data
2128 : !> \param[in] comm Message passing environment identifier
2129 : !> \par MPI mapping
2130 : !> mpi_scatter
2131 : ! **************************************************************************************************
2132 0 : SUBROUTINE mp_iscatter_${nametype1}$v2(msg_scatter, msg, root, comm, request)
2133 : ${type1}$, INTENT(IN) :: msg_scatter(:, :)
2134 : ${type1}$, INTENT(INOUT) :: msg(:)
2135 : INTEGER, INTENT(IN) :: root
2136 : CLASS(mp_comm_type), INTENT(IN) :: comm
2137 : TYPE(mp_request_type), INTENT(OUT) :: request
2138 :
2139 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iscatter_${nametype1}$v2'
2140 :
2141 : INTEGER :: handle
2142 : #if defined(__parallel)
2143 : INTEGER :: ierr, msglen
2144 : #endif
2145 :
2146 0 : CALL mp_timeset(routineN, handle)
2147 :
2148 : #if defined(__parallel)
2149 0 : CPASSERT(IS_CONTIGUOUS(msg_scatter) .OR. SIZE(msg_scatter) == 0)
2150 0 : msglen = SIZE(msg)
2151 : CALL mpi_iscatter(msg_scatter, msglen, ${mpi_type1}$, msg, &
2152 0 : msglen, ${mpi_type1}$, root, comm%handle, request%handle, ierr)
2153 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iscatter @ "//routineN)
2154 0 : CALL add_perf(perf_id=24, count=1, msg_size=1*${bytes1}$)
2155 : #else
2156 : MARK_USED(root)
2157 : MARK_USED(comm)
2158 : msg(:) = msg_scatter(:, 1)
2159 : request = mp_request_null
2160 : #endif
2161 0 : CALL mp_timestop(handle)
2162 0 : END SUBROUTINE mp_iscatter_${nametype1}$v2
2163 :
2164 : ! **************************************************************************************************
2165 : !> \brief Scatters data from one processes to all others
2166 : !> \param[in] msg_scatter Data to scatter (for root process)
2167 : !> \param[in] root Process which scatters data
2168 : !> \param[in] comm Message passing environment identifier
2169 : !> \par MPI mapping
2170 : !> mpi_scatter
2171 : ! **************************************************************************************************
2172 0 : SUBROUTINE mp_iscatterv_${nametype1}$v(msg_scatter, sendcounts, displs, msg, recvcount, root, comm, request)
2173 : ${type1}$, INTENT(IN) :: msg_scatter(:)
2174 : INTEGER, INTENT(IN) :: sendcounts(:), displs(:)
2175 : ${type1}$, INTENT(INOUT) :: msg(:)
2176 : INTEGER, INTENT(IN) :: recvcount, root
2177 : CLASS(mp_comm_type), INTENT(IN) :: comm
2178 : TYPE(mp_request_type), INTENT(OUT) :: request
2179 :
2180 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iscatterv_${nametype1}$v'
2181 :
2182 : INTEGER :: handle
2183 : #if defined(__parallel)
2184 : INTEGER :: ierr
2185 : #endif
2186 :
2187 0 : CALL mp_timeset(routineN, handle)
2188 :
2189 : #if defined(__parallel)
2190 0 : CPASSERT(IS_CONTIGUOUS(msg_scatter) .OR. SIZE(msg_scatter) == 0)
2191 0 : CPASSERT(IS_CONTIGUOUS(msg) .OR. SIZE(msg) == 0)
2192 0 : CPASSERT(IS_CONTIGUOUS(sendcounts) .OR. SIZE(sendcounts) == 0)
2193 0 : CPASSERT(IS_CONTIGUOUS(displs) .OR. SIZE(displs) == 0)
2194 : CALL mpi_iscatterv(msg_scatter, sendcounts, displs, ${mpi_type1}$, msg, &
2195 0 : recvcount, ${mpi_type1}$, root, comm%handle, request%handle, ierr)
2196 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iscatterv @ "//routineN)
2197 0 : CALL add_perf(perf_id=24, count=1, msg_size=1*${bytes1}$)
2198 : #else
2199 : MARK_USED(sendcounts)
2200 : MARK_USED(displs)
2201 : MARK_USED(recvcount)
2202 : MARK_USED(root)
2203 : MARK_USED(comm)
2204 : msg(1:recvcount) = msg_scatter(1 + displs(1):1 + displs(1) + sendcounts(1))
2205 : request = mp_request_null
2206 : #endif
2207 0 : CALL mp_timestop(handle)
2208 0 : END SUBROUTINE mp_iscatterv_${nametype1}$v
2209 :
2210 : ! **************************************************************************************************
2211 : !> \brief Gathers a datum from all processes to one
2212 : !> \param[in] msg Datum to send to root
2213 : !> \param[out] msg_gather Received data (on root)
2214 : !> \param[in] root Process which gathers the data
2215 : !> \param[in] comm Message passing environment identifier
2216 : !> \par MPI mapping
2217 : !> mpi_gather
2218 : ! **************************************************************************************************
2219 0 : SUBROUTINE mp_gather_${nametype1}$ (msg, msg_gather, root, comm)
2220 : ${type1}$, INTENT(IN) :: msg
2221 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg_gather(:)
2222 : INTEGER, INTENT(IN) :: root
2223 : CLASS(mp_comm_type), INTENT(IN) :: comm
2224 :
2225 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gather_${nametype1}$'
2226 :
2227 : INTEGER :: handle
2228 : #if defined(__parallel)
2229 : INTEGER :: ierr, msglen
2230 : #endif
2231 :
2232 0 : CALL mp_timeset(routineN, handle)
2233 :
2234 : #if defined(__parallel)
2235 0 : msglen = 1
2236 : CALL mpi_gather(msg, msglen, ${mpi_type1}$, msg_gather, &
2237 0 : msglen, ${mpi_type1}$, root, comm%handle, ierr)
2238 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gather @ "//routineN)
2239 0 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2240 : #else
2241 : MARK_USED(root)
2242 : MARK_USED(comm)
2243 : msg_gather(1) = msg
2244 : #endif
2245 0 : CALL mp_timestop(handle)
2246 0 : END SUBROUTINE mp_gather_${nametype1}$
2247 :
2248 : ! **************************************************************************************************
2249 : !> \brief Gathers a datum from all processes to one, uses the source process of comm
2250 : !> \param[in] msg Datum to send to root
2251 : !> \param[out] msg_gather Received data (on root)
2252 : !> \param[in] comm Message passing environment identifier
2253 : !> \par MPI mapping
2254 : !> mpi_gather
2255 : ! **************************************************************************************************
2256 30 : SUBROUTINE mp_gather_${nametype1}$_src(msg, msg_gather, comm)
2257 : ${type1}$, INTENT(IN) :: msg
2258 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg_gather(:)
2259 : CLASS(mp_comm_type), INTENT(IN) :: comm
2260 :
2261 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gather_${nametype1}$_src'
2262 :
2263 : INTEGER :: handle
2264 : #if defined(__parallel)
2265 : INTEGER :: ierr, msglen
2266 : #endif
2267 :
2268 30 : CALL mp_timeset(routineN, handle)
2269 :
2270 : #if defined(__parallel)
2271 30 : msglen = 1
2272 : CALL mpi_gather(msg, msglen, ${mpi_type1}$, msg_gather, &
2273 30 : msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
2274 30 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gather @ "//routineN)
2275 30 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2276 : #else
2277 : MARK_USED(comm)
2278 : msg_gather(1) = msg
2279 : #endif
2280 30 : CALL mp_timestop(handle)
2281 30 : END SUBROUTINE mp_gather_${nametype1}$_src
2282 :
2283 : ! **************************************************************************************************
2284 : !> \brief Gathers data from all processes to one
2285 : !> \param[in] msg Datum to send to root
2286 : !> \param msg_gather ...
2287 : !> \param root ...
2288 : !> \param comm ...
2289 : !> \par Data length
2290 : !> All data (msg) is equal-sized
2291 : !> \par MPI mapping
2292 : !> mpi_gather
2293 : !> \note see mp_gather_${nametype1}$
2294 : ! **************************************************************************************************
2295 0 : SUBROUTINE mp_gather_${nametype1}$v(msg, msg_gather, root, comm)
2296 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:)
2297 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg_gather(:)
2298 : INTEGER, INTENT(IN) :: root
2299 : CLASS(mp_comm_type), INTENT(IN) :: comm
2300 :
2301 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gather_${nametype1}$v'
2302 :
2303 : INTEGER :: handle
2304 : #if defined(__parallel)
2305 : INTEGER :: ierr, msglen
2306 : #endif
2307 :
2308 0 : CALL mp_timeset(routineN, handle)
2309 :
2310 : #if defined(__parallel)
2311 0 : msglen = SIZE(msg)
2312 : CALL mpi_gather(msg, msglen, ${mpi_type1}$, msg_gather, &
2313 0 : msglen, ${mpi_type1}$, root, comm%handle, ierr)
2314 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gather @ "//routineN)
2315 0 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2316 : #else
2317 : MARK_USED(root)
2318 : MARK_USED(comm)
2319 : msg_gather = msg
2320 : #endif
2321 0 : CALL mp_timestop(handle)
2322 0 : END SUBROUTINE mp_gather_${nametype1}$v
2323 :
2324 : ! **************************************************************************************************
2325 : !> \brief Gathers data from all processes to one. Gathers from comm%source
2326 : !> \param[in] msg Datum to send to root
2327 : !> \param msg_gather ...
2328 : !> \param comm ...
2329 : !> \par Data length
2330 : !> All data (msg) is equal-sized
2331 : !> \par MPI mapping
2332 : !> mpi_gather
2333 : !> \note see mp_gather_${nametype1}$
2334 : ! **************************************************************************************************
2335 0 : SUBROUTINE mp_gather_${nametype1}$v_src(msg, msg_gather, comm)
2336 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:)
2337 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg_gather(:)
2338 : CLASS(mp_comm_type), INTENT(IN) :: comm
2339 :
2340 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gather_${nametype1}$v_src'
2341 :
2342 : INTEGER :: handle
2343 : #if defined(__parallel)
2344 : INTEGER :: ierr, msglen
2345 : #endif
2346 :
2347 0 : CALL mp_timeset(routineN, handle)
2348 :
2349 : #if defined(__parallel)
2350 0 : msglen = SIZE(msg)
2351 : CALL mpi_gather(msg, msglen, ${mpi_type1}$, msg_gather, &
2352 0 : msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
2353 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gather @ "//routineN)
2354 0 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2355 : #else
2356 : MARK_USED(comm)
2357 : msg_gather = msg
2358 : #endif
2359 0 : CALL mp_timestop(handle)
2360 0 : END SUBROUTINE mp_gather_${nametype1}$v_src
2361 :
2362 : ! **************************************************************************************************
2363 : !> \brief Gathers data from all processes to one
2364 : !> \param[in] msg Datum to send to root
2365 : !> \param msg_gather ...
2366 : !> \param root ...
2367 : !> \param comm ...
2368 : !> \par Data length
2369 : !> All data (msg) is equal-sized
2370 : !> \par MPI mapping
2371 : !> mpi_gather
2372 : !> \note see mp_gather_${nametype1}$
2373 : ! **************************************************************************************************
2374 0 : SUBROUTINE mp_gather_${nametype1}$m(msg, msg_gather, root, comm)
2375 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:, :)
2376 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg_gather(:, :)
2377 : INTEGER, INTENT(IN) :: root
2378 : CLASS(mp_comm_type), INTENT(IN) :: comm
2379 :
2380 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gather_${nametype1}$m'
2381 :
2382 : INTEGER :: handle
2383 : #if defined(__parallel)
2384 : INTEGER :: ierr, msglen
2385 : #endif
2386 :
2387 0 : CALL mp_timeset(routineN, handle)
2388 :
2389 : #if defined(__parallel)
2390 0 : msglen = SIZE(msg)
2391 : CALL mpi_gather(msg, msglen, ${mpi_type1}$, msg_gather, &
2392 0 : msglen, ${mpi_type1}$, root, comm%handle, ierr)
2393 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gather @ "//routineN)
2394 0 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2395 : #else
2396 : MARK_USED(root)
2397 : MARK_USED(comm)
2398 : msg_gather = msg
2399 : #endif
2400 0 : CALL mp_timestop(handle)
2401 0 : END SUBROUTINE mp_gather_${nametype1}$m
2402 :
2403 : ! **************************************************************************************************
2404 : !> \brief Gathers data from all processes to one. Gathers from comm%source
2405 : !> \param[in] msg Datum to send to root
2406 : !> \param msg_gather ...
2407 : !> \param comm ...
2408 : !> \par Data length
2409 : !> All data (msg) is equal-sized
2410 : !> \par MPI mapping
2411 : !> mpi_gather
2412 : !> \note see mp_gather_${nametype1}$
2413 : ! **************************************************************************************************
2414 94 : SUBROUTINE mp_gather_${nametype1}$m_src(msg, msg_gather, comm)
2415 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:, :)
2416 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msg_gather(:, :)
2417 : CLASS(mp_comm_type), INTENT(IN) :: comm
2418 :
2419 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gather_${nametype1}$m_src'
2420 :
2421 : INTEGER :: handle
2422 : #if defined(__parallel)
2423 : INTEGER :: ierr, msglen
2424 : #endif
2425 :
2426 94 : CALL mp_timeset(routineN, handle)
2427 :
2428 : #if defined(__parallel)
2429 282 : msglen = SIZE(msg)
2430 : CALL mpi_gather(msg, msglen, ${mpi_type1}$, msg_gather, &
2431 94 : msglen, ${mpi_type1}$, comm%source, comm%handle, ierr)
2432 94 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gather @ "//routineN)
2433 94 : CALL add_perf(perf_id=4, count=1, msg_size=msglen*${bytes1}$)
2434 : #else
2435 : MARK_USED(comm)
2436 : msg_gather = msg
2437 : #endif
2438 94 : CALL mp_timestop(handle)
2439 94 : END SUBROUTINE mp_gather_${nametype1}$m_src
2440 :
2441 : ! **************************************************************************************************
2442 : !> \brief Gathers data from all processes to one.
2443 : !> \param[in] sendbuf Data to send to root
2444 : !> \param[out] recvbuf Received data (on root)
2445 : !> \param[in] recvcounts Sizes of data received from processes
2446 : !> \param[in] displs Offsets of data received from processes
2447 : !> \param[in] root Process which gathers the data
2448 : !> \param[in] comm Message passing environment identifier
2449 : !> \par Data length
2450 : !> Data can have different lengths
2451 : !> \par Offsets
2452 : !> Offsets start at 0
2453 : !> \par MPI mapping
2454 : !> mpi_gather
2455 : ! **************************************************************************************************
2456 0 : SUBROUTINE mp_gatherv_${nametype1}$v(sendbuf, recvbuf, recvcounts, displs, root, comm)
2457 :
2458 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: sendbuf
2459 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(OUT) :: recvbuf
2460 : INTEGER, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: recvcounts, displs
2461 : INTEGER, INTENT(IN) :: root
2462 : CLASS(mp_comm_type), INTENT(IN) :: comm
2463 :
2464 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gatherv_${nametype1}$v'
2465 :
2466 : INTEGER :: handle
2467 : #if defined(__parallel)
2468 : INTEGER :: ierr, sendcount
2469 : #endif
2470 :
2471 0 : CALL mp_timeset(routineN, handle)
2472 :
2473 : #if defined(__parallel)
2474 0 : sendcount = SIZE(sendbuf)
2475 : CALL mpi_gatherv(sendbuf, sendcount, ${mpi_type1}$, &
2476 : recvbuf, recvcounts, displs, ${mpi_type1}$, &
2477 0 : root, comm%handle, ierr)
2478 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gatherv @ "//routineN)
2479 : CALL add_perf(perf_id=4, &
2480 : count=1, &
2481 0 : msg_size=sendcount*${bytes1}$)
2482 : #else
2483 : MARK_USED(recvcounts)
2484 : MARK_USED(root)
2485 : MARK_USED(comm)
2486 : recvbuf(1 + displs(1):) = sendbuf
2487 : #endif
2488 0 : CALL mp_timestop(handle)
2489 0 : END SUBROUTINE mp_gatherv_${nametype1}$v
2490 :
2491 : ! **************************************************************************************************
2492 : !> \brief Gathers data from all processes to one. Gathers from comm%source
2493 : !> \param[in] sendbuf Data to send to root
2494 : !> \param[out] recvbuf Received data (on root)
2495 : !> \param[in] recvcounts Sizes of data received from processes
2496 : !> \param[in] displs Offsets of data received from processes
2497 : !> \param[in] comm Message passing environment identifier
2498 : !> \par Data length
2499 : !> Data can have different lengths
2500 : !> \par Offsets
2501 : !> Offsets start at 0
2502 : !> \par MPI mapping
2503 : !> mpi_gather
2504 : ! **************************************************************************************************
2505 210 : SUBROUTINE mp_gatherv_${nametype1}$v_src(sendbuf, recvbuf, recvcounts, displs, comm)
2506 :
2507 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: sendbuf
2508 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(OUT) :: recvbuf
2509 : INTEGER, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: recvcounts, displs
2510 : CLASS(mp_comm_type), INTENT(IN) :: comm
2511 :
2512 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gatherv_${nametype1}$v_src'
2513 :
2514 : INTEGER :: handle
2515 : #if defined(__parallel)
2516 : INTEGER :: ierr, sendcount
2517 : #endif
2518 :
2519 210 : CALL mp_timeset(routineN, handle)
2520 :
2521 : #if defined(__parallel)
2522 210 : sendcount = SIZE(sendbuf)
2523 : CALL mpi_gatherv(sendbuf, sendcount, ${mpi_type1}$, &
2524 : recvbuf, recvcounts, displs, ${mpi_type1}$, &
2525 210 : comm%source, comm%handle, ierr)
2526 210 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gatherv @ "//routineN)
2527 : CALL add_perf(perf_id=4, &
2528 : count=1, &
2529 210 : msg_size=sendcount*${bytes1}$)
2530 : #else
2531 : MARK_USED(recvcounts)
2532 : MARK_USED(comm)
2533 : recvbuf(1 + displs(1):) = sendbuf
2534 : #endif
2535 210 : CALL mp_timestop(handle)
2536 210 : END SUBROUTINE mp_gatherv_${nametype1}$v_src
2537 :
2538 : ! **************************************************************************************************
2539 : !> \brief Gathers data from all processes to one.
2540 : !> \param[in] sendbuf Data to send to root
2541 : !> \param[out] recvbuf Received data (on root)
2542 : !> \param[in] recvcounts Sizes of data received from processes
2543 : !> \param[in] displs Offsets of data received from processes
2544 : !> \param[in] root Process which gathers the data
2545 : !> \param[in] comm Message passing environment identifier
2546 : !> \par Data length
2547 : !> Data can have different lengths
2548 : !> \par Offsets
2549 : !> Offsets start at 0
2550 : !> \par MPI mapping
2551 : !> mpi_gather
2552 : ! **************************************************************************************************
2553 56 : SUBROUTINE mp_gatherv_${nametype1}$m2(sendbuf, recvbuf, recvcounts, displs, root, comm)
2554 :
2555 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, INTENT(IN) :: sendbuf
2556 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, INTENT(OUT) :: recvbuf
2557 : INTEGER, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: recvcounts, displs
2558 : INTEGER, INTENT(IN) :: root
2559 : CLASS(mp_comm_type), INTENT(IN) :: comm
2560 :
2561 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gatherv_${nametype1}$m2'
2562 :
2563 : INTEGER :: handle
2564 : #if defined(__parallel)
2565 : INTEGER :: ierr, sendcount
2566 : #endif
2567 :
2568 56 : CALL mp_timeset(routineN, handle)
2569 :
2570 : #if defined(__parallel)
2571 168 : sendcount = SIZE(sendbuf)
2572 : CALL mpi_gatherv(sendbuf, sendcount, ${mpi_type1}$, &
2573 : recvbuf, recvcounts, displs, ${mpi_type1}$, &
2574 56 : root, comm%handle, ierr)
2575 56 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gatherv @ "//routineN)
2576 : CALL add_perf(perf_id=4, &
2577 : count=1, &
2578 56 : msg_size=sendcount*${bytes1}$)
2579 : #else
2580 : MARK_USED(recvcounts)
2581 : MARK_USED(root)
2582 : MARK_USED(comm)
2583 : recvbuf(:, 1 + displs(1):) = sendbuf
2584 : #endif
2585 56 : CALL mp_timestop(handle)
2586 56 : END SUBROUTINE mp_gatherv_${nametype1}$m2
2587 :
2588 : ! **************************************************************************************************
2589 : !> \brief Gathers data from all processes to one.
2590 : !> \param[in] sendbuf Data to send to root
2591 : !> \param[out] recvbuf Received data (on root)
2592 : !> \param[in] recvcounts Sizes of data received from processes
2593 : !> \param[in] displs Offsets of data received from processes
2594 : !> \param[in] comm Message passing environment identifier
2595 : !> \par Data length
2596 : !> Data can have different lengths
2597 : !> \par Offsets
2598 : !> Offsets start at 0
2599 : !> \par MPI mapping
2600 : !> mpi_gather
2601 : ! **************************************************************************************************
2602 0 : SUBROUTINE mp_gatherv_${nametype1}$m2_src(sendbuf, recvbuf, recvcounts, displs, comm)
2603 :
2604 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, INTENT(IN) :: sendbuf
2605 : ${type1}$, DIMENSION(:, :), CONTIGUOUS, INTENT(OUT) :: recvbuf
2606 : INTEGER, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: recvcounts, displs
2607 : CLASS(mp_comm_type), INTENT(IN) :: comm
2608 :
2609 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_gatherv_${nametype1}$m2_src'
2610 :
2611 : INTEGER :: handle
2612 : #if defined(__parallel)
2613 : INTEGER :: ierr, sendcount
2614 : #endif
2615 :
2616 0 : CALL mp_timeset(routineN, handle)
2617 :
2618 : #if defined(__parallel)
2619 0 : sendcount = SIZE(sendbuf)
2620 : CALL mpi_gatherv(sendbuf, sendcount, ${mpi_type1}$, &
2621 : recvbuf, recvcounts, displs, ${mpi_type1}$, &
2622 0 : comm%source, comm%handle, ierr)
2623 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gatherv @ "//routineN)
2624 : CALL add_perf(perf_id=4, &
2625 : count=1, &
2626 0 : msg_size=sendcount*${bytes1}$)
2627 : #else
2628 : MARK_USED(recvcounts)
2629 : MARK_USED(comm)
2630 : recvbuf(:, 1 + displs(1):) = sendbuf
2631 : #endif
2632 0 : CALL mp_timestop(handle)
2633 0 : END SUBROUTINE mp_gatherv_${nametype1}$m2_src
2634 :
2635 : ! **************************************************************************************************
2636 : !> \brief Gathers data from all processes to one.
2637 : !> \param[in] sendbuf Data to send to root
2638 : !> \param[out] recvbuf Received data (on root)
2639 : !> \param[in] recvcounts Sizes of data received from processes
2640 : !> \param[in] displs Offsets of data received from processes
2641 : !> \param[in] root Process which gathers the data
2642 : !> \param[in] comm Message passing environment identifier
2643 : !> \par Data length
2644 : !> Data can have different lengths
2645 : !> \par Offsets
2646 : !> Offsets start at 0
2647 : !> \par MPI mapping
2648 : !> mpi_gather
2649 : ! **************************************************************************************************
2650 0 : SUBROUTINE mp_igatherv_${nametype1}$v(sendbuf, sendcount, recvbuf, recvcounts, displs, root, comm, request)
2651 : ${type1}$, DIMENSION(:), INTENT(IN) :: sendbuf
2652 : ${type1}$, DIMENSION(:), INTENT(OUT) :: recvbuf
2653 : INTEGER, DIMENSION(:), CONTIGUOUS, INTENT(IN) :: recvcounts, displs
2654 : INTEGER, INTENT(IN) :: sendcount, root
2655 : CLASS(mp_comm_type), INTENT(IN) :: comm
2656 : TYPE(mp_request_type), INTENT(OUT) :: request
2657 :
2658 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_igatherv_${nametype1}$v'
2659 :
2660 : INTEGER :: handle
2661 : #if defined(__parallel)
2662 : INTEGER :: ierr
2663 : #endif
2664 :
2665 0 : CALL mp_timeset(routineN, handle)
2666 :
2667 : #if defined(__parallel)
2668 0 : CPASSERT(IS_CONTIGUOUS(sendbuf) .OR. SIZE(sendbuf) == 0)
2669 0 : CPASSERT(IS_CONTIGUOUS(recvbuf) .OR. SIZE(recvbuf) == 0)
2670 0 : CPASSERT(IS_CONTIGUOUS(recvcounts) .OR. SIZE(recvcounts) == 0)
2671 0 : CPASSERT(IS_CONTIGUOUS(displs) .OR. SIZE(displs) == 0)
2672 : CALL mpi_igatherv(sendbuf, sendcount, ${mpi_type1}$, &
2673 : recvbuf, recvcounts, displs, ${mpi_type1}$, &
2674 0 : root, comm%handle, request%handle, ierr)
2675 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_gatherv @ "//routineN)
2676 : CALL add_perf(perf_id=24, &
2677 : count=1, &
2678 0 : msg_size=sendcount*${bytes1}$)
2679 : #else
2680 : MARK_USED(sendcount)
2681 : MARK_USED(recvcounts)
2682 : MARK_USED(root)
2683 : MARK_USED(comm)
2684 : recvbuf(1 + displs(1):1 + displs(1) + recvcounts(1)) = sendbuf(1:sendcount)
2685 : request = mp_request_null
2686 : #endif
2687 0 : CALL mp_timestop(handle)
2688 0 : END SUBROUTINE mp_igatherv_${nametype1}$v
2689 :
2690 : ! **************************************************************************************************
2691 : !> \brief Gathers a datum from all processes and all processes receive the
2692 : !> same data
2693 : !> \param[in] msgout Datum to send
2694 : !> \param[out] msgin Received data
2695 : !> \param[in] comm Message passing environment identifier
2696 : !> \par Data size
2697 : !> All processes send equal-sized data
2698 : !> \par MPI mapping
2699 : !> mpi_allgather
2700 : ! **************************************************************************************************
2701 190368 : SUBROUTINE mp_allgather_${nametype1}$ (msgout, msgin, comm)
2702 : ${type1}$, INTENT(IN) :: msgout
2703 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msgin(:)
2704 : CLASS(mp_comm_type), INTENT(IN) :: comm
2705 :
2706 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgather_${nametype1}$'
2707 :
2708 : INTEGER :: handle
2709 : #if defined(__parallel)
2710 : INTEGER :: ierr, rcount, scount
2711 : #endif
2712 :
2713 190368 : CALL mp_timeset(routineN, handle)
2714 :
2715 : #if defined(__parallel)
2716 190368 : scount = 1
2717 190368 : rcount = 1
2718 : CALL MPI_ALLGATHER(msgout, scount, ${mpi_type1}$, &
2719 : msgin, rcount, ${mpi_type1}$, &
2720 190368 : comm%handle, ierr)
2721 190368 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2722 : #else
2723 : MARK_USED(comm)
2724 : msgin = msgout
2725 : #endif
2726 190368 : CALL mp_timestop(handle)
2727 190368 : END SUBROUTINE mp_allgather_${nametype1}$
2728 :
2729 : ! **************************************************************************************************
2730 : !> \brief Gathers a datum from all processes and all processes receive the
2731 : !> same data
2732 : !> \param[in] msgout Datum to send
2733 : !> \param[out] msgin Received data
2734 : !> \param[in] comm Message passing environment identifier
2735 : !> \par Data size
2736 : !> All processes send equal-sized data
2737 : !> \par MPI mapping
2738 : !> mpi_allgather
2739 : ! **************************************************************************************************
2740 0 : SUBROUTINE mp_allgather_${nametype1}$2(msgout, msgin, comm)
2741 : ${type1}$, INTENT(IN) :: msgout
2742 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msgin(:, :)
2743 : CLASS(mp_comm_type), INTENT(IN) :: comm
2744 :
2745 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgather_${nametype1}$2'
2746 :
2747 : INTEGER :: handle
2748 : #if defined(__parallel)
2749 : INTEGER :: ierr, rcount, scount
2750 : #endif
2751 :
2752 0 : CALL mp_timeset(routineN, handle)
2753 :
2754 : #if defined(__parallel)
2755 0 : scount = 1
2756 0 : rcount = 1
2757 : CALL MPI_ALLGATHER(msgout, scount, ${mpi_type1}$, &
2758 : msgin, rcount, ${mpi_type1}$, &
2759 0 : comm%handle, ierr)
2760 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2761 : #else
2762 : MARK_USED(comm)
2763 : msgin = msgout
2764 : #endif
2765 0 : CALL mp_timestop(handle)
2766 0 : END SUBROUTINE mp_allgather_${nametype1}$2
2767 :
2768 : ! **************************************************************************************************
2769 : !> \brief Gathers a datum from all processes and all processes receive the
2770 : !> same data
2771 : !> \param[in] msgout Datum to send
2772 : !> \param[out] msgin Received data
2773 : !> \param[in] comm Message passing environment identifier
2774 : !> \par Data size
2775 : !> All processes send equal-sized data
2776 : !> \par MPI mapping
2777 : !> mpi_allgather
2778 : ! **************************************************************************************************
2779 0 : SUBROUTINE mp_iallgather_${nametype1}$ (msgout, msgin, comm, request)
2780 : ${type1}$, INTENT(IN) :: msgout
2781 : ${type1}$, INTENT(OUT) :: msgin(:)
2782 : CLASS(mp_comm_type), INTENT(IN) :: comm
2783 : TYPE(mp_request_type), INTENT(OUT) :: request
2784 :
2785 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgather_${nametype1}$'
2786 :
2787 : INTEGER :: handle
2788 : #if defined(__parallel)
2789 : INTEGER :: ierr, rcount, scount
2790 : #endif
2791 :
2792 0 : CALL mp_timeset(routineN, handle)
2793 :
2794 : #if defined(__parallel)
2795 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
2796 0 : scount = 1
2797 0 : rcount = 1
2798 : CALL MPI_IALLGATHER(msgout, scount, ${mpi_type1}$, &
2799 : msgin, rcount, ${mpi_type1}$, &
2800 0 : comm%handle, request%handle, ierr)
2801 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2802 : #else
2803 : MARK_USED(comm)
2804 : msgin = msgout
2805 : request = mp_request_null
2806 : #endif
2807 0 : CALL mp_timestop(handle)
2808 0 : END SUBROUTINE mp_iallgather_${nametype1}$
2809 :
2810 : ! **************************************************************************************************
2811 : !> \brief Gathers vector data from all processes and all processes receive the
2812 : !> same data
2813 : !> \param[in] msgout Rank-1 data to send
2814 : !> \param[out] msgin Received data
2815 : !> \param[in] comm Message passing environment identifier
2816 : !> \par Data size
2817 : !> All processes send equal-sized data
2818 : !> \par Ranks
2819 : !> The last rank counts the processes
2820 : !> \par MPI mapping
2821 : !> mpi_allgather
2822 : ! **************************************************************************************************
2823 43184 : SUBROUTINE mp_allgather_${nametype1}$12(msgout, msgin, comm)
2824 : ${type1}$, INTENT(IN), CONTIGUOUS :: msgout(:)
2825 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msgin(:, :)
2826 : CLASS(mp_comm_type), INTENT(IN) :: comm
2827 :
2828 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgather_${nametype1}$12'
2829 :
2830 : INTEGER :: handle
2831 : #if defined(__parallel)
2832 : INTEGER :: ierr, rcount, scount
2833 : #endif
2834 :
2835 43184 : CALL mp_timeset(routineN, handle)
2836 :
2837 : #if defined(__parallel)
2838 43184 : scount = SIZE(msgout(:))
2839 43184 : rcount = scount
2840 : CALL MPI_ALLGATHER(msgout, scount, ${mpi_type1}$, &
2841 : msgin, rcount, ${mpi_type1}$, &
2842 43184 : comm%handle, ierr)
2843 43184 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2844 : #else
2845 : MARK_USED(comm)
2846 : msgin(:, 1) = msgout(:)
2847 : #endif
2848 43184 : CALL mp_timestop(handle)
2849 43184 : END SUBROUTINE mp_allgather_${nametype1}$12
2850 :
2851 : ! **************************************************************************************************
2852 : !> \brief Gathers matrix data from all processes and all processes receive the
2853 : !> same data
2854 : !> \param[in] msgout Rank-2 data to send
2855 : !> \param msgin ...
2856 : !> \param comm ...
2857 : !> \note see mp_allgather_${nametype1}$12
2858 : ! **************************************************************************************************
2859 84130 : SUBROUTINE mp_allgather_${nametype1}$23(msgout, msgin, comm)
2860 : ${type1}$, INTENT(IN), CONTIGUOUS :: msgout(:, :)
2861 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msgin(:, :, :)
2862 : CLASS(mp_comm_type), INTENT(IN) :: comm
2863 :
2864 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgather_${nametype1}$23'
2865 :
2866 : INTEGER :: handle
2867 : #if defined(__parallel)
2868 : INTEGER :: ierr, rcount, scount
2869 : #endif
2870 :
2871 84130 : CALL mp_timeset(routineN, handle)
2872 :
2873 : #if defined(__parallel)
2874 252390 : scount = SIZE(msgout(:, :))
2875 84130 : rcount = scount
2876 : CALL MPI_ALLGATHER(msgout, scount, ${mpi_type1}$, &
2877 : msgin, rcount, ${mpi_type1}$, &
2878 84130 : comm%handle, ierr)
2879 84130 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2880 : #else
2881 : MARK_USED(comm)
2882 : msgin(:, :, 1) = msgout(:, :)
2883 : #endif
2884 84130 : CALL mp_timestop(handle)
2885 84130 : END SUBROUTINE mp_allgather_${nametype1}$23
2886 :
2887 : ! **************************************************************************************************
2888 : !> \brief Gathers rank-3 data from all processes and all processes receive the
2889 : !> same data
2890 : !> \param[in] msgout Rank-3 data to send
2891 : !> \param msgin ...
2892 : !> \param comm ...
2893 : !> \note see mp_allgather_${nametype1}$12
2894 : ! **************************************************************************************************
2895 442 : SUBROUTINE mp_allgather_${nametype1}$34(msgout, msgin, comm)
2896 : ${type1}$, INTENT(IN), CONTIGUOUS :: msgout(:, :, :)
2897 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msgin(:, :, :, :)
2898 : CLASS(mp_comm_type), INTENT(IN) :: comm
2899 :
2900 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgather_${nametype1}$34'
2901 :
2902 : INTEGER :: handle
2903 : #if defined(__parallel)
2904 : INTEGER :: ierr, rcount, scount
2905 : #endif
2906 :
2907 442 : CALL mp_timeset(routineN, handle)
2908 :
2909 : #if defined(__parallel)
2910 1768 : scount = SIZE(msgout(:, :, :))
2911 442 : rcount = scount
2912 : CALL MPI_ALLGATHER(msgout, scount, ${mpi_type1}$, &
2913 : msgin, rcount, ${mpi_type1}$, &
2914 442 : comm%handle, ierr)
2915 442 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2916 : #else
2917 : MARK_USED(comm)
2918 : msgin(:, :, :, 1) = msgout(:, :, :)
2919 : #endif
2920 442 : CALL mp_timestop(handle)
2921 442 : END SUBROUTINE mp_allgather_${nametype1}$34
2922 :
2923 : ! **************************************************************************************************
2924 : !> \brief Gathers rank-2 data from all processes and all processes receive the
2925 : !> same data
2926 : !> \param[in] msgout Rank-2 data to send
2927 : !> \param msgin ...
2928 : !> \param comm ...
2929 : !> \note see mp_allgather_${nametype1}$12
2930 : ! **************************************************************************************************
2931 0 : SUBROUTINE mp_allgather_${nametype1}$22(msgout, msgin, comm)
2932 : ${type1}$, INTENT(IN), CONTIGUOUS :: msgout(:, :)
2933 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msgin(:, :)
2934 : CLASS(mp_comm_type), INTENT(IN) :: comm
2935 :
2936 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgather_${nametype1}$22'
2937 :
2938 : INTEGER :: handle
2939 : #if defined(__parallel)
2940 : INTEGER :: ierr, rcount, scount
2941 : #endif
2942 :
2943 0 : CALL mp_timeset(routineN, handle)
2944 :
2945 : #if defined(__parallel)
2946 0 : scount = SIZE(msgout(:, :))
2947 0 : rcount = scount
2948 : CALL MPI_ALLGATHER(msgout, scount, ${mpi_type1}$, &
2949 : msgin, rcount, ${mpi_type1}$, &
2950 0 : comm%handle, ierr)
2951 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgather @ "//routineN)
2952 : #else
2953 : MARK_USED(comm)
2954 : msgin(:, :) = msgout(:, :)
2955 : #endif
2956 0 : CALL mp_timestop(handle)
2957 0 : END SUBROUTINE mp_allgather_${nametype1}$22
2958 :
2959 : ! **************************************************************************************************
2960 : !> \brief Gathers rank-1 data from all processes and all processes receive the
2961 : !> same data
2962 : !> \param[in] msgout Rank-1 data to send
2963 : !> \param msgin ...
2964 : !> \param comm ...
2965 : !> \param request ...
2966 : !> \note see mp_allgather_${nametype1}$11
2967 : ! **************************************************************************************************
2968 0 : SUBROUTINE mp_iallgather_${nametype1}$11(msgout, msgin, comm, request)
2969 : ${type1}$, INTENT(IN) :: msgout(:)
2970 : ${type1}$, INTENT(OUT) :: msgin(:)
2971 : CLASS(mp_comm_type), INTENT(IN) :: comm
2972 : TYPE(mp_request_type), INTENT(OUT) :: request
2973 :
2974 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgather_${nametype1}$11'
2975 :
2976 : INTEGER :: handle
2977 : #if defined(__parallel)
2978 : INTEGER :: ierr, rcount, scount
2979 : #endif
2980 :
2981 0 : CALL mp_timeset(routineN, handle)
2982 :
2983 : #if defined(__parallel)
2984 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
2985 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
2986 0 : scount = SIZE(msgout(:))
2987 0 : rcount = scount
2988 : CALL MPI_IALLGATHER(msgout, scount, ${mpi_type1}$, &
2989 : msgin, rcount, ${mpi_type1}$, &
2990 0 : comm%handle, request%handle, ierr)
2991 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgather @ "//routineN)
2992 : #else
2993 : MARK_USED(comm)
2994 : msgin = msgout
2995 : request = mp_request_null
2996 : #endif
2997 0 : CALL mp_timestop(handle)
2998 0 : END SUBROUTINE mp_iallgather_${nametype1}$11
2999 :
3000 : ! **************************************************************************************************
3001 : !> \brief Gathers rank-2 data from all processes and all processes receive the
3002 : !> same data
3003 : !> \param[in] msgout Rank-2 data to send
3004 : !> \param msgin ...
3005 : !> \param comm ...
3006 : !> \param request ...
3007 : !> \note see mp_allgather_${nametype1}$12
3008 : ! **************************************************************************************************
3009 0 : SUBROUTINE mp_iallgather_${nametype1}$13(msgout, msgin, comm, request)
3010 : ${type1}$, INTENT(IN) :: msgout(:)
3011 : ${type1}$, INTENT(OUT) :: msgin(:, :, :)
3012 : CLASS(mp_comm_type), INTENT(IN) :: comm
3013 : TYPE(mp_request_type), INTENT(OUT) :: request
3014 :
3015 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgather_${nametype1}$13'
3016 :
3017 : INTEGER :: handle
3018 : #if defined(__parallel)
3019 : INTEGER :: ierr, rcount, scount
3020 : #endif
3021 :
3022 0 : CALL mp_timeset(routineN, handle)
3023 :
3024 : #if defined(__parallel)
3025 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3026 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3027 :
3028 0 : scount = SIZE(msgout(:))
3029 0 : rcount = scount
3030 : CALL MPI_IALLGATHER(msgout, scount, ${mpi_type1}$, &
3031 : msgin, rcount, ${mpi_type1}$, &
3032 0 : comm%handle, request%handle, ierr)
3033 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgather @ "//routineN)
3034 : #else
3035 : MARK_USED(comm)
3036 : msgin(:, 1, 1) = msgout(:)
3037 : request = mp_request_null
3038 : #endif
3039 0 : CALL mp_timestop(handle)
3040 0 : END SUBROUTINE mp_iallgather_${nametype1}$13
3041 :
3042 : ! **************************************************************************************************
3043 : !> \brief Gathers rank-2 data from all processes and all processes receive the
3044 : !> same data
3045 : !> \param[in] msgout Rank-2 data to send
3046 : !> \param msgin ...
3047 : !> \param comm ...
3048 : !> \param request ...
3049 : !> \note see mp_allgather_${nametype1}$12
3050 : ! **************************************************************************************************
3051 0 : SUBROUTINE mp_iallgather_${nametype1}$22(msgout, msgin, comm, request)
3052 : ${type1}$, INTENT(IN) :: msgout(:, :)
3053 : ${type1}$, INTENT(OUT) :: msgin(:, :)
3054 : CLASS(mp_comm_type), INTENT(IN) :: comm
3055 : TYPE(mp_request_type), INTENT(OUT) :: request
3056 :
3057 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgather_${nametype1}$22'
3058 :
3059 : INTEGER :: handle
3060 : #if defined(__parallel)
3061 : INTEGER :: ierr, rcount, scount
3062 : #endif
3063 :
3064 0 : CALL mp_timeset(routineN, handle)
3065 :
3066 : #if defined(__parallel)
3067 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3068 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3069 :
3070 0 : scount = SIZE(msgout(:, :))
3071 0 : rcount = scount
3072 : CALL MPI_IALLGATHER(msgout, scount, ${mpi_type1}$, &
3073 : msgin, rcount, ${mpi_type1}$, &
3074 0 : comm%handle, request%handle, ierr)
3075 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgather @ "//routineN)
3076 : #else
3077 : MARK_USED(comm)
3078 : msgin(:, :) = msgout(:, :)
3079 : request = mp_request_null
3080 : #endif
3081 0 : CALL mp_timestop(handle)
3082 0 : END SUBROUTINE mp_iallgather_${nametype1}$22
3083 :
3084 : ! **************************************************************************************************
3085 : !> \brief Gathers rank-2 data from all processes and all processes receive the
3086 : !> same data
3087 : !> \param[in] msgout Rank-2 data to send
3088 : !> \param msgin ...
3089 : !> \param comm ...
3090 : !> \param request ...
3091 : !> \note see mp_allgather_${nametype1}$12
3092 : ! **************************************************************************************************
3093 0 : SUBROUTINE mp_iallgather_${nametype1}$24(msgout, msgin, comm, request)
3094 : ${type1}$, INTENT(IN) :: msgout(:, :)
3095 : ${type1}$, INTENT(OUT) :: msgin(:, :, :, :)
3096 : CLASS(mp_comm_type), INTENT(IN) :: comm
3097 : TYPE(mp_request_type), INTENT(OUT) :: request
3098 :
3099 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgather_${nametype1}$24'
3100 :
3101 : INTEGER :: handle
3102 : #if defined(__parallel)
3103 : INTEGER :: ierr, rcount, scount
3104 : #endif
3105 :
3106 0 : CALL mp_timeset(routineN, handle)
3107 :
3108 : #if defined(__parallel)
3109 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3110 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3111 :
3112 0 : scount = SIZE(msgout(:, :))
3113 0 : rcount = scount
3114 : CALL MPI_IALLGATHER(msgout, scount, ${mpi_type1}$, &
3115 : msgin, rcount, ${mpi_type1}$, &
3116 0 : comm%handle, request%handle, ierr)
3117 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgather @ "//routineN)
3118 : #else
3119 : MARK_USED(comm)
3120 : msgin(:, :, 1, 1) = msgout(:, :)
3121 : request = mp_request_null
3122 : #endif
3123 0 : CALL mp_timestop(handle)
3124 0 : END SUBROUTINE mp_iallgather_${nametype1}$24
3125 :
3126 : ! **************************************************************************************************
3127 : !> \brief Gathers rank-3 data from all processes and all processes receive the
3128 : !> same data
3129 : !> \param[in] msgout Rank-3 data to send
3130 : !> \param msgin ...
3131 : !> \param comm ...
3132 : !> \param request ...
3133 : !> \note see mp_allgather_${nametype1}$12
3134 : ! **************************************************************************************************
3135 0 : SUBROUTINE mp_iallgather_${nametype1}$33(msgout, msgin, comm, request)
3136 : ${type1}$, INTENT(IN) :: msgout(:, :, :)
3137 : ${type1}$, INTENT(OUT) :: msgin(:, :, :)
3138 : CLASS(mp_comm_type), INTENT(IN) :: comm
3139 : TYPE(mp_request_type), INTENT(OUT) :: request
3140 :
3141 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgather_${nametype1}$33'
3142 :
3143 : INTEGER :: handle
3144 : #if defined(__parallel)
3145 : INTEGER :: ierr, rcount, scount
3146 : #endif
3147 :
3148 0 : CALL mp_timeset(routineN, handle)
3149 :
3150 : #if defined(__parallel)
3151 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3152 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3153 :
3154 0 : scount = SIZE(msgout(:, :, :))
3155 0 : rcount = scount
3156 : CALL MPI_IALLGATHER(msgout, scount, ${mpi_type1}$, &
3157 : msgin, rcount, ${mpi_type1}$, &
3158 0 : comm%handle, request%handle, ierr)
3159 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgather @ "//routineN)
3160 : #else
3161 : MARK_USED(comm)
3162 : msgin(:, :, :) = msgout(:, :, :)
3163 : request = mp_request_null
3164 : #endif
3165 0 : CALL mp_timestop(handle)
3166 0 : END SUBROUTINE mp_iallgather_${nametype1}$33
3167 :
3168 : ! **************************************************************************************************
3169 : !> \brief Gathers vector data from all processes and all processes receive the
3170 : !> same data
3171 : !> \param[in] msgout Rank-1 data to send
3172 : !> \param[out] msgin Received data
3173 : !> \param[in] rcount Size of sent data for every process
3174 : !> \param[in] rdispl Offset of sent data for every process
3175 : !> \param[in] comm Message passing environment identifier
3176 : !> \par Data size
3177 : !> Processes can send different-sized data
3178 : !> \par Ranks
3179 : !> The last rank counts the processes
3180 : !> \par Offsets
3181 : !> Offsets are from 0
3182 : !> \par MPI mapping
3183 : !> mpi_allgather
3184 : ! **************************************************************************************************
3185 295999 : SUBROUTINE mp_allgatherv_${nametype1}$v(msgout, msgin, rcount, rdispl, comm)
3186 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgout(:)
3187 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgin(:)
3188 : INTEGER, CONTIGUOUS, INTENT(IN) :: rcount(:), rdispl(:)
3189 : CLASS(mp_comm_type), INTENT(IN) :: comm
3190 :
3191 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgatherv_${nametype1}$v'
3192 :
3193 : INTEGER :: handle
3194 : #if defined(__parallel)
3195 : INTEGER :: ierr, scount
3196 : #endif
3197 :
3198 295999 : CALL mp_timeset(routineN, handle)
3199 :
3200 : #if defined(__parallel)
3201 295999 : scount = SIZE(msgout)
3202 : CALL MPI_ALLGATHERV(msgout, scount, ${mpi_type1}$, msgin, rcount, &
3203 295999 : rdispl, ${mpi_type1}$, comm%handle, ierr)
3204 295999 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgatherv @ "//routineN)
3205 : #else
3206 : MARK_USED(rcount)
3207 : MARK_USED(rdispl)
3208 : MARK_USED(comm)
3209 : msgin = msgout
3210 : #endif
3211 295999 : CALL mp_timestop(handle)
3212 295999 : END SUBROUTINE mp_allgatherv_${nametype1}$v
3213 :
3214 : ! **************************************************************************************************
3215 : !> \brief Gathers vector data from all processes and all processes receive the
3216 : !> same data
3217 : !> \param[in] msgout Rank-1 data to send
3218 : !> \param[out] msgin Received data
3219 : !> \param[in] rcount Size of sent data for every process
3220 : !> \param[in] rdispl Offset of sent data for every process
3221 : !> \param[in] comm Message passing environment identifier
3222 : !> \par Data size
3223 : !> Processes can send different-sized data
3224 : !> \par Ranks
3225 : !> The last rank counts the processes
3226 : !> \par Offsets
3227 : !> Offsets are from 0
3228 : !> \par MPI mapping
3229 : !> mpi_allgather
3230 : ! **************************************************************************************************
3231 28436 : SUBROUTINE mp_allgatherv_${nametype1}$m2(msgout, msgin, rcount, rdispl, comm)
3232 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgout(:, :)
3233 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgin(:, :)
3234 : INTEGER, CONTIGUOUS, INTENT(IN) :: rcount(:), rdispl(:)
3235 : CLASS(mp_comm_type), INTENT(IN) :: comm
3236 :
3237 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allgatherv_${nametype1}$v'
3238 :
3239 : INTEGER :: handle
3240 : #if defined(__parallel)
3241 : INTEGER :: ierr, scount
3242 : #endif
3243 :
3244 28436 : CALL mp_timeset(routineN, handle)
3245 :
3246 : #if defined(__parallel)
3247 85308 : scount = SIZE(msgout)
3248 : CALL MPI_ALLGATHERV(msgout, scount, ${mpi_type1}$, msgin, rcount, &
3249 28436 : rdispl, ${mpi_type1}$, comm%handle, ierr)
3250 28436 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_allgatherv @ "//routineN)
3251 : #else
3252 : MARK_USED(rcount)
3253 : MARK_USED(rdispl)
3254 : MARK_USED(comm)
3255 : msgin = msgout
3256 : #endif
3257 28436 : CALL mp_timestop(handle)
3258 28436 : END SUBROUTINE mp_allgatherv_${nametype1}$m2
3259 :
3260 : ! **************************************************************************************************
3261 : !> \brief Gathers vector data from all processes and all processes receive the
3262 : !> same data
3263 : !> \param[in] msgout Rank-1 data to send
3264 : !> \param[out] msgin Received data
3265 : !> \param[in] rcount Size of sent data for every process
3266 : !> \param[in] rdispl Offset of sent data for every process
3267 : !> \param[in] comm Message passing environment identifier
3268 : !> \par Data size
3269 : !> Processes can send different-sized data
3270 : !> \par Ranks
3271 : !> The last rank counts the processes
3272 : !> \par Offsets
3273 : !> Offsets are from 0
3274 : !> \par MPI mapping
3275 : !> mpi_allgather
3276 : ! **************************************************************************************************
3277 0 : SUBROUTINE mp_iallgatherv_${nametype1}$v(msgout, msgin, rcount, rdispl, comm, request)
3278 : ${type1}$, INTENT(IN) :: msgout(:)
3279 : ${type1}$, INTENT(OUT) :: msgin(:)
3280 : INTEGER, CONTIGUOUS, INTENT(IN) :: rcount(:), rdispl(:)
3281 : CLASS(mp_comm_type), INTENT(IN) :: comm
3282 : TYPE(mp_request_type), INTENT(OUT) :: request
3283 :
3284 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgatherv_${nametype1}$v'
3285 :
3286 : INTEGER :: handle
3287 : #if defined(__parallel)
3288 : INTEGER :: ierr, scount, rsize
3289 : #endif
3290 :
3291 0 : CALL mp_timeset(routineN, handle)
3292 :
3293 : #if defined(__parallel)
3294 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3295 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3296 0 : CPASSERT(IS_CONTIGUOUS(rcount) .OR. SIZE(rcount) == 0)
3297 0 : CPASSERT(IS_CONTIGUOUS(rdispl) .OR. SIZE(rdispl) == 0)
3298 :
3299 0 : scount = SIZE(msgout)
3300 0 : rsize = SIZE(rcount)
3301 : CALL mp_iallgatherv_${nametype1}$v_internal(msgout, scount, msgin, rsize, rcount, &
3302 0 : rdispl, comm, request, ierr)
3303 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgatherv @ "//routineN)
3304 : #else
3305 : MARK_USED(rcount)
3306 : MARK_USED(rdispl)
3307 : MARK_USED(comm)
3308 : msgin = msgout
3309 : request = mp_request_null
3310 : #endif
3311 0 : CALL mp_timestop(handle)
3312 0 : END SUBROUTINE mp_iallgatherv_${nametype1}$v
3313 :
3314 : ! **************************************************************************************************
3315 : !> \brief Gathers vector data from all processes and all processes receive the
3316 : !> same data
3317 : !> \param[in] msgout Rank-1 data to send
3318 : !> \param[out] msgin Received data
3319 : !> \param[in] rcount Size of sent data for every process
3320 : !> \param[in] rdispl Offset of sent data for every process
3321 : !> \param[in] comm Message passing environment identifier
3322 : !> \par Data size
3323 : !> Processes can send different-sized data
3324 : !> \par Ranks
3325 : !> The last rank counts the processes
3326 : !> \par Offsets
3327 : !> Offsets are from 0
3328 : !> \par MPI mapping
3329 : !> mpi_allgather
3330 : ! **************************************************************************************************
3331 0 : SUBROUTINE mp_iallgatherv_${nametype1}$v2(msgout, msgin, rcount, rdispl, comm, request)
3332 : ${type1}$, INTENT(IN) :: msgout(:)
3333 : ${type1}$, INTENT(OUT) :: msgin(:)
3334 : INTEGER, INTENT(IN) :: rcount(:, :), rdispl(:, :)
3335 : CLASS(mp_comm_type), INTENT(IN) :: comm
3336 : TYPE(mp_request_type), INTENT(OUT) :: request
3337 :
3338 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_iallgatherv_${nametype1}$v2'
3339 :
3340 : INTEGER :: handle
3341 : #if defined(__parallel)
3342 : INTEGER :: ierr, scount, rsize
3343 : #endif
3344 :
3345 0 : CALL mp_timeset(routineN, handle)
3346 :
3347 : #if defined(__parallel)
3348 0 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3349 0 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3350 0 : CPASSERT(IS_CONTIGUOUS(rcount) .OR. SIZE(rcount) == 0)
3351 0 : CPASSERT(IS_CONTIGUOUS(rdispl) .OR. SIZE(rdispl) == 0)
3352 :
3353 0 : scount = SIZE(msgout)
3354 0 : rsize = SIZE(rcount)
3355 : CALL mp_iallgatherv_${nametype1}$v_internal(msgout, scount, msgin, rsize, rcount, &
3356 0 : rdispl, comm, request, ierr)
3357 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_iallgatherv @ "//routineN)
3358 : #else
3359 : MARK_USED(rcount)
3360 : MARK_USED(rdispl)
3361 : MARK_USED(comm)
3362 : msgin = msgout
3363 : request = mp_request_null
3364 : #endif
3365 0 : CALL mp_timestop(handle)
3366 0 : END SUBROUTINE mp_iallgatherv_${nametype1}$v2
3367 :
3368 : ! **************************************************************************************************
3369 : !> \brief wrapper needed to deal with interfaces as present in openmpi 1.8.1
3370 : !> the issue is with the rank of rcount and rdispl
3371 : !> \param count ...
3372 : !> \param array_of_requests ...
3373 : !> \param array_of_statuses ...
3374 : !> \param ierr ...
3375 : !> \author Alfio Lazzaro
3376 : ! **************************************************************************************************
3377 : #if defined(__parallel)
3378 0 : SUBROUTINE mp_iallgatherv_${nametype1}$v_internal(msgout, scount, msgin, rsize, rcount, rdispl, comm, request, ierr)
3379 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgout(:)
3380 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgin(:)
3381 : INTEGER, INTENT(IN) :: rsize
3382 : INTEGER, INTENT(IN) :: rcount(rsize), rdispl(rsize), scount
3383 : CLASS(mp_comm_type), INTENT(IN) :: comm
3384 : TYPE(mp_request_type), INTENT(OUT) :: request
3385 : INTEGER, INTENT(INOUT) :: ierr
3386 :
3387 : CALL MPI_IALLGATHERV(msgout, scount, ${mpi_type1}$, msgin, rcount, &
3388 0 : rdispl, ${mpi_type1}$, comm%handle, request%handle, ierr)
3389 :
3390 0 : END SUBROUTINE mp_iallgatherv_${nametype1}$v_internal
3391 : #endif
3392 :
3393 : ! **************************************************************************************************
3394 : !> \brief Sums a vector and partitions the result among processes
3395 : !> \param[in] msgout Data to sum
3396 : !> \param[out] msgin Received portion of summed data
3397 : !> \param[in] rcount Partition sizes of the summed data for
3398 : !> every process
3399 : !> \param[in] comm Message passing environment identifier
3400 : ! **************************************************************************************************
3401 924 : SUBROUTINE mp_sum_scatter_${nametype1}$v(msgout, msgin, rcount, comm)
3402 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgout(:, :)
3403 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgin(:)
3404 : INTEGER, CONTIGUOUS, INTENT(IN) :: rcount(:)
3405 : CLASS(mp_comm_type), INTENT(IN) :: comm
3406 :
3407 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sum_scatter_${nametype1}$v'
3408 :
3409 : INTEGER :: handle
3410 : #if defined(__parallel)
3411 : INTEGER :: ierr
3412 : #endif
3413 :
3414 924 : CALL mp_timeset(routineN, handle)
3415 :
3416 : #if defined(__parallel)
3417 : CALL MPI_REDUCE_SCATTER(msgout, msgin, rcount, ${mpi_type1}$, MPI_SUM, &
3418 924 : comm%handle, ierr)
3419 924 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_reduce_scatter @ "//routineN)
3420 :
3421 : CALL add_perf(perf_id=3, count=1, &
3422 924 : msg_size=rcount(1)*2*${bytes1}$)
3423 : #else
3424 : MARK_USED(rcount)
3425 : MARK_USED(comm)
3426 : msgin = msgout(:, 1)
3427 : #endif
3428 924 : CALL mp_timestop(handle)
3429 924 : END SUBROUTINE mp_sum_scatter_${nametype1}$v
3430 :
3431 : ! **************************************************************************************************
3432 : !> \brief Sends and receives vector data
3433 : !> \param[in] msgin Data to send
3434 : !> \param[in] dest Process to send data to
3435 : !> \param[out] msgout Received data
3436 : !> \param[in] source Process from which to receive
3437 : !> \param[in] comm Message passing environment identifier
3438 : !> \param[in] tag Send and recv tag (default: 0)
3439 : ! **************************************************************************************************
3440 512 : SUBROUTINE mp_sendrecv_${nametype1}$ (msgin, dest, msgout, source, comm, tag)
3441 : ${type1}$, INTENT(IN) :: msgin
3442 : INTEGER, INTENT(IN) :: dest
3443 : ${type1}$, INTENT(OUT) :: msgout
3444 : INTEGER, INTENT(IN) :: source
3445 : CLASS(mp_comm_type), INTENT(IN) :: comm
3446 : INTEGER, INTENT(IN), OPTIONAL :: tag
3447 :
3448 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sendrecv_${nametype1}$'
3449 :
3450 : INTEGER :: handle
3451 : #if defined(__parallel)
3452 : INTEGER :: ierr, msglen_in, msglen_out, &
3453 : recv_tag, send_tag
3454 : #endif
3455 :
3456 512 : CALL mp_timeset(routineN, handle)
3457 :
3458 : #if defined(__parallel)
3459 512 : msglen_in = 1
3460 512 : msglen_out = 1
3461 512 : send_tag = 0 ! cannot think of something better here, this might be dangerous
3462 512 : recv_tag = 0 ! cannot think of something better here, this might be dangerous
3463 512 : IF (PRESENT(tag)) THEN
3464 512 : send_tag = tag
3465 512 : recv_tag = tag
3466 : END IF
3467 : CALL mpi_sendrecv(msgin, msglen_in, ${mpi_type1}$, dest, send_tag, msgout, &
3468 512 : msglen_out, ${mpi_type1}$, source, recv_tag, comm%handle, MPI_STATUS_IGNORE, ierr)
3469 512 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_sendrecv @ "//routineN)
3470 : CALL add_perf(perf_id=7, count=1, &
3471 512 : msg_size=(msglen_in + msglen_out)*${bytes1}$/2)
3472 : #else
3473 : MARK_USED(dest)
3474 : MARK_USED(source)
3475 : MARK_USED(comm)
3476 : MARK_USED(tag)
3477 : msgout = msgin
3478 : #endif
3479 512 : CALL mp_timestop(handle)
3480 512 : END SUBROUTINE mp_sendrecv_${nametype1}$
3481 :
3482 : ! **************************************************************************************************
3483 : !> \brief Sends and receives vector data
3484 : !> \param[in] msgin Data to send
3485 : !> \param[in] dest Process to send data to
3486 : !> \param[out] msgout Received data
3487 : !> \param[in] source Process from which to receive
3488 : !> \param[in] comm Message passing environment identifier
3489 : !> \param[in] tag Send and recv tag (default: 0)
3490 : ! **************************************************************************************************
3491 1188470 : SUBROUTINE mp_sendrecv_${nametype1}$v(msgin, dest, msgout, source, comm, tag)
3492 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgin(:)
3493 : INTEGER, INTENT(IN) :: dest
3494 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgout(:)
3495 : INTEGER, INTENT(IN) :: source
3496 : CLASS(mp_comm_type), INTENT(IN) :: comm
3497 : INTEGER, INTENT(IN), OPTIONAL :: tag
3498 :
3499 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sendrecv_${nametype1}$v'
3500 :
3501 : INTEGER :: handle
3502 : #if defined(__parallel)
3503 : INTEGER :: ierr, msglen_in, msglen_out, &
3504 : recv_tag, send_tag
3505 : #endif
3506 :
3507 1188470 : CALL mp_timeset(routineN, handle)
3508 :
3509 : #if defined(__parallel)
3510 1188470 : msglen_in = SIZE(msgin)
3511 1188470 : msglen_out = SIZE(msgout)
3512 1188470 : send_tag = 0 ! cannot think of something better here, this might be dangerous
3513 1188470 : recv_tag = 0 ! cannot think of something better here, this might be dangerous
3514 1188470 : IF (PRESENT(tag)) THEN
3515 1188344 : send_tag = tag
3516 1188344 : recv_tag = tag
3517 : END IF
3518 : CALL mpi_sendrecv(msgin, msglen_in, ${mpi_type1}$, dest, send_tag, msgout, &
3519 1188470 : msglen_out, ${mpi_type1}$, source, recv_tag, comm%handle, MPI_STATUS_IGNORE, ierr)
3520 1188470 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_sendrecv @ "//routineN)
3521 : CALL add_perf(perf_id=7, count=1, &
3522 1188470 : msg_size=(msglen_in + msglen_out)*${bytes1}$/2)
3523 : #else
3524 : MARK_USED(dest)
3525 : MARK_USED(source)
3526 : MARK_USED(comm)
3527 : MARK_USED(tag)
3528 : msgout = msgin
3529 : #endif
3530 1188470 : CALL mp_timestop(handle)
3531 1188470 : END SUBROUTINE mp_sendrecv_${nametype1}$v
3532 :
3533 : ! **************************************************************************************************
3534 : !> \brief Sends and receives matrix data
3535 : !> \param msgin ...
3536 : !> \param dest ...
3537 : !> \param msgout ...
3538 : !> \param source ...
3539 : !> \param comm ...
3540 : !> \param tag ...
3541 : !> \note see mp_sendrecv_${nametype1}$v
3542 : ! **************************************************************************************************
3543 152680 : SUBROUTINE mp_sendrecv_${nametype1}$m2(msgin, dest, msgout, source, comm, tag)
3544 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgin(:, :)
3545 : INTEGER, INTENT(IN) :: dest
3546 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgout(:, :)
3547 : INTEGER, INTENT(IN) :: source
3548 : CLASS(mp_comm_type), INTENT(IN) :: comm
3549 : INTEGER, INTENT(IN), OPTIONAL :: tag
3550 :
3551 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sendrecv_${nametype1}$m2'
3552 :
3553 : INTEGER :: handle
3554 : #if defined(__parallel)
3555 : INTEGER :: ierr, msglen_in, msglen_out, &
3556 : recv_tag, send_tag
3557 : #endif
3558 :
3559 152680 : CALL mp_timeset(routineN, handle)
3560 :
3561 : #if defined(__parallel)
3562 152680 : msglen_in = SIZE(msgin, 1)*SIZE(msgin, 2)
3563 152680 : msglen_out = SIZE(msgout, 1)*SIZE(msgout, 2)
3564 152680 : send_tag = 0 ! cannot think of something better here, this might be dangerous
3565 152680 : recv_tag = 0 ! cannot think of something better here, this might be dangerous
3566 152680 : IF (PRESENT(tag)) THEN
3567 646 : send_tag = tag
3568 646 : recv_tag = tag
3569 : END IF
3570 : CALL mpi_sendrecv(msgin, msglen_in, ${mpi_type1}$, dest, send_tag, msgout, &
3571 152680 : msglen_out, ${mpi_type1}$, source, recv_tag, comm%handle, MPI_STATUS_IGNORE, ierr)
3572 152680 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_sendrecv @ "//routineN)
3573 : CALL add_perf(perf_id=7, count=1, &
3574 152680 : msg_size=(msglen_in + msglen_out)*${bytes1}$/2)
3575 : #else
3576 : MARK_USED(dest)
3577 : MARK_USED(source)
3578 : MARK_USED(comm)
3579 : MARK_USED(tag)
3580 : msgout = msgin
3581 : #endif
3582 152680 : CALL mp_timestop(handle)
3583 152680 : END SUBROUTINE mp_sendrecv_${nametype1}$m2
3584 :
3585 : ! **************************************************************************************************
3586 : !> \brief Sends and receives rank-3 data
3587 : !> \param msgin ...
3588 : !> \param dest ...
3589 : !> \param msgout ...
3590 : !> \param source ...
3591 : !> \param comm ...
3592 : !> \note see mp_sendrecv_${nametype1}$v
3593 : ! **************************************************************************************************
3594 82608 : SUBROUTINE mp_sendrecv_${nametype1}$m3(msgin, dest, msgout, source, comm, tag)
3595 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgin(:, :, :)
3596 : INTEGER, INTENT(IN) :: dest
3597 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgout(:, :, :)
3598 : INTEGER, INTENT(IN) :: source
3599 : CLASS(mp_comm_type), INTENT(IN) :: comm
3600 : INTEGER, INTENT(IN), OPTIONAL :: tag
3601 :
3602 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sendrecv_${nametype1}$m3'
3603 :
3604 : INTEGER :: handle
3605 : #if defined(__parallel)
3606 : INTEGER :: ierr, msglen_in, msglen_out, &
3607 : recv_tag, send_tag
3608 : #endif
3609 :
3610 82608 : CALL mp_timeset(routineN, handle)
3611 :
3612 : #if defined(__parallel)
3613 330432 : msglen_in = SIZE(msgin)
3614 330432 : msglen_out = SIZE(msgout)
3615 82608 : send_tag = 0 ! cannot think of something better here, this might be dangerous
3616 82608 : recv_tag = 0 ! cannot think of something better here, this might be dangerous
3617 82608 : IF (PRESENT(tag)) THEN
3618 484 : send_tag = tag
3619 484 : recv_tag = tag
3620 : END IF
3621 : CALL mpi_sendrecv(msgin, msglen_in, ${mpi_type1}$, dest, send_tag, msgout, &
3622 82608 : msglen_out, ${mpi_type1}$, source, recv_tag, comm%handle, MPI_STATUS_IGNORE, ierr)
3623 82608 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_sendrecv @ "//routineN)
3624 : CALL add_perf(perf_id=7, count=1, &
3625 82608 : msg_size=(msglen_in + msglen_out)*${bytes1}$/2)
3626 : #else
3627 : MARK_USED(dest)
3628 : MARK_USED(source)
3629 : MARK_USED(comm)
3630 : MARK_USED(tag)
3631 : msgout = msgin
3632 : #endif
3633 82608 : CALL mp_timestop(handle)
3634 82608 : END SUBROUTINE mp_sendrecv_${nametype1}$m3
3635 :
3636 : ! **************************************************************************************************
3637 : !> \brief Sends and receives rank-4 data
3638 : !> \param msgin ...
3639 : !> \param dest ...
3640 : !> \param msgout ...
3641 : !> \param source ...
3642 : !> \param comm ...
3643 : !> \note see mp_sendrecv_${nametype1}$v
3644 : ! **************************************************************************************************
3645 0 : SUBROUTINE mp_sendrecv_${nametype1}$m4(msgin, dest, msgout, source, comm, tag)
3646 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msgin(:, :, :, :)
3647 : INTEGER, INTENT(IN) :: dest
3648 : ${type1}$, CONTIGUOUS, INTENT(OUT) :: msgout(:, :, :, :)
3649 : INTEGER, INTENT(IN) :: source
3650 : CLASS(mp_comm_type), INTENT(IN) :: comm
3651 : INTEGER, INTENT(IN), OPTIONAL :: tag
3652 :
3653 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_sendrecv_${nametype1}$m4'
3654 :
3655 : INTEGER :: handle
3656 : #if defined(__parallel)
3657 : INTEGER :: ierr, msglen_in, msglen_out, &
3658 : recv_tag, send_tag
3659 : #endif
3660 :
3661 0 : CALL mp_timeset(routineN, handle)
3662 :
3663 : #if defined(__parallel)
3664 0 : msglen_in = SIZE(msgin)
3665 0 : msglen_out = SIZE(msgout)
3666 0 : send_tag = 0 ! cannot think of something better here, this might be dangerous
3667 0 : recv_tag = 0 ! cannot think of something better here, this might be dangerous
3668 0 : IF (PRESENT(tag)) THEN
3669 0 : send_tag = tag
3670 0 : recv_tag = tag
3671 : END IF
3672 : CALL mpi_sendrecv(msgin, msglen_in, ${mpi_type1}$, dest, send_tag, msgout, &
3673 0 : msglen_out, ${mpi_type1}$, source, recv_tag, comm%handle, MPI_STATUS_IGNORE, ierr)
3674 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_sendrecv @ "//routineN)
3675 : CALL add_perf(perf_id=7, count=1, &
3676 0 : msg_size=(msglen_in + msglen_out)*${bytes1}$/2)
3677 : #else
3678 : MARK_USED(dest)
3679 : MARK_USED(source)
3680 : MARK_USED(comm)
3681 : MARK_USED(tag)
3682 : msgout = msgin
3683 : #endif
3684 0 : CALL mp_timestop(handle)
3685 0 : END SUBROUTINE mp_sendrecv_${nametype1}$m4
3686 :
3687 : ! **************************************************************************************************
3688 : !> \brief Non-blocking send and receive of a scalar
3689 : !> \param[in] msgin Scalar data to send
3690 : !> \param[in] dest Which process to send to
3691 : !> \param[out] msgout Receive data into this pointer
3692 : !> \param[in] source Process to receive from
3693 : !> \param[in] comm Message passing environment identifier
3694 : !> \param[out] send_request Request handle for the send
3695 : !> \param[out] recv_request Request handle for the receive
3696 : !> \param[in] tag (optional) tag to differentiate requests
3697 : !> \par Implementation
3698 : !> Calls mpi_isend and mpi_irecv.
3699 : !> \par History
3700 : !> 02.2005 created [Alfio Lazzaro]
3701 : ! **************************************************************************************************
3702 0 : SUBROUTINE mp_isendrecv_${nametype1}$ (msgin, dest, msgout, source, comm, send_request, &
3703 : recv_request, tag)
3704 : ${type1}$, INTENT(IN) :: msgin
3705 : INTEGER, INTENT(IN) :: dest
3706 : ${type1}$, INTENT(INOUT) :: msgout
3707 : INTEGER, INTENT(IN) :: source
3708 : CLASS(mp_comm_type), INTENT(IN) :: comm
3709 : TYPE(mp_request_type), INTENT(out) :: send_request, recv_request
3710 : INTEGER, INTENT(in), OPTIONAL :: tag
3711 :
3712 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isendrecv_${nametype1}$'
3713 :
3714 : INTEGER :: handle
3715 : #if defined(__parallel)
3716 : INTEGER :: ierr, my_tag
3717 : #endif
3718 :
3719 0 : CALL mp_timeset(routineN, handle)
3720 :
3721 : #if defined(__parallel)
3722 0 : my_tag = 0
3723 0 : IF (PRESENT(tag)) my_tag = tag
3724 :
3725 : CALL mpi_irecv(msgout, 1, ${mpi_type1}$, source, my_tag, &
3726 0 : comm%handle, recv_request%handle, ierr)
3727 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_irecv @ "//routineN)
3728 :
3729 : CALL mpi_isend(msgin, 1, ${mpi_type1}$, dest, my_tag, &
3730 0 : comm%handle, send_request%handle, ierr)
3731 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_isend @ "//routineN)
3732 :
3733 0 : CALL add_perf(perf_id=8, count=1, msg_size=2*${bytes1}$)
3734 : #else
3735 : MARK_USED(dest)
3736 : MARK_USED(source)
3737 : MARK_USED(comm)
3738 : MARK_USED(tag)
3739 : send_request = mp_request_null
3740 : recv_request = mp_request_null
3741 : msgout = msgin
3742 : #endif
3743 0 : CALL mp_timestop(handle)
3744 0 : END SUBROUTINE mp_isendrecv_${nametype1}$
3745 :
3746 : ! **************************************************************************************************
3747 : !> \brief Non-blocking send and receive of a vector
3748 : !> \param[in] msgin Vector data to send
3749 : !> \param[in] dest Which process to send to
3750 : !> \param[out] msgout Receive data into this pointer
3751 : !> \param[in] source Process to receive from
3752 : !> \param[in] comm Message passing environment identifier
3753 : !> \param[out] send_request Request handle for the send
3754 : !> \param[out] recv_request Request handle for the receive
3755 : !> \param[in] tag (optional) tag to differentiate requests
3756 : !> \par Implementation
3757 : !> Calls mpi_isend and mpi_irecv.
3758 : !> \par History
3759 : !> 11.2004 created [Joost VandeVondele]
3760 : !> \note
3761 : !> arrays can be pointers or assumed shape, but they must be contiguous!
3762 : ! **************************************************************************************************
3763 1196044 : SUBROUTINE mp_isendrecv_${nametype1}$v(msgin, dest, msgout, source, comm, send_request, &
3764 : recv_request, tag)
3765 : ${type1}$, DIMENSION(:), INTENT(IN) :: msgin
3766 : INTEGER, INTENT(IN) :: dest
3767 : ${type1}$, DIMENSION(:), INTENT(INOUT) :: msgout
3768 : INTEGER, INTENT(IN) :: source
3769 : CLASS(mp_comm_type), INTENT(IN) :: comm
3770 : TYPE(mp_request_type), INTENT(out) :: send_request, recv_request
3771 : INTEGER, INTENT(in), OPTIONAL :: tag
3772 :
3773 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isendrecv_${nametype1}$v'
3774 :
3775 : INTEGER :: handle
3776 : #if defined(__parallel)
3777 : INTEGER :: ierr, msglen, my_tag
3778 : ${type1}$ :: foo
3779 : #endif
3780 :
3781 1196044 : CALL mp_timeset(routineN, handle)
3782 :
3783 : #if defined(__parallel)
3784 1196044 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
3785 1196044 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3786 :
3787 1196044 : my_tag = 0
3788 1196044 : IF (PRESENT(tag)) my_tag = tag
3789 :
3790 1196044 : msglen = SIZE(msgout, 1)
3791 1196044 : IF (msglen > 0) THEN
3792 : CALL mpi_irecv(msgout(1), msglen, ${mpi_type1}$, source, my_tag, &
3793 1196044 : comm%handle, recv_request%handle, ierr)
3794 : ELSE
3795 : CALL mpi_irecv(foo, msglen, ${mpi_type1}$, source, my_tag, &
3796 0 : comm%handle, recv_request%handle, ierr)
3797 : END IF
3798 1196044 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_irecv @ "//routineN)
3799 :
3800 1196044 : msglen = SIZE(msgin, 1)
3801 1196044 : IF (msglen > 0) THEN
3802 : CALL mpi_isend(msgin(1), msglen, ${mpi_type1}$, dest, my_tag, &
3803 1196044 : comm%handle, send_request%handle, ierr)
3804 : ELSE
3805 : CALL mpi_isend(foo, msglen, ${mpi_type1}$, dest, my_tag, &
3806 0 : comm%handle, send_request%handle, ierr)
3807 : END IF
3808 1196044 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_isend @ "//routineN)
3809 :
3810 1196044 : msglen = (msglen + SIZE(msgout, 1) + 1)/2
3811 1196044 : CALL add_perf(perf_id=8, count=1, msg_size=msglen*${bytes1}$)
3812 : #else
3813 : MARK_USED(dest)
3814 : MARK_USED(source)
3815 : MARK_USED(comm)
3816 : MARK_USED(tag)
3817 : send_request = mp_request_null
3818 : recv_request = mp_request_null
3819 : msgout = msgin
3820 : #endif
3821 1196044 : CALL mp_timestop(handle)
3822 1196044 : END SUBROUTINE mp_isendrecv_${nametype1}$v
3823 :
3824 : ! **************************************************************************************************
3825 : !> \brief Non-blocking send of vector data
3826 : !> \param msgin ...
3827 : !> \param dest ...
3828 : !> \param comm ...
3829 : !> \param request ...
3830 : !> \param tag ...
3831 : !> \par History
3832 : !> 08.2003 created [f&j]
3833 : !> \note see mp_isendrecv_${nametype1}$v
3834 : !> \note
3835 : !> arrays can be pointers or assumed shape, but they must be contiguous!
3836 : ! **************************************************************************************************
3837 845595 : SUBROUTINE mp_isend_${nametype1}$v(msgin, dest, comm, request, tag)
3838 : ${type1}$, DIMENSION(:), INTENT(IN) :: msgin
3839 : INTEGER, INTENT(IN) :: dest
3840 : CLASS(mp_comm_type), INTENT(IN) :: comm
3841 : TYPE(mp_request_type), INTENT(out) :: request
3842 : INTEGER, INTENT(in), OPTIONAL :: tag
3843 :
3844 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isend_${nametype1}$v'
3845 :
3846 : INTEGER :: handle, ierr
3847 : #if defined(__parallel)
3848 : INTEGER :: msglen, my_tag
3849 : ${type1}$ :: foo(1)
3850 : #endif
3851 :
3852 845595 : CALL mp_timeset(routineN, handle)
3853 :
3854 : #if defined(__parallel)
3855 845595 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3856 845595 : my_tag = 0
3857 845595 : IF (PRESENT(tag)) my_tag = tag
3858 :
3859 845595 : msglen = SIZE(msgin)
3860 845595 : IF (msglen > 0) THEN
3861 : CALL mpi_isend(msgin(1), msglen, ${mpi_type1}$, dest, my_tag, &
3862 845337 : comm%handle, request%handle, ierr)
3863 : ELSE
3864 : CALL mpi_isend(foo, msglen, ${mpi_type1}$, dest, my_tag, &
3865 258 : comm%handle, request%handle, ierr)
3866 : END IF
3867 845595 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_isend @ "//routineN)
3868 :
3869 845595 : CALL add_perf(perf_id=11, count=1, msg_size=msglen*${bytes1}$)
3870 : #else
3871 : MARK_USED(msgin)
3872 : MARK_USED(dest)
3873 : MARK_USED(comm)
3874 : MARK_USED(request)
3875 : MARK_USED(tag)
3876 : ierr = 1
3877 : request = mp_request_null
3878 : CALL mp_stop(ierr, "mp_isend called in non parallel case")
3879 : #endif
3880 845595 : CALL mp_timestop(handle)
3881 845595 : END SUBROUTINE mp_isend_${nametype1}$v
3882 :
3883 : ! **************************************************************************************************
3884 : !> \brief Non-blocking send of matrix data
3885 : !> \param msgin ...
3886 : !> \param dest ...
3887 : !> \param comm ...
3888 : !> \param request ...
3889 : !> \param tag ...
3890 : !> \par History
3891 : !> 2009-11-25 [UB] Made type-generic for templates
3892 : !> \author fawzi
3893 : !> \note see mp_isendrecv_${nametype1}$v
3894 : !> \note see mp_isend_${nametype1}$v
3895 : !> \note
3896 : !> arrays can be pointers or assumed shape, but they must be contiguous!
3897 : ! **************************************************************************************************
3898 762707 : SUBROUTINE mp_isend_${nametype1}$m2(msgin, dest, comm, request, tag)
3899 : ${type1}$, DIMENSION(:, :), INTENT(IN) :: msgin
3900 : INTEGER, INTENT(IN) :: dest
3901 : CLASS(mp_comm_type), INTENT(IN) :: comm
3902 : TYPE(mp_request_type), INTENT(out) :: request
3903 : INTEGER, INTENT(in), OPTIONAL :: tag
3904 :
3905 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isend_${nametype1}$m2'
3906 :
3907 : INTEGER :: handle, ierr
3908 : #if defined(__parallel)
3909 : INTEGER :: msglen, my_tag
3910 : ${type1}$ :: foo(1)
3911 : #endif
3912 :
3913 762707 : CALL mp_timeset(routineN, handle)
3914 :
3915 : #if defined(__parallel)
3916 2288121 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3917 :
3918 762707 : my_tag = 0
3919 762707 : IF (PRESENT(tag)) my_tag = tag
3920 :
3921 762707 : msglen = SIZE(msgin, 1)*SIZE(msgin, 2)
3922 762707 : IF (msglen > 0) THEN
3923 : CALL mpi_isend(msgin(1, 1), msglen, ${mpi_type1}$, dest, my_tag, &
3924 762707 : comm%handle, request%handle, ierr)
3925 : ELSE
3926 : CALL mpi_isend(foo, msglen, ${mpi_type1}$, dest, my_tag, &
3927 0 : comm%handle, request%handle, ierr)
3928 : END IF
3929 762707 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_isend @ "//routineN)
3930 :
3931 762707 : CALL add_perf(perf_id=11, count=1, msg_size=msglen*${bytes1}$)
3932 : #else
3933 : MARK_USED(msgin)
3934 : MARK_USED(dest)
3935 : MARK_USED(comm)
3936 : MARK_USED(request)
3937 : MARK_USED(tag)
3938 : ierr = 1
3939 : request = mp_request_null
3940 : CALL mp_stop(ierr, "mp_isend called in non parallel case")
3941 : #endif
3942 762707 : CALL mp_timestop(handle)
3943 762707 : END SUBROUTINE mp_isend_${nametype1}$m2
3944 :
3945 : ! **************************************************************************************************
3946 : !> \brief Non-blocking send of rank-3 data
3947 : !> \param msgin ...
3948 : !> \param dest ...
3949 : !> \param comm ...
3950 : !> \param request ...
3951 : !> \param tag ...
3952 : !> \par History
3953 : !> 9.2008 added _rm3 subroutine [Iain Bethune]
3954 : !> (c) The Numerical Algorithms Group (NAG) Ltd, 2008 on behalf of the HECToR project
3955 : !> 2009-11-25 [UB] Made type-generic for templates
3956 : !> \author fawzi
3957 : !> \note see mp_isendrecv_${nametype1}$v
3958 : !> \note see mp_isend_${nametype1}$v
3959 : !> \note
3960 : !> arrays can be pointers or assumed shape, but they must be contiguous!
3961 : ! **************************************************************************************************
3962 9294 : SUBROUTINE mp_isend_${nametype1}$m3(msgin, dest, comm, request, tag)
3963 : ${type1}$, DIMENSION(:, :, :), INTENT(IN) :: msgin
3964 : INTEGER, INTENT(IN) :: dest
3965 : CLASS(mp_comm_type), INTENT(IN) :: comm
3966 : TYPE(mp_request_type), INTENT(out) :: request
3967 : INTEGER, INTENT(in), OPTIONAL :: tag
3968 :
3969 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isend_${nametype1}$m3'
3970 :
3971 : INTEGER :: handle, ierr
3972 : #if defined(__parallel)
3973 : INTEGER :: msglen, my_tag
3974 : ${type1}$ :: foo(1)
3975 : #endif
3976 :
3977 9294 : CALL mp_timeset(routineN, handle)
3978 :
3979 : #if defined(__parallel)
3980 37176 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
3981 :
3982 9294 : my_tag = 0
3983 9294 : IF (PRESENT(tag)) my_tag = tag
3984 :
3985 9294 : msglen = SIZE(msgin, 1)*SIZE(msgin, 2)*SIZE(msgin, 3)
3986 9294 : IF (msglen > 0) THEN
3987 : CALL mpi_isend(msgin(1, 1, 1), msglen, ${mpi_type1}$, dest, my_tag, &
3988 9294 : comm%handle, request%handle, ierr)
3989 : ELSE
3990 : CALL mpi_isend(foo, msglen, ${mpi_type1}$, dest, my_tag, &
3991 0 : comm%handle, request%handle, ierr)
3992 : END IF
3993 9294 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_isend @ "//routineN)
3994 :
3995 9294 : CALL add_perf(perf_id=11, count=1, msg_size=msglen*${bytes1}$)
3996 : #else
3997 : MARK_USED(msgin)
3998 : MARK_USED(dest)
3999 : MARK_USED(comm)
4000 : MARK_USED(request)
4001 : MARK_USED(tag)
4002 : ierr = 1
4003 : request = mp_request_null
4004 : CALL mp_stop(ierr, "mp_isend called in non parallel case")
4005 : #endif
4006 9294 : CALL mp_timestop(handle)
4007 9294 : END SUBROUTINE mp_isend_${nametype1}$m3
4008 :
4009 : ! **************************************************************************************************
4010 : !> \brief Non-blocking send of rank-4 data
4011 : !> \param msgin the input message
4012 : !> \param dest the destination processor
4013 : !> \param comm the communicator object
4014 : !> \param request the communication request id
4015 : !> \param tag the message tag
4016 : !> \par History
4017 : !> 2.2016 added _${nametype1}$m4 subroutine [Nico Holmberg]
4018 : !> \author fawzi
4019 : !> \note see mp_isend_${nametype1}$v
4020 : !> \note
4021 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4022 : ! **************************************************************************************************
4023 56 : SUBROUTINE mp_isend_${nametype1}$m4(msgin, dest, comm, request, tag)
4024 : ${type1}$, DIMENSION(:, :, :, :), INTENT(IN) :: msgin
4025 : INTEGER, INTENT(IN) :: dest
4026 : CLASS(mp_comm_type), INTENT(IN) :: comm
4027 : TYPE(mp_request_type), INTENT(out) :: request
4028 : INTEGER, INTENT(in), OPTIONAL :: tag
4029 :
4030 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_isend_${nametype1}$m4'
4031 :
4032 : INTEGER :: handle, ierr
4033 : #if defined(__parallel)
4034 : INTEGER :: msglen, my_tag
4035 : ${type1}$ :: foo(1)
4036 : #endif
4037 :
4038 56 : CALL mp_timeset(routineN, handle)
4039 :
4040 : #if defined(__parallel)
4041 280 : CPASSERT(IS_CONTIGUOUS(msgin) .OR. SIZE(msgin) == 0)
4042 :
4043 56 : my_tag = 0
4044 56 : IF (PRESENT(tag)) my_tag = tag
4045 :
4046 56 : msglen = SIZE(msgin, 1)*SIZE(msgin, 2)*SIZE(msgin, 3)*SIZE(msgin, 4)
4047 56 : IF (msglen > 0) THEN
4048 : CALL mpi_isend(msgin(1, 1, 1, 1), msglen, ${mpi_type1}$, dest, my_tag, &
4049 56 : comm%handle, request%handle, ierr)
4050 : ELSE
4051 : CALL mpi_isend(foo, msglen, ${mpi_type1}$, dest, my_tag, &
4052 0 : comm%handle, request%handle, ierr)
4053 : END IF
4054 56 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_isend @ "//routineN)
4055 :
4056 56 : CALL add_perf(perf_id=11, count=1, msg_size=msglen*${bytes1}$)
4057 : #else
4058 : MARK_USED(msgin)
4059 : MARK_USED(dest)
4060 : MARK_USED(comm)
4061 : MARK_USED(request)
4062 : MARK_USED(tag)
4063 : ierr = 1
4064 : request = mp_request_null
4065 : CALL mp_stop(ierr, "mp_isend called in non parallel case")
4066 : #endif
4067 56 : CALL mp_timestop(handle)
4068 56 : END SUBROUTINE mp_isend_${nametype1}$m4
4069 :
4070 : ! **************************************************************************************************
4071 : !> \brief Non-blocking receive of vector data
4072 : !> \param msgout ...
4073 : !> \param source ...
4074 : !> \param comm ...
4075 : !> \param request ...
4076 : !> \param tag ...
4077 : !> \par History
4078 : !> 08.2003 created [f&j]
4079 : !> 2009-11-25 [UB] Made type-generic for templates
4080 : !> \note see mp_isendrecv_${nametype1}$v
4081 : !> \note
4082 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4083 : ! **************************************************************************************************
4084 845795 : SUBROUTINE mp_irecv_${nametype1}$v(msgout, source, comm, request, tag)
4085 : ${type1}$, DIMENSION(:), INTENT(INOUT) :: msgout
4086 : INTEGER, INTENT(IN) :: source
4087 : CLASS(mp_comm_type), INTENT(IN) :: comm
4088 : TYPE(mp_request_type), INTENT(out) :: request
4089 : INTEGER, INTENT(in), OPTIONAL :: tag
4090 :
4091 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_irecv_${nametype1}$v'
4092 :
4093 : INTEGER :: handle
4094 : #if defined(__parallel)
4095 : INTEGER :: ierr, msglen, my_tag
4096 : ${type1}$ :: foo(1)
4097 : #endif
4098 :
4099 845795 : CALL mp_timeset(routineN, handle)
4100 :
4101 : #if defined(__parallel)
4102 845795 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
4103 :
4104 845795 : my_tag = 0
4105 845795 : IF (PRESENT(tag)) my_tag = tag
4106 :
4107 845795 : msglen = SIZE(msgout)
4108 845795 : IF (msglen > 0) THEN
4109 : CALL mpi_irecv(msgout(1), msglen, ${mpi_type1}$, source, my_tag, &
4110 845408 : comm%handle, request%handle, ierr)
4111 : ELSE
4112 : CALL mpi_irecv(foo, msglen, ${mpi_type1}$, source, my_tag, &
4113 387 : comm%handle, request%handle, ierr)
4114 : END IF
4115 845795 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_irecv @ "//routineN)
4116 :
4117 845795 : CALL add_perf(perf_id=12, count=1, msg_size=msglen*${bytes1}$)
4118 : #else
4119 : CPABORT("mp_irecv called in non parallel case")
4120 : MARK_USED(msgout)
4121 : MARK_USED(source)
4122 : MARK_USED(comm)
4123 : MARK_USED(tag)
4124 : request = mp_request_null
4125 : #endif
4126 845795 : CALL mp_timestop(handle)
4127 845795 : END SUBROUTINE mp_irecv_${nametype1}$v
4128 :
4129 : ! **************************************************************************************************
4130 : !> \brief Non-blocking receive of matrix data
4131 : !> \param msgout ...
4132 : !> \param source ...
4133 : !> \param comm ...
4134 : !> \param request ...
4135 : !> \param tag ...
4136 : !> \par History
4137 : !> 2009-11-25 [UB] Made type-generic for templates
4138 : !> \author fawzi
4139 : !> \note see mp_isendrecv_${nametype1}$v
4140 : !> \note see mp_irecv_${nametype1}$v
4141 : !> \note
4142 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4143 : ! **************************************************************************************************
4144 762679 : SUBROUTINE mp_irecv_${nametype1}$m2(msgout, source, comm, request, tag)
4145 : ${type1}$, DIMENSION(:, :), INTENT(INOUT) :: msgout
4146 : INTEGER, INTENT(IN) :: source
4147 : CLASS(mp_comm_type), INTENT(IN) :: comm
4148 : TYPE(mp_request_type), INTENT(out) :: request
4149 : INTEGER, INTENT(in), OPTIONAL :: tag
4150 :
4151 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_irecv_${nametype1}$m2'
4152 :
4153 : INTEGER :: handle
4154 : #if defined(__parallel)
4155 : INTEGER :: ierr, msglen, my_tag
4156 : ${type1}$ :: foo(1)
4157 : #endif
4158 :
4159 762679 : CALL mp_timeset(routineN, handle)
4160 :
4161 : #if defined(__parallel)
4162 2288037 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
4163 :
4164 762679 : my_tag = 0
4165 762679 : IF (PRESENT(tag)) my_tag = tag
4166 :
4167 762679 : msglen = SIZE(msgout, 1)*SIZE(msgout, 2)
4168 762679 : IF (msglen > 0) THEN
4169 : CALL mpi_irecv(msgout(1, 1), msglen, ${mpi_type1}$, source, my_tag, &
4170 762679 : comm%handle, request%handle, ierr)
4171 : ELSE
4172 : CALL mpi_irecv(foo, msglen, ${mpi_type1}$, source, my_tag, &
4173 0 : comm%handle, request%handle, ierr)
4174 : END IF
4175 762679 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_irecv @ "//routineN)
4176 :
4177 762679 : CALL add_perf(perf_id=12, count=1, msg_size=msglen*${bytes1}$)
4178 : #else
4179 : MARK_USED(msgout)
4180 : MARK_USED(source)
4181 : MARK_USED(comm)
4182 : MARK_USED(tag)
4183 : request = mp_request_null
4184 : CPABORT("mp_irecv called in non parallel case")
4185 : #endif
4186 762679 : CALL mp_timestop(handle)
4187 762679 : END SUBROUTINE mp_irecv_${nametype1}$m2
4188 :
4189 : ! **************************************************************************************************
4190 : !> \brief Non-blocking send of rank-3 data
4191 : !> \param msgout ...
4192 : !> \param source ...
4193 : !> \param comm ...
4194 : !> \param request ...
4195 : !> \param tag ...
4196 : !> \par History
4197 : !> 9.2008 added _rm3 subroutine [Iain Bethune] (c) The Numerical Algorithms Group (NAG) Ltd, 2008 on behalf of the HECToR project
4198 : !> 2009-11-25 [UB] Made type-generic for templates
4199 : !> \author fawzi
4200 : !> \note see mp_isendrecv_${nametype1}$v
4201 : !> \note see mp_irecv_${nametype1}$v
4202 : !> \note
4203 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4204 : ! **************************************************************************************************
4205 9294 : SUBROUTINE mp_irecv_${nametype1}$m3(msgout, source, comm, request, tag)
4206 : ${type1}$, DIMENSION(:, :, :), INTENT(INOUT) :: msgout
4207 : INTEGER, INTENT(IN) :: source
4208 : CLASS(mp_comm_type), INTENT(IN) :: comm
4209 : TYPE(mp_request_type), INTENT(out) :: request
4210 : INTEGER, INTENT(in), OPTIONAL :: tag
4211 :
4212 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_irecv_${nametype1}$m3'
4213 :
4214 : INTEGER :: handle
4215 : #if defined(__parallel)
4216 : INTEGER :: ierr, msglen, my_tag
4217 : ${type1}$ :: foo(1)
4218 : #endif
4219 :
4220 9294 : CALL mp_timeset(routineN, handle)
4221 :
4222 : #if defined(__parallel)
4223 37176 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
4224 :
4225 9294 : my_tag = 0
4226 9294 : IF (PRESENT(tag)) my_tag = tag
4227 :
4228 9294 : msglen = SIZE(msgout, 1)*SIZE(msgout, 2)*SIZE(msgout, 3)
4229 9294 : IF (msglen > 0) THEN
4230 : CALL mpi_irecv(msgout(1, 1, 1), msglen, ${mpi_type1}$, source, my_tag, &
4231 9294 : comm%handle, request%handle, ierr)
4232 : ELSE
4233 : CALL mpi_irecv(foo, msglen, ${mpi_type1}$, source, my_tag, &
4234 0 : comm%handle, request%handle, ierr)
4235 : END IF
4236 9294 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_ircv @ "//routineN)
4237 :
4238 9294 : CALL add_perf(perf_id=12, count=1, msg_size=msglen*${bytes1}$)
4239 : #else
4240 : MARK_USED(msgout)
4241 : MARK_USED(source)
4242 : MARK_USED(comm)
4243 : MARK_USED(tag)
4244 : request = mp_request_null
4245 : CPABORT("mp_irecv called in non parallel case")
4246 : #endif
4247 9294 : CALL mp_timestop(handle)
4248 9294 : END SUBROUTINE mp_irecv_${nametype1}$m3
4249 :
4250 : ! **************************************************************************************************
4251 : !> \brief Non-blocking receive of rank-4 data
4252 : !> \param msgout the output message
4253 : !> \param source the source processor
4254 : !> \param comm the communicator object
4255 : !> \param request the communication request id
4256 : !> \param tag the message tag
4257 : !> \par History
4258 : !> 2.2016 added _${nametype1}$m4 subroutine [Nico Holmberg]
4259 : !> \author fawzi
4260 : !> \note see mp_irecv_${nametype1}$v
4261 : !> \note
4262 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4263 : ! **************************************************************************************************
4264 56 : SUBROUTINE mp_irecv_${nametype1}$m4(msgout, source, comm, request, tag)
4265 : ${type1}$, DIMENSION(:, :, :, :), INTENT(INOUT) :: msgout
4266 : INTEGER, INTENT(IN) :: source
4267 : CLASS(mp_comm_type), INTENT(IN) :: comm
4268 : TYPE(mp_request_type), INTENT(out) :: request
4269 : INTEGER, INTENT(in), OPTIONAL :: tag
4270 :
4271 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_irecv_${nametype1}$m4'
4272 :
4273 : INTEGER :: handle
4274 : #if defined(__parallel)
4275 : INTEGER :: ierr, msglen, my_tag
4276 : ${type1}$ :: foo(1)
4277 : #endif
4278 :
4279 56 : CALL mp_timeset(routineN, handle)
4280 :
4281 : #if defined(__parallel)
4282 280 : CPASSERT(IS_CONTIGUOUS(msgout) .OR. SIZE(msgout) == 0)
4283 :
4284 56 : my_tag = 0
4285 56 : IF (PRESENT(tag)) my_tag = tag
4286 :
4287 56 : msglen = SIZE(msgout, 1)*SIZE(msgout, 2)*SIZE(msgout, 3)*SIZE(msgout, 4)
4288 56 : IF (msglen > 0) THEN
4289 : CALL mpi_irecv(msgout(1, 1, 1, 1), msglen, ${mpi_type1}$, source, my_tag, &
4290 56 : comm%handle, request%handle, ierr)
4291 : ELSE
4292 : CALL mpi_irecv(foo, msglen, ${mpi_type1}$, source, my_tag, &
4293 0 : comm%handle, request%handle, ierr)
4294 : END IF
4295 56 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_ircv @ "//routineN)
4296 :
4297 56 : CALL add_perf(perf_id=12, count=1, msg_size=msglen*${bytes1}$)
4298 : #else
4299 : MARK_USED(msgout)
4300 : MARK_USED(source)
4301 : MARK_USED(comm)
4302 : MARK_USED(tag)
4303 : request = mp_request_null
4304 : CPABORT("mp_irecv called in non parallel case")
4305 : #endif
4306 56 : CALL mp_timestop(handle)
4307 56 : END SUBROUTINE mp_irecv_${nametype1}$m4
4308 :
4309 : ! **************************************************************************************************
4310 : !> \brief Window initialization function for vector data
4311 : !> \param base ...
4312 : !> \param comm ...
4313 : !> \param win ...
4314 : !> \par History
4315 : !> 02.2015 created [Alfio Lazzaro]
4316 : !> \note
4317 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4318 : ! **************************************************************************************************
4319 0 : SUBROUTINE mp_win_create_${nametype1}$v(base, comm, win)
4320 : ${type1}$, DIMENSION(:), INTENT(INOUT), CONTIGUOUS :: base
4321 : TYPE(mp_comm_type), INTENT(IN) :: comm
4322 : CLASS(mp_win_type), INTENT(INOUT) :: win
4323 :
4324 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_win_create_${nametype1}$v'
4325 :
4326 : INTEGER :: handle
4327 : #if defined(__parallel)
4328 : INTEGER :: ierr
4329 : INTEGER(kind=mpi_address_kind) :: len
4330 : ${type1}$ :: foo(1)
4331 : #endif
4332 :
4333 0 : CALL mp_timeset(routineN, handle)
4334 :
4335 : #if defined(__parallel)
4336 :
4337 0 : len = SIZE(base)*${bytes1}$
4338 0 : IF (len > 0) THEN
4339 0 : CALL mpi_win_create(base(1), len, ${bytes1}$, MPI_INFO_NULL, comm%handle, win%handle, ierr)
4340 : ELSE
4341 0 : CALL mpi_win_create(foo, len, ${bytes1}$, MPI_INFO_NULL, comm%handle, win%handle, ierr)
4342 : END IF
4343 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_win_create @ "//routineN)
4344 :
4345 0 : CALL add_perf(perf_id=20, count=1)
4346 : #else
4347 : MARK_USED(base)
4348 : MARK_USED(comm)
4349 : win%handle = mp_win_null_handle
4350 : #endif
4351 0 : CALL mp_timestop(handle)
4352 0 : END SUBROUTINE mp_win_create_${nametype1}$v
4353 :
4354 : ! **************************************************************************************************
4355 : !> \brief Single-sided get function for vector data
4356 : !> \param base ...
4357 : !> \param comm ...
4358 : !> \param win ...
4359 : !> \par History
4360 : !> 02.2015 created [Alfio Lazzaro]
4361 : !> \note
4362 : !> arrays can be pointers or assumed shape, but they must be contiguous!
4363 : ! **************************************************************************************************
4364 0 : SUBROUTINE mp_rget_${nametype1}$v(base, source, win, win_data, myproc, disp, request, &
4365 : origin_datatype, target_datatype)
4366 : ${type1}$, DIMENSION(:), CONTIGUOUS, INTENT(INOUT) :: base
4367 : INTEGER, INTENT(IN) :: source
4368 : CLASS(mp_win_type), INTENT(IN) :: win
4369 : ${type1}$, DIMENSION(:), INTENT(IN) :: win_data
4370 : INTEGER, INTENT(IN), OPTIONAL :: myproc, disp
4371 : TYPE(mp_request_type), INTENT(OUT) :: request
4372 : TYPE(mp_type_descriptor_type), INTENT(IN), OPTIONAL :: origin_datatype, target_datatype
4373 :
4374 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_rget_${nametype1}$v'
4375 :
4376 : INTEGER :: handle
4377 : #if defined(__parallel)
4378 : INTEGER :: ierr, len, &
4379 : origin_len, target_len
4380 : LOGICAL :: do_local_copy
4381 : INTEGER(kind=mpi_address_kind) :: disp_aint
4382 : MPI_DATA_TYPE :: handle_origin_datatype, handle_target_datatype
4383 : #endif
4384 :
4385 0 : CALL mp_timeset(routineN, handle)
4386 :
4387 : #if defined(__parallel)
4388 0 : len = SIZE(base)
4389 0 : disp_aint = 0
4390 0 : IF (PRESENT(disp)) THEN
4391 0 : disp_aint = INT(disp, KIND=mpi_address_kind)
4392 : END IF
4393 0 : handle_origin_datatype = ${mpi_type1}$
4394 0 : origin_len = len
4395 0 : IF (PRESENT(origin_datatype)) THEN
4396 0 : handle_origin_datatype = origin_datatype%type_handle
4397 0 : origin_len = 1
4398 : END IF
4399 0 : handle_target_datatype = ${mpi_type1}$
4400 0 : target_len = len
4401 0 : IF (PRESENT(target_datatype)) THEN
4402 0 : handle_target_datatype = target_datatype%type_handle
4403 0 : target_len = 1
4404 : END IF
4405 0 : IF (len > 0) THEN
4406 0 : do_local_copy = .FALSE.
4407 0 : IF (PRESENT(myproc) .AND. .NOT. PRESENT(origin_datatype) .AND. .NOT. PRESENT(target_datatype)) THEN
4408 0 : IF (myproc .EQ. source) do_local_copy = .TRUE.
4409 : END IF
4410 : IF (do_local_copy) THEN
4411 0 : !$OMP PARALLEL WORKSHARE DEFAULT(none) SHARED(base,win_data,disp_aint,len)
4412 : base(:) = win_data(disp_aint + 1:disp_aint + len)
4413 : !$OMP END PARALLEL WORKSHARE
4414 0 : request = mp_request_null
4415 0 : ierr = 0
4416 : ELSE
4417 : CALL mpi_rget(base(1), origin_len, handle_origin_datatype, source, disp_aint, &
4418 0 : target_len, handle_target_datatype, win%handle, request%handle, ierr)
4419 : END IF
4420 : ELSE
4421 0 : request = mp_request_null
4422 0 : ierr = 0
4423 : END IF
4424 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_rget @ "//routineN)
4425 :
4426 0 : CALL add_perf(perf_id=25, count=1, msg_size=SIZE(base)*${bytes1}$)
4427 : #else
4428 : MARK_USED(source)
4429 : MARK_USED(win)
4430 : MARK_USED(myproc)
4431 : MARK_USED(origin_datatype)
4432 : MARK_USED(target_datatype)
4433 :
4434 : request = mp_request_null
4435 : !
4436 : IF (PRESENT(disp)) THEN
4437 : base(:) = win_data(disp + 1:disp + SIZE(base))
4438 : ELSE
4439 : base(:) = win_data(:SIZE(base))
4440 : END IF
4441 :
4442 : #endif
4443 0 : CALL mp_timestop(handle)
4444 0 : END SUBROUTINE mp_rget_${nametype1}$v
4445 :
4446 : ! **************************************************************************************************
4447 : !> \brief ...
4448 : !> \param count ...
4449 : !> \param lengths ...
4450 : !> \param displs ...
4451 : !> \return ...
4452 : ! ***************************************************************************
4453 0 : FUNCTION mp_type_indexed_make_${nametype1}$ (count, lengths, displs) &
4454 0 : RESULT(type_descriptor)
4455 : INTEGER, INTENT(IN) :: count
4456 : INTEGER, DIMENSION(1:count), INTENT(IN), TARGET :: lengths, displs
4457 : TYPE(mp_type_descriptor_type) :: type_descriptor
4458 :
4459 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_type_indexed_make_${nametype1}$'
4460 :
4461 : INTEGER :: handle
4462 : #if defined(__parallel)
4463 : INTEGER :: ierr
4464 : #endif
4465 :
4466 0 : CALL mp_timeset(routineN, handle)
4467 :
4468 : #if defined(__parallel)
4469 : CALL mpi_type_indexed(count, lengths, displs, ${mpi_type1}$, &
4470 0 : type_descriptor%type_handle, ierr)
4471 0 : IF (ierr /= 0) &
4472 0 : CPABORT("MPI_Type_Indexed @ "//routineN)
4473 0 : CALL mpi_type_commit(type_descriptor%type_handle, ierr)
4474 0 : IF (ierr /= 0) &
4475 0 : CPABORT("MPI_Type_commit @ "//routineN)
4476 : #else
4477 : type_descriptor%type_handle = ${handle1}$
4478 : #endif
4479 0 : type_descriptor%length = count
4480 0 : NULLIFY (type_descriptor%subtype)
4481 0 : type_descriptor%vector_descriptor(1:2) = 1
4482 0 : type_descriptor%has_indexing = .TRUE.
4483 0 : type_descriptor%index_descriptor%index => lengths
4484 0 : type_descriptor%index_descriptor%chunks => displs
4485 :
4486 0 : CALL mp_timestop(handle)
4487 :
4488 0 : END FUNCTION mp_type_indexed_make_${nametype1}$
4489 :
4490 : ! **************************************************************************************************
4491 : !> \brief Allocates special parallel memory
4492 : !> \param[in] DATA pointer to integer array to allocate
4493 : !> \param[in] len number of integers to allocate
4494 : !> \param[out] stat (optional) allocation status result
4495 : !> \author UB
4496 : ! **************************************************************************************************
4497 0 : SUBROUTINE mp_allocate_${nametype1}$ (DATA, len, stat)
4498 : ${type1}$, CONTIGUOUS, DIMENSION(:), POINTER :: DATA
4499 : INTEGER, INTENT(IN) :: len
4500 : INTEGER, INTENT(OUT), OPTIONAL :: stat
4501 :
4502 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_allocate_${nametype1}$'
4503 :
4504 : INTEGER :: handle, ierr
4505 :
4506 0 : CALL mp_timeset(routineN, handle)
4507 :
4508 : #if defined(__parallel)
4509 0 : NULLIFY (DATA)
4510 0 : CALL mp_alloc_mem(DATA, len, stat=ierr)
4511 0 : IF (ierr /= 0 .AND. .NOT. PRESENT(stat)) &
4512 0 : CALL mp_stop(ierr, "mpi_alloc_mem @ "//routineN)
4513 0 : CALL add_perf(perf_id=15, count=1)
4514 : #else
4515 : ALLOCATE (DATA(len), stat=ierr)
4516 : IF (ierr /= 0 .AND. .NOT. PRESENT(stat)) &
4517 : CALL mp_stop(ierr, "ALLOCATE @ "//routineN)
4518 : #endif
4519 0 : IF (PRESENT(stat)) stat = ierr
4520 0 : CALL mp_timestop(handle)
4521 0 : END SUBROUTINE mp_allocate_${nametype1}$
4522 :
4523 : ! **************************************************************************************************
4524 : !> \brief Deallocates special parallel memory
4525 : !> \param[in] DATA pointer to special memory to deallocate
4526 : !> \param stat ...
4527 : !> \author UB
4528 : ! **************************************************************************************************
4529 0 : SUBROUTINE mp_deallocate_${nametype1}$ (DATA, stat)
4530 : ${type1}$, CONTIGUOUS, DIMENSION(:), POINTER :: DATA
4531 : INTEGER, INTENT(OUT), OPTIONAL :: stat
4532 :
4533 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_deallocate_${nametype1}$'
4534 :
4535 : INTEGER :: handle
4536 : #if defined(__parallel)
4537 : INTEGER :: ierr
4538 : #endif
4539 :
4540 0 : CALL mp_timeset(routineN, handle)
4541 :
4542 : #if defined(__parallel)
4543 0 : CALL mp_free_mem(DATA, ierr)
4544 0 : IF (PRESENT(stat)) THEN
4545 0 : stat = ierr
4546 : ELSE
4547 0 : IF (ierr /= 0) CALL mp_stop(ierr, "mpi_free_mem @ "//routineN)
4548 : END IF
4549 0 : NULLIFY (DATA)
4550 0 : CALL add_perf(perf_id=15, count=1)
4551 : #else
4552 : DEALLOCATE (DATA)
4553 : IF (PRESENT(stat)) stat = 0
4554 : #endif
4555 0 : CALL mp_timestop(handle)
4556 0 : END SUBROUTINE mp_deallocate_${nametype1}$
4557 :
4558 : ! **************************************************************************************************
4559 : !> \brief (parallel) Blocking individual file write using explicit offsets
4560 : !> (serial) Unformatted stream write
4561 : !> \param[in] fh file handle (file storage unit)
4562 : !> \param[in] offset file offset (position)
4563 : !> \param[in] msg data to be written to the file
4564 : !> \param msglen ...
4565 : !> \par MPI-I/O mapping mpi_file_write_at
4566 : !> \par STREAM-I/O mapping WRITE
4567 : !> \param[in](optional) msglen number of the elements of data
4568 : ! **************************************************************************************************
4569 0 : SUBROUTINE mp_file_write_at_${nametype1}$v(fh, offset, msg, msglen)
4570 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:)
4571 : CLASS(mp_file_type), INTENT(IN) :: fh
4572 : INTEGER, INTENT(IN), OPTIONAL :: msglen
4573 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4574 :
4575 : INTEGER :: msg_len
4576 : #if defined(__parallel)
4577 : INTEGER :: ierr
4578 : #endif
4579 :
4580 0 : msg_len = SIZE(msg)
4581 0 : IF (PRESENT(msglen)) msg_len = msglen
4582 : #if defined(__parallel)
4583 0 : CALL MPI_FILE_WRITE_AT(fh%handle, offset, msg, msg_len, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4584 0 : IF (ierr .NE. 0) &
4585 0 : CPABORT("mpi_file_write_at_${nametype1}$v @ mp_file_write_at_${nametype1}$v")
4586 : #else
4587 : WRITE (UNIT=fh%handle, POS=offset + 1) msg(1:msg_len)
4588 : #endif
4589 0 : END SUBROUTINE mp_file_write_at_${nametype1}$v
4590 :
4591 : ! **************************************************************************************************
4592 : !> \brief ...
4593 : !> \param fh ...
4594 : !> \param offset ...
4595 : !> \param msg ...
4596 : ! **************************************************************************************************
4597 0 : SUBROUTINE mp_file_write_at_${nametype1}$ (fh, offset, msg)
4598 : ${type1}$, INTENT(IN) :: msg
4599 : CLASS(mp_file_type), INTENT(IN) :: fh
4600 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4601 :
4602 : #if defined(__parallel)
4603 : INTEGER :: ierr
4604 :
4605 : ierr = 0
4606 0 : CALL MPI_FILE_WRITE_AT(fh%handle, offset, msg, 1, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4607 0 : IF (ierr .NE. 0) &
4608 0 : CPABORT("mpi_file_write_at_${nametype1}$ @ mp_file_write_at_${nametype1}$")
4609 : #else
4610 : WRITE (UNIT=fh%handle, POS=offset + 1) msg
4611 : #endif
4612 0 : END SUBROUTINE mp_file_write_at_${nametype1}$
4613 :
4614 : ! **************************************************************************************************
4615 : !> \brief (parallel) Blocking collective file write using explicit offsets
4616 : !> (serial) Unformatted stream write
4617 : !> \param fh ...
4618 : !> \param offset ...
4619 : !> \param msg ...
4620 : !> \param msglen ...
4621 : !> \par MPI-I/O mapping mpi_file_write_at_all
4622 : !> \par STREAM-I/O mapping WRITE
4623 : ! **************************************************************************************************
4624 0 : SUBROUTINE mp_file_write_at_all_${nametype1}$v(fh, offset, msg, msglen)
4625 : ${type1}$, CONTIGUOUS, INTENT(IN) :: msg(:)
4626 : CLASS(mp_file_type), INTENT(IN) :: fh
4627 : INTEGER, INTENT(IN), OPTIONAL :: msglen
4628 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4629 :
4630 : INTEGER :: msg_len
4631 : #if defined(__parallel)
4632 : INTEGER :: ierr
4633 : #endif
4634 :
4635 0 : msg_len = SIZE(msg)
4636 0 : IF (PRESENT(msglen)) msg_len = msglen
4637 : #if defined(__parallel)
4638 0 : CALL MPI_FILE_WRITE_AT_ALL(fh%handle, offset, msg, msg_len, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4639 0 : IF (ierr .NE. 0) &
4640 0 : CPABORT("mpi_file_write_at_all_${nametype1}$v @ mp_file_write_at_all_${nametype1}$v")
4641 : #else
4642 : WRITE (UNIT=fh%handle, POS=offset + 1) msg(1:msg_len)
4643 : #endif
4644 0 : END SUBROUTINE mp_file_write_at_all_${nametype1}$v
4645 :
4646 : ! **************************************************************************************************
4647 : !> \brief ...
4648 : !> \param fh ...
4649 : !> \param offset ...
4650 : !> \param msg ...
4651 : ! **************************************************************************************************
4652 0 : SUBROUTINE mp_file_write_at_all_${nametype1}$ (fh, offset, msg)
4653 : ${type1}$, INTENT(IN) :: msg
4654 : CLASS(mp_file_type), INTENT(IN) :: fh
4655 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4656 :
4657 : #if defined(__parallel)
4658 : INTEGER :: ierr
4659 :
4660 : ierr = 0
4661 0 : CALL MPI_FILE_WRITE_AT_ALL(fh%handle, offset, msg, 1, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4662 0 : IF (ierr .NE. 0) &
4663 0 : CPABORT("mpi_file_write_at_all_${nametype1}$ @ mp_file_write_at_all_${nametype1}$")
4664 : #else
4665 : WRITE (UNIT=fh%handle, POS=offset + 1) msg
4666 : #endif
4667 0 : END SUBROUTINE mp_file_write_at_all_${nametype1}$
4668 :
4669 : ! **************************************************************************************************
4670 : !> \brief (parallel) Blocking individual file read using explicit offsets
4671 : !> (serial) Unformatted stream read
4672 : !> \param[in] fh file handle (file storage unit)
4673 : !> \param[in] offset file offset (position)
4674 : !> \param[out] msg data to be read from the file
4675 : !> \param msglen ...
4676 : !> \par MPI-I/O mapping mpi_file_read_at
4677 : !> \par STREAM-I/O mapping READ
4678 : !> \param[in](optional) msglen number of elements of data
4679 : ! **************************************************************************************************
4680 0 : SUBROUTINE mp_file_read_at_${nametype1}$v(fh, offset, msg, msglen)
4681 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msg(:)
4682 : CLASS(mp_file_type), INTENT(IN) :: fh
4683 : INTEGER, INTENT(IN), OPTIONAL :: msglen
4684 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4685 :
4686 : INTEGER :: msg_len
4687 : #if defined(__parallel)
4688 : INTEGER :: ierr
4689 : #endif
4690 :
4691 0 : msg_len = SIZE(msg)
4692 0 : IF (PRESENT(msglen)) msg_len = msglen
4693 : #if defined(__parallel)
4694 0 : CALL MPI_FILE_READ_AT(fh%handle, offset, msg, msg_len, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4695 0 : IF (ierr .NE. 0) &
4696 0 : CPABORT("mpi_file_read_at_${nametype1}$v @ mp_file_read_at_${nametype1}$v")
4697 : #else
4698 : READ (UNIT=fh%handle, POS=offset + 1) msg(1:msg_len)
4699 : #endif
4700 0 : END SUBROUTINE mp_file_read_at_${nametype1}$v
4701 :
4702 : ! **************************************************************************************************
4703 : !> \brief ...
4704 : !> \param fh ...
4705 : !> \param offset ...
4706 : !> \param msg ...
4707 : ! **************************************************************************************************
4708 0 : SUBROUTINE mp_file_read_at_${nametype1}$ (fh, offset, msg)
4709 : ${type1}$, INTENT(OUT) :: msg
4710 : CLASS(mp_file_type), INTENT(IN) :: fh
4711 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4712 :
4713 : #if defined(__parallel)
4714 : INTEGER :: ierr
4715 :
4716 : ierr = 0
4717 0 : CALL MPI_FILE_READ_AT(fh%handle, offset, msg, 1, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4718 0 : IF (ierr .NE. 0) &
4719 0 : CPABORT("mpi_file_read_at_${nametype1}$ @ mp_file_read_at_${nametype1}$")
4720 : #else
4721 : READ (UNIT=fh%handle, POS=offset + 1) msg
4722 : #endif
4723 0 : END SUBROUTINE mp_file_read_at_${nametype1}$
4724 :
4725 : ! **************************************************************************************************
4726 : !> \brief (parallel) Blocking collective file read using explicit offsets
4727 : !> (serial) Unformatted stream read
4728 : !> \param fh ...
4729 : !> \param offset ...
4730 : !> \param msg ...
4731 : !> \param msglen ...
4732 : !> \par MPI-I/O mapping mpi_file_read_at_all
4733 : !> \par STREAM-I/O mapping READ
4734 : ! **************************************************************************************************
4735 0 : SUBROUTINE mp_file_read_at_all_${nametype1}$v(fh, offset, msg, msglen)
4736 : ${type1}$, INTENT(OUT), CONTIGUOUS :: msg(:)
4737 : CLASS(mp_file_type), INTENT(IN) :: fh
4738 : INTEGER, INTENT(IN), OPTIONAL :: msglen
4739 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4740 :
4741 : INTEGER :: msg_len
4742 : #if defined(__parallel)
4743 : INTEGER :: ierr
4744 : #endif
4745 :
4746 0 : msg_len = SIZE(msg)
4747 0 : IF (PRESENT(msglen)) msg_len = msglen
4748 : #if defined(__parallel)
4749 0 : CALL MPI_FILE_READ_AT_ALL(fh%handle, offset, msg, msg_len, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4750 0 : IF (ierr .NE. 0) &
4751 0 : CPABORT("mpi_file_read_at_all_${nametype1}$v @ mp_file_read_at_all_${nametype1}$v")
4752 : #else
4753 : READ (UNIT=fh%handle, POS=offset + 1) msg(1:msg_len)
4754 : #endif
4755 0 : END SUBROUTINE mp_file_read_at_all_${nametype1}$v
4756 :
4757 : ! **************************************************************************************************
4758 : !> \brief ...
4759 : !> \param fh ...
4760 : !> \param offset ...
4761 : !> \param msg ...
4762 : ! **************************************************************************************************
4763 0 : SUBROUTINE mp_file_read_at_all_${nametype1}$ (fh, offset, msg)
4764 : ${type1}$, INTENT(OUT) :: msg
4765 : CLASS(mp_file_type), INTENT(IN) :: fh
4766 : INTEGER(kind=file_offset), INTENT(IN) :: offset
4767 :
4768 : #if defined(__parallel)
4769 : INTEGER :: ierr
4770 :
4771 : ierr = 0
4772 0 : CALL MPI_FILE_READ_AT_ALL(fh%handle, offset, msg, 1, ${mpi_type1}$, MPI_STATUS_IGNORE, ierr)
4773 0 : IF (ierr .NE. 0) &
4774 0 : CPABORT("mpi_file_read_at_all_${nametype1}$ @ mp_file_read_at_all_${nametype1}$")
4775 : #else
4776 : READ (UNIT=fh%handle, POS=offset + 1) msg
4777 : #endif
4778 0 : END SUBROUTINE mp_file_read_at_all_${nametype1}$
4779 :
4780 : ! **************************************************************************************************
4781 : !> \brief ...
4782 : !> \param ptr ...
4783 : !> \param vector_descriptor ...
4784 : !> \param index_descriptor ...
4785 : !> \return ...
4786 : ! **************************************************************************************************
4787 0 : FUNCTION mp_type_make_${nametype1}$ (ptr, &
4788 : vector_descriptor, index_descriptor) &
4789 0 : RESULT(type_descriptor)
4790 : ${type1}$, DIMENSION(:), TARGET, ASYNCHRONOUS :: ptr
4791 : INTEGER, DIMENSION(2), INTENT(IN), OPTIONAL :: vector_descriptor
4792 : TYPE(mp_indexing_meta_type), INTENT(IN), OPTIONAL :: index_descriptor
4793 : TYPE(mp_type_descriptor_type) :: type_descriptor
4794 :
4795 : CHARACTER(len=*), PARAMETER :: routineN = 'mp_type_make_${nametype1}$'
4796 :
4797 : #if defined(__parallel)
4798 : INTEGER :: ierr
4799 : #if defined(__MPI_F08)
4800 : ! Even OpenMPI 5.x misses mpi_get_address in the F08 interface
4801 : EXTERNAL :: mpi_get_address
4802 : #endif
4803 : #endif
4804 :
4805 : NULLIFY (type_descriptor%subtype)
4806 0 : type_descriptor%length = SIZE(ptr)
4807 : #if defined(__parallel)
4808 0 : type_descriptor%type_handle = ${mpi_type1}$
4809 0 : CALL MPI_Get_address(ptr, type_descriptor%base, ierr)
4810 0 : IF (ierr /= 0) &
4811 0 : CPABORT("MPI_Get_address @ "//routineN)
4812 : #else
4813 : type_descriptor%type_handle = ${handle1}$
4814 : #endif
4815 0 : type_descriptor%vector_descriptor(1:2) = 1
4816 0 : type_descriptor%has_indexing = .FALSE.
4817 0 : type_descriptor%data_${nametype1}$ => ptr
4818 0 : IF (PRESENT(vector_descriptor) .OR. PRESENT(index_descriptor)) THEN
4819 0 : CPABORT(routineN//": Vectors and indices NYI")
4820 : END IF
4821 0 : END FUNCTION mp_type_make_${nametype1}$
4822 :
4823 : ! **************************************************************************************************
4824 : !> \brief Allocates an array, using MPI_ALLOC_MEM ... this is hackish
4825 : !> as the Fortran version returns an integer, which we take to be a C_PTR
4826 : !> \param DATA data array to allocate
4827 : !> \param[in] len length (in data elements) of data array allocation
4828 : !> \param[out] stat (optional) allocation status result
4829 : ! **************************************************************************************************
4830 0 : SUBROUTINE mp_alloc_mem_${nametype1}$ (DATA, len, stat)
4831 : ${type1}$, CONTIGUOUS, DIMENSION(:), POINTER :: DATA
4832 : INTEGER, INTENT(IN) :: len
4833 : INTEGER, INTENT(OUT), OPTIONAL :: stat
4834 :
4835 : #if defined(__parallel)
4836 : INTEGER :: size, ierr, length, &
4837 : mp_res
4838 : INTEGER(KIND=MPI_ADDRESS_KIND) :: mp_size
4839 : TYPE(C_PTR) :: mp_baseptr
4840 : MPI_INFO_TYPE :: mp_info
4841 :
4842 0 : length = MAX(len, 1)
4843 0 : CALL MPI_TYPE_SIZE(${mpi_type1}$, size, ierr)
4844 0 : mp_size = INT(length, KIND=MPI_ADDRESS_KIND)*size
4845 0 : IF (mp_size .GT. mp_max_memory_size) THEN
4846 0 : CPABORT("MPI cannot allocate more than 2 GiByte")
4847 : END IF
4848 0 : mp_info = MPI_INFO_NULL
4849 0 : CALL MPI_ALLOC_MEM(mp_size, mp_info, mp_baseptr, mp_res)
4850 0 : CALL C_F_POINTER(mp_baseptr, DATA, (/length/))
4851 0 : IF (PRESENT(stat)) stat = mp_res
4852 : #else
4853 : INTEGER :: length, mystat
4854 : length = MAX(len, 1)
4855 : IF (PRESENT(stat)) THEN
4856 : ALLOCATE (DATA(length), stat=mystat)
4857 : stat = mystat ! show to convention checker that stat is used
4858 : ELSE
4859 : ALLOCATE (DATA(length))
4860 : END IF
4861 : #endif
4862 0 : END SUBROUTINE mp_alloc_mem_${nametype1}$
4863 :
4864 : ! **************************************************************************************************
4865 : !> \brief Deallocates am array, ... this is hackish
4866 : !> as the Fortran version takes an integer, which we hope to get by reference
4867 : !> \param DATA data array to allocate
4868 : !> \param[out] stat (optional) allocation status result
4869 : ! **************************************************************************************************
4870 0 : SUBROUTINE mp_free_mem_${nametype1}$ (DATA, stat)
4871 : ${type1}$, DIMENSION(:), &
4872 : POINTER, ASYNCHRONOUS :: DATA
4873 : INTEGER, INTENT(OUT), OPTIONAL :: stat
4874 :
4875 : #if defined(__parallel)
4876 : INTEGER :: mp_res
4877 0 : CALL MPI_FREE_MEM(DATA, mp_res)
4878 0 : IF (PRESENT(stat)) stat = mp_res
4879 : #else
4880 : DEALLOCATE (DATA)
4881 : IF (PRESENT(stat)) stat = 0
4882 : #endif
4883 0 : END SUBROUTINE mp_free_mem_${nametype1}$
4884 : #:endfor
|