void MooseApp::setupOptions() { // Print the header, this is as early as possible std::string hdr = header(); if (multiAppLevel() > 0) MooseUtils::indentMessage(_name, hdr); Moose::out << hdr << std::endl; if (getParam<bool>("error_unused")) setCheckUnusedFlag(true); else if (getParam<bool>("warn_unused")) setCheckUnusedFlag(false); if (getParam<bool>("error_override")) setErrorOverridden(); _parallel_mesh_on_command_line = getParam<bool>("parallel_mesh"); _half_transient = getParam<bool>("half_transient"); _pars.set<bool>("timing") = getParam<bool>("timing"); if (isParamValid("trap_fpe") && isParamValid("no_trap_fpe")) mooseError("Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags."); if (isParamValid("trap_fpe")) Moose::_trap_fpe = true; else if (isParamValid("no_trap_fpe")) Moose::_trap_fpe = false; Moose::_warnings_are_errors = getParam<bool>("error"); Moose::_color_console = !getParam<bool>("no_color"); if (getParam<bool>("help")) { _command_line->printUsage(); _ready_to_exit = true; } else if (isParamValid("dump")) { _parser.initSyntaxFormatter(Parser::INPUT_FILE, true); // Get command line argument following --dump on command line std::string dump_following_arg = getParam<std::string>("dump"); // If the argument following --dump is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --dump. if (dump_following_arg.empty() || (dump_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(dump_following_arg); _ready_to_exit = true; } else if (isParamValid("yaml")) { _parser.initSyntaxFormatter(Parser::YAML, true); // Get command line argument following --yaml on command line std::string yaml_following_arg = getParam<std::string>("yaml"); // If the argument following --yaml is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --yaml. if (yaml_following_arg.empty() || (yaml_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(yaml_following_arg); _ready_to_exit = true; } else if (getParam<bool>("syntax")) { std::multimap<std::string, Syntax::ActionInfo> syntax = _syntax.getAssociatedActions(); Moose::out << "**START SYNTAX DATA**\n"; for (std::multimap<std::string, Syntax::ActionInfo>::iterator it = syntax.begin(); it != syntax.end(); ++it) Moose::out << it->first << "\n"; Moose::out << "**END SYNTAX DATA**\n" << std::endl; _ready_to_exit = true; } else if (_input_filename != "" || isParamValid("input_file")) // They already specified an input filename { if (_input_filename == "") _input_filename = getParam<std::string>("input_file"); if (isParamValid("recover")) { // We need to set the flag manually here since the recover parameter is a string type (takes an optional filename) _recover = true; // Get command line argument following --recover on command line std::string recover_following_arg = getParam<std::string>("recover"); // If the argument following --recover is non-existent or begins with // a dash then we are going to eventually find the newest recovery file to use if (!(recover_following_arg.empty() || (recover_following_arg.find('-') == 0))) _recover_base = recover_following_arg; } _parser.parse(_input_filename); _action_warehouse.build(); } else { if (_check_input) mooseError("You specified --check-input, but did not provide an input file. Add -i <inputfile> to your command line."); _command_line->printUsage(); _ready_to_exit = true; } }
void MooseApp::setupOptions() { if (getParam<bool>("error_unused")) setCheckUnusedFlag(true); else if (getParam<bool>("warn_unused")) setCheckUnusedFlag(false); if (getParam<bool>("error_override")) setErrorOverridden(); _parallel_mesh_on_command_line = getParam<bool>("parallel_mesh"); _half_transient = getParam<bool>("half_transient"); _pars.set<bool>("timing") = getParam<bool>("timing"); if (isParamValid("trap_fpe") && isParamValid("no_trap_fpe")) mooseError("Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags."); if (isParamValid("trap_fpe")) Moose::_trap_fpe = true; else if (isParamValid("no_trap_fpe")) Moose::_trap_fpe = false; Moose::_warnings_are_errors = getParam<bool>("error"); Moose::_color_console = getParam<bool>("no_color"); if (getParam<bool>("help")) { _command_line->printUsage(); _ready_to_exit = true; } else if (isParamValid("dump")) { _parser.initSyntaxFormatter(Parser::INPUT_FILE, true); // Get command line argument following --dump on command line std::string dump_following_arg = getParam<std::string>("dump"); // If the argument following --dump is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --dump. if (dump_following_arg.empty() || (dump_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(dump_following_arg); _ready_to_exit = true; } else if (isParamValid("yaml")) { _parser.initSyntaxFormatter(Parser::YAML, true); // Get command line argument following --yaml on command line std::string yaml_following_arg = getParam<std::string>("yaml"); // If the argument following --yaml is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --yaml. if (yaml_following_arg.empty() || (yaml_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(yaml_following_arg); _ready_to_exit = true; } else if (getParam<bool>("syntax")) { std::multimap<std::string, Syntax::ActionInfo> syntax = _syntax.getAssociatedActions(); Moose::out << "**START SYNTAX DATA**\n"; for (std::multimap<std::string, Syntax::ActionInfo>::iterator it = syntax.begin(); it != syntax.end(); ++it) { Moose::out << it->first << "\n"; } Moose::out << "**END SYNTAX DATA**\n" << std::endl; _ready_to_exit = true; } else if (_input_filename != "") // They already specified an input filename { _parser.parse(_input_filename); _action_warehouse.build(); return; } else if (isParamValid("input_file")) { if (isParamValid("recover")) { _recover = true; // Get command line argument following --recover on command line std::string recover_following_arg = getParam<std::string>("recover"); // If the argument following --recover is non-existent or begins with // a dash then we are going to eventually find the newest recovery file to use if (!(recover_following_arg.empty() || (recover_following_arg.find('-') == 0))) _recover_base = recover_following_arg; } _input_filename = getParam<std::string>("input_file"); _parser.parse(_input_filename); _action_warehouse.build(); } else { _command_line->printUsage(); _ready_to_exit = true; } }
void MooseApp::setupOptions() { // Print the header, this is as early as possible std::string hdr(header() + "\n"); if (multiAppLevel() > 0) MooseUtils::indentMessage(_name, hdr); Moose::out << hdr << std::flush; if (getParam<bool>("error_unused")) setCheckUnusedFlag(true); else if (getParam<bool>("warn_unused")) setCheckUnusedFlag(false); if (getParam<bool>("error_override")) setErrorOverridden(); _parallel_mesh_on_command_line = getParam<bool>("parallel_mesh"); _half_transient = getParam<bool>("half_transient"); _pars.set<bool>("timing") = getParam<bool>("timing"); if (isParamValid("trap_fpe") && isParamValid("no_trap_fpe")) mooseError("Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags."); if (isParamValid("trap_fpe")) Moose::_trap_fpe = true; else if (isParamValid("no_trap_fpe")) Moose::_trap_fpe = false; // Turn all warnings in MOOSE to errors (almost see next logic block) Moose::_warnings_are_errors = getParam<bool>("error"); /** * Deprecated messages can be toggled to errors independently from everything else. * Normally they are toggled with the --error flag but that behavior can * be modified with the --allow-warnings. */ if (getParam<bool>("error_deprecated") || (Moose::_warnings_are_errors && !getParam<bool>("allow_deprecated"))) Moose::_deprecated_is_error = true; else Moose::_deprecated_is_error = false; // Toggle the color console off Moose::_color_console = !getParam<bool>("no_color"); // If there's no threading model active, but the user asked for // --n-threads > 1 on the command line, throw a mooseError. This is // intended to prevent situations where the user has potentially // built MOOSE incorrectly (neither TBB nor pthreads found) and is // asking for multiple threads, not knowing that there will never be // any threads launched. #if !LIBMESH_USING_THREADS if (libMesh::command_line_value ("--n-threads", 1) > 1) mooseError("You specified --n-threads > 1, but there is no threading model active!"); #endif // Build a minimal running application, ignoring the input file. if (getParam<bool>("minimal")) createMinimalApp(); else if (getParam<bool>("help")) { Moose::perf_log.disable_logging(); _command_line->printUsage(); _ready_to_exit = true; } else if (isParamValid("dump")) { Moose::perf_log.disable_logging(); _parser.initSyntaxFormatter(Parser::INPUT_FILE, true); // Get command line argument following --dump on command line std::string dump_following_arg = getParam<std::string>("dump"); // If the argument following --dump is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --dump. if (dump_following_arg.empty() || (dump_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(dump_following_arg); _ready_to_exit = true; } else if (isParamValid("yaml")) { Moose::perf_log.disable_logging(); _parser.initSyntaxFormatter(Parser::YAML, true); // Get command line argument following --yaml on command line std::string yaml_following_arg = getParam<std::string>("yaml"); // If the argument following --yaml is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --yaml. if (yaml_following_arg.empty() || (yaml_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(yaml_following_arg); _ready_to_exit = true; } else if (getParam<bool>("syntax")) { Moose::perf_log.disable_logging(); std::multimap<std::string, Syntax::ActionInfo> syntax = _syntax.getAssociatedActions(); Moose::out << "**START SYNTAX DATA**\n"; for (std::multimap<std::string, Syntax::ActionInfo>::iterator it = syntax.begin(); it != syntax.end(); ++it) Moose::out << it->first << "\n"; Moose::out << "**END SYNTAX DATA**\n" << std::endl; _ready_to_exit = true; } else if (_input_filename != "" || isParamValid("input_file")) // They already specified an input filename { if (_input_filename == "") _input_filename = getParam<std::string>("input_file"); if (isParamValid("recover")) { // We need to set the flag manually here since the recover parameter is a string type (takes an optional filename) _recover = true; // Get command line argument following --recover on command line std::string recover_following_arg = getParam<std::string>("recover"); // If the argument following --recover is non-existent or begins with // a dash then we are going to eventually find the newest recovery file to use if (!(recover_following_arg.empty() || (recover_following_arg.find('-') == 0))) _recover_base = recover_following_arg; } _parser.parse(_input_filename); _action_warehouse.build(); } else { Moose::perf_log.disable_logging(); if (_check_input) mooseError("You specified --check-input, but did not provide an input file. Add -i <inputfile> to your command line."); _command_line->printUsage(); _ready_to_exit = true; } }
void MooseApp::setupOptions() { // MOOSE was updated to have the ability to register execution flags in similar fashion as // objects. However, this change requires all *App.C/h files to be updated with the new // registerExecFlags method. To avoid breaking all applications the default MOOSE flags // are added if nothing has been added to this point. In the future this could go away or // perhaps be a warning. if (_execute_flags.items().empty()) Moose::registerExecFlags(_factory); // Print the header, this is as early as possible std::string hdr(header() + "\n"); if (multiAppLevel() > 0) MooseUtils::indentMessage(_name, hdr); Moose::out << hdr << std::flush; if (getParam<bool>("error_unused")) setCheckUnusedFlag(true); else if (getParam<bool>("warn_unused")) setCheckUnusedFlag(false); if (getParam<bool>("error_override")) setErrorOverridden(); _distributed_mesh_on_command_line = getParam<bool>("distributed_mesh"); _half_transient = getParam<bool>("half_transient"); // The no_timing flag takes precedence over the timing flag. if (getParam<bool>("no_timing")) _pars.set<bool>("timing") = false; if (isParamValid("trap_fpe") && isParamValid("no_trap_fpe")) mooseError("Cannot use both \"--trap-fpe\" and \"--no-trap-fpe\" flags."); if (isParamValid("trap_fpe")) Moose::_trap_fpe = true; else if (isParamValid("no_trap_fpe")) Moose::_trap_fpe = false; // Turn all warnings in MOOSE to errors (almost see next logic block) Moose::_warnings_are_errors = getParam<bool>("error"); // Deprecated messages can be toggled to errors independently from everything else. Moose::_deprecated_is_error = getParam<bool>("error_deprecated"); if (isUltimateMaster()) // makes sure coloring isn't reset incorrectly in multi-app settings { // Toggle the color console off Moose::setColorConsole(true, true); // set default color condition if (getParam<bool>("no_color")) Moose::setColorConsole(false); char * c_color = std::getenv("MOOSE_COLOR"); std::string color = "on"; if (c_color) color = c_color; if (getParam<std::string>("color") != "default-on") color = getParam<std::string>("color"); if (color == "auto") Moose::setColorConsole(true); else if (color == "on") Moose::setColorConsole(true, true); else if (color == "off") Moose::setColorConsole(false); else mooseWarning("ignoring invalid --color arg (want 'auto', 'on', or 'off')"); } // this warning goes below --color processing to honor that setting for // the warning. And below settings for warnings/error setup. if (getParam<bool>("no_color")) mooseDeprecated("The --no-color flag is deprecated. Use '--color off' instead."); // If there's no threading model active, but the user asked for // --n-threads > 1 on the command line, throw a mooseError. This is // intended to prevent situations where the user has potentially // built MOOSE incorrectly (neither TBB nor pthreads found) and is // asking for multiple threads, not knowing that there will never be // any threads launched. #if !LIBMESH_USING_THREADS if (libMesh::command_line_value("--n-threads", 1) > 1) mooseError("You specified --n-threads > 1, but there is no threading model active!"); #endif // Build a minimal running application, ignoring the input file. if (getParam<bool>("minimal")) createMinimalApp(); else if (getParam<bool>("display_version")) { Moose::perf_log.disable_logging(); Moose::out << getPrintableVersion() << std::endl; _ready_to_exit = true; return; } else if (getParam<bool>("help")) { Moose::perf_log.disable_logging(); _command_line->printUsage(); _ready_to_exit = true; } else if (isParamValid("dump")) { Moose::perf_log.disable_logging(); // Get command line argument following --dump on command line std::string following_arg = getParam<std::string>("dump"); // The argument following --dump is a parameter search string, // which can be empty. std::string param_search; if (!following_arg.empty() && (following_arg.find('-') != 0)) param_search = following_arg; JsonSyntaxTree tree(param_search); _parser.buildJsonSyntaxTree(tree); JsonInputFileFormatter formatter; Moose::out << "### START DUMP DATA ###\n" << formatter.toString(tree.getRoot()) << "\n### END DUMP DATA ###\n"; _ready_to_exit = true; } else if (isParamValid("registry")) { Moose::out << "Label\tType\tName\tClass\tFile\n"; auto & objmap = Registry::allObjects(); for (auto & entry : objmap) { for (auto & obj : entry.second) { std::string name = obj._name; if (name.empty()) name = obj._alias; if (name.empty()) name = obj._classname; Moose::out << entry.first << "\tobject\t" << name << "\t" << obj._classname << "\t" << obj._file << "\n"; } } auto & actmap = Registry::allActions(); for (auto & entry : actmap) { for (auto & act : entry.second) Moose::out << entry.first << "\taction\t" << act._name << "\t" << act._classname << "\t" << act._file << "\n"; } _ready_to_exit = true; } else if (isParamValid("registry_hit")) { Moose::out << "### START REGISTRY DATA ###\n"; hit::Section root(""); auto sec = new hit::Section("registry"); root.addChild(sec); auto objsec = new hit::Section("objects"); sec->addChild(objsec); auto & objmap = Registry::allObjects(); for (auto & entry : objmap) { for (auto & obj : entry.second) { std::string name = obj._name; if (name.empty()) name = obj._alias; if (name.empty()) name = obj._classname; auto ent = new hit::Section("entry"); objsec->addChild(ent); ent->addChild(new hit::Field("label", hit::Field::Kind::String, entry.first)); ent->addChild(new hit::Field("type", hit::Field::Kind::String, "object")); ent->addChild(new hit::Field("name", hit::Field::Kind::String, name)); ent->addChild(new hit::Field("class", hit::Field::Kind::String, obj._classname)); ent->addChild(new hit::Field("file", hit::Field::Kind::String, obj._file)); } } auto actsec = new hit::Section("actions"); sec->addChild(actsec); auto & actmap = Registry::allActions(); for (auto & entry : actmap) { for (auto & act : entry.second) { auto ent = new hit::Section("entry"); actsec->addChild(ent); ent->addChild(new hit::Field("label", hit::Field::Kind::String, entry.first)); ent->addChild(new hit::Field("type", hit::Field::Kind::String, "action")); ent->addChild(new hit::Field("task", hit::Field::Kind::String, act._name)); ent->addChild(new hit::Field("class", hit::Field::Kind::String, act._classname)); ent->addChild(new hit::Field("file", hit::Field::Kind::String, act._file)); } } Moose::out << root.render(); Moose::out << "\n### END REGISTRY DATA ###\n"; _ready_to_exit = true; } else if (isParamValid("definition")) { Moose::perf_log.disable_logging(); JsonSyntaxTree tree(""); _parser.buildJsonSyntaxTree(tree); SONDefinitionFormatter formatter; Moose::out << formatter.toString(tree.getRoot()) << "\n"; _ready_to_exit = true; } else if (isParamValid("yaml")) { Moose::perf_log.disable_logging(); _parser.initSyntaxFormatter(Parser::YAML, true); // Get command line argument following --yaml on command line std::string yaml_following_arg = getParam<std::string>("yaml"); // If the argument following --yaml is non-existent or begins with // a dash, call buildFullTree() with an empty string, otherwise // pass the argument following --yaml. if (yaml_following_arg.empty() || (yaml_following_arg.find('-') == 0)) _parser.buildFullTree(""); else _parser.buildFullTree(yaml_following_arg); _ready_to_exit = true; } else if (isParamValid("json")) { Moose::perf_log.disable_logging(); // Get command line argument following --json on command line std::string json_following_arg = getParam<std::string>("json"); // The argument following --json is a parameter search string, // which can be empty. std::string search; if (!json_following_arg.empty() && (json_following_arg.find('-') != 0)) search = json_following_arg; JsonSyntaxTree tree(search); _parser.buildJsonSyntaxTree(tree); Moose::out << "**START JSON DATA**\n" << tree.getRoot() << "\n**END JSON DATA**\n"; _ready_to_exit = true; } else if (getParam<bool>("syntax")) { Moose::perf_log.disable_logging(); std::multimap<std::string, Syntax::ActionInfo> syntax = _syntax.getAssociatedActions(); Moose::out << "**START SYNTAX DATA**\n"; for (const auto & it : syntax) Moose::out << it.first << "\n"; Moose::out << "**END SYNTAX DATA**\n" << std::endl; _ready_to_exit = true; } else if (_input_filename != "" || isParamValid("input_file")) // They already specified an input filename { if (_input_filename == "") _input_filename = getParam<std::string>("input_file"); if (isParamValid("recover")) { // We need to set the flag manually here since the recover parameter is a string type (takes // an optional filename) _recover = true; // Get command line argument following --recover on command line std::string recover_following_arg = getParam<std::string>("recover"); // If the argument following --recover is non-existent or begins with // a dash then we are going to eventually find the newest recovery file to use if (!(recover_following_arg.empty() || (recover_following_arg.find('-') == 0))) _recover_base = recover_following_arg; } // Optionally get command line argument following --recoversuffix // on command line. Currently this argument applies to both // recovery and restart files. if (isParamValid("recoversuffix")) { _recover_suffix = getParam<std::string>("recoversuffix"); } _parser.parse(_input_filename); if (isParamValid("mesh_only")) { _syntax.registerTaskName("mesh_only", true); _syntax.addDependency("mesh_only", "setup_mesh_complete"); _action_warehouse.setFinalTask("mesh_only"); } else if (isParamValid("split_mesh")) { _syntax.registerTaskName("split_mesh", true); _syntax.addDependency("split_mesh", "setup_mesh_complete"); _action_warehouse.setFinalTask("split_mesh"); } _action_warehouse.build(); } else { Moose::perf_log.disable_logging(); if (_check_input) mooseError("You specified --check-input, but did not provide an input file. Add -i " "<inputfile> to your command line."); _command_line->printUsage(); _ready_to_exit = true; } }