1 //MR CHANGE 2 #define OMPI_SKIP_MPICXX 1 3 //MR CHANGE END 4 #include <mpi.h> 5 #include <stdio.h> 6 #include <stdlib.h> 7 #include <string.h> 8 9 #include <sys/types.h> 10 #include <sys/stat.h> 11 12 #include "common_c.h" 13 14 #if !(defined IOSTREAMH) 15 #include <iostream> 16 #include <strstream> 17 using namespace std; 18 #endif 19 20 #include <FCMangle.h> 21 #define input FortranCInterface_GLOBAL_(input,INPUT) 22 #define proces FortranCInterface_GLOBAL_(proces,PROCES) 23 #define timer FortranCInterface_GLOBAL_(timer,TIMER) 24 25 #ifdef intel 26 #include <direct.h> 27 #define chdir _chdir 28 #else 29 #include <unistd.h> 30 #endif 31 32 extern "C" char phasta_iotype[80]; 33 char phasta_iotype[80]; 34 35 extern int SONFATH; 36 extern "C" void proces(); 37 extern "C" void input(); 38 extern int input_fform(char inpfname[]); 39 //MR CHANGE 40 extern void setIOparam(); // For SyncIO 41 //MR CHANGE END 42 43 int myrank; /* made file global for ease in debugging */ 44 45 void 46 catchDebugger() { 47 while (1) { 48 int debuggerPresent=0; 49 int fakeSTOP = 1; // please stop HERE and assign as next line 50 // assign or set debuggerPresent=1 51 if(debuggerPresent) { 52 break; 53 } 54 } 55 } 56 57 // some useful debugging functions 58 59 void 60 pdarray( void* darray , int start, int end ) { 61 for( int i=start; i < end; i++ ){ 62 cout << ((double*)darray)[i] << endl; 63 } 64 } 65 66 void 67 piarray( void* iarray , int start, int end ) { 68 for( int i=start; i < end; i++ ){ 69 cout << ((int*)iarray)[i] << endl; 70 } 71 } 72 73 extern "C" int 74 phasta( int argc, 75 char *argv[] ) { 76 77 int size,ierr; 78 char inpfilename[100]; 79 char* pauseDebugger = getenv("catchDebugger"); 80 //cout << "pauseDebugger" << pauseDebugger << endl; 81 82 MPI_Init(&argc,&argv); 83 MPI_Comm_size (MPI_COMM_WORLD, &size); 84 MPI_Comm_rank (MPI_COMM_WORLD, &myrank); 85 86 workfc.numpe = size; 87 workfc.myrank = myrank; 88 89 #if (defined WIN32) 90 if(argc > 2 ){ 91 catchDebugger(); 92 } 93 #endif 94 #if (1) // ALWAYS ( defined LAUNCH_GDB ) && !( defined WIN32 ) 95 96 if ( pauseDebugger ) { 97 98 int parent_pid = getpid(); 99 int gdb_child = fork(); 100 cout << "gdb_child" << gdb_child << endl; 101 102 if( gdb_child == 0 ) { 103 104 cout << "Debugger Process initiating" << endl; 105 strstream exec_string; 106 107 #if ( defined decalp ) 108 exec_string <<"xterm -e idb " 109 << " -pid "<< parent_pid <<" "<< argv[0] << endl; 110 #endif 111 #if ( defined LINUX ) 112 exec_string <<"xterm -e gdb" 113 << " -pid "<< parent_pid <<" "<< argv[0] << endl; 114 #endif 115 #if ( defined SUN4 ) 116 exec_string <<"xterm -e dbx " 117 << " - "<< parent_pid <<" "<< argv[0] << endl; 118 #endif 119 #if ( defined IRIX ) 120 exec_string <<"xterm -e dbx " 121 << " -p "<< parent_pid <<" "<< argv[0] << endl; 122 #endif 123 system( exec_string.str() ); 124 exit(0); 125 } 126 catchDebugger(); 127 } 128 129 #endif 130 131 /* Input data */ 132 if(argc > 1 ){ 133 strcpy(inpfilename,argv[1]); 134 } else { 135 strcpy(inpfilename,"solver.inp"); 136 } 137 ierr = input_fform(inpfilename); 138 if(!ierr){ 139 sprintf(inpfilename,"%d-procs_case/",size); 140 if( chdir( inpfilename ) ) { 141 cerr << "could not change to the problem directory " 142 << inpfilename << endl; 143 return 1; 144 } 145 MPI_Barrier(MPI_COMM_WORLD); 146 147 //MR CHANGE 148 setIOparam(); 149 //MR CHANGE END 150 151 input(); 152 /* now we can start the solver */ 153 proces(); 154 } 155 else{ 156 printf("error during reading ascii input \n"); 157 } 158 159 //MR CHANGE 160 161 MPI_Barrier(MPI_COMM_WORLD); 162 if ( myrank == 0 ) { 163 printf("phasta.cc - last call before finalize!\n"); 164 } 165 //MR CHANGE 166 167 MPI_Finalize(); 168 return 0; 169 } 170