MPI SSend Recv pair

Hi All,

I’ve written the following piece of MPI code that would enforce a temporal order on a section of it. It should print ‘Hello’ in any order, and ‘Hello Again’ in order by rank. But it is ending up crashing with a signal 11 segmentation fault.

ppinit and ppexit do MPI_Init and MPI_Finalize
me=rank
nvp=size

rest are integer variables.

  call ppinit
  write(*,*)"Hello from rank ",me,"of",nvp

  if ( me .ne. 0 ) then
     call MPI_RECV(zstart, 1, MPI_INTEGER, 0, 0, MPI_COMM_WORLD, ierr)
  else 
     zstart = 1
  end if

  if (zstart .eq. 1) then
     write(*,*)"Hello Again from rank ",me,"of",nvp
     zdone = 1 
  else 
     zdone = 0
  end if

  if ( me .ne. (nvp-1)) then
     call MPI_SSEND(zdone, 1, MPI_INTEGER, 1, 0 , MPI_COMM_WORLD, ierr)
  end if

  call ppexit

Would appreciate if any MPI users help debug where I am going wrong.

  • Aditya