I'm trying to solve a simple problem with MPI but when I comment all the
PRINT lines the program gets into a deadlock, when I uncomment one of
them then the programm proceeds smoothly!!!! I can't understand what is
wrong with this? I'm using blocking send and receive so time difference
that print makes should not has any effect on the overal performance!
idea of IF is that odd processes first send and evens recieve then vice
versa, so there should not be any deadlock even if there don't be any
buffer on the way!
What is wrong with my algorithm that makes it break?
integer,parameter ::IM=100,JM=100 REAL,ALLOCATABLE ::T(:,:),TF(:,:) .. CALL MPI_COMM_RANK(MPI_COMM_WORLD,RNK,IERR) CALL MPI_COMM_SIZE(MPI_COMM_WORLD,SIZ,IERR) .. prv = rnk-1 nxt = rnk+1 LIM = INT(IM/SIZ) IF (rnk==0) THEN ALLOCATE(TF(IM,JM)) prv = MPI_PROC_NULL ELSEIF(rnk==siz-1) THEN NXT = MPI_PROC_NULL LIM = LIM+MOD(IM,SIZ) END IF ALLOCATE(T(LIM+2,JM+2)) IF (MOD(RNK,2)==0) THEN CALL MPI_SEND(T(2,:),JM+2,MPI_REAL,PRV,10,MPI_COMM_WORLD,IERR) !PRINT*,RNK,'SENT' CALL MPI_RECV(T(1,:),JM+2,MPI_REAL,PRV,20,MPI_COMM_WORLD,STAT,IERR) !PRINT*,RNK,'RECIEVED' ELSE CALL MPI_RECV(T(LIM+2,:),JM+2,MPI_REAL,NXT,10,MPI_COMM_WORLD,STAT,IERR) PRINT*,RNK,'RECIEVED' CALL MPI_SEND(T(LIM+1,:),JM+2,MPI_REAL,NXT,20,MPI_COMM_WORLD,IERR) !PRINT*,RNK,'SENT' END IF