diff --git a/miniapp/miniapp.cpp b/miniapp/miniapp.cpp index be9bcd1dc5b2bca9a657aeeb21d2514affdd5f05..24ea92483e85c7e184e08726c10fe7e11d248169 100644 --- a/miniapp/miniapp.cpp +++ b/miniapp/miniapp.cpp @@ -66,37 +66,37 @@ int main(int argc, char** argv) { auto recipe = make_recipe(options, pdist); auto cell_range = distribute_cells(recipe->num_cells()); - // build model from recipe - // TODO: I would rather just forward the options object. model_type m(*recipe, cell_range.first, cell_range.second); - std::unique_ptr<file_export_type> file_exporter; + + // File output is depending on the input arguments + std::unique_ptr<file_export_type> file_exporter; if (!options.spike_file_output) { - m.set_global_spike_callback( - file_export_type::do_nothing); - m.set_local_spike_callback( - file_export_type::do_nothing); + // TODO: use the no_function if PR:77 + m.set_global_spike_callback(file_export_type::do_nothing); + m.set_local_spike_callback(file_export_type::do_nothing); } else { - file_exporter = nest::mc::util::make_unique<file_export_type>( - options.file_name, options.output_path, - options.file_extention, true); + // The exporter is the same for both global and local output + // just registered as a different callback + file_exporter = + util::make_unique<file_export_type>( + options.file_name, options.output_path, + options.file_extention, options.over_write); if (options.single_file_per_rank) { - m.set_global_spike_callback( - file_export_type::do_nothing); + m.set_global_spike_callback(file_export_type::do_nothing); m.set_local_spike_callback( - [&](const std::vector<spike_type>& spikes) { file_exporter->do_export(spikes); }); - + [&](const std::vector<spike_type>& spikes) { + file_exporter->do_export(spikes); }); } else { m.set_global_spike_callback( - [&](const std::vector<spike_type>& spikes) { file_exporter->do_export(spikes); }); - m.set_local_spike_callback( - file_export_type::do_nothing); + [&](const std::vector<spike_type>& spikes) { + file_exporter->do_export(spikes); }); + m.set_local_spike_callback(file_export_type::do_nothing); } } - // inject some artificial spikes, 1 per 20 neurons. cell_gid_type spike_cell = 20*((cell_range.first+19)/20); diff --git a/src/communication/exporter_interface.hpp b/src/communication/exporter_interface.hpp index 8f7a714c9a1a735d338950c130debab89c0e3123..58178a9f5234cc62a5c2f33ca0cdd72129b88093 100644 --- a/src/communication/exporter_interface.hpp +++ b/src/communication/exporter_interface.hpp @@ -27,7 +27,7 @@ public: // Returns the status of the exporter virtual bool good() const = 0; - // Static NULL version of the do_export function for NOP callbacks + // Static version of the do_export function for NOP callbacks static void do_nothing(const std::vector<spike_type>&) {} }; diff --git a/src/model.hpp b/src/model.hpp index f6d3f7922ae925a7bb6831d7f7b028277318b5ba..1e98bddf74ff7fe2c55264a05f222082cc8f4edc 100644 --- a/src/model.hpp +++ b/src/model.hpp @@ -178,11 +178,16 @@ public: std::size_t num_spikes() const { return communicator_.num_spikes(); } std::size_t num_groups() const { return cell_groups_.size(); } + // register a callback that will perform a export of the global + // spike vector void set_global_spike_callback(std::function<void( const std::vector<spike_type>&)> global_export_callback) { global_export_callback_ = global_export_callback; } + + // register a callback that will perform a export of the rank local + // spike vector void set_local_spike_callback(std::function<void( const std::vector<spike_type>&)> local_export_callback) {