Simpatico  v1.10
MpiFileIo.cpp
1 /*
2 * Util Package - C++ Utilities for Scientific Computation
3 *
4 * Copyright 2010 - 2017, The Regents of the University of Minnesota
5 * Distributed under the terms of the GNU General Public License.
6 */
7 
8 #include "MpiFileIo.h"
9 
10 namespace Util
11 {
12 
13  /*
14  * Constructor.
15  *
16  * Note: Default constructor for _indent string creates an empty string.
17  */
19  : isIoProcessor_(true)
20  #ifdef UTIL_MPI
21  , communicatorPtr_(0)
22  #endif
23  {}
24 
25  /*
26  * Copy constructor.
27  */
29  : isIoProcessor_(other.isIoProcessor_)
30  #ifdef UTIL_MPI
31  , communicatorPtr_(other.communicatorPtr_)
32  #endif
33  {}
34 
35  #ifdef UTIL_MPI
36  void MpiFileIo::setIoCommunicator(MPI::Intracomm& communicator)
37  {
38  communicatorPtr_ = &communicator;
39  if (communicator.Get_rank() == 0) {
40  isIoProcessor_ = true;
41  } else {
42  isIoProcessor_ = false;
43  }
44  }
45 
47  {
48  communicatorPtr_ = 0;
49  isIoProcessor_ = true;
50  }
51  #endif
52 
53 }
void setIoCommunicator(MPI::Intracomm &communicator)
Set the communicator.
Definition: MpiFileIo.cpp:36
Identifies whether this processor may do file I/O.
Definition: MpiFileIo.h:33
Utility classes for scientific computation.
Definition: accumulators.mod:1
void clearCommunicator()
Clear (nullify) the communicator.
Definition: MpiFileIo.cpp:46
MpiFileIo()
Constructor.
Definition: MpiFileIo.cpp:18