NEURON
nrnmain.cpp
Go to the documentation of this file.
1 #include <nrnconf.h>
2 #include <stdio.h>
3 #include <string.h>
4 #include "../nrncvode/nrnneosm.h"
5 #include <nrnmpi.h>
6 #include <errno.h>
7 #include "isoc99.h"
8 
9 extern "C" int nrn_isdouble(double*, double, double);
10 extern int ivocmain(int, const char**, const char**);
11 extern int nrn_main_launch;
12 extern int nrn_noauto_dlopen_nrnmech;
13 #if NRNMPI_DYNAMICLOAD
14 extern void nrnmpi_stubs();
15 extern char* nrnmpi_load(int is_python);
16 #endif
17 #if NRNMPI
18 extern "C" void nrnmpi_init(int nrnmpi_under_nrncontrol, int* pargc, char*** pargv);
19 #endif
20 
21 int main(int argc, char** argv, char** env) {
22  nrn_isdouble(0, 0, 0);
23  nrn_main_launch = 1;
24 
25 #if defined(AUTO_DLOPEN_NRNMECH) && AUTO_DLOPEN_NRNMECH == 0
27 #endif
28 
29 #if 0
30 printf("argc=%d\n", argc);
31 for (int i=0; i < argc; ++i) {
32 printf("argv[%d]=|%s|\n", i, argv[i]);
33 }
34 #endif
35 #if NRNMPI
36 #if NRNMPI_DYNAMICLOAD
37  nrnmpi_stubs();
38  for (int i = 0; i < argc; ++i) {
39  if (strcmp("-mpi", argv[i]) == 0) {
40  char* pmes;
41  pmes = nrnmpi_load(0);
42  if (pmes) {
43  printf("%s\n", pmes);
44  exit(1);
45  }
46  break;
47  }
48  }
49 #endif
50  nrnmpi_init(1, &argc, &argv); // may change argc and argv
51 #endif
52  errno = 0;
53  return ivocmain(argc, (const char**) argv, (const char**) env);
54 }
55 
56 #if USENCS
57 void nrn2ncs_outputevent(int, double) {}
58 #endif
59 
60 // moving following to src/oc/ockludge.cpp since on
61 // Darwin Kernel Version 8.9.1 on apple i686 (and the newest config.guess
62 // thinks it is a i386, but that is a different story)
63 // including mpi.h gives some errors like:
64 // /Users/hines/mpich2-1.0.5p4/instl/include/mpicxx.h:26:2: error: #error
65 // SEEK_SET is #defined but must not be for the C++ binding of MPI"
66 
67 #if 0 && NRNMPI && DARWIN
68 // For DARWIN I do not really know the proper way to avoid
69 // dyld: lazy symbol binding failed: Symbol not found: _MPI_Init
70 // when the MPI functions are all used in the libnrnmpi.dylib
71 // but the libmpi.a is statically linked. Therefore I am forcing
72 // the linking here by listing all the MPI functions being used.
73 #include <mpi.h>
74 static void work_around() {
75  MPI_Comm c = MPI_COMM_WORLD;
76  MPI_Init(0, 0);
77  MPI_Comm_rank(c, 0);
78  MPI_Comm_size(c, 0);
79  MPI_Wtime();
80  MPI_Finalize();
81  MPI_Unpack(0, 0, 0, 0, 0, 0, c);
82  MPI_Pack(0, 0, 0, 0, 0, 0, c);
83  MPI_Pack_size(0, 0, c, 0);
84  MPI_Send(0,0,0,0,0,c);
85  MPI_Probe(0, 0, c, 0);
86  MPI_Get_count(0, 0, 0);
87  MPI_Recv(0,0,0,0,0,c,0);
88  MPI_Sendrecv(0,0,0,0,0,0,0,0,0,0,c,0);
89  MPI_Iprobe(0,0,c,0,0);
90  MPI_Get_address(0,0);
91  MPI_Type_create_struct(0,0,0,0,0);
92  MPI_Type_commit(0);
93  MPI_Allgather(0,0,0,0,0,0,c);
94  MPI_Allgatherv(0,0,0,0,0,0,0,c);
95  MPI_Allreduce(0,0,0,0,0,c);
96 }
97 #endif
#define c
static char * env[]
Definition: inithoc.cpp:233
static int argc
Definition: inithoc.cpp:53
static char ** argv
Definition: inithoc.cpp:54
#define i
Definition: md1redef.h:12
#define printf
Definition: mwprefix.h:26
int nrn_isdouble(double *, double, double)
Definition: isoc99.cpp:12
int main(int argc, char **argv, char **env)
Definition: nrnmain.cpp:21
int nrn_main_launch
Definition: hoc_init.cpp:528
int ivocmain(int, const char **, const char **)
Main entrypoint function into the HOC interpeter.
Definition: ivocmain.cpp:407
int nrn_noauto_dlopen_nrnmech
Definition: hoc_init.cpp:406
void nrnmpi_init(int nrnmpi_under_nrncontrol, int *pargc, char ***pargv)
Definition: nrnmpi.cpp:58