X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3d39ee2f8a52715e6b417575029faa8a91307f21..7842bd614301712801b9f2b4a117824333cd3e16:/teshsuite/smpi/mpich3-test/comm/probe-intercomm.c diff --git a/teshsuite/smpi/mpich3-test/comm/probe-intercomm.c b/teshsuite/smpi/mpich3-test/comm/probe-intercomm.c index 03c9e109c1..85464ef857 100644 --- a/teshsuite/smpi/mpich3-test/comm/probe-intercomm.c +++ b/teshsuite/smpi/mpich3-test/comm/probe-intercomm.c @@ -15,57 +15,58 @@ static char MTEST_Descrip[] = "Test MPI_Probe() for an intercomm"; */ #define MAX_DATA_LEN 100 -int main( int argc, char *argv[] ) +int main(int argc, char *argv[]) { int errs = 0, recvlen, isLeft; MPI_Status status; int rank, size; - MPI_Comm intercomm; + MPI_Comm intercomm; char buf[MAX_DATA_LEN]; const char *test_str = "test"; - MTest_Init( &argc, &argv ); + MTest_Init(&argc, &argv); - MPI_Comm_rank( MPI_COMM_WORLD, &rank ); - MPI_Comm_size( MPI_COMM_WORLD, &size ); + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &size); if (size < 2) { - fprintf( stderr, "This test requires at least two processes." ); - MPI_Abort( MPI_COMM_WORLD, 1 ); - exit(1); + fprintf(stderr, "This test requires at least two processes."); + MPI_Abort(MPI_COMM_WORLD, 1); } - while (MTestGetIntercomm( &intercomm, &isLeft, 2 )) { - if (intercomm == MPI_COMM_NULL) continue; + while (MTestGetIntercomm(&intercomm, &isLeft, 2)) { + if (intercomm == MPI_COMM_NULL) + continue; MPI_Comm_rank(intercomm, &rank); /* 0 ranks on each side communicate, everyone else does nothing */ - if(rank == 0) { + if (rank == 0) { if (isLeft) { recvlen = -1; MPI_Probe(0, 0, intercomm, &status); MPI_Get_count(&status, MPI_CHAR, &recvlen); if (recvlen != (strlen(test_str) + 1)) { - printf(" Error: recvlen (%d) != strlen(\"%s\")+1 (%d)\n", recvlen, test_str, (int)strlen(test_str) + 1); + printf(" Error: recvlen (%d) != strlen(\"%s\")+1 (%d)\n", recvlen, test_str, + (int) strlen(test_str) + 1); ++errs; } buf[0] = '\0'; MPI_Recv(buf, recvlen, MPI_CHAR, 0, 0, intercomm, &status); - if (strcmp(test_str,buf)) { + if (strcmp(test_str, buf)) { printf(" Error: strcmp(test_str,buf)!=0\n"); ++errs; } } else { strncpy(buf, test_str, 5); - MPI_Send(buf, strlen(buf)+1, MPI_CHAR, 0, 0, intercomm); + MPI_Send(buf, strlen(buf) + 1, MPI_CHAR, 0, 0, intercomm); } } MTestFreeComm(&intercomm); } - MTest_Finalize( errs ); + MTest_Finalize(errs); MPI_Finalize(); return 0; }