Skip to content

Commit

Permalink
Capture return code and use it for --run
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Sep 16, 2024
1 parent 97b05cc commit 17b83f0
Show file tree
Hide file tree
Showing 64 changed files with 76 additions and 190 deletions.
4 changes: 1 addition & 3 deletions examples/ex01_inputfile/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex02_kernel/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex03_coupling/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex04_bcs/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex05_amr/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex06_transient/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex07_ics/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex08_materials/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex09_stateful_materials/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex10_aux/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex11_prec/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex12_pbp/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex13_functions/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex14_pps/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex15_actions/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex16_timestepper/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex17_dirac/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex18_scalar_kernel/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex19_dampers/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex20_user_objects/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions examples/ex21_debugging/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExampleApp>(argc, argv);

return 0;
return Moose::main<ExampleApp>(argc, argv);
}
10 changes: 9 additions & 1 deletion framework/include/base/MooseApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ class MooseApp : public ConsoleStreamInterface,
return name;
}

/**
* Get the shell exit code for the application
* @return The shell exit code
*/
int exitCode() const { return _exit_code; }

/**
* Get the parameters of the object
* @return The parameters of the object
Expand Down Expand Up @@ -1234,6 +1240,8 @@ class MooseApp : public ConsoleStreamInterface,
/// Indicates whether warnings or errors are displayed when overridden parameters are detected
bool _error_overridden;
bool _ready_to_exit;
/// The exit code
int _exit_code;

/// This variable indicates when a request has been made to restart from an Exodus file
bool _initial_from_file;
Expand Down Expand Up @@ -1412,7 +1420,7 @@ class MooseApp : public ConsoleStreamInterface,
* and launches the TestHarness to process the given directory.
* @return a Boolean value used to indicate whether the application should exit early
*/
bool runInputs() const;
bool runInputs();

/// General storage for custom RestartableData that can be added to from outside applications
std::unordered_map<RestartableDataMapName, std::pair<RestartableDataMap, std::string>>
Expand Down
4 changes: 3 additions & 1 deletion framework/include/base/MooseMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void addMainCommandLineParams(InputParameters & params);
* Initialize, create and run a MooseApp
*/
template <typename DefaultAppType>
void
int
main(int argc, char * argv[])
{
MooseInit init(argc, argv);
Expand All @@ -45,5 +45,7 @@ main(int argc, char * argv[])
auto app = createMooseApp(default_app_name, argc, argv);

app->run();

return app->exitCode();
}
}
8 changes: 3 additions & 5 deletions framework/src/base/MooseApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ MooseApp::MooseApp(InputParameters parameters)
_factory(*this),
_error_overridden(false),
_ready_to_exit(false),
_exit_code(0),
_initial_from_file(false),
_distributed_mesh_on_command_line(false),
_recover(false),
Expand Down Expand Up @@ -1669,7 +1670,7 @@ MooseApp::copyInputs() const
}

bool
MooseApp::runInputs() const
MooseApp::runInputs()
{
if (isParamValid("run"))
{
Expand Down Expand Up @@ -1717,10 +1718,7 @@ MooseApp::runInputs() const
if (processor_id() == 0)
return_value = system(cmd.c_str());
_communicator.broadcast(return_value);

// TODO: return the actual return value here
if (WIFEXITED(return_value) && WEXITSTATUS(return_value) != 0)
mooseError("Run failed");
_exit_code = return_value;
return true;
}

Expand Down
4 changes: 1 addition & 3 deletions modules/chemical_reactions/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ChemicalReactionsTestApp>(argc, argv);

return 0;
return Moose::main<ChemicalReactionsTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/combined/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@
int
main(int argc, char * argv[])
{
Moose::main<CombinedTestApp>(argc, argv);

return 0;
return Moose::main<CombinedTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/contact/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ContactTestApp>(argc, argv);

return 0;
return Moose::main<ContactTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/electromagnetics/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ElectromagneticsTestApp>(argc, argv);

return 0;
return Moose::main<ElectromagneticsTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/external_petsc_solver/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<ExternalPetscSolverTestApp>(argc, argv);

return 0;
return Moose::main<ExternalPetscSolverTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/fluid_properties/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<FluidPropertiesTestApp>(argc, argv);

return 0;
return Moose::main<FluidPropertiesTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/fsi/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<FsiTestApp>(argc, argv);

return 0;
return Moose::main<FsiTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/functional_expansion_tools/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<FunctionalExpansionToolsTestApp>(argc, argv);

return 0;
return Moose::main<FunctionalExpansionToolsTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/geochemistry/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<GeochemistryTestApp>(argc, argv);

return 0;
return Moose::main<GeochemistryTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/heat_transfer/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<HeatTransferTestApp>(argc, argv);

return 0;
return Moose::main<HeatTransferTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/level_set/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<LevelSetTestApp>(argc, argv);

return 0;
return Moose::main<LevelSetTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/misc/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<MiscTestApp>(argc, argv);

return 0;
return Moose::main<MiscTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/navier_stokes/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<NavierStokesTestApp>(argc, argv);

return 0;
return Moose::main<NavierStokesTestApp>(argc, argv);
}
4 changes: 1 addition & 3 deletions modules/optimization/src/main.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@
int
main(int argc, char * argv[])
{
Moose::main<OptimizationTestApp>(argc, argv);

return 0;
return Moose::main<OptimizationTestApp>(argc, argv);
}
Loading

0 comments on commit 17b83f0

Please sign in to comment.