Page 1 of 1

Set pointer when using mod file that defines pointer

Posted: Fri Nov 20, 2015 11:40 am
by neuromau
This is just an FYI - my code was erroring out during a call to fcurrent() (as part of the call from finitialize() during the init procedure). It was reporting a segmentation violation and it took me awhile to realize it was due to the use of a mechanism (mod file) that defined and used a couple of pointers in its BREAKPOINT block, where I was only interested in using (and therefore only setting) one pointer. When a mechanism from a mod file is referenced in NEURON code, all pointers used (ie, on the right side of an equation) in the mod file must be set in the NEURON code. In retrospect, this is super obvious but I'm still adding an FYI post to save others a few minutes if they make this same mistake.

Code: Select all

pointerplaceholder = 0
setpointer mymech.unusedpointer, pointerplaceholder 
(I don't want to remove the pointer from the mechanism as it will certainly be used in other slight variations of the model.)

Re: Set pointer when using mod file that defines pointer

Posted: Fri Nov 20, 2015 1:27 pm
by ted
Good point (no pun intended). Been there, done that, and every time it happens I tell myself "don't do this again"--but eventually guess what happens . . .

The error message really gives no clue

Code: Select all

 Segmentation violation
 near line 1
so the problem can be quite difficult to diagnose unless you just happen to think of it, or have been using a development cycle in which you make only a few incremental changes, then run a test, then make some more changes etc..