mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #356 from atgeirr/accept-deck-as-argument
Accept single deck filename as command line argument.
This commit is contained in:
commit
e13ed48e4e
@ -95,14 +95,26 @@ try
|
|||||||
std::cout << "* http://opm-project.org *\n";
|
std::cout << "* http://opm-project.org *\n";
|
||||||
std::cout << "* *\n";
|
std::cout << "* *\n";
|
||||||
std::cout << "******************************************************************************************\n\n";
|
std::cout << "******************************************************************************************\n\n";
|
||||||
|
|
||||||
|
// Read parameters, see if a deck was specified on the command line.
|
||||||
std::cout << "--------------- Reading parameters ---------------" << std::endl;
|
std::cout << "--------------- Reading parameters ---------------" << std::endl;
|
||||||
parameter::ParameterGroup param(argc, argv, false);
|
parameter::ParameterGroup param(argc, argv, false);
|
||||||
|
if (!param.unhandledArguments().empty()) {
|
||||||
|
if (param.unhandledArguments().size() != 1) {
|
||||||
|
OPM_THROW(std::runtime_error, "You can only specify a single input deck on the command line.");
|
||||||
|
} else {
|
||||||
|
param.insertParameter("deck_filename", param.unhandledArguments()[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we have a "deck_filename", grid and props will be read from that.
|
// We must have an input deck. Grid and props will be read from that.
|
||||||
bool use_deck = param.has("deck_filename");
|
if (!param.has("deck_filename")) {
|
||||||
if (!use_deck) {
|
std::cerr << "This program must be run with an input deck.\n"
|
||||||
OPM_THROW(std::runtime_error, "This program must be run with an input deck. "
|
"Specify the deck filename either\n"
|
||||||
"Specify the deck with deck_filename=deckname.data (for example).");
|
" a) as a command line argument by itself\n"
|
||||||
|
" b) as a command line parameter with the syntax deck_filename=<path to your deck>, or\n"
|
||||||
|
" c) as a parameter in a parameter file (.param or .xml) passed to the program.";
|
||||||
|
OPM_THROW(std::runtime_error, "Input deck required.");
|
||||||
}
|
}
|
||||||
std::shared_ptr<GridManager> grid;
|
std::shared_ptr<GridManager> grid;
|
||||||
std::shared_ptr<BlackoilPropertiesInterface> props;
|
std::shared_ptr<BlackoilPropertiesInterface> props;
|
||||||
|
@ -122,14 +122,26 @@ try
|
|||||||
std::cout << "* http://opm-project.org *\n";
|
std::cout << "* http://opm-project.org *\n";
|
||||||
std::cout << "* *\n";
|
std::cout << "* *\n";
|
||||||
std::cout << "******************************************************************************************\n\n";
|
std::cout << "******************************************************************************************\n\n";
|
||||||
|
|
||||||
|
// Read parameters, see if a deck was specified on the command line.
|
||||||
std::cout << "--------------- Reading parameters ---------------" << std::endl;
|
std::cout << "--------------- Reading parameters ---------------" << std::endl;
|
||||||
parameter::ParameterGroup param(argc, argv, false);
|
parameter::ParameterGroup param(argc, argv, false);
|
||||||
|
if (!param.unhandledArguments().empty()) {
|
||||||
|
if (param.unhandledArguments().size() != 1) {
|
||||||
|
OPM_THROW(std::runtime_error, "You can only specify a single input deck on the command line.");
|
||||||
|
} else {
|
||||||
|
param.insertParameter("deck_filename", param.unhandledArguments()[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If we have a "deck_filename", grid and props will be read from that.
|
// We must have an input deck. Grid and props will be read from that.
|
||||||
bool use_deck = param.has("deck_filename");
|
if (!param.has("deck_filename")) {
|
||||||
if (!use_deck) {
|
std::cerr << "This program must be run with an input deck.\n"
|
||||||
OPM_THROW(std::runtime_error, "This program must be run with an input deck. "
|
"Specify the deck filename either\n"
|
||||||
"Specify the deck with deck_filename=deckname.data (for example).");
|
" a) as a command line argument by itself\n"
|
||||||
|
" b) as a command line parameter with the syntax deck_filename=<path to your deck>, or\n"
|
||||||
|
" c) as a parameter in a parameter file (.param or .xml) passed to the program.";
|
||||||
|
OPM_THROW(std::runtime_error, "Input deck required.");
|
||||||
}
|
}
|
||||||
std::shared_ptr<Dune::CpGrid> grid;
|
std::shared_ptr<Dune::CpGrid> grid;
|
||||||
std::shared_ptr<BlackoilPropertiesInterface> props;
|
std::shared_ptr<BlackoilPropertiesInterface> props;
|
||||||
|
Loading…
Reference in New Issue
Block a user