From 7d7b461b38a68a8bb27af163271c8b75de0a9fac Mon Sep 17 00:00:00 2001 From: Derek Bankieris Date: Mon, 6 May 2019 11:32:12 -0500 Subject: [PATCH] Allow specification of MC slave output directory Refs #763 --- include/trick/MonteCarlo.hh | 3 +++ .../MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp | 2 +- .../sim_services/MonteCarlo/MonteCarlo_master_file_io.cpp | 6 ++++++ .../sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/trick/MonteCarlo.hh b/include/trick/MonteCarlo.hh index 6cf7daec..cef79d33 100644 --- a/include/trick/MonteCarlo.hh +++ b/include/trick/MonteCarlo.hh @@ -259,6 +259,9 @@ namespace Trick { /** Options to be passed to the slave sim. */ std::string slave_sim_options; + /** Base output directory for slaves. */ + std::string slave_output_directory; + private: int run_queue(Trick::ScheduledJobQueue* queue, std::string in_string) ; diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp index feeb19bb..ec7303f8 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_dispatch_run_to_slave.cpp @@ -19,7 +19,7 @@ void Trick::MonteCarlo::dispatch_run_to_slave(MonteRun *run, MonteSlave *slave) connection_device.port = slave->port; if (tc_connect(&connection_device) == TC_SUCCESS) { std::stringstream buffer_stream; - buffer_stream << run_directory << "/RUN_" << std::setw(5) << std::setfill('0') << run->id; + buffer_stream << slave_output_directory << "/RUN_" << std::setw(5) << std::setfill('0') << run->id; std::string buffer = ""; for (std::vector::size_type j = 0; j < run->variables.size(); ++j) { buffer += run->variables[j] + "\n"; diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_master_file_io.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_master_file_io.cpp index a69a5f7c..43863bb6 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_master_file_io.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_master_file_io.cpp @@ -34,6 +34,12 @@ int Trick::MonteCarlo::construct_run_directory() { return -1; } run_directory = run_base_directory + "MONTE_" + run_directory; + + // If the user hasn't set an output directory for slaves, default to + // the same location as the master's output. + if (slave_output_directory.empty()) { + slave_output_directory = run_directory; + } } if (access(run_directory.c_str(), F_OK) != 0) { diff --git a/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp b/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp index 667da171..0e16c1e5 100644 --- a/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp +++ b/trick_source/sim_services/MonteCarlo/MonteCarlo_spawn_slaves.cpp @@ -49,7 +49,7 @@ void Trick::MonteCarlo::initialize_slave(Trick::MonteSlave* slave_to_init) { << " --monte_host " << machine_name << " --monte_sync_port " << listen_device.port << " --monte_client_id " << slave_to_init->id - << " -O " << run_directory; + << " -O " << slave_output_directory; buffer += ss.str(); /**
  • Append user sim options. */