Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 9f99176

Browse files
Merge branch 'master' into be_quiet
2 parents 9654969 + 2e34f42 commit 9f99176

File tree

9 files changed

+25
-19
lines changed

9 files changed

+25
-19
lines changed

coreneuron/apps/main1.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
465465

466466
std::vector<ReportConfiguration> configs;
467467
std::vector<std::unique_ptr<ReportHandler> > report_handlers;
468+
std::string spikes_population_name;
468469
bool reports_needs_finalize = false;
469470

470471
if (!corenrn_param.is_quiet()) {
@@ -482,7 +483,8 @@ extern "C" int run_solve_core(int argc, char** argv) {
482483
printf("\n WARNING! : Can't enable reports with model duplications feature! \n");
483484
} else {
484485
configs = create_report_configurations(corenrn_param.reportfilepath.c_str(),
485-
corenrn_param.outpath.c_str());
486+
corenrn_param.outpath.c_str(),
487+
spikes_population_name);
486488
reports_needs_finalize = configs.size();
487489
}
488490
}
@@ -596,7 +598,7 @@ extern "C" int run_solve_core(int argc, char** argv) {
596598
// write spike information to outpath
597599
{
598600
Instrumentor::phase p("output-spike");
599-
output_spikes(output_dir.c_str());
601+
output_spikes(output_dir.c_str(), spikes_population_name);
600602
}
601603

602604
{

coreneuron/io/output_spikes.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void sort_spikes(std::vector<double>& spikevec_time, std::vector<int>& spikevec_
155155
* \todo : MPI related code should be factored into nrnmpi.c
156156
* Check spike record length which is set to 64 chars
157157
*/
158-
void output_spikes_parallel(const char* outpath) {
158+
void output_spikes_parallel(const char* outpath, const std::string& population_name) {
159159
std::stringstream ss;
160160
ss << outpath << "/out.dat";
161161
std::string fname = ss.str();
@@ -165,9 +165,7 @@ void output_spikes_parallel(const char* outpath) {
165165
remove(fname.c_str());
166166
}
167167
#ifdef ENABLE_SONATA_REPORTS
168-
// TODO: Move population_name as input parameter
169-
const char* population_name = "All";
170-
sonata_write_spikes(population_name, spikevec_time.data(), spikevec_time.size(), spikevec_gid.data(),
168+
sonata_write_spikes(population_name.data(), spikevec_time.data(), spikevec_time.size(), spikevec_gid.data(),
171169
spikevec_gid.size(), outpath);
172170
#endif // ENABLE_SONATA_REPORTS
173171
sort_spikes(spikevec_time, spikevec_gid);
@@ -253,10 +251,10 @@ void output_spikes_serial(const char* outpath) {
253251
fclose(f);
254252
}
255253

256-
void output_spikes(const char* outpath) {
254+
void output_spikes(const char* outpath, const std::string& population_name) {
257255
#if NRNMPI
258256
if (nrnmpi_initialized()) {
259-
output_spikes_parallel(outpath);
257+
output_spikes_parallel(outpath, population_name);
260258
} else {
261259
output_spikes_serial(outpath);
262260
}

coreneuron/io/output_spikes.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3232
#include <vector>
3333
#include <utility>
3434
namespace coreneuron {
35-
void output_spikes(const char* outpath);
35+
void output_spikes(const char* outpath, const std::string& population_name);
3636
void mk_spikevec_buffer(int);
3737

3838
extern std::vector<double> spikevec_time;

coreneuron/io/reports/nrnreport.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct ReportConfiguration {
6262
char unit[REPORT_MAX_NAME_LEN]; // unit of the report
6363
char format[REPORT_MAX_NAME_LEN]; // format of the report (Bin, hdf5, SONATA)
6464
char type_str[REPORT_MAX_NAME_LEN]; // type of report string
65+
char population_name[REPORT_MAX_NAME_LEN]; // population name of the report
6566
ReportType type; // type of the report
6667
int mech_id; // mechanism
6768
double report_dt; // reporting timestep
@@ -74,7 +75,8 @@ struct ReportConfiguration {
7475

7576
void setup_report_engine(double dt_report, double mindelay);
7677
std::vector<ReportConfiguration> create_report_configurations(const char* filename,
77-
const char* output_dir);
78+
const char* output_dir,
79+
std::string& spikes_population_name);
7880
void finalize_report();
7981
void nrn_flush_reports(double t);
8082
void set_report_buffer_size(int n);

coreneuron/io/reports/report_configuration_parser.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,13 @@ void parse_filter_string(char* filter, ReportConfiguration& config) {
5858
}
5959

6060
std::vector<ReportConfiguration> create_report_configurations(const char* conf_file,
61-
const char* output_dir) {
61+
const char* output_dir,
62+
std::string& spikes_population_name) {
6263
std::vector<ReportConfiguration> reports;
6364
int num_reports = 0;
6465
char report_on[REPORT_MAX_NAME_LEN] = "";
6566
char raw_line[REPORT_MAX_FILEPATH_LEN] = "";
67+
char spikes_population[REPORT_MAX_NAME_LEN] = "";
6668
int is_soma;
6769
int* gids;
6870

@@ -82,10 +84,10 @@ std::vector<ReportConfiguration> create_report_configurations(const char* conf_f
8284
report.mech_id = -1;
8385
report.buffer_size = 4; // default size to 4 Mb
8486
fgets(raw_line, REPORT_MAX_FILEPATH_LEN, fp);
85-
sscanf(raw_line, "\n%s %s %s %s %s %s %d %lf %lf %lf %d %d\n", report.name,
87+
sscanf(raw_line, "\n%s %s %s %s %s %s %d %lf %lf %lf %d %d %s\n", report.name,
8688
report.target_name, report.type_str, report_on, report.unit, report.format, &is_soma,
8789
&report.report_dt, &report.start, &report.stop, &report.num_gids,
88-
&report.buffer_size);
90+
&report.buffer_size, report.population_name);
8991
for (int i = 0; i < REPORT_MAX_NAME_LEN; i++) {
9092
report.type_str[i] = tolower(report.type_str[i]);
9193
}
@@ -119,6 +121,9 @@ std::vector<ReportConfiguration> create_report_configurations(const char* conf_f
119121
free(gids);
120122
}
121123
}
124+
fgets(raw_line, REPORT_MAX_NAME_LEN, fp);
125+
sscanf(raw_line, "%s\n", spikes_population);
126+
spikes_population_name = spikes_population;
122127
fclose(fp);
123128
return reports;
124129
}

coreneuron/io/reports/report_event.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace coreneuron {
1212

13-
#if defined(ENABLE_REPORTINGLIB) || defined(ENABLE_SONATA_REPORTS)
13+
#if defined(ENABLE_BIN_REPORTS) || defined(ENABLE_SONATA_REPORTS)
1414
struct VarWithMapping {
1515
int id;
1616
double* var_value;
@@ -36,6 +36,6 @@ class ReportEvent : public DiscreteEvent {
3636
std::vector<int> gids_to_report;
3737
double tstart;
3838
};
39-
#endif // defined(ENABLE_REPORTINGLIB) || defined(ENABLE_SONATA_REPORTS)
39+
#endif // defined(ENABLE_BIN_REPORTS) || defined(ENABLE_SONATA_REPORTS)
4040

4141
} // Namespace coreneuron

coreneuron/io/reports/sonata_report_handler.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,16 @@ void SonataReportHandler::register_report(const NrnThread& nt,
4242
config.type_str);
4343
sonata_set_report_max_buffer_size_hint(config.output_path, config.buffer_size);
4444

45-
const char* population_name = "All";
4645
for (const auto& kv : vars_to_report) {
4746
int gid = kv.first;
4847
const std::vector<VarWithMapping>& vars = kv.second;
4948
if (!vars.size())
5049
continue;
5150

52-
sonata_add_node(config.output_path, population_name, gid);
51+
sonata_add_node(config.output_path, config.population_name, gid);
5352
sonata_set_report_max_buffer_size_hint(config.output_path, config.buffer_size);
5453
for (const auto& variable : vars) {
55-
sonata_add_element(config.output_path, population_name, gid, variable.id, variable.var_value);
54+
sonata_add_element(config.output_path, config.population_name, gid, variable.id, variable.var_value);
5655
}
5756
}
5857
}

coreneuron/sim/fadvance_core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void nrn_fixed_step_minimal() { /* not so minimal anymore with gap junctions */
8181
}
8282
#endif
8383

84-
#ifdef ENABLE_REPORTING
84+
#if defined(ENABLE_BIN_REPORTS) || defined(ENABLE_SONATA_REPORTS)
8585
nrn_flush_reports(nrn_threads[0]._t);
8686
#endif
8787
t = nrn_threads[0]._t;
16 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)