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

Commit 9be1bd7

Browse files
iomaganarispramodk
authored andcommitted
Run simulation with different mod files if they are not used, Fixes #54 (#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
1 parent f25f77a commit 9be1bd7

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

coreneuron/nrniv/nrn_setup.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ std::vector<NetCon*> netcon_in_presyn_order_;
263263
/// Only for setup vector of netcon source gids
264264
std::vector<int*> netcon_srcgid;
265265

266+
/// Vector storing indexes (IDs) of different mechanisms of mod files between Neuron and CoreNeuron
267+
extern std::vector<int> different_mechanism_type;
268+
266269
// Wrap read_phase1 and read_phase2 calls to allow using nrn_multithread_job.
267270
// Args marshaled by store_phase_args are used by phase1_wrapper
268271
// and phase2_wrapper.
@@ -1137,10 +1140,31 @@ void read_phase2(FileHandler& F, int imult, NrnThread& nt) {
11371140
nmech = F.read_int();
11381141
tml_index = new int[nmech];
11391142
ml_nodecount = new int[nmech];
1143+
int diff_mech_count = 0;
11401144
for (int i = 0; i < nmech; ++i) {
11411145
tml_index[i] = F.read_int();
11421146
ml_nodecount[i] = F.read_int();
1147+
auto mechanism_differs =
1148+
std::find(different_mechanism_type.begin(), different_mechanism_type.end(),
1149+
tml_index[i]) != different_mechanism_type.end();
1150+
if (mechanism_differs) {
1151+
if (nrnmpi_myid == 0) {
1152+
printf("Error: %s is a different MOD file than used by NEURON!\n",
1153+
nrn_get_mechname(tml_index[i]));
1154+
}
1155+
diff_mech_count++;
1156+
}
1157+
}
1158+
1159+
if (diff_mech_count > 0) {
1160+
if (nrnmpi_myid == 0) {
1161+
printf(
1162+
"Error : NEURON and CoreNEURON must use same mod files for compatibility, %d different mod file(s) found. Re-compile special and special-core!\n",
1163+
diff_mech_count);
1164+
}
1165+
nrn_abort(1);
11431166
}
1167+
11441168
nt._nidata = F.read_int();
11451169
nt._nvdata = F.read_int();
11461170
nt.n_weight = F.read_int();
@@ -2204,4 +2228,5 @@ size_t model_size(void) {
22042228

22052229
return nbyte;
22062230
}
2231+
22072232
} // namespace coreneuron

coreneuron/nrnoc/register_mech.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
3535
#include "coreneuron/nrnmpi/nrnmpi.h"
3636
#include "coreneuron/nrnoc/mech_mapping.hpp"
3737
#include "coreneuron/nrnoc/membfunc.h"
38+
#include <vector>
3839

3940
namespace coreneuron {
4041
int secondorder = 0;
@@ -86,6 +87,10 @@ static int ion_write_depend_size_;
8687
static int** ion_write_depend_;
8788
static void ion_write_depend(int type, int etype);
8889

90+
/* Vector keeping the types (IDs) of different mechanisms of mod files between Neuron and CoreNeuron
91+
*/
92+
std::vector<int> different_mechanism_type;
93+
8994
bbcore_read_t* nrn_bbcore_read_;
9095
bbcore_write_t* nrn_bbcore_write_;
9196
void hoc_reg_bbcore_read(int type, bbcore_read_t f) {
@@ -275,11 +280,7 @@ void hoc_register_prop_size(int type, int psize, int dpsize) {
275280
pold = nrn_prop_param_size_[type];
276281
dpold = nrn_prop_dparam_size_[type];
277282
if (psize != pold || dpsize != dpold) {
278-
printf("%s prop sizes differ psize %d %d dpsize %d %d\n", memb_func[type].sym, psize,
279-
pold, dpsize, dpold);
280-
printf("Error: %s is different version of MOD file than the one used by NEURON!\n",
281-
memb_func[type].sym);
282-
exit(1);
283+
different_mechanism_type.push_back(type);
283284
}
284285
nrn_prop_param_size_[type] = psize;
285286
nrn_prop_dparam_size_[type] = dpsize;

0 commit comments

Comments
 (0)