Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / teshsuite / smpi / privatization / privatization.c
1 /* Copyright (c) 2017-2022. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <mpi.h>
9
10
11 static int myvalue = 0;
12 static void test_opts(int argc, char* const argv[])
13 {
14   int found = 0;
15   static struct option long_options[] = {
16   {(char*)"long",     no_argument, 0,  0 },
17   {0,         0,                 0,  0 }
18   };
19   while (1) {
20     int ret = getopt_long_only(argc, argv, "s", long_options, NULL);
21     if(ret==-1)
22       break;
23
24     switch (ret) {
25       case 0:
26       case 's':
27         found ++;
28       break;
29       default:
30         printf("option %s", long_options[0].name);
31       break;
32     }
33   }
34   if (found!=2){
35     printf("(smpi_)getopt_long_only failed ! \n");
36   }
37 }
38 int main(int argc, char **argv)
39 {
40     int me;
41
42     MPI_Init(&argc, &argv);
43     /* test getopt_long function */
44     test_opts(argc, argv);
45
46     MPI_Comm_rank(MPI_COMM_WORLD, &me);
47
48     MPI_Barrier(MPI_COMM_WORLD);
49
50     myvalue = me;
51
52     MPI_Barrier(MPI_COMM_WORLD);
53
54     if(myvalue!=me)
55       printf("Privatization error - %d != %d\n", myvalue, me);
56     MPI_Finalize();
57     return 0;
58 }