Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
ignore generated tesh files
[simgrid.git] / teshsuite / smpi / isp / umpire / intercomm_create-no-error.c
1 /* -*- Mode: C; -*- */
2 /* Creator: Bronis R. de Supinski (bronis@llnl.gov)  */
3
4 /* type-no-error-exhaustive.c -- use all group constructors correctly */
5
6 #ifndef lint
7 static char *rcsid =
8   "$Header: /usr/gapps/asde/cvs-vault/umpire/tests/intercomm_create-no-error.c,v 1.1 2002/07/30 21:34:43 bronis Exp $";
9 #endif
10
11 #include <stdio.h>
12 #include <string.h>
13 #include "mpi.h"
14
15
16 #define INTERCOMM_CREATE_TAG 666
17
18
19 int
20 main (int argc, char **argv)
21 {
22   int nprocs = -1;
23   int rank = -1;
24   char processor_name[128];
25   int namelen = 128;
26   int i;
27   MPI_Comm temp, intercomm = MPI_COMM_NULL;
28
29   /* init */
30   MPI_Init (&argc, &argv);
31   MPI_Comm_size (MPI_COMM_WORLD, &nprocs);
32   MPI_Comm_rank (MPI_COMM_WORLD, &rank);
33   MPI_Get_processor_name (processor_name, &namelen);
34   printf ("(%d) is alive on %s\n", rank, processor_name);
35   fflush (stdout);
36
37   MPI_Barrier (MPI_COMM_WORLD);
38
39   if (nprocs < 2) {
40       printf ("requires at least 2 tasks\n");
41   }
42   else {
43     /* need lots of stuff for this constructor... */
44     MPI_Comm_split (MPI_COMM_WORLD, rank % 2, nprocs - rank, &temp);
45
46     MPI_Intercomm_create (temp, 0, MPI_COMM_WORLD, 
47                           nprocs - 
48                           ((rank % 2) ? 2 - (nprocs % 2) : 1 + (nprocs % 2)),
49                           INTERCOMM_CREATE_TAG, &intercomm);
50       
51     MPI_Comm_free (&intercomm);
52
53     MPI_Comm_free (&temp);
54   }
55
56   MPI_Barrier (MPI_COMM_WORLD);
57
58   printf ("(%d) Finished normally\n", rank);
59   MPI_Finalize ();
60 }
61
62 /* EOF */