recv-send.sh 446 Bytes
Newer Older
j.knedlik's avatar
j.knedlik committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
mpic++ -o sendrecv.exe -x c++ - << EOF
#include <mpi.h>
int main(int argc, char **argv)
{
  MPI_Init(NULL,NULL);
  int rank;
  int number=-1;
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  if (rank == 0) {
  	number = 0;
    	MPI_Send(&number, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
  } else {
    	MPI_Recv(&number, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,
        MPI_STATUS_IGNORE);
 }
  MPI_Finalize();
  return number;
}
EOF
srun -n 2 -- $PWD/sendrecv.exe