1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
//
#include "ProcData.hpp"

ProcData *ProcData::instance_ = 0;
int ProcData::isInitialized = 0;

int ProcData::initialize(int &argc, char **&argv) 
{
  if (isInitialized == 1) return 1;

#ifdef USE_MPI  
  int ierror;
  ierror = MPI_Init(&argc, &argv);<--- ierror is assigned
  ierror = MPI_Comm_rank(MPI_COMM_WORLD, &myRank);<--- ierror is overwritten<--- ierror is assigned
  ierror = MPI_Comm_size(MPI_COMM_WORLD, &numProcs);<--- ierror is overwritten
#else
  myRank = 0;
  numProcs = 1;
#endif
  
/* initialize designated rank of master */  
  masterRank = 0;

  isInitialized = 1;

  return ierror;
}

ProcData::~ProcData() 
{
#ifdef USE_MPI
  MPI_Finalize();
#endif

  isInitialized = 0;
}