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 type mpi_grp_t
47 ! Components are public by default
48 type(MPI_Comm) :: comm = mpi_comm_undefined
49 integer :: size = 0
50 integer :: rank = 0
51 contains
52 ! Wrapper functions for common MPI calls
53 ! We do not check the error code in any of those wrappers because the behavior of
54 ! an application is undefined after an MPI error according to the standard. The
55 ! default is to let the application crash in such a case with an error message
56 ! from the MPI runtime.
57 procedure :: barrier => mpi_grp_barrier
58 procedure :: dmpi_grp_scatterv, zmpi_grp_scatterv, impi_grp_scatterv, lmpi_grp_scatterv
59 generic :: scatterv => dmpi_grp_scatterv, zmpi_grp_scatterv, impi_grp_scatterv, lmpi_grp_scatterv
60 procedure :: dmpi_grp_scatterv_i8, zmpi_grp_scatterv_i8, impi_grp_scatterv_i8, lmpi_grp_scatterv_i8
61 generic :: scatterv => dmpi_grp_scatterv_i8, zmpi_grp_scatterv_i8, impi_grp_scatterv_i8, lmpi_grp_scatterv_i8
62 procedure :: dmpi_grp_gatherv, zmpi_grp_gatherv, impi_grp_gatherv, lmpi_grp_gatherv
63 generic :: gatherv => dmpi_grp_gatherv, zmpi_grp_gatherv, impi_grp_gatherv, lmpi_grp_gatherv
64 procedure :: dmpi_grp_gather_0, zmpi_grp_gather_0, impi_grp_gather_0, lmpi_grp_gather_0
65 generic :: gather => dmpi_grp_gather_0, zmpi_grp_gather_0, impi_grp_gather_0, lmpi_grp_gather_0
66 procedure :: dmpi_grp_gatherv_i8, zmpi_grp_gatherv_i8, impi_grp_gatherv_i8, lmpi_grp_gatherv_i8
67 generic :: gatherv => dmpi_grp_gatherv_i8, zmpi_grp_gatherv_i8, impi_grp_gatherv_i8, lmpi_grp_gatherv_i8
68 procedure :: dmpi_grp_alltoallv, zmpi_grp_alltoallv, impi_grp_alltoallv, lmpi_grp_alltoallv
69 generic :: alltoallv => dmpi_grp_alltoallv, zmpi_grp_alltoallv, impi_grp_alltoallv, lmpi_grp_alltoallv
70 procedure :: dmpi_grp_alltoallv_2, zmpi_grp_alltoallv_2, impi_grp_alltoallv_2, lmpi_grp_alltoallv_2
71 generic :: alltoallv => dmpi_grp_alltoallv_2, zmpi_grp_alltoallv_2, impi_grp_alltoallv_2, lmpi_grp_alltoallv_2
72 procedure :: dmpi_grp_alltoallv_3, zmpi_grp_alltoallv_3, impi_grp_alltoallv_3, lmpi_grp_alltoallv_3
73 generic :: alltoallv => dmpi_grp_alltoallv_3, zmpi_grp_alltoallv_3, impi_grp_alltoallv_3, lmpi_grp_alltoallv_3
74 procedure :: dmpi_grp_alltoallv_i8, zmpi_grp_alltoallv_i8, impi_grp_alltoallv_i8, lmpi_grp_alltoallv_i8
75 generic :: alltoallv => dmpi_grp_alltoallv_i8, zmpi_grp_alltoallv_i8, impi_grp_alltoallv_i8, lmpi_grp_alltoallv_i8
76 procedure :: dmpi_grp_alltoall, zmpi_grp_alltoall, impi_grp_alltoall, lmpi_grp_alltoall
77 generic :: alltoall => dmpi_grp_alltoall, zmpi_grp_alltoall, impi_grp_alltoall, lmpi_grp_alltoall
78 procedure :: dmpi_grp_allgatherv, zmpi_grp_allgatherv, impi_grp_allgatherv, lmpi_grp_allgatherv
79 generic :: allgatherv => dmpi_grp_allgatherv, zmpi_grp_allgatherv, impi_grp_allgatherv, lmpi_grp_allgatherv
80 procedure :: dmpi_grp_allgatherv_2, zmpi_grp_allgatherv_2, impi_grp_allgatherv_2, lmpi_grp_allgatherv_2
81 generic :: allgatherv => dmpi_grp_allgatherv_2, zmpi_grp_allgatherv_2, impi_grp_allgatherv_2, lmpi_grp_allgatherv_2
82 procedure :: dmpi_grp_allgatherv_3, zmpi_grp_allgatherv_3, impi_grp_allgatherv_3, lmpi_grp_allgatherv_3
83 generic :: allgatherv => dmpi_grp_allgatherv_3, zmpi_grp_allgatherv_3, impi_grp_allgatherv_3, lmpi_grp_allgatherv_3
84 procedure :: dmpi_grp_allgatherv_3_1, zmpi_grp_allgatherv_3_1, impi_grp_allgatherv_3_1, lmpi_grp_allgatherv_3_1
85 generic :: allgatherv => dmpi_grp_allgatherv_3_1, zmpi_grp_allgatherv_3_1, impi_grp_allgatherv_3_1, lmpi_grp_allgatherv_3_1
86 procedure :: dmpi_grp_allgatherv_i8, zmpi_grp_allgatherv_i8, impi_grp_allgatherv_i8, lmpi_grp_allgatherv_i8
87 generic :: allgatherv => dmpi_grp_allgatherv_i8, zmpi_grp_allgatherv_i8, impi_grp_allgatherv_i8, lmpi_grp_allgatherv_i8
88 procedure :: dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
89 generic :: bcast => dmpi_grp_bcast, zmpi_grp_bcast, impi_grp_bcast, lmpi_grp_bcast
90 procedure :: dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
91 generic :: bcast => dmpi_grp_bcast_0, zmpi_grp_bcast_0, impi_grp_bcast_0, lmpi_grp_bcast_0
92 procedure :: dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
93 generic :: bcast => dmpi_grp_bcast_2, zmpi_grp_bcast_2, impi_grp_bcast_2, lmpi_grp_bcast_2
94 procedure :: dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
95 generic :: bcast => dmpi_grp_bcast_3, zmpi_grp_bcast_3, impi_grp_bcast_3, lmpi_grp_bcast_3
96 procedure :: chmpi_grp_bcast_0, lompi_grp_bcast_0
97 generic :: bcast => chmpi_grp_bcast_0, lompi_grp_bcast_0
98 procedure :: dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
99 generic :: bcast => dmpi_grp_bcast_0_l, zmpi_grp_bcast_0_l, impi_grp_bcast_0_l, lmpi_grp_bcast_0_l
100 procedure :: dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
101 generic :: allreduce => dmpi_grp_allreduce, zmpi_grp_allreduce, impi_grp_allreduce, lmpi_grp_allreduce
102 procedure :: dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
103 generic :: allreduce => dmpi_grp_allreduce_2, zmpi_grp_allreduce_2, impi_grp_allreduce_2, lmpi_grp_allreduce_2
104 procedure :: dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
105 generic :: allreduce => dmpi_grp_allreduce_3, zmpi_grp_allreduce_3, impi_grp_allreduce_3, lmpi_grp_allreduce_3
106 procedure :: dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
107 generic :: allreduce => dmpi_grp_allreduce_0, zmpi_grp_allreduce_0, impi_grp_allreduce_0, lmpi_grp_allreduce_0
108 procedure :: lompi_grp_allreduce_0
109 generic :: allreduce => lompi_grp_allreduce_0
110 procedure :: dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
111 procedure :: impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
112 procedure :: lompi_grp_allreduce_inplace_0
113 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_0, zmpi_grp_allreduce_inplace_0
114 generic :: allreduce_inplace => impi_grp_allreduce_inplace_0, lmpi_grp_allreduce_inplace_0
115 generic :: allreduce_inplace => lompi_grp_allreduce_inplace_0
116 procedure :: dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
117 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
118 generic :: allreduce_inplace => dmpi_grp_allreduce_inplace_1, zmpi_grp_allreduce_inplace_1, &
119 impi_grp_allreduce_inplace_1, lmpi_grp_allreduce_inplace_1
120 procedure :: dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
121 generic :: allgather => dmpi_grp_allgather, zmpi_grp_allgather, impi_grp_allgather, lmpi_grp_allgather
122 procedure :: dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
123 generic :: allgather => dmpi_grp_allgather_0, zmpi_grp_allgather_0, impi_grp_allgather_0, lmpi_grp_allgather_0
124 procedure :: dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
125 generic :: recv => dmpi_grp_recv, zmpi_grp_recv, impi_grp_recv, lmpi_grp_recv
126 procedure :: dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
127 generic :: recv => dmpi_grp_recv_0, zmpi_grp_recv_0, impi_grp_recv_0, lmpi_grp_recv_0
128 procedure :: dmpi_grp_recv_2, zmpi_grp_recv_2, impi_grp_recv_2, lmpi_grp_recv_2
129 generic :: recv => dmpi_grp_recv_2, zmpi_grp_recv_2, impi_grp_recv_2, lmpi_grp_recv_2
130 procedure :: dmpi_grp_recv_3, zmpi_grp_recv_3, impi_grp_recv_3, lmpi_grp_recv_3
131 generic :: recv => dmpi_grp_recv_3, zmpi_grp_recv_3, impi_grp_recv_3, lmpi_grp_recv_3
132 procedure :: lompi_grp_recv_0
133 generic :: recv => lompi_grp_recv_0
134 procedure :: dmpi_grp_send, zmpi_grp_send, impi_grp_send, lmpi_grp_send
135 generic :: send => dmpi_grp_send, zmpi_grp_send, impi_grp_send, lmpi_grp_send
140 procedure :: dmpi_grp_send_3, zmpi_grp_send_3, impi_grp_send_3, lmpi_grp_send_3
141 generic :: send => dmpi_grp_send_3, zmpi_grp_send_3, impi_grp_send_3, lmpi_grp_send_3
142 procedure :: lompi_grp_send_0
143 generic :: send => lompi_grp_send_0
165 generic :: wait => mpi_grp_wait, mpi_grp_waitall
166 procedure :: abort => mpi_grp_abort
167 end type mpi_grp_t
169 type(mpi_grp_t), public :: mpi_world
172 integer, public :: mpi_err
174 private :: not_in_openmp
177contains
184 subroutine mpi_init_comm(comm)
185 type(mpi_comm), intent(out) :: comm
186#if defined(HAVE_MPI)
187#if defined(HAVE_OPENMP)
188 integer :: provided
190 call mpi_init_thread(mpi_thread_funneled, provided, mpi_err)
191#else
192 call mpi_init(mpi_err)
193#endif
194 comm = mpi_comm_world
195#else
196 comm = mpi_comm_undefined
197#endif
199 end subroutine mpi_init_comm
203 subroutine blacs_init()
204#if defined(HAVE_MPI)
205#ifdef HAVE_SCALAPACK
206 integer :: iam, nprocs
207 integer :: blacs_default_system_context
209 ! Determine my process number and the number of processes in machine
210 call blacs_pinfo(iam, nprocs)
212 ! If machine needs additional set up, do it now
213 if (nprocs < 1) then
214 call blacs_setup(iam, mpi_world%size)
215 end if
217 ! blacs_gridinit() or blacs_gridmap() must be called, else
218 ! blacs_exit() triggers an error with openmpi:
219 ! *** An error occurred in MPI_Type_free
220 ! *** MPI_ERR_TYPE: invalid datatype
221 call blacs_get(-1,0, blacs_default_system_context)
222 call blacs_gridinit(blacs_default_system_context, 'R', 1, 1)
223#endif
224#endif
225 end subroutine blacs_init
229 subroutine mpi_mod_end()
231#ifdef HAVE_SCALAPACK
232 if (mpi_world%comm /= mpi_comm_undefined) call blacs_exit(1)
233#endif
235#if defined(HAVE_MPI)
236 ! end MPI, if we started it
237 if (mpi_world%comm /= mpi_comm_undefined) call mpi_finalize(mpi_err)
238#endif
240 end subroutine mpi_mod_end
247 subroutine mpi_grp_init(grp, comm)
248 type(mpi_grp_t), intent(out) :: grp
249 type(mpi_comm), intent(in) :: comm
251 grp%comm = comm
252#if defined(HAVE_MPI)
253 if (grp%comm == mpi_comm_null) grp%comm = mpi_comm_undefined
254#endif
256 if (grp%comm == mpi_comm_undefined) then
257 grp%rank = 0
258 grp%size = 1
259#if defined(HAVE_MPI)
260 else
261 call mpi_comm_rank(grp%comm, grp%rank, mpi_err)
263
264 call mpi_comm_size(grp%comm, grp%size, mpi_err)
266#endif
267 end if
268
269 end subroutine mpi_grp_init
270
271
272 logical &
273#ifndef have_openmp
274 pure &
275#endif
276 function not_in_openmp()
278#ifdef HAVE_OPENMP
279 not_in_openmp = .not. omp_in_parallel()
280#else
282#endif
283
284 end function not_in_openmp
285
286
287 !-----------------------------------------------------------
288 subroutine mpi_error_check(error)
289 integer, intent(in) :: error
290
291#if defined(HAVE_MPI)
292 character(len=MPI_MAX_ERROR_STRING) :: message
293 integer :: length, temp
294
295 if (error /= mpi_success ) then
296 call mpi_error_string( error, message, length, temp)
297 print * , message(1:length)
298 call mpi_abort(mpi_comm_world, 1 , temp)
299 end if
300#endif
301 end subroutine mpi_error_check
302
303 ! ---------------------------------------------------------
304 subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
305 type(mpi_grp_t), intent(out) :: mpi_grp_out
306 type(mpi_grp_t), intent(in) :: mpi_grp_in
307
308 mpi_grp_out%comm = mpi_grp_in%comm
309 mpi_grp_out%size = mpi_grp_in%size
310 mpi_grp_out%rank = mpi_grp_in%rank
311 end subroutine mpi_grp_copy
312
313 ! ---------------------------------------------------------
314 subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
315 type(mpi_grp_t), intent(out) :: mpi_grp_out
316 type(mpi_grp_t), intent(in) :: mpi_grp_in
317
318#if defined(HAVE_MPI)
319 call mpi_comm_dup(mpi_grp_in%comm, mpi_grp_out%comm, mpi_err)
321 call mpi_comm_rank(mpi_grp_out%comm, mpi_grp_out%rank, mpi_err)
323 call mpi_comm_size(mpi_grp_out%comm, mpi_grp_out%size, mpi_err)
325#else
326 call mpi_grp_copy(mpi_grp_out, mpi_grp_in)
327#endif
328 end subroutine mpi_grp_duplicate
329
330 ! ---------------------------------------------------------
331 logical function mpi_grp_is_root(grp)
332 type(mpi_grp_t), intent(in) :: grp
333
334 mpi_grp_is_root = (grp%rank == 0)
335 end function mpi_grp_is_root
336
337 ! ---------------------------------------------------------
338 subroutine mpi_grp_barrier(mpi_grp)
339 class(mpi_grp_t), intent(in) :: mpi_grp
341 if (mpi_grp%comm == mpi_comm_undefined) return
342#if defined(HAVE_MPI)
343 assert(not_in_openmp())
344
345 call mpi_debug_in(mpi_grp%comm, c_mpi_barrier)
346 call mpi_barrier(mpi_grp%comm, mpi_err)
348 call mpi_debug_out(mpi_grp%comm, c_mpi_barrier)
349#endif
350 end subroutine mpi_grp_barrier
351
352 ! ---------------------------------------------------------
353 subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
354 class(mpi_grp_t), intent(in) :: mpi_grp
355 character(len=*), intent(inout) :: buf
356 integer, intent(in) :: cnt
357 type(mpi_datatype), intent(in) :: sendtype
358 integer, intent(in) :: root
359
360#if defined(HAVE_MPI)
361 assert(not_in_openmp())
362
363 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
364 if (mpi_grp%comm /= mpi_comm_undefined) then
365 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm, mpi_err)
367 end if
368 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
369#endif
370 end subroutine chmpi_grp_bcast_0
371
372 ! ---------------------------------------------------------
373 subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
374 class(mpi_grp_t), intent(in) :: mpi_grp
375 logical, intent(inout) :: buf
376 integer, intent(in) :: cnt
377 type(mpi_datatype), intent(in) :: sendtype
378 integer, intent(in) :: root
379
380#if defined(HAVE_MPI)
382
383 call mpi_debug_in(mpi_grp%comm, c_mpi_bcast)
384 if (mpi_grp%comm /= mpi_comm_undefined) then
385 call mpi_bcast(buf, cnt, sendtype, root, mpi_grp%comm, mpi_err)
387 end if
388 call mpi_debug_out(mpi_grp%comm, c_mpi_bcast)
389#endif
390 end subroutine lompi_grp_bcast_0
391
392 ! ---------------------------------------------------------
393 ! copy routine for serial case
394 subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
395 use iso_c_binding
396 logical, target, intent(in) :: sendbuf
397 logical, target, intent(out) :: recvbuf
398 integer, intent(in) :: count
399 integer :: ii
400 logical, pointer :: send(:), recv(:)
401
402 call c_f_pointer(c_loc(sendbuf), send, [count])
403 call c_f_pointer(c_loc(recvbuf), recv, [count])
404 do ii = 1, count
405 recv(ii) = send(ii)
406 end do
407 end subroutine lompi_grp_copy_0
408
409 ! ---------------------------------------------------------
410 subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
411 class(mpi_grp_t), intent(in) :: mpi_grp
412 logical, intent(in) :: sendbuf
413 logical, intent(out) :: recvbuf
414 integer, intent(in) :: count
415 type(mpi_datatype), intent(in):: datatype
416 type(mpi_op), intent(in) :: op
417
418#if defined(HAVE_MPI)
419 assert(not_in_openmp())
420
421 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
422 if (mpi_grp%comm /= mpi_comm_undefined) then
423 call mpi_allreduce(sendbuf, recvbuf, count, datatype, op, &
424 mpi_grp%comm, mpi_err)
426 else
427 call lompi_grp_copy_0(sendbuf, recvbuf, count)
428 end if
429 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
430#else
431 call lompi_grp_copy_0(sendbuf, recvbuf, count)
432#endif
433 end subroutine lompi_grp_allreduce_0
434
435 ! ---------------------------------------------------------
436 subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
437 class(mpi_grp_t), intent(in) :: mpi_grp
438 logical, intent(inout) :: recvbuf
439 integer, intent(in) :: count
440 type(mpi_datatype), intent(in) :: datatype
441 type(mpi_op), intent(in) :: op
442
443#if defined(HAVE_MPI)
444 assert(not_in_openmp())
445
446 call mpi_debug_in(mpi_grp%comm, c_mpi_allreduce)
447 if (mpi_grp%comm /= mpi_comm_undefined) then
448 call mpi_allreduce(mpi_in_place, recvbuf, count, datatype, op, &
449 mpi_grp%comm, mpi_err)
451 end if
452 call mpi_debug_out(mpi_grp%comm, c_mpi_allreduce)
453#endif
454 end subroutine lompi_grp_allreduce_inplace_0
455
456 ! ---------------------------------------------------------
457 subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
458 class(mpi_grp_t), intent(in) :: mpi_grp
459 logical, intent(out) :: recvbuf
460 integer, intent(in) :: recvcount
461 type(mpi_datatype),intent(in) :: recvtype
462 integer, intent(in) :: source
463 integer, optional, intent(in) :: tag
464
465 integer :: tag_
467 tag_ = 0
468 if (present(tag)) tag_ = tag
469 if (mpi_grp%comm == mpi_comm_undefined) return
470#if defined(HAVE_MPI)
471 assert(not_in_openmp())
472
473 call mpi_recv(recvbuf, recvcount, recvtype, source, tag_, mpi_grp%comm, mpi_status_ignore, mpi_err)
475#endif
476 end subroutine lompi_grp_recv_0
477
478 ! ---------------------------------------------------------
479 subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
480 class(mpi_grp_t), intent(in) :: mpi_grp
481 logical, intent(out) :: sendbuf
482 integer, intent(in) :: sendcount
483 type(mpi_datatype),intent(in) :: sendtype
484 integer, intent(in) :: dest
485 integer, optional, intent(in) :: tag
486
487 integer :: tag_
488
489 tag_ = 0
490 if (present(tag)) tag_ = tag
491 if (mpi_grp%comm == mpi_comm_undefined) return
492#if defined(HAVE_MPI)
493 assert(not_in_openmp())
494
495 call mpi_send(sendbuf, sendcount, sendtype, dest, tag_, mpi_grp%comm, mpi_err)
497#endif
498 end subroutine lompi_grp_send_0
499
500 ! ---------------------------------------------------------
501 subroutine mpi_grp_wait(mpi_grp, request)
502 class(mpi_grp_t), intent(in) :: mpi_grp
503 type(mpi_request), intent(inout) :: request
504
505 if (mpi_grp%comm == mpi_comm_undefined) return
506#if defined(HAVE_MPI)
507 assert(not_in_openmp())
508
509 call mpi_wait(request, mpi_status_ignore, mpi_err)
511#endif
512 end subroutine mpi_grp_wait
513
514 ! ---------------------------------------------------------
515 subroutine mpi_grp_waitall(mpi_grp, count, requests)
516 class(mpi_grp_t), intent(in) :: mpi_grp
517 integer, intent(in) :: count
518 type(mpi_request), intent(inout) :: requests(:)
519
520 if (mpi_grp%comm == mpi_comm_undefined) return
521#if defined(HAVE_MPI)
522 assert(not_in_openmp())
523
524 call mpi_waitall(count, requests, mpi_statuses_ignore, mpi_err)
526#endif
527 end subroutine mpi_grp_waitall
528
529 ! ---------------------------------------------------------
530 subroutine mpi_grp_abort(mpi_grp)
531 class(mpi_grp_t), intent(in) :: mpi_grp
532
533 if (mpi_grp%comm /= mpi_comm_undefined) then
534#if defined(HAVE_MPI)
535 assert(not_in_openmp())
536
537 ! Abort with an arbitrary error code
538 call mpi_abort(mpi_grp%comm, 999, mpi_err)
540#endif
541 end if
542
543 end subroutine mpi_grp_abort
544
545 ! ---------------------------------------------------------
547 real(real64) function mpi_get_Wtime() result(now)
548#if defined(HAVE_MPI)
549 now = mpi_wtime()
550#else
551 now = loct_clock()
552#endif
553 end function mpi_get_wtime
554
555#include "undef.F90"
556#include "real.F90"
557#include "mpi_inc.F90"
558
559#include "undef.F90"
560#include "complex.F90"
561#include "mpi_inc.F90"
562
563#include "undef.F90"
564#include "integer.F90"
565#include "mpi_inc.F90"
566
567#include "undef.F90"
568#include "integer8.F90"
569#include "mpi_inc.F90"
570
571end module mpi_oct_m
573
574!! Local Variables:
575!! mode: f90
576!! coding: utf-8
577!! 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:624
subroutine impi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4514
subroutine zmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3172
subroutine mpi_grp_duplicate(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:408
subroutine impi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4492
subroutine lmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6064
subroutine lompi_grp_copy_0(sendbuf, recvbuf, count)
Definition: mpi.F90:488
subroutine zmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3034
subroutine blacs_init()
Initialize BLACS to enable use of SCALAPACK.
Definition: mpi.F90:297
real(real64) function, public mpi_get_wtime()
. Returns an elapsed time on the calling processor.
Definition: mpi.F90:641
subroutine dmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1692
subroutine zmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3195
subroutine dmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1807
subroutine zmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3126
subroutine lompi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:467
logical function mpi_grp_is_root(grp)
Definition: mpi.F90:425
subroutine impi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4537
subroutine zmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3080
subroutine mpi_grp_copy(mpi_grp_out, mpi_grp_in)
Definition: mpi.F90:398
subroutine zmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3241
subroutine impi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4652
subroutine impi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4629
subroutine impi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4380
subroutine lompi_grp_allreduce_inplace_0(mpi_grp, recvbuf, count, datatype, op)
Definition: mpi.F90:530
subroutine impi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4582
subroutine zmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3103
subroutine dmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1738
subroutine zmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2946
subroutine dmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1646
subroutine lmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5903
subroutine dmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1556
subroutine impi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4468
subroutine lompi_grp_recv_0(mpi_grp, recvbuf, recvcount, recvtype, source, tag)
Definition: mpi.F90:551
subroutine dmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:1512
subroutine mpi_grp_wait(mpi_grp, request)
Definition: mpi.F90:595
subroutine lmpi_grp_irecv(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5949
type(mpi_grp_t), public mpi_world
Definition: mpi.F90:262
subroutine impi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4606
subroutine mpi_mod_end()
Finalize MPI, and optionally BLACS.
Definition: mpi.F90:323
logical pure function, private not_in_openmp()
Definition: mpi.F90:370
subroutine lmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6087
subroutine mpi_grp_init(grp, comm)
Initialize MPI group instance.
Definition: mpi.F90:341
subroutine zmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:2990
subroutine dmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1624
subroutine impi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:4560
subroutine impi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:4675
subroutine dmpi_grp_isend(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1761
subroutine dmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1784
subroutine zmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3148
subroutine lmpi_grp_irecv_3(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5995
subroutine mpi_grp_barrier(mpi_grp)
Definition: mpi.F90:432
subroutine zmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:3058
subroutine lmpi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:5859
subroutine mpi_init_comm(comm)
Wrapper for MPI_COMM_WORLD initialisation.
Definition: mpi.F90:278
subroutine impi_grp_send_2(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:4424
subroutine dmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1669
integer, public mpi_err
used to store return values of mpi calls
Definition: mpi.F90:265
subroutine lmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6017
subroutine dmpi_grp_irecv_0_int64(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:1600
subroutine lmpi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:5815
subroutine lmpi_grp_isend_0(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6041
subroutine dmpi_grp_isend_0_int64(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:1714
subroutine zmpi_grp_isend_2(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:3218
subroutine mpi_grp_waitall(mpi_grp, count, requests)
Definition: mpi.F90:609
subroutine lompi_grp_allreduce_0(mpi_grp, sendbuf, recvbuf, count, datatype, op)
Definition: mpi.F90:504
subroutine lmpi_grp_irecv_0(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5927
subroutine lompi_grp_send_0(mpi_grp, sendbuf, sendcount, sendtype, dest, tag)
Definition: mpi.F90:573
subroutine mpi_error_check(error)
Definition: mpi.F90:382
subroutine lmpi_grp_isend_3(mpi_grp, sendbuf, sendcount, sendtype, source, request, tag)
Definition: mpi.F90:6110
subroutine chmpi_grp_bcast_0(mpi_grp, buf, cnt, sendtype, root)
Definition: mpi.F90:447
subroutine lmpi_grp_irecv_2(mpi_grp, recvbuf, recvcount, recvtype, source, request, tag)
Definition: mpi.F90:5972
This is defined even when running serial.
Definition: mpi.F90:139
int true(void)