I'm writing an MPI C program. I have troubles debugging it, because whenever I use fprintf, like this: fprintf(stdout, "worker: %d", worker); if the program hangs, because of some blocking MPI_Recv, I can't see any output. I'm sure the line of code is reached, because I can put a return statement after the fprintf statement, in which case the process finishes execution and the output is printed. Any ideas, on how to print (see the output) even though the process gets blocked later by Recv? I hope this makes sense.
+1
A:
By default, stdout
is line buffered, so you may want to end your debugging print calls with newlines:
fprintf(stdout, "workder: %d\n", worker);
If you don't want a newline, you can flush the stream yourself:
fprintf(stdout, "workder: %d", worker);
fflush(stdout);
Alok
2010-03-15 03:28:26