I am tring to write a 4 * 4 array using MPI_SET_VIEW and MPI_WRITE_ALL. The xx is a 4 * 4 array and I expect xx = (0,1,2,3; 0,1,2,3; 0,1,2,3; 0,1,2,3) for this code. The globle_size and the local_size equal to 4 and 2. I first create a subarray 2 * 2 file type, so that I divide this 4 * 4 array into 4 parts which is 2 * 2. Then I set view of this file type, and write the xx. The result shold equal to (0,1,2,3; 0,1,2,3; 0,1,2,3; 0,1,2,3), however, it is not. Some of the results are right, and some are wrong.
1 When I do j=ls2,le2, i = ls1,le1, xx(i,j)=i, is array xx() a 4*4 array or 2 * 2 array? ls1=ls2=0,le1=le2=1.
2 For MPI_WRITE_ALL, Should I use 4 * 4 array or 2 * 2 array? and what should I put for the count?1 or 4?
3 For MPI_WRITE_ALL, Should I use filetype as typestyle?
integer::filesize,buffsize,i,Status(MPI_STATUS_SIZE),charsize,disp,filetype,j,count
integer::nproc,cart_comm,ierr,fh,datatype
INTEGER(KIND=MPI_OFFSET_KIND) offset
integer,dimension(dim):: sizes,inersizes,start,sb,ss
character:: name*50,para*100,zone*100
do j=local_start(2),local_end(2)
do i=local_start(1),local_end(1)
xx(i,j)=i
enddo
enddo
count=1
offset=0
start=cart_coords*local_length
call MPI_TYPE_CREATE_SUBARRAY(2,global_length,local_length,start,MPI_ORDER_FORTRAN,&
MPI_integer,filetype,ierr)
call MPI_TYPE_COMMIT(filetype,ierr)
call MPI_File_open(MPI_COMM_WORLD,'out.dat', &
MPI_MODE_WRONLY + MPI_MODE_CREATE,MPI_INFO_NULL,fh,ierr)
call MPI_File_set_view(fh,offset,MPI_integer,filetype,&
"native",MPI_INFO_NULL,ierr)
CALL MPI_FILE_WRITE(fh, xx,1, filetype, MPI_STATUS_ignore, ierr)