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