27 #include <mxx/comm.hpp>
28 #include <mxx/env.hpp>
30 #include "JSON/JSONLoader.h"
31 #include "Drivers/DriverException.h"
36 int main(
int argc,
char* argv[])
39 mxx::env env(argc, argv);
40 mxx::env::set_exception_on_error();
41 auto world = mxx::comm();
43 std::stringstream helpStream;
45 <<
"Welcome to SSAGES - Software Suite for Advanced General Ensemble Simulations\n"
47 << argv[0] <<
" [-h | --help] [ --version ] InputFile.json\n"
49 <<
"Required parameters:\n"
50 <<
"InputFile.json - Input file specifying the general ensemble method and\n"
51 <<
" all required input parameters in the JSON format. For more\n"
52 <<
" information on the input file, confer the user manual.\n"
54 <<
"Optional parameters:\n"
55 <<
" -h | --help - Print this help message\n"
56 <<
" --version - Print SSAGES and engine version and quit\n";
58 std::stringstream versionStream;
60 <<
"SSAGES version " << SSAGES_VERSION <<
"\n"
61 <<
"Engine: " << MD_ENGINE_VERSION <<
"\n";
64 const char *OPT_STRING =
"h!";
67 static struct option longOpts[] = {
68 {
"help", no_argument,
nullptr,
'h' },
69 {
"version", no_argument,
nullptr,
'!' },
74 int opt = getopt_long(argc, argv, OPT_STRING, longOpts, &optionindex);
79 std::cout << helpStream.str();
83 std::cout << versionStream.str();
90 opt = getopt_long(argc, argv, OPT_STRING, longOpts, &optionindex);
94 if (optionindex >= argc) {
95 std::cerr <<
"Error! No JSON input file given. Use " << argv[0] <<
" --help "
96 <<
"for information on how to call SSAGES.\n";
102 std::string input = argv[optionindex];
106 auto* driver = Driver::Build(json, world);
109 if(world.rank() == 0)
111 MPI_Abort(world, -1);
112 }
catch(std::exception& e) {
113 if(world.rank() == 0)
115 MPI_Abort(world, -1);
117 std::string err = strerror(k);
118 if(world.rank() == 0)
120 MPI_Abort(world, -1);
Exception to be thrown when building the Driver fails.
std::vector< std::string > GetErrors()
Get specific error message.
Class for loading JSON content from files.
Json::Value LoadFile(const std::string &filename, const mxx::comm &world)
Load file and return JSON tree.
int DumpErrorsToConsole(const std::vector< std::string > &msgs, int notw)
Print a list of errors.