LifeV
main_getpot.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Test GetPot type conversion
30 
31  @author C. Malossi <cristiano.malossi@epfl.ch>
32  @contributor
33  @maintainer
34 
35  @date 2009-05-05
36 
37  Check if GetPot is able to read correctly an integer, real, boolean, string value
38  */
39 
40 // ===================================================
41 //! Includes
42 // ===================================================
43 
44 #include <Epetra_ConfigDefs.h>
45 #ifdef EPETRA_MPI
46 #include <mpi.h>
47 #include <Epetra_MpiComm.h>
48 #else
49 #include <Epetra_SerialComm.h>
50 #endif
51 
52 
53 
54 #include <lifev/core/LifeV.hpp>
55 #include <lifev/core/filter/GetPot.hpp>
56 
57 
58 
59 // ===================================================
60 //! Namespaces
61 // ===================================================
62 using namespace LifeV;
63 
64 
65 // ===================================================
66 //! Main
67 // ===================================================
68 int main (int argc, char** argv)
69 {
70 
71 #ifdef HAVE_MPI
72  MPI_Init (&argc, &argv);
73  std::cout << "MPI Initialization" << std::endl;
74 #endif
75 
76  GetPot command_line (argc, argv);
77  const std::string data_file_name = command_line.follow ( "data_getPot", 2, "-f", "--file" );
78 
79  GetPot dataFile ( data_file_name );
80 
81  int A = dataFile ( "variables/A", 0 );
82  std::cout << "A: " << A << std::endl;
83 
84  Real B = dataFile ( "variables/B", 0.0 );
85  std::cout << "B: " << B << std::endl;
86 
87  bool C = dataFile ( "variables/C", false );
88  std::cout << "C: " << C << std::endl;
89 
90  std::string D = dataFile ( "variables/D", "empty" );
91  std::cout << "D: " << D << std::endl;
92 
93  std::string E = dataFile ( "variables/E", "empty empty" );
94  std::cout << "E: " << E << std::endl;
95 
96 
97 #ifdef HAVE_MPI
98  MPI_Finalize();
99  std::cout << "MPI Finalization" << std::endl;
100 #endif
101 
102  return ( EXIT_SUCCESS );
103 }
double operator()(const char *VarName, const double &Default) const
Definition: GetPot.hpp:2033
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
void updateInverseJacobian(const UInt &iQuadPt)
int main(int argc, char **argv)
Definition: dummy.cpp:5
double Real
Generic real data.
Definition: LifeV.hpp:175
int operator()(const char *VarName, int Default) const
Definition: GetPot.hpp:2021
const std::string operator()(const char *VarName, const char *Default) const
Definition: GetPot.hpp:2045
GetPot(const STRING_VECTOR &FileNameList)
Definition: GetPot.hpp:645
bool operator()(const char *VarName, bool Default) const
Definition: GetPot.hpp:2008
const std::string follow(const char *Default, unsigned No, const char *Option,...)
Definition: GetPot.hpp:1510