28 for (
int i = 1; i < argc; ++i)
30 tokens.emplace_back(argv[i]);
35 get_parameters_filename()
39#ifdef PRISMS_PF_WITH_CALIPER
46 throw std::runtime_error(
47 "Too many command line arguments. The arguments should specify "
48 "the input file name and caliper configurations, if applicable. For example, "
49 "`./main -i parameters.prm`");
53 std::string parameters_filename =
"parameters.prm";
55 if (argc >= n_args - 1 && !cmd_option_exists(
"-i"))
57 throw std::runtime_error(
58 "Invalid command line option. Use `-i` to specify the input file, "
59 "e.g., `./main -i parameters.prm`.");
63 if (cmd_option_exists(
"-i"))
65 parameters_filename = get_cmd_option(
"-i");
69 if (parameters_filename.size() < 4 ||
70 parameters_filename.substr(parameters_filename.size() - 4) !=
".prm")
72 throw std::runtime_error(
"The input file must have the `.prm` extension. Please "
73 "rename the file accordingly.");
77 std::ifstream ifs_prm(parameters_filename);
80 throw std::runtime_error(
"The specified parameters file `" + parameters_filename +
86 <<
"Using the input parameter file: " << parameters_filename <<
"\n";
88 return parameters_filename;
91#ifdef PRISMS_PF_WITH_CALIPER
93 get_caliper_configuration()
101 throw std::runtime_error(
102 "Too many command line arguments. The arguments should specify "
103 "the input file name and caliper configurations, if applicable. For example, "
104 "`./main -i parameters.prm -P runtime-report`");
108 std::string config =
"runtime-report";
110 if (argc >= n_args - 1 && !cmd_option_exists(
"-P"))
112 throw std::runtime_error(
113 "Invalid command line option. Use `-P` to specify caliper configurations, "
114 "e.g., `./main -P runtime-report`.");
118 if (cmd_option_exists(
"-P"))
120 config = get_cmd_option(
"-P");
125 <<
"Using the caliper configuration: " << config <<
"\n";
133 std::vector<std::string> tokens;
135 [[nodiscard]]
const std::string &
136 get_cmd_option(
const std::string &option)
const
138 std::vector<std::string>::const_iterator itr;
139 itr = std::find(tokens.begin(), tokens.end(), option);
140 if (itr != tokens.end() && ++itr != tokens.end())
144 static const std::string empty_string;
149 cmd_option_exists(
const std::string &option)
const
151 return std::find(tokens.begin(), tokens.end(), option) != tokens.end();
static dealii::ConditionalOStream & pout_base()
Generic parallel output stream. Used for essential information in release and debug mode.
Definition conditional_ostreams.cc:31