78int main(
int narg,
char *arg[])
80 Tpetra::ScopeGuard tscope(&narg, &arg);
81 Teuchos::RCP<const Teuchos::Comm<int> > comm = Tpetra::getDefaultComm();
83 int rank = comm->getRank();
84 int nprocs = comm->getSize();
87 std::set<string> basicMsgs, detailedMsgs, verboseMsgs;
88 std::set<string>::iterator next;
90 std::ostringstream oss;
91 oss <<
"Proc " << rank <<
": This is a ";
93 basicMsgs.insert(oss.str()+
string(
" basic message."));
94 basicMsgs.insert(oss.str()+
string(
"another basic message."));
95 detailedMsgs.insert(oss.str()+
string(
" detailed message."));
96 detailedMsgs.insert(oss.str()+
string(
"another detailed message."));
97 verboseMsgs.insert(oss.str()+
string(
" verbose message."));
98 verboseMsgs.insert(oss.str()+
string(
"another verbose message."));
105 bool iPrint = (rank%2 == 0);
109 for (
int i = 0; i < numLevels; i++){
116 catch(std::exception &e){
123 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
124 std::cout <<
"Even ranks participate, output level is: " << level << std::endl;
130 for (next=basicMsgs.begin(); next != basicMsgs.end(); ++next){
131 dm->print(BASIC_STATUS, *next);
134 for (next=detailedMsgs.begin(); next != detailedMsgs.end(); ++next){
135 dm->print(DETAILED_STATUS, *next);
138 for (next=verboseMsgs.begin(); next != verboseMsgs.end(); ++next){
139 dm->print(VERBOSE_DETAILED_STATUS, *next);
143 catch(std::exception &e){
154 iPrint = (rank == 0);
157 for (
int i = 0; i < numLevels; i++){
161 std::ios_base::openmode flags = std::ios_base::out & std::ios_base::trunc;
163 std::ofstream outF(
"testFile.txt", flags);
168 catch(std::exception &e){
175 std::cout <<
"\nThere are " << nprocs <<
" processes. ";
176 std::cout <<
"Rank zero only participates, output level is: ";
177 std::cout << level << std::endl;
181 for (next=basicMsgs.begin(); next != basicMsgs.end(); ++next){
182 dm->print(BASIC_STATUS, *next);
186 for (next=detailedMsgs.begin(); next != detailedMsgs.end(); ++next){
187 dm->print(DETAILED_STATUS, *next);
191 for (next=verboseMsgs.begin(); next != verboseMsgs.end(); ++next){
192 dm->print(VERBOSE_DETAILED_STATUS, *next);
196 catch(std::exception &e){
209 std::ifstream inF(
"testFile.txt");
211 while (getline(inF, s)){
212 std::cout << s << std::endl;
215 system(
"rm testFile.txt");
222 std::cout <<
"PASS" << std::endl;