diff --git a/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dispatch_run_to_slave.cpp b/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dispatch_run_to_slave.cpp index f12a2a92..64ca5523 100644 --- a/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dispatch_run_to_slave.cpp +++ b/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dispatch_run_to_slave.cpp @@ -23,10 +23,10 @@ void Trick::MonteCarlo::dispatch_run_to_slave(MonteRun *in_run, MonteSlave *in_s for (std::vector::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", diff --git a/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dryrun.cpp b/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dryrun.cpp index c7ae95b0..9b26777e 100644 --- a/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dryrun.cpp +++ b/trick_source/sim_services/MonteCarlo/src/MonteCarlo_dryrun.cpp @@ -1,7 +1,14 @@ +#include +#include +#include +#include +#include + #include "sim_services/MonteCarlo/include/MonteCarlo.hh" #include "sim_services/Message/include/message_proto.h" #include "sim_services/Message/include/message_type.h" +#include "sim_services/CommandLineArguments/include/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::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() ; + } } /**
  • Run the master shutdown jobs */ diff --git a/trick_source/sim_services/MonteCarlo/src/MonteCarlo_slave_process_run.cpp b/trick_source/sim_services/MonteCarlo/src/MonteCarlo_slave_process_run.cpp index 6f6612a6..79f0451e 100644 --- a/trick_source/sim_services/MonteCarlo/src/MonteCarlo_slave_process_run.cpp +++ b/trick_source/sim_services/MonteCarlo/src/MonteCarlo_slave_process_run.cpp @@ -119,7 +119,10 @@ int Trick::MonteCarlo::slave_process_run() { fprintf(fp, "# 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"); - fprintf(fp, "execfile(\"%s\")\n\n", command_line_args_get_input_file()); + fprintf(fp, "if (sys.version_info > (3, 0)):\n"); + fprintf(fp, " exec(open(\"%s\").read())\n", command_line_args_get_input_file()); + fprintf(fp, "else:\n"); + fprintf(fp, " execfile(\"%s\")\n\n", command_line_args_get_input_file()); fprintf(fp, "trick.mc_set_enabled(0)\n"); fprintf(fp, "%s" , input); fclose(fp);