1191 monte exit code (#1196)

* #1191 refactor monte exit_string_status and fix char*[] array values

closes #1191
This commit is contained in:
Scott Fennell 2021-10-18 16:08:47 -05:00 committed by GitHub
parent 5b3770d15a
commit 087c98ce01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 5 deletions

View File

@ -21,6 +21,18 @@
%template(MonteVarVector) std::vector<Trick::MonteVar*>;
#endif
/* strings to match ExitStatus enum in MonteRun */
static const char* MC_exit_status_string[] = {
"Incomplete",
"Complete",
"Failed",
"Core Dumped",
"Timed Out",
"No Permission to Output Directory",
"Bad Input",
"Unrecognized Return Code"
} ;
namespace Trick {
/**
@ -36,7 +48,10 @@ namespace Trick {
class MonteRun {
public:
/** Details the manner in which this run exited. */
/**
* Details the manner in which this run exited. Update
* Strings in MC_exit_status_string above when editing enum.
*/
enum ExitStatus {
MC_RUN_INCOMPLETE, /**< not completed */
MC_RUN_COMPLETE, /**< process completed with exit status zero */
@ -78,6 +93,8 @@ namespace Trick {
end_time(0),
exit_status(MC_RUN_INCOMPLETE) {}
/* return exit status string that matches enum value */
const char* exit_status_string() const;
};
/**

View File

@ -72,4 +72,8 @@ Trick::MonteCarlo::~MonteCarlo() {
connection_device.error_handler = NULL ;
}
const char* Trick::MonteRun::exit_status_string() const {
return MC_exit_status_string[exit_status];
}

View File

@ -60,10 +60,8 @@ void Trick::MonteCarlo::shutdown_slaves() {
}
}
}
void Trick::MonteCarlo::print_statistics(FILE** fp) {
static const char *exit_status_string[] =
{"Incomplete", "Complete", "Core Dumped", "Timed Out",
"No Permission to Output Directory", "Bad Input" } ;
fprintf(*fp,
"\nMonte Carlo complete: %u runs (%zu successful) (%zu non-zero exit status) (%zu errors) (%u out of range)\n",
@ -109,7 +107,7 @@ void Trick::MonteCarlo::print_statistics(FILE** fp) {
fprintf(*fp, "\nThe following runs failed to complete:\n");
for (const MonteRun* run : error_runs) {
fprintf(*fp, "RUN_%05d MonteRun::ExitStatus = %s (%d)\n", run->id,
exit_status_string[run->exit_status], run->exit_status);
run->exit_status_string(), run->exit_status);
}
}
}