mirror of
https://github.com/nasa/trick.git
synced 2024-12-22 06:27:49 +00:00
008337e69b
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.
50 lines
2.0 KiB
C++
50 lines
2.0 KiB
C++
|
|
#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() {
|
|
|
|
/** <ul><li> For all runs: run the pre run jobs. */
|
|
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 */
|
|
run_queue(&master_shutdown_queue, "in master_shutdown queue") ;
|
|
|
|
message_publish(MSG_INFO, "Monte [Master] Dry run complete.\n") ;
|
|
|
|
exit(0) ;
|
|
}
|