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
7namespace BaseLib::MPI
8{
9MPI_Comm OGS_COMM_WORLD = MPI_COMM_WORLD;
10}
11#endif // USE_PETSC
12
13namespace BaseLib::MPI
14{
15Setup::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 {
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 {
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
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
#define OGS_FATAL(...)
Definition Error.h:19
MPI_Comm OGS_COMM_WORLD
Definition MPI.cpp:9
Setup(int argc, char *argv[])
Definition MPI.cpp:15