Hi Ted,
When i run NEURON through(nrniv) by double clicking the hoc file, I can enter any variable name in the nrniv window and get its value. How can i do this when i run NEURON in a parallel environment using the terminal ?
Thanks,
shyam
Accessing a variable on a particular host
Moderator: hines
-
- Site Admin
- Posts: 6358
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Accessing a variable on a particular host
Suppose there is some variable x and there are N hosts. If you just execute
a_statement_that_involves_x
you'll be accessing x on host 0. If you want to access x on a particular host, you could iterate over all host ids until you get to the right one. In pseudocode you'd do this by
To make this something that could be done conveniently from the command line, it would be useful to wrap the for loop inside a proc like so (more pseudocode follows):
Then you could type
onhost(2, "print xyz")
onhost(1, "a = 2")
or whatever.
To imitate a phrase from my favorite old calculus textbook,
"Implementation of the pseudocode in hoc is left as an exercise to the reader."
a_statement_that_involves_x
you'll be accessing x on host 0. If you want to access x on a particular host, you could iterate over all host ids until you get to the right one. In pseudocode you'd do this by
Code: Select all
for i = 0,number_of_hosts-1 {
if (host id == i) {
a_statement_that_involves_x
}
}
Code: Select all
// $s2 is a string that is to be executed
// $1 is the id of the host on which it is to be executed
proc onhost() {
if ($1 >= number of hosts) {
print "host ", $1, " doesn't exist"
} else {
for i = 0,number_of_hosts-1 {
if (host id == i) {
execute($s2)
}
}
}
}
onhost(2, "print xyz")
onhost(1, "a = 2")
or whatever.
To imitate a phrase from my favorite old calculus textbook,
"Implementation of the pseudocode in hoc is left as an exercise to the reader."
Re: Accessing a variable on a particular host
Thanks Ted. It works fine.
-
- Site Admin
- Posts: 6358
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Accessing a variable on a particular host
Good work. Thanks for asking the question, and for using NEURON in your research.