| 1 | < | /* | 
| 1 | > | /* | 
| 2 |  | * Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. | 
| 3 |  | * | 
| 4 |  | * The University of Notre Dame grants you ("Licensee") a | 
| 46 |  | #include "utils/simError.h" | 
| 47 |  |  | 
| 48 |  | namespace oopse { | 
| 49 | < | StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) : mask_(mask){ | 
| 49 | > | StatWriter::StatWriter( const std::string& filename, const StatsBitSet& mask) : mask_(mask){ | 
| 50 |  |  | 
| 51 |  | #ifdef IS_MPI | 
| 52 | < | if(worldRank == 0 ){ | 
| 52 | > | if(worldRank == 0 ){ | 
| 53 |  | #endif // is_mpi | 
| 54 |  |  | 
| 55 | < | statfile_.open(filename.c_str(), std::ios::out | std::ios::trunc ); | 
| 55 | > | statfile_.open(filename.c_str(), std::ios::out | std::ios::trunc ); | 
| 56 |  |  | 
| 57 | < | if( !statfile_ ){ | 
| 57 | > | if( !statfile_ ){ | 
| 58 |  |  | 
| 59 | < | sprintf( painCave.errMsg, | 
| 60 | < | "Could not open \"%s\" for stat output.\n", | 
| 61 | < | filename.c_str()); | 
| 62 | < | painCave.isFatal = 1; | 
| 63 | < | simError(); | 
| 64 | < | } | 
| 59 | > | sprintf( painCave.errMsg, | 
| 60 | > | "Could not open \"%s\" for stat output.\n", | 
| 61 | > | filename.c_str()); | 
| 62 | > | painCave.isFatal = 1; | 
| 63 | > | simError(); | 
| 64 | > | } | 
| 65 |  |  | 
| 66 | < | writeTitle(); | 
| 66 | > | writeTitle(); | 
| 67 |  |  | 
| 68 |  | #ifdef IS_MPI | 
| 69 | < | } | 
| 69 | > | } | 
| 70 |  |  | 
| 71 | < | sprintf( checkPointMsg, | 
| 72 | < | "Sucessfully opened output file for stating.\n"); | 
| 73 | < | MPIcheckPoint(); | 
| 71 | > | sprintf( checkPointMsg, | 
| 72 | > | "Sucessfully opened output file for stating.\n"); | 
| 73 | > | MPIcheckPoint(); | 
| 74 |  | #endif // is_mpi | 
| 75 |  |  | 
| 76 | < | } | 
| 76 | > | } | 
| 77 |  |  | 
| 78 | < | StatWriter::~StatWriter( ){ | 
| 78 | > | StatWriter::~StatWriter( ){ | 
| 79 |  |  | 
| 80 |  | #ifdef IS_MPI | 
| 81 | < | if(worldRank == 0 ){ | 
| 81 | > | if(worldRank == 0 ){ | 
| 82 |  | #endif // is_mpi | 
| 83 |  |  | 
| 84 | < | statfile_.close(); | 
| 84 | > | statfile_.close(); | 
| 85 |  |  | 
| 86 |  | #ifdef IS_MPI | 
| 87 | < | } | 
| 87 | > | } | 
| 88 |  | #endif // is_mpi | 
| 89 | < | } | 
| 89 | > | } | 
| 90 |  |  | 
| 91 | < | void StatWriter::writeTitle() { | 
| 91 | > | void StatWriter::writeTitle() { | 
| 92 |  |  | 
| 93 |  |  | 
| 94 |  | #ifdef IS_MPI | 
| 95 |  | if(worldRank == 0 ){ | 
| 96 |  | #endif // is_mpi | 
| 97 |  |  | 
| 98 | < | //write title | 
| 99 | < | statfile_ << "#"; | 
| 100 | < | for (int i =0; i < mask_.size(); ++i) { | 
| 101 | < | if (mask_[i]) { | 
| 102 | < | statfile_ << "\t" << Stats::getTitle(i) << "(" << Stats::getUnits(i) << ")"; | 
| 103 | < | } | 
| 104 | < | } | 
| 105 | < | statfile_ << std::endl; | 
| 98 | > | //write title | 
| 99 | > | statfile_ << "#"; | 
| 100 | > | for (int i =0; i < mask_.size(); ++i) { | 
| 101 | > | if (mask_[i]) { | 
| 102 | > | statfile_ << "\t" << Stats::getTitle(i) << "(" << Stats::getUnits(i) << ")"; | 
| 103 | > | } | 
| 104 | > | } | 
| 105 | > | statfile_ << std::endl; | 
| 106 |  |  | 
| 107 |  | #ifdef IS_MPI | 
| 108 | < | } | 
| 108 | > | } | 
| 109 |  | #endif // is_mpi | 
| 110 | < | } | 
| 110 | > | } | 
| 111 |  |  | 
| 112 | < | void StatWriter::writeStat(const Stats& s){ | 
| 112 | > | void StatWriter::writeStat(const Stats& s){ | 
| 113 |  |  | 
| 114 |  | #ifdef IS_MPI | 
| 115 |  | if(worldRank == 0 ){ | 
| 116 |  | #endif // is_mpi | 
| 117 |  |  | 
| 118 | < | statfile_.precision(8); | 
| 118 | > | statfile_.precision(8); | 
| 119 |  |  | 
| 120 | < | for (int i =0; i < mask_.size(); ++i) { | 
| 121 | < | if (mask_[i]) { | 
| 122 | < | statfile_ << "\t" << s[i]; | 
| 123 | < | } | 
| 124 | < | } | 
| 125 | < | statfile_ << std::endl; | 
| 120 | > | for (int i =0; i < mask_.size(); ++i) { | 
| 121 | > | if (mask_[i]) { | 
| 122 | > | statfile_ << "\t" << s[i]; | 
| 123 | > | } | 
| 124 | > | } | 
| 125 | > | statfile_ << std::endl; | 
| 126 |  |  | 
| 127 | < | statfile_.flush(); | 
| 127 | > | statfile_.flush(); | 
| 128 |  |  | 
| 129 |  | #ifdef IS_MPI | 
| 130 |  | } | 
| 131 |  | #endif // is_mpi | 
| 132 | < | } | 
| 132 | > | } | 
| 133 |  |  | 
| 134 |  | } |