Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran MPI array communication

Status
Not open for further replies.

VLBalbert

Technical User
Sep 16, 2010
2
US
Hi there, I hope someone can help me here. This is the problem:

I need to communicate between processes a slice of a 3D array (i,j,k). The slice is a plane with j=constant. The memory is not contiguos on the slice since j changes faster then k.
the dimensions of the array are (NI,NJ,NK)

My solution number one: create an MPI_type_vector.
call MPI_TYPE_VECTOR(NK, NI, NJ, MPI_REAL8, y_slice_vec, err)
call MPI_TYPE_COMMIT(y_slice_vec, err)

so that was NK elements with NI number of entries with stride NJ.

My solution number two: create an MPI_type_struct.
integer, parameter :: szr=8 ! real8 memory displacement
Allocate(block_lenghts(NK),offset(NK),types(NK))
block_lenghts:))=NI
types:))=MPI_REAL8
offset:))=szr*NI*NJ
call MPI_TYPE_STRUCT(NK, block_lenghts, offset, types, y_slice, err)
call MPI_TYPE_COMMIT(y_slice, err)

and then communicate with send and receive statements. None of them work! bunch of zeros get communicate, but at least the program doesn't crash.
 
I found the error, at least vor MPI_type_vector:
the stride is the one between elements, not blocks, therefore
call MPI_TYPE_VECTOR(NK, NI, NI*NJ, MPI_REAL8, y_slice_vec, err)
cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top