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
assigned block
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: assigned block
Three different concepts are involved here, and it is important not to confuse them: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?
- declaration of a variable
assertion of the scope of a variable
assertion of whether the variable is RANGE or GLOBAL
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
- it is not visible outside the block
it does not retain its value between invocations of the block
"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.
examples of usage.