mirror of
https://github.com/nasa/trick.git
synced 2024-12-19 05:07:54 +00:00
Monte Carlo dry runs produce monte_input files #318
The input file that is created while running monte carlo runs is done in 3 different places. There was no easy way to collect all of those lines in one place, so I duplicated the lines in the dryrun function.
This commit is contained in:
parent
a8c41d7cb5
commit
008337e69b
@ -24,10 +24,10 @@ void Trick::MonteCarlo::dispatch_run_to_slave(MonteRun *in_run, MonteSlave *in_s
|
||||
for (std::vector<std::string>::size_type j = 0; j < in_run->variables.size(); ++j) {
|
||||
buffer += in_run->variables[j] + "\n";
|
||||
}
|
||||
buffer += std::string("trick.set_output_dir(\"") + buffer_stream.str() + std::string("\");\n");
|
||||
buffer += std::string("trick.set_output_dir(\"") + buffer_stream.str() + std::string("\")\n");
|
||||
buffer_stream.str("");
|
||||
buffer_stream << in_run->id ;
|
||||
buffer += std::string("trick.mc_set_current_run(") + buffer_stream.str() + std::string(");\n");
|
||||
buffer += std::string("trick.mc_set_current_run(") + buffer_stream.str() + std::string(")\n");
|
||||
|
||||
if (verbosity >= INFORMATIONAL) {
|
||||
message_publish(MSG_INFO, "Monte [Master] Dispatching run %d to %s:%d.\n",
|
||||
|
@ -1,7 +1,14 @@
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "trick/MonteCarlo.hh"
|
||||
#include "trick/message_proto.h"
|
||||
#include "trick/message_type.h"
|
||||
#include "trick/command_line_protos.h"
|
||||
|
||||
/** @par Detailed Design: */
|
||||
void Trick::MonteCarlo::dryrun() {
|
||||
@ -10,6 +17,27 @@ void Trick::MonteCarlo::dryrun() {
|
||||
MonteRun * curr_run;
|
||||
while ((curr_run = get_next_dispatch())) {
|
||||
prepare_run(curr_run);
|
||||
|
||||
// Write out the input file for this run.
|
||||
std::stringstream buffer_stream;
|
||||
buffer_stream << run_directory << "/RUN_" << std::setw(5) << std::setfill('0') << curr_run->id;
|
||||
std::ofstream of ;
|
||||
if ( (access(buffer_stream.str().c_str(), F_OK) == 0) or (mkdir(buffer_stream.str().c_str(), 0755) == 0) ) {
|
||||
of.open(std::string(buffer_stream.str() + "/monte_input").c_str()) ;
|
||||
of << "# This run can be executed in stand alone (non-Monte Carlo) mode by running\n"
|
||||
"# the S_main executable with this file specified as the input file.\n\n" ;
|
||||
of << "if (sys.version_info > (3, 0)):" << std::endl ;
|
||||
of << " exec(open(\"" << command_line_args_get_input_file() << "\").read())" << std::endl ;
|
||||
of << "else:" << std::endl ;
|
||||
of << " execfile(\"" << command_line_args_get_input_file() << "\")" << std::endl << std::endl ;
|
||||
of << "trick.mc_set_enabled(0)" << std::endl ;
|
||||
for (std::vector<std::string>::size_type j = 0; j < curr_run->variables.size(); ++j) {
|
||||
of << curr_run->variables[j] << std::endl ;
|
||||
}
|
||||
of << "trick.set_output_dir(\"" << buffer_stream.str() << "\")" << std::endl ;
|
||||
of << "trick.mc_set_current_run(" << curr_run->id << ")" << std::endl ;
|
||||
of.close() ;
|
||||
}
|
||||
}
|
||||
|
||||
/** <ul><li> Run the master shutdown jobs */
|
||||
|
Loading…
Reference in New Issue
Block a user