diff --git a/coreneuron/apps/main1.cpp b/coreneuron/apps/main1.cpp index 2f6530311..fb74df7d0 100644 --- a/coreneuron/apps/main1.cpp +++ b/coreneuron/apps/main1.cpp @@ -516,7 +516,6 @@ extern "C" void mk_mech_init(int argc, char** argv) { } // reads mechanism information from bbcore_mech.dat - mk_mech((corenrn_param.datpath).c_str()); } diff --git a/coreneuron/io/nrn_filehandler.cpp b/coreneuron/io/nrn_filehandler.cpp index 4318d9bee..40171aec7 100644 --- a/coreneuron/io/nrn_filehandler.cpp +++ b/coreneuron/io/nrn_filehandler.cpp @@ -17,7 +17,7 @@ FileHandler::FileHandler(const std::string& filename) this->open(filename); } -bool FileHandler::file_exist(const std::string& filename) const { +bool FileHandler::file_exist(const std::string& filename) { struct stat buffer; return (stat(filename.c_str(), &buffer) == 0); } diff --git a/coreneuron/io/nrn_filehandler.hpp b/coreneuron/io/nrn_filehandler.hpp index e7d280023..65cab4b97 100644 --- a/coreneuron/io/nrn_filehandler.hpp +++ b/coreneuron/io/nrn_filehandler.hpp @@ -61,7 +61,7 @@ class FileHandler { return F.fail(); } - bool file_exist(const std::string& filename) const; + static bool file_exist(const std::string& filename); /** nothing more to read */ bool eof(); diff --git a/coreneuron/io/nrn_setup.hpp b/coreneuron/io/nrn_setup.hpp index 3f5d90a8b..8d1f757b5 100644 --- a/coreneuron/io/nrn_setup.hpp +++ b/coreneuron/io/nrn_setup.hpp @@ -117,8 +117,12 @@ inline void* phase_wrapper_w(NrnThread* nt, UserParams& userParams, bool in_memo ".dat"; // Avoid trying to open the gid_gap.dat file if it doesn't exist when there are no - // gap junctions in this gid - if (P == gap && !userParams.file_reader[i].file_exist(fname)) { + // gap junctions in this gid. + // Note that we still need to close `userParams.file_reader[i]` + // because files are opened in the order of `gid_1.dat`, `gid_2.dat` and `gid_gap.dat`. + // When we open next file, `gid_gap.dat` in this case, we are supposed to close the + // handle for `gid_2.dat` even though file doesn't exist. + if (P == gap && !FileHandler::file_exist(fname)) { userParams.file_reader[i].close(); } else { // if no file failed to open or not opened at all diff --git a/coreneuron/mechanism/mech/cfile/cabvars.h b/coreneuron/mechanism/mech/cfile/cabvars.h index 846892263..96b90e1b3 100644 --- a/coreneuron/mechanism/mech/cfile/cabvars.h +++ b/coreneuron/mechanism/mech/cfile/cabvars.h @@ -22,6 +22,6 @@ static void (*mechanism[])(void) = {/* type will start at 3 */ /* extracellular requires special handling and must be type 5 */ extracell_reg_, #endif - 0}; + nullptr}; } // namespace coreneuron diff --git a/tests/integration/ring_gap/mod files/halfgap.mod b/tests/integration/ring_gap/mod files/halfgap.mod old mode 100755 new mode 100644