NEURON
init.cpp
Go to the documentation of this file.
1 #include <../../nmodlconf.h>
2 /* /local/src/master/nrn/src/nmodl/init.c,v 4.5 1998/03/25 14:33:42 hines Exp */
3 
4 #include "modl.h"
5 #include "parse1.hpp"
6 
7 extern List *firstlist;
8 extern List *syminorder;
11 char buf[NRN_BUFSIZE]; /* volatile temporary buffer */
12 
13 static struct { /* Keywords */
14  char *name;
15  short kval;
16 } keywords[] = {
17  "VERBATIM", VERBATIM,
18  "COMMENT", COMMENT,
19  "TITLE", MODEL,
20  "CONSTANT", CONSTANT,
21  "PARAMETER", PARAMETER,
22  "INDEPENDENT", INDEPENDENT,
23  "ASSIGNED", DEPENDENT,
24  "INITIAL", INITIAL1,
25  "TERMINAL", TERMINAL,
26  "DERIVATIVE", DERIVATIVE,
27  "EQUATION", EQUATION,
28  "BREAKPOINT", BREAKPOINT,
29  "CONDUCTANCE", CONDUCTANCE,
30  "SOLVE", SOLVE,
31  "STATE", STATE,
32  "STEPPED", STEPPED,
33  "LINEAR", LINEAR,
34  "NONLINEAR", NONLINEAR,
35  "DISCRETE", DISCRETE,
36  "FUNCTION", FUNCTION1,
37  "FUNCTION_TABLE", FUNCTION_TABLE,
38  "PROCEDURE", PROCEDURE,
39  "PARTIAL", PARTIAL,
40  "INT", INT,
41  "DEL2", DEL2,
42  "DEL", DEL,
43  "LOCAL", LOCAL,
44  "METHOD", USING,
45  "STEADYSTATE", USING,
46  "SENS", SENS,
47  "STEP", STEP,
48  "WITH", WITH,
49  "FROM", FROM,
50  "FORALL", FORALL1,
51  "TO", TO,
52  "BY", BY,
53  "if", IF,
54  "else", ELSE,
55  "while", WHILE,
56  "START", START1,
57  "DEFINE", DEFINE1,
58  "KINETIC", KINETIC,
59  "CONSERVE", CONSERVE,
60  "PLOT", PLOT,
61  "VS", VS,
62  "LAG", LAG,
63  "RESET", RESET,
64  "MATCH", MATCH,
65  "MODEL_LEVEL", MODEL_LEVEL, /* inserted by merge */
66  "SWEEP", SWEEP,
67  "FIRST", FIRST,
68  "LAST", LAST,
69  "COMPARTMENT", COMPARTMENT,
70  "LONGITUDINAL_DIFFUSION", LONGDIFUS,
71  "PUTQ", PUTQ,
72  "GETQ", GETQ,
73  "IFERROR", IFERROR,
74  "SOLVEFOR", SOLVEFOR,
75  "UNITS", UNITS,
76  "UNITSON", UNITSON,
77  "UNITSOFF", UNITSOFF,
78  "TABLE", TABLE,
79  "DEPEND", DEPEND,
80  "NEURON", NEURON,
81  "SUFFIX", SUFFIX,
82  "POINT_PROCESS", SUFFIX,
83  "ARTIFICIAL_CELL", SUFFIX,
84  "NONSPECIFIC_CURRENT", NONSPECIFIC,
85  "ELECTRODE_CURRENT", ELECTRODE_CURRENT,
86  "SECTION", SECTION,
87  "RANGE", RANGE,
88  "USEION", USEION,
89  "READ", READ,
90  "WRITE", WRITE,
91  "VALENCE", VALENCE,
92  "CHARGE", VALENCE,
93  "GLOBAL", GLOBAL,
94  "POINTER", POINTER,
95  "BBCOREPOINTER", BBCOREPOINTER,
96  "EXTERNAL", EXTERNAL,
97  "INCLUDE", INCLUDE1,
98  "CONSTRUCTOR", CONSTRUCTOR,
99  "DESTRUCTOR", DESTRUCTOR,
100  "NET_RECEIVE", NETRECEIVE,
101  "BEFORE", BEFORE, /* before NEURON sets up cy' = f(y,t) */
102  "AFTER", AFTER, /* after NEURON solves cy' = f(y, t) */
103  "WATCH", WATCH,
104  "FOR_NETCONS", FOR_NETCONS,
105  "THREADSAFE", THREADSAFE,
106  "PROTECT", PROTECT,
107  "MUTEXLOCK", NRNMUTEXLOCK,
108  "MUTEXUNLOCK", NRNMUTEXUNLOCK,
109  "REPRESENTS", REPRESENTS,
110  0, 0
111 };
112 
113 /*
114  * the following special output tokens are used to make the .c file barely
115  * readable
116  */
117 static struct { /* special output tokens */
118  char *name;
119  short subtype;
121 } special[] = {
122  ";", SEMI, &semi,
123  "{", BEGINBLK, &beginblk,
124  "}", ENDBLK, &endblk,
125  0, 0, 0
126 };
127 
128 static struct { /* numerical methods */
129  char *name;
130  long subtype; /* All the types that will work with this */
131  short varstep;
132 } methods[] = {
133  "adams", DERF | KINF, 0,
134  "runge", DERF | KINF, 0,
135  "euler", DERF | KINF, 0,
136  "adeuler", DERF | KINF, 1,
137  "heun", DERF | KINF, 0,
138  "adrunge", DERF | KINF, 1,
139  "gear", DERF | KINF, 1,
140  "newton", NLINF, 0,
141  "simplex", NLINF, 0,
142  "simeq", LINF, 0,
143  "seidel", LINF, 0,
144  "_advance", KINF, 0,
145  "sparse", KINF, 0,
146  "derivimplicit", DERF, 0, /* name hard wired in deriv.c */
147  "cnexp", DERF, 0, /* see solve.c */
148  "clsoda", DERF | KINF, 1, /* Tolerance built in to scopgear.c */
149  "after_cvode", 0, 0,
150  "cvode_t", 0, 0,
151  "cvode_t_v", 0, 0,
152  0, 0, 0
153 };
154 
155 static char *extdef[] = { /* external names that can be used as doubles
156  * without giving an error message */
157 #include "extdef.h"
158  0
159 };
160 
161 static char *extdef2[] = { /* external function names that can be used
162  * with array and function name arguments */
163 #include "extdef2.h"
164  0
165 };
166 
167 static char *extdef3[] = { /* function names that get two reset arguments
168  * added */
169  "threshold",
170  "squarewave",
171  "sawtooth",
172  "revsawtooth",
173  "ramp",
174  "pulse",
175  "perpulse",
176  "step",
177  "perstep",
178  "stepforce",
179  "schedule",
180  0
181 };
182 
183 static char *extdef4[] = { /* functions that need a first arg of NrnThread* */
184  "at_time",
185  0
186 };
187 
188 static char *extdef5[] = { /* the extdef names that are not threadsafe */
189 #include "extdef5.h"
190  0
191 };
192 
194 
195 void init()
196 {
197  int i;
198  Symbol *s;
199 
200  symbol_init();
201  for (i = 0; keywords[i].name; i++) {
202  s = install(keywords[i].name, keywords[i].kval);
203  s->subtype = KEYWORD;
204  }
205  for (i = 0; methods[i].name; i++) {
206  s = install(methods[i].name, METHOD);
207  s->subtype = methods[i].subtype;
208  s->u.i = methods[i].varstep;
209  }
210  for (i = 0; special[i].name; i++) {
211  s = install(special[i].name, SPECIAL);
212  *(special[i].p) = s;
213  s->subtype = special[i].subtype;
214  }
215  for (i = 0; extdef[i]; i++) {
216  s = install(extdef[i], NAME);
217  s->subtype = EXTDEF;
218  }
219  for (i = 0; extdef2[i]; i++) {
220  s = install(extdef2[i], NAME);
221  s->subtype = EXTDEF2;
222  }
223  for (i = 0; extdef3[i]; i++) {
224  s = lookup(extdef3[i]);
225  assert(s && (s->subtype & EXTDEF));
226  s->subtype |= EXTDEF3;
227  }
228  for (i = 0; extdef4[i]; i++) {
229  s = lookup(extdef4[i]);
230  assert(s && (s->subtype & EXTDEF));
231  s->subtype |= EXTDEF4;
232  }
233  for (i = 0; extdef5[i]; i++) {
234  s = lookup(extdef5[i]);
235  assert(s);
236  s->subtype |= EXTDEF5;
237  }
238  intoken = newlist();
239  initfunc = newlist();
240  modelfunc = newlist();
241  termfunc = newlist();
242  procfunc = newlist();
243  initlist = newlist();
244  firstlist = newlist();
245  syminorder = newlist();
246  plotlist = newlist();
247  constructorfunc = newlist();
248  destructorfunc = newlist();
249 #if NMODL
250  nrninit();
251 #endif
252 }
#define KINF
Definition: model.h:132
#define assert(ex)
Definition: hocassrt.h:26
#define DERF
Definition: model.h:125
List * constructorfunc
Definition: init.cpp:193
short varstep
Definition: init.cpp:134
List * initfunc
Definition: init.cpp:8
#define INT
Definition: bbslsrv.cpp:7
#define STATE
Definition: membfunc.h:71
#define SPECIAL
Definition: model.h:100
List * initlist
Definition: init.cpp:8
Symbol * endblk
Definition: init.cpp:11
#define NRN_BUFSIZE
Definition: model.h:13
#define EXTDEF4
Definition: modl.h:214
int i
Definition: model.h:62
static struct @34 keywords[]
Symbol * beginblk
Definition: init.cpp:11
#define SUFFIX
Definition: units.cpp:58
Definition: model.h:15
void init()
Definition: init.cpp:169
void symbol_init()
Definition: symbol.cpp:13
#define EXTDEF5
Definition: modl.h:215
#define install
Definition: redef.h:82
_CONST char * s
Definition: system.cpp:74
Symbol ** p
Definition: init.cpp:123
List * procfunc
Definition: init.cpp:9
static char * extdef4[]
Definition: init.cpp:183
#define KEYWORD
Definition: model.h:113
void nrninit()
Definition: nocpout.cpp:209
Definition: model.h:57
char * name
Definition: init.cpp:16
List * newlist()
Definition: list.cpp:50
#define ENDBLK
Definition: model.h:124
#define NLINF
Definition: model.h:127
#define EXTDEF
Definition: model.h:131
NMODL parser global flags / functions.
#define lookup
Definition: redef.h:90
long subtype
Definition: model.h:59
short kval
Definition: init.cpp:17
static int PLOT(int, int, double, double)
Definition: axis.cpp:266
List * destructorfunc
Definition: init.cpp:193
static char * extdef5[]
Definition: init.cpp:188
static char * extdef3[]
Definition: init.cpp:167
#define EXTDEF2
Definition: modl.h:210
List * syminorder
Definition: init.cpp:10
List * intoken
Definition: init.cpp:12
#define LINF
Definition: model.h:126
long subtype
Definition: init.cpp:122
static char * extdef2[]
Definition: init.cpp:161
#define i
Definition: md1redef.h:12
Symbol * semi
Definition: init.cpp:11
static struct @36 methods[]
List * firstlist
Definition: init.cpp:8
char buf[512]
Definition: init.cpp:13
List * modelfunc
Definition: init.cpp:8
static struct @35 special[]
union Symbol::@18 u
#define EXTDEF3
Definition: modl.h:212
#define SEMI
Definition: model.h:122
static char * extdef[]
Definition: init.cpp:155
List * termfunc
Definition: init.cpp:8
#define BEGINBLK
Definition: model.h:123
#define MATCH(cond)
List * plotlist
Definition: init.cpp:9