NEURON
init.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #include <nrnmpiuse.h>
3 
4 # include <stdio.h>
5 #include <errno.h>
6 #include <string.h>
7 #include <stdlib.h>
8 #include <unistd.h>
9 #include "section.h"
10 #include "parse.hpp"
11 #include "nrniv_mf.h"
12 #include "cabvars.h"
13 #include "neuron.h"
14 #include "membdef.h"
15 #include "nrnmpi.h"
16 
17 
18 
19 /* change this to correspond to the ../nmodl/nocpout nmodl_version_ string*/
20 static char nmodl_version_[] =
21  "7.7.0";
22 
23 static char banner[] =
24  "Duke, Yale, and the BlueBrain Project -- Copyright 1984-2021\n\
25 See http://neuron.yale.edu/neuron/credits\n";
26 
27 #ifdef WIN32
28 #if defined(HAVE_DLFCN_H) && !defined(__MINGW32__)
29 #include <dlfcn.h>
30 #else
31 #define RTLD_NOW 0
32 extern "C" {
33 extern void* dlopen(const char* name, int mode);
34 extern void* dlsym(void* handle, char* name);
35 extern int dlclose(void* handle);
36 extern char* dlerror();
37 }
38 #endif
39 /*#include "../mswin/windll/dll.h"*/
40 /*static struct DLL* dll;*/
41 #endif // WIN32
42 
43 #if defined(WIN32) || defined(NRNMECH_DLL_STYLE)
44 extern char* nrn_mech_dll; /* declared in hoc_init.cpp so ivocmain.cpp can see it */
45 extern int nrn_noauto_dlopen_nrnmech; /* default 0 declared in hoc_init.cpp */
46 #endif
47 
48 #if defined(WIN32)
49 #undef DLL_DEFAULT_FNAME
50 #define DLL_DEFAULT_FNAME "nrnmech.dll"
51 #endif // WIN32
52 
53 #if defined(NRNMECH_DLL_STYLE)
54 #if defined(DARWIN)
55 
56 #ifndef DLL_DEFAULT_FNAME
57 #define DLL_DEFAULT_FNAME "libnrnmech.dylib"
58 #endif
59 
60 // error message hint with regard to mismatched arch
61 void nrn_possible_mismatched_arch(const char* libname) {
62  if (strncmp(NRNHOSTCPU, "arm64", 5) == 0) {
63  // what arch are we running on
64 #if __arm64__
65  const char* we_are{"arm64"};
66 #elif __x86_64__
67  const char* we_are{"x86_64"};
68 #endif
69 
70  // what arch did we try to dlopen
71  char* cmd;
72  cmd = new char[strlen(libname) + 100];
73  sprintf(cmd, "lipo -archs %s 2> /dev/null", libname);
74  char libname_arch[20]{0};
75  FILE* p = popen(cmd, "r");
76  delete [] cmd;
77  if (!p) { return; }
78  fgets(libname_arch, 18, p);
79  if (strlen(libname_arch) == 0) {return;}
80  pclose(p);
81 
82  if (strstr(libname_arch, we_are) == NULL) {
83  fprintf(stderr, "libnrniv.dylib running as %s\n", we_are);
84  fprintf(stderr, "but %s can only run as %s\n", libname, libname_arch);
85  }
86  }
87 }
88 
89 #if __GNUC__ < 4
90 #include "osxdlfcn.h"
91 #include "osxdlfcn.cpp"
92 #else
93 #include <dlfcn.h>
94 #endif // __GNUC__
95 
96 #else
97 
98 #if defined(HAVE_DLFCN_H) && !defined(__MINGW32__)
99 #include <dlfcn.h>
100 #endif
101 
102 #ifndef DLL_DEFAULT_FNAME
103 #define DLL_DEFAULT_FNAME "./libnrnmech.so"
104 #endif
105 #endif
106 #else // !defined(NRNMECH_DLL_STYLE)
107 #if defined(HAVE_DLFCN_H) && !defined(__MINGW32__)
108 #include <dlfcn.h>
109 #endif
110 #endif
111 
112 # define CHECK(name) if (hoc_lookup(name) != (Symbol *)0){\
113  IGNORE(fprintf(stderr, CHKmes, name));\
114  nrn_exit(1);}
115 
116 static char CHKmes[] = "The user defined name, %s, already exists\n";
117 
119 
122 extern int nrn_nobanner_;
127 int nrn_global_ncell = 0; /* used to be rootnodecount */
128 extern double hoc_default_dll_loaded_;
129 extern int nrn_istty_;
130 extern int nrn_nobanner_;
131 
133  "Ra", 1e-6, 1e9,
134  "L", 1e-4, 1e20,
135  "diam", 1e-9, 1e9,
136  "cm", 0., 1e9,
137  "rallbranch", 1., 1e9,
138  "nseg", 1., 1e9,
139  "celsius", -273., 1e6,
140  "dt", 1e-9, 1e15,
141  0, 0., 0.
142 };
143 
145  "Ra", "ohm-cm",
146  "L", "um",
147  "diam", "um",
148  "cm", "uF/cm2",
149  "celsius", "degC",
150  "dt", "ms",
151  "t", "ms",
152  "v", "mV",
153  "i_cap", "mA/cm2",
154  0, 0
155 };
156 
158 extern int nrn_load_dll_recover_error();
159 extern void nrn_load_name_check(const char* name);
160 static int memb_func_size_;
163 short* memb_order_;
166 char* pnt_map; /* so prop_free can know its a point mech*/
168 
169 cTemplate** nrn_pnt_template_; /* for finding artificial cells */
170 /* for synaptic events. */
174 
175  /* values are type numbers of mechanisms which do net_send call */
183 
185  nrn_watch_allocate_[type] = waf;
186 }
187 
188 // also for read
189 using bbcore_write_t = void (*)(double*, int*, int*, int*, double*, Datum*, Datum*, NrnThread*);
192 
193 extern "C" void hoc_reg_bbcore_write(int type, bbcore_write_t f) {
194  nrn_bbcore_write_[type] = f;
195 }
196 
197 extern "C" void hoc_reg_bbcore_read(int type, bbcore_write_t f) {
198  nrn_bbcore_read_[type] = f;
199 }
200 
201 const char** nrn_nmodl_text_;
202 extern "C" void hoc_reg_nmodl_text(int type, const char* txt) {
203  nrn_nmodl_text_[type] = txt;
204 }
205 
206 const char** nrn_nmodl_filename_;
207 extern "C" void hoc_reg_nmodl_filename(int type, const char* filename) {
208  nrn_nmodl_filename_[type] = filename;
209 }
210 
211 extern "C" void add_nrn_has_net_event(int type) {
215 }
216 
217 /* values are type numbers of mechanisms which have FOR_NETCONS statement */
218 int nrn_fornetcon_cnt_; /* how many models have a FOR_NETCONS statement */
219 int* nrn_fornetcon_type_; /* what are the type numbers */
220 int* nrn_fornetcon_index_; /* what is the index into the ppvar array */
221 
222 extern "C" void add_nrn_fornetcons(int type, int indx) {
223  int i = nrn_fornetcon_cnt_++;
224  nrn_fornetcon_type_ = (int*)erealloc(nrn_fornetcon_type_, (i+1)*sizeof(int));
225  nrn_fornetcon_index_ = (int*)erealloc(nrn_fornetcon_index_, (i+1)*sizeof(int));
228 }
229 
230 /* array is parallel to memb_func. All are 0 except 1 for ARTIFICIAL_CELL */
233 
234 extern "C" void add_nrn_artcell(int type, int qi) {
237 }
238 
239 int nrn_is_artificial(int pnttype) {
240  return (int)nrn_is_artificial_[pointsym[pnttype]->subtype];
241 }
242 
243 int nrn_is_cable(void) {return 1;}
244 
245 void* nrn_realpath_dlopen(const char* relpath, int flags) {
246  char* abspath = NULL;
247  void* handle = NULL;
248 
249  /* use realpath or _fullpath even if is already a full path */
250 
251 #if defined(HAVE_REALPATH)
252  abspath = realpath(relpath, NULL);
253 #else /* not HAVE_REALPATH */
254 #if defined(__MINGW32__)
255  abspath = _fullpath(NULL, relpath, 0);
256 #else /* not __MINGW32__ */
257  abspath = strdup(relpath);
258 #endif /* not __MINGW32__ */
259 #endif /* not HAVE_REALPATH */
260  if (abspath) {
261  handle = dlopen(abspath, flags);
262 #if DARWIN
263  if (!handle) {
264  nrn_possible_mismatched_arch(abspath);
265  }
266 #endif
267  free(abspath);
268  }else{
269  int patherr = errno;
270  handle = dlopen(relpath, flags);
271  if (!handle) {
272  Fprintf(stderr, "realpath failed errno=%d (%s) and dlopen failed with %s\n", patherr, strerror(patherr), relpath);
273 #if DARWIN
274  nrn_possible_mismatched_arch(abspath);
275 #endif
276  }
277  }
278  return handle;
279 }
280 
281 int mswin_load_dll(const char* cp1) {
282  void* handle;
283  if (nrnmpi_myid < 1) if (!nrn_nobanner_ && nrn_istty_) {
284  fprintf(stderr, "loading membrane mechanisms from %s\n", cp1);
285  }
286 #if DARWIN
287  handle = nrn_realpath_dlopen(cp1, RTLD_NOW);
288 #else
289  handle = dlopen(cp1, RTLD_NOW);
290 #endif
291  if (handle) {
292  Pfrv mreg = (Pfrv)dlsym(handle, "modl_reg");
293  if (mreg) {
294  (*mreg)();
295  }else{
296  fprintf(stderr, "dlsym _modl_reg failed\n%s\n", dlerror());
297  dlclose(handle);
298  return 0;
299  }
300  return 1;
301  }else{
302  fprintf(stderr, "dlopen failed - \n%s\n", dlerror());
303  }
304  return 0;
305 }
306 
307 void hoc_nrn_load_dll(void) {
308  int i;
309  FILE* f;
310  const char* fn;
311  fn = expand_env_var(gargstr(1));
312  f = fopen(fn, "rb");
313  if (f) {
314  fclose(f);
315  nrn_load_dll_called_ = hoc_symlist;
318  /* If hoc_execerror, recover before that call */
319  i = mswin_load_dll(fn);
322  nrn_load_dll_called_ = (Symlist*)0;
323  hoc_retpushx((double)i);
324  }else{
325  hoc_retpushx(0.);
326  }
327 }
328 
329 extern void nrn_threads_create(int, int);
330 
331 static DoubScal scdoub[] = {
332  "t", &t,
333  "dt", &dt,
334  0,0
335 };
336 
337 void hoc_last_init(void)
338 {
339  int i;
340  Pfrv *m;
341  Symbol *s;
342 
343  hoc_register_var(scdoub, (DoubVec*)0, (VoidFunc*)0);
344  nrn_threads_create(1, 0); // single thread
345 
346  if (nrnmpi_myid < 1) if (nrn_nobanner_ == 0) {
347  extern char* nrn_version(int i);
348  Fprintf(stderr, "%s\n", nrn_version(1));
349  Fprintf(stderr, "%s\n", banner);
350  IGNORE(fflush(stderr));
351  }
352  memb_func_size_ = 30;
353  memb_func = (Memb_func*)ecalloc(memb_func_size_, sizeof(Memb_func));
354  memb_list = (Memb_list*)ecalloc(memb_func_size_, sizeof(Memb_list));
355  pointsym = (Symbol**)ecalloc(memb_func_size_, sizeof(Symbol*));
356  point_process = (Point_process**)ecalloc(memb_func_size_, sizeof(Point_process*));
357  pnt_map = static_cast<char *>(ecalloc(memb_func_size_, sizeof(char)));
358  memb_func[1].alloc = cab_alloc;
359  nrn_pnt_template_ = (cTemplate**)ecalloc(memb_func_size_, sizeof(cTemplate*));
362  pnt_receive_size = (short*)ecalloc(memb_func_size_, sizeof(short));
363  nrn_is_artificial_ = (short*)ecalloc(memb_func_size_, sizeof(short));
364  nrn_artcell_qindex_ = (short*)ecalloc(memb_func_size_, sizeof(short));
365  nrn_prop_param_size_ = (int*)ecalloc(memb_func_size_, sizeof(int));
366  nrn_prop_dparam_size_ = (int*)ecalloc(memb_func_size_, sizeof(int));
367  nrn_dparam_ptr_start_ = (int*)ecalloc(memb_func_size_, sizeof(int));
368  nrn_dparam_ptr_end_ = (int*)ecalloc(memb_func_size_, sizeof(int));
369  memb_order_ = (short*)ecalloc(memb_func_size_, sizeof(short));
370  bamech_ = (BAMech**)ecalloc(BEFORE_AFTER_SIZE, sizeof(BAMech*));
374  nrn_nmodl_text_ = (const char**)ecalloc(memb_func_size_, sizeof(const char*));
375  nrn_nmodl_filename_ = (const char**)ecalloc(memb_func_size_, sizeof(const char*));
377 
378 #if KEEP_NSEG_PARM
379  {extern int keep_nseg_parm_; keep_nseg_parm_ = 1; }
380 #endif
381 
382  section_list = hoc_l_newlist();
383 
384  CHECK("v");
385  s = hoc_install("v", RANGEVAR, 0.0, &hoc_symlist);
386  s->u.rng.type = VINDEX;
387 
388  CHECK("i_membrane_");
389  s = hoc_install("i_membrane_", RANGEVAR, 0.0, &hoc_symlist);
390  s->u.rng.type = IMEMFAST;
391 
392  for (i = 0; usrprop[i].name; i++) {
393  CHECK(usrprop[i].name);
394  s = hoc_install(usrprop[i].name, UNDEF, 0.0, &hoc_symlist);
395  s->type = VAR;
396  s->subtype = USERPROPERTY;
397  s->u.rng.type = usrprop[i].type;
398  s->u.rng.index = usrprop[i].index;
399  }
400  SectionList_reg();
401  SectionRef_reg();
402  register_mech(morph_mech, morph_alloc, (Pvmi)0, (Pvmi)0, (Pvmi)0, (Pvmi)0, -1, 0);
404  for (m = mechanism; *m; m++) {
405  (*m)();
406  }
407 #if !MAC && !defined(WIN32)
408  modl_reg();
409 #endif
410  hoc_register_limits(0, _hoc_parm_limits);
411  hoc_register_units(0, _hoc_parm_units);
412 #if defined(WIN32) || defined(NRNMECH_DLL_STYLE)
413  /* use the default if it exists (and not a binary special) */
415  FILE* ff = fopen(DLL_DEFAULT_FNAME, "r");
416  if (ff) {
417  fclose(ff);
418  nrn_mech_dll = DLL_DEFAULT_FNAME;
419  }
420  }
421  if (nrn_mech_dll) {
422  char *cp1, *cp2;
424 #if defined(WIN32)
425 /* Sometimes (windows 10 and launch recent enthought canopy) it seems that
426 mswin_load_dll fails if the filename is not a full path to nrnmech.dll
427 */
428 if (strcmp(nrn_mech_dll, "nrnmech.dll") == 0) {
429  char buf[5100];
430  char* retval = getcwd(buf, 4096);
431  if (retval) {
432  strncat(buf, "\\", 100);
433  strncat(buf, nrn_mech_dll, 100);
434  mswin_load_dll(buf);
435  }
436 }else{
437 #endif /*WIN32*/
438  for (cp1 = nrn_mech_dll; *cp1; cp1 = cp2) {
439  for (cp2 = cp1; *cp2; ++cp2) {
440  if (*cp2 == ';') {
441  *cp2 = '\0';
442  ++cp2;
443  break;
444  }
445  }
446  mswin_load_dll(cp1);
447  }
448 #if defined(WIN32)
449 }
450 #endif /*WIN32*/
451  }
452 #endif /* WIN32 || NRNMECH_DLL_STYLE */
453  s = hoc_lookup("section_owner");
454  s->type = OBJECTFUNC;
455 
456  /* verify that all ions have a defined CHARGE */
458 }
459 
460 void initnrn(void) {
461  secondorder = DEF_secondorder; /* >0 means crank-nicolson. 2 means currents
462  adjusted to t+dt/2 */
463  t = 0; /* msec */
464  dt = DEF_dt; /* msec */
465  clamp_resist = DEF_clamp_resist; /*megohm*/
466  celsius = DEF_celsius; /* degrees celsius */
467  hoc_retpushx(1.);
468 }
469 
470 static int pointtype = 1; /* starts at 1 since 0 means not point in pnt_map*/
472 
473 /* if vectorized then thread_data_size added to it */
475  const char **m,
476  Pvmp alloc,
477  Pvmi cur,
478  Pvmi jacob,
479  Pvmi stat,
480  Pvmi initialize,
481  int nrnpointerindex, /* if -1 then there are none */
482  int vectorized
483 ){
484  static int type = 2; /* 0 unused, 1 for cable section */
485  int j, k, modltype, pindx, modltypemax;
486  Symbol *s;
487  const char **m2;
488 
489  nrn_load_name_check(m[1]);
490 
491  if (type >= memb_func_size_) {
492  memb_func_size_ += 20;
493  memb_func = (Memb_func*)erealloc(memb_func, memb_func_size_*sizeof(Memb_func));
494  memb_list = (Memb_list*)erealloc(memb_list, memb_func_size_*sizeof(Memb_list));
495  pointsym = (Symbol**)erealloc(pointsym, memb_func_size_*sizeof(Symbol*));
496  point_process = (Point_process**)erealloc(point_process, memb_func_size_*sizeof(Point_process*));
497  pnt_map = static_cast<char *>(erealloc(pnt_map, memb_func_size_*sizeof(char)));
498  nrn_pnt_template_ = (cTemplate**)erealloc(nrn_pnt_template_, memb_func_size_*sizeof(cTemplate*));
501  pnt_receive_size = (short*)erealloc(pnt_receive_size, memb_func_size_*sizeof(short));
508  memb_order_ = (short*)erealloc(memb_order_, memb_func_size_*sizeof(short));
511  nrn_nmodl_text_ = (const char**)erealloc(nrn_nmodl_text_, memb_func_size_*sizeof(const char*));
512  nrn_nmodl_filename_ = (const char**)erealloc(nrn_nmodl_filename_, memb_func_size_*sizeof(const char*));
514  for (j=memb_func_size_ - 20; j < memb_func_size_; ++j) {
515  pnt_map[j] = 0;
516  point_process[j] = (Point_process*)0;
517  pointsym[j] = (Symbol*)0;
518  nrn_pnt_template_[j] = (cTemplate*)0;
521  pnt_receive_size[j] = 0;
522  nrn_is_artificial_[j] = 0;
523  nrn_artcell_qindex_[j] = 0;
524  memb_order_[j] = 0;
527  nrn_nmodl_text_[j] = (const char*)0;
528  nrn_nmodl_filename_[j] = (const char*) 0;
530  }
531  nrn_mk_prop_pools(memb_func_size_);
532  }
533 
534  nrn_prop_param_size_[type] = 0; /* fill in later */
535  nrn_prop_dparam_size_[type] = 0; /* fill in later */
536  nrn_dparam_ptr_start_[type] = 0; /* fill in later */
537  nrn_dparam_ptr_end_[type] = 0; /* fill in later */
538  memb_func[type].current = cur;
539  memb_func[type].jacob = jacob;
540  memb_func[type].alloc = alloc;
541  memb_func[type].state = stat;
542  memb_func[type].initialize = initialize;
543  memb_func[type].destructor = nullptr;
544 #if VECTORIZE
545  memb_func[type].vectorized = vectorized ? 1:0;
546  memb_func[type].thread_size_ = vectorized ? (vectorized - 1) : 0;
547  memb_func[type].thread_mem_init_ = nullptr;
548  memb_func[type].thread_cleanup_ = nullptr;
549  memb_func[type].thread_table_check_ = nullptr;
550  memb_func[type]._update_ion_pointers = nullptr;
551  memb_func[type].is_point = 0;
552  memb_func[type].hoc_mech = nullptr;
553  memb_func[type].setdata_ = nullptr;
554  memb_func[type].dparam_semantics = (int*)0;
555  memb_list[type].nodecount = 0;
556  memb_list[type]._thread = (Datum*)0;
557  memb_order_[type] = type;
558 #endif
559 #if CVODE
560  memb_func[type].ode_count = nullptr;
561  memb_func[type].ode_map = nullptr;
562  memb_func[type].ode_spec = nullptr;
563  memb_func[type].ode_matsol = nullptr;
564  memb_func[type].ode_synonym = nullptr;
565  memb_func[type].singchan_ = nullptr;
566 #endif
567  /* as of 5.2 nmodl translates so that the version string
568  is the first string in m. This allows the neuron application
569  to determine if nmodl c files are compatible with this version
570  Note that internal mechanisms have a version of "0" and are
571  by nature consistent.
572  */
573 
574 /*printf("%s %s\n", m[0], m[1]);*/
575  if (strcmp(m[0], "0") == 0) { /* valid by nature */
576  }else if (m[0][0] > '9') { /* must be 5.1 or before */
577 Fprintf(stderr, "Mechanism %s needs to be re-translated.\n\
578 It's pre version 6.0 \"c\" code is incompatible with this neuron version.\n", m[0]);
580  hoc_execerror("Mechanism needs to be retranslated:", m[0]);
581  }else{
582  nrn_exit(1);
583  }
584  }else if (strcmp(m[0], nmodl_version_) != 0){
585 Fprintf(stderr, "Mechanism %s needs to be re-translated.\n\
586 It's version %s \"c\" code is incompatible with this neuron version.\n",
587 m[1], m[0]);
589  hoc_execerror("Mechanism needs to be retranslated:", m[1]);
590  }else{
591  nrn_exit(1);
592  }
593  }
594 
595  s = hoc_install(m[1], MECHANISM, 0.0, &hoc_symlist);
596  s->subtype = type;
597  memb_func[type].sym = s;
598 /* printf("%s type=%d\n", s->name, type);*/
599  m2 = m + 2;
600  if (nrnpointerindex == -1) {
601  modltypemax = STATE;
602  } else {
603  modltypemax = NRNPOINTER;
604  }
605  for (k=0, j=0, modltype=nrnocCONST; modltype<=modltypemax; modltype++, j++){
606  /*EMPTY*/
607  for (; m2[j]; j++, k++) {
608  ;
609  }
610  }
611  s->s_varn = k;
612  s->u.ppsym = (Symbol **) emalloc((unsigned)(j*sizeof(Symbol *)));
613 /* this is set up for the possiblility of overloading range variables.
614 We are currently not allowing this. Hence the #if.
615 If never overloaded then no reason for list of symbols for each mechanism.
616 */
617 /* the indexing is confusing because k refers to index in the range indx list
618 and j refers to index in mechanism list which has 0 elements to separate
619 nrnocCONST, DEPENDENT, and STATE */
620 /* variable pointers added on at end, if they exist */
621 /* allowing range variable arrays. Must extract dimension info from name[%d]*/
622 /* pindx refers to index into the p-array */
623  pindx = 0;
624  for (j=0, k=0, modltype=nrnocCONST; modltype <= modltypemax; modltype++, j++) {
625  for (; m2[j]; j++, k++) {
626  Symbol *s2;
627  char buf[200], *cp; int indx; unsigned nsub=0;
628  strcpy(buf, m2[j]); /* not allowed to change constant string */
629  indx = 1;
630  cp = strchr(buf, '[');
631  if (cp) {
632 #if EXTRACELLULAR
633  if (cp[1] == 'N') {
634  indx = nlayer;
635  }else
636 #endif
637  {
638  sscanf(cp+1, "%d", &indx);
639  }
640  nsub = 1;
641  *cp = '\0';
642  }
643  /*SUPPRESS 624*/
644  if ((s2 = hoc_lookup(buf))) {
645 #if 0
646  if (s2->subtype != RANGEVAR) {
647  IGNORE(fprintf(stderr, CHKmes,
648  buf));
649  }
650 #else
651 IGNORE(fprintf(stderr, CHKmes, buf));
652 #endif
653  }else{
654  s2 = hoc_install(buf, RANGEVAR, 0.0, &hoc_symlist);
655  s2->subtype = modltype;
656  s2->u.rng.type = type;
657  s2->cpublic = 1;
658  if (modltype == NRNPOINTER) { /* not in p array */
659  s2->u.rng.index = nrnpointerindex;
660  } else {
661  s2->u.rng.index = pindx;
662  }
663  if (nsub) {
664  s2->arayinfo = (Arrayinfo *) emalloc(
665  sizeof(Arrayinfo) + nsub * sizeof(int));
666  s2->arayinfo->a_varn = (unsigned *)0;
667  s2->arayinfo->refcount = 1;
668  s2->arayinfo->nsub = nsub;
669  s2->arayinfo->sub[0] = indx;
670  }
671  if (modltype == NRNPOINTER) {
672  if (nrn_dparam_ptr_end_[type] == 0) {
673  nrn_dparam_ptr_start_[type] = nrnpointerindex;
674  }
675  nrnpointerindex += indx;
676  nrn_dparam_ptr_end_[type] = nrnpointerindex;
677  }else {
678  pindx += indx;
679  }
680  }
681  s->u.ppsym[k] = s2;
682  }
683  }
684  ++type;
685  n_memb_func = type;
686 }
687 
688 extern "C" void register_mech(
689  const char **m,
690  Pvmp alloc,
691  Pvmi cur,
692  Pvmi jacob,
693  Pvmi stat,
694  Pvmi initialize,
695  int nrnpointerindex, /* if -1 then there are none */
696  int vectorized
697 ){
698  int type = n_memb_func;
699  nrn_register_mech_common(m, alloc, cur, jacob, stat, initialize,
700  nrnpointerindex, vectorized);
701  if (nrnpy_reg_mech_p_) {
702  (*nrnpy_reg_mech_p_)(type);
703  }
704 }
705 
706 extern "C" void nrn_writes_conc(int type, int unused) {
707  static int lastion = EXTRACELL+1;
708  int i;
709  for (i=n_memb_func - 2; i >= lastion; --i) {
710  memb_order_[i+1] = memb_order_[i];
711  }
712  memb_order_[lastion] = type;
713 #if 0
714  printf("%s reordered from %d to %d\n", memb_func[type].sym->name, type, lastion);
715 #endif
716  if (nrn_is_ion(type)) {
717  ++lastion;
718  }
719 }
720 
721 extern "C" void hoc_register_prop_size(int type, int psize, int dpsize) {
722  nrn_prop_param_size_[type] = psize;
723  nrn_prop_dparam_size_[type] = dpsize;
724  if (memb_func[type].dparam_semantics) {
725  free(memb_func[type].dparam_semantics);
726  memb_func[type].dparam_semantics = (int*)0;
727  }
728  if (dpsize) {
729  memb_func[type].dparam_semantics = (int*)ecalloc(dpsize, sizeof(int));
730  }
731 }
732 extern "C" void hoc_register_dparam_semantics(int type, int ix, const char* name) {
733  /* only interested in area, iontype, cvode_ieq,
734  netsend, pointer, pntproc, bbcorepointer, watch, diam,
735  fornetcon,
736  xx_ion and #xx_ion which will get
737  a semantics value of -1, -2, -3,
738  -4, -5, -6, -7, -8, -9, -10
739  type, and type+1000 respectively
740  */
741  if (strcmp(name, "area") == 0) {
742  memb_func[type].dparam_semantics[ix] = -1;
743  }else if (strcmp(name, "iontype") == 0) {
744  memb_func[type].dparam_semantics[ix] = -2;
745  }else if (strcmp(name, "cvodeieq") == 0) {
746  memb_func[type].dparam_semantics[ix] = -3;
747  }else if (strcmp(name, "netsend") == 0) {
748  memb_func[type].dparam_semantics[ix] = -4;
749  }else if (strcmp(name, "pointer") == 0) {
750  memb_func[type].dparam_semantics[ix] = -5;
751  }else if (strcmp(name, "pntproc") == 0) {
752  memb_func[type].dparam_semantics[ix] = -6;
753  }else if (strcmp(name, "bbcorepointer") == 0) {
754  memb_func[type].dparam_semantics[ix] = -7;
755  }else if (strcmp(name, "watch") == 0) {
756  memb_func[type].dparam_semantics[ix] = -8;
757  }else if (strcmp(name, "diam") == 0) {
758  memb_func[type].dparam_semantics[ix] = -9;
759  }else if (strcmp(name, "fornetcon") == 0) {
760  memb_func[type].dparam_semantics[ix] = -10;
761  }else{
762  int i = 0;
763  if (name[0] == '#') { i = 1; }
764  Symbol* s = hoc_lookup(name+i);
765  if (s && s->type == MECHANISM) {
766  memb_func[type].dparam_semantics[ix] = s->subtype + i*1000;
767  }else{
768 fprintf(stderr, "mechanism %s : unknown semantics for %s\n", memb_func[type].sym->name, name);
769 assert(0);
770  }
771  }
772 #if 0
773  printf("dparam semantics %s ix=%d %s %d\n", memb_func[type].sym->name,
774  ix, name, memb_func[type].dparam_semantics[ix]);
775 #endif
776 }
777 
778 #if CVODE
779 extern "C" void hoc_register_cvode(
780  int i,
783  Pvmi spec,
784  Pvmi matsol
785 ){
786  memb_func[i].ode_count = cnt;
787  memb_func[i].ode_map = map;
788  memb_func[i].ode_spec = spec;
789  memb_func[i].ode_matsol = matsol;
790 }
791 extern "C" void hoc_register_synonym(int i, void (*syn)(int, double**, Datum**)){
792  memb_func[i].ode_synonym = syn;
793 }
794 #endif
795 
796 extern "C" void register_destructor(Pvmp d) {
797  memb_func[n_memb_func - 1].destructor = d;
798 }
799 
801  pointsym[pointtype] = s2;
802  s2->cpublic = 0;
804  memb_func[n_memb_func-1].is_point = 1;
805  if (nrnpy_reg_mech_p_) {
806  (*nrnpy_reg_mech_p_)(n_memb_func-1);
807  }
808  return pointtype++;
809 }
810 
811 extern void class2oc(const char *,
812  void *(*cons)(Object *),
813  void (*destruct)(void *),
814  Member_func *,
815  int (*checkpoint)(void **),
818 );
819 
820 
821 extern "C" int point_register_mech(
822  const char **m,
823  Pvmp alloc,
824  Pvmi cur,
825  Pvmi jacob,
826  Pvmi stat,
827  Pvmi initialize,
828  int nrnpointerindex,
829  int vectorized,
830 
831  void* (*constructor)(Object*),
832  void (*destructor)(void*),
833  Member_func* fmember
834 ){
835  extern void steer_point_process(void* v);
836  Symlist* sl;
837  Symbol* s, *s2;
838  nrn_load_name_check(m[1]);
839  class2oc(m[1], constructor, destructor, fmember, nullptr, nullptr, nullptr);
840  s = hoc_lookup(m[1]);
841  sl = hoc_symlist;
845  nrn_register_mech_common(m, alloc, cur, jacob, stat, initialize,
846  nrnpointerindex, vectorized);
847  nrn_pnt_template_[n_memb_func-1] = s->u.ctemplate;
848  s2 = hoc_lookup(m[1]);
849  hoc_symlist = sl;
850  return point_reg_helper(s2);
851 }
852 
853 /* some stuff from scopmath needed for built-in models */
854 
855 #if 0
856 double* makevector(int nrows)
857 {
858  double* v;
859  v = (double*)emalloc((unsigned)(nrows*sizeof(double)));
860  return v;
861 }
862 #endif
863 
865 extern "C" void _modl_cleanup(void){}
866 
867 #if 1
868 extern "C" void _modl_set_dt(double newdt) {
869  dt = newdt;
870  nrn_threads->_dt = newdt;
871 }
872 extern "C" void _modl_set_dt_thread(double newdt, NrnThread* nt) {
873  nt->_dt = newdt;
874 }
875 extern "C" double _modl_get_dt_thread(NrnThread* nt) {
876  return nt->_dt;
877 }
878 #endif
879 
880 extern "C" int nrn_pointing(double* pd) {
881  return pd ? 1 : 0;
882 }
883 
885 extern "C" void state_discontinuity(int i, double* pd, double d) {
886  if (state_discon_allowed_ && state_discon_flag_ == 0) {
887  *pd = d;
888 /*printf("state_discontinuity t=%g pd=%lx d=%g\n", t, (long)pd, d);*/
889  }
890 }
891 
893 {
894  int i;
895  Symbol* sym;
896  for (i=0; limits[i].name; ++i) {
897  sym = (Symbol*)0;
898  if (type && memb_func[type].is_point) {
899  Symbol* t;
900  t = hoc_lookup(memb_func[type].sym->name);
901  sym = hoc_table_lookup(
902  limits[i].name,
903  t->u.ctemplate->symtable
904  );
905  }
906  if (!sym) {
907  sym = hoc_lookup(limits[i].name);
908  }
909  hoc_symbol_limits(sym, limits[i].bnd[0], limits[i].bnd[1]);
910  }
911 }
912 
914 {
915  int i;
916  Symbol* sym;
917  for (i=0; units[i].name; ++i) {
918  sym = (Symbol*)0;
919  if (type && memb_func[type].is_point) {
920  Symbol* t;
921  t = hoc_lookup(memb_func[type].sym->name);
922  sym = hoc_table_lookup(
923  units[i].name,
924  t->u.ctemplate->symtable
925  );
926  }
927  if (!sym) {
928  sym = hoc_lookup(units[i].name);
929  }
930  hoc_symbol_units(sym, units[i].units);
931  }
932 }
933 
934 void hoc_reg_ba(int mt, nrn_bamech_t f, int type)
935 {
936  BAMech* bam;
937  switch (type) { /* see bablk in src/nmodl/nocpout.cpp */
938  case 11: type = BEFORE_BREAKPOINT; break;
939  case 22: type = AFTER_SOLVE; break;
940  case 13: type = BEFORE_INITIAL; break;
941  case 23: type = AFTER_INITIAL; break;
942  case 14: type = BEFORE_STEP; break;
943  default:
944 printf("before-after processing type %d for %s not implemented\n", type, memb_func[mt].sym->name);
945  nrn_exit(1);
946  }
947  bam = (BAMech*)emalloc(sizeof(BAMech));
948  bam->f = f;
949  bam->type = mt;
950  bam->next = bamech_[type];
951  bamech_[type] = bam;
952 }
953 
954 extern "C" void _cvode_abstol(Symbol** s, double* tol, int i)
955 {
956 #if CVODE
957  if (s && s[i]->extra) {
958  double x;
959  x = s[i]->extra->tolerance;
960  if (x != 0) {
961  tol[i] *= x;
962  }
963  }
964 #endif
965 }
966 
967 extern Node** node_construct(int);
968 
969 extern "C" void hoc_register_tolerance(int type, HocStateTolerance* tol, Symbol*** stol)
970 {
971 #if CVODE
972  int i;
973  Symbol* sym;
974 /*printf("register tolerance for %s\n", memb_func[type].sym->name);*/
975  for (i = 0; tol[i].name; ++i) {
976  if (memb_func[type].is_point) {
977  Symbol* t;
978  t = hoc_lookup(memb_func[type].sym->name);
979  sym = hoc_table_lookup(
980  tol[i].name,
981  t->u.ctemplate->symtable
982  );
983  }else{
984  sym = hoc_lookup(tol[i].name);
985  }
986  hoc_symbol_tolerance(sym, tol[i].tolerance);
987  }
988 
989  if (memb_func[type].ode_count) {
990  Symbol** psym, *msym, *vsym;
991  double **pv;
992  Node** pnode;
993  Prop* p;
994  int i, j, k, n, na, index=0;
995 
996  n = (*memb_func[type].ode_count)(type);
997  if (n > 0) {
998  psym = (Symbol**)ecalloc(n, sizeof(Symbol*));
999  pv = (double**)ecalloc(2*n, sizeof(double*));
1000  pnode = node_construct(1);
1001 prop_alloc(&(pnode[0]->prop), MORPHOLOGY, pnode[0]); /* in case we need diam */
1002 p = prop_alloc(&(pnode[0]->prop), type, pnode[0]); /* this and any ions */
1003 (*memb_func[type].ode_map)(0, pv, pv+n, p->param, p->dparam, (double*)0, type);
1004  for (i=0; i < n; ++i) {
1005  for (p = pnode[0]->prop; p; p = p->next) {
1006  if (pv[i] >= p->param && pv[i] < (p->param + p->param_size)) {
1007  index = pv[i] - p->param;
1008  break;
1009  }
1010  }
1011 
1012  /* p is the prop and index is the index
1013  into the p->param array */
1014  assert(p);
1015  /* need to find symbol for this */
1016  msym = memb_func[p->type].sym;
1017  for (j=0; j < msym->s_varn; ++j) {
1018  vsym = msym->u.ppsym[j];
1019  if (vsym->type == RANGEVAR && vsym->u.rng.index == index) {
1020  psym[i] = vsym;
1021 /*printf("identified %s at index %d of %s\n", vsym->name, index, msym->name);*/
1022  if (ISARRAY(vsym)) {
1023  na = vsym->arayinfo->sub[0];
1024  for (k=1; k < na; ++k) {
1025  psym[++i] = vsym;
1026  }
1027  }
1028  break;
1029  }
1030  }
1031  assert (j < msym->s_varn);
1032  }
1033 
1034  node_destruct(pnode, 1);
1035  *stol = psym;
1036  free (pv);
1037  }
1038  }
1039 #endif
1040 }
1041 
1042 extern "C" void _nrn_thread_reg(int i, int cons, void(*f)(Datum*)) {
1043  if (cons == 1) {
1044  memb_func[i].thread_mem_init_ = f;
1045  }else if (cons == 0) {
1046  memb_func[i].thread_cleanup_ = f;
1047  }else if (cons == 2) {
1048  memb_func[i]._update_ion_pointers = f;
1049  }
1050 }
1051 
1052 extern "C" void _nrn_thread_table_reg(int i, void (*f)(double*, Datum*, Datum*, NrnThread*, int)) {
1053  memb_func[i].thread_table_check_ = f;
1054 }
1055 
1056 extern "C" void _nrn_setdata_reg(int i, void(*call)(Prop*)) {
1057  memb_func[i].setdata_ = call;
1058 }
1059 /* there is some question about the _extcall_thread variables, if any. */
1060 extern "C" double nrn_call_mech_func(Symbol* s, int narg, Prop* p, int type) {
1061  extern double hoc_call_func(Symbol*, int);
1062  void (*call)(Prop*) = memb_func[type].setdata_;
1063  if (call) {
1064  (*call)(p);
1065  }
1066  return hoc_call_func(s, narg);
1067 }
1068 
1070  if (ifarg(1)) {
1071  int arg = (int)chkarg(1, 0, 1);
1073  }
1075 }
int state_discon_flag_
Definition: init.cpp:884
Definition: hocdec.h:84
int param_size
Definition: section.h:217
void * ecalloc(size_t n, size_t size)
Definition: symbol.cpp:221
void hoc_register_units(int type, HocParmUnits *units)
Definition: init.cpp:913
char * strstr(cs, ct) char *cs
hoc_List * hoc_l_newlist()
double * param
Definition: section.h:218
#define assert(ex)
Definition: hocassrt.h:26
short type
Definition: cabvars.h:10
void nrn_verify_ion_charge_defined()
Definition: eion.cpp:232
pclose(FILE *p)
Definition: macprt.cpp:107
void * erealloc(void *ptr, size_t n)
Definition: symbol.cpp:267
static HocParmLimits _hoc_parm_limits[]
Definition: init.cpp:132
void(* pnt_receive_t)(Point_process *, double *, double)
Definition: nrniv_mf.h:14
int thread_size_
Definition: membfunc.h:48
static char banner[]
Definition: init.cpp:23
#define CHECK(name)
Definition: init.cpp:112
#define nrnocCONST
Definition: membfunc.h:69
#define prop
Definition: md1redef.h:29
static int pointtype
Definition: init.cpp:470
float tolerance
Definition: hocdec.h:113
void hoc_symbol_limits(Symbol *sym, float low, float high)
Definition: code2.cpp:99
int point_reg_helper(Symbol *s2)
Definition: init.cpp:800
static realtype retval
void nrn_mk_prop_pools(int)
Definition: cxprop.cpp:255
short type
Definition: model.h:58
const char * dlerror(void)
Definition: osxdlfcn.cpp:174
static HocParmLimits limits[]
Definition: extcelln.cpp:33
int nsub
Definition: hocdec.h:70
short * nrn_artcell_qindex_
Definition: init.cpp:232
static void pnode(Prop *)
Definition: psection.cpp:47
void hoc_reg_bbcore_write(int type, bbcore_write_t f)
Definition: init.cpp:193
void nrn_writes_conc(int type, int unused)
Definition: init.cpp:706
void register_destructor(Pvmp d)
Definition: init.cpp:796
Symbol * hoc_lookup(const char *)
Symlist * symtable
Definition: hocdec.h:196
void
const char ** nrn_nmodl_filename_
Definition: init.cpp:206
#define NRNPOINTER
Definition: nocpout.cpp:100
Pvmi current
Definition: membfunc.h:33
Represent main neuron object computed by single thread.
Definition: multicore.h:58
Symlist * nrn_load_dll_called_
Definition: hocusr.cpp:17
int nrn_is_artificial(int pnttype)
Definition: init.cpp:239
int nrn_load_dll_recover_error()
Definition: hocusr.cpp:22
#define STATE
Definition: membfunc.h:71
const char * expand_env_var(const char *s)
Definition: fileio.cpp:146
#define VINDEX
Definition: membfunc.h:61
void hoc_reg_nmodl_text(int type, const char *txt)
Definition: init.cpp:202
int _nrnunit_use_legacy_
Definition: hoc_init.cpp:273
char * name
Definition: model.h:72
#define IMEMFAST
Definition: membfunc.h:60
static int ode_count(int type)
Definition: kschan.cpp:114
void(* thread_cleanup_)(Datum *)
Definition: membfunc.h:50
void morph_alloc(Prop *p)
Definition: cabcode.cpp:413
static int narg()
Definition: ivocvect.cpp:135
#define Fprintf
Definition: model.h:249
char * nrn_mech_dll
Definition: hoc_init.cpp:269
#define v
Definition: md1redef.h:4
int nrn_sparse_partrans
Definition: init.cpp:125
void(* nrnpy_reg_mech_p_)(int)
Definition: init.cpp:118
#define AFTER_INITIAL
Definition: membfunc.h:74
void * hoc_mech
Definition: membfunc.h:54
static philox4x32_key_t k
Definition: nrnran123.cpp:11
char * nrn_version(int)
Definition: nrnversion.cpp:27
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
void nrnunit_use_legacy()
Definition: init.cpp:1069
#define AFTER_SOLVE
Definition: membfunc.h:76
int dlclose(void *handle)
Definition: osxdlfcn.cpp:178
#define MORPHOLOGY
Definition: membfunc.h:63
int type
Definition: membfunc.h:81
Point_process ** point_process
Definition: init.cpp:165
bbcore_write_t * nrn_bbcore_read_
Definition: init.cpp:191
static void destruct(void *v)
Definition: grglyph.cpp:215
static const char * morph_mech[]
Definition: cabvars.h:76
int nrn_fornetcon_cnt_
Definition: init.cpp:218
#define cur
Definition: eion.cpp:338
#define e
Definition: passive0.cpp:24
#define DEF_celsius
Definition: membdef.h:11
#define BEFORE_AFTER_SIZE
Definition: membfunc.h:78
Symbol * hoc_install(const char *, int, double, Symlist **)
void _modl_cleanup(void)
Definition: init.cpp:865
Datum * _thread
Definition: nrnoc_ml.h:17
#define gargstr
Definition: hocdec.h:14
int refcount
Definition: hocdec.h:71
#define DEF_dt
Definition: membdef.h:5
int * nrn_prop_param_size_
Definition: init.cpp:178
Memb_func * memb_func
Definition: init.cpp:161
short type
Definition: section.h:215
#define IGNORE(arg)
Definition: model.h:262
int secondorder
Definition: init.cpp:120
#define RTLD_NOW
Definition: osxdlfcn.h:61
const char * name
Definition: hocdec.h:264
static double map(void *v)
Definition: mlinedit.cpp:46
double hoc_call_func(Symbol *s, int narg)
Definition: code.cpp:1445
double _dt
Definition: multicore.h:60
const char * name
Definition: hocdec.h:274
void(* steer)(void *)
Definition: hocdec.h:208
static List * bnd[4]
Definition: partial.cpp:160
unsigned s_varn
Definition: hocdec.h:157
const char ** nrn_nmodl_text_
Definition: init.cpp:201
pnt_receive_init_t * pnt_receive_init
Definition: init.cpp:172
double clamp_resist
Definition: init.cpp:123
Pvmp destructor
Definition: membfunc.h:37
Symbol * sym
Definition: membfunc.h:38
#define BEFORE_STEP
Definition: membfunc.h:77
sl
Definition: seclist.cpp:186
cTemplate ** nrn_pnt_template_
Definition: init.cpp:169
int sub[1]
Definition: hocdec.h:72
int const size_t const size_t n
Definition: nrngsl.h:12
double t
Definition: init.cpp:123
int nrn_istty_
Definition: hoc.cpp:870
void(*)(double *, int *, int *, int *, double *, Datum *, Datum *, NrnThread *) bbcore_write_t
Definition: init.cpp:189
HocStruct Symbol ** ppsym
Definition: hocdec.h:149
void _nrn_thread_reg(int i, int cons, void(*f)(Datum *))
Definition: init.cpp:1042
static void destructor(void *v)
Definition: seclist.cpp:40
int nodecount
Definition: nrnoc_ml.h:18
_CONST char * s
Definition: system.cpp:74
Symbol ** p
Definition: init.cpp:123
NrnThread * nrn_threads
Definition: multicore.cpp:45
pnt_receive_t * pnt_receive
Definition: init.cpp:171
void(* nrn_bamech_t)(Node *, double *, Datum *, Datum *, struct NrnThread *)
Definition: membfunc.h:24
Pvmi state
Definition: membfunc.h:35
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
Definition: hoc_oop.cpp:1581
FILE * popen(char *s1, char *s2)
Definition: macprt.cpp:102
static int indx
Definition: deriv.cpp:240
Memb_list * memb_list
Definition: init.cpp:162
Node ** node_construct(int)
Definition: solve.cpp:593
void hoc_nrn_load_dll(void)
Definition: init.cpp:307
int point_register_mech(const char **m, Pvmp alloc, Pvmi cur, Pvmi jacob, Pvmi stat, Pvmi initialize, int nrnpointerindex, int vectorized, void *(*constructor)(Object *), void(*destructor)(void *), Member_func *fmember)
Definition: init.cpp:821
Arrayinfo * arayinfo
Definition: hocdec.h:158
int * nrn_dparam_ptr_end_
Definition: init.cpp:181
#define printf
Definition: mwprefix.h:26
void(* thread_mem_init_)(Datum *)
Definition: membfunc.h:49
void hoc_register_prop_size(int type, int psize, int dpsize)
Definition: init.cpp:721
void(* Pvmp)(Prop *)
Definition: membfunc.h:19
void nrn_register_mech_common(const char **m, Pvmp alloc, Pvmi cur, Pvmi jacob, Pvmi stat, Pvmi initialize, int nrnpointerindex, int vectorized)
Definition: init.cpp:474
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
Definition: membfunc.h:18
char * hoc_symbol_units(Symbol *, const char *)
Definition: code2.cpp:128
#define USERPROPERTY
Definition: hocdec.h:94
int
Definition: nrnmusic.cpp:71
void hoc_reg_nmodl_filename(int type, const char *filename)
Definition: init.cpp:207
Pvmp alloc
Definition: membfunc.h:32
#define ISARRAY(arg)
Definition: hocdec.h:163
Prop * prop_alloc(Prop **, int, Node *)
Definition: treeset.cpp:688
short * memb_order_
Definition: init.cpp:163
#define BEFORE_INITIAL
Definition: membfunc.h:73
int n_memb_func
Definition: init.cpp:471
void hoc_execerror(const char *, const char *)
Definition: hoc.cpp:741
nrn_bamech_t f
Definition: membfunc.h:80
Symlist * hoc_symlist
#define cnt
Definition: spt2queue.cpp:19
double htablemin
Definition: init.cpp:123
errno
Definition: system.cpp:98
Symbol ** pointsym
Definition: init.cpp:164
hoc_retpushx(1.0)
static Symbol * vsym
Definition: occvode.cpp:49
size_t j
hoc_List * section_list
Definition: init.cpp:126
void hoc_reg_watch_allocate(int type, NrnWatchAllocateFunc_t waf)
Definition: init.cpp:184
void SectionList_reg(void)
Definition: seclist.cpp:280
fprintf(stderr, "Don't know the location of params at %p\, pp)
static HocParmUnits _hoc_parm_units[]
Definition: init.cpp:144
Pvmi initialize
Definition: membfunc.h:36
Definition: model.h:57
void state_discontinuity(int i, double *pd, double d)
Definition: init.cpp:885
BAMech ** bamech_
Definition: init.cpp:167
void nrn_threads_create(int, int)
Definition: multicore.cpp:490
void add_nrn_artcell(int type, int qi)
Definition: init.cpp:234
static void * constructor(Object *ho)
Definition: seclist.cpp:30
void * dlopen(const char *path, int mode)
Definition: osxdlfcn.cpp:85
HocSymExtension * extra
Definition: hocdec.h:159
Definition: section.h:213
char * name
Definition: init.cpp:16
static double tolerance
Definition: hocprax.cpp:73
double nrn_call_mech_func(Symbol *s, int narg, Prop *p, int type)
Definition: init.cpp:1060
void node_destruct(Node **, int)
Definition: solve.cpp:661
int is_point_
Definition: hocdec.h:198
int keep_nseg_parm_
Definition: cabcode.cpp:1553
char * emalloc(unsigned n)
Definition: list.cpp:189
int _ninits
Definition: init.cpp:864
void units(unit *)
Definition: units.cpp:736
void(* NrnWatchAllocateFunc_t)(Datum *)
Definition: nrniv_mf.h:97
Symlist * hoc_built_in_symlist
Definition: symbol.cpp:39
int nrn_pointing(double *pd)
Definition: init.cpp:880
#define nlayer
Definition: section.h:187
void hoc_register_dparam_semantics(int type, int ix, const char *name)
Definition: init.cpp:732
static void * cons(Object *o)
Definition: grglyph.cpp:208
int ifarg(int)
Definition: code.cpp:1562
void add_nrn_fornetcons(int type, int indx)
Definition: init.cpp:222
#define call
Definition: redef.h:34
int mswin_load_dll(const char *cp1)
Definition: init.cpp:281
Datum * dparam
Definition: section.h:219
long subtype
Definition: model.h:59
#define matsol
Definition: lineq.h:7
static int memb_func_size_
Definition: init.cpp:160
struct Symbol::@52::@53 rng
void _cvode_abstol(Symbol **s, double *tol, int i)
Definition: init.cpp:954
void hoc_register_cvode(int i, nrn_ode_count_t cnt, nrn_ode_map_t map, Pvmi spec, Pvmi matsol)
Definition: init.cpp:779
NrnWatchAllocateFunc_t * nrn_watch_allocate_
Definition: init.cpp:182
void(* _update_ion_pointers)(Datum *)
Definition: membfunc.h:52
#define DEF_clamp_resist
Definition: membdef.h:17
void hoc_register_var(DoubScal *scdoub, DoubVec *vdoub, VoidFunc *fn)
Definition: hocusr.cpp:110
void hoc_register_limits(int type, HocParmLimits *limits)
Definition: init.cpp:892
#define DEF_secondorder
Definition: membdef.h:6
Pvmi jacob
Definition: membfunc.h:34
short cpublic
Note: public is a reserved keyword.
Definition: hocdec.h:125
int * nrn_prop_dparam_size_
Definition: init.cpp:179
int state_discon_allowed_
Definition: init.cpp:121
void steer_point_process(void *v)
Definition: point.cpp:303
double dt
Definition: init.cpp:123
int nrnmpi_myid
static DoubScal scdoub[]
Definition: init.cpp:331
double _modl_get_dt_thread(NrnThread *nt)
Definition: init.cpp:875
void hoc_register_synonym(int i, void(*syn)(int, double **, Datum **))
Definition: init.cpp:791
void _modl_set_dt(double newdt)
Definition: init.cpp:868
Definition: hocdec.h:226
void hoc_register_tolerance(int type, HocStateTolerance *tol, Symbol ***stol)
Definition: init.cpp:969
HocStruct cTemplate * ctemplate
Definition: hocdec.h:151
const char * name
Definition: hocdec.h:269
bbcore_write_t * nrn_bbcore_write_
Definition: init.cpp:190
int vectorized
Definition: membfunc.h:47
Symbol * hoc_table_lookup(const char *, Symlist *)
Definition: symbol.cpp:60
void add_nrn_has_net_event(int type)
Definition: init.cpp:211
void initnrn(void)
Definition: init.cpp:460
void register_mech(const char **m, Pvmp alloc, Pvmi cur, Pvmi jacob, Pvmi stat, Pvmi initialize, int nrnpointerindex, int vectorized)
Definition: init.cpp:688
double htablemax
Definition: init.cpp:123
int * nrn_dparam_ptr_start_
Definition: init.cpp:180
#define i
Definition: md1redef.h:12
int is_point
Definition: membfunc.h:53
int * nrn_fornetcon_type_
Definition: init.cpp:219
void(* thread_table_check_)(double *, Datum *, Datum *, NrnThread *, int)
Definition: membfunc.h:51
void(* Pfrv)(void)
Definition: hocdec.h:40
struct Prop * next
Definition: section.h:214
void nrn_exit(int)
Definition: hoc.cpp:219
double hoc_default_dll_loaded_
Definition: hoc_init.cpp:266
static Pfrv mechanism[]
Definition: cabvars.h:45
#define arg
Definition: redef.h:28
char buf[512]
Definition: init.cpp:13
static struct @32 flags[]
void hoc_reg_bbcore_read(int type, bbcore_write_t f)
Definition: init.cpp:197
static char nmodl_version_[]
Definition: init.cpp:20
void hoc_symbol_tolerance(Symbol *, double)
Definition: code2.cpp:109
int * dparam_semantics
Definition: membfunc.h:56
void hoc_reg_ba(int mt, nrn_bamech_t f, int type)
Definition: init.cpp:934
int nrn_netrec_state_adjust
Definition: init.cpp:124
void * dlsym(void *handle, const char *symbol)
Definition: osxdlfcn.cpp:193
void modl_reg(void)
Needed for compilation.
Definition: inithoc.cpp:393
void cab_alloc(Prop *p)
Definition: cabcode.cpp:397
int nrn_nobanner_
Definition: init.cpp:130
void _modl_set_dt_thread(double newdt, NrnThread *nt)
Definition: init.cpp:872
void _nrn_thread_table_reg(int i, void(*f)(double *, Datum *, Datum *, NrnThread *, int))
Definition: init.cpp:1052
union Symbol::@18 u
static Symbol * pv[4]
Definition: partial.cpp:80
static struct @41 usrprop[]
double celsius
Definition: init.cpp:123
Definition: section.h:132
static char CHKmes[]
Definition: init.cpp:116
struct BAMech * next
Definition: membfunc.h:82
void hoc_last_init(void)
Definition: init.cpp:337
Definition: hocdec.h:176
int * nrn_has_net_event_
Definition: init.cpp:177
int * nrn_fornetcon_index_
Definition: init.cpp:220
short * nrn_is_artificial_
Definition: init.cpp:231
void(* pnt_receive_init_t)(Point_process *, double *, double)
Definition: nrniv_mf.h:15
FILE * fopen()
void(* nrn_ode_map_t)(int, double **, double **, double *, Datum *, double *, int)
Definition: membfunc.h:21
unsigned * a_varn
Definition: hocdec.h:69
#define BEFORE_BREAKPOINT
Definition: membfunc.h:75
return NULL
Definition: cabcode.cpp:461
int(* nrn_ode_count_t)(int)
Definition: membfunc.h:20
char * pnt_map
Definition: init.cpp:166
double chkarg(int, double low, double high)
Definition: code2.cpp:608
void _nrn_setdata_reg(int i, void(*call)(Prop *))
Definition: init.cpp:1056
short * pnt_receive_size
Definition: init.cpp:173
void SectionRef_reg(void)
Definition: secref.cpp:365
short index
Definition: cabvars.h:11
int nrn_noauto_dlopen_nrnmech
Definition: hoc_init.cpp:270
int nrn_is_ion(int)
Definition: eion.cpp:45
int nrn_is_cable(void)
Definition: init.cpp:243
int nrn_global_ncell
Definition: init.cpp:127
void nrn_load_name_check(const char *name)
Definition: hocusr.cpp:33
void(* setdata_)(struct Prop *)
Definition: membfunc.h:55
void * nrn_realpath_dlopen(const char *relpath, int flags)
Definition: init.cpp:245
int nrn_has_net_event_cnt_
Definition: init.cpp:176