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 44 : Environment::Environment(int& argc, char**& argv, const MPI_Comm& comm)
12 44 : : comm_m(comm) {
13 44 : if (!initialized()) {
14 44 : MPI_Init(&argc, &argv);
15 : }
16 44 : }
17 :
18 44 : Environment::~Environment() {
19 44 : if (!finalized()) {
20 44 : MPI_Finalize();
21 : }
22 44 : }
23 :
24 44 : bool Environment::initialized() {
25 44 : int flag = 0;
26 44 : MPI_Initialized(&flag);
27 44 : return (flag != 0);
28 : }
29 :
30 44 : bool Environment::finalized() {
31 44 : int flag = 0;
32 44 : MPI_Finalized(&flag);
33 44 : return (flag != 0);
34 : }
35 : } // namespace mpi
36 : } // namespace ippl
|