assigned block

NMODL and the Channel Builder.
Post Reply
MH

assigned block

Post by MH »

Hi!
I read that the assigned block is a block whereby it is possible to declare two types of variables:
1. variables given outside mod file and used in every mechanism
and
2. statements inside mod file - unknown dependent variables in differential equations

Would an example of the first be declaring global variables?
Would an example of the first be declaring range or local variables?

If not, could you please clarify?!
Thanks!
MH
ted
Site Admin
Posts: 6384
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: assigned block

Post by ted »

MH wrote:I read that the assigned block is a block whereby it is possible to declare two types of variables:
1. variables given outside mod file and used in every mechanism
and
2. statements inside mod file - unknown dependent variables in differential equations

Would an example of the first be declaring global variables?
Would an example of the first be declaring range or local variables?
Three different concepts are involved here, and it is important not to confuse them:
  • declaration of a variable
    assertion of the scope of a variable
    assertion of whether the variable is RANGE or GLOBAL
NMODL requires that all variables be declared. Declarations are usually done in the
STATE, PARAMETER, or ASSIGNED blocks.

The classical programming notion of variable scope has to do with the "visibility" of a
variable outside of the block of code in which it is used. In NMODL, variables that have
been declared in the STATE, PARAMETER, or ASSIGNED blocks are global in the
classical programming sense, because they are visible throughout the entire mod file
and also at the hoc level. The properties of a variable that has been declared LOCAL
depend on whether the declaration was done inside or ouside of an equation definition
block (equation definition blocks include PROCEDURE, FUNCTION, DERIVATIVE,
KINETIC). A variable declared LOCAL outside an equation definition block has the same
scope and persistence as a static variable in C:
  • it is visible throughout the mechanism, but not visible to hoc
    it is shared between all instances of that mechanism
    it is initialized to 0
    it retains its value on exit from the mechanism
Declaring a variable LOCAL _inside_ an equation definition block means that
  • it is not visible outside the block
    it does not retain its value between invocations of the block
RANGE vs. GLOBAL is a NEURON-specific concept that is concerned with the
"anatomical extent" of a variable, but it also has some bearing on the visibility of a
variable from hoc. These assertions are made inside the NEURON block.

A RANGE variable may be inhomogeneous in space, but a GLOBAL variable has the
same value at all locations (i.e. for every instance of the mechanism, throughout a
model).
  • --PARAMETERs are GLOBAL by default, and visible from hoc
    --STATEs are RANGE by default, and visible from hoc
    --mechanism-specific ASSIGNED variables are RANGE by default, but they are not visible from hoc unless they also appear in a GLOBAL or RANGE statement in the NEURON block
    --ASSIGNED variables that are not mechanism-specific (v, celsius, t, dt, diam, area) _are_ visible from hoc but are not mentioned in the NEURON block. celsius is not a RANGE variable.
All this is discussed in chapter 9 of The NEURON Book, in the context of many practical
examples of usage.
Post Reply