Branch data Line data Source code
1 : : //
2 : : // Class Environment
3 : : //
4 : : #include "Ippl.h"
5 : :
6 : : #include "Environment.h"
7 : :
8 : : namespace ippl {
9 : : namespace mpi {
10 : :
11 : 836 : Environment::Environment(int& argc, char**& argv, const MPI_Comm& comm)
12 : 836 : : comm_m(comm) {
13 [ + - ]: 836 : if (!initialized()) {
14 : 836 : MPI_Init(&argc, &argv);
15 : : }
16 : 836 : }
17 : :
18 : 836 : Environment::~Environment() {
19 [ + - ]: 836 : if (!finalized()) {
20 : 836 : MPI_Finalize();
21 : : }
22 : 836 : }
23 : :
24 : 836 : bool Environment::initialized() {
25 : 836 : int flag = 0;
26 [ + - ]: 836 : MPI_Initialized(&flag);
27 : 836 : return (flag != 0);
28 : : }
29 : :
30 : 836 : bool Environment::finalized() {
31 : 836 : int flag = 0;
32 [ + - ]: 836 : MPI_Finalized(&flag);
33 : 836 : return (flag != 0);
34 : : }
35 : : } // namespace mpi
36 : : } // namespace ippl
|