index2filename.cpp
1 #include "index2filename.hpp"
2 #include "../../misc/int2str.hpp"
3 #ifdef RICH_MPI
4 #include <mpi.h>
5 #endif
6 
8 
9 Rubric::Rubric(const string& prefix,
10  const string& postfix):
11  prefix_(prefix), postfix_(postfix) {}
12 
13 string Rubric::operator()(int index)
14 {
15 #ifndef RICH_MPI
16  return prefix_+int2str(index)+postfix_;
17 #else
18  int rank=0;
19  MPI_Comm_rank(MPI_COMM_WORLD,&rank);
20  return prefix_+int2str(index)+"_"+int2str(rank)+postfix_;
21 #endif
22 }
std::string int2str(int n)
Converts an integer to a string.
Definition: int2str.cpp:6
Rubric(const string &prefix, const string &postfix)
Class constructor.
virtual ~Index2FileName(void)
class destructor
string operator()(int index)
Constructs a file name.