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