Page 1 of 1
Aborting a simulation run from within NMODL
Posted: Thu Apr 24, 2008 2:20 pm
by sec6
Is there a way to abort a NEURON simulation (i.e. terminate computation prior to t == tstop) from within a NMODL mechanism?
I'm wanting to do this for debugging purposes, i.e. something like:
Code: Select all
IF (fooBar > maxLegalValue) {
printf ("Variable fooBar has been assigned an illegal value: %g\n",fooBar)
dummyVar = 1/0
}
However, contrary to expectations, the divide-by-zero didn't result in premature termination. I suppose I want something like an "abort()" function. ... or maybe I should try setting t = tstop? Or is there some way I can force a segfault?
Posted: Fri Apr 25, 2008 9:25 am
by hines
abort()
is a good way to stop immediately. And is what I use when I am using gdb and want
to get control at a specific location (usually before an assert error).
If you want to return immediately to the interpreter use
hoc_execerror("message1", "message2")
if you want to stop at the end of the current step use the global varialbe
VERBATIM
extern int stoprun
ENDVERBATIM
and then set it with
stoprun = 1
Posted: Sat Apr 26, 2008 9:02 am
by sec6
hines wrote:
is a good way to stop immediately. And is what I use when I am using gdb and want
to get control at a specific location (usually before an assert error).
If you want to return immediately to the interpreter use
Code: Select all
hoc_execerror("message1", "message2")
if you want to stop at the end of the current step use the global varialbe
Code: Select all
VERBATIM
extern int stoprun
ENDVERBATIM
and then set it with
Perfect. Thanks. Turns out if I'd just guessed, & tried "abort()" I could have avoided bothering you with a question. However, I'm glad I did bother you, because now I know the "stoprun = 1" trick, which is the answer to the question I *should* have asked
Addendum:
FWIW, hoc_execerror does drop me back into the hoc interpreter, but hoc then reports a bus error and drops me back to the Unix shell -- I'm not sure whether that's expected behavior or not. Anyway, it's not a serious issue for me, so I'm not going to pursue it.