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

Commit 635b31f

Browse files
authored
Fix calls from NET_RECEIVE. (#1311)
1 parent 64cf627 commit 635b31f

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

src/codegen/codegen_neuron_cpp_visitor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,10 @@ void CodegenNeuronCppVisitor::print_net_receive() {
21612161
printer->add_line("auto * _ppvar = _nrn_mechanism_access_dparam(_pnt->prop);");
21622162

21632163
printer->fmt_line("auto inst = make_instance_{}(_lmc);", info.mod_suffix);
2164+
printer->fmt_line("// nocmodl has a nullptr dereference for thread variables.");
2165+
printer->fmt_line("// NMODL will fail to compile at a later point, because of");
2166+
printer->fmt_line("// missing '_thread_vars'.");
2167+
printer->fmt_line("Datum * _thread = nullptr;");
21642168

21652169
printer->add_line("size_t id = 0;");
21662170
printer->add_line("double t = _nt->_t;");
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
NEURON {
2+
POINT_PROCESS NetReceiveCalls
3+
RANGE c1, c2
4+
}
5+
6+
ASSIGNED {
7+
c1
8+
c2
9+
}
10+
11+
INITIAL {
12+
c1 = 0
13+
c2 = 0
14+
}
15+
16+
FUNCTION one() {
17+
one = 1
18+
}
19+
20+
PROCEDURE increment_c2() {
21+
c2 = c2 + 2
22+
}
23+
24+
NET_RECEIVE(w) {
25+
c1 = c1 + one()
26+
increment_c2()
27+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import numpy as np
2+
3+
from neuron import h, gui
4+
from neuron.units import ms
5+
6+
7+
def test_calls():
8+
nseg = 1
9+
10+
soma = h.Section()
11+
soma.nseg = nseg
12+
13+
syn = h.NetReceiveCalls(soma(0.5))
14+
15+
stim = h.NetStim()
16+
stim.interval = 0.2
17+
stim.number = 3
18+
stim.start = 0.1
19+
20+
netcon = h.NetCon(stim, syn)
21+
22+
h.stdinit()
23+
h.run()
24+
25+
assert syn.c1 == 3
26+
assert syn.c2 == 6
27+
28+
29+
if __name__ == "__main__":
30+
test_calls()

0 commit comments

Comments
 (0)