9 main(
int narg,
char **args)
23 MPI_Init(&narg, &args);
24 MPI_Comm_size(MPI_COMM_WORLD, &Np);
27 fprintf(stderr,
"Not enough processes to run sanity check; need %d, but I've only got %d\n",
NPROC, Np);
28 MPI_Abort(MPI_COMM_WORLD, -1);
31 for (i=0; i !=
WASTE_SIZE; i++) WasteOfSpace[i] = 0.0;
35 for (i=0; i !=
NPROC; i++) irank[i] = i;
36 MPI_Comm_group(MPI_COMM_WORLD, &wgrp);
37 MPI_Group_incl(wgrp,
NPROC, irank, &mgrp);
38 MPI_Comm_create(MPI_COMM_WORLD, mgrp, &mcom);
39 MPI_Group_free(&mgrp);
43 if (mcom != MPI_COMM_NULL)
45 MPI_Comm_rank(mcom, &Iam);
51 MPI_Recv(&i, 1, MPI_INT, (
NPROC+Iam-1)%
NPROC, 0, mcom, &stat);
52 MPI_Send(&Iam, 1, MPI_INT, (Iam+1)%
NPROC, 0, mcom);
56 MPI_Send(&Iam, 1, MPI_INT, (Iam+1)%
NPROC, 0, mcom);
57 MPI_Recv(&i, 1, MPI_INT, (
NPROC+Iam-1)%
NPROC, 0, mcom, &stat);
64 fprintf(stderr,
"Communication does not seem to work properly!!\n");
65 MPI_Abort(MPI_COMM_WORLD, -1);
68 fprintf(stdout,
"%d: C MPI sanity test passed\n", Iam);