Aborting a simulation run from within NMODL

NMODL and the Channel Builder.
Post Reply
sec6
Posts: 39
Joined: Sat Mar 15, 2008 10:32 am

Aborting a simulation run from within NMODL

Post by sec6 » Thu Apr 24, 2008 2:20 pm

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?

hines
Site Admin
Posts: 1586
Joined: Wed May 18, 2005 3:32 pm

Post by hines » Fri Apr 25, 2008 9:25 am

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

sec6
Posts: 39
Joined: Sat Mar 15, 2008 10:32 am

Post by sec6 » Sat Apr 26, 2008 9:02 am

hines wrote:

Code: Select all

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

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

Code: Select all

stoprun = 1
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.

Post Reply