Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix HAVE_FOOBAR flags handling
[simgrid.git] / teshsuite / smpi / mpich3-test / datatype / zero-blklen-vector.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *
4  *  (C) 2003 by Argonne National Laboratory.
5  *      See COPYRIGHT in top-level directory.
6  */     
7
8 #include <mpi.h>
9 #include <stdio.h>
10 int main(int argc, char* argv[])
11 {
12         int iam, np;
13         int m = 2, n = 0, lda = 1;
14         double A[2];
15         MPI_Comm comm = MPI_COMM_WORLD;
16         MPI_Datatype type = MPI_DOUBLE, vtype;
17
18         MPI_Init(&argc,&argv);
19         MPI_Comm_size(comm, &np);
20         MPI_Comm_rank(comm, &iam);
21         if (np < 2) {
22                 printf( "Should be at least 2 processes for the test\n");
23         } else {
24                 MPI_Type_vector(n, m, lda, type, &vtype);
25                 MPI_Type_commit(&vtype);
26                 A[0] = -1.0-0.1*iam;
27                 A[1] = 0.5+0.1*iam;
28                 printf("In process %i of %i before Bcast: A = %f,%f\n",
29                        iam, np, A[0], A[1] );
30                 MPI_Bcast(A, 1, vtype, 0, comm);
31                 printf("In process %i of %i after Bcast: A = %f,%f\n",
32                        iam, np, A[0], A[1]);
33                 MPI_Type_free(&vtype);
34         }
35
36         MPI_Finalize();
37    return(0);
38 }