Add exception handlers to all tutorials and examples

This commit is contained in:
Andreas Lauser 2013-09-03 14:41:38 +02:00
parent a26483b51d
commit 51cb4f2cb8
12 changed files with 57 additions and 0 deletions

View File

@ -92,6 +92,7 @@ public:
int main() int main()
try
{ {
int iter = 0; int iter = 0;
const double atol = 1.0e-13; const double atol = 1.0e-13;
@ -102,3 +103,8 @@ int main()
<< " using " << iter << " iterations." << '\n'; << " using " << iter << " iterations." << '\n';
std::cout << " f(x) = " << Func()(soln) << '\n'; std::cout << " f(x) = " << Func()(soln) << '\n';
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -71,6 +71,7 @@ namespace
// ----------------- Main program ----------------- // ----------------- Main program -----------------
int int
main(int argc, char** argv) main(int argc, char** argv)
try
{ {
using namespace Opm; using namespace Opm;
@ -283,3 +284,8 @@ main(int argc, char** argv)
} }
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -72,6 +72,7 @@ namespace
// ----------------- Main program ----------------- // ----------------- Main program -----------------
int int
main(int argc, char** argv) main(int argc, char** argv)
try
{ {
using namespace Opm; using namespace Opm;
@ -302,3 +303,8 @@ main(int argc, char** argv)
} }
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -74,6 +74,7 @@ namespace
// ----------------- Main program ----------------- // ----------------- Main program -----------------
int int
main(int argc, char** argv) main(int argc, char** argv)
try
{ {
using namespace Opm; using namespace Opm;
@ -299,3 +300,8 @@ main(int argc, char** argv)
} }
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -109,6 +109,7 @@ fluxFunc(const std::vector<ADB>& m)
int main() int main()
try
{ {
typedef AutoDiff::ForwardBlock<double> ADB; typedef AutoDiff::ForwardBlock<double> ADB;
typedef ADB::V V; typedef ADB::V V;
@ -296,3 +297,8 @@ int main()
<< "function s1 = solution\n" << "function s1 = solution\n"
<< "s1 = [\n" << sw1 << "\n];\n"; << "s1 = [\n" << sw1 << "\n];\n";
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -47,6 +47,7 @@
int int
main(int argc, char* argv[]) main(int argc, char* argv[])
try
{ {
const Opm::parameter::ParameterGroup param(argc, argv, false); const Opm::parameter::ParameterGroup param(argc, argv, false);
const Opm::GridManager gm(5, 5); const Opm::GridManager gm(5, 5);
@ -103,3 +104,8 @@ main(int argc, char* argv[])
return 0; return 0;
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -85,6 +85,7 @@ namespace {
int int
main(int argc, char* argv[]) main(int argc, char* argv[])
try
{ {
const Opm::parameter::ParameterGroup param(argc, argv, false); const Opm::parameter::ParameterGroup param(argc, argv, false);
const Opm::GridManager gm(20, 1); const Opm::GridManager gm(20, 1);
@ -117,3 +118,8 @@ main(int argc, char* argv[])
return 0; return 0;
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -41,6 +41,7 @@
int int
main() main()
try
{ {
typedef AutoDiff::Forward<double> AdFW; typedef AutoDiff::Forward<double> AdFW;
@ -69,3 +70,8 @@ main()
std::cout << "a - 1: " << (a - 1) << '\n'; std::cout << "a - 1: " << (a - 1) << '\n';
std::cout << "a - b: " << (a - b) << '\n'; std::cout << "a - b: " << (a - b) << '\n';
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}

View File

@ -193,6 +193,7 @@ BOOST_AUTO_TEST_CASE(Addition)
#include <iostream> #include <iostream>
int main() int main()
try
{ {
typedef AutoDiff::ForwardBlock<double> ADB; typedef AutoDiff::ForwardBlock<double> ADB;
std::vector<int> blocksizes = { 3, 1, 2 }; std::vector<int> blocksizes = { 3, 1, 2 };
@ -233,4 +234,8 @@ int main()
m.insert(1,1) = 1; m.insert(1,1) = 1;
std::cout << m*sqx; std::cout << m*sqx;
} }
catch (const std::exception &e) {
std::cerr << "Program threw an exception: " << e.what() << "\n";
throw;
}
#endif #endif

View File

@ -83,6 +83,7 @@ BOOST_FIXTURE_TEST_CASE(Construction, TestFixture<SetupSimple>)
} }
BOOST_FIXTURE_TEST_CASE(SurfaceDensity, TestFixture<SetupSimple>) BOOST_FIXTURE_TEST_CASE(SurfaceDensity, TestFixture<SetupSimple>)
{ {
Opm::BlackoilPropsAd boprops_ad(props); Opm::BlackoilPropsAd boprops_ad(props);

View File

@ -63,3 +63,5 @@ BOOST_AUTO_TEST_CASE(ScalarMultiplication)
BOOST_CHECK_EQUAL( x3.value().cwiseNotEqual( y3.value() ).count(), 0 ); BOOST_CHECK_EQUAL( x3.value().cwiseNotEqual( y3.value() ).count(), 0 );
} }

View File

@ -31,6 +31,7 @@ BOOST_AUTO_TEST_CASE(Initialisation)
} }
BOOST_AUTO_TEST_CASE(Addition) BOOST_AUTO_TEST_CASE(Addition)
{ {
typedef AutoDiff::Forward<double> AdFW; typedef AutoDiff::Forward<double> AdFW;