KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to send 2d chunks of data using MPI_GATHER . For example: I have 2x3 arrays on each node and I want 8x3 array on root, if I have 4 nodes. For 1d arrays, MPI_GATHER sorts data according to MPI ranks, but for 2d data it creates a mess! What is the clean way to put chunks in order? I expected the output of this code: program testmpi use mpi implicit none integer :: send (2,3) integer :: rec (4,3) integer :: ierror,my_rank,i,j call MPI_Init(ierror) MPI_DATA_TYPE type_col ! find out process rank call MPI_Comm_rank(MPI_COMM_WORLD, my_rank, ierror) if (my_rank==0) then send=1 do i=1,2 print*,(send(i,j),j=1,3) enddo endif if (my_rank==1) then send=5 ! do 1,2 ! print*,(send(i,j),j=1,3) ! enddo endif call MPI_GATHER(send,6,MPI_INTEGER,rec,6,MPI_INTEGER,0,MPI_COMM_WORLD,ierror) if (my_rank==0) then print*,'<><><><><>rec' do i=1,4 print*,(rec(i,j),j=1,3) enddo endif call MPI_Finalize(ierror) end program testmpi to be something like this : 1 1 1 1 1 1 5 5 5 5 5 5 but it looks like this: 1 1 5 1 1 5 1 5 5 1 5 5
Tags (comma-separated)
Save Edits
Cancel