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