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