73int main(
int narg,
char *arg[])
75 Tpetra::ScopeGuard tscope(&narg, &arg);
76 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
78 int rank = comm->getRank();
79 int nprocs = comm->getSize();
82 MetricOutputManager<int> *intmom = NULL;
83 MetricOutputManager<float> *floatmom = NULL;
84 MetricOutputManager<double> *doublemom = NULL;
88 bool iPrint = (rank%2 == 0);
89 bool someOnePrints =
true;
94 intmom =
new MetricOutputManager<int>(
95 rank, iPrint, std::cout, someOnePrints,
string(
"units"), 10);
97 catch(std::exception &e){
103 if (intmom->getMetricsOn() !=
true)
109 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
110 std::cout <<
"Even ranks only participate." << std::endl;
114 intmom->print(
string(
"number of things"), 10);
115 intmom->print(
string(
"number of other things"), 5);
117 catch(std::exception &e){
128 someOnePrints =
true;
132 floatmom =
new MetricOutputManager<float>(
134 rank, iPrint, std::cout, someOnePrints,
string(
"dollars"), 10);
136 catch(std::exception &e){
142 if (floatmom->getMetricsOn() !=
true)
148 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
149 std::cout <<
"All ranks participate." << std::endl;
153 floatmom->print(
string(
"Price of things"), 10.10);
154 floatmom->print(
string(
"Price of other things"), 25.25);
156 catch(std::exception &e){
166 iPrint = (rank == 0);
167 someOnePrints =
true;
170 std::ios_base::openmode flags = std::ios_base::out & std::ios_base::trunc;
172 std::ofstream outF(
"testMetricFile.txt", flags);
175 doublemom =
new MetricOutputManager<double>( rank, iPrint, outF, someOnePrints,
string(
"microseconds"), 10);
177 catch(std::exception &e){
184 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
185 std::cout <<
"Rank zero only participates" << std::endl;
189 doublemom->print(
string(
"Time to do something"),
191 doublemom->print(
string(
"Time to do something else"),
194 catch(std::exception &e){
205 std::ifstream inF(
"testMetricFile.txt");
207 while (getline(inF, s)){
208 std::cout << s << std::endl;
211 system(
"rm testMetricFile.txt");
219 std::cout <<
"PASS" << std::endl;