4 |
|
#include "io/StatWriter.hpp" |
5 |
|
#include "utils/simError.h" |
6 |
|
|
7 |
< |
StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) mask_(mask){ |
7 |
> |
namespace oopse { |
8 |
> |
StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) : mask_(mask){ |
9 |
|
|
10 |
|
#ifdef IS_MPI |
11 |
|
if(worldRank == 0 ){ |
12 |
|
#endif // is_mpi |
13 |
|
|
14 |
< |
statfile_.open(filename.c_str(), ios::out | ios::trunc ); |
14 |
> |
statfile_.open(filename.c_str(), std::ios::out | std::ios::trunc ); |
15 |
|
|
16 |
|
if( !statfile_ ){ |
17 |
|
|
21 |
|
painCave.isFatal = 1; |
22 |
|
simError(); |
23 |
|
} |
24 |
+ |
|
25 |
+ |
writeTitle(); |
26 |
|
|
27 |
|
#ifdef IS_MPI |
28 |
|
} |
55 |
|
#endif // is_mpi |
56 |
|
|
57 |
|
//write title |
58 |
< |
statfile_ << "#" |
59 |
< |
for (int i =0; i < mask_.size(); ++i) { |
60 |
< |
if (mask_[i]) { |
61 |
< |
statfile_ << "\t" << Stats::getTitle(i) << "(" << Stats::getUnits(i) << ")" |
59 |
< |
} |
58 |
> |
statfile_ << "#"; |
59 |
> |
for (int i =0; i < mask_.size(); ++i) { |
60 |
> |
if (mask_[i]) { |
61 |
> |
statfile_ << "\t" << Stats::getTitle(i) << "(" << Stats::getUnits(i) << ")"; |
62 |
|
} |
63 |
+ |
} |
64 |
|
statfile_ << std::endl; |
65 |
|
|
66 |
|
#ifdef IS_MPI |
68 |
|
#endif // is_mpi |
69 |
|
} |
70 |
|
|
71 |
< |
void StatWriter::writeStat(Stats* s){ |
71 |
> |
void StatWriter::writeStat(const Stats& s){ |
72 |
|
|
73 |
|
#ifdef IS_MPI |
74 |
|
if(worldRank == 0 ){ |
78 |
|
|
79 |
|
for (int i =0; i < mask_.size(); ++i) { |
80 |
|
if (mask_[i]) { |
81 |
< |
statfile_ << "\t" << s->statData[i]; |
81 |
> |
statfile_ << "\t" << s[i]; |
82 |
|
} |
83 |
|
} |
84 |
|
statfile_ << std::endl; |
90 |
|
#endif // is_mpi |
91 |
|
} |
92 |
|
|
93 |
+ |
} |