#include "Configuration.hpp" #include #include #include "MpiEnvironment.hpp" #include #include auto Configuration::parseArgs(int argc, char* argv[], const MpiEnvironment& env) -> Configuration { namespace po = boost::program_options; Configuration cfg; po::options_description desc{"Allowed options"}; desc.add_options()("help,h", "produce help message") // ("gridrows,r", po::value(&cfg.GridRows)->required(), "number of rows in the grid") // ("gridcols,c", po::value(&cfg.GridColumns)->required(), "number of columns in the grid") // ("file,f", po::value(&cfg.InputFilePath)->required(), "path to wireworld file"); // po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); if (vm.count("help") > 0 && env.isMaster()) { std::cout << desc << "\n"; } po::notify(vm); const auto& totalCellCount = cfg.GridColumns * cfg.GridRows; const auto& worldSize = env.worldSize(); if (totalCellCount != worldSize) { throw std::invalid_argument( boost::str(boost::format("Total number of cells (%d) does not " "match the MPI World size (%d)") % totalCellCount % worldSize)); } return cfg; }