diff --git a/dune/common/parallel/communicator.hh b/dune/common/parallel/communicator.hh index 3d3f970b06060f9b29da60923be5cba6f5d67601..b47484da85720a1f5070ab71937b580eb32f470c 100644 --- a/dune/common/parallel/communicator.hh +++ b/dune/common/parallel/communicator.hh @@ -1433,15 +1433,23 @@ namespace Dune if(FORWARD) { assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= recvBufferSize ); Dune::dvverb<<rank<<": receiving "<<info->second.second.size_<<" from "<<info->first<<std::endl; - MPI_Irecv(recvBuffer+info->second.second.start_, info->second.second.size_, - MPI_BYTE, info->first, commTag_, communicator_, - recvRequests+i); + if(info->second.second.size_) + MPI_Irecv(recvBuffer+info->second.second.start_, info->second.second.size_, + MPI_BYTE, info->first, commTag_, communicator_, + recvRequests+i); + else + # Nothing to receive -> set request to inactive + recvRequests[i]=MPI_REQUEST_NULL; }else{ assert(info->second.first.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.first.size_ <= recvBufferSize ); Dune::dvverb<<rank<<": receiving "<<info->second.first.size_<<" to "<<info->first<<std::endl; - MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_, - MPI_BYTE, info->first, commTag_, communicator_, - recvRequests+i); + if(info->second.first.size_) + MPI_Irecv(recvBuffer+info->second.first.start_, info->second.first.size_, + MPI_BYTE, info->first, commTag_, communicator_, + recvRequests+i); + else + # Nothing to receive -> set request to inactive + recvRequests[i]=MPI_REQUEST_NULL; } } @@ -1452,15 +1460,23 @@ namespace Dune assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= recvBufferSize ); Dune::dvverb<<rank<<": sending "<<info->second.first.size_<<" to "<<info->first<<std::endl; assert(info->second.first.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.first.size_ <= sendBufferSize ); - MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_, - MPI_BYTE, info->first, commTag_, communicator_, - sendRequests+i); + if(info->second.first.size_) + MPI_Issend(sendBuffer+info->second.first.start_, info->second.first.size_, + MPI_BYTE, info->first, commTag_, communicator_, + sendRequests+i); + else + # Nothing to send -> set request to inactive + sendRequests[i]=MPI_REQUEST_NULL; }else{ assert(info->second.second.start_*sizeof(typename CommPolicy<Data>::IndexedType)+info->second.second.size_ <= sendBufferSize ); Dune::dvverb<<rank<<": sending "<<info->second.second.size_<<" to "<<info->first<<std::endl; - MPI_Issend(sendBuffer+info->second.second.start_, info->second.second.size_, - MPI_BYTE, info->first, commTag_, communicator_, - sendRequests+i); + if(info->second.second.size_) + MPI_Issend(sendBuffer+info->second.second.start_, info->second.second.size_, + MPI_BYTE, info->first, commTag_, communicator_, + sendRequests+i); + else + # Nothing to send -> set request to inactive + sendRequests[i]=MPI_REQUEST_NULL; } // Wait for completion of receive and immediately start scatter