Skip to content

Commit

Permalink
Loading dat files: shall not consider -1 holes
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdonline committed Nov 6, 2024
1 parent d0f0cfe commit 342e8f8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/coreneuron/io/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ std::vector<std::vector<int>> nrnthreads_netcon_negsrcgid_tid;

/* read files.dat file and distribute cellgroups to all mpi ranks */
void nrn_read_filesdat(int& ngrp, int*& grp, const char* filesdat) {
constexpr int FILES_DAT_END = -1;

patstimtype = nrn_get_mechtype("PatternStim");
if (corenrn_embedded && !corenrn_file_mode) {
ngrp = corenrn_embedded_nthread;
Expand Down Expand Up @@ -211,17 +213,21 @@ void nrn_read_filesdat(int& ngrp, int*& grp, const char* filesdat) {
grp = new int[iNumFiles / nrnmpi_numprocs + 1];

// irerate over gids in files.dat
for (int iNum = 0; iNum < iNumFiles; ++iNum) {
for (int iNum = 0, nFiles=0; nFiles < iNumFiles; ++iNum) {
int iFile;

nrn_assert(fscanf(fp, "%d\n", &iFile) == 1);
if ((iNum % nrnmpi_numprocs) == nrnmpi_myid) {
if (iFile == -1) {
if (iFile == FILES_DAT_END) {
// Sentinel value, we are done for this rank
break;
}
grp[ngrp] = iFile;
ngrp++;
grp[ngrp++] = iFile;
}

// Count only valid file ids
if (iFile != FILES_DAT_END) {
nFiles++;
}
}

Expand Down

0 comments on commit 342e8f8

Please sign in to comment.