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

Commit e4b75c1

Browse files
WeinaJiOmar Awile
authored andcommitted
fix for checkpoint saving issue in neurodamus-py: (#231)
NetCon with no target is allowed in checkpoint set to `pnttype = 0` and `pntindex = -1` * comment out the not-working code and remove #if 0, keep it as todo
1 parent 8085e7c commit e4b75c1

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

coreneuron/nrniv/nrn_checkpoint.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,21 +428,24 @@ static void write_phase2(NrnThread& nt, FileHandlerWrap& fh) {
428428
for (int i = 0; i < nnetcon; ++i) {
429429
NetCon& nc = nt.netcons[i];
430430
Point_process* pnt = nc.target_;
431-
assert(pnt); // nrn_setup.cpp allows type <=0 which generates nullptr target.
432-
pnttype[i] = pnt->_type;
431+
if (pnt == nullptr) {
432+
// nrn_setup.cpp allows type <=0 which generates nullptr target.
433+
pnttype[i] = 0;
434+
pntindex[i] = -1;
435+
} else {
436+
pnttype[i] = pnt->_type;
437+
438+
// todo: this seems most natural, but does not work. Perhaps should look
439+
// into how pntindex determined in nrnbbcore_write.cpp and change there.
440+
// int ix = pnt->_i_instance;
441+
// if (ml_pinv[pnt->_type]) {
442+
// ix = ml_pinv[pnt->_type][ix];
443+
// }
433444

434-
#if 0
435-
// todo: this seems most natural, but does not work. Perhaps should look
436-
// into how pntindex determined in nrnbbcore_write.cpp and change there.
437-
int ix = pnt->_i_instance;
438-
if (ml_pinv[pnt->_type]) {
439-
ix = ml_pinv[pnt->_type][ix];
445+
// follow the inverse of nrn_setup.cpp using pnt_offset computed above.
446+
int ix = (pnt - nt.pntprocs) - pnt_offset[pnt->_type];
447+
pntindex[i] = ix;
440448
}
441-
#else
442-
// follow the inverse of nrn_setup.cpp using pnt_offset computed above.
443-
int ix = (pnt - nt.pntprocs) - pnt_offset[pnt->_type];
444-
#endif
445-
pntindex[i] = ix;
446449
delay[i] = nc.delay_;
447450
}
448451
fh.write_array<int>(pnttype, nnetcon);

0 commit comments

Comments
 (0)