55 int main(
int argc,
char* argv[])
61 std::ostream &out = ( procRank == 0 ? std::cout : blackhole );
73 "This example program demonstrates how to use this Teuchos::CommandLineProcessor class\n" 74 "to get options from the command-line and print this help messange automatically.\n" 84 My_CLP.
setOption(
"iterations", &NumIters,
"Number of iterations");
87 My_CLP.
setOption(
"long-matrix-dim", &MatrixDim,
"Matrix dimension (long)");
88 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 90 My_CLP.
setOption(
"long-long-matrix-dim", &MatrixDim2,
"Matrix dimension (long long)");
93 double Tolerance = 1e-10;
94 My_CLP.
setOption(
"tolerance", &Tolerance,
"Tolerance");
96 std::string Solver =
"GMRES";
97 My_CLP.
setOption(
"solver", &Solver,
"Linear solver");
99 bool Precondition =
true;
100 My_CLP.
setOption(
"precondition",
"no-precondition",
101 &Precondition,
"Preconditioning flag");
103 const int num_speed_values = 3;
105 const char* speed_opt_names[] = {
"slow",
"medium",
"fast" };
109 num_speed_values, speed_opt_values, speed_opt_names,
110 "Speed of our solver" 135 parseReturn= My_CLP.
parse( argc, argv );
145 out <<
"\nPrinting help message with new values of command-line arguments ...\n\n";
150 out <<
"\nPrinting user options after parsing ...\n\n";
151 out <<
"NumIters = " << NumIters << std::endl;
152 out <<
"MatrixDim = " << MatrixDim << std::endl;
153 #ifdef HAVE_TEUCHOS_LONG_LONG_INT 154 out <<
"MatrixDim2 = " << MatrixDim2 << std::endl;
156 out <<
"Tolerance = " << Tolerance << std::endl;
157 out <<
"Solver = \"" << Solver <<
"\"\n";
158 out <<
"Precondition = " << Precondition << std::endl;
159 out <<
"Speed = " << Speed << std::endl;
166 out <<
"\nEnd Result: TEST PASSED" << std::endl;
168 return ( success ? 0 : 1 );
static int getRank()
The rank of the calling process in MPI_COMM_WORLD.
void recogniseAllOptions(const bool &recogniseAllOptions)
Set if all options must be recognized or not.
basic_ostream<> subclass that does nothing but discard output.
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
Initialize, finalize, and query the global MPI session.
void setOption(const char option_true[], const char option_false[], bool *option_val, const char documentation[]=NULL)
Set a boolean option.
EParseCommandLineReturn parse(int argc, char *argv[], std::ostream *errout=&std::cerr) const
Parse a command line.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
static T max()
Returns a value designating the maximum value accessible by code using OrdinalTraits.
void throwExceptions(const bool &throwExceptions)
Set if an std::exception is thrown, there is a parse error, or help is printed.
std::string Teuchos_Version()
int main(int argc, char *argv[])
EParseCommandLineReturn
Return value for CommandLineProcessor::parse(). Note: These enums are all given non-negative values s...
Defines basic traits for the ordinal field type.
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
void setDocString(const char doc_string[])
Set a documentation sting for the entire program printed when –help is specified.
void printHelpMessage(const char program_name[], std::ostream &out) const
Print the help message.
Class that helps parse command line input arguments from (argc,argv[]) and set options.