2

What are some useful ways to debug NEURON simulator .MOD files? In other languages one can usually use print() statements to see the variable values. Is there something like a print() statement in .MOD files?

Justas
  • 5,718
  • 2
  • 34
  • 36

1 Answers1

3

Use printf() statements

For example, in any of the sections within a .MOD file, adding the printf() statement below will print the variable t, i, and v values every time that section is evaluated during the simulation:

BREAKPOINT {
    SOLVE state METHOD cnexp
    g = (B - A)*gmax
    i = g*(v - e)

    printf("time: %g, current: %g, voltage: %g \n", t, i, v)
}

Will result in something that looks like this:

time: 231.062, current: 0.000609815, voltage: -67.2939 
time: 231.188, current: 0.000609059, voltage: -67.2938 
time: 231.312, current: 0.000608304, voltage: -67.2937 
time: 231.438, current: 0.00060755, voltage: -67.2936 
time: 231.562, current: 0.000606844, voltage: -67.2924 

Notes:

  • Recompile the .mod files in the folder after adding the above statements
  • Don't forget to include the '\n' at the end to avoid piling up the output
  • Other parameter options (besides %g) can be found in the printf() reference
Justas
  • 5,718
  • 2
  • 34
  • 36