GenericDriver.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #include "Teuchos_CommandLineProcessor.hpp"
00030 #include "Teuchos_GlobalMPISession.hpp"
00031 #include "Teuchos_VerboseObject.hpp"
00032 #include "Teuchos_StandardCatchMacros.hpp"
00033 
00034 
00035 int main( int argc, char* argv[] )
00036 {
00037 
00038   Teuchos::GlobalMPISession mpiSession(&argc, &argv);
00039 
00040   using Teuchos::CommandLineProcessor;
00041  
00042   Teuchos::RCP<Teuchos::FancyOStream>
00043     out = Teuchos::VerboseObjectBase::getDefaultOStream();
00044 
00045   int returnVal = 0;
00046 
00047   bool success = true;
00048  
00049   try {
00050 
00051     CommandLineProcessor clp(false); // Don't throw exceptions
00052 
00053     std::string printMsg = "";
00054     clp.setOption( "print-msg", &printMsg, "Print message to the screen." );
00055 
00056     clp.setOption( "return-val", &returnVal, "Value to return from main." );
00057 
00058     CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
00059     if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
00060       *out << "\nEnd Result: TEST FAILED" << std::endl;
00061       return parse_return;
00062     }
00063  
00064     if (printMsg.length())
00065       *out << "\n" << printMsg << "\n";
00066 
00067   }
00068   TEUCHOS_STANDARD_CATCH_STATEMENTS(true, std::cerr, success);
00069  
00070   if(success)
00071     *out << "\nEnd Result: TEST PASSED" << std::endl; 
00072  
00073   return returnVal;
00074  
00075 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Tue Oct 20 10:13:59 2009 for Teuchos Package Browser (Single Doxygen Collection) by  doxygen 1.6.1