I implemented the scheme you suggested and it was much easier than I thought. Very nice, thanks for your help.
However, I noticed that the execution times were much higher than the cases in which the failure didn't occur.
Is there any reason, apart from some implementation mistake, to explain this behavior?
I don't know if it would help, but I am sending below part of the receiver process Fortran code.
Thanks in advance.
c-----------------------------------------------------------------------
subroutine my_receiver
c ------------------------------------------------------------------
(...)
c Local
c -----
integer*4 m_stat(MPI_STATUS_SIZE)
integer*4 m_request(zrecv) ! request identifier for asynchronous receives
character card(zrecv)*(zbuf) ! buffer for receiving messages
c Pre-post RECVs
c --------------
do irecv = 1, zrecv
call MPI_IRECV(card(irecv), zbuf, MPI_CHARACTER,
. MPI_ANY_SOURCE, MPI_ANY_TAG, M_COMM_SDDP,
. m_request(irecv), m_ierr )
end do !irecv
do while( keep_receiving )
c Wait for any of the pre-posted requests to arrive
c -------------------------------------------------
call MPI_WAITANY(zrecv, m_request, irecv, m_stat, m_ierr)
c Process message: disk IO
c ---------------
<DO SOMETHING>
if( SOMETHING_ELSE ) then
keep_receiving = .false.
end if
c Re-post RECV
c ------------
call MPI_IRECV(card(irecv), zbuf, MPI_CHARACTER,
. MPI_ANY_SOURCE, MPI_ANY_TAG, M_COMM_SDDP,
. m_request(irecv), m_ierr)
end do
c Cancel unused RECVs
c -------------------
do irecv = 1, zrecv
call MPI_CANCEL( m_request(irecv), m_ierr )
end do !irecv
(...)
return
end