1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4
5 #include <unistd.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8
9
10 #include <iostream>
11 #include <sstream>
12 using namespace std;
13
14 #define OMPI_SKIP_MPICXX 1
15 #include <mpi.h>
16
17 #include <FCMangle.h>
18 #define input FortranCInterface_GLOBAL_(input,INPUT)
19 #define timer FortranCInterface_GLOBAL_(timer,TIMER)
20
21 #include "commonAcuStat_c.h"
22
23 extern "C" char phasta_iotype[80];
24 char phasta_iotype[80];
25
26 extern "C" void input();
27 //MR CHANGE
28 extern void setIOparam(); // For SyncIO
29 //MR CHANGE END
30
31 int myrank; /* made file global for ease in debugging */
32
33 void
catchDebugger()34 catchDebugger() {
35 while (1) {
36 int debuggerPresent=0;
37 int fakeSTOP = 1; // please stop HERE and assign as next line
38 // assign or set debuggerPresent=1
39 if(debuggerPresent) {
40 break;
41 }
42 }
43 }
44
45 // some useful debugging functions
46
47 void
pdarray(void * darray,int start,int end)48 pdarray( void* darray , int start, int end ) {
49 for( int i=start; i < end; i++ ){
50 cout << ((double*)darray)[i] << endl;
51 }
52 }
53
54 void
piarray(void * iarray,int start,int end)55 piarray( void* iarray , int start, int end ) {
56 for( int i=start; i < end; i++ ){
57 cout << ((int*)iarray)[i] << endl;
58 }
59 }
60
61 extern "C" int
phasta(int argc,char * argv[])62 phasta( int argc,
63 char *argv[] ) {
64
65 int size,ierr;
66 char inpfilename[100];
67 char* pauseDebugger = getenv("catchDebugger");
68 //cout << "pauseDebugger" << pauseDebugger << endl;
69
70 MPI_Init(&argc,&argv);
71 MPI_Comm_size (MPI_COMM_WORLD, &size);
72 MPI_Comm_rank (MPI_COMM_WORLD, &myrank);
73
74 workfc.numpe = size;
75 workfc.myrank = myrank;
76
77 #if (defined WIN32)
78 if(argc > 2 ){
79 catchDebugger();
80 }
81 #endif
82 #if (1) // ALWAYS ( defined LAUNCH_GDB ) && !( defined WIN32 )
83
84 if ( pauseDebugger ) {
85
86 int parent_pid = getpid();
87 int gdb_child = fork();
88 cout << "gdb_child" << gdb_child << endl;
89
90 if( gdb_child == 0 ) {
91
92 cout << "Debugger Process initiating" << endl;
93 std::stringstream exec_string;
94
95 #if ( defined decalp )
96 exec_string <<"xterm -e idb "
97 << " -pid "<< parent_pid <<" "<< argv[0] << endl;
98 #endif
99 #if ( defined LINUX )
100 exec_string <<"xterm -e gdb"
101 << " -pid "<< parent_pid <<" "<< argv[0] << endl;
102 #endif
103 #if ( defined SUN4 )
104 exec_string <<"xterm -e dbx "
105 << " - "<< parent_pid <<" "<< argv[0] << endl;
106 #endif
107 #if ( defined IRIX )
108 exec_string <<"xterm -e dbx "
109 << " -p "<< parent_pid <<" "<< argv[0] << endl;
110 #endif
111 std::string s = exec_string.str();
112 system( s.c_str() );
113 exit(0);
114 }
115 catchDebugger();
116 }
117
118 #endif
119
120 //MR CHANGE
121 setIOparam();
122 //MR CHANGE END
123
124 input();
125 //MR CHANGE
126
127 MPI_Barrier(MPI_COMM_WORLD);
128 if ( myrank == 0 ) {
129 printf("phasta.cc - last call before finalize!\n");
130 }
131 //MR CHANGE
132
133 MPI_Finalize();
134 return 0;
135 }
136