Re: [OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-31 Thread Yevgeny Kliteynik
You can explicitly specify the type of buffering that you want to get with setvbuf() C function. It can be block-buffered, line-buffered and unbuffered. Stdout is line-buffered by default. To make it un-buffered, you need something like this: setvbuf(stdout, NULL, _IONBF, 0) -- YK On 30-Mar-11

Re: [OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-30 Thread Jeff Squyres
I don't remember this being a function of the C language or the compiler; I'm pretty sure you can change whether stdout is line buffered or not at the OS level. As for OMPI, we deliberately set each MPI process' stdout to be line buffered before relaying it up to the mpirun process. This was b

Re: [OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-30 Thread Meilin Bai
You remind me. I now realize that it is not an matter of compiler, but an issue of C language. The printf() function in C doesn't print messages onto the standard ouput immediately, but instead stores them in a buffer. Only in some cases does the standard output work, defined in standard C: 1.

Re: [OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-30 Thread Pascal Deveze
Maybe this could solve your problem: Just add \n in the string you want to display: printf("Please give N= \n"); Of course, this will return, but the string is displayed. This run by me without the fflush(). On the other hand, do you really observe that the time of the scanf () and the time

Re: [OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-29 Thread Meilin Bai
So it means that MPI doesn't suit to interactive programming? Though we can really use fflush(stdout) to get the right order, it takes too more time, and it's said that using fflush() is not a good progrmming style in C. On the other hand, in Fortran language, this situation won't exist. Maybe it

Re: [OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-29 Thread Prentice Bisbal
On 03/29/2011 01:29 PM, Meilin Bai wrote: > Dear open-mpi users: > > I come across a little problem when running a MPI C program compiled > with Open MPI 1.4.3. A part of codes as follows: > > MPI_Init(&argc, &argv); > MPI_Comm_size(MPI_COMM_WORLD, &numprocs); > MPI_Comm_rank(MPI_CO

[OMPI users] printf and scanf problem of C code compiled with Open MPI

2011-03-29 Thread Meilin Bai
Dear open-mpi users: I come across a little problem when running a MPI C program compiled with Open MPI 1.4.3. A part of codes as follows: MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); MPI_Get_processor_name(processor_name,