Discussion:
Question
(too old to reply)
Mojtaba Ghasemi
2012-01-06 00:42:35 UTC
Permalink
Hello
I am a graduate student working in the reservoir simulation group at
University of Texas at Austin.

I am working on a project related to the application of MPI for
development of a parallel reservoir simulator.

For post processing of the results, I need to write the results into
binary files.

I want to write the results sorted (I mean first processor writes and
then second processor and then third processor and etc. )
I am thinking of the following loop for my idea:

Do K = 1, NZ (local NX,NY,NZ)
DO IP = 1, # of Processors
IF (Current Processor is
equal to IP) Then
DO J =1, NY
DO I =1, NX
Write(Binary
file) Pressure(I,J,K)
END DO ! I
END DO ! J
END IF
Other Processors WAIT here !
END DO ! IP
END DO ! K

But I don’t know how I should say that other processors wait until
current processor writes its output and then they go to the next
processor.
Is there any MPI command which I can use for my work?

I appreciate your help.
Sincerely
Mojtaba Ghasemi
Gilles
2012-01-09 07:28:47 UTC
Permalink
Hi,

The idea you exposed here is the right one. Actually, this is the very one I usually use to present MPI_Barrier with a non-trivial real-life use case.

the code becomes:

do i=0,np-1
if (myrank == i)
open(fd, .....) ! open the output file in append mode
write(fd, ....) ! write whatever you need to there
close(fd) ! close the file (forces its flush to disk)
endif
MPI_Barrier(comm, ierr)
enddo

you end up with a sequentialised writing in your file, from rank 0 up to rank np-1.

Cheers.

Gilles
Post by Mojtaba Ghasemi
Hello
I am a graduate student working in the reservoir simulation group at
University of Texas at Austin.
I am working on a project related to the application of MPI for
development of a parallel reservoir simulator.
For post processing of the results, I need to write the results into
binary files.
I want to write the results sorted (I mean first processor writes and
then second processor and then third processor and etc. )
Do K = 1, NZ (local NX,NY,NZ)
DO IP = 1, # of Processors
IF (Current Processor is
equal to IP) Then
DO J =1, NY
DO I =1, NX
Write(Binary
file) Pressure(I,J,K)
END DO ! I
END DO ! J
END IF
Other Processors WAIT here !
END DO ! IP
END DO ! K
But I don’t know how I should say that other processors wait until
current processor writes its output and then they go to the next
processor.
Is there any MPI command which I can use for my work?
I appreciate your help.
Sincerely
Mojtaba Ghasemi
Loading...