I am using MPI in fortran for computation of my data. I verified by printing the data that, computations are being performed on the desired rang by each process just fine but, it the master is unable to collate the data.
Here is the code that I am trying to make it work: EDIT: Created a tag which is constant for the send and recv
integer :: tag
tag = 123
if(pid.ne.0) then
print *,'pid: ',pid,'sending'
DO j = start_index+1, end_index
CALL MPI_SEND(datapacket(j),1, MPI_REAL,0, tag, MPI_COMM_WORLD)
!print *,'sending'
END DO
print *,'send complete'
else
DO slave_id = 1, npe-1
rec_start_index = slave_id*population_size+1
rec_end_index = (slave_id + 1) * population_size;
IF (slave_id == npe-1) THEN
rec_end_index = total-1;
ENDIF
print *,'received 1',rec_start_index,rec_end_index
CALL MPI_RECV(datapacket(j),1,MPI_REAL,slave_id,tag,MPI_COMM_WORLD, &
& status)
!print *,'received 2',rec_start_index,rec_end_index
END DO
It never prints received
or anything after the MPI_RECV
call but, I can see the sending happening just fine however, there is no way I can verify it except to rely on the print statements.
The variable databpacket
is initialized as follows:
real, dimension (:), allocatable :: datapacket
Is there any thing that I am doing wrong here?
EDIT: For the test setup all the process are being run on the localhost.