Debian Codegraph @

dune/uggrid/parallel/ppif/ppifcontext.cc

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LGPL-2.1-or-later
3 #include "config.h"
4
5 #include "ppifcontext.hh"
6
7 namespace PPIF {
8
9 #if ModelP
10 PPIFContext
11 ::PPIFContext()
12 : PPIFContext(MPI_COMM_WORLD)
13 {
14 /* Nothing */
15 }
16 #else
17 PPIFContext
18 ::PPIFContext()
19 {
20 /* Nothing */
21 }
22 #endif
23
24 PPIFContext
25 ::~PPIFContext()
26 {
27 #if ModelP
28 ExitPPIF(*this);
29
30 int finalized;
31 MPI_Finalized(&finalized);
32
33 if (not finalized)
34 MPI_Comm_free(&comm_);
35 #endif
36 }
37
38 #if ModelP
39 PPIFContext
40 ::PPIFContext(const MPI_Comm& comm)
41 {
42 MPI_Comm_dup(comm, &comm_);
43 MPI_Comm_rank(comm_, &me_);
44 MPI_Comm_size(comm_, &procs_);
45
46 InitPPIF(*this);
47 }
48 #endif
49
50 } /* namespace PPIF */