60 <<
"\n***\n*** Printing to default OStream before main() even starts!\n***\n\n"
71 int main(
int argc,
char* argv[])
90 CommandLineProcessor clp;
91 clp.throwExceptions(
false);
92 clp.addOutputSetupOptions(
true);
93 CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
94 if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL )
return parse_return;
98 out = VerboseObjectBase::getDefaultOStream();
110 *out <<
"\n***\n*** Testing VerboseObject base class use\n***\n";
112 *out <<
"\n*** Algorithm output with default formatting\n\n";
115 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
116 *out <<
"\n*** Algorithm output with no front matter\n\n";
117 out->setShowAllFrontMatter(
false);
120 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
121 *out <<
"\n*** Algorithm output with processor ranks\n\n";
122 out->setShowAllFrontMatter(
false).setShowProcRank(
true);
125 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
126 *out <<
"\n*** Algorithm output with line prefix names\n\n";
127 out->setShowAllFrontMatter(
false).setShowLinePrefix(
true);
130 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
131 *out <<
"\n*** Algorithm output with tab counts\n\n";
132 out->setShowAllFrontMatter(
false).setShowTabCount(
true);
135 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
136 *out <<
"\n*** Algorithm output with line prefix names and tab counts\n\n";
137 out->setShowAllFrontMatter(
false).setShowLinePrefix(
true).setShowTabCount(
true);
140 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
141 *out <<
"\n*** Algorithm output with processor ranks and line prefix names\n\n";
142 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowLinePrefix(
true);
145 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
146 *out <<
"\n*** Algorithm output with processor ranks and tab counts\n\n";
147 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowTabCount(
true);
150 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
151 *out <<
"\n*** Algorithm output with processor ranks, line prefix names, and tab counts\n\n";
152 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowLinePrefix(
true).setShowTabCount(
true);
155 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
156 *out <<
"\n*** Algorithm output with processor ranks, line prefix names, and tab counts but no output for AlgorithmA\n\n";
158 out->setShowAllFrontMatter(
false).setShowProcRank(
true).setShowLinePrefix(
true).setShowTabCount(
true);
162 *out <<
"\n*** Running the algorithm by setting parameters in the parameter list ...\n";
166 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
167 *out <<
"\n*** Set AlgorithmA verbosity level to extreme through a parameter list\n\n";
168 algoParams.
sublist(
"VerboseObject").
set(
"Verbosity Level",
"extreme");
169 algoParams.
set(
"Algo Type",
"Harry");
170 algoParams.
set(
"Algo Tol",0.3);
173 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
174 *out <<
"\n*** Set AlgorithmA verbosity level to medium and the output file \"AlgorithmA.out\" through a parameter list\n\n";
175 algoParams.
sublist(
"VerboseObject").
set(
"Verbosity Level",
"medium");
176 algoParams.
sublist(
"VerboseObject").
set(
"Output File",
"AlgorithmA.out");
177 algoParams.
set(
"Algo Type",
"John");
178 algoParams.
set(
"Algo Tol",10);
181 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
182 *out <<
"\n*** Set AlgorithmA verbosity level to low and the output back to default through a parameter list\n\n";
183 algoParams.
sublist(
"VerboseObject").
set(
"Verbosity Level",
"low");
184 algoParams.
sublist(
"VerboseObject").
set(
"Output File",
"none");
185 algoParams.
set(
"Algo Tol",
"20");
188 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1);
189 *out <<
"\n***\n*** Do some more simple tests to make sure things work correctly\n***\n\n";
196 out->setShowAllFrontMatter(
false).setShowProcRank(numProcs>1).setShowTabCount(
true);
199 *out <<
"\n***\n*** Testing basic FancyOStream and OSTab classes\n***\n\n";
201 *out <<
"\nThis is very good output\nand I like it a lot!\n";
204 *out <<
"This should";
206 *out <<
" printed on";
208 *out <<
" line two lines below the above output!\n";
213 *out <<
"This should be indented one tab!\n";
216 *out <<
"This should be indented two tabs!\n";
217 *out2 <<
"This should be indented zero tabs from out2!\n";
220 *out <<
"This should be indented two tabs!\n";
221 *out2 <<
"This should be indented one tab from out2!\n";
224 *out <<
"This should be indented one tab!\n";
226 *out <<
"This should be indented zero tabs!\n";
230 *out <<
"\n***\n*** Now outputting the latent output that was sent to out2\n***\n\n"
231 <<
dyn_cast<std::ostringstream>(*out2->getOStream()).str();
234 *out <<
"\nEnd Result: TEST PASSED" << std::endl;
239 return ( success ? 0 : 1 );
RCP< T > rcp(const boost::shared_ptr< T > &sptr)
Conversion function that takes in a boost::shared_ptr object and spits out a Teuchos::RCP object...
static int getRank()
The rank of the calling process in MPI_COMM_WORLD.
EVerbosityLevel
Verbosity level.
void setParameterList(Teuchos::RCP< Teuchos::ParameterList > const ¶mList)
Set parameters from a parameter list and return with default values.
static int getNProc()
The number of processes in MPI_COMM_WORLD.
static void setDefaultVerbLevel(const EVerbosityLevel defaultVerbLevel)
Set the default verbosity level.
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
Templated set method.
Initialize, finalize, and query the global MPI session.
basic_OSTab< char > OSTab
T * getRawPtr() const
Get the raw C++ pointer to the underlying object.
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
Deprecated.
static EVerbosityLevel getDefaultVerbLevel()
Get the default verbosity level.
T_To & dyn_cast(T_From &from)
Dynamic casting utility function meant to replace dynamic_cast<T&> by throwing a better documented er...
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static RCP< FancyOStream > getDefaultOStream()
Get the default output stream object.
TestVerboseObjectBaseInitialization()
Teuchos::RCP< const Teuchos::ParameterList > getParameterList() const
Get const version of the parameter list that was set using setParameterList().
Non-templated base class for objects that can print their activities to a stream. ...
std::string Teuchos_Version()
A list of parameters of arbitrary type.
static TestVerboseObjectBaseInitialization testVerboseObjectBaseInitialization
int main(int argc, char *argv[])
basic_FancyOStream< char > FancyOStream
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
#define TEUCHOS_TEST_FOR_EXCEPT_PRINT(throw_exception_test, out_ptr)
This macro is the same as TEUCHOS_TEST_FOR_EXCEPT() except that the exception will be caught...
ParameterList & sublist(const std::string &name, bool mustAlreadyExist=false, const std::string &docString="")
Creates an empty sublist and returns a reference to the sublist name. If the list already exists...
Smart reference counting pointer class for automatic garbage collection.
#define TEUCHOS_ASSERT(assertion_test)
This macro is throws when an assert fails.
void doAlgorithmStuff(Teuchos::ParameterList *algoParams=0)
virtual RCP< FancyOStream > getOStream() const
Return the output stream to be used for out for *this object.
Class that helps parse command line input arguments from (argc,argv[]) and set options.
Generate output as defined by the object.