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 #if !(defined IOSTREAMH) 9 #include <iostream> 10 #include <strstream> 11 using namespace std; 12 #endif 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 "commonM2N_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 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 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 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 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 strstream 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 system( exec_string.str() ); 112 exit(0); 113 } 114 catchDebugger(); 115 } 116 117 #endif 118 119 //MR CHANGE 120 setIOparam(); 121 //MR CHANGE END 122 123 input(); 124 //MR CHANGE 125 126 MPI_Barrier(MPI_COMM_WORLD); 127 if ( myrank == 0 ) { 128 printf("phasta.cc - last call before finalize!\n"); 129 } 130 //MR CHANGE 131 132 MPI_Finalize(); 133 return 0; 134 } 135