Didasko  Development
 All Classes Namespaces Files Functions Variables Pages
// @HEADER
// ***********************************************************************
//
// Didasko Tutorial Package
// Copyright (2005) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions about Didasko? Contact Marzio Sala (marzio.sala _AT_ gmail.com)
//
// ***********************************************************************
// @HEADER
#include "Didasko_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#endif
#if defined(HAVE_DIDASKO_TEUCHOS)
#include "Teuchos_CommandLineProcessor.hpp"
int main(int argc, char* argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
// Creating an empty command line processor looks like:
Teuchos::CommandLineProcessor My_CLP;
/* To set and option, it must be given a name and default value. Additionally,
each option can be given a help string. Although it is not necessary, a help
string aids a users comprehension of the acceptable command line arguments.
Some examples of setting command line options are:
*/
// Set an integer command line option.
int NumIters = 1550;
My_CLP.setOption("iterations", &NumIters, "Number of iterations");
// Set a double-precision command line option.
double Tolerance = 1e-10;
My_CLP.setOption("tolerance", &Tolerance, "Tolerance");
// Set a string command line option.
string Solver = "GMRES";
My_CLP.setOption("solver", &Solver, "Linear solver");
// Set a boolean command line option.
bool Precondition;
My_CLP.setOption("precondition","no-precondition",
&Precondition,"Preconditioning flag");
/* There are also two methods that control the strictness of the command line processor.
For a command line processor to be sensitive to any bad command line option that it
does not recognize use:
*/
My_CLP.recogniseAllOptions(false);
/* Then, if the parser finds a command line option it doesn't recognize, it will
throw an exception. To prevent a command line processor from throwing an exception
when it encounters a unrecognized option or help is printed, use:
*/
My_CLP.throwExceptions(false);
//Finally, to parse the command line, argc and argv are passed to the parse method:
My_CLP.parse( argc, argv );
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
#else
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
#ifdef HAVE_MPI
MPI_Init(&argc,&argv);
#endif
puts("Please configure Didasko with:");
puts("--enable-teuchos");
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return 0;
}
#endif