Skip to content

Commit

Permalink
Fix calls from NET_RECEIVE.
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Jun 11, 2024
1 parent 84417c8 commit df31f43
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/codegen/codegen_neuron_cpp_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2129,6 +2129,10 @@ void CodegenNeuronCppVisitor::print_net_receive() {
printer->add_line("auto * _ppvar = _nrn_mechanism_access_dparam(_pnt->prop);");

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

printer->add_line("size_t id = 0;");
printer->add_line("double t = _nt->_t;");
Expand Down
27 changes: 27 additions & 0 deletions test/usecases/NetReceiveCalls.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
NEURON {
POINT_PROCESS NetReceiveCalls
RANGE c1, c2
}

ASSIGNED {
c1
c2
}

INITIAL {
c1 = 0
c2 = 0
}

FUNCTION one() {
one = 1
}

PROCEDURE increment_c2() {
c2 = c2 + 2
}

NET_RECEIVE(w) {
c1 = c1 + one()
increment_c2()
}
29 changes: 29 additions & 0 deletions test/usecases/net_receive/test_calls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np

from neuron import h, gui
from neuron.units import ms


def test_calls():
nseg = 1

soma = h.Section()
soma.nseg = nseg

syn = h.NetReceiveCalls(soma(0.5))

stim = h.NetStim()
stim.interval = 0.2
stim.number = 3
stim.start = 0.1

netcon = h.NetCon(stim, syn)

h.stdinit()
h.run()

assert syn.c1 == 3
assert syn.c2 == 6

if __name__ == "__main__":
test_calls()

0 comments on commit df31f43

Please sign in to comment.