Hi Folks,
I am using the following f90 example program for writing a file in parallel
with MIP:
[snip]
program parallel_io
use mpi
implicit none
integer ierr, i, myrank, BUFSIZE, thefile, intsize
parameter (BUFSIZE=100)
integer buf(BUFSIZE)
! integer (kind=MPI_OFFSET_KIND) disp
integer*8 disp
call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world, myrank,ierr)
do i=0,BUFSIZE
buf(i) = myrank*BUFSIZE + i
print*, 'i =', i, 'myrank =', myrank, 'buf(i)=',buf(i)
end do
call mpi_file_open(mpi_comm_world, 'testfile', MPI_MODE_WRONLY +
MPI_MODE_CREATE, mpi_info_null, thefile, ierr)
call mpi_type_size(MPI_INTEGER, intsize, ierr)
disp = myrank * BUFSIZE * intsize
! call mpi_file_set_view(thefile, disp, MPI_INTEGER, MPI_INTEGER, 'native',
mpi_info_null, ierr)
call mpi_file_write_at(thefile, disp, buf, BUFSIZE, MPI_INTEGER,
mpi_status_ignore, ierr)
call mpi_file_close(thefile, ierr)
call mpi_finalize(ierr)
end program parallel_io
[snip]
And the follwoing program shall read all the data in again, and print them out
[snip]
program parallel_read_io
use mpi
implicit none
integer ierr, i, myrank, BUFSIZE, thefile, intsize
parameter (BUFSIZE=100)
integer buf(BUFSIZE)
! integer (kind=MPI_OFFSET_KIND) disp
integer*8 disp
call mpi_init(ierr)
call mpi_comm_rank(mpi_comm_world, myrank,ierr)
! do i=0,BUFSIZE
! buf(i) = myrank*BUFSIZE + i
! end do
call mpi_file_open(mpi_comm_world, 'testfile', MPI_MODE_RDONLY, mpi_info_null,
thefile, ierr)
call mpi_type_size(MPI_INTEGER, intsize, ierr)
disp = myrank * BUFSIZE * intsize
! call mpi_file_set_view(thefile, disp, MPI_INTEGER, MPI_INTEGER, 'native',
mpi_info_null, ierr)
! call mpi_file_read(thefile, buf, BUFSIZE, MPI_INTEGER, mpi_status_ignore,
ierr)
call mpi_file_read_at(thefile, disp, buf, BUFSIZE, MPI_INTEGER,
mpi_status_ignore, ierr)
call mpi_file_close(thefile, ierr)
! print the data read in...
if (myrank.eq.1) then
do i = 0,BUFSIZE
print*, 'i =', i, 'myrank =', myrank, 'buf(i)=', buf(i)
end do
endif
call mpi_finalize(ierr)
[snip]
I have maid several tests, also with do loops only from 0 to (BUFSIZE-1), with
MPI_FILE_SET_VIEW and MPI_FILE_READ, etc...
When I am reading the data in again and print them out, I always have:
buf(0)=0
for every rank, so I assume that something with the offset is wrong. I am using
openmpi with an Intel f90 compiler.
What am I doing wrong?
Best wishes
Alexander
|