MPI003 irecv-buffer-used-before-completion
warning enabled by defaultThe buffer of a pending mpi_irecv is used before the request is completed.
Why
Until mpi_wait/mpi_test completes an mpi_irecv, its buffer holds undefined data: the message may arrive before, during or after the access. Reading it gives stale or partial values, writing it may be overwritten by the incoming message. Complete the request first.
Reported
fortran
call mpi_irecv(halo, n, MPI_REAL8, src, 0, comm, req, ierr)
q(0) = halo(1) ! the message may not be there yet
call mpi_wait(req, MPI_STATUS_IGNORE, ierr)Preferred
fortran
call mpi_irecv(halo, n, MPI_REAL8, src, 0, comm, req, ierr)
call mpi_wait(req, MPI_STATUS_IGNORE, ierr)
q(0) = halo(1)Suppressing
For one occurrence, with the reason on the same line (or alone on the line before the statement):
fortran
! fobis: ignore[MPI003] <why this occurrence is fine>For the whole project, ignore = MPI003 in the fobos [lint] section.