Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[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     }
24     else {
25         MPI_Type_vector(n, m, lda, type, &vtype);
26         MPI_Type_commit(&vtype);
27         A[0] = -1.0 - 0.1 * iam;
28         A[1] = 0.5 + 0.1 * iam;
29         printf("In process %i of %i before Bcast: A = %f,%f\n", 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", iam, np, A[0], A[1]);
32         MPI_Type_free(&vtype);
33     }
34
35     MPI_Finalize();
36 }