cmpi

warning: passing argument 7 of ‘MPI_Recv’ from incompatible pointer type


I'm trying to compile an MPI_Exchange function but keep getting the below errors.

Error:

OddEvenSort.c: In function ‘MPI_Exchange’:
OddEvenSort.c:75: warning: passing argument 7 of ‘MPI_Recv’ from incompatible pointer type
/usr/lib/openmpi/include/mpi.h:1174: note: expected ‘struct MPI_Status *’ but argument is of type ‘int *’
OddEvenSort.c:84: warning: passing argument 7 of ‘MPI_Recv’ from incompatible pointer type
/usr/lib/openmpi/include/mpi.h:1174: note: expected ‘struct MPI_Status *’ but argument is of type ‘int *’
/usr/bin/mpicc  -o OddEvenSort OddEvenSort.o -lm

Code:

int MPI_Exchange( int n, double *a, int rank1, int rank2,MPI_Comm comm )
{
   int rank, tag1, tag2, size, i, status;
   double * b, * c;


  MPI_Comm_rank(comm, &rank);
  MPI_Comm_size(comm, &size);

   if(rank == rank1){
     MPI_Send(&a[0],n,MPI_DOUBLE,rank2,tag1,comm);
     MPI_Recv(&b[0],n,MPI_DOUBLE,rank2,tag2,comm,&status);
     c = merge_array(n,a,n,b);
     for(i=0;i<n;i++){
       a[i] = c[i];
     }

   }
   else if(rank == rank2){
      MPI_Send(&a[0],n,MPI_DOUBLE,rank1,tag1,comm);
     MPI_Recv(&b[0],n,MPI_DOUBLE,rank1,tag2,comm,&status);
     c = merge_array(n,a,n,b);
     for(i=0;i<n;i++){
       a[i] = c[i+n];
     }
   }

     return MPI_SUCCESS;
    }

I believe the errors refer to &status in the two instances of MPI_Recv. I'm trying to get the address of status, which was declared earlier on in my code as MPI_Status status.


Solution

  • You have status declared as a local int:

       int rank, tag1, tag2, size, i, status;
    

    which overrides any global declaration of status earlier in your code.

    Either change the name of your local status variable or make it the appropriate type.