MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MpiContainer.cc File Reference
#include "MpiContainer.h"
#include "Logger.h"
#include "SpeciesHandler.h"
#include "GeneralDefine.h"

Go to the source code of this file.

Functions

void initialiseMPI ()
 Inialises the MPI library. More...
 

Function Documentation

void initialiseMPI ( )

Inialises the MPI library.

Definition at line 133 of file MpiContainer.cc.

References MPIContainer::deleteMercuryMPITypes(), MPIContainer::Instance(), and PROCESSOR_ID.

Referenced by DPMBase::constructor(), printError(), printInfo(), and printMessage().

134 {
135 #ifdef MERCURY_USE_MPI
136  //Check if MPI is already initialised
137  if (!MPI::Is_initialized())
138  {
139  MPI::Init();
140  MPIContainer& communicator = MPIContainer::Instance();
141  if (PROCESSOR_ID == 0)
142  {
143  std::cout << "MPI has been initialised" << std::endl;
144  }
145 
146  //MPI should be finalised at the end of any program.
147  std::atexit([]()
148  {
149  MPIContainer& communicator = MPIContainer::Instance();
150  communicator.deleteMercuryMPITypes();
151  MPI::Finalize();
152  if (PROCESSOR_ID == 0)
153  {
154  std::cout << "MPI has been finalised" << std::endl;
155  }
156  });
157  }
158 #endif
159 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:125
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
#define PROCESSOR_ID
Definition: GeneralDefine.h:63
void deleteMercuryMPITypes()
Deletes the MercuryMPITypes.
Definition: MpiContainer.h:565