Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
547960522ec5c7a3ea8ba9d464e2817fda4006d1
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / probenull.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2005 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include "mpi.h"
8 #include "mpitest.h"
9
10 /* 
11  * This program checks that MPI_Iprobe and MPI_Probe correctly handle
12  * a source of MPI_PROC_NULL
13  */
14
15 int main(int argc, char **argv)
16 {
17     int flag;
18     int errs = 0;
19     MPI_Status status;
20
21     MTest_Init(&argc, &argv);
22
23     MPI_Iprobe( MPI_PROC_NULL, 10, MPI_COMM_WORLD, &flag, &status );
24     if (!flag) {
25         errs++;
26         printf( "Iprobe of source=MPI_PROC_NULL returned flag=false\n" );
27     }
28     else {
29         if (status.MPI_SOURCE != MPI_PROC_NULL) {
30             printf( "Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n",
31                     status.MPI_SOURCE );
32             errs++;
33         }
34         if (status.MPI_TAG    != MPI_ANY_TAG) {
35             printf( "Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n",
36                     status.MPI_TAG );
37             errs++;
38         }
39     }
40     /* If Iprobe failed, probe is likely to as well.  Avoid a possible hang 
41        by testing Probe only if Iprobe test passed */
42     if (errs == 0) {
43         MPI_Probe(  MPI_PROC_NULL, 10, MPI_COMM_WORLD, &status );
44         if (status.MPI_SOURCE != MPI_PROC_NULL) {
45             printf( "Status.MPI_SOURCE was %d, should be MPI_PROC_NULL\n",
46                     status.MPI_SOURCE );
47             errs++;
48         }
49         if (status.MPI_TAG    != MPI_ANY_TAG) {
50             printf( "Status.MPI_TAG was %d, should be MPI_ANY_TAGL\n",
51                     status.MPI_TAG );
52             errs++;
53         }
54     }
55
56     MTest_Finalize( errs );
57     MPI_Finalize();
58     return 0;
59 }