-
Notifications
You must be signed in to change notification settings - Fork 3
/
common.hoc
77 lines (73 loc) · 1.98 KB
/
common.hoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
load_file("netparmpi.hoc")
objref pnm, pc, tvec, idvec
proc pcell() {localobj s
s = new String()
sprint(s.s, "t%g", t)
pc.prcellstate($1, s.s)
}
proc spike2file() { localobj outf, s
if(dump_coreneuron_model) {
return
}
s = new String()
sprint(s.s, "out%s.dat", $s1)
outf = new File()
if (pc.id == 0) {outf.wopen(s.s) outf.close }
for pnm.serialize() {
outf.aopen(s.s)
for i=0, idvec.size-1 {
outf.printf("%.8g\t%d\n", tvec.x[i], idvec.x[i])
}
outf.close
}
}
proc prun() { local mode localobj po
mode = 0
if(dump_coreneuron_model) {
pc.nrnbbcore_write("coredat")
print "dump_coreneuron_model=1, finishing execution without simulation\n"
return
}
if (use_coreneuron || use_coreneuron_gpu) {
if (!nrnpython("from neuron import coreneuron")) {
printf("Python not available\n")
return
}
po = new PythonObject()
po.coreneuron.enable = 1
if(use_coreneuron_filemode) {
po.coreneuron.filemode = 1
}
if(use_coreneuron_gpu) {
po.coreneuron.gpu = 1
}
if(pc.id == 0) {
printf("nrncore_arg: |%s|\n", po.coreneuron.nrncore_arg(tstop))
}
mode = use_coreneuron_psolve_test_mode
} else {
tsav = startsw()
}
if (mode == 0) {
pc.psolve(tstop)
} else if (mode == 1) { // good for testing complete nrn->corenrn
po.coreneuron.enable = 0
pc.psolve(tstop/2) // nrn in arbitrary state
po.coreneuron.enable = 1
pc.psolve(tstop)
} else if (mode == 2) {
while (t < tstop) {
pc.psolve(t + 1)
}
} else {
while (t < tstop) {
po.coreneuron.enable = 0
pc.psolve(t + 0.5)
po.coreneuron.enable = 1
pc.psolve(t + 0.5)
}
}
if (!use_coreneuron && pc.id == 0) {
printf("psolve time %g\n", startsw() - tsav)
}
}