NEURON NMODL/MOD File Cheat Sheet

Compile .mod files with with (specify path after to compile specific mod files):

nrnivmodl

Check units with (nrnivmodl does not check unit consistency):

modlunit file.mod

Meaning of various NMODL keywords

  • RANGE – varies with position (0-1) on a section.
    • Read/set with section.var or section(0.5).var.
    • If section.nseg > 1:
      • section(0.5).var can have a different value than section(0 or 1).var.
      • If 0.5 and 0/1 values are different, sec.var will return the value at 0.5.
      • However, setting sec.var will set the value at all locations (0-1).
      • The above behavior is un-intuitive if nseg is even (0.5 becomes exactly in between two compartments). As a rule, always use odd nseg values.
    • STATE vars are always RANGE.
  • GLOBAL – “global” does not vary with position. Non-RANGE PARAMETERs are GLOBAL by default.
    • Accessible with h.var_modsuffix. In HOC only, can also access via sec.var_suffix, but not in Python.
  • PARAMETER – Either set externally by user, or passed in from simulation (e.g. celsius) for read-only use in equations. NEURON GUI treats these as editable. Always visible to user. By default will be GLOBAL, unless specified in RANGE.
  • ASSIGNED – variables whose value is computed by statements and their value should be retained during simulation. By default hidden from user, unless specified as RANGE or GLOBAL.
  • LOCAL – value is shared across all instances of the mechanism (incl. MPI? doubt it — probably within a process)
  • INCLUDE “file.inc” — replaces the line with the file.inc contents. Searches cwd, then mod file location, then in env var MODL_INCLUDES