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>
50 #define PR_PROFILE pr_profile();
57 static PropertyData properties[] = {{
"*gui",
"sgimotif"},
58 {
"*PopupWindow*overlay",
"true"},
59 {
"*PopupWindow*saveUnder",
"on"},
60 {
"*TransientWindow*saveUnder",
"on"},
61 {
"*background",
"#ffffff"},
62 {
"*brush_width",
"0"},
63 {
"*double_buffered",
"on"},
66 {
"*font",
"*Arial*bold*--12*"},
67 {
"*MenuBar*font",
"*Arial*bold*--12*"},
68 {
"*MenuItem*font",
"*Arial*bold*--12*"},
70 {
"*foreground",
"#000000"},
71 {
"*synchronous",
"off"},
72 {
"*malloc_debug",
"on"},
74 {
"*Scene_background",
"#ffffff"},
75 {
"*Scene_foreground",
"#000000"},
76 {
"*FieldEditor*background",
"#ffffff"},
78 {
"*default_brush",
"0"},
79 {
"*view_margin",
".25"},
80 {
"*pwm_dismiss_button",
"Iconify"},
81 {
"*dismiss_button",
"Close"},
82 {
"*use_transient_windows",
"yes"},
83 {
"*nrn_library",
" $(NEURONHOME)/lib"},
84 {
"*view_pick_epsilon",
"2"},
85 {
"*pwm_canvas_height",
"120"},
86 {
"*pwm_paper_height",
"11"},
87 {
"*pwm_paper_width",
"8.5"},
88 {
"*pwm_paper_resolution",
".5"},
89 {
"*pwm_pixel_resolution",
"0"},
90 {
"*window_manager_offset_x",
"5."},
91 {
"*window_manager_offset_y",
"26."},
92 {
"*pwm_print_file_filter",
"*.ps"},
93 {
"*pwm_idraw_file_filter",
"*.id"},
94 {
"*pwm_ascii_file_filter",
"*"},
95 {
"*pwm_save_file_filter",
"*.ses"},
96 {
"*pwm_idraw_prologue",
"$(NEURONHOME)/lib/prologue.id"},
97 {
"*pwm_postscript_filter",
"sed 's;/Adobe-;/;'"},
98 {
"*SlowSlider*autorepeatStart",
"0."},
99 {
"*scene_print_border",
"1"},
100 {
"*radioScale",
".9"},
101 {
"*stepper_size",
"20."},
102 {
"*xvalue_field_size_increase",
"10."},
103 {
"*xvalue_format",
"%.5g"},
104 {
"*graph_axis_default",
"0"},
105 {
"*shape_scale_file",
"$(NEURONHOME)/lib/shape.cm2"},
106 {
"*shape_quadedge",
"0"},
107 {
"*CBWidget_ncolor",
"10"},
108 {
"*CBWidget_nbrush",
"10"},
109 {
"*units_on_flag",
"on"},
112 {
"*Py_NoSiteFlag",
"0"},
114 {
"*nopython",
"off"},
115 {
"*err_dialog",
"off"},
120 static OptionDesc options[] = {{
"-dismissbutton",
"*dismiss_button", OptionValueImplicit,
"Close"},
121 {
"-extrapipeinput",
"*extrapipeinput", OptionValueNext},
122 {
"-dll",
"*nrnmechdll", OptionValueNext},
123 {
"-showwinio",
"*showwinio", OptionValueImplicit,
"on"},
124 {
"-hidewinio",
"*showwinio", OptionValueImplicit,
"off"},
125 {
"-isatty",
"*isatty", OptionValueImplicit,
"1"},
126 {
"-notatty",
"*isatty", OptionValueImplicit,
"-1"},
127 {
"-neosim",
"*neosim", OptionValueImplicit,
"on"},
128 {
"-bbs_nhost",
"*bbs_nhost", OptionValueNext},
129 {
"-NSTACK",
"*NSTACK", OptionValueNext},
130 {
"-NFRAME",
"*NFRAME", OptionValueNext},
131 {
"--version",
"*print_nrn_version", OptionValueImplicit,
"on"},
132 {
"-python",
"*python", OptionValueImplicit,
"on"},
133 {
"-nopython",
"*nopython", OptionValueImplicit,
"on"},
134 {
"-pyexe",
"*pyexe", OptionValueNext},
135 {
"-Py_NoSiteFlag",
"*Py_NoSiteFlag", OptionValueImplicit,
"1"},
136 {
"-nobanner",
"*banner", OptionValueImplicit,
"off"},
138 {
"-mswin_scale",
"*mswin_scale", OptionValueNext},
149 #if (defined(NRNMECH_DLL_STYLE) || defined(WIN32))
152 #if defined(USE_PYTHON)
154 extern int use_python_interpreter;
170 static char* ocsmall_argv[] = {0,
"difus.hoc"};
172 #if defined(WIN32) && HAVE_IV
173 extern HWND hCurrWnd;
179 int hoc_xopen1(
const char* filename,
const char* rcs);
185 #if !defined(MINGW) && !MAC
194 for (
i=0; environ[
i]; ++
i) {
195 printf(
"%p %s\n", environ[
i], environ[
i]);
200 #if DARWIN || defined(__linux__)
213 const char* path_prefix_to_libnrniv() {
214 static char* path_prefix_to_libnrniv_ =
NULL;
215 if (!path_prefix_to_libnrniv_) {
220 if (
info.dli_fname) {
222 if (
info.dli_fname[0] ==
'/') {
223 size_t last_slash =
name.rfind(
"/");
224 path_prefix_to_libnrniv_ = strndup(
name.c_str(), last_slash + 1);
225 path_prefix_to_libnrniv_[last_slash + 1] =
'\0';
229 if (!path_prefix_to_libnrniv_) {
230 path_prefix_to_libnrniv_ = strdup(
"");
233 return path_prefix_to_libnrniv_;
241 void mac_open_doc(
const char* s) {
243 static bool done =
false;
246 char* cp = strrchr(cs,
':');
249 if (chdir(cs) == 0) {
251 printf(
"current directory is \"%s\"\n", cs);
259 void mac_open_app() {
268 int ivocmain(
int,
const char**,
const char**);
276 #if NRNMPI_DYNAMICLOAD
277 extern void nrnmpi_stubs();
278 extern char* nrnmpi_load(
int is_python);
291 #include <sys/stat.h>
292 static bool isdir(
const char*
p) {
294 bool b = stat(
p, &st) == 0 && S_ISDIR(st.st_mode);
312 for (
i = 0;
i < *pargc; ++
i) {
313 if (strcmp(opt,
argv[
i]) == 0) {
315 for (;
i < *pargc; ++
i) {
328 for (
i = 0;
i < *pargc - 1; ++
i) {
329 if (strcmp(opt,
argv[
i]) == 0) {
332 for (;
i < *pargc; ++
i) {
355 void nrn_InitializeJavaVM();
359 void prargs(
const char* s,
int argc,
const char**
argv) {
371 #if NRNMPI_DYNAMICLOAD
373 const char* pmes = nrnmpi_load(1);
446 for (
i = 0;
i <
argc + 1; ++
i) {
452 "nrniv [options] [fileargs]\n\
454 -dll filename dynamically load the linked mod files.\n\
455 -h print this help message\n\
456 -help print this help message\n\
457 -isatty unbuffered stdout, print prompt when waiting for stdin\n\
458 -mpi launched by mpirun or mpiexec, in parallel environment\n\
459 -mswin_scale float scales gui on screen\n\
460 -music launched as a process of the MUlti SImulator Coordinator\n\
461 -NSTACK integer size of stack (default 1000)\n\
462 -NFRAME integer depth of function call nesting (default 200)\n\
463 -nobanner do not print startup banner\n\
464 -nogui do not send any gui info to screen\n\
465 -notatty buffered stdout and no prompt\n\
466 -python Python is the interpreter\n\
467 -pyexe path Python to use if python (or python3 fallback) not right.\n\
468 -nopython Do not initialize Python\n\
469 -Py_NoSiteFlag Set Py_NoSiteFlag=1 before initializing Python\n\
470 -realtime For hard real-time simulation for dynamic clamp\n\
471 --version print version info\n\
472 and all InterViews and X11 options\n\
473 fileargs: any number of following\n\
474 - input from stdin til ^D (end of file)\n\
475 -c \"statement\" execute next statement\n\
476 filename execute contents of filename\n\
514 if (strncmp(
"-p4", (
argv)[
i], 3) == 0) {
518 if (strcmp(
"-mpi", (
argv)[
i]) == 0) {
525 "Warning: detected user attempt to enable MPI, but MPI support was disabled at build "
531 #if defined(IVX11_DYNAM)
542 printf(
"Warning: attempt to enable MUSIC but MUSIC support was disabled at build time.\n");
551 const char** our_argv =
argv;
554 #if !defined(MINGW) && !defined(MAC)
564 #if defined(HAVE_PUTENV)
567 static char* buffer =
new char[strlen(NEURON_DATA_DIR) + 12];
568 sprintf(buffer,
"NEURONHOME=%s", NEURON_DATA_DIR);
571 #elif defined(HAVE_SETENV)
572 setenv(
"NEURONHOME", NEURON_DATA_DIR, 1);
575 #error "I don't know how to set environment variables."
581 #if HAVE_UNISTD_H && !defined(__APPLE__)
584 #if defined(__APPLE__)
585 env = (*_NSGetEnviron());
596 #if defined(WIN32) && HAVE_IV
598 "No NEURONHOME environment variable.",
599 "NEURON Incomplete Installation",
604 "Warning: no NEURONHOME environment variable-- setting\
614 our_argv =
new char*[2];
615 our_argv[0] =
"Neuron";
616 our_argv[1] =
":lib:hoc:macload.hoc";
617 session =
new Session(
"NEURON", our_argc, our_argv, options, properties);
621 our_argv =
new char*[1];
622 our_argv[0] =
"Neuron";
623 session =
new Session(
"NEURON", our_argc, our_argv, options, properties);
624 SIOUXSettings.asktosaveonclose =
false;
626 #if defined(WIN32) || carbon
628 session =
new Session(
"NEURON", our_argc, (
char**) our_argv, options, properties);
633 session =
new Session(
"NEURON", our_argc, (
char**) our_argv, options, properties);
636 "Warning: no DISPLAY environment variable.\
637 \n--No graphics will be displayed.\n");
649 if ((f =
fopen(nrn_props,
"r")) != (FILE*) 0) {
651 session->style()->load_file(
String(nrn_props), -5);
658 if ((f =
fopen(nrn_props,
"r")) != (FILE*) 0) {
660 session->style()->load_file(
String(nrn_props), -5);
663 sprintf(
buf,
"Can't load NEURON resources from %s[aults]", nrn_props);
668 session->style()->load_file(
String(nrn_props), -5);
673 sprintf(nrn_props,
"%s/%s", h,
".nrn.defaults");
674 session->style()->load_file(
String(nrn_props), -5);
683 session->style()->find_attribute(
"NSTACK",
hoc_nstack);
684 session->style()->find_attribute(
"NFRAME",
hoc_nframe);
686 if (session->style()->value_is_on(
"err_dialog")) {
697 #if defined(USE_PYTHON)
702 if (session->style()->value_is_on(
"nopython")) {
706 if (session->style()->find_attribute(
"pyexe", str)) {
723 #if defined(WIN32) && HAVE_IV
726 int pw = GetSystemMetrics(SM_CXVIRTUALSCREEN);
728 scale = 1200. / double(pw);
730 session->style()->find_attribute(
"mswin_scale", scale);
731 iv_display_scale(
float(scale));
738 #if (defined(NRNMECH_DLL_STYLE) || defined(WIN32))
742 if (session->style()->find_attribute(
"nrnmechdll", str)) {
769 if (session->style()->find_attribute(
"isatty",
i)) {
785 if (session && session->style()->value_is_on(
"units_on_flag")) {
788 Oc oc(session, our_argv[0],
env);
794 nrn_InitializeJavaVM();
798 ocsmall_argv[0] = our_argv[0];
799 exit_status = oc.
run(2, ocsmall_argv);
802 #if defined(USE_PYTHON)
804 if (session && session->style()->value_is_on(
"python")) {
805 use_python_interpreter = 1;
809 use_python_interpreter = 1;
817 (*p_nrnpython_start)(1);
820 fprintf(stderr,
"Python not available\n");
826 exit_status = oc.
run(our_argc, our_argv);
834 if (session && session->style()->value_is_on(
"neosim")) {
839 "neosim not available.\nModify nrn/src/nrniv/Imakefile and remove "
840 "nrniv/$CPU/netcvode.o\n");
845 #if defined(USE_PYTHON)
846 if (use_python_interpreter) {
855 (*p_nrnpython_start)(0);
871 extern int ifarg(
int);
int run(int argc, const char **argv)
static Session * session_
static HandleStdin * handleStdin_
static ostream * idraw_stream
const char * string() const
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)
DLFCN_EXPORT int dladdr(const void *addr, Dl_info *info)
int nrn_err_dialog_active_
bool mac_load_dll(const char *name)
void setneuronhome(const char *)
int ivocmain_session(int, const char **, const char **, int start_session)
This used to be ivocmain, the main entrypoint to the HOC interpreter.
int ivocmain(int, const char **, const char **)
Main entrypoint function into the HOC interpeter.
int hoc_obj_run(const char *, Object *)
int(* p_neosim_main)(int, const char **, const char **)
int hoc_print_first_instance
int nrn_is_python_extension
static char * nrn_optarg(const char *opt, int *argc, char **argv)
static int nrn_optargint(const char *opt, int *argc, char **argv, int dflt)
void hoc_main1_init(const char *, const char **)
void hoc_single_event_run()
const char ** nrn_global_argv
int hoc_main1(int, const char **, const char **)
static bool nrn_optarg_on(const char *opt, int *argc, char **argv)
double hoc_default_dll_loaded_
int hoc_xopen1(const char *filename, const char *rcs)
char * getenv(const char *s)
void * nrnisaac_new(void)
void nrnmpi_init(int nrnmpi_under_nrncontrol, int *pargc, char ***pargv)
int(* p_nrnpython_start)(int)
static double done(void *v)