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