xref: /petsc/src/vec/is/ao/tests/ex4.c (revision b122ec5aa1bd4469eb4e0673542fb7de3f411254)
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   CHKERRQ(PetscInitialize(&argc,&argv,(char*)0,help));
14   CHKERRMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank));
15   CHKERRQ(PetscMalloc1(4,&localvert));
16 
17   if (rank == 0) {
18     nlocal       = 4;
19     localvert[0] = 0;
20     localvert[1] = 1;
21     localvert[2] = 2;
22     localvert[3] = 3;
23   } else {
24     nlocal = 0;
25   }
26 
27   /* Test AOCreateBasic() */
28   CHKERRQ(AOCreateBasic(PETSC_COMM_WORLD, nlocal, localvert, NULL, &ao));
29   CHKERRQ(AODestroy(&ao));
30 
31   /* Test AOCreateMemoryScalable() */
32   CHKERRQ(AOCreateMemoryScalable(PETSC_COMM_WORLD, nlocal, localvert, NULL, &ao));
33   CHKERRQ(AODestroy(&ao));
34 
35   CHKERRQ(PetscFree(localvert));
36   CHKERRQ(PetscFinalize());
37   return 0;
38 }
39 
40 /*TEST
41 
42    test:
43 
44    test:
45       suffix: 2
46       nsize: 2
47       output_file: output/ex4_1.out
48 
49 TEST*/
50