63 #include <Teuchos_DefaultComm.hpp> 74 int main(
int argc,
char *argv[])
76 Teuchos::GlobalMPISession session(&argc, &argv);
77 Teuchos::RCP<const Teuchos::Comm<int> > comm =
78 Teuchos::DefaultComm<int>::getComm();
80 int rank = comm->getRank();
81 int nprocs = comm->getSize();
90 bool iPrint = (rank%2 == 0);
91 bool someOnePrints =
true;
97 rank, iPrint, std::cout, someOnePrints, string(
"units"), 10);
99 catch(std::exception &e){
111 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
112 std::cout <<
"Even ranks only participate." << std::endl;
116 intmom->
print(
string(
"number of things"), 10);
117 intmom->
print(
string(
"number of other things"), 5);
119 catch(std::exception &e){
130 someOnePrints =
true;
136 rank, iPrint, std::cout, someOnePrints, string(
"dollars"), 10);
138 catch(std::exception &e){
150 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
151 std::cout <<
"All ranks participate." << std::endl;
155 floatmom->
print(
string(
"Price of things"), 10.10);
156 floatmom->
print(
string(
"Price of other things"), 25.25);
158 catch(std::exception &e){
168 iPrint = (rank == 0);
169 someOnePrints =
true;
172 ios_base::openmode flags = ios_base::out & ios_base::trunc;
174 ofstream outF(
"testMetricFile.txt", flags);
179 catch(std::exception &e){
186 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
187 std::cout <<
"Rank zero only participates" << std::endl;
191 doublemom->
print(
string(
"Time to do something"),
193 doublemom->
print(
string(
"Time to do something else"),
196 catch(std::exception &e){
207 ifstream inF(
"testMetricFile.txt");
209 while (getline(inF, s)){
210 std::cout << s << std::endl;
213 system(
"rm testMetricFile.txt");
221 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)
bool getMetricsOn() const
Return true if any process outputs metrics.
common code used by tests
int main(int argc, char *argv[])
static const std::string fail