NEURON
ocmain.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 /* /local/src/master/nrn/src/oc/ocmain.cpp,v 1.7 1997/07/29 20:23:33 hines Exp */
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <hocdec.h>
7 
9 extern const char* neuron_home;
10 
11 extern Object** (*nrnpy_gui_helper_)(const char* name, Object* obj) = NULL;
12 extern double (*nrnpy_object_to_double_)(Object*) = NULL;
13 
14 #if MAC
15 char hoc_console_buffer[256];
16 #endif
17 
18 #if defined(WIN32)
19 void* cvode_pmem;
20 extern void setneuronhome(const char*);
21 #endif
22 
23 static void setnrnhome(const char* arg) {
24 #if !defined(WIN32) && !defined(MAC)
25  /*
26  Gary Holt's first pass at this was:
27 
28  Set the NEURONHOME environment variable. This should override any setting
29  in the environment, so someone doesn't accidently use data files from an
30  old version of neuron.
31 
32  But I have decided to use the environment variable if it exists
33  */
34  neuron_home = getenv("NEURONHOME");
35  if (!neuron_home) {
36 #if defined(HAVE_PUTENV)
37  static char* buffer;
38  buffer = static_cast<char*>(malloc(strlen(NEURON_DATA_DIR) + 12));
39  sprintf(buffer, "NEURONHOME=%s", NEURON_DATA_DIR);
40  putenv(buffer);
41  neuron_home = NEURON_DATA_DIR;
42 #elif defined(HAVE_SETENV)
43  setenv("NEURONHOME", NEURON_DATA_DIR, 1);
44  neuron_home = NEURON_DATA_DIR;
45 #else
46 #error "I don't know how to set environment variables."
47 // Maybe in this case the user will have to set it by hand.
48 #endif
49  }
50 
51 #else // Not unix:
53 #endif
54 }
55 
56 #if LINDA /* LINDA (SAF) */
57 real_main(int argc, const char** argv, const char** envp) {
58 #else
59 int main(int argc, const char** argv, const char** envp) {
60 #endif
61  int err;
62  nrn_isdouble(nullptr, 0., 0.);
63 #if MAC
64  int our_argc = 1;
65  char* our_argv[1];
66  our_argv[0] = "Neuron";
67  err = hoc_main1(our_argc, our_argv, envp);
68 #else
69  setnrnhome(argv[0]);
70  err = hoc_main1(argc, argv, envp);
71 #endif
72  if (!err) {
74  }
75 #if EXPRESS
76  exit(0);
77 #else
78 #if LINDA
79  lexit(0);
80 #else
81  return err;
82 #endif
83 #endif
84 }
85 
86 
87 void hoc_single_event_run() { /* for interviews, ivoc make use of own main */
88 #if LINDA
89  extern int hoc_retreat_flag;
90  if (hoc_retreat_flag) {
91  hoc_retreat();
92  }
93 #endif
94 #if INTERVIEWS && 0
96 #endif
97  hoc_ret();
98  hoc_pushx(0.);
99 }
100 
102  return 1;
103 }
105 
106 #ifdef WIN32
107 void ivcleanup() {}
108 void ivoc_win32_cleanup() {}
109 int bad_install_ok;
110 #endif
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)
void hoc_ret()
static int argc
Definition: inithoc.cpp:53
static char ** argv
Definition: inithoc.cpp:54
void setneuronhome(const char *)
Definition: ivocmain.cpp:186
void hoc_final_exit()
Definition: hoc.cpp:1131
int hoc_main1(int, const char **, const char **)
Definition: hoc.cpp:983
void hoc_pushx(double)
char * getenv(const char *s)
Definition: macprt.cpp:67
char * name
Definition: init.cpp:16
#define putenv
Definition: mwprefix.h:37
int nrn_isdouble(double *, double, double)
Definition: isoc99.cpp:12
void single_event_run()
const char * neuron_home
Definition: hoc_init.cpp:404
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
void hoc_notify_value()
Definition: ocmain.cpp:104
int main(int argc, const char **argv, const char **envp)
Definition: ocmain.cpp:59
void hoc_single_event_run()
Definition: ocmain.cpp:87
int hoc_nstack
Definition: ocmain.cpp:8
int run_til_stdin()
Definition: ocmain.cpp:101
int hoc_nframe
Definition: ocmain.cpp:8
static void setnrnhome(const char *arg)
Definition: ocmain.cpp:23
#define arg
Definition: redef.h:28
#define NULL
Definition: sptree.h:16
Definition: hocdec.h:227