28 #include <Teuchos_DefaultComm.hpp>
38 int main(
int narg,
char *arg[])
40 Tpetra::ScopeGuard tscope(&narg, &arg);
41 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
43 int rank = comm->getRank();
44 int nprocs = comm->getSize();
53 bool iPrint = (rank%2 == 0);
54 bool someOnePrints =
true;
60 rank, iPrint, std::cout, someOnePrints, string(
"units"), 10);
62 catch(std::exception &e){
74 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
75 std::cout <<
"Even ranks only participate." << std::endl;
79 intmom->
print(
string(
"number of things"), 10);
80 intmom->
print(
string(
"number of other things"), 5);
82 catch(std::exception &e){
99 rank, iPrint, std::cout, someOnePrints, string(
"dollars"), 10);
101 catch(std::exception &e){
113 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
114 std::cout <<
"All ranks participate." << std::endl;
118 floatmom->
print(
string(
"Price of things"), 10.10);
119 floatmom->
print(
string(
"Price of other things"), 25.25);
121 catch(std::exception &e){
131 iPrint = (rank == 0);
132 someOnePrints =
true;
135 std::ios_base::openmode flags = std::ios_base::out & std::ios_base::trunc;
137 std::ofstream outF(
"testMetricFile.txt", flags);
142 catch(std::exception &e){
149 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
150 std::cout <<
"Rank zero only participates" << std::endl;
154 doublemom->
print(
string(
"Time to do something"),
156 doublemom->
print(
string(
"Time to do something else"),
159 catch(std::exception &e){
170 std::ifstream inF(
"testMetricFile.txt");
172 while (getline(inF, s)){
173 std::cout << s << std::endl;
176 system(
"rm testMetricFile.txt");
184 std::cout <<
"PASS" << std::endl;
Defines the MetricOutputManager class.
void print(const std::string &msg, const T val)
Print a line of information.
MetricOutputManager handles output of profiling messages.
Defines Parameter related enumerators, declares functions.
#define TEST_FAIL_AND_EXIT(comm, ok, s, code)
int main(int narg, char **arg)
common code used by tests
bool getMetricsOn() const
Return true if any process outputs metrics.
static const std::string fail