1 #include <../../nrnconf.h> 2 #include <../nrnpython/nrnpython_config.h> 8 int hoc_main1(
int,
const char**,
const char**);
16 #if !defined (__APPLE__) 17 extern char** environ;
19 #include <crt_externs.h> 25 #include <IV-Win/MWlib.h> 26 void iv_display_scale(
float);
33 #include <InterViews/style.h> 40 #if defined(IVX11_DYNAM) 41 #include <IV-X11/ivx11_dynam.h> 48 #if MAC || defined(WIN32) 51 #include "../nrnjava/njconf.h" 56 #define PR_PROFILE pr_profile(); 65 {
"*PopupWindow*overlay",
"true"},
66 {
"*PopupWindow*saveUnder",
"on"},
67 {
"*TransientWindow*saveUnder",
"on"},
68 {
"*background",
"#ffffff"},
69 {
"*brush_width",
"0"},
70 {
"*double_buffered",
"on"},
72 #if defined(WIN32)|| defined(CYGWIN) 73 {
"*font",
"*Arial*bold*--12*"},
74 {
"*MenuBar*font",
"*Arial*bold*--12*"},
75 {
"*MenuItem*font",
"*Arial*bold*--12*"},
77 {
"*foreground",
"#000000"},
78 {
"*synchronous",
"off"},
79 {
"*malloc_debug",
"on"},
81 {
"*Scene_background",
"#ffffff"},
82 {
"*Scene_foreground",
"#000000"},
83 {
"*FieldEditor*background",
"#ffffff"},
85 {
"*default_brush",
"0"},
86 {
"*view_margin",
".25"},
87 {
"*pwm_dismiss_button",
"Iconify"},
88 {
"*dismiss_button",
"Close"},
89 {
"*use_transient_windows",
"yes"},
90 {
"*nrn_library",
" $(NEURONHOME)/lib"},
91 {
"*view_pick_epsilon",
"2"},
92 {
"*pwm_canvas_height",
"120"},
93 {
"*pwm_paper_height",
"11"},
94 {
"*pwm_paper_width",
"8.5"},
95 {
"*pwm_paper_resolution",
".5"},
96 {
"*pwm_pixel_resolution",
"0"},
97 {
"*window_manager_offset_x",
"5."},
98 {
"*window_manager_offset_y",
"26."},
99 {
"*pwm_print_file_filter",
"*.ps"},
100 {
"*pwm_idraw_file_filter",
"*.id"},
101 {
"*pwm_ascii_file_filter",
"*"},
102 {
"*pwm_save_file_filter",
"*.ses"},
103 {
"*pwm_idraw_prologue",
"$(NEURONHOME)/lib/prologue.id"},
104 {
"*pwm_postscript_filter",
"sed 's;/Adobe-;/;'"},
105 {
"*SlowSlider*autorepeatStart",
"0."},
106 {
"*scene_print_border",
"1"},
107 {
"*radioScale",
".9"},
108 {
"*stepper_size",
"20."},
109 {
"*xvalue_field_size_increase",
"10."},
110 {
"*xvalue_format",
"%.5g"},
111 {
"*graph_axis_default",
"0"},
112 {
"*shape_scale_file",
"$(NEURONHOME)/lib/shape.cm2"},
113 {
"*shape_quadedge",
"0"},
114 {
"*CBWidget_ncolor",
"10"},
115 {
"*CBWidget_nbrush",
"10"},
116 {
"*units_on_flag",
"on"},
119 {
"*Py_NoSiteFlag",
"0"},
121 {
"*nopython",
"off"},
122 {
"*err_dialog",
"off"},
129 {
"-dismissbutton",
"*dismiss_button", OptionValueImplicit,
"Close"},
130 {
"-extrapipeinput",
"*extrapipeinput", OptionValueNext},
131 {
"-dll",
"*nrnmechdll", OptionValueNext},
132 {
"-showwinio",
"*showwinio", OptionValueImplicit,
"on"},
133 {
"-hidewinio",
"*showwinio", OptionValueImplicit,
"off"},
134 {
"-isatty",
"*isatty", OptionValueImplicit,
"1"},
135 {
"-notatty",
"*isatty", OptionValueImplicit,
"-1"},
136 {
"-neosim",
"*neosim", OptionValueImplicit,
"on"},
137 {
"-bbs_nhost",
"*bbs_nhost", OptionValueNext},
138 {
"-NSTACK",
"*NSTACK", OptionValueNext},
139 {
"-NFRAME",
"*NFRAME", OptionValueNext},
140 {
"--version",
"*print_nrn_version", OptionValueImplicit,
"on"},
141 {
"-python",
"*python", OptionValueImplicit,
"on"},
142 {
"-nopython",
"*nopython", OptionValueImplicit,
"on"},
143 {
"-pyexe",
"*pyexe", OptionValueNext},
144 {
"-Py_NoSiteFlag",
"*Py_NoSiteFlag", OptionValueImplicit,
"1"},
145 {
"-nobanner",
"*banner", OptionValueImplicit,
"off"},
147 {
"-mswin_scale",
"*mswin_scale", OptionValueNext},
159 #if (defined(NRNMECH_DLL_STYLE) || defined(WIN32)) 162 #if defined(USE_PYTHON) 164 extern int use_python_interpreter;
180 static char* ocsmall_argv[] = {0,
"difus.hoc"};
182 #if defined(WIN32) && HAVE_IV 189 int hoc_xopen1(
const char* filename,
const char* rcs);
195 #if !defined(WIN32) && !MAC && !defined(CYGWIN) 204 for (i=0; environ[
i]; ++
i) {
205 printf(
"%p %s\n", environ[i], environ[i]);
210 #if DARWIN || defined(__linux__) 223 const char* path_prefix_to_libnrniv() {
224 static char* path_prefix_to_libnrniv_ =
NULL;
225 if (!path_prefix_to_libnrniv_) {
233 size_t last_slash = name.rfind(
"/");
234 path_prefix_to_libnrniv_ = strndup(name.c_str(), last_slash+1);
235 path_prefix_to_libnrniv_[last_slash+1] =
'\0';
239 if (!path_prefix_to_libnrniv_) {
240 path_prefix_to_libnrniv_ = strdup(
"");
243 return path_prefix_to_libnrniv_;
245 #endif // DARWIN || defined(__linux__) 251 void mac_open_doc(
const char*
s) {
253 static bool done =
false;
256 char* cp = strrchr(cs,
':');
259 if (chdir(cs) == 0) {
261 printf(
"current directory is \"%s\"\n", cs);
278 int ivocmain(
int,
const char**,
const char**);
286 #if NRNMPI_DYNAMICLOAD 287 extern void nrnmpi_stubs();
288 extern char* nrnmpi_load(
int is_python);
301 #include <sys/stat.h> 302 static bool isdir(
const char*
p) {
304 bool b = stat(p, &st) == 0 && S_ISDIR(st.st_mode);
322 for (i=0; i < *pargc; ++
i) {
323 if (strcmp(opt, argv[i]) == 0) {
325 for (; i < *pargc; ++
i) {
338 for (i=0; i < *pargc - 1; ++
i) {
339 if (strcmp(opt, argv[i]) == 0) {
342 for (; i < *pargc; ++
i) {
368 #if 0 //for debugging 369 void prargs(
const char*
s,
int argc,
const char**
argv) {
372 for (i=0; i <
argc; ++
i) {
373 printf(
" %d |%s|\n", i, argv[i]);
381 #if NRNMPI_DYNAMICLOAD 383 const char* pmes = nrnmpi_load(1);
458 for (i = 0; i < argc+1; ++
i) {
464 printf(
"nrniv [options] [fileargs]\n\ 466 -dll filename dynamically load the linked mod files.\n\ 467 -h print this help message\n\ 468 -help print this help message\n\ 469 -isatty unbuffered stdout, print prompt when waiting for stdin\n\ 470 -mpi launched by mpirun or mpiexec, in parallel environment\n\ 471 -mswin_scale float scales gui on screen\n\ 472 -music launched as a process of the MUlti SImulator Coordinator\n\ 473 -NSTACK integer size of stack (default 1000)\n\ 474 -NFRAME integer depth of function call nesting (default 200)\n\ 475 -nobanner do not print startup banner\n\ 476 -nogui do not send any gui info to screen\n\ 477 -notatty buffered stdout and no prompt\n\ 478 -python Python is the interpreter\n\ 479 -pyexe path Python to use if python (or python3 fallback) not right.\n\ 480 -nopython Do not initialize Python\n\ 481 -Py_NoSiteFlag Set Py_NoSiteFlag=1 before initializing Python\n\ 482 -realtime For hard real-time simulation for dynamic clamp\n\ 483 --version print version info\n\ 484 and all InterViews and X11 options\n\ 485 fileargs: any number of following\n\ 486 - input from stdin til ^D (end of file)\n\ 487 -c \"statement\" execute next statement\n\ 488 filename execute contents of filename\n\ 525 for (i=0; i <
argc; ++
i) {
526 if (strncmp(
"-p4", (argv)[i], 3) == 0) {
530 if (strcmp(
"-mpi", (argv)[i]) == 0) {
536 printf(
"Warning: detected user attempt to enable MPI, but MPI support was disabled at build time.\n");
541 #if defined(IVX11_DYNAM) 552 printf(
"Warning: attempt to enable MUSIC but MUSIC support was disabled at build time.\n");
561 const char** our_argv =
argv;
564 #if !defined(WIN32)&&!defined(MAC) && !defined(CYGWIN) 574 #if defined(HAVE_PUTENV) 577 static char* buffer =
new char[strlen(NEURON_DATA_DIR) + 12];
578 sprintf(buffer,
"NEURONHOME=%s", NEURON_DATA_DIR);
581 #elif defined(HAVE_SETENV) 582 setenv(
"NEURONHOME", NEURON_DATA_DIR, 1);
585 #error "I don't know how to set environment variables." 591 #if HAVE_UNISTD_H && !defined(__APPLE__) 594 #if defined (__APPLE__) 595 env = (*_NSGetEnviron());
606 #if defined(WIN32) && HAVE_IV 607 MessageBox(0,
"No NEURONHOME environment variable.",
"NEURON Incomplete Installation", MB_OK);
610 fprintf(stderr,
"Warning: no NEURONHOME environment variable-- setting\ 619 our_argv =
new char*[2];
620 our_argv[0] =
"Neuron";
621 our_argv[1] =
":lib:hoc:macload.hoc";
622 session =
new Session(
"NEURON", our_argc, our_argv,
options, properties);
626 our_argv =
new char*[1];
627 our_argv[0] =
"Neuron";
628 session =
new Session(
"NEURON", our_argc, our_argv,
options, properties);
629 SIOUXSettings.asktosaveonclose =
false;
631 #if defined(WIN32) || carbon 633 session =
new Session(
"NEURON", our_argc, (
char**)our_argv,
options, properties);
638 session =
new Session(
"NEURON", our_argc, (
char**)our_argv,
options, properties);
640 fprintf(stderr,
"Warning: no DISPLAY environment variable.\ 641 \n--No graphics will be displayed.\n");
653 if ((f =
fopen(nrn_props,
"r")) != (FILE*)0) {
655 session->style()->load_file(
String(nrn_props), -5);
662 if ((f =
fopen(nrn_props,
"r")) != (FILE*)0) {
664 session->style()->load_file(
String(nrn_props), -5);
667 sprintf(buf,
"Can't load NEURON resources from %s[aults]",
673 session->style()->load_file(
String(nrn_props), -5);
678 sprintf(nrn_props,
"%s/%s", h,
".nrn.defaults");
679 session->style()->load_file(
String(nrn_props), -5);
688 session->style()->find_attribute(
"NSTACK",
hoc_nstack);
689 session->style()->find_attribute(
"NFRAME",
hoc_nframe);
691 if (session->style()->value_is_on(
"err_dialog")) {
702 #if defined(USE_PYTHON) 707 if (session->style()->value_is_on(
"nopython")) {
711 if (session->style()->find_attribute(
"pyexe", str)) {
726 #if defined(WIN32) && HAVE_IV 729 int pw = GetSystemMetrics(SM_CXVIRTUALSCREEN);
731 scale = 1200./double(pw);
733 session->style()->find_attribute(
"mswin_scale", scale);
734 iv_display_scale(
float(scale));
741 #if (defined(NRNMECH_DLL_STYLE) || defined(WIN32)) 745 if (session->style()->find_attribute(
"nrnmechdll", str)) {
766 #endif //NRNMECH_DLL_STYLE 772 if (session->style()->find_attribute(
"isatty", i)) {
786 if (session && session->style()->value_is_on(
"units_on_flag")) {
789 Oc oc(session, our_argv[0], env);
790 #if defined(WIN32) && !defined(CYGWIN) 791 if (session->style()->find_attribute(
"showwinio", str)
792 && !session->style()->value_is_on(
"showwinio")
807 ocsmall_argv[0] = our_argv[0];
808 oc.
run(2, ocsmall_argv);
811 #if defined(USE_PYTHON) 813 if (session && session->style()->value_is_on(
"python")) {
814 use_python_interpreter = 1;
818 use_python_interpreter = 1;
825 fprintf(stderr,
"Python not available\n");
831 oc.
run(our_argc, our_argv);
839 if (session && session->style()->value_is_on(
"neosim")) {
843 printf(
"neosim not available.\nModify nrn/src/nrniv/Imakefile and remove nrniv/$CPU/netcvode.o\n");
848 #if defined(USE_PYTHON) 849 if (use_python_interpreter) {
872 extern int ifarg(
int);
void hoc_single_event_run()
static ostream * idraw_stream
int ivocmain_session(int, const char **, const char **, int start_session)
This used to be ivocmain, the main entrypoint to the HOC interpreter.
double hoc_default_dll_loaded_
static int nrn_optargint(const char *opt, int *argc, char **argv, int dflt)
int dladdr(const void *dl_restrict, Dl_info *dl_restrict)
static char * nrn_optarg(const char *opt, int *argc, char **argv)
static Session * session_
const char ** nrn_global_argv
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
const char * string() const
int nrn_err_dialog_active_
static double done(void *v)
int hoc_print_first_instance
int(* p_nrnpython_start)(int)
int hoc_xopen1(const char *filename, const char *rcs)
void nrnmpi_init(int nrnmpi_under_nrncontrol, int *pargc, char ***pargv)
char * getenv(const char *s)
fprintf(stderr, "Don't know the location of params at %p\, pp)
int ivocmain(int, const char **, const char **)
Main entrypoint function into the HOC interpeter.
static JavaVMOption * options
static bool nrn_optarg_on(const char *opt, int *argc, char **argv)
static HandleStdin * handleStdin_
void * nrnisaac_new(void)
int hoc_obj_run(const char *, Object *)
void nrn_InitializeJavaVM()
bool mac_load_dll(const char *name)
int hoc_main1(int, const char **, const char **)
void hoc_main1_init(const char *, const char **)
void setneuronhome(const char *)
int run(int argc, const char **argv)
int nrn_is_python_extension
int(* p_neosim_main)(int, const char **, const char **)