Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'Adrien.Gougeon/simgrid-master'
[simgrid.git] / teshsuite / smpi / privatization / privatization.c
1
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <mpi.h>
5
6
7 static int myvalue = 0;
8 static void test_opts(int argc, char* const argv[])
9 {
10   int found = 0;
11   static struct option long_options[] = {
12   {(char*)"long",     no_argument, 0,  0 },
13   {0,         0,                 0,  0 }
14   };
15   while (1) {
16     int ret = getopt_long_only(argc, argv, "s", long_options, NULL);
17     if(ret==-1)
18       break;
19
20     switch (ret) {
21       case 0:
22       case 's':
23         found ++;
24       break;
25       default:
26         printf("option %s", long_options[0].name);
27       break;
28     }
29   }
30   if (found!=2){
31     printf("(smpi_)getopt_long_only failed ! \n");
32   }
33 }
34 int main(int argc, char **argv)
35 {
36     int me;
37
38     MPI_Init(&argc, &argv);
39     /* test getopt_long function */
40     test_opts(argc, argv);
41
42     MPI_Comm_rank(MPI_COMM_WORLD, &me);
43
44     MPI_Barrier(MPI_COMM_WORLD);
45
46     myvalue = me;
47
48     MPI_Barrier(MPI_COMM_WORLD);
49
50     if(myvalue!=me)
51       printf("Privatization error - %d != %d\n", myvalue, me);
52     MPI_Finalize();
53     return 0;
54 }