tardebut wrote:in order to declare the value of an state as GLOBAL, the assigment of xout = state1 either at the end of the DERIVATIVE block or in the BEFORE BREAKPOINT block does the trick.
True, but I'm not sure that it is useful to do that. Suppose
1. foo is the name of such a mechanism, and
2. there is a model that has multiple instances of foo, and
3. each instance has a different value of state1 (STATEs are automatically RANGE variables and are likely to have values that differ across multiple instances of a mechanism)
Then
at the end of each advance, the value of foo's xout variable will be the value of state1 from the last instance of foo that was updated. And that is completely accidental--it depends on how the model was set up and how the model's equations are evaluated in the course of an advance.
Of course, if there is only one instance of foo, this problem doesn't arise.
Now, what seems to be a working solution for the communication is to declare in the NEURON block of the receiving mechanism,
EXTERNAL xout_fromwhereitwasdeclaredasglobal
Wow, I re-read the documentation of the NEURON block, and sure enough, there
is an EXTERNAL keyword that can be used in the NEURON block
http://www.neuron.yale.edu/neuron/stati ... l#external. I stand corrected, and I have learned something new and possibly useful. That said, I obviously haven't run into a situation in which some other strategy didn't work. Also, the requirement that the complete hoc name of the EXTERNAL variable be named in the NMODL file makes it difficult to write generalizable code. With POINTER, I can produce a mechanism that can be coupled to any other mechanism regardless of its name, because the coupling can be specified in hoc, instead of at the time that the NMODL code is compiled.
The original question regarding the comparison of this approach to the use of pointers comes from a message one get when compliling these .mod.
"Notice: Assignment to the GLOBAL variable, "xout", is not thread safe"
If a mechanism foo has some variable bar that is supposed to be GLOBAL, then every instance of foo is supposed to see the same value for bar. Under multithreaded code execution, each thread operates in its own address space, so there is no way that bar can be truly GLOBAL. At best, bar can be "GLOBAL on a per-thread basis" that is, thread j will have its own bar which has the same value for all foos in thread j, but the bar that belongs to thread k is likely to have a different value and can only be seen by the foos in thread k.