NEURON
init.cpp
Go to the documentation of this file.
1 #include <../../nmodlconf.h>
2 /* /local/src/master/nrn/src/modlunit/init.c,v 1.9 1998/03/25 14:33:55 hines Exp */
3 
4 #include "model.h"
5 #include "parse1.hpp"
6 
7 extern int unitonflag;
13 char buf[512]; /* volatile temporary buffer */
14 
15 static struct { /* Keywords */
16  char* name;
17  short kval;
18 } keywords[] = {"VERBATIM",
19  VERBATIM,
20  "ENDVERBATIM",
21  END_VERBATIM, /* explicit in lex.lpp */
22  "COMMENT",
23  COMMENT,
24  "ENDCOMMENT",
25  END_COMMENT, /* explicit in lex.lpp */
26  "TITLE",
27  TITLE,
28  "CONSTANT",
29  CONSTANT,
30  "PARAMETER",
31  PARAMETER,
32  "INDEPENDENT",
33  INDEPENDENT,
34  "ASSIGNED",
35  ASSIGNED,
36  "INITIAL",
37  INITIAL1,
38  "TERMINAL",
39  TERMINAL,
40  "DERIVATIVE",
41  DERIVATIVE,
42  "EQUATION",
43  EQUATION,
44  "BREAKPOINT",
45  BREAKPOINT,
46  "CONDUCTANCE",
47  CONDUCTANCE,
48  "SOLVE",
49  SOLVE,
50  "STATE",
51  STATE,
52  "STEPPED",
53  STEPPED,
54  "LINEAR",
55  LINEAR,
56  "NONLINEAR",
57  NONLINEAR,
58  "DISCRETE",
59  DISCRETE,
60  "FUNCTION",
61  FUNCTION1,
62  "FUNCTION_TABLE",
63  FUNCTION_TABLE,
64  "PROCEDURE",
65  PROCEDURE,
66  "PARTIAL",
67  PARTIAL,
68  "INT",
69  INT,
70  "DEL2",
71  DEL2,
72  "DEL",
73  DEL,
74  "LOCAL",
75  LOCAL,
76  "METHOD",
77  USING,
78  "STEADYSTATE",
79  USING,
80  "SENS",
81  SENS,
82  "STEP",
83  STEP,
84  "WITH",
85  WITH,
86  "FROM",
87  FROM,
88  "TO",
89  TO,
90  "BY",
91  BY,
92  "if",
93  IF,
94  "else",
95  ELSE,
96  "while",
97  WHILE,
98  "IF",
99  IF,
100  "ELSE",
101  ELSE,
102  "WHILE",
103  WHILE,
104  "START",
105  START1,
106  "DEFINE",
107  DEFINE1,
108  "KINETIC",
109  KINETIC,
110  "CONSERVE",
111  CONSERVE,
112  "PLOT",
113  PLOT,
114  "VS",
115  VS,
116  "LAG",
117  LAG,
118  "RESET",
119  RESET,
120  "MATCH",
121  MATCH,
122  "MODEL_LEVEL",
123  MODEL_LEVEL, /* inserted by merge */
124  "SWEEP",
125  SWEEP,
126  "FIRST",
127  FIRST,
128  "LAST",
129  LAST,
130  "COMPARTMENT",
131  COMPARTMENT,
132  "LONGITUDINAL_DIFFUSION",
133  LONGDIFUS,
134  "PUTQ",
135  PUTQ,
136  "GETQ",
137  GETQ,
138  "IFERROR",
139  IFERROR,
140  "SOLVEFOR",
141  SOLVEFOR,
142  "UNITS",
143  UNITBLK,
144  "UNITSON",
145  UNITSON,
146  "UNITSOFF",
147  UNITSOFF,
148  "TABLE",
149  TABLE,
150  "DEPEND",
151  DEPEND,
152  "NEURON",
153  NEURON,
154  "SUFFIX",
155  SUFFIX,
156  "POINT_PROCESS",
157  SUFFIX,
158  "ARTIFICIAL_CELL",
159  SUFFIX,
160  "NONSPECIFIC_CURRENT",
161  NONSPECIFIC,
162  "ELECTRODE_CURRENT",
163  ELECTRODE_CURRENT,
164  "USEION",
165  USEION,
166  "READ",
167  READ,
168  "WRITE",
169  WRITE,
170  "RANGE",
171  RANGE,
172  "SECTION",
173  SECTION,
174  "VALENCE",
175  VALENCE,
176  "CHARGE",
177  VALENCE,
178  "GLOBAL",
179  GLOBAL,
180  "POINTER",
181  POINTER,
182  "BBCOREPOINTER",
183  POINTER,
184  "EXTERNAL",
185  EXTERNAL,
186  "INCLUDE",
187  INCLUDE1,
188  "CONSTRUCTOR",
189  CONSTRUCTOR,
190  "DESTRUCTOR",
191  DESTRUCTOR,
192  "NET_RECEIVE",
193  NETRECEIVE,
194  "BEFORE",
195  BEFORE, /* before NEURON sets up cy' = f(y,t) */
196  "AFTER",
197  AFTER, /* after NEURON solves cy' = f(y, t) */
198  "WATCH",
199  WATCH,
200  "FOR_NETCONS",
201  FOR_NETCONS,
202  "THREADSAFE",
203  THREADSAFE,
204  "PROTECT",
205  PROTECT,
206  0,
207  0};
208 
209 /*
210  * the following special output tokens are used to make the .c file barely
211  * readable
212  */
213 static struct { /* special output tokens */
214  char* name;
215  long subtype;
217 } special[] = {";", SEMI, &semi, "{", BEGINBLK, &beginblk, "}", ENDBLK, &endblk, 0, 0, 0};
218 
219 static struct { /* numerical methods */
220  char* name;
221  long subtype; /* All the types that will work with this */
222  short varstep;
223 } methods[] = {"adams",
224  DERF | KINF,
225  0,
226  "runge",
227  DERF | KINF,
228  0,
229  "euler",
230  DERF | KINF,
231  0,
232  "adeuler",
233  DERF | KINF,
234  1,
235  "heun",
236  DERF | KINF,
237  0,
238  "adrunge",
239  DERF | KINF,
240  1,
241  "newton",
242  NLINF,
243  0,
244  "simplex",
245  NLINF,
246  0,
247  "simeq",
248  LINF,
249  0,
250  "seidel",
251  LINF,
252  0,
253  "_advance",
254  KINF,
255  0,
256  "sparse",
257  KINF,
258  0,
259  "derivimplicit",
260  DERF,
261  0, /* name hard wired in deriv.c */
262  "cnexp",
263  DERF,
264  0,
265  "clsoda",
266  DERF | KINF,
267  0, /* Tolerance built in to scopgear.c */
268  "after_cvode",
269  0,
270  0,
271  "cvode_t",
272  0,
273  0,
274  "cvode_t_v",
275  0,
276  0,
277  0,
278  0,
279  0};
280 
281 static char* extdef[] = {/* external names that can be used as doubles
282  * without giving an error message */
283 #include "extdef.h"
284  0};
285 
286 static char* extargs[] = {/* units of args to external functions */
287 /* format: name, returnunits, arg1unit, arg2unit, ..., 0, */
288 #include "extargs.h"
289  0};
290 
291 void init() {
292  int i;
293  Symbol* s;
294 
295  symbol_init();
296  for (i = 0; keywords[i].name; i++) {
297  s = install(keywords[i].name, keywords[i].kval);
298  s->subtype = KEYWORD;
299  }
300  for (i = 0; methods[i].name; i++) {
301  s = install(methods[i].name, METHOD);
302  s->subtype = methods[i].subtype;
303  s->u.i = methods[i].varstep;
304  }
305  for (i = 0; special[i].name; i++) {
306  s = install(special[i].name, SPECIAL);
307  *(special[i].p) = s;
308  s->subtype = special[i].subtype;
309  }
310  for (i = 0; extdef[i]; i++) {
311  s = install(extdef[i], NAME);
312  s->subtype = EXTDEF;
313  }
314  for (i = 0; extargs[i]; ++i) {
315  List* lu;
316  s = lookup(extargs[i++]);
317  assert(s);
318  s->u.str = extargs[i++];
319  lu = newlist();
320  while (extargs[i]) {
321  lappendstr(lu, extargs[i]);
322  ++i;
323  }
324  s->info = itemarray(3, ITEM0, ITEM0, lu);
325  }
326  intoken = newlist();
327  initfunc = newlist();
328  modelfunc = newlist();
329  termfunc = newlist();
330  procfunc = newlist();
331  initlist = newlist();
332  firstlist = newlist();
333  syminorder = newlist();
334  plotlist = newlist();
335  solvelist = newlist();
336  misc = newlist();
337 }
338 
339 /* init.c,v
340  * Revision 1.9 1998/03/25 14:33:55 hines
341  * Model descriptions of a POINT_PROCESS may contain a
342  * NET_RECEIVE(weight){statementlist}
343  * weight is a reference variable and may be changed within this block.
344  *
345  * Revision 1.8 1998/02/19 20:43:09 hines
346  * modlunit more up to date with respect to nmodl
347  *
348  * Revision 1.7 1997/11/20 21:34:34 hines
349  * can specify external function argument units for modlunit checking
350  * in nrn/src/modlunit/extargs.h
351  * for example at_time must take an argument with units of ms.
352  * Not all useful functions are listed at this time.
353  *
354  * Revision 1.6 1997/11/13 21:45:05 hines
355  * modlunit checks for LONGITUDINAL_DIFFUSION expr { state }
356  * are that expr has the units of micron4/ms, and that there exist a prior
357  * COMPARTMENT statement with a volume expression with units micron3/micron
358  *
359  * Revision 1.5 1997/07/29 20:21:43 hines
360  * mac port of nmodl, modlunit
361  *
362  * Revision 1.4 1997/06/26 20:12:09 hines
363  * modlunit more up to date with respect to allowed external functions.
364  *
365  * Revision 1.3 1995/07/16 13:05:30 hines
366  * FUNCTION_TABLE looks good so far
367  *
368  * Revision 1.2 1995/07/15 12:12:41 hines
369  * CONSTRUCTRO DESTRUCTOR handled
370  *
371  * Revision 1.1.1.1 1994/10/12 17:22:47 hines
372  * NEURON 3.0 distribution
373  *
374  * Revision 1.12 1994/09/26 18:51:06 hines
375  * USEION ... VALENCE real
376  *
377  * Revision 1.11 1994/05/18 18:08:13 hines
378  * INCLUDE "file"
379  * tries originalpath/file ./file MODL_INCLUDEpaths/file
380  *
381  * Revision 1.10 1993/07/08 14:36:28 hines
382  * An alternative to NONSPECIFIC_CURRENT is ELECTRODE_CURRENT
383  *
384  * Revision 1.9 92/06/01 13:25:30 hines
385  * NEURON {EXTERNAL name, name, ...} allowed
386  *
387  * Revision 1.8 92/02/17 12:30:50 hines
388  * constant states with a compartment size didn't have space allocated
389  * to store the compartment size.
390  *
391  * Revision 1.7 91/09/16 16:03:36 hines
392  * NEURON { RANGE SECTION GLOBAL} syntax
393  *
394  * Revision 1.6 91/01/29 07:10:29 hines
395  * POINT_PROCESS keyword allowed
396  *
397  * Revision 1.5 90/12/12 11:33:08 hines
398  * LOCAL vectors allowed. Some more NEURON syntax added
399  *
400  * Revision 1.4 90/11/23 13:43:41 hines
401  * BREAKPOINT PARAMETER
402  *
403  * Revision 1.3 90/11/20 15:30:23 hines
404  * added 4 varieties of unit factors. They are
405  * name = (real)
406  * name = ((unit) -> (unit)) must be conformable
407  * name = (physical_constant)
408  * name = (physical_constant (unit)) must be conformable
409  *
410  * Revision 1.2 90/11/15 13:00:23 hines
411  * function units and number units work. accepts NEURON block
412  *
413  * Revision 1.1 90/11/13 16:10:08 hines
414  * Initial revision
415  * */
char buf[512]
Definition: init.cpp:13
Symbol * semi
Definition: init.cpp:11
List * intoken
Definition: init.cpp:12
#define assert(ex)
Definition: hocassrt.h:32
#define i
Definition: md1redef.h:12
#define STATE
Definition: membfunc.h:71
#define DERF
Definition: model.h:125
#define LINF
Definition: model.h:126
#define ENDBLK
Definition: model.h:124
#define ITEM0
Definition: model.h:22
#define SPECIAL
Definition: model.h:100
#define EXTDEF
Definition: model.h:131
#define KINF
Definition: model.h:132
#define BEGINBLK
Definition: model.h:123
#define SEMI
Definition: model.h:122
#define KEYWORD
Definition: model.h:113
#define NLINF
Definition: model.h:127
void init()
Definition: init.cpp:291
List * plotlist
Definition: init.cpp:9
List * initfunc
Definition: init.cpp:8
List * procfunc
Definition: init.cpp:9
int unitonflag
Definition: units.cpp:45
char * name
Definition: init.cpp:16
Symbol * beginblk
Definition: init.cpp:11
static struct @17 methods[]
List * firstlist
Definition: init.cpp:8
Symbol ** p
Definition: init.cpp:216
List * syminorder
Definition: init.cpp:10
static char * extdef[]
Definition: init.cpp:281
List * initlist
Definition: init.cpp:8
List * misc
Definition: init.cpp:9
static struct @15 keywords[]
short kval
Definition: init.cpp:17
List * termfunc
Definition: init.cpp:8
List * solvelist
Definition: init.cpp:9
Symbol * endblk
Definition: init.cpp:11
static char * extargs[]
Definition: init.cpp:286
long subtype
Definition: init.cpp:215
List * modelfunc
Definition: init.cpp:8
short varstep
Definition: init.cpp:222
static struct @16 special[]
Item * lappendstr(List *list, char *str)
Definition: list.cpp:134
Item * itemarray(va_alist) va_dcl
Definition: list.cpp:339
List * newlist()
Definition: list.cpp:47
#define SUFFIX
Definition: units.cpp:63
void symbol_init()
Definition: symbol.cpp:13
#define MATCH(cond)
static int PLOT(int, int, double, double)
Definition: axis.cpp:268
#define INT
Definition: bbslsrv.cpp:7
#define lookup
Definition: redef.h:90
#define install
Definition: redef.h:82
Definition: model.h:15
Definition: model.h:57
int i
Definition: model.h:62
long subtype
Definition: model.h:59
Item * info
Definition: model.h:60
union Symbol::@18 u
char * str
Definition: model.h:63