Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[codacy] Reduce scope for variables.
[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 **argv[]){
9   int found = 0;
10   static struct option long_options[] = {
11   {"long",     no_argument, 0,  0 },
12   {0,         0,                 0,  0 }
13   };
14   while (1) {
15     int ret = getopt_long_only(*argc, *argv, "s", long_options, NULL);
16     if(ret==-1)
17       break;
18
19     switch (ret) {
20       case 0:
21         found++;
22       break;
23       case 's':
24         found ++;
25       break;
26       default:
27         printf("option %s", long_options[0].name);
28       break;
29     }
30   }
31   if (found!=2){
32     printf("(smpi_)getopt_long_only failed ! \n");
33   }
34 }
35 int main(int argc, char **argv)
36 {
37     int me;
38
39     MPI_Init(&argc, &argv);
40     /* test getopt_long function */
41     test_opts(&argc, &argv);
42
43     MPI_Comm_rank(MPI_COMM_WORLD, &me);
44
45     MPI_Barrier(MPI_COMM_WORLD);
46
47     myvalue = me;
48
49     MPI_Barrier(MPI_COMM_WORLD);
50
51     if(myvalue!=me)
52       printf("Privatization error - %d != %d\n", myvalue, me);
53     MPI_Finalize();
54     return 0;
55 }