xref: /petsc/src/vec/is/ao/tests/ex4.c (revision ebead697dbf761eb322f829370bbe90b3bd93fa3)
1 
2 static char help[] = "Test AO with on IS with 0 entries - contributed by Ethan Coon <ecoon@lanl.gov>, Apr 2011.\n\n";
3 
4 #include <petscsys.h>
5 #include <petscao.h>
6 
7 int main(int argc,char **argv)
8 {
9   AO             ao;
10   PetscInt       *localvert=NULL, nlocal;
11   PetscMPIInt    rank;
12 
13   PetscFunctionBeginUser;
14   PetscCall(PetscInitialize(&argc,&argv,(char*)0,help));
15   PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank));
16   PetscCall(PetscMalloc1(4,&localvert));
17 
18   if (rank == 0) {
19     nlocal       = 4;
20     localvert[0] = 0;
21     localvert[1] = 1;
22     localvert[2] = 2;
23     localvert[3] = 3;
24   } else {
25     nlocal = 0;
26   }
27 
28   /* Test AOCreateBasic() */
29   PetscCall(AOCreateBasic(PETSC_COMM_WORLD, nlocal, localvert, NULL, &ao));
30   PetscCall(AODestroy(&ao));
31 
32   /* Test AOCreateMemoryScalable() */
33   PetscCall(AOCreateMemoryScalable(PETSC_COMM_WORLD, nlocal, localvert, NULL, &ao));
34   PetscCall(AODestroy(&ao));
35 
36   PetscCall(PetscFree(localvert));
37   PetscCall(PetscFinalize());
38   return 0;
39 }
40 
41 /*TEST
42 
43    test:
44 
45    test:
46       suffix: 2
47       nsize: 2
48       output_file: output/ex4_1.out
49 
50 TEST*/
51