16 void initialize(
int& argc,
char* argv[], MPI_Comm comm) {
17 Env = std::make_unique<mpi::Environment>(argc, argv, comm);
19 Comm = std::make_unique<mpi::Communicator>(comm);
21 Info = std::make_unique<Inform>(
"Ippl");
22 Warn = std::make_unique<Inform>(
"Warning", std::cerr);
26 std::list<std::string> notparsed;
29 while (nargs < argc) {
31 if (
Comm->rank() == 0) {
38 throw std::runtime_error(
"Missing info level value!");
44 throw std::runtime_error(
"Missing timer fence enable option!");
46 if (std::strcmp(argv[nargs],
"on") == 0) {
48 }
else if (std::strcmp(argv[nargs],
"off") == 0) {
51 throw std::runtime_error(
"Invalid timer fence option");
56 std::string header(
"Compile-time options: ");
57 while (options.length() > 58) {
58 std::string line = options.substr(0, 58);
59 size_t n = line.find_last_of(
' ');
60 *
Info << header << line.substr(0, n) <<
"\n";
62 header = std::string(22,
' ');
63 options = options.substr(n + 1);
70 throw std::runtime_error(
"Missing overallocation factor value!");
73 Comm->setDefaultOverallocation(factor);
74 }
else if (nargs > 0 && std::strstr(argv[nargs],
"--kokkos") ==
nullptr) {
75 notparsed.push_back(argv[nargs]);
80 Info->setOutputLevel(infoLevel);
81 Error->setOutputLevel(infoLevel);
82 Warn->setOutputLevel(infoLevel);
84 }
catch (
const std::exception& e) {
85 if (
Comm->rank() == 0) {
86 std::cerr << e.what() << std::endl;
91 Kokkos::initialize(argc, argv);
121 constexpr bool isInt = std::is_integral_v<T>;
122 std::string sarg = arg;
126 if constexpr (isInt) {
127 ret = std::stoll(sarg, &parsed);
129 ret = std::stold(sarg, &parsed);
131 if (parsed != sarg.length())
132 throw std::invalid_argument(
"Failed to parse");
134 }
catch (std::invalid_argument& e) {
135 if constexpr (isInt) {
136 throw std::runtime_error(
"Expected integer argument!");
138 throw std::runtime_error(
"Expected floating point argument!");
142 throw std::runtime_error(
"Unreachable state");