43int main(
int narg,
char *arg[])
45 Tpetra::ScopeGuard tscope(&narg, &arg);
46 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
48 int rank = comm->getRank();
49 int nprocs = comm->getSize();
52 std::set<string> basicMsgs, detailedMsgs, verboseMsgs;
53 std::set<string>::iterator next;
55 std::ostringstream oss;
56 oss <<
"Proc " << rank <<
": This is a ";
58 basicMsgs.insert(oss.str()+
string(
" basic message."));
59 basicMsgs.insert(oss.str()+
string(
"another basic message."));
60 detailedMsgs.insert(oss.str()+
string(
" detailed message."));
61 detailedMsgs.insert(oss.str()+
string(
"another detailed message."));
62 verboseMsgs.insert(oss.str()+
string(
" verbose message."));
63 verboseMsgs.insert(oss.str()+
string(
"another verbose message."));
70 bool iPrint = (rank%2 == 0);
74 for (
int i = 0; i < numLevels; i++){
81 catch(std::exception &e){
88 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
89 std::cout <<
"Even ranks participate, output level is: " << level << std::endl;
95 for (next=basicMsgs.begin(); next != basicMsgs.end(); ++next){
96 dm->
print(BASIC_STATUS, *next);
99 for (next=detailedMsgs.begin(); next != detailedMsgs.end(); ++next){
100 dm->
print(DETAILED_STATUS, *next);
103 for (next=verboseMsgs.begin(); next != verboseMsgs.end(); ++next){
104 dm->
print(VERBOSE_DETAILED_STATUS, *next);
108 catch(std::exception &e){
119 iPrint = (rank == 0);
122 for (
int i = 0; i < numLevels; i++){
126 std::ios_base::openmode flags = std::ios_base::out & std::ios_base::trunc;
128 std::ofstream outF(
"testFile.txt", flags);
133 catch(std::exception &e){
140 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
141 std::cout <<
"Rank zero only participates, output level is: ";
142 std::cout << level << std::endl;
146 for (next=basicMsgs.begin(); next != basicMsgs.end(); ++next){
147 dm->
print(BASIC_STATUS, *next);
151 for (next=detailedMsgs.begin(); next != detailedMsgs.end(); ++next){
152 dm->
print(DETAILED_STATUS, *next);
156 for (next=verboseMsgs.begin(); next != verboseMsgs.end(); ++next){
157 dm->
print(VERBOSE_DETAILED_STATUS, *next);
161 catch(std::exception &e){
174 std::ifstream inF(
"testFile.txt");
176 while (getline(inF, s)){
177 std::cout << s << std::endl;
180 system(
"rm testFile.txt");
187 std::cout <<
"PASS" << std::endl;