OGS
MPI.cpp
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2
// SPDX-License-Identifier: BSD-3-Clause
3
4
#include "
MPI.h
"
5
6
#ifdef USE_PETSC
7
namespace
BaseLib::MPI
8
{
9
MPI_Comm
OGS_COMM_WORLD
= MPI_COMM_WORLD;
10
}
11
#endif
// USE_PETSC
12
13
namespace
BaseLib::MPI
14
{
15
Setup::Setup
(
int
argc,
char
* argv[])
16
{
17
#ifdef USE_PETSC
18
{
19
int
mpi_init;
20
MPI_Initialized(&mpi_init);
21
if
(mpi_init == 1)
22
{
23
OGS_FATAL
(
24
"MPI has already been initialized. OGS does not support "
25
"multiple MPI sessions in the same process"
);
26
}
27
}
28
29
{
30
int
mpi_fin;
31
MPI_Finalized(&mpi_fin);
32
if
(mpi_fin == 1)
33
{
34
OGS_FATAL
(
35
"MPI has already been shut down. OGS does not support multiple "
36
"MPI sessions in the same process"
);
37
}
38
}
39
40
MPI_Init(&argc, &argv);
41
#else
42
(void)argc;
43
(void)argv;
44
#endif
45
}
46
47
Setup::~Setup
()
48
{
49
#ifdef USE_PETSC
50
int
mpi_init;
51
MPI_Initialized(&mpi_init);
52
if
(mpi_init == 1)
53
{
54
MPI_Finalize();
55
}
56
#endif
// USE_PETSC
57
}
58
}
// namespace BaseLib::MPI
OGS_FATAL
#define OGS_FATAL(...)
Definition
Error.h:19
MPI.h
BaseLib::MPI
Definition
MPI.cpp:8
BaseLib::MPI::OGS_COMM_WORLD
MPI_Comm OGS_COMM_WORLD
Definition
MPI.cpp:9
BaseLib::MPI::Setup::~Setup
~Setup()
Definition
MPI.cpp:47
BaseLib::MPI::Setup::Setup
Setup(int argc, char *argv[])
Definition
MPI.cpp:15
BaseLib
MPI.cpp
Generated by
1.14.0