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

Commit

Permalink
Run simulation with different mod files if they are not used, Fixes #54
Browse files Browse the repository at this point in the history
… (#140)

- Added a global vector that stores the different mod files between Neuron and CoreNeuron
- Search this vector when a mod file is read to be used in the simulation and if it is found exit, else continue simulation
  • Loading branch information
iomaganaris authored and pramodk committed Feb 27, 2019
1 parent f25f77a commit 9be1bd7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
25 changes: 25 additions & 0 deletions coreneuron/nrniv/nrn_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ std::vector<NetCon*> netcon_in_presyn_order_;
/// Only for setup vector of netcon source gids
std::vector<int*> netcon_srcgid;

/// Vector storing indexes (IDs) of different mechanisms of mod files between Neuron and CoreNeuron
extern std::vector<int> different_mechanism_type;

// Wrap read_phase1 and read_phase2 calls to allow using nrn_multithread_job.
// Args marshaled by store_phase_args are used by phase1_wrapper
// and phase2_wrapper.
Expand Down Expand Up @@ -1137,10 +1140,31 @@ void read_phase2(FileHandler& F, int imult, NrnThread& nt) {
nmech = F.read_int();
tml_index = new int[nmech];
ml_nodecount = new int[nmech];
int diff_mech_count = 0;
for (int i = 0; i < nmech; ++i) {
tml_index[i] = F.read_int();
ml_nodecount[i] = F.read_int();
auto mechanism_differs =
std::find(different_mechanism_type.begin(), different_mechanism_type.end(),
tml_index[i]) != different_mechanism_type.end();
if (mechanism_differs) {
if (nrnmpi_myid == 0) {
printf("Error: %s is a different MOD file than used by NEURON!\n",
nrn_get_mechname(tml_index[i]));
}
diff_mech_count++;
}
}

if (diff_mech_count > 0) {
if (nrnmpi_myid == 0) {
printf(
"Error : NEURON and CoreNEURON must use same mod files for compatibility, %d different mod file(s) found. Re-compile special and special-core!\n",
diff_mech_count);
}
nrn_abort(1);
}

nt._nidata = F.read_int();
nt._nvdata = F.read_int();
nt.n_weight = F.read_int();
Expand Down Expand Up @@ -2204,4 +2228,5 @@ size_t model_size(void) {

return nbyte;
}

} // namespace coreneuron
11 changes: 6 additions & 5 deletions coreneuron/nrnoc/register_mech.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
#include "coreneuron/nrnmpi/nrnmpi.h"
#include "coreneuron/nrnoc/mech_mapping.hpp"
#include "coreneuron/nrnoc/membfunc.h"
#include <vector>

namespace coreneuron {
int secondorder = 0;
Expand Down Expand Up @@ -86,6 +87,10 @@ static int ion_write_depend_size_;
static int** ion_write_depend_;
static void ion_write_depend(int type, int etype);

/* Vector keeping the types (IDs) of different mechanisms of mod files between Neuron and CoreNeuron
*/
std::vector<int> different_mechanism_type;

bbcore_read_t* nrn_bbcore_read_;
bbcore_write_t* nrn_bbcore_write_;
void hoc_reg_bbcore_read(int type, bbcore_read_t f) {
Expand Down Expand Up @@ -275,11 +280,7 @@ void hoc_register_prop_size(int type, int psize, int dpsize) {
pold = nrn_prop_param_size_[type];
dpold = nrn_prop_dparam_size_[type];
if (psize != pold || dpsize != dpold) {
printf("%s prop sizes differ psize %d %d dpsize %d %d\n", memb_func[type].sym, psize,
pold, dpsize, dpold);
printf("Error: %s is different version of MOD file than the one used by NEURON!\n",
memb_func[type].sym);
exit(1);
different_mechanism_type.push_back(type);
}
nrn_prop_param_size_[type] = psize;
nrn_prop_dparam_size_[type] = dpsize;
Expand Down

0 comments on commit 9be1bd7

Please sign in to comment.