Octopus
mpi.F90
Go to the documentation of this file.
1!! Copyright (C) 2005-2006 Heiko Appel, Florian Lorenzen
2!!
3!! This program is free software; you can redistribute it and/or modify
4!! it under the terms of the GNU General Public License as published by
5!! the Free Software Foundation; either version 2, or (at your option)
6!! any later version.
7!!
8!! This program is distributed in the hope that it will be useful,
9!! but WITHOUT ANY WARRANTY; without even the implied warranty of
10!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11!! GNU General Public License for more details.
12!!
13!! You should have received a copy of the GNU General Public License
14!! along with this program; if not, write to the Free Software
15!! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16!! 02110-1301, USA.
17!!
18
19#include "global.h"
20
21module mpi_oct_m
22#ifdef HAVE_MPI
23 use mpi_f08
24#else
26#endif
27 use blacs_oct_m
28 use loct_oct_m
30 use iso_c_binding
31 use, intrinsic :: iso_fortran_env
32#ifdef HAVE_OPENMP
33 use omp_lib
34#endif
35
36
37 implicit none
38
39 ! I do not make this module private on purpose, so that the symbols defined either in
40 ! module mpi, or in mpif.h are exported
41
43 type(MPI_Comm), parameter, public :: MPI_COMM_UNDEFINED = mpi_comm(-1)
44
46 integer, parameter, private :: root_process = 0
47
49 type mpi_grp_t
50 ! Components are public by default
51 type(MPI_Comm) :: comm = mpi_comm_undefined
52 integer :: size = 0
53 integer :: rank = 0
54 contains
55 ! Wrapper functions for common MPI calls
56 ! We do not check the error code in any of those wrappers because the behavior of
57 ! an application is undefined after an MPI error according to the standard. The
58 ! default is to let the application crash in such a case with an error message
59 ! from the MPI runtime.
60 procedure :: barrier => mpi_grp_barrier
61 procedure :: dmpi_grp_scatterv, zmpi_grp_scatterv, impi_grp_scatterv, lmpi_grp_scatterv
62 generic :: scatterv => dmpi_grp_scatterv, zmpi_grp_scatterv, impi_grp_scatterv, lmpi_grp_scatterv
63 procedure :: dmpi_grp_scatterv_i8, zmpi_grp_scatterv_i8, impi_grp_scatterv_i8, lmpi_grp_scatterv_i8
64 generic :: scatterv => dmpi_grp_scatterv_i8, zmpi_grp_scatterv_i8, impi_grp_scatterv_i8, lmpi_grp_scatterv_i8
65 procedure :: dmpi_grp_gatherv, zmpi_grp_gatherv, impi_grp_gatherv, lmpi_grp_gatherv
66 generic :: gatherv => dmpi_grp_gatherv, zmpi_grp_gatherv, impi_grp_gatherv, lmpi_grp_gatherv
67 procedure :: dmpi_grp_gather_0, zmpi_grp_gather_0, impi_grp_gather_0, lmpi_grp_gather_0
68 generic :: gather => dmpi_grp_gather_0, zmpi_grp_gather_0, impi_grp_gather_0, lmpi_grp_gather_0
69 procedure :: dmpi_grp_gatherv_i8, zmpi_grp_gatherv_i8, impi_grp_gatherv_i8, lmpi_grp_gatherv_i8
70 generic :: gatherv => dmpi_grp_gatherv_i8, zmpi_grp_gatherv_i8, impi_grp_gatherv_i8, lmpi_grp_gatherv_i8
71 procedure :: dmpi_grp_alltoallv, zmpi_grp_alltoallv, impi_grp_alltoallv, lmpi_grp_alltoallv
72 generic :: alltoallv => dmpi_grp_alltoallv, zmpi_grp_alltoallv, impi_grp_alltoallv, lmpi_grp_alltoallv
73 procedure :: dmpi_grp_alltoallv_2, zmpi_grp_alltoallv_2, impi_grp_alltoallv_2, lmpi_grp_alltoallv_2
74 generic :: alltoallv => dmpi_grp_alltoallv_2, zmpi_grp_alltoallv_2, impi_grp_alltoallv_2, lmpi_grp_alltoallv_2
75 procedure :: dmpi_grp_alltoallv_3, zmpi_grp_alltoallv_3, impi_grp_alltoallv_3, lmpi_grp_alltoallv_3
76 generic :: alltoallv => dmpi_grp_alltoallv_3, zmpi_grp_alltoallv_3, impi_grp_alltoallv_3, lmpi_grp_alltoallv_3
77 procedure :: dmpi_grp_alltoallv_i8, zmpi_grp_alltoallv_i8, impi_grp_alltoallv_i8, lmpi_grp_alltoallv_i8
78 generic :: alltoallv => dmpi_grp_alltoallv_i8, zmpi_grp_alltoallv_i8, impi_grp_alltoallv_i8, lmpi_grp_alltoallv_i8
79 procedure :: dmpi_grp_alltoall, zmpi_grp_alltoall, impi_grp_alltoall, lmpi_grp_alltoall
80 generic :: alltoall => dmpi_grp_alltoall, zmpi_grp_alltoall, impi_grp_alltoall, lmpi_grp_alltoall
81 procedure :: dmpi_grp_allgatherv, zmpi_grp_allgatherv, impi_grp_allgatherv, lmpi_grp_allgatherv
82 generic :: allgatherv => dmpi_grp_allgatherv, zmpi_grp_allgatherv, impi_grp_allgatherv, lmpi_grp_allgatherv
83 procedure :: dmpi_grp_allgatherv_2, zmpi_grp_allgatherv_2, impi_grp_allgatherv_2, lmpi_grp_allgatherv_2
84 generic :: allgatherv => dmpi_grp_allgatherv_2, zmpi_grp_allgatherv_2, impi_grp_allgatherv_2, lmpi_grp_allgatherv_2
85 procedure :: dmpi_grp_allgatherv_3, zmpi_grp_allgatherv_3, impi_grp_allgatherv_3, lmpi_grp_allgatherv_3
86 generic :: allgatherv => dmpi_grp_allgatherv_3, zmpi_grp_allgatherv_3, impi_grp_allgatherv_3, lmpi_grp_allgatherv_3
87 procedure :: dmpi_grp_allgatherv_3_1, zmpi_grp_allgatherv_3_1, impi_grp_allgatherv_3_1, lmpi_grp_allgatherv_3_1
88 generic :: allgatherv => dmpi_grp_allgatherv_3_1, zmpi_grp_allgatherv_3_1, impi_grp_allgatherv_3_1, lmpi_grp_allgatherv_3_1
89 procedure :: dmpi_grp_allgatherv_i8, zmpi_grp_allgatherv_i8, impi_grp_allgatherv_i8, lmpi_grp_allgatherv_i8
90 generic :: allgatherv => dmpi_grp_allgatherv_i8, zmpi_grp_allgatherv_i8, impi_grp_allgatherv_i8, lmpi_grp_allgatherv_i8
91 procedure :: dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
92 generic :: bcast => dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
93 procedure :: dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
94 generic :: bcast => dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
95 procedure :: dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
96 generic :: bcast => dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
97 procedure :: dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
98 generic :: bcast => dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
99 procedure :: chmpi_grp_bcast_0, lompi_grp_bcast_0
100 generic :: bcast => chmpi_grp_bcast_0, lompi_grp_bcast_0
101 procedure :: dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
102 generic :: bcast => dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
103 procedure :: dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
104 generic :: allreduce => dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
105 procedure :: dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
106 generic :: allreduce => dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
107 procedure :: dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
108 generic :: allreduce => dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
109 procedure :: dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
110 generic :: allreduce => dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
111 procedure :: lompi_grp_allreduce_0
112 generic :: allreduce => lompi_grp_allreduce_0
113 procedure :: dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
114 procedure :: impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
115 procedure :: lompi_grp_allreduce_inplace_0
116 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
117 generic :: allreduce_inplace => impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
118 generic :: allreduce_inplace => lompi_grp_allreduce_inplace_0
119 procedure :: dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
120 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
121 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
122 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
123 procedure :: dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
124 generic :: allgather => dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
125 procedure :: dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
126 generic :: allgather => dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
127 procedure :: dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
128 generic :: recv => dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
129 procedure :: dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
130 generic :: recv => dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
131 procedure :: dmpi_grp_recv_2, zmpi_grp_recv_2, impi_grp_recv_2, lmpi_grp_recv_2
132 generic :: recv => dmpi_grp_recv_2, zmpi_grp_recv_2, impi_grp_recv_2, lmpi_grp_recv_2
133 procedure :: dmpi_grp_recv_3, zmpi_grp_recv_3, impi_grp_recv_3, lmpi_grp_recv_3
134 generic :: recv => dmpi_grp_recv_3, zmpi_grp_recv_3, impi_grp_recv_3, lmpi_grp_recv_3
135 procedure :: lompi_grp_recv_0
136 generic :: recv => lompi_grp_recv_0
143 procedure :: dmpi_grp_send_3, zmpi_grp_send_3, impi_grp_send_3, lmpi_grp_send_3
144 generic :: send => dmpi_grp_send_3, zmpi_grp_send_3, impi_grp_send_3, lmpi_grp_send_3
145 procedure :: lompi_grp_send_0
146 generic :: send => lompi_grp_send_0
168 generic :: wait => mpi_grp_wait, mpi_grp_waitall
169 procedure :: abort => mpi_grp_abort
170 procedure :: is_root => mpi_grp_is_root
171 end type mpi_grp_t
173 type(mpi_grp_t), public :: mpi_world
176 integer, public :: mpi_err
178 private :: not_in_openmp
181contains
188 subroutine mpi_init_comm(comm)
189 type(mpi_comm), intent(out) :: comm
190#if defined(HAVE_MPI)
191#if defined(HAVE_OPENMP)
192 integer :: provided
194 call mpi_init_thread(mpi_thread_funneled, provided, mpi_err)
195#else
196 call mpi_init(mpi_err)
197#endif
198 comm = mpi_comm_world
199#else
200 comm = mpi_comm_undefined
201#endif
203 end subroutine mpi_init_comm
207 subroutine blacs_init()
208#if defined(HAVE_MPI)
209#ifdef HAVE_SCALAPACK
210 integer :: iam, nprocs
211 integer :: blacs_default_system_context
213 ! Determine my process number and the number of processes in machine
214 call blacs_pinfo(iam, nprocs)
215
216 ! If machine needs additional set up, do it now
217 if (nprocs < 1) then
218 call blacs_setup(iam, mpi_world%size)
219 end if
221 ! blacs_gridinit() or blacs_gridmap() must be called, else
222 ! blacs_exit() triggers an error with openmpi:
223 ! *** An error occurred in MPI_Type_free
224 ! *** MPI_ERR_TYPE: invalid datatype
225 call blacs_get(0, 0, blacs_default_system_context)
226 call blacs_gridinit(blacs_default_system_context, 'R', mpi_world%size, 1)
227 call blacs_gridexit(blacs_default_system_context)
228#endif
229#endif
230 end subroutine blacs_init
234 subroutine mpi_mod_end()
236#ifdef HAVE_SCALAPACK
237 if (mpi_world%comm /= mpi_comm_undefined) call blacs_exit(1)
238#endif
240#if defined(HAVE_MPI)
241 ! end MPI, if we started it
242 if (mpi_world%comm /= mpi_comm_undefined) call mpi_finalize(mpi_err)
243#endif
245 end subroutine mpi_mod_end
252 subroutine mpi_grp_init(grp, comm)
253 type(mpi_grp_t), intent(out) :: grp
254 type(mpi_comm), intent(in) :: comm
256 grp%comm = comm
257#if defined(HAVE_MPI)
258 if (grp%comm == mpi_comm_null) grp%comm = mpi_comm_undefined
259#endif
261 if (grp%comm == mpi_comm_undefined) then
262 grp%rank = 0
263 grp%size = 1
264#if defined(HAVE_MPI)
265 else
266 call mpi_comm_rank(grp%comm, grp%rank, mpi_err)
268
269 call mpi_comm_size(grp%comm, grp%size, mpi_err)
271#endif
272 end if
273
274 end subroutine mpi_grp_init
275
276
277 logical &
278#ifndef have_openmp
279 pure &
280#endif
281 function not_in_openmp()
282
283#ifdef HAVE_OPENMP
284 not_in_openmp = .not. omp_in_parallel()
285#else
287#endif
288
289 end function not_in_openmp
290
291
292 !-----------------------------------------------------------
293 subroutine mpi_error_check(error)
294 integer, intent(in) :: error
295
296#if defined(HAVE_MPI)
297 character(len=MPI_MAX_ERROR_STRING) :: message
298 integer :: length, temp
299
300 if (error /= mpi_success ) then
301 call mpi_error_string( error, message, length, temp)
302 print * , message(1:length)
303 call mpi_abort(mpi_comm_world, 1 , temp)
304 end if
305#endif
306 end subroutine mpi_error_check
307
308 ! ---------------------------------------------------------
309 subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
310 type(mpi_grp_t), intent(out) :: mpi_grp_out
311 type(mpi_grp_t), intent(in) :: mpi_grp_in
312
313 mpi_grp_out%comm = mpi_grp_in%comm
314 mpi_grp_out%size = mpi_grp_in%size
315 mpi_grp_out%rank = mpi_grp_in%rank
316 end subroutine mpi_grp_copy
317
318 ! ---------------------------------------------------------
319 subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
320 type(mpi_grp_t), intent(out) :: mpi_grp_out
321 type(mpi_grp_t), intent(in) :: mpi_grp_in
322
323#if defined(HAVE_MPI)
324 call mpi_comm_dup(mpi_grp_in%comm, mpi_grp_out%comm, mpi_err)
326 call mpi_comm_rank(mpi_grp_out%comm, mpi_grp_out%rank, mpi_err)
328 call mpi_comm_size(mpi_grp_out%comm, mpi_grp_out%size, mpi_err)
330#else
331 call mpi_grp_copy(mpi_grp_out, mpi_grp_in)
332#endif
333 end subroutine mpi_grp_duplicate
334
336 logical function mpi_grp_is_root(grp)
337 class(mpi_grp_t), intent(in) :: grp
338
339 mpi_grp_is_root = (grp%rank == root_process)
340 end function mpi_grp_is_root
341
342 ! ---------------------------------------------------------
343 subroutine mpi_grp_barrier(mpi_grp)
344 class(mpi_grp_t), intent(in) :: mpi_grp
346 if (mpi_grp%comm == mpi_comm_undefined) return
347#if defined(HAVE_MPI)
348 assert(not_in_openmp())
349
350 call mpi_debug_in(mpi_grp%comm, c_mpi_barrier)
351 call mpi_barrier(mpi_grp%comm, mpi_err)
353 call mpi_debug_out(mpi_grp%comm, c_mpi_barrier)
354#endif
355 end subroutine mpi_grp_barrier
356
357 ! ---------------------------------------------------------
358 subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
359 class(mpi_grp_t), intent(in) :: mpi_grp
360 character(len=*), intent(inout) :: buf
361 integer, intent(in) :: cnt
362 type(mpi_datatype), intent(in) :: sendtype
363 integer, intent(in) :: root
364
365#if defined(HAVE_MPI)
366 assert(not_in_openmp())
367
368 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
369 if (mpi_grp%comm /= mpi_comm_undefined) then
370 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm, mpi_err)
372 end if
373 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
374#endif
375 end subroutine chmpi_grp_bcast_0
376
377 ! ---------------------------------------------------------
378 subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
379 class(mpi_grp_t), intent(in) :: mpi_grp
380 logical, intent(inout) :: buf
381 integer, intent(in) :: cnt
382 type(mpi_datatype), intent(in) :: sendtype
383 integer, intent(in) :: root
384
385#if defined(HAVE_MPI)
387
388 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
389 if (mpi_grp%comm /= mpi_comm_undefined) then
390 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm, mpi_err)
392 end if
393 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
394#endif
395 end subroutine lompi_grp_bcast_0
396
397 ! ---------------------------------------------------------
398 ! copy routine for serial case
399 subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
400 use iso_c_binding
401 logical, target, intent(in) :: sendbuf
402 logical, target, intent(out) :: recvbuf
403 integer, intent(in) :: count
404 integer :: ii
405 logical, pointer :: send(:), recv(:)
406
407 call c_f_pointer(c_loc(sendbuf), send, [count])
408 call c_f_pointer(c_loc(recvbuf), recv, [count])
409 do ii = 1, count
410 recv(ii) = send(ii)
411 end do
412 end subroutine lompi_grp_copy_0
413
414 ! ---------------------------------------------------------
415 subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
416 class(mpi_grp_t), intent(in) :: mpi_grp
417 logical, intent(in) :: sendbuf
418 logical, intent(out) :: recvbuf
419 integer, intent(in) :: count
420 type(mpi_datatype), intent(in):: datatype
421 type(mpi_op), intent(in) :: op
422
423#if defined(HAVE_MPI)
424 assert(not_in_openmp())
425
426 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
427 if (mpi_grp%comm /= mpi_comm_undefined) then
428 call mpi_allreduce(sendbuf, recvbuf, count, datatype, op, &
429 mpi_grp%comm, mpi_err)
431 else
432 call lompi_grp_copy_0(sendbuf, recvbuf, count)
433 end if
434 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
435#else
436 call lompi_grp_copy_0(sendbuf, recvbuf, count)
437#endif
438 end subroutine lompi_grp_allreduce_0
439
440 ! ---------------------------------------------------------
441 subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
442 class(mpi_grp_t), intent(in) :: mpi_grp
443 logical, intent(inout) :: recvbuf
444 integer, intent(in) :: count
445 type(mpi_datatype), intent(in) :: datatype
446 type(mpi_op), intent(in) :: op
447
448#if defined(HAVE_MPI)
449 assert(not_in_openmp())
450
451 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
452 if (mpi_grp%comm /= mpi_comm_undefined) then
453 call mpi_allreduce(mpi_in_place, recvbuf, count, datatype, op, &
454 mpi_grp%comm, mpi_err)
456 end if
457 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
458#endif
459 end subroutine lompi_grp_allreduce_inplace_0
460
461 ! ---------------------------------------------------------
462 subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
463 class(mpi_grp_t), intent(in) :: mpi_grp
464 logical, intent(out) :: recvbuf
465 integer, intent(in) :: recvcount
466 type(mpi_datatype),intent(in) :: recvtype
467 integer, intent(in) :: source
468 integer, optional, intent(in) :: tag
469
470 integer :: tag_
472 tag_ = 0
473 if (present(tag)) tag_ = tag
474 if (mpi_grp%comm == mpi_comm_undefined) return
475#if defined(HAVE_MPI)
476 assert(not_in_openmp())
477
478 call mpi_recv(recvbuf, recvcount, recvtype, source, tag_, mpi_grp%comm, mpi_status_ignore, mpi_err)
480#endif
481 end subroutine lompi_grp_recv_0
482
483 ! ---------------------------------------------------------
484 subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
485 class(mpi_grp_t), intent(in) :: mpi_grp
486 logical, intent(out) :: sendbuf
487 integer, intent(in) :: sendcount
488 type(mpi_datatype),intent(in) :: sendtype
489 integer, intent(in) :: dest
490 integer, optional, intent(in) :: tag
491
492 integer :: tag_
493
494 tag_ = 0
495 if (present(tag)) tag_ = tag
496 if (mpi_grp%comm == mpi_comm_undefined) return
497#if defined(HAVE_MPI)
498 assert(not_in_openmp())
499
500 call mpi_send(sendbuf, sendcount, sendtype, dest, tag_, mpi_grp%comm, mpi_err)
502#endif
503 end subroutine lompi_grp_send_0
504
505 ! ---------------------------------------------------------
506 subroutine mpi_grp_wait(mpi_grp, request)
507 class(mpi_grp_t), intent(in) :: mpi_grp
508 type(mpi_request), intent(inout) :: request
509
510 if (mpi_grp%comm == mpi_comm_undefined) return
511#if defined(HAVE_MPI)
512 assert(not_in_openmp())
513
514 call mpi_wait(request, mpi_status_ignore, mpi_err)
516#endif
517 end subroutine mpi_grp_wait
518
519 ! ---------------------------------------------------------
520 subroutine mpi_grp_waitall(mpi_grp, count, requests)
521 class(mpi_grp_t), intent(in) :: mpi_grp
522 integer, intent(in) :: count
523 type(mpi_request), intent(inout) :: requests(:)
524
525 if (mpi_grp%comm == mpi_comm_undefined) return
526#if defined(HAVE_MPI)
527 assert(not_in_openmp())
528
529 call mpi_waitall(count, requests, mpi_statuses_ignore, mpi_err)
531#endif
532 end subroutine mpi_grp_waitall
533
534 ! ---------------------------------------------------------
535 subroutine mpi_grp_abort(mpi_grp)
536 class(mpi_grp_t), intent(in) :: mpi_grp
537
538 if (mpi_grp%comm /= mpi_comm_undefined) then
539#if defined(HAVE_MPI)
540 assert(not_in_openmp())
541
542 ! Abort with an arbitrary error code
543 call mpi_abort(mpi_grp%comm, 999, mpi_err)
545#endif
546 end if
547
548 end subroutine mpi_grp_abort
549
550 ! ---------------------------------------------------------
552 real(real64) function mpi_get_Wtime() result(now)
553#if defined(HAVE_MPI)
554 now = mpi_wtime()
555#else
556 now = loct_clock()
557#endif
558 end function mpi_get_wtime
559
560#include "undef.F90"
561#include "real.F90"
562#include "mpi_inc.F90"
563
564#include "undef.F90"
565#include "complex.F90"
566#include "mpi_inc.F90"
567
568#include "undef.F90"
569#include "integer.F90"
570#include "mpi_inc.F90"
571
572#include "undef.F90"
573#include "integer8.F90"
574#include "mpi_inc.F90"
575
576end module mpi_oct_m
578
579!! Local Variables:
580!! mode: f90
581!! coding: utf-8
582!! End:
This module contains interfaces for BLACS routines Interfaces are from http:
Definition: blacs.F90:27
integer, parameter, public c_mpi_allreduce
Definition: mpi_debug.F90:137
subroutine, public mpi_debug_in(comm, index)
Definition: mpi_debug.F90:241
integer, parameter, public c_mpi_bcast
Definition: mpi_debug.F90:137
integer, parameter, public c_mpi_barrier
Definition: mpi_debug.F90:137
subroutine, public mpi_debug_out(comm, index)
Definition: mpi_debug.F90:265
subroutine mpi_grp_abort(mpi_grp)
Definition: mpi.F90:629
subroutine impi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4519
subroutine zmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3177
subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:413
subroutine impi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4497
subroutine lmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:5842
subroutine lmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6069
subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
Definition: mpi.F90:493
subroutine zmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3039
subroutine blacs_init()
Initialize BLACS to enable use of SCALAPACK.
Definition: mpi.F90:301
real(real64) function, public mpi_get_wtime()
. Returns an elapsed time on the calling processor.
Definition: mpi.F90:646
subroutine dmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1697
subroutine zmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3200
subroutine dmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1812
subroutine zmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3131
subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:472
logical function mpi_grp_is_root(grp)
Is the current MPI process of grpcomm, root.
Definition: mpi.F90:430
subroutine impi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4542
subroutine zmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3085
subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:403
subroutine zmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3246
subroutine impi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4657
subroutine impi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4634
subroutine impi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4385
subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
Definition: mpi.F90:535
subroutine impi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4587
subroutine zmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3108
subroutine dmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1743
subroutine zmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2951
subroutine dmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1651
subroutine lmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5908
subroutine dmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1561
subroutine impi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4473
subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:556
subroutine dmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1517
subroutine mpi_grp_wait(mpi_grp, request)
Definition: mpi.F90:600
subroutine lmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5954
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:266
subroutine impi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4611
subroutine mpi_mod_end()
Finalize MPI, and optionally BLACS.
Definition: mpi.F90:328
subroutine dmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1539
logical pure function, private not_in_openmp()
Definition: mpi.F90:375
subroutine zmpi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2973
subroutine lmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6092
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:346
subroutine zmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2995
subroutine dmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1629
subroutine impi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4565
subroutine impi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4680
subroutine dmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1766
subroutine dmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1789
subroutine zmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3153
subroutine lmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:6000
subroutine mpi_grp_barrier(mpi_grp)
Definition: mpi.F90:437
subroutine zmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3063
subroutine lmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:5864
subroutine mpi_init_comm(comm)
Wrapper for MPI_COMM_WORLD initialisation.
Definition: mpi.F90:282
subroutine impi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4429
subroutine dmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1674
integer, public mpi_err
used to store return values of mpi calls
Definition: mpi.F90:269
subroutine lmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6022
subroutine dmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1605
subroutine lmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:5820
subroutine lmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6046
subroutine dmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1719
subroutine zmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3223
subroutine mpi_grp_waitall(mpi_grp, count, requests)
Definition: mpi.F90:614
subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
Definition: mpi.F90:509
subroutine lmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5932
subroutine impi_grp_send(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4407
subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:578
subroutine mpi_error_check(error)
Definition: mpi.F90:387
subroutine lmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6115
subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:452
subroutine lmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5977
This is defined even when running serial.
Definition: mpi.F90:142
int true(void)