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 #if !(defined IOSTREAMH) 10 #include <iostream> 11 #include <strstream> 12 using namespace std; 13 #endif 14 15 #define OMPI_SKIP_MPICXX 1 16 #include <mpi.h> 17 18 #include <FCMangle.h> 19 #define input FortranCInterface_GLOBAL_(input,INPUT) 20 #define timer FortranCInterface_GLOBAL_(timer,TIMER) 21 22 #include "commonM2N_c.h" 23 24 extern "C" char phasta_iotype[80]; 25 char phasta_iotype[80]; 26 27 extern "C" void input(); 28 //MR CHANGE 29 extern void setIOparam(); // For SyncIO 30 //MR CHANGE END 31 32 int myrank; /* made file global for ease in debugging */ 33 34 void 35 catchDebugger() { 36 while (1) { 37 int debuggerPresent=0; 38 int fakeSTOP = 1; // please stop HERE and assign as next line 39 // assign or set debuggerPresent=1 40 if(debuggerPresent) { 41 break; 42 } 43 } 44 } 45 46 // some useful debugging functions 47 48 void 49 pdarray( void* darray , int start, int end ) { 50 for( int i=start; i < end; i++ ){ 51 cout << ((double*)darray)[i] << endl; 52 } 53 } 54 55 void 56 piarray( void* iarray , int start, int end ) { 57 for( int i=start; i < end; i++ ){ 58 cout << ((int*)iarray)[i] << endl; 59 } 60 } 61 62 extern "C" int 63 phasta( int argc, 64 char *argv[] ) { 65 66 int size,ierr; 67 char inpfilename[100]; 68 char* pauseDebugger = getenv("catchDebugger"); 69 //cout << "pauseDebugger" << pauseDebugger << endl; 70 71 MPI_Init(&argc,&argv); 72 MPI_Comm_size (MPI_COMM_WORLD, &size); 73 MPI_Comm_rank (MPI_COMM_WORLD, &myrank); 74 75 workfc.numpe = size; 76 workfc.myrank = myrank; 77 78 #if (defined WIN32) 79 if(argc > 2 ){ 80 catchDebugger(); 81 } 82 #endif 83 #if (1) // ALWAYS ( defined LAUNCH_GDB ) && !( defined WIN32 ) 84 85 if ( pauseDebugger ) { 86 87 int parent_pid = getpid(); 88 int gdb_child = fork(); 89 cout << "gdb_child" << gdb_child << endl; 90 91 if( gdb_child == 0 ) { 92 93 cout << "Debugger Process initiating" << endl; 94 strstream exec_string; 95 96 #if ( defined decalp ) 97 exec_string <<"xterm -e idb " 98 << " -pid "<< parent_pid <<" "<< argv[0] << endl; 99 #endif 100 #if ( defined LINUX ) 101 exec_string <<"xterm -e gdb" 102 << " -pid "<< parent_pid <<" "<< argv[0] << endl; 103 #endif 104 #if ( defined SUN4 ) 105 exec_string <<"xterm -e dbx " 106 << " - "<< parent_pid <<" "<< argv[0] << endl; 107 #endif 108 #if ( defined IRIX ) 109 exec_string <<"xterm -e dbx " 110 << " -p "<< parent_pid <<" "<< argv[0] << endl; 111 #endif 112 system( exec_string.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